@panneau/fields 5.0.0-alpha.15 → 5.0.0-alpha.16

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.
Files changed (139) hide show
  1. package/README.md +53 -3
  2. package/dist/address/AddressField.css +44 -0
  3. package/dist/address/AddressField.d.ts +37 -0
  4. package/dist/address/AddressField.d.ts.map +1 -0
  5. package/dist/address/AddressField.js +411 -0
  6. package/dist/address/AddressField.js.map +1 -0
  7. package/dist/address/AddressField.module.js +22 -0
  8. package/dist/address/AddressField.module.js.map +1 -0
  9. package/dist/address/address.d.ts +23 -0
  10. package/dist/address/address.d.ts.map +1 -0
  11. package/dist/address/address.js +58 -0
  12. package/dist/address/address.js.map +1 -0
  13. package/dist/address/index.d.ts +3 -0
  14. package/dist/address/index.d.ts.map +1 -0
  15. package/dist/address/index.js +3 -0
  16. package/dist/color/ColorField.css +9 -0
  17. package/dist/color/ColorField.d.ts +10 -3
  18. package/dist/color/ColorField.d.ts.map +1 -1
  19. package/dist/color/ColorField.js +341 -81
  20. package/dist/color/ColorField.js.map +1 -1
  21. package/dist/color/ColorField.module.js +4 -2
  22. package/dist/color/ColorField.module.js.map +1 -1
  23. package/dist/color/index.d.ts +1 -0
  24. package/dist/color/index.d.ts.map +1 -1
  25. package/dist/color/index.js +3 -1
  26. package/dist/color/palette.d.ts +23 -0
  27. package/dist/color/palette.d.ts.map +1 -0
  28. package/dist/color/palette.js +34 -0
  29. package/dist/color/palette.js.map +1 -0
  30. package/dist/country/CountryField.css +42 -0
  31. package/dist/country/CountryField.d.ts +19 -4
  32. package/dist/country/CountryField.d.ts.map +1 -1
  33. package/dist/country/CountryField.js +355 -82
  34. package/dist/country/CountryField.js.map +1 -1
  35. package/dist/country/CountryField.module.js +20 -0
  36. package/dist/country/CountryField.module.js.map +1 -0
  37. package/dist/country/index.d.ts +1 -1
  38. package/dist/country/index.d.ts.map +1 -1
  39. package/dist/daterange/DateRangeField.css +9 -0
  40. package/dist/daterange/DateRangeField.d.ts +31 -0
  41. package/dist/daterange/DateRangeField.d.ts.map +1 -0
  42. package/dist/daterange/DateRangeField.js +372 -0
  43. package/dist/daterange/DateRangeField.js.map +1 -0
  44. package/dist/daterange/DateRangeField.module.js +12 -0
  45. package/dist/daterange/DateRangeField.module.js.map +1 -0
  46. package/dist/daterange/index.d.ts +3 -0
  47. package/dist/daterange/index.d.ts.map +1 -0
  48. package/dist/daterange/index.js +3 -0
  49. package/dist/daterange/range.d.ts +61 -0
  50. package/dist/daterange/range.d.ts.map +1 -0
  51. package/dist/daterange/range.js +119 -0
  52. package/dist/daterange/range.js.map +1 -0
  53. package/dist/duration/DurationField.css +1 -1
  54. package/dist/duration/DurationField.d.ts +54 -13
  55. package/dist/duration/DurationField.d.ts.map +1 -1
  56. package/dist/duration/DurationField.js +205 -159
  57. package/dist/duration/DurationField.js.map +1 -1
  58. package/dist/duration/DurationField.module.js.map +1 -1
  59. package/dist/duration/index.d.ts +1 -1
  60. package/dist/duration/index.d.ts.map +1 -1
  61. package/dist/duration/index.js +1 -1
  62. package/dist/embed/EmbedField.d.ts +11 -2
  63. package/dist/embed/EmbedField.d.ts.map +1 -1
  64. package/dist/embed/EmbedField.js +179 -116
  65. package/dist/embed/EmbedField.js.map +1 -1
  66. package/dist/link/LinkField.css +12 -0
  67. package/dist/link/LinkField.d.ts +38 -0
  68. package/dist/link/LinkField.d.ts.map +1 -0
  69. package/dist/link/LinkField.js +742 -0
  70. package/dist/link/LinkField.js.map +1 -0
  71. package/dist/link/LinkField.module.js +8 -0
  72. package/dist/link/LinkField.module.js.map +1 -0
  73. package/dist/link/index.d.ts +3 -0
  74. package/dist/link/index.d.ts.map +1 -0
  75. package/dist/link/index.js +3 -0
  76. package/dist/link/link.d.ts +30 -0
  77. package/dist/link/link.d.ts.map +1 -0
  78. package/dist/link/link.js +63 -0
  79. package/dist/link/link.js.map +1 -0
  80. package/dist/link/pages.d.ts +17 -0
  81. package/dist/link/pages.d.ts.map +1 -0
  82. package/dist/link/pages.js +104 -0
  83. package/dist/link/pages.js.map +1 -0
  84. package/dist/location/LocationField.d.ts.map +1 -1
  85. package/dist/location/LocationField.js +9 -85
  86. package/dist/location/LocationField.js.map +1 -1
  87. package/dist/location/nominatim.d.ts +8 -2
  88. package/dist/location/nominatim.d.ts.map +1 -1
  89. package/dist/location/nominatim.js +32 -3
  90. package/dist/location/nominatim.js.map +1 -1
  91. package/dist/location/search.d.ts +10 -0
  92. package/dist/location/search.d.ts.map +1 -0
  93. package/dist/location/search.js +83 -0
  94. package/dist/location/search.js.map +1 -0
  95. package/dist/location/types.d.ts +8 -2
  96. package/dist/location/types.d.ts.map +1 -1
  97. package/dist/money/MoneyField.d.ts +28 -0
  98. package/dist/money/MoneyField.d.ts.map +1 -0
  99. package/dist/money/MoneyField.js +269 -0
  100. package/dist/money/MoneyField.js.map +1 -0
  101. package/dist/money/index.d.ts +3 -0
  102. package/dist/money/index.d.ts.map +1 -0
  103. package/dist/money/index.js +3 -0
  104. package/dist/money/money.d.ts +27 -0
  105. package/dist/money/money.d.ts.map +1 -0
  106. package/dist/money/money.js +56 -0
  107. package/dist/money/money.js.map +1 -0
  108. package/dist/region/RegionField.js +1 -1
  109. package/dist/shared/builtIn.d.ts +3 -1
  110. package/dist/shared/builtIn.d.ts.map +1 -1
  111. package/dist/shared/builtIn.js +18 -8
  112. package/dist/shared/builtIn.js.map +1 -1
  113. package/dist/shared/dates.js +2 -2
  114. package/dist/shared/dates.js.map +1 -1
  115. package/dist/shared/flow.d.ts.map +1 -1
  116. package/dist/shared/flow.js +1 -0
  117. package/dist/shared/flow.js.map +1 -1
  118. package/dist/shared/part.d.ts +26 -0
  119. package/dist/shared/part.d.ts.map +1 -0
  120. package/dist/shared/part.js +64 -0
  121. package/dist/shared/part.js.map +1 -0
  122. package/dist/tel/TelField.css +25 -0
  123. package/dist/tel/TelField.d.ts +14 -2
  124. package/dist/tel/TelField.d.ts.map +1 -1
  125. package/dist/tel/TelField.js +246 -145
  126. package/dist/tel/TelField.js.map +1 -1
  127. package/dist/tel/TelField.module.js +12 -0
  128. package/dist/tel/TelField.module.js.map +1 -0
  129. package/dist/tel/index.d.ts +1 -1
  130. package/dist/tel/index.d.ts.map +1 -1
  131. package/dist/tel/index.js +2 -2
  132. package/dist/tel/phone.d.ts +28 -0
  133. package/dist/tel/phone.d.ts.map +1 -1
  134. package/dist/tel/phone.js +48 -1
  135. package/dist/tel/phone.js.map +1 -1
  136. package/dist/url/UrlField.d.ts.map +1 -1
  137. package/dist/url/UrlField.js +1 -1
  138. package/dist/url/UrlField.js.map +1 -1
  139. package/package.json +24 -4
