@antcde/vue-utils 0.2.13 → 0.2.14-rc.09815b8

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 CHANGED
@@ -1,182 +1,427 @@
1
- import { useColorMode as P, objectPick as L, objectOmit as C, useMagicKeys as M, whenever as g, watchDebounced as O, useAsyncState as I } from "@vueuse/core";
2
- import { computed as u, watch as h, ref as d, onBeforeUnmount as E, onMounted as U, onUnmounted as D, readonly as H, inject as W } from "vue";
3
- import { useI18n as z } from "vue-i18n";
4
- import { newCommsClient as B, newCommsHost as K } from "@antcde/connect-ts";
5
- import { concat as R, Subject as T, concatMap as S, map as w, distinctUntilChanged as G, debounceTime as V, BehaviorSubject as j, filter as q } from "rxjs";
6
- function te(t, o) {
7
- const n = P(o), e = u(() => t.context.value.darkMode), s = u(() => {
8
- switch (e.value) {
9
- case null:
10
- return "auto";
11
- case !0:
12
- return "dark";
13
- case !1:
14
- return "light";
15
- default:
16
- return n.value;
17
- }
18
- }), r = u(() => {
19
- switch (s.value) {
20
- case "light":
21
- case "auto":
22
- return !1;
23
- case "dark":
24
- return !0;
25
- }
26
- });
27
- return Object.assign(
28
- s,
29
- { host: e, isDark: r },
30
- L(n, ["state", "system", "store"])
31
- );
32
- }
33
- function se(t, o) {
34
- const n = z(o);
35
- return h(
36
- () => t.context.value.user?.language,
37
- (e) => n.locale.value = e ?? "en",
38
- { immediate: !0 }
39
- ), n;
40
- }
41
- function F(t, o) {
42
- const n = d({}), e = B({ parent: window.parent, connect: t }), s = d(""), r = u({
43
- get: () => s.value,
44
- set: (i) => e.appState.set(i)
45
- });
46
- return e.context.subscribe((i) => n.value = i), R(e.appState.get(), e.appState).subscribe((i) => s.value = i), N(e.signal, e, o), E(() => e.unsubscribe()), Object.assign(
47
- C(e, ["context", "toolbar", "appState"]),
48
- {
49
- context: n,
50
- toolbar: J(e),
51
- appState: r
52
- }
53
- );
54
- }
55
- function J(t) {
56
- const o = d(""), n = {
57
- title: u({
58
- get: () => t.toolbar.get().title,
59
- set: (e) => t.toolbar.set((s) => ({ ...s, title: e }))
60
- }),
61
- subtitle: u({
62
- get: () => t.toolbar.get().subtitle,
63
- set: (e) => t.toolbar.set((s) => ({ ...s, subtitle: e }))
64
- }),
65
- searchEnabled: u({
66
- get: () => t.toolbar.get().search.enabled,
67
- set: (e) => t.toolbar.set((s) => ({ ...s, search: { ...s.search, enabled: e } }))
68
- }),
69
- search: u({
70
- get: () => o.value,
71
- set: (e) => t.toolbar.set((s) => ({ ...s, search: { ...s.search, input: e } }))
72
- }),
73
- menu: u({
74
- get: () => t.toolbar.get().menu ?? [],
75
- set: (e) => t.toolbar.set((s) => ({ ...s, menu: e }))
76
- }),
77
- isLoading: u({
78
- get: () => t.toolbar.get().isLoading,
79
- set: (e) => t.toolbar.set((s) => ({ ...s, isLoading: e }))
80
- })
81
- };
82
- return t.toolbar.pipe(w((e) => e.search.input ?? ""), G(), V(300)).forEach((e) => o.value = e), n;
83
- }
84
- function N(t, o, n) {
85
- const e = M(), s = e.ctrl ?? u(() => !1), r = e.shift ?? u(() => !1), i = new T(), m = i.pipe(
86
- S(n ?? ((c) => Promise.resolve(c))),
87
- S((c) => t(c))
88
- ).subscribe();
89
- return o.add(m), m.add(g(s, () => i.next({ hotkeys: { ctrl: !0 } }))), m.add(g(r, () => i.next({ hotkeys: { shift: !0 } }))), m;
90
- }
91
- function ne(t) {
92
- const { context: o } = t, n = new j({}), e = (a) => n.next(a(n.value)), s = d(), r = new j(void 0), i = h(s, (a) => r.next(a), { immediate: !0 }), m = r.asObservable().pipe(
93
- w((a) => a?.contentWindow),
94
- q((a) => !!a)
95
- ), c = K({ ...t, contextChanges: n, windowChanges: m });
96
- Object.entries(o).map(([a, b]) => h(
97
- b,
98
- (A) => e((k) => ({ ...k, [a]: A })),
99
- { immediate: !0 }
100
- )).forEach((a) => c.scope.add(a)), c.toolbar.subscribe((a) => {
101
- const b = t.toolbar;
102
- b.title.value = a.title, b.subtitle.value = a.subtitle, b.searchEnabled.value = a.search?.enabled ?? !1, b.search.value = a.search?.input, b.menu.value = a.menu, b.isLoading.value = a?.isLoading ?? !1;
103
- });
104
- const f = O(
105
- t.toolbar.search,
106
- (a) => c.toolbar.set.search(a),
107
- { immediate: !0, debounce: 100 }
108
- );
109
- c.scope.add(i), c.scope.add(f);
110
- const p = d(c.appState.get()), l = u({
111
- get: () => p.value,
112
- set: (a) => c.appState.set(a)
113
- });
114
- c.appState.changes.subscribe((a) => p.value = a);
115
- const v = d(!1);
116
- c.isConnectionInitialized.subscribe((a) => v.value = a);
117
- const { unsubscribe: x, signal: y, closed: _ } = c;
118
- return {
119
- ...t,
120
- client: s,
121
- appState: l,
122
- isConnectionInitialized: v,
123
- unsubscribe: x,
124
- signal: y,
125
- closed: _
126
- };
127
- }
128
- function oe(t) {
129
- const o = u(() => t.value?.user), n = u(() => t.value?.license), e = u(() => t.value?.project), s = u(() => !!o.value?.is_admin), r = u(() => !!n.value?.user_is_admin), i = u(() => !!e.value?.user_is_admin);
130
- function m(l) {
131
- return !o.value || !n.value ? !1 : s.value || r.value ? !0 : (n.value.user_roles ?? []).some((v) => v.name === l);
132
- }
133
- function c(l) {
134
- return !o.value || !n.value ? !1 : s.value || r.value ? !0 : !!n.value.user_permissions?.[String(l)];
135
- }
136
- function f(l) {
137
- return !o.value || !e.value ? !1 : s.value || r.value || i.value ? !0 : (e.value.user_roles ?? []).some((v) => v.name === l);
138
- }
139
- function p(l) {
140
- return !o.value || !e.value ? !1 : s.value || r.value ? !0 : !!e.value.user_permissions?.[String(l)];
141
- }
142
- return { isGlobalAdmin: s, isLicenseAdmin: r, isProjectAdmin: i, hasLicenseRole: m, hasLicensePermission: c, hasProjectRole: f, hasProjectPermission: p };
143
- }
144
- function ae(t = "comms") {
145
- const [o, n] = Q(
146
- t,
147
- () => F(),
148
- (e) => e.unsubscribe()
149
- );
150
- return { provideComms: o, injectComms: n };
151
- }
152
- function Q(t, o, n) {
153
- let e;
154
- const s = () => (!e && (e = o()), e);
155
- return [
156
- (r) => (r.onUnmount(() => n && e && n(e)), r.provide(t, s)),
157
- () => W(t)()
158
- ];
159
- }
160
- function re(t, o, n) {
161
- const s = I(t, o, { immediate: !1, ...n });
162
- return Object.assign(C(s, ["execute"]), {
163
- execute: (...r) => s.execute(void 0, ...r),
164
- executeDelayed: s.execute
165
- });
166
- }
167
- function ue(t) {
168
- let o;
169
- const n = d(void 0);
170
- return U(() => o = t.signal.receive((e) => n.value = e)), D(() => o?.()), [H(n), () => o?.()];
171
- }
172
- export {
173
- te as useAntColorMode,
174
- se as useAntI18n,
175
- re as useApi,
176
- F as useCommsClient,
177
- ne as useCommsHost,
178
- ae as useCommsInjection,
179
- oe as usePermissions,
180
- ue as useSignal,
181
- Q as useSingleton
182
- };
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
+ 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
+ import { useI18n as g } from "vue-i18n";
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
+ //#region src/formatDate.ts
7
+ var O = "nl", k = {
8
+ short: {
9
+ day: "2-digit",
10
+ month: "2-digit",
11
+ year: "numeric"
12
+ },
13
+ medium: {
14
+ day: "numeric",
15
+ month: "short",
16
+ year: "numeric"
17
+ },
18
+ long: {
19
+ day: "numeric",
20
+ month: "long",
21
+ year: "numeric"
22
+ },
23
+ monthDay: {
24
+ day: "numeric",
25
+ month: "short"
26
+ },
27
+ shortDateTime: {
28
+ day: "2-digit",
29
+ month: "2-digit",
30
+ year: "numeric",
31
+ hour: "2-digit",
32
+ minute: "2-digit",
33
+ hour12: !1
34
+ },
35
+ mediumDateTime: {
36
+ day: "numeric",
37
+ month: "short",
38
+ year: "numeric",
39
+ hour: "2-digit",
40
+ minute: "2-digit",
41
+ hour12: !1
42
+ }
43
+ }, A = new Set(["short", "shortDateTime"]);
44
+ function j(e) {
45
+ return e instanceof Date ? e : new Date(e);
46
+ }
47
+ function M(e) {
48
+ return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
49
+ }
50
+ function N(e, t = {}) {
51
+ let { preset: n = "short", locale: r = O, fallback: i = "" } = t;
52
+ if (e == null || e === "") return i;
53
+ let a = j(e);
54
+ if (Number.isNaN(a.getTime())) return i;
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
+ }
59
+ //#endregion
60
+ //#region src/useAntColorMode.ts
61
+ function P(e, n) {
62
+ let i = r(n), a = s(() => e.context.value.darkMode), o = s(() => {
63
+ switch (a.value) {
64
+ case null: return "auto";
65
+ case !0: return "dark";
66
+ case !1: return "light";
67
+ default: return i.value;
68
+ }
69
+ }), c = s(() => {
70
+ switch (o.value) {
71
+ case "light":
72
+ case "auto": return !1;
73
+ case "dark": return !0;
74
+ }
75
+ });
76
+ return Object.assign(o, {
77
+ host: a,
78
+ isDark: c
79
+ }, t(i, [
80
+ "state",
81
+ "system",
82
+ "store"
83
+ ]));
84
+ }
85
+ //#endregion
86
+ //#region src/useAntI18n.ts
87
+ function F(e, t) {
88
+ let n = g(t);
89
+ return h(() => e.context.value.user?.language, (e) => n.locale.value = e ?? "en", { immediate: !0 }), n;
90
+ }
91
+ //#endregion
92
+ //#region src/useAppTourMode.ts
93
+ var I = p(!1), L = p(null);
94
+ function R() {
95
+ function e(e) {
96
+ h(() => e.value.tourMode, (e) => {
97
+ I.value = !!e, e || (L.value = null);
98
+ }, { immediate: !0 });
99
+ }
100
+ function t(e) {
101
+ I.value && (L.value = e);
102
+ }
103
+ function n() {
104
+ I.value = !1, L.value = null;
105
+ }
106
+ return {
107
+ isActive: f(I),
108
+ activeZoneId: f(L),
109
+ connectContext: e,
110
+ setActiveZone: t,
111
+ exit: n
112
+ };
113
+ }
114
+ //#endregion
115
+ //#region src/useCommsClient.ts
116
+ function z(t, n, r) {
117
+ let i = p({}), a = v({
118
+ parent: window.parent,
119
+ connect: t,
120
+ manifest: r
121
+ }), o = p(""), c = s({
122
+ get: () => o.value,
123
+ set: (e) => a.appState.set(e)
124
+ });
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
+ "context",
127
+ "toolbar",
128
+ "appState"
129
+ ]), {
130
+ context: i,
131
+ toolbar: B(a),
132
+ appState: c
133
+ });
134
+ }
135
+ function B(e) {
136
+ let t = p(""), n = {
137
+ title: s({
138
+ get: () => e.toolbar.get().title,
139
+ set: (t) => e.toolbar.set((e) => ({
140
+ ...e,
141
+ title: t
142
+ }))
143
+ }),
144
+ subtitle: s({
145
+ get: () => e.toolbar.get().subtitle,
146
+ set: (t) => e.toolbar.set((e) => ({
147
+ ...e,
148
+ subtitle: t
149
+ }))
150
+ }),
151
+ searchEnabled: s({
152
+ get: () => e.toolbar.get().search.enabled,
153
+ set: (t) => e.toolbar.set((e) => ({
154
+ ...e,
155
+ search: {
156
+ ...e.search,
157
+ enabled: t
158
+ }
159
+ }))
160
+ }),
161
+ search: s({
162
+ get: () => t.value,
163
+ set: (t) => e.toolbar.set((e) => ({
164
+ ...e,
165
+ search: {
166
+ ...e.search,
167
+ input: t
168
+ }
169
+ }))
170
+ }),
171
+ menu: s({
172
+ get: () => e.toolbar.get().menu ?? [],
173
+ set: (t) => e.toolbar.set((e) => ({
174
+ ...e,
175
+ menu: t
176
+ }))
177
+ }),
178
+ isLoading: s({
179
+ get: () => e.toolbar.get().isLoading,
180
+ set: (t) => e.toolbar.set((e) => ({
181
+ ...e,
182
+ isLoading: t
183
+ }))
184
+ })
185
+ };
186
+ return e.toolbar.pipe(D((e) => e.search.input ?? ""), T(), w(300)).forEach((e) => t.value = e), n;
187
+ }
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
+ return t.add(u), u.add(o(a, () => l.next({ hotkeys: { ctrl: !0 } }))), u.add(o(c, () => l.next({ hotkeys: { shift: !0 } }))), u;
191
+ }
192
+ //#endregion
193
+ //#region src/useCommsHost.ts
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
+ ...e,
197
+ contextChanges: n,
198
+ windowChanges: l
199
+ });
200
+ Object.entries(t).map(([e, t]) => h(t, (t) => r((n) => ({
201
+ ...n,
202
+ [e]: _(t)
203
+ })), { immediate: !0 })).forEach((e) => u.scope.add(e)), u.toolbar.subscribe((t) => {
204
+ let n = e.toolbar;
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;
206
+ });
207
+ let d = a(e.toolbar.search, (e) => u.toolbar.set.search(e), {
208
+ immediate: !0,
209
+ debounce: 100
210
+ });
211
+ u.scope.add(c), u.scope.add(d);
212
+ let f = p(u.appState.get()), m = s({
213
+ get: () => f.value,
214
+ set: (e) => u.appState.set(e)
215
+ });
216
+ u.appState.changes.subscribe((e) => f.value = e);
217
+ let g = p(!1);
218
+ u.isConnectionInitialized.subscribe((e) => g.value = e);
219
+ let v = p(null);
220
+ u.manifest?.subscribe((e) => v.value = e);
221
+ let { unsubscribe: x, signal: S, closed: C } = u;
222
+ return {
223
+ ...e,
224
+ client: i,
225
+ appState: m,
226
+ isConnectionInitialized: g,
227
+ manifest: v,
228
+ unsubscribe: x,
229
+ signal: S,
230
+ closed: C
231
+ };
232
+ }
233
+ //#endregion
234
+ //#region src/usePermissions.ts
235
+ function U(e) {
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
+ function c(e) {
238
+ return !t.value || !n.value ? !1 : i.value || a.value ? !0 : (n.value.user_roles ?? []).some((t) => t.name === e);
239
+ }
240
+ function l(e) {
241
+ return !t.value || !n.value ? !1 : i.value || a.value ? !0 : !!n.value.user_permissions?.[String(e)];
242
+ }
243
+ function u(e) {
244
+ return !t.value || !r.value ? !1 : i.value || a.value || o.value ? !0 : (r.value.user_roles ?? []).some((t) => t.name === e);
245
+ }
246
+ function d(e) {
247
+ return !t.value || !r.value ? !1 : i.value || a.value ? !0 : !!r.value.user_permissions?.[String(e)];
248
+ }
249
+ return {
250
+ isGlobalAdmin: i,
251
+ isLicenseAdmin: a,
252
+ isProjectAdmin: o,
253
+ hasLicenseRole: c,
254
+ hasLicensePermission: l,
255
+ hasProjectRole: u,
256
+ hasProjectPermission: d
257
+ };
258
+ }
259
+ //#endregion
260
+ //#region src/useTemplateVersioning.ts
261
+ function W(e) {
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
+ async function b(n) {
264
+ c.value = !0;
265
+ try {
266
+ return t.value = (await e.tasks.checkForUpdates(n))?.data ?? null, t.value;
267
+ } catch {
268
+ return t.value = null, null;
269
+ } finally {
270
+ c.value = !1;
271
+ }
272
+ }
273
+ async function x(t, r) {
274
+ l.value = !0;
275
+ try {
276
+ return n.value = (await e.tasks.versionDiff(t, r))?.data ?? null, n.value;
277
+ } catch {
278
+ return n.value = null, null;
279
+ } finally {
280
+ l.value = !1;
281
+ }
282
+ }
283
+ async function S(t, r, i) {
284
+ l.value = !0;
285
+ try {
286
+ return n.value = (await e.tasks.versionCompare(t, r, i))?.data ?? null, n.value;
287
+ } catch {
288
+ return n.value = null, null;
289
+ } finally {
290
+ l.value = !1;
291
+ }
292
+ }
293
+ async function C(t) {
294
+ u.value = !0;
295
+ try {
296
+ return r.value = (await e.tasks.versionDiffOriginal(t))?.data ?? null, r.value;
297
+ } catch {
298
+ return r.value = null, null;
299
+ } finally {
300
+ u.value = !1;
301
+ }
302
+ }
303
+ async function w(r, a) {
304
+ d.value = !0;
305
+ try {
306
+ return i.value = (await e.tasks.syncToLatestVersion(r, a))?.data ?? null, t.value = null, n.value = null, i.value;
307
+ } catch {
308
+ return i.value = null, null;
309
+ } finally {
310
+ d.value = !1;
311
+ }
312
+ }
313
+ async function T(t, n) {
314
+ f.value = !0;
315
+ try {
316
+ let r = (await e.tasks.publishVersion(t, { change_summary: n }))?.data ?? null;
317
+ return r && (a.value = [r, ...a.value], o.value = r), r;
318
+ } catch {
319
+ return null;
320
+ } finally {
321
+ f.value = !1;
322
+ }
323
+ }
324
+ async function E(t) {
325
+ h.value = !0;
326
+ try {
327
+ return a.value = (await e.tasks.listVersions(t))?.data ?? [], a.value;
328
+ } catch {
329
+ return a.value = [], [];
330
+ } finally {
331
+ h.value = !1;
332
+ }
333
+ }
334
+ async function D(t) {
335
+ try {
336
+ return o.value = (await e.tasks.latestVersion(t))?.data ?? null, o.value;
337
+ } catch {
338
+ return o.value = null, null;
339
+ }
340
+ }
341
+ let O = m([]), k = p(!1), A = p(!1), j = m([]);
342
+ async function M(t) {
343
+ k.value = !0;
344
+ try {
345
+ return O.value = (await e.tasks.getInstances(t))?.data ?? [], O.value;
346
+ } catch {
347
+ return O.value = [], [];
348
+ } finally {
349
+ k.value = !1;
350
+ }
351
+ }
352
+ async function N(t, n) {
353
+ A.value = !0, j.value = [];
354
+ try {
355
+ return j.value = (await e.tasks.pushSync(t, n))?.data ?? [], j.value;
356
+ } catch {
357
+ return j.value = [], [];
358
+ } finally {
359
+ A.value = !1;
360
+ }
361
+ }
362
+ function P() {
363
+ t.value = null, n.value = null, r.value = null, i.value = null, a.value = [], o.value = null, O.value = [], j.value = [];
364
+ }
365
+ return {
366
+ updateCheck: t,
367
+ diff: n,
368
+ userCustomizations: r,
369
+ syncResult: i,
370
+ versions: a,
371
+ latestVersion: o,
372
+ instances: O,
373
+ pushSyncResults: j,
374
+ isCheckingUpdate: c,
375
+ isFetchingDiff: l,
376
+ isFetchingCustomizations: u,
377
+ isSyncing: d,
378
+ isPublishing: f,
379
+ isFetchingVersions: h,
380
+ isFetchingInstances: k,
381
+ isPushSyncing: A,
382
+ hasUpdate: g,
383
+ currentVersion: _,
384
+ availableVersion: v,
385
+ totalChanges: y,
386
+ checkForUpdates: b,
387
+ fetchDiff: x,
388
+ fetchUserCustomizations: C,
389
+ compareVersions: S,
390
+ syncToVersion: w,
391
+ publishVersion: T,
392
+ fetchVersions: E,
393
+ fetchLatestVersion: D,
394
+ fetchInstances: M,
395
+ pushSync: N,
396
+ reset: P
397
+ };
398
+ }
399
+ //#endregion
400
+ //#region src/utils.ts
401
+ function G(e = "comms") {
402
+ let [t, n] = K(e, () => z(), (e) => e.unsubscribe());
403
+ return {
404
+ provideComms: t,
405
+ injectComms: n
406
+ };
407
+ }
408
+ function K(e, t, n) {
409
+ let r, i = () => (!r && (r = t()), r);
410
+ return [(t) => (t.onUnmount(() => n && r && n(r)), t.provide(e, i)), () => c(e)()];
411
+ }
412
+ function q(t, r, i) {
413
+ let a = n(t, r, {
414
+ immediate: !1,
415
+ ...i
416
+ });
417
+ return Object.assign(e(a, ["execute"]), {
418
+ execute: (...e) => a.execute(void 0, ...e),
419
+ executeDelayed: a.execute
420
+ });
421
+ }
422
+ function J(e) {
423
+ let t, n = p(void 0);
424
+ return u(() => t = e.signal.receive((e) => n.value = e)), d(() => t?.()), [f(n), () => t?.()];
425
+ }
426
+ //#endregion
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 };
@@ -0,0 +1,22 @@
1
+ export type DateFormatPreset = 'short' | 'medium' | 'long' | 'monthDay' | 'shortDateTime' | 'mediumDateTime' | 'iso';
2
+ export interface FormatDateOptions {
3
+ /** Display preset. Default: 'short' (DD-MM-YYYY numeric). */
4
+ preset?: DateFormatPreset;
5
+ /** BCP-47 locale tag. Default: 'nl' (Dutch DD-MM-YYYY notation). */
6
+ locale?: string;
7
+ /** Returned when value is null/undefined/empty/invalid. Default: ''. */
8
+ fallback?: string;
9
+ }
10
+ /**
11
+ * Format a date for display across the ANT environment.
12
+ *
13
+ * Default is the Dutch DD-MM-YYYY notation. German callers get DD.MM.YYYY
14
+ * via native Intl. English (`en`, `en-US`, `en-GB`, ...) is intentionally
15
+ * mapped to the Dutch numeric pattern for the `short`/`shortDateTime`
16
+ * presets to keep the project-wide DD-MM-YYYY default even when the host
17
+ * runs in English.
18
+ *
19
+ * Storage stays ISO everywhere — use the `iso` preset only for payload
20
+ * serialisation, never for display.
21
+ */
22
+ export declare function formatDate(value: Date | string | number | null | undefined, options?: FormatDateOptions): string;
@@ -1,6 +1,9 @@
1
+ export { type DateFormatPreset, formatDate, type FormatDateOptions } from './formatDate';
1
2
  export { useAntColorMode, type UseAntColorModeOptions, type UseAntColorModeReturn } from './useAntColorMode';
