pxd 0.0.39 → 0.0.41

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 (240) hide show
  1. package/README.md +9 -3
  2. package/dist/components/active-graph/index.vue +10 -5
  3. package/dist/components/backtop/index.vue +75 -0
  4. package/dist/components/badge/index.vue +9 -7
  5. package/dist/components/book/index.vue +3 -3
  6. package/dist/components/browser/index.vue +2 -2
  7. package/dist/components/checkbox/index.vue +4 -3
  8. package/dist/components/checkbox-group/index.vue +1 -1
  9. package/dist/components/choicebox-group/index.vue +1 -1
  10. package/dist/components/command-menu/index.vue +124 -0
  11. package/dist/components/command-menu-group/index.vue +18 -0
  12. package/dist/components/command-menu-item/index.vue +13 -0
  13. package/dist/components/countdown/index.vue +2 -1
  14. package/dist/components/drawer/index.vue +26 -26
  15. package/dist/components/error/index.vue +2 -2
  16. package/dist/components/fader/index.vue +31 -17
  17. package/dist/components/grid/index.vue +2 -2
  18. package/dist/components/grid-item/index.vue +2 -2
  19. package/dist/components/hold-button/index.vue +1 -1
  20. package/dist/components/index.d.ts +7 -0
  21. package/dist/components/index.js +7 -0
  22. package/dist/components/input/index.vue +18 -10
  23. package/dist/components/intersection-observer/index.vue +5 -5
  24. package/dist/components/kbd/index.vue +21 -8
  25. package/dist/components/{intersection-observer/content.vue → keep-alive-container/index.vue} +3 -1
  26. package/dist/components/list/index.vue +100 -92
  27. package/dist/components/list-item/index.vue +35 -33
  28. package/dist/components/loading-bar/index.vue +149 -0
  29. package/dist/components/material/index.vue +8 -8
  30. package/dist/components/menu/index.vue +26 -16
  31. package/dist/components/message/index.vue +28 -18
  32. package/dist/components/modal/index.vue +32 -36
  33. package/dist/components/note/index.vue +1 -1
  34. package/dist/components/overlay/index.vue +77 -24
  35. package/dist/components/pagination/index.vue +2 -2
  36. package/dist/components/placeholder/index.vue +13 -6
  37. package/dist/components/popover/index.vue +97 -87
  38. package/dist/components/progress/index.vue +1 -1
  39. package/dist/components/radio/index.vue +4 -3
  40. package/dist/components/radio-group/index.vue +1 -1
  41. package/dist/components/scrollable/index.vue +161 -94
  42. package/dist/components/slider/index.vue +7 -7
  43. package/dist/components/stack/index.vue +4 -4
  44. package/dist/components/switch/index.vue +1 -1
  45. package/dist/components/text/index.vue +1 -1
  46. package/dist/components/theme-switcher/index.vue +6 -2
  47. package/dist/components/time-picker/index.vue +281 -0
  48. package/dist/components/tooltip/index.vue +7 -7
  49. package/dist/composables/index.d.ts +1 -0
  50. package/dist/composables/index.js +1 -0
  51. package/dist/composables/use-browser-observer.d.ts +5 -5
  52. package/dist/composables/use-color-scheme.d.ts +5 -1
  53. package/dist/composables/use-color-scheme.js +20 -1
  54. package/dist/composables/use-config-provider-context.d.ts +1 -1
  55. package/dist/composables/use-countdown.d.ts +6 -0
  56. package/dist/composables/use-countdown.js +21 -7
  57. package/dist/composables/use-delay-destroy.d.ts +4 -4
  58. package/dist/composables/use-delay-destroy.js +15 -11
  59. package/dist/composables/use-focus-trap.d.ts +2 -2
  60. package/dist/composables/use-focus-trap.js +6 -6
  61. package/dist/composables/use-loading-bar.d.ts +25 -0
  62. package/dist/composables/use-loading-bar.js +27 -0
  63. package/dist/composables/use-media-query.js +1 -1
  64. package/dist/composables/use-message.d.ts +4 -1
  65. package/dist/composables/use-message.js +18 -0
  66. package/dist/composables/use-pointer-gesture.d.ts +2 -2
  67. package/dist/composables/use-pointer-gesture.js +3 -3
  68. package/dist/composables/use-repeat-action.d.ts +2 -2
  69. package/dist/composables/use-repeat-action.js +5 -5
  70. package/dist/composables/use-virtual-list.d.ts +1 -1
  71. package/dist/contexts/avatar.d.ts +1 -1
  72. package/dist/contexts/carousel.d.ts +1 -1
  73. package/dist/contexts/checkbox.d.ts +1 -1
  74. package/dist/contexts/choicebox.d.ts +2 -2
  75. package/dist/contexts/collapse.d.ts +1 -1
  76. package/dist/contexts/list.d.ts +5 -6
  77. package/dist/contexts/list.js +3 -3
  78. package/dist/contexts/radio.d.ts +1 -1
  79. package/dist/contexts/resizable.d.ts +1 -1
  80. package/dist/contexts/switch.d.ts +2 -2
  81. package/dist/{components/carousel → dist/components/keep-alive-container}/index.vue.d.ts +1 -1
  82. package/dist/index.d.ts +1 -1
  83. package/dist/index.js +1 -1
  84. package/dist/locales/en-us.d.ts +15 -7
  85. package/dist/locales/en-us.js +17 -9
  86. package/dist/locales/zh-cn.d.ts +15 -7
  87. package/dist/locales/zh-cn.js +17 -9
  88. package/dist/{components → src/components}/active-graph/index.vue.d.ts +7 -5
  89. package/dist/{components → src/components}/avatar-group/index.vue.d.ts +1 -1
  90. package/dist/src/components/backtop/index.vue.d.ts +20 -0
  91. package/dist/{components → src/components}/badge/index.vue.d.ts +2 -1
  92. package/dist/{components → src/components}/book/index.vue.d.ts +1 -1
  93. package/dist/{components → src/components}/browser/index.vue.d.ts +1 -1
  94. package/dist/{components → src/components}/button/index.vue.d.ts +1 -1
  95. package/dist/{components/intersection-observer/content.vue.d.ts → src/components/carousel/index.vue.d.ts} +1 -1
  96. package/dist/{components → src/components}/carousel-group/index.vue.d.ts +1 -1
  97. package/dist/{components → src/components}/chip/index.vue.d.ts +1 -1
  98. package/dist/{components → src/components}/choicebox/index.vue.d.ts +1 -1
  99. package/dist/{components → src/components}/choicebox-group/index.vue.d.ts +1 -1
  100. package/dist/{components → src/components}/collapse/index.vue.d.ts +1 -1
  101. package/dist/{components → src/components}/collapse-group/index.vue.d.ts +1 -1
  102. package/dist/src/components/command-menu/index.vue.d.ts +39 -0
  103. package/dist/src/components/command-menu-group/index.vue.d.ts +16 -0
  104. package/dist/src/components/command-menu-item/index.vue.d.ts +12 -0
  105. package/dist/{components → src/components}/config-provider/index.vue.d.ts +1 -1
  106. package/dist/{components → src/components}/description/index.vue.d.ts +1 -1
  107. package/dist/{components → src/components}/drawer/index.vue.d.ts +19 -14
  108. package/dist/{components → src/components}/empty-state/index.vue.d.ts +1 -1
  109. package/dist/{components → src/components}/error/index.vue.d.ts +1 -1
  110. package/dist/src/components/fader/index.vue.d.ts +11 -0
  111. package/dist/{components → src/components}/gauge/index.vue.d.ts +1 -1
  112. package/dist/{components → src/components}/grid/index.vue.d.ts +1 -1
  113. package/dist/{components → src/components}/grid-item/index.vue.d.ts +1 -1
  114. package/dist/{components → src/components}/hold-button/index.vue.d.ts +1 -1
  115. package/dist/{components → src/components}/input/index.vue.d.ts +9 -4
  116. package/dist/{components → src/components}/intersection-observer/index.vue.d.ts +3 -3
  117. package/dist/{components → src/components}/kbd/index.vue.d.ts +8 -5
  118. package/dist/src/components/keep-alive-container/index.vue.d.ts +12 -0
  119. package/dist/{components → src/components}/link-button/index.vue.d.ts +1 -1
  120. package/dist/src/components/list/index.vue.d.ts +40 -0
  121. package/dist/{components → src/components}/list-item/index.vue.d.ts +4 -4
  122. package/dist/src/components/loading-bar/index.vue.d.ts +14 -0
  123. package/dist/{components → src/components}/loading-dots/index.vue.d.ts +1 -1
  124. package/dist/{components → src/components}/material/index.vue.d.ts +1 -1
  125. package/dist/{components → src/components}/menu/index.vue.d.ts +11 -7
  126. package/dist/{components → src/components}/message/index.vue.d.ts +13 -13
  127. package/dist/{components → src/components}/modal/index.vue.d.ts +19 -14
  128. package/dist/{components → src/components}/more-button/index.vue.d.ts +1 -1
  129. package/dist/{components → src/components}/note/index.vue.d.ts +1 -1
  130. package/dist/{components → src/components}/number-input/index.vue.d.ts +1 -1
  131. package/dist/{components → src/components}/overlay/index.vue.d.ts +3 -4
  132. package/dist/{components → src/components}/pagination/index.vue.d.ts +1 -1
  133. package/dist/{components → src/components}/pin-input/index.vue.d.ts +1 -1
  134. package/dist/src/components/placeholder/index.vue.d.ts +9 -0
  135. package/dist/{components → src/components}/popover/index.vue.d.ts +10 -8
  136. package/dist/{components → src/components}/progress/index.vue.d.ts +1 -1
  137. package/dist/{components → src/components}/radio/index.vue.d.ts +1 -1
  138. package/dist/{components → src/components}/radio-group/index.vue.d.ts +1 -1
  139. package/dist/{components → src/components}/resizable/index.vue.d.ts +1 -1
  140. package/dist/src/components/resizable-handle/index.vue.d.ts +2 -0
  141. package/dist/{components → src/components}/resizable-panel/index.vue.d.ts +1 -1
  142. package/dist/{components → src/components}/skeleton/index.vue.d.ts +1 -1
  143. package/dist/{components → src/components}/slider/index.vue.d.ts +1 -1
  144. package/dist/{components → src/components}/snippet/index.vue.d.ts +1 -1
  145. package/dist/src/components/spinner/index.vue.d.ts +2 -0
  146. package/dist/{components → src/components}/stack/index.vue.d.ts +1 -1
  147. package/dist/{components → src/components}/status-dot/index.vue.d.ts +1 -1
  148. package/dist/{components → src/components}/switch/index.vue.d.ts +1 -1
  149. package/dist/{components → src/components}/switch-group/index.vue.d.ts +1 -1
  150. package/dist/{components → src/components}/teleport/index.vue.d.ts +1 -1
  151. package/dist/{components → src/components}/text/index.vue.d.ts +1 -1
  152. package/dist/{components → src/components}/textarea/index.vue.d.ts +1 -1
  153. package/dist/{components → src/components}/theme-switcher/index.vue.d.ts +1 -1
  154. package/dist/src/components/time-picker/index.vue.d.ts +25 -0
  155. package/dist/{components → src/components}/toggle/index.vue.d.ts +1 -1
  156. package/dist/{components → src/components}/tooltip/index.vue.d.ts +3 -5
  157. package/dist/{components → src/components}/virtual-list/index.vue.d.ts +1 -1
  158. package/dist/src/composables/use-browser-observer.d.ts +12 -0
  159. package/dist/src/composables/use-color-scheme.d.ts +11 -0
  160. package/dist/src/composables/use-config-provider-context.d.ts +7 -0
  161. package/dist/src/composables/use-copy-click.d.ts +4 -0
  162. package/dist/src/composables/use-countdown.d.ts +60 -0
  163. package/dist/src/composables/use-delay-change.d.ts +7 -0
  164. package/dist/src/composables/use-delay-destroy.d.ts +13 -0
  165. package/dist/src/composables/use-focus-trap.d.ts +4 -0
  166. package/dist/src/composables/use-loading-bar.d.ts +25 -0
  167. package/dist/src/composables/use-media-query.d.ts +15 -0
  168. package/dist/src/composables/use-message.d.ts +33 -0
  169. package/dist/src/composables/use-model-value.d.ts +11 -0
  170. package/dist/src/composables/use-pointer-gesture.d.ts +180 -0
  171. package/dist/src/composables/use-repeat-action.d.ts +16 -0
  172. package/dist/src/composables/use-unique-id-context.d.ts +2 -0
  173. package/dist/src/composables/use-virtual-list.d.ts +16 -0
  174. package/dist/src/contexts/avatar.d.ts +2 -0
  175. package/dist/src/contexts/carousel.d.ts +13 -0
  176. package/dist/src/contexts/checkbox.d.ts +2 -0
  177. package/dist/src/contexts/choicebox.d.ts +4 -0
  178. package/dist/src/contexts/collapse.d.ts +8 -0
  179. package/dist/src/contexts/list.d.ts +8 -0
  180. package/dist/src/contexts/radio.d.ts +2 -0
  181. package/dist/src/contexts/resizable.d.ts +35 -0
  182. package/dist/src/contexts/switch.d.ts +4 -0
  183. package/dist/src/locales/en-us.d.ts +42 -0
  184. package/dist/src/plugins/dayjs-millisecond-token.d.ts +3 -0
  185. package/dist/src/types/components/time-picker.d.ts +4 -0
  186. package/dist/src/utils/context.d.ts +17 -0
  187. package/dist/src/utils/date.d.ts +26 -0
  188. package/dist/src/utils/debounce/index.d.ts +73 -0
  189. package/dist/src/utils/debounce.d.ts +1 -0
  190. package/dist/src/utils/dom.d.ts +40 -0
  191. package/dist/{utils/events.d.ts → src/utils/event.d.ts} +1 -0
  192. package/dist/src/utils/format.d.ts +25 -0
  193. package/dist/src/utils/get.d.ts +11 -0
  194. package/dist/src/utils/is.d.ts +4 -0
  195. package/dist/src/utils/ref.d.ts +5 -0
  196. package/dist/src/utils/regexp.d.ts +8 -0
  197. package/dist/src/utils/responsive.d.ts +3 -0
  198. package/dist/src/utils/throttle/index.d.ts +53 -0
  199. package/dist/src/utils/throttle.d.ts +1 -0
  200. package/dist/src/utils/uid.d.ts +1 -0
  201. package/dist/styles/styles.css +2 -2
  202. package/dist/styles/tw.css +18 -1
  203. package/dist/types/components/list.d.ts +4 -3
  204. package/dist/types/components/time-picker.d.ts +4 -0
  205. package/dist/types/components/time-picker.js +0 -0
  206. package/dist/types/shared/utils.d.ts +5 -2
  207. package/dist/utils/date.d.ts +3 -3
  208. package/dist/utils/debounce/compat.d.ts +143 -0
  209. package/dist/utils/debounce/compat.js +47 -0
  210. package/dist/utils/debounce/index.d.ts +73 -0
  211. package/dist/utils/debounce/index.js +60 -0
  212. package/dist/utils/debounce.d.ts +1 -73
  213. package/dist/utils/debounce.js +1 -60
  214. package/dist/utils/event.d.ts +9 -0
  215. package/dist/utils/{events.js → event.js} +3 -0
  216. package/dist/utils/format.d.ts +4 -1
  217. package/dist/utils/format.js +6 -0
  218. package/dist/utils/ref.d.ts +2 -5
  219. package/dist/utils/regexp.d.ts +4 -0
  220. package/dist/utils/regexp.js +4 -0
  221. package/dist/utils/responsive.d.ts +2 -1
  222. package/dist/utils/responsive.js +4 -1
  223. package/dist/utils/throttle/compat.d.ts +79 -0
  224. package/dist/utils/throttle/compat.js +9 -0
  225. package/dist/utils/throttle/index.d.ts +53 -0
  226. package/dist/utils/throttle/index.js +34 -0
  227. package/dist/utils/throttle.d.ts +1 -53
  228. package/dist/utils/throttle.js +1 -34
  229. package/dist/utils/uid.js +1 -1
  230. package/package.json +11 -11
  231. package/volar.d.ts +7 -0
  232. package/dist/components/fader/index.vue.d.ts +0 -11
  233. package/dist/components/list/index.vue.d.ts +0 -29
  234. package/dist/components/placeholder/index.vue.d.ts +0 -8
  235. package/dist/components/resizable-handle/index.vue.d.ts +0 -2
  236. package/dist/components/spinner/index.vue.d.ts +0 -2
  237. /package/dist/{components → src/components}/avatar/index.vue.d.ts +0 -0
  238. /package/dist/{components → src/components}/checkbox/index.vue.d.ts +0 -0
  239. /package/dist/{components → src/components}/checkbox-group/index.vue.d.ts +0 -0
  240. /package/dist/{components → src/components}/countdown/index.vue.d.ts +0 -0
