@panneau/forms 5.0.0-alpha.4 → 5.0.0-alpha.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +12 -10
  2. package/dist/ConflictDialog.js +200 -63
  3. package/dist/ConflictDialog.js.map +1 -1
  4. package/dist/ErrorSummary.js.map +1 -1
  5. package/dist/FieldErrorBoundary.js.map +1 -1
  6. package/dist/Form.css +98 -23
  7. package/dist/Form.d.ts +3 -2
  8. package/dist/Form.d.ts.map +1 -1
  9. package/dist/Form.js +122 -21
  10. package/dist/Form.js.map +1 -1
  11. package/dist/Form.module.js +29 -10
  12. package/dist/Form.module.js.map +1 -1
  13. package/dist/FormBinding.d.ts.map +1 -1
  14. package/dist/FormBinding.js +78 -67
  15. package/dist/FormBinding.js.map +1 -1
  16. package/dist/FormSkeleton.d.ts +23 -0
  17. package/dist/FormSkeleton.d.ts.map +1 -0
  18. package/dist/FormSkeleton.js +435 -0
  19. package/dist/FormSkeleton.js.map +1 -0
  20. package/dist/FormView.d.ts +43 -4
  21. package/dist/FormView.d.ts.map +1 -1
  22. package/dist/FormView.js +335 -121
  23. package/dist/FormView.js.map +1 -1
  24. package/dist/context.d.ts +8 -8
  25. package/dist/context.d.ts.map +1 -1
  26. package/dist/context.js +8 -16
  27. package/dist/context.js.map +1 -1
  28. package/dist/cx.js.map +1 -1
  29. package/dist/describe.js.map +1 -1
  30. package/dist/formatError.d.ts +2 -2
  31. package/dist/formatError.d.ts.map +1 -1
  32. package/dist/formatError.js +31 -5
  33. package/dist/formatError.js.map +1 -1
  34. package/dist/index.d.ts +11 -9
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/layout/Layout.d.ts +28 -0
  37. package/dist/layout/Layout.d.ts.map +1 -1
  38. package/dist/layout/Layout.js +331 -89
  39. package/dist/layout/Layout.js.map +1 -1
  40. package/dist/locales/index.js.map +1 -1
  41. package/dist/panels/SaveControls.d.ts +27 -0
  42. package/dist/panels/SaveControls.d.ts.map +1 -0
  43. package/dist/panels/SaveControls.js +90 -0
  44. package/dist/panels/SaveControls.js.map +1 -0
  45. package/dist/panels/panels.d.ts +34 -0
  46. package/dist/panels/panels.d.ts.map +1 -0
  47. package/dist/panels/panels.js +61 -0
  48. package/dist/panels/panels.js.map +1 -0
  49. package/dist/paths.d.ts.map +1 -1
  50. package/dist/paths.js +2 -1
  51. package/dist/paths.js.map +1 -1
  52. package/dist/publication/Publication.d.ts +57 -0
  53. package/dist/publication/Publication.d.ts.map +1 -0
  54. package/dist/publication/Publication.js +427 -0
  55. package/dist/publication/Publication.js.map +1 -0
  56. package/dist/publication/index.d.ts +4 -0
  57. package/dist/publication/index.d.ts.map +1 -0
  58. package/dist/publication/index.js +1 -0
  59. package/dist/unsaved.js.map +1 -1
  60. package/package.json +16 -9
package/README.md CHANGED
@@ -51,16 +51,18 @@ Under a `PanneauProvider`, forms use the field components of the plugins and the
51
51
 
52
52
  ## What a form does
53
53
 
54
- | Feature | How |
55
- | ----------------- | ----------------------------------------------------------------------------------------------------------------------- |
56
- | Layout | `row` (12-column widths), `column`, `section` (collapsible), `tabs`, `sidebar`, `text`, `component`, and `visibleWhen` |
57
- | Phones | Rows stack and the sidebar goes under the form when the form is narrow (container queries) |
58
- | Errors | Next to each field, nested fields included (`blocks.2.body`), in a summary with links, and counted on tabs and sections |
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 a toast |
61
- | Unsaved changes | The page asks before closing (`guardUnsavedChanges`); `useLeaveConfirmation()` guards in-app navigation with a dialog |
62
- | Broken fields | Each field has an error boundary: a field that throws shows a message, the rest of the form keeps working |
63
- | Version conflicts | A dialog shows the values that differ, then loads the current version or saves the local one over it |
54
+ | Feature | How |
55
+ | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
56
+ | Layout | `row` (12-column widths), `column`, `section` (collapsible), `tabs`, `sidebar`, `text`, `component`, and `visibleWhen` |
57
+ | Phones | Rows stack and the sidebar goes under the form when the form is narrow (container queries) |
58
+ | Errors | Next to each field, nested fields included (`blocks.2.body`), in a summary with links, and counted on tabs and sections |
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 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 |
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 |
63
+ | Broken fields | Each field has an error boundary: a field that throws shows a message, the rest of the form keeps working |
64
+ | Version conflicts | A dialog shows the values that differ, then loads the current version or saves the local one over it |
65
+ | Loading | With `isLoading`, while the item loads: a skeleton of the layout, and of each field, its label and a block of its height ([0034](../../docs/decisions/0034-skeletons-while-content-loads.md)) |
64
66
 
65
67
  `Form` creates its state with `useForm()`. To keep the state outside, use `useForm()` and `FormView`.
66
68
 
