@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.
@@ -1,11 +1,11 @@
1
1
  import { formatAppDate as d } from "../../helpers/Datetime.js";
2
- var A = 4, k = 24, v = 10, S = 8, M = 14, h = (t) => typeof t == "string" || typeof t == "number", u = (t) => Array.isArray(t) ? t.filter(h) : [], f = (t) => h(t) && t !== "" ? t : null, x = (t) => typeof t == "number" ? t : 0, y = (t, n, e) => {
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
- }, b = (t) => {
5
+ }, $ = (t) => {
6
6
  const [n, e] = u(t);
7
7
  return [typeof n == "string" ? n : "", typeof e == "string" ? e : ""];
8
- }, C = (t) => typeof t == "object" && t !== null && !Array.isArray(t), c = (t) => C(t) ? t : { text: "" }, w = (t, n) => t.wordMatch ? [{
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
- }, g = (t) => JSON.stringify(Array.isArray(t) ? [...t].map(String).sort() : t ?? null), $ = (t, n) => {
32
- if (t.defaultValue !== void 0) return g(n) !== g(t.defaultValue);
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 c(n).text.trim() !== "";
48
+ return g(n).text.trim() !== "";
49
49
  case "date-range":
50
- return b(n).some((e) => e !== "");
50
+ return $(n).some((e) => e !== "");
51
51
  }
52
- }, T = (t, n) => t.filter((e) => $(e, n[e.id])).length, m = (t, n) => t.find((e) => e.value === n)?.label ?? String(n), _ = (t, n) => {
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
- if (t.kind === "single") {
57
- if (e > v) return "search-list";
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 } = c(n), l = w(t, e), o = l && i !== l[0]?.value ? l.find((a) => a.value === i)?.label : void 0;
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] = b(n);
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
- }, D = (t, n, e) => t.flatMap((r) => {
94
+ }, F = (t, n, e) => t.flatMap((r) => {
100
95
  const i = n[r.id];
101
- if (!$(r, i)) return [];
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((s) => s !== a)
112
+ next: o.filter((A) => A !== a)
118
113
  }));
119
114
  }
120
115
  const l = r.kind === "text" ? {
121
- ...c(i),
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: V(r, i, e),
122
+ label: I(r, i, e),
128
123
  next: l
129
124
  }];
130
125
  });
131
126
  export {
132
- T as countActiveFilters,
127
+ _ as countActiveFilters,
133
128
  E as defaultFilterValue,
134
- V as filterSummary,
135
- D as getAppliedFilters,
136
- w as getTextModes,
137
- $ as isFilterActive,
138
- h as isScalar,
139
- C as isTextFilterValue,
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
- _ as pickControl,
142
- b as toDateRange,
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
- c as toText
143
+ g as toText
148
144
  };
@@ -23,7 +23,7 @@ var r = (i) => {
23
23
  const o = {
24
24
  ...i,
25
25
  lib: d,
26
- libBuildNumber: 683,
26
+ libBuildNumber: 688,
27
27
  libCommit: n,
28
28
  libBuildDate: t
29
29
  };
@@ -1,58 +1,69 @@
1
- import { useAuth as d } from "./useAuth/useAuth.js";
2
- import { ChangePasswordModal as w } from "../components/Auth/ChangePasswordModal/ChangePasswordModal2.js";
3
- import { ThemeSettings as A } from "../components/ThemeSettings/ThemeSettings2.js";
4
- import { useState as s } from "react";
5
- import { Fragment as k, jsx as o, jsxs as v } from "react/jsx-runtime";
6
- var j = ({ appName: l, mfaModal: e, themeLabel: c = "Theme", loginPath: m = "/login" }) => {
7
- const { user: u, logout: p } = d(), [f, t] = s(!1), [h, n] = s(!1), [g, a] = s(!1), C = async () => {
8
- await p(), window.location.href = m;
9
- }, i = {
10
- label: c,
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
- }, r = [
16
+ }, m = [
16
17
  {
17
18
  label: "Change Password",
18
19
  icon: "lock",
19
- onClick: () => n(!0),
20
+ onClick: () => a(!0),
20
21
  isActive: !1
21
22
  },
22
- ...e ? [{
23
+ ...o ? [{
23
24
  label: "Two-factor Authentication",
24
25
  icon: "key",
25
- onClick: () => a(!0),
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 ${u?.username ?? ""}`.trim(),
36
+ label: `Logout ${n?.username ?? ""}`.trim(),
30
37
  icon: "logout",
31
- onClick: C,
38
+ onClick: d,
32
39
  isActive: !1
33
40
  }
34
- ], O = /* @__PURE__ */ v(k, { children: [
35
- /* @__PURE__ */ o(A, {
36
- isOpen: f,
41
+ ], A = /* @__PURE__ */ P(T, { children: [
42
+ /* @__PURE__ */ s(b, {
43
+ isOpen: C,
37
44
  onClose: () => t(!1),
38
- currentApp: l
45
+ currentApp: f
39
46
  }),
40
- /* @__PURE__ */ o(w, {
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: i,
51
- accountItems: r,
52
- items: [i, ...r],
53
- modals: O
61
+ themeItem: r,
62
+ accountItems: m,
63
+ items: [r, ...m],
64
+ modals: A
54
65
  };
55
66
  };
56
67
  export {
57
- j as useAccountMenu
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 {