pxd 0.0.55 → 0.0.61
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 +18 -4
- package/dist/components/_internal/fragment-container.vue +3 -2
- package/dist/components/active-graph/index.d.vue.ts +2 -3
- package/dist/components/active-graph/index.vue +23 -16
- package/dist/components/active-graph/types.d.ts +4 -3
- package/dist/components/avatar/index.vue +19 -10
- package/dist/components/avatar/types.d.ts +0 -12
- package/dist/components/avatar-group/index.d.vue.ts +2 -2
- package/dist/components/avatar-group/index.vue +4 -3
- package/dist/components/avatar-group/types.d.ts +11 -0
- package/dist/components/badge/index.d.vue.ts +1 -1
- package/dist/components/badge/index.vue +47 -3
- package/dist/components/badge/types.d.ts +24 -1
- package/dist/components/book/index.vue +3 -2
- package/dist/components/browser/index.vue +6 -2
- package/dist/components/button/index.d.vue.ts +1 -1
- package/dist/components/button/index.vue +60 -12
- package/dist/components/carousel/index.d.vue.ts +24 -2
- package/dist/components/carousel/index.vue +341 -28
- package/dist/components/carousel/types.d.ts +2 -2
- package/dist/components/carousel-item/index.d.vue.ts +13 -0
- package/dist/components/carousel-item/index.vue +49 -0
- package/dist/components/checkbox/index.d.vue.ts +1 -5
- package/dist/components/checkbox/index.vue +66 -31
- package/dist/components/checkbox/types.d.ts +2 -14
- package/dist/components/checkbox-group/index.d.vue.ts +2 -7
- package/dist/components/checkbox-group/index.vue +11 -29
- package/dist/components/checkbox-group/types.d.ts +12 -0
- package/dist/components/chip/index.d.vue.ts +1 -1
- package/dist/components/chip/index.vue +31 -2
- package/dist/components/choicebox/index.d.vue.ts +11 -5
- package/dist/components/choicebox/index.vue +36 -54
- package/dist/components/choicebox/types.d.ts +11 -18
- package/dist/components/choicebox-item/index.d.vue.ts +16 -0
- package/dist/components/choicebox-item/index.vue +67 -0
- package/dist/components/choicebox-item/types.d.ts +12 -0
- package/dist/components/collapse/index.d.vue.ts +5 -4
- package/dist/components/collapse/index.vue +47 -30
- package/dist/components/collapse/types.d.ts +2 -5
- package/dist/components/collapse-group/index.d.vue.ts +2 -4
- package/dist/components/collapse-group/index.vue +8 -20
- package/dist/components/collapse-group/types.d.ts +6 -0
- package/dist/components/command-menu/index.vue +6 -7
- package/dist/components/command-menu/types.d.ts +0 -5
- package/dist/components/command-menu-group/index.d.vue.ts +1 -1
- package/dist/components/command-menu-group/index.vue +3 -2
- package/dist/components/command-menu-group/types.d.ts +5 -0
- package/dist/components/config-provider/index.d.vue.ts +3 -3
- package/dist/components/config-provider/index.vue +6 -4
- package/dist/components/countdown/index.vue +3 -2
- package/dist/components/countdown/types.d.ts +2 -2
- package/dist/components/dash-line/index.vue +3 -1
- package/dist/components/description/index.d.vue.ts +1 -1
- package/dist/components/description/index.vue +8 -7
- package/dist/components/description/types.d.ts +1 -1
- package/dist/components/drawer/index.d.vue.ts +3 -2
- package/dist/components/drawer/index.vue +20 -15
- package/dist/components/drawer/types.d.ts +3 -3
- package/dist/components/ellipsis-text/index.d.vue.ts +14 -0
- package/dist/components/ellipsis-text/index.vue +242 -0
- package/dist/components/ellipsis-text/types.d.ts +14 -0
- package/dist/components/empty-state/index.vue +6 -2
- package/dist/components/error/index.d.vue.ts +1 -3
- package/dist/components/error/index.vue +21 -6
- package/dist/components/error/types.d.ts +7 -1
- package/dist/components/fader/index.vue +30 -11
- package/dist/components/fader/types.d.ts +2 -2
- package/dist/components/gauge/index.vue +7 -2
- package/dist/components/grid/index.vue +9 -4
- package/dist/components/grid/types.d.ts +0 -5
- package/dist/components/grid-item/index.d.vue.ts +1 -1
- package/dist/components/grid-item/index.vue +16 -8
- package/dist/components/grid-item/types.d.ts +6 -0
- package/dist/components/hold-button/index.d.vue.ts +2 -2
- package/dist/components/hold-button/index.vue +1 -1
- package/dist/components/index.d.ts +7 -3
- package/dist/components/index.js +7 -3
- package/dist/components/input/index.d.vue.ts +8 -8
- package/dist/components/input/index.vue +54 -21
- package/dist/components/input/types.d.ts +7 -10
- package/dist/components/intersection-observer/index.d.vue.ts +0 -1
- package/dist/components/intersection-observer/index.vue +12 -3
- package/dist/components/kbd/index.vue +1 -1
- package/dist/components/link-button/index.d.vue.ts +1 -1
- package/dist/components/link-button/index.vue +4 -6
- package/dist/components/link-button/types.d.ts +1 -1
- package/dist/components/list/index.d.vue.ts +8 -5
- package/dist/components/list/index.vue +50 -54
- package/dist/components/list/types.d.ts +3 -20
- package/dist/components/list-item/index.d.vue.ts +3 -2
- package/dist/components/list-item/index.vue +44 -18
- package/dist/components/list-item/types.d.ts +15 -0
- package/dist/components/loading-bar/index.vue +33 -2
- package/dist/components/loading-bar/types.d.ts +1 -1
- package/dist/components/loading-dots/index.vue +3 -2
- package/dist/components/menu/index.d.vue.ts +5 -2
- package/dist/components/menu/index.vue +4 -1
- package/dist/components/menu/types.d.ts +5 -0
- package/dist/components/message/index.d.vue.ts +11 -8
- package/dist/components/message/index.vue +4 -12
- package/dist/components/message/types.d.ts +1 -12
- package/dist/components/message-item/index.d.vue.ts +1 -3
- package/dist/components/message-item/index.vue +13 -7
- package/dist/components/message-item/types.d.ts +11 -0
- package/dist/components/modal/index.d.vue.ts +3 -2
- package/dist/components/modal/index.vue +17 -13
- package/dist/components/modal/types.d.ts +3 -3
- package/dist/components/noise-background/index.vue +4 -3
- package/dist/components/note/index.d.vue.ts +1 -2
- package/dist/components/note/index.vue +81 -29
- package/dist/components/note/types.d.ts +10 -2
- package/dist/components/number-input/index.d.vue.ts +5 -4
- package/dist/components/number-input/index.vue +36 -6
- package/dist/components/number-input/types.d.ts +2 -0
- package/dist/components/overlay/index.vue +1 -1
- package/dist/components/overlay/types.d.ts +1 -1
- package/dist/components/pagination/index.vue +5 -3
- package/dist/components/pin-input/index.d.vue.ts +6 -1
- package/dist/components/pin-input/index.vue +60 -23
- package/dist/components/pin-input/types.d.ts +0 -4
- package/dist/components/placeholder/index.vue +14 -11
- package/dist/components/popover/index.vue +116 -78
- package/dist/components/popover/types.d.ts +1 -0
- package/dist/components/progress/index.d.vue.ts +1 -1
- package/dist/components/progress/index.vue +15 -2
- package/dist/components/project-banner/index.d.vue.ts +18 -0
- package/dist/components/project-banner/index.vue +59 -0
- package/dist/components/project-banner/types.d.ts +8 -0
- package/dist/components/radio/index.vue +62 -20
- package/dist/components/radio/types.d.ts +1 -14
- package/dist/components/radio-group/index.d.vue.ts +2 -4
- package/dist/components/radio-group/index.vue +11 -16
- package/dist/components/radio-group/types.d.ts +12 -0
- package/dist/components/resizable/types.d.ts +5 -10
- package/dist/components/resizable-handle/index.vue +1 -1
- package/dist/components/resizable-panel/index.d.vue.ts +1 -1
- package/dist/components/resizable-panel/index.vue +7 -2
- package/dist/components/resizable-panel/types.d.ts +4 -0
- package/dist/components/scrollable/index.d.vue.ts +29 -0
- package/dist/components/scrollable/index.vue +98 -83
- package/dist/components/scrollable/types.d.ts +19 -6
- package/dist/components/skeleton/index.vue +24 -1
- package/dist/components/slider/index.d.vue.ts +6 -6
- package/dist/components/slider/index.vue +86 -44
- package/dist/components/slider/types.d.ts +1 -1
- package/dist/components/snippet/index.vue +28 -2
- package/dist/components/spinner/index.vue +4 -2
- package/dist/components/stack/index.d.vue.ts +2 -2
- package/dist/components/stack/index.vue +35 -3
- package/dist/components/stack/types.d.ts +1 -1
- package/dist/components/status-dot/index.vue +5 -1
- package/dist/components/switch/index.d.vue.ts +10 -1
- package/dist/components/switch/index.vue +35 -44
- package/dist/components/switch/types.d.ts +4 -12
- package/dist/components/switch-item/index.d.vue.ts +14 -0
- package/dist/components/switch-item/index.vue +79 -0
- package/dist/components/switch-item/types.d.ts +9 -0
- package/dist/components/teleport/index.d.vue.ts +1 -1
- package/dist/components/teleport/index.vue +1 -1
- package/dist/components/teleport/types.d.ts +1 -1
- package/dist/components/text/index.d.vue.ts +1 -2
- package/dist/components/text/index.vue +36 -22
- package/dist/components/text/types.d.ts +1 -1
- package/dist/components/textarea/index.d.vue.ts +4 -4
- package/dist/components/textarea/index.vue +33 -4
- package/dist/components/textarea/types.d.ts +0 -1
- package/dist/components/time-picker/index.d.vue.ts +1 -2
- package/dist/components/time-picker/index.vue +43 -9
- package/dist/components/time-picker/types.d.ts +1 -2
- package/dist/components/toggle/index.vue +11 -10
- package/dist/components/toggle-button/index.d.vue.ts +22 -0
- package/dist/components/toggle-button/index.vue +110 -0
- package/dist/components/toggle-button/types.d.ts +16 -0
- package/dist/components/{choicebox-group → toggle-button-group}/index.d.vue.ts +5 -5
- package/dist/components/toggle-button-group/index.vue +68 -0
- package/dist/components/toggle-button-group/types.d.ts +22 -0
- package/dist/components/tooltip/index.d.vue.ts +2 -0
- package/dist/components/tooltip/index.vue +9 -3
- package/dist/components/tooltip/types.d.ts +3 -2
- package/dist/components/virtual-list/index.d.vue.ts +25 -4
- package/dist/components/virtual-list/index.vue +66 -10
- package/dist/components/virtual-list/types.d.ts +9 -4
- package/dist/composables/index.d.ts +2 -2
- package/dist/composables/index.js +2 -2
- package/dist/composables/use-browser-observer.d.ts +5 -5
- package/dist/composables/use-browser-observer.js +23 -20
- package/dist/composables/use-copy-click.js +4 -0
- package/dist/composables/use-countdown.d.ts +2 -2
- package/dist/composables/use-delay-destroy.d.ts +1 -1
- package/dist/composables/use-focus-trap.d.ts +7 -3
- package/dist/composables/use-focus-trap.js +19 -7
- package/dist/composables/use-forward-ref-expose.d.ts +2 -0
- package/dist/composables/use-forward-ref-expose.js +41 -0
- package/dist/composables/use-message.d.ts +4 -7
- package/dist/composables/use-model-value.d.ts +9 -8
- package/dist/composables/use-popover-responsive.d.ts +2 -2
- package/dist/composables/use-popover-responsive.js +3 -3
- package/dist/composables/use-repeat-action.d.ts +1 -1
- package/dist/composables/use-repeat-action.js +2 -2
- package/dist/composables/use-virtual-list.d.ts +21 -12
- package/dist/composables/use-virtual-list.js +90 -158
- package/dist/composables/use-window-size.d.ts +4 -0
- package/dist/composables/use-window-size.js +27 -0
- package/dist/contexts/avatar.d.ts +5 -2
- package/dist/contexts/carousel.d.ts +4 -4
- package/dist/contexts/carousel.js +1 -1
- package/dist/contexts/checkbox.d.ts +7 -2
- package/dist/contexts/choicebox.d.ts +8 -4
- package/dist/contexts/choicebox.js +1 -4
- package/dist/contexts/collapse.d.ts +5 -6
- package/dist/contexts/collapse.js +1 -1
- package/dist/contexts/config-provider.d.ts +5 -0
- package/dist/{composables/use-config-provider-context.js → contexts/config-provider.js} +8 -5
- package/dist/contexts/list.d.ts +1 -1
- package/dist/contexts/radio.d.ts +8 -2
- package/dist/contexts/resizable.d.ts +1 -1
- package/dist/contexts/switch.d.ts +8 -4
- package/dist/contexts/switch.js +1 -2
- package/dist/contexts/toggle-button.d.ts +7 -0
- package/dist/contexts/toggle-button.js +2 -0
- package/dist/styles/source.css +14 -2
- package/dist/styles/styles.css +2 -2
- package/dist/styles/tw.css +14 -2
- package/dist/types/shared/props.d.ts +1 -3
- package/dist/types/shared/utils.d.ts +0 -3
- package/dist/utils/context.d.ts +1 -0
- package/dist/utils/get.d.ts +1 -0
- package/dist/utils/get.js +14 -0
- package/dist/utils/ref.d.ts +1 -1
- package/dist/utils/responsive.js +2 -1
- package/dist/utils/throttle.js +9 -7
- package/dist/utils/uid.d.ts +1 -1
- package/dist/utils/uid.js +2 -2
- package/package.json +23 -21
- package/volar.d.ts +7 -3
- package/dist/components/badge/cn.d.ts +0 -90
- package/dist/components/badge/cn.js +0 -44
- package/dist/components/button/cn.d.ts +0 -121
- package/dist/components/button/cn.js +0 -55
- package/dist/components/carousel-group/index.d.vue.ts +0 -35
- package/dist/components/carousel-group/index.vue +0 -368
- package/dist/components/checkbox/cn.d.ts +0 -67
- package/dist/components/checkbox/cn.js +0 -31
- package/dist/components/chip/cn.d.ts +0 -49
- package/dist/components/chip/cn.js +0 -26
- package/dist/components/choicebox-group/index.vue +0 -65
- package/dist/components/error/cn.d.ts +0 -22
- package/dist/components/error/cn.js +0 -15
- package/dist/components/input/cn.d.ts +0 -73
- package/dist/components/input/cn.js +0 -36
- package/dist/components/list-item/cn.d.ts +0 -22
- package/dist/components/list-item/cn.js +0 -15
- package/dist/components/loading-bar/cn.d.ts +0 -70
- package/dist/components/loading-bar/cn.js +0 -32
- package/dist/components/note/cn.d.ts +0 -121
- package/dist/components/note/cn.js +0 -66
- package/dist/components/pin-input/cn.d.ts +0 -46
- package/dist/components/pin-input/cn.js +0 -25
- package/dist/components/progress/cn.d.ts +0 -19
- package/dist/components/progress/cn.js +0 -14
- package/dist/components/radio/cn.d.ts +0 -46
- package/dist/components/radio/cn.js +0 -42
- package/dist/components/skeleton/cn.d.ts +0 -43
- package/dist/components/skeleton/cn.js +0 -24
- package/dist/components/snippet/cn.d.ts +0 -52
- package/dist/components/snippet/cn.js +0 -27
- package/dist/components/stack/cn.d.ts +0 -70
- package/dist/components/stack/cn.js +0 -33
- package/dist/components/switch/cn.d.ts +0 -16
- package/dist/components/switch/cn.js +0 -13
- package/dist/components/switch-group/index.d.vue.ts +0 -23
- package/dist/components/switch-group/index.vue +0 -54
- package/dist/components/text/cn.d.ts +0 -67
- package/dist/components/text/cn.js +0 -34
- package/dist/components/textarea/cn.d.ts +0 -58
- package/dist/components/textarea/cn.js +0 -30
- package/dist/composables/use-config-provider-context.d.ts +0 -3
- package/dist/composables/use-unique-id-context.d.ts +0 -2
- package/dist/composables/use-unique-id-context.js +0 -11
|
@@ -1,26 +1,82 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import LoaderCircleIcon from "@gdsicon/vue/loader-circle";
|
|
3
|
+
import { shallowRef } from "vue";
|
|
2
4
|
import { useVirtualList } from "../../composables/use-virtual-list";
|
|
5
|
+
defineOptions({
|
|
6
|
+
name: "PVirtualList",
|
|
7
|
+
inheritAttrs: false
|
|
8
|
+
});
|
|
3
9
|
const props = defineProps({
|
|
10
|
+
errorText: { type: String, required: false, default: "Request failed. Click to reload" },
|
|
11
|
+
loadingText: { type: String, required: false, default: "Loading..." },
|
|
12
|
+
finishedText: { type: String, required: false, default: "Finished" },
|
|
13
|
+
status: { type: String, required: false },
|
|
4
14
|
dataKey: { type: String, required: false, default: "id" },
|
|
5
15
|
listData: { type: Array, required: false, default: () => [] },
|
|
6
|
-
itemSize: { type: Number, required: false, default: 50 }
|
|
16
|
+
itemSize: { type: Number, required: false, default: 50 },
|
|
17
|
+
overScan: { type: Number, required: false, default: 2 },
|
|
18
|
+
onBottom: { type: Function, required: false },
|
|
19
|
+
bottomThreshold: { type: Number, required: false, default: 50 }
|
|
20
|
+
});
|
|
21
|
+
const emits = defineEmits(["retry", "bottom"]);
|
|
22
|
+
const containerRef = shallowRef();
|
|
23
|
+
const {
|
|
24
|
+
totalSize,
|
|
25
|
+
virtualItems,
|
|
26
|
+
measureElement,
|
|
27
|
+
getVirtualizer,
|
|
28
|
+
scrollToIndex,
|
|
29
|
+
scrollToOffset,
|
|
30
|
+
scrollBy
|
|
31
|
+
} = useVirtualList(containerRef, props);
|
|
32
|
+
function onRetryClick() {
|
|
33
|
+
if (props.status !== "error") {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
emits("retry");
|
|
37
|
+
}
|
|
38
|
+
defineExpose({
|
|
39
|
+
totalSize,
|
|
40
|
+
virtualItems,
|
|
41
|
+
getVirtualizer,
|
|
42
|
+
scrollToIndex,
|
|
43
|
+
scrollToOffset,
|
|
44
|
+
scrollBy
|
|
7
45
|
});
|
|
8
|
-
const { containerRef, renderList, listHeight, listStyle, setItemRef } = useVirtualList(props);
|
|
9
46
|
</script>
|
|
10
47
|
|
|
11
48
|
<template>
|
|
12
|
-
<div ref="containerRef" class="pxd-virtual-list relative overflow-auto">
|
|
13
|
-
<div
|
|
49
|
+
<div ref="containerRef" class="pxd-virtual-list relative overflow-auto" v-bind="$attrs">
|
|
50
|
+
<div
|
|
51
|
+
class="pxd-virtual-list--content relative w-full content-visibility-auto"
|
|
52
|
+
:style="{ height: `${totalSize}px`, containIntrinsicSize: `auto ${totalSize}px` }"
|
|
53
|
+
>
|
|
14
54
|
<div
|
|
15
|
-
v-for="
|
|
16
|
-
:key="
|
|
17
|
-
:ref="(el) =>
|
|
18
|
-
|
|
55
|
+
v-for="virtualItem in virtualItems"
|
|
56
|
+
:key="virtualItem.key"
|
|
57
|
+
:ref="(el) => measureElement(el)"
|
|
58
|
+
:data-index="virtualItem.index"
|
|
59
|
+
class="pxd-virtual-list--item left-0 top-0 absolute w-full"
|
|
60
|
+
:style="{ transform: `translateY(${virtualItem.start}px)` }"
|
|
19
61
|
>
|
|
20
|
-
<slot :item="item" />
|
|
62
|
+
<slot name="item" :item="listData[virtualItem.index]" :virtual-item="virtualItem" />
|
|
21
63
|
</div>
|
|
22
64
|
</div>
|
|
23
65
|
|
|
24
|
-
<div
|
|
66
|
+
<div
|
|
67
|
+
v-if="status"
|
|
68
|
+
class="pxd-virtual-list--message py-4 text-sm left-0 right-0 flex items-center justify-center text-gray-600 empty:hidden motion-safe:transition-colors"
|
|
69
|
+
:class="{ 'cursor-pointer hover:text-gray-900': status === 'error' }"
|
|
70
|
+
@click="onRetryClick"
|
|
71
|
+
>
|
|
72
|
+
<slot name="message">
|
|
73
|
+
<span v-if="status === 'error'">{{ errorText }}</span>
|
|
74
|
+
<span v-else-if="status === 'finished'">{{ finishedText }}</span>
|
|
75
|
+
<template v-else-if="status === 'loading'">
|
|
76
|
+
<LoaderCircleIcon class="mr-1.5 motion-safe:animate-spin" />
|
|
77
|
+
<span>{{ loadingText }}</span>
|
|
78
|
+
</template>
|
|
79
|
+
</slot>
|
|
80
|
+
</div>
|
|
25
81
|
</div>
|
|
26
82
|
</template>
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { VirtualListOptions } from '../../composables/use-virtual-list';
|
|
2
|
+
export interface VirtualListProps extends VirtualListOptions {
|
|
3
|
+
errorText?: string;
|
|
4
|
+
loadingText?: string;
|
|
5
|
+
finishedText?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface VirtualListEmits {
|
|
8
|
+
retry: [];
|
|
9
|
+
bottom: [];
|
|
5
10
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './use-browser-observer.js';
|
|
2
2
|
export * from './use-client-online.js';
|
|
3
3
|
export * from './use-color-scheme.js';
|
|
4
|
-
export * from './use-config-provider-context.js';
|
|
5
4
|
export * from './use-copy-click.js';
|
|
6
5
|
export * from './use-countdown.js';
|
|
7
6
|
export * from './use-deferred-value.js';
|
|
@@ -9,6 +8,7 @@ export * from './use-delay-change.js';
|
|
|
9
8
|
export * from './use-delay-destroy.js';
|
|
10
9
|
export * from './use-document-hidden.js';
|
|
11
10
|
export * from './use-focus-trap.js';
|
|
11
|
+
export * from './use-forward-ref-expose.js';
|
|
12
12
|
export * from './use-loading-bar.js';
|
|
13
13
|
export * from './use-lock-scroll.js';
|
|
14
14
|
export * from './use-media-query.js';
|
|
@@ -19,5 +19,5 @@ export * from './use-pointer-gesture.js';
|
|
|
19
19
|
export * from './use-popover-responsive.js';
|
|
20
20
|
export * from './use-repeat-action.js';
|
|
21
21
|
export * from './use-toggle-value.js';
|
|
22
|
-
export * from './use-unique-id-context.js';
|
|
23
22
|
export * from './use-virtual-list.js';
|
|
23
|
+
export * from './use-window-size.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from "./use-browser-observer.js";
|
|
2
2
|
export * from "./use-client-online.js";
|
|
3
3
|
export * from "./use-color-scheme.js";
|
|
4
|
-
export * from "./use-config-provider-context.js";
|
|
5
4
|
export * from "./use-copy-click.js";
|
|
6
5
|
export * from "./use-countdown.js";
|
|
7
6
|
export * from "./use-deferred-value.js";
|
|
@@ -9,6 +8,7 @@ export * from "./use-delay-change.js";
|
|
|
9
8
|
export * from "./use-delay-destroy.js";
|
|
10
9
|
export * from "./use-document-hidden.js";
|
|
11
10
|
export * from "./use-focus-trap.js";
|
|
11
|
+
export * from "./use-forward-ref-expose.js";
|
|
12
12
|
export * from "./use-loading-bar.js";
|
|
13
13
|
export * from "./use-lock-scroll.js";
|
|
14
14
|
export * from "./use-media-query.js";
|
|
@@ -19,5 +19,5 @@ export * from "./use-pointer-gesture.js";
|
|
|
19
19
|
export * from "./use-popover-responsive.js";
|
|
20
20
|
export * from "./use-repeat-action.js";
|
|
21
21
|
export * from "./use-toggle-value.js";
|
|
22
|
-
export * from "./use-unique-id-context.js";
|
|
23
22
|
export * from "./use-virtual-list.js";
|
|
23
|
+
export * from "./use-window-size.js";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { MaybeRefOrGetter } from 'vue';
|
|
2
1
|
import type { Nullable } from '../types/shared/utils';
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
2
|
+
import type { MaybeRefOrGetter, Ref } from 'vue';
|
|
3
|
+
export declare const useIntersectionObserver: (target: TargetRef, callback: IntersectionObserverCallback, options?: IntersectionObserverInit) => ObserverResults<IntersectionObserver>;
|
|
4
|
+
export declare const useMutationObserver: (target: TargetRef, callback: MutationCallback, options?: MutationObserverInit) => ObserverResults<MutationObserver>;
|
|
5
|
+
export declare const useResizeObserver: (target: TargetRef, callback: ResizeObserverCallback, options?: ResizeObserverOptions) => ObserverResults<ResizeObserver>;
|
|
6
6
|
type Observers = IntersectionObserver | ResizeObserver | MutationObserver;
|
|
7
7
|
type TargetRef = MaybeRefOrGetter<Nullable<HTMLElement>> | MaybeRefOrGetter<Nullable<HTMLElement>>[] | MaybeRefOrGetter<Nullable<HTMLElement>[]>;
|
|
8
8
|
interface ObserverResults<T extends Observers> {
|
|
9
|
-
observer: T | undefined
|
|
9
|
+
observer: Ref<T | undefined>;
|
|
10
10
|
stop: () => void;
|
|
11
11
|
}
|
|
12
12
|
export {};
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { isNotNil } from "es-toolkit";
|
|
2
|
-
import { computed, onBeforeUnmount, watch } from "vue";
|
|
2
|
+
import { computed, onBeforeUnmount, watch, shallowRef } from "vue";
|
|
3
3
|
import { toArray } from "../utils/format.js";
|
|
4
4
|
import { toValue, unrefElement } from "../utils/ref.js";
|
|
5
|
-
export const useIntersectionObserver = createObserver(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export const useIntersectionObserver = createObserver(
|
|
6
|
+
globalThis.IntersectionObserver,
|
|
7
|
+
"IntersectionObserver"
|
|
8
|
+
);
|
|
9
|
+
export const useMutationObserver = createObserver(globalThis.MutationObserver, "MutationObserver");
|
|
10
|
+
export const useResizeObserver = createObserver(globalThis.ResizeObserver, "ResizeObserver");
|
|
11
|
+
function createObserver(ObserverConstructor, type) {
|
|
9
12
|
function observerWrapper(target, callback, options) {
|
|
10
|
-
|
|
13
|
+
const observer = shallowRef();
|
|
11
14
|
const targets = computed(
|
|
12
15
|
() => toArray(toValue(target)).map(unrefElement).filter(isNotNil)
|
|
13
16
|
);
|
|
14
17
|
const unwatch = watch(
|
|
15
|
-
|
|
16
|
-
(
|
|
18
|
+
targets,
|
|
19
|
+
(newTargets) => {
|
|
17
20
|
if (typeof window === "undefined" || typeof ObserverConstructor === "undefined") {
|
|
18
21
|
return;
|
|
19
22
|
}
|
|
@@ -21,25 +24,25 @@ function createObserver(ObserverConstructor) {
|
|
|
21
24
|
if (!newTargets?.length) {
|
|
22
25
|
return;
|
|
23
26
|
}
|
|
24
|
-
if (
|
|
25
|
-
observer = new ObserverConstructor(
|
|
27
|
+
if (type === "IntersectionObserver") {
|
|
28
|
+
observer.value = new ObserverConstructor(
|
|
26
29
|
callback,
|
|
27
30
|
options
|
|
28
31
|
);
|
|
29
|
-
newTargets.forEach((el) => observer.observe(el));
|
|
30
|
-
} else if (
|
|
31
|
-
observer = new ObserverConstructor(
|
|
32
|
+
newTargets.forEach((el) => observer.value.observe(el));
|
|
33
|
+
} else if (type === "MutationObserver") {
|
|
34
|
+
observer.value = new ObserverConstructor(
|
|
32
35
|
callback
|
|
33
36
|
);
|
|
34
37
|
newTargets.forEach(
|
|
35
|
-
(el) => observer.observe(el, options)
|
|
38
|
+
(el) => observer.value.observe(el, options)
|
|
36
39
|
);
|
|
37
|
-
} else {
|
|
38
|
-
observer = new ObserverConstructor(
|
|
40
|
+
} else if (type === "ResizeObserver") {
|
|
41
|
+
observer.value = new ObserverConstructor(
|
|
39
42
|
callback
|
|
40
43
|
);
|
|
41
44
|
newTargets.forEach(
|
|
42
|
-
(el) => observer.observe(el, options)
|
|
45
|
+
(el) => observer.value.observe(el, options)
|
|
43
46
|
);
|
|
44
47
|
}
|
|
45
48
|
},
|
|
@@ -49,11 +52,11 @@ function createObserver(ObserverConstructor) {
|
|
|
49
52
|
}
|
|
50
53
|
);
|
|
51
54
|
function cleanup() {
|
|
52
|
-
if (!observer) {
|
|
55
|
+
if (!observer.value) {
|
|
53
56
|
return;
|
|
54
57
|
}
|
|
55
|
-
observer.disconnect();
|
|
56
|
-
observer = void 0;
|
|
58
|
+
observer.value.disconnect();
|
|
59
|
+
observer.value = void 0;
|
|
57
60
|
}
|
|
58
61
|
function stop() {
|
|
59
62
|
cleanup();
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { shallowRef } from "vue";
|
|
2
|
+
import { isServer } from "../utils/is.js";
|
|
2
3
|
export function useCopyClick() {
|
|
3
4
|
let copiedTimer;
|
|
4
5
|
let copyPromise = null;
|
|
5
6
|
const isCopied = shallowRef(false);
|
|
6
7
|
async function copyText(text = "") {
|
|
8
|
+
if (isServer()) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
7
11
|
if (copyPromise) {
|
|
8
12
|
return copyPromise;
|
|
9
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EmitFn, Ref } from 'vue';
|
|
2
|
-
export interface
|
|
2
|
+
export interface CountdownOptions {
|
|
3
3
|
/**
|
|
4
4
|
* 是否启用正计时
|
|
5
5
|
* Whether to enable count up mode.
|
|
@@ -58,5 +58,5 @@ interface Results {
|
|
|
58
58
|
reset: () => void;
|
|
59
59
|
timestamp: Ref<number>;
|
|
60
60
|
}
|
|
61
|
-
export declare function useCountdown<T extends Record<string, any>>(props:
|
|
61
|
+
export declare function useCountdown<T extends Record<string, any>>(props: CountdownOptions, emits: EmitFn<T>): Results;
|
|
62
62
|
export {};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import type { Options as FocusTrapOptions } from 'focus-trap';
|
|
2
1
|
import type { MaybeElementRef } from '../types/shared/utils';
|
|
2
|
+
import type { Options as FocusTrapOptions } from 'focus-trap';
|
|
3
|
+
import { type MaybeRefOrGetter } from 'vue';
|
|
4
|
+
export interface UseFocusTrapOptions extends FocusTrapOptions {
|
|
5
|
+
autoFocusElement?: string | boolean;
|
|
6
|
+
}
|
|
3
7
|
/**
|
|
4
|
-
* Best-practice defaults for dialogs (Modal/Drawer):
|
|
8
|
+
* Best-practice defaults for dialogs (Modal/Drawer/Popover):
|
|
5
9
|
* - Keep trap active unless component decides to close (avoid implicit deactivation).
|
|
6
10
|
* - Always provide a fallback focus target to avoid runtime errors when no tabbables exist.
|
|
7
11
|
* - Prevent scroll jumps caused by focusing.
|
|
8
12
|
* - Share a trap stack among PXD traps so nested dialogs coordinate pause/unpause.
|
|
9
13
|
*/
|
|
10
|
-
export declare function useFocusTrap(container: MaybeElementRef<HTMLElement>, userOptions?:
|
|
14
|
+
export declare function useFocusTrap(container: MaybeElementRef<HTMLElement>, userOptions?: MaybeRefOrGetter<UseFocusTrapOptions>): {
|
|
11
15
|
stop: import("vue").WatchHandle;
|
|
12
16
|
};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { createFocusTrap } from "focus-trap";
|
|
2
2
|
import { onBeforeUnmount, watch } from "vue";
|
|
3
3
|
import { toValue } from "../utils/ref.js";
|
|
4
|
-
const
|
|
4
|
+
const focusTrapStack = [];
|
|
5
|
+
const AUTO_FOCUS_FIRST_SELECTOR = [
|
|
6
|
+
'input:not([type="hidden"]):not(:disabled)',
|
|
7
|
+
"button:not(:disabled)",
|
|
8
|
+
"select:not(:disabled)",
|
|
9
|
+
"textarea:not(:disabled)",
|
|
10
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
11
|
+
].join(",");
|
|
5
12
|
export function useFocusTrap(container, userOptions = {}) {
|
|
6
13
|
let trapper = null;
|
|
7
14
|
const unwatch = watch(
|
|
@@ -10,6 +17,7 @@ export function useFocusTrap(container, userOptions = {}) {
|
|
|
10
17
|
if (!target) {
|
|
11
18
|
return;
|
|
12
19
|
}
|
|
20
|
+
const { autoFocusElement, ...restOptions } = toValue(userOptions);
|
|
13
21
|
const defaultOptions = {
|
|
14
22
|
allowOutsideClick: true,
|
|
15
23
|
escapeDeactivates: false,
|
|
@@ -18,20 +26,24 @@ export function useFocusTrap(container, userOptions = {}) {
|
|
|
18
26
|
returnFocusOnDeactivate: true,
|
|
19
27
|
preventScroll: true,
|
|
20
28
|
fallbackFocus: () => target,
|
|
21
|
-
initialFocus: () =>
|
|
29
|
+
initialFocus: () => {
|
|
30
|
+
if (autoFocusElement) {
|
|
31
|
+
const elSelector = typeof autoFocusElement === "boolean" ? AUTO_FOCUS_FIRST_SELECTOR : autoFocusElement;
|
|
32
|
+
return target.querySelector(elSelector) ?? target;
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
},
|
|
22
36
|
// Coordinate nested PXD dialogs
|
|
23
|
-
trapStack:
|
|
37
|
+
trapStack: focusTrapStack
|
|
24
38
|
};
|
|
25
|
-
trapper = createFocusTrap(target, { ...defaultOptions, ...
|
|
39
|
+
trapper = createFocusTrap(target, { ...defaultOptions, ...restOptions });
|
|
26
40
|
trapper.activate();
|
|
27
41
|
onCleanup(() => {
|
|
28
42
|
trapper.deactivate();
|
|
29
43
|
trapper = null;
|
|
30
44
|
});
|
|
31
45
|
},
|
|
32
|
-
{
|
|
33
|
-
flush: "post"
|
|
34
|
-
}
|
|
46
|
+
{ flush: "post" }
|
|
35
47
|
);
|
|
36
48
|
onBeforeUnmount(() => {
|
|
37
49
|
unwatch();
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { toValue } from "../utils/ref.js";
|
|
2
|
+
export function useForwardRefExpose(refEl) {
|
|
3
|
+
return new Proxy({}, {
|
|
4
|
+
get(_, prop) {
|
|
5
|
+
const target = toValue(refEl);
|
|
6
|
+
if (!target) {
|
|
7
|
+
return void 0;
|
|
8
|
+
}
|
|
9
|
+
const value = Reflect.get(target, prop, target);
|
|
10
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
11
|
+
},
|
|
12
|
+
set(_, prop, value) {
|
|
13
|
+
const target = toValue(refEl);
|
|
14
|
+
if (!target) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return Reflect.set(target, prop, value, target);
|
|
18
|
+
},
|
|
19
|
+
has(_, prop) {
|
|
20
|
+
const target = toValue(refEl);
|
|
21
|
+
if (!target) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return prop in target;
|
|
25
|
+
},
|
|
26
|
+
ownKeys() {
|
|
27
|
+
const target = toValue(refEl);
|
|
28
|
+
if (!target) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
return Reflect.ownKeys(target);
|
|
32
|
+
},
|
|
33
|
+
getOwnPropertyDescriptor(_, prop) {
|
|
34
|
+
const target = toValue(refEl);
|
|
35
|
+
if (!target) {
|
|
36
|
+
return void 0;
|
|
37
|
+
}
|
|
38
|
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { VNode } from 'vue';
|
|
2
1
|
import type { ButtonProps } from '../components/button/types';
|
|
3
2
|
import type { ComponentClass } from '../types/shared/props';
|
|
3
|
+
import type { VNode } from 'vue';
|
|
4
4
|
type MessageContent = string | VNode;
|
|
5
5
|
type PromiseMessageHandler = MessageContent | ((data: unknown) => MessageContent);
|
|
6
6
|
interface Action {
|
|
@@ -22,15 +22,12 @@ interface Options {
|
|
|
22
22
|
success?: PromiseMessageHandler;
|
|
23
23
|
finally?: PromiseMessageHandler;
|
|
24
24
|
}
|
|
25
|
-
export interface
|
|
25
|
+
export interface MessageItemConfig extends Options {
|
|
26
|
+
height?: number;
|
|
26
27
|
_timerId?: ReturnType<typeof setTimeout>;
|
|
27
28
|
_remainingMs?: number;
|
|
28
29
|
_startedAtMs?: number;
|
|
29
30
|
}
|
|
30
|
-
export interface MessageItemHeightType {
|
|
31
|
-
id: MessageItemType['id'];
|
|
32
|
-
height: number;
|
|
33
|
-
}
|
|
34
31
|
interface UseMessage {
|
|
35
32
|
(msg: MessageContent, options?: Options): void;
|
|
36
33
|
info: (msg: MessageContent, options?: Options) => void;
|
|
@@ -44,7 +41,7 @@ export type MessageActionType = 'create' | 'remove' | 'clear';
|
|
|
44
41
|
export interface MessageUpdateParams {
|
|
45
42
|
type: MessageActionType;
|
|
46
43
|
group: string;
|
|
47
|
-
data?:
|
|
44
|
+
data?: MessageItemConfig | {
|
|
48
45
|
id: Options['id'];
|
|
49
46
|
};
|
|
50
47
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { WritableComputedRef } from 'vue';
|
|
2
|
-
interface
|
|
3
|
-
|
|
4
|
-
set?: (value: any) => void;
|
|
5
|
-
withChange?: boolean;
|
|
2
|
+
interface BaseProps {
|
|
3
|
+
modelValue?: any;
|
|
6
4
|
}
|
|
7
|
-
interface
|
|
5
|
+
interface BaseEmits {
|
|
8
6
|
(event: 'change', ...args: any[]): void;
|
|
9
7
|
(event: 'update:modelValue', ...args: any[]): void;
|
|
10
8
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
interface ModelValueOptions {
|
|
10
|
+
get?: (value: any) => any;
|
|
11
|
+
set?: (value: any) => void;
|
|
12
|
+
withChange?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function useModelValue<P extends BaseProps, E extends BaseEmits>(props: P, emits: E, options?: ModelValueOptions): WritableComputedRef<NonNullable<P['modelValue']>>;
|
|
14
15
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export declare function usePopoverResponsive(): {
|
|
2
2
|
isXs: import("vue").Ref<boolean, boolean>;
|
|
3
3
|
attrs: import("vue").ComputedRef<{
|
|
4
|
-
readonly contentClass: "bg-background-100
|
|
4
|
+
readonly contentClass: "bg-background-100 border w-full rounded-tl-xl rounded-tr-xl";
|
|
5
5
|
readonly wrapperClass: "fixed w-screen h-screen items-end pointer-events-none pxd-container-mask";
|
|
6
6
|
readonly transitionType: "fade-slide";
|
|
7
7
|
} | {
|
|
8
|
-
readonly contentClass: "bg-background-100
|
|
8
|
+
readonly contentClass: "bg-background-100 border rounded-xl";
|
|
9
9
|
readonly wrapperClass: "";
|
|
10
10
|
readonly transitionType: "fade-scale";
|
|
11
11
|
}>;
|
|
@@ -3,16 +3,16 @@ import { PRESET_MEDIA_QUERIES, useMediaQuery } from "./use-media-query.js";
|
|
|
3
3
|
export function usePopoverResponsive() {
|
|
4
4
|
const isXs = useMediaQuery(PRESET_MEDIA_QUERIES.IS_XS);
|
|
5
5
|
const attrs = computed(() => {
|
|
6
|
-
const basicContentClass = "bg-background-100
|
|
6
|
+
const basicContentClass = "bg-background-100 border";
|
|
7
7
|
if (isXs.value) {
|
|
8
8
|
return {
|
|
9
|
-
contentClass: `${basicContentClass} w-full rounded-tl-
|
|
9
|
+
contentClass: `${basicContentClass} w-full rounded-tl-xl rounded-tr-xl`,
|
|
10
10
|
wrapperClass: "fixed w-screen h-screen items-end pointer-events-none pxd-container-mask",
|
|
11
11
|
transitionType: "fade-slide"
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
return {
|
|
15
|
-
contentClass: `${basicContentClass} rounded-
|
|
15
|
+
contentClass: `${basicContentClass} rounded-xl`,
|
|
16
16
|
wrapperClass: "",
|
|
17
17
|
transitionType: "fade-scale"
|
|
18
18
|
};
|
|
@@ -5,10 +5,10 @@ export function useRepeatAction(actionOrOptions) {
|
|
|
5
5
|
const {
|
|
6
6
|
action,
|
|
7
7
|
disabled,
|
|
8
|
-
finalInterval = 1e3 /
|
|
8
|
+
finalInterval = 1e3 / 16.6,
|
|
9
9
|
// 60fps
|
|
10
10
|
initialInterval = 680,
|
|
11
|
-
accelerationDuration =
|
|
11
|
+
accelerationDuration = 1500
|
|
12
12
|
} = typeof actionOrOptions === "function" ? { action: actionOrOptions } : actionOrOptions;
|
|
13
13
|
let timer = null;
|
|
14
14
|
let startTime = 0;
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
+
import type { MaybeElementRef } from '../types/shared';
|
|
2
|
+
import type { VirtualItem } from '@tanstack/virtual-core';
|
|
1
3
|
import type { ComponentPublicInstance } from 'vue';
|
|
2
|
-
|
|
4
|
+
import { Virtualizer } from '@tanstack/virtual-core';
|
|
5
|
+
export interface VirtualListItem extends VirtualItem {
|
|
6
|
+
key: string | number;
|
|
7
|
+
}
|
|
8
|
+
export interface VirtualListOptions {
|
|
9
|
+
status?: 'loading' | 'finished' | 'error' | '';
|
|
3
10
|
dataKey?: string;
|
|
4
|
-
listData
|
|
5
|
-
itemSize
|
|
11
|
+
listData?: any[];
|
|
12
|
+
itemSize?: number;
|
|
13
|
+
overScan?: number;
|
|
14
|
+
onBottom?: () => void | Promise<void>;
|
|
15
|
+
bottomThreshold?: number;
|
|
6
16
|
}
|
|
7
|
-
export declare function useVirtualList<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
getStartIndex: (scrollTop: number) => number;
|
|
17
|
+
export declare function useVirtualList<Options extends VirtualListOptions>(containerRef: MaybeElementRef<HTMLElement>, options: Options): {
|
|
18
|
+
virtualItems: import("vue").ComputedRef<VirtualListItem[]>;
|
|
19
|
+
totalSize: import("vue").ComputedRef<number>;
|
|
20
|
+
measureElement: (el: Element | ComponentPublicInstance | null) => void;
|
|
21
|
+
scrollToIndex: any;
|
|
22
|
+
scrollToOffset: any;
|
|
23
|
+
scrollBy: any;
|
|
24
|
+
getVirtualizer: () => Virtualizer<HTMLElement, HTMLElement>;
|
|
16
25
|
};
|