@caspeco/casper-ui-library 10.0.3 → 10.1.0
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/dist/components/combobox/combobox.d.ts.map +1 -1
- package/dist/components/combobox/combobox.js +186 -169
- package/dist/components/combobox/types.d.ts +1 -0
- package/dist/components/combobox/types.d.ts.map +1 -1
- package/dist/components/input/input-recipe.d.ts.map +1 -1
- package/dist/components/input/input-recipe.js +8 -3
- package/dist/components/input/input.composition.d.ts.map +1 -1
- package/dist/components/input/input.d.ts +1 -0
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/input/input.js +76 -52
- package/dist/components/input/types.d.ts +2 -2
- package/dist/components/input/types.d.ts.map +1 -1
- package/dist/components/menu/menu-box-button.d.ts +4 -1
- package/dist/components/menu/menu-box-button.d.ts.map +1 -1
- package/dist/components/menu/menu-box-button.js +15 -14
- package/dist/components/phone-input/country-data.d.ts +22 -0
- package/dist/components/phone-input/country-data.d.ts.map +1 -0
- package/dist/components/phone-input/country-data.js +38 -0
- package/dist/components/phone-input/country-data.spec.d.ts +2 -0
- package/dist/components/phone-input/country-data.spec.d.ts.map +1 -0
- package/dist/components/phone-input/country-list.d.ts +19 -0
- package/dist/components/phone-input/country-list.d.ts.map +1 -0
- package/dist/components/phone-input/country-list.js +27 -0
- package/dist/components/phone-input/country-selector.d.ts +59 -0
- package/dist/components/phone-input/country-selector.d.ts.map +1 -0
- package/dist/components/phone-input/country-selector.js +120 -0
- package/dist/components/phone-input/index.d.ts +5 -0
- package/dist/components/phone-input/index.d.ts.map +1 -0
- package/dist/components/phone-input/phone-input-helpers.d.ts +47 -0
- package/dist/components/phone-input/phone-input-helpers.d.ts.map +1 -0
- package/dist/components/phone-input/phone-input-helpers.js +134 -0
- package/dist/components/phone-input/phone-input-helpers.spec.d.ts +2 -0
- package/dist/components/phone-input/phone-input-helpers.spec.d.ts.map +1 -0
- package/dist/components/phone-input/phone-input.composition.d.ts +26 -0
- package/dist/components/phone-input/phone-input.composition.d.ts.map +1 -0
- package/dist/components/phone-input/phone-input.d.ts +22 -0
- package/dist/components/phone-input/phone-input.d.ts.map +1 -0
- package/dist/components/phone-input/phone-input.js +43 -0
- package/dist/components/phone-input/phone-input.spec.d.ts +2 -0
- package/dist/components/phone-input/phone-input.spec.d.ts.map +1 -0
- package/dist/components/phone-input/phone-input.visual.test.d.ts +2 -0
- package/dist/components/phone-input/phone-input.visual.test.d.ts.map +1 -0
- package/dist/components/phone-input/translations.d.ts +60 -0
- package/dist/components/phone-input/translations.d.ts.map +1 -0
- package/dist/components/phone-input/translations.js +54 -0
- package/dist/components/phone-input/types.d.ts +45 -0
- package/dist/components/phone-input/types.d.ts.map +1 -0
- package/dist/components/phone-input/use-phone-input.d.ts +49 -0
- package/dist/components/phone-input/use-phone-input.d.ts.map +1 -0
- package/dist/components/phone-input/use-phone-input.js +138 -0
- package/dist/components/phone-input/use-phone-input.spec.d.ts +2 -0
- package/dist/components/phone-input/use-phone-input.spec.d.ts.map +1 -0
- package/dist/hooks/use-measured-width.d.ts +23 -0
- package/dist/hooks/use-measured-width.d.ts.map +1 -0
- package/dist/hooks/use-measured-width.js +22 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +289 -285
- package/dist/node_modules/country-flag-icons/modules/countries.json.js +4 -0
- package/dist/node_modules/country-flag-icons/modules/hasFlag.js +7 -0
- package/dist/node_modules/country-flag-icons/modules/react/3x2/index.js +6303 -0
- package/dist/node_modules/country-flag-icons/react/3x2/index.js +269 -0
- package/dist/node_modules/libphonenumber-js/es6/ParseError.js +89 -0
- package/dist/node_modules/libphonenumber-js/es6/PhoneNumber.js +192 -0
- package/dist/node_modules/libphonenumber-js/es6/constants.js +10 -0
- package/dist/node_modules/libphonenumber-js/es6/format.js +98 -0
- package/dist/node_modules/libphonenumber-js/es6/getCountries.js +7 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/RFC3966.js +11 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/applyInternationalSeparatorStyle.js +7 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/checkNumberLength.js +16 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/extension/createExtensionPattern.js +11 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/extension/extractExtension.js +18 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCode.js +46 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js +27 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js +23 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractNationalNumber.js +39 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js +31 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/extractPhoneContext.js +23 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/formatNationalNumberUsingFormat.js +25 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/getCountryAndCallingCodeFromOneOfThem.js +12 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/getCountryByCallingCode.js +9 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/getCountryByNationalNumber.js +43 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/getIddPrefix.js +12 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/getNumberType.js +52 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/getPossibleCountriesForNumber.js +14 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/isCallingCode.js +7 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/isCountryCode.js +7 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/isObject.js +7 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/isViablePhoneNumber.js +20 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/matchesEntirely.js +6 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/parseDigits.js +79 -0
- package/dist/node_modules/libphonenumber-js/es6/helpers/stripIddPrefix.js +19 -0
- package/dist/node_modules/libphonenumber-js/es6/isPossible.js +35 -0
- package/dist/node_modules/libphonenumber-js/es6/isValid.js +14 -0
- package/dist/node_modules/libphonenumber-js/es6/isValidPhoneNumber.js +59 -0
- package/dist/node_modules/libphonenumber-js/es6/metadata.js +494 -0
- package/dist/node_modules/libphonenumber-js/es6/normalizeArguments.js +108 -0
- package/dist/node_modules/libphonenumber-js/es6/parse.js +138 -0
- package/dist/node_modules/libphonenumber-js/es6/parseIncompletePhoneNumber.js +40 -0
- package/dist/node_modules/libphonenumber-js/es6/parsePhoneNumber.js +9 -0
- package/dist/node_modules/libphonenumber-js/es6/parsePhoneNumberWithError_.js +55 -0
- package/dist/node_modules/libphonenumber-js/es6/parsePhoneNumber_.js +62 -0
- package/dist/node_modules/libphonenumber-js/es6/tools/semver-compare.js +14 -0
- package/dist/node_modules/libphonenumber-js/metadata.min.json.js +4 -0
- package/dist/node_modules/libphonenumber-js/min/exports/getCountries.js +8 -0
- package/dist/node_modules/libphonenumber-js/min/exports/getCountryCallingCode.js +8 -0
- package/dist/node_modules/libphonenumber-js/min/exports/isSupportedCountry.js +8 -0
- package/dist/node_modules/libphonenumber-js/min/exports/isValidPhoneNumber.js +8 -0
- package/dist/node_modules/libphonenumber-js/min/exports/parsePhoneNumber.js +8 -0
- package/dist/node_modules/libphonenumber-js/min/exports/withMetadataArgument.js +8 -0
- package/dist/test-utils/create-visual-tests.d.ts.map +1 -1
- package/package.json +3 -1
|
@@ -1,61 +1,85 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { c as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { jsx as $ } from "react/jsx-runtime";
|
|
2
|
+
import { c as N } from "../../_virtual/compiler-runtime.js";
|
|
3
|
+
import { useMeasuredWidth as q } from "../../hooks/use-measured-width.js";
|
|
4
|
+
import { ThemeBreakPointToken as W } from "../../theme/theme-tokens.js";
|
|
5
|
+
import { useBreakpointValue as X, Input as Z, InputGroup as F } from "@chakra-ui/react";
|
|
6
|
+
import L from "react";
|
|
7
|
+
import { getVisualStateStyle as Y } from "./helper.js";
|
|
8
|
+
import { ThemeColorVariable as w, ThemeSpaceVariable as b } from "../../theme/theme-types.js";
|
|
9
|
+
const J = {
|
|
10
|
+
sm: "2rem",
|
|
11
|
+
md: "2.5rem",
|
|
12
|
+
lg: "3rem",
|
|
13
|
+
xl: "3.5rem"
|
|
14
|
+
}, P = "md";
|
|
15
|
+
function D(p, i, e) {
|
|
16
|
+
if (p)
|
|
17
|
+
return i !== null ? `${i}px` : e;
|
|
18
|
+
}
|
|
19
|
+
const re = L.forwardRef((p, i) => {
|
|
20
|
+
const e = N.c(48);
|
|
21
|
+
let r, s, a, d, t, m, c, n, S, E, l;
|
|
22
|
+
e[0] !== p ? ({
|
|
23
|
+
size: S,
|
|
24
|
+
visualState: l,
|
|
25
|
+
leftAddon: d,
|
|
26
|
+
rightAddon: c,
|
|
15
27
|
leftElement: t,
|
|
16
|
-
rightElement:
|
|
17
|
-
variant:
|
|
18
|
-
isDisabled:
|
|
19
|
-
isReadOnly:
|
|
20
|
-
isRequired:
|
|
21
|
-
...
|
|
22
|
-
} =
|
|
23
|
-
const
|
|
24
|
-
let S;
|
|
25
|
-
e[12] !== i ? (S = i ? H(i) : void 0, e[12] = i, e[13] = S) : S = e[13];
|
|
26
|
-
const R = S, x = m === "lg" ? T.Medium : T.Small, V = m === "lg" ? "3rem" : m === "md" ? "2.5rem" : "2rem";
|
|
28
|
+
rightElement: n,
|
|
29
|
+
variant: E,
|
|
30
|
+
isDisabled: r,
|
|
31
|
+
isReadOnly: s,
|
|
32
|
+
isRequired: a,
|
|
33
|
+
...m
|
|
34
|
+
} = p, e[0] = p, e[1] = r, e[2] = s, e[3] = a, e[4] = d, e[5] = t, e[6] = m, e[7] = c, e[8] = n, e[9] = S, e[10] = E, e[11] = l) : (r = e[1], s = e[2], a = e[3], d = e[4], t = e[5], m = e[6], c = e[7], n = e[8], S = e[9], E = e[10], l = e[11]);
|
|
35
|
+
const o = S === void 0 ? P : S, T = E === void 0 ? "outline" : E;
|
|
27
36
|
let g;
|
|
28
|
-
e[
|
|
29
|
-
|
|
37
|
+
e[12] !== l ? (g = l ? Y(l) : void 0, e[12] = l, e[13] = g) : g = e[13];
|
|
38
|
+
const x = g, G = X(typeof o == "string" || o === void 0 ? {
|
|
39
|
+
[W.Base]: o ?? P
|
|
40
|
+
} : o, {
|
|
41
|
+
fallback: P
|
|
42
|
+
}) ?? P, f = J[G], [R, A] = q(!!t), [k, O] = q(!!n), V = !!t;
|
|
43
|
+
let h;
|
|
44
|
+
e[14] !== f || e[15] !== A || e[16] !== V ? (h = D(V, A, f), e[14] = f, e[15] = A, e[16] = V, e[17] = h) : h = e[17];
|
|
45
|
+
const j = h, z = !!n;
|
|
46
|
+
let v;
|
|
47
|
+
e[18] !== O || e[19] !== f || e[20] !== z ? (v = D(z, O, f), e[18] = O, e[19] = f, e[20] = z, e[21] = v) : v = e[21];
|
|
48
|
+
const C = v;
|
|
49
|
+
let I;
|
|
50
|
+
e[22] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (I = {
|
|
51
|
+
pointerEvents: "auto",
|
|
52
|
+
height: "100%",
|
|
53
|
+
color: w.OnSurface,
|
|
30
54
|
_disabled: {
|
|
31
55
|
opacity: 1,
|
|
32
|
-
color:
|
|
56
|
+
color: w.OnSurfaceSubdued
|
|
33
57
|
}
|
|
34
|
-
}, e[
|
|
35
|
-
const
|
|
36
|
-
let
|
|
37
|
-
e[
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
paddingInline: A,
|
|
46
|
-
width: O,
|
|
47
|
-
...q
|
|
48
|
-
}, e[18] = A, e[19] = O, e[20] = f) : f = e[20];
|
|
49
|
-
let u;
|
|
50
|
-
e[21] !== c || e[22] !== f ? (u = {
|
|
51
|
-
"& > div:first-of-type": c,
|
|
52
|
-
"& > div:last-of-type": f
|
|
53
|
-
}, e[21] = c, e[22] = f, e[23] = u) : u = e[23];
|
|
54
|
-
let p;
|
|
55
|
-
e[24] !== R || e[25] !== o || e[26] !== n || e[27] !== d || e[28] !== E || e[29] !== r || e[30] !== m || e[31] !== I ? (p = /* @__PURE__ */ z(C, { ref: E, css: R, size: m, variant: I, disabled: o, readOnly: n, required: d, ...r }), e[24] = R, e[25] = o, e[26] = n, e[27] = d, e[28] = E, e[29] = r, e[30] = m, e[31] = I, e[32] = p) : p = e[32];
|
|
58
|
+
}, e[22] = I) : I = e[22];
|
|
59
|
+
const U = I;
|
|
60
|
+
let _;
|
|
61
|
+
e[23] !== t || e[24] !== R ? (_ = t ? {
|
|
62
|
+
ref: R,
|
|
63
|
+
justifyContent: "flex-start",
|
|
64
|
+
paddingInlineStart: b.Small,
|
|
65
|
+
paddingInlineEnd: b.XSmall,
|
|
66
|
+
...U
|
|
67
|
+
} : void 0, e[23] = t, e[24] = R, e[25] = _) : _ = e[25];
|
|
68
|
+
const H = _;
|
|
56
69
|
let y;
|
|
57
|
-
|
|
70
|
+
e[26] !== k || e[27] !== n ? (y = n ? {
|
|
71
|
+
ref: k,
|
|
72
|
+
justifyContent: "flex-end",
|
|
73
|
+
paddingInlineStart: b.XSmall,
|
|
74
|
+
paddingInlineEnd: b.Small,
|
|
75
|
+
...U
|
|
76
|
+
} : void 0, e[26] = k, e[27] = n, e[28] = y) : y = e[28];
|
|
77
|
+
const M = y;
|
|
78
|
+
let u;
|
|
79
|
+
e[29] !== x || e[30] !== C || e[31] !== r || e[32] !== s || e[33] !== a || e[34] !== i || e[35] !== m || e[36] !== o || e[37] !== j || e[38] !== T ? (u = /* @__PURE__ */ $(Z, { ref: i, css: x, size: o, variant: T, disabled: r, readOnly: s, required: a, ps: j, pe: C, ...m }), e[29] = x, e[30] = C, e[31] = r, e[32] = s, e[33] = a, e[34] = i, e[35] = m, e[36] = o, e[37] = j, e[38] = T, e[39] = u) : u = e[39];
|
|
80
|
+
let B;
|
|
81
|
+
return e[40] !== M || e[41] !== d || e[42] !== t || e[43] !== c || e[44] !== n || e[45] !== H || e[46] !== u ? (B = /* @__PURE__ */ $(F, { startElement: t, endElement: n, startAddon: d, endAddon: c, startElementProps: H, endElementProps: M, width: "100%", children: u }), e[40] = M, e[41] = d, e[42] = t, e[43] = c, e[44] = n, e[45] = H, e[46] = u, e[47] = B) : B = e[47], B;
|
|
58
82
|
});
|
|
59
83
|
export {
|
|
60
|
-
|
|
84
|
+
re as Input
|
|
61
85
|
};
|
|
@@ -4,7 +4,7 @@ import { ReactNode } from 'react';
|
|
|
4
4
|
export type VisualInputState = "success" | "warning";
|
|
5
5
|
export type CustomProperties = {
|
|
6
6
|
/** Size of input. Defaults to medium / 'md'. */
|
|
7
|
-
size?: ConditionalValue<"sm" | "md" | "lg">;
|
|
7
|
+
size?: ConditionalValue<"sm" | "md" | "lg" | "xl">;
|
|
8
8
|
/** Element to append to the right of input */
|
|
9
9
|
rightAddon?: ReactNode;
|
|
10
10
|
/** Element to append to the left of input */
|
|
@@ -22,7 +22,7 @@ export type CustomProperties = {
|
|
|
22
22
|
isReadOnly?: boolean;
|
|
23
23
|
isRequired?: boolean;
|
|
24
24
|
};
|
|
25
|
-
type ChakraInputProperties = Pick<ChakraInputProps, "id" | "type" | "value" | "placeholder" | "onChange" | "onBlur" | "onFocus" | "onKeyDown" | "name" | "autoComplete" | "autoFocus" | "pattern" | "inputMode" | "defaultValue">;
|
|
25
|
+
type ChakraInputProperties = Pick<ChakraInputProps, "id" | "type" | "value" | "placeholder" | "onChange" | "onBlur" | "onFocus" | "onKeyDown" | "onPaste" | "name" | "autoComplete" | "autoFocus" | "pattern" | "inputMode" | "defaultValue">;
|
|
26
26
|
export type InputProps = CustomProperties & ChakraInputProperties & CustomChakraBoxProps & LayoutProps & MarginProps & PaddingProps & TypographyProps;
|
|
27
27
|
export {};
|
|
28
28
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../lib/components/input/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC7G,OAAO,KAAK,EAAE,UAAU,IAAI,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,CAAC;AAErD,MAAM,MAAM,gBAAgB,GAAG;IAC9B,gDAAgD;IAChD,IAAI,CAAC,EAAE,gBAAgB,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../lib/components/input/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC7G,OAAO,KAAK,EAAE,UAAU,IAAI,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,CAAC;AAErD,MAAM,MAAM,gBAAgB,GAAG;IAC9B,gDAAgD;IAChD,IAAI,CAAC,EAAE,gBAAgB,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;IACnD,8CAA8C;IAC9C,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,6CAA6C;IAC7C,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,uEAAuE;IACvE,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,sEAAsE;IACtE,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB;mGAC+F;IAC/F,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,uEAAuE;IACvE,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAG9B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,KAAK,qBAAqB,GAAG,IAAI,CAChC,gBAAgB,EACd,IAAI,GACJ,MAAM,GACN,OAAO,GACP,aAAa,GACb,UAAU,GACV,QAAQ,GACR,SAAS,GACT,WAAW,GACX,SAAS,GACT,MAAM,GACN,cAAc,GACd,WAAW,GACX,SAAS,GACT,WAAW,GACX,cAAc,CAChB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,gBAAgB,GACxC,qBAAqB,GACrB,oBAAoB,GACpB,WAAW,GACX,WAAW,GACX,YAAY,GACZ,eAAe,CAAC"}
|
|
@@ -5,5 +5,8 @@ import { ButtonProps } from '@chakra-ui/react';
|
|
|
5
5
|
* A Box that acts as a trigger for Menu
|
|
6
6
|
* @see Docs https://caspeco.github.io/casper-ui-library/components/menu/
|
|
7
7
|
*/
|
|
8
|
-
export declare const MenuBoxButton: import('react').ForwardRefExoticComponent<Omit<BoxProps, InteractionProps> & Pick<ButtonProps, InteractionProps> &
|
|
8
|
+
export declare const MenuBoxButton: import('react').ForwardRefExoticComponent<Omit<BoxProps, InteractionProps> & Pick<ButtonProps, "_focus" | InteractionProps> & {
|
|
9
|
+
/** If `true`, the trigger is disabled and the menu cannot be opened. */
|
|
10
|
+
isDisabled?: boolean;
|
|
11
|
+
} & import('react').RefAttributes<HTMLButtonElement>>;
|
|
9
12
|
//# sourceMappingURL=menu-box-button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-box-button.d.ts","sourceRoot":"","sources":["../../../lib/components/menu/menu-box-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAA4C,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"menu-box-button.d.ts","sourceRoot":"","sources":["../../../lib/components/menu/menu-box-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAA4C,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAS9F;;;GAGG;AACH,eAAO,MAAM,aAAa;IARxB,wEAAwE;iBAC3D,OAAO;qDAiBrB,CAAC"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import { c as m } from "../../_virtual/compiler-runtime.js";
|
|
3
|
-
import { MenuTrigger as
|
|
4
|
-
import { forwardRef as
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
children:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
import { MenuTrigger as u, Button as p } from "@chakra-ui/react";
|
|
4
|
+
import { forwardRef as d } from "react";
|
|
5
|
+
const a = d((l, s) => {
|
|
6
|
+
const e = m.c(9);
|
|
7
|
+
let t, o, r;
|
|
8
|
+
e[0] !== l ? ({
|
|
9
|
+
children: t,
|
|
10
|
+
isDisabled: o,
|
|
11
|
+
...r
|
|
12
|
+
} = l, e[0] = l, e[1] = t, e[2] = o, e[3] = r) : (t = e[1], o = e[2], r = e[3]);
|
|
13
|
+
let i;
|
|
14
|
+
return e[4] !== t || e[5] !== o || e[6] !== r || e[7] !== s ? (i = /* @__PURE__ */ n(u, { asChild: !0, children: /* @__PURE__ */ n(p, { ref: s, unstyled: !0, disabled: o, ...r, children: t }) }), e[4] = t, e[5] = o, e[6] = r, e[7] = s, e[8] = i) : i = e[8], i;
|
|
14
15
|
});
|
|
15
|
-
|
|
16
|
+
a.displayName = "MenuBoxButton";
|
|
16
17
|
export {
|
|
17
|
-
|
|
18
|
+
a as MenuBoxButton
|
|
18
19
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CountryCode } from 'libphonenumber-js';
|
|
2
|
+
import { Locales } from './translations.js';
|
|
3
|
+
/** Lowercases and strips diacritics for accent-insensitive search (e.g. "espana" matches "España"). */
|
|
4
|
+
export declare function normalizeForSearch(value: string): string;
|
|
5
|
+
/** A country row produced by {@link getLocalizedCountries}. */
|
|
6
|
+
export interface CountryItem {
|
|
7
|
+
code: CountryCode;
|
|
8
|
+
/** Name in the UI locale (e.g. "Germany"/"Tyskland"); shown in the list. */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Name in the country's own language (e.g. "Deutschland" for DE). */
|
|
11
|
+
nativeName: string;
|
|
12
|
+
callingCode: string;
|
|
13
|
+
/** Normalized search haystack, e.g. "germany deutschland de 49" for DE in en-US. */
|
|
14
|
+
searchText: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Country list localized to `locale`, sorted by localized name, memoized per locale.
|
|
18
|
+
* Each item's `searchText` is precomputed so callers filter with one substring match.
|
|
19
|
+
* The returned array is shared — do not mutate it.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getLocalizedCountries(locale: Locales): CountryItem[];
|
|
22
|
+
//# sourceMappingURL=country-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country-data.d.ts","sourceRoot":"","sources":["../../../lib/components/phone-input/country-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC1F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,uGAAuG;AACvG,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKxD;AAQD,+DAA+D;AAC/D,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,WAAW,CAAC;IAClB,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,oFAAoF;IACpF,UAAU,EAAE,MAAM,CAAC;CACnB;AAgBD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,WAAW,EAAE,CAmBpE"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getCountries as m } from "../../node_modules/libphonenumber-js/min/exports/getCountries.js";
|
|
2
|
+
import { getCountryCallingCode as r } from "../../node_modules/libphonenumber-js/min/exports/getCountryCallingCode.js";
|
|
3
|
+
function l(e) {
|
|
4
|
+
return e.normalize("NFD").replace(new RegExp("\\p{Diacritic}", "gu"), "").toLowerCase();
|
|
5
|
+
}
|
|
6
|
+
const s = m().map((e) => {
|
|
7
|
+
const n = new Intl.Locale(`und-${e}`).maximize().language, t = new Intl.DisplayNames([n], {
|
|
8
|
+
type: "region"
|
|
9
|
+
}).of(e) ?? e;
|
|
10
|
+
return {
|
|
11
|
+
code: e,
|
|
12
|
+
callingCode: r(e),
|
|
13
|
+
nativeName: t
|
|
14
|
+
};
|
|
15
|
+
}), o = /* @__PURE__ */ new Map();
|
|
16
|
+
function C(e) {
|
|
17
|
+
let n = o.get(e);
|
|
18
|
+
if (!n) {
|
|
19
|
+
const t = new Intl.DisplayNames([e], {
|
|
20
|
+
type: "region"
|
|
21
|
+
});
|
|
22
|
+
n = s.map((a) => {
|
|
23
|
+
const i = t.of(a.code) ?? a.code;
|
|
24
|
+
return {
|
|
25
|
+
code: a.code,
|
|
26
|
+
name: i,
|
|
27
|
+
nativeName: a.nativeName,
|
|
28
|
+
callingCode: a.callingCode,
|
|
29
|
+
searchText: l(`${i} ${a.nativeName} ${a.code} ${a.callingCode}`)
|
|
30
|
+
};
|
|
31
|
+
}).sort((a, i) => a.name.localeCompare(i.name, e)), o.set(e, n);
|
|
32
|
+
}
|
|
33
|
+
return n;
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
C as getLocalizedCountries,
|
|
37
|
+
l as normalizeForSearch
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country-data.spec.d.ts","sourceRoot":"","sources":["../../../lib/components/phone-input/country-data.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CountryCode } from 'libphonenumber-js';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { CountryItem } from './country-data.js';
|
|
4
|
+
interface CountryListProps {
|
|
5
|
+
items: CountryItem[];
|
|
6
|
+
/** Renders the row contents for an item (flag, name, calling code). */
|
|
7
|
+
renderItem: (item: CountryItem) => ReactNode;
|
|
8
|
+
isReadOnly?: boolean;
|
|
9
|
+
/** The currently selected country code; its row renders a checkmark. */
|
|
10
|
+
selectedCode?: CountryCode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Virtualized country list: only the visible rows are mounted, so the ~245-country dropdown
|
|
14
|
+
* stays fast. Rendered inside the Menu content, so clicking a row still selects through the
|
|
15
|
+
* Menu's `onSelect`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function CountryList({ items, renderItem, isReadOnly, selectedCode }: CountryListProps): import("react").JSX.Element;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=country-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country-list.d.ts","sourceRoot":"","sources":["../../../lib/components/phone-input/country-list.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAU,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMlD,UAAU,gBAAgB;IACzB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,uEAAuE;IACvE,UAAU,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,SAAS,CAAC;IAC7C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,wEAAwE;IACxE,YAAY,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,UAAkB,EAAE,YAAY,EAAE,EAAE,gBAAgB,+BA2CpG"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { Box as i } from "@chakra-ui/react";
|
|
3
|
+
import { useVirtualizer as a } from "../../node_modules/@tanstack/react-virtual/dist/esm/index.js";
|
|
4
|
+
import { useRef as u } from "react";
|
|
5
|
+
import { MenuItem as d } from "../menu/menu-item.js";
|
|
6
|
+
import { CheckIcon as f } from "../icon/icons/check-icon.js";
|
|
7
|
+
const h = 40, p = 250, I = 300;
|
|
8
|
+
function _({
|
|
9
|
+
items: n,
|
|
10
|
+
renderItem: s,
|
|
11
|
+
isReadOnly: c = !1,
|
|
12
|
+
selectedCode: m
|
|
13
|
+
}) {
|
|
14
|
+
const l = u(null), o = a({
|
|
15
|
+
count: n.length,
|
|
16
|
+
getScrollElement: () => l.current,
|
|
17
|
+
estimateSize: () => h,
|
|
18
|
+
overscan: 8
|
|
19
|
+
});
|
|
20
|
+
return /* @__PURE__ */ t(i, { ref: l, maxHeight: p, minWidth: I, overflowY: "auto", children: /* @__PURE__ */ t(i, { height: o.getTotalSize(), position: "relative", width: "100%", children: o.getVirtualItems().map((r) => {
|
|
21
|
+
const e = n[r.index];
|
|
22
|
+
return e ? /* @__PURE__ */ t(i, { "data-index": r.index, ref: o.measureElement, position: "absolute", top: 0, left: 0, width: "100%", transform: `translateY(${r.start}px)`, children: /* @__PURE__ */ t(d, { value: e.code, isDisabled: c, rightIcon: e.code === m ? f : void 0, children: s(e) }) }, e.code) : null;
|
|
23
|
+
}) }) });
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
_ as CountryList
|
|
27
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Placement } from '../combobox/index.js';
|
|
2
|
+
import { CountryCode } from 'libphonenumber-js';
|
|
3
|
+
import { default as React } from 'react';
|
|
4
|
+
import { Locales } from './translations.js';
|
|
5
|
+
export interface CountrySelectorProps {
|
|
6
|
+
/**
|
|
7
|
+
* The currently selected country code (e.g., 'US', 'GB', 'FR')
|
|
8
|
+
*/
|
|
9
|
+
value?: CountryCode;
|
|
10
|
+
/**
|
|
11
|
+
* Callback fired when the selected country changes
|
|
12
|
+
*/
|
|
13
|
+
onChange: (country: CountryCode) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Placeholder text displayed in the input field
|
|
16
|
+
* @default "Search country..."
|
|
17
|
+
*/
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the selector is disabled
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
isDisabled?: boolean;
|
|
24
|
+
/** Size of the input and menu items
|
|
25
|
+
* @default "md"
|
|
26
|
+
*/
|
|
27
|
+
size?: "sm" | "md" | "lg" | "xl";
|
|
28
|
+
/**
|
|
29
|
+
* Whether the field is read-only
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
isReadOnly?: boolean;
|
|
33
|
+
/** Menu placement for the dropdown (optional) */
|
|
34
|
+
menuPlacement?: Placement;
|
|
35
|
+
/** Locale for translations */
|
|
36
|
+
locale?: Locales;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Country selector component for phone input
|
|
40
|
+
*
|
|
41
|
+
* Provides a searchable dropdown to select a country. Uses the Menu component
|
|
42
|
+
* with custom search functionality for efficient searching through 245+ countries/regions.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* const [country, setCountry] = React.useState<CountryCode>("US");
|
|
47
|
+
*
|
|
48
|
+
* <CountrySelector
|
|
49
|
+
* id="country-selector"
|
|
50
|
+
* value={country}
|
|
51
|
+
* onChange={setCountry}
|
|
52
|
+
* placeholder="Select country..."
|
|
53
|
+
* />
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @see Docs https://caspeco.github.io/casper-ui-library/components/phone-input
|
|
57
|
+
*/
|
|
58
|
+
export declare function CountrySelector({ value, onChange, placeholder, isReadOnly, size, menuPlacement, locale, isDisabled, }: CountrySelectorProps): React.JSX.Element;
|
|
59
|
+
//# sourceMappingURL=country-selector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country-selector.d.ts","sourceRoot":"","sources":["../../../lib/components/phone-input/country-selector.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAWvD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAA0B,MAAM,OAAO,CAAC;AAG/C,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA2B5D,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;IAEpB;;OAEG;IACH,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;IAEzC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAEjC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,iDAAiD;IACjD,aAAa,CAAC,EAAE,SAAS,CAAC;IAE1B,8BAA8B;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAAC,EAC/B,KAAK,EACL,QAAQ,EACR,WAAW,EACX,UAAkB,EAClB,IAAW,EACX,aAAa,EACb,MAAgB,EAChB,UAAkB,GAClB,EAAE,oBAAoB,qBAiHtB"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { jsx as l, jsxs as V } from "react/jsx-runtime";
|
|
2
|
+
import { c as Se } from "../../_virtual/compiler-runtime.js";
|
|
3
|
+
import * as ge from "../../node_modules/country-flag-icons/react/3x2/index.js";
|
|
4
|
+
import { useState as Ce, useId as ye } from "react";
|
|
5
|
+
import { getLocalizedCountries as xe, normalizeForSearch as be } from "./country-data.js";
|
|
6
|
+
import { CountryList as ve } from "./country-list.js";
|
|
7
|
+
import { translations as Ie } from "./translations.js";
|
|
8
|
+
import { ModuleWebIcon as _e } from "../icon/icons/module-web-icon.js";
|
|
9
|
+
import { MenuIconButton as Fe } from "../menu/menu-icon-button.js";
|
|
10
|
+
import { SelectIcon as Te } from "../icon/icons/select-icon.js";
|
|
11
|
+
import { Text as te } from "../text/text.js";
|
|
12
|
+
import ze from "../../node_modules/country-flag-icons/modules/hasFlag.js";
|
|
13
|
+
import { Menu as Oe } from "../menu/menu.js";
|
|
14
|
+
import { Flex as fe } from "../flex/flex.js";
|
|
15
|
+
import { MenuBoxButton as Be } from "../menu/menu-box-button.js";
|
|
16
|
+
import { SearchIcon as Me } from "../icon/icons/search-icon.js";
|
|
17
|
+
import { Box as ue } from "../box/box.js";
|
|
18
|
+
import { FormControl as we } from "../form-control/form-control.js";
|
|
19
|
+
import { Input as Le } from "../input/input.js";
|
|
20
|
+
import { Divider as Ee } from "../divider/divider.js";
|
|
21
|
+
import { MenuList as De } from "../menu/menu-list.js";
|
|
22
|
+
import { ThemeSpaceVariable as Y, ThemeColorVariable as oe, ThemeFontSizeVariable as je } from "../../theme/theme-types.js";
|
|
23
|
+
function pe(n) {
|
|
24
|
+
const e = n.code;
|
|
25
|
+
if (!ze(e))
|
|
26
|
+
return null;
|
|
27
|
+
const t = ge[e];
|
|
28
|
+
return t ? /* @__PURE__ */ l(t, { "aria-label": n.name, height: 16, width: 24, style: {
|
|
29
|
+
flexShrink: 0,
|
|
30
|
+
boxShadow: `0 0 0 1px ${oe.OnSurfaceBorder}`
|
|
31
|
+
} }) : null;
|
|
32
|
+
}
|
|
33
|
+
const ke = {
|
|
34
|
+
xs: 12,
|
|
35
|
+
sm: 12,
|
|
36
|
+
md: 16,
|
|
37
|
+
lg: 20,
|
|
38
|
+
xl: 24
|
|
39
|
+
};
|
|
40
|
+
function it(n) {
|
|
41
|
+
const e = Se.c(87), {
|
|
42
|
+
value: t,
|
|
43
|
+
onChange: P,
|
|
44
|
+
placeholder: he,
|
|
45
|
+
isReadOnly: le,
|
|
46
|
+
size: ne,
|
|
47
|
+
menuPlacement: Z,
|
|
48
|
+
locale: re,
|
|
49
|
+
isDisabled: ie
|
|
50
|
+
} = n, q = le === void 0 ? !1 : le, se = ne === void 0 ? "md" : ne, $ = re === void 0 ? "en-US" : re, c = ie === void 0 ? !1 : ie, [d, ae] = Ce(""), G = ye(), m = Ie[$], J = se === "sm" ? "xs" : "sm", R = ke[se];
|
|
51
|
+
let f, u, p, h, S, r, g, i, C, y, x, b, s, v, I, _, F, a, T, z, O, B, M;
|
|
52
|
+
if (e[0] !== c || e[1] !== $ || e[2] !== R || e[3] !== Z || e[4] !== P || e[5] !== d || e[6] !== t) {
|
|
53
|
+
const Q = xe($), ce = be(d.trim());
|
|
54
|
+
r = ce ? Q.filter((o) => o.searchText.includes(ce)) : Q;
|
|
55
|
+
const me = t ? r.find((o) => o.code === t) : void 0;
|
|
56
|
+
S = me ? [me, ...r.filter((o) => o.code !== t)] : r;
|
|
57
|
+
let A;
|
|
58
|
+
e[30] !== t ? (A = (o) => o.code === t, e[30] = t, e[31] = A) : A = e[31];
|
|
59
|
+
const de = Q.find(A);
|
|
60
|
+
let H;
|
|
61
|
+
e[32] !== P ? (H = (o) => {
|
|
62
|
+
P(o), ae("");
|
|
63
|
+
}, e[32] = P, e[33] = H) : H = e[33];
|
|
64
|
+
const ee = H;
|
|
65
|
+
let N;
|
|
66
|
+
e[34] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (N = (o) => {
|
|
67
|
+
ae(o.target.value);
|
|
68
|
+
}, e[34] = N) : N = e[34], g = N, h = Re, p = Oe, e[35] !== ee ? (s = (o) => {
|
|
69
|
+
ee(o.value);
|
|
70
|
+
}, e[35] = ee, e[36] = s) : s = e[36], v = !0, I = Z, _ = !0, F = "unmount", e[37] !== R ? (a = [-8, R], e[37] = R, e[38] = a) : a = e[38], u = fe, y = "center", x = Y.XSmall, b = "center", f = Be, T = "flex", z = c, O = c ? "disabled" : "pointer", B = -1, M = !0, e[39] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (i = {
|
|
71
|
+
outline: "none"
|
|
72
|
+
}, e[39] = i) : i = e[39], C = de ? pe(de) : /* @__PURE__ */ l(_e, {}), e[0] = c, e[1] = $, e[2] = R, e[3] = Z, e[4] = P, e[5] = d, e[6] = t, e[7] = f, e[8] = u, e[9] = p, e[10] = h, e[11] = S, e[12] = r, e[13] = g, e[14] = i, e[15] = C, e[16] = y, e[17] = x, e[18] = b, e[19] = s, e[20] = v, e[21] = I, e[22] = _, e[23] = F, e[24] = a, e[25] = T, e[26] = z, e[27] = O, e[28] = B, e[29] = M;
|
|
73
|
+
} else
|
|
74
|
+
f = e[7], u = e[8], p = e[9], h = e[10], S = e[11], r = e[12], g = e[13], i = e[14], C = e[15], y = e[16], x = e[17], b = e[18], s = e[19], v = e[20], I = e[21], _ = e[22], F = e[23], a = e[24], T = e[25], z = e[26], O = e[27], B = e[28], M = e[29];
|
|
75
|
+
let w;
|
|
76
|
+
e[40] !== f || e[41] !== i || e[42] !== C || e[43] !== T || e[44] !== z || e[45] !== O || e[46] !== B || e[47] !== M ? (w = /* @__PURE__ */ l(f, { display: T, isDisabled: z, cursor: O, tabIndex: B, "aria-hidden": M, _focus: i, children: C }), e[40] = f, e[41] = i, e[42] = C, e[43] = T, e[44] = z, e[45] = O, e[46] = B, e[47] = M, e[48] = w) : w = e[48];
|
|
77
|
+
let L;
|
|
78
|
+
e[49] !== J || e[50] !== c || e[51] !== m.openCountrySelector ? (L = /* @__PURE__ */ l(Fe, { size: J, variant: "ghost", icon: Te, isDisabled: c, "aria-label": m.openCountrySelector }), e[49] = J, e[50] = c, e[51] = m.openCountrySelector, e[52] = L) : L = e[52];
|
|
79
|
+
let E;
|
|
80
|
+
e[53] !== u || e[54] !== y || e[55] !== x || e[56] !== b || e[57] !== w || e[58] !== L ? (E = /* @__PURE__ */ V(u, { align: y, gap: x, justify: b, children: [
|
|
81
|
+
w,
|
|
82
|
+
L
|
|
83
|
+
] }), e[53] = u, e[54] = y, e[55] = x, e[56] = b, e[57] = w, e[58] = L, e[59] = E) : E = e[59];
|
|
84
|
+
const K = he ?? m.searchCountryPlaceholder;
|
|
85
|
+
let U;
|
|
86
|
+
e[60] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (U = /* @__PURE__ */ l(Me, {}), e[60] = U) : U = e[60];
|
|
87
|
+
let D;
|
|
88
|
+
e[61] !== g || e[62] !== G || e[63] !== d || e[64] !== K ? (D = /* @__PURE__ */ l(ue, { onClick: Pe, children: /* @__PURE__ */ l(we, { isInvalid: !1, children: /* @__PURE__ */ l(Le, { id: G, placeholder: K, size: "md", value: d, onChange: g, variant: "ghost", leftElement: U }) }) }), e[61] = g, e[62] = G, e[63] = d, e[64] = K, e[65] = D) : D = e[65];
|
|
89
|
+
let W;
|
|
90
|
+
e[66] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (W = /* @__PURE__ */ l(Ee, { mb: "3px" }), e[66] = W) : W = e[66];
|
|
91
|
+
let j;
|
|
92
|
+
e[67] !== h || e[68] !== S || e[69] !== r.length || e[70] !== q || e[71] !== m.noCountriesFound || e[72] !== t ? (j = r.length > 0 ? /* @__PURE__ */ l(ve, { items: S, renderItem: h, isReadOnly: q, selectedCode: t }) : /* @__PURE__ */ l(te, { padding: Y.Medium, paddingBottom: Y.X2Large, fontSize: je.Large, color: oe.OnBackgroundHeader, fontWeight: "500", textAlign: "center", width: "300px", children: m.noCountriesFound }), e[67] = h, e[68] = S, e[69] = r.length, e[70] = q, e[71] = m.noCountriesFound, e[72] = t, e[73] = j) : j = e[73];
|
|
93
|
+
let k;
|
|
94
|
+
e[74] !== D || e[75] !== j ? (k = /* @__PURE__ */ V(De, { overflow: "unset", overflowY: "unset", paddingTop: 0, children: [
|
|
95
|
+
D,
|
|
96
|
+
W,
|
|
97
|
+
j
|
|
98
|
+
] }), e[74] = D, e[75] = j, e[76] = k) : k = e[76];
|
|
99
|
+
let X;
|
|
100
|
+
return e[77] !== p || e[78] !== s || e[79] !== v || e[80] !== I || e[81] !== _ || e[82] !== F || e[83] !== a || e[84] !== E || e[85] !== k ? (X = /* @__PURE__ */ V(p, { onSelect: s, closeOnSelect: v, placement: I, isLazy: _, lazyBehavior: F, offset: a, children: [
|
|
101
|
+
E,
|
|
102
|
+
k
|
|
103
|
+
] }), e[77] = p, e[78] = s, e[79] = v, e[80] = I, e[81] = _, e[82] = F, e[83] = a, e[84] = E, e[85] = k, e[86] = X) : X = e[86], X;
|
|
104
|
+
}
|
|
105
|
+
function Pe(n) {
|
|
106
|
+
return n.stopPropagation();
|
|
107
|
+
}
|
|
108
|
+
function Re(n) {
|
|
109
|
+
return /* @__PURE__ */ V(fe, { direction: "row", gap: Y.Small, alignItems: "center", children: [
|
|
110
|
+
pe(n),
|
|
111
|
+
/* @__PURE__ */ V(ue, { children: [
|
|
112
|
+
/* @__PURE__ */ l(te, { display: "inline", children: n.name }),
|
|
113
|
+
" ",
|
|
114
|
+
/* @__PURE__ */ l(te, { display: "inline", color: oe.OnSurfaceSubdued, children: `(+${n.callingCode})` })
|
|
115
|
+
] })
|
|
116
|
+
] });
|
|
117
|
+
}
|
|
118
|
+
export {
|
|
119
|
+
it as CountrySelector
|
|
120
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { PhoneInput } from './phone-input.js';
|
|
2
|
+
export { usePhoneInput } from './use-phone-input.js';
|
|
3
|
+
export type { UsePhoneInputOptions, UsePhoneInputReturn } from './use-phone-input.js';
|
|
4
|
+
export type { CountryCode, PhoneInputControlProps, PhoneInputProps, PhoneValidationResult } from './types.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/phone-input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACnF,YAAY,EAAE,WAAW,EAAE,sBAAsB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CountryCode } from 'libphonenumber-js';
|
|
2
|
+
import { Locales } from './translations.js';
|
|
3
|
+
import { PhoneValidationResult } from './types.js';
|
|
4
|
+
export type ValidatePhoneNumberOptions = {
|
|
5
|
+
/** Field is required (drives the empty-value error once feedback is revealed). */
|
|
6
|
+
isRequired?: boolean;
|
|
7
|
+
/** Whether to surface error feedback (revealed on blur/validate, cleared when fixed). */
|
|
8
|
+
showValidation?: boolean;
|
|
9
|
+
/** Locale for error messages. */
|
|
10
|
+
locale?: Locales;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Validate a phone number for a country. `isValid` is always reported; `errorMessage` is set only
|
|
14
|
+
* when `showValidation` is true and the number fails (required+empty, or content not yet valid).
|
|
15
|
+
*/
|
|
16
|
+
export declare function validatePhoneNumber(value: string, country: CountryCode, options?: ValidatePhoneNumberOptions): PhoneValidationResult;
|
|
17
|
+
/** Format to international format, or return the original value if it can't be parsed. */
|
|
18
|
+
export declare function formatPhoneNumber(value: string, country: CountryCode): string;
|
|
19
|
+
/**
|
|
20
|
+
* Convert to E.164 storage format (e.g. "+46737884410"). Falls back to a best-effort "+digits"
|
|
21
|
+
* while the number is still being typed, and "" when empty.
|
|
22
|
+
*/
|
|
23
|
+
export declare function toE164(value: string, country: CountryCode): string;
|
|
24
|
+
/** National number (digits without the country code), or "" if there is none. */
|
|
25
|
+
export declare function extractNationalNumber(value: string, country: CountryCode): string;
|
|
26
|
+
/** Whether the value has a national number beyond a bare dial-code prefix ("+46" → false, "+46 73…" → true). */
|
|
27
|
+
export declare function hasNationalContent(value: string, country: CountryCode): boolean;
|
|
28
|
+
/** Whether the value has content but isn't yet valid (warrants an "incomplete" warning). */
|
|
29
|
+
export declare function isIncompletePhoneNumber(value: string, country: CountryCode): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Detect the country for an international "+" value, resolving its calling code (longest match
|
|
32
|
+
* first) to the primary region. Returns undefined for non-"+" values or unknown codes.
|
|
33
|
+
*/
|
|
34
|
+
export declare function detectCountryFromInput(value: string): CountryCode | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* The country to switch to for a "+" value, or undefined to keep `currentCountry`. Switches only on
|
|
37
|
+
* a different calling code, so countries sharing one (e.g. American Samoa & US, both +1) keep their flag.
|
|
38
|
+
*/
|
|
39
|
+
export declare function detectCountryChange(value: string, currentCountry: CountryCode): CountryCode | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Whether a "+" value's leading digits can no longer prefix any calling code ("+999"), used to
|
|
42
|
+
* show a generic flag. A bare "+" or a viable prefix returns false to avoid flicker while typing.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isUnknownCallingCode(value: string): boolean;
|
|
45
|
+
/** Resolve the initial country: explicit prop → device locale → locale-prop region → "SE". */
|
|
46
|
+
export declare function resolveInitialCountry(country: CountryCode | undefined, locale: Locales): CountryCode;
|
|
47
|
+
//# sourceMappingURL=phone-input-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-input-helpers.d.ts","sourceRoot":"","sources":["../../../lib/components/phone-input/phone-input-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAMN,KAAK,WAAW,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,MAAM,0BAA0B,GAAG;IACxC,kFAAkF;IAClF,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,yFAAyF;IACzF,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,iCAAiC;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,0BAA+B,GACtC,qBAAqB,CAmBvB;AAED,0FAA0F;AAC1F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,MAAM,CAE7E;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,MAAM,CAalE;AAED,iFAAiF;AACjF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,MAAM,CAQjF;AASD,gHAAgH;AAChH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAE/E;AAED,4FAA4F;AAC5F,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAEpF;AA+BD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CA6B7E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,GAAG,WAAW,GAAG,SAAS,CAUvG;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAgB3D;AA+BD,8FAA8F;AAC9F,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,EAAE,MAAM,EAAE,OAAO,GAAG,WAAW,CAKpG"}
|