@invoicebox/ui 0.1.0-alpha.57 → 0.1.0-alpha.59

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 (26) hide show
  1. package/dist/components/common/SecondaryButton/styles.d.ts +2 -2
  2. package/dist/components/common/Typography/index.d.ts +2 -2
  3. package/dist/components/common/Typography/index.js +4 -4
  4. package/dist/components/common/Typography/index.stories.d.ts +1 -1
  5. package/dist/components/form/InputLabel/styles.d.ts +2 -2
  6. package/dist/components/form/PhoneInput/constants.d.ts +2 -0
  7. package/dist/components/form/PhoneInput/constants.js +50 -0
  8. package/dist/components/form/PhoneInput/hooks/useValidateInitialValue.d.ts +4 -0
  9. package/dist/components/form/PhoneInput/hooks/useValidateInitialValue.js +40 -0
  10. package/dist/components/form/PhoneInput/index.d.ts +21 -0
  11. package/dist/components/form/PhoneInput/index.js +156 -0
  12. package/dist/components/form/PhoneInput/index.stories.d.ts +6 -0
  13. package/dist/components/form/PhoneInput/index.stories.js +93 -0
  14. package/dist/components/form/PhoneInput/phoneInputLogic.d.ts +21 -0
  15. package/dist/components/form/PhoneInput/phoneInputLogic.js +70 -0
  16. package/dist/components/form/PhoneInput/styles.d.ts +4 -0
  17. package/dist/components/form/PhoneInput/styles.js +20 -0
  18. package/dist/components/form/PhoneInput/types.d.ts +15 -0
  19. package/dist/components/form/PhoneInput/types.js +8 -0
  20. package/dist/components/form/PureInput/index.d.ts +9 -2
  21. package/dist/components/form/PureInput/index.js +3 -2
  22. package/dist/components/form/PureInput/styles.d.ts +2 -2
  23. package/dist/components/form/Select/styles.d.ts +3 -3
  24. package/dist/index.d.ts +5 -1
  25. package/dist/index.js +14 -0
  26. package/package.json +2 -1
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { TSecondaryButtonPalette } from './palette';
3
- export declare const Inner: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("../Typography").TProps, {
3
+ export declare const Inner: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("../Typography").TProps & import("react").RefAttributes<HTMLInputElement>, {
4
4
  $isLoading?: boolean | undefined;
5
- }>> & Omit<import("react").FC<import("../Typography").TProps>, keyof import("react").Component<any, {}, any>>;
5
+ }>> & Omit<import("react").ForwardRefExoticComponent<import("../Typography").TProps & import("react").RefAttributes<HTMLInputElement>>, keyof import("react").Component<any, {}, any>>;
6
6
  export declare const Wrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
7
7
  $palette: TSecondaryButtonPalette;
8
8
  $fullWidth: boolean;
@@ -1,4 +1,4 @@
1
- import { ButtonHTMLAttributes, FC, HTMLAttributes, InputHTMLAttributes } from 'react';
1
+ import React, { ButtonHTMLAttributes, HTMLAttributes, InputHTMLAttributes } from 'react';
2
2
  import { typography } from './typography';
3
3
  type TDivProps = {
4
4
  element?: 'div';
@@ -21,5 +21,5 @@ type TInputProps = {
21
21
  export type TProps = {
22
22
  variant: keyof typeof typography;
23
23
  } & (TDivProps | TParagraphProps | TSpanProps | THeadingProps | TButtonProps | TInputProps);
24
- export declare const Typography: FC<TProps>;
24
+ export declare const Typography: React.ForwardRefExoticComponent<TProps & React.RefAttributes<HTMLInputElement>>;
25
25
  export {};
@@ -5,18 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.Typography = void 0;
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
  var S = _interopRequireWildcard(require("./styles"));
10
10
  var _useCss = require("../../../hooks/useCss");
11
11
  var _excluded = ["variant", "element"];
12
12
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
13
13
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
14
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
16
15
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
17
16
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
18
17
  var CSS_ID = 'INVOICEBOX_UI_TYPOGRAPHY';
19
- var Typography = exports.Typography = function Typography(_ref) {
18
+ var Typography = exports.Typography = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
20
19
  var variant = _ref.variant,
21
20
  _ref$element = _ref.element,
22
21
  element = _ref$element === void 0 ? 'div' : _ref$element,
@@ -26,7 +25,8 @@ var Typography = exports.Typography = function Typography(_ref) {
26
25
  css: "@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap')"
27
26
  });
28
27
  return /*#__PURE__*/_react["default"].createElement(S.Wrapper, _extends({
28
+ ref: ref,
29
29
  as: element,
30
30
  $variant: variant
31
31
  }, rest));
32
- };
32
+ });
@@ -3,7 +3,7 @@ import type { StoryObj } from '@storybook/react';
3
3
  import { Typography } from '.';
