@declarion/react 0.12.4 → 0.19.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.
- package/dist-lib/ActionRunner-F1HBBKyQ.js +8344 -0
- package/dist-lib/{DraggableChildrenTable-CcogMLSZ.js → DraggableChildrenTable-D7kzLdIg.js} +55 -54
- package/dist-lib/{Grid-Cwxca9aO.js → Grid-Cz_2olTR.js} +120 -120
- package/dist-lib/{MarkdownRenderer-Dbl3AFDQ.js → MarkdownRenderer-Cm-nbv6g.js} +1 -1
- package/dist-lib/api/data.d.ts +28 -0
- package/dist-lib/api/entities.d.ts +13 -7
- package/dist-lib/dataTableStyles-vwD1mVOP.js +22 -0
- package/dist-lib/declarion-react.css +1 -1
- package/dist-lib/hooks/useCursorEntityData.d.ts +57 -0
- package/dist-lib/hooks/useEntityData.d.ts +2 -2
- package/dist-lib/hooks/useSSE.d.ts +1 -0
- package/dist-lib/index.js +5285 -7322
- package/dist-lib/lib/actions.d.ts +23 -18
- package/dist-lib/testing.d.ts +66 -0
- package/dist-lib/testing.js +147 -0
- package/dist-lib/types/api.d.ts +24 -0
- package/dist-lib/types/schema.d.ts +20 -0
- package/package.json +14 -3
- package/dist-lib/dataTableStyles-EMyLDQRB.js +0 -5342
- package/dist-lib/rich-text-CJpzFOG5.js +0 -46
- package/dist-lib/value-CrpaObP_.js +0 -774
|
@@ -1,70 +1,71 @@
|
|
|
1
1
|
import { s as e } from "./DynamicIcon-DCRdxxZ7.js";
|
|
2
|
-
import {
|
|
2
|
+
import { En as t, er as n, gn as r, m as i, p as a, tr as o } from "./ActionRunner-F1HBBKyQ.js";
|
|
3
|
+
import { n as s, r as c, t as l } from "./dataTableStyles-vwD1mVOP.js";
|
|
3
4
|
import { useCallback as u, useMemo as d, useRef as f } from "react";
|
|
4
5
|
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
5
6
|
import { DndContext as h, PointerSensor as g, closestCenter as _, useSensor as v, useSensors as y } from "@dnd-kit/core";
|
|
6
7
|
import { SortableContext as b, useSortable as x, verticalListSortingStrategy as S } from "@dnd-kit/sortable";
|
|
7
8
|
import { CSS as C } from "@dnd-kit/utilities";
|
|
8
9
|
//#region src/components/detail-layout/DraggableChildrenTable.tsx
|
|
9
|
-
function w({ config:
|
|
10
|
-
let w = f(null), E =
|
|
10
|
+
function w({ config: t, childEntity: n, schema: i, rows: a, onChange: l, validationErrors: x, refs: C }) {
|
|
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) => {
|
|
11
12
|
if (k.has(e) || e === E) return !1;
|
|
12
|
-
let t =
|
|
13
|
+
let t = n.fields.get(e);
|
|
13
14
|
return !(!t || t.auto || t.primary || t.source);
|
|
14
15
|
}), j = new Set(D.filter((e) => {
|
|
15
16
|
if (e === E) return !0;
|
|
16
|
-
let t =
|
|
17
|
+
let t = n.fields.get(e);
|
|
17
18
|
return t && (t.auto || t.primary || t.source);
|
|
18
|
-
})), M = D.filter((e) => e !== E), N = d(() =>
|
|
19
|
-
l(
|
|
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
|
+
l(a.map((r) => r._key === e ? {
|
|
20
21
|
...r,
|
|
21
22
|
[t]: n,
|
|
22
23
|
_dirty: !0
|
|
23
24
|
} : r));
|
|
24
|
-
}, [
|
|
25
|
-
let e =
|
|
25
|
+
}, [a, l]), F = u(() => {
|
|
26
|
+
let e = a.filter((e) => !e._deleted).reduce((e, t) => {
|
|
26
27
|
let n = typeof t[E] == "number" ? t[E] : -1;
|
|
27
28
|
return Math.max(e, n);
|
|
28
|
-
}, -1),
|
|
29
|
+
}, -1), r = {
|
|
29
30
|
_key: crypto.randomUUID(),
|
|
30
31
|
_dirty: !0,
|
|
31
32
|
[E]: e + 1
|
|
32
|
-
}, i =
|
|
33
|
+
}, i = t.quick_add?.defaults ?? {};
|
|
33
34
|
for (let e of A) {
|
|
34
|
-
let
|
|
35
|
-
|
|
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]);
|
|
36
37
|
}
|
|
37
|
-
l([...
|
|
38
|
+
l([...a, r]);
|
|
38
39
|
}, [
|
|
39
|
-
|
|
40
|
+
a,
|
|
40
41
|
l,
|
|
41
42
|
A,
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
n,
|
|
44
|
+
t.quick_add?.defaults,
|
|
44
45
|
E
|
|
45
46
|
]), I = u((e) => {
|
|
46
|
-
l(
|
|
47
|
+
l(a.map((t) => t._key === e ? {
|
|
47
48
|
...t,
|
|
48
49
|
_deleted: !0
|
|
49
50
|
} : t));
|
|
50
|
-
}, [
|
|
51
|
-
l(
|
|
51
|
+
}, [a, l]), L = u((e) => {
|
|
52
|
+
l(a.map((t) => t._key === e ? {
|
|
52
53
|
...t,
|
|
53
54
|
_deleted: !1
|
|
54
55
|
} : t));
|
|
55
|
-
}, [
|
|
56
|
+
}, [a, l]), R = u((e) => {
|
|
56
57
|
let { active: t, over: n } = e;
|
|
57
58
|
if (!n || t.id === n.id) return;
|
|
58
|
-
let r =
|
|
59
|
-
if (
|
|
60
|
-
let
|
|
61
|
-
|
|
59
|
+
let r = a.filter((e) => !e._deleted), i = a.filter((e) => e._deleted), o = r.findIndex((e) => e._key === String(t.id)), s = r.findIndex((e) => e._key === String(n.id));
|
|
60
|
+
if (o === -1 || s === -1) return;
|
|
61
|
+
let c = [...r], [u] = c.splice(o, 1);
|
|
62
|
+
c.splice(s, 0, u), l([...c.map((e, t) => ({
|
|
62
63
|
...e,
|
|
63
64
|
[E]: t,
|
|
64
65
|
_dirty: e[E] === t ? e._dirty : !0
|
|
65
66
|
})), ...i]);
|
|
66
67
|
}, [
|
|
67
|
-
|
|
68
|
+
a,
|
|
68
69
|
l,
|
|
69
70
|
E
|
|
70
71
|
]), z = u((e) => {
|
|
@@ -99,7 +100,7 @@ function w({ config: n, childEntity: r, schema: i, rows: c, onChange: l, validat
|
|
|
99
100
|
}
|
|
100
101
|
});
|
|
101
102
|
} else e.key === "Escape" && t.blur?.();
|
|
102
|
-
}, [F]), B =
|
|
103
|
+
}, [F]), B = s;
|
|
103
104
|
return /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("div", {
|
|
104
105
|
style: { overflowX: "auto" },
|
|
105
106
|
children: /* @__PURE__ */ p(h, {
|
|
@@ -108,7 +109,7 @@ function w({ config: n, childEntity: r, schema: i, rows: c, onChange: l, validat
|
|
|
108
109
|
onDragEnd: R,
|
|
109
110
|
children: /* @__PURE__ */ m("table", {
|
|
110
111
|
ref: w,
|
|
111
|
-
style:
|
|
112
|
+
style: c,
|
|
112
113
|
onKeyDown: z,
|
|
113
114
|
children: [/* @__PURE__ */ p("thead", { children: /* @__PURE__ */ m("tr", { children: [
|
|
114
115
|
/* @__PURE__ */ p("th", { style: {
|
|
@@ -117,10 +118,10 @@ function w({ config: n, childEntity: r, schema: i, rows: c, onChange: l, validat
|
|
|
117
118
|
padding: "0 4px"
|
|
118
119
|
} }),
|
|
119
120
|
M.map((e) => {
|
|
120
|
-
let t =
|
|
121
|
+
let t = n.fields.get(e);
|
|
121
122
|
return /* @__PURE__ */ p("th", {
|
|
122
123
|
style: B,
|
|
123
|
-
children: t ?
|
|
124
|
+
children: t ? r(t, e, i.entities) : e
|
|
124
125
|
}, e);
|
|
125
126
|
}),
|
|
126
127
|
/* @__PURE__ */ p("th", { style: {
|
|
@@ -130,12 +131,12 @@ function w({ config: n, childEntity: r, schema: i, rows: c, onChange: l, validat
|
|
|
130
131
|
] }) }), /* @__PURE__ */ p(b, {
|
|
131
132
|
items: N,
|
|
132
133
|
strategy: S,
|
|
133
|
-
children: /* @__PURE__ */ p("tbody", { children:
|
|
134
|
+
children: /* @__PURE__ */ p("tbody", { children: a.map((e) => /* @__PURE__ */ p(T, {
|
|
134
135
|
row: e,
|
|
135
136
|
columns: M,
|
|
136
137
|
editableColumns: A,
|
|
137
138
|
displayOnlyColumns: j,
|
|
138
|
-
childEntity:
|
|
139
|
+
childEntity: n,
|
|
139
140
|
validationErrors: x,
|
|
140
141
|
refs: C,
|
|
141
142
|
onCellChange: P,
|
|
@@ -147,7 +148,7 @@ function w({ config: n, childEntity: r, schema: i, rows: c, onChange: l, validat
|
|
|
147
148
|
})
|
|
148
149
|
}), /* @__PURE__ */ p("div", {
|
|
149
150
|
style: { marginTop: 8 },
|
|
150
|
-
children: /* @__PURE__ */ p(
|
|
151
|
+
children: /* @__PURE__ */ p(o, {
|
|
151
152
|
kind: "ghost",
|
|
152
153
|
size: "xs",
|
|
153
154
|
icon: /* @__PURE__ */ p(e.plus, { size: 12 }),
|
|
@@ -156,16 +157,16 @@ function w({ config: n, childEntity: r, schema: i, rows: c, onChange: l, validat
|
|
|
156
157
|
})
|
|
157
158
|
})] });
|
|
158
159
|
}
|
|
159
|
-
function T({ row:
|
|
160
|
-
let v =
|
|
161
|
-
id:
|
|
160
|
+
function T({ row: r, columns: o, editableColumns: s, displayOnlyColumns: c, childEntity: u, validationErrors: d, refs: f, onCellChange: h, onDelete: g, onUndoDelete: _ }) {
|
|
161
|
+
let v = a(), y = !!r._deleted, b = d?.[r._key], { attributes: S, listeners: w, setNodeRef: T, transform: E, transition: D, isDragging: O } = x({
|
|
162
|
+
id: r._key,
|
|
162
163
|
disabled: y
|
|
163
164
|
}), k = {
|
|
164
165
|
transform: C.Translate.toString(E),
|
|
165
166
|
transition: D,
|
|
166
167
|
zIndex: O ? 10 : void 0,
|
|
167
168
|
opacity: O ? .5 : void 0
|
|
168
|
-
}, A =
|
|
169
|
+
}, A = l, j = {
|
|
169
170
|
padding: "4px 4px",
|
|
170
171
|
borderBottom: "1px solid var(--divider)",
|
|
171
172
|
verticalAlign: "middle"
|
|
@@ -199,40 +200,40 @@ function T({ row: t, columns: a, editableColumns: o, displayOnlyColumns: s, chil
|
|
|
199
200
|
children: /* @__PURE__ */ p(e.grid, { size: 14 })
|
|
200
201
|
})
|
|
201
202
|
}),
|
|
202
|
-
|
|
203
|
-
let n = u.fields.get(e),
|
|
204
|
-
return y ||
|
|
203
|
+
o.map((e) => {
|
|
204
|
+
let n = u.fields.get(e), a = b?.includes(e), o = c.has(e), l = s.includes(e);
|
|
205
|
+
return y || o || !l ? /* @__PURE__ */ p("td", {
|
|
205
206
|
style: {
|
|
206
207
|
...A,
|
|
207
208
|
textDecoration: y ? "line-through" : "none"
|
|
208
209
|
},
|
|
209
|
-
children: n ?
|
|
210
|
+
children: n ? i({
|
|
210
211
|
field: n,
|
|
211
212
|
fieldName: e,
|
|
212
|
-
value:
|
|
213
|
+
value: r[e],
|
|
213
214
|
mode: "display",
|
|
214
|
-
record:
|
|
215
|
+
record: r,
|
|
215
216
|
refs: f,
|
|
216
217
|
locale: v
|
|
217
|
-
}) :
|
|
218
|
+
}) : t(r[e])
|
|
218
219
|
}, e) : /* @__PURE__ */ p("td", {
|
|
219
220
|
style: {
|
|
220
221
|
...j,
|
|
221
|
-
outline:
|
|
222
|
+
outline: a ? "1px solid var(--danger)" : "none",
|
|
222
223
|
outlineOffset: -1,
|
|
223
|
-
borderRadius:
|
|
224
|
+
borderRadius: a ? 4 : 0
|
|
224
225
|
},
|
|
225
|
-
title:
|
|
226
|
-
children: n ?
|
|
226
|
+
title: a ? `${e} is required` : void 0,
|
|
227
|
+
children: n ? i({
|
|
227
228
|
field: n,
|
|
228
229
|
fieldName: e,
|
|
229
|
-
value:
|
|
230
|
+
value: r[e],
|
|
230
231
|
mode: "edit",
|
|
231
|
-
onChange: (
|
|
232
|
-
record:
|
|
232
|
+
onChange: (t) => h(r._key, e, t),
|
|
233
|
+
record: r,
|
|
233
234
|
refs: f,
|
|
234
235
|
locale: v
|
|
235
|
-
}) :
|
|
236
|
+
}) : t(r[e])
|
|
236
237
|
}, e);
|
|
237
238
|
}),
|
|
238
239
|
/* @__PURE__ */ p("td", {
|
|
@@ -244,12 +245,12 @@ function T({ row: t, columns: a, editableColumns: o, displayOnlyColumns: s, chil
|
|
|
244
245
|
children: y ? /* @__PURE__ */ p(n, {
|
|
245
246
|
size: 24,
|
|
246
247
|
icon: /* @__PURE__ */ p(e.refresh, { size: 12 }),
|
|
247
|
-
onClick: () => _(
|
|
248
|
+
onClick: () => _(r._key),
|
|
248
249
|
title: "Undo delete"
|
|
249
250
|
}) : /* @__PURE__ */ p(n, {
|
|
250
251
|
size: 24,
|
|
251
252
|
icon: /* @__PURE__ */ p(e.trash, { size: 12 }),
|
|
252
|
-
onClick: () => g(
|
|
253
|
+
onClick: () => g(r._key),
|
|
253
254
|
title: "Delete row"
|
|
254
255
|
})
|
|
255
256
|
})
|