@memobit/libs 4.1.0 → 4.2.0
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/components/Auth/WatchLinkModal/WatchLinkModal.css +1 -0
- package/dist/components/Auth/WatchLinkModal/WatchLinkModal2.js +127 -0
- package/dist/components/PageShell/PageParts.js +129 -120
- package/dist/components/PageShell/filterRules.js +28 -32
- package/dist/helpers/VersionInfo.js +1 -1
- package/dist/hooks/useAccountMenu.js +41 -30
- package/dist/index.d.ts +14 -1
- package/dist/index.js +174 -172
- package/dist/router.d.ts +1 -0
- package/dist/version.js +1 -1
- package/dist/version.json +4 -4
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { formatAppDate as d } from "../../helpers/Datetime.js";
|
|
2
|
-
var
|
|
2
|
+
var s = 4, v = 24, S = 10, k = 8, M = 14, c = (t) => typeof t == "string" || typeof t == "number", u = (t) => Array.isArray(t) ? t.filter(c) : [], f = (t) => c(t) && t !== "" ? t : null, x = (t) => typeof t == "number" ? t : 0, y = (t, n, e) => {
|
|
3
3
|
const [r, i] = u(t);
|
|
4
4
|
return [typeof r == "number" ? r : n, typeof i == "number" ? i : e];
|
|
5
|
-
},
|
|
5
|
+
}, $ = (t) => {
|
|
6
6
|
const [n, e] = u(t);
|
|
7
7
|
return [typeof n == "string" ? n : "", typeof e == "string" ? e : ""];
|
|
8
|
-
},
|
|
8
|
+
}, w = (t) => typeof t == "object" && t !== null && !Array.isArray(t), g = (t) => w(t) ? t : { text: "" }, C = (t, n) => t.wordMatch ? [{
|
|
9
9
|
value: "or",
|
|
10
10
|
label: n.anyWord
|
|
11
11
|
}, {
|
|
@@ -28,8 +28,8 @@ var A = 4, k = 24, v = 10, S = 8, M = 14, h = (t) => typeof t == "string" || typ
|
|
|
28
28
|
default:
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
31
|
-
},
|
|
32
|
-
if (t.defaultValue !== void 0) return
|
|
31
|
+
}, h = (t) => JSON.stringify(Array.isArray(t) ? [...t].map(String).sort() : t ?? null), b = (t, n) => {
|
|
32
|
+
if (t.defaultValue !== void 0) return h(n) !== h(t.defaultValue);
|
|
33
33
|
switch (t.kind) {
|
|
34
34
|
case "single":
|
|
35
35
|
case "date":
|
|
@@ -45,21 +45,16 @@ var A = 4, k = 24, v = 10, S = 8, M = 14, h = (t) => typeof t == "string" || typ
|
|
|
45
45
|
case "toggle":
|
|
46
46
|
return n === !0;
|
|
47
47
|
case "text":
|
|
48
|
-
return
|
|
48
|
+
return g(n).text.trim() !== "";
|
|
49
49
|
case "date-range":
|
|
50
|
-
return
|
|
50
|
+
return $(n).some((e) => e !== "");
|
|
51
51
|
}
|
|
52
|
-
},
|
|
52
|
+
}, _ = (t, n) => t.filter((e) => b(e, n[e.id])).length, m = (t, n) => t.find((e) => e.value === n)?.label ?? String(n), V = (t, n = 0) => t.length <= s && t.reduce((e, r) => e + r.length, n) <= v, D = (t, n) => {
|
|
53
53
|
if (t.kind !== "single" && t.kind !== "multi") return null;
|
|
54
54
|
if (t.control) return t.control;
|
|
55
55
|
const e = t.options.length;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const r = t.options.reduce((i, l) => i + l.label.length, 3);
|
|
59
|
-
return e <= A && r <= k ? "segmented" : n === "sheet" ? "chips" : "radio";
|
|
60
|
-
}
|
|
61
|
-
return e > M ? "search-list" : e <= S || n === "sheet" ? "chips" : "checklist";
|
|
62
|
-
}, V = (t, n, e) => {
|
|
56
|
+
return t.kind === "single" ? e > S ? "search-list" : V(t.options.map((r) => r.label), 3) ? "segmented" : n === "sheet" ? "chips" : "radio" : e > M ? "search-list" : e <= k || n === "sheet" ? "chips" : "checklist";
|
|
57
|
+
}, I = (t, n, e) => {
|
|
63
58
|
switch (t.kind) {
|
|
64
59
|
case "single": {
|
|
65
60
|
const r = f(n);
|
|
@@ -82,7 +77,7 @@ var A = 4, k = 24, v = 10, S = 8, M = 14, h = (t) => typeof t == "string" || typ
|
|
|
82
77
|
case "toggle":
|
|
83
78
|
return t.label;
|
|
84
79
|
case "text": {
|
|
85
|
-
const { text: r, mode: i } =
|
|
80
|
+
const { text: r, mode: i } = g(n), l = C(t, e), o = l && i !== l[0]?.value ? l.find((a) => a.value === i)?.label : void 0;
|
|
86
81
|
return o ? `“${r.trim()}” · ${o}` : `“${r.trim()}”`;
|
|
87
82
|
}
|
|
88
83
|
case "date": {
|
|
@@ -92,13 +87,13 @@ var A = 4, k = 24, v = 10, S = 8, M = 14, h = (t) => typeof t == "string" || typ
|
|
|
92
87
|
return t.relation === "until" ? e.dateUntil(i) : e.dateSince(i);
|
|
93
88
|
}
|
|
94
89
|
case "date-range": {
|
|
95
|
-
const [r, i] =
|
|
90
|
+
const [r, i] = $(n);
|
|
96
91
|
return r && i ? `${d(r)} – ${d(i)}` : r ? e.dateSince(d(r)) : i ? e.dateUntil(d(i)) : "";
|
|
97
92
|
}
|
|
98
93
|
}
|
|
99
|
-
},
|
|
94
|
+
}, F = (t, n, e) => t.flatMap((r) => {
|
|
100
95
|
const i = n[r.id];
|
|
101
|
-
if (
|
|
96
|
+
if (!b(r, i)) return [];
|
|
102
97
|
if (r.kind === "multi" && r.chips === "excluded") {
|
|
103
98
|
const o = u(i);
|
|
104
99
|
return r.options.filter((a) => !o.includes(a.value)).map((a) => ({
|
|
@@ -114,35 +109,36 @@ var A = 4, k = 24, v = 10, S = 8, M = 14, h = (t) => typeof t == "string" || typ
|
|
|
114
109
|
key: `${r.id}:${a}`,
|
|
115
110
|
filterId: r.id,
|
|
116
111
|
label: m(r.options, a),
|
|
117
|
-
next: o.filter((
|
|
112
|
+
next: o.filter((A) => A !== a)
|
|
118
113
|
}));
|
|
119
114
|
}
|
|
120
115
|
const l = r.kind === "text" ? {
|
|
121
|
-
...
|
|
116
|
+
...g(i),
|
|
122
117
|
text: ""
|
|
123
118
|
} : E(r);
|
|
124
119
|
return [{
|
|
125
120
|
key: r.id,
|
|
126
121
|
filterId: r.id,
|
|
127
|
-
label:
|
|
122
|
+
label: I(r, i, e),
|
|
128
123
|
next: l
|
|
129
124
|
}];
|
|
130
125
|
});
|
|
131
126
|
export {
|
|
132
|
-
|
|
127
|
+
_ as countActiveFilters,
|
|
133
128
|
E as defaultFilterValue,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
129
|
+
I as filterSummary,
|
|
130
|
+
V as fitsSegmented,
|
|
131
|
+
F as getAppliedFilters,
|
|
132
|
+
C as getTextModes,
|
|
133
|
+
b as isFilterActive,
|
|
134
|
+
c as isScalar,
|
|
135
|
+
w as isTextFilterValue,
|
|
140
136
|
m as optionLabel,
|
|
141
|
-
|
|
142
|
-
|
|
137
|
+
D as pickControl,
|
|
138
|
+
$ as toDateRange,
|
|
143
139
|
u as toList,
|
|
144
140
|
x as toNumber,
|
|
145
141
|
y as toRange,
|
|
146
142
|
f as toScalar,
|
|
147
|
-
|
|
143
|
+
g as toText
|
|
148
144
|
};
|
|
@@ -1,58 +1,69 @@
|
|
|
1
|
-
import { useAuth as
|
|
2
|
-
import { ChangePasswordModal as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { useAuth as L } from "./useAuth/useAuth.js";
|
|
2
|
+
import { ChangePasswordModal as v } from "../components/Auth/ChangePasswordModal/ChangePasswordModal2.js";
|
|
3
|
+
import { WatchLinkModal as I } from "../components/Auth/WatchLinkModal/WatchLinkModal2.js";
|
|
4
|
+
import { ThemeSettings as b } from "../components/ThemeSettings/ThemeSettings2.js";
|
|
5
|
+
import { useState as e } from "react";
|
|
6
|
+
import { Fragment as T, jsx as s, jsxs as P } from "react/jsx-runtime";
|
|
7
|
+
var S = ({ appName: f, mfaModal: o, watchLink: p = !1, themeLabel: h = "Theme", loginPath: u = "/login" }) => {
|
|
8
|
+
const { user: n, logout: k } = L(), [C, t] = e(!1), [g, a] = e(!1), [O, i] = e(!1), [w, l] = e(!1), c = p && !!n, d = async () => {
|
|
9
|
+
await k(), window.location.href = u;
|
|
10
|
+
}, r = {
|
|
11
|
+
label: h,
|
|
11
12
|
icon: "theme-picker",
|
|
12
13
|
onClick: () => t(!0),
|
|
13
14
|
isActive: !1,
|
|
14
15
|
separator: !0
|
|
15
|
-
},
|
|
16
|
+
}, m = [
|
|
16
17
|
{
|
|
17
18
|
label: "Change Password",
|
|
18
19
|
icon: "lock",
|
|
19
|
-
onClick: () =>
|
|
20
|
+
onClick: () => a(!0),
|
|
20
21
|
isActive: !1
|
|
21
22
|
},
|
|
22
|
-
...
|
|
23
|
+
...o ? [{
|
|
23
24
|
label: "Two-factor Authentication",
|
|
24
25
|
icon: "key",
|
|
25
|
-
onClick: () =>
|
|
26
|
+
onClick: () => i(!0),
|
|
27
|
+
isActive: !1
|
|
28
|
+
}] : [],
|
|
29
|
+
...c ? [{
|
|
30
|
+
label: "Link a watch",
|
|
31
|
+
icon: "link",
|
|
32
|
+
onClick: () => l(!0),
|
|
26
33
|
isActive: !1
|
|
27
34
|
}] : [],
|
|
28
35
|
{
|
|
29
|
-
label: `Logout ${
|
|
36
|
+
label: `Logout ${n?.username ?? ""}`.trim(),
|
|
30
37
|
icon: "logout",
|
|
31
|
-
onClick:
|
|
38
|
+
onClick: d,
|
|
32
39
|
isActive: !1
|
|
33
40
|
}
|
|
34
|
-
],
|
|
35
|
-
/* @__PURE__ */
|
|
36
|
-
isOpen:
|
|
41
|
+
], A = /* @__PURE__ */ P(T, { children: [
|
|
42
|
+
/* @__PURE__ */ s(b, {
|
|
43
|
+
isOpen: C,
|
|
37
44
|
onClose: () => t(!1),
|
|
38
|
-
currentApp:
|
|
45
|
+
currentApp: f
|
|
39
46
|
}),
|
|
40
|
-
/* @__PURE__ */
|
|
41
|
-
isOpen: h,
|
|
42
|
-
onClose: () => n(!1)
|
|
43
|
-
}),
|
|
44
|
-
e && /* @__PURE__ */ o(e, {
|
|
47
|
+
/* @__PURE__ */ s(v, {
|
|
45
48
|
isOpen: g,
|
|
46
49
|
onClose: () => a(!1)
|
|
50
|
+
}),
|
|
51
|
+
o && /* @__PURE__ */ s(o, {
|
|
52
|
+
isOpen: O,
|
|
53
|
+
onClose: () => i(!1)
|
|
54
|
+
}),
|
|
55
|
+
c && /* @__PURE__ */ s(I, {
|
|
56
|
+
isOpen: w,
|
|
57
|
+
onClose: () => l(!1)
|
|
47
58
|
})
|
|
48
59
|
] });
|
|
49
60
|
return {
|
|
50
|
-
themeItem:
|
|
51
|
-
accountItems:
|
|
52
|
-
items: [
|
|
53
|
-
modals:
|
|
61
|
+
themeItem: r,
|
|
62
|
+
accountItems: m,
|
|
63
|
+
items: [r, ...m],
|
|
64
|
+
modals: A
|
|
54
65
|
};
|
|
55
66
|
};
|
|
56
67
|
export {
|
|
57
|
-
|
|
68
|
+
S as useAccountMenu
|
|
58
69
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -4408,11 +4408,12 @@ export declare const UNALLOCATED_FILTER_KEY = "__unallocated__";
|
|
|
4408
4408
|
|
|
4409
4409
|
export declare const UNALLOCATED_FILTER_LABEL = "Unallocated";
|
|
4410
4410
|
|
|
4411
|
-
export declare const useAccountMenu: ({ appName, mfaModal: MfaModal, themeLabel, loginPath }: UseAccountMenuOptions) => UseAccountMenuReturn;
|
|
4411
|
+
export declare const useAccountMenu: ({ appName, mfaModal: MfaModal, watchLink, themeLabel, loginPath, }: UseAccountMenuOptions) => UseAccountMenuReturn;
|
|
4412
4412
|
|
|
4413
4413
|
export declare interface UseAccountMenuOptions {
|
|
4414
4414
|
appName: string;
|
|
4415
4415
|
mfaModal?: ComponentType<AccountMenuModalProps>;
|
|
4416
|
+
watchLink?: boolean;
|
|
4416
4417
|
themeLabel?: string;
|
|
4417
4418
|
loginPath?: string;
|
|
4418
4419
|
}
|
|
@@ -4638,6 +4639,18 @@ export declare interface VirtualListProps<T> {
|
|
|
4638
4639
|
rowClassName?: string;
|
|
4639
4640
|
}
|
|
4640
4641
|
|
|
4642
|
+
/**
|
|
4643
|
+
* Links a watch app (Garmin Connect IQ) to the signed-in account: the watch shows a 6-character
|
|
4644
|
+
* code, entering it here signs that watch in. Lists the linked watches so one can be signed out.
|
|
4645
|
+
* Talks to the framework's watch/* routes, which the app must route (see memobit-framework README).
|
|
4646
|
+
*/
|
|
4647
|
+
export declare function WatchLinkModal({ isOpen, onClose }: WatchLinkModalProps): ReactElement;
|
|
4648
|
+
|
|
4649
|
+
declare interface WatchLinkModalProps {
|
|
4650
|
+
isOpen: boolean;
|
|
4651
|
+
onClose: () => void;
|
|
4652
|
+
}
|
|
4653
|
+
|
|
4641
4654
|
export declare const WHtR: default_2.FC<WHtRProps>;
|
|
4642
4655
|
|
|
4643
4656
|
declare interface WHtRProps {
|