@gct-paas/core-web 0.1.4-dev.0 → 0.1.4-dev.2
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/index.min.cjs +12 -12
- package/dist/index.system.min.js +12 -12
- package/es/editor/index.mjs +1 -1
- package/es/index.d.ts +1 -0
- package/es/index.mjs +2 -0
- package/es/node_modules/.pnpm/{@vueuse_core@10.11.1_vue@3.5.13_typescript@5.8.3_ → @vueuse_core@13.7.0_vue@3.5.18_typescript@5.9.2_}/node_modules/@vueuse/core/index.mjs +1717 -919
- package/es/node_modules/.pnpm/{@vueuse_shared@10.11.1_vue@3.5.13_typescript@5.8.3_ → @vueuse_shared@13.7.0_vue@3.5.18_typescript@5.9.2_}/node_modules/@vueuse/shared/index.mjs +271 -206
- package/es/node_modules/.pnpm/{vue3-colorpicker@2.3.0_@aesoper_normal-utils@0.1.5_@popperjs_core@2.11.8_@vueuse_core@1_9cfe46f6a11310063dbf07d888abdb76 → vue3-colorpicker@2.3.0_@aesoper_normal-utils@0.1.5_@popperjs_core@2.11.8_@vueuse_core@1_c6850a6c65df63e96440af393dfce213}/node_modules/vue3-colorpicker/index.es.mjs +3 -3
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.mjs +3 -0
- package/es/utils/with-install.d.ts +14 -0
- package/es/utils/with-install.mjs +14 -0
- package/package.json +7 -8
- package/es/node_modules/.pnpm/vue-demi@0.14.10_vue@3.5.13_typescript@5.8.3_/node_modules/vue-demi/lib/index.mjs +0 -29
- /package/es/node_modules/.pnpm/{vue-types@3.0.2_vue@3.5.13_typescript@5.8.3_ → vue-types@3.0.2_vue@3.5.18_typescript@5.9.2_}/node_modules/vue-types/dist/vue-types.m.mjs +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { shallowRef, watchEffect, readonly, ref, watch, customRef, getCurrentScope, onScopeDispose, effectScope, getCurrentInstance, provide, inject, version, isRef, unref, computed, reactive, toRefs as toRefs$1, toRef as toRef$1, onBeforeMount, nextTick, onBeforeUnmount, onMounted, onUnmounted, isReactive } from 'vue';
|
|
1
|
+
import { shallowRef, watchEffect, readonly, watch, customRef, getCurrentScope, onScopeDispose, effectScope, getCurrentInstance, hasInjectionContext, inject, provide, ref, isRef, unref, toValue as toValue$1, computed, reactive, toRefs as toRefs$1, toRef as toRef$1, shallowReadonly, onBeforeMount, nextTick, onBeforeUnmount, onMounted, onUnmounted, isReactive } from 'vue';
|
|
3
2
|
|
|
4
3
|
function computedEager(fn, options) {
|
|
5
4
|
var _a;
|
|
@@ -13,16 +12,16 @@ function computedEager(fn, options) {
|
|
|
13
12
|
return readonly(result);
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
function computedWithControl(source, fn) {
|
|
15
|
+
function computedWithControl(source, fn, options = {}) {
|
|
17
16
|
let v = void 0;
|
|
18
17
|
let track;
|
|
19
18
|
let trigger;
|
|
20
|
-
|
|
19
|
+
let dirty = true;
|
|
21
20
|
const update = () => {
|
|
22
|
-
dirty
|
|
21
|
+
dirty = true;
|
|
23
22
|
trigger();
|
|
24
23
|
};
|
|
25
|
-
watch(source, update, { flush: "sync" });
|
|
24
|
+
watch(source, update, { flush: "sync", ...options });
|
|
26
25
|
const get = typeof fn === "function" ? fn : fn.get;
|
|
27
26
|
const set = typeof fn === "function" ? void 0 : fn.set;
|
|
28
27
|
const result = customRef((_track, _trigger) => {
|
|
@@ -30,9 +29,9 @@ function computedWithControl(source, fn) {
|
|
|
30
29
|
trigger = _trigger;
|
|
31
30
|
return {
|
|
32
31
|
get() {
|
|
33
|
-
if (dirty
|
|
34
|
-
v = get();
|
|
35
|
-
dirty
|
|
32
|
+
if (dirty) {
|
|
33
|
+
v = get(v);
|
|
34
|
+
dirty = false;
|
|
36
35
|
}
|
|
37
36
|
track();
|
|
38
37
|
return v;
|
|
@@ -42,8 +41,7 @@ function computedWithControl(source, fn) {
|
|
|
42
41
|
}
|
|
43
42
|
};
|
|
44
43
|
});
|
|
45
|
-
|
|
46
|
-
result.trigger = update;
|
|
44
|
+
result.trigger = update;
|
|
47
45
|
return result;
|
|
48
46
|
}
|
|
49
47
|
|
|
@@ -55,11 +53,15 @@ function tryOnScopeDispose(fn) {
|
|
|
55
53
|
return false;
|
|
56
54
|
}
|
|
57
55
|
|
|
56
|
+
// @__NO_SIDE_EFFECTS__
|
|
58
57
|
function createEventHook() {
|
|
59
58
|
const fns = /* @__PURE__ */ new Set();
|
|
60
59
|
const off = (fn) => {
|
|
61
60
|
fns.delete(fn);
|
|
62
61
|
};
|
|
62
|
+
const clear = () => {
|
|
63
|
+
fns.clear();
|
|
64
|
+
};
|
|
63
65
|
const on = (fn) => {
|
|
64
66
|
fns.add(fn);
|
|
65
67
|
const offFn = () => off(fn);
|
|
@@ -74,10 +76,12 @@ function createEventHook() {
|
|
|
74
76
|
return {
|
|
75
77
|
on,
|
|
76
78
|
off,
|
|
77
|
-
trigger
|
|
79
|
+
trigger,
|
|
80
|
+
clear
|
|
78
81
|
};
|
|
79
82
|
}
|
|
80
83
|
|
|
84
|
+
// @__NO_SIDE_EFFECTS__
|
|
81
85
|
function createGlobalState(stateFactory) {
|
|
82
86
|
let initialized = false;
|
|
83
87
|
let state;
|
|
@@ -93,7 +97,18 @@ function createGlobalState(stateFactory) {
|
|
|
93
97
|
|
|
94
98
|
const localProvidedStateMap = /* @__PURE__ */ new WeakMap();
|
|
95
99
|
|
|
96
|
-
const
|
|
100
|
+
const injectLocal = /* @__NO_SIDE_EFFECTS__ */ (...args) => {
|
|
101
|
+
var _a;
|
|
102
|
+
const key = args[0];
|
|
103
|
+
const instance = (_a = getCurrentInstance()) == null ? void 0 : _a.proxy;
|
|
104
|
+
if (instance == null && !hasInjectionContext())
|
|
105
|
+
throw new Error("injectLocal must be called in setup");
|
|
106
|
+
if (instance && localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance))
|
|
107
|
+
return localProvidedStateMap.get(instance)[key];
|
|
108
|
+
return inject(...args);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
function provideLocal(key, value) {
|
|
97
112
|
var _a;
|
|
98
113
|
const instance = (_a = getCurrentInstance()) == null ? void 0 : _a.proxy;
|
|
99
114
|
if (instance == null)
|
|
@@ -102,20 +117,10 @@ const provideLocal = (key, value) => {
|
|
|
102
117
|
localProvidedStateMap.set(instance, /* @__PURE__ */ Object.create(null));
|
|
103
118
|
const localProvidedState = localProvidedStateMap.get(instance);
|
|
104
119
|
localProvidedState[key] = value;
|
|
105
|
-
provide(key, value);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const injectLocal = (...args) => {
|
|
109
|
-
var _a;
|
|
110
|
-
const key = args[0];
|
|
111
|
-
const instance = (_a = getCurrentInstance()) == null ? void 0 : _a.proxy;
|
|
112
|
-
if (instance == null)
|
|
113
|
-
throw new Error("injectLocal must be called in setup");
|
|
114
|
-
if (localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance))
|
|
115
|
-
return localProvidedStateMap.get(instance)[key];
|
|
116
|
-
return inject(...args);
|
|
117
|
-
};
|
|
120
|
+
return provide(key, value);
|
|
121
|
+
}
|
|
118
122
|
|
|
123
|
+
// @__NO_SIDE_EFFECTS__
|
|
119
124
|
function createInjectionState(composable, options) {
|
|
120
125
|
const key = (options == null ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState");
|
|
121
126
|
const defaultValue = options == null ? void 0 : options.defaultValue;
|
|
@@ -128,6 +133,16 @@ function createInjectionState(composable, options) {
|
|
|
128
133
|
return [useProvidingState, useInjectedState];
|
|
129
134
|
}
|
|
130
135
|
|
|
136
|
+
// @__NO_SIDE_EFFECTS__
|
|
137
|
+
function createRef(value, deep) {
|
|
138
|
+
if (deep === true) {
|
|
139
|
+
return ref(value);
|
|
140
|
+
} else {
|
|
141
|
+
return shallowRef(value);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// @__NO_SIDE_EFFECTS__
|
|
131
146
|
function createSharedComposable(composable) {
|
|
132
147
|
let subscribers = 0;
|
|
133
148
|
let state;
|
|
@@ -142,7 +157,7 @@ function createSharedComposable(composable) {
|
|
|
142
157
|
};
|
|
143
158
|
return (...args) => {
|
|
144
159
|
subscribers += 1;
|
|
145
|
-
if (!
|
|
160
|
+
if (!scope) {
|
|
146
161
|
scope = effectScope(true);
|
|
147
162
|
state = scope.run(() => composable(...args));
|
|
148
163
|
}
|
|
@@ -152,11 +167,6 @@ function createSharedComposable(composable) {
|
|
|
152
167
|
}
|
|
153
168
|
|
|
154
169
|
function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) {
|
|
155
|
-
if (!isVue3 && !version.startsWith("2.7.")) {
|
|
156
|
-
if (process.env.NODE_ENV !== "production")
|
|
157
|
-
throw new Error("[VueUse] extendRef only works in Vue 2.7 or above.");
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
170
|
for (const [key, value] of Object.entries(extend)) {
|
|
161
171
|
if (key === "value")
|
|
162
172
|
continue;
|
|
@@ -187,6 +197,7 @@ function isDefined(v) {
|
|
|
187
197
|
return unref(v) != null;
|
|
188
198
|
}
|
|
189
199
|
|
|
200
|
+
// @__NO_SIDE_EFFECTS__
|
|
190
201
|
function makeDestructurable(obj, arr) {
|
|
191
202
|
if (typeof Symbol !== "undefined") {
|
|
192
203
|
const clone = { ...obj };
|
|
@@ -208,18 +219,15 @@ function makeDestructurable(obj, arr) {
|
|
|
208
219
|
}
|
|
209
220
|
}
|
|
210
221
|
|
|
211
|
-
|
|
212
|
-
return typeof r === "function" ? r() : unref(r);
|
|
213
|
-
}
|
|
214
|
-
const resolveUnref = toValue;
|
|
215
|
-
|
|
222
|
+
// @__NO_SIDE_EFFECTS__
|
|
216
223
|
function reactify(fn, options) {
|
|
217
|
-
const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? unref : toValue;
|
|
224
|
+
const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? unref : toValue$1;
|
|
218
225
|
return function(...args) {
|
|
219
226
|
return computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
|
|
220
227
|
};
|
|
221
228
|
}
|
|
222
229
|
|
|
230
|
+
// @__NO_SIDE_EFFECTS__
|
|
223
231
|
function reactifyObject(obj, optionsOrKeys = {}) {
|
|
224
232
|
let keys = [];
|
|
225
233
|
let options;
|
|
@@ -283,7 +291,7 @@ function reactiveComputed(fn) {
|
|
|
283
291
|
function reactiveOmit(obj, ...keys) {
|
|
284
292
|
const flatKeys = keys.flat();
|
|
285
293
|
const predicate = flatKeys[0];
|
|
286
|
-
return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs$1(obj)).filter(([k, v]) => !predicate(toValue(v), k))) : Object.fromEntries(Object.entries(toRefs$1(obj)).filter((e) => !flatKeys.includes(e[0]))));
|
|
294
|
+
return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs$1(obj)).filter(([k, v]) => !predicate(toValue$1(v), k))) : Object.fromEntries(Object.entries(toRefs$1(obj)).filter((e) => !flatKeys.includes(e[0]))));
|
|
287
295
|
}
|
|
288
296
|
|
|
289
297
|
const isClient = typeof window !== "undefined" && typeof document !== "undefined";
|
|
@@ -313,6 +321,46 @@ function getIsIOS() {
|
|
|
313
321
|
return isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((_b = window == null ? void 0 : window.navigator) == null ? void 0 : _b.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window == null ? void 0 : window.navigator.userAgent));
|
|
314
322
|
}
|
|
315
323
|
|
|
324
|
+
function toRef(...args) {
|
|
325
|
+
if (args.length !== 1)
|
|
326
|
+
return toRef$1(...args);
|
|
327
|
+
const r = args[0];
|
|
328
|
+
return typeof r === "function" ? readonly(customRef(() => ({ get: r, set: noop }))) : ref(r);
|
|
329
|
+
}
|
|
330
|
+
const resolveRef = toRef;
|
|
331
|
+
|
|
332
|
+
function reactivePick(obj, ...keys) {
|
|
333
|
+
const flatKeys = keys.flat();
|
|
334
|
+
const predicate = flatKeys[0];
|
|
335
|
+
return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs$1(obj)).filter(([k, v]) => predicate(toValue$1(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function refAutoReset(defaultValue, afterMs = 1e4) {
|
|
339
|
+
return customRef((track, trigger) => {
|
|
340
|
+
let value = toValue$1(defaultValue);
|
|
341
|
+
let timer;
|
|
342
|
+
const resetAfter = () => setTimeout(() => {
|
|
343
|
+
value = toValue$1(defaultValue);
|
|
344
|
+
trigger();
|
|
345
|
+
}, toValue$1(afterMs));
|
|
346
|
+
tryOnScopeDispose(() => {
|
|
347
|
+
clearTimeout(timer);
|
|
348
|
+
});
|
|
349
|
+
return {
|
|
350
|
+
get() {
|
|
351
|
+
track();
|
|
352
|
+
return value;
|
|
353
|
+
},
|
|
354
|
+
set(newValue) {
|
|
355
|
+
value = newValue;
|
|
356
|
+
trigger();
|
|
357
|
+
clearTimeout(timer);
|
|
358
|
+
timer = resetAfter();
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
|
|
316
364
|
function createFilterWrapper(filter, fn) {
|
|
317
365
|
function wrapper(...args) {
|
|
318
366
|
return new Promise((resolve, reject) => {
|
|
@@ -333,32 +381,34 @@ function debounceFilter(ms, options = {}) {
|
|
|
333
381
|
lastRejector();
|
|
334
382
|
lastRejector = noop;
|
|
335
383
|
};
|
|
384
|
+
let lastInvoker;
|
|
336
385
|
const filter = (invoke) => {
|
|
337
|
-
const duration = toValue(ms);
|
|
338
|
-
const maxDuration = toValue(options.maxWait);
|
|
386
|
+
const duration = toValue$1(ms);
|
|
387
|
+
const maxDuration = toValue$1(options.maxWait);
|
|
339
388
|
if (timer)
|
|
340
389
|
_clearTimeout(timer);
|
|
341
390
|
if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
|
|
342
391
|
if (maxTimer) {
|
|
343
392
|
_clearTimeout(maxTimer);
|
|
344
|
-
maxTimer =
|
|
393
|
+
maxTimer = void 0;
|
|
345
394
|
}
|
|
346
395
|
return Promise.resolve(invoke());
|
|
347
396
|
}
|
|
348
397
|
return new Promise((resolve, reject) => {
|
|
349
398
|
lastRejector = options.rejectOnCancel ? reject : resolve;
|
|
399
|
+
lastInvoker = invoke;
|
|
350
400
|
if (maxDuration && !maxTimer) {
|
|
351
401
|
maxTimer = setTimeout(() => {
|
|
352
402
|
if (timer)
|
|
353
403
|
_clearTimeout(timer);
|
|
354
|
-
maxTimer =
|
|
355
|
-
resolve(
|
|
404
|
+
maxTimer = void 0;
|
|
405
|
+
resolve(lastInvoker());
|
|
356
406
|
}, maxDuration);
|
|
357
407
|
}
|
|
358
408
|
timer = setTimeout(() => {
|
|
359
409
|
if (maxTimer)
|
|
360
410
|
_clearTimeout(maxTimer);
|
|
361
|
-
maxTimer =
|
|
411
|
+
maxTimer = void 0;
|
|
362
412
|
resolve(invoke());
|
|
363
413
|
}, duration);
|
|
364
414
|
});
|
|
@@ -388,7 +438,7 @@ function throttleFilter(...args) {
|
|
|
388
438
|
}
|
|
389
439
|
};
|
|
390
440
|
const filter = (_invoke) => {
|
|
391
|
-
const duration = toValue(ms);
|
|
441
|
+
const duration = toValue$1(ms);
|
|
392
442
|
const elapsed = Date.now() - lastExec;
|
|
393
443
|
const invoke = () => {
|
|
394
444
|
return lastValue = _invoke();
|
|
@@ -419,8 +469,11 @@ function throttleFilter(...args) {
|
|
|
419
469
|
};
|
|
420
470
|
return filter;
|
|
421
471
|
}
|
|
422
|
-
function pausableFilter(extendFilter = bypassFilter) {
|
|
423
|
-
const
|
|
472
|
+
function pausableFilter(extendFilter = bypassFilter, options = {}) {
|
|
473
|
+
const {
|
|
474
|
+
initialState = "active"
|
|
475
|
+
} = options;
|
|
476
|
+
const isActive = toRef(initialState === "active");
|
|
424
477
|
function pause() {
|
|
425
478
|
isActive.value = false;
|
|
426
479
|
}
|
|
@@ -434,26 +487,6 @@ function pausableFilter(extendFilter = bypassFilter) {
|
|
|
434
487
|
return { isActive: readonly(isActive), pause, resume, eventFilter };
|
|
435
488
|
}
|
|
436
489
|
|
|
437
|
-
const directiveHooks = {
|
|
438
|
-
mounted: isVue3 ? "mounted" : "inserted",
|
|
439
|
-
updated: isVue3 ? "updated" : "componentUpdated",
|
|
440
|
-
unmounted: isVue3 ? "unmounted" : "unbind"
|
|
441
|
-
};
|
|
442
|
-
|
|
443
|
-
function cacheStringFunction(fn) {
|
|
444
|
-
const cache = /* @__PURE__ */ Object.create(null);
|
|
445
|
-
return (str) => {
|
|
446
|
-
const hit = cache[str];
|
|
447
|
-
return hit || (cache[str] = fn(str));
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
const hyphenateRE = /\B([A-Z])/g;
|
|
451
|
-
const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
|
|
452
|
-
const camelizeRE = /-(\w)/g;
|
|
453
|
-
const camelize = cacheStringFunction((str) => {
|
|
454
|
-
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
|
|
455
|
-
});
|
|
456
|
-
|
|
457
490
|
function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
|
|
458
491
|
return new Promise((resolve, reject) => {
|
|
459
492
|
if (throwOnTimeout)
|
|
@@ -497,6 +530,9 @@ function increaseWithUnit(target, delta) {
|
|
|
497
530
|
return target;
|
|
498
531
|
return result + unit;
|
|
499
532
|
}
|
|
533
|
+
function pxValue(px) {
|
|
534
|
+
return px.endsWith("rem") ? Number.parseFloat(px) * 16 : Number.parseFloat(px);
|
|
535
|
+
}
|
|
500
536
|
function objectPick(obj, keys, omitUndefined = false) {
|
|
501
537
|
return keys.reduce((n, k) => {
|
|
502
538
|
if (k in obj) {
|
|
@@ -514,50 +550,29 @@ function objectOmit(obj, keys, omitUndefined = false) {
|
|
|
514
550
|
function objectEntries(obj) {
|
|
515
551
|
return Object.entries(obj);
|
|
516
552
|
}
|
|
517
|
-
function
|
|
518
|
-
return
|
|
553
|
+
function toArray(value) {
|
|
554
|
+
return Array.isArray(value) ? value : [value];
|
|
519
555
|
}
|
|
520
556
|
|
|
521
|
-
function
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
}
|
|
527
|
-
const resolveRef = toRef;
|
|
528
|
-
|
|
529
|
-
function reactivePick(obj, ...keys) {
|
|
530
|
-
const flatKeys = keys.flat();
|
|
531
|
-
const predicate = flatKeys[0];
|
|
532
|
-
return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs$1(obj)).filter(([k, v]) => predicate(toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
|
|
557
|
+
function cacheStringFunction(fn) {
|
|
558
|
+
const cache = /* @__PURE__ */ Object.create(null);
|
|
559
|
+
return (str) => {
|
|
560
|
+
const hit = cache[str];
|
|
561
|
+
return hit || (cache[str] = fn(str));
|
|
562
|
+
};
|
|
533
563
|
}
|
|
564
|
+
const hyphenateRE = /\B([A-Z])/g;
|
|
565
|
+
const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
|
|
566
|
+
const camelizeRE = /-(\w)/g;
|
|
567
|
+
const camelize = cacheStringFunction((str) => {
|
|
568
|
+
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
|
|
569
|
+
});
|
|
534
570
|
|
|
535
|
-
function
|
|
536
|
-
return
|
|
537
|
-
let value = toValue(defaultValue);
|
|
538
|
-
let timer;
|
|
539
|
-
const resetAfter = () => setTimeout(() => {
|
|
540
|
-
value = toValue(defaultValue);
|
|
541
|
-
trigger();
|
|
542
|
-
}, toValue(afterMs));
|
|
543
|
-
tryOnScopeDispose(() => {
|
|
544
|
-
clearTimeout(timer);
|
|
545
|
-
});
|
|
546
|
-
return {
|
|
547
|
-
get() {
|
|
548
|
-
track();
|
|
549
|
-
return value;
|
|
550
|
-
},
|
|
551
|
-
set(newValue) {
|
|
552
|
-
value = newValue;
|
|
553
|
-
trigger();
|
|
554
|
-
clearTimeout(timer);
|
|
555
|
-
timer = resetAfter();
|
|
556
|
-
}
|
|
557
|
-
};
|
|
558
|
-
});
|
|
571
|
+
function getLifeCycleTarget(target) {
|
|
572
|
+
return target || getCurrentInstance();
|
|
559
573
|
}
|
|
560
574
|
|
|
575
|
+
// @__NO_SIDE_EFFECTS__
|
|
561
576
|
function useDebounceFn(fn, ms = 200, options = {}) {
|
|
562
577
|
return createFilterWrapper(
|
|
563
578
|
debounceFilter(ms, options),
|
|
@@ -566,14 +581,15 @@ function useDebounceFn(fn, ms = 200, options = {}) {
|
|
|
566
581
|
}
|
|
567
582
|
|
|
568
583
|
function refDebounced(value, ms = 200, options = {}) {
|
|
569
|
-
const debounced = ref(value
|
|
584
|
+
const debounced = ref(toValue$1(value));
|
|
570
585
|
const updater = useDebounceFn(() => {
|
|
571
586
|
debounced.value = value.value;
|
|
572
587
|
}, ms, options);
|
|
573
588
|
watch(value, () => updater());
|
|
574
|
-
return debounced;
|
|
589
|
+
return shallowReadonly(debounced);
|
|
575
590
|
}
|
|
576
591
|
|
|
592
|
+
// @__NO_SIDE_EFFECTS__
|
|
577
593
|
function refDefault(source, defaultValue) {
|
|
578
594
|
return computed({
|
|
579
595
|
get() {
|
|
@@ -586,6 +602,7 @@ function refDefault(source, defaultValue) {
|
|
|
586
602
|
});
|
|
587
603
|
}
|
|
588
604
|
|
|
605
|
+
// @__NO_SIDE_EFFECTS__
|
|
589
606
|
function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
|
|
590
607
|
return createFilterWrapper(
|
|
591
608
|
throttleFilter(ms, trailing, leading, rejectOnCancel),
|
|
@@ -596,7 +613,7 @@ function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnC
|
|
|
596
613
|
function refThrottled(value, delay = 200, trailing = true, leading = true) {
|
|
597
614
|
if (delay <= 0)
|
|
598
615
|
return value;
|
|
599
|
-
const throttled = ref(value
|
|
616
|
+
const throttled = ref(toValue$1(value));
|
|
600
617
|
const updater = useThrottleFn(() => {
|
|
601
618
|
throttled.value = value.value;
|
|
602
619
|
}, delay, trailing, leading);
|
|
@@ -604,6 +621,7 @@ function refThrottled(value, delay = 200, trailing = true, leading = true) {
|
|
|
604
621
|
return throttled;
|
|
605
622
|
}
|
|
606
623
|
|
|
624
|
+
// @__NO_SIDE_EFFECTS__
|
|
607
625
|
function refWithControl(initial, options = {}) {
|
|
608
626
|
let source = initial;
|
|
609
627
|
let track;
|
|
@@ -662,12 +680,8 @@ function set(...args) {
|
|
|
662
680
|
ref.value = value;
|
|
663
681
|
}
|
|
664
682
|
if (args.length === 3) {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
} else {
|
|
668
|
-
const [target, key, value] = args;
|
|
669
|
-
target[key] = value;
|
|
670
|
-
}
|
|
683
|
+
const [target, key, value] = args;
|
|
684
|
+
target[key] = value;
|
|
671
685
|
}
|
|
672
686
|
}
|
|
673
687
|
|
|
@@ -689,9 +703,10 @@ function watchWithFilter(source, cb, options = {}) {
|
|
|
689
703
|
function watchPausable(source, cb, options = {}) {
|
|
690
704
|
const {
|
|
691
705
|
eventFilter: filter,
|
|
706
|
+
initialState = "active",
|
|
692
707
|
...watchOptions
|
|
693
708
|
} = options;
|
|
694
|
-
const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
|
|
709
|
+
const { eventFilter, pause, resume, isActive } = pausableFilter(filter, { initialState });
|
|
695
710
|
const stop = watchWithFilter(
|
|
696
711
|
source,
|
|
697
712
|
cb,
|
|
@@ -748,11 +763,10 @@ function syncRefs(source, targets, options = {}) {
|
|
|
748
763
|
deep = false,
|
|
749
764
|
immediate = true
|
|
750
765
|
} = options;
|
|
751
|
-
|
|
752
|
-
targets = [targets];
|
|
766
|
+
const targetsArray = toArray(targets);
|
|
753
767
|
return watch(
|
|
754
768
|
source,
|
|
755
|
-
(newValue) =>
|
|
769
|
+
(newValue) => targetsArray.forEach((target) => target.value = newValue),
|
|
756
770
|
{ flush, deep, immediate }
|
|
757
771
|
);
|
|
758
772
|
}
|
|
@@ -768,7 +782,7 @@ function toRefs(objectRef, options = {}) {
|
|
|
768
782
|
},
|
|
769
783
|
set(v) {
|
|
770
784
|
var _a;
|
|
771
|
-
const replaceRef = (_a = toValue(options.replaceRef)) != null ? _a : true;
|
|
785
|
+
const replaceRef = (_a = toValue$1(options.replaceRef)) != null ? _a : true;
|
|
772
786
|
if (replaceRef) {
|
|
773
787
|
if (Array.isArray(objectRef.value)) {
|
|
774
788
|
const copy = [...objectRef.value];
|
|
@@ -788,6 +802,9 @@ function toRefs(objectRef, options = {}) {
|
|
|
788
802
|
return result;
|
|
789
803
|
}
|
|
790
804
|
|
|
805
|
+
const toValue = toValue$1;
|
|
806
|
+
const resolveUnref = toValue$1;
|
|
807
|
+
|
|
791
808
|
function tryOnBeforeMount(fn, sync = true, target) {
|
|
792
809
|
const instance = getLifeCycleTarget(target);
|
|
793
810
|
if (instance)
|
|
@@ -805,7 +822,7 @@ function tryOnBeforeUnmount(fn, target) {
|
|
|
805
822
|
}
|
|
806
823
|
|
|
807
824
|
function tryOnMounted(fn, sync = true, target) {
|
|
808
|
-
const instance = getLifeCycleTarget();
|
|
825
|
+
const instance = getLifeCycleTarget(target);
|
|
809
826
|
if (instance)
|
|
810
827
|
onMounted(fn, target);
|
|
811
828
|
else if (sync)
|
|
@@ -828,7 +845,10 @@ function createUntil(r, isNot = false) {
|
|
|
828
845
|
r,
|
|
829
846
|
(v) => {
|
|
830
847
|
if (condition(v) !== isNot) {
|
|
831
|
-
|
|
848
|
+
if (stop)
|
|
849
|
+
stop();
|
|
850
|
+
else
|
|
851
|
+
nextTick(() => stop == null ? void 0 : stop());
|
|
832
852
|
resolve(v);
|
|
833
853
|
}
|
|
834
854
|
},
|
|
@@ -842,7 +862,7 @@ function createUntil(r, isNot = false) {
|
|
|
842
862
|
const promises = [watcher];
|
|
843
863
|
if (timeout != null) {
|
|
844
864
|
promises.push(
|
|
845
|
-
promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => stop == null ? void 0 : stop())
|
|
865
|
+
promiseTimeout(timeout, throwOnTimeout).then(() => toValue$1(r)).finally(() => stop == null ? void 0 : stop())
|
|
846
866
|
);
|
|
847
867
|
}
|
|
848
868
|
return Promise.race(promises);
|
|
@@ -857,7 +877,10 @@ function createUntil(r, isNot = false) {
|
|
|
857
877
|
[r, value],
|
|
858
878
|
([v1, v2]) => {
|
|
859
879
|
if (isNot !== (v1 === v2)) {
|
|
860
|
-
|
|
880
|
+
if (stop)
|
|
881
|
+
stop();
|
|
882
|
+
else
|
|
883
|
+
nextTick(() => stop == null ? void 0 : stop());
|
|
861
884
|
resolve(v1);
|
|
862
885
|
}
|
|
863
886
|
},
|
|
@@ -871,9 +894,9 @@ function createUntil(r, isNot = false) {
|
|
|
871
894
|
const promises = [watcher];
|
|
872
895
|
if (timeout != null) {
|
|
873
896
|
promises.push(
|
|
874
|
-
promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => {
|
|
897
|
+
promiseTimeout(timeout, throwOnTimeout).then(() => toValue$1(r)).finally(() => {
|
|
875
898
|
stop == null ? void 0 : stop();
|
|
876
|
-
return toValue(r);
|
|
899
|
+
return toValue$1(r);
|
|
877
900
|
})
|
|
878
901
|
);
|
|
879
902
|
}
|
|
@@ -894,7 +917,7 @@ function createUntil(r, isNot = false) {
|
|
|
894
917
|
function toContains(value, options) {
|
|
895
918
|
return toMatch((v) => {
|
|
896
919
|
const array = Array.from(v);
|
|
897
|
-
return array.includes(value) || array.includes(toValue(value));
|
|
920
|
+
return array.includes(value) || array.includes(toValue$1(value));
|
|
898
921
|
}, options);
|
|
899
922
|
}
|
|
900
923
|
function changed(options) {
|
|
@@ -907,7 +930,7 @@ function createUntil(r, isNot = false) {
|
|
|
907
930
|
return count >= n;
|
|
908
931
|
}, options);
|
|
909
932
|
}
|
|
910
|
-
if (Array.isArray(toValue(r))) {
|
|
933
|
+
if (Array.isArray(toValue$1(r))) {
|
|
911
934
|
const instance = {
|
|
912
935
|
toMatch,
|
|
913
936
|
toContains,
|
|
@@ -942,34 +965,48 @@ function until(r) {
|
|
|
942
965
|
function defaultComparator(value, othVal) {
|
|
943
966
|
return value === othVal;
|
|
944
967
|
}
|
|
968
|
+
// @__NO_SIDE_EFFECTS__
|
|
945
969
|
function useArrayDifference(...args) {
|
|
946
|
-
var _a;
|
|
970
|
+
var _a, _b;
|
|
947
971
|
const list = args[0];
|
|
948
972
|
const values = args[1];
|
|
949
973
|
let compareFn = (_a = args[2]) != null ? _a : defaultComparator;
|
|
974
|
+
const {
|
|
975
|
+
symmetric = false
|
|
976
|
+
} = (_b = args[3]) != null ? _b : {};
|
|
950
977
|
if (typeof compareFn === "string") {
|
|
951
978
|
const key = compareFn;
|
|
952
979
|
compareFn = (value, othVal) => value[key] === othVal[key];
|
|
953
980
|
}
|
|
954
|
-
|
|
981
|
+
const diff1 = computed(() => toValue$1(list).filter((x) => toValue$1(values).findIndex((y) => compareFn(x, y)) === -1));
|
|
982
|
+
if (symmetric) {
|
|
983
|
+
const diff2 = computed(() => toValue$1(values).filter((x) => toValue$1(list).findIndex((y) => compareFn(x, y)) === -1));
|
|
984
|
+
return computed(() => symmetric ? [...toValue$1(diff1), ...toValue$1(diff2)] : toValue$1(diff1));
|
|
985
|
+
} else {
|
|
986
|
+
return diff1;
|
|
987
|
+
}
|
|
955
988
|
}
|
|
956
989
|
|
|
990
|
+
// @__NO_SIDE_EFFECTS__
|
|
957
991
|
function useArrayEvery(list, fn) {
|
|
958
|
-
return computed(() => toValue(list).every((element, index, array) => fn(toValue(element), index, array)));
|
|
992
|
+
return computed(() => toValue$1(list).every((element, index, array) => fn(toValue$1(element), index, array)));
|
|
959
993
|
}
|
|
960
994
|
|
|
995
|
+
// @__NO_SIDE_EFFECTS__
|
|
961
996
|
function useArrayFilter(list, fn) {
|
|
962
|
-
return computed(() => toValue(list).map((i) => toValue(i)).filter(fn));
|
|
997
|
+
return computed(() => toValue$1(list).map((i) => toValue$1(i)).filter(fn));
|
|
963
998
|
}
|
|
964
999
|
|
|
1000
|
+
// @__NO_SIDE_EFFECTS__
|
|
965
1001
|
function useArrayFind(list, fn) {
|
|
966
|
-
return computed(() => toValue(
|
|
967
|
-
toValue(list).find((element, index, array) => fn(toValue(element), index, array))
|
|
1002
|
+
return computed(() => toValue$1(
|
|
1003
|
+
toValue$1(list).find((element, index, array) => fn(toValue$1(element), index, array))
|
|
968
1004
|
));
|
|
969
1005
|
}
|
|
970
1006
|
|
|
1007
|
+
// @__NO_SIDE_EFFECTS__
|
|
971
1008
|
function useArrayFindIndex(list, fn) {
|
|
972
|
-
return computed(() => toValue(list).findIndex((element, index, array) => fn(toValue(element), index, array)));
|
|
1009
|
+
return computed(() => toValue$1(list).findIndex((element, index, array) => fn(toValue$1(element), index, array)));
|
|
973
1010
|
}
|
|
974
1011
|
|
|
975
1012
|
function findLast(arr, cb) {
|
|
@@ -980,15 +1017,17 @@ function findLast(arr, cb) {
|
|
|
980
1017
|
}
|
|
981
1018
|
return void 0;
|
|
982
1019
|
}
|
|
1020
|
+
// @__NO_SIDE_EFFECTS__
|
|
983
1021
|
function useArrayFindLast(list, fn) {
|
|
984
|
-
return computed(() => toValue(
|
|
985
|
-
!Array.prototype.findLast ? findLast(toValue(list), (element, index, array) => fn(toValue(element), index, array)) : toValue(list).findLast((element, index, array) => fn(toValue(element), index, array))
|
|
1022
|
+
return computed(() => toValue$1(
|
|
1023
|
+
!Array.prototype.findLast ? findLast(toValue$1(list), (element, index, array) => fn(toValue$1(element), index, array)) : toValue$1(list).findLast((element, index, array) => fn(toValue$1(element), index, array))
|
|
986
1024
|
));
|
|
987
1025
|
}
|
|
988
1026
|
|
|
989
1027
|
function isArrayIncludesOptions(obj) {
|
|
990
1028
|
return isObject(obj) && containsProp(obj, "formIndex", "comparator");
|
|
991
1029
|
}
|
|
1030
|
+
// @__NO_SIDE_EFFECTS__
|
|
992
1031
|
function useArrayIncludes(...args) {
|
|
993
1032
|
var _a;
|
|
994
1033
|
const list = args[0];
|
|
@@ -1001,35 +1040,39 @@ function useArrayIncludes(...args) {
|
|
|
1001
1040
|
}
|
|
1002
1041
|
if (typeof comparator === "string") {
|
|
1003
1042
|
const key = comparator;
|
|
1004
|
-
comparator = (element, value2) => element[key] === toValue(value2);
|
|
1043
|
+
comparator = (element, value2) => element[key] === toValue$1(value2);
|
|
1005
1044
|
}
|
|
1006
|
-
comparator = comparator != null ? comparator : (element, value2) => element === toValue(value2);
|
|
1007
|
-
return computed(() => toValue(list).slice(formIndex).some((element, index, array) => comparator(
|
|
1008
|
-
toValue(element),
|
|
1009
|
-
toValue(value),
|
|
1045
|
+
comparator = comparator != null ? comparator : (element, value2) => element === toValue$1(value2);
|
|
1046
|
+
return computed(() => toValue$1(list).slice(formIndex).some((element, index, array) => comparator(
|
|
1047
|
+
toValue$1(element),
|
|
1048
|
+
toValue$1(value),
|
|
1010
1049
|
index,
|
|
1011
|
-
toValue(array)
|
|
1050
|
+
toValue$1(array)
|
|
1012
1051
|
)));
|
|
1013
1052
|
}
|
|
1014
1053
|
|
|
1054
|
+
// @__NO_SIDE_EFFECTS__
|
|
1015
1055
|
function useArrayJoin(list, separator) {
|
|
1016
|
-
return computed(() => toValue(list).map((i) => toValue(i)).join(toValue(separator)));
|
|
1056
|
+
return computed(() => toValue$1(list).map((i) => toValue$1(i)).join(toValue$1(separator)));
|
|
1017
1057
|
}
|
|
1018
1058
|
|
|
1059
|
+
// @__NO_SIDE_EFFECTS__
|
|
1019
1060
|
function useArrayMap(list, fn) {
|
|
1020
|
-
return computed(() => toValue(list).map((i) => toValue(i)).map(fn));
|
|
1061
|
+
return computed(() => toValue$1(list).map((i) => toValue$1(i)).map(fn));
|
|
1021
1062
|
}
|
|
1022
1063
|
|
|
1064
|
+
// @__NO_SIDE_EFFECTS__
|
|
1023
1065
|
function useArrayReduce(list, reducer, ...args) {
|
|
1024
|
-
const reduceCallback = (sum, value, index) => reducer(toValue(sum), toValue(value), index);
|
|
1066
|
+
const reduceCallback = (sum, value, index) => reducer(toValue$1(sum), toValue$1(value), index);
|
|
1025
1067
|
return computed(() => {
|
|
1026
|
-
const resolved = toValue(list);
|
|
1027
|
-
return args.length ? resolved.reduce(reduceCallback, toValue(args[0])) : resolved.reduce(reduceCallback);
|
|
1068
|
+
const resolved = toValue$1(list);
|
|
1069
|
+
return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? toValue$1(args[0]()) : toValue$1(args[0])) : resolved.reduce(reduceCallback);
|
|
1028
1070
|
});
|
|
1029
1071
|
}
|
|
1030
1072
|
|
|
1073
|
+
// @__NO_SIDE_EFFECTS__
|
|
1031
1074
|
function useArraySome(list, fn) {
|
|
1032
|
-
return computed(() => toValue(list).some((element, index, array) => fn(toValue(element), index, array)));
|
|
1075
|
+
return computed(() => toValue$1(list).some((element, index, array) => fn(toValue$1(element), index, array)));
|
|
1033
1076
|
}
|
|
1034
1077
|
|
|
1035
1078
|
function uniq(array) {
|
|
@@ -1042,16 +1085,17 @@ function uniqueElementsBy(array, fn) {
|
|
|
1042
1085
|
return acc;
|
|
1043
1086
|
}, []);
|
|
1044
1087
|
}
|
|
1088
|
+
// @__NO_SIDE_EFFECTS__
|
|
1045
1089
|
function useArrayUnique(list, compareFn) {
|
|
1046
1090
|
return computed(() => {
|
|
1047
|
-
const resolvedList = toValue(list).map((element) => toValue(element));
|
|
1091
|
+
const resolvedList = toValue$1(list).map((element) => toValue$1(element));
|
|
1048
1092
|
return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList);
|
|
1049
1093
|
});
|
|
1050
1094
|
}
|
|
1051
1095
|
|
|
1052
1096
|
function useCounter(initialValue = 0, options = {}) {
|
|
1053
1097
|
let _initialValue = unref(initialValue);
|
|
1054
|
-
const count =
|
|
1098
|
+
const count = shallowRef(initialValue);
|
|
1055
1099
|
const {
|
|
1056
1100
|
max = Number.POSITIVE_INFINITY,
|
|
1057
1101
|
min = Number.NEGATIVE_INFINITY
|
|
@@ -1064,11 +1108,11 @@ function useCounter(initialValue = 0, options = {}) {
|
|
|
1064
1108
|
_initialValue = val;
|
|
1065
1109
|
return set(val);
|
|
1066
1110
|
};
|
|
1067
|
-
return { count, inc, dec, get, set, reset };
|
|
1111
|
+
return { count: shallowReadonly(count), inc, dec, get, set, reset };
|
|
1068
1112
|
}
|
|
1069
1113
|
|
|
1070
1114
|
const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i;
|
|
1071
|
-
const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
|
|
1115
|
+
const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|z{1,4}|SSS/g;
|
|
1072
1116
|
function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) {
|
|
1073
1117
|
let m = hours < 12 ? "AM" : "PM";
|
|
1074
1118
|
if (hasPeriod)
|
|
@@ -1091,6 +1135,10 @@ function formatDate(date, formatStr, options = {}) {
|
|
|
1091
1135
|
const milliseconds = date.getMilliseconds();
|
|
1092
1136
|
const day = date.getDay();
|
|
1093
1137
|
const meridiem = (_a = options.customMeridiem) != null ? _a : defaultMeridiem;
|
|
1138
|
+
const stripTimeZone = (dateString) => {
|
|
1139
|
+
var _a2;
|
|
1140
|
+
return (_a2 = dateString.split(" ")[1]) != null ? _a2 : "";
|
|
1141
|
+
};
|
|
1094
1142
|
const matches = {
|
|
1095
1143
|
Yo: () => formatOrdinal(years),
|
|
1096
1144
|
YY: () => String(years).slice(-2),
|
|
@@ -1098,8 +1146,8 @@ function formatDate(date, formatStr, options = {}) {
|
|
|
1098
1146
|
M: () => month + 1,
|
|
1099
1147
|
Mo: () => formatOrdinal(month + 1),
|
|
1100
1148
|
MM: () => `${month + 1}`.padStart(2, "0"),
|
|
1101
|
-
MMM: () => date.toLocaleDateString(options.locales, { month: "short" }),
|
|
1102
|
-
MMMM: () => date.toLocaleDateString(options.locales, { month: "long" }),
|
|
1149
|
+
MMM: () => date.toLocaleDateString(toValue$1(options.locales), { month: "short" }),
|
|
1150
|
+
MMMM: () => date.toLocaleDateString(toValue$1(options.locales), { month: "long" }),
|
|
1103
1151
|
D: () => String(days),
|
|
1104
1152
|
Do: () => formatOrdinal(days),
|
|
1105
1153
|
DD: () => `${days}`.padStart(2, "0"),
|
|
@@ -1117,13 +1165,17 @@ function formatDate(date, formatStr, options = {}) {
|
|
|
1117
1165
|
ss: () => `${seconds}`.padStart(2, "0"),
|
|
1118
1166
|
SSS: () => `${milliseconds}`.padStart(3, "0"),
|
|
1119
1167
|
d: () => day,
|
|
1120
|
-
dd: () => date.toLocaleDateString(options.locales, { weekday: "narrow" }),
|
|
1121
|
-
ddd: () => date.toLocaleDateString(options.locales, { weekday: "short" }),
|
|
1122
|
-
dddd: () => date.toLocaleDateString(options.locales, { weekday: "long" }),
|
|
1168
|
+
dd: () => date.toLocaleDateString(toValue$1(options.locales), { weekday: "narrow" }),
|
|
1169
|
+
ddd: () => date.toLocaleDateString(toValue$1(options.locales), { weekday: "short" }),
|
|
1170
|
+
dddd: () => date.toLocaleDateString(toValue$1(options.locales), { weekday: "long" }),
|
|
1123
1171
|
A: () => meridiem(hours, minutes),
|
|
1124
1172
|
AA: () => meridiem(hours, minutes, false, true),
|
|
1125
1173
|
a: () => meridiem(hours, minutes, true),
|
|
1126
|
-
aa: () => meridiem(hours, minutes, true, true)
|
|
1174
|
+
aa: () => meridiem(hours, minutes, true, true),
|
|
1175
|
+
z: () => stripTimeZone(date.toLocaleDateString(toValue$1(options.locales), { timeZoneName: "shortOffset" })),
|
|
1176
|
+
zz: () => stripTimeZone(date.toLocaleDateString(toValue$1(options.locales), { timeZoneName: "shortOffset" })),
|
|
1177
|
+
zzz: () => stripTimeZone(date.toLocaleDateString(toValue$1(options.locales), { timeZoneName: "shortOffset" })),
|
|
1178
|
+
zzzz: () => stripTimeZone(date.toLocaleDateString(toValue$1(options.locales), { timeZoneName: "longOffset" }))
|
|
1127
1179
|
};
|
|
1128
1180
|
return formatStr.replace(REGEX_FORMAT, (match, $1) => {
|
|
1129
1181
|
var _a2, _b;
|
|
@@ -1147,8 +1199,9 @@ function normalizeDate(date) {
|
|
|
1147
1199
|
}
|
|
1148
1200
|
return new Date(date);
|
|
1149
1201
|
}
|
|
1202
|
+
// @__NO_SIDE_EFFECTS__
|
|
1150
1203
|
function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
|
|
1151
|
-
return computed(() => formatDate(normalizeDate(toValue(date)), toValue(formatStr), options));
|
|
1204
|
+
return computed(() => formatDate(normalizeDate(toValue$1(date)), toValue$1(formatStr), options));
|
|
1152
1205
|
}
|
|
1153
1206
|
|
|
1154
1207
|
function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
@@ -1157,7 +1210,7 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
|
1157
1210
|
immediateCallback = false
|
|
1158
1211
|
} = options;
|
|
1159
1212
|
let timer = null;
|
|
1160
|
-
const isActive =
|
|
1213
|
+
const isActive = shallowRef(false);
|
|
1161
1214
|
function clean() {
|
|
1162
1215
|
if (timer) {
|
|
1163
1216
|
clearInterval(timer);
|
|
@@ -1169,14 +1222,15 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
|
1169
1222
|
clean();
|
|
1170
1223
|
}
|
|
1171
1224
|
function resume() {
|
|
1172
|
-
const intervalValue = toValue(interval);
|
|
1225
|
+
const intervalValue = toValue$1(interval);
|
|
1173
1226
|
if (intervalValue <= 0)
|
|
1174
1227
|
return;
|
|
1175
1228
|
isActive.value = true;
|
|
1176
1229
|
if (immediateCallback)
|
|
1177
1230
|
cb();
|
|
1178
1231
|
clean();
|
|
1179
|
-
|
|
1232
|
+
if (isActive.value)
|
|
1233
|
+
timer = setInterval(cb, intervalValue);
|
|
1180
1234
|
}
|
|
1181
1235
|
if (immediate && isClient)
|
|
1182
1236
|
resume();
|
|
@@ -1189,7 +1243,7 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
|
1189
1243
|
}
|
|
1190
1244
|
tryOnScopeDispose(pause);
|
|
1191
1245
|
return {
|
|
1192
|
-
isActive,
|
|
1246
|
+
isActive: shallowReadonly(isActive),
|
|
1193
1247
|
pause,
|
|
1194
1248
|
resume
|
|
1195
1249
|
};
|
|
@@ -1201,7 +1255,7 @@ function useInterval(interval = 1e3, options = {}) {
|
|
|
1201
1255
|
immediate = true,
|
|
1202
1256
|
callback
|
|
1203
1257
|
} = options;
|
|
1204
|
-
const counter =
|
|
1258
|
+
const counter = shallowRef(0);
|
|
1205
1259
|
const update = () => counter.value += 1;
|
|
1206
1260
|
const reset = () => {
|
|
1207
1261
|
counter.value = 0;
|
|
@@ -1216,36 +1270,37 @@ function useInterval(interval = 1e3, options = {}) {
|
|
|
1216
1270
|
);
|
|
1217
1271
|
if (exposeControls) {
|
|
1218
1272
|
return {
|
|
1219
|
-
counter,
|
|
1273
|
+
counter: shallowReadonly(counter),
|
|
1220
1274
|
reset,
|
|
1221
1275
|
...controls
|
|
1222
1276
|
};
|
|
1223
1277
|
} else {
|
|
1224
|
-
return counter;
|
|
1278
|
+
return shallowReadonly(counter);
|
|
1225
1279
|
}
|
|
1226
1280
|
}
|
|
1227
1281
|
|
|
1228
1282
|
function useLastChanged(source, options = {}) {
|
|
1229
1283
|
var _a;
|
|
1230
|
-
const ms =
|
|
1284
|
+
const ms = shallowRef((_a = options.initialValue) != null ? _a : null);
|
|
1231
1285
|
watch(
|
|
1232
1286
|
source,
|
|
1233
1287
|
() => ms.value = timestamp(),
|
|
1234
1288
|
options
|
|
1235
1289
|
);
|
|
1236
|
-
return ms;
|
|
1290
|
+
return shallowReadonly(ms);
|
|
1237
1291
|
}
|
|
1238
1292
|
|
|
1239
1293
|
function useTimeoutFn(cb, interval, options = {}) {
|
|
1240
1294
|
const {
|
|
1241
|
-
immediate = true
|
|
1295
|
+
immediate = true,
|
|
1296
|
+
immediateCallback = false
|
|
1242
1297
|
} = options;
|
|
1243
|
-
const isPending =
|
|
1244
|
-
let timer
|
|
1298
|
+
const isPending = shallowRef(false);
|
|
1299
|
+
let timer;
|
|
1245
1300
|
function clear() {
|
|
1246
1301
|
if (timer) {
|
|
1247
1302
|
clearTimeout(timer);
|
|
1248
|
-
timer =
|
|
1303
|
+
timer = void 0;
|
|
1249
1304
|
}
|
|
1250
1305
|
}
|
|
1251
1306
|
function stop() {
|
|
@@ -1253,13 +1308,15 @@ function useTimeoutFn(cb, interval, options = {}) {
|
|
|
1253
1308
|
clear();
|
|
1254
1309
|
}
|
|
1255
1310
|
function start(...args) {
|
|
1311
|
+
if (immediateCallback)
|
|
1312
|
+
cb();
|
|
1256
1313
|
clear();
|
|
1257
1314
|
isPending.value = true;
|
|
1258
1315
|
timer = setTimeout(() => {
|
|
1259
1316
|
isPending.value = false;
|
|
1260
|
-
timer =
|
|
1317
|
+
timer = void 0;
|
|
1261
1318
|
cb(...args);
|
|
1262
|
-
}, toValue(interval));
|
|
1319
|
+
}, toValue$1(interval));
|
|
1263
1320
|
}
|
|
1264
1321
|
if (immediate) {
|
|
1265
1322
|
isPending.value = true;
|
|
@@ -1268,7 +1325,7 @@ function useTimeoutFn(cb, interval, options = {}) {
|
|
|
1268
1325
|
}
|
|
1269
1326
|
tryOnScopeDispose(stop);
|
|
1270
1327
|
return {
|
|
1271
|
-
isPending:
|
|
1328
|
+
isPending: shallowReadonly(isPending),
|
|
1272
1329
|
start,
|
|
1273
1330
|
stop
|
|
1274
1331
|
};
|
|
@@ -1295,6 +1352,7 @@ function useTimeout(interval = 1e3, options = {}) {
|
|
|
1295
1352
|
}
|
|
1296
1353
|
}
|
|
1297
1354
|
|
|
1355
|
+
// @__NO_SIDE_EFFECTS__
|
|
1298
1356
|
function useToNumber(value, options = {}) {
|
|
1299
1357
|
const {
|
|
1300
1358
|
method = "parseFloat",
|
|
@@ -1302,8 +1360,10 @@ function useToNumber(value, options = {}) {
|
|
|
1302
1360
|
nanToZero
|
|
1303
1361
|
} = options;
|
|
1304
1362
|
return computed(() => {
|
|
1305
|
-
let resolved = toValue(value);
|
|
1306
|
-
if (typeof
|
|
1363
|
+
let resolved = toValue$1(value);
|
|
1364
|
+
if (typeof method === "function")
|
|
1365
|
+
resolved = method(resolved);
|
|
1366
|
+
else if (typeof resolved === "string")
|
|
1307
1367
|
resolved = Number[method](resolved, radix);
|
|
1308
1368
|
if (nanToZero && Number.isNaN(resolved))
|
|
1309
1369
|
resolved = 0;
|
|
@@ -1311,24 +1371,26 @@ function useToNumber(value, options = {}) {
|
|
|
1311
1371
|
});
|
|
1312
1372
|
}
|
|
1313
1373
|
|
|
1374
|
+
// @__NO_SIDE_EFFECTS__
|
|
1314
1375
|
function useToString(value) {
|
|
1315
|
-
return computed(() => `${toValue(value)}`);
|
|
1376
|
+
return computed(() => `${toValue$1(value)}`);
|
|
1316
1377
|
}
|
|
1317
1378
|
|
|
1379
|
+
// @__NO_SIDE_EFFECTS__
|
|
1318
1380
|
function useToggle(initialValue = false, options = {}) {
|
|
1319
1381
|
const {
|
|
1320
1382
|
truthyValue = true,
|
|
1321
1383
|
falsyValue = false
|
|
1322
1384
|
} = options;
|
|
1323
1385
|
const valueIsRef = isRef(initialValue);
|
|
1324
|
-
const _value =
|
|
1386
|
+
const _value = shallowRef(initialValue);
|
|
1325
1387
|
function toggle(value) {
|
|
1326
1388
|
if (arguments.length) {
|
|
1327
1389
|
_value.value = value;
|
|
1328
1390
|
return _value.value;
|
|
1329
1391
|
} else {
|
|
1330
|
-
const truthy = toValue(truthyValue);
|
|
1331
|
-
_value.value = _value.value === truthy ? toValue(falsyValue) : truthy;
|
|
1392
|
+
const truthy = toValue$1(truthyValue);
|
|
1393
|
+
_value.value = _value.value === truthy ? toValue$1(falsyValue) : truthy;
|
|
1332
1394
|
return _value.value;
|
|
1333
1395
|
}
|
|
1334
1396
|
}
|
|
@@ -1339,7 +1401,7 @@ function useToggle(initialValue = false, options = {}) {
|
|
|
1339
1401
|
}
|
|
1340
1402
|
|
|
1341
1403
|
function watchArray(source, cb, options) {
|
|
1342
|
-
let oldList = (options == null ? void 0 : options.immediate) ? [] : [...source
|
|
1404
|
+
let oldList = (options == null ? void 0 : options.immediate) ? [] : [...typeof source === "function" ? source() : Array.isArray(source) ? source : toValue$1(source)];
|
|
1343
1405
|
return watch(source, (newList, _, onCleanup) => {
|
|
1344
1406
|
const oldListRemains = Array.from({ length: oldList.length });
|
|
1345
1407
|
const added = [];
|
|
@@ -1366,12 +1428,12 @@ function watchAtMost(source, cb, options) {
|
|
|
1366
1428
|
count,
|
|
1367
1429
|
...watchOptions
|
|
1368
1430
|
} = options;
|
|
1369
|
-
const current =
|
|
1431
|
+
const current = shallowRef(0);
|
|
1370
1432
|
const stop = watchWithFilter(
|
|
1371
1433
|
source,
|
|
1372
1434
|
(...args) => {
|
|
1373
1435
|
current.value += 1;
|
|
1374
|
-
if (current.value >= toValue(count))
|
|
1436
|
+
if (current.value >= toValue$1(count))
|
|
1375
1437
|
nextTick(() => stop());
|
|
1376
1438
|
cb(...args);
|
|
1377
1439
|
},
|
|
@@ -1420,50 +1482,50 @@ function watchIgnorable(source, cb, options = {}) {
|
|
|
1420
1482
|
let ignorePrevAsyncUpdates;
|
|
1421
1483
|
let stop;
|
|
1422
1484
|
if (watchOptions.flush === "sync") {
|
|
1423
|
-
|
|
1485
|
+
let ignore = false;
|
|
1424
1486
|
ignorePrevAsyncUpdates = () => {
|
|
1425
1487
|
};
|
|
1426
1488
|
ignoreUpdates = (updater) => {
|
|
1427
|
-
ignore
|
|
1489
|
+
ignore = true;
|
|
1428
1490
|
updater();
|
|
1429
|
-
ignore
|
|
1491
|
+
ignore = false;
|
|
1430
1492
|
};
|
|
1431
1493
|
stop = watch(
|
|
1432
1494
|
source,
|
|
1433
1495
|
(...args) => {
|
|
1434
|
-
if (!ignore
|
|
1496
|
+
if (!ignore)
|
|
1435
1497
|
filteredCb(...args);
|
|
1436
1498
|
},
|
|
1437
1499
|
watchOptions
|
|
1438
1500
|
);
|
|
1439
1501
|
} else {
|
|
1440
1502
|
const disposables = [];
|
|
1441
|
-
|
|
1442
|
-
|
|
1503
|
+
let ignoreCounter = 0;
|
|
1504
|
+
let syncCounter = 0;
|
|
1443
1505
|
ignorePrevAsyncUpdates = () => {
|
|
1444
|
-
ignoreCounter
|
|
1506
|
+
ignoreCounter = syncCounter;
|
|
1445
1507
|
};
|
|
1446
1508
|
disposables.push(
|
|
1447
1509
|
watch(
|
|
1448
1510
|
source,
|
|
1449
1511
|
() => {
|
|
1450
|
-
syncCounter
|
|
1512
|
+
syncCounter++;
|
|
1451
1513
|
},
|
|
1452
1514
|
{ ...watchOptions, flush: "sync" }
|
|
1453
1515
|
)
|
|
1454
1516
|
);
|
|
1455
1517
|
ignoreUpdates = (updater) => {
|
|
1456
|
-
const syncCounterPrev = syncCounter
|
|
1518
|
+
const syncCounterPrev = syncCounter;
|
|
1457
1519
|
updater();
|
|
1458
|
-
ignoreCounter
|
|
1520
|
+
ignoreCounter += syncCounter - syncCounterPrev;
|
|
1459
1521
|
};
|
|
1460
1522
|
disposables.push(
|
|
1461
1523
|
watch(
|
|
1462
1524
|
source,
|
|
1463
1525
|
(...args) => {
|
|
1464
|
-
const ignore = ignoreCounter
|
|
1465
|
-
ignoreCounter
|
|
1466
|
-
syncCounter
|
|
1526
|
+
const ignore = ignoreCounter > 0 && ignoreCounter === syncCounter;
|
|
1527
|
+
ignoreCounter = 0;
|
|
1528
|
+
syncCounter = 0;
|
|
1467
1529
|
if (ignore)
|
|
1468
1530
|
return;
|
|
1469
1531
|
filteredCb(...args);
|
|
@@ -1490,11 +1552,14 @@ function watchImmediate(source, cb, options) {
|
|
|
1490
1552
|
}
|
|
1491
1553
|
|
|
1492
1554
|
function watchOnce(source, cb, options) {
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1555
|
+
return watch(
|
|
1556
|
+
source,
|
|
1557
|
+
cb,
|
|
1558
|
+
{
|
|
1559
|
+
...options,
|
|
1560
|
+
once: true
|
|
1561
|
+
}
|
|
1562
|
+
);
|
|
1498
1563
|
}
|
|
1499
1564
|
|
|
1500
1565
|
function watchThrottled(source, cb, options = {}) {
|
|
@@ -1548,8 +1613,8 @@ function getWatchSources(sources) {
|
|
|
1548
1613
|
if (isReactive(sources))
|
|
1549
1614
|
return sources;
|
|
1550
1615
|
if (Array.isArray(sources))
|
|
1551
|
-
return sources.map((item) => toValue(item));
|
|
1552
|
-
return toValue(sources);
|
|
1616
|
+
return sources.map((item) => toValue$1(item));
|
|
1617
|
+
return toValue$1(sources);
|
|
1553
1618
|
}
|
|
1554
1619
|
function getOldValue(source) {
|
|
1555
1620
|
return Array.isArray(source) ? source.map(() => void 0) : void 0;
|
|
@@ -1573,4 +1638,4 @@ function whenever(source, cb, options) {
|
|
|
1573
1638
|
return stop;
|
|
1574
1639
|
}
|
|
1575
1640
|
|
|
1576
|
-
export { assert, refAutoReset as autoResetRef, bypassFilter, camelize, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch,
|
|
1641
|
+
export { assert, refAutoReset as autoResetRef, bypassFilter, camelize, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createRef, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, computedEager as eagerComputed, extendRef, formatDate, get, getLifeCycleTarget, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, makeDestructurable, noop, normalizeDate, notNullish, now, objectEntries, objectOmit, objectPick, pausableFilter, watchPausable as pausableWatch, promiseTimeout, provideLocal, pxValue, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toArray, toReactive, toRef, toRefs, toValue, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToNumber, useToString, useToggle, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };
|