@@ -0,0 +1,73 @@
1
+ interface DebounceOptions {
2
+ /**
3
+ * An optional AbortSignal to cancel the debounced function.
4
+ */
5
+ signal?: AbortSignal;
6
+ /**
7
+ * An optional array specifying whether the function should be invoked on the leading edge, trailing edge, or both.
8
+ * If `edges` includes "leading", the function will be invoked at the start of the delay period.
9
+ * If `edges` includes "trailing", the function will be invoked at the end of the delay period.
10
+ * If both "leading" and "trailing" are included, the function will be invoked at both the start and end of the delay period.
11
+ * @default ["trailing"]
12
+ */
13
+ edges?: Array<'leading' | 'trailing'>;
14
+ }
15
+ export interface DebouncedFunction<F extends (...args: any[]) => void> {
16
+ (...args: Parameters<F>): void;
17
+ /**
18
+ * Schedules the execution of the debounced function after the specified debounce delay.
19
+ * This method resets any existing timer, ensuring that the function is only invoked
20
+ * after the delay has elapsed since the last call to the debounced function.
21
+ * It is typically called internally whenever the debounced function is invoked.
22
+ *
23
+ * @returns {void}
24
+ */
25
+ schedule: () => void;
26
+ /**
27
+ * Cancels any pending execution of the debounced function.
28
+ * This method clears the active timer and resets any stored context or arguments.
29
+ */
30
+ cancel: () => void;
31
+ /**
32
+ * Immediately invokes the debounced function if there is a pending execution.
33
+ * This method executes the function right away if there is a pending execution.
34
+ */
35
+ flush: () => void;
36
+ }
37
+ /**
38
+ * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
39
+ * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
40
+ * method to cancel any pending execution.
41
+ *
42
+ * @template F - The type of function.
43
+ * @param {F} func - The function to debounce.
44
+ * @param {number} debounceMs - The number of milliseconds to delay.
45
+ * @param {DebounceOptions} options - The options object
46
+ * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the debounced function.
47
+ * @returns A new debounced function with a `cancel` method.
48
+ *
49
+ * @example
50
+ * const debouncedFunction = debounce(() => {
51
+ * console.log('Function executed');
52
+ * }, 1000);
53
+ *
54
+ * // Will log 'Function executed' after 1 second if not called again in that time
55
+ * debouncedFunction();
56
+ *
57
+ * // Will not log anything as the previous call is canceled
58
+ * debouncedFunction.cancel();
59
+ *
60
+ * // With AbortSignal
61
+ * const controller = new AbortController();
62
+ * const signal = controller.signal;
63
+ * const debouncedWithSignal = debounce(() => {
64
+ * console.log('Function executed');
65
+ * }, 1000, { signal });
66
+ *
67
+ * debouncedWithSignal();
68
+ *
69
+ * // Will cancel the debounced function call
70
+ * controller.abort();
71
+ */
72
+ export declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number, { signal, edges }?: DebounceOptions): DebouncedFunction<F>;
73
+ export {};
@@ -0,0 +1,60 @@
1
+ export function debounce(func, debounceMs, { signal, edges } = {}) {
2
+ let pendingThis;
3
+ let pendingArgs = null;
4
+ let timeoutId = null;
5
+ const leading = edges != null && edges.includes("leading");
6
+ const trailing = edges == null || edges.includes("trailing");
7
+ const invoke = () => {
8
+ if (pendingArgs !== null) {
9
+ func.apply(pendingThis, pendingArgs);
10
+ pendingThis = void 0;
11
+ pendingArgs = null;
12
+ }
13
+ };
14
+ const cancelTimer = () => {
15
+ if (timeoutId !== null) {
16
+ clearTimeout(timeoutId);
17
+ timeoutId = null;
18
+ }
19
+ };
20
+ const cancel = () => {
21
+ cancelTimer();
22
+ pendingThis = void 0;
23
+ pendingArgs = null;
24
+ };
25
+ const onTimerEnd = () => {
26
+ if (trailing) {
27
+ invoke();
28
+ }
29
+ cancel();
30
+ };
31
+ const schedule = () => {
32
+ if (timeoutId != null) {
33
+ clearTimeout(timeoutId);
34
+ }
35
+ timeoutId = setTimeout(() => {
36
+ timeoutId = null;
37
+ onTimerEnd();
38
+ }, debounceMs);
39
+ };
40
+ const flush = () => {
41
+ invoke();
42
+ };
43
+ const debounced = function(...args) {
44
+ if (signal?.aborted) {
45
+ return;
46
+ }
47
+ pendingThis = this;
48
+ pendingArgs = args;
49
+ const isFirstCall = timeoutId == null;
50
+ schedule();
51
+ if (leading && isFirstCall) {
52
+ invoke();
53
+ }
54
+ };
55
+ debounced.schedule = schedule;
56
+ debounced.cancel = cancel;
57
+ debounced.flush = flush;
58
+ signal?.addEventListener("abort", cancel, { once: true });
59
+ return debounced;
60
+ }
@@ -1,73 +1 @@
1
- interface DebounceOptions {
2
- /**
3
- * An optional AbortSignal to cancel the debounced function.
4
- */
5
- signal?: AbortSignal;
6
- /**
7
- * An optional array specifying whether the function should be invoked on the leading edge, trailing edge, or both.
8
- * If `edges` includes "leading", the function will be invoked at the start of the delay period.
9
- * If `edges` includes "trailing", the function will be invoked at the end of the delay period.
10
- * If both "leading" and "trailing" are included, the function will be invoked at both the start and end of the delay period.
11
- * @default ["trailing"]
12
- */
13
- edges?: Array<'leading' | 'trailing'>;
14
- }
15
- export interface DebouncedFunction<F extends (...args: any[]) => void> {
16
- (...args: Parameters<F>): void;
17
- /**
18
- * Schedules the execution of the debounced function after the specified debounce delay.
19
- * This method resets any existing timer, ensuring that the function is only invoked
20
- * after the delay has elapsed since the last call to the debounced function.
21
- * It is typically called internally whenever the debounced function is invoked.
22
- *
23
- * @returns {void}
24
- */
25
- schedule: () => void;
26
- /**
27
- * Cancels any pending execution of the debounced function.
28
- * This method clears the active timer and resets any stored context or arguments.
29
- */
30
- cancel: () => void;
31
- /**
32
- * Immediately invokes the debounced function if there is a pending execution.
33
- * This method executes the function right away if there is a pending execution.
34
- */
35
- flush: () => void;
36
- }
37
- /**
38
- * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
39
- * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
40
- * method to cancel any pending execution.
41
- *
42
- * @template F - The type of function.
43
- * @param {F} func - The function to debounce.
44
- * @param {number} debounceMs - The number of milliseconds to delay.
45
- * @param {DebounceOptions} options - The options object
46
- * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the debounced function.
47
- * @returns A new debounced function with a `cancel` method.
48
- *
49
- * @example
50
- * const debouncedFunction = debounce(() => {
51
- * console.log('Function executed');
52
- * }, 1000);
53
- *
54
- * // Will log 'Function executed' after 1 second if not called again in that time
55
- * debouncedFunction();
56
- *
57
- * // Will not log anything as the previous call is canceled
58
- * debouncedFunction.cancel();
59
- *
60
- * // With AbortSignal
61
- * const controller = new AbortController();
62
- * const signal = controller.signal;
63
- * const debouncedWithSignal = debounce(() => {
64
- * console.log('Function executed');
65
- * }, 1000, { signal });
66
- *
67
- * debouncedWithSignal();
68
- *
69
- * // Will cancel the debounced function call
70
- * controller.abort();
71
- */
72
- export declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number, { signal, edges }?: DebounceOptions): DebouncedFunction<F>;
73
- export {};
1
+ export * from './debounce/index';
@@ -1,60 +1 @@
1
- export function debounce(func, debounceMs, { signal, edges } = {}) {
2
- let pendingThis;
3
- let pendingArgs = null;
4
- let timeoutId = null;
5
- const leading = edges != null && edges.includes("leading");
6
- const trailing = edges == null || edges.includes("trailing");
7
- const invoke = () => {
8
- if (pendingArgs !== null) {
9
- func.apply(pendingThis, pendingArgs);
10
- pendingThis = void 0;
11
- pendingArgs = null;
12
- }
13
- };
14
- const cancelTimer = () => {
15
- if (timeoutId !== null) {
16
- clearTimeout(timeoutId);
17
- timeoutId = null;
18
- }
19
- };
20
- const cancel = () => {
21
- cancelTimer();
22
- pendingThis = void 0;
23
- pendingArgs = null;
24
- };
25
- const onTimerEnd = () => {
26
- if (trailing) {
27
- invoke();
28
- }
29
- cancel();
30
- };
31
- const schedule = () => {
32
- if (timeoutId != null) {
33
- clearTimeout(timeoutId);
34
- }
35
- timeoutId = setTimeout(() => {
36
- timeoutId = null;
37
- onTimerEnd();
38
- }, debounceMs);
39
- };
40
- const flush = () => {
41
- invoke();
42
- };
43
- const debounced = function(...args) {
44
- if (signal?.aborted) {
45
- return;
46
- }
47
- pendingThis = this;
48
- pendingArgs = args;
49
- const isFirstCall = timeoutId == null;
50
- schedule();
51
- if (leading && isFirstCall) {
52
- invoke();
53
- }
54
- };
55
- debounced.schedule = schedule;
56
- debounced.cancel = cancel;
57
- debounced.flush = flush;
58
- signal?.addEventListener("abort", cancel, { once: true });
59
- return debounced;
60
- }
1
+ export * from "./debounce/index.js";
@@ -0,0 +1,9 @@
1
+ import type { Nullable } from '../types/shared';
2
+ type EventHandler<E extends Event = Event> = (event: E) => void;
3
+ export declare function on<E extends Event = Event>(el: Nullable<EventTarget>, event: string, handler: EventHandler<E>, options?: AddEventListenerOptions): () => void;
4
+ export declare function off<E extends Event = Event>(el: Nullable<EventTarget>, event: string, handler: EventHandler<E>, options?: AddEventListenerOptions): void;
5
+ export declare function once<E extends Event = Event>(el: Nullable<EventTarget>, event: string, handler: EventHandler<E>, options?: AddEventListenerOptions): void;
6
+ export declare function optimizedOn<E extends Event = Event>(el: Nullable<EventTarget>, event: string, handler: EventHandler<E>, options?: AddEventListenerOptions): void;
7
+ export declare function optimizedOff<E extends Event = Event>(el: Nullable<EventTarget>, event: string, handler: EventHandler<E>, options?: AddEventListenerOptions): void;
8
+ export declare function sleep(ms: number): Promise<unknown>;
9
+ export {};
@@ -69,3 +69,6 @@ export function optimizedOff(el, event, handler, options) {
69
69
  delete el[`__cached_${event}`];
70
70
  }
