@destyler/tour 0.0.7-beta.5 → 0.0.7-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts DELETED
@@ -1,378 +0,0 @@
1
- import * as _zag_js_anatomy from '@zag-js/anatomy';
2
- import { DirectionProperty, CommonProperties, Required, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
3
- import * as _zag_js_core from '@zag-js/core';
4
- import { StateMachine, Machine } from '@zag-js/core';
5
- import { InteractOutsideHandlers } from '@zag-js/dismissable';
6
- export { FocusOutsideEvent, InteractOutsideEvent, PointerDownOutsideEvent } from '@zag-js/dismissable';
7
- import { Placement, AnchorRect } from '@zag-js/popper';
8
-
9
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"content" | "actionTrigger" | "closeTrigger" | "progressText" | "title" | "description" | "positioner" | "arrow" | "arrowTip" | "backdrop" | "spotlight">;
10
-
11
- interface Point {
12
- x: number;
13
- y: number;
14
- }
15
-
16
- interface StepEffectArgs {
17
- next: () => void;
18
- goto: (id: string) => void;
19
- dismiss: () => void;
20
- show: () => void;
21
- update: (data: Partial<StepBaseDetails>) => void;
22
- target?: (() => HTMLElement | null) | undefined;
23
- }
24
- type StepType = 'tooltip' | 'dialog' | 'wait' | 'floating';
25
- type StepActionType = 'next' | 'prev' | 'dismiss';
26
- type StepActionFn = (actionMap: StepActionMap) => void;
27
- type StepPlacement = Placement | 'center';
28
- interface StepAction {
29
- /**
30
- * The label of the action
31
- */
32
- label: string;
33
- /**
34
- * The action to perform
35
- */
36
- action?: StepActionType | StepActionFn | undefined;
37
- /**
38
- * The attributes to apply to the action trigger
39
- */
40
- attrs?: Record<string, any> | undefined;
41
- }
42
- interface StepBaseDetails {
43
- /**
44
- * The type of the step. If no target is provided,
45
- * the step will be treated as a modal step.
46
- */
47
- type?: StepType | undefined;
48
- /**
49
- * Function to return the target element to highlight
50
- */
51
- target?: () => HTMLElement | null;
52
- /**
53
- * The title of the step
54
- */
55
- title: any;
56
- /**
57
- * The description of the step
58
- */
59
- description: any;
60
- /**
61
- * The placement of the step
62
- */
63
- placement?: StepPlacement | undefined;
64
- /**
65
- * The offset between the content and the target
66
- */
67
- offset?: {
68
- mainAxis?: number;
69
- crossAxis?: number;
70
- } | undefined;
71
- /**
72
- * Additional metadata of the step
73
- */
74
- meta?: Record<string, any> | undefined;
75
- /**
76
- * Whether to show a backdrop behind the step
77
- */
78
- backdrop?: boolean | undefined;
79
- /**
80
- * Whether to show an arrow tip on the step
81
- */
82
- arrow?: boolean | undefined;
83
- /**
84
- * The actions to perform when the step is completed
85
- */
86
- actions?: StepAction[] | undefined;
87
- }
88
- interface StepDetails extends StepBaseDetails {
89
- /**
90
- * The unique identifier of the step
91
- */
92
- id: string;
93
- /**
94
- * The effect to run before the step is shown
95
- */
96
- effect?: (args: StepEffectArgs) => VoidFunction;
97
- }
98
- interface StepChangeDetails {
99
- stepId: string | null;
100
- stepIndex: number;
101
- totalSteps: number;
102
- complete: boolean;
103
- progress: number;
104
- }
105
- type StepStatus = 'idle' | 'started' | 'skipped' | 'completed' | 'dismissed' | 'not-found';
106
- interface StepActionMap {
107
- next: () => void;
108
- prev: () => void;
109
- dismiss: () => void;
110
- goto: (id: string) => void;
111
- }
112
- interface StatusChangeDetails {
113
- status: StepStatus;
114
- stepId: string | null;
115
- stepIndex: number;
116
- }
117
- interface ProgressTextDetails {
118
- current: number;
119
- total: number;
120
- }
121
- interface IntlTranslations {
122
- progressText?: (details: ProgressTextDetails) => string;
123
- nextStep?: string | undefined;
124
- prevStep?: string | undefined;
125
- close?: string | undefined;
126
- skip?: string | undefined;
127
- }
128
- type ElementIds = Partial<{
129
- content: string;
130
- title: string;
131
- description: string;
132
- positioner: string;
133
- backdrop: string;
134
- arrow: string;
135
- }>;
136
- interface PublicContext extends DirectionProperty, CommonProperties, InteractOutsideHandlers {
137
- /**
138
- * The ids of the elements in the tour. Useful for composition.
139
- */
140
- ids?: ElementIds | undefined;
141
- /**
142
- * The steps of the tour
143
- */
144
- steps: StepDetails[];
145
- /**
146
- * The id of the currently highlighted step
147
- */
148
- stepId: string | null;
149
- /**
150
- * Callback when the highlighted step changes
151
- */
152
- onStepChange?: (details: StepChangeDetails) => void;
153
- /**
154
- * Callback when the tour is opened or closed
155
- */
156
- onStatusChange?: (details: StatusChangeDetails) => void;
157
- /**
158
- * Whether to close the tour when the user clicks outside the tour
159
- * @default true
160
- */
161
- closeOnInteractOutside: boolean;
162
- /**
163
- * Whether to close the tour when the user presses the escape key
164
- * @default true
165
- */
166
- closeOnEscape: boolean;
167
- /**
168
- * Whether to allow keyboard navigation (right/left arrow keys to navigate between steps)
169
- * @default true
170
- */
171
- keyboardNavigation: boolean;
172
- /**
173
- * Prevents interaction with the rest of the page while the tour is open
174
- * @default false
175
- */
176
- preventInteraction: boolean;
177
- /**
178
- * The offsets to apply to the spotlight
179
- * @default "{ x: 10, y: 10 }"
180
- */
181
- spotlightOffset: Point;
182
- /**
183
- * The radius of the spotlight clip path
184
- * @default 4
185
- */
186
- spotlightRadius: number;
187
- /**
188
- * The translations for the tour
189
- */
190
- translations: IntlTranslations;
191
- }
192
- interface PrivateContext {
193
- /**
194
- * @internal
195
- * The rect of the current step's target element
196
- */
197
- targetRect: Required<AnchorRect>;
198
- /**
199
- * @internal
200
- * The current placement of the menu
201
- */
202
- currentPlacement?: StepPlacement | undefined;
203
- /**
204
- * @internal
205
- * The size of the boundary element (default to the window size)
206
- */
207
- boundarySize: {
208
- width: number;
209
- height: number;
210
- };
211
- /**
212
- * @internal
213
- * The function to cleanup the target attributes
214
- */
215
- _targetCleanup?: VoidFunction | undefined;
216
- /**
217
- * @internal
218
- * The function to cleanup the step effects
219
- */
220
- _effectCleanup?: VoidFunction | undefined;
221
- /**
222
- * @internal
223
- * The resolved target element
224
- */
225
- resolvedTarget: {
226
- value: HTMLElement | null;
227
- };
228
- }
229
- type ComputedContext = Readonly<{
230
- /**
231
- * The current step details
232
- */
233
- step: StepDetails | null;
234
- /**
235
- * The index of the current step
236
- */
237
- stepIndex: number;
238
- /**
239
- * Whether there is a next step
240
- */
241
- hasNextStep: boolean;
242
- /**
243
- * Whether there is a previous step
244
- */
245
- hasPrevStep: boolean;
246
- /**
247
- * Whether the current step is the first step
248
- */
249
- isFirstStep: boolean;
250
- /**
251
- * Whether the current step is the last step
252
- */
253
- isLastStep: boolean;
254
- }>;
255
- type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
256
- interface MachineContext extends PublicContext, PrivateContext, ComputedContext {
257
- }
258
- interface MachineState {
259
- tags: 'closed' | 'open';
260
- value: 'tour.inactive' | 'tour.active' | 'step.waiting' | 'target.resolving' | 'target.scrolling';
261
- }
262
- type State = StateMachine.State<MachineContext, MachineState>;
263
- type Send = StateMachine.Send<StateMachine.AnyEventObject>;
264
- type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
265
- interface StepActionTriggerProps {
266
- action: StepAction;
267
- }
268
- interface MachineApi<T extends PropTypes = PropTypes> {
269
- /**
270
- * Whether the tour is open
271
- */
272
- open: boolean;
273
- /**
274
- * The total number of steps
275
- */
276
- totalSteps: number;
277
- /**
278
- * The index of the current step
279
- */
280
- stepIndex: number;
281
- /**
282
- * The current step details
283
- */
284
- step: StepDetails | null;
285
- /**
286
- * Whether there is a next step
287
- */
288
- hasNextStep: boolean;
289
- /**
290
- * Whether there is a previous step
291
- */
292
- hasPrevStep: boolean;
293
- /**
294
- * Whether the current step is the first step
295
- */
296
- firstStep: boolean;
297
- /**
298
- * Whether the current step is the last step
299
- */
300
- lastStep: boolean;
301
- /**
302
- * Add a new step to the tour
303
- */
304
- addStep: (step: StepDetails) => void;
305
- /**
306
- * Remove a step from the tour
307
- */
308
- removeStep: (id: string) => void;
309
- /**
310
- * Update a step in the tour with partial details
311
- */
312
- updateStep: (id: string, stepOverrides: Partial<StepDetails>) => void;
313
- /**
314
- * Set the steps of the tour
315
- */
316
- setSteps: (steps: StepDetails[]) => void;
317
- /**
318
- * Set the current step of the tour
319
- */
320
- setStep: (id: string) => void;
321
- /**
322
- * Start the tour at a specific step (or the first step if not provided)
323
- */
324
- start: (id?: string) => void;
325
- /**
326
- * Check if a step is valid
327
- */
328
- isValidStep: (id: string) => boolean;
329
- /**
330
- * Check if a step is visible
331
- */
332
- isCurrentStep: (id: string) => boolean;
333
- /**
334
- * Move to the next step
335
- */
336
- next: () => void;
337
- /**
338
- * Move to the previous step
339
- */
340
- prev: () => void;
341
- /**
342
- * Returns the progress text
343
- */
344
- getProgressText: () => string;
345
- /**
346
- * Returns the progress percent
347
- */
348
- getProgressPercent: () => number;
349
- getBackdropProps: () => T['element'];
350
- getSpotlightProps: () => T['element'];
351
- getProgressTextProps: () => T['element'];
352
- getPositionerProps: () => T['element'];
353
- getArrowProps: () => T['element'];
354
- getArrowTipProps: () => T['element'];
355
- getContentProps: () => T['element'];
356
- getTitleProps: () => T['element'];
357
- getDescriptionProps: () => T['element'];
358
- getCloseTriggerProps: () => T['button'];
359
- getActionTriggerProps: (props: StepActionTriggerProps) => T['button'];
360
- }
361
-
362
- declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
363
-
364
- declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
365
-
366
- declare const props: ("ids" | "steps" | "stepId" | "onStepChange" | "onStatusChange" | "closeOnInteractOutside" | "closeOnEscape" | "keyboardNavigation" | "preventInteraction" | "spotlightOffset" | "spotlightRadius" | "translations" | "dir" | "id" | "getRootNode" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside")[];
367
- declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "ids" | "steps" | "stepId" | "onStepChange" | "onStatusChange" | "closeOnInteractOutside" | "closeOnEscape" | "keyboardNavigation" | "preventInteraction" | "spotlightOffset" | "spotlightRadius" | "translations" | "dir" | "id" | "getRootNode" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside">];
368
-
369
- interface WaitOptions {
370
- timeout: number;
371
- rootNode?: Document | ShadowRoot | undefined;
372
- }
373
- type WaitForPromiseReturn<T> = [Promise<T>, () => void];
374
- declare function waitForElement(target: () => HTMLElement, options: WaitOptions): WaitForPromiseReturn<HTMLElement>;
375
- type EditableElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
376
- declare function waitForElementValue(target: () => EditableElement | null, value: string, options: WaitOptions): WaitForPromiseReturn<void>;
377
-
378
- export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type IntlTranslations, type Point, type ProgressTextDetails, type Service, type StatusChangeDetails, type StepAction, type StepActionMap, type StepActionTriggerProps, type StepBaseDetails, type StepChangeDetails, type StepDetails, type StepEffectArgs, type StepPlacement, type StepStatus, type StepType, type WaitOptions, anatomy, connect, machine, props, splitProps, waitForElement, waitForElementValue };