@panneau/forms 5.0.0-alpha.4 → 5.0.0-alpha.42
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/README.md +12 -10
- package/dist/ConflictDialog.js +200 -63
- package/dist/ConflictDialog.js.map +1 -1
- package/dist/ErrorSummary.js.map +1 -1
- package/dist/FieldErrorBoundary.js.map +1 -1
- package/dist/Form.css +98 -23
- package/dist/Form.d.ts +3 -2
- package/dist/Form.d.ts.map +1 -1
- package/dist/Form.js +122 -21
- package/dist/Form.js.map +1 -1
- package/dist/Form.module.js +29 -10
- package/dist/Form.module.js.map +1 -1
- package/dist/FormBinding.d.ts.map +1 -1
- package/dist/FormBinding.js +78 -67
- package/dist/FormBinding.js.map +1 -1
- package/dist/FormSkeleton.d.ts +23 -0
- package/dist/FormSkeleton.d.ts.map +1 -0
- package/dist/FormSkeleton.js +435 -0
- package/dist/FormSkeleton.js.map +1 -0
- package/dist/FormView.d.ts +43 -4
- package/dist/FormView.d.ts.map +1 -1
- package/dist/FormView.js +335 -121
- package/dist/FormView.js.map +1 -1
- package/dist/context.d.ts +8 -8
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +8 -16
- package/dist/context.js.map +1 -1
- package/dist/cx.js.map +1 -1
- package/dist/describe.js.map +1 -1
- package/dist/formatError.d.ts +2 -2
- package/dist/formatError.d.ts.map +1 -1
- package/dist/formatError.js +31 -5
- package/dist/formatError.js.map +1 -1
- package/dist/index.d.ts +11 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/layout/Layout.d.ts +28 -0
- package/dist/layout/Layout.d.ts.map +1 -1
- package/dist/layout/Layout.js +331 -89
- package/dist/layout/Layout.js.map +1 -1
- package/dist/locales/index.js.map +1 -1
- package/dist/panels/SaveControls.d.ts +27 -0
- package/dist/panels/SaveControls.d.ts.map +1 -0
- package/dist/panels/SaveControls.js +90 -0
- package/dist/panels/SaveControls.js.map +1 -0
- package/dist/panels/panels.d.ts +34 -0
- package/dist/panels/panels.d.ts.map +1 -0
- package/dist/panels/panels.js +61 -0
- package/dist/panels/panels.js.map +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +2 -1
- package/dist/paths.js.map +1 -1
- package/dist/publication/Publication.d.ts +57 -0
- package/dist/publication/Publication.d.ts.map +1 -0
- package/dist/publication/Publication.js +427 -0
- package/dist/publication/Publication.js.map +1 -0
- package/dist/publication/index.d.ts +4 -0
- package/dist/publication/index.d.ts.map +1 -0
- package/dist/publication/index.js +1 -0
- package/dist/unsaved.js.map +1 -1
- package/package.json +16 -9
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import { messages } from "./messages.js";
|
|
2
|
+
import Form_module_default from "./Form.module.js";
|
|
3
|
+
import { cx } from "./cx.js";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
|
+
import { Aside, AsideLayout, AsidePanel, LoadingRegion, Skeleton, usePanneauIntl } from "@panneau/ui";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { isWideField } from "@panneau/fields";
|
|
8
|
+
//#region src/FormSkeleton.tsx
|
|
9
|
+
/** The height of a field's control, by type: one line, unless the type says otherwise. */
|
|
10
|
+
var HEIGHTS = {
|
|
11
|
+
textarea: "6rem",
|
|
12
|
+
json: "8rem",
|
|
13
|
+
richtext: "10rem",
|
|
14
|
+
html: "10rem",
|
|
15
|
+
file: "6rem",
|
|
16
|
+
media: "6rem",
|
|
17
|
+
image: "8rem",
|
|
18
|
+
group: "8rem",
|
|
19
|
+
repeater: "8rem",
|
|
20
|
+
location: "16rem"
|
|
21
|
+
};
|
|
22
|
+
/** A label's line, about as wide as its text. */
|
|
23
|
+
function LabelSkeleton(t0) {
|
|
24
|
+
const $ = c(2);
|
|
25
|
+
const { text } = t0;
|
|
26
|
+
const length = Math.max(4, Math.min(text?.length ?? 10, 40));
|
|
27
|
+
const t1 = `${String(length)}ch`;
|
|
28
|
+
let t2;
|
|
29
|
+
if ($[0] !== t1) {
|
|
30
|
+
t2 = /* @__PURE__ */ jsx(Skeleton, {
|
|
31
|
+
className: Form_module_default.skeletonLabel,
|
|
32
|
+
width: t1
|
|
33
|
+
});
|
|
34
|
+
$[0] = t1;
|
|
35
|
+
$[1] = t2;
|
|
36
|
+
} else t2 = $[1];
|
|
37
|
+
return t2;
|
|
38
|
+
}
|
|
39
|
+
function FieldSkeleton(t0) {
|
|
40
|
+
const $ = c(10);
|
|
41
|
+
const { field } = t0;
|
|
42
|
+
if (field?.type === "boolean") {
|
|
43
|
+
let t1;
|
|
44
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
45
|
+
t1 = /* @__PURE__ */ jsx(Skeleton, {
|
|
46
|
+
shape: "rect",
|
|
47
|
+
width: "1.25rem",
|
|
48
|
+
height: "1.25rem"
|
|
49
|
+
});
|
|
50
|
+
$[0] = t1;
|
|
51
|
+
} else t1 = $[0];
|
|
52
|
+
let t2;
|
|
53
|
+
if ($[1] !== field.label) {
|
|
54
|
+
t2 = /* @__PURE__ */ jsxs("div", {
|
|
55
|
+
className: Form_module_default.skeletonInline,
|
|
56
|
+
children: [t1, /* @__PURE__ */ jsx(LabelSkeleton, { text: field.label })]
|
|
57
|
+
});
|
|
58
|
+
$[1] = field.label;
|
|
59
|
+
$[2] = t2;
|
|
60
|
+
} else t2 = $[2];
|
|
61
|
+
return t2;
|
|
62
|
+
}
|
|
63
|
+
const t1 = field?.label ?? field?.name;
|
|
64
|
+
let t2;
|
|
65
|
+
if ($[3] !== t1) {
|
|
66
|
+
t2 = /* @__PURE__ */ jsx(LabelSkeleton, { text: t1 });
|
|
67
|
+
$[3] = t1;
|
|
68
|
+
$[4] = t2;
|
|
69
|
+
} else t2 = $[4];
|
|
70
|
+
const t3 = HEIGHTS[field?.type ?? ""] ?? "var(--panneau-control-height)";
|
|
71
|
+
let t4;
|
|
72
|
+
if ($[5] !== t3) {
|
|
73
|
+
t4 = /* @__PURE__ */ jsx(Skeleton, {
|
|
74
|
+
shape: "rect",
|
|
75
|
+
height: t3
|
|
76
|
+
});
|
|
77
|
+
$[5] = t3;
|
|
78
|
+
$[6] = t4;
|
|
79
|
+
} else t4 = $[6];
|
|
80
|
+
let t5;
|
|
81
|
+
if ($[7] !== t2 || $[8] !== t4) {
|
|
82
|
+
t5 = /* @__PURE__ */ jsxs("div", {
|
|
83
|
+
className: Form_module_default.skeletonField,
|
|
84
|
+
children: [t2, t4]
|
|
85
|
+
});
|
|
86
|
+
$[7] = t2;
|
|
87
|
+
$[8] = t4;
|
|
88
|
+
$[9] = t5;
|
|
89
|
+
} else t5 = $[9];
|
|
90
|
+
return t5;
|
|
91
|
+
}
|
|
92
|
+
function NodeSkeleton(t0) {
|
|
93
|
+
const $ = c(45);
|
|
94
|
+
const { node, fields } = t0;
|
|
95
|
+
switch (node.type) {
|
|
96
|
+
case "field": {
|
|
97
|
+
let t1;
|
|
98
|
+
if ($[0] !== fields || $[1] !== node.name) {
|
|
99
|
+
t1 = node.name !== void 0 && fields.has(node.name) ? /* @__PURE__ */ jsx(FieldSkeleton, { field: fields.get(node.name) }) : null;
|
|
100
|
+
$[0] = fields;
|
|
101
|
+
$[1] = node.name;
|
|
102
|
+
$[2] = t1;
|
|
103
|
+
} else t1 = $[2];
|
|
104
|
+
return t1;
|
|
105
|
+
}
|
|
106
|
+
case "row": {
|
|
107
|
+
let t1;
|
|
108
|
+
if ($[3] !== node.children) {
|
|
109
|
+
t1 = node.children ?? [];
|
|
110
|
+
$[3] = node.children;
|
|
111
|
+
$[4] = t1;
|
|
112
|
+
} else t1 = $[4];
|
|
113
|
+
let t2;
|
|
114
|
+
if ($[5] !== fields || $[6] !== t1) {
|
|
115
|
+
let t3;
|
|
116
|
+
if ($[8] !== fields) {
|
|
117
|
+
t3 = (child_0, index_0) => /* @__PURE__ */ jsx("div", {
|
|
118
|
+
className: Form_module_default.cell,
|
|
119
|
+
style: { "--panneau-span": child_0.width ?? 12 },
|
|
120
|
+
children: /* @__PURE__ */ jsx(NodeSkeleton, {
|
|
121
|
+
node: child_0,
|
|
122
|
+
fields
|
|
123
|
+
})
|
|
124
|
+
}, index_0);
|
|
125
|
+
$[8] = fields;
|
|
126
|
+
$[9] = t3;
|
|
127
|
+
} else t3 = $[9];
|
|
128
|
+
t2 = t1.map(t3);
|
|
129
|
+
$[5] = fields;
|
|
130
|
+
$[6] = t1;
|
|
131
|
+
$[7] = t2;
|
|
132
|
+
} else t2 = $[7];
|
|
133
|
+
let t3;
|
|
134
|
+
if ($[10] !== t2) {
|
|
135
|
+
t3 = /* @__PURE__ */ jsx("div", {
|
|
136
|
+
className: Form_module_default.row,
|
|
137
|
+
children: t2
|
|
138
|
+
});
|
|
139
|
+
$[10] = t2;
|
|
140
|
+
$[11] = t3;
|
|
141
|
+
} else t3 = $[11];
|
|
142
|
+
return t3;
|
|
143
|
+
}
|
|
144
|
+
case "tabs": {
|
|
145
|
+
let t1;
|
|
146
|
+
let t2;
|
|
147
|
+
let t3;
|
|
148
|
+
let tabs;
|
|
149
|
+
if ($[12] !== node.children) {
|
|
150
|
+
tabs = (node.children ?? []).filter(_temp);
|
|
151
|
+
t3 = Form_module_default.stack;
|
|
152
|
+
t1 = Form_module_default.skeletonTabs;
|
|
153
|
+
t2 = tabs.map(_temp2);
|
|
154
|
+
$[12] = node.children;
|
|
155
|
+
$[13] = t1;
|
|
156
|
+
$[14] = t2;
|
|
157
|
+
$[15] = t3;
|
|
158
|
+
$[16] = tabs;
|
|
159
|
+
} else {
|
|
160
|
+
t1 = $[13];
|
|
161
|
+
t2 = $[14];
|
|
162
|
+
t3 = $[15];
|
|
163
|
+
tabs = $[16];
|
|
164
|
+
}
|
|
165
|
+
let t4;
|
|
166
|
+
if ($[17] !== t1 || $[18] !== t2) {
|
|
167
|
+
t4 = /* @__PURE__ */ jsx("div", {
|
|
168
|
+
className: t1,
|
|
169
|
+
children: t2
|
|
170
|
+
});
|
|
171
|
+
$[17] = t1;
|
|
172
|
+
$[18] = t2;
|
|
173
|
+
$[19] = t4;
|
|
174
|
+
} else t4 = $[19];
|
|
175
|
+
let t5;
|
|
176
|
+
if ($[20] !== tabs[0]?.children) {
|
|
177
|
+
t5 = tabs[0]?.children ?? [];
|
|
178
|
+
$[20] = tabs[0]?.children;
|
|
179
|
+
$[21] = t5;
|
|
180
|
+
} else t5 = $[21];
|
|
181
|
+
let t6;
|
|
182
|
+
if ($[22] !== fields || $[23] !== t5) {
|
|
183
|
+
t6 = /* @__PURE__ */ jsx(NodesSkeleton, {
|
|
184
|
+
nodes: t5,
|
|
185
|
+
fields
|
|
186
|
+
});
|
|
187
|
+
$[22] = fields;
|
|
188
|
+
$[23] = t5;
|
|
189
|
+
$[24] = t6;
|
|
190
|
+
} else t6 = $[24];
|
|
191
|
+
let t7;
|
|
192
|
+
if ($[25] !== t3 || $[26] !== t4 || $[27] !== t6) {
|
|
193
|
+
t7 = /* @__PURE__ */ jsxs("div", {
|
|
194
|
+
className: t3,
|
|
195
|
+
children: [t4, t6]
|
|
196
|
+
});
|
|
197
|
+
$[25] = t3;
|
|
198
|
+
$[26] = t4;
|
|
199
|
+
$[27] = t6;
|
|
200
|
+
$[28] = t7;
|
|
201
|
+
} else t7 = $[28];
|
|
202
|
+
return t7;
|
|
203
|
+
}
|
|
204
|
+
case "section": {
|
|
205
|
+
let t1;
|
|
206
|
+
if ($[29] !== node.label) {
|
|
207
|
+
t1 = node.label !== void 0 ? /* @__PURE__ */ jsx(Skeleton, {
|
|
208
|
+
className: Form_module_default.sectionTitle,
|
|
209
|
+
width: `${String(Math.min(node.label.length, 40))}ch`
|
|
210
|
+
}) : null;
|
|
211
|
+
$[29] = node.label;
|
|
212
|
+
$[30] = t1;
|
|
213
|
+
} else t1 = $[30];
|
|
214
|
+
let t2;
|
|
215
|
+
if ($[31] !== fields || $[32] !== node.children || $[33] !== node.collapsed || $[34] !== node.collapsible) {
|
|
216
|
+
t2 = node.collapsible === true && node.collapsed === true ? null : /* @__PURE__ */ jsx(NodesSkeleton, {
|
|
217
|
+
nodes: node.children ?? [],
|
|
218
|
+
fields
|
|
219
|
+
});
|
|
220
|
+
$[31] = fields;
|
|
221
|
+
$[32] = node.children;
|
|
222
|
+
$[33] = node.collapsed;
|
|
223
|
+
$[34] = node.collapsible;
|
|
224
|
+
$[35] = t2;
|
|
225
|
+
} else t2 = $[35];
|
|
226
|
+
let t3;
|
|
227
|
+
if ($[36] !== t1 || $[37] !== t2) {
|
|
228
|
+
t3 = /* @__PURE__ */ jsxs("div", {
|
|
229
|
+
className: Form_module_default.section,
|
|
230
|
+
children: [t1, t2]
|
|
231
|
+
});
|
|
232
|
+
$[36] = t1;
|
|
233
|
+
$[37] = t2;
|
|
234
|
+
$[38] = t3;
|
|
235
|
+
} else t3 = $[38];
|
|
236
|
+
return t3;
|
|
237
|
+
}
|
|
238
|
+
case "text": {
|
|
239
|
+
let t1;
|
|
240
|
+
if ($[39] === Symbol.for("react.memo_cache_sentinel")) {
|
|
241
|
+
t1 = /* @__PURE__ */ jsx(Skeleton, {
|
|
242
|
+
className: Form_module_default.text,
|
|
243
|
+
lines: 2
|
|
244
|
+
});
|
|
245
|
+
$[39] = t1;
|
|
246
|
+
} else t1 = $[39];
|
|
247
|
+
return t1;
|
|
248
|
+
}
|
|
249
|
+
default: {
|
|
250
|
+
let t1;
|
|
251
|
+
if ($[40] !== node.children) {
|
|
252
|
+
t1 = node.children ?? [];
|
|
253
|
+
$[40] = node.children;
|
|
254
|
+
$[41] = t1;
|
|
255
|
+
} else t1 = $[41];
|
|
256
|
+
let t2;
|
|
257
|
+
if ($[42] !== fields || $[43] !== t1) {
|
|
258
|
+
t2 = /* @__PURE__ */ jsx(NodesSkeleton, {
|
|
259
|
+
nodes: t1,
|
|
260
|
+
fields
|
|
261
|
+
});
|
|
262
|
+
$[42] = fields;
|
|
263
|
+
$[43] = t1;
|
|
264
|
+
$[44] = t2;
|
|
265
|
+
} else t2 = $[44];
|
|
266
|
+
return t2;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function _temp2(tab, index) {
|
|
271
|
+
return /* @__PURE__ */ jsx(LabelSkeleton, { text: tab.label }, index);
|
|
272
|
+
}
|
|
273
|
+
function _temp(child) {
|
|
274
|
+
return child.type === "tab";
|
|
275
|
+
}
|
|
276
|
+
function NodesSkeleton(t0) {
|
|
277
|
+
const $ = c(7);
|
|
278
|
+
const { nodes, fields } = t0;
|
|
279
|
+
let t1;
|
|
280
|
+
if ($[0] !== fields || $[1] !== nodes) {
|
|
281
|
+
let t2;
|
|
282
|
+
if ($[3] !== fields) {
|
|
283
|
+
t2 = (node, index) => /* @__PURE__ */ jsx(NodeSkeleton, {
|
|
284
|
+
node,
|
|
285
|
+
fields
|
|
286
|
+
}, index);
|
|
287
|
+
$[3] = fields;
|
|
288
|
+
$[4] = t2;
|
|
289
|
+
} else t2 = $[4];
|
|
290
|
+
t1 = nodes.map(t2);
|
|
291
|
+
$[0] = fields;
|
|
292
|
+
$[1] = nodes;
|
|
293
|
+
$[2] = t1;
|
|
294
|
+
} else t1 = $[2];
|
|
295
|
+
let t2;
|
|
296
|
+
if ($[5] !== t1) {
|
|
297
|
+
t2 = /* @__PURE__ */ jsx("div", {
|
|
298
|
+
className: Form_module_default.stack,
|
|
299
|
+
children: t1
|
|
300
|
+
});
|
|
301
|
+
$[5] = t1;
|
|
302
|
+
$[6] = t2;
|
|
303
|
+
} else t2 = $[6];
|
|
304
|
+
return t2;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* A form whose values load (decision 0034): its layout, and for each field its label and a block
|
|
308
|
+
* of the field's height, from its type. The fields of the first tab are drawn, and conditions are
|
|
309
|
+
* not checked, since there are no values yet.
|
|
310
|
+
*/
|
|
311
|
+
function FormSkeleton(t0) {
|
|
312
|
+
const $ = c(32);
|
|
313
|
+
const { main, flow: t1, sidebar, fields, footer, className, layoutClassName, sidebarClassName, footerClassName } = t0;
|
|
314
|
+
let t2;
|
|
315
|
+
if ($[0] !== t1) {
|
|
316
|
+
t2 = t1 === void 0 ? [] : t1;
|
|
317
|
+
$[0] = t1;
|
|
318
|
+
$[1] = t2;
|
|
319
|
+
} else t2 = $[1];
|
|
320
|
+
const flow = t2;
|
|
321
|
+
const intl = usePanneauIntl();
|
|
322
|
+
let t3;
|
|
323
|
+
if ($[2] !== intl) {
|
|
324
|
+
t3 = intl.formatMessage(messages.loading);
|
|
325
|
+
$[2] = intl;
|
|
326
|
+
$[3] = t3;
|
|
327
|
+
} else t3 = $[3];
|
|
328
|
+
let t4;
|
|
329
|
+
if ($[4] !== className) {
|
|
330
|
+
t4 = cx(Form_module_default.form, className);
|
|
331
|
+
$[4] = className;
|
|
332
|
+
$[5] = t4;
|
|
333
|
+
} else t4 = $[5];
|
|
334
|
+
let t5;
|
|
335
|
+
if ($[6] !== layoutClassName) {
|
|
336
|
+
t5 = layoutClassName !== void 0 ? { className: layoutClassName } : {};
|
|
337
|
+
$[6] = layoutClassName;
|
|
338
|
+
$[7] = t5;
|
|
339
|
+
} else t5 = $[7];
|
|
340
|
+
let t6;
|
|
341
|
+
if ($[8] !== fields || $[9] !== intl || $[10] !== sidebar || $[11] !== sidebarClassName) {
|
|
342
|
+
t6 = sidebar.length > 0 ? /* @__PURE__ */ jsx(Aside, {
|
|
343
|
+
label: intl.formatMessage(messages.sidebar),
|
|
344
|
+
...sidebarClassName !== void 0 ? { className: sidebarClassName } : {},
|
|
345
|
+
children: sidebar.map((node, index) => /* @__PURE__ */ jsx(AsidePanel, {
|
|
346
|
+
title: node.label,
|
|
347
|
+
isCollapsible: false,
|
|
348
|
+
children: /* @__PURE__ */ jsx(NodesSkeleton, {
|
|
349
|
+
nodes: node.children ?? [],
|
|
350
|
+
fields
|
|
351
|
+
})
|
|
352
|
+
}, index))
|
|
353
|
+
}) : null;
|
|
354
|
+
$[8] = fields;
|
|
355
|
+
$[9] = intl;
|
|
356
|
+
$[10] = sidebar;
|
|
357
|
+
$[11] = sidebarClassName;
|
|
358
|
+
$[12] = t6;
|
|
359
|
+
} else t6 = $[12];
|
|
360
|
+
let t7;
|
|
361
|
+
if ($[13] !== fields || $[14] !== main) {
|
|
362
|
+
t7 = /* @__PURE__ */ jsx(NodesSkeleton, {
|
|
363
|
+
nodes: main,
|
|
364
|
+
fields
|
|
365
|
+
});
|
|
366
|
+
$[13] = fields;
|
|
367
|
+
$[14] = main;
|
|
368
|
+
$[15] = t7;
|
|
369
|
+
} else t7 = $[15];
|
|
370
|
+
let t8;
|
|
371
|
+
if ($[16] !== fields || $[17] !== flow) {
|
|
372
|
+
t8 = flow.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
373
|
+
className: Form_module_default.flow,
|
|
374
|
+
children: flow.map((node_0, index_0) => {
|
|
375
|
+
const field = node_0.name !== void 0 ? fields.get(node_0.name) : void 0;
|
|
376
|
+
return /* @__PURE__ */ jsx("div", {
|
|
377
|
+
className: cx(Form_module_default.flowCell, (field === void 0 || isWideField(field)) && Form_module_default.flowWide),
|
|
378
|
+
children: /* @__PURE__ */ jsx(NodeSkeleton, {
|
|
379
|
+
node: node_0,
|
|
380
|
+
fields
|
|
381
|
+
})
|
|
382
|
+
}, index_0);
|
|
383
|
+
})
|
|
384
|
+
}) : null;
|
|
385
|
+
$[16] = fields;
|
|
386
|
+
$[17] = flow;
|
|
387
|
+
$[18] = t8;
|
|
388
|
+
} else t8 = $[18];
|
|
389
|
+
let t9;
|
|
390
|
+
if ($[19] !== t5 || $[20] !== t6 || $[21] !== t7 || $[22] !== t8) {
|
|
391
|
+
t9 = /* @__PURE__ */ jsxs(AsideLayout, {
|
|
392
|
+
...t5,
|
|
393
|
+
mainClassName: Form_module_default.stack,
|
|
394
|
+
aside: t6,
|
|
395
|
+
children: [t7, t8]
|
|
396
|
+
});
|
|
397
|
+
$[19] = t5;
|
|
398
|
+
$[20] = t6;
|
|
399
|
+
$[21] = t7;
|
|
400
|
+
$[22] = t8;
|
|
401
|
+
$[23] = t9;
|
|
402
|
+
} else t9 = $[23];
|
|
403
|
+
let t10;
|
|
404
|
+
if ($[24] !== footer || $[25] !== footerClassName) {
|
|
405
|
+
t10 = footer ? /* @__PURE__ */ jsx("div", {
|
|
406
|
+
className: cx(Form_module_default.footer, footerClassName),
|
|
407
|
+
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
408
|
+
shape: "rect",
|
|
409
|
+
width: "6rem",
|
|
410
|
+
height: "var(--panneau-control-height)"
|
|
411
|
+
})
|
|
412
|
+
}) : null;
|
|
413
|
+
$[24] = footer;
|
|
414
|
+
$[25] = footerClassName;
|
|
415
|
+
$[26] = t10;
|
|
416
|
+
} else t10 = $[26];
|
|
417
|
+
let t11;
|
|
418
|
+
if ($[27] !== t10 || $[28] !== t3 || $[29] !== t4 || $[30] !== t9) {
|
|
419
|
+
t11 = /* @__PURE__ */ jsxs(LoadingRegion, {
|
|
420
|
+
label: t3,
|
|
421
|
+
className: t4,
|
|
422
|
+
children: [t9, t10]
|
|
423
|
+
});
|
|
424
|
+
$[27] = t10;
|
|
425
|
+
$[28] = t3;
|
|
426
|
+
$[29] = t4;
|
|
427
|
+
$[30] = t9;
|
|
428
|
+
$[31] = t11;
|
|
429
|
+
} else t11 = $[31];
|
|
430
|
+
return t11;
|
|
431
|
+
}
|
|
432
|
+
//#endregion
|
|
433
|
+
export { FormSkeleton };
|
|
434
|
+
|
|
435
|
+
//# sourceMappingURL=FormSkeleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormSkeleton.js","names":["CSSProperties","ReactNode","isWideField","Field","LayoutNode","Aside","AsideLayout","AsidePanel","LoadingRegion","Skeleton","usePanneauIntl","styles","cx","messages","HEIGHTS","Readonly","Record","textarea","json","richtext","html","file","media","image","group","repeater","location","LabelSkeleton","t0","$","_c","text","length","Math","max","min","t1","String","t2","skeletonLabel","FieldSkeleton","field","type","Symbol","for","label","skeletonInline","name","t3","t4","t5","skeletonField","NodeSkeleton","node","fields","undefined","has","get","children","child_0","index_0","index","cell","child","width","map","row","tabs","filter","_temp","stack","skeletonTabs","_temp2","t6","t7","sectionTitle","collapsed","collapsible","section","tab","NodesSkeleton","nodes","FormSkeletonProps","main","flow","sidebar","ReadonlyMap","footer","className","layoutClassName","sidebarClassName","footerClassName","FormSkeleton","intl","formatMessage","loading","form","t8","node_0","flowCell","flowWide","t9","t10","t11","_c","styles"],"sources":["../src/FormSkeleton.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from 'react';\n\nimport { isWideField } from '@panneau/fields';\nimport type { Field, LayoutNode } from '@panneau/protocol';\nimport {\n Aside,\n AsideLayout,\n AsidePanel,\n LoadingRegion,\n Skeleton,\n usePanneauIntl,\n} from '@panneau/ui';\n\nimport styles from './Form.module.css';\nimport { cx } from './cx';\nimport { messages } from './messages';\n\n/** The height of a field's control, by type: one line, unless the type says otherwise. */\nconst HEIGHTS: Readonly<Record<string, string>> = {\n textarea: '6rem',\n json: '8rem',\n richtext: '10rem',\n html: '10rem',\n file: '6rem',\n media: '6rem',\n image: '8rem',\n group: '8rem',\n repeater: '8rem',\n location: '16rem',\n};\n\n/** A label's line, about as wide as its text. */\nfunction LabelSkeleton({ text }: { text: string | undefined }) {\n const length = Math.max(4, Math.min(text?.length ?? 10, 40));\n return <Skeleton className={styles.skeletonLabel} width={`${String(length)}ch`} />;\n}\n\nfunction FieldSkeleton({ field }: { field: Field | undefined }) {\n if (field?.type === 'boolean') {\n return (\n <div className={styles.skeletonInline}>\n <Skeleton shape=\"rect\" width=\"1.25rem\" height=\"1.25rem\" />\n <LabelSkeleton text={field.label} />\n </div>\n );\n }\n return (\n <div className={styles.skeletonField}>\n <LabelSkeleton text={field?.label ?? field?.name} />\n <Skeleton\n shape=\"rect\"\n height={HEIGHTS[field?.type ?? ''] ?? 'var(--panneau-control-height)'}\n />\n </div>\n );\n}\n\nfunction NodeSkeleton({\n node,\n fields,\n}: {\n node: LayoutNode;\n fields: ReadonlyMap<string, Field>;\n}): ReactNode {\n switch (node.type) {\n case 'field':\n return node.name !== undefined && fields.has(node.name) ? (\n <FieldSkeleton field={fields.get(node.name)} />\n ) : null;\n case 'row':\n return (\n <div className={styles.row}>\n {(node.children ?? []).map((child, index) => (\n <div\n key={index}\n className={styles.cell}\n style={{ '--panneau-span': child.width ?? 12 } as CSSProperties}\n >\n <NodeSkeleton node={child} fields={fields} />\n </div>\n ))}\n </div>\n );\n case 'tabs': {\n // The tabs, and the content of the first one.\n const tabs = (node.children ?? []).filter((child) => child.type === 'tab');\n return (\n <div className={styles.stack}>\n <div className={styles.skeletonTabs}>\n {tabs.map((tab, index) => (\n <LabelSkeleton key={index} text={tab.label} />\n ))}\n </div>\n <NodesSkeleton nodes={tabs[0]?.children ?? []} fields={fields} />\n </div>\n );\n }\n case 'section':\n return (\n <div className={styles.section}>\n {node.label !== undefined ? (\n <Skeleton\n className={styles.sectionTitle}\n width={`${String(Math.min(node.label.length, 40))}ch`}\n />\n ) : null}\n {node.collapsible === true && node.collapsed === true ? null : (\n <NodesSkeleton nodes={node.children ?? []} fields={fields} />\n )}\n </div>\n );\n case 'text':\n return <Skeleton className={styles.text} lines={2} />;\n default:\n // Containers out of place, unknown ones, and the fields a `component` node frames.\n return <NodesSkeleton nodes={node.children ?? []} fields={fields} />;\n }\n}\n\nfunction NodesSkeleton({\n nodes,\n fields,\n}: {\n nodes: readonly LayoutNode[];\n fields: ReadonlyMap<string, Field>;\n}) {\n return (\n <div className={styles.stack}>\n {nodes.map((node, index) => (\n <NodeSkeleton key={index} node={node} fields={fields} />\n ))}\n </div>\n );\n}\n\nexport interface FormSkeletonProps {\n /** The main nodes of the layout. */\n main: readonly LayoutNode[];\n /** The fields that the layout doesn't place, which flow in columns after it. */\n flow?: readonly LayoutNode[];\n /** The sidebars of the layout. */\n sidebar: readonly LayoutNode[];\n fields: ReadonlyMap<string, Field>;\n /** Draws the footer, with its button. */\n footer: boolean;\n className?: string | undefined;\n layoutClassName?: string | undefined;\n sidebarClassName?: string | undefined;\n footerClassName?: string | undefined;\n}\n\n/**\n * A form whose values load (decision 0034): its layout, and for each field its label and a block\n * of the field's height, from its type. The fields of the first tab are drawn, and conditions are\n * not checked, since there are no values yet.\n */\nexport function FormSkeleton({\n main,\n flow = [],\n sidebar,\n fields,\n footer,\n className,\n layoutClassName,\n sidebarClassName,\n footerClassName,\n}: FormSkeletonProps) {\n const intl = usePanneauIntl();\n return (\n <LoadingRegion\n label={intl.formatMessage(messages.loading)}\n className={cx(styles.form, className)}\n >\n <AsideLayout\n {...(layoutClassName !== undefined ? { className: layoutClassName } : {})}\n mainClassName={styles.stack}\n aside={\n sidebar.length > 0 ? (\n <Aside\n label={intl.formatMessage(messages.sidebar)}\n {...(sidebarClassName !== undefined\n ? { className: sidebarClassName }\n : {})}\n >\n {sidebar.map((node, index) => (\n <AsidePanel key={index} title={node.label} isCollapsible={false}>\n <NodesSkeleton nodes={node.children ?? []} fields={fields} />\n </AsidePanel>\n ))}\n </Aside>\n ) : null\n }\n >\n <NodesSkeleton nodes={main} fields={fields} />\n {flow.length > 0 ? (\n <div className={styles.flow}>\n {flow.map((node, index) => {\n const field =\n node.name !== undefined ? fields.get(node.name) : undefined;\n return (\n <div\n key={index}\n className={cx(\n styles.flowCell,\n (field === undefined || isWideField(field)) &&\n styles.flowWide,\n )}\n >\n <NodeSkeleton node={node} fields={fields} />\n </div>\n );\n })}\n </div>\n ) : null}\n </AsideLayout>\n {footer ? (\n <div className={cx(styles.footer, footerClassName)}>\n <Skeleton shape=\"rect\" width=\"6rem\" height=\"var(--panneau-control-height)\" />\n </div>\n ) : null}\n </LoadingRegion>\n );\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAMc,UAA4C;CAC9CG,UAAU;CACVC,MAAM;CACNC,UAAU;CACVC,MAAM;CACNC,MAAM;CACNC,OAAO;CACPC,OAAO;CACPC,OAAO;CACPC,UAAU;CACVC,UAAU;AACd;;AAGA,SAAAC,cAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAuB,MAAA,EAAAC,SAAAH;CACnB,MAAAI,SAAeC,KAAIC,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AxE,EAAA;CAAA,IAAAyE;CAAA,IAAAzE,EAAA,QAAA0D,UAAA1D,EAAA,QAAA8D,iBAAA;EACbW,MAAAf,SACG,oBAAA,OAAA;GAAgB,WAAA3E,GAAGD,oBAAM4E,QAASI,eAAe;GAC7C,UAAA,oBAAC,UAAD;IAAgB,OAAA;IAAa,OAAA;IAAc,QAAA;GAA+B,CAAA;EACxE,CAAA,IAHT;EAIO9D,EAAA,MAAA0D;EAAA1D,EAAA,MAAA8D;EAAA9D,EAAA,MAAAyE;CAAA,OAAAA,MAAAzE,EAAA;CAAA,IAAA0E;CAAA,IAAA1E,EAAA,QAAAyE,OAAAzE,EAAA,QAAAmB,MAAAnB,EAAA,QAAAoB,MAAApB,EAAA,QAAAwE,IAAA;EAlDZE,MAAA,qBAAC,eAAD;GACW,OAAAvD;GACI,WAAAC;GAFf,UAAA,CAIIoD,IA0CCC,GA9CS;;EAmDEzE,EAAA,MAAAyE;EAAAzE,EAAA,MAAAmB;EAAAnB,EAAA,MAAAoB;EAAApB,EAAA,MAAAwE;EAAAxE,EAAA,MAAA0E;CAAA,OAAAA,MAAA1E,EAAA;CAAA,OAnDhB0E;AAmDgB"}
|
package/dist/FormView.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import { type Form } from '@panneau/core';
|
|
3
|
-
import { type FieldEntry, type RelationSource, type UploadSource } from '@panneau/fields';
|
|
3
|
+
import { type FieldCheckSource, type FieldEntry, type RelationSource, type UploadSource } from '@panneau/fields';
|
|
4
4
|
import type { Field, LayoutNode } from '@panneau/protocol';
|
|
5
|
+
import { type FormPanelComponent } from './panels/panels.js';
|
|
5
6
|
export interface FormViewProps {
|
|
6
7
|
/** The form state, from `useForm()` or `createForm()` of `@panneau/core`. */
|
|
7
8
|
form: Form;
|
|
@@ -18,8 +19,19 @@ export interface FormViewProps {
|
|
|
18
19
|
* parent `FieldsProvider`. Without one, values hold the files themselves.
|
|
19
20
|
*/
|
|
20
21
|
uploadSource?: UploadSource | null;
|
|
22
|
+
/**
|
|
23
|
+
* Where fields with `check` check their value, such as a slug's availability:
|
|
24
|
+
* `createFieldCheckSource(adapter, resource, id)`. Defaults to the one of a parent
|
|
25
|
+
* `FieldsProvider`.
|
|
26
|
+
*/
|
|
27
|
+
checkSource?: FieldCheckSource | null;
|
|
21
28
|
/** Field entries by type, over the built-in ones and those of the plugins. */
|
|
22
29
|
components?: Readonly<Record<string, FieldEntry>>;
|
|
30
|
+
/**
|
|
31
|
+
* Panels of the sidebar, by name, over the built-in ones and those of plugins: the app gives
|
|
32
|
+
* its own (decision 0075).
|
|
33
|
+
*/
|
|
34
|
+
panels?: Readonly<Record<string, FormPanelComponent>>;
|
|
23
35
|
/** Label of the submit button. Defaults to "Save". `null` hides the button. */
|
|
24
36
|
submitLabel?: ReactNode;
|
|
25
37
|
/** Other buttons, next to the submit button. */
|
|
@@ -31,15 +43,39 @@ export interface FormViewProps {
|
|
|
31
43
|
* current item: fetch it, and `form.reset()` with it.
|
|
32
44
|
*/
|
|
33
45
|
onReload?: () => void;
|
|
34
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Asks for confirmation before the page is left with unsaved changes: closed or reloaded, or,
|
|
48
|
+
* under a `LeaveGuardsProvider`, left through the app's router. Defaults to true.
|
|
49
|
+
*/
|
|
35
50
|
guardUnsavedChanges?: boolean;
|
|
36
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Shows "Saved" in a toast after a successful submit, when the form has no footer to say it
|
|
53
|
+
* (no submit button and no `actions`). Defaults to true. A form with a footer says "Saved" in
|
|
54
|
+
* it, next to its button, where "Unsaved changes" was: the page already shows it (decision
|
|
55
|
+
* 0062).
|
|
56
|
+
*/
|
|
37
57
|
showSavedToast?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The item was saved just before the form started over from it (a new `key` after a save):
|
|
60
|
+
* the footer says "Saved" until the values change.
|
|
61
|
+
*/
|
|
62
|
+
saved?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* The values load, such as the item to edit: the form draws a skeleton of its layout and
|
|
65
|
+
* fields instead (decision 0034).
|
|
66
|
+
*/
|
|
67
|
+
isLoading?: boolean;
|
|
38
68
|
id?: string;
|
|
39
69
|
'aria-label'?: string;
|
|
40
70
|
className?: string;
|
|
41
71
|
layoutClassName?: string;
|
|
42
72
|
sidebarClassName?: string;
|
|
73
|
+
/**
|
|
74
|
+
* The key under which the browser remembers the collapsed panels of the sidebar
|
|
75
|
+
* (`panneau:<key>-panel-<label>`), such as `form-articles`. Without one, they last as long as
|
|
76
|
+
* the form.
|
|
77
|
+
*/
|
|
78
|
+
sidebarStorageKey?: string;
|
|
43
79
|
footerClassName?: string;
|
|
44
80
|
summaryClassName?: string;
|
|
45
81
|
}
|
|
@@ -48,6 +84,9 @@ export interface FormViewProps {
|
|
|
48
84
|
* an error summary, a scroll to the first error, error counts on tabs and sections, a guard for
|
|
49
85
|
* unsaved changes and the dialog of version conflicts. Saving is the job of the form's
|
|
50
86
|
* `onSubmit`.
|
|
87
|
+
*
|
|
88
|
+
* ⌘ Enter (Ctrl Enter elsewhere) saves from any of its fields. After a failed save, every
|
|
89
|
+
* collapsed section that holds an error opens, and the first error is focused.
|
|
51
90
|
*/
|
|
52
|
-
export declare function FormView({ form, fields, layout, locales, relationSource, uploadSource, components, submitLabel, actions, onSubmitted, onReload, guardUnsavedChanges, showSavedToast, id, 'aria-label': ariaLabel, className, layoutClassName, sidebarClassName, footerClassName, summaryClassName, }: FormViewProps): import("react").JSX.Element;
|
|
91
|
+
export declare function FormView({ form, fields, layout, locales, relationSource, uploadSource, checkSource, components, panels, submitLabel, actions, onSubmitted, onReload, guardUnsavedChanges, showSavedToast, saved, isLoading, id, 'aria-label': ariaLabel, className, layoutClassName, sidebarClassName, sidebarStorageKey, footerClassName, summaryClassName, }: FormViewProps): import("react").JSX.Element;
|
|
53
92
|
//# sourceMappingURL=FormView.d.ts.map
|
package/dist/FormView.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormView.d.ts","sourceRoot":"","sources":["../src/FormView.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"FormView.d.ts","sourceRoot":"","sources":["../src/FormView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,SAAS,EAAoB,MAAM,OAAO,CAAC;AAE7E,OAAO,EACH,KAAK,IAAI,EASZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,UAAU,EAEf,KAAK,cAAc,EACnB,KAAK,YAAY,EAEpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AA4B3D,OAAO,EAAE,KAAK,kBAAkB,EAAgC,MAAM,iBAAiB,CAAC;AAGxF,MAAM,WAAW,aAAa;IAC1B,6EAA6E;IAC7E,IAAI,EAAE,IAAI,CAAC;IACX,8BAA8B;IAC9B,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IACzB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IAC/B,yFAAyF;IACzF,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,sFAAsF;IACtF,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IACvC;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACnC;;;;OAIG;IACH,WAAW,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACtC,8EAA8E;IAC9E,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAClD;;;OAGG;IACH,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;IACtD,+EAA+E;IAC/E,WAAW,CAAC,E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