@panneau/fields 5.0.0-alpha.12 → 5.0.0-alpha.14

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 (56) hide show
  1. package/README.md +13 -1
  2. package/dist/country/CountryField.d.ts +17 -0
  3. package/dist/country/CountryField.d.ts.map +1 -0
  4. package/dist/country/CountryField.js +151 -0
  5. package/dist/country/CountryField.js.map +1 -0
  6. package/dist/country/codes.d.ts +6 -0
  7. package/dist/country/codes.d.ts.map +1 -0
  8. package/dist/country/codes.js +261 -0
  9. package/dist/country/codes.js.map +1 -0
  10. package/dist/country/countries.d.ts +32 -0
  11. package/dist/country/countries.d.ts.map +1 -0
  12. package/dist/country/countries.js +60 -0
  13. package/dist/country/countries.js.map +1 -0
  14. package/dist/country/index.d.ts +3 -0
  15. package/dist/country/index.d.ts.map +1 -0
  16. package/dist/country/index.js +4 -0
  17. package/dist/region/RegionField.d.ts +22 -0
  18. package/dist/region/RegionField.d.ts.map +1 -0
  19. package/dist/region/RegionField.js +136 -0
  20. package/dist/region/RegionField.js.map +1 -0
  21. package/dist/region/data.d.ts +5 -0
  22. package/dist/region/data.d.ts.map +1 -0
  23. package/dist/region/data.js +513 -0
  24. package/dist/region/data.js.map +1 -0
  25. package/dist/region/index.d.ts +3 -0
  26. package/dist/region/index.d.ts.map +1 -0
  27. package/dist/region/index.js +3 -0
  28. package/dist/region/regions.d.ts +15 -0
  29. package/dist/region/regions.d.ts.map +1 -0
  30. package/dist/region/regions.js +29 -0
  31. package/dist/region/regions.js.map +1 -0
  32. package/dist/shared/CodeComboBox.d.ts +20 -0
  33. package/dist/shared/CodeComboBox.d.ts.map +1 -0
  34. package/dist/shared/CodeComboBox.js +238 -0
  35. package/dist/shared/CodeComboBox.js.map +1 -0
  36. package/dist/shared/builtIn.d.ts.map +1 -1
  37. package/dist/shared/builtIn.js +5 -1
  38. package/dist/shared/builtIn.js.map +1 -1
  39. package/dist/shared/entry.d.ts.map +1 -1
  40. package/dist/shared/entry.js +1 -1
  41. package/dist/shared/entry.js.map +1 -1
  42. package/dist/shared/flow.d.ts.map +1 -1
  43. package/dist/shared/flow.js +2 -0
  44. package/dist/shared/flow.js.map +1 -1
  45. package/dist/tel/TelField.d.ts +16 -5
  46. package/dist/tel/TelField.d.ts.map +1 -1
  47. package/dist/tel/TelField.js +253 -51
  48. package/dist/tel/TelField.js.map +1 -1
  49. package/dist/tel/index.d.ts +1 -0
  50. package/dist/tel/index.d.ts.map +1 -1
  51. package/dist/tel/index.js +3 -1
  52. package/dist/tel/phone.d.ts +31 -0
  53. package/dist/tel/phone.d.ts.map +1 -0
  54. package/dist/tel/phone.js +60 -0
  55. package/dist/tel/phone.js.map +1 -0
  56. package/package.json +15 -4
package/README.md CHANGED
@@ -34,7 +34,9 @@ Every field takes `value`, `onChange`, `onBlur`, `errors`, `disabled`, `readOnly
34
34
  | `@panneau/fields/url` | `UrlField` | `string`, with `https://` added on blur |
35
35
  | `@panneau/fields/color` | `ColorField` | `'#1d4ed8'` |
36
36
  | `@panneau/fields/slug` | `SlugField`, `slugify()`, `sourceText()` | `string`, following a `source` until edited, checked with `onCheck` |
37
- | `@panneau/fields/tel` | `TelField` | `string`, as typed |
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 |
39
+ | `@panneau/fields/region` | `RegionField`, `getRegions()` | `'QC'`, the region of its country; the text for other countries |
38
40
  | `@panneau/fields/range` | `RangeField` (a slider) | `number`, `null` until moved |
39
41
  | `@panneau/fields/duration` | `DurationField`, `formatDuration()` | seconds, typed in hours, minutes and seconds |
40
42
  | `@panneau/fields/json` | `JsonField`, `parseJson()` | an object or an array; the text while it doesn't parse |
@@ -137,6 +139,16 @@ import { createEmbedSource } from '@panneau/fields';
137
139
  <FieldsProvider embedSource={createEmbedSource(adapter)}>…</FieldsProvider>;
138
140
  ```
139
141
 
142
+ 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
+
144
+ 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
+
146
+ ```tsx
147
+ <CountryField label="Country" preferred={['CA', 'US']} value={country} onChange={setCountry} />
148
+ <RegionField label="Province" country={country} value={province} onChange={setProvince} />
149
+ <TelField label="Phone" country="CA" value={phone} onChange={setPhone} />
150
+ ```
151
+
140
152
  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.
141
153
 
142
154
  ```tsx
@@ -0,0 +1,17 @@
1
+ import type { FieldEntryProps, FieldProps } from '../shared/types.js';
2
+ export interface CountryFieldProps extends FieldProps<string> {
3
+ /** The codes to offer. All countries without it. */
4
+ countries?: readonly string[];
5
+ /** Codes shown first, in their order, above the others: `['CA', 'US']`. */
6
+ preferred?: readonly string[];
7
+ placeholder?: string;
8
+ controlClassName?: string;
9
+ }
10
+ /**
11
+ * A country, as its ISO 3166-1 alpha-2 code (`CA`): a combo box of the countries with their flags
12
+ * and their names in the user's locale. Typing filters them by name or by code.
13
+ */
14
+ export declare function CountryField({ countries, preferred, placeholder, ...props }: CountryFieldProps): import("react").JSX.Element;
15
+ /** The `country` type: `settings.countries` and `settings.preferred`. */
16
+ export declare function CountryFieldEntry(props: FieldEntryProps): import("react").JSX.Element;
17
+ //# sourceMappingURL=CountryField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CountryField.d.ts","sourceRoot":"","sources":["../../src/country/CountryField.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGnE,MAAM,WAAW,iBAAkB,SAAQ,UAAU,CAAC,MAAM,CAAC;IACzD,oDAAoD;IACpD,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,2EAA2E;IAC3E,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,+BAe9F;AAKD,yEAAyE;AACzE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,eAAe,+BAYvD"}
@@ -0,0 +1,151 @@
1
+ import { getFieldProps, getSetting, isString } from "../shared/entry.js";
2
+ import { messages } from "../shared/messages.js";
3
+ import { CodeComboBox } from "../shared/CodeComboBox.js";
4
+ import { getCountryChoices } from "./countries.js";
5
+ import { c } from "react/compiler-runtime";
6
+ import { usePanneauIntl } from "@panneau/ui";
7
+ import { jsx } from "react/jsx-runtime";
8
+ //#region src/country/CountryField.tsx
9
+ /**
10
+ * A country, as its ISO 3166-1 alpha-2 code (`CA`): a combo box of the countries with their flags
11
+ * and their names in the user's locale. Typing filters them by name or by code.
12
+ */
13
+ function CountryField(t0) {
14
+ const $ = c(23);
15
+ let countries;
16
+ let placeholder;
17
+ let preferred;
18
+ let props;
19
+ if ($[0] !== t0) {
20
+ ({countries, preferred, placeholder, ...props} = t0);
21
+ $[0] = t0;
22
+ $[1] = countries;
23
+ $[2] = placeholder;
24
+ $[3] = preferred;
25
+ $[4] = props;
26
+ } else {
27
+ countries = $[1];
28
+ placeholder = $[2];
29
+ preferred = $[3];
30
+ props = $[4];
31
+ }
32
+ const intl = usePanneauIntl();
33
+ let T0;
34
+ let t1;
35
+ let t2;
36
+ if ($[5] !== countries || $[6] !== intl.locale || $[7] !== preferred || $[8] !== props) {
37
+ const choices = getCountryChoices(intl.locale, {
38
+ countries,
39
+ preferred
40
+ });
41
+ T0 = CodeComboBox;
42
+ t1 = props;
43
+ t2 = [...choices.preferred, ...choices.others].map(_temp);
44
+ $[5] = countries;
45
+ $[6] = intl.locale;
46
+ $[7] = preferred;
47
+ $[8] = props;
48
+ $[9] = T0;
49
+ $[10] = t1;
50
+ $[11] = t2;
51
+ } else {
52
+ T0 = $[9];
53
+ t1 = $[10];
54
+ t2 = $[11];
55
+ }
56
+ let t3;
57
+ if ($[12] !== intl || $[13] !== placeholder) {
58
+ t3 = placeholder ?? intl.formatMessage(messages.countryPlaceholder);
59
+ $[12] = intl;
60
+ $[13] = placeholder;
61
+ $[14] = t3;
62
+ } else t3 = $[14];
63
+ let t4;
64
+ if ($[15] !== intl) {
65
+ t4 = intl.formatMessage(messages.noCountries);
66
+ $[15] = intl;
67
+ $[16] = t4;
68
+ } else t4 = $[16];
69
+ let t5;
70
+ if ($[17] !== T0 || $[18] !== t1 || $[19] !== t2 || $[20] !== t3 || $[21] !== t4) {
71
+ t5 = /* @__PURE__ */ jsx(T0, {
72
+ ...t1,
73
+ choices: t2,
74
+ placeholder: t3,
75
+ emptyMessage: t4
76
+ });
77
+ $[17] = T0;
78
+ $[18] = t1;
79
+ $[19] = t2;
80
+ $[20] = t3;
81
+ $[21] = t4;
82
+ $[22] = t5;
83
+ } else t5 = $[22];
84
+ return t5;
85
+ }
86
+ function _temp(country) {
87
+ return {
88
+ code: country.code,
89
+ name: country.name,
90
+ prefix: country.flag
91
+ };
92
+ }
93
+ var isCodes = (value) => Array.isArray(value) && value.every(isString);
94
+ /** The `country` type: `settings.countries` and `settings.preferred`. */
95
+ function CountryFieldEntry(props) {
96
+ const $ = c(16);
97
+ let t0;
98
+ if ($[0] !== props.field) {
99
+ t0 = getSetting(props.field, "countries", isCodes);
100
+ $[0] = props.field;
101
+ $[1] = t0;
102
+ } else t0 = $[1];
103
+ const countries = t0;
104
+ let t1;
105
+ if ($[2] !== props.field) {
106
+ t1 = getSetting(props.field, "preferred", isCodes);
107
+ $[2] = props.field;
108
+ $[3] = t1;
109
+ } else t1 = $[3];
110
+ const preferred = t1;
111
+ let t2;
112
+ if ($[4] !== props) {
113
+ t2 = getFieldProps(props);
114
+ $[4] = props;
115
+ $[5] = t2;
116
+ } else t2 = $[5];
117
+ let t3;
118
+ if ($[6] !== countries) {
119
+ t3 = countries !== void 0 ? { countries } : {};
120
+ $[6] = countries;
121
+ $[7] = t3;
122
+ } else t3 = $[7];
123
+ let t4;
124
+ if ($[8] !== preferred) {
125
+ t4 = preferred !== void 0 ? { preferred } : {};
126
+ $[8] = preferred;
127
+ $[9] = t4;
128
+ } else t4 = $[9];
129
+ const t5 = isString(props.value) ? props.value : null;
130
+ let t6;
131
+ if ($[10] !== props.onChange || $[11] !== t2 || $[12] !== t3 || $[13] !== t4 || $[14] !== t5) {
132
+ t6 = /* @__PURE__ */ jsx(CountryField, {
133
+ ...t2,
134
+ ...t3,
135
+ ...t4,
136
+ value: t5,
137
+ onChange: props.onChange
138
+ });
139
+ $[10] = props.onChange;
140
+ $[11] = t2;
141
+ $[12] = t3;
142
+ $[13] = t4;
143
+ $[14] = t5;
144
+ $[15] = t6;
145
+ } else t6 = $[15];
146
+ return t6;
147
+ }
148
+ //#endregion
149
+ export { CountryField, CountryFieldEntry };
150
+
151
+ //# sourceMappingURL=CountryField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CountryField.js","names":["usePanneauIntl","CodeComboBox","getFieldProps","getSetting","isString","messages","FieldEntryProps","FieldProps","getCountryChoices","CountryFieldProps","countries","preferred","placeholder","controlClassName","CountryField","t0","$","_c","props","intl","T0","t1","t2","locale","choices","others","map","_temp","t3","formatMessage","countryPlaceholder","t4","noCountries","t5","country","code","name","prefix","flag","isCodes","value","Array","isArray","every","CountryFieldEntry","field","undefined","t6","onChange","_c"],"sources":["../../src/country/CountryField.tsx"],"sourcesContent":["import { usePanneauIntl } from '@panneau/ui';\n\nimport { CodeComboBox } from '../shared/CodeComboBox';\nimport { getFieldProps, getSetting, isString } from '../shared/entry';\nimport { messages } from '../shared/messages';\nimport type { FieldEntryProps, FieldProps } from '../shared/types';\nimport { getCountryChoices } from './countries';\n\nexport interface CountryFieldProps extends FieldProps<string> {\n /** The codes to offer. All countries without it. */\n countries?: readonly string[];\n /** Codes shown first, in their order, above the others: `['CA', 'US']`. */\n preferred?: readonly string[];\n placeholder?: string;\n controlClassName?: string;\n}\n\n/**\n * A country, as its ISO 3166-1 alpha-2 code (`CA`): a combo box of the countries with their flags\n * and their names in the user's locale. Typing filters them by name or by code.\n */\nexport function CountryField({ countries, preferred, placeholder, ...props }: CountryFieldProps) {\n const intl = usePanneauIntl();\n const choices = getCountryChoices(intl.locale, { countries, preferred });\n return (\n <CodeComboBox\n {...props}\n choices={[...choices.preferred, ...choices.others].map((country) => ({\n code: country.code,\n name: country.name,\n prefix: country.flag,\n }))}\n placeholder={placeholder ?? intl.formatMessage(messages.countryPlaceholder)}\n emptyMessage={intl.formatMessage(messages.noCountries)}\n />\n );\n}\n\nconst isCodes = (value: unknown): value is string[] =>\n Array.isArray(value) && value.every(isString);\n\n/** The `country` type: `settings.countries` and `settings.preferred`. */\nexport function CountryFieldEntry(props: FieldEntryProps) {\n const countries = getSetting(props.field, 'countries', isCodes);\n const preferred = getSetting(props.field, 'preferred', isCodes);\n return (\n <CountryField\n {...getFieldProps(props)}\n {...(countries !== undefined ? { countries } : {})}\n {...(preferred !== undefined ? { preferred } : {})}\n value={isString(props.value) ? props.value : null}\n onChange={props.onChange}\n />\n );\n}\n"],"mappings":"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"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The ISO 3166-1 alpha-2 codes of the countries and territories, and `XK` (Kosovo), which is
3
+ * widely used for it though not assigned.
4
+ */
5
+ export declare const COUNTRY_CODES: readonly string[];
6
+ //# sourceMappingURL=codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../src/country/codes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EA2P1C,CAAC"}
@@ -0,0 +1,261 @@
1
+ //#region src/country/codes.ts
2
+ /**
3
+ * The ISO 3166-1 alpha-2 codes of the countries and territories, and `XK` (Kosovo), which is
4
+ * widely used for it though not assigned.
5
+ */
6
+ var COUNTRY_CODES = [
7
+ "AD",
8
+ "AE",
9
+ "AF",
10
+ "AG",
11
+ "AI",
12
+ "AL",
13
+ "AM",
14
+ "AO",
15
+ "AQ",
16
+ "AR",
17
+ "AS",
18
+ "AT",
19
+ "AU",
20
+ "AW",
21
+ "AX",
22
+ "AZ",
23
+ "BA",
24
+ "BB",
25
+ "BD",
26
+ "BE",
27
+ "BF",
28
+ "BG",
29
+ "BH",
30
+ "BI",
31
+ "BJ",
32
+ "BL",
33
+ "BM",
34
+ "BN",
35
+ "BO",
36
+ "BQ",
37
+ "BR",
38
+ "BS",
39
+ "BT",
40
+ "BV",
41
+ "BW",
42
+ "BY",
43
+ "BZ",
44
+ "CA",
45
+ "CC",
46
+ "CD",
47
+ "CF",
48
+ "CG",
49
+ "CH",
50
+ "CI",
51
+ "CK",
52
+ "CL",
53
+ "CM",
54
+ "CN",
55
+ "CO",
56
+ "CR",
57
+ "CU",
58
+ "CV",
59
+ "CW",
60
+ "CX",
61
+ "CY",
62
+ "CZ",
63
+ "DE",
64
+ "DJ",
65
+ "DK",
66
+ "DM",
67
+ "DO",
68
+ "DZ",
69
+ "EC",
70
+ "EE",
71
+ "EG",
72
+ "EH",
73
+ "ER",
74
+ "ES",
75
+ "ET",
76
+ "FI",
77
+ "FJ",
78
+ "FK",
79
+ "FM",
80
+ "FO",
81
+ "FR",
82
+ "GA",
83
+ "GB",
84
+ "GD",
85
+ "GE",
86
+ "GF",
87
+ "GG",
88
+ "GH",
89
+ "GI",
90
+ "GL",
91
+ "GM",
92
+ "GN",
93
+ "GP",
94
+ "GQ",
95
+ "GR",
96
+ "GS",
97
+ "GT",
98
+ "GU",
99
+ "GW",
100
+ "GY",
101
+ "HK",
102
+ "HM",
103
+ "HN",
104
+ "HR",
105
+ "HT",
106
+ "HU",
107
+ "ID",
108
+ "IE",
109
+ "IL",
110
+ "IM",
111
+ "IN",
112
+ "IO",
113
+ "IQ",
114
+ "IR",
115
+ "IS",
116
+ "IT",
117
+ "JE",
118
+ "JM",
119
+ "JO",
120
+ "JP",
121
+ "KE",
122
+ "KG",
123
+ "KH",
124
+ "KI",
125
+ "KM",
126
+ "KN",
127
+ "KP",
128
+ "KR",
129
+ "KW",
130
+ "KY",
131
+ "KZ",
132
+ "LA",
133
+ "LB",
134
+ "LC",
135
+ "LI",
136
+ "LK",
137
+ "LR",
138
+ "LS",
139
+ "LT",
140
+ "LU",
141
+ "LV",
142
+ "LY",
143
+ "MA",
144
+ "MC",
145
+ "MD",
146
+ "ME",
147
+ "MF",
148
+ "MG",
149
+ "MH",
150
+ "MK",
151
+ "ML",
152
+ "MM",
153
+ "MN",
154
+ "MO",
155
+ "MP",
156
+ "MQ",
157
+ "MR",
158
+ "MS",
159
+ "MT",
160
+ "MU",
161
+ "MV",
162
+ "MW",
163
+ "MX",
164
+ "MY",
165
+ "MZ",
166
+ "NA",
167
+ "NC",
168
+ "NE",
169
+ "NF",
170
+ "NG",
171
+ "NI",
172
+ "NL",
173
+ "NO",
174
+ "NP",
175
+ "NR",
176
+ "NU",
177
+ "NZ",
178
+ "OM",
179
+ "PA",
180
+ "PE",
181
+ "PF",
182
+ "PG",
183
+ "PH",
184
+ "PK",
185
+ "PL",
186
+ "PM",
187
+ "PN",
188
+ "PR",
189
+ "PS",
190
+ "PT",
191
+ "PW",
192
+ "PY",
193
+ "QA",
194
+ "RE",
195
+ "RO",
196
+ "RS",
197
+ "RU",
198
+ "RW",
199
+ "SA",
200
+ "SB",
201
+ "SC",
202
+ "SD",
203
+ "SE",
204
+ "SG",
205
+ "SH",
206
+ "SI",
207
+ "SJ",
208
+ "SK",
209
+ "SL",
210
+ "SM",
211
+ "SN",
212
+ "SO",
213
+ "SR",
214
+ "SS",
215
+ "ST",
216
+ "SV",
217
+ "SX",
218
+ "SY",
219
+ "SZ",
220
+ "TC",
221
+ "TD",
222
+ "TF",
223
+ "TG",
224
+ "TH",
225
+ "TJ",
226
+ "TK",
227
+ "TL",
228
+ "TM",
229
+ "TN",
230
+ "TO",
231
+ "TR",
232
+ "TT",
233
+ "TV",
234
+ "TW",
235
+ "TZ",
236
+ "UA",
237
+ "UG",
238
+ "UM",
239
+ "US",
240
+ "UY",
241
+ "UZ",
242
+ "VA",
243
+ "VC",
244
+ "VE",
245
+ "VG",
246
+ "VI",
247
+ "VN",
248
+ "VU",
249
+ "WF",
250
+ "WS",
251
+ "XK",
252
+ "YE",
253
+ "YT",
254
+ "ZA",
255
+ "ZM",
256
+ "ZW"
257
+ ];
258
+ //#endregion
259
+ export { COUNTRY_CODES };
260
+
261
+ //# sourceMappingURL=codes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codes.js","names":["COUNTRY_CODES"],"sources":["../../src/country/codes.ts"],"sourcesContent":["/**\n * The ISO 3166-1 alpha-2 codes of the countries and territories, and `XK` (Kosovo), which is\n * widely used for it though not assigned.\n */\nexport const COUNTRY_CODES: readonly string[] = [\n 'AD',\n 'AE',\n 'AF',\n 'AG',\n 'AI',\n 'AL',\n 'AM',\n 'AO',\n 'AQ',\n 'AR',\n 'AS',\n 'AT',\n 'AU',\n 'AW',\n 'AX',\n 'AZ',\n 'BA',\n 'BB',\n 'BD',\n 'BE',\n 'BF',\n 'BG',\n 'BH',\n 'BI',\n 'BJ',\n 'BL',\n 'BM',\n 'BN',\n 'BO',\n 'BQ',\n 'BR',\n 'BS',\n 'BT',\n 'BV',\n 'BW',\n 'BY',\n 'BZ',\n 'CA',\n 'CC',\n 'CD',\n 'CF',\n 'CG',\n 'CH',\n 'CI',\n 'CK',\n 'CL',\n 'CM',\n 'CN',\n 'CO',\n 'CR',\n 'CU',\n 'CV',\n 'CW',\n 'CX',\n 'CY',\n 'CZ',\n 'DE',\n 'DJ',\n 'DK',\n 'DM',\n 'DO',\n 'DZ',\n 'EC',\n 'EE',\n 'EG',\n 'EH',\n 'ER',\n 'ES',\n 'ET',\n 'FI',\n 'FJ',\n 'FK',\n 'FM',\n 'FO',\n 'FR',\n 'GA',\n 'GB',\n 'GD',\n 'GE',\n 'GF',\n 'GG',\n 'GH',\n 'GI',\n 'GL',\n 'GM',\n 'GN',\n 'GP',\n 'GQ',\n 'GR',\n 'GS',\n 'GT',\n 'GU',\n 'GW',\n 'GY',\n 'HK',\n 'HM',\n 'HN',\n 'HR',\n 'HT',\n 'HU',\n 'ID',\n 'IE',\n 'IL',\n 'IM',\n 'IN',\n 'IO',\n 'IQ',\n 'IR',\n 'IS',\n 'IT',\n 'JE',\n 'JM',\n 'JO',\n 'JP',\n 'KE',\n 'KG',\n 'KH',\n 'KI',\n 'KM',\n 'KN',\n 'KP',\n 'KR',\n 'KW',\n 'KY',\n 'KZ',\n 'LA',\n 'LB',\n 'LC',\n 'LI',\n 'LK',\n 'LR',\n 'LS',\n 'LT',\n 'LU',\n 'LV',\n 'LY',\n 'MA',\n 'MC',\n 'MD',\n 'ME',\n 'MF',\n 'MG',\n 'MH',\n 'MK',\n 'ML',\n 'MM',\n 'MN',\n 'MO',\n 'MP',\n 'MQ',\n 'MR',\n 'MS',\n 'MT',\n 'MU',\n 'MV',\n 'MW',\n 'MX',\n 'MY',\n 'MZ',\n 'NA',\n 'NC',\n 'NE',\n 'NF',\n 'NG',\n 'NI',\n 'NL',\n 'NO',\n 'NP',\n 'NR',\n 'NU',\n 'NZ',\n 'OM',\n 'PA',\n 'PE',\n 'PF',\n 'PG',\n 'PH',\n 'PK',\n 'PL',\n 'PM',\n 'PN',\n 'PR',\n 'PS',\n 'PT',\n 'PW',\n 'PY',\n 'QA',\n 'RE',\n 'RO',\n 'RS',\n 'RU',\n 'RW',\n 'SA',\n 'SB',\n 'SC',\n 'SD',\n 'SE',\n 'SG',\n 'SH',\n 'SI',\n 'SJ',\n 'SK',\n 'SL',\n 'SM',\n 'SN',\n 'SO',\n 'SR',\n 'SS',\n 'ST',\n 'SV',\n 'SX',\n 'SY',\n 'SZ',\n 'TC',\n 'TD',\n 'TF',\n 'TG',\n 'TH',\n 'TJ',\n 'TK',\n 'TL',\n 'TM',\n 'TN',\n 'TO',\n 'TR',\n 'TT',\n 'TV',\n 'TW',\n 'TZ',\n 'UA',\n 'UG',\n 'UM',\n 'US',\n 'UY',\n 'UZ',\n 'VA',\n 'VC',\n 'VE',\n 'VG',\n 'VI',\n 'VN',\n 'VU',\n 'WF',\n 'WS',\n 'XK',\n 'YE',\n 'YT',\n 'ZA',\n 'ZM',\n 'ZW',\n];\n"],"mappings":";;;;;AAIA,IAAaA,gBAAmC;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAAI"}
@@ -0,0 +1,32 @@
1
+ import { COUNTRY_CODES } from './codes.js';
2
+ export { COUNTRY_CODES };
3
+ /** A country to choose: its code, its name in a locale, and its flag. */
4
+ export interface CountryChoice {
5
+ /** ISO 3166-1 alpha-2 code, in capitals: `CA`. */
6
+ code: string;
7
+ name: string;
8
+ flag: string;
9
+ }
10
+ /** Whether a value is a code of `COUNTRY_CODES`. */
11
+ export declare function isCountryCode(value: unknown): value is string;
12
+ /** The flag of a country, as an emoji: two regional indicator symbols. */
13
+ export declare function getCountryFlag(code: string): string;
14
+ /** The name of a country in a locale (`Canada`, `Allemagne`), or its code when unknown. */
15
+ export declare function getCountryName(code: string, locale: string): string;
16
+ export interface CountryChoicesOptions {
17
+ /** The codes to offer. All countries without it. */
18
+ countries?: readonly string[] | undefined;
19
+ /** Codes shown first, in their order, above the others. */
20
+ preferred?: readonly string[] | undefined;
21
+ }
22
+ /**
23
+ * The countries to choose from, with their names in the locale: the preferred ones first, in
24
+ * their order, then the others, sorted by name in the locale.
25
+ */
26
+ export declare function getCountryChoices(locale: string, { countries, preferred }?: CountryChoicesOptions): {
27
+ preferred: CountryChoice[];
28
+ others: CountryChoice[];
29
+ };
30
+ /** The region of a locale (`fr-CA` gives `CA`), or `null`. */
31
+ export declare function getLocaleCountry(locale: string): string | null;
32
+ //# sourceMappingURL=countries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"countries.d.ts","sourceRoot":"","sources":["../../src/country/countries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC1B,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAID,oDAAoD;AACpD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE7D;AAED,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKnD;AAID,2FAA2F;AAC3F,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAWnE;AAED,MAAM,WAAW,qBAAqB;IAClC,oDAAoD;IACpD,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAC1C,2DAA2D;IAC3D,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CAC7C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC7B,MAAM,EAAE,MAAM,EACd,EAAE,SAAS,EAAE,SAAc,EAAE,GAAE,qBAA0B,GAC1D;IAAE,SAAS,EAAE,aAAa,EAAE,CAAC;IAAC,MAAM,EAAE,aAAa,EAAE,CAAA;CAAE,CAgBzD;AAED,8DAA8D;AAC9D,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAO9D"}
@@ -0,0 +1,60 @@
1
+ import { COUNTRY_CODES } from "./codes.js";
2
+ //#region src/country/countries.ts
3
+ var CODE = /^[A-Z]{2}$/;
4
+ /** Whether a value is a code of `COUNTRY_CODES`. */
5
+ function isCountryCode(value) {
6
+ return typeof value === "string" && COUNTRY_CODES.includes(value);
7
+ }
8
+ /** The flag of a country, as an emoji: two regional indicator symbols. */
9
+ function getCountryFlag(code) {
10
+ if (!CODE.test(code)) return "";
11
+ return String.fromCodePoint(...[...code].map((letter) => 127397 + letter.charCodeAt(0)));
12
+ }
13
+ var displayNames = /* @__PURE__ */ new Map();
14
+ /** The name of a country in a locale (`Canada`, `Allemagne`), or its code when unknown. */
15
+ function getCountryName(code, locale) {
16
+ let names = displayNames.get(locale);
17
+ if (names === void 0) {
18
+ names = new Intl.DisplayNames([locale, "en"], {
19
+ type: "region",
20
+ fallback: "code"
21
+ });
22
+ displayNames.set(locale, names);
23
+ }
24
+ try {
25
+ return names.of(code) ?? code;
26
+ } catch {
27
+ return code;
28
+ }
29
+ }
30
+ /**
31
+ * The countries to choose from, with their names in the locale: the preferred ones first, in
32
+ * their order, then the others, sorted by name in the locale.
33
+ */
34
+ function getCountryChoices(locale, { countries, preferred = [] } = {}) {
35
+ const codes = (countries ?? COUNTRY_CODES).filter(isCountryCode);
36
+ const choice = (code) => ({
37
+ code,
38
+ name: getCountryName(code, locale),
39
+ flag: getCountryFlag(code)
40
+ });
41
+ const first = preferred.filter((code) => codes.includes(code));
42
+ const collator = new Intl.Collator(locale);
43
+ return {
44
+ preferred: first.map(choice),
45
+ others: codes.filter((code) => !first.includes(code)).map(choice).sort((a, b) => collator.compare(a.name, b.name))
46
+ };
47
+ }
48
+ /** The region of a locale (`fr-CA` gives `CA`), or `null`. */
49
+ function getLocaleCountry(locale) {
50
+ try {
51
+ const region = new Intl.Locale(locale).maximize().region;
52
+ return region !== void 0 && isCountryCode(region) ? region : null;
53
+ } catch {
54
+ return null;
55
+ }
56
+ }
57
+ //#endregion
58
+ export { COUNTRY_CODES, getCountryChoices, getCountryFlag, getCountryName, getLocaleCountry, isCountryCode };
59
+
60
+ //# sourceMappingURL=countries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"countries.js","names":["COUNTRY_CODES","CountryChoice","code","name","flag","CODE","isCountryCode","value","includes","getCountryFlag","test","String","fromCodePoint","map","letter","charCodeAt","displayNames","Map","Intl","DisplayNames","getCountryName","locale","names","get","undefined","type","fallback","set","of","CountryChoicesOptions","countries","preferred","getCountryChoices","others","codes","filter","choice","first","collator","Collator","sort","a","b","compare","getLocaleCountry","region","Locale","maximize"],"sources":["../../src/country/countries.ts"],"sourcesContent":["import { COUNTRY_CODES } from './codes';\n\nexport { COUNTRY_CODES };\n\n/** A country to choose: its code, its name in a locale, and its flag. */\nexport interface CountryChoice {\n /** ISO 3166-1 alpha-2 code, in capitals: `CA`. */\n code: string;\n name: string;\n flag: string;\n}\n\nconst CODE = /^[A-Z]{2}$/;\n\n/** Whether a value is a code of `COUNTRY_CODES`. */\nexport function isCountryCode(value: unknown): value is string {\n return typeof value === 'string' && COUNTRY_CODES.includes(value);\n}\n\n/** The flag of a country, as an emoji: two regional indicator symbols. */\nexport function getCountryFlag(code: string): string {\n if (!CODE.test(code)) {\n return '';\n }\n return String.fromCodePoint(...[...code].map((letter) => 0x1f1a5 + letter.charCodeAt(0)));\n}\n\nconst displayNames = new Map<string, Intl.DisplayNames>();\n\n/** The name of a country in a locale (`Canada`, `Allemagne`), or its code when unknown. */\nexport function getCountryName(code: string, locale: string): string {\n let names = displayNames.get(locale);\n if (names === undefined) {\n names = new Intl.DisplayNames([locale, 'en'], { type: 'region', fallback: 'code' });\n displayNames.set(locale, names);\n }\n try {\n return names.of(code) ?? code;\n } catch {\n return code;\n }\n}\n\nexport interface CountryChoicesOptions {\n /** The codes to offer. All countries without it. */\n countries?: readonly string[] | undefined;\n /** Codes shown first, in their order, above the others. */\n preferred?: readonly string[] | undefined;\n}\n\n/**\n * The countries to choose from, with their names in the locale: the preferred ones first, in\n * their order, then the others, sorted by name in the locale.\n */\nexport function getCountryChoices(\n locale: string,\n { countries, preferred = [] }: CountryChoicesOptions = {},\n): { preferred: CountryChoice[]; others: CountryChoice[] } {\n const codes = (countries ?? COUNTRY_CODES).filter(isCountryCode);\n const choice = (code: string): CountryChoice => ({\n code,\n name: getCountryName(code, locale),\n flag: getCountryFlag(code),\n });\n const first = preferred.filter((code) => codes.includes(code));\n const collator = new Intl.Collator(locale);\n return {\n preferred: first.map(choice),\n others: codes\n .filter((code) => !first.includes(code))\n .map(choice)\n .sort((a, b) => collator.compare(a.name, b.name)),\n };\n}\n\n/** The region of a locale (`fr-CA` gives `CA`), or `null`. */\nexport function getLocaleCountry(locale: string): string | null {\n try {\n const region = new Intl.Locale(locale).maximize().region;\n return region !== undefined && isCountryCode(region) ? region : null;\n } catch {\n return null;\n }\n}\n"],"mappings":";;AAYA,IAAMK,OAAO;;AAGb,SAAgBC,cAAcC,OAAiC;CAC3D,OAAO,OAAOA,UAAU,YAAYP,cAAcQ,SAASD,KAAK;AACpE;;AAGA,SAAgBE,eAAeP,MAAsB;CACjD,IAAI,CAACG,KAAKK,KAAKR,IAAI,GACf,OAAO;CAEX,OAAOS,OAAOC,cAAc,GAAG,CAAC,GAAGV,IAAI,CAAC,CAACW,KAAKC,WAAW,SAAUA,OAAOC,WAAW,CAAC,CAAC,CAAC;AAC5F;AAEA,IAAMC,+BAAe,IAAIC,IAA+B;;AAGxD,SAAgBG,eAAelB,MAAcmB,QAAwB;CACjE,IAAIC,QAAQN,aAAaO,IAAIF,MAAM;CACnC,IAAIC,UAAUE,KAAAA,GAAW;EACrBF,QAAQ,IAAIJ,KAAKC,aAAa,CAACE,QAAQ,IAAI,GAAG;GAAEI,MAAM;GAAUC,UAAU;EAAO,CAAC;EAClFV,aAAaW,IAAIN,QAAQC,KAAK;CAClC;CACA,IAAI;EACA,OAAOA,MAAMM,GAAG1B,IAAI,KAAKA;CAC7B,QAAQ;EACJ,OAAOA;CACX;AACJ;;;;;AAaA,SAAgB8B,kBACZX,QACA,EAAES,WAAWC,YAAY,CAAA,MAA8B,CAAC,GACD;CACvD,MAAMG,SAASJ,aAAa9B,cAAAA,CAAemC,OAAO7B,aAAa;CAC/D,MAAM8B,UAAUlC,UAAiC;EAC7CA;EACAC,MAAMiB,eAAelB,MAAMmB,MAAM;EACjCjB,MAAMK,eAAeP,IAAI;CAC7B;CACA,MAAMmC,QAAQN,UAAUI,QAAQjC,SAASgC,MAAM1B,SAASN,IAAI,CAAC;CAC7D,MAAMoC,WAAW,IAAIpB,KAAKqB,SAASlB,MAAM;CACzC,OAAO;EACHU,WAAWM,MAAMxB,IAAIuB,MAAM;EAC3BH,QAAQC,MACHC,QAAQjC,SAAS,CAACmC,MAAM7B,SAASN,IAAI,CAAC,CAAC,CACvCW,IAAIuB,MAAM,CAAC,CACXI,MAAMC,GAAGC,MAAMJ,SAASK,QAAQF,EAAEtC,MAAMuC,EAAEvC,IAAI,CAAC;CACxD;AACJ;;AAGA,SAAgByC,iBAAiBvB,QAA+B;CAC5D,IAAI;EACA,MAAMwB,SAAS,IAAI3B,KAAK4B,OAAOzB,MAAM,CAAC,CAAC0B,SAAS,CAAC,CAACF;EAClD,OAAOA,WAAWrB,KAAAA,KAAalB,cAAcuC,MAAM,IAAIA,SAAS;CACpE,QAAQ;EACJ,OAAO;CACX;AACJ"}
@@ -0,0 +1,3 @@
1
+ export { CountryField, CountryFieldEntry, type CountryFieldProps } from './CountryField.js';
2
+ export { COUNTRY_CODES, type CountryChoice, type CountryChoicesOptions, getCountryChoices, getCountryFlag, getCountryName, getLocaleCountry, isCountryCode, } from './countries.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/country/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACzF,OAAO,EACH,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,aAAa,GAChB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { COUNTRY_CODES } from "./codes.js";
2
+ import { getCountryChoices, getCountryFlag, getCountryName, getLocaleCountry, isCountryCode } from "./countries.js";
3
+ import { CountryField, CountryFieldEntry } from "./CountryField.js";
4
+ export { COUNTRY_CODES, CountryField, CountryFieldEntry, getCountryChoices, getCountryFlag, getCountryName, getLocaleCountry, isCountryCode };
@@ -0,0 +1,22 @@
1
+ import type { Field } from '@panneau/protocol';
2
+ import type { FieldEntryProps, FieldProps } from '../shared/types.js';
3
+ export interface RegionFieldProps extends FieldProps<string> {
4
+ /** The country of the region (`CA`). Without it, or for a country without known regions, a text. */
5
+ country?: string | null;
6
+ placeholder?: string;
7
+ controlClassName?: string;
8
+ }
9
+ /**
10
+ * A state, a province or a territory of a country. For the countries that Panneau knows the
11
+ * regions of, a combo box of their names in the user's locale, whose value is the code of the
12
+ * region without its country (`QC`). For the others, the region as typed.
13
+ */
14
+ export declare function RegionField({ country, placeholder, ...props }: RegionFieldProps): import("react").JSX.Element;
15
+ /**
16
+ * The country of a `region` field: the value of the field that `from` names in the same object,
17
+ * or `settings.country`.
18
+ */
19
+ export declare function getRegionCountry(field: Field, parentValue: unknown): string | null;
20
+ /** The `region` type: its country from `from` or `settings.country`. */
21
+ export declare function RegionFieldEntry(props: FieldEntryProps): import("react").JSX.Element;
22
+ //# sourceMappingURL=RegionField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RegionField.d.ts","sourceRoot":"","sources":["../../src/region/RegionField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAM/C,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAInE,MAAM,WAAW,gBAAiB,SAAQ,UAAU,CAAC,MAAM,CAAC;IACxD,oGAAoG;IACpG,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,EAAE,gBAAgB,+BAoB/E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAQlF;AAED,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,+BAStD"}