pxd 0.0.52 → 0.0.53
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 +6 -3
- package/dist/components/active-graph/index.d.vue.ts +0 -2
- package/dist/components/active-graph/index.vue +35 -37
- package/dist/components/avatar/index.d.vue.ts +2 -2
- package/dist/components/avatar/index.vue +17 -16
- package/dist/components/avatar-group/index.d.vue.ts +1 -1
- package/dist/components/avatar-group/index.vue +4 -1
- package/dist/components/badge/cn.d.ts +90 -0
- package/dist/components/badge/cn.js +44 -0
- package/dist/components/badge/index.d.vue.ts +5 -33
- package/dist/components/badge/index.vue +10 -56
- package/dist/components/book/index.vue +90 -17
- package/dist/components/browser/index.vue +21 -6
- package/dist/components/button/cn.d.ts +121 -0
- package/dist/components/button/cn.js +55 -0
- package/dist/components/button/index.d.vue.ts +8 -14
- package/dist/components/button/index.vue +22 -74
- package/dist/components/carousel-group/index.d.vue.ts +1 -1
- package/dist/components/carousel-group/index.vue +32 -28
- package/dist/components/checkbox/cn.d.ts +67 -0
- package/dist/components/checkbox/cn.js +31 -0
- package/dist/components/checkbox/index.vue +9 -19
- package/dist/components/chip/cn.d.ts +49 -0
- package/dist/components/chip/cn.js +26 -0
- package/dist/components/chip/index.vue +13 -21
- package/dist/components/choicebox/index.vue +1 -1
- package/dist/components/choicebox-group/index.vue +6 -3
- package/dist/components/collapse/index.vue +7 -1
- package/dist/components/collapse-group/index.vue +7 -7
- package/dist/components/command-menu/index.vue +9 -8
- package/dist/components/command-menu-group/index.vue +4 -1
- package/dist/components/config-provider/index.d.vue.ts +1 -0
- package/dist/components/config-provider/index.vue +2 -1
- package/dist/components/countdown/index.vue +2 -10
- package/dist/components/dash-line/index.vue +22 -16
- package/dist/components/description/index.vue +4 -2
- package/dist/components/drawer/index.vue +19 -11
- package/dist/components/empty-state/index.vue +3 -1
- package/dist/components/error/cn.d.ts +22 -0
- package/dist/components/error/cn.js +15 -0
- package/dist/components/error/index.vue +13 -14
- package/dist/components/fader/index.vue +30 -14
- package/dist/components/gauge/index.vue +6 -6
- package/dist/components/grid/index.vue +16 -12
- package/dist/components/grid-item/index.vue +4 -4
- package/dist/components/hold-button/index.vue +19 -13
- package/dist/components/input/cn.d.ts +73 -0
- package/dist/components/input/cn.js +36 -0
- package/dist/components/input/index.d.vue.ts +14 -16
- package/dist/components/input/index.vue +74 -101
- package/dist/components/intersection-observer/index.vue +7 -3
- package/dist/components/kbd/index.vue +2 -2
- package/dist/components/link-button/index.d.vue.ts +8 -8
- package/dist/components/link-button/index.vue +17 -25
- package/dist/components/list/index.d.vue.ts +0 -1
- package/dist/components/list/index.vue +58 -57
- package/dist/components/list-item/cn.d.ts +22 -0
- package/dist/components/list-item/cn.js +15 -0
- package/dist/components/list-item/index.d.vue.ts +3 -3
- package/dist/components/list-item/index.vue +14 -25
- package/dist/components/loading-bar/cn.d.ts +70 -0
- package/dist/components/loading-bar/cn.js +32 -0
- package/dist/components/loading-bar/index.d.vue.ts +2 -0
- package/dist/components/loading-bar/index.vue +68 -61
- package/dist/components/loading-dots/index.vue +12 -4
- package/dist/components/menu/index.d.vue.ts +2 -2
- package/dist/components/menu/index.vue +4 -4
- package/dist/components/message/index.vue +82 -48
- package/dist/components/message-item/index.vue +7 -2
- package/dist/components/modal/index.vue +20 -12
- package/dist/components/more-button/index.d.vue.ts +1 -3
- package/dist/components/more-button/index.vue +7 -17
- package/dist/components/note/cn.d.ts +121 -0
- package/dist/components/note/cn.js +66 -0
- package/dist/components/note/index.d.vue.ts +3 -39
- package/dist/components/note/index.vue +18 -37
- package/dist/components/number-input/index.d.vue.ts +19 -10
- package/dist/components/number-input/index.vue +121 -75
- package/dist/components/overlay/index.vue +4 -20
- package/dist/components/pagination/index.vue +25 -8
- package/dist/components/pin-input/cn.d.ts +46 -0
- package/dist/components/pin-input/cn.js +25 -0
- package/dist/components/pin-input/index.vue +11 -20
- package/dist/components/placeholder/index.vue +11 -4
- package/dist/components/popover/index.d.vue.ts +4 -3
- package/dist/components/popover/index.vue +107 -54
- package/dist/components/progress/cn.d.ts +19 -0
- package/dist/components/progress/cn.js +14 -0
- package/dist/components/progress/index.d.vue.ts +1 -1
- package/dist/components/progress/index.vue +21 -14
- package/dist/components/radio/cn.d.ts +46 -0
- package/dist/components/radio/cn.js +42 -0
- package/dist/components/radio/index.vue +11 -18
- package/dist/components/resizable/index.vue +8 -2
- package/dist/components/resizable-handle/index.vue +1 -0
- package/dist/components/resizable-panel/index.vue +12 -11
- package/dist/components/skeleton/cn.d.ts +43 -0
- package/dist/components/skeleton/cn.js +24 -0
- package/dist/components/skeleton/index.d.vue.ts +4 -3
- package/dist/components/skeleton/index.vue +11 -20
- package/dist/components/slider/index.d.vue.ts +1 -1
- package/dist/components/slider/index.vue +14 -12
- package/dist/components/snippet/cn.d.ts +52 -0
- package/dist/components/snippet/cn.js +27 -0
- package/dist/components/snippet/index.vue +21 -29
- package/dist/components/spinner/index.vue +3 -1
- package/dist/components/stack/cn.d.ts +70 -0
- package/dist/components/stack/cn.js +33 -0
- package/dist/components/stack/index.d.vue.ts +2 -2
- package/dist/components/stack/index.vue +16 -31
- package/dist/components/status-dot/index.vue +5 -1
- package/dist/components/switch/cn.d.ts +16 -0
- package/dist/components/switch/cn.js +13 -0
- package/dist/components/switch/index.vue +5 -11
- package/dist/components/switch-group/index.vue +7 -4
- package/dist/components/text/cn.d.ts +67 -0
- package/dist/components/text/cn.js +34 -0
- package/dist/components/text/index.d.vue.ts +1 -1
- package/dist/components/text/index.vue +16 -25
- package/dist/components/textarea/cn.d.ts +58 -0
- package/dist/components/textarea/cn.js +30 -0
- package/dist/components/textarea/index.d.vue.ts +2 -0
- package/dist/components/textarea/index.vue +17 -24
- package/dist/components/theme-switcher/index.vue +6 -3
- package/dist/components/time-picker/index.d.vue.ts +2 -2
- package/dist/components/time-picker/index.vue +45 -25
- package/dist/components/toggle/index.vue +10 -6
- package/dist/components/tooltip/index.vue +3 -3
- package/dist/components/virtual-list/index.vue +1 -7
- package/dist/composables/use-browser-observer.d.ts +1 -1
- package/dist/composables/use-browser-observer.js +19 -15
- package/dist/composables/use-config-provider-context.d.ts +1 -0
- package/dist/composables/use-config-provider-context.js +5 -10
- package/dist/composables/use-countdown.js +1 -3
- package/dist/composables/use-deferred-value.js +1 -5
- package/dist/composables/use-delay-change.js +1 -4
- package/dist/composables/use-delay-destroy.js +1 -5
- package/dist/composables/use-loading-bar.d.ts +6 -14
- package/dist/composables/use-loading-bar.js +3 -14
- package/dist/composables/use-message.d.ts +9 -3
- package/dist/composables/use-message.js +9 -9
- package/dist/composables/use-model-value.d.ts +1 -0
- package/dist/composables/use-model-value.js +4 -2
- package/dist/composables/use-outside-click.js +12 -8
- package/dist/composables/use-pointer-gesture.js +5 -1
- package/dist/composables/use-toggle-value.js +1 -4
- package/dist/composables/use-virtual-list.js +14 -7
- package/dist/contexts/avatar.js +4 -4
- package/dist/contexts/carousel.js +1 -4
- package/dist/contexts/checkbox.js +1 -4
- package/dist/contexts/choicebox.js +2 -8
- package/dist/contexts/collapse.js +1 -4
- package/dist/contexts/list.js +5 -8
- package/dist/contexts/radio.js +4 -4
- package/dist/contexts/resizable.js +1 -4
- package/dist/contexts/switch.js +2 -8
- package/dist/index.d.ts +1 -0
- package/dist/styles/source.css +106 -59
- package/dist/styles/styles.css +1 -1
- package/dist/styles/tw.css +106 -59
- package/dist/types/components/avatar.d.ts +2 -2
- package/dist/types/components/button.d.ts +11 -4
- package/dist/types/components/index.d.ts +12 -0
- package/dist/types/components/input.d.ts +4 -5
- package/dist/types/components/list.d.ts +1 -1
- package/dist/types/components/switch.d.ts +1 -1
- package/dist/types/shared/props.d.ts +6 -4
- package/dist/types/shared/utils.d.ts +3 -1
- package/dist/utils/context.d.ts +2 -8
- package/dist/utils/date.d.ts +1 -1
- package/dist/utils/date.js +1 -5
- package/dist/utils/event.js +6 -18
- package/dist/utils/format.d.ts +1 -1
- package/dist/utils/format.js +1 -1
- package/dist/utils/is.d.ts +0 -1
- package/dist/utils/is.js +3 -2
- package/dist/utils/responsive.js +7 -4
- package/dist/utils/throttle.js +4 -2
- package/package.json +45 -43
- package/dist/components/_internal/fragment-container.vue.d.ts +0 -13
- package/dist/components/active-graph/index.vue.d.ts +0 -51
- package/dist/components/avatar/index.vue.d.ts +0 -34
- package/dist/components/avatar-group/index.vue.d.ts +0 -8
- package/dist/components/backtop/index.vue.d.ts +0 -21
- package/dist/components/badge/index.vue.d.ts +0 -52
- package/dist/components/book/index.vue.d.ts +0 -28
- package/dist/components/browser/index.vue.d.ts +0 -16
- package/dist/components/button/index.vue.d.ts +0 -29
- package/dist/components/carousel/index.vue.d.ts +0 -13
- package/dist/components/carousel-group/index.vue.d.ts +0 -35
- package/dist/components/checkbox/index.vue.d.ts +0 -26
- package/dist/components/checkbox-group/index.vue.d.ts +0 -28
- package/dist/components/chip/index.vue.d.ts +0 -24
- package/dist/components/choicebox/index.vue.d.ts +0 -16
- package/dist/components/choicebox-group/index.vue.d.ts +0 -24
- package/dist/components/collapse/index.vue.d.ts +0 -22
- package/dist/components/collapse-group/index.vue.d.ts +0 -20
- package/dist/components/command-menu/index.vue.d.ts +0 -42
- package/dist/components/command-menu-group/index.vue.d.ts +0 -17
- package/dist/components/command-menu-item/index.vue.d.ts +0 -13
- package/dist/components/config-provider/index.vue.d.ts +0 -22
- package/dist/components/countdown/index.vue.d.ts +0 -51
- package/dist/components/dash-line/index.vue.d.ts +0 -13
- package/dist/components/description/index.vue.d.ts +0 -20
- package/dist/components/drawer/index.vue.d.ts +0 -60
- package/dist/components/empty-state/index.vue.d.ts +0 -23
- package/dist/components/error/index.vue.d.ts +0 -22
- package/dist/components/fader/index.vue.d.ts +0 -12
- package/dist/components/gauge/index.vue.d.ts +0 -14
- package/dist/components/grid/index.vue.d.ts +0 -19
- package/dist/components/grid-item/index.vue.d.ts +0 -18
- package/dist/components/hold-button/index.vue.d.ts +0 -42
- package/dist/components/input/index.vue.d.ts +0 -55
- package/dist/components/intersection-observer/index.vue.d.ts +0 -39
- package/dist/components/kbd/index.vue.d.ts +0 -24
- package/dist/components/label/index.vue.d.ts +0 -13
- package/dist/components/link-button/index.vue.d.ts +0 -33
- package/dist/components/list/index.vue.d.ts +0 -44
- package/dist/components/list-item/index.vue.d.ts +0 -29
- package/dist/components/loading-bar/index.vue.d.ts +0 -15
- package/dist/components/loading-dots/index.vue.d.ts +0 -15
- package/dist/components/material/index.vue.d.ts +0 -18
- package/dist/components/menu/index.vue.d.ts +0 -33
- package/dist/components/message/index.vue.d.ts +0 -176
- package/dist/components/message-item/index.vue.d.ts +0 -15
- package/dist/components/modal/index.vue.d.ts +0 -58
- package/dist/components/more-button/index.vue.d.ts +0 -20
- package/dist/components/noise-background/index.vue.d.ts +0 -19
- package/dist/components/note/index.vue.d.ts +0 -64
- package/dist/components/number-input/index.vue.d.ts +0 -39
- package/dist/components/overlay/index.vue.d.ts +0 -35
- package/dist/components/pagination/index.vue.d.ts +0 -21
- package/dist/components/pin-input/index.vue.d.ts +0 -28
- package/dist/components/placeholder/index.vue.d.ts +0 -18
- package/dist/components/popover/index.vue.d.ts +0 -73
- package/dist/components/progress/index.vue.d.ts +0 -34
- package/dist/components/radio/index.vue.d.ts +0 -20
- package/dist/components/radio-group/index.vue.d.ts +0 -22
- package/dist/components/resizable/index.vue.d.ts +0 -19
- package/dist/components/resizable-handle/index.vue.d.ts +0 -3
- package/dist/components/resizable-panel/index.vue.d.ts +0 -20
- package/dist/components/scrollable/index.vue.d.ts +0 -0
- package/dist/components/skeleton/index.vue.d.ts +0 -26
- package/dist/components/slider/index.vue.d.ts +0 -26
- package/dist/components/snippet/index.vue.d.ts +0 -18
- package/dist/components/spinner/index.vue.d.ts +0 -3
- package/dist/components/stack/index.vue.d.ts +0 -30
- package/dist/components/status-dot/index.vue.d.ts +0 -11
- package/dist/components/switch/index.vue.d.ts +0 -20
- package/dist/components/switch-group/index.vue.d.ts +0 -23
- package/dist/components/teleport/index.vue.d.ts +0 -21
- package/dist/components/text/index.vue.d.ts +0 -26
- package/dist/components/textarea/index.vue.d.ts +0 -28
- package/dist/components/theme-switcher/index.vue.d.ts +0 -8
- package/dist/components/time-picker/index.vue.d.ts +0 -35
- package/dist/components/toggle/index.vue.d.ts +0 -41
- package/dist/components/tooltip/index.vue.d.ts +0 -32
- package/dist/components/virtual-list/index.vue.d.ts +0 -24
|
@@ -6,7 +6,7 @@ import WarningIcon from "@gdsicon/vue/warning";
|
|
|
6
6
|
import { computed, h } from "vue";
|
|
7
7
|
import { useConfigProvider } from "../../composables/use-config-provider-context";
|
|
8
8
|
import { isTruthyProp } from "../../utils/format";
|
|
9
|
-
import {
|
|
9
|
+
import { noteVariant } from "./cn";
|
|
10
10
|
defineOptions({
|
|
11
11
|
name: "PNote"
|
|
12
12
|
});
|
|
@@ -16,71 +16,52 @@ const props = defineProps({
|
|
|
16
16
|
fill: { type: Boolean, required: false },
|
|
17
17
|
label: { type: [Boolean, String, Number, Array, null], required: false, default: true }
|
|
18
18
|
});
|
|
19
|
-
const
|
|
20
|
-
sm: "px-2 py-1.5 text-xs",
|
|
21
|
-
md: "px-3 py-2 text-sm",
|
|
22
|
-
lg: "px-4 py-2.5 text-base"
|
|
23
|
-
};
|
|
19
|
+
const configProvider = useConfigProvider();
|
|
24
20
|
const VARIANTS = {
|
|
25
21
|
success: {
|
|
26
|
-
icon: CheckCircleIcon
|
|
27
|
-
fill: "text-blue-900 bg-blue-200 border-blue-100",
|
|
28
|
-
basic: "text-blue-900 border-blue-500"
|
|
22
|
+
icon: CheckCircleIcon
|
|
29
23
|
},
|
|
30
24
|
error: {
|
|
31
|
-
icon: StopIcon
|
|
32
|
-
fill: "text-red-900 bg-red-200 border-red-100",
|
|
33
|
-
basic: "text-red-900 border-red-500"
|
|
25
|
+
icon: StopIcon
|
|
34
26
|
},
|
|
35
27
|
warning: {
|
|
36
|
-
icon: WarningIcon
|
|
37
|
-
fill: "text-amber-900 bg-amber-200 border-amber-100",
|
|
38
|
-
basic: "text-amber-900 border-amber-500"
|
|
28
|
+
icon: WarningIcon
|
|
39
29
|
},
|
|
40
30
|
default: {
|
|
41
|
-
icon: InformationIcon
|
|
42
|
-
fill: "text-foreground-secondary bg-gray-200 border-gray-100",
|
|
43
|
-
basic: "text-foreground-secondary border-input"
|
|
31
|
+
icon: InformationIcon
|
|
44
32
|
},
|
|
45
33
|
primary: {
|
|
46
|
-
icon: InformationIcon
|
|
47
|
-
fill: "text-gray-100 bg-primary border-gray-100",
|
|
48
|
-
basic: "text-primary border-gray-alpha-400"
|
|
34
|
+
icon: InformationIcon
|
|
49
35
|
},
|
|
50
36
|
violet: {
|
|
51
|
-
icon: InformationIcon
|
|
52
|
-
fill: "text-violet-900 bg-violet-200 border-violet-100",
|
|
53
|
-
basic: "text-violet-900 border-violet-400"
|
|
37
|
+
icon: InformationIcon
|
|
54
38
|
},
|
|
55
39
|
cyan: {
|
|
56
|
-
icon: InformationIcon
|
|
57
|
-
fill: "text-teal-900 bg-teal-200 border-teal-100",
|
|
58
|
-
basic: "text-teal-900 border-teal-400"
|
|
40
|
+
icon: InformationIcon
|
|
59
41
|
}
|
|
60
42
|
};
|
|
61
|
-
const config = useConfigProvider();
|
|
62
43
|
const computedLabel = computed(() => {
|
|
63
44
|
const { label } = props;
|
|
64
45
|
if (isTruthyProp(label)) {
|
|
65
|
-
return
|
|
46
|
+
return VARIANTS[props.variant]?.icon || InformationIcon;
|
|
66
47
|
}
|
|
67
48
|
if (typeof label === "string" && label) {
|
|
68
49
|
return h("span", null, label);
|
|
69
50
|
}
|
|
70
51
|
return false;
|
|
71
52
|
});
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
53
|
+
const computedClasses = computed(() => {
|
|
54
|
+
return noteVariant({
|
|
55
|
+
fill: props.fill,
|
|
56
|
+
size: props.size || configProvider.size,
|
|
57
|
+
variant: props.variant
|
|
58
|
+
});
|
|
78
59
|
});
|
|
79
60
|
</script>
|
|
80
61
|
|
|
81
62
|
<template>
|
|
82
|
-
<div :class="
|
|
83
|
-
<div class="gap-3 flex">
|
|
63
|
+
<div :class="computedClasses">
|
|
64
|
+
<div class="gap-3 flex flex-1">
|
|
84
65
|
<slot v-if="computedLabel" name="label">
|
|
85
66
|
<Component :is="computedLabel" class="size-4 font-medium h-lh shrink-0" />
|
|
86
67
|
</slot>
|
|
@@ -6,26 +6,35 @@ interface Props {
|
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
precision?: number;
|
|
8
8
|
scientific?: boolean;
|
|
9
|
+
clearValue?: number | null;
|
|
9
10
|
modelValue?: number | null;
|
|
10
11
|
}
|
|
11
|
-
declare var
|
|
12
|
+
declare var __VLS_15: {}, __VLS_22: {}, __VLS_25: {}, __VLS_27: {};
|
|
12
13
|
type __VLS_Slots = {} & {
|
|
13
|
-
|
|
14
|
+
minusIcon?: (props: typeof __VLS_15) => any;
|
|
14
15
|
} & {
|
|
15
|
-
|
|
16
|
+
prefix?: (props: typeof __VLS_22) => any;
|
|
17
|
+
} & {
|
|
18
|
+
suffix?: (props: typeof __VLS_25) => any;
|
|
19
|
+
} & {
|
|
20
|
+
plusIcon?: (props: typeof __VLS_27) => any;
|
|
16
21
|
};
|
|
17
22
|
declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
input: (args_0: number | null | undefined) => any;
|
|
24
|
+
blur: (args_0: FocusEvent) => any;
|
|
25
|
+
change: (args_0: number | null | undefined, args_1: Event) => any;
|
|
26
|
+
focus: (args_0: FocusEvent) => any;
|
|
27
|
+
"update:modelValue": (args_0: number | null | undefined) => any;
|
|
20
28
|
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
onInput?: ((args_0: number | null | undefined) => any) | undefined;
|
|
30
|
+
onBlur?: ((args_0: FocusEvent) => any) | undefined;
|
|
31
|
+
onChange?: ((args_0: number | null | undefined, args_1: Event) => any) | undefined;
|
|
32
|
+
onFocus?: ((args_0: FocusEvent) => any) | undefined;
|
|
33
|
+
"onUpdate:modelValue"?: ((args_0: number | null | undefined) => any) | undefined;
|
|
23
34
|
}>, {
|
|
24
|
-
disabled: boolean;
|
|
25
35
|
max: number;
|
|
26
|
-
precision: number;
|
|
27
36
|
min: number;
|
|
28
|
-
|
|
37
|
+
clearValue: number | null;
|
|
29
38
|
step: number;
|
|
30
39
|
scientific: boolean;
|
|
31
40
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import MinusIcon from "@gdsicon/vue/minus";
|
|
3
3
|
import PlusIcon from "@gdsicon/vue/plus";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { isNil, isNumber, isUndefined } from "es-toolkit";
|
|
5
|
+
import { computed, reactive, watch } from "vue";
|
|
6
6
|
import { useRepeatAction } from "../../composables/use-repeat-action";
|
|
7
7
|
import { NOOP } from "../../utils/event";
|
|
8
|
-
import { FLOATING_REGEX, SCIENCE_NUMERIC_REGEX } from "../../utils/regexp";
|
|
9
8
|
import PInput from "../input/index.vue";
|
|
10
9
|
defineOptions({
|
|
11
10
|
name: "PNumberInput",
|
|
@@ -19,36 +18,81 @@ const props = defineProps({
|
|
|
19
18
|
min: { type: Number, required: false, default: Number.MIN_SAFE_INTEGER },
|
|
20
19
|
max: { type: Number, required: false, default: Number.MAX_SAFE_INTEGER },
|
|
21
20
|
step: { type: Number, required: false, default: 1 },
|
|
22
|
-
readonly: { type: Boolean, required: false
|
|
23
|
-
disabled: { type: Boolean, required: false
|
|
24
|
-
precision: { type: Number, required: false
|
|
21
|
+
readonly: { type: Boolean, required: false },
|
|
22
|
+
disabled: { type: Boolean, required: false },
|
|
23
|
+
precision: { type: Number, required: false },
|
|
25
24
|
scientific: { type: Boolean, required: false, default: true },
|
|
25
|
+
clearValue: { type: [Number, null], required: false, default: null },
|
|
26
26
|
modelValue: { type: [Number, null], required: false }
|
|
27
27
|
});
|
|
28
|
-
const emits = defineEmits(["change", "update:modelValue"]);
|
|
29
|
-
const modelValue =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
const emits = defineEmits(["focus", "blur", "input", "change", "update:modelValue"]);
|
|
29
|
+
const modelValue = computed({
|
|
30
|
+
get() {
|
|
31
|
+
return props.modelValue;
|
|
32
|
+
},
|
|
33
|
+
set(value) {
|
|
34
|
+
emits("input", value);
|
|
35
|
+
emits("update:modelValue", value);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const inputData = reactive({
|
|
39
|
+
currentValue: props.modelValue,
|
|
40
|
+
userInput: null
|
|
41
|
+
});
|
|
42
|
+
const inputValue = computed(() => {
|
|
43
|
+
if (inputData.userInput !== null) {
|
|
44
|
+
return inputData.userInput;
|
|
45
|
+
}
|
|
46
|
+
let currentValue = inputData.currentValue;
|
|
47
|
+
if (isNil(currentValue)) {
|
|
48
|
+
return "";
|
|
49
|
+
}
|
|
50
|
+
if (isNumber(currentValue)) {
|
|
51
|
+
if (Number.isNaN(currentValue)) {
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
if (!isUndefined(props.precision)) {
|
|
55
|
+
currentValue = currentValue.toFixed(props.precision);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return currentValue;
|
|
59
|
+
});
|
|
60
|
+
const decreaseDisabled = computed(
|
|
61
|
+
() => props.disabled || isNumber(props.modelValue) && props.modelValue <= props.min
|
|
62
|
+
);
|
|
63
|
+
const increaseDisabled = computed(
|
|
64
|
+
() => props.disabled || isNumber(props.modelValue) && props.modelValue >= props.max
|
|
65
|
+
);
|
|
66
|
+
const valuePrecision = computed(() => {
|
|
67
|
+
if (props.precision) {
|
|
68
|
+
return props.precision;
|
|
69
|
+
}
|
|
70
|
+
const stringValue = String(props.step);
|
|
71
|
+
const decimalIndex = stringValue.indexOf(".");
|
|
72
|
+
if (decimalIndex === -1) {
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
return stringValue.length - decimalIndex - 1;
|
|
76
|
+
});
|
|
77
|
+
const { start: startDecrease, stop: stopDecrease } = useRepeatAction({
|
|
36
78
|
disabled: decreaseDisabled,
|
|
37
79
|
action: decreaseValue
|
|
38
80
|
});
|
|
39
|
-
const {
|
|
40
|
-
start: startIncrease,
|
|
41
|
-
stop: stopIncrease
|
|
42
|
-
} = useRepeatAction({
|
|
81
|
+
const { start: startIncrease, stop: stopIncrease } = useRepeatAction({
|
|
43
82
|
disabled: increaseDisabled,
|
|
44
83
|
action: increaseValue
|
|
45
84
|
});
|
|
46
|
-
|
|
47
|
-
|
|
85
|
+
function toPrecision(value) {
|
|
86
|
+
if (!value) {
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
if (Number.isNaN(value)) {
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
48
92
|
if (!Number.isFinite(value)) {
|
|
49
93
|
return value;
|
|
50
94
|
}
|
|
51
|
-
const p = Math.max(0,
|
|
95
|
+
const p = Math.max(0, valuePrecision.value ?? 0);
|
|
52
96
|
const factor = 10 ** p;
|
|
53
97
|
return Math.round(value * factor) / factor;
|
|
54
98
|
}
|
|
@@ -62,66 +106,29 @@ function clampToRange(value) {
|
|
|
62
106
|
return value;
|
|
63
107
|
}
|
|
64
108
|
function increaseValue() {
|
|
65
|
-
if (
|
|
109
|
+
if (props.readonly || props.disabled || increaseDisabled.value) {
|
|
66
110
|
return;
|
|
67
111
|
}
|
|
68
|
-
const
|
|
69
|
-
|
|
112
|
+
const numeric = Number(inputValue.value) || 0;
|
|
113
|
+
const value = toPrecision(numeric + props.step);
|
|
114
|
+
inputData.currentValue = value;
|
|
115
|
+
modelValue.value = clampToRange(value ?? 0);
|
|
70
116
|
}
|
|
71
117
|
function decreaseValue() {
|
|
72
|
-
if (
|
|
118
|
+
if (props.readonly || props.disabled || decreaseDisabled.value) {
|
|
73
119
|
return;
|
|
74
120
|
}
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (value === "") {
|
|
80
|
-
return "";
|
|
81
|
-
}
|
|
82
|
-
const parsed = Number.parseFloat(value);
|
|
83
|
-
if (Number.isNaN(parsed)) {
|
|
84
|
-
return 0;
|
|
85
|
-
}
|
|
86
|
-
const rounded = toPrecision(parsed, props.precision);
|
|
87
|
-
return clampToRange(rounded);
|
|
121
|
+
const numeric = Number(inputValue.value) || 0;
|
|
122
|
+
const value = toPrecision(numeric - props.step);
|
|
123
|
+
inputData.currentValue = value;
|
|
124
|
+
modelValue.value = clampToRange(value ?? 0);
|
|
88
125
|
}
|
|
89
|
-
function numberFormatter(value) {
|
|
90
|
-
if ([null, void 0, ""].includes(value)) {
|
|
91
|
-
return "";
|
|
92
|
-
}
|
|
93
|
-
const number = typeof value === "number" ? value : Number.parseFloat(String(value));
|
|
94
|
-
if (Number.isNaN(number)) {
|
|
95
|
-
return "";
|
|
96
|
-
}
|
|
97
|
-
const { precision } = props;
|
|
98
|
-
const rounded = toPrecision(number, precision);
|
|
99
|
-
return rounded.toFixed(Math.max(0, precision));
|
|
100
|
-
}
|
|
101
|
-
const ALLOWED_KEY = [
|
|
102
|
-
"Backspace",
|
|
103
|
-
"Delete",
|
|
104
|
-
"Tab",
|
|
105
|
-
"ArrowLeft",
|
|
106
|
-
"ArrowRight",
|
|
107
|
-
"ArrowUp",
|
|
108
|
-
"ArrowDown",
|
|
109
|
-
"Home",
|
|
110
|
-
"End"
|
|
111
|
-
];
|
|
112
126
|
function onInputKeydown(ev) {
|
|
113
|
-
if (props.readonly || props.disabled) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
127
|
const key = ev.key;
|
|
117
128
|
if (!props.scientific && ["e", "E"].includes(key)) {
|
|
118
129
|
ev.preventDefault();
|
|
119
130
|
return;
|
|
120
131
|
}
|
|
121
|
-
if (!allowedRegex.value.test(key) && !ALLOWED_KEY.includes(key) && !ev.ctrlKey && !ev.metaKey) {
|
|
122
|
-
ev.preventDefault();
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
132
|
if (ev.key === "ArrowUp") {
|
|
126
133
|
ev.preventDefault();
|
|
127
134
|
increaseValue();
|
|
@@ -130,12 +137,41 @@ function onInputKeydown(ev) {
|
|
|
130
137
|
decreaseValue();
|
|
131
138
|
}
|
|
132
139
|
}
|
|
140
|
+
function onInputFocus(event) {
|
|
141
|
+
emits("focus", event);
|
|
142
|
+
}
|
|
143
|
+
function onInputBlur(event) {
|
|
144
|
+
inputData.userInput = null;
|
|
145
|
+
if (inputData.currentValue === null) {
|
|
146
|
+
;
|
|
147
|
+
event.target.value = "";
|
|
148
|
+
}
|
|
149
|
+
emits("blur", event);
|
|
150
|
+
}
|
|
151
|
+
function onInputInput(value) {
|
|
152
|
+
inputData.userInput = value;
|
|
153
|
+
const newValue = value === "" ? null : Number.parseFloat(value);
|
|
154
|
+
inputData.currentValue = toPrecision(newValue ?? 0);
|
|
155
|
+
modelValue.value = inputData.currentValue;
|
|
156
|
+
}
|
|
157
|
+
function onInputChange(value, event) {
|
|
158
|
+
const newValue = toPrecision(value === "" ? null : Number.parseFloat(value));
|
|
159
|
+
emits("change", newValue, event);
|
|
160
|
+
}
|
|
161
|
+
watch(
|
|
162
|
+
() => props.modelValue,
|
|
163
|
+
(newVal, oldVal) => {
|
|
164
|
+
if (inputData.userInput === null && newVal !== oldVal) {
|
|
165
|
+
inputData.currentValue = toPrecision(props.modelValue ?? 0);
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
{ immediate: true }
|
|
169
|
+
);
|
|
133
170
|
</script>
|
|
134
171
|
|
|
135
172
|
<template>
|
|
136
173
|
<PInput
|
|
137
174
|
v-bind="$attrs"
|
|
138
|
-
v-model="modelValue"
|
|
139
175
|
:min="min"
|
|
140
176
|
:max="max"
|
|
141
177
|
align="center"
|
|
@@ -145,20 +181,27 @@ function onInputKeydown(ev) {
|
|
|
145
181
|
:readonly="readonly"
|
|
146
182
|
:prefix-style="false"
|
|
147
183
|
:suffix-style="false"
|
|
148
|
-
:
|
|
149
|
-
:
|
|
184
|
+
:clear-value="clearValue"
|
|
185
|
+
:model-value="inputValue"
|
|
186
|
+
@blur="onInputBlur"
|
|
187
|
+
@focus="onInputFocus"
|
|
188
|
+
@input="onInputInput"
|
|
189
|
+
@change="onInputChange"
|
|
150
190
|
@keydown="onInputKeydown"
|
|
151
191
|
>
|
|
152
192
|
<template #prefix>
|
|
153
193
|
<button
|
|
154
|
-
|
|
194
|
+
tabindex="-1"
|
|
195
|
+
class="flex aspect-square h-full cursor-pointer touch-manipulation appearance-none items-center justify-center border-r font-inherit text-foreground outline-none enabled:hover:bg-background-hover enabled:hover:text-gray-1000 enabled:active:bg-background-active disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-700 motion-safe:transition-colors"
|
|
155
196
|
:disabled="decreaseDisabled"
|
|
156
197
|
@pointerdown="startDecrease"
|
|
157
198
|
@pointercancel="stopDecrease"
|
|
158
199
|
@pointerup="stopDecrease"
|
|
159
200
|
@contextmenu.prevent="NOOP"
|
|
160
201
|
>
|
|
161
|
-
<
|
|
202
|
+
<slot name="minusIcon">
|
|
203
|
+
<MinusIcon class="pointer-events-none" />
|
|
204
|
+
</slot>
|
|
162
205
|
</button>
|
|
163
206
|
|
|
164
207
|
<slot name="prefix" />
|
|
@@ -168,14 +211,17 @@ function onInputKeydown(ev) {
|
|
|
168
211
|
<slot name="suffix" />
|
|
169
212
|
|
|
170
213
|
<button
|
|
171
|
-
|
|
214
|
+
tabindex="-1"
|
|
215
|
+
class="flex aspect-square h-full cursor-pointer touch-manipulation appearance-none items-center justify-center border-l font-inherit text-foreground outline-none enabled:hover:bg-background-hover enabled:hover:text-gray-1000 enabled:active:bg-background-active disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-700 motion-safe:transition-colors"
|
|
172
216
|
:disabled="increaseDisabled"
|
|
173
217
|
@pointerdown="startIncrease"
|
|
174
218
|
@pointercancel="stopIncrease"
|
|
175
219
|
@pointerup="stopIncrease"
|
|
176
220
|
@contextmenu.prevent="NOOP"
|
|
177
221
|
>
|
|
178
|
-
<
|
|
222
|
+
<slot name="plusIcon">
|
|
223
|
+
<PlusIcon class="pointer-events-none" />
|
|
224
|
+
</slot>
|
|
179
225
|
</button>
|
|
180
226
|
</template>
|
|
181
227
|
</PInput>
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import {
|
|
3
|
-
computed,
|
|
4
|
-
nextTick,
|
|
5
|
-
onBeforeUnmount,
|
|
6
|
-
shallowRef,
|
|
7
|
-
watch
|
|
8
|
-
} from "vue";
|
|
2
|
+
import { computed, nextTick, onBeforeUnmount, shallowRef, watch } from "vue";
|
|
9
3
|
import { useLockScroll } from "../../composables";
|
|
10
4
|
import { cachedOff, cachedOn, NOOP } from "../../utils/event";
|
|
11
5
|
import { isTruthyProp } from "../../utils/format";
|
|
@@ -32,10 +26,7 @@ const props = defineProps({
|
|
|
32
26
|
shownElement: { type: null, required: false }
|
|
33
27
|
});
|
|
34
28
|
const emits = defineEmits(["click", "escape", "update:modelValue"]);
|
|
35
|
-
const {
|
|
36
|
-
lockScroll,
|
|
37
|
-
unlockScroll
|
|
38
|
-
} = useLockScroll();
|
|
29
|
+
const { lockScroll, unlockScroll } = useLockScroll();
|
|
39
30
|
const overlayId = Symbol("pxd-overlay");
|
|
40
31
|
const clipPath = shallowRef("");
|
|
41
32
|
const computedStyle = computed(() => ({
|
|
@@ -109,15 +100,8 @@ function onOverlayVisibleChange(visible) {
|
|
|
109
100
|
cachedOff(document, "keydown", onOverlayKeydown);
|
|
110
101
|
shownElementEl?.classList.remove("pointer-events-auto");
|
|
111
102
|
}
|
|
112
|
-
watch(
|
|
113
|
-
|
|
114
|
-
onOverlayVisibleChange,
|
|
115
|
-
{ immediate: true }
|
|
116
|
-
);
|
|
117
|
-
watch(
|
|
118
|
-
() => props.shownElement,
|
|
119
|
-
tryGetShownElementIfNeed
|
|
120
|
-
);
|
|
103
|
+
watch(() => props.modelValue, onOverlayVisibleChange, { immediate: true });
|
|
104
|
+
watch(() => props.shownElement, tryGetShownElementIfNeed);
|
|
121
105
|
onBeforeUnmount(() => {
|
|
122
106
|
cachedOff(document, "keydown", onOverlayKeydown);
|
|
123
107
|
removeOverlay(overlayId);
|
|
@@ -8,14 +8,24 @@ defineProps({
|
|
|
8
8
|
prev: { type: Object, required: false },
|
|
9
9
|
next: { type: Object, required: false }
|
|
10
10
|
});
|
|
11
|
-
const
|
|
11
|
+
const configProvider = useConfigProvider();
|
|
12
12
|
</script>
|
|
13
13
|
|
|
14
14
|
<template>
|
|
15
|
-
<nav
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
<nav
|
|
16
|
+
aria-label="pagination"
|
|
17
|
+
class="pxd-pagination relative flex w-full flex-wrap items-start justify-between"
|
|
18
|
+
>
|
|
19
|
+
<RouterLink
|
|
20
|
+
v-if="prev"
|
|
21
|
+
:to="prev.href"
|
|
22
|
+
class="pxd-pagination--prev min-h-13 group py-1 pr-2 pl-6 rounded-md no-underline! self-focus-ring outline-none"
|
|
23
|
+
>
|
|
24
|
+
<span
|
|
25
|
+
secondary
|
|
26
|
+
class="text-13px text-foreground-secondary group-hover:text-foreground motion-safe:transition-colors"
|
|
27
|
+
>
|
|
28
|
+
{{ configProvider.locale.compare.prev }}
|
|
19
29
|
</span>
|
|
20
30
|
|
|
21
31
|
<div class="pxd-pagination--label prev relative flex items-center text-foreground">
|
|
@@ -28,9 +38,16 @@ const config = useConfigProvider();
|
|
|
28
38
|
<slot />
|
|
29
39
|
</div>
|
|
30
40
|
|
|
31
|
-
<RouterLink
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
<RouterLink
|
|
42
|
+
v-if="next"
|
|
43
|
+
:to="next.href"
|
|
44
|
+
class="pxd-pagination--next min-h-13 group py-1 pl-2 pr-6 rounded-md no-underline! self-focus-ring outline-none"
|
|
45
|
+
>
|
|
46
|
+
<span
|
|
47
|
+
secondary
|
|
48
|
+
class="text-13px text-foreground-secondary group-hover:text-foreground motion-safe:transition-colors"
|
|
49
|
+
>
|
|
50
|
+
{{ configProvider.locale.compare.next }}
|
|
34
51
|
</span>
|
|
35
52
|
|
|
36
53
|
<div class="pxd-pagination--label next relative flex items-center text-foreground">
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare const pinInputVariant: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
size: {
|
|
3
|
+
xs: string;
|
|
4
|
+
sm: string;
|
|
5
|
+
md: string;
|
|
6
|
+
lg: string;
|
|
7
|
+
};
|
|
8
|
+
error: {
|
|
9
|
+
true: string;
|
|
10
|
+
false: string;
|
|
11
|
+
};
|
|
12
|
+
disabled: {
|
|
13
|
+
true: string;
|
|
14
|
+
false: string;
|
|
15
|
+
};
|
|
16
|
+
}, undefined, "pxd-input--border rounded-md motion-safe:transition-all", {
|
|
17
|
+
size: {
|
|
18
|
+
xs: string;
|
|
19
|
+
sm: string;
|
|
20
|
+
md: string;
|
|
21
|
+
lg: string;
|
|
22
|
+
};
|
|
23
|
+
error: {
|
|
24
|
+
true: string;
|
|
25
|
+
false: string;
|
|
26
|
+
};
|
|
27
|
+
disabled: {
|
|
28
|
+
true: string;
|
|
29
|
+
false: string;
|
|
30
|
+
};
|
|
31
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
32
|
+
size: {
|
|
33
|
+
xs: string;
|
|
34
|
+
sm: string;
|
|
35
|
+
md: string;
|
|
36
|
+
lg: string;
|
|
37
|
+
};
|
|
38
|
+
error: {
|
|
39
|
+
true: string;
|
|
40
|
+
false: string;
|
|
41
|
+
};
|
|
42
|
+
disabled: {
|
|
43
|
+
true: string;
|
|
44
|
+
false: string;
|
|
45
|
+
};
|
|
46
|
+
}, undefined, "pxd-input--border rounded-md motion-safe:transition-all", unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { tv } from "tailwind-variants";
|
|
2
|
+
export const pinInputVariant = tv({
|
|
3
|
+
base: "pxd-input--border rounded-md motion-safe:transition-all",
|
|
4
|
+
variants: {
|
|
5
|
+
size: {
|
|
6
|
+
xs: "w-6 text-xs",
|
|
7
|
+
sm: "w-7.5 text-sm",
|
|
8
|
+
md: "w-9 text-sm",
|
|
9
|
+
lg: "w-10 text-base"
|
|
10
|
+
},
|
|
11
|
+
error: {
|
|
12
|
+
true: "is-error",
|
|
13
|
+
false: ""
|
|
14
|
+
},
|
|
15
|
+
disabled: {
|
|
16
|
+
true: "is-disabled",
|
|
17
|
+
false: ""
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
size: "md",
|
|
22
|
+
error: false,
|
|
23
|
+
disabled: false
|
|
24
|
+
}
|
|
25
|
+
});
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { computed, ref, shallowRef } from "vue";
|
|
3
3
|
import { useConfigProvider } from "../../composables/use-config-provider-context";
|
|
4
4
|
import { useModelValue } from "../../composables/use-model-value";
|
|
5
|
-
import {
|
|
5
|
+
import { isTruthyProp } from "../../utils/format";
|
|
6
|
+
import { pinInputVariant } from "./cn";
|
|
6
7
|
defineOptions({
|
|
7
8
|
name: "PPinInput",
|
|
8
9
|
model: {
|
|
@@ -23,13 +24,7 @@ const props = defineProps({
|
|
|
23
24
|
type: { type: String, required: false, default: "numeric" }
|
|
24
25
|
});
|
|
25
26
|
const emits = defineEmits(["change", "update:modelValue"]);
|
|
26
|
-
const
|
|
27
|
-
xs: "w-6 text-xs",
|
|
28
|
-
sm: "w-7.5 text-sm",
|
|
29
|
-
md: "w-9 text-sm",
|
|
30
|
-
lg: "w-10 text-base"
|
|
31
|
-
};
|
|
32
|
-
const config = useConfigProvider();
|
|
27
|
+
const configProvider = useConfigProvider();
|
|
33
28
|
const inputsRef = shallowRef([]);
|
|
34
29
|
const modelValue = useModelValue(props, emits);
|
|
35
30
|
const modelValueLocal = ref(
|
|
@@ -54,16 +49,12 @@ const computedInputType = computed(() => {
|
|
|
54
49
|
const computedInputMode = computed(() => {
|
|
55
50
|
return props.type.includes("numeric") ? "numeric" : "text";
|
|
56
51
|
});
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
classes.push("is-disabled");
|
|
64
|
-
}
|
|
65
|
-
classes.push(getFallbackValue(props.size, SIZES, config.size));
|
|
66
|
-
return classes.join(" ");
|
|
52
|
+
const computedClasses = computed(() => {
|
|
53
|
+
return pinInputVariant({
|
|
54
|
+
size: props.size || configProvider.size,
|
|
55
|
+
error: isTruthyProp(props.error),
|
|
56
|
+
disabled: isTruthyProp(props.disabled)
|
|
57
|
+
});
|
|
67
58
|
});
|
|
68
59
|
function setInputValue(value, index) {
|
|
69
60
|
if (index !== void 0) {
|
|
@@ -193,7 +184,7 @@ function onInputPastedValue(ev) {
|
|
|
193
184
|
@compositionend="onCompositionEnd"
|
|
194
185
|
@click="onContainerClick"
|
|
195
186
|
>
|
|
196
|
-
<div v-for="(n, i) of length" :key="n" :class="
|
|
187
|
+
<div v-for="(n, i) of length" :key="n" :class="computedClasses">
|
|
197
188
|
<input
|
|
198
189
|
ref="inputsRef"
|
|
199
190
|
:value="modelValueLocal[i]"
|
|
@@ -213,7 +204,7 @@ function onInputPastedValue(ev) {
|
|
|
213
204
|
:inputmode="computedInputMode"
|
|
214
205
|
@paste="onInputPastedValue"
|
|
215
206
|
@beforeinput="onBeforeInputValue"
|
|
216
|
-
|
|
207
|
+
/>
|
|
217
208
|
</div>
|
|
218
209
|
</label>
|
|
219
210
|
</template>
|