pxd 0.0.45 → 0.0.47
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/components/_internal/fragment-container.d.ts +2 -0
- package/dist/components/_internal/fragment-container.js +25 -0
- package/dist/components/badge/index.vue +1 -1
- package/dist/components/button/index.vue +1 -1
- package/dist/components/carousel-group/index.d.vue.ts +1 -2
- package/dist/components/carousel-group/index.vue +16 -4
- package/dist/components/carousel-group/index.vue.d.ts +1 -2
- package/dist/components/choicebox/index.vue +1 -1
- package/dist/components/choicebox-group/index.vue +1 -1
- package/dist/components/config-provider/index.vue +1 -1
- package/dist/components/error/index.d.vue.ts +2 -2
- package/dist/components/error/index.vue +1 -1
- package/dist/components/error/index.vue.d.ts +2 -2
- package/dist/components/fader/index.vue +4 -21
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/input/index.d.vue.ts +4 -5
- package/dist/components/input/index.vue +67 -71
- package/dist/components/input/index.vue.d.ts +4 -5
- package/dist/components/intersection-observer/index.vue +3 -3
- package/dist/components/link-button/index.vue +1 -1
- package/dist/components/list-item/index.vue +1 -1
- package/dist/components/menu/index.d.vue.ts +3 -3
- package/dist/components/menu/index.vue +1 -7
- package/dist/components/menu/index.vue.d.ts +3 -3
- package/dist/components/noise-background/index.d.vue.ts +19 -0
- package/dist/components/noise-background/index.vue +18 -0
- package/dist/components/noise-background/index.vue.d.ts +19 -0
- package/dist/components/note/index.d.vue.ts +3 -3
- package/dist/components/note/index.vue +1 -1
- package/dist/components/note/index.vue.d.ts +3 -3
- package/dist/components/number-input/index.d.vue.ts +1 -1
- package/dist/components/number-input/index.vue +1 -1
- package/dist/components/number-input/index.vue.d.ts +1 -1
- package/dist/components/pin-input/index.d.vue.ts +3 -14
- package/dist/components/pin-input/index.vue +28 -40
- package/dist/components/pin-input/index.vue.d.ts +3 -14
- package/dist/components/placeholder/index.vue +3 -5
- package/dist/components/popover/index.d.vue.ts +6 -16
- package/dist/components/popover/index.vue +71 -284
- package/dist/components/popover/index.vue.d.ts +6 -16
- package/dist/components/progress/index.d.vue.ts +1 -1
- package/dist/components/progress/index.vue.d.ts +1 -1
- package/dist/components/slider/index.d.vue.ts +1 -1
- package/dist/components/slider/index.vue.d.ts +1 -1
- package/dist/components/stack/index.vue +1 -1
- package/dist/components/status-dot/index.d.vue.ts +3 -2
- package/dist/components/status-dot/index.vue +1 -1
- package/dist/components/status-dot/index.vue.d.ts +3 -2
- package/dist/components/text/index.vue +1 -1
- package/dist/components/textarea/index.d.vue.ts +2 -13
- package/dist/components/textarea/index.vue +25 -33
- package/dist/components/textarea/index.vue.d.ts +2 -13
- package/dist/components/time-picker/index.d.vue.ts +7 -0
- package/dist/components/time-picker/index.vue +76 -93
- package/dist/components/time-picker/index.vue.d.ts +7 -0
- package/dist/components/toggle/index.d.vue.ts +4 -7
- package/dist/components/toggle/index.vue +32 -41
- package/dist/components/toggle/index.vue.d.ts +4 -7
- package/dist/components/tooltip/index.vue +1 -1
- package/dist/composables/use-outside-click.js +8 -2
- package/dist/styles/source.css +4 -3
- package/dist/styles/styles.css +1 -1
- package/dist/styles/tw.css +4 -3
- package/dist/types/components/error.d.ts +1 -1
- package/dist/types/components/input.d.ts +1 -1
- package/dist/utils/debounce.d.ts +1 -1
- package/dist/utils/debounce.js +1 -1
- package/dist/utils/get.d.ts +0 -8
- package/dist/utils/get.js +0 -125
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.js +11 -0
- package/dist/utils/throttle.d.ts +7 -1
- package/dist/utils/throttle.js +16 -1
- package/package.json +8 -2
- package/volar.d.ts +1 -1
- package/dist/components/keep-alive-container/index.d.vue.ts +0 -13
- package/dist/components/keep-alive-container/index.vue +0 -11
- package/dist/components/keep-alive-container/index.vue.d.ts +0 -13
- package/dist/utils/debounce/compat.d.ts +0 -143
- package/dist/utils/debounce/compat.js +0 -47
- package/dist/utils/debounce/index.d.ts +0 -73
- package/dist/utils/debounce/index.js +0 -60
- package/dist/utils/throttle/compat.d.ts +0 -79
- package/dist/utils/throttle/compat.js +0 -9
- package/dist/utils/throttle/index.d.ts +0 -53
- package/dist/utils/throttle/index.js +0 -34
|
@@ -1,31 +1,24 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import {
|
|
2
|
+
import { arrow, computePosition, flip, offset, shift } from "@floating-ui/dom";
|
|
3
|
+
import { computed, shallowRef, watch } from "vue";
|
|
3
4
|
import { useIntersectionObserver } from "../../composables/use-browser-observer";
|
|
4
5
|
import { useDelayDestroy } from "../../composables/use-delay-destroy";
|
|
5
6
|
import { useOutsideClick } from "../../composables/use-outside-click";
|
|
6
7
|
import { debounce } from "../../utils/debounce";
|
|
7
|
-
import {
|
|
8
|
-
getElementRectFromContainer,
|
|
9
|
-
getScrollContainer,
|
|
10
|
-
getScrollElByContainer,
|
|
11
|
-
getViewportRect
|
|
12
|
-
} from "../../utils/dom";
|
|
13
8
|
import { optimizedOff, optimizedOn } from "../../utils/event";
|
|
14
9
|
import { getCssUnitValue, toArray } from "../../utils/format";
|
|
15
|
-
import { isServer } from "../../utils/is";
|
|
16
|
-
import { throttleByRaf } from "../../utils/throttle";
|
|
17
10
|
import PTeleport from "../teleport/index.vue";
|
|
18
11
|
defineOptions({
|
|
19
12
|
name: "PPopover",
|
|
20
13
|
inheritAttrs: false
|
|
21
14
|
});
|
|
22
15
|
const props = defineProps({
|
|
23
|
-
zIndex: { type: Number, required: false
|
|
16
|
+
zIndex: { type: [Number, String], required: false },
|
|
24
17
|
offset: { type: Number, required: false, default: 8 },
|
|
25
18
|
visible: { type: Boolean, required: false },
|
|
26
19
|
trigger: { type: [String, Array], required: false, default: () => ["hover"] },
|
|
27
20
|
disabled: { type: Boolean, required: false },
|
|
28
|
-
maxWidth: { type: Number, required: false },
|
|
21
|
+
maxWidth: { type: [Number, String], required: false },
|
|
29
22
|
position: { type: null, required: false, default: "bottom" },
|
|
30
23
|
showDelay: { type: Number, required: false, default: 300 },
|
|
31
24
|
hideDelay: { type: Number, required: false, default: 300 },
|
|
@@ -33,36 +26,27 @@ const props = defineProps({
|
|
|
33
26
|
showArrow: { type: Boolean, required: false },
|
|
34
27
|
arrowColor: { type: String, required: false, default: "hsl(var(--primary))" },
|
|
35
28
|
autoPosition: { type: Boolean, required: false, default: true },
|
|
36
|
-
closeOnScroll: { type: Boolean, required: false },
|
|
37
29
|
wrapperClass: { type: [String, Array, Object], required: false },
|
|
38
30
|
contentClass: { type: [String, Array, Object], required: false },
|
|
39
31
|
contentStyle: { type: [Object, String], required: false },
|
|
40
|
-
showTransition: { type: Boolean, required: false, default: true },
|
|
41
|
-
hideTransition: { type: Boolean, required: false, default: true },
|
|
42
32
|
transitionType: { type: String, required: false, default: "fade-scale" },
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
closeOnScrollThreshold: { type: Number, required: false, default: 150 }
|
|
33
|
+
closeOnInvisible: { type: Boolean, required: false, default: true },
|
|
34
|
+
closeOnPressEscape: { type: Boolean, required: false }
|
|
46
35
|
});
|
|
47
36
|
const emits = defineEmits(["show", "hide", "escape", "outside-click", "trigger-click", "visible-change"]);
|
|
48
|
-
let triggerRect = null;
|
|
49
|
-
let wrapperRect = null;
|
|
50
|
-
let viewportRect = null;
|
|
51
|
-
let scrollContainer;
|
|
52
37
|
let showPopoverTimer;
|
|
53
38
|
let hidePopoverTimer;
|
|
54
|
-
let savedScrollPosition = 0;
|
|
55
39
|
const allowedMethods = ["click", "manual", "contextmenu"];
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
"--popover-bg": props.arrowColor,
|
|
60
|
-
"--popover-offset": getCssUnitValue(props.offset),
|
|
61
|
-
"--popover-max-width": getCssUnitValue(props.maxWidth),
|
|
62
|
-
"--popover-arrow-offset": `${props.offset - 5}px`
|
|
63
|
-
});
|
|
40
|
+
const arrayRef = shallowRef(null);
|
|
41
|
+
const triggerRef = shallowRef(null);
|
|
42
|
+
const wrapperRef = shallowRef(null);
|
|
64
43
|
const localPosition = shallowRef(props.position);
|
|
65
44
|
const triggerMethods = computed(() => toArray(props.trigger));
|
|
45
|
+
const wrapperStyle = computed(() => ({
|
|
46
|
+
"z-index": props.zIndex,
|
|
47
|
+
"--popover-bg": props.arrowColor,
|
|
48
|
+
"--popover-max-width": getCssUnitValue(props.maxWidth)
|
|
49
|
+
}));
|
|
66
50
|
const {
|
|
67
51
|
render: isRender,
|
|
68
52
|
visible: isVisible,
|
|
@@ -70,17 +54,10 @@ const {
|
|
|
70
54
|
hide: hidePopover
|
|
71
55
|
} = useDelayDestroy(props.visible, {
|
|
72
56
|
delay: 2e3,
|
|
73
|
-
|
|
74
|
-
if (
|
|
75
|
-
await nextTick();
|
|
76
|
-
getBoundingRects();
|
|
77
|
-
reversePositionIfNeed();
|
|
57
|
+
visibleChange(v) {
|
|
58
|
+
if (triggerMethods.value.includes("manual")) {
|
|
78
59
|
return;
|
|
79
60
|
}
|
|
80
|
-
restorePosition();
|
|
81
|
-
clearBoundingRect();
|
|
82
|
-
},
|
|
83
|
-
visibleChange(v) {
|
|
84
61
|
emits("visible-change", v);
|
|
85
62
|
if (v) {
|
|
86
63
|
emits("show");
|
|
@@ -94,7 +71,8 @@ useOutsideClick(wrapperRef, {
|
|
|
94
71
|
return isVisible.value && allowedMethods.some((t) => triggerMethods.value.includes(t));
|
|
95
72
|
},
|
|
96
73
|
isOutside: (ev) => {
|
|
97
|
-
|
|
74
|
+
const el = ev.target;
|
|
75
|
+
return !(triggerRef.value?.contains(el) || wrapperRef.value?.contains(el));
|
|
98
76
|
},
|
|
99
77
|
onTrigger: debounce((ev) => {
|
|
100
78
|
emits("outside-click", ev);
|
|
@@ -104,37 +82,12 @@ useOutsideClick(wrapperRef, {
|
|
|
104
82
|
handlePopoverHide();
|
|
105
83
|
}, 500, { edges: ["leading"] })
|
|
106
84
|
});
|
|
107
|
-
let triggerVisible = false;
|
|
108
85
|
useIntersectionObserver(triggerRef, ([entry]) => {
|
|
109
|
-
|
|
110
|
-
});
|
|
111
|
-
const onContainerScroll = throttleByRaf(async (ev) => {
|
|
112
|
-
if (!isVisible.value) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const scrollTop = getScrollElByContainer(ev.target).scrollTop;
|
|
116
|
-
const delta = Math.abs(scrollTop - savedScrollPosition);
|
|
117
|
-
if (props.closeOnScroll && (delta >= props.closeOnScrollThreshold || !triggerVisible)) {
|
|
86
|
+
if (props.closeOnInvisible && isVisible.value && entry.intersectionRatio === 0) {
|
|
118
87
|
handlePopoverHide(true);
|
|
119
88
|
}
|
|
120
|
-
if (!props.autoPosition) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if (delta < props.autoPositionThreshold) {
|
|
124
|
-
reversePositionIfNeed();
|
|
125
|
-
}
|
|
126
89
|
});
|
|
127
|
-
function
|
|
128
|
-
triggerRect = triggerRef.value.getBoundingClientRect();
|
|
129
|
-
wrapperRect = wrapperRef.value.getBoundingClientRect();
|
|
130
|
-
viewportRect = getViewportRect();
|
|
131
|
-
}
|
|
132
|
-
function clearBoundingRect() {
|
|
133
|
-
triggerRect = null;
|
|
134
|
-
wrapperRect = null;
|
|
135
|
-
viewportRect = null;
|
|
136
|
-
}
|
|
137
|
-
async function handlePopoverShow(immediate = false) {
|
|
90
|
+
async function handlePopoverShow() {
|
|
138
91
|
if (showPopoverTimer || props.disabled) {
|
|
139
92
|
return;
|
|
140
93
|
}
|
|
@@ -146,16 +99,37 @@ async function handlePopoverShow(immediate = false) {
|
|
|
146
99
|
showPopoverTimer = setTimeout(() => {
|
|
147
100
|
showPopoverTimer = null;
|
|
148
101
|
resolve();
|
|
149
|
-
},
|
|
102
|
+
}, props.showDelay);
|
|
103
|
+
});
|
|
104
|
+
await showPopover();
|
|
105
|
+
const { x, y, placement, middlewareData } = await computePosition(
|
|
106
|
+
triggerRef.value,
|
|
107
|
+
wrapperRef.value,
|
|
108
|
+
{
|
|
109
|
+
placement: localPosition.value,
|
|
110
|
+
middleware: [
|
|
111
|
+
shift(),
|
|
112
|
+
offset(props.offset),
|
|
113
|
+
props.autoPosition && flip(),
|
|
114
|
+
props.showArrow && arrow({ element: arrayRef.value })
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
localPosition.value = placement;
|
|
119
|
+
Object.assign(wrapperRef.value.style, {
|
|
120
|
+
left: `${x}px`,
|
|
121
|
+
top: `${y}px`
|
|
150
122
|
});
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
123
|
+
if (middlewareData.arrow) {
|
|
124
|
+
const { x: x2, y: y2 } = middlewareData.arrow;
|
|
125
|
+
Object.assign(arrayRef.value.style, {
|
|
126
|
+
left: x2 != null ? `${Math.max(x2, 5)}px` : "",
|
|
127
|
+
top: y2 != null ? `${Math.max(y2, 5)}px` : ""
|
|
128
|
+
});
|
|
129
|
+
}
|
|
155
130
|
if (props.closeOnPressEscape) {
|
|
156
131
|
optimizedOn(document, "keydown", onPopoverKeystroke);
|
|
157
132
|
}
|
|
158
|
-
optimizedOn(scrollContainer, "scroll", onContainerScroll, { passive: true });
|
|
159
133
|
}
|
|
160
134
|
async function handlePopoverHide(immediate = false) {
|
|
161
135
|
if (hidePopoverTimer) {
|
|
@@ -172,17 +146,15 @@ async function handlePopoverHide(immediate = false) {
|
|
|
172
146
|
}, immediate ? 0 : props.hideDelay);
|
|
173
147
|
});
|
|
174
148
|
await hidePopover();
|
|
175
|
-
wrapperRect = null;
|
|
176
149
|
if (props.closeOnPressEscape) {
|
|
177
150
|
optimizedOff(document, "keydown", onPopoverKeystroke);
|
|
178
151
|
}
|
|
179
|
-
optimizedOff(scrollContainer, "scroll", onContainerScroll);
|
|
180
152
|
}
|
|
181
153
|
function onPopoverKeystroke(ev) {
|
|
182
154
|
if (ev.ctrlKey || ev.metaKey || ev.altKey || ev.shiftKey) {
|
|
183
155
|
return;
|
|
184
156
|
}
|
|
185
|
-
if (ev.key !== "Escape"
|
|
157
|
+
if (ev.key !== "Escape") {
|
|
186
158
|
return;
|
|
187
159
|
}
|
|
188
160
|
emits("escape", ev);
|
|
@@ -257,121 +229,6 @@ function onContentPointerLeave() {
|
|
|
257
229
|
}
|
|
258
230
|
handlePopoverHide();
|
|
259
231
|
}
|
|
260
|
-
async function updateContentPosition() {
|
|
261
|
-
if (!wrapperRect) {
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
const { offset, maxWidth, zIndex, arrowColor } = props;
|
|
265
|
-
const { width: wrapperWidth, height: wrapperHeight } = wrapperRect;
|
|
266
|
-
const { scrollLeft, scrollTop, width, height } = getElementRectFromContainer(triggerRect, viewportRect);
|
|
267
|
-
let top = "";
|
|
268
|
-
let left = "";
|
|
269
|
-
switch (localPosition.value) {
|
|
270
|
-
case "top":
|
|
271
|
-
top = `${scrollTop - wrapperHeight}px`;
|
|
272
|
-
left = `${scrollLeft + width / 2 - wrapperWidth / 2}px`;
|
|
273
|
-
break;
|
|
274
|
-
case "top-start":
|
|
275
|
-
top = `${scrollTop - wrapperHeight}px`;
|
|
276
|
-
left = `${scrollLeft}px`;
|
|
277
|
-
break;
|
|
278
|
-
case "top-end":
|
|
279
|
-
top = `${scrollTop - wrapperHeight}px`;
|
|
280
|
-
left = `${scrollLeft + width - wrapperWidth}px`;
|
|
281
|
-
break;
|
|
282
|
-
case "right":
|
|
283
|
-
top = `${scrollTop + height / 2 - wrapperHeight / 2}px`;
|
|
284
|
-
left = `${scrollLeft + width}px`;
|
|
285
|
-
break;
|
|
286
|
-
case "right-start":
|
|
287
|
-
top = `${scrollTop}px`;
|
|
288
|
-
left = `${scrollLeft + width}px`;
|
|
289
|
-
break;
|
|
290
|
-
case "right-end":
|
|
291
|
-
top = `${scrollTop + height - wrapperHeight}px`;
|
|
292
|
-
left = `${scrollLeft + width}px`;
|
|
293
|
-
break;
|
|
294
|
-
case "bottom":
|
|
295
|
-
top = `${scrollTop + height}px`;
|
|
296
|
-
left = `${scrollLeft + width / 2 - wrapperWidth / 2}px`;
|
|
297
|
-
break;
|
|
298
|
-
case "bottom-start":
|
|
299
|
-
top = `${scrollTop + height}px`;
|
|
300
|
-
left = `${scrollLeft}px`;
|
|
301
|
-
break;
|
|
302
|
-
case "bottom-end":
|
|
303
|
-
top = `${scrollTop + height}px`;
|
|
304
|
-
left = `${scrollLeft + width - wrapperWidth}px`;
|
|
305
|
-
break;
|
|
306
|
-
case "left":
|
|
307
|
-
top = `${scrollTop + height / 2 - wrapperHeight / 2}px`;
|
|
308
|
-
left = `${scrollLeft - wrapperWidth}px`;
|
|
309
|
-
break;
|
|
310
|
-
case "left-start":
|
|
311
|
-
top = `${scrollTop}px`;
|
|
312
|
-
left = `${scrollLeft - wrapperWidth}px`;
|
|
313
|
-
break;
|
|
314
|
-
case "left-end":
|
|
315
|
-
top = `${scrollTop + height - wrapperHeight}px`;
|
|
316
|
-
left = `${scrollLeft - wrapperWidth}px`;
|
|
317
|
-
break;
|
|
318
|
-
}
|
|
319
|
-
wrapperStyle.value = {
|
|
320
|
-
left,
|
|
321
|
-
top,
|
|
322
|
-
zIndex,
|
|
323
|
-
"--popover-bg": arrowColor,
|
|
324
|
-
"--popover-offset": getCssUnitValue(offset),
|
|
325
|
-
"--popover-max-width": getCssUnitValue(maxWidth),
|
|
326
|
-
"--popover-arrow-offset": `${offset - 5}px`
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
function restorePosition() {
|
|
330
|
-
localPosition.value = props.position;
|
|
331
|
-
}
|
|
332
|
-
function reversePosition(position, modifier) {
|
|
333
|
-
const positionsMap = {
|
|
334
|
-
top: "bottom",
|
|
335
|
-
left: "right",
|
|
336
|
-
right: "left",
|
|
337
|
-
bottom: "top"
|
|
338
|
-
};
|
|
339
|
-
localPosition.value = `${positionsMap[position]}${modifier ? "-" : ""}${modifier}`;
|
|
340
|
-
}
|
|
341
|
-
function reversePositionIfNeed() {
|
|
342
|
-
if (!wrapperRect) {
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
const trigger = triggerRect;
|
|
346
|
-
const wrapper = wrapperRect;
|
|
347
|
-
const viewport = viewportRect;
|
|
348
|
-
const [position, modifier = ""] = localPosition.value.split("-");
|
|
349
|
-
if (position === "left") {
|
|
350
|
-
if (trigger.left - wrapper.width < 0) {
|
|
351
|
-
reversePosition(position, modifier);
|
|
352
|
-
} else {
|
|
353
|
-
restorePosition();
|
|
354
|
-
}
|
|
355
|
-
} else if (position === "top") {
|
|
356
|
-
if (trigger.top - wrapper.height < 0) {
|
|
357
|
-
reversePosition(position, modifier);
|
|
358
|
-
} else {
|
|
359
|
-
restorePosition();
|
|
360
|
-
}
|
|
361
|
-
} else if (position === "right") {
|
|
362
|
-
if (trigger.right + wrapper.width > viewport.width) {
|
|
363
|
-
reversePosition(position, modifier);
|
|
364
|
-
} else {
|
|
365
|
-
restorePosition();
|
|
366
|
-
}
|
|
367
|
-
} else if (position === "bottom") {
|
|
368
|
-
if (trigger.bottom + wrapper.height > viewport.height) {
|
|
369
|
-
reversePosition(position, modifier);
|
|
370
|
-
} else {
|
|
371
|
-
restorePosition();
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
232
|
const triggerMethodEvents = {
|
|
376
233
|
focus: [
|
|
377
234
|
["focusin", onTriggerFocusin],
|
|
@@ -393,13 +250,6 @@ function updateTriggerEvents(methods, dom, handler) {
|
|
|
393
250
|
}
|
|
394
251
|
}
|
|
395
252
|
}
|
|
396
|
-
function onResizeUpdatePosition() {
|
|
397
|
-
if (!isVisible.value || !props.autoPosition) {
|
|
398
|
-
return;
|
|
399
|
-
}
|
|
400
|
-
getBoundingRects();
|
|
401
|
-
updateContentPosition();
|
|
402
|
-
}
|
|
403
253
|
watch(
|
|
404
254
|
() => props.visible,
|
|
405
255
|
(visible) => {
|
|
@@ -417,18 +267,6 @@ watch(
|
|
|
417
267
|
updateTriggerEvents(newMethods, newDom, optimizedOn);
|
|
418
268
|
}
|
|
419
269
|
);
|
|
420
|
-
onMounted(() => {
|
|
421
|
-
if (isServer) {
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
scrollContainer = getScrollContainer(triggerRef.value);
|
|
425
|
-
optimizedOn(window, "resize", onResizeUpdatePosition);
|
|
426
|
-
});
|
|
427
|
-
onBeforeUnmount(() => {
|
|
428
|
-
clearBoundingRect();
|
|
429
|
-
optimizedOff(window, "resize", onResizeUpdatePosition);
|
|
430
|
-
optimizedOff(scrollContainer, "scroll", onContainerScroll);
|
|
431
|
-
});
|
|
432
270
|
defineExpose({
|
|
433
271
|
show: handlePopoverShow,
|
|
434
272
|
hide: handlePopoverHide
|
|
@@ -454,14 +292,12 @@ defineExpose({
|
|
|
454
292
|
:data-visible="isVisible"
|
|
455
293
|
:data-enterable="enterable"
|
|
456
294
|
:data-position="localPosition"
|
|
457
|
-
:data-show-transition="showTransition"
|
|
458
|
-
:data-hide-transition="hideTransition"
|
|
459
295
|
:data-transition-type="transitionType"
|
|
460
|
-
class="pxd-popover--container sm:max-w-(--popover-max-width) absolute isolate w-max max-w-full motion-reduce:data-[visible=false]:hidden"
|
|
296
|
+
class="pxd-popover--container sm:max-w-(--popover-max-width) absolute isolate z-1 w-max max-w-full motion-reduce:data-[visible=false]:hidden"
|
|
461
297
|
@pointerenter="onContentPointerEnter"
|
|
462
298
|
@pointerleave="onContentPointerLeave"
|
|
463
299
|
>
|
|
464
|
-
<i v-if="showArrow" class="pxd-popover--arrow absolute z-1" />
|
|
300
|
+
<i v-if="showArrow" ref="arrayRef" class="pxd-popover--arrow absolute z-1 border-solid" />
|
|
465
301
|
<div class="pxd-popover--content" :class="contentClass" :style="contentStyle">
|
|
466
302
|
<slot name="content" />
|
|
467
303
|
</div>
|
|
@@ -489,20 +325,23 @@ defineExpose({
|
|
|
489
325
|
}
|
|
490
326
|
|
|
491
327
|
.pxd-popover--container {
|
|
492
|
-
|
|
493
|
-
|
|
328
|
+
will-change: transform, opacity;
|
|
329
|
+
animation: popover-fade-show var(--default-transition-duration) var(--default-transition-timing-function) forwards;
|
|
330
|
+
|
|
331
|
+
&[data-visible="true"][data-transition-type="fade"] {
|
|
332
|
+
animation-name: popover-fade-show;
|
|
494
333
|
}
|
|
495
334
|
|
|
496
|
-
&[data-visible="false"][data-
|
|
497
|
-
animation: popover-fade-hide
|
|
335
|
+
&[data-visible="false"][data-transition-type="fade"] {
|
|
336
|
+
animation-name: popover-fade-hide;
|
|
498
337
|
}
|
|
499
338
|
|
|
500
|
-
&[data-visible="true"][data-
|
|
501
|
-
animation: popover-fade-scale-show
|
|
339
|
+
&[data-visible="true"][data-transition-type="fade-scale"] {
|
|
340
|
+
animation-name: popover-fade-scale-show;
|
|
502
341
|
}
|
|
503
342
|
|
|
504
|
-
&[data-visible="false"][data-
|
|
505
|
-
animation: popover-fade-scale-hide
|
|
343
|
+
&[data-visible="false"][data-transition-type="fade-scale"] {
|
|
344
|
+
animation-name: popover-fade-scale-hide;
|
|
506
345
|
}
|
|
507
346
|
|
|
508
347
|
&[data-enterable="false"] {
|
|
@@ -530,49 +369,29 @@ defineExpose({
|
|
|
530
369
|
}
|
|
531
370
|
|
|
532
371
|
&[data-position='left'] {
|
|
533
|
-
transform-origin:
|
|
372
|
+
transform-origin: right center ;
|
|
534
373
|
}
|
|
535
374
|
&[data-position='left-start'] {
|
|
536
|
-
transform-origin:
|
|
375
|
+
transform-origin: right top;
|
|
537
376
|
}
|
|
538
377
|
&[data-position='left-end'] {
|
|
539
|
-
transform-origin:
|
|
378
|
+
transform-origin: right bottom;
|
|
540
379
|
}
|
|
541
380
|
|
|
542
381
|
&[data-position='right'] {
|
|
543
|
-
transform-origin:
|
|
382
|
+
transform-origin: left center;
|
|
544
383
|
}
|
|
545
384
|
&[data-position='right-start'] {
|
|
546
|
-
transform-origin:
|
|
385
|
+
transform-origin: left top;
|
|
547
386
|
}
|
|
548
387
|
&[data-position='right-end'] {
|
|
549
|
-
transform-origin:
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
&[data-position^='top'] {
|
|
553
|
-
padding-bottom: var(--popover-offset);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
&[data-position^='bottom'] {
|
|
557
|
-
padding-top: var(--popover-offset);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
&[data-position^='left'] {
|
|
561
|
-
padding-right: var(--popover-offset);
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
&[data-position^='right'] {
|
|
565
|
-
padding-left: var(--popover-offset);
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
.pxd-popover--arrow {
|
|
569
|
-
border-style: solid;
|
|
388
|
+
transform-origin: left bottom;
|
|
570
389
|
}
|
|
571
390
|
|
|
572
391
|
&[data-position="top"] .pxd-popover--arrow,
|
|
573
392
|
&[data-position="top-start"] .pxd-popover--arrow,
|
|
574
393
|
&[data-position="top-end"] .pxd-popover--arrow {
|
|
575
|
-
bottom:
|
|
394
|
+
bottom: -5px;
|
|
576
395
|
border-width: 6px 6px 0;
|
|
577
396
|
border-color: var(--popover-bg) transparent transparent;
|
|
578
397
|
}
|
|
@@ -580,7 +399,7 @@ defineExpose({
|
|
|
580
399
|
&[data-position='bottom'] .pxd-popover--arrow,
|
|
581
400
|
&[data-position='bottom-start'] .pxd-popover--arrow,
|
|
582
401
|
&[data-position='bottom-end'] .pxd-popover--arrow {
|
|
583
|
-
top:
|
|
402
|
+
top: -5px;
|
|
584
403
|
border-width: 0 6px 6px;
|
|
585
404
|
border-color: transparent transparent var(--popover-bg);
|
|
586
405
|
}
|
|
@@ -588,7 +407,7 @@ defineExpose({
|
|
|
588
407
|
&[data-position='left'] .pxd-popover--arrow,
|
|
589
408
|
&[data-position='left-start'] .pxd-popover--arrow,
|
|
590
409
|
&[data-position='left-end'] .pxd-popover--arrow {
|
|
591
|
-
right:
|
|
410
|
+
right: -5px;
|
|
592
411
|
border-width: 6px 0 6px 6px;
|
|
593
412
|
border-color: transparent transparent transparent var(--popover-bg);
|
|
594
413
|
}
|
|
@@ -596,41 +415,9 @@ defineExpose({
|
|
|
596
415
|
&[data-position='right'] .pxd-popover--arrow,
|
|
597
416
|
&[data-position='right-start'] .pxd-popover--arrow,
|
|
598
417
|
&[data-position='right-end'] .pxd-popover--arrow {
|
|
599
|
-
left:
|
|
418
|
+
left: -5px;
|
|
600
419
|
border-width: 6px 6px 6px 0;
|
|
601
420
|
border-color: transparent var(--popover-bg) transparent transparent;
|
|
602
421
|
}
|
|
603
|
-
|
|
604
|
-
&[data-position='top'] .pxd-popover--arrow,
|
|
605
|
-
&[data-position='bottom'] .pxd-popover--arrow {
|
|
606
|
-
left: 50%;
|
|
607
|
-
transform: translateX(-50%);
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
&[data-position='left'] .pxd-popover--arrow,
|
|
611
|
-
&[data-position='right'] .pxd-popover--arrow {
|
|
612
|
-
top: 50%;
|
|
613
|
-
transform: translateY(-50%);
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
&[data-position='left-start'] .pxd-popover--arrow,
|
|
617
|
-
&[data-position='right-start'] .pxd-popover--arrow {
|
|
618
|
-
top: 16px;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
&[data-position='left-end'] .pxd-popover--arrow,
|
|
622
|
-
&[data-position='right-end'] .pxd-popover--arrow {
|
|
623
|
-
bottom: 16px;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
&[data-position='top-start'] .pxd-popover--arrow,
|
|
627
|
-
&[data-position='bottom-start'] .pxd-popover--arrow {
|
|
628
|
-
left: 16px;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
&[data-position='top-end'] .pxd-popover--arrow,
|
|
632
|
-
&[data-position='bottom-end'] .pxd-popover--arrow {
|
|
633
|
-
right: 16px;
|
|
634
|
-
}
|
|
635
422
|
}
|
|
636
423
|
</style>
|
|
@@ -2,12 +2,12 @@ import type { CSSProperties } from 'vue';
|
|
|
2
2
|
import type { PopoverTrigger } from '../../types/components/popover';
|
|
3
3
|
import type { ComponentClass, ComponentPosition } from '../../types/shared';
|
|
4
4
|
interface Props {
|
|
5
|
-
zIndex?: number;
|
|
5
|
+
zIndex?: number | string;
|
|
6
6
|
offset?: number;
|
|
7
7
|
visible?: boolean;
|
|
8
8
|
trigger?: PopoverTrigger | PopoverTrigger[];
|
|
9
9
|
disabled?: boolean;
|
|
10
|
-
maxWidth?: number;
|
|
10
|
+
maxWidth?: number | string;
|
|
11
11
|
position?: ComponentPosition;
|
|
12
12
|
showDelay?: number;
|
|
13
13
|
hideDelay?: number;
|
|
@@ -15,20 +15,14 @@ interface Props {
|
|
|
15
15
|
showArrow?: boolean;
|
|
16
16
|
arrowColor?: string;
|
|
17
17
|
autoPosition?: boolean;
|
|
18
|
-
closeOnScroll?: boolean;
|
|
19
18
|
wrapperClass?: ComponentClass;
|
|
20
19
|
contentClass?: ComponentClass;
|
|
21
20
|
contentStyle?: CSSProperties | string;
|
|
22
|
-
showTransition?: boolean;
|
|
23
|
-
hideTransition?: boolean;
|
|
24
21
|
transitionType?: 'fade' | 'fade-scale';
|
|
22
|
+
closeOnInvisible?: boolean;
|
|
25
23
|
closeOnPressEscape?: boolean;
|
|
26
|
-
/** 自动调整位置的阈值, 当滚动距离超过该值时, 自动调整位置, 单位: px */
|
|
27
|
-
autoPositionThreshold?: number;
|
|
28
|
-
/** 滚动隐藏的阈值, 当滚动距离超过该值时, 自动隐藏弹窗, 单位: px */
|
|
29
|
-
closeOnScrollThreshold?: number;
|
|
30
24
|
}
|
|
31
|
-
declare function handlePopoverShow(
|
|
25
|
+
declare function handlePopoverShow(): Promise<void>;
|
|
32
26
|
declare function handlePopoverHide(immediate?: boolean): Promise<void>;
|
|
33
27
|
declare var __VLS_1: {}, __VLS_9: {};
|
|
34
28
|
type __VLS_Slots = {} & {
|
|
@@ -54,19 +48,15 @@ declare const __VLS_base: import("vue").DefineComponent<Props, {
|
|
|
54
48
|
"onOutside-click"?: ((args_0: MouseEvent) => any) | undefined;
|
|
55
49
|
"onTrigger-click"?: ((args_0: PointerEvent) => any) | undefined;
|
|
56
50
|
}>, {
|
|
57
|
-
|
|
51
|
+
position: ComponentPosition;
|
|
58
52
|
offset: number;
|
|
59
53
|
trigger: PopoverTrigger | PopoverTrigger[];
|
|
60
|
-
position: ComponentPosition;
|
|
61
54
|
showDelay: number;
|
|
62
55
|
hideDelay: number;
|
|
63
56
|
arrowColor: string;
|
|
64
57
|
autoPosition: boolean;
|
|
65
|
-
showTransition: boolean;
|
|
66
|
-
hideTransition: boolean;
|
|
67
58
|
transitionType: "fade" | "fade-scale";
|
|
68
|
-
|
|
69
|
-
closeOnScrollThreshold: number;
|
|
59
|
+
closeOnInvisible: boolean;
|
|
70
60
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
71
61
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
72
62
|
declare const _default: typeof __VLS_export;
|
|
@@ -18,8 +18,8 @@ declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, i
|
|
|
18
18
|
"onUpdate:modelValue"?: ((args_0: number) => any) | undefined;
|
|
19
19
|
}>, {
|
|
20
20
|
label: boolean | string | number;
|
|
21
|
-
max: number;
|
|
22
21
|
variant: ComponentVariant | "secondary";
|
|
22
|
+
max: number;
|
|
23
23
|
min: number;
|
|
24
24
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
25
25
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -18,8 +18,8 @@ declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, i
|
|
|
18
18
|
"onUpdate:modelValue"?: ((args_0: number) => any) | undefined;
|
|
19
19
|
}>, {
|
|
20
20
|
label: boolean | string | number;
|
|
21
|
-
max: number;
|
|
22
21
|
variant: ComponentVariant | "secondary";
|
|
22
|
+
max: number;
|
|
23
23
|
min: number;
|
|
24
24
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
25
25
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -14,8 +14,8 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
|
|
|
14
14
|
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
15
15
|
"onUpdate:modelValue"?: ((args_0: NonNullable<number | [number, number] | null | undefined>) => any) | undefined;
|
|
16
16
|
}>, {
|
|
17
|
-
max: number;
|
|
18
17
|
variant: ComponentVariant | "secondary";
|
|
18
|
+
max: number;
|
|
19
19
|
modelValue: number | [number, number] | null;
|
|
20
20
|
min: number;
|
|
21
21
|
step: number;
|
|
@@ -14,8 +14,8 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
|
|
|
14
14
|
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
15
15
|
"onUpdate:modelValue"?: ((args_0: NonNullable<number | [number, number] | null | undefined>) => any) | undefined;
|
|
16
16
|
}>, {
|
|
17
|
-
max: number;
|
|
18
17
|
variant: ComponentVariant | "secondary";
|
|
18
|
+
max: number;
|
|
19
19
|
modelValue: number | [number, number] | null;
|
|
20
20
|
min: number;
|
|
21
21
|
step: number;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { ComponentLabel } from 'dist/index';
|
|
1
2
|
interface Props {
|
|
2
|
-
label?: boolean |
|
|
3
|
+
label?: boolean | ComponentLabel;
|
|
3
4
|
state?: 'QUEUED' | 'BUILDING' | 'READY' | 'ERROR' | 'CANCELED';
|
|
4
5
|
}
|
|
5
6
|
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
6
|
-
label: boolean |
|
|
7
|
+
label: boolean | ComponentLabel;
|
|
7
8
|
state: "QUEUED" | "BUILDING" | "READY" | "ERROR" | "CANCELED";
|
|
8
9
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
10
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { capitalize as capitalizeText } from "../../utils/format";
|
|
3
3
|
const props = defineProps({
|
|
4
|
-
label: { type:
|
|
4
|
+
label: { type: Boolean, required: false, skipCheck: true, default: false },
|
|
5
5
|
state: { type: String, required: false, default: "QUEUED" }
|
|
6
6
|
});
|
|
7
7
|
const stateClassNames = {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { ComponentLabel } from 'dist/index';
|
|
1
2
|
interface Props {
|
|
2
|
-
label?: boolean |
|
|
3
|
+
label?: boolean | ComponentLabel;
|
|
3
4
|
state?: 'QUEUED' | 'BUILDING' | 'READY' | 'ERROR' | 'CANCELED';
|
|
4
5
|
}
|
|
5
6
|
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
6
|
-
label: boolean |
|
|
7
|
+
label: boolean | ComponentLabel;
|
|
7
8
|
state: "QUEUED" | "BUILDING" | "READY" | "ERROR" | "CANCELED";
|
|
8
9
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
10
|
declare const _default: typeof __VLS_export;
|