2
3
  export { useAntI18n, type UseAntI18nReturn } from './useAntI18n';
4
+ export { useAppTourMode } from './useAppTourMode';
3
5
  export { type UseCommsClient, useCommsClient } from './useCommsClient';
4
6
  export { type CommsHostArgs, type UseCommsHost, useCommsHost } from './useCommsHost';
5
7
  export { type UsePermissions, usePermissions } from './usePermissions';
8
+ export { useTemplateVersioning, type UseTemplateVersioningReturn } from './useTemplateVersioning';
6
9
  export { type AnyUseApiReturn, type CommsToolbar, useApi, type UseApiReturn, useCommsInjection, useSignal, useSingleton, } from './utils';
@@ -0,0 +1,26 @@
1
+ import { Ref } from 'vue';
2
+ /**
3
+ * Iframe-side tour mode — mirrors the OS `useTourMode` API.
4
+ *
5
+ * Call `connectContext(context)` once in App.vue to wire the OS context stream.
6
+ * Then call `useAppTourMode()` anywhere to read state and set the active zone.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // App.vue — one-time wiring
11
+ * const { comms } = injectContext()
12
+ * useAppTourMode().connectContext(comms.context)
13
+ *
14
+ * // Any component
15
+ * const { isActive, activeZoneId, setActiveZone } = useAppTourMode()
16
+ * ```
17
+ */
18
+ export declare function useAppTourMode(): {
19
+ isActive: Readonly<Ref<boolean, boolean>>;
20
+ activeZoneId: Readonly<Ref<string | null, string | null>>;
21
+ connectContext: (context: Ref<{
22
+ tourMode?: boolean | null;
23
+ }>) => void;
24
+ setActiveZone: (id: string | null) => void;
25
+ exit: () => void;
26
+ };
@@ -1,4 +1,4 @@
1
- import { AntConnect, Client, Context, Signal } from '@antcde/connect-ts';
1
+ import { AntConnect, AppManifest, Client, Context, Signal } from '@antcde/connect-ts';
2
2
  import { ObservableInput } from 'rxjs';
