@rotki/ui-library 3.0.0-beta.1 → 3.0.0-beta.3

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 (156) hide show
  1. package/dist/components/accordions/accordion/RuiAccordion.vue_vue_type_script_setup_true_lang.js +3 -3
  2. package/dist/components/accordions/accordion/RuiAccordion.vue_vue_type_script_setup_true_lang.js.map +1 -1
  3. package/dist/components/accordions/accordions/RuiAccordions.vue_vue_type_script_setup_true_lang.js +1 -1
  4. package/dist/components/avatars/RuiAvatar.vue_vue_type_script_setup_true_lang.js +1 -1
  5. package/dist/components/avatars/RuiAvatarGroup.vue_vue_type_script_setup_true_lang.js +1 -1
  6. package/dist/components/buttons/button/RuiButton.js.map +1 -1
  7. package/dist/components/buttons/button/RuiButton.vue_vue_type_script_setup_true_lang.js +10 -10
  8. package/dist/components/buttons/button/RuiButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  9. package/dist/components/buttons/button/button-styles.js +10 -2
  10. package/dist/components/buttons/button/button-styles.js.map +1 -1
  11. package/dist/components/buttons/button-group/RuiButtonGroup.vue_vue_type_script_setup_true_lang.js +1 -1
  12. package/dist/components/calendar/RuiCalendar.vue_vue_type_script_setup_true_lang.js +1 -1
  13. package/dist/components/calendar/RuiCalendarGrid.vue_vue_type_script_setup_true_lang.js +1 -1
  14. package/dist/components/calendar/RuiCalendarHeader.vue_vue_type_script_setup_true_lang.js +1 -1
  15. package/dist/components/calendar/RuiCalendarMenu.vue_vue_type_script_setup_true_lang.js +1 -1
  16. package/dist/components/chips/RuiChip.vue_vue_type_script_setup_true_lang.js +1 -1
  17. package/dist/components/color-picker/RuiColorBoard.vue_vue_type_script_setup_true_lang.js +1 -1
  18. package/dist/components/color-picker/RuiColorDisplay.vue_vue_type_script_setup_true_lang.js +1 -1
  19. package/dist/components/color-picker/RuiColorHue.vue_vue_type_script_setup_true_lang.js +1 -1
  20. package/dist/components/color-picker/RuiColorInput.vue_vue_type_script_setup_true_lang.js +9 -10
  21. package/dist/components/color-picker/RuiColorInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
  22. package/dist/components/color-picker/RuiColorPicker.vue_vue_type_script_setup_true_lang.js +3 -4
  23. package/dist/components/color-picker/RuiColorPicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
  24. package/dist/components/date-time-picker/RuiDateTimePicker.vue_vue_type_script_setup_true_lang.js +33 -33
  25. package/dist/components/date-time-picker/RuiDateTimePicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
  26. package/dist/components/date-time-picker/use-date-bounds.js +1 -1
  27. package/dist/components/date-time-picker/use-date-time-selection.js +65 -66
  28. package/dist/components/date-time-picker/use-date-time-selection.js.map +1 -1
  29. package/dist/components/date-time-picker/use-input-handler.js +1 -1
  30. package/dist/components/date-time-picker/use-keyboard-handler.js +29 -30
  31. package/dist/components/date-time-picker/use-keyboard-handler.js.map +1 -1
  32. package/dist/components/forms/auto-complete/RuiAutoComplete.js.map +1 -1
  33. package/dist/components/forms/auto-complete/RuiAutoComplete.vue_vue_type_script_setup_true_lang.js +25 -24
  34. package/dist/components/forms/auto-complete/RuiAutoComplete.vue_vue_type_script_setup_true_lang.js.map +1 -1
  35. package/dist/components/forms/auto-complete/auto-complete-styles.d.ts +3 -53
  36. package/dist/components/forms/auto-complete/auto-complete-styles.js +2 -1
  37. package/dist/components/forms/auto-complete/auto-complete-styles.js.map +1 -1
  38. package/dist/components/forms/category-picker/RuiCategoryPicker.vue_vue_type_script_setup_true_lang.js +49 -49
  39. package/dist/components/forms/category-picker/RuiCategoryPicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
  40. package/dist/components/forms/checkbox/RuiCheckbox.vue_vue_type_script_setup_true_lang.js +1 -1
  41. package/dist/components/forms/checkbox/checkbox-group/RuiCheckboxGroup.vue_vue_type_script_setup_true_lang.js +1 -1
  42. package/dist/components/forms/file-upload/RuiFileUpload.js.map +1 -1
  43. package/dist/components/forms/file-upload/RuiFileUpload.vue_vue_type_script_setup_true_lang.js +19 -17
  44. package/dist/components/forms/file-upload/RuiFileUpload.vue_vue_type_script_setup_true_lang.js.map +1 -1
  45. package/dist/components/forms/radio-button/radio/RuiRadio.vue_vue_type_script_setup_true_lang.js +1 -1
  46. package/dist/components/forms/select/RuiMenuSelect.vue_vue_type_script_setup_true_lang.js +11 -11
  47. package/dist/components/forms/select/RuiMenuSelect.vue_vue_type_script_setup_true_lang.js.map +1 -1
  48. package/dist/components/forms/slider/RuiSlider.vue_vue_type_script_setup_true_lang.js +17 -17
  49. package/dist/components/forms/slider/RuiSlider.vue_vue_type_script_setup_true_lang.js.map +1 -1
  50. package/dist/components/forms/switch/RuiSwitch.vue_vue_type_script_setup_true_lang.js +1 -1
  51. package/dist/components/forms/text-area/RuiTextArea.vue_vue_type_script_setup_true_lang.js +21 -21
  52. package/dist/components/forms/text-area/RuiTextArea.vue_vue_type_script_setup_true_lang.js.map +1 -1
  53. package/dist/components/forms/text-field/RuiTextField.js.map +1 -1
  54. package/dist/components/forms/text-field/RuiTextField.vue.d.ts +2 -0
  55. package/dist/components/forms/text-field/RuiTextField.vue_vue_type_script_setup_true_lang.js +24 -20
  56. package/dist/components/forms/text-field/RuiTextField.vue_vue_type_script_setup_true_lang.js.map +1 -1
  57. package/dist/components/forms/text-input-styles.js +1 -1
  58. package/dist/components/forms/text-input-styles.js.map +1 -1
  59. package/dist/components/helpers/RuiFormTextDetail.js.map +1 -1
  60. package/dist/components/helpers/RuiFormTextDetail.vue.d.ts +11 -1
  61. package/dist/components/helpers/RuiFormTextDetail.vue_vue_type_script_setup_true_lang.js +3 -3
  62. package/dist/components/helpers/RuiFormTextDetail.vue_vue_type_script_setup_true_lang.js.map +1 -1
  63. package/dist/components/icons/RuiIcon.vue_vue_type_script_setup_true_lang.js +1 -1
  64. package/dist/components/logos/RuiLogo.vue_vue_type_script_setup_true_lang.js +1 -1
  65. package/dist/components/overlays/badge/RuiBadge.vue_vue_type_script_setup_true_lang.js +1 -1
  66. package/dist/components/overlays/dialog/RuiDialog.vue_vue_type_script_setup_true_lang.js +1 -1
  67. package/dist/components/overlays/menu/RuiMenu.vue_vue_type_script_setup_true_lang.js +17 -17
  68. package/dist/components/overlays/menu/RuiMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  69. package/dist/components/overlays/navigation-drawer/RuiNavigationDrawer.js.map +1 -1
  70. package/dist/components/overlays/navigation-drawer/RuiNavigationDrawer.vue_vue_type_script_setup_true_lang.js +9 -9
  71. package/dist/components/overlays/navigation-drawer/RuiNavigationDrawer.vue_vue_type_script_setup_true_lang.js.map +1 -1
  72. package/dist/components/overlays/notification/RuiNotification.vue_vue_type_script_setup_true_lang.js +3 -4
  73. package/dist/components/overlays/notification/RuiNotification.vue_vue_type_script_setup_true_lang.js.map +1 -1
  74. package/dist/components/overlays/tooltip/RuiTooltip.vue_vue_type_script_setup_true_lang.js +1 -1
  75. package/dist/components/progress/RuiProgress.vue_vue_type_script_setup_true_lang.js +1 -1
  76. package/dist/components/steppers/RuiFooterStepper.vue_vue_type_script_setup_true_lang.js +1 -1
  77. package/dist/components/steppers/RuiStepper.js.map +1 -1
  78. package/dist/components/steppers/RuiStepper.vue_vue_type_script_setup_true_lang.js +13 -8
  79. package/dist/components/steppers/RuiStepper.vue_vue_type_script_setup_true_lang.js.map +1 -1
  80. package/dist/components/tables/RuiDataTable.vue_vue_type_script_setup_true_lang.js +27 -27
  81. package/dist/components/tables/RuiDataTable.vue_vue_type_script_setup_true_lang.js.map +1 -1
  82. package/dist/components/tables/RuiTableHead.vue_vue_type_script_setup_true_lang.js +1 -1
  83. package/dist/components/tables/RuiTablePagination.vue_vue_type_script_setup_true_lang.js +1 -1
  84. package/dist/components/tables/data-table/RuiDataTableCell.vue_vue_type_script_setup_true_lang.js +1 -1
  85. package/dist/components/tables/data-table/RuiDataTableGroupRow.vue_vue_type_script_setup_true_lang.js +1 -1
  86. package/dist/components/tables/data-table/RuiDataTableMobileSort.vue_vue_type_script_setup_true_lang.js +1 -1
  87. package/dist/components/tables/data-table/RuiDataTableRow.vue_vue_type_script_setup_true_lang.js +23 -23
  88. package/dist/components/tables/data-table/RuiDataTableRow.vue_vue_type_script_setup_true_lang.js.map +1 -1
  89. package/dist/components/tables/use-pagination-navigation.js +1 -1
  90. package/dist/components/tabs/tab/RuiTab.vue_vue_type_script_setup_true_lang.js +1 -1
  91. package/dist/components/tabs/tab/use-tab-link.js +1 -1
  92. package/dist/components/tabs/tab-items/RuiTabItems.vue_vue_type_script_setup_true_lang.js +6 -6
  93. package/dist/components/tabs/tab-items/RuiTabItems.vue_vue_type_script_setup_true_lang.js.map +1 -1
  94. package/dist/components/tabs/tabs/RuiTabs.vue_vue_type_script_setup_true_lang.js +11 -12
  95. package/dist/components/tabs/tabs/RuiTabs.vue_vue_type_script_setup_true_lang.js.map +1 -1
  96. package/dist/components/tabs/tabs/use-tab-indicator.js +7 -7
  97. package/dist/components/tabs/tabs/use-tab-indicator.js.map +1 -1
  98. package/dist/components/tabs/tabs/use-tab-keyboard.js +1 -1
  99. package/dist/components/tabs/tabs/use-tab-scroll.js +15 -15
  100. package/dist/components/tabs/tabs/use-tab-scroll.js.map +1 -1
  101. package/dist/components/time-picker/RuiTimePicker.vue_vue_type_script_setup_true_lang.js +60 -61
  102. package/dist/components/time-picker/RuiTimePicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
  103. package/dist/composables/breakpoint.js +3 -3
  104. package/dist/composables/breakpoint.js.map +1 -1
  105. package/dist/composables/dropdown-menu.d.ts +9 -9
  106. package/dist/composables/dropdown-menu.js +32 -32
  107. package/dist/composables/dropdown-menu.js.map +1 -1
  108. package/dist/composables/floating.d.ts +1 -1
  109. package/dist/composables/floating.js +11 -11
  110. package/dist/composables/floating.js.map +1 -1
  111. package/dist/composables/forms/auto-complete/focus.js +16 -17
  112. package/dist/composables/forms/auto-complete/focus.js.map +1 -1
  113. package/dist/composables/forms/auto-complete/keyboard-navigation.js +1 -1
  114. package/dist/composables/forms/auto-complete/search.js +6 -7
  115. package/dist/composables/forms/auto-complete/search.js.map +1 -1
  116. package/dist/composables/forms/auto-complete/selection.js +1 -1
  117. package/dist/composables/forms/auto-complete/value.js +1 -1
  118. package/dist/composables/forms/category-picker/use-category-picker.js +1 -1
  119. package/dist/composables/forms/use-prepend-append-width.js +6 -6
  120. package/dist/composables/forms/use-prepend-append-width.js.map +1 -1
  121. package/dist/composables/keyboard-scroll.js +5 -5
  122. package/dist/composables/keyboard-scroll.js.map +1 -1
  123. package/dist/composables/overlay-stack.js +1 -1
  124. package/dist/composables/sticky-header.js +8 -8
  125. package/dist/composables/sticky-header.js.map +1 -1
  126. package/dist/composables/tables/data-table/columns.js +1 -1
  127. package/dist/composables/tables/data-table/expansion.js +1 -1
  128. package/dist/composables/tables/data-table/grouping.js +27 -28
  129. package/dist/composables/tables/data-table/grouping.js.map +1 -1
  130. package/dist/composables/tables/data-table/page-scroll.d.ts +7 -5
  131. package/dist/composables/tables/data-table/page-scroll.js +48 -17
  132. package/dist/composables/tables/data-table/page-scroll.js.map +1 -1
  133. package/dist/composables/tables/data-table/pagination.js +1 -1
  134. package/dist/composables/tables/data-table/selection.js +37 -38
  135. package/dist/composables/tables/data-table/selection.js.map +1 -1
  136. package/dist/composables/tables/data-table/sort.js +1 -1
  137. package/dist/composables/theme.js +12 -12
  138. package/dist/composables/theme.js.map +1 -1
  139. package/dist/composables/timeout-manager.js +1 -1
  140. package/dist/index.d.ts +2 -2
  141. package/dist/index.js +2 -2
  142. package/dist/index.js.map +1 -1
  143. package/dist/style.css +6 -18
  144. package/dist/types/dom.d.ts +9 -0
  145. package/dist/types/theme.d.ts +2 -3
  146. package/dist/types/theme.js.map +1 -1
  147. package/dist/utils/form-text-detail.js +1 -1
  148. package/dist/utils/helpers.js +1 -1
  149. package/dist/vendor/@vueuse/core/dist/index.js +1577 -0
  150. package/dist/vendor/@vueuse/core/dist/index.js.map +1 -0
  151. package/dist/vendor/@vueuse/shared/dist/index.js +563 -0
  152. package/dist/vendor/@vueuse/shared/dist/index.js.map +1 -0
  153. package/dist/vite-plugin/index.js +5 -6
  154. package/dist/vite-plugin/index.js.map +1 -1
  155. package/dist/web-types.json +9 -2
  156. package/package.json +5 -4
