@antcde/vue-utils 0.2.31 → 0.2.32-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 +45 -33
- package/dist/types/index.d.ts +1 -0
- package/dist/types/useAppQueryParam.d.ts +8 -0
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -290,7 +290,7 @@ var Te = [
|
|
|
290
290
|
function M(e, t, n) {
|
|
291
291
|
n === void 0 && (n = " ");
|
|
292
292
|
var r = String(e);
|
|
293
|
-
return t
|
|
293
|
+
return t |= 0, r.length > t ? String(r) : (t -= r.length, t > n.length && (n += j(n, t / n.length)), n.slice(0, t) + String(r));
|
|
294
294
|
}
|
|
295
295
|
var Oe = function(e, t, n) {
|
|
296
296
|
var r = e.split(t);
|
|
@@ -1010,15 +1010,7 @@ function ut(e) {
|
|
|
1010
1010
|
else {
|
|
1011
1011
|
for (var o = [], s = [], n = 0; n < t.byweekday.length; n++) {
|
|
1012
1012
|
var c = t.byweekday[n];
|
|
1013
|
-
|
|
1014
|
-
o.push(c);
|
|
1015
|
-
continue;
|
|
1016
|
-
}
|
|
1017
|
-
if (Ee(c)) {
|
|
1018
|
-
o.push(E.fromStr(c).weekday);
|
|
1019
|
-
continue;
|
|
1020
|
-
}
|
|
1021
|
-
!c.n || t.freq > $.MONTHLY ? o.push(c.weekday) : s.push([c.weekday, c.n]);
|
|
1013
|
+
O(c) ? o.push(c) : Ee(c) ? o.push(E.fromStr(c).weekday) : !c.n || t.freq > $.MONTHLY ? o.push(c.weekday) : s.push([c.weekday, c.n]);
|
|
1022
1014
|
}
|
|
1023
1015
|
t.byweekday = F(o) ? o : null, t.bynweekday = F(s) ? s : null;
|
|
1024
1016
|
}
|
|
@@ -1979,23 +1971,43 @@ function En(e, t) {
|
|
|
1979
1971
|
return g(() => e.context.value.user?.language, (e) => n.locale.value = e ?? "en", { immediate: !0 }), n;
|
|
1980
1972
|
}
|
|
1981
1973
|
//#endregion
|
|
1974
|
+
//#region src/useAppQueryParam.ts
|
|
1975
|
+
function Dn(e) {
|
|
1976
|
+
let t = Array.isArray(e) ? e[0] : e;
|
|
1977
|
+
return typeof t == "string" && t !== "" ? t : null;
|
|
1978
|
+
}
|
|
1979
|
+
function On(e, t, n = {}) {
|
|
1980
|
+
let r = m(void 0), i = e.signal.receive((e) => {
|
|
1981
|
+
e.route?.query && (r.value = Dn(e.route.query[t]));
|
|
1982
|
+
});
|
|
1983
|
+
return d(i), s({
|
|
1984
|
+
get: () => r.value === void 0 ? Dn(e.context.value?.initialRouteQuery?.[t]) : r.value,
|
|
1985
|
+
set: (i) => {
|
|
1986
|
+
r.value = i, e.signal({ route: {
|
|
1987
|
+
query: { [t]: i },
|
|
1988
|
+
push: n.history === "push"
|
|
1989
|
+
} });
|
|
1990
|
+
}
|
|
1991
|
+
});
|
|
1992
|
+
}
|
|
1993
|
+
//#endregion
|
|
1982
1994
|
//#region src/useAppTourMode.ts
|
|
1983
|
-
var
|
|
1984
|
-
function
|
|
1995
|
+
var kn = m(!1), An = m(null);
|
|
1996
|
+
function jn() {
|
|
1985
1997
|
function e(e) {
|
|
1986
1998
|
g(() => e.value.tourMode, (e) => {
|
|
1987
|
-
|
|
1999
|
+
kn.value = !!e, e || (An.value = null);
|
|
1988
2000
|
}, { immediate: !0 });
|
|
1989
2001
|
}
|
|
1990
2002
|
function t(e) {
|
|
1991
|
-
|
|
2003
|
+
kn.value && (An.value = e);
|
|
1992
2004
|
}
|
|
1993
2005
|
function n() {
|
|
1994
|
-
|
|
2006
|
+
kn.value = !1, An.value = null;
|
|
1995
2007
|
}
|
|
1996
2008
|
return {
|
|
1997
|
-
isActive: p(
|
|
1998
|
-
activeZoneId: p(
|
|
2009
|
+
isActive: p(kn),
|
|
2010
|
+
activeZoneId: p(An),
|
|
1999
2011
|
connectContext: e,
|
|
2000
2012
|
setActiveZone: t,
|
|
2001
2013
|
exit: n
|
|
@@ -2003,7 +2015,7 @@ function kn() {
|
|
|
2003
2015
|
}
|
|
2004
2016
|
//#endregion
|
|
2005
2017
|
//#region src/useCommsClient.ts
|
|
2006
|
-
function
|
|
2018
|
+
function Mn(t, n, r) {
|
|
2007
2019
|
let i = m({}), a = b({
|
|
2008
2020
|
parent: window.parent,
|
|
2009
2021
|
connect: t,
|
|
@@ -2012,17 +2024,17 @@ function An(t, n, r) {
|
|
|
2012
2024
|
get: () => o.value,
|
|
2013
2025
|
set: (e) => a.appState.set(e)
|
|
2014
2026
|
});
|
|
2015
|
-
return a.context.subscribe((e) => i.value = e), ne(a.appState.get(), a.appState).subscribe((e) => o.value = e),
|
|
2027
|
+
return a.context.subscribe((e) => i.value = e), ne(a.appState.get(), a.appState).subscribe((e) => o.value = e), Pn(a.signal, a, n), l(() => a.unsubscribe()), Object.assign(e(a, [
|
|
2016
2028
|
"context",
|
|
2017
2029
|
"toolbar",
|
|
2018
2030
|
"appState"
|
|
2019
2031
|
]), {
|
|
2020
2032
|
context: i,
|
|
2021
|
-
toolbar:
|
|
2033
|
+
toolbar: Nn(a),
|
|
2022
2034
|
appState: c
|
|
2023
2035
|
});
|
|
2024
2036
|
}
|
|
2025
|
-
function
|
|
2037
|
+
function Nn(e) {
|
|
2026
2038
|
let t = m(""), n = {
|
|
2027
2039
|
title: s({
|
|
2028
2040
|
get: () => e.toolbar.get().title,
|
|
@@ -2075,13 +2087,13 @@ function jn(e) {
|
|
|
2075
2087
|
};
|
|
2076
2088
|
return e.toolbar.pipe(C((e) => e.search.input ?? ""), ae(), ie(300)).forEach((e) => t.value = e), n;
|
|
2077
2089
|
}
|
|
2078
|
-
function
|
|
2090
|
+
function Pn(e, t, n) {
|
|
2079
2091
|
let r = i(), a = r.ctrl ?? s(() => !1), c = r.shift ?? s(() => !1), l = new te(), u = l.pipe(re(n ?? ((e) => Promise.resolve(e))), re((t) => e(t))).subscribe();
|
|
2080
2092
|
return t.add(u), u.add(o(a, () => l.next({ hotkeys: { ctrl: !0 } }))), u.add(o(c, () => l.next({ hotkeys: { shift: !0 } }))), u;
|
|
2081
2093
|
}
|
|
2082
2094
|
//#endregion
|
|
2083
2095
|
//#region src/useCommsHost.ts
|
|
2084
|
-
function
|
|
2096
|
+
function Fn(e) {
|
|
2085
2097
|
let { context: t } = e, n = new x({}), r = (e) => n.next(e(n.value)), i = m(), o = new x(void 0), c = g(i, (e) => o.next(e), { immediate: !0 }), l = o.asObservable().pipe(C((e) => e?.contentWindow), S((e) => !!e)), u = ee({
|
|
2086
2098
|
...e,
|
|
2087
2099
|
contextChanges: n,
|
|
@@ -2122,12 +2134,12 @@ function Nn(e) {
|
|
|
2122
2134
|
}
|
|
2123
2135
|
//#endregion
|
|
2124
2136
|
//#region src/useFeature.ts
|
|
2125
|
-
function
|
|
2137
|
+
function In(e, t) {
|
|
2126
2138
|
return s(() => e.value?.features?.[t] === !0);
|
|
2127
2139
|
}
|
|
2128
2140
|
//#endregion
|
|
2129
2141
|
//#region src/usePermissions.ts
|
|
2130
|
-
function
|
|
2142
|
+
function Ln(e) {
|
|
2131
2143
|
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);
|
|
2132
2144
|
function c(e) {
|
|
2133
2145
|
return !t.value || !n.value ? !1 : i.value || a.value ? !0 : (n.value.user_roles ?? []).some((t) => t.name === e);
|
|
@@ -2153,7 +2165,7 @@ function Fn(e) {
|
|
|
2153
2165
|
}
|
|
2154
2166
|
//#endregion
|
|
2155
2167
|
//#region src/useTemplateVersioning.ts
|
|
2156
|
-
function
|
|
2168
|
+
function Rn(e) {
|
|
2157
2169
|
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);
|
|
2158
2170
|
async function b(n) {
|
|
2159
2171
|
c.value = !0;
|
|
@@ -2302,7 +2314,7 @@ function In(e) {
|
|
|
2302
2314
|
}
|
|
2303
2315
|
//#endregion
|
|
2304
2316
|
//#region src/useTriggerDispatch.ts
|
|
2305
|
-
function
|
|
2317
|
+
function zn(e, t = {}) {
|
|
2306
2318
|
let n = t.authorizationTimeoutMs ?? 3e5, r = /* @__PURE__ */ new Set();
|
|
2307
2319
|
d(() => {
|
|
2308
2320
|
for (let e of r) e();
|
|
@@ -2329,18 +2341,18 @@ function Ln(e, t = {}) {
|
|
|
2329
2341
|
}
|
|
2330
2342
|
//#endregion
|
|
2331
2343
|
//#region src/utils.ts
|
|
2332
|
-
function
|
|
2333
|
-
let [t, n] =
|
|
2344
|
+
function Bn(e = "comms") {
|
|
2345
|
+
let [t, n] = Vn(e, () => Mn(), (e) => e.unsubscribe());
|
|
2334
2346
|
return {
|
|
2335
2347
|
provideComms: t,
|
|
2336
2348
|
injectComms: n
|
|
2337
2349
|
};
|
|
2338
2350
|
}
|
|
2339
|
-
function
|
|
2351
|
+
function Vn(e, t, n) {
|
|
2340
2352
|
let r, i = () => (!r && (r = t()), r);
|
|
2341
2353
|
return [(t) => (t.onUnmount(() => n && r && n(r)), t.provide(e, i)), () => c(e)()];
|
|
2342
2354
|
}
|
|
2343
|
-
function
|
|
2355
|
+
function Hn(t, r, i) {
|
|
2344
2356
|
let a = n(t, r, {
|
|
2345
2357
|
immediate: !1,
|
|
2346
2358
|
...i
|
|
@@ -2350,9 +2362,9 @@ function Bn(t, r, i) {
|
|
|
2350
2362
|
executeDelayed: a.execute
|
|
2351
2363
|
});
|
|
2352
2364
|
}
|
|
2353
|
-
function
|
|
2365
|
+
function Un(e) {
|
|
2354
2366
|
let t, n = m(void 0);
|
|
2355
2367
|
return u(() => t = e.signal.receive((e) => n.value = e)), f(() => t?.()), [p(n), () => t?.()];
|
|
2356
2368
|
}
|
|
2357
2369
|
//#endregion
|
|
2358
|
-
export { pe as SCHEDULE_DAYS, bn as TASK_PRIORITIES, _e as browserZone, be as buildScheduleRule, ve as defaultScheduleSpec, we as describeRefresh, le as formatDate, ue as formatDateRange, fe as formatRefreshLabel, yn as nextOccurrences, Ce as parseScheduleRule, wn as taskPriorityColor, Cn as taskPriorityIcon, Tn as useAntColorMode, En as useAntI18n,
|
|
2370
|
+
export { pe as SCHEDULE_DAYS, bn as TASK_PRIORITIES, _e as browserZone, be as buildScheduleRule, ve as defaultScheduleSpec, we as describeRefresh, le as formatDate, ue as formatDateRange, fe as formatRefreshLabel, yn as nextOccurrences, Ce as parseScheduleRule, wn as taskPriorityColor, Cn as taskPriorityIcon, Tn as useAntColorMode, En as useAntI18n, Hn as useApi, On as useAppQueryParam, jn as useAppTourMode, Mn as useCommsClient, Fn as useCommsHost, Bn as useCommsInjection, In as useFeature, Ln as usePermissions, Un as useSignal, Vn as useSingleton, Rn as useTemplateVersioning, zn as useTriggerDispatch, ye as weekdayOf };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { nextOccurrences, type ScheduleOccurrence } from './refreshScheduleOccur
|
|
|
5
5
|
export { TASK_PRIORITIES, taskPriorityColor, taskPriorityIcon } from './taskPriority';
|
|
6
6
|
export { useAntColorMode, type UseAntColorModeOptions, type UseAntColorModeReturn } from './useAntColorMode';
|
|
7
7
|
export { useAntI18n, type UseAntI18nReturn } from './useAntI18n';
|
|
8
|
+
export { useAppQueryParam, type UseAppQueryParamOptions } from './useAppQueryParam';
|
|
8
9
|
export { useAppTourMode } from './useAppTourMode';
|
|
9
10
|
export { type UseCommsClient, useCommsClient } from './useCommsClient';
|
|
10
11
|
export { type CommsHostArgs, type UseCommsHost, useCommsHost } from './useCommsHost';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WritableComputedRef } from 'vue';
|
|
2
|
+
import { UseCommsClient } from './useCommsClient';
|
|
3
|
+
export interface UseAppQueryParamOptions {
|
|
4
|
+
/** `push` adds a browser history entry per change, so Back returns to the previous value. */
|
|
5
|
+
history?: 'push' | 'replace';
|
|
6
|
+
}
|
|
7
|
+
/** An OS URL query param this app owns, synced both ways: deep links, back/forward and task state replay. */
|
|
8
|
+
export declare function useAppQueryParam(comms: UseCommsClient, key: string, options?: UseAppQueryParamOptions): WritableComputedRef<string | null>;
|
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.32-rc.2",
|
|
5
5
|
"description": "Helper to use ANT Comms in Vue 3",
|
|
6
6
|
"author": "CollaborAll",
|
|
7
7
|
"exports": {
|
|
@@ -33,20 +33,20 @@
|
|
|
33
33
|
"vue-i18n": "^11.1.12"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@antcde/connect-ts": "0.4.
|
|
36
|
+
"@antcde/connect-ts": "0.4.37-rc.2",
|
|
37
37
|
"rrule": "^2.8.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@tsconfig/node22": "^22.0.6",
|
|
41
|
-
"@types/node": "^22.20.
|
|
42
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
43
|
-
"@vue/language-core": "^3.3.
|
|
41
|
+
"@types/node": "^22.20.5",
|
|
42
|
+
"@vitejs/plugin-vue": "^6.0.10",
|
|
43
|
+
"@vue/language-core": "^3.3.13",
|
|
44
44
|
"@vue/tsconfig": "^0.9.1",
|
|
45
|
-
"happy-dom": "^20.14.
|
|
45
|
+
"happy-dom": "^20.14.6",
|
|
46
46
|
"typescript": "~6.0.3",
|
|
47
|
-
"vite": "^8.3.
|
|
48
|
-
"vite-plugin-dts": "^5.1.
|
|
49
|
-
"vitest": "^5.0.
|
|
50
|
-
"vue-tsc": "^3.3.
|
|
47
|
+
"vite": "^8.3.4",
|
|
48
|
+
"vite-plugin-dts": "^5.1.2",
|
|
49
|
+
"vitest": "^5.0.4",
|
|
50
|
+
"vue-tsc": "^3.3.13"
|
|
51
51
|
}
|
|
52
52
|
}
|