3
3
  import { Ref } from 'vue';
4
4
  import { CommsToolbar } from './utils';
@@ -20,5 +20,5 @@ type KeyboardShortcutsHook = (signal: Signal) => ObservableInput<Signal>;
20
20
  * @param keyboardsShortcuts By default it will process keyboards from the client and send them to the host.
21
21
  *
22
22
  */
23
- export declare function useCommsClient(connect?: AntConnect, keyboardsShortcuts?: KeyboardShortcutsHook): UseCommsClient;
23
+ export declare function useCommsClient(connect?: AntConnect, keyboardsShortcuts?: KeyboardShortcutsHook, manifest?: AppManifest): UseCommsClient;
24
24
  export {};
@@ -1,4 +1,4 @@
1
- import { AntConnect, LabelFilterState, License, Notepad, Notification, ProjectShort, SignalObserverFactory, SignalReceiver, SignalSender, Task, User } from '@antcde/connect-ts';
1
+ import { AntConnect, AppManifest, LabelFilterState, License, Notepad, Notification, ProjectShort, SignalObserverFactory, SignalReceiver, SignalSender, Task, User } from '@antcde/connect-ts';
2
2
  import { SubscriptionLike } from 'rxjs';
3
3
  import { Ref } from 'vue';
4
4
  import { CommsToolbar } from './utils';