@@ -0,0 +1,563 @@
1
+ import { computed, customRef, effectScope, getCurrentInstance, getCurrentScope, hasInjectionContext, inject, isRef, nextTick, onMounted, onScopeDispose, readonly, ref, shallowReadonly, shallowRef, toRef, toValue, unref, watch } from "vue";
2
+ //#region vendor/@vueuse/shared/dist/index.js
3
+ /**
4
+ * Call onScopeDispose() if it's inside an effect scope lifecycle, if not, do nothing
5
+ *
6
+ * @param fn
7
+ */
8
+ function tryOnScopeDispose(fn, failSilently) {
9
+ if (getCurrentScope()) {
10
+ onScopeDispose(fn, failSilently);
11
+ return true;
12
+ }
13
+ return false;
14
+ }
15
+ var localProvidedStateMap = /* @__PURE__ */ new WeakMap();
16
+ /**
17
+ * On the basis of `inject`, it is allowed to directly call inject to obtain the value after call provide in the same component.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * injectLocal('MyInjectionKey', 1)
22
+ * const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1
23
+ * ```
24
+ *
25
+ * @__NO_SIDE_EFFECTS__
26
+ */
27
+ var injectLocal = (...args) => {
28
+ var _getCurrentInstance;
29
+ const key = args[0];
30
+ const instance = (_getCurrentInstance = getCurrentInstance()) === null || _getCurrentInstance === void 0 ? void 0 : _getCurrentInstance.proxy;
31
+ const owner = instance !== null && instance !== void 0 ? instance : getCurrentScope();
32
+ if (owner == null && !hasInjectionContext()) throw new Error("injectLocal must be called in setup");
33
+ if (owner && localProvidedStateMap.has(owner) && key in localProvidedStateMap.get(owner)) return localProvidedStateMap.get(owner)[key];
34
+ return inject(...args);
35
+ };
36
+ var isClient = typeof window !== "undefined" && typeof document !== "undefined";
37
+ typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
38
+ var notNullish = (val) => val != null;
39
+ var toString = Object.prototype.toString;
40
+ var isObject = (val) => toString.call(val) === "[object Object]";
41
+ var clamp = (n, min, max) => Math.min(max, Math.max(min, n));
42
+ var noop = () => {};
43
+ var isIOS = /* #__PURE__ */ getIsIOS();
44
+ function getIsIOS() {
45
+ var _window, _window2, _window3;
46
+ return isClient && !!((_window = window) === null || _window === void 0 || (_window = _window.navigator) === null || _window === void 0 ? void 0 : _window.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.navigator) === null || _window2 === void 0 ? void 0 : _window2.maxTouchPoints) > 2 && /iPad|Macintosh/.test((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.navigator.userAgent));
47
+ }
48
+ function toRef$1(...args) {
49
+ if (args.length !== 1) return toRef(...args);
50
+ const r = args[0];
51
+ return typeof r === "function" ? readonly(customRef(() => ({
52
+ get: r,
53
+ set: noop
54
+ }))) : ref(r);
55
+ }
56
+ function createFilterWrapper(filter, fn) {
57
+ function wrapper(...args) {
58
+ return new Promise((resolve, reject) => {
59
+ Promise.resolve(filter(() => fn.apply(this, args), {
60
+ fn,
61
+ thisArg: this,
62
+ args
63
+ })).then(resolve).catch(reject);
64
+ });
65
+ }
66
+ if ("cancel" in filter) Object.assign(wrapper, {
67
+ cancel: filter.cancel,
68
+ flush: filter.flush,
69
+ isPending: filter.isPending
70
+ });
71
+ return wrapper;
72
+ }
73
+ var bypassFilter = (invoke) => {
74
+ return invoke();
75
+ };
76
+ /**
77
+ * Create an EventFilter that debounce the events
78
+ */
79
+ function debounceFilter(ms, options = {}) {
80
+ let timer;
81
+ let maxTimer;
82
+ let lastRejector = noop;
83
+ let lastResolve = noop;
84
+ const _pending = shallowRef(false);
85
+ const _clearTimeout = (timer) => {
86
+ clearTimeout(timer);
87
+ lastRejector();
88
+ lastRejector = noop;
89
+ };
90
+ let lastInvoker;
91
+ const handler = (invoke) => {
92
+ const duration = toValue(ms);
93
+ const maxDuration = toValue(options.maxWait);
94
+ if (timer) _clearTimeout(timer);
95
+ if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
96
+ if (maxTimer) {
97
+ _clearTimeout(maxTimer);
98
+ maxTimer = void 0;
99
+ }
100
+ _pending.value = false;
101
+ return Promise.resolve(invoke());
102
+ }
103
+ _pending.value = true;
104
+ return new Promise((resolve, reject) => {
105
+ lastRejector = options.rejectOnCancel ? reject : resolve;
106
+ lastResolve = resolve;
107
+ lastInvoker = invoke;
108
+ if (maxDuration && !maxTimer) maxTimer = setTimeout(() => {
109
+ if (timer) _clearTimeout(timer);
110
+ maxTimer = void 0;
111
+ _pending.value = false;
112
+ resolve(lastInvoker());
113
+ }, maxDuration);
114
+ timer = setTimeout(() => {
115
+ if (maxTimer) _clearTimeout(maxTimer);
116
+ maxTimer = void 0;
117
+ _pending.value = false;
118
+ resolve(invoke());
119
+ }, duration);
120
+ });
121
+ };
122
+ return Object.assign(handler, {
123
+ cancel: () => {
124
+ if (timer) {
125
+ _clearTimeout(timer);
126
+ timer = void 0;
127
+ }
128
+ if (maxTimer) {
129
+ _clearTimeout(maxTimer);
130
+ maxTimer = void 0;
131
+ }
132
+ _pending.value = false;
133
+ lastResolve = noop;
134
+ },
135
+ flush: () => {
136
+ if (_pending.value) {
137
+ if (timer) {
138
+ clearTimeout(timer);
139
+ timer = void 0;
140
+ }
141
+ if (maxTimer) {
142
+ clearTimeout(maxTimer);
143
+ maxTimer = void 0;
144
+ }
145
+ _pending.value = false;
146
+ const resolve = lastResolve;
147
+ lastRejector = noop;
148
+ lastResolve = noop;
149
+ resolve(lastInvoker());
150
+ }
151
+ },
152
+ isPending: shallowReadonly(_pending)
153
+ });
154
+ }
155
+ function throttleFilter(...args) {
156
+ let lastExec = 0;
157
+ let timer;
158
+ let isLeading = true;
159
+ let lastRejector = noop;
160
+ let lastValue;
161
+ let ms;
162
+ let trailing;
163
+ let leading;
164
+ let rejectOnCancel;
165
+ if (!isRef(args[0]) && typeof args[0] === "object") ({delay: ms, trailing = true, leading = true, rejectOnCancel = false} = args[0]);
166
+ else [ms, trailing = true, leading = true, rejectOnCancel = false] = args;
167
+ const clear = () => {
168
+ if (timer) {
169
+ clearTimeout(timer);
170
+ timer = void 0;
171
+ lastRejector();
172
+ lastRejector = noop;
173
+ }
174
+ };
175
+ const filter = (_invoke) => {
176
+ const duration = toValue(ms);
177
+ const elapsed = Date.now() - lastExec;
178
+ const invoke = () => {
179
+ return lastValue = _invoke();
180
+ };
181
+ clear();
182
+ if (duration <= 0) {
183
+ lastExec = Date.now();
184
+ return invoke();
185
+ }
186
+ if (elapsed > duration) {
187
+ lastExec = Date.now();
188
+ if (leading || !isLeading) invoke();
189
+ } else if (trailing) lastValue = new Promise((resolve, reject) => {
190
+ lastRejector = rejectOnCancel ? reject : resolve;
191
+ timer = setTimeout(() => {
192
+ lastExec = Date.now();
193
+ isLeading = true;
194
+ resolve(invoke());
195
+ clear();
196
+ }, Math.max(0, duration - elapsed));
197
+ });
198
+ if (!leading && !timer) timer = setTimeout(() => isLeading = true, duration);
199
+ isLeading = false;
200
+ return lastValue;
201
+ };
202
+ return filter;
203
+ }
204
+ /**
205
+ * EventFilter that gives extra controls to pause and resume the filter
206
+ *
207
+ * @param extendFilter Extra filter to apply when the PausableFilter is active, default to none
208
+ * @param options Options to configure the filter
209
+ */
210
+ function pausableFilter(extendFilter = bypassFilter, options = {}) {
211
+ const { initialState = "active" } = options;
212
+ const isActive = toRef$1(initialState === "active");
213
+ function pause() {
214
+ isActive.value = false;
215
+ }
216
+ function resume() {
217
+ isActive.value = true;
218
+ }
219
+ const eventFilter = (...args) => {
220
+ if (isActive.value) extendFilter(...args);
221
+ };
222
+ return {
223
+ isActive: shallowReadonly(isActive),
224
+ pause,
225
+ resume,
226
+ eventFilter
227
+ };
228
+ }
229
+ /**
230
+ * Create singleton promise function
231
+ *
232
+ * @example
233
+ * ```
234
+ * const promise = createSingletonPromise(async () => { ... })
235
+ *
236
+ * await promise()
237
+ * await promise() // all of them will be bind to a single promise instance
238
+ * await promise() // and be resolved together
239
+ * ```
240
+ */
241
+ function createSingletonPromise(fn) {
242
+ let _promise;
243
+ function wrapper() {
244
+ if (!_promise) _promise = fn();
245
+ return _promise;
246
+ }
247
+ wrapper.reset = async () => {
248
+ const _prev = _promise;
249
+ _promise = void 0;
250
+ if (_prev) await _prev;
251
+ };
252
+ return wrapper;
253
+ }
254
+ function increaseWithUnit(target, delta) {
255
+ var _target$match;
256
+ if (typeof target === "number") return target + delta;
257
+ const value = ((_target$match = target.match(/^-?\d+\.?\d*/)) === null || _target$match === void 0 ? void 0 : _target$match[0]) || "";
258
+ const unit = target.slice(value.length);
259
+ const result = Number.parseFloat(value) + delta;
260
+ if (Number.isNaN(result)) return target;
261
+ return result + unit;
262
+ }
263
+ /**
264
+ * Get a px value for SSR use, do not rely on this method outside of SSR as REM unit is assumed at 16px, which might not be the case on the client
265
+ */
266
+ function pxValue(px) {
267
+ return px.endsWith("rem") ? Number.parseFloat(px) * 16 : Number.parseFloat(px);
268
+ }
269
+ /**
270
+ * Create a new subset object by giving keys
271
+ */
272
+ function objectPick(obj, keys, omitUndefined = false) {
273
+ return keys.reduce((n, k) => {
274
+ if (k in obj) {
275
+ if (!omitUndefined || obj[k] !== void 0) n[k] = obj[k];
276
+ }
277
+ return n;
278
+ }, {});
279
+ }
280
+ /**
281
+ * Create a new subset object by omit giving keys
282
+ */
283
+ function objectOmit(obj, keys, omitUndefined = false) {
284
+ return Object.fromEntries(Object.entries(obj).filter(([key, value]) => {
285
+ return (!omitUndefined || value !== void 0) && !keys.includes(key);
286
+ }));
287
+ }
288
+ function toArray(value) {
289
+ return Array.isArray(value) ? value : [value];
290
+ }
291
+ function getLifeCycleTarget(target) {
292
+ return target || getCurrentInstance();
293
+ }
294
+ /**
295
+ * Make a composable function usable with multiple Vue instances.
296
+ *
297
+ * @see https://vueuse.org/createSharedComposable
298
+ *
299
+ * @__NO_SIDE_EFFECTS__
300
+ */
301
+ function createSharedComposable(composable) {
302
+ if (!isClient) return composable;
303
+ let subscribers = 0;
304
+ let state;
305
+ let scope;
306
+ const dispose = () => {
307
+ subscribers -= 1;
308
+ if (scope && subscribers <= 0) {
309
+ scope.stop();
310
+ state = void 0;
311
+ scope = void 0;
312
+ }
313
+ };
314
+ return ((...args) => {
315
+ subscribers += 1;
316
+ if (!scope) {
317
+ scope = effectScope(true);
318
+ state = scope.run(() => composable(...args));
319
+ }
320
+ tryOnScopeDispose(dispose);
321
+ return state;
322
+ });
323
+ }
324
+ function get(obj, key) {
325
+ if (key == null) return unref(obj);
326
+ return unref(obj)[key];
327
+ }
328
+ function isDefined(v) {
329
+ return unref(v) != null;
330
+ }
331
+ /**
332
+ * Debounce execution of a function.
333
+ *
334
+ * @see https://vueuse.org/useDebounceFn
335
+ * @param fn A function to be executed after delay milliseconds debounced.
336
+ * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
337
+ * @param options Options
338
+ *
339
+ * @return A new, debounced, function with isPending, cancel, and flush properties.
340
+ */
341
+ function useDebounceFn(fn, ms = 200, options = {}) {
342
+ return createFilterWrapper(debounceFilter(ms, options), fn);
343
+ }
344
+ /**
345
+ * Debounce updates of a ref.
346
+ *
347
+ * @return A new debounced ref.
348
+ */
349
+ function refDebounced(value, ms = 200, options = {}) {
350
+ const debounced = ref(toValue(value));
351
+ const updater = useDebounceFn(() => {
352
+ debounced.value = value.value;
353
+ }, ms, options);
354
+ watch(value, () => updater());
355
+ return shallowReadonly(debounced);
356
+ }
357
+ /**
358
+ * Throttle execution of a function. Especially useful for rate limiting
359
+ * execution of handlers on events like resize and scroll.
360
+ *
361
+ * @param fn A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
362
+ * to `callback` when the throttled-function is executed.
363
+ * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
364
+ * (default value: 200)
365
+ *
366
+ * @param [trailing] if true, call fn again after the time is up (default value: false)
367
+ *
368
+ * @param [leading] if true, call fn on the leading edge of the ms timeout (default value: true)
369
+ *
370
+ * @param [rejectOnCancel] if true, reject the last call if it's been cancel (default value: false)
371
+ *
372
+ * @return A new, throttled, function.
373
+ *
374
+ * @__NO_SIDE_EFFECTS__
375
+ */
376
+ function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
377
+ return createFilterWrapper(throttleFilter(ms, trailing, leading, rejectOnCancel), fn);
378
+ }
379
+ /**
380
+ * Shorthand for `ref.value = x`
381
+ */
382
+ function set(...args) {
383
+ if (args.length === 2) {
384
+ const [ref, value] = args;
385
+ ref.value = value;
386
+ }
387
+ if (args.length === 3) {
388
+ const [target, key, value] = args;
389
+ target[key] = value;
390
+ }
391
+ }
392
+ function watchWithFilter(source, cb, options = {}) {
393
+ const { eventFilter = bypassFilter, ...watchOptions } = options;
394
+ return watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
395
+ }
396
+ /** @deprecated Use Vue's built-in `watch` instead. This function will be removed in future version. */
397
+ function watchPausable(source, cb, options = {}) {
398
+ const { eventFilter: filter, initialState = "active", ...watchOptions } = options;
399
+ const { eventFilter, pause, resume, isActive } = pausableFilter(filter, { initialState });
400
+ return {
401
+ stop: watchWithFilter(source, cb, {
402
+ ...watchOptions,
403
+ eventFilter
404
+ }),
405
+ pause,
406
+ resume,
407
+ isActive
408
+ };
409
+ }
410
+ /**
411
+ * Call onMounted() if it's inside a component lifecycle, if not, just call the function
412
+ *
413
+ * @param fn
414
+ * @param sync if set to false, it will run in the nextTick() of Vue
415
+ * @param target
416
+ */
417
+ function tryOnMounted(fn, sync = true, target) {
418
+ if (getLifeCycleTarget(target)) onMounted(fn, target);
419
+ else if (sync) fn();
420
+ else nextTick(fn);
421
+ }
422
+ /**
423
+ * Reactive `Array.map`
424
+ *
425
+ * @see https://vueuse.org/useArrayMap
426
+ * @param list - the array was called upon.
427
+ * @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array.
428
+ *
429
+ * @returns a new array with each element being the result of the callback function.
430
+ *
431
+ * @__NO_SIDE_EFFECTS__
432
+ */
433
+ function useArrayMap(list, fn) {
434
+ return computed(() => toValue(list).map((i) => toValue(i)).map(fn));
435
+ }
436
+ /**
437
+ * Wrapper for `setTimeout` with controls.
438
+ *
439
+ * @param cb
440
+ * @param interval
441
+ * @param options
442
+ */
443
+ function useTimeoutFn(cb, interval, options = {}) {
444
+ const { immediate = true, immediateCallback = false } = options;
445
+ const isPending = shallowRef(false);
446
+ let timer;
447
+ function clear() {
448
+ if (timer) {
449
+ clearTimeout(timer);
450
+ timer = void 0;
451
+ }
452
+ }
453
+ function stop() {
454
+ isPending.value = false;
455
+ clear();
456
+ }
457
+ function start(...args) {
458
+ if (immediateCallback) cb();
459
+ clear();
460
+ isPending.value = true;
461
+ timer = setTimeout(() => {
462
+ isPending.value = false;
463
+ timer = void 0;
464
+ cb(...args);
465
+ }, toValue(interval));
466
+ }
467
+ if (immediate) {
468
+ isPending.value = true;
469
+ if (isClient) start();
470
+ }
471
+ tryOnScopeDispose(stop);
472
+ return {
473
+ isPending: shallowReadonly(isPending),
474
+ start,
475
+ stop
476
+ };
477
+ }
478
+ function watchDebounced(source, cb, options = {}) {
479
+ const { debounce = 0, maxWait = void 0, ...watchOptions } = options;
480
+ return watchWithFilter(source, cb, {
481
+ ...watchOptions,
482
+ eventFilter: debounceFilter(debounce, { maxWait })
483
+ });
484
+ }
485
+ function watchIgnorable(source, cb, options = {}) {
486
+ const { eventFilter = bypassFilter, ...watchOptions } = options;
487
+ const filteredCb = createFilterWrapper(eventFilter, cb);
488
+ let ignoreUpdates;
489
+ let ignorePrevAsyncUpdates;
490
+ let stop;
491
+ if (watchOptions.flush === "sync") {
492
+ let ignore = false;
493
+ ignorePrevAsyncUpdates = () => {};
494
+ ignoreUpdates = (updater) => {
495
+ ignore = true;
496
+ updater();
497
+ ignore = false;
498
+ };
499
+ stop = watch(source, (...args) => {
500
+ if (!ignore) filteredCb(...args);
501
+ }, watchOptions);
502
+ } else {
503
+ const disposables = [];
504
+ let ignoreCounter = 0;
505
+ let syncCounter = 0;
506
+ ignorePrevAsyncUpdates = () => {
507
+ ignoreCounter = syncCounter;
508
+ };
509
+ disposables.push(watch(source, () => {
510
+ syncCounter++;
511
+ }, {
512
+ ...watchOptions,
513
+ flush: "sync"
514
+ }));
515
+ ignoreUpdates = (updater) => {
516
+ const syncCounterPrev = syncCounter;
517
+ updater();
518
+ ignoreCounter += syncCounter - syncCounterPrev;
519
+ };
520
+ disposables.push(watch(source, (...args) => {
521
+ const ignore = ignoreCounter > 0 && ignoreCounter === syncCounter;
522
+ ignoreCounter = 0;
523
+ syncCounter = 0;
524
+ if (ignore) return;
525
+ filteredCb(...args);
526
+ }, watchOptions));
527
+ stop = () => {
528
+ disposables.forEach((fn) => fn());
529
+ };
530
+ }
531
+ return {
532
+ stop,
533
+ ignoreUpdates,
534
+ ignorePrevAsyncUpdates
535
+ };
536
+ }
537
+ /**
538
+ * Shorthand for watching value with {immediate: true}
539
+ *
540
+ * @see https://vueuse.org/watchImmediate
541
+ */
542
+ function watchImmediate(source, cb, options) {
543
+ return watch(source, cb, {
544
+ ...options,
545
+ immediate: true
546
+ });
547
+ }
548
+ function whenever(source, cb, options) {
549
+ const stop = watch(source, (v, ov, onInvalidate) => {
550
+ if (v) {
551
+ if (options === null || options === void 0 ? void 0 : options.once) nextTick(() => stop());
552
+ cb(v, ov, onInvalidate);
553
+ }
554
+ }, {
555
+ ...options,
556
+ once: false
557
+ });
558
+ return stop;
559
+ }
560
+ //#endregion
561
+ export { bypassFilter, clamp, createFilterWrapper, createSharedComposable, createSingletonPromise, debounceFilter, get, getLifeCycleTarget, increaseWithUnit, injectLocal, isClient, isDefined, isIOS, isObject, noop, notNullish, objectOmit, objectPick, pausableFilter, pxValue, refDebounced, set, throttleFilter, toArray, toRef$1 as toRef, tryOnMounted, tryOnScopeDispose, useArrayMap, useDebounceFn, useThrottleFn, useTimeoutFn, watchDebounced, watchIgnorable, watchImmediate, watchPausable, watchWithFilter, whenever };
562
+
563
+ //# sourceMappingURL=index.js.map