@alfalab/core-components-international-phone-input 2.0.4 → 2.0.6

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 (51) hide show
  1. package/{Component-70284312.d.ts → Component-57569e57.d.ts} +1 -1
  2. package/Component.responsive.d.ts +4 -4
  3. package/components/base-international-phone-input/Component.d.ts +1 -1
  4. package/components/base-international-phone-input/Component.js +34 -6
  5. package/components/base-international-phone-input/index.css +2 -2
  6. package/components/country-select/Component.js +1 -1
  7. package/components/country-select/index.css +8 -8
  8. package/components/flag-icon/component.js +1 -1
  9. package/components/flag-icon/index.css +3 -3
  10. package/components/select-field/component.js +1 -1
  11. package/components/select-field/index.css +9 -9
  12. package/cssm/{Component-70284312.d.ts → Component-57569e57.d.ts} +1 -1
  13. package/cssm/Component.responsive.d.ts +4 -4
  14. package/cssm/components/base-international-phone-input/Component.d.ts +1 -1
  15. package/cssm/components/base-international-phone-input/Component.js +33 -5
  16. package/cssm/types.d.ts +1 -1
  17. package/{esm/typings-70284312.d.ts → cssm/typings-57569e57.d.ts} +5 -1
  18. package/cssm/utils-89376c31.d.ts +1 -1
  19. package/{modern/Component-70284312.d.ts → esm/Component-57569e57.d.ts} +1 -1
  20. package/esm/Component.responsive.d.ts +4 -4
  21. package/esm/components/base-international-phone-input/Component.d.ts +1 -1
  22. package/esm/components/base-international-phone-input/Component.js +34 -6
  23. package/esm/components/base-international-phone-input/index.css +2 -2
  24. package/esm/components/country-select/Component.js +1 -1
  25. package/esm/components/country-select/index.css +8 -8
  26. package/esm/components/flag-icon/component.js +1 -1
  27. package/esm/components/flag-icon/index.css +3 -3
  28. package/esm/components/select-field/component.js +1 -1
  29. package/esm/components/select-field/index.css +9 -9
  30. package/esm/types.d.ts +1 -1
  31. package/{modern/typings-70284312.d.ts → esm/typings-57569e57.d.ts} +5 -1
  32. package/esm/utils-89376c31.d.ts +1 -1
  33. package/{esm/Component-70284312.d.ts → modern/Component-57569e57.d.ts} +1 -1
  34. package/modern/Component.responsive.d.ts +4 -4
  35. package/modern/components/base-international-phone-input/Component.d.ts +1 -1
  36. package/modern/components/base-international-phone-input/Component.js +30 -4
  37. package/modern/components/base-international-phone-input/index.css +2 -2
  38. package/modern/components/country-select/Component.js +1 -1
  39. package/modern/components/country-select/index.css +8 -8
  40. package/modern/components/flag-icon/component.js +1 -1
  41. package/modern/components/flag-icon/index.css +3 -3
  42. package/modern/components/select-field/component.js +1 -1
  43. package/modern/components/select-field/index.css +9 -9
  44. package/modern/types.d.ts +1 -1
  45. package/{cssm/typings-70284312.d.ts → modern/typings-57569e57.d.ts} +5 -1
  46. package/modern/utils-89376c31.d.ts +1 -1
  47. package/package.json +4 -4
  48. package/src/components/base-international-phone-input/Component.tsx +38 -0
  49. package/types.d.ts +1 -1
  50. package/{typings-70284312.d.ts → typings-57569e57.d.ts} +5 -1
  51. package/utils-89376c31.d.ts +1 -1
@@ -1,4 +1,4 @@
1
- /* hash: 1tm53 */
1
+ /* hash: sz3rw */
2
2
  :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
3
3
  } /* deprecated */ :root {
4
4
  --color-light-neutral-translucent-700: rgba(4, 4, 21, 0.47);
@@ -18,29 +18,29 @@
18
18
  --gap-s: 12px;
19
19
  } :root {
20
20
  } :root {
21
- } .international-phone-input__component_1r6tp {
21
+ } .international-phone-input__component_61i1r {
22
22
  position: static;
23
23
  display: flex;
24
24
  min-width: initial;
25
25
  height: 100%;
26
- } .international-phone-input__option_1r6tp {
26
+ } .international-phone-input__option_61i1r {
27
27
  display: flex;
28
28
  align-items: flex-start;
29
29
  padding: var(--gap-s);
30
- } .international-phone-input__flag_1r6tp {
30
+ } .international-phone-input__flag_61i1r {
31
31
  flex-shrink: 0;
32
32
  margin-right: var(--gap-xs);
33
- } .international-phone-input__countryName_1r6tp {
33
+ } .international-phone-input__countryName_61i1r {
34
34
  margin-right: var(--gap-xs);
35
- } .international-phone-input__dialCode_1r6tp {
35
+ } .international-phone-input__dialCode_61i1r {
36
36
  color: var(--color-light-text-secondary);
37
- } .international-phone-input__flagIconWrapper_1r6tp {
37
+ } .international-phone-input__flagIconWrapper_61i1r {
38
38
  display: flex;
39
39
  justify-content: center;
40
40
  align-items: center;
41
41
  width: 24px;
42
42
  height: 24px;
43
43
  margin-left: var(--gap-s);
44
- } .international-phone-input__emptyCountryIcon_1r6tp {
44
+ } .international-phone-input__emptyCountryIcon_61i1r {
45
45
  color: var(--color-light-neutral-translucent-700);
46
46
  }
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import cn from 'classnames';
3
3
  import { flagSprite } from './flagSprite.js';
