@destyler/popover 0.0.3 → 0.0.5
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/README.md +7 -0
- package/dist/component.cjs +28 -28
- package/dist/component.d.cts +859 -300
- package/dist/component.d.mts +859 -300
- package/dist/component.d.ts +859 -300
- package/dist/component.mjs +10 -21
- package/dist/index.cjs +14 -7
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +2 -1
- package/dist/resolver.cjs +8 -8
- package/dist/resolver.d.cts +2 -2
- package/dist/resolver.d.mts +2 -2
- package/dist/resolver.d.ts +2 -2
- package/dist/resolver.mjs +8 -8
- package/dist/shared/{popover.87a37156.mjs → popover.005a231a.mjs} +120 -190
- package/dist/shared/popover.2b6be8bf.d.cts +885 -0
- package/dist/shared/popover.2b6be8bf.d.mts +885 -0
- package/dist/shared/popover.2b6be8bf.d.ts +885 -0
- package/dist/shared/{popover.0f6ec87d.cjs → popover.49550c9f.cjs} +132 -192
- package/package.json +20 -22
- package/dist/shared/popover.1e7c063d.d.cts +0 -610
- package/dist/shared/popover.1e7c063d.d.mts +0 -610
- package/dist/shared/popover.1e7c063d.d.ts +0 -610
|
@@ -1,66 +1,69 @@
|
|
|
1
1
|
import { defineComponent, h, mergeProps, toRef, ref, withDirectives, onMounted } from 'vue';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { popperArrowProps, PopperArrow, PopperRoot, popperContentProps, PopperContent, PopperAnchor } from '@destyler/popper';
|
|
3
|
+
import { primitiveProps, Primitive } from '@destyler/primitive';
|
|
4
4
|
import { createContext } from '@destyler/shared';
|
|
5
5
|
import { useVModel, useId, useForwardProps, useFocusGuards, useForwardPropsEmits, useForwardExpose, useHideOthers } from '@destyler/composition';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { Presence } from '@destyler/presence';
|
|
7
|
+
import { dismissableLayerProps, DismissableLayer } from '@destyler/dismissable-layer';
|
|
8
|
+
import { dismissableLayerEmits } from '@destyler/dismissable-layer/component';
|
|
9
|
+
import { focusScopeProps, FocusScope } from '@destyler/focus-scope';
|
|
9
10
|
import { BindOnceDirective } from '@destyler/directives';
|
|
10
|
-
import {
|
|
11
|
+
import { teleportPrimitiveProps, TeleportPrimitive } from '@destyler/teleport';
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
-
|
|
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
|
-
}
|
|
13
|
+
const popoverArrowProps = {
|
|
14
|
+
...popperArrowProps
|
|
33
15
|
};
|
|
34
|
-
const
|
|
16
|
+
const PopoverArrow = defineComponent({
|
|
35
17
|
name: "DestylerPopoverArrow",
|
|
36
|
-
props:
|
|
18
|
+
props: popoverArrowProps,
|
|
37
19
|
render() {
|
|
38
|
-
return h(
|
|
20
|
+
return h(PopperArrow, mergeProps(this.$props, {}), () => this.$slots.default?.());
|
|
39
21
|
}
|
|
40
22
|
});
|
|
41
23
|
|
|
42
24
|
const [injectPopoverRootContext, providePopoverRootContext] = createContext("DestylerPopoverRoot");
|
|
43
|
-
const
|
|
25
|
+
const popoverRootProps = {
|
|
26
|
+
/**
|
|
27
|
+
* The open state of the popover when it is initially rendered. Use when you do not need to control its open state.
|
|
28
|
+
*
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
44
31
|
defaultOpen: {
|
|
45
32
|
type: Boolean,
|
|
46
33
|
required: false,
|
|
47
34
|
default: false
|
|
48
35
|
},
|
|
36
|
+
/**
|
|
37
|
+
* The controlled open state of the popover.
|
|
38
|
+
*
|
|
39
|
+
* @default undefined
|
|
40
|
+
*/
|
|
49
41
|
open: {
|
|
50
42
|
type: Boolean,
|
|
51
43
|
required: false,
|
|
52
44
|
default: void 0
|
|
53
45
|
},
|
|
46
|
+
/**
|
|
47
|
+
* The modality of the popover. When set to true, interaction with outside elements will be disabled and only popover content will be visible to screen readers.
|
|
48
|
+
*
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
54
51
|
modal: {
|
|
55
52
|
type: Boolean,
|
|
56
53
|
required: false,
|
|
57
54
|
default: false
|
|
58
55
|
}
|
|
59
56
|
};
|
|
60
|
-
const
|
|
57
|
+
const popoverRootEmits = {
|
|
58
|
+
/**
|
|
59
|
+
* Event handler called when the open state of the popover changes.
|
|
60
|
+
*/
|
|
61
|
+
"update:open": (_value) => true
|
|
62
|
+
};
|
|
63
|
+
const PopoverRoot = defineComponent({
|
|
61
64
|
name: "DestylerPopoverRoot",
|
|
62
|
-
props:
|
|
63
|
-
emits:
|
|
65
|
+
props: popoverRootProps,
|
|
66
|
+
emits: popoverRootEmits,
|
|
64
67
|
setup(props, { emit }) {
|
|
65
68
|
const modalRef = toRef(props.modal);
|
|
66
69
|
const openRef = useVModel(props, "open", emit, {
|
|
@@ -93,25 +96,23 @@ const DestylerPopoverRoot = defineComponent({
|
|
|
93
96
|
};
|
|
94
97
|
},
|
|
95
98
|
render() {
|
|
96
|
-
return h(
|
|
99
|
+
return h(PopperRoot, null, () => this.$slots.default?.());
|
|
97
100
|
}
|
|
98
101
|
});
|
|
99
102
|
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
},
|
|
103
|
+
const popoverCloseProps = {
|
|
104
|
+
...primitiveProps,
|
|
105
|
+
/**
|
|
106
|
+
* @default button
|
|
107
|
+
*/
|
|
106
108
|
as: {
|
|
107
|
-
|
|
108
|
-
required: false,
|
|
109
|
+
...primitiveProps.as,
|
|
109
110
|
default: "button"
|
|
110
111
|
}
|
|
111
112
|
};
|
|
112
|
-
const
|
|
113
|
+
const PopoverClose = defineComponent({
|
|
113
114
|
name: "DestylerPopoverClose",
|
|
114
|
-
props:
|
|
115
|
+
props: popoverCloseProps,
|
|
115
116
|
setup() {
|
|
116
117
|
const rootContext = injectPopoverRootContext();
|
|
117
118
|
return {
|
|
@@ -119,7 +120,7 @@ const DestylerPopoverClose = defineComponent({
|
|
|
119
120
|
};
|
|
120
121
|
},
|
|
121
122
|
render() {
|
|
122
|
-
return h(
|
|
123
|
+
return h(Primitive, {
|
|
123
124
|
as: this.$props.as,
|
|
124
125
|
asChild: this.$props.asChild,
|
|
125
126
|
type: this.$props.as === "button" ? "button" : void 0,
|
|
@@ -130,97 +131,34 @@ const DestylerPopoverClose = defineComponent({
|
|
|
130
131
|
}
|
|
131
132
|
});
|
|
132
133
|
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
},
|
|
134
|
+
const popoverContentImplProps = {
|
|
135
|
+
...popperContentProps,
|
|
136
|
+
...dismissableLayerProps,
|
|
137
|
+
/**
|
|
138
|
+
* Used to force mounting when more control is needed. Useful when
|
|
139
|
+
* controlling animation with Vue animation libraries.
|
|
140
|
+
*/
|
|
213
141
|
trapFocus: {
|
|
214
|
-
|
|
215
|
-
required: false,
|
|
216
|
-
default: false
|
|
142
|
+
...focusScopeProps.trapped
|
|
217
143
|
}
|
|
218
144
|
};
|
|
219
|
-
const
|
|
220
|
-
|
|
145
|
+
const popoverContentImplEmits = {
|
|
146
|
+
...dismissableLayerEmits,
|
|
147
|
+
/**
|
|
148
|
+
* Event handler called when auto-focusing on open.
|
|
149
|
+
* Can be prevented.
|
|
150
|
+
*/
|
|
151
|
+
openAutoFocus: (_event) => true,
|
|
152
|
+
/**
|
|
153
|
+
* Event handler called when auto-focusing on close.
|
|
154
|
+
* Can be prevented.
|
|
155
|
+
*/
|
|
156
|
+
closeAutoFocus: (_event) => true
|
|
157
|
+
};
|
|
158
|
+
const PopoverContentImpl = defineComponent({
|
|
221
159
|
name: "DestylerPopoverContentImpl",
|
|
222
|
-
props:
|
|
223
|
-
emits:
|
|
160
|
+
props: popoverContentImplProps,
|
|
161
|
+
emits: popoverContentImplEmits,
|
|
224
162
|
setup(props) {
|
|
225
163
|
const forwarded = useForwardProps(props);
|
|
226
164
|
const rootContext = injectPopoverRootContext();
|
|
@@ -231,7 +169,7 @@ const DestylerPopoverContentImpl = defineComponent({
|
|
|
231
169
|
};
|
|
232
170
|
},
|
|
233
171
|
render() {
|
|
234
|
-
return h(
|
|
172
|
+
return h(FocusScope, {
|
|
235
173
|
asChild: true,
|
|
236
174
|
loop: true,
|
|
237
175
|
trapped: this.$props.trapFocus,
|
|
@@ -241,7 +179,7 @@ const DestylerPopoverContentImpl = defineComponent({
|
|
|
241
179
|
onUnmountAutoFocus: (event) => {
|
|
242
180
|
this.$emit("closeAutoFocus", event);
|
|
243
181
|
}
|
|
244
|
-
}, () => h(
|
|
182
|
+
}, () => h(DismissableLayer, {
|
|
245
183
|
asChild: true,
|
|
246
184
|
disableOutsidePointerEvents: this.$props.disableOutsidePointerEvents,
|
|
247
185
|
onPointerDownOutside: (event) => {
|
|
@@ -259,15 +197,15 @@ const DestylerPopoverContentImpl = defineComponent({
|
|
|
259
197
|
onDismiss: () => {
|
|
260
198
|
this.rootContext.onOpenChange(false);
|
|
261
199
|
}
|
|
262
|
-
}, () => withDirectives(h(
|
|
200
|
+
}, () => withDirectives(h(PopperContent, mergeProps(this.forwarded, {
|
|
263
201
|
"data-state": this.rootContext.open.value ? "open" : "closed",
|
|
264
202
|
"role": "dialog",
|
|
265
203
|
"style": {
|
|
266
|
-
"--
|
|
267
|
-
"--
|
|
268
|
-
"--
|
|
269
|
-
"--
|
|
270
|
-
"--
|
|
204
|
+
"--destyler-popover-content-transform-origin": "var(--destyler-popper-transform-origin)",
|
|
205
|
+
"--destyler-popover-content-available-width": "var(--destyler-popper-available-width)",
|
|
206
|
+
"--destyler-popover-content-available-height": "var(--destyler-popper-available-height)",
|
|
207
|
+
"--destyler-popover-trigger-width": "var(--destyler-popper-anchor-width)",
|
|
208
|
+
"--destyler-popover-trigger-height": "var(--destyler-popper-anchor-height)"
|
|
271
209
|
}
|
|
272
210
|
}), () => this.$slots.default?.()), [
|
|
273
211
|
[BindOnceDirective, { id: this.rootContext.contentId }]
|
|
@@ -275,10 +213,10 @@ const DestylerPopoverContentImpl = defineComponent({
|
|
|
275
213
|
}
|
|
276
214
|
});
|
|
277
215
|
|
|
278
|
-
const
|
|
216
|
+
const PopoverContentModal = defineComponent({
|
|
279
217
|
name: "DestylerPopoverContentModal",
|
|
280
|
-
props:
|
|
281
|
-
emits:
|
|
218
|
+
props: popoverContentImplProps,
|
|
219
|
+
emits: popoverContentImplEmits,
|
|
282
220
|
setup(props, { emit }) {
|
|
283
221
|
const rootContext = injectPopoverRootContext();
|
|
284
222
|
const isRightClickOutsideRef = ref(false);
|
|
@@ -293,7 +231,7 @@ const DestylerPopoverContentModal = defineComponent({
|
|
|
293
231
|
};
|
|
294
232
|
},
|
|
295
233
|
render() {
|
|
296
|
-
return h(
|
|
234
|
+
return h(PopoverContentImpl, {
|
|
297
235
|
ref: (el) => this.forwardRef(el),
|
|
298
236
|
...mergeProps(this.forwarded),
|
|
299
237
|
trapFocus: this.rootContext.open.value,
|
|
@@ -314,10 +252,10 @@ const DestylerPopoverContentModal = defineComponent({
|
|
|
314
252
|
}
|
|
315
253
|
});
|
|
316
254
|
|
|
317
|
-
const
|
|
255
|
+
const PopoverContentNonModal = defineComponent({
|
|
318
256
|
name: "DestylerPopoverContentNonModal",
|
|
319
|
-
props:
|
|
320
|
-
emits:
|
|
257
|
+
props: popoverContentImplProps,
|
|
258
|
+
emits: popoverContentImplEmits,
|
|
321
259
|
setup(props, { emit }) {
|
|
322
260
|
const rootContext = injectPopoverRootContext();
|
|
323
261
|
const hasInteractedOutsideRef = ref(false);
|
|
@@ -331,7 +269,7 @@ const DestylerPopoverContentNonModal = defineComponent({
|
|
|
331
269
|
};
|
|
332
270
|
},
|
|
333
271
|
render() {
|
|
334
|
-
return h(
|
|
272
|
+
return h(PopoverContentImpl, {
|
|
335
273
|
...this.forwarded,
|
|
336
274
|
trapFocus: false,
|
|
337
275
|
disableOutsidePointerEvents: false,
|
|
@@ -363,19 +301,27 @@ const DestylerPopoverContentNonModal = defineComponent({
|
|
|
363
301
|
}
|
|
364
302
|
});
|
|
365
303
|
|
|
366
|
-
const
|
|
367
|
-
...
|
|
304
|
+
const popoverContentProps = {
|
|
305
|
+
...popoverContentImplProps,
|
|
306
|
+
/**
|
|
307
|
+
* Used to force mounting when more control is needed. Useful when
|
|
308
|
+
* controlling animation with Vue animation libraries.
|
|
309
|
+
*
|
|
310
|
+
* @default false
|
|
311
|
+
*/
|
|
368
312
|
forceMount: {
|
|
369
313
|
type: Boolean,
|
|
370
314
|
required: false,
|
|
371
315
|
default: false
|
|
372
316
|
}
|
|
373
317
|
};
|
|
374
|
-
const
|
|
375
|
-
|
|
318
|
+
const popoverContentEmits = {
|
|
319
|
+
...popoverContentImplEmits
|
|
320
|
+
};
|
|
321
|
+
const PopoverContent = defineComponent({
|
|
376
322
|
name: "DestylerPopoverContent",
|
|
377
|
-
props:
|
|
378
|
-
emits:
|
|
323
|
+
props: popoverContentProps,
|
|
324
|
+
emits: popoverContentEmits,
|
|
379
325
|
setup(props, { emit }) {
|
|
380
326
|
const rootContext = injectPopoverRootContext();
|
|
381
327
|
const forwarded = useForwardPropsEmits(props, emit);
|
|
@@ -386,56 +332,40 @@ const DestylerPopoverContent = defineComponent({
|
|
|
386
332
|
},
|
|
387
333
|
render() {
|
|
388
334
|
const useVShow = this.rootContext.modal.value;
|
|
389
|
-
return h(
|
|
335
|
+
return h(Presence, {
|
|
390
336
|
present: this.forceMount || this.rootContext.open.value
|
|
391
|
-
}, () => useVShow ? h(
|
|
337
|
+
}, () => useVShow ? h(PopoverContentModal, {
|
|
392
338
|
...this.forwarded
|
|
393
|
-
}, () => this.$slots.default?.()) : h(
|
|
339
|
+
}, () => this.$slots.default?.()) : h(PopoverContentNonModal, {
|
|
394
340
|
...this.forwarded
|
|
395
341
|
}, () => this.$slots.default?.()));
|
|
396
342
|
}
|
|
397
343
|
});
|
|
398
344
|
|
|
399
|
-
const
|
|
400
|
-
|
|
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
|
-
}
|
|
345
|
+
const popoverPortalProps = {
|
|
346
|
+
...teleportPrimitiveProps
|
|
415
347
|
};
|
|
416
|
-
const
|
|
348
|
+
const PopoverPortal = defineComponent({
|
|
417
349
|
name: "DestylerPopoverPortal",
|
|
418
|
-
props:
|
|
350
|
+
props: popoverPortalProps,
|
|
419
351
|
render() {
|
|
420
|
-
return h(
|
|
352
|
+
return h(TeleportPrimitive, mergeProps(this.$props), () => this.$slots.default?.());
|
|
421
353
|
}
|
|
422
354
|
});
|
|
423
355
|
|
|
424
|
-
const
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
},
|
|
356
|
+
const popoverTriggerProps = {
|
|
357
|
+
...primitiveProps,
|
|
358
|
+
/**
|
|
359
|
+
* @default button
|
|
360
|
+
*/
|
|
430
361
|
as: {
|
|
431
|
-
|
|
432
|
-
required: false,
|
|
362
|
+
...primitiveProps.as,
|
|
433
363
|
default: "button"
|
|
434
364
|
}
|
|
435
365
|
};
|
|
436
|
-
const
|
|
366
|
+
const PopoverTrigger = defineComponent({
|
|
437
367
|
name: "DestylerPopoverTrigger",
|
|
438
|
-
props:
|
|
368
|
+
props: popoverTriggerProps,
|
|
439
369
|
setup() {
|
|
440
370
|
const rootContext = injectPopoverRootContext();
|
|
441
371
|
const { forwardRef, currentElement: triggerElement } = useForwardExpose();
|
|
@@ -448,9 +378,9 @@ const DestylerPopoverTrigger = defineComponent({
|
|
|
448
378
|
};
|
|
449
379
|
},
|
|
450
380
|
render() {
|
|
451
|
-
return h(this.rootContext.hasCustomAnchor.value ?
|
|
381
|
+
return h(this.rootContext.hasCustomAnchor.value ? Primitive : PopperAnchor, {
|
|
452
382
|
asChild: true
|
|
453
|
-
}, () => h(
|
|
383
|
+
}, () => h(Primitive, {
|
|
454
384
|
"ref": (el) => this.forwardRef(el),
|
|
455
385
|
"type": this.$props.as === "button" ? "button" : void 0,
|
|
456
386
|
"as": this.$props.as,
|
|
@@ -466,4 +396,4 @@ const DestylerPopoverTrigger = defineComponent({
|
|
|
466
396
|
}
|
|
467
397
|
});
|
|
468
398
|
|
|
469
|
-
export {
|
|
399
|
+
export { PopoverArrow as P, PopoverClose as a, popoverCloseProps as b, PopoverContent as c, popoverContentProps as d, popoverContentEmits as e, PopoverContentImpl as f, popoverContentImplProps as g, popoverContentImplEmits as h, injectPopoverRootContext as i, PopoverContentModal as j, PopoverContentNonModal as k, PopoverPortal as l, popoverPortalProps as m, PopoverRoot as n, popoverRootProps as o, popoverArrowProps as p, popoverRootEmits as q, PopoverTrigger as r, popoverTriggerProps as s };
|