@destyler/dialog 0.0.1-beta.8 → 0.0.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/LICENSE +21 -0
- package/dist/component.cjs +550 -0
- package/dist/component.d.cts +225 -0
- package/dist/component.d.mts +225 -0
- package/dist/component.d.ts +225 -0
- package/dist/component.mjs +537 -0
- package/dist/index.cjs +21 -482
- package/dist/index.d.cts +4 -653
- package/dist/index.d.mts +4 -653
- package/dist/index.d.ts +4 -653
- package/dist/index.mjs +10 -457
- package/dist/resolver.cjs +27 -0
- package/dist/resolver.d.cts +6 -0
- package/dist/resolver.d.mts +6 -0
- package/dist/resolver.d.ts +6 -0
- package/dist/resolver.mjs +24 -0
- package/dist/shared/dialog.25aba8c4.d.cts +420 -0
- package/dist/shared/dialog.25aba8c4.d.mts +420 -0
- package/dist/shared/dialog.25aba8c4.d.ts +420 -0
- package/package.json +19 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-PRESENT Elone Hoo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const vue = require('vue');
|
|
4
|
+
const primitive = require('@destyler/primitive');
|
|
5
|
+
const shared = require('@destyler/shared');
|
|
6
|
+
const composition = require('@destyler/composition');
|
|
7
|
+
const presence = require('@destyler/presence');
|
|
8
|
+
const focusScope = require('@destyler/focus-scope');
|
|
9
|
+
const dismissableLayer = require('@destyler/dismissable-layer');
|
|
10
|
+
const directives = require('@destyler/directives');
|
|
11
|
+
const teleport = require('@destyler/teleport');
|
|
12
|
+
|
|
13
|
+
const destylerDialogRootProps = {
|
|
14
|
+
open: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
required: false,
|
|
17
|
+
default: void 0
|
|
18
|
+
},
|
|
19
|
+
defaultOpen: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
required: false,
|
|
22
|
+
default: false
|
|
23
|
+
},
|
|
24
|
+
modal: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
required: false,
|
|
27
|
+
default: true
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const [injectDialogRootContext, provideDialogRootContext] = shared.createContext("DestylerDialogRoot");
|
|
31
|
+
const DestylerDialogRoot = vue.defineComponent({
|
|
32
|
+
name: "DestylerDialogRoot",
|
|
33
|
+
props: destylerDialogRootProps,
|
|
34
|
+
emits: ["update:open"],
|
|
35
|
+
setup(props, { emit }) {
|
|
36
|
+
const open = composition.useVModel(props, "open", emit, {
|
|
37
|
+
defaultValue: props.defaultOpen,
|
|
38
|
+
passive: props.open === void 0
|
|
39
|
+
});
|
|
40
|
+
const triggerElement = vue.ref();
|
|
41
|
+
const contentElement = vue.ref();
|
|
42
|
+
const { modal } = vue.toRefs(props);
|
|
43
|
+
provideDialogRootContext({
|
|
44
|
+
open,
|
|
45
|
+
modal,
|
|
46
|
+
openModal: () => {
|
|
47
|
+
open.value = true;
|
|
48
|
+
},
|
|
49
|
+
onOpenChange: (value) => {
|
|
50
|
+
open.value = value;
|
|
51
|
+
},
|
|
52
|
+
onOpenToggle: () => {
|
|
53
|
+
open.value = !open.value;
|
|
54
|
+
},
|
|
55
|
+
contentId: composition.useId(),
|
|
56
|
+
titleId: composition.useId(),
|
|
57
|
+
descriptionId: composition.useId(),
|
|
58
|
+
triggerElement,
|
|
59
|
+
contentElement
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
render() {
|
|
63
|
+
return this.$slots.default?.();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const destylerDialogCloseProps = {
|
|
68
|
+
asChild: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
required: false,
|
|
71
|
+
default: false
|
|
72
|
+
},
|
|
73
|
+
as: {
|
|
74
|
+
type: [String, Object],
|
|
75
|
+
required: false,
|
|
76
|
+
default: "button"
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const DestylerDialogClose = vue.defineComponent({
|
|
80
|
+
name: "DestylerDialogClose",
|
|
81
|
+
props: destylerDialogCloseProps,
|
|
82
|
+
setup() {
|
|
83
|
+
const rootContext = injectDialogRootContext();
|
|
84
|
+
return {
|
|
85
|
+
rootContext
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
render() {
|
|
89
|
+
return vue.h(primitive.DestylerPrimitive, vue.mergeProps(this.$props, {
|
|
90
|
+
type: this.$props.as === "button" ? "button" : void 0,
|
|
91
|
+
onClick: () => {
|
|
92
|
+
this.rootContext.onOpenChange(false);
|
|
93
|
+
}
|
|
94
|
+
}), {
|
|
95
|
+
default: () => this.$slots.default?.()
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const destylerDialogContentImplProps = {
|
|
101
|
+
as: {
|
|
102
|
+
type: [String, Object],
|
|
103
|
+
required: false,
|
|
104
|
+
default: "div"
|
|
105
|
+
},
|
|
106
|
+
asChild: {
|
|
107
|
+
type: Boolean,
|
|
108
|
+
required: false,
|
|
109
|
+
default: false
|
|
110
|
+
},
|
|
111
|
+
forceMount: {
|
|
112
|
+
type: Boolean,
|
|
113
|
+
required: false
|
|
114
|
+
},
|
|
115
|
+
trapFocus: {
|
|
116
|
+
type: Boolean,
|
|
117
|
+
required: false,
|
|
118
|
+
default: false
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const DestylerDialogContentImpl = vue.defineComponent({
|
|
122
|
+
name: "DestylerDialogContentImpl",
|
|
123
|
+
props: destylerDialogContentImplProps,
|
|
124
|
+
emits: ["openAutoFocus", "closeAutoFocus", "escapeKeyDown", "pointerDownOutside", "focusOutside", "interactOutside", "dismiss"],
|
|
125
|
+
setup() {
|
|
126
|
+
const rootContext = injectDialogRootContext();
|
|
127
|
+
const { forwardRef, currentElement: contentElement } = composition.useForwardExpose();
|
|
128
|
+
vue.onMounted(() => {
|
|
129
|
+
rootContext.contentElement = contentElement;
|
|
130
|
+
});
|
|
131
|
+
return {
|
|
132
|
+
rootContext,
|
|
133
|
+
forwardRef
|
|
134
|
+
};
|
|
135
|
+
},
|
|
136
|
+
render() {
|
|
137
|
+
return vue.h(focusScope.DestylerFocusScope, {
|
|
138
|
+
asChild: true,
|
|
139
|
+
loop: true,
|
|
140
|
+
trapped: this.$props.trapFocus,
|
|
141
|
+
onMountAutoFocus: (event) => {
|
|
142
|
+
this.$emit("openAutoFocus", event);
|
|
143
|
+
},
|
|
144
|
+
onUnmountAutoFocus: (event) => {
|
|
145
|
+
this.$emit("closeAutoFocus", event);
|
|
146
|
+
}
|
|
147
|
+
}, vue.withDirectives(vue.h(dismissableLayer.DestylerDismissableLayer, vue.mergeProps(this.$attrs, {
|
|
148
|
+
"ref": (el) => this.forwardRef(el),
|
|
149
|
+
"as": this.$props.as,
|
|
150
|
+
"asChild": this.$props.asChild,
|
|
151
|
+
"role": "dialog",
|
|
152
|
+
"aria-describedby": this.rootContext.descriptionId,
|
|
153
|
+
"aria-labelledby": this.rootContext.titleId,
|
|
154
|
+
"data-state": shared.getOpenState(this.rootContext.open.value),
|
|
155
|
+
"isDismissable": true,
|
|
156
|
+
"onDismiss": () => {
|
|
157
|
+
this.rootContext.onOpenChange(false);
|
|
158
|
+
},
|
|
159
|
+
"onEscapeKeyDown": (event) => {
|
|
160
|
+
this.$emit("escapeKeyDown", event);
|
|
161
|
+
},
|
|
162
|
+
"onFocusOutside": (event) => {
|
|
163
|
+
this.$emit("focusOutside", event);
|
|
164
|
+
},
|
|
165
|
+
"onInteractOutside": (event) => {
|
|
166
|
+
this.$emit("interactOutside", event);
|
|
167
|
+
},
|
|
168
|
+
"onPointerDownOutside": (event) => {
|
|
169
|
+
this.$emit("pointerDownOutside", event);
|
|
170
|
+
}
|
|
171
|
+
}), {
|
|
172
|
+
default: () => this.$slots.default?.()
|
|
173
|
+
}), [
|
|
174
|
+
[directives.BindOnceDirective, { id: this.rootContext.contentId }]
|
|
175
|
+
]));
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
const DestylerDialogContentModal = vue.defineComponent({
|
|
180
|
+
name: "DestylerDialogContentModal",
|
|
181
|
+
props: destylerDialogContentImplProps,
|
|
182
|
+
emits: ["openAutoFocus", "closeAutoFocus", "escapeKeyDown", "pointerDownOutside", "focusOutside", "interactOutside", "dismiss"],
|
|
183
|
+
setup(_, { emit }) {
|
|
184
|
+
const rootContext = injectDialogRootContext();
|
|
185
|
+
const emitsAsProps = composition.useEmitAsProps(emit);
|
|
186
|
+
const { forwardRef, currentElement } = composition.useForwardExpose();
|
|
187
|
+
composition.useHideOthers(currentElement);
|
|
188
|
+
return {
|
|
189
|
+
rootContext,
|
|
190
|
+
emitsAsProps,
|
|
191
|
+
forwardRef
|
|
192
|
+
};
|
|
193
|
+
},
|
|
194
|
+
render() {
|
|
195
|
+
return vue.h(DestylerDialogContentImpl, vue.mergeProps(this.$props, this.emitsAsProps, {
|
|
196
|
+
"ref": (el) => this.forwardRef(el),
|
|
197
|
+
"trap-focus": this.rootContext.open.value,
|
|
198
|
+
"disableOutsidePointerEvents": true,
|
|
199
|
+
"onCloseAutoFocus": (event) => {
|
|
200
|
+
this.$emit("closeAutoFocus", event);
|
|
201
|
+
if (!event.defaultPrevented) {
|
|
202
|
+
event.preventDefault();
|
|
203
|
+
this.rootContext.triggerElement.value?.focus();
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
"onPointerDownOutside": (event) => {
|
|
207
|
+
const originalEvent = event.detail.originalEvent;
|
|
208
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
209
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
210
|
+
if (isRightClick)
|
|
211
|
+
event.preventDefault();
|
|
212
|
+
},
|
|
213
|
+
"onFocusOutside": (event) => {
|
|
214
|
+
event.preventDefault();
|
|
215
|
+
},
|
|
216
|
+
"onOpenAutoFocus": (event) => {
|
|
217
|
+
this.$emit("openAutoFocus", event);
|
|
218
|
+
}
|
|
219
|
+
}), {
|
|
220
|
+
default: () => this.$slots.default?.()
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
const DestylerDialogContentNonModal = vue.defineComponent({
|
|
226
|
+
name: "DestylerDialogContentNonModal",
|
|
227
|
+
props: destylerDialogContentImplProps,
|
|
228
|
+
emits: ["openAutoFocus", "closeAutoFocus", "escapeKeyDown", "pointerDownOutside", "focusOutside", "interactOutside", "dismiss"],
|
|
229
|
+
setup(_, { emit }) {
|
|
230
|
+
const rootContext = injectDialogRootContext();
|
|
231
|
+
const hasInteractedOutsideRef = vue.ref(false);
|
|
232
|
+
const hasPointerDownOutsideRef = vue.ref(false);
|
|
233
|
+
const emitsAsProps = composition.useEmitAsProps(emit);
|
|
234
|
+
return {
|
|
235
|
+
rootContext,
|
|
236
|
+
hasInteractedOutsideRef,
|
|
237
|
+
hasPointerDownOutsideRef,
|
|
238
|
+
emitsAsProps
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
render() {
|
|
242
|
+
return vue.h(DestylerDialogContentImpl, vue.mergeProps(this.$props, this.emitsAsProps, {
|
|
243
|
+
"trap-focus": false,
|
|
244
|
+
"disableOutsidePointerEvents": false,
|
|
245
|
+
"onCloseAutoFocus": (event) => {
|
|
246
|
+
this.$emit("closeAutoFocus", event);
|
|
247
|
+
if (!event.defaultPrevented) {
|
|
248
|
+
if (!this.hasInteractedOutsideRef)
|
|
249
|
+
this.rootContext.triggerElement.value?.focus();
|
|
250
|
+
event.preventDefault();
|
|
251
|
+
}
|
|
252
|
+
this.hasInteractedOutsideRef = false;
|
|
253
|
+
this.hasPointerDownOutsideRef = false;
|
|
254
|
+
},
|
|
255
|
+
"onInteractOutside": (event) => {
|
|
256
|
+
if (!event.defaultPrevented) {
|
|
257
|
+
this.hasInteractedOutsideRef = true;
|
|
258
|
+
if (event.detail.originalEvent.type === "pointerdown")
|
|
259
|
+
this.hasPointerDownOutsideRef = true;
|
|
260
|
+
}
|
|
261
|
+
const target = event.target;
|
|
262
|
+
const targetIsTrigger = this.rootContext.triggerElement.value?.contains(target);
|
|
263
|
+
if (targetIsTrigger)
|
|
264
|
+
event.preventDefault();
|
|
265
|
+
if (event.detail.originalEvent.type === "focusin" && this.hasPointerDownOutsideRef)
|
|
266
|
+
event.preventDefault();
|
|
267
|
+
}
|
|
268
|
+
}), {
|
|
269
|
+
default: () => this.$slots.default?.()
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
const destylerDialogContentProps = {
|
|
275
|
+
as: {
|
|
276
|
+
type: [String, Object],
|
|
277
|
+
required: false,
|
|
278
|
+
default: "div"
|
|
279
|
+
},
|
|
280
|
+
asChild: {
|
|
281
|
+
type: Boolean,
|
|
282
|
+
required: false,
|
|
283
|
+
default: false
|
|
284
|
+
},
|
|
285
|
+
forceMount: {
|
|
286
|
+
type: Boolean,
|
|
287
|
+
required: false
|
|
288
|
+
},
|
|
289
|
+
trapFocus: {
|
|
290
|
+
type: Boolean,
|
|
291
|
+
required: false,
|
|
292
|
+
default: false
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
const DestylerDialogContent = vue.defineComponent({
|
|
296
|
+
name: "DestylerDialogContent",
|
|
297
|
+
props: destylerDialogContentProps,
|
|
298
|
+
emits: ["openAutoFocus", "closeAutoFocus", "escapeKeyDown", "pointerDownOutside", "focusOutside", "interactOutside", "dismiss"],
|
|
299
|
+
setup(_, { emit }) {
|
|
300
|
+
const rootContext = injectDialogRootContext();
|
|
301
|
+
const emitsAsProps = composition.useEmitAsProps(emit);
|
|
302
|
+
const { forwardRef } = composition.useForwardExpose();
|
|
303
|
+
return {
|
|
304
|
+
rootContext,
|
|
305
|
+
emitsAsProps,
|
|
306
|
+
forwardRef
|
|
307
|
+
};
|
|
308
|
+
},
|
|
309
|
+
render() {
|
|
310
|
+
const useVShow = this.rootContext.modal.value;
|
|
311
|
+
return vue.h(presence.DestylerPresence, {
|
|
312
|
+
present: this.$props.forceMount || this.rootContext.open.value
|
|
313
|
+
}, [
|
|
314
|
+
useVShow ? vue.h(DestylerDialogContentModal, vue.mergeProps(this.$props, this.emitsAsProps, this.$attrs, {
|
|
315
|
+
ref: (el) => this.forwardRef(el),
|
|
316
|
+
onOpenAutoFocus: (event) => {
|
|
317
|
+
this.$emit("openAutoFocus", event);
|
|
318
|
+
}
|
|
319
|
+
}), {
|
|
320
|
+
default: () => this.$slots.default?.()
|
|
321
|
+
}) : vue.h(DestylerDialogContentNonModal, vue.mergeProps(this.$props, this.emitsAsProps, this.$attrs), {
|
|
322
|
+
ref: (el) => this.forwardRef(el),
|
|
323
|
+
default: () => this.$slots.default?.()
|
|
324
|
+
})
|
|
325
|
+
]);
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
const destylerDialogDescriptionProps = {
|
|
330
|
+
asChild: {
|
|
331
|
+
type: Boolean,
|
|
332
|
+
required: false,
|
|
333
|
+
default: false
|
|
334
|
+
},
|
|
335
|
+
as: {
|
|
336
|
+
type: [String, Object],
|
|
337
|
+
required: false,
|
|
338
|
+
default: "p"
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
const DestylerDialogDescription = vue.defineComponent({
|
|
342
|
+
name: "DestylerDialogDescription",
|
|
343
|
+
props: destylerDialogDescriptionProps,
|
|
344
|
+
setup() {
|
|
345
|
+
const rootContext = injectDialogRootContext();
|
|
346
|
+
return {
|
|
347
|
+
rootContext
|
|
348
|
+
};
|
|
349
|
+
},
|
|
350
|
+
render() {
|
|
351
|
+
return vue.withDirectives(vue.h(primitive.DestylerPrimitive, {
|
|
352
|
+
as: this.$props.as,
|
|
353
|
+
asChild: this.$props.asChild
|
|
354
|
+
}, {
|
|
355
|
+
default: () => this.$slots.default?.()
|
|
356
|
+
}), [
|
|
357
|
+
[directives.BindOnceDirective, { id: this.rootContext.descriptionId }]
|
|
358
|
+
]);
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
const destylerDialogOverlayImplProps = {
|
|
363
|
+
as: {
|
|
364
|
+
type: [String, Object],
|
|
365
|
+
required: false,
|
|
366
|
+
default: "div"
|
|
367
|
+
},
|
|
368
|
+
asChild: {
|
|
369
|
+
type: Boolean,
|
|
370
|
+
required: false,
|
|
371
|
+
default: false
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
const DestylerDialogOverlayImpl = vue.defineComponent({
|
|
375
|
+
name: "DestylerDialogOverlayImpl",
|
|
376
|
+
props: destylerDialogOverlayImplProps,
|
|
377
|
+
setup() {
|
|
378
|
+
const rootContext = injectDialogRootContext();
|
|
379
|
+
composition.useForwardExpose();
|
|
380
|
+
return {
|
|
381
|
+
rootContext
|
|
382
|
+
};
|
|
383
|
+
},
|
|
384
|
+
render() {
|
|
385
|
+
return vue.h(primitive.DestylerPrimitive, {
|
|
386
|
+
"as": this.$props.as,
|
|
387
|
+
"asChild": this.$props.asChild,
|
|
388
|
+
"data-state": this.rootContext.open.value ? "open" : "closed",
|
|
389
|
+
"style": {
|
|
390
|
+
"pointer-events": "auto"
|
|
391
|
+
}
|
|
392
|
+
}, {
|
|
393
|
+
default: () => this.$slots.default?.()
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
const destylerDialogOverlayProps = {
|
|
399
|
+
as: {
|
|
400
|
+
type: [String, Object],
|
|
401
|
+
required: false,
|
|
402
|
+
default: "div"
|
|
403
|
+
},
|
|
404
|
+
asChild: {
|
|
405
|
+
type: Boolean,
|
|
406
|
+
required: false,
|
|
407
|
+
default: false
|
|
408
|
+
},
|
|
409
|
+
forceMount: {
|
|
410
|
+
type: Boolean,
|
|
411
|
+
required: false
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
const DestylerDialogOverlay = vue.defineComponent({
|
|
415
|
+
name: "DestylerDialogOverlay",
|
|
416
|
+
props: destylerDialogOverlayProps,
|
|
417
|
+
setup() {
|
|
418
|
+
const rootContext = injectDialogRootContext();
|
|
419
|
+
const { forwardRef } = composition.useForwardExpose();
|
|
420
|
+
return {
|
|
421
|
+
rootContext,
|
|
422
|
+
forwardRef
|
|
423
|
+
};
|
|
424
|
+
},
|
|
425
|
+
render() {
|
|
426
|
+
const useVShow = this.rootContext?.modal.value;
|
|
427
|
+
return useVShow ? vue.h(presence.DestylerPresence, {
|
|
428
|
+
present: this.$props.forceMount || this.rootContext.open.value
|
|
429
|
+
}, vue.h(DestylerDialogOverlayImpl, vue.mergeProps(this.$attrs, {
|
|
430
|
+
ref: (el) => this.forwardRef(el),
|
|
431
|
+
as: this.$props.as,
|
|
432
|
+
asChild: this.$props.asChild
|
|
433
|
+
}), {
|
|
434
|
+
default: () => this.$slots.default?.()
|
|
435
|
+
})) : null;
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
const destylerDialogPortalProps = {
|
|
440
|
+
as: {
|
|
441
|
+
type: [String, Object],
|
|
442
|
+
required: false,
|
|
443
|
+
default: "div"
|
|
444
|
+
},
|
|
445
|
+
asChild: {
|
|
446
|
+
type: Boolean,
|
|
447
|
+
required: false,
|
|
448
|
+
default: false
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
const DestylerDialogPortal = vue.defineComponent({
|
|
452
|
+
name: "DestylerDialogPortal",
|
|
453
|
+
props: destylerDialogPortalProps,
|
|
454
|
+
render() {
|
|
455
|
+
return vue.h(teleport.DestylerTeleport, {}, {
|
|
456
|
+
default: () => this.$slots.default?.()
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
const destylerDialogTitleProps = {
|
|
462
|
+
asChild: {
|
|
463
|
+
type: Boolean,
|
|
464
|
+
required: false,
|
|
465
|
+
default: false
|
|
466
|
+
},
|
|
467
|
+
as: {
|
|
468
|
+
type: [String, Object],
|
|
469
|
+
required: false,
|
|
470
|
+
default: "h2"
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
const DestylerDialogTitle = vue.defineComponent({
|
|
474
|
+
name: "DestylerDialogTitle",
|
|
475
|
+
props: destylerDialogTitleProps,
|
|
476
|
+
setup() {
|
|
477
|
+
const rootContext = injectDialogRootContext();
|
|
478
|
+
return {
|
|
479
|
+
rootContext
|
|
480
|
+
};
|
|
481
|
+
},
|
|
482
|
+
render() {
|
|
483
|
+
return vue.withDirectives(vue.h(primitive.DestylerPrimitive, {
|
|
484
|
+
as: this.$props.as,
|
|
485
|
+
asChild: this.$props.asChild
|
|
486
|
+
}, {
|
|
487
|
+
default: () => this.$slots.default?.()
|
|
488
|
+
}), [
|
|
489
|
+
[directives.BindOnceDirective, { id: this.rootContext.titleId }]
|
|
490
|
+
]);
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
const destylerDialogTriggerProps = {
|
|
495
|
+
asChild: {
|
|
496
|
+
type: Boolean,
|
|
497
|
+
required: false,
|
|
498
|
+
default: false
|
|
499
|
+
},
|
|
500
|
+
as: {
|
|
501
|
+
type: [String, Object],
|
|
502
|
+
required: false,
|
|
503
|
+
default: "button"
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
const DestylerDialogTrigger = vue.defineComponent({
|
|
507
|
+
name: "DestylerDialogTrigger",
|
|
508
|
+
props: destylerDialogTriggerProps,
|
|
509
|
+
setup() {
|
|
510
|
+
const rootContext = injectDialogRootContext();
|
|
511
|
+
const { forwardRef, currentElement } = composition.useForwardExpose();
|
|
512
|
+
vue.onMounted(() => {
|
|
513
|
+
rootContext.triggerElement = currentElement;
|
|
514
|
+
});
|
|
515
|
+
return {
|
|
516
|
+
rootContext,
|
|
517
|
+
forwardRef
|
|
518
|
+
};
|
|
519
|
+
},
|
|
520
|
+
render() {
|
|
521
|
+
return vue.h(primitive.DestylerPrimitive, vue.mergeProps(this.$attrs, {
|
|
522
|
+
"as": this.$props.as,
|
|
523
|
+
"asChild": this.$props.asChild,
|
|
524
|
+
"ref": (el) => this.forwardRef(el),
|
|
525
|
+
"type": this.$props.as === "button" ? "button" : void 0,
|
|
526
|
+
"aria-haspopup": "dialog",
|
|
527
|
+
"aria-expanded": this.rootContext.open.value || false,
|
|
528
|
+
"aria-controls": this.rootContext.contentId,
|
|
529
|
+
"data-state": this.rootContext.open.value ? "open" : "closed",
|
|
530
|
+
"onClick": () => {
|
|
531
|
+
this.rootContext.onOpenToggle();
|
|
532
|
+
}
|
|
533
|
+
}), {
|
|
534
|
+
default: () => this.$slots.default?.()
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
exports.DestylerDialogClose = DestylerDialogClose;
|
|
540
|
+
exports.DestylerDialogContent = DestylerDialogContent;
|
|
541
|
+
exports.DestylerDialogContentImpl = DestylerDialogContentImpl;
|
|
542
|
+
exports.DestylerDialogContentModal = DestylerDialogContentModal;
|
|
543
|
+
exports.DestylerDialogContentNonModal = DestylerDialogContentNonModal;
|
|
544
|
+
exports.DestylerDialogDescription = DestylerDialogDescription;
|
|
545
|
+
exports.DestylerDialogOverlay = DestylerDialogOverlay;
|
|
546
|
+
exports.DestylerDialogOverlayImpl = DestylerDialogOverlayImpl;
|
|
547
|
+
exports.DestylerDialogPortal = DestylerDialogPortal;
|
|
548
|
+
exports.DestylerDialogRoot = DestylerDialogRoot;
|
|
549
|
+
exports.DestylerDialogTitle = DestylerDialogTitle;
|
|
550
|
+
exports.DestylerDialogTrigger = DestylerDialogTrigger;
|