@panneau/fields 5.0.0-alpha.2 → 5.0.0-alpha.21
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 +186 -20
- package/dist/address/AddressField.css +44 -0
- package/dist/address/AddressField.d.ts +37 -0
- package/dist/address/AddressField.d.ts.map +1 -0
- package/dist/address/AddressField.js +411 -0
- package/dist/address/AddressField.js.map +1 -0
- package/dist/address/AddressField.module.js +22 -0
- package/dist/address/AddressField.module.js.map +1 -0
- package/dist/address/address.d.ts +23 -0
- package/dist/address/address.d.ts.map +1 -0
- package/dist/address/address.js +58 -0
- package/dist/address/address.js.map +1 -0
- package/dist/address/index.d.ts +3 -0
- package/dist/address/index.d.ts.map +1 -0
- package/dist/address/index.js +3 -0
- package/dist/boolean/BooleanField.d.ts +1 -1
- package/dist/boolean/BooleanField.js +78 -17
- package/dist/boolean/BooleanField.js.map +1 -1
- package/dist/boolean/index.d.ts +1 -1
- package/dist/color/ColorField.css +9 -0
- package/dist/color/ColorField.d.ts +12 -5
- package/dist/color/ColorField.d.ts.map +1 -1
- package/dist/color/ColorField.js +341 -81
- package/dist/color/ColorField.js.map +1 -1
- package/dist/color/ColorField.module.js +4 -2
- package/dist/color/ColorField.module.js.map +1 -1
- package/dist/color/index.d.ts +2 -1
- package/dist/color/index.d.ts.map +1 -1
- package/dist/color/index.js +3 -1
- package/dist/color/palette.d.ts +23 -0
- package/dist/color/palette.d.ts.map +1 -0
- package/dist/color/palette.js +34 -0
- package/dist/color/palette.js.map +1 -0
- 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.css +42 -0
- package/dist/country/CountryField.d.ts +32 -0
- package/dist/country/CountryField.d.ts.map +1 -0
- package/dist/country/CountryField.js +424 -0
- package/dist/country/CountryField.js.map +1 -0
- package/dist/country/CountryField.module.js +20 -0
- package/dist/country/CountryField.module.js.map +1 -0
- package/dist/country/codes.d.ts +6 -0
- package/dist/country/codes.d.ts.map +1 -0
- package/dist/country/codes.js +261 -0
- package/dist/country/codes.js.map +1 -0
- package/dist/country/countries.d.ts +32 -0
- package/dist/country/countries.d.ts.map +1 -0
- package/dist/country/countries.js +60 -0
- package/dist/country/countries.js.map +1 -0
- package/dist/country/index.d.ts +3 -0
- package/dist/country/index.d.ts.map +1 -0
- package/dist/country/index.js +4 -0
- 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/date/DateField.d.ts +1 -1
- package/dist/date/DateField.js.map +1 -1
- package/dist/date/index.d.ts +1 -1
- package/dist/daterange/DateRangeField.css +9 -0
- package/dist/daterange/DateRangeField.d.ts +31 -0
- package/dist/daterange/DateRangeField.d.ts.map +1 -0
- package/dist/daterange/DateRangeField.js +372 -0
- package/dist/daterange/DateRangeField.js.map +1 -0
- package/dist/daterange/DateRangeField.module.js +12 -0
- package/dist/daterange/DateRangeField.module.js.map +1 -0
- package/dist/daterange/index.d.ts +3 -0
- package/dist/daterange/index.d.ts.map +1 -0
- package/dist/daterange/index.js +3 -0
- package/dist/daterange/range.d.ts +61 -0
- package/dist/daterange/range.d.ts.map +1 -0
- package/dist/daterange/range.js +119 -0
- package/dist/daterange/range.js.map +1 -0
- package/dist/datetime/DateTimeField.d.ts +1 -1
- package/dist/datetime/DateTimeField.js +107 -20
- package/dist/datetime/DateTimeField.js.map +1 -1
- package/dist/datetime/index.d.ts +1 -1
- package/dist/duration/DurationField.css +11 -0
- package/dist/duration/DurationField.d.ts +67 -0
- package/dist/duration/DurationField.d.ts.map +1 -0
- package/dist/duration/DurationField.js +260 -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/email/EmailField.d.ts +2 -2
- package/dist/email/EmailField.js.map +1 -1
- package/dist/email/index.d.ts +1 -1
- package/dist/embed/EmbedField.css +60 -0
- package/dist/embed/EmbedField.d.ts +29 -0
- package/dist/embed/EmbedField.d.ts.map +1 -0
- package/dist/embed/EmbedField.js +309 -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/file/FileField.css +54 -0
- package/dist/file/FileField.d.ts +50 -0
- package/dist/file/FileField.d.ts.map +1 -0
- package/dist/file/FileField.js +288 -0
- package/dist/file/FileField.js.map +1 -0
- package/dist/file/FileField.module.js +22 -0
- package/dist/file/FileField.module.js.map +1 -0
- package/dist/file/index.d.ts +3 -0
- package/dist/file/index.d.ts.map +1 -0
- package/dist/file/index.js +1 -0
- package/dist/group/GroupField.css +20 -3
- package/dist/group/GroupField.d.ts +10 -4
- package/dist/group/GroupField.d.ts.map +1 -1
- package/dist/group/GroupField.js +71 -66
- 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/group/index.d.ts +1 -1
- package/dist/index.d.ts +21 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -2
- 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 +207 -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/link/LinkField.css +12 -0
- package/dist/link/LinkField.d.ts +38 -0
- package/dist/link/LinkField.d.ts.map +1 -0
- package/dist/link/LinkField.js +742 -0
- package/dist/link/LinkField.js.map +1 -0
- package/dist/link/LinkField.module.js +8 -0
- package/dist/link/LinkField.module.js.map +1 -0
- package/dist/link/index.d.ts +3 -0
- package/dist/link/index.d.ts.map +1 -0
- package/dist/link/index.js +3 -0
- package/dist/link/link.d.ts +30 -0
- package/dist/link/link.d.ts.map +1 -0
- package/dist/link/link.js +63 -0
- package/dist/link/link.js.map +1 -0
- package/dist/link/pages.d.ts +17 -0
- package/dist/link/pages.d.ts.map +1 -0
- package/dist/link/pages.js +104 -0
- package/dist/link/pages.js.map +1 -0
- package/dist/locales/index.js.map +1 -1
- package/dist/localized/LocalizedField.css +27 -6
- package/dist/localized/LocalizedField.d.ts +19 -8
- package/dist/localized/LocalizedField.d.ts.map +1 -1
- package/dist/localized/LocalizedField.js +238 -105
- 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/localized/index.d.ts +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 +487 -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 +205 -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 +23 -0
- package/dist/location/nominatim.d.ts.map +1 -0
- package/dist/location/nominatim.js +79 -0
- package/dist/location/nominatim.js.map +1 -0
- package/dist/location/search.d.ts +10 -0
- package/dist/location/search.d.ts.map +1 -0
- package/dist/location/search.js +83 -0
- package/dist/location/search.js.map +1 -0
- package/dist/location/types.d.ts +46 -0
- package/dist/location/types.d.ts.map +1 -0
- package/dist/missing/MissingField.d.ts +4 -3
- package/dist/missing/MissingField.d.ts.map +1 -1
- package/dist/missing/MissingField.js +3 -2
- package/dist/missing/MissingField.js.map +1 -1
- package/dist/money/MoneyField.d.ts +28 -0
- package/dist/money/MoneyField.d.ts.map +1 -0
- package/dist/money/MoneyField.js +269 -0
- package/dist/money/MoneyField.js.map +1 -0
- package/dist/money/index.d.ts +3 -0
- package/dist/money/index.d.ts.map +1 -0
- package/dist/money/index.js +3 -0
- package/dist/money/money.d.ts +27 -0
- package/dist/money/money.d.ts.map +1 -0
- package/dist/money/money.js +56 -0
- package/dist/money/money.js.map +1 -0
- package/dist/number/NumberField.d.ts +1 -1
- package/dist/number/NumberField.js.map +1 -1
- package/dist/number/index.d.ts +1 -1
- package/dist/range/RangeField.d.ts +22 -0
- package/dist/range/RangeField.d.ts.map +1 -0
- package/dist/range/RangeField.js +203 -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/region/RegionField.d.ts +23 -0
- package/dist/region/RegionField.d.ts.map +1 -0
- package/dist/region/RegionField.js +174 -0
- package/dist/region/RegionField.js.map +1 -0
- package/dist/region/RegionFlag.css +9 -0
- package/dist/region/RegionFlag.d.ts +20 -0
- package/dist/region/RegionFlag.d.ts.map +1 -0
- package/dist/region/RegionFlag.js +61 -0
- package/dist/region/RegionFlag.js.map +1 -0
- package/dist/region/RegionFlag.module.js +8 -0
- package/dist/region/RegionFlag.module.js.map +1 -0
- package/dist/region/data.d.ts +5 -0
- package/dist/region/data.d.ts.map +1 -0
- package/dist/region/data.js +513 -0
- package/dist/region/data.js.map +1 -0
- package/dist/region/flags/CA.d.ts +4 -0
- package/dist/region/flags/CA.d.ts.map +1 -0
- package/dist/region/flags/CA.js +21 -0
- package/dist/region/flags/CA.js.map +1 -0
- package/dist/region/flags/US.d.ts +4 -0
- package/dist/region/flags/US.d.ts.map +1 -0
- package/dist/region/flags/US.js +65 -0
- package/dist/region/flags/US.js.map +1 -0
- package/dist/region/flags.d.ts +17 -0
- package/dist/region/flags.d.ts.map +1 -0
- package/dist/region/flags.js +84 -0
- package/dist/region/flags.js.map +1 -0
- package/dist/region/index.d.ts +5 -0
- package/dist/region/index.d.ts.map +1 -0
- package/dist/region/index.js +5 -0
- package/dist/region/regions.d.ts +15 -0
- package/dist/region/regions.d.ts.map +1 -0
- package/dist/region/regions.js +29 -0
- package/dist/region/regions.js.map +1 -0
- package/dist/relation/RelationField.d.ts +2 -2
- package/dist/relation/RelationField.d.ts.map +1 -1
- package/dist/relation/RelationField.js +511 -171
- package/dist/relation/RelationField.js.map +1 -1
- package/dist/relation/index.d.ts +2 -2
- package/dist/repeater/RepeaterField.d.ts +13 -2
- package/dist/repeater/RepeaterField.d.ts.map +1 -1
- package/dist/repeater/RepeaterField.js +138 -50
- package/dist/repeater/RepeaterField.js.map +1 -1
- package/dist/repeater/index.d.ts +1 -1
- package/dist/select/SelectField.d.ts +1 -1
- package/dist/select/SelectField.js.map +1 -1
- package/dist/select/index.d.ts +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.d.ts +21 -0
- package/dist/shared/CodeComboBox.d.ts.map +1 -0
- package/dist/shared/CodeComboBox.js +238 -0
- package/dist/shared/CodeComboBox.js.map +1 -0
- package/dist/shared/DefinitionField.d.ts +9 -4
- package/dist/shared/DefinitionField.d.ts.map +1 -1
- package/dist/shared/DefinitionField.js +98 -78
- package/dist/shared/DefinitionField.js.map +1 -1
- package/dist/shared/builtIn.d.ts +7 -3
- package/dist/shared/builtIn.d.ts.map +1 -1
- package/dist/shared/builtIn.js +39 -7
- 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 +33 -5
- package/dist/shared/context.d.ts.map +1 -1
- package/dist/shared/context.js +36 -20
- package/dist/shared/context.js.map +1 -1
- package/dist/shared/cx.js.map +1 -1
- package/dist/shared/dates.js +2 -2
- package/dist/shared/dates.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/entry.d.ts +13 -4
- package/dist/shared/entry.d.ts.map +1 -1
- package/dist/shared/entry.js +24 -7
- 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 +38 -0
- package/dist/shared/flow.js.map +1 -0
- package/dist/shared/part.d.ts +26 -0
- package/dist/shared/part.d.ts.map +1 -0
- package/dist/shared/part.js +64 -0
- package/dist/shared/part.js.map +1 -0
- package/dist/shared/relation.js.map +1 -1
- 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 +12 -0
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/slug/SlugField.css +18 -0
- package/dist/slug/SlugField.d.ts +33 -5
- package/dist/slug/SlugField.d.ts.map +1 -1
- package/dist/slug/SlugField.js +346 -126
- 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.css +25 -0
- package/dist/tel/TelField.d.ts +34 -0
- package/dist/tel/TelField.d.ts.map +1 -0
- package/dist/tel/TelField.js +390 -0
- package/dist/tel/TelField.js.map +1 -0
- package/dist/tel/TelField.module.js +12 -0
- package/dist/tel/TelField.module.js.map +1 -0
- package/dist/tel/index.d.ts +3 -0
- package/dist/tel/index.d.ts.map +1 -0
- package/dist/tel/index.js +3 -0
- package/dist/tel/phone.d.ts +59 -0
- package/dist/tel/phone.d.ts.map +1 -0
- package/dist/tel/phone.js +107 -0
- package/dist/tel/phone.js.map +1 -0
- package/dist/text/TextField.d.ts +12 -4
- package/dist/text/TextField.d.ts.map +1 -1
- package/dist/text/TextField.js +104 -60
- package/dist/text/TextField.js.map +1 -1
- package/dist/text/index.d.ts +1 -1
- package/dist/textarea/TextAreaField.d.ts +1 -1
- package/dist/textarea/TextAreaField.js.map +1 -1
- package/dist/textarea/index.d.ts +1 -1
- package/dist/time/TimeField.d.ts +1 -1
- package/dist/time/TimeField.js +64 -10
- package/dist/time/TimeField.js.map +1 -1
- package/dist/time/index.d.ts +1 -1
- package/dist/upload/FilePicker.css +24 -0
- package/dist/upload/FilePicker.d.ts +14 -0
- package/dist/upload/FilePicker.d.ts.map +1 -0
- package/dist/upload/FilePicker.js +130 -0
- package/dist/upload/FilePicker.js.map +1 -0
- package/dist/upload/FilePicker.module.js +12 -0
- package/dist/upload/FilePicker.module.js.map +1 -0
- package/dist/upload/UploadList.css +93 -0
- package/dist/upload/UploadList.d.ts +18 -0
- package/dist/upload/UploadList.d.ts.map +1 -0
- package/dist/upload/UploadList.js +144 -0
- package/dist/upload/UploadList.js.map +1 -0
- package/dist/upload/UploadList.module.js +32 -0
- package/dist/upload/UploadList.module.js.map +1 -0
- package/dist/upload/files.d.ts +5 -0
- package/dist/upload/files.d.ts.map +1 -0
- package/dist/upload/files.js +26 -0
- package/dist/upload/files.js.map +1 -0
- package/dist/upload/types.d.ts +58 -0
- package/dist/upload/types.d.ts.map +1 -0
- package/dist/upload/useRejectionMessage.d.ts +4 -0
- package/dist/upload/useRejectionMessage.d.ts.map +1 -0
- package/dist/upload/useRejectionMessage.js +25 -0
- package/dist/upload/useRejectionMessage.js.map +1 -0
- package/dist/upload/useUploads.d.ts +30 -0
- package/dist/upload/useUploads.d.ts.map +1 -0
- package/dist/upload/useUploads.js +115 -0
- package/dist/upload/useUploads.js.map +1 -0
- package/dist/uppy/index.d.ts +3 -0
- package/dist/uppy/index.d.ts.map +1 -0
- package/dist/uppy/index.js +1 -0
- package/dist/uppy/uploader.d.ts +44 -0
- package/dist/uppy/uploader.d.ts.map +1 -0
- package/dist/uppy/uploader.js +139 -0
- package/dist/uppy/uploader.js.map +1 -0
- package/dist/url/UrlField.d.ts +2 -2
- package/dist/url/UrlField.d.ts.map +1 -1
- package/dist/url/UrlField.js +69 -14
- package/dist/url/UrlField.js.map +1 -1
- package/dist/url/index.d.ts +1 -1
- package/package.json +110 -7
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { GroupFieldEntry } from "../group/GroupField.js";
|
|
1
2
|
import { getParentPath, useFieldsContext } from "./context.js";
|
|
2
3
|
import { LocalizedFieldEntry } from "../localized/LocalizedField.js";
|
|
3
4
|
import { MissingFieldEntry } from "../missing/MissingField.js";
|
|
5
|
+
import { RepeaterFieldEntry } from "../repeater/RepeaterField.js";
|
|
4
6
|
import { builtInFields } from "./builtIn.js";
|
|
5
7
|
import { c } from "react/compiler-runtime";
|
|
6
|
-
import { evaluateCondition } from "@panneau/protocol/runtime";
|
|
8
|
+
import { evaluateCondition, getNestedShape } from "@panneau/protocol/runtime";
|
|
7
9
|
import { jsx } from "react/jsx-runtime";
|
|
8
10
|
//#region src/shared/DefinitionField.tsx
|
|
9
11
|
/**
|
|
@@ -13,115 +15,132 @@ import { jsx } from "react/jsx-runtime";
|
|
|
13
15
|
* parent value is false.
|
|
14
16
|
*/
|
|
15
17
|
function NestedField(t0) {
|
|
16
|
-
const $ = c(
|
|
17
|
-
const { field, path, value, onChange, onBlur, errors, parentValue, disabled, readOnly, className } = t0;
|
|
18
|
+
const $ = c(39);
|
|
19
|
+
const { field, path, value, onChange, onBlur, errors, parentValue, locale, hideLabel, disabled, readOnly, className } = t0;
|
|
18
20
|
const { binding: Binding } = useFieldsContext();
|
|
19
21
|
let t1;
|
|
20
|
-
if ($[0] !==
|
|
21
|
-
t1 =
|
|
22
|
-
$[0] =
|
|
22
|
+
if ($[0] !== locale) {
|
|
23
|
+
t1 = locale !== void 0 ? { locale } : {};
|
|
24
|
+
$[0] = locale;
|
|
23
25
|
$[1] = t1;
|
|
24
26
|
} else t1 = $[1];
|
|
25
27
|
let t2;
|
|
26
|
-
if ($[2] !==
|
|
27
|
-
t2 =
|
|
28
|
-
$[2] =
|
|
28
|
+
if ($[2] !== hideLabel) {
|
|
29
|
+
t2 = hideLabel !== void 0 ? { hideLabel } : {};
|
|
30
|
+
$[2] = hideLabel;
|
|
29
31
|
$[3] = t2;
|
|
30
32
|
} else t2 = $[3];
|
|
31
33
|
let t3;
|
|
32
|
-
if ($[4] !==
|
|
33
|
-
t3 =
|
|
34
|
-
$[4] =
|
|
34
|
+
if ($[4] !== disabled) {
|
|
35
|
+
t3 = disabled !== void 0 ? { disabled } : {};
|
|
36
|
+
$[4] = disabled;
|
|
35
37
|
$[5] = t3;
|
|
36
38
|
} else t3 = $[5];
|
|
37
39
|
let t4;
|
|
38
|
-
if ($[6] !==
|
|
39
|
-
t4 = {
|
|
40
|
+
if ($[6] !== readOnly) {
|
|
41
|
+
t4 = readOnly !== void 0 ? { readOnly } : {};
|
|
42
|
+
$[6] = readOnly;
|
|
43
|
+
$[7] = t4;
|
|
44
|
+
} else t4 = $[7];
|
|
45
|
+
let t5;
|
|
46
|
+
if ($[8] !== className) {
|
|
47
|
+
t5 = className !== void 0 ? { className } : {};
|
|
48
|
+
$[8] = className;
|
|
49
|
+
$[9] = t5;
|
|
50
|
+
} else t5 = $[9];
|
|
51
|
+
let t6;
|
|
52
|
+
if ($[10] !== field || $[11] !== parentValue || $[12] !== path || $[13] !== t1 || $[14] !== t2 || $[15] !== t3 || $[16] !== t4 || $[17] !== t5) {
|
|
53
|
+
t6 = {
|
|
40
54
|
field,
|
|
41
55
|
path,
|
|
42
56
|
parentValue,
|
|
43
57
|
...t1,
|
|
44
58
|
...t2,
|
|
45
|
-
...t3
|
|
59
|
+
...t3,
|
|
60
|
+
...t4,
|
|
61
|
+
...t5
|
|
46
62
|
};
|
|
47
|
-
$[
|
|
48
|
-
$[
|
|
49
|
-
$[
|
|
50
|
-
$[
|
|
51
|
-
$[
|
|
52
|
-
$[
|
|
53
|
-
$[
|
|
54
|
-
|
|
55
|
-
|
|
63
|
+
$[10] = field;
|
|
64
|
+
$[11] = parentValue;
|
|
65
|
+
$[12] = path;
|
|
66
|
+
$[13] = t1;
|
|
67
|
+
$[14] = t2;
|
|
68
|
+
$[15] = t3;
|
|
69
|
+
$[16] = t4;
|
|
70
|
+
$[17] = t5;
|
|
71
|
+
$[18] = t6;
|
|
72
|
+
} else t6 = $[18];
|
|
73
|
+
const shared = t6;
|
|
56
74
|
if (Binding !== null) {
|
|
57
|
-
let
|
|
58
|
-
if ($[
|
|
59
|
-
|
|
60
|
-
$[
|
|
61
|
-
$[
|
|
62
|
-
} else
|
|
63
|
-
let
|
|
64
|
-
if ($[
|
|
65
|
-
|
|
75
|
+
let t7;
|
|
76
|
+
if ($[19] !== path) {
|
|
77
|
+
t7 = getParentPath(path);
|
|
78
|
+
$[19] = path;
|
|
79
|
+
$[20] = t7;
|
|
80
|
+
} else t7 = $[20];
|
|
81
|
+
let t8;
|
|
82
|
+
if ($[21] !== shared) {
|
|
83
|
+
t8 = (bound) => /* @__PURE__ */ jsx(DefinitionField, {
|
|
66
84
|
...shared,
|
|
67
85
|
...bound
|
|
68
86
|
});
|
|
69
|
-
$[
|
|
70
|
-
$[
|
|
71
|
-
} else
|
|
72
|
-
let
|
|
73
|
-
if ($[
|
|
74
|
-
|
|
87
|
+
$[21] = shared;
|
|
88
|
+
$[22] = t8;
|
|
89
|
+
} else t8 = $[22];
|
|
90
|
+
let t9;
|
|
91
|
+
if ($[23] !== Binding || $[24] !== field || $[25] !== path || $[26] !== t7 || $[27] !== t8) {
|
|
92
|
+
t9 = /* @__PURE__ */ jsx(Binding, {
|
|
75
93
|
field,
|
|
76
94
|
path,
|
|
77
|
-
parentPath:
|
|
78
|
-
render:
|
|
95
|
+
parentPath: t7,
|
|
96
|
+
render: t8
|
|
79
97
|
});
|
|
80
|
-
$[
|
|
81
|
-
$[
|
|
82
|
-
$[
|
|
83
|
-
$[
|
|
84
|
-
$[
|
|
85
|
-
$[
|
|
86
|
-
} else
|
|
87
|
-
return
|
|
98
|
+
$[23] = Binding;
|
|
99
|
+
$[24] = field;
|
|
100
|
+
$[25] = path;
|
|
101
|
+
$[26] = t7;
|
|
102
|
+
$[27] = t8;
|
|
103
|
+
$[28] = t9;
|
|
104
|
+
} else t9 = $[28];
|
|
105
|
+
return t9;
|
|
88
106
|
}
|
|
89
107
|
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];
|
|
97
|
-
let t7;
|
|
98
|
-
if ($[25] !== errors) {
|
|
99
|
-
t7 = errors !== void 0 ? { errors } : {};
|
|
100
|
-
$[25] = errors;
|
|
101
|
-
$[26] = t7;
|
|
102
|
-
} else t7 = $[26];
|
|
108
|
+
const t7 = onChange ?? _temp;
|
|
103
109
|
let t8;
|
|
104
|
-
if ($[
|
|
105
|
-
t8 =
|
|
110
|
+
if ($[29] !== onBlur) {
|
|
111
|
+
t8 = onBlur !== void 0 ? { onBlur } : {};
|
|
112
|
+
$[29] = onBlur;
|
|
113
|
+
$[30] = t8;
|
|
114
|
+
} else t8 = $[30];
|
|
115
|
+
let t9;
|
|
116
|
+
if ($[31] !== errors) {
|
|
117
|
+
t9 = errors !== void 0 ? { errors } : {};
|
|
118
|
+
$[31] = errors;
|
|
119
|
+
$[32] = t9;
|
|
120
|
+
} else t9 = $[32];
|
|
121
|
+
let t10;
|
|
122
|
+
if ($[33] !== shared || $[34] !== t7 || $[35] !== t8 || $[36] !== t9 || $[37] !== value) {
|
|
123
|
+
t10 = /* @__PURE__ */ jsx(DefinitionField, {
|
|
106
124
|
...shared,
|
|
107
125
|
value,
|
|
108
|
-
onChange:
|
|
109
|
-
...
|
|
110
|
-
...
|
|
126
|
+
onChange: t7,
|
|
127
|
+
...t8,
|
|
128
|
+
...t9
|
|
111
129
|
});
|
|
112
|
-
$[
|
|
113
|
-
$[
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
-
} else
|
|
119
|
-
return
|
|
130
|
+
$[33] = shared;
|
|
131
|
+
$[34] = t7;
|
|
132
|
+
$[35] = t8;
|
|
133
|
+
$[36] = t9;
|
|
134
|
+
$[37] = value;
|
|
135
|
+
$[38] = t10;
|
|
136
|
+
} else t10 = $[38];
|
|
137
|
+
return t10;
|
|
120
138
|
}
|
|
121
139
|
/**
|
|
122
140
|
* Renders a field of the definition with the entry of its type: from the fields context, or a
|
|
123
|
-
* built-in one. A localized field renders an input per locale. A
|
|
124
|
-
*
|
|
141
|
+
* built-in one. A localized field renders an input per locale. A compound field without an entry
|
|
142
|
+
* (decision 0065) renders as a group, or as a repeater with `multiple`. Another type without an
|
|
143
|
+
* entry renders a placeholder that names the missing plugin.
|
|
125
144
|
*/
|
|
126
145
|
function _temp() {}
|
|
127
146
|
function DefinitionField(props) {
|
|
@@ -137,7 +156,8 @@ function DefinitionField(props) {
|
|
|
137
156
|
} else t0 = $[1];
|
|
138
157
|
return t0;
|
|
139
158
|
}
|
|
140
|
-
const
|
|
159
|
+
const shape = getNestedShape(field);
|
|
160
|
+
const Entry = components[field.type] ?? builtInFields[field.type] ?? (shape === "repeater" ? RepeaterFieldEntry : shape === "group" ? GroupFieldEntry : MissingFieldEntry);
|
|
141
161
|
let t0;
|
|
142
162
|
if ($[2] !== Entry || $[3] !== props) {
|
|
143
163
|
t0 = /* @__PURE__ */ jsx(Entry, { ...props });
|
|
@@ -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
|
|
1
|
+
{"version":3,"file":"DefinitionField.js","names":["Field","evaluateCondition","getNestedShape","GroupFieldEntry","LocalizedFieldEntry","MissingFieldEntry","RepeaterFieldEntry","builtInFields","getParentPath","useFieldsContext","FieldEntryProps","NestedFieldProps","field","path","value","onChange","onBlur","errors","parentValue","locale","hideLabel","disabled","readOnly","className","NestedField","t0","$","_c","binding","Binding","t1","undefined","t2","t3","t4","t5","t6","shared","t7","t8","bound","t9","visibleWhen","_temp","t10","DefinitionField","props","components","localized","shape","Entry","type","_c"],"sources":["../../src/shared/DefinitionField.tsx"],"sourcesContent":["import type { Field } from '@panneau/protocol';\nimport { evaluateCondition, getNestedShape } 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 { GroupFieldEntry } from '../group/GroupField';\nimport { LocalizedFieldEntry } from '../localized/LocalizedField';\nimport { MissingFieldEntry } from '../missing/MissingField';\nimport { RepeaterFieldEntry } from '../repeater/RepeaterField';\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 /** Renders the field without a visible label, named by its label for assistive technologies. */\n hideLabel?: boolean;\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 hideLabel,\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 ...(hideLabel !== undefined ? { hideLabel } : {}),\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 compound field without an entry\n * (decision 0065) renders as a group, or as a repeater with `multiple`. Another type without an\n * entry renders a 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 shape = getNestedShape(field);\n const Entry =\n components[field.type] ??\n builtInFields[field.type] ??\n (shape === 'repeater'\n ? RepeaterFieldEntry\n : shape === 'group'\n ? GroupFieldEntry\n : MissingFieldEntry);\n return <Entry {...props} />;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyCA,SAAOwB,YAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAqB,MAAA,EAAAf,OAAAC,MAAAC,OAAAC,UAAAC,QAAAC,QAAAC,aAAAC,QAAAC,WAAAC,UAAAC,UAAAC,cAAAE;CAcxB,MAAA,EAAAG,SAAAC,YAA6BpB,iBAAiB;CAAE,IAAAqB;CAAA,IAAAJ,EAAA,OAAAP,QAAA;EAKxCW,KAAAX,WAAWY,KAAAA,IAAX,EAAAZ,OAAqC,IAArC,CAAqC;EAACO,EAAA,KAAAP;EAAAO,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAM;CAAA,IAAAN,EAAA,OAAAN,WAAA;EACtCY,KAAAZ,cAAcW,KAAAA,IAAd,EAAAX,UAA2C,IAA3C,CAA2C;EAACM,EAAA,KAAAN;EAAAM,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAAA,IAAAO;CAAA,IAAAP,EAAA,OAAAL,UAAA;EAC5CY,KAAAZ,aAAaU,KAAAA,IAAb,EA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cf,EAAA,MAAAW;EAAAX,EAAA,MAAAY;EAAAZ,EAAA,MAAAa;EAAAb,EAAA,MAAAe;EAAAf,EAAA,MAAAZ;EAAAY,EAAA,MAAAkB;CAAA,OAAAA,MAAAlB,EAAA;CAAA,OANFkB;AAME;;;;;;;AA7CH,SAAAD,QAAA,CAAA;AAuDP,SAAOE,gBAAAC,OAAA;CAAA,MAAApB,IAAAC,EAAA,CAAA;CACH,MAAA,EAAAoB,eAAuBtC,iBAAiB;CACxC,MAAA,EAAAG,UAAkBkC;CAClB,IAAIlC,MAAKoC,cAAe,MAAI;EAAA,IAAAvB;EAAA,IAAAC,EAAA,OAAAoB,OAAA;GACjBrB,KAAA,oBAAC,qBAAD,EAAoB,GAAKqB,MAAK,CAAA;GAAIpB,EAAA,KAAAoB;GAAApB,EAAA,KAAAD;EAAA,OAAAA,KAAAC,EAAA;EAAA,OAAlCD;CAAkC;CAE7C,MAAAwB,QAAc/C,eAAeU,KAAK;CAClC,MAAAsC,QACIH,WAAWnC,MAAKuC,SAChB5C,cAAcK,MAAKuC,UAClBF,UAAU,aAAV3C,qBAEK2C,UAAU,UAAV9C,kBAAAE;CAEqB,IAAAoB;CAAA,IAAAC,EAAA,OAAAwB,SAAAxB,EAAA,OAAAoB,OAAA;EACxBrB,KAAA,oBAAC,OAAD,EAAM,GAAKqB,MAAK,CAAA;EAAIpB,EAAA,KAAAwB;EAAAxB,EAAA,KAAAoB;EAAApB,EAAA,KAAAD;CAAA,OAAAA,KAAAC,EAAA;CAAA,OAApBD;AAAoB"}
|
package/dist/shared/builtIn.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type { FieldEntry } from './types';
|
|
1
|
+
import type { FieldEntry } from './types.js';
|
|
2
2
|
/**
|
|
3
|
-
* The entries of the built-in field types. `richtext` and `media` come with their plugins
|
|
4
|
-
*
|
|
3
|
+
* The entries of the built-in field types. `richtext` and `media` come with their plugins
|
|
4
|
+
* (`@panneau/editor` and `@panneau/media`): without them, `DefinitionField` renders a placeholder.
|
|
5
|
+
* `file` uploads through the upload source of the fields context, or gives the files themselves.
|
|
6
|
+
* `embed`, `location` and `address` use its embed source and its maps; `location` loads Leaflet
|
|
7
|
+
* when shown. `link` searches its pages with the relation source, and picks its files with the
|
|
8
|
+
* `media` entry.
|
|
5
9
|
*/
|
|
6
10
|
export declare const builtInFields: Readonly<Record<string, FieldEntry>>;
|
|
7
11
|
/**
|
|
@@ -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":"AA+BA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CA8B9D,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
|
@@ -1,23 +1,41 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GroupFieldEntry } from "../group/GroupField.js";
|
|
2
|
+
import { RepeaterFieldEntry } from "../repeater/RepeaterField.js";
|
|
3
|
+
import { CountryFieldEntry } from "../country/CountryField.js";
|
|
4
|
+
import { LocationFieldEntry } from "../location/LocationField.js";
|
|
2
5
|
import { TextFieldEntry } from "../text/TextField.js";
|
|
6
|
+
import { RegionFieldEntry } from "../region/RegionField.js";
|
|
7
|
+
import { AddressFieldEntry } from "../address/AddressField.js";
|
|
8
|
+
import { BooleanFieldEntry } from "../boolean/BooleanField.js";
|
|
3
9
|
import { ColorFieldEntry } from "../color/ColorField.js";
|
|
4
10
|
import { DateFieldEntry } from "../date/DateField.js";
|
|
11
|
+
import { DateRangeFieldEntry } from "../daterange/DateRangeField.js";
|
|
5
12
|
import { DateTimeFieldEntry } from "../datetime/DateTimeField.js";
|
|
13
|
+
import { DurationFieldEntry } from "../duration/DurationField.js";
|
|
6
14
|
import { EmailFieldEntry } from "../email/EmailField.js";
|
|
7
|
-
import {
|
|
15
|
+
import { EmbedFieldEntry } from "../embed/EmbedField.js";
|
|
16
|
+
import { FileFieldEntry } from "../file/FileField.js";
|
|
17
|
+
import { JsonFieldEntry } from "../json/JsonField.js";
|
|
18
|
+
import { TelFieldEntry } from "../tel/TelField.js";
|
|
19
|
+
import { UrlFieldEntry } from "../url/UrlField.js";
|
|
20
|
+
import { LinkFieldEntry } from "../link/LinkField.js";
|
|
21
|
+
import { MoneyFieldEntry } from "../money/MoneyField.js";
|
|
8
22
|
import { NumberFieldEntry } from "../number/NumberField.js";
|
|
23
|
+
import { RangeFieldEntry } from "../range/RangeField.js";
|
|
9
24
|
import { RelationFieldEntry } from "../relation/RelationField.js";
|
|
10
|
-
import { RepeaterFieldEntry } from "../repeater/RepeaterField.js";
|
|
11
25
|
import { SelectFieldEntry } from "../select/SelectField.js";
|
|
12
26
|
import { SlugFieldEntry } from "../slug/SlugField.js";
|
|
27
|
+
import { TagsFieldEntry } from "../tags/TagsField.js";
|
|
13
28
|
import { TextAreaFieldEntry } from "../textarea/TextAreaField.js";
|
|
14
29
|
import { TimeFieldEntry } from "../time/TimeField.js";
|
|
15
|
-
import { UrlFieldEntry } from "../url/UrlField.js";
|
|
16
30
|
import { fr } from "@panneau/intl";
|
|
17
31
|
//#region src/shared/builtIn.ts
|
|
18
32
|
/**
|
|
19
|
-
* The entries of the built-in field types. `richtext` and `media` come with their plugins
|
|
20
|
-
*
|
|
33
|
+
* The entries of the built-in field types. `richtext` and `media` come with their plugins
|
|
34
|
+
* (`@panneau/editor` and `@panneau/media`): without them, `DefinitionField` renders a placeholder.
|
|
35
|
+
* `file` uploads through the upload source of the fields context, or gives the files themselves.
|
|
36
|
+
* `embed`, `location` and `address` use its embed source and its maps; `location` loads Leaflet
|
|
37
|
+
* when shown. `link` searches its pages with the relation source, and picks its files with the
|
|
38
|
+
* `media` entry.
|
|
21
39
|
*/
|
|
22
40
|
var builtInFields = {
|
|
23
41
|
text: TextFieldEntry,
|
|
@@ -32,9 +50,23 @@ var builtInFields = {
|
|
|
32
50
|
url: UrlFieldEntry,
|
|
33
51
|
color: ColorFieldEntry,
|
|
34
52
|
slug: SlugFieldEntry,
|
|
53
|
+
file: FileFieldEntry,
|
|
35
54
|
relation: RelationFieldEntry,
|
|
36
55
|
group: GroupFieldEntry,
|
|
37
|
-
repeater: RepeaterFieldEntry
|
|
56
|
+
repeater: RepeaterFieldEntry,
|
|
57
|
+
tel: TelFieldEntry,
|
|
58
|
+
range: RangeFieldEntry,
|
|
59
|
+
duration: DurationFieldEntry,
|
|
60
|
+
json: JsonFieldEntry,
|
|
61
|
+
tags: TagsFieldEntry,
|
|
62
|
+
embed: EmbedFieldEntry,
|
|
63
|
+
location: LocationFieldEntry,
|
|
64
|
+
country: CountryFieldEntry,
|
|
65
|
+
region: RegionFieldEntry,
|
|
66
|
+
address: AddressFieldEntry,
|
|
67
|
+
link: LinkFieldEntry,
|
|
68
|
+
daterange: DateRangeFieldEntry,
|
|
69
|
+
money: MoneyFieldEntry
|
|
38
70
|
};
|
|
39
71
|
/**
|
|
40
72
|
* 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 { 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
|
|
1
|
+
{"version":3,"file":"builtIn.js","names":["fr","AddressFieldEntry","BooleanFieldEntry","ColorFieldEntry","CountryFieldEntry","DateFieldEntry","DateRangeFieldEntry","DateTimeFieldEntry","DurationFieldEntry","EmailFieldEntry","EmbedFieldEntry","FileFieldEntry","GroupFieldEntry","JsonFieldEntry","LinkFieldEntry","LocationFieldEntry","MoneyFieldEntry","NumberFieldEntry","RangeFieldEntry","RegionFieldEntry","RelationFieldEntry","RepeaterFieldEntry","SelectFieldEntry","SlugFieldEntry","TagsFieldEntry","TelFieldEntry","TextFieldEntry","TextAreaFieldEntry","TimeFieldEntry","UrlFieldEntry","FieldEntry","builtInFields","Readonly","Record","text","textarea","number","boolean","date","datetime","time","select","email","url","color","slug","file","relation","group","repeater","tel","range","duration","json","tags","embed","location","country","region","address","link","daterange","money","fieldsPlugin","id","fields","locales"],"sources":["../../src/shared/builtIn.ts"],"sourcesContent":["import { fr } from '@panneau/intl';\n\nimport { AddressFieldEntry } from '../address/AddressField';\nimport { BooleanFieldEntry } from '../boolean/BooleanField';\nimport { ColorFieldEntry } from '../color/ColorField';\nimport { CountryFieldEntry } from '../country/CountryField';\nimport { DateFieldEntry } from '../date/DateField';\nimport { DateRangeFieldEntry } from '../daterange/DateRangeField';\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 { LinkFieldEntry } from '../link/LinkField';\nimport { LocationFieldEntry } from '../location/LocationField';\nimport { MoneyFieldEntry } from '../money/MoneyField';\nimport { NumberFieldEntry } from '../number/NumberField';\nimport { RangeFieldEntry } from '../range/RangeField';\nimport { RegionFieldEntry } from '../region/RegionField';\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`, `location` and `address` use its embed source and its maps; `location` loads Leaflet\n * when shown. `link` searches its pages with the relation source, and picks its files with the\n * `media` entry.\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 country: CountryFieldEntry,\n region: RegionFieldEntry,\n address: AddressFieldEntry,\n link: LinkFieldEntry,\n daterange: DateRangeFieldEntry,\n money: MoneyFieldEntry,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa+B,gBAAsD;CAC/DG,MAAMR;CACNS,UAAUR;CACVS,QAAQnB;CACRoB,SAASnC;CACToC,MAAMjC;CACNkC,UAAUhC;CACViC,MAAMZ;CACNa,QAAQnB;CACRoB,OAAOjC;CACPkC,KAAKd;CACLe,OAAOzC;CACP0C,MAAMtB;CACNuB,MAAMnC;CACNoC,UAAU3B;CACV4B,OAAOpC;CACPqC,UAAU5B;CACV6B,KAAKzB;CACL0B,OAAOjC;CACPkC,UAAU5C;CACV6C,MAAMxC;CACNyC,MAAM9B;CACN+B,OAAO7C;CACP8C,UAAUzC;CACV0C,SAASrD;CACTsD,QAAQvC;CACRwC,SAAS1D;CACT2D,MAAM9C;CACN+C,WAAWvD;CACXwD,OAAO9C;AACX;;;;;;AAOA,IAAa+C,eAIT;CACAC,IAAI;CACJC,QAAQlC;CACRmC,SAAS,EAAElE,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":["FieldCheckRequest","FieldCheckResponse","FieldCheckSource","check","field","request","value","locale","values","Record","options","signal","AbortSignal","Promise","FieldCheckAdapter","checkField","resource","createFieldCheckSource","adapter","id","undefined","call"],"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,SAAgBiB,uBACZC,SACAF,UACAG,KAAoB,MACG;CACvB,MAAM,EAAEJ,eAAeG;CACvB,IAAIH,eAAeK,KAAAA,GACf,OAAO;CAEX,OAAO,EACHjB,QAAQC,OAAOC,SAAS,EAAEM,aACtBI,WAAWM,KAAKH,SAASF,UAAUZ,OAAO;EAAE,GAAGC;EAASc;CAAG,GAAG,EAAER,OAAO,CAAC,EAChF;AACJ"}
|
package/dist/shared/context.d.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { type ComponentType, type ReactNode } from 'react';
|
|
2
2
|
import type { Field } from '@panneau/protocol';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
3
|
+
import type { MapsConfig } from '../location/types.js';
|
|
4
|
+
import type { UploadSource } from '../upload/types.js';
|
|
5
|
+
import type { FieldCheckSource } from './check.js';
|
|
6
|
+
import type { EmbedSource } from './embed.js';
|
|
7
|
+
import type { RelationSource } from './relation.js';
|
|
8
|
+
import type { FieldEntry } from './types.js';
|
|
5
9
|
/** What a binding gives a field: its value, handlers and errors at a path. */
|
|
6
10
|
export interface BoundFieldProps {
|
|
7
11
|
value: unknown;
|
|
8
12
|
onChange: (value: unknown) => void;
|
|
9
13
|
onBlur?: () => void;
|
|
10
14
|
errors?: readonly string[];
|
|
15
|
+
/**
|
|
16
|
+
* Paths inside the field that have errors (`title.en`), for fields that show their nested
|
|
17
|
+
* fields themselves: a localized field marks its locales in error.
|
|
18
|
+
*/
|
|
19
|
+
invalidPaths?: readonly string[];
|
|
11
20
|
}
|
|
12
21
|
/** Props of a binding: it decides whether a field shows, and where its value comes from. */
|
|
13
22
|
export interface FieldBindingProps {
|
|
@@ -32,6 +41,17 @@ export interface FieldsContextValue {
|
|
|
32
41
|
locales: readonly string[];
|
|
33
42
|
/** Where relation fields search for items. */
|
|
34
43
|
relationSource: RelationSource | null;
|
|
44
|
+
/**
|
|
45
|
+
* Where fields that take files upload them directly to storage. Without one, they give the
|
|
46
|
+
* files themselves.
|
|
47
|
+
*/
|
|
48
|
+
uploadSource: UploadSource | null;
|
|
49
|
+
/** Where fields with `check` check their value, such as a slug's availability. */
|
|
50
|
+
checkSource: FieldCheckSource | null;
|
|
51
|
+
/** Where `embed` fields get what a URL embeds. Without one, they keep the URL alone. */
|
|
52
|
+
embedSource: EmbedSource | null;
|
|
53
|
+
/** The tiles and the address search of `location` fields. */
|
|
54
|
+
maps: MapsConfig | null;
|
|
35
55
|
binding: FieldBinding | null;
|
|
36
56
|
}
|
|
37
57
|
/** The fields context of the closest `FieldsProvider`. */
|
|
@@ -41,15 +61,23 @@ export interface FieldsProviderProps {
|
|
|
41
61
|
components?: Readonly<Record<string, FieldEntry>>;
|
|
42
62
|
locales?: readonly string[];
|
|
43
63
|
relationSource?: RelationSource | null;
|
|
64
|
+
/** Make it once, outside of render: fields make an uploader for each source they get. */
|
|
65
|
+
uploadSource?: UploadSource | null;
|
|
66
|
+
/** `createFieldCheckSource(adapter, resource, id)`, for the form of an item. */
|
|
67
|
+
checkSource?: FieldCheckSource | null;
|
|
68
|
+
/** `createEmbedSource(adapter)`. */
|
|
69
|
+
embedSource?: EmbedSource | null;
|
|
70
|
+
/** The tiles and the address search of `location` fields. */
|
|
71
|
+
maps?: MapsConfig | null;
|
|
44
72
|
binding?: FieldBinding | null;
|
|
45
73
|
children?: ReactNode;
|
|
46
74
|
}
|
|
47
75
|
/**
|
|
48
76
|
* Provides what fields rendered from a definition need: the components of each type, the locales
|
|
49
|
-
* of localized values,
|
|
50
|
-
* provider.
|
|
77
|
+
* of localized values, the sources of relations, uploads, checks and embeds, the maps of
|
|
78
|
+
* locations, and a binding. Values not given come from the parent provider.
|
|
51
79
|
*/
|
|
52
|
-
export declare function FieldsProvider({ components, locales, relationSource, binding, children, }: FieldsProviderProps): import("react").JSX.Element;
|
|
80
|
+
export declare function FieldsProvider({ components, locales, relationSource, uploadSource, checkSource, embedSource, maps, binding, children, }: FieldsProviderProps): import("react").JSX.Element;
|
|
53
81
|
/** The parent path of a path: `blocks.2` for `blocks.2.title`, `''` for `title`. */
|
|
54
82
|
export declare function getParentPath(path: string): string;
|
|
55
83
|
//# 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,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,8EAA8E;AAC9E,MAAM,WAAW,eAAe;IAC5B,KAAK,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xB;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
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { c } from "react/compiler-runtime";
|
|
2
|
-
import { createContext, use } from "react";
|
|
3
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, use } from "react";
|
|
4
4
|
//#region src/shared/context.tsx
|
|
5
5
|
var FieldsContext = createContext({
|
|
6
6
|
components: {},
|
|
7
7
|
locales: [],
|
|
8
8
|
relationSource: null,
|
|
9
|
+
uploadSource: null,
|
|
10
|
+
checkSource: null,
|
|
11
|
+
embedSource: null,
|
|
12
|
+
maps: null,
|
|
9
13
|
binding: null
|
|
10
14
|
});
|
|
11
15
|
/** The fields context of the closest `FieldsProvider`. */
|
|
@@ -14,12 +18,12 @@ function useFieldsContext() {
|
|
|
14
18
|
}
|
|
15
19
|
/**
|
|
16
20
|
* Provides what fields rendered from a definition need: the components of each type, the locales
|
|
17
|
-
* of localized values,
|
|
18
|
-
* 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.
|
|
19
23
|
*/
|
|
20
24
|
function FieldsProvider(t0) {
|
|
21
|
-
const $ = c(
|
|
22
|
-
const { components, locales, relationSource, binding, children } = t0;
|
|
25
|
+
const $ = c(15);
|
|
26
|
+
const { components, locales, relationSource, uploadSource, checkSource, embedSource, maps, binding, children } = t0;
|
|
23
27
|
const parent = use(FieldsContext);
|
|
24
28
|
let t1;
|
|
25
29
|
if ($[0] !== components || $[1] !== parent.components) {
|
|
@@ -33,33 +37,45 @@ function FieldsProvider(t0) {
|
|
|
33
37
|
} else t1 = $[2];
|
|
34
38
|
const t2 = locales ?? parent.locales;
|
|
35
39
|
const t3 = relationSource === void 0 ? parent.relationSource : relationSource;
|
|
36
|
-
const t4 =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
const t4 = uploadSource === void 0 ? parent.uploadSource : uploadSource;
|
|
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 = {
|
|
40
48
|
components: t1,
|
|
41
49
|
locales: t2,
|
|
42
50
|
relationSource: t3,
|
|
43
|
-
|
|
51
|
+
uploadSource: t4,
|
|
52
|
+
checkSource: t5,
|
|
53
|
+
embedSource: t6,
|
|
54
|
+
maps: t7,
|
|
55
|
+
binding: t8
|
|
44
56
|
};
|
|
45
57
|
$[3] = t1;
|
|
46
58
|
$[4] = t2;
|
|
47
59
|
$[5] = t3;
|
|
48
60
|
$[6] = t4;
|
|
49
61
|
$[7] = t5;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
62
|
+
$[8] = t6;
|
|
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, {
|
|
55
71
|
value,
|
|
56
72
|
children
|
|
57
73
|
});
|
|
58
|
-
$[
|
|
59
|
-
$[
|
|
60
|
-
$[
|
|
61
|
-
} else
|
|
62
|
-
return
|
|
74
|
+
$[12] = children;
|
|
75
|
+
$[13] = value;
|
|
76
|
+
$[14] = t10;
|
|
77
|
+
} else t10 = $[14];
|
|
78
|
+
return t10;
|
|
63
79
|
}
|
|
64
80
|
/** The parent path of a path: `blocks.2` for `blocks.2.title`, `''` for `title`. */
|
|
65
81
|
function getParentPath(path) {
|