@antcde/vue-utils 0.2.21 → 0.2.22-rc.2
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 +122 -75
- package/dist/types/formatDate.d.ts +20 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/useTriggerDispatch.d.ts +28 -0
- package/package.json +6 -6
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
|
-
import { computed as s, inject as c, onBeforeUnmount as l, onMounted as u,
|
|
3
|
-
import { useI18n as
|
|
4
|
-
import { clone as
|
|
5
|
-
import { BehaviorSubject as
|
|
2
|
+
import { computed as s, inject as c, onBeforeUnmount as l, onMounted as u, onScopeDispose as d, onUnmounted as f, readonly as p, ref as m, shallowRef as h, watch as g } from "vue";
|
|
3
|
+
import { useI18n as _ } from "vue-i18n";
|
|
4
|
+
import { clone as v, isAuthorizationRequired as y, newCommsClient as b, newCommsHost as x } from "@antcde/connect-ts";
|
|
5
|
+
import { BehaviorSubject as S, Subject as C, concat as w, concatMap as T, debounceTime as E, distinctUntilChanged as D, filter as O, map as k } from "rxjs";
|
|
6
6
|
//#region src/formatDate.ts
|
|
7
|
-
var
|
|
7
|
+
var A = "nl", j = {
|
|
8
8
|
short: {
|
|
9
9
|
day: "2-digit",
|
|
10
10
|
month: "2-digit",
|
|
@@ -40,25 +40,36 @@ var O = "nl", k = {
|
|
|
40
40
|
minute: "2-digit",
|
|
41
41
|
hour12: !1
|
|
42
42
|
}
|
|
43
|
-
},
|
|
44
|
-
function
|
|
43
|
+
}, M = /* @__PURE__ */ new Set(["short", "shortDateTime"]);
|
|
44
|
+
function N(e) {
|
|
45
45
|
return e instanceof Date ? e : new Date(e);
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function P(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 F(e, t = {}) {
|
|
51
|
+
let { preset: n = "short", locale: r = A, fallback: i = "" } = t;
|
|
52
52
|
if (e == null || e === "") return i;
|
|
53
|
-
let a =
|
|
53
|
+
let a = N(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 P(a);
|
|
56
|
+
let o = M.has(n) && /^en\b/i.test(r) ? A : r;
|
|
57
|
+
return new Intl.DateTimeFormat(o, j[n]).format(a);
|
|
58
|
+
}
|
|
59
|
+
function I(e, t, n = {}) {
|
|
60
|
+
let { preset: r = "medium", locale: i = A, fallback: a = "" } = n, o = e == null || e === "" ? null : N(e), s = t == null || t === "" ? null : N(t), c = o && !Number.isNaN(o.getTime()) ? o : null, l = s && !Number.isNaN(s.getTime()) ? s : null;
|
|
61
|
+
if (!c && !l) return a;
|
|
62
|
+
if (!c || !l || P(c) === P(l)) return F(c ?? l, {
|
|
63
|
+
preset: r === "iso" ? "medium" : r,
|
|
64
|
+
locale: i,
|
|
65
|
+
fallback: a
|
|
66
|
+
});
|
|
67
|
+
let u = r === "iso" ? "medium" : r;
|
|
68
|
+
return new Intl.DateTimeFormat(i, j[u]).formatRange(c, l);
|
|
58
69
|
}
|
|
59
70
|
//#endregion
|
|
60
71
|
//#region src/useAntColorMode.ts
|
|
61
|
-
function
|
|
72
|
+
function L(e, n) {
|
|
62
73
|
let i = r(n), a = s(() => e.context.value.darkMode), o = s(() => {
|
|
63
74
|
switch (a.value) {
|
|
64
75
|
case null: return "auto";
|
|
@@ -84,28 +95,28 @@ function P(e, n) {
|
|
|
84
95
|
}
|
|
85
96
|
//#endregion
|
|
86
97
|
//#region src/useAntI18n.ts
|
|
87
|
-
function
|
|
88
|
-
let n =
|
|
89
|
-
return
|
|
98
|
+
function R(e, t) {
|
|
99
|
+
let n = _(t);
|
|
100
|
+
return g(() => e.context.value.user?.language, (e) => n.locale.value = e ?? "en", { immediate: !0 }), n;
|
|
90
101
|
}
|
|
91
102
|
//#endregion
|
|
92
103
|
//#region src/useAppTourMode.ts
|
|
93
|
-
var
|
|
94
|
-
function
|
|
104
|
+
var z = m(!1), B = m(null);
|
|
105
|
+
function V() {
|
|
95
106
|
function e(e) {
|
|
96
|
-
|
|
97
|
-
|
|
107
|
+
g(() => e.value.tourMode, (e) => {
|
|
108
|
+
z.value = !!e, e || (B.value = null);
|
|
98
109
|
}, { immediate: !0 });
|
|
99
110
|
}
|
|
100
111
|
function t(e) {
|
|
101
|
-
|
|
112
|
+
z.value && (B.value = e);
|
|
102
113
|
}
|
|
103
114
|
function n() {
|
|
104
|
-
|
|
115
|
+
z.value = !1, B.value = null;
|
|
105
116
|
}
|
|
106
117
|
return {
|
|
107
|
-
isActive:
|
|
108
|
-
activeZoneId:
|
|
118
|
+
isActive: p(z),
|
|
119
|
+
activeZoneId: p(B),
|
|
109
120
|
connectContext: e,
|
|
110
121
|
setActiveZone: t,
|
|
111
122
|
exit: n
|
|
@@ -113,27 +124,27 @@ function R() {
|
|
|
113
124
|
}
|
|
114
125
|
//#endregion
|
|
115
126
|
//#region src/useCommsClient.ts
|
|
116
|
-
function
|
|
117
|
-
let i =
|
|
127
|
+
function H(t, n, r) {
|
|
128
|
+
let i = m({}), a = b({
|
|
118
129
|
parent: window.parent,
|
|
119
130
|
connect: t,
|
|
120
131
|
manifest: r
|
|
121
|
-
}), o =
|
|
132
|
+
}), o = m(""), c = s({
|
|
122
133
|
get: () => o.value,
|
|
123
134
|
set: (e) => a.appState.set(e)
|
|
124
135
|
});
|
|
125
|
-
return a.context.subscribe((e) => i.value = e),
|
|
136
|
+
return a.context.subscribe((e) => i.value = e), w(a.appState.get(), a.appState).subscribe((e) => o.value = e), W(a.signal, a, n), l(() => a.unsubscribe()), Object.assign(e(a, [
|
|
126
137
|
"context",
|
|
127
138
|
"toolbar",
|
|
128
139
|
"appState"
|
|
129
140
|
]), {
|
|
130
141
|
context: i,
|
|
131
|
-
toolbar:
|
|
142
|
+
toolbar: U(a),
|
|
132
143
|
appState: c
|
|
133
144
|
});
|
|
134
145
|
}
|
|
135
|
-
function
|
|
136
|
-
let t =
|
|
146
|
+
function U(e) {
|
|
147
|
+
let t = m(""), n = {
|
|
137
148
|
title: s({
|
|
138
149
|
get: () => e.toolbar.get().title,
|
|
139
150
|
set: (t) => e.toolbar.set((e) => ({
|
|
@@ -183,23 +194,23 @@ function B(e) {
|
|
|
183
194
|
}))
|
|
184
195
|
})
|
|
185
196
|
};
|
|
186
|
-
return e.toolbar.pipe(
|
|
197
|
+
return e.toolbar.pipe(k((e) => e.search.input ?? ""), D(), E(300)).forEach((e) => t.value = e), n;
|
|
187
198
|
}
|
|
188
|
-
function
|
|
189
|
-
let r = i(), a = r.ctrl ?? s(() => !1), c = r.shift ?? s(() => !1), l = new
|
|
199
|
+
function W(e, t, n) {
|
|
200
|
+
let r = i(), a = r.ctrl ?? s(() => !1), c = r.shift ?? s(() => !1), l = new C(), u = l.pipe(T(n ?? ((e) => Promise.resolve(e))), T((t) => e(t))).subscribe();
|
|
190
201
|
return t.add(u), u.add(o(a, () => l.next({ hotkeys: { ctrl: !0 } }))), u.add(o(c, () => l.next({ hotkeys: { shift: !0 } }))), u;
|
|
191
202
|
}
|
|
192
203
|
//#endregion
|
|
193
204
|
//#region src/useCommsHost.ts
|
|
194
|
-
function
|
|
195
|
-
let { context: t } = e, n = new
|
|
205
|
+
function G(e) {
|
|
206
|
+
let { context: t } = e, n = new S({}), r = (e) => n.next(e(n.value)), i = m(), o = new S(void 0), c = g(i, (e) => o.next(e), { immediate: !0 }), l = o.asObservable().pipe(k((e) => e?.contentWindow), O((e) => !!e)), u = x({
|
|
196
207
|
...e,
|
|
197
208
|
contextChanges: n,
|
|
198
209
|
windowChanges: l
|
|
199
210
|
});
|
|
200
|
-
Object.entries(t).map(([e, t]) =>
|
|
211
|
+
Object.entries(t).map(([e, t]) => g(t, (t) => r((n) => ({
|
|
201
212
|
...n,
|
|
202
|
-
[e]:
|
|
213
|
+
[e]: v(t)
|
|
203
214
|
})), { immediate: !0 })).forEach((e) => u.scope.add(e)), u.toolbar.subscribe((t) => {
|
|
204
215
|
let n = e.toolbar;
|
|
205
216
|
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;
|
|
@@ -209,30 +220,30 @@ function H(e) {
|
|
|
209
220
|
debounce: 100
|
|
210
221
|
});
|
|
211
222
|
u.scope.add(c), u.scope.add(d);
|
|
212
|
-
let f =
|
|
223
|
+
let f = m(u.appState.get()), p = s({
|
|
213
224
|
get: () => f.value,
|
|
214
225
|
set: (e) => u.appState.set(e)
|
|
215
226
|
});
|
|
216
227
|
u.appState.changes.subscribe((e) => f.value = e);
|
|
217
|
-
let
|
|
218
|
-
u.isConnectionInitialized.subscribe((e) =>
|
|
219
|
-
let
|
|
220
|
-
u.manifest?.subscribe((e) =>
|
|
221
|
-
let { unsubscribe:
|
|
228
|
+
let h = m(!1);
|
|
229
|
+
u.isConnectionInitialized.subscribe((e) => h.value = e);
|
|
230
|
+
let _ = m(null);
|
|
231
|
+
u.manifest?.subscribe((e) => _.value = e);
|
|
232
|
+
let { unsubscribe: y, signal: b, closed: C } = u;
|
|
222
233
|
return {
|
|
223
234
|
...e,
|
|
224
235
|
client: i,
|
|
225
|
-
appState:
|
|
226
|
-
isConnectionInitialized:
|
|
227
|
-
manifest:
|
|
228
|
-
unsubscribe:
|
|
229
|
-
signal:
|
|
236
|
+
appState: p,
|
|
237
|
+
isConnectionInitialized: h,
|
|
238
|
+
manifest: _,
|
|
239
|
+
unsubscribe: y,
|
|
240
|
+
signal: b,
|
|
230
241
|
closed: C
|
|
231
242
|
};
|
|
232
243
|
}
|
|
233
244
|
//#endregion
|
|
234
245
|
//#region src/usePermissions.ts
|
|
235
|
-
function
|
|
246
|
+
function K(e) {
|
|
236
247
|
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
248
|
function c(e) {
|
|
238
249
|
return !t.value || !n.value ? !1 : i.value || a.value ? !0 : (n.value.user_roles ?? []).some((t) => t.name === e);
|
|
@@ -258,12 +269,13 @@ function U(e) {
|
|
|
258
269
|
}
|
|
259
270
|
//#endregion
|
|
260
271
|
//#region src/useTemplateVersioning.ts
|
|
261
|
-
function
|
|
262
|
-
let t =
|
|
272
|
+
function q(e) {
|
|
273
|
+
let t = h(null), n = h(null), r = h(null), i = h(null), a = h([]), o = h(null), c = m(!1), l = m(!1), u = m(!1), d = m(!1), f = m(!1), p = m(!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
274
|
async function b(n) {
|
|
264
275
|
c.value = !0;
|
|
265
276
|
try {
|
|
266
|
-
|
|
277
|
+
let r = await e.tasks.checkForUpdates(n);
|
|
278
|
+
return t.value = r?.data ?? null, t.value;
|
|
267
279
|
} catch {
|
|
268
280
|
return t.value = null, null;
|
|
269
281
|
} finally {
|
|
@@ -273,7 +285,8 @@ function W(e) {
|
|
|
273
285
|
async function x(t, r) {
|
|
274
286
|
l.value = !0;
|
|
275
287
|
try {
|
|
276
|
-
|
|
288
|
+
let i = await e.tasks.versionDiff(t, r);
|
|
289
|
+
return n.value = i?.data ?? null, n.value;
|
|
277
290
|
} catch {
|
|
278
291
|
return n.value = null, null;
|
|
279
292
|
} finally {
|
|
@@ -283,7 +296,8 @@ function W(e) {
|
|
|
283
296
|
async function S(t, r, i) {
|
|
284
297
|
l.value = !0;
|
|
285
298
|
try {
|
|
286
|
-
|
|
299
|
+
let a = await e.tasks.versionCompare(t, r, i);
|
|
300
|
+
return n.value = a?.data ?? null, n.value;
|
|
287
301
|
} catch {
|
|
288
302
|
return n.value = null, null;
|
|
289
303
|
} finally {
|
|
@@ -293,7 +307,8 @@ function W(e) {
|
|
|
293
307
|
async function C(t) {
|
|
294
308
|
u.value = !0;
|
|
295
309
|
try {
|
|
296
|
-
|
|
310
|
+
let n = await e.tasks.versionDiffOriginal(t);
|
|
311
|
+
return r.value = n?.data ?? null, r.value;
|
|
297
312
|
} catch {
|
|
298
313
|
return r.value = null, null;
|
|
299
314
|
} finally {
|
|
@@ -303,7 +318,8 @@ function W(e) {
|
|
|
303
318
|
async function w(r, a) {
|
|
304
319
|
d.value = !0;
|
|
305
320
|
try {
|
|
306
|
-
|
|
321
|
+
let o = await e.tasks.syncToLatestVersion(r, a);
|
|
322
|
+
return i.value = o?.data ?? null, t.value = null, n.value = null, i.value;
|
|
307
323
|
} catch {
|
|
308
324
|
return i.value = null, null;
|
|
309
325
|
} finally {
|
|
@@ -322,27 +338,30 @@ function W(e) {
|
|
|
322
338
|
}
|
|
323
339
|
}
|
|
324
340
|
async function E(t) {
|
|
325
|
-
|
|
341
|
+
p.value = !0;
|
|
326
342
|
try {
|
|
327
|
-
|
|
343
|
+
let n = await e.tasks.listVersions(t);
|
|
344
|
+
return a.value = n?.data ?? [], a.value;
|
|
328
345
|
} catch {
|
|
329
346
|
return a.value = [], [];
|
|
330
347
|
} finally {
|
|
331
|
-
|
|
348
|
+
p.value = !1;
|
|
332
349
|
}
|
|
333
350
|
}
|
|
334
351
|
async function D(t) {
|
|
335
352
|
try {
|
|
336
|
-
|
|
353
|
+
let n = await e.tasks.latestVersion(t);
|
|
354
|
+
return o.value = n?.data ?? null, o.value;
|
|
337
355
|
} catch {
|
|
338
356
|
return o.value = null, null;
|
|
339
357
|
}
|
|
340
358
|
}
|
|
341
|
-
let O =
|
|
359
|
+
let O = h([]), k = m(!1), A = m(!1), j = h([]);
|
|
342
360
|
async function M(t) {
|
|
343
361
|
k.value = !0;
|
|
344
362
|
try {
|
|
345
|
-
|
|
363
|
+
let n = await e.tasks.getInstances(t);
|
|
364
|
+
return O.value = n?.data ?? [], O.value;
|
|
346
365
|
} catch {
|
|
347
366
|
return O.value = [], [];
|
|
348
367
|
} finally {
|
|
@@ -352,7 +371,8 @@ function W(e) {
|
|
|
352
371
|
async function N(t, n) {
|
|
353
372
|
A.value = !0, j.value = [];
|
|
354
373
|
try {
|
|
355
|
-
|
|
374
|
+
let r = await e.tasks.pushSync(t, n);
|
|
375
|
+
return j.value = r?.data ?? [], j.value;
|
|
356
376
|
} catch {
|
|
357
377
|
return j.value = [], [];
|
|
358
378
|
} finally {
|
|
@@ -376,7 +396,7 @@ function W(e) {
|
|
|
376
396
|
isFetchingCustomizations: u,
|
|
377
397
|
isSyncing: d,
|
|
378
398
|
isPublishing: f,
|
|
379
|
-
isFetchingVersions:
|
|
399
|
+
isFetchingVersions: p,
|
|
380
400
|
isFetchingInstances: k,
|
|
381
401
|
isPushSyncing: A,
|
|
382
402
|
hasUpdate: g,
|
|
@@ -397,19 +417,46 @@ function W(e) {
|
|
|
397
417
|
};
|
|
398
418
|
}
|
|
399
419
|
//#endregion
|
|
420
|
+
//#region src/useTriggerDispatch.ts
|
|
421
|
+
function J(e, t = {}) {
|
|
422
|
+
let n = t.authorizationTimeoutMs ?? 5 * 6e4, r = /* @__PURE__ */ new Set();
|
|
423
|
+
d(() => {
|
|
424
|
+
for (let e of r) e();
|
|
425
|
+
});
|
|
426
|
+
function i(t) {
|
|
427
|
+
return new Promise((i) => {
|
|
428
|
+
let a = !1, o, s, c, l = (e) => {
|
|
429
|
+
a || (a = !0, o?.(), s && clearTimeout(s), c && r.delete(c), i(e));
|
|
430
|
+
};
|
|
431
|
+
c = () => l(!1), r.add(c), o = e.signal.receive((e) => {
|
|
432
|
+
let n = e.oauthAuthorizeResult;
|
|
433
|
+
n && n.secretId === t.secret_id && l(n.ok);
|
|
434
|
+
}), s = setTimeout(l, n, !1), e.signal({ oauthAuthorize: {
|
|
435
|
+
authorizeUrl: t.authorize_url,
|
|
436
|
+
secretId: t.secret_id
|
|
437
|
+
} });
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
async function a(e) {
|
|
441
|
+
let t = await e();
|
|
442
|
+
return !y(t) || !await i(t) ? t : e();
|
|
443
|
+
}
|
|
444
|
+
return { dispatch: a };
|
|
445
|
+
}
|
|
446
|
+
//#endregion
|
|
400
447
|
//#region src/utils.ts
|
|
401
|
-
function
|
|
402
|
-
let [t, n] =
|
|
448
|
+
function Y(e = "comms") {
|
|
449
|
+
let [t, n] = X(e, () => H(), (e) => e.unsubscribe());
|
|
403
450
|
return {
|
|
404
451
|
provideComms: t,
|
|
405
452
|
injectComms: n
|
|
406
453
|
};
|
|
407
454
|
}
|
|
408
|
-
function
|
|
455
|
+
function X(e, t, n) {
|
|
409
456
|
let r, i = () => (!r && (r = t()), r);
|
|
410
457
|
return [(t) => (t.onUnmount(() => n && r && n(r)), t.provide(e, i)), () => c(e)()];
|
|
411
458
|
}
|
|
412
|
-
function
|
|
459
|
+
function Z(t, r, i) {
|
|
413
460
|
let a = n(t, r, {
|
|
414
461
|
immediate: !1,
|
|
415
462
|
...i
|
|
@@ -419,9 +466,9 @@ function q(t, r, i) {
|
|
|
419
466
|
executeDelayed: a.execute
|
|
420
467
|
});
|
|
421
468
|
}
|
|
422
|
-
function
|
|
423
|
-
let t, n =
|
|
424
|
-
return u(() => t = e.signal.receive((e) => n.value = e)),
|
|
469
|
+
function Q(e) {
|
|
470
|
+
let t, n = m(void 0);
|
|
471
|
+
return u(() => t = e.signal.receive((e) => n.value = e)), f(() => t?.()), [p(n), () => t?.()];
|
|
425
472
|
}
|
|
426
473
|
//#endregion
|
|
427
|
-
export {
|
|
474
|
+
export { F as formatDate, I as formatDateRange, L as useAntColorMode, R as useAntI18n, Z as useApi, V as useAppTourMode, H as useCommsClient, G as useCommsHost, Y as useCommsInjection, K as usePermissions, Q as useSignal, X as useSingleton, q as useTemplateVersioning, J as useTriggerDispatch };
|
|
@@ -7,6 +7,14 @@ export interface FormatDateOptions {
|
|
|
7
7
|
/** Returned when value is null/undefined/empty/invalid. Default: ''. */
|
|
8
8
|
fallback?: string;
|
|
9
9
|
}
|
|
10
|
+
export interface FormatDateRangeOptions {
|
|
11
|
+
/** Display preset. Default: 'medium' (e.g. 6 Aug 2025). */
|
|
12
|
+
preset?: DateFormatPreset;
|
|
13
|
+
/** BCP-47 locale tag. Default: 'nl'. */
|
|
14
|
+
locale?: string;
|
|
15
|
+
/** Returned when both ends are null/undefined/empty/invalid. Default: ''. */
|
|
16
|
+
fallback?: string;
|
|
17
|
+
}
|
|
10
18
|
/**
|
|
11
19
|
* Format a date for display across the ANT environment.
|
|
12
20
|
*
|
|
@@ -20,3 +28,15 @@ export interface FormatDateOptions {
|
|
|
20
28
|
* serialisation, never for display.
|
|
21
29
|
*/
|
|
22
30
|
export declare function formatDate(value: Date | string | number | null | undefined, options?: FormatDateOptions): string;
|
|
31
|
+
/**
|
|
32
|
+
* Format a date range with a smart, non-redundant year.
|
|
33
|
+
*
|
|
34
|
+
* Uses native `Intl…formatRange`, so the year collapses when both ends share
|
|
35
|
+
* it and stays on both ends when the range spans years:
|
|
36
|
+
* same month : 6–20 Aug 2025
|
|
37
|
+
* same year : 6 Aug – 20 Sep 2025
|
|
38
|
+
* multi-year : 6 Dec 2025 – 20 Jan 2026
|
|
39
|
+
*
|
|
40
|
+
* One-sided or same-day ranges fall back to a single `formatDate`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function formatDateRange(start: Date | string | number | null | undefined, end: Date | string | number | null | undefined, options?: FormatDateRangeOptions): string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type DateFormatPreset, formatDate, type FormatDateOptions } from './formatDate';
|
|
1
|
+
export { type DateFormatPreset, formatDate, type FormatDateOptions, formatDateRange, type FormatDateRangeOptions } from './formatDate';
|
|
2
2
|
export { useAntColorMode, type UseAntColorModeOptions, type UseAntColorModeReturn } from './useAntColorMode';
|
|
3
3
|
export { useAntI18n, type UseAntI18nReturn } from './useAntI18n';
|
|
4
4
|
export { useAppTourMode } from './useAppTourMode';
|
|
@@ -6,4 +6,5 @@ export { type UseCommsClient, useCommsClient } from './useCommsClient';
|
|
|
6
6
|
export { type CommsHostArgs, type UseCommsHost, useCommsHost } from './useCommsHost';
|
|
7
7
|
export { type UsePermissions, usePermissions } from './usePermissions';
|
|
8
8
|
export { useTemplateVersioning, type UseTemplateVersioningReturn } from './useTemplateVersioning';
|
|
9
|
+
export { useTriggerDispatch, type UseTriggerDispatchOptions, type UseTriggerDispatchReturn } from './useTriggerDispatch';
|
|
9
10
|
export { type AnyUseApiReturn, type CommsToolbar, useApi, type UseApiReturn, useCommsInjection, useSignal, useSingleton, } from './utils';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { TriggerDispatchResult } from '@antcde/connect-ts';
|
|
2
|
+
import { UseCommsClient } from './useCommsClient';
|
|
3
|
+
export interface UseTriggerDispatchOptions {
|
|
4
|
+
authorizationTimeoutMs?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface UseTriggerDispatchReturn {
|
|
7
|
+
dispatch: (run: () => Promise<TriggerDispatchResult>) => Promise<TriggerDispatchResult>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Wrap a trigger dispatch so a per-user OAuth2 "authorization required" outcome is
|
|
11
|
+
* handled transparently for iframe apps: on that outcome the helper asks the HOST
|
|
12
|
+
* (via the `oauthAuthorize` signal) to open the provider consent popup, awaits the
|
|
13
|
+
* host's `oauthAuthorizeResult`, and — when the user authorized — re-runs the
|
|
14
|
+
* dispatch exactly once. Any other outcome is returned unchanged.
|
|
15
|
+
*
|
|
16
|
+
* `run` is the caller's own dispatch invocation (e.g. a `useApi(...).execute`
|
|
17
|
+
* wrapper that resolves to the response body), so this composable stays decoupled
|
|
18
|
+
* from how the request is made and re-runs the identical call after consent.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const { dispatch } = useTriggerDispatch(comms)
|
|
22
|
+
* const call = useApi(connect.triggers.dispatch, null)
|
|
23
|
+
* const result = await dispatch(async () => {
|
|
24
|
+
* await call.execute(triggerableType, triggerableId, triggerId)
|
|
25
|
+
* return call.state.value
|
|
26
|
+
* })
|
|
27
|
+
*/
|
|
28
|
+
export declare function useTriggerDispatch(comms: UseCommsClient, options?: UseTriggerDispatchOptions): UseTriggerDispatchReturn;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antcde/vue-utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.22-rc.2",
|
|
5
5
|
"description": "Helper to use ANT Comms in Vue 3",
|
|
6
6
|
"author": "CollaborAll",
|
|
7
7
|
"exports": {
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
"vue-i18n": "^11.1.12"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@antcde/connect-ts": "0.4.
|
|
34
|
+
"@antcde/connect-ts": "0.4.27-rc.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@tsconfig/node22": "^22.0.5",
|
|
38
|
-
"@types/node": "^22.
|
|
39
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
38
|
+
"@types/node": "^22.20.1",
|
|
39
|
+
"@vitejs/plugin-vue": "^6.0.8",
|
|
40
40
|
"@vue/tsconfig": "^0.9.1",
|
|
41
41
|
"typescript": "~6.0.3",
|
|
42
|
-
"vite": "^8.
|
|
42
|
+
"vite": "^8.1.5",
|
|
43
43
|
"vite-plugin-dts": "^4.5.4",
|
|
44
|
-
"vue-tsc": "^3.3.
|
|
44
|
+
"vue-tsc": "^3.3.7"
|
|
45
45
|
}
|
|
46
46
|
}
|