@panneau/fields 5.0.0-alpha.12 → 5.0.0-alpha.13
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 +13 -1
- package/dist/country/CountryField.d.ts +17 -0
- package/dist/country/CountryField.d.ts.map +1 -0
- package/dist/country/CountryField.js +151 -0
- package/dist/country/CountryField.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/region/RegionField.d.ts +22 -0
- package/dist/region/RegionField.d.ts.map +1 -0
- package/dist/region/RegionField.js +136 -0
- package/dist/region/RegionField.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/index.d.ts +3 -0
- package/dist/region/index.d.ts.map +1 -0
- package/dist/region/index.js +3 -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/shared/CodeComboBox.d.ts +20 -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/builtIn.d.ts.map +1 -1
- package/dist/shared/builtIn.js +5 -1
- package/dist/shared/builtIn.js.map +1 -1
- package/dist/shared/entry.d.ts.map +1 -1
- package/dist/shared/entry.js +1 -1
- package/dist/shared/entry.js.map +1 -1
- package/dist/shared/flow.d.ts.map +1 -1
- package/dist/shared/flow.js +2 -0
- package/dist/shared/flow.js.map +1 -1
- package/dist/tel/TelField.d.ts +16 -5
- package/dist/tel/TelField.d.ts.map +1 -1
- package/dist/tel/TelField.js +253 -51
- package/dist/tel/TelField.js.map +1 -1
- package/dist/tel/index.d.ts +1 -0
- package/dist/tel/index.d.ts.map +1 -1
- package/dist/tel/index.js +3 -1
- package/dist/tel/phone.d.ts +31 -0
- package/dist/tel/phone.d.ts.map +1 -0
- package/dist/tel/phone.js +60 -0
- package/dist/tel/phone.js.map +1 -0
- package/package.json +15 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.js","names":["RegionEntry","code","en","fr","REGIONS","Readonly","Record","AR","AU","BR","CA","CN","IN","JP","MX","US"],"sources":["../../src/region/data.ts"],"sourcesContent":["// Generated from the CLDR (common/subdivisions/en.xml and fr.xml, and the subdivision containment\n// of cldr-core 49): the first-level subdivisions that postal addresses name. Codes are those of\n// ISO 3166-2, without their country.\n\n/** A region: its code, its English name, and its French name when it differs. */\nexport type RegionEntry = readonly [code: string, en: string, fr?: string];\n\n/** The regions of the countries that Panneau knows, by country code. */\nexport const REGIONS: Readonly<Record<string, readonly RegionEntry[]>> = {\n AR: [\n ['A', 'Salta'],\n ['B', 'Buenos Aires Province', 'Province de Buenos Aires'],\n ['C', 'Buenos Aires'],\n ['D', 'San Luis'],\n ['E', 'Entre Ríos'],\n ['F', 'La Rioja'],\n ['G', 'Santiago del Estero'],\n ['H', 'Chaco'],\n ['J', 'San Juan'],\n ['K', 'Catamarca'],\n ['L', 'La Pampa'],\n ['M', 'Mendoza'],\n ['N', 'Misiones'],\n ['P', 'Formosa'],\n ['Q', 'Neuquén'],\n ['R', 'Río Negro'],\n ['S', 'Santa Fe'],\n ['T', 'Tucumán'],\n ['U', 'Chubut'],\n ['V', 'Tierra del Fuego', 'Terre de Feu'],\n ['W', 'Corrientes'],\n ['X', 'Córdoba'],\n ['Y', 'Jujuy'],\n ['Z', 'Santa Cruz'],\n ],\n AU: [\n ['ACT', 'Australian Capital Territory', 'Territoire de la capitale australienne'],\n ['NSW', 'New South Wales', 'Nouvelle-Galles du Sud'],\n ['NT', 'Northern Territory', 'Territoire du Nord'],\n ['QLD', 'Queensland'],\n ['SA', 'South Australia', 'Australie-Méridionale'],\n ['TAS', 'Tasmania', 'Tasmanie'],\n ['VIC', 'Victoria'],\n ['WA', 'Western Australia', 'Australie-Occidentale'],\n ],\n BR: [\n ['AC', 'Acre'],\n ['AL', 'Alagoas'],\n ['AM', 'Amazonas'],\n ['AP', 'Amapá'],\n ['BA', 'Bahia'],\n ['CE', 'Ceará'],\n ['DF', 'Federal District', 'District Fédéral'],\n ['ES', 'Espírito Santo'],\n ['GO', 'Goiás'],\n ['MA', 'Maranhão'],\n ['MG', 'Minas Gerais'],\n ['MS', 'Mato Grosso do Sul'],\n ['MT', 'Mato Grosso'],\n ['PA', 'Pará'],\n ['PB', 'Paraíba'],\n ['PE', 'Pernambuco', 'Pernambouc'],\n ['PI', 'Piauí'],\n ['PR', 'Paraná'],\n ['RJ', 'Rio de Janeiro', 'État de Rio de Janeiro'],\n ['RN', 'Rio Grande do Norte'],\n ['RO', 'Rondônia'],\n ['RR', 'Roraima'],\n ['RS', 'Rio Grande do Sul'],\n ['SC', 'Santa Catarina'],\n ['SE', 'Sergipe'],\n ['SP', 'São Paulo', 'État de São Paulo'],\n ['TO', 'Tocantins'],\n ],\n CA: [\n ['AB', 'Alberta'],\n ['BC', 'British Columbia', 'Colombie-Britannique'],\n ['MB', 'Manitoba'],\n ['NB', 'New Brunswick', 'Nouveau-Brunswick'],\n ['NL', 'Newfoundland and Labrador', 'Terre-Neuve-et-Labrador'],\n ['NS', 'Nova Scotia', 'Nouvelle-Écosse'],\n ['NT', 'Northwest Territories', 'Territoires du Nord-Ouest'],\n ['NU', 'Nunavut'],\n ['ON', 'Ontario'],\n ['PE', 'Prince Edward Island', 'Île-du-Prince-Édouard'],\n ['QC', 'Quebec', 'Québec'],\n ['SK', 'Saskatchewan'],\n ['YT', 'Yukon'],\n ],\n CN: [\n ['AH', 'Anhui'],\n ['BJ', 'Beijing', 'Pékin'],\n ['CQ', 'Chongqing'],\n ['FJ', 'Fujian'],\n ['GD', 'Guangdong'],\n ['GS', 'Gansu'],\n ['GX', 'Guangxi'],\n ['GZ', 'Guizhou'],\n ['HA', 'Henan'],\n ['HB', 'Hubei'],\n ['HE', 'Hebei'],\n ['HI', 'Hainan'],\n ['HL', 'Heilongjiang'],\n ['HN', 'Hunan'],\n ['JL', 'Jilin'],\n ['JS', 'Jiangsu'],\n ['JX', 'Jiangxi'],\n ['LN', 'Liaoning'],\n ['NM', 'Inner Mongolia', 'Mongolie-Intérieure'],\n ['NX', 'Ningxia', 'Níngxià'],\n ['QH', 'Qinghai'],\n ['SC', 'Sichuan'],\n ['SD', 'Shandong'],\n ['SH', 'Shanghai'],\n ['SN', 'Shaanxi'],\n ['SX', 'Shanxi'],\n ['TJ', 'Tianjin'],\n ['XJ', 'Xinjiang'],\n ['XZ', 'Tibet', 'Région autonome du Tibet'],\n ['YN', 'Yunnan'],\n ['ZJ', 'Zhejiang'],\n ],\n IN: [\n ['AN', 'Andaman and Nicobar Islands', 'Îles Andaman-et-Nicobar'],\n ['AP', 'Andhra Pradesh'],\n ['AR', 'Arunachal Pradesh'],\n ['AS', 'Assam'],\n ['BR', 'Bihar'],\n ['CG', 'Chhattīsgarh', 'Chhattisgarh'],\n ['CH', 'Chandigarh'],\n ['DH', 'Dādra and Nagar Haveli and Damān and Diu', 'Dadra et Nagar Haveli et Daman et Diu'],\n ['DL', 'Delhi'],\n ['GA', 'Goa'],\n ['GJ', 'Gujarat'],\n ['HP', 'Himachal Pradesh'],\n ['HR', 'Haryana'],\n ['JH', 'Jharkhand'],\n ['JK', 'Jammu and Kashmir', 'Jammu-et-Cachemire'],\n ['KA', 'Karnataka'],\n ['KL', 'Kerala'],\n ['LA', 'Ladakh'],\n ['LD', 'Lakshadweep'],\n ['MH', 'Maharashtra'],\n ['ML', 'Meghalaya'],\n ['MN', 'Manipur'],\n ['MP', 'Madhya Pradesh'],\n ['MZ', 'Mizoram'],\n ['NL', 'Nagaland'],\n ['OD', 'Odisha'],\n ['PB', 'Punjab', 'Pendjab'],\n ['PY', 'Puducherry', 'Territoire de Pondichéry'],\n ['RJ', 'Rajasthan'],\n ['SK', 'Sikkim'],\n ['TN', 'Tamil Nadu'],\n ['TR', 'Tripura'],\n ['TS', 'Telangāna', 'Telangana'],\n ['UK', 'Uttarākhand', 'Uttarakhand'],\n ['UP', 'Uttar Pradesh'],\n ['WB', 'West Bengal', 'Bengale-Occidental'],\n ],\n JP: [\n ['01', 'Hokkaidō'],\n ['02', 'Aomori'],\n ['03', 'Iwate'],\n ['04', 'Miyagi'],\n ['05', 'Akita'],\n ['06', 'Yamagata'],\n ['07', 'Fukushima'],\n ['08', 'Ibaraki'],\n ['09', 'Tochigi'],\n ['10', 'Gunma'],\n ['11', 'Saitama'],\n ['12', 'Chiba'],\n ['13', 'Tokyo'],\n ['14', 'Kanagawa'],\n ['15', 'Niigata'],\n ['16', 'Toyama'],\n ['17', 'Ishikawa'],\n ['18', 'Fukui'],\n ['19', 'Yamanashi'],\n ['20', 'Nagano'],\n ['21', 'Gifu'],\n ['22', 'Shizuoka'],\n ['23', 'Aichi'],\n ['24', 'Mie'],\n ['25', 'Shiga'],\n ['26', 'Kyōto', 'Kyoto'],\n ['27', 'Ōsaka', 'Osaka'],\n ['28', 'Hyōgo'],\n ['29', 'Nara'],\n ['30', 'Wakayama'],\n ['31', 'Tottori'],\n ['32', 'Shimane'],\n ['33', 'Okayama'],\n ['34', 'Hiroshima'],\n ['35', 'Yamaguchi'],\n ['36', 'Tokushima'],\n ['37', 'Kagawa'],\n ['38', 'Ehime'],\n ['39', 'Kōchi'],\n ['40', 'Fukuoka'],\n ['41', 'Saga'],\n ['42', 'Nagasaki'],\n ['43', 'Kumamoto'],\n ['44', 'Ōita'],\n ['45', 'Miyazaki'],\n ['46', 'Kagoshima'],\n ['47', 'Okinawa'],\n ],\n MX: [\n ['AGU', 'Aguascalientes'],\n ['BCN', 'Baja California', 'Basse-Californie'],\n ['BCS', 'Baja California Sur', 'Basse-Californie du Sud'],\n ['CAM', 'Campeche'],\n ['CHH', 'Chihuahua'],\n ['CHP', 'Chiapas'],\n ['CMX', 'Ciudad de Mexico', 'Mexico'],\n ['COA', 'Coahuila'],\n ['COL', 'Colima'],\n ['DUR', 'Durango'],\n ['GRO', 'Guerrero'],\n ['GUA', 'Guanajuato'],\n ['HID', 'Hidalgo'],\n ['JAL', 'Jalisco'],\n ['MEX', 'Mexico State', 'État de Mexico'],\n ['MIC', 'Michoacán'],\n ['MOR', 'Morelos'],\n ['NAY', 'Nayarit'],\n ['NLE', 'Nuevo León'],\n ['OAX', 'Oaxaca'],\n ['PUE', 'Puebla'],\n ['QUE', 'Querétaro'],\n ['ROO', 'Quintana Roo'],\n ['SIN', 'Sinaloa'],\n ['SLP', 'San Luis Potosí'],\n ['SON', 'Sonora'],\n ['TAB', 'Tabasco'],\n ['TAM', 'Tamaulipas'],\n ['TLA', 'Tlaxcala'],\n ['VER', 'Veracruz'],\n ['YUC', 'Yucatán'],\n ['ZAC', 'Zacatecas'],\n ],\n US: [\n ['AK', 'Alaska'],\n ['AL', 'Alabama'],\n ['AR', 'Arkansas'],\n ['AS', 'American Samoa'],\n ['AZ', 'Arizona'],\n ['CA', 'California', 'Californie'],\n ['CO', 'Colorado'],\n ['CT', 'Connecticut'],\n ['DC', 'Washington DC', 'District de Columbia'],\n ['DE', 'Delaware'],\n ['FL', 'Florida', 'Floride'],\n ['GA', 'Georgia', 'Géorgie'],\n ['GU', 'Guam'],\n ['HI', 'Hawaii', 'Hawaï'],\n ['IA', 'Iowa'],\n ['ID', 'Idaho'],\n ['IL', 'Illinois'],\n ['IN', 'Indiana'],\n ['KS', 'Kansas'],\n ['KY', 'Kentucky'],\n ['LA', 'Louisiana', 'Louisiane'],\n ['MA', 'Massachusetts'],\n ['MD', 'Maryland'],\n ['ME', 'Maine'],\n ['MI', 'Michigan'],\n ['MN', 'Minnesota'],\n ['MO', 'Missouri'],\n ['MP', 'Northern Mariana Islands'],\n ['MS', 'Mississippi'],\n ['MT', 'Montana'],\n ['NC', 'North Carolina', 'Caroline du Nord'],\n ['ND', 'North Dakota', 'Dakota du Nord'],\n ['NE', 'Nebraska'],\n ['NH', 'New Hampshire'],\n ['NJ', 'New Jersey'],\n ['NM', 'New Mexico', 'Nouveau-Mexique'],\n ['NV', 'Nevada'],\n ['NY', 'New York'],\n ['OH', 'Ohio'],\n ['OK', 'Oklahoma'],\n ['OR', 'Oregon'],\n ['PA', 'Pennsylvania', 'Pennsylvanie'],\n ['PR', 'Puerto Rico'],\n ['RI', 'Rhode Island'],\n ['SC', 'South Carolina', 'Caroline du Sud'],\n ['SD', 'South Dakota', 'Dakota du Sud'],\n ['TN', 'Tennessee'],\n ['TX', 'Texas'],\n ['UM', 'U.S. Outlying Islands'],\n ['UT', 'Utah'],\n ['VA', 'Virginia', 'Virginie'],\n ['VI', 'U.S. Virgin Islands'],\n ['VT', 'Vermont'],\n ['WA', 'Washington', 'État de Washington'],\n ['WI', 'Wisconsin'],\n ['WV', 'West Virginia', 'Virginie-Occidentale'],\n ['WY', 'Wyoming'],\n ],\n};\n"],"mappings":";;AAQA,IAAaI,UAA4D;CACrEG,IAAI;EACA,CAAC,KAAK,OAAO;EACb;GAAC;GAAK;GAAyB;EAA0B;EACzD,CAAC,KAAK,cAAc;EACpB,CAAC,KAAK,UAAU;EAChB,CAAC,KAAK,YAAY;EAClB,CAAC,KAAK,UAAU;EAChB,CAAC,KAAK,qBAAqB;EAC3B,CAAC,KAAK,OAAO;EACb,CAAC,KAAK,UAAU;EAChB,CAAC,KAAK,WAAW;EACjB,CAAC,KAAK,UAAU;EAChB,CAAC,KAAK,SAAS;EACf,CAAC,KAAK,UAAU;EAChB,CAAC,KAAK,SAAS;EACf,CAAC,KAAK,SAAS;EACf,CAAC,KAAK,WAAW;EACjB,CAAC,KAAK,UAAU;EAChB,CAAC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AAM,YAAY;EACnB;GAAC;GAAM;GAAc;EAAiB;EACtC,CAAC,MAAM,QAAQ;EACf,CAAC,MAAM,UAAU;EACjB,CAAC,MAAM,MAAM;EACb,CAAC,MAAM,UAAU;EACjB,CAAC,MAAM,QAAQ;EACf;GAAC;GAAM;GAAgB;EAAc;EACrC,CAAC,MAAM,aAAa;EACpB,CAAC,MAAM,cAAc;EACrB;GAAC;GAAM;GAAkB;EAAiB;EAC1C;GAAC;GAAM;GAAgB;EAAe;EACtC,CAAC,MAAM,WAAW;EAClB,CAAC,MAAM,OAAO;EACd,CAAC,MAAM,uBAAuB;EAC9B,CAAC,MAAM,MAAM;EACb;GAAC;GAAM;GAAY;EAAU;EAC7B,CAAC,MAAM,qBAAqB;EAC5B,CAAC,MAAM,SAAS;EAChB;GAAC;GAAM;GAAc;EAAoB;EACzC,CAAC,MAAM,WAAW;EAClB;GAAC;GAAM;GAAiB;EAAsB;EAC9C,CAAC,MAAM,SAAS;CAAC;AAEzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/region/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,gBAAgB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,KAAK,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** A region of a country: its code without the country (`QC`), and its name in a locale. */
|
|
2
|
+
export interface Region {
|
|
3
|
+
code: string;
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
6
|
+
/** The countries whose regions Panneau knows, by code. */
|
|
7
|
+
export declare const REGION_COUNTRIES: readonly string[];
|
|
8
|
+
/**
|
|
9
|
+
* The regions of a country, with their names in the locale (French or English), sorted by name.
|
|
10
|
+
* `null` for a country whose regions Panneau doesn't know.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getRegions(country: string | null | undefined, locale: string): Region[] | null;
|
|
13
|
+
/** The name of a region of a country in the locale, or `null` when Panneau doesn't know it. */
|
|
14
|
+
export declare function getRegionName(country: string | null | undefined, code: string, locale: string): string | null;
|
|
15
|
+
//# sourceMappingURL=regions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regions.d.ts","sourceRoot":"","sources":["../../src/region/regions.ts"],"names":[],"mappings":"AAEA,4FAA4F;AAC5F,MAAM,WAAW,MAAM;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,0DAA0D;AAC1D,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAAyB,CAAC;AAMxE;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAS9F;AAED,+FAA+F;AAC/F,wBAAgB,aAAa,CACzB,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAClC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACf,MAAM,GAAG,IAAI,CAIf"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { REGIONS } from "./data.js";
|
|
2
|
+
//#region src/region/regions.ts
|
|
3
|
+
/** The countries whose regions Panneau knows, by code. */
|
|
4
|
+
var REGION_COUNTRIES = Object.keys(REGIONS);
|
|
5
|
+
function nameIn(entry, locale) {
|
|
6
|
+
return locale.toLowerCase().startsWith("fr") ? entry[2] ?? entry[1] : entry[1];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The regions of a country, with their names in the locale (French or English), sorted by name.
|
|
10
|
+
* `null` for a country whose regions Panneau doesn't know.
|
|
11
|
+
*/
|
|
12
|
+
function getRegions(country, locale) {
|
|
13
|
+
const entries = country !== null && country !== void 0 ? REGIONS[country] : void 0;
|
|
14
|
+
if (entries === void 0) return null;
|
|
15
|
+
const collator = new Intl.Collator(locale);
|
|
16
|
+
return entries.map((entry) => ({
|
|
17
|
+
code: entry[0],
|
|
18
|
+
name: nameIn(entry, locale)
|
|
19
|
+
})).sort((a, b) => collator.compare(a.name, b.name));
|
|
20
|
+
}
|
|
21
|
+
/** The name of a region of a country in the locale, or `null` when Panneau doesn't know it. */
|
|
22
|
+
function getRegionName(country, code, locale) {
|
|
23
|
+
const entry = (country !== null && country !== void 0 ? REGIONS[country] : void 0)?.find((item) => item[0] === code);
|
|
24
|
+
return entry !== void 0 ? nameIn(entry, locale) : null;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { REGION_COUNTRIES, getRegionName, getRegions };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=regions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regions.js","names":["REGIONS","Region","code","name","REGION_COUNTRIES","Object","keys","nameIn","entry","locale","toLowerCase","startsWith","getRegions","country","entries","undefined","collator","Intl","Collator","map","sort","a","b","compare","getRegionName","find","item"],"sources":["../../src/region/regions.ts"],"sourcesContent":["import { REGIONS } from './data';\n\n/** A region of a country: its code without the country (`QC`), and its name in a locale. */\nexport interface Region {\n code: string;\n name: string;\n}\n\n/** The countries whose regions Panneau knows, by code. */\nexport const REGION_COUNTRIES: readonly string[] = Object.keys(REGIONS);\n\nfunction nameIn(entry: readonly [string, string, string?], locale: string): string {\n return locale.toLowerCase().startsWith('fr') ? (entry[2] ?? entry[1]) : entry[1];\n}\n\n/**\n * The regions of a country, with their names in the locale (French or English), sorted by name.\n * `null` for a country whose regions Panneau doesn't know.\n */\nexport function getRegions(country: string | null | undefined, locale: string): Region[] | null {\n const entries = country !== null && country !== undefined ? REGIONS[country] : undefined;\n if (entries === undefined) {\n return null;\n }\n const collator = new Intl.Collator(locale);\n return entries\n .map((entry) => ({ code: entry[0], name: nameIn(entry, locale) }))\n .sort((a, b) => collator.compare(a.name, b.name));\n}\n\n/** The name of a region of a country in the locale, or `null` when Panneau doesn't know it. */\nexport function getRegionName(\n country: string | null | undefined,\n code: string,\n locale: string,\n): string | null {\n const entries = country !== null && country !== undefined ? REGIONS[country] : undefined;\n const entry = entries?.find((item) => item[0] === code);\n return entry !== undefined ? nameIn(entry, locale) : null;\n}\n"],"mappings":";;;AASA,IAAaI,mBAAsCC,OAAOC,KAAKN,OAAO;AAEtE,SAASO,OAAOC,OAA2CC,QAAwB;CAC/E,OAAOA,OAAOC,YAAY,CAAC,CAACC,WAAW,IAAI,IAAKH,MAAM,MAAMA,MAAM,KAAMA,MAAM;AAClF;;;;;AAMA,SAAgBI,WAAWC,SAAoCJ,QAAiC;CAC5F,MAAMK,UAAUD,YAAY,QAAQA,YAAYE,KAAAA,IAAYf,QAAQa,WAAWE,KAAAA;CAC/E,IAAID,YAAYC,KAAAA,GACZ,OAAO;CAEX,MAAMC,WAAW,IAAIC,KAAKC,SAAST,MAAM;CACzC,OAAOK,QACFK,KAAKX,WAAW;EAAEN,MAAMM,MAAM;EAAIL,MAAMI,OAAOC,OAAOC,MAAM;CAAE,EAAE,CAAC,CACjEW,MAAMC,GAAGC,MAAMN,SAASO,QAAQF,EAAElB,MAAMmB,EAAEnB,IAAI,CAAC;AACxD;;AAGA,SAAgBqB,cACZX,SACAX,MACAO,QACa;CAEb,MAAMD,SADUK,YAAY,QAAQA,YAAYE,KAAAA,IAAYf,QAAQa,WAAWE,KAAAA,EAAAA,EACxDU,MAAMC,SAASA,KAAK,OAAOxB,IAAI;CACtD,OAAOM,UAAUO,KAAAA,IAAYR,OAAOC,OAAOC,MAAM,IAAI;AACzD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FieldProps } from './types.js';
|
|
2
|
+
/** A choice of a code combo box: a code, its name, and a decorative prefix (a flag). */
|
|
3
|
+
export interface CodeChoice {
|
|
4
|
+
code: string;
|
|
5
|
+
name: string;
|
|
6
|
+
prefix?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CodeComboBoxProps extends Omit<FieldProps<string>, 'onChange'> {
|
|
9
|
+
choices: readonly CodeChoice[];
|
|
10
|
+
onChange?: ((value: string | null) => void) | undefined;
|
|
11
|
+
placeholder?: string | undefined;
|
|
12
|
+
emptyMessage: string;
|
|
13
|
+
controlClassName?: string | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A combo box of codes shown by their names (countries, regions): typing filters them by the start
|
|
17
|
+
* of a word of their name, or by their code. A value outside the choices shows as it is.
|
|
18
|
+
*/
|
|
19
|
+
export declare function CodeComboBox({ choices, value, onChange, onBlur, label, description, errors, disabled, readOnly, required, placeholder, name, id, autoFocus, emptyMessage, className, labelClassName, descriptionClassName, errorsClassName, controlClassName, ...props }: CodeComboBoxProps): import("react").JSX.Element;
|
|
20
|
+
//# sourceMappingURL=CodeComboBox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeComboBox.d.ts","sourceRoot":"","sources":["../../src/shared/CodeComboBox.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,wFAAwF;AACxF,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAC3E,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IAC/B,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACxD,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AAwBD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EACzB,OAAO,EACP,KAAK,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,WAAW,EACX,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,IAAI,EACJ,EAAE,EACF,SAAS,EACT,YAAY,EACZ,SAAS,EACT,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,GAAG,KAAK,EACX,EAAE,iBAAiB,+BA0DnB"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { ComboBox } from "@panneau/ui";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/shared/CodeComboBox.tsx
|
|
6
|
+
/** Lower case, without accents: `Québec` matches `quebec`. */
|
|
7
|
+
function normalize(text) {
|
|
8
|
+
return text.normalize("NFD").replace(/\p{Diacritic}/gu, "").toLowerCase();
|
|
9
|
+
}
|
|
10
|
+
function matches(choice, query) {
|
|
11
|
+
const text = normalize(query.trim());
|
|
12
|
+
if (text === "") return true;
|
|
13
|
+
return normalize(choice.name).split(/[\s'’-]+/).some((word) => word.startsWith(text)) || normalize(choice.name).startsWith(text) || choice.code.toLowerCase() === text;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A combo box of codes shown by their names (countries, regions): typing filters them by the start
|
|
17
|
+
* of a word of their name, or by their code. A value outside the choices shows as it is.
|
|
18
|
+
*/
|
|
19
|
+
function CodeComboBox(t0) {
|
|
20
|
+
const $ = c(71);
|
|
21
|
+
let autoFocus;
|
|
22
|
+
let choices;
|
|
23
|
+
let className;
|
|
24
|
+
let controlClassName;
|
|
25
|
+
let description;
|
|
26
|
+
let descriptionClassName;
|
|
27
|
+
let disabled;
|
|
28
|
+
let emptyMessage;
|
|
29
|
+
let errors;
|
|
30
|
+
let errorsClassName;
|
|
31
|
+
let id;
|
|
32
|
+
let label;
|
|
33
|
+
let labelClassName;
|
|
34
|
+
let name;
|
|
35
|
+
let onBlur;
|
|
36
|
+
let onChange;
|
|
37
|
+
let placeholder;
|
|
38
|
+
let props;
|
|
39
|
+
let readOnly;
|
|
40
|
+
let required;
|
|
41
|
+
let value;
|
|
42
|
+
if ($[0] !== t0) {
|
|
43
|
+
({choices, value, onChange, onBlur, label, description, errors, disabled, readOnly, required, placeholder, name, id, autoFocus, emptyMessage, className, labelClassName, descriptionClassName, errorsClassName, controlClassName, ...props} = t0);
|
|
44
|
+
$[0] = t0;
|
|
45
|
+
$[1] = autoFocus;
|
|
46
|
+
$[2] = choices;
|
|
47
|
+
$[3] = className;
|
|
48
|
+
$[4] = controlClassName;
|
|
49
|
+
$[5] = description;
|
|
50
|
+
$[6] = descriptionClassName;
|
|
51
|
+
$[7] = disabled;
|
|
52
|
+
$[8] = emptyMessage;
|
|
53
|
+
$[9] = errors;
|
|
54
|
+
$[10] = errorsClassName;
|
|
55
|
+
$[11] = id;
|
|
56
|
+
$[12] = label;
|
|
57
|
+
$[13] = labelClassName;
|
|
58
|
+
$[14] = name;
|
|
59
|
+
$[15] = onBlur;
|
|
60
|
+
$[16] = onChange;
|
|
61
|
+
$[17] = placeholder;
|
|
62
|
+
$[18] = props;
|
|
63
|
+
$[19] = readOnly;
|
|
64
|
+
$[20] = required;
|
|
65
|
+
$[21] = value;
|
|
66
|
+
} else {
|
|
67
|
+
autoFocus = $[1];
|
|
68
|
+
choices = $[2];
|
|
69
|
+
className = $[3];
|
|
70
|
+
controlClassName = $[4];
|
|
71
|
+
description = $[5];
|
|
72
|
+
descriptionClassName = $[6];
|
|
73
|
+
disabled = $[7];
|
|
74
|
+
emptyMessage = $[8];
|
|
75
|
+
errors = $[9];
|
|
76
|
+
errorsClassName = $[10];
|
|
77
|
+
id = $[11];
|
|
78
|
+
label = $[12];
|
|
79
|
+
labelClassName = $[13];
|
|
80
|
+
name = $[14];
|
|
81
|
+
onBlur = $[15];
|
|
82
|
+
onChange = $[16];
|
|
83
|
+
placeholder = $[17];
|
|
84
|
+
props = $[18];
|
|
85
|
+
readOnly = $[19];
|
|
86
|
+
required = $[20];
|
|
87
|
+
value = $[21];
|
|
88
|
+
}
|
|
89
|
+
const [query, setQuery] = useState(null);
|
|
90
|
+
const current = value !== null && value !== void 0 && value !== "" ? value : null;
|
|
91
|
+
let t1;
|
|
92
|
+
if ($[22] !== choices || $[23] !== current) {
|
|
93
|
+
t1 = current !== null ? choices.find((choice) => choice.code === current) : null;
|
|
94
|
+
$[22] = choices;
|
|
95
|
+
$[23] = current;
|
|
96
|
+
$[24] = t1;
|
|
97
|
+
} else t1 = $[24];
|
|
98
|
+
const selected = t1;
|
|
99
|
+
let t2;
|
|
100
|
+
if ($[25] !== choices || $[26] !== current || $[27] !== query || $[28] !== selected) {
|
|
101
|
+
t2 = (query !== null ? choices.filter((choice_0) => matches(choice_0, query)) : choices).concat(current !== null && selected === void 0 && query === null ? [{
|
|
102
|
+
code: current,
|
|
103
|
+
name: current
|
|
104
|
+
}] : []).map(_temp);
|
|
105
|
+
$[25] = choices;
|
|
106
|
+
$[26] = current;
|
|
107
|
+
$[27] = query;
|
|
108
|
+
$[28] = selected;
|
|
109
|
+
$[29] = t2;
|
|
110
|
+
} else t2 = $[29];
|
|
111
|
+
const items = t2;
|
|
112
|
+
let t3;
|
|
113
|
+
if ($[30] !== errors) {
|
|
114
|
+
t3 = errors ?? [];
|
|
115
|
+
$[30] = errors;
|
|
116
|
+
$[31] = t3;
|
|
117
|
+
} else t3 = $[31];
|
|
118
|
+
let t4;
|
|
119
|
+
if ($[32] !== controlClassName) {
|
|
120
|
+
t4 = controlClassName !== void 0 ? { controlClassName } : {};
|
|
121
|
+
$[32] = controlClassName;
|
|
122
|
+
$[33] = t4;
|
|
123
|
+
} else t4 = $[33];
|
|
124
|
+
let t5;
|
|
125
|
+
if ($[34] !== props) {
|
|
126
|
+
t5 = props["aria-label"] !== void 0 ? { "aria-label": props["aria-label"] } : {};
|
|
127
|
+
$[34] = props;
|
|
128
|
+
$[35] = t5;
|
|
129
|
+
} else t5 = $[35];
|
|
130
|
+
let t6;
|
|
131
|
+
if ($[36] !== name) {
|
|
132
|
+
t6 = name !== void 0 ? { name } : {};
|
|
133
|
+
$[36] = name;
|
|
134
|
+
$[37] = t6;
|
|
135
|
+
} else t6 = $[37];
|
|
136
|
+
let t7;
|
|
137
|
+
if ($[38] !== id) {
|
|
138
|
+
t7 = id !== void 0 ? { id } : {};
|
|
139
|
+
$[38] = id;
|
|
140
|
+
$[39] = t7;
|
|
141
|
+
} else t7 = $[39];
|
|
142
|
+
const t8 = query === null ? selected?.prefix : void 0;
|
|
143
|
+
const t9 = query ?? selected?.name ?? current ?? "";
|
|
144
|
+
let t10;
|
|
145
|
+
let t11;
|
|
146
|
+
if ($[40] !== current || $[41] !== onChange) {
|
|
147
|
+
t10 = (text) => {
|
|
148
|
+
setQuery(text);
|
|
149
|
+
if (text === "" && current !== null) onChange?.(null);
|
|
150
|
+
};
|
|
151
|
+
t11 = (code) => {
|
|
152
|
+
setQuery(null);
|
|
153
|
+
if (code !== null && code !== current) onChange?.(code);
|
|
154
|
+
};
|
|
155
|
+
$[40] = current;
|
|
156
|
+
$[41] = onChange;
|
|
157
|
+
$[42] = t10;
|
|
158
|
+
$[43] = t11;
|
|
159
|
+
} else {
|
|
160
|
+
t10 = $[42];
|
|
161
|
+
t11 = $[43];
|
|
162
|
+
}
|
|
163
|
+
let t12;
|
|
164
|
+
if ($[44] !== onBlur) {
|
|
165
|
+
t12 = () => {
|
|
166
|
+
setQuery(null);
|
|
167
|
+
onBlur?.();
|
|
168
|
+
};
|
|
169
|
+
$[44] = onBlur;
|
|
170
|
+
$[45] = t12;
|
|
171
|
+
} else t12 = $[45];
|
|
172
|
+
let t13;
|
|
173
|
+
if ($[46] !== autoFocus || $[47] !== className || $[48] !== current || $[49] !== description || $[50] !== descriptionClassName || $[51] !== disabled || $[52] !== emptyMessage || $[53] !== errorsClassName || $[54] !== items || $[55] !== label || $[56] !== labelClassName || $[57] !== placeholder || $[58] !== readOnly || $[59] !== required || $[60] !== t10 || $[61] !== t11 || $[62] !== t12 || $[63] !== t3 || $[64] !== t4 || $[65] !== t5 || $[66] !== t6 || $[67] !== t7 || $[68] !== t8 || $[69] !== t9) {
|
|
174
|
+
t13 = /* @__PURE__ */ jsx(ComboBox, {
|
|
175
|
+
label,
|
|
176
|
+
description,
|
|
177
|
+
errors: t3,
|
|
178
|
+
isRequired: required,
|
|
179
|
+
isDisabled: disabled,
|
|
180
|
+
isReadOnly: readOnly,
|
|
181
|
+
autoFocus,
|
|
182
|
+
className,
|
|
183
|
+
labelClassName,
|
|
184
|
+
descriptionClassName,
|
|
185
|
+
errorsClassName,
|
|
186
|
+
...t4,
|
|
187
|
+
...t5,
|
|
188
|
+
...t6,
|
|
189
|
+
...t7,
|
|
190
|
+
items,
|
|
191
|
+
value: current,
|
|
192
|
+
prefix: t8,
|
|
193
|
+
inputValue: t9,
|
|
194
|
+
onInputChange: t10,
|
|
195
|
+
onChange: t11,
|
|
196
|
+
onBlur: t12,
|
|
197
|
+
placeholder,
|
|
198
|
+
emptyMessage
|
|
199
|
+
});
|
|
200
|
+
$[46] = autoFocus;
|
|
201
|
+
$[47] = className;
|
|
202
|
+
$[48] = current;
|
|
203
|
+
$[49] = description;
|
|
204
|
+
$[50] = descriptionClassName;
|
|
205
|
+
$[51] = disabled;
|
|
206
|
+
$[52] = emptyMessage;
|
|
207
|
+
$[53] = errorsClassName;
|
|
208
|
+
$[54] = items;
|
|
209
|
+
$[55] = label;
|
|
210
|
+
$[56] = labelClassName;
|
|
211
|
+
$[57] = placeholder;
|
|
212
|
+
$[58] = readOnly;
|
|
213
|
+
$[59] = required;
|
|
214
|
+
$[60] = t10;
|
|
215
|
+
$[61] = t11;
|
|
216
|
+
$[62] = t12;
|
|
217
|
+
$[63] = t3;
|
|
218
|
+
$[64] = t4;
|
|
219
|
+
$[65] = t5;
|
|
220
|
+
$[66] = t6;
|
|
221
|
+
$[67] = t7;
|
|
222
|
+
$[68] = t8;
|
|
223
|
+
$[69] = t9;
|
|
224
|
+
$[70] = t13;
|
|
225
|
+
} else t13 = $[70];
|
|
226
|
+
return t13;
|
|
227
|
+
}
|
|
228
|
+
function _temp(choice_1) {
|
|
229
|
+
return {
|
|
230
|
+
id: choice_1.code,
|
|
231
|
+
label: choice_1.name,
|
|
232
|
+
...choice_1.prefix !== void 0 ? { prefix: choice_1.prefix } : {}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
//#endregion
|
|
236
|
+
export { CodeComboBox };
|
|
237
|
+
|
|
238
|
+
//# sourceMappingURL=CodeComboBox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeComboBox.js","names":["ReactNode","useState","ComboBox","FieldProps","CodeChoice","code","name","prefix","CodeComboBoxProps","Omit","choices","onChange","value","placeholder","emptyMessage","controlClassName","normalize","text","replace","toLowerCase","matches","choice","query","trim","split","some","word","startsWith","CodeComboBox","t0","$","_c","autoFocus","className","description","descriptionClassName","disabled","errors","errorsClassName","id","label","labelClassName","onBlur","props","readOnly","required","setQuery","current","undefined","t1","find","selected","t2","filter","choice_0","concat","map","_temp","items","t3","t4","t5","t6","t7","t8","t9","t10","t11","t12","t13","choice_1","_c"],"sources":["../../src/shared/CodeComboBox.tsx"],"sourcesContent":["import { type ReactNode, useState } from 'react';\n\nimport { ComboBox } from '@panneau/ui';\n\nimport type { FieldProps } from './types';\n\n/** A choice of a code combo box: a code, its name, and a decorative prefix (a flag). */\nexport interface CodeChoice {\n code: string;\n name: string;\n prefix?: string;\n}\n\nexport interface CodeComboBoxProps extends Omit<FieldProps<string>, 'onChange'> {\n choices: readonly CodeChoice[];\n onChange?: ((value: string | null) => void) | undefined;\n placeholder?: string | undefined;\n emptyMessage: string;\n controlClassName?: string | undefined;\n}\n\n/** Lower case, without accents: `Québec` matches `quebec`. */\nfunction normalize(text: string): string {\n return text\n .normalize('NFD')\n .replace(/\\p{Diacritic}/gu, '')\n .toLowerCase();\n}\n\nfunction matches(choice: CodeChoice, query: string): boolean {\n const text = normalize(query.trim());\n if (text === '') {\n return true;\n }\n return (\n normalize(choice.name)\n .split(/[\\s'’-]+/)\n .some((word) => word.startsWith(text)) ||\n normalize(choice.name).startsWith(text) ||\n choice.code.toLowerCase() === text\n );\n}\n\n/**\n * A combo box of codes shown by their names (countries, regions): typing filters them by the start\n * of a word of their name, or by their code. A value outside the choices shows as it is.\n */\nexport function CodeComboBox({\n choices,\n value,\n onChange,\n onBlur,\n label,\n description,\n errors,\n disabled,\n readOnly,\n required,\n placeholder,\n name,\n id,\n autoFocus,\n emptyMessage,\n className,\n labelClassName,\n descriptionClassName,\n errorsClassName,\n controlClassName,\n ...props\n}: CodeComboBoxProps) {\n // The text being typed, while the user searches; the name of the value otherwise.\n const [query, setQuery] = useState<string | null>(null);\n const current = value !== null && value !== undefined && value !== '' ? value : null;\n const selected = current !== null ? choices.find((choice) => choice.code === current) : null;\n const items = (query !== null ? choices.filter((choice) => matches(choice, query)) : choices)\n .concat(\n // A value outside the choices, kept from before, stays selectable as it is.\n current !== null && selected === undefined && query === null\n ? [{ code: current, name: current }]\n : [],\n )\n .map((choice): { id: string; label: string; prefix?: ReactNode } => ({\n id: choice.code,\n label: choice.name,\n ...(choice.prefix !== undefined ? { prefix: choice.prefix } : {}),\n }));\n return (\n <ComboBox\n label={label}\n description={description}\n errors={errors ?? []}\n isRequired={required}\n isDisabled={disabled}\n isReadOnly={readOnly}\n autoFocus={autoFocus}\n className={className}\n labelClassName={labelClassName}\n descriptionClassName={descriptionClassName}\n errorsClassName={errorsClassName}\n {...(controlClassName !== undefined ? { controlClassName } : {})}\n {...(props['aria-label'] !== undefined ? { 'aria-label': props['aria-label'] } : {})}\n {...(name !== undefined ? { name } : {})}\n {...(id !== undefined ? { id } : {})}\n items={items}\n value={current}\n prefix={query === null ? selected?.prefix : undefined}\n inputValue={query ?? selected?.name ?? current ?? ''}\n onInputChange={(text) => {\n setQuery(text);\n if (text === '' && current !== null) {\n onChange?.(null);\n }\n }}\n onChange={(code) => {\n setQuery(null);\n if (code !== null && code !== current) {\n onChange?.(code);\n }\n }}\n onBlur={() => {\n setQuery(null);\n onBlur?.();\n }}\n placeholder={placeholder}\n emptyMessage={emptyMessage}\n />\n );\n}\n"],"mappings":";;;;;;AAsBA,SAASgB,UAAUC,MAAsB;CACrC,OAAOA,KACFD,UAAU,KAAK,CAAC,CAChBE,QAAQ,mBAAmB,EAAE,CAAC,CAC9BC,YAAY;AACrB;AAEA,SAASC,QAAQC,QAAoBC,OAAwB;CACzD,MAAML,OAAOD,UAAUM,MAAMC,KAAK,CAAC;CACnC,IAAIN,SAAS,IACT,OAAO;CAEX,OACID,UAAUK,OAAOf,IAAI,CAAC,CACjBkB,MAAM,UAAU,CAAC,CACjBC,MAAMC,SAASA,KAAKC,WAAWV,IAAI,CAAC,KACzCD,UAAUK,OAAOf,IAAI,CAAC,CAACqB,WAAWV,IAAI,KACtCI,OAAOhB,KAAKc,YAAY,MAAMF;AAEtC;;;;;AAMA,SAAOW,aAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAtB;CAAA,IAAAuB;CAAA,IAAAlB;CAAA,IAAAmB;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAtB;CAAA,IAAAuB;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAnC;CAAA,IAAAoC;CAAA,IAAA/B;CAAA,IAAAE;CAAA,IAAA8B;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAjC;CAAA,IAAAkB,EAAA,OAAAD,IAAA;EAAsB,CAAA,CAAAnB,SAAAE,OAAAD,UAAA+B,QAAAF,OAAAN,aAAAG,QAAAD,UAAAQ,UAAAC,UAAAhC,aAAAP,MAAAiC,IAAAP,WAAAlB,cAAAmB,WAAAQ,gBAA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AkC;EAAAlC,EAAA,MAAAmC;EAAAnC,EAAA,MAAAuC;CAAA,OAAAA,MAAAvC,EAAA;CAAA,OAtCFuC;AAsCE;AA9EH,SAAAZ,MAAAa,UAAA;CAAA,OAkCsE;EAAA/B,IAC7DlB,SAAMhB;EAAKmC,OACRnB,SAAMf;EAAK,GACde,SAAMd,WAAYyC,KAAAA,IAAlB,EAAAzC,QAAwCc,SAAMd,OAAa,IAA3D,CAA2D;CACnE;AAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtIn.d.ts","sourceRoot":"","sources":["../../src/shared/builtIn.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"builtIn.d.ts","sourceRoot":"","sources":["../../src/shared/builtIn.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CA0B9D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAC7C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;CAK7D,CAAC"}
|
package/dist/shared/builtIn.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BooleanFieldEntry } from "../boolean/BooleanField.js";
|
|
2
2
|
import { TextFieldEntry } from "../text/TextField.js";
|
|
3
3
|
import { ColorFieldEntry } from "../color/ColorField.js";
|
|
4
|
+
import { CountryFieldEntry } from "../country/CountryField.js";
|
|
4
5
|
import { DateFieldEntry } from "../date/DateField.js";
|
|
5
6
|
import { DateTimeFieldEntry } from "../datetime/DateTimeField.js";
|
|
6
7
|
import { DurationFieldEntry } from "../duration/DurationField.js";
|
|
@@ -12,6 +13,7 @@ import { JsonFieldEntry } from "../json/JsonField.js";
|
|
|
12
13
|
import { LocationFieldEntry } from "../location/LocationField.js";
|
|
13
14
|
import { NumberFieldEntry } from "../number/NumberField.js";
|
|
14
15
|
import { RangeFieldEntry } from "../range/RangeField.js";
|
|
16
|
+
import { RegionFieldEntry } from "../region/RegionField.js";
|
|
15
17
|
import { RelationFieldEntry } from "../relation/RelationField.js";
|
|
16
18
|
import { RepeaterFieldEntry } from "../repeater/RepeaterField.js";
|
|
17
19
|
import { SelectFieldEntry } from "../select/SelectField.js";
|
|
@@ -52,7 +54,9 @@ var builtInFields = {
|
|
|
52
54
|
json: JsonFieldEntry,
|
|
53
55
|
tags: TagsFieldEntry,
|
|
54
56
|
embed: EmbedFieldEntry,
|
|
55
|
-
location: LocationFieldEntry
|
|
57
|
+
location: LocationFieldEntry,
|
|
58
|
+
country: CountryFieldEntry,
|
|
59
|
+
region: RegionFieldEntry
|
|
56
60
|
};
|
|
57
61
|
/**
|
|
58
62
|
* The built-in fields as a `@panneau/core` plugin: their entries, and the French messages of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtIn.js","names":["fr","BooleanFieldEntry","ColorFieldEntry","DateFieldEntry","DateTimeFieldEntry","DurationFieldEntry","EmailFieldEntry","EmbedFieldEntry","FileFieldEntry","GroupFieldEntry","JsonFieldEntry","LocationFieldEntry","NumberFieldEntry","RangeFieldEntry","RelationFieldEntry","RepeaterFieldEntry","SelectFieldEntry","SlugFieldEntry","TagsFieldEntry","TelFieldEntry","TextFieldEntry","TextAreaFieldEntry","TimeFieldEntry","UrlFieldEntry","FieldEntry","builtInFields","Readonly","Record","text","textarea","number","boolean","date","datetime","time","select","email","url","color","slug","file","relation","group","repeater","tel","range","duration","json","tags","embed","location","fieldsPlugin","id","fields","locales"],"sources":["../../src/shared/builtIn.ts"],"sourcesContent":["import { fr } from '@panneau/intl';\n\nimport { BooleanFieldEntry } from '../boolean/BooleanField';\nimport { ColorFieldEntry } from '../color/ColorField';\nimport { DateFieldEntry } from '../date/DateField';\nimport { DateTimeFieldEntry } from '../datetime/DateTimeField';\nimport { DurationFieldEntry } from '../duration/DurationField';\nimport { EmailFieldEntry } from '../email/EmailField';\nimport { EmbedFieldEntry } from '../embed/EmbedField';\nimport { FileFieldEntry } from '../file/FileField';\nimport { GroupFieldEntry } from '../group/GroupField';\nimport { JsonFieldEntry } from '../json/JsonField';\nimport { LocationFieldEntry } from '../location/LocationField';\nimport { NumberFieldEntry } from '../number/NumberField';\nimport { RangeFieldEntry } from '../range/RangeField';\nimport { RelationFieldEntry } from '../relation/RelationField';\nimport { RepeaterFieldEntry } from '../repeater/RepeaterField';\nimport { SelectFieldEntry } from '../select/SelectField';\nimport { SlugFieldEntry } from '../slug/SlugField';\nimport { TagsFieldEntry } from '../tags/TagsField';\nimport { TelFieldEntry } from '../tel/TelField';\nimport { TextFieldEntry } from '../text/TextField';\nimport { TextAreaFieldEntry } from '../textarea/TextAreaField';\nimport { TimeFieldEntry } from '../time/TimeField';\nimport { UrlFieldEntry } from '../url/UrlField';\nimport type { FieldEntry } from './types';\n\n/**\n * The entries of the built-in field types. `richtext` and `media` come with their plugins\n * (`@panneau/editor` and `@panneau/media`): without them, `DefinitionField` renders a placeholder.\n * `file` uploads through the upload source of the fields context, or gives the files themselves.\n * `embed` and `location` use its embed source and its maps; `location` loads Leaflet when shown.\n */\nexport const builtInFields: Readonly<Record<string, FieldEntry>> = {\n text: TextFieldEntry,\n textarea: TextAreaFieldEntry,\n number: NumberFieldEntry,\n boolean: BooleanFieldEntry,\n date: DateFieldEntry,\n datetime: DateTimeFieldEntry,\n time: TimeFieldEntry,\n select: SelectFieldEntry,\n email: EmailFieldEntry,\n url: UrlFieldEntry,\n color: ColorFieldEntry,\n slug: SlugFieldEntry,\n file: FileFieldEntry,\n relation: RelationFieldEntry,\n group: GroupFieldEntry,\n repeater: RepeaterFieldEntry,\n tel: TelFieldEntry,\n range: RangeFieldEntry,\n duration: DurationFieldEntry,\n json: JsonFieldEntry,\n tags: TagsFieldEntry,\n embed: EmbedFieldEntry,\n location: LocationFieldEntry,\n};\n\n/**\n * The built-in fields as a `@panneau/core` plugin: their entries, and the French messages of\n * every Panneau package (`@panneau/ui`, `@panneau/fields`, `@panneau/forms`…, from\n * `@panneau/intl`). Pass it before the plugins that override a type.\n */\nexport const fieldsPlugin: {\n id: string;\n fields: Readonly<Record<string, FieldEntry>>;\n locales: Readonly<Record<string, Record<string, string>>>;\n} = {\n id: 'panneau-fields',\n fields: builtInFields,\n locales: { fr },\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"builtIn.js","names":["fr","BooleanFieldEntry","ColorFieldEntry","CountryFieldEntry","DateFieldEntry","DateTimeFieldEntry","DurationFieldEntry","EmailFieldEntry","EmbedFieldEntry","FileFieldEntry","GroupFieldEntry","JsonFieldEntry","LocationFieldEntry","NumberFieldEntry","RangeFieldEntry","RegionFieldEntry","RelationFieldEntry","RepeaterFieldEntry","SelectFieldEntry","SlugFieldEntry","TagsFieldEntry","TelFieldEntry","TextFieldEntry","TextAreaFieldEntry","TimeFieldEntry","UrlFieldEntry","FieldEntry","builtInFields","Readonly","Record","text","textarea","number","boolean","date","datetime","time","select","email","url","color","slug","file","relation","group","repeater","tel","range","duration","json","tags","embed","location","country","region","fieldsPlugin","id","fields","locales"],"sources":["../../src/shared/builtIn.ts"],"sourcesContent":["import { fr } from '@panneau/intl';\n\nimport { BooleanFieldEntry } from '../boolean/BooleanField';\nimport { ColorFieldEntry } from '../color/ColorField';\nimport { CountryFieldEntry } from '../country/CountryField';\nimport { DateFieldEntry } from '../date/DateField';\nimport { DateTimeFieldEntry } from '../datetime/DateTimeField';\nimport { DurationFieldEntry } from '../duration/DurationField';\nimport { EmailFieldEntry } from '../email/EmailField';\nimport { EmbedFieldEntry } from '../embed/EmbedField';\nimport { FileFieldEntry } from '../file/FileField';\nimport { GroupFieldEntry } from '../group/GroupField';\nimport { JsonFieldEntry } from '../json/JsonField';\nimport { LocationFieldEntry } from '../location/LocationField';\nimport { NumberFieldEntry } from '../number/NumberField';\nimport { RangeFieldEntry } from '../range/RangeField';\nimport { RegionFieldEntry } from '../region/RegionField';\nimport { RelationFieldEntry } from '../relation/RelationField';\nimport { RepeaterFieldEntry } from '../repeater/RepeaterField';\nimport { SelectFieldEntry } from '../select/SelectField';\nimport { SlugFieldEntry } from '../slug/SlugField';\nimport { TagsFieldEntry } from '../tags/TagsField';\nimport { TelFieldEntry } from '../tel/TelField';\nimport { TextFieldEntry } from '../text/TextField';\nimport { TextAreaFieldEntry } from '../textarea/TextAreaField';\nimport { TimeFieldEntry } from '../time/TimeField';\nimport { UrlFieldEntry } from '../url/UrlField';\nimport type { FieldEntry } from './types';\n\n/**\n * The entries of the built-in field types. `richtext` and `media` come with their plugins\n * (`@panneau/editor` and `@panneau/media`): without them, `DefinitionField` renders a placeholder.\n * `file` uploads through the upload source of the fields context, or gives the files themselves.\n * `embed` and `location` use its embed source and its maps; `location` loads Leaflet when shown.\n */\nexport const builtInFields: Readonly<Record<string, FieldEntry>> = {\n text: TextFieldEntry,\n textarea: TextAreaFieldEntry,\n number: NumberFieldEntry,\n boolean: BooleanFieldEntry,\n date: DateFieldEntry,\n datetime: DateTimeFieldEntry,\n time: TimeFieldEntry,\n select: SelectFieldEntry,\n email: EmailFieldEntry,\n url: UrlFieldEntry,\n color: ColorFieldEntry,\n slug: SlugFieldEntry,\n file: FileFieldEntry,\n relation: RelationFieldEntry,\n group: GroupFieldEntry,\n repeater: RepeaterFieldEntry,\n tel: TelFieldEntry,\n range: RangeFieldEntry,\n duration: DurationFieldEntry,\n json: JsonFieldEntry,\n tags: TagsFieldEntry,\n embed: EmbedFieldEntry,\n location: LocationFieldEntry,\n country: CountryFieldEntry,\n region: RegionFieldEntry,\n};\n\n/**\n * The built-in fields as a `@panneau/core` plugin: their entries, and the French messages of\n * every Panneau package (`@panneau/ui`, `@panneau/fields`, `@panneau/forms`…, from\n * `@panneau/intl`). Pass it before the plugins that override a type.\n */\nexport const fieldsPlugin: {\n id: string;\n fields: Readonly<Record<string, FieldEntry>>;\n locales: Readonly<Record<string, Record<string, string>>>;\n} = {\n id: 'panneau-fields',\n fields: builtInFields,\n locales: { fr },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,IAAa2B,gBAAsD;CAC/DG,MAAMR;CACNS,UAAUR;CACVS,QAAQnB;CACRoB,SAAShC;CACTiC,MAAM9B;CACN+B,UAAU9B;CACV+B,MAAMZ;CACNa,QAAQnB;CACRoB,OAAO/B;CACPgC,KAAKd;CACLe,OAAOtC;CACPuC,MAAMtB;CACNuB,MAAMjC;CACNkC,UAAU3B;CACV4B,OAAOlC;CACPmC,UAAU5B;CACV6B,KAAKzB;CACL0B,OAAOjC;CACPkC,UAAU1C;CACV2C,MAAMtC;CACNuC,MAAM9B;CACN+B,OAAO3C;CACP4C,UAAUxC;CACVyC,SAASlD;CACTmD,QAAQvC;AACZ;;;;;;AAOA,IAAawC,eAIT;CACAC,IAAI;CACJC,QAAQ9B;CACR+B,SAAS,EAAE1D,GAAG;AAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../src/shared/entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE3D;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,CAI3E;AAED,8DAA8D;AAC9D,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,GAAG,KAAK,GAAG,MA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EAA+E;AAC/E,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,CAAC,iBAG9F;AAED,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAmC,CAAC;AACvF,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,OAAqC,CAAC;AAC1F,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MACE,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,aAAa,CACzB,KAAK,EAAE,eAAe,GACvB,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAkB1E;AAED,wCAAwC;AACxC,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAEtD;AAED,+FAA+F;AAC/F,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE,GAAG,IAAI,CAQvD;AAED,iEAAiE;AACjE,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAGtD"}
|
package/dist/shared/entry.js
CHANGED
|
@@ -38,7 +38,7 @@ function getFieldProps(props) {
|
|
|
38
38
|
description: field.help,
|
|
39
39
|
...field.placeholder !== void 0 ? { placeholder: field.placeholder } : {},
|
|
40
40
|
required: isRequired(field),
|
|
41
|
-
readOnly: props.readOnly === true || field.readOnly === true,
|
|
41
|
+
readOnly: props.readOnly === true || field.readOnly === true || field.abilities?.update === false,
|
|
42
42
|
disabled: props.disabled === true,
|
|
43
43
|
errors: props.errors ?? [],
|
|
44
44
|
...props.onBlur !== void 0 ? { onBlur: props.onBlur } : {},
|
package/dist/shared/entry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.js","names":["Field","Rule","FieldEntryProps","FieldProps","findRule","field","rule","rules","find","candidate","mode","undefined","getRuleNumber","found","value","isRequired","getSetting","name","guard","T","settings","isString","isBoolean","isNumber","Number","isNaN","getFieldProps","props","Omit","placeholder","label","path","hideLabel","description","help","required","readOnly","disabled","errors","onBlur","className","asString","getAccept","accept","length","Array","isArray","filter","getMaxSize"],"sources":["../../src/shared/entry.ts"],"sourcesContent":["import type { Field, Rule } from '@panneau/protocol';\n\nimport type { FieldEntryProps, FieldProps } from './types';\n\n/**\n * The rule of a field with this name, if any. A rule limited to a mode (`\"mode\": \"create\"`)\n * doesn't count: forms keep it, without its `mode`, in that mode only (`resolveFields()` of\n * `@panneau/core`).\n */\nexport function findRule(field: Field, rule: Rule['rule']): Rule | undefined {\n return field.rules?.find(\n (candidate) => candidate.rule === rule && candidate.mode === undefined,\n );\n}\n\n/** The number of a `min` or `max` rule of a field, if any. */\nexport function getRuleNumber(field: Field, rule: 'min' | 'max'): number | undefined {\n const found = findRule(field, rule);\n return found !== undefined && 'value' in found && typeof found.value === 'number'\n ? found.value\n : undefined;\n}\n\n/** Whether a field has the `required` rule. */\nexport function isRequired(field: Field): boolean {\n return findRule(field, 'required') !== undefined;\n}\n\n/** A setting of a field (`settings.<name>`), when it has the expected type. */\nexport function getSetting<T>(field: Field, name: string, guard: (value: unknown) => value is T) {\n const value = field.settings?.[name];\n return guard(value) ? value : undefined;\n}\n\nexport const isString = (value: unknown): value is string => typeof value === 'string';\nexport const isBoolean = (value: unknown): value is boolean => typeof value === 'boolean';\nexport const isNumber = (value: unknown): value is number =>\n typeof value === 'number' && !Number.isNaN(value);\n\n/**\n * The props that every field takes, from a registry entry's props: label (the field's name\n * without one, or `aria-label` with `hideLabel`), help, required mark, read-only, errors and\n * handlers. Plugins use it to write their own entries.\n */\nexport function getFieldProps(\n props: FieldEntryProps,\n): Omit<FieldProps<never>, 'value' | 'onChange'> & { placeholder?: string } {\n const { field } = props;\n // A field always has a label: its name when the definition gives none.\n const label = field.label ?? field.name;\n return {\n name: props.path,\n ...(props.hideLabel === true ? { 'aria-label': label } : { label }),\n description: field.help,\n ...(field.placeholder !== undefined ? { placeholder: field.placeholder } : {}),\n required: isRequired(field),\n
|
|
1
|
+
{"version":3,"file":"entry.js","names":["Field","Rule","FieldEntryProps","FieldProps","findRule","field","rule","rules","find","candidate","mode","undefined","getRuleNumber","found","value","isRequired","getSetting","name","guard","T","settings","isString","isBoolean","isNumber","Number","isNaN","getFieldProps","props","Omit","placeholder","label","path","hideLabel","description","help","required","readOnly","abilities","update","disabled","errors","onBlur","className","asString","getAccept","accept","length","Array","isArray","filter","getMaxSize"],"sources":["../../src/shared/entry.ts"],"sourcesContent":["import type { Field, Rule } from '@panneau/protocol';\n\nimport type { FieldEntryProps, FieldProps } from './types';\n\n/**\n * The rule of a field with this name, if any. A rule limited to a mode (`\"mode\": \"create\"`)\n * doesn't count: forms keep it, without its `mode`, in that mode only (`resolveFields()` of\n * `@panneau/core`).\n */\nexport function findRule(field: Field, rule: Rule['rule']): Rule | undefined {\n return field.rules?.find(\n (candidate) => candidate.rule === rule && candidate.mode === undefined,\n );\n}\n\n/** The number of a `min` or `max` rule of a field, if any. */\nexport function getRuleNumber(field: Field, rule: 'min' | 'max'): number | undefined {\n const found = findRule(field, rule);\n return found !== undefined && 'value' in found && typeof found.value === 'number'\n ? found.value\n : undefined;\n}\n\n/** Whether a field has the `required` rule. */\nexport function isRequired(field: Field): boolean {\n return findRule(field, 'required') !== undefined;\n}\n\n/** A setting of a field (`settings.<name>`), when it has the expected type. */\nexport function getSetting<T>(field: Field, name: string, guard: (value: unknown) => value is T) {\n const value = field.settings?.[name];\n return guard(value) ? value : undefined;\n}\n\nexport const isString = (value: unknown): value is string => typeof value === 'string';\nexport const isBoolean = (value: unknown): value is boolean => typeof value === 'boolean';\nexport const isNumber = (value: unknown): value is number =>\n typeof value === 'number' && !Number.isNaN(value);\n\n/**\n * The props that every field takes, from a registry entry's props: label (the field's name\n * without one, or `aria-label` with `hideLabel`), help, required mark, read-only, errors and\n * handlers. Plugins use it to write their own entries.\n */\nexport function getFieldProps(\n props: FieldEntryProps,\n): Omit<FieldProps<never>, 'value' | 'onChange'> & { placeholder?: string } {\n const { field } = props;\n // A field always has a label: its name when the definition gives none.\n const label = field.label ?? field.name;\n return {\n name: props.path,\n ...(props.hideLabel === true ? { 'aria-label': label } : { label }),\n description: field.help,\n ...(field.placeholder !== undefined ? { placeholder: field.placeholder } : {}),\n required: isRequired(field),\n // A field the user can't edit is read-only (`abilities.update: false`, decision 0046)\n readOnly:\n props.readOnly === true || field.readOnly === true || field.abilities?.update === false,\n disabled: props.disabled === true,\n errors: props.errors ?? [],\n ...(props.onBlur !== undefined ? { onBlur: props.onBlur } : {}),\n ...(props.className !== undefined ? { className: props.className } : {}),\n };\n}\n\n/** The value as a string, or `null`. */\nexport function asString(value: unknown): string | null {\n return typeof value === 'string' ? value : null;\n}\n\n/** The accepted MIME types of a field that takes files: its `accept`, or its `accept` rule. */\nexport function getAccept(field: Field): string[] | null {\n if (field.accept !== undefined && field.accept.length > 0) {\n return field.accept;\n }\n const rule = findRule(field, 'accept');\n return rule !== undefined && 'value' in rule && Array.isArray(rule.value)\n ? rule.value.filter(isString)\n : null;\n}\n\n/** The largest file of a field, in bytes: its `maxSize` rule. */\nexport function getMaxSize(field: Field): number | null {\n const rule = findRule(field, 'maxSize');\n return rule !== undefined && 'value' in rule && isNumber(rule.value) ? rule.value : null;\n}\n"],"mappings":";;;;;;AASA,SAAgBI,SAASC,OAAcC,MAAsC;CACzE,OAAOD,MAAME,OAAOC,MACfC,cAAcA,UAAUH,SAASA,QAAQG,UAAUC,SAASC,KAAAA,CACjE;AACJ;;AAGA,SAAgBC,cAAcP,OAAcC,MAAyC;CACjF,MAAMO,QAAQT,SAASC,OAAOC,IAAI;CAClC,OAAOO,UAAUF,KAAAA,KAAa,WAAWE,SAAS,OAAOA,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B,MAAMvC,OAAOF,SAASC,OAAO,QAAQ;CACrC,OAAOC,SAASK,KAAAA,KAAa,WAAWL,QAAQyC,MAAMC,QAAQ1C,KAAKQ,KAAK,IAClER,KAAKQ,MAAMmC,OAAO5B,QAAQ,IAC1B;AACV;;AAGA,SAAgB6B,WAAW7C,OAA6B;CACpD,MAAMC,OAAOF,SAASC,OAAO,SAAS;CACtC,OAAOC,SAASK,KAAAA,KAAa,WAAWL,QAAQiB,SAASjB,KAAKQ,KAAK,IAAIR,KAAKQ,QAAQ;AACxF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../src/shared/flow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../src/shared/flow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAyB/C;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CASjD"}
|
package/dist/shared/flow.js
CHANGED
package/dist/shared/flow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow.js","names":["Field","getSetting","isString","COMPACT_TYPES","Set","isWideField","field","localized","multiple","widget","type","undefined","has"],"sources":["../../src/shared/flow.ts"],"sourcesContent":["import type { Field } from '@panneau/protocol';\n\nimport { getSetting, isString } from './entry';\n\n/** Types whose input is short: they share a row with others in a flow of fields. */\nconst COMPACT_TYPES = new Set([\n 'text',\n 'email',\n 'url',\n 'tel',\n 'number',\n 'date',\n 'datetime',\n 'time',\n 'duration',\n 'color',\n 'select',\n 'boolean',\n 'range',\n 'slug',\n 'relation',\n]);\n\n/**\n * Whether a field takes a whole row where fields flow in columns, such as in a form without a\n * layout or in a group: long inputs (a text area, rich text, blocks), several values, a value per\n * locale, and the types of plugins. Short inputs share a row.\n */\nexport function isWideField(field: Field): boolean {\n if (field.localized === true || field.multiple === true) {\n return true;\n }\n const widget = getSetting(field, 'widget', isString);\n if (field.type === 'select' && widget !== undefined && widget !== 'dropdown') {\n return true;\n }\n return !COMPACT_TYPES.has(field.type);\n}\n"],"mappings":";;;AAKA,IAAMG,gCAAgB,IAAIC,IAAI;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAAU,CACb;;;;;;AAOD,SAAgBC,YAAYC,OAAuB;CAC/C,IAAIA,MAAMC,cAAc,QAAQD,MAAME,aAAa,MAC/C,OAAO;CAEX,MAAMC,SAASR,WAAWK,OAAO,UAAUJ,QAAQ;CACnD,IAAII,MAAMI,SAAS,YAAYD,WAAWE,KAAAA,KAAaF,WAAW,YAC9D,OAAO;CAEX,OAAO,CAACN,cAAcS,IAAIN,MAAMI,IAAI;AACxC"}
|
|
1
|
+
{"version":3,"file":"flow.js","names":["Field","getSetting","isString","COMPACT_TYPES","Set","isWideField","field","localized","multiple","widget","type","undefined","has"],"sources":["../../src/shared/flow.ts"],"sourcesContent":["import type { Field } from '@panneau/protocol';\n\nimport { getSetting, isString } from './entry';\n\n/** Types whose input is short: they share a row with others in a flow of fields. */\nconst COMPACT_TYPES = new Set([\n 'text',\n 'email',\n 'url',\n 'tel',\n 'country',\n 'region',\n 'number',\n 'date',\n 'datetime',\n 'time',\n 'duration',\n 'color',\n 'select',\n 'boolean',\n 'range',\n 'slug',\n 'relation',\n]);\n\n/**\n * Whether a field takes a whole row where fields flow in columns, such as in a form without a\n * layout or in a group: long inputs (a text area, rich text, blocks), several values, a value per\n * locale, and the types of plugins. Short inputs share a row.\n */\nexport function isWideField(field: Field): boolean {\n if (field.localized === true || field.multiple === true) {\n return true;\n }\n const widget = getSetting(field, 'widget', isString);\n if (field.type === 'select' && widget !== undefined && widget !== 'dropdown') {\n return true;\n }\n return !COMPACT_TYPES.has(field.type);\n}\n"],"mappings":";;;AAKA,IAAMG,gCAAgB,IAAIC,IAAI;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAAU,CACb;;;;;;AAOD,SAAgBC,YAAYC,OAAuB;CAC/C,IAAIA,MAAMC,cAAc,QAAQD,MAAME,aAAa,MAC/C,OAAO;CAEX,MAAMC,SAASR,WAAWK,OAAO,UAAUJ,QAAQ;CACnD,IAAII,MAAMI,SAAS,YAAYD,WAAWE,KAAAA,KAAaF,WAAW,YAC9D,OAAO;CAEX,OAAO,CAACN,cAAcS,IAAIN,MAAMI,IAAI;AACxC"}
|
package/dist/tel/TelField.d.ts
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import type { FieldEntryProps } from '../shared/types.js';
|
|
2
2
|
import { type TextFieldProps } from '../text/TextField.js';
|
|
3
|
-
export
|
|
3
|
+
export interface TelFieldProps extends Omit<TextFieldProps, 'type' | 'inputMode' | 'prefix' | 'maxLength' | 'secret'> {
|
|
4
|
+
/**
|
|
5
|
+
* The country of a new number (`CA`). Without it, the region of the user's locale (`fr-CA`
|
|
6
|
+
* gives `CA`).
|
|
7
|
+
*/
|
|
8
|
+
country?: string | null;
|
|
9
|
+
}
|
|
4
10
|
/**
|
|
5
|
-
* A phone number,
|
|
6
|
-
*
|
|
11
|
+
* A phone number, in E.164 (`+15145550199`). The country of the number, its flag and its calling
|
|
12
|
+
* code, is in a menu at the start of the input, and the number shows in the format of its country
|
|
13
|
+
* as it is typed. The country follows the number: typing `+33…` picks France.
|
|
14
|
+
*
|
|
15
|
+
* Until a number is complete, the value is the text as typed, which the `tel` rule refuses. A value
|
|
16
|
+
* that isn't E.164, kept from before, shows as it is, and becomes E.164 when the field is left, if
|
|
17
|
+
* it reads as a number of the chosen country.
|
|
7
18
|
*/
|
|
8
|
-
export declare function TelField({ value, onChange, onBlur, ...props }: TelFieldProps): import("react").JSX.Element;
|
|
9
|
-
/** The `tel` type. */
|
|
19
|
+
export declare function TelField({ value, onChange, onBlur, country: defaultCountry, disabled, readOnly, ...props }: TelFieldProps): import("react").JSX.Element;
|
|
20
|
+
/** The `tel` type: `settings.country` is the country of a new number. */
|
|
10
21
|
export declare function TelFieldEntry(props: FieldEntryProps): import("react").JSX.Element;
|
|
11
22
|
//# sourceMappingURL=TelField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TelField.d.ts","sourceRoot":"","sources":["../../src/tel/TelField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TelField.d.ts","sourceRoot":"","sources":["../../src/tel/TelField.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AASnE,MAAM,WAAW,aAAc,SAAQ,IAAI,CACvC,cAAc,EACd,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAC3D;IACG;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAaD;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,EACrB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,OAAO,EAAE,cAAc,EACvB,QAAQ,EACR,QAAQ,EACR,GAAG,KAAK,EACX,EAAE,aAAa,+BAwFf;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,+BAUnD"}
|