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.
Files changed (258) hide show
  1. package/README.md +6 -3
  2. package/dist/components/active-graph/index.d.vue.ts +0 -2
  3. package/dist/components/active-graph/index.vue +35 -37
  4. package/dist/components/avatar/index.d.vue.ts +2 -2
  5. package/dist/components/avatar/index.vue +17 -16
  6. package/dist/components/avatar-group/index.d.vue.ts +1 -1
  7. package/dist/components/avatar-group/index.vue +4 -1
  8. package/dist/components/badge/cn.d.ts +90 -0
  9. package/dist/components/badge/cn.js +44 -0
  10. package/dist/components/badge/index.d.vue.ts +5 -33
  11. package/dist/components/badge/index.vue +10 -56
  12. package/dist/components/book/index.vue +90 -17
  13. package/dist/components/browser/index.vue +21 -6
  14. package/dist/components/button/cn.d.ts +121 -0
  15. package/dist/components/button/cn.js +55 -0
  16. package/dist/components/button/index.d.vue.ts +8 -14
  17. package/dist/components/button/index.vue +22 -74
  18. package/dist/components/carousel-group/index.d.vue.ts +1 -1
  19. package/dist/components/carousel-group/index.vue +32 -28
  20. package/dist/components/checkbox/cn.d.ts +67 -0
  21. package/dist/components/checkbox/cn.js +31 -0
  22. package/dist/components/checkbox/index.vue +9 -19
  23. package/dist/components/chip/cn.d.ts +49 -0
  24. package/dist/components/chip/cn.js +26 -0
  25. package/dist/components/chip/index.vue +13 -21
  26. package/dist/components/choicebox/index.vue +1 -1
  27. package/dist/components/choicebox-group/index.vue +6 -3
  28. package/dist/components/collapse/index.vue +7 -1
  29. package/dist/components/collapse-group/index.vue +7 -7
  30. package/dist/components/command-menu/index.vue +9 -8
  31. package/dist/components/command-menu-group/index.vue +4 -1
  32. package/dist/components/config-provider/index.d.vue.ts +1 -0
  33. package/dist/components/config-provider/index.vue +2 -1
  34. package/dist/components/countdown/index.vue +2 -10
  35. package/dist/components/dash-line/index.vue +22 -16
  36. package/dist/components/description/index.vue +4 -2
  37. package/dist/components/drawer/index.vue +19 -11
  38. package/dist/components/empty-state/index.vue +3 -1
  39. package/dist/components/error/cn.d.ts +22 -0
  40. package/dist/components/error/cn.js +15 -0
  41. package/dist/components/error/index.vue +13 -14
  42. package/dist/components/fader/index.vue +30 -14
  43. package/dist/components/gauge/index.vue +6 -6
  44. package/dist/components/grid/index.vue +16 -12
  45. package/dist/components/grid-item/index.vue +4 -4
  46. package/dist/components/hold-button/index.vue +19 -13
  47. package/dist/components/input/cn.d.ts +73 -0
  48. package/dist/components/input/cn.js +36 -0
  49. package/dist/components/input/index.d.vue.ts +14 -16
  50. package/dist/components/input/index.vue +74 -101
  51. package/dist/components/intersection-observer/index.vue +7 -3
  52. package/dist/components/kbd/index.vue +2 -2
  53. package/dist/components/link-button/index.d.vue.ts +8 -8
  54. package/dist/components/link-button/index.vue +17 -25
  55. package/dist/components/list/index.d.vue.ts +0 -1
  56. package/dist/components/list/index.vue +58 -57
  57. package/dist/components/list-item/cn.d.ts +22 -0
  58. package/dist/components/list-item/cn.js +15 -0
  59. package/dist/components/list-item/index.d.vue.ts +3 -3
  60. package/dist/components/list-item/index.vue +14 -25
  61. package/dist/components/loading-bar/cn.d.ts +70 -0
  62. package/dist/components/loading-bar/cn.js +32 -0
  63. package/dist/components/loading-bar/index.d.vue.ts +2 -0
  64. package/dist/components/loading-bar/index.vue +68 -61
  65. package/dist/components/loading-dots/index.vue +12 -4
  66. package/dist/components/menu/index.d.vue.ts +2 -2
  67. package/dist/components/menu/index.vue +4 -4
  68. package/dist/components/message/index.vue +82 -48
  69. package/dist/components/message-item/index.vue +7 -2
  70. package/dist/components/modal/index.vue +20 -12
  71. package/dist/components/more-button/index.d.vue.ts +1 -3
  72. package/dist/components/more-button/index.vue +7 -17
  73. package/dist/components/note/cn.d.ts +121 -0
  74. package/dist/components/note/cn.js +66 -0
  75. package/dist/components/note/index.d.vue.ts +3 -39
  76. package/dist/components/note/index.vue +18 -37
  77. package/dist/components/number-input/index.d.vue.ts +19 -10
  78. package/dist/components/number-input/index.vue +121 -75
  79. package/dist/components/overlay/index.vue +4 -20
  80. package/dist/components/pagination/index.vue +25 -8
  81. package/dist/components/pin-input/cn.d.ts +46 -0
  82. package/dist/components/pin-input/cn.js +25 -0
  83. package/dist/components/pin-input/index.vue +11 -20
  84. package/dist/components/placeholder/index.vue +11 -4
  85. package/dist/components/popover/index.d.vue.ts +4 -3
  86. package/dist/components/popover/index.vue +107 -54
  87. package/dist/components/progress/cn.d.ts +19 -0
  88. package/dist/components/progress/cn.js +14 -0
  89. package/dist/components/progress/index.d.vue.ts +1 -1
  90. package/dist/components/progress/index.vue +21 -14
  91. package/dist/components/radio/cn.d.ts +46 -0
  92. package/dist/components/radio/cn.js +42 -0
  93. package/dist/components/radio/index.vue +11 -18
  94. package/dist/components/resizable/index.vue +8 -2
  95. package/dist/components/resizable-handle/index.vue +1 -0
  96. package/dist/components/resizable-panel/index.vue +12 -11
  97. package/dist/components/skeleton/cn.d.ts +43 -0
  98. package/dist/components/skeleton/cn.js +24 -0
  99. package/dist/components/skeleton/index.d.vue.ts +4 -3
  100. package/dist/components/skeleton/index.vue +11 -20
  101. package/dist/components/slider/index.d.vue.ts +1 -1
  102. package/dist/components/slider/index.vue +14 -12
  103. package/dist/components/snippet/cn.d.ts +52 -0
  104. package/dist/components/snippet/cn.js +27 -0
  105. package/dist/components/snippet/index.vue +21 -29
  106. package/dist/components/spinner/index.vue +3 -1
  107. package/dist/components/stack/cn.d.ts +70 -0
  108. package/dist/components/stack/cn.js +33 -0
  109. package/dist/components/stack/index.d.vue.ts +2 -2
  110. package/dist/components/stack/index.vue +16 -31
  111. package/dist/components/status-dot/index.vue +5 -1
  112. package/dist/components/switch/cn.d.ts +16 -0
  113. package/dist/components/switch/cn.js +13 -0
  114. package/dist/components/switch/index.vue +5 -11
  115. package/dist/components/switch-group/index.vue +7 -4
  116. package/dist/components/text/cn.d.ts +67 -0
  117. package/dist/components/text/cn.js +34 -0
  118. package/dist/components/text/index.d.vue.ts +1 -1
  119. package/dist/components/text/index.vue +16 -25
  120. package/dist/components/textarea/cn.d.ts +58 -0
  121. package/dist/components/textarea/cn.js +30 -0
  122. package/dist/components/textarea/index.d.vue.ts +2 -0
  123. package/dist/components/textarea/index.vue +17 -24
  124. package/dist/components/theme-switcher/index.vue +6 -3
  125. package/dist/components/time-picker/index.d.vue.ts +2 -2
  126. package/dist/components/time-picker/index.vue +45 -25
  127. package/dist/components/toggle/index.vue +10 -6
  128. package/dist/components/tooltip/index.vue +3 -3
  129. package/dist/components/virtual-list/index.vue +1 -7
  130. package/dist/composables/use-browser-observer.d.ts +1 -1
  131. package/dist/composables/use-browser-observer.js +19 -15
  132. package/dist/composables/use-config-provider-context.d.ts +1 -0
  133. package/dist/composables/use-config-provider-context.js +5 -10
  134. package/dist/composables/use-countdown.js +1 -3
  135. package/dist/composables/use-deferred-value.js +1 -5
  136. package/dist/composables/use-delay-change.js +1 -4
  137. package/dist/composables/use-delay-destroy.js +1 -5
  138. package/dist/composables/use-loading-bar.d.ts +6 -14
  139. package/dist/composables/use-loading-bar.js +3 -14
  140. package/dist/composables/use-message.d.ts +9 -3
  141. package/dist/composables/use-message.js +9 -9
  142. package/dist/composables/use-model-value.d.ts +1 -0
  143. package/dist/composables/use-model-value.js +4 -2
  144. package/dist/composables/use-outside-click.js +12 -8
  145. package/dist/composables/use-pointer-gesture.js +5 -1
  146. package/dist/composables/use-toggle-value.js +1 -4
  147. package/dist/composables/use-virtual-list.js +14 -7
  148. package/dist/contexts/avatar.js +4 -4
  149. package/dist/contexts/carousel.js +1 -4
  150. package/dist/contexts/checkbox.js +1 -4
  151. package/dist/contexts/choicebox.js +2 -8
  152. package/dist/contexts/collapse.js +1 -4
  153. package/dist/contexts/list.js +5 -8
  154. package/dist/contexts/radio.js +4 -4
  155. package/dist/contexts/resizable.js +1 -4
  156. package/dist/contexts/switch.js +2 -8
  157. package/dist/index.d.ts +1 -0
  158. package/dist/styles/source.css +106 -59
  159. package/dist/styles/styles.css +1 -1
  160. package/dist/styles/tw.css +106 -59
  161. package/dist/types/components/avatar.d.ts +2 -2
  162. package/dist/types/components/button.d.ts +11 -4
  163. package/dist/types/components/index.d.ts +12 -0
  164. package/dist/types/components/input.d.ts +4 -5
  165. package/dist/types/components/list.d.ts +1 -1
  166. package/dist/types/components/switch.d.ts +1 -1
  167. package/dist/types/shared/props.d.ts +6 -4
  168. package/dist/types/shared/utils.d.ts +3 -1
  169. package/dist/utils/context.d.ts +2 -8
  170. package/dist/utils/date.d.ts +1 -1
  171. package/dist/utils/date.js +1 -5
  172. package/dist/utils/event.js +6 -18
  173. package/dist/utils/format.d.ts +1 -1
  174. package/dist/utils/format.js +1 -1
  175. package/dist/utils/is.d.ts +0 -1
  176. package/dist/utils/is.js +3 -2
  177. package/dist/utils/responsive.js +7 -4
  178. package/dist/utils/throttle.js +4 -2
  179. package/package.json +45 -43
  180. package/dist/components/_internal/fragment-container.vue.d.ts +0 -13
  181. package/dist/components/active-graph/index.vue.d.ts +0 -51
  182. package/dist/components/avatar/index.vue.d.ts +0 -34
  183. package/dist/components/avatar-group/index.vue.d.ts +0 -8
  184. package/dist/components/backtop/index.vue.d.ts +0 -21
  185. package/dist/components/badge/index.vue.d.ts +0 -52
  186. package/dist/components/book/index.vue.d.ts +0 -28
  187. package/dist/components/browser/index.vue.d.ts +0 -16
  188. package/dist/components/button/index.vue.d.ts +0 -29
  189. package/dist/components/carousel/index.vue.d.ts +0 -13
  190. package/dist/components/carousel-group/index.vue.d.ts +0 -35
  191. package/dist/components/checkbox/index.vue.d.ts +0 -26
  192. package/dist/components/checkbox-group/index.vue.d.ts +0 -28
  193. package/dist/components/chip/index.vue.d.ts +0 -24
  194. package/dist/components/choicebox/index.vue.d.ts +0 -16
  195. package/dist/components/choicebox-group/index.vue.d.ts +0 -24
  196. package/dist/components/collapse/index.vue.d.ts +0 -22
  197. package/dist/components/collapse-group/index.vue.d.ts +0 -20
  198. package/dist/components/command-menu/index.vue.d.ts +0 -42
  199. package/dist/components/command-menu-group/index.vue.d.ts +0 -17
  200. package/dist/components/command-menu-item/index.vue.d.ts +0 -13
  201. package/dist/components/config-provider/index.vue.d.ts +0 -22
  202. package/dist/components/countdown/index.vue.d.ts +0 -51
  203. package/dist/components/dash-line/index.vue.d.ts +0 -13
  204. package/dist/components/description/index.vue.d.ts +0 -20
  205. package/dist/components/drawer/index.vue.d.ts +0 -60
  206. package/dist/components/empty-state/index.vue.d.ts +0 -23
  207. package/dist/components/error/index.vue.d.ts +0 -22
  208. package/dist/components/fader/index.vue.d.ts +0 -12
  209. package/dist/components/gauge/index.vue.d.ts +0 -14
  210. package/dist/components/grid/index.vue.d.ts +0 -19
  211. package/dist/components/grid-item/index.vue.d.ts +0 -18
  212. package/dist/components/hold-button/index.vue.d.ts +0 -42
  213. package/dist/components/input/index.vue.d.ts +0 -55
  214. package/dist/components/intersection-observer/index.vue.d.ts +0 -39
  215. package/dist/components/kbd/index.vue.d.ts +0 -24
  216. package/dist/components/label/index.vue.d.ts +0 -13
  217. package/dist/components/link-button/index.vue.d.ts +0 -33
  218. package/dist/components/list/index.vue.d.ts +0 -44
  219. package/dist/components/list-item/index.vue.d.ts +0 -29
  220. package/dist/components/loading-bar/index.vue.d.ts +0 -15
  221. package/dist/components/loading-dots/index.vue.d.ts +0 -15
  222. package/dist/components/material/index.vue.d.ts +0 -18
  223. package/dist/components/menu/index.vue.d.ts +0 -33
  224. package/dist/components/message/index.vue.d.ts +0 -176
  225. package/dist/components/message-item/index.vue.d.ts +0 -15
  226. package/dist/components/modal/index.vue.d.ts +0 -58
  227. package/dist/components/more-button/index.vue.d.ts +0 -20
  228. package/dist/components/noise-background/index.vue.d.ts +0 -19
  229. package/dist/components/note/index.vue.d.ts +0 -64
  230. package/dist/components/number-input/index.vue.d.ts +0 -39
  231. package/dist/components/overlay/index.vue.d.ts +0 -35
  232. package/dist/components/pagination/index.vue.d.ts +0 -21
  233. package/dist/components/pin-input/index.vue.d.ts +0 -28
  234. package/dist/components/placeholder/index.vue.d.ts +0 -18
  235. package/dist/components/popover/index.vue.d.ts +0 -73
  236. package/dist/components/progress/index.vue.d.ts +0 -34
  237. package/dist/components/radio/index.vue.d.ts +0 -20
  238. package/dist/components/radio-group/index.vue.d.ts +0 -22
  239. package/dist/components/resizable/index.vue.d.ts +0 -19
  240. package/dist/components/resizable-handle/index.vue.d.ts +0 -3
  241. package/dist/components/resizable-panel/index.vue.d.ts +0 -20
  242. package/dist/components/scrollable/index.vue.d.ts +0 -0
  243. package/dist/components/skeleton/index.vue.d.ts +0 -26
  244. package/dist/components/slider/index.vue.d.ts +0 -26
  245. package/dist/components/snippet/index.vue.d.ts +0 -18
  246. package/dist/components/spinner/index.vue.d.ts +0 -3
  247. package/dist/components/stack/index.vue.d.ts +0 -30
  248. package/dist/components/status-dot/index.vue.d.ts +0 -11
  249. package/dist/components/switch/index.vue.d.ts +0 -20
  250. package/dist/components/switch-group/index.vue.d.ts +0 -23
  251. package/dist/components/teleport/index.vue.d.ts +0 -21
  252. package/dist/components/text/index.vue.d.ts +0 -26
  253. package/dist/components/textarea/index.vue.d.ts +0 -28
  254. package/dist/components/theme-switcher/index.vue.d.ts +0 -8
  255. package/dist/components/time-picker/index.vue.d.ts +0 -35
  256. package/dist/components/toggle/index.vue.d.ts +0 -41
  257. package/dist/components/tooltip/index.vue.d.ts +0 -32
  258. package/dist/components/virtual-list/index.vue.d.ts +0 -24