@@ -52,72 +52,209 @@ function _temp2(label_0) {
52
52
  function _temp(entry_0) {
53
53
  return entry_0 !== null && typeof entry_0 === "object" && "label" in entry_0 ? String(entry_0.label) : null;
54
54
  }
55
- function ConflictDialog({ isOpen, fields, values, current, onReload, onOverwrite, isPending = false, className }) {
55
+ function ConflictDialog(t0) {
56
+ const $ = c(58);
57
+ const { isOpen, fields, values, current, onReload, onOverwrite, isPending: t1, className } = t0;
58
+ const isPending = t1 === void 0 ? false : t1;
56
59
  const intl = usePanneauIntl();
57
60
  const format = useFormatValue();
58
- const theirs = current !== null ? getItemValues(current, fields.map((field) => field.name)) : null;
59
- const changed = theirs !== null ? fields.filter((field_0) => !isEqual(values[field_0.name] ?? null, theirs[field_0.name] ?? null)) : [];
60
- return /* @__PURE__ */ jsx(Dialog, {
61
- isOpen,
62
- role: "alertdialog",
63
- isDismissable: false,
64
- isKeyboardDismissDisabled: true,
65
- title: intl.formatMessage(messages.conflictTitle),
66
- size: "lg",
67
- className,
68
- footer: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Button, {
69
- onPress: onReload,
70
- isDisabled: isPending,
71
- children: intl.formatMessage(messages.loadCurrent)
72
- }), /* @__PURE__ */ jsx(Button, {
73
- variant: "danger",
74
- onPress: onOverwrite,
75
- isPending,
76
- children: intl.formatMessage(messages.overwrite)
77
- })] }),
78
- children: /* @__PURE__ */ jsxs("div", {
79
- className: ConflictDialog_module_default.body,
80
- children: [/* @__PURE__ */ jsx("p", {
61
+ let T0;
62
+ let t10;
63
+ let t11;
64
+ let t12;
65
+ let t2;
66
+ let t3;
67
+ let t4;
68
+ let t5;
69
+ let t6;
70
+ let t7;
71
+ let t8;
72
+ let t9;
73
+ if ($[0] !== className || $[1] !== current || $[2] !== fields || $[3] !== format || $[4] !== intl || $[5] !== isOpen || $[6] !== isPending || $[7] !== onOverwrite || $[8] !== onReload || $[9] !== values) {
74
+ const theirs = current !== null ? getItemValues(current, fields.map(_temp3)) : null;
75
+ const changed = theirs !== null ? fields.filter((field_0) => !isEqual(values[field_0.name] ?? null, theirs[field_0.name] ?? null)) : [];
76
+ T0 = Dialog;
77
+ t5 = isOpen;
78
+ t6 = "alertdialog";
79
+ t7 = false;
80
+ t8 = true;
81
+ if ($[22] !== intl) {
82
+ t9 = intl.formatMessage(messages.conflictTitle);
83
+ $[22] = intl;
84
+ $[23] = t9;
85
+ } else t9 = $[23];
86
+ t10 = "lg";
87
+ t11 = className;
88
+ let t13;
89
+ if ($[24] !== intl) {
90
+ t13 = intl.formatMessage(messages.loadCurrent);
91
+ $[24] = intl;
92
+ $[25] = t13;
93
+ } else t13 = $[25];
94
+ let t14;
95
+ if ($[26] !== isPending || $[27] !== onReload || $[28] !== t13) {
96
+ t14 = /* @__PURE__ */ jsx(Button, {
97
+ onPress: onReload,
98
+ isDisabled: isPending,
99
+ children: t13
100
+ });
101
+ $[26] = isPending;
102
+ $[27] = onReload;
103
+ $[28] = t13;
104
+ $[29] = t14;
105
+ } else t14 = $[29];
106
+ let t15;
107
+ if ($[30] !== intl) {
108
+ t15 = intl.formatMessage(messages.overwrite);
109
+ $[30] = intl;
110
+ $[31] = t15;
111
+ } else t15 = $[31];
112
+ let t16;
113
+ if ($[32] !== isPending || $[33] !== onOverwrite || $[34] !== t15) {
114
+ t16 = /* @__PURE__ */ jsx(Button, {
115
+ variant: "danger",
116
+ onPress: onOverwrite,
117
+ isPending,
118
+ children: t15
119
+ });
120
+ $[32] = isPending;
121
+ $[33] = onOverwrite;
122
+ $[34] = t15;
123
+ $[35] = t16;
124
+ } else t16 = $[35];
125
+ if ($[36] !== t14 || $[37] !== t16) {
126
+ t12 = /* @__PURE__ */ jsxs(Fragment, { children: [t14, t16] });
127
+ $[36] = t14;
128
+ $[37] = t16;
129
+ $[38] = t12;
130
+ } else t12 = $[38];
131
+ t2 = ConflictDialog_module_default.body;
132
+ let t17;
133
+ if ($[39] !== intl) {
134
+ t17 = intl.formatMessage(messages.conflictMessage);
135
+ $[39] = intl;
136
+ $[40] = t17;
137
+ } else t17 = $[40];
138
+ if ($[41] !== t17) {
139
+ t3 = /* @__PURE__ */ jsx("p", {
81
140
  className: ConflictDialog_module_default.message,
82
- children: intl.formatMessage(messages.conflictMessage)
83
- }), theirs === null ? /* @__PURE__ */ jsx("p", {
84
- className: ConflictDialog_module_default.muted,
85
- children: intl.formatMessage(messages.conflictUnknown)
86
- }) : changed.length > 0 ? /* @__PURE__ */ jsxs("section", {
87
- "aria-labelledby": "panneau-conflict-changes",
88
- children: [/* @__PURE__ */ jsx("h3", {
89
- id: "panneau-conflict-changes",
90
- className: ConflictDialog_module_default.heading,
91
- children: intl.formatMessage(messages.conflictChanges)
92
- }), /* @__PURE__ */ jsx("dl", {
93
- className: ConflictDialog_module_default.changes,
94
- children: changed.map((field_1) => /* @__PURE__ */ jsxs("div", {
95
- className: ConflictDialog_module_default.change,
96
- children: [
97
- /* @__PURE__ */ jsx("dt", {
98
- className: ConflictDialog_module_default.label,
99
- children: field_1.label ?? field_1.name
100
- }),
101
- /* @__PURE__ */ jsxs("dd", {
102
- className: ConflictDialog_module_default.version,
103
- children: [/* @__PURE__ */ jsx("span", {
104
- className: ConflictDialog_module_default.which,
105
- children: intl.formatMessage(messages.yours)
106
- }), format(values[field_1.name], field_1)]
107
- }),
108
- /* @__PURE__ */ jsxs("dd", {
109
- className: ConflictDialog_module_default.version,
110
- children: [/* @__PURE__ */ jsx("span", {
111
- className: ConflictDialog_module_default.which,
112
- children: intl.formatMessage(messages.current)
113
- }), format(theirs[field_1.name], field_1)]
114
- })
115
- ]
116
- }, field_1.name))
117
- })]
118
- }) : null]
119
- })
120
- });
141
+ children: t17
142
+ });
143
+ $[41] = t17;
144
+ $[42] = t3;
145
+ } else t3 = $[42];
146
+ t4 = theirs === null ? /* @__PURE__ */ jsx("p", {
147
+ className: ConflictDialog_module_default.muted,
148
+ children: intl.formatMessage(messages.conflictUnknown)
149
+ }) : changed.length > 0 ? /* @__PURE__ */ jsxs("section", {
150
+ "aria-labelledby": "panneau-conflict-changes",
151
+ children: [/* @__PURE__ */ jsx("h3", {
152
+ id: "panneau-conflict-changes",
153
+ className: ConflictDialog_module_default.heading,
154
+ children: intl.formatMessage(messages.conflictChanges)
155
+ }), /* @__PURE__ */ jsx("dl", {
156
+ className: ConflictDialog_module_default.changes,
157
+ children: changed.map((field_1) => /* @__PURE__ */ jsxs("div", {
158
+ className: ConflictDialog_module_default.change,
159
+ children: [
160
+ /* @__PURE__ */ jsx("dt", {
161
+ className: ConflictDialog_module_default.label,
162
+ children: field_1.label ?? field_1.name
163
+ }),
164
+ /* @__PURE__ */ jsxs("dd", {
165
+ className: ConflictDialog_module_default.version,
166
+ children: [/* @__PURE__ */ jsx("span", {
167
+ className: ConflictDialog_module_default.which,
168
+ children: intl.formatMessage(messages.yours)
169
+ }), format(values[field_1.name], field_1)]
170
+ }),
171
+ /* @__PURE__ */ jsxs("dd", {
172
+ className: ConflictDialog_module_default.version,
173
+ children: [/* @__PURE__ */ jsx("span", {
174
+ className: ConflictDialog_module_default.which,
175
+ children: intl.formatMessage(messages.current)
176
+ }), format(theirs[field_1.name], field_1)]
177
+ })
178
+ ]
179
+ }, field_1.name))
180
+ })]
181
+ }) : null;
182
+ $[0] = className;
183
+ $[1] = current;
184
+ $[2] = fields;
185
+ $[3] = format;
186
+ $[4] = intl;
187
+ $[5] = isOpen;
188
+ $[6] = isPending;
189
+ $[7] = onOverwrite;
190
+ $[8] = onReload;
191
+ $[9] = values;
192
+ $[10] = T0;
193
+ $[11] = t10;
194
+ $[12] = t11;
195
+ $[13] = t12;
196
+ $[14] = t2;
197
+ $[15] = t3;
198
+ $[16] = t4;
199
+ $[17] = t5;
200
+ $[18] = t6;
201
+ $[19] = t7;
202
+ $[20] = t8;
203
+ $[21] = t9;
204
+ } else {
205
+ T0 = $[10];
206
+ t10 = $[11];
207
+ t11 = $[12];
208
+ t12 = $[13];
209
+ t2 = $[14];
210
+ t3 = $[15];
211
+ t4 = $[16];
212
+ t5 = $[17];
213
+ t6 = $[18];
214
+ t7 = $[19];
215
+ t8 = $[20];
216
+ t9 = $[21];
217
+ }
218
+ let t13;
219
+ if ($[43] !== t2 || $[44] !== t3 || $[45] !== t4) {
220
+ t13 = /* @__PURE__ */ jsxs("div", {
221
+ className: t2,
222
+ children: [t3, t4]
223
+ });
224
+ $[43] = t2;
225
+ $[44] = t3;
226
+ $[45] = t4;
227
+ $[46] = t13;
228
+ } else t13 = $[46];
229
+ let t14;
230
+ if ($[47] !== T0 || $[48] !== t10 || $[49] !== t11 || $[50] !== t12 || $[51] !== t13 || $[52] !== t5 || $[53] !== t6 || $[54] !== t7 || $[55] !== t8 || $[56] !== t9) {
231
+ t14 = /* @__PURE__ */ jsx(T0, {
232
+ isOpen: t5,
233
+ role: t6,
234
+ isDismissable: t7,
235
+ isKeyboardDismissDisabled: t8,
236
+ title: t9,
237
+ size: t10,
238
+ className: t11,
239
+ footer: t12,
240
+ children: t13
241
+ });
242
+ $[47] = T0;
243
+ $[48] = t10;
244
+ $[49] = t11;
245
+ $[50] = t12;
246
+ $[51] = t13;
247
+ $[52] = t5;
248
+ $[53] = t6;
249
+ $[54] = t7;
250
+ $[55] = t8;
251
+ $[56] = t9;
252
+ $[57] = t14;
253
+ } else t14 = $[57];
254
+ return t14;
255
+ }
256
+ function _temp3(field) {
257
+ return field.name;
121
258
  }
