@panneau/fields 5.0.0-alpha.4 → 5.0.0-alpha.6
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 +67 -21
- package/dist/duration/DurationField.css +11 -0
- package/dist/duration/DurationField.d.ts +26 -0
- package/dist/duration/DurationField.d.ts.map +1 -0
- package/dist/duration/DurationField.js +129 -0
- package/dist/duration/DurationField.js.map +1 -0
- package/dist/duration/DurationField.module.js +12 -0
- package/dist/duration/DurationField.module.js.map +1 -0
- package/dist/duration/index.d.ts +2 -0
- package/dist/duration/index.d.ts.map +1 -0
- package/dist/duration/index.js +1 -0
- package/dist/embed/EmbedField.css +60 -0
- package/dist/embed/EmbedField.d.ts +20 -0
- package/dist/embed/EmbedField.d.ts.map +1 -0
- package/dist/embed/EmbedField.js +130 -0
- package/dist/embed/EmbedField.js.map +1 -0
- package/dist/embed/EmbedField.module.js +22 -0
- package/dist/embed/EmbedField.module.js.map +1 -0
- package/dist/embed/index.d.ts +3 -0
- package/dist/embed/index.d.ts.map +1 -0
- package/dist/embed/index.js +3 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/json/JsonField.css +7 -0
- package/dist/json/JsonField.d.ts +22 -0
- package/dist/json/JsonField.d.ts.map +1 -0
- package/dist/json/JsonField.js +125 -0
- package/dist/json/JsonField.js.map +1 -0
- package/dist/json/JsonField.module.js +8 -0
- package/dist/json/JsonField.module.js.map +1 -0
- package/dist/json/index.d.ts +2 -0
- package/dist/json/index.d.ts.map +1 -0
- package/dist/json/index.js +1 -0
- package/dist/localized/LocalizedField.d.ts.map +1 -1
- package/dist/localized/LocalizedField.js +1 -0
- package/dist/localized/LocalizedField.js.map +1 -1
- package/dist/location/LocationField.css +54 -0
- package/dist/location/LocationField.d.ts +31 -0
- package/dist/location/LocationField.d.ts.map +1 -0
- package/dist/location/LocationField.js +350 -0
- package/dist/location/LocationField.js.map +1 -0
- package/dist/location/LocationField.module.js +22 -0
- package/dist/location/LocationField.module.js.map +1 -0
- package/dist/location/LocationMap.d.ts +25 -0
- package/dist/location/LocationMap.d.ts.map +1 -0
- package/dist/location/LocationMap.js +115 -0
- package/dist/location/LocationMap.js.map +1 -0
- package/dist/location/index.d.ts +5 -0
- package/dist/location/index.d.ts.map +1 -0
- package/dist/location/index.js +4 -0
- package/dist/location/leafletCss.d.ts +2 -0
- package/dist/location/leafletCss.d.ts.map +1 -0
- package/dist/location/leafletCss.js +6 -0
- package/dist/location/leafletCss.js.map +1 -0
- package/dist/location/nominatim.d.ts +17 -0
- package/dist/location/nominatim.d.ts.map +1 -0
- package/dist/location/nominatim.js +50 -0
- package/dist/location/nominatim.js.map +1 -0
- package/dist/location/types.d.ts +40 -0
- package/dist/location/types.d.ts.map +1 -0
- package/dist/range/RangeField.d.ts +22 -0
- package/dist/range/RangeField.d.ts.map +1 -0
- package/dist/range/RangeField.js +132 -0
- package/dist/range/RangeField.js.map +1 -0
- package/dist/range/index.d.ts +2 -0
- package/dist/range/index.d.ts.map +1 -0
- package/dist/range/index.js +1 -0
- package/dist/relation/RelationField.d.ts.map +1 -1
- package/dist/relation/RelationField.js +24 -24
- package/dist/relation/RelationField.js.map +1 -1
- package/dist/shared/DefinitionField.d.ts +3 -1
- package/dist/shared/DefinitionField.d.ts.map +1 -1
- package/dist/shared/DefinitionField.js +80 -72
- package/dist/shared/DefinitionField.js.map +1 -1
- package/dist/shared/builtIn.d.ts +1 -0
- package/dist/shared/builtIn.d.ts.map +1 -1
- package/dist/shared/builtIn.js +16 -1
- package/dist/shared/builtIn.js.map +1 -1
- package/dist/shared/check.d.ts +27 -0
- package/dist/shared/check.d.ts.map +1 -0
- package/dist/shared/check.js +18 -0
- package/dist/shared/check.js.map +1 -0
- package/dist/shared/context.d.ts +18 -3
- package/dist/shared/context.d.ts.map +1 -1
- package/dist/shared/context.js +31 -19
- package/dist/shared/context.js.map +1 -1
- package/dist/shared/embed.d.ts +19 -0
- package/dist/shared/embed.d.ts.map +1 -0
- package/dist/shared/embed.js +14 -0
- package/dist/shared/embed.js.map +1 -0
- package/dist/shared/types.d.ts +2 -0
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/slug/SlugField.css +18 -0
- package/dist/slug/SlugField.d.ts +31 -3
- package/dist/slug/SlugField.d.ts.map +1 -1
- package/dist/slug/SlugField.js +231 -159
- package/dist/slug/SlugField.js.map +1 -1
- package/dist/slug/SlugField.module.js +14 -0
- package/dist/slug/SlugField.module.js.map +1 -0
- package/dist/slug/index.d.ts +1 -1
- package/dist/slug/index.d.ts.map +1 -1
- package/dist/slug/index.js +1 -1
- package/dist/tags/TagsField.d.ts +17 -0
- package/dist/tags/TagsField.d.ts.map +1 -0
- package/dist/tags/TagsField.js +120 -0
- package/dist/tags/TagsField.js.map +1 -0
- package/dist/tags/index.d.ts +2 -0
- package/dist/tags/index.d.ts.map +1 -0
- package/dist/tags/index.js +1 -0
- package/dist/tel/TelField.d.ts +11 -0
- package/dist/tel/TelField.d.ts.map +1 -0
- package/dist/tel/TelField.js +87 -0
- package/dist/tel/TelField.js.map +1 -0
- package/dist/tel/index.d.ts +2 -0
- package/dist/tel/index.d.ts.map +1 -0
- package/dist/tel/index.js +1 -0
- package/package.json +41 -4
|
@@ -13,110 +13,118 @@ import { jsx } from "react/jsx-runtime";
|
|
|
13
13
|
* parent value is false.
|
|
14
14
|
*/
|
|
15
15
|
function NestedField(t0) {
|
|
16
|
-
const $ = c(
|
|
17
|
-
const { field, path, value, onChange, onBlur, errors, parentValue, disabled, readOnly, className } = t0;
|
|
16
|
+
const $ = c(36);
|
|
17
|
+
const { field, path, value, onChange, onBlur, errors, parentValue, locale, disabled, readOnly, className } = t0;
|
|
18
18
|
const { binding: Binding } = useFieldsContext();
|
|
19
19
|
let t1;
|
|
20
|
-
if ($[0] !==
|
|
21
|
-
t1 =
|
|
22
|
-
$[0] =
|
|
20
|
+
if ($[0] !== locale) {
|
|
21
|
+
t1 = locale !== void 0 ? { locale } : {};
|
|
22
|
+
$[0] = locale;
|
|
23
23
|
$[1] = t1;
|
|
24
24
|
} else t1 = $[1];
|
|
25
25
|
let t2;
|
|
26
|
-
if ($[2] !==
|
|
27
|
-
t2 =
|
|
28
|
-
$[2] =
|
|
26
|
+
if ($[2] !== disabled) {
|
|
27
|
+
t2 = disabled !== void 0 ? { disabled } : {};
|
|
28
|
+
$[2] = disabled;
|
|
29
29
|
$[3] = t2;
|
|
30
30
|
} else t2 = $[3];
|
|
31
31
|
let t3;
|
|
32
|
-
if ($[4] !==
|
|
33
|
-
t3 =
|
|
34
|
-
$[4] =
|
|
32
|
+
if ($[4] !== readOnly) {
|
|
33
|
+
t3 = readOnly !== void 0 ? { readOnly } : {};
|
|
34
|
+
$[4] = readOnly;
|
|
35
35
|
$[5] = t3;
|
|
36
36
|
} else t3 = $[5];
|
|
37
37
|
let t4;
|
|
38
|
-
if ($[6] !==
|
|
39
|
-
t4 = {
|
|
38
|
+
if ($[6] !== className) {
|
|
39
|
+
t4 = className !== void 0 ? { className } : {};
|
|
40
|
+
$[6] = className;
|
|
41
|
+
$[7] = t4;
|
|
42
|
+
} else t4 = $[7];
|
|
43
|
+
let t5;
|
|
44
|
+
if ($[8] !== field || $[9] !== parentValue || $[10] !== path || $[11] !== t1 || $[12] !== t2 || $[13] !== t3 || $[14] !== t4) {
|
|
45
|
+
t5 = {
|
|
40
46
|
field,
|
|
41
47
|
path,
|
|
42
48
|
parentValue,
|
|
43
49
|
...t1,
|
|
44
50
|
...t2,
|
|
45
|
-
...t3
|
|
51
|
+
...t3,
|
|
52
|
+
...t4
|
|
46
53
|
};
|
|
47
|
-
$[
|
|
48
|
-
$[
|
|
49
|
-
$[
|
|
50
|
-
$[
|
|
51
|
-
$[
|
|
52
|
-
$[
|
|
53
|
-
$[
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
$[8] = field;
|
|
55
|
+
$[9] = parentValue;
|
|
56
|
+
$[10] = path;
|
|
57
|
+
$[11] = t1;
|
|
58
|
+
$[12] = t2;
|
|
59
|
+
$[13] = t3;
|
|
60
|
+
$[14] = t4;
|
|
61
|
+
$[15] = t5;
|
|
62
|
+
} else t5 = $[15];
|
|
63
|
+
const shared = t5;
|
|
56
64
|
if (Binding !== null) {
|
|
57
|
-
let t5;
|
|
58
|
-
if ($[13] !== path) {
|
|
59
|
-
t5 = getParentPath(path);
|
|
60
|
-
$[13] = path;
|
|
61
|
-
$[14] = t5;
|
|
62
|
-
} else t5 = $[14];
|
|
63
65
|
let t6;
|
|
64
|
-
if ($[
|
|
65
|
-
t6 = (
|
|
66
|
+
if ($[16] !== path) {
|
|
67
|
+
t6 = getParentPath(path);
|
|
68
|
+
$[16] = path;
|
|
69
|
+
$[17] = t6;
|
|
70
|
+
} else t6 = $[17];
|
|
71
|
+
let t7;
|
|
72
|
+
if ($[18] !== shared) {
|
|
73
|
+
t7 = (bound) => /* @__PURE__ */ jsx(DefinitionField, {
|
|
66
74
|
...shared,
|
|
67
75
|
...bound
|
|
68
76
|
});
|
|
69
|
-
$[
|
|
70
|
-
$[
|
|
71
|
-
} else
|
|
72
|
-
let
|
|
73
|
-
if ($[
|
|
74
|
-
|
|
77
|
+
$[18] = shared;
|
|
78
|
+
$[19] = t7;
|
|
79
|
+
} else t7 = $[19];
|
|
80
|
+
let t8;
|
|
81
|
+
if ($[20] !== Binding || $[21] !== field || $[22] !== path || $[23] !== t6 || $[24] !== t7) {
|
|
82
|
+
t8 = /* @__PURE__ */ jsx(Binding, {
|
|
75
83
|
field,
|
|
76
84
|
path,
|
|
77
|
-
parentPath:
|
|
78
|
-
render:
|
|
85
|
+
parentPath: t6,
|
|
86
|
+
render: t7
|
|
79
87
|
});
|
|
80
|
-
$[
|
|
81
|
-
$[
|
|
82
|
-
$[
|
|
83
|
-
$[
|
|
84
|
-
$[
|
|
85
|
-
$[
|
|
86
|
-
} else
|
|
87
|
-
return
|
|
88
|
+
$[20] = Binding;
|
|
89
|
+
$[21] = field;
|
|
90
|
+
$[22] = path;
|
|
91
|
+
$[23] = t6;
|
|
92
|
+
$[24] = t7;
|
|
93
|
+
$[25] = t8;
|
|
94
|
+
} else t8 = $[25];
|
|
95
|
+
return t8;
|
|
88
96
|
}
|
|
89
97
|
if (field.visibleWhen !== void 0 && !evaluateCondition(field.visibleWhen, parentValue)) return null;
|
|
90
|
-
const
|
|
91
|
-
let t6;
|
|
92
|
-
if ($[23] !== onBlur) {
|
|
93
|
-
t6 = onBlur !== void 0 ? { onBlur } : {};
|
|
94
|
-
$[23] = onBlur;
|
|
95
|
-
$[24] = t6;
|
|
96
|
-
} else t6 = $[24];
|
|
98
|
+
const t6 = onChange ?? _temp;
|
|
97
99
|
let t7;
|
|
98
|
-
if ($[
|
|
99
|
-
t7 =
|
|
100
|
-
$[
|
|
101
|
-
$[
|
|
102
|
-
} else t7 = $[
|
|
100
|
+
if ($[26] !== onBlur) {
|
|
101
|
+
t7 = onBlur !== void 0 ? { onBlur } : {};
|
|
102
|
+
$[26] = onBlur;
|
|
103
|
+
$[27] = t7;
|
|
104
|
+
} else t7 = $[27];
|
|
103
105
|
let t8;
|
|
104
|
-
if ($[
|
|
105
|
-
t8 =
|
|
106
|
+
if ($[28] !== errors) {
|
|
107
|
+
t8 = errors !== void 0 ? { errors } : {};
|
|
108
|
+
$[28] = errors;
|
|
109
|
+
$[29] = t8;
|
|
110
|
+
} else t8 = $[29];
|
|
111
|
+
let t9;
|
|
112
|
+
if ($[30] !== shared || $[31] !== t6 || $[32] !== t7 || $[33] !== t8 || $[34] !== value) {
|
|
113
|
+
t9 = /* @__PURE__ */ jsx(DefinitionField, {
|
|
106
114
|
...shared,
|
|
107
115
|
value,
|
|
108
|
-
onChange:
|
|
109
|
-
...
|
|
110
|
-
...
|
|
116
|
+
onChange: t6,
|
|
117
|
+
...t7,
|
|
118
|
+
...t8
|
|
111
119
|
});
|
|
112
|
-
$[
|
|
113
|
-
$[
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
-
} else
|
|
119
|
-
return
|
|
120
|
+
$[30] = shared;
|
|
121
|
+
$[31] = t6;
|
|
122
|
+
$[32] = t7;
|
|
123
|
+
$[33] = t8;
|
|
124
|
+
$[34] = value;
|
|
125
|
+
$[35] = t9;
|
|
126
|
+
} else t9 = $[35];
|
|
127
|
+
return t9;
|
|
120
128
|
}
|
|
121
129
|
/**
|
|
122
130
|
* Renders a field of the definition with the entry of its type: from the fields context, or a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefinitionField.js","names":["field","path","value","_c"],"sources":["../../src/shared/DefinitionField.tsx"],"sourcesContent":["import type { Field } from '@panneau/protocol';\nimport { evaluateCondition } from '@panneau/protocol/runtime';\n\n// Groups, repeaters and localized values render nested fields, which render through\n// `DefinitionField`: the modules import each other, which is fine since they only use each other\n// while rendering.\nimport { LocalizedFieldEntry } from '../localized/LocalizedField';\nimport { MissingFieldEntry } from '../missing/MissingField';\nimport { builtInFields } from './builtIn';\nimport { getParentPath, useFieldsContext } from './context';\nimport type { FieldEntryProps } from './types';\n\nexport interface NestedFieldProps {\n field: Field;\n /** Dot path of the field's value. */\n path: string;\n /** The value, without a binding. */\n value?: unknown;\n /** Sets the value, without a binding. */\n onChange?: (value: unknown) => void;\n onBlur?: () => void;\n errors?: readonly string[];\n /** The object the field belongs to, for conditions and generated values. */\n parentValue?: unknown;\n disabled?: boolean;\n readOnly?: boolean;\n className?: string;\n}\n\n/**\n * A field inside another one (a group, a block, a localized value), or at the top of a form.\n * With a binding in context, the binding gives its value and decides whether it shows. Without\n * one, it uses `value` and `onChange`, and hides itself when its `visibleWhen` condition on the\n * parent value is false.\n */\nexport function NestedField({\n field,\n path,\n value,\n onChange,\n onBlur,\n errors,\n parentValue,\n disabled,\n readOnly,\n className,\n}: NestedFieldProps) {\n const { binding: Binding } = useFieldsContext();\n const shared = {\n field,\n path,\n parentValue,\n ...(disabled !== undefined ? { disabled } : {}),\n ...(readOnly !== undefined ? { readOnly } : {}),\n ...(className !== undefined ? { className } : {}),\n };\n if (Binding !== null) {\n return (\n <Binding\n field={field}\n path={path}\n parentPath={getParentPath(path)}\n render={(bound) => <DefinitionField {...shared} {...bound} />}\n />\n );\n }\n if (field.visibleWhen !== undefined && !evaluateCondition(field.visibleWhen, parentValue)) {\n return null;\n }\n return (\n <DefinitionField\n {...shared}\n value={value}\n onChange={onChange ?? (() => undefined)}\n {...(onBlur !== undefined ? { onBlur } : {})}\n {...(errors !== undefined ? { errors } : {})}\n />\n );\n}\n\n/**\n * Renders a field of the definition with the entry of its type: from the fields context, or a\n * built-in one. A localized field renders an input per locale. A type without an entry renders a\n * placeholder that names the missing plugin.\n */\nexport function DefinitionField(props: FieldEntryProps) {\n const { components } = useFieldsContext();\n const { field } = props;\n if (field.localized === true) {\n return <LocalizedFieldEntry {...props} />;\n }\n const Entry = components[field.type] ?? builtInFields[field.type] ?? MissingFieldEntry;\n return <Entry {...props} />;\n}\n"],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"DefinitionField.js","names":["field","path","value","_c"],"sources":["../../src/shared/DefinitionField.tsx"],"sourcesContent":["import type { Field } from '@panneau/protocol';\nimport { evaluateCondition } from '@panneau/protocol/runtime';\n\n// Groups, repeaters and localized values render nested fields, which render through\n// `DefinitionField`: the modules import each other, which is fine since they only use each other\n// while rendering.\nimport { LocalizedFieldEntry } from '../localized/LocalizedField';\nimport { MissingFieldEntry } from '../missing/MissingField';\nimport { builtInFields } from './builtIn';\nimport { getParentPath, useFieldsContext } from './context';\nimport type { FieldEntryProps } from './types';\n\nexport interface NestedFieldProps {\n field: Field;\n /** Dot path of the field's value. */\n path: string;\n /** The value, without a binding. */\n value?: unknown;\n /** Sets the value, without a binding. */\n onChange?: (value: unknown) => void;\n onBlur?: () => void;\n errors?: readonly string[];\n /** The object the field belongs to, for conditions and generated values. */\n parentValue?: unknown;\n /** The locale of the value, in a localized field. */\n locale?: string;\n disabled?: boolean;\n readOnly?: boolean;\n className?: string;\n}\n\n/**\n * A field inside another one (a group, a block, a localized value), or at the top of a form.\n * With a binding in context, the binding gives its value and decides whether it shows. Without\n * one, it uses `value` and `onChange`, and hides itself when its `visibleWhen` condition on the\n * parent value is false.\n */\nexport function NestedField({\n field,\n path,\n value,\n onChange,\n onBlur,\n errors,\n parentValue,\n locale,\n disabled,\n readOnly,\n className,\n}: NestedFieldProps) {\n const { binding: Binding } = useFieldsContext();\n const shared = {\n field,\n path,\n parentValue,\n ...(locale !== undefined ? { locale } : {}),\n ...(disabled !== undefined ? { disabled } : {}),\n ...(readOnly !== undefined ? { readOnly } : {}),\n ...(className !== undefined ? { className } : {}),\n };\n if (Binding !== null) {\n return (\n <Binding\n field={field}\n path={path}\n parentPath={getParentPath(path)}\n render={(bound) => <DefinitionField {...shared} {...bound} />}\n />\n );\n }\n if (field.visibleWhen !== undefined && !evaluateCondition(field.visibleWhen, parentValue)) {\n return null;\n }\n return (\n <DefinitionField\n {...shared}\n value={value}\n onChange={onChange ?? (() => undefined)}\n {...(onBlur !== undefined ? { onBlur } : {})}\n {...(errors !== undefined ? { errors } : {})}\n />\n );\n}\n\n/**\n * Renders a field of the definition with the entry of its type: from the fields context, or a\n * built-in one. A localized field renders an input per locale. A type without an entry renders a\n * placeholder that names the missing plugin.\n */\nexport function DefinitionField(props: FieldEntryProps) {\n const { components } = useFieldsContext();\n const { field } = props;\n if (field.localized === true) {\n return <LocalizedFieldEntry {...props} />;\n }\n const Entry = components[field.type] ?? builtInFields[field.type] ?? MissingFieldEntry;\n return <Entry {...props} />;\n}\n"],"mappings":";;;;;;;;;;;;;;AAqCA,SAAO,YAAA,IAAA;CAAA,MAAA,IAAAG,EAAA,EAAA;CAAqB,MAAA,EAAA,OAAA,MAAA,OAAA,UAAA,QAAA,QAAA,aAAA,QAAA,UAAA,UAAA,cAAA;CAaxB,MAAA,EAAA,SAAA,YAA6B,iBAAiB;CAAE,IAAA;CAAA,IAAA,EAAA,OAAA,QAAA;EAKxC,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;;;;;;AA3CH,SAAA,QAAA,CAAA;AAoDP,SAAO,gBAAA,OAAA;CAAA,MAAA,IAAAA,EAAA,CAAA;CACH,MAAA,EAAA,eAAuB,iBAAiB;CACxC,MAAA,EAAA,UAAkB;CAClB,IAAI,MAAK,cAAe,MAAI;EAAA,IAAA;EAAA,IAAA,EAAA,OAAA,OAAA;GACjB,KAAA,oBAAC,qBAAD,EAAoB,GAAK,MAAK,CAAA;GAAI,EAAA,KAAA;GAAA,EAAA,KAAA;EAAA,OAAA,KAAA,EAAA;EAAA,OAAlC;CAAkC;CAE7C,MAAA,QAAc,WAAW,MAAK,SAAU,cAAc,MAAK,SAA7C;CAAyE,IAAA;CAAA,IAAA,EAAA,OAAA,SAAA,EAAA,OAAA,OAAA;EAChF,KAAA,oBAAC,OAAD,EAAM,GAAK,MAAK,CAAA;EAAI,EAAA,KAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,OAApB;AAAoB"}
|
package/dist/shared/builtIn.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { FieldEntry } from './types';
|
|
|
3
3
|
* The entries of the built-in field types. `richtext` and `media` come with their plugins
|
|
4
4
|
* (`@panneau/editor` and `@panneau/media`): without them, `DefinitionField` renders a placeholder.
|
|
5
5
|
* `file` uploads through the upload source of the fields context, or gives the files themselves.
|
|
6
|
+
* `embed` and `location` use its embed source and its maps; `location` loads Leaflet when shown.
|
|
6
7
|
*/
|
|
7
8
|
export declare const builtInFields: Readonly<Record<string, FieldEntry>>;
|
|
8
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtIn.d.ts","sourceRoot":"","sources":["../../src/shared/builtIn.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"builtIn.d.ts","sourceRoot":"","sources":["../../src/shared/builtIn.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAwB9D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAC7C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;CAK7D,CAAC"}
|
package/dist/shared/builtIn.js
CHANGED
|
@@ -3,14 +3,21 @@ import { TextFieldEntry } from "../text/TextField.js";
|
|
|
3
3
|
import { ColorFieldEntry } from "../color/ColorField.js";
|
|
4
4
|
import { DateFieldEntry } from "../date/DateField.js";
|
|
5
5
|
import { DateTimeFieldEntry } from "../datetime/DateTimeField.js";
|
|
6
|
+
import { DurationFieldEntry } from "../duration/DurationField.js";
|
|
6
7
|
import { EmailFieldEntry } from "../email/EmailField.js";
|
|
8
|
+
import { EmbedFieldEntry } from "../embed/EmbedField.js";
|
|
7
9
|
import { FileFieldEntry } from "../file/FileField.js";
|
|
8
10
|
import { GroupFieldEntry } from "../group/GroupField.js";
|
|
11
|
+
import { JsonFieldEntry } from "../json/JsonField.js";
|
|
12
|
+
import { LocationFieldEntry } from "../location/LocationField.js";
|
|
9
13
|
import { NumberFieldEntry } from "../number/NumberField.js";
|
|
14
|
+
import { RangeFieldEntry } from "../range/RangeField.js";
|
|
10
15
|
import { RelationFieldEntry } from "../relation/RelationField.js";
|
|
11
16
|
import { RepeaterFieldEntry } from "../repeater/RepeaterField.js";
|
|
12
17
|
import { SelectFieldEntry } from "../select/SelectField.js";
|
|
13
18
|
import { SlugFieldEntry } from "../slug/SlugField.js";
|
|
19
|
+
import { TagsFieldEntry } from "../tags/TagsField.js";
|
|
20
|
+
import { TelFieldEntry } from "../tel/TelField.js";
|
|
14
21
|
import { TextAreaFieldEntry } from "../textarea/TextAreaField.js";
|
|
15
22
|
import { TimeFieldEntry } from "../time/TimeField.js";
|
|
16
23
|
import { UrlFieldEntry } from "../url/UrlField.js";
|
|
@@ -20,6 +27,7 @@ import { fr } from "@panneau/intl";
|
|
|
20
27
|
* The entries of the built-in field types. `richtext` and `media` come with their plugins
|
|
21
28
|
* (`@panneau/editor` and `@panneau/media`): without them, `DefinitionField` renders a placeholder.
|
|
22
29
|
* `file` uploads through the upload source of the fields context, or gives the files themselves.
|
|
30
|
+
* `embed` and `location` use its embed source and its maps; `location` loads Leaflet when shown.
|
|
23
31
|
*/
|
|
24
32
|
var builtInFields = {
|
|
25
33
|
text: TextFieldEntry,
|
|
@@ -37,7 +45,14 @@ var builtInFields = {
|
|
|
37
45
|
file: FileFieldEntry,
|
|
38
46
|
relation: RelationFieldEntry,
|
|
39
47
|
group: GroupFieldEntry,
|
|
40
|
-
repeater: RepeaterFieldEntry
|
|
48
|
+
repeater: RepeaterFieldEntry,
|
|
49
|
+
tel: TelFieldEntry,
|
|
50
|
+
range: RangeFieldEntry,
|
|
51
|
+
duration: DurationFieldEntry,
|
|
52
|
+
json: JsonFieldEntry,
|
|
53
|
+
tags: TagsFieldEntry,
|
|
54
|
+
embed: EmbedFieldEntry,
|
|
55
|
+
location: LocationFieldEntry
|
|
41
56
|
};
|
|
42
57
|
/**
|
|
43
58
|
* The built-in fields as a `@panneau/core` plugin: their entries, and the French messages of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtIn.js","names":[],"sources":["../../src/shared/builtIn.ts"],"sourcesContent":["import { fr } from '@panneau/intl';\n\nimport { BooleanFieldEntry } from '../boolean/BooleanField';\nimport { ColorFieldEntry } from '../color/ColorField';\nimport { DateFieldEntry } from '../date/DateField';\nimport { DateTimeFieldEntry } from '../datetime/DateTimeField';\nimport { EmailFieldEntry } from '../email/EmailField';\nimport { FileFieldEntry } from '../file/FileField';\nimport { GroupFieldEntry } from '../group/GroupField';\nimport { NumberFieldEntry } from '../number/NumberField';\nimport { RelationFieldEntry } from '../relation/RelationField';\nimport { RepeaterFieldEntry } from '../repeater/RepeaterField';\nimport { SelectFieldEntry } from '../select/SelectField';\nimport { SlugFieldEntry } from '../slug/SlugField';\nimport { TextFieldEntry } from '../text/TextField';\nimport { TextAreaFieldEntry } from '../textarea/TextAreaField';\nimport { TimeFieldEntry } from '../time/TimeField';\nimport { UrlFieldEntry } from '../url/UrlField';\nimport type { FieldEntry } from './types';\n\n/**\n * The entries of the built-in field types. `richtext` and `media` come with their plugins\n * (`@panneau/editor` and `@panneau/media`): without them, `DefinitionField` renders a placeholder.\n * `file` uploads through the upload source of the fields context, or gives the files themselves.\n */\nexport const builtInFields: Readonly<Record<string, FieldEntry>> = {\n text: TextFieldEntry,\n textarea: TextAreaFieldEntry,\n number: NumberFieldEntry,\n boolean: BooleanFieldEntry,\n date: DateFieldEntry,\n datetime: DateTimeFieldEntry,\n time: TimeFieldEntry,\n select: SelectFieldEntry,\n email: EmailFieldEntry,\n url: UrlFieldEntry,\n color: ColorFieldEntry,\n slug: SlugFieldEntry,\n file: FileFieldEntry,\n relation: RelationFieldEntry,\n group: GroupFieldEntry,\n repeater: RepeaterFieldEntry,\n};\n\n/**\n * The built-in fields as a `@panneau/core` plugin: their entries, and the French messages of\n * every Panneau package (`@panneau/ui`, `@panneau/fields`, `@panneau/forms`…, from\n * `@panneau/intl`). Pass it before the plugins that override a type.\n */\nexport const fieldsPlugin: {\n id: string;\n fields: Readonly<Record<string, FieldEntry>>;\n locales: Readonly<Record<string, Record<string, string>>>;\n} = {\n id: 'panneau-fields',\n fields: builtInFields,\n locales: { fr },\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"builtIn.js","names":[],"sources":["../../src/shared/builtIn.ts"],"sourcesContent":["import { fr } from '@panneau/intl';\n\nimport { BooleanFieldEntry } from '../boolean/BooleanField';\nimport { ColorFieldEntry } from '../color/ColorField';\nimport { DateFieldEntry } from '../date/DateField';\nimport { DateTimeFieldEntry } from '../datetime/DateTimeField';\nimport { DurationFieldEntry } from '../duration/DurationField';\nimport { EmailFieldEntry } from '../email/EmailField';\nimport { EmbedFieldEntry } from '../embed/EmbedField';\nimport { FileFieldEntry } from '../file/FileField';\nimport { GroupFieldEntry } from '../group/GroupField';\nimport { JsonFieldEntry } from '../json/JsonField';\nimport { LocationFieldEntry } from '../location/LocationField';\nimport { NumberFieldEntry } from '../number/NumberField';\nimport { RangeFieldEntry } from '../range/RangeField';\nimport { RelationFieldEntry } from '../relation/RelationField';\nimport { RepeaterFieldEntry } from '../repeater/RepeaterField';\nimport { SelectFieldEntry } from '../select/SelectField';\nimport { SlugFieldEntry } from '../slug/SlugField';\nimport { TagsFieldEntry } from '../tags/TagsField';\nimport { TelFieldEntry } from '../tel/TelField';\nimport { TextFieldEntry } from '../text/TextField';\nimport { TextAreaFieldEntry } from '../textarea/TextAreaField';\nimport { TimeFieldEntry } from '../time/TimeField';\nimport { UrlFieldEntry } from '../url/UrlField';\nimport type { FieldEntry } from './types';\n\n/**\n * The entries of the built-in field types. `richtext` and `media` come with their plugins\n * (`@panneau/editor` and `@panneau/media`): without them, `DefinitionField` renders a placeholder.\n * `file` uploads through the upload source of the fields context, or gives the files themselves.\n * `embed` and `location` use its embed source and its maps; `location` loads Leaflet when shown.\n */\nexport const builtInFields: Readonly<Record<string, FieldEntry>> = {\n text: TextFieldEntry,\n textarea: TextAreaFieldEntry,\n number: NumberFieldEntry,\n boolean: BooleanFieldEntry,\n date: DateFieldEntry,\n datetime: DateTimeFieldEntry,\n time: TimeFieldEntry,\n select: SelectFieldEntry,\n email: EmailFieldEntry,\n url: UrlFieldEntry,\n color: ColorFieldEntry,\n slug: SlugFieldEntry,\n file: FileFieldEntry,\n relation: RelationFieldEntry,\n group: GroupFieldEntry,\n repeater: RepeaterFieldEntry,\n tel: TelFieldEntry,\n range: RangeFieldEntry,\n duration: DurationFieldEntry,\n json: JsonFieldEntry,\n tags: TagsFieldEntry,\n embed: EmbedFieldEntry,\n location: LocationFieldEntry,\n};\n\n/**\n * The built-in fields as a `@panneau/core` plugin: their entries, and the French messages of\n * every Panneau package (`@panneau/ui`, `@panneau/fields`, `@panneau/forms`…, from\n * `@panneau/intl`). Pass it before the plugins that override a type.\n */\nexport const fieldsPlugin: {\n id: string;\n fields: Readonly<Record<string, FieldEntry>>;\n locales: Readonly<Record<string, Record<string, string>>>;\n} = {\n id: 'panneau-fields',\n fields: builtInFields,\n locales: { fr },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAa,gBAAsD;CAC/D,MAAM;CACN,UAAU;CACV,QAAQ;CACR,SAAS;CACT,MAAM;CACN,UAAU;CACV,MAAM;CACN,QAAQ;CACR,OAAO;CACP,KAAK;CACL,OAAO;CACP,MAAM;CACN,MAAM;CACN,UAAU;CACV,OAAO;CACP,UAAU;CACV,KAAK;CACL,OAAO;CACP,UAAU;CACV,MAAM;CACN,MAAM;CACN,OAAO;CACP,UAAU;AACd;;;;;;AAOA,IAAa,eAIT;CACA,IAAI;CACJ,QAAQ;CACR,SAAS,EAAE,GAAG;AAClB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { FieldCheckRequest, FieldCheckResponse } from '@panneau/protocol';
|
|
2
|
+
/**
|
|
3
|
+
* Where fields with `check` check their value as it is typed: whether a slug is available, and
|
|
4
|
+
* its URL. The value's locale and the form's values come with each check.
|
|
5
|
+
*/
|
|
6
|
+
export interface FieldCheckSource {
|
|
7
|
+
check(field: string, request: {
|
|
8
|
+
value: string;
|
|
9
|
+
locale?: string;
|
|
10
|
+
values?: Record<string, unknown>;
|
|
11
|
+
}, options: {
|
|
12
|
+
signal: AbortSignal;
|
|
13
|
+
}): Promise<FieldCheckResponse>;
|
|
14
|
+
}
|
|
15
|
+
/** What `createFieldCheckSource()` needs from an adapter: the `checkField()` of `@panneau/data`. */
|
|
16
|
+
export interface FieldCheckAdapter {
|
|
17
|
+
checkField?(resource: string, field: string, request: FieldCheckRequest, options?: {
|
|
18
|
+
signal?: AbortSignal;
|
|
19
|
+
}): Promise<FieldCheckResponse>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The check source of a form of a resource, through an adapter (`POST
|
|
23
|
+
* /resources/{resource}/fields/{field}/check`): `id` is the item being edited, or null when
|
|
24
|
+
* creating one. Null when the adapter can't check.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createFieldCheckSource(adapter: FieldCheckAdapter, resource: string, id?: string | null): FieldCheckSource | null;
|
|
27
|
+
//# sourceMappingURL=check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/shared/check.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE/E;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC7B,KAAK,CACD,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,EAC7E,OAAO,EAAE;QAAE,MAAM,EAAE,WAAW,CAAA;KAAE,GACjC,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAClC;AAED,oGAAoG;AACpG,MAAM,WAAW,iBAAiB;IAC9B,UAAU,CAAC,CACP,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,iBAAiB,EAC1B,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GACnC,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,MAAM,EAChB,EAAE,GAAE,MAAM,GAAG,IAAW,GACzB,gBAAgB,GAAG,IAAI,CASzB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/shared/check.ts
|
|
2
|
+
/**
|
|
3
|
+
* The check source of a form of a resource, through an adapter (`POST
|
|
4
|
+
* /resources/{resource}/fields/{field}/check`): `id` is the item being edited, or null when
|
|
5
|
+
* creating one. Null when the adapter can't check.
|
|
6
|
+
*/
|
|
7
|
+
function createFieldCheckSource(adapter, resource, id = null) {
|
|
8
|
+
const { checkField } = adapter;
|
|
9
|
+
if (checkField === void 0) return null;
|
|
10
|
+
return { check: (field, request, { signal }) => checkField.call(adapter, resource, field, {
|
|
11
|
+
...request,
|
|
12
|
+
id
|
|
13
|
+
}, { signal }) };
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { createFieldCheckSource };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","names":[],"sources":["../../src/shared/check.ts"],"sourcesContent":["import type { FieldCheckRequest, FieldCheckResponse } from '@panneau/protocol';\n\n/**\n * Where fields with `check` check their value as it is typed: whether a slug is available, and\n * its URL. The value's locale and the form's values come with each check.\n */\nexport interface FieldCheckSource {\n check(\n field: string,\n request: { value: string; locale?: string; values?: Record<string, unknown> },\n options: { signal: AbortSignal },\n ): Promise<FieldCheckResponse>;\n}\n\n/** What `createFieldCheckSource()` needs from an adapter: the `checkField()` of `@panneau/data`. */\nexport interface FieldCheckAdapter {\n checkField?(\n resource: string,\n field: string,\n request: FieldCheckRequest,\n options?: { signal?: AbortSignal },\n ): Promise<FieldCheckResponse>;\n}\n\n/**\n * The check source of a form of a resource, through an adapter (`POST\n * /resources/{resource}/fields/{field}/check`): `id` is the item being edited, or null when\n * creating one. Null when the adapter can't check.\n */\nexport function createFieldCheckSource(\n adapter: FieldCheckAdapter,\n resource: string,\n id: string | null = null,\n): FieldCheckSource | null {\n const { checkField } = adapter;\n if (checkField === undefined) {\n return null;\n }\n return {\n check: (field, request, { signal }) =>\n checkField.call(adapter, resource, field, { ...request, id }, { signal }),\n };\n}\n"],"mappings":";;;;;;AA6BA,SAAgB,uBACZ,SACA,UACA,KAAoB,MACG;CACvB,MAAM,EAAE,eAAe;CACvB,IAAI,eAAe,KAAA,GACf,OAAO;CAEX,OAAO,EACH,QAAQ,OAAO,SAAS,EAAE,aACtB,WAAW,KAAK,SAAS,UAAU,OAAO;EAAE,GAAG;EAAS;CAAG,GAAG,EAAE,OAAO,CAAC,EAChF;AACJ"}
|
package/dist/shared/context.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type ComponentType, type ReactNode } from 'react';
|
|
2
2
|
import type { Field } from '@panneau/protocol';
|
|
3
|
+
import type { MapsConfig } from '../location/types';
|
|
3
4
|
import type { UploadSource } from '../upload/types';
|
|
5
|
+
import type { FieldCheckSource } from './check';
|
|
6
|
+
import type { EmbedSource } from './embed';
|
|
4
7
|
import type { RelationSource } from './relation';
|
|
5
8
|
import type { FieldEntry } from './types';
|
|
6
9
|
/** What a binding gives a field: its value, handlers and errors at a path. */
|
|
@@ -38,6 +41,12 @@ export interface FieldsContextValue {
|
|
|
38
41
|
* files themselves.
|
|
39
42
|
*/
|
|
40
43
|
uploadSource: UploadSource | null;
|
|
44
|
+
/** Where fields with `check` check their value, such as a slug's availability. */
|
|
45
|
+
checkSource: FieldCheckSource | null;
|
|
46
|
+
/** Where `embed` fields get what a URL embeds. Without one, they keep the URL alone. */
|
|
47
|
+
embedSource: EmbedSource | null;
|
|
48
|
+
/** The tiles and the address search of `location` fields. */
|
|
49
|
+
maps: MapsConfig | null;
|
|
41
50
|
binding: FieldBinding | null;
|
|
42
51
|
}
|
|
43
52
|
/** The fields context of the closest `FieldsProvider`. */
|
|
@@ -49,15 +58,21 @@ export interface FieldsProviderProps {
|
|
|
49
58
|
relationSource?: RelationSource | null;
|
|
50
59
|
/** Make it once, outside of render: fields make an uploader for each source they get. */
|
|
51
60
|
uploadSource?: UploadSource | null;
|
|
61
|
+
/** `createFieldCheckSource(adapter, resource, id)`, for the form of an item. */
|
|
62
|
+
checkSource?: FieldCheckSource | null;
|
|
63
|
+
/** `createEmbedSource(adapter)`. */
|
|
64
|
+
embedSource?: EmbedSource | null;
|
|
65
|
+
/** The tiles and the address search of `location` fields. */
|
|
66
|
+
maps?: MapsConfig | null;
|
|
52
67
|
binding?: FieldBinding | null;
|
|
53
68
|
children?: ReactNode;
|
|
54
69
|
}
|
|
55
70
|
/**
|
|
56
71
|
* Provides what fields rendered from a definition need: the components of each type, the locales
|
|
57
|
-
* of localized values,
|
|
58
|
-
* provider.
|
|
72
|
+
* of localized values, the sources of relations, uploads, checks and embeds, the maps of
|
|
73
|
+
* locations, and a binding. Values not given come from the parent provider.
|
|
59
74
|
*/
|
|
60
|
-
export declare function FieldsProvider({ components, locales, relationSource, uploadSource, binding, children, }: FieldsProviderProps): import("react").JSX.Element;
|
|
75
|
+
export declare function FieldsProvider({ components, locales, relationSource, uploadSource, checkSource, embedSource, maps, binding, children, }: FieldsProviderProps): import("react").JSX.Element;
|
|
61
76
|
/** The parent path of a path: `blocks.2` for `blocks.2.title`, `''` for `title`. */
|
|
62
77
|
export declare function getParentPath(path: string): string;
|
|
63
78
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/shared/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAsB,MAAM,OAAO,CAAC;AAE/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAA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xB,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;CAChC;AAaD,0DAA0D;AAC1D,wBAAgB,gBAAgB,IAAI,kBAAkB,CAErD;AAED,MAAM,WAAW,mBAAmB;IAChC,uEAAuE;IACvE,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IACvC,yFAAyF;IACzF,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACnC,gFAAgF;IAChF,WAAW,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACtC,oCAAoC;IACpC,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC,6DAA6D;IAC7D,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IACzB,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAC3B,UAAU,EACV,OAAO,EACP,cAAc,EACd,YAAY,EACZ,WAAW,EACX,WAAW,EACX,IAAI,EACJ,OAAO,EACP,QAAQ,GACX,EAAE,mBAAmB,+BAcrB;AAED,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGlD"}
|
package/dist/shared/context.js
CHANGED
|
@@ -7,6 +7,9 @@ var FieldsContext = createContext({
|
|
|
7
7
|
locales: [],
|
|
8
8
|
relationSource: null,
|
|
9
9
|
uploadSource: null,
|
|
10
|
+
checkSource: null,
|
|
11
|
+
embedSource: null,
|
|
12
|
+
maps: null,
|
|
10
13
|
binding: null
|
|
11
14
|
});
|
|
12
15
|
/** The fields context of the closest `FieldsProvider`. */
|
|
@@ -15,12 +18,12 @@ function useFieldsContext() {
|
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
17
20
|
* Provides what fields rendered from a definition need: the components of each type, the locales
|
|
18
|
-
* of localized values,
|
|
19
|
-
* provider.
|
|
21
|
+
* of localized values, the sources of relations, uploads, checks and embeds, the maps of
|
|
22
|
+
* locations, and a binding. Values not given come from the parent provider.
|
|
20
23
|
*/
|
|
21
24
|
function FieldsProvider(t0) {
|
|
22
|
-
const $ = c(
|
|
23
|
-
const { components, locales, relationSource, uploadSource, binding, children } = t0;
|
|
25
|
+
const $ = c(15);
|
|
26
|
+
const { components, locales, relationSource, uploadSource, checkSource, embedSource, maps, binding, children } = t0;
|
|
24
27
|
const parent = use(FieldsContext);
|
|
25
28
|
let t1;
|
|
26
29
|
if ($[0] !== components || $[1] !== parent.components) {
|
|
@@ -35,15 +38,21 @@ function FieldsProvider(t0) {
|
|
|
35
38
|
const t2 = locales ?? parent.locales;
|
|
36
39
|
const t3 = relationSource === void 0 ? parent.relationSource : relationSource;
|
|
37
40
|
const t4 = uploadSource === void 0 ? parent.uploadSource : uploadSource;
|
|
38
|
-
const t5 =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
const t5 = checkSource === void 0 ? parent.checkSource : checkSource;
|
|
42
|
+
const t6 = embedSource === void 0 ? parent.embedSource : embedSource;
|
|
43
|
+
const t7 = maps === void 0 ? parent.maps : maps;
|
|
44
|
+
const t8 = binding === void 0 ? parent.binding : binding;
|
|
45
|
+
let t9;
|
|
46
|
+
if ($[3] !== t1 || $[4] !== t2 || $[5] !== t3 || $[6] !== t4 || $[7] !== t5 || $[8] !== t6 || $[9] !== t7 || $[10] !== t8) {
|
|
47
|
+
t9 = {
|
|
42
48
|
components: t1,
|
|
43
49
|
locales: t2,
|
|
44
50
|
relationSource: t3,
|
|
45
51
|
uploadSource: t4,
|
|
46
|
-
|
|
52
|
+
checkSource: t5,
|
|
53
|
+
embedSource: t6,
|
|
54
|
+
maps: t7,
|
|
55
|
+
binding: t8
|
|
47
56
|
};
|
|
48
57
|
$[3] = t1;
|
|
49
58
|
$[4] = t2;
|
|
@@ -51,19 +60,22 @@ function FieldsProvider(t0) {
|
|
|
51
60
|
$[6] = t4;
|
|
52
61
|
$[7] = t5;
|
|
53
62
|
$[8] = t6;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
63
|
+
$[9] = t7;
|
|
64
|
+
$[10] = t8;
|
|
65
|
+
$[11] = t9;
|
|
66
|
+
} else t9 = $[11];
|
|
67
|
+
const value = t9;
|
|
68
|
+
let t10;
|
|
69
|
+
if ($[12] !== children || $[13] !== value) {
|
|
70
|
+
t10 = /* @__PURE__ */ jsx(FieldsContext, {
|
|
59
71
|
value,
|
|
60
72
|
children
|
|
61
73
|
});
|
|
62
|
-
$[
|
|
63
|
-
$[
|
|
64
|
-
$[
|
|
65
|
-
} else
|
|
66
|
-
return
|
|
74
|
+
$[12] = children;
|
|
75
|
+
$[13] = value;
|
|
76
|
+
$[14] = t10;
|
|
77
|
+
} else t10 = $[14];
|
|
78
|
+
return t10;
|
|
67
79
|
}
|
|
68
80
|
/** The parent path of a path: `blocks.2` for `blocks.2.title`, `''` for `title`. */
|
|
69
81
|
function getParentPath(path) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":["value","children","_c"],"sources":["../../src/shared/context.tsx"],"sourcesContent":["import { type ComponentType, type ReactNode, createContext, use } from 'react';\n\nimport type { Field } from '@panneau/protocol';\n\nimport type { UploadSource } from '../upload/types';\nimport type { RelationSource } from './relation';\nimport type { FieldEntry } from './types';\n\n/** What a binding gives a field: its value, handlers and errors at a path. */\nexport interface BoundFieldProps {\n value: unknown;\n onChange: (value: unknown) => void;\n onBlur?: () => void;\n errors?: readonly string[];\n}\n\n/** Props of a binding: it decides whether a field shows, and where its value comes from. */\nexport interface FieldBindingProps {\n field: Field;\n /** Dot path of the field's value. */\n path: string;\n /** Dot path of the object the field belongs to: `''` at the top, `blocks.2` in a block. */\n parentPath: string;\n /** Renders the field with its bound value. */\n render: (bound: BoundFieldProps) => ReactNode;\n}\n\n/**\n * Binds nested fields (in groups, blocks and localized values) to a store by path, instead of the\n * value and `onChange` of their parent. `@panneau/forms` binds them to its form state, so that\n * every value is set, validated and shown in error by its own path.\n */\nexport type FieldBinding = ComponentType<FieldBindingProps>;\n\nexport interface FieldsContextValue {\n /** Registry entries, by field type, over the built-in ones. */\n components: Readonly<Record<string, FieldEntry>>;\n /** Locales of localized values, in order. */\n locales: readonly string[];\n /** Where relation fields search for items. */\n relationSource: RelationSource | null;\n /**\n * Where fields that take files upload them directly to storage. Without one, they give the\n * files themselves.\n */\n uploadSource: UploadSource | null;\n binding: FieldBinding | null;\n}\n\nconst FieldsContext = createContext<FieldsContextValue>({\n components: {},\n locales: [],\n relationSource: null,\n uploadSource: null,\n binding: null,\n});\n\n/** The fields context of the closest `FieldsProvider`. */\nexport function useFieldsContext(): FieldsContextValue {\n return use(FieldsContext);\n}\n\nexport interface FieldsProviderProps {\n /** Registry entries by type, added over those of a parent provider. */\n components?: Readonly<Record<string, FieldEntry>>;\n locales?: readonly string[];\n relationSource?: RelationSource | null;\n /** Make it once, outside of render: fields make an uploader for each source they get. */\n uploadSource?: UploadSource | null;\n binding?: FieldBinding | null;\n children?: ReactNode;\n}\n\n/**\n * Provides what fields rendered from a definition need: the components of each type, the locales\n * of localized values,
|
|
1
|
+
{"version":3,"file":"context.js","names":["value","children","_c"],"sources":["../../src/shared/context.tsx"],"sourcesContent":["import { type ComponentType, type ReactNode, createContext, use } from 'react';\n\nimport type { Field } from '@panneau/protocol';\n\nimport type { MapsConfig } from '../location/types';\nimport type { UploadSource } from '../upload/types';\nimport type { FieldCheckSource } from './check';\nimport type { EmbedSource } from './embed';\nimport type { RelationSource } from './relation';\nimport type { FieldEntry } from './types';\n\n/** What a binding gives a field: its value, handlers and errors at a path. */\nexport interface BoundFieldProps {\n value: unknown;\n onChange: (value: unknown) => void;\n onBlur?: () => void;\n errors?: readonly string[];\n}\n\n/** Props of a binding: it decides whether a field shows, and where its value comes from. */\nexport interface FieldBindingProps {\n field: Field;\n /** Dot path of the field's value. */\n path: string;\n /** Dot path of the object the field belongs to: `''` at the top, `blocks.2` in a block. */\n parentPath: string;\n /** Renders the field with its bound value. */\n render: (bound: BoundFieldProps) => ReactNode;\n}\n\n/**\n * Binds nested fields (in groups, blocks and localized values) to a store by path, instead of the\n * value and `onChange` of their parent. `@panneau/forms` binds them to its form state, so that\n * every value is set, validated and shown in error by its own path.\n */\nexport type FieldBinding = ComponentType<FieldBindingProps>;\n\nexport interface FieldsContextValue {\n /** Registry entries, by field type, over the built-in ones. */\n components: Readonly<Record<string, FieldEntry>>;\n /** Locales of localized values, in order. */\n locales: readonly string[];\n /** Where relation fields search for items. */\n relationSource: RelationSource | null;\n /**\n * Where fields that take files upload them directly to storage. Without one, they give the\n * files themselves.\n */\n uploadSource: UploadSource | null;\n /** Where fields with `check` check their value, such as a slug's availability. */\n checkSource: FieldCheckSource | null;\n /** Where `embed` fields get what a URL embeds. Without one, they keep the URL alone. */\n embedSource: EmbedSource | null;\n /** The tiles and the address search of `location` fields. */\n maps: MapsConfig | null;\n binding: FieldBinding | null;\n}\n\nconst FieldsContext = createContext<FieldsContextValue>({\n components: {},\n locales: [],\n relationSource: null,\n uploadSource: null,\n checkSource: null,\n embedSource: null,\n maps: null,\n binding: null,\n});\n\n/** The fields context of the closest `FieldsProvider`. */\nexport function useFieldsContext(): FieldsContextValue {\n return use(FieldsContext);\n}\n\nexport interface FieldsProviderProps {\n /** Registry entries by type, added over those of a parent provider. */\n components?: Readonly<Record<string, FieldEntry>>;\n locales?: readonly string[];\n relationSource?: RelationSource | null;\n /** Make it once, outside of render: fields make an uploader for each source they get. */\n uploadSource?: UploadSource | null;\n /** `createFieldCheckSource(adapter, resource, id)`, for the form of an item. */\n checkSource?: FieldCheckSource | null;\n /** `createEmbedSource(adapter)`. */\n embedSource?: EmbedSource | null;\n /** The tiles and the address search of `location` fields. */\n maps?: MapsConfig | null;\n binding?: FieldBinding | null;\n children?: ReactNode;\n}\n\n/**\n * Provides what fields rendered from a definition need: the components of each type, the locales\n * of localized values, the sources of relations, uploads, checks and embeds, the maps of\n * locations, and a binding. Values not given come from the parent provider.\n */\nexport function FieldsProvider({\n components,\n locales,\n relationSource,\n uploadSource,\n checkSource,\n embedSource,\n maps,\n binding,\n children,\n}: FieldsProviderProps) {\n const parent = use(FieldsContext);\n const value: FieldsContextValue = {\n components:\n components !== undefined ? { ...parent.components, ...components } : parent.components,\n locales: locales ?? parent.locales,\n relationSource: relationSource === undefined ? parent.relationSource : relationSource,\n uploadSource: uploadSource === undefined ? parent.uploadSource : uploadSource,\n checkSource: checkSource === undefined ? parent.checkSource : checkSource,\n embedSource: embedSource === undefined ? parent.embedSource : embedSource,\n maps: maps === undefined ? parent.maps : maps,\n binding: binding === undefined ? parent.binding : binding,\n };\n return <FieldsContext value={value}>{children}</FieldsContext>;\n}\n\n/** The parent path of a path: `blocks.2` for `blocks.2.title`, `''` for `title`. */\nexport function getParentPath(path: string): string {\n const index = path.lastIndexOf('.');\n return index === -1 ? '' : path.slice(0, index);\n}\n"],"mappings":";;;;AA0DA,IAAM,gBAAgB,cAAkC;CACpD,YAAY,CAAC;CACb,SAAS,CAAA;CACT,gBAAgB;CAChB,cAAc;CACd,aAAa;CACb,aAAa;CACb,MAAM;CACN,SAAS;AACb,CAAC;;AAGD,SAAgB,mBAAuC;CACnD,OAAO,IAAI,aAAa;AAC5B;;;;;;AAwBA,SAAO,eAAA,IAAA;CAAA,MAAA,IAAAE,EAAA,EAAA;CAAwB,MAAA,EAAA,YAAA,SAAA,gBAAA,cAAA,aAAA,aAAA,MAAA,SAAA,aAAA;CAW3B,MAAA,SAAe,IAAI,aAAa;CAAE,IAAA;CAAA,IAAA,EAAA,OAAA,cAAA,EAAA,OAAA,OAAA,YAAA;EAG1B,KAAA,eAAe,KAAA,IAAf;GAAA,GAAgC,OAAM;GAAW,GAAK;EAA+B,IAAhB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AAK,MAAM,GAAG,KAAK;AAClD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { EmbedValue } from '@panneau/protocol';
|
|
2
|
+
/** Where `embed` fields get what a URL embeds: the backend, from the provider's oEmbed. */
|
|
3
|
+
export interface EmbedSource {
|
|
4
|
+
resolve(url: string, options: {
|
|
5
|
+
signal: AbortSignal;
|
|
6
|
+
}): Promise<EmbedValue>;
|
|
7
|
+
}
|
|
8
|
+
/** What `createEmbedSource()` needs from an adapter: the `resolveEmbed()` of `@panneau/data`. */
|
|
9
|
+
export interface EmbedAdapter {
|
|
10
|
+
resolveEmbed?(url: string, options?: {
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
}): Promise<EmbedValue>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The embed source of an adapter (`GET /embeds?url=`). Null when the adapter can't resolve
|
|
16
|
+
* embeds: `embed` fields then keep the URL alone.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createEmbedSource(adapter: EmbedAdapter): EmbedSource | null;
|
|
19
|
+
//# sourceMappingURL=embed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../../src/shared/embed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,2FAA2F;AAC3F,MAAM,WAAW,WAAW;IACxB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC/E;AAED,iGAAiG;AACjG,MAAM,WAAW,YAAY;IACzB,YAAY,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACvF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW,GAAG,IAAI,CAM3E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/shared/embed.ts
|
|
2
|
+
/**
|
|
3
|
+
* The embed source of an adapter (`GET /embeds?url=`). Null when the adapter can't resolve
|
|
4
|
+
* embeds: `embed` fields then keep the URL alone.
|
|
5
|
+
*/
|
|
6
|
+
function createEmbedSource(adapter) {
|
|
7
|
+
const { resolveEmbed } = adapter;
|
|
8
|
+
if (resolveEmbed === void 0) return null;
|
|
9
|
+
return { resolve: (url, { signal }) => resolveEmbed.call(adapter, url, { signal }) };
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { createEmbedSource };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=embed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed.js","names":[],"sources":["../../src/shared/embed.ts"],"sourcesContent":["import type { EmbedValue } from '@panneau/protocol';\n\n/** Where `embed` fields get what a URL embeds: the backend, from the provider's oEmbed. */\nexport interface EmbedSource {\n resolve(url: string, options: { signal: AbortSignal }): Promise<EmbedValue>;\n}\n\n/** What `createEmbedSource()` needs from an adapter: the `resolveEmbed()` of `@panneau/data`. */\nexport interface EmbedAdapter {\n resolveEmbed?(url: string, options?: { signal?: AbortSignal }): Promise<EmbedValue>;\n}\n\n/**\n * The embed source of an adapter (`GET /embeds?url=`). Null when the adapter can't resolve\n * embeds: `embed` fields then keep the URL alone.\n */\nexport function createEmbedSource(adapter: EmbedAdapter): EmbedSource | null {\n const { resolveEmbed } = adapter;\n if (resolveEmbed === undefined) {\n return null;\n }\n return { resolve: (url, { signal }) => resolveEmbed.call(adapter, url, { signal }) };\n}\n"],"mappings":";;;;;AAgBA,SAAgB,kBAAkB,SAA2C;CACzE,MAAM,EAAE,iBAAiB;CACzB,IAAI,iBAAiB,KAAA,GACjB,OAAO;CAEX,OAAO,EAAE,UAAU,KAAK,EAAE,aAAa,aAAa,KAAK,SAAS,KAAK,EAAE,OAAO,CAAC,EAAE;AACvF"}
|
package/dist/shared/types.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export interface FieldEntryProps {
|
|
|
43
43
|
readOnly?: boolean;
|
|
44
44
|
/** The object the field belongs to: the form's values, or a group or a block. */
|
|
45
45
|
parentValue?: unknown;
|
|
46
|
+
/** The locale of the value: the input of a locale of a localized field. */
|
|
47
|
+
locale?: string;
|
|
46
48
|
className?: string;
|
|
47
49
|
}
|
|
48
50
|
/** A registry entry: renders the field of a type from its definition. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;GAGG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IACzB,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IACrC,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,iCAAiC;IACjC,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6DAA6D;I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3
|
+
flex-direction: column;
|
|
4
|
+
gap: var(--panneau-space-1);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.panneau-slug-field-url {
|
|
8
|
+
overflow-wrap: anywhere;
|
|
9
|
+
color: var(--panneau-color-link);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.panneau-slug-field-taken {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-wrap: wrap;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: var(--panneau-space-2);
|
|
17
|
+
color: var(--panneau-color-warning);
|
|
18
|
+
}
|