mgv-backoffice 1.44.0 → 1.45.0
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/README.md +2016 -2000
- package/dist/components/Pagination.vue.d.ts +9 -0
- package/dist/composables/useLatestRequest.d.ts +51 -0
- package/dist/index.d.ts +3 -1
- package/dist/ui-lib.js +942 -899
- package/dist/ui-lib.umd.cjs +1 -1
- package/dist/utils/format.d.ts +8 -0
- package/package.json +1 -1
- package/src/components/Pagination.test.ts +39 -0
- package/src/components/Pagination.vue +102 -87
- package/src/composables/useLatestRequest.test.ts +61 -0
- package/src/composables/useLatestRequest.ts +81 -0
- package/src/index.ts +3 -0
- package/src/utils/format.test.ts +26 -0
- package/src/utils/format.ts +25 -0
|
@@ -7,6 +7,10 @@ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractP
|
|
|
7
7
|
type: NumberConstructor;
|
|
8
8
|
default: number;
|
|
9
9
|
};
|
|
10
|
+
page: {
|
|
11
|
+
type: NumberConstructor;
|
|
12
|
+
default: undefined;
|
|
13
|
+
};
|
|
10
14
|
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
11
15
|
"page-changed": (...args: any[]) => void;
|
|
12
16
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
@@ -18,9 +22,14 @@ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractP
|
|
|
18
22
|
type: NumberConstructor;
|
|
19
23
|
default: number;
|
|
20
24
|
};
|
|
25
|
+
page: {
|
|
26
|
+
type: NumberConstructor;
|
|
27
|
+
default: undefined;
|
|
28
|
+
};
|
|
21
29
|
}>> & Readonly<{
|
|
22
30
|
"onPage-changed"?: ((...args: any[]) => any) | undefined;
|
|
23
31
|
}>, {
|
|
32
|
+
page: number;
|
|
24
33
|
itemsPerPage: number;
|
|
25
34
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
26
35
|
declare const _default: typeof __VLS_export;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** One begun request: its abort signal and whether it is still the latest. */
|
|
2
|
+
export interface LatestRequestToken {
|
|
3
|
+
/** Pass to fetch(); aborted as soon as a newer request begins (or on cancel). */
|
|
4
|
+
signal: AbortSignal;
|
|
5
|
+
/**
|
|
6
|
+
* True while no newer begin() / cancel() has happened. Check it after every
|
|
7
|
+
* await before writing state, so a superseded response can never clobber
|
|
8
|
+
* the newer one's — and only the latest call clears its loading flag.
|
|
9
|
+
*/
|
|
10
|
+
isLatest: () => boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* "Latest request wins" guard for views that refetch on every filter change,
|
|
14
|
+
* poll, or Refresh click. Each `begin()` aborts the previous in-flight request
|
|
15
|
+
* on the wire and hands back a fresh AbortSignal plus an `isLatest()` check
|
|
16
|
+
* (a monotonic request id), so a slow, stale response that still lands can be
|
|
17
|
+
* dropped instead of racing the fresh one.
|
|
18
|
+
*
|
|
19
|
+
* `cancel()` aborts the in-flight request and invalidates it without starting
|
|
20
|
+
* a new one (e.g. the selection was cleared). When called inside a component
|
|
21
|
+
* setup / effect scope, the in-flight request is cancelled automatically on
|
|
22
|
+
* unmount.
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* const latest = useLatestRequest()
|
|
26
|
+
* async function load() {
|
|
27
|
+
* const req = latest.begin()
|
|
28
|
+
* loading.value = true
|
|
29
|
+
* try {
|
|
30
|
+
* const res = await fetchThings(req.signal)
|
|
31
|
+
* if (!req.isLatest()) return
|
|
32
|
+
* rows.value = res
|
|
33
|
+
* } catch (e) {
|
|
34
|
+
* if (!req.isLatest() || isAbortError(e)) return
|
|
35
|
+
* error.value = String(e)
|
|
36
|
+
* } finally {
|
|
37
|
+
* if (req.isLatest()) loading.value = false
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function useLatestRequest(): {
|
|
43
|
+
begin: () => LatestRequestToken;
|
|
44
|
+
cancel: () => void;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* True for the rejection an aborted fetch() produces (a DOMException — or, in
|
|
48
|
+
* some runtimes, a plain Error — named "AbortError"). Superseded / cancelled
|
|
49
|
+
* requests should be swallowed silently rather than shown as an error.
|
|
50
|
+
*/
|
|
51
|
+
export declare function isAbortError(e: unknown): boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -74,6 +74,8 @@ export { useFieldClasses } from './composables/useFieldClasses';
|
|
|
74
74
|
export type { FieldClasses } from './composables/useFieldClasses';
|
|
75
75
|
export { usePolling } from './composables/usePolling';
|
|
76
76
|
export type { UsePollingOptions } from './composables/usePolling';
|
|
77
|
+
export { useLatestRequest, isAbortError } from './composables/useLatestRequest';
|
|
78
|
+
export type { LatestRequestToken } from './composables/useLatestRequest';
|
|
77
79
|
export { AlertEnum } from './enums/AlertEnum';
|
|
78
80
|
export { BaseBadgeEnum } from './enums/BaseBadgeEnum';
|
|
79
81
|
export { BaseButtonEnum } from './enums/BaseButtonEnum';
|
|
@@ -101,7 +103,7 @@ export { methodBadgeSolid, methodBadgeBright, methodBadgeTinted, statusBadgeSoli
|
|
|
101
103
|
export { rowKeyMissing, rowValueMissing } from './utils/kvRows';
|
|
102
104
|
export type { KeyValueRowLike } from './utils/kvRows';
|
|
103
105
|
export { sanitizeHtml, isSafeHref } from './utils/sanitizeHtml';
|
|
104
|
-
export { fmtNumber, fmtDate, fmtDateTime, fmtDateTimeMs, fmtDateShort, fmtCalendarDate, fmtCalendarDateTime, fmtMsAsSeconds, fmtBytes, fmtPrice, fmtPct, fmtUsd, fmtDuration, formatJson, stringifyValue, } from './utils/format';
|
|
106
|
+
export { fmtNumber, fmtDate, fmtDateTime, fmtDateTimeMs, fmtDateShort, fmtCalendarDate, fmtCalendarDateTime, fmtMsAsSeconds, fmtBytes, fmtPrice, fmtPct, fmtUsd, fmtMoney, fmtDuration, formatJson, stringifyValue, } from './utils/format';
|
|
105
107
|
export { isValidAbsoluteUrl, isValidJson, isValidXml, isValidBase64, } from './utils/validate';
|
|
106
108
|
export { buildSpecParams, firstInvalidNumericSpec } from './utils/specForm';
|
|
107
109
|
export { humanizeEnum, humanizeTextVNodes } from './utils/humanize';
|