@destyler/tooltip 0.0.7-beta.7 → 0.1.0

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.ts CHANGED
@@ -1,146 +1,149 @@
1
- import * as _zag_js_anatomy from '@zag-js/anatomy';
2
- import { DirectionProperty, CommonProperties, 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 { PositioningOptions, Placement } from '@zag-js/popper';
6
- export { Placement, PositioningOptions } from '@zag-js/popper';
7
-
8
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"trigger" | "arrow" | "arrowTip" | "positioner" | "content">;
1
+ import * as _destyler_anatomy0 from "@destyler/anatomy";
2
+ import { Placement, PositioningOptions } from "@destyler/popper";
3
+ import * as _destyler_xstate0 from "@destyler/xstate";
4
+ import { AnyEventObject, Machine, XSend, XState } from "@destyler/xstate";
5
+ import { CommonProperties, DirectionProperty, NormalizeProps, PropTypes, RequiredBy } from "@destyler/types";
9
6
 
7
+ //#region src/anatomy.d.ts
8
+ declare const anatomy: _destyler_anatomy0.AnatomyInstance<"trigger" | "content" | "arrow" | "positioner" | "arrowTip">;
9
+ //#endregion
10
+ //#region src/types.d.ts
10
11
  interface OpenChangeDetails {
11
- open: boolean;
12
+ open: boolean;
12
13
  }
13
14
  type ElementIds = Partial<{
14
- trigger: string;
15
- content: string;
16
- arrow: string;
17
- positioner: string;
15
+ trigger: string;
16
+ content: string;
17
+ arrow: string;
18
+ positioner: string;
18
19
  }>;
19
20
  interface PublicContext extends DirectionProperty, CommonProperties {
20
- /**
21
- * The ids of the elements in the tooltip. Useful for composition.
22
- */
23
- 'ids'?: ElementIds | undefined;
24
- /**
25
- * The `id` of the tooltip.
26
- */
27
- 'id': string;
28
- /**
29
- * The open delay of the tooltip.
30
- * @default 1000
31
- */
32
- 'openDelay': number;
33
- /**
34
- * The close delay of the tooltip.
35
- * @default 500
36
- */
37
- 'closeDelay': number;
38
- /**
39
- * Whether to close the tooltip on pointerdown.
40
- * @default true
41
- */
42
- 'closeOnPointerDown': boolean;
43
- /**
44
- * Whether to close the tooltip when the Escape key is pressed.
45
- * @default true
46
- */
47
- 'closeOnEscape'?: boolean | undefined;
48
- /**
49
- * Whether the tooltip should close on scroll
50
- * @default true
51
- */
52
- 'closeOnScroll'?: boolean | undefined;
53
- /**
54
- * Whether the tooltip should close on click
55
- * @default true
56
- */
57
- 'closeOnClick'?: boolean | undefined;
58
- /**
59
- * Whether the tooltip's content is interactive.
60
- * In this mode, the tooltip will remain open when user hovers over the content.
61
- * @see https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus
62
- *
63
- * @default false
64
- */
65
- 'interactive': boolean;
66
- /**
67
- * Function called when the tooltip is opened.
68
- */
69
- 'onOpenChange'?: (details: OpenChangeDetails) => void;
70
- /**
71
- * Custom label for the tooltip.
72
- */
73
- 'aria-label'?: string | undefined;
74
- /**
75
- * The user provided options used to position the popover content
76
- */
77
- 'positioning': PositioningOptions;
78
- /**
79
- * Whether the tooltip is disabled
80
- */
81
- 'disabled'?: boolean | undefined;
82
- /**
83
- * Whether the tooltip is open
84
- */
85
- 'open'?: boolean | undefined;
86
- /**
87
- * Whether the tooltip is controlled by the user
88
- */
89
- 'open.controlled'?: boolean | undefined;
21
+ /**
22
+ * The ids of the elements in the tooltip. Useful for composition.
23
+ */
24
+ 'ids'?: ElementIds | undefined;
25
+ /**
26
+ * The `id` of the tooltip.
27
+ */
28
+ 'id': string;
29
+ /**
30
+ * The open delay of the tooltip.
31
+ * @default 1000
32
+ */
33
+ 'openDelay': number;
34
+ /**
35
+ * The close delay of the tooltip.
36
+ * @default 500
37
+ */
38
+ 'closeDelay': number;
39
+ /**
40
+ * Whether to close the tooltip on pointerdown.
41
+ * @default true
42
+ */
43
+ 'closeOnPointerDown': boolean;
44
+ /**
45
+ * Whether to close the tooltip when the Escape key is pressed.
46
+ * @default true
47
+ */
48
+ 'closeOnEscape'?: boolean | undefined;
49
+ /**
50
+ * Whether the tooltip should close on scroll
51
+ * @default true
52
+ */
53
+ 'closeOnScroll'?: boolean | undefined;
54
+ /**
55
+ * Whether the tooltip should close on click
56
+ * @default true
57
+ */
58
+ 'closeOnClick'?: boolean | undefined;
59
+ /**
60
+ * Whether the tooltip's content is interactive.
61
+ * In this mode, the tooltip will remain open when user hovers over the content.
62
+ * @see https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus
63
+ *
64
+ * @default false
65
+ */
66
+ 'interactive': boolean;
67
+ /**
68
+ * Function called when the tooltip is opened.
69
+ */
70
+ 'onOpenChange'?: (details: OpenChangeDetails) => void;
71
+ /**
72
+ * Custom label for the tooltip.
73
+ */
74
+ 'aria-label'?: string | undefined;
75
+ /**
76
+ * The user provided options used to position the popover content
77
+ */
78
+ 'positioning': PositioningOptions;
79
+ /**
80
+ * Whether the tooltip is disabled
81
+ */
82
+ 'disabled'?: boolean | undefined;
83
+ /**
84
+ * Whether the tooltip is open
85
+ */
86
+ 'open'?: boolean | undefined;
87
+ /**
88
+ * Whether the tooltip is controlled by the user
89
+ */
90
+ 'open.controlled'?: boolean | undefined;
90
91
  }
91
92
  type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
92
93
  type ComputedContext = Readonly<{
93
- /**
94
- * @computed Whether an `aria-label` is set.
95
- */
96
- hasAriaLabel: boolean;
94
+ /**
95
+ * @computed Whether an `aria-label` is set.
96
+ */
97
+ hasAriaLabel: boolean;
97
98
  }>;
98
99
  interface PrivateContext {
99
- /**
100
- * @internal
101
- * The computed placement of the tooltip.
102
- */
103
- currentPlacement?: Placement | undefined;
104
- /**
105
- * @internal
106
- * Whether the pointermove already opened the tooltip.
107
- */
108
- hasPointerMoveOpened?: boolean | undefined;
109
- }
110
- interface MachineContext extends PublicContext, ComputedContext, PrivateContext {
100
+ /**
101
+ * @internal
102
+ * The computed placement of the tooltip.
103
+ */
104
+ currentPlacement?: Placement | undefined;
105
+ /**
106
+ * @internal
107
+ * Whether the pointermove already opened the tooltip.
108
+ */
109
+ hasPointerMoveOpened?: boolean | undefined;
111
110
  }
111
+ interface MachineContext extends PublicContext, ComputedContext, PrivateContext {}
112
112
  interface MachineState {
113
- value: 'opening' | 'open' | 'closing' | 'closed';
114
- tags: 'open' | 'closed';
113
+ value: 'opening' | 'open' | 'closing' | 'closed';
114
+ tags: 'open' | 'closed';
115
115
  }
116
- type State = StateMachine.State<MachineContext, MachineState>;
117
- type Send = StateMachine.Send<StateMachine.AnyEventObject>;
118
- type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
116
+ type State = XState<MachineContext, MachineState>;
117
+ type Send = XSend<AnyEventObject>;
118
+ type Service = Machine<MachineContext, MachineState, AnyEventObject>;
119
119
  interface MachineApi<T extends PropTypes = PropTypes> {
120
- /**
121
- * Whether the tooltip is open.
122
- */
123
- open: boolean;
124
- /**
125
- * Function to open the tooltip.
126
- */
127
- setOpen: (open: boolean) => void;
128
- /**
129
- * Function to reposition the popover
130
- */
131
- reposition: (options?: Partial<PositioningOptions>) => void;
132
- getTriggerProps: () => T['button'];
133
- getArrowProps: () => T['element'];
134
- getArrowTipProps: () => T['element'];
135
- getPositionerProps: () => T['element'];
136
- getContentProps: () => T['element'];
120
+ /**
121
+ * Whether the tooltip is open.
122
+ */
123
+ open: boolean;
124
+ /**
125
+ * Function to open the tooltip.
126
+ */
127
+ setOpen: (open: boolean) => void;
128
+ /**
129
+ * Function to reposition the popover
130
+ */
131
+ reposition: (options?: Partial<PositioningOptions>) => void;
132
+ getTriggerProps: () => T['button'];
133
+ getArrowProps: () => T['element'];
134
+ getArrowTipProps: () => T['element'];
135
+ getPositionerProps: () => T['element'];
136
+ getContentProps: () => T['element'];
137
137
  }
138
-
138
+ //#endregion
139
+ //#region src/connect.d.ts
139
140
  declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
140
-
141
- declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
142
-
143
- declare const props: ("ids" | "id" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "aria-label" | "positioning" | "disabled" | "open" | "open.controlled" | "dir" | "getRootNode")[];
144
- declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "ids" | "id" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "aria-label" | "positioning" | "disabled" | "open" | "open.controlled" | "dir" | "getRootNode">];
145
-
146
- export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type OpenChangeDetails, type Service, anatomy, connect, machine, props, splitProps };
141
+ //#endregion
142
+ //#region src/machine.d.ts
143
+ declare function machine(userContext: UserDefinedContext): _destyler_xstate0.Machine<MachineContext, MachineState, _destyler_xstate0.AnyEventObject>;
144
+ //#endregion
145
+ //#region src/props.d.ts
146
+ declare const props: ("open" | "id" | "ids" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "aria-label" | "positioning" | "disabled" | "open.controlled" | "dir" | "getRootNode")[];
147
+ declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "open" | "id" | "ids" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "aria-label" | "positioning" | "disabled" | "open.controlled" | "dir" | "getRootNode">];
148
+ //#endregion
149
+ export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type OpenChangeDetails, type Placement, type PositioningOptions, type Service, anatomy, connect, machine, props, splitProps };