@bagelink/vue 1.2.3 → 1.2.5
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/composables/index.d.ts +1 -0
- package/dist/composables/index.d.ts.map +1 -1
- package/dist/composables/usePolling.d.ts +14 -0
- package/dist/composables/usePolling.d.ts.map +1 -0
- package/dist/index.cjs +180 -4
- package/dist/index.mjs +180 -4
- package/dist/utils/BagelFormUtils.d.ts +3 -0
- package/dist/utils/BagelFormUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/composables/index.ts +1 -1
- package/src/composables/usePolling.ts +102 -0
- package/src/utils/BagelFormUtils.ts +6 -0
- package/dist/types/timeago.d.ts +0 -23
- package/dist/types/timeago.d.ts.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BglFormSchemaFnT, BglFormSchemaT, IfAny } from '..';
|
|
2
2
|
import { Ref, UnwrapRef } from 'vue';
|
|
3
3
|
export { useDevice } from './useDevice';
|
|
4
|
+
export { usePolling } from './usePolling';
|
|
4
5
|
export { useValidateFieldValue } from './useValidateFieldValue';
|
|
5
6
|
interface UseBglSchemaParamsT<T> {
|
|
6
7
|
schema?: BglFormSchemaFnT<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composables/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE5E,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAIzC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composables/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE5E,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAIzC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,UAAU,mBAAmB,CAAC,CAAC;IAC9B,MAAM,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAA;IAC5B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;CACZ;AAED,wBAAgB,YAAY,CAAC,CAAC,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAC1D,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAE,mBAAmB,CAAC,CAAC,CAAM,GACpD,cAAc,CAAC,CAAC,CAAC,CAanB;AAED,wBAAgB,QAAQ,CAAC,CAAC,EACzB,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,CAAC,GACb,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAC5B,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,GACtB,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAUpC;AAED,eAAO,MAAM,eAAe,iBAAW,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface PollingOptions {
|
|
2
|
+
interval?: number;
|
|
3
|
+
inactivityThreshold?: number;
|
|
4
|
+
pauseInBackground?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function usePolling(fn: () => Promise<any> | void, options?: PollingOptions): {
|
|
7
|
+
isPolling: import('vue').Ref<boolean, boolean>;
|
|
8
|
+
pausePolling: () => void;
|
|
9
|
+
resumePolling: () => void;
|
|
10
|
+
startPolling: () => void;
|
|
11
|
+
stopPolling: () => void;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=usePolling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePolling.d.ts","sourceRoot":"","sources":["../../src/composables/usePolling.ts"],"names":[],"mappings":"AAMA,UAAU,cAAc;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC3B;AAED,wBAAgB,UAAU,CACzB,EAAE,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,EAC7B,OAAO,GAAE,cAAmB;;;;;;EAuF5B"}
|
package/dist/index.cjs
CHANGED
|
@@ -10984,6 +10984,7 @@ typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalSc
|
|
|
10984
10984
|
const notNullish = (val) => val != null;
|
|
10985
10985
|
const toString$1 = Object.prototype.toString;
|
|
10986
10986
|
const isObject$2 = (val) => toString$1.call(val) === "[object Object]";
|
|
10987
|
+
const timestamp = () => +Date.now();
|
|
10987
10988
|
const noop$1 = () => {
|
|
10988
10989
|
};
|
|
10989
10990
|
const isIOS = /* @__PURE__ */ getIsIOS();
|
|
@@ -11045,6 +11046,60 @@ function debounceFilter(ms, options = {}) {
|
|
|
11045
11046
|
};
|
|
11046
11047
|
return filter3;
|
|
11047
11048
|
}
|
|
11049
|
+
function throttleFilter(...args) {
|
|
11050
|
+
let lastExec = 0;
|
|
11051
|
+
let timer;
|
|
11052
|
+
let isLeading = true;
|
|
11053
|
+
let lastRejector = noop$1;
|
|
11054
|
+
let lastValue;
|
|
11055
|
+
let ms;
|
|
11056
|
+
let trailing;
|
|
11057
|
+
let leading;
|
|
11058
|
+
let rejectOnCancel;
|
|
11059
|
+
if (!vue.isRef(args[0]) && typeof args[0] === "object")
|
|
11060
|
+
({ delay: ms, trailing = true, leading = true, rejectOnCancel = false } = args[0]);
|
|
11061
|
+
else
|
|
11062
|
+
[ms, trailing = true, leading = true, rejectOnCancel = false] = args;
|
|
11063
|
+
const clear = () => {
|
|
11064
|
+
if (timer) {
|
|
11065
|
+
clearTimeout(timer);
|
|
11066
|
+
timer = void 0;
|
|
11067
|
+
lastRejector();
|
|
11068
|
+
lastRejector = noop$1;
|
|
11069
|
+
}
|
|
11070
|
+
};
|
|
11071
|
+
const filter3 = (_invoke) => {
|
|
11072
|
+
const duration = vue.toValue(ms);
|
|
11073
|
+
const elapsed = Date.now() - lastExec;
|
|
11074
|
+
const invoke = () => {
|
|
11075
|
+
return lastValue = _invoke();
|
|
11076
|
+
};
|
|
11077
|
+
clear();
|
|
11078
|
+
if (duration <= 0) {
|
|
11079
|
+
lastExec = Date.now();
|
|
11080
|
+
return invoke();
|
|
11081
|
+
}
|
|
11082
|
+
if (elapsed > duration && (leading || !isLeading)) {
|
|
11083
|
+
lastExec = Date.now();
|
|
11084
|
+
invoke();
|
|
11085
|
+
} else if (trailing) {
|
|
11086
|
+
lastValue = new Promise((resolve, reject3) => {
|
|
11087
|
+
lastRejector = rejectOnCancel ? reject3 : resolve;
|
|
11088
|
+
timer = setTimeout(() => {
|
|
11089
|
+
lastExec = Date.now();
|
|
11090
|
+
isLeading = true;
|
|
11091
|
+
resolve(invoke());
|
|
11092
|
+
clear();
|
|
11093
|
+
}, Math.max(0, duration - elapsed));
|
|
11094
|
+
});
|
|
11095
|
+
}
|
|
11096
|
+
if (!leading && !timer)
|
|
11097
|
+
timer = setTimeout(() => isLeading = true, duration);
|
|
11098
|
+
isLeading = false;
|
|
11099
|
+
return lastValue;
|
|
11100
|
+
};
|
|
11101
|
+
return filter3;
|
|
11102
|
+
}
|
|
11048
11103
|
function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
|
|
11049
11104
|
return new Promise((resolve, reject3) => {
|
|
11050
11105
|
if (throwOnTimeout)
|
|
@@ -11550,6 +11605,50 @@ function useIntersectionObserver(target, callback, options = {}) {
|
|
|
11550
11605
|
stop
|
|
11551
11606
|
};
|
|
11552
11607
|
}
|
|
11608
|
+
const defaultEvents$1 = ["mousemove", "mousedown", "resize", "keydown", "touchstart", "wheel"];
|
|
11609
|
+
const oneMinute = 6e4;
|
|
11610
|
+
function useIdle(timeout = oneMinute, options = {}) {
|
|
11611
|
+
const {
|
|
11612
|
+
initialState = false,
|
|
11613
|
+
listenForVisibilityChange = true,
|
|
11614
|
+
events = defaultEvents$1,
|
|
11615
|
+
window: window2 = defaultWindow,
|
|
11616
|
+
eventFilter = throttleFilter(50)
|
|
11617
|
+
} = options;
|
|
11618
|
+
const idle = vue.shallowRef(initialState);
|
|
11619
|
+
const lastActive = vue.shallowRef(timestamp());
|
|
11620
|
+
let timer;
|
|
11621
|
+
const reset = () => {
|
|
11622
|
+
idle.value = false;
|
|
11623
|
+
clearTimeout(timer);
|
|
11624
|
+
timer = setTimeout(() => idle.value = true, timeout);
|
|
11625
|
+
};
|
|
11626
|
+
const onEvent = createFilterWrapper(
|
|
11627
|
+
eventFilter,
|
|
11628
|
+
() => {
|
|
11629
|
+
lastActive.value = timestamp();
|
|
11630
|
+
reset();
|
|
11631
|
+
}
|
|
11632
|
+
);
|
|
11633
|
+
if (window2) {
|
|
11634
|
+
const document2 = window2.document;
|
|
11635
|
+
const listenerOptions = { passive: true };
|
|
11636
|
+
for (const event of events)
|
|
11637
|
+
useEventListener(window2, event, onEvent, listenerOptions);
|
|
11638
|
+
if (listenForVisibilityChange) {
|
|
11639
|
+
useEventListener(document2, "visibilitychange", () => {
|
|
11640
|
+
if (!document2.hidden)
|
|
11641
|
+
onEvent();
|
|
11642
|
+
}, listenerOptions);
|
|
11643
|
+
}
|
|
11644
|
+
reset();
|
|
11645
|
+
}
|
|
11646
|
+
return {
|
|
11647
|
+
idle,
|
|
11648
|
+
lastActive,
|
|
11649
|
+
reset
|
|
11650
|
+
};
|
|
11651
|
+
}
|
|
11553
11652
|
function useVirtualList(list, options) {
|
|
11554
11653
|
const { containerStyle, wrapperProps, scrollTo, calculateRange, currentList, containerRef } = "itemHeight" in options ? useVerticalVirtualList(options, list) : useHorizontalVirtualList(options, list);
|
|
11555
11654
|
return {
|
|
@@ -15252,7 +15351,10 @@ function txtField(id, label, options) {
|
|
|
15252
15351
|
type: options == null ? void 0 : options.type,
|
|
15253
15352
|
pattern: options == null ? void 0 : options.pattern,
|
|
15254
15353
|
multiline: options == null ? void 0 : options.multiline,
|
|
15255
|
-
autocomplete: options == null ? void 0 : options.autocomplete
|
|
15354
|
+
autocomplete: options == null ? void 0 : options.autocomplete,
|
|
15355
|
+
rows: options == null ? void 0 : options.rows,
|
|
15356
|
+
code: options == null ? void 0 : options.code,
|
|
15357
|
+
autoheight: options == null ? void 0 : options.autoheight
|
|
15256
15358
|
}
|
|
15257
15359
|
};
|
|
15258
15360
|
}
|
|
@@ -18958,12 +19060,12 @@ function speedometer(samplesCount, min2) {
|
|
|
18958
19060
|
};
|
|
18959
19061
|
}
|
|
18960
19062
|
function throttle$2(fn, freq) {
|
|
18961
|
-
let
|
|
19063
|
+
let timestamp2 = 0;
|
|
18962
19064
|
let threshold = 1e3 / freq;
|
|
18963
19065
|
let lastArgs;
|
|
18964
19066
|
let timer;
|
|
18965
19067
|
const invoke = (args, now = Date.now()) => {
|
|
18966
|
-
|
|
19068
|
+
timestamp2 = now;
|
|
18967
19069
|
lastArgs = null;
|
|
18968
19070
|
if (timer) {
|
|
18969
19071
|
clearTimeout(timer);
|
|
@@ -18973,7 +19075,7 @@ function throttle$2(fn, freq) {
|
|
|
18973
19075
|
};
|
|
18974
19076
|
const throttled = (...args) => {
|
|
18975
19077
|
const now = Date.now();
|
|
18976
|
-
const passed = now -
|
|
19078
|
+
const passed = now - timestamp2;
|
|
18977
19079
|
if (passed >= threshold) {
|
|
18978
19080
|
invoke(args, now);
|
|
18979
19081
|
} else {
|
|
@@ -36185,6 +36287,79 @@ function useDevice() {
|
|
|
36185
36287
|
isMobile
|
|
36186
36288
|
};
|
|
36187
36289
|
}
|
|
36290
|
+
const SECONDS = 1e3;
|
|
36291
|
+
const MINUTES = 60 * SECONDS;
|
|
36292
|
+
function usePolling(fn, options = {}) {
|
|
36293
|
+
const {
|
|
36294
|
+
interval = 30 * SECONDS,
|
|
36295
|
+
inactivityThreshold = 5 * MINUTES,
|
|
36296
|
+
pauseInBackground = true
|
|
36297
|
+
} = options;
|
|
36298
|
+
const { idle } = useIdle(inactivityThreshold);
|
|
36299
|
+
const isPolling = vue.ref(true);
|
|
36300
|
+
const pollingId = vue.ref(null);
|
|
36301
|
+
const isTabActive = () => {
|
|
36302
|
+
return !pauseInBackground || document.visibilityState === "visible";
|
|
36303
|
+
};
|
|
36304
|
+
const stopPolling = () => {
|
|
36305
|
+
isPolling.value = false;
|
|
36306
|
+
if (pollingId.value !== null) {
|
|
36307
|
+
clearTimeout(pollingId.value);
|
|
36308
|
+
pollingId.value = null;
|
|
36309
|
+
}
|
|
36310
|
+
};
|
|
36311
|
+
const pausePolling = () => {
|
|
36312
|
+
if (pollingId.value !== null) {
|
|
36313
|
+
clearTimeout(pollingId.value);
|
|
36314
|
+
pollingId.value = null;
|
|
36315
|
+
}
|
|
36316
|
+
};
|
|
36317
|
+
const startPolling = () => {
|
|
36318
|
+
if (pollingId.value !== null) {
|
|
36319
|
+
clearTimeout(pollingId.value);
|
|
36320
|
+
pollingId.value = null;
|
|
36321
|
+
}
|
|
36322
|
+
const poll = async () => {
|
|
36323
|
+
if (isPolling.value && isTabActive() && !idle.value) {
|
|
36324
|
+
try {
|
|
36325
|
+
await fn();
|
|
36326
|
+
} catch (error) {
|
|
36327
|
+
console.error("Polling error:", error);
|
|
36328
|
+
}
|
|
36329
|
+
}
|
|
36330
|
+
if (isPolling.value) {
|
|
36331
|
+
pollingId.value = window.setTimeout(poll, interval);
|
|
36332
|
+
}
|
|
36333
|
+
};
|
|
36334
|
+
poll();
|
|
36335
|
+
};
|
|
36336
|
+
const resumePolling = () => {
|
|
36337
|
+
if (isPolling.value) startPolling();
|
|
36338
|
+
else console.warn("Cannot resume polling that was stopped");
|
|
36339
|
+
};
|
|
36340
|
+
function updateVisibility() {
|
|
36341
|
+
if (document.visibilityState === "visible") {
|
|
36342
|
+
if (isPolling.value) startPolling();
|
|
36343
|
+
} else if (pauseInBackground) {
|
|
36344
|
+
pausePolling();
|
|
36345
|
+
}
|
|
36346
|
+
}
|
|
36347
|
+
vue.onMounted(() => {
|
|
36348
|
+
document.addEventListener("visibilitychange", updateVisibility);
|
|
36349
|
+
startPolling();
|
|
36350
|
+
});
|
|
36351
|
+
vue.onUnmounted(() => {
|
|
36352
|
+
document.removeEventListener("visibilitychange", updateVisibility);
|
|
36353
|
+
stopPolling();
|
|
36354
|
+
});
|
|
36355
|
+
return {
|
|
36356
|
+
isPolling,
|
|
36357
|
+
pausePolling,
|
|
36358
|
+
resumePolling,
|
|
36359
|
+
startPolling,
|
|
36360
|
+
stopPolling
|
|
36361
|
+
};
|
|
36362
|
+
}
|
|
36188
36363
|
function useValidateFieldValue(inputVal, getInput, validateFn, getFormData) {
|
|
36189
36364
|
watchDebounced(
|
|
36190
36365
|
inputVal,
|
|
@@ -37708,5 +37883,6 @@ exports.useI18nT = useI18nT;
|
|
|
37708
37883
|
exports.useLang = useLang;
|
|
37709
37884
|
exports.useLocalStorage = useLocalStorage;
|
|
37710
37885
|
exports.useModal = useModal;
|
|
37886
|
+
exports.usePolling = usePolling;
|
|
37711
37887
|
exports.useValidateFieldValue = useValidateFieldValue;
|
|
37712
37888
|
exports.vDraggable = vDraggable;
|
package/dist/index.mjs
CHANGED
|
@@ -10982,6 +10982,7 @@ typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalSc
|
|
|
10982
10982
|
const notNullish = (val) => val != null;
|
|
10983
10983
|
const toString$1 = Object.prototype.toString;
|
|
10984
10984
|
const isObject$2 = (val) => toString$1.call(val) === "[object Object]";
|
|
10985
|
+
const timestamp = () => +Date.now();
|
|
10985
10986
|
const noop$1 = () => {
|
|
10986
10987
|
};
|
|
10987
10988
|
const isIOS = /* @__PURE__ */ getIsIOS();
|
|
@@ -11043,6 +11044,60 @@ function debounceFilter(ms, options = {}) {
|
|
|
11043
11044
|
};
|
|
11044
11045
|
return filter3;
|
|
11045
11046
|
}
|
|
11047
|
+
function throttleFilter(...args) {
|
|
11048
|
+
let lastExec = 0;
|
|
11049
|
+
let timer;
|
|
11050
|
+
let isLeading = true;
|
|
11051
|
+
let lastRejector = noop$1;
|
|
11052
|
+
let lastValue;
|
|
11053
|
+
let ms;
|
|
11054
|
+
let trailing;
|
|
11055
|
+
let leading;
|
|
11056
|
+
let rejectOnCancel;
|
|
11057
|
+
if (!isRef(args[0]) && typeof args[0] === "object")
|
|
11058
|
+
({ delay: ms, trailing = true, leading = true, rejectOnCancel = false } = args[0]);
|
|
11059
|
+
else
|
|
11060
|
+
[ms, trailing = true, leading = true, rejectOnCancel = false] = args;
|
|
11061
|
+
const clear = () => {
|
|
11062
|
+
if (timer) {
|
|
11063
|
+
clearTimeout(timer);
|
|
11064
|
+
timer = void 0;
|
|
11065
|
+
lastRejector();
|
|
11066
|
+
lastRejector = noop$1;
|
|
11067
|
+
}
|
|
11068
|
+
};
|
|
11069
|
+
const filter3 = (_invoke) => {
|
|
11070
|
+
const duration = toValue(ms);
|
|
11071
|
+
const elapsed = Date.now() - lastExec;
|
|
11072
|
+
const invoke = () => {
|
|
11073
|
+
return lastValue = _invoke();
|
|
11074
|
+
};
|
|
11075
|
+
clear();
|
|
11076
|
+
if (duration <= 0) {
|
|
11077
|
+
lastExec = Date.now();
|
|
11078
|
+
return invoke();
|
|
11079
|
+
}
|
|
11080
|
+
if (elapsed > duration && (leading || !isLeading)) {
|
|
11081
|
+
lastExec = Date.now();
|
|
11082
|
+
invoke();
|
|
11083
|
+
} else if (trailing) {
|
|
11084
|
+
lastValue = new Promise((resolve, reject3) => {
|
|
11085
|
+
lastRejector = rejectOnCancel ? reject3 : resolve;
|
|
11086
|
+
timer = setTimeout(() => {
|
|
11087
|
+
lastExec = Date.now();
|
|
11088
|
+
isLeading = true;
|
|
11089
|
+
resolve(invoke());
|
|
11090
|
+
clear();
|
|
11091
|
+
}, Math.max(0, duration - elapsed));
|
|
11092
|
+
});
|
|
11093
|
+
}
|
|
11094
|
+
if (!leading && !timer)
|
|
11095
|
+
timer = setTimeout(() => isLeading = true, duration);
|
|
11096
|
+
isLeading = false;
|
|
11097
|
+
return lastValue;
|
|
11098
|
+
};
|
|
11099
|
+
return filter3;
|
|
11100
|
+
}
|
|
11046
11101
|
function promiseTimeout(ms, throwOnTimeout = false, reason = "Timeout") {
|
|
11047
11102
|
return new Promise((resolve, reject3) => {
|
|
11048
11103
|
if (throwOnTimeout)
|
|
@@ -11548,6 +11603,50 @@ function useIntersectionObserver(target, callback, options = {}) {
|
|
|
11548
11603
|
stop
|
|
11549
11604
|
};
|
|
11550
11605
|
}
|
|
11606
|
+
const defaultEvents$1 = ["mousemove", "mousedown", "resize", "keydown", "touchstart", "wheel"];
|
|
11607
|
+
const oneMinute = 6e4;
|
|
11608
|
+
function useIdle(timeout = oneMinute, options = {}) {
|
|
11609
|
+
const {
|
|
11610
|
+
initialState = false,
|
|
11611
|
+
listenForVisibilityChange = true,
|
|
11612
|
+
events = defaultEvents$1,
|
|
11613
|
+
window: window2 = defaultWindow,
|
|
11614
|
+
eventFilter = throttleFilter(50)
|
|
11615
|
+
} = options;
|
|
11616
|
+
const idle = shallowRef(initialState);
|
|
11617
|
+
const lastActive = shallowRef(timestamp());
|
|
11618
|
+
let timer;
|
|
11619
|
+
const reset = () => {
|
|
11620
|
+
idle.value = false;
|
|
11621
|
+
clearTimeout(timer);
|
|
11622
|
+
timer = setTimeout(() => idle.value = true, timeout);
|
|
11623
|
+
};
|
|
11624
|
+
const onEvent = createFilterWrapper(
|
|
11625
|
+
eventFilter,
|
|
11626
|
+
() => {
|
|
11627
|
+
lastActive.value = timestamp();
|
|
11628
|
+
reset();
|
|
11629
|
+
}
|
|
11630
|
+
);
|
|
11631
|
+
if (window2) {
|
|
11632
|
+
const document2 = window2.document;
|
|
11633
|
+
const listenerOptions = { passive: true };
|
|
11634
|
+
for (const event of events)
|
|
11635
|
+
useEventListener(window2, event, onEvent, listenerOptions);
|
|
11636
|
+
if (listenForVisibilityChange) {
|
|
11637
|
+
useEventListener(document2, "visibilitychange", () => {
|
|
11638
|
+
if (!document2.hidden)
|
|
11639
|
+
onEvent();
|
|
11640
|
+
}, listenerOptions);
|
|
11641
|
+
}
|
|
11642
|
+
reset();
|
|
11643
|
+
}
|
|
11644
|
+
return {
|
|
11645
|
+
idle,
|
|
11646
|
+
lastActive,
|
|
11647
|
+
reset
|
|
11648
|
+
};
|
|
11649
|
+
}
|
|
11551
11650
|
function useVirtualList(list, options) {
|
|
11552
11651
|
const { containerStyle, wrapperProps, scrollTo, calculateRange, currentList, containerRef } = "itemHeight" in options ? useVerticalVirtualList(options, list) : useHorizontalVirtualList(options, list);
|
|
11553
11652
|
return {
|
|
@@ -15250,7 +15349,10 @@ function txtField(id, label, options) {
|
|
|
15250
15349
|
type: options == null ? void 0 : options.type,
|
|
15251
15350
|
pattern: options == null ? void 0 : options.pattern,
|
|
15252
15351
|
multiline: options == null ? void 0 : options.multiline,
|
|
15253
|
-
autocomplete: options == null ? void 0 : options.autocomplete
|
|
15352
|
+
autocomplete: options == null ? void 0 : options.autocomplete,
|
|
15353
|
+
rows: options == null ? void 0 : options.rows,
|
|
15354
|
+
code: options == null ? void 0 : options.code,
|
|
15355
|
+
autoheight: options == null ? void 0 : options.autoheight
|
|
15254
15356
|
}
|
|
15255
15357
|
};
|
|
15256
15358
|
}
|
|
@@ -18956,12 +19058,12 @@ function speedometer(samplesCount, min2) {
|
|
|
18956
19058
|
};
|
|
18957
19059
|
}
|
|
18958
19060
|
function throttle$2(fn, freq) {
|
|
18959
|
-
let
|
|
19061
|
+
let timestamp2 = 0;
|
|
18960
19062
|
let threshold = 1e3 / freq;
|
|
18961
19063
|
let lastArgs;
|
|
18962
19064
|
let timer;
|
|
18963
19065
|
const invoke = (args, now = Date.now()) => {
|
|
18964
|
-
|
|
19066
|
+
timestamp2 = now;
|
|
18965
19067
|
lastArgs = null;
|
|
18966
19068
|
if (timer) {
|
|
18967
19069
|
clearTimeout(timer);
|
|
@@ -18971,7 +19073,7 @@ function throttle$2(fn, freq) {
|
|
|
18971
19073
|
};
|
|
18972
19074
|
const throttled = (...args) => {
|
|
18973
19075
|
const now = Date.now();
|
|
18974
|
-
const passed = now -
|
|
19076
|
+
const passed = now - timestamp2;
|
|
18975
19077
|
if (passed >= threshold) {
|
|
18976
19078
|
invoke(args, now);
|
|
18977
19079
|
} else {
|
|
@@ -36183,6 +36285,79 @@ function useDevice() {
|
|
|
36183
36285
|
isMobile
|
|
36184
36286
|
};
|
|
36185
36287
|
}
|
|
36288
|
+
const SECONDS = 1e3;
|
|
36289
|
+
const MINUTES = 60 * SECONDS;
|
|
36290
|
+
function usePolling(fn, options = {}) {
|
|
36291
|
+
const {
|
|
36292
|
+
interval = 30 * SECONDS,
|
|
36293
|
+
inactivityThreshold = 5 * MINUTES,
|
|
36294
|
+
pauseInBackground = true
|
|
36295
|
+
} = options;
|
|
36296
|
+
const { idle } = useIdle(inactivityThreshold);
|
|
36297
|
+
const isPolling = ref(true);
|
|
36298
|
+
const pollingId = ref(null);
|
|
36299
|
+
const isTabActive = () => {
|
|
36300
|
+
return !pauseInBackground || document.visibilityState === "visible";
|
|
36301
|
+
};
|
|
36302
|
+
const stopPolling = () => {
|
|
36303
|
+
isPolling.value = false;
|
|
36304
|
+
if (pollingId.value !== null) {
|
|
36305
|
+
clearTimeout(pollingId.value);
|
|
36306
|
+
pollingId.value = null;
|
|
36307
|
+
}
|
|
36308
|
+
};
|
|
36309
|
+
const pausePolling = () => {
|
|
36310
|
+
if (pollingId.value !== null) {
|
|
36311
|
+
clearTimeout(pollingId.value);
|
|
36312
|
+
pollingId.value = null;
|
|
36313
|
+
}
|
|
36314
|
+
};
|
|
36315
|
+
const startPolling = () => {
|
|
36316
|
+
if (pollingId.value !== null) {
|
|
36317
|
+
clearTimeout(pollingId.value);
|
|
36318
|
+
pollingId.value = null;
|
|
36319
|
+
}
|
|
36320
|
+
const poll = async () => {
|
|
36321
|
+
if (isPolling.value && isTabActive() && !idle.value) {
|
|
36322
|
+
try {
|
|
36323
|
+
await fn();
|
|
36324
|
+
} catch (error) {
|
|
36325
|
+
console.error("Polling error:", error);
|
|
36326
|
+
}
|
|
36327
|
+
}
|
|
36328
|
+
if (isPolling.value) {
|
|
36329
|
+
pollingId.value = window.setTimeout(poll, interval);
|
|
36330
|
+
}
|
|
36331
|
+
};
|
|
36332
|
+
poll();
|
|
36333
|
+
};
|
|
36334
|
+
const resumePolling = () => {
|
|
36335
|
+
if (isPolling.value) startPolling();
|
|
36336
|
+
else console.warn("Cannot resume polling that was stopped");
|
|
36337
|
+
};
|
|
36338
|
+
function updateVisibility() {
|
|
36339
|
+
if (document.visibilityState === "visible") {
|
|
36340
|
+
if (isPolling.value) startPolling();
|
|
36341
|
+
} else if (pauseInBackground) {
|
|
36342
|
+
pausePolling();
|
|
36343
|
+
}
|
|
36344
|
+
}
|
|
36345
|
+
onMounted(() => {
|
|
36346
|
+
document.addEventListener("visibilitychange", updateVisibility);
|
|
36347
|
+
startPolling();
|
|
36348
|
+
});
|
|
36349
|
+
onUnmounted(() => {
|
|
36350
|
+
document.removeEventListener("visibilitychange", updateVisibility);
|
|
36351
|
+
stopPolling();
|
|
36352
|
+
});
|
|
36353
|
+
return {
|
|
36354
|
+
isPolling,
|
|
36355
|
+
pausePolling,
|
|
36356
|
+
resumePolling,
|
|
36357
|
+
startPolling,
|
|
36358
|
+
stopPolling
|
|
36359
|
+
};
|
|
36360
|
+
}
|
|
36186
36361
|
function useValidateFieldValue(inputVal, getInput, validateFn, getFormData) {
|
|
36187
36362
|
watchDebounced(
|
|
36188
36363
|
inputVal,
|
|
@@ -37707,6 +37882,7 @@ export {
|
|
|
37707
37882
|
useLang,
|
|
37708
37883
|
useLocalStorage,
|
|
37709
37884
|
useModal,
|
|
37885
|
+
usePolling,
|
|
37710
37886
|
useValidateFieldValue,
|
|
37711
37887
|
vDraggable
|
|
37712
37888
|
};
|
|
@@ -20,6 +20,9 @@ interface TextInputOptions<T, K> extends InputOptions<T, K> {
|
|
|
20
20
|
type?: 'text' | 'tel' | 'email';
|
|
21
21
|
pattern?: string;
|
|
22
22
|
multiline?: boolean;
|
|
23
|
+
autoheight?: boolean;
|
|
24
|
+
code?: boolean;
|
|
25
|
+
rows?: number | string;
|
|
23
26
|
}
|
|
24
27
|
interface SlctInputOptions<T, K> extends InputOptions<T, K> {
|
|
25
28
|
searchable?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BagelFormUtils.d.ts","sourceRoot":"","sources":["../../src/utils/BagelFormUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC/I,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAA;AAErF,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;CACnB;AAED,UAAU,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W,EAAE,OAAO,WAAW,CAAA;IAC/B,UAAU,EAAE,OAAO,UAAU,CAAA;IAC7B,SAAS,EAAE,OAAO,SAAS,CAAA;IAC3B,QAAQ,EAAE,OAAO,QAAQ,CAAA;IACzB,MAAM,EAAE,OAAO,MAAM,CAAA;IACrB,WAAW,EAAE,OAAO,WAAW,CAAA;IAC/B,UAAU,EAAE,OAAO,UAAU,CAAA;IAC7B,OAAO,EAAE,OAAO,OAAO,CAAA;IACvB,QAAQ,EAAE,OAAO,QAAQ,CAAA;IACzB,UAAU,EAAE,OAAO,UAAU,CAAA;IAC7B,QAAQ,EAAE,OAAO,QAAQ,CAAA;IACzB,QAAQ,EAAE,OAAO,QAAQ,CAAA;IACzB,gBAAgB,EAAE,OAAO,gBAAgB,CAAA;CACzC,CAiBA"}
|
package/package.json
CHANGED
package/src/composables/index.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { getFallbackSchema } from '@bagelink/vue'
|
|
|
5
5
|
import { ref, watch } from 'vue'
|
|
6
6
|
|
|
7
7
|
export { useDevice } from './useDevice'
|
|
8
|
+
export { usePolling } from './usePolling'
|
|
8
9
|
export { useValidateFieldValue } from './useValidateFieldValue'
|
|
9
|
-
|
|
10
10
|
interface UseBglSchemaParamsT<T> {
|
|
11
11
|
schema?: BglFormSchemaFnT<T>
|
|
12
12
|
columns?: string[]
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useIdle } from '@vueuse/core'
|
|
2
|
+
import { ref, onMounted, onUnmounted } from 'vue'
|
|
3
|
+
|
|
4
|
+
const SECONDS = 1000
|
|
5
|
+
const MINUTES = 60 * SECONDS
|
|
6
|
+
|
|
7
|
+
interface PollingOptions {
|
|
8
|
+
interval?: number
|
|
9
|
+
inactivityThreshold?: number
|
|
10
|
+
pauseInBackground?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function usePolling(
|
|
14
|
+
fn: () => Promise<any> | void,
|
|
15
|
+
options: PollingOptions = {}
|
|
16
|
+
) {
|
|
17
|
+
const {
|
|
18
|
+
interval = 30 * SECONDS,
|
|
19
|
+
inactivityThreshold = 5 * MINUTES,
|
|
20
|
+
pauseInBackground = true,
|
|
21
|
+
} = options
|
|
22
|
+
|
|
23
|
+
const { idle } = useIdle(inactivityThreshold)
|
|
24
|
+
const isPolling = ref(true)
|
|
25
|
+
const pollingId = ref<number | null>(null)
|
|
26
|
+
|
|
27
|
+
const isTabActive = () => {
|
|
28
|
+
return !pauseInBackground || document.visibilityState === 'visible'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Stop polling permanently - cannot be resumed
|
|
32
|
+
const stopPolling = () => {
|
|
33
|
+
isPolling.value = false // Permanently set to false
|
|
34
|
+
if (pollingId.value !== null) {
|
|
35
|
+
clearTimeout(pollingId.value)
|
|
36
|
+
pollingId.value = null
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Pause polling temporarily - can be resumed
|
|
41
|
+
const pausePolling = () => {
|
|
42
|
+
if (pollingId.value !== null) {
|
|
43
|
+
clearTimeout(pollingId.value)
|
|
44
|
+
pollingId.value = null
|
|
45
|
+
}
|
|
46
|
+
// Note: We don't change isPolling.value here, just clear the timeout
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Start polling with intelligent checks
|
|
50
|
+
const startPolling = () => {
|
|
51
|
+
// Clear any existing polling timeout
|
|
52
|
+
if (pollingId.value !== null) {
|
|
53
|
+
clearTimeout(pollingId.value)
|
|
54
|
+
pollingId.value = null
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const poll = async () => {
|
|
58
|
+
if (isPolling.value && isTabActive() && !idle.value) {
|
|
59
|
+
try {
|
|
60
|
+
await fn()
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error('Polling error:', error)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (isPolling.value) {
|
|
66
|
+
pollingId.value = window.setTimeout(poll, interval)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
poll()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const resumePolling = () => {
|
|
73
|
+
if (isPolling.value) startPolling()
|
|
74
|
+
else console.warn('Cannot resume polling that was stopped')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function updateVisibility() {
|
|
78
|
+
if (document.visibilityState === 'visible') {
|
|
79
|
+
if (isPolling.value) startPolling()
|
|
80
|
+
} else if (pauseInBackground) {
|
|
81
|
+
pausePolling()
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
onMounted(() => {
|
|
86
|
+
document.addEventListener('visibilitychange', updateVisibility)
|
|
87
|
+
startPolling()
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
onUnmounted(() => {
|
|
91
|
+
document.removeEventListener('visibilitychange', updateVisibility)
|
|
92
|
+
stopPolling()
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
isPolling,
|
|
97
|
+
pausePolling,
|
|
98
|
+
resumePolling,
|
|
99
|
+
startPolling,
|
|
100
|
+
stopPolling
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -23,6 +23,9 @@ interface TextInputOptions<T, K> extends InputOptions<T, K> {
|
|
|
23
23
|
type?: 'text' | 'tel' | 'email'
|
|
24
24
|
pattern?: string
|
|
25
25
|
multiline?: boolean
|
|
26
|
+
autoheight?: boolean
|
|
27
|
+
code?: boolean
|
|
28
|
+
rows?: number | string
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
interface SlctInputOptions<T, K> extends InputOptions<T, K> {
|
|
@@ -94,6 +97,9 @@ export function txtField<T extends { [key: string]: any }, P>(
|
|
|
94
97
|
pattern: options?.pattern,
|
|
95
98
|
multiline: options?.multiline,
|
|
96
99
|
autocomplete: options?.autocomplete,
|
|
100
|
+
rows: options?.rows,
|
|
101
|
+
code: options?.code,
|
|
102
|
+
autoheight: options?.autoheight,
|
|
97
103
|
},
|
|
98
104
|
}
|
|
99
105
|
}
|
package/dist/types/timeago.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export interface TimeUnit {
|
|
2
|
-
singular: string;
|
|
3
|
-
plural: string;
|
|
4
|
-
}
|
|
5
|
-
export type TranslationValue = string | TimeUnit;
|
|
6
|
-
export interface LanguageTranslations {
|
|
7
|
-
[key: string]: TranslationValue;
|
|
8
|
-
}
|
|
9
|
-
export type AvailableTimeLanguages = 'en' | 'es' | 'fr' | 'he';
|
|
10
|
-
export type DayFormatTypes = 'DD' | 'DDD' | 'DDDD';
|
|
11
|
-
export type MonthFormatTypes = 'MM' | 'MMM' | 'MMMM';
|
|
12
|
-
export type YearFormatTypes = 'YY' | 'YYYY';
|
|
13
|
-
export type HourFormatTypes = 'HH';
|
|
14
|
-
export type MinuteFormatTypes = 'mm';
|
|
15
|
-
export type SecondFormatTypes = 'ss';
|
|
16
|
-
export type MillisecondFormatTypes = 'sss';
|
|
17
|
-
export type AmPmFormatTypes = 'AmPm';
|
|
18
|
-
export type DateFormatSeparatorTypes = '/' | '-' | ' ' | ':' | '.';
|
|
19
|
-
export type CommonDateFormats = `${DayFormatTypes}${DateFormatSeparatorTypes}${MonthFormatTypes}${DateFormatSeparatorTypes}${YearFormatTypes}` | 'DD.MM.YY' | 'DD.MM.YYYY' | 'DD/MM/YY' | 'DD/MM/YYYY' | 'MM.DD.YY' | 'MM.DD.YYYY' | 'MM/DD/YY' | 'MM/DD/YYYY' | 'YYYY-MM-DD' | 'YY-MM-DD' | 'DD MMM YYYY' | 'DD MMMM YYYY' | 'DDD, DD MMM' | 'DDDD, DD MMMM' | 'MMM DD' | 'MMMM DD';
|
|
20
|
-
export type CommonTimeFormats = 'HH:mm' | 'HH:mm:ss' | 'HH:mm:ss:sss' | 'HH:MM' | 'HH:mm AmPm';
|
|
21
|
-
export type CommonDateTimeFormats = `${CommonDateFormats} ${CommonTimeFormats}` | `${CommonTimeFormats}, ${CommonDateFormats}` | 'YYYY-MM-DD HH:MM';
|
|
22
|
-
export type DateTimeAcceptedFormats = CommonDateFormats | CommonTimeFormats | CommonDateTimeFormats;
|
|
23
|
-
//# sourceMappingURL=timeago.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timeago.d.ts","sourceRoot":"","sources":["../../src/types/timeago.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACd;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,QAAQ,CAAA;AAEhD,MAAM,WAAW,oBAAoB;IACpC,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAA;CAC/B;AAED,MAAM,MAAM,sBAAsB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAE9D,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM,CAAA;AAClD,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM,CAAA;AACpD,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,MAAM,CAAA;AAC3C,MAAM,MAAM,eAAe,GAAG,IAAI,CAAA;AAClC,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAA;AACpC,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAA;AACpC,MAAM,MAAM,sBAAsB,GAAG,KAAK,CAAA;AAC1C,MAAM,MAAM,eAAe,GAAG,MAAM,CAAA;AAEpC,MAAM,MAAM,wBAAwB,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAGlE,MAAM,MAAM,iBAAiB,GAC1B,GAAG,cAAc,GAAG,wBAAwB,GAAG,gBAAgB,GAAG,wBAAwB,GAAG,eAAe,EAAE,GAC9G,UAAU,GAAG,YAAY,GAAG,UAAU,GAAG,YAAY,GACrD,UAAU,GAAG,YAAY,GAAG,UAAU,GAAG,YAAY,G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