@declarion/react 0.354.0 → 0.359.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.
@@ -0,0 +1,27 @@
1
+ import { Select as e } from "../primitives/Fields.js";
2
+ import { useSchema as t } from "../../hooks/useSchema.js";
3
+ import { useText as n } from "../../hooks/useText.js";
4
+ import { coerceDisplayString as r } from "../../lib/display-value.js";
5
+ import { errorOptions as i } from "../../lib/error-options.js";
6
+ import { EMPTY_CELL as a } from "./cells/factories/emptyCell.js";
7
+ import { Fragment as o, jsx as s } from "react/jsx-runtime";
8
+ // src/components/fields/ErrorField.tsx
9
+ var c = "__declarion_error_null__";
10
+ function l({ field: l, value: u, mode: d, onChange: f, fieldId: p, labelId: m, t: h }) {
11
+ let { data: g } = t(), _ = n("errors"), v = u != null && u !== "" ? r(u) : "";
12
+ if (d === "display") return v ? /* @__PURE__ */ s(o, { children: _(v, v) }) : a;
13
+ let y = [...l.required ? [] : [{
14
+ value: c,
15
+ label: h("field.enum.none", "— None —")
16
+ }], ...i(g?.errors, h)];
17
+ return /* @__PURE__ */ s(e, {
18
+ id: p,
19
+ "aria-labelledby": m,
20
+ "aria-required": l.required || void 0,
21
+ value: v || c,
22
+ options: y,
23
+ onChange: (e) => f?.(e === c ? null : e),
24
+ placeholder: h("field.select_placeholder", "Select…")
25
+ });
26
+ }
27
+ export { l as ErrorField };
@@ -1,32 +1,37 @@
1
1
  import { IconBtn as e } from "../primitives/IconBtn.js";
2
2
  import { Icon as t } from "../primitives/Icons.js";
3
- import { useText as n } from "../../hooks/useText.js";
4
- import { coerceDisplayString as r } from "../../lib/display-value.js";
5
- import { Suspense as i, lazy as a, useState as o } from "react";
6
- import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
3
+ import { useSchema as n } from "../../hooks/useSchema.js";
4
+ import { useText as r } from "../../hooks/useText.js";
5
+ import { coerceDisplayString as i } from "../../lib/display-value.js";
6
+ import { Suspense as a, lazy as o, useState as s } from "react";
7
+ import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
7
8
  // src/components/fields/JsonField.tsx
