@panneau/fields 5.0.0-alpha.2 → 5.0.0-alpha.20
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
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { getAccept, getFieldProps, getMaxSize } from "../shared/entry.js";
|
|
2
|
+
import { useFieldsContext } from "../shared/context.js";
|
|
3
|
+
import { messages } from "../shared/messages.js";
|
|
4
|
+
import { FilePicker } from "../upload/FilePicker.js";
|
|
5
|
+
import { formatSize } from "../upload/files.js";
|
|
6
|
+
import { UploadList } from "../upload/UploadList.js";
|
|
7
|
+
import { useRejectionMessage } from "../upload/useRejectionMessage.js";
|
|
8
|
+
import { useUploads } from "../upload/useUploads.js";
|
|
9
|
+
import FileField_module_default from "./FileField.module.js";
|
|
10
|
+
import { c } from "react/compiler-runtime";
|
|
11
|
+
import { Fieldset, IconButton, usePanneauIntl } from "@panneau/ui";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { FileText, X } from "lucide-react";
|
|
14
|
+
import { useEffect, useRef, useState } from "react";
|
|
15
|
+
//#region src/file/FileField.tsx
|
|
16
|
+
function fileSize(file) {
|
|
17
|
+
return typeof file.size === "number" ? file.size : null;
|
|
18
|
+
}
|
|
19
|
+
function fileUrl(file) {
|
|
20
|
+
return !(file instanceof Blob) && "url" in file && typeof file.url === "string" ? file.url : null;
|
|
21
|
+
}
|
|
22
|
+
/** Whether a value is a file of a `file` value. */
|
|
23
|
+
function isFileValue(value) {
|
|
24
|
+
if (typeof File !== "undefined" && value instanceof File) return true;
|
|
25
|
+
return typeof value === "object" && value !== null && typeof value.name === "string";
|
|
26
|
+
}
|
|
27
|
+
/** The files of a value, single or multiple. */
|
|
28
|
+
function toFiles(value) {
|
|
29
|
+
if (Array.isArray(value)) return value.filter(isFileValue);
|
|
30
|
+
return isFileValue(value) ? [value] : [];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Files that belong to an item, outside the media library: an attachment, a PDF, a CSV (the
|
|
34
|
+
* `file` type). With an upload source, files go directly to storage, and the value references
|
|
35
|
+
* each upload (`{ upload, name, mime, size }`). Without one, the value is the file itself. Items
|
|
36
|
+
* give stored files, which the field shows with a link. A new file replaces the file of a single
|
|
37
|
+
* value, and is added to a multiple one.
|
|
38
|
+
*/
|
|
39
|
+
function FileField(props) {
|
|
40
|
+
const $ = c(42);
|
|
41
|
+
const intl = usePanneauIntl();
|
|
42
|
+
const context = useFieldsContext();
|
|
43
|
+
const { accept: t0, maxSize: t1, label, description, errors: t2, disabled, readOnly, required, className, labelClassName, descriptionClassName, errorsClassName } = props;
|
|
44
|
+
const accept = t0 === void 0 ? null : t0;
|
|
45
|
+
const maxSize = t1 === void 0 ? null : t1;
|
|
46
|
+
let t3;
|
|
47
|
+
if ($[0] !== t2) {
|
|
48
|
+
t3 = t2 === void 0 ? [] : t2;
|
|
49
|
+
$[0] = t2;
|
|
50
|
+
$[1] = t3;
|
|
51
|
+
} else t3 = $[1];
|
|
52
|
+
const errors = t3;
|
|
53
|
+
const uploadSource = props.uploadSource === void 0 ? context.uploadSource : props.uploadSource;
|
|
54
|
+
const multiple = props.multiple === true;
|
|
55
|
+
let t4;
|
|
56
|
+
if ($[2] !== props.value) {
|
|
57
|
+
t4 = toFiles(props.value);
|
|
58
|
+
$[2] = props.value;
|
|
59
|
+
$[3] = t4;
|
|
60
|
+
} else t4 = $[3];
|
|
61
|
+
const files = t4;
|
|
62
|
+
const editable = disabled !== true && readOnly !== true;
|
|
63
|
+
let t5;
|
|
64
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
65
|
+
t5 = [];
|
|
66
|
+
$[4] = t5;
|
|
67
|
+
} else t5 = $[4];
|
|
68
|
+
const [rejections, setRejections] = useState(t5);
|
|
69
|
+
const rejectionMessage = useRejectionMessage(maxSize);
|
|
70
|
+
const latest = useRef(files);
|
|
71
|
+
let t6;
|
|
72
|
+
if ($[5] !== files) {
|
|
73
|
+
t6 = () => {
|
|
74
|
+
latest.current = files;
|
|
75
|
+
};
|
|
76
|
+
$[5] = files;
|
|
77
|
+
$[6] = t6;
|
|
78
|
+
} else t6 = $[6];
|
|
79
|
+
useEffect(t6);
|
|
80
|
+
const set = (next) => {
|
|
81
|
+
latest.current = next;
|
|
82
|
+
if (props.multiple === true) props.onChange?.(next.length > 0 ? next : null);
|
|
83
|
+
else props.onChange?.(next[0] ?? null);
|
|
84
|
+
};
|
|
85
|
+
let t7;
|
|
86
|
+
if ($[7] !== rejectionMessage) {
|
|
87
|
+
t7 = (file_0, reason) => setRejections((current) => [...current, rejectionMessage(file_0, reason)]);
|
|
88
|
+
$[7] = rejectionMessage;
|
|
89
|
+
$[8] = t7;
|
|
90
|
+
} else t7 = $[8];
|
|
91
|
+
const upload = useUploads({
|
|
92
|
+
source: uploadSource,
|
|
93
|
+
accept,
|
|
94
|
+
maxSize,
|
|
95
|
+
onUploaded: (file) => set(multiple ? [...latest.current, file] : [file]),
|
|
96
|
+
onRejected: t7
|
|
97
|
+
});
|
|
98
|
+
const T0 = Fieldset;
|
|
99
|
+
let t8;
|
|
100
|
+
if ($[9] !== errors || $[10] !== rejections) {
|
|
101
|
+
t8 = [...errors, ...rejections];
|
|
102
|
+
$[9] = errors;
|
|
103
|
+
$[10] = rejections;
|
|
104
|
+
$[11] = t8;
|
|
105
|
+
} else t8 = $[11];
|
|
106
|
+
const t9 = FileField_module_default;
|
|
107
|
+
const t10 = files.length > 0 ? /* @__PURE__ */ jsx("ul", {
|
|
108
|
+
className: FileField_module_default.files,
|
|
109
|
+
children: files.map((file_1, index) => {
|
|
110
|
+
const { name } = file_1;
|
|
111
|
+
const url = fileUrl(file_1);
|
|
112
|
+
const size = fileSize(file_1);
|
|
113
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
114
|
+
className: FileField_module_default.file,
|
|
115
|
+
children: [
|
|
116
|
+
/* @__PURE__ */ jsx(FileText, {
|
|
117
|
+
"aria-hidden": true,
|
|
118
|
+
className: FileField_module_default.icon
|
|
119
|
+
}),
|
|
120
|
+
url !== null ? /* @__PURE__ */ jsx("a", {
|
|
121
|
+
href: url,
|
|
122
|
+
className: FileField_module_default.name,
|
|
123
|
+
target: "_blank",
|
|
124
|
+
rel: "noreferrer",
|
|
125
|
+
children: name
|
|
126
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
127
|
+
className: FileField_module_default.name,
|
|
128
|
+
children: name
|
|
129
|
+
}),
|
|
130
|
+
size !== null ? /* @__PURE__ */ jsx("span", {
|
|
131
|
+
className: FileField_module_default.size,
|
|
132
|
+
children: formatSize(size, intl.locale)
|
|
133
|
+
}) : null,
|
|
134
|
+
editable ? /* @__PURE__ */ jsx(IconButton, {
|
|
135
|
+
icon: X,
|
|
136
|
+
size: "sm",
|
|
137
|
+
label: intl.formatMessage(messages.removeFile, { name }),
|
|
138
|
+
onPress: () => set(latest.current.filter((_, at) => at !== index))
|
|
139
|
+
}) : null
|
|
140
|
+
]
|
|
141
|
+
}, `${String(index)}-${name}`);
|
|
142
|
+
})
|
|
143
|
+
}) : upload.items.length === 0 ? /* @__PURE__ */ jsx("span", {
|
|
144
|
+
className: FileField_module_default.none,
|
|
145
|
+
children: intl.formatMessage(messages.noFile)
|
|
146
|
+
}) : null;
|
|
147
|
+
let t11;
|
|
148
|
+
if ($[12] !== upload.cancel || $[13] !== upload.items || $[14] !== upload.pause || $[15] !== upload.resume || $[16] !== upload.retry) {
|
|
149
|
+
t11 = /* @__PURE__ */ jsx(UploadList, {
|
|
150
|
+
items: upload.items,
|
|
151
|
+
onPause: upload.pause,
|
|
152
|
+
onResume: upload.resume,
|
|
153
|
+
onCancel: upload.cancel,
|
|
154
|
+
onRetry: upload.retry
|
|
155
|
+
});
|
|
156
|
+
$[12] = upload.cancel;
|
|
157
|
+
$[13] = upload.items;
|
|
158
|
+
$[14] = upload.pause;
|
|
159
|
+
$[15] = upload.resume;
|
|
160
|
+
$[16] = upload.retry;
|
|
161
|
+
$[17] = t11;
|
|
162
|
+
} else t11 = $[17];
|
|
163
|
+
let t12;
|
|
164
|
+
if ($[18] !== accept || $[19] !== editable || $[20] !== files.length || $[21] !== intl || $[22] !== multiple || $[23] !== upload) {
|
|
165
|
+
t12 = editable ? /* @__PURE__ */ jsx(FilePicker, {
|
|
166
|
+
accept,
|
|
167
|
+
multiple,
|
|
168
|
+
...!multiple && files.length > 0 ? { label: intl.formatMessage(messages.replaceFile) } : {},
|
|
169
|
+
onSelect: (selected) => {
|
|
170
|
+
setRejections([]);
|
|
171
|
+
upload.add(selected);
|
|
172
|
+
}
|
|
173
|
+
}) : null;
|
|
174
|
+
$[18] = accept;
|
|
175
|
+
$[19] = editable;
|
|
176
|
+
$[20] = files.length;
|
|
177
|
+
$[21] = intl;
|
|
178
|
+
$[22] = multiple;
|
|
179
|
+
$[23] = upload;
|
|
180
|
+
$[24] = t12;
|
|
181
|
+
} else t12 = $[24];
|
|
182
|
+
let t13;
|
|
183
|
+
if ($[25] !== t10 || $[26] !== t11 || $[27] !== t12 || $[28] !== t9.field) {
|
|
184
|
+
t13 = /* @__PURE__ */ jsxs("div", {
|
|
185
|
+
className: t9.field,
|
|
186
|
+
children: [
|
|
187
|
+
t10,
|
|
188
|
+
t11,
|
|
189
|
+
t12
|
|
190
|
+
]
|
|
191
|
+
});
|
|
192
|
+
$[25] = t10;
|
|
193
|
+
$[26] = t11;
|
|
194
|
+
$[27] = t12;
|
|
195
|
+
$[28] = t9.field;
|
|
196
|
+
$[29] = t13;
|
|
197
|
+
} else t13 = $[29];
|
|
198
|
+
let t14;
|
|
199
|
+
if ($[30] !== T0 || $[31] !== className || $[32] !== description || $[33] !== descriptionClassName || $[34] !== disabled || $[35] !== errorsClassName || $[36] !== label || $[37] !== labelClassName || $[38] !== required || $[39] !== t13 || $[40] !== t8) {
|
|
200
|
+
t14 = /* @__PURE__ */ jsx(T0, {
|
|
201
|
+
legend: label,
|
|
202
|
+
description,
|
|
203
|
+
errors: t8,
|
|
204
|
+
isRequired: required,
|
|
205
|
+
isDisabled: disabled,
|
|
206
|
+
className,
|
|
207
|
+
legendClassName: labelClassName,
|
|
208
|
+
descriptionClassName,
|
|
209
|
+
errorsClassName,
|
|
210
|
+
children: t13
|
|
211
|
+
});
|
|
212
|
+
$[30] = T0;
|
|
213
|
+
$[31] = className;
|
|
214
|
+
$[32] = description;
|
|
215
|
+
$[33] = descriptionClassName;
|
|
216
|
+
$[34] = disabled;
|
|
217
|
+
$[35] = errorsClassName;
|
|
218
|
+
$[36] = label;
|
|
219
|
+
$[37] = labelClassName;
|
|
220
|
+
$[38] = required;
|
|
221
|
+
$[39] = t13;
|
|
222
|
+
$[40] = t8;
|
|
223
|
+
$[41] = t14;
|
|
224
|
+
} else t14 = $[41];
|
|
225
|
+
return t14;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* The registry entry of the `file` type: the field's `multiple`, `accept` (or its `accept` rule)
|
|
229
|
+
* and `maxSize` rule, with the upload source of the fields context.
|
|
230
|
+
*/
|
|
231
|
+
function FileFieldEntry(props) {
|
|
232
|
+
const $ = c(15);
|
|
233
|
+
const { field, value, onChange } = props;
|
|
234
|
+
let t0;
|
|
235
|
+
if ($[0] !== props) {
|
|
236
|
+
t0 = getFieldProps(props);
|
|
237
|
+
$[0] = props;
|
|
238
|
+
$[1] = t0;
|
|
239
|
+
} else t0 = $[1];
|
|
240
|
+
let t1;
|
|
241
|
+
if ($[2] !== field) {
|
|
242
|
+
t1 = getAccept(field);
|
|
243
|
+
$[2] = field;
|
|
244
|
+
$[3] = t1;
|
|
245
|
+
} else t1 = $[3];
|
|
246
|
+
let t2;
|
|
247
|
+
if ($[4] !== field) {
|
|
248
|
+
t2 = getMaxSize(field);
|
|
249
|
+
$[4] = field;
|
|
250
|
+
$[5] = t2;
|
|
251
|
+
} else t2 = $[5];
|
|
252
|
+
let t3;
|
|
253
|
+
if ($[6] !== t0 || $[7] !== t1 || $[8] !== t2) {
|
|
254
|
+
t3 = {
|
|
255
|
+
...t0,
|
|
256
|
+
accept: t1,
|
|
257
|
+
maxSize: t2
|
|
258
|
+
};
|
|
259
|
+
$[6] = t0;
|
|
260
|
+
$[7] = t1;
|
|
261
|
+
$[8] = t2;
|
|
262
|
+
$[9] = t3;
|
|
263
|
+
} else t3 = $[9];
|
|
264
|
+
const common = t3;
|
|
265
|
+
let t4;
|
|
266
|
+
if ($[10] !== common || $[11] !== field.multiple || $[12] !== onChange || $[13] !== value) {
|
|
267
|
+
t4 = field.multiple === true ? /* @__PURE__ */ jsx(FileField, {
|
|
268
|
+
...common,
|
|
269
|
+
multiple: true,
|
|
270
|
+
value: toFiles(value),
|
|
271
|
+
onChange
|
|
272
|
+
}) : /* @__PURE__ */ jsx(FileField, {
|
|
273
|
+
...common,
|
|
274
|
+
value: toFiles(value)[0] ?? null,
|
|
275
|
+
onChange
|
|
276
|
+
});
|
|
277
|
+
$[10] = common;
|
|
278
|
+
$[11] = field.multiple;
|
|
279
|
+
$[12] = onChange;
|
|
280
|
+
$[13] = value;
|
|
281
|
+
$[14] = t4;
|
|
282
|
+
} else t4 = $[14];
|
|
283
|
+
return t4;
|
|
284
|
+
}
|
|
285
|
+
//#endregion
|
|
286
|
+
export { FileField, FileFieldEntry, isFileValue, toFiles };
|
|
287
|
+
|
|
288
|
+
//# sourceMappingURL=FileField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileField.js","names":["FileText","X","useEffect","useRef","useState","StoredFile","Fieldset","IconButton","usePanneauIntl","useFieldsContext","getAccept","getFieldProps","getMaxSize","messages","FieldEntryProps","FieldProps","FilePicker","UploadList","formatSize","UploadSource","UploadedFile","useRejectionMessage","useUploads","styles","FileValue","File","FileFieldBaseProps","Omit","accept","maxSize","uploadSource","SingleFileFieldProps","multiple","value","onChange","MultipleFileFieldProps","FileFieldProps","fileSize","file","size","fileUrl","Blob","url","isFileValue","name","toFiles","Array","isArray","filter","FileField","props","$","_c","intl","context","t0","t1","label","description","errors","t2","disabled","readOnly","required","className","labelClassName","descriptionClassName","errorsClassName","undefined","t3","t4","files","editable","t5","Symbol","for","rejections","setRejections","rejectionMessage","latest","t6","current","set","next","length","t7","file_0","reason","upload","source","onUploaded","onRejected","T0","t8","t10","map","file_1","index","String","icon","locale","formatMessage","removeFile","_","at","items","none","noFile","t11","cancel","pause","resume","retry","t12","replaceFile","selected","add","t13","t9","field","t14","FileFieldEntry","common","_c","styles"],"sources":["../../src/file/FileField.tsx"],"sourcesContent":["import { FileText, X } from 'lucide-react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport type { StoredFile } from '@panneau/protocol';\nimport { Fieldset, IconButton, usePanneauIntl } from '@panneau/ui';\n\nimport { useFieldsContext } from '../shared/context';\nimport { getAccept, getFieldProps, getMaxSize } from '../shared/entry';\nimport { messages } from '../shared/messages';\nimport type { FieldEntryProps, FieldProps } from '../shared/types';\nimport { FilePicker } from '../upload/FilePicker';\nimport { UploadList } from '../upload/UploadList';\nimport { formatSize } from '../upload/files';\nimport type { UploadSource, UploadedFile } from '../upload/types';\nimport { useRejectionMessage } from '../upload/useRejectionMessage';\nimport { useUploads } from '../upload/useUploads';\nimport styles from './FileField.module.css';\n\n/**\n * A file of a `file` value: a stored file, as items give it; an upload, once the browser sent the\n * file to storage; or the file itself, sent in a multipart request without direct uploads.\n */\nexport type FileValue = StoredFile | UploadedFile | File;\n\nexport interface FileFieldBaseProps extends Omit<FieldProps<never>, 'value' | 'onChange'> {\n /** Accepted MIME types (`application/pdf`, `image/*`). Others are refused before they are sent. */\n accept?: readonly string[] | null;\n /** Largest file, in bytes. Larger ones are refused before they are sent. */\n maxSize?: number | null;\n /**\n * Where files are uploaded directly to storage. Defaults to the one of the fields context.\n * Without one, the value holds the files themselves, which the adapter sends in\n * `multipart/form-data`.\n */\n uploadSource?: UploadSource | null;\n}\n\nexport interface SingleFileFieldProps extends FileFieldBaseProps {\n multiple?: false;\n value?: FileValue | null;\n onChange?: (value: FileValue | null) => void;\n}\n\nexport interface MultipleFileFieldProps extends FileFieldBaseProps {\n multiple: true;\n value?: readonly FileValue[] | null;\n /** Called with the files. An empty list is `null`. */\n onChange?: (value: FileValue[] | null) => void;\n}\n\nexport type FileFieldProps = SingleFileFieldProps | MultipleFileFieldProps;\n\nfunction fileSize(file: FileValue): number | null {\n return typeof file.size === 'number' ? file.size : null;\n}\n\nfunction fileUrl(file: FileValue): string | null {\n return !(file instanceof Blob) && 'url' in file && typeof file.url === 'string'\n ? file.url\n : null;\n}\n\n/** Whether a value is a file of a `file` value. */\nexport function isFileValue(value: unknown): value is FileValue {\n if (typeof File !== 'undefined' && value instanceof File) {\n return true;\n }\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { name?: unknown }).name === 'string'\n );\n}\n\n/** The files of a value, single or multiple. */\nexport function toFiles(value: unknown): FileValue[] {\n if (Array.isArray(value)) {\n return value.filter(isFileValue);\n }\n return isFileValue(value) ? [value] : [];\n}\n\n/**\n * Files that belong to an item, outside the media library: an attachment, a PDF, a CSV (the\n * `file` type). With an upload source, files go directly to storage, and the value references\n * each upload (`{ upload, name, mime, size }`). Without one, the value is the file itself. Items\n * give stored files, which the field shows with a link. A new file replaces the file of a single\n * value, and is added to a multiple one.\n */\nexport function FileField(props: FileFieldProps) {\n const intl = usePanneauIntl();\n const context = useFieldsContext();\n const {\n accept = null,\n maxSize = null,\n label,\n description,\n errors = [],\n disabled,\n readOnly,\n required,\n className,\n labelClassName,\n descriptionClassName,\n errorsClassName,\n } = props;\n const uploadSource =\n props.uploadSource === undefined ? context.uploadSource : props.uploadSource;\n const multiple = props.multiple === true;\n const files = toFiles(props.value);\n const editable = disabled !== true && readOnly !== true;\n const [rejections, setRejections] = useState<string[]>([]);\n const rejectionMessage = useRejectionMessage(maxSize);\n\n // The files as last set, so that uploads that end together all add theirs.\n const latest = useRef(files);\n useEffect(() => {\n latest.current = files;\n });\n const set = (next: FileValue[]) => {\n latest.current = next;\n if (props.multiple === true) {\n props.onChange?.(next.length > 0 ? next : null);\n } else {\n props.onChange?.(next[0] ?? null);\n }\n };\n\n const upload = useUploads({\n source: uploadSource,\n accept,\n maxSize,\n onUploaded: (file) => set(multiple ? [...latest.current, file] : [file]),\n onRejected: (file, reason) =>\n setRejections((current) => [...current, rejectionMessage(file, reason)]),\n });\n\n return (\n <Fieldset\n legend={label}\n description={description}\n errors={[...errors, ...rejections]}\n isRequired={required}\n isDisabled={disabled}\n className={className}\n legendClassName={labelClassName}\n descriptionClassName={descriptionClassName}\n errorsClassName={errorsClassName}\n >\n <div className={styles.field}>\n {files.length > 0 ? (\n <ul className={styles.files}>\n {files.map((file, index) => {\n const { name } = file;\n const url = fileUrl(file);\n const size = fileSize(file);\n return (\n <li key={`${String(index)}-${name}`} className={styles.file}>\n <FileText aria-hidden className={styles.icon} />\n {url !== null ? (\n <a\n href={url}\n className={styles.name}\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {name}\n </a>\n ) : (\n <span className={styles.name}>{name}</span>\n )}\n {size !== null ? (\n <span className={styles.size}>\n {formatSize(size, intl.locale)}\n </span>\n ) : null}\n {editable ? (\n <IconButton\n icon={X}\n size=\"sm\"\n label={intl.formatMessage(messages.removeFile, {\n name,\n })}\n onPress={() =>\n set(latest.current.filter((_, at) => at !== index))\n }\n />\n ) : null}\n </li>\n );\n })}\n </ul>\n ) : upload.items.length === 0 ? (\n <span className={styles.none}>{intl.formatMessage(messages.noFile)}</span>\n ) : null}\n <UploadList\n items={upload.items}\n onPause={upload.pause}\n onResume={upload.resume}\n onCancel={upload.cancel}\n onRetry={upload.retry}\n />\n {editable ? (\n <FilePicker\n accept={accept}\n multiple={multiple}\n {...(!multiple && files.length > 0\n ? { label: intl.formatMessage(messages.replaceFile) }\n : {})}\n onSelect={(selected) => {\n setRejections([]);\n upload.add(selected);\n }}\n />\n ) : null}\n </div>\n </Fieldset>\n );\n}\n\n/**\n * The registry entry of the `file` type: the field's `multiple`, `accept` (or its `accept` rule)\n * and `maxSize` rule, with the upload source of the fields context.\n */\nexport function FileFieldEntry(props: FieldEntryProps) {\n const { field, value, onChange } = props;\n const common = {\n ...getFieldProps(props),\n accept: getAccept(field),\n maxSize: getMaxSize(field),\n };\n return field.multiple === true ? (\n <FileField {...common} multiple value={toFiles(value)} onChange={onChange} />\n ) : (\n <FileField {...common} value={toFiles(value)[0] ?? null} onChange={onChange} />\n );\n}\n"],"mappings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AAAkB,EAAA,MAAAmB;CAAA,OAAAA,KAAAnB,EAAA;CAAA,OAJMmB;AAIN"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import "./FileField.css";
|
|
2
|
+
//#region src/file/FileField.module.css
|
|
3
|
+
var field = "panneau-file-field-field";
|
|
4
|
+
var files = "panneau-file-field-files";
|
|
5
|
+
var file = "panneau-file-field-file";
|
|
6
|
+
var icon = "panneau-file-field-icon";
|
|
7
|
+
var name = "panneau-file-field-name";
|
|
8
|
+
var size = "panneau-file-field-size";
|
|
9
|
+
var none = "panneau-file-field-none";
|
|
10
|
+
var FileField_module_default = {
|
|
11
|
+
field,
|
|
12
|
+
files,
|
|
13
|
+
file,
|
|
14
|
+
icon,
|
|
15
|
+
name,
|
|
16
|
+
size,
|
|
17
|
+
none
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { FileField_module_default as default, field, file, files, icon, name, none, size };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=FileField.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileField.module.js","names":[],"sources":["../../src/file/FileField.module.css"],"sourcesContent":[".field {\n display: grid;\n gap: var(--panneau-space-2);\n}\n\n.files {\n display: grid;\n gap: var(--panneau-space-1);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.file {\n display: flex;\n align-items: center;\n gap: var(--panneau-space-2);\n min-height: var(--panneau-control-height-sm);\n padding-inline: var(--panneau-space-2) var(--panneau-space-1);\n background-color: var(--panneau-color-surface-sunken);\n border: var(--panneau-border-width) solid var(--panneau-color-border);\n border-radius: var(--panneau-radius-md);\n}\n\n.icon {\n flex: none;\n width: 1rem;\n height: 1rem;\n color: var(--panneau-color-text-muted);\n}\n\n.name {\n flex: 1 1 auto;\n min-width: 0;\n overflow: hidden;\n font-size: var(--panneau-font-size-sm);\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\na.name {\n color: var(--panneau-color-link);\n}\n\n.size {\n flex: none;\n font-size: var(--panneau-font-size-sm);\n color: var(--panneau-color-text-muted);\n}\n\n.none {\n font-size: var(--panneau-font-size-md);\n color: var(--panneau-color-text-muted);\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { type FileFieldBaseProps, FileField, FileFieldEntry, type FileFieldProps, type FileValue, type MultipleFileFieldProps, type SingleFileFieldProps, isFileValue, toFiles, } from './FileField.js';
|
|
2
|
+
export type { UploadItem, UploadItemStatus, UploadSource, UploadedFile, Uploader, } from '../upload/types.js';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,kBAAkB,EACvB,SAAS,EACT,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,WAAW,EACX,OAAO,GACV,MAAM,aAAa,CAAC;AACrB,YAAY,EACR,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,QAAQ,GACX,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FileField, FileFieldEntry, isFileValue, toFiles } from "./FileField.js";
|
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
.panneau-group-field-fields {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
gap: var(--panneau-space-4);
|
|
5
2
|
padding: var(--panneau-space-4);
|
|
6
3
|
border: var(--panneau-border-width) solid var(--panneau-color-border);
|
|
7
4
|
border-radius: var(--panneau-radius-md);
|
|
8
5
|
}
|
|
9
6
|
|
|
7
|
+
/* Short fields share a row, in columns of at least 14rem. */
|
|
8
|
+
.panneau-group-field-flow {
|
|
9
|
+
display: grid;
|
|
10
|
+
grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
|
|
11
|
+
gap: var(--panneau-space-4);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.panneau-group-field-cell {
|
|
15
|
+
min-width: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* A field hidden by its condition renders nothing: its cell takes no column. */
|
|
19
|
+
.panneau-group-field-cell:empty {
|
|
20
|
+
display: none;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.panneau-group-field-wide {
|
|
24
|
+
grid-column: 1 / -1;
|
|
25
|
+
}
|
|
26
|
+
|
|
10
27
|
@media (max-width: 30rem) {
|
|
11
28
|
.panneau-group-field-fields {
|
|
12
29
|
padding: var(--panneau-space-3);
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
1
2
|
import type { Field } from '@panneau/protocol';
|
|
2
|
-
import type { FieldEntryProps, FieldProps } from '../shared/types';
|
|
3
|
+
import type { FieldEntryProps, FieldProps } from '../shared/types.js';
|
|
3
4
|
export type GroupValue = Record<string, unknown>;
|
|
4
5
|
export interface GroupFieldProps extends FieldProps<GroupValue> {
|
|
5
6
|
/** The nested fields, rendered with the entries of the fields context. */
|
|
6
7
|
fields: readonly Field[];
|
|
7
8
|
/** Dot path of the group's value, the prefix of its fields' paths. Defaults to `name`. */
|
|
8
9
|
path?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Lays out the rendered fields, by name, instead of the flow of short fields side by side:
|
|
12
|
+
* the layout of a compound field (decision 0065).
|
|
13
|
+
*/
|
|
14
|
+
renderFields?: (parts: Readonly<Record<string, ReactNode>>, value: GroupValue) => ReactNode;
|
|
9
15
|
fieldsClassName?: string;
|
|
10
16
|
}
|
|
11
17
|
/**
|
|
12
|
-
* A nested object: its fields under a legend
|
|
13
|
-
* the path `<group>.<field>`. Without a binding in the fields context, the group sets the whole
|
|
18
|
+
* A nested object: its fields under a legend, short ones side by side (`isWideField()`). Each
|
|
19
|
+
* field renders with the entry of its type, at the path `<group>.<field>`. Without a binding in the fields context, the group sets the whole
|
|
14
20
|
* object through `onChange`.
|
|
15
21
|
*/
|
|
16
|
-
export declare function GroupField({ fields, path, name, value, onChange, onBlur, label, description, errors, disabled, readOnly, required, className, labelClassName, descriptionClassName, errorsClassName, fieldsClassName, }: GroupFieldProps): import("react").JSX.Element;
|
|
22
|
+
export declare function GroupField({ fields, path, name, value, onChange, onBlur, label, description, errors, disabled, readOnly, required, className, labelClassName, descriptionClassName, errorsClassName, renderFields, fieldsClassName, }: GroupFieldProps): import("react").JSX.Element;
|
|
17
23
|
/** The `group` type: its `fields`, as a nested object. */
|
|
18
24
|
export declare function GroupFieldEntry(props: FieldEntryProps): import("react").JSX.Element;
|
|
19
25
|
//# sourceMappingURL=GroupField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupField.d.ts","sourceRoot":"","sources":["../../src/group/GroupField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"GroupField.d.ts","sourceRoot":"","sources":["../../src/group/GroupField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAO/C,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGnE,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,MAAM,WAAW,eAAgB,SAAQ,UAAU,CAAC,UAAU,CAAC;IAC3D,0EAA0E;IAC1E,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IACzB,0FAA0F;IAC1F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,KAAK,SAAS,CAAC;IAC5F,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EACvB,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,WAAW,EACX,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,eAAe,GAClB,EAAE,eAAe,+BA+CjB;AAED,0DAA0D;AAC1D,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,+BAerD"}
|
package/dist/group/GroupField.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cx } from "../shared/cx.js";
|
|
2
2
|
import { getFieldProps } from "../shared/entry.js";
|
|
3
|
+
import { isWideField } from "../shared/flow.js";
|
|
3
4
|
import GroupField_module_default from "./GroupField.module.js";
|
|
4
5
|
import { NestedField } from "../shared/DefinitionField.js";
|
|
5
6
|
import { c } from "react/compiler-runtime";
|
|
@@ -7,13 +8,13 @@ import { Fieldset } from "@panneau/ui";
|
|
|
7
8
|
import { jsx } from "react/jsx-runtime";
|
|
8
9
|
//#region src/group/GroupField.tsx
|
|
9
10
|
/**
|
|
10
|
-
* A nested object: its fields under a legend
|
|
11
|
-
* the path `<group>.<field>`. Without a binding in the fields context, the group sets the whole
|
|
11
|
+
* A nested object: its fields under a legend, short ones side by side (`isWideField()`). Each
|
|
12
|
+
* field renders with the entry of its type, at the path `<group>.<field>`. Without a binding in the fields context, the group sets the whole
|
|
12
13
|
* object through `onChange`.
|
|
13
14
|
*/
|
|
14
15
|
function GroupField(t0) {
|
|
15
|
-
const $ = c(
|
|
16
|
-
const { fields, path, name, value, onChange, onBlur, label, description, errors, disabled, readOnly, required, className, labelClassName, descriptionClassName, errorsClassName, fieldsClassName } = t0;
|
|
16
|
+
const $ = c(29);
|
|
17
|
+
const { fields, path, name, value, onChange, onBlur, label, description, errors, disabled, readOnly, required, className, labelClassName, descriptionClassName, errorsClassName, renderFields, fieldsClassName } = t0;
|
|
17
18
|
const base = path ?? name ?? "";
|
|
18
19
|
let t1;
|
|
19
20
|
if ($[0] !== value) {
|
|
@@ -23,59 +24,63 @@ function GroupField(t0) {
|
|
|
23
24
|
} else t1 = $[1];
|
|
24
25
|
const object = t1;
|
|
25
26
|
let t2;
|
|
26
|
-
if ($[2] !==
|
|
27
|
-
t2 =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
if ($[2] !== base || $[3] !== disabled || $[4] !== object || $[5] !== onBlur || $[6] !== onChange || $[7] !== readOnly) {
|
|
28
|
+
t2 = (field) => /* @__PURE__ */ jsx(NestedField, {
|
|
29
|
+
field,
|
|
30
|
+
path: base !== "" ? `${base}.${field.name}` : field.name,
|
|
31
|
+
value: object[field.name],
|
|
32
|
+
onChange: (next) => onChange?.({
|
|
33
|
+
...object,
|
|
34
|
+
[field.name]: next
|
|
35
|
+
}),
|
|
36
|
+
...onBlur !== void 0 ? { onBlur } : {},
|
|
37
|
+
parentValue: object,
|
|
38
|
+
...disabled !== void 0 ? { disabled } : {},
|
|
39
|
+
...readOnly !== void 0 ? { readOnly } : {}
|
|
40
|
+
});
|
|
41
|
+
$[2] = base;
|
|
42
|
+
$[3] = disabled;
|
|
43
|
+
$[4] = object;
|
|
44
|
+
$[5] = onBlur;
|
|
45
|
+
$[6] = onChange;
|
|
46
|
+
$[7] = readOnly;
|
|
47
|
+
$[8] = t2;
|
|
48
|
+
} else t2 = $[8];
|
|
49
|
+
const renderField = t2;
|
|
31
50
|
let t3;
|
|
32
|
-
if ($[
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
path: base !== "" ? `${base}.${field.name}` : field.name,
|
|
38
|
-
value: object[field.name],
|
|
39
|
-
onChange: (next) => onChange?.({
|
|
40
|
-
...object,
|
|
41
|
-
[field.name]: next
|
|
42
|
-
}),
|
|
43
|
-
...onBlur !== void 0 ? { onBlur } : {},
|
|
44
|
-
parentValue: object,
|
|
45
|
-
...disabled !== void 0 ? { disabled } : {},
|
|
46
|
-
...readOnly !== void 0 ? { readOnly } : {}
|
|
47
|
-
}, field.name);
|
|
48
|
-
$[12] = base;
|
|
49
|
-
$[13] = disabled;
|
|
50
|
-
$[14] = object;
|
|
51
|
-
$[15] = onBlur;
|
|
52
|
-
$[16] = onChange;
|
|
53
|
-
$[17] = readOnly;
|
|
54
|
-
$[18] = t4;
|
|
55
|
-
} else t4 = $[18];
|
|
56
|
-
t3 = fields.map(t4);
|
|
57
|
-
$[4] = base;
|
|
58
|
-
$[5] = disabled;
|
|
59
|
-
$[6] = fields;
|
|
60
|
-
$[7] = object;
|
|
61
|
-
$[8] = onBlur;
|
|
62
|
-
$[9] = onChange;
|
|
63
|
-
$[10] = readOnly;
|
|
64
|
-
$[11] = t3;
|
|
65
|
-
} else t3 = $[11];
|
|
51
|
+
if ($[9] !== fieldsClassName) {
|
|
52
|
+
t3 = cx(GroupField_module_default.fields, fieldsClassName);
|
|
53
|
+
$[9] = fieldsClassName;
|
|
54
|
+
$[10] = t3;
|
|
55
|
+
} else t3 = $[10];
|
|
66
56
|
let t4;
|
|
67
|
-
if ($[
|
|
68
|
-
t4 = /* @__PURE__ */ jsx("div", {
|
|
69
|
-
className:
|
|
70
|
-
children:
|
|
57
|
+
if ($[11] !== fields || $[12] !== object || $[13] !== renderField || $[14] !== renderFields) {
|
|
58
|
+
t4 = renderFields !== void 0 ? renderFields(Object.fromEntries(fields.map((field_0) => [field_0.name, renderField(field_0)])), object) : /* @__PURE__ */ jsx("div", {
|
|
59
|
+
className: GroupField_module_default.flow,
|
|
60
|
+
children: fields.map((field_1) => /* @__PURE__ */ jsx("div", {
|
|
61
|
+
className: cx(GroupField_module_default.cell, isWideField(field_1) && GroupField_module_default.wide),
|
|
62
|
+
children: renderField(field_1)
|
|
63
|
+
}, field_1.name))
|
|
71
64
|
});
|
|
72
|
-
$[
|
|
73
|
-
$[
|
|
74
|
-
$[
|
|
75
|
-
|
|
65
|
+
$[11] = fields;
|
|
66
|
+
$[12] = object;
|
|
67
|
+
$[13] = renderField;
|
|
68
|
+
$[14] = renderFields;
|
|
69
|
+
$[15] = t4;
|
|
70
|
+
} else t4 = $[15];
|
|
76
71
|
let t5;
|
|
77
|
-
if ($[
|
|
78
|
-
t5 = /* @__PURE__ */ jsx(
|
|
72
|
+
if ($[16] !== t3 || $[17] !== t4) {
|
|
73
|
+
t5 = /* @__PURE__ */ jsx("div", {
|
|
74
|
+
className: t3,
|
|
75
|
+
children: t4
|
|
76
|
+
});
|
|
77
|
+
$[16] = t3;
|
|
78
|
+
$[17] = t4;
|
|
79
|
+
$[18] = t5;
|
|
80
|
+
} else t5 = $[18];
|
|
81
|
+
let t6;
|
|
82
|
+
if ($[19] !== className || $[20] !== description || $[21] !== descriptionClassName || $[22] !== errors || $[23] !== errorsClassName || $[24] !== label || $[25] !== labelClassName || $[26] !== required || $[27] !== t5) {
|
|
83
|
+
t6 = /* @__PURE__ */ jsx(Fieldset, {
|
|
79
84
|
legend: label,
|
|
80
85
|
description,
|
|
81
86
|
errors,
|
|
@@ -84,20 +89,20 @@ function GroupField(t0) {
|
|
|
84
89
|
legendClassName: labelClassName,
|
|
85
90
|
descriptionClassName,
|
|
86
91
|
errorsClassName,
|
|
87
|
-
children:
|
|
92
|
+
children: t5
|
|
88
93
|
});
|
|
89
|
-
$[
|
|
90
|
-
$[
|
|
91
|
-
$[
|
|
92
|
-
$[
|
|
93
|
-
$[
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
96
|
-
$[
|
|
97
|
-
$[
|
|
98
|
-
$[
|
|
99
|
-
} else
|
|
100
|
-
return
|
|
94
|
+
$[19] = className;
|
|
95
|
+
$[20] = description;
|
|
96
|
+
$[21] = descriptionClassName;
|
|
97
|
+
$[22] = errors;
|
|
98
|
+
$[23] = errorsClassName;
|
|
99
|
+
$[24] = label;
|
|
100
|
+
$[25] = labelClassName;
|
|
101
|
+
$[26] = required;
|
|
102
|
+
$[27] = t5;
|
|
103
|
+
$[28] = t6;
|
|
104
|
+
} else t6 = $[28];
|
|
105
|
+
return t6;
|
|
101
106
|
}
|
|
102
107
|
/** The `group` type: its `fields`, as a nested object. */
|
|
103
108
|
function GroupFieldEntry(props) {
|