@destyler/popover 0.0.1-beta.1 → 0.0.1-beta.10
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/component.cjs +56 -0
- package/dist/component.d.cts +790 -0
- package/dist/component.d.mts +790 -0
- package/dist/component.d.ts +790 -0
- package/dist/component.mjs +46 -0
- package/dist/index.cjs +20 -1172
- package/dist/index.d.cts +5 -408
- package/dist/index.d.mts +5 -408
- package/dist/index.d.ts +5 -408
- package/dist/index.mjs +11 -1168
- package/dist/resolver.cjs +25 -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 +22 -0
- package/dist/shared/popover.ada869b3.mjs +469 -0
- package/dist/shared/popover.b75b8d61.d.cts +610 -0
- package/dist/shared/popover.b75b8d61.d.mts +610 -0
- package/dist/shared/popover.b75b8d61.d.ts +610 -0
- package/dist/shared/popover.c7826df2.cjs +480 -0
- package/package.json +21 -5
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const name = "@destyler/popover";
|
|
4
|
+
|
|
5
|
+
const packageName = name;
|
|
6
|
+
const popoverComponentName = [
|
|
7
|
+
"DestylerPopoverArrow",
|
|
8
|
+
"DestylerPopoverClose",
|
|
9
|
+
"DestylerPopoverContent",
|
|
10
|
+
"DestylerPopoverPortal",
|
|
11
|
+
"DestylerPopoverRoot",
|
|
12
|
+
"DestylerPopoverTrigger"
|
|
13
|
+
];
|
|
14
|
+
function DestylerPopoverResolver() {
|
|
15
|
+
return {
|
|
16
|
+
type: "component",
|
|
17
|
+
resolve: (name2) => {
|
|
18
|
+
if (popoverComponentName.includes(name2))
|
|
19
|
+
return { name: name2, from: packageName };
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.DestylerPopoverResolver = DestylerPopoverResolver;
|
|
25
|
+
exports.popoverComponentName = popoverComponentName;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const name = "@destyler/popover";
|
|
2
|
+
|
|
3
|
+
const packageName = name;
|
|
4
|
+
const popoverComponentName = [
|
|
5
|
+
"DestylerPopoverArrow",
|
|
6
|
+
"DestylerPopoverClose",
|
|
7
|
+
"DestylerPopoverContent",
|
|
8
|
+
"DestylerPopoverPortal",
|
|
9
|
+
"DestylerPopoverRoot",
|
|
10
|
+
"DestylerPopoverTrigger"
|
|
11
|
+
];
|
|
12
|
+
function DestylerPopoverResolver() {
|
|
13
|
+
return {
|
|
14
|
+
type: "component",
|
|
15
|
+
resolve: (name2) => {
|
|
16
|
+
if (popoverComponentName.includes(name2))
|
|
17
|
+
return { name: name2, from: packageName };
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { DestylerPopoverResolver, popoverComponentName };
|
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
import { defineComponent, h, mergeProps, toRef, ref, withDirectives, onMounted } from 'vue';
|
|
2
|
+
import { DestylerPopperArrow, DestylerPopperRoot, DestylerPopperContent, DestylerPopperAnchor } from '@destyler/popper';
|
|
3
|
+
import { DestylerPrimitive } from '@destyler/primitive';
|
|
4
|
+
import { createContext } from '@destyler/shared';
|
|
5
|
+
import { useVModel, useId, useForwardProps, useFocusGuards, useForwardPropsEmits, useCustomElement, useHideOthers } from '@destyler/composition';
|
|
6
|
+
import { DestylerPresence } from '@destyler/presence';
|
|
7
|
+
import { DestylerDismissableLayer } from '@destyler/dismissable-layer';
|
|
8
|
+
import { DestylerFocusScope } from '@destyler/focus-scope';
|
|
9
|
+
import { BindOnceDirective } from '@destyler/directives';
|
|
10
|
+
import { DestylerTeleport } from '@destyler/teleport';
|
|
11
|
+
|
|
12
|
+
const destylerPopoverArrowProps = {
|
|
13
|
+
asChild: {
|
|
14
|
+
type: Boolean,
|
|
15
|
+
required: false,
|
|
16
|
+
default: false
|
|
17
|
+
},
|
|
18
|
+
width: {
|
|
19
|
+
type: Number,
|
|
20
|
+
required: false,
|
|
21
|
+
default: 5
|
|
22
|
+
},
|
|
23
|
+
height: {
|
|
24
|
+
type: Number,
|
|
25
|
+
required: false,
|
|
26
|
+
default: 10
|
|
27
|
+
},
|
|
28
|
+
as: {
|
|
29
|
+
type: [String, Object],
|
|
30
|
+
required: false,
|
|
31
|
+
default: "svg"
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const DestylerPopoverArrow = defineComponent({
|
|
35
|
+
name: "DestylerPopoverArrow",
|
|
36
|
+
props: destylerPopoverArrowProps,
|
|
37
|
+
render() {
|
|
38
|
+
return h(DestylerPopperArrow, mergeProps(this.$props, {}), this.$slots.default?.());
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const [injectPopoverRootContext, providePopoverRootContext] = createContext("DestylerPopoverRoot");
|
|
43
|
+
const destylerPopoverRootProps = {
|
|
44
|
+
defaultOpen: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
required: false,
|
|
47
|
+
default: false
|
|
48
|
+
},
|
|
49
|
+
open: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
required: false,
|
|
52
|
+
default: void 0
|
|
53
|
+
},
|
|
54
|
+
modal: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
required: false,
|
|
57
|
+
default: false
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const DestylerPopoverRoot = defineComponent({
|
|
61
|
+
name: "DestylerPopoverRoot",
|
|
62
|
+
props: destylerPopoverRootProps,
|
|
63
|
+
emits: ["update:open"],
|
|
64
|
+
setup(props, { emit }) {
|
|
65
|
+
const modalRef = toRef(props.modal);
|
|
66
|
+
const openRef = useVModel(props, "open", emit, {
|
|
67
|
+
defaultValue: props.defaultOpen,
|
|
68
|
+
passive: props.open === void 0
|
|
69
|
+
});
|
|
70
|
+
const triggerElement = ref();
|
|
71
|
+
const hasCustomAnchor = ref(false);
|
|
72
|
+
function handleUpdateOpen(value) {
|
|
73
|
+
openRef.value = value;
|
|
74
|
+
}
|
|
75
|
+
providePopoverRootContext({
|
|
76
|
+
contentId: useId(),
|
|
77
|
+
modal: modalRef,
|
|
78
|
+
open: openRef,
|
|
79
|
+
onOpenChange: (value) => {
|
|
80
|
+
handleUpdateOpen(value);
|
|
81
|
+
},
|
|
82
|
+
onOpenToggle: () => {
|
|
83
|
+
handleUpdateOpen(!openRef.value);
|
|
84
|
+
},
|
|
85
|
+
triggerElement,
|
|
86
|
+
hasCustomAnchor
|
|
87
|
+
});
|
|
88
|
+
return {
|
|
89
|
+
openRef,
|
|
90
|
+
modalRef,
|
|
91
|
+
triggerElement,
|
|
92
|
+
hasCustomAnchor
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
render() {
|
|
96
|
+
return h(DestylerPopperRoot, this.$slots.default?.());
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const destylerPopoverCloseProps = {
|
|
101
|
+
asChild: {
|
|
102
|
+
type: Boolean,
|
|
103
|
+
required: false,
|
|
104
|
+
default: false
|
|
105
|
+
},
|
|
106
|
+
as: {
|
|
107
|
+
type: [String, Object],
|
|
108
|
+
required: false,
|
|
109
|
+
default: "button"
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const DestylerPopoverClose = defineComponent({
|
|
113
|
+
name: "DestylerPopoverClose",
|
|
114
|
+
props: destylerPopoverCloseProps,
|
|
115
|
+
setup() {
|
|
116
|
+
const rootContext = injectPopoverRootContext();
|
|
117
|
+
return {
|
|
118
|
+
rootContext
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
render() {
|
|
122
|
+
return h(DestylerPrimitive, {
|
|
123
|
+
as: this.$props.as,
|
|
124
|
+
asChild: this.$props.asChild,
|
|
125
|
+
type: this.$props.as === "button" ? "button" : void 0,
|
|
126
|
+
onClick: () => {
|
|
127
|
+
this.rootContext.onOpenChange(false);
|
|
128
|
+
}
|
|
129
|
+
}, this.$slots.default?.());
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const destylerPopoverContentImplProps = {
|
|
134
|
+
side: {
|
|
135
|
+
type: String,
|
|
136
|
+
required: false,
|
|
137
|
+
default: "bottom"
|
|
138
|
+
},
|
|
139
|
+
sideOffset: {
|
|
140
|
+
type: Number,
|
|
141
|
+
required: false,
|
|
142
|
+
default: 0
|
|
143
|
+
},
|
|
144
|
+
align: {
|
|
145
|
+
type: String,
|
|
146
|
+
required: false,
|
|
147
|
+
default: "center"
|
|
148
|
+
},
|
|
149
|
+
alignOffset: {
|
|
150
|
+
type: Number,
|
|
151
|
+
required: false,
|
|
152
|
+
default: 0
|
|
153
|
+
},
|
|
154
|
+
avoidCollisions: {
|
|
155
|
+
type: Boolean,
|
|
156
|
+
required: false,
|
|
157
|
+
default: true
|
|
158
|
+
},
|
|
159
|
+
collisionBoundary: {
|
|
160
|
+
type: [Object, Array, null],
|
|
161
|
+
required: false,
|
|
162
|
+
default: () => []
|
|
163
|
+
},
|
|
164
|
+
collisionPadding: {
|
|
165
|
+
type: [Number, Object],
|
|
166
|
+
required: false,
|
|
167
|
+
default: 0
|
|
168
|
+
},
|
|
169
|
+
arrowPadding: {
|
|
170
|
+
type: Number,
|
|
171
|
+
required: false,
|
|
172
|
+
default: 0
|
|
173
|
+
},
|
|
174
|
+
sticky: {
|
|
175
|
+
type: String,
|
|
176
|
+
required: false,
|
|
177
|
+
default: "partial"
|
|
178
|
+
},
|
|
179
|
+
hideWhenDetached: {
|
|
180
|
+
type: Boolean,
|
|
181
|
+
required: false,
|
|
182
|
+
default: false
|
|
183
|
+
},
|
|
184
|
+
updatePositionStrategy: {
|
|
185
|
+
type: String,
|
|
186
|
+
required: false,
|
|
187
|
+
default: "optimized"
|
|
188
|
+
},
|
|
189
|
+
onPlaced: {
|
|
190
|
+
type: Function,
|
|
191
|
+
required: false
|
|
192
|
+
},
|
|
193
|
+
prioritizePosition: {
|
|
194
|
+
type: Boolean,
|
|
195
|
+
required: false,
|
|
196
|
+
default: false
|
|
197
|
+
},
|
|
198
|
+
as: {
|
|
199
|
+
type: [String, Object],
|
|
200
|
+
required: false,
|
|
201
|
+
default: "div"
|
|
202
|
+
},
|
|
203
|
+
asChild: {
|
|
204
|
+
type: Boolean,
|
|
205
|
+
required: false,
|
|
206
|
+
default: false
|
|
207
|
+
},
|
|
208
|
+
disableOutsidePointerEvents: {
|
|
209
|
+
type: Boolean,
|
|
210
|
+
required: false,
|
|
211
|
+
default: false
|
|
212
|
+
},
|
|
213
|
+
trapFocus: {
|
|
214
|
+
type: Boolean,
|
|
215
|
+
required: false,
|
|
216
|
+
default: false
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
const destylerPopoverContentImplEmits = ["escapeKeyDown", "pointerDownOutside", "focusOutside", "interactOutside", "dismiss", "openAutoFocus", "closeAutoFocus"];
|
|
220
|
+
const DestylerPopoverContentImpl = defineComponent({
|
|
221
|
+
name: "DestylerPopoverContentImpl",
|
|
222
|
+
props: destylerPopoverContentImplProps,
|
|
223
|
+
emits: destylerPopoverContentImplEmits,
|
|
224
|
+
setup(props) {
|
|
225
|
+
const forwarded = useForwardProps(props);
|
|
226
|
+
const rootContext = injectPopoverRootContext();
|
|
227
|
+
useFocusGuards();
|
|
228
|
+
return {
|
|
229
|
+
rootContext,
|
|
230
|
+
forwarded
|
|
231
|
+
};
|
|
232
|
+
},
|
|
233
|
+
render() {
|
|
234
|
+
return h(DestylerFocusScope, {
|
|
235
|
+
asChild: true,
|
|
236
|
+
loop: true,
|
|
237
|
+
trapped: this.$props.trapFocus,
|
|
238
|
+
onMountAutoFocus: (event) => {
|
|
239
|
+
this.$emit("openAutoFocus", event);
|
|
240
|
+
},
|
|
241
|
+
onUnmountAutoFocus: (event) => {
|
|
242
|
+
this.$emit("closeAutoFocus", event);
|
|
243
|
+
}
|
|
244
|
+
}, h(DestylerDismissableLayer, {
|
|
245
|
+
asChild: true,
|
|
246
|
+
disableOutsidePointerEvents: this.$props.disableOutsidePointerEvents,
|
|
247
|
+
onPointerDownOutside: (event) => {
|
|
248
|
+
this.$emit("pointerDownOutside", event);
|
|
249
|
+
},
|
|
250
|
+
onInteractOutside: (event) => {
|
|
251
|
+
this.$emit("interactOutside", event);
|
|
252
|
+
},
|
|
253
|
+
onEscapeKeyDown: (event) => {
|
|
254
|
+
this.$emit("escapeKeyDown", event);
|
|
255
|
+
},
|
|
256
|
+
onFocusOutside: (event) => {
|
|
257
|
+
this.$emit("focusOutside", event);
|
|
258
|
+
},
|
|
259
|
+
onDismiss: () => {
|
|
260
|
+
this.rootContext.onOpenChange(false);
|
|
261
|
+
}
|
|
262
|
+
}, withDirectives(h(DestylerPopperContent, mergeProps(this.forwarded, {
|
|
263
|
+
"data-state": this.rootContext.open.value ? "open" : "closed",
|
|
264
|
+
"role": "dialog",
|
|
265
|
+
"style": {
|
|
266
|
+
"--destyler_popover_content_transform_origin": "var(--destyler_popper_transform_origin)",
|
|
267
|
+
"--destyler_popover_content_available_width": "var(--destyler_popper_available_width)",
|
|
268
|
+
"--destyler_popover_content_available_height": "var(--destyler_popper_available_height)",
|
|
269
|
+
"--destyler_popover_trigger_width": "var(--destyler_popper_anchor_width)",
|
|
270
|
+
"--destyler_popover_trigger_height": "var(--destyler_popper_anchor_height)"
|
|
271
|
+
}
|
|
272
|
+
}), this.$slots.default?.()), [
|
|
273
|
+
[BindOnceDirective, { id: this.rootContext.contentId }]
|
|
274
|
+
])));
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
const DestylerPopoverContentModal = defineComponent({
|
|
279
|
+
name: "DestylerPopoverContentModal",
|
|
280
|
+
props: destylerPopoverContentImplProps,
|
|
281
|
+
emits: destylerPopoverContentImplEmits,
|
|
282
|
+
setup(props, { emit }) {
|
|
283
|
+
const rootContext = injectPopoverRootContext();
|
|
284
|
+
const isRightClickOutsideRef = ref(false);
|
|
285
|
+
const forwarded = useForwardPropsEmits(props, emit);
|
|
286
|
+
const { customElement, currentElement } = useCustomElement();
|
|
287
|
+
useHideOthers(currentElement);
|
|
288
|
+
return {
|
|
289
|
+
rootContext,
|
|
290
|
+
forwarded,
|
|
291
|
+
isRightClickOutsideRef,
|
|
292
|
+
customElement
|
|
293
|
+
};
|
|
294
|
+
},
|
|
295
|
+
render() {
|
|
296
|
+
return h(DestylerPopoverContentImpl, {
|
|
297
|
+
"ref": "customElement",
|
|
298
|
+
...mergeProps(this.forwarded),
|
|
299
|
+
"trapFocus": this.rootContext.open.value,
|
|
300
|
+
"disable-outside-pointer-events": "",
|
|
301
|
+
"onCloseAutoFocusPrevent": (event) => {
|
|
302
|
+
this.$emit("closeAutoFocus", event);
|
|
303
|
+
if (!this.isRightClickOutsideRef)
|
|
304
|
+
this.rootContext.triggerElement.value?.focus();
|
|
305
|
+
},
|
|
306
|
+
"onPointerDownOutside": (event) => {
|
|
307
|
+
this.$emit("pointerDownOutside", event);
|
|
308
|
+
const originalEvent = event.detail.originalEvent;
|
|
309
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
310
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
311
|
+
this.isRightClickOutsideRef = isRightClick;
|
|
312
|
+
}
|
|
313
|
+
}, this.$slots.default?.());
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
const DestylerPopoverContentNonModal = defineComponent({
|
|
318
|
+
name: "DestylerPopoverContentNonModal",
|
|
319
|
+
props: destylerPopoverContentImplProps,
|
|
320
|
+
emits: destylerPopoverContentImplEmits,
|
|
321
|
+
setup(props, { emit }) {
|
|
322
|
+
const rootContext = injectPopoverRootContext();
|
|
323
|
+
const hasInteractedOutsideRef = ref(false);
|
|
324
|
+
const hasPointerDownOutsideRef = ref(false);
|
|
325
|
+
const forwarded = useForwardPropsEmits(props, emit);
|
|
326
|
+
return {
|
|
327
|
+
forwarded,
|
|
328
|
+
rootContext,
|
|
329
|
+
hasInteractedOutsideRef,
|
|
330
|
+
hasPointerDownOutsideRef
|
|
331
|
+
};
|
|
332
|
+
},
|
|
333
|
+
render() {
|
|
334
|
+
return h(DestylerPopoverContentImpl, {
|
|
335
|
+
...this.forwarded,
|
|
336
|
+
trapFocus: false,
|
|
337
|
+
disableOutsidePointerEvents: false,
|
|
338
|
+
onCloseAutoFocus: (event) => {
|
|
339
|
+
this.$emit("closeAutoFocus", event);
|
|
340
|
+
if (!event.defaultPrevented) {
|
|
341
|
+
if (!this.hasInteractedOutsideRef)
|
|
342
|
+
this.rootContext.triggerElement.value?.focus();
|
|
343
|
+
event.preventDefault();
|
|
344
|
+
}
|
|
345
|
+
this.hasInteractedOutsideRef = false;
|
|
346
|
+
this.hasPointerDownOutsideRef = false;
|
|
347
|
+
},
|
|
348
|
+
onInteractOutside: async (event) => {
|
|
349
|
+
this.$emit("interactOutside", event);
|
|
350
|
+
if (!event.defaultPrevented) {
|
|
351
|
+
this.hasInteractedOutsideRef = true;
|
|
352
|
+
if (event.detail.originalEvent.type === "pointerdown")
|
|
353
|
+
this.hasPointerDownOutsideRef = true;
|
|
354
|
+
}
|
|
355
|
+
const target = event.target;
|
|
356
|
+
const targetIsTrigger = this.rootContext.triggerElement.value?.contains(target);
|
|
357
|
+
if (targetIsTrigger)
|
|
358
|
+
event.preventDefault();
|
|
359
|
+
if (event.detail.originalEvent.type === "focusin" && this.hasPointerDownOutsideRef)
|
|
360
|
+
event.preventDefault();
|
|
361
|
+
}
|
|
362
|
+
}, this.$slots.default?.());
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
const destylerPopoverContentProps = {
|
|
367
|
+
...destylerPopoverContentImplProps,
|
|
368
|
+
forceMount: {
|
|
369
|
+
type: Boolean,
|
|
370
|
+
required: false,
|
|
371
|
+
default: false
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
const destylerPopoverContentEmits = [...destylerPopoverContentImplEmits];
|
|
375
|
+
const DestylerPopoverContent = defineComponent({
|
|
376
|
+
name: "DestylerPopoverContent",
|
|
377
|
+
props: destylerPopoverContentProps,
|
|
378
|
+
emits: destylerPopoverContentEmits,
|
|
379
|
+
setup(props, { emit }) {
|
|
380
|
+
const rootContext = injectPopoverRootContext();
|
|
381
|
+
const forwarded = useForwardPropsEmits(props, emit);
|
|
382
|
+
return {
|
|
383
|
+
rootContext,
|
|
384
|
+
forwarded
|
|
385
|
+
};
|
|
386
|
+
},
|
|
387
|
+
render() {
|
|
388
|
+
const useVShow = this.rootContext.modal.value;
|
|
389
|
+
return h(DestylerPresence, {
|
|
390
|
+
present: this.forceMount || this.rootContext.open.value
|
|
391
|
+
}, useVShow ? h(DestylerPopoverContentModal, {
|
|
392
|
+
...this.forwarded
|
|
393
|
+
}, this.$slots.default?.()) : h(DestylerPopoverContentNonModal, {
|
|
394
|
+
...this.forwarded
|
|
395
|
+
}, this.$slots.default?.()));
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
const destylerPopoverPortalProps = {
|
|
400
|
+
to: {
|
|
401
|
+
type: [String, Object],
|
|
402
|
+
required: false,
|
|
403
|
+
default: "body"
|
|
404
|
+
},
|
|
405
|
+
disabled: {
|
|
406
|
+
type: Boolean,
|
|
407
|
+
required: false,
|
|
408
|
+
default: false
|
|
409
|
+
},
|
|
410
|
+
forceMount: {
|
|
411
|
+
type: Boolean,
|
|
412
|
+
required: false,
|
|
413
|
+
default: false
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
const DestylerPopoverPortal = defineComponent({
|
|
417
|
+
name: "DestylerPopoverPortal",
|
|
418
|
+
props: destylerPopoverPortalProps,
|
|
419
|
+
render() {
|
|
420
|
+
return h(DestylerTeleport, mergeProps(this.$props), this.$slots.default?.());
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
const destylerPopoverTriggerProps = {
|
|
425
|
+
asChild: {
|
|
426
|
+
type: Boolean,
|
|
427
|
+
required: false,
|
|
428
|
+
default: false
|
|
429
|
+
},
|
|
430
|
+
as: {
|
|
431
|
+
type: [String, Object],
|
|
432
|
+
required: false,
|
|
433
|
+
default: "button"
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
const DestylerPopoverTrigger = defineComponent({
|
|
437
|
+
name: "DestylerPopoverTrigger",
|
|
438
|
+
props: destylerPopoverTriggerProps,
|
|
439
|
+
setup() {
|
|
440
|
+
const rootContext = injectPopoverRootContext();
|
|
441
|
+
const { customElement, currentElement: triggerElement } = useCustomElement();
|
|
442
|
+
onMounted(() => {
|
|
443
|
+
rootContext.triggerElement.value = triggerElement.value;
|
|
444
|
+
});
|
|
445
|
+
return {
|
|
446
|
+
rootContext,
|
|
447
|
+
customElement
|
|
448
|
+
};
|
|
449
|
+
},
|
|
450
|
+
render() {
|
|
451
|
+
return h(this.rootContext.hasCustomAnchor.value ? DestylerPrimitive : DestylerPopperAnchor, {
|
|
452
|
+
asChild: true
|
|
453
|
+
}, h(DestylerPrimitive, {
|
|
454
|
+
"ref": "customElement",
|
|
455
|
+
"type": this.$props.as === "button" ? "button" : void 0,
|
|
456
|
+
"as": this.$props.as,
|
|
457
|
+
"aria-haspopup": "dialog",
|
|
458
|
+
"asChild": this.$props.asChild,
|
|
459
|
+
"aria-expanded": this.rootContext.open.value,
|
|
460
|
+
"aria-controls": this.rootContext.contentId,
|
|
461
|
+
"data-state": this.rootContext.open.value ? "open" : "closed",
|
|
462
|
+
"onClick": () => {
|
|
463
|
+
this.rootContext.onOpenToggle();
|
|
464
|
+
}
|
|
465
|
+
}, this.$slots.default?.()));
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
export { DestylerPopoverArrow as D, DestylerPopoverClose as a, DestylerPopoverContent as b, DestylerPopoverContentImpl as c, DestylerPopoverContentModal as d, DestylerPopoverContentNonModal as e, DestylerPopoverPortal as f, DestylerPopoverRoot as g, DestylerPopoverTrigger as h, injectPopoverRootContext as i };
|