@antcde/vue-utils 0.2.32-rc.1 → 0.2.32
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 +43 -23
- package/dist/types/index.d.ts +1 -0
- package/dist/types/useAppQueryParam.d.ts +8 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1971,23 +1971,43 @@ function En(e, t) {
|
|
|
1971
1971
|
return g(() => e.context.value.user?.language, (e) => n.locale.value = e ?? "en", { immediate: !0 }), n;
|
|
1972
1972
|
}
|
|
1973
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
|
|
1974
1994
|
//#region src/useAppTourMode.ts
|
|
1975
|
-
var
|
|
1976
|
-
function
|
|
1995
|
+
var kn = m(!1), An = m(null);
|
|
1996
|
+
function jn() {
|
|
1977
1997
|
function e(e) {
|
|
1978
1998
|
g(() => e.value.tourMode, (e) => {
|
|
1979
|
-
|
|
1999
|
+
kn.value = !!e, e || (An.value = null);
|
|
1980
2000
|
}, { immediate: !0 });
|
|
1981
2001
|
}
|
|
1982
2002
|
function t(e) {
|
|
1983
|
-
|
|
2003
|
+
kn.value && (An.value = e);
|
|
1984
2004
|
}
|
|
1985
2005
|
function n() {
|
|
1986
|
-
|
|
2006
|
+
kn.value = !1, An.value = null;
|
|
1987
2007
|
}
|
|
1988
2008
|
return {
|
|
1989
|
-
isActive: p(
|
|
1990
|
-
activeZoneId: p(
|
|
2009
|
+
isActive: p(kn),
|
|
2010
|
+
activeZoneId: p(An),
|
|
1991
2011
|
connectContext: e,
|
|
1992
2012
|
setActiveZone: t,
|
|
1993
2013
|
exit: n
|
|
@@ -1995,7 +2015,7 @@ function kn() {
|
|
|
1995
2015
|
}
|
|
1996
2016
|
//#endregion
|
|
1997
2017
|
//#region src/useCommsClient.ts
|
|
1998
|
-
function
|
|
2018
|
+
function Mn(t, n, r) {
|
|
1999
2019
|
let i = m({}), a = b({
|
|
2000
2020
|
parent: window.parent,
|
|
2001
2021
|
connect: t,
|
|
@@ -2004,17 +2024,17 @@ function An(t, n, r) {
|
|
|
2004
2024
|
get: () => o.value,
|
|
2005
2025
|
set: (e) => a.appState.set(e)
|
|
2006
2026
|
});
|
|
2007
|
-
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, [
|
|
2008
2028
|
"context",
|
|
2009
2029
|
"toolbar",
|
|
2010
2030
|
"appState"
|
|
2011
2031
|
]), {
|
|
2012
2032
|
context: i,
|
|
2013
|
-
toolbar:
|
|
2033
|
+
toolbar: Nn(a),
|
|
2014
2034
|
appState: c
|
|
2015
2035
|
});
|
|
2016
2036
|
}
|
|
2017
|
-
function
|
|
2037
|
+
function Nn(e) {
|
|
2018
2038
|
let t = m(""), n = {
|
|
2019
2039
|
title: s({
|
|
2020
2040
|
get: () => e.toolbar.get().title,
|
|
@@ -2067,13 +2087,13 @@ function jn(e) {
|
|
|
2067
2087
|
};
|
|
2068
2088
|
return e.toolbar.pipe(C((e) => e.search.input ?? ""), ae(), ie(300)).forEach((e) => t.value = e), n;
|
|
2069
2089
|
}
|
|
2070
|
-
function
|
|
2090
|
+
function Pn(e, t, n) {
|
|
2071
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();
|
|
2072
2092
|
return t.add(u), u.add(o(a, () => l.next({ hotkeys: { ctrl: !0 } }))), u.add(o(c, () => l.next({ hotkeys: { shift: !0 } }))), u;
|
|
2073
2093
|
}
|
|
2074
2094
|
//#endregion
|
|
2075
2095
|
//#region src/useCommsHost.ts
|
|
2076
|
-
function
|
|
2096
|
+
function Fn(e) {
|
|
2077
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({
|
|
2078
2098
|
...e,
|
|
2079
2099
|
contextChanges: n,
|
|
@@ -2114,12 +2134,12 @@ function Nn(e) {
|
|
|
2114
2134
|
}
|
|
2115
2135
|
//#endregion
|
|
2116
2136
|
//#region src/useFeature.ts
|
|
2117
|
-
function
|
|
2137
|
+
function In(e, t) {
|
|
2118
2138
|
return s(() => e.value?.features?.[t] === !0);
|
|
2119
2139
|
}
|
|
2120
2140
|
//#endregion
|
|
2121
2141
|
//#region src/usePermissions.ts
|
|
2122
|
-
function
|
|
2142
|
+
function Ln(e) {
|
|
2123
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);
|
|
2124
2144
|
function c(e) {
|
|
2125
2145
|
return !t.value || !n.value ? !1 : i.value || a.value ? !0 : (n.value.user_roles ?? []).some((t) => t.name === e);
|
|
@@ -2145,7 +2165,7 @@ function Fn(e) {
|
|
|
2145
2165
|
}
|
|
2146
2166
|
//#endregion
|
|
2147
2167
|
//#region src/useTemplateVersioning.ts
|
|
2148
|
-
function
|
|
2168
|
+
function Rn(e) {
|
|
2149
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);
|
|
2150
2170
|
async function b(n) {
|
|
2151
2171
|
c.value = !0;
|
|
@@ -2294,7 +2314,7 @@ function In(e) {
|
|
|
2294
2314
|
}
|
|
2295
2315
|
//#endregion
|
|
2296
2316
|
//#region src/useTriggerDispatch.ts
|
|
2297
|
-
function
|
|
2317
|
+
function zn(e, t = {}) {
|
|
2298
2318
|
let n = t.authorizationTimeoutMs ?? 3e5, r = /* @__PURE__ */ new Set();
|
|
2299
2319
|
d(() => {
|
|
2300
2320
|
for (let e of r) e();
|
|
@@ -2321,18 +2341,18 @@ function Ln(e, t = {}) {
|
|
|
2321
2341
|
}
|
|
2322
2342
|
//#endregion
|
|
2323
2343
|
//#region src/utils.ts
|
|
2324
|
-
function
|
|
2325
|
-
let [t, n] =
|
|
2344
|
+
function Bn(e = "comms") {
|
|
2345
|
+
let [t, n] = Vn(e, () => Mn(), (e) => e.unsubscribe());
|
|
2326
2346
|
return {
|
|
2327
2347
|
provideComms: t,
|
|
2328
2348
|
injectComms: n
|
|
2329
2349
|
};
|
|
2330
2350
|
}
|
|
2331
|
-
function
|
|
2351
|
+
function Vn(e, t, n) {
|
|
2332
2352
|
let r, i = () => (!r && (r = t()), r);
|
|
2333
2353
|
return [(t) => (t.onUnmount(() => n && r && n(r)), t.provide(e, i)), () => c(e)()];
|
|
2334
2354
|
}
|
|
2335
|
-
function
|
|
2355
|
+
function Hn(t, r, i) {
|
|
2336
2356
|
let a = n(t, r, {
|
|
2337
2357
|
immediate: !1,
|
|
2338
2358
|
...i
|
|
@@ -2342,9 +2362,9 @@ function Bn(t, r, i) {
|
|
|
2342
2362
|
executeDelayed: a.execute
|
|
2343
2363
|
});
|
|
2344
2364
|
}
|
|
2345
|
-
function
|
|
2365
|
+
function Un(e) {
|
|
2346
2366
|
let t, n = m(void 0);
|
|
2347
2367
|
return u(() => t = e.signal.receive((e) => n.value = e)), f(() => t?.()), [p(n), () => t?.()];
|
|
2348
2368
|
}
|
|
2349
2369
|
//#endregion
|
|
2350
|
-
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.32
|
|
4
|
+
"version": "0.2.32",
|
|
5
5
|
"description": "Helper to use ANT Comms in Vue 3",
|
|
6
6
|
"author": "CollaborAll",
|
|
7
7
|
"exports": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"vue-i18n": "^11.1.12"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@antcde/connect-ts": "0.4.37
|
|
36
|
+
"@antcde/connect-ts": "0.4.37",
|
|
37
37
|
"rrule": "^2.8.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|