@phillips/seldon 1.175.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.
Files changed (31) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +43 -41
  3. package/dist/patterns/CountryPicker/CountryPicker.d.ts +14 -0
  4. package/dist/patterns/CountryPicker/CountryPicker.js +71 -0
  5. package/dist/patterns/CountryPicker/CountryPicker.stories.d.ts +14 -0
  6. package/dist/patterns/CountryPicker/CountryPicker.test.d.ts +1 -0
  7. package/dist/patterns/CountryPicker/CountryPickerCountryList.d.ts +34 -0
  8. package/dist/patterns/CountryPicker/CountryPickerCountryList.js +66 -0
  9. package/dist/patterns/CountryPicker/CountryPickerCountryList.test.d.ts +1 -0
  10. package/dist/patterns/CountryPicker/CountryPickerModal.d.ts +24 -0
  11. package/dist/patterns/CountryPicker/CountryPickerModal.js +117 -0
  12. package/dist/patterns/CountryPicker/CountryPickerModal.test.d.ts +1 -0
  13. package/dist/patterns/CountryPicker/CountryPickerOption.d.ts +20 -0
  14. package/dist/patterns/CountryPicker/CountryPickerOption.js +62 -0
  15. package/dist/patterns/CountryPicker/CountryPickerOption.test.d.ts +1 -0
  16. package/dist/patterns/CountryPicker/CountryPickerTrigger.d.ts +21 -0
  17. package/dist/patterns/CountryPicker/CountryPickerTrigger.js +67 -0
  18. package/dist/patterns/CountryPicker/CountryPickerTrigger.test.d.ts +1 -0
  19. package/dist/patterns/CountryPicker/constants.d.ts +899 -0
  20. package/dist/patterns/CountryPicker/constants.js +279 -0
  21. package/dist/patterns/CountryPicker/index.d.ts +1 -0
  22. package/dist/patterns/CountryPicker/types.d.ts +30 -0
  23. package/dist/patterns/CountryPicker/types.js +6 -0
  24. package/dist/patterns/CountryPicker/utils.d.ts +2 -0
  25. package/dist/patterns/CountryPicker/utils.js +9 -0
  26. package/dist/patterns/CountryPicker/utils.test.d.ts +1 -0
  27. package/dist/scss/componentStyles.scss +3 -0
  28. package/dist/scss/patterns/CountryPicker/_countryPickerModal.scss +108 -0
  29. package/dist/scss/patterns/CountryPicker/_countryPickerOption.scss +71 -0
  30. package/dist/scss/patterns/CountryPicker/_countryPickerTrigger.scss +73 -0
  31. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -90,5 +90,6 @@ export * from './patterns/BidSnapshot';
90
90
  export * from './patterns/FilterMenu';
91
91
  export * from './patterns/ObjectTile';
92
92
  export * from './utils/hooks';
93
+ export * from './patterns/CountryPicker';
93
94
  export * from './components/DescriptiveRadioButton';
94
95
  export * from './components/DescriptiveRadioButtonGroup';
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { PaddingTokens as a, SpacingTokens as f, defaultYear as s, emailValidation as l, encodeURLSearchParams as d, findChildrenExcludingTypes as m, findChildrenOfType as p, focusElementById as u, generatePaddingClassName as i, getCommonProps as x, noOp as n, px as g, useNormalizedInputProps as c } from "./utils/index.js";
1
+ import { PaddingTokens as a, SpacingTokens as f, defaultYear as s, emailValidation as l, encodeURLSearchParams as d, findChildrenExcludingTypes as m, findChildrenOfType as p, focusElementById as u, generatePaddingClassName as i, getCommonProps as x, noOp as n, px as c, useNormalizedInputProps as g } from "./utils/index.js";
2
2
  import { default as C } from "./pages/Page.js";
3
- import { SSRMediaQuery as B, ssrMediaQueryStyle as P } from "./providers/SeldonProvider/utils.js";
3
+ import { SSRMediaQuery as P, ssrMediaQueryStyle as B } from "./providers/SeldonProvider/utils.js";
4
4
  import { usePendingState as A } from "./utils/hooks.js";