4
4
 
5
- var styles = {"flagIcon":"international-phone-input__flagIcon_dxseh","flagPlaceholder":"international-phone-input__flagPlaceholder_dxseh"};
5
+ var styles = {"flagIcon":"international-phone-input__flagIcon_mn1nz","flagPlaceholder":"international-phone-input__flagPlaceholder_mn1nz"};
6
6
  require('./index.css')
7
7
 
8
8
  /**
@@ -1,4 +1,4 @@
1
- /* hash: 17zwu */
1
+ /* hash: 9lu45 */
2
2
  :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
3
3
  } /* deprecated */ :root {
4
4
  --color-light-neutral-translucent-100: rgba(38, 55, 88, 0.06); /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
@@ -17,10 +17,10 @@
17
17
  --gap-3xs: 2px;
18
18
  } :root {
19
19
  } :root {
20
- } .international-phone-input__flagIcon_dxseh {
20
+ } .international-phone-input__flagIcon_mn1nz {
21
21
  max-width: 24px;
22
22
  max-height: 24px;
23
- } .international-phone-input__flagPlaceholder_dxseh {
23
+ } .international-phone-input__flagPlaceholder_mn1nz {
24
24
  width: 24px;
25
25
  height: 16px;
26
26
  max-height: 16px;
@@ -6,7 +6,7 @@ import { useFocus } from '@alfalab/hooks';
6
6
  import { WorldMagnifierMIcon } from '@alfalab/icons-glyph/WorldMagnifierMIcon';
7
7
  import { FlagIcon } from '../flag-icon/component.js';
8
8
 
9
- var styles = {"component":"international-phone-input__component_1tk3e","flagIconContainer":"international-phone-input__flagIconContainer_1tk3e","emptyCountryIcon":"international-phone-input__emptyCountryIcon_1tk3e","disabled":"international-phone-input__disabled_1tk3e","inner":"international-phone-input__inner_1tk3e","size-64":"international-phone-input__size-64_1tk3e","size-72":"international-phone-input__size-72_1tk3e","focusVisible":"international-phone-input__focusVisible_1tk3e"};
9
+ var styles = {"component":"international-phone-input__component_y5c1x","flagIconContainer":"international-phone-input__flagIconContainer_y5c1x","emptyCountryIcon":"international-phone-input__emptyCountryIcon_y5c1x","disabled":"international-phone-input__disabled_y5c1x","inner":"international-phone-input__inner_y5c1x","size-64":"international-phone-input__size-64_y5c1x","size-72":"international-phone-input__size-72_y5c1x","focusVisible":"international-phone-input__focusVisible_y5c1x"};
10
10
  require('./index.css')
11
11
 
12
12
  var EMPTY_COUNTRY_SELECT_FIELD = {
@@ -1,4 +1,4 @@
1
- /* hash: 3r6mf */
1
+ /* hash: a6qqq */
2
2
  :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
3
3
  } /* deprecated */ :root {
4
4
  --color-light-border-link: #2288fa;
@@ -21,33 +21,33 @@
21
21
  } :root {
22
22
  --focus-color: var(--color-light-border-link);
23
23
  --disabled-cursor: not-allowed;
24
- } .international-phone-input__component_1tk3e {
24
+ } .international-phone-input__component_y5c1x {
25
25
  height: 100%;
26
26
  cursor: pointer;
27
27
  outline: none;
28
28
  position: relative;
29
- } .international-phone-input__flagIconContainer_1tk3e {
29
+ } .international-phone-input__flagIconContainer_y5c1x {
30
30
  display: flex;
31
31
  justify-content: center;
32
32
  align-items: center;
33
33
  width: 24px;
34
34
  height: 24px;
35
35
  margin-right: var(--gap-2xs);
36
- } .international-phone-input__emptyCountryIcon_1tk3e {
36
+ } .international-phone-input__emptyCountryIcon_y5c1x {
37
37
  color: var(--color-light-neutral-translucent-700);
38
- } .international-phone-input__disabled_1tk3e {
38
+ } .international-phone-input__disabled_y5c1x {
39
39
  cursor: var(--disabled-cursor);
40
- } .international-phone-input__inner_1tk3e {
40
+ } .international-phone-input__inner_y5c1x {
41
41
  position: relative;
42
42
  display: flex;
43
43
  align-items: center;
44
44
  height: 100%;
45
45
  padding-left: var(--gap-s);
46
46
  outline: none;
47
- } .international-phone-input__size-64_1tk3e .international-phone-input__inner_1tk3e,
48
- .international-phone-input__size-72_1tk3e .international-phone-input__inner_1tk3e {
47
+ } .international-phone-input__size-64_y5c1x .international-phone-input__inner_y5c1x,
48
+ .international-phone-input__size-72_y5c1x .international-phone-input__inner_y5c1x {
49
49
  padding-left: var(--gap-m);
50
- } .international-phone-input__focusVisible_1tk3e {
50
+ } .international-phone-input__focusVisible_y5c1x {
51
51
  outline: 2px solid var(--focus-color);
52
52
  outline-offset: 2px;
53
53
  }
package/esm/types.d.ts CHANGED
@@ -5,7 +5,7 @@ import { InputMobileProps } from "@alfalab/core-components-input/mobile";
5
5
  import { InputAutocompleteProps } from "@alfalab/core-components-input-autocomplete";
6
6
  import { InputAutocompleteDesktopProps } from "@alfalab/core-components-input-autocomplete/desktop";
7
7
  import { InputAutocompleteMobileProps } from "@alfalab/core-components-input-autocomplete/mobile";
8
- import { OptionShape } from "./typings-70284312";
8
+ import { OptionShape } from "./typings-57569e57";
9
9
  import { SharedCountrySelectProps } from "./components/country-select/index";
10
10
  type Country = {
11
11
  name: string;
@@ -998,7 +998,7 @@ type BaseSelectProps = {
998
998
  /**
999
999
  * Дополнительный класс для поповера
1000
1000
  */
1001
- popperClassName?: string;
1001
+ popperClassName?: PopoverProps['className'];
1002
1002
  /**
1003
1003
  * Список вариантов выбора
1004
1004
  */
@@ -1195,6 +1195,10 @@ type BaseSelectProps = {
1195
1195
  * Показывать OptionsList, если он пустой
1196
1196
  */
1197
1197
  showEmptyOptionsList?: boolean;
1198
+ /**
1199
+ * Дополнительные пропсы для Popover
1200
+ */
1201
+ popoverProps?: Omit<PopoverProps, 'update' | 'zIndex' | 'position' | 'className' | 'open' | 'anchorElement' | 'preventFlip' | 'dataTestId'>;
1198
1202
  };
1199
1203
  type FieldProps = {
1200
1204
  /**
@@ -1,5 +1,5 @@
1
1
  import { ReactNode, RefObject } from 'react';
2
- import { BaseSelectProps, GroupShape, OptionShape } from "./typings-70284312";
2
+ import { BaseSelectProps, GroupShape, OptionShape } from "./typings-57569e57";
3
3
  declare const isGroup: (item: OptionShape | GroupShape) => item is GroupShape;
4
4
  declare const isOptionShape: (item: OptionShape | string | null) => item is OptionShape;
5
5
  declare const joinOptions: ({ selected, selectedMultiple, }: {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import React from 'react';
3
- import { OptgroupProps } from "./typings-70284312";
3
+ import { OptgroupProps } from "./typings-57569e57";
4
4
  declare const Optgroup: ({ children, className, label, size }: OptgroupProps) => React.JSX.Element;
5
5
  export { Optgroup };
@@ -7,7 +7,7 @@ declare const InternationalPhoneInput: React.ForwardRefExoticComponent<(({
7
7
  clearableCountryCode?: boolean | undefined;
8
8
  countrySelectProps?: import("./components/country-select/index").SharedCountrySelectProps | undefined;
9
9
  clear?: boolean | undefined;
10
- filterFn?: ((value: string | undefined, option: import("./typings-70284312").OptionShape) => boolean) | undefined;
10
+ filterFn?: ((value: string | undefined, option: import("./typings-57569e57").OptionShape) => boolean) | undefined;
11
11
  onCountryChange?: ((country?: import("./types").Country | undefined) => void) | undefined;
12
12
  onChange?: ((phone: string) => void) | undefined;
13
13
  onBlur?: ((event: React.FocusEvent<HTMLDivElement | HTMLInputElement, Element>) => void) | undefined;
@@ -26,15 +26,15 @@ declare const InternationalPhoneInput: React.ForwardRefExoticComponent<(({
26
26
  clearableCountryCode?: boolean | undefined;
27
27
  countrySelectProps?: import("./components/country-select/index").SharedCountrySelectProps | undefined;
28
28
  clear?: boolean | undefined;
29
- filterFn?: ((value: string | undefined, option: import("./typings-70284312").OptionShape) => boolean) | undefined;
29
+ filterFn?: ((value: string | undefined, option: import("./typings-57569e57").OptionShape) => boolean) | undefined;
30
30
  onCountryChange?: ((country?: import("./types").Country | undefined) => void) | undefined;
31
31
  onChange?: ((phone: string) => void) | undefined;
32
32
  onBlur?: ((event: React.FocusEvent<HTMLDivElement | HTMLInputElement, Element>) => void) | undefined;
33
33
  onFocus?: ((event: React.FocusEvent<HTMLDivElement | HTMLInputElement, Element>) => void) | undefined;
34
34
  } & {
35
- options: (import("./typings-70284312").OptionShape | import("./typings-70284312").GroupShape)[];
35
+ options: (import("./typings-57569e57").OptionShape | import("./typings-57569e57").GroupShape)[];
36
36
  } & Omit<import("@alfalab/core-components-input-autocomplete/types").InputAutocompleteCommonProps, "onChange" | "onInput"> & {
37
- options: (import("./typings-70284312").OptionShape | import("./typings-70284312").GroupShape)[];
37
+ options: (import("./typings-57569e57").OptionShape | import("./typings-57569e57").GroupShape)[];
38
38
  } & Omit<import("@alfalab/core-components-input-autocomplete/types").InputAutocompleteMobileProps, "onChange" | "onInput"> & {
39
39
  breakpoint?: number | undefined;
40
40
  defaultMatchMediaValue?: boolean | (() => boolean) | undefined;
@@ -9,7 +9,7 @@ declare const BaseInternationalPhoneInput: React.ForwardRefExoticComponent<{
9
9
  clearableCountryCode?: boolean | undefined;
10
10
  countrySelectProps?: import("../country-select/index").SharedCountrySelectProps | undefined;
11
11
  clear?: boolean | undefined;
12
- filterFn?: ((value: string | undefined, option: import("../../typings-70284312").OptionShape) => boolean) | undefined;
12
+ filterFn?: ((value: string | undefined, option: import("../../typings-57569e57").OptionShape) => boolean) | undefined;
13
13
  onCountryChange?: ((country?: Country | undefined) => void) | undefined;
14
14
  onChange?: ((phone: string) => void) | undefined;
15
15
  onBlur?: ((event: React.FocusEvent<HTMLDivElement | HTMLInputElement, Element>) => void) | undefined;
@@ -6,13 +6,15 @@ import { BaseOption } from '@alfalab/core-components-select/modern/shared';
6
6
  import { initCountries, findCountry, filterPhones, createMaskOptions, getClear, getPhoneData } from '../../utils/index.js';
7
7
  import { CountrySelect } from '../country-select/Component.js';
8
8
 
9
- const styles = {"component":"international-phone-input__component_1druh","addons":"international-phone-input__addons_1druh"};
9
+ const styles = {"component":"international-phone-input__component_eq2nn","addons":"international-phone-input__addons_eq2nn"};
10
10
  require('./index.css')
11
11
 
12
- const BaseInternationalPhoneInput = forwardRef(({ clearableCountryCode, value, country: countryProp, filterFn, onChange, onCountryChange, countrySelectProps, countries, defaultIso2, disabled, options, size = 56, Input, InputAutocomplete, SelectComponent, view, clear: clearProp, ...restProps }, ref) => {
12
+ const BaseInternationalPhoneInput = forwardRef(({ clearableCountryCode, value, country: countryProp, filterFn, onChange, onCountryChange, countrySelectProps, countries, defaultIso2, disabled, options, size = 56, Input, InputAutocomplete, SelectComponent, view, clear: clearProp, open: openProps, defaultOpen, ...restProps }, ref) => {
13
13
  const countriesData = useMemo(() => initCountries(countries), [countries]);
14
14
  const inputRef = useRef(null);
15
15
  const inputWrapperRef = useRef(null);
16
+ const [open, setOpen] = useState(defaultOpen);
17
+ const [openCountry, setOpenCountry] = useState(countrySelectProps?.defaultOpen);
16
18
  const [selectedCountry, setSelectedCountry] = useState(() => findCountry(countriesData, value, defaultIso2, countryProp));
17
19
  const filteredOptions = filterPhones(value, options, filterFn);
18
20
  const country = countryProp ?? selectedCountry;
@@ -67,7 +69,31 @@ const BaseInternationalPhoneInput = forwardRef(({ clearableCountryCode, value, c
67
69
  }
68
70
  // eslint-disable-next-line react-hooks/exhaustive-deps
69
71
  }, [value, maskOptions]);
70
- const renderCountrySelect = (compact = false) => (React.createElement(CountrySelect, { dataTestId: restProps?.dataTestId, ...countrySelectProps, view: view, SelectComponent: SelectComponent, disabled: disabled || countrySelectProps?.disabled, onChange: handleSelectCountry, country: country, countries: compact ? [] : countriesData, fieldWidth: inputWrapperRef.current?.getBoundingClientRect().width }));
72
+ const openPhoneSelect = (payload) => {
73
+ if (openProps === undefined)
74
+ setOpen(payload.open);
75
+ restProps.onOpen?.(payload);
76
+ };
77
+ const openCountrySelect = (payload) => {
78
+ if (countrySelectProps?.open === undefined)
79
+ setOpenCountry(payload.open);
80
+ countrySelectProps?.onOpen?.(payload);
81
+ };
82
+ const handlePhoneSelectOpen = (payload) => {
83
+ if (payload.open) {
84
+ openCountrySelect({ open: false });
85
+ }
86
+ openPhoneSelect(payload);
87
+ };
88
+ const handleCountrySelectOpen = (payload) => {
89
+ if (payload.open) {
90
+ openPhoneSelect({ open: false });
91
+ }
92
+ openCountrySelect(payload);
93
+ };
94
+ const showPhoneSelect = Boolean(open || openProps);
95
+ const showCountrySelect = Boolean(openCountry || countrySelectProps?.open);
96
+ const renderCountrySelect = (compact = false) => (React.createElement(CountrySelect, { dataTestId: restProps?.dataTestId, ...countrySelectProps, view: view, SelectComponent: SelectComponent, disabled: disabled || countrySelectProps?.disabled, onChange: handleSelectCountry, country: country, countries: compact ? [] : countriesData, fieldWidth: inputWrapperRef.current?.getBoundingClientRect().width, onOpen: handleCountrySelectOpen, open: showCountrySelect }));
71
97
  const inputProps = {
72
98
  className: styles.component,
73
99
  ref: mergeRefs([maskRef, ref, inputRef]),
@@ -77,7 +103,7 @@ const BaseInternationalPhoneInput = forwardRef(({ clearableCountryCode, value, c
77
103
  clear: getClear(clearProp, clearableCountryCode, value, country?.countryCode),
78
104
  ...restProps.inputProps,
79
105
  };
80
- return Array.isArray(options) ? (React.createElement(InputAutocomplete, { closeOnSelect: true, Option: BaseOption, size: size, ...restProps, disabled: disabled, options: filteredOptions, value: value, onChange: handleOptionSelect, onInput: (phone) => updatePhoneData(phone), inputProps: {
106
+ return Array.isArray(options) ? (React.createElement(InputAutocomplete, { closeOnSelect: true, Option: BaseOption, size: size, ...restProps, disabled: disabled, options: filteredOptions, value: value, open: showPhoneSelect, onOpen: handlePhoneSelectOpen, onChange: handleOptionSelect, onInput: (phone) => updatePhoneData(phone), inputProps: {
81
107
  ...inputProps,
82
108
  onClear: handleClear,
83
109
  onInput: handleInput,
@@ -1,5 +1,5 @@
1
- /* hash: 5t2j9 */
1
+ /* hash: 1yemg */
2
2
 
3
- .international-phone-input__component_1druh .international-phone-input__addons_1druh {
3
+ .international-phone-input__component_eq2nn .international-phone-input__addons_eq2nn {
4
4
  padding-left: 0;
5
5
  }
@@ -5,7 +5,7 @@ import { WorldMagnifierMIcon } from '@alfalab/icons-glyph/WorldMagnifierMIcon';
5
5
  import { FlagIcon } from '../flag-icon/component.js';
6
6
  import { EMPTY_COUNTRY_SELECT_FIELD, SelectField } from '../select-field/component.js';
7
7
 
8
- const styles = {"component":"international-phone-input__component_1r6tp","option":"international-phone-input__option_1r6tp","flag":"international-phone-input__flag_1r6tp","countryName":"international-phone-input__countryName_1r6tp","dialCode":"international-phone-input__dialCode_1r6tp","flagIconWrapper":"international-phone-input__flagIconWrapper_1r6tp","emptyCountryIcon":"international-phone-input__emptyCountryIcon_1r6tp"};
8
+ const styles = {"component":"international-phone-input__component_61i1r","option":"international-phone-input__option_61i1r","flag":"international-phone-input__flag_61i1r","countryName":"international-phone-input__countryName_61i1r","dialCode":"international-phone-input__dialCode_61i1r","flagIconWrapper":"international-phone-input__flagIconWrapper_61i1r","emptyCountryIcon":"international-phone-input__emptyCountryIcon_61i1r"};
9
9
  require('./index.css')
10
10
 
11
11
  const CountrySelect = ({ hideCountrySelect, countries, country, dataTestId, fieldWidth, onChange, view = 'desktop', SelectComponent, ...restProps }) => {
@@ -1,4 +1,4 @@
1
- /* hash: 1tm53 */
1
+ /* hash: sz3rw */
2
2
  :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
3
3
  } /* deprecated */ :root {
4
4
  --color-light-neutral-translucent-700: rgba(4, 4, 21, 0.47);
@@ -18,29 +18,29 @@
18
18
  --gap-s: 12px;
19
19
  } :root {
20
20
  } :root {
21
- } .international-phone-input__component_1r6tp {
21
+ } .international-phone-input__component_61i1r {
22
22
  position: static;
23
23
  display: flex;
24
24
  min-width: initial;
25
25
  height: 100%;
26
- } .international-phone-input__option_1r6tp {
26
+ } .international-phone-input__option_61i1r {
27
27
  display: flex;
28
28
  align-items: flex-start;
29
29
  padding: var(--gap-s);
30
- } .international-phone-input__flag_1r6tp {
30
+ } .international-phone-input__flag_61i1r {
31
31
  flex-shrink: 0;
32
32
  margin-right: var(--gap-xs);
33
- } .international-phone-input__countryName_1r6tp {
33
+ } .international-phone-input__countryName_61i1r {
34
34
  margin-right: var(--gap-xs);
35
- } .international-phone-input__dialCode_1r6tp {
35
+ } .international-phone-input__dialCode_61i1r {
36
36
  color: var(--color-light-text-secondary);
37
- } .international-phone-input__flagIconWrapper_1r6tp {
37
+ } .international-phone-input__flagIconWrapper_61i1r {
38
38
  display: flex;
39
39
  justify-content: center;
40
40
  align-items: center;
41
41
  width: 24px;
42
42
  height: 24px;
43
43
  margin-left: var(--gap-s);
44
- } .international-phone-input__emptyCountryIcon_1r6tp {
44
+ } .international-phone-input__emptyCountryIcon_61i1r {
45
45
  color: var(--color-light-neutral-translucent-700);
46
46
  }
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import cn from 'classnames';
3
3
  import { flagSprite } from './flagSprite.js';
4
4
 
5
- const styles = {"flagIcon":"international-phone-input__flagIcon_dxseh","flagPlaceholder":"international-phone-input__flagPlaceholder_dxseh"};
5
+ const styles = {"flagIcon":"international-phone-input__flagIcon_mn1nz","flagPlaceholder":"international-phone-input__flagPlaceholder_mn1nz"};
6
6
  require('./index.css')
7
7
 
8
8
  /**
@@ -1,4 +1,4 @@
1
- /* hash: 17zwu */
1
+ /* hash: 9lu45 */
2
2
  :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
3
3
  } /* deprecated */ :root {
4
4
  --color-light-neutral-translucent-100: rgba(38, 55, 88, 0.06); /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
@@ -17,10 +17,10 @@
17
17
  --gap-3xs: 2px;
18
18
  } :root {
19
19
  } :root {
20
- } .international-phone-input__flagIcon_dxseh {
20
+ } .international-phone-input__flagIcon_mn1nz {
21
21
  max-width: 24px;
22
22
  max-height: 24px;
23
- } .international-phone-input__flagPlaceholder_dxseh {
23
+ } .international-phone-input__flagPlaceholder_mn1nz {
24
24
  width: 24px;
25
25
  height: 16px;
26
26
  max-height: 16px;
@@ -5,7 +5,7 @@ import { useFocus } from '@alfalab/hooks';
5
5
  import { WorldMagnifierMIcon } from '@alfalab/icons-glyph/WorldMagnifierMIcon';
6
6
  import { FlagIcon } from '../flag-icon/component.js';
7
7
 
8
- const styles = {"component":"international-phone-input__component_1tk3e","flagIconContainer":"international-phone-input__flagIconContainer_1tk3e","emptyCountryIcon":"international-phone-input__emptyCountryIcon_1tk3e","disabled":"international-phone-input__disabled_1tk3e","inner":"international-phone-input__inner_1tk3e","size-64":"international-phone-input__size-64_1tk3e","size-72":"international-phone-input__size-72_1tk3e","focusVisible":"international-phone-input__focusVisible_1tk3e"};
8
+ const styles = {"component":"international-phone-input__component_y5c1x","flagIconContainer":"international-phone-input__flagIconContainer_y5c1x","emptyCountryIcon":"international-phone-input__emptyCountryIcon_y5c1x","disabled":"international-phone-input__disabled_y5c1x","inner":"international-phone-input__inner_y5c1x","size-64":"international-phone-input__size-64_y5c1x","size-72":"international-phone-input__size-72_y5c1x","focusVisible":"international-phone-input__focusVisible_y5c1x"};
9
9
  require('./index.css')
10
10
 
11
11
  const EMPTY_COUNTRY_SELECT_FIELD = {
@@ -1,4 +1,4 @@
1
- /* hash: 3r6mf */
1
+ /* hash: a6qqq */
2
2
  :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
3
3
  } /* deprecated */ :root {
4
4
  --color-light-border-link: #2288fa;
@@ -21,33 +21,33 @@
21
21
  } :root {
22
22
  --focus-color: var(--color-light-border-link);
23
23
  --disabled-cursor: not-allowed;
24
- } .international-phone-input__component_1tk3e {
24
+ } .international-phone-input__component_y5c1x {
25
25
  height: 100%;
26
26
  cursor: pointer;
27
27
  outline: none;
28
28
  position: relative;
29
- } .international-phone-input__flagIconContainer_1tk3e {
29
+ } .international-phone-input__flagIconContainer_y5c1x {
30
30
  display: flex;
31
31
  justify-content: center;
32
32
  align-items: center;
33
33
  width: 24px;
34
34
  height: 24px;
35
35
  margin-right: var(--gap-2xs);
36
- } .international-phone-input__emptyCountryIcon_1tk3e {
36
+ } .international-phone-input__emptyCountryIcon_y5c1x {
37
37
  color: var(--color-light-neutral-translucent-700);
38
- } .international-phone-input__disabled_1tk3e {
38
+ } .international-phone-input__disabled_y5c1x {
39
39
  cursor: var(--disabled-cursor);
40
- } .international-phone-input__inner_1tk3e {
40
+ } .international-phone-input__inner_y5c1x {
41
41
  position: relative;
42
42
  display: flex;
43
43
  align-items: center;
44
44
  height: 100%;
45
45
  padding-left: var(--gap-s);
46
46
  outline: none;
47
- } .international-phone-input__size-64_1tk3e .international-phone-input__inner_1tk3e,
48
- .international-phone-input__size-72_1tk3e .international-phone-input__inner_1tk3e {
47
+ } .international-phone-input__size-64_y5c1x .international-phone-input__inner_y5c1x,
48
+ .international-phone-input__size-72_y5c1x .international-phone-input__inner_y5c1x {
49
49
  padding-left: var(--gap-m);
50
- } .international-phone-input__focusVisible_1tk3e {
50
+ } .international-phone-input__focusVisible_y5c1x {
51
51
  outline: 2px solid var(--focus-color);
52
52
  outline-offset: 2px;
53
53
  }
package/modern/types.d.ts CHANGED
@@ -5,7 +5,7 @@ import { InputMobileProps } from "@alfalab/core-components-input/mobile";
5
5
  import { InputAutocompleteProps } from "@alfalab/core-components-input-autocomplete";
6
6
  import { InputAutocompleteDesktopProps } from "@alfalab/core-components-input-autocomplete/desktop";
7
7
  import { InputAutocompleteMobileProps } from "@alfalab/core-components-input-autocomplete/mobile";
8
- import { OptionShape } from "./typings-70284312";
8
+ import { OptionShape } from "./typings-57569e57";
9
9
  import { SharedCountrySelectProps } from "./components/country-select/index";
10
10
  type Country = {
11
11
  name: string;
@@ -998,7 +998,7 @@ type BaseSelectProps = {
998
998
  /**
999
999
  * Дополнительный класс для поповера
1000
1000
  */
1001
- popperClassName?: string;
1001
+ popperClassName?: PopoverProps['className'];
1002
1002
  /**
1003
1003
  * Список вариантов выбора
1004
1004
  */
@@ -1195,6 +1195,10 @@ type BaseSelectProps = {
1195
1195
  * Показывать OptionsList, если он пустой
1196
1196
  */
1197
1197
  showEmptyOptionsList?: boolean;
1198
+ /**
1199
+ * Дополнительные пропсы для Popover
1200
+ */
1201
+ popoverProps?: Omit<PopoverProps, 'update' | 'zIndex' | 'position' | 'className' | 'open' | 'anchorElement' | 'preventFlip' | 'dataTestId'>;
1198
1202
  };
1199
1203
  type FieldProps = {
1200
1204
  /**
@@ -1,5 +1,5 @@
1
1
  import { ReactNode, RefObject } from 'react';
2
- import { BaseSelectProps, GroupShape, OptionShape } from "./typings-70284312";
2
+ import { BaseSelectProps, GroupShape, OptionShape } from "./typings-57569e57";
3
3
  declare const isGroup: (item: OptionShape | GroupShape) => item is GroupShape;
4
4
  declare const isOptionShape: (item: OptionShape | string | null) => item is OptionShape;
5
5
  declare const joinOptions: ({ selected, selectedMultiple, }: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-international-phone-input",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -14,9 +14,9 @@
14
14
  "react": "^16.9.0 || ^17.0.1 || ^18.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@alfalab/core-components-input-autocomplete": "12.0.4",
18
- "@alfalab/core-components-input": "^14.3.2",
19
- "@alfalab/core-components-select": "^17.3.4",
17
+ "@alfalab/core-components-input-autocomplete": "12.0.6",
18
+ "@alfalab/core-components-input": "^14.3.3",
19
+ "@alfalab/core-components-select": "^17.4.0",
20
20
  "@alfalab/core-components-shared": "^0.9.1",
21
21
  "@alfalab/core-components-mq": "^4.2.0",
22
22
  "@alfalab/hooks": "^1.13.0",
@@ -51,6 +51,8 @@ export const BaseInternationalPhoneInput = forwardRef<
51
51
  SelectComponent,
52
52
  view,
53
53
  clear: clearProp,
54
+ open: openProps,
55
+ defaultOpen,
54
56
  ...restProps
55
57
  },
56
58
  ref,
@@ -59,6 +61,10 @@ export const BaseInternationalPhoneInput = forwardRef<
59
61
  const inputRef = useRef<HTMLInputElement>(null);
60
62
  const inputWrapperRef = useRef<HTMLDivElement>(null);
61
63
 
64
+ const [open, setOpen] = useState<boolean | undefined>(defaultOpen);
65
+ const [openCountry, setOpenCountry] = useState<boolean | undefined>(
66
+ countrySelectProps?.defaultOpen,
67
+ );
62
68
  const [selectedCountry, setSelectedCountry] = useState<Country | undefined>(() =>
63
69
  findCountry(countriesData, value, defaultIso2, countryProp),
64
70
  );
@@ -139,6 +145,34 @@ export const BaseInternationalPhoneInput = forwardRef<
139
145
  // eslint-disable-next-line react-hooks/exhaustive-deps
140
146
  }, [value, maskOptions]);
141
147
 
148
+ const openPhoneSelect: InputAutocompleteProps['onOpen'] = (payload) => {
149
+ if (openProps === undefined) setOpen(payload.open);
150
+ restProps.onOpen?.(payload);
151
+ };
152
+
153
+ const openCountrySelect: InputAutocompleteProps['onOpen'] = (payload) => {
154
+ if (countrySelectProps?.open === undefined) setOpenCountry(payload.open);
155
+ countrySelectProps?.onOpen?.(payload);
156
+ };
157
+
158
+ const handlePhoneSelectOpen: InputAutocompleteProps['onOpen'] = (payload) => {
159
+ if (payload.open) {
160
+ openCountrySelect({ open: false });
161
+ }
162
+
163
+ openPhoneSelect(payload);
164
+ };
165
+
166
+ const handleCountrySelectOpen: InputAutocompleteProps['onOpen'] = (payload) => {
167
+ if (payload.open) {
168
+ openPhoneSelect({ open: false });
169
+ }
170
+ openCountrySelect(payload);
171
+ };
172
+
173
+ const showPhoneSelect = Boolean(open || openProps);
174
+ const showCountrySelect = Boolean(openCountry || countrySelectProps?.open);
175
+
142
176
  const renderCountrySelect = (compact = false) => (
143
177
  <CountrySelect
144
178
  dataTestId={restProps?.dataTestId}
@@ -150,6 +184,8 @@ export const BaseInternationalPhoneInput = forwardRef<
150
184
  country={country}
151
185
  countries={compact ? [] : countriesData}
152
186
  fieldWidth={inputWrapperRef.current?.getBoundingClientRect().width}
187
+ onOpen={handleCountrySelectOpen}
188
+ open={showCountrySelect}
153
189
  />
154
190
  );
155
191
 
@@ -172,6 +208,8 @@ export const BaseInternationalPhoneInput = forwardRef<
172
208
  disabled={disabled}
173
209
  options={filteredOptions}
174
210
  value={value}
211
+ open={showPhoneSelect}
212
+ onOpen={handlePhoneSelectOpen}
175
213
  onChange={handleOptionSelect}
176
214
  onInput={(phone) => updatePhoneData(phone)}
177
215
  inputProps={{
package/types.d.ts CHANGED
@@ -5,7 +5,7 @@ import { InputMobileProps } from "@alfalab/core-components-input/mobile";
5
5
  import { InputAutocompleteProps } from "@alfalab/core-components-input-autocomplete";
6
6
  import { InputAutocompleteDesktopProps } from "@alfalab/core-components-input-autocomplete/desktop";
7
7
  import { InputAutocompleteMobileProps } from "@alfalab/core-components-input-autocomplete/mobile";
8
- import { OptionShape } from "./typings-70284312";
8
+ import { OptionShape } from "./typings-57569e57";
9
9
  import { SharedCountrySelectProps } from "./components/country-select/index";
10
10
  type Country = {
11
11
  name: string;
@@ -998,7 +998,7 @@ type BaseSelectProps = {
998
998
  /**
999
999
  * Дополнительный класс для поповера
1000
1000
  */
1001
- popperClassName?: string;
1001
+ popperClassName?: PopoverProps['className'];
1002
1002
  /**
1003
1003
  * Список вариантов выбора
1004
1004
  */
@@ -1195,6 +1195,10 @@ type BaseSelectProps = {
1195
1195
  * Показывать OptionsList, если он пустой
1196
1196
  */
1197
1197
  showEmptyOptionsList?: boolean;
1198
+ /**
1199
+ * Дополнительные пропсы для Popover
1200
+ */
1201
+ popoverProps?: Omit<PopoverProps, 'update' | 'zIndex' | 'position' | 'className' | 'open' | 'anchorElement' | 'preventFlip' | 'dataTestId'>;
1198
1202
  };
1199
1203
  type FieldProps = {
1200
1204
  /**