@anzusystems/common-admin 2.0.0-rc.19 → 2.0.0-rc.20
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/common-admin.css +1 -1
- package/dist/common-admin.js +7 -1
- package/dist/domains/filters/datatable/components/ADatatableSidePanel.js +7 -0
- package/dist/domains/filters/datatable/components/ADatatableSidePanel.js.map +1 -0
- package/dist/domains/filters/datatable/components/ADatatableSidePanel.vue.d.ts +36 -0
- package/dist/domains/filters/datatable/components/ADatatableSidePanel.vue_vue_type_script_setup_true_lang.js +53 -0
- package/dist/domains/filters/datatable/components/ADatatableSidePanel.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/domains/filters/datatable/components/ALiveListingPill.js +7 -0
- package/dist/domains/filters/datatable/components/ALiveListingPill.js.map +1 -0
- package/dist/domains/filters/datatable/components/ALiveListingPill.vue.d.ts +24 -0
- package/dist/domains/filters/datatable/components/ALiveListingPill.vue_vue_type_script_setup_true_lang.js +78 -0
- package/dist/domains/filters/datatable/components/ALiveListingPill.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/domains/filters/datatable/composables/useDatatableSidePanel.d.ts +25 -0
- package/dist/domains/filters/datatable/composables/useDatatableSidePanel.js +45 -0
- package/dist/domains/filters/datatable/composables/useDatatableSidePanel.js.map +1 -0
- package/dist/domains/filters/datatable/composables/useLiveListing.d.ts +75 -0
- package/dist/domains/filters/datatable/composables/useLiveListing.js +142 -0
- package/dist/domains/filters/datatable/composables/useLiveListing.js.map +1 -0
- package/dist/domains/filters/datatable/composables/useSeenRecords.d.ts +18 -0
- package/dist/domains/filters/datatable/composables/useSeenRecords.js +69 -0
- package/dist/domains/filters/datatable/composables/useSeenRecords.js.map +1 -0
- package/dist/domains/system/appShell/components/AActionbar.vue_vue_type_script_setup_true_lang.js +30 -25
- package/dist/domains/system/appShell/components/AActionbar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/domains/system/composables/breadcrumbs.d.ts +5 -0
- package/dist/domains/system/composables/breadcrumbs.js.map +1 -1
- package/dist/domains/system/composables/browserTitle.d.ts +46 -0
- package/dist/domains/system/composables/browserTitle.js +56 -0
- package/dist/domains/system/composables/browserTitle.js.map +1 -0
- package/dist/lib.d.ts +10 -0
- package/dist/locales/cs/common/system.js +85 -0
- package/dist/locales/cs/common/system.js.map +1 -1
- package/dist/locales/cs.d.ts +6 -0
- package/dist/locales/en/common/system.js +51 -0
- package/dist/locales/en/common/system.js.map +1 -1
- package/dist/locales/en.d.ts +6 -0
- package/dist/locales/sk/common/system.js +85 -0
- package/dist/locales/sk/common/system.js.map +1 -1
- package/dist/locales/sk.d.ts +6 -0
- package/dist/plugins/i18n.d.ts +6 -0
- package/package.json +2 -2
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComputedRef, MaybeRefOrGetter, Ref } from 'vue';
|
|
2
|
+
export interface DatatableSidePanelWidth {
|
|
3
|
+
/** Window width from which this panel width applies. */
|
|
4
|
+
from: number;
|
|
5
|
+
width: number;
|
|
6
|
+
}
|
|
7
|
+
export interface UseDatatableSidePanelOptions {
|
|
8
|
+
/** Narrower windows get no panel; a row click should open the record's detail instead. Default 1000. */
|
|
9
|
+
minWindowWidth?: number;
|
|
10
|
+
/** Panel width by window width. Default (also for an empty list) 480 from 1800, 420 from 1500, 360 below. */
|
|
11
|
+
widths?: DatatableSidePanelWidth[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* State of a panel next to a list that shows the record of the clicked row. Pair it with `ADatatableSidePanel`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useDatatableSidePanel<TId = number>(options?: UseDatatableSidePanelOptions): {
|
|
17
|
+
selectedId: Ref<TId | null, TId | null>;
|
|
18
|
+
isOpen: ComputedRef<boolean>;
|
|
19
|
+
available: ComputedRef<boolean>;
|
|
20
|
+
width: ComputedRef<number>;
|
|
21
|
+
windowWidth: import('vue').ShallowRef<number>;
|
|
22
|
+
open: (id: TId) => boolean;
|
|
23
|
+
close: () => void;
|
|
24
|
+
columnsWithPanel: <T>(columns: MaybeRefOrGetter<T[]>, hidden: MaybeRefOrGetter<string[]>) => ComputedRef<T[]>;
|
|
25
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { computed as e, ref as t, toValue as n, watch as r } from "vue";
|
|
2
|
+
import { useWindowSize as i } from "@vueuse/core";
|
|
3
|
+
// src/domains/filters/datatable/composables/useDatatableSidePanel.ts
|
|
4
|
+
var a = [
|
|
5
|
+
{
|
|
6
|
+
from: 1800,
|
|
7
|
+
width: 480
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
from: 1500,
|
|
11
|
+
width: 420
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
from: 0,
|
|
15
|
+
width: 360
|
|
16
|
+
}
|
|
17
|
+
];
|
|
18
|
+
function o(o = {}) {
|
|
19
|
+
let s = o.minWindowWidth ?? 1e3, c = [...o.widths?.length ? o.widths : a].sort((e, t) => t.from - e.from), { width: l } = i(), u = t(null), d = e(() => l.value >= s), f = e(() => d.value && u.value !== null), p = e(() => (c.find((e) => l.value >= e.from) ?? c.at(-1)).width), m = (e) => d.value ? (u.value = e, !0) : !1, h = () => {
|
|
20
|
+
u.value = null;
|
|
21
|
+
};
|
|
22
|
+
return r(d, (e) => {
|
|
23
|
+
e || h();
|
|
24
|
+
}), {
|
|
25
|
+
selectedId: u,
|
|
26
|
+
isOpen: f,
|
|
27
|
+
available: d,
|
|
28
|
+
width: p,
|
|
29
|
+
windowWidth: l,
|
|
30
|
+
open: m,
|
|
31
|
+
close: h,
|
|
32
|
+
columnsWithPanel: (t, r) => e(() => {
|
|
33
|
+
let e = n(t);
|
|
34
|
+
if (!f.value) return e;
|
|
35
|
+
let i = n(r);
|
|
36
|
+
return e.filter((e) => {
|
|
37
|
+
let t = e.key;
|
|
38
|
+
return typeof t != "string" || !i.includes(t);
|
|
39
|
+
});
|
|
40
|
+
})
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export { o as useDatatableSidePanel };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=useDatatableSidePanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDatatableSidePanel.js","names":["DEFAULT_WIDTHS","useDatatableSidePanel","minWindowWidth","options","widths","b","a","windowWidth","useWindowSize","selectedId","ref","available","computed","isOpen","width","one","open","id","close","watch","value","all","toValue","columns","skip","hidden","key","column"],"sources":["../../../../../src/domains/filters/datatable/composables/useDatatableSidePanel.ts"],"sourcesContent":["import { useWindowSize } from '@vueuse/core'\nimport { computed, ref, toValue, watch, type ComputedRef, type MaybeRefOrGetter, type Ref } from 'vue'\n\nexport interface DatatableSidePanelWidth {\n /** Window width from which this panel width applies. */\n from: number\n width: number\n}\n\nexport interface UseDatatableSidePanelOptions {\n /** Narrower windows get no panel; a row click should open the record's detail instead. Default 1000. */\n minWindowWidth?: number\n /** Panel width by window width. Default (also for an empty list) 480 from 1800, 420 from 1500, 360 below. */\n widths?: DatatableSidePanelWidth[]\n}\n\nconst DEFAULT_WIDTHS: DatatableSidePanelWidth[] = [\n { from: 1800, width: 480 },\n { from: 1500, width: 420 },\n { from: 0, width: 360 },\n]\n\n/**\n * State of a panel next to a list that shows the record of the clicked row. Pair it with `ADatatableSidePanel`.\n */\nexport function useDatatableSidePanel<TId = number>(options: UseDatatableSidePanelOptions = {}) {\n const minWindowWidth = options.minWindowWidth ?? 1000\n const widths = [...(options.widths?.length ? options.widths : DEFAULT_WIDTHS)].sort((a, b) => b.from - a.from)\n const { width: windowWidth } = useWindowSize()\n\n const selectedId = ref<TId | null>(null) as Ref<TId | null>\n const available = computed(() => windowWidth.value >= minWindowWidth)\n const isOpen = computed(() => available.value && selectedId.value !== null)\n const width = computed(() => (widths.find((one) => windowWidth.value >= one.from) ?? widths.at(-1)!).width)\n\n /** Shows a record in the panel; false when the window is too narrow for one. */\n const open = (id: TId) => {\n if (!available.value) return false\n selectedId.value = id\n return true\n }\n\n const close = () => {\n selectedId.value = null\n }\n\n watch(available, (value) => {\n if (!value) close()\n })\n\n /** The columns to render: while the panel is open, without the given keys. The stored column setting stays. */\n const columnsWithPanel = <T>(columns: MaybeRefOrGetter<T[]>, hidden: MaybeRefOrGetter<string[]>): ComputedRef<T[]> =>\n computed(() => {\n const all = toValue(columns)\n if (!isOpen.value) return all\n const skip = toValue(hidden)\n return all.filter((column) => {\n const key = (column as { key?: unknown }).key\n return typeof key !== 'string' || !skip.includes(key)\n })\n })\n\n return {\n selectedId,\n isOpen,\n available,\n width,\n windowWidth,\n open,\n close,\n columnsWithPanel,\n }\n}\n"],"mappings":";;;AAgBA,IAAMA,IAA4C;CAChD;EAAE,MAAM;EAAM,OAAO;CAAI;CACzB;EAAE,MAAM;EAAM,OAAO;CAAI;CACzB;EAAE,MAAM;EAAG,OAAO;CAAI;AACxB;AAKA,SAAgBC,EAAoC,IAAwC,CAAC,GAAG;CAC9F,IAAMC,IAAiBC,EAAQ,kBAAkB,KAC3CC,IAAS,CAAC,GAAID,EAAQ,QAAQ,SAASA,EAAQ,SAASH,CAAe,CAAC,CAAC,MAAM,GAAG,MAAMK,EAAE,OAAOC,EAAE,IAAI,GACvG,EAAE,OAAOC,MAAgBC,EAAc,GAEvCC,IAAaC,EAAgB,IAAI,GACjCC,IAAYC,QAAeL,EAAY,SAASL,CAAc,GAC9DW,IAASD,QAAeD,EAAU,SAASF,EAAW,UAAU,IAAI,GACpEK,IAAQF,SAAgBR,EAAO,MAAM,MAAQG,EAAY,SAASQ,EAAI,IAAI,KAAKX,EAAO,GAAG,EAAE,EAAA,CAAI,KAAK,GAGpGY,KAAQ,MACPL,EAAU,SACf,EAAW,QAAQM,GACZ,MAFsB,IAKzBC,UAAc;EAClB,EAAW,QAAQ;CACrB;CAkBA,OAhBAC,EAAMR,IAAY,MAAU;EAC1B,AAAKS,KAAOF,EAAM;CACpB,CAAC,GAcM;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA,mBAnB2B,GAAgC,MAC3DN,QAAe;GACb,IAAMS,IAAMC,EAAQC,CAAO;GAC3B,IAAI,CAACV,EAAO,OAAO,OAAOQ;GAC1B,IAAMG,IAAOF,EAAQG,CAAM;GAC3B,OAAOJ,EAAI,QAAQ,MAAW;IAC5B,IAAMK,IAAOC,EAA6B;IAC1C,OAAO,OAAOD,KAAQ,YAAY,CAACF,EAAK,SAASE,CAAG;GACtD,CAAC;EACH,CAAC;CAWH;AACF"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { MaybeRefOrGetter } from 'vue';
|
|
2
|
+
export type LiveListingKey = number | string;
|
|
3
|
+
export interface LiveListingProbeOptions {
|
|
4
|
+
limit: number;
|
|
5
|
+
signal: AbortSignal;
|
|
6
|
+
}
|
|
7
|
+
export interface LiveListingInterval {
|
|
8
|
+
/** Probe period while the browser tab is visible. */
|
|
9
|
+
visibleMs: number;
|
|
10
|
+
/** Probe period while the browser tab is hidden, so a count in the browser title stays fresh. */
|
|
11
|
+
hiddenMs: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* How often a list without backend signals probes for new records: every 10 s while the browser tab is visible,
|
|
15
|
+
* every minute while it is hidden, so a count in the browser title stays fresh.
|
|
16
|
+
*/
|
|
17
|
+
export declare const LIVE_LISTING_INTERVAL: LiveListingInterval;
|
|
18
|
+
/**
|
|
19
|
+
* How a record counts as new: `newer` than the newest record the user has seen, or `unseen`, a record of the probe
|
|
20
|
+
* the user has not seen listed, for listings where a record can enter with a key older than the newest one.
|
|
21
|
+
*/
|
|
22
|
+
export type LiveListingNewness = 'newer' | 'unseen';
|
|
23
|
+
export interface UseLiveListingOptions<T> {
|
|
24
|
+
/**
|
|
25
|
+
* Newest records under the current filters, newest first by `key`, at most `limit` of them.
|
|
26
|
+
* It must leave the shown list alone and load nothing else for the rows.
|
|
27
|
+
*/
|
|
28
|
+
probe: (options: LiveListingProbeOptions) => Promise<T[]>;
|
|
29
|
+
/** Newness key: an autoincrement id, or a UTC datetime string in one format. */
|
|
30
|
+
key: (item: T) => LiveListingKey;
|
|
31
|
+
/** Fetches the list on the click of the pill and reports it back with `markLoaded`. */
|
|
32
|
+
reload: () => Promise<void>;
|
|
33
|
+
/** What the user filters by. When it changes, the baseline is set anew; otherwise it never decreases. */
|
|
34
|
+
scope?: MaybeRefOrGetter<unknown>;
|
|
35
|
+
/** Probes on a timer, for listings without a backend signal, or while it is down. */
|
|
36
|
+
interval?: MaybeRefOrGetter<LiveListingInterval | false>;
|
|
37
|
+
newness?: LiveListingNewness;
|
|
38
|
+
/**
|
|
39
|
+
* How many of the newest records a probe asks for. Default `max + 1`; with `unseen` newness give the page size,
|
|
40
|
+
* as an unseen record can enter anywhere on the first page.
|
|
41
|
+
*/
|
|
42
|
+
probeLimit?: number;
|
|
43
|
+
/** Highest count shown as a number, more is shown as `max+`. */
|
|
44
|
+
max?: number;
|
|
45
|
+
/** Shortest gap between the start of two probes requested by signals. */
|
|
46
|
+
minIntervalMs?: number;
|
|
47
|
+
/** Wait after a signal, so a burst of signals ends in one probe. */
|
|
48
|
+
debounceMs?: number;
|
|
49
|
+
}
|
|
50
|
+
/** Orders newness keys: numbers by value, strings (UTC datetimes in one format) as text. */
|
|
51
|
+
export declare const compareLiveListingKeys: (a: LiveListingKey, b: LiveListingKey) => number;
|
|
52
|
+
/**
|
|
53
|
+
* Tells the user that new records exist under the current filters, without changing the list until they click.
|
|
54
|
+
* A probe (a small list request, newest first) runs on a signal, on a timer or when the user returns to the
|
|
55
|
+
* browser tab; its records newer than the baseline are the count. The baseline is the newest record the user
|
|
56
|
+
* has seen, taken from every full load reported through `markLoaded`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function useLiveListing<T>(options: UseLiveListingOptions<T>): {
|
|
59
|
+
count: Readonly<import('vue').Ref<number, number>>;
|
|
60
|
+
overflow: import('vue').ComputedRef<boolean>;
|
|
61
|
+
label: import('vue').ComputedRef<string>;
|
|
62
|
+
failed: Readonly<import('vue').Ref<boolean, boolean>>;
|
|
63
|
+
/** Records already listed changed; see `markChanged`. */
|
|
64
|
+
changed: Readonly<import('vue').Ref<boolean, boolean>>;
|
|
65
|
+
/** The newest record the user has seen: `null` for an empty list, `undefined` before the first load. */
|
|
66
|
+
baseline: Readonly<import('vue').Ref<LiveListingKey | null | undefined, LiveListingKey | null | undefined>>;
|
|
67
|
+
max: number;
|
|
68
|
+
markLoaded: (items: T[], loaded: {
|
|
69
|
+
newestFirst: boolean;
|
|
70
|
+
newest?: T[];
|
|
71
|
+
}) => void;
|
|
72
|
+
requestProbe: () => void;
|
|
73
|
+
markChanged: () => void;
|
|
74
|
+
apply: () => Promise<void>;
|
|
75
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { computed as e, onScopeDispose as t, readonly as n, ref as r, shallowRef as i, toValue as a, watch as o } from "vue";
|
|
2
|
+
import { useDocumentVisibility as s } from "@vueuse/core";
|
|
3
|
+
// src/domains/filters/datatable/composables/useLiveListing.ts
|
|
4
|
+
var c = {
|
|
5
|
+
visibleMs: 1e4,
|
|
6
|
+
hiddenMs: 6e4
|
|
7
|
+
}, l = 2e3, ee = 6e4, u = (e, t) => {
|
|
8
|
+
if (typeof e == "number" && typeof t == "number") return e - t;
|
|
9
|
+
let n = String(e), r = String(t);
|
|
10
|
+
return n === r ? 0 : n < r ? -1 : 1;
|
|
11
|
+
}, te = (e) => {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.stringify(e) ?? "";
|
|
14
|
+
} catch {
|
|
15
|
+
return String(e);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
function d(c) {
|
|
19
|
+
let d = c.max ?? 9, f = c.minIntervalMs ?? 1e4, p = c.debounceMs ?? 1500, m = c.newness ?? "newer", h = Math.max(c.probeLimit ?? d + 1, d + 1), g = () => a(c.interval) ?? !1, _ = r(0), v = r(!1), y = r(!1), b = e(() => _.value > d), ne = e(() => _.value === 0 ? "" : b.value ? `${d}+` : String(_.value)), x, S = i(void 0), C = (e) => {
|
|
20
|
+
x = e, S.value = e;
|
|
21
|
+
}, w, T = /* @__PURE__ */ new Set(), E = 0, D, O, k = !1, A = 0, j, M, N, P = 0, F = !1, I = 0, L = 0, R, z, B = !1, V = s(), re = (e) => m === "unseen" ? x !== void 0 && !T.has(e) : x === null || x !== void 0 && u(e, x) > 0, H = (e, t) => {
|
|
22
|
+
w !== t && T.clear(), (w !== t || x == null || e !== null && u(e, x) > 0) && C(e), w = t;
|
|
23
|
+
}, U = (e) => {
|
|
24
|
+
m === "unseen" && e.forEach((e) => T.add(c.key(e)));
|
|
25
|
+
}, W = (e) => e.reduce((e, t) => {
|
|
26
|
+
let n = c.key(t);
|
|
27
|
+
return e === null || u(n, e) > 0 ? n : e;
|
|
28
|
+
}, null), G = () => {
|
|
29
|
+
D?.abort(), D = void 0, O = void 0, k = !1;
|
|
30
|
+
}, K = () => {
|
|
31
|
+
clearTimeout(j), clearTimeout(M), clearTimeout(N), j = void 0, M = void 0, N = void 0;
|
|
32
|
+
}, q = (e) => {
|
|
33
|
+
if (clearTimeout(N), B) return;
|
|
34
|
+
let t = Math.min(f * 2 ** P, ee);
|
|
35
|
+
P += 1, N = setTimeout(() => {
|
|
36
|
+
N = void 0, e();
|
|
37
|
+
}, t);
|
|
38
|
+
}, J = () => {
|
|
39
|
+
P = 0, clearTimeout(N), N = void 0, v.value = !1;
|
|
40
|
+
}, Y = () => {
|
|
41
|
+
F && (F = !1, Q());
|
|
42
|
+
}, X = () => {
|
|
43
|
+
clearTimeout(j), j = void 0;
|
|
44
|
+
let e = g();
|
|
45
|
+
if (!e || B || b.value || x === void 0) return;
|
|
46
|
+
let t = V.value === "hidden" ? e.hiddenMs : e.visibleMs;
|
|
47
|
+
j = setTimeout(async () => {
|
|
48
|
+
j = void 0, await Z(), X();
|
|
49
|
+
}, t);
|
|
50
|
+
}, Z = async () => {
|
|
51
|
+
if (B || x === void 0 || b.value) return;
|
|
52
|
+
if (D) {
|
|
53
|
+
k = !0;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
let e = E, t = new AbortController();
|
|
57
|
+
D = t, O = t, A = Date.now();
|
|
58
|
+
try {
|
|
59
|
+
let n = await c.probe({
|
|
60
|
+
limit: h,
|
|
61
|
+
signal: t.signal
|
|
62
|
+
});
|
|
63
|
+
if (t.signal.aborted || e !== E) return;
|
|
64
|
+
_.value = n.filter((e) => re(c.key(e))).length, J(), b.value && K();
|
|
65
|
+
} catch {
|
|
66
|
+
if (t.signal.aborted || e !== E) return;
|
|
67
|
+
v.value = !0, g() || q(() => void Z());
|
|
68
|
+
} finally {
|
|
69
|
+
D === t && (D = void 0), O === t && (O = void 0), k && !t.signal.aborted && (k = !1, Q());
|
|
70
|
+
}
|
|
71
|
+
}, Q = () => {
|
|
72
|
+
if (B || b.value) return;
|
|
73
|
+
if (x === void 0) {
|
|
74
|
+
F = !0;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (M) return;
|
|
78
|
+
let e = Math.max(p, A + f - Date.now());
|
|
79
|
+
M = setTimeout(() => {
|
|
80
|
+
M = void 0, Z();
|
|
81
|
+
}, e);
|
|
82
|
+
}, ie = () => {
|
|
83
|
+
B || (I += 1, Q());
|
|
84
|
+
}, $ = async (e, t) => {
|
|
85
|
+
let n = new AbortController();
|
|
86
|
+
D = n;
|
|
87
|
+
try {
|
|
88
|
+
let r = m === "unseen" ? h : 1, i = await c.probe({
|
|
89
|
+
limit: r,
|
|
90
|
+
signal: n.signal
|
|
91
|
+
});
|
|
92
|
+
if (n.signal.aborted || t !== E) return;
|
|
93
|
+
H(W(i), e), U(i), J(), X(), Y();
|
|
94
|
+
} catch {
|
|
95
|
+
if (n.signal.aborted || t !== E) return;
|
|
96
|
+
v.value = !0, q(() => {
|
|
97
|
+
t === E && $(e, t);
|
|
98
|
+
});
|
|
99
|
+
} finally {
|
|
100
|
+
D === n && (D = void 0), k && !n.signal.aborted && (k = !1, Q());
|
|
101
|
+
}
|
|
102
|
+
}, ae = () => M !== void 0 || k || O !== void 0 || (R === void 0 ? _.value > 0 : I > R), oe = (e, t) => {
|
|
103
|
+
E += 1, ae() && (F = !0), y.value = R !== void 0 && L > R, G(), K(), _.value = 0, P = 0, v.value = !1;
|
|
104
|
+
let n = te(a(c.scope)), r = t.newestFirst ? e : t.newest;
|
|
105
|
+
r ? (H(W(r), n), U(r), X(), Y()) : (C(void 0), X(), $(n, E));
|
|
106
|
+
}, se = () => {
|
|
107
|
+
B || E === 0 || (I += 1, L = I, y.value = !0);
|
|
108
|
+
}, ce = async () => {
|
|
109
|
+
(M !== void 0 || k || O !== void 0) && (F = !0), O &&= (O.abort(), D === O && (D = void 0), void 0), k = !1, clearTimeout(j), clearTimeout(M), j = void 0, M = void 0;
|
|
110
|
+
let e = E;
|
|
111
|
+
R = I;
|
|
112
|
+
try {
|
|
113
|
+
await c.reload();
|
|
114
|
+
} finally {
|
|
115
|
+
R = void 0, E === e && (X(), Y());
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
return o(() => a(c.interval), () => {
|
|
119
|
+
!B && x !== void 0 && X();
|
|
120
|
+
}), o(V, (e) => {
|
|
121
|
+
B || x === void 0 || (e === "visible" && !b.value && Date.now() - A > l && Z(), X());
|
|
122
|
+
}), t(() => {
|
|
123
|
+
B = !0, G(), K();
|
|
124
|
+
}), {
|
|
125
|
+
count: n(_),
|
|
126
|
+
overflow: b,
|
|
127
|
+
label: ne,
|
|
128
|
+
failed: n(v),
|
|
129
|
+
changed: n(y),
|
|
130
|
+
baseline: n(S),
|
|
131
|
+
max: d,
|
|
132
|
+
markLoaded: oe,
|
|
133
|
+
requestProbe: ie,
|
|
134
|
+
markChanged: se,
|
|
135
|
+
apply: () => (z ??= ce().finally(() => {
|
|
136
|
+
z = void 0;
|
|
137
|
+
}), z)
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export { c as LIVE_LISTING_INTERVAL, u as compareLiveListingKeys, d as useLiveListing };
|
|
141
|
+
|
|
142
|
+
//# sourceMappingURL=useLiveListing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLiveListing.js","names":["LIVE_LISTING_INTERVAL","RETURN_PROBE_GAP_MS","MAX_RETRY_MS","compareLiveListingKeys","a","b","sa","sb","serializeScope","scope","useLiveListing","max","options","minIntervalMs","debounceMs","newness","probeLimit","currentInterval","toValue","count","ref","failed","changed","overflow","computed","label","baseline","baselineState","shallowRef","setBaseline","value","baselineScope","seenKeys","generation","controller","probeInFlight","rerun","lastProbeAt","intervalTimer","signalTimer","retryTimer","failures","probeWanted","signals","changedAtSignal","applyingFrom","applying","disposed","visibility","useDocumentVisibility","isNew","key","raiseBaseline","see","items","item","newestKey","newest","abortProbe","clearTimers","scheduleRetry","ms","run","succeeded","runWantedProbe","scheduleProbe","scheduleInterval","interval","runProbe","myGeneration","myController","wait","requestProbe","fetchBaseline","limit","signalPending","markLoaded","seenNewest","loaded","markChanged","reloadOnClick","loadsBefore","watch","onScopeDispose","readonly"],"sources":["../../../../../src/domains/filters/datatable/composables/useLiveListing.ts"],"sourcesContent":["import { useDocumentVisibility } from '@vueuse/core'\nimport { computed, onScopeDispose, readonly, ref, shallowRef, toValue, watch, type MaybeRefOrGetter } from 'vue'\n\nexport type LiveListingKey = number | string\n\nexport interface LiveListingProbeOptions {\n limit: number\n signal: AbortSignal\n}\n\nexport interface LiveListingInterval {\n /** Probe period while the browser tab is visible. */\n visibleMs: number\n /** Probe period while the browser tab is hidden, so a count in the browser title stays fresh. */\n hiddenMs: number\n}\n\n/**\n * How often a list without backend signals probes for new records: every 10 s while the browser tab is visible,\n * every minute while it is hidden, so a count in the browser title stays fresh.\n */\nexport const LIVE_LISTING_INTERVAL: LiveListingInterval = { visibleMs: 10_000, hiddenMs: 60_000 }\n\n/**\n * How a record counts as new: `newer` than the newest record the user has seen, or `unseen`, a record of the probe\n * the user has not seen listed, for listings where a record can enter with a key older than the newest one.\n */\nexport type LiveListingNewness = 'newer' | 'unseen'\n\nexport interface UseLiveListingOptions<T> {\n /**\n * Newest records under the current filters, newest first by `key`, at most `limit` of them.\n * It must leave the shown list alone and load nothing else for the rows.\n */\n probe: (options: LiveListingProbeOptions) => Promise<T[]>\n /** Newness key: an autoincrement id, or a UTC datetime string in one format. */\n key: (item: T) => LiveListingKey\n /** Fetches the list on the click of the pill and reports it back with `markLoaded`. */\n reload: () => Promise<void>\n /** What the user filters by. When it changes, the baseline is set anew; otherwise it never decreases. */\n scope?: MaybeRefOrGetter<unknown>\n /** Probes on a timer, for listings without a backend signal, or while it is down. */\n interval?: MaybeRefOrGetter<LiveListingInterval | false>\n newness?: LiveListingNewness\n /**\n * How many of the newest records a probe asks for. Default `max + 1`; with `unseen` newness give the page size,\n * as an unseen record can enter anywhere on the first page.\n */\n probeLimit?: number\n /** Highest count shown as a number, more is shown as `max+`. */\n max?: number\n /** Shortest gap between the start of two probes requested by signals. */\n minIntervalMs?: number\n /** Wait after a signal, so a burst of signals ends in one probe. */\n debounceMs?: number\n}\n\nconst RETURN_PROBE_GAP_MS = 2000\nconst MAX_RETRY_MS = 60_000\n\n/** Orders newness keys: numbers by value, strings (UTC datetimes in one format) as text. */\nexport const compareLiveListingKeys = (a: LiveListingKey, b: LiveListingKey) => {\n if (typeof a === 'number' && typeof b === 'number') return a - b\n const sa = String(a)\n const sb = String(b)\n if (sa === sb) return 0\n return sa < sb ? -1 : 1\n}\n\nconst serializeScope = (scope: unknown) => {\n try {\n return JSON.stringify(scope) ?? ''\n } catch {\n return String(scope)\n }\n}\n\n/**\n * Tells the user that new records exist under the current filters, without changing the list until they click.\n * A probe (a small list request, newest first) runs on a signal, on a timer or when the user returns to the\n * browser tab; its records newer than the baseline are the count. The baseline is the newest record the user\n * has seen, taken from every full load reported through `markLoaded`.\n */\nexport function useLiveListing<T>(options: UseLiveListingOptions<T>) {\n const max = options.max ?? 9\n const minIntervalMs = options.minIntervalMs ?? 10_000\n const debounceMs = options.debounceMs ?? 1500\n const newness = options.newness ?? 'newer'\n const probeLimit = Math.max(options.probeLimit ?? max + 1, max + 1)\n const currentInterval = () => toValue(options.interval) ?? false\n\n const count = ref(0)\n const failed = ref(false)\n const changed = ref(false)\n const overflow = computed(() => count.value > max)\n const label = computed(() => {\n if (count.value === 0) return ''\n return overflow.value ? `${max}+` : String(count.value)\n })\n\n // undefined: not known yet, nothing is probed; null: the filtered list was empty, every record is new.\n let baseline: LiveListingKey | null | undefined = undefined\n // The same, for callers that keep what the user has seen, e.g. for a count on an inactive tab.\n const baselineState = shallowRef<LiveListingKey | null | undefined>(undefined)\n const setBaseline = (value: LiveListingKey | null | undefined) => {\n baseline = value\n baselineState.value = value\n }\n let baselineScope: string | undefined = undefined\n // With `unseen` newness: the keys the user has seen listed under the baseline scope.\n const seenKeys = new Set<LiveListingKey>()\n // Bumped by every full load: answers of probes started before it are dropped.\n let generation = 0\n let controller: AbortController | undefined = undefined\n // The controller of a probe in flight, as opposed to a baseline fetch.\n let probeInFlight: AbortController | undefined = undefined\n let rerun = false\n let lastProbeAt = 0\n let intervalTimer: ReturnType<typeof setTimeout> | undefined = undefined\n let signalTimer: ReturnType<typeof setTimeout> | undefined = undefined\n // A failed probe or baseline fetch is tried again, less and less often, also when no interval runs.\n let retryTimer: ReturnType<typeof setTimeout> | undefined = undefined\n let failures = 0\n // A probe asked for while no baseline is known, or while a full load replaces the list: it runs once the list is.\n let probeWanted = false\n // Signals (`requestProbe`, `markChanged`) counted, so the pill's reload can tell those that came while it ran.\n let signals = 0\n let changedAtSignal = 0\n let applyingFrom: number | undefined = undefined\n let applying: Promise<void> | undefined = undefined\n let disposed = false\n\n const visibility = useDocumentVisibility()\n\n const isNew = (key: LiveListingKey) => {\n if (newness === 'unseen') return baseline !== undefined && !seenKeys.has(key)\n return baseline === null || (baseline !== undefined && compareLiveListingKeys(key, baseline) > 0)\n }\n\n const raiseBaseline = (key: LiveListingKey | null, scope: string) => {\n if (baselineScope !== scope) seenKeys.clear()\n if (baselineScope !== scope || baseline === undefined || baseline === null) {\n setBaseline(key)\n } else if (key !== null && compareLiveListingKeys(key, baseline) > 0) {\n setBaseline(key)\n }\n baselineScope = scope\n }\n\n const see = (items: T[]) => {\n if (newness === 'unseen') items.forEach((item) => seenKeys.add(options.key(item)))\n }\n\n const newestKey = (items: T[]) =>\n items.reduce<LiveListingKey | null>((newest, item) => {\n const key = options.key(item)\n return newest === null || compareLiveListingKeys(key, newest) > 0 ? key : newest\n }, null)\n\n const abortProbe = () => {\n controller?.abort()\n controller = undefined\n probeInFlight = undefined\n rerun = false\n }\n\n const clearTimers = () => {\n clearTimeout(intervalTimer)\n clearTimeout(signalTimer)\n clearTimeout(retryTimer)\n intervalTimer = undefined\n signalTimer = undefined\n retryTimer = undefined\n }\n\n const scheduleRetry = (run: () => void) => {\n clearTimeout(retryTimer)\n if (disposed) return\n const ms = Math.min(minIntervalMs * 2 ** failures, MAX_RETRY_MS)\n failures += 1\n retryTimer = setTimeout(() => {\n retryTimer = undefined\n run()\n }, ms)\n }\n\n const succeeded = () => {\n failures = 0\n clearTimeout(retryTimer)\n retryTimer = undefined\n failed.value = false\n }\n\n const runWantedProbe = () => {\n if (!probeWanted) return\n probeWanted = false\n scheduleProbe()\n }\n\n const scheduleInterval = () => {\n clearTimeout(intervalTimer)\n intervalTimer = undefined\n const interval = currentInterval()\n if (!interval || disposed || overflow.value || baseline === undefined) return\n const ms = visibility.value === 'hidden' ? interval.hiddenMs : interval.visibleMs\n intervalTimer = setTimeout(async () => {\n intervalTimer = undefined\n await runProbe()\n scheduleInterval()\n }, ms)\n }\n\n const runProbe = async () => {\n if (disposed || baseline === undefined || overflow.value) return\n if (controller) {\n rerun = true\n return\n }\n const myGeneration = generation\n const myController = new AbortController()\n controller = myController\n probeInFlight = myController\n lastProbeAt = Date.now()\n try {\n const items = await options.probe({ limit: probeLimit, signal: myController.signal })\n if (myController.signal.aborted || myGeneration !== generation) return\n count.value = items.filter((item) => isNew(options.key(item))).length\n succeeded()\n if (overflow.value) clearTimers()\n } catch {\n if (myController.signal.aborted || myGeneration !== generation) return\n failed.value = true\n // The interval tries again on its own; signals may not come for long.\n if (!currentInterval()) scheduleRetry(() => void runProbe())\n } finally {\n if (controller === myController) controller = undefined\n if (probeInFlight === myController) probeInFlight = undefined\n if (rerun && !myController.signal.aborted) {\n rerun = false\n scheduleProbe()\n }\n }\n }\n\n const scheduleProbe = () => {\n if (disposed || overflow.value) return\n if (baseline === undefined) {\n probeWanted = true\n return\n }\n if (signalTimer) return\n const wait = Math.max(debounceMs, lastProbeAt + minIntervalMs - Date.now())\n signalTimer = setTimeout(() => {\n signalTimer = undefined\n void runProbe()\n }, wait)\n }\n\n /** Asks for a probe, e.g. on a backend signal. A burst of requests ends in one probe. */\n const requestProbe = () => {\n if (disposed) return\n signals += 1\n scheduleProbe()\n }\n\n const fetchBaseline = async (scope: string, myGeneration: number) => {\n const myController = new AbortController()\n controller = myController\n try {\n // With `unseen` newness, what the probe would count is seen: the list the user looks at holds it.\n const limit = newness === 'unseen' ? probeLimit : 1\n const items = await options.probe({ limit, signal: myController.signal })\n if (myController.signal.aborted || myGeneration !== generation) return\n raiseBaseline(newestKey(items), scope)\n see(items)\n succeeded()\n scheduleInterval()\n runWantedProbe()\n } catch {\n if (myController.signal.aborted || myGeneration !== generation) return\n failed.value = true\n // Without a baseline nothing is probed, so the fetch itself is tried again.\n scheduleRetry(() => {\n if (myGeneration === generation) void fetchBaseline(scope, myGeneration)\n })\n } finally {\n if (controller === myController) controller = undefined\n if (rerun && !myController.signal.aborted) {\n rerun = false\n scheduleProbe()\n }\n }\n }\n\n // A probe still to run or running may announce records the load did not see; so may one that counted records\n // while the load ran, unknown outside the pill's reload, which knows when it started.\n const signalPending = () =>\n signalTimer !== undefined ||\n rerun ||\n probeInFlight !== undefined ||\n (applyingFrom !== undefined ? signals > applyingFrom : count.value > 0)\n\n /**\n * Reports a successful full load of the list: a filter, a sort, page 1 or a reload after the click.\n * `newestFirst`: the items are page 1 sorted newest first, so the newest of them is the baseline.\n * Otherwise `newest` gives it: what the probe returns under the loaded filters (one record, with `unseen` newness\n * `probeLimit`), asked for when the load started, so a record created while the list loaded is counted, at worst\n * one the list shows. Without it one probe after the load finds the baseline and takes such a record as seen.\n * A switch to another page needs no report.\n */\n const markLoaded = (items: T[], loaded: { newestFirst: boolean; newest?: T[] }) => {\n generation += 1\n if (signalPending()) probeWanted = true\n // A change signalled while the pill's reload ran may be newer than what it loaded.\n changed.value = applyingFrom !== undefined && changedAtSignal > applyingFrom\n abortProbe()\n clearTimers()\n count.value = 0\n failures = 0\n failed.value = false\n const scope = serializeScope(toValue(options.scope))\n const seenNewest = loaded.newestFirst ? items : loaded.newest\n if (seenNewest) {\n raiseBaseline(newestKey(seenNewest), scope)\n see(seenNewest)\n scheduleInterval()\n runWantedProbe()\n return\n }\n // No probe runs until the new baseline is known: under other filters the old one means nothing, under the same\n // ones it may be older than the rows shown, so a probe would count them.\n setBaseline(undefined)\n scheduleInterval()\n void fetchBaseline(scope, generation)\n }\n\n /**\n * Asks the user to reload the list because records already in it changed, e.g. moved to another tab or got\n * another status, which no count shows. The pill offers it while nothing new is counted.\n */\n const markChanged = () => {\n // Before the first load nothing is shown that could change.\n if (disposed || generation === 0) return\n signals += 1\n changedAtSignal = signals\n changed.value = true\n }\n\n const reloadOnClick = async () => {\n if (signalTimer !== undefined || rerun || probeInFlight !== undefined) probeWanted = true\n // Only probes stop: a baseline still being fetched is needed when the reload fails.\n if (probeInFlight) {\n probeInFlight.abort()\n if (controller === probeInFlight) controller = undefined\n probeInFlight = undefined\n }\n rerun = false\n clearTimeout(intervalTimer)\n clearTimeout(signalTimer)\n intervalTimer = undefined\n signalTimer = undefined\n const loadsBefore = generation\n applyingFrom = signals\n try {\n await options.reload()\n } finally {\n applyingFrom = undefined\n // A fetched list reported itself through `markLoaded`, which started the counting anew. Without one nothing\n // was shown: the pill keeps what it offered and the looking goes on.\n if (generation === loadsBefore) {\n scheduleInterval()\n runWantedProbe()\n }\n }\n }\n\n /**\n * The click on the pill: reloads the list and starts counting again from it. A click while the reload runs\n * waits for the same reload.\n */\n const apply = () => {\n applying ??= reloadOnClick().finally(() => {\n applying = undefined\n })\n return applying\n }\n\n watch(\n () => toValue(options.interval),\n () => {\n if (!disposed && baseline !== undefined) scheduleInterval()\n }\n )\n\n watch(visibility, (value) => {\n if (disposed || baseline === undefined) return\n if (value === 'visible' && !overflow.value && Date.now() - lastProbeAt > RETURN_PROBE_GAP_MS) {\n void runProbe()\n }\n scheduleInterval()\n })\n\n onScopeDispose(() => {\n disposed = true\n abortProbe()\n clearTimers()\n })\n\n return {\n count: readonly(count),\n overflow,\n label,\n failed: readonly(failed),\n /** Records already listed changed; see `markChanged`. */\n changed: readonly(changed),\n /** The newest record the user has seen: `null` for an empty list, `undefined` before the first load. */\n baseline: readonly(baselineState),\n max,\n markLoaded,\n requestProbe,\n markChanged,\n apply,\n }\n}\n"],"mappings":";;;AAqBA,IAAaA,IAA6C;CAAE,WAAW;CAAQ,UAAU;AAAO,GAoC1FC,IAAsB,KACtBC,KAAe,KAGRC,KAA0B,GAAmB,MAAsB;CAC9E,IAAI,OAAOC,KAAM,YAAY,OAAOC,KAAM,UAAU,OAAOD,IAAIC;CAC/D,IAAMC,IAAK,OAAOF,CAAC,GACbG,IAAK,OAAOF,CAAC;CAEnB,OADIC,MAAOC,IAAW,IACfD,IAAKC,IAAK,KAAK;AACxB,GAEMC,MAAkB,MAAmB;CACzC,IAAI;EACF,OAAO,KAAK,UAAUC,CAAK,KAAK;CAClC,QAAQ;EACN,OAAO,OAAOA,CAAK;CACrB;AACF;AAQA,SAAgBC,EAAkB,GAAmC;CACnE,IAAMC,IAAMC,EAAQ,OAAO,GACrBC,IAAgBD,EAAQ,iBAAiB,KACzCE,IAAaF,EAAQ,cAAc,MACnCG,IAAUH,EAAQ,WAAW,SAC7BI,IAAa,KAAK,IAAIJ,EAAQ,cAAcD,IAAM,GAAGA,IAAM,CAAC,GAC5DM,UAAwBC,EAAQN,EAAQ,QAAQ,KAAK,IAErDO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U;EACf,IAAI;GACF,MAAM/B,EAAQ,OAAO;EACvB,UAAU;GAIR,AAHA,IAAe,KAAA,GAGXqB,MAAegD,MACjBf,EAAiB,GACjBF,EAAe;EAEnB;CACF;CAkCA,OArBAkB,QACQhE,EAAQN,EAAQ,QAAQ,SACxB;EACJ,AAAI,CAACmC,KAAYrB,MAAa,KAAA,KAAWwC,EAAiB;CAC5D,CACF,GAEAgB,EAAMlC,IAAa,MAAU;EAC3B,AAAID,KAAYrB,MAAa,KAAA,MACzBI,MAAU,aAAa,CAACP,EAAS,SAAS,KAAK,IAAI,IAAIc,IAAcpC,KACvEmE,EAAc,GAEhBF,EAAiB;CACnB,CAAC,GAEDiB,QAAqB;EAGnB,AAFA,IAAW,IACXzB,EAAW,GACXC,EAAY;CACd,CAAC,GAEM;EACL,OAAOyB,EAASjE,CAAK;EACrB;EACA;EACA,QAAQiE,EAAS/D,CAAM;EAEvB,SAAS+D,EAAS9D,CAAO;EAEzB,UAAU8D,EAASzD,CAAa;EAChC;EACA;EACA;EACA;EACA,cAxCA,MAAaqD,GAAc,CAAC,CAAC,cAAc;GACzC,IAAW,KAAA;EACb,CAAC,GACMlC;CAsCT;AACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LiveListingKey } from './useLiveListing';
|
|
2
|
+
export interface UseSeenRecordsOptions<T> {
|
|
3
|
+
/** localStorage key, one per list. */
|
|
4
|
+
storageKey: string;
|
|
5
|
+
/** An autoincrement id, or a UTC datetime string in one format. */
|
|
6
|
+
key: (item: T) => LiveListingKey;
|
|
7
|
+
/** How long a record stays seen after the user saw it. Default 7 days. */
|
|
8
|
+
ttlMs?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Records the user has seen, kept in the browser. On the first visit everything the list shows counts as seen,
|
|
12
|
+
* so only what comes later stands out.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useSeenRecords<T>(options: UseSeenRecordsOptions<T>): {
|
|
15
|
+
initialize: (items: T[]) => void;
|
|
16
|
+
isSeen: (item: T) => boolean;
|
|
17
|
+
markSeen: (item: T | T[]) => void;
|
|
18
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { compareLiveListingKeys as e } from "./useLiveListing.js";
|
|
2
|
+
import { shallowRef as t } from "vue";
|
|
3
|
+
import { useEventListener as n } from "@vueuse/core";
|
|
4
|
+
// src/domains/filters/datatable/composables/useSeenRecords.ts
|
|
5
|
+
var r = 864e5;
|
|
6
|
+
function i(i) {
|
|
7
|
+
let a = i.ttlMs ?? 7 * r, o = () => ({
|
|
8
|
+
upTo: null,
|
|
9
|
+
seen: {}
|
|
10
|
+
}), s = () => {
|
|
11
|
+
try {
|
|
12
|
+
let e = localStorage.getItem(i.storageKey);
|
|
13
|
+
if (!e) return o();
|
|
14
|
+
let t = JSON.parse(e);
|
|
15
|
+
return {
|
|
16
|
+
upTo: typeof t?.upTo == "number" || typeof t?.upTo == "string" ? t.upTo : null,
|
|
17
|
+
seen: t?.seen && typeof t.seen == "object" ? t.seen : {}
|
|
18
|
+
};
|
|
19
|
+
} catch {
|
|
20
|
+
return o();
|
|
21
|
+
}
|
|
22
|
+
}, c = Date.now(), l = s(), u = Object.entries(l.seen).filter(([, e]) => c - e < a), d = t({
|
|
23
|
+
...l,
|
|
24
|
+
seen: Object.fromEntries(u)
|
|
25
|
+
}), f = (e) => {
|
|
26
|
+
d.value = e;
|
|
27
|
+
try {
|
|
28
|
+
localStorage.setItem(i.storageKey, JSON.stringify(e));
|
|
29
|
+
} catch {}
|
|
30
|
+
};
|
|
31
|
+
n(window, "storage", (e) => {
|
|
32
|
+
e.key === i.storageKey && (d.value = s());
|
|
33
|
+
}), u.length !== Object.keys(l.seen).length && f({
|
|
34
|
+
...l,
|
|
35
|
+
seen: Object.fromEntries(u)
|
|
36
|
+
});
|
|
37
|
+
let p = (t) => {
|
|
38
|
+
let n = t[0];
|
|
39
|
+
if (d.value.upTo !== null || n === void 0) return;
|
|
40
|
+
let r = t.reduce((t, n) => {
|
|
41
|
+
let r = i.key(n);
|
|
42
|
+
return e(r, t) > 0 ? r : t;
|
|
43
|
+
}, i.key(n));
|
|
44
|
+
f({
|
|
45
|
+
...d.value,
|
|
46
|
+
upTo: r
|
|
47
|
+
});
|
|
48
|
+
}, m = (t) => {
|
|
49
|
+
let n = i.key(t), r = d.value.upTo;
|
|
50
|
+
return r !== null && e(n, r) <= 0 || String(n) in d.value.seen;
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
initialize: p,
|
|
54
|
+
isSeen: m,
|
|
55
|
+
markSeen: (e) => {
|
|
56
|
+
let t = (Array.isArray(e) ? e : [e]).filter((e) => !m(e));
|
|
57
|
+
if (t.length === 0) return;
|
|
58
|
+
let n = Date.now(), r = { ...d.value.seen };
|
|
59
|
+
for (let e of t) r[String(i.key(e))] = n;
|
|
60
|
+
f({
|
|
61
|
+
...d.value,
|
|
62
|
+
seen: r
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export { i as useSeenRecords };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=useSeenRecords.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSeenRecords.js","names":["DAY_MS","useSeenRecords","ttlMs","options","empty","read","raw","parsed","now","stored","kept","at","state","shallowRef","write","next","useEventListener","event","initialize","first","items","newest","key","item","compareLiveListingKeys","max","isSeen","upTo","fresh","one","seen"],"sources":["../../../../../src/domains/filters/datatable/composables/useSeenRecords.ts"],"sourcesContent":["import { useEventListener } from '@vueuse/core'\nimport { shallowRef } from 'vue'\nimport { compareLiveListingKeys, type LiveListingKey } from '@/domains/filters/datatable/composables/useLiveListing'\n\nexport interface UseSeenRecordsOptions<T> {\n /** localStorage key, one per list. */\n storageKey: string\n /** An autoincrement id, or a UTC datetime string in one format. */\n key: (item: T) => LiveListingKey\n /** How long a record stays seen after the user saw it. Default 7 days. */\n ttlMs?: number\n}\n\ninterface SeenRecordsState {\n /** Everything up to this key was in the list when the user came the first time; `null` before that. */\n upTo: LiveListingKey | null\n /** Records seen since, by key, with the time they were seen. */\n seen: Record<string, number>\n}\n\nconst DAY_MS = 24 * 60 * 60 * 1000\n\n/**\n * Records the user has seen, kept in the browser. On the first visit everything the list shows counts as seen,\n * so only what comes later stands out.\n */\nexport function useSeenRecords<T>(options: UseSeenRecordsOptions<T>) {\n const ttlMs = options.ttlMs ?? 7 * DAY_MS\n const empty = (): SeenRecordsState => ({ upTo: null, seen: {} })\n const read = (): SeenRecordsState => {\n try {\n const raw = localStorage.getItem(options.storageKey)\n if (!raw) return empty()\n const parsed = JSON.parse(raw)\n return {\n upTo: typeof parsed?.upTo === 'number' || typeof parsed?.upTo === 'string' ? parsed.upTo : null,\n seen: parsed?.seen && typeof parsed.seen === 'object' ? parsed.seen : {},\n }\n } catch {\n return empty()\n }\n }\n const now = Date.now()\n const stored = read()\n const kept = Object.entries(stored.seen).filter(([, at]) => now - at < ttlMs)\n const state = shallowRef<SeenRecordsState>({ ...stored, seen: Object.fromEntries(kept) })\n // Written at once, without vueuse's useLocalStorage: it skips a second write within one tick, and a click\n // that opens a record may leave the page right after it.\n const write = (next: SeenRecordsState) => {\n state.value = next\n try {\n localStorage.setItem(options.storageKey, JSON.stringify(next))\n } catch {\n // Full or blocked storage: the marks last until the page closes.\n }\n }\n useEventListener(window, 'storage', (event: StorageEvent) => {\n if (event.key === options.storageKey) state.value = read()\n })\n\n if (kept.length !== Object.keys(stored.seen).length) write({ ...stored, seen: Object.fromEntries(kept) })\n\n /** Called with the first list the user sees; on the first visit it marks all of it as seen. */\n const initialize = (items: T[]) => {\n const first = items[0]\n if (state.value.upTo !== null || first === undefined) return\n const newest = items.reduce<LiveListingKey>((max, item) => {\n const key = options.key(item)\n return compareLiveListingKeys(key, max) > 0 ? key : max\n }, options.key(first))\n write({ ...state.value, upTo: newest })\n }\n\n const isSeen = (item: T) => {\n const key = options.key(item)\n const upTo = state.value.upTo\n return (upTo !== null && compareLiveListingKeys(key, upTo) <= 0) || String(key) in state.value.seen\n }\n\n const markSeen = (item: T | T[]) => {\n const items = Array.isArray(item) ? item : [item]\n const fresh = items.filter((one) => !isSeen(one))\n if (fresh.length === 0) return\n const at = Date.now()\n const seen = { ...state.value.seen }\n for (const one of fresh) seen[String(options.key(one))] = at\n write({ ...state.value, seen })\n }\n\n return {\n initialize,\n isSeen,\n markSeen,\n }\n}\n"],"mappings":";;;;AAoBA,IAAMA,IAAS;AAMf,SAAgBC,EAAkB,GAAmC;CACnE,IAAMC,IAAQC,EAAQ,SAAS,IAAIH,GAC7BI,WAAiC;EAAE,MAAM;EAAM,MAAM,CAAC;CAAE,IACxDC,UAA+B;EACnC,IAAI;GACF,IAAMC,IAAM,aAAa,QAAQH,EAAQ,UAAU;GACnD,IAAI,CAACG,GAAK,OAAOF,EAAM;GACvB,IAAMG,IAAS,KAAK,MAAMD,CAAG;GAC7B,OAAO;IACL,MAAM,OAAOC,GAAQ,QAAS,YAAY,OAAOA,GAAQ,QAAS,WAAWA,EAAO,OAAO;IAC3F,MAAMA,GAAQ,QAAQ,OAAOA,EAAO,QAAS,WAAWA,EAAO,OAAO,CAAC;GACzE;EACF,QAAQ;GACN,OAAOH,EAAM;EACf;CACF,GACMI,IAAM,KAAK,IAAI,GACfC,IAASJ,EAAK,GACdK,IAAO,OAAO,QAAQD,EAAO,IAAI,CAAC,CAAC,QAAQ,GAAGE,OAAQH,IAAMG,IAAKT,CAAK,GACtEU,IAAQC,EAA6B;EAAE,GAAGJ;EAAQ,MAAM,OAAO,YAAYC,CAAI;CAAE,CAAC,GAGlFI,KAAS,MAA2B;EACxC,EAAM,QAAQC;EACd,IAAI;GACF,aAAa,QAAQZ,EAAQ,YAAY,KAAK,UAAUY,CAAI,CAAC;EAC/D,QAAQ,CAER;CACF;CAKA,AAJAC,EAAiB,QAAQ,YAAY,MAAwB;EAC3D,AAAIC,EAAM,QAAQd,EAAQ,eAAY,EAAM,QAAQE,EAAK;CAC3D,CAAC,GAEGK,EAAK,WAAW,OAAO,KAAKD,EAAO,IAAI,CAAC,CAAC,UAAQK,EAAM;EAAE,GAAGL;EAAQ,MAAM,OAAO,YAAYC,CAAI;CAAE,CAAC;CAGxG,IAAMQ,KAAc,MAAe;EACjC,IAAMC,IAAQC,EAAM;EACpB,IAAIR,EAAM,MAAM,SAAS,QAAQO,MAAU,KAAA,GAAW;EACtD,IAAME,IAASD,EAAM,QAAwB,GAAK,MAAS;GACzD,IAAME,IAAMnB,EAAQ,IAAIoB,CAAI;GAC5B,OAAOC,EAAuBF,GAAKG,CAAG,IAAI,IAAIH,IAAMG;EACtD,GAAGtB,EAAQ,IAAIgB,CAAK,CAAC;EACrB,EAAM;GAAE,GAAGP,EAAM;GAAO,MAAMS;EAAO,CAAC;CACxC,GAEMK,KAAU,MAAY;EAC1B,IAAMJ,IAAMnB,EAAQ,IAAIoB,CAAI,GACtBI,IAAOf,EAAM,MAAM;EACzB,OAAQe,MAAS,QAAQH,EAAuBF,GAAKK,CAAI,KAAK,KAAM,OAAOL,CAAG,KAAKV,EAAM,MAAM;CACjG;CAYA,OAAO;EACL;EACA;EACA,WAbgB,MAAkB;GAElC,IAAMgB,KADQ,MAAM,QAAQL,CAAI,IAAIA,IAAO,CAACA,CAAI,EAAA,CAC5B,QAAQ,MAAQ,CAACG,EAAOG,CAAG,CAAC;GAChD,IAAID,EAAM,WAAW,GAAG;GACxB,IAAMjB,IAAK,KAAK,IAAI,GACdmB,IAAO,EAAE,GAAGlB,EAAM,MAAM,KAAK;GACnC,KAAK,IAAMiB,KAAOD,GAAO,EAAK,OAAOzB,EAAQ,IAAI0B,CAAG,CAAC,KAAKlB;GAC1D,EAAM;IAAE,GAAGC,EAAM;IAAO;GAAK,CAAC;EAChC;CAMA;AACF"}
|
package/dist/domains/system/appShell/components/AActionbar.vue_vue_type_script_setup_true_lang.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { actionbarSlot as e } from "../composables/teleportSlot.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { registerBrowserTitleBreadcrumbs as t } from "../../composables/browserTitle.js";
|
|
3
|
+
import { isString as n, isUndefined as r } from "../../../../shared/utils/common.js";
|
|
4
|
+
import { Fragment as i, computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as u, createVNode as d, defineComponent as f, normalizeClass as p, onBeforeUnmount as m, openBlock as h, renderList as g, renderSlot as _, resolveDynamicComponent as v, toDisplayString as y, unref as b, watch as x, withCtx as S } from "vue";
|
|
5
|
+
import { useRoute as C } from "vue-router";
|
|
6
|
+
import { VBreadcrumbs as w, VBreadcrumbsDivider as T, VBreadcrumbsItem as E } from "vuetify/components/VBreadcrumbs";
|
|
6
7
|
// src/domains/system/appShell/components/AActionbar.vue?vue&type=script&setup=true&lang.ts
|
|
7
|
-
var
|
|
8
|
+
var D = { class: "flex-grow-1 flex-shrink-1 min-width-0 overflow-hidden" }, O = {
|
|
8
9
|
key: 0,
|
|
9
10
|
class: "d-flex align-center min-width-0"
|
|
10
|
-
},
|
|
11
|
+
}, k = { class: "v-breadcrumbs-item__text" }, A = { class: "flex-grow-0 flex-shrink-0 pl-2" }, j = /*@__PURE__*/ f({
|
|
11
12
|
__name: "AActionbar",
|
|
12
13
|
props: {
|
|
13
14
|
breadcrumbs: { default: void 0 },
|
|
@@ -17,42 +18,46 @@ var w = { class: "flex-grow-1 flex-shrink-1 min-width-0 overflow-hidden" }, T =
|
|
|
17
18
|
},
|
|
18
19
|
target: { default: void 0 }
|
|
19
20
|
},
|
|
20
|
-
setup(
|
|
21
|
-
let
|
|
21
|
+
setup(f) {
|
|
22
|
+
let j = f, M = C(), N = a(() => (j.target ?? e).Source), P;
|
|
23
|
+
x(() => j.target ? void 0 : j.breadcrumbs, (e) => {
|
|
24
|
+
P?.(), P = e ? t(e) : void 0;
|
|
25
|
+
}, { immediate: !0 }), m(() => P?.());
|
|
26
|
+
let F = (e) => {
|
|
22
27
|
let t = { name: e.routeName };
|
|
23
|
-
return
|
|
24
|
-
},
|
|
25
|
-
if (!(
|
|
28
|
+
return r(e.routeParams) ? r(e.id) || (t.params = { id: e.id }) : t.params = { ...e.routeParams }, t;
|
|
29
|
+
}, I = (e, t) => {
|
|
30
|
+
if (!(r(j.breadcrumbs) || !j.breadcrumbs.options.linkLastItem && t === j.breadcrumbs.items.value.length - 1)) return (j.resolveBreadcrumbRoute ?? F)(e);
|
|
26
31
|
};
|
|
27
|
-
return (e,
|
|
28
|
-
default:
|
|
32
|
+
return (e, t) => (h(), o(v(N.value), null, {
|
|
33
|
+
default: S(() => [l("div", D, [_(e.$slots, "breadcrumbs", {}, () => [b(r)(f.breadcrumbs) ? s("", !0) : (h(), c("div", O, [f.breadcrumbs.items.value.length > 0 ? (h(), o(T, {
|
|
29
34
|
key: 0,
|
|
30
35
|
class: "px-1"
|
|
31
36
|
}, {
|
|
32
|
-
default:
|
|
37
|
+
default: S(() => [...t[0] ||= [u(" » ", -1)]]),
|
|
33
38
|
_: 1
|
|
34
|
-
})) :
|
|
35
|
-
key:
|
|
39
|
+
})) : s("", !0), (h(), o(w, {
|
|
40
|
+
key: b(n)(b(M).name) ? b(M).name : b(M).fullPath,
|
|
36
41
|
class: "pl-1 min-width-0",
|
|
37
42
|
density: "compact"
|
|
38
43
|
}, {
|
|
39
|
-
default:
|
|
40
|
-
to:
|
|
44
|
+
default: S(() => [(h(!0), c(i, null, g(f.breadcrumbs.items.value, (e, n) => (h(), c(i, { key: e.routeName }, [d(E, {
|
|
45
|
+
to: I(e, n),
|
|
41
46
|
disabled: !1,
|
|
42
|
-
class:
|
|
47
|
+
class: p({ "min-width-0": n === f.breadcrumbs.items.value.length - 1 })
|
|
43
48
|
}, {
|
|
44
|
-
default:
|
|
49
|
+
default: S(() => [l("div", k, y(e.title), 1)]),
|
|
45
50
|
_: 2
|
|
46
|
-
}, 1032, ["to", "class"]),
|
|
47
|
-
default:
|
|
51
|
+
}, 1032, ["to", "class"]), n < f.breadcrumbs.items.value.length - 1 ? (h(), o(T, { key: 0 }, {
|
|
52
|
+
default: S(() => [...t[1] ||= [u(" » ", -1)]]),
|
|
48
53
|
_: 1
|
|
49
|
-
})) :
|
|
54
|
+
})) : s("", !0)], 64))), 128))]),
|
|
50
55
|
_: 1
|
|
51
|
-
}))]))])]),
|
|
56
|
+
}))]))])]), l("div", A, [_(e.$slots, "buttons")])]),
|
|
52
57
|
_: 3
|
|
53
58
|
}));
|
|
54
59
|
}
|
|
55
60
|
});
|
|
56
|
-
export {
|
|
61
|
+
export { j as default };
|
|
57
62
|
|
|
58
63
|
//# sourceMappingURL=AActionbar.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AActionbar.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_resolveDynamicComponent","_withCtx","_createElementVNode","_renderSlot","_unref","_createElementBlock","_component_VBreadcrumbsDivider","_createTextVNode","_component_VBreadcrumbs","_Fragment","_renderList","_createVNode","_component_VBreadcrumbsItem","_normalizeClass","_toDisplayString","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","AActionbar_vue_vue_type_script_setup_true_lang_default","props","__props","route","useRoute","Source","computed","actionbarSlot","byName","location","item","isUndefined","breadcrumbTo","index","openBlock","createBlock","resolveDynamicComponent","withCtx","createElementVNode","renderSlot","_ctx","unref","createCommentVNode","createElementBlock","VBreadcrumbsDivider","_cache","createTextVNode","VBreadcrumbs","isString","Fragment","renderList","breadcrumb","createVNode","VBreadcrumbsItem","normalizeClass","toDisplayString"],"sources":["../../../../../src/domains/system/appShell/components/AActionbar.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { RouteLocationAsRelativeGeneric, RouteLocationRaw } from 'vue-router'\nimport { useRoute } from 'vue-router'\nimport { computed } from 'vue'\nimport { actionbarSlot, type TeleportSlot } from '@/domains/system/appShell/composables/teleportSlot'\nimport type { BreadcrumbItem, Breadcrumbs } from '@/domains/system/composables/breadcrumbs'\nimport { isString, isUndefined } from '@/shared/utils/common'\n\nconst props = withDefaults(\n defineProps<{\n breadcrumbs?: Breadcrumbs | undefined\n /**\n * Where a breadcrumb links to, for a breadcrumb that links at all (not the last one, unless\n * `linkLastItem`). Default: its route name with `routeParams`, or `{ id }` when it has an id.\n */\n resolveBreadcrumbRoute?: (item: BreadcrumbItem) => RouteLocationRaw\n /** Another teleport slot to render into. Default: the app bar's actionbar. */\n target?: TeleportSlot\n }>(),\n {\n breadcrumbs: undefined,\n resolveBreadcrumbRoute: undefined,\n target: undefined,\n }\n)\n\nconst route = useRoute()\n\nconst Source = computed(() => (props.target ?? actionbarSlot).Source)\n\nconst byName = (item: BreadcrumbItem): RouteLocationRaw => {\n const location: RouteLocationAsRelativeGeneric = { name: item.routeName }\n if (!isUndefined(item.routeParams)) {\n location.params = { ...item.routeParams }\n } else if (!isUndefined(item.id)) {\n location.params = { id: item.id }\n }\n // A breadcrumb's route name is only known at runtime, but RouteLocationRaw is a union keyed on\n // literal names. Names are checked at their definition sites by anzu/valid-route-name.\n return location as RouteLocationRaw\n}\n\nconst breadcrumbTo = (item: BreadcrumbItem, index: number): RouteLocationRaw | undefined => {\n if (\n isUndefined(props.breadcrumbs) ||\n (!props.breadcrumbs.options.linkLastItem && index === props.breadcrumbs.items.value.length - 1)\n ) {\n return undefined\n }\n return (props.resolveBreadcrumbRoute ?? byName)(item)\n}\n</script>\n\n<template>\n <component :is=\"Source\">\n <div class=\"flex-grow-1 flex-shrink-1 min-width-0 overflow-hidden\">\n <slot name=\"breadcrumbs\">\n <div\n v-if=\"!isUndefined(breadcrumbs)\"\n class=\"d-flex align-center min-width-0\"\n >\n <VBreadcrumbsDivider\n v-if=\"breadcrumbs.items.value.length > 0\"\n class=\"px-1\"\n >\n »\n </VBreadcrumbsDivider>\n <VBreadcrumbs\n :key=\"isString(route.name) ? route.name : route.fullPath\"\n class=\"pl-1 min-width-0\"\n density=\"compact\"\n >\n <template\n v-for=\"(breadcrumb, index) in breadcrumbs.items.value\"\n :key=\"breadcrumb.routeName\"\n >\n <VBreadcrumbsItem\n :to=\"breadcrumbTo(breadcrumb, index)\"\n :disabled=\"false\"\n :class=\"{ 'min-width-0': index === breadcrumbs.items.value.length - 1 }\"\n >\n <div class=\"v-breadcrumbs-item__text\">\n {{ breadcrumb.title }}\n </div>\n </VBreadcrumbsItem>\n <VBreadcrumbsDivider v-if=\"index < breadcrumbs.items.value.length - 1\"> » </VBreadcrumbsDivider>\n </template>\n </VBreadcrumbs>\n </div>\n </slot>\n </div>\n <div class=\"flex-grow-0 flex-shrink-0 pl-2\">\n <slot name=\"buttons\" />\n </div>\n </component>\n</template>\n\n<style lang=\"scss\">\n.v-breadcrumbs-item__text {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n</style>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AActionbar.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_resolveDynamicComponent","_withCtx","_createElementVNode","_renderSlot","_unref","_createElementBlock","_component_VBreadcrumbsDivider","_createTextVNode","_component_VBreadcrumbs","_Fragment","_renderList","_createVNode","_component_VBreadcrumbsItem","_normalizeClass","_toDisplayString","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","AActionbar_vue_vue_type_script_setup_true_lang_default","props","__props","route","useRoute","Source","computed","actionbarSlot","unregisterBrowserTitle","watch","breadcrumbs","registerBrowserTitleBreadcrumbs","onBeforeUnmount","byName","location","item","isUndefined","breadcrumbTo","index","openBlock","createBlock","resolveDynamicComponent","withCtx","createElementVNode","renderSlot","_ctx","unref","createCommentVNode","createElementBlock","VBreadcrumbsDivider","_cache","createTextVNode","VBreadcrumbs","isString","Fragment","renderList","breadcrumb","createVNode","VBreadcrumbsItem","normalizeClass","toDisplayString"],"sources":["../../../../../src/domains/system/appShell/components/AActionbar.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { RouteLocationAsRelativeGeneric, RouteLocationRaw } from 'vue-router'\nimport { useRoute } from 'vue-router'\nimport { computed, onBeforeUnmount, watch } from 'vue'\nimport { actionbarSlot, type TeleportSlot } from '@/domains/system/appShell/composables/teleportSlot'\nimport type { BreadcrumbItem, Breadcrumbs } from '@/domains/system/composables/breadcrumbs'\nimport { registerBrowserTitleBreadcrumbs } from '@/domains/system/composables/browserTitle'\nimport { isString, isUndefined } from '@/shared/utils/common'\n\nconst props = withDefaults(\n defineProps<{\n breadcrumbs?: Breadcrumbs | undefined\n /**\n * Where a breadcrumb links to, for a breadcrumb that links at all (not the last one, unless\n * `linkLastItem`). Default: its route name with `routeParams`, or `{ id }` when it has an id.\n */\n resolveBreadcrumbRoute?: (item: BreadcrumbItem) => RouteLocationRaw\n /** Another teleport slot to render into. Default: the app bar's actionbar. */\n target?: TeleportSlot\n }>(),\n {\n breadcrumbs: undefined,\n resolveBreadcrumbRoute: undefined,\n target: undefined,\n }\n)\n\nconst route = useRoute()\n\nconst Source = computed(() => (props.target ?? actionbarSlot).Source)\n\n// Only the app bar's breadcrumbs name the page in the browser tab; another target is a part of the page.\nlet unregisterBrowserTitle: (() => void) | undefined\nwatch(\n () => (props.target ? undefined : props.breadcrumbs),\n (breadcrumbs) => {\n unregisterBrowserTitle?.()\n unregisterBrowserTitle = breadcrumbs ? registerBrowserTitleBreadcrumbs(breadcrumbs) : undefined\n },\n { immediate: true }\n)\nonBeforeUnmount(() => unregisterBrowserTitle?.())\n\nconst byName = (item: BreadcrumbItem): RouteLocationRaw => {\n const location: RouteLocationAsRelativeGeneric = { name: item.routeName }\n if (!isUndefined(item.routeParams)) {\n location.params = { ...item.routeParams }\n } else if (!isUndefined(item.id)) {\n location.params = { id: item.id }\n }\n // A breadcrumb's route name is only known at runtime, but RouteLocationRaw is a union keyed on\n // literal names. Names are checked at their definition sites by anzu/valid-route-name.\n return location as RouteLocationRaw\n}\n\nconst breadcrumbTo = (item: BreadcrumbItem, index: number): RouteLocationRaw | undefined => {\n if (\n isUndefined(props.breadcrumbs) ||\n (!props.breadcrumbs.options.linkLastItem && index === props.breadcrumbs.items.value.length - 1)\n ) {\n return undefined\n }\n return (props.resolveBreadcrumbRoute ?? byName)(item)\n}\n</script>\n\n<template>\n <component :is=\"Source\">\n <div class=\"flex-grow-1 flex-shrink-1 min-width-0 overflow-hidden\">\n <slot name=\"breadcrumbs\">\n <div\n v-if=\"!isUndefined(breadcrumbs)\"\n class=\"d-flex align-center min-width-0\"\n >\n <VBreadcrumbsDivider\n v-if=\"breadcrumbs.items.value.length > 0\"\n class=\"px-1\"\n >\n »\n </VBreadcrumbsDivider>\n <VBreadcrumbs\n :key=\"isString(route.name) ? route.name : route.fullPath\"\n class=\"pl-1 min-width-0\"\n density=\"compact\"\n >\n <template\n v-for=\"(breadcrumb, index) in breadcrumbs.items.value\"\n :key=\"breadcrumb.routeName\"\n >\n <VBreadcrumbsItem\n :to=\"breadcrumbTo(breadcrumb, index)\"\n :disabled=\"false\"\n :class=\"{ 'min-width-0': index === breadcrumbs.items.value.length - 1 }\"\n >\n <div class=\"v-breadcrumbs-item__text\">\n {{ breadcrumb.title }}\n </div>\n </VBreadcrumbsItem>\n <VBreadcrumbsDivider v-if=\"index < breadcrumbs.items.value.length - 1\"> » </VBreadcrumbsDivider>\n </template>\n </VBreadcrumbs>\n </div>\n </slot>\n </div>\n <div class=\"flex-grow-0 flex-shrink-0 pl-2\">\n <slot name=\"buttons\" />\n </div>\n </component>\n</template>\n\n<style lang=\"scss\">\n.v-breadcrumbs-item__text {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EASA,IAAMsB,IAAQC,GAkBRC,IAAQC,EAAS,GAEjBC,IAASC,SAAgBL,EAAM,UAAUM,EAAA,CAAe,MAAM,GAGhEC;EASJ,AARAC,QACSR,EAAM,SAAS,KAAA,IAAYA,EAAM,cACvC,MAAgB;GAEf,AADAO,IAAyB,GACz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,EAcWI,GAAA,MAAAC,EAbqBW,EAAA,YAAY,MAAM,QAAxC,GAAY,O,YACd,KAAAkC,EAAW,U,IAEjB5C,EAQmBC,GAAA;KAPhB,IAAIwB,EAAamB,GAAYlB,CAAK;KAClC,UAAU;KACV,OAAKxB,EAAA,EAAA,eAAmBwB,MAAUhB,EAAA,YAAY,MAAM,MAAM,SAAM,EAAA,CAAA;;KAEjE,SAAApB,QAEM,CAFNC,EAEM,OAFNe,GAEMH,EADDyC,EAAW,KAAK,GAAA,CAAA,C;;I,2BAGIlB,IAAQhB,EAAA,YAAY,MAAM,MAAM,SAAM,KAAjEvB,EAAA,GAAAC,EAAsGO,GAAA,EAAA,KAAA,EAAA,GAAA;KAA/B,SAAAL,QAAS,CAAA,GAAA,AAAAgD,EAAA,OAAA,CAAT1C,EAAA,OAAS,EAAA,C;;;;G,YAM1FL,EAEM,OAFNgB,GAEM,CADJf,EAAuByC,EAAA,QAAA,SAAA,C"}
|
|
@@ -12,6 +12,11 @@ export interface Breadcrumbs {
|
|
|
12
12
|
}
|
|
13
13
|
export interface BreadcrumbOptions {
|
|
14
14
|
linkLastItem: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* What names the page in the browser tab: an item index (negative from the end), its own text, or a getter.
|
|
17
|
+
* Default: the item `useBrowserTitle` is configured with, the last one unless set otherwise.
|
|
18
|
+
*/
|
|
19
|
+
browserTitle?: number | string | (() => string);
|
|
15
20
|
}
|
|
16
21
|
export declare const defaultOptions: BreadcrumbOptions;
|
|
17
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breadcrumbs.js","names":["defaultOptions","defineBreadcrumbs","items","computed","options"],"sources":["../../../../src/domains/system/composables/breadcrumbs.ts"],"sourcesContent":["import { computed, type ComputedRef } from 'vue'\nimport type { DocId, IntegerId } from '@/shared/types/common'\n\nexport interface BreadcrumbItem {\n title: string\n routeName: string\n id?: IntegerId | DocId\n routeParams?: any\n}\n\nexport interface Breadcrumbs {\n items: ComputedRef<Array<BreadcrumbItem>>\n options: BreadcrumbOptions\n}\n\nexport interface BreadcrumbOptions {\n linkLastItem: boolean\n}\n\nexport const defaultOptions: BreadcrumbOptions = {\n linkLastItem: false,\n}\n\n/**\n * Breadcrumbs of a page for `AActionbar`. A getter `items` is wrapped\n * in a `computed`, so it is read only when the actionbar renders.\n * An existing `ComputedRef` is kept as it is.\n */\nexport function defineBreadcrumbs(\n items: (() => Array<BreadcrumbItem>) | ComputedRef<Array<BreadcrumbItem>>,\n options: Partial<BreadcrumbOptions> = {}\n): Breadcrumbs {\n return {\n items: typeof items === 'function' ? computed(items) : items,\n options: {\n ...defaultOptions,\n ...options,\n },\n }\n}\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"breadcrumbs.js","names":["defaultOptions","defineBreadcrumbs","items","computed","options"],"sources":["../../../../src/domains/system/composables/breadcrumbs.ts"],"sourcesContent":["import { computed, type ComputedRef } from 'vue'\nimport type { DocId, IntegerId } from '@/shared/types/common'\n\nexport interface BreadcrumbItem {\n title: string\n routeName: string\n id?: IntegerId | DocId\n routeParams?: any\n}\n\nexport interface Breadcrumbs {\n items: ComputedRef<Array<BreadcrumbItem>>\n options: BreadcrumbOptions\n}\n\nexport interface BreadcrumbOptions {\n linkLastItem: boolean\n /**\n * What names the page in the browser tab: an item index (negative from the end), its own text, or a getter.\n * Default: the item `useBrowserTitle` is configured with, the last one unless set otherwise.\n */\n browserTitle?: number | string | (() => string)\n}\n\nexport const defaultOptions: BreadcrumbOptions = {\n linkLastItem: false,\n}\n\n/**\n * Breadcrumbs of a page for `AActionbar`. A getter `items` is wrapped\n * in a `computed`, so it is read only when the actionbar renders.\n * An existing `ComputedRef` is kept as it is.\n */\nexport function defineBreadcrumbs(\n items: (() => Array<BreadcrumbItem>) | ComputedRef<Array<BreadcrumbItem>>,\n options: Partial<BreadcrumbOptions> = {}\n): Breadcrumbs {\n return {\n items: typeof items === 'function' ? computed(items) : items,\n options: {\n ...defaultOptions,\n ...options,\n },\n }\n}\n"],"mappings":";;AAwBA,IAAaA,IAAoC,EAC/C,cAAc,GAChB;AAOA,SAAgBC,EACd,GACA,IAAsC,CAAC,GAC1B;CACb,OAAO;EACL,OAAO,OAAOC,KAAU,aAAaC,EAASD,CAAK,IAAIA;EACvD,SAAS;GACP,GAAGF;GACH,GAAGI;EACL;CACF;AACF"}
|