5
- import { AuctionStatus as V, LotStatus as b, SupportedLanguages as v } from "./types/commonTypes.js";
6
- import { default as h } from "./components/Button/Button.js";
5
+ import { AuctionStatus as V, LotStatus as b, SupportedLanguages as y } from "./types/commonTypes.js";
6
+ import { default as v } from "./components/Button/Button.js";
7
7
  import { ButtonVariants as w } from "./components/Button/types.js";
8
8
  import { default as F } from "./components/IconButton/IconButton.js";
9
9
  import { default as M } from "./components/Accordion/Accordion.js";
@@ -25,14 +25,14 @@ import { default as de } from "./components/ContentPeek/ContentPeek.js";
25
25
  import { HeightUnits as pe } from "./components/ContentPeek/utils.js";
26
26
  import { default as ie } from "./components/Detail/Detail.js";
27
27
  import { default as ne } from "./components/Drawer/Drawer.js";
28
- import { default as ce } from "./components/Dropdown/Dropdown.js";
28
+ import { default as ge } from "./components/Dropdown/Dropdown.js";
29
29
  import { default as Ce } from "./components/ErrorBoundary/ErrorBoundary.js";
30
- import { default as Be } from "./components/Grid/Grid.js";
30
+ import { default as Pe } from "./components/Grid/Grid.js";
31
31
  import { default as Ie } from "./components/GridItem/GridItem.js";
32
32
  import { GridItemAlign as Le } from "./components/GridItem/types.js";
33
33
  import { default as be } from "./components/Input/Input.js";
34
- import { default as ye } from "./components/Link/Link.js";
35
- import { LinkVariants as ke } from "./components/Link/types.js";
34
+ import { default as ke } from "./components/Link/Link.js";
35
+ import { LinkVariants as he } from "./components/Link/types.js";
36
36
  import { default as De } from "./components/LinkBlock/LinkBlock.js";
37
37
  import { default as He } from "./components/LinkList/LinkList.js";
38
38
  import { default as Ne } from "./components/Modal/Modal.js";
@@ -51,14 +51,14 @@ import { default as st } from "./components/SplitPanel/SplitPanel.js";
51
51
  import { default as dt } from "./components/Tabs/TabsContainer.js";
52
52
  import { default as pt } from "./components/Tabs/TabsContent.js";
53
53
  import { Tag as it, default as xt } from "./components/Tags/Tags.js";
54
- import { TextAlignments as gt, TextVariants as ct } from "./components/Text/types.js";
54
+ import { TextAlignments as ct, TextVariants as gt } from "./components/Text/types.js";
55
55
  import { default as Ct } from "./components/Text/Text.js";
56
- import { TextSymbolVariants as Bt } from "./components/TextSymbol/types.js";
56
+ import { TextSymbolVariants as Pt } from "./components/TextSymbol/types.js";
57
57
  import { default as It } from "./components/TextSymbol/TextSymbol.js";
58
58
  import { default as Lt } from "./components/Video/Video.js";
59
59
  import { default as bt } from "./patterns/DetailList/DetailList.js";
60
- import { DetailListAlignment as yt } from "./patterns/DetailList/types.js";
61
- import { default as kt } from "./patterns/FavoritesCollectionTile/FavoritesCollectionTile.js";
60
+ import { DetailListAlignment as kt } from "./patterns/DetailList/types.js";
61
+ import { default as ht } from "./patterns/FavoritesCollectionTile/FavoritesCollectionTile.js";
62
62
  import { default as Dt } from "./patterns/HeroBanner/HeroBanner.js";
63
63
  import { default as Ht } from "./patterns/LanguageSelector/LanguageSelector.js";
64
64
  import { default as Nt } from "./patterns/SaleHeaderBanner/SaleHeaderBanner.js";
@@ -77,14 +77,14 @@ import { default as so } from "./components/ExitGateCard/ExitGateCard.js";
77
77
  import { default as mo } from "./components/Loader/Loader.js";
78
78
  import { default as uo } from "./components/PageContentWrapper/PageContentWrapper.js";
79
79
  import { default as xo } from "./components/PhoneNumberPicker/PhoneNumberPicker.js";
