@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 +338 -27
- package/dist/index.d.cts +131 -4
- package/dist/index.d.mts +131 -4
- package/dist/index.d.ts +131 -4
- package/dist/index.mjs +337 -11
- package/package.json +11 -20
- package/README.md +0 -7
- package/dist/component.cjs +0 -40
- package/dist/component.d.cts +0 -453
- package/dist/component.d.mts +0 -453
- package/dist/component.d.ts +0 -453
- package/dist/component.mjs +0 -11
- package/dist/resolver.cjs +0 -27
- package/dist/resolver.d.cts +0 -6
- package/dist/resolver.d.mts +0 -6
- package/dist/resolver.d.ts +0 -6
- package/dist/resolver.mjs +0 -24
- package/dist/shared/dialog.1e7a01aa.mjs +0 -514
- package/dist/shared/dialog.d09a7a95.cjs +0 -540
- package/dist/shared/dialog.f396ab6e.d.cts +0 -622
- package/dist/shared/dialog.f396ab6e.d.mts +0 -622
- package/dist/shared/dialog.f396ab6e.d.ts +0 -622
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,131 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import '@
|
|
4
|
-
import '@
|
|
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.mjs
CHANGED
|
@@ -1,11 +1,337 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import '@
|
|
4
|
-
import '@
|
|
5
|
-
import '@
|
|
6
|
-
import '@
|
|
7
|
-
import '@
|
|
8
|
-
import '@
|
|
9
|
-
import '@
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { createAnatomy } from '@zag-js/anatomy';
|
|
2
|
+
import { createScope, raf } from '@zag-js/dom-query';
|
|
3
|
+
import { ariaHidden } from '@zag-js/aria-hidden';
|
|
4
|
+
import { createMachine } from '@zag-js/core';
|
|
5
|
+
import { trackDismissableElement } from '@zag-js/dismissable';
|
|
6
|
+
import { trapFocus } from '@zag-js/focus-trap';
|
|
7
|
+
import { preventBodyScroll } from '@zag-js/remove-scroll';
|
|
8
|
+
import { compact, createSplitProps } from '@zag-js/utils';
|
|
9
|
+
import { createProps } from '@zag-js/types';
|
|
10
|
+
|
|
11
|
+
const anatomy = createAnatomy("dialog").parts(
|
|
12
|
+
"trigger",
|
|
13
|
+
"backdrop",
|
|
14
|
+
"positioner",
|
|
15
|
+
"content",
|
|
16
|
+
"title",
|
|
17
|
+
"description",
|
|
18
|
+
"closeTrigger"
|
|
19
|
+
);
|
|
20
|
+
const parts = anatomy.build();
|
|
21
|
+
|
|
22
|
+
const dom = createScope({
|
|
23
|
+
getPositionerId: (ctx) => ctx.ids?.positioner ?? `dialog:${ctx.id}:positioner`,
|
|
24
|
+
getBackdropId: (ctx) => ctx.ids?.backdrop ?? `dialog:${ctx.id}:backdrop`,
|
|
25
|
+
getContentId: (ctx) => ctx.ids?.content ?? `dialog:${ctx.id}:content`,
|
|
26
|
+
getTriggerId: (ctx) => ctx.ids?.trigger ?? `dialog:${ctx.id}:trigger`,
|
|
27
|
+
getTitleId: (ctx) => ctx.ids?.title ?? `dialog:${ctx.id}:title`,
|
|
28
|
+
getDescriptionId: (ctx) => ctx.ids?.description ?? `dialog:${ctx.id}:description`,
|
|
29
|
+
getCloseTriggerId: (ctx) => ctx.ids?.closeTrigger ?? `dialog:${ctx.id}:close`,
|
|
30
|
+
getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
|
|
31
|
+
getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
|
|
32
|
+
getBackdropEl: (ctx) => dom.getById(ctx, dom.getBackdropId(ctx)),
|
|
33
|
+
getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
|
|
34
|
+
getTitleEl: (ctx) => dom.getById(ctx, dom.getTitleId(ctx)),
|
|
35
|
+
getDescriptionEl: (ctx) => dom.getById(ctx, dom.getDescriptionId(ctx)),
|
|
36
|
+
getCloseTriggerEl: (ctx) => dom.getById(ctx, dom.getCloseTriggerId(ctx))
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
function connect(state, send, normalize) {
|
|
40
|
+
const ariaLabel = state.context["aria-label"];
|
|
41
|
+
const open = state.matches("open");
|
|
42
|
+
const rendered = state.context.renderedElements;
|
|
43
|
+
return {
|
|
44
|
+
open,
|
|
45
|
+
setOpen(nextOpen) {
|
|
46
|
+
if (nextOpen === open)
|
|
47
|
+
return;
|
|
48
|
+
send(nextOpen ? "OPEN" : "CLOSE");
|
|
49
|
+
},
|
|
50
|
+
getTriggerProps() {
|
|
51
|
+
return normalize.button({
|
|
52
|
+
...parts.trigger.attrs,
|
|
53
|
+
"dir": state.context.dir,
|
|
54
|
+
"id": dom.getTriggerId(state.context),
|
|
55
|
+
"aria-haspopup": "dialog",
|
|
56
|
+
"type": "button",
|
|
57
|
+
"aria-expanded": open,
|
|
58
|
+
"data-state": open ? "open" : "closed",
|
|
59
|
+
"aria-controls": dom.getContentId(state.context),
|
|
60
|
+
onClick(event) {
|
|
61
|
+
if (event.defaultPrevented)
|
|
62
|
+
return;
|
|
63
|
+
send("TOGGLE");
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
getBackdropProps() {
|
|
68
|
+
return normalize.element({
|
|
69
|
+
...parts.backdrop.attrs,
|
|
70
|
+
"dir": state.context.dir,
|
|
71
|
+
"hidden": !open,
|
|
72
|
+
"id": dom.getBackdropId(state.context),
|
|
73
|
+
"data-state": open ? "open" : "closed"
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
getPositionerProps() {
|
|
77
|
+
return normalize.element({
|
|
78
|
+
...parts.positioner.attrs,
|
|
79
|
+
dir: state.context.dir,
|
|
80
|
+
id: dom.getPositionerId(state.context),
|
|
81
|
+
style: {
|
|
82
|
+
pointerEvents: open ? void 0 : "none"
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
getContentProps() {
|
|
87
|
+
return normalize.element({
|
|
88
|
+
...parts.content.attrs,
|
|
89
|
+
"dir": state.context.dir,
|
|
90
|
+
"role": state.context.role,
|
|
91
|
+
"hidden": !open,
|
|
92
|
+
"id": dom.getContentId(state.context),
|
|
93
|
+
"tabIndex": -1,
|
|
94
|
+
"data-state": open ? "open" : "closed",
|
|
95
|
+
"aria-modal": true,
|
|
96
|
+
"aria-label": ariaLabel || void 0,
|
|
97
|
+
"aria-labelledby": ariaLabel || !rendered.title ? void 0 : dom.getTitleId(state.context),
|
|
98
|
+
"aria-describedby": rendered.description ? dom.getDescriptionId(state.context) : void 0
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
getTitleProps() {
|
|
102
|
+
return normalize.element({
|
|
103
|
+
...parts.title.attrs,
|
|
104
|
+
dir: state.context.dir,
|
|
105
|
+
id: dom.getTitleId(state.context)
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
getDescriptionProps() {
|
|
109
|
+
return normalize.element({
|
|
110
|
+
...parts.description.attrs,
|
|
111
|
+
dir: state.context.dir,
|
|
112
|
+
id: dom.getDescriptionId(state.context)
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
getCloseTriggerProps() {
|
|
116
|
+
return normalize.button({
|
|
117
|
+
...parts.closeTrigger.attrs,
|
|
118
|
+
dir: state.context.dir,
|
|
119
|
+
id: dom.getCloseTriggerId(state.context),
|
|
120
|
+
type: "button",
|
|
121
|
+
onClick(event) {
|
|
122
|
+
if (event.defaultPrevented)
|
|
123
|
+
return;
|
|
124
|
+
event.stopPropagation();
|
|
125
|
+
send("CLOSE");
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function machine(userContext) {
|
|
133
|
+
const ctx = compact(userContext);
|
|
134
|
+
return createMachine(
|
|
135
|
+
{
|
|
136
|
+
id: "dialog",
|
|
137
|
+
initial: ctx.open ? "open" : "closed",
|
|
138
|
+
context: {
|
|
139
|
+
role: "dialog",
|
|
140
|
+
renderedElements: {
|
|
141
|
+
title: true,
|
|
142
|
+
description: true
|
|
143
|
+
},
|
|
144
|
+
modal: true,
|
|
145
|
+
trapFocus: true,
|
|
146
|
+
preventScroll: true,
|
|
147
|
+
closeOnInteractOutside: true,
|
|
148
|
+
closeOnEscape: true,
|
|
149
|
+
restoreFocus: true,
|
|
150
|
+
...ctx
|
|
151
|
+
},
|
|
152
|
+
created: ["setAlertDialogProps"],
|
|
153
|
+
watch: {
|
|
154
|
+
open: ["toggleVisibility"]
|
|
155
|
+
},
|
|
156
|
+
states: {
|
|
157
|
+
open: {
|
|
158
|
+
entry: ["checkRenderedElements", "syncZIndex"],
|
|
159
|
+
activities: ["trackDismissableElement", "trapFocus", "preventScroll", "hideContentBelow"],
|
|
160
|
+
on: {
|
|
161
|
+
"CONTROLLED.CLOSE": {
|
|
162
|
+
target: "closed"
|
|
163
|
+
},
|
|
164
|
+
"CLOSE": [
|
|
165
|
+
{
|
|
166
|
+
guard: "isOpenControlled",
|
|
167
|
+
actions: ["invokeOnClose"]
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
target: "closed",
|
|
171
|
+
actions: ["invokeOnClose"]
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
"TOGGLE": [
|
|
175
|
+
{
|
|
176
|
+
guard: "isOpenControlled",
|
|
177
|
+
actions: ["invokeOnClose"]
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
target: "closed",
|
|
181
|
+
actions: ["invokeOnClose"]
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
closed: {
|
|
187
|
+
on: {
|
|
188
|
+
"CONTROLLED.OPEN": {
|
|
189
|
+
target: "open"
|
|
190
|
+
},
|
|
191
|
+
"OPEN": [
|
|
192
|
+
{
|
|
193
|
+
guard: "isOpenControlled",
|
|
194
|
+
actions: ["invokeOnOpen"]
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
target: "open",
|
|
198
|
+
actions: ["invokeOnOpen"]
|
|
199
|
+
}
|
|
200
|
+
],
|
|
201
|
+
"TOGGLE": [
|
|
202
|
+
{
|
|
203
|
+
guard: "isOpenControlled",
|
|
204
|
+
actions: ["invokeOnOpen"]
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
target: "open",
|
|
208
|
+
actions: ["invokeOnOpen"]
|
|
209
|
+
}
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
guards: {
|
|
217
|
+
isOpenControlled: (ctx2) => !!ctx2["open.controlled"]
|
|
218
|
+
},
|
|
219
|
+
activities: {
|
|
220
|
+
trackDismissableElement(ctx2, _evt, { send }) {
|
|
221
|
+
const getContentEl = () => dom.getContentEl(ctx2);
|
|
222
|
+
return trackDismissableElement(getContentEl, {
|
|
223
|
+
defer: true,
|
|
224
|
+
pointerBlocking: ctx2.modal,
|
|
225
|
+
exclude: [dom.getTriggerEl(ctx2)],
|
|
226
|
+
onInteractOutside(event) {
|
|
227
|
+
ctx2.onInteractOutside?.(event);
|
|
228
|
+
if (!ctx2.closeOnInteractOutside) {
|
|
229
|
+
event.preventDefault();
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
persistentElements: ctx2.persistentElements,
|
|
233
|
+
onFocusOutside: ctx2.onFocusOutside,
|
|
234
|
+
onPointerDownOutside: ctx2.onPointerDownOutside,
|
|
235
|
+
onEscapeKeyDown(event) {
|
|
236
|
+
ctx2.onEscapeKeyDown?.(event);
|
|
237
|
+
if (!ctx2.closeOnEscape) {
|
|
238
|
+
event.preventDefault();
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
onDismiss() {
|
|
242
|
+
send({ type: "CLOSE", src: "interact-outside" });
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
},
|
|
246
|
+
preventScroll(ctx2) {
|
|
247
|
+
if (!ctx2.preventScroll)
|
|
248
|
+
return;
|
|
249
|
+
return preventBodyScroll(dom.getDoc(ctx2));
|
|
250
|
+
},
|
|
251
|
+
trapFocus(ctx2) {
|
|
252
|
+
if (!ctx2.trapFocus || !ctx2.modal)
|
|
253
|
+
return;
|
|
254
|
+
const contentEl = () => dom.getContentEl(ctx2);
|
|
255
|
+
return trapFocus(contentEl, {
|
|
256
|
+
preventScroll: true,
|
|
257
|
+
returnFocusOnDeactivate: !!ctx2.restoreFocus,
|
|
258
|
+
initialFocus: ctx2.initialFocusEl,
|
|
259
|
+
setReturnFocus: (el) => ctx2.finalFocusEl?.() ?? el
|
|
260
|
+
});
|
|
261
|
+
},
|
|
262
|
+
hideContentBelow(ctx2) {
|
|
263
|
+
if (!ctx2.modal)
|
|
264
|
+
return;
|
|
265
|
+
const getElements = () => [dom.getContentEl(ctx2)];
|
|
266
|
+
return ariaHidden(getElements, { defer: true });
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
actions: {
|
|
270
|
+
setAlertDialogProps(ctx2) {
|
|
271
|
+
if (ctx2.role !== "alertdialog")
|
|
272
|
+
return;
|
|
273
|
+
ctx2.initialFocusEl ||= () => dom.getCloseTriggerEl(ctx2);
|
|
274
|
+
ctx2.closeOnInteractOutside = false;
|
|
275
|
+
},
|
|
276
|
+
checkRenderedElements(ctx2) {
|
|
277
|
+
raf(() => {
|
|
278
|
+
ctx2.renderedElements.title = !!dom.getTitleEl(ctx2);
|
|
279
|
+
ctx2.renderedElements.description = !!dom.getDescriptionEl(ctx2);
|
|
280
|
+
});
|
|
281
|
+
},
|
|
282
|
+
syncZIndex(ctx2) {
|
|
283
|
+
raf(() => {
|
|
284
|
+
const contentEl = dom.getContentEl(ctx2);
|
|
285
|
+
if (!contentEl)
|
|
286
|
+
return;
|
|
287
|
+
const win = dom.getWin(ctx2);
|
|
288
|
+
const styles = win.getComputedStyle(contentEl);
|
|
289
|
+
const elems = [dom.getPositionerEl(ctx2), dom.getBackdropEl(ctx2)];
|
|
290
|
+
elems.forEach((node) => {
|
|
291
|
+
node?.style.setProperty("--z-index", styles.zIndex);
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
},
|
|
295
|
+
invokeOnClose(ctx2) {
|
|
296
|
+
ctx2.onOpenChange?.({ open: false });
|
|
297
|
+
},
|
|
298
|
+
invokeOnOpen(ctx2) {
|
|
299
|
+
ctx2.onOpenChange?.({ open: true });
|
|
300
|
+
},
|
|
301
|
+
toggleVisibility(ctx2, evt, { send }) {
|
|
302
|
+
send({ type: ctx2.open ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE", previousEvent: evt });
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const props = createProps()([
|
|
310
|
+
"aria-label",
|
|
311
|
+
"closeOnEscape",
|
|
312
|
+
"closeOnInteractOutside",
|
|
313
|
+
"dir",
|
|
314
|
+
"finalFocusEl",
|
|
315
|
+
"getRootNode",
|
|
316
|
+
"getRootNode",
|
|
317
|
+
"id",
|
|
318
|
+
"id",
|
|
319
|
+
"ids",
|
|
320
|
+
"initialFocusEl",
|
|
321
|
+
"modal",
|
|
322
|
+
"onEscapeKeyDown",
|
|
323
|
+
"onFocusOutside",
|
|
324
|
+
"onInteractOutside",
|
|
325
|
+
"onOpenChange",
|
|
326
|
+
"onPointerDownOutside",
|
|
327
|
+
"open.controlled",
|
|
328
|
+
"open",
|
|
329
|
+
"persistentElements",
|
|
330
|
+
"preventScroll",
|
|
331
|
+
"restoreFocus",
|
|
332
|
+
"role",
|
|
333
|
+
"trapFocus"
|
|
334
|
+
]);
|
|
335
|
+
const splitProps = createSplitProps(props);
|
|
336
|
+
|
|
337
|
+
export { anatomy, connect, machine, props, splitProps };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@destyler/dialog",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7-beta.1",
|
|
5
5
|
"description": "before taking action, please confirm.",
|
|
6
6
|
"author": "Elone Hoo <elonehoo@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -10,14 +10,6 @@
|
|
|
10
10
|
"types": "./dist/index.d.mts",
|
|
11
11
|
"default": "./dist/index.mjs"
|
|
12
12
|
},
|
|
13
|
-
"./resolver": {
|
|
14
|
-
"types": "./dist/resolver.d.mts",
|
|
15
|
-
"default": "./dist/resolver.mjs"
|
|
16
|
-
},
|
|
17
|
-
"./component": {
|
|
18
|
-
"types": "./dist/component.d.mts",
|
|
19
|
-
"default": "./dist/component.mjs"
|
|
20
|
-
},
|
|
21
13
|
"./*": "./*"
|
|
22
14
|
},
|
|
23
15
|
"main": "dist/index.cjs",
|
|
@@ -27,21 +19,20 @@
|
|
|
27
19
|
"*.d.ts",
|
|
28
20
|
"dist"
|
|
29
21
|
],
|
|
30
|
-
"peerDependencies": {
|
|
31
|
-
"vue": ">=3.4.21"
|
|
32
|
-
},
|
|
33
22
|
"dependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
23
|
+
"@zag-js/anatomy": "^0.80.0",
|
|
24
|
+
"@zag-js/aria-hidden": "^0.80.0",
|
|
25
|
+
"@zag-js/core": "^0.80.0",
|
|
26
|
+
"@zag-js/dismissable": "^0.80.0",
|
|
27
|
+
"@zag-js/dom-query": "^0.80.0",
|
|
28
|
+
"@zag-js/focus-trap": "^0.80.0",
|
|
29
|
+
"@zag-js/remove-scroll": "^0.80.0",
|
|
30
|
+
"@zag-js/types": "^0.80.0",
|
|
31
|
+
"@zag-js/utils": "^0.80.0"
|
|
42
32
|
},
|
|
43
33
|
"scripts": {
|
|
44
34
|
"clear": "rimraf ./dist",
|
|
35
|
+
"clear:node_modules": "rimraf ./node_modules",
|
|
45
36
|
"build": "pnpm run clear && unbuild",
|
|
46
37
|
"stub": "unbuild --stub"
|
|
47
38
|
}
|
package/README.md
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# @destyler/dialog
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@destyler/dialog)
|
|
4
|
-
|
|
5
|
-
> before taking action, please confirm.
|
|
6
|
-
|
|
7
|
-
[GitHub](https://github.com/destyler/destyler) | [Documentation](https://destyler-dev.zeabur.app/)
|
package/dist/component.cjs
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
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');
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
exports.DialogClose = index.DialogClose;
|
|
18
|
-
exports.DialogContent = index.DialogContent;
|
|
19
|
-
exports.DialogContentImpl = index.DialogContentImpl;
|
|
20
|
-
exports.DialogContentModal = index.DialogContentModal;
|
|
21
|
-
exports.DialogContentNonModal = index.DialogContentNonModal;
|
|
22
|
-
exports.DialogDescription = index.DialogDescription;
|
|
23
|
-
exports.DialogOverlay = index.DialogOverlay;
|
|
24
|
-
exports.DialogOverlayImpl = index.DialogOverlayImpl;
|
|
25
|
-
exports.DialogPortal = index.DialogPortal;
|
|
26
|
-
exports.DialogRoot = index.DialogRoot;
|
|
27
|
-
exports.DialogTitle = index.DialogTitle;
|
|
28
|
-
exports.DialogTrigger = index.DialogTrigger;
|
|
29
|
-
exports.dialogCloseProps = index.dialogCloseProps;
|
|
30
|
-
exports.dialogContentEmits = index.dialogContentEmits;
|
|
31
|
-
exports.dialogContentImplEmtis = index.dialogContentImplEmtis;
|
|
32
|
-
exports.dialogContentImplProps = index.dialogContentImplProps;
|
|
33
|
-
exports.dialogContentProps = index.dialogContentProps;
|
|
34
|
-
exports.dialogDescriptionProps = index.dialogDescriptionProps;
|
|
35
|
-
exports.dialogOverlayImplProps = index.dialogOverlayImplProps;
|
|
36
|
-
exports.dialogPortalProps = index.dialogPortalProps;
|
|
37
|
-
exports.dialogRootEmits = index.dialogRootEmits;
|
|
38
|
-
exports.dialogRootProps = index.dialogRootProps;
|
|
39
|
-
exports.dialogTitleProps = index.dialogTitleProps;
|
|
40
|
-
exports.dialogTriggerProps = index.dialogTriggerProps;
|