@destyler/dialog 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.cjs CHANGED
@@ -1,32 +1,343 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./shared/dialog.d09a7a95.cjs');
4
- require('vue');
5
- require('@destyler/primitive');
6
- require('@destyler/composition');
7
- require('@destyler/shared');
8
- require('@destyler/presence');
9
- require('@destyler/focus-scope');
10
- require('@destyler/dismissable-layer');
11
- require('@destyler/dismissable-layer/component');
12
- require('@destyler/directives');
13
- require('@destyler/teleport');
3
+ const anatomy$1 = require('@zag-js/anatomy');
4
+ const domQuery = require('@zag-js/dom-query');
5
+ const ariaHidden = require('@zag-js/aria-hidden');
6
+ const core = require('@zag-js/core');
7
+ const dismissable = require('@zag-js/dismissable');
8
+ const focusTrap = require('@zag-js/focus-trap');
9
+ const removeScroll = require('@zag-js/remove-scroll');
10
+ const utils = require('@zag-js/utils');
11
+ const types = require('@zag-js/types');
14
12
 
13
+ const anatomy = anatomy$1.createAnatomy("dialog").parts(
14
+ "trigger",
15
+ "backdrop",
16
+ "positioner",
17
+ "content",
18
+ "title",
19
+ "description",
20
+ "closeTrigger"
21
+ );
22
+ const parts = anatomy.build();
15
23
 
24
+ const dom = domQuery.createScope({
25
+ getPositionerId: (ctx) => ctx.ids?.positioner ?? `dialog:${ctx.id}:positioner`,
26
+ getBackdropId: (ctx) => ctx.ids?.backdrop ?? `dialog:${ctx.id}:backdrop`,
27
+ getContentId: (ctx) => ctx.ids?.content ?? `dialog:${ctx.id}:content`,
28
+ getTriggerId: (ctx) => ctx.ids?.trigger ?? `dialog:${ctx.id}:trigger`,
29
+ getTitleId: (ctx) => ctx.ids?.title ?? `dialog:${ctx.id}:title`,
30
+ getDescriptionId: (ctx) => ctx.ids?.description ?? `dialog:${ctx.id}:description`,
31
+ getCloseTriggerId: (ctx) => ctx.ids?.closeTrigger ?? `dialog:${ctx.id}:close`,
32
+ getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
33
+ getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
34
+ getBackdropEl: (ctx) => dom.getById(ctx, dom.getBackdropId(ctx)),
35
+ getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
36
+ getTitleEl: (ctx) => dom.getById(ctx, dom.getTitleId(ctx)),
37
+ getDescriptionEl: (ctx) => dom.getById(ctx, dom.getDescriptionId(ctx)),
38
+ getCloseTriggerEl: (ctx) => dom.getById(ctx, dom.getCloseTriggerId(ctx))
39
+ });
16
40
 
