@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
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
import { getFieldProps, getSetting, isNumber, isString } from "../shared/entry.js";
|
|
2
|
+
import { useFieldsContext } from "../shared/context.js";
|
|
3
|
+
import { messages } from "../shared/messages.js";
|
|
4
|
+
import LocationField_module_default from "./LocationField.module.js";
|
|
5
|
+
import { LocationMap } from "./LocationMap.js";
|
|
6
|
+
import { useAddressSearch } from "./search.js";
|
|
7
|
+
import { c } from "react/compiler-runtime";
|
|
8
|
+
import { ComboBox, Fieldset, IconButton, NumberInput, TextInput, usePanneauIntl } from "@panneau/ui";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { X } from "lucide-react";
|
|
11
|
+
import { useRef, useState } from "react";
|
|
12
|
+
//#region src/location/LocationField.tsx
|
|
13
|
+
/** OpenStreetMap's standard tiles: fine for an admin panel, with their credit. */
|
|
14
|
+
var OPEN_STREET_MAP_TILES = {
|
|
15
|
+
url: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
|
|
16
|
+
attribution: "© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors",
|
|
17
|
+
maxZoom: 19
|
|
18
|
+
};
|
|
19
|
+
var DEFAULT_CENTER = {
|
|
20
|
+
lat: 20,
|
|
21
|
+
lng: 0
|
|
22
|
+
};
|
|
23
|
+
/** Whether a value is a point. */
|
|
24
|
+
function isLocation(value) {
|
|
25
|
+
return value !== null && typeof value === "object" && isNumber(value.lat) && isNumber(value.lng);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A point on a map, and its address. Clicking the map or dragging the marker places the point,
|
|
29
|
+
* and its latitude and longitude can be typed. With an address search, a place found sets the
|
|
30
|
+
* point and the address; with a reverse search, placing a point fills an empty address.
|
|
31
|
+
*/
|
|
32
|
+
function LocationField(t0) {
|
|
33
|
+
const $ = c(100);
|
|
34
|
+
const { value, onChange, onBlur, geocoding: geocodingProp, tiles: tilesProp, center: t1, zoom: t2, label, description, errors, disabled, readOnly, required, className } = t0;
|
|
35
|
+
const center = t1 === void 0 ? DEFAULT_CENTER : t1;
|
|
36
|
+
const zoom = t2 === void 0 ? 15 : t2;
|
|
37
|
+
const intl = usePanneauIntl();
|
|
38
|
+
const { maps } = useFieldsContext();
|
|
39
|
+
const geocoding = geocodingProp === void 0 ? maps?.geocoding ?? null : geocodingProp;
|
|
40
|
+
const tiles = tilesProp ?? maps?.tiles ?? OPEN_STREET_MAP_TILES;
|
|
41
|
+
const editable = disabled !== true && readOnly !== true;
|
|
42
|
+
const [query, setQuery] = useState("");
|
|
43
|
+
const [chosen, setChosen] = useState(null);
|
|
44
|
+
const search = useAddressSearch(editable && query !== chosen?.label ? geocoding : null, query, intl.locale);
|
|
45
|
+
let t3;
|
|
46
|
+
if ($[0] !== chosen || $[1] !== query || $[2] !== search) {
|
|
47
|
+
t3 = chosen !== null && query === chosen.label ? [chosen] : search.results;
|
|
48
|
+
$[0] = chosen;
|
|
49
|
+
$[1] = query;
|
|
50
|
+
$[2] = search;
|
|
51
|
+
$[3] = t3;
|
|
52
|
+
} else t3 = $[3];
|
|
53
|
+
const places = t3;
|
|
54
|
+
const addressRef = useRef(null);
|
|
55
|
+
let t4;
|
|
56
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
57
|
+
t4 = () => window.requestAnimationFrame(() => addressRef.current?.querySelector("input")?.focus());
|
|
58
|
+
$[4] = t4;
|
|
59
|
+
} else t4 = $[4];
|
|
60
|
+
const focusAddress = t4;
|
|
61
|
+
const t5 = value?.lat ?? null;
|
|
62
|
+
const t6 = value?.lng ?? null;
|
|
63
|
+
let t7;
|
|
64
|
+
if ($[5] !== t5 || $[6] !== t6 || $[7] !== value) {
|
|
65
|
+
t7 = {
|
|
66
|
+
source: value,
|
|
67
|
+
lat: t5,
|
|
68
|
+
lng: t6
|
|
69
|
+
};
|
|
70
|
+
$[5] = t5;
|
|
71
|
+
$[6] = t6;
|
|
72
|
+
$[7] = value;
|
|
73
|
+
$[8] = t7;
|
|
74
|
+
} else t7 = $[8];
|
|
75
|
+
const [draft, setDraft] = useState(t7);
|
|
76
|
+
if (draft.source !== value) setDraft({
|
|
77
|
+
source: value,
|
|
78
|
+
lat: value?.lat ?? null,
|
|
79
|
+
lng: value?.lng ?? null
|
|
80
|
+
});
|
|
81
|
+
let t8;
|
|
82
|
+
if ($[9] !== geocoding || $[10] !== intl.locale || $[11] !== onChange || $[12] !== value?.address) {
|
|
83
|
+
t8 = (point, newAddress) => {
|
|
84
|
+
const address = newAddress ?? value?.address;
|
|
85
|
+
const next = {
|
|
86
|
+
lat: Number(point.lat.toFixed(6)),
|
|
87
|
+
lng: Number(point.lng.toFixed(6)),
|
|
88
|
+
...address !== void 0 && address !== "" ? { address } : {}
|
|
89
|
+
};
|
|
90
|
+
onChange?.(next);
|
|
91
|
+
if ((address === void 0 || address === "") && geocoding?.reverse !== void 0) {
|
|
92
|
+
const controller = new AbortController();
|
|
93
|
+
geocoding.reverse(point, {
|
|
94
|
+
signal: controller.signal,
|
|
95
|
+
locale: intl.locale
|
|
96
|
+
}).then((place) => {
|
|
97
|
+
if (place !== null) onChange?.({
|
|
98
|
+
...next,
|
|
99
|
+
address: place.label
|
|
100
|
+
});
|
|
101
|
+
}).catch(_temp);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
$[9] = geocoding;
|
|
105
|
+
$[10] = intl.locale;
|
|
106
|
+
$[11] = onChange;
|
|
107
|
+
$[12] = value?.address;
|
|
108
|
+
$[13] = t8;
|
|
109
|
+
} else t8 = $[13];
|
|
110
|
+
const setPoint = t8;
|
|
111
|
+
let t9;
|
|
112
|
+
if ($[14] !== draft || $[15] !== onChange || $[16] !== setPoint) {
|
|
113
|
+
t9 = (key, number) => {
|
|
114
|
+
const next_0 = {
|
|
115
|
+
...draft,
|
|
116
|
+
[key]: number
|
|
117
|
+
};
|
|
118
|
+
setDraft(next_0);
|
|
119
|
+
if (next_0.lat !== null && next_0.lng !== null) setPoint({
|
|
120
|
+
lat: next_0.lat,
|
|
121
|
+
lng: next_0.lng
|
|
122
|
+
});
|
|
123
|
+
else if (next_0.lat === null && next_0.lng === null) onChange?.(null);
|
|
124
|
+
};
|
|
125
|
+
$[14] = draft;
|
|
126
|
+
$[15] = onChange;
|
|
127
|
+
$[16] = setPoint;
|
|
128
|
+
$[17] = t9;
|
|
129
|
+
} else t9 = $[17];
|
|
130
|
+
const setCoordinate = t9;
|
|
131
|
+
let t10;
|
|
132
|
+
if ($[18] !== value) {
|
|
133
|
+
t10 = isLocation(value) ? {
|
|
134
|
+
lat: value.lat,
|
|
135
|
+
lng: value.lng
|
|
136
|
+
} : null;
|
|
137
|
+
$[18] = value;
|
|
138
|
+
$[19] = t10;
|
|
139
|
+
} else t10 = $[19];
|
|
140
|
+
const point_0 = t10;
|
|
141
|
+
let t11;
|
|
142
|
+
if ($[20] !== chosen || $[21] !== editable || $[22] !== geocoding || $[23] !== intl || $[24] !== places || $[25] !== query || $[26] !== search || $[27] !== setPoint) {
|
|
143
|
+
t11 = editable && geocoding !== null ? /* @__PURE__ */ jsx(ComboBox, {
|
|
144
|
+
"aria-label": intl.formatMessage(messages.searchAddress),
|
|
145
|
+
placeholder: intl.formatMessage(messages.searchAddress),
|
|
146
|
+
onInputChange: setQuery,
|
|
147
|
+
items: places.map(_temp2),
|
|
148
|
+
isLoading: search.loading,
|
|
149
|
+
menuTrigger: "input",
|
|
150
|
+
emptyMessage: query.trim().length < 3 ? intl.formatMessage(messages.searchAddressHint, { count: 3 }) : intl.formatMessage(messages.noPlaces),
|
|
151
|
+
value: chosen !== null && query === chosen.label ? "0" : null,
|
|
152
|
+
onChange: (id) => {
|
|
153
|
+
const result_0 = id !== null ? places[Number(id)] : void 0;
|
|
154
|
+
if (result_0 !== void 0) {
|
|
155
|
+
setChosen(result_0);
|
|
156
|
+
setPoint(result_0, result_0.label);
|
|
157
|
+
focusAddress();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}) : null;
|
|
161
|
+
$[20] = chosen;
|
|
162
|
+
$[21] = editable;
|
|
163
|
+
$[22] = geocoding;
|
|
164
|
+
$[23] = intl;
|
|
165
|
+
$[24] = places;
|
|
166
|
+
$[25] = query;
|
|
167
|
+
$[26] = search;
|
|
168
|
+
$[27] = setPoint;
|
|
169
|
+
$[28] = t11;
|
|
170
|
+
} else t11 = $[28];
|
|
171
|
+
let t12;
|
|
172
|
+
if ($[29] !== setPoint) {
|
|
173
|
+
t12 = (next_1) => setPoint(next_1);
|
|
174
|
+
$[29] = setPoint;
|
|
175
|
+
$[30] = t12;
|
|
176
|
+
} else t12 = $[30];
|
|
177
|
+
const t13 = !editable;
|
|
178
|
+
let t14;
|
|
179
|
+
if ($[31] !== intl || $[32] !== label) {
|
|
180
|
+
t14 = intl.formatMessage(messages.map, { label: typeof label === "string" ? label : "" });
|
|
181
|
+
$[31] = intl;
|
|
182
|
+
$[32] = label;
|
|
183
|
+
$[33] = t14;
|
|
184
|
+
} else t14 = $[33];
|
|
185
|
+
let t15;
|
|
186
|
+
if ($[34] !== center || $[35] !== point_0 || $[36] !== t12 || $[37] !== t13 || $[38] !== t14 || $[39] !== tiles || $[40] !== zoom) {
|
|
187
|
+
t15 = /* @__PURE__ */ jsx(LocationMap, {
|
|
188
|
+
point: point_0,
|
|
189
|
+
onChange: t12,
|
|
190
|
+
tiles,
|
|
191
|
+
center,
|
|
192
|
+
zoom,
|
|
193
|
+
readOnly: t13,
|
|
194
|
+
label: t14
|
|
195
|
+
});
|
|
196
|
+
$[34] = center;
|
|
197
|
+
$[35] = point_0;
|
|
198
|
+
$[36] = t12;
|
|
199
|
+
$[37] = t13;
|
|
200
|
+
$[38] = t14;
|
|
201
|
+
$[39] = tiles;
|
|
202
|
+
$[40] = zoom;
|
|
203
|
+
$[41] = t15;
|
|
204
|
+
} else t15 = $[41];
|
|
205
|
+
let t16;
|
|
206
|
+
if ($[42] !== intl) {
|
|
207
|
+
t16 = intl.formatMessage(messages.latitude);
|
|
208
|
+
$[42] = intl;
|
|
209
|
+
$[43] = t16;
|
|
210
|
+
} else t16 = $[43];
|
|
211
|
+
let t17;
|
|
212
|
+
if ($[44] !== setCoordinate) {
|
|
213
|
+
t17 = (next_2) => setCoordinate("lat", next_2);
|
|
214
|
+
$[44] = setCoordinate;
|
|
215
|
+
$[45] = t17;
|
|
216
|
+
} else t17 = $[45];
|
|
217
|
+
let t18;
|
|
218
|
+
if ($[46] !== onBlur) {
|
|
219
|
+
t18 = () => onBlur?.();
|
|
220
|
+
$[46] = onBlur;
|
|
221
|
+
$[47] = t18;
|
|
222
|
+
} else t18 = $[47];
|
|
223
|
+
let t19;
|
|
224
|
+
if ($[48] === Symbol.for("react.memo_cache_sentinel")) {
|
|
225
|
+
t19 = { maximumFractionDigits: 6 };
|
|
226
|
+
$[48] = t19;
|
|
227
|
+
} else t19 = $[48];
|
|
228
|
+
let t20;
|
|
229
|
+
if ($[49] !== disabled || $[50] !== draft.lat || $[51] !== readOnly || $[52] !== t16 || $[53] !== t17 || $[54] !== t18) {
|
|
230
|
+
t20 = /* @__PURE__ */ jsx(NumberInput, {
|
|
231
|
+
label: t16,
|
|
232
|
+
value: draft.lat,
|
|
233
|
+
onChange: t17,
|
|
234
|
+
onBlur: t18,
|
|
235
|
+
minValue: -90,
|
|
236
|
+
maxValue: 90,
|
|
237
|
+
step: 1e-6,
|
|
238
|
+
formatOptions: t19,
|
|
239
|
+
isDisabled: disabled,
|
|
240
|
+
isReadOnly: readOnly,
|
|
241
|
+
className: LocationField_module_default.coordinate
|
|
242
|
+
});
|
|
243
|
+
$[49] = disabled;
|
|
244
|
+
$[50] = draft.lat;
|
|
245
|
+
$[51] = readOnly;
|
|
246
|
+
$[52] = t16;
|
|
247
|
+
$[53] = t17;
|
|
248
|
+
$[54] = t18;
|
|
249
|
+
$[55] = t20;
|
|
250
|
+
} else t20 = $[55];
|
|
251
|
+
let t21;
|
|
252
|
+
if ($[56] !== intl) {
|
|
253
|
+
t21 = intl.formatMessage(messages.longitude);
|
|
254
|
+
$[56] = intl;
|
|
255
|
+
$[57] = t21;
|
|
256
|
+
} else t21 = $[57];
|
|
257
|
+
let t22;
|
|
258
|
+
if ($[58] !== setCoordinate) {
|
|
259
|
+
t22 = (next_3) => setCoordinate("lng", next_3);
|
|
260
|
+
$[58] = setCoordinate;
|
|
261
|
+
$[59] = t22;
|
|
262
|
+
} else t22 = $[59];
|
|
263
|
+
let t23;
|
|
264
|
+
if ($[60] !== onBlur) {
|
|
265
|
+
t23 = () => onBlur?.();
|
|
266
|
+
$[60] = onBlur;
|
|
267
|
+
$[61] = t23;
|
|
268
|
+
} else t23 = $[61];
|
|
269
|
+
let t24;
|
|
270
|
+
if ($[62] === Symbol.for("react.memo_cache_sentinel")) {
|
|
271
|
+
t24 = { maximumFractionDigits: 6 };
|
|
272
|
+
$[62] = t24;
|
|
273
|
+
} else t24 = $[62];
|
|
274
|
+
let t25;
|
|
275
|
+
if ($[63] !== disabled || $[64] !== draft.lng || $[65] !== readOnly || $[66] !== t21 || $[67] !== t22 || $[68] !== t23) {
|
|
276
|
+
t25 = /* @__PURE__ */ jsx(NumberInput, {
|
|
277
|
+
label: t21,
|
|
278
|
+
value: draft.lng,
|
|
279
|
+
onChange: t22,
|
|
280
|
+
onBlur: t23,
|
|
281
|
+
minValue: -180,
|
|
282
|
+
maxValue: 180,
|
|
283
|
+
step: 1e-6,
|
|
284
|
+
formatOptions: t24,
|
|
285
|
+
isDisabled: disabled,
|
|
286
|
+
isReadOnly: readOnly,
|
|
287
|
+
className: LocationField_module_default.coordinate
|
|
288
|
+
});
|
|
289
|
+
$[63] = disabled;
|
|
290
|
+
$[64] = draft.lng;
|
|
291
|
+
$[65] = readOnly;
|
|
292
|
+
$[66] = t21;
|
|
293
|
+
$[67] = t22;
|
|
294
|
+
$[68] = t23;
|
|
295
|
+
$[69] = t25;
|
|
296
|
+
} else t25 = $[69];
|
|
297
|
+
let t26;
|
|
298
|
+
if ($[70] !== editable || $[71] !== intl || $[72] !== onChange || $[73] !== point_0) {
|
|
299
|
+
t26 = editable && point_0 !== null ? /* @__PURE__ */ jsx(IconButton, {
|
|
300
|
+
icon: X,
|
|
301
|
+
label: intl.formatMessage(messages.removePoint),
|
|
302
|
+
className: LocationField_module_default.remove,
|
|
303
|
+
onPress: () => onChange?.(null)
|
|
304
|
+
}) : null;
|
|
305
|
+
$[70] = editable;
|
|
306
|
+
$[71] = intl;
|
|
307
|
+
$[72] = onChange;
|
|
308
|
+
$[73] = point_0;
|
|
309
|
+
$[74] = t26;
|
|
310
|
+
} else t26 = $[74];
|
|
311
|
+
let t27;
|
|
312
|
+
if ($[75] !== t20 || $[76] !== t25 || $[77] !== t26) {
|
|
313
|
+
t27 = /* @__PURE__ */ jsxs("div", {
|
|
314
|
+
className: LocationField_module_default.coordinates,
|
|
315
|
+
children: [
|
|
316
|
+
t20,
|
|
317
|
+
t25,
|
|
318
|
+
t26
|
|
319
|
+
]
|
|
320
|
+
});
|
|
321
|
+
$[75] = t20;
|
|
322
|
+
$[76] = t25;
|
|
323
|
+
$[77] = t26;
|
|
324
|
+
$[78] = t27;
|
|
325
|
+
} else t27 = $[78];
|
|
326
|
+
let t28;
|
|
327
|
+
if ($[79] !== disabled || $[80] !== intl || $[81] !== onBlur || $[82] !== onChange || $[83] !== point_0 || $[84] !== readOnly || $[85] !== value?.address) {
|
|
328
|
+
t28 = point_0 !== null ? /* @__PURE__ */ jsx("div", {
|
|
329
|
+
ref: addressRef,
|
|
330
|
+
children: /* @__PURE__ */ jsx(TextInput, {
|
|
331
|
+
label: intl.formatMessage(messages.address),
|
|
332
|
+
value: value?.address ?? "",
|
|
333
|
+
onChange: (address_0) => onChange?.({
|
|
334
|
+
lat: point_0.lat,
|
|
335
|
+
lng: point_0.lng,
|
|
336
|
+
...address_0 !== "" ? { address: address_0 } : {}
|
|
337
|
+
}),
|
|
338
|
+
onBlur: () => onBlur?.(),
|
|
339
|
+
isDisabled: disabled,
|
|
340
|
+
isReadOnly: readOnly
|
|
341
|
+
})
|
|
342
|
+
}) : null;
|
|
343
|
+
$[79] = disabled;
|
|
344
|
+
$[80] = intl;
|
|
345
|
+
$[81] = onBlur;
|
|
346
|
+
$[82] = onChange;
|
|
347
|
+
$[83] = point_0;
|
|
348
|
+
$[84] = readOnly;
|
|
349
|
+
$[85] = value?.address;
|
|
350
|
+
$[86] = t28;
|
|
351
|
+
} else t28 = $[86];
|
|
352
|
+
let t29;
|
|
353
|
+
if ($[87] !== t11 || $[88] !== t15 || $[89] !== t27 || $[90] !== t28) {
|
|
354
|
+
t29 = /* @__PURE__ */ jsxs("div", {
|
|
355
|
+
className: LocationField_module_default.location,
|
|
356
|
+
children: [
|
|
357
|
+
t11,
|
|
358
|
+
t15,
|
|
359
|
+
t27,
|
|
360
|
+
t28
|
|
361
|
+
]
|
|
362
|
+
});
|
|
363
|
+
$[87] = t11;
|
|
364
|
+
$[88] = t15;
|
|
365
|
+
$[89] = t27;
|
|
366
|
+
$[90] = t28;
|
|
367
|
+
$[91] = t29;
|
|
368
|
+
} else t29 = $[91];
|
|
369
|
+
let t30;
|
|
370
|
+
if ($[92] !== className || $[93] !== description || $[94] !== disabled || $[95] !== errors || $[96] !== label || $[97] !== required || $[98] !== t29) {
|
|
371
|
+
t30 = /* @__PURE__ */ jsx(Fieldset, {
|
|
372
|
+
legend: label,
|
|
373
|
+
description,
|
|
374
|
+
errors,
|
|
375
|
+
isRequired: required,
|
|
376
|
+
isDisabled: disabled,
|
|
377
|
+
className,
|
|
378
|
+
children: t29
|
|
379
|
+
});
|
|
380
|
+
$[92] = className;
|
|
381
|
+
$[93] = description;
|
|
382
|
+
$[94] = disabled;
|
|
383
|
+
$[95] = errors;
|
|
384
|
+
$[96] = label;
|
|
385
|
+
$[97] = required;
|
|
386
|
+
$[98] = t29;
|
|
387
|
+
$[99] = t30;
|
|
388
|
+
} else t30 = $[99];
|
|
389
|
+
return t30;
|
|
390
|
+
}
|
|
391
|
+
function _temp2(result, index) {
|
|
392
|
+
return {
|
|
393
|
+
id: String(index),
|
|
394
|
+
label: result.label
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
function _temp() {}
|
|
398
|
+
function isPoint(value) {
|
|
399
|
+
return isLocation(value);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* The `location` type: settings `zoom`, `center` (`{ "lat", "lng" }`, where the map opens without
|
|
403
|
+
* a point) and `tiles` (`{ "url", "attribution" }`), over the maps of the `FieldsProvider`.
|
|
404
|
+
*/
|
|
405
|
+
function LocationFieldEntry(props) {
|
|
406
|
+
const $ = c(23);
|
|
407
|
+
const { field } = props;
|
|
408
|
+
let t0;
|
|
409
|
+
if ($[0] !== field) {
|
|
410
|
+
t0 = getSetting(field, "zoom", isNumber);
|
|
411
|
+
$[0] = field;
|
|
412
|
+
$[1] = t0;
|
|
413
|
+
} else t0 = $[1];
|
|
414
|
+
const zoom = t0;
|
|
415
|
+
let t1;
|
|
416
|
+
if ($[2] !== field) {
|
|
417
|
+
t1 = getSetting(field, "center", isPoint);
|
|
418
|
+
$[2] = field;
|
|
419
|
+
$[3] = t1;
|
|
420
|
+
} else t1 = $[3];
|
|
421
|
+
const center = t1;
|
|
422
|
+
let t2;
|
|
423
|
+
if ($[4] !== field) {
|
|
424
|
+
t2 = getSetting(field, "tiles", _temp3);
|
|
425
|
+
$[4] = field;
|
|
426
|
+
$[5] = t2;
|
|
427
|
+
} else t2 = $[5];
|
|
428
|
+
const tiles = t2;
|
|
429
|
+
let t3;
|
|
430
|
+
if ($[6] !== props) {
|
|
431
|
+
t3 = getFieldProps(props);
|
|
432
|
+
$[6] = props;
|
|
433
|
+
$[7] = t3;
|
|
434
|
+
} else t3 = $[7];
|
|
435
|
+
let fieldProps;
|
|
436
|
+
if ($[8] !== t3) {
|
|
437
|
+
const { placeholder: _placeholder, ...t4 } = t3;
|
|
438
|
+
fieldProps = t4;
|
|
439
|
+
$[8] = t3;
|
|
440
|
+
$[9] = fieldProps;
|
|
441
|
+
} else fieldProps = $[9];
|
|
442
|
+
const t4 = isLocation(props.value) ? props.value : null;
|
|
443
|
+
let t5;
|
|
444
|
+
if ($[10] !== zoom) {
|
|
445
|
+
t5 = zoom !== void 0 ? { zoom } : {};
|
|
446
|
+
$[10] = zoom;
|
|
447
|
+
$[11] = t5;
|
|
448
|
+
} else t5 = $[11];
|
|
449
|
+
let t6;
|
|
450
|
+
if ($[12] !== center) {
|
|
451
|
+
t6 = center !== void 0 ? { center } : {};
|
|
452
|
+
$[12] = center;
|
|
453
|
+
$[13] = t6;
|
|
454
|
+
} else t6 = $[13];
|
|
455
|
+
let t7;
|
|
456
|
+
if ($[14] !== tiles) {
|
|
457
|
+
t7 = tiles !== void 0 ? { tiles } : {};
|
|
458
|
+
$[14] = tiles;
|
|
459
|
+
$[15] = t7;
|
|
460
|
+
} else t7 = $[15];
|
|
461
|
+
let t8;
|
|
462
|
+
if ($[16] !== fieldProps || $[17] !== props.onChange || $[18] !== t4 || $[19] !== t5 || $[20] !== t6 || $[21] !== t7) {
|
|
463
|
+
t8 = /* @__PURE__ */ jsx(LocationField, {
|
|
464
|
+
...fieldProps,
|
|
465
|
+
value: t4,
|
|
466
|
+
onChange: props.onChange,
|
|
467
|
+
...t5,
|
|
468
|
+
...t6,
|
|
469
|
+
...t7
|
|
470
|
+
});
|
|
471
|
+
$[16] = fieldProps;
|
|
472
|
+
$[17] = props.onChange;
|
|
473
|
+
$[18] = t4;
|
|
474
|
+
$[19] = t5;
|
|
475
|
+
$[20] = t6;
|
|
476
|
+
$[21] = t7;
|
|
477
|
+
$[22] = t8;
|
|
478
|
+
} else t8 = $[22];
|
|
479
|
+
return t8;
|
|
480
|
+
}
|
|
481
|
+
function _temp3(value) {
|
|
482
|
+
return value !== null && typeof value === "object" && isString(value.url) && isString(value.attribution);
|
|
483
|
+
}
|
|
484
|
+
//#endregion
|
|
485
|
+
export { LocationField, LocationFieldEntry, OPEN_STREET_MAP_TILES, isLocation };
|
|
486
|
+
|
|
487
|
+
//# sourceMappingURL=LocationField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocationField.js","names":["X","useRef","useState","LocationValue","ComboBox","Fieldset","IconButton","NumberInput","TextInput","usePanneauIntl","useFieldsContext","getFieldProps","getSetting","isNumber","isString","messages","FieldEntryProps","FieldProps","styles","LocationMap","Point","SEARCH_MIN_LENGTH","useAddressSearch","GeocodingResult","GeocodingSource","MapTiles","OPEN_STREET_MAP_TILES","url","attribution","maxZoom","DEFAULT_CENTER","lat","lng","LocationFieldProps","geocoding","tiles","center","zoom","isLocation","value","Record","LocationField","t0","$","_c","onChange","onBlur","geocodingProp","tilesProp","t1","t2","label","description","errors","disabled","readOnly","required","className","undefined","intl","maps","editable","query","setQuery","chosen","setChosen","search","locale","t3","results","places","addressRef","t4","Symbol","for","window","requestAnimationFrame","current","querySelector","focus","focusAddress","t5","t6","t7","source","draft","setDraft","t8","address","point","newAddress","next","Number","toFixed","reverse","controller","AbortController","signal","then","place","catch","_temp","setPoint","t9","key","number","next_0","setCoordinate","t10","point_0","t11","formatMessage","searchAddress","map","_temp2","loading","trim","length","searchAddressHint","count","noPlaces","id","result_0","result","t12","next_1","t13","t14","t15","t16","latitude","t17","next_2","t18","t19","maximumFractionDigits","t20","coordinate","t21","longitude","t22","next_3","t23","t24","t25","t26","removePoint","remove","t27","coordinates","t28","address_0","t29","location","t30","index","String","isPoint","LocationFieldEntry","props","field","_temp3","fieldProps","placeholder","_placeholder","_c","styles"],"sources":["../../src/location/LocationField.tsx"],"sourcesContent":["import { X } from 'lucide-react';\nimport { useRef, useState } from 'react';\n\nimport type { LocationValue } from '@panneau/protocol';\nimport {\n ComboBox,\n Fieldset,\n IconButton,\n NumberInput,\n TextInput,\n usePanneauIntl,\n} from '@panneau/ui';\n\nimport { useFieldsContext } from '../shared/context';\nimport { getFieldProps, getSetting, isNumber, isString } from '../shared/entry';\nimport { messages } from '../shared/messages';\nimport type { FieldEntryProps, FieldProps } from '../shared/types';\nimport styles from './LocationField.module.css';\nimport { LocationMap, type Point } from './LocationMap';\nimport { SEARCH_MIN_LENGTH, useAddressSearch } from './search';\nimport type { GeocodingResult, GeocodingSource, MapTiles } from './types';\n\nexport type { LocationValue };\n\n/** OpenStreetMap's standard tiles: fine for an admin panel, with their credit. */\nexport const OPEN_STREET_MAP_TILES: MapTiles = {\n url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',\n attribution:\n '© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors',\n maxZoom: 19,\n};\n\nconst DEFAULT_CENTER: Point = { lat: 20, lng: 0 };\n\nexport interface LocationFieldProps extends FieldProps<LocationValue> {\n /** The address search. Defaults to that of the `FieldsProvider`; without one, there is none. */\n geocoding?: GeocodingSource | null;\n /** The tiles of the map. Defaults to those of the `FieldsProvider`, or OpenStreetMap's. */\n tiles?: MapTiles;\n /** Where the map opens without a point. Defaults to the whole world. */\n center?: Point;\n /** Zoom of the map on a point. Defaults to 15. */\n zoom?: number;\n}\n\n/** Whether a value is a point. */\nexport function isLocation(value: unknown): value is LocationValue {\n return (\n value !== null &&\n typeof value === 'object' &&\n isNumber((value as Record<string, unknown>).lat) &&\n isNumber((value as Record<string, unknown>).lng)\n );\n}\n\n/**\n * A point on a map, and its address. Clicking the map or dragging the marker places the point,\n * and its latitude and longitude can be typed. With an address search, a place found sets the\n * point and the address; with a reverse search, placing a point fills an empty address.\n */\nexport function LocationField({\n value,\n onChange,\n onBlur,\n geocoding: geocodingProp,\n tiles: tilesProp,\n center = DEFAULT_CENTER,\n zoom = 15,\n label,\n description,\n errors,\n disabled,\n readOnly,\n required,\n className,\n}: LocationFieldProps) {\n const intl = usePanneauIntl();\n const { maps } = useFieldsContext();\n const geocoding = geocodingProp === undefined ? (maps?.geocoding ?? null) : geocodingProp;\n const tiles = tilesProp ?? maps?.tiles ?? OPEN_STREET_MAP_TILES;\n const editable = disabled !== true && readOnly !== true;\n const [query, setQuery] = useState('');\n // The place chosen: the search shows its label until something else is typed\n const [chosen, setChosen] = useState<GeocodingResult | null>(null);\n const search = useAddressSearch(\n editable && query !== chosen?.label ? geocoding : null,\n query,\n intl.locale,\n );\n const places = chosen !== null && query === chosen.label ? [chosen] : search.results;\n // A place chosen moves focus to its address, which closes the results\n const addressRef = useRef<HTMLDivElement>(null);\n const focusAddress = () =>\n window.requestAnimationFrame(() =>\n addressRef.current?.querySelector<HTMLInputElement>('input')?.focus(),\n );\n\n // The coordinates as typed: a value needs both\n const [draft, setDraft] = useState<{ source: unknown; lat: number | null; lng: number | null }>(\n { source: value, lat: value?.lat ?? null, lng: value?.lng ?? null },\n );\n if (draft.source !== value) {\n setDraft({ source: value, lat: value?.lat ?? null, lng: value?.lng ?? null });\n }\n\n const setPoint = (point: Point, newAddress?: string) => {\n const address = newAddress ?? value?.address;\n const next: LocationValue = {\n lat: Number(point.lat.toFixed(6)),\n lng: Number(point.lng.toFixed(6)),\n ...(address !== undefined && address !== '' ? { address } : {}),\n };\n onChange?.(next);\n // Fills an empty address from the point\n if ((address === undefined || address === '') && geocoding?.reverse !== undefined) {\n const controller = new AbortController();\n void geocoding\n .reverse(point, { signal: controller.signal, locale: intl.locale })\n .then((place) => {\n if (place !== null) {\n onChange?.({ ...next, address: place.label });\n }\n })\n .catch(() => undefined);\n }\n };\n\n const setCoordinate = (key: 'lat' | 'lng', number: number | null) => {\n const next = { ...draft, [key]: number };\n setDraft(next);\n if (next.lat !== null && next.lng !== null) {\n setPoint({ lat: next.lat, lng: next.lng });\n } else if (next.lat === null && next.lng === null) {\n onChange?.(null);\n }\n };\n\n const point = isLocation(value) ? { lat: value.lat, lng: value.lng } : null;\n return (\n <Fieldset\n legend={label}\n description={description}\n errors={errors}\n isRequired={required}\n isDisabled={disabled}\n className={className}\n >\n <div className={styles.location}>\n {editable && geocoding !== null ? (\n <ComboBox\n aria-label={intl.formatMessage(messages.searchAddress)}\n placeholder={intl.formatMessage(messages.searchAddress)}\n onInputChange={setQuery}\n items={places.map((result, index) => ({\n id: String(index),\n label: result.label,\n }))}\n isLoading={search.loading}\n menuTrigger=\"input\"\n emptyMessage={\n query.trim().length < SEARCH_MIN_LENGTH\n ? intl.formatMessage(messages.searchAddressHint, {\n count: SEARCH_MIN_LENGTH,\n })\n : intl.formatMessage(messages.noPlaces)\n }\n value={chosen !== null && query === chosen.label ? '0' : null}\n onChange={(id) => {\n const result = id !== null ? places[Number(id)] : undefined;\n if (result !== undefined) {\n setChosen(result);\n setPoint(result, result.label);\n focusAddress();\n }\n }}\n />\n ) : null}\n <LocationMap\n point={point}\n onChange={(next) => setPoint(next)}\n tiles={tiles}\n center={center}\n zoom={zoom}\n readOnly={!editable}\n label={intl.formatMessage(messages.map, {\n label: typeof label === 'string' ? label : '',\n })}\n />\n <div className={styles.coordinates}>\n <NumberInput\n label={intl.formatMessage(messages.latitude)}\n value={draft.lat}\n onChange={(next) => setCoordinate('lat', next)}\n onBlur={() => onBlur?.()}\n minValue={-90}\n maxValue={90}\n step={0.000001}\n formatOptions={{ maximumFractionDigits: 6 }}\n isDisabled={disabled}\n isReadOnly={readOnly}\n className={styles.coordinate}\n />\n <NumberInput\n label={intl.formatMessage(messages.longitude)}\n value={draft.lng}\n onChange={(next) => setCoordinate('lng', next)}\n onBlur={() => onBlur?.()}\n minValue={-180}\n maxValue={180}\n step={0.000001}\n formatOptions={{ maximumFractionDigits: 6 }}\n isDisabled={disabled}\n isReadOnly={readOnly}\n className={styles.coordinate}\n />\n {editable && point !== null ? (\n <IconButton\n icon={X}\n label={intl.formatMessage(messages.removePoint)}\n className={styles.remove}\n onPress={() => onChange?.(null)}\n />\n ) : null}\n </div>\n {point !== null ? (\n <div ref={addressRef}>\n <TextInput\n label={intl.formatMessage(messages.address)}\n value={value?.address ?? ''}\n onChange={(address) =>\n onChange?.({\n lat: point.lat,\n lng: point.lng,\n ...(address !== '' ? { address } : {}),\n })\n }\n onBlur={() => onBlur?.()}\n isDisabled={disabled}\n isReadOnly={readOnly}\n />\n </div>\n ) : null}\n </div>\n </Fieldset>\n );\n}\n\nfunction isPoint(value: unknown): value is Point {\n return isLocation(value);\n}\n\n/**\n * The `location` type: settings `zoom`, `center` (`{ \"lat\", \"lng\" }`, where the map opens without\n * a point) and `tiles` (`{ \"url\", \"attribution\" }`), over the maps of the `FieldsProvider`.\n */\nexport function LocationFieldEntry(props: FieldEntryProps) {\n const { field } = props;\n const zoom = getSetting(field, 'zoom', isNumber);\n const center = getSetting(field, 'center', isPoint);\n const tiles = getSetting(\n field,\n 'tiles',\n (value): value is MapTiles =>\n value !== null &&\n typeof value === 'object' &&\n isString((value as Record<string, unknown>).url) &&\n isString((value as Record<string, unknown>).attribution),\n );\n const { placeholder: _placeholder, ...fieldProps } = getFieldProps(props);\n return (\n <LocationField\n {...fieldProps}\n value={isLocation(props.value) ? props.value : null}\n onChange={props.onChange}\n {...(zoom !== undefined ? { zoom } : {})}\n {...(center !== undefined ? { center } : {})}\n {...(tiles !== undefined ? { tiles } : {})}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAyBA,IAAa0B,wBAAkC;CAC3CC,KAAK;CACLC,aACI;CACJC,SAAS;AACb;AAEA,IAAMC,iBAAwB;CAAEC,KAAK;CAAIC,KAAK;AAAE;;AAchD,SAAgBM,WAAWC,OAAwC;CAC/D,OACIA,UAAU,QACV,OAAOA,UAAU,YACjB1B,SAAU0B,MAAkCR,GAAG,KAC/ClB,SAAU0B,MAAkCP,GAAG;AAEvD;;;;;;AAOA,SAAOS,cAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAuB,MAAA,EAAAL,OAAAM,UAAAC,QAAAZ,WAAAa,eAAAZ,OAAAa,WAAAZ,QAAAa,IAAAZ,MAAAa,IAAAC,OAAAC,aAAAC,QAAAC,UAAAC,UAAAC,UAAAC,cAAAf;CAM1B,MAAAN,SAAAa,OAAAS,KAAAA,IAAA5B,iBAAAmB;CACA,MAAAZ,OAAAa,OAAAQ,KAAAA,IAAA,KAAAR;CASA,MAAAS,OAAalD,eAAe;CAC5B,MAAA,EAAAmD,SAAiBlD,iBAAiB;CAClC,MAAAwB,YAAkBa,kBAAkBW,KAAAA,IAAaE,MAAI1B,aAAJ,OAA/Ba;CAClB,MAAAZ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AAA;CAAA,OAQKA,UAAU,QACV,OAAOA,UAAU,YACjBzB,SAAUyB,MAAgCZ,GAAK,KAC/Cb,SAAUyB,MAAgCX,WAAa;AAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import "./LocationField.css";
|
|
2
|
+
//#region src/location/LocationField.module.css
|
|
3
|
+
var location = "panneau-location-field-location";
|
|
4
|
+
var map = "panneau-location-field-map";
|
|
5
|
+
var marker = "panneau-location-field-marker";
|
|
6
|
+
var pin = "panneau-location-field-pin";
|
|
7
|
+
var coordinates = "panneau-location-field-coordinates";
|
|
8
|
+
var coordinate = "panneau-location-field-coordinate";
|
|
9
|
+
var remove = "panneau-location-field-remove";
|
|
10
|
+
var LocationField_module_default = {
|
|
11
|
+
location,
|
|
12
|
+
map,
|
|
13
|
+
marker,
|
|
14
|
+
pin,
|
|
15
|
+
coordinates,
|
|
16
|
+
coordinate,
|
|
17
|
+
remove
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { coordinate, coordinates, LocationField_module_default as default, location, map, marker, pin, remove };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=LocationField.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocationField.module.js","names":[],"sources":["../../src/location/LocationField.module.css"],"sourcesContent":["/* The search, the map, then the coordinates and the address. */\n.location {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-2);\n}\n\n.map {\n position: relative;\n z-index: 0;\n height: 16rem;\n overflow: hidden;\n background-color: var(--panneau-color-surface-sunken);\n border: var(--panneau-border-width) solid var(--panneau-color-border-control);\n border-radius: var(--panneau-radius-md);\n}\n\n.map:focus-visible {\n outline: var(--panneau-focus-width) solid var(--panneau-color-focus);\n outline-offset: 1px;\n}\n\n/* A pin: a round head pointing down at the point. */\n.marker {\n background: none;\n border: 0;\n}\n\n.pin {\n display: block;\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n background-color: var(--panneau-color-accent);\n border: 2px solid var(--panneau-color-surface);\n border-radius: 50% 50% 50% 0;\n box-shadow: var(--panneau-shadow-sm);\n rotate: -45deg;\n}\n\n.coordinates {\n display: flex;\n flex-wrap: wrap;\n align-items: flex-end;\n gap: var(--panneau-space-2);\n}\n\n.coordinate {\n flex: 1 1 8rem;\n}\n\n.remove {\n flex: none;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { MapTiles } from './types.js';
|
|
2
|
+
export interface Point {
|
|
3
|
+
lat: number;
|
|
4
|
+
lng: number;
|
|
5
|
+
}
|
|
6
|
+
export interface LocationMapProps {
|
|
7
|
+
point: Point | null;
|
|
8
|
+
/** Called with the point clicked, or where the marker was dropped. */
|
|
9
|
+
onChange?: (point: Point) => void;
|
|
10
|
+
tiles: MapTiles;
|
|
11
|
+
/** Where the map opens without a point. */
|
|
12
|
+
center: Point;
|
|
13
|
+
/** Zoom of the map on a point; the map opens wider without one. */
|
|
14
|
+
zoom: number;
|
|
15
|
+
readOnly?: boolean;
|
|
16
|
+
/** Accessible name of the map. */
|
|
17
|
+
label: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A Leaflet map with a marker on the point. Clicking the map or dragging the marker moves the
|
|
22
|
+
* point. Leaflet and its stylesheet load when the map first shows.
|
|
23
|
+
*/
|
|
24
|
+
export declare function LocationMap({ point, onChange, tiles, center, zoom, readOnly, label, className, }: LocationMapProps): import("react").JSX.Element;
|
|
25
|
+
//# sourceMappingURL=LocationMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocationMap.d.ts","sourceRoot":"","sources":["../../src/location/LocationMap.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAwBxC,MAAM,WAAW,KAAK;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAClC,KAAK,EAAE,QAAQ,CAAC;IAChB,2CAA2C;IAC3C,MAAM,EAAE,KAAK,CAAC;IACd,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,KAAK,EACL,MAAM,EACN,IAAI,EACJ,QAAgB,EAChB,KAAK,EACL,SAAS,GACZ,EAAE,gBAAgB,+BAuGlB"}
|