MCPcopy
hub / github.com/nilbuild/driver.js / driver

Function driver

src/driver.ts:51–449  ·  view source on GitHub ↗
(options: Config = {})

Source from the content-addressed store, hash-verified

49}
50
51export function driver(options: Config = {}): Driver {
52 configure(options);
53
54 function handleClose() {
55 if (!getConfig("allowClose")) {
56 return;
57 }
58
59 destroy();
60 }
61
62 function handleOverlayClick() {
63 const overlayClickBehavior = getConfig("overlayClickBehavior");
64
65 if (getConfig("allowClose") && overlayClickBehavior === "close") {
66 destroy();
67 return;
68 }
69
70 if (typeof overlayClickBehavior === "function") {
71 const activeStep = getState("__activeStep");
72 const activeElement = getState("__activeElement");
73
74 overlayClickBehavior(activeElement, activeStep!, {
75 config: getConfig(),
76 state: getState(),
77 driver: getCurrentDriver(),
78 });
79
80 return;
81 }
82
83 if (overlayClickBehavior === "nextStep") {
84 const activeStep = getState("activeStep");
85 const activeElement = getState("activeElement");
86
87 const steps = getConfig("steps") || [];
88 const isLastStep = getState("activeIndex") === steps.length - 1;
89 const onDoneClick = activeStep?.popover?.onDoneClick || getConfig("onDoneClick");
90 if (isLastStep && onDoneClick) {
91 onDoneClick(activeElement, activeStep!, {
92 config: getConfig(),
93 state: getState(),
94 driver: getCurrentDriver(),
95 });
96 return;
97 }
98
99 const onNextClick = activeStep?.popover?.onNextClick || getConfig("onNextClick");
100 if (onNextClick) {
101 onNextClick(activeElement, activeStep!, {
102 config: getConfig(),
103 state: getState(),
104 driver: getCurrentDriver(),
105 });
106 return;
107 }
108

Callers 11

createDriverFunction · 0.90
onClickFunction · 0.85
FormHelpFunction · 0.85
tourWithDurationFunction · 0.85
runFunction · 0.85
runFunction · 0.85
runFunction · 0.85
tourWithScrollFunction · 0.85
runFunction · 0.85
runFunction · 0.85

Calls 9

configureFunction · 0.90
getStateFunction · 0.90
resetStateFunction · 0.90
getConfigFunction · 0.90
highlightFunction · 0.90
setCurrentDriverFunction · 0.90
initFunction · 0.85
driveFunction · 0.85
destroyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…