package/README.md CHANGED
@@ -32,13 +32,17 @@ Every field takes `value`, `onChange`, `onBlur`, `errors`, `disabled`, `readOnly
32
32
  | `@panneau/fields/select` | `SelectField` (dropdown, radios, checkboxes) | an option's value, or a list with `multiple` |
33
33
  | `@panneau/fields/email` | `EmailField` | `string` |
34
34
  | `@panneau/fields/url` | `UrlField` | `string`, with `https://` added on blur |
35
- | `@panneau/fields/color` | `ColorField` | `'#1d4ed8'` |
35
+ | `@panneau/fields/color` | `ColorField`, `getColorPalette()` | `'#1d4ed8'`, or a `value` of its `palette` |
36
36
  | `@panneau/fields/slug` | `SlugField`, `slugify()`, `sourceText()` | `string`, following a `source` until edited, checked with `onCheck` |
37
37
  | `@panneau/fields/tel` | `TelField`, `parsePhone()` | E.164, `'+15145550199'`; the text until the number is complete |
38
- | `@panneau/fields/country` | `CountryField`, `getCountryName()` | `'CA'`, ISO 3166-1 alpha-2 |
38
+ | `@panneau/fields/country` | `CountryField`, `getCountryName()` | `'CA'`, ISO 3166-1 alpha-2, or a list with `multiple` |
39
39
  | `@panneau/fields/region` | `RegionField`, `getRegions()` | `'QC'`, the region of its country; the text for other countries |
40
+ | `@panneau/fields/address` | `AddressField`, `formatAddress()` | `{ street, unit, city, region, postalCode, country, point }` |
41
+ | `@panneau/fields/link` | `LinkField`, `getLinkText()` | `{ type, url, page, file, label, newTab }` |
42
+ | `@panneau/fields/daterange` | `DateRangeField`, `formatDateRange()` | `{ start, end }`, days or date-times, either `null` when open |
43
+ | `@panneau/fields/money` | `MoneyField`, `formatMoney()` | `{ amount, currency }`, the amount in minor units (`1250`) |
40
44
  | `@panneau/fields/range` | `RangeField` (a slider) | `number`, `null` until moved |
41
- | `@panneau/fields/duration` | `DurationField`, `formatDuration()` | seconds, typed in hours, minutes and seconds |
45
+ | `@panneau/fields/duration` | `DurationField`, `formatDuration()` | a whole number of its `unit`, seconds by default |
42
46
  | `@panneau/fields/json` | `JsonField`, `parseJson()` | an object or an array; the text while it doesn't parse |
43
47
  | `@panneau/fields/tags` | `TagsField` | a list of strings, free or among suggestions |
44
48
  | `@panneau/fields/embed` | `EmbedField` | `{ url, title, thumbnailUrl, … }`, from the backend (below) |
@@ -139,8 +143,14 @@ import { createEmbedSource } from '@panneau/fields';
139
143
  <FieldsProvider embedSource={createEmbedSource(adapter)}>…</FieldsProvider>;
140
144
  ```
141
145
 
146
+ `providers` (the `providers` rule of a definition) lists the providers an embed may come from, `['YouTube', 'Vimeo']`: the field names them under its help, and refuses an embed of another provider as soon as its preview comes back ([decision 0058](../../docs/decisions/0058-multiple-countries-embed-providers-color-palettes.md)).
147
+
142
148
  A `tel` field shows the country of the number, its flag and calling code, in a menu at the start of its input, and formats the number as it is typed. Its value is in E.164 once the number is complete, and the text as typed until then, which the `tel` rule refuses. `country` (`settings.country`) is the country of a new number, the region of the user's locale without it. Formats come from `libphonenumber-js`, with its smallest metadata.
143
149
 
150
+ With `extension` (`settings.extension`), an input after the number takes the digits of an extension, kept with the number after `;ext=`: `+15145550199;ext=123`. An extension typed or pasted after the number (`ext. 123`, `x123`, `poste 123`) moves to that input when the field is left. To send a number to a service that has no extensions, such as SMS, take the `number` of `splitExtension(value)` ([decision 0057](../../docs/decisions/0057-phone-extensions.md)).
151
+
152
+ A `duration` field keeps a whole number of its `unit` (`settings.unit`: `seconds` by default, `minutes`, `hours` or `days`), typed in parts from `largestUnit` (hours by default, or `days`) down to `precision` (the unit by default). The largest part has no upper bound; hours stop at 23 below days. `formatDuration(value, { unit, precision, largestUnit })` writes it as lists show it, `2 d 4 h` ([decision 0056](../../docs/decisions/0056-duration-units.md)).
153
+
144
154
  A `country` field picks a country by its name in the user's locale, with its flag; `countries` limits the choices and `preferred` puts some first. A `region` field picks a state, a province or a territory of its `country` (a field's `from`, or `settings.country`): for Argentina, Australia, Brazil, Canada, China, India, Japan, Mexico and the United States, among their regions, named in English or French, and its value is the code without the country (`QC`); for other countries, it is a text ([decision 0047](../../docs/decisions/0047-countries-regions-and-phone-numbers.md)).
145
155
 
146
156
  ```tsx
@@ -149,6 +159,46 @@ A `country` field picks a country by its name in the user's locale, with its fla
149
159
  <TelField label="Phone" country="CA" value={phone} onChange={setPhone} />