17
- exports.DialogClose = index.DialogClose;
18
- exports.DialogContent = index.DialogContent;
19
- exports.DialogDescription = index.DialogDescription;
20
- exports.DialogOverlay = index.DialogOverlay;
21
- exports.DialogPortal = index.DialogPortal;
22
- exports.DialogRoot = index.DialogRoot;
23
- exports.DialogTitle = index.DialogTitle;
24
- exports.DialogTrigger = index.DialogTrigger;
25
- exports.dialogCloseProps = index.dialogCloseProps;
26
- exports.dialogContentProps = index.dialogContentProps;
27
- exports.dialogDescriptionProps = index.dialogDescriptionProps;
28
- exports.dialogOverlayProps = index.dialogOverlayProps;
29
- exports.dialogPortalProps = index.dialogPortalProps;
30
- exports.dialogRootProps = index.dialogRootProps;
31
- exports.dialogTitleProps = index.dialogTitleProps;
32
- exports.dialogTriggerProps = index.dialogTriggerProps;
41
+ function connect(state, send, normalize) {
42
+ const ariaLabel = state.context["aria-label"];
43
+ const open = state.matches("open");
44
+ const rendered = state.context.renderedElements;
45
+ return {
46
+ open,
47
+ setOpen(nextOpen) {
48
+ if (nextOpen === open)
49
+ return;
50
+ send(nextOpen ? "OPEN" : "CLOSE");
51
+ },
52
+ getTriggerProps() {
53
+ return normalize.button({
54
+ ...parts.trigger.attrs,
55
+ "dir": state.context.dir,
56
+ "id": dom.getTriggerId(state.context),
57
+ "aria-haspopup": "dialog",
58
+ "type": "button",
59
+ "aria-expanded": open,
60
+ "data-state": open ? "open" : "closed",
61
+ "aria-controls": dom.getContentId(state.context),
62
+ onClick(event) {
63
+ if (event.defaultPrevented)
64
+ return;
65
+ send("TOGGLE");
66
+ }
67
+ });
68
+ },
69
+ getBackdropProps() {
70
+ return normalize.element({
71
+ ...parts.backdrop.attrs,
72
+ "dir": state.context.dir,
73
+ "hidden": !open,
74
+ "id": dom.getBackdropId(state.context),
75
+ "data-state": open ? "open" : "closed"
76
+ });
77
+ },
78
+ getPositionerProps() {
79
+ return normalize.element({
80
+ ...parts.positioner.attrs,
81
+ dir: state.context.dir,
82
+ id: dom.getPositionerId(state.context),
83
+ style: {
84
+ pointerEvents: open ? void 0 : "none"
85
+ }
86
+ });
87
+ },
88
+ getContentProps() {
89
+ return normalize.element({
90
+ ...parts.content.attrs,
91
+ "dir": state.context.dir,
92
+ "role": state.context.role,
93
+ "hidden": !open,
94
+ "id": dom.getContentId(state.context),
95
+ "tabIndex": -1,
96
+ "data-state": open ? "open" : "closed",
97
+ "aria-modal": true,
98
+ "aria-label": ariaLabel || void 0,
99
+ "aria-labelledby": ariaLabel || !rendered.title ? void 0 : dom.getTitleId(state.context),
100
+ "aria-describedby": rendered.description ? dom.getDescriptionId(state.context) : void 0
101
+ });
102
+ },
103
+ getTitleProps() {
104
+ return normalize.element({
105
+ ...parts.title.attrs,
106
+ dir: state.context.dir,
107
+ id: dom.getTitleId(state.context)
108
+ });
109
+ },
110
+ getDescriptionProps() {
111
+ return normalize.element({
112
+ ...parts.description.attrs,
113
+ dir: state.context.dir,
114
+ id: dom.getDescriptionId(state.context)
115
+ });
116
+ },
117
+ getCloseTriggerProps() {
118
+ return normalize.button({
119
+ ...parts.closeTrigger.attrs,
120
+ dir: state.context.dir,
121
+ id: dom.getCloseTriggerId(state.context),
122
+ type: "button",
123
+ onClick(event) {
124
+ if (event.defaultPrevented)
125
+ return;
126
+ event.stopPropagation();
127
+ send("CLOSE");
128
+ }
129
+ });
130
+ }
131
+ };
132
+ }
133
+
134
+ function machine(userContext) {
135
+ const ctx = utils.compact(userContext);
136
+ return core.createMachine(
137
+ {
138
+ id: "dialog",
139
+ initial: ctx.open ? "open" : "closed",
140
+ context: {
141
+ role: "dialog",
142
+ renderedElements: {
143
+ title: true,
144
+ description: true
145
+ },
146
+ modal: true,
147
+ trapFocus: true,
148
+ preventScroll: true,
149
+ closeOnInteractOutside: true,
150
+ closeOnEscape: true,
151
+ restoreFocus: true,
152
+ ...ctx
153
+ },
154
+ created: ["setAlertDialogProps"],
155
+ watch: {
156
+ open: ["toggleVisibility"]
157
+ },
158
+ states: {
159
+ open: {
160
+ entry: ["checkRenderedElements", "syncZIndex"],
161
+ activities: ["trackDismissableElement", "trapFocus", "preventScroll", "hideContentBelow"],
162
+ on: {
163
+ "CONTROLLED.CLOSE": {
164
+ target: "closed"
165
+ },
166
+ "CLOSE": [
167
+ {
168
+ guard: "isOpenControlled",
169
+ actions: ["invokeOnClose"]
170
+ },
171
+ {
172
+ target: "closed",
173
+ actions: ["invokeOnClose"]
174
+ }
175
+ ],
176
+ "TOGGLE": [
177
+ {
178
+ guard: "isOpenControlled",
179
+ actions: ["invokeOnClose"]
180
+ },
181
+ {
182
+ target: "closed",
183
+ actions: ["invokeOnClose"]
184
+ }
185
+ ]
186
+ }
187
+ },
188
+ closed: {
189
+ on: {
190
+ "CONTROLLED.OPEN": {
191
+ target: "open"
192
+ },
193
+ "OPEN": [
194
+ {
195
+ guard: "isOpenControlled",
196
+ actions: ["invokeOnOpen"]
197
+ },
198
+ {
199
+ target: "open",
200
+ actions: ["invokeOnOpen"]
201
+ }
202
+ ],
203
+ "TOGGLE": [
204
+ {
205
+ guard: "isOpenControlled",
206
+ actions: ["invokeOnOpen"]
207
+ },
208
+ {
209
+ target: "open",
210
+ actions: ["invokeOnOpen"]
211
+ }
212
+ ]
213
+ }
214
+ }
215
+ }
216
+ },
217
+ {
218
+ guards: {
219
+ isOpenControlled: (ctx2) => !!ctx2["open.controlled"]
220
+ },
221
+ activities: {
222
+ trackDismissableElement(ctx2, _evt, { send }) {
223
+ const getContentEl = () => dom.getContentEl(ctx2);
224
+ return dismissable.trackDismissableElement(getContentEl, {
225
+ defer: true,
226
+ pointerBlocking: ctx2.modal,
227
+ exclude: [dom.getTriggerEl(ctx2)],
228
+ onInteractOutside(event) {
229
+ ctx2.onInteractOutside?.(event);
230
+ if (!ctx2.closeOnInteractOutside) {
231
+ event.preventDefault();
232
+ }
233
+ },
234
+ persistentElements: ctx2.persistentElements,
235
+ onFocusOutside: ctx2.onFocusOutside,
236
+ onPointerDownOutside: ctx2.onPointerDownOutside,
237
+ onEscapeKeyDown(event) {
238
+ ctx2.onEscapeKeyDown?.(event);
239
+ if (!ctx2.closeOnEscape) {
240
+ event.preventDefault();
241
+ }
242
+ },
243
+ onDismiss() {
244
+ send({ type: "CLOSE", src: "interact-outside" });
245
+ }
246
+ });
247
+ },
248
+ preventScroll(ctx2) {
249
+ if (!ctx2.preventScroll)
250
+ return;
251
+ return removeScroll.preventBodyScroll(dom.getDoc(ctx2));
252
+ },
253
+ trapFocus(ctx2) {
254
+ if (!ctx2.trapFocus || !ctx2.modal)
255
+ return;
256
+ const contentEl = () => dom.getContentEl(ctx2);
257
+ return focusTrap.trapFocus(contentEl, {
258
+ preventScroll: true,
259
+ returnFocusOnDeactivate: !!ctx2.restoreFocus,
260
+ initialFocus: ctx2.initialFocusEl,
261
+ setReturnFocus: (el) => ctx2.finalFocusEl?.() ?? el
262
+ });
263
+ },
264
+ hideContentBelow(ctx2) {
265
+ if (!ctx2.modal)
266
+ return;
267
+ const getElements = () => [dom.getContentEl(ctx2)];
268
+ return ariaHidden.ariaHidden(getElements, { defer: true });
269
+ }
270
+ },
271
+ actions: {
272
+ setAlertDialogProps(ctx2) {
273
+ if (ctx2.role !== "alertdialog")
274
+ return;
275
+ ctx2.initialFocusEl ||= () => dom.getCloseTriggerEl(ctx2);
276
+ ctx2.closeOnInteractOutside = false;
277
+ },
278
+ checkRenderedElements(ctx2) {
279
+ domQuery.raf(() => {
280
+ ctx2.renderedElements.title = !!dom.getTitleEl(ctx2);
281
+ ctx2.renderedElements.description = !!dom.getDescriptionEl(ctx2);
282
+ });
283
+ },
284
+ syncZIndex(ctx2) {
285
+ domQuery.raf(() => {
286
+ const contentEl = dom.getContentEl(ctx2);
287
+ if (!contentEl)
288
+ return;
289
+ const win = dom.getWin(ctx2);
290
+ const styles = win.getComputedStyle(contentEl);
291
+ const elems = [dom.getPositionerEl(ctx2), dom.getBackdropEl(ctx2)];
292
+ elems.forEach((node) => {
293
+ node?.style.setProperty("--z-index", styles.zIndex);
294
+ });
295
+ });
296
+ },
297
+ invokeOnClose(ctx2) {
298
+ ctx2.onOpenChange?.({ open: false });
299
+ },
300
+ invokeOnOpen(ctx2) {
301
+ ctx2.onOpenChange?.({ open: true });
302
+ },
303
+ toggleVisibility(ctx2, evt, { send }) {
304
+ send({ type: ctx2.open ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE", previousEvent: evt });
305
+ }
306
+ }
307
+ }
308
+ );
309
+ }
310
+
311
+ const props = types.createProps()([
312
+ "aria-label",
313
+ "closeOnEscape",
314
+ "closeOnInteractOutside",
315
+ "dir",
316
+ "finalFocusEl",
317
+ "getRootNode",
318
+ "getRootNode",
319
+ "id",
320
+ "id",
321
+ "ids",
322
+ "initialFocusEl",
323
+ "modal",
324
+ "onEscapeKeyDown",
325
+ "onFocusOutside",
326
+ "onInteractOutside",
327
+ "onOpenChange",
328
+ "onPointerDownOutside",
329
+ "open.controlled",
330
+ "open",
331
+ "persistentElements",
332
+ "preventScroll",
333
+ "restoreFocus",
334
+ "role",
335
+ "trapFocus"
336
+ ]);
337
+ const splitProps = utils.createSplitProps(props);
338
+
339
+ exports.anatomy = anatomy;
340
+ exports.connect = connect;
341
+ exports.machine = machine;
342
+ exports.props = props;
343
+ exports.splitProps = splitProps;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,131 @@
1
- export { a as DialogClose, b as DialogCloseProps, c as DialogContent, g as DialogContentProps, h as DialogDescription, j as DialogDescriptionProps, k as DialogOverlay, z as DialogOverlayProps, l as DialogPortal, n as DialogPortalProps, o as DialogRoot, r as DialogRootProps, s as DialogTitle, u as DialogTitleProps, v as DialogTrigger, x as DialogTriggerProps, d as dialogCloseProps, e as dialogContentProps, i as dialogDescriptionProps, y as dialogOverlayProps, m as dialogPortalProps, p as dialogRootProps, t as dialogTitleProps, w as dialogTriggerProps } from './shared/dialog.f396ab6e.cjs';
2
- import 'vue';
3
- import '@destyler/shared';
4
- import '@destyler/primitive';
1
+ import * as _zag_js_anatomy from '@zag-js/anatomy';
2
+ import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, 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
+
8
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"trigger" | "backdrop" | "positioner" | "content" | "title" | "description" | "closeTrigger">;
9
+
10
+ interface OpenChangeDetails {
11
+ open: boolean;
12
+ }
13
+ type ElementIds = Partial<{
14
+ trigger: string;
15
+ positioner: string;
16
+ backdrop: string;
17
+ content: string;
18
+ closeTrigger: string;
19
+ title: string;
20
+ description: string;
21
+ }>;
22
+ interface PublicContext extends DirectionProperty, CommonProperties, DismissableElementHandlers, PersistentElementOptions {
23
+ /**
24
+ * The ids of the elements in the dialog. Useful for composition.
25
+ */
26
+ 'ids'?: ElementIds | undefined;
27
+ /**
28
+ * Whether to trap focus inside the dialog when it's opened
29
+ * @default true
30
+ */
31
+ 'trapFocus': boolean;
32
+ /**
33
+ * Whether to prevent scrolling behind the dialog when it's opened
34
+ * @default true
35
+ */
36
+ 'preventScroll': boolean;
37
+ /**
38
+ * Whether to prevent pointer interaction outside the element and hide all content below it
39
+ * @default true
40
+ */
41
+ 'modal'?: boolean | undefined;
42
+ /**
43
+ * Element to receive focus when the dialog is opened
44
+ */
45
+ 'initialFocusEl'?: (() => HTMLElement | null) | undefined;
46
+ /**
47
+ * Element to receive focus when the dialog is closed
48
+ */
49
+ 'finalFocusEl'?: (() => HTMLElement | null) | undefined;
50
+ /**
51
+ * Whether to restore focus to the element that had focus before the dialog was opened
52
+ */
53
+ 'restoreFocus'?: boolean | undefined;
54
+ /**
55
+ * Callback to be invoked when the dialog is opened or closed
56
+ */
57
+ 'onOpenChange'?: ((details: OpenChangeDetails) => void) | undefined;
58
+ /**
59
+ * Whether to close the dialog when the outside is clicked
60
+ * @default true
61
+ */
62
+ 'closeOnInteractOutside': boolean;
63
+ /**
64
+ * Whether to close the dialog when the escape key is pressed
65
+ * @default true
66
+ */
67
+ 'closeOnEscape': boolean;
68
+ /**
69
+ * Human readable label for the dialog, in event the dialog title is not rendered
70
+ */
71
+ 'aria-label'?: string | undefined;
72
+ /**
73
+ * The dialog's role
74
+ * @default "dialog"
75
+ */
76
+ 'role': 'dialog' | 'alertdialog';
77
+ /**
78
+ * Whether the dialog is open
79
+ */
80
+ 'open'?: boolean | undefined;
81
+ /**
82
+ * Whether the dialog is controlled by the user
83
+ */
84
+ 'open.controlled'?: boolean | undefined;
85
+ }
86
+ type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
87
+ type ComputedContext = Readonly<{}>;
88
+ interface PrivateContext {
89
+ /**
90
+ * @internal
91
+ * Whether some elements are rendered
92
+ */
93
+ renderedElements: {
94
+ title: boolean;
95
+ description: boolean;
96
+ };
97
+ }
98
+ interface MachineContext extends PublicContext, PrivateContext, ComputedContext {
99
+ }
100
+ interface MachineState {
101
+ value: 'open' | 'closed';
102
+ }
103
+ type State = StateMachine.State<MachineContext, MachineState>;
104
+ type Send = StateMachine.Send<StateMachine.AnyEventObject>;
105
+ type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
106
+ interface MachineApi<T extends PropTypes = PropTypes> {
107
+ /**
108
+ * Whether the dialog is open
109
+ */
110
+ open: boolean;
111
+ /**
112
+ * Function to open or close the dialog
113
+ */
114
+ setOpen: (open: boolean) => void;
115
+ getTriggerProps: () => T['button'];
116
+ getBackdropProps: () => T['element'];
117
+ getPositionerProps: () => T['element'];
118
+ getContentProps: () => T['element'];
119
+ getTitleProps: () => T['element'];
120
+ getDescriptionProps: () => T['element'];
121
+ getCloseTriggerProps: () => T['button'];
122
+ }
123
+
124
+ declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
125
+
126
+ declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
127
+
128
+ declare const props: ("ids" | "trapFocus" | "preventScroll" | "modal" | "initialFocusEl" | "finalFocusEl" | "restoreFocus" | "onOpenChange" | "closeOnInteractOutside" | "closeOnEscape" | "aria-label" | "role" | "open" | "open.controlled" | "dir" | "id" | "getRootNode" | "onEscapeKeyDown" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside" | "persistentElements")[];
129
+ declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "ids" | "trapFocus" | "preventScroll" | "modal" | "initialFocusEl" | "finalFocusEl" | "restoreFocus" | "onOpenChange" | "closeOnInteractOutside" | "closeOnEscape" | "aria-label" | "role" | "open" | "open.controlled" | "dir" | "id" | "getRootNode" | "onEscapeKeyDown" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside" | "persistentElements">];
130
+
131
+ export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type OpenChangeDetails, type Service, anatomy, connect, machine, props, splitProps };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,131 @@
1
- export { a as DialogClose, b as DialogCloseProps, c as DialogContent, g as DialogContentProps, h as DialogDescription, j as DialogDescriptionProps, k as DialogOverlay, z as DialogOverlayProps, l as DialogPortal, n as DialogPortalProps, o as DialogRoot, r as DialogRootProps, s as DialogTitle, u as DialogTitleProps, v as DialogTrigger, x as DialogTriggerProps, d as dialogCloseProps, e as dialogContentProps, i as dialogDescriptionProps, y as dialogOverlayProps, m as dialogPortalProps, p as dialogRootProps, t as dialogTitleProps, w as dialogTriggerProps } from './shared/dialog.f396ab6e.mjs';
2
- import 'vue';
3
- import '@destyler/shared';
4
- import '@destyler/primitive';
1
+ import * as _zag_js_anatomy from '@zag-js/anatomy';
2
+ import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, 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
+
8
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"trigger" | "backdrop" | "positioner" | "content" | "title" | "description" | "closeTrigger">;
9
+
10
+ interface OpenChangeDetails {
11
+ open: boolean;
12
+ }
13
+ type ElementIds = Partial<{
14
+ trigger: string;
15
+ positioner: string;
16
+ backdrop: string;
17
+ content: string;
18
+ closeTrigger: string;
19
+ title: string;
20
+ description: string;
21
+ }>;
22
+ interface PublicContext extends DirectionProperty, CommonProperties, DismissableElementHandlers, PersistentElementOptions {
23
+ /**
24
+ * The ids of the elements in the dialog. Useful for composition.
25
+ */
26
+ 'ids'?: ElementIds | undefined;
27
+ /**
28
+ * Whether to trap focus inside the dialog when it's opened
29
+ * @default true
30
+ */
31
+ 'trapFocus': boolean;
32
+ /**
33
+ * Whether to prevent scrolling behind the dialog when it's opened
34
+ * @default true
35
+ */
36
+ 'preventScroll': boolean;
37
+ /**
38
+ * Whether to prevent pointer interaction outside the element and hide all content below it
39
+ * @default true
40
+ */
41
+ 'modal'?: boolean | undefined;
42
+ /**
43
+ * Element to receive focus when the dialog is opened
44
+ */
45
+ 'initialFocusEl'?: (() => HTMLElement | null) | undefined;
46
+ /**
47
+ * Element to receive focus when the dialog is closed
48
+ */
49
+ 'finalFocusEl'?: (() => HTMLElement | null) | undefined;
50
+ /**
51
+ * Whether to restore focus to the element that had focus before the dialog was opened
52
+ */
53
+ 'restoreFocus'?: boolean | undefined;
54
+ /**
55
+ * Callback to be invoked when the dialog is opened or closed
56
+ */
57
+ 'onOpenChange'?: ((details: OpenChangeDetails) => void) | undefined;
58
+ /**
59
+ * Whether to close the dialog when the outside is clicked
60
+ * @default true
61
+ */
62
+ 'closeOnInteractOutside': boolean;
63
+ /**
64
+ * Whether to close the dialog when the escape key is pressed
65
+ * @default true
66
+ */
67
+ 'closeOnEscape': boolean;
68
+ /**
69
+ * Human readable label for the dialog, in event the dialog title is not rendered
70
+ */
71
+ 'aria-label'?: string | undefined;
72
+ /**
73
+ * The dialog's role
74
+ * @default "dialog"
75
+ */
76
+ 'role': 'dialog' | 'alertdialog';
77
+ /**
78
+ * Whether the dialog is open
79
+ */
80
+ 'open'?: boolean | undefined;
81
+ /**
82
+ * Whether the dialog is controlled by the user
83
+ */
84
+ 'open.controlled'?: boolean | undefined;
85
+ }
86
+ type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
87
+ type ComputedContext = Readonly<{}>;
88
+ interface PrivateContext {
89
+ /**
90
+ * @internal
91
+ * Whether some elements are rendered
92
+ */
93
+ renderedElements: {
94
+ title: boolean;
95
+ description: boolean;
96
+ };
97
+ }
98
+ interface MachineContext extends PublicContext, PrivateContext, ComputedContext {
99
+ }
100
+ interface MachineState {
101
+ value: 'open' | 'closed';
102
+ }
103
+ type State = StateMachine.State<MachineContext, MachineState>;
104
+ type Send = StateMachine.Send<StateMachine.AnyEventObject>;
105
+ type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
106
+ interface MachineApi<T extends PropTypes = PropTypes> {
107
+ /**
108
+ * Whether the dialog is open
109
+ */
110
+ open: boolean;
111
+ /**
112
+ * Function to open or close the dialog
113
+ */
114
+ setOpen: (open: boolean) => void;
115
+ getTriggerProps: () => T['button'];
116
+ getBackdropProps: () => T['element'];
117
+ getPositionerProps: () => T['element'];
118
+ getContentProps: () => T['element'];
119
+ getTitleProps: () => T['element'];
120
+ getDescriptionProps: () => T['element'];
121
+ getCloseTriggerProps: () => T['button'];
122
+ }
123
+
124
+ declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
125
+
126
+ declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
127
+
128
+ declare const props: ("ids" | "trapFocus" | "preventScroll" | "modal" | "initialFocusEl" | "finalFocusEl" | "restoreFocus" | "onOpenChange" | "closeOnInteractOutside" | "closeOnEscape" | "aria-label" | "role" | "open" | "open.controlled" | "dir" | "id" | "getRootNode" | "onEscapeKeyDown" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside" | "persistentElements")[];
129
+ declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "ids" | "trapFocus" | "preventScroll" | "modal" | "initialFocusEl" | "finalFocusEl" | "restoreFocus" | "onOpenChange" | "closeOnInteractOutside" | "closeOnEscape" | "aria-label" | "role" | "open" | "open.controlled" | "dir" | "id" | "getRootNode" | "onEscapeKeyDown" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside" | "persistentElements">];
130
+
131
+ export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type OpenChangeDetails, type Service, anatomy, connect, machine, props, splitProps };