@@ -1,6 +1,8 @@
1
1
  import type { InputProps } from '../../types/components/input';
2
- declare function setNativeInputValue(value: any): void;
3
- declare function clearValue(): void;
2
+ declare function blur(): void;
3
+ declare function focus(): void;
4
+ declare function select(): void;
5
+ declare function clear(): void;
4
6
  declare var __VLS_1: {}, __VLS_18: {};
5
7
  type __VLS_Slots = {} & {
6
8
  prefix?: (props: typeof __VLS_1) => any;
@@ -8,40 +10,36 @@ type __VLS_Slots = {} & {
8
10
  suffix?: (props: typeof __VLS_18) => any;
9
11
  };
10
12
  declare const __VLS_base: import("vue").DefineComponent<InputProps, {
11
- blur: () => void | undefined;
12
- focus: () => void | undefined;
13
- select: () => void | undefined;
14
- clear: typeof clearValue;
15
- setInputValue: typeof setNativeInputValue;
13
+ blur: typeof blur;
14
+ clear: typeof clear;
15
+ focus: typeof focus;
16
+ select: typeof select;
16
17
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
17
18
  input: (args_0: string) => any;
18
- click: (args_0: MouseEvent) => any;
19
- clear: (args_0: string) => any;
20
19
  blur: (args_0: FocusEvent) => any;
21
- change: (args_0: string) => any;
20
+ change: (args_0: string, args_1: Event) => any;
21
+ click: (args_0: MouseEvent) => any;
22
22
  compositionend: (args_0: CompositionEvent) => any;
23
23
  compositionstart: (args_0: CompositionEvent) => any;
24
24
  compositionupdate: (args_0: CompositionEvent) => any;
25
25
  focus: (args_0: FocusEvent) => any;
26
26
  keydown: (args_0: KeyboardEvent) => any;
27
+ clear: (args_0: string) => any;
27
28
  "update:modelValue": (args_0: string) => any;
28
29
  }, string, import("vue").PublicProps, Readonly<InputProps> & Readonly<{
29
30
  onInput?: ((args_0: string) => any) | undefined;
30
- onClick?: ((args_0: MouseEvent) => any) | undefined;
31
- onClear?: ((args_0: string) => any) | undefined;
32
31
  onBlur?: ((args_0: FocusEvent) => any) | undefined;
33
- onChange?: ((args_0: string) => any) | undefined;
32
+ onChange?: ((args_0: string, args_1: Event) => any) | undefined;
33
+ onClick?: ((args_0: MouseEvent) => any) | undefined;
34
34
  onCompositionend?: ((args_0: CompositionEvent) => any) | undefined;
35
35
  onCompositionstart?: ((args_0: CompositionEvent) => any) | undefined;
36
36
  onCompositionupdate?: ((args_0: CompositionEvent) => any) | undefined;
37
37
  onFocus?: ((args_0: FocusEvent) => any) | undefined;
38
38
  onKeydown?: ((args_0: KeyboardEvent) => any) | undefined;
39
+ onClear?: ((args_0: string) => any) | undefined;
39
40
  "onUpdate:modelValue"?: ((args_0: string) => any) | undefined;
40
41
  }>, {
41
42
  align: "left" | "center" | "right";
42
- error: boolean | string;
43
- placeholder: string;
44
- modelValue: import("../../types/shared").ComponentLabel;
45
43
  prefixStyle: boolean;
46
44
  suffixStyle: boolean;
47
45
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -2,13 +2,13 @@
2
2
  import CrossIcon from "@gdsicon/vue/cross";
3
3
  import EyeIcon from "@gdsicon/vue/eye";
4
4
  import EyeOffIcon from "@gdsicon/vue/eye-off";
5
- import { computed, nextTick, onMounted, shallowRef, watch } from "vue";
5
+ import { computed, shallowRef } from "vue";
6
6
  import { useConfigProvider } from "../../composables/use-config-provider-context";
7
7
  import { useModelValue } from "../../composables/use-model-value";
8
8
  import { NOOP } from "../../utils/event";
9
9
  import { isTruthyProp } from "../../utils/format";
10
- import { getFallbackValue } from "../../utils/get";
11
10
  import { getUniqueId } from "../../utils/uid";
11
+ import { inputVariant } from "./cn";
12
12
  defineOptions({
13
13
  name: "PInput",
14
14
  inheritAttrs: false,
@@ -19,11 +19,10 @@ defineOptions({
19
19
  });
20
20
  const props = defineProps({
21
21
  size: { type: String, required: false },
22
- error: { type: [Boolean, String], required: false, default: false },
22
+ error: { type: [Boolean, String], required: false },
23
23
  min: { type: [Number, String], required: false },
24
24
  max: { type: [Number, String], required: false },
25
25
  align: { type: String, required: false, default: "left" },
26
- label: { type: [String, Number, Array, null], required: false },
27
26
  readonly: { type: Boolean, required: false },
28
27
  disabled: { type: Boolean, required: false },
29
28
  password: { type: Boolean, required: false },
@@ -34,66 +33,34 @@ const props = defineProps({
34
33
  minlength: { type: [Number, String], required: false },
35
34
  maxlength: { type: [Number, String], required: false },
36
35
  clearable: { type: Boolean, required: false },
37
- modelValue: { type: [String, Number, Array, null], required: false, default: "" },
38
- placeholder: { type: String, required: false, default: "" },
36
+ clearValue: { type: null, required: false },
37
+ modelValue: { type: null, required: false },
38
+ placeholder: { type: String, required: false },
39
39
  prefixStyle: { type: Boolean, required: false, default: true },
40
40
  suffixStyle: { type: Boolean, required: false, default: true },
41
41
  prefixClass: { type: null, required: false },
42
42
  suffixClass: { type: null, required: false },
43
- selectOnFocus: { type: Boolean, required: false },
44
- parser: { type: Function, required: false },
45
- formatter: { type: Function, required: false }
43
+ selectOnFocus: { type: Boolean, required: false }
46
44
  });
47
45
  const emits = defineEmits(["click", "clear", "input", "change", "focus", "blur", "keydown", "update:modelValue", "compositionstart", "compositionupdate", "compositionend"]);
48
- const SIZES = {
49
- xs: "h-6 text-xs rounded-sm",
50
- sm: "h-7.5 text-sm rounded-md",
51
- md: "h-9 text-sm rounded-md",
52
- lg: "h-10 text-base rounded-lg"
53
- };
54
- const ALIGN = {
55
- left: "text-left",
56
- center: "text-center",
57
- right: "text-right"
58
- };
59
46
  const uniqueId = getUniqueId();
60
47
  const inputRef = shallowRef();
61
- const config = useConfigProvider();
62
- const computedModelValue = useModelValue(props, emits);
48
+ const configProvider = useConfigProvider();
49
+ const modelValue = useModelValue(props, emits, { withChange: false });
63
50
  const isComposing = shallowRef(false);
64
51
  const isPasswordVisible = shallowRef(!props.password);
65
- const internalInputType = computed(() => props.inputType || isPasswordVisible.value ? "text" : "password");
66
- const computedClass = computed(() => {
67
- const classes = [];
68
- classes.push(getFallbackValue(props.size, SIZES, config.size), props.align && ALIGN[props.align]);
69
- if (isTruthyProp(props.disabled)) {
70
- classes.push("is-disabled");
71
- }
72
- if (isTruthyProp(props.readonly)) {
73
- classes.push("is-readonly");
74
- }
75
- if (props.error) {
76
- classes.push("is-error");
77
- }
78
- return classes.join(" ");
52
+ const inputType = computed(() => props.inputType || isPasswordVisible.value ? "text" : "password");
53
+ const computedClasses = computed(() => {
54
+ return inputVariant({
55
+ size: props.size || configProvider.size,
56
+ align: props.align,
57
+ error: isTruthyProp(props.error),
58
+ disabled: isTruthyProp(props.disabled),
59
+ readonly: isTruthyProp(props.readonly)
60
+ });
79
61
  });
80
- function getValueFromEvent(ev) {
81
- let { value } = ev.target;
82
- if (props.parser) {
83
- value = props.parser(value);
84
- }
85
- return value;
86
- }
87
- function getFormattedValue(value) {
88
- return typeof props.formatter === "function" ? props.formatter(value) : value;
89
- }
90
- function setNativeInputValue(value) {
91
- const input = inputRef.value;
92
- const formatterValue = getFormattedValue(value);
93
- if (input == null || input.value === formatterValue) {
94
- return;
95
- }
96
- input.value = formatterValue;
62
+ function getInputValue(ev) {
63
+ return ev.target.value;
97
64
  }
98
65
  function onFocus(event) {
99
66
  if (props.selectOnFocus) {
@@ -104,24 +71,29 @@ function onFocus(event) {
104
71
  function onBlur(event) {
105
72
  emits("blur", event);
106
73
  }
107
- function onChange(event) {
108
- emits("change", getValueFromEvent(event));
109
- }
110
74
  function onClick(event) {
111
75
  emits("click", event);
112
76
  }
77
+ function onChange(event) {
78
+ const inputValue = getInputValue(event);
79
+ emits("change", inputValue, event);
80
+ }
113
81
  async function onInput(event) {
114
82
  const ev = event;
115
83
  if (ev.isComposing || isComposing.value) {
116
84
  return;
117
85
  }
118
- const value = getValueFromEvent(event);
119
- computedModelValue.value = value;
120
- emits("input", value);
121
- await nextTick();
122
- setNativeInputValue(value);
86
+ const inputValue = getInputValue(event);
87
+ modelValue.value = inputValue;
88
+ emits("input", inputValue);
123
89
  }
124
90
  function onKeydown(event) {
91
+ if (props.readonly) {
92
+ return;
93
+ }
94
+ if (event.key === "Enter") {
95
+ onChange(event);
96
+ }
125
97
  emits("keydown", event);
126
98
  }
127
99
  function onCompositionStart(event) {
@@ -133,56 +105,53 @@ function onCompositionUpdate(event) {
133
105
  emits("compositionupdate", event);
134
106
  }
135
107
  async function onCompositionEnd(event) {
136
- if (isComposing.value) {
137
- const value = getValueFromEvent(event);
138
- computedModelValue.value = value;
139
- isComposing.value = false;
140
- }
108
+ isComposing.value = false;
141
109
  emits("compositionend", event);
142
- await nextTick();
143
- setNativeInputValue(getValueFromEvent(event));
110
+ const inputValue = getInputValue(event);
111
+ modelValue.value = inputValue;
112
+ emits("input", inputValue);
144
113
  }
145
114
  function toggleType() {
146
115
  isPasswordVisible.value = !isPasswordVisible.value;
147
116
  }
148
- function clearValue() {
149
- emits("clear", "");
150
- setNativeInputValue("");
151
- computedModelValue.value = "";
117
+ function blur() {
118
+ inputRef.value?.blur();
119
+ }
120
+ function focus() {
121
+ inputRef.value?.focus();
122
+ }
123
+ function select() {
124
+ inputRef.value?.select();
125
+ }
126
+ function clear() {
127
+ const clearValue = props.clearValue ?? "";
128
+ emits("clear", clearValue);
129
+ modelValue.value = clearValue;
152
130
  }
153
- const blur = () => inputRef.value?.blur();
154
- const focus = () => inputRef.value?.focus();
155
- const select = () => inputRef.value?.select();
156
- watch(() => props.modelValue, (value) => {
157
- setNativeInputValue(getFormattedValue(value));
158
- });
159
- onMounted(async () => {
160
- await nextTick();
161
- setNativeInputValue(getFormattedValue(computedModelValue.value));
162
- });
163
131
  defineExpose({
164
132
  blur,
133
+ clear,
165
134
  focus,
166
- select,
167
- clear: clearValue,
168
- setInputValue: setNativeInputValue
135
+ select
169
136
  });
170
137
  </script>
171
138
 
172
139
  <template>
173
140
  <label
174
- class="pxd-input pxd-input--border group relative flex w-full max-w-full items-center overflow-hidden bg-background-100 data-[disabled=true]:cursor-not-allowed data-[disabled=true]:bg-gray-100 motion-safe:transition-all"
175
141
  :for="uniqueId"
176
142
  :data-disabled="disabled"
177
- :class="computedClass"
143
+ :class="computedClasses"
178
144
  v-bind="$attrs"
179
145
  @click="onClick"
180
146
  @dragstart.prevent="NOOP"
181
147
  >
182
148
  <div
183
149
  v-if="$slots.prefix"
184
- class="pxd-input--prefix text-sm pl-3 flex h-full items-center text-foreground-secondary"
185
- :class="[{ 'pr-3 rounded-l-inherit border-r border-gray-300 bg-background-200': prefixStyle }, prefixClass]"
150
+ class="pxd-input--prefix text-sm flex h-full items-center text-foreground-secondary"
151
+ :class="[
152
+ { 'px-3 rounded-l-inherit border-r border-gray-300 bg-background-200': prefixStyle },
153
+ prefixClass
154
+ ]"
186
155
  @pointerdown.prevent="NOOP"
187
156
  >
188
157
  <slot name="prefix" />
@@ -191,13 +160,14 @@ defineExpose({
191
160
  <input
192
161
  :id="uniqueId"
193
162
  ref="inputRef"
194
- class="px-3 py-0 size-full appearance-none rounded-inherit border-none bg-transparent [text-align:inherit] font-inherit outline-none select-auto file:font-medium file:border-0 file:bg-transparent placeholder:text-gray-600 placeholder:select-none read-only:cursor-default disabled:cursor-not-allowed disabled:text-gray-700 disabled:placeholder:text-gray-500"
195
- :type="internalInputType"
196
- :min="min"
197
- :max="max"
163
+ class="px-3 py-0 file:font-medium size-full appearance-none rounded-inherit border-none bg-transparent [text-align:inherit] font-inherit outline-none select-auto file:border-0 file:bg-transparent placeholder:text-gray-600 placeholder:select-none read-only:cursor-default disabled:cursor-not-allowed disabled:text-gray-700 disabled:placeholder:text-gray-500"
198
164
  autocorrect="off"
199
165
  autocomplete="off"
200
166
  autocapitalize="off"
167
+ :min="min"
168
+ :max="max"
169
+ :type="inputType"
170
+ :value="modelValue"
201
171
  :readonly="readonly"
202
172
  :disabled="disabled"
203
173
  :required="required"
@@ -205,9 +175,8 @@ defineExpose({
205
175
  :minlength="minlength"
206
176
  :maxlength="maxlength"
207
177
  :autofocus="autofocus"
208
- :placeholder="placeholder"
209
178
  :aria-disabled="disabled"
210
- :data-value="computedModelValue"
179
+ :placeholder="placeholder"
211
180
  @blur="onBlur"
212
181
  @focus="onFocus"
213
182
  @input="onInput"
@@ -216,13 +185,14 @@ defineExpose({
216
185
  @compositionstart="onCompositionStart"
217
186
  @compositionupdate="onCompositionUpdate"
218
187
  @compositionend="onCompositionEnd"
219
- >
188
+ />
220
189
 
221
190
  <div
222
191
  v-if="password || clearable"
223
- v-show="computedModelValue"
192
+ v-show="modelValue"
224
193
  :class="{ 'pr-2': password && clearable }"
225
- class="pxd-input--icon right-0 top-0 gap-1 flex aspect-square h-full cursor-pointer items-center justify-center rounded-r-inherit text-foreground-secondary"
194
+ class="pxd-input--icon top-0 right-0 gap-1 flex aspect-square h-full cursor-pointer items-center justify-center rounded-r-inherit text-foreground-secondary"
195
+ @pointerdown.prevent="NOOP"
226
196
  >
227
197
  <button
228
198
  v-if="password"
@@ -235,7 +205,7 @@ defineExpose({
235
205
  <button
236
206
  v-if="clearable"
237
207
  class="p-1 appearance-none rounded-sm font-inherit self-focus-ring outline-none hover:bg-background-hover hover:text-foreground active:bg-background-active motion-safe:transition-colors"
238
- @click.stop.prevent="clearValue"
208
+ @click.stop.prevent="clear"
239
209
  >
240
210
  <CrossIcon class="size-3 pointer-events-none" />
241
211
  </button>
@@ -243,8 +213,11 @@ defineExpose({
243
213
 
244
214
  <div
245
215
  v-if="$slots.suffix"
246
- class="pxd-input--suffix text-sm pr-3 flex h-full items-center text-foreground-secondary"
247
- :class="[{ 'pl-3 rounded-r-inherit border-l border-gray-300 bg-background-200': suffixStyle }, suffixClass]"
216
+ class="pxd-input--suffix text-sm flex h-full items-center text-foreground-secondary"
217
+ :class="[
218
+ { 'px-3 rounded-r-inherit border-l border-gray-300 bg-background-200': suffixStyle },
219
+ suffixClass
220
+ ]"
248
221
  @pointerdown.prevent="NOOP"
249
222
  >
250
223
  <slot name="suffix" />
@@ -45,9 +45,13 @@ function onVisibleChange(isIntersecting) {
45
45
  }
46
46
  emits("visible-change", isIntersecting);
47
47
  }
48
- useIntersectionObserver(containerRef, ([entry]) => {
49
- onVisibleChange(entry.isIntersecting);
50
- }, props);
48
+ useIntersectionObserver(
49
+ containerRef,
50
+ ([entry]) => {
51
+ onVisibleChange(entry.isIntersecting);
52
+ },
53
+ props
54
+ );
51
55
  </script>
52
56
 
53
57
  <template>
@@ -27,8 +27,8 @@ const INTERNAL_KEYS = {
27
27
  ctrl: "Ctrl",
28
28
  enter: "\u21B5"
29
29
  };
30
- const config = useConfigProvider();
31
- const computedSize = computed(() => getFallbackValue(props.size, SIZES, config.size));
30
+ const configProvider = useConfigProvider();
31
+ const computedSize = computed(() => getFallbackValue(props.size, SIZES, configProvider.size));
32
32
  const internalKey = computed(() => {
33
33
  return Object.entries(INTERNAL_KEYS).filter(([k]) => {
34
34
  return props[k];
@@ -1,27 +1,27 @@
1
+ import type { ButtonVariant } from '../../types/components/button';
1
2
  interface Props {
2
3
  href: string;
3
4
  text?: string;
4
- type?: 'button' | 'text';
5
5
  align?: 'left' | 'center' | 'right';
6
- target?: '_blank' | '_self' | '_parent' | '_top';
6
+ target?: HTMLAnchorElement['target'];
7
+ variant?: ButtonVariant;
7
8
  externalIcon?: boolean;
8
9
  }
9
- declare var __VLS_11: {}, __VLS_13: {}, __VLS_16: {};
10
+ declare var __VLS_9: {}, __VLS_11: {}, __VLS_14: {};
10
11
  type __VLS_Slots = {} & {
11
- prefix?: (props: typeof __VLS_11) => any;
12
+ prefix?: (props: typeof __VLS_9) => any;
12
13
  } & {
13
- default?: (props: typeof __VLS_13) => any;
14
+ default?: (props: typeof __VLS_11) => any;
14
15
  } & {
15
- suffix?: (props: typeof __VLS_16) => any;
16
+ suffix?: (props: typeof __VLS_14) => any;
16
17
  };
17
18
  declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
18
19
  click: (args_0: MouseEvent) => any;
19
20
  }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
20
21
  onClick?: ((args_0: MouseEvent) => any) | undefined;
21
22
  }>, {
22
- type: "button" | "text";
23
23
  align: "left" | "center" | "right";
24
- target: "_blank" | "_self" | "_parent" | "_top";
24
+ target: HTMLAnchorElement["target"];
25
25
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
26
26
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
27
27
  declare const _default: typeof __VLS_export;
@@ -9,39 +9,36 @@ defineOptions({
9
9
  const props = defineProps({
10
10
  href: { type: String, required: true },
11
11
  text: { type: String, required: false },
12
- type: { type: String, required: false, default: "button" },
13
12
  align: { type: String, required: false, default: "left" },
14
- target: { type: String, required: false, default: "_self" },
13
+ target: { type: null, required: false, default: "_self" },
14
+ variant: { type: String, required: false },
15
15
  externalIcon: { type: Boolean, required: false }
16
16
  });
17
17
  const emits = defineEmits(["click"]);
18
18
  const attrs = useAttrs();
19
- const computedClass = computed(() => {
20
- const classes = ["pxd-link-button"];
21
- if (props.type === "text") {
22
- classes.push("font-medium hover:underline hover:opacity-70 active:opacity-90 motion-safe:transition-opacity");
23
- }
24
- return classes.join(" ");
25
- });
26
- const computedAttrs = computed(() => {
27
- const { href, target, type } = props;
19
+ const linkButtonAttrs = computed(() => {
20
+ const { externalIcon, text, href, ...restProps } = props;
21
+ const baseAttrs = {
22
+ ...attrs,
23
+ ...restProps,
24
+ class: "pxd-link-button",
25
+ rel: "noopener noreferrer",
26
+ onClick: onLinkClick
27
+ };
28
28
  if (!href) {
29
- return null;
29
+ return baseAttrs;
30
30
  }
31
- const variant = type === "text" ? "simple" : attrs.variant || "default";
32
31
  if (isExternalLink(href)) {
33
32
  return {
33
+ ...baseAttrs,
34
34
  as: "a",
35
- href,
36
- target,
37
- variant,
38
- rel: "noopener noreferrer"
35
+ href
39
36
  };
40
37
  }
41
38
  return {
39
+ ...baseAttrs,
42
40
  as: "router-link",
43
- to: href,
44
- variant
41
+ to: href
45
42
  };
46
43
  });
47
44
  function onLinkClick(ev) {
@@ -50,12 +47,7 @@ function onLinkClick(ev) {
50
47
  </script>
51
48
 
52
49
  <template>
53
- <PButton
54
- :align="align"
55
- :class="computedClass"
56
- v-bind="computedAttrs"
57
- @click="onLinkClick"
58
- >
50
+ <PButton v-bind="linkButtonAttrs">
59
51
  <template #prefix>
60
52
  <slot name="prefix" />
61
53
  </template>
@@ -1,7 +1,6 @@
1
1
  import type { ListOption, ListOptionSelected } from '../../types/components/list';
2
2
  interface Props {
3
3
  loop?: boolean;
4
- width?: string | number;
5
4
  options?: ListOption[];
6
5
  keyListener?: boolean;
7
6
  itemTransition?: boolean;
@@ -2,7 +2,6 @@
2
2
  import { nextTick, onBeforeUnmount, onMounted, shallowRef } from "vue";
3
3
  import { provideListContext } from "../../contexts/list";
4
4
  import { cachedOff, cachedOn } from "../../utils/event";
5
- import { getCssUnitValue } from "../../utils/format";
6
5
  import { isServer } from "../../utils/is";
7
6
  import { throttle } from "../../utils/throttle";
8
7
  import PListItem from "../list-item/index.vue";
@@ -13,7 +12,6 @@ defineOptions({
13
12
  });
14
13
  const props = defineProps({
15
14
  loop: { type: Boolean, required: false, default: true },
16
- width: { type: [String, Number], required: false },
17
15
  options: { type: Array, required: false, default: () => [] },
18
16
  keyListener: { type: Boolean, required: false, default: true },
19
17
  itemTransition: { type: Boolean, required: false, default: true },
@@ -30,62 +28,66 @@ const FUNCTION_KEYS = ["Enter", "Tab", "Home", "End"];
30
28
  const PREVENT_DEFAULT_KEYS = [...FUNCTION_KEYS, ...PREV_KEYS, ...NEXT_KEYS];
31
29
  const listItemKeys = [];
32
30
  const listItemsMap = /* @__PURE__ */ new Map();
33
- const containerKeydownThrottled = throttle((ev) => {
34
- if (ev.ctrlKey || ev.metaKey || ev.altKey || ev.shiftKey) {
35
- return;
36
- }
37
- const { key } = ev;
38
- if (key === "Tab") {
39
- return;
40
- }
41
- if (key === "Enter") {
42
- listItemsMap.get(activeValue.value)?.click();
43
- return;
44
- }
45
- if (key === "Escape" && props.closeOnPressEscape) {
46
- emits("escape", ev);
47
- return;
48
- }
49
- let newActiveValue = "";
50
- const listItemKeyLength = listItemKeys.length;
51
- if (PREV_KEYS.includes(key)) {
52
- if (activeValue.value) {
53
- const index = listItemKeys.indexOf(activeValue.value);
54
- if (props.loop) {
55
- const prevIndex = (index - 1 + listItemKeys.length) % listItemKeys.length;
56
- newActiveValue = listItemKeys[prevIndex];
57
- } else if (index > 0) {
58
- newActiveValue = listItemKeys[index - 1];
59
- }
60
- } else {
61
- newActiveValue = listItemKeys[listItemKeyLength - 1];
31
+ const containerKeydownThrottled = throttle(
32
+ (ev) => {
33
+ if (ev.ctrlKey || ev.metaKey || ev.altKey || ev.shiftKey) {
34
+ return;
35
+ }
36
+ const { key } = ev;
37
+ if (key === "Tab") {
38
+ return;
62
39
  }
63
- } else if (NEXT_KEYS.includes(key)) {
64
- if (activeValue.value) {
65
- const index = listItemKeys.indexOf(activeValue.value);
66
- if (props.loop) {
67
- const nextIndex = (index + 1) % listItemKeys.length;
68
- newActiveValue = listItemKeys[nextIndex];
69
- } else if (index < listItemKeys.length - 1) {
70
- newActiveValue = listItemKeys[index + 1];
40
+ if (key === "Enter") {
41
+ listItemsMap.get(activeValue.value)?.click();
42
+ return;
43
+ }
44
+ if (key === "Escape" && props.closeOnPressEscape) {
45
+ emits("escape", ev);
46
+ return;
47
+ }
48
+ let newActiveValue = "";
49
+ const listItemKeyLength = listItemKeys.length;
50
+ if (PREV_KEYS.includes(key)) {
51
+ if (activeValue.value) {
52
+ const index = listItemKeys.indexOf(activeValue.value);
53
+ if (props.loop) {
54
+ const prevIndex = (index - 1 + listItemKeys.length) % listItemKeys.length;
55
+ newActiveValue = listItemKeys[prevIndex];
56
+ } else if (index > 0) {
57
+ newActiveValue = listItemKeys[index - 1];
58
+ }
59
+ } else {
60
+ newActiveValue = listItemKeys[listItemKeyLength - 1];
61
+ }
62
+ } else if (NEXT_KEYS.includes(key)) {
63
+ if (activeValue.value) {
64
+ const index = listItemKeys.indexOf(activeValue.value);
65
+ if (props.loop) {
66
+ const nextIndex = (index + 1) % listItemKeys.length;
67
+ newActiveValue = listItemKeys[nextIndex];
68
+ } else if (index < listItemKeys.length - 1) {
69
+ newActiveValue = listItemKeys[index + 1];
70
+ }
71
+ } else {
72
+ newActiveValue = listItemKeys[0];
71
73
  }
72
- } else {
74
+ } else if (key === "Home") {
73
75
  newActiveValue = listItemKeys[0];
76
+ } else if (key === "End") {
77
+ newActiveValue = listItemKeys[listItemKeyLength - 1];
74
78
  }
75
- } else if (key === "Home") {
76
- newActiveValue = listItemKeys[0];
77
- } else if (key === "End") {
78
- newActiveValue = listItemKeys[listItemKeyLength - 1];
79
- }
80
- if (!newActiveValue) {
81
- return;
82
- }
83
- if (activeValue.value !== newActiveValue) {
84
- emits("toggle");
85
- activeValue.value = newActiveValue;
86
- }
87
- listItemsMap.get(activeValue.value)?.scrollIntoView({ block: "nearest" });
88
- }, 100, { edges: ["leading"] });
79
+ if (!newActiveValue) {
80
+ return;
81
+ }
82
+ if (activeValue.value !== newActiveValue) {
83
+ emits("toggle");
84
+ activeValue.value = newActiveValue;
85
+ }
86
+ listItemsMap.get(activeValue.value)?.scrollIntoView({ block: "nearest" });
87
+ },
88
+ 100,
89
+ { edges: ["leading"] }
90
+ );
89
91
  function onContainerKeydown(ev) {
90
92
  if (!props.keyListener || listItemKeys.length === 0) {
91
93
  return;
@@ -105,7 +107,7 @@ function onPointerOver(ev) {
105
107
  }
106
108
  activeValue.value = itemValue;
107
109
  }
108
- function onOptionClick(ev, item) {
110
+ function onOptionClick(item, ev) {
109
111
  const { as, onClick, ...option } = item;
110
112
  activeValue.value = "";
111
113
  emits("select", ev, option);
@@ -159,8 +161,7 @@ defineExpose({
159
161
  role="list"
160
162
  tabindex="-1"
161
163
  :data-transition="itemTransition"
162
- class="pxd-list group/list max-w-full list-none bg-background-100 outline-none"
163
- :style="{ width: getCssUnitValue(width) }"
164
+ class="pxd-list group/list m-0 p-0 max-w-full list-none bg-background-100 outline-none"
164
165
  v-bind="$attrs"
165
166
  @pointerover="onPointerOver"
166
167
  >