@panneau/forms 5.0.0-alpha.6 → 5.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/FormView.js CHANGED
@@ -5,8 +5,10 @@ import { ErrorSummary } from "./ErrorSummary.js";
5
5
  import { FormContext, RevealContext, createRevealRegistry, useFormState } from "./context.js";
6
6
  import { FormBinding } from "./FormBinding.js";
7
7
  import { cx } from "./cx.js";
8
+ import { FormSkeleton } from "./FormSkeleton.js";
8
9
  import { LayoutNodes } from "./layout/Layout.js";
9
10
  import { useBeforeUnloadGuard, useLeaveConfirmation } from "./unsaved.js";
11
+ import { c } from "react/compiler-runtime";
10
12
  import { getLayoutFieldNames, getProblem, resolveFields, selectVisible, useLeaveGuard, usePanneau, usePlugins } from "@panneau/core";
11
13
  import { Alert, Button, usePanneauIntl, useToast } from "@panneau/ui";
12
14
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -42,7 +44,13 @@ function orderErrors(names, errors) {
42
44
  * unsaved changes and the dialog of version conflicts. Saving is the job of the form's
43
45
  * `onSubmit`.
44
46
  */
45
- function FormView({ form, fields, layout = [], locales, relationSource, uploadSource, checkSource, components, submitLabel, actions, onSubmitted, onReload, guardUnsavedChanges = true, showSavedToast = true, id, "aria-label": ariaLabel, className, layoutClassName, sidebarClassName, footerClassName, summaryClassName }) {
47
+ function FormView(t0) {
48
+ const $ = c(46);
49
+ const { form, fields, layout: t1, locales, relationSource, uploadSource, checkSource, components, submitLabel, actions, onSubmitted, onReload, guardUnsavedChanges: t2, showSavedToast: t3, isLoading: t4, id, "aria-label": ariaLabel, className, layoutClassName, sidebarClassName, footerClassName, summaryClassName } = t0;
50
+ const layout = t1 === void 0 ? [] : t1;
51
+ const guardUnsavedChanges = t2 === void 0 ? true : t2;
52
+ const showSavedToast = t3 === void 0 ? true : t3;
53
+ const isLoading = t4 === void 0 ? false : t4;
46
54
  const intl = usePanneauIntl();
47
55
  const toasts = useToast();
48
56
  const { definition } = usePanneau();
@@ -56,15 +64,34 @@ function FormView({ form, fields, layout = [], locales, relationSource, uploadSo
56
64
  const leave = useLeaveConfirmation(guarded);
57
65
  useLeaveGuard(guarded, leave.confirmLeave);
58
66
  const resolved = resolveFields(fields, layout);
59
- const main = resolved.layout.filter((node) => node.type !== "sidebar");
60
- const sidebar = resolved.layout.filter((node_0) => node_0.type === "sidebar" && selectVisible(state, node_0));
61
- const order = [...getLayoutFieldNames(main), ...getLayoutFieldNames(sidebar.flatMap((node_1) => node_1.children ?? []))];
62
- const entries = {
63
- ...builtInFields,
64
- ...Object.fromEntries(plugins.fields),
65
- ...components
66
- };
67
- /** Opens the tab or section of a path, then scrolls to its field and focuses it. */
67
+ const main = resolved.layout.filter(_temp);
68
+ let t5;
69
+ if ($[0] !== state) {
70
+ t5 = (node_0) => node_0.type === "sidebar" && selectVisible(state, node_0);
71
+ $[0] = state;
72
+ $[1] = t5;
73
+ } else t5 = $[1];
74
+ const sidebar = resolved.layout.filter(t5);
75
+ const order = [...getLayoutFieldNames(main), ...getLayoutFieldNames(sidebar.flatMap(_temp2))];
76
+ let t6;
77
+ if ($[2] !== plugins.fields) {
78
+ t6 = Object.fromEntries(plugins.fields);
79
+ $[2] = plugins.fields;
80
+ $[3] = t6;
81
+ } else t6 = $[3];
82
+ const t7 = t6;
83
+ let t8;
84
+ if ($[4] !== components || $[5] !== t7) {
85
+ t8 = {
86
+ ...builtInFields,
87
+ ...t7,
88
+ ...components
89
+ };
90
+ $[4] = components;
91
+ $[5] = t7;
92
+ $[6] = t8;
93
+ } else t8 = $[6];
94
+ const entries = t8;
68
95
  const goTo = (path) => {
69
96
  registry.reveal(path);
70
97
  requestAnimationFrame(() => {
@@ -104,25 +131,156 @@ function FormView({ form, fields, layout = [], locales, relationSource, uploadSo
104
131
  return;
105
132
  }
106
133
  setResolving(true);
107
- try {
108
- handle(await form.resolveConflict(choice));
109
- } finally {
110
- setResolving(false);
111
- }
134
+ await form.resolveConflict(choice).then(handle).finally(() => setResolving(false));
112
135
  };
113
- const problem = state.status === "error" ? getProblem(state.error) : null;
136
+ let t9;
137
+ if ($[7] !== state.error || $[8] !== state.status) {
138
+ t9 = state.status === "error" ? getProblem(state.error) : null;
139
+ $[7] = state.error;
140
+ $[8] = state.status;
141
+ $[9] = t9;
142
+ } else t9 = $[9];
143
+ const problem = t9;
114
144
  const errorDetail = problem?.detail ?? (problem === null && state.error instanceof Error ? state.error.message : void 0);
115
145
  const showSummary = state.status === "invalid" && state.submitCount > 0;
146
+ if (isLoading) return /* @__PURE__ */ jsx(FormSkeleton, {
147
+ main,
148
+ sidebar: resolved.layout.filter(_temp3),
149
+ fields: resolved.fieldsByName,
150
+ footer: submitLabel !== null || actions !== void 0,
151
+ className,
152
+ layoutClassName,
153
+ sidebarClassName,
154
+ footerClassName
155
+ });
156
+ let t10;
157
+ if ($[10] !== definition?.locales || $[11] !== locales) {
158
+ t10 = locales ?? definition?.locales ?? [];
159
+ $[10] = definition?.locales;
160
+ $[11] = locales;
161
+ $[12] = t10;
162
+ } else t10 = $[12];
163
+ let t11;
164
+ if ($[13] !== relationSource) {
165
+ t11 = relationSource !== void 0 ? { relationSource } : {};
166
+ $[13] = relationSource;
167
+ $[14] = t11;
168
+ } else t11 = $[14];
169
+ let t12;
170
+ if ($[15] !== uploadSource) {
171
+ t12 = uploadSource !== void 0 ? { uploadSource } : {};
172
+ $[15] = uploadSource;
173
+ $[16] = t12;
174
+ } else t12 = $[16];
175
+ let t13;
176
+ if ($[17] !== checkSource) {
177
+ t13 = checkSource !== void 0 ? { checkSource } : {};
178
+ $[17] = checkSource;
179
+ $[18] = t13;
180
+ } else t13 = $[18];
181
+ let t14;
182
+ if ($[19] !== className) {
183
+ t14 = cx(Form_module_default.form, className);
184
+ $[19] = className;
185
+ $[20] = t14;
186
+ } else t14 = $[20];
187
+ let t15;
188
+ if ($[21] !== errorDetail || $[22] !== intl || $[23] !== state.status) {
189
+ t15 = state.status === "error" ? /* @__PURE__ */ jsx(Alert, {
190
+ tone: "danger",
191
+ role: "alert",
192
+ title: intl.formatMessage(messages.saveFailed),
193
+ actions: /* @__PURE__ */ jsx(Button, {
194
+ size: "sm",
195
+ type: "submit",
196
+ children: intl.formatMessage(messages.retry)
197
+ }),
198
+ children: errorDetail
199
+ }) : null;
200
+ $[21] = errorDetail;
201
+ $[22] = intl;
202
+ $[23] = state.status;
203
+ $[24] = t15;
204
+ } else t15 = $[24];
205
+ const t16 = sidebar.length > 0 && Form_module_default.withSidebar;
206
+ let t17;
207
+ if ($[25] !== layoutClassName || $[26] !== t16) {
208
+ t17 = cx(Form_module_default.layout, t16, layoutClassName);
209
+ $[25] = layoutClassName;
210
+ $[26] = t16;
211
+ $[27] = t17;
212
+ } else t17 = $[27];
213
+ let t18;
214
+ if ($[28] !== actions || $[29] !== footerClassName || $[30] !== intl || $[31] !== state.dirty || $[32] !== state.status || $[33] !== submitLabel) {
215
+ t18 = submitLabel !== null || actions !== void 0 ? /* @__PURE__ */ jsxs("div", {
216
+ className: cx(Form_module_default.footer, footerClassName),
217
+ children: [
218
+ state.dirty ? /* @__PURE__ */ jsx("span", {
219
+ className: Form_module_default.dirty,
220
+ role: "status",
221
+ children: intl.formatMessage(messages.unsaved)
222
+ }) : null,
223
+ actions,
224
+ submitLabel !== null ? /* @__PURE__ */ jsx(Button, {
225
+ type: "submit",
226
+ variant: "primary",
227
+ isPending: state.status === "submitting",
228
+ children: submitLabel ?? intl.formatMessage(messages.save)
229
+ }) : null
230
+ ]
231
+ }) : null;
232
+ $[28] = actions;
233
+ $[29] = footerClassName;
234
+ $[30] = intl;
235
+ $[31] = state.dirty;
236
+ $[32] = state.status;
237
+ $[33] = submitLabel;
238
+ $[34] = t18;
239
+ } else t18 = $[34];
240
+ const t19 = state.status === "conflict" || resolving;
241
+ const t20 = state.conflict?.current ?? null;
242
+ let t21;
243
+ let t22;
244
+ if ($[35] !== resolve) {
245
+ t21 = () => void resolve("reload");
246
+ t22 = () => void resolve("overwrite");
247
+ $[35] = resolve;
248
+ $[36] = t21;
249
+ $[37] = t22;
250
+ } else {
251
+ t21 = $[36];
252
+ t22 = $[37];
253
+ }
254
+ let t23;
255
+ if ($[38] !== resolved.fields || $[39] !== resolving || $[40] !== state.values || $[41] !== t19 || $[42] !== t20 || $[43] !== t21 || $[44] !== t22) {
256
+ t23 = /* @__PURE__ */ jsx(ConflictDialog, {
257
+ isOpen: t19,
258
+ fields: resolved.fields,
259
+ values: state.values,
260
+ current: t20,
261
+ isPending: resolving,
262
+ onReload: t21,
263
+ onOverwrite: t22
264
+ });
265
+ $[38] = resolved.fields;
266
+ $[39] = resolving;
267
+ $[40] = state.values;
268
+ $[41] = t19;
269
+ $[42] = t20;
270
+ $[43] = t21;
271
+ $[44] = t22;
272
+ $[45] = t23;
273
+ } else t23 = $[45];
116
274
  return /* @__PURE__ */ jsx(FormContext, {
117
275
  value: form,
118
276
  children: /* @__PURE__ */ jsx(RevealContext, {
119
277
  value: registry,
120
278
  children: /* @__PURE__ */ jsxs(FieldsProvider, {
121
279
  components: entries,
122
- locales: locales ?? definition?.locales ?? [],
123
- ...relationSource !== void 0 ? { relationSource } : {},
124
- ...uploadSource !== void 0 ? { uploadSource } : {},
125
- ...checkSource !== void 0 ? { checkSource } : {},
280
+ locales: t10,
281
+ ...t11,
282
+ ...t12,
283
+ ...t13,
126
284
  binding: FormBinding,
127
285
  children: [
128
286
  /* @__PURE__ */ jsxs("form", {
@@ -130,7 +288,7 @@ function FormView({ form, fields, layout = [], locales, relationSource, uploadSo
130
288
  id,
131
289
  "aria-label": ariaLabel,
132
290
  noValidate: true,
133
- className: cx(Form_module_default.form, className),
291
+ className: t14,
134
292
  onSubmit: (event) => {
135
293
  event.preventDefault();
136
294
  form.submit().then(handle);
@@ -142,19 +300,9 @@ function FormView({ form, fields, layout = [], locales, relationSource, uploadSo
142
300
  onSelect: goTo,
143
301
  ...summaryClassName !== void 0 ? { className: summaryClassName } : {}
144
302
  }) : null,
145
- state.status === "error" ? /* @__PURE__ */ jsx(Alert, {
146
- tone: "danger",
147
- role: "alert",
148
- title: intl.formatMessage(messages.saveFailed),
149
- actions: /* @__PURE__ */ jsx(Button, {
150
- size: "sm",
151
- type: "submit",
152
- children: intl.formatMessage(messages.retry)
153
- }),
154
- children: errorDetail
155
- }) : null,
303
+ t15,
156
304
  /* @__PURE__ */ jsxs("div", {
157
- className: cx(Form_module_default.layout, sidebar.length > 0 && Form_module_default.withSidebar, layoutClassName),
305
+ className: t17,
158
306
  children: [/* @__PURE__ */ jsx("div", {
159
307
  className: Form_module_default.stack,
160
308
  children: /* @__PURE__ */ jsx(LayoutNodes, {
@@ -163,49 +311,34 @@ function FormView({ form, fields, layout = [], locales, relationSource, uploadSo
163
311
  })
164
312
  }), sidebar.length > 0 ? /* @__PURE__ */ jsx("aside", {
165
313
  className: cx(Form_module_default.sidebar, sidebarClassName),
166
- children: sidebar.map((node_2, index) => /* @__PURE__ */ jsx("div", {
314
+ children: sidebar.map((node_3, index) => /* @__PURE__ */ jsx("div", {
167
315
  className: Form_module_default.stack,
168
316
  children: /* @__PURE__ */ jsx(LayoutNodes, {
169
- nodes: node_2.children ?? [],
317
+ nodes: node_3.children ?? [],
170
318
  fields: resolved.fieldsByName
171
319
  })
172
320
  }, index))
173
321
  }) : null]
174
322
  }),
175
- submitLabel !== null || actions !== void 0 ? /* @__PURE__ */ jsxs("div", {
176
- className: cx(Form_module_default.footer, footerClassName),
177
- children: [
178
- state.dirty ? /* @__PURE__ */ jsx("span", {
179
- className: Form_module_default.dirty,
180
- role: "status",
181
- children: intl.formatMessage(messages.unsaved)
182
- }) : null,
183
- actions,
184
- submitLabel !== null ? /* @__PURE__ */ jsx(Button, {
185
- type: "submit",
186
- variant: "primary",
187
- isPending: state.status === "submitting",
188
- children: submitLabel ?? intl.formatMessage(messages.save)
189
- }) : null
190
- ]
191
- }) : null
323
+ t18
192
324
  ]
193
325
  }),
194
- /* @__PURE__ */ jsx(ConflictDialog, {
195
- isOpen: state.status === "conflict" || resolving,
196
- fields: resolved.fields,
197
- values: state.values,
198
- current: state.conflict?.current ?? null,
199
- isPending: resolving,
200
- onReload: () => void resolve("reload"),
201
- onOverwrite: () => void resolve("overwrite")
202
- }),
326
+ t23,
203
327
  leave.dialog
204
328
  ]
205
329
  })
206
330
  })
207
331
  });
208
332
  }
333
+ function _temp3(node_2) {
334
+ return node_2.type === "sidebar";
335
+ }
336
+ function _temp2(node_1) {
337
+ return node_1.children ?? [];
338
+ }
339
+ function _temp(node) {
340
+ return node.type !== "sidebar";
341
+ }
209
342
  //#endregion
210
343
  export { FormView };
211
344
 
@@ -1 +1 @@
1
- {"version":3,"file":"FormView.js","names":["node","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 { FormContext, RevealContext, createRevealRegistry, useFormState } from './context';\nimport { cx } from './cx';\nimport { 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 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 (`blocks.2.body` before `blocks.10.body`).\n */\nfunction orderErrors(\n names: readonly string[],\n errors: Record<string, 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 compare = (a: string, b: string) =>\n rank(a) - rank(b) || a.localeCompare(b, undefined, { numeric: true });\n return Object.fromEntries(Object.entries(errors).sort(([a], [b]) => compare(a, b)));\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 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 const resolved = resolveFields(fields, layout);\n const main = resolved.layout.filter((node) => node.type !== 'sidebar');\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 or section 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 or section to open before scrolling.\n requestAnimationFrame(() => {\n const element = root.current !== null ? findFieldElement(root.current, path) : null;\n if (element === null) {\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 };\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))[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 try {\n handle(await form.resolveConflict(choice));\n } finally {\n setResolving(false);\n }\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 return (\n <FormContext value={form}>\n <RevealContext value={registry}>\n <FieldsProvider\n components={entries}\n locales={locales ?? definition?.locales ?? []}\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)}\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={main} fields={resolved.fieldsByName} />\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":";;;;;;;;;;;;;;;AAqFA,IAAM,YACF;;AAGJ,SAAS,iBAAiB,MAAmB,MAAkC;CAC3E,IAAI,UAAU;CACd,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MAAM;MACd,SAAS,MAAM,UAAU,WAAW;MACpC,WAAW;MACX,gBAAgB,KAAK,QAAQ,QAAQ;MACrC,mBAAmB,KAAK,QAAQ,WAAW;KAAE,CAAA;KAEhD,MAAM;IACK;;EACL,CAAA;CACN,CAAA;AAErB"}
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","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","compare","a","b","localeCompare","undefined","numeric","Object","fromEntries","entries","sort","FormView","t0","$","_c","t1","t2","t3","t4","ariaLabel","intl","toasts","definition","plugins","state","registry","resolving","setResolving","guarded","dirty","leave","confirmLeave","resolved","main","filter","_temp","t5","node_0","node","type","sidebar","order","flatMap","_temp2","t6","t7","t8","goTo","reveal","requestAnimationFrame","reduced","window","matchMedia","matches","scrollIntoView","block","behavior","target","focus","preventScroll","handle","status","first","keys","show","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","t16","withSidebar","t17","t18","footer","unsaved","save","t19","t20","t21","t22","t23","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 { 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 (`blocks.2.body` before `blocks.10.body`).\n */\nfunction orderErrors(\n names: readonly string[],\n errors: Record<string, 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 compare = (a: string, b: string) =>\n rank(a) - rank(b) || a.localeCompare(b, undefined, { numeric: true });\n return Object.fromEntries(Object.entries(errors).sort(([a], [b]) => compare(a, b)));\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 const resolved = resolveFields(fields, layout);\n const main = resolved.layout.filter((node) => node.type !== 'sidebar');\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 or section 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 or section to open before scrolling.\n requestAnimationFrame(() => {\n const element = root.current !== null ? findFieldElement(root.current, path) : null;\n if (element === null) {\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 };\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))[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={main}\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={locales ?? definition?.locales ?? []}\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)}\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={main} fields={resolved.fieldsByName} />\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,IAAM+D,YACF;;AAGJ,SAASC,iBAAiBC,MAAmBE,MAAkC;CAC3E,IAAIC,UAAUD;CACd,OAAOC,YAAY,IAAI;EACnB,MAAMC,UAAUJ,KAAKK,cACjB,uBAAuBC,IAAIC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C,CAAA,IAPf;OAUAuH;OAcD,qBAAA,OAAA;QACe,WAAAG;QADf,UAAA,CAOI,oBAAA,OAAA;SAAgB,WAAA9J,oBAAM2K;SAClB,UAAA,oBAAC,aAAD;UAAoBjF,OAAAA;UAAc,QAAAD,SAAQ4D;SAAa,CAAA;QACrD,CAAA,GACLpD,QAAOxC,SAAU,IACd,oBAAA,SAAA;SAAkB,WAAAlD,GAAGP,oBAAMiG,SAAU/D,gBAAgB;SAChD+D,UAAAA,QAAO2E,KAAKC,QAAAvH,UACT,oBAAA,OAAA;UAA4B,WAAAtD,oBAAM2K;UAC9B,UAAA,oBAAC,aAAD;WACW,OAAA5E,OAAI+E,YAAJ,CAAA;WACC,QAAArF,SAAQ4D;UAAa,CAAA;SAE/B,GALI/F,KAKJ,CACT;QACG,CAAA,IAVX,IAYC;;OACLyG;MAmBE;;KACPQ;KASChF,MAAKwF;IA/FK;;EADL,CAAA;CADN,CAAA;AAoGE;AA1Of,SAAA3B,OAAA4B,QAAA;CAAA,OA0HmDjF,OAAIC,SAAU;AAAS;AA1H1E,SAAAI,OAAA6E,QAAA;CAAA,OA6CkDlF,OAAI+E,YAAJ,CAAA;AAAmB;AA7CrE,SAAAlF,MAAAG,MAAA;CAAA,OAuC2CA,KAAIC,SAAU;AAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":[],"sources":["../src/context.ts"],"sourcesContent":["import { createContext, use, useSyncExternalStore } from 'react';\n\nimport type { Form, FormState } from '@panneau/core';\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/** Opens the containers (tabs, sections) that hold a path, so that its field can be reached. */\nexport type Revealer = (path: string) => void;\n\nexport interface RevealRegistry {\n add(revealer: Revealer): () => void;\n reveal(path: string): void;\n}\n\nexport function createRevealRegistry(): RevealRegistry {\n const revealers = new Set<Revealer>();\n return {\n add(revealer) {\n revealers.add(revealer);\n return () => {\n revealers.delete(revealer);\n };\n },\n reveal(path) {\n revealers.forEach((revealer) => revealer(path));\n },\n };\n}\n\nexport const RevealContext = createContext<RevealRegistry>(createRevealRegistry());\n"],"mappings":";;AAIA,IAAa,cAAc,cAA2B,IAAI;;AAG1D,SAAgB,iBAAuB;CACnC,MAAM,OAAO,IAAI,WAAW;CAC5B,IAAI,SAAS,MACT,MAAM,IAAI,MAAM,kEAAkE;CAEtF,OAAO;AACX;;AAGA,SAAO,aAAA,MAAA;CAAA,OACI,qBAAqB,KAAI,WAAY,KAAI,UAAW,KAAI,QAAS;AAAC;AAW7E,SAAgB,uBAAuC;CACnD,MAAM,4BAAY,IAAI,IAAc;CACpC,OAAO;EACH,IAAI,UAAU;GACV,UAAU,IAAI,QAAQ;GACtB,aAAa;IACT,UAAU,OAAO,QAAQ;GAC7B;EACJ;EACA,OAAO,MAAM;GACT,UAAU,SAAS,aAAa,SAAS,IAAI,CAAC;EAClD;CACJ;AACJ;AAEA,IAAa,gBAAgB,cAA8B,qBAAqB,CAAC"}
1
+ {"version":3,"file":"context.js","names":["createContext","use","useSyncExternalStore","Form","FormState","FormContext","useFormContext","form","Error","useFormState","subscribe","getState","Revealer","path","RevealRegistry","add","revealer","reveal","createRevealRegistry","revealers","Set","delete","forEach","RevealContext"],"sources":["../src/context.ts"],"sourcesContent":["import { createContext, use, useSyncExternalStore } from 'react';\n\nimport type { Form, FormState } from '@panneau/core';\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/** Opens the containers (tabs, sections) that hold a path, so that its field can be reached. */\nexport type Revealer = (path: string) => void;\n\nexport interface RevealRegistry {\n add(revealer: Revealer): () => void;\n reveal(path: string): void;\n}\n\nexport function createRevealRegistry(): RevealRegistry {\n const revealers = new Set<Revealer>();\n return {\n add(revealer) {\n revealers.add(revealer);\n return () => {\n revealers.delete(revealer);\n };\n },\n reveal(path) {\n revealers.forEach((revealer) => revealer(path));\n },\n };\n}\n\nexport const RevealContext = createContext<RevealRegistry>(createRevealRegistry());\n"],"mappings":";;AAIA,IAAaK,cAAcL,cAA2B,IAAI;;AAG1D,SAAgBM,iBAAuB;CACnC,MAAMC,OAAON,IAAII,WAAW;CAC5B,IAAIE,SAAS,MACT,MAAM,IAAIC,MAAM,kEAAkE;CAEtF,OAAOD;AACX;;AAGA,SAAOE,aAAAF,MAAA;CAAA,OACIL,qBAAqBK,KAAIG,WAAYH,KAAII,UAAWJ,KAAII,QAAS;AAAC;AAW7E,SAAgBO,uBAAuC;CACnD,MAAMC,4BAAY,IAAIC,IAAc;CACpC,OAAO;EACHL,IAAIC,UAAU;GACVG,UAAUJ,IAAIC,QAAQ;GACtB,aAAa;IACTG,UAAUE,OAAOL,QAAQ;GAC7B;EACJ;EACAC,OAAOJ,MAAM;GACTM,UAAUG,SAASN,aAAaA,SAASH,IAAI,CAAC;EAClD;CACJ;AACJ;AAEA,IAAaU,gBAAgBvB,cAA8BkB,qBAAqB,CAAC"}
package/dist/cx.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cx.js","names":[],"sources":["../src/cx.ts"],"sourcesContent":["/** Joins class names, skipping empty ones. */\nexport function cx(...classNames: (string | false | null | undefined)[]): string {\n return classNames.filter(Boolean).join(' ');\n}\n"],"mappings":";;AACA,SAAgB,GAAG,GAAG,YAA2D;CAC7E,OAAO,WAAW,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AAC9C"}
1
+ {"version":3,"file":"cx.js","names":["cx","classNames","filter","Boolean","join"],"sources":["../src/cx.ts"],"sourcesContent":["/** Joins class names, skipping empty ones. */\nexport function cx(...classNames: (string | false | null | undefined)[]): string {\n return classNames.filter(Boolean).join(' ');\n}\n"],"mappings":";;AACA,SAAgBA,GAAG,GAAGC,YAA2D;CAC7E,OAAOA,WAAWC,OAAOC,OAAO,CAAC,CAACC,KAAK,GAAG;AAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"describe.js","names":[],"sources":["../src/describe.ts"],"sourcesContent":["import type { Field } from '@panneau/protocol';\n\nimport { getPathSteps } from './paths';\n\n/**\n * A readable name for the value at a path, from the labels of its fields: `Blocks › 3 › Body`,\n * `Title (fr)`. Unknown paths are returned as is.\n */\nexport function describePath(fields: readonly Field[], path: string): string {\n const steps = getPathSteps(fields, path);\n if (steps.length === 0) {\n return path;\n }\n return steps\n .map((step) => {\n const label = step.field.label ?? step.field.name;\n const locale = step.locale !== undefined ? ` (${step.locale})` : '';\n const index = step.index !== undefined ? ` › ${step.index + 1}` : '';\n return `${label}${locale}${index}`;\n })\n .join(' › ');\n}\n"],"mappings":";;;;;;AAQA,SAAgB,aAAa,QAA0B,MAAsB;CACzE,MAAM,QAAQ,aAAa,QAAQ,IAAI;CACvC,IAAI,MAAM,WAAW,GACjB,OAAO;CAEX,OAAO,MACF,KAAK,SAAS;EAIX,OAAO,GAHO,KAAK,MAAM,SAAS,KAAK,MAAM,OAC9B,KAAK,WAAW,KAAA,IAAY,KAAK,KAAK,OAAM,KAAM,KACnD,KAAK,UAAU,KAAA,IAAY,MAAM,KAAK,QAAQ,MAAM;CAEtE,CAAC,CAAC,CACD,KAAK,KAAK;AACnB"}
1
+ {"version":3,"file":"describe.js","names":["Field","getPathSteps","describePath","fields","path","steps","length","map","step","label","field","name","locale","undefined","index","join"],"sources":["../src/describe.ts"],"sourcesContent":["import type { Field } from '@panneau/protocol';\n\nimport { getPathSteps } from './paths';\n\n/**\n * A readable name for the value at a path, from the labels of its fields: `Blocks › 3 › Body`,\n * `Title (fr)`. Unknown paths are returned as is.\n */\nexport function describePath(fields: readonly Field[], path: string): string {\n const steps = getPathSteps(fields, path);\n if (steps.length === 0) {\n return path;\n }\n return steps\n .map((step) => {\n const label = step.field.label ?? step.field.name;\n const locale = step.locale !== undefined ? ` (${step.locale})` : '';\n const index = step.index !== undefined ? ` › ${step.index + 1}` : '';\n return `${label}${locale}${index}`;\n })\n .join(' › ');\n}\n"],"mappings":";;;;;;AAQA,SAAgBE,aAAaC,QAA0BC,MAAsB;CACzE,MAAMC,QAAQJ,aAAaE,QAAQC,IAAI;CACvC,IAAIC,MAAMC,WAAW,GACjB,OAAOF;CAEX,OAAOC,MACFE,KAAKC,SAAS;EAIX,OAAO,GAHOA,KAAKE,MAAMD,SAASD,KAAKE,MAAMC,OAC9BH,KAAKI,WAAWC,KAAAA,IAAY,KAAKL,KAAKI,OAAM,KAAM,KACnDJ,KAAKM,UAAUD,KAAAA,IAAY,MAAML,KAAKM,QAAQ,MAAM;CAEtE,CAAC,CAAC,CACDC,KAAK,KAAK;AACnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"formatError.js","names":["_c"],"sources":["../src/formatError.ts"],"sourcesContent":["import type { Field, RuleFailure } from '@panneau/protocol';\nimport { usePanneauIntl } from '@panneau/ui';\n\nimport { messages } from './messages';\nimport { getPathSteps } from './paths';\n\nconst COUNTED = new Set(['repeater', 'relation', 'media', 'select']);\n\n/**\n * Translates the failures of the portable rules with react-intl, for `formatError`. `min` and\n * `max` say \"characters\" for texts and \"items\" for lists, from the field at the path, and `crop`\n * names its ratios. A rule's own `message` wins.\n */\nexport function useFormatRuleFailure(\n fields: readonly Field[],\n): (failure: RuleFailure, path: string) => string {\n const intl = usePanneauIntl();\n return (failure, path) => {\n if (failure.message !== undefined) {\n return failure.message;\n }\n const step = getPathSteps(fields, path).at(-1);\n const field = step?.field;\n const value = typeof failure.value === 'number' ? failure.value : 0;\n if (failure.rule === 'min' || failure.rule === 'max') {\n const list =\n field !== undefined &&\n step?.index === undefined &&\n COUNTED.has(field.type) &&\n (field.type === 'repeater' || field.multiple === true);\n const numeric = field?.type === 'number';\n const key = list\n ? failure.rule === 'min'\n ? 'minItems'\n : 'maxItems'\n : numeric\n ? failure.rule\n : failure.rule === 'min'\n ? 'minLength'\n : 'maxLength';\n return intl.formatMessage(messages.rule[key], { value });\n }\n if (failure.rule === 'crop') {\n const given =\n typeof failure.value === 'object' && failure.value !== null\n ? (failure.value as { ratios?: unknown }).ratios\n : undefined;\n const ratios = Array.isArray(given)\n ? given.filter((ratio): ratio is string => typeof ratio === 'string')\n : [];\n return ratios.length > 0\n ? intl.formatMessage(messages.rule.cropRatios, {\n ratios: intl.formatList(ratios, { type: 'disjunction' }),\n })\n : intl.formatMessage(messages.rule.crop);\n }\n const rule = failure.rule as keyof typeof messages.rule;\n if (rule in messages.rule && rule !== 'min' && rule !== 'max') {\n return intl.formatMessage(\n messages.rule[\n rule as Exclude<\n typeof rule,\n | 'min'\n | 'max'\n | 'minLength'\n | 'maxLength'\n | 'minItems'\n | 'maxItems'\n | 'cropRatios'\n >\n ],\n );\n }\n return intl.formatMessage(messages.rule.invalid);\n };\n}\n"],"mappings":";;;;;AAMA,IAAM,0BAAU,IAAI,IAAI;CAAC;CAAY;CAAY;CAAS;AAAQ,CAAC;;;;;;AAOnE,SAAO,qBAAA,QAAA;CAAA,MAAA,IAAAA,EAAA,CAAA;CAGH,MAAA,OAAa,eAAe;CAAE,IAAA;CAAA,IAAA,EAAA,OAAA,UAAA,EAAA,OAAA,MAAA;EACvB,MAAA,SAAA,SAAA;GACH,IAAI,QAAO,YAAa,KAAA,GAAS,OACtB,QAAO;GAElB,MAAA,OAAa,aAAa,QAAQ,IAAI,CAAC,CAAA,GAAI,EAAE;GAC7C,MAAA,QAAc,MAAI;GAClB,MAAA,QAAc,OAAO,QAAO,UAAW,WAAW,QAAO,QAA3C;GACd,IAAI,QAAO,SAAU,SAAS,QAAO,SAAU,OAAK;IAChD,MAAA,OACI,UAAU,KAAA,KACV,MAAI,UAAY,KAAA,KAChB,QAAO,IAAK,MAAK,IAAK,MACrB,MAAK,SAAU,cAAc,MAAK,aAAc;IACrD,MAAA,UAAgB,OAAK,SAAW;IAChC,MAAA,MAAY,OACN,QAAO,SAAU,QAAjB,aAAA,aAGA,UACE,QAAO,OACP,QAAO,SAAU,QAAjB,cAAA;IAEc,OACf,KAAI,cAAe,SAAQ,KAAM,MAAM,EAAA,MAAQ,CAAC;GAAC;GAE5D,IAAI,QAAO,SAAU,QAAM;IACvB,MAAA,QACI,OAAO,QAAO,UAAW,YAAY,QAAO,UAAW,OAChD,QAAO,MAA8B,SAD5C,KAAA;IAGJ,MAAA,SAAe,MAAK,QAAS,KAEtB,IADD,MAAK,OAAQ,KACZ,IAFQ,CAAA;IAEN,OACF,OAAM,SAAU,IACjB,KAAI,cAAe,SAAQ,KAAK,YAAa,EAAA,QACjC,KAAI,WAAY,QAAQ,EAAA,MAAQ,cAAc,CAAC,EAC3D,CACqC,IAArC,KAAI,cAAe,SAAQ,KAAK,IAAK;GAAC;GAEhD,MAAA,OAAa,QAAO;GACpB,IAAI,QAAQ,SAAQ,QAAS,SAAS,SAAS,SAAS,OAAK,OAClD,KAAI,cACP,SAAQ,KACJ,KAWR;GACH,OACM,KAAI,cAAe,SAAQ,KAAK,OAAQ;EAAC;EACnD,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,OAzDM;AAyDN;AA7DE,SAAA,MAAA,OAAA;CAAA,OAmCoD,OAAO,UAAU;AAAQ"}
1
+ {"version":3,"file":"formatError.js","names":["Field","RuleFailure","usePanneauIntl","messages","getPathSteps","COUNTED","Set","useFormatRuleFailure","fields","$","_c","intl","t0","failure","path","message","undefined","step","at","field","value","rule","list","index","has","type","multiple","numeric","key","formatMessage","given","ratios","Array","isArray","filter","_temp","length","cropRatios","formatList","crop","Exclude","invalid","ratio","_c"],"sources":["../src/formatError.ts"],"sourcesContent":["import type { Field, RuleFailure } from '@panneau/protocol';\nimport { usePanneauIntl } from '@panneau/ui';\n\nimport { messages } from './messages';\nimport { getPathSteps } from './paths';\n\nconst COUNTED = new Set(['repeater', 'relation', 'media', 'select']);\n\n/**\n * Translates the failures of the portable rules with react-intl, for `formatError`. `min` and\n * `max` say \"characters\" for texts and \"items\" for lists, from the field at the path, and `crop`\n * names its ratios. A rule's own `message` wins.\n */\nexport function useFormatRuleFailure(\n fields: readonly Field[],\n): (failure: RuleFailure, path: string) => string {\n const intl = usePanneauIntl();\n return (failure, path) => {\n if (failure.message !== undefined) {\n return failure.message;\n }\n const step = getPathSteps(fields, path).at(-1);\n const field = step?.field;\n const value = typeof failure.value === 'number' ? failure.value : 0;\n if (failure.rule === 'min' || failure.rule === 'max') {\n const list =\n field !== undefined &&\n step?.index === undefined &&\n COUNTED.has(field.type) &&\n (field.type === 'repeater' || field.multiple === true);\n const numeric = field?.type === 'number';\n const key = list\n ? failure.rule === 'min'\n ? 'minItems'\n : 'maxItems'\n : numeric\n ? failure.rule\n : failure.rule === 'min'\n ? 'minLength'\n : 'maxLength';\n return intl.formatMessage(messages.rule[key], { value });\n }\n if (failure.rule === 'crop') {\n const given =\n typeof failure.value === 'object' && failure.value !== null\n ? (failure.value as { ratios?: unknown }).ratios\n : undefined;\n const ratios = Array.isArray(given)\n ? given.filter((ratio): ratio is string => typeof ratio === 'string')\n : [];\n return ratios.length > 0\n ? intl.formatMessage(messages.rule.cropRatios, {\n ratios: intl.formatList(ratios, { type: 'disjunction' }),\n })\n : intl.formatMessage(messages.rule.crop);\n }\n const rule = failure.rule as keyof typeof messages.rule;\n if (rule in messages.rule && rule !== 'min' && rule !== 'max') {\n return intl.formatMessage(\n messages.rule[\n rule as Exclude<\n typeof rule,\n | 'min'\n | 'max'\n | 'minLength'\n | 'maxLength'\n | 'minItems'\n | 'maxItems'\n | 'cropRatios'\n >\n ],\n );\n }\n return intl.formatMessage(messages.rule.invalid);\n };\n}\n"],"mappings":";;;;;AAMA,I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3D,CACqC,IAArCd,KAAIkB,cAAe1B,SAAQkB,KAAKkB,IAAK;GAAC;GAEhD,MAAAlB,OAAaR,QAAOQ;GACpB,IAAIA,QAAQlB,SAAQkB,QAASA,SAAS,SAASA,SAAS,OAAK,OAClDV,KAAIkB,cACP1B,SAAQkB,KACJA,KAWR;GACH,OACMV,KAAIkB,cAAe1B,SAAQkB,KAAKoB,OAAQ;EAAC;EACnDhC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,OAzDMG;AAyDN;AA7DE,SAAAuB,MAAAO,OAAA;CAAA,OAmCoD,OAAOA,UAAU;AAAQ"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export { ConflictDialog, type ConflictDialogProps } from './ConflictDialog';
2
- export { describePath } from './describe';
3
- export { ErrorSummary, type ErrorSummaryProps } from './ErrorSummary';
4
- export { Form, type FormProps } from './Form';
5
- export { FormBinding } from './FormBinding';
6
- export { FormView, type FormViewProps } from './FormView';
7
- export { useFormContext, useFormState } from './context';
8
- export { useFormatRuleFailure } from './formatError';
9
- export { type LeaveConfirmation, useBeforeUnloadGuard, useLeaveConfirmation } from './unsaved';
1
+ export { ConflictDialog, type ConflictDialogProps } from './ConflictDialog.js';
2
+ export { describePath } from './describe.js';
3
+ export { ErrorSummary, type ErrorSummaryProps } from './ErrorSummary.js';
4
+ export { Form, type FormProps } from './Form.js';
5
+ export { FormBinding } from './FormBinding.js';
6
+ export { FormView, type FormViewProps } from './FormView.js';
7
+ export { useFormContext, useFormState } from './context.js';
8
+ export { useFormatRuleFailure } from './formatError.js';
9
+ export { type LeaveConfirmation, useBeforeUnloadGuard, useLeaveConfirmation } from './unsaved.js';
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Layout.js","names":["count","index","tab","fields","selected","form","names","content","expanded","setExpanded","titleId","field","child","node","_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 } 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 { 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"],"mappings":";;;;;;;;;;;AA+BA,SAAS,aAAa,OAA0B,MAAuB;CACnE,MAAM,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC;CAC7B,OAAO,SAAS,KAAA,KAAa,MAAM,SAAS,IAAI;AACpD;AAEA,SAAA,WAAA,IAAA;CAAA,MAAA,IAAAc,EAAA,CAAA;CAAoB,MAAA,EAAA,MAAA,UAAA;CAChB,MAAA,OAAa,eAAe;CAC5B,MAAA,QAAc,iBAAiB,aAAa,IAAI,GAAG,KAAK;CACxD,IAAI,UAAU,GAAC,OACJ;CAGN,MAAA,KAAA;CAAW,MAAA,KAAA;CAAgB,MAAA,KAAA,KAAI,cAAe,SAAQ,YAAa,EAAA,MAAQ,CAAC;CAAC,IAAA;CAAA,IAAA,EAAA,OAAA,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A,IAAA;GAAA,IAAA,EAAA,QAAA,UAAA,EAAA,QAAA,IAAA;IAD3C,KAAA,oBAAA,OAAA;KAAgB,WAAAA,oBAAM;KAClB,UAAA,oBAAC,aAAD;MAAoB,OAAA;MAA6B;KAAM,CAAA;IACrD,CAAA;IAAA,EAAA,MAAA;IAAA,EAAA,MAAA;IAAA,EAAA,MAAA;GAAA,OAAA,KAAA,EAAA;GAAA,OAFN;EAEM;CAElB;AAAC;;AAIL,SAAgB,YAAY,EAAE,OAAO,UAAkC;CACnE,OAAO,MAAM,KAAK,MAAM,UAAU,oBAAC,gBAAD;EAAkC;EAAc;CAAO,GAAlC,KAAkC,CAAG;AAChG"}
1
+ {"version":3,"file":"Layout.js","names":["CSSProperties","ReactNode","createElement","use","useEffect","useId","useState","Form","getLayoutFieldNames","selectErrorCount","selectVisible","usePlugins","NestedField","Field","LayoutNode","Badge","Disclosure","Tab","TabList","TabPanel","Tabs","usePanneauIntl","styles","RevealContext","useFormContext","useFormState","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","_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 } 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 { 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"],"mappings":";;;;;;;;;;;AA+BA,SAAS+B,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,OAAatB,eAAe;CAC5B,MAAAuB,QAAcnC,iBAAiBgB,aAAaiB,IAAI,GAAGV,KAAK;CACxD,IAAIY,UAAU,GAAC,OACJ;CAGN,MAAAC,KAAA9B;CAAW,MAAA+B,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,E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W,EAAA,MAAAX;IAAAW,EAAA,MAAAM;IAAAN,EAAA,MAAAO;GAAA,OAAAA,KAAAP,EAAA;GAAA,OAFNO;EAEM;CAElB;AAAC;;AAIL,SAAgBsE,YAAY,EAAEzF,OAAOC,UAAkC;CACnE,OAAOD,MAAMiC,KAAKT,MAAMc,UAAU,oBAAC,gBAAD;EAAkCd;EAAcvB;CAAO,GAAlCqC,KAAkC,CAAG;AAChG"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["allFr"],"sources":["../../src/locales/index.ts"],"sourcesContent":["import { fr as allFr, getDefaultMessages } from '@panneau/intl';\n\nimport { messages } from '../messages';\n\n/**\n * The English messages of `@panneau/forms`, by id. They are also the default messages.\n *\n * @deprecated Use `en`, or `withPanneauMessages()`, from `@panneau/intl`: they have the messages\n * of every package.\n */\nexport const en: Record<string, string> = getDefaultMessages(messages);\n\n/**\n * The French messages of `@panneau/forms`, by id.\n *\n * @deprecated Use `fr`, or `withPanneauMessages()`, from `@panneau/intl`: they have the messages\n * of every package.\n */\nexport const fr: Record<string, string> = Object.fromEntries(\n Object.entries(allFr).filter(([id]) => id in en),\n);\n"],"mappings":";;;;;;;;;AAUA,IAAa,KAA6B,mBAAmB,QAAQ;;;;;;;AAQrE,IAAa,KAA6B,OAAO,YAC7C,OAAO,QAAQA,IAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,MAAM,EAAE,CACnD"}
1
+ {"version":3,"file":"index.js","names":["fr","allFr","getDefaultMessages","messages","en","Record","Object","fromEntries","entries","filter","id","allFr"],"sources":["../../src/locales/index.ts"],"sourcesContent":["import { fr as allFr, getDefaultMessages } from '@panneau/intl';\n\nimport { messages } from '../messages';\n\n/**\n * The English messages of `@panneau/forms`, by id. They are also the default messages.\n *\n * @deprecated Use `en`, or `withPanneauMessages()`, from `@panneau/intl`: they have the messages\n * of every package.\n */\nexport const en: Record<string, string> = getDefaultMessages(messages);\n\n/**\n * The French messages of `@panneau/forms`, by id.\n *\n * @deprecated Use `fr`, or `withPanneauMessages()`, from `@panneau/intl`: they have the messages\n * of every package.\n */\nexport const fr: Record<string, string> = Object.fromEntries(\n Object.entries(allFr).filter(([id]) => id in en),\n);\n"],"mappings":";;;;;;;;;AAUA,IAAaI,KAA6BF,mBAAmBC,QAAQ;;;;;;;AAQrE,IAAaH,KAA6BM,OAAOC,YAC7CD,OAAOE,QAAQP,IAAK,CAAC,CAACQ,QAAQ,CAACC,QAAQA,MAAMN,EAAE,CACnD"}