@destyler/popover 0.0.5 → 0.0.7-beta.1

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.mts CHANGED
@@ -1,5 +1,152 @@
1
- export { a as PopoverArrow, b as PopoverArrowProps, c as PopoverClose, e as PopoverCloseProps, f as PopoverContent, i as PopoverContentProps, j as PopoverPortal, l as PopoverPortalProps, m as PopoverRoot, q as PopoverRootProps, r as PopoverTrigger, t as PopoverTriggerProps, p as popoverArrowProps, d as popoverCloseProps, g as popoverContentProps, k as popoverPortalProps, n as popoverRootProps, s as popoverTriggerProps } from './shared/popover.2b6be8bf.mjs';
2
- import '@destyler/primitive';
3
- import 'vue';
4
- import '@destyler/shared';
5
- import '@vue/shared';
1
+ import * as _zag_js_anatomy from '@zag-js/anatomy';
2
+ import { RequiredBy, PropTypes, CommonProperties, DirectionProperty, NormalizeProps } from '@zag-js/types';
3
+ import * as _zag_js_core from '@zag-js/core';
4
+ import { Machine, StateMachine } from '@zag-js/core';
5
+ import { DismissableElementHandlers, PersistentElementOptions } from '@zag-js/dismissable';
6
+ export { FocusOutsideEvent, InteractOutsideEvent, PointerDownOutsideEvent } from '@zag-js/dismissable';
7
+ import { PositioningOptions, Placement } from '@zag-js/popper';
8
+ export { Placement, PositioningOptions } from '@zag-js/popper';
9
+
10
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"arrow" | "arrowTip" | "anchor" | "trigger" | "indicator" | "positioner" | "content" | "title" | "description" | "closeTrigger">;
11
+
12
+ interface OpenChangeDetails {
13
+ open: boolean;
14
+ }
15
+ type ElementIds = Partial<{
16
+ anchor: string;
17
+ trigger: string;
18
+ content: string;
19
+ title: string;
20
+ description: string;
21
+ closeTrigger: string;
22
+ positioner: string;
23
+ arrow: string;
24
+ }>;
25
+ interface PublicContext extends CommonProperties, DirectionProperty, DismissableElementHandlers, PersistentElementOptions {
26
+ /**
27
+ * The ids of the elements in the popover. Useful for composition.
28
+ */
29
+ 'ids'?: ElementIds | undefined;
30
+ /**
31
+ * Whether the popover should be modal. When set to `true`:
32
+ * - interaction with outside elements will be disabled
33
+ * - only popover content will be visible to screen readers
34
+ * - scrolling is blocked
35
+ * - focus is trapped within the popover
36
+ *
37
+ * @default false
38
+ */
39
+ 'modal'?: boolean | undefined;
40
+ /**
41
+ * Whether the popover is portalled. This will proxy the tabbing behavior regardless of the DOM position
42
+ * of the popover content.
43
+ *
44
+ * @default true
45
+ */
46
+ 'portalled'?: boolean | undefined;
47
+ /**
48
+ * Whether to automatically set focus on the first focusable
49
+ * content within the popover when opened.
50
+ *
51
+ * @default true
52
+ */
53
+ 'autoFocus'?: boolean | undefined;
54
+ /**
55
+ * The element to focus on when the popover is opened.
56
+ */
57
+ 'initialFocusEl'?: (() => HTMLElement | null) | undefined;
58
+ /**
59
+ * Whether to close the popover when the user clicks outside of the popover.
60
+ * @default true
61
+ */
62
+ 'closeOnInteractOutside'?: boolean | undefined;
63
+ /**
64
+ * Whether to close the popover when the escape key is pressed.
65
+ * @default true
66
+ */
67
+ 'closeOnEscape'?: boolean | undefined;
68
+ /**
69
+ * Function invoked when the popover opens or closes
70
+ */
71
+ 'onOpenChange'?: ((details: OpenChangeDetails) => void) | undefined;
72
+ /**
73
+ * The user provided options used to position the popover content
74
+ */
75
+ 'positioning': PositioningOptions;
76
+ /**
77
+ * Whether the popover is open
78
+ */
79
+ 'open'?: boolean | undefined;
80
+ /**
81
+ * Whether the popover is controlled by the user
82
+ */
83
+ 'open.controlled'?: boolean | undefined;
84
+ }
85
+ type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
86
+ type ComputedContext = Readonly<{
87
+ /**
88
+ * @computed
89
+ * The computed value of `portalled`
90
+ */
91
+ currentPortalled: boolean;
92
+ }>;
93
+ interface PrivateContext {
94
+ /**
95
+ * @internal
96
+ * The elements that are rendered on mount
97
+ */
98
+ renderedElements: {
99
+ title: boolean;
100
+ description: boolean;
101
+ };
102
+ /**
103
+ * @internal
104
+ * The computed placement (maybe different from initial placement)
105
+ */
106
+ currentPlacement?: Placement | undefined;
107
+ }
108
+ interface MachineContext extends PublicContext, ComputedContext, PrivateContext {
109
+ }
110
+ interface MachineState {
111
+ value: 'open' | 'closed';
112
+ }
113
+ type State = StateMachine.State<MachineContext, MachineState>;
114
+ type Send = StateMachine.Send<StateMachine.AnyEventObject>;
115
+ type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
116
+ interface MachineApi<T extends PropTypes = PropTypes> {
117
+ /**
118
+ * Whether the popover is portalled.
119
+ */
120
+ portalled: boolean;
121
+ /**
122
+ * Whether the popover is open
123
+ */
124
+ open: boolean;
125
+ /**
126
+ * Function to open or close the popover
127
+ */
128
+ setOpen: (open: boolean) => void;
129
+ /**
130
+ * Function to reposition the popover
131
+ */
132
+ reposition: (options?: Partial<PositioningOptions>) => void;
133
+ getArrowProps: () => T['element'];
134
+ getArrowTipProps: () => T['element'];
135
+ getAnchorProps: () => T['element'];
136
+ getTriggerProps: () => T['button'];
137
+ getIndicatorProps: () => T['element'];
138
+ getPositionerProps: () => T['element'];
139
+ getContentProps: () => T['element'];
140
+ getTitleProps: () => T['element'];
141
+ getDescriptionProps: () => T['element'];
142
+ getCloseTriggerProps: () => T['button'];
143
+ }
144
+
145
+ declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
146
+
147
+ declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
148
+
149
+ declare const props: ("ids" | "modal" | "portalled" | "autoFocus" | "initialFocusEl" | "closeOnInteractOutside" | "closeOnEscape" | "onOpenChange" | "positioning" | "open" | "open.controlled" | "id" | "getRootNode" | "dir" | "onEscapeKeyDown" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside" | "persistentElements")[];
150
+ declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "ids" | "modal" | "portalled" | "autoFocus" | "initialFocusEl" | "closeOnInteractOutside" | "closeOnEscape" | "onOpenChange" | "positioning" | "open" | "open.controlled" | "id" | "getRootNode" | "dir" | "onEscapeKeyDown" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside" | "persistentElements">];
151
+
152
+ export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type OpenChangeDetails, type Service, anatomy, connect, machine, props, splitProps };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,152 @@
1
- export { a as PopoverArrow, b as PopoverArrowProps, c as PopoverClose, e as PopoverCloseProps, f as PopoverContent, i as PopoverContentProps, j as PopoverPortal, l as PopoverPortalProps, m as PopoverRoot, q as PopoverRootProps, r as PopoverTrigger, t as PopoverTriggerProps, p as popoverArrowProps, d as popoverCloseProps, g as popoverContentProps, k as popoverPortalProps, n as popoverRootProps, s as popoverTriggerProps } from './shared/popover.2b6be8bf.js';
2
- import '@destyler/primitive';
3
- import 'vue';
4
- import '@destyler/shared';
5
- import '@vue/shared';
1
+ import * as _zag_js_anatomy from '@zag-js/anatomy';
2
+ import { RequiredBy, PropTypes, CommonProperties, DirectionProperty, NormalizeProps } from '@zag-js/types';
3
+ import * as _zag_js_core from '@zag-js/core';
4
+ import { Machine, StateMachine } from '@zag-js/core';
5
+ import { DismissableElementHandlers, PersistentElementOptions } from '@zag-js/dismissable';
6
+ export { FocusOutsideEvent, InteractOutsideEvent, PointerDownOutsideEvent } from '@zag-js/dismissable';
7
+ import { PositioningOptions, Placement } from '@zag-js/popper';
8
+ export { Placement, PositioningOptions } from '@zag-js/popper';
9
+
10
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"arrow" | "arrowTip" | "anchor" | "trigger" | "indicator" | "positioner" | "content" | "title" | "description" | "closeTrigger">;
11
+
12
+ interface OpenChangeDetails {
13
+ open: boolean;
14
+ }
15
+ type ElementIds = Partial<{
16
+ anchor: string;
17
+ trigger: string;
18
+ content: string;
19
+ title: string;
20
+ description: string;
21
+ closeTrigger: string;
22
+ positioner: string;
23
+ arrow: string;
24
+ }>;
25
+ interface PublicContext extends CommonProperties, DirectionProperty, DismissableElementHandlers, PersistentElementOptions {
26
+ /**
27
+ * The ids of the elements in the popover. Useful for composition.
28
+ */
29
+ 'ids'?: ElementIds | undefined;
30
+ /**
31
+ * Whether the popover should be modal. When set to `true`:
32
+ * - interaction with outside elements will be disabled
33
+ * - only popover content will be visible to screen readers
34
+ * - scrolling is blocked
35
+ * - focus is trapped within the popover
36
+ *
37
+ * @default false
38
+ */
39
+ 'modal'?: boolean | undefined;
40
+ /**
41
+ * Whether the popover is portalled. This will proxy the tabbing behavior regardless of the DOM position
42
+ * of the popover content.
43
+ *
44
+ * @default true
45
+ */
46
+ 'portalled'?: boolean | undefined;
47
+ /**
48
+ * Whether to automatically set focus on the first focusable
49
+ * content within the popover when opened.
50
+ *
51
+ * @default true
52
+ */
53
+ 'autoFocus'?: boolean | undefined;
54
+ /**
55
+ * The element to focus on when the popover is opened.
56
+ */
57
+ 'initialFocusEl'?: (() => HTMLElement | null) | undefined;
58
+ /**
59
+ * Whether to close the popover when the user clicks outside of the popover.
60
+ * @default true
61
+ */
62
+ 'closeOnInteractOutside'?: boolean | undefined;
63
+ /**
64
+ * Whether to close the popover when the escape key is pressed.
65
+ * @default true
66
+ */
67
+ 'closeOnEscape'?: boolean | undefined;
68
+ /**
69
+ * Function invoked when the popover opens or closes
70
+ */
71
+ 'onOpenChange'?: ((details: OpenChangeDetails) => void) | undefined;
72
+ /**
73
+ * The user provided options used to position the popover content
74
+ */
75
+ 'positioning': PositioningOptions;
76
+ /**
77
+ * Whether the popover is open
78
+ */
79
+ 'open'?: boolean | undefined;
80
+ /**
81
+ * Whether the popover is controlled by the user
82
+ */
83
+ 'open.controlled'?: boolean | undefined;
84
+ }
85
+ type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
86
+ type ComputedContext = Readonly<{
87
+ /**
88
+ * @computed
89
+ * The computed value of `portalled`
90
+ */
91
+ currentPortalled: boolean;
92
+ }>;
93
+ interface PrivateContext {
94
+ /**
95
+ * @internal
96
+ * The elements that are rendered on mount
97
+ */
98
+ renderedElements: {
99
+ title: boolean;
100
+ description: boolean;
101
+ };
102
+ /**
103
+ * @internal
104
+ * The computed placement (maybe different from initial placement)
105
+ */
106
+ currentPlacement?: Placement | undefined;
107
+ }
108
+ interface MachineContext extends PublicContext, ComputedContext, PrivateContext {
109
+ }
110
+ interface MachineState {
111
+ value: 'open' | 'closed';
112
+ }
113
+ type State = StateMachine.State<MachineContext, MachineState>;
114
+ type Send = StateMachine.Send<StateMachine.AnyEventObject>;
115
+ type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
116
+ interface MachineApi<T extends PropTypes = PropTypes> {
117
+ /**
118
+ * Whether the popover is portalled.
119
+ */
120
+ portalled: boolean;
121
+ /**
122
+ * Whether the popover is open
123
+ */
124
+ open: boolean;
125
+ /**
126
+ * Function to open or close the popover
127
+ */
128
+ setOpen: (open: boolean) => void;
129
+ /**
130
+ * Function to reposition the popover
131
+ */
132
+ reposition: (options?: Partial<PositioningOptions>) => void;
133
+ getArrowProps: () => T['element'];
134
+ getArrowTipProps: () => T['element'];
135
+ getAnchorProps: () => T['element'];
136
+ getTriggerProps: () => T['button'];
137
+ getIndicatorProps: () => T['element'];
138
+ getPositionerProps: () => T['element'];
139
+ getContentProps: () => T['element'];
140
+ getTitleProps: () => T['element'];
141
+ getDescriptionProps: () => T['element'];
142
+ getCloseTriggerProps: () => T['button'];
143
+ }
144
+
145
+ declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
146
+
147
+ declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
148
+
149
+ declare const props: ("ids" | "modal" | "portalled" | "autoFocus" | "initialFocusEl" | "closeOnInteractOutside" | "closeOnEscape" | "onOpenChange" | "positioning" | "open" | "open.controlled" | "id" | "getRootNode" | "dir" | "onEscapeKeyDown" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside" | "persistentElements")[];
150
+ declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "ids" | "modal" | "portalled" | "autoFocus" | "initialFocusEl" | "closeOnInteractOutside" | "closeOnEscape" | "onOpenChange" | "positioning" | "open" | "open.controlled" | "id" | "getRootNode" | "dir" | "onEscapeKeyDown" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside" | "persistentElements">];
151
+
152
+ export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type OpenChangeDetails, type Service, anatomy, connect, machine, props, splitProps };