@zag-js/popover 1.34.1 → 1.35.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.mts CHANGED
@@ -1,154 +1,10 @@
1
- import { DismissableElementHandlers, PersistentElementOptions } from '@zag-js/dismissable';
2
1
  export { FocusOutsideEvent, InteractOutsideEvent, PointerDownOutsideEvent } from '@zag-js/dismissable';
3
- import * as _zag_js_anatomy from '@zag-js/anatomy';
4
- import { PropTypes, RequiredBy, CommonProperties, DirectionProperty, NormalizeProps } from '@zag-js/types';
5
- import * as _zag_js_core from '@zag-js/core';
6
- import { Machine, EventObject, Service } from '@zag-js/core';
7
- import { PositioningOptions, Placement } from '@zag-js/popper';
2
+ export { anatomy } from './popover.anatomy.mjs';
3
+ export { connect } from './popover.connect.mjs';
4
+ export { machine } from './popover.machine.mjs';
5
+ export { props, splitProps } from './popover.props.mjs';
6
+ export { PopoverApi as Api, ElementIds, PopoverMachine as Machine, OpenChangeDetails, PopoverProps as Props, PopoverService as Service } from './popover.types.mjs';
8
7
  export { Placement, PositioningOptions } from '@zag-js/popper';
9
-
10
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"content" | "title" | "anchor" | "arrow" | "arrowTip" | "trigger" | "indicator" | "positioner" | "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 PopoverProps 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 | undefined;
76
- /**
77
- * The controlled open state of the popover
78
- */
79
- open?: boolean | undefined;
80
- /**
81
- * The initial open state of the popover when rendered.
82
- * Use when you don't need to control the open state of the popover.
83
- */
84
- defaultOpen?: boolean | undefined;
85
- }
86
- type PropsWithDefault = "closeOnInteractOutside" | "closeOnEscape" | "modal" | "portalled" | "autoFocus" | "positioning";
87
- type ComputedContext = Readonly<{
88
- /**
89
- * The computed value of `portalled`
90
- */
91
- currentPortalled: boolean;
92
- }>;
93
- interface PrivateContext {
94
- /**
95
- * The elements that are rendered on mount
96
- */
97
- renderedElements: {
98
- title: boolean;
99
- description: boolean;
100
- };
101
- /**
102
- * The computed placement (maybe different from initial placement)
103
- */
104
- currentPlacement?: Placement | undefined;
105
- }
106
- interface PopoverSchema {
107
- props: RequiredBy<PopoverProps, PropsWithDefault>;
108
- state: "open" | "closed";
109
- context: PrivateContext;
110
- computed: ComputedContext;
111
- event: EventObject;
112
- action: string;
113
- effect: string;
114
- guard: string;
115
- }
116
- type PopoverService = Service<PopoverSchema>;
117
- type PopoverMachine = Machine<PopoverSchema>;
118
- interface PopoverApi<T extends PropTypes = PropTypes> {
119
- /**
120
- * Whether the popover is portalled.
121
- */
122
- portalled: boolean;
123
- /**
124
- * Whether the popover is open
125
- */
126
- open: boolean;
127
- /**
128
- * Function to open or close the popover
129
- */
130
- setOpen: (open: boolean) => void;
131
- /**
132
- * Function to reposition the popover
133
- */
134
- reposition: (options?: Partial<PositioningOptions>) => void;
135
- getArrowProps: () => T["element"];
136
- getArrowTipProps: () => T["element"];
137
- getAnchorProps: () => T["element"];
138
- getTriggerProps: () => T["button"];
139
- getIndicatorProps: () => T["element"];
140
- getPositionerProps: () => T["element"];
141
- getContentProps: () => T["element"];
142
- getTitleProps: () => T["element"];
143
- getDescriptionProps: () => T["element"];
144
- getCloseTriggerProps: () => T["button"];
145
- }
146
-
147
- declare function connect<T extends PropTypes>(service: PopoverService, normalize: NormalizeProps<T>): PopoverApi<T>;
148
-
149
- declare const machine: _zag_js_core.Machine<PopoverSchema>;
150
-
151
- declare const props: (keyof PopoverProps)[];
152
- declare const splitProps: <Props extends Partial<PopoverProps>>(props: Props) => [Partial<PopoverProps>, Omit<Props, keyof PopoverProps>];
153
-
154
- export { type PopoverApi as Api, type ElementIds, type PopoverMachine as Machine, type OpenChangeDetails, type PopoverProps as Props, type PopoverService as Service, anatomy, connect, machine, props, splitProps };
8
+ import '@zag-js/anatomy';
9
+ import '@zag-js/types';
10
+ import '@zag-js/core';
package/dist/index.d.ts CHANGED
@@ -1,154 +1,10 @@
1
- import { DismissableElementHandlers, PersistentElementOptions } from '@zag-js/dismissable';
2
1
  export { FocusOutsideEvent, InteractOutsideEvent, PointerDownOutsideEvent } from '@zag-js/dismissable';
