pxd 0.0.26 → 0.0.28
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/active-graph/index.vue +9 -9
- package/dist/components/avatar/index.vue +4 -4
- package/dist/components/avatar-group/index.vue +2 -2
- package/dist/components/badge/index.vue +2 -2
- package/dist/components/book/index.vue +10 -10
- package/dist/components/book/index.vue.d.ts +1 -1
- package/dist/components/browser/index.vue +10 -10
- package/dist/components/button/index.vue +4 -4
- package/dist/components/carousel/index.vue +1 -1
- package/dist/components/carousel-group/index.vue +26 -20
- package/dist/components/checkbox/index.vue +7 -6
- package/dist/components/checkbox-group/index.vue +1 -1
- package/dist/components/chip/index.vue +6 -6
- package/dist/components/choicebox/index.vue +2 -2
- package/dist/components/collapse/index.vue +2 -2
- package/dist/components/config-provider/index.vue +1 -1
- package/dist/components/countdown/index.vue +39 -0
- package/dist/components/countdown/index.vue.d.ts +49 -0
- package/dist/components/description/index.vue +2 -2
- package/dist/components/drawer/index.vue +5 -5
- package/dist/components/empty-state/index.vue +6 -6
- package/dist/components/error/index.vue +1 -1
- package/dist/components/gauge/index.vue +4 -4
- package/dist/components/hold-button/index.vue +3 -3
- package/dist/components/hold-button/index.vue.d.ts +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/input/index.vue +7 -7
- package/dist/components/kbd/index.vue +1 -1
- package/dist/components/link-button/index.vue +1 -1
- package/dist/components/loading-dots/index.vue +3 -3
- package/dist/components/material/index.vue +1 -1
- package/dist/components/menu/index.vue +1 -2
- package/dist/components/menu-item/index.vue +1 -1
- package/dist/components/menu-list/index.vue +3 -2
- package/dist/components/modal/index.vue +5 -5
- package/dist/components/more-button/index.vue +1 -1
- package/dist/components/note/index.vue +2 -2
- package/dist/components/overlay/index.vue +8 -8
- package/dist/components/pagination/index.vue +9 -9
- package/dist/components/pin-input/index.vue +3 -3
- package/dist/components/popover/index.vue +175 -176
- package/dist/components/popover/index.vue.d.ts +3 -4
- package/dist/components/progress/index.vue +3 -3
- package/dist/components/radio/index.vue +8 -7
- package/dist/components/radio-group/index.vue +1 -1
- package/dist/components/resizable/index.vue +3 -2
- package/dist/components/resizable-handle/index.vue +10 -6
- package/dist/components/resizable-panel/index.vue +4 -4
- package/dist/components/resizable-panel/index.vue.d.ts +2 -2
- package/dist/components/scrollable/index.vue +8 -8
- package/dist/components/skeleton/index.vue +1 -1
- package/dist/components/slider/index.vue +4 -4
- package/dist/components/snippet/index.vue +3 -3
- package/dist/components/spinner/index.vue +2 -2
- package/dist/components/stack/index.vue +5 -4
- package/dist/components/stack/index.vue.d.ts +2 -2
- package/dist/components/status-dot/index.vue +1 -1
- package/dist/components/switch/index.vue +3 -3
- package/dist/components/switch-group/index.vue +1 -1
- package/dist/components/text/index.vue.d.ts +1 -1
- package/dist/components/textarea/index.vue +2 -2
- package/dist/components/theme-switcher/index.vue +9 -80
- package/dist/components/theme-switcher/index.vue.d.ts +5 -6
- package/dist/components/toggle/index.vue +32 -25
- package/dist/components/toggle/index.vue.d.ts +7 -4
- package/dist/components/tooltip/index.vue +12 -13
- package/dist/components/tooltip/index.vue.d.ts +6 -1
- package/dist/components/virtual-list/index.vue +2 -2
- package/dist/composables/index.d.ts +2 -0
- package/dist/composables/index.js +2 -0
- package/dist/composables/useColorScheme.d.ts +7 -0
- package/dist/composables/useColorScheme.js +70 -0
- package/dist/composables/useConfigProviderContext.js +1 -1
- package/dist/composables/useCountdown.d.ts +48 -0
- package/dist/composables/useCountdown.js +136 -0
- package/dist/composables/useFocusTrap.js +21 -2
- package/dist/composables/useMediaQuery.d.ts +9 -8
- package/dist/composables/useMediaQuery.js +45 -19
- package/dist/contexts/resizable.d.ts +4 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/locales/index.d.ts +2 -2
- package/dist/locales/index.js +2 -2
- package/dist/styles/styles.css +1 -1
- package/dist/styles/tw.css +15 -5
- package/dist/types/shared/props.d.ts +2 -2
- package/dist/utils/debounce.d.ts +73 -0
- package/dist/utils/debounce.js +60 -0
- package/dist/utils/dom.js +2 -2
- package/dist/utils/events.d.ts +6 -3
- package/dist/utils/events.js +34 -0
- package/dist/utils/fn.d.ts +1 -2
- package/dist/utils/fn.js +0 -2
- package/dist/utils/is.d.ts +0 -1
- package/dist/utils/is.js +0 -1
- package/dist/utils/throttle.d.ts +47 -0
- package/dist/utils/throttle.js +19 -0
- package/package.json +13 -20
- /package/dist/locales/{en-US.d.ts → en-us.d.ts} +0 -0
- /package/dist/locales/{en-US.js → en-us.js} +0 -0
- /package/dist/locales/{zh-CN.d.ts → zh-cn.d.ts} +0 -0
- /package/dist/locales/{zh-CN.js → zh-cn.js} +0 -0
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, nextTick, onBeforeUnmount, onMounted, shallowRef, watch } from "vue";
|
|
3
3
|
import { useDelayDestroy } from "../../composables/useDelayDestroy";
|
|
4
|
+
import { PRESET_MEDIA_QUERIES, useMediaQuery } from "../../composables/useMediaQuery";
|
|
4
5
|
import {
|
|
5
6
|
getElementRectFromContainer,
|
|
6
7
|
getScrollContainer,
|
|
7
8
|
getScrollElByContainer,
|
|
8
9
|
getScrollPositions
|
|
9
10
|
} from "../../utils/dom";
|
|
10
|
-
import { off, on } from "../../utils/events";
|
|
11
|
+
import { off, on, optimizedOff, optimizedOn } from "../../utils/events";
|
|
11
12
|
import { throttleByRaf } from "../../utils/fn";
|
|
12
13
|
import { toArray } from "../../utils/format";
|
|
13
|
-
import {
|
|
14
|
+
import { isServer } from "../../utils/is";
|
|
14
15
|
import PTeleport from "../teleport/index.vue";
|
|
15
16
|
defineOptions({
|
|
16
17
|
name: "PPopover"
|
|
@@ -27,29 +28,36 @@ const props = defineProps({
|
|
|
27
28
|
showDelay: { type: Number, required: false, default: 300 },
|
|
28
29
|
hideDelay: { type: Number, required: false, default: 300 },
|
|
29
30
|
enterable: { type: Boolean, required: false },
|
|
30
|
-
showArrow: { type: Boolean, required: false, default:
|
|
31
|
-
arrowColor: { type: String, required: false, default: "var(--
|
|
32
|
-
triggerClass: { type: [String, Array, Object], required: false },
|
|
33
|
-
popoverClass: { type: [String, Array, Object], required: false },
|
|
31
|
+
showArrow: { type: Boolean, required: false, default: false },
|
|
32
|
+
arrowColor: { type: String, required: false, default: "hsl(var(--primary))" },
|
|
34
33
|
destroyDelay: { type: Number, required: false, default: 2e3 },
|
|
35
34
|
scrollHidden: { type: Boolean, required: false, default: false },
|
|
35
|
+
triggerClass: { type: [String, Array, Object], required: false },
|
|
36
|
+
popoverClass: { type: [String, Array, Object], required: false },
|
|
37
|
+
triggerStyle: { type: [Object, String], required: false },
|
|
36
38
|
popoverStyle: { type: [Object, String], required: false },
|
|
37
39
|
transitionName: { type: String, required: false },
|
|
38
40
|
showTransition: { type: Boolean, required: false, default: true },
|
|
39
41
|
hideTransition: { type: Boolean, required: false, default: true },
|
|
40
|
-
translateOffset: { type: [String, Number], required: false, default: 0 },
|
|
41
42
|
closeOnPressEscape: { type: Boolean, required: false, default: false },
|
|
42
|
-
scrollHiddenThreshold: { type: Number, required: false, default:
|
|
43
|
+
scrollHiddenThreshold: { type: Number, required: false, default: 150 },
|
|
43
44
|
dynamicPositionThreshold: { type: Number, required: false, default: 5 }
|
|
44
45
|
});
|
|
45
46
|
const emits = defineEmits(["show", "hide", "trigger-keydown"]);
|
|
46
|
-
|
|
47
|
+
const triggerRect = shallowRef();
|
|
47
48
|
let viewportRect = null;
|
|
48
49
|
let scrollContainer;
|
|
49
50
|
let cachedContainerRect = null;
|
|
50
51
|
let lastScrollInfo = null;
|
|
51
52
|
let showPopoverTimer;
|
|
52
53
|
let hidePopoverTimer;
|
|
54
|
+
const triggerRef = shallowRef();
|
|
55
|
+
const wrapperRef = shallowRef();
|
|
56
|
+
const localPosition = shallowRef(props.position);
|
|
57
|
+
const wrapperStyle = shallowRef({
|
|
58
|
+
left: "-100%",
|
|
59
|
+
top: "-100%"
|
|
60
|
+
});
|
|
53
61
|
const {
|
|
54
62
|
render: isRender,
|
|
55
63
|
visible: isVisible,
|
|
@@ -59,27 +67,20 @@ const {
|
|
|
59
67
|
default: props.visible,
|
|
60
68
|
delay: props.destroyDelay
|
|
61
69
|
});
|
|
62
|
-
const
|
|
63
|
-
const containerRef = shallowRef();
|
|
64
|
-
const localPosition = shallowRef(props.position);
|
|
65
|
-
const originalPosition = shallowRef(props.position);
|
|
66
|
-
const containerStyle = shallowRef({
|
|
67
|
-
left: "-100%",
|
|
68
|
-
top: "-100%"
|
|
69
|
-
});
|
|
70
|
+
const isSmUp = useMediaQuery(PRESET_MEDIA_QUERIES.SM_UP);
|
|
70
71
|
const triggerMethods = computed(() => toArray(props.trigger));
|
|
71
72
|
let cachedScrollTop = 0;
|
|
72
|
-
let
|
|
73
|
-
let
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return
|
|
73
|
+
let cachedBasePosition = null;
|
|
74
|
+
let cachedPositionForBase = null;
|
|
75
|
+
const basePosition = computed(() => {
|
|
76
|
+
if (cachedPositionForBase === localPosition.value && cachedBasePosition) {
|
|
77
|
+
return cachedBasePosition;
|
|
78
|
+
}
|
|
79
|
+
cachedPositionForBase = localPosition.value;
|
|
80
|
+
cachedBasePosition = localPosition.value.split("-")[0];
|
|
81
|
+
return cachedBasePosition;
|
|
81
82
|
});
|
|
82
|
-
const
|
|
83
|
+
const computedTransitionName = computed(() => props.transitionName ?? `pxd-transition--popover-${basePosition.value}`);
|
|
83
84
|
const onContainerScroll = throttleByRaf((ev) => {
|
|
84
85
|
if (!isVisible.value) {
|
|
85
86
|
return;
|
|
@@ -112,14 +113,14 @@ function isContainerOverlapping(viewportRect2, containerRect, scrollInfo) {
|
|
|
112
113
|
};
|
|
113
114
|
}
|
|
114
115
|
function getTriggerRect() {
|
|
115
|
-
triggerRect = triggerRef.value.getBoundingClientRect();
|
|
116
|
+
triggerRect.value = triggerRef.value.getBoundingClientRect();
|
|
116
117
|
viewportRect = document.documentElement.getBoundingClientRect();
|
|
117
118
|
}
|
|
118
119
|
function handleDynamicPositionAdjustment() {
|
|
119
|
-
if (!
|
|
120
|
+
if (!wrapperRef.value || !triggerRect.value || !viewportRect) {
|
|
120
121
|
return;
|
|
121
122
|
}
|
|
122
|
-
const containerRect =
|
|
123
|
+
const containerRect = wrapperRef.value.getBoundingClientRect();
|
|
123
124
|
const scrollInfo = getScrollPositions(scrollContainer);
|
|
124
125
|
if (cachedContainerRect && lastScrollInfo) {
|
|
125
126
|
const rectChanged = Math.abs(containerRect.top - cachedContainerRect.top) > 1 || Math.abs(containerRect.left - cachedContainerRect.left) > 1;
|
|
@@ -131,18 +132,17 @@ function handleDynamicPositionAdjustment() {
|
|
|
131
132
|
cachedContainerRect = containerRect;
|
|
132
133
|
lastScrollInfo = scrollInfo;
|
|
133
134
|
getTriggerRect();
|
|
135
|
+
const originalPosition = props.position;
|
|
134
136
|
const currentOverlapping = isContainerOverlapping(viewportRect, containerRect, scrollInfo);
|
|
135
137
|
let needsUpdate = false;
|
|
136
138
|
if (currentOverlapping.isOverlapping) {
|
|
137
|
-
if (localPosition.value === originalPosition
|
|
139
|
+
if (localPosition.value === originalPosition) {
|
|
138
140
|
reverseRenderPosition(currentOverlapping);
|
|
139
141
|
needsUpdate = true;
|
|
140
142
|
}
|
|
141
|
-
} else {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
143
|
+
} else if (localPosition.value !== originalPosition) {
|
|
144
|
+
handleOriginalPositionCheck();
|
|
145
|
+
return;
|
|
146
146
|
}
|
|
147
147
|
if (needsUpdate) {
|
|
148
148
|
updateContentPosition();
|
|
@@ -150,13 +150,13 @@ function handleDynamicPositionAdjustment() {
|
|
|
150
150
|
}
|
|
151
151
|
function handleOriginalPositionCheck() {
|
|
152
152
|
const tempPosition = localPosition.value;
|
|
153
|
-
localPosition.value =
|
|
153
|
+
localPosition.value = props.position;
|
|
154
154
|
updateContentPosition();
|
|
155
155
|
nextTick(() => {
|
|
156
|
-
if (!
|
|
156
|
+
if (!wrapperRef.value || !viewportRect) {
|
|
157
157
|
return;
|
|
158
158
|
}
|
|
159
|
-
const newContainerRect =
|
|
159
|
+
const newContainerRect = wrapperRef.value.getBoundingClientRect();
|
|
160
160
|
const newOverlapping = isContainerOverlapping(viewportRect, newContainerRect, getScrollPositions(scrollContainer));
|
|
161
161
|
if (newOverlapping.isOverlapping) {
|
|
162
162
|
localPosition.value = tempPosition;
|
|
@@ -172,7 +172,6 @@ async function handlePopoverShow(immediate = false) {
|
|
|
172
172
|
clearTimeout(showPopoverTimer);
|
|
173
173
|
showPopoverTimer = setTimeout(() => {
|
|
174
174
|
localPosition.value = props.position;
|
|
175
|
-
originalPosition.value = props.position;
|
|
176
175
|
updateContentPosition();
|
|
177
176
|
openPopover();
|
|
178
177
|
resolve(true);
|
|
@@ -181,17 +180,16 @@ async function handlePopoverShow(immediate = false) {
|
|
|
181
180
|
});
|
|
182
181
|
cachedScrollTop = getScrollElByContainer(scrollContainer).scrollTop;
|
|
183
182
|
on(scrollContainer, "scroll", onContainerScroll, { passive: true });
|
|
184
|
-
nextTick(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
});
|
|
183
|
+
await nextTick();
|
|
184
|
+
const overlapping = isContainerOverlapping(
|
|
185
|
+
viewportRect,
|
|
186
|
+
wrapperRef.value.getBoundingClientRect(),
|
|
187
|
+
getScrollPositions(scrollContainer)
|
|
188
|
+
);
|
|
189
|
+
if (overlapping.isOverlapping) {
|
|
190
|
+
reverseRenderPosition(overlapping);
|
|
191
|
+
updateContentPosition();
|
|
192
|
+
}
|
|
195
193
|
}
|
|
196
194
|
async function handlePopoverHide(immediate = false) {
|
|
197
195
|
await new Promise((resolve) => {
|
|
@@ -260,7 +258,7 @@ async function onTriggerContextmenu(ev) {
|
|
|
260
258
|
}
|
|
261
259
|
function onClickOutsideToHide(ev) {
|
|
262
260
|
const target = ev.target;
|
|
263
|
-
if (!triggerRef.value?.contains(target) && !
|
|
261
|
+
if (!triggerRef.value?.contains(target) && !wrapperRef.value?.contains(target)) {
|
|
264
262
|
handlePopoverHide();
|
|
265
263
|
}
|
|
266
264
|
}
|
|
@@ -283,74 +281,93 @@ function onContentPointerLeave() {
|
|
|
283
281
|
handlePopoverHide();
|
|
284
282
|
}
|
|
285
283
|
function updateContentPosition() {
|
|
284
|
+
const { offset, maxWidth, zIndex, arrowColor } = props;
|
|
285
|
+
const { scrollLeft, scrollTop, width, height } = getElementRectFromContainer(triggerRect.value, viewportRect);
|
|
286
286
|
const position = localPosition.value;
|
|
287
|
-
const { offset, arrowColor, maxWidth } = props;
|
|
288
|
-
const { scrollLeft, scrollTop, width, height } = getElementRectFromContainer(triggerRect, viewportRect);
|
|
289
287
|
const isVertical = position.startsWith("top") || position.startsWith("bottom");
|
|
290
288
|
const isHorizontal = position.startsWith("left") || position.startsWith("right");
|
|
291
289
|
let top = "";
|
|
292
290
|
let left = "";
|
|
293
|
-
let
|
|
291
|
+
let translateX = "0";
|
|
292
|
+
let translateY = "0";
|
|
294
293
|
if (isVertical) {
|
|
295
294
|
if (position === "top") {
|
|
296
295
|
top = `${scrollTop}px`;
|
|
297
296
|
left = `${scrollLeft + width / 2}px`;
|
|
298
|
-
|
|
297
|
+
translateX = "-50%";
|
|
298
|
+
translateY = "-100%";
|
|
299
299
|
} else if (position === "bottom") {
|
|
300
300
|
top = `${scrollTop + height}px`;
|
|
301
301
|
left = `${scrollLeft + width / 2}px`;
|
|
302
|
-
|
|
302
|
+
translateX = "-50%";
|
|
303
303
|
} else if (position === "top-start") {
|
|
304
304
|
top = `${scrollTop}px`;
|
|
305
305
|
left = `${scrollLeft}px`;
|
|
306
|
-
|
|
306
|
+
translateY = "-100%";
|
|
307
307
|
} else if (position === "top-end") {
|
|
308
308
|
top = `${scrollTop}px`;
|
|
309
309
|
left = `${scrollLeft + width}px`;
|
|
310
|
-
|
|
310
|
+
translateX = "-100%";
|
|
311
|
+
translateY = "-100%";
|
|
311
312
|
} else if (position === "bottom-start") {
|
|
312
313
|
top = `${scrollTop + height}px`;
|
|
313
314
|
left = `${scrollLeft}px`;
|
|
314
|
-
transform = "translate(0, 0)";
|
|
315
315
|
} else if (position === "bottom-end") {
|
|
316
316
|
top = `${scrollTop + height}px`;
|
|
317
317
|
left = `${scrollLeft + width}px`;
|
|
318
|
-
|
|
318
|
+
translateX = "-100%";
|
|
319
|
+
}
|
|
320
|
+
if (!isSmUp.value) {
|
|
321
|
+
left = "";
|
|
322
|
+
translateX = "0";
|
|
319
323
|
}
|
|
320
324
|
} else if (isHorizontal) {
|
|
321
|
-
if (
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
325
|
+
if (isSmUp.value) {
|
|
326
|
+
if (position === "left") {
|
|
327
|
+
top = `${scrollTop + height / 2}px`;
|
|
328
|
+
left = `${scrollLeft}px`;
|
|
329
|
+
translateX = "-100%";
|
|
330
|
+
translateY = "-50%";
|
|
331
|
+
} else if (position === "right") {
|
|
332
|
+
top = `${scrollTop + height / 2}px`;
|
|
333
|
+
left = `${scrollLeft + width}px`;
|
|
334
|
+
translateX = "0";
|
|
335
|
+
translateY = "-50%";
|
|
336
|
+
} else if (position === "left-start") {
|
|
337
|
+
top = `${scrollTop}px`;
|
|
338
|
+
left = `${scrollLeft}px`;
|
|
339
|
+
translateX = "-100%";
|
|
340
|
+
translateY = "0";
|
|
341
|
+
} else if (position === "left-end") {
|
|
342
|
+
top = `${scrollTop + height}px`;
|
|
343
|
+
left = `${scrollLeft}px`;
|
|
344
|
+
translateX = "-100%";
|
|
345
|
+
translateY = "-100%";
|
|
346
|
+
} else if (position === "right-start") {
|
|
347
|
+
top = `${scrollTop}px`;
|
|
348
|
+
left = `${scrollLeft + width}px`;
|
|
349
|
+
} else if (position === "right-end") {
|
|
350
|
+
top = `${scrollTop + height}px`;
|
|
351
|
+
left = `${scrollLeft + width}px`;
|
|
352
|
+
translateX = "0";
|
|
353
|
+
translateY = "-100%";
|
|
354
|
+
}
|
|
355
|
+
} else {
|
|
338
356
|
top = `${scrollTop}px`;
|
|
339
|
-
left =
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
top = `${scrollTop + height}px`;
|
|
343
|
-
left = `${scrollLeft + width}px`;
|
|
344
|
-
transform = "translate(0, -100%)";
|
|
357
|
+
left = "";
|
|
358
|
+
translateY = "-100%";
|
|
359
|
+
localPosition.value = "top-start";
|
|
345
360
|
}
|
|
346
361
|
}
|
|
347
|
-
|
|
362
|
+
wrapperStyle.value = {
|
|
348
363
|
left,
|
|
349
364
|
top,
|
|
350
|
-
|
|
351
|
-
"
|
|
365
|
+
zIndex,
|
|
366
|
+
"transform": `translate3d(${translateX}, ${translateY}, 0)`,
|
|
367
|
+
"--color": arrowColor,
|
|
352
368
|
"--offset": `${offset}px`,
|
|
353
|
-
"--
|
|
369
|
+
"--max-width": `${maxWidth}px`,
|
|
370
|
+
"--arrow-offset": `${offset - 5}px`
|
|
354
371
|
};
|
|
355
372
|
}
|
|
356
373
|
function reverseRenderPosition(overlapping) {
|
|
@@ -386,16 +403,6 @@ function reverseRenderPosition(overlapping) {
|
|
|
386
403
|
}
|
|
387
404
|
localPosition.value = newModifier ? `${newPosition}-${newModifier}` : newPosition;
|
|
388
405
|
}
|
|
389
|
-
watch(
|
|
390
|
-
() => props.visible,
|
|
391
|
-
(visible) => {
|
|
392
|
-
if (visible) {
|
|
393
|
-
handlePopoverShow();
|
|
394
|
-
} else {
|
|
395
|
-
handlePopoverHide();
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
);
|
|
399
406
|
const triggerMethodEvents = {
|
|
400
407
|
click: [
|
|
401
408
|
["click", onTriggerClick]
|
|
@@ -437,35 +444,50 @@ function onTriggerKeydown(ev) {
|
|
|
437
444
|
ev.stopPropagation();
|
|
438
445
|
handlePopoverHide();
|
|
439
446
|
}
|
|
447
|
+
function onResizeUpdatePosition() {
|
|
448
|
+
if (!isVisible.value) {
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
getTriggerRect();
|
|
452
|
+
updateContentPosition();
|
|
453
|
+
}
|
|
454
|
+
watch(
|
|
455
|
+
() => props.visible,
|
|
456
|
+
(visible) => {
|
|
457
|
+
if (visible) {
|
|
458
|
+
handlePopoverShow();
|
|
459
|
+
} else {
|
|
460
|
+
handlePopoverHide();
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
);
|
|
440
464
|
watch(
|
|
441
465
|
() => [triggerRef.value, triggerMethods.value],
|
|
442
466
|
([newDom, newMethods], [oldDom, oldMethods]) => {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
}
|
|
446
|
-
if (newDom) {
|
|
447
|
-
updateTriggerEvents(newMethods, newDom, on);
|
|
448
|
-
}
|
|
467
|
+
updateTriggerEvents(oldMethods, oldDom, off);
|
|
468
|
+
updateTriggerEvents(newMethods, newDom, on);
|
|
449
469
|
}
|
|
450
470
|
);
|
|
451
471
|
onMounted(() => {
|
|
452
|
-
if (
|
|
472
|
+
if (isServer) {
|
|
453
473
|
return;
|
|
454
474
|
}
|
|
455
475
|
scrollContainer = getScrollContainer(triggerRef.value, true);
|
|
476
|
+
optimizedOn(window, "resize", onResizeUpdatePosition);
|
|
456
477
|
});
|
|
457
478
|
onBeforeUnmount(() => {
|
|
458
|
-
triggerRect = null;
|
|
459
479
|
viewportRect = null;
|
|
480
|
+
triggerRect.value = void 0;
|
|
460
481
|
cachedContainerRect = null;
|
|
461
482
|
lastScrollInfo = null;
|
|
462
|
-
|
|
463
|
-
|
|
483
|
+
cachedBasePosition = null;
|
|
484
|
+
cachedPositionForBase = null;
|
|
464
485
|
clearTimeout(showPopoverTimer);
|
|
465
486
|
clearTimeout(hidePopoverTimer);
|
|
466
487
|
off(document, "click", onClickOutsideToHide);
|
|
467
488
|
off(document, "contextmenu", onTriggerContextmenu);
|
|
468
489
|
off(scrollContainer, "scroll", onContainerScroll);
|
|
490
|
+
optimizedOff(window, "resize", onResizeUpdatePosition);
|
|
469
491
|
});
|
|
470
492
|
defineExpose({
|
|
471
493
|
show: handlePopoverShow,
|
|
@@ -477,8 +499,9 @@ defineExpose({
|
|
|
477
499
|
<div class="pxd-popover relative inline-flex w-max">
|
|
478
500
|
<div
|
|
479
501
|
ref="triggerRef"
|
|
480
|
-
class="pxd-
|
|
502
|
+
class="pxd-popover--trigger active:select-none"
|
|
481
503
|
:class="triggerClass"
|
|
504
|
+
:style="triggerStyle"
|
|
482
505
|
@contextmenu.prevent
|
|
483
506
|
@keydown="onTriggerKeydown"
|
|
484
507
|
>
|
|
@@ -486,22 +509,20 @@ defineExpose({
|
|
|
486
509
|
</div>
|
|
487
510
|
|
|
488
511
|
<PTeleport>
|
|
489
|
-
<Transition
|
|
490
|
-
mode="out-in" :name="transitionName" :class="{ showTransition, hideTransition }"
|
|
491
|
-
:style="{ '--translate-offset': translateOffset, zIndex }"
|
|
492
|
-
>
|
|
512
|
+
<Transition mode="out-in" :name="computedTransitionName" :class="{ showTransition, hideTransition }">
|
|
493
513
|
<div
|
|
494
514
|
v-if="isRender"
|
|
495
515
|
v-show="isVisible"
|
|
496
|
-
ref="
|
|
497
|
-
:style="
|
|
516
|
+
ref="wrapperRef"
|
|
517
|
+
:style="wrapperStyle"
|
|
518
|
+
:data-arrow="showArrow"
|
|
519
|
+
:data-enterable="enterable"
|
|
498
520
|
:data-position="localPosition"
|
|
499
|
-
class="pxd-
|
|
500
|
-
:class="[{ 'pointer-events-none': !enterable, 'show-arrow': showArrow }]"
|
|
521
|
+
class="pxd-popover--container sm:max-w-(--max-width) p-2.5 sm:p-0 absolute isolate w-max max-w-full data-[enterable=false]:pointer-events-none"
|
|
501
522
|
@pointerenter="onContentPointerEnter"
|
|
502
523
|
@pointerleave="onContentPointerLeave"
|
|
503
524
|
>
|
|
504
|
-
<div class="pxd-
|
|
525
|
+
<div class="pxd-popover--content" :class="popoverClass" :style="popoverStyle">
|
|
505
526
|
<slot name="content">
|
|
506
527
|
{{ content }}
|
|
507
528
|
</slot>
|
|
@@ -513,7 +534,7 @@ defineExpose({
|
|
|
513
534
|
</template>
|
|
514
535
|
|
|
515
536
|
<style lang="postcss">
|
|
516
|
-
.pxd-
|
|
537
|
+
.pxd-popover--container {
|
|
517
538
|
|
|
518
539
|
&[data-position^='top'] {
|
|
519
540
|
padding-bottom: var(--offset);
|
|
@@ -531,75 +552,75 @@ defineExpose({
|
|
|
531
552
|
padding-left: var(--offset);
|
|
532
553
|
}
|
|
533
554
|
|
|
534
|
-
|
|
535
|
-
.pxd-
|
|
555
|
+
&[data-arrow="true"] {
|
|
556
|
+
.pxd-popover--content::after {
|
|
536
557
|
content: '';
|
|
537
558
|
position: absolute;
|
|
538
559
|
border-style: solid;
|
|
539
560
|
z-index: 1;
|
|
540
561
|
}
|
|
541
562
|
|
|
542
|
-
&[data-position="top"] .pxd-
|
|
543
|
-
&[data-position="top-start"] .pxd-
|
|
544
|
-
&[data-position="top-end"] .pxd-
|
|
545
|
-
bottom:
|
|
563
|
+
&[data-position="top"] .pxd-popover--content::after,
|
|
564
|
+
&[data-position="top-start"] .pxd-popover--content::after,
|
|
565
|
+
&[data-position="top-end"] .pxd-popover--content::after {
|
|
566
|
+
bottom: var(--arrow-offset);
|
|
546
567
|
border-width: 6px 6px 0;
|
|
547
|
-
border-color: var(--
|
|
568
|
+
border-color: var(--color) transparent transparent;
|
|
548
569
|
}
|
|
549
570
|
|
|
550
|
-
&[data-position='bottom'] .pxd-
|
|
551
|
-
&[data-position='bottom-start'] .pxd-
|
|
552
|
-
&[data-position='bottom-end'] .pxd-
|
|
553
|
-
top:
|
|
571
|
+
&[data-position='bottom'] .pxd-popover--content::after,
|
|
572
|
+
&[data-position='bottom-start'] .pxd-popover--content::after,
|
|
573
|
+
&[data-position='bottom-end'] .pxd-popover--content::after {
|
|
574
|
+
top: var(--arrow-offset);
|
|
554
575
|
border-width: 0 6px 6px;
|
|
555
|
-
border-color: transparent transparent var(--
|
|
576
|
+
border-color: transparent transparent var(--color);
|
|
556
577
|
}
|
|
557
578
|
|
|
558
|
-
&[data-position='left'] .pxd-
|
|
559
|
-
&[data-position='left-start'] .pxd-
|
|
560
|
-
&[data-position='left-end'] .pxd-
|
|
561
|
-
right:
|
|
579
|
+
&[data-position='left'] .pxd-popover--content::after,
|
|
580
|
+
&[data-position='left-start'] .pxd-popover--content::after,
|
|
581
|
+
&[data-position='left-end'] .pxd-popover--content::after {
|
|
582
|
+
right: var(--arrow-offset);
|
|
562
583
|
border-width: 6px 0 6px 6px;
|
|
563
|
-
border-color: transparent transparent transparent var(--
|
|
584
|
+
border-color: transparent transparent transparent var(--color);
|
|
564
585
|
}
|
|
565
586
|
|
|
566
|
-
&[data-position='right'] .pxd-
|
|
567
|
-
&[data-position='right-start'] .pxd-
|
|
568
|
-
&[data-position='right-end'] .pxd-
|
|
569
|
-
left:
|
|
587
|
+
&[data-position='right'] .pxd-popover--content::after,
|
|
588
|
+
&[data-position='right-start'] .pxd-popover--content::after,
|
|
589
|
+
&[data-position='right-end'] .pxd-popover--content::after {
|
|
590
|
+
left: var(--arrow-offset);
|
|
570
591
|
border-width: 6px 6px 6px 0;
|
|
571
|
-
border-color: transparent var(--
|
|
592
|
+
border-color: transparent var(--color) transparent transparent;
|
|
572
593
|
}
|
|
573
594
|
|
|
574
|
-
&[data-position='top'] .pxd-
|
|
575
|
-
&[data-position='bottom'] .pxd-
|
|
595
|
+
&[data-position='top'] .pxd-popover--content::after,
|
|
596
|
+
&[data-position='bottom'] .pxd-popover--content::after {
|
|
576
597
|
left: 50%;
|
|
577
598
|
transform: translateX(-50%);
|
|
578
599
|
}
|
|
579
600
|
|
|
580
|
-
&[data-position='left'] .pxd-
|
|
581
|
-
&[data-position='right'] .pxd-
|
|
601
|
+
&[data-position='left'] .pxd-popover--content::after,
|
|
602
|
+
&[data-position='right'] .pxd-popover--content::after {
|
|
582
603
|
top: 50%;
|
|
583
604
|
transform: translateY(-50%);
|
|
584
605
|
}
|
|
585
606
|
|
|
586
|
-
&[data-position='left-start'] .pxd-
|
|
587
|
-
&[data-position='right-start'] .pxd-
|
|
607
|
+
&[data-position='left-start'] .pxd-popover--content::after,
|
|
608
|
+
&[data-position='right-start'] .pxd-popover--content::after {
|
|
588
609
|
top: 15px;
|
|
589
610
|
}
|
|
590
611
|
|
|
591
|
-
&[data-position='left-end'] .pxd-
|
|
592
|
-
&[data-position='right-end'] .pxd-
|
|
612
|
+
&[data-position='left-end'] .pxd-popover--content::after,
|
|
613
|
+
&[data-position='right-end'] .pxd-popover--content::after {
|
|
593
614
|
bottom: 15px;
|
|
594
615
|
}
|
|
595
616
|
|
|
596
|
-
&[data-position='top-start'] .pxd-
|
|
597
|
-
&[data-position='bottom-start'] .pxd-
|
|
617
|
+
&[data-position='top-start'] .pxd-popover--content::after,
|
|
618
|
+
&[data-position='bottom-start'] .pxd-popover--content::after {
|
|
598
619
|
left: 15px;
|
|
599
620
|
}
|
|
600
621
|
|
|
601
|
-
&[data-position='top-end'] .pxd-
|
|
602
|
-
&[data-position='bottom-end'] .pxd-
|
|
622
|
+
&[data-position='top-end'] .pxd-popover--content::after,
|
|
623
|
+
&[data-position='bottom-end'] .pxd-popover--content::after {
|
|
603
624
|
right: 15px;
|
|
604
625
|
}
|
|
605
626
|
}
|
|
@@ -613,9 +634,7 @@ defineExpose({
|
|
|
613
634
|
.hideTransition.pxd-transition--popover-left-leave-active,
|
|
614
635
|
.showTransition.pxd-transition--popover-right-enter-active,
|
|
615
636
|
.hideTransition.pxd-transition--popover-right-leave-active {
|
|
616
|
-
transition:
|
|
617
|
-
opacity var(--default-transition-duration) var(--default-transition-timing-function),
|
|
618
|
-
margin var(--default-transition-duration) var(--default-transition-timing-function);
|
|
637
|
+
transition: opacity var(--default-transition-duration) var(--default-transition-timing-function);
|
|
619
638
|
}
|
|
620
639
|
|
|
621
640
|
.showTransition.pxd-transition--popover-top-enter-from,
|
|
@@ -628,24 +647,4 @@ defineExpose({
|
|
|
628
647
|
.hideTransition.pxd-transition--popover-right-leave-to {
|
|
629
648
|
opacity: 0;
|
|
630
649
|
}
|
|
631
|
-
|
|
632
|
-
.showTransition.pxd-transition--popover-top-enter-from,
|
|
633
|
-
.hideTransition.pxd-transition--popover-top-leave-to {
|
|
634
|
-
margin-top: calc(1px * var(--translate-offset));
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
.showTransition.pxd-transition--popover-bottom-enter-from,
|
|
638
|
-
.hideTransition.pxd-transition--popover-bottom-leave-to {
|
|
639
|
-
margin-top: calc(-1px * var(--translate-offset));
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
.showTransition.pxd-transition--popover-left-enter-from,
|
|
643
|
-
.hideTransition.pxd-transition--popover-left-leave-to {
|
|
644
|
-
margin-left: calc(1px * var(--translate-offset));
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
.showTransition.pxd-transition--popover-right-enter-from,
|
|
648
|
-
.hideTransition.pxd-transition--popover-right-leave-to {
|
|
649
|
-
margin-left: calc(-1px * var(--translate-offset));
|
|
650
|
-
}
|
|
651
650
|
</style>
|
|
@@ -15,15 +15,15 @@ interface Props {
|
|
|
15
15
|
enterable?: boolean;
|
|
16
16
|
showArrow?: boolean;
|
|
17
17
|
arrowColor?: string;
|
|
18
|
-
triggerClass?: ComponentClass;
|
|
19
|
-
popoverClass?: ComponentClass;
|
|
20
18
|
destroyDelay?: number;
|
|
21
19
|
scrollHidden?: boolean;
|
|
20
|
+
triggerClass?: ComponentClass;
|
|
21
|
+
popoverClass?: ComponentClass;
|
|
22
|
+
triggerStyle?: CSSProperties | string;
|
|
22
23
|
popoverStyle?: CSSProperties | string;
|
|
23
24
|
transitionName?: string;
|
|
24
25
|
showTransition?: boolean;
|
|
25
26
|
hideTransition?: boolean;
|
|
26
|
-
translateOffset?: string | number;
|
|
27
27
|
closeOnPressEscape?: boolean;
|
|
28
28
|
scrollHiddenThreshold?: number;
|
|
29
29
|
dynamicPositionThreshold?: number;
|
|
@@ -61,7 +61,6 @@ declare const __VLS_component: import("vue").DefineComponent<Props, {
|
|
|
61
61
|
scrollHidden: boolean;
|
|
62
62
|
showTransition: boolean;
|
|
63
63
|
hideTransition: boolean;
|
|
64
|
-
translateOffset: string | number;
|
|
65
64
|
closeOnPressEscape: boolean;
|
|
66
65
|
scrollHiddenThreshold: number;
|
|
67
66
|
dynamicPositionThreshold: number;
|
|
@@ -49,7 +49,7 @@ const computedLabel = computed(() => {
|
|
|
49
49
|
return false;
|
|
50
50
|
});
|
|
51
51
|
const computedClass = computed(() => {
|
|
52
|
-
const classes = ["pxd-progress-bar flex-1 rounded-full
|
|
52
|
+
const classes = ["pxd-progress-bar flex-1 overflow-hidden rounded-full bg-gray-200", getFallbackValue(props.size, SIZES, config.size)];
|
|
53
53
|
return classes.join(" ");
|
|
54
54
|
});
|
|
55
55
|
const computedColors = computed(() => {
|
|
@@ -69,12 +69,12 @@ const computedProgressBarStyles = computed(() => {
|
|
|
69
69
|
</script>
|
|
70
70
|
|
|
71
71
|
<template>
|
|
72
|
-
<div role="progressbar" class="pxd-progress w-full
|
|
72
|
+
<div role="progressbar" class="pxd-progress flex w-full items-center" :aria-valuenow="progress" :aria-valuemin="min" :aria-valuemax="max">
|
|
73
73
|
<div :class="computedClass">
|
|
74
74
|
<div class="h-full rounded-inherit motion-safe:transition-all" :style="computedProgressBarStyles" />
|
|
75
75
|
</div>
|
|
76
76
|
|
|
77
|
-
<span v-if="computedLabel || $slots.default" class="text-
|
|
77
|
+
<span v-if="computedLabel || $slots.default" class="text-sm ml-3 font-mono text-foreground-secondary empty:hidden">
|
|
78
78
|
<slot>
|
|
79
79
|
{{ computedLabel }}
|
|
80
80
|
</slot>
|