150
160
  ```
151
161
 
162
+ With `multiple`, a `country` field holds several countries, in the order they were chosen: each one shows with its flag and a button that removes it, and the combo box adds another. A `color` field with a `palette` only offers its colors, in a select with their swatches: `value` is what it stores, `color` draws the swatch, and `label` names it ([decision 0058](../../docs/decisions/0058-multiple-countries-embed-providers-color-palettes.md)).
163
+
164
+ ```tsx
165
+ <CountryField multiple label="Countries" value={countries} onChange={setCountries} />
166
+ <ColorField
167
+ label="Background"
168
+ palette={[
169
+ { value: 'white', label: 'White', color: '#ffffff' },
170
+ { value: 'purple', label: 'Purple', color: '#6b21a8' },
171
+ ]}
172
+ value={background}
173
+ onChange={setBackground}
174
+ />
175
+ ```
176
+
177
+ An `address` field edits the parts of a postal address: the country first, which sets the labels (_Province_, _State_), the order (the postal code last in Canada and the United States, first elsewhere) and the regions of the others, then the street, the unit, the city, the region and the postal code, normalized for its country when it loses focus (`H2X 1Y4`). `country` is the country of a new address; with one country in `countries`, the field doesn't show it. With the address search of the `FieldsProvider`'s maps, a place found fills every part, when the source gives them (`createNominatimSource()` does); with `point`, a map places the address ([decision 0054](../../docs/decisions/0054-addresses.md)).
178
+
179
+ A `link` field picks the type of a link, then its URL (`https://…`), its page (searched in the resources of `pages` with the relation source), its email address (`mailto:…`), its phone number (`tel:+…`), its file (with the `media` entry of the fields context), or the text of a type of the site, with a label per locale and whether it opens in a new tab ([decision 0055](../../docs/decisions/0055-links.md)). In a form, the parts of both fields show the errors of their own paths (`address.postalCode`, `link.url`).
180
+
181
+ ```tsx
182
+ <AddressField label="Address" country="CA" preferred={['CA', 'US']} value={address} onChange={setAddress} />
183
+ <LinkField
184
+ label="Button"
185
+ types={[{ id: 'page' }, { id: 'url' }, { id: 'email' }]}
186
+ pages={['pages', 'events']}
187
+ newTab="external"
188
+ value={link}
189
+ onChange={setLink}
190
+ />
191
+ ```
192
+
193
+ A `daterange` field edits a start and an end in one control, with one calendar for both ([decision 0053](../../docs/decisions/0053-date-ranges-and-money.md)). Its bounds are days (`2026-11-04`, both inclusive), or date-times with `time`, shown in the zone of the value, then `timeZone`, then the browser's, and written in UTC. `allDay` adds an "All day" switch, whose ranges have days as bounds and `allDay: true`; `chooseTimeZone` adds a menu of zones, kept in the value as `timeZone`. A bound left empty is `null`, which the `daterange` rule refuses unless the field's `open` allows it.
194
+
195
+ A `money` field types an amount in the currency format of the locale, with the digits of its currency in ISO 4217, and keeps it in minor units, without floating point errors: `{ amount: 1250, currency: 'CAD' }` is 12.50 $. `currency` fixes the currency; `currencies` lists those a menu after the amount offers, every currency without either.
196
+
197
+ ```tsx
198
+ <DateRangeField label="Dates" time allDay timeZone="America/Toronto" value={dates} onChange={setDates} />
199
+ <MoneyField label="Price" currency="CAD" min={0} value={price} onChange={setPrice} />
200
+ ```
201
+
152
202
  A `location` field places a point on a Leaflet map, loaded when the field is first shown. The tiles are OpenStreetMap's by default. `maps` sets other tiles and an address search, a `GeocodingSource`: `createNominatimSource()` searches OpenStreetMap's Nominatim, whose [usage policy](https://operations.osmfoundation.org/policies/nominatim/) suits small volumes; a product with more uses its own service. Without a geocoding source, the field has no address search, and the latitude and longitude are typed or picked on the map.
153
203
 
154
204
  ```tsx
@@ -0,0 +1,44 @@
1
+ /* The search, the parts, then the map. */
2
+ .panneau-address-field-address {
3
+ display: flex;
4
+ flex-direction: column;
5
+ gap: var(--panneau-space-3);
6
+ }
7
+
8
+ /* The parts on a grid of six columns: the street and its unit, then the city, the region and the
9
+ postal code in the order of the country. */
10
+ .panneau-address-field-parts {
11
+ display: grid;
12
+ grid-template-columns: repeat(6, minmax(0, 1fr));
13
+ gap: var(--panneau-space-3);
14
+ }
15
+
16
+ .panneau-address-field-part {
17
+ grid-column: span 2;
18
+ min-width: 0;
19
+ }
20
+
21
+ .panneau-address-field-country {
22
+ grid-column: 1 / -1;
23
+ }
24
+
25
+ .panneau-address-field-street {
26
+ grid-column: span 4;
27
+ }
28
+
29
+ .panneau-address-field-map {
30
+ display: flex;
31
+ flex-direction: column;
32
+ gap: var(--panneau-space-2);
33
+ }
34
+
35
+ .panneau-address-field-remove {
36
+ align-self: flex-start;
37
+ }
38
+
39
+ @media (max-width: 40rem) {
40
+ .panneau-address-field-part,
41
+ .panneau-address-field-street {
42
+ grid-column: 1 / -1;
43
+ }
44
+ }
@@ -0,0 +1,37 @@
1
+ import type { AddressPart, AddressValue } from '@panneau/protocol';
2
+ import type { GeocodingSource, MapTiles } from '../location/types.js';
3
+ import type { FieldEntryProps, FieldProps } from '../shared/types.js';
4
+ export interface AddressFieldProps extends FieldProps<AddressValue> {
5
+ /** Dot path of the value, the prefix of the paths of its parts. Defaults to `name`. */
6
+ path?: string;
7
+ /** The country of a new address (`CA`), set as soon as a part is typed. */
8
+ country?: string | null;
9
+ /** The countries the field allows. With one, the field doesn't show the country. */
10
+ countries?: readonly string[];
11
+ /** Countries shown first: `['CA', 'US']`. */
12
+ preferred?: readonly string[];
13
+ /** The parts a filled address must have, marked as required. */
14
+ requiredParts?: readonly AddressPart[];
15
+ /** Adds a map under the parts, and the point of the address to the value. */
16
+ point?: boolean;
17
+ /** The address search. Defaults to that of the `FieldsProvider`; without one, there is none. */
18
+ geocoding?: GeocodingSource | null;
19
+ /** The tiles of the map. Defaults to those of the `FieldsProvider`, or OpenStreetMap's. */
20
+ tiles?: MapTiles;
21
+ /** Zoom of the map on a point. Defaults to 16. */
22
+ zoom?: number;
23
+ }
24
+ /**
25
+ * A postal address (decision 0054): the country first, which sets the labels, the order and the
26
+ * regions of the other parts, then the street, the unit, the city, the region and the postal
27
+ * code, which is normalized for the country when it loses focus. With an address search, a place
28
+ * found fills every part; with `point`, a map places the address. Each part shows the errors of
29
+ * its own path (`address.postalCode`) in a form.
30
+ */
31
+ export declare function AddressField({ value, onChange, onBlur, path, name, country: countryProp, countries, preferred, requiredParts, point: withPoint, geocoding: geocodingProp, tiles: tilesProp, zoom, label, description, errors, disabled, readOnly, required, className, }: AddressFieldProps): import("react").JSX.Element;
32
+ /**
33
+ * The `address` type: settings `country`, `countries`, `preferred`, `required` (the parts a
34
+ * filled address must have) and `point`, over the maps of the `FieldsProvider`.
35
+ */
36
+ export declare function AddressFieldEntry(props: FieldEntryProps): import("react").JSX.Element;
37
+ //# sourceMappingURL=AddressField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AddressField.d.ts","sourceRoot":"","sources":["../../src/address/AddressField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAS,MAAM,mBAAmB,CAAC;AAY1E,OAAO,KAAK,EAAmB,eAAe,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAOpF,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKnE,MAAM,WAAW,iBAAkB,SAAQ,UAAU,CAAC,YAAY,CAAC;IAC/D,uFAAuF;IACvF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,oFAAoF;IACpF,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,6CAA6C;IAC7C,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,gEAAgE;IAChE,aAAa,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IACvC,6EAA6E;IAC7E,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gGAAgG;IAChG,SAAS,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IACnC,2FAA2F;IAC3F,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAcD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,OAAO,EAAE,WAAW,EACpB,SAAS,EACT,SAAS,EACT,aAA8C,EAC9C,KAAK,EAAE,SAAiB,EACxB,SAAS,EAAE,aAAa,EACxB,KAAK,EAAE,SAAS,EAChB,IAAS,EACT,KAAK,EACL,WAAW,EACX,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,GACZ,EAAE,iBAAiB,+BAuNnB;AAUD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,eAAe,+BAoBvD"}
@@ -0,0 +1,411 @@
1
+ import { useFieldsContext } from "../shared/context.js";
2
+ import { cx } from "../shared/cx.js";
3
+ import { getFieldProps, getSetting, isBoolean, isString } from "../shared/entry.js";
4
+ import { messages } from "../shared/messages.js";
5
+ import { CountryField } from "../country/CountryField.js";
6
+ import { LocationMap } from "../location/LocationMap.js";
7
+ import { useAddressSearch } from "../location/search.js";
8
+ import { OPEN_STREET_MAP_TILES } from "../location/LocationField.js";
9
+ import { TextField } from "../text/TextField.js";
10
+ import { RegionField } from "../region/RegionField.js";
11
+ import { BoundPart } from "../shared/part.js";
12
+ import AddressField_module_default from "./AddressField.module.js";
13
+ import { cleanAddress, endsWithRegion, isAddress } from "./address.js";
14
+ import { c } from "react/compiler-runtime";
15
+ import { DEFAULT_ADDRESS_REQUIRED_PARTS, getAddressRequiredParts, normalizePostalCode } from "@panneau/protocol/runtime";
16
+ import { X } from "lucide-react";
17
+ import { useRef, useState } from "react";
18
+ import { ComboBox, Fieldset, IconButton, usePanneauIntl } from "@panneau/ui";
19
+ import { jsx, jsxs } from "react/jsx-runtime";
20
+ //#region src/address/AddressField.tsx
21
+ var WORLD = {
22
+ lat: 20,
23
+ lng: 0
24
+ };
25
+ /** The type of the field of each part, for the binding of the fields context. */
26
+ var PART_TYPES = {
27
+ country: "country",
28
+ street: "text",
29
+ unit: "text",
30
+ city: "text",
31
+ region: "region",
32
+ postalCode: "text"
33
+ };
34
+ /**
35
+ * A postal address (decision 0054): the country first, which sets the labels, the order and the
36
+ * regions of the other parts, then the street, the unit, the city, the region and the postal
37
+ * code, which is normalized for the country when it loses focus. With an address search, a place
38
+ * found fills every part; with `point`, a map places the address. Each part shows the errors of
39
+ * its own path (`address.postalCode`) in a form.
40
+ */
41
+ function AddressField(t0) {
42
+ const $ = c(34);
43
+ const { value, onChange, onBlur, path, name, country: countryProp, countries, preferred, requiredParts: t1, point: t2, geocoding: geocodingProp, tiles: tilesProp, zoom: t3, label, description, errors, disabled, readOnly, required, className } = t0;
44
+ const requiredParts = t1 === void 0 ? DEFAULT_ADDRESS_REQUIRED_PARTS : t1;
45
+ const withPoint = t2 === void 0 ? false : t2;
46
+ const zoom = t3 === void 0 ? 16 : t3;
47
+ const intl = usePanneauIntl();
48
+ const { maps } = useFieldsContext();
49
+ const geocoding = geocodingProp === void 0 ? maps?.geocoding ?? null : geocodingProp;
50
+ const tiles = tilesProp ?? maps?.tiles ?? OPEN_STREET_MAP_TILES;
51
+ const editable = disabled !== true && readOnly !== true;
52
+ const base = path ?? name ?? "";
53
+ const onlyCountry = countries?.length === 1 ? countries[0] : void 0;
54
+ const defaultCountry = onlyCountry ?? countryProp ?? null;
55
+ const address = value ?? {};
56
+ const country = address.country ?? defaultCountry;
57
+ const filled = value !== null && value !== void 0;
58
+ let t4;
59
+ if ($[0] !== defaultCountry || $[1] !== onChange) {
60
+ t4 = (next) => onChange?.(cleanAddress(next, defaultCountry));
61
+ $[0] = defaultCountry;
62
+ $[1] = onChange;
63
+ $[2] = t4;
64
+ } else t4 = $[2];
65
+ const change = t4;
66
+ const setPart = (part, text) => change({
67
+ ...address,
68
+ [part]: text ?? void 0
69
+ });
70
+ const setCountry = (next_0) => change({
71
+ ...address,
72
+ country: next_0 ?? void 0,
73
+ region: next_0 === country ? address.region : void 0,
74
+ postalCode: address.postalCode !== void 0 ? normalizePostalCode(address.postalCode, next_0) : void 0
75
+ });
76
+ const [query, setQuery] = useState("");
77
+ const [chosen, setChosen] = useState(null);
78
+ const search = useAddressSearch(editable && query !== chosen?.label ? geocoding : null, query, intl.locale);
79
+ const unitRef = useRef(null);
80
+ let t5;
81
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
82
+ t5 = () => window.requestAnimationFrame(() => unitRef.current?.querySelector("input")?.focus());
83
+ $[3] = t5;
84
+ } else t5 = $[3];
85
+ const focusUnit = t5;
86
+ const places = (chosen !== null && query === chosen.label ? [chosen] : search.results).filter(_temp);
87
+ const labels = {
88
+ country: intl.formatMessage(messages.addressCountry),
89
+ street: intl.formatMessage(messages.addressStreet),
90
+ unit: intl.formatMessage(messages.addressUnit),
91
+ city: intl.formatMessage(messages.addressCity),
92
+ region: intl.formatMessage(country === "CA" ? messages.addressProvince : country === "US" ? messages.addressState : messages.addressRegion),
93
+ postalCode: intl.formatMessage(country === "US" ? messages.addressZipCode : messages.addressPostalCode)
94
+ };
95
+ const renderPart = (part_0, input) => {
96
+ const field = {
97
+ name: part_0,
98
+ type: PART_TYPES[part_0],
99
+ label: labels[part_0]
100
+ };
101
+ return /* @__PURE__ */ jsx("div", {
102
+ className: cx(AddressField_module_default.part, AddressField_module_default[part_0]),
103
+ ...part_0 === "unit" ? { ref: unitRef } : {},
104
+ children: /* @__PURE__ */ jsx(BoundPart, {
105
+ field,
106
+ path: base !== "" ? `${base}.${part_0}` : part_0,
107
+ ...onBlur !== void 0 ? { onBlur } : {},
108
+ render: input
109
+ })
110
+ }, part_0);
111
+ };
112
+ const shared = (part_1, bound) => ({
113
+ label: labels[part_1],
114
+ errors: bound.errors ?? [],
115
+ ...disabled !== void 0 ? { disabled } : {},
116
+ ...readOnly !== void 0 ? { readOnly } : {},
117
+ required: requiredParts.includes(part_1) && (required === true || filled)
118
+ });
119
+ const textPart = (part_2, autoComplete) => renderPart(part_2, (bound_0) => /* @__PURE__ */ jsx(TextField, {
120
+ ...shared(part_2, bound_0),
121
+ autoComplete,
122
+ value: address[part_2] ?? null,
123
+ onChange: (text_0) => setPart(part_2, text_0),
124
+ ...bound_0.onBlur !== void 0 ? { onBlur: bound_0.onBlur } : {}
125
+ }));
126
+ const region = renderPart("region", (bound_1) => /* @__PURE__ */ jsx(RegionField, {
127
+ ...shared("region", bound_1),
128
+ country,
129
+ value: address.region ?? null,
130
+ onChange: (text_1) => setPart("region", text_1),
131
+ ...bound_1.onBlur !== void 0 ? { onBlur: bound_1.onBlur } : {}
132
+ }));
133
+ const postalCode = renderPart("postalCode", (bound_2) => /* @__PURE__ */ jsx(TextField, {
134
+ ...shared("postalCode", bound_2),
135
+ autoComplete: "postal-code",
136
+ value: address.postalCode ?? null,
137
+ onChange: (text_2) => setPart("postalCode", text_2),
138
+ onBlur: () => {
139
+ if (address.postalCode !== void 0) {
140
+ const normalized = normalizePostalCode(address.postalCode, country);
141
+ if (normalized !== address.postalCode) setPart("postalCode", normalized);
142
+ }
143
+ bound_2.onBlur?.();
144
+ }
145
+ }));
146
+ const city = textPart("city", "address-level2");
147
+ const locality = endsWithRegion(country) ? [
148
+ city,
149
+ region,
150
+ postalCode
151
+ ] : [
152
+ postalCode,
153
+ city,
154
+ region
155
+ ];
156
+ const point = address.point ?? null;
157
+ const T0 = Fieldset;
158
+ const t6 = AddressField_module_default;
159
+ const t7 = editable && geocoding !== null ? /* @__PURE__ */ jsx(ComboBox, {
160
+ "aria-label": intl.formatMessage(messages.searchAddress),
161
+ placeholder: intl.formatMessage(messages.searchAddress),
162
+ onInputChange: setQuery,
163
+ items: places.map(_temp2),
164
+ isLoading: search.loading,
165
+ menuTrigger: "input",
166
+ emptyMessage: query.trim().length < 3 ? intl.formatMessage(messages.searchAddressHint, { count: 3 }) : intl.formatMessage(messages.noPlaces),
167
+ value: chosen !== null && query === chosen.label ? "0" : null,
168
+ onChange: (id) => {
169
+ const result_1 = id !== null ? places[Number(id)] : void 0;
170
+ if (result_1 !== void 0) {
171
+ setChosen(result_1);
172
+ change({
173
+ ...result_1.address,
174
+ ...withPoint ? { point: roundPoint(result_1) } : {}
175
+ });
176
+ focusUnit();
177
+ }
178
+ }
179
+ }) : null;
180
+ const t8 = AddressField_module_default;
181
+ const t9 = onlyCountry === void 0 ? renderPart("country", (bound_3) => /* @__PURE__ */ jsx(CountryField, {
182
+ ...shared("country", bound_3),
183
+ ...countries !== void 0 ? { countries } : {},
184
+ ...preferred !== void 0 ? { preferred } : {},
185
+ value: country,
186
+ onChange: setCountry,
187
+ ...bound_3.onBlur !== void 0 ? { onBlur: bound_3.onBlur } : {}
188
+ })) : null;
189
+ const t10 = textPart("street", "address-line1");
190
+ const t11 = textPart("unit", "address-line2");
191
+ let t12;
192
+ if ($[4] !== locality || $[5] !== t10 || $[6] !== t11 || $[7] !== t8.parts || $[8] !== t9) {
193
+ t12 = /* @__PURE__ */ jsxs("div", {
194
+ className: t8.parts,
195
+ children: [
196
+ t9,
197
+ t10,
198
+ t11,
199
+ locality
200
+ ]
201
+ });
202
+ $[4] = locality;
203
+ $[5] = t10;
204
+ $[6] = t11;
205
+ $[7] = t8.parts;
206
+ $[8] = t9;
207
+ $[9] = t12;
208
+ } else t12 = $[9];
209
+ let t13;
210
+ if ($[10] !== address || $[11] !== change || $[12] !== editable || $[13] !== intl || $[14] !== label || $[15] !== point || $[16] !== tiles || $[17] !== withPoint || $[18] !== zoom) {
211
+ t13 = withPoint ? /* @__PURE__ */ jsxs("div", {
212
+ className: AddressField_module_default.map,
213
+ children: [/* @__PURE__ */ jsx(LocationMap, {
214
+ point,
215
+ onChange: (next_1) => change({
216
+ ...address,
217
+ point: roundPoint(next_1)
218
+ }),
219
+ tiles,
220
+ center: point ?? WORLD,
221
+ zoom,
222
+ readOnly: !editable,
223
+ label: intl.formatMessage(messages.map, { label: typeof label === "string" ? label : "" })
224
+ }), editable && point !== null ? /* @__PURE__ */ jsx(IconButton, {
225
+ icon: X,
226
+ label: intl.formatMessage(messages.removePoint),
227
+ className: AddressField_module_default.remove,
228
+ onPress: () => change({
229
+ ...address,
230
+ point: void 0
231
+ })
232
+ }) : null]
233
+ }) : null;
234
+ $[10] = address;
235
+ $[11] = change;
236
+ $[12] = editable;
237
+ $[13] = intl;
238
+ $[14] = label;
239
+ $[15] = point;
240
+ $[16] = tiles;
241
+ $[17] = withPoint;
242
+ $[18] = zoom;
243
+ $[19] = t13;
244
+ } else t13 = $[19];
245
+ let t14;
246
+ if ($[20] !== t12 || $[21] !== t13 || $[22] !== t6.address || $[23] !== t7) {
247
+ t14 = /* @__PURE__ */ jsxs("div", {
248
+ className: t6.address,
249
+ children: [
250
+ t7,
251
+ t12,
252
+ t13
253
+ ]
254
+ });
255
+ $[20] = t12;
256
+ $[21] = t13;
257
+ $[22] = t6.address;
258
+ $[23] = t7;
259
+ $[24] = t14;
260
+ } else t14 = $[24];
261
+ let t15;
262
+ if ($[25] !== T0 || $[26] !== className || $[27] !== description || $[28] !== disabled || $[29] !== errors || $[30] !== label || $[31] !== required || $[32] !== t14) {
263
+ t15 = /* @__PURE__ */ jsx(T0, {
264
+ legend: label,
265
+ description,
266
+ errors,
267
+ isRequired: required,
268
+ isDisabled: disabled,
269
+ className,
270
+ children: t14
271
+ });
272
+ $[25] = T0;
273
+ $[26] = className;
274
+ $[27] = description;
275
+ $[28] = disabled;
276
+ $[29] = errors;
277
+ $[30] = label;
278
+ $[31] = required;
279
+ $[32] = t14;
280
+ $[33] = t15;
281
+ } else t15 = $[33];
282
+ return t15;
283
+ }
284
+ /** A point to the sixth decimal, about ten centimetres. */
285
+ function _temp2(result_0, index) {
286
+ return {
287
+ id: String(index),
288
+ label: result_0.label
289
+ };
290
+ }
291
+ function _temp(result) {
292
+ return result.address !== void 0;
293
+ }
294
+ function roundPoint(point) {
295
+ return {
296
+ lat: Number(point.lat.toFixed(6)),
297
+ lng: Number(point.lng.toFixed(6))
298
+ };
299
+ }
300
+ var isCodes = (value) => Array.isArray(value) && value.every(isString);
301
+ /**
302
+ * The `address` type: settings `country`, `countries`, `preferred`, `required` (the parts a
303
+ * filled address must have) and `point`, over the maps of the `FieldsProvider`.
304
+ */
305
+ function AddressFieldEntry(props) {
306
+ const $ = c(32);
307
+ const { field } = props;
308
+ let t0;
309
+ if ($[0] !== field) {
310
+ t0 = getSetting(field, "country", isString);
311
+ $[0] = field;
312
+ $[1] = t0;
313
+ } else t0 = $[1];
314
+ const country = t0;
315
+ let t1;
316
+ if ($[2] !== field) {
317
+ t1 = getSetting(field, "countries", isCodes);
318
+ $[2] = field;
319
+ $[3] = t1;
320
+ } else t1 = $[3];
321
+ const countries = t1;
322
+ let t2;
323
+ if ($[4] !== field) {
324
+ t2 = getSetting(field, "preferred", isCodes);
325
+ $[4] = field;
326
+ $[5] = t2;
327
+ } else t2 = $[5];
328
+ const preferred = t2;
329
+ let t3;
330
+ if ($[6] !== field) {
331
+ t3 = getSetting(field, "point", isBoolean);
332
+ $[6] = field;
333
+ $[7] = t3;
334
+ } else t3 = $[7];
335
+ const point = t3;
336
+ let t4;
337
+ if ($[8] !== props) {
338
+ t4 = getFieldProps(props);
339
+ $[8] = props;
340
+ $[9] = t4;
341
+ } else t4 = $[9];
342
+ let fieldProps;
343
+ if ($[10] !== t4) {
344
+ const { placeholder: _placeholder, ...t5 } = t4;
345
+ fieldProps = t5;
346
+ $[10] = t4;
347
+ $[11] = fieldProps;
348
+ } else fieldProps = $[11];
349
+ const t5 = props.path;
350
+ const t6 = isAddress(props.value) ? props.value : null;
351
+ const t7 = props.onChange;
352
+ let t8;
353
+ if ($[12] !== field) {
354
+ t8 = getAddressRequiredParts(field);
355
+ $[12] = field;
356
+ $[13] = t8;
357
+ } else t8 = $[13];
358
+ let t9;
359
+ if ($[14] !== country) {
360
+ t9 = country !== void 0 ? { country } : {};
361
+ $[14] = country;
362
+ $[15] = t9;
363
+ } else t9 = $[15];
364
+ let t10;
365
+ if ($[16] !== countries) {
366
+ t10 = countries !== void 0 ? { countries } : {};
367
+ $[16] = countries;
368
+ $[17] = t10;
369
+ } else t10 = $[17];
370
+ let t11;
371
+ if ($[18] !== preferred) {
372
+ t11 = preferred !== void 0 ? { preferred } : {};
373
+ $[18] = preferred;
374
+ $[19] = t11;
375
+ } else t11 = $[19];
376
+ let t12;
377
+ if ($[20] !== point) {
378
+ t12 = point !== void 0 ? { point } : {};
379
+ $[20] = point;
380
+ $[21] = t12;
381
+ } else t12 = $[21];
382
+ let t13;
383
+ if ($[22] !== fieldProps || $[23] !== props.onChange || $[24] !== props.path || $[25] !== t10 || $[26] !== t11 || $[27] !== t12 || $[28] !== t6 || $[29] !== t8 || $[30] !== t9) {
384
+ t13 = /* @__PURE__ */ jsx(AddressField, {
385
+ ...fieldProps,
386
+ path: t5,
387
+ value: t6,
388
+ onChange: t7,
389
+ requiredParts: t8,
390
+ ...t9,
391
+ ...t10,
392
+ ...t11,
393
+ ...t12
394
+ });
395
+ $[22] = fieldProps;
396
+ $[23] = props.onChange;
397
+ $[24] = props.path;
398
+ $[25] = t10;
399
+ $[26] = t11;
400
+ $[27] = t12;
401
+ $[28] = t6;
402
+ $[29] = t8;
403
+ $[30] = t9;
404
+ $[31] = t13;
405
+ } else t13 = $[31];
406
+ return t13;
407
+ }
408
+ //#endregion
409
+ export { AddressField, AddressFieldEntry };
410
+
411
+ //# sourceMappingURL=AddressField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AddressField.js","names":["X","ReactNode","useRef","useState","AddressPart","AddressValue","Field","DEFAULT_ADDRESS_REQUIRED_PARTS","getAddressRequiredParts","normalizePostalCode","ComboBox","Fieldset","IconButton","usePanneauIntl","CountryField","OPEN_STREET_MAP_TILES","LocationMap","Point","SEARCH_MIN_LENGTH","useAddressSearch","GeocodingResult","GeocodingSource","MapTiles","RegionField","useFieldsContext","cx","getFieldProps","getSetting","isBoolean","isString","messages","BoundPart","BoundPartProps","FieldEntryProps","FieldProps","TextField","styles","cleanAddress","endsWithRegion","isAddress","AddressFieldProps","path","country","countries","preferred","requiredParts","point","geocoding","tiles","zoom","WORLD","lat","lng","PART_TYPES","Readonly","Record","street","unit","city","region","postalCode","AddressField","t0","$","_c","value","onChange","onBlur","name","countryProp","t1","t2","geocodingProp","tilesProp","t3","label","description","errors","disabled","readOnly","required","className","undefined","withPoint","intl","maps","editable","base","onlyCountry","length","defaultCountry","address","filled","t4","next","change","setPart","part","text","setCountry","next_0","query","setQuery","chosen","setChosen","search","locale","unitRef","t5","Symbol","for","window","requestAnimationFrame","current","querySelector","focus","focusUnit","places","results","filter","_temp","labels","formatMessage","addressCountry","addressStreet","addressUnit","addressCity","addressProvince","addressState","addressRegion","addressZipCode","addressPostalCode","renderPart","part_0","input","field","type","ref","shared","part_1","bound","includes","textPart","part_2","autoComplete","bound_0","text_0","bound_1","text_1","bound_2","text_2","normalized","locality","T0","t7","searchAddress","map","_temp2","loading","trim","searchAddressHint","count","noPlaces","id","result_1","Number","result","roundPoint","t9","bound_3","t10","t11","t12","t8","parts","t13","next_1","removePoint","remove","t14","t6","t15","result_0","index","String","toFixed","isCodes","Array","isArray","every","AddressFieldEntry","props","fieldProps","placeholder","_placeholder","_c","styles"],"sources":["../../src/address/AddressField.tsx"],"sourcesContent":["import { X } from 'lucide-react';\nimport { type ReactNode, useRef, useState } from 'react';\n\nimport type { AddressPart, AddressValue, Field } from '@panneau/protocol';\nimport {\n DEFAULT_ADDRESS_REQUIRED_PARTS,\n getAddressRequiredParts,\n normalizePostalCode,\n} from '@panneau/protocol/runtime';\nimport { ComboBox, Fieldset, IconButton, usePanneauIntl } from '@panneau/ui';\n\nimport { CountryField } from '../country/CountryField';\nimport { OPEN_STREET_MAP_TILES } from '../location/LocationField';\nimport { LocationMap, type Point } from '../location/LocationMap';\nimport { SEARCH_MIN_LENGTH, useAddressSearch } from '../location/search';\nimport type { GeocodingResult, GeocodingSource, MapTiles } from '../location/types';\nimport { RegionField } from '../region/RegionField';\nimport { useFieldsContext } from '../shared/context';\nimport { cx } from '../shared/cx';\nimport { getFieldProps, getSetting, isBoolean, isString } from '../shared/entry';\nimport { messages } from '../shared/messages';\nimport { BoundPart, type BoundPartProps } from '../shared/part';\nimport type { FieldEntryProps, FieldProps } from '../shared/types';\nimport { TextField } from '../text/TextField';\nimport styles from './AddressField.module.css';\nimport { cleanAddress, endsWithRegion, isAddress } from './address';\n\nexport interface AddressFieldProps extends FieldProps<AddressValue> {\n /** Dot path of the value, the prefix of the paths of its parts. Defaults to `name`. */\n path?: string;\n /** The country of a new address (`CA`), set as soon as a part is typed. */\n country?: string | null;\n /** The countries the field allows. With one, the field doesn't show the country. */\n countries?: readonly string[];\n /** Countries shown first: `['CA', 'US']`. */\n preferred?: readonly string[];\n /** The parts a filled address must have, marked as required. */\n requiredParts?: readonly AddressPart[];\n /** Adds a map under the parts, and the point of the address to the value. */\n point?: boolean;\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 /** Zoom of the map on a point. Defaults to 16. */\n zoom?: number;\n}\n\nconst WORLD: Point = { lat: 20, lng: 0 };\n\n/** The type of the field of each part, for the binding of the fields context. */\nconst PART_TYPES: Readonly<Record<AddressPart, string>> = {\n country: 'country',\n street: 'text',\n unit: 'text',\n city: 'text',\n region: 'region',\n postalCode: 'text',\n};\n\n/**\n * A postal address (decision 0054): the country first, which sets the labels, the order and the\n * regions of the other parts, then the street, the unit, the city, the region and the postal\n * code, which is normalized for the country when it loses focus. With an address search, a place\n * found fills every part; with `point`, a map places the address. Each part shows the errors of\n * its own path (`address.postalCode`) in a form.\n */\nexport function AddressField({\n value,\n onChange,\n onBlur,\n path,\n name,\n country: countryProp,\n countries,\n preferred,\n requiredParts = DEFAULT_ADDRESS_REQUIRED_PARTS,\n point: withPoint = false,\n geocoding: geocodingProp,\n tiles: tilesProp,\n zoom = 16,\n label,\n description,\n errors,\n disabled,\n readOnly,\n required,\n className,\n}: AddressFieldProps) {\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 base = path ?? name ?? '';\n const onlyCountry = countries?.length === 1 ? countries[0] : undefined;\n const defaultCountry = onlyCountry ?? countryProp ?? null;\n const address: AddressValue = value ?? {};\n const country = address.country ?? defaultCountry;\n const filled = value !== null && value !== undefined;\n\n const change = (next: Partial<Record<keyof AddressValue, unknown>>) =>\n onChange?.(cleanAddress(next, defaultCountry));\n const setPart = (part: AddressPart, text: string | null) =>\n change({ ...address, [part]: text ?? undefined });\n // A region belongs to its country, and a postal code is written as in its country\n const setCountry = (next: string | null) =>\n change({\n ...address,\n country: next ?? undefined,\n region: next === country ? address.region : undefined,\n postalCode:\n address.postalCode !== undefined\n ? normalizePostalCode(address.postalCode, next)\n : undefined,\n });\n\n const [query, setQuery] = useState('');\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 // A place chosen moves focus to the unit, the part it doesn't fill, which closes the results\n const unitRef = useRef<HTMLDivElement>(null);\n const focusUnit = () =>\n window.requestAnimationFrame(() =>\n unitRef.current?.querySelector<HTMLInputElement>('input')?.focus(),\n );\n const places = (chosen !== null && query === chosen.label ? [chosen] : search.results).filter(\n (result) => result.address !== undefined,\n );\n\n const labels: Record<AddressPart, string> = {\n country: intl.formatMessage(messages.addressCountry),\n street: intl.formatMessage(messages.addressStreet),\n unit: intl.formatMessage(messages.addressUnit),\n city: intl.formatMessage(messages.addressCity),\n region: intl.formatMessage(\n country === 'CA'\n ? messages.addressProvince\n : country === 'US'\n ? messages.addressState\n : messages.addressRegion,\n ),\n postalCode: intl.formatMessage(\n country === 'US' ? messages.addressZipCode : messages.addressPostalCode,\n ),\n };\n\n const renderPart = (part: AddressPart, input: (bound: BoundPartProps) => ReactNode) => {\n const field: Field = { name: part, type: PART_TYPES[part], label: labels[part] };\n return (\n <div\n key={part}\n className={cx(styles.part, styles[part])}\n {...(part === 'unit' ? { ref: unitRef } : {})}\n >\n <BoundPart\n field={field}\n path={base !== '' ? `${base}.${part}` : part}\n {...(onBlur !== undefined ? { onBlur } : {})}\n render={input}\n />\n </div>\n );\n };\n const shared = (part: AddressPart, bound: BoundPartProps) => ({\n label: labels[part],\n errors: bound.errors ?? [],\n ...(disabled !== undefined ? { disabled } : {}),\n ...(readOnly !== undefined ? { readOnly } : {}),\n required: requiredParts.includes(part) && (required === true || filled),\n });\n const textPart = (part: 'street' | 'unit' | 'city', autoComplete: string) =>\n renderPart(part, (bound) => (\n <TextField\n {...shared(part, bound)}\n autoComplete={autoComplete}\n value={address[part] ?? null}\n onChange={(text) => setPart(part, text)}\n {...(bound.onBlur !== undefined ? { onBlur: bound.onBlur } : {})}\n />\n ));\n\n const region = renderPart('region', (bound) => (\n <RegionField\n {...shared('region', bound)}\n country={country}\n value={address.region ?? null}\n onChange={(text) => setPart('region', text)}\n {...(bound.onBlur !== undefined ? { onBlur: bound.onBlur } : {})}\n />\n ));\n const postalCode = renderPart('postalCode', (bound) => (\n <TextField\n {...shared('postalCode', bound)}\n autoComplete=\"postal-code\"\n value={address.postalCode ?? null}\n onChange={(text) => setPart('postalCode', text)}\n onBlur={() => {\n if (address.postalCode !== undefined) {\n const normalized = normalizePostalCode(address.postalCode, country);\n if (normalized !== address.postalCode) {\n setPart('postalCode', normalized);\n }\n }\n bound.onBlur?.();\n }}\n />\n ));\n const city = textPart('city', 'address-level2');\n const locality = endsWithRegion(country)\n ? [city, region, postalCode]\n : [postalCode, city, region];\n\n const point = address.point ?? 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.address}>\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 change({\n ...result.address,\n ...(withPoint ? { point: roundPoint(result) } : {}),\n });\n focusUnit();\n }\n }}\n />\n ) : null}\n <div className={styles.parts}>\n {onlyCountry === undefined\n ? renderPart('country', (bound) => (\n <CountryField\n {...shared('country', bound)}\n {...(countries !== undefined ? { countries } : {})}\n {...(preferred !== undefined ? { preferred } : {})}\n value={country}\n onChange={setCountry}\n {...(bound.onBlur !== undefined ? { onBlur: bound.onBlur } : {})}\n />\n ))\n : null}\n {textPart('street', 'address-line1')}\n {textPart('unit', 'address-line2')}\n {locality}\n </div>\n {withPoint ? (\n <div className={styles.map}>\n <LocationMap\n point={point}\n onChange={(next) => change({ ...address, point: roundPoint(next) })}\n tiles={tiles}\n center={point ?? WORLD}\n zoom={zoom}\n readOnly={!editable}\n label={intl.formatMessage(messages.map, {\n label: typeof label === 'string' ? label : '',\n })}\n />\n {editable && point !== null ? (\n <IconButton\n icon={X}\n label={intl.formatMessage(messages.removePoint)}\n className={styles.remove}\n onPress={() => change({ ...address, point: undefined })}\n />\n ) : null}\n </div>\n ) : null}\n </div>\n </Fieldset>\n );\n}\n\n/** A point to the sixth decimal, about ten centimetres. */\nfunction roundPoint(point: Point): Point {\n return { lat: Number(point.lat.toFixed(6)), lng: Number(point.lng.toFixed(6)) };\n}\n\nconst isCodes = (value: unknown): value is string[] =>\n Array.isArray(value) && value.every(isString);\n\n/**\n * The `address` type: settings `country`, `countries`, `preferred`, `required` (the parts a\n * filled address must have) and `point`, over the maps of the `FieldsProvider`.\n */\nexport function AddressFieldEntry(props: FieldEntryProps) {\n const { field } = props;\n const country = getSetting(field, 'country', isString);\n const countries = getSetting(field, 'countries', isCodes);\n const preferred = getSetting(field, 'preferred', isCodes);\n const point = getSetting(field, 'point', isBoolean);\n const { placeholder: _placeholder, ...fieldProps } = getFieldProps(props);\n return (\n <AddressField\n {...fieldProps}\n path={props.path}\n value={isAddress(props.value) ? props.value : null}\n onChange={props.onChange}\n requiredParts={getAddressRequiredParts(field)}\n {...(country !== undefined ? { country } : {})}\n {...(countries !== undefined ? { countries } : {})}\n {...(preferred !== undefined ? { preferred } : {})}\n {...(point !== undefined ? { point } : {})}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgDA,IAAMkD,QAAe;CAAEC,KAAK;CAAIC,KAAK;AAAE;;AAGvC,IAAMC,aAAoD;CACtDX,SAAS;CACTc,QAAQ;CACRC,MAAM;CACNC,MAAM;CACNC,QAAQ;CACRC,YAAY;AAChB;;;;;;;;AASA,SAAOC,aAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAsB,MAAA,EAAAC,OAAAC,UAAAC,QAAA1B,MAAA2B,MAAA1B,SAAA2B,aAAA1B,WAAAC,WAAAC,eAAAyB,IAAAxB,OAAAyB,IAAAxB,WAAAyB,eAAAxB,OAAAyB,WAAAxB,MAAAyB,IAAAC,OAAAC,aAAAC,QAAAC,UAAAC,UAAAC,UAAAC,cAAAnB;CASzB,MAAAjB,gBAAAyB,OAAAY,KAAAA,I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