80
- import { default as go } from "./patterns/FiltersInline/FiltersInline.js";
80
+ import { default as co } from "./patterns/FiltersInline/FiltersInline.js";
81
81
  import { FilterButtonIconType as So, FilterButtonType as Co } from "./patterns/FiltersInline/types.js";
82
- import { default as Bo } from "./patterns/SaleCard/SaleCard.js";
82
+ import { default as Po } from "./patterns/SaleCard/SaleCard.js";
83
83
  import { SaleCardActions as Io } from "./patterns/SaleCard/SaleCardActions.js";
84
84
  import { SaleCardVariants as Lo } from "./patterns/SaleCard/types.js";
85
85
  import { default as bo } from "./patterns/ViewingDetails/ViewingDetails.js";
86
- import { default as yo } from "./components/ProgressIndicator/ProgressIndicator.js";
87
- import { default as ko } from "./site-furniture/Footer/Footer.js";
86
+ import { default as ko } from "./components/ProgressIndicator/ProgressIndicator.js";
87
+ import { default as ho } from "./site-furniture/Footer/Footer.js";
88
88
  import { default as Do } from "./site-furniture/Header/Header.js";
89
89
  import { default as Ho } from "./components/AddToCalendar/AddToCalendar.js";
90
90
  import { default as No } from "./components/Article/Article.js";
@@ -103,11 +103,12 @@ import { useToast as sr } from "./components/Toast/useToast.js";
103
103
  import { default as dr } from "./patterns/AccountPageHeader/AccountPageHeader.js";
104
104
  import { default as pr } from "./patterns/BidSnapshot/BidSnapshot.js";
105
105
  import { default as ir } from "./patterns/BidSnapshot/BidMessage.js";
106
- import { BidMessageVariants as nr, BidStatusEnum as gr } from "./patterns/BidSnapshot/types.js";
106
+ import { BidMessageVariants as nr, BidStatusEnum as cr } from "./patterns/BidSnapshot/types.js";
107
107
  import { default as Sr } from "./patterns/FilterMenu/FilterMenu.js";
108
108
  import { default as Tr } from "./patterns/ObjectTile/ObjectTile.js";
