@panneau/fields 5.0.0-alpha.18 → 5.0.0-alpha.19
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 +23 -0
- package/dist/address/AddressField.js +3 -3
- package/dist/compound/Compound.css +26 -0
- package/dist/compound/Compound.module.js +16 -0
- package/dist/compound/Compound.module.js.map +1 -0
- package/dist/compound/compound.d.ts +56 -0
- package/dist/compound/compound.d.ts.map +1 -0
- package/dist/compound/compound.js +186 -0
- package/dist/compound/compound.js.map +1 -0
- package/dist/country/CountryField.js +1 -1
- package/dist/credits/CreditsField.d.ts +15 -0
- package/dist/credits/CreditsField.d.ts.map +1 -0
- package/dist/credits/CreditsField.js +58 -0
- package/dist/credits/CreditsField.js.map +1 -0
- package/dist/credits/credits.d.ts +18 -0
- package/dist/credits/credits.d.ts.map +1 -0
- package/dist/credits/credits.js +33 -0
- package/dist/credits/credits.js.map +1 -0
- package/dist/credits/index.d.ts +5 -0
- package/dist/credits/index.d.ts.map +1 -0
- package/dist/credits/index.js +3 -0
- package/dist/embed/EmbedField.js +2 -2
- package/dist/file/FileField.js +3 -3
- package/dist/group/GroupField.d.ts +7 -1
- package/dist/group/GroupField.d.ts.map +1 -1
- package/dist/group/GroupField.js +60 -68
- package/dist/group/GroupField.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/json/JsonField.js +1 -1
- package/dist/link/LinkField.js +3 -3
- package/dist/localized/LocalizedField.js +3 -3
- package/dist/location/LocationField.js +3 -3
- package/dist/location/LocationMap.js +1 -1
- package/dist/money/MoneyField.js +1 -1
- package/dist/relation/RelationField.js +3 -3
- package/dist/repeater/RepeaterField.d.ts +12 -1
- package/dist/repeater/RepeaterField.d.ts.map +1 -1
- package/dist/repeater/RepeaterField.js +53 -49
- package/dist/repeater/RepeaterField.js.map +1 -1
- package/dist/sessions/SessionsField.d.ts +15 -0
- package/dist/sessions/SessionsField.d.ts.map +1 -0
- package/dist/sessions/SessionsField.js +49 -0
- package/dist/sessions/SessionsField.js.map +1 -0
- package/dist/sessions/index.d.ts +4 -0
- package/dist/sessions/index.d.ts.map +1 -0
- package/dist/sessions/index.js +1 -0
- package/dist/shared/CodeComboBox.js +1 -1
- package/dist/shared/DefinitionField.d.ts +3 -2
- package/dist/shared/DefinitionField.d.ts.map +1 -1
- package/dist/shared/DefinitionField.js +8 -4
- package/dist/shared/DefinitionField.js.map +1 -1
- package/dist/shared/builtIn.js +2 -2
- package/dist/shared/context.js +1 -1
- package/dist/slug/SlugField.js +3 -3
- package/dist/tel/TelField.js +1 -1
- 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 +14 -4
package/dist/group/GroupField.js
CHANGED
|
@@ -13,8 +13,8 @@ import { jsx } from "react/jsx-runtime";
|
|
|
13
13
|
* object through `onChange`.
|
|
14
14
|
*/
|
|
15
15
|
function GroupField(t0) {
|
|
16
|
-
const $ = c(
|
|
17
|
-
const { fields, path, name, value, onChange, onBlur, label, description, errors, disabled, readOnly, required, className, labelClassName, descriptionClassName, errorsClassName, fieldsClassName } = t0;
|
|
16
|
+
const $ = c(29);
|
|
17
|
+
const { fields, path, name, value, onChange, onBlur, label, description, errors, disabled, readOnly, required, className, labelClassName, descriptionClassName, errorsClassName, renderFields, fieldsClassName } = t0;
|
|
18
18
|
const base = path ?? name ?? "";
|
|
19
19
|
let t1;
|
|
20
20
|
if ($[0] !== value) {
|
|
@@ -24,70 +24,62 @@ function GroupField(t0) {
|
|
|
24
24
|
} else t1 = $[1];
|
|
25
25
|
const object = t1;
|
|
26
26
|
let t2;
|
|
27
|
-
if ($[2] !==
|
|
28
|
-
t2 =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
if ($[2] !== base || $[3] !== disabled || $[4] !== object || $[5] !== onBlur || $[6] !== onChange || $[7] !== readOnly) {
|
|
28
|
+
t2 = (field) => /* @__PURE__ */ jsx(NestedField, {
|
|
29
|
+
field,
|
|
30
|
+
path: base !== "" ? `${base}.${field.name}` : field.name,
|
|
31
|
+
value: object[field.name],
|
|
32
|
+
onChange: (next) => onChange?.({
|
|
33
|
+
...object,
|
|
34
|
+
[field.name]: next
|
|
35
|
+
}),
|
|
36
|
+
...onBlur !== void 0 ? { onBlur } : {},
|
|
37
|
+
parentValue: object,
|
|
38
|
+
...disabled !== void 0 ? { disabled } : {},
|
|
39
|
+
...readOnly !== void 0 ? { readOnly } : {}
|
|
40
|
+
});
|
|
41
|
+
$[2] = base;
|
|
42
|
+
$[3] = disabled;
|
|
43
|
+
$[4] = object;
|
|
44
|
+
$[5] = onBlur;
|
|
45
|
+
$[6] = onChange;
|
|
46
|
+
$[7] = readOnly;
|
|
47
|
+
$[8] = t2;
|
|
48
|
+
} else t2 = $[8];
|
|
49
|
+
const renderField = t2;
|
|
32
50
|
let t3;
|
|
33
|
-
if ($[
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
children: /* @__PURE__ */ jsx(NestedField, {
|
|
39
|
-
field,
|
|
40
|
-
path: base !== "" ? `${base}.${field.name}` : field.name,
|
|
41
|
-
value: object[field.name],
|
|
42
|
-
onChange: (next) => onChange?.({
|
|
43
|
-
...object,
|
|
44
|
-
[field.name]: next
|
|
45
|
-
}),
|
|
46
|
-
...onBlur !== void 0 ? { onBlur } : {},
|
|
47
|
-
parentValue: object,
|
|
48
|
-
...disabled !== void 0 ? { disabled } : {},
|
|
49
|
-
...readOnly !== void 0 ? { readOnly } : {}
|
|
50
|
-
})
|
|
51
|
-
}, field.name);
|
|
52
|
-
$[12] = base;
|
|
53
|
-
$[13] = disabled;
|
|
54
|
-
$[14] = object;
|
|
55
|
-
$[15] = onBlur;
|
|
56
|
-
$[16] = onChange;
|
|
57
|
-
$[17] = readOnly;
|
|
58
|
-
$[18] = t4;
|
|
59
|
-
} else t4 = $[18];
|
|
60
|
-
t3 = fields.map(t4);
|
|
61
|
-
$[4] = base;
|
|
62
|
-
$[5] = disabled;
|
|
63
|
-
$[6] = fields;
|
|
64
|
-
$[7] = object;
|
|
65
|
-
$[8] = onBlur;
|
|
66
|
-
$[9] = onChange;
|
|
67
|
-
$[10] = readOnly;
|
|
68
|
-
$[11] = t3;
|
|
69
|
-
} else t3 = $[11];
|
|
51
|
+
if ($[9] !== fieldsClassName) {
|
|
52
|
+
t3 = cx(GroupField_module_default.fields, fieldsClassName);
|
|
53
|
+
$[9] = fieldsClassName;
|
|
54
|
+
$[10] = t3;
|
|
55
|
+
} else t3 = $[10];
|
|
70
56
|
let t4;
|
|
71
|
-
if ($[
|
|
72
|
-
t4 = /* @__PURE__ */ jsx("div", {
|
|
57
|
+
if ($[11] !== fields || $[12] !== object || $[13] !== renderField || $[14] !== renderFields) {
|
|
58
|
+
t4 = renderFields !== void 0 ? renderFields(Object.fromEntries(fields.map((field_0) => [field_0.name, renderField(field_0)])), object) : /* @__PURE__ */ jsx("div", {
|
|
73
59
|
className: GroupField_module_default.flow,
|
|
74
|
-
children:
|
|
60
|
+
children: fields.map((field_1) => /* @__PURE__ */ jsx("div", {
|
|
61
|
+
className: cx(GroupField_module_default.cell, isWideField(field_1) && GroupField_module_default.wide),
|
|
62
|
+
children: renderField(field_1)
|
|
63
|
+
}, field_1.name))
|
|
75
64
|
});
|
|
76
|
-
$[
|
|
77
|
-
$[
|
|
78
|
-
|
|
65
|
+
$[11] = fields;
|
|
66
|
+
$[12] = object;
|
|
67
|
+
$[13] = renderField;
|
|
68
|
+
$[14] = renderFields;
|
|
69
|
+
$[15] = t4;
|
|
70
|
+
} else t4 = $[15];
|
|
79
71
|
let t5;
|
|
80
|
-
if ($[
|
|
72
|
+
if ($[16] !== t3 || $[17] !== t4) {
|
|
81
73
|
t5 = /* @__PURE__ */ jsx("div", {
|
|
82
|
-
className:
|
|
74
|
+
className: t3,
|
|
83
75
|
children: t4
|
|
84
76
|
});
|
|
85
|
-
$[
|
|
86
|
-
$[
|
|
87
|
-
$[
|
|
88
|
-
} else t5 = $[
|
|
77
|
+
$[16] = t3;
|
|
78
|
+
$[17] = t4;
|
|
79
|
+
$[18] = t5;
|
|
80
|
+
} else t5 = $[18];
|
|
89
81
|
let t6;
|
|
90
|
-
if ($[
|
|
82
|
+
if ($[19] !== className || $[20] !== description || $[21] !== descriptionClassName || $[22] !== errors || $[23] !== errorsClassName || $[24] !== label || $[25] !== labelClassName || $[26] !== required || $[27] !== t5) {
|
|
91
83
|
t6 = /* @__PURE__ */ jsx(Fieldset, {
|
|
92
84
|
legend: label,
|
|
93
85
|
description,
|
|
@@ -99,17 +91,17 @@ function GroupField(t0) {
|
|
|
99
91
|
errorsClassName,
|
|
100
92
|
children: t5
|
|
101
93
|
});
|
|
102
|
-
$[
|
|
103
|
-
$[
|
|
104
|
-
$[
|
|
105
|
-
$[
|
|
106
|
-
$[
|
|
107
|
-
$[
|
|
108
|
-
$[
|
|
109
|
-
$[
|
|
110
|
-
$[
|
|
111
|
-
$[
|
|
112
|
-
} else t6 = $[
|
|
94
|
+
$[19] = className;
|
|
95
|
+
$[20] = description;
|
|
96
|
+
$[21] = descriptionClassName;
|
|
97
|
+
$[22] = errors;
|
|
98
|
+
$[23] = errorsClassName;
|
|
99
|
+
$[24] = label;
|
|
100
|
+
$[25] = labelClassName;
|
|
101
|
+
$[26] = required;
|
|
102
|
+
$[27] = t5;
|
|
103
|
+
$[28] = t6;
|
|
104
|
+
} else t6 = $[28];
|
|
113
105
|
return t6;
|
|
114
106
|
}
|
|
115
107
|
/** The `group` type: its `fields`, as a nested object. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupField.js","names":["Field","Fieldset","NestedField","cx","getFieldProps","isWideField","FieldEntryProps","FieldProps","styles","GroupValue","Record","GroupFieldProps","fields","path","fieldsClassName","GroupField","t0","$","_c","name","
|
|
1
|
+
{"version":3,"file":"GroupField.js","names":["ReactNode","Field","Fieldset","NestedField","cx","getFieldProps","isWideField","FieldEntryProps","FieldProps","styles","GroupValue","Record","GroupFieldProps","fields","path","renderFields","parts","Readonly","value","fieldsClassName","GroupField","t0","$","_c","name","onChange","onBlur","label","description","errors","disabled","readOnly","required","className","labelClassName","descriptionClassName","errorsClassName","base","t1","object","t2","field","next","undefined","renderField","t3","t4","Object","fromEntries","map","field_0","flow","field_1","cell","wide","t5","t6","GroupFieldEntry","props","Array","isArray","_c","styles"],"sources":["../../src/group/GroupField.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport type { Field } from '@panneau/protocol';\nimport { Fieldset } from '@panneau/ui';\n\nimport { NestedField } from '../shared/DefinitionField';\nimport { cx } from '../shared/cx';\nimport { getFieldProps } from '../shared/entry';\nimport { isWideField } from '../shared/flow';\nimport type { FieldEntryProps, FieldProps } from '../shared/types';\nimport styles from './GroupField.module.css';\n\nexport type GroupValue = Record<string, unknown>;\n\nexport interface GroupFieldProps extends FieldProps<GroupValue> {\n /** The nested fields, rendered with the entries of the fields context. */\n fields: readonly Field[];\n /** Dot path of the group's value, the prefix of its fields' paths. Defaults to `name`. */\n path?: string;\n /**\n * Lays out the rendered fields, by name, instead of the flow of short fields side by side:\n * the layout of a compound field (decision 0065).\n */\n renderFields?: (parts: Readonly<Record<string, ReactNode>>, value: GroupValue) => ReactNode;\n fieldsClassName?: string;\n}\n\n/**\n * A nested object: its fields under a legend, short ones side by side (`isWideField()`). Each\n * field renders with the entry of its type, at the path `<group>.<field>`. Without a binding in the fields context, the group sets the whole\n * object through `onChange`.\n */\nexport function GroupField({\n fields,\n path,\n name,\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 renderFields,\n fieldsClassName,\n}: GroupFieldProps) {\n const base = path ?? name ?? '';\n const object = value ?? {};\n const renderField = (field: Field) => (\n <NestedField\n field={field}\n path={base !== '' ? `${base}.${field.name}` : field.name}\n value={object[field.name]}\n onChange={(next) => onChange?.({ ...object, [field.name]: next })}\n {...(onBlur !== undefined ? { onBlur } : {})}\n parentValue={object}\n {...(disabled !== undefined ? { disabled } : {})}\n {...(readOnly !== undefined ? { readOnly } : {})}\n />\n );\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={cx(styles.fields, fieldsClassName)}>\n {renderFields !== undefined ? (\n renderFields(\n Object.fromEntries(fields.map((field) => [field.name, renderField(field)])),\n object,\n )\n ) : (\n <div className={styles.flow}>\n {fields.map((field) => (\n <div\n key={field.name}\n className={cx(styles.cell, isWideField(field) && styles.wide)}\n >\n {renderField(field)}\n </div>\n ))}\n </div>\n )}\n </div>\n </Fieldset>\n );\n}\n\n/** The `group` type: its `fields`, as a nested object. */\nexport function GroupFieldEntry(props: FieldEntryProps) {\n const { value } = props;\n return (\n <GroupField\n {...getFieldProps(props)}\n fields={props.field.fields ?? []}\n path={props.path}\n value={\n value !== null && typeof value === 'object' && !Array.isArray(value)\n ? (value as GroupValue)\n : null\n }\n onChange={props.onChange}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,SAAOoB,WAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAoB,MAAA,EAAAV,QAAAC,MAAAU,MAAAN,OAAAO,UAAAC,QAAAC,OAAAC,aAAAC,QAAAC,UAAAC,UAAAC,UAAAC,WAAAC,gBAAAC,sBAAAC,iBAAArB,cAAAI,oBAAAE;CAoBvB,MAAAgB,OAAavB,QAAAU,QAAA;CAAmB,IAAAc;CAAA,IAAAhB,EAAA,OAAAJ,OAAA;EACjBoB,KAAApB,SAAA,CAAU;EAACI,EAAA,KAAAJ;EAAAI,EAAA,KAAAgB;CAAA,OAAAA,KAAAhB,EAAA;CAA1B,MAAAiB,SAAeD;CAAY,IAAAE;CAAA,IAAAlB,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ApC,IAAAC,EAAA,EAAA;CACH,MAAA,EAAAL,UAAkBwC;CAAM,IAAArC;CAAA,IAAAC,EAAA,OAAAoC,OAAA;EAGZrC,KAAAhB,cAAcqD,KAAK;EAACpC,EAAA,KAAAoC;EAAApC,EAAA,KAAAD;CAAA,OAAAA,KAAAC,EAAA;CAAA,IAAAgB;CAAA,IAAAhB,EAAA,OAAAoC,MAAAjB,MAAA5B,QAAA;EAChByB,KAAAoB,MAAKjB,MAAM5B,UAAX,CAAA;EAAwBS,EAAA,KAAAoC,MAAAjB,MAAA5B;EAAAS,EAAA,KAAAgB;CAAA,OAAAA,KAAAhB,EAAA;CAG5B,MAAAkB,KAAAtB,UAAU,QAAQ,OAAOA,UAAU,YAAnC,CAAgDyC,MAAKC,QAAS1C,KAAK,IAC5DA,QADP;CAEU,IAAA2B;CAAA,IAAAvB,EAAA,OAAAoC,MAAAjC,YAAAH,EAAA,OAAAoC,MAAA5C,QAAAQ,EAAA,OAAAD,MAAAC,EAAA,OAAAgB,MAAAhB,EAAA,OAAAkB,IAAA;EAPlBK,KAAA,oBAAC,YAAD;GAAW,GACHxB;GACI,QAAAiB;GACF,MAAAoB,MAAK5C;GAEP,OAAA0B;GAIM,UAAAkB,MAAKjC;EAAS,CAAA;EAC1BH,EAAA,KAAAoC,MAAAjC;EAAAH,EAAA,KAAAoC,MAAA5C;EAAAQ,EAAA,KAAAD;EAAAC,EAAA,KAAAgB;EAAAhB,EAAA,KAAAkB;EAAAlB,EAAA,KAAAuB;CAAA,OAAAA,KAAAvB,EAAA;CAAA,OAVFuB;AAUE"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export type { GeocodingResult, GeocodingSource, MapTiles, MapsConfig } from './l
|
|
|
9
9
|
export { type NominatimSourceOptions, createNominatimSource } from './location/nominatim.js';
|
|
10
10
|
export type { FieldEntry, FieldEntryProps, FieldProps } from './shared/types.js';
|
|
11
11
|
export { isWideField } from './shared/flow.js';
|
|
12
|
+
export { type CompoundFieldEntry, type CompoundFieldOptions, type CompoundLayoutProps, type CompoundSummary, type CompoundSummaryContext, defineCompoundField, restParts, summarizeCompound, } from './compound/compound.js';
|
|
12
13
|
export { MissingFieldEntry } from './missing/MissingField.js';
|
|
13
14
|
export { type RevealRegistry, type Revealer, RevealContext, createRevealRegistry, useRevealer, } from './shared/reveal.js';
|
|
14
15
|
export { type FileFieldBaseProps, FileField, FileFieldEntry, type FileFieldProps, type FileValue, type MultipleFileFieldProps, type SingleFileFieldProps, isFileValue, toFiles, } from './file/FileField.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EACH,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,aAAa,EACb,gBAAgB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACH,QAAQ,EACR,SAAS,EACT,aAAa,EACb,UAAU,EACV,aAAa,EACb,UAAU,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,oBAAoB,EACpB,YAAY,EACZ,qBAAqB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,sBAAsB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxF,YAAY,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B,CAAC;AAC3D,OAAO,EACH,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,aAAa,EACb,oBAAoB,EACpB,WAAW,GACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,KAAK,kBAAkB,EACvB,SAAS,EACT,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,WAAW,EACX,OAAO,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EACH,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,QAAQ,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { FieldsProvider, getParentPath, useFieldsContext } from "./shared/context.js";
|
|
2
1
|
import { findRule, getAccept, getFieldProps, getMaxSize, getRuleNumber, isRequired } from "./shared/entry.js";
|
|
2
|
+
import { isWideField } from "./shared/flow.js";
|
|
3
|
+
import { FieldsProvider, getParentPath, useFieldsContext } from "./shared/context.js";
|
|
3
4
|
import { RevealContext, createRevealRegistry, useRevealer } from "./shared/reveal.js";
|
|
4
5
|
import { MissingFieldEntry } from "./missing/MissingField.js";
|
|
5
6
|
import { FilePicker } from "./upload/FilePicker.js";
|
|
@@ -8,11 +9,11 @@ import { UploadList } from "./upload/UploadList.js";
|
|
|
8
9
|
import { useRejectionMessage } from "./upload/useRejectionMessage.js";
|
|
9
10
|
import { useUploads } from "./upload/useUploads.js";
|
|
10
11
|
import { FileField, FileFieldEntry, isFileValue, toFiles } from "./file/FileField.js";
|
|
11
|
-
import { isWideField } from "./shared/flow.js";
|
|
12
12
|
import { createRelationSource, toReferences, useRelationReferences } from "./shared/relation.js";
|
|
13
13
|
import { builtInFields, fieldsPlugin } from "./shared/builtIn.js";
|
|
14
14
|
import { DefinitionField, NestedField } from "./shared/DefinitionField.js";
|
|
15
15
|
import { createFieldCheckSource } from "./shared/check.js";
|
|
16
16
|
import { createEmbedSource } from "./shared/embed.js";
|
|
17
17
|
import { createNominatimSource } from "./location/nominatim.js";
|
|
18
|
-
|
|
18
|
+
import { defineCompoundField, restParts, summarizeCompound } from "./compound/compound.js";
|
|
19
|
+
export { DefinitionField, FieldsProvider, FileField, FileFieldEntry, FilePicker, MissingFieldEntry, NestedField, RevealContext, UploadList, builtInFields, createEmbedSource, createFieldCheckSource, createNominatimSource, createRelationSource, createRevealRegistry, defineCompoundField, fieldsPlugin, findRule, formatSize, getAccept, getFieldProps, getMaxSize, getParentPath, getRuleNumber, isFileValue, isRequired, isWideField, matchesMime, restParts, summarizeCompound, toFiles, toReferences, useFieldsContext, useRejectionMessage, useRelationReferences, useRevealer, useUploads };
|
package/dist/json/JsonField.js
CHANGED
|
@@ -2,9 +2,9 @@ import { getFieldProps, getSetting, isNumber } from "../shared/entry.js";
|
|
|
2
2
|
import { messages } from "../shared/messages.js";
|
|
3
3
|
import JsonField_module_default from "./JsonField.module.js";
|
|
4
4
|
import { c } from "react/compiler-runtime";
|
|
5
|
-
import { useState } from "react";
|
|
6
5
|
import { TextArea, usePanneauIntl } from "@panneau/ui";
|
|
7
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { useState } from "react";
|
|
8
8
|
//#region src/json/JsonField.tsx
|
|
9
9
|
/** The text of a value: indented JSON, or the text that doesn't parse as it is. */
|
|
10
10
|
function toText(value) {
|
package/dist/link/LinkField.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useFieldsContext } from "../shared/context.js";
|
|
2
1
|
import { getFieldProps, getSetting, isString } from "../shared/entry.js";
|
|
2
|
+
import { useFieldsContext } from "../shared/context.js";
|
|
3
3
|
import { messages } from "../shared/messages.js";
|
|
4
4
|
import { LocalizedField } from "../localized/LocalizedField.js";
|
|
5
5
|
import { TextField } from "../text/TextField.js";
|
|
@@ -13,10 +13,10 @@ import { usePageSearch } from "./pages.js";
|
|
|
13
13
|
import { DefinitionField } from "../shared/DefinitionField.js";
|
|
14
14
|
import { c } from "react/compiler-runtime";
|
|
15
15
|
import { getLinkNewTab, getLinkTypes } from "@panneau/protocol/runtime";
|
|
16
|
-
import { File, FileText, Globe, Hash, Mail, Phone } from "lucide-react";
|
|
17
|
-
import { useState } from "react";
|
|
18
16
|
import { Checkbox, ComboBox, Fieldset, SegmentedControl, TextInput, usePanneauIntl } from "@panneau/ui";
|
|
19
17
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
import { File, FileText, Globe, Hash, Mail, Phone } from "lucide-react";
|
|
19
|
+
import { useState } from "react";
|
|
20
20
|
//#region src/link/LinkField.tsx
|
|
21
21
|
var DEFAULT_TYPES = [
|
|
22
22
|
{ id: "url" },
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { useFieldsContext } from "../shared/context.js";
|
|
2
1
|
import { cx } from "../shared/cx.js";
|
|
3
2
|
import { getFieldProps } from "../shared/entry.js";
|
|
3
|
+
import { useFieldsContext } from "../shared/context.js";
|
|
4
4
|
import { messages } from "../shared/messages.js";
|
|
5
5
|
import { useRevealer } from "../shared/reveal.js";
|
|
6
6
|
import LocalizedField_module_default from "./LocalizedField.module.js";
|
|
7
7
|
import { NestedField } from "../shared/DefinitionField.js";
|
|
8
8
|
import { c } from "react/compiler-runtime";
|
|
9
9
|
import { isFilled } from "@panneau/protocol/runtime";
|
|
10
|
-
import { Plus } from "lucide-react";
|
|
11
|
-
import { useState } from "react";
|
|
12
10
|
import { Fieldset, Icon, SegmentedControl, usePanneauIntl } from "@panneau/ui";
|
|
13
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { Plus } from "lucide-react";
|
|
13
|
+
import { useState } from "react";
|
|
14
14
|
//#region src/localized/LocalizedField.tsx
|
|
15
15
|
/** The name of a locale in the UI's language, capitalized (`Français`, `English`). */
|
|
16
16
|
function useLocaleName() {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { useFieldsContext } from "../shared/context.js";
|
|
2
1
|
import { getFieldProps, getSetting, isNumber, isString } from "../shared/entry.js";
|
|
2
|
+
import { useFieldsContext } from "../shared/context.js";
|
|
3
3
|
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 { useAddressSearch } from "./search.js";
|
|
7
7
|
import { c } from "react/compiler-runtime";
|
|
8
|
-
import { X } from "lucide-react";
|
|
9
|
-
import { useRef, useState } from "react";
|
|
10
8
|
import { ComboBox, Fieldset, IconButton, NumberInput, TextInput, usePanneauIntl } from "@panneau/ui";
|
|
11
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { X } from "lucide-react";
|
|
11
|
+
import { useRef, useState } from "react";
|
|
12
12
|
//#region src/location/LocationField.tsx
|
|
13
13
|
/** OpenStreetMap's standard tiles: fine for an admin panel, with their credit. */
|
|
14
14
|
var OPEN_STREET_MAP_TILES = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import LocationField_module_default from "./LocationField.module.js";
|
|
2
2
|
import { LEAFLET_CSS } from "./leafletCss.js";
|
|
3
3
|
import { c } from "react/compiler-runtime";
|
|
4
|
-
import { useEffect, useEffectEvent, useRef } from "react";
|
|
5
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { useEffect, useEffectEvent, useRef } from "react";
|
|
6
6
|
//#region src/location/LocationMap.tsx
|
|
7
7
|
var STYLE_ID = "panneau-leaflet-css";
|
|
8
8
|
/** Loads Leaflet, outside the component: the React Compiler doesn't handle `import()`. */
|
package/dist/money/MoneyField.js
CHANGED
|
@@ -3,9 +3,9 @@ import { messages } from "../shared/messages.js";
|
|
|
3
3
|
import { CURRENCY_CODES, getCurrencyName, getMoneyFormatOptions, isMoneyValue, toMoneyValue } from "./money.js";
|
|
4
4
|
import { c } from "react/compiler-runtime";
|
|
5
5
|
import { fromMinorUnits } from "@panneau/protocol/runtime";
|
|
6
|
-
import { useState } from "react";
|
|
7
6
|
import { NumberInput, Select, usePanneauIntl } from "@panneau/ui";
|
|
8
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { useState } from "react";
|
|
9
9
|
//#region src/money/MoneyField.tsx
|
|
10
10
|
/**
|
|
11
11
|
* An amount and its currency, `{ amount, currency }`, with the amount in minor units (decision
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { useFieldsContext } from "../shared/context.js";
|
|
2
1
|
import { cx } from "../shared/cx.js";
|
|
3
2
|
import { getFieldProps } from "../shared/entry.js";
|
|
3
|
+
import { useFieldsContext } from "../shared/context.js";
|
|
4
4
|
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 { X } from "lucide-react";
|
|
9
|
-
import { useEffect, useState } from "react";
|
|
10
8
|
import { ComboBox, Fieldset, IconButton, usePanneauIntl } from "@panneau/ui";
|
|
11
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { X } from "lucide-react";
|
|
11
|
+
import { useEffect, useState } from "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";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
1
2
|
import type { BlockType, Field } from '@panneau/protocol';
|
|
2
3
|
import type { FieldEntryProps, FieldProps } from '../shared/types.js';
|
|
3
4
|
/** An item of a repeater. Typed blocks have their type in `type`. */
|
|
@@ -13,6 +14,16 @@ export interface RepeaterFieldProps extends FieldProps<RepeaterItem[]> {
|
|
|
13
14
|
min?: number;
|
|
14
15
|
/** Most items: no item can be added above it. */
|
|
15
16
|
max?: number;
|
|
17
|
+
/**
|
|
18
|
+
* The title of an item, after its number: a summary of its values (decision 0065). Without
|
|
19
|
+
* one, or when it gives `null`, the label of its type, or "Item 2".
|
|
20
|
+
*/
|
|
21
|
+
itemTitle?: (item: RepeaterItem, index: number) => string | null;
|
|
22
|
+
/**
|
|
23
|
+
* Lays out the rendered fields of an item, by name, instead of one under the other: the
|
|
24
|
+
* layout of a compound field (decision 0065).
|
|
25
|
+
*/
|
|
26
|
+
renderFields?: (parts: Readonly<Record<string, ReactNode>>, item: RepeaterItem) => ReactNode;
|
|
16
27
|
itemClassName?: string;
|
|
17
28
|
}
|
|
18
29
|
/**
|
|
@@ -20,7 +31,7 @@ export interface RepeaterFieldProps extends FieldProps<RepeaterItem[]> {
|
|
|
20
31
|
* can be added, moved and removed. Each field renders at the path `<list>.<index>.<field>`. An
|
|
21
32
|
* empty list is `null`.
|
|
22
33
|
*/
|
|
23
|
-
export declare function RepeaterField({ fields, types, path, name, value, onChange, onBlur, label, description, errors, disabled, readOnly, required, min, max, className, labelClassName, descriptionClassName, errorsClassName, itemClassName, }: RepeaterFieldProps): import("react").JSX.Element;
|
|
34
|
+
export declare function RepeaterField({ fields, types, path, name, value, onChange, onBlur, label, description, errors, disabled, readOnly, required, min, max, itemTitle, renderFields, className, labelClassName, descriptionClassName, errorsClassName, itemClassName, }: RepeaterFieldProps): import("react").JSX.Element;
|
|
24
35
|
/**
|
|
25
36
|
* The `repeater` type: `fields`, or `types` for typed blocks, with `min` and `max` items from its
|
|
26
37
|
* rules.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RepeaterField.d.ts","sourceRoot":"","sources":["../../src/repeater/RepeaterField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RepeaterField.d.ts","sourceRoot":"","sources":["../../src/repeater/RepeaterField.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAS,MAAM,OAAO,CAAC;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAe1D,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGnE,qEAAqE;AACrE,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnD,MAAM,WAAW,kBAAmB,SAAQ,UAAU,CAAC,YAAY,EAAE,CAAC;IAClE,+BAA+B;IAC/B,MAAM,CAAC,EAAE,SAAS,KAAK,EAAE,CAAC;IAC1B,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC7B,mGAAmG;IACnG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACjE;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,KAAK,SAAS,CAAC;IAC7F,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AAUD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAC1B,MAAW,EACX,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,WAAW,EACX,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,GAAO,EACP,GAAG,EACH,SAAS,EACT,YAAY,EACZ,SAAS,EACT,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,aAAa,GAChB,EAAE,kBAAkB,+BAoKpB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,+BAwBxD"}
|
|
@@ -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 { ArrowDown, ArrowUp, Plus, Trash2 } from "lucide-react";
|
|
8
|
-
import { useId } from "react";
|
|
9
7
|
import { Button, Fieldset, IconButton, Menu, MenuItem, MenuTrigger, usePanneauIntl } from "@panneau/ui";
|
|
10
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { ArrowDown, ArrowUp, Plus, Trash2 } from "lucide-react";
|
|
10
|
+
import { useId } from "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]] : []));
|
|
@@ -18,8 +18,8 @@ function defaults(fields) {
|
|
|
18
18
|
* empty list is `null`.
|
|
19
19
|
*/
|
|
20
20
|
function RepeaterField(t0) {
|
|
21
|
-
const $ = c(
|
|
22
|
-
const { fields: t1, types, path, name, value, onChange, onBlur, label, description, errors, disabled, readOnly, required, min: t2, max, className, labelClassName, descriptionClassName, errorsClassName, itemClassName } = t0;
|
|
21
|
+
const $ = c(47);
|
|
22
|
+
const { fields: t1, types, path, name, value, onChange, onBlur, label, description, errors, disabled, readOnly, required, min: t2, max, itemTitle, renderFields, className, labelClassName, descriptionClassName, errorsClassName, itemClassName } = t0;
|
|
23
23
|
let t3;
|
|
24
24
|
if ($[0] !== t1) {
|
|
25
25
|
t3 = t1 === void 0 ? [] : t1;
|
|
@@ -76,7 +76,7 @@ function RepeaterField(t0) {
|
|
|
76
76
|
} else t7 = $[12];
|
|
77
77
|
const add = t7;
|
|
78
78
|
let t8;
|
|
79
|
-
if ($[13] !== base || $[14] !== canRemove || $[15] !== disabled || $[16] !== editable || $[17] !== fields || $[18] !== id || $[19] !== intl || $[20] !== itemClassName || $[21] !==
|
|
79
|
+
if ($[13] !== base || $[14] !== canRemove || $[15] !== disabled || $[16] !== editable || $[17] !== fields || $[18] !== id || $[19] !== intl || $[20] !== itemClassName || $[21] !== itemTitle || $[22] !== items || $[23] !== move || $[24] !== onBlur || $[25] !== readOnly || $[26] !== renderFields || $[27] !== set || $[28] !== types) {
|
|
80
80
|
t8 = items.length > 0 ? /* @__PURE__ */ jsx("ol", {
|
|
81
81
|
className: RepeaterField_module_default.items,
|
|
82
82
|
children: items.map((item, index) => {
|
|
@@ -84,6 +84,20 @@ function RepeaterField(t0) {
|
|
|
84
84
|
const itemFields = types !== void 0 ? type_0?.fields ?? [] : fields;
|
|
85
85
|
const number = index + 1;
|
|
86
86
|
const titleId = `${id}-${index}`;
|
|
87
|
+
const summary = itemTitle?.(item, index) ?? null;
|
|
88
|
+
const renderField = (field) => /* @__PURE__ */ jsx(NestedField, {
|
|
89
|
+
field,
|
|
90
|
+
path: `${base}.${index}.${field.name}`,
|
|
91
|
+
value: item[field.name],
|
|
92
|
+
onChange: (next_1) => set(items.map((current, i) => i === index ? {
|
|
93
|
+
...current,
|
|
94
|
+
[field.name]: next_1
|
|
95
|
+
} : current)),
|
|
96
|
+
...onBlur !== void 0 ? { onBlur } : {},
|
|
97
|
+
parentValue: item,
|
|
98
|
+
...disabled !== void 0 ? { disabled } : {},
|
|
99
|
+
...readOnly !== void 0 ? { readOnly } : {}
|
|
100
|
+
}, field.name);
|
|
87
101
|
return /* @__PURE__ */ jsxs("li", {
|
|
88
102
|
className: cx(RepeaterField_module_default.item, itemClassName),
|
|
89
103
|
"aria-labelledby": titleId,
|
|
@@ -95,7 +109,7 @@ function RepeaterField(t0) {
|
|
|
95
109
|
children: [/* @__PURE__ */ jsx("span", {
|
|
96
110
|
className: RepeaterField_module_default.index,
|
|
97
111
|
children: number
|
|
98
|
-
}), type_0?.label ?? (typeof item.type === "string" ? item.type : intl.formatMessage(messages.item, { index: number }))]
|
|
112
|
+
}), summary ?? type_0?.label ?? (typeof item.type === "string" ? item.type : intl.formatMessage(messages.item, { index: number }))]
|
|
99
113
|
}), editable ? /* @__PURE__ */ jsxs("span", {
|
|
100
114
|
className: RepeaterField_module_default.tools,
|
|
101
115
|
children: [
|
|
@@ -118,25 +132,13 @@ function RepeaterField(t0) {
|
|
|
118
132
|
size: "sm",
|
|
119
133
|
label: intl.formatMessage(messages.removeItem, { index: number }),
|
|
120
134
|
isDisabled: !canRemove,
|
|
121
|
-
onPress: () => set(items.filter((_,
|
|
135
|
+
onPress: () => set(items.filter((_, i_0) => i_0 !== index))
|
|
122
136
|
})
|
|
123
137
|
]
|
|
124
138
|
}) : null]
|
|
125
139
|
}), /* @__PURE__ */ jsx("div", {
|
|
126
140
|
className: RepeaterField_module_default.body,
|
|
127
|
-
children: itemFields.map((
|
|
128
|
-
field,
|
|
129
|
-
path: `${base}.${index}.${field.name}`,
|
|
130
|
-
value: item[field.name],
|
|
131
|
-
onChange: (next_1) => set(items.map((current, i_0) => i_0 === index ? {
|
|
132
|
-
...current,
|
|
133
|
-
[field.name]: next_1
|
|
134
|
-
} : current)),
|
|
135
|
-
...onBlur !== void 0 ? { onBlur } : {},
|
|
136
|
-
parentValue: item,
|
|
137
|
-
...disabled !== void 0 ? { disabled } : {},
|
|
138
|
-
...readOnly !== void 0 ? { readOnly } : {}
|
|
139
|
-
}, field.name))
|
|
141
|
+
children: renderFields !== void 0 ? renderFields(Object.fromEntries(itemFields.map((field_0) => [field_0.name, renderField(field_0)])), item) : itemFields.map(renderField)
|
|
140
142
|
})]
|
|
141
143
|
}, index);
|
|
142
144
|
})
|
|
@@ -152,16 +154,18 @@ function RepeaterField(t0) {
|
|
|
152
154
|
$[18] = id;
|
|
153
155
|
$[19] = intl;
|
|
154
156
|
$[20] = itemClassName;
|
|
155
|
-
$[21] =
|
|
156
|
-
$[22] =
|
|
157
|
-
$[23] =
|
|
158
|
-
$[24] =
|
|
159
|
-
$[25] =
|
|
160
|
-
$[26] =
|
|
161
|
-
$[27] =
|
|
162
|
-
|
|
157
|
+
$[21] = itemTitle;
|
|
158
|
+
$[22] = items;
|
|
159
|
+
$[23] = move;
|
|
160
|
+
$[24] = onBlur;
|
|
161
|
+
$[25] = readOnly;
|
|
162
|
+
$[26] = renderFields;
|
|
163
|
+
$[27] = set;
|
|
164
|
+
$[28] = types;
|
|
165
|
+
$[29] = t8;
|
|
166
|
+
} else t8 = $[29];
|
|
163
167
|
let t9;
|
|
164
|
-
if ($[
|
|
168
|
+
if ($[30] !== add || $[31] !== canAdd || $[32] !== editable || $[33] !== intl || $[34] !== types) {
|
|
165
169
|
t9 = editable ? /* @__PURE__ */ jsx("div", {
|
|
166
170
|
className: RepeaterField_module_default.footer,
|
|
167
171
|
children: types !== void 0 ? /* @__PURE__ */ jsxs(MenuTrigger, { children: [/* @__PURE__ */ jsx(Button, {
|
|
@@ -181,15 +185,15 @@ function RepeaterField(t0) {
|
|
|
181
185
|
children: intl.formatMessage(messages.add)
|
|
182
186
|
})
|
|
183
187
|
}) : null;
|
|
184
|
-
$[
|
|
185
|
-
$[
|
|
186
|
-
$[
|
|
187
|
-
$[
|
|
188
|
-
$[
|
|
189
|
-
$[
|
|
190
|
-
} else t9 = $[
|
|
188
|
+
$[30] = add;
|
|
189
|
+
$[31] = canAdd;
|
|
190
|
+
$[32] = editable;
|
|
191
|
+
$[33] = intl;
|
|
192
|
+
$[34] = types;
|
|
193
|
+
$[35] = t9;
|
|
194
|
+
} else t9 = $[35];
|
|
191
195
|
let t10;
|
|
192
|
-
if ($[
|
|
196
|
+
if ($[36] !== className || $[37] !== description || $[38] !== descriptionClassName || $[39] !== errors || $[40] !== errorsClassName || $[41] !== label || $[42] !== labelClassName || $[43] !== required || $[44] !== t8 || $[45] !== t9) {
|
|
193
197
|
t10 = /* @__PURE__ */ jsxs(Fieldset, {
|
|
194
198
|
legend: label,
|
|
195
199
|
description,
|
|
@@ -201,18 +205,18 @@ function RepeaterField(t0) {
|
|
|
201
205
|
errorsClassName,
|
|
202
206
|
children: [t8, t9]
|
|
203
207
|
});
|
|
204
|
-
$[
|
|
205
|
-
$[
|
|
206
|
-
$[
|
|
207
|
-
$[
|
|
208
|
-
$[
|
|
209
|
-
$[
|
|
210
|
-
$[
|
|
211
|
-
$[
|
|
212
|
-
$[
|
|
213
|
-
$[
|
|
214
|
-
$[
|
|
215
|
-
} else t10 = $[
|
|
208
|
+
$[36] = className;
|
|
209
|
+
$[37] = description;
|
|
210
|
+
$[38] = descriptionClassName;
|
|
211
|
+
$[39] = errors;
|
|
212
|
+
$[40] = errorsClassName;
|
|
213
|
+
$[41] = label;
|
|
214
|
+
$[42] = labelClassName;
|
|
215
|
+
$[43] = required;
|
|
216
|
+
$[44] = t8;
|
|
217
|
+
$[45] = t9;
|
|
218
|
+
$[46] = t10;
|
|
219
|
+
} else t10 = $[46];
|
|
216
220
|
return t10;
|
|
217
221
|
}
|
|
218
222
|
/**
|