3
- import * as _zag_js_anatomy from '@zag-js/anatomy';
4
- import { PropTypes, RequiredBy, CommonProperties, DirectionProperty, NormalizeProps } from '@zag-js/types';
5
- import * as _zag_js_core from '@zag-js/core';
6
- import { Machine, EventObject, Service } from '@zag-js/core';
7
- import { PositioningOptions, Placement } from '@zag-js/popper';
2
+ export { anatomy } from './popover.anatomy.js';
3
+ export { connect } from './popover.connect.js';
4
+ export { machine } from './popover.machine.js';
5
+ export { props, splitProps } from './popover.props.js';
6
+ export { PopoverApi as Api, ElementIds, PopoverMachine as Machine, OpenChangeDetails, PopoverProps as Props, PopoverService as Service } from './popover.types.js';
8
7
  export { Placement, PositioningOptions } from '@zag-js/popper';
9
-
10
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"content" | "title" | "anchor" | "arrow" | "arrowTip" | "trigger" | "indicator" | "positioner" | "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 PopoverProps 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 | undefined;
76
- /**
77
- * The controlled open state of the popover
78
- */
79
- open?: boolean | undefined;
80
- /**
81
- * The initial open state of the popover when rendered.
82
- * Use when you don't need to control the open state of the popover.
83
- */
84
- defaultOpen?: boolean | undefined;
85
- }
86
- type PropsWithDefault = "closeOnInteractOutside" | "closeOnEscape" | "modal" | "portalled" | "autoFocus" | "positioning";
87
- type ComputedContext = Readonly<{
88
- /**
89
- * The computed value of `portalled`
90
- */
91
- currentPortalled: boolean;
92
- }>;
93
- interface PrivateContext {
94
- /**
95
- * The elements that are rendered on mount
96
- */
97
- renderedElements: {
98
- title: boolean;
99
- description: boolean;
100
- };
101
- /**
102
- * The computed placement (maybe different from initial placement)
103
- */
104
- currentPlacement?: Placement | undefined;
105
- }
106
- interface PopoverSchema {
107
- props: RequiredBy<PopoverProps, PropsWithDefault>;
108
- state: "open" | "closed";
109
- context: PrivateContext;
110
- computed: ComputedContext;
111
- event: EventObject;
112
- action: string;
113
- effect: string;
114
- guard: string;
115
- }
116
- type PopoverService = Service<PopoverSchema>;
117
- type PopoverMachine = Machine<PopoverSchema>;
118
- interface PopoverApi<T extends PropTypes = PropTypes> {
119
- /**
120
- * Whether the popover is portalled.
121
- */
122
- portalled: boolean;
123
- /**
124
- * Whether the popover is open
125
- */
126
- open: boolean;
127
- /**
128
- * Function to open or close the popover
129
- */
130
- setOpen: (open: boolean) => void;
131
- /**
132
- * Function to reposition the popover
133
- */
134
- reposition: (options?: Partial<PositioningOptions>) => void;
135
- getArrowProps: () => T["element"];
136
- getArrowTipProps: () => T["element"];
137
- getAnchorProps: () => T["element"];
138
- getTriggerProps: () => T["button"];
139
- getIndicatorProps: () => T["element"];
140
- getPositionerProps: () => T["element"];
141
- getContentProps: () => T["element"];
142
- getTitleProps: () => T["element"];
143
- getDescriptionProps: () => T["element"];
144
- getCloseTriggerProps: () => T["button"];
145
- }
146
-
147
- declare function connect<T extends PropTypes>(service: PopoverService, normalize: NormalizeProps<T>): PopoverApi<T>;
148
-
149
- declare const machine: _zag_js_core.Machine<PopoverSchema>;
150
-
151
- declare const props: (keyof PopoverProps)[];
152
- declare const splitProps: <Props extends Partial<PopoverProps>>(props: Props) => [Partial<PopoverProps>, Omit<Props, keyof PopoverProps>];
153
-
154
- export { type PopoverApi as Api, type ElementIds, type PopoverMachine as Machine, type OpenChangeDetails, type PopoverProps as Props, type PopoverService as Service, anatomy, connect, machine, props, splitProps };
8
+ import '@zag-js/anatomy';
9
+ import '@zag-js/types';
10
+ import '@zag-js/core';