@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.
- package/dist/components/accordions/accordion/RuiAccordion.vue_vue_type_script_setup_true_lang.js +3 -3
- package/dist/components/accordions/accordion/RuiAccordion.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/accordions/accordions/RuiAccordions.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/avatars/RuiAvatar.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/avatars/RuiAvatarGroup.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/buttons/button/RuiButton.js.map +1 -1
- package/dist/components/buttons/button/RuiButton.vue_vue_type_script_setup_true_lang.js +10 -10
- package/dist/components/buttons/button/RuiButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/buttons/button/button-styles.js +10 -2
- package/dist/components/buttons/button/button-styles.js.map +1 -1
- package/dist/components/buttons/button-group/RuiButtonGroup.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/calendar/RuiCalendar.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/calendar/RuiCalendarGrid.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/calendar/RuiCalendarHeader.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/calendar/RuiCalendarMenu.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/chips/RuiChip.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/color-picker/RuiColorBoard.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/color-picker/RuiColorDisplay.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/color-picker/RuiColorHue.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/color-picker/RuiColorInput.vue_vue_type_script_setup_true_lang.js +9 -10
- package/dist/components/color-picker/RuiColorInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/color-picker/RuiColorPicker.vue_vue_type_script_setup_true_lang.js +3 -4
- package/dist/components/color-picker/RuiColorPicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/date-time-picker/RuiDateTimePicker.vue_vue_type_script_setup_true_lang.js +33 -33
- package/dist/components/date-time-picker/RuiDateTimePicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/date-time-picker/use-date-bounds.js +1 -1
- package/dist/components/date-time-picker/use-date-time-selection.js +65 -66
- package/dist/components/date-time-picker/use-date-time-selection.js.map +1 -1
- package/dist/components/date-time-picker/use-input-handler.js +1 -1
- package/dist/components/date-time-picker/use-keyboard-handler.js +29 -30
- package/dist/components/date-time-picker/use-keyboard-handler.js.map +1 -1
- package/dist/components/forms/auto-complete/RuiAutoComplete.js.map +1 -1
- package/dist/components/forms/auto-complete/RuiAutoComplete.vue_vue_type_script_setup_true_lang.js +25 -24
- package/dist/components/forms/auto-complete/RuiAutoComplete.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/forms/auto-complete/auto-complete-styles.d.ts +3 -53
- package/dist/components/forms/auto-complete/auto-complete-styles.js +2 -1
- package/dist/components/forms/auto-complete/auto-complete-styles.js.map +1 -1
- package/dist/components/forms/category-picker/RuiCategoryPicker.vue_vue_type_script_setup_true_lang.js +49 -49
- package/dist/components/forms/category-picker/RuiCategoryPicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/forms/checkbox/RuiCheckbox.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/forms/checkbox/checkbox-group/RuiCheckboxGroup.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/forms/file-upload/RuiFileUpload.js.map +1 -1
- package/dist/components/forms/file-upload/RuiFileUpload.vue_vue_type_script_setup_true_lang.js +19 -17
- package/dist/components/forms/file-upload/RuiFileUpload.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/forms/radio-button/radio/RuiRadio.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/forms/select/RuiMenuSelect.vue_vue_type_script_setup_true_lang.js +11 -11
- package/dist/components/forms/select/RuiMenuSelect.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/forms/slider/RuiSlider.vue_vue_type_script_setup_true_lang.js +17 -17
- package/dist/components/forms/slider/RuiSlider.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/forms/switch/RuiSwitch.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/forms/text-area/RuiTextArea.vue_vue_type_script_setup_true_lang.js +21 -21
- package/dist/components/forms/text-area/RuiTextArea.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/forms/text-field/RuiTextField.js.map +1 -1
- package/dist/components/forms/text-field/RuiTextField.vue.d.ts +2 -0
- package/dist/components/forms/text-field/RuiTextField.vue_vue_type_script_setup_true_lang.js +24 -20
- package/dist/components/forms/text-field/RuiTextField.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/forms/text-input-styles.js +1 -1
- package/dist/components/forms/text-input-styles.js.map +1 -1
- package/dist/components/helpers/RuiFormTextDetail.js.map +1 -1
- package/dist/components/helpers/RuiFormTextDetail.vue.d.ts +11 -1
- package/dist/components/helpers/RuiFormTextDetail.vue_vue_type_script_setup_true_lang.js +3 -3
- package/dist/components/helpers/RuiFormTextDetail.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/icons/RuiIcon.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/logos/RuiLogo.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/overlays/badge/RuiBadge.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/overlays/dialog/RuiDialog.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/overlays/menu/RuiMenu.vue_vue_type_script_setup_true_lang.js +17 -17
- package/dist/components/overlays/menu/RuiMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/overlays/navigation-drawer/RuiNavigationDrawer.js.map +1 -1
- package/dist/components/overlays/navigation-drawer/RuiNavigationDrawer.vue_vue_type_script_setup_true_lang.js +9 -9
- package/dist/components/overlays/navigation-drawer/RuiNavigationDrawer.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/overlays/notification/RuiNotification.vue_vue_type_script_setup_true_lang.js +3 -4
- package/dist/components/overlays/notification/RuiNotification.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/overlays/tooltip/RuiTooltip.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/progress/RuiProgress.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/steppers/RuiFooterStepper.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/steppers/RuiStepper.js.map +1 -1
- package/dist/components/steppers/RuiStepper.vue_vue_type_script_setup_true_lang.js +13 -8
- package/dist/components/steppers/RuiStepper.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/tables/RuiDataTable.vue_vue_type_script_setup_true_lang.js +27 -27
- package/dist/components/tables/RuiDataTable.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/tables/RuiTableHead.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/tables/RuiTablePagination.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/tables/data-table/RuiDataTableCell.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/tables/data-table/RuiDataTableGroupRow.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/tables/data-table/RuiDataTableMobileSort.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/tables/data-table/RuiDataTableRow.vue_vue_type_script_setup_true_lang.js +23 -23
- package/dist/components/tables/data-table/RuiDataTableRow.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/tables/use-pagination-navigation.js +1 -1
- package/dist/components/tabs/tab/RuiTab.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/tabs/tab/use-tab-link.js +1 -1
- package/dist/components/tabs/tab-items/RuiTabItems.vue_vue_type_script_setup_true_lang.js +6 -6
- package/dist/components/tabs/tab-items/RuiTabItems.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/tabs/tabs/RuiTabs.vue_vue_type_script_setup_true_lang.js +11 -12
- package/dist/components/tabs/tabs/RuiTabs.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/tabs/tabs/use-tab-indicator.js +7 -7
- package/dist/components/tabs/tabs/use-tab-indicator.js.map +1 -1
- package/dist/components/tabs/tabs/use-tab-keyboard.js +1 -1
- package/dist/components/tabs/tabs/use-tab-scroll.js +15 -15
- package/dist/components/tabs/tabs/use-tab-scroll.js.map +1 -1
- package/dist/components/time-picker/RuiTimePicker.vue_vue_type_script_setup_true_lang.js +60 -61
- package/dist/components/time-picker/RuiTimePicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/composables/breakpoint.js +3 -3
- package/dist/composables/breakpoint.js.map +1 -1
- package/dist/composables/dropdown-menu.d.ts +9 -9
- package/dist/composables/dropdown-menu.js +32 -32
- package/dist/composables/dropdown-menu.js.map +1 -1
- package/dist/composables/floating.d.ts +1 -1
- package/dist/composables/floating.js +11 -11
- package/dist/composables/floating.js.map +1 -1
- package/dist/composables/forms/auto-complete/focus.js +16 -17
- package/dist/composables/forms/auto-complete/focus.js.map +1 -1
- package/dist/composables/forms/auto-complete/keyboard-navigation.js +1 -1
- package/dist/composables/forms/auto-complete/search.js +6 -7
- package/dist/composables/forms/auto-complete/search.js.map +1 -1
- package/dist/composables/forms/auto-complete/selection.js +1 -1
- package/dist/composables/forms/auto-complete/value.js +1 -1
- package/dist/composables/forms/category-picker/use-category-picker.js +1 -1
- package/dist/composables/forms/use-prepend-append-width.js +6 -6
- package/dist/composables/forms/use-prepend-append-width.js.map +1 -1
- package/dist/composables/keyboard-scroll.js +5 -5
- package/dist/composables/keyboard-scroll.js.map +1 -1
- package/dist/composables/overlay-stack.js +1 -1
- package/dist/composables/sticky-header.js +8 -8
- package/dist/composables/sticky-header.js.map +1 -1
- package/dist/composables/tables/data-table/columns.js +1 -1
- package/dist/composables/tables/data-table/expansion.js +1 -1
- package/dist/composables/tables/data-table/grouping.js +27 -28
- package/dist/composables/tables/data-table/grouping.js.map +1 -1
- package/dist/composables/tables/data-table/page-scroll.d.ts +7 -5
- package/dist/composables/tables/data-table/page-scroll.js +48 -17
- package/dist/composables/tables/data-table/page-scroll.js.map +1 -1
- package/dist/composables/tables/data-table/pagination.js +1 -1
- package/dist/composables/tables/data-table/selection.js +37 -38
- package/dist/composables/tables/data-table/selection.js.map +1 -1
- package/dist/composables/tables/data-table/sort.js +1 -1
- package/dist/composables/theme.js +12 -12
- package/dist/composables/theme.js.map +1 -1
- package/dist/composables/timeout-manager.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/style.css +6 -18
- package/dist/types/dom.d.ts +9 -0
- package/dist/types/theme.d.ts +2 -3
- package/dist/types/theme.js.map +1 -1
- package/dist/utils/form-text-detail.js +1 -1
- package/dist/utils/helpers.js +1 -1
- package/dist/vendor/@vueuse/core/dist/index.js +1577 -0
- package/dist/vendor/@vueuse/core/dist/index.js.map +1 -0
- package/dist/vendor/@vueuse/shared/dist/index.js +563 -0
- package/dist/vendor/@vueuse/shared/dist/index.js.map +1 -0
- package/dist/vite-plugin/index.js +5 -6
- package/dist/vite-plugin/index.js.map +1 -1
- package/dist/web-types.json +9 -2
- package/package.json +5 -4
|
@@ -0,0 +1,1577 @@
|
|
|
1
|
+
import { 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 as toRef$1, tryOnMounted, tryOnScopeDispose, useArrayMap, useDebounceFn, useThrottleFn, useTimeoutFn, watchDebounced, watchIgnorable, watchImmediate, watchPausable, watchWithFilter, whenever } from "../../shared/dist/index.js";
|
|
2
|
+
import { computed, getCurrentInstance, hasInjectionContext, nextTick, onMounted, reactive, ref, shallowReadonly, shallowRef, toRaw, toValue, unref, watch, watchEffect } from "vue";
|
|
3
|
+
//#region vendor/@vueuse/core/dist/index.js
|
|
4
|
+
var defaultWindow = isClient ? window : void 0;
|
|
5
|
+
isClient && window.document;
|
|
6
|
+
var defaultNavigator = isClient ? window.navigator : void 0;
|
|
7
|
+
isClient && window.location;
|
|
8
|
+
/**
|
|
9
|
+
* Get the dom element of a ref of element or Vue component instance
|
|
10
|
+
*
|
|
11
|
+
* @param elRef
|
|
12
|
+
*/
|
|
13
|
+
function unrefElement(elRef) {
|
|
14
|
+
var _$el;
|
|
15
|
+
const plain = toValue(elRef);
|
|
16
|
+
return (_$el = plain === null || plain === void 0 ? void 0 : plain.$el) !== null && _$el !== void 0 ? _$el : plain;
|
|
17
|
+
}
|
|
18
|
+
function useEventListener(...args) {
|
|
19
|
+
const register = (el, event, listener, options) => {
|
|
20
|
+
el.addEventListener(event, listener, options);
|
|
21
|
+
return () => el.removeEventListener(event, listener, options);
|
|
22
|
+
};
|
|
23
|
+
const firstParamTargets = computed(() => {
|
|
24
|
+
const test = toArray(toValue(args[0])).filter((e) => e != null);
|
|
25
|
+
return test.every((e) => typeof e !== "string") ? test : void 0;
|
|
26
|
+
});
|
|
27
|
+
return watchImmediate(() => {
|
|
28
|
+
var _firstParamTargets$va, _firstParamTargets$va2;
|
|
29
|
+
return [
|
|
30
|
+
(_firstParamTargets$va = (_firstParamTargets$va2 = firstParamTargets.value) === null || _firstParamTargets$va2 === void 0 ? void 0 : _firstParamTargets$va2.map((e) => unrefElement(e))) !== null && _firstParamTargets$va !== void 0 ? _firstParamTargets$va : [defaultWindow].filter((e) => e != null),
|
|
31
|
+
toArray(toValue(firstParamTargets.value ? args[1] : args[0])),
|
|
32
|
+
toArray(unref(firstParamTargets.value ? args[2] : args[1])),
|
|
33
|
+
toValue(firstParamTargets.value ? args[3] : args[2])
|
|
34
|
+
];
|
|
35
|
+
}, ([raw_targets, raw_events, raw_listeners, raw_options], _, onCleanup) => {
|
|
36
|
+
if (!(raw_targets === null || raw_targets === void 0 ? void 0 : raw_targets.length) || !(raw_events === null || raw_events === void 0 ? void 0 : raw_events.length) || !(raw_listeners === null || raw_listeners === void 0 ? void 0 : raw_listeners.length)) return;
|
|
37
|
+
const optionsClone = isObject(raw_options) ? { ...raw_options } : raw_options;
|
|
38
|
+
const cleanups = raw_targets.flatMap((el) => raw_events.flatMap((event) => raw_listeners.map((listener) => register(el, event, listener, optionsClone))));
|
|
39
|
+
onCleanup(() => {
|
|
40
|
+
cleanups.forEach((fn) => fn());
|
|
41
|
+
});
|
|
42
|
+
}, { flush: "post" });
|
|
43
|
+
}
|
|
44
|
+
var _iOSWorkaround = false;
|
|
45
|
+
function onClickOutside(target, handler, options = {}) {
|
|
46
|
+
const { window = defaultWindow, ignore = [], capture = true, detectIframe = false, controls = false } = options;
|
|
47
|
+
if (!window) return controls ? {
|
|
48
|
+
stop: noop,
|
|
49
|
+
cancel: noop,
|
|
50
|
+
trigger: noop
|
|
51
|
+
} : noop;
|
|
52
|
+
if (isIOS && !_iOSWorkaround) {
|
|
53
|
+
_iOSWorkaround = true;
|
|
54
|
+
const listenerOptions = { passive: true };
|
|
55
|
+
Array.from(window.document.body.children).forEach((el) => el.addEventListener("click", noop, listenerOptions));
|
|
56
|
+
window.document.documentElement.addEventListener("click", noop, listenerOptions);
|
|
57
|
+
}
|
|
58
|
+
let shouldListen = true;
|
|
59
|
+
const shouldIgnore = (event) => {
|
|
60
|
+
return toValue(ignore).some((target) => {
|
|
61
|
+
if (typeof target === "string") return Array.from(window.document.querySelectorAll(target)).some((el) => el === event.target || event.composedPath().includes(el));
|
|
62
|
+
else {
|
|
63
|
+
const el = unrefElement(target);
|
|
64
|
+
return el && (event.target === el || event.composedPath().includes(el));
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Determines if the given target has multiple root elements.
|
|
70
|
+
* Referenced from: https://github.com/vuejs/test-utils/blob/ccb460be55f9f6be05ab708500a41ec8adf6f4bc/src/vue-wrapper.ts#L21
|
|
71
|
+
*/
|
|
72
|
+
function hasMultipleRoots(target) {
|
|
73
|
+
const vm = toValue(target);
|
|
74
|
+
return vm && vm.$.subTree.shapeFlag === 16;
|
|
75
|
+
}
|
|
76
|
+
function checkMultipleRoots(target, event) {
|
|
77
|
+
const vm = toValue(target);
|
|
78
|
+
const children = vm.$.subTree && vm.$.subTree.children;
|
|
79
|
+
if (children == null || !Array.isArray(children)) return false;
|
|
80
|
+
return children.some((child) => child.el === event.target || event.composedPath().includes(child.el));
|
|
81
|
+
}
|
|
82
|
+
const listener = (event) => {
|
|
83
|
+
const el = unrefElement(target);
|
|
84
|
+
if (event.target == null) return;
|
|
85
|
+
if (!(el instanceof Element) && hasMultipleRoots(target) && checkMultipleRoots(target, event)) return;
|
|
86
|
+
if (!el || el === event.target || event.composedPath().includes(el)) return;
|
|
87
|
+
if ("detail" in event && event.detail === 0) shouldListen = !shouldIgnore(event);
|
|
88
|
+
if (!shouldListen) {
|
|
89
|
+
shouldListen = true;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
handler(event);
|
|
93
|
+
};
|
|
94
|
+
let isProcessingClick = false;
|
|
95
|
+
const cleanup = [
|
|
96
|
+
useEventListener(window, "click", (event) => {
|
|
97
|
+
if (!isProcessingClick) {
|
|
98
|
+
isProcessingClick = true;
|
|
99
|
+
setTimeout(() => {
|
|
100
|
+
isProcessingClick = false;
|
|
101
|
+
}, 0);
|
|
102
|
+
listener(event);
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
passive: true,
|
|
106
|
+
capture
|
|
107
|
+
}),
|
|
108
|
+
useEventListener(window, "pointerdown", (e) => {
|
|
109
|
+
const el = unrefElement(target);
|
|
110
|
+
shouldListen = !shouldIgnore(e) && !!(el && !e.composedPath().includes(el));
|
|
111
|
+
}, { passive: true }),
|
|
112
|
+
detectIframe && useEventListener(window, "blur", (event) => {
|
|
113
|
+
setTimeout(() => {
|
|
114
|
+
const el = unrefElement(target);
|
|
115
|
+
let activeEl = window.document.activeElement;
|
|
116
|
+
while (activeEl === null || activeEl === void 0 ? void 0 : activeEl.shadowRoot) activeEl = activeEl.shadowRoot.activeElement;
|
|
117
|
+
if ((activeEl === null || activeEl === void 0 ? void 0 : activeEl.tagName) === "IFRAME" && !(el === null || el === void 0 ? void 0 : el.contains(window.document.activeElement))) handler(event);
|
|
118
|
+
}, 0);
|
|
119
|
+
}, { passive: true })
|
|
120
|
+
].filter(Boolean);
|
|
121
|
+
const stop = () => cleanup.forEach((fn) => fn());
|
|
122
|
+
if (controls) return {
|
|
123
|
+
stop,
|
|
124
|
+
cancel: () => {
|
|
125
|
+
shouldListen = false;
|
|
126
|
+
},
|
|
127
|
+
trigger: (event) => {
|
|
128
|
+
shouldListen = true;
|
|
129
|
+
listener(event);
|
|
130
|
+
shouldListen = false;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
return stop;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Mounted state in ref.
|
|
137
|
+
*
|
|
138
|
+
* @see https://vueuse.org/useMounted
|
|
139
|
+
*
|
|
140
|
+
* @__NO_SIDE_EFFECTS__
|
|
141
|
+
*/
|
|
142
|
+
function useMounted() {
|
|
143
|
+
const isMounted = shallowRef(false);
|
|
144
|
+
const instance = getCurrentInstance();
|
|
145
|
+
if (instance) onMounted(() => {
|
|
146
|
+
isMounted.value = true;
|
|
147
|
+
}, instance);
|
|
148
|
+
return isMounted;
|
|
149
|
+
}
|
|
150
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
151
|
+
function useSupported(callback) {
|
|
152
|
+
const isMounted = useMounted();
|
|
153
|
+
return computed(() => {
|
|
154
|
+
isMounted.value;
|
|
155
|
+
return Boolean(callback());
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Watch for changes being made to the DOM tree.
|
|
160
|
+
*
|
|
161
|
+
* @see https://vueuse.org/useMutationObserver
|
|
162
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver MutationObserver MDN
|
|
163
|
+
* @param target
|
|
164
|
+
* @param callback
|
|
165
|
+
* @param options
|
|
166
|
+
*/
|
|
167
|
+
function useMutationObserver(target, callback, options = {}) {
|
|
168
|
+
const { window = defaultWindow, ...mutationOptions } = options;
|
|
169
|
+
let observer;
|
|
170
|
+
const isSupported = /* @__PURE__ */ useSupported(() => window && "MutationObserver" in window);
|
|
171
|
+
const cleanup = () => {
|
|
172
|
+
if (observer) {
|
|
173
|
+
observer.disconnect();
|
|
174
|
+
observer = void 0;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
const stopWatch = watch(computed(() => {
|
|
178
|
+
const items = toArray(toValue(target)).map(unrefElement).filter(notNullish);
|
|
179
|
+
return new Set(items);
|
|
180
|
+
}), (newTargets) => {
|
|
181
|
+
cleanup();
|
|
182
|
+
if (isSupported.value && newTargets.size) {
|
|
183
|
+
observer = new MutationObserver(callback);
|
|
184
|
+
newTargets.forEach((el) => observer.observe(el, mutationOptions));
|
|
185
|
+
}
|
|
186
|
+
}, {
|
|
187
|
+
immediate: true,
|
|
188
|
+
flush: "post"
|
|
189
|
+
});
|
|
190
|
+
const takeRecords = () => {
|
|
191
|
+
return observer === null || observer === void 0 ? void 0 : observer.takeRecords();
|
|
192
|
+
};
|
|
193
|
+
const stop = () => {
|
|
194
|
+
stopWatch();
|
|
195
|
+
cleanup();
|
|
196
|
+
};
|
|
197
|
+
tryOnScopeDispose(stop);
|
|
198
|
+
return {
|
|
199
|
+
isSupported,
|
|
200
|
+
stop,
|
|
201
|
+
takeRecords
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Fires when the element or any element containing it is removed.
|
|
206
|
+
*
|
|
207
|
+
* @param target
|
|
208
|
+
* @param callback
|
|
209
|
+
* @param options
|
|
210
|
+
*/
|
|
211
|
+
function onElementRemoval(target, callback, options = {}) {
|
|
212
|
+
const { window = defaultWindow, document = window === null || window === void 0 ? void 0 : window.document, flush = "sync" } = options;
|
|
213
|
+
if (!window || !document) return noop;
|
|
214
|
+
let stopFn;
|
|
215
|
+
const cleanupAndUpdate = (fn) => {
|
|
216
|
+
stopFn === null || stopFn === void 0 || stopFn();
|
|
217
|
+
stopFn = fn;
|
|
218
|
+
};
|
|
219
|
+
const stopWatch = watchEffect(() => {
|
|
220
|
+
const el = unrefElement(target);
|
|
221
|
+
if (el) {
|
|
222
|
+
const { stop } = useMutationObserver(document, (mutationsList) => {
|
|
223
|
+
if (mutationsList.map((mutation) => [...mutation.removedNodes]).flat().some((node) => node === el || node.contains(el))) callback(mutationsList);
|
|
224
|
+
}, {
|
|
225
|
+
window,
|
|
226
|
+
childList: true,
|
|
227
|
+
subtree: true
|
|
228
|
+
});
|
|
229
|
+
cleanupAndUpdate(stop);
|
|
230
|
+
}
|
|
231
|
+
}, { flush });
|
|
232
|
+
const stopHandle = () => {
|
|
233
|
+
stopWatch();
|
|
234
|
+
cleanupAndUpdate();
|
|
235
|
+
};
|
|
236
|
+
tryOnScopeDispose(stopHandle);
|
|
237
|
+
return stopHandle;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Reactive `document.activeElement`
|
|
241
|
+
*
|
|
242
|
+
* @see https://vueuse.org/useActiveElement
|
|
243
|
+
* @param options
|
|
244
|
+
*
|
|
245
|
+
* @__NO_SIDE_EFFECTS__
|
|
246
|
+
*/
|
|
247
|
+
function useActiveElement(options = {}) {
|
|
248
|
+
var _options$document;
|
|
249
|
+
const { window = defaultWindow, deep = true, triggerOnRemoval = false } = options;
|
|
250
|
+
const document = (_options$document = options.document) !== null && _options$document !== void 0 ? _options$document : window === null || window === void 0 ? void 0 : window.document;
|
|
251
|
+
const getDeepActiveElement = () => {
|
|
252
|
+
let element = document === null || document === void 0 ? void 0 : document.activeElement;
|
|
253
|
+
if (deep) {
|
|
254
|
+
var _element$shadowRoot;
|
|
255
|
+
while (element === null || element === void 0 ? void 0 : element.shadowRoot) element = element === null || element === void 0 || (_element$shadowRoot = element.shadowRoot) === null || _element$shadowRoot === void 0 ? void 0 : _element$shadowRoot.activeElement;
|
|
256
|
+
}
|
|
257
|
+
return element;
|
|
258
|
+
};
|
|
259
|
+
const activeElement = shallowRef();
|
|
260
|
+
const trigger = () => {
|
|
261
|
+
activeElement.value = getDeepActiveElement();
|
|
262
|
+
};
|
|
263
|
+
if (window) {
|
|
264
|
+
const listenerOptions = {
|
|
265
|
+
capture: true,
|
|
266
|
+
passive: true
|
|
267
|
+
};
|
|
268
|
+
useEventListener(window, "blur", (event) => {
|
|
269
|
+
if (event.relatedTarget !== null) return;
|
|
270
|
+
trigger();
|
|
271
|
+
}, listenerOptions);
|
|
272
|
+
useEventListener(window, "focus", trigger, listenerOptions);
|
|
273
|
+
}
|
|
274
|
+
if (triggerOnRemoval) onElementRemoval(activeElement, trigger, { document });
|
|
275
|
+
trigger();
|
|
276
|
+
return activeElement;
|
|
277
|
+
}
|
|
278
|
+
var ssrWidthSymbol = Symbol("vueuse-ssr-width");
|
|
279
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
280
|
+
function useSSRWidth() {
|
|
281
|
+
const ssrWidth = hasInjectionContext() ? injectLocal(ssrWidthSymbol, null) : null;
|
|
282
|
+
return typeof ssrWidth === "number" ? ssrWidth : void 0;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Reactive Media Query.
|
|
286
|
+
*
|
|
287
|
+
* @see https://vueuse.org/useMediaQuery
|
|
288
|
+
* @param query
|
|
289
|
+
* @param options
|
|
290
|
+
*/
|
|
291
|
+
function useMediaQuery(query, options = {}) {
|
|
292
|
+
const { window = defaultWindow, ssrWidth = /* @__PURE__ */ useSSRWidth() } = options;
|
|
293
|
+
const isSupported = /* @__PURE__ */ useSupported(() => window && "matchMedia" in window && typeof window.matchMedia === "function");
|
|
294
|
+
const ssrSupport = shallowRef(typeof ssrWidth === "number");
|
|
295
|
+
const mediaQuery = shallowRef();
|
|
296
|
+
const matches = shallowRef(false);
|
|
297
|
+
const handler = (event) => {
|
|
298
|
+
matches.value = event.matches;
|
|
299
|
+
};
|
|
300
|
+
watchEffect(() => {
|
|
301
|
+
if (ssrSupport.value) {
|
|
302
|
+
ssrSupport.value = !isSupported.value;
|
|
303
|
+
const queryStrings = toValue(query).split(",");
|
|
304
|
+
matches.value = queryStrings.some((queryString) => {
|
|
305
|
+
const not = queryString.includes("not all");
|
|
306
|
+
const minWidth = queryString.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
|
|
307
|
+
const maxWidth = queryString.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
|
|
308
|
+
let res = Boolean(minWidth || maxWidth);
|
|
309
|
+
if (minWidth && res) res = ssrWidth >= pxValue(minWidth[1]);
|
|
310
|
+
if (maxWidth && res) res = ssrWidth <= pxValue(maxWidth[1]);
|
|
311
|
+
return not ? !res : res;
|
|
312
|
+
});
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (!isSupported.value) return;
|
|
316
|
+
mediaQuery.value = window.matchMedia(toValue(query));
|
|
317
|
+
matches.value = mediaQuery.value.matches;
|
|
318
|
+
});
|
|
319
|
+
useEventListener(mediaQuery, "change", handler, { passive: true });
|
|
320
|
+
return computed(() => matches.value);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Breakpoints from Tailwind V2
|
|
324
|
+
*
|
|
325
|
+
* @see https://tailwindcss.com/docs/breakpoints
|
|
326
|
+
*/
|
|
327
|
+
var breakpointsTailwind = {
|
|
328
|
+
"sm": 640,
|
|
329
|
+
"md": 768,
|
|
330
|
+
"lg": 1024,
|
|
331
|
+
"xl": 1280,
|
|
332
|
+
"2xl": 1536
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Reactively viewport breakpoints
|
|
336
|
+
*
|
|
337
|
+
* @see https://vueuse.org/useBreakpoints
|
|
338
|
+
*
|
|
339
|
+
* @__NO_SIDE_EFFECTS__
|
|
340
|
+
*/
|
|
341
|
+
function useBreakpoints(breakpoints, options = {}) {
|
|
342
|
+
function getValue(k, delta) {
|
|
343
|
+
let v = toValue(breakpoints[toValue(k)]);
|
|
344
|
+
if (delta != null) v = increaseWithUnit(v, delta);
|
|
345
|
+
if (typeof v === "number") v = `${v}px`;
|
|
346
|
+
return v;
|
|
347
|
+
}
|
|
348
|
+
const { window = defaultWindow, strategy = "min-width", ssrWidth = /* @__PURE__ */ useSSRWidth() } = options;
|
|
349
|
+
const ssrSupport = typeof ssrWidth === "number";
|
|
350
|
+
const mounted = ssrSupport ? shallowRef(false) : { value: true };
|
|
351
|
+
if (ssrSupport) tryOnMounted(() => mounted.value = !!window);
|
|
352
|
+
function match(query, size) {
|
|
353
|
+
if (!mounted.value && ssrSupport) return query === "min" ? ssrWidth >= pxValue(size) : ssrWidth <= pxValue(size);
|
|
354
|
+
if (!window) return false;
|
|
355
|
+
return window.matchMedia(`(${query}-width: ${size})`).matches;
|
|
356
|
+
}
|
|
357
|
+
const greaterOrEqual = (k) => {
|
|
358
|
+
return useMediaQuery(() => `(min-width: ${getValue(k)})`, options);
|
|
359
|
+
};
|
|
360
|
+
const smallerOrEqual = (k) => {
|
|
361
|
+
return useMediaQuery(() => `(max-width: ${getValue(k)})`, options);
|
|
362
|
+
};
|
|
363
|
+
const shortcutMethods = Object.keys(breakpoints).reduce((shortcuts, k) => {
|
|
364
|
+
Object.defineProperty(shortcuts, k, {
|
|
365
|
+
get: () => strategy === "min-width" ? greaterOrEqual(k) : smallerOrEqual(k),
|
|
366
|
+
enumerable: true,
|
|
367
|
+
configurable: true
|
|
368
|
+
});
|
|
369
|
+
return shortcuts;
|
|
370
|
+
}, {});
|
|
371
|
+
function current() {
|
|
372
|
+
const points = Object.keys(breakpoints).map((k) => [
|
|
373
|
+
k,
|
|
374
|
+
shortcutMethods[k],
|
|
375
|
+
pxValue(getValue(k))
|
|
376
|
+
]).sort((a, b) => a[2] - b[2]);
|
|
377
|
+
return computed(() => points.filter(([, v]) => v.value).map(([k]) => k));
|
|
378
|
+
}
|
|
379
|
+
return Object.assign(shortcutMethods, {
|
|
380
|
+
greaterOrEqual,
|
|
381
|
+
smallerOrEqual,
|
|
382
|
+
greater(k) {
|
|
383
|
+
return useMediaQuery(() => `(min-width: ${getValue(k, .1)})`, options);
|
|
384
|
+
},
|
|
385
|
+
smaller(k) {
|
|
386
|
+
return useMediaQuery(() => `(max-width: ${getValue(k, -.1)})`, options);
|
|
387
|
+
},
|
|
388
|
+
between(a, b) {
|
|
389
|
+
return useMediaQuery(() => `(min-width: ${getValue(a)}) and (max-width: ${getValue(b, -.1)})`, options);
|
|
390
|
+
},
|
|
391
|
+
isGreater(k) {
|
|
392
|
+
return match("min", getValue(k, .1));
|
|
393
|
+
},
|
|
394
|
+
isGreaterOrEqual(k) {
|
|
395
|
+
return match("min", getValue(k));
|
|
396
|
+
},
|
|
397
|
+
isSmaller(k) {
|
|
398
|
+
return match("max", getValue(k, -.1));
|
|
399
|
+
},
|
|
400
|
+
isSmallerOrEqual(k) {
|
|
401
|
+
return match("max", getValue(k));
|
|
402
|
+
},
|
|
403
|
+
isInBetween(a, b) {
|
|
404
|
+
return match("min", getValue(a)) && match("max", getValue(b, -.1));
|
|
405
|
+
},
|
|
406
|
+
current,
|
|
407
|
+
active() {
|
|
408
|
+
const bps = current();
|
|
409
|
+
return computed(() => bps.value.length === 0 ? "" : bps.value.at(strategy === "min-width" ? -1 : 0));
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Reactive Permissions API.
|
|
415
|
+
*
|
|
416
|
+
* @see https://vueuse.org/usePermission
|
|
417
|
+
*
|
|
418
|
+
* @__NO_SIDE_EFFECTS__
|
|
419
|
+
*/
|
|
420
|
+
function usePermission(permissionDesc, options = {}) {
|
|
421
|
+
const { controls = false, navigator = defaultNavigator } = options;
|
|
422
|
+
const isSupported = /* @__PURE__ */ useSupported(() => navigator && "permissions" in navigator);
|
|
423
|
+
const permissionStatus = shallowRef();
|
|
424
|
+
const desc = typeof permissionDesc === "string" ? { name: permissionDesc } : permissionDesc;
|
|
425
|
+
const state = shallowRef();
|
|
426
|
+
const update = () => {
|
|
427
|
+
var _permissionStatus$val, _permissionStatus$val2;
|
|
428
|
+
state.value = (_permissionStatus$val = (_permissionStatus$val2 = permissionStatus.value) === null || _permissionStatus$val2 === void 0 ? void 0 : _permissionStatus$val2.state) !== null && _permissionStatus$val !== void 0 ? _permissionStatus$val : "prompt";
|
|
429
|
+
};
|
|
430
|
+
useEventListener(permissionStatus, "change", update, { passive: true });
|
|
431
|
+
const query = createSingletonPromise(async () => {
|
|
432
|
+
if (!isSupported.value) return;
|
|
433
|
+
if (!permissionStatus.value) try {
|
|
434
|
+
permissionStatus.value = await navigator.permissions.query(desc);
|
|
435
|
+
} catch (_unused) {
|
|
436
|
+
permissionStatus.value = void 0;
|
|
437
|
+
} finally {
|
|
438
|
+
update();
|
|
439
|
+
}
|
|
440
|
+
if (controls) return toRaw(permissionStatus.value);
|
|
441
|
+
});
|
|
442
|
+
query();
|
|
443
|
+
if (controls) return {
|
|
444
|
+
state,
|
|
445
|
+
isSupported,
|
|
446
|
+
query
|
|
447
|
+
};
|
|
448
|
+
else return state;
|
|
449
|
+
}
|
|
450
|
+
function useClipboard(options = {}) {
|
|
451
|
+
const { navigator = defaultNavigator, read = false, source, copiedDuring = 1500, legacy = false } = options;
|
|
452
|
+
const isClipboardApiSupported = /* @__PURE__ */ useSupported(() => navigator && "clipboard" in navigator);
|
|
453
|
+
const permissionRead = usePermission("clipboard-read");
|
|
454
|
+
const permissionWrite = usePermission("clipboard-write");
|
|
455
|
+
const isSupported = computed(() => isClipboardApiSupported.value || legacy);
|
|
456
|
+
const text = shallowRef("");
|
|
457
|
+
const copied = shallowRef(false);
|
|
458
|
+
const copyPending = shallowRef(false);
|
|
459
|
+
const timeout = useTimeoutFn(() => copied.value = false, copiedDuring, { immediate: false });
|
|
460
|
+
let lastLegacyId = 0;
|
|
461
|
+
async function updateText() {
|
|
462
|
+
let useLegacy = !(isClipboardApiSupported.value && isAllowed(permissionRead.value));
|
|
463
|
+
if (!useLegacy) try {
|
|
464
|
+
text.value = await navigator.clipboard.readText();
|
|
465
|
+
} catch (_unused) {
|
|
466
|
+
useLegacy = true;
|
|
467
|
+
}
|
|
468
|
+
if (useLegacy) text.value = legacyRead();
|
|
469
|
+
}
|
|
470
|
+
if (isSupported.value && read) useEventListener(["copy", "cut"], updateText, { passive: true });
|
|
471
|
+
async function copy(value) {
|
|
472
|
+
const resolvedValue = value !== null && value !== void 0 ? value : toValue(source);
|
|
473
|
+
if (isSupported.value && resolvedValue != null) {
|
|
474
|
+
copyPending.value = true;
|
|
475
|
+
let useLegacy = !(isClipboardApiSupported.value && isAllowed(permissionWrite.value));
|
|
476
|
+
if (!useLegacy) try {
|
|
477
|
+
const clipboardItem = createClipboardItem(resolvedValue);
|
|
478
|
+
await navigator.clipboard.write([clipboardItem]);
|
|
479
|
+
} catch (_unused2) {
|
|
480
|
+
useLegacy = true;
|
|
481
|
+
}
|
|
482
|
+
if (useLegacy) if (typeof resolvedValue === "string") {
|
|
483
|
+
text.value = resolvedValue;
|
|
484
|
+
legacyCopy(resolvedValue);
|
|
485
|
+
} else {
|
|
486
|
+
const currentId = ++lastLegacyId;
|
|
487
|
+
const resolvedText = await resolvedValue();
|
|
488
|
+
if (resolvedText != null && currentId === lastLegacyId) {
|
|
489
|
+
text.value = resolvedText;
|
|
490
|
+
legacyCopy(resolvedText);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
copied.value = true;
|
|
494
|
+
timeout.start();
|
|
495
|
+
copyPending.value = false;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
function createClipboardItem(value) {
|
|
499
|
+
if (typeof value === "string") {
|
|
500
|
+
text.value = value;
|
|
501
|
+
return new ClipboardItem({ "text/plain": value });
|
|
502
|
+
} else return new ClipboardItem({ "text/plain": value().then((resolvedText = "") => {
|
|
503
|
+
text.value = resolvedText;
|
|
504
|
+
return new Blob([resolvedText], { type: "text/plain" });
|
|
505
|
+
}) });
|
|
506
|
+
}
|
|
507
|
+
function legacyCopy(value) {
|
|
508
|
+
const ta = document.createElement("textarea");
|
|
509
|
+
ta.value = value;
|
|
510
|
+
ta.style.position = "absolute";
|
|
511
|
+
ta.style.opacity = "0";
|
|
512
|
+
ta.setAttribute("readonly", "");
|
|
513
|
+
document.body.appendChild(ta);
|
|
514
|
+
ta.select();
|
|
515
|
+
document.execCommand("copy");
|
|
516
|
+
ta.remove();
|
|
517
|
+
}
|
|
518
|
+
function legacyRead() {
|
|
519
|
+
var _document$getSelectio, _document, _document$getSelectio2;
|
|
520
|
+
return (_document$getSelectio = (_document = document) === null || _document === void 0 || (_document$getSelectio2 = _document.getSelection) === null || _document$getSelectio2 === void 0 || (_document$getSelectio2 = _document$getSelectio2.call(_document)) === null || _document$getSelectio2 === void 0 ? void 0 : _document$getSelectio2.toString()) !== null && _document$getSelectio !== void 0 ? _document$getSelectio : "";
|
|
521
|
+
}
|
|
522
|
+
function isAllowed(status) {
|
|
523
|
+
return status === "granted" || status === "prompt";
|
|
524
|
+
}
|
|
525
|
+
return {
|
|
526
|
+
copyPending: shallowReadonly(copyPending),
|
|
527
|
+
isSupported,
|
|
528
|
+
text: shallowReadonly(text),
|
|
529
|
+
copied: shallowReadonly(copied),
|
|
530
|
+
copy
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
var _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
534
|
+
var globalKey = "__vueuse_ssr_handlers__";
|
|
535
|
+
var handlers = /* #__PURE__ */ getHandlers();
|
|
536
|
+
function getHandlers() {
|
|
537
|
+
if (!(globalKey in _global)) _global[globalKey] = _global[globalKey] || {};
|
|
538
|
+
return _global[globalKey];
|
|
539
|
+
}
|
|
540
|
+
function getSSRHandler(key, fallback) {
|
|
541
|
+
return handlers[key] || fallback;
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Reactive dark theme preference.
|
|
545
|
+
*
|
|
546
|
+
* @see https://vueuse.org/usePreferredDark
|
|
547
|
+
* @param [options]
|
|
548
|
+
*
|
|
549
|
+
* @__NO_SIDE_EFFECTS__
|
|
550
|
+
*/
|
|
551
|
+
function usePreferredDark(options) {
|
|
552
|
+
return useMediaQuery("(prefers-color-scheme: dark)", options);
|
|
553
|
+
}
|
|
554
|
+
function guessSerializerType(rawInit) {
|
|
555
|
+
return rawInit == null ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
|
|
556
|
+
}
|
|
557
|
+
var StorageSerializers = {
|
|
558
|
+
boolean: {
|
|
559
|
+
read: (v) => v === "true",
|
|
560
|
+
write: (v) => String(v)
|
|
561
|
+
},
|
|
562
|
+
object: {
|
|
563
|
+
read: (v) => JSON.parse(v),
|
|
564
|
+
write: (v) => JSON.stringify(v)
|
|
565
|
+
},
|
|
566
|
+
number: {
|
|
567
|
+
read: (v) => Number.parseFloat(v),
|
|
568
|
+
write: (v) => String(v)
|
|
569
|
+
},
|
|
570
|
+
any: {
|
|
571
|
+
read: (v) => v,
|
|
572
|
+
write: (v) => String(v)
|
|
573
|
+
},
|
|
574
|
+
string: {
|
|
575
|
+
read: (v) => v,
|
|
576
|
+
write: (v) => String(v)
|
|
577
|
+
},
|
|
578
|
+
map: {
|
|
579
|
+
read: (v) => new Map(JSON.parse(v)),
|
|
580
|
+
write: (v) => JSON.stringify(Array.from(v.entries()))
|
|
581
|
+
},
|
|
582
|
+
set: {
|
|
583
|
+
read: (v) => new Set(JSON.parse(v)),
|
|
584
|
+
write: (v) => JSON.stringify(Array.from(v))
|
|
585
|
+
},
|
|
586
|
+
date: {
|
|
587
|
+
read: (v) => new Date(v),
|
|
588
|
+
write: (v) => v.toISOString()
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
var customStorageEventName = "vueuse-storage";
|
|
592
|
+
/**
|
|
593
|
+
* Reactive LocalStorage/SessionStorage.
|
|
594
|
+
*
|
|
595
|
+
* @see https://vueuse.org/useStorage
|
|
596
|
+
*/
|
|
597
|
+
function useStorage(key, defaults, storage, options = {}) {
|
|
598
|
+
var _options$serializer;
|
|
599
|
+
const { flush = "pre", deep = true, listenToStorageChanges = true, writeDefaults = true, mergeDefaults = false, shallow, window = defaultWindow, eventFilter, onError = (e) => {
|
|
600
|
+
console.error(e);
|
|
601
|
+
}, initOnMounted } = options;
|
|
602
|
+
const data = (shallow ? shallowRef : ref)(typeof defaults === "function" ? defaults() : defaults);
|
|
603
|
+
const keyComputed = computed(() => toValue(key));
|
|
604
|
+
if (!storage) try {
|
|
605
|
+
storage = getSSRHandler("getDefaultStorage", () => defaultWindow === null || defaultWindow === void 0 ? void 0 : defaultWindow.localStorage)();
|
|
606
|
+
} catch (e) {
|
|
607
|
+
onError(e);
|
|
608
|
+
}
|
|
609
|
+
if (!storage) return data;
|
|
610
|
+
const rawInit = toValue(defaults);
|
|
611
|
+
const type = guessSerializerType(rawInit);
|
|
612
|
+
const serializer = (_options$serializer = options.serializer) !== null && _options$serializer !== void 0 ? _options$serializer : StorageSerializers[type];
|
|
613
|
+
const { pause: pauseWatch, resume: resumeWatch } = watchPausable(data, (newValue) => write(newValue), {
|
|
614
|
+
flush,
|
|
615
|
+
deep,
|
|
616
|
+
eventFilter
|
|
617
|
+
});
|
|
618
|
+
watch(keyComputed, () => update(), { flush });
|
|
619
|
+
let firstMounted = false;
|
|
620
|
+
const onStorageEvent = (ev) => {
|
|
621
|
+
if (initOnMounted && !firstMounted) return;
|
|
622
|
+
update(ev);
|
|
623
|
+
};
|
|
624
|
+
const onStorageCustomEvent = (ev) => {
|
|
625
|
+
if (initOnMounted && !firstMounted) return;
|
|
626
|
+
updateFromCustomEvent(ev);
|
|
627
|
+
};
|
|
628
|
+
/**
|
|
629
|
+
* The custom event is needed for same-document syncing when using custom
|
|
630
|
+
* storage backends, but it doesn't work across different documents.
|
|
631
|
+
*
|
|
632
|
+
* TODO: Consider implementing a BroadcastChannel-based solution that fixes this.
|
|
633
|
+
*/
|
|
634
|
+
if (window && listenToStorageChanges) if (storage instanceof Storage) useEventListener(window, "storage", onStorageEvent, { passive: true });
|
|
635
|
+
else useEventListener(window, customStorageEventName, onStorageCustomEvent);
|
|
636
|
+
if (initOnMounted) tryOnMounted(() => {
|
|
637
|
+
firstMounted = true;
|
|
638
|
+
update();
|
|
639
|
+
});
|
|
640
|
+
else update();
|
|
641
|
+
function dispatchWriteEvent(oldValue, newValue) {
|
|
642
|
+
if (window) {
|
|
643
|
+
const payload = {
|
|
644
|
+
key: keyComputed.value,
|
|
645
|
+
oldValue,
|
|
646
|
+
newValue,
|
|
647
|
+
storageArea: storage
|
|
648
|
+
};
|
|
649
|
+
window.dispatchEvent(storage instanceof Storage ? new StorageEvent("storage", payload) : new CustomEvent(customStorageEventName, { detail: payload }));
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
function write(v) {
|
|
653
|
+
try {
|
|
654
|
+
const oldValue = storage.getItem(keyComputed.value);
|
|
655
|
+
if (v == null) {
|
|
656
|
+
dispatchWriteEvent(oldValue, null);
|
|
657
|
+
storage.removeItem(keyComputed.value);
|
|
658
|
+
} else {
|
|
659
|
+
const serialized = serializer.write(v);
|
|
660
|
+
if (oldValue !== serialized) {
|
|
661
|
+
storage.setItem(keyComputed.value, serialized);
|
|
662
|
+
dispatchWriteEvent(oldValue, serialized);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
} catch (e) {
|
|
666
|
+
onError(e);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
function read(event) {
|
|
670
|
+
const rawValue = event ? event.newValue : storage.getItem(keyComputed.value);
|
|
671
|
+
if (rawValue == null) {
|
|
672
|
+
if (writeDefaults && rawInit != null) storage.setItem(keyComputed.value, serializer.write(rawInit));
|
|
673
|
+
return rawInit;
|
|
674
|
+
} else if (!event && mergeDefaults) {
|
|
675
|
+
const value = serializer.read(rawValue);
|
|
676
|
+
if (typeof mergeDefaults === "function") return mergeDefaults(value, rawInit);
|
|
677
|
+
else if (type === "object" && !Array.isArray(value)) return {
|
|
678
|
+
...rawInit,
|
|
679
|
+
...value
|
|
680
|
+
};
|
|
681
|
+
return value;
|
|
682
|
+
} else if (typeof rawValue !== "string") return rawValue;
|
|
683
|
+
else return serializer.read(rawValue);
|
|
684
|
+
}
|
|
685
|
+
function update(event) {
|
|
686
|
+
if (event && event.storageArea !== storage) return;
|
|
687
|
+
if (event && event.key == null) {
|
|
688
|
+
data.value = rawInit;
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
if (event && event.key !== keyComputed.value) return;
|
|
692
|
+
pauseWatch();
|
|
693
|
+
try {
|
|
694
|
+
const serializedData = serializer.write(data.value);
|
|
695
|
+
if (event === void 0 || (event === null || event === void 0 ? void 0 : event.newValue) !== serializedData) data.value = read(event);
|
|
696
|
+
} catch (e) {
|
|
697
|
+
onError(e);
|
|
698
|
+
} finally {
|
|
699
|
+
if (event) nextTick(resumeWatch);
|
|
700
|
+
else resumeWatch();
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
function updateFromCustomEvent(event) {
|
|
704
|
+
update(event.detail);
|
|
705
|
+
}
|
|
706
|
+
return data;
|
|
707
|
+
}
|
|
708
|
+
var CSS_DISABLE_TRANS = "*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}";
|
|
709
|
+
/**
|
|
710
|
+
* Reactive color mode with auto data persistence.
|
|
711
|
+
*
|
|
712
|
+
* @see https://vueuse.org/useColorMode
|
|
713
|
+
* @param options
|
|
714
|
+
*/
|
|
715
|
+
function useColorMode(options = {}) {
|
|
716
|
+
const { selector = "html", attribute = "class", initialValue = "auto", window = defaultWindow, storage, storageKey = "vueuse-color-scheme", listenToStorageChanges = true, storageRef, emitAuto, disableTransition = true } = options;
|
|
717
|
+
const modes = {
|
|
718
|
+
auto: "",
|
|
719
|
+
light: "light",
|
|
720
|
+
dark: "dark",
|
|
721
|
+
...options.modes || {}
|
|
722
|
+
};
|
|
723
|
+
const preferredDark = usePreferredDark({ window });
|
|
724
|
+
const system = computed(() => preferredDark.value ? "dark" : "light");
|
|
725
|
+
const store = storageRef || (storageKey == null ? toRef$1(initialValue) : useStorage(storageKey, initialValue, storage, {
|
|
726
|
+
window,
|
|
727
|
+
listenToStorageChanges
|
|
728
|
+
}));
|
|
729
|
+
const state = computed(() => store.value === "auto" ? system.value : store.value);
|
|
730
|
+
const updateHTMLAttrs = getSSRHandler("updateHTMLAttrs", (selector, attribute, value) => {
|
|
731
|
+
const el = typeof selector === "string" ? window === null || window === void 0 ? void 0 : window.document.querySelector(selector) : unrefElement(selector);
|
|
732
|
+
if (!el) return;
|
|
733
|
+
const classesToAdd = /* @__PURE__ */ new Set();
|
|
734
|
+
const classesToRemove = /* @__PURE__ */ new Set();
|
|
735
|
+
let attributeToChange = null;
|
|
736
|
+
if (attribute === "class") {
|
|
737
|
+
const current = value.split(/\s/g);
|
|
738
|
+
Object.values(modes).flatMap((i) => (i || "").split(/\s/g)).filter(Boolean).forEach((v) => {
|
|
739
|
+
if (current.includes(v)) classesToAdd.add(v);
|
|
740
|
+
else classesToRemove.add(v);
|
|
741
|
+
});
|
|
742
|
+
} else attributeToChange = {
|
|
743
|
+
key: attribute,
|
|
744
|
+
value
|
|
745
|
+
};
|
|
746
|
+
if (classesToAdd.size === 0 && classesToRemove.size === 0 && attributeToChange === null) return;
|
|
747
|
+
let style;
|
|
748
|
+
if (disableTransition) {
|
|
749
|
+
style = window.document.createElement("style");
|
|
750
|
+
style.appendChild(document.createTextNode(CSS_DISABLE_TRANS));
|
|
751
|
+
window.document.head.appendChild(style);
|
|
752
|
+
}
|
|
753
|
+
for (const c of classesToAdd) el.classList.add(c);
|
|
754
|
+
for (const c of classesToRemove) el.classList.remove(c);
|
|
755
|
+
if (attributeToChange) el.setAttribute(attributeToChange.key, attributeToChange.value);
|
|
756
|
+
if (disableTransition) {
|
|
757
|
+
window.getComputedStyle(style).opacity;
|
|
758
|
+
document.head.removeChild(style);
|
|
759
|
+
}
|
|
760
|
+
});
|
|
761
|
+
function defaultOnChanged(mode) {
|
|
762
|
+
var _modes$mode;
|
|
763
|
+
updateHTMLAttrs(selector, attribute, (_modes$mode = modes[mode]) !== null && _modes$mode !== void 0 ? _modes$mode : mode);
|
|
764
|
+
}
|
|
765
|
+
function onChanged(mode) {
|
|
766
|
+
if (options.onChanged) options.onChanged(mode, defaultOnChanged);
|
|
767
|
+
else defaultOnChanged(mode);
|
|
768
|
+
}
|
|
769
|
+
watch(state, onChanged, {
|
|
770
|
+
flush: "post",
|
|
771
|
+
immediate: true
|
|
772
|
+
});
|
|
773
|
+
tryOnMounted(() => onChanged(state.value));
|
|
774
|
+
const auto = computed({
|
|
775
|
+
get() {
|
|
776
|
+
return emitAuto ? store.value : state.value;
|
|
777
|
+
},
|
|
778
|
+
set(v) {
|
|
779
|
+
store.value = v;
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
return Object.assign(auto, {
|
|
783
|
+
store,
|
|
784
|
+
system,
|
|
785
|
+
state
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
function useDropZone(target, options = {}) {
|
|
789
|
+
const isOverDropZone = shallowRef(false);
|
|
790
|
+
const files = shallowRef(null);
|
|
791
|
+
let counter = 0;
|
|
792
|
+
let isValid = true;
|
|
793
|
+
if (isClient) {
|
|
794
|
+
var _options$multiple, _options$preventDefau;
|
|
795
|
+
const _options = typeof options === "function" ? { onDrop: options } : options;
|
|
796
|
+
const multiple = (_options$multiple = _options.multiple) !== null && _options$multiple !== void 0 ? _options$multiple : true;
|
|
797
|
+
const preventDefaultForUnhandled = (_options$preventDefau = _options.preventDefaultForUnhandled) !== null && _options$preventDefau !== void 0 ? _options$preventDefau : false;
|
|
798
|
+
const getFiles = (event) => {
|
|
799
|
+
var _event$dataTransfer$f, _event$dataTransfer;
|
|
800
|
+
const list = Array.from((_event$dataTransfer$f = (_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 ? void 0 : _event$dataTransfer.files) !== null && _event$dataTransfer$f !== void 0 ? _event$dataTransfer$f : []);
|
|
801
|
+
return list.length === 0 ? null : multiple ? list : [list[0]];
|
|
802
|
+
};
|
|
803
|
+
const checkDataTypes = (types) => {
|
|
804
|
+
const dataTypes = unref(_options.dataTypes);
|
|
805
|
+
if (typeof dataTypes === "function") return dataTypes(types);
|
|
806
|
+
if (!(dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length)) return true;
|
|
807
|
+
if (types.length === 0) return false;
|
|
808
|
+
return types.every((type) => dataTypes.some((allowedType) => type.includes(allowedType)));
|
|
809
|
+
};
|
|
810
|
+
const checkValidity = (items) => {
|
|
811
|
+
if (_options.checkValidity) return _options.checkValidity(items);
|
|
812
|
+
const types = Array.from(items !== null && items !== void 0 ? items : []).map((item) => item.type);
|
|
813
|
+
const dataTypesValid = checkDataTypes(types);
|
|
814
|
+
const multipleFilesValid = multiple || items.length <= 1;
|
|
815
|
+
return dataTypesValid && multipleFilesValid;
|
|
816
|
+
};
|
|
817
|
+
const isSafari = () => /^(?:(?!chrome|android).)*safari/i.test(navigator.userAgent) && !("chrome" in window);
|
|
818
|
+
const handleDragEvent = (event, eventType) => {
|
|
819
|
+
var _event$dataTransfer2, _ref;
|
|
820
|
+
const dataTransferItemList = (_event$dataTransfer2 = event.dataTransfer) === null || _event$dataTransfer2 === void 0 ? void 0 : _event$dataTransfer2.items;
|
|
821
|
+
isValid = (_ref = dataTransferItemList && checkValidity(dataTransferItemList)) !== null && _ref !== void 0 ? _ref : false;
|
|
822
|
+
if (preventDefaultForUnhandled) event.preventDefault();
|
|
823
|
+
if (!isSafari() && !isValid) {
|
|
824
|
+
if (event.dataTransfer) event.dataTransfer.dropEffect = "none";
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
event.preventDefault();
|
|
828
|
+
if (event.dataTransfer) event.dataTransfer.dropEffect = "copy";
|
|
829
|
+
const currentFiles = getFiles(event);
|
|
830
|
+
switch (eventType) {
|
|
831
|
+
case "enter":
|
|
832
|
+
var _options$onEnter;
|
|
833
|
+
counter += 1;
|
|
834
|
+
isOverDropZone.value = true;
|
|
835
|
+
(_options$onEnter = _options.onEnter) === null || _options$onEnter === void 0 || _options$onEnter.call(_options, null, event);
|
|
836
|
+
break;
|
|
837
|
+
case "over":
|
|
838
|
+
var _options$onOver;
|
|
839
|
+
(_options$onOver = _options.onOver) === null || _options$onOver === void 0 || _options$onOver.call(_options, null, event);
|
|
840
|
+
break;
|
|
841
|
+
case "leave":
|
|
842
|
+
var _options$onLeave;
|
|
843
|
+
counter -= 1;
|
|
844
|
+
if (counter === 0) isOverDropZone.value = false;
|
|
845
|
+
(_options$onLeave = _options.onLeave) === null || _options$onLeave === void 0 || _options$onLeave.call(_options, null, event);
|
|
846
|
+
break;
|
|
847
|
+
case "drop":
|
|
848
|
+
counter = 0;
|
|
849
|
+
isOverDropZone.value = false;
|
|
850
|
+
if (isValid) {
|
|
851
|
+
var _options$onDrop;
|
|
852
|
+
files.value = currentFiles;
|
|
853
|
+
(_options$onDrop = _options.onDrop) === null || _options$onDrop === void 0 || _options$onDrop.call(_options, currentFiles, event);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
};
|
|
857
|
+
useEventListener(target, "dragenter", (event) => handleDragEvent(event, "enter"));
|
|
858
|
+
useEventListener(target, "dragover", (event) => handleDragEvent(event, "over"));
|
|
859
|
+
useEventListener(target, "dragleave", (event) => handleDragEvent(event, "leave"));
|
|
860
|
+
useEventListener(target, "drop", (event) => handleDragEvent(event, "drop"));
|
|
861
|
+
}
|
|
862
|
+
return {
|
|
863
|
+
files,
|
|
864
|
+
isOverDropZone
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Reports changes to the dimensions of an Element's content or the border-box
|
|
869
|
+
*
|
|
870
|
+
* @see https://vueuse.org/useResizeObserver
|
|
871
|
+
* @param target
|
|
872
|
+
* @param callback
|
|
873
|
+
* @param options
|
|
874
|
+
*/
|
|
875
|
+
function useResizeObserver(target, callback, options = {}) {
|
|
876
|
+
const { window = defaultWindow, ...observerOptions } = options;
|
|
877
|
+
let observer;
|
|
878
|
+
const isSupported = /* @__PURE__ */ useSupported(() => window && "ResizeObserver" in window);
|
|
879
|
+
const cleanup = () => {
|
|
880
|
+
if (observer) {
|
|
881
|
+
observer.disconnect();
|
|
882
|
+
observer = void 0;
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
const stopWatch = watch(computed(() => {
|
|
886
|
+
const _targets = toValue(target);
|
|
887
|
+
return Array.isArray(_targets) ? _targets.map((el) => unrefElement(el)) : [unrefElement(_targets)];
|
|
888
|
+
}), (els) => {
|
|
889
|
+
cleanup();
|
|
890
|
+
if (isSupported.value && window) {
|
|
891
|
+
observer = new ResizeObserver(callback);
|
|
892
|
+
for (const _el of els) if (_el) observer.observe(_el, observerOptions);
|
|
893
|
+
}
|
|
894
|
+
}, {
|
|
895
|
+
immediate: true,
|
|
896
|
+
flush: "post"
|
|
897
|
+
});
|
|
898
|
+
const stop = () => {
|
|
899
|
+
cleanup();
|
|
900
|
+
stopWatch();
|
|
901
|
+
};
|
|
902
|
+
tryOnScopeDispose(stop);
|
|
903
|
+
return {
|
|
904
|
+
isSupported,
|
|
905
|
+
stop
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Reactive bounding box of an HTML element.
|
|
910
|
+
*
|
|
911
|
+
* @see https://vueuse.org/useElementBounding
|
|
912
|
+
* @param target
|
|
913
|
+
*/
|
|
914
|
+
function useElementBounding(target, options = {}) {
|
|
915
|
+
const { reset = true, windowResize = true, windowScroll = true, immediate = true, updateTiming = "sync" } = options;
|
|
916
|
+
const height = shallowRef(0);
|
|
917
|
+
const bottom = shallowRef(0);
|
|
918
|
+
const left = shallowRef(0);
|
|
919
|
+
const right = shallowRef(0);
|
|
920
|
+
const top = shallowRef(0);
|
|
921
|
+
const width = shallowRef(0);
|
|
922
|
+
const x = shallowRef(0);
|
|
923
|
+
const y = shallowRef(0);
|
|
924
|
+
function recalculate() {
|
|
925
|
+
const el = unrefElement(target);
|
|
926
|
+
if (!el) {
|
|
927
|
+
if (reset) {
|
|
928
|
+
height.value = 0;
|
|
929
|
+
bottom.value = 0;
|
|
930
|
+
left.value = 0;
|
|
931
|
+
right.value = 0;
|
|
932
|
+
top.value = 0;
|
|
933
|
+
width.value = 0;
|
|
934
|
+
x.value = 0;
|
|
935
|
+
y.value = 0;
|
|
936
|
+
}
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
const rect = el.getBoundingClientRect();
|
|
940
|
+
height.value = rect.height;
|
|
941
|
+
bottom.value = rect.bottom;
|
|
942
|
+
left.value = rect.left;
|
|
943
|
+
right.value = rect.right;
|
|
944
|
+
top.value = rect.top;
|
|
945
|
+
width.value = rect.width;
|
|
946
|
+
x.value = rect.x;
|
|
947
|
+
y.value = rect.y;
|
|
948
|
+
}
|
|
949
|
+
function update() {
|
|
950
|
+
if (updateTiming === "sync") recalculate();
|
|
951
|
+
else if (updateTiming === "next-frame") requestAnimationFrame(() => recalculate());
|
|
952
|
+
}
|
|
953
|
+
useResizeObserver(target, update);
|
|
954
|
+
watch(() => unrefElement(target), (ele) => !ele && update());
|
|
955
|
+
useMutationObserver(target, update, { attributeFilter: ["style", "class"] });
|
|
956
|
+
if (windowScroll) useEventListener("scroll", update, {
|
|
957
|
+
capture: true,
|
|
958
|
+
passive: true
|
|
959
|
+
});
|
|
960
|
+
if (windowResize) useEventListener("resize", update, { passive: true });
|
|
961
|
+
tryOnMounted(() => {
|
|
962
|
+
if (immediate) update();
|
|
963
|
+
});
|
|
964
|
+
return {
|
|
965
|
+
height,
|
|
966
|
+
bottom,
|
|
967
|
+
left,
|
|
968
|
+
right,
|
|
969
|
+
top,
|
|
970
|
+
width,
|
|
971
|
+
x,
|
|
972
|
+
y,
|
|
973
|
+
update
|
|
974
|
+
};
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* Reactive size of an HTML element.
|
|
978
|
+
*
|
|
979
|
+
* @see https://vueuse.org/useElementSize
|
|
980
|
+
*/
|
|
981
|
+
function useElementSize(target, initialSize = {
|
|
982
|
+
width: 0,
|
|
983
|
+
height: 0
|
|
984
|
+
}, options = {}) {
|
|
985
|
+
const { window = defaultWindow, box = "content-box" } = options;
|
|
986
|
+
const isSVG = computed(() => {
|
|
987
|
+
var _unrefElement;
|
|
988
|
+
return (_unrefElement = unrefElement(target)) === null || _unrefElement === void 0 || (_unrefElement = _unrefElement.namespaceURI) === null || _unrefElement === void 0 ? void 0 : _unrefElement.includes("svg");
|
|
989
|
+
});
|
|
990
|
+
const width = shallowRef(initialSize.width);
|
|
991
|
+
const height = shallowRef(initialSize.height);
|
|
992
|
+
const { stop: stop1 } = useResizeObserver(target, ([entry]) => {
|
|
993
|
+
const boxSize = box === "border-box" ? entry.borderBoxSize : box === "content-box" ? entry.contentBoxSize : entry.devicePixelContentBoxSize;
|
|
994
|
+
if (window && isSVG.value) {
|
|
995
|
+
const $elem = unrefElement(target);
|
|
996
|
+
if ($elem) {
|
|
997
|
+
const rect = $elem.getBoundingClientRect();
|
|
998
|
+
width.value = rect.width;
|
|
999
|
+
height.value = rect.height;
|
|
1000
|
+
}
|
|
1001
|
+
} else if (boxSize) {
|
|
1002
|
+
const formatBoxSize = toArray(boxSize);
|
|
1003
|
+
width.value = formatBoxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0);
|
|
1004
|
+
height.value = formatBoxSize.reduce((acc, { blockSize }) => acc + blockSize, 0);
|
|
1005
|
+
} else {
|
|
1006
|
+
width.value = entry.contentRect.width;
|
|
1007
|
+
height.value = entry.contentRect.height;
|
|
1008
|
+
}
|
|
1009
|
+
}, options);
|
|
1010
|
+
tryOnMounted(() => {
|
|
1011
|
+
const ele = unrefElement(target);
|
|
1012
|
+
if (ele && "offsetWidth" in ele) if (box === "content-box" && window) {
|
|
1013
|
+
const cs = window.getComputedStyle(ele);
|
|
1014
|
+
const padX = Number.parseFloat(cs.paddingLeft) + Number.parseFloat(cs.paddingRight);
|
|
1015
|
+
const padY = Number.parseFloat(cs.paddingTop) + Number.parseFloat(cs.paddingBottom);
|
|
1016
|
+
const bdX = Number.parseFloat(cs.borderLeftWidth) + Number.parseFloat(cs.borderRightWidth);
|
|
1017
|
+
const bdY = Number.parseFloat(cs.borderTopWidth) + Number.parseFloat(cs.borderBottomWidth);
|
|
1018
|
+
width.value = ele.offsetWidth - padX - bdX;
|
|
1019
|
+
height.value = ele.offsetHeight - padY - bdY;
|
|
1020
|
+
} else {
|
|
1021
|
+
width.value = ele.offsetWidth;
|
|
1022
|
+
height.value = ele.offsetHeight;
|
|
1023
|
+
}
|
|
1024
|
+
else if (ele) {
|
|
1025
|
+
width.value = initialSize.width;
|
|
1026
|
+
height.value = initialSize.height;
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
1029
|
+
const stop2 = watch(() => unrefElement(target), (ele) => {
|
|
1030
|
+
width.value = ele ? initialSize.width : 0;
|
|
1031
|
+
height.value = ele ? initialSize.height : 0;
|
|
1032
|
+
});
|
|
1033
|
+
function stop() {
|
|
1034
|
+
stop1();
|
|
1035
|
+
stop2();
|
|
1036
|
+
}
|
|
1037
|
+
return {
|
|
1038
|
+
width,
|
|
1039
|
+
height,
|
|
1040
|
+
stop
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Detects changes to a target element's visibility.
|
|
1045
|
+
*
|
|
1046
|
+
* @see https://vueuse.org/useIntersectionObserver
|
|
1047
|
+
* @param target
|
|
1048
|
+
* @param callback
|
|
1049
|
+
* @param options
|
|
1050
|
+
*/
|
|
1051
|
+
function useIntersectionObserver(target, callback, options = {}) {
|
|
1052
|
+
const { root, rootMargin, threshold = 0, window = defaultWindow, immediate = true } = options;
|
|
1053
|
+
const isSupported = /* @__PURE__ */ useSupported(() => window && "IntersectionObserver" in window);
|
|
1054
|
+
const targets = computed(() => {
|
|
1055
|
+
return toArray(toValue(target)).map(unrefElement).filter(notNullish);
|
|
1056
|
+
});
|
|
1057
|
+
let cleanup = noop;
|
|
1058
|
+
const isActive = shallowRef(immediate);
|
|
1059
|
+
const stopWatch = isSupported.value ? watch(() => [
|
|
1060
|
+
targets.value,
|
|
1061
|
+
unrefElement(root),
|
|
1062
|
+
toValue(rootMargin),
|
|
1063
|
+
isActive.value
|
|
1064
|
+
], ([targets, root, rootMargin]) => {
|
|
1065
|
+
cleanup();
|
|
1066
|
+
if (!isActive.value) return;
|
|
1067
|
+
if (!targets.length) return;
|
|
1068
|
+
const observer = new IntersectionObserver(callback, {
|
|
1069
|
+
root: unrefElement(root),
|
|
1070
|
+
rootMargin,
|
|
1071
|
+
threshold
|
|
1072
|
+
});
|
|
1073
|
+
targets.forEach((el) => el && observer.observe(el));
|
|
1074
|
+
cleanup = () => {
|
|
1075
|
+
observer.disconnect();
|
|
1076
|
+
cleanup = noop;
|
|
1077
|
+
};
|
|
1078
|
+
}, {
|
|
1079
|
+
immediate,
|
|
1080
|
+
flush: "post"
|
|
1081
|
+
}) : noop;
|
|
1082
|
+
const stop = () => {
|
|
1083
|
+
cleanup();
|
|
1084
|
+
stopWatch();
|
|
1085
|
+
isActive.value = false;
|
|
1086
|
+
};
|
|
1087
|
+
tryOnScopeDispose(stop);
|
|
1088
|
+
return {
|
|
1089
|
+
isSupported,
|
|
1090
|
+
isActive,
|
|
1091
|
+
pause() {
|
|
1092
|
+
cleanup();
|
|
1093
|
+
isActive.value = false;
|
|
1094
|
+
},
|
|
1095
|
+
resume() {
|
|
1096
|
+
isActive.value = true;
|
|
1097
|
+
},
|
|
1098
|
+
stop
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* Track or set the focus state of a DOM element.
|
|
1103
|
+
*
|
|
1104
|
+
* @see https://vueuse.org/useFocus
|
|
1105
|
+
* @param target The target element for the focus and blur events.
|
|
1106
|
+
* @param options
|
|
1107
|
+
*/
|
|
1108
|
+
function useFocus(target, options = {}) {
|
|
1109
|
+
const { initialValue = false, focusVisible = false, preventScroll = false } = options;
|
|
1110
|
+
const innerFocused = shallowRef(false);
|
|
1111
|
+
const targetElement = computed(() => unrefElement(target));
|
|
1112
|
+
const listenerOptions = { passive: true };
|
|
1113
|
+
useEventListener(targetElement, "focus", (event) => {
|
|
1114
|
+
var _matches, _ref;
|
|
1115
|
+
if (!focusVisible || ((_matches = (_ref = event.target).matches) === null || _matches === void 0 ? void 0 : _matches.call(_ref, ":focus-visible"))) innerFocused.value = true;
|
|
1116
|
+
}, listenerOptions);
|
|
1117
|
+
useEventListener(targetElement, "blur", () => innerFocused.value = false, listenerOptions);
|
|
1118
|
+
const focused = computed({
|
|
1119
|
+
get: () => innerFocused.value,
|
|
1120
|
+
set(value) {
|
|
1121
|
+
var _targetElement$value, _targetElement$value2;
|
|
1122
|
+
if (!value && innerFocused.value) (_targetElement$value = targetElement.value) === null || _targetElement$value === void 0 || _targetElement$value.blur();
|
|
1123
|
+
else if (value && !innerFocused.value) (_targetElement$value2 = targetElement.value) === null || _targetElement$value2 === void 0 || _targetElement$value2.focus({ preventScroll });
|
|
1124
|
+
}
|
|
1125
|
+
});
|
|
1126
|
+
watch(targetElement, () => {
|
|
1127
|
+
focused.value = initialValue;
|
|
1128
|
+
}, {
|
|
1129
|
+
immediate: true,
|
|
1130
|
+
flush: "post"
|
|
1131
|
+
});
|
|
1132
|
+
return { focused };
|
|
1133
|
+
}
|
|
1134
|
+
var EVENT_FOCUS_IN = "focusin";
|
|
1135
|
+
var EVENT_FOCUS_OUT = "focusout";
|
|
1136
|
+
var PSEUDO_CLASS_FOCUS_WITHIN = ":focus-within";
|
|
1137
|
+
/**
|
|
1138
|
+
* Track if focus is contained within the target element
|
|
1139
|
+
*
|
|
1140
|
+
* @see https://vueuse.org/useFocusWithin
|
|
1141
|
+
* @param target The target element to track
|
|
1142
|
+
* @param options Focus within options
|
|
1143
|
+
*/
|
|
1144
|
+
function useFocusWithin(target, options = {}) {
|
|
1145
|
+
const { window = defaultWindow } = options;
|
|
1146
|
+
const targetElement = computed(() => unrefElement(target));
|
|
1147
|
+
const _focused = shallowRef(false);
|
|
1148
|
+
const focused = computed(() => _focused.value);
|
|
1149
|
+
const activeElement = useActiveElement(options);
|
|
1150
|
+
if (!window || !activeElement.value) return { focused };
|
|
1151
|
+
const listenerOptions = { passive: true };
|
|
1152
|
+
useEventListener(targetElement, EVENT_FOCUS_IN, () => _focused.value = true, listenerOptions);
|
|
1153
|
+
useEventListener(targetElement, EVENT_FOCUS_OUT, () => {
|
|
1154
|
+
var _targetElement$value$, _targetElement$value, _targetElement$value$2;
|
|
1155
|
+
return _focused.value = (_targetElement$value$ = (_targetElement$value = targetElement.value) === null || _targetElement$value === void 0 || (_targetElement$value$2 = _targetElement$value.matches) === null || _targetElement$value$2 === void 0 ? void 0 : _targetElement$value$2.call(_targetElement$value, PSEUDO_CLASS_FOCUS_WITHIN)) !== null && _targetElement$value$ !== void 0 ? _targetElement$value$ : false;
|
|
1156
|
+
}, listenerOptions);
|
|
1157
|
+
return { focused };
|
|
1158
|
+
}
|
|
1159
|
+
/**
|
|
1160
|
+
* We have to check if the scroll amount is close enough to some threshold in order to
|
|
1161
|
+
* more accurately calculate arrivedState. This is because scrollTop/scrollLeft are non-rounded
|
|
1162
|
+
* numbers, while scrollHeight/scrollWidth and clientHeight/clientWidth are rounded.
|
|
1163
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#determine_if_an_element_has_been_totally_scrolled
|
|
1164
|
+
*/
|
|
1165
|
+
var ARRIVED_STATE_THRESHOLD_PIXELS = 1;
|
|
1166
|
+
/**
|
|
1167
|
+
* Reactive scroll.
|
|
1168
|
+
*
|
|
1169
|
+
* @see https://vueuse.org/useScroll
|
|
1170
|
+
* @param element
|
|
1171
|
+
* @param options
|
|
1172
|
+
*/
|
|
1173
|
+
function useScroll(element, options = {}) {
|
|
1174
|
+
const { throttle = 0, idle = 200, onStop = noop, onScroll = noop, offset = {
|
|
1175
|
+
left: 0,
|
|
1176
|
+
right: 0,
|
|
1177
|
+
top: 0,
|
|
1178
|
+
bottom: 0
|
|
1179
|
+
}, observe: _observe = { mutation: false }, eventListenerOptions = {
|
|
1180
|
+
capture: false,
|
|
1181
|
+
passive: true
|
|
1182
|
+
}, behavior = "auto", window = defaultWindow, onError = (e) => {
|
|
1183
|
+
console.error(e);
|
|
1184
|
+
} } = options;
|
|
1185
|
+
const observe = typeof _observe === "boolean" ? { mutation: _observe } : _observe;
|
|
1186
|
+
const internalX = shallowRef(0);
|
|
1187
|
+
const internalY = shallowRef(0);
|
|
1188
|
+
const x = computed({
|
|
1189
|
+
get() {
|
|
1190
|
+
return internalX.value;
|
|
1191
|
+
},
|
|
1192
|
+
set(x) {
|
|
1193
|
+
scrollTo(x, void 0);
|
|
1194
|
+
}
|
|
1195
|
+
});
|
|
1196
|
+
const y = computed({
|
|
1197
|
+
get() {
|
|
1198
|
+
return internalY.value;
|
|
1199
|
+
},
|
|
1200
|
+
set(y) {
|
|
1201
|
+
scrollTo(void 0, y);
|
|
1202
|
+
}
|
|
1203
|
+
});
|
|
1204
|
+
function scrollTo(_x, _y) {
|
|
1205
|
+
var _ref, _toValue, _toValue2, _document;
|
|
1206
|
+
if (!window) return;
|
|
1207
|
+
const _element = toValue(element);
|
|
1208
|
+
if (!_element) return;
|
|
1209
|
+
(_ref = _element instanceof Document ? window.document.body : _element) === null || _ref === void 0 || _ref.scrollTo({
|
|
1210
|
+
top: (_toValue = toValue(_y)) !== null && _toValue !== void 0 ? _toValue : y.value,
|
|
1211
|
+
left: (_toValue2 = toValue(_x)) !== null && _toValue2 !== void 0 ? _toValue2 : x.value,
|
|
1212
|
+
behavior: toValue(behavior)
|
|
1213
|
+
});
|
|
1214
|
+
const scrollContainer = (_element === null || _element === void 0 || (_document = _element.document) === null || _document === void 0 ? void 0 : _document.documentElement) || (_element === null || _element === void 0 ? void 0 : _element.documentElement) || _element;
|
|
1215
|
+
if (x != null) internalX.value = scrollContainer.scrollLeft;
|
|
1216
|
+
if (y != null) internalY.value = scrollContainer.scrollTop;
|
|
1217
|
+
}
|
|
1218
|
+
const isScrolling = shallowRef(false);
|
|
1219
|
+
const arrivedState = reactive({
|
|
1220
|
+
left: true,
|
|
1221
|
+
right: false,
|
|
1222
|
+
top: true,
|
|
1223
|
+
bottom: false
|
|
1224
|
+
});
|
|
1225
|
+
const directions = reactive({
|
|
1226
|
+
left: false,
|
|
1227
|
+
right: false,
|
|
1228
|
+
top: false,
|
|
1229
|
+
bottom: false
|
|
1230
|
+
});
|
|
1231
|
+
const onScrollEnd = (e) => {
|
|
1232
|
+
if (!isScrolling.value) return;
|
|
1233
|
+
isScrolling.value = false;
|
|
1234
|
+
directions.left = false;
|
|
1235
|
+
directions.right = false;
|
|
1236
|
+
directions.top = false;
|
|
1237
|
+
directions.bottom = false;
|
|
1238
|
+
onStop(e);
|
|
1239
|
+
};
|
|
1240
|
+
const onScrollEndDebounced = useDebounceFn(onScrollEnd, throttle + idle);
|
|
1241
|
+
const setArrivedState = (target) => {
|
|
1242
|
+
var _document2;
|
|
1243
|
+
if (!window) return;
|
|
1244
|
+
const el = (target === null || target === void 0 || (_document2 = target.document) === null || _document2 === void 0 ? void 0 : _document2.documentElement) || (target === null || target === void 0 ? void 0 : target.documentElement) || unrefElement(target);
|
|
1245
|
+
const { display, flexDirection, direction } = window.getComputedStyle(el);
|
|
1246
|
+
const directionMultipler = direction === "rtl" ? -1 : 1;
|
|
1247
|
+
const scrollLeft = el.scrollLeft;
|
|
1248
|
+
directions.left = scrollLeft < internalX.value;
|
|
1249
|
+
directions.right = scrollLeft > internalX.value;
|
|
1250
|
+
const left = Math.abs(scrollLeft * directionMultipler) <= (offset.left || 0);
|
|
1251
|
+
const right = Math.abs(scrollLeft * directionMultipler) + el.clientWidth >= el.scrollWidth - (offset.right || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
|
|
1252
|
+
if (display === "flex" && flexDirection === "row-reverse") {
|
|
1253
|
+
arrivedState.left = right;
|
|
1254
|
+
arrivedState.right = left;
|
|
1255
|
+
} else {
|
|
1256
|
+
arrivedState.left = left;
|
|
1257
|
+
arrivedState.right = right;
|
|
1258
|
+
}
|
|
1259
|
+
internalX.value = scrollLeft;
|
|
1260
|
+
let scrollTop = el.scrollTop;
|
|
1261
|
+
if (target === window.document && !scrollTop) scrollTop = window.document.body.scrollTop;
|
|
1262
|
+
directions.top = scrollTop < internalY.value;
|
|
1263
|
+
directions.bottom = scrollTop > internalY.value;
|
|
1264
|
+
const top = Math.abs(scrollTop) <= (offset.top || 0);
|
|
1265
|
+
const bottom = Math.abs(scrollTop) + el.clientHeight >= el.scrollHeight - (offset.bottom || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
|
|
1266
|
+
/**
|
|
1267
|
+
* reverse columns and rows behave exactly the other way around,
|
|
1268
|
+
* bottom is treated as top and top is treated as the negative version of bottom
|
|
1269
|
+
*/
|
|
1270
|
+
if (display === "flex" && flexDirection === "column-reverse") {
|
|
1271
|
+
arrivedState.top = bottom;
|
|
1272
|
+
arrivedState.bottom = top;
|
|
1273
|
+
} else {
|
|
1274
|
+
arrivedState.top = top;
|
|
1275
|
+
arrivedState.bottom = bottom;
|
|
1276
|
+
}
|
|
1277
|
+
internalY.value = scrollTop;
|
|
1278
|
+
};
|
|
1279
|
+
const onScrollHandler = (e) => {
|
|
1280
|
+
var _documentElement;
|
|
1281
|
+
if (!window) return;
|
|
1282
|
+
const eventTarget = (_documentElement = e.target.documentElement) !== null && _documentElement !== void 0 ? _documentElement : e.target;
|
|
1283
|
+
setArrivedState(eventTarget);
|
|
1284
|
+
isScrolling.value = true;
|
|
1285
|
+
onScrollEndDebounced(e);
|
|
1286
|
+
onScroll(e);
|
|
1287
|
+
};
|
|
1288
|
+
useEventListener(element, "scroll", throttle ? useThrottleFn(onScrollHandler, throttle, true, false) : onScrollHandler, eventListenerOptions);
|
|
1289
|
+
tryOnMounted(() => {
|
|
1290
|
+
try {
|
|
1291
|
+
const _element = toValue(element);
|
|
1292
|
+
if (!_element) return;
|
|
1293
|
+
setArrivedState(_element);
|
|
1294
|
+
} catch (e) {
|
|
1295
|
+
onError(e);
|
|
1296
|
+
}
|
|
1297
|
+
});
|
|
1298
|
+
if ((observe === null || observe === void 0 ? void 0 : observe.mutation) && element != null && element !== window && element !== document) useMutationObserver(element, () => {
|
|
1299
|
+
const _element = toValue(element);
|
|
1300
|
+
if (!_element) return;
|
|
1301
|
+
setArrivedState(_element);
|
|
1302
|
+
}, {
|
|
1303
|
+
attributes: true,
|
|
1304
|
+
childList: true,
|
|
1305
|
+
subtree: true
|
|
1306
|
+
});
|
|
1307
|
+
useEventListener(element, "scrollend", onScrollEnd, eventListenerOptions);
|
|
1308
|
+
return {
|
|
1309
|
+
x,
|
|
1310
|
+
y,
|
|
1311
|
+
isScrolling,
|
|
1312
|
+
arrivedState,
|
|
1313
|
+
directions,
|
|
1314
|
+
measure() {
|
|
1315
|
+
const _element = toValue(element);
|
|
1316
|
+
if (window && _element) setArrivedState(_element);
|
|
1317
|
+
}
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
/**
|
|
1321
|
+
* Reactive prefers-reduced-motion media query.
|
|
1322
|
+
*
|
|
1323
|
+
* @see https://vueuse.org/usePreferredReducedMotion
|
|
1324
|
+
* @param [options]
|
|
1325
|
+
*
|
|
1326
|
+
* @__NO_SIDE_EFFECTS__
|
|
1327
|
+
*/
|
|
1328
|
+
function usePreferredReducedMotion(options) {
|
|
1329
|
+
const isReduced = useMediaQuery("(prefers-reduced-motion: reduce)", options);
|
|
1330
|
+
return computed(() => {
|
|
1331
|
+
if (isReduced.value) return "reduce";
|
|
1332
|
+
return "no-preference";
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
Number.POSITIVE_INFINITY;
|
|
1336
|
+
/**
|
|
1337
|
+
* Please consider using [`vue-virtual-scroller`](https://github.com/Akryum/vue-virtual-scroller) if you are looking for more features.
|
|
1338
|
+
*/
|
|
1339
|
+
function useVirtualList(list, options) {
|
|
1340
|
+
const { containerStyle, wrapperProps, scrollTo, calculateRange, currentList, containerRef } = "itemHeight" in options ? useVerticalVirtualList(options, list) : useHorizontalVirtualList(options, list);
|
|
1341
|
+
return {
|
|
1342
|
+
list: currentList,
|
|
1343
|
+
scrollTo,
|
|
1344
|
+
containerProps: {
|
|
1345
|
+
ref: containerRef,
|
|
1346
|
+
onScroll: () => {
|
|
1347
|
+
calculateRange();
|
|
1348
|
+
},
|
|
1349
|
+
style: containerStyle
|
|
1350
|
+
},
|
|
1351
|
+
wrapperProps
|
|
1352
|
+
};
|
|
1353
|
+
}
|
|
1354
|
+
function useVirtualListResources(list) {
|
|
1355
|
+
const containerRef = shallowRef(null);
|
|
1356
|
+
const size = useElementSize(containerRef);
|
|
1357
|
+
const currentList = ref([]);
|
|
1358
|
+
const source = shallowRef(list);
|
|
1359
|
+
return {
|
|
1360
|
+
state: ref({
|
|
1361
|
+
start: 0,
|
|
1362
|
+
end: 10
|
|
1363
|
+
}),
|
|
1364
|
+
source,
|
|
1365
|
+
currentList,
|
|
1366
|
+
size,
|
|
1367
|
+
containerRef
|
|
1368
|
+
};
|
|
1369
|
+
}
|
|
1370
|
+
function createGetViewCapacity(state, source, itemSize) {
|
|
1371
|
+
return (containerSize) => {
|
|
1372
|
+
if (typeof itemSize === "number") return Math.ceil(containerSize / itemSize);
|
|
1373
|
+
const { start = 0 } = state.value;
|
|
1374
|
+
let sum = 0;
|
|
1375
|
+
let capacity = 0;
|
|
1376
|
+
for (let i = start; i < source.value.length; i++) {
|
|
1377
|
+
const size = itemSize(i);
|
|
1378
|
+
sum += size;
|
|
1379
|
+
capacity = i;
|
|
1380
|
+
if (sum > containerSize) break;
|
|
1381
|
+
}
|
|
1382
|
+
return capacity - start;
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
function createGetOffset(source, itemSize) {
|
|
1386
|
+
return (scrollDirection) => {
|
|
1387
|
+
if (typeof itemSize === "number") return Math.floor(scrollDirection / itemSize) + 1;
|
|
1388
|
+
let sum = 0;
|
|
1389
|
+
let offset = 0;
|
|
1390
|
+
for (let i = 0; i < source.value.length; i++) {
|
|
1391
|
+
const size = itemSize(i);
|
|
1392
|
+
sum += size;
|
|
1393
|
+
if (sum >= scrollDirection) {
|
|
1394
|
+
offset = i;
|
|
1395
|
+
break;
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
return offset + 1;
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
function createCalculateRange(type, overscan, getOffset, getViewCapacity, { containerRef, state, currentList, source }) {
|
|
1402
|
+
return () => {
|
|
1403
|
+
const element = containerRef.value;
|
|
1404
|
+
if (element) {
|
|
1405
|
+
const offset = getOffset(type === "vertical" ? element.scrollTop : element.scrollLeft);
|
|
1406
|
+
const viewCapacity = getViewCapacity(type === "vertical" ? element.clientHeight : element.clientWidth);
|
|
1407
|
+
const from = offset - overscan;
|
|
1408
|
+
const to = offset + viewCapacity + overscan;
|
|
1409
|
+
state.value = {
|
|
1410
|
+
start: from < 0 ? 0 : from,
|
|
1411
|
+
end: to > source.value.length ? source.value.length : to
|
|
1412
|
+
};
|
|
1413
|
+
currentList.value = source.value.slice(state.value.start, state.value.end).map((ele, index) => ({
|
|
1414
|
+
data: ele,
|
|
1415
|
+
index: index + state.value.start
|
|
1416
|
+
}));
|
|
1417
|
+
}
|
|
1418
|
+
};
|
|
1419
|
+
}
|
|
1420
|
+
function createGetDistance(itemSize, source) {
|
|
1421
|
+
return (index) => {
|
|
1422
|
+
if (typeof itemSize === "number") return index * itemSize;
|
|
1423
|
+
return source.value.slice(0, index).reduce((sum, _, i) => sum + itemSize(i), 0);
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
function useWatchForSizes(size, listRef, totalSize, containerRef, calculateRange) {
|
|
1427
|
+
watch([
|
|
1428
|
+
size.width,
|
|
1429
|
+
size.height,
|
|
1430
|
+
listRef,
|
|
1431
|
+
totalSize,
|
|
1432
|
+
containerRef
|
|
1433
|
+
], () => {
|
|
1434
|
+
calculateRange();
|
|
1435
|
+
});
|
|
1436
|
+
}
|
|
1437
|
+
function createComputedTotalSize(itemSize, source) {
|
|
1438
|
+
return computed(() => {
|
|
1439
|
+
if (typeof itemSize === "number") return source.value.length * itemSize;
|
|
1440
|
+
return source.value.reduce((sum, _, index) => sum + itemSize(index), 0);
|
|
1441
|
+
});
|
|
1442
|
+
}
|
|
1443
|
+
var scrollToDictionaryForElementScrollKey = {
|
|
1444
|
+
horizontal: "scrollLeft",
|
|
1445
|
+
vertical: "scrollTop"
|
|
1446
|
+
};
|
|
1447
|
+
var scrollToDictionaryForElementScrollToKey = {
|
|
1448
|
+
horizontal: "left",
|
|
1449
|
+
vertical: "top"
|
|
1450
|
+
};
|
|
1451
|
+
var defaultScrollToOptions = {
|
|
1452
|
+
behavior: "auto",
|
|
1453
|
+
block: "start",
|
|
1454
|
+
inline: "nearest"
|
|
1455
|
+
};
|
|
1456
|
+
function createScrollTo(type, calculateRange, getDistance, containerRef, itemSize) {
|
|
1457
|
+
return (index, options = defaultScrollToOptions) => {
|
|
1458
|
+
if (!containerRef.value) return;
|
|
1459
|
+
options = {
|
|
1460
|
+
...defaultScrollToOptions,
|
|
1461
|
+
...options
|
|
1462
|
+
};
|
|
1463
|
+
let offset = 0;
|
|
1464
|
+
const axisToCheck = options[type === "horizontal" ? "inline" : "block"];
|
|
1465
|
+
if (axisToCheck) {
|
|
1466
|
+
const containerSize = type === "horizontal" ? containerRef.value.clientWidth : containerRef.value.clientHeight;
|
|
1467
|
+
const fullItemSize = typeof itemSize === "number" ? itemSize : itemSize(index);
|
|
1468
|
+
if (axisToCheck === "center") offset = containerSize / 2 - fullItemSize / 2;
|
|
1469
|
+
else if (axisToCheck === "end") offset = containerSize - fullItemSize;
|
|
1470
|
+
else if (axisToCheck === "nearest") {
|
|
1471
|
+
const containerScrollPosition = containerRef.value[scrollToDictionaryForElementScrollKey[type]];
|
|
1472
|
+
if (getDistance(index) > containerScrollPosition + containerSize / 2) offset = containerSize - fullItemSize;
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
containerRef.value.scrollTo({
|
|
1476
|
+
[scrollToDictionaryForElementScrollToKey[type]]: getDistance(index) - offset,
|
|
1477
|
+
behavior: options.behavior
|
|
1478
|
+
});
|
|
1479
|
+
calculateRange();
|
|
1480
|
+
};
|
|
1481
|
+
}
|
|
1482
|
+
function useHorizontalVirtualList(options, list) {
|
|
1483
|
+
const resources = useVirtualListResources(list);
|
|
1484
|
+
const { state, source, currentList, size, containerRef } = resources;
|
|
1485
|
+
const containerStyle = { overflowX: "auto" };
|
|
1486
|
+
const { itemWidth, overscan = 5 } = options;
|
|
1487
|
+
const getViewCapacity = createGetViewCapacity(state, source, itemWidth);
|
|
1488
|
+
const calculateRange = createCalculateRange("horizontal", overscan, createGetOffset(source, itemWidth), getViewCapacity, resources);
|
|
1489
|
+
const getDistanceLeft = createGetDistance(itemWidth, source);
|
|
1490
|
+
const offsetLeft = computed(() => getDistanceLeft(state.value.start));
|
|
1491
|
+
const totalWidth = createComputedTotalSize(itemWidth, source);
|
|
1492
|
+
useWatchForSizes(size, source, totalWidth, containerRef, calculateRange);
|
|
1493
|
+
return {
|
|
1494
|
+
scrollTo: createScrollTo("horizontal", calculateRange, getDistanceLeft, containerRef, itemWidth),
|
|
1495
|
+
calculateRange,
|
|
1496
|
+
wrapperProps: computed(() => {
|
|
1497
|
+
return { style: {
|
|
1498
|
+
height: "100%",
|
|
1499
|
+
width: `${totalWidth.value - offsetLeft.value}px`,
|
|
1500
|
+
marginLeft: `${offsetLeft.value}px`,
|
|
1501
|
+
display: "flex"
|
|
1502
|
+
} };
|
|
1503
|
+
}),
|
|
1504
|
+
containerStyle,
|
|
1505
|
+
currentList,
|
|
1506
|
+
containerRef
|
|
1507
|
+
};
|
|
1508
|
+
}
|
|
1509
|
+
function useVerticalVirtualList(options, list) {
|
|
1510
|
+
const resources = useVirtualListResources(list);
|
|
1511
|
+
const { state, source, currentList, size, containerRef } = resources;
|
|
1512
|
+
const containerStyle = { overflowY: "auto" };
|
|
1513
|
+
const { itemHeight, overscan = 5 } = options;
|
|
1514
|
+
const getViewCapacity = createGetViewCapacity(state, source, itemHeight);
|
|
1515
|
+
const calculateRange = createCalculateRange("vertical", overscan, createGetOffset(source, itemHeight), getViewCapacity, resources);
|
|
1516
|
+
const getDistanceTop = createGetDistance(itemHeight, source);
|
|
1517
|
+
const offsetTop = computed(() => getDistanceTop(state.value.start));
|
|
1518
|
+
const totalHeight = createComputedTotalSize(itemHeight, source);
|
|
1519
|
+
useWatchForSizes(size, source, totalHeight, containerRef, calculateRange);
|
|
1520
|
+
return {
|
|
1521
|
+
calculateRange,
|
|
1522
|
+
scrollTo: createScrollTo("vertical", calculateRange, getDistanceTop, containerRef, itemHeight),
|
|
1523
|
+
containerStyle,
|
|
1524
|
+
wrapperProps: computed(() => {
|
|
1525
|
+
return { style: {
|
|
1526
|
+
width: "100%",
|
|
1527
|
+
height: `${totalHeight.value - offsetTop.value}px`,
|
|
1528
|
+
marginTop: `${offsetTop.value}px`
|
|
1529
|
+
} };
|
|
1530
|
+
}),
|
|
1531
|
+
currentList,
|
|
1532
|
+
containerRef
|
|
1533
|
+
};
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* Reactive window size.
|
|
1537
|
+
*
|
|
1538
|
+
* @see https://vueuse.org/useWindowSize
|
|
1539
|
+
* @param options
|
|
1540
|
+
*
|
|
1541
|
+
* @__NO_SIDE_EFFECTS__
|
|
1542
|
+
*/
|
|
1543
|
+
function useWindowSize(options = {}) {
|
|
1544
|
+
const { window = defaultWindow, initialWidth = Number.POSITIVE_INFINITY, initialHeight = Number.POSITIVE_INFINITY, listenOrientation = true, includeScrollbar = true, type = "inner" } = options;
|
|
1545
|
+
const width = shallowRef(initialWidth);
|
|
1546
|
+
const height = shallowRef(initialHeight);
|
|
1547
|
+
const update = () => {
|
|
1548
|
+
if (window) if (type === "outer") {
|
|
1549
|
+
width.value = window.outerWidth;
|
|
1550
|
+
height.value = window.outerHeight;
|
|
1551
|
+
} else if (type === "visual" && window.visualViewport) {
|
|
1552
|
+
const { width: visualViewportWidth, height: visualViewportHeight, scale } = window.visualViewport;
|
|
1553
|
+
width.value = Math.round(visualViewportWidth * scale);
|
|
1554
|
+
height.value = Math.round(visualViewportHeight * scale);
|
|
1555
|
+
} else if (includeScrollbar) {
|
|
1556
|
+
width.value = window.innerWidth;
|
|
1557
|
+
height.value = window.innerHeight;
|
|
1558
|
+
} else {
|
|
1559
|
+
width.value = window.document.documentElement.clientWidth;
|
|
1560
|
+
height.value = window.document.documentElement.clientHeight;
|
|
1561
|
+
}
|
|
1562
|
+
};
|
|
1563
|
+
update();
|
|
1564
|
+
tryOnMounted(update);
|
|
1565
|
+
const listenerOptions = { passive: true };
|
|
1566
|
+
useEventListener("resize", update, listenerOptions);
|
|
1567
|
+
if (window && type === "visual" && window.visualViewport) useEventListener(window.visualViewport, "resize", update, listenerOptions);
|
|
1568
|
+
if (listenOrientation) watch(useMediaQuery("(orientation: portrait)"), () => update());
|
|
1569
|
+
return {
|
|
1570
|
+
width,
|
|
1571
|
+
height
|
|
1572
|
+
};
|
|
1573
|
+
}
|
|
1574
|
+
//#endregion
|
|
1575
|
+
export { StorageSerializers, breakpointsTailwind, bypassFilter, clamp, createFilterWrapper, createSharedComposable, createSingletonPromise, customStorageEventName, debounceFilter, defaultNavigator, defaultWindow, get, getLifeCycleTarget, getSSRHandler, increaseWithUnit, injectLocal, isClient, isDefined, isIOS, isObject, noop, notNullish, objectOmit, objectPick, onClickOutside, onElementRemoval, pausableFilter, pxValue, refDebounced, set, throttleFilter, toArray, toRef$1 as toRef, tryOnMounted, tryOnScopeDispose, unrefElement, useActiveElement, useArrayMap, useBreakpoints, useClipboard, useColorMode, useDebounceFn, useDropZone, useElementBounding, useElementSize, useEventListener, useFocus, useFocusWithin, useIntersectionObserver, useMediaQuery, useMounted, useMutationObserver, usePermission, usePreferredDark, usePreferredReducedMotion, useResizeObserver, useSSRWidth, useScroll, useStorage, useSupported, useThrottleFn, useTimeoutFn, useVirtualList, useWindowSize, watchDebounced, watchIgnorable, watchImmediate, watchPausable, watchWithFilter, whenever };
|
|
1576
|
+
|
|
1577
|
+
//# sourceMappingURL=index.js.map
|