8
- var u = a(() => import("./JsonEditor.js").then((e) => ({ default: e.JsonEditor })));
9
- function d() {
10
- return /* @__PURE__ */ c("div", { className: "h-20 rounded-md border border-border bg-muted animate-pulse" });
9
+ var d = o(() => import("./JsonEditor.js").then((e) => ({ default: e.JsonEditor })));
10
+ function f() {
11
+ return /* @__PURE__ */ l("div", { className: "h-20 rounded-md border border-border bg-muted animate-pulse" });
11
12
  }
12
- function f(e) {
13
+ function p(e) {
13
14
  return e == null ? !0 : typeof e == "string" ? e.trim() === "" : Array.isArray(e) ? e.length === 0 : typeof e == "object" && Object.keys(e).length === 0;
14
15
  }
15
- function p(e) {
16
+ function m(e) {
16
17
  return Array.isArray(e) && e.every((e) => [
17
18
  "string",
18
19
  "number",
19
20
  "boolean"
20
21
  ].includes(typeof e));
21
22
  }
22
- function m({ value: e, mode: t, onChange: n, fieldId: r }) {
23
- return t === "display" ? f(e) ? /* @__PURE__ */ c("span", {
23
+ function h({ value: e, mode: t, onChange: n, fieldId: r, entityCode: i, fieldName: o }) {
24
+ let s = T(i, o);
25
+ return t === "display" ? p(e) ? /* @__PURE__ */ l("span", {
24
26
  style: {
25
27
  fontSize: 12.5,
26
28
  color: "var(--text-4)"
27
29
  },
28
30
  children: "—"
29
- }) : p(e) ? /* @__PURE__ */ c("ul", {
31
+ }) : s && typeof e == "object" && !Array.isArray(e) ? /* @__PURE__ */ l(D, {
32
+ value: e,
33
+ body: /* @__PURE__ */ l(E, { value: e })
34
+ }) : m(e) ? /* @__PURE__ */ l("ul", {
30
35
  className: "mono",
31
36
  style: {
32
37
  margin: 0,
@@ -35,17 +40,17 @@ function m({ value: e, mode: t, onChange: n, fieldId: r }) {
35
40
  fontSize: 12.5,
36
41
  lineHeight: 1.7
37
42
  },
38
- children: e.map((e, t) => /* @__PURE__ */ c("li", { children: String(e) }, t))
39
- }) : /* @__PURE__ */ c(S, { value: e }) : /* @__PURE__ */ c(i, {
40
- fallback: /* @__PURE__ */ c(d, {}),
41
- children: /* @__PURE__ */ c(u, {
43
+ children: e.map((e, t) => /* @__PURE__ */ l("li", { children: String(e) }, t))
44
+ }) : /* @__PURE__ */ l(D, { value: e }) : /* @__PURE__ */ l(a, {
45
+ fallback: /* @__PURE__ */ l(f, {}),
46
+ children: /* @__PURE__ */ l(d, {
42
47
  value: e,
43
48
  onChange: n,
44
49
  id: r
45
50
  })
46
51
  });
47
52
  }
48
- var h = {
53
+ var g = {
49
54
  display: "flex",
50
55
  flexDirection: "column",
51
56
  gap: 6,
@@ -53,72 +58,103 @@ var h = {
53
58
  borderRadius: "var(--radius-md)",
54
59
  padding: 12,
55
60
  background: "var(--surface-2)"
56
- }, g = {
61
+ }, _ = {
57
62
  display: "flex",
58
63
  flexDirection: "column",
59
64
  gap: 8
60
- }, _ = {
65
+ }, v = {
61
66
  display: "flex",
62
67
  flexWrap: "wrap",
63
68
  alignItems: "baseline",
64
69
  gap: 8
65
- }, v = {
70
+ }, y = {
66
71
  fontSize: 11.5,
67
72
  fontWeight: 500,
68
73
  color: "var(--text-3)",
69
74
  width: 120,
70
75
  flexShrink: 0,
71
76
  overflowWrap: "anywhere"
72
- }, y = {
73
- ...g,
77
+ }, b = {
78
+ ..._,
74
79
  paddingLeft: 10,
75
80
  borderLeft: "2px solid var(--border)"
76
- }, b = {
81
+ }, x = {
77
82
  minWidth: 0,
78
83
  flex: "1 1 14rem",
79
84
  fontSize: 12.5,
80
85
  overflowWrap: "anywhere"
81
- }, x = {
86
+ }, S = {
82
87
  display: "flex",
83
88
  justifyContent: "flex-end"
84
- };
85
- function S({ value: r }) {
86
- let a = n(), [s, f] = o(!1), p = s ? a("field.json.hide_source", "Hide JSON") : a("field.json.show_source", "Show JSON");
87
- return /* @__PURE__ */ l("div", {
88
- style: h,
89
- children: [/* @__PURE__ */ c("div", {
90
- style: x,
91
- children: /* @__PURE__ */ c(e, {
89
+ }, C = {
90
+ fontSize: 12.5,
91
+ fontWeight: 500
92
+ }, w = /* @__PURE__ */ new Set([
93
+ "type",
94
+ "status",
95
+ "title",
96
+ "detail",
97
+ "instance",
98
+ "retryable"
99
+ ]);
100
+ function T(e, t) {
101
+ let { data: r } = n(), i = e ? r?.entities[e] : void 0;
102
+ return i ? [...i.fields].some(([, e]) => e.type === "error" && e.source === `$row.${t}.type`) : !1;
103
+ }
104
+ function E({ value: e }) {
105
+ let t = r("errors"), n = typeof e.type == "string" ? e.type : "", i = n.startsWith("/errors/") ? n.slice(8) : n, a = Object.fromEntries(Object.entries(e).filter(([e]) => !w.has(e)));
106
+ return /* @__PURE__ */ u("div", {
107
+ style: _,
108
+ children: [
109
+ i ? /* @__PURE__ */ l("span", {
110
+ style: C,
111
+ children: t(i, i)
112
+ }) : null,
113
+ typeof e.detail == "string" && e.detail ? /* @__PURE__ */ l("span", {
114
+ style: x,
115
+ children: e.detail
116
+ }) : null,
117
+ Object.keys(a).length > 0 ? /* @__PURE__ */ l(O, { value: a }) : null
118
+ ]
119
+ });
120
+ }
121
+ function D({ value: n, body: i }) {
122
+ let o = r(), [c, p] = s(!1), m = c ? o("field.json.hide_source", "Hide JSON") : o("field.json.show_source", "Show JSON");
123
+ return /* @__PURE__ */ u("div", {
124
+ style: g,
125
+ children: [/* @__PURE__ */ l("div", {
126
+ style: S,
127
+ children: /* @__PURE__ */ l(e, {
92
128
  size: 22,
93
- icon: /* @__PURE__ */ c(t.code, { size: 13 }),
129
+ icon: /* @__PURE__ */ l(t.code, { size: 13 }),
94
130
  onClick: (e) => {
95
- e.stopPropagation(), f((e) => !e);
131
+ e.stopPropagation(), p((e) => !e);
96
132
  },
97
- title: p,
98
- "aria-label": p,
99
- "aria-pressed": s
133
+ title: m,
134
+ "aria-label": m,
135
+ "aria-pressed": c
100
136
  })
101
- }), s ? /* @__PURE__ */ c(i, {
102
- fallback: /* @__PURE__ */ c(d, {}),
103
- children: /* @__PURE__ */ c(u, {
104
- value: r,
137
+ }), c ? /* @__PURE__ */ l(a, {
138
+ fallback: /* @__PURE__ */ l(f, {}),
139
+ children: /* @__PURE__ */ l(d, {
140
+ value: n,
105
141
  readOnly: !0
106
142
  })
107
- }) : /* @__PURE__ */ c(w, { value: r })]
143
+ }) : i ?? /* @__PURE__ */ l(k, { value: n })]
108
144
  });
109
145
  }
110
- function C({ value: e, nested: t }) {
146
+ function O({ value: e, nested: t }) {
111
147
  let n = Array.isArray(e) ? e.map((e, t) => [String(t + 1), e]) : Object.entries(e);
112
- return /* @__PURE__ */ c("div", {
113
- style: t ? y : g,
114
- children: n.map(([e, t]) => /* @__PURE__ */ l("div", {
115
- style: _,
116
- children: [/* @__PURE__ */ c("span", {
117
- style: v,
148
+ return /* @__PURE__ */ l("div", {
149
+ style: t ? b : _,
150
+ children: n.map(([e, t]) => /* @__PURE__ */ u("div", {
151
+ style: v,
152
+ children: [/* @__PURE__ */ l("span", {
153
+ style: y,
118
154
  children: e
119
- }), /* @__PURE__ */ c("div", {
120
- style: b,
121
- children: /* @__PURE__ */ c(w, {
155
+ }), /* @__PURE__ */ l("div", {
156
+ style: x,
157
+ children: /* @__PURE__ */ l(k, {
122
158
  value: t,
123
159
  nested: !0
124
160
  })
@@ -126,13 +162,21 @@ function C({ value: e, nested: t }) {
126
162
  }, e))
127
163
  });
128
164
  }
129
- function w({ value: e, nested: t }) {
130
- return f(e) ? /* @__PURE__ */ c("span", {
165
+ function k({ value: e, nested: t }) {
166
+ let n = r();
167
+ return p(e) ? /* @__PURE__ */ l("span", {
131
168
  style: { color: "var(--text-4)" },
132
169
  children: "—"
133
- }) : p(e) ? /* @__PURE__ */ c(s, { children: e.map(String).join(", ") }) : typeof e == "object" ? /* @__PURE__ */ c(C, {
170
+ }) : m(e) ? /* @__PURE__ */ l(c, { children: e.map((e) => A(e, n.language)).join(", ") }) : typeof e == "object" ? /* @__PURE__ */ l(O, {
134
171
  value: e,
135
172
  nested: t
136
- }) : /* @__PURE__ */ c(s, { children: r(e) });
173
+ }) : /* @__PURE__ */ l(c, { children: A(e, n.language) });
174
+ }
175
+ function A(e, t) {
176
+ if (typeof e == "number" && Number.isFinite(e) && !Number.isInteger(e)) {
177
+ let n = Math.abs(e) < 1 ? { maximumSignificantDigits: 4 } : { maximumFractionDigits: 4 };
178
+ return new Intl.NumberFormat(t, n).format(e);
179
+ }
180
+ return i(e);
137
181
  }
138
- export { m as JsonField, f as isEmptyJsonValue };
182
+ export { h as JsonField, p as isEmptyJsonValue };
@@ -0,0 +1,11 @@
1
+ import { useText as e } from "../../../../hooks/useText.js";
2
+ import { coerceDisplayString as t } from "../../../../lib/display-value.js";
3
+ import { EMPTY_CELL as n } from "./emptyCell.js";
4
+ import { Fragment as r, jsx as i } from "react/jsx-runtime";
5
+ // src/components/fields/cells/factories/errorTitle.tsx
6
+ function a({ code: t }) {
7
+ let n = e("errors");
8
+ return /* @__PURE__ */ i(r, { children: n(t, t) });
9
+ }
10
+ var o = () => (e) => e == null || e === "" ? n : /* @__PURE__ */ i(a, { code: t(e) });
11
+ export { o as errorFactory };
@@ -50,6 +50,7 @@ var d = (e) => {
50
50
  }
51
51
  return /* @__PURE__ */ i(t, {
52
52
  field: e.field,
53
+ entityCode: e.entityCode,
53
54
  fieldName: e.fieldName,
54
55
  value: s,
55
56
  mode: "display",
@@ -21,8 +21,9 @@ import { passwordMaskFactory as x } from "./factories/passwordMask.js";
21
21
  import { richTextPreviewFactory as S } from "./factories/richTextPreview.js";
22
22
  import { multilangInlineFactory as C } from "./factories/multilangInline.js";
23
23
  import { fileReferenceFactory as w } from "./factories/fileReference.js";
24
+ import { errorFactory as T } from "./factories/errorTitle.js";
24
25
  // src/components/fields/cells/registry.ts
25
- var T = {
26
+ var E = {
26
27
  text: e,
27
28
  bool_pill: t,
28
29
  badge: n,
@@ -48,12 +49,13 @@ var T = {
48
49
  markdown: b,
49
50
  password_mask: x,
50
51
  rich_text_preview: S,
51
- multilang_inline: C
52
+ multilang_inline: C,
53
+ error: T
52
54
  };
53
- Object.keys(T).sort();
54
- function E(e) {
55
- let t = e.field.display?.widget ?? "text", n = T[t];
55
+ Object.keys(E).sort();
56
+ function D(e) {
57
+ let t = e.field.display?.widget ?? "text", n = E[t];
56
58
  if (!n) throw Error(`resolveCellRenderer: no factory registered for widget "${t}" (field "${e.fieldName}"). The engine must stamp a smart default at YAML-load time; an unknown widget here indicates an out-of-sync allow-list.`);
57
59
  return n(e);
58
60
  }
59
- export { E as resolveCellRenderer };
61
+ export { D as resolveCellRenderer };
@@ -2,69 +2,71 @@ import { FIELD_TYPES as e } from "../../types/fieldType.js";
2
2
  import { StringField as t } from "./StringField.js";
3
3
  import { TextField as n } from "./TextField.js";
4
4
  import { EnumField as r } from "./EnumField.js";
5
- import { EmailField as i } from "./EmailField.js";
6
- import { UrlField as a } from "./UrlField.js";
7
- import { PhoneField as o } from "./PhoneField.js";
8
- import { TimestampField as s } from "./TimestampField.js";
9
- import { BoolField as c } from "./BoolField.js";
10
- import { NumberField as l } from "./NumberField.js";
11
- import { RefField as u } from "./RefField.js";
12
- import { JsonField as d } from "./JsonField.js";
13
- import { MultilangField as f } from "./MultilangField.js";
14
- import { MultilangTextField as p } from "./MultilangTextField.js";
15
- import { MultilangArrayField as m } from "./MultilangArrayField.js";
16
- import { StructureField as h } from "./StructureField.js";
17
- import { SecretField as g } from "./SecretField.js";
18
- import { PasswordField as _ } from "./PasswordField.js";
19
- import { StringArrayField as v } from "./StringArrayField.js";
20
- import { IntArrayField as y } from "./IntArrayField.js";
21
- import { RichTextField as b } from "./RichTextField.js";
22
- import { FileReferenceField as x } from "./FileReferenceField.js";
23
- import { resolveCellRenderer as S } from "./cells/registry.js";
24
- import { jsx as C } from "react/jsx-runtime";
5
+ import { ErrorField as i } from "./ErrorField.js";
6
+ import { EmailField as a } from "./EmailField.js";
7
+ import { UrlField as o } from "./UrlField.js";
8
+ import { PhoneField as s } from "./PhoneField.js";
9
+ import { TimestampField as c } from "./TimestampField.js";
10
+ import { BoolField as l } from "./BoolField.js";
11
+ import { NumberField as u } from "./NumberField.js";
12
+ import { RefField as d } from "./RefField.js";
13
+ import { JsonField as f } from "./JsonField.js";
14
+ import { MultilangField as p } from "./MultilangField.js";
15
+ import { MultilangTextField as m } from "./MultilangTextField.js";
16
+ import { MultilangArrayField as h } from "./MultilangArrayField.js";
17
+ import { StructureField as g } from "./StructureField.js";
18
+ import { SecretField as _ } from "./SecretField.js";
19
+ import { PasswordField as v } from "./PasswordField.js";
20
+ import { StringArrayField as y } from "./StringArrayField.js";
21
+ import { IntArrayField as b } from "./IntArrayField.js";
22
+ import { RichTextField as x } from "./RichTextField.js";
23
+ import { FileReferenceField as S } from "./FileReferenceField.js";
24
+ import { resolveCellRenderer as C } from "./cells/registry.js";
25
+ import { jsx as w } from "react/jsx-runtime";
25
26
  // src/components/fields/index.tsx
26
- var w = {
27
+ var T = {
27
28
  string: t,
28
29
  text: n,
29
- rich_text: b,
30
- int: l,
31
- float: l,
32
- decimal: l,
33
- bool: c,
34
- timestamp: s,
35
- date: s,
36
- time: s,
30
+ rich_text: x,
31
+ int: u,
32
+ float: u,
33
+ decimal: u,
34
+ bool: l,
35
+ timestamp: c,
36
+ date: c,
37
+ time: c,
37
38
  enum: r,
38
- email: i,
39
- url: a,
40
- phone: o,
39
+ error: i,
40
+ email: a,
41
+ url: o,
42
+ phone: s,
41
43
  uuid: t,
42
44
  bytes: t,
43
- ref: u,
44
- file_ref: x,
45
+ ref: d,
46
+ file_ref: S,
45
47
  folder_ref: t,
46
- json: d,
48
+ json: f,
47
49
  tags: t,
48
- string_array: v,
49
- int_array: y,
50
- uuid_array: v,
51
- multilang: f,
52
- multilang_text: p,
53
- multilang_array: m,
54
- structure: h,
55
- secret: g,
56
- password: _
50
+ string_array: y,
51
+ int_array: b,
52
+ uuid_array: y,
53
+ multilang: p,
54
+ multilang_text: m,
55
+ multilang_array: h,
56
+ structure: g,
57
+ secret: _,
58
+ password: v
57
59
  };
58
- for (let t of e) if (!w[t]) throw Error(`editRegistry: missing entry for FieldType "${t}". The FieldType union and editRegistry must cover every field type the server declares.`);
59
- function T(e) {
60
- if (e.field.type === "json" && e.field.structure) return /* @__PURE__ */ C(h, { ...e });
60
+ for (let t of e) if (!T[t]) throw Error(`editRegistry: missing entry for FieldType "${t}". The FieldType union and editRegistry must cover every field type the server declares.`);
61
+ function E(e) {
62
+ if (e.field.type === "json" && e.field.structure) return /* @__PURE__ */ w(g, { ...e });
61
63
  if (e.mode === "edit") {
62
- let t = w[e.field.type];
64
+ let t = T[e.field.type];
63
65
  if (!t) throw Error(`renderField: no edit-mode renderer for FieldType "${e.field.type}" (field "${e.fieldName}"). editRegistry must be total over FieldType; check types/fieldType.ts and components/fields/index.tsx.`);
64
- return /* @__PURE__ */ C(t, { ...e });
66
+ return /* @__PURE__ */ w(t, { ...e });
65
67
  }
66
68
  if (!e.field.display?.widget) throw Error(`renderField: display mode requires a non-empty field.display.widget (field "${e.fieldName}", type "${e.field.type}"). The engine must stamp a smart default; an empty widget here means the field bypassed ResolveDefaultWidgets.`);
67
- return S({
69
+ return C({
68
70
  field: e.field,
69
71
  fieldName: e.fieldName,
70
72
  surface: e.surface ?? "detail",
@@ -77,4 +79,4 @@ function T(e) {
77
79
  detailScreen: e.detailScreen
78
80
  })(e.value, e.record ?? {});
79
81
  }
80
- export { w as editRegistry, T as renderField };
82
+ export { T as editRegistry, E as renderField };
@@ -20,43 +20,43 @@ var w = {
20
20
  tab: "Tab",
21
21
  esc: "Esc"
22
22
  };
23
- function T({ entity: T, entityCode: D, record: O, title: k, recordId: A, avatarName: j, fields: M, refs: N, screen: P, actions: F, screenActionLayout: I, entityActionLayout: L, executeAction: R, onClose: z, onOpen: B, onSave: V }) {
24
- let H = p(), U = m(T), [W, G] = b({ ...O }), [K, q] = b(!1);
25
- h(K);
26
- let J = y(null), { run: Y } = a(), X = d(T, P, W);
23
+ function T({ entity: T, entityCode: D, record: O, title: k, recordId: A, avatarName: j, fields: M, refs: N, screen: te, actions: P, screenActionLayout: F, entityActionLayout: I, executeAction: L, onClose: R, onOpen: z, onSave: B }) {
24
+ let V = p(), H = m(T), [U, W] = b({ ...O }), [G, K] = b(!1);
25
+ h(G);
26
+ let q = y(null), { run: J } = a(), Y = d(T, te, U);
27
27
  _(() => {
28
- G({ ...O }), q(!1);
28
+ W({ ...O }), K(!1);
29
29
  }, [O]), _(() => {
30
- J.current?.focus();
30
+ q.current?.focus();
31
31
  }, []);
32
- let Z = v(() => {
33
- let e = X?.action_layout ?? I ?? L ?? c(F, "quick_peek"), t = l(e, F, void 0, "quick_peek");
34
- return s(H, t, F, void 0, W, [], U, f(T, W));
32
+ let X = v(() => {
33
+ let e = Y?.action_layout ?? F ?? I ?? c(P, "quick_peek"), t = l(e, P, void 0, "quick_peek");
34
+ return s(V, t, P, void 0, U, [], H, f(T, U));
35
35
  }, [
36
- H,
37
- X?.action_layout,
38
- I,
39
- L,
36
+ V,
37
+ Y?.action_layout,
40
38
  F,
41
- W,
39
+ I,
40
+ P,
41
+ U,
42
42
  T,
43
- U
44
- ]), Q = ({ code: e, action: t }) => {
45
- Y({
43
+ H
44
+ ]), Z = ({ code: e, action: t }) => {
45
+ J({
46
46
  action: t,
47
- title: H(t.display?.name) || e,
48
- row: W,
49
- execute: (n) => R(e, t, n)
47
+ title: V(t.display?.name) || e,
48
+ row: U,
49
+ execute: (n) => L(e, t, n)
50
50
  });
51
- }, $ = (e, t) => {
51
+ }, Q = (e, t) => {
52
52
  let n = {
53
- ...W,
53
+ ...U,
54
54
  [e]: t
55
55
  };
56
- G(n), q(!0), V?.(n);
57
- }, te = X?.quick_peek?.width ?? 480, ne = M.some((e) => !e.readOnly);
56
+ W(n), K(!0), B?.(n);
57
+ }, ne = Y?.quick_peek?.width ?? 480, $ = M.some((e) => !e.readOnly);
58
58
  return /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S("div", {
59
- onClick: z,
59
+ onClick: R,
60
60
  style: {
61
61
  position: "fixed",
62
62
  inset: 0,
@@ -64,19 +64,19 @@ function T({ entity: T, entityCode: D, record: O, title: k, recordId: A, avatarN
64
64
  zIndex: 40
65
65
  }
66
66
  }), /* @__PURE__ */ C("aside", {
67
- ref: J,
67
+ ref: q,
68
68
  role: "dialog",
69
- "aria-label": H("list.peek.dialog", "Quick peek"),
69
+ "aria-label": V("list.peek.dialog", "Quick peek"),
70
70
  tabIndex: -1,
71
71
  onKeyDown: (e) => {
72
- e.key === "Escape" && z();
72
+ e.key === "Escape" && R();
73
73
  },
74
74
  style: {
75
75
  position: "fixed",
76
76
  top: "var(--topbar-h)",
77
77
  right: 0,
78
78
  bottom: "var(--tabbar-h)",
79
- width: te,
79
+ width: ne,
80
80
  background: "var(--surface)",
81
81
  borderLeft: "1px solid var(--border)",
82
82
  zIndex: 41,
@@ -124,13 +124,13 @@ function T({ entity: T, entityCode: D, record: O, title: k, recordId: A, avatarN
124
124
  }),
125
125
  /* @__PURE__ */ S(r, {
126
126
  icon: /* @__PURE__ */ S(n.external, { size: 13 }),
127
- title: K ? H("list.peek.open_in_tab_dirty", "Open in tab (keeps unsaved changes)") : H("list.peek.open_in_tab", "Open in tab"),
128
- onClick: () => B(K ? W : null)
127
+ title: G ? V("list.peek.open_in_tab_dirty", "Open in tab (keeps unsaved changes)") : V("list.peek.open_in_tab", "Open in tab"),
128
+ onClick: () => z(G ? U : null)
129
129
  }),
130
130
  /* @__PURE__ */ S(r, {
131
131
  icon: /* @__PURE__ */ S(n.x, { size: 14 }),
132
- title: H("list.peek.close", "Close"),
133
- onClick: z
132
+ title: V("list.peek.close", "Close"),
133
+ onClick: R
134
134
  })
135
135
  ]
136
136
  }),
@@ -154,35 +154,31 @@ function T({ entity: T, entityCode: D, record: O, title: k, recordId: A, avatarN
154
154
  alignItems: "center",
155
155
  gap: 6
156
156
  },
157
- children: [ne && /* @__PURE__ */ C(x, { children: [
158
- /* @__PURE__ */ S(n.sparkle, { size: 12 }),
159
- " ",
160
- H("list.peek.hint", "Inline quick-edit — click any field to change.")
161
- ] }), g(H("list.peek.keys_hint", "{tab} to move, {esc} to close."), {
157
+ children: [$ && /* @__PURE__ */ S(n.sparkle, { size: 12 }), /* @__PURE__ */ C("span", { children: [$ && /* @__PURE__ */ C(x, { children: [V("list.peek.hint", "Inline quick-edit — click any field to change."), " "] }), g(V("list.peek.keys_hint", "{tab} to move, {esc} to close."), {
162
158
  tab: /* @__PURE__ */ S(i, { children: w.tab }),
163
159
  esc: /* @__PURE__ */ S(i, { children: w.esc })
164
- })]
160
+ })] })]
165
161
  }), M.map((e) => /* @__PURE__ */ S(E, {
166
162
  label: e.label,
167
163
  children: e.kind === "file" ? ee({
168
164
  entity: T,
169
165
  entityCode: D,
170
166
  fieldName: e.key,
171
- record: W,
167
+ record: U,
172
168
  mode: e.readOnly ? "display" : "edit",
173
- onChange: (t) => $(e.key, t),
169
+ onChange: (t) => Q(e.key, t),
174
170
  refs: N,
175
171
  disabled: e.readOnly,
176
- t: H
172
+ t: V
177
173
  }) : /* @__PURE__ */ S(o, {
178
174
  field: e.field,
179
175
  fieldName: e.key,
180
176
  label: e.label,
181
- value: W[e.key],
182
- record: W,
177
+ value: U[e.key],
178
+ record: U,
183
179
  refs: N,
184
180
  readOnly: e.readOnly,
185
- onCommit: (t) => $(e.key, t)
181
+ onCommit: (t) => Q(e.key, t)
186
182
  })
187
183
  }, e.key))]
188
184
  }),
@@ -195,7 +191,7 @@ function T({ entity: T, entityCode: D, record: O, title: k, recordId: A, avatarN
195
191
  alignItems: "center"
196
192
  },
197
193
  children: [
198
- K && /* @__PURE__ */ C("span", {
194
+ G && /* @__PURE__ */ C("span", {
199
195
  style: {
200
196
  fontSize: 11,
201
197
  color: "var(--warn)",
@@ -208,7 +204,7 @@ function T({ entity: T, entityCode: D, record: O, title: k, recordId: A, avatarN
208
204
  height: 6,
209
205
  borderRadius: 999,
210
206
  background: "var(--warn)"
211
- } }), H("list.peek.unsaved", "Unsaved")]
207
+ } }), V("list.peek.unsaved", "Unsaved")]
212
208
  }),
213
209
  /* @__PURE__ */ S("div", {
214
210
  style: {
@@ -217,24 +213,24 @@ function T({ entity: T, entityCode: D, record: O, title: k, recordId: A, avatarN
217
213
  display: "flex",
218
214
  justifyContent: "flex-end"
219
215
  },
220
- children: Z.length > 0 && /* @__PURE__ */ S(u, {
221
- layout: Z,
222
- row: W,
223
- onRun: (e, t) => Q({
216
+ children: X.length > 0 && /* @__PURE__ */ S(u, {
217
+ layout: X,
218
+ row: U,
219
+ onRun: (e, t) => Z({
224
220
  code: e,
225
221
  action: t
226
222
  }),
227
223
  kind: "toolbar",
228
- entityActions: F,
224
+ entityActions: P,
229
225
  align: "trailing",
230
- ariaLabel: H("list.peek.actions", "Quick peek actions")
226
+ ariaLabel: V("list.peek.actions", "Quick peek actions")
231
227
  })
232
228
  }),
233
229
  /* @__PURE__ */ S(t, {
234
230
  kind: "primary",
235
231
  icon: /* @__PURE__ */ S(n.edit, { size: 13 }),
236
- onClick: () => B(K ? W : null),
237
- children: H("list.peek.open_full", "Open full")
232
+ onClick: () => z(G ? U : null),
233
+ children: V("list.peek.open_full", "Open full")
238
234
  })
239
235
  ]
240
236
  })
@@ -52,6 +52,7 @@ var n = 4, r = 2, i = 2, a = [
52
52
  "timestamp",
53
53
  "timestamptz",
54
54
  "enum",
55
+ "error",
55
56
  "status"
56
57
  ]);
57
58
  function f(e) {
@@ -1,74 +1,77 @@
1
1
  import { effectiveSpecialValues as e, fieldDisplayName as t } from "../../../types/schema.js";
2
+ import { errorOptions as n } from "../../../lib/error-options.js";
2
3
  // src/components/pages/list/filter-meta.ts
3
- function n(e, t, n, r) {
4
+ function r(e, t, n, r, i) {
4
5
  if (!t || !n) return [];
5
- let a = t.filter_operators ?? {}, o = (t.filters ?? []).filter((e) => a[e]?.length);
6
- return i({
6
+ let o = t.filter_operators ?? {}, s = (t.filters ?? []).filter((e) => o[e]?.length);
7
+ return a({
7
8
  t: e,
8
9
  screen: t,
9
10
  entity: n,
10
- entities: r
11
- }, o, a);
11
+ entities: r,
12
+ errors: i
13
+ }, s, o);
12
14
  }
13
- function r(e, t, n, r) {
14
- return !t || !n ? [] : i({
15
+ function i(e, t, n, r, i) {
16
+ return !t || !n ? [] : a({
15
17
  t: e,
16
18
  screen: t,
17
19
  entity: n,
18
- entities: r
20
+ entities: r,
21
+ errors: i
19
22
  }, Object.keys(n.filter_operators), n.filter_operators);
20
23
  }
21
- function i({ t: n, screen: r, entity: i, entities: a }, o, s) {
22
- let c = [];
23
- for (let l of o) {
24
- let o = s[l];
25
- if (l.startsWith("$status.")) {
26
- let e = l.slice(8), t = i.status_groups?.[e];
24
+ function a({ t: r, screen: i, entity: a, entities: o, errors: s }, c, l) {
25
+ let u = [];
26
+ for (let d of c) {
27
+ let c = l[d];
28
+ if (d.startsWith("$status.")) {
29
+ let e = d.slice(8), t = a.status_groups?.[e];
27
30
  if (!t) continue;
28
- c.push({
29
- code: l,
30
- label: n(t.name) || e,
31
+ u.push({
32
+ code: d,
33
+ label: r(t.name) || e,
31
34
  type: "status",
32
- operators: o,
35
+ operators: c,
33
36
  options: t.statuses.map((e) => ({
34
37
  value: e.code,
35
- label: n(e.name) || e.code,
38
+ label: r(e.name) || e.code,
36
39
  color: e.color
37
40
  }))
38
41
  });
39
42
  continue;
40
43
  }
41
- if (l.startsWith("$property.")) {
42
- let e = l.slice(10), t = i.properties?.[e];
44
+ if (d.startsWith("$property.")) {
45
+ let e = d.slice(10), t = a.properties?.[e];
43
46
  if (!t) continue;
44
- c.push({
45
- code: l,
46
- label: n(t.name) || e,
47
+ u.push({
48
+ code: d,
49
+ label: r(t.name) || e,
47
50
  type: "property",
48
- operators: o
51
+ operators: c
49
52
  });
50
53
  continue;
51
54
  }
52
- let u = i.fields.get(l);
53
- if (!u) continue;
54
- let d = t(n, u, l, a), f = u.values?.map((e) => ({
55
+ let f = a.fields.get(d);
56
+ if (!f) continue;
57
+ let p = t(r, f, d, o), m = f.type === "error" ? n(s, r) : f.values?.map((e) => ({
55
58
  value: e.code,
56
- label: n(e.name) || e.code,
59
+ label: r(e.name) || e.code,
57
60
  color: e.color
58
- })), p = e(u.special_values, r?.special_values?.[l]);
59
- c.push({
60
- code: l,
61
- label: d,
62
- type: u.type,
63
- operators: o,
64
- options: f,
65
- ref: u.ref,
66
- specialValues: p.length > 0 ? p : void 0
61
+ })), h = e(f.special_values, i?.special_values?.[d]);
62
+ u.push({
63
+ code: d,
64
+ label: p,
65
+ type: f.type,
66
+ operators: c,
67
+ options: m,
68
+ ref: f.ref,
69
+ specialValues: h.length > 0 ? h : void 0
67
70
  });
68
71
  }
69
- return c;
72
+ return u;
70
73
  }
71
- function a(e, n, r, i) {
74
+ function o(e, n, r, i) {
72
75
  if (i.startsWith("$status.")) {
73
76
  let t = n.status_groups?.[i.slice(8)];
74
77
  return t && e(t.name) || i;
@@ -80,4 +83,4 @@ function a(e, n, r, i) {
80
83
  let a = n.fields.get(i);
81
84
  return a ? t(e, a, i, r) : i;
82
85
  }
83
- export { r as buildFilterDisplayMeta, n as buildFilterFieldMeta, a as filterFieldLabel };
86
+ export { i as buildFilterDisplayMeta, r as buildFilterFieldMeta, o as filterFieldLabel };
@@ -1,33 +1,36 @@
1
1
  import { useText as e } from "../../../hooks/useText.js";
2
- import { useJsonSnapshot as t } from "../../../hooks/useJsonSnapshot.js";
3
- import { buildFilterDisplayMeta as n, buildFilterFieldMeta as r, filterFieldLabel as i } from "./filter-meta.js";
4
- import { visibleFilters as a } from "./visible-filters.js";
5
- import { useCallback as o, useMemo as s } from "react";
2
+ import { useSchema as t } from "../../../hooks/useSchema.js";
3
+ import { useJsonSnapshot as n } from "../../../hooks/useJsonSnapshot.js";
4
+ import { buildFilterDisplayMeta as r, buildFilterFieldMeta as i, filterFieldLabel as a } from "./filter-meta.js";
5
+ import { visibleFilters as o } from "./visible-filters.js";
6
+ import { useCallback as s, useMemo as c } from "react";
6
7
  // src/components/pages/list/useListFilterPresentation.ts
7
- function c(c, l, u, d) {
8
- let f = e(), p = t(d);
8
+ function l(l, u, d, f) {
9
+ let p = e(), m = t().data?.errors, h = n(f);
9
10
  return {
10
- visibleFilterState: s(() => l ? a(p, l.filter_operators) : {
11
- filters: p,
11
+ visibleFilterState: c(() => u ? o(h, u.filter_operators) : {
12
+ filters: h,
12
13
  omitted: !1
13
- }, [p, l]),
14
- filterFieldMeta: s(() => r(f, c, l, u), [
15
- f,
16
- c,
14
+ }, [h, u]),
15
+ filterFieldMeta: c(() => i(p, l, u, d, m), [
16
+ p,
17
17
  l,
18
- u
18
+ u,
19
+ d,
20
+ m
19
21
  ]),
20
- allFilterFieldMeta: s(() => n(f, c, l, u), [
21
- f,
22
- c,
22
+ allFilterFieldMeta: c(() => r(p, l, u, d, m), [
23
+ p,
23
24
  l,
24
- u
25
+ u,
26
+ d,
27
+ m
25
28
  ]),
26
- filterFieldName: o((e) => l ? i(f, l, u, e) : e, [
27
- f,
28
- l,
29
- u
29
+ filterFieldName: s((e) => u ? a(p, u, d, e) : e, [
30
+ p,
31
+ u,
32
+ d
30
33
  ])
31
34
  };
32
35
  }
33
- export { c as useListFilterPresentation };
36
+ export { l as useListFilterPresentation };
@@ -11,7 +11,7 @@ var t = [
11
11
  "slate"
12
12
  ];
13
13
  function n({ name: n, size: r = 22, color: i }) {
14
- let a = n.split(/\s+/).map((e) => e[0]).slice(0, 2).join("").toUpperCase(), o = t[n.split("").reduce((e, t) => e + t.charCodeAt(0), 0) % t.length], s = i || `var(--pill-${o}-bg)`;
14
+ let a = n.split(/\s+/).filter((e) => /^[\p{L}\p{N}]/u.test(e)).map((e) => e[0]).slice(0, 2).join("").toUpperCase(), o = t[n.split("").reduce((e, t) => e + t.charCodeAt(0), 0) % t.length], s = i || `var(--pill-${o}-bg)`;
15
15
  return /* @__PURE__ */ e("span", {
16
16
  style: {
17
17
  display: "inline-flex",
@@ -1,10 +1,22 @@
1
- import { useScreenTabRegistration as e } from "./useRegisterScreenTab.js";
2
- import { useTabSearchMirror as t } from "./useTabSearchMirror.js";
3
- import { useRef as n } from "react";
4
- import { useLocation as r, useSearchParams as i } from "react-router";
1
+ import { useEmbed as e } from "../embed/EmbedContext.js";
2
+ import { useScreenTabRegistration as t } from "./useRegisterScreenTab.js";
3
+ import { useTabSearchMirror as n } from "./useTabSearchMirror.js";
4
+ import { useTabStore as r } from "../stores/tabs.js";
5
+ import { useEffect as i, useRef as a } from "react";
6
+ import { useLocation as o, useSearchParams as s } from "react-router";
5
7
  // src/hooks/useScreenTab.ts
6
- function a(a) {
7
- let o = r(), [s] = i(), c = a?.route ?? o.pathname, l = n(s.toString());
8
- e(c, a?.title ?? c, a?.icon, l.current), t(c);
8
+ function c(c) {
9
+ let l = o(), [u] = s(), d = c?.route ?? l.pathname, f = a(u.toString());
10
+ t(d, c?.title ?? d, c?.icon, f.current), n(d);
11
+ let p = c?.title, m = e();
12
+ i(() => {
13
+ if (!p || m.enabled) return;
14
+ let e = r.getState().findTabByPathname(d);
15
+ e && (e.title !== p || e.derivedTitle) && r.getState().updateTabTitle(e.id, p);
16
+ }, [
17
+ d,
18
+ p,
19
+ m.enabled
20
+ ]);
9
21
  }
10
- export { a as useScreenTab };
22
+ export { c as useScreenTab };
@@ -854,7 +854,9 @@ interface UseScreenTabOptions {
854
854
  /** The tab's route. Defaults to the live `location.pathname` - the right value
855
855
  * for a param-less custom screen, which is the common case. */
856
856
  route?: string;
857
- /** Tab title. Defaults to the route when omitted. */
857
+ /** Tab title. Defaults to the route when omitted. A changed title renames the
858
+ * open tab, so a record's name that loads after mount reaches the tab and the
859
+ * breadcrumb. */
858
860
  title?: string;
859
861
  /** Tab icon name (resolved by the icon registry). */
860
862
  icon?: string;
@@ -2290,7 +2292,7 @@ export declare function useAgentConversation(initialConversationId?: string, age
2290
2292
  };
2291
2293
  /** Metadata needed to evaluate a record-only filter condition. */
2292
2294
  interface FilterRecordField {
2293
- type: "string" | "text" | "rich_text" | "email" | "url" | "phone" | "enum" | "int" | "float" | "decimal" | "date" | "timestamp" | "time" | "bool" | "ref" | "uuid" | (string & {});
2295
+ type: "string" | "text" | "rich_text" | "email" | "url" | "phone" | "enum" | "error" | "int" | "float" | "decimal" | "date" | "timestamp" | "time" | "bool" | "ref" | "uuid" | (string & {});
2294
2296
  }
2295
2297
  type FilterRecordFields = Readonly<Record<string, FilterRecordField>>;
2296
2298
  type FilterRecord = Readonly<Record<string, unknown>>;
@@ -0,0 +1,8 @@
1
+ // src/lib/error-options.ts
2
+ function e(e, t) {
3
+ return Object.entries(e ?? {}).map(([e, n]) => ({
4
+ value: e,
5
+ label: t(n) || e
6
+ })).sort((e, n) => e.label.localeCompare(n.label, t.language));
7
+ }
8
+ export { e as errorOptions };
@@ -22,6 +22,7 @@ var e = /* @__PURE__ */ new Set([
22
22
  url: r,
23
23
  phone: r,
24
24
  enum: i,
25
+ error: i,
25
26
  int: a,
26
27
  float: a,
27
28
  decimal: a,
@@ -83,7 +84,7 @@ function p(e, t, n, r) {
83
84
  function m(r, i, a) {
84
85
  if (t.has(r)) return typeof i != "number" || typeof a != "number" || !Number.isFinite(i) || !Number.isFinite(a) ? void 0 : i === a ? 0 : i < a ? -1 : 1;
85
86
  if (n.has(r)) return typeof i != "string" || typeof a != "string" || !h(r, i) || !h(r, a) ? void 0 : i === a ? 0 : i < a ? -1 : 1;
86
- if (e.has(r) || r === "enum" || r === "ref" || r === "uuid") return typeof i != "string" || typeof a != "string" ? void 0 : i === a ? 0 : i < a ? -1 : 1;
87
+ if (e.has(r) || r === "enum" || r === "error" || r === "ref" || r === "uuid") return typeof i != "string" || typeof a != "string" ? void 0 : i === a ? 0 : i < a ? -1 : 1;
87
88
  if (r === "bool") return typeof i != "boolean" || typeof a != "boolean" ? void 0 : i === a ? 0 : i ? 1 : -1;
88
89
  }
89
90
  function h(e, t) {
@@ -1,3 +1,3 @@
1
1
  // src/types/fieldType.ts
2
- var e = /* @__PURE__ */ "bool.bytes.date.decimal.email.enum.file_ref.float.folder_ref.int.int_array.json.multilang.multilang_array.multilang_text.password.phone.ref.rich_text.secret.string.string_array.structure.tags.text.time.timestamp.url.uuid.uuid_array".split(".");
2
+ var e = /* @__PURE__ */ "bool.bytes.date.decimal.email.enum.error.file_ref.float.folder_ref.int.int_array.json.multilang.multilang_array.multilang_text.password.phone.ref.rich_text.secret.string.string_array.structure.tags.text.time.timestamp.url.uuid.uuid_array".split(".");
3
3
  export { e as FIELD_TYPES };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@declarion/react",
3
- "version": "0.354.0",
3
+ "version": "0.359.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "React SDK for Declarion, the schema-driven business apps platform.",