@panneau/fields 5.0.0-alpha.11 → 5.0.0-alpha.12
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/embed/EmbedField.js +1 -1
- package/dist/file/FileField.js +2 -2
- package/dist/group/GroupField.css +20 -3
- package/dist/group/GroupField.d.ts +2 -2
- package/dist/group/GroupField.d.ts.map +1 -1
- package/dist/group/GroupField.js +49 -36
- package/dist/group/GroupField.js.map +1 -1
- package/dist/group/GroupField.module.js +10 -2
- package/dist/group/GroupField.module.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/json/JsonField.js +1 -1
- package/dist/localized/LocalizedField.css +27 -6
- package/dist/localized/LocalizedField.d.ts +18 -7
- package/dist/localized/LocalizedField.d.ts.map +1 -1
- package/dist/localized/LocalizedField.js +236 -104
- package/dist/localized/LocalizedField.js.map +1 -1
- package/dist/localized/LocalizedField.module.js +10 -4
- package/dist/localized/LocalizedField.module.js.map +1 -1
- package/dist/location/LocationField.js +2 -2
- package/dist/relation/RelationField.js +2 -2
- package/dist/repeater/RepeaterField.js +2 -2
- package/dist/shared/DefinitionField.d.ts +3 -1
- package/dist/shared/DefinitionField.d.ts.map +1 -1
- package/dist/shared/DefinitionField.js +81 -73
- package/dist/shared/DefinitionField.js.map +1 -1
- package/dist/shared/context.d.ts +5 -0
- package/dist/shared/context.d.ts.map +1 -1
- package/dist/shared/context.js.map +1 -1
- package/dist/shared/entry.d.ts +2 -2
- package/dist/shared/entry.d.ts.map +1 -1
- package/dist/shared/entry.js +4 -3
- package/dist/shared/entry.js.map +1 -1
- package/dist/shared/flow.d.ts +8 -0
- package/dist/shared/flow.d.ts.map +1 -0
- package/dist/shared/flow.js +35 -0
- package/dist/shared/flow.js.map +1 -0
- package/dist/shared/reveal.d.ts +16 -0
- package/dist/shared/reveal.d.ts.map +1 -0
- package/dist/shared/reveal.js +46 -0
- package/dist/shared/reveal.js.map +1 -0
- package/dist/shared/types.d.ts +10 -0
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/slug/SlugField.js +2 -2
- package/dist/text/TextField.js +2 -2
- package/dist/upload/FilePicker.js +1 -1
- package/dist/upload/UploadList.js +1 -1
- package/dist/url/UrlField.js +1 -1
- package/package.json +4 -4
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { useFieldsContext } from "../shared/context.js";
|
|
2
2
|
import { cx } from "../shared/cx.js";
|
|
3
3
|
import { getFieldProps } from "../shared/entry.js";
|
|
4
|
+
import { messages } from "../shared/messages.js";
|
|
5
|
+
import { useRevealer } from "../shared/reveal.js";
|
|
4
6
|
import LocalizedField_module_default from "./LocalizedField.module.js";
|
|
5
7
|
import { NestedField } from "../shared/DefinitionField.js";
|
|
6
8
|
import { c } from "react/compiler-runtime";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
+
import { isFilled } from "@panneau/protocol/runtime";
|
|
10
|
+
import { Plus } from "lucide-react";
|
|
11
|
+
import { useState } from "react";
|
|
12
|
+
import { Fieldset, Icon, SegmentedControl, usePanneauIntl } from "@panneau/ui";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
14
|
//#region src/localized/LocalizedField.tsx
|
|
10
15
|
/** The name of a locale in the UI's language, capitalized (`Français`, `English`). */
|
|
11
16
|
function useLocaleName() {
|
|
@@ -29,27 +34,114 @@ function useLocaleName() {
|
|
|
29
34
|
return t0;
|
|
30
35
|
}
|
|
31
36
|
/**
|
|
32
|
-
* A value per locale
|
|
33
|
-
*
|
|
37
|
+
* A value per locale: one locale at a time, under the field's label, with a switch at the end of
|
|
38
|
+
* the label's line for the others. The switch marks the locales in error, and the empty ones: to
|
|
39
|
+
* fill in when the field is required, to add otherwise. A value without any locale filled is
|
|
40
|
+
* `null`.
|
|
34
41
|
*/
|
|
35
42
|
function LocalizedField(t0) {
|
|
36
|
-
const $ = c(
|
|
37
|
-
const { locales, children, value, onChange, onBlur, label, description, errors, disabled, readOnly, required, className, labelClassName, descriptionClassName, errorsClassName, localeClassName } = t0;
|
|
43
|
+
const $ = c(58);
|
|
44
|
+
const { locales, children, value, onChange, onBlur, label, description, errors, disabled, readOnly, required, locale, onLocaleChange, invalidLocales: t1, className, labelClassName, descriptionClassName, errorsClassName, localeClassName } = t0;
|
|
45
|
+
let t2;
|
|
46
|
+
if ($[0] !== t1) {
|
|
47
|
+
t2 = t1 === void 0 ? [] : t1;
|
|
48
|
+
$[0] = t1;
|
|
49
|
+
$[1] = t2;
|
|
50
|
+
} else t2 = $[1];
|
|
51
|
+
const invalidLocales = t2;
|
|
52
|
+
const intl = usePanneauIntl();
|
|
38
53
|
const localeName = useLocaleName();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
const [uncontrolled, setUncontrolled] = useState(locales[0]);
|
|
55
|
+
const wanted = locale ?? uncontrolled;
|
|
56
|
+
let t3;
|
|
57
|
+
if ($[2] !== locales || $[3] !== wanted) {
|
|
58
|
+
t3 = wanted !== void 0 && locales.includes(wanted) ? wanted : locales[0];
|
|
59
|
+
$[2] = locales;
|
|
60
|
+
$[3] = wanted;
|
|
61
|
+
$[4] = t3;
|
|
62
|
+
} else t3 = $[4];
|
|
63
|
+
const current = t3;
|
|
64
|
+
let t4;
|
|
65
|
+
if ($[5] !== intl || $[6] !== invalidLocales || $[7] !== localeName || $[8] !== locales || $[9] !== required || $[10] !== value) {
|
|
66
|
+
let t5;
|
|
67
|
+
if ($[12] !== intl || $[13] !== invalidLocales || $[14] !== localeName || $[15] !== required || $[16] !== value) {
|
|
68
|
+
t5 = (option, index) => {
|
|
69
|
+
const name = localeName(option);
|
|
70
|
+
const invalid = invalidLocales.includes(option);
|
|
71
|
+
const empty = !isFilled(value?.[option]);
|
|
72
|
+
const addable = !invalid && empty && required !== true && index > 0;
|
|
73
|
+
let textValue = name;
|
|
74
|
+
if (invalid) textValue = intl.formatMessage(messages.localeInvalid, { locale: name });
|
|
75
|
+
else if (addable) textValue = intl.formatMessage(messages.addLocale, { locale: name });
|
|
76
|
+
else if (empty) textValue = intl.formatMessage(messages.localeEmpty, { locale: name });
|
|
77
|
+
return {
|
|
78
|
+
value: option,
|
|
79
|
+
textValue,
|
|
80
|
+
label: /* @__PURE__ */ jsxs("span", {
|
|
81
|
+
className: LocalizedField_module_default.option,
|
|
82
|
+
children: [
|
|
83
|
+
addable ? /* @__PURE__ */ jsx(Icon, {
|
|
84
|
+
icon: Plus,
|
|
85
|
+
size: "sm"
|
|
86
|
+
}) : null,
|
|
87
|
+
option.toUpperCase(),
|
|
88
|
+
invalid ? /* @__PURE__ */ jsx("span", { className: cx(LocalizedField_module_default.marker, LocalizedField_module_default.invalid) }) : null,
|
|
89
|
+
!invalid && empty && required === true ? /* @__PURE__ */ jsx("span", { className: cx(LocalizedField_module_default.marker, LocalizedField_module_default.empty) }) : null
|
|
90
|
+
]
|
|
91
|
+
})
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
$[12] = intl;
|
|
95
|
+
$[13] = invalidLocales;
|
|
96
|
+
$[14] = localeName;
|
|
97
|
+
$[15] = required;
|
|
98
|
+
$[16] = value;
|
|
99
|
+
$[17] = t5;
|
|
100
|
+
} else t5 = $[17];
|
|
101
|
+
t4 = locales.map(t5);
|
|
102
|
+
$[5] = intl;
|
|
103
|
+
$[6] = invalidLocales;
|
|
104
|
+
$[7] = localeName;
|
|
105
|
+
$[8] = locales;
|
|
106
|
+
$[9] = required;
|
|
107
|
+
$[10] = value;
|
|
108
|
+
$[11] = t4;
|
|
109
|
+
} else t4 = $[11];
|
|
110
|
+
const options = t4;
|
|
111
|
+
let t5;
|
|
112
|
+
if ($[18] !== current || $[19] !== intl || $[20] !== locales.length || $[21] !== onLocaleChange || $[22] !== options) {
|
|
113
|
+
t5 = locales.length > 1 ? /* @__PURE__ */ jsx(SegmentedControl, {
|
|
114
|
+
size: "sm",
|
|
115
|
+
"aria-label": intl.formatMessage(messages.locales),
|
|
116
|
+
options,
|
|
117
|
+
...current !== void 0 ? { value: current } : {},
|
|
118
|
+
onChange: (next) => {
|
|
119
|
+
setUncontrolled(next);
|
|
120
|
+
onLocaleChange?.(next);
|
|
121
|
+
}
|
|
122
|
+
}) : void 0;
|
|
123
|
+
$[18] = current;
|
|
124
|
+
$[19] = intl;
|
|
125
|
+
$[20] = locales.length;
|
|
126
|
+
$[21] = onLocaleChange;
|
|
127
|
+
$[22] = options;
|
|
128
|
+
$[23] = t5;
|
|
129
|
+
} else t5 = $[23];
|
|
130
|
+
let t6;
|
|
131
|
+
if ($[24] !== children || $[25] !== current || $[26] !== disabled || $[27] !== localeClassName || $[28] !== localeName || $[29] !== locales || $[30] !== onBlur || $[31] !== onChange || $[32] !== readOnly || $[33] !== required || $[34] !== value) {
|
|
132
|
+
let t7;
|
|
133
|
+
if ($[36] !== children || $[37] !== current || $[38] !== disabled || $[39] !== localeClassName || $[40] !== localeName || $[41] !== onBlur || $[42] !== onChange || $[43] !== readOnly || $[44] !== required || $[45] !== value) {
|
|
134
|
+
t7 = (option_0) => /* @__PURE__ */ jsx("div", {
|
|
44
135
|
className: cx(LocalizedField_module_default.locale, localeClassName),
|
|
136
|
+
hidden: option_0 !== current,
|
|
45
137
|
children: children({
|
|
46
|
-
locale,
|
|
47
|
-
label: localeName(
|
|
48
|
-
value: value?.[
|
|
49
|
-
onChange: (
|
|
138
|
+
locale: option_0,
|
|
139
|
+
label: localeName(option_0),
|
|
140
|
+
value: value?.[option_0] ?? null,
|
|
141
|
+
onChange: (next_0) => {
|
|
50
142
|
const updated = {
|
|
51
143
|
...value,
|
|
52
|
-
[
|
|
144
|
+
[option_0]: next_0
|
|
53
145
|
};
|
|
54
146
|
const filled = Object.values(updated).some(_temp);
|
|
55
147
|
onChange?.(filled ? updated : null);
|
|
@@ -59,44 +151,38 @@ function LocalizedField(t0) {
|
|
|
59
151
|
...readOnly !== void 0 ? { readOnly } : {},
|
|
60
152
|
...required !== void 0 ? { required } : {}
|
|
61
153
|
})
|
|
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
|
-
$[21] = t1;
|
|
94
|
-
$[22] = t2;
|
|
95
|
-
} else t2 = $[22];
|
|
96
|
-
let t3;
|
|
97
|
-
if ($[23] !== className || $[24] !== description || $[25] !== descriptionClassName || $[26] !== errors || $[27] !== errorsClassName || $[28] !== label || $[29] !== labelClassName || $[30] !== required || $[31] !== t2) {
|
|
98
|
-
t3 = /* @__PURE__ */ jsx(Fieldset, {
|
|
154
|
+
}, option_0);
|
|
155
|
+
$[36] = children;
|
|
156
|
+
$[37] = current;
|
|
157
|
+
$[38] = disabled;
|
|
158
|
+
$[39] = localeClassName;
|
|
159
|
+
$[40] = localeName;
|
|
160
|
+
$[41] = onBlur;
|
|
161
|
+
$[42] = onChange;
|
|
162
|
+
$[43] = readOnly;
|
|
163
|
+
$[44] = required;
|
|
164
|
+
$[45] = value;
|
|
165
|
+
$[46] = t7;
|
|
166
|
+
} else t7 = $[46];
|
|
167
|
+
t6 = locales.map(t7);
|
|
168
|
+
$[24] = children;
|
|
169
|
+
$[25] = current;
|
|
170
|
+
$[26] = disabled;
|
|
171
|
+
$[27] = localeClassName;
|
|
172
|
+
$[28] = localeName;
|
|
173
|
+
$[29] = locales;
|
|
174
|
+
$[30] = onBlur;
|
|
175
|
+
$[31] = onChange;
|
|
176
|
+
$[32] = readOnly;
|
|
177
|
+
$[33] = required;
|
|
178
|
+
$[34] = value;
|
|
179
|
+
$[35] = t6;
|
|
180
|
+
} else t6 = $[35];
|
|
181
|
+
let t7;
|
|
182
|
+
if ($[47] !== className || $[48] !== description || $[49] !== descriptionClassName || $[50] !== errors || $[51] !== errorsClassName || $[52] !== label || $[53] !== labelClassName || $[54] !== required || $[55] !== t5 || $[56] !== t6) {
|
|
183
|
+
t7 = /* @__PURE__ */ jsx(Fieldset, {
|
|
99
184
|
legend: label,
|
|
185
|
+
legendEnd: t5,
|
|
100
186
|
description,
|
|
101
187
|
errors,
|
|
102
188
|
isRequired: required,
|
|
@@ -104,30 +190,36 @@ function LocalizedField(t0) {
|
|
|
104
190
|
legendClassName: labelClassName,
|
|
105
191
|
descriptionClassName,
|
|
106
192
|
errorsClassName,
|
|
107
|
-
children:
|
|
193
|
+
children: t6
|
|
108
194
|
});
|
|
109
|
-
$[
|
|
110
|
-
$[
|
|
111
|
-
$[
|
|
112
|
-
$[
|
|
113
|
-
$[
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
-
$[
|
|
119
|
-
|
|
120
|
-
|
|
195
|
+
$[47] = className;
|
|
196
|
+
$[48] = description;
|
|
197
|
+
$[49] = descriptionClassName;
|
|
198
|
+
$[50] = errors;
|
|
199
|
+
$[51] = errorsClassName;
|
|
200
|
+
$[52] = label;
|
|
201
|
+
$[53] = labelClassName;
|
|
202
|
+
$[54] = required;
|
|
203
|
+
$[55] = t5;
|
|
204
|
+
$[56] = t6;
|
|
205
|
+
$[57] = t7;
|
|
206
|
+
} else t7 = $[57];
|
|
207
|
+
return t7;
|
|
121
208
|
}
|
|
122
|
-
/**
|
|
123
|
-
* A field of the definition with `localized: true`: the field of its type for each locale of the
|
|
124
|
-
* fields context, each at its own path (`title.fr`).
|
|
125
|
-
*/
|
|
209
|
+
/** The locale of a path inside a localized field (`title.en`, `body.en.0` in `title`), if any. */
|
|
126
210
|
function _temp(entry) {
|
|
127
211
|
return entry !== null && entry !== void 0 && entry !== "";
|
|
128
212
|
}
|
|
213
|
+
function localeOf(path, fieldPath, locales) {
|
|
214
|
+
return locales.find((locale) => path === `${fieldPath}.${locale}` || path.startsWith(`${fieldPath}.${locale}.`));
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* A field of the definition with `localized: true`: the field of its type for each locale of the
|
|
218
|
+
* fields context, each at its own path (`title.fr`). It shows the locale of a path the form
|
|
219
|
+
* reveals, such as the first error on submit.
|
|
220
|
+
*/
|
|
129
221
|
function LocalizedFieldEntry(props) {
|
|
130
|
-
const $ = c(
|
|
222
|
+
const $ = c(36);
|
|
131
223
|
const { locales: contextLocales } = useFieldsContext();
|
|
132
224
|
const { field, path, value } = props;
|
|
133
225
|
let t0;
|
|
@@ -145,22 +237,56 @@ function LocalizedFieldEntry(props) {
|
|
|
145
237
|
$[4] = t1;
|
|
146
238
|
} else t1 = $[4];
|
|
147
239
|
const locales = t1;
|
|
240
|
+
const [locale, setLocale] = useState(locales[0]);
|
|
148
241
|
let t2;
|
|
149
|
-
if ($[5] !==
|
|
150
|
-
t2 =
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const { name: _name, onBlur: _onBlur, ...t3 } = t2;
|
|
157
|
-
chrome = t3;
|
|
242
|
+
if ($[5] !== locales || $[6] !== path) {
|
|
243
|
+
t2 = (revealed) => {
|
|
244
|
+
const found = localeOf(revealed, path, locales);
|
|
245
|
+
if (found !== void 0) setLocale(found);
|
|
246
|
+
};
|
|
247
|
+
$[5] = locales;
|
|
248
|
+
$[6] = path;
|
|
158
249
|
$[7] = t2;
|
|
159
|
-
|
|
160
|
-
|
|
250
|
+
} else t2 = $[7];
|
|
251
|
+
useRevealer(t2);
|
|
161
252
|
let t3;
|
|
162
|
-
if ($[
|
|
163
|
-
|
|
253
|
+
if ($[8] !== locales || $[9] !== path || $[10] !== props.invalidPaths) {
|
|
254
|
+
let t4;
|
|
255
|
+
if ($[12] !== path || $[13] !== props.invalidPaths) {
|
|
256
|
+
t4 = (candidate) => (props.invalidPaths ?? []).some((invalid) => localeOf(invalid, path, [candidate]) !== void 0);
|
|
257
|
+
$[12] = path;
|
|
258
|
+
$[13] = props.invalidPaths;
|
|
259
|
+
$[14] = t4;
|
|
260
|
+
} else t4 = $[14];
|
|
261
|
+
t3 = locales.filter(t4);
|
|
262
|
+
$[8] = locales;
|
|
263
|
+
$[9] = path;
|
|
264
|
+
$[10] = props.invalidPaths;
|
|
265
|
+
$[11] = t3;
|
|
266
|
+
} else t3 = $[11];
|
|
267
|
+
const invalidLocales = t3;
|
|
268
|
+
let t4;
|
|
269
|
+
if ($[15] !== props) {
|
|
270
|
+
t4 = getFieldProps(props);
|
|
271
|
+
$[15] = props;
|
|
272
|
+
$[16] = t4;
|
|
273
|
+
} else t4 = $[16];
|
|
274
|
+
let chrome;
|
|
275
|
+
if ($[17] !== t4) {
|
|
276
|
+
const { name: _name, onBlur: _onBlur, ...t5 } = t4;
|
|
277
|
+
chrome = t5;
|
|
278
|
+
$[17] = t4;
|
|
279
|
+
$[18] = chrome;
|
|
280
|
+
} else chrome = $[18];
|
|
281
|
+
let t5;
|
|
282
|
+
if ($[19] !== locale) {
|
|
283
|
+
t5 = locale !== void 0 ? { locale } : {};
|
|
284
|
+
$[19] = locale;
|
|
285
|
+
$[20] = t5;
|
|
286
|
+
} else t5 = $[20];
|
|
287
|
+
let t6;
|
|
288
|
+
if ($[21] !== field || $[22] !== path || $[23] !== props.disabled || $[24] !== props.onBlur || $[25] !== props.parentValue || $[26] !== props.readOnly) {
|
|
289
|
+
t6 = (input) => /* @__PURE__ */ jsx(NestedField, {
|
|
164
290
|
field: {
|
|
165
291
|
...field,
|
|
166
292
|
localized: false,
|
|
@@ -173,34 +299,40 @@ function LocalizedFieldEntry(props) {
|
|
|
173
299
|
...props.onBlur !== void 0 ? { onBlur: props.onBlur } : {},
|
|
174
300
|
parentValue: props.parentValue,
|
|
175
301
|
locale: input.locale,
|
|
302
|
+
hideLabel: true,
|
|
176
303
|
...props.disabled !== void 0 ? { disabled: props.disabled } : {},
|
|
177
304
|
...props.readOnly !== void 0 ? { readOnly: props.readOnly } : {}
|
|
178
305
|
});
|
|
179
|
-
$[
|
|
180
|
-
$[
|
|
181
|
-
$[
|
|
182
|
-
$[
|
|
183
|
-
$[
|
|
184
|
-
$[
|
|
185
|
-
$[
|
|
186
|
-
} else
|
|
187
|
-
let
|
|
188
|
-
if ($[
|
|
189
|
-
|
|
306
|
+
$[21] = field;
|
|
307
|
+
$[22] = path;
|
|
308
|
+
$[23] = props.disabled;
|
|
309
|
+
$[24] = props.onBlur;
|
|
310
|
+
$[25] = props.parentValue;
|
|
311
|
+
$[26] = props.readOnly;
|
|
312
|
+
$[27] = t6;
|
|
313
|
+
} else t6 = $[27];
|
|
314
|
+
let t7;
|
|
315
|
+
if ($[28] !== chrome || $[29] !== invalidLocales || $[30] !== locales || $[31] !== props.onChange || $[32] !== record || $[33] !== t5 || $[34] !== t6) {
|
|
316
|
+
t7 = /* @__PURE__ */ jsx(LocalizedField, {
|
|
190
317
|
...chrome,
|
|
191
318
|
locales,
|
|
192
319
|
value: record,
|
|
193
320
|
onChange: props.onChange,
|
|
194
|
-
|
|
321
|
+
...t5,
|
|
322
|
+
onLocaleChange: setLocale,
|
|
323
|
+
invalidLocales,
|
|
324
|
+
children: t6
|
|
195
325
|
});
|
|
196
|
-
$[
|
|
197
|
-
$[
|
|
198
|
-
$[
|
|
199
|
-
$[
|
|
200
|
-
$[
|
|
201
|
-
$[
|
|
202
|
-
|
|
203
|
-
|
|
326
|
+
$[28] = chrome;
|
|
327
|
+
$[29] = invalidLocales;
|
|
328
|
+
$[30] = locales;
|
|
329
|
+
$[31] = props.onChange;
|
|
330
|
+
$[32] = record;
|
|
331
|
+
$[33] = t5;
|
|
332
|
+
$[34] = t6;
|
|
333
|
+
$[35] = t7;
|
|
334
|
+
} else t7 = $[35];
|
|
335
|
+
return t7;
|
|
204
336
|
}
|
|
205
337
|
//#endregion
|
|
206
338
|
export { LocalizedField, LocalizedFieldEntry, useLocaleName };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalizedField.js","names":["ReactNode","Fieldset","usePanneauIntl","NestedField","useFieldsContext","cx","getFieldProps","FieldEntryProps","FieldProps","styles","LocalizedValue","Partial","Record","V","LocalizedInputProps","locale","label","value","onChange","onBlur","disabled","readOnly","required","LocalizedFieldProps","locales","children","props","localeClassName","useLocaleName","$","_c","intl","t0","name","formatDisplayName","type","undefined","text","toUpperCase","charAt","toLocaleUpperCase","slice","LocalizedField","description","errors","className","labelClassName","descriptionClassName","errorsClassName","localeName","t1","t2","next","updated","filled","Object","values","some","_temp","map","t3","entry","LocalizedFieldEntry","contextLocales","field","path","Array","isArray","record","length","keys","chrome","_name","_onBlur","parentValue","input","localized","help","t4","_c","styles"],"sources":["../../src/localized/LocalizedField.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { Fieldset, usePanneauIntl } from '@panneau/ui';\n\nimport { NestedField } from '../shared/DefinitionField';\nimport { useFieldsContext } from '../shared/context';\nimport { cx } from '../shared/cx';\nimport { getFieldProps } from '../shared/entry';\nimport type { FieldEntryProps, FieldProps } from '../shared/types';\nimport styles from './LocalizedField.module.css';\n\n/** A localized value: a value per locale (`{ fr: 'Été', en: 'Summer' }`). */\nexport type LocalizedValue<V> = Partial<Record<string, V | null>>;\n\n/** What `LocalizedField` gives the input of each locale. */\nexport interface LocalizedInputProps<V> {\n locale: string;\n /** Name of the locale in the UI's language, as the input's label. */\n label: string;\n value: V | null;\n onChange: (value: V | null) => void;\n onBlur?: () => void;\n disabled?: boolean;\n readOnly?: boolean;\n required?: boolean;\n}\n\nexport interface LocalizedFieldProps<V> extends FieldProps<LocalizedValue<V>> {\n /** Locales, in order. */\n locales: readonly string[];\n /** Renders the input of a locale. */\n children: (props: LocalizedInputProps<V>) => ReactNode;\n localeClassName?: string;\n}\n\n/** The name of a locale in the UI's language, capitalized (`Français`, `English`). */\nexport function useLocaleName(): (locale: string) => string {\n const intl = usePanneauIntl();\n return (locale) => {\n let name: string | undefined;\n try {\n name = intl.formatDisplayName(locale, { type: 'language' });\n } catch {\n name = undefined;\n }\n const text = name ?? locale.toUpperCase();\n return text.charAt(0).toLocaleUpperCase(intl.locale) + text.slice(1);\n };\n}\n\n/**\n * A value per locale, with an input for each locale under one legend. A value without any locale\n * filled is `null`.\n */\nexport function LocalizedField<V>({\n locales,\n children,\n value,\n onChange,\n onBlur,\n label,\n description,\n errors,\n disabled,\n readOnly,\n required,\n className,\n labelClassName,\n descriptionClassName,\n errorsClassName,\n localeClassName,\n}: LocalizedFieldProps<V>) {\n const localeName = useLocaleName();\n return (\n <Fieldset\n legend={label}\n description={description}\n errors={errors}\n isRequired={required}\n className={className}\n legendClassName={labelClassName}\n descriptionClassName={descriptionClassName}\n errorsClassName={errorsClassName}\n >\n <div className={styles.locales}>\n {locales.map((locale) => (\n <div key={locale} className={cx(styles.locale, localeClassName)}>\n {children({\n locale,\n label: localeName(locale),\n value: value?.[locale] ?? null,\n onChange: (next) => {\n const updated = { ...value, [locale]: next };\n const filled = Object.values(updated).some(\n (entry) =>\n entry !== null && entry !== undefined && entry !== '',\n );\n onChange?.(filled ? updated : null);\n },\n ...(onBlur !== undefined ? { onBlur } : {}),\n ...(disabled !== undefined ? { disabled } : {}),\n ...(readOnly !== undefined ? { readOnly } : {}),\n ...(required !== undefined ? { required } : {}),\n })}\n </div>\n ))}\n </div>\n </Fieldset>\n );\n}\n\n/**\n * A field of the definition with `localized: true`: the field of its type for each locale of the\n * fields context, each at its own path (`title.fr`).\n */\nexport function LocalizedFieldEntry(props: FieldEntryProps) {\n const { locales: contextLocales } = useFieldsContext();\n const { field, path, value } = props;\n const record =\n value !== null && typeof value === 'object' && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : {};\n const locales = contextLocales.length > 0 ? contextLocales : Object.keys(record);\n const { name: _name, onBlur: _onBlur, ...chrome } = getFieldProps(props);\n return (\n <LocalizedField<unknown>\n {...chrome}\n locales={locales}\n value={record}\n onChange={props.onChange}\n >\n {(input) => (\n <NestedField\n field={{ ...field, localized: false, label: input.label, help: undefined }}\n path={`${path}.${input.locale}`}\n value={input.value}\n onChange={input.onChange}\n {...(props.onBlur !== undefined ? { onBlur: props.onBlur } : {})}\n parentValue={props.parentValue}\n locale={input.locale}\n {...(props.disabled !== undefined ? { disabled: props.disabled } : {})}\n {...(props.readOnly !== undefined ? { readOnly: props.readOnly } : {})}\n />\n )}\n </LocalizedField>\n );\n}\n"],"mappings":";;;;;;;;;;AAoCA,SAAO4B,gBAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CACH,MAAAC,OAAa7B,eAAe;CAAE,IAAA8B;CAAA,IAAAH,EAAA,OAAAE,MAAA;EACvBC,MAAAjB,WAAA;GACCkB,IAAAA;GACJ,IAAA;IACIA,OAAOF,KAAIG,kBAAmBnB,QAAQ,EAAAoB,MAAQ,WAAW,CAAC;GAAtD,QAAA;IAEJF,OAAOG,KAAAA;GAAH;GAER,MAAAC,OAAaJ,QAAQlB,OAAMuB,YAAa;GAAE,OACnCD,KAAIE,OAAQ,CAAC,CAAC,CAAAC,kBAAmBT,KAAIhB,MAAO,IAAIsB,KAAII,MAAO,CAAC;EAAC;EACvEZ,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,OATMG;AASN;;;;;AAOL,SAAOU,eAAAV,IAAA;CAAA,MAAAH,IAAAC,EAAA,EAAA;CAA2B,MAAA,EAAAN,SAAAC,UAAAR,OAAAC,UAAAC,QAAAH,OAAA2B,aAAAC,QAAAxB,UAAAC,UAAAC,UAAAuB,WAAAC,gBAAAC,sBAAAC,iBAAArB,oBAAAK;CAkB9B,MAAAiB,aAAmBrB,cAAc;CAAE,IAAAsB;C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LocalizedField.js","names":["Plus","ReactNode","useState","isFilled","Fieldset","Icon","SegmentedControl","usePanneauIntl","NestedField","useFieldsContext","cx","getFieldProps","messages","useRevealer","FieldEntryProps","FieldProps","styles","LocalizedValue","Partial","Record","V","LocalizedInputProps","locale","label","value","onChange","onBlur","disabled","readOnly","required","LocalizedFieldProps","locales","children","props","onLocaleChange","invalidLocales","localeClassName","useLocaleName","$","_c","intl","t0","name","formatDisplayName","type","undefined","text","toUpperCase","charAt","toLocaleUpperCase","slice","LocalizedField","description","errors","t1","className","labelClassName","descriptionClassName","errorsClassName","t2","localeName","uncontrolled","setUncontrolled","wanted","t3","includes","current","t4","t5","option","index","invalid","empty","addable","textValue","formatMessage","localeInvalid","addLocale","localeEmpty","marker","map","options","length","next","t6","t7","option_0","next_0","updated","filled","Object","values","some","_temp","entry","localeOf","path","fieldPath","find","startsWith","LocalizedFieldEntry","contextLocales","field","Array","isArray","record","keys","setLocale","revealed","found","invalidPaths","candidate","filter","chrome","_name","_onBlur","parentValue","input","localized","help","_c","styles"],"sources":["../../src/localized/LocalizedField.tsx"],"sourcesContent":["import { Plus } from 'lucide-react';\nimport { type ReactNode, useState } from 'react';\n\nimport { isFilled } from '@panneau/protocol/runtime';\nimport { Fieldset, Icon, SegmentedControl, usePanneauIntl } from '@panneau/ui';\n\nimport { NestedField } from '../shared/DefinitionField';\nimport { useFieldsContext } from '../shared/context';\nimport { cx } from '../shared/cx';\nimport { getFieldProps } from '../shared/entry';\nimport { messages } from '../shared/messages';\nimport { useRevealer } from '../shared/reveal';\nimport type { FieldEntryProps, FieldProps } from '../shared/types';\nimport styles from './LocalizedField.module.css';\n\n/** A localized value: a value per locale (`{ fr: 'Été', en: 'Summer' }`). */\nexport type LocalizedValue<V> = Partial<Record<string, V | null>>;\n\n/** What `LocalizedField` gives the input of each locale. */\nexport interface LocalizedInputProps<V> {\n locale: string;\n /**\n * Name of the locale in the UI's language. The field shows the locales: give it to the input\n * as its `aria-label`, not as a visible label.\n */\n label: string;\n value: V | null;\n onChange: (value: V | null) => void;\n onBlur?: () => void;\n disabled?: boolean;\n readOnly?: boolean;\n required?: boolean;\n}\n\nexport interface LocalizedFieldProps<V> extends FieldProps<LocalizedValue<V>> {\n /** Locales, in order. The first one shows first. */\n locales: readonly string[];\n /** Renders the input of a locale. */\n children: (props: LocalizedInputProps<V>) => ReactNode;\n /** The locale shown. Controlled with `onLocaleChange`. */\n locale?: string;\n onLocaleChange?: (locale: string) => void;\n /** Locales whose value has errors: their switch shows it. */\n invalidLocales?: readonly string[];\n localeClassName?: string;\n}\n\n/** The name of a locale in the UI's language, capitalized (`Français`, `English`). */\nexport function useLocaleName(): (locale: string) => string {\n const intl = usePanneauIntl();\n return (locale) => {\n let name: string | undefined;\n try {\n name = intl.formatDisplayName(locale, { type: 'language' });\n } catch {\n name = undefined;\n }\n const text = name ?? locale.toUpperCase();\n return text.charAt(0).toLocaleUpperCase(intl.locale) + text.slice(1);\n };\n}\n\n/**\n * A value per locale: one locale at a time, under the field's label, with a switch at the end of\n * the label's line for the others. The switch marks the locales in error, and the empty ones: to\n * fill in when the field is required, to add otherwise. A value without any locale filled is\n * `null`.\n */\nexport function LocalizedField<V>({\n locales,\n children,\n value,\n onChange,\n onBlur,\n label,\n description,\n errors,\n disabled,\n readOnly,\n required,\n locale,\n onLocaleChange,\n invalidLocales = [],\n className,\n labelClassName,\n descriptionClassName,\n errorsClassName,\n localeClassName,\n}: LocalizedFieldProps<V>) {\n const intl = usePanneauIntl();\n const localeName = useLocaleName();\n const [uncontrolled, setUncontrolled] = useState(locales[0]);\n const wanted = locale ?? uncontrolled;\n const current = wanted !== undefined && locales.includes(wanted) ? wanted : locales[0];\n\n const options = locales.map((option, index) => {\n const name = localeName(option);\n const invalid = invalidLocales.includes(option);\n const empty = !isFilled(value?.[option]);\n // An empty locale after the first is a translation to add, unless every locale is required.\n const addable = !invalid && empty && required !== true && index > 0;\n let textValue = name;\n if (invalid) {\n textValue = intl.formatMessage(messages.localeInvalid, { locale: name });\n } else if (addable) {\n textValue = intl.formatMessage(messages.addLocale, { locale: name });\n } else if (empty) {\n textValue = intl.formatMessage(messages.localeEmpty, { locale: name });\n }\n return {\n value: option,\n textValue,\n label: (\n <span className={styles.option}>\n {addable ? <Icon icon={Plus} size=\"sm\" /> : null}\n {option.toUpperCase()}\n {invalid ? <span className={cx(styles.marker, styles.invalid)} /> : null}\n {!invalid && empty && required === true ? (\n <span className={cx(styles.marker, styles.empty)} />\n ) : null}\n </span>\n ),\n };\n });\n\n return (\n <Fieldset\n legend={label}\n legendEnd={\n locales.length > 1 ? (\n <SegmentedControl\n size=\"sm\"\n aria-label={intl.formatMessage(messages.locales)}\n options={options}\n {...(current !== undefined ? { value: current } : {})}\n onChange={(next) => {\n setUncontrolled(next);\n onLocaleChange?.(next);\n }}\n />\n ) : undefined\n }\n description={description}\n errors={errors}\n isRequired={required}\n className={className}\n legendClassName={labelClassName}\n descriptionClassName={descriptionClassName}\n errorsClassName={errorsClassName}\n >\n {locales.map((option) => (\n // Every locale stays mounted: inputs keep their state, and errors can be revealed.\n <div\n key={option}\n className={cx(styles.locale, localeClassName)}\n hidden={option !== current}\n >\n {children({\n locale: option,\n label: localeName(option),\n value: value?.[option] ?? null,\n onChange: (next) => {\n const updated = { ...value, [option]: next };\n const filled = Object.values(updated).some(\n (entry) => entry !== null && entry !== undefined && entry !== '',\n );\n onChange?.(filled ? updated : null);\n },\n ...(onBlur !== undefined ? { onBlur } : {}),\n ...(disabled !== undefined ? { disabled } : {}),\n ...(readOnly !== undefined ? { readOnly } : {}),\n ...(required !== undefined ? { required } : {}),\n })}\n </div>\n ))}\n </Fieldset>\n );\n}\n\n/** The locale of a path inside a localized field (`title.en`, `body.en.0` in `title`), if any. */\nfunction localeOf(path: string, fieldPath: string, locales: readonly string[]) {\n return locales.find(\n (locale) => path === `${fieldPath}.${locale}` || path.startsWith(`${fieldPath}.${locale}.`),\n );\n}\n\n/**\n * A field of the definition with `localized: true`: the field of its type for each locale of the\n * fields context, each at its own path (`title.fr`). It shows the locale of a path the form\n * reveals, such as the first error on submit.\n */\nexport function LocalizedFieldEntry(props: FieldEntryProps) {\n const { locales: contextLocales } = useFieldsContext();\n const { field, path, value } = props;\n const record =\n value !== null && typeof value === 'object' && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : {};\n const locales = contextLocales.length > 0 ? contextLocales : Object.keys(record);\n const [locale, setLocale] = useState(locales[0]);\n useRevealer((revealed) => {\n const found = localeOf(revealed, path, locales);\n if (found !== undefined) {\n setLocale(found);\n }\n });\n const invalidLocales = locales.filter((candidate) =>\n (props.invalidPaths ?? []).some(\n (invalid) => localeOf(invalid, path, [candidate]) !== undefined,\n ),\n );\n const { name: _name, onBlur: _onBlur, ...chrome } = getFieldProps(props);\n return (\n <LocalizedField<unknown>\n {...chrome}\n locales={locales}\n value={record}\n onChange={props.onChange}\n {...(locale !== undefined ? { locale } : {})}\n onLocaleChange={setLocale}\n invalidLocales={invalidLocales}\n >\n {(input) => (\n <NestedField\n field={{ ...field, localized: false, label: input.label, help: undefined }}\n path={`${path}.${input.locale}`}\n value={input.value}\n onChange={input.onChange}\n {...(props.onBlur !== undefined ? { onBlur: props.onBlur } : {})}\n parentValue={props.parentValue}\n locale={input.locale}\n hideLabel\n {...(props.disabled !== undefined ? { disabled: props.disabled } : {})}\n {...(props.readOnly !== undefined ? { readOnly: props.readOnly } : {})}\n />\n )}\n </LocalizedField>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgDA,SAAOqC,gBAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CACH,MAAAC,OAAajC,eAAe;CAAE,IAAAkC;CAAA,IAAAH,EAAA,OAAAE,MAAA;EACvBC,MAAAnB,WAAA;GACCoB,IAAAA;GACJ,IAAA;IACIA,OAAOF,KAAIG,kBAAmBrB,QAAQ,EAAAsB,MAAQ,WAAW,CAAC;GAAtD,QAAA;IAEJF,OAAOG,KAAAA;GAAH;GAER,MAAAC,OAAaJ,QAAQpB,OAAMy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AAYmB,KAAAA,IAAjB,EAAAnB,QAAuCO,MAAKP,OAAa,IAAzD,CAAyD;GACjD,aAAAO,MAAKmF;GACV,QAAAC,MAAK/F;GACb,WAAA;GAAS,GACJW,MAAKN,aAAckB,KAAAA,IAAnB,EAAAlB,UAA2CM,MAAKN,SAAe,IAA/D,CAA+D;GAAC,GAChEM,MAAKL,aAAciB,KAAAA,IAAnB,EAAAjB,UAA2CK,MAAKL,SAAe,IAA/D,CAA+D;EAAC,CAAA;EAE5EU,EAAA,MAAAgE;EAAAhE,EAAA,MAAA0D;EAAA1D,EAAA,MAAAL,MAAAN;EAAAW,EAAA,MAAAL,MAAAP;EAAAY,EAAA,MAAAL,MAAAmF;EAAA9E,EAAA,MAAAL,MAAAL;EAAAU,EAAA,MAAA8C;CAAA,OAAAA,KAAA9C,EAAA;CAAA,IAAA+C;CAAA,IAAA/C,EAAA,QAAA2E,UAAA3E,EAAA,QAAAH,kBAAAG,EAAA,QAAAP,WAAAO,EAAA,QAAAL,MAAAR,YAAAa,EAAA,QAAAmE,UAAAnE,EAAA,QAAA8B,MAAA9B,EAAA,QAAA8C,IAAA;EAtBLC,KAAA,oBAAC,gBAAD;GAAe,GACP4B;GACKlF;GACF0E,OAAAA;GACG,UAAAxE,MAAKR;GAAS,GACnB2C;GACWuC,gBAAAA;GACAxE;GAEfiD,UAAAA;EATU,CAAA;EAuBE9C,EAAA,MAAA2E;EAAA3E,EAAA,MAAAH;EAAAG,EAAA,MAAAP;EAAAO,EAAA,MAAAL,MAAAR;EAAAa,EAAA,MAAAmE;EAAAnE,EAAA,MAAA8B;EAAA9B,EAAA,MAAA8C;EAAA9C,EAAA,MAAA+C;CAAA,OAAAA,KAAA/C,EAAA;CAAA,OAvBjB+C;AAuBiB"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import "./LocalizedField.css";
|
|
2
2
|
//#region src/localized/LocalizedField.module.css
|
|
3
|
-
var locales = "panneau-localized-field-locales";
|
|
4
3
|
var locale = "panneau-localized-field-locale";
|
|
4
|
+
var option = "panneau-localized-field-option";
|
|
5
|
+
var marker = "panneau-localized-field-marker";
|
|
6
|
+
var invalid = "panneau-localized-field-invalid";
|
|
7
|
+
var empty = "panneau-localized-field-empty";
|
|
5
8
|
var LocalizedField_module_default = {
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
locale,
|
|
10
|
+
option,
|
|
11
|
+
marker,
|
|
12
|
+
invalid,
|
|
13
|
+
empty
|
|
8
14
|
};
|
|
9
15
|
//#endregion
|
|
10
|
-
export { LocalizedField_module_default as default, locale,
|
|
16
|
+
export { LocalizedField_module_default as default, empty, invalid, locale, marker, option };
|
|
11
17
|
|
|
12
18
|
//# sourceMappingURL=LocalizedField.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalizedField.module.js","names":[],"sources":["../../src/localized/LocalizedField.module.css"],"sourcesContent":[".
|
|
1
|
+
{"version":3,"file":"LocalizedField.module.js","names":[],"sources":["../../src/localized/LocalizedField.module.css"],"sourcesContent":[".locale {\n min-width: 0;\n}\n\n.locale[hidden] {\n display: none;\n}\n\n.option {\n display: inline-flex;\n align-items: center;\n gap: var(--panneau-space-1);\n letter-spacing: 0.02em;\n}\n\n.marker {\n flex: 0 0 auto;\n width: 0.45em;\n height: 0.45em;\n background-color: currentcolor;\n border-radius: 50%;\n}\n\n.invalid {\n color: var(--panneau-color-danger);\n}\n\n.empty {\n color: var(--panneau-color-warning);\n}\n"],"mappings":""}
|
|
@@ -4,10 +4,10 @@ import { messages } from "../shared/messages.js";
|
|
|
4
4
|
import LocationField_module_default from "./LocationField.module.js";
|
|
5
5
|
import { LocationMap } from "./LocationMap.js";
|
|
6
6
|
import { c } from "react/compiler-runtime";
|
|
7
|
-
import {
|
|
7
|
+
import { X } from "lucide-react";
|
|
8
8
|
import { useEffect, useRef, useState } from "react";
|
|
9
|
+
import { ComboBox, Fieldset, IconButton, NumberInput, TextInput, usePanneauIntl } from "@panneau/ui";
|
|
9
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { X } from "lucide-react";
|
|
11
11
|
//#region src/location/LocationField.tsx
|
|
12
12
|
/** OpenStreetMap's standard tiles: fine for an admin panel, with their credit. */
|
|
13
13
|
var OPEN_STREET_MAP_TILES = {
|
|
@@ -5,10 +5,10 @@ import { messages } from "../shared/messages.js";
|
|
|
5
5
|
import { toReferences, useRelationReferences } from "../shared/relation.js";
|
|
6
6
|
import RelationField_module_default from "./RelationField.module.js";
|
|
7
7
|
import { c } from "react/compiler-runtime";
|
|
8
|
-
import {
|
|
8
|
+
import { X } from "lucide-react";
|
|
9
9
|
import { useEffect, useState } from "react";
|
|
10
|
+
import { ComboBox, Fieldset, IconButton, usePanneauIntl } from "@panneau/ui";
|
|
10
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { X } from "lucide-react";
|
|
12
12
|
//#region src/relation/RelationField.tsx
|
|
13
13
|
/** The id of the "Create “…”" option of the picker. */
|
|
14
14
|
var CREATE_ID = "\0create";
|
|
@@ -4,10 +4,10 @@ import { messages } from "../shared/messages.js";
|
|
|
4
4
|
import RepeaterField_module_default from "./RepeaterField.module.js";
|
|
5
5
|
import { NestedField } from "../shared/DefinitionField.js";
|
|
6
6
|
import { c } from "react/compiler-runtime";
|
|
7
|
-
import {
|
|
7
|
+
import { ArrowDown, ArrowUp, Plus, Trash2 } from "lucide-react";
|
|
8
8
|
import { useId } from "react";
|
|
9
|
+
import { Button, Fieldset, IconButton, Menu, MenuItem, MenuTrigger, usePanneauIntl } from "@panneau/ui";
|
|
9
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { ArrowDown, ArrowUp, Plus, Trash2 } from "lucide-react";
|
|
11
11
|
//#region src/repeater/RepeaterField.tsx
|
|
12
12
|
function defaults(fields) {
|
|
13
13
|
return Object.fromEntries(fields.flatMap((field) => field.default !== void 0 ? [[field.name, field.default]] : []));
|
|
@@ -14,6 +14,8 @@ export interface NestedFieldProps {
|
|
|
14
14
|
parentValue?: unknown;
|
|
15
15
|
/** The locale of the value, in a localized field. */
|
|
16
16
|
locale?: string;
|
|
17
|
+
/** Renders the field without a visible label, named by its label for assistive technologies. */
|
|
18
|
+
hideLabel?: boolean;
|
|
17
19
|
disabled?: boolean;
|
|
18
20
|
readOnly?: boolean;
|
|
19
21
|
className?: string;
|
|
@@ -24,7 +26,7 @@ export interface NestedFieldProps {
|
|
|
24
26
|
* one, it uses `value` and `onChange`, and hides itself when its `visibleWhen` condition on the
|
|
25
27
|
* parent value is false.
|
|
26
28
|
*/
|
|
27
|
-
export declare function NestedField({ field, path, value, onChange, onBlur, errors, parentValue, locale, disabled, readOnly, className, }: NestedFieldProps): import("react").JSX.Element | null;
|
|
29
|
+
export declare function NestedField({ field, path, value, onChange, onBlur, errors, parentValue, locale, hideLabel, disabled, readOnly, className, }: NestedFieldProps): import("react").JSX.Element | null;
|
|
28
30
|
/**
|
|
29
31
|
* Renders a field of the definition with the entry of its type: from the fields context, or a
|
|
30
32
|
* built-in one. A localized field renders an input per locale. A type without an entry renders a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefinitionField.d.ts","sourceRoot":"","sources":["../../src/shared/DefinitionField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAU/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,KAAK,CAAC;IACb,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B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