@panneau/forms 5.0.0-alpha.0 → 5.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -10
- package/dist/ConflictDialog.css +15 -10
- package/dist/ConflictDialog.js +201 -61
- package/dist/ConflictDialog.js.map +1 -1
- package/dist/ConflictDialog.module.js +11 -9
- package/dist/ConflictDialog.module.js.map +1 -1
- package/dist/ErrorSummary.js.map +1 -1
- package/dist/FieldErrorBoundary.js.map +1 -1
- package/dist/Form.css +52 -22
- package/dist/Form.d.ts +3 -2
- package/dist/Form.d.ts.map +1 -1
- package/dist/Form.js +122 -21
- package/dist/Form.js.map +1 -1
- package/dist/Form.module.js +29 -21
- package/dist/Form.module.js.map +1 -1
- package/dist/FormBinding.js.map +1 -1
- package/dist/FormSkeleton.d.ts +21 -0
- package/dist/FormSkeleton.d.ts.map +1 -0
- package/dist/FormSkeleton.js +402 -0
- package/dist/FormSkeleton.js.map +1 -0
- package/dist/FormView.d.ts +22 -3
- package/dist/FormView.d.ts.map +1 -1
- package/dist/FormView.js +234 -92
- package/dist/FormView.js.map +1 -1
- package/dist/context.js.map +1 -1
- package/dist/cx.js.map +1 -1
- package/dist/describe.js.map +1 -1
- package/dist/formatError.d.ts +2 -2
- package/dist/formatError.d.ts.map +1 -1
- package/dist/formatError.js +10 -2
- package/dist/formatError.js.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/layout/Layout.js.map +1 -1
- package/dist/locales/index.js.map +1 -1
- package/dist/paths.js.map +1 -1
- package/dist/unsaved.js.map +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -51,16 +51,17 @@ 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()`
|
|
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 a toast |
|
|
61
|
+
| Unsaved changes | The page asks before closing (`guardUnsavedChanges`). Under a `LeaveGuardsProvider` of `@panneau/core`, leaving through the app's router asks in a dialog too; `useLeaveConfirmation()` gives that dialog to other routers |
|
|
62
|
+
| 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 |
|
|
64
|
+
| 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
65
|
|
|
65
66
|
`Form` creates its state with `useForm()`. To keep the state outside, use `useForm()` and `FormView`.
|
|
66
67
|
|
package/dist/ConflictDialog.css
CHANGED
|
@@ -1,27 +1,32 @@
|
|
|
1
|
-
.panneau-body
|
|
1
|
+
.panneau-conflict-dialog-body {
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
gap: var(--panneau-space-4);
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
.panneau-
|
|
7
|
+
.panneau-conflict-dialog-message {
|
|
8
|
+
margin: 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.panneau-conflict-dialog-muted {
|
|
8
12
|
color: var(--panneau-color-text-muted);
|
|
13
|
+
margin: 0;
|
|
9
14
|
}
|
|
10
15
|
|
|
11
|
-
.panneau-
|
|
12
|
-
margin
|
|
16
|
+
.panneau-conflict-dialog-heading {
|
|
17
|
+
margin: 0 0 var(--panneau-space-2);
|
|
13
18
|
font-size: var(--panneau-font-size-md);
|
|
14
19
|
font-weight: var(--panneau-font-weight-bold);
|
|
15
20
|
}
|
|
16
21
|
|
|
17
|
-
.panneau-changes
|
|
22
|
+
.panneau-conflict-dialog-changes {
|
|
18
23
|
display: flex;
|
|
19
24
|
flex-direction: column;
|
|
20
25
|
gap: var(--panneau-space-3);
|
|
21
26
|
margin: 0;
|
|
22
27
|
}
|
|
23
28
|
|
|
24
|
-
.panneau-change
|
|
29
|
+
.panneau-conflict-dialog-change {
|
|
25
30
|
display: grid;
|
|
26
31
|
grid-template-columns: minmax(8rem, 1fr) 2fr 2fr;
|
|
27
32
|
gap: var(--panneau-space-1) var(--panneau-space-3);
|
|
@@ -29,11 +34,11 @@
|
|
|
29
34
|
border-bottom: var(--panneau-border-width) solid var(--panneau-color-border);
|
|
30
35
|
}
|
|
31
36
|
|
|
32
|
-
.panneau-
|
|
37
|
+
.panneau-conflict-dialog-label {
|
|
33
38
|
font-weight: var(--panneau-font-weight-medium);
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
.panneau-version
|
|
41
|
+
.panneau-conflict-dialog-version {
|
|
37
42
|
display: flex;
|
|
38
43
|
flex-direction: column;
|
|
39
44
|
min-width: 0;
|
|
@@ -41,7 +46,7 @@
|
|
|
41
46
|
overflow-wrap: anywhere;
|
|
42
47
|
}
|
|
43
48
|
|
|
44
|
-
.panneau-which
|
|
49
|
+
.panneau-conflict-dialog-which {
|
|
45
50
|
font-size: var(--panneau-font-size-xs);
|
|
46
51
|
color: var(--panneau-color-text-muted);
|
|
47
52
|
text-transform: uppercase;
|
|
@@ -49,7 +54,7 @@
|
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
@media (max-width: 40rem) {
|
|
52
|
-
.panneau-change
|
|
57
|
+
.panneau-conflict-dialog-change {
|
|
53
58
|
grid-template-columns: 1fr;
|
|
54
59
|
}
|
|
55
60
|
}
|
package/dist/ConflictDialog.js
CHANGED
|
@@ -52,69 +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(
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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", {
|
|
140
|
+
className: ConflictDialog_module_default.message,
|
|
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;
|
|
118
258
|
}
|
|
119
259
|
//#endregion
|
|
120
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>{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,OA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;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,UA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,EAAA,QAAA0C,OAAA1C,EAAA,QAAA0D,OAAA1D,EAAA,QAAA8C,MAAA9C,EAAA,QAAA+C,MAAA/C,EAAA,QAAAgD,MAAAhD,EAAA,QAAAiD,MAAAjD,EAAA,QAAAkD,IAAA;EAjDVU,MAAA,oBAAC,IAAD;GACYzE,QAAAA;GACH,MAAA4D;GACU,eAAAC;GACf,2BAAAC;GACO,OAAAC;GACF,MAAAV;GACM7C,WAAAA;GAEP,QAAA+C;GAUJgB,UAAAA;EAnBG,CAAA;EAkDE1D,EAAA,MAAAuC;EAAAvC,EAAA,MAAAwC;EAAAxC,EAAA,MAAAyC;EAAAzC,EAAA,MAAA0C;EAAA1C,EAAA,MAAA0D;EAAA1D,EAAA,MAAA8C;EAAA9C,EAAA,MAAA+C;EAAA/C,EAAA,MAAAgD;EAAAhD,EAAA,MAAAiD;EAAAjD,EAAA,MAAAkD;EAAAlD,EAAA,MAAA4D;CAAA,OAAAA,MAAA5D,EAAA;CAAA,OAlDT4D;AAkDS;AA5EV,SAAAR,OAAAtD,OAAA;CAAA,OAgBiCA,MAAK0D;AAAK"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import "./ConflictDialog.css";
|
|
2
2
|
//#region src/ConflictDialog.module.css
|
|
3
|
-
var body = "panneau-body
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
3
|
+
var body = "panneau-conflict-dialog-body";
|
|
4
|
+
var message = "panneau-conflict-dialog-message";
|
|
5
|
+
var muted = "panneau-conflict-dialog-muted";
|
|
6
|
+
var heading = "panneau-conflict-dialog-heading";
|
|
7
|
+
var changes = "panneau-conflict-dialog-changes";
|
|
8
|
+
var change = "panneau-conflict-dialog-change";
|
|
9
|
+
var label = "panneau-conflict-dialog-label";
|
|
10
|
+
var version = "panneau-conflict-dialog-version";
|
|
11
|
+
var which = "panneau-conflict-dialog-which";
|
|
11
12
|
var ConflictDialog_module_default = {
|
|
12
13
|
body,
|
|
14
|
+
message,
|
|
13
15
|
muted,
|
|
14
16
|
heading,
|
|
15
17
|
changes,
|
|
@@ -19,6 +21,6 @@ var ConflictDialog_module_default = {
|
|
|
19
21
|
which
|
|
20
22
|
};
|
|
21
23
|
//#endregion
|
|
22
|
-
export { body, change, changes, ConflictDialog_module_default as default, heading, label, muted, version, which };
|
|
24
|
+
export { body, change, changes, ConflictDialog_module_default as default, heading, label, message, muted, version, which };
|
|
23
25
|
|
|
24
26
|
//# sourceMappingURL=ConflictDialog.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConflictDialog.module.js","names":[],"sources":["../src/ConflictDialog.module.css"],"sourcesContent":[".body {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-4);\n}\n\n.muted {\n color: var(--panneau-color-text-muted);\n}\n\n.heading {\n margin
|
|
1
|
+
{"version":3,"file":"ConflictDialog.module.js","names":[],"sources":["../src/ConflictDialog.module.css"],"sourcesContent":[".body {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-4);\n}\n\n.message {\n margin: 0;\n}\n\n.muted {\n color: var(--panneau-color-text-muted);\n margin: 0;\n}\n\n.heading {\n margin: 0 0 var(--panneau-space-2);\n font-size: var(--panneau-font-size-md);\n font-weight: var(--panneau-font-weight-bold);\n}\n\n.changes {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-3);\n margin: 0;\n}\n\n.change {\n display: grid;\n grid-template-columns: minmax(8rem, 1fr) 2fr 2fr;\n gap: var(--panneau-space-1) var(--panneau-space-3);\n padding-bottom: var(--panneau-space-3);\n border-bottom: var(--panneau-border-width) solid var(--panneau-color-border);\n}\n\n.label {\n font-weight: var(--panneau-font-weight-medium);\n}\n\n.version {\n display: flex;\n flex-direction: column;\n min-width: 0;\n margin: 0;\n overflow-wrap: anywhere;\n}\n\n.which {\n font-size: var(--panneau-font-size-xs);\n color: var(--panneau-color-text-muted);\n text-transform: uppercase;\n letter-spacing: 0.04em;\n}\n\n@media (max-width: 40rem) {\n .change {\n grid-template-columns: 1fr;\n }\n}\n"],"mappings":""}
|
package/dist/ErrorSummary.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorSummary.js","names":["
|
|
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={()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,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,
|
|
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"}
|