@antcde/vue-utils 0.2.14-rc.6a3e1ae → 0.2.14-rc.77e4e54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +47 -47
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { objectOmit as e, objectPick as t, useAsyncState as n, useColorMode as r, useMagicKeys as i, watchDebounced as a, whenever as o } from "@vueuse/core";
|
|
2
2
|
import { computed as s, inject as c, onBeforeUnmount as l, onMounted as u, onUnmounted as d, readonly as f, ref as p, shallowRef as m, watch as h } from "vue";
|
|
3
3
|
import { useI18n as g } from "vue-i18n";
|
|
4
|
-
import {
|
|
5
|
-
import { BehaviorSubject as
|
|
4
|
+
import { clone as _, newCommsClient as v, newCommsHost as y } from "@antcde/connect-ts";
|
|
5
|
+
import { BehaviorSubject as b, Subject as x, concat as S, concatMap as C, debounceTime as w, distinctUntilChanged as T, filter as E, map as D } from "rxjs";
|
|
6
6
|
//#region src/formatDate.ts
|
|
7
|
-
var
|
|
7
|
+
var O = "nl", k = {
|
|
8
8
|
short: {
|
|
9
9
|
day: "2-digit",
|
|
10
10
|
month: "2-digit",
|
|
@@ -40,25 +40,25 @@ var D = "nl", O = {
|
|
|
40
40
|
minute: "2-digit",
|
|
41
41
|
hour12: !1
|
|
42
42
|
}
|
|
43
|
-
},
|
|
44
|
-
function
|
|
43
|
+
}, A = new Set(["short", "shortDateTime"]);
|
|
44
|
+
function j(e) {
|
|
45
45
|
return e instanceof Date ? e : new Date(e);
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function M(e) {
|
|
48
48
|
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
let { preset: n = "short", locale: r =
|
|
50
|
+
function N(e, t = {}) {
|
|
51
|
+
let { preset: n = "short", locale: r = O, fallback: i = "" } = t;
|
|
52
52
|
if (e == null || e === "") return i;
|
|
53
|
-
let a =
|
|
53
|
+
let a = j(e);
|
|
54
54
|
if (Number.isNaN(a.getTime())) return i;
|
|
55
|
-
if (n === "iso") return
|
|
56
|
-
let o =
|
|
57
|
-
return new Intl.DateTimeFormat(o,
|
|
55
|
+
if (n === "iso") return M(a);
|
|
56
|
+
let o = A.has(n) && /^en\b/i.test(r) ? O : r;
|
|
57
|
+
return new Intl.DateTimeFormat(o, k[n]).format(a);
|
|
58
58
|
}
|
|
59
59
|
//#endregion
|
|
60
60
|
//#region src/useAntColorMode.ts
|
|
61
|
-
function
|
|
61
|
+
function P(e, n) {
|
|
62
62
|
let i = r(n), a = s(() => e.context.value.darkMode), o = s(() => {
|
|
63
63
|
switch (a.value) {
|
|
64
64
|
case null: return "auto";
|
|
@@ -84,28 +84,28 @@ function N(e, n) {
|
|
|
84
84
|
}
|
|
85
85
|
//#endregion
|
|
86
86
|
//#region src/useAntI18n.ts
|
|
87
|
-
function
|
|
87
|
+
function F(e, t) {
|
|
88
88
|
let n = g(t);
|
|
89
89
|
return h(() => e.context.value.user?.language, (e) => n.locale.value = e ?? "en", { immediate: !0 }), n;
|
|
90
90
|
}
|
|
91
91
|
//#endregion
|
|
92
92
|
//#region src/useAppTourMode.ts
|
|
93
|
-
var
|
|
94
|
-
function
|
|
93
|
+
var I = p(!1), L = p(null);
|
|
94
|
+
function R() {
|
|
95
95
|
function e(e) {
|
|
96
96
|
h(() => e.value.tourMode, (e) => {
|
|
97
|
-
|
|
97
|
+
I.value = !!e, e || (L.value = null);
|
|
98
98
|
}, { immediate: !0 });
|
|
99
99
|
}
|
|
100
100
|
function t(e) {
|
|
101
|
-
|
|
101
|
+
I.value && (L.value = e);
|
|
102
102
|
}
|
|
103
103
|
function n() {
|
|
104
|
-
|
|
104
|
+
I.value = !1, L.value = null;
|
|
105
105
|
}
|
|
106
106
|
return {
|
|
107
|
-
isActive: f(
|
|
108
|
-
activeZoneId: f(
|
|
107
|
+
isActive: f(I),
|
|
108
|
+
activeZoneId: f(L),
|
|
109
109
|
connectContext: e,
|
|
110
110
|
setActiveZone: t,
|
|
111
111
|
exit: n
|
|
@@ -113,8 +113,8 @@ function L() {
|
|
|
113
113
|
}
|
|
114
114
|
//#endregion
|
|
115
115
|
//#region src/useCommsClient.ts
|
|
116
|
-
function
|
|
117
|
-
let i = p({}), a =
|
|
116
|
+
function z(t, n, r) {
|
|
117
|
+
let i = p({}), a = v({
|
|
118
118
|
parent: window.parent,
|
|
119
119
|
connect: t,
|
|
120
120
|
manifest: r
|
|
@@ -122,17 +122,17 @@ function R(t, n, r) {
|
|
|
122
122
|
get: () => o.value,
|
|
123
123
|
set: (e) => a.appState.set(e)
|
|
124
124
|
});
|
|
125
|
-
return a.context.subscribe((e) => i.value = e),
|
|
125
|
+
return a.context.subscribe((e) => i.value = e), S(a.appState.get(), a.appState).subscribe((e) => o.value = e), V(a.signal, a, n), l(() => a.unsubscribe()), Object.assign(e(a, [
|
|
126
126
|
"context",
|
|
127
127
|
"toolbar",
|
|
128
128
|
"appState"
|
|
129
129
|
]), {
|
|
130
130
|
context: i,
|
|
131
|
-
toolbar:
|
|
131
|
+
toolbar: B(a),
|
|
132
132
|
appState: c
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function B(e) {
|
|
136
136
|
let t = p(""), n = {
|
|
137
137
|
title: s({
|
|
138
138
|
get: () => e.toolbar.get().title,
|
|
@@ -183,23 +183,23 @@ function z(e) {
|
|
|
183
183
|
}))
|
|
184
184
|
})
|
|
185
185
|
};
|
|
186
|
-
return e.toolbar.pipe(
|
|
186
|
+
return e.toolbar.pipe(D((e) => e.search.input ?? ""), T(), w(300)).forEach((e) => t.value = e), n;
|
|
187
187
|
}
|
|
188
|
-
function
|
|
189
|
-
let r = i(), a = r.ctrl ?? s(() => !1), c = r.shift ?? s(() => !1), l = new
|
|
188
|
+
function V(e, t, n) {
|
|
189
|
+
let r = i(), a = r.ctrl ?? s(() => !1), c = r.shift ?? s(() => !1), l = new x(), u = l.pipe(C(n ?? ((e) => Promise.resolve(e))), C((t) => e(t))).subscribe();
|
|
190
190
|
return t.add(u), u.add(o(a, () => l.next({ hotkeys: { ctrl: !0 } }))), u.add(o(c, () => l.next({ hotkeys: { shift: !0 } }))), u;
|
|
191
191
|
}
|
|
192
192
|
//#endregion
|
|
193
193
|
//#region src/useCommsHost.ts
|
|
194
|
-
function
|
|
195
|
-
let { context: t } = e, n = new
|
|
194
|
+
function H(e) {
|
|
195
|
+
let { context: t } = e, n = new b({}), r = (e) => n.next(e(n.value)), i = p(), o = new b(void 0), c = h(i, (e) => o.next(e), { immediate: !0 }), l = o.asObservable().pipe(D((e) => e?.contentWindow), E((e) => !!e)), u = y({
|
|
196
196
|
...e,
|
|
197
197
|
contextChanges: n,
|
|
198
198
|
windowChanges: l
|
|
199
199
|
});
|
|
200
200
|
Object.entries(t).map(([e, t]) => h(t, (t) => r((n) => ({
|
|
201
201
|
...n,
|
|
202
|
-
[e]: t
|
|
202
|
+
[e]: _(t)
|
|
203
203
|
})), { immediate: !0 })).forEach((e) => u.scope.add(e)), u.toolbar.subscribe((t) => {
|
|
204
204
|
let n = e.toolbar;
|
|
205
205
|
n.title.value = t.title, n.subtitle.value = t.subtitle, n.searchEnabled.value = t.search?.enabled ?? !1, n.search.value = t.search?.input, n.menu.value = t.menu, n.isLoading.value = t?.isLoading ?? !1;
|
|
@@ -216,23 +216,23 @@ function V(e) {
|
|
|
216
216
|
u.appState.changes.subscribe((e) => f.value = e);
|
|
217
217
|
let g = p(!1);
|
|
218
218
|
u.isConnectionInitialized.subscribe((e) => g.value = e);
|
|
219
|
-
let
|
|
220
|
-
u.manifest?.subscribe((e) =>
|
|
221
|
-
let { unsubscribe:
|
|
219
|
+
let v = p(null);
|
|
220
|
+
u.manifest?.subscribe((e) => v.value = e);
|
|
221
|
+
let { unsubscribe: x, signal: S, closed: C } = u;
|
|
222
222
|
return {
|
|
223
223
|
...e,
|
|
224
224
|
client: i,
|
|
225
225
|
appState: m,
|
|
226
226
|
isConnectionInitialized: g,
|
|
227
|
-
manifest:
|
|
228
|
-
unsubscribe:
|
|
229
|
-
signal:
|
|
230
|
-
closed:
|
|
227
|
+
manifest: v,
|
|
228
|
+
unsubscribe: x,
|
|
229
|
+
signal: S,
|
|
230
|
+
closed: C
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
233
|
//#endregion
|
|
234
234
|
//#region src/usePermissions.ts
|
|
235
|
-
function
|
|
235
|
+
function U(e) {
|
|
236
236
|
let t = s(() => e.value?.user), n = s(() => e.value?.license), r = s(() => e.value?.project), i = s(() => !!t.value?.is_admin), a = s(() => !!n.value?.user_is_admin), o = s(() => !!r.value?.user_is_admin || a.value);
|
|
237
237
|
function c(e) {
|
|
238
238
|
return !t.value || !n.value ? !1 : i.value || a.value ? !0 : (n.value.user_roles ?? []).some((t) => t.name === e);
|
|
@@ -258,7 +258,7 @@ function H(e) {
|
|
|
258
258
|
}
|
|
259
259
|
//#endregion
|
|
260
260
|
//#region src/useTemplateVersioning.ts
|
|
261
|
-
function
|
|
261
|
+
function W(e) {
|
|
262
262
|
let t = m(null), n = m(null), r = m(null), i = m(null), a = m([]), o = m(null), c = p(!1), l = p(!1), u = p(!1), d = p(!1), f = p(!1), h = p(!1), g = s(() => t.value?.has_update ?? !1), _ = s(() => t.value?.current_version ?? null), v = s(() => t.value?.latest_version ?? null), y = s(() => n.value ? n.value.added.length + n.value.removed.length + n.value.modified.length + n.value.relations_added.length + n.value.relations_removed.length : 0);
|
|
263
263
|
async function b(n) {
|
|
264
264
|
c.value = !0;
|
|
@@ -398,18 +398,18 @@ function U(e) {
|
|
|
398
398
|
}
|
|
399
399
|
//#endregion
|
|
400
400
|
//#region src/utils.ts
|
|
401
|
-
function
|
|
402
|
-
let [t, n] =
|
|
401
|
+
function G(e = "comms") {
|
|
402
|
+
let [t, n] = K(e, () => z(), (e) => e.unsubscribe());
|
|
403
403
|
return {
|
|
404
404
|
provideComms: t,
|
|
405
405
|
injectComms: n
|
|
406
406
|
};
|
|
407
407
|
}
|
|
408
|
-
function
|
|
408
|
+
function K(e, t, n) {
|
|
409
409
|
let r, i = () => (!r && (r = t()), r);
|
|
410
410
|
return [(t) => (t.onUnmount(() => n && r && n(r)), t.provide(e, i)), () => c(e)()];
|
|
411
411
|
}
|
|
412
|
-
function
|
|
412
|
+
function q(t, r, i) {
|
|
413
413
|
let a = n(t, r, {
|
|
414
414
|
immediate: !1,
|
|
415
415
|
...i
|
|
@@ -419,9 +419,9 @@ function K(t, r, i) {
|
|
|
419
419
|
executeDelayed: a.execute
|
|
420
420
|
});
|
|
421
421
|
}
|
|
422
|
-
function
|
|
422
|
+
function J(e) {
|
|
423
423
|
let t, n = p(void 0);
|
|
424
424
|
return u(() => t = e.signal.receive((e) => n.value = e)), d(() => t?.()), [f(n), () => t?.()];
|
|
425
425
|
}
|
|
426
426
|
//#endregion
|
|
427
|
-
export {
|
|
427
|
+
export { N as formatDate, P as useAntColorMode, F as useAntI18n, q as useApi, R as useAppTourMode, z as useCommsClient, H as useCommsHost, G as useCommsInjection, U as usePermissions, J as useSignal, K as useSingleton, W as useTemplateVersioning };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antcde/vue-utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.14-rc.
|
|
4
|
+
"version": "0.2.14-rc.77e4e54",
|
|
5
5
|
"description": "Helper to use ANT Comms in Vue 3",
|
|
6
6
|
"author": "CollaborAll",
|
|
7
7
|
"exports": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"vue-i18n": "^11.1.12"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@antcde/connect-ts": "0.4.18-rc.
|
|
34
|
+
"@antcde/connect-ts": "0.4.18-rc.77e4e54"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@tsconfig/node22": "^22.0.5",
|