@declarion/react 0.254.0 → 0.302.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.
Files changed (31) hide show
  1. package/dist-lib/components/actions/ResponsiveActionBar.js +255 -239
  2. package/dist-lib/components/detail-layout/DetailHighlights.js +40 -40
  3. package/dist-lib/components/detail-layout/EvidenceBlock.js +10 -9
  4. package/dist-lib/components/detail-layout/useQuickAdd.js +45 -47
  5. package/dist-lib/components/fields/EnumField.js +25 -25
  6. package/dist-lib/components/fields/JsonField.js +8 -5
  7. package/dist-lib/components/fields/cells/factories/badge.js +14 -27
  8. package/dist-lib/components/fields/cells/factories/statusPill.js +13 -26
  9. package/dist-lib/components/fields/cells/factories/tagList.js +13 -26
  10. package/dist-lib/components/pages/SmartDetailPage.impl.js +416 -415
  11. package/dist-lib/components/pages/auth/AuthShell.js +57 -76
  12. package/dist-lib/components/pages/list/ListCardRow.js +66 -66
  13. package/dist-lib/components/pages/list/columns.js +30 -30
  14. package/dist-lib/components/pages/profile/Profile.impl.js +130 -126
  15. package/dist-lib/components/pages/tenant-params/TenantParamsPage.impl.js +107 -109
  16. package/dist-lib/components/params/ParamsBlock.js +42 -37
  17. package/dist-lib/components/params/param-editors.js +20 -33
  18. package/dist-lib/components/primitives/Btn.js +3 -0
  19. package/dist-lib/components/primitives/IconBtn.js +2 -2
  20. package/dist-lib/components/primitives/Pill.js +36 -15
  21. package/dist-lib/components/shared/StatusGroupsDisplay.js +49 -49
  22. package/dist-lib/declarion-react.css +1 -1
  23. package/dist-lib/hooks/useDeclaredEnum.js +38 -0
  24. package/dist-lib/hooks/useResponsiveMode.js +1 -1
  25. package/dist-lib/index.d.ts +34 -12
  26. package/dist-lib/index.js +123 -122
  27. package/dist-lib/lib/evidence-verdict.js +8 -20
  28. package/dist-lib/lib/fill-from.js +15 -0
  29. package/dist-lib/testing.d.ts +1 -1
  30. package/dist-lib/{useResponsiveMode-DjoWkC2n.d.ts → useResponsiveMode-CBSHZBY5.d.ts} +3 -1
  31. package/package.json +1 -1
@@ -13,25 +13,12 @@ import { RetryButton as f } from "../primitives/RetryButton.js";
13
13
  import { useState as p } from "react";
14
14
  import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
15
15
  // src/components/params/param-editors.tsx
16
- var _ = {
17
- object: ["params.source.object", "Record"],
18
- user: ["params.source.user", "User"],
19
- role: ["params.source.role", "Role"],
20
- tenant: ["params.source.tenant", "Tenant"],
21
- env: ["params.source.env", "Environment"],
22
- yaml: ["params.source.yaml", "Default"],
23
- none: ["params.source.none", "Not set"]
24
- };
25
- function v(e, t) {
26
- let n = _[t];
27
- return n ? e(n[0], n[1]) : t;
28
- }
29
- var y = t["undo-2"];
30
- function b({ param: t, description: n, onReset: r }) {
16
+ var _ = t["undo-2"];
17
+ function v({ param: t, description: n, onReset: r }) {
31
18
  let a = d(), [o, s] = p(!1);
32
19
  return /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(e, {
33
20
  size: "xs",
34
- icon: /* @__PURE__ */ h(y, { size: 12 }),
21
+ icon: /* @__PURE__ */ h(_, { size: 12 }),
35
22
  onClick: () => s(!0),
36
23
  children: a("params.reset", "Reset to default")
37
24
  }), /* @__PURE__ */ h(i, {
@@ -43,7 +30,7 @@ function b({ param: t, description: n, onReset: r }) {
43
30
  onConfirm: () => r(t)
44
31
  })] });
45
32
  }