122
259
  //#endregion
123
260
  export { ConflictDialog };
@@ -1 +1 @@
1
- {"version":3,"file":"ConflictDialog.js","names":["labels","entry","label","field","_c","_Fragment","styles"],"sources":["../src/ConflictDialog.tsx"],"sourcesContent":["import { getItemValues, isEqual } from '@panneau/core';\nimport type { Field, Item } from '@panneau/protocol';\nimport { Button, Dialog, usePanneauIntl } from '@panneau/ui';\n\nimport styles from './ConflictDialog.module.css';\nimport { messages } from './messages';\n\nexport interface ConflictDialogProps {\n isOpen: boolean;\n /** The fields of the form, for their labels. */\n fields: readonly Field[];\n /** The values in the form. */\n values: Record<string, unknown>;\n /** The current item, as the backend sent it with the `412`. */\n current: Item | null;\n /** Drops the local changes and continues from the current item. */\n onReload: () => void;\n /** Saves the local values over the current version. */\n onOverwrite: () => void;\n isPending?: boolean;\n className?: string;\n}\n\ntype Formatter = (value: unknown, field?: Field) => string;\n\nfunction useFormatValue(): Formatter {\n const intl = usePanneauIntl();\n const format: Formatter = (value, field) => {\n const options = field?.options;\n if (options !== undefined) {\n const labels = (Array.isArray(value) ? value : [value]).map(\n (entry: unknown) =>\n options.find((option) => option.value === entry)?.label ?? entry,\n );\n if (value !== null && value !== undefined) {\n return labels.map((label) => format(label)).join(', ');\n }\n }\n if (value === null || value === undefined || value === '') {\n return intl.formatMessage(messages.empty);\n }\n if (typeof value === 'boolean') {\n return intl.formatMessage(value ? messages.yes : messages.no);\n }\n if (typeof value === 'string' || typeof value === 'number') {\n const text = String(value);\n return text.length > 120 ? `${text.slice(0, 117)}…` : text;\n }\n if (Array.isArray(value)) {\n const labels = value.map((entry: unknown) =>\n entry !== null && typeof entry === 'object' && 'label' in entry\n ? String((entry as { label: unknown }).label)\n : null,\n );\n return labels.every((label) => label !== null)\n ? labels.join(', ')\n : intl.formatMessage(messages.itemCount, { count: value.length });\n }\n if (typeof value === 'object') {\n const record = value as Record<string, unknown>;\n if (typeof record.label === 'string') {\n return record.label;\n }\n return Object.entries(record)\n .map(([key, entry]) => `${key}: ${format(entry)}`)\n .join(' · ');\n }\n return String(value);\n };\n return format;\n}\n\n/**\n * The dialog of a version conflict (decision 0008): someone else saved the item since the form\n * loaded it. It shows the values that differ, and lets the user load the current version or save\n * theirs over it.\n */\nexport function ConflictDialog({\n isOpen,\n fields,\n values,\n current,\n onReload,\n onOverwrite,\n isPending = false,\n className,\n}: ConflictDialogProps) {\n const intl = usePanneauIntl();\n const format = useFormatValue();\n const theirs =\n current !== null\n ? getItemValues(\n current,\n fields.map((field) => field.name),\n )\n : null;\n const changed =\n theirs !== null\n ? fields.filter(\n (field) => !isEqual(values[field.name] ?? null, theirs[field.name] ?? null),\n )\n : [];\n return (\n <Dialog\n isOpen={isOpen}\n role=\"alertdialog\"\n isDismissable={false}\n isKeyboardDismissDisabled\n title={intl.formatMessage(messages.conflictTitle)}\n size=\"lg\"\n className={className}\n footer={\n <>\n <Button onPress={onReload} isDisabled={isPending}>\n {intl.formatMessage(messages.loadCurrent)}\n </Button>\n <Button variant=\"danger\" onPress={onOverwrite} isPending={isPending}>\n {intl.formatMessage(messages.overwrite)}\n </Button>\n </>\n }\n >\n <div className={styles.body}>\n <p className={styles.message}>{intl.formatMessage(messages.conflictMessage)}</p>\n {theirs === null ? (\n <p className={styles.muted}>{intl.formatMessage(messages.conflictUnknown)}</p>\n ) : changed.length > 0 ? (\n <section aria-labelledby=\"panneau-conflict-changes\">\n <h3 id=\"panneau-conflict-changes\" className={styles.heading}>\n {intl.formatMessage(messages.conflictChanges)}\n </h3>\n <dl className={styles.changes}>\n {changed.map((field) => (\n <div key={field.name} className={styles.change}>\n <dt className={styles.label}>{field.label ?? field.name}</dt>\n <dd className={styles.version}>\n <span className={styles.which}>\n {intl.formatMessage(messages.yours)}\n </span>\n {format(values[field.name], field)}\n </dd>\n <dd className={styles.version}>\n <span className={styles.which}>\n {intl.formatMessage(messages.current)}\n </span>\n {format(theirs[field.name], field)}\n </dd>\n </div>\n ))}\n </dl>\n </section>\n ) : null}\n </div>\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;AAyBA,SAAA,iBAAA;CAAA,MAAA,IAAAI,EAAA,CAAA;CACI,MAAA,OAAa,eAAe;CAAE,IAAA;CAAA,IAAA,EAAA,OAAA,MAAA;EAC9B,UAA0B,OAAA,UAAA;GACtB,MAAA,UAAgB,OAAK;GACrB,IAAI,YAAY,KAAA,GAAS;IACrB,MAAA,UAAgB,MAAK,QAAS,KAAuB,IAArC,QAAA,CAAgC,KAAK,EAAA,CAAC,KAClD,UACI,QAAO,MAAM,WAAY,OAAM,UAAW,KAAY,CAAC,EAAA,SAAvD,KACR;IACA,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAS,OAC9B,OAAM,KAAK,UAAW,OAAO,KAAK,CAAC,CAAC,CAAA,KAAM,IAAI;GACxD;GAEL,IAAI,UAAU,QAAQ,UAAU,KAAA,KAAa,UAAU,IAAE,OAC9C,KAAI,cAAe,SAAQ,KAAM;GAE5C,IAAI,OAAO,UAAU,WAAS,OACnB,KAAI,cAAe,QAAQ,SAAQ,MAAO,SAAQ,EAAG;GAEhE,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAQ;IACtD,MAAA,OAAa,OAAO,KAAK;IAAE,OACpB,KAAI,SAAU,MAAd,GAAuB,KAAI,MAAO,GAAG,GAAG,EAAC,KAAzC;GAAmD;GAE9D,IAAI,MAAK,QAAS,KAAK,GAAC;IACpB,MAAA,WAAe,MAAK,IAAK,KAIzB;IAAE,OACKJ,SAAM,MAAO,MAEgD,IAD9DA,SAAM,KAAM,IACkD,IAA9D,KAAI,cA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GACrD,UAAA,KAAK,cAAc,SAAS,SAAS;EAClC,CAAA,CACZ,EAAA,CAAA;EAGJ,UAAA,qBAAC,OAAD;GAAK,WAAWC,8BAAO;GAAvB,UAAA,CACI,oBAAC,KAAD;IAAG,WAAWA,8BAAO;IAAU,UAAA,KAAK,cAAc,SAAS,eAAe;GAAK,CAAA,GAC9E,WAAW,OACR,oBAAC,KAAD;IAAG,WAAWA,8BAAO;IAAQ,UAAA,KAAK,cAAc,SAAS,eAAe;GAAK,CAAA,IAC7E,QAAQ,SAAS,IACjB,qBAAC,WAAD;IAAS,mBAAgB;IAAzB,UAAA,CACI,oBAAC,MAAD;KAAI,IAAG;KAA2B,WAAWA,8BAAO;KAC/C,UAAA,KAAK,cAAc,SAAS,eAAe;IAC5C,CAAA,GACJ,oBAAC,MAAD;KAAI,WAAWA,8BAAO;KACjB,UAAA,QAAQ,KAAKH,YACV,qBAAC,OAAD;MAAsB,WAAWG,8BAAO;MAAxC,UAAA;OACI,oBAAC,MAAD;QAAI,WAAWA,8BAAO;QAAQH,UAAAA,QAAM,SAASA,QAAM;OAAS,CAAA;OAC5D,qBAAC,MAAD;QAAI,WAAWG,8BAAO;QAAtB,UAAA,CACI,oBAAC,QAAD;SAAM,WAAWA,8BAAO;SACnB,UAAA,KAAK,cAAc,SAAS,KAAK;QAChC,CAAA,GACL,OAAO,OAAOH,QAAM,OAAOA,OAAK,CACjC;;OACJ,qBAAC,MAAD;QAAI,WAAWG,8BAAO;QAAtB,UAAA,CACI,oBAAC,QAAD;SAAM,WAAWA,8BAAO;SACnB,UAAA,KAAK,cAAc,SAAS,OAAO;QAClC,CAAA,GACL,OAAO,OAAOH,QAAM,OAAOA,OAAK,CACjC;;MACH;KAdKA,GAAAA,QAAM,IAcX,CACR;IACD,CAAA,CACC;GACT,CAAA,IAAA,IACH;;CACD,CAAA;AAEhB"}
1
+ {"version":3,"file":"ConflictDialog.js","names":["getItemValues","isEqual","Field","Item","Button","Dialog","usePanneauIntl","styles","messages","ConflictDialogProps","isOpen","fields","values","Record","current","onReload","onOverwrite","isPending","className","Formatter","value","field","useFormatValue","$","_c","intl","format","options","undefined","labels","Array","isArray","map","entry","find","option","label","join","formatMessage","empty","yes","no","text","String","length","slice","labels_0","_temp","every","_temp2","itemCount","count","record","Object","entries","t0","key","entry_1","label_0","entry_0","ConflictDialog","t1","T0","t10","t11","t12","t2","t3","t4","t5","t6","t7","t8","t9","theirs","_temp3","changed","filter","field_0","name","conflictTitle","t13","loadCurrent","t14","t15","overwrite","t16","body","t17","conflictMessage","message","muted","conflictUnknown","heading","conflictChanges","changes","field_1","change","version","which","yours","_c","_Fragment","styles"],"sources":["../src/ConflictDialog.tsx"],"sourcesContent":["import { getItemValues, isEqual } from '@panneau/core';\nimport type { Field, Item } from '@panneau/protocol';\nimport { Button, Dialog, usePanneauIntl } from '@panneau/ui';\n\nimport styles from './ConflictDialog.module.css';\nimport { messages } from './messages';\n\nexport interface ConflictDialogProps {\n isOpen: boolean;\n /** The fields of the form, for their labels. */\n fields: readonly Field[];\n /** The values in the form. */\n values: Record<string, unknown>;\n /** The current item, as the backend sent it with the `412`. */\n current: Item | null;\n /** Drops the local changes and continues from the current item. */\n onReload: () => void;\n /** Saves the local values over the current version. */\n onOverwrite: () => void;\n isPending?: boolean;\n className?: string;\n}\n\ntype Formatter = (value: unknown, field?: Field) => string;\n\nfunction useFormatValue(): Formatter {\n const intl = usePanneauIntl();\n const format: Formatter = (value, field) => {\n const options = field?.options;\n if (options !== undefined) {\n const labels = (Array.isArray(value) ? value : [value]).map(\n (entry: unknown) =>\n options.find((option) => option.value === entry)?.label ?? entry,\n );\n if (value !== null && value !== undefined) {\n return labels.map((label) => format(label)).join(', ');\n }\n }\n if (value === null || value === undefined || value === '') {\n return intl.formatMessage(messages.empty);\n }\n if (typeof value === 'boolean') {\n return intl.formatMessage(value ? messages.yes : messages.no);\n }\n if (typeof value === 'string' || typeof value === 'number') {\n const text = String(value);\n return text.length > 120 ? `${text.slice(0, 117)}…` : text;\n }\n if (Array.isArray(value)) {\n const labels = value.map((entry: unknown) =>\n entry !== null && typeof entry === 'object' && 'label' in entry\n ? String((entry as { label: unknown }).label)\n : null,\n );\n return labels.every((label) => label !== null)\n ? labels.join(', ')\n : intl.formatMessage(messages.itemCount, { count: value.length });\n }\n if (typeof value === 'object') {\n const record = value as Record<string, unknown>;\n if (typeof record.label === 'string') {\n return record.label;\n }\n return Object.entries(record)\n .map(([key, entry]) => `${key}: ${format(entry)}`)\n .join(' · ');\n }\n return String(value);\n };\n return format;\n}\n\n/**\n * The dialog of a version conflict (decision 0008): someone else saved the item since the form\n * loaded it. It shows the values that differ, and lets the user load the current version or save\n * theirs over it.\n */\nexport function ConflictDialog({\n isOpen,\n fields,\n values,\n current,\n onReload,\n onOverwrite,\n isPending = false,\n className,\n}: ConflictDialogProps) {\n const intl = usePanneauIntl();\n const format = useFormatValue();\n const theirs =\n current !== null\n ? getItemValues(\n current,\n fields.map((field) => field.name),\n )\n : null;\n const changed =\n theirs !== null\n ? fields.filter(\n (field) => !isEqual(values[field.name] ?? null, theirs[field.name] ?? null),\n )\n : [];\n return (\n <Dialog\n isOpen={isOpen}\n role=\"alertdialog\"\n isDismissable={false}\n isKeyboardDismissDisabled\n title={intl.formatMessage(messages.conflictTitle)}\n size=\"lg\"\n className={className}\n footer={\n <>\n <Button onPress={onReload} isDisabled={isPending}>\n {intl.formatMessage(messages.loadCurrent)}\n </Button>\n <Button variant=\"danger\" onPress={onOverwrite} isPending={isPending}>\n {intl.formatMessage(messages.overwrite)}\n </Button>\n </>\n }\n >\n <div className={styles.body}>\n <p className={styles.message}>{intl.formatMessage(messages.conflictMessage)}</p>\n {theirs === null ? (\n <p className={styles.muted}>{intl.formatMessage(messages.conflictUnknown)}</p>\n ) : changed.length > 0 ? (\n <section aria-labelledby=\"panneau-conflict-changes\">\n <h3 id=\"panneau-conflict-changes\" className={styles.heading}>\n {intl.formatMessage(messages.conflictChanges)}\n </h3>\n <dl className={styles.changes}>\n {changed.map((field) => (\n <div key={field.name} className={styles.change}>\n <dt className={styles.label}>{field.label ?? field.name}</dt>\n <dd className={styles.version}>\n <span className={styles.which}>\n {intl.formatMessage(messages.yours)}\n </span>\n {format(values[field.name], field)}\n </dd>\n <dd className={styles.version}>\n <span className={styles.which}>\n {intl.formatMessage(messages.current)}\n </span>\n {format(theirs[field.name], field)}\n </dd>\n </div>\n ))}\n </dl>\n </section>\n ) : null}\n </div>\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;AAyBA,SAAAsB,iBAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CACI,MAAAC,OAAanB,eAAe;CAAE,IAAAoB;CAAA,IAAAH,EAAA,OAAAE,MAAA;EAC9BC,UAA0BN,OAAAC,UAAA;GACtB,MAAAM,UAAgBN,OAAKM;GACrB,IAAIA,YAAYC,KAAAA,GAAS;IACrB,MAAAC,UAAgBC,MAAKC,QAASX,KAAuB,IAArCA,QAAA,CAAgCA,KAAK,EAAA,CAACY,KAClDC,UACIN,QAAOO,MAAMC,WAAYA,OAAMf,UAAWa,KAAY,CAAC,EAAAG,SAAvDH,KACR;IACA,IAAIb,UAAU,QAAQA,UAAUQ,KAAAA,GAAS,OAC9BC,OAAMG,KAAKI,UAAWV,OAAOU,KAAK,CAAC,CAAC,CAAAC,KAAM,IAAI;GACxD;GAEL,IAAIjB,UAAU,QAAQA,UAAUQ,KAAAA,KAAaR,UAAU,IAAE,OAC9CK,KAAIa,cAAe9B,SAAQ+B,KAAM;GAE5C,IAAI,OAAOnB,UAAU,WAAS,OACnBK,KAAIa,cAAelB,QAAQZ,SAAQgC,MAAOhC,SAAQiC,EAAG;GAEhE,IAAI,OAAOrB,UAAU,YAAY,OAAOA,UAAU,UAAQ;IACtD,MAAAsB,OAAaC,OAAOvB,KAAK;IAAE,OACpBsB,KAAIE,SAAU,MAAd,GAAuBF,KAAIG,MAAO,GAAG,GAAG,EAAC,KAAzCH;GAAmD;GAE9D,IAAIZ,MAAKC,QAASX,KAAK,GA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EAAA,MAAAiD;EAAAjD,EAAA,MAAAkD;EAAAlD,EAAA,MAAA4D;CAAA,OAAAA,MAAA5D,EAAA;CAAA,OAlDT4D;AAkDS;AA5EV,SAAAR,OAAAtD,OAAA;CAAA,OAgBiCA,MAAK0D;AAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorSummary.js","names":["ref","path","name","list","_c","styles"],"sources":["../src/ErrorSummary.tsx"],"sourcesContent":["import type { Ref } from 'react';\n\nimport type { Field } from '@panneau/protocol';\nimport { Alert, usePanneauIntl } from '@panneau/ui';\n\nimport styles from './Form.module.css';\nimport { describePath } from './describe';\nimport { messages } from './messages';\n\nexport interface ErrorSummaryProps {\n /** Errors by dot path, in the order to list them. */\n errors: Record<string, string[]>;\n /** The fields of the form, for the names of the paths. */\n fields: readonly Field[];\n /** Called with a path when its link is pressed. */\n onSelect: (path: string) => void;\n ref?: Ref<HTMLDivElement>;\n className?: string;\n}\n\n/**\n * The errors of a form, listed at the top after a failed submit: each one links to its field.\n * Assistive technologies announce it when it appears.\n */\nexport function ErrorSummary({ errors, fields, onSelect, ref, className }: ErrorSummaryProps) {\n const intl = usePanneauIntl();\n const entries = Object.entries(errors).filter(([, list]) => list.length > 0);\n if (entries.length === 0) {\n return null;\n }\n return (\n <Alert\n ref={ref}\n tone=\"danger\"\n role=\"alert\"\n tabIndex={-1}\n className={className ?? styles.summary}\n title={intl.formatMessage(messages.summaryTitle, { count: entries.length })}\n >\n <ul className={styles.summaryList}>\n {entries.map(([path, list]) => {\n const name = describePath(fields, path);\n return (\n <li key={path}>\n <button\n type=\"button\"\n className={styles.summaryLink}\n onClick={() => onSelect(path)}\n >\n {name}\n </button>\n {`: ${list.join(' ')}`}\n </li>\n );\n })}\n </ul>\n </Alert>\n );\n}\n"],"mappings":";;;;;;;;;;;AAwBA,SAAO,aAAA,IAAA;CAAA,MAAA,IAAAI,EAAA,EAAA;CAAsB,MAAA,EAAA,QAAA,QAAA,UAAA,KAAA,cAAA;CACzB,MA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EAAA;EAAA,KAAA,EAAA;EAAA,KAAA,EAAA;EAAA,KAAA,EAAA;EAAA,KAAA,EAAA;EAAA,KAAA,EAAA;EAAA,KAAA,EAAA;EAAA,KAAA,EAAA;EAAA,KAAA,EAAA;CAAA;CAAA,IAAA,OAAA,OAAA,IAAA,6BAAA,GAAA,OAAA;CAAA,IAAA;CAAA,IAAA,EAAA,QAAA,MAAA,EAAA,QAAA,IAAA;EAfN,MAAA,oBAAA,MAAA;GAAe,WAAA;GACV,UAAA;EAeA,CAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,MAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,QAAA,MAAA,EAAA,QAAA,OAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,MAAA,EAAA,QAAA,IAAA;EAxBT,MAAA,oBAAC,IAAD;GACS,KAAAH;GACA,MAAA;GACA,MAAA;GACK,UAAA;GACC,WAAA;GACJ,OAAA;GAEP,UAAA;EARE,CAAA;EAyBE,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,MAAA,EAAA;CAAA,OAzBR;AAyBQ;AAhCT,SAAA,MAAA,IAAA;CAE4C,MAAA,GAAA,QAAA;CAAQ,OAAK,KAAI,SAAU;AAAC"}
1
+ {"version":3,"file":"ErrorSummary.js","names":["Ref","Field","Alert","usePanneauIntl","styles","describePath","messages","ErrorSummaryProps","errors","Record","fields","onSelect","path","ref","HTMLDivElement","className","ErrorSummary","t0","$","_c","intl","T0","t1","t2","t3","t4","t5","t6","t7","t8","t9","Symbol","for","bb0","entries","Object","filter","_temp","length","summary","formatMessage","summaryTitle","count","summaryList","map","t10","list_0","name","summaryLink","list","join","t11","_c","styles"],"sources":["../src/ErrorSummary.tsx"],"sourcesContent":["import type { Ref } from 'react';\n\nimport type { Field } from '@panneau/protocol';\nimport { Alert, usePanneauIntl } from '@panneau/ui';\n\nimport styles from './Form.module.css';\nimport { describePath } from './describe';\nimport { messages } from './messages';\n\nexport interface ErrorSummaryProps {\n /** Errors by dot path, in the order to list them. */\n errors: Record<string, string[]>;\n /** The fields of the form, for the names of the paths. */\n fields: readonly Field[];\n /** Called with a path when its link is pressed. */\n onSelect: (path: string) => void;\n ref?: Ref<HTMLDivElement>;\n className?: string;\n}\n\n/**\n * The errors of a form, listed at the top after a failed submit: each one links to its field.\n * Assistive technologies announce it when it appears.\n */\nexport function ErrorSummary({ errors, fields, onSelect, ref, className }: ErrorSummaryProps) {\n const intl = usePanneauIntl();\n const entries = Object.entries(errors).filter(([, list]) => list.length > 0);\n if (entries.length === 0) {\n return null;\n }\n return (\n <Alert\n ref={ref}\n tone=\"danger\"\n role=\"alert\"\n tabIndex={-1}\n className={className ?? styles.summary}\n title={intl.formatMessage(messages.summaryTitle, { count: entries.length })}\n >\n <ul className={styles.summaryList}>\n {entries.map(([path, list]) => {\n const name = describePath(fields, path);\n return (\n <li key={path}>\n <button\n type=\"button\"\n className={styles.summaryLink}\n onClick={() => onSelect(path)}\n >\n {name}\n </button>\n {`: ${list.join(' ')}`}\n </li>\n );\n })}\n </ul>\n </Alert>\n );\n}\n"],"mappings":";;;;;;;;;;;AAwBA,SAAOgB,aAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAsB,MAAA,EAAAX,QAAAE,QAAAC,UAAAE,KAAAE,cAAAE;CACzB,MAAAG,OAAajB,eAAe;CAAE,IAAAkB;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAZ,EAAA,OAAAH,aAAAG,EAAA,OAAAV,U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;EAAAO,KAAAP,EAAA;EAAAQ,KAAAR,EAAA;EAAAS,KAAAT,EAAA;EAAAU,KAAAV,EAAA;EAAAW,KAAAX,EAAA;EAAAY,KAAAZ,EAAA;CAAA;CAAA,IAAAY,OAAAC,OAAAC,IAAA,6BAAA,GAAA,OAAAF;CAAA,IAAAe;CAAA,IAAA3B,EAAA,QAAAI,MAAAJ,EAAA,QAAAK,IAAA;EAfNsB,MAAA,oBAAA,MAAA;GAAe,WAAAvB;GACVC,UAAAA;EAeA,CAAA;EAAAL,EAAA,MAAAI;EAAAJ,EAAA,MAAAK;EAAAL,EAAA,MAAA2B;CAAA,OAAAA,MAAA3B,EAAA;CAAA,IAAAiC;CAAA,IAAAjC,EAAA,QAAAG,MAAAH,EAAA,QAAA2B,OAAA3B,EAAA,QAAAM,MAAAN,EAAA,QAAAO,MAAAP,EAAA,QAAAQ,MAAAR,EAAA,QAAAS,MAAAT,EAAA,QAAAU,MAAAV,EAAA,QAAAW,IAAA;EAxBTsB,MAAA,oBAAC,IAAD;GACStC,KAAAA;GACA,MAAAY;GACA,MAAAC;GACK,UAAAC;GACC,WAAAC;GACJ,OAAAC;GAEPgB,UAAAA;EARE,CAAA;EAyBE3B,EAAA,MAAAG;EAAAH,EAAA,MAAA2B;EAAA3B,EAAA,MAAAM;EAAAN,EAAA,MAAAO;EAAAP,EAAA,MAAAQ;EAAAR,EAAA,MAAAS;EAAAT,EAAA,MAAAU;EAAAV,EAAA,MAAAW;EAAAX,EAAA,MAAAiC;CAAA,OAAAA,MAAAjC,EAAA;CAAA,OAzBRiC;AAyBQ;AAhCT,SAAAd,MAAApB,IAAA;CAE4C,MAAA,GAAAgC,QAAAhC;CAAQ,OAAKgC,KAAIX,SAAU;AAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"FieldErrorBoundary.js","names":[],"sources":["../src/FieldErrorBoundary.tsx"],"sourcesContent":["import { Component, type ErrorInfo, type ReactNode } from 'react';\n\ninterface FieldErrorBoundaryProps {\n /** What to show instead of the field, with a function that renders it again. */\n fallback: (retry: () => void) => ReactNode;\n onError?: (error: unknown, info: ErrorInfo) => void;\n children?: ReactNode;\n}\n\ninterface FieldErrorBoundaryState {\n failed: boolean;\n}\n\n/** Keeps a field that throws from taking the whole form down (decision 0006). */\nexport class FieldErrorBoundary extends Component<\n FieldErrorBoundaryProps,\n FieldErrorBoundaryState\n> {\n override state: FieldErrorBoundaryState = { failed: false };\n\n static getDerivedStateFromError(): FieldErrorBoundaryState {\n return { failed: true };\n }\n\n override componentDidCatch(error: unknown, info: ErrorInfo) {\n this.props.onError?.(error, info);\n }\n\n override render() {\n if (this.state.failed) {\n return this.props.fallback(() => this.setState({ failed: false }));\n }\n return this.props.children;\n }\n}\n"],"mappings":";;;AAcA,IAAa,qBAAb,cAAwC,UAGtC;CACE,QAA0C,EAAE,QAAQ,MAAM;CAE1D,OAAO,2BAAoD;EACvD,OAAO,EAAE,QAAQ,KAAK;CAC1B;CAEA,kBAA2B,OAAgB,MAAiB;EACxD,KAAK,MAAM,UAAU,OAAO,IAAI;CACpC;CAEA,SAAkB;EACd,IAAI,KAAK,MAAM,QACX,OAAO,KAAK,MAAM,eAAe,KAAK,SAAS,EAAE,QAAQ,MAAM,CAAC,CAAC;EAErE,OAAO,KAAK,MAAM;CACtB;AACJ"}
1
+ {"version":3,"file":"FieldErrorBoundary.js","names":["Component","ErrorInfo","ReactNode","FieldErrorBoundaryProps","fallback","retry","onError","error","info","children","FieldErrorBoundaryState","failed","FieldErrorBoundary","state","getDerivedStateFromError","componentDidCatch","props","render","setState"],"sources":["../src/FieldErrorBoundary.tsx"],"sourcesContent":["import { Component, type ErrorInfo, type ReactNode } from 'react';\n\ninterface FieldErrorBoundaryProps {\n /** What to show instead of the field, with a function that renders it again. */\n fallback: (retry: () => void) => ReactNode;\n onError?: (error: unknown, info: ErrorInfo) => void;\n children?: ReactNode;\n}\n\ninterface FieldErrorBoundaryState {\n failed: boolean;\n}\n\n/** Keeps a field that throws from taking the whole form down (decision 0006). */\nexport class FieldErrorBoundary extends Component<\n FieldErrorBoundaryProps,\n FieldErrorBoundaryState\n> {\n override state: FieldErrorBoundaryState = { failed: false };\n\n static getDerivedStateFromError(): FieldErrorBoundaryState {\n return { failed: true };\n }\n\n override componentDidCatch(error: unknown, info: ErrorInfo) {\n this.props.onError?.(error, info);\n }\n\n override render() {\n if (this.state.failed) {\n return this.props.fallback(() => this.setState({ failed: false }));\n }\n return this.props.children;\n }\n}\n"],"mappings":";;;AAcA,IAAaY,qBAAb,cAAwCZ,UAGtC;CACE,QAA0C,EAAEW,QAAQ,MAAM;CAE1D,OAAOG,2BAAoD;EACvD,OAAO,EAAEH,QAAQ,KAAK;CAC1B;CAEA,kBAA2BJ,OAAgBC,MAAiB;EACxD,KAAKQ,MAAMV,UAAUC,OAAOC,IAAI;CACpC;CAEA,SAAkB;EACd,IAAI,KAAKK,MAAMF,QACX,OAAO,KAAKK,MAAMZ,eAAe,KAAKc,SAAS,EAAEP,QAAQ,MAAM,CAAC,CAAC;EAErE,OAAO,KAAKK,MAAMP;CACtB;AACJ"}
package/dist/Form.css CHANGED
@@ -6,19 +6,6 @@
6
6
  min-width: 0;
7
7
  }
8
8
 
9
- .panneau-form-layout {
10
- display: grid;
11
- gap: var(--panneau-space-6);
12
- min-width: 0;
13
- }
14
-
15
- @container panneau-form (min-width: 56rem) {
16
- .panneau-form-with-sidebar {
17
- grid-template-columns: minmax(0, 1fr) minmax(16rem, 20rem);
18
- align-items: start;
19
- }
20
- }
21
-
22
9
  .panneau-form-stack {
23
10
  display: flex;
24
11
  flex-direction: column;
@@ -38,6 +25,27 @@
38
25
  min-width: 0;
39
26
  }
40
27
 
28
+ /* Fields that the layout doesn't place: short ones side by side, in columns of at least 16rem. */
29
+ .panneau-form-flow {
30
+ display: grid;
31
+ grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
32
+ gap: var(--panneau-space-5) var(--panneau-space-4);
33
+ min-width: 0;
34
+ }
35
+
36
+ .panneau-form-flow-cell {
37
+ min-width: 0;
38
+ }
39
+
40
+ /* A field hidden by its condition renders nothing: its cell takes no column. */
41
+ .panneau-form-flow-cell:empty {
42
+ display: none;
43
+ }
44
+
45
+ .panneau-form-flow-wide {
46
+ grid-column: 1 / -1;
47
+ }
48
+
41
49
  /* Narrow containers (phones, side panels): every cell takes the full width. */
42
50
  @container panneau-form (max-width: 36rem) {
43
51
  .panneau-form-cell {
@@ -89,21 +97,15 @@
89
97
  margin: 0;
90
98
  }
91
99
 
92
- .panneau-form-sidebar {
93
- display: flex;
94
- flex-direction: column;
95
- gap: var(--panneau-space-5);
96
- min-width: 0;
97
- }
98
-
99
100
  .panneau-form-field {
100
101
  min-width: 0;
101
102
  scroll-margin: var(--panneau-space-10);
102
103
  }
103
104
 
105
+ /* Sticks to the bottom of the window, above what the frame of the app puts there (a dock). */
104
106
  .panneau-form-footer {
105
107
  position: sticky;
106
- bottom: 0;
108
+ bottom: var(--panneau-frame-bottom, 0px);
107
109
  z-index: 1;
108
110
  display: flex;
109
111
  flex-wrap: wrap;
@@ -115,12 +117,61 @@
115
117
  border-top: var(--panneau-border-width) solid var(--panneau-color-border);
116
118
  }
117
119
 
118
- .panneau-form-dirty {
120
+ /* Beside the form, the `save` and `errors` panels of its sidebar take the place of the footer and
121
+ of the summary at the top (decision 0075). The aside goes beside the form from 56rem. */
122
+ @container panneau-form (min-width: 56rem) {
123
+ /* Twice, over the display of the components it hides */
124
+ .panneau-form-beside-aside-hidden.panneau-form-beside-aside-hidden {
125
+ display: none;
126
+ }
127
+ }
128
+
129
+ /* The state of the publication, at the top of its panel. */
130
+ .panneau-form-publication-state {
131
+ display: flex;
132
+ flex-wrap: wrap;
133
+ align-items: center;
134
+ gap: var(--panneau-space-2);
135
+ }
136
+
137
+ /* The state of the form and its Save button, at the top of its sidebar. */
138
+ .panneau-form-save-panel {
139
+ display: flex;
140
+ flex-wrap: wrap;
141
+ align-items: center;
142
+ justify-content: flex-end;
143
+ gap: var(--panneau-space-2) var(--panneau-space-3);
144
+ }
145
+
146
+ /* "Unsaved changes", "Saved" or the failure of the last save, next to the button. */
147
+ .panneau-form-status {
148
+ display: inline-flex;
149
+ align-items: center;
150
+ gap: var(--panneau-space-1);
119
151
  margin-inline-end: auto;
120
152
  font-size: var(--panneau-font-size-sm);
121
153
  color: var(--panneau-color-text-muted);
122
154
  }
123
155
 
156
+ .panneau-form-status-error {
157
+ color: var(--panneau-color-danger);
158
+ }
159
+
160
+ /* A new status comes in: it fades in and rises a little, as a toast does. */
161
+ .panneau-form-status-text {
162
+ display: inline-flex;
163
+ align-items: center;
164
+ gap: var(--panneau-space-1);
165
+ animation: panneau-form-status-in var(--panneau-duration-slow) var(--panneau-ease-out);
166
+ }
167
+
168
+ @keyframes panneau-form-status-in {
169
+ from {
170
+ opacity: 0;
171
+ transform: translateY(0.25rem);
172
+ }
173
+ }
174
+
124
175
  .panneau-form-summary:focus {
125
176
  outline: var(--panneau-focus-width) solid var(--panneau-color-focus);
126
177
  outline-offset: 2px;
@@ -151,7 +202,31 @@
151
202
  }
152
203
 
153
204
  @container panneau-form (max-width: 36rem) {
154
- .panneau-form-footer > :not(.panneau-form-dirty) {
205
+ .panneau-form-footer > :not(.panneau-form-status) {
155
206
  flex: 1 1 auto;
156
207
  }
157
208
  }
209
+
210
+ /* The skeleton of a form whose values load. */
211
+ .panneau-form-skeleton-field {
212
+ display: flex;
213
+ flex-direction: column;
214
+ gap: var(--panneau-space-1);
215
+ }
216
+
217
+ .panneau-form-skeleton-inline {
218
+ display: flex;
219
+ align-items: center;
220
+ gap: var(--panneau-space-2);
221
+ }
222
+
223
+ .panneau-form-skeleton-label {
224
+ font-size: var(--panneau-font-size-sm);
225
+ }
226
+
227
+ .panneau-form-skeleton-tabs {
228
+ display: flex;
229
+ gap: var(--panneau-space-5);
230
+ padding-block: var(--panneau-space-2);
231
+ border-bottom: var(--panneau-border-width) solid var(--panneau-color-border);
232
+ }
package/dist/Form.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type FormOptions } from '@panneau/core';
2
2
  import type { Field, LayoutNode } from '@panneau/protocol';
3
- import { type FormViewProps } from './FormView';
3
+ import { type FormViewProps } from './FormView.js';
4
4
  export interface FormProps extends Omit<FormViewProps, 'form' | 'fields' | 'layout'>, Pick<FormOptions, 'values' | 'version' | 'mode' | 'store' | 'formatError' | 'onSubmit'> {
5
5
  /** The fields of the form. Without a layout, they are rendered in order. */
6
6
  fields: readonly Field[];
@@ -14,7 +14,8 @@ export interface FormProps extends Omit<FormViewProps, 'form' | 'fields' | 'layo
14
14
  * translated with react-intl.
15
15
  *
16
16
  * Initial values and the version are read once: give the form a new `key` to start from another
17
- * item, or use `useForm()` and `FormView`.
17
+ * item, or use `useForm()` and `FormView`. While the item loads, `isLoading` draws a skeleton of
18
+ * the form, and a new `key` once it is there starts the form from its values.
18
19
  */
19
20
  export declare function Form({ fields, layout, values, version, mode, store, formatError, onSubmit, locales, ...props }: FormProps): import("react").JSX.Element;
20
21
  //# sourceMappingURL=Form.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../src/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAsC,MAAM,eAAe,CAAC;AACrF,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAG1D,MAAM,WAAW,SACb,SACI,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC,EACjD,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,aAAa,GAAG,UAAU,CAAC;IAC3F,4EAA4E;IAC5E,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IACzB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;CAClC;AAED;;;;;;;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