@declarion/react 0.358.0 → 0.365.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.
@@ -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 };