46
- function x({ text: e, onRetry: n }) {
33
+ function y({ text: e, onRetry: n }) {
47
34
  return /* @__PURE__ */ g("div", {
48
35
  style: {
49
36
  padding: "8px 10px",
@@ -62,14 +49,14 @@ function x({ text: e, onRetry: n }) {
62
49
  ]
63
50
  });
64
51
  }
65
- function S(e, t) {
52
+ function b(e, t) {
66
53
  let n = d(), { data: r } = c(), i = e.flatMap((e) => e.ref?.entity && e.value != null && e.value !== "" ? [{
67
54
  ref: e.ref,
68
55
  value: e.value
69
56
  }] : []), { refs: a } = s(i, t, r?.entities);
70
57
  return (e) => e.ref?.entity ? o(n, a, e.ref, e.value, r?.entities) : void 0;
71
58
  }
72
- function C({ type: e, value: t, values: n, structure: r, label: i, maxWidth: a = 180 }) {
59
+ function x({ type: e, value: t, values: n, structure: r, label: i, maxWidth: a = 180 }) {
73
60
  let o = d(), { data: s } = c(), l = (e) => {
74
61
  let t = n?.find((t) => t.code === e);
75
62
  return t && o(t.name) || u(e);
@@ -93,15 +80,15 @@ function C({ type: e, value: t, values: n, structure: r, label: i, maxWidth: a =
93
80
  children: p
94
81
  });
95
82
  }
96
- function w({ param: i, current: o, error: s, onCancel: c, onSave: l }) {
97
- let u = d(), [f, m] = p(() => E(i, o)), [_, v] = p(!1), [y, b] = p(null);
83
+ function S({ param: i, current: o, error: s, onCancel: c, onSave: l }) {
84
+ let u = d(), [f, m] = p(() => w(i, o)), [_, v] = p(!1), [b, x] = p(null);
98
85
  async function S() {
99
- b(null);
86
+ x(null);
100
87
  let e;
101
88
  try {
102
- e = D(u, f);
89
+ e = T(u, f);
103
90
  } catch (e) {
104
- b(String(e instanceof Error ? e.message : e));
91
+ x(String(e instanceof Error ? e.message : e));
105
92
  return;
106
93
  }
107
94
  v(!0);
@@ -144,12 +131,12 @@ function w({ param: i, current: o, error: s, onCancel: c, onSave: l }) {
144
131
  },
145
132
  children: [
146
133
  /* @__PURE__ */ h(n, { children: u("params.value", "Value") }),
147
- /* @__PURE__ */ h(T, {
134
+ /* @__PURE__ */ h(C, {
148
135
  param: i,
149
136
  value: f,
150
137
  onChange: m
151
138
  }),
152
- (y || s) && /* @__PURE__ */ h(x, { text: y || s })
139
+ (b || s) && /* @__PURE__ */ h(y, { text: b || s })
153
140
  ]
154
141
  }),
155
142
  /* @__PURE__ */ g("div", {
@@ -179,7 +166,7 @@ function w({ param: i, current: o, error: s, onCancel: c, onSave: l }) {
179
166
  ]
180
167
  });
181
168
  }
182
- function T({ param: e, value: t, onChange: n }) {
169
+ function C({ param: e, value: t, onChange: n }) {
183
170
  let r = d(), i = {
184
171
  type: e.type,
185
172
  structure: e.structure,
@@ -196,22 +183,22 @@ function T({ param: e, value: t, onChange: n }) {
196
183
  t: r
197
184
  }) });
198
185
  }
199
- function E(e, t) {
186
+ function w(e, t) {
200
187
  return e.type === "bool" ? t === !0 : e.type === "structure" ? t ?? (e.array ? [] : {}) : t ?? null;
201
188
  }
202
- function D(e, t) {
189
+ function T(e, t) {
203
190
  if (t == null) throw Error(e("params.value.required", "Enter a value."));
204
191
  return t;
205
192
  }
206
- var O = /* @__PURE__ */ new Set([
193
+ var E = /* @__PURE__ */ new Set([
207
194
  "server",
208
195
  "database",
209
196
  "auth",
210
197
  "sso",
211
198
  "seeder"
212
199
  ]);
213
- function k(e) {
200
+ function D(e) {
214
201
  let t = e.scopes ?? [];
215
- return t.length === 0 ? !O.has(e.category ?? "") : t.includes("tenant");
202
+ return t.length === 0 ? !E.has(e.category ?? "") : t.includes("tenant");
216
203
  }
217
- export { w as EditParamDialog, x as ErrorLine, b as ResetParamControl, C as ValuePreview, v as paramSourceName, k as paramTenantEditable, S as useParamRefLabels };
204
+ export { S as EditParamDialog, y as ErrorLine, v as ResetParamControl, x as ValuePreview, D as paramTenantEditable, b as useParamRefLabels };
@@ -8,6 +8,9 @@ var n = e(function({ kind: e = "default", size: n = "sm", icon: r, iconRight: i,
8
8
  gap: 6,
9
9
  height: n === "xs" ? 24 : n === "sm" ? 28 : n === "md" ? 32 : 36,
10
10
  padding: `0 ${n === "xs" ? 8 : n === "sm" ? 10 : n === "md" ? 12 : 14}px`,
11
+ minWidth: "var(--touch-target-min-size)",
12
+ minHeight: "var(--touch-target-min-size)",
13
+ justifyContent: "center",
11
14
  borderRadius: "var(--radius-md)",
12
15
  fontSize: n === "xs" ? 11.5 : 12.5,
13
16
  fontWeight: 500,
@@ -15,8 +15,8 @@ var n = e(function({ icon: e, onClick: n, title: r, size: i = 28, active: a, dis
15
15
  justifyContent: "center",
16
16
  width: i,
17
17
  height: i,
18
- minWidth: "var(--icon-button-min-size)",
19
- minHeight: "var(--icon-button-min-size)",
18
+ minWidth: "var(--touch-target-min-size)",
19
+ minHeight: "var(--touch-target-min-size)",
20
20
  borderRadius: "var(--radius-md)",
21
21
  border: "1px solid transparent",
22
22
  background: a ? "var(--surface-3)" : "transparent",
@@ -1,41 +1,62 @@
1
1
  import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
2
  // src/components/primitives/Pill.tsx
3
- function n(e) {
4
- return e == null || e === !1 || e === "" ? !1 : !Array.isArray(e) || e.some((e) => n(e));
3
+ var n = [
4
+ "indigo",
5
+ "emerald",
6
+ "amber",
7
+ "rose",
8
+ "sky",
9
+ "violet",
10
+ "slate",
11
+ "teal",
12
+ "blue",
13
+ "orange"
14
+ ], r = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
15
+ function i(e) {
16
+ return e && (n.includes(e) || r.test(e)) ? e : "slate";
5
17
  }
6
- function r({ tone: r = "slate", children: i, size: a = "sm", dot: o = !1, style: s }) {
7
- let c = `var(--pill-${r}-bg)`, l = `var(--pill-${r})`;
18
+ function a(e) {
19
+ return e.startsWith("#") ? `color-mix(in srgb, ${e} var(--pill-hex-fg-mix), var(--pill-hex-fg-base))` : `var(--pill-${e})`;
20
+ }
21
+ function o(e) {
22
+ return e.startsWith("#") ? `color-mix(in srgb, ${e} var(--pill-hex-bg-mix), transparent)` : `var(--pill-${e}-bg)`;
23
+ }
24
+ function s(e) {
25
+ return e == null || e === !1 || e === "" ? !1 : !Array.isArray(e) || e.some((e) => s(e));
26
+ }
27
+ function c({ tone: n = "slate", children: r, size: i = "sm", dot: c = !1, style: l }) {
28
+ let u = o(n), d = a(n);
8
29
  return /* @__PURE__ */ t("span", {
9
30
  className: "num",
10
31
  style: {
11
32
  display: "inline-flex",
12
33
  alignItems: "center",
13
34
  gap: 6,
14
- height: a === "sm" ? 20 : a === "xs" ? 16 : 24,
15
- padding: `0 ${a === "xs" ? 6 : 8}px`,
35
+ height: i === "sm" ? 20 : i === "xs" ? 16 : 24,
36
+ padding: `0 ${i === "xs" ? 6 : 8}px`,
16
37
  borderRadius: 999,
17
- background: c,
18
- color: l,
19
- fontSize: a === "xs" ? 10.5 : 11.5,
38
+ background: u,
39
+ color: d,
40
+ fontSize: i === "xs" ? 10.5 : 11.5,
20
41
  fontWeight: 500,
21
42
  whiteSpace: "nowrap",
22
43
  maxWidth: "100%",
23
- ...s
44
+ ...l
24
45
  },
25
- children: [o && /* @__PURE__ */ e("span", { style: {
46
+ children: [c && /* @__PURE__ */ e("span", { style: {
26
47
  width: 6,
27
48
  height: 6,
28
49
  borderRadius: 999,
29
- background: l
30
- } }), n(i) && /* @__PURE__ */ e("span", {
50
+ background: d
51
+ } }), s(r) && /* @__PURE__ */ e("span", {
31
52
  style: {
32
53
  minWidth: 0,
33
54
  overflow: "hidden",
34
55
  textOverflow: "ellipsis",
35
56
  whiteSpace: "nowrap"
36
57
  },
37
- children: i
58
+ children: r
38
59
  })]
39
60
  });
40
61
  }
41
- export { r as Pill };
62
+ export { n as PILL_TONES, c as Pill, i as pillColor, a as pillForeground };
@@ -1,122 +1,122 @@
1
- import { Pill as e } from "../primitives/Pill.js";
2
- import { Select as t } from "../primitives/Fields.js";
3
- import { StatusStepper as n } from "./StatusStepper.js";
4
- import { useText as r } from "../../hooks/useText.js";
5
- import { jsx as i, jsxs as a } from "react/jsx-runtime";
1
+ import { Pill as e, pillColor as t, pillForeground as n } from "../primitives/Pill.js";
2
+ import { Select as r } from "../primitives/Fields.js";
3
+ import { StatusStepper as i } from "./StatusStepper.js";
4
+ import { useText as a } from "../../hooks/useText.js";
5
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
6
6
  // src/components/shared/StatusGroupsDisplay.tsx
7
- function o({ statusGroups: o, objectStatuses: s, onSetStatus: c, isPending: l, mode: u = "edit" }) {
8
- let d = r();
9
- return /* @__PURE__ */ i("div", {
7
+ function c({ statusGroups: c, objectStatuses: l, onSetStatus: u, isPending: d, mode: f = "edit" }) {
8
+ let p = a();
9
+ return /* @__PURE__ */ o("div", {
10
10
  style: {
11
11
  display: "flex",
12
12
  flexWrap: "wrap",
13
13
  alignItems: "center",
14
14
  gap: 16
15
15
  },
16
- children: Object.entries(o).map(([r, o]) => {
17
- let f = s?.find((e) => e.group_code === r)?.status_code, p = f ? o.statuses.find((e) => e.code === f) : void 0;
18
- if (o.display_mode === "stepper") {
19
- let e = u === "edit", t = e ? o.transitions && f ? /* @__PURE__ */ new Set([f, ...o.transitions[f] ?? []]) : new Set(o.statuses.map((e) => e.code)) : void 0;
20
- return /* @__PURE__ */ a("div", {
16
+ children: Object.entries(c).map(([a, c]) => {
17
+ let m = l?.find((e) => e.group_code === a)?.status_code, h = m ? c.statuses.find((e) => e.code === m) : void 0;
18
+ if (c.display_mode === "stepper") {
19
+ let e = f === "edit", t = e ? c.transitions && m ? /* @__PURE__ */ new Set([m, ...c.transitions[m] ?? []]) : new Set(c.statuses.map((e) => e.code)) : void 0;
20
+ return /* @__PURE__ */ s("div", {
21
21
  style: {
22
22
  display: "flex",
23
23
  alignItems: "center",
24
24
  gap: 8,
25
25
  minWidth: 0
26
26
  },
27
- children: [/* @__PURE__ */ a("span", {
27
+ children: [/* @__PURE__ */ s("span", {
28
28
  style: {
29
29
  fontSize: 12,
30
30
  color: "var(--text-3)",
31
31
  flexShrink: 0
32
32
  },
33
- children: [d(o.name), ":"]
34
- }), /* @__PURE__ */ i("div", {
33
+ children: [p(c.name), ":"]
34
+ }), /* @__PURE__ */ o("div", {
35
35
  style: {
36
36
  minWidth: 240,
37
- opacity: l ? .6 : 1,
38
- pointerEvents: l ? "none" : "auto"
37
+ opacity: d ? .6 : 1,
38
+ pointerEvents: d ? "none" : "auto"
39
39
  },
40
- children: /* @__PURE__ */ i(n, {
41
- stages: o.statuses.map((e) => ({
40
+ children: /* @__PURE__ */ o(i, {
41
+ stages: c.statuses.map((e) => ({
42
42
  code: e.code,
43
- label: d(e.name)
43
+ label: p(e.name)
44
44
  })),
45
- current: f,
45
+ current: m,
46
46
  selectable: t,
47
- onSelect: e ? (e) => c(r, e) : void 0,
47
+ onSelect: e ? (e) => u(a, e) : void 0,
48
48
  compact: !0
49
49
  })
50
50
  })]
51
- }, r);
51
+ }, a);
52
52
  }
53
- if (u === "display") return /* @__PURE__ */ a("div", {
53
+ if (f === "display") return /* @__PURE__ */ s("div", {
54
54
  style: {
55
55
  display: "flex",
56
56
  alignItems: "center",
57
57
  gap: 8
58
58
  },
59
- children: [/* @__PURE__ */ a("span", {
59
+ children: [/* @__PURE__ */ s("span", {
60
60
  style: {
61
61
  fontSize: 12,
62
62
  color: "var(--text-3)"
63
63
  },
64
- children: [d(o.name), ":"]
65
- }), p ? /* @__PURE__ */ i(e, {
66
- tone: p.color ?? "slate",
64
+ children: [p(c.name), ":"]
65
+ }), h ? /* @__PURE__ */ o(e, {
66
+ tone: t(h.color),
67
67
  size: "xs",
68
- children: d(p.name)
69
- }) : /* @__PURE__ */ i("span", {
68
+ children: p(h.name)
69
+ }) : /* @__PURE__ */ o("span", {
70
70
  style: {
71
71
  fontSize: 12.5,
72
72
  color: "var(--text-4)"
73
73
  },
74
74
  children: "—"
75
75
  })]
76
- }, r);
77
- let m = (o.transitions && f ? o.statuses.filter((e) => e.code === f || (o.transitions[f]?.includes(e.code) ?? !1)) : o.statuses).map((e) => ({
76
+ }, a);
77
+ let g = (c.transitions && m ? c.statuses.filter((e) => e.code === m || (c.transitions[m]?.includes(e.code) ?? !1)) : c.statuses).map((e) => ({
78
78
  value: e.code,
79
- label: /* @__PURE__ */ a("span", {
79
+ label: /* @__PURE__ */ s("span", {
80
80
  style: {
81
81
  display: "inline-flex",
82
82
  alignItems: "center",
83
83
  gap: 6
84
84
  },
85
- children: [e.color && /* @__PURE__ */ i("span", { style: {
85
+ children: [e.color && /* @__PURE__ */ o("span", { style: {
86
86
  width: 8,
87
87
  height: 8,
88
88
  borderRadius: 999,
89
- background: `var(--pill-${e.color}, ${e.color})`,
89
+ background: n(t(e.color)),
90
90
  display: "inline-block"
91
- } }), d(e.name)]
91
+ } }), p(e.name)]
92
92
  })
93
93
  }));
94
- return /* @__PURE__ */ a("div", {
94
+ return /* @__PURE__ */ s("div", {
95
95
  style: {
96
96
  display: "flex",
97
97
  alignItems: "center",
98
98
  gap: 8
99
99
  },
100
- children: [/* @__PURE__ */ a("span", {
100
+ children: [/* @__PURE__ */ s("span", {
101
101
  style: {
102
102
  fontSize: 12,
103
103
  color: "var(--text-3)"
104
104
  },
105
- children: [d(o.name), ":"]
106
- }), /* @__PURE__ */ i("div", {
105
+ children: [p(c.name), ":"]
106
+ }), /* @__PURE__ */ o("div", {
107
107
  style: {
108
108
  minWidth: 180,
109
- opacity: l ? .6 : 1,
110
- pointerEvents: l ? "none" : "auto"
109
+ opacity: d ? .6 : 1,
110
+ pointerEvents: d ? "none" : "auto"
111
111
  },
112
- children: /* @__PURE__ */ i(t, {
113
- value: f ?? "",
114
- options: m,
115
- onChange: (e) => c(r, e)
112
+ children: /* @__PURE__ */ o(r, {
113
+ value: m ?? "",
114
+ options: g,
115
+ onChange: (e) => u(a, e)
116
116
  })
117
117
  })]
118
- }, r);
118
+ }, a);
119
119
  })
120
120
  });
121
121
  }
122
- export { o as StatusGroupsDisplay };
122
+ export { c as StatusGroupsDisplay };