4
4
  declare const meta: {
5
5
  title: string;
6
- component: React.FC<import(".").TProps>;
6
+ component: React.ForwardRefExoticComponent<import(".").TProps & React.RefAttributes<HTMLInputElement>>;
7
7
  tags: string[];
8
8
  };
9
9
  export default meta;
@@ -1,9 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { TInputLabelPalette } from './palette';
3
- export declare const Label: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("../../common/Typography").TProps, {
3
+ export declare const Label: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("../../common/Typography").TProps & import("react").RefAttributes<HTMLInputElement>, {
4
4
  $inFocus: boolean;
5
5
  $palette: TInputLabelPalette;
6
- }>> & Omit<import("react").FC<import("../../common/Typography").TProps>, keyof import("react").Component<any, {}, any>>;
6
+ }>> & Omit<import("react").ForwardRefExoticComponent<import("../../common/Typography").TProps & import("react").RefAttributes<HTMLInputElement>>, keyof import("react").Component<any, {}, any>>;
7
7
  export declare const Wrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
8
8
  $disabled: boolean;
9
9
  $isLabel: boolean;
@@ -0,0 +1,2 @@
1
+ import { TCountryRule, TSupportedCountries } from './types';
2
+ export declare const allCountriesPhoneRules: Record<TSupportedCountries, TCountryRule>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.allCountriesPhoneRules = void 0;
7
+ var allCountriesPhoneRules = exports.allCountriesPhoneRules = {
8
+ RUS: {
9
+ mask: '+9 (999) 999-99-99',
10
+ startSubsequence: '7',
11
+ regexp: /^\+?7(9\d{9})$/,
12
+ flag: 'RUS'
13
+ },
14
+ BLR: {
15
+ mask: '+999 99 999-99-99',
16
+ startSubsequence: '375',
17
+ regexp: /^(\+?375)?(24|25|29|33|44)\d{7}$/,
18
+ flag: 'BLR'
19
+ },
20
+ AZE: {
21
+ mask: '+999 (99) 999-9999',
22
+ startSubsequence: '994',
23
+ regexp: /^\+?994\d{9}$/,
24
+ flag: 'AZE'
25
+ },
26
+ ARM: {
27
+ mask: '+999 (99) 999-999',
28
+ startSubsequence: '374',
29
+ regexp: /\+?374\d{8}/,
30
+ flag: 'ARM'
31
+ },
32
+ KAZ: {
33
+ mask: '+9 (999) 999-99-99',
34
+ startSubsequence: '7',
35
+ regexp: /^(\+?7|8)?7\d{9}$/,
36
+ flag: 'KAZ'
37
+ },
38
+ TJK: {
39
+ mask: '+999-99-999-9999',
40
+ startSubsequence: '992',
41
+ regexp: /^\+?992\d{9}$/,
42
+ flag: 'TJK'
43
+ },
44
+ UZB: {
45
+ mask: '+999 99 9999999',
46
+ startSubsequence: '998',
47
+ regexp: /\+?998\d{9}/,
48
+ flag: 'UZB'
49
+ }
50
+ };
@@ -0,0 +1,4 @@
1
+ import { TCountryRule } from '../types';
2
+ export declare const useValidateInitialValue: (initialValue: string, currentCountriesPhoneRules: {
3
+ [p: string]: TCountryRule;
4
+ }, onValid: (currentInputValue: string, countryCode: string) => void, onUnValid: (countryCode: string) => void) => void;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useValidateInitialValue = void 0;
7
+ var _react = require("react");
8
+ var _phoneInputLogic = require("../phoneInputLogic");
9
+ var _constants = require("../constants");
10
+ var _types = require("../types");
11
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
+ var useValidateInitialValue = exports.useValidateInitialValue = function useValidateInitialValue(initialValue, currentCountriesPhoneRules, onValid, onUnValid) {
18
+ var _useState = (0, _react.useState)(false),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ isInitialValidateDone = _useState2[0],
21
+ setIsInitialValidateDone = _useState2[1];
22
+ (0, _react.useEffect)(function () {
23
+ if (isInitialValidateDone) return;
24
+ if (initialValue) {
25
+ var currentCountry = Object.entries(currentCountriesPhoneRules).find(function (item) {
26
+ return _phoneInputLogic.phoneInputLogic.getIsHaveStartSequenceInString(initialValue, item[1].startSubsequence);
27
+ });
28
+ var _countryCode = currentCountry ? currentCountry[0] : _types.RUS_COUNTRY_CODE;
29
+ var isValidInputValue = _phoneInputLogic.phoneInputLogic.getIsValidPhoneInput(initialValue, currentCountry ? currentCountry[1] : _constants.allCountriesPhoneRules.RUS);
30
+ if (isValidInputValue) {
31
+ onValid(initialValue, _countryCode);
32
+ } else {
33
+ onUnValid(_countryCode);
34
+ }
35
+ }
36
+ setIsInitialValidateDone(true);
37
+
38
+ // eslint-disable-next-line react-hooks/exhaustive-deps
39
+ }, [isInitialValidateDone]);
40
+ };
@@ -0,0 +1,21 @@
1
+ import { FC } from 'react';
2
+ import { TSupportedCountries } from './types';
3
+ import { TProps as TPureInputProps } from '../PureInput';
4
+ import { TProps as TCountrySelectProps } from '../CountrySelect';
5
+ type TFieldProps = Pick<TPureInputProps, 'name' | 'onBlur' | 'onFocus'> & {
6
+ value: string;
7
+ onChange: (value: string) => void;
8
+ hasError?: boolean;
9
+ };
10
+ type TControlProps = Pick<TPureInputProps, 'disabled' | 'id'> & {
11
+ label: string;
12
+ countrySelectProps: Pick<TCountrySelectProps, 'selectedLabel' | 'placeholder'>;
13
+ onCountryChange?: (countryCode: string) => void;
14
+ countries?: Array<{
15
+ label: string;
16
+ value: TSupportedCountries;
17
+ }>;
18
+ };
19
+ export type TProps = TControlProps & TFieldProps;
20
+ export declare const PhoneInput: FC<TProps>;
21
+ export {};
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.PhoneInput = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _reactInputMask = _interopRequireDefault(require("@mona-health/react-input-mask"));
10
+ var S = _interopRequireWildcard(require("./styles"));
11
+ var _phoneInputLogic = require("./phoneInputLogic");
12
+ var _useValidateInitialValue = require("./hooks/useValidateInitialValue");
13
+ var _types = require("./types");
14
+ var _useInputFocus2 = require("../../../hooks/useInputFocus");
15
+ var _InputLabel = require("../InputLabel");
16
+ var _PureInput = require("../PureInput");
17
+ var _CountrySelect = require("../CountrySelect");
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
20
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
21
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
22
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
23
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
24
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
25
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
26
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
27
+ var PhoneInput = exports.PhoneInput = function PhoneInput(_ref) {
28
+ var onBlur = _ref.onBlur,
29
+ name = _ref.name,
30
+ onFocus = _ref.onFocus,
31
+ countrySelectProps = _ref.countrySelectProps,
32
+ value = _ref.value,
33
+ onChange = _ref.onChange,
34
+ hasError = _ref.hasError,
35
+ label = _ref.label,
36
+ disabled = _ref.disabled,
37
+ id = _ref.id,
38
+ countries = _ref.countries,
39
+ onCountryChange = _ref.onCountryChange;
40
+ var countrySelectOptions = (0, _react.useMemo)(function () {
41
+ return _phoneInputLogic.phoneInputLogic.getCountriesSelectOptions(countries);
42
+ }, [countries]);
43
+ var isHaveSelectCountries = (0, _react.useMemo)(function () {
44
+ return _phoneInputLogic.phoneInputLogic.getIsHaveCountriesSelectOptions(countrySelectOptions);
45
+ }, [countrySelectOptions]);
46
+ var currentCountriesPhoneRules = (0, _react.useMemo)(function () {
47
+ return _phoneInputLogic.phoneInputLogic.getCountriesPhoneRules(countrySelectOptions);
48
+ }, [countrySelectOptions]);
49
+ var _useInputFocus = (0, _useInputFocus2.useInputFocus)({
50
+ onFocus: onFocus,
51
+ onBlur: onBlur
52
+ }),
53
+ inFocus = _useInputFocus.inFocus,
54
+ focusHandler = _useInputFocus.handleFocus,
55
+ blurHandler = _useInputFocus.handleBlur;
56
+ var _useState = (0, _react.useState)(false),
57
+ _useState2 = _slicedToArray(_useState, 2),
58
+ isHaveInputError = _useState2[0],
59
+ setIsHaveInputError = _useState2[1];
60
+ var _useState3 = (0, _react.useState)(true),
61
+ _useState4 = _slicedToArray(_useState3, 2),
62
+ isFirstBlur = _useState4[0],
63
+ setIsFirstBlur = _useState4[1];
64
+ var _useState5 = (0, _react.useState)(value),
65
+ _useState6 = _slicedToArray(_useState5, 2),
66
+ inputValue = _useState6[0],
67
+ setInputValue = _useState6[1];
68
+ var _useState7 = (0, _react.useState)(_types.RUS_COUNTRY_CODE),
69
+ _useState8 = _slicedToArray(_useState7, 2),
70
+ country = _useState8[0],
71
+ setCountry = _useState8[1];
72
+ var handleChangeCountry = (0, _react.useCallback)(function (countryCode) {
73
+ setCountry(countryCode);
74
+ if (onCountryChange) {
75
+ onCountryChange(countryCode);
76
+ }
77
+ }, [onCountryChange]);
78
+ var handleValid = (0, _react.useCallback)(function (currentInputValue, countryCode) {
79
+ onChange(currentInputValue);
80
+ setIsHaveInputError(false);
81
+ setCountry(countryCode);
82
+ }, [onChange]);
83
+ var handleUnValid = (0, _react.useCallback)(function (countryCode) {
84
+ onChange('');
85
+ setIsHaveInputError(true);
86
+ setCountry(countryCode);
87
+ }, [onChange]);
88
+ (0, _useValidateInitialValue.useValidateInitialValue)(value, currentCountriesPhoneRules, handleValid, handleUnValid);
89
+ var handleInputValueChange = (0, _react.useCallback)(function (currentInputValue) {
90
+ var notFormattedValue = _phoneInputLogic.phoneInputLogic.getOnlyNumbersFromString(currentInputValue);
91
+ var currentCountry = currentCountriesPhoneRules[country];
92
+ var newCountry = Object.entries(currentCountriesPhoneRules).find(function (item) {
93
+ return _phoneInputLogic.phoneInputLogic.getIsHaveStartSequenceInString(notFormattedValue, item[1].startSubsequence) && currentCountry.flag !== item[1].flag;
94
+ });
95
+ var isNeedChangeCountry = newCountry && currentCountry.startSubsequence !== newCountry[1].startSubsequence;
96
+ if (isNeedChangeCountry && newCountry) {
97
+ handleChangeCountry(newCountry[0]);
98
+ }
99
+ var isValidInputValue = _phoneInputLogic.phoneInputLogic.getIsValidPhoneInput(notFormattedValue, isNeedChangeCountry && newCountry ? newCountry[1] : currentCountry);
100
+ setIsHaveInputError(!isValidInputValue);
101
+ onChange(isValidInputValue ? notFormattedValue : '');
102
+ setInputValue(notFormattedValue);
103
+ }, [country, currentCountriesPhoneRules, handleChangeCountry, onChange]);
104
+ var handleChange = (0, _react.useCallback)(function (event) {
105
+ handleInputValueChange(event.target.value);
106
+ }, [handleInputValueChange]);
107
+ var handleBlur = (0, _react.useCallback)(function (event) {
108
+ blurHandler(event);
109
+ if (isFirstBlur) {
110
+ setIsFirstBlur(false);
111
+ }
112
+ }, [isFirstBlur, blurHandler]);
113
+ var handleCountryChange = (0, _react.useCallback)(function (countryValue) {
114
+ handleChangeCountry(countryValue);
115
+ var currentCountry = currentCountriesPhoneRules[countryValue];
116
+ var isValidInputValue = _phoneInputLogic.phoneInputLogic.getIsValidPhoneInput(inputValue, currentCountry);
117
+ setIsFirstBlur(false);
118
+ setIsHaveInputError(!isValidInputValue);
119
+ }, [currentCountriesPhoneRules, handleChangeCountry, inputValue]);
120
+ var handlePaste = (0, _react.useCallback)(function (event) {
121
+ event.preventDefault();
122
+ var pasteText = event.clipboardData.getData('Text').trim();
123
+ handleInputValueChange(pasteText);
124
+ }, [handleInputValueChange]);
125
+ return /*#__PURE__*/_react["default"].createElement(_InputLabel.InputLabel, {
126
+ inFocus: inFocus,
127
+ label: label,
128
+ disabled: disabled
129
+ }, /*#__PURE__*/_react["default"].createElement(S.InputLabelContent, null, !!(countrySelectOptions !== null && countrySelectOptions !== void 0 && countrySelectOptions.length) && /*#__PURE__*/_react["default"].createElement(S.InputLabelFloatWrapper, null, /*#__PURE__*/_react["default"].createElement(S.CountrySelectWrapper, null, /*#__PURE__*/_react["default"].createElement(_CountrySelect.CountrySelect, {
130
+ minWidth: "350px",
131
+ options: countrySelectOptions,
132
+ onChange: handleCountryChange,
133
+ value: country,
134
+ placeholder: countrySelectProps.placeholder,
135
+ positionVertical: 16,
136
+ positionRight: "0",
137
+ positionLeft: "-20px",
138
+ disabled: disabled,
139
+ selectedLabel: countrySelectProps.selectedLabel
140
+ }))), /*#__PURE__*/_react["default"].createElement(_reactInputMask["default"], {
141
+ value: inputValue,
142
+ onFocus: focusHandler,
143
+ onBlur: handleBlur,
144
+ onChange: handleChange,
145
+ mask: currentCountriesPhoneRules[country].mask,
146
+ maskPlaceholder: null,
147
+ disabled: disabled,
148
+ onPaste: handlePaste
149
+ }, /*#__PURE__*/_react["default"].createElement(_PureInput.PureInput, {
150
+ id: id,
151
+ hasError: hasError || (isFirstBlur ? false : isHaveInputError),
152
+ inFocus: inFocus,
153
+ name: name,
154
+ paddingLeft: isHaveSelectCountries ? 75 : 18
155
+ }))));
156
+ };
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { TProps, PhoneInput } from '.';
3
+ declare const meta: Meta<typeof PhoneInput>;
4
+ export default meta;
5
+ export declare const MultiCountry: StoryObj<TProps>;
6
+ export declare const DefaultRusCountry: StoryObj<TProps>;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = exports.MultiCountry = exports.DefaultRusCountry = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _ = require(".");
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
12
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
16
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
17
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
18
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
19
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
20
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
21
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
22
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
23
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
24
+ var meta = {
25
+ title: 'form/PhoneInput',
26
+ component: _.PhoneInput,
27
+ tags: ['autodocs'],
28
+ argTypes: {
29
+ onBlur: {
30
+ action: 'onBlur'
31
+ },
32
+ onFocus: {
33
+ action: 'onFocus'
34
+ },
35
+ onCountryChange: {
36
+ action: 'onCountryChange'
37
+ }
38
+ }
39
+ };
40
+ var _default = exports["default"] = meta;
41
+ var Component = function Component(props) {
42
+ var _useState = (0, _react.useState)('37411800000'),
43
+ _useState2 = _slicedToArray(_useState, 2),
44
+ value = _useState2[0],
45
+ setValue = _useState2[1];
46
+ return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("p", null, "\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435: ", /*#__PURE__*/_react["default"].createElement("span", null, value)), /*#__PURE__*/_react["default"].createElement("div", {
47
+ style: {
48
+ width: 400
49
+ }
50
+ }, /*#__PURE__*/_react["default"].createElement(_.PhoneInput, _extends({}, props, {
51
+ value: value,
52
+ onChange: setValue
53
+ }))));
54
+ };
55
+ var commonProps = {
56
+ disabled: false,
57
+ label: 'Телефон',
58
+ countrySelectProps: {
59
+ placeholder: 'Поиск',
60
+ selectedLabel: '(выбрано)'
61
+ }
62
+ };
63
+ var MultiCountry = exports.MultiCountry = {
64
+ args: _objectSpread(_objectSpread({}, commonProps), {}, {
65
+ countries: [{
66
+ label: 'Россия',
67
+ value: 'RUS'
68
+ }, {
69
+ label: 'Армения',
70
+ value: 'ARM'
71
+ }, {
72
+ label: 'Белорусь',
73
+ value: 'BLR'
74
+ }, {
75
+ label: 'Казахстан',
76
+ value: 'KAZ'
77
+ }, {
78
+ label: 'Азербайджан',
79
+ value: 'AZE'
80
+ }, {
81
+ label: 'Такджикистан',
82
+ value: 'TJK'
83
+ }, {
84
+ label: 'Узбекистан',
85
+ value: 'UZB'
86
+ }]
87
+ }),
88
+ render: Component
89
+ };
90
+ var DefaultRusCountry = exports.DefaultRusCountry = {
91
+ args: commonProps,
92
+ render: Component
93
+ };
@@ -0,0 +1,21 @@
1
+ import { TCountryRule, TCountrySelectOption, TSupportedCountries } from './types';
2
+ declare class PhoneInputLogic {
3
+ getIsValidPhoneInput(value: string, country: TCountryRule): boolean;
4
+ getCountriesSelectOptions(countries?: Array<{
5
+ label: string;
6
+ value: TSupportedCountries;
7
+ }>): {
8
+ description: string;
9
+ flag: "RUS" | "BLR" | "KAZ" | "AZE" | "ARM" | "KGZ" | "MDA" | "TJK" | "UZB" | "CHN" | "ENG" | "ESP";
10
+ label: string;
11
+ value: TSupportedCountries;
12
+ }[] | undefined;
13
+ getIsHaveCountriesSelectOptions(countrySelectOptions?: Array<TCountrySelectOption>): boolean;
14
+ getCountriesPhoneRules(countrySelectOptions?: Array<TCountrySelectOption>): {
15
+ [k: string]: TCountryRule;
16
+ };
17
+ getIsHaveStartSequenceInString(value: string, subsequence: string): boolean;
18
+ getOnlyNumbersFromString(value: string): string;
19
+ }
20
+ export declare const phoneInputLogic: PhoneInputLogic;
21
+ export {};
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.phoneInputLogic = void 0;
7
+ var _constants = require("./constants");
8
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
9
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
14
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
16
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
17
+ var PhoneInputLogic = /*#__PURE__*/function () {
18
+ function PhoneInputLogic() {
19
+ _classCallCheck(this, PhoneInputLogic);
20
+ }
21
+ _createClass(PhoneInputLogic, [{
22
+ key: "getIsValidPhoneInput",
23
+ value: function getIsValidPhoneInput(value, country) {
24
+ return !!value.match(country.regexp);
25
+ }
26
+ }, {
27
+ key: "getCountriesSelectOptions",
28
+ value: function getCountriesSelectOptions(countries) {
29
+ var supportedCountries = countries === null || countries === void 0 ? void 0 : countries.filter(function (country) {
30
+ return _constants.allCountriesPhoneRules[country.value];
31
+ });
32
+ return supportedCountries === null || supportedCountries === void 0 ? void 0 : supportedCountries.map(function (country) {
33
+ var countryRules = _constants.allCountriesPhoneRules[country.value];
34
+ return _objectSpread(_objectSpread({}, country), {}, {
35
+ description: "+".concat(countryRules.startSubsequence),
36
+ flag: countryRules.flag
37
+ });
38
+ });
39
+ }
40
+ }, {
41
+ key: "getIsHaveCountriesSelectOptions",
42
+ value: function getIsHaveCountriesSelectOptions(countrySelectOptions) {
43
+ return !!(countrySelectOptions !== null && countrySelectOptions !== void 0 && countrySelectOptions.length);
44
+ }
45
+ }, {
46
+ key: "getCountriesPhoneRules",
47
+ value: function getCountriesPhoneRules(countrySelectOptions) {
48
+ return this.getIsHaveCountriesSelectOptions(countrySelectOptions) ? Object.fromEntries(Object.entries(_constants.allCountriesPhoneRules).filter(function (ruleItem) {
49
+ return countrySelectOptions === null || countrySelectOptions === void 0 ? void 0 : countrySelectOptions.find(function (countrySelectOption) {
50
+ return countrySelectOption.value === ruleItem[0];
51
+ });
52
+ })) : {
53
+ RUS: _constants.allCountriesPhoneRules.RUS
54
+ };
55
+ }
56
+ }, {
57
+ key: "getIsHaveStartSequenceInString",
58
+ value: function getIsHaveStartSequenceInString(value, subsequence) {
59
+ return value.startsWith(subsequence);
60
+ }
61
+ }, {
62
+ key: "getOnlyNumbersFromString",
63
+ value: function getOnlyNumbersFromString(value) {
64
+ var _value$match;
65
+ return ((_value$match = value.match(/\d/g)) === null || _value$match === void 0 ? void 0 : _value$match.join('')) || '';
66
+ }
67
+ }]);
68
+ return PhoneInputLogic;
69
+ }();
70
+ var phoneInputLogic = exports.phoneInputLogic = new PhoneInputLogic();
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ export declare const CountrySelectWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
3
+ export declare const InputLabelContent: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
4
+ export declare const InputLabelFloatWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.InputLabelFloatWrapper = exports.InputLabelContent = exports.CountrySelectWrapper = void 0;
7
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
9
+ var CountrySelectWrapper = exports.CountrySelectWrapper = _styledComponents["default"].div.withConfig({
10
+ displayName: "styles__CountrySelectWrapper",
11
+ componentId: "sc-pqm10s-0"
12
+ })(["padding-left:20px;width:100%;"]);
13
+ var InputLabelContent = exports.InputLabelContent = _styledComponents["default"].div.withConfig({
14
+ displayName: "styles__InputLabelContent",
15
+ componentId: "sc-pqm10s-1"
16
+ })(["position:relative;"]);
17
+ var InputLabelFloatWrapper = exports.InputLabelFloatWrapper = _styledComponents["default"].div.withConfig({
18
+ displayName: "styles__InputLabelFloatWrapper",
19
+ componentId: "sc-pqm10s-2"
20
+ })(["position:absolute;height:100%;width:100%;pointer-events:none;display:flex;align-items:center;"]);
@@ -0,0 +1,15 @@
1
+ export declare const RUS_COUNTRY_CODE = "RUS";
2
+ export declare const supportedCountries: readonly ["RUS", "BLR", "AZE", "ARM", "KAZ", "TJK", "UZB"];
3
+ export type TSupportedCountries = (typeof supportedCountries)[number];
4
+ export type TCountryRule = {
5
+ mask: string;
6
+ startSubsequence: string;
7
+ regexp: RegExp;
8
+ flag: string;
9
+ };
10
+ export type TCountrySelectOption = {
11
+ description: string;
12
+ flag: string;
13
+ label: string;
14
+ value: string;
15
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.supportedCountries = exports.RUS_COUNTRY_CODE = void 0;
7
+ var RUS_COUNTRY_CODE = exports.RUS_COUNTRY_CODE = 'RUS';
8
+ var supportedCountries = exports.supportedCountries = [RUS_COUNTRY_CODE, 'BLR', 'AZE', 'ARM', 'KAZ', 'TJK', 'UZB'];
@@ -1,4 +1,4 @@
1
- import { FC, InputHTMLAttributes } from 'react';
1
+ import React, { InputHTMLAttributes } from 'react';
2
2
  export type TProps = InputHTMLAttributes<HTMLInputElement> & {
3
3
  paddingLeft?: number;
4
4
  paddingRight?: number;
@@ -7,4 +7,11 @@ export type TProps = InputHTMLAttributes<HTMLInputElement> & {
7
7
  hasBorder?: boolean;
8
8
  className?: never;
9
9
  };
10
- export declare const PureInput: FC<TProps>;
10
+ export declare const PureInput: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
11
+ paddingLeft?: number | undefined;
12
+ paddingRight?: number | undefined;
13
+ hasError?: boolean | undefined;
14
+ inFocus?: boolean | undefined;
15
+ hasBorder?: boolean | undefined;
16
+ className?: undefined;
17
+ } & React.RefAttributes<HTMLInputElement>>;
@@ -15,7 +15,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
15
15
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
16
16
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
17
17
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
18
- var PureInput = exports.PureInput = function PureInput(_ref) {
18
+ var PureInput = exports.PureInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
19
19
  var _ref$paddingLeft = _ref.paddingLeft,
20
20
  paddingLeft = _ref$paddingLeft === void 0 ? 18 : _ref$paddingLeft,
21
21
  _ref$paddingRight = _ref.paddingRight,
@@ -30,6 +30,7 @@ var PureInput = exports.PureInput = function PureInput(_ref) {
30
30
  rest = _objectWithoutProperties(_ref, _excluded);
31
31
  var palette = (0, _palette.useComponentPalette)('pureInput');
32
32
  return /*#__PURE__*/_react["default"].createElement(S.Wrapper, _extends({
33
+ ref: ref,
33
34
  variant: "bodyMRegular",
34
35
  element: "input",
35
36
  $paddingLeft: paddingLeft,
@@ -39,4 +40,4 @@ var PureInput = exports.PureInput = function PureInput(_ref) {
39
40
  $hasBorder: hasBorder,
40
41
  $palette: palette
41
42
  }, rest));
42
- };
43
+ });
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { TPureInputPalette } from './palette';
3
- export declare const Wrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("../../common/Typography").TProps, {
3
+ export declare const Wrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("../../common/Typography").TProps & import("react").RefAttributes<HTMLInputElement>, {
4
4
  $paddingLeft: number;
5
5
  $paddingRight: number;
6
6
  $hasError: boolean;
7
7
  $inFocus: boolean;
8
8
  $hasBorder: boolean;
9
9
  $palette: TPureInputPalette;
10
- }>> & Omit<import("react").FC<import("../../common/Typography").TProps>, keyof import("react").Component<any, {}, any>>;
10
+ }>> & Omit<import("react").ForwardRefExoticComponent<import("../../common/Typography").TProps & import("react").RefAttributes<HTMLInputElement>>, keyof import("react").Component<any, {}, any>>;
@@ -3,8 +3,8 @@ import { TSelectPalette } from './palette';
3
3
  export declare const Wrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
4
4
  export declare const InputWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
5
5
  export declare const Options: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
6
- export declare const Option: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("../../common/Typography").TProps, {
6
+ export declare const Option: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("../../common/Typography").TProps & import("react").RefAttributes<HTMLInputElement>, {
7
7
  $palette: TSelectPalette;
8
8
  $isGrouped: boolean;
9
- }>> & Omit<import("react").FC<import("../../common/Typography").TProps>, keyof import("react").Component<any, {}, any>>;
10
- export declare const Group: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("../../common/Typography").TProps, import("styled-components/dist/types").BaseObject>> & Omit<import("react").FC<import("../../common/Typography").TProps>, keyof import("react").Component<any, {}, any>>;
9
+ }>> & Omit<import("react").ForwardRefExoticComponent<import("../../common/Typography").TProps & import("react").RefAttributes<HTMLInputElement>>, keyof import("react").Component<any, {}, any>>;
10
+ export declare const Group: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("../../common/Typography").TProps & import("react").RefAttributes<HTMLInputElement>, import("styled-components/dist/types").BaseObject>> & Omit<import("react").ForwardRefExoticComponent<import("../../common/Typography").TProps & import("react").RefAttributes<HTMLInputElement>>, keyof import("react").Component<any, {}, any>>;
package/dist/index.d.ts CHANGED
@@ -24,7 +24,11 @@ export type { TProps as TDividerProps } from './components/common/Divider';
24
24
  export { SearchInput } from './components/form/SearchInput';
25
25
  export type { TProps as TSearchInputProps } from './components/form/SearchInput';
26
26
  export { Flag } from './components/common/Flag';
27
- export type { TProps as TFlagProps } from './components/common/Flag';
27
+ export type { TProps as TFlagProps, TFlagKey } from './components/common/Flag';
28
+ export { CountrySelect } from './components/form/CountrySelect';
29
+ export type { TProps as TCountrySelectProps } from './components/form/CountrySelect';
30
+ export { PhoneInput } from './components/form/PhoneInput';
31
+ export type { TProps as TPhoneInputProps } from './components/form/PhoneInput';
28
32
  export { PaletteProvider } from './palette';
29
33
  export type { TAbstractPalette } from './palette';
30
34
  export { useOutsideClick } from './hooks/useOutsideClick';
package/dist/index.js CHANGED
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "Calendar", {
15
15
  return _Calendar.Calendar;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "CountrySelect", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _CountrySelect.CountrySelect;
22
+ }
23
+ });
18
24
  Object.defineProperty(exports, "DateInput", {
19
25
  enumerable: true,
20
26
  get: function get() {
@@ -63,6 +69,12 @@ Object.defineProperty(exports, "PaletteProvider", {
63
69
  return _palette.PaletteProvider;
64
70
  }
65
71
  });
72
+ Object.defineProperty(exports, "PhoneInput", {
73
+ enumerable: true,
74
+ get: function get() {
75
+ return _PhoneInput.PhoneInput;
76
+ }
77
+ });
66
78
  Object.defineProperty(exports, "PositiveIntegerInput", {
67
79
  enumerable: true,
68
80
  get: function get() {
@@ -147,6 +159,8 @@ var _WarningIcon = require("./components/common/WarningIcon");
147
159
  var _Divider = require("./components/common/Divider");
148
160
  var _SearchInput = require("./components/form/SearchInput");
149
161
  var _Flag = require("./components/common/Flag");
162
+ var _CountrySelect = require("./components/form/CountrySelect");
163
+ var _PhoneInput = require("./components/form/PhoneInput");
150
164
  var _palette = require("./palette");
151
165
  var _useOutsideClick = require("./hooks/useOutsideClick");
152
166
  var _useInputFocus = require("./hooks/useInputFocus");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@invoicebox/ui",
3
- "version": "0.1.0-alpha.57",
3
+ "version": "0.1.0-alpha.59",
4
4
  "description": "Invoicebox UI",
5
5
  "license": "Apache License 2.0",
6
6
  "scripts": {
@@ -47,6 +47,7 @@
47
47
  "webpack": "^5.90.1"
48
48
  },
49
49
  "dependencies": {
50
+ "@mona-health/react-input-mask": "^3.0.3",
50
51
  "hex-to-rgba": "^2.0.1",
51
52
  "lottie-react": "^2.4.0",
52
53
  "react-calendar": "^4.8.0",