@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
package/dist/FormView.js
CHANGED
|
@@ -2,13 +2,17 @@ import { messages } from "./messages.js";
|
|
|
2
2
|
import { ConflictDialog } from "./ConflictDialog.js";
|
|
3
3
|
import Form_module_default from "./Form.module.js";
|
|
4
4
|
import { ErrorSummary } from "./ErrorSummary.js";
|
|
5
|
-
import { FormContext, RevealContext, createRevealRegistry, useFormState } from "./context.js";
|
|
5
|
+
import { ErrorSectionsContext, FormContext, RevealContext, createRevealRegistry as createRevealRegistry$1, useFormState } from "./context.js";
|
|
6
6
|
import { FormBinding } from "./FormBinding.js";
|
|
7
7
|
import { cx } from "./cx.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { FormSkeleton } from "./FormSkeleton.js";
|
|
9
|
+
import { SaveContext, SaveControls, SummaryContext } from "./panels/SaveControls.js";
|
|
10
|
+
import { PanelsContext, builtInPanels } from "./panels/panels.js";
|
|
11
|
+
import { FieldFlow, LayoutNodes, SidebarNode } from "./layout/Layout.js";
|
|
12
|
+
import { useBeforeUnloadGuard, useLeaveConfirmation } from "./unsaved.js";
|
|
13
|
+
import { c } from "react/compiler-runtime";
|
|
14
|
+
import { getLayoutFieldNames, getProblem, resolveFields, selectVisible, useLeaveGuard, usePanneau, usePlugins } from "@panneau/core";
|
|
15
|
+
import { Alert, Aside, AsideLayout, Button, isApplePlatform, usePanneauIntl, useToast, useToastOffset } from "@panneau/ui";
|
|
12
16
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
17
|
import { useRef, useState } from "react";
|
|
14
18
|
import { FieldsProvider, builtInFields } from "@panneau/fields";
|
|
@@ -26,74 +30,156 @@ function findFieldElement(root, path) {
|
|
|
26
30
|
}
|
|
27
31
|
/**
|
|
28
32
|
* Error paths in the order of their fields: the order of the layout for top-level fields, then
|
|
29
|
-
* the order of the paths inside them (`
|
|
33
|
+
* the order of the paths inside them: locales in their order (`title.fr` before `title.en`), and
|
|
34
|
+
* items by number (`blocks.2.body` before `blocks.10.body`).
|
|
30
35
|
*/
|
|
31
|
-
function orderErrors(names, errors) {
|
|
36
|
+
function orderErrors(names, errors, locales = []) {
|
|
32
37
|
const rank = (path) => {
|
|
33
38
|
const index = names.indexOf(path.split(".")[0] ?? "");
|
|
34
39
|
return index === -1 ? names.length : index;
|
|
35
40
|
};
|
|
36
|
-
const
|
|
41
|
+
const localeRank = (path) => {
|
|
42
|
+
const index = locales.indexOf(path.split(".")[1] ?? "");
|
|
43
|
+
return index === -1 ? locales.length : index;
|
|
44
|
+
};
|
|
45
|
+
const compare = (a, b) => rank(a) - rank(b) || localeRank(a) - localeRank(b) || a.localeCompare(b, void 0, { numeric: true });
|
|
37
46
|
return Object.fromEntries(Object.entries(errors).sort(([a], [b]) => compare(a, b)));
|
|
38
47
|
}
|
|
48
|
+
/** Whether a node is a field that the layout as given doesn't place. */
|
|
49
|
+
function isUnplacedField(node, placed) {
|
|
50
|
+
return node?.type === "field" && node.name !== void 0 && !placed.has(node.name);
|
|
51
|
+
}
|
|
52
|
+
/** Whether a key press saves: ⌘ Enter on Apple platforms, Ctrl Enter elsewhere. */
|
|
53
|
+
function isSaveShortcut(event, apple) {
|
|
54
|
+
return event.key === "Enter" && (apple ? event.metaKey : event.ctrlKey) && !event.altKey && !event.shiftKey && !event.repeat && !event.nativeEvent.isComposing;
|
|
55
|
+
}
|
|
39
56
|
/**
|
|
40
57
|
* Renders a form: its fields in their layout, bound to the form state of `@panneau/core`, with
|
|
41
58
|
* an error summary, a scroll to the first error, error counts on tabs and sections, a guard for
|
|
42
59
|
* unsaved changes and the dialog of version conflicts. Saving is the job of the form's
|
|
43
60
|
* `onSubmit`.
|
|
61
|
+
*
|
|
62
|
+
* ⌘ Enter (Ctrl Enter elsewhere) saves from any of its fields. After a failed save, every
|
|
63
|
+
* collapsed section that holds an error opens, and the first error is focused.
|
|
44
64
|
*/
|
|
45
|
-
function FormView(
|
|
65
|
+
function FormView(t0) {
|
|
66
|
+
const $ = c(48);
|
|
67
|
+
const { form, fields, layout: t1, locales, relationSource, uploadSource, checkSource, components, panels, submitLabel, actions, onSubmitted, onReload, guardUnsavedChanges: t2, showSavedToast: t3, saved: t4, isLoading: t5, id, "aria-label": ariaLabel, className, layoutClassName, sidebarClassName, sidebarStorageKey, footerClassName, summaryClassName } = t0;
|
|
68
|
+
const layout = t1 === void 0 ? [] : t1;
|
|
69
|
+
const guardUnsavedChanges = t2 === void 0 ? true : t2;
|
|
70
|
+
const showSavedToast = t3 === void 0 ? true : t3;
|
|
71
|
+
const saved = t4 === void 0 ? false : t4;
|
|
72
|
+
const isLoading = t5 === void 0 ? false : t5;
|
|
46
73
|
const intl = usePanneauIntl();
|
|
47
74
|
const toasts = useToast();
|
|
48
75
|
const { definition } = usePanneau();
|
|
49
76
|
const plugins = usePlugins();
|
|
50
77
|
const state = useFormState(form);
|
|
51
|
-
const [registry] = useState(createRevealRegistry);
|
|
78
|
+
const [registry] = useState(createRevealRegistry$1);
|
|
79
|
+
const [errorSections] = useState(createRevealRegistry$1);
|
|
52
80
|
const [resolving, setResolving] = useState(false);
|
|
53
81
|
const root = useRef(null);
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
82
|
+
const footer = useRef(null);
|
|
83
|
+
const hasFooter = submitLabel !== null || actions !== void 0;
|
|
84
|
+
useToastOffset(footer, hasFooter && !isLoading);
|
|
85
|
+
const [savedShown, setSavedShown] = useState(saved);
|
|
86
|
+
if (savedShown && state.dirty) setSavedShown(false);
|
|
87
|
+
const guarded = guardUnsavedChanges && state.dirty;
|
|
88
|
+
useBeforeUnloadGuard(guarded);
|
|
89
|
+
const leave = useLeaveConfirmation(guarded);
|
|
90
|
+
useLeaveGuard(guarded, leave.confirmLeave);
|
|
91
|
+
const formLocales = locales ?? definition?.locales ?? [];
|
|
92
|
+
const resolved = resolveFields(fields, layout, { mode: form.mode });
|
|
93
|
+
const main = resolved.layout.filter(_temp);
|
|
94
|
+
const placed = new Set(getLayoutFieldNames(layout));
|
|
95
|
+
let split = main.length;
|
|
96
|
+
while (split > 0 && isUnplacedField(main[split - 1], placed)) split = split - 1;
|
|
97
|
+
const flow = main.slice(split);
|
|
98
|
+
const laidOut = main.slice(0, split);
|
|
99
|
+
let t6;
|
|
100
|
+
if ($[0] !== state) {
|
|
101
|
+
t6 = (node_0) => node_0.type === "sidebar" && selectVisible(state, node_0);
|
|
102
|
+
$[0] = state;
|
|
103
|
+
$[1] = t6;
|
|
104
|
+
} else t6 = $[1];
|
|
105
|
+
const sidebar = resolved.layout.filter(t6);
|
|
106
|
+
const order = [...getLayoutFieldNames(main), ...getLayoutFieldNames(sidebar.flatMap(_temp2))];
|
|
107
|
+
let t7;
|
|
108
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
109
|
+
t7 = Object.entries(builtInPanels);
|
|
110
|
+
$[2] = t7;
|
|
111
|
+
} else t7 = $[2];
|
|
112
|
+
const t8 = plugins.panels;
|
|
113
|
+
let t9;
|
|
114
|
+
if ($[3] !== panels) {
|
|
115
|
+
t9 = Object.entries(panels ?? {});
|
|
116
|
+
$[3] = panels;
|
|
117
|
+
$[4] = t9;
|
|
118
|
+
} else t9 = $[4];
|
|
119
|
+
let t10;
|
|
120
|
+
if ($[5] !== t8 || $[6] !== t9) {
|
|
121
|
+
t10 = new Map([
|
|
122
|
+
...t7,
|
|
123
|
+
...t8,
|
|
124
|
+
...t9
|
|
125
|
+
]);
|
|
126
|
+
$[5] = t8;
|
|
127
|
+
$[6] = t9;
|
|
128
|
+
$[7] = t10;
|
|
129
|
+
} else t10 = $[7];
|
|
130
|
+
const panelEntries = t10;
|
|
131
|
+
const hasPanel = (name) => sidebar.some((node_2) => node_2.panel === name);
|
|
132
|
+
let t11;
|
|
133
|
+
if ($[8] !== plugins.fields) {
|
|
134
|
+
t11 = Object.fromEntries(plugins.fields);
|
|
135
|
+
$[8] = plugins.fields;
|
|
136
|
+
$[9] = t11;
|
|
137
|
+
} else t11 = $[9];
|
|
138
|
+
const t12 = t11;
|
|
139
|
+
let t13;
|
|
140
|
+
if ($[10] !== components || $[11] !== t12) {
|
|
141
|
+
t13 = {
|
|
142
|
+
...builtInFields,
|
|
143
|
+
...t12,
|
|
144
|
+
...components
|
|
145
|
+
};
|
|
146
|
+
$[10] = components;
|
|
147
|
+
$[11] = t12;
|
|
148
|
+
$[12] = t13;
|
|
149
|
+
} else t13 = $[12];
|
|
150
|
+
const entries = t13;
|
|
65
151
|
const goTo = (path) => {
|
|
66
152
|
registry.reveal(path);
|
|
67
|
-
|
|
153
|
+
const show = (frames) => {
|
|
68
154
|
const element = root.current !== null ? findFieldElement(root.current, path) : null;
|
|
69
155
|
if (element === null) return;
|
|
156
|
+
if (element.closest("[hidden]") !== null && frames > 0) {
|
|
157
|
+
requestAnimationFrame(() => show(frames - 1));
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
70
160
|
const reduced = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
71
161
|
element.scrollIntoView?.({
|
|
72
162
|
block: "center",
|
|
73
163
|
behavior: reduced ? "auto" : "smooth"
|
|
74
164
|
});
|
|
75
165
|
(element.querySelector("[aria-invalid=\"true\"]") ?? element.querySelector(FOCUSABLE))?.focus({ preventScroll: true });
|
|
76
|
-
}
|
|
166
|
+
};
|
|
167
|
+
requestAnimationFrame(() => show(3));
|
|
77
168
|
};
|
|
78
169
|
const handle = (result) => {
|
|
79
170
|
if (result === null) return;
|
|
80
171
|
if (result.status === "invalid") {
|
|
81
|
-
|
|
172
|
+
Object.keys(result.errors).forEach((path_0) => errorSections.reveal(path_0));
|
|
173
|
+
const first = Object.keys(orderErrors(order, result.errors, formLocales))[0];
|
|
82
174
|
if (first !== void 0) goTo(first);
|
|
83
175
|
} else if (result.status === "submitted") {
|
|
84
|
-
|
|
176
|
+
setSavedShown(true);
|
|
177
|
+
if (showSavedToast && !hasFooter) toasts.show({
|
|
85
178
|
title: intl.formatMessage(messages.saved),
|
|
86
179
|
tone: "success"
|
|
87
|
-
});
|
|
180
|
+
}, { key: "panneau-form-saved" });
|
|
88
181
|
onSubmitted?.(result.result);
|
|
89
|
-
}
|
|
90
|
-
title: intl.formatMessage(messages.saveFailed),
|
|
91
|
-
tone: "danger",
|
|
92
|
-
action: {
|
|
93
|
-
label: intl.formatMessage(messages.retry),
|
|
94
|
-
onAction: () => void form.submit().then(handle)
|
|
95
|
-
}
|
|
96
|
-
}, { timeout: 8e3 });
|
|
182
|
+
}
|
|
97
183
|
};
|
|
98
184
|
const resolve = async (choice) => {
|
|
99
185
|
if (choice === "reload" && state.conflict?.current === null && onReload !== void 0) {
|
|
@@ -101,103 +187,231 @@ function FormView({ form, fields, layout = [], locales, relationSource, uploadSo
|
|
|
101
187
|
return;
|
|
102
188
|
}
|
|
103
189
|
setResolving(true);
|
|
104
|
-
|
|
105
|
-
handle(await form.resolveConflict(choice));
|
|
106
|
-
} finally {
|
|
107
|
-
setResolving(false);
|
|
108
|
-
}
|
|
190
|
+
await form.resolveConflict(choice).then(handle).finally(() => setResolving(false));
|
|
109
191
|
};
|
|
110
|
-
|
|
192
|
+
let t14;
|
|
193
|
+
if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
|
|
194
|
+
const apple = isApplePlatform();
|
|
195
|
+
t14 = (event) => {
|
|
196
|
+
if (!isSaveShortcut(event, apple) || !(event.target instanceof Node) || !event.currentTarget.contains(event.target)) return;
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
event.currentTarget.requestSubmit();
|
|
199
|
+
};
|
|
200
|
+
$[13] = t14;
|
|
201
|
+
} else t14 = $[13];
|
|
202
|
+
const onKeyDown = t14;
|
|
203
|
+
let t15;
|
|
204
|
+
if ($[14] !== state.error || $[15] !== state.status) {
|
|
205
|
+
t15 = state.status === "error" ? getProblem(state.error) : null;
|
|
206
|
+
$[14] = state.error;
|
|
207
|
+
$[15] = state.status;
|
|
208
|
+
$[16] = t15;
|
|
209
|
+
} else t15 = $[16];
|
|
210
|
+
const problem = t15;
|
|
111
211
|
const errorDetail = problem?.detail ?? (problem === null && state.error instanceof Error ? state.error.message : void 0);
|
|
112
212
|
const showSummary = state.status === "invalid" && state.submitCount > 0;
|
|
213
|
+
const orderedErrors = showSummary ? orderErrors(order, state.errors, formLocales) : {};
|
|
214
|
+
const t16 = state.status === "error" ? "error" : state.dirty ? "unsaved" : savedShown && state.status !== "submitting" ? "saved" : null;
|
|
215
|
+
const t17 = state.status === "submitting";
|
|
216
|
+
let t18;
|
|
217
|
+
if ($[17] !== intl || $[18] !== submitLabel) {
|
|
218
|
+
t18 = submitLabel === void 0 ? intl.formatMessage(messages.save) : submitLabel;
|
|
219
|
+
$[17] = intl;
|
|
220
|
+
$[18] = submitLabel;
|
|
221
|
+
$[19] = t18;
|
|
222
|
+
} else t18 = $[19];
|
|
223
|
+
let t19;
|
|
224
|
+
if ($[20] !== actions || $[21] !== t16 || $[22] !== t17 || $[23] !== t18) {
|
|
225
|
+
t19 = {
|
|
226
|
+
status: t16,
|
|
227
|
+
isSubmitting: t17,
|
|
228
|
+
actions,
|
|
229
|
+
submitLabel: t18
|
|
230
|
+
};
|
|
231
|
+
$[20] = actions;
|
|
232
|
+
$[21] = t16;
|
|
233
|
+
$[22] = t17;
|
|
234
|
+
$[23] = t18;
|
|
235
|
+
$[24] = t19;
|
|
236
|
+
} else t19 = $[24];
|
|
237
|
+
const save = t19;
|
|
238
|
+
if (isLoading) return /* @__PURE__ */ jsx(FormSkeleton, {
|
|
239
|
+
main: laidOut,
|
|
240
|
+
flow,
|
|
241
|
+
sidebar: resolved.layout.filter(_temp3),
|
|
242
|
+
fields: resolved.fieldsByName,
|
|
243
|
+
footer: hasFooter,
|
|
244
|
+
className,
|
|
245
|
+
layoutClassName,
|
|
246
|
+
sidebarClassName,
|
|
247
|
+
footerClassName
|
|
248
|
+
});
|
|
249
|
+
let t20;
|
|
250
|
+
if ($[25] !== relationSource) {
|
|
251
|
+
t20 = relationSource !== void 0 ? { relationSource } : {};
|
|
252
|
+
$[25] = relationSource;
|
|
253
|
+
$[26] = t20;
|
|
254
|
+
} else t20 = $[26];
|
|
255
|
+
let t21;
|
|
256
|
+
if ($[27] !== uploadSource) {
|
|
257
|
+
t21 = uploadSource !== void 0 ? { uploadSource } : {};
|
|
258
|
+
$[27] = uploadSource;
|
|
259
|
+
$[28] = t21;
|
|
260
|
+
} else t21 = $[28];
|
|
261
|
+
let t22;
|
|
262
|
+
if ($[29] !== checkSource) {
|
|
263
|
+
t22 = checkSource !== void 0 ? { checkSource } : {};
|
|
264
|
+
$[29] = checkSource;
|
|
265
|
+
$[30] = t22;
|
|
266
|
+
} else t22 = $[30];
|
|
267
|
+
let t23;
|
|
268
|
+
if ($[31] !== className) {
|
|
269
|
+
t23 = cx(Form_module_default.form, className);
|
|
270
|
+
$[31] = className;
|
|
271
|
+
$[32] = t23;
|
|
272
|
+
} else t23 = $[32];
|
|
273
|
+
let t24;
|
|
274
|
+
if ($[33] !== errorDetail || $[34] !== intl || $[35] !== state.status) {
|
|
275
|
+
t24 = state.status === "error" ? /* @__PURE__ */ jsx(Alert, {
|
|
276
|
+
tone: "danger",
|
|
277
|
+
role: "alert",
|
|
278
|
+
title: intl.formatMessage(messages.saveFailed),
|
|
279
|
+
actions: /* @__PURE__ */ jsx(Button, {
|
|
280
|
+
size: "sm",
|
|
281
|
+
type: "submit",
|
|
282
|
+
children: intl.formatMessage(messages.retry)
|
|
283
|
+
}),
|
|
284
|
+
children: errorDetail
|
|
285
|
+
}) : null;
|
|
286
|
+
$[33] = errorDetail;
|
|
287
|
+
$[34] = intl;
|
|
288
|
+
$[35] = state.status;
|
|
289
|
+
$[36] = t24;
|
|
290
|
+
} else t24 = $[36];
|
|
291
|
+
const t25 = state.status === "conflict" || resolving;
|
|
292
|
+
const t26 = state.conflict?.current ?? null;
|
|
293
|
+
let t27;
|
|
294
|
+
let t28;
|
|
295
|
+
if ($[37] !== resolve) {
|
|
296
|
+
t27 = () => void resolve("reload");
|
|
297
|
+
t28 = () => void resolve("overwrite");
|
|
298
|
+
$[37] = resolve;
|
|
299
|
+
$[38] = t27;
|
|
300
|
+
$[39] = t28;
|
|
301
|
+
} else {
|
|
302
|
+
t27 = $[38];
|
|
303
|
+
t28 = $[39];
|
|
304
|
+
}
|
|
305
|
+
let t29;
|
|
306
|
+
if ($[40] !== resolved.fields || $[41] !== resolving || $[42] !== state.values || $[43] !== t25 || $[44] !== t26 || $[45] !== t27 || $[46] !== t28) {
|
|
307
|
+
t29 = /* @__PURE__ */ jsx(ConflictDialog, {
|
|
308
|
+
isOpen: t25,
|
|
309
|
+
fields: resolved.fields,
|
|
310
|
+
values: state.values,
|
|
311
|
+
current: t26,
|
|
312
|
+
isPending: resolving,
|
|
313
|
+
onReload: t27,
|
|
314
|
+
onOverwrite: t28
|
|
315
|
+
});
|
|
316
|
+
$[40] = resolved.fields;
|
|
317
|
+
$[41] = resolving;
|
|
318
|
+
$[42] = state.values;
|
|
319
|
+
$[43] = t25;
|
|
320
|
+
$[44] = t26;
|
|
321
|
+
$[45] = t27;
|
|
322
|
+
$[46] = t28;
|
|
323
|
+
$[47] = t29;
|
|
324
|
+
} else t29 = $[47];
|
|
113
325
|
return /* @__PURE__ */ jsx(FormContext, {
|
|
114
326
|
value: form,
|
|
115
|
-
children: /* @__PURE__ */ jsx(
|
|
116
|
-
value:
|
|
117
|
-
children: /* @__PURE__ */
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
ref: root,
|
|
125
|
-
id,
|
|
126
|
-
"aria-label": ariaLabel,
|
|
127
|
-
noValidate: true,
|
|
128
|
-
className: cx(Form_module_default.form, className),
|
|
129
|
-
onSubmit: (event) => {
|
|
130
|
-
event.preventDefault();
|
|
131
|
-
form.submit().then(handle);
|
|
327
|
+
children: /* @__PURE__ */ jsx(PanelsContext, {
|
|
328
|
+
value: panelEntries,
|
|
329
|
+
children: /* @__PURE__ */ jsx(SaveContext, {
|
|
330
|
+
value: save,
|
|
331
|
+
children: /* @__PURE__ */ jsx(SummaryContext, {
|
|
332
|
+
value: {
|
|
333
|
+
errors: orderedErrors,
|
|
334
|
+
fields: resolved.fields,
|
|
335
|
+
onSelect: goTo
|
|
132
336
|
},
|
|
133
|
-
children:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
337
|
+
children: /* @__PURE__ */ jsx(RevealContext, {
|
|
338
|
+
value: registry,
|
|
339
|
+
children: /* @__PURE__ */ jsx(ErrorSectionsContext, {
|
|
340
|
+
value: errorSections,
|
|
341
|
+
children: /* @__PURE__ */ jsxs(FieldsProvider, {
|
|
342
|
+
components: entries,
|
|
343
|
+
locales: formLocales,
|
|
344
|
+
...t20,
|
|
345
|
+
...t21,
|
|
346
|
+
...t22,
|
|
347
|
+
binding: FormBinding,
|
|
348
|
+
children: [
|
|
349
|
+
/* @__PURE__ */ jsxs("form", {
|
|
350
|
+
ref: root,
|
|
351
|
+
id,
|
|
352
|
+
"aria-label": ariaLabel,
|
|
353
|
+
noValidate: true,
|
|
354
|
+
className: t23,
|
|
355
|
+
onSubmit: (event_0) => {
|
|
356
|
+
event_0.preventDefault();
|
|
357
|
+
form.submit().then(handle);
|
|
358
|
+
},
|
|
359
|
+
onKeyDown,
|
|
360
|
+
children: [
|
|
361
|
+
showSummary ? /* @__PURE__ */ jsx(ErrorSummary, {
|
|
362
|
+
errors: orderedErrors,
|
|
363
|
+
fields: resolved.fields,
|
|
364
|
+
onSelect: goTo,
|
|
365
|
+
className: cx(summaryClassName ?? Form_module_default.summary, hasPanel("errors") && Form_module_default.besideAsideHidden)
|
|
366
|
+
}) : null,
|
|
367
|
+
t24,
|
|
368
|
+
/* @__PURE__ */ jsxs(AsideLayout, {
|
|
369
|
+
className: layoutClassName,
|
|
370
|
+
mainClassName: Form_module_default.stack,
|
|
371
|
+
aside: sidebar.length > 0 ? /* @__PURE__ */ jsx(Aside, {
|
|
372
|
+
label: intl.formatMessage(messages.sidebar),
|
|
373
|
+
className: sidebarClassName,
|
|
374
|
+
children: sidebar.map((node_4, index) => /* @__PURE__ */ jsx(SidebarNode, {
|
|
375
|
+
node: node_4,
|
|
376
|
+
fields: resolved.fieldsByName,
|
|
377
|
+
storageKey: sidebarStorageKey
|
|
378
|
+
}, index))
|
|
379
|
+
}) : null,
|
|
380
|
+
children: [/* @__PURE__ */ jsx(LayoutNodes, {
|
|
381
|
+
nodes: laidOut,
|
|
382
|
+
fields: resolved.fieldsByName
|
|
383
|
+
}), flow.length > 0 ? /* @__PURE__ */ jsx(FieldFlow, {
|
|
384
|
+
nodes: flow,
|
|
385
|
+
fields: resolved.fieldsByName
|
|
386
|
+
}) : null]
|
|
387
|
+
}),
|
|
388
|
+
hasFooter ? /* @__PURE__ */ jsx("div", {
|
|
389
|
+
ref: footer,
|
|
390
|
+
className: cx(Form_module_default.footer, hasPanel("save") && Form_module_default.besideAsideHidden, footerClassName),
|
|
391
|
+
children: /* @__PURE__ */ jsx(SaveControls, { ...save })
|
|
392
|
+
}) : null
|
|
393
|
+
]
|
|
394
|
+
}),
|
|
395
|
+
t29,
|
|
396
|
+
leave.dialog
|
|
397
|
+
]
|
|
398
|
+
})
|
|
399
|
+
})
|
|
400
|
+
})
|
|
401
|
+
})
|
|
197
402
|
})
|
|
198
403
|
})
|
|
199
404
|
});
|
|
200
405
|
}
|
|
406
|
+
function _temp3(node_3) {
|
|
407
|
+
return node_3.type === "sidebar";
|
|
408
|
+
}
|
|
409
|
+
function _temp2(node_1) {
|
|
410
|
+
return node_1.children ?? [];
|
|
411
|
+
}
|
|
412
|
+
function _temp(node) {
|
|
413
|
+
return node.type !== "sidebar";
|
|
414
|
+
}
|
|
201
415
|
//#endregion
|
|
202
416
|
export { FormView };
|
|
203
417
|
|