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
@@ -0,0 +1,22 @@
1
+ export declare const listItemVariant: import("tailwind-variants").TVReturnType<{
2
+ type: {
3
+ error: string;
4
+ warning: string;
5
+ default: string;
6
+ separator: string;
7
+ };
8
+ }, undefined, "pxd-list-item h-10 gap-3 px-2 text-sm flex w-full cursor-pointer items-center rounded-md outline-none data-[disabled=true]:pointer-events-none data-[disabled=true]:text-gray-700 group-data-[transition=true]/list:motion-safe:transition-colors", {
9
+ type: {
10
+ error: string;
11
+ warning: string;
12
+ default: string;
13
+ separator: string;
14
+ };
15
+ }, undefined, import("tailwind-variants").TVReturnType<{
16
+ type: {
17
+ error: string;
18
+ warning: string;
19
+ default: string;
20
+ separator: string;
21
+ };
22
+ }, undefined, "pxd-list-item h-10 gap-3 px-2 text-sm flex w-full cursor-pointer items-center rounded-md outline-none data-[disabled=true]:pointer-events-none data-[disabled=true]:text-gray-700 group-data-[transition=true]/list:motion-safe:transition-colors", unknown, unknown, undefined>>;
@@ -0,0 +1,15 @@
1
+ import { tv } from "tailwind-variants";
2
+ export const listItemVariant = tv({
3
+ base: "pxd-list-item h-10 gap-3 px-2 text-sm flex w-full cursor-pointer items-center rounded-md outline-none data-[disabled=true]:pointer-events-none data-[disabled=true]:text-gray-700 group-data-[transition=true]/list:motion-safe:transition-colors",
4
+ variants: {
5
+ type: {
6
+ error: "text-red-900 pointer-coarse:active:bg-red-100 pointer-fine:data-[selected=true]:bg-red-100",
7
+ warning: "text-amber-900 pointer-coarse:active:bg-amber-100 pointer-fine:data-[selected=true]:bg-amber-100",
8
+ default: "text-foreground pointer-coarse:active:bg-gray-alpha-100 pointer-fine:data-[selected=true]:bg-gray-alpha-100",
9
+ separator: "h-0! px-0 m-1.5 w-auto! border-b"
10
+ }
11
+ },
12
+ defaultVariants: {
13
+ type: "default"
14
+ }
15
+ });
@@ -11,13 +11,13 @@ type __VLS_Slots = {} & {
11
11
  default?: (props: typeof __VLS_11) => any;
12
12
  };
13
13
  declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
14
- click: (args_0: MouseEvent, args_1: ListOptionSelected) => any;
14
+ click: (args_0: ListOptionSelected, args_1: MouseEvent) => any;
15
15
  }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
