@antcde/vue-utils 0.2.28-rc.1 → 0.2.28-rc.3
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
|
@@ -68,8 +68,32 @@ function I(e, t, n = {}) {
|
|
|
68
68
|
return new Intl.DateTimeFormat(i, j[u]).formatRange(c, l);
|
|
69
69
|
}
|
|
70
70
|
//#endregion
|
|
71
|
+
//#region src/taskPriority.ts
|
|
72
|
+
var L = [
|
|
73
|
+
"low",
|
|
74
|
+
"normal",
|
|
75
|
+
"high",
|
|
76
|
+
"urgent"
|
|
77
|
+
], R = {
|
|
78
|
+
low: "mdi-signal-cellular-1",
|
|
79
|
+
normal: "mdi-signal-cellular-2",
|
|
80
|
+
high: "mdi-signal-cellular-3",
|
|
81
|
+
urgent: "mdi-alert"
|
|
82
|
+
}, z = {
|
|
83
|
+
low: "blue-lighten-1",
|
|
84
|
+
normal: "green-lighten-1",
|
|
85
|
+
high: "yellow-lighten-1",
|
|
86
|
+
urgent: "red-lighten-1"
|
|
87
|
+
};
|
|
88
|
+
function ee(e) {
|
|
89
|
+
return R[e];
|
|
90
|
+
}
|
|
91
|
+
function B(e) {
|
|
92
|
+
return z[e];
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
71
95
|
//#region src/useAntColorMode.ts
|
|
72
|
-
function
|
|
96
|
+
function V(e, n) {
|
|
73
97
|
let i = r(n), a = s(() => e.context.value.darkMode), o = s(() => {
|
|
74
98
|
switch (a.value) {
|
|
75
99
|
case null: return "auto";
|
|
@@ -95,28 +119,28 @@ function L(e, n) {
|
|
|
95
119
|
}
|
|
96
120
|
//#endregion
|
|
97
121
|
//#region src/useAntI18n.ts
|
|
98
|
-
function
|
|
122
|
+
function H(e, t) {
|
|
99
123
|
let n = _(t);
|
|
100
124
|
return g(() => e.context.value.user?.language, (e) => n.locale.value = e ?? "en", { immediate: !0 }), n;
|
|
101
125
|
}
|
|
102
126
|
//#endregion
|
|
103
127
|
//#region src/useAppTourMode.ts
|
|
104
|
-
var
|
|
105
|
-
function
|
|
128
|
+
var U = m(!1), W = m(null);
|
|
129
|
+
function G() {
|
|
106
130
|
function e(e) {
|
|
107
131
|
g(() => e.value.tourMode, (e) => {
|
|
108
|
-
|
|
132
|
+
U.value = !!e, e || (W.value = null);
|
|
109
133
|
}, { immediate: !0 });
|
|
110
134
|
}
|
|
111
135
|
function t(e) {
|
|
112
|
-
|
|
136
|
+
U.value && (W.value = e);
|
|
113
137
|
}
|
|
114
138
|
function n() {
|
|
115
|
-
|
|
139
|
+
U.value = !1, W.value = null;
|
|
116
140
|
}
|
|
117
141
|
return {
|
|
118
|
-
isActive: p(
|
|
119
|
-
activeZoneId: p(
|
|
142
|
+
isActive: p(U),
|
|
143
|
+
activeZoneId: p(W),
|
|
120
144
|
connectContext: e,
|
|
121
145
|
setActiveZone: t,
|
|
122
146
|
exit: n
|
|
@@ -124,7 +148,7 @@ function V() {
|
|
|
124
148
|
}
|
|
125
149
|
//#endregion
|
|
126
150
|
//#region src/useCommsClient.ts
|
|
127
|
-
function
|
|
151
|
+
function K(t, n, r) {
|
|
128
152
|
let i = m({}), a = b({
|
|
129
153
|
parent: window.parent,
|
|
130
154
|
connect: t,
|
|
@@ -133,17 +157,17 @@ function H(t, n, r) {
|
|
|
133
157
|
get: () => o.value,
|
|
134
158
|
set: (e) => a.appState.set(e)
|
|
135
159
|
});
|
|
136
|
-
return a.context.subscribe((e) => i.value = e), w(a.appState.get(), a.appState).subscribe((e) => o.value = e),
|
|
160
|
+
return a.context.subscribe((e) => i.value = e), w(a.appState.get(), a.appState).subscribe((e) => o.value = e), J(a.signal, a, n), l(() => a.unsubscribe()), Object.assign(e(a, [
|
|
137
161
|
"context",
|
|
138
162
|
"toolbar",
|
|
139
163
|
"appState"
|
|
140
164
|
]), {
|
|
141
165
|
context: i,
|
|
142
|
-
toolbar:
|
|
166
|
+
toolbar: q(a),
|
|
143
167
|
appState: c
|
|
144
168
|
});
|
|
145
169
|
}
|
|
146
|
-
function
|
|
170
|
+
function q(e) {
|
|
147
171
|
let t = m(""), n = {
|
|
148
172
|
title: s({
|
|
149
173
|
get: () => e.toolbar.get().title,
|
|
@@ -196,13 +220,13 @@ function U(e) {
|
|
|
196
220
|
};
|
|
197
221
|
return e.toolbar.pipe(k((e) => e.search.input ?? ""), D(), E(300)).forEach((e) => t.value = e), n;
|
|
198
222
|
}
|
|
199
|
-
function
|
|
223
|
+
function J(e, t, n) {
|
|
200
224
|
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();
|
|
201
225
|
return t.add(u), u.add(o(a, () => l.next({ hotkeys: { ctrl: !0 } }))), u.add(o(c, () => l.next({ hotkeys: { shift: !0 } }))), u;
|
|
202
226
|
}
|
|
203
227
|
//#endregion
|
|
204
228
|
//#region src/useCommsHost.ts
|
|
205
|
-
function
|
|
229
|
+
function Y(e) {
|
|
206
230
|
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({
|
|
207
231
|
...e,
|
|
208
232
|
contextChanges: n,
|
|
@@ -242,8 +266,13 @@ function G(e) {
|
|
|
242
266
|
};
|
|
243
267
|
}
|
|
244
268
|
//#endregion
|
|
269
|
+
//#region src/useFeature.ts
|
|
270
|
+
function X(e, t) {
|
|
271
|
+
return s(() => e.value?.features?.[t] === !0);
|
|
272
|
+
}
|
|
273
|
+
//#endregion
|
|
245
274
|
//#region src/usePermissions.ts
|
|
246
|
-
function
|
|
275
|
+
function Z(e) {
|
|
247
276
|
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);
|
|
248
277
|
function c(e) {
|
|
249
278
|
return !t.value || !n.value ? !1 : i.value || a.value ? !0 : (n.value.user_roles ?? []).some((t) => t.name === e);
|
|
@@ -269,7 +298,7 @@ function K(e) {
|
|
|
269
298
|
}
|
|
270
299
|
//#endregion
|
|
271
300
|
//#region src/useTemplateVersioning.ts
|
|
272
|
-
function
|
|
301
|
+
function Q(e) {
|
|
273
302
|
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);
|
|
274
303
|
async function b(n) {
|
|
275
304
|
c.value = !0;
|
|
@@ -418,7 +447,7 @@ function q(e) {
|
|
|
418
447
|
}
|
|
419
448
|
//#endregion
|
|
420
449
|
//#region src/useTriggerDispatch.ts
|
|
421
|
-
function
|
|
450
|
+
function te(e, t = {}) {
|
|
422
451
|
let n = t.authorizationTimeoutMs ?? 3e5, r = /* @__PURE__ */ new Set();
|
|
423
452
|
d(() => {
|
|
424
453
|
for (let e of r) e();
|
|
@@ -445,18 +474,18 @@ function J(e, t = {}) {
|
|
|
445
474
|
}
|
|
446
475
|
//#endregion
|
|
447
476
|
//#region src/utils.ts
|
|
448
|
-
function
|
|
449
|
-
let [t, n] =
|
|
477
|
+
function ne(e = "comms") {
|
|
478
|
+
let [t, n] = $(e, () => K(), (e) => e.unsubscribe());
|
|
450
479
|
return {
|
|
451
480
|
provideComms: t,
|
|
452
481
|
injectComms: n
|
|
453
482
|
};
|
|
454
483
|
}
|
|
455
|
-
function
|
|
484
|
+
function $(e, t, n) {
|
|
456
485
|
let r, i = () => (!r && (r = t()), r);
|
|
457
486
|
return [(t) => (t.onUnmount(() => n && r && n(r)), t.provide(e, i)), () => c(e)()];
|
|
458
487
|
}
|
|
459
|
-
function
|
|
488
|
+
function re(t, r, i) {
|
|
460
489
|
let a = n(t, r, {
|
|
461
490
|
immediate: !1,
|
|
462
491
|
...i
|
|
@@ -466,9 +495,9 @@ function Z(t, r, i) {
|
|
|
466
495
|
executeDelayed: a.execute
|
|
467
496
|
});
|
|
468
497
|
}
|
|
469
|
-
function
|
|
498
|
+
function ie(e) {
|
|
470
499
|
let t, n = m(void 0);
|
|
471
500
|
return u(() => t = e.signal.receive((e) => n.value = e)), f(() => t?.()), [p(n), () => t?.()];
|
|
472
501
|
}
|
|
473
502
|
//#endregion
|
|
474
|
-
export { F as formatDate, I as formatDateRange,
|
|
503
|
+
export { L as TASK_PRIORITIES, F as formatDate, I as formatDateRange, B as taskPriorityColor, ee as taskPriorityIcon, V as useAntColorMode, H as useAntI18n, re as useApi, G as useAppTourMode, K as useCommsClient, Y as useCommsHost, ne as useCommsInjection, X as useFeature, Z as usePermissions, ie as useSignal, $ as useSingleton, Q as useTemplateVersioning, te as useTriggerDispatch };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export { type DateFormatPreset, formatDate, type FormatDateOptions, formatDateRange, type FormatDateRangeOptions } from './formatDate';
|
|
2
|
+
export { TASK_PRIORITIES, taskPriorityColor, taskPriorityIcon } from './taskPriority';
|
|
2
3
|
export { useAntColorMode, type UseAntColorModeOptions, type UseAntColorModeReturn } from './useAntColorMode';
|
|
3
4
|
export { useAntI18n, type UseAntI18nReturn } from './useAntI18n';
|
|
4
5
|
export { useAppTourMode } from './useAppTourMode';
|
|
5
6
|
export { type UseCommsClient, useCommsClient } from './useCommsClient';
|
|
6
7
|
export { type CommsHostArgs, type UseCommsHost, useCommsHost } from './useCommsHost';
|
|
8
|
+
export { useFeature } from './useFeature';
|
|
7
9
|
export { type UsePermissions, usePermissions } from './usePermissions';
|
|
8
10
|
export { useTemplateVersioning, type UseTemplateVersioningReturn } from './useTemplateVersioning';
|
|
9
11
|
export { useTriggerDispatch, type UseTriggerDispatchOptions, type UseTriggerDispatchReturn } from './useTriggerDispatch';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TaskPriority } from '@antcde/connect-ts';
|
|
2
|
+
export declare const TASK_PRIORITIES: readonly TaskPriority[];
|
|
3
|
+
/** An mdi icon name. */
|
|
4
|
+
export declare function taskPriorityIcon(priority: TaskPriority): string;
|
|
5
|
+
/** A Vuetify colour name, for `<v-icon :color>`. */
|
|
6
|
+
export declare function taskPriorityColor(priority: TaskPriority): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AntConnect, AppManifest, LabelFilterState, License, Notepad, Notification, ProjectShort, SignalObserverFactory, SignalReceiver, SignalSender, Task, User } from '@antcde/connect-ts';
|
|
1
|
+
import { AntConnect, AppManifest, FeatureFlags, 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';
|
|
@@ -23,6 +23,7 @@ export interface CommsHostArgs {
|
|
|
23
23
|
}>>;
|
|
24
24
|
darkMode: Ref<Nullable<boolean>>;
|
|
25
25
|
selectedLabels: Ref<LabelFilterState>;
|
|
26
|
+
features?: Ref<Nullable<FeatureFlags>>;
|
|
26
27
|
};
|
|
27
28
|
newSignalObserver: SignalObserverFactory;
|
|
28
29
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antcde/vue-utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.28-rc.
|
|
4
|
+
"version": "0.2.28-rc.3",
|
|
5
5
|
"description": "Helper to use ANT Comms in Vue 3",
|
|
6
6
|
"author": "CollaborAll",
|
|
7
7
|
"exports": {
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
"build": "pnpm clean && vite build",
|
|
23
23
|
"build:watch": "vite build --watch",
|
|
24
24
|
"type-check": "vue-tsc --noEmit",
|
|
25
|
+
"test": "vitest --run",
|
|
26
|
+
"test:watch": "vitest",
|
|
25
27
|
"clean": "pnpm dlx rimraf dist"
|
|
26
28
|
},
|
|
27
29
|
"peerDependencies": {
|
|
@@ -31,7 +33,7 @@
|
|
|
31
33
|
"vue-i18n": "^11.1.12"
|
|
32
34
|
},
|
|
33
35
|
"dependencies": {
|
|
34
|
-
"@antcde/connect-ts": "0.4.33-rc.
|
|
36
|
+
"@antcde/connect-ts": "0.4.33-rc.3"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
37
39
|
"@tsconfig/node22": "^22.0.6",
|
|
@@ -39,9 +41,11 @@
|
|
|
39
41
|
"@vitejs/plugin-vue": "^6.0.9",
|
|
40
42
|
"@vue/language-core": "^3.3.11",
|
|
41
43
|
"@vue/tsconfig": "^0.9.1",
|
|
44
|
+
"happy-dom": "^20.14.5",
|
|
42
45
|
"typescript": "~6.0.3",
|
|
43
46
|
"vite": "^8.3.0",
|
|
44
47
|
"vite-plugin-dts": "^5.1.1",
|
|
48
|
+
"vitest": "^5.0.1",
|
|
45
49
|
"vue-tsc": "^3.3.11"
|
|
46
50
|
}
|
|
47
51
|
}
|