71
71
  }
72
+ export function sleep(ms) {
73
+ return new Promise((resolve) => setTimeout(resolve, ms));
74
+ }
@@ -7,7 +7,10 @@ export declare function camelize(str: string): string;
7
7
  export declare function pascalize(text: string): string;
8
8
  /** KababCase -> kabab-case */
9
9
  export declare function uncapitalize(text: string): string;
10
- export declare function isTruthyProp(value: unknown): unknown;
10
+ /** 'kabab-case' -> 'Kabab Case' */
11
+ export declare function humanize(text: string): string;
12
+ export declare function isTruthyProp(value: unknown): {};
13
+ export declare function clampValue(n: number, min: number, max: number): number;
11
14
  export declare function isExternalLink(href: string): boolean;
12
15
  export declare function toArray(value: unknown | unknown[]): any[];
13
16
  export declare function getCssUnitValue(value: Nullable<CSSValue | string>, fallbackValue?: string): string;
@@ -12,9 +12,15 @@ export function pascalize(text) {
12
12
  export function uncapitalize(text) {
13
13
  return text.charAt(0).toLowerCase() + text.slice(1).replace(/([A-Z])/g, "-$1").toLowerCase();
14
14
  }
15
+ export function humanize(text) {
16
+ return text.replace(/-/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
17
+ }
15
18
  export function isTruthyProp(value) {
16
19
  return value || value === "";
17
20
  }
21
+ export function clampValue(n, min, max) {
22
+ return min != null && max != null ? Math.min(Math.max(n, min), max) : n;
23
+ }
18
24
  export function isExternalLink(href) {
19
25
  const firstChar = href.slice(0, 1);
20
26
  if (["#", "/"].includes(firstChar)) {
@@ -1,8 +1,5 @@
1
- import type { ComponentPublicInstance, MaybeRef, MaybeRefOrGetter } from 'vue';
2
- import type { Nullable } from '../types/shared/utils';
3
- export type MaybeElement = Nullable<HTMLElement | SVGElement | ComponentPublicInstance>;
4
- export type MaybeElementRef<T extends MaybeElement = MaybeElement> = MaybeRef<T>;
5
- export type MaybeComputedElementRef<T extends MaybeElement = MaybeElement> = MaybeRefOrGetter<T>;
1
+ import type { ComponentPublicInstance, MaybeRefOrGetter } from 'vue';
2
+ import type { MaybeElement } from '../types/shared/utils';
6
3
  export type UnRefElementReturn<T extends MaybeElement = MaybeElement> = T extends ComponentPublicInstance ? Exclude<MaybeElement, ComponentPublicInstance> : T | undefined;
7
4
  export declare function toValue<T>(source: MaybeRefOrGetter<T>): T;
8
5
  export declare function unrefElement<T extends MaybeElement>(elRef: MaybeRefOrGetter<T>): UnRefElementReturn<T>;
@@ -2,3 +2,7 @@ export declare const INTEGER_REGEX: RegExp;
2
2
  export declare const FLOATING_REGEX: RegExp;
3
3
  export declare const POSITIVE_INTEGER_REGEX: RegExp;
4
4
  export declare const SCIENCE_NUMERIC_REGEX: RegExp;
5
+ export declare const DATE_REGEX: RegExp;
6
+ export declare const TIME_REGEX: RegExp;
7
+ export declare const DATE_TIME_REGEX: RegExp;
8
+ export declare const TIME_REGEX_WITH_MILLISECONDS: RegExp;
@@ -2,3 +2,7 @@ export const INTEGER_REGEX = /^-?\d+$/;
2
2
  export const FLOATING_REGEX = /^-?\d+\.?\d*/;
3
3
  export const POSITIVE_INTEGER_REGEX = /^\d+$/;
4
4
  export const SCIENCE_NUMERIC_REGEX = /^-?\d+(?:\.\d*)?(e-?\d+)?$/i;
5
+ export const DATE_REGEX = /^(\d{4})-(\d{2})-(\d{2})$/;
6
+ export const TIME_REGEX = /^(\d{2}):(\d{2}):(\d{2})$/;
7
+ export const DATE_TIME_REGEX = /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/;
8
+ export const TIME_REGEX_WITH_MILLISECONDS = /^(\d{2}):(\d{2}):(\d{2})\.(\d{1,3})$/;
@@ -1,2 +1,3 @@
1
1
  import type { ResponsiveValue } from '../types/shared/props';
2
- export declare function getResponsiveValue<V extends string | number>(prop: ResponsiveValue<V> | undefined, xsValue: V, valueSetter: (acc: Record<string, V>, bp: any, v: V) => void): Record<string, V>;
2
+ import type { Nullable } from '../types/shared/utils';
3
+ export declare function getResponsiveValue<V extends string | number>(prop: ResponsiveValue<V> | undefined, xsValue: Nullable<V>, valueSetter: (acc: Record<string, V>, bp: any, v: V) => void): Record<string, V>;
@@ -1,5 +1,8 @@
1
1
  export function getResponsiveValue(prop, xsValue, valueSetter) {
2
- const formatted = Object.assign({ xs: xsValue }, typeof prop === "object" ? prop : {});
2
+ const formatted = Object.assign(
3
+ xsValue ? { xs: xsValue } : {},
4
+ typeof prop === "object" ? prop : {}
5
+ );
3
6
  return Object.entries(formatted).reduce((acc, [bp, value]) => {
4
7
  valueSetter(acc, bp, value);
5
8
  return acc;
@@ -0,0 +1,79 @@
1
+ import type { DebouncedFunc, DebouncedFuncLeading } from '../debounce/compat';
2
+ interface ThrottleSettings {
3
+ /**
4
+ * If `true`, the function will be invoked on the leading edge of the timeout.
5
+ * @default true
6
+ */
7
+ leading?: boolean | undefined;
8
+ /**
9
+ * If `true`, the function will be invoked on the trailing edge of the timeout.
10
+ * @default true
11
+ */
12
+ trailing?: boolean | undefined;
13
+ }
14
+ type ThrottleSettingsLeading = (ThrottleSettings & {
15
+ leading: true;
16
+ }) | Omit<ThrottleSettings, 'leading'>;
17
+ /**
18
+ * Creates a throttled function that only invokes the provided function at most once
19
+ * per every `throttleMs` milliseconds. Subsequent calls to the throttled function
20
+ * within the wait time will not trigger the execution of the original function.
21
+ *
22
+ * @template F - The type of function.
23
+ * @param {F} func - The function to throttle.
24
+ * @param {number} throttleMs - The number of milliseconds to throttle executions to.
25
+ * @param {ThrottleOptions} options - The options object
26
+ * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the throttled function.
27
+ * @param {boolean} options.leading - If `true`, the function will be invoked on the leading edge of the timeout.
28
+ * @param {boolean} options.trailing - If `true`, the function will be invoked on the trailing edge of the timeout.
29
+ * @returns {(...args: Parameters<F>) => void} A new throttled function that accepts the same parameters as the original function.
30
+ *
31
+ * @example
32
+ * const throttledFunction = throttle(() => {
33
+ * console.log('Function executed');
34
+ * }, 1000);
35
+ *
36
+ * // Will log 'Function executed' immediately
37
+ * throttledFunction();
38
+ *
39
+ * // Will not log anything as it is within the throttle time
40
+ * throttledFunction();
41
+ *
42
+ * // After 1 second
43
+ * setTimeout(() => {
44
+ * throttledFunction(); // Will log 'Function executed'
45
+ * }, 1000);
46
+ */
47
+ export declare function throttle<T extends (...args: any) => any>(func: T, throttleMs?: number, options?: ThrottleSettingsLeading): DebouncedFuncLeading<T>;
48
+ /**
49
+ * Creates a throttled function that only invokes the provided function at most once
50
+ * per every `throttleMs` milliseconds. Subsequent calls to the throttled function
51
+ * within the wait time will not trigger the execution of the original function.
52
+ *
53
+ * @template F - The type of function.
54
+ * @param {F} func - The function to throttle.
55
+ * @param {number} throttleMs - The number of milliseconds to throttle executions to.
56
+ * @param {ThrottleOptions} options - The options object
57
+ * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the throttled function.
58
+ * @param {boolean} options.leading - If `true`, the function will be invoked on the leading edge of the timeout.
59
+ * @param {boolean} options.trailing - If `true`, the function will be invoked on the trailing edge of the timeout.
60
+ * @returns {(...args: Parameters<F>) => void} A new throttled function that accepts the same parameters as the original function.
61
+ *
62
+ * @example
63
+ * const throttledFunction = throttle(() => {
64
+ * console.log('Function executed');
65
+ * }, 1000);
66
+ *
67
+ * // Will log 'Function executed' immediately
68
+ * throttledFunction();
69
+ *
70
+ * // Will not log anything as it is within the throttle time
71
+ * throttledFunction();
72
+ *
73
+ * // After 1 second
74
+ * setTimeout(() => {
75
+ * throttledFunction(); // Will log 'Function executed'
76
+ * }, 1000);
77
+ */
78
+ export declare function throttle<T extends (...args: any) => any>(func: T, throttleMs?: number, options?: ThrottleSettings): DebouncedFunc<T>;
79
+ export {};
@@ -0,0 +1,9 @@
1
+ import { debounce } from "../debounce/compat.js";
2
+ export function throttle(func, throttleMs = 0, options = {}) {
3
+ const { leading = true, trailing = true } = options;
4
+ return debounce(func, throttleMs, {
5
+ leading,
6
+ maxWait: throttleMs,
7
+ trailing
8
+ });
9
+ }
@@ -0,0 +1,53 @@
1
+ import type { Callback } from '../../types/shared';
2
+ interface ThrottleOptions {
3
+ /**
4
+ * An optional AbortSignal to cancel the debounced function.
5
+ */
6
+ signal?: AbortSignal;
7
+ /**
8
+ * An optional array specifying whether the function should be invoked on the leading edge, trailing edge, or both.
9
+ * If `edges` includes "leading", the function will be invoked at the start of the delay period.
10
+ * If `edges` includes "trailing", the function will be invoked at the end of the delay period.
11
+ * If both "leading" and "trailing" are included, the function will be invoked at both the start and end of the delay period.
12
+ * @default ["leading", "trailing"]
13
+ */
14
+ edges?: Array<'leading' | 'trailing'>;
15
+ }
16
+ export interface ThrottledFunction<F extends (...args: any[]) => void> {
17
+ (...args: Parameters<F>): void;
18
+ cancel: () => void;
19
+ flush: () => void;
20
+ }
21
+ /**
22
+ * Creates a throttled function that only invokes the provided function at most once
23
+ * per every `throttleMs` milliseconds. Subsequent calls to the throttled function
24
+ * within the wait time will not trigger the execution of the original function.
25
+ *
26
+ * @template F - The type of function.
27
+ * @param {F} func - The function to throttle.
28
+ * @param {number} throttleMs - The number of milliseconds to throttle executions to.
29
+ * @returns {(...args: Parameters<F>) => void} A new throttled function that accepts the same parameters as the original function.
30
+ *
31
+ * @example
32
+ * const throttledFunction = throttle(() => {
33
+ * console.log('Function executed');
34
+ * }, 1000);
35
+ *
36
+ * // Will log 'Function executed' immediately
37
+ * throttledFunction();
38
+ *
39
+ * // Will not log anything as it is within the throttle time
40
+ * throttledFunction();
41
+ *
42
+ * // After 1 second
43
+ * setTimeout(() => {
44
+ * throttledFunction(); // Will log 'Function executed'
45
+ * }, 1000);
46
+ */
47
+ export declare function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number, { signal, edges }?: ThrottleOptions): ThrottledFunction<F>;
48
+ interface ThrottleByRafReturnType<T extends Callback> {
49
+ (...args: Parameters<T>): void;
50
+ cancel: () => void;
51
+ }
52
+ export declare function throttleByRaf<T extends Callback>(callback: T): ThrottleByRafReturnType<T>;
53
+ export {};
@@ -0,0 +1,34 @@
1
+ import { debounce } from "../debounce/index.js";
2
+ export function throttle(func, throttleMs, { signal, edges = ["leading", "trailing"] } = {}) {
3
+ let pendingAt = null;
4
+ const debounced = debounce(func, throttleMs, { signal, edges });
5
+ const throttled = function(...args) {
6
+ if (pendingAt == null) {
7
+ pendingAt = Date.now();
8
+ } else {
9
+ if (Date.now() - pendingAt >= throttleMs) {
10
+ pendingAt = Date.now();
11
+ debounced.cancel();
12
+ }
13
+ }
14
+ debounced(...args);
15
+ };
16
+ throttled.cancel = debounced.cancel;
17
+ throttled.flush = debounced.flush;
18
+ return throttled;
19
+ }
20
+ export function throttleByRaf(callback) {
21
+ let timer;
22
+ const throttle2 = (...args) => {
23
+ timer && window.cancelAnimationFrame(timer);
24
+ timer = window.requestAnimationFrame(() => {
25
+ callback(...args);
26
+ timer = 0;
27
+ });
28
+ };
29
+ throttle2.cancel = () => {
30
+ window.cancelAnimationFrame(timer);
31
+ timer = 0;
32
+ };
33
+ return throttle2;
34
+ }
@@ -1,53 +1 @@
1
- import type { Callback } from '../types/shared';
2
- interface ThrottleOptions {
3
- /**
4
- * An optional AbortSignal to cancel the debounced function.
5
- */
6
- signal?: AbortSignal;
7
- /**
8
- * An optional array specifying whether the function should be invoked on the leading edge, trailing edge, or both.
9
- * If `edges` includes "leading", the function will be invoked at the start of the delay period.
10
- * If `edges` includes "trailing", the function will be invoked at the end of the delay period.
11
- * If both "leading" and "trailing" are included, the function will be invoked at both the start and end of the delay period.
12
- * @default ["leading", "trailing"]
13
- */
14
- edges?: Array<'leading' | 'trailing'>;
15
- }
16
- export interface ThrottledFunction<F extends (...args: any[]) => void> {
17
- (...args: Parameters<F>): void;
18
- cancel: () => void;
19
- flush: () => void;
20
- }
21
- /**
22
- * Creates a throttled function that only invokes the provided function at most once
23
- * per every `throttleMs` milliseconds. Subsequent calls to the throttled function
24
- * within the wait time will not trigger the execution of the original function.
25
- *
26
- * @template F - The type of function.
27
- * @param {F} func - The function to throttle.
28
- * @param {number} throttleMs - The number of milliseconds to throttle executions to.
29
- * @returns {(...args: Parameters<F>) => void} A new throttled function that accepts the same parameters as the original function.
30
- *
31
- * @example
32
- * const throttledFunction = throttle(() => {
33
- * console.log('Function executed');
34
- * }, 1000);
35
- *
36
- * // Will log 'Function executed' immediately
37
- * throttledFunction();
38
- *
39
- * // Will not log anything as it is within the throttle time
40
- * throttledFunction();
41
- *
42
- * // After 1 second
43
- * setTimeout(() => {
44
- * throttledFunction(); // Will log 'Function executed'
45
- * }, 1000);
46
- */
47
- export declare function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number, { signal, edges }?: ThrottleOptions): ThrottledFunction<F>;
48
- interface ThrottleByRafReturnType<T extends Callback> {
49
- (...args: Parameters<T>): void;
50
- cancel: () => void;
51
- }
52
- export declare function throttleByRaf<T extends Callback>(callback: T): ThrottleByRafReturnType<T>;
53
- export {};
1
+ export * from './throttle/index';
@@ -1,34 +1 @@
1
- import { debounce } from "./debounce.js";
2
- export function throttle(func, throttleMs, { signal, edges = ["leading", "trailing"] } = {}) {
3
- let pendingAt = null;
4
- const debounced = debounce(func, throttleMs, { signal, edges });
5
- const throttled = function(...args) {
6
- if (pendingAt == null) {
7
- pendingAt = Date.now();
8
- } else {
9
- if (Date.now() - pendingAt >= throttleMs) {
10
- pendingAt = Date.now();
11
- debounced.cancel();
12
- }
13
- }
14
- debounced(...args);
15
- };
16
- throttled.cancel = debounced.cancel;
17
- throttled.flush = debounced.flush;
18
- return throttled;
19
- }
20
- export function throttleByRaf(callback) {
21
- let timer;
22
- const throttle2 = (...args) => {
23
- timer && window.cancelAnimationFrame(timer);
24
- timer = window.requestAnimationFrame(() => {
25
- callback(...args);
26
- timer = 0;
27
- });
28
- };
29
- throttle2.cancel = () => {
30
- window.cancelAnimationFrame(timer);
31
- timer = 0;
32
- };
33
- return throttle2;
34
- }
1
+ export * from "./throttle/index.js";
package/dist/utils/uid.js CHANGED
@@ -1,4 +1,4 @@
1
1
  let _id = 0;
2
2
  export function getUniqueId() {
3
- return `pxd_${_id++}`;
3
+ return `_pid_${_id++}`;
4
4
  }