@antcde/vue-utils 0.2.28-rc.1 → 0.2.28-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 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 L(e, n) {
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 R(e, t) {
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 z = m(!1), B = m(null);
105
- function V() {
128
+ var U = m(!1), W = m(null);
129
+ function G() {
106
130
  function e(e) {
107
131
  g(() => e.value.tourMode, (e) => {
108
- z.value = !!e, e || (B.value = null);
132
+ U.value = !!e, e || (W.value = null);
109
133
  }, { immediate: !0 });
110
134
  }
111
135
  function t(e) {
112
- z.value && (B.value = e);
136
+ U.value && (W.value = e);
113
137
  }
114
138
  function n() {
115
- z.value = !1, B.value = null;
139
+ U.value = !1, W.value = null;
116
140
  }
117
141
  return {
118
- isActive: p(z),
119
- activeZoneId: p(B),
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 H(t, n, r) {
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), W(a.signal, a, n), l(() => a.unsubscribe()), Object.assign(e(a, [
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: U(a),
166
+ toolbar: q(a),
143
167
  appState: c
144
168
  });
145
169
  }
146
- function U(e) {
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 W(e, t, n) {
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 G(e) {
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 K(e) {
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 q(e) {
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 J(e, t = {}) {
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 Y(e = "comms") {
449
- let [t, n] = X(e, () => H(), (e) => e.unsubscribe());
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 X(e, t, n) {
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 Z(t, r, i) {
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 Q(e) {
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, 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 };
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 };
@@ -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
  }
@@ -0,0 +1,3 @@
1
+ import { Context } from '@antcde/connect-ts';
2
+ import { ComputedRef, Ref } from 'vue';
3
+ export declare function useFeature(context: Ref<Context>, name: string): ComputedRef<boolean>;
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.1",
4
+ "version": "0.2.28-rc.2",
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.33-rc.1"
34
+ "@antcde/connect-ts": "0.4.33-rc.2"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@tsconfig/node22": "^22.0.6",