109
- import { default as Pr } from "./components/DescriptiveRadioButton/DescriptiveRadioButton.js";
110
- import { default as Ar } from "./components/DescriptiveRadioButtonGroup/DescriptiveRadioButtonGroup.js";
109
+ import { default as Br } from "./patterns/CountryPicker/CountryPicker.js";
110
+ import { default as Ar } from "./components/DescriptiveRadioButton/DescriptiveRadioButton.js";
111
+ import { default as Vr } from "./components/DescriptiveRadioButtonGroup/DescriptiveRadioButtonGroup.js";
111
112
  export {
112
113
  M as Accordion,
113
114
  E as AccordionItem,
@@ -121,9 +122,9 @@ export {
121
122
  ir as BidMessage,
122
123
  nr as BidMessageVariants,
123
124
  pr as BidSnapshot,
124
- gr as BidStatusEnum,
125
+ cr as BidStatusEnum,
125
126
  Q as Breadcrumb,
126
- h as Button,
127
+ v as Button,
127
128
  w as ButtonVariants,
128
129
  Y as Carousel,
129
130
  q as CarouselArrows,
@@ -139,17 +140,18 @@ export {
139
140
  pe as ContentPeekHeightUnits,
140
141
  Go as Countdown,
141
142
  Uo as CountdownVariants,
142
- Pr as DescriptiveRadioButton,
143
- Ar as DescriptiveRadioButtonGroup,
143
+ Br as CountryPicker,
144
+ Ar as DescriptiveRadioButton,
145
+ Vr as DescriptiveRadioButtonGroup,
144
146
  ie as Detail,
145
147
  bt as DetailList,
146
- yt as DetailListAlignment,
148
+ kt as DetailListAlignment,
147
149
  Qo as Divider,
148
150
  ne as Drawer,
149
- ce as Dropdown,
151
+ ge as Dropdown,
150
152
  Ce as ErrorBoundary,
151
153
  so as ExitGateCard,
152
- kt as FavoritesCollectionTile,
154
+ ht as FavoritesCollectionTile,
153
155
  zo as FavoritingTileButton,
154
156
  Yo as Filter,
155
157
  So as FilterButtonIconType,
@@ -157,9 +159,9 @@ export {
157
159
  Ko as FilterHeader,
158
160
  qo as FilterInput,
159
161
  Sr as FilterMenu,
160
- go as FiltersInline,
161
- ko as Footer,
162
- Be as Grid,
162
+ co as FiltersInline,
163
+ ho as Footer,
164
+ Pe as Grid,
163
165
  Ie as GridItem,
164
166
  Le as GridItemAlign,
165
167
  Do as Header,
@@ -168,10 +170,10 @@ export {
168
170
  F as IconButton,
169
171
  be as Input,
170
172
  Ht as LanguageSelector,
171
- ye as Link,
173
+ ke as Link,
172
174
  De as LinkBlock,
173
175
  He as LinkList,
174
- ke as LinkVariants,
176
+ he as LinkVariants,
175
177
  mo as Loader,
176
178
  b as LotStatus,
177
179
  Ne as Modal,
@@ -187,10 +189,10 @@ export {
187
189
  xo as PhoneNumberPicker,
188
190
  _o as Pictogram,
189
191
  qe as PinchZoom,
190
- yo as ProgressIndicator,
192
+ ko as ProgressIndicator,
191
193
  Ke as Row,
192
- B as SSRMediaQuery,
193
- Bo as SaleCard,
194
+ P as SSRMediaQuery,
195
+ Po as SaleCard,
194
196
  Io as SaleCardActions,
195
197
  Lo as SaleCardVariants,
196
198
  Nt as SaleHeaderBanner,
@@ -206,17 +208,17 @@ export {
206
208
  Kt as StatefulViewingsList,
207
209
  Qt as Subscribe,
208
210
  zt as SubscriptionState,
209
- v as SupportedLanguages,
211
+ y as SupportedLanguages,
210
212
  dt as TabsContainer,
211
213
  pt as TabsContent,
212
214
  it as Tag,
213
215
  xt as TagsList,
214
216
  Ct as Text,
215
- gt as TextAlignments,
217
+ ct as TextAlignments,
216
218
  er as TextArea,
217
- Bt as TextSymbolVariants,
219
+ Pt as TextSymbolVariants,
218
220
  It as TextSymbols,
219
- ct as TextVariants,
221
+ gt as TextVariants,
220
222
  or as Toast,
221
223
  ar as ToastProvider,
222
224
  qt as UserManagement,
@@ -232,9 +234,9 @@ export {
232
234
  i as generatePaddingClassName,
233
235
  x as getCommonProps,
234
236
  n as noOp,
235
- g as px,
236
- P as ssrMediaQueryStyle,
237
- c as useNormalizedInputProps,
237
+ c as px,
238
+ B as ssrMediaQueryStyle,
239
+ g as useNormalizedInputProps,
238
240
  A as usePendingState,
239
241
  sr as useToast
240
242
  };
@@ -0,0 +1,14 @@
1
+ import { CountryPickerTriggerProps } from './CountryPickerTrigger';
2
+ import { CountryPickerModalProps } from './CountryPickerModal';
3
+ import { CommonProps, PrependTrigger, PhoneConfig, CountryConfig } from './types';
4
+ /**
5
+ * Props for the CountryPicker component.
6
+ * Combines:
7
+ * - CommonProps (excluding variantConfig, which is provided by PhoneConfig or CountryConfig)
8
+ * - Discriminated union for picker mode (PhoneConfig | CountryConfig)
9
+ * - Modal props
10
+ * - PrependTrigger utility for trigger props
11
+ */
12
+ export type CountryPickerProps = Omit<CommonProps, 'variantConfig'> & (PhoneConfig | CountryConfig) & CountryPickerModalProps & PrependTrigger<Omit<CountryPickerTriggerProps, 'baseClassName'>>;
13
+ declare const CountryPicker: import('react').ForwardRefExoticComponent<CountryPickerProps & import('react').RefAttributes<HTMLButtonElement>>;
14
+ export default CountryPicker;
@@ -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,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,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,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,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;