@@ -30,6 +30,7 @@ export interface UseCommsHost extends CommsHostArgs, SubscriptionLike {
30
30
  client: Ref<HTMLIFrameElement | null | undefined>;
31
31
  appState: Ref<string>;
32
32
  isConnectionInitialized: Ref<boolean>;
33
+ manifest: Ref<AppManifest | null>;
33
34
  signal: SignalReceiver & SignalSender;
34
35
  }
35
36
  export declare function useCommsHost(args: CommsHostArgs): UseCommsHost;
@@ -0,0 +1,36 @@
1
+ import { AntConnect, PushSyncResult, TaskTemplateVersion, TemplateInstance, VersionCheck, VersionDiff, VersionSyncResult } from '@antcde/connect-ts';
2
+ import { ComputedRef, ref, shallowRef } from 'vue';
3
+ export interface UseTemplateVersioningReturn {
4
+ updateCheck: Readonly<ReturnType<typeof shallowRef<VersionCheck | null>>>;
5
+ diff: Readonly<ReturnType<typeof shallowRef<VersionDiff | null>>>;
6
+ userCustomizations: Readonly<ReturnType<typeof shallowRef<VersionDiff | null>>>;
7
+ syncResult: Readonly<ReturnType<typeof shallowRef<VersionSyncResult | null>>>;
8
+ versions: Readonly<ReturnType<typeof shallowRef<TaskTemplateVersion[]>>>;
9
+ latestVersion: Readonly<ReturnType<typeof shallowRef<TaskTemplateVersion | null>>>;
10
+ instances: Readonly<ReturnType<typeof shallowRef<TemplateInstance[]>>>;
11
+ pushSyncResults: Readonly<ReturnType<typeof shallowRef<PushSyncResult[]>>>;
12
+ isCheckingUpdate: Readonly<ReturnType<typeof ref<boolean>>>;
13
+ isFetchingDiff: Readonly<ReturnType<typeof ref<boolean>>>;
14
+ isFetchingCustomizations: Readonly<ReturnType<typeof ref<boolean>>>;
15
+ isSyncing: Readonly<ReturnType<typeof ref<boolean>>>;
16
+ isPublishing: Readonly<ReturnType<typeof ref<boolean>>>;
17
+ isFetchingVersions: Readonly<ReturnType<typeof ref<boolean>>>;
18
+ isFetchingInstances: Readonly<ReturnType<typeof ref<boolean>>>;
19
+ isPushSyncing: Readonly<ReturnType<typeof ref<boolean>>>;
20
+ hasUpdate: ComputedRef<boolean>;
21
+ currentVersion: ComputedRef<number | null>;
22
+ availableVersion: ComputedRef<number | null>;
23
+ totalChanges: ComputedRef<number>;
24
+ checkForUpdates: (taskId: string) => Promise<VersionCheck | null>;
25
+ fetchDiff: (taskId: string, targetVersionId?: string) => Promise<VersionDiff | null>;
26
+ fetchUserCustomizations: (taskId: string) => Promise<VersionDiff | null>;
27
+ compareVersions: (templateId: string, fromVersionId: string, toVersionId: string) => Promise<VersionDiff | null>;
28
+ syncToVersion: (taskId: string, targetVersionId?: string) => Promise<VersionSyncResult | null>;
29
+ publishVersion: (templateId: string, changeSummary?: string) => Promise<TaskTemplateVersion | null>;
30
+ fetchVersions: (templateId: string) => Promise<TaskTemplateVersion[]>;
31
+ fetchLatestVersion: (templateId: string) => Promise<TaskTemplateVersion | null>;
32
+ fetchInstances: (templateId: string) => Promise<TemplateInstance[]>;
33
+ pushSync: (templateId: string, instanceIds: string[]) => Promise<PushSyncResult[]>;
34
+ reset: () => void;
35
+ }
36
+ export declare function useTemplateVersioning(connect: AntConnect): UseTemplateVersioningReturn;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antcde/vue-utils",
3
3
  "type": "module",