16
- onClick?: ((args_0: MouseEvent, args_1: ListOptionSelected) => any) | undefined;
16
+ onClick?: ((args_0: ListOptionSelected, args_1: MouseEvent) => any) | undefined;
17
17
  }>, {
18
18
  type: "default" | "error" | "warning" | "separator";
19
- as: import("../../types/shared").ComponentAs;
20
19
  disabled: boolean;
20
+ as: import("../../types/shared").ComponentAs;
21
21
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
22
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
23
23
  declare const _default: typeof __VLS_export;
@@ -3,45 +3,34 @@ import { computed, nextTick, onMounted, shallowRef } from "vue";
3
3
  import { useListContext, useListFilterValue } from "../../contexts/list";
4
4
  import { unrefElement } from "../../utils/ref";
5
5
  import { getUniqueId } from "../../utils/uid";
6
+ import { listItemVariant } from "./cn";
6
7
  defineOptions({
7
8
  name: "PListItem"
8
9
  });
9
10
  const props = defineProps({
10
11
  as: { type: null, required: false, default: "li" },
11
- type: { type: null, required: false, default: "default" },
12
- label: { type: null, required: false },
13
- disabled: { type: null, required: false, default: false },
14
- description: { type: null, required: false }
12
+ type: { type: String, required: false, default: "default" },
13
+ label: { type: [String, Number, Array, null], required: false },
14
+ disabled: { type: Boolean, required: false, default: false },
15
+ description: { type: [String, Number, Array, null], required: false }
15
16
  });
16
17
  const emits = defineEmits(["click"]);
17
- const {
18
- activeValue,
19
- onOptionClick
20
- } = useListContext();
18
+ const { activeValue, onOptionClick } = useListContext();
21
19
  const uniqueId = getUniqueId();
22
20
  const filterValue = useListFilterValue();
23
21
  const itemRef = shallowRef();
24
22
  const currentValue = shallowRef("");
25
- const itemTypeMap = {
26
- error: "text-red-900 pointer-coarse:active:bg-red-100 pointer-fine:data-[selected=true]:bg-red-100",
27
- warning: "text-amber-900 pointer-coarse:active:bg-amber-100 pointer-fine:data-[selected=true]:bg-amber-100",
28
- default: "text-foreground pointer-coarse:active:bg-gray-alpha-100 pointer-fine:data-[selected=true]:bg-gray-alpha-100",
29
- separator: "!h-0 !w-auto px-0 m-1.5 border-b"
30
- };
31
- const isVisible = computed(() => filterValue?.value ? currentValue.value.includes(filterValue.value.toLowerCase()) : true);
23
+ const isVisible = computed(
24
+ () => filterValue?.value ? currentValue.value.includes(filterValue.value.toLowerCase()) : true
25
+ );
32
26
  const isSelected = computed(() => activeValue.value === uniqueId);
33
27
  const isDisabled = computed(() => props.disabled || props.type === "separator");
34
- const computedClass = computed(() => {
35
- const { type = "default" } = props;
36
- const classes = ["pxd-list-item h-10 gap-3 px-2 text-sm flex w-full cursor-pointer items-center rounded-md outline-none data-[disabled=true]:pointer-events-none data-[disabled=true]:text-gray-700 group-data-[transition=true]/list:motion-safe:transition-colors"];
37
- if (type in itemTypeMap) {
38
- classes.push(itemTypeMap[type]);
39
- }
40
- return classes.join(" ");
28
+ const computedClasses = computed(() => {
29
+ return listItemVariant({ type: props.type });
41
30
  });
42
31
  function onItemClick(ev) {
43
- emits("click", ev, props);
44
- onOptionClick?.(ev, props);
32
+ emits("click", props, ev);
33
+ onOptionClick?.(props, ev);
45
34
  }
46
35
  onMounted(async () => {
47
36
  await nextTick();
@@ -64,7 +53,7 @@ onMounted(async () => {
64
53
  :data-value="uniqueId"
65
54
  :data-selected="isSelected"
66
55
  :data-disabled="isDisabled"
67
- :class="computedClass"
56
+ :class="computedClasses"
68
57
  @click.prevent.stop="onItemClick"
69
58
  >
70
59
  <slot v-if="type !== 'separator'">
@@ -0,0 +1,70 @@
1
+ export declare const loadingBarVariant: import("tailwind-variants").TVReturnType<{
2
+ status: {
3
+ running: {
4
+ inner: string;
5
+ };
6
+ finish: {
7
+ inner: string;
8
+ };
9
+ error: {
10
+ inner: string;
11
+ };
12
+ };
13
+ absolute: {
14
+ true: {
15
+ wrapper: string;
16
+ };
17
+ false: {
18
+ wrapper: string;
19
+ };
20
+ };
21
+ }, {
22
+ wrapper: string;
23
+ inner: string;
24
+ }, undefined, {
25
+ status: {
26
+ running: {
27
+ inner: string;
28
+ };
29
+ finish: {
30
+ inner: string;
31
+ };
32
+ error: {
33
+ inner: string;
34
+ };
35
+ };
36
+ absolute: {
37
+ true: {
38
+ wrapper: string;
39
+ };
40
+ false: {
41
+ wrapper: string;
42
+ };
43
+ };
44
+ }, {
45
+ wrapper: string;
46
+ inner: string;
47
+ }, import("tailwind-variants").TVReturnType<{
48
+ status: {
49
+ running: {
50
+ inner: string;
51
+ };
52
+ finish: {
53
+ inner: string;
54
+ };
55
+ error: {
56
+ inner: string;
57
+ };
58
+ };
59
+ absolute: {
60
+ true: {
61
+ wrapper: string;
62
+ };
63
+ false: {
64
+ wrapper: string;
65
+ };
66
+ };
67
+ }, {
68
+ wrapper: string;
69
+ inner: string;
70
+ }, undefined, unknown, unknown, undefined>>;
@@ -0,0 +1,32 @@
1
+ import { tv } from "tailwind-variants";
2
+ export const loadingBarVariant = tv({
3
+ slots: {
4
+ wrapper: "pxd-loading-bar top-0 left-0 right-0 pointer-events-none z-10 max-w-full overflow-hidden",
5
+ inner: "pxd-loading-bar--inner h-1 origin-left data-[hidden=true]:h-0 data-[transition=false]:transition-none! motion-safe:transition-all"
6
+ },
7
+ variants: {
8
+ status: {
9
+ running: {
10
+ inner: "bg-gray-500"
11
+ },
12
+ finish: {
13
+ inner: "bg-primary"
14
+ },
15
+ error: {
16
+ inner: "bg-red-900"
17
+ }
18
+ },
19
+ absolute: {
20
+ true: {
21
+ wrapper: "absolute"
22
+ },
23
+ false: {
24
+ wrapper: "fixed"
25
+ }
26
+ }
27
+ },
28
+ defaultVariants: {
29
+ status: "finish",
30
+ absolute: false
31
+ }
32
+ });
@@ -3,10 +3,12 @@ interface Props {
3
3
  group?: string;
4
4
  minimum?: number;
5
5
  trickle?: boolean;
6
+ hideDelay?: number;
6
7
  trickleThreshold?: number;
7
8
  }
8
9
  declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
9
10
  group: string;
11
+ hideDelay: number;
10
12
  minimum: number;
11
13
  trickle: boolean;
12
14
  trickleThreshold: number;
@@ -1,15 +1,11 @@
1
1
  <script setup>
2
2
  import { computed, onBeforeUnmount, onMounted, shallowRef } from "vue";
3
- import {
4
- ERROR_LOADING_BAR_EVENT_NAME,
5
- FINISH_LOADING_BAR_EVENT_NAME,
6
- INCREASE_LOADING_BAR_EVENT_NAME,
7
- START_LOADING_BAR_EVENT_NAME
8
- } from "../../composables/use-loading-bar";
3
+ import { UPDATE_LOADING_BAR_EVENT_NAME } from "../../composables/use-loading-bar";
9
4
  import { cachedOff, cachedOn } from "../../utils/event";
10
- import { clampValue } from "../../utils/format";
5
+ import { clampValue, isTruthyProp } from "../../utils/format";
11
6
  import { isServer } from "../../utils/is";
12
7
  import PTeleport from "../teleport/index.vue";
8
+ import { loadingBarVariant } from "./cn";
13
9
  defineOptions({
14
10
  name: "PLoadingBar",
15
11
  inheritAttrs: false
@@ -19,22 +15,23 @@ const props = defineProps({
19
15
  group: { type: String, required: false, default: "default" },
20
16
  minimum: { type: Number, required: false, default: 0.08 },
21
17
  trickle: { type: Boolean, required: false, default: true },
18
+ hideDelay: { type: Number, required: false, default: 500 },
22
19
  trickleThreshold: { type: Number, required: false, default: 300 }
23
20
  });
24
- let hideTimerId;
25
21
  let prevTimestamp = 0;
26
22
  let prevAnimationKey = 0;
23
+ let hiddenBarTimeout;
24
+ let enableTransitionTimeout;
25
+ const ENABLE_TRANSITION_DELAY = 0;
27
26
  const status = shallowRef("finish");
28
- const hidden = shallowRef(false);
29
- const progress = shallowRef(0);
30
- const computedClass = computed(() => {
31
- const _status = status.value;
32
- return {
33
- "opacity-0": hidden.value,
34
- "bg-gray-500": _status === "running",
35
- "bg-primary": _status === "finish",
36
- "bg-red-900": _status === "error"
37
- };
27
+ const hiddenBar = shallowRef(false);
28
+ const progressValue = shallowRef(0);
29
+ const enableTransition = shallowRef(false);
30
+ const computedClasses = computed(() => {
31
+ return loadingBarVariant({
32
+ status: status.value,
33
+ absolute: isTruthyProp(props.to)
34
+ });
38
35
  });
39
36
  function getIncreaseDelta(n) {
40
37
  if (n >= 0 && n < 0.2) {
@@ -50,7 +47,7 @@ function getIncreaseDelta(n) {
50
47
  }
51
48
  }
52
49
  function increaseProgress(n) {
53
- if (progress.value >= 1) {
50
+ if (progressValue.value >= 1) {
54
51
  cancelAnimationFrame(prevAnimationKey);
55
52
  return;
56
53
  }
@@ -62,88 +59,98 @@ function increaseProgress(n) {
62
59
  return;
63
60
  }
64
61
  prevTimestamp = now;
65
- const amount = n || getIncreaseDelta(progress.value);
66
- progress.value = clampValue(progress.value + amount, 0, 0.994);
62
+ const amount = n || getIncreaseDelta(progressValue.value);
63
+ progressValue.value = clampValue(progressValue.value + amount, 0, 0.994);
67
64
  if (amount === 0 || !props.trickle) {
68
65
  return;
69
66
  }
70
67
  prevAnimationKey = requestAnimationFrame(() => increaseProgress());
71
68
  }
72
- function onStartProgress({ detail }) {
73
- if (detail.group !== props.group) {
69
+ async function hideAndResetProgress() {
70
+ hiddenBarTimeout = setTimeout(() => {
71
+ hiddenBar.value = true;
72
+ }, props.hideDelay);
73
+ }
74
+ function handleStartProgress() {
75
+ if (status.value === "running") {
74
76
  return;
75
77
  }
76
- hidden.value = false;
78
+ enableTransition.value = false;
79
+ hiddenBar.value = false;
77
80
  status.value = "running";
78
- clearTimeout(hideTimerId);
79
- progress.value = props.minimum;
81
+ progressValue.value = props.minimum;
82
+ clearTimeout(hiddenBarTimeout);
83
+ clearTimeout(enableTransitionTimeout);
84
+ enableTransitionTimeout = setTimeout(() => {
85
+ enableTransition.value = true;
86
+ }, ENABLE_TRANSITION_DELAY);
80
87
  if (!props.trickle) {
81
88
  return;
82
89
  }
83
90
  prevTimestamp = 0;
84
91
  requestAnimationFrame(() => increaseProgress());
85
92
  }
86
- function onErrorProgress({ detail }) {
87
- if (detail.group !== props.group) {
93
+ async function handleErrorProgress() {
94
+ if (status.value !== "running") {
88
95
  return;
89
96
  }
90
97
  cancelAnimationFrame(prevAnimationKey);
91
- clearTimeout(hideTimerId);
92
98
  status.value = "error";
93
- hidden.value = false;
94
- progress.value = 1;
95
- hideTimerId = setTimeout(() => {
96
- hidden.value = true;
97
- }, 500);
99
+ hiddenBar.value = false;
100
+ progressValue.value = 1;
101
+ hideAndResetProgress();
98
102
  }
99
- function onFinishProgress({ detail }) {
100
- if (detail.group !== props.group) {
103
+ function handleFinishProgress() {
104
+ if (status.value !== "running") {
101
105
  return;
102
106
  }
103
107
  cancelAnimationFrame(prevAnimationKey);
104
- clearTimeout(hideTimerId);
105
108
  status.value = "finish";
106
- hidden.value = false;
107
- progress.value = 1;
108
- hideTimerId = setTimeout(() => {
109
- hidden.value = true;
110
- }, 500);
109
+ hiddenBar.value = false;
110
+ progressValue.value = 1;
111
+ hideAndResetProgress();
112
+ }
113
+ function handleIncreaseProgress(value) {
114
+ increaseProgress(value);
111
115
  }
112
- function onIncreaseProgress({ detail }) {
116
+ function onUpdateLoadingBar({ detail }) {
113
117
  if (detail.group !== props.group) {
114
118
  return;
115
119
  }
116
- increaseProgress(detail.value);
120
+ switch (detail.type) {
121
+ case "start":
122
+ handleStartProgress();
123
+ break;
124
+ case "error":
125
+ handleErrorProgress();
126
+ break;
127
+ case "finish":
128
+ handleFinishProgress();
129
+ break;
130
+ case "increase":
131
+ handleIncreaseProgress(detail.value);
132
+ break;
133
+ }
117
134
  }
118
135
  onMounted(() => {
119
136
  if (isServer()) {
120
137
  return;
121
138
  }
122
- cachedOn(window, START_LOADING_BAR_EVENT_NAME, onStartProgress);
123
- cachedOn(window, ERROR_LOADING_BAR_EVENT_NAME, onErrorProgress);
124
- cachedOn(window, FINISH_LOADING_BAR_EVENT_NAME, onFinishProgress);
125
- cachedOn(window, INCREASE_LOADING_BAR_EVENT_NAME, onIncreaseProgress);
139
+ cachedOn(window, UPDATE_LOADING_BAR_EVENT_NAME, onUpdateLoadingBar);
126
140
  });
127
141
  onBeforeUnmount(() => {
128
- cachedOff(window, START_LOADING_BAR_EVENT_NAME, onStartProgress);
129
- cachedOff(window, ERROR_LOADING_BAR_EVENT_NAME, onErrorProgress);
130
- cachedOff(window, FINISH_LOADING_BAR_EVENT_NAME, onFinishProgress);
131
- cachedOff(window, INCREASE_LOADING_BAR_EVENT_NAME, onIncreaseProgress);
142
+ cachedOff(window, UPDATE_LOADING_BAR_EVENT_NAME, onUpdateLoadingBar);
132
143
  });
133
144
  </script>
134
145
 
135
146
  <template>
136
147
  <PTeleport :to="to">
137
- <div
138
- aria-hidden="true"
139
- class="pxd-loading-bar top-0 left-0 right-0 h-1 pointer-events-none z-10 max-w-full overflow-hidden"
140
- :class="to ? 'absolute' : 'fixed'"
141
- v-bind="$attrs"
142
- >
148
+ <div aria-hidden="true" :class="computedClasses.wrapper()" v-bind="$attrs">
143
149
  <div
144
- class="pxd-loading-bar--inner size-full origin-left rounded-r-full motion-safe:transition-all"
145
- :class="computedClass"
146
- :style="{ transform: `scaleX(${progress})` }"
150
+ :data-hidden="hiddenBar"
151
+ :data-transition="enableTransition"
152
+ :class="computedClasses.inner()"
153
+ :style="{ transform: `scaleX(${progressValue})` }"
147
154
  />
148
155
  </div>
149
156
  </PTeleport>
@@ -10,9 +10,17 @@ defineOptions({
10
10
  <slot name="prefix" />
11
11
  </div>
12
12
 
13
- <span class="pxd-loading--dot mx-px size-[calc(1em/4)] rounded-full bg-gray-900 motion-reduce:opacity-20" />
14
- <span class="pxd-loading--dot mx-px size-[calc(1em/4)] rounded-full bg-gray-900 motion-reduce:opacity-50" style="animation-delay:.2s" />
15
- <span class="pxd-loading--dot mx-px size-[calc(1em/4)] rounded-full bg-gray-900 motion-reduce:opacity-80" style="animation-delay:.4s" />
13
+ <span
14
+ class="pxd-loading--dot mx-px size-[calc(1em/4)] rounded-full bg-gray-900 default-animation-timing-function! motion-safe:animate-[fade-loading_1.4s_infinite] motion-reduce:opacity-20"
15
+ />
16
+ <span
17
+ class="pxd-loading--dot mx-px size-[calc(1em/4)] rounded-full bg-gray-900 default-animation-timing-function! motion-safe:animate-[fade-loading_1.4s_infinite] motion-reduce:opacity-50"
18
+ style="animation-delay: 0.2s"
19
+ />
20
+ <span
21
+ class="pxd-loading--dot mx-px size-[calc(1em/4)] rounded-full bg-gray-900 default-animation-timing-function! motion-safe:animate-[fade-loading_1.4s_infinite] motion-reduce:opacity-80"
22
+ style="animation-delay: 0.4s"
23
+ />
16
24
 
17
25
  <div v-if="$slots.suffix" class="pxd-loading-dots--text ml-3">
18
26
  <slot name="suffix" />
@@ -21,5 +29,5 @@ defineOptions({
21
29
  </template>
22
30
 
23
31
  <style>
24
- @keyframes fade-loading{0%,to{opacity:.2}20%{opacity:.8}}@media (prefers-reduced-motion:no-preference){.pxd-loading-dots .pxd-loading--dot{animation:fade-loading 1.4s infinite var(--default-transition-timing-function)}}
32
+ @keyframes fade-loading{0%,to{opacity:.2}20%{opacity:.8}}
25
33
  </style>
@@ -13,10 +13,10 @@ type __VLS_Slots = {} & {
13
13
  items?: (props: typeof __VLS_23) => any;
14
14
  };
15
15
  declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
16
- select: (args_0: MouseEvent, args_1: ListOptionSelected) => any;
16
+ select: (args_0: ListOptionSelected, args_1: MouseEvent) => any;
17
17
  change: (visible: boolean) => any;
18
18
  }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
19
- onSelect?: ((args_0: MouseEvent, args_1: ListOptionSelected) => any) | undefined;
19
+ onSelect?: ((args_0: ListOptionSelected, args_1: MouseEvent) => any) | undefined;
20
20
  onChange?: ((visible: boolean) => any) | undefined;
21
21
  }>, {
22
22
  options: ListOption[];
@@ -1,6 +1,7 @@
1
1
  <script setup>
2
2
  import { shallowRef } from "vue";
3
3
  import { usePopoverResponsive } from "../../composables/use-popover-responsive";
4
+ import { getCssUnitValue } from "../../utils/format";
4
5
  import PList from "../list/index.vue";
5
6
  import PPopover from "../popover/index.vue";
6
7
  defineOptions({
@@ -23,17 +24,15 @@ function hidePopover() {
23
24
  onVisibleChange(false);
24
25
  }
25
26
  function onOptionClick(ev, item) {
26
- emits("select", ev, item);
27
+ emits("select", item, ev);
27
28
  hidePopover();
28
29
  }
29
30
  </script>
30
31
 
31
32
  <template>
32
33
  <PPopover
33
- enterable
34
34
  class="pxd-menu"
35
35
  trigger="click"
36
- :show-delay="0"
37
36
  :hide-delay="100"
38
37
  :position="position"
39
38
  :visible="popoverVisible"
@@ -55,7 +54,8 @@ function onOptionClick(ev, item) {
55
54
  :width="width"
56
55
  :options="options"
57
56
  :key-listener="popoverVisible"
58
- class="max-h-68 rounded-inherit"
57
+ :style="{ '--list-width': getCssUnitValue(width) }"
58
+ class="max-h-68 sm:w-(--list-width) rounded-inherit"
59
59
  @select="onOptionClick"
60
60
  >
61
61
  <slot name="items" />