@declarion/react 0.25.0 → 0.26.1

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,5 +1,5 @@
1
1
  import { s as e } from "./DynamicIcon-DCRdxxZ7.js";
2
- import { ar as t, jn as n, m as r, or as i, p as a, yn as o } from "./ActionRunner-eixtbT5K.js";
2
+ import { Fn as t, In as n, m as r, mn as i, p as a, tn as o } from "./ActionRunner-B2e3Igpd.js";
3
3
  import { n as s, r as c, t as l } from "./dataTableStyles-vwD1mVOP.js";
4
4
  import { useCallback as u, useMemo as d, useRef as f } from "react";
5
5
  import { jsx as p, jsxs as m } from "react/jsx-runtime";
@@ -7,14 +7,14 @@ import { DndContext as h, PointerSensor as g, closestCenter as _, useSensor as v
7
7
  import { SortableContext as b, useSortable as x, verticalListSortingStrategy as S } from "@dnd-kit/sortable";
8
8
  import { CSS as C } from "@dnd-kit/utilities";
9
9
  //#region src/components/detail-layout/DraggableChildrenTable.tsx
10
- function w({ config: t, childEntity: n, schema: r, rows: a, onChange: l, validationErrors: x, refs: C }) {
10
+ function w({ config: t, childEntity: r, schema: i, rows: a, onChange: l, validationErrors: x, refs: C }) {
11
11
  let w = f(null), E = t.position_field, D = t.columns, O = y(v(g, { activationConstraint: { distance: 5 } })), k = new Set(Array.isArray(t.foreign_key) ? t.foreign_key : [t.foreign_key]), A = D.filter((e) => {
12
12
  if (k.has(e) || e === E) return !1;
13
- let t = n.fields.get(e);
13
+ let t = r.fields.get(e);
14
14
  return !(!t || t.auto || t.primary || t.source);
15
15
  }), j = new Set(D.filter((e) => {
16
16
  if (e === E) return !0;
17
- let t = n.fields.get(e);
17
+ let t = r.fields.get(e);
18
18
  return t && (t.auto || t.primary || t.source);
19
19
  })), M = D.filter((e) => e !== E), N = d(() => a.filter((e) => !e._deleted).map((e) => e._key), [a]), P = u((e, t, n) => {
20
20
  l(a.map((r) => r._key === e ? {
@@ -26,21 +26,21 @@ function w({ config: t, childEntity: n, schema: r, rows: a, onChange: l, validat
26
26
  let e = a.filter((e) => !e._deleted).reduce((e, t) => {
27
27
  let n = typeof t[E] == "number" ? t[E] : -1;
28
28
  return Math.max(e, n);
29
- }, -1), r = {
29
+ }, -1), n = {
30
30
  _key: crypto.randomUUID(),
31
31
  _dirty: !0,
32
32
  [E]: e + 1
33
33
  }, i = t.quick_add?.defaults ?? {};
34
34
  for (let e of A) {
35
- let t = n.fields.get(e);
36
- t && (i[e] === void 0 ? t.default === void 0 ? t.type === "bool" && (r[e] = !1) : r[e] = t.default : r[e] = i[e]);
35
+ let t = r.fields.get(e);
36
+ t && (i[e] === void 0 ? t.default === void 0 ? t.type === "bool" && (n[e] = !1) : n[e] = t.default : n[e] = i[e]);
37
37
  }
38
- l([...a, r]);
38
+ l([...a, n]);
39
39
  }, [
40
40
  a,
41
41
  l,
42
42
  A,
43
- n,
43
+ r,
44
44
  t.quick_add?.defaults,
45
45
  E
46
46
  ]), I = u((e) => {
@@ -118,10 +118,10 @@ function w({ config: t, childEntity: n, schema: r, rows: a, onChange: l, validat
118
118
  padding: "0 4px"
119
119
  } }),
120
120
  M.map((e) => {
121
- let t = n.fields.get(e);
121
+ let t = r.fields.get(e);
122
122
  return /* @__PURE__ */ p("th", {
123
123
  style: B,
124
- children: t ? o(t, e, r.entities) : e
124
+ children: t ? o(t, e, i.entities) : e
125
125
  }, e);
126
126
  }),
127
127
  /* @__PURE__ */ p("th", { style: {
@@ -136,7 +136,7 @@ function w({ config: t, childEntity: n, schema: r, rows: a, onChange: l, validat
136
136
  columns: M,
137
137
  editableColumns: A,
138
138
  displayOnlyColumns: j,
139
- childEntity: n,
139
+ childEntity: r,
140
140
  validationErrors: x,
141
141
  refs: C,
142
142
  onCellChange: P,
@@ -148,7 +148,7 @@ function w({ config: t, childEntity: n, schema: r, rows: a, onChange: l, validat
148
148
  })
149
149
  }), /* @__PURE__ */ p("div", {
150
150
  style: { marginTop: 8 },
151
- children: /* @__PURE__ */ p(i, {
151
+ children: /* @__PURE__ */ p(n, {
152
152
  kind: "ghost",
153
153
  size: "xs",
154
154
  icon: /* @__PURE__ */ p(e.plus, { size: 12 }),
@@ -157,9 +157,9 @@ function w({ config: t, childEntity: n, schema: r, rows: a, onChange: l, validat
157
157
  })
158
158
  })] });
159
159
  }
160
- function T({ row: i, columns: o, editableColumns: s, displayOnlyColumns: c, childEntity: u, validationErrors: d, refs: f, onCellChange: h, onDelete: g, onUndoDelete: _ }) {
161
- let v = a(), y = !!i._deleted, b = d?.[i._key], { attributes: S, listeners: w, setNodeRef: T, transform: E, transition: D, isDragging: O } = x({
162
- id: i._key,
160
+ function T({ row: n, columns: o, editableColumns: s, displayOnlyColumns: c, childEntity: u, validationErrors: d, refs: f, onCellChange: h, onDelete: g, onUndoDelete: _ }) {
161
+ let v = a(), y = !!n._deleted, b = d?.[n._key], { attributes: S, listeners: w, setNodeRef: T, transform: E, transition: D, isDragging: O } = x({
162
+ id: n._key,
163
163
  disabled: y
164
164
  }), k = {
165
165
  transform: C.Translate.toString(E),
@@ -210,12 +210,12 @@ function T({ row: i, columns: o, editableColumns: s, displayOnlyColumns: c, chil
210
210
  children: t ? r({
211
211
  field: t,
212
212
  fieldName: e,
213
- value: i[e],
213
+ value: n[e],
214
214
  mode: "display",
215
- record: i,
215
+ record: n,
216
216
  refs: f,
217
217
  locale: v
218
- }) : n(i[e])
218
+ }) : i(n[e])
219
219
  }, e) : /* @__PURE__ */ p("td", {
220
220
  style: {
221
221
  ...j,
@@ -227,13 +227,13 @@ function T({ row: i, columns: o, editableColumns: s, displayOnlyColumns: c, chil
227
227
  children: t ? r({
228
228
  field: t,
229
229
  fieldName: e,
230
- value: i[e],
230
+ value: n[e],
231
231
  mode: "edit",
232
- onChange: (t) => h(i._key, e, t),
233
- record: i,
232
+ onChange: (t) => h(n._key, e, t),
233
+ record: n,
234
234
  refs: f,
235
235
  locale: v
236
- }) : n(i[e])
236
+ }) : i(n[e])
237
237
  }, e);
238
238
  }),
239
239
  /* @__PURE__ */ p("td", {
@@ -245,12 +245,12 @@ function T({ row: i, columns: o, editableColumns: s, displayOnlyColumns: c, chil
245
245
  children: y ? /* @__PURE__ */ p(t, {
246
246
  size: 24,
247
247
  icon: /* @__PURE__ */ p(e.refresh, { size: 12 }),
248
- onClick: () => _(i._key),
248
+ onClick: () => _(n._key),
249
249
  title: "Undo delete"
250
250
  }) : /* @__PURE__ */ p(t, {
251
251
  size: 24,
252
252
  icon: /* @__PURE__ */ p(e.trash, { size: 12 }),
253
- onClick: () => g(i._key),
253
+ onClick: () => g(n._key),
254
254
  title: "Delete row"
255
255
  })
256
256
  })
@@ -1,4 +1,5 @@
1
- import { D as e, E as t, F as n, I as r, L as i, M as a, R as o, j as s, k as c, z as l } from "./ActionRunner-eixtbT5K.js";
1
+ import { C as e, S as t, _ as n, b as r, x as i, y as a } from "./ActionRunner-B2e3Igpd.js";
2
+ import { c as o, i as s, l as c, t as l } from "./value-D7fe0TEL.js";
2
3
  import { useCallback as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
3
4
  import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
4
5
  import { DndContext as v, PointerSensor as y, closestCenter as b, useSensor as x, useSensors as ee } from "@dnd-kit/core";
@@ -6,79 +7,79 @@ import { SortableContext as te, arrayMove as ne, rectSortingStrategy as re, useS
6
7
  import { CSS as C } from "@dnd-kit/utilities";
7
8
  //#region src/components/file-widgets/Grid.tsx
8
9
  function w(e, t) {
9
- return s(e, t);
10
+ return o(e, t);
10
11
  }
11
- function T(e) {
12
- let { field: i, fieldName: a, value: s, onChange: h, mode: S, disabled: C } = e, w = t(s), [T, k] = m([]), [A, j] = m(/* @__PURE__ */ new Set()), [M, N] = m(null), { register: P, unregister: F, isDraft: I } = c(), L = p(/* @__PURE__ */ new Set()), R = p([]);
12
+ function T(i) {
13
+ let { field: o, fieldName: s, value: c, onChange: h, mode: S, disabled: C } = i, w = l(c), [T, k] = m([]), [A, j] = m(/* @__PURE__ */ new Set()), [M, N] = m(null), { register: P, unregister: F, isDraft: I } = n(), L = p(/* @__PURE__ */ new Set()), R = p([]);
13
14
  R.current = T;
14
15
  let z = p(w);
15
16
  z.current = w, d(() => () => {
16
17
  R.current.forEach((e) => e.abort());
17
18
  }, []);
18
- let B = ee(x(y, { activationConstraint: { distance: 5 } })), V = i.display?.placeholder || a, H = (i.accepts ?? ["image/*"]).join(","), U = i.display?.reorderable !== !1, W = i.display?.listable_thumbnail, G = u(async (t) => {
19
- let s = l(t, i.accepts, i.max_size_bytes), c = `tile-${Math.random().toString(36).slice(2)}-${Date.now()}`, u = new AbortController();
20
- if (s) {
19
+ let B = ee(x(y, { activationConstraint: { distance: 5 } })), V = o.display?.placeholder || s, H = (o.accepts ?? ["image/*"]).join(","), U = o.display?.reorderable !== !1, W = o.display?.listable_thumbnail, G = u(async (n) => {
20
+ let c = e(n, o.accepts, o.max_size_bytes), l = `tile-${Math.random().toString(36).slice(2)}-${Date.now()}`, u = new AbortController();
21
+ if (c) {
21
22
  k((e) => [...e, {
22
- localId: c,
23
- filename: t.name,
23
+ localId: l,
24
+ filename: n.name,
24
25
  progress: null,
25
- error: s,
26
+ error: c,
26
27
  abort: () => {}
27
28
  }]);
28
29
  return;
29
30
  }
30
31
  k((e) => [...e, {
31
- localId: c,
32
- filename: t.name,
32
+ localId: l,
33
+ filename: n.name,
33
34
  progress: {
34
35
  loaded: 0,
35
- total: t.size,
36
+ total: n.size,
36
37
  pct: 0
37
38
  },
38
39
  error: null,
39
40
  abort: () => u.abort()
40
41
  }]);
41
42
  try {
42
- let n = await o({
43
- file: t,
44
- entityCode: e.entityCode,
45
- fieldCode: a,
43
+ let e = await t({
44
+ file: n,
45
+ entityCode: i.entityCode,
46
+ fieldCode: s,
46
47
  signal: u.signal,
47
- onProgress: (e) => k((t) => t.map((t) => t.localId === c ? {
48
+ onProgress: (e) => k((t) => t.map((t) => t.localId === l ? {
48
49
  ...t,
49
50
  progress: e
50
51
  } : t))
51
52
  });
52
- if (L.current.delete(c)) {
53
- r(n.id).catch(() => {}), F(n.id);
53
+ if (L.current.delete(l)) {
54
+ r(e.id).catch(() => {}), F(e.id);
54
55
  return;
55
56
  }
56
- P(n.id, () => r(n.id));
57
- let i = {
58
- id: n.id,
59
- filename: n.filename,
60
- content_type: n.content_type,
61
- size_bytes: n.size_bytes,
62
- sha256: n.sha256,
63
- width: n.width,
64
- height: n.height,
65
- url: n.url,
66
- metadata: n.metadata
67
- }, s = [...z.current, i];
68
- z.current = s, h?.(s), k((e) => e.filter((e) => e.localId !== c));
57
+ P(e.id, () => r(e.id));
58
+ let a = {
59
+ id: e.id,
60
+ filename: e.filename,
61
+ content_type: e.content_type,
62
+ size_bytes: e.size_bytes,
63
+ sha256: e.sha256,
64
+ width: e.width,
65
+ height: e.height,
66
+ url: e.url,
67
+ metadata: e.metadata
68
+ }, o = [...z.current, a];
69
+ z.current = o, h?.(o), k((e) => e.filter((e) => e.localId !== l));
69
70
  } catch (e) {
70
- if (e instanceof n && e.code === "ABORTED") {
71
- k((e) => e.filter((e) => e.localId !== c));
71
+ if (e instanceof a && e.code === "ABORTED") {
72
+ k((e) => e.filter((e) => e.localId !== l));
72
73
  return;
73
74
  }
74
- let t = e instanceof n ? {
75
+ let t = e instanceof a ? {
75
76
  code: e.code,
76
77
  message: e.message
77
78
  } : {
78
79
  code: "UNKNOWN",
79
80
  message: e instanceof Error ? e.message : "Upload failed"
80
81
  };
81
- k((e) => e.map((e) => e.localId === c ? {
82
+ k((e) => e.map((e) => e.localId === l ? {
82
83
  ...e,
83
84
  error: t,
84
85
  progress: null,
@@ -86,11 +87,11 @@ function T(e) {
86
87
  } : e));
87
88
  }
88
89
  }, [
89
- i.accepts,
90
- i.max_size_bytes,
91
- a,
90
+ o.accepts,
91
+ o.max_size_bytes,
92
+ s,
92
93
  h,
93
- e.entityCode,
94
+ i.entityCode,
94
95
  P,
95
96
  F
96
97
  ]), K = u((e) => {
@@ -160,7 +161,7 @@ function T(e) {
160
161
  C || (e.key === "Enter" || e.key === " ") && e.target === e.currentTarget && (e.preventDefault(), J());
161
162
  }, [C, J]), $ = S === "display", fe = f(() => w.map((e) => e.id), [w]);
162
163
  return /* @__PURE__ */ _("div", {
163
- "data-testid": `file-widget-${a}`,
164
+ "data-testid": `file-widget-${s}`,
164
165
  className: "flex flex-col gap-2",
165
166
  children: [
166
167
  !$ && A.size > 0 && /* @__PURE__ */ _("div", {
@@ -225,7 +226,7 @@ function T(e) {
225
226
  className: "col-span-full flex h-24 cursor-pointer items-center justify-center text-sm text-muted-foreground",
226
227
  onClick: J,
227
228
  "data-testid": "grid-empty",
228
- children: i.display?.placeholder || "Drop files here or click to browse"
229
+ children: o.display?.placeholder || "Drop files here or click to browse"
229
230
  })
230
231
  ]
231
232
  })
@@ -238,7 +239,7 @@ function T(e) {
238
239
  multiple: !0,
239
240
  onChange: oe,
240
241
  style: { display: "none" },
241
- "data-testid": `file-input-${a}`
242
+ "data-testid": `file-input-${s}`
242
243
  }),
243
244
  Y && /* @__PURE__ */ g(O, {
244
245
  file: Y,
@@ -251,46 +252,46 @@ function T(e) {
251
252
  ]
252
253
  });
253
254
  }
254
- function E({ file: t, selected: n, disabled: r, reorderable: i, preferredThumbnail: o, onSelect: s, onRemove: c, onPreview: l }) {
255
+ function E({ file: e, selected: t, disabled: n, reorderable: r, preferredThumbnail: i, onSelect: a, onRemove: o, onPreview: l }) {
255
256
  let { attributes: u, listeners: d, setNodeRef: f, transform: p, transition: m, isDragging: v } = S({
256
- id: t.id,
257
- disabled: !i
257
+ id: e.id,
258
+ disabled: !r
258
259
  }), y = {
259
260
  transform: C.Transform.toString(p),
260
261
  transition: m,
261
262
  opacity: v ? .5 : 1
262
- }, b = e(t.id, a(t, o), w(t, o));
263
+ }, b = s(e.id, c(e, i), w(e, i));
263
264
  return /* @__PURE__ */ _("div", {
264
265
  ref: f,
265
266
  style: y,
266
- className: `group relative aspect-square overflow-hidden rounded-md border ${n ? "border-accent" : "border-border"} bg-surface-2`,
267
- "data-testid": `grid-tile-${t.id}`,
268
- "data-selected": n || void 0,
267
+ className: `group relative aspect-square overflow-hidden rounded-md border ${t ? "border-accent" : "border-border"} bg-surface-2`,
268
+ "data-testid": `grid-tile-${e.id}`,
269
+ "data-selected": t || void 0,
269
270
  children: [b ? /* @__PURE__ */ g("img", {
270
271
  src: b,
271
- alt: t.filename,
272
+ alt: e.filename,
272
273
  className: "h-full w-full cursor-pointer object-cover",
273
274
  loading: "lazy",
274
275
  onClick: l
275
276
  }) : /* @__PURE__ */ g("div", {
276
277
  className: "flex h-full w-full cursor-pointer items-center justify-center bg-surface-3 text-xs text-muted-foreground",
277
278
  onClick: l,
278
- children: t.filename
279
- }), !r && /* @__PURE__ */ _(h, { children: [
279
+ children: e.filename
280
+ }), !n && /* @__PURE__ */ _(h, { children: [
280
281
  /* @__PURE__ */ g("input", {
281
282
  type: "checkbox",
282
283
  className: "absolute left-1 top-1 h-4 w-4 cursor-pointer",
283
- checked: n,
284
- onChange: s,
285
- "aria-label": `Select ${t.filename}`,
286
- "data-testid": `select-${t.id}`,
284
+ checked: t,
285
+ onChange: a,
286
+ "aria-label": `Select ${e.filename}`,
287
+ "data-testid": `select-${e.id}`,
287
288
  onClick: (e) => e.stopPropagation()
288
289
  }),
289
- i && /* @__PURE__ */ g("button", {
290
+ r && /* @__PURE__ */ g("button", {
290
291
  type: "button",
291
292
  className: "absolute right-1 top-1 cursor-grab rounded-sm border border-border bg-card px-1 text-xs",
292
- "aria-label": `Drag to reorder ${t.filename}`,
293
- "data-testid": `drag-${t.id}`,
293
+ "aria-label": `Drag to reorder ${e.filename}`,
294
+ "data-testid": `drag-${e.id}`,
294
295
  ...u,
295
296
  ...d,
296
297
  children: "⋮⋮"
@@ -305,8 +306,8 @@ function E({ file: t, selected: n, disabled: r, reorderable: i, preferredThumbna
305
306
  }), /* @__PURE__ */ g("button", {
306
307
  type: "button",
307
308
  className: "rounded-sm border border-border bg-card px-2 py-0.5 text-xs text-destructive",
308
- onClick: c,
309
- "data-testid": `remove-${t.id}`,
309
+ onClick: o,
310
+ "data-testid": `remove-${e.id}`,
310
311
  children: "Delete"
311
312
  })]
312
313
  })
@@ -345,54 +346,54 @@ function D({ tile: e, onCancel: t, onDismiss: n }) {
345
346
  ]
346
347
  });
347
348
  }
348
- function O({ file: t, hasPrev: n, hasNext: r, onPrev: a, onNext: o, onClose: s }) {
349
- let c = e(t.id, "preview", t.presigned_url ?? t.url ?? w(t));
349
+ function O({ file: e, hasPrev: t, hasNext: n, onPrev: r, onNext: a, onClose: o }) {
350
+ let c = s(e.id, "preview", e.presigned_url ?? e.url ?? w(e));
350
351
  return /* @__PURE__ */ _("div", {
351
352
  className: "fixed inset-0 z-50 flex items-center justify-center bg-black/80",
352
353
  role: "dialog",
353
354
  "aria-modal": "true",
354
- "aria-label": t.filename,
355
+ "aria-label": e.filename,
355
356
  "data-testid": "lightbox",
356
- onClick: s,
357
+ onClick: o,
357
358
  children: [
358
359
  /* @__PURE__ */ g("button", {
359
360
  type: "button",
360
361
  className: "absolute right-4 top-4 rounded-sm border border-border bg-card px-3 py-1 text-foreground",
361
362
  onClick: (e) => {
362
- e.stopPropagation(), s();
363
+ e.stopPropagation(), o();
363
364
  },
364
365
  "data-testid": "lightbox-close",
365
366
  children: "Close"
366
367
  }),
367
- n && /* @__PURE__ */ g("button", {
368
+ t && /* @__PURE__ */ g("button", {
368
369
  type: "button",
369
370
  className: "absolute left-4 rounded-sm border border-border bg-card px-3 py-2 text-foreground",
370
371
  onClick: (e) => {
371
- e.stopPropagation(), a();
372
+ e.stopPropagation(), r();
372
373
  },
373
374
  "data-testid": "lightbox-prev",
374
375
  children: "‹"
375
376
  }),
376
- r && /* @__PURE__ */ g("button", {
377
+ n && /* @__PURE__ */ g("button", {
377
378
  type: "button",
378
379
  className: "absolute right-4 bottom-4 rounded-sm border border-border bg-card px-3 py-2 text-foreground",
379
380
  onClick: (e) => {
380
- e.stopPropagation(), o();
381
+ e.stopPropagation(), a();
381
382
  },
382
383
  "data-testid": "lightbox-next",
383
384
  children: "›"
384
385
  }),
385
386
  c ? /* @__PURE__ */ g("img", {
386
387
  src: c,
387
- alt: t.filename,
388
+ alt: e.filename,
388
389
  className: "max-h-[90vh] max-w-[90vw] object-contain",
389
390
  onClick: (e) => e.stopPropagation()
390
391
  }) : /* @__PURE__ */ _("div", {
391
392
  className: "rounded-md bg-card p-4 text-foreground",
392
393
  children: [
393
- t.filename,
394
+ e.filename,
394
395
  " (",
395
- i(t.size_bytes),
396
+ i(e.size_bytes),
396
397
  ")"
397
398
  ]
398
399
  })
@@ -1,4 +1,4 @@
1
- import { U as e } from "./ActionRunner-eixtbT5K.js";
1
+ import { T as e } from "./ActionRunner-B2e3Igpd.js";
2
2
  import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
3
  import r, { defaultUrlTransform as i } from "react-markdown";
4
4
  import a from "remark-breaks";