4
- "version": "0.2.13",
4
+ "version": "0.2.14-rc.09815b8",
5
5
  "description": "Helper to use ANT Comms in Vue 3",
6
6
  "author": "CollaborAll",
7
7
  "exports": {
@@ -25,22 +25,22 @@
25
25
  "clean": "pnpm dlx rimraf dist"
26
26
  },
27
27
  "peerDependencies": {
28
- "@vueuse/core": "^13.9.0",
28
+ "@vueuse/core": "^14.0.0",
29
29
  "rxjs": "^7.0.0",
30
30
  "vue": "^3.5.10",
31
31
  "vue-i18n": "^11.1.12"
32
32
  },
33
33
  "dependencies": {
34
- "@antcde/connect-ts": "0.4.17"
34
+ "@antcde/connect-ts": "0.4.19-rc.09815b8"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@tsconfig/node22": "^22.0.5",
38
- "@types/node": "^22.19.17",
39
- "@vitejs/plugin-vue": "^6.0.5",
40
- "@vue/tsconfig": "^0.8.1",
41
- "typescript": "~5.9.3",
42
- "vite": "^7.3.2",
38
+ "@types/node": "^22.19.21",
39
+ "@vitejs/plugin-vue": "^6.0.7",
40
+ "@vue/tsconfig": "^0.9.1",
41
+ "typescript": "~6.0.3",
42
+ "vite": "^8.0.16",
43
43
  "vite-plugin-dts": "^4.5.4",
44
- "vue-tsc": "^3.2.6"
44
+ "vue-tsc": "^3.3.5"
45
45
  }
46
46
  }