@panneau/forms 5.0.0-alpha.16 → 5.0.0-alpha.18
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 +2 -1
- package/dist/Form.css +10 -2
- package/dist/Form.module.js +5 -3
- package/dist/Form.module.js.map +1 -1
- package/dist/FormView.d.ts +15 -2
- package/dist/FormView.d.ts.map +1 -1
- package/dist/FormView.js +221 -182
- package/dist/FormView.js.map +1 -1
- package/dist/context.d.ts +7 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +8 -2
- package/dist/context.js.map +1 -1
- package/dist/layout/Layout.d.ts.map +1 -1
- package/dist/layout/Layout.js +74 -60
- package/dist/layout/Layout.js.map +1 -1
- package/package.json +9 -7
package/README.md
CHANGED
|
@@ -57,7 +57,8 @@ Under a `PanneauProvider`, forms use the field components of the plugins and the
|
|
|
57
57
|
| Phones | Rows stack and the sidebar goes under the form when the form is narrow (container queries) |
|
|
58
58
|
| Errors | Next to each field, nested fields included (`blocks.2.body`), in a summary with links, and counted on tabs and sections |
|
|
59
59
|
| First error | After a failed submit, its tab or section opens, and the field scrolls into view and gets focus |
|
|
60
|
-
| Server errors | An alert with a retry in the form, and
|
|
60
|
+
| Server errors | An alert with a retry in the form, and the failure next to the button |
|
|
61
|
+
| Saved | "Saved" in the footer, next to the button, until the values change (`saved` keeps it when the form starts over from the item it saved); a toast only for a form without a footer |
|
|
61
62
|
| Unsaved changes | The page asks before closing (`guardUnsavedChanges`). Under a `LeaveGuardsProvider` of `@panneau/core`, leaving through the app's router asks in a dialog too; `useLeaveConfirmation()` gives that dialog to other routers |
|
|
62
63
|
| Broken fields | Each field has an error boundary: a field that throws shows a message, the rest of the form keeps working |
|
|
63
64
|
| Version conflicts | A dialog shows the values that differ, then loads the current version or saves the local one over it |
|
package/dist/Form.css
CHANGED
|
@@ -136,12 +136,20 @@
|
|
|
136
136
|
border-top: var(--panneau-border-width) solid var(--panneau-color-border);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
.
|
|
139
|
+
/* "Unsaved changes", "Saved" or the failure of the last save, next to the button. */
|
|
140
|
+
.panneau-form-status {
|
|
141
|
+
display: inline-flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
gap: var(--panneau-space-1);
|
|
140
144
|
margin-inline-end: auto;
|
|
141
145
|
font-size: var(--panneau-font-size-sm);
|
|
142
146
|
color: var(--panneau-color-text-muted);
|
|
143
147
|
}
|
|
144
148
|
|
|
149
|
+
.panneau-form-status-error {
|
|
150
|
+
color: var(--panneau-color-danger);
|
|
151
|
+
}
|
|
152
|
+
|
|
145
153
|
.panneau-form-summary:focus {
|
|
146
154
|
outline: var(--panneau-focus-width) solid var(--panneau-color-focus);
|
|
147
155
|
outline-offset: 2px;
|
|
@@ -172,7 +180,7 @@
|
|
|
172
180
|
}
|
|
173
181
|
|
|
174
182
|
@container panneau-form (max-width: 36rem) {
|
|
175
|
-
.panneau-form-footer > :not(.panneau-form-
|
|
183
|
+
.panneau-form-footer > :not(.panneau-form-status) {
|
|
176
184
|
flex: 1 1 auto;
|
|
177
185
|
}
|
|
178
186
|
}
|
package/dist/Form.module.js
CHANGED
|
@@ -17,7 +17,8 @@ var text = "panneau-form-text";
|
|
|
17
17
|
var sidebar = "panneau-form-sidebar";
|
|
18
18
|
var field = "panneau-form-field";
|
|
19
19
|
var footer = "panneau-form-footer";
|
|
20
|
-
var
|
|
20
|
+
var status = "panneau-form-status";
|
|
21
|
+
var statusError = "panneau-form-status-error";
|
|
21
22
|
var summary = "panneau-form-summary";
|
|
22
23
|
var summaryList = "panneau-form-summary-list";
|
|
23
24
|
var summaryLink = "panneau-form-summary-link";
|
|
@@ -43,7 +44,8 @@ var Form_module_default = {
|
|
|
43
44
|
sidebar,
|
|
44
45
|
field,
|
|
45
46
|
footer,
|
|
46
|
-
|
|
47
|
+
status,
|
|
48
|
+
statusError,
|
|
47
49
|
summary,
|
|
48
50
|
summaryList,
|
|
49
51
|
summaryLink,
|
|
@@ -53,6 +55,6 @@ var Form_module_default = {
|
|
|
53
55
|
skeletonTabs
|
|
54
56
|
};
|
|
55
57
|
//#endregion
|
|
56
|
-
export { cell, Form_module_default as default,
|
|
58
|
+
export { cell, Form_module_default as default, field, flow, flowCell, flowWide, footer, form, layout, row, section, sectionDescription, sectionHeader, sectionTitle, sidebar, skeletonField, skeletonInline, skeletonLabel, skeletonTabs, stack, status, statusError, summary, summaryLink, summaryList, text, withSidebar };
|
|
57
59
|
|
|
58
60
|
//# sourceMappingURL=Form.module.js.map
|
package/dist/Form.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.module.js","names":[],"sources":["../src/Form.module.css"],"sourcesContent":[".form {\n container: panneau-form / inline-size;\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-6);\n min-width: 0;\n}\n\n.layout {\n display: grid;\n gap: var(--panneau-space-6);\n min-width: 0;\n}\n\n@container panneau-form (min-width: 56rem) {\n .withSidebar {\n grid-template-columns: minmax(0, 1fr) minmax(16rem, 20rem);\n align-items: start;\n }\n}\n\n.stack {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-5);\n min-width: 0;\n}\n\n.row {\n display: grid;\n grid-template-columns: repeat(12, minmax(0, 1fr));\n gap: var(--panneau-space-5) var(--panneau-space-4);\n min-width: 0;\n}\n\n.cell {\n grid-column: span var(--panneau-span, 12);\n min-width: 0;\n}\n\n/* Fields that the layout doesn't place: short ones side by side, in columns of at least 16rem. */\n.flow {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));\n gap: var(--panneau-space-5) var(--panneau-space-4);\n min-width: 0;\n}\n\n.flowCell {\n min-width: 0;\n}\n\n/* A field hidden by its condition renders nothing: its cell takes no column. */\n.flowCell:empty {\n display: none;\n}\n\n.flowWide {\n grid-column: 1 / -1;\n}\n\n/* Narrow containers (phones, side panels): every cell takes the full width. */\n@container panneau-form (max-width: 36rem) {\n .cell {\n grid-column: 1 / -1;\n }\n}\n\n.section {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-4);\n min-width: 0;\n padding: var(--panneau-space-4) var(--panneau-space-5);\n background-color: var(--panneau-color-surface);\n border: var(--panneau-border-width) solid var(--panneau-color-border);\n border-radius: var(--panneau-radius-lg);\n}\n\n@container panneau-form (max-width: 36rem) {\n .section {\n padding: var(--panneau-space-3);\n }\n}\n\n.sectionHeader {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-1);\n}\n\n.sectionDescription {\n margin: 0;\n}\n\n.sectionTitle {\n display: flex;\n align-items: center;\n gap: var(--panneau-space-2);\n font-size: var(--panneau-font-size-lg);\n font-weight: var(--panneau-font-weight-bold);\n line-height: var(--panneau-line-height-tight);\n margin: 0;\n}\n\n.sectionDescription,\n.text {\n font-size: var(--panneau-font-size-md);\n color: var(--panneau-color-text-muted);\n margin: 0;\n}\n\n.sidebar {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-5);\n min-width: 0;\n}\n\n.field {\n min-width: 0;\n scroll-margin: var(--panneau-space-10);\n}\n\n.footer {\n position: sticky;\n bottom: 0;\n z-index: 1;\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: flex-end;\n gap: var(--panneau-space-2) var(--panneau-space-3);\n padding: var(--panneau-space-3) 0;\n background-color: var(--panneau-color-bg);\n border-top: var(--panneau-border-width) solid var(--panneau-color-border);\n}\n\n.
|
|
1
|
+
{"version":3,"file":"Form.module.js","names":[],"sources":["../src/Form.module.css"],"sourcesContent":[".form {\n container: panneau-form / inline-size;\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-6);\n min-width: 0;\n}\n\n.layout {\n display: grid;\n gap: var(--panneau-space-6);\n min-width: 0;\n}\n\n@container panneau-form (min-width: 56rem) {\n .withSidebar {\n grid-template-columns: minmax(0, 1fr) minmax(16rem, 20rem);\n align-items: start;\n }\n}\n\n.stack {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-5);\n min-width: 0;\n}\n\n.row {\n display: grid;\n grid-template-columns: repeat(12, minmax(0, 1fr));\n gap: var(--panneau-space-5) var(--panneau-space-4);\n min-width: 0;\n}\n\n.cell {\n grid-column: span var(--panneau-span, 12);\n min-width: 0;\n}\n\n/* Fields that the layout doesn't place: short ones side by side, in columns of at least 16rem. */\n.flow {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));\n gap: var(--panneau-space-5) var(--panneau-space-4);\n min-width: 0;\n}\n\n.flowCell {\n min-width: 0;\n}\n\n/* A field hidden by its condition renders nothing: its cell takes no column. */\n.flowCell:empty {\n display: none;\n}\n\n.flowWide {\n grid-column: 1 / -1;\n}\n\n/* Narrow containers (phones, side panels): every cell takes the full width. */\n@container panneau-form (max-width: 36rem) {\n .cell {\n grid-column: 1 / -1;\n }\n}\n\n.section {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-4);\n min-width: 0;\n padding: var(--panneau-space-4) var(--panneau-space-5);\n background-color: var(--panneau-color-surface);\n border: var(--panneau-border-width) solid var(--panneau-color-border);\n border-radius: var(--panneau-radius-lg);\n}\n\n@container panneau-form (max-width: 36rem) {\n .section {\n padding: var(--panneau-space-3);\n }\n}\n\n.sectionHeader {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-1);\n}\n\n.sectionDescription {\n margin: 0;\n}\n\n.sectionTitle {\n display: flex;\n align-items: center;\n gap: var(--panneau-space-2);\n font-size: var(--panneau-font-size-lg);\n font-weight: var(--panneau-font-weight-bold);\n line-height: var(--panneau-line-height-tight);\n margin: 0;\n}\n\n.sectionDescription,\n.text {\n font-size: var(--panneau-font-size-md);\n color: var(--panneau-color-text-muted);\n margin: 0;\n}\n\n.sidebar {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-5);\n min-width: 0;\n}\n\n.field {\n min-width: 0;\n scroll-margin: var(--panneau-space-10);\n}\n\n.footer {\n position: sticky;\n bottom: 0;\n z-index: 1;\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: flex-end;\n gap: var(--panneau-space-2) var(--panneau-space-3);\n padding: var(--panneau-space-3) 0;\n background-color: var(--panneau-color-bg);\n border-top: var(--panneau-border-width) solid var(--panneau-color-border);\n}\n\n/* \"Unsaved changes\", \"Saved\" or the failure of the last save, next to the button. */\n.status {\n display: inline-flex;\n align-items: center;\n gap: var(--panneau-space-1);\n margin-inline-end: auto;\n font-size: var(--panneau-font-size-sm);\n color: var(--panneau-color-text-muted);\n}\n\n.statusError {\n color: var(--panneau-color-danger);\n}\n\n.summary:focus {\n outline: var(--panneau-focus-width) solid var(--panneau-color-focus);\n outline-offset: 2px;\n}\n\n.summaryList {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-1);\n margin: 0;\n padding-inline-start: var(--panneau-space-5);\n}\n\n.summaryLink {\n padding: 0;\n font: inherit;\n color: inherit;\n text-align: start;\n text-decoration: underline;\n cursor: pointer;\n background: none;\n border: 0;\n}\n\n.summaryLink:focus-visible {\n outline: var(--panneau-focus-width) solid var(--panneau-color-focus);\n outline-offset: 2px;\n}\n\n@container panneau-form (max-width: 36rem) {\n .footer > :not(.status) {\n flex: 1 1 auto;\n }\n}\n\n/* The skeleton of a form whose values load. */\n.skeletonField {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-1);\n}\n\n.skeletonInline {\n display: flex;\n align-items: center;\n gap: var(--panneau-space-2);\n}\n\n.skeletonLabel {\n font-size: var(--panneau-font-size-sm);\n}\n\n.skeletonTabs {\n display: flex;\n gap: var(--panneau-space-5);\n padding-block: var(--panneau-space-2);\n border-bottom: var(--panneau-border-width) solid var(--panneau-color-border);\n}\n"],"mappings":""}
|
package/dist/FormView.d.ts
CHANGED
|
@@ -42,8 +42,18 @@ export interface FormViewProps {
|
|
|
42
42
|
* under a `LeaveGuardsProvider`, left through the app's router. Defaults to true.
|
|
43
43
|
*/
|
|
44
44
|
guardUnsavedChanges?: boolean;
|
|
45
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Shows "Saved" in a toast after a successful submit, when the form has no footer to say it
|
|
47
|
+
* (no submit button and no `actions`). Defaults to true. A form with a footer says "Saved" in
|
|
48
|
+
* it, next to its button, where "Unsaved changes" was: the page already shows it (decision
|
|
49
|
+
* 0062).
|
|
50
|
+
*/
|
|
46
51
|
showSavedToast?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* The item was saved just before the form started over from it (a new `key` after a save):
|
|
54
|
+
* the footer says "Saved" until the values change.
|
|
55
|
+
*/
|
|
56
|
+
saved?: boolean;
|
|
47
57
|
/**
|
|
48
58
|
* The values load, such as the item to edit: the form draws a skeleton of its layout and
|
|
49
59
|
* fields instead (decision 0034).
|
|
@@ -62,6 +72,9 @@ export interface FormViewProps {
|
|
|
62
72
|
* an error summary, a scroll to the first error, error counts on tabs and sections, a guard for
|
|
63
73
|
* unsaved changes and the dialog of version conflicts. Saving is the job of the form's
|
|
64
74
|
* `onSubmit`.
|
|
75
|
+
*
|
|
76
|
+
* ⌘ Enter (Ctrl Enter elsewhere) saves from any of its fields. After a failed save, every
|
|
77
|
+
* collapsed section that holds an error opens, and the first error is focused.
|
|
65
78
|
*/
|
|
66
|
-
export declare function FormView({ form, fields, layout, locales, relationSource, uploadSource, checkSource, components, submitLabel, actions, onSubmitted, onReload, guardUnsavedChanges, showSavedToast, isLoading, id, 'aria-label': ariaLabel, className, layoutClassName, sidebarClassName, footerClassName, summaryClassName, }: FormViewProps): import("react").JSX.Element;
|
|
79
|
+
export declare function FormView({ form, fields, layout, locales, relationSource, uploadSource, checkSource, components, submitLabel, actions, onSubmitted, onReload, guardUnsavedChanges, showSavedToast, saved, isLoading, id, 'aria-label': ariaLabel, className, layoutClassName, sidebarClassName, footerClassName, summaryClassName, }: FormViewProps): import("react").JSX.Element;
|
|
67
80
|
//# 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.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C9B;;;;;OAKG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B;AA8DD;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,EACrB,IAAI,EACJ,MAAM,EACN,MAAW,EACX,OAAO,EACP,cAAc,EACd,YAAY,EACZ,WAAW,EACX,UAAU,EACV,WAAW,EACX,OAAO,EACP,WAAW,EACX,QAAQ,EACR,mBAA0B,EAC1B,cAAqB,EACrB,KAAa,EACb,SAAiB,EACjB,EAAE,EACF,YAAY,EAAE,SAAS,EACvB,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACnB,EAAE,aAAa,+BAyRf"}
|
package/dist/FormView.js
CHANGED
|
@@ -2,7 +2,7 @@ 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
8
|
import { FormSkeleton } from "./FormSkeleton.js";
|
|
@@ -10,8 +10,9 @@ import { FieldFlow, LayoutNodes } from "./layout/Layout.js";
|
|
|
10
10
|
import { useBeforeUnloadGuard, useLeaveConfirmation } from "./unsaved.js";
|
|
11
11
|
import { c } from "react/compiler-runtime";
|
|
12
12
|
import { getLayoutFieldNames, getProblem, resolveFields, selectVisible, useLeaveGuard, usePanneau, usePlugins } from "@panneau/core";
|
|
13
|
-
import { Alert, Button, usePanneauIntl, useToast } from "@panneau/ui";
|
|
14
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Alert, Button, Icon, Tooltip, isApplePlatform, usePanneauIntl, useToast, useToastOffset } from "@panneau/ui";
|
|
14
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
import { CircleCheck } from "lucide-react";
|
|
15
16
|
import { useRef, useState } from "react";
|
|
16
17
|
import { FieldsProvider, builtInFields } from "@panneau/fields";
|
|
17
18
|
//#region src/FormView.tsx
|
|
@@ -47,27 +48,41 @@ function orderErrors(names, errors, locales = []) {
|
|
|
47
48
|
function isUnplacedField(node, placed) {
|
|
48
49
|
return node?.type === "field" && node.name !== void 0 && !placed.has(node.name);
|
|
49
50
|
}
|
|
51
|
+
/** Whether a key press saves: ⌘ Enter on Apple platforms, Ctrl Enter elsewhere. */
|
|
52
|
+
function isSaveShortcut(event, apple) {
|
|
53
|
+
return event.key === "Enter" && (apple ? event.metaKey : event.ctrlKey) && !event.altKey && !event.shiftKey && !event.repeat && !event.nativeEvent.isComposing;
|
|
54
|
+
}
|
|
50
55
|
/**
|
|
51
56
|
* Renders a form: its fields in their layout, bound to the form state of `@panneau/core`, with
|
|
52
57
|
* an error summary, a scroll to the first error, error counts on tabs and sections, a guard for
|
|
53
58
|
* unsaved changes and the dialog of version conflicts. Saving is the job of the form's
|
|
54
59
|
* `onSubmit`.
|
|
60
|
+
*
|
|
61
|
+
* ⌘ Enter (Ctrl Enter elsewhere) saves from any of its fields. After a failed save, every
|
|
62
|
+
* collapsed section that holds an error opens, and the first error is focused.
|
|
55
63
|
*/
|
|
56
64
|
function FormView(t0) {
|
|
57
|
-
const $ = c(
|
|
58
|
-
const { form, fields, layout: t1, locales, relationSource, uploadSource, checkSource, components, submitLabel, actions, onSubmitted, onReload, guardUnsavedChanges: t2, showSavedToast: t3,
|
|
65
|
+
const $ = c(49);
|
|
66
|
+
const { form, fields, layout: t1, locales, relationSource, uploadSource, checkSource, components, submitLabel, actions, onSubmitted, onReload, guardUnsavedChanges: t2, showSavedToast: t3, saved: t4, isLoading: t5, id, "aria-label": ariaLabel, className, layoutClassName, sidebarClassName, footerClassName, summaryClassName } = t0;
|
|
59
67
|
const layout = t1 === void 0 ? [] : t1;
|
|
60
68
|
const guardUnsavedChanges = t2 === void 0 ? true : t2;
|
|
61
69
|
const showSavedToast = t3 === void 0 ? true : t3;
|
|
62
|
-
const
|
|
70
|
+
const saved = t4 === void 0 ? false : t4;
|
|
71
|
+
const isLoading = t5 === void 0 ? false : t5;
|
|
63
72
|
const intl = usePanneauIntl();
|
|
64
73
|
const toasts = useToast();
|
|
65
74
|
const { definition } = usePanneau();
|
|
66
75
|
const plugins = usePlugins();
|
|
67
76
|
const state = useFormState(form);
|
|
68
|
-
const [registry] = useState(createRevealRegistry);
|
|
77
|
+
const [registry] = useState(createRevealRegistry$1);
|
|
78
|
+
const [errorSections] = useState(createRevealRegistry$1);
|
|
69
79
|
const [resolving, setResolving] = useState(false);
|
|
70
80
|
const root = useRef(null);
|
|
81
|
+
const footer = useRef(null);
|
|
82
|
+
const hasFooter = submitLabel !== null || actions !== void 0;
|
|
83
|
+
useToastOffset(footer, hasFooter && !isLoading);
|
|
84
|
+
const [savedShown, setSavedShown] = useState(saved);
|
|
85
|
+
if (savedShown && state.dirty) setSavedShown(false);
|
|
71
86
|
const guarded = guardUnsavedChanges && state.dirty;
|
|
72
87
|
useBeforeUnloadGuard(guarded);
|
|
73
88
|
const leave = useLeaveConfirmation(guarded);
|
|
@@ -80,33 +95,33 @@ function FormView(t0) {
|
|
|
80
95
|
while (split > 0 && isUnplacedField(main[split - 1], placed)) split = split - 1;
|
|
81
96
|
const flow = main.slice(split);
|
|
82
97
|
const laidOut = main.slice(0, split);
|
|
83
|
-
let
|
|
98
|
+
let t6;
|
|
84
99
|
if ($[0] !== state) {
|
|
85
|
-
|
|
100
|
+
t6 = (node_0) => node_0.type === "sidebar" && selectVisible(state, node_0);
|
|
86
101
|
$[0] = state;
|
|
87
|
-
$[1] =
|
|
88
|
-
} else
|
|
89
|
-
const sidebar = resolved.layout.filter(
|
|
102
|
+
$[1] = t6;
|
|
103
|
+
} else t6 = $[1];
|
|
104
|
+
const sidebar = resolved.layout.filter(t6);
|
|
90
105
|
const order = [...getLayoutFieldNames(main), ...getLayoutFieldNames(sidebar.flatMap(_temp2))];
|
|
91
|
-
let
|
|
106
|
+
let t7;
|
|
92
107
|
if ($[2] !== plugins.fields) {
|
|
93
|
-
|
|
108
|
+
t7 = Object.fromEntries(plugins.fields);
|
|
94
109
|
$[2] = plugins.fields;
|
|
95
|
-
$[3] =
|
|
96
|
-
} else
|
|
97
|
-
const
|
|
98
|
-
let
|
|
99
|
-
if ($[4] !== components || $[5] !==
|
|
100
|
-
|
|
110
|
+
$[3] = t7;
|
|
111
|
+
} else t7 = $[3];
|
|
112
|
+
const t8 = t7;
|
|
113
|
+
let t9;
|
|
114
|
+
if ($[4] !== components || $[5] !== t8) {
|
|
115
|
+
t9 = {
|
|
101
116
|
...builtInFields,
|
|
102
|
-
...
|
|
117
|
+
...t8,
|
|
103
118
|
...components
|
|
104
119
|
};
|
|
105
120
|
$[4] = components;
|
|
106
|
-
$[5] =
|
|
107
|
-
$[6] =
|
|
108
|
-
} else
|
|
109
|
-
const entries =
|
|
121
|
+
$[5] = t8;
|
|
122
|
+
$[6] = t9;
|
|
123
|
+
} else t9 = $[6];
|
|
124
|
+
const entries = t9;
|
|
110
125
|
const goTo = (path) => {
|
|
111
126
|
registry.reveal(path);
|
|
112
127
|
const show = (frames) => {
|
|
@@ -128,22 +143,17 @@ function FormView(t0) {
|
|
|
128
143
|
const handle = (result) => {
|
|
129
144
|
if (result === null) return;
|
|
130
145
|
if (result.status === "invalid") {
|
|
146
|
+
Object.keys(result.errors).forEach((path_0) => errorSections.reveal(path_0));
|
|
131
147
|
const first = Object.keys(orderErrors(order, result.errors, formLocales))[0];
|
|
132
148
|
if (first !== void 0) goTo(first);
|
|
133
149
|
} else if (result.status === "submitted") {
|
|
134
|
-
|
|
150
|
+
setSavedShown(true);
|
|
151
|
+
if (showSavedToast && !hasFooter) toasts.show({
|
|
135
152
|
title: intl.formatMessage(messages.saved),
|
|
136
153
|
tone: "success"
|
|
137
|
-
});
|
|
154
|
+
}, { key: "panneau-form-saved" });
|
|
138
155
|
onSubmitted?.(result.result);
|
|
139
|
-
}
|
|
140
|
-
title: intl.formatMessage(messages.saveFailed),
|
|
141
|
-
tone: "danger",
|
|
142
|
-
action: {
|
|
143
|
-
label: intl.formatMessage(messages.retry),
|
|
144
|
-
onAction: () => void form.submit().then(handle)
|
|
145
|
-
}
|
|
146
|
-
}, { timeout: 8e3 });
|
|
156
|
+
}
|
|
147
157
|
};
|
|
148
158
|
const resolve = async (choice) => {
|
|
149
159
|
if (choice === "reload" && state.conflict?.current === null && onReload !== void 0) {
|
|
@@ -153,14 +163,31 @@ function FormView(t0) {
|
|
|
153
163
|
setResolving(true);
|
|
154
164
|
await form.resolveConflict(choice).then(handle).finally(() => setResolving(false));
|
|
155
165
|
};
|
|
156
|
-
let
|
|
157
|
-
if ($[7]
|
|
158
|
-
|
|
159
|
-
$[7] =
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
166
|
+
let t10;
|
|
167
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
168
|
+
t10 = isApplePlatform();
|
|
169
|
+
$[7] = t10;
|
|
170
|
+
} else t10 = $[7];
|
|
171
|
+
const apple = t10;
|
|
172
|
+
let t11;
|
|
173
|
+
if ($[8] !== apple) {
|
|
174
|
+
t11 = (event) => {
|
|
175
|
+
if (!isSaveShortcut(event, apple) || !(event.target instanceof Node) || !event.currentTarget.contains(event.target)) return;
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
event.currentTarget.requestSubmit();
|
|
178
|
+
};
|
|
179
|
+
$[8] = apple;
|
|
180
|
+
$[9] = t11;
|
|
181
|
+
} else t11 = $[9];
|
|
182
|
+
const onKeyDown = t11;
|
|
183
|
+
let t12;
|
|
184
|
+
if ($[10] !== state.error || $[11] !== state.status) {
|
|
185
|
+
t12 = state.status === "error" ? getProblem(state.error) : null;
|
|
186
|
+
$[10] = state.error;
|
|
187
|
+
$[11] = state.status;
|
|
188
|
+
$[12] = t12;
|
|
189
|
+
} else t12 = $[12];
|
|
190
|
+
const problem = t12;
|
|
164
191
|
const errorDetail = problem?.detail ?? (problem === null && state.error instanceof Error ? state.error.message : void 0);
|
|
165
192
|
const showSummary = state.status === "invalid" && state.submitCount > 0;
|
|
166
193
|
if (isLoading) return /* @__PURE__ */ jsx(FormSkeleton, {
|
|
@@ -168,39 +195,39 @@ function FormView(t0) {
|
|
|
168
195
|
flow,
|
|
169
196
|
sidebar: resolved.layout.filter(_temp3),
|
|
170
197
|
fields: resolved.fieldsByName,
|
|
171
|
-
footer:
|
|
198
|
+
footer: hasFooter,
|
|
172
199
|
className,
|
|
173
200
|
layoutClassName,
|
|
174
201
|
sidebarClassName,
|
|
175
202
|
footerClassName
|
|
176
203
|
});
|
|
177
|
-
let t10;
|
|
178
|
-
if ($[10] !== relationSource) {
|
|
179
|
-
t10 = relationSource !== void 0 ? { relationSource } : {};
|
|
180
|
-
$[10] = relationSource;
|
|
181
|
-
$[11] = t10;
|
|
182
|
-
} else t10 = $[11];
|
|
183
|
-
let t11;
|
|
184
|
-
if ($[12] !== uploadSource) {
|
|
185
|
-
t11 = uploadSource !== void 0 ? { uploadSource } : {};
|
|
186
|
-
$[12] = uploadSource;
|
|
187
|
-
$[13] = t11;
|
|
188
|
-
} else t11 = $[13];
|
|
189
|
-
let t12;
|
|
190
|
-
if ($[14] !== checkSource) {
|
|
191
|
-
t12 = checkSource !== void 0 ? { checkSource } : {};
|
|
192
|
-
$[14] = checkSource;
|
|
193
|
-
$[15] = t12;
|
|
194
|
-
} else t12 = $[15];
|
|
195
204
|
let t13;
|
|
196
|
-
if ($[
|
|
197
|
-
t13 =
|
|
198
|
-
$[
|
|
199
|
-
$[
|
|
200
|
-
} else t13 = $[
|
|
205
|
+
if ($[13] !== relationSource) {
|
|
206
|
+
t13 = relationSource !== void 0 ? { relationSource } : {};
|
|
207
|
+
$[13] = relationSource;
|
|
208
|
+
$[14] = t13;
|
|
209
|
+
} else t13 = $[14];
|
|
201
210
|
let t14;
|
|
202
|
-
if ($[
|
|
203
|
-
t14 =
|
|
211
|
+
if ($[15] !== uploadSource) {
|
|
212
|
+
t14 = uploadSource !== void 0 ? { uploadSource } : {};
|
|
213
|
+
$[15] = uploadSource;
|
|
214
|
+
$[16] = t14;
|
|
215
|
+
} else t14 = $[16];
|
|
216
|
+
let t15;
|
|
217
|
+
if ($[17] !== checkSource) {
|
|
218
|
+
t15 = checkSource !== void 0 ? { checkSource } : {};
|
|
219
|
+
$[17] = checkSource;
|
|
220
|
+
$[18] = t15;
|
|
221
|
+
} else t15 = $[18];
|
|
222
|
+
let t16;
|
|
223
|
+
if ($[19] !== className) {
|
|
224
|
+
t16 = cx(Form_module_default.form, className);
|
|
225
|
+
$[19] = className;
|
|
226
|
+
$[20] = t16;
|
|
227
|
+
} else t16 = $[20];
|
|
228
|
+
let t17;
|
|
229
|
+
if ($[21] !== errorDetail || $[22] !== intl || $[23] !== state.status) {
|
|
230
|
+
t17 = state.status === "error" ? /* @__PURE__ */ jsx(Alert, {
|
|
204
231
|
tone: "danger",
|
|
205
232
|
role: "alert",
|
|
206
233
|
title: intl.formatMessage(messages.saveFailed),
|
|
@@ -211,138 +238,150 @@ function FormView(t0) {
|
|
|
211
238
|
}),
|
|
212
239
|
children: errorDetail
|
|
213
240
|
}) : null;
|
|
214
|
-
$[
|
|
215
|
-
$[
|
|
216
|
-
$[
|
|
217
|
-
$[
|
|
218
|
-
} else
|
|
219
|
-
const
|
|
220
|
-
let
|
|
221
|
-
if ($[
|
|
222
|
-
|
|
223
|
-
$[
|
|
224
|
-
$[
|
|
225
|
-
$[
|
|
226
|
-
} else
|
|
227
|
-
let
|
|
228
|
-
if ($[
|
|
229
|
-
|
|
241
|
+
$[21] = errorDetail;
|
|
242
|
+
$[22] = intl;
|
|
243
|
+
$[23] = state.status;
|
|
244
|
+
$[24] = t17;
|
|
245
|
+
} else t17 = $[24];
|
|
246
|
+
const t18 = sidebar.length > 0 && Form_module_default.withSidebar;
|
|
247
|
+
let t19;
|
|
248
|
+
if ($[25] !== layoutClassName || $[26] !== t18) {
|
|
249
|
+
t19 = cx(Form_module_default.layout, t18, layoutClassName);
|
|
250
|
+
$[25] = layoutClassName;
|
|
251
|
+
$[26] = t18;
|
|
252
|
+
$[27] = t19;
|
|
253
|
+
} else t19 = $[27];
|
|
254
|
+
let t20;
|
|
255
|
+
if ($[28] !== actions || $[29] !== apple || $[30] !== footerClassName || $[31] !== hasFooter || $[32] !== intl || $[33] !== savedShown || $[34] !== state.dirty || $[35] !== state.status || $[36] !== submitLabel) {
|
|
256
|
+
t20 = hasFooter ? /* @__PURE__ */ jsxs("div", {
|
|
257
|
+
ref: footer,
|
|
230
258
|
className: cx(Form_module_default.footer, footerClassName),
|
|
231
259
|
children: [
|
|
232
|
-
|
|
233
|
-
className: Form_module_default.
|
|
260
|
+
/* @__PURE__ */ jsx("span", {
|
|
261
|
+
className: cx(Form_module_default.status, state.status === "error" && Form_module_default.statusError),
|
|
234
262
|
role: "status",
|
|
235
|
-
children: intl.formatMessage(messages.unsaved)
|
|
236
|
-
})
|
|
263
|
+
children: state.status === "error" ? intl.formatMessage(messages.saveFailed) : state.dirty ? intl.formatMessage(messages.unsaved) : savedShown && state.status !== "submitting" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Icon, { icon: CircleCheck }), intl.formatMessage(messages.saved)] }) : null
|
|
264
|
+
}),
|
|
237
265
|
actions,
|
|
238
|
-
submitLabel !== null ? /* @__PURE__ */ jsx(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
266
|
+
submitLabel !== null ? /* @__PURE__ */ jsx(Tooltip, {
|
|
267
|
+
content: intl.formatMessage(messages.saveShortcut, { modifier: apple ? "⌘" : "Ctrl" }),
|
|
268
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
269
|
+
type: "submit",
|
|
270
|
+
variant: "primary",
|
|
271
|
+
isPending: state.status === "submitting",
|
|
272
|
+
"aria-keyshortcuts": apple ? "Meta+Enter" : "Control+Enter",
|
|
273
|
+
children: submitLabel ?? intl.formatMessage(messages.save)
|
|
274
|
+
})
|
|
243
275
|
}) : null
|
|
244
276
|
]
|
|
245
277
|
}) : null;
|
|
246
|
-
$[
|
|
247
|
-
$[
|
|
248
|
-
$[
|
|
249
|
-
$[
|
|
250
|
-
$[
|
|
251
|
-
$[
|
|
252
|
-
$[
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
278
|
+
$[28] = actions;
|
|
279
|
+
$[29] = apple;
|
|
280
|
+
$[30] = footerClassName;
|
|
281
|
+
$[31] = hasFooter;
|
|
282
|
+
$[32] = intl;
|
|
283
|
+
$[33] = savedShown;
|
|
284
|
+
$[34] = state.dirty;
|
|
285
|
+
$[35] = state.status;
|
|
286
|
+
$[36] = submitLabel;
|
|
287
|
+
$[37] = t20;
|
|
288
|
+
} else t20 = $[37];
|
|
289
|
+
const t21 = state.status === "conflict" || resolving;
|
|
290
|
+
const t22 = state.conflict?.current ?? null;
|
|
291
|
+
let t23;
|
|
292
|
+
let t24;
|
|
293
|
+
if ($[38] !== resolve) {
|
|
294
|
+
t23 = () => void resolve("reload");
|
|
295
|
+
t24 = () => void resolve("overwrite");
|
|
296
|
+
$[38] = resolve;
|
|
297
|
+
$[39] = t23;
|
|
298
|
+
$[40] = t24;
|
|
264
299
|
} else {
|
|
265
|
-
|
|
266
|
-
|
|
300
|
+
t23 = $[39];
|
|
301
|
+
t24 = $[40];
|
|
267
302
|
}
|
|
268
|
-
let
|
|
269
|
-
if ($[
|
|
270
|
-
|
|
271
|
-
isOpen:
|
|
303
|
+
let t25;
|
|
304
|
+
if ($[41] !== resolved.fields || $[42] !== resolving || $[43] !== state.values || $[44] !== t21 || $[45] !== t22 || $[46] !== t23 || $[47] !== t24) {
|
|
305
|
+
t25 = /* @__PURE__ */ jsx(ConflictDialog, {
|
|
306
|
+
isOpen: t21,
|
|
272
307
|
fields: resolved.fields,
|
|
273
308
|
values: state.values,
|
|
274
|
-
current:
|
|
309
|
+
current: t22,
|
|
275
310
|
isPending: resolving,
|
|
276
|
-
onReload:
|
|
277
|
-
onOverwrite:
|
|
311
|
+
onReload: t23,
|
|
312
|
+
onOverwrite: t24
|
|
278
313
|
});
|
|
279
|
-
$[
|
|
280
|
-
$[
|
|
281
|
-
$[
|
|
282
|
-
$[
|
|
283
|
-
$[
|
|
284
|
-
$[
|
|
285
|
-
$[
|
|
286
|
-
$[
|
|
287
|
-
} else
|
|
314
|
+
$[41] = resolved.fields;
|
|
315
|
+
$[42] = resolving;
|
|
316
|
+
$[43] = state.values;
|
|
317
|
+
$[44] = t21;
|
|
318
|
+
$[45] = t22;
|
|
319
|
+
$[46] = t23;
|
|
320
|
+
$[47] = t24;
|
|
321
|
+
$[48] = t25;
|
|
322
|
+
} else t25 = $[48];
|
|
288
323
|
return /* @__PURE__ */ jsx(FormContext, {
|
|
289
324
|
value: form,
|
|
290
325
|
children: /* @__PURE__ */ jsx(RevealContext, {
|
|
291
326
|
value: registry,
|
|
292
|
-
children: /* @__PURE__ */
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
fields: resolved.fieldsByName
|
|
325
|
-
}), flow.length > 0 ? /* @__PURE__ */ jsx(FieldFlow, {
|
|
326
|
-
nodes: flow,
|
|
327
|
-
fields: resolved.fieldsByName
|
|
328
|
-
}) : null]
|
|
329
|
-
}), sidebar.length > 0 ? /* @__PURE__ */ jsx("aside", {
|
|
330
|
-
className: cx(Form_module_default.sidebar, sidebarClassName),
|
|
331
|
-
children: sidebar.map((node_3, index) => /* @__PURE__ */ jsx("div", {
|
|
327
|
+
children: /* @__PURE__ */ jsx(ErrorSectionsContext, {
|
|
328
|
+
value: errorSections,
|
|
329
|
+
children: /* @__PURE__ */ jsxs(FieldsProvider, {
|
|
330
|
+
components: entries,
|
|
331
|
+
locales: formLocales,
|
|
332
|
+
...t13,
|
|
333
|
+
...t14,
|
|
334
|
+
...t15,
|
|
335
|
+
binding: FormBinding,
|
|
336
|
+
children: [
|
|
337
|
+
/* @__PURE__ */ jsxs("form", {
|
|
338
|
+
ref: root,
|
|
339
|
+
id,
|
|
340
|
+
"aria-label": ariaLabel,
|
|
341
|
+
noValidate: true,
|
|
342
|
+
className: t16,
|
|
343
|
+
onSubmit: (event_0) => {
|
|
344
|
+
event_0.preventDefault();
|
|
345
|
+
form.submit().then(handle);
|
|
346
|
+
},
|
|
347
|
+
onKeyDown,
|
|
348
|
+
children: [
|
|
349
|
+
showSummary ? /* @__PURE__ */ jsx(ErrorSummary, {
|
|
350
|
+
errors: orderErrors(order, state.errors, formLocales),
|
|
351
|
+
fields: resolved.fields,
|
|
352
|
+
onSelect: goTo,
|
|
353
|
+
...summaryClassName !== void 0 ? { className: summaryClassName } : {}
|
|
354
|
+
}) : null,
|
|
355
|
+
t17,
|
|
356
|
+
/* @__PURE__ */ jsxs("div", {
|
|
357
|
+
className: t19,
|
|
358
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
332
359
|
className: Form_module_default.stack,
|
|
333
|
-
children: /* @__PURE__ */ jsx(LayoutNodes, {
|
|
334
|
-
nodes:
|
|
360
|
+
children: [/* @__PURE__ */ jsx(LayoutNodes, {
|
|
361
|
+
nodes: laidOut,
|
|
362
|
+
fields: resolved.fieldsByName
|
|
363
|
+
}), flow.length > 0 ? /* @__PURE__ */ jsx(FieldFlow, {
|
|
364
|
+
nodes: flow,
|
|
335
365
|
fields: resolved.fieldsByName
|
|
336
|
-
})
|
|
337
|
-
},
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
366
|
+
}) : null]
|
|
367
|
+
}), sidebar.length > 0 ? /* @__PURE__ */ jsx("aside", {
|
|
368
|
+
className: cx(Form_module_default.sidebar, sidebarClassName),
|
|
369
|
+
children: sidebar.map((node_3, index) => /* @__PURE__ */ jsx("div", {
|
|
370
|
+
className: Form_module_default.stack,
|
|
371
|
+
children: /* @__PURE__ */ jsx(LayoutNodes, {
|
|
372
|
+
nodes: node_3.children ?? [],
|
|
373
|
+
fields: resolved.fieldsByName
|
|
374
|
+
})
|
|
375
|
+
}, index))
|
|
376
|
+
}) : null]
|
|
377
|
+
}),
|
|
378
|
+
t20
|
|
379
|
+
]
|
|
380
|
+
}),
|
|
381
|
+
t25,
|
|
382
|
+
leave.dialog
|
|
383
|
+
]
|
|
384
|
+
})
|
|
346
385
|
})
|
|
347
386
|
})
|
|
348
387
|
});
|
package/dist/FormView.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormView.js","names":["ReactNode","useRef","useState","Form","SubmitResult","getLayoutFieldNames","getProblem","resolveFields","selectVisible","useLeaveGuard","usePanneau","usePlugins","FieldCheckSource","FieldEntry","FieldsProvider","RelationSource","UploadSource","builtInFields","Field","LayoutNode","Alert","Button","usePanneauIntl","useToast","ConflictDialog","ErrorSummary","styles","FormBinding","FormSkeleton","FormContext","RevealContext","createRevealRegistry","useFormState","cx","FieldFlow","LayoutNodes","messages","useBeforeUnloadGuard","useLeaveConfirmation","FormViewProps","form","fields","layout","locales","relationSource","uploadSource","checkSource","components","Readonly","Record","submitLabel","actions","onSubmitted","result","onReload","guardUnsavedChanges","showSavedToast","isLoading","id","className","layoutClassName","sidebarClassName","footerClassName","summaryClassName","FOCUSABLE","findFieldElement","root","HTMLElement","path","current","element","querySelector","CSS","escape","includes","slice","lastIndexOf","orderErrors","names","errors","rank","index","indexOf","split","length","localeRank","compare","a","b","localeCompare","undefined","numeric","Object","fromEntries","entries","sort","isUnplacedField","node","placed","ReadonlySet","type","name","has","FormView","t0","$","_c","t1","t2","t3","t4","ariaLabel","intl","toasts","definition","plugins","state","registry","resolving","setResolving","guarded","dirty","leave","confirmLeave","formLocales","resolved","mode","main","filter","_temp","Set","flow","laidOut","t5","node_0","sidebar","order","flatMap","_temp2","t6","t7","t8","goTo","reveal","show","frames","closest","requestAnimationFrame","reduced","window","matchMedia","matches","scrollIntoView","block","behavior","target","focus","preventScroll","handle","status","first","keys","title","formatMessage","saved","tone","saveFailed","action","label","retry","onAction","submit","then","timeout","resolve","choice","conflict","resolveConflict","finally","t9","error","problem","errorDetail","detail","Error","message","showSummary","submitCount","_temp3","fieldsByName","t10","t11","t12","t13","t14","t15","withSidebar","t16","t17","footer","unsaved","save","t18","t19","t20","t21","t22","values","event","preventDefault","stack","map","node_3","children","dialog","node_2","node_1","_c","styles"],"sources":["../src/FormView.tsx"],"sourcesContent":["import { type ReactNode, useRef, useState } from 'react';\n\nimport {\n type Form,\n type SubmitResult,\n getLayoutFieldNames,\n getProblem,\n resolveFields,\n selectVisible,\n useLeaveGuard,\n usePanneau,\n usePlugins,\n} from '@panneau/core';\nimport {\n type FieldCheckSource,\n type FieldEntry,\n FieldsProvider,\n type RelationSource,\n type UploadSource,\n builtInFields,\n} from '@panneau/fields';\nimport type { Field, LayoutNode } from '@panneau/protocol';\nimport { Alert, Button, usePanneauIntl, useToast } from '@panneau/ui';\n\nimport { ConflictDialog } from './ConflictDialog';\nimport { ErrorSummary } from './ErrorSummary';\nimport styles from './Form.module.css';\nimport { FormBinding } from './FormBinding';\nimport { FormSkeleton } from './FormSkeleton';\nimport { FormContext, RevealContext, createRevealRegistry, useFormState } from './context';\nimport { cx } from './cx';\nimport { FieldFlow, LayoutNodes } from './layout/Layout';\nimport { messages } from './messages';\nimport { useBeforeUnloadGuard, useLeaveConfirmation } from './unsaved';\n\nexport interface FormViewProps {\n /** The form state, from `useForm()` or `createForm()` of `@panneau/core`. */\n form: Form;\n /** The fields of the form. */\n fields: readonly Field[];\n /** The layout tree. Fields that no node references are added at the end. */\n layout?: readonly LayoutNode[];\n /** Locales of localized fields. Defaults to the definition's, from `PanneauProvider`. */\n locales?: readonly string[];\n /** Where relation fields search. Defaults to the one of a parent `FieldsProvider`. */\n relationSource?: RelationSource | null;\n /**\n * Where fields that take files upload them directly to storage. Defaults to the one of a\n * parent `FieldsProvider`. Without one, values hold the files themselves.\n */\n uploadSource?: UploadSource | null;\n /**\n * Where fields with `check` check their value, such as a slug's availability:\n * `createFieldCheckSource(adapter, resource, id)`. Defaults to the one of a parent\n * `FieldsProvider`.\n */\n checkSource?: FieldCheckSource | null;\n /** Field entries by type, over the built-in ones and those of the plugins. */\n components?: Readonly<Record<string, FieldEntry>>;\n /** Label of the submit button. Defaults to \"Save\". `null` hides the button. */\n submitLabel?: ReactNode;\n /** Other buttons, next to the submit button. */\n actions?: ReactNode;\n /** Called after a successful submit, with what `onSubmit` returned. */\n onSubmitted?: (result: unknown) => void;\n /**\n * Called by \"Load the current version\" in the conflict dialog when the backend didn't send the\n * current item: fetch it, and `form.reset()` with it.\n */\n onReload?: () => void;\n /**\n * Asks for confirmation before the page is left with unsaved changes: closed or reloaded, or,\n * under a `LeaveGuardsProvider`, left through the app's router. Defaults to true.\n */\n guardUnsavedChanges?: boolean;\n /** Shows a toast after a successful submit. Defaults to true. */\n showSavedToast?: boolean;\n /**\n * The values load, such as the item to edit: the form draws a skeleton of its layout and\n * fields instead (decision 0034).\n */\n isLoading?: boolean;\n id?: string;\n 'aria-label'?: string;\n className?: string;\n layoutClassName?: string;\n sidebarClassName?: string;\n footerClassName?: string;\n summaryClassName?: string;\n}\n\nconst FOCUSABLE =\n 'input:not([type=\"hidden\"]):not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/** The element of the field at a path, or of the closest field that holds it. */\nfunction findFieldElement(root: HTMLElement, path: string): HTMLElement | null {\n let current = path;\n while (current !== '') {\n const element = root.querySelector<HTMLElement>(\n `[data-panneau-path=\"${CSS.escape(current)}\"]`,\n );\n if (element !== null) {\n return element;\n }\n current = current.includes('.') ? current.slice(0, current.lastIndexOf('.')) : '';\n }\n return null;\n}\n\n/**\n * Error paths in the order of their fields: the order of the layout for top-level fields, then\n * the order of the paths inside them: locales in their order (`title.fr` before `title.en`), and\n * items by number (`blocks.2.body` before `blocks.10.body`).\n */\nfunction orderErrors(\n names: readonly string[],\n errors: Record<string, string[]>,\n locales: readonly string[] = [],\n): Record<string, string[]> {\n const rank = (path: string) => {\n const index = names.indexOf(path.split('.')[0] ?? '');\n return index === -1 ? names.length : index;\n };\n const localeRank = (path: string) => {\n const index = locales.indexOf(path.split('.')[1] ?? '');\n return index === -1 ? locales.length : index;\n };\n const compare = (a: string, b: string) =>\n rank(a) - rank(b) ||\n localeRank(a) - localeRank(b) ||\n a.localeCompare(b, undefined, { numeric: true });\n return Object.fromEntries(Object.entries(errors).sort(([a], [b]) => compare(a, b)));\n}\n\n/** Whether a node is a field that the layout as given doesn't place. */\nfunction isUnplacedField(node: LayoutNode | undefined, placed: ReadonlySet<string>): boolean {\n return node?.type === 'field' && node.name !== undefined && !placed.has(node.name);\n}\n\n/**\n * Renders a form: its fields in their layout, bound to the form state of `@panneau/core`, with\n * an error summary, a scroll to the first error, error counts on tabs and sections, a guard for\n * unsaved changes and the dialog of version conflicts. Saving is the job of the form's\n * `onSubmit`.\n */\nexport function FormView({\n form,\n fields,\n layout = [],\n locales,\n relationSource,\n uploadSource,\n checkSource,\n components,\n submitLabel,\n actions,\n onSubmitted,\n onReload,\n guardUnsavedChanges = true,\n showSavedToast = true,\n isLoading = false,\n id,\n 'aria-label': ariaLabel,\n className,\n layoutClassName,\n sidebarClassName,\n footerClassName,\n summaryClassName,\n}: FormViewProps) {\n const intl = usePanneauIntl();\n const toasts = useToast();\n const { definition } = usePanneau();\n const plugins = usePlugins();\n const state = useFormState(form);\n const [registry] = useState(createRevealRegistry);\n const [resolving, setResolving] = useState(false);\n const root = useRef<HTMLFormElement>(null);\n const guarded = guardUnsavedChanges && state.dirty;\n useBeforeUnloadGuard(guarded);\n // Leaving through the app's router asks first, in a dialog\n const leave = useLeaveConfirmation(guarded);\n useLeaveGuard(guarded, leave.confirmLeave);\n\n // In the mode of the form, as its rules are checked: the required mark of a password\n // required on create shows on create only\n const formLocales = locales ?? definition?.locales ?? [];\n const resolved = resolveFields(fields, layout, { mode: form.mode });\n const main = resolved.layout.filter((node) => node.type !== 'sidebar');\n // The fields that the layout doesn't place come last: they flow in columns\n const placed = new Set(getLayoutFieldNames(layout));\n let split = main.length;\n while (split > 0 && isUnplacedField(main[split - 1], placed)) {\n split -= 1;\n }\n const flow = main.slice(split);\n const laidOut = main.slice(0, split);\n const sidebar = resolved.layout.filter(\n (node) => node.type === 'sidebar' && selectVisible(state, node),\n );\n const order = [\n ...getLayoutFieldNames(main),\n ...getLayoutFieldNames(sidebar.flatMap((node) => node.children ?? [])),\n ];\n const entries: Record<string, FieldEntry> = {\n ...builtInFields,\n ...(Object.fromEntries(plugins.fields) as Record<string, FieldEntry>),\n ...components,\n };\n\n /** Opens the tab, section or locale of a path, then scrolls to its field and focuses it. */\n const goTo = (path: string) => {\n registry.reveal(path);\n // Wait for the tab, section or locale to open before scrolling: a few frames at most.\n const show = (frames: number) => {\n const element = root.current !== null ? findFieldElement(root.current, path) : null;\n if (element === null) {\n return;\n }\n if (element.closest('[hidden]') !== null && frames > 0) {\n requestAnimationFrame(() => show(frames - 1));\n return;\n }\n const reduced = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;\n element.scrollIntoView?.({ block: 'center', behavior: reduced ? 'auto' : 'smooth' });\n const target =\n element.querySelector<HTMLElement>('[aria-invalid=\"true\"]') ??\n element.querySelector<HTMLElement>(FOCUSABLE);\n target?.focus({ preventScroll: true });\n };\n requestAnimationFrame(() => show(3));\n };\n\n const handle = (result: SubmitResult | null) => {\n if (result === null) {\n return;\n }\n if (result.status === 'invalid') {\n const first = Object.keys(orderErrors(order, result.errors, formLocales))[0];\n if (first !== undefined) {\n goTo(first);\n }\n } else if (result.status === 'submitted') {\n if (showSavedToast) {\n toasts.show({ title: intl.formatMessage(messages.saved), tone: 'success' });\n }\n onSubmitted?.(result.result);\n } else if (result.status === 'error') {\n toasts.show(\n {\n title: intl.formatMessage(messages.saveFailed),\n tone: 'danger',\n action: {\n label: intl.formatMessage(messages.retry),\n onAction: () => void form.submit().then(handle),\n },\n },\n { timeout: 8000 },\n );\n }\n };\n\n const resolve = async (choice: 'reload' | 'overwrite') => {\n if (choice === 'reload' && state.conflict?.current === null && onReload !== undefined) {\n onReload();\n return;\n }\n setResolving(true);\n await form\n .resolveConflict(choice)\n .then(handle)\n .finally(() => setResolving(false));\n };\n\n const problem = state.status === 'error' ? getProblem(state.error) : null;\n const errorDetail =\n problem?.detail ??\n (problem === null && state.error instanceof Error ? state.error.message : undefined);\n const showSummary = state.status === 'invalid' && state.submitCount > 0;\n\n if (isLoading) {\n return (\n <FormSkeleton\n main={laidOut}\n flow={flow}\n sidebar={resolved.layout.filter((node) => node.type === 'sidebar')}\n fields={resolved.fieldsByName}\n footer={submitLabel !== null || actions !== undefined}\n className={className}\n layoutClassName={layoutClassName}\n sidebarClassName={sidebarClassName}\n footerClassName={footerClassName}\n />\n );\n }\n\n return (\n <FormContext value={form}>\n <RevealContext value={registry}>\n <FieldsProvider\n components={entries}\n locales={formLocales}\n {...(relationSource !== undefined ? { relationSource } : {})}\n {...(uploadSource !== undefined ? { uploadSource } : {})}\n {...(checkSource !== undefined ? { checkSource } : {})}\n binding={FormBinding}\n >\n <form\n ref={root}\n id={id}\n aria-label={ariaLabel}\n noValidate\n className={cx(styles.form, className)}\n onSubmit={(event) => {\n event.preventDefault();\n void form.submit().then(handle);\n }}\n >\n {showSummary ? (\n <ErrorSummary\n errors={orderErrors(order, state.errors, formLocales)}\n fields={resolved.fields}\n onSelect={goTo}\n {...(summaryClassName !== undefined\n ? { className: summaryClassName }\n : {})}\n />\n ) : null}\n {state.status === 'error' ? (\n <Alert\n tone=\"danger\"\n role=\"alert\"\n title={intl.formatMessage(messages.saveFailed)}\n actions={\n <Button size=\"sm\" type=\"submit\">\n {intl.formatMessage(messages.retry)}\n </Button>\n }\n >\n {errorDetail}\n </Alert>\n ) : null}\n <div\n className={cx(\n styles.layout,\n sidebar.length > 0 && styles.withSidebar,\n layoutClassName,\n )}\n >\n <div className={styles.stack}>\n <LayoutNodes nodes={laidOut} fields={resolved.fieldsByName} />\n {flow.length > 0 ? (\n <FieldFlow nodes={flow} fields={resolved.fieldsByName} />\n ) : null}\n </div>\n {sidebar.length > 0 ? (\n <aside className={cx(styles.sidebar, sidebarClassName)}>\n {sidebar.map((node, index) => (\n <div key={index} className={styles.stack}>\n <LayoutNodes\n nodes={node.children ?? []}\n fields={resolved.fieldsByName}\n />\n </div>\n ))}\n </aside>\n ) : null}\n </div>\n {submitLabel !== null || actions !== undefined ? (\n <div className={cx(styles.footer, footerClassName)}>\n {state.dirty ? (\n <span className={styles.dirty} role=\"status\">\n {intl.formatMessage(messages.unsaved)}\n </span>\n ) : null}\n {actions}\n {submitLabel !== null ? (\n <Button\n type=\"submit\"\n variant=\"primary\"\n isPending={state.status === 'submitting'}\n >\n {submitLabel ?? intl.formatMessage(messages.save)}\n </Button>\n ) : null}\n </div>\n ) : null}\n </form>\n <ConflictDialog\n isOpen={state.status === 'conflict' || resolving}\n fields={resolved.fields}\n values={state.values}\n current={state.conflict?.current ?? null}\n isPending={resolving}\n onReload={() => void resolve('reload')}\n onOverwrite={() => void resolve('overwrite')}\n />\n {leave.dialog}\n </FieldsProvider>\n </RevealContext>\n </FormContext>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA2FA,IAAMgE,YACF;;AAGJ,SAASC,iBAAiBC,MAAmBE,MAAkC;CAC3E,IAAIC,UAAUD;CACd,OAAOC,YAAY,IAAI;EACnB,MAAMC,UAAUJ,KAAKK,cACjB,uBAAuBC,IAAIC,OAAOJ,OAAO,EAAC,GAC9C;EACA,IAAIC,YAAY,MACZ,OAAOA;EAEXD,UAAUA,QAAQK,SAAS,GAAG,IAAIL,QAAQM,MAAM,GAAGN,QAAQO,YAAY,GAAG,CAAC,IAAI;CACnF;CACA,OAAO;AACX;;;;;;AAOA,SAASC,YACLC,OACAC,QACApC,UAA6B,CAAA,GACL;CACxB,MAAMqC,QAAQZ,SAAiB;EAC3B,MAAMa,QAAQH,MAAMI,QAAQd,KAAKe,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE;EACpD,OAAOF,UAAU,KAAKH,MAAMM,SAASH;CACzC;CACA,MAAMI,cAAcjB,SAAiB;EACjC,MAAMa,QAAQtC,QAAQuC,QAAQd,KAAKe,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE;EACtD,OAAOF,UAAU,KAAKtC,QAAQyC,SAASH;CAC3C;CACA,MAAMK,WAAWC,GAAWC,MACxBR,KAAKO,CAAC,IAAIP,KAAKQ,CAAC,KAChBH,WAAWE,CAAC,IAAIF,WAAWG,CAAC,KAC5BD,EAAE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A/B,WACcI,iBACZ,IAFF,CAEE;OAAC,CAAA,IAPf;OAUAmI;OAcD,qBAAA,OAAA;QACe,WAAAG;QADf,UAAA,CAOI,qBAAA,OAAA;SAAgB,WAAA3K,oBAAMwL;SAAtB,UAAA,CACI,oBAAC,aAAD;UAAoB9E,OAAAA;UAAiB,QAAAP,SAAQgE;SAAa,CAAA,GACzD1D,KAAI/C,SAAU,IACX,oBAAC,WAAD;UAAkB+C,OAAAA;UAAc,QAAAN,SAAQgE;SAAa,CAAA,IADxD,IAGC;QACLtD,CAAAA,GAAAA,QAAOnD,SAAU,IACd,oBAAA,SAAA;SAAkB,WAAAnD,GAAGP,oBAAM6G,SAAU1E,gBAAgB;SAChD0E,UAAAA,QAAO4E,KAAKC,QAAAnI,UACT,oBAAA,OAAA;UAA4B,WAAAvD,oBAAMwL;UAC9B,UAAA,oBAAC,aAAD;WACW,OAAAjH,OAAIoH,YAAJ,CAAA;WACC,QAAAxF,SAAQgE;UAAa,CAAA;SAE/B,GALI5G,KAKJ,CACT;QACG,CAAA,IAVX,IAYC;;OACLqH;MAmBE;;KACPQ;KASCpF,MAAK4F;IAlGK;;EADL,CAAA;CADN,CAAA;AAuGE;AA9Pf,SAAA1B,OAAA2B,QAAA;CAAA,OA2ImDtH,OAAIG,SAAU;AAAS;AA3I1E,SAAAsC,OAAA8E,QAAA;CAAA,OAwDkDvH,OAAIoH,YAAJ,CAAA;AAAmB;AAxDrE,SAAApF,MAAAhC,MAAA;CAAA,OA0C2CA,KAAIG,SAAU;AAAS"}
|
|
1
|
+
{"version":3,"file":"FormView.js","names":["CircleCheck","KeyboardEvent","ReactNode","useRef","useState","Form","SubmitResult","getLayoutFieldNames","getProblem","resolveFields","selectVisible","useLeaveGuard","usePanneau","usePlugins","FieldCheckSource","FieldEntry","FieldsProvider","RelationSource","UploadSource","builtInFields","Field","LayoutNode","Alert","Button","Icon","Tooltip","isApplePlatform","usePanneauIntl","useToast","useToastOffset","ConflictDialog","ErrorSummary","styles","FormBinding","FormSkeleton","ErrorSectionsContext","FormContext","RevealContext","createRevealRegistry","useFormState","cx","FieldFlow","LayoutNodes","messages","useBeforeUnloadGuard","useLeaveConfirmation","FormViewProps","form","fields","layout","locales","relationSource","uploadSource","checkSource","components","Readonly","Record","submitLabel","actions","onSubmitted","result","onReload","guardUnsavedChanges","showSavedToast","saved","isLoading","id","className","layoutClassName","sidebarClassName","footerClassName","summaryClassName","FOCUSABLE","findFieldElement","root","HTMLElement","path","current","element","querySelector","CSS","escape","includes","slice","lastIndexOf","orderErrors","names","errors","rank","index","indexOf","split","length","localeRank","compare","a","b","localeCompare","undefined","numeric","Object","fromEntries","entries","sort","isUnplacedField","node","placed","ReadonlySet","type","name","has","isSaveShortcut","event","apple","key","metaKey","ctrlKey","altKey","shiftKey","repeat","nativeEvent","isComposing","FormView","t0","$","_c","t1","t2","t3","t4","t5","ariaLabel","intl","toasts","definition","plugins","state","registry","errorSections","resolving","setResolving","footer","hasFooter","savedShown","setSavedShown","dirty","guarded","leave","confirmLeave","formLocales","resolved","mode","main","filter","_temp","Set","flow","laidOut","t6","node_0","sidebar","order","flatMap","_temp2","t7","t8","t9","goTo","reveal","show","frames","closest","requestAnimationFrame","reduced","window","matchMedia","matches","scrollIntoView","block","behavior","target","focus","preventScroll","handle","status","keys","forEach","path_0","first","title","formatMessage","tone","resolve","choice","conflict","resolveConflict","then","finally","t10","Symbol","for","t11","Node","currentTarget","contains","preventDefault","requestSubmit","onKeyDown","t12","error","problem","errorDetail","detail","Error","message","showSummary","submitCount","_temp3","fieldsByName","t13","t14","t15","t16","t17","saveFailed","retry","t18","withSidebar","t19","t20","statusError","unsaved","saveShortcut","modifier","save","t21","t22","t23","t24","t25","values","event_0","submit","stack","map","node_3","children","dialog","node_2","node_1","_c","createRevealRegistry","styles","_Fragment"],"sources":["../src/FormView.tsx"],"sourcesContent":["import { CircleCheck } from 'lucide-react';\nimport { type KeyboardEvent, type ReactNode, useRef, useState } from 'react';\n\nimport {\n type Form,\n type SubmitResult,\n getLayoutFieldNames,\n getProblem,\n resolveFields,\n selectVisible,\n useLeaveGuard,\n usePanneau,\n usePlugins,\n} from '@panneau/core';\nimport {\n type FieldCheckSource,\n type FieldEntry,\n FieldsProvider,\n type RelationSource,\n type UploadSource,\n builtInFields,\n} from '@panneau/fields';\nimport type { Field, LayoutNode } from '@panneau/protocol';\nimport {\n Alert,\n Button,\n Icon,\n Tooltip,\n isApplePlatform,\n usePanneauIntl,\n useToast,\n useToastOffset,\n} from '@panneau/ui';\n\nimport { ConflictDialog } from './ConflictDialog';\nimport { ErrorSummary } from './ErrorSummary';\nimport styles from './Form.module.css';\nimport { FormBinding } from './FormBinding';\nimport { FormSkeleton } from './FormSkeleton';\nimport {\n ErrorSectionsContext,\n FormContext,\n RevealContext,\n createRevealRegistry,\n useFormState,\n} from './context';\nimport { cx } from './cx';\nimport { FieldFlow, LayoutNodes } from './layout/Layout';\nimport { messages } from './messages';\nimport { useBeforeUnloadGuard, useLeaveConfirmation } from './unsaved';\n\nexport interface FormViewProps {\n /** The form state, from `useForm()` or `createForm()` of `@panneau/core`. */\n form: Form;\n /** The fields of the form. */\n fields: readonly Field[];\n /** The layout tree. Fields that no node references are added at the end. */\n layout?: readonly LayoutNode[];\n /** Locales of localized fields. Defaults to the definition's, from `PanneauProvider`. */\n locales?: readonly string[];\n /** Where relation fields search. Defaults to the one of a parent `FieldsProvider`. */\n relationSource?: RelationSource | null;\n /**\n * Where fields that take files upload them directly to storage. Defaults to the one of a\n * parent `FieldsProvider`. Without one, values hold the files themselves.\n */\n uploadSource?: UploadSource | null;\n /**\n * Where fields with `check` check their value, such as a slug's availability:\n * `createFieldCheckSource(adapter, resource, id)`. Defaults to the one of a parent\n * `FieldsProvider`.\n */\n checkSource?: FieldCheckSource | null;\n /** Field entries by type, over the built-in ones and those of the plugins. */\n components?: Readonly<Record<string, FieldEntry>>;\n /** Label of the submit button. Defaults to \"Save\". `null` hides the button. */\n submitLabel?: ReactNode;\n /** Other buttons, next to the submit button. */\n actions?: ReactNode;\n /** Called after a successful submit, with what `onSubmit` returned. */\n onSubmitted?: (result: unknown) => void;\n /**\n * Called by \"Load the current version\" in the conflict dialog when the backend didn't send the\n * current item: fetch it, and `form.reset()` with it.\n */\n onReload?: () => void;\n /**\n * Asks for confirmation before the page is left with unsaved changes: closed or reloaded, or,\n * under a `LeaveGuardsProvider`, left through the app's router. Defaults to true.\n */\n guardUnsavedChanges?: boolean;\n /**\n * Shows \"Saved\" in a toast after a successful submit, when the form has no footer to say it\n * (no submit button and no `actions`). Defaults to true. A form with a footer says \"Saved\" in\n * it, next to its button, where \"Unsaved changes\" was: the page already shows it (decision\n * 0062).\n */\n showSavedToast?: boolean;\n /**\n * The item was saved just before the form started over from it (a new `key` after a save):\n * the footer says \"Saved\" until the values change.\n */\n saved?: boolean;\n /**\n * The values load, such as the item to edit: the form draws a skeleton of its layout and\n * fields instead (decision 0034).\n */\n isLoading?: boolean;\n id?: string;\n 'aria-label'?: string;\n className?: string;\n layoutClassName?: string;\n sidebarClassName?: string;\n footerClassName?: string;\n summaryClassName?: string;\n}\n\nconst FOCUSABLE =\n 'input:not([type=\"hidden\"]):not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/** The element of the field at a path, or of the closest field that holds it. */\nfunction findFieldElement(root: HTMLElement, path: string): HTMLElement | null {\n let current = path;\n while (current !== '') {\n const element = root.querySelector<HTMLElement>(\n `[data-panneau-path=\"${CSS.escape(current)}\"]`,\n );\n if (element !== null) {\n return element;\n }\n current = current.includes('.') ? current.slice(0, current.lastIndexOf('.')) : '';\n }\n return null;\n}\n\n/**\n * Error paths in the order of their fields: the order of the layout for top-level fields, then\n * the order of the paths inside them: locales in their order (`title.fr` before `title.en`), and\n * items by number (`blocks.2.body` before `blocks.10.body`).\n */\nfunction orderErrors(\n names: readonly string[],\n errors: Record<string, string[]>,\n locales: readonly string[] = [],\n): Record<string, string[]> {\n const rank = (path: string) => {\n const index = names.indexOf(path.split('.')[0] ?? '');\n return index === -1 ? names.length : index;\n };\n const localeRank = (path: string) => {\n const index = locales.indexOf(path.split('.')[1] ?? '');\n return index === -1 ? locales.length : index;\n };\n const compare = (a: string, b: string) =>\n rank(a) - rank(b) ||\n localeRank(a) - localeRank(b) ||\n a.localeCompare(b, undefined, { numeric: true });\n return Object.fromEntries(Object.entries(errors).sort(([a], [b]) => compare(a, b)));\n}\n\n/** Whether a node is a field that the layout as given doesn't place. */\nfunction isUnplacedField(node: LayoutNode | undefined, placed: ReadonlySet<string>): boolean {\n return node?.type === 'field' && node.name !== undefined && !placed.has(node.name);\n}\n\n/** Whether a key press saves: ⌘ Enter on Apple platforms, Ctrl Enter elsewhere. */\nfunction isSaveShortcut(event: KeyboardEvent, apple: boolean): boolean {\n return (\n event.key === 'Enter' &&\n (apple ? event.metaKey : event.ctrlKey) &&\n !event.altKey &&\n !event.shiftKey &&\n !event.repeat &&\n !event.nativeEvent.isComposing\n );\n}\n\n/**\n * Renders a form: its fields in their layout, bound to the form state of `@panneau/core`, with\n * an error summary, a scroll to the first error, error counts on tabs and sections, a guard for\n * unsaved changes and the dialog of version conflicts. Saving is the job of the form's\n * `onSubmit`.\n *\n * ⌘ Enter (Ctrl Enter elsewhere) saves from any of its fields. After a failed save, every\n * collapsed section that holds an error opens, and the first error is focused.\n */\nexport function FormView({\n form,\n fields,\n layout = [],\n locales,\n relationSource,\n uploadSource,\n checkSource,\n components,\n submitLabel,\n actions,\n onSubmitted,\n onReload,\n guardUnsavedChanges = true,\n showSavedToast = true,\n saved = false,\n isLoading = false,\n id,\n 'aria-label': ariaLabel,\n className,\n layoutClassName,\n sidebarClassName,\n footerClassName,\n summaryClassName,\n}: FormViewProps) {\n const intl = usePanneauIntl();\n const toasts = useToast();\n const { definition } = usePanneau();\n const plugins = usePlugins();\n const state = useFormState(form);\n const [registry] = useState(createRevealRegistry);\n const [errorSections] = useState(createRevealRegistry);\n const [resolving, setResolving] = useState(false);\n const root = useRef<HTMLFormElement>(null);\n const footer = useRef<HTMLDivElement>(null);\n const hasFooter = submitLabel !== null || actions !== undefined;\n // Toasts rise above the footer, which sticks to the bottom of the page.\n useToastOffset(footer, hasFooter && !isLoading);\n // \"Saved\" in the footer, from the last submit or from before the form started over, until the\n // values change.\n const [savedShown, setSavedShown] = useState(saved);\n if (savedShown && state.dirty) {\n setSavedShown(false);\n }\n const guarded = guardUnsavedChanges && state.dirty;\n useBeforeUnloadGuard(guarded);\n // Leaving through the app's router asks first, in a dialog\n const leave = useLeaveConfirmation(guarded);\n useLeaveGuard(guarded, leave.confirmLeave);\n\n // In the mode of the form, as its rules are checked: the required mark of a password\n // required on create shows on create only\n const formLocales = locales ?? definition?.locales ?? [];\n const resolved = resolveFields(fields, layout, { mode: form.mode });\n const main = resolved.layout.filter((node) => node.type !== 'sidebar');\n // The fields that the layout doesn't place come last: they flow in columns\n const placed = new Set(getLayoutFieldNames(layout));\n let split = main.length;\n while (split > 0 && isUnplacedField(main[split - 1], placed)) {\n split -= 1;\n }\n const flow = main.slice(split);\n const laidOut = main.slice(0, split);\n const sidebar = resolved.layout.filter(\n (node) => node.type === 'sidebar' && selectVisible(state, node),\n );\n const order = [\n ...getLayoutFieldNames(main),\n ...getLayoutFieldNames(sidebar.flatMap((node) => node.children ?? [])),\n ];\n const entries: Record<string, FieldEntry> = {\n ...builtInFields,\n ...(Object.fromEntries(plugins.fields) as Record<string, FieldEntry>),\n ...components,\n };\n\n /** Opens the tab, section or locale of a path, then scrolls to its field and focuses it. */\n const goTo = (path: string) => {\n registry.reveal(path);\n // Wait for the tab, section or locale to open before scrolling: a few frames at most.\n const show = (frames: number) => {\n const element = root.current !== null ? findFieldElement(root.current, path) : null;\n if (element === null) {\n return;\n }\n if (element.closest('[hidden]') !== null && frames > 0) {\n requestAnimationFrame(() => show(frames - 1));\n return;\n }\n const reduced = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;\n element.scrollIntoView?.({ block: 'center', behavior: reduced ? 'auto' : 'smooth' });\n const target =\n element.querySelector<HTMLElement>('[aria-invalid=\"true\"]') ??\n element.querySelector<HTMLElement>(FOCUSABLE);\n target?.focus({ preventScroll: true });\n };\n requestAnimationFrame(() => show(3));\n };\n\n const handle = (result: SubmitResult | null) => {\n if (result === null) {\n return;\n }\n if (result.status === 'invalid') {\n // Every collapsed section with an error opens: what is left to fix shows while\n // scrolling down\n Object.keys(result.errors).forEach((path) => errorSections.reveal(path));\n const first = Object.keys(orderErrors(order, result.errors, formLocales))[0];\n if (first !== undefined) {\n goTo(first);\n }\n } else if (result.status === 'submitted') {\n setSavedShown(true);\n if (showSavedToast && !hasFooter) {\n toasts.show(\n { title: intl.formatMessage(messages.saved), tone: 'success' },\n { key: 'panneau-form-saved' },\n );\n }\n onSubmitted?.(result.result);\n }\n // An error shows in the page: its alert, and the footer next to the button.\n };\n\n const resolve = async (choice: 'reload' | 'overwrite') => {\n if (choice === 'reload' && state.conflict?.current === null && onReload !== undefined) {\n onReload();\n return;\n }\n setResolving(true);\n await form\n .resolveConflict(choice)\n .then(handle)\n .finally(() => setResolving(false));\n };\n\n const apple = isApplePlatform();\n const onKeyDown = (event: KeyboardEvent<HTMLFormElement>) => {\n // Not `defaultPrevented`: rich text editors prevent the default of every Enter. Keys of\n // what a field opens in a portal, such as a dialog, reach the form through React: they\n // are that dialog's own.\n if (\n !isSaveShortcut(event, apple) ||\n !(event.target instanceof Node) ||\n !event.currentTarget.contains(event.target)\n ) {\n return;\n }\n event.preventDefault();\n event.currentTarget.requestSubmit();\n };\n\n const problem = state.status === 'error' ? getProblem(state.error) : null;\n const errorDetail =\n problem?.detail ??\n (problem === null && state.error instanceof Error ? state.error.message : undefined);\n const showSummary = state.status === 'invalid' && state.submitCount > 0;\n\n if (isLoading) {\n return (\n <FormSkeleton\n main={laidOut}\n flow={flow}\n sidebar={resolved.layout.filter((node) => node.type === 'sidebar')}\n fields={resolved.fieldsByName}\n footer={hasFooter}\n className={className}\n layoutClassName={layoutClassName}\n sidebarClassName={sidebarClassName}\n footerClassName={footerClassName}\n />\n );\n }\n\n return (\n <FormContext value={form}>\n <RevealContext value={registry}>\n <ErrorSectionsContext value={errorSections}>\n <FieldsProvider\n components={entries}\n locales={formLocales}\n {...(relationSource !== undefined ? { relationSource } : {})}\n {...(uploadSource !== undefined ? { uploadSource } : {})}\n {...(checkSource !== undefined ? { checkSource } : {})}\n binding={FormBinding}\n >\n <form\n ref={root}\n id={id}\n aria-label={ariaLabel}\n noValidate\n className={cx(styles.form, className)}\n onSubmit={(event) => {\n event.preventDefault();\n void form.submit().then(handle);\n }}\n onKeyDown={onKeyDown}\n >\n {showSummary ? (\n <ErrorSummary\n errors={orderErrors(order, state.errors, formLocales)}\n fields={resolved.fields}\n onSelect={goTo}\n {...(summaryClassName !== undefined\n ? { className: summaryClassName }\n : {})}\n />\n ) : null}\n {state.status === 'error' ? (\n <Alert\n tone=\"danger\"\n role=\"alert\"\n title={intl.formatMessage(messages.saveFailed)}\n actions={\n <Button size=\"sm\" type=\"submit\">\n {intl.formatMessage(messages.retry)}\n </Button>\n }\n >\n {errorDetail}\n </Alert>\n ) : null}\n <div\n className={cx(\n styles.layout,\n sidebar.length > 0 && styles.withSidebar,\n layoutClassName,\n )}\n >\n <div className={styles.stack}>\n <LayoutNodes nodes={laidOut} fields={resolved.fieldsByName} />\n {flow.length > 0 ? (\n <FieldFlow nodes={flow} fields={resolved.fieldsByName} />\n ) : null}\n </div>\n {sidebar.length > 0 ? (\n <aside className={cx(styles.sidebar, sidebarClassName)}>\n {sidebar.map((node, index) => (\n <div key={index} className={styles.stack}>\n <LayoutNodes\n nodes={node.children ?? []}\n fields={resolved.fieldsByName}\n />\n </div>\n ))}\n </aside>\n ) : null}\n </div>\n {hasFooter ? (\n <div ref={footer} className={cx(styles.footer, footerClassName)}>\n <span\n className={cx(\n styles.status,\n state.status === 'error' && styles.statusError,\n )}\n role=\"status\"\n >\n {state.status === 'error' ? (\n intl.formatMessage(messages.saveFailed)\n ) : state.dirty ? (\n intl.formatMessage(messages.unsaved)\n ) : savedShown && state.status !== 'submitting' ? (\n <>\n <Icon icon={CircleCheck} />\n {intl.formatMessage(messages.saved)}\n </>\n ) : null}\n </span>\n {actions}\n {submitLabel !== null ? (\n <Tooltip\n content={intl.formatMessage(messages.saveShortcut, {\n modifier: apple ? '⌘' : 'Ctrl',\n })}\n >\n <Button\n type=\"submit\"\n variant=\"primary\"\n isPending={state.status === 'submitting'}\n aria-keyshortcuts={\n apple ? 'Meta+Enter' : 'Control+Enter'\n }\n >\n {submitLabel ?? intl.formatMessage(messages.save)}\n </Button>\n </Tooltip>\n ) : null}\n </div>\n ) : null}\n </form>\n <ConflictDialog\n isOpen={state.status === 'conflict' || resolving}\n fields={resolved.fields}\n values={state.values}\n current={state.conflict?.current ?? null}\n isPending={resolving}\n onReload={() => void resolve('reload')}\n onOverwrite={() => void resolve('overwrite')}\n />\n {leave.dialog}\n </FieldsProvider>\n </ErrorSectionsContext>\n </RevealContext>\n </FormContext>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqHA,IAAMwE,YACF;;AAGJ,SAASC,iBAAiBC,MAAmBE,MAAkC;CAC3E,IAAIC,UAAUD;CACd,OAAOC,YAAY,IAAI;EACnB,MAAMC,UAAUJ,KAAKK,cACjB,uBAAuBC,IAAIC,OAAOJ,OAAO,EAAC,GAC9C;EACA,IAAIC,YAAY,MACZ,OAAOA;EAEXD,UAAUA,QAAQK,SAAS,GAAG,IAAIL,QAAQM,MAAM,GAAGN,QAAQO,YAAY,GAAG,CAAC,IAAI;CACnF;CACA,OAAO;AACX;;;;;;AAOA,SAASC,YACLC,OACAC,QACArC,UAA6B,CAAA,GACL;CACxB,MAAMsC,QAAQZ,SAAiB;EAC3B,MAAMa,QAAQH,MAAMI,QAAQd,KAAKe,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE;EACpD,OAAOF,UAAU,KAAKH,MAAMM,SAASH;CACzC;CACA,MAAMI,cAAcjB,SAAiB;EACjC,MAA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PU;MASC5F,MAAKoG;KAzHK;;GADE,CAAA;EADX,CAAA;CADN,CAAA;AAgIE;AA/Sf,SAAA9B,OAAA+B,QAAA;CAAA,OAmKmD/I,OAAIG,SAAU;AAAS;AAnK1E,SAAAuD,OAAAsF,QAAA;CAAA,OAoEkDhJ,OAAI6I,YAAJ,CAAA;AAAmB;AApErE,SAAA5F,MAAAjD,MAAA;CAAA,OAsD2CA,KAAIG,SAAU;AAAS"}
|
package/dist/context.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import type { Form, FormState } from '@panneau/core';
|
|
2
|
+
import { type RevealRegistry } from '@panneau/fields';
|
|
2
3
|
export declare const FormContext: import("react").Context<Form | null>;
|
|
3
4
|
/** The form of the closest `FormView`. */
|
|
4
5
|
export declare function useFormContext(): Form;
|
|
5
6
|
/** The state of a form, updated on every change. */
|
|
6
7
|
export declare function useFormState(form: Form): FormState;
|
|
7
8
|
export { RevealContext, createRevealRegistry } from '@panneau/fields';
|
|
9
|
+
/**
|
|
10
|
+
* Where a form asks its sections to open on the paths of its errors after a failed save: every
|
|
11
|
+
* collapsed section that holds one opens. Unlike `RevealContext`, tabs don't follow: one only
|
|
12
|
+
* can show, and each keeps its error count.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ErrorSectionsContext: import("react").Context<RevealRegistry>;
|
|
8
15
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,iBAAiB,CAAC;AAE5E,eAAO,MAAM,WAAW,sCAAmC,CAAC;AAE5D,0CAA0C;AAC1C,wBAAgB,cAAc,IAAI,IAAI,CAMrC;AAED,oDAAoD;AACpD,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,CAElD;AAID,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEtE;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,yCAAwD,CAAC"}
|
package/dist/context.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext, use, useSyncExternalStore } from "react";
|
|
2
|
-
import { RevealContext, createRevealRegistry } from "@panneau/fields";
|
|
2
|
+
import { RevealContext, createRevealRegistry, createRevealRegistry as createRevealRegistry$1 } from "@panneau/fields";
|
|
3
3
|
//#region src/context.ts
|
|
4
4
|
var FormContext = createContext(null);
|
|
5
5
|
/** The form of the closest `FormView`. */
|
|
@@ -12,7 +12,13 @@ function useFormContext() {
|
|
|
12
12
|
function useFormState(form) {
|
|
13
13
|
return useSyncExternalStore(form.subscribe, form.getState, form.getState);
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Where a form asks its sections to open on the paths of its errors after a failed save: every
|
|
17
|
+
* collapsed section that holds one opens. Unlike `RevealContext`, tabs don't follow: one only
|
|
18
|
+
* can show, and each keeps its error count.
|
|
19
|
+
*/
|
|
20
|
+
var ErrorSectionsContext = createContext(createRevealRegistry());
|
|
15
21
|
//#endregion
|
|
16
|
-
export { FormContext, RevealContext, createRevealRegistry, useFormContext, useFormState };
|
|
22
|
+
export { ErrorSectionsContext, FormContext, RevealContext, createRevealRegistry$1 as createRevealRegistry, useFormContext, useFormState };
|
|
17
23
|
|
|
18
24
|
//# sourceMappingURL=context.js.map
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":["createContext","use","useSyncExternalStore","Form","FormState","FormContext","useFormContext","form","Error","useFormState","subscribe","getState","RevealContext","
|
|
1
|
+
{"version":3,"file":"context.js","names":["createContext","use","useSyncExternalStore","Form","FormState","RevealRegistry","createRevealRegistry","FormContext","useFormContext","form","Error","useFormState","subscribe","getState","RevealContext","ErrorSectionsContext"],"sources":["../src/context.ts"],"sourcesContent":["import { createContext, use, useSyncExternalStore } from 'react';\n\nimport type { Form, FormState } from '@panneau/core';\nimport { type RevealRegistry, createRevealRegistry } from '@panneau/fields';\n\nexport const FormContext = createContext<Form | null>(null);\n\n/** The form of the closest `FormView`. */\nexport function useFormContext(): Form {\n const form = use(FormContext);\n if (form === null) {\n throw new Error('This component must be rendered inside a <Form> or a <FormView>.');\n }\n return form;\n}\n\n/** The state of a form, updated on every change. */\nexport function useFormState(form: Form): FormState {\n return useSyncExternalStore(form.subscribe, form.getState, form.getState);\n}\n\n// The reveal registry is in `@panneau/fields`, for the fields that hide some of their own (the\n// locales of a localized field).\nexport { RevealContext, createRevealRegistry } from '@panneau/fields';\n\n/**\n * Where a form asks its sections to open on the paths of its errors after a failed save: every\n * collapsed section that holds one opens. Unlike `RevealContext`, tabs don't follow: one only\n * can show, and each keeps its error count.\n */\nexport const ErrorSectionsContext = createContext<RevealRegistry>(createRevealRegistry());\n"],"mappings":";;;AAKA,IAAaO,cAAcP,cAA2B,IAAI;;AAG1D,SAAgBQ,iBAAuB;CACnC,MAAMC,OAAOR,IAAIM,WAAW;CAC5B,IAAIE,SAAS,MACT,MAAM,IAAIC,MAAM,kEAAkE;CAEtF,OAAOD;AACX;;AAGA,SAAOE,aAAAF,MAAA;CAAA,OACIP,qBAAqBO,KAAIG,WAAYH,KAAII,UAAWJ,KAAII,QAAS;AAAC;;;;;;AAY7E,IAAaE,uBAAuBf,cAA8BM,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../../src/layout/Layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,SAAS,EAMjB,MAAM,OAAO,CAAC;AAUf,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAQ3D,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IAC7B,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CACtC;
|
|
1
|
+
{"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../../src/layout/Layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,SAAS,EAMjB,MAAM,OAAO,CAAC;AAUf,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAQ3D,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IAC7B,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CACtC;AA8LD,qCAAqC;AACrC,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,GAAG,SAAS,CAErE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,GAAG,SAAS,CAmBnE"}
|
package/dist/layout/Layout.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { messages } from "../messages.js";
|
|
2
2
|
import Form_module_default from "../Form.module.js";
|
|
3
|
-
import { RevealContext, useFormContext, useFormState } from "../context.js";
|
|
3
|
+
import { ErrorSectionsContext, RevealContext, useFormContext, useFormState } from "../context.js";
|
|
4
4
|
import { cx } from "../cx.js";
|
|
5
5
|
import { c } from "react/compiler-runtime";
|
|
6
6
|
import { getLayoutFieldNames, selectErrorCount, selectVisible, usePlugins } from "@panneau/core";
|
|
@@ -109,10 +109,11 @@ function _temp(tab) {
|
|
|
109
109
|
return getLayoutFieldNames(tab.children ?? []);
|
|
110
110
|
}
|
|
111
111
|
function SectionNode(t0) {
|
|
112
|
-
const $ = c(
|
|
112
|
+
const $ = c(38);
|
|
113
113
|
const { node, fields } = t0;
|
|
114
114
|
const form = useFormContext();
|
|
115
115
|
const registry = use(RevealContext);
|
|
116
|
+
const errorSections = use(ErrorSectionsContext);
|
|
116
117
|
const titleId = useId();
|
|
117
118
|
let t1;
|
|
118
119
|
if ($[0] !== node.children) {
|
|
@@ -130,37 +131,50 @@ function SectionNode(t0) {
|
|
|
130
131
|
const [expanded, setExpanded] = useState(node.collapsed !== true);
|
|
131
132
|
let t3;
|
|
132
133
|
let t4;
|
|
133
|
-
if ($[4] !==
|
|
134
|
-
t3 = () =>
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
134
|
+
if ($[4] !== errorSections || $[5] !== names || $[6] !== registry) {
|
|
135
|
+
t3 = () => {
|
|
136
|
+
const open = (path) => {
|
|
137
|
+
if (containsPath(names, path)) setExpanded(true);
|
|
138
|
+
};
|
|
139
|
+
const removeRevealer = registry.add(open);
|
|
140
|
+
const removeOpener = errorSections.add(open);
|
|
141
|
+
return () => {
|
|
142
|
+
removeRevealer();
|
|
143
|
+
removeOpener();
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
t4 = [
|
|
147
|
+
registry,
|
|
148
|
+
errorSections,
|
|
149
|
+
names
|
|
150
|
+
];
|
|
151
|
+
$[4] = errorSections;
|
|
152
|
+
$[5] = names;
|
|
153
|
+
$[6] = registry;
|
|
154
|
+
$[7] = t3;
|
|
155
|
+
$[8] = t4;
|
|
142
156
|
} else {
|
|
143
|
-
t3 = $[
|
|
144
|
-
t4 = $[
|
|
157
|
+
t3 = $[7];
|
|
158
|
+
t4 = $[8];
|
|
145
159
|
}
|
|
146
160
|
useEffect(t3, t4);
|
|
147
161
|
let t5;
|
|
148
|
-
if ($[
|
|
162
|
+
if ($[9] !== node.description) {
|
|
149
163
|
t5 = node.description !== void 0 ? /* @__PURE__ */ jsx("p", {
|
|
150
164
|
className: Form_module_default.sectionDescription,
|
|
151
165
|
children: node.description
|
|
152
166
|
}) : null;
|
|
153
|
-
$[
|
|
154
|
-
$[
|
|
155
|
-
} else t5 = $[
|
|
167
|
+
$[9] = node.description;
|
|
168
|
+
$[10] = t5;
|
|
169
|
+
} else t5 = $[10];
|
|
156
170
|
let t6;
|
|
157
|
-
if ($[
|
|
171
|
+
if ($[11] !== node.children) {
|
|
158
172
|
t6 = node.children ?? [];
|
|
159
|
-
$[
|
|
160
|
-
$[
|
|
161
|
-
} else t6 = $[
|
|
173
|
+
$[11] = node.children;
|
|
174
|
+
$[12] = t6;
|
|
175
|
+
} else t6 = $[12];
|
|
162
176
|
let t7;
|
|
163
|
-
if ($[
|
|
177
|
+
if ($[13] !== fields || $[14] !== t6) {
|
|
164
178
|
t7 = /* @__PURE__ */ jsx("div", {
|
|
165
179
|
className: Form_module_default.stack,
|
|
166
180
|
children: /* @__PURE__ */ jsx(LayoutNodes, {
|
|
@@ -168,40 +182,40 @@ function SectionNode(t0) {
|
|
|
168
182
|
fields
|
|
169
183
|
})
|
|
170
184
|
});
|
|
171
|
-
$[
|
|
172
|
-
$[
|
|
173
|
-
$[
|
|
174
|
-
} else t7 = $[
|
|
185
|
+
$[13] = fields;
|
|
186
|
+
$[14] = t6;
|
|
187
|
+
$[15] = t7;
|
|
188
|
+
} else t7 = $[15];
|
|
175
189
|
let t8;
|
|
176
|
-
if ($[
|
|
190
|
+
if ($[16] !== t5 || $[17] !== t7) {
|
|
177
191
|
t8 = /* @__PURE__ */ jsxs(Fragment, { children: [t5, t7] });
|
|
178
|
-
$[
|
|
179
|
-
$[
|
|
180
|
-
$[
|
|
181
|
-
} else t8 = $[
|
|
192
|
+
$[16] = t5;
|
|
193
|
+
$[17] = t7;
|
|
194
|
+
$[18] = t8;
|
|
195
|
+
} else t8 = $[18];
|
|
182
196
|
const content = t8;
|
|
183
197
|
if (node.collapsible === true) {
|
|
184
198
|
let t9;
|
|
185
|
-
if ($[
|
|
199
|
+
if ($[19] !== form || $[20] !== names) {
|
|
186
200
|
t9 = /* @__PURE__ */ jsx(ErrorBadge, {
|
|
187
201
|
form,
|
|
188
202
|
names
|
|
189
203
|
});
|
|
190
|
-
$[
|
|
191
|
-
$[
|
|
192
|
-
$[
|
|
193
|
-
} else t9 = $[
|
|
204
|
+
$[19] = form;
|
|
205
|
+
$[20] = names;
|
|
206
|
+
$[21] = t9;
|
|
207
|
+
} else t9 = $[21];
|
|
194
208
|
let t10;
|
|
195
|
-
if ($[
|
|
209
|
+
if ($[22] !== content) {
|
|
196
210
|
t10 = /* @__PURE__ */ jsx("div", {
|
|
197
211
|
className: Form_module_default.stack,
|
|
198
212
|
children: content
|
|
199
213
|
});
|
|
200
|
-
$[
|
|
201
|
-
$[
|
|
202
|
-
} else t10 = $[
|
|
214
|
+
$[22] = content;
|
|
215
|
+
$[23] = t10;
|
|
216
|
+
} else t10 = $[23];
|
|
203
217
|
let t11;
|
|
204
|
-
if ($[
|
|
218
|
+
if ($[24] !== expanded || $[25] !== node.label || $[26] !== t10 || $[27] !== t9) {
|
|
205
219
|
t11 = /* @__PURE__ */ jsx("div", {
|
|
206
220
|
className: Form_module_default.section,
|
|
207
221
|
children: /* @__PURE__ */ jsx(Disclosure, {
|
|
@@ -212,17 +226,17 @@ function SectionNode(t0) {
|
|
|
212
226
|
children: t10
|
|
213
227
|
})
|
|
214
228
|
});
|
|
215
|
-
$[
|
|
216
|
-
$[
|
|
217
|
-
$[
|
|
218
|
-
$[
|
|
219
|
-
$[
|
|
220
|
-
} else t11 = $[
|
|
229
|
+
$[24] = expanded;
|
|
230
|
+
$[25] = node.label;
|
|
231
|
+
$[26] = t10;
|
|
232
|
+
$[27] = t9;
|
|
233
|
+
$[28] = t11;
|
|
234
|
+
} else t11 = $[28];
|
|
221
235
|
return t11;
|
|
222
236
|
}
|
|
223
237
|
const t9 = node.label !== void 0 ? titleId : void 0;
|
|
224
238
|
let t10;
|
|
225
|
-
if ($[
|
|
239
|
+
if ($[29] !== form || $[30] !== names || $[31] !== node.label || $[32] !== titleId) {
|
|
226
240
|
t10 = node.label !== void 0 ? /* @__PURE__ */ jsx("div", {
|
|
227
241
|
className: Form_module_default.sectionHeader,
|
|
228
242
|
children: /* @__PURE__ */ jsxs("h3", {
|
|
@@ -238,24 +252,24 @@ function SectionNode(t0) {
|
|
|
238
252
|
]
|
|
239
253
|
})
|
|
240
254
|
}) : null;
|
|
241
|
-
$[
|
|
242
|
-
$[
|
|
243
|
-
$[
|
|
244
|
-
$[
|
|
245
|
-
$[
|
|
246
|
-
} else t10 = $[
|
|
255
|
+
$[29] = form;
|
|
256
|
+
$[30] = names;
|
|
257
|
+
$[31] = node.label;
|
|
258
|
+
$[32] = titleId;
|
|
259
|
+
$[33] = t10;
|
|
260
|
+
} else t10 = $[33];
|
|
247
261
|
let t11;
|
|
248
|
-
if ($[
|
|
262
|
+
if ($[34] !== content || $[35] !== t10 || $[36] !== t9) {
|
|
249
263
|
t11 = /* @__PURE__ */ jsxs("section", {
|
|
250
264
|
className: Form_module_default.section,
|
|
251
265
|
"aria-labelledby": t9,
|
|
252
266
|
children: [t10, content]
|
|
253
267
|
});
|
|
254
|
-
$[
|
|
255
|
-
$[
|
|
256
|
-
$[
|
|
257
|
-
$[
|
|
258
|
-
} else t11 = $[
|
|
268
|
+
$[34] = content;
|
|
269
|
+
$[35] = t10;
|
|
270
|
+
$[36] = t9;
|
|
271
|
+
$[37] = t11;
|
|
272
|
+
} else t11 = $[37];
|
|
259
273
|
return t11;
|
|
260
274
|
}
|
|
261
275
|
function ComponentNode(t0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layout.js","names":["CSSProperties","ReactNode","createElement","use","useEffect","useId","useState","Form","getLayoutFieldNames","selectErrorCount","selectVisible","usePlugins","NestedField","isWideField","Field","LayoutNode","Badge","Disclosure","Tab","TabList","TabPanel","Tabs","usePanneauIntl","styles","RevealContext","useFormContext","useFormState","cx","messages","LayoutProps","nodes","fields","ReadonlyMap","containsPath","names","path","name","split","undefined","includes","ErrorBadge","t0","$","_c","form","intl","count","T0","t1","t2","formatMessage","errorCount","t3","TabsNode","node","state","registry","id","child","type","tabs","children","filter","map","_temp","selected","setSelected","add","index","findIndex","tabNames","Symbol","for","key","String","tab_2","index_1","stack","tab","label","_temp2","join","tab_1","index_0","tab_0","SectionNode","titleId","expanded","setExpanded","collapsed","t4","t5","description","sectionDescription","t6","t7","t8","content","collapsible","t9","t10","t11","section","sectionHeader","sectionTitle","ComponentNode","components","bb0","Component","component","get","props","LayoutNodeView","field","values","cell","width","row","text","LayoutNodes","FieldFlow","flowCell","flowWide","flow","_c","styles","_Fragment"],"sources":["../../src/layout/Layout.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ReactNode,\n createElement,\n use,\n useEffect,\n useId,\n useState,\n} from 'react';\n\nimport {\n type Form,\n getLayoutFieldNames,\n selectErrorCount,\n selectVisible,\n usePlugins,\n} from '@panneau/core';\nimport { NestedField, isWideField } from '@panneau/fields';\nimport type { Field, LayoutNode } from '@panneau/protocol';\nimport { Badge, Disclosure, Tab, TabList, TabPanel, Tabs, usePanneauIntl } from '@panneau/ui';\n\nimport styles from '../Form.module.css';\nimport { RevealContext, useFormContext, useFormState } from '../context';\nimport { cx } from '../cx';\nimport { messages } from '../messages';\n\nexport interface LayoutProps {\n nodes: readonly LayoutNode[];\n fields: ReadonlyMap<string, Field>;\n}\n\n/** Whether a path belongs to one of the field names (`title.fr` to `title`). */\nfunction containsPath(names: readonly string[], path: string): boolean {\n const name = path.split('.')[0];\n return name !== undefined && names.includes(name);\n}\n\nfunction ErrorBadge({ form, names }: { form: Form; names: readonly string[] }) {\n const intl = usePanneauIntl();\n const count = selectErrorCount(useFormState(form), names);\n if (count === 0) {\n return null;\n }\n return (\n <Badge tone=\"danger\" label={intl.formatMessage(messages.errorCount, { count })}>\n {count}\n </Badge>\n );\n}\n\nfunction TabsNode({ node, fields }: { node: LayoutNode; fields: ReadonlyMap<string, Field> }) {\n const form = useFormContext();\n const state = useFormState(form);\n const registry = use(RevealContext);\n const id = useId();\n const tabs = (node.children ?? []).filter(\n (child) => child.type === 'tab' && selectVisible(state, child),\n );\n const names = tabs.map((tab) => getLayoutFieldNames(tab.children ?? []));\n const [selected, setSelected] = useState<string>(`${id}-0`);\n\n useEffect(\n () =>\n registry.add((path) => {\n const index = names.findIndex((tabNames) => containsPath(tabNames, path));\n if (index !== -1) {\n setSelected(`${id}-${index}`);\n }\n }),\n [registry, names, id],\n );\n\n return (\n <Tabs selectedKey={selected} onSelectionChange={(key) => setSelected(String(key))}>\n <TabList aria-label={node.label ?? tabs.map((tab) => tab.label ?? '').join(', ')}>\n {tabs.map((tab, index) => (\n <Tab key={index} id={`${id}-${index}`}>\n {tab.label} <ErrorBadge form={form} names={names[index] ?? []} />\n </Tab>\n ))}\n </TabList>\n {tabs.map((tab, index) => (\n // Panels stay mounted: fields keep their state, and errors can be revealed.\n <TabPanel key={index} id={`${id}-${index}`} shouldForceMount>\n <div className={styles.stack}>\n <LayoutNodes nodes={tab.children ?? []} fields={fields} />\n </div>\n </TabPanel>\n ))}\n </Tabs>\n );\n}\n\nfunction SectionNode({ node, fields }: { node: LayoutNode; fields: ReadonlyMap<string, Field> }) {\n const form = useFormContext();\n const registry = use(RevealContext);\n const titleId = useId();\n const names = getLayoutFieldNames(node.children ?? []);\n const [expanded, setExpanded] = useState(node.collapsed !== true);\n\n useEffect(\n () =>\n registry.add((path) => {\n if (containsPath(names, path)) {\n setExpanded(true);\n }\n }),\n [registry, names],\n );\n\n const content = (\n <>\n {node.description !== undefined ? (\n <p className={styles.sectionDescription}>{node.description}</p>\n ) : null}\n <div className={styles.stack}>\n <LayoutNodes nodes={node.children ?? []} fields={fields} />\n </div>\n </>\n );\n if (node.collapsible === true) {\n return (\n <div className={styles.section}>\n <Disclosure\n title={node.label}\n titleEnd={<ErrorBadge form={form} names={names} />}\n isExpanded={expanded}\n onExpandedChange={setExpanded}\n >\n <div className={styles.stack}>{content}</div>\n </Disclosure>\n </div>\n );\n }\n return (\n <section\n className={styles.section}\n aria-labelledby={node.label !== undefined ? titleId : undefined}\n >\n {node.label !== undefined ? (\n <div className={styles.sectionHeader}>\n <h3 id={titleId} className={styles.sectionTitle}>\n {node.label} <ErrorBadge form={form} names={names} />\n </h3>\n </div>\n ) : null}\n {content}\n </section>\n );\n}\n\nfunction ComponentNode({ node }: { node: LayoutNode }) {\n const form = useFormContext();\n const { components } = usePlugins();\n const Component = node.component !== undefined ? components.get(node.component) : undefined;\n if (Component === undefined) {\n return null;\n }\n // A component of the plugin registry, looked up by name: not created during render.\n return createElement(Component, { ...node.props, node, form });\n}\n\nfunction LayoutNodeView({\n node,\n fields,\n}: {\n node: LayoutNode;\n fields: ReadonlyMap<string, Field>;\n}) {\n const form = useFormContext();\n const state = useFormState(form);\n if (!selectVisible(state, node)) {\n return null;\n }\n switch (node.type) {\n case 'field': {\n const field = node.name !== undefined ? fields.get(node.name) : undefined;\n return field !== undefined ? (\n <NestedField field={field} path={field.name} parentValue={state.values} />\n ) : null;\n }\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 <LayoutNodeView node={child} fields={fields} />\n </div>\n ))}\n </div>\n );\n case 'tabs':\n return <TabsNode node={node} fields={fields} />;\n case 'section':\n return <SectionNode node={node} fields={fields} />;\n case 'text':\n return <p className={styles.text}>{node.text ?? node.label}</p>;\n case 'component':\n return <ComponentNode node={node} />;\n default:\n // `column`, a `tab` or a `sidebar` out of place, and unknown containers.\n return (\n <div className={styles.stack}>\n <LayoutNodes nodes={node.children ?? []} fields={fields} />\n </div>\n );\n }\n}\n\n/** Renders layout nodes in order. */\nexport function LayoutNodes({ nodes, fields }: LayoutProps): ReactNode {\n return nodes.map((node, index) => <LayoutNodeView key={index} node={node} fields={fields} />);\n}\n\n/**\n * Fields that the layout doesn't place, in columns: short fields side by side, wide ones\n * (`isWideField()`) on their own row.\n */\nexport function FieldFlow({ nodes, fields }: LayoutProps): ReactNode {\n return (\n <div className={styles.flow}>\n {nodes.map((node, index) => {\n const field = 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)) && styles.flowWide,\n )}\n >\n <LayoutNodeView node={node} fields={fields} />\n </div>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,SAASiC,aAAaC,OAA0BC,MAAuB;CACnE,MAAMC,OAAOD,KAAKE,MAAM,GAAG,CAAC,CAAC;CAC7B,OAAOD,SAASE,KAAAA,KAAaJ,MAAMK,SAASH,IAAI;AACpD;AAEA,SAAAI,WAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAoB,MAAA,EAAAC,MAAAV,UAAAO;CAChB,MAAAI,OAAavB,eAAe;CAC5B,MAAAwB,QAAcrC,iBAAiBiB,aAAakB,IAAI,GAAGV,KAAK;CACxD,IAAIY,UAAU,GAAC,OACJ;CAGN,MAAAC,KAAA/B;CAAW,MAAAgC,KAAA;CAAgB,MAAAC,KAAAJ,KAAIK,cAAetB,SAAQuB,YAAa,EAAAL,MAAQ,CAAC;CAAC,IAAAM;CAAA,IAAAV,EAAA,OAAAK,MAAAL,EAAA,OAAAI,SAAAJ,EAAA,OAAAO,IAAA;EAA9EG,KAAA,oBAAC,IAAD;GAAY,MAAAJ;GAAgB,OAAAC;GACvBH,UAAAA;EADC,CAAA;EAEEJ,EAAA,KAAAK;EAAAL,EAAA,KAAAI;EAAAJ,EAAA,KAAAO;EAAAP,EAAA,KAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,OAFRU;AAEQ;AAIhB,SAAAC,SAAAZ,IAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAkB,MAAA,EAAAW,MAAAvB,WAAAU;CACd,MAAAG,OAAanB,eAAe;CAC5B,MA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AG;AAChG;;;;;AAMA,SAAOoD,UAAA/E,IAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAmB,MAAA,EAAAb,OAAAC,WAAAU;CAA8B,IAAAO;CAAA,IAAAN,EAAA,OAAAX,UAAAW,EAAA,OAAAZ,OAAA;EAAA,IAAAmB;EAAA,IAAAP,EAAA,OAAAX,QAAA;GAGjCkB,MAAAK,MAAAc,UAAA;IACP,MAAA6C,QAAc3D,KAAIlB,SAAUE,KAAAA,IAAYP,OAAM+E,IAAKxD,KAAIlB,IAAiB,IAA1DE,KAAAA;IAA4D,OAEtE,oBAAA,OAAA;KAEe,WAAAX,GACPJ,oBAAMkG,WACLR,UAAU3E,KAAAA,KAAazB,YAAYoG,KAAK,MAAM1F,oBAAMmG,QACzD;KAEA,UAAA,oBAAC,gBAAD;MAAsBpE;MAAcvB;KAAM,CAAA;IACxC,GAPGqC,KAOH;GAAA;GAEb1B,EAAA,KAAAX;GAAAW,EAAA,KAAAO;EAAA,OAAAA,KAAAP,EAAA;EAbAM,KAAAlB,MAAKiC,IAAKd,EAaV;EAACP,EAAA,KAAAX;EAAAW,EAAA,KAAAZ;EAAAY,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAAA,IAAAO;CAAA,IAAAP,EAAA,OAAAM,IAAA;EAdNC,KAAA,oBAAA,OAAA;GAAgB,WAAA1B,oBAAMoG;GACjB3E,UAAAA;EAcC,CAAA;EAAAN,EAAA,KAAAM;EAAAN,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,OAfNO;AAeM"}
|
|
1
|
+
{"version":3,"file":"Layout.js","names":["CSSProperties","ReactNode","createElement","use","useEffect","useId","useState","Form","getLayoutFieldNames","selectErrorCount","selectVisible","usePlugins","NestedField","isWideField","Field","LayoutNode","Badge","Disclosure","Tab","TabList","TabPanel","Tabs","usePanneauIntl","styles","ErrorSectionsContext","RevealContext","useFormContext","useFormState","cx","messages","LayoutProps","nodes","fields","ReadonlyMap","containsPath","names","path","name","split","undefined","includes","ErrorBadge","t0","$","_c","form","intl","count","T0","t1","t2","formatMessage","errorCount","t3","TabsNode","node","state","registry","id","child","type","tabs","children","filter","map","_temp","selected","setSelected","add","index","findIndex","tabNames","Symbol","for","key","String","tab_2","index_1","stack","tab","label","_temp2","join","tab_1","index_0","tab_0","SectionNode","errorSections","titleId","expanded","setExpanded","collapsed","t4","open","removeRevealer","removeOpener","t5","description","sectionDescription","t6","t7","t8","content","collapsible","t9","t10","t11","section","sectionHeader","sectionTitle","ComponentNode","components","bb0","Component","component","get","props","LayoutNodeView","field","values","cell","width","row","text","LayoutNodes","FieldFlow","flowCell","flowWide","flow","_c","styles","_Fragment"],"sources":["../../src/layout/Layout.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ReactNode,\n createElement,\n use,\n useEffect,\n useId,\n useState,\n} from 'react';\n\nimport {\n type Form,\n getLayoutFieldNames,\n selectErrorCount,\n selectVisible,\n usePlugins,\n} from '@panneau/core';\nimport { NestedField, isWideField } from '@panneau/fields';\nimport type { Field, LayoutNode } from '@panneau/protocol';\nimport { Badge, Disclosure, Tab, TabList, TabPanel, Tabs, usePanneauIntl } from '@panneau/ui';\n\nimport styles from '../Form.module.css';\nimport { ErrorSectionsContext, RevealContext, useFormContext, useFormState } from '../context';\nimport { cx } from '../cx';\nimport { messages } from '../messages';\n\nexport interface LayoutProps {\n nodes: readonly LayoutNode[];\n fields: ReadonlyMap<string, Field>;\n}\n\n/** Whether a path belongs to one of the field names (`title.fr` to `title`). */\nfunction containsPath(names: readonly string[], path: string): boolean {\n const name = path.split('.')[0];\n return name !== undefined && names.includes(name);\n}\n\nfunction ErrorBadge({ form, names }: { form: Form; names: readonly string[] }) {\n const intl = usePanneauIntl();\n const count = selectErrorCount(useFormState(form), names);\n if (count === 0) {\n return null;\n }\n return (\n <Badge tone=\"danger\" label={intl.formatMessage(messages.errorCount, { count })}>\n {count}\n </Badge>\n );\n}\n\nfunction TabsNode({ node, fields }: { node: LayoutNode; fields: ReadonlyMap<string, Field> }) {\n const form = useFormContext();\n const state = useFormState(form);\n const registry = use(RevealContext);\n const id = useId();\n const tabs = (node.children ?? []).filter(\n (child) => child.type === 'tab' && selectVisible(state, child),\n );\n const names = tabs.map((tab) => getLayoutFieldNames(tab.children ?? []));\n const [selected, setSelected] = useState<string>(`${id}-0`);\n\n useEffect(\n () =>\n registry.add((path) => {\n const index = names.findIndex((tabNames) => containsPath(tabNames, path));\n if (index !== -1) {\n setSelected(`${id}-${index}`);\n }\n }),\n [registry, names, id],\n );\n\n return (\n <Tabs selectedKey={selected} onSelectionChange={(key) => setSelected(String(key))}>\n <TabList aria-label={node.label ?? tabs.map((tab) => tab.label ?? '').join(', ')}>\n {tabs.map((tab, index) => (\n <Tab key={index} id={`${id}-${index}`}>\n {tab.label} <ErrorBadge form={form} names={names[index] ?? []} />\n </Tab>\n ))}\n </TabList>\n {tabs.map((tab, index) => (\n // Panels stay mounted: fields keep their state, and errors can be revealed.\n <TabPanel key={index} id={`${id}-${index}`} shouldForceMount>\n <div className={styles.stack}>\n <LayoutNodes nodes={tab.children ?? []} fields={fields} />\n </div>\n </TabPanel>\n ))}\n </Tabs>\n );\n}\n\nfunction SectionNode({ node, fields }: { node: LayoutNode; fields: ReadonlyMap<string, Field> }) {\n const form = useFormContext();\n const registry = use(RevealContext);\n const errorSections = use(ErrorSectionsContext);\n const titleId = useId();\n const names = getLayoutFieldNames(node.children ?? []);\n const [expanded, setExpanded] = useState(node.collapsed !== true);\n\n // Opens to reveal a field, and after a failed save when it holds an error\n useEffect(() => {\n const open = (path: string) => {\n if (containsPath(names, path)) {\n setExpanded(true);\n }\n };\n const removeRevealer = registry.add(open);\n const removeOpener = errorSections.add(open);\n return () => {\n removeRevealer();\n removeOpener();\n };\n }, [registry, errorSections, names]);\n\n const content = (\n <>\n {node.description !== undefined ? (\n <p className={styles.sectionDescription}>{node.description}</p>\n ) : null}\n <div className={styles.stack}>\n <LayoutNodes nodes={node.children ?? []} fields={fields} />\n </div>\n </>\n );\n if (node.collapsible === true) {\n return (\n <div className={styles.section}>\n <Disclosure\n title={node.label}\n titleEnd={<ErrorBadge form={form} names={names} />}\n isExpanded={expanded}\n onExpandedChange={setExpanded}\n >\n <div className={styles.stack}>{content}</div>\n </Disclosure>\n </div>\n );\n }\n return (\n <section\n className={styles.section}\n aria-labelledby={node.label !== undefined ? titleId : undefined}\n >\n {node.label !== undefined ? (\n <div className={styles.sectionHeader}>\n <h3 id={titleId} className={styles.sectionTitle}>\n {node.label} <ErrorBadge form={form} names={names} />\n </h3>\n </div>\n ) : null}\n {content}\n </section>\n );\n}\n\nfunction ComponentNode({ node }: { node: LayoutNode }) {\n const form = useFormContext();\n const { components } = usePlugins();\n const Component = node.component !== undefined ? components.get(node.component) : undefined;\n if (Component === undefined) {\n return null;\n }\n // A component of the plugin registry, looked up by name: not created during render.\n return createElement(Component, { ...node.props, node, form });\n}\n\nfunction LayoutNodeView({\n node,\n fields,\n}: {\n node: LayoutNode;\n fields: ReadonlyMap<string, Field>;\n}) {\n const form = useFormContext();\n const state = useFormState(form);\n if (!selectVisible(state, node)) {\n return null;\n }\n switch (node.type) {\n case 'field': {\n const field = node.name !== undefined ? fields.get(node.name) : undefined;\n return field !== undefined ? (\n <NestedField field={field} path={field.name} parentValue={state.values} />\n ) : null;\n }\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 <LayoutNodeView node={child} fields={fields} />\n </div>\n ))}\n </div>\n );\n case 'tabs':\n return <TabsNode node={node} fields={fields} />;\n case 'section':\n return <SectionNode node={node} fields={fields} />;\n case 'text':\n return <p className={styles.text}>{node.text ?? node.label}</p>;\n case 'component':\n return <ComponentNode node={node} />;\n default:\n // `column`, a `tab` or a `sidebar` out of place, and unknown containers.\n return (\n <div className={styles.stack}>\n <LayoutNodes nodes={node.children ?? []} fields={fields} />\n </div>\n );\n }\n}\n\n/** Renders layout nodes in order. */\nexport function LayoutNodes({ nodes, fields }: LayoutProps): ReactNode {\n return nodes.map((node, index) => <LayoutNodeView key={index} node={node} fields={fields} />);\n}\n\n/**\n * Fields that the layout doesn't place, in columns: short fields side by side, wide ones\n * (`isWideField()`) on their own row.\n */\nexport function FieldFlow({ nodes, fields }: LayoutProps): ReactNode {\n return (\n <div className={styles.flow}>\n {nodes.map((node, index) => {\n const field = 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)) && styles.flowWide,\n )}\n >\n <LayoutNodeView node={node} fields={fields} />\n </div>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,SAASkC,aAAaC,OAA0BC,MAAuB;CACnE,MAAMC,OAAOD,KAAKE,MAAM,GAAG,CAAC,CAAC;CAC7B,OAAOD,SAASE,KAAAA,KAAaJ,MAAMK,SAASH,IAAI;AACpD;AAEA,SAAAI,WAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAoB,MAAA,EAAAC,MAAAV,UAAAO;CAChB,MAAAI,OAAaxB,eAAe;CAC5B,MAAAyB,QAActC,iBAAiBkB,aAAakB,IAAI,GAAGV,KAAK;CACxD,IAAIY,UAAU,GAAC,OACJ;CAGN,MAAAC,KAAAhC;CAAW,MAAAiC,KAAA;CAAgB,MAAAC,KAAAJ,KAAIK,cAAetB,SAAQuB,YAAa,EAAAL,MAAQ,CAAC;CAAC,IAAAM;CAAA,IAAAV,EAAA,OAAAK,MAAAL,EAAA,OAAAI,SAAAJ,EAAA,OAAAO,IAAA;EAA9EG,KAAA,oBAAC,IAAD;GAAY,MAAAJ;GAAgB,OAAAC;GACvBH,UAAAA;EADC,CAAA;EAEEJ,EAAA,KAAAK;EAAAL,EAAA,KAAAI;EAAAJ,EAAA,KAAAO;EAAAP,EAAA,KAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,OAFRU;AAEQ;A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;GACjB/E,UAAAA;EAcC,CAAA;EAAAN,EAAA,KAAAM;EAAAN,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,OAfNO;AAeM"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/forms",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.18",
|
|
4
4
|
"description": "Forms of Panneau: fields in a layout, driven by the form state of @panneau/core, with errors, unsaved changes and version conflicts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,13 +41,15 @@
|
|
|
41
41
|
"react-intl": "^12.0.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@panneau/core": "5.0.0-alpha.
|
|
45
|
-
"@panneau/fields": "5.0.0-alpha.
|
|
46
|
-
"@panneau/intl": "5.0.0-alpha.
|
|
47
|
-
"@panneau/protocol": "5.0.0-alpha.
|
|
48
|
-
"@panneau/ui": "5.0.0-alpha.
|
|
44
|
+
"@panneau/core": "5.0.0-alpha.18",
|
|
45
|
+
"@panneau/fields": "5.0.0-alpha.18",
|
|
46
|
+
"@panneau/intl": "5.0.0-alpha.18",
|
|
47
|
+
"@panneau/protocol": "5.0.0-alpha.18",
|
|
48
|
+
"@panneau/ui": "5.0.0-alpha.18",
|
|
49
|
+
"lucide-react": "^1.57.0"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
|
-
"@panneau/data": "5.0.0-alpha.
|
|
52
|
+
"@panneau/data": "5.0.0-alpha.18",
|
|
53
|
+
"@panneau/editor": "5.0.0-alpha.18"
|
|
52
54
|
}
|
|
53
55
|
}
|