@declarion/react 0.163.0 → 0.168.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/components/actions/ActionDialog.js +93 -88
- package/dist-lib/components/actions/ActionRunner.js +3 -1
- package/dist-lib/components/fields/JsonEditor.js +10 -6
- package/dist-lib/components/pages/SmartDetailPage.impl.js +484 -474
- package/dist-lib/hooks/usePageStateRuntime.js +1 -1
- package/dist-lib/hooks/useRegisterScreenTab.js +15 -13
- package/package.json +1 -1
|
@@ -32,7 +32,10 @@ function w(e, t) {
|
|
|
32
32
|
}
|
|
33
33
|
return u(e, { row: t });
|
|
34
34
|
}
|
|
35
|
-
function T(e) {
|
|
35
|
+
function T(e, t, n) {
|
|
36
|
+
return n === "" && e.type === "string" && typeof e.default == "string" && C.test(e.default) && t !== "" && t != null;
|
|
37
|
+
}
|
|
38
|
+
function E(e) {
|
|
36
39
|
return {
|
|
37
40
|
type: e.type ?? "string",
|
|
38
41
|
required: e.required,
|
|
@@ -46,18 +49,18 @@ function T(e) {
|
|
|
46
49
|
ref: c(e.ref)
|
|
47
50
|
};
|
|
48
51
|
}
|
|
49
|
-
function
|
|
52
|
+
function D(e, t) {
|
|
50
53
|
if (!e.includes("${")) return e;
|
|
51
54
|
let n = u(e, { params: t });
|
|
52
55
|
return n == null ? "" : d(n);
|
|
53
56
|
}
|
|
54
|
-
var
|
|
55
|
-
function
|
|
57
|
+
var O = /\$\{\s*([^}]+?)\s*\}/g;
|
|
58
|
+
function k(e, t) {
|
|
56
59
|
let n = `params.${t}`;
|
|
57
|
-
for (let t of e.matchAll(
|
|
60
|
+
for (let t of e.matchAll(O)) if (t[1] === n) return !0;
|
|
58
61
|
return !1;
|
|
59
62
|
}
|
|
60
|
-
function
|
|
63
|
+
function A({ param: e, value: t, onChange: r, statusGroups: i }) {
|
|
61
64
|
let a = p(), o = _(() => {
|
|
62
65
|
let t = i ? Object.entries(i) : [];
|
|
63
66
|
return [{
|
|
@@ -79,12 +82,12 @@ function k({ param: e, value: t, onChange: r, statusGroups: i }) {
|
|
|
79
82
|
placeholder: a("action.dialog.select_status_group", "Select status group…")
|
|
80
83
|
});
|
|
81
84
|
}
|
|
82
|
-
function
|
|
85
|
+
function j({ param: e, value: t, onChange: r, statusGroups: i, formData: a }) {
|
|
83
86
|
let o = p(), s = _(() => {
|
|
84
87
|
if (!i) return [];
|
|
85
88
|
let t = e.filter?.status_group;
|
|
86
89
|
if (t) {
|
|
87
|
-
let e =
|
|
90
|
+
let e = D(t, a);
|
|
88
91
|
return e && i[e] ? i[e].statuses : [];
|
|
89
92
|
}
|
|
90
93
|
return Object.values(i).flatMap((e) => e.statuses);
|
|
@@ -106,67 +109,69 @@ function A({ param: e, value: t, onChange: r, statusGroups: i, formData: a }) {
|
|
|
106
109
|
placeholder: o("action.dialog.select_status", "Select status…")
|
|
107
110
|
});
|
|
108
111
|
}
|
|
109
|
-
function
|
|
110
|
-
let
|
|
111
|
-
|
|
112
|
-
}, [
|
|
112
|
+
function M({ open: n, onOpenChange: c, action: u, actionName: d, onSubmit: C, isPending: D, row: O, bulkSelection: M }) {
|
|
113
|
+
let N = p(), { data: P } = l(), F = u.resolved_params, I = u.resolved_hidden_defaults, L = !!u.destructive, R = s(N, u), z = h(() => {
|
|
114
|
+
D || c(!1);
|
|
115
|
+
}, [D, c]), B = v(null);
|
|
113
116
|
g(() => {
|
|
114
|
-
n &&
|
|
117
|
+
n && B.current?.focus();
|
|
115
118
|
}, [n]);
|
|
116
|
-
let
|
|
117
|
-
if (u.entity &&
|
|
118
|
-
}, [u.entity,
|
|
119
|
-
if (u.entity &&
|
|
120
|
-
}, [u.entity,
|
|
121
|
-
if (
|
|
122
|
-
for (let [e, t] of
|
|
123
|
-
return
|
|
119
|
+
let V = _(() => F ? Array.from(F) : [], [F]), H = _(() => {
|
|
120
|
+
if (u.entity && P) return P.entities[u.entity]?.status_groups;
|
|
121
|
+
}, [u.entity, P]), U = _(() => {
|
|
122
|
+
if (u.entity && P) return P.entities[u.entity];
|
|
123
|
+
}, [u.entity, P]), W = _(() => {
|
|
124
|
+
if (U) {
|
|
125
|
+
for (let [e, t] of U.fields) if (t.primary) return e;
|
|
126
|
+
return U.primary_key?.[0];
|
|
124
127
|
}
|
|
125
|
-
}, [
|
|
126
|
-
let e = { ...
|
|
127
|
-
for (let [t, n] of
|
|
128
|
+
}, [U]), G = h(() => {
|
|
129
|
+
let e = { ...I };
|
|
130
|
+
for (let [t, n] of V) if (n.type === "id_array") e[t] = M && W ? M.map((e) => e[W]).filter((e) => e != null) : [];
|
|
128
131
|
else if (n.type === "entity_patch") e[t] = {};
|
|
129
132
|
else if (n.type === "bool") {
|
|
130
|
-
let r = w(n.default,
|
|
133
|
+
let r = w(n.default, O);
|
|
131
134
|
e[t] = r === !0 || r === "true";
|
|
132
|
-
} else e[t] = w(n.default,
|
|
135
|
+
} else e[t] = w(n.default, O);
|
|
133
136
|
return e;
|
|
134
137
|
}, [
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
V,
|
|
139
|
+
O,
|
|
140
|
+
M,
|
|
141
|
+
W,
|
|
142
|
+
I
|
|
143
|
+
]), [K] = y(G), [q, J] = y(K);
|
|
144
|
+
m(n && JSON.stringify(q) !== JSON.stringify(K));
|
|
145
|
+
let Y = h((e, t) => {
|
|
146
|
+
J((n) => {
|
|
143
147
|
let r = {
|
|
144
148
|
...n,
|
|
145
149
|
[e]: t
|
|
146
150
|
};
|
|
147
|
-
if (!
|
|
148
|
-
for (let [t, n] of
|
|
151
|
+
if (!F) return r;
|
|
152
|
+
for (let [t, n] of F) {
|
|
149
153
|
if (n.type !== "status") continue;
|
|
150
154
|
let i = n.filter?.status_group;
|
|
151
|
-
i &&
|
|
155
|
+
i && k(i, e) && (r[t] = "");
|
|
152
156
|
}
|
|
153
157
|
return r;
|
|
154
158
|
});
|
|
155
|
-
}, [
|
|
156
|
-
let e = { ...
|
|
157
|
-
for (let [t, n] of
|
|
158
|
-
let r =
|
|
159
|
+
}, [F]), X = h(() => {
|
|
160
|
+
let e = { ...q };
|
|
161
|
+
for (let [t, n] of V) {
|
|
162
|
+
let r = q[t], i = r == null || r === "";
|
|
159
163
|
if (n.required && i) return;
|
|
160
|
-
i && delete e[t];
|
|
164
|
+
i && !T(n, K[t], r) && delete e[t];
|
|
161
165
|
}
|
|
162
166
|
C(e);
|
|
163
167
|
}, [
|
|
168
|
+
q,
|
|
164
169
|
K,
|
|
165
|
-
|
|
170
|
+
V,
|
|
166
171
|
C
|
|
167
172
|
]);
|
|
168
173
|
return n ? /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x("div", {
|
|
169
|
-
onClick:
|
|
174
|
+
onClick: z,
|
|
170
175
|
style: {
|
|
171
176
|
position: "fixed",
|
|
172
177
|
inset: 0,
|
|
@@ -176,14 +181,14 @@ function j({ open: n, onOpenChange: c, action: u, actionName: d, onSubmit: C, is
|
|
|
176
181
|
}
|
|
177
182
|
}), /* @__PURE__ */ S("div", {
|
|
178
183
|
"data-testid": "action-dialog",
|
|
179
|
-
ref:
|
|
184
|
+
ref: B,
|
|
180
185
|
role: "dialog",
|
|
181
186
|
"aria-modal": "true",
|
|
182
|
-
"aria-busy":
|
|
187
|
+
"aria-busy": D,
|
|
183
188
|
"aria-label": d,
|
|
184
189
|
tabIndex: -1,
|
|
185
190
|
onKeyDown: (e) => {
|
|
186
|
-
e.key === "Escape" &&
|
|
191
|
+
e.key === "Escape" && z();
|
|
187
192
|
},
|
|
188
193
|
style: {
|
|
189
194
|
position: "fixed",
|
|
@@ -218,14 +223,14 @@ function j({ open: n, onOpenChange: c, action: u, actionName: d, onSubmit: C, is
|
|
|
218
223
|
width: 28,
|
|
219
224
|
height: 28,
|
|
220
225
|
borderRadius: "var(--radius-md)",
|
|
221
|
-
background:
|
|
222
|
-
color:
|
|
226
|
+
background: L ? "var(--danger-soft)" : "var(--accent-soft)",
|
|
227
|
+
color: L ? "var(--danger)" : "var(--accent)",
|
|
223
228
|
display: "inline-flex",
|
|
224
229
|
alignItems: "center",
|
|
225
230
|
justifyContent: "center",
|
|
226
231
|
flexShrink: 0
|
|
227
232
|
},
|
|
228
|
-
children: x(
|
|
233
|
+
children: x(L ? r.trash : r.bolt, { size: 15 })
|
|
229
234
|
}),
|
|
230
235
|
/* @__PURE__ */ S("div", {
|
|
231
236
|
style: {
|
|
@@ -245,12 +250,12 @@ function j({ open: n, onOpenChange: c, action: u, actionName: d, onSubmit: C, is
|
|
|
245
250
|
color: "var(--text-3)",
|
|
246
251
|
marginTop: 2
|
|
247
252
|
},
|
|
248
|
-
children:
|
|
253
|
+
children: N(u.display?.description) || (V.length > 0 ? N("action.dialog.params_hint", "Fill in the parameters below to execute this action.") : "")
|
|
249
254
|
})]
|
|
250
255
|
}),
|
|
251
256
|
/* @__PURE__ */ x(i, {
|
|
252
257
|
icon: /* @__PURE__ */ x(r.x, { size: 14 }),
|
|
253
|
-
onClick:
|
|
258
|
+
onClick: z
|
|
254
259
|
})
|
|
255
260
|
]
|
|
256
261
|
}),
|
|
@@ -264,19 +269,19 @@ function j({ open: n, onOpenChange: c, action: u, actionName: d, onSubmit: C, is
|
|
|
264
269
|
minWidth: 0,
|
|
265
270
|
minHeight: 0
|
|
266
271
|
},
|
|
267
|
-
children: [
|
|
272
|
+
children: [R && /* @__PURE__ */ x("div", {
|
|
268
273
|
style: {
|
|
269
274
|
fontSize: 12.5,
|
|
270
275
|
lineHeight: 1.5,
|
|
271
276
|
color: "var(--text-2)",
|
|
272
|
-
background:
|
|
277
|
+
background: L ? "var(--danger-soft)" : "var(--surface-2)",
|
|
273
278
|
border: "1px solid var(--divider)",
|
|
274
279
|
borderRadius: "var(--radius-md)",
|
|
275
280
|
padding: "10px 12px"
|
|
276
281
|
},
|
|
277
|
-
children:
|
|
282
|
+
children: R
|
|
278
283
|
}), /* @__PURE__ */ x("fieldset", {
|
|
279
|
-
disabled:
|
|
284
|
+
disabled: D,
|
|
280
285
|
style: {
|
|
281
286
|
border: 0,
|
|
282
287
|
margin: 0,
|
|
@@ -285,45 +290,45 @@ function j({ open: n, onOpenChange: c, action: u, actionName: d, onSubmit: C, is
|
|
|
285
290
|
display: "flex",
|
|
286
291
|
flexDirection: "column",
|
|
287
292
|
gap: 12,
|
|
288
|
-
pointerEvents:
|
|
289
|
-
opacity:
|
|
293
|
+
pointerEvents: D ? "none" : void 0,
|
|
294
|
+
opacity: D ? .6 : 1
|
|
290
295
|
},
|
|
291
|
-
children:
|
|
292
|
-
let r =
|
|
296
|
+
children: V.map(([e, n]) => {
|
|
297
|
+
let r = N(n.display?.name) || e;
|
|
293
298
|
if (n.type === "id_array") return null;
|
|
294
299
|
let i;
|
|
295
300
|
if (n.type === "entity_patch") {
|
|
296
301
|
let t = typeof n.filter?.targets == "string" ? n.filter.targets : void 0;
|
|
297
302
|
i = /* @__PURE__ */ x(f, {
|
|
298
|
-
entity:
|
|
303
|
+
entity: U,
|
|
299
304
|
filterTargets: t,
|
|
300
|
-
selectedRows:
|
|
301
|
-
value:
|
|
302
|
-
onChange: (t) =>
|
|
305
|
+
selectedRows: M,
|
|
306
|
+
value: q[e] ?? {},
|
|
307
|
+
onChange: (t) => Y(e, t)
|
|
303
308
|
});
|
|
304
|
-
} else if (n.type === "status_group") i = /* @__PURE__ */ x(
|
|
309
|
+
} else if (n.type === "status_group") i = /* @__PURE__ */ x(A, {
|
|
305
310
|
param: n,
|
|
306
|
-
value:
|
|
307
|
-
onChange: (t) =>
|
|
308
|
-
statusGroups:
|
|
309
|
-
formData:
|
|
311
|
+
value: q[e],
|
|
312
|
+
onChange: (t) => Y(e, t),
|
|
313
|
+
statusGroups: H,
|
|
314
|
+
formData: q
|
|
310
315
|
});
|
|
311
|
-
else if (n.type === "status") i = /* @__PURE__ */ x(
|
|
316
|
+
else if (n.type === "status") i = /* @__PURE__ */ x(j, {
|
|
312
317
|
param: n,
|
|
313
|
-
value:
|
|
314
|
-
onChange: (t) =>
|
|
315
|
-
statusGroups:
|
|
316
|
-
formData:
|
|
318
|
+
value: q[e],
|
|
319
|
+
onChange: (t) => Y(e, t),
|
|
320
|
+
statusGroups: H,
|
|
321
|
+
formData: q
|
|
317
322
|
});
|
|
318
323
|
else {
|
|
319
|
-
let t =
|
|
324
|
+
let t = E(n);
|
|
320
325
|
i = o({
|
|
321
326
|
field: t,
|
|
322
327
|
fieldName: e,
|
|
323
|
-
value:
|
|
328
|
+
value: q[e],
|
|
324
329
|
mode: "edit",
|
|
325
|
-
onChange: (t) =>
|
|
326
|
-
t:
|
|
330
|
+
onChange: (t) => Y(e, t),
|
|
331
|
+
t: N
|
|
327
332
|
});
|
|
328
333
|
}
|
|
329
334
|
return /* @__PURE__ */ S("div", {
|
|
@@ -341,7 +346,7 @@ function j({ open: n, onOpenChange: c, action: u, actionName: d, onSubmit: C, is
|
|
|
341
346
|
marginTop: 4,
|
|
342
347
|
marginBottom: 0
|
|
343
348
|
},
|
|
344
|
-
children:
|
|
349
|
+
children: N(n.display.description)
|
|
345
350
|
})
|
|
346
351
|
]
|
|
347
352
|
}, e);
|
|
@@ -363,21 +368,21 @@ function j({ open: n, onOpenChange: c, action: u, actionName: d, onSubmit: C, is
|
|
|
363
368
|
children: [
|
|
364
369
|
/* @__PURE__ */ x("div", { style: { flex: 1 } }),
|
|
365
370
|
/* @__PURE__ */ x(e, {
|
|
366
|
-
onClick:
|
|
367
|
-
disabled:
|
|
368
|
-
children:
|
|
371
|
+
onClick: z,
|
|
372
|
+
disabled: D,
|
|
373
|
+
children: N("dialog.cancel", "Cancel")
|
|
369
374
|
}),
|
|
370
375
|
/* @__PURE__ */ x(e, {
|
|
371
376
|
kind: "primary",
|
|
372
|
-
danger:
|
|
373
|
-
icon: x(
|
|
374
|
-
onClick:
|
|
375
|
-
disabled:
|
|
376
|
-
children:
|
|
377
|
+
danger: L,
|
|
378
|
+
icon: x(D ? a : L ? r.trash : r.bolt, { size: 13 }),
|
|
379
|
+
onClick: X,
|
|
380
|
+
disabled: D,
|
|
381
|
+
children: D ? N("action.dialog.working", "Working…") : d || N("dialog.confirm", "Confirm")
|
|
377
382
|
})
|
|
378
383
|
]
|
|
379
384
|
})
|
|
380
385
|
]
|
|
381
386
|
})] }) : null;
|
|
382
387
|
}
|
|
383
|
-
export {
|
|
388
|
+
export { M as ActionDialog };
|
|
@@ -121,7 +121,9 @@ function F({ children: r }) {
|
|
|
121
121
|
};
|
|
122
122
|
switch (a.kind) {
|
|
123
123
|
case "success": {
|
|
124
|
-
let i = k(o)
|
|
124
|
+
let i = k(o);
|
|
125
|
+
if (!r && !i && O(o)) return;
|
|
126
|
+
let a = i ? { action: {
|
|
125
127
|
label: l("action.result.download", "Download"),
|
|
126
128
|
onClick: () => {
|
|
127
129
|
n(u, i.url, i.filename).catch((e) => {
|
|
@@ -14,12 +14,16 @@ function a(e) {
|
|
|
14
14
|
}
|
|
15
15
|
function o({ value: o, onChange: s, readOnly: c, id: l }) {
|
|
16
16
|
let u = t(null), d = t(null), f = t(s);
|
|
17
|
-
|
|
17
|
+
e(() => {
|
|
18
18
|
f.current = s;
|
|
19
|
-
}, [s])
|
|
19
|
+
}, [s]);
|
|
20
|
+
let p = t(o);
|
|
21
|
+
return e(() => {
|
|
22
|
+
p.current = o;
|
|
23
|
+
}, [o]), e(() => {
|
|
20
24
|
if (!u.current) return;
|
|
21
25
|
let e = {
|
|
22
|
-
content: a(
|
|
26
|
+
content: a(p.current),
|
|
23
27
|
readOnly: c ?? !1,
|
|
24
28
|
mode: c ? r.tree : r.text,
|
|
25
29
|
mainMenuBar: !c,
|
|
@@ -45,12 +49,12 @@ function o({ value: o, onChange: s, readOnly: c, id: l }) {
|
|
|
45
49
|
attributes: !0,
|
|
46
50
|
attributeFilter: ["data-color-scheme"]
|
|
47
51
|
});
|
|
48
|
-
let
|
|
52
|
+
let o = i({
|
|
49
53
|
target: u.current,
|
|
50
54
|
props: e
|
|
51
55
|
});
|
|
52
|
-
return d.current =
|
|
53
|
-
n.disconnect(),
|
|
56
|
+
return d.current = o, () => {
|
|
57
|
+
n.disconnect(), o.destroy(), d.current = null;
|
|
54
58
|
};
|
|
55
59
|
}, [c]), e(() => {
|
|
56
60
|
d.current && c && d.current.updateProps({ content: a(o) });
|