@phillips/seldon 1.174.0 → 1.176.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/ProgressIndicator/ProgressIndicator.d.ts +43 -0
- package/dist/components/ProgressIndicator/ProgressIndicator.js +62 -0
- package/dist/components/ProgressIndicator/ProgressIndicator.stories.d.ts +52 -0
- package/dist/components/ProgressIndicator/ProgressIndicator.test.d.ts +1 -0
- package/dist/components/ProgressIndicator/index.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +92 -88
- package/dist/node_modules/@radix-ui/react-progress/dist/index.js +84 -0
- package/dist/node_modules/@radix-ui/react-progress/node_modules/@radix-ui/react-primitive/dist/index.js +32 -0
- package/dist/node_modules/@radix-ui/react-progress/node_modules/@radix-ui/react-slot/dist/index.js +49 -0
- package/dist/patterns/CountryPicker/CountryPicker.d.ts +14 -0
- package/dist/patterns/CountryPicker/CountryPicker.js +71 -0
- package/dist/patterns/CountryPicker/CountryPicker.stories.d.ts +14 -0
- package/dist/patterns/CountryPicker/CountryPicker.test.d.ts +1 -0
- package/dist/patterns/CountryPicker/CountryPickerCountryList.d.ts +34 -0
- package/dist/patterns/CountryPicker/CountryPickerCountryList.js +66 -0
- package/dist/patterns/CountryPicker/CountryPickerCountryList.test.d.ts +1 -0
- package/dist/patterns/CountryPicker/CountryPickerModal.d.ts +24 -0
- package/dist/patterns/CountryPicker/CountryPickerModal.js +117 -0
- package/dist/patterns/CountryPicker/CountryPickerModal.test.d.ts +1 -0
- package/dist/patterns/CountryPicker/CountryPickerOption.d.ts +20 -0
- package/dist/patterns/CountryPicker/CountryPickerOption.js +62 -0
- package/dist/patterns/CountryPicker/CountryPickerOption.test.d.ts +1 -0
- package/dist/patterns/CountryPicker/CountryPickerTrigger.d.ts +21 -0
- package/dist/patterns/CountryPicker/CountryPickerTrigger.js +67 -0
- package/dist/patterns/CountryPicker/CountryPickerTrigger.test.d.ts +1 -0
- package/dist/patterns/CountryPicker/constants.d.ts +899 -0
- package/dist/patterns/CountryPicker/constants.js +279 -0
- package/dist/patterns/CountryPicker/index.d.ts +1 -0
- package/dist/patterns/CountryPicker/types.d.ts +30 -0
- package/dist/patterns/CountryPicker/types.js +6 -0
- package/dist/patterns/CountryPicker/utils.d.ts +2 -0
- package/dist/patterns/CountryPicker/utils.js +9 -0
- package/dist/patterns/CountryPicker/utils.test.d.ts +1 -0
- package/dist/scss/componentStyles.scss +4 -0
- package/dist/scss/components/Input/_input.scss +0 -3
- package/dist/scss/components/ProgressIndicator/_progressIndicator.scss +59 -0
- package/dist/scss/patterns/CountryPicker/_countryPickerModal.scss +108 -0
- package/dist/scss/patterns/CountryPicker/_countryPickerOption.scss +71 -0
- package/dist/scss/patterns/CountryPicker/_countryPickerTrigger.scss +73 -0
- package/package.json +2 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsxs as h, Fragment as v, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as N, useState as j } from "react";
|
|
3
|
+
import M from "./CountryPickerTrigger.js";
|
|
4
|
+
import O from "./CountryPickerModal.js";
|
|
5
|
+
import { getCommonProps as T } from "../../utils/index.js";
|
|
6
|
+
import { toConfig as m } from "./types.js";
|
|
7
|
+
const w = N(
|
|
8
|
+
({
|
|
9
|
+
triggerLabelText: l,
|
|
10
|
+
hasTriggerError: c,
|
|
11
|
+
triggerErrorMsg: u,
|
|
12
|
+
triggerDisplayValue: f,
|
|
13
|
+
modalTitle: p,
|
|
14
|
+
searchInputLabel: d,
|
|
15
|
+
searchInputPlaceholder: C,
|
|
16
|
+
selectButtonLabel: y,
|
|
17
|
+
inputName: o,
|
|
18
|
+
baseClassName: k = "CountryPicker",
|
|
19
|
+
value: t,
|
|
20
|
+
onChange: s,
|
|
21
|
+
isPhone: P,
|
|
22
|
+
...a
|
|
23
|
+
}, g) => {
|
|
24
|
+
const [x, i] = j(!1), { className: n } = T(a, k), b = {
|
|
25
|
+
modalTitle: p,
|
|
26
|
+
searchInputLabel: d,
|
|
27
|
+
searchInputPlaceholder: C,
|
|
28
|
+
selectButtonLabel: y,
|
|
29
|
+
inputName: o,
|
|
30
|
+
...a
|
|
31
|
+
}, r = P ? m(!0, t, s) : m(!1, t, s);
|
|
32
|
+
return /* @__PURE__ */ h(v, { children: [
|
|
33
|
+
/* @__PURE__ */ e(
|
|
34
|
+
M,
|
|
35
|
+
{
|
|
36
|
+
ref: g,
|
|
37
|
+
labelText: l,
|
|
38
|
+
displayValue: f,
|
|
39
|
+
onClick: () => i(!0),
|
|
40
|
+
hasError: c,
|
|
41
|
+
errorMsg: u,
|
|
42
|
+
variantConfig: r,
|
|
43
|
+
baseClassName: n
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
/* @__PURE__ */ e(
|
|
47
|
+
O,
|
|
48
|
+
{
|
|
49
|
+
...b,
|
|
50
|
+
isOpen: x,
|
|
51
|
+
onClose: () => i(!1),
|
|
52
|
+
variantConfig: r,
|
|
53
|
+
baseClassName: n
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
/* @__PURE__ */ e(
|
|
57
|
+
"input",
|
|
58
|
+
{
|
|
59
|
+
type: "hidden",
|
|
60
|
+
name: o || "value",
|
|
61
|
+
value: r.value ?? "",
|
|
62
|
+
"data-testid": "country-picker-hidden-input"
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
] });
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
w.displayName = "CountryPicker";
|
|
69
|
+
export {
|
|
70
|
+
w as default
|
|
71
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
import { default as CountryPicker, CountryPickerProps } from './CountryPicker';
|
|
3
|
+
declare const meta: Meta<typeof CountryPicker>;
|
|
4
|
+
export default meta;
|
|
5
|
+
export declare const Playground: {
|
|
6
|
+
(props: CountryPickerProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
args: {
|
|
8
|
+
modalTitle: string;
|
|
9
|
+
searchLabel: string;
|
|
10
|
+
searchPlaceholder: string;
|
|
11
|
+
selectButtonLabel: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare const CountryPhoneCodePicker: (props: CountryPickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CommonProps, Country } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the country list in the picker modal.
|
|
5
|
+
* Includes prioritized and grouped countries, styling, and refs for keyboard navigation.
|
|
6
|
+
*/
|
|
7
|
+
type CountryPickerCountryListProps = CommonProps & {
|
|
8
|
+
/**
|
|
9
|
+
* List of prioritized countries to display first (e.g., US, GB).
|
|
10
|
+
*/
|
|
11
|
+
filteredPrioritized: Country[];
|
|
12
|
+
/**
|
|
13
|
+
* Grouped countries by first letter for display with headers.
|
|
14
|
+
*/
|
|
15
|
+
groupedCountries: Record<string, Country[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Base class name for styling.
|
|
18
|
+
*/
|
|
19
|
+
baseClassName?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Title for the modal, used for aria-label.
|
|
22
|
+
*/
|
|
23
|
+
modalTitle: string;
|
|
24
|
+
/**
|
|
25
|
+
* Ref to the list container for keyboard navigation.
|
|
26
|
+
*/
|
|
27
|
+
listRef: React.RefObject<HTMLDivElement>;
|
|
28
|
+
/**
|
|
29
|
+
* Name attribute for radio inputs.
|
|
30
|
+
*/
|
|
31
|
+
inputName: string;
|
|
32
|
+
};
|
|
33
|
+
export declare const CountryPickerCountryList: ({ filteredPrioritized, groupedCountries, baseClassName, modalTitle, listRef, variantConfig, inputName, }: CountryPickerCountryListProps) => import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback as a } from "react";
|
|
3
|
+
import x from "../../components/Text/Text.js";
|
|
4
|
+
import { TextVariants as k } from "../../components/Text/types.js";
|
|
5
|
+
import { CountryPickerOption as v } from "./CountryPickerOption.js";
|
|
6
|
+
const j = ({
|
|
7
|
+
filteredPrioritized: y,
|
|
8
|
+
groupedCountries: f,
|
|
9
|
+
baseClassName: e,
|
|
10
|
+
modalTitle: m,
|
|
11
|
+
listRef: i,
|
|
12
|
+
variantConfig: c,
|
|
13
|
+
inputName: d
|
|
14
|
+
}) => {
|
|
15
|
+
const { isPhone: p, value: h } = c, s = a(
|
|
16
|
+
(r) => r.map(({ name: t, code: n }) => /* @__PURE__ */ l(
|
|
17
|
+
v,
|
|
18
|
+
{
|
|
19
|
+
code: n,
|
|
20
|
+
name: t,
|
|
21
|
+
isChecked: h === (p ? n : t),
|
|
22
|
+
inputName: d,
|
|
23
|
+
baseClassName: e,
|
|
24
|
+
variantConfig: c
|
|
25
|
+
},
|
|
26
|
+
n
|
|
27
|
+
)),
|
|
28
|
+
[h, p, d, e, c]
|
|
29
|
+
), _ = (r) => {
|
|
30
|
+
if (!i.current) return;
|
|
31
|
+
const t = Array.from(i.current.querySelectorAll('input[type="radio"]')), n = t.findIndex((o) => o === document.activeElement);
|
|
32
|
+
if (r.key === "ArrowDown" || r.key === "ArrowRight") {
|
|
33
|
+
r.preventDefault();
|
|
34
|
+
const o = (n + 1) % t.length;
|
|
35
|
+
t[o]?.focus();
|
|
36
|
+
} else if (r.key === "ArrowUp" || r.key === "ArrowLeft") {
|
|
37
|
+
r.preventDefault();
|
|
38
|
+
const o = (n - 1 + t.length) % t.length;
|
|
39
|
+
t[o]?.focus();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return /* @__PURE__ */ u(
|
|
43
|
+
"div",
|
|
44
|
+
{
|
|
45
|
+
className: `${e}__list`,
|
|
46
|
+
ref: i,
|
|
47
|
+
tabIndex: -1,
|
|
48
|
+
onKeyDown: _,
|
|
49
|
+
role: "radiogroup",
|
|
50
|
+
"aria-label": m,
|
|
51
|
+
children: [
|
|
52
|
+
s(y),
|
|
53
|
+
Object.entries(f).map(([r, t]) => /* @__PURE__ */ u("div", { className: `${e}__group`, children: [
|
|
54
|
+
/* @__PURE__ */ u("div", { className: `${e}__letter-header`, children: [
|
|
55
|
+
/* @__PURE__ */ l(x, { variant: k.heading2, className: `${e}__letter-text`, children: r }),
|
|
56
|
+
/* @__PURE__ */ l("div", { className: `${e}__letter-line` })
|
|
57
|
+
] }),
|
|
58
|
+
s(t)
|
|
59
|
+
] }, r))
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
j as CountryPickerCountryList
|
|
66
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type CountryPickerModalProps = {
|
|
2
|
+
/**
|
|
3
|
+
* The title displayed at the top of the modal.
|
|
4
|
+
*/
|
|
5
|
+
modalTitle: string;
|
|
6
|
+
/**
|
|
7
|
+
* The label for the search input field.
|
|
8
|
+
*/
|
|
9
|
+
searchInputLabel: string;
|
|
10
|
+
/**
|
|
11
|
+
* Placeholder text for the search input field.
|
|
12
|
+
*/
|
|
13
|
+
searchInputPlaceholder: string;
|
|
14
|
+
/**
|
|
15
|
+
* Label for the button used to confirm the selection.
|
|
16
|
+
*/
|
|
17
|
+
selectButtonLabel: string;
|
|
18
|
+
/**
|
|
19
|
+
* The name attribute for a hidden input field, if applicable.
|
|
20
|
+
*/
|
|
21
|
+
inputName?: string;
|
|
22
|
+
};
|
|
23
|
+
declare const CountryPickerModal: import('react').ForwardRefExoticComponent<import('./types').CommonProps & import('./types').ModalStateProps & CountryPickerModalProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
24
|
+
export default CountryPickerModal;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { jsx as o, jsxs as y } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as j, useState as S, useEffect as H, useRef as V, useMemo as f } from "react";
|
|
3
|
+
import N from "../../components/Button/Button.js";
|
|
4
|
+
import U from "../../components/Input/Input.js";
|
|
5
|
+
import G from "../../components/Modal/Modal.js";
|
|
6
|
+
import K from "../../components/Text/Text.js";
|
|
7
|
+
import { TextVariants as L } from "../../components/Text/types.js";
|
|
8
|
+
import { countries as v } from "./constants.js";
|
|
9
|
+
import { getSafeCountryCallingCode as O } from "./utils.js";
|
|
10
|
+
import { ButtonVariants as Z } from "../../components/Button/types.js";
|
|
11
|
+
import q from "../../components/Icon/Icon.js";
|
|
12
|
+
import { CountryPickerCountryList as A } from "./CountryPickerCountryList.js";
|
|
13
|
+
const w = ["US", "GB", "HK", "CH"], z = (n, l) => {
|
|
14
|
+
if (!l) return n;
|
|
15
|
+
const d = l.replace(/[.*?^${}()|[\]\\]/g, "\\$&").replace(/\+/g, "");
|
|
16
|
+
if (!d) return n;
|
|
17
|
+
const i = new RegExp(d, "gi");
|
|
18
|
+
return n.filter((u) => {
|
|
19
|
+
const h = u.name, t = u.code, p = O(t).replace(/\+/g, "");
|
|
20
|
+
return i.test(h) || i.test(t) || i.test(p) || i.test("+" + p);
|
|
21
|
+
});
|
|
22
|
+
}, J = j(
|
|
23
|
+
({
|
|
24
|
+
isOpen: n = !1,
|
|
25
|
+
onClose: l,
|
|
26
|
+
modalTitle: m,
|
|
27
|
+
searchInputLabel: d,
|
|
28
|
+
searchInputPlaceholder: i,
|
|
29
|
+
selectButtonLabel: u,
|
|
30
|
+
inputName: h = "value",
|
|
31
|
+
baseClassName: t,
|
|
32
|
+
variantConfig: _
|
|
33
|
+
}, p) => {
|
|
34
|
+
const { value: g, onChange: C, isPhone: E } = _, [c, I] = S(g), x = (e) => v.some((a) => a.code === e);
|
|
35
|
+
H(() => {
|
|
36
|
+
I(g);
|
|
37
|
+
}, [n, g]);
|
|
38
|
+
const [s, B] = S(""), D = V(null), F = V(null), [P, R] = f(() => {
|
|
39
|
+
const e = w.map((r) => v.filter(($) => $.code === r)).flat(), a = v.filter((r) => !w.includes(r.code));
|
|
40
|
+
return [
|
|
41
|
+
e,
|
|
42
|
+
// keep original order for prioritized
|
|
43
|
+
a.sort((r, $) => r.name.localeCompare($.name))
|
|
44
|
+
];
|
|
45
|
+
}, []), M = f(() => z(P, s), [P, s]), k = f(() => z(R, s), [R, s]), T = f(() => {
|
|
46
|
+
const e = {};
|
|
47
|
+
return k.forEach((a) => {
|
|
48
|
+
const r = a.name[0].toUpperCase();
|
|
49
|
+
e[r] || (e[r] = []), e[r].push(a);
|
|
50
|
+
}), e;
|
|
51
|
+
}, [k]);
|
|
52
|
+
return /* @__PURE__ */ o(
|
|
53
|
+
G,
|
|
54
|
+
{
|
|
55
|
+
isOpen: n,
|
|
56
|
+
onClose: l,
|
|
57
|
+
"data-testid": "country-picker-modal",
|
|
58
|
+
className: `${t}__modal`,
|
|
59
|
+
ref: p,
|
|
60
|
+
children: /* @__PURE__ */ y("div", { className: `${t}__wrapper`, children: [
|
|
61
|
+
/* @__PURE__ */ y("div", { className: `${t}__header`, children: [
|
|
62
|
+
/* @__PURE__ */ o(K, { variant: L.heading3, className: `${t}__header-text`, children: m }),
|
|
63
|
+
/* @__PURE__ */ y("div", { className: `${t}__input-wrapper`, children: [
|
|
64
|
+
/* @__PURE__ */ o("span", { className: `${t}__input-icon`, "aria-hidden": "true", children: /* @__PURE__ */ o(q, { icon: "Search", width: 16, height: 16, color: "currentColor" }) }),
|
|
65
|
+
/* @__PURE__ */ o(
|
|
66
|
+
U,
|
|
67
|
+
{
|
|
68
|
+
id: "countrySearch",
|
|
69
|
+
type: "search",
|
|
70
|
+
labelText: d,
|
|
71
|
+
placeholder: i,
|
|
72
|
+
value: s,
|
|
73
|
+
onChange: (e) => {
|
|
74
|
+
B(e.target.value);
|
|
75
|
+
},
|
|
76
|
+
autoFocus: !0,
|
|
77
|
+
className: `${t}__input`
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
] })
|
|
81
|
+
] }),
|
|
82
|
+
/* @__PURE__ */ o(
|
|
83
|
+
A,
|
|
84
|
+
{
|
|
85
|
+
filteredPrioritized: M,
|
|
86
|
+
groupedCountries: T,
|
|
87
|
+
baseClassName: t,
|
|
88
|
+
modalTitle: m,
|
|
89
|
+
listRef: F,
|
|
90
|
+
variantConfig: _,
|
|
91
|
+
inputName: h
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
/* @__PURE__ */ o("div", { className: `${t}__button-container`, children: /* @__PURE__ */ o(
|
|
95
|
+
N,
|
|
96
|
+
{
|
|
97
|
+
onClick: () => {
|
|
98
|
+
c && (E ? x(c) && C(c) : x(c) || C(c), l?.());
|
|
99
|
+
},
|
|
100
|
+
className: `${t}__button`,
|
|
101
|
+
"data-testid": "country-picker-modal-select-button",
|
|
102
|
+
ref: D,
|
|
103
|
+
type: "button",
|
|
104
|
+
variant: Z.secondary,
|
|
105
|
+
isDisabled: !c,
|
|
106
|
+
children: u
|
|
107
|
+
}
|
|
108
|
+
) })
|
|
109
|
+
] })
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
J.displayName = "CountryPickerModal";
|
|
115
|
+
export {
|
|
116
|
+
J as default
|
|
117
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Country, ModalBaseProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Props for a single country option in the picker.
|
|
4
|
+
* Extends Country and adds selection state and input name.
|
|
5
|
+
*/
|
|
6
|
+
export type CountryPickerOptionProps = Country & {
|
|
7
|
+
/**
|
|
8
|
+
* Indicates whether the option is currently selected.
|
|
9
|
+
*/
|
|
10
|
+
isChecked: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The name attribute for the input element.
|
|
13
|
+
*/
|
|
14
|
+
inputName: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Renders a single country option for selection.
|
|
18
|
+
* Handles both country and phone picker modes via discriminated union.
|
|
19
|
+
*/
|
|
20
|
+
export declare const CountryPickerOption: ({ code, name, isChecked, inputName, baseClassName, variantConfig, }: ModalBaseProps & CountryPickerOptionProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsxs as _, jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import $ from "../../components/Text/Text.js";
|
|
3
|
+
import { TextVariants as d } from "../../components/Text/types.js";
|
|
4
|
+
import e from "../../node_modules/classnames/index.js";
|
|
5
|
+
import { getSafeCountryCallingCode as g } from "./utils.js";
|
|
6
|
+
const v = ({
|
|
7
|
+
code: t,
|
|
8
|
+
name: n,
|
|
9
|
+
isChecked: r,
|
|
10
|
+
inputName: f,
|
|
11
|
+
baseClassName: o,
|
|
12
|
+
variantConfig: h
|
|
13
|
+
}) => {
|
|
14
|
+
const c = `${o}__radio-${t}`, { isPhone: i, onChange: l } = h;
|
|
15
|
+
return /* @__PURE__ */ _(
|
|
16
|
+
"label",
|
|
17
|
+
{
|
|
18
|
+
htmlFor: c,
|
|
19
|
+
className: e(`${o}__option`, {
|
|
20
|
+
[`${o}__option--selected`]: r,
|
|
21
|
+
[`${o}__option--is-phone`]: i
|
|
22
|
+
}),
|
|
23
|
+
"aria-label": i ? `${n} +${g(t)}` : n,
|
|
24
|
+
children: [
|
|
25
|
+
/* @__PURE__ */ p(
|
|
26
|
+
"input",
|
|
27
|
+
{
|
|
28
|
+
type: "radio",
|
|
29
|
+
id: c,
|
|
30
|
+
name: f,
|
|
31
|
+
checked: r,
|
|
32
|
+
className: e(`${o}__radio`, {
|
|
33
|
+
[`${o}__radio--selected`]: r,
|
|
34
|
+
[`${o}__radio--visually-hidden`]: i
|
|
35
|
+
}),
|
|
36
|
+
onChange: () => {
|
|
37
|
+
l(i ? t : n);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
),
|
|
41
|
+
/* @__PURE__ */ _("span", { className: `${o}__option-content`, children: [
|
|
42
|
+
/* @__PURE__ */ p($, { variant: d.string2, className: `${o}__option-name`, children: n }),
|
|
43
|
+
i && /* @__PURE__ */ _($, { variant: d.string2, className: `${o}__option-code`, children: [
|
|
44
|
+
"+",
|
|
45
|
+
g(t)
|
|
46
|
+
] })
|
|
47
|
+
] }),
|
|
48
|
+
/* @__PURE__ */ p(
|
|
49
|
+
"img",
|
|
50
|
+
{
|
|
51
|
+
src: `https://flagcdn.com/24x18/${t.toLowerCase()}.png`,
|
|
52
|
+
alt: `${n} flag`,
|
|
53
|
+
className: `${o}__option-flag`
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
export {
|
|
61
|
+
v as CountryPickerOption
|
|
62
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type CountryPickerTriggerProps = {
|
|
3
|
+
/**
|
|
4
|
+
* The label text displayed above the button.
|
|
5
|
+
*/
|
|
6
|
+
labelText: string;
|
|
7
|
+
/**
|
|
8
|
+
* The value displayed inside the button (e.g., selected country name or phone code).
|
|
9
|
+
*/
|
|
10
|
+
displayValue: string;
|
|
11
|
+
/**
|
|
12
|
+
* Optional flag to indicate if there is an error.
|
|
13
|
+
*/
|
|
14
|
+
hasError?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Optional error message to display when there is an error.
|
|
17
|
+
*/
|
|
18
|
+
errorMsg?: string;
|
|
19
|
+
};
|
|
20
|
+
declare const CountryPickerTrigger: React.ForwardRefExoticComponent<import('./types').CommonProps & import('./types').ModalStateProps & CountryPickerTriggerProps & Pick<React.ButtonHTMLAttributes<HTMLButtonElement>, "id" | "className" | "onClick"> & React.RefAttributes<HTMLButtonElement>>;
|
|
21
|
+
export default CountryPickerTrigger;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsxs as a, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import x from "../../components/Icon/Icon.js";
|
|
3
|
+
import { TextVariants as m } from "../../components/Text/types.js";
|
|
4
|
+
import p from "../../components/Text/Text.js";
|
|
5
|
+
import i from "../../node_modules/classnames/index.js";
|
|
6
|
+
import { countries as y } from "./constants.js";
|
|
7
|
+
import { forwardRef as k } from "react";
|
|
8
|
+
const w = k(
|
|
9
|
+
({ labelText: c, displayValue: f, onClick: $, hasError: e = !1, errorMsg: o, id: n, className: h, baseClassName: r, variantConfig: u }, v) => {
|
|
10
|
+
const { isPhone: l, value: g } = u, d = o ? `${r}__trigger-error-msg` : void 0, _ = l ? g : y.filter((s) => s.name === g)?.[0]?.code;
|
|
11
|
+
return /* @__PURE__ */ a("div", { className: i(`${r}__trigger`, h), children: [
|
|
12
|
+
/* @__PURE__ */ t(
|
|
13
|
+
p,
|
|
14
|
+
{
|
|
15
|
+
variant: m.string2,
|
|
16
|
+
className: i(`${r}__trigger-label`, {
|
|
17
|
+
[`${r}__trigger-label--error`]: e
|
|
18
|
+
}),
|
|
19
|
+
id: n ? `${n}-label` : void 0,
|
|
20
|
+
children: c
|
|
21
|
+
}
|
|
22
|
+
),
|
|
23
|
+
/* @__PURE__ */ a(
|
|
24
|
+
"button",
|
|
25
|
+
{
|
|
26
|
+
ref: v,
|
|
27
|
+
type: "button",
|
|
28
|
+
"aria-label": c,
|
|
29
|
+
"aria-invalid": e,
|
|
30
|
+
"aria-describedby": d,
|
|
31
|
+
className: i(`${r}__trigger-btn`, {
|
|
32
|
+
[`${r}__trigger-btn--error`]: e,
|
|
33
|
+
[`${r}__trigger-btn--is-phone`]: l
|
|
34
|
+
}),
|
|
35
|
+
onClick: $,
|
|
36
|
+
"data-testid": "country-picker-trigger",
|
|
37
|
+
id: n,
|
|
38
|
+
children: [
|
|
39
|
+
_ && /* @__PURE__ */ t(
|
|
40
|
+
"img",
|
|
41
|
+
{
|
|
42
|
+
src: `https://flagcdn.com/24x18/${_.toLowerCase()}.png`,
|
|
43
|
+
alt: `${g} flag`,
|
|
44
|
+
className: `${r}__trigger-flag`
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
/* @__PURE__ */ t("span", { className: i(`${r}__trigger-text`), children: f }),
|
|
48
|
+
/* @__PURE__ */ t("span", { className: i(`${r}__trigger-icon`), children: /* @__PURE__ */ t(x, { icon: "ChevronDown", color: "$pure-black", width: 16, height: 16 }) })
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
e && o && /* @__PURE__ */ t(
|
|
53
|
+
p,
|
|
54
|
+
{
|
|
55
|
+
variant: m.string2,
|
|
56
|
+
className: i(`${r}__trigger-error-msg`),
|
|
57
|
+
id: d,
|
|
58
|
+
children: o
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
] });
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
w.displayName = "CountryPickerTrigger";
|
|
65
|
+
export {
|
|
66
|
+
w as default
|
|
67
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|