pxd 0.0.13 → 0.0.15

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.
Files changed (71) hide show
  1. package/dist/components/active-graph/index.vue +163 -0
  2. package/dist/components/active-graph/index.vue.d.ts +19 -0
  3. package/dist/components/avatar/index.vue +28 -7
  4. package/dist/components/avatar/index.vue.d.ts +9 -1
  5. package/dist/components/button/index.vue +9 -5
  6. package/dist/components/button/index.vue.d.ts +6 -4
  7. package/dist/components/checkbox/index.vue +4 -3
  8. package/dist/components/checkbox/index.vue.d.ts +2 -2
  9. package/dist/components/checkbox-group/index.vue +5 -1
  10. package/dist/components/config-provider/index.vue +3 -1
  11. package/dist/components/config-provider/index.vue.d.ts +1 -0
  12. package/dist/components/description/index.vue +31 -0
  13. package/dist/components/description/index.vue.d.ts +19 -0
  14. package/dist/components/error/index.vue +17 -13
  15. package/dist/components/gauge/index.vue +12 -17
  16. package/dist/components/gauge/index.vue.d.ts +2 -2
  17. package/dist/components/hold-button/index.vue +1 -1
  18. package/dist/components/index.d.ts +4 -1
  19. package/dist/components/index.js +4 -1
  20. package/dist/components/input/index.vue +27 -19
  21. package/dist/components/input/index.vue.d.ts +12 -9
  22. package/dist/components/kbd/index.vue +1 -1
  23. package/dist/components/link-button/index.vue +1 -1
  24. package/dist/components/more-button/index.vue +2 -2
  25. package/dist/components/note/index.vue +14 -7
  26. package/dist/components/note/index.vue.d.ts +35 -7
  27. package/dist/components/progress/index.vue +9 -15
  28. package/dist/components/progress/index.vue.d.ts +2 -2
  29. package/dist/components/radio/index.vue +2 -2
  30. package/dist/components/radio/index.vue.d.ts +2 -2
  31. package/dist/components/radio-group/index.vue.d.ts +2 -2
  32. package/dist/components/scrollable/index.vue +2 -3
  33. package/dist/components/slider/index.vue +35 -27
  34. package/dist/components/slider/index.vue.d.ts +5 -4
  35. package/dist/components/snippet/index.vue +4 -3
  36. package/dist/components/textarea/index.vue +18 -10
  37. package/dist/components/textarea/index.vue.d.ts +16 -5
  38. package/dist/components/{color-scheme → theme-switcher}/index.vue +5 -2
  39. package/dist/components/toggle/index.vue +2 -2
  40. package/dist/components/toggle/index.vue.d.ts +2 -2
  41. package/dist/components/tooltip/index.vue +265 -0
  42. package/dist/components/tooltip/index.vue.d.ts +36 -0
  43. package/dist/composables/useConfigProviderContext.d.ts +1 -0
  44. package/dist/composables/useConfigProviderContext.js +3 -1
  45. package/dist/composables/useModelValue.d.ts +1 -1
  46. package/dist/composables/useRandomValueContext.js +6 -6
  47. package/dist/index.d.ts +1 -1
  48. package/dist/index.js +1 -1
  49. package/dist/locales/en-US.d.ts +32 -0
  50. package/dist/locales/en-US.js +31 -0
  51. package/dist/locales/index.d.ts +2 -0
  52. package/dist/locales/index.js +2 -0
  53. package/dist/locales/zh-CN.d.ts +32 -0
  54. package/dist/locales/zh-CN.js +31 -0
  55. package/dist/styles/dst.css +277 -0
  56. package/dist/styles/styles.css +2 -0
  57. package/dist/styles/tw.css +361 -355
  58. package/dist/utils/colors.d.ts +1 -0
  59. package/dist/utils/colors.js +13 -0
  60. package/dist/utils/date.d.ts +12 -0
  61. package/dist/utils/date.js +40 -0
  62. package/dist/utils/fn.d.ts +1 -0
  63. package/dist/utils/fn.js +17 -0
  64. package/dist/utils/random.d.ts +1 -1
  65. package/dist/utils/random.js +2 -2
  66. package/dist/utils/uid.d.ts +1 -0
  67. package/dist/utils/uid.js +4 -0
  68. package/package.json +27 -7
  69. package/dist/styles/index.css +0 -2
  70. package/dist/styles/tokens.css +0 -238
  71. /package/dist/components/{color-scheme → theme-switcher}/index.vue.d.ts +0 -0
@@ -1,13 +1,14 @@
1
1
  <script setup>
2
- import { EyeIcon, EyeOffIcon } from "gdsi/vue";
2
+ import EyeIcon from "@gdsicon/vue/eye";
3
+ import EyeOffIcon from "@gdsicon/vue/eye-off";
3
4
  import { twMerge } from "tailwind-merge";
4
5
  import { computed, shallowRef } from "vue";
5
6
  import { useComputedSize } from "../../composables/useComputedSize";
6
7
  import { useModelValue } from "../../composables/useModelValue";
8
+ import { getUniqueId } from "../../utils/uid";
7
9
  import PError from "../error/index.vue";
8
10
  defineOptions({
9
11
  name: "PInput",
10
- inheritAttrs: false,
11
12
  model: {
12
13
  prop: "modelValue",
13
14
  event: "update:modelValue"
@@ -16,17 +17,19 @@ defineOptions({
16
17
  const props = defineProps({
17
18
  size: { type: String, required: false },
18
19
  error: { type: String, required: false },
20
+ label: { type: String, required: false },
19
21
  readonly: { type: Boolean, required: false },
20
22
  disabled: { type: Boolean, required: false },
21
23
  password: { type: Boolean, required: false },
22
- modelValue: { type: String, required: false, default: "" },
24
+ minlength: { type: [Number, String], required: false },
25
+ maxlength: { type: [Number, String], required: false },
26
+ modelValue: { type: [String, Number, Array, null], required: false, default: "" },
23
27
  placeholder: { type: String, required: false },
24
28
  prefixStyle: { type: Boolean, required: false, default: true },
25
- suffixStyle: { type: Boolean, required: false, default: true },
26
- minlength: { type: [Number, String], required: false },
27
- maxlength: { type: [Number, String], required: false }
29
+ suffixStyle: { type: Boolean, required: false, default: true }
28
30
  });
29
31
  const emits = defineEmits(["update:modelValue", "focus", "blur", "change"]);
32
+ const randomId = getUniqueId();
30
33
  const SIZES = {
31
34
  xs: "h-6 text-xs",
32
35
  sm: "h-7.5 text-sm",
@@ -37,7 +40,7 @@ const modelValue = useModelValue(props, emits);
37
40
  const internalInputType = shallowRef(props.password ? "password" : "text");
38
41
  const computedSize = useComputedSize(props.size, SIZES);
39
42
  const computedClasses = computed(() => {
40
- const basic = ["pxd-input--container relative flex items-center justify-center rounded-inherit h-full motion-safe:transition-all overflow-hidden rounded-md bg-background"];
43
+ const basic = ["pxd-input--container flex items-center relative rounded-inherit h-full motion-safe:transition-all overflow-hidden rounded-md bg-background"];
41
44
  basic.push(computedSize.value);
42
45
  if (props.disabled) {
43
46
  basic.push("is-disabled bg-gray-100");
@@ -65,18 +68,23 @@ function togglePasswordType() {
65
68
  </script>
66
69
 
67
70
  <template>
68
- <div class="pxd-input max-w-full">
69
- <label :class="computedClasses">
71
+ <label class="pxd-input w-full max-w-full" :for="randomId">
72
+ <div v-if="label || $slots.label" class="pxd-input--label text-sm text-gray-900 mb-2 max-w-full">
73
+ <slot name="label">{{ label }}</slot>
74
+ </div>
75
+
76
+ <div :class="computedClasses">
70
77
  <div
71
78
  v-if="$slots.prefix"
72
79
  aria-hidden="true"
73
- class="pl-3 h-full flex items-center text-sm text-gray-700 "
80
+ class="pxd-input--prefix pl-3 h-full flex items-center text-sm text-gray-700 "
74
81
  :class="{ 'bg-background-secondary rounded-tl-inherit rounded-bl-inherit border-r pr-3': prefixStyle }"
75
82
  >
76
83
  <slot name="prefix" />
77
84
  </div>
78
85
 
79
86
  <input
87
+ :id="randomId"
80
88
  v-model="modelValue"
81
89
  class="w-full h-full px-3 rounded-inherit outline-none bg-transparent disabled:text-gray-700 disabled:cursor-not-allowed placeholder:select-none file:border-0 file:bg-transparent file:font-medium"
82
90
  :class="{ 'pr-10': password }"
@@ -103,38 +111,38 @@ function togglePasswordType() {
103
111
  <div
104
112
  v-if="$slots.suffix"
105
113
  aria-hidden="true"
106
- class="pr-3 h-full flex items-center text-sm text-gray-700"
114
+ class="pxd-input--suffix pr-3 h-full flex items-center text-sm text-gray-700"
107
115
  :class="{ 'bg-background-secondary rounded-tr-inherit rounded-br-inherit border-l pl-3': suffixStyle }"
108
116
  >
109
117
  <slot name="suffix" />
110
118
  </div>
111
- </label>
119
+ </div>
112
120
 
113
- <PError v-if="error" class="mt-1.5" :size="size">
121
+ <PError v-if="error" class="mt-2" :size="size">
114
122
  {{ error }}
115
123
  </PError>
116
- </div>
124
+ </label>
117
125
  </template>
118
126
 
119
127
  <style lang="postcss">
120
128
  .pxd-input--container {
121
- box-shadow: 0 0 0 1px var(--border-color, var(--gray-alpha-300));
129
+ box-shadow: 0 0 0 1px var(--border-color, var(--color-gray-alpha-300));
122
130
 
123
131
  &:not(.is-disabled, .is-readonly):hover {
124
- --border-color: var(--gray-alpha-600);
132
+ --border-color: var(--color-gray-alpha-600);
125
133
  }
126
134
 
127
135
  &:not(.is-disabled, .is-readonly):focus-within {
128
- box-shadow: 0 0 0 1px var(--gray-alpha-600), 0 0 0 4px var(--gray-alpha-300);
136
+ box-shadow: 0 0 0 1px var(--color-gray-alpha-600), 0 0 0 4px var(--color-gray-alpha-300);
129
137
  }
130
138
 
131
139
  &.is-error {
132
140
  &, &:focus-within {
133
- box-shadow: 0 0 0 1px hsl(var(--red-900-value)), 0 0 0 4px hsl(var(--red-300-value));
141
+ box-shadow: 0 0 0 1px hsl(var(--color-red-900-value)), 0 0 0 4px hsl(var(--color-red-300-value));
134
142
  }
135
143
 
136
144
  &:not(.is-disabled, .is-readonly, :focus):hover {
137
- box-shadow: 0 0 0 1px hsl(var(--red-900-value)), 0 0 0 4px hsl(var(--red-500-value));
145
+ box-shadow: 0 0 0 1px hsl(var(--color-red-900-value)), 0 0 0 4px hsl(var(--color-red-500-value));
138
146
  }
139
147
  }
140
148
  }
@@ -2,34 +2,37 @@ import type { ComponentSizeWithXs } from '../../types/components';
2
2
  interface Props {
3
3
  size?: ComponentSizeWithXs;
4
4
  error?: string;
5
+ label?: string;
5
6
  readonly?: boolean;
6
7
  disabled?: boolean;
7
8
  password?: boolean;
8
- modelValue?: string;
9
+ minlength?: number | string;
10
+ maxlength?: number | string;
11
+ modelValue?: string | number | readonly string[] | null;
9
12
  placeholder?: string;
10
13
  prefixStyle?: boolean;
11
14
  suffixStyle?: boolean;
12
- minlength?: number | string;
13
- maxlength?: number | string;
14
15
  }
15
- declare var __VLS_1: {}, __VLS_11: {};
16
+ declare var __VLS_1: {}, __VLS_3: {}, __VLS_13: {};
16
17
  type __VLS_Slots = {} & {
17
- prefix?: (props: typeof __VLS_1) => any;
18
+ label?: (props: typeof __VLS_1) => any;
19
+ } & {
20
+ prefix?: (props: typeof __VLS_3) => any;
18
21
  } & {
19
- suffix?: (props: typeof __VLS_11) => any;
22
+ suffix?: (props: typeof __VLS_13) => any;
20
23
  };
21
24
  declare const __VLS_component: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
25
  blur: (args_0: FocusEvent) => any;
23
26
  change: (args_0: Event) => any;
24
27
  focus: (args_0: FocusEvent) => any;
25
- "update:modelValue": (args_0: string) => any;
28
+ "update:modelValue": (args_0: NonNullable<string | number | readonly string[]>) => any;
26
29
  }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
27
30
  onBlur?: (args_0: FocusEvent) => any;
28
31
  onChange?: (args_0: Event) => any;
29
32
  onFocus?: (args_0: FocusEvent) => any;
30
- "onUpdate:modelValue"?: (args_0: string) => any;
33
+ "onUpdate:modelValue"?: (args_0: NonNullable<string | number | readonly string[]>) => any;
31
34
  }>, {
32
- modelValue: string;
35
+ modelValue: string | number | readonly string[] | null;
33
36
  prefixStyle: boolean;
34
37
  suffixStyle: boolean;
35
38
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -26,7 +26,7 @@ const internalKey = computed(() => {
26
26
 
27
27
  <template>
28
28
  <kbd
29
- class="pxd-keyboard-input border border-input inline-flex px-1.5 items-center bg-background text-gray-1000 text-center rounded-md font-sans ml-1"
29
+ class="pxd-keyboard border border-input inline-flex px-1.5 items-center bg-background text-gray-1000 text-center rounded-md font-sans ml-1"
30
30
  :class="[small ? 'h-5 text-xs' : 'h-6 text-sm']"
31
31
  >
32
32
  {{ internalKey }}
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { ExternalIcon } from "gdsi/vue";
2
+ import ExternalIcon from "@gdsicon/vue/external";
3
3
  import { computed, useAttrs } from "vue";
4
4
  import { isExternalLink } from "../../utils/format";
5
5
  import Button from "../button/index.vue";
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { ChevronDownIcon } from "gdsi/vue";
2
+ import ChevronDownIcon from "@gdsicon/vue/chevron-down";
3
3
  import { useModelValue } from "../../composables/useModelValue";
4
4
  import Button from "../button/index.vue";
5
5
  defineOptions({
@@ -46,6 +46,6 @@ function onToggleExpand() {
46
46
  content: '';
47
47
  display: block;
48
48
  width: 100%;
49
- border-top: 1px solid var(--gray-alpha-300);
49
+ border-top: 1px solid var(--color-gray-alpha-300);
50
50
  }
51
51
  </style>
@@ -1,5 +1,8 @@
1
1
  <script setup>
2
- import { CheckCircleIcon, InformationIcon, StopIcon, WarningIcon } from "gdsi/vue";
2
+ import CheckCircleIcon from "@gdsicon/vue/check-circle";
3
+ import InformationIcon from "@gdsicon/vue/information";
4
+ import StopIcon from "@gdsicon/vue/stop";
5
+ import WarningIcon from "@gdsicon/vue/warning";
3
6
  import { twMerge } from "tailwind-merge";
4
7
  import { computed, h } from "vue";
5
8
  import { useComputedSize } from "../../composables/useComputedSize";
@@ -66,7 +69,7 @@ const computedLabel = computed(() => {
66
69
  });
67
70
  const computedSize = useComputedSize(props.size, SIZES);
68
71
  const computedClasses = computed(() => {
69
- const basic = ["pxd-note flex items-center gap-3 border rounded-md w-max"];
72
+ const basic = ["pxd-note flex flex-col sm:flex-row sm:items-center gap-2 border rounded-md w-max max-w-full"];
70
73
  basic.push(computedSize.value);
71
74
  if (props.fill) {
72
75
  basic.push((VARIANTS[props.variant] || VARIANTS.default)?.fill);
@@ -79,13 +82,17 @@ const computedClasses = computed(() => {
79
82
 
80
83
  <template>
81
84
  <div :class="computedClasses">
82
- <slot v-if="computedLabel" name="label">
83
- <component :is="computedLabel" class="font-medium" />
84
- </slot>
85
+ <div class="flex items-center gap-3">
86
+ <slot v-if="computedLabel" name="label">
87
+ <component :is="computedLabel" class="font-medium flex-shrink-0" />
88
+ </slot>
85
89
 
86
- <slot />
90
+ <span class="flex-1">
91
+ <slot />
92
+ </span>
93
+ </div>
87
94
 
88
- <div v-if="$slots.action" class="pxd-note--action ml-2">
95
+ <div v-if="$slots.action" class="pxd-note--action">
89
96
  <slot name="action" />
90
97
  </div>
91
98
  </div>
@@ -7,37 +7,65 @@ interface Props {
7
7
  }
8
8
  declare const VARIANTS: {
9
9
  success: {
10
- icon: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
10
+ icon: DefineComponent<{
11
+ width?: string;
12
+ height?: string;
13
+ fill?: string;
14
+ }>;
11
15
  fill: string;
12
16
  classes: string;
13
17
  };
14
18
  error: {
15
- icon: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
19
+ icon: DefineComponent<{
20
+ width?: string;
21
+ height?: string;
22
+ fill?: string;
23
+ }>;
16
24
  fill: string;
17
25
  classes: string;
18
26
  };
19
27
  warning: {
20
- icon: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
28
+ icon: DefineComponent<{
29
+ width?: string;
30
+ height?: string;
31
+ fill?: string;
32
+ }>;
21
33
  fill: string;
22
34
  classes: string;
23
35
  };
24
36
  default: {
25
- icon: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
37
+ icon: DefineComponent<{
38
+ width?: string;
39
+ height?: string;
40
+ fill?: string;
41
+ }>;
26
42
  fill: string;
27
43
  classes: string;
28
44
  };
29
45
  primary: {
30
- icon: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
46
+ icon: DefineComponent<{
47
+ width?: string;
48
+ height?: string;
49
+ fill?: string;
50
+ }>;
31
51
  fill: string;
32
52
  classes: string;
33
53
  };
34
54
  violet: {
35
- icon: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
55
+ icon: DefineComponent<{
56
+ width?: string;
57
+ height?: string;
58
+ fill?: string;
59
+ }>;
36
60
  fill: string;
37
61
  classes: string;
38
62
  };
39
63
  cyan: {
40
- icon: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
64
+ icon: DefineComponent<{
65
+ width?: string;
66
+ height?: string;
67
+ fill?: string;
68
+ }>;
41
69
  fill: string;
42
70
  classes: string;
43
71
  };
@@ -2,6 +2,7 @@
2
2
  import { computed } from "vue";
3
3
  import { useConfigProvider } from "../../composables/useConfigProviderContext";
4
4
  import { useModelValue } from "../../composables/useModelValue";
5
+ import { getStateColor } from "../../utils/colors";
5
6
  defineOptions({
6
7
  name: "PProgress",
7
8
  model: {
@@ -16,7 +17,7 @@ const props = defineProps({
16
17
  label: { type: [String, Number, Boolean], required: false, default: false },
17
18
  variant: { type: String, required: false, default: "primary" },
18
19
  colors: { type: Object, required: false },
19
- modelValue: { type: Number, required: true }
20
+ modelValue: { type: [Number, null], required: false }
20
21
  });
21
22
  const emits = defineEmits(["update:modelValue"]);
22
23
  const config = useConfigProvider();
@@ -27,14 +28,13 @@ const SIZES = {
27
28
  };
28
29
  const VARIANTS_COLORS = {
29
30
  primary: "var(--color-primary)",
30
- success: "hsl(var(--blue-700-value))",
31
- warning: "hsl(var(--amber-700-value))",
32
- secondary: "hsl(var(--gray-700-value))",
33
- error: "hsl(var(--red-700-value))"
31
+ success: "hsl(var(--color-blue-700-value))",
32
+ warning: "hsl(var(--color-amber-700-value))",
33
+ secondary: "hsl(var(--color-gray-700-value))",
34
+ error: "hsl(var(--color-red-700-value))"
34
35
  };
35
- const progress = useModelValue(props, emits);
36
- const sortedColorKeys = computed(() => {
37
- return props.colors ? Object.keys(props.colors).map(Number).sort((a, b) => a - b) : [];
36
+ const progress = useModelValue(props, emits, {
37
+ get: () => props.modelValue || 0
38
38
  });
39
39
  const computedLabel = computed(() => {
40
40
  const { label } = props;
@@ -49,13 +49,7 @@ const computedLabel = computed(() => {
49
49
  const computedColors = computed(() => {
50
50
  const { colors, variant } = props;
51
51
  if (colors) {
52
- const sortedKeys = sortedColorKeys.value;
53
- for (let i = 0; i < sortedKeys.length; i++) {
54
- if (progress.value < sortedKeys[i]) {
55
- return colors[sortedKeys[i - 1]];
56
- }
57
- }
58
- return colors[sortedKeys.at(-1)];
52
+ return getStateColor(progress.value, colors) || VARIANTS_COLORS[variant];
59
53
  }
60
54
  return VARIANTS_COLORS[variant];
61
55
  });
@@ -6,7 +6,7 @@ interface Props {
6
6
  label?: string | number | boolean;
7
7
  variant?: ComponentVariant | 'secondary';
8
8
  colors?: Record<string, string>;
9
- modelValue: number;
9
+ modelValue?: number | null;
10
10
  }
11
11
  declare var __VLS_1: {};
12
12
  type __VLS_Slots = {} & {
@@ -21,7 +21,7 @@ declare const __VLS_component: import("vue").DefineComponent<Props, {}, {}, {},
21
21
  max: number;
22
22
  min: number;
23
23
  label: string | number | boolean;
24
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
24
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
25
25
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
26
26
  export default _default;
27
27
  type __VLS_WithSlots<T, S> = T & {
@@ -3,7 +3,7 @@ import { twMerge } from "tailwind-merge";
3
3
  import { computed, inject } from "vue";
4
4
  import { useModelValue } from "../../composables/useModelValue";
5
5
  import { useRandomValue } from "../../composables/useRandomValueContext";
6
- import { getRandomId } from "../../utils/random";
6
+ import { getUniqueId } from "../../utils/uid";
7
7
  defineOptions({
8
8
  name: "PRadio",
9
9
  model: {
@@ -19,7 +19,7 @@ const props = defineProps({
19
19
  modelValue: { type: [String, Number], required: false }
20
20
  });
21
21
  const emits = defineEmits(["update:modelValue"]);
22
- const randomId = getRandomId();
22
+ const randomId = getUniqueId();
23
23
  const modelValue = useModelValue(props, emits);
24
24
  const radioGroupName = useRandomValue("radioGroupName");
25
25
  const radioGroupProps = inject("radioGroupProps", {
@@ -10,9 +10,9 @@ type __VLS_Slots = {} & {
10
10
  default?: (props: typeof __VLS_1) => any;
11
11
  };
12
12
  declare const __VLS_component: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
- "update:modelValue": (args_0: string | number) => any;
13
+ "update:modelValue": (args_0: NonNullable<string | number>) => any;
14
14
  }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
15
- "onUpdate:modelValue"?: (args_0: string | number) => any;
15
+ "onUpdate:modelValue"?: (args_0: NonNullable<string | number>) => any;
16
16
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
17
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
18
18
  export default _default;
@@ -14,9 +14,9 @@ type __VLS_Slots = {} & {
14
14
  default?: (props: typeof __VLS_5) => any;
15
15
  };
16
16
  declare const __VLS_component: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
17
- "update:modelValue": (args_0: string | number) => any;
17
+ "update:modelValue": (args_0: NonNullable<string | number>) => any;
18
18
  }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
19
- "onUpdate:modelValue"?: (args_0: string | number) => any;
19
+ "onUpdate:modelValue"?: (args_0: NonNullable<string | number>) => any;
20
20
  }>, {
21
21
  options: RadioGroupOptions[];
22
22
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -11,8 +11,8 @@ const props = defineProps({
11
11
  scrollbar: { type: Boolean, required: false, default: true },
12
12
  scrollbarSize: { type: Number, required: false, default: 6 },
13
13
  staticContent: { type: Boolean, required: false },
14
- scrollbarColor: { type: String, required: false, default: "var(--gray-alpha-300)" },
15
- scrollbarHoverColor: { type: String, required: false, default: "var(--gray-alpha-500)" }
14
+ scrollbarColor: { type: String, required: false, default: "var(--color-gray-alpha-300)" },
15
+ scrollbarHoverColor: { type: String, required: false, default: "var(--color-gray-alpha-500)" }
16
16
  });
17
17
  const emits = defineEmits(["scroll"]);
18
18
  const PADDING = 4;
@@ -283,7 +283,6 @@ defineExpose({
283
283
  &::after {
284
284
  content: '';
285
285
  position: absolute;
286
- backdrop-filter: blur(30px);
287
286
  background: linear-gradient(var(--dir), transparent, var(--c, var(--background-100)));
288
287
  mask-image: linear-gradient(var(--dir-revert), var(--c, var(--background-100)) 50%, transparent);
289
288
  opacity: 0;
@@ -3,16 +3,21 @@ import { computed, onBeforeUnmount, shallowRef } from "vue";
3
3
  import { useComputedSize } from "../../composables/useComputedSize";
4
4
  import { useModelValue } from "../../composables/useModelValue";
5
5
  defineOptions({
6
- name: "PSlider"
6
+ name: "PSlider",
7
+ model: {
8
+ prop: "modelValue",
9
+ event: "update:modelValue"
10
+ }
7
11
  });
8
12
  const props = defineProps({
9
13
  min: { type: Number, required: false, default: 0 },
10
14
  max: { type: Number, required: false, default: 100 },
11
15
  step: { type: Number, required: false, default: 1 },
12
16
  range: { type: Boolean, required: false },
17
+ disabled: { type: Boolean, required: false },
13
18
  size: { type: String, required: false },
14
19
  variant: { type: String, required: false, default: "primary" },
15
- modelValue: { type: [Number, Array], required: false, default: 0 }
20
+ modelValue: { type: [Number, Array, null], required: false, default: 0 }
16
21
  });
17
22
  const emits = defineEmits(["update:modelValue"]);
18
23
  const SIZES = {
@@ -31,10 +36,10 @@ const SIZES = {
31
36
  };
32
37
  const VARIANTS = {
33
38
  primary: "var(--color-primary)",
34
- success: "hsl(var(--blue-700-value))",
35
- warning: "hsl(var(--amber-700-value))",
36
- secondary: "hsl(var(--gray-700-value))",
37
- error: "hsl(var(--red-700-value))"
39
+ success: "hsl(var(--color-blue-700-value))",
40
+ warning: "hsl(var(--color-amber-700-value))",
41
+ secondary: "hsl(var(--color-gray-700-value))",
42
+ error: "hsl(var(--color-red-700-value))"
38
43
  };
39
44
  let isDragging = false;
40
45
  let lastClientX;
@@ -61,12 +66,12 @@ const trackStyle = computed(() => {
61
66
  return {
62
67
  left: `${startPercentage.value}%`,
63
68
  width: `${endPercentage.value - startPercentage.value}%`,
64
- backgroundColor: VARIANTS[props.variant] || VARIANTS.primary
69
+ backgroundColor: props.disabled ? "var(--color-gray-alpha-400)" : VARIANTS[props.variant] || VARIANTS.primary
65
70
  };
66
71
  }
67
72
  return {
68
73
  width: `${endPercentage.value}%`,
69
- backgroundColor: VARIANTS[props.variant] || VARIANTS.primary
74
+ backgroundColor: props.disabled ? "var(--color-gray-alpha-400)" : VARIANTS[props.variant] || VARIANTS.primary
70
75
  };
71
76
  });
72
77
  function updateValueFromPosition(clientX) {
@@ -109,29 +114,29 @@ function scheduleUpdate() {
109
114
  if (animationFrameId)
110
115
  return;
111
116
  animationFrameId = requestAnimationFrame(() => {
117
+ animationFrameId = null;
112
118
  if (lastClientX !== null) {
113
119
  updateValueFromPosition(lastClientX);
114
120
  }
115
- animationFrameId = null;
116
121
  if (isDragging) {
117
122
  scheduleUpdate();
118
123
  }
119
124
  });
120
125
  }
121
- function startDragging(e, thumb) {
126
+ function startDragging(ev, thumb) {
122
127
  isDragging = true;
123
128
  activeThumb.value = thumb;
124
- lastClientX = e.clientX;
125
- updateValueFromPosition(e.clientX);
129
+ lastClientX = ev.clientX;
130
+ updateValueFromPosition(ev.clientX);
126
131
  document.addEventListener("pointermove", handleMove, { passive: false });
127
132
  document.addEventListener("pointerup", endDragging, { once: true });
128
133
  document.addEventListener("pointercancel", endDragging, { once: true });
129
134
  }
130
- function handleMove(e) {
131
- if (!isDragging)
135
+ function handleMove(ev) {
136
+ if (!isDragging || props.disabled)
132
137
  return;
133
- e.preventDefault();
134
- lastClientX = e.clientX;
138
+ ev.preventDefault();
139
+ lastClientX = ev.clientX;
135
140
  scheduleUpdate();
136
141
  }
137
142
  function endDragging() {
@@ -145,19 +150,22 @@ function endDragging() {
145
150
  document.removeEventListener("pointermove", handleMove);
146
151
  document.removeEventListener("pointercancel", endDragging);
147
152
  }
148
- function handleSliderClick(e) {
149
- if (isDragging || !props.range)
153
+ function handleSliderClick(ev) {
154
+ if (isDragging || !props.range || props.disabled)
150
155
  return;
151
156
  const rect = sliderRef.value?.getBoundingClientRect();
152
157
  if (!rect)
153
158
  return;
154
- const clickPosition = (e.clientX - rect.left) / rect.width;
159
+ const clickPosition = (ev.clientX - rect.left) / rect.width;
155
160
  const startPos = startPercentage.value / 100;
156
161
  const endPos = endPercentage.value / 100;
157
162
  const thumb = Math.abs(clickPosition - startPos) < Math.abs(clickPosition - endPos) ? "start" : "end";
158
- startDragging(e, thumb);
163
+ startDragging(ev, thumb);
159
164
  }
160
165
  function onWrapperPointerdown(ev) {
166
+ if (props.disabled) {
167
+ return;
168
+ }
161
169
  if (props.range) {
162
170
  handleSliderClick(ev);
163
171
  return;
@@ -186,26 +194,26 @@ onBeforeUnmount(() => {
186
194
  <div
187
195
  ref="sliderRef"
188
196
  :role="range ? 'group' : 'slider'"
189
- :class="computedSize.track"
190
197
  class="pxd-slider group/slider relative bg-gray-200 flex items-center rounded-full select-none touch-none"
198
+ :class="[{ 'cursor-not-allowed': disabled }, computedSize.track]"
191
199
  @pointerdown.prevent="onWrapperPointerdown"
192
200
  >
193
201
  <div
194
- class="pxd-slider--track absolute h-full bg-primary rounded-full group-hover/slider:will-change-[width,left]"
202
+ class="pxd-slider--track absolute h-full rounded-full touch-none group-active/slider:will-change-[width,left]"
195
203
  :style="trackStyle"
196
204
  />
197
205
 
198
206
  <div
199
207
  v-if="props.range"
200
- class="pxd-slider--thumb absolute bg-background rounded-xs hover:scale-130 active:scale-130 active:z-10 -translate-x-1/2"
201
- :class="[{ 'scale-130': activeThumb === 'start' }, computedSize.thumb]"
208
+ class="pxd-slider--thumb absolute bg-background rounded-xs touch-none hover:scale-130 group-active/slider:will-change-[width,left] active:scale-130 active:z-10 -translate-x-1/2"
209
+ :class="[{ 'scale-130': activeThumb === 'start', 'pointer-events-none': disabled }, computedSize.thumb]"
202
210
  :style="{ left: `${startPercentage}%` }"
203
211
  @pointerdown.prevent.stop="startDragging($event, 'start')"
204
212
  />
205
213
 
206
214
  <div
207
- class="pxd-slider--thumb absolute bg-background rounded-xs hover:scale-130 active:scale-130 active:z-10 -translate-x-1/2"
208
- :class="[{ 'scale-130': activeThumb === 'end' }, computedSize.thumb]"
215
+ class="pxd-slider--thumb absolute bg-background rounded-xs touch-none hover:scale-130 group-active/slider:will-change-[width,left] active:scale-130 active:z-10 -translate-x-1/2"
216
+ :class="[{ 'scale-130': activeThumb === 'end', 'pointer-events-none': disabled }, computedSize.thumb]"
209
217
  :style="{ left: `${endPercentage}%` }"
210
218
  @pointerdown.prevent.stop="startDragging($event, 'end')"
211
219
  />
@@ -214,7 +222,7 @@ onBeforeUnmount(() => {
214
222
 
215
223
  <style>
216
224
  .pxd-slider--thumb {
217
- box-shadow: 0 0 0 1px var(--gray-alpha-500), 0 1px 2px var(--gray-alpha-100);
225
+ box-shadow: 0 0 0 1px var(--color-gray-alpha-500), 0 1px 2px var(--color-gray-alpha-100);
218
226
  }
219
227
 
220
228
  .pxd-slider--thumb::after {
@@ -4,19 +4,20 @@ interface Props {
4
4
  max?: number;
5
5
  step?: number;
6
6
  range?: boolean;
7
+ disabled?: boolean;
7
8
  size?: ComponentSize;
8
9
  variant?: ComponentVariant | 'secondary';
9
- modelValue?: number | [number, number];
10
+ modelValue?: number | [number, number] | null;
10
11
  }
11
12
  declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
- "update:modelValue": (args_0: number | [number, number]) => any;
13
+ "update:modelValue": (args_0: NonNullable<number | [number, number]>) => any;
13
14
  }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
14
- "onUpdate:modelValue"?: (args_0: number | [number, number]) => any;
15
+ "onUpdate:modelValue"?: (args_0: NonNullable<number | [number, number]>) => any;
15
16
  }>, {
16
17
  variant: ComponentVariant | "secondary";
17
18
  max: number;
18
19
  min: number;
19
20
  step: number;
20
- modelValue: number | [number, number];
21
+ modelValue: number | [number, number] | null;
21
22
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
22
23
  export default _default;