@panneau/fields 5.0.0-alpha.14 → 5.0.0-alpha.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -3
- package/dist/address/AddressField.css +44 -0
- package/dist/address/AddressField.d.ts +37 -0
- package/dist/address/AddressField.d.ts.map +1 -0
- package/dist/address/AddressField.js +411 -0
- package/dist/address/AddressField.js.map +1 -0
- package/dist/address/AddressField.module.js +22 -0
- package/dist/address/AddressField.module.js.map +1 -0
- package/dist/address/address.d.ts +23 -0
- package/dist/address/address.d.ts.map +1 -0
- package/dist/address/address.js +58 -0
- package/dist/address/address.js.map +1 -0
- package/dist/address/index.d.ts +3 -0
- package/dist/address/index.d.ts.map +1 -0
- package/dist/address/index.js +3 -0
- package/dist/color/ColorField.css +9 -0
- package/dist/color/ColorField.d.ts +10 -3
- package/dist/color/ColorField.d.ts.map +1 -1
- package/dist/color/ColorField.js +341 -81
- package/dist/color/ColorField.js.map +1 -1
- package/dist/color/ColorField.module.js +4 -2
- package/dist/color/ColorField.module.js.map +1 -1
- package/dist/color/index.d.ts +1 -0
- package/dist/color/index.d.ts.map +1 -1
- package/dist/color/index.js +3 -1
- package/dist/color/palette.d.ts +23 -0
- package/dist/color/palette.d.ts.map +1 -0
- package/dist/color/palette.js +34 -0
- package/dist/color/palette.js.map +1 -0
- package/dist/country/CountryField.css +42 -0
- package/dist/country/CountryField.d.ts +19 -4
- package/dist/country/CountryField.d.ts.map +1 -1
- package/dist/country/CountryField.js +355 -82
- package/dist/country/CountryField.js.map +1 -1
- package/dist/country/CountryField.module.js +20 -0
- package/dist/country/CountryField.module.js.map +1 -0
- package/dist/country/index.d.ts +1 -1
- package/dist/country/index.d.ts.map +1 -1
- package/dist/daterange/DateRangeField.css +9 -0
- package/dist/daterange/DateRangeField.d.ts +31 -0
- package/dist/daterange/DateRangeField.d.ts.map +1 -0
- package/dist/daterange/DateRangeField.js +372 -0
- package/dist/daterange/DateRangeField.js.map +1 -0
- package/dist/daterange/DateRangeField.module.js +12 -0
- package/dist/daterange/DateRangeField.module.js.map +1 -0
- package/dist/daterange/index.d.ts +3 -0
- package/dist/daterange/index.d.ts.map +1 -0
- package/dist/daterange/index.js +3 -0
- package/dist/daterange/range.d.ts +61 -0
- package/dist/daterange/range.d.ts.map +1 -0
- package/dist/daterange/range.js +119 -0
- package/dist/daterange/range.js.map +1 -0
- package/dist/duration/DurationField.css +1 -1
- package/dist/duration/DurationField.d.ts +54 -13
- package/dist/duration/DurationField.d.ts.map +1 -1
- package/dist/duration/DurationField.js +205 -159
- package/dist/duration/DurationField.js.map +1 -1
- package/dist/duration/DurationField.module.js.map +1 -1
- package/dist/duration/index.d.ts +1 -1
- package/dist/duration/index.d.ts.map +1 -1
- package/dist/duration/index.js +1 -1
- package/dist/embed/EmbedField.d.ts +11 -2
- package/dist/embed/EmbedField.d.ts.map +1 -1
- package/dist/embed/EmbedField.js +179 -116
- package/dist/embed/EmbedField.js.map +1 -1
- package/dist/link/LinkField.css +12 -0
- package/dist/link/LinkField.d.ts +38 -0
- package/dist/link/LinkField.d.ts.map +1 -0
- package/dist/link/LinkField.js +742 -0
- package/dist/link/LinkField.js.map +1 -0
- package/dist/link/LinkField.module.js +8 -0
- package/dist/link/LinkField.module.js.map +1 -0
- package/dist/link/index.d.ts +3 -0
- package/dist/link/index.d.ts.map +1 -0
- package/dist/link/index.js +3 -0
- package/dist/link/link.d.ts +30 -0
- package/dist/link/link.d.ts.map +1 -0
- package/dist/link/link.js +63 -0
- package/dist/link/link.js.map +1 -0
- package/dist/link/pages.d.ts +17 -0
- package/dist/link/pages.d.ts.map +1 -0
- package/dist/link/pages.js +104 -0
- package/dist/link/pages.js.map +1 -0
- package/dist/location/LocationField.d.ts.map +1 -1
- package/dist/location/LocationField.js +9 -85
- package/dist/location/LocationField.js.map +1 -1
- package/dist/location/nominatim.d.ts +8 -2
- package/dist/location/nominatim.d.ts.map +1 -1
- package/dist/location/nominatim.js +32 -3
- package/dist/location/nominatim.js.map +1 -1
- package/dist/location/search.d.ts +10 -0
- package/dist/location/search.d.ts.map +1 -0
- package/dist/location/search.js +83 -0
- package/dist/location/search.js.map +1 -0
- package/dist/location/types.d.ts +8 -2
- package/dist/location/types.d.ts.map +1 -1
- package/dist/money/MoneyField.d.ts +28 -0
- package/dist/money/MoneyField.d.ts.map +1 -0
- package/dist/money/MoneyField.js +269 -0
- package/dist/money/MoneyField.js.map +1 -0
- package/dist/money/index.d.ts +3 -0
- package/dist/money/index.d.ts.map +1 -0
- package/dist/money/index.js +3 -0
- package/dist/money/money.d.ts +27 -0
- package/dist/money/money.d.ts.map +1 -0
- package/dist/money/money.js +56 -0
- package/dist/money/money.js.map +1 -0
- package/dist/region/RegionField.js +1 -1
- package/dist/shared/builtIn.d.ts +3 -1
- package/dist/shared/builtIn.d.ts.map +1 -1
- package/dist/shared/builtIn.js +18 -8
- package/dist/shared/builtIn.js.map +1 -1
- package/dist/shared/dates.js +2 -2
- package/dist/shared/dates.js.map +1 -1
- package/dist/shared/flow.d.ts.map +1 -1
- package/dist/shared/flow.js +1 -0
- package/dist/shared/flow.js.map +1 -1
- package/dist/shared/part.d.ts +26 -0
- package/dist/shared/part.d.ts.map +1 -0
- package/dist/shared/part.js +64 -0
- package/dist/shared/part.js.map +1 -0
- package/dist/tel/TelField.css +25 -0
- package/dist/tel/TelField.d.ts +14 -2
- package/dist/tel/TelField.d.ts.map +1 -1
- package/dist/tel/TelField.js +246 -145
- package/dist/tel/TelField.js.map +1 -1
- package/dist/tel/TelField.module.js +12 -0
- package/dist/tel/TelField.module.js.map +1 -0
- package/dist/tel/index.d.ts +1 -1
- package/dist/tel/index.d.ts.map +1 -1
- package/dist/tel/index.js +2 -2
- package/dist/tel/phone.d.ts +28 -0
- package/dist/tel/phone.d.ts.map +1 -1
- package/dist/tel/phone.js +48 -1
- package/dist/tel/phone.js.map +1 -1
- package/dist/url/UrlField.d.ts.map +1 -1
- package/dist/url/UrlField.js +1 -1
- package/dist/url/UrlField.js.map +1 -1
- package/package.json +24 -4
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { getParentPath, useFieldsContext } from "./context.js";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/shared/part.tsx
|
|
5
|
+
/**
|
|
6
|
+
* A part of a value that a field edits itself (the postal code of an address, the URL of a link):
|
|
7
|
+
* the field keeps its whole value, and the binding of the fields context gives each part the
|
|
8
|
+
* errors of its own path, and marks it touched when it loses focus. Without a binding, the part
|
|
9
|
+
* gets `errors` and `onBlur`.
|
|
10
|
+
*/
|
|
11
|
+
function BoundPart(t0) {
|
|
12
|
+
const $ = c(14);
|
|
13
|
+
const { field, path, errors, onBlur, render } = t0;
|
|
14
|
+
const { binding: Binding } = useFieldsContext();
|
|
15
|
+
if (Binding === null) {
|
|
16
|
+
let t1;
|
|
17
|
+
if ($[0] !== errors || $[1] !== onBlur || $[2] !== render) {
|
|
18
|
+
t1 = render({
|
|
19
|
+
...errors !== void 0 ? { errors } : {},
|
|
20
|
+
...onBlur !== void 0 ? { onBlur } : {}
|
|
21
|
+
});
|
|
22
|
+
$[0] = errors;
|
|
23
|
+
$[1] = onBlur;
|
|
24
|
+
$[2] = render;
|
|
25
|
+
$[3] = t1;
|
|
26
|
+
} else t1 = $[3];
|
|
27
|
+
return t1;
|
|
28
|
+
}
|
|
29
|
+
let t1;
|
|
30
|
+
if ($[4] !== path) {
|
|
31
|
+
t1 = getParentPath(path);
|
|
32
|
+
$[4] = path;
|
|
33
|
+
$[5] = t1;
|
|
34
|
+
} else t1 = $[5];
|
|
35
|
+
let t2;
|
|
36
|
+
if ($[6] !== render) {
|
|
37
|
+
t2 = (bound) => render({
|
|
38
|
+
...bound.errors !== void 0 ? { errors: bound.errors } : {},
|
|
39
|
+
...bound.onBlur !== void 0 ? { onBlur: bound.onBlur } : {}
|
|
40
|
+
});
|
|
41
|
+
$[6] = render;
|
|
42
|
+
$[7] = t2;
|
|
43
|
+
} else t2 = $[7];
|
|
44
|
+
let t3;
|
|
45
|
+
if ($[8] !== Binding || $[9] !== field || $[10] !== path || $[11] !== t1 || $[12] !== t2) {
|
|
46
|
+
t3 = /* @__PURE__ */ jsx(Binding, {
|
|
47
|
+
field,
|
|
48
|
+
path,
|
|
49
|
+
parentPath: t1,
|
|
50
|
+
render: t2
|
|
51
|
+
});
|
|
52
|
+
$[8] = Binding;
|
|
53
|
+
$[9] = field;
|
|
54
|
+
$[10] = path;
|
|
55
|
+
$[11] = t1;
|
|
56
|
+
$[12] = t2;
|
|
57
|
+
$[13] = t3;
|
|
58
|
+
} else t3 = $[13];
|
|
59
|
+
return t3;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { BoundPart };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=part.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"part.js","names":["ReactNode","Field","getParentPath","useFieldsContext","BoundPartProps","errors","onBlur","PartBindingProps","field","path","render","bound","BoundPart","t0","$","_c","binding","Binding","t1","undefined","t2","t3","_c"],"sources":["../../src/shared/part.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport type { Field } from '@panneau/protocol';\n\nimport { getParentPath, useFieldsContext } from './context';\n\n/** What a part of a value gets from the binding of the fields context: its errors and its blur. */\nexport interface BoundPartProps {\n errors?: readonly string[];\n onBlur?: () => void;\n}\n\nexport interface PartBindingProps {\n /** The part, as a field of the definition: the binding reads its errors by its path. */\n field: Field;\n /** Dot path of the part (`address.postalCode`). */\n path: string;\n /** Errors of the part without a binding. */\n errors?: readonly string[];\n /** Blur of the part without a binding. */\n onBlur?: () => void;\n render: (bound: BoundPartProps) => ReactNode;\n}\n\n/**\n * A part of a value that a field edits itself (the postal code of an address, the URL of a link):\n * the field keeps its whole value, and the binding of the fields context gives each part the\n * errors of its own path, and marks it touched when it loses focus. Without a binding, the part\n * gets `errors` and `onBlur`.\n */\nexport function BoundPart({ field, path, errors, onBlur, render }: PartBindingProps) {\n const { binding: Binding } = useFieldsContext();\n if (Binding === null) {\n return render({\n ...(errors !== undefined ? { errors } : {}),\n ...(onBlur !== undefined ? { onBlur } : {}),\n });\n }\n return (\n <Binding\n field={field}\n path={path}\n parentPath={getParentPath(path)}\n render={(bound) =>\n render({\n ...(bound.errors !== undefined ? { errors: bound.errors } : {}),\n ...(bound.onBlur !== undefined ? { onBlur: bound.onBlur } : {}),\n })\n }\n />\n );\n}\n"],"mappings":";;;;;;;;;;AA8BA,SAAOY,UAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAmB,MAAA,EAAAP,OAAAC,MAAAJ,QAAAC,QAAAI,WAAAG;CACtB,MAAA,EAAAG,SAAAC,YAA6Bd,iBAAiB;CAC9C,IAAIc,YAAY,MAAI;EAAA,IAAAC;EAAA,IAAAJ,EAAA,OAAAT,UAAAS,EAAA,OAAAR,UAAAQ,EAAA,OAAAJ,QAAA;GACTQ,KAAAR,OAAO;IAAA,GACNL,WAAWc,KAAAA,IAAX,EAAAd,OAAqC,IAArC,CAAqC;IAAC,GACtCC,WAAWa,KAAAA,IAAX,EAAAb,OAAqC,IAArC,CAAqC;GAC7C,CAAC;GAACQ,EAAA,KAAAT;GAAAS,EAAA,KAAAR;GAAAQ,EAAA,KAAAJ;GAAAI,EAAA,KAAAI;EAAA,OAAAA,KAAAJ,EAAA;EAAA,OAHKI;CAGL;CACL,IAAAA;CAAA,IAAAJ,EAAA,OAAAL,MAAA;EAKmBS,KAAAhB,cAAcO,IAAI;EAACK,EAAA,KAAAL;EAAAK,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAM;CAAA,IAAAN,EAAA,OAAAJ,QAAA;EACvBU,MAAAT,UACJD,OAAO;GAAA,GACCC,MAAKN,WAAYc,KAAAA,IAAjB,EAAAd,QAAuCM,MAAKN,OAAa,IAAzD,CAAyD;GAAC,GAC1DM,MAAKL,WAAYa,KAAAA,IAAjB,EAAAb,QAAuCK,MAAKL,OAAa,IAAzD,CAAyD;EACjE,CAAC;EAACQ,EAAA,KAAAJ;EAAAI,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAAA,IAAAO;CAAA,IAAAP,EAAA,OAAAG,WAAAH,EAAA,OAAAN,SAAAM,EAAA,QAAAL,QAAAK,EAAA,QAAAI,MAAAJ,EAAA,QAAAM,IAAA;EARVC,KAAA,oBAAC,SAAD;GACWb;GACDC;GACM,YAAAS;GACJ,QAAAE;EAIF,CAAA;EAERN,EAAA,KAAAG;EAAAH,EAAA,KAAAN;EAAAM,EAAA,MAAAL;EAAAK,EAAA,MAAAI;EAAAJ,EAAA,MAAAM;EAAAN,EAAA,MAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,OAVFO;AAUE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* The extension, after the number, in the same box. */
|
|
2
|
+
.panneau-tel-field-extension {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
gap: var(--panneau-space-1);
|
|
6
|
+
align-self: stretch;
|
|
7
|
+
padding-inline-start: var(--panneau-space-2);
|
|
8
|
+
border-inline-start: var(--panneau-border-width) solid var(--panneau-color-border-control);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.panneau-tel-field-extension-input {
|
|
12
|
+
width: 6ch;
|
|
13
|
+
min-width: 0;
|
|
14
|
+
padding: 0;
|
|
15
|
+
font: inherit;
|
|
16
|
+
color: var(--panneau-color-text);
|
|
17
|
+
background: transparent;
|
|
18
|
+
border: 0;
|
|
19
|
+
outline: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.panneau-tel-field-extension-input:read-only,
|
|
23
|
+
.panneau-tel-field-extension-input:disabled {
|
|
24
|
+
cursor: inherit;
|
|
25
|
+
}
|
package/dist/tel/TelField.d.ts
CHANGED
|
@@ -6,6 +6,11 @@ export interface TelFieldProps extends Omit<TextFieldProps, 'type' | 'inputMode'
|
|
|
6
6
|
* gives `CA`).
|
|
7
7
|
*/
|
|
8
8
|
country?: string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Adds an input for the extension, after the number. The value is then the number with its
|
|
11
|
+
* extension after `;ext=`, as in a `tel:` URI: `+15145550199;ext=123`.
|
|
12
|
+
*/
|
|
13
|
+
extension?: boolean;
|
|
9
14
|
}
|
|
10
15
|
/**
|
|
11
16
|
* A phone number, in E.164 (`+15145550199`). The country of the number, its flag and its calling
|
|
@@ -15,8 +20,15 @@ export interface TelFieldProps extends Omit<TextFieldProps, 'type' | 'inputMode'
|
|
|
15
20
|
* Until a number is complete, the value is the text as typed, which the `tel` rule refuses. A value
|
|
16
21
|
* that isn't E.164, kept from before, shows as it is, and becomes E.164 when the field is left, if
|
|
17
22
|
* it reads as a number of the chosen country.
|
|
23
|
+
*
|
|
24
|
+
* With `extension`, an input after the number takes the digits of an extension, kept after `;ext=`
|
|
25
|
+
* (`+15145550199;ext=123`). An extension typed or pasted after the number (`ext. 123`, `x123`,
|
|
26
|
+
* `poste 123`) moves to that input when the field is left.
|
|
27
|
+
*/
|
|
28
|
+
export declare function TelField({ value, onChange, onBlur, country: defaultCountry, extension: allowsExtension, suffix, disabled, readOnly, ...props }: TelFieldProps): import("react").JSX.Element;
|
|
29
|
+
/**
|
|
30
|
+
* The `tel` type: `settings.country` is the country of a new number, and `settings.extension` adds
|
|
31
|
+
* an input for an extension.
|
|
18
32
|
*/
|
|
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. */
|
|
21
33
|
export declare function TelFieldEntry(props: FieldEntryProps): import("react").JSX.Element;
|
|
22
34
|
//# sourceMappingURL=TelField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAcnE,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;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAgBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,EACrB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,eAAuB,EAClC,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,GAAG,KAAK,EACX,EAAE,aAAa,+BAgJf;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,+BAYnD"}
|
package/dist/tel/TelField.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { getFieldProps, getSetting, isString } from "../shared/entry.js";
|
|
1
|
+
import { getFieldProps, getSetting, isBoolean, isString } from "../shared/entry.js";
|
|
2
2
|
import { messages } from "../shared/messages.js";
|
|
3
|
-
import { TextField } from "../text/TextField.js";
|
|
4
3
|
import { getCountryFlag, getCountryName, getLocaleCountry } from "../country/countries.js";
|
|
5
|
-
import {
|
|
4
|
+
import { TextField } from "../text/TextField.js";
|
|
5
|
+
import TelField_module_default from "./TelField.module.js";
|
|
6
|
+
import { formatPhoneInput, getCallingCode, getPhoneCountries, joinExtension, parsePhone, readExtension, readPhone, splitExtension } from "./phone.js";
|
|
6
7
|
import { c } from "react/compiler-runtime";
|
|
7
8
|
import { useState } from "react";
|
|
8
9
|
import { Select, usePanneauIntl } from "@panneau/ui";
|
|
9
|
-
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
11
|
//#region src/tel/TelField.tsx
|
|
12
|
+
/** Characters that aren't part of a number: an extension typed after it (`x123`, `ext. 123`). */
|
|
13
|
+
var NOT_A_NUMBER = /[^\d\s()+.-]/;
|
|
11
14
|
/** The text shown for a value: a number of the country in its format, any other as it is. */
|
|
12
15
|
function display(value, country) {
|
|
13
16
|
const number = parsePhone(value);
|
|
@@ -22,18 +25,24 @@ function display(value, country) {
|
|
|
22
25
|
* Until a number is complete, the value is the text as typed, which the `tel` rule refuses. A value
|
|
23
26
|
* that isn't E.164, kept from before, shows as it is, and becomes E.164 when the field is left, if
|
|
24
27
|
* it reads as a number of the chosen country.
|
|
28
|
+
*
|
|
29
|
+
* With `extension`, an input after the number takes the digits of an extension, kept after `;ext=`
|
|
30
|
+
* (`+15145550199;ext=123`). An extension typed or pasted after the number (`ext. 123`, `x123`,
|
|
31
|
+
* `poste 123`) moves to that input when the field is left.
|
|
25
32
|
*/
|
|
26
33
|
function TelField(t0) {
|
|
27
|
-
const $ = c(
|
|
34
|
+
const $ = c(88);
|
|
28
35
|
let defaultCountry;
|
|
29
36
|
let disabled;
|
|
30
37
|
let onBlur;
|
|
31
38
|
let onChange;
|
|
32
39
|
let props;
|
|
33
40
|
let readOnly;
|
|
41
|
+
let suffix;
|
|
42
|
+
let t1;
|
|
34
43
|
let value;
|
|
35
44
|
if ($[0] !== t0) {
|
|
36
|
-
({value, onChange, onBlur, country: defaultCountry, disabled, readOnly, ...props} = t0);
|
|
45
|
+
({value, onChange, onBlur, country: defaultCountry, extension: t1, suffix, disabled, readOnly, ...props} = t0);
|
|
37
46
|
$[0] = t0;
|
|
38
47
|
$[1] = defaultCountry;
|
|
39
48
|
$[2] = disabled;
|
|
@@ -41,7 +50,9 @@ function TelField(t0) {
|
|
|
41
50
|
$[4] = onChange;
|
|
42
51
|
$[5] = props;
|
|
43
52
|
$[6] = readOnly;
|
|
44
|
-
$[7] =
|
|
53
|
+
$[7] = suffix;
|
|
54
|
+
$[8] = t1;
|
|
55
|
+
$[9] = value;
|
|
45
56
|
} else {
|
|
46
57
|
defaultCountry = $[1];
|
|
47
58
|
disabled = $[2];
|
|
@@ -49,47 +60,63 @@ function TelField(t0) {
|
|
|
49
60
|
onChange = $[4];
|
|
50
61
|
props = $[5];
|
|
51
62
|
readOnly = $[6];
|
|
52
|
-
|
|
63
|
+
suffix = $[7];
|
|
64
|
+
t1 = $[8];
|
|
65
|
+
value = $[9];
|
|
53
66
|
}
|
|
67
|
+
const allowsExtension = t1 === void 0 ? false : t1;
|
|
54
68
|
const intl = usePanneauIntl();
|
|
55
69
|
const [chosen, setChosen] = useState(null);
|
|
56
70
|
const [draft, setDraft] = useState(null);
|
|
57
|
-
let
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
$[8] = value;
|
|
61
|
-
$[9] = t1;
|
|
62
|
-
} else t1 = $[9];
|
|
63
|
-
const number = t1;
|
|
71
|
+
let country;
|
|
72
|
+
let number;
|
|
73
|
+
let parts;
|
|
64
74
|
let t2;
|
|
65
|
-
if ($[10] !==
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
if ($[10] !== allowsExtension || $[11] !== chosen || $[12] !== defaultCountry || $[13] !== draft || $[14] !== intl.locale || $[15] !== value) {
|
|
76
|
+
parts = allowsExtension ? splitExtension(value) : {
|
|
77
|
+
number: value ?? null,
|
|
78
|
+
extension: null
|
|
79
|
+
};
|
|
80
|
+
number = parsePhone(parts.number);
|
|
81
|
+
country = number?.country ?? chosen ?? defaultCountry ?? getLocaleCountry(intl.locale) ?? null;
|
|
82
|
+
t2 = draft ?? display(parts.number, country);
|
|
83
|
+
$[10] = allowsExtension;
|
|
84
|
+
$[11] = chosen;
|
|
85
|
+
$[12] = defaultCountry;
|
|
86
|
+
$[13] = draft;
|
|
87
|
+
$[14] = intl.locale;
|
|
88
|
+
$[15] = value;
|
|
89
|
+
$[16] = country;
|
|
90
|
+
$[17] = number;
|
|
91
|
+
$[18] = parts;
|
|
92
|
+
$[19] = t2;
|
|
93
|
+
} else {
|
|
94
|
+
country = $[16];
|
|
95
|
+
number = $[17];
|
|
96
|
+
parts = $[18];
|
|
97
|
+
t2 = $[19];
|
|
98
|
+
}
|
|
99
|
+
const shown = t2;
|
|
74
100
|
let t3;
|
|
75
|
-
if ($[
|
|
76
|
-
t3 =
|
|
77
|
-
$[15] = country;
|
|
78
|
-
$[16] = draft;
|
|
79
|
-
$[17] = value;
|
|
80
|
-
$[18] = t3;
|
|
81
|
-
} else t3 = $[18];
|
|
82
|
-
const shown = t3;
|
|
83
|
-
let t4;
|
|
84
|
-
if ($[19] !== onChange || $[20] !== value) {
|
|
85
|
-
t4 = (next) => {
|
|
101
|
+
if ($[20] !== onChange || $[21] !== value) {
|
|
102
|
+
t3 = (next) => {
|
|
86
103
|
if (next !== (value ?? null)) onChange?.(next);
|
|
87
104
|
};
|
|
88
|
-
$[
|
|
89
|
-
$[
|
|
90
|
-
$[
|
|
91
|
-
} else
|
|
92
|
-
const emit =
|
|
105
|
+
$[20] = onChange;
|
|
106
|
+
$[21] = value;
|
|
107
|
+
$[22] = t3;
|
|
108
|
+
} else t3 = $[22];
|
|
109
|
+
const emit = t3;
|
|
110
|
+
let t4;
|
|
111
|
+
if ($[23] !== emit || $[24] !== parts) {
|
|
112
|
+
t4 = (next_0, extension) => {
|
|
113
|
+
emit(joinExtension(next_0, extension === void 0 ? parts.extension : extension));
|
|
114
|
+
};
|
|
115
|
+
$[23] = emit;
|
|
116
|
+
$[24] = parts;
|
|
117
|
+
$[25] = t4;
|
|
118
|
+
} else t4 = $[25];
|
|
119
|
+
const emitNumber = t4;
|
|
93
120
|
let T0;
|
|
94
121
|
let t10;
|
|
95
122
|
let t5;
|
|
@@ -97,64 +124,64 @@ function TelField(t0) {
|
|
|
97
124
|
let t7;
|
|
98
125
|
let t8;
|
|
99
126
|
let t9;
|
|
100
|
-
if ($[
|
|
127
|
+
if ($[26] !== disabled || $[27] !== intl || $[28] !== readOnly) {
|
|
101
128
|
const collator = new Intl.Collator(intl.locale);
|
|
102
129
|
let t11;
|
|
103
|
-
if ($[
|
|
130
|
+
if ($[36] !== intl.locale) {
|
|
104
131
|
t11 = (code) => ({
|
|
105
132
|
code,
|
|
106
133
|
name: getCountryName(code, intl.locale)
|
|
107
134
|
});
|
|
108
|
-
$[
|
|
109
|
-
$[
|
|
110
|
-
} else t11 = $[
|
|
135
|
+
$[36] = intl.locale;
|
|
136
|
+
$[37] = t11;
|
|
137
|
+
} else t11 = $[37];
|
|
111
138
|
const countries = getPhoneCountries().map(t11).sort((a, b) => collator.compare(a.name, b.name));
|
|
112
139
|
T0 = Select;
|
|
113
|
-
if ($[
|
|
140
|
+
if ($[38] !== intl) {
|
|
114
141
|
t5 = intl.formatMessage(messages.telCountry);
|
|
115
|
-
$[
|
|
116
|
-
$[
|
|
117
|
-
} else t5 = $[
|
|
142
|
+
$[38] = intl;
|
|
143
|
+
$[39] = t5;
|
|
144
|
+
} else t5 = $[39];
|
|
118
145
|
t6 = "bare";
|
|
119
146
|
t7 = true;
|
|
120
147
|
t8 = disabled === true || readOnly === true;
|
|
121
148
|
t9 = "+";
|
|
122
149
|
t10 = countries.map(_temp);
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
127
|
-
$[
|
|
128
|
-
$[
|
|
129
|
-
$[
|
|
130
|
-
$[
|
|
131
|
-
$[
|
|
132
|
-
$[
|
|
150
|
+
$[26] = disabled;
|
|
151
|
+
$[27] = intl;
|
|
152
|
+
$[28] = readOnly;
|
|
153
|
+
$[29] = T0;
|
|
154
|
+
$[30] = t10;
|
|
155
|
+
$[31] = t5;
|
|
156
|
+
$[32] = t6;
|
|
157
|
+
$[33] = t7;
|
|
158
|
+
$[34] = t8;
|
|
159
|
+
$[35] = t9;
|
|
133
160
|
} else {
|
|
134
|
-
T0 = $[
|
|
135
|
-
t10 = $[
|
|
136
|
-
t5 = $[
|
|
137
|
-
t6 = $[
|
|
138
|
-
t7 = $[
|
|
139
|
-
t8 = $[
|
|
140
|
-
t9 = $[
|
|
161
|
+
T0 = $[29];
|
|
162
|
+
t10 = $[30];
|
|
163
|
+
t5 = $[31];
|
|
164
|
+
t6 = $[32];
|
|
165
|
+
t7 = $[33];
|
|
166
|
+
t8 = $[34];
|
|
167
|
+
t9 = $[35];
|
|
141
168
|
}
|
|
142
169
|
let t11;
|
|
143
|
-
if ($[
|
|
144
|
-
t11 = (
|
|
145
|
-
const code_1 =
|
|
170
|
+
if ($[40] !== emitNumber || $[41] !== number?.nationalNumber || $[42] !== shown) {
|
|
171
|
+
t11 = (next_1) => {
|
|
172
|
+
const code_1 = next_1 !== null ? String(next_1) : null;
|
|
146
173
|
setChosen(code_1);
|
|
147
174
|
setDraft(null);
|
|
148
175
|
const digits = number?.nationalNumber ?? shown.replace(/^\+/, "");
|
|
149
|
-
|
|
176
|
+
emitNumber(readPhone(digits, code_1).value);
|
|
150
177
|
};
|
|
151
|
-
$[
|
|
152
|
-
$[
|
|
153
|
-
$[
|
|
154
|
-
$[
|
|
155
|
-
} else t11 = $[
|
|
178
|
+
$[40] = emitNumber;
|
|
179
|
+
$[41] = number?.nationalNumber;
|
|
180
|
+
$[42] = shown;
|
|
181
|
+
$[43] = t11;
|
|
182
|
+
} else t11 = $[43];
|
|
156
183
|
let t12;
|
|
157
|
-
if ($[
|
|
184
|
+
if ($[44] !== T0 || $[45] !== country || $[46] !== t10 || $[47] !== t11 || $[48] !== t5 || $[49] !== t6 || $[50] !== t7 || $[51] !== t8 || $[52] !== t9) {
|
|
158
185
|
t12 = /* @__PURE__ */ jsx(T0, {
|
|
159
186
|
"aria-label": t5,
|
|
160
187
|
appearance: t6,
|
|
@@ -166,51 +193,105 @@ function TelField(t0) {
|
|
|
166
193
|
renderValue: _temp2,
|
|
167
194
|
onChange: t11
|
|
168
195
|
});
|
|
169
|
-
$[
|
|
170
|
-
$[
|
|
171
|
-
$[
|
|
172
|
-
$[
|
|
173
|
-
$[
|
|
174
|
-
$[
|
|
175
|
-
$[
|
|
176
|
-
$[
|
|
177
|
-
$[
|
|
178
|
-
$[
|
|
179
|
-
} else t12 = $[
|
|
196
|
+
$[44] = T0;
|
|
197
|
+
$[45] = country;
|
|
198
|
+
$[46] = t10;
|
|
199
|
+
$[47] = t11;
|
|
200
|
+
$[48] = t5;
|
|
201
|
+
$[49] = t6;
|
|
202
|
+
$[50] = t7;
|
|
203
|
+
$[51] = t8;
|
|
204
|
+
$[52] = t9;
|
|
205
|
+
$[53] = t12;
|
|
206
|
+
} else t12 = $[53];
|
|
180
207
|
const picker = t12;
|
|
181
208
|
let t13;
|
|
182
|
-
if ($[
|
|
183
|
-
t13 = (
|
|
209
|
+
if ($[54] !== allowsExtension || $[55] !== disabled || $[56] !== emitNumber || $[57] !== intl || $[58] !== onBlur || $[59] !== parts || $[60] !== props || $[61] !== readOnly) {
|
|
210
|
+
t13 = allowsExtension ? /* @__PURE__ */ jsxs("span", {
|
|
211
|
+
className: TelField_module_default.extension,
|
|
212
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
213
|
+
"aria-hidden": "true",
|
|
214
|
+
children: intl.formatMessage(messages.telExtensionShort)
|
|
215
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
216
|
+
className: TelField_module_default.extensionInput,
|
|
217
|
+
type: "text",
|
|
218
|
+
inputMode: "numeric",
|
|
219
|
+
autoComplete: "tel-extension",
|
|
220
|
+
"aria-label": intl.formatMessage(messages.telExtension),
|
|
221
|
+
"aria-invalid": (props.errors?.length ?? 0) > 0 || void 0,
|
|
222
|
+
maxLength: 10,
|
|
223
|
+
value: parts.extension ?? "",
|
|
224
|
+
disabled,
|
|
225
|
+
readOnly,
|
|
226
|
+
onChange: (event) => {
|
|
227
|
+
const digits_0 = event.target.value.replace(/\D/g, "").slice(0, 10);
|
|
228
|
+
emitNumber(parts.number, digits_0 === "" ? null : digits_0);
|
|
229
|
+
},
|
|
230
|
+
onBlur: () => onBlur?.()
|
|
231
|
+
})]
|
|
232
|
+
}) : null;
|
|
233
|
+
$[54] = allowsExtension;
|
|
234
|
+
$[55] = disabled;
|
|
235
|
+
$[56] = emitNumber;
|
|
236
|
+
$[57] = intl;
|
|
237
|
+
$[58] = onBlur;
|
|
238
|
+
$[59] = parts;
|
|
239
|
+
$[60] = props;
|
|
240
|
+
$[61] = readOnly;
|
|
241
|
+
$[62] = t13;
|
|
242
|
+
} else t13 = $[62];
|
|
243
|
+
const extensionInput = t13;
|
|
244
|
+
let t14;
|
|
245
|
+
if ($[63] !== extensionInput || $[64] !== suffix) {
|
|
246
|
+
t14 = extensionInput !== null || suffix !== void 0 ? { suffix: /* @__PURE__ */ jsxs(Fragment, { children: [extensionInput, suffix] }) } : {};
|
|
247
|
+
$[63] = extensionInput;
|
|
248
|
+
$[64] = suffix;
|
|
249
|
+
$[65] = t14;
|
|
250
|
+
} else t14 = $[65];
|
|
251
|
+
let t15;
|
|
252
|
+
if ($[66] !== allowsExtension || $[67] !== country || $[68] !== emitNumber || $[69] !== shown) {
|
|
253
|
+
t15 = (text) => {
|
|
184
254
|
const typed = text ?? "";
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
const
|
|
255
|
+
const typedExtension = allowsExtension && NOT_A_NUMBER.test(typed);
|
|
256
|
+
const added = typed.startsWith(shown) ? typed.slice(shown.length) : "";
|
|
257
|
+
const next_2 = !typedExtension && added !== "" && !(allowsExtension && added.trim() === "") ? formatPhoneInput(typed, country) : typed;
|
|
258
|
+
setDraft(next_2);
|
|
259
|
+
if (typedExtension) {
|
|
260
|
+
emitNumber(next_2.trim());
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const read = readPhone(next_2, country);
|
|
188
264
|
if (read.country !== null && read.country !== country) setChosen(read.country);
|
|
189
|
-
|
|
265
|
+
emitNumber(read.value);
|
|
190
266
|
};
|
|
191
|
-
$[
|
|
192
|
-
$[
|
|
193
|
-
$[
|
|
194
|
-
$[
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
267
|
+
$[66] = allowsExtension;
|
|
268
|
+
$[67] = country;
|
|
269
|
+
$[68] = emitNumber;
|
|
270
|
+
$[69] = shown;
|
|
271
|
+
$[70] = t15;
|
|
272
|
+
} else t15 = $[70];
|
|
273
|
+
let t16;
|
|
274
|
+
if ($[71] !== allowsExtension || $[72] !== country || $[73] !== disabled || $[74] !== emitNumber || $[75] !== onBlur || $[76] !== parts || $[77] !== readOnly) {
|
|
275
|
+
t16 = () => {
|
|
199
276
|
setDraft(null);
|
|
200
|
-
if (readOnly !== true && disabled !== true && isString(
|
|
277
|
+
if (readOnly !== true && disabled !== true && isString(parts.number) && parsePhone(parts.number) === null) {
|
|
278
|
+
const typed_0 = allowsExtension ? readExtension(parts.number) : null;
|
|
279
|
+
emitNumber(readPhone(typed_0?.number ?? parts.number, country).value, typed_0?.extension ?? parts.extension);
|
|
280
|
+
}
|
|
201
281
|
onBlur?.();
|
|
202
282
|
};
|
|
203
|
-
$[
|
|
204
|
-
$[
|
|
205
|
-
$[
|
|
206
|
-
$[
|
|
207
|
-
$[
|
|
208
|
-
$[
|
|
209
|
-
$[
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
283
|
+
$[71] = allowsExtension;
|
|
284
|
+
$[72] = country;
|
|
285
|
+
$[73] = disabled;
|
|
286
|
+
$[74] = emitNumber;
|
|
287
|
+
$[75] = onBlur;
|
|
288
|
+
$[76] = parts;
|
|
289
|
+
$[77] = readOnly;
|
|
290
|
+
$[78] = t16;
|
|
291
|
+
} else t16 = $[78];
|
|
292
|
+
let t17;
|
|
293
|
+
if ($[79] !== disabled || $[80] !== picker || $[81] !== props || $[82] !== readOnly || $[83] !== shown || $[84] !== t14 || $[85] !== t15 || $[86] !== t16) {
|
|
294
|
+
t17 = /* @__PURE__ */ jsx(TextField, {
|
|
214
295
|
autoComplete: "tel",
|
|
215
296
|
...props,
|
|
216
297
|
disabled,
|
|
@@ -218,22 +299,27 @@ function TelField(t0) {
|
|
|
218
299
|
type: "tel",
|
|
219
300
|
inputMode: "tel",
|
|
220
301
|
prefix: picker,
|
|
302
|
+
...t14,
|
|
221
303
|
value: shown,
|
|
222
|
-
onChange:
|
|
223
|
-
onBlur:
|
|
304
|
+
onChange: t15,
|
|
305
|
+
onBlur: t16
|
|
224
306
|
});
|
|
225
|
-
$[
|
|
226
|
-
$[
|
|
227
|
-
$[
|
|
228
|
-
$[
|
|
229
|
-
$[
|
|
230
|
-
$[
|
|
231
|
-
$[
|
|
232
|
-
$[
|
|
233
|
-
|
|
234
|
-
|
|
307
|
+
$[79] = disabled;
|
|
308
|
+
$[80] = picker;
|
|
309
|
+
$[81] = props;
|
|
310
|
+
$[82] = readOnly;
|
|
311
|
+
$[83] = shown;
|
|
312
|
+
$[84] = t14;
|
|
313
|
+
$[85] = t15;
|
|
314
|
+
$[86] = t16;
|
|
315
|
+
$[87] = t17;
|
|
316
|
+
} else t17 = $[87];
|
|
317
|
+
return t17;
|
|
235
318
|
}
|
|
236
|
-
/**
|
|
319
|
+
/**
|
|
320
|
+
* The `tel` type: `settings.country` is the country of a new number, and `settings.extension` adds
|
|
321
|
+
* an input for an extension.
|
|
322
|
+
*/
|
|
237
323
|
function _temp2(option) {
|
|
238
324
|
return `+${getCallingCode(String(option.value)) ?? ""}`;
|
|
239
325
|
}
|
|
@@ -246,7 +332,7 @@ function _temp(t0) {
|
|
|
246
332
|
};
|
|
247
333
|
}
|
|
248
334
|
function TelFieldEntry(props) {
|
|
249
|
-
const $ = c(
|
|
335
|
+
const $ = c(16);
|
|
250
336
|
let t0;
|
|
251
337
|
if ($[0] !== props.field) {
|
|
252
338
|
t0 = getSetting(props.field, "country", isString);
|
|
@@ -255,33 +341,48 @@ function TelFieldEntry(props) {
|
|
|
255
341
|
} else t0 = $[1];
|
|
256
342
|
const country = t0;
|
|
257
343
|
let t1;
|
|
258
|
-
if ($[2] !== props) {
|
|
259
|
-
t1 =
|
|
260
|
-
$[2] = props;
|
|
344
|
+
if ($[2] !== props.field) {
|
|
345
|
+
t1 = getSetting(props.field, "extension", isBoolean);
|
|
346
|
+
$[2] = props.field;
|
|
261
347
|
$[3] = t1;
|
|
262
348
|
} else t1 = $[3];
|
|
349
|
+
const extension = t1 === true;
|
|
263
350
|
let t2;
|
|
264
|
-
if ($[4] !==
|
|
265
|
-
t2 =
|
|
266
|
-
$[4] =
|
|
351
|
+
if ($[4] !== props) {
|
|
352
|
+
t2 = getFieldProps(props);
|
|
353
|
+
$[4] = props;
|
|
267
354
|
$[5] = t2;
|
|
268
355
|
} else t2 = $[5];
|
|
269
|
-
|
|
356
|
+
let t3;
|
|
357
|
+
if ($[6] !== country) {
|
|
358
|
+
t3 = country !== void 0 ? { country } : {};
|
|
359
|
+
$[6] = country;
|
|
360
|
+
$[7] = t3;
|
|
361
|
+
} else t3 = $[7];
|
|
270
362
|
let t4;
|
|
271
|
-
if ($[
|
|
272
|
-
t4 =
|
|
273
|
-
|
|
363
|
+
if ($[8] !== extension) {
|
|
364
|
+
t4 = extension ? { extension } : {};
|
|
365
|
+
$[8] = extension;
|
|
366
|
+
$[9] = t4;
|
|
367
|
+
} else t4 = $[9];
|
|
368
|
+
const t5 = isString(props.value) ? props.value : null;
|
|
369
|
+
let t6;
|
|
370
|
+
if ($[10] !== props.onChange || $[11] !== t2 || $[12] !== t3 || $[13] !== t4 || $[14] !== t5) {
|
|
371
|
+
t6 = /* @__PURE__ */ jsx(TelField, {
|
|
274
372
|
...t2,
|
|
275
|
-
|
|
373
|
+
...t3,
|
|
374
|
+
...t4,
|
|
375
|
+
value: t5,
|
|
276
376
|
onChange: props.onChange
|
|
277
377
|
});
|
|
278
|
-
$[
|
|
279
|
-
$[
|
|
280
|
-
$[
|
|
281
|
-
$[
|
|
282
|
-
$[
|
|
283
|
-
|
|
284
|
-
|
|
378
|
+
$[10] = props.onChange;
|
|
379
|
+
$[11] = t2;
|
|
380
|
+
$[12] = t3;
|
|
381
|
+
$[13] = t4;
|
|
382
|
+
$[14] = t5;
|
|
383
|
+
$[15] = t6;
|
|
384
|
+
} else t6 = $[15];
|
|
385
|
+
return t6;
|
|
285
386
|
}
|
|
286
387
|
//#endregion
|
|
287
388
|
export { TelField, TelFieldEntry };
|