@invoicebox/ui 0.1.0-alpha.8 → 0.1.0-alpha.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -1
- package/dist/breakpoints/index.d.ts +7 -0
- package/dist/breakpoints/index.js +13 -0
- package/dist/components/common/Arrow/components/StyledSvg/index.d.ts +8 -0
- package/dist/components/common/Arrow/components/StyledSvg/index.js +25 -0
- package/dist/components/common/Arrow/components/StyledSvg/index.stories.d.ts +5 -0
- package/dist/components/common/Arrow/components/StyledSvg/index.stories.js +26 -0
- package/dist/components/common/Arrow/components/Svg/index.d.ts +6 -0
- package/dist/components/common/Arrow/components/Svg/index.js +26 -0
- package/dist/components/common/Arrow/components/Svg/index.stories.d.ts +6 -0
- package/dist/components/common/Arrow/components/Svg/index.stories.js +21 -0
- package/dist/components/common/Arrow/index.d.ts +10 -0
- package/dist/components/common/Arrow/index.js +29 -0
- package/dist/components/common/Arrow/index.stories.d.ts +6 -0
- package/dist/components/common/Arrow/index.stories.js +21 -0
- package/dist/components/common/Arrow/palette.d.ts +6 -0
- package/dist/components/common/Arrow/palette.js +14 -0
- package/dist/components/common/Calendar/docs.stories.d.ts +6 -0
- package/dist/components/common/Calendar/docs.stories.js +20 -0
- package/dist/components/common/Calendar/index.css +81 -0
- package/dist/components/common/Calendar/index.d.ts +8 -0
- package/dist/components/common/Calendar/index.js +40 -0
- package/dist/components/common/Calendar/index.stories.d.ts +7 -0
- package/dist/components/common/Calendar/index.stories.js +55 -0
- package/dist/components/common/Calendar/palette.d.ts +9 -0
- package/dist/components/common/Calendar/palette.js +17 -0
- package/dist/components/common/Divider/index.d.ts +6 -0
- package/dist/components/common/Divider/index.js +20 -0
- package/dist/components/common/Divider/index.stories.d.ts +6 -0
- package/dist/components/common/Divider/index.stories.js +14 -0
- package/dist/components/common/Divider/palette.d.ts +5 -0
- package/dist/components/common/Divider/palette.js +11 -0
- package/dist/components/common/Divider/styles.d.ts +5 -0
- package/dist/components/common/Divider/styles.js +15 -0
- package/dist/components/common/Dropdown/index.d.ts +14 -0
- package/dist/components/common/Dropdown/index.js +117 -0
- package/dist/components/common/Dropdown/index.stories.d.ts +6 -0
- package/dist/components/common/Dropdown/index.stories.js +59 -0
- package/dist/components/common/Dropdown/palette.d.ts +6 -0
- package/dist/components/common/Dropdown/palette.js +14 -0
- package/dist/components/common/Dropdown/styles.d.ts +14 -0
- package/dist/components/common/Dropdown/styles.js +47 -0
- package/dist/components/common/Flag/components/ArmFlag/index.d.ts +1 -0
- package/dist/components/common/Flag/components/ArmFlag/index.js +30 -0
- package/dist/components/common/Flag/components/ArmFlag/index.stories.d.ts +5 -0
- package/dist/components/common/Flag/components/ArmFlag/index.stories.js +14 -0
- package/dist/components/common/Flag/components/AzeFlag/index.d.ts +1 -0
- package/dist/components/common/Flag/components/AzeFlag/index.js +40 -0
- package/dist/components/common/Flag/components/AzeFlag/index.stories.d.ts +5 -0
- package/dist/components/common/Flag/components/AzeFlag/index.stories.js +14 -0
- package/dist/components/common/Flag/components/BlrFlag/index.d.ts +1 -0
- package/dist/components/common/Flag/components/BlrFlag/index.js +35 -0
- package/dist/components/common/Flag/components/BlrFlag/index.stories.d.ts +5 -0
- package/dist/components/common/Flag/components/BlrFlag/index.stories.js +14 -0
- package/dist/components/common/Flag/components/ChnFlag/index.d.ts +1 -0
- package/dist/components/common/Flag/components/ChnFlag/index.js +32 -0
- package/dist/components/common/Flag/components/ChnFlag/index.stories.d.ts +5 -0
- package/dist/components/common/Flag/components/ChnFlag/index.stories.js +14 -0
- package/dist/components/common/Flag/components/EngFlag/index.d.ts +1 -0
- package/dist/components/common/Flag/components/EngFlag/index.js +54 -0
- package/dist/components/common/Flag/components/EngFlag/index.stories.d.ts +5 -0
- package/dist/components/common/Flag/components/EngFlag/index.stories.js +14 -0
- package/dist/components/common/Flag/components/EspFlag/index.d.ts +1 -0
- package/dist/components/common/Flag/components/EspFlag/index.js +86 -0
- package/dist/components/common/Flag/components/EspFlag/index.stories.d.ts +5 -0
- package/dist/components/common/Flag/components/EspFlag/index.stories.js +14 -0
- package/dist/components/common/Flag/components/KazFlag/index.d.ts +1 -0
- package/dist/components/common/Flag/components/KazFlag/index.js +35 -0
- package/dist/components/common/Flag/components/KazFlag/index.stories.d.ts +5 -0
- package/dist/components/common/Flag/components/KazFlag/index.stories.js +14 -0
- package/dist/components/common/Flag/components/KgzFlag/index.d.ts +1 -0
- package/dist/components/common/Flag/components/KgzFlag/index.js +32 -0
- package/dist/components/common/Flag/components/KgzFlag/index.stories.d.ts +5 -0
- package/dist/components/common/Flag/components/KgzFlag/index.stories.js +14 -0
- package/dist/components/common/Flag/components/MdaFlag/index.d.ts +1 -0
- package/dist/components/common/Flag/components/MdaFlag/index.js +52 -0
- package/dist/components/common/Flag/components/MdaFlag/index.stories.d.ts +5 -0
- package/dist/components/common/Flag/components/MdaFlag/index.stories.js +14 -0
- package/dist/components/common/Flag/components/RusFlag/index.d.ts +1 -0
- package/dist/components/common/Flag/components/RusFlag/index.js +32 -0
- package/dist/components/common/Flag/components/RusFlag/index.stories.d.ts +5 -0
- package/dist/components/common/Flag/components/RusFlag/index.stories.js +14 -0
- package/dist/components/common/Flag/components/TjkFlag/index.d.ts +1 -0
- package/dist/components/common/Flag/components/TjkFlag/index.js +37 -0
- package/dist/components/common/Flag/components/TjkFlag/index.stories.d.ts +5 -0
- package/dist/components/common/Flag/components/TjkFlag/index.stories.js +14 -0
- package/dist/components/common/Flag/components/UnknownFlag/index.d.ts +1 -0
- package/dist/components/common/Flag/components/UnknownFlag/index.js +26 -0
- package/dist/components/common/Flag/components/UnknownFlag/index.stories.d.ts +5 -0
- package/dist/components/common/Flag/components/UnknownFlag/index.stories.js +14 -0
- package/dist/components/common/Flag/components/UzbFlag/index.d.ts +1 -0
- package/dist/components/common/Flag/components/UzbFlag/index.js +43 -0
- package/dist/components/common/Flag/components/UzbFlag/index.stories.d.ts +5 -0
- package/dist/components/common/Flag/components/UzbFlag/index.stories.js +14 -0
- package/dist/components/common/Flag/index.d.ts +11 -0
- package/dist/components/common/Flag/index.js +49 -0
- package/dist/components/common/Flag/index.stories.d.ts +6 -0
- package/dist/components/common/Flag/index.stories.js +22 -0
- package/dist/components/common/Flag/styles.d.ts +4 -0
- package/dist/components/common/Flag/styles.js +19 -0
- package/dist/components/common/InvoiceboxLoader/assets/loader.json +1 -0
- package/dist/components/common/InvoiceboxLoader/index.d.ts +5 -0
- package/dist/components/common/InvoiceboxLoader/index.js +878 -0
- package/dist/components/common/InvoiceboxLoader/index.stories.d.ts +5 -0
- package/dist/components/common/InvoiceboxLoader/index.stories.js +18 -0
- package/dist/components/common/InvoiceboxSpinner/index.d.ts +7 -0
- package/dist/components/common/InvoiceboxSpinner/index.js +39 -0
- package/dist/components/common/InvoiceboxSpinner/index.stories.d.ts +10 -0
- package/dist/components/common/InvoiceboxSpinner/index.stories.js +18 -0
- package/dist/components/common/InvoiceboxSpinner/palette.d.ts +6 -0
- package/dist/components/common/InvoiceboxSpinner/palette.js +12 -0
- package/dist/components/common/InvoiceboxSpinner/styles.d.ts +4 -0
- package/dist/components/common/InvoiceboxSpinner/styles.js +19 -0
- package/dist/components/common/Scrollbar/index.d.ts +6 -0
- package/dist/components/common/Scrollbar/index.js +70 -0
- package/dist/components/common/Scrollbar/index.stories.d.ts +13 -0
- package/dist/components/common/Scrollbar/index.stories.js +45 -0
- package/dist/components/common/Scrollbar/palette.d.ts +5 -0
- package/dist/components/common/Scrollbar/palette.js +11 -0
- package/dist/components/common/SecondaryButton/index.d.ts +15 -0
- package/dist/components/common/SecondaryButton/index.js +48 -0
- package/dist/components/common/SecondaryButton/index.stories.d.ts +11 -0
- package/dist/components/common/SecondaryButton/index.stories.js +38 -0
- package/dist/components/common/SecondaryButton/palette.d.ts +8 -0
- package/dist/components/common/SecondaryButton/palette.js +14 -0
- package/dist/components/common/SecondaryButton/styles.d.ts +11 -0
- package/dist/components/common/SecondaryButton/styles.js +46 -0
- package/dist/components/common/Skeleton/index.d.ts +8 -0
- package/dist/components/common/Skeleton/index.js +28 -0
- package/dist/components/common/Skeleton/index.stories.d.ts +11 -0
- package/dist/components/common/Skeleton/index.stories.js +29 -0
- package/dist/components/common/Skeleton/palette.d.ts +6 -0
- package/dist/components/common/Skeleton/palette.js +12 -0
- package/dist/components/common/Skeleton/styles.d.ts +10 -0
- package/dist/components/common/Skeleton/styles.js +37 -0
- package/dist/components/common/Typography/index.d.ts +25 -0
- package/dist/components/common/Typography/index.js +32 -0
- package/dist/components/common/Typography/index.stories.d.ts +11 -0
- package/dist/components/common/Typography/index.stories.js +36 -0
- package/dist/components/common/Typography/styles.d.ts +5 -0
- package/dist/components/common/Typography/styles.js +16 -0
- package/dist/components/common/Typography/typography.d.ts +20 -0
- package/dist/components/common/Typography/typography.js +28 -0
- package/dist/components/common/WarningIcon/components/Icon.d.ts +6 -0
- package/dist/components/common/WarningIcon/components/Icon.js +22 -0
- package/dist/components/common/WarningIcon/index.d.ts +7 -0
- package/dist/components/common/WarningIcon/index.js +23 -0
- package/dist/components/common/WarningIcon/index.stories.d.ts +5 -0
- package/dist/components/common/WarningIcon/index.stories.js +14 -0
- package/dist/components/common/WarningIcon/palette.d.ts +5 -0
- package/dist/components/common/WarningIcon/palette.js +11 -0
- package/dist/components/common/WarningIcon/styles.d.ts +10 -0
- package/dist/components/common/WarningIcon/styles.js +22 -0
- package/dist/components/form/CountrySelect/components/CountryItem/index.d.ts +13 -0
- package/dist/components/form/CountrySelect/components/CountryItem/index.js +41 -0
- package/dist/components/form/CountrySelect/components/CountryItem/index.stories.d.ts +5 -0
- package/dist/components/form/CountrySelect/components/CountryItem/index.stories.js +34 -0
- package/dist/components/form/CountrySelect/components/CountryItem/stlyes.d.ts +9 -0
- package/dist/components/form/CountrySelect/components/CountryItem/stlyes.js +31 -0
- package/dist/components/form/CountrySelect/index.d.ts +22 -0
- package/dist/components/form/CountrySelect/index.js +122 -0
- package/dist/components/form/CountrySelect/index.stories.d.ts +5 -0
- package/dist/components/form/CountrySelect/index.stories.js +57 -0
- package/dist/components/form/CountrySelect/logic.d.ts +5 -0
- package/dist/components/form/CountrySelect/logic.js +25 -0
- package/dist/components/form/CountrySelect/palette.d.ts +9 -0
- package/dist/components/form/CountrySelect/palette.js +17 -0
- package/dist/components/form/CountrySelect/stlyes.d.ts +8 -0
- package/dist/components/form/CountrySelect/stlyes.js +27 -0
- package/dist/components/form/DateInput/components/Icon/index.d.ts +1 -0
- package/dist/components/form/DateInput/components/Icon/index.js +33 -0
- package/dist/components/form/DateInput/components/Icon/index.stories.d.ts +5 -0
- package/dist/components/form/DateInput/components/Icon/index.stories.js +14 -0
- package/dist/components/form/DateInput/docs.stories.d.ts +6 -0
- package/dist/components/form/DateInput/docs.stories.js +20 -0
- package/dist/components/form/DateInput/index.d.ts +9 -0
- package/dist/components/form/DateInput/index.js +111 -0
- package/dist/components/form/DateInput/index.stories.d.ts +7 -0
- package/dist/components/form/DateInput/index.stories.js +52 -0
- package/dist/components/form/DateInput/logic.d.ts +10 -0
- package/dist/components/form/DateInput/logic.js +71 -0
- package/dist/components/form/DateInput/palette.d.ts +5 -0
- package/dist/components/form/DateInput/palette.js +11 -0
- package/dist/components/form/DateInput/styles.d.ts +8 -0
- package/dist/components/form/DateInput/styles.js +28 -0
- package/dist/components/form/InputLabel/index.d.ts +8 -0
- package/dist/components/form/InputLabel/index.js +31 -0
- package/dist/components/form/InputLabel/index.stories.d.ts +5 -0
- package/dist/components/form/InputLabel/index.stories.js +33 -0
- package/dist/components/form/InputLabel/palette.d.ts +7 -0
- package/dist/components/form/InputLabel/palette.js +13 -0
- package/dist/components/form/InputLabel/styles.d.ts +11 -0
- package/dist/components/form/InputLabel/styles.js +36 -0
- package/dist/components/form/PhoneInput/constants.d.ts +3 -0
- package/dist/components/form/PhoneInput/constants.js +73 -0
- package/dist/components/form/PhoneInput/externalPhoneLogic.d.ts +7 -0
- package/dist/components/form/PhoneInput/externalPhoneLogic.js +38 -0
- package/dist/components/form/PhoneInput/hooks/useValidateInitialValue.d.ts +4 -0
- package/dist/components/form/PhoneInput/hooks/useValidateInitialValue.js +41 -0
- package/dist/components/form/PhoneInput/index.d.ts +21 -0
- package/dist/components/form/PhoneInput/index.js +175 -0
- package/dist/components/form/PhoneInput/index.stories.d.ts +7 -0
- package/dist/components/form/PhoneInput/index.stories.js +114 -0
- package/dist/components/form/PhoneInput/phoneInputLogic.d.ts +30 -0
- package/dist/components/form/PhoneInput/phoneInputLogic.js +140 -0
- package/dist/components/form/PhoneInput/styles.d.ts +4 -0
- package/dist/components/form/PhoneInput/styles.js +20 -0
- package/dist/components/form/PhoneInput/types.d.ts +18 -0
- package/dist/components/form/PhoneInput/types.js +9 -0
- package/dist/components/form/PositiveIntegerInput/hooks/useFilters.d.ts +6 -0
- package/dist/components/form/PositiveIntegerInput/hooks/useFilters.js +21 -0
- package/dist/components/form/PositiveIntegerInput/hooks/useIncrement.d.ts +4 -0
- package/dist/components/form/PositiveIntegerInput/hooks/useIncrement.js +22 -0
- package/dist/components/form/PositiveIntegerInput/hooks/useIncrementDisabledFlags.d.ts +9 -0
- package/dist/components/form/PositiveIntegerInput/hooks/useIncrementDisabledFlags.js +24 -0
- package/dist/components/form/PositiveIntegerInput/hooks/useNormalizers.d.ts +4 -0
- package/dist/components/form/PositiveIntegerInput/hooks/useNormalizers.js +22 -0
- package/dist/components/form/PositiveIntegerInput/index.d.ts +10 -0
- package/dist/components/form/PositiveIntegerInput/index.js +94 -0
- package/dist/components/form/PositiveIntegerInput/index.stories.d.ts +5 -0
- package/dist/components/form/PositiveIntegerInput/index.stories.js +49 -0
- package/dist/components/form/PositiveIntegerInput/styles.d.ts +6 -0
- package/dist/components/form/PositiveIntegerInput/styles.js +25 -0
- package/dist/components/form/PureInput/index.d.ts +17 -0
- package/dist/{stories/Button.js → components/form/PureInput/index.js} +29 -32
- package/dist/components/form/PureInput/index.stories.d.ts +5 -0
- package/dist/components/form/PureInput/index.stories.js +23 -0
- package/dist/components/form/PureInput/palette.d.ts +10 -0
- package/dist/components/form/PureInput/palette.js +18 -0
- package/dist/components/form/PureInput/styles.d.ts +10 -0
- package/dist/components/form/PureInput/styles.js +34 -0
- package/dist/components/form/SearchInput/components/CrossIcon/index.d.ts +1 -0
- package/dist/components/form/SearchInput/components/CrossIcon/index.js +23 -0
- package/dist/components/form/SearchInput/components/CrossIcon/index.stories.d.ts +5 -0
- package/dist/components/form/SearchInput/components/CrossIcon/index.stories.js +14 -0
- package/dist/components/form/SearchInput/components/SearchIcon/index.d.ts +1 -0
- package/dist/components/form/SearchInput/components/SearchIcon/index.js +24 -0
- package/dist/components/form/SearchInput/components/SearchIcon/index.stories.d.ts +5 -0
- package/dist/components/form/SearchInput/components/SearchIcon/index.stories.js +14 -0
- package/dist/components/form/SearchInput/index.d.ts +7 -0
- package/dist/components/form/SearchInput/index.js +50 -0
- package/dist/components/form/SearchInput/index.stories.d.ts +5 -0
- package/dist/components/form/SearchInput/index.stories.js +38 -0
- package/dist/components/form/SearchInput/palette.d.ts +5 -0
- package/dist/components/form/SearchInput/palette.js +11 -0
- package/dist/components/form/SearchInput/styles.d.ts +7 -0
- package/dist/components/form/SearchInput/styles.js +25 -0
- package/dist/components/form/Select/components/Input/index.d.ts +6 -0
- package/dist/components/form/Select/components/Input/index.js +42 -0
- package/dist/components/form/Select/components/Input/index.stories.d.ts +5 -0
- package/dist/components/form/Select/components/Input/index.stories.js +27 -0
- package/dist/components/form/Select/components/Input/styles.d.ts +3 -0
- package/dist/components/form/Select/components/Input/styles.js +16 -0
- package/dist/components/form/Select/hooks/useOptionGroups.d.ts +5 -0
- package/dist/components/form/Select/hooks/useOptionGroups.js +33 -0
- package/dist/components/form/Select/index.d.ts +17 -0
- package/dist/components/form/Select/index.js +138 -0
- package/dist/components/form/Select/index.stories.d.ts +5 -0
- package/dist/components/form/Select/index.stories.js +96 -0
- package/dist/components/form/Select/palette.d.ts +5 -0
- package/dist/components/form/Select/palette.js +13 -0
- package/dist/components/form/Select/styles.d.ts +10 -0
- package/dist/components/form/Select/styles.js +37 -0
- package/dist/hooks/useCss/index.d.ts +6 -0
- package/dist/hooks/useCss/index.js +31 -0
- package/dist/hooks/useCss/index.stories.d.ts +4 -0
- package/dist/hooks/useCss/index.stories.js +38 -0
- package/dist/hooks/useInputFocus/index.d.ts +11 -0
- package/dist/hooks/useInputFocus/index.js +37 -0
- package/dist/hooks/useInputFocus/index.stories.d.ts +4 -0
- package/dist/hooks/useInputFocus/index.stories.js +29 -0
- package/dist/hooks/useOutsideClick/index.d.ts +2 -0
- package/dist/hooks/useOutsideClick/index.js +22 -0
- package/dist/hooks/useOutsideClick/index.stories.d.ts +4 -0
- package/dist/hooks/useOutsideClick/index.stories.js +27 -0
- package/dist/hooks/useUnupdatableHandler/index.d.ts +1 -0
- package/dist/hooks/useUnupdatableHandler/index.js +16 -0
- package/dist/hooks/useUnupdatableHandler/index.stories.d.ts +4 -0
- package/dist/hooks/useUnupdatableHandler/index.stories.js +45 -0
- package/dist/index.d.ts +37 -1
- package/dist/index.js +171 -3
- package/dist/palette/colors.stories.d.ts +4 -0
- package/dist/palette/colors.stories.js +41 -0
- package/dist/palette/constants.d.ts +2 -0
- package/dist/palette/constants.js +18 -0
- package/dist/palette/context.d.ts +35 -0
- package/dist/palette/context.js +40 -0
- package/dist/palette/index.d.ts +3 -0
- package/dist/palette/index.js +19 -0
- package/dist/palette/index.stories.d.ts +4 -0
- package/dist/palette/index.stories.js +83 -0
- package/dist/palette/provider.d.ts +10 -0
- package/dist/palette/provider.js +65 -0
- package/dist/palette/types.d.ts +12 -0
- package/dist/palette/types.js +1 -0
- package/dist/palette/useComponentPalette.d.ts +2 -0
- package/dist/palette/useComponentPalette.js +22 -0
- package/dist/palette/usePalette.d.ts +17 -0
- package/dist/palette/usePalette.js +11 -0
- package/package.json +17 -6
- package/dist/stories/Button.d.ts +0 -26
- package/dist/stories/Button.stories.d.ts +0 -21
- package/dist/stories/Button.stories.js +0 -49
- package/dist/stories/styles.d.ts +0 -23
- package/dist/stories/styles.js +0 -32
|
@@ -0,0 +1,175 @@
|
|
|
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 inputRef = (0, _react.useRef)();
|
|
41
|
+
var countrySelectOptions = (0, _react.useMemo)(function () {
|
|
42
|
+
return _phoneInputLogic.phoneInputLogic.getCountriesSelectOptions(countries);
|
|
43
|
+
}, [countries]);
|
|
44
|
+
var isHaveSelectCountries = (0, _react.useMemo)(function () {
|
|
45
|
+
return _phoneInputLogic.phoneInputLogic.getIsHaveCountriesSelectOptions(countrySelectOptions);
|
|
46
|
+
}, [countrySelectOptions]);
|
|
47
|
+
var currentCountriesPhoneRules = (0, _react.useMemo)(function () {
|
|
48
|
+
return _phoneInputLogic.phoneInputLogic.getCountriesPhoneRulesBySelectOptions(countrySelectOptions);
|
|
49
|
+
}, [countrySelectOptions]);
|
|
50
|
+
var _useInputFocus = (0, _useInputFocus2.useInputFocus)({
|
|
51
|
+
onFocus: onFocus,
|
|
52
|
+
onBlur: onBlur
|
|
53
|
+
}),
|
|
54
|
+
inFocus = _useInputFocus.inFocus,
|
|
55
|
+
focusHandler = _useInputFocus.handleFocus,
|
|
56
|
+
blurHandler = _useInputFocus.handleBlur;
|
|
57
|
+
var _useState = (0, _react.useState)(false),
|
|
58
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
59
|
+
isHaveInputError = _useState2[0],
|
|
60
|
+
setIsHaveInputError = _useState2[1];
|
|
61
|
+
var _useState3 = (0, _react.useState)(true),
|
|
62
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
63
|
+
isFirstBlur = _useState4[0],
|
|
64
|
+
setIsFirstBlur = _useState4[1];
|
|
65
|
+
var _useState5 = (0, _react.useState)(value),
|
|
66
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
67
|
+
inputValue = _useState6[0],
|
|
68
|
+
setInputValue = _useState6[1];
|
|
69
|
+
var _useState7 = (0, _react.useState)(_types.RUS_COUNTRY_CODE),
|
|
70
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
71
|
+
country = _useState8[0],
|
|
72
|
+
setCountry = _useState8[1];
|
|
73
|
+
var handleChangeCountry = (0, _react.useCallback)(function (countryCode) {
|
|
74
|
+
setCountry(countryCode);
|
|
75
|
+
if (onCountryChange) {
|
|
76
|
+
onCountryChange(countryCode);
|
|
77
|
+
}
|
|
78
|
+
}, [onCountryChange]);
|
|
79
|
+
var handleInitialValid = (0, _react.useCallback)(function (currentInputValue, countryCode) {
|
|
80
|
+
onChange(currentInputValue);
|
|
81
|
+
setIsHaveInputError(false);
|
|
82
|
+
setCountry(countryCode);
|
|
83
|
+
}, [onChange]);
|
|
84
|
+
var handleInitialUnValid = (0, _react.useCallback)(function (countryCode) {
|
|
85
|
+
onChange('');
|
|
86
|
+
setIsHaveInputError(true);
|
|
87
|
+
setCountry(countryCode);
|
|
88
|
+
}, [onChange]);
|
|
89
|
+
(0, _useValidateInitialValue.useValidateInitialValue)(value, currentCountriesPhoneRules, handleInitialValid, handleInitialUnValid);
|
|
90
|
+
var getNewCountryByInputValue = (0, _react.useCallback)(function (currentValue) {
|
|
91
|
+
var currentCountry = currentCountriesPhoneRules[country];
|
|
92
|
+
var newCountry = Object.entries(currentCountriesPhoneRules).find(function (item) {
|
|
93
|
+
return _phoneInputLogic.phoneInputLogic.getIsHaveStartSequenceInString(currentValue, item[1].startSubsequence) && currentCountry.flag !== item[1].flag;
|
|
94
|
+
});
|
|
95
|
+
var isNeedChangeCountry = _phoneInputLogic.phoneInputLogic.getIsNeedChangeCountry(currentValue, currentCountry, newCountry);
|
|
96
|
+
var isNeedAndCanChangeCountry = isNeedChangeCountry && !!newCountry;
|
|
97
|
+
if (isNeedAndCanChangeCountry) {
|
|
98
|
+
handleChangeCountry(newCountry[0]);
|
|
99
|
+
}
|
|
100
|
+
return isNeedAndCanChangeCountry ? newCountry[1] : currentCountry;
|
|
101
|
+
}, [country, currentCountriesPhoneRules, handleChangeCountry]);
|
|
102
|
+
var getIsValidValue = (0, _react.useCallback)(function (currentValue) {
|
|
103
|
+
var currentCountry = getNewCountryByInputValue(currentValue);
|
|
104
|
+
return _phoneInputLogic.phoneInputLogic.getIsValidPhoneInputByCountry(currentValue, currentCountry);
|
|
105
|
+
}, [getNewCountryByInputValue]);
|
|
106
|
+
var handleInputValueChange = (0, _react.useCallback)(function (currentInputValue, event) {
|
|
107
|
+
var notFormattedValue = _phoneInputLogic.phoneInputLogic.getOnlyNumbersFromString(currentInputValue);
|
|
108
|
+
var moveCaret = event ? _phoneInputLogic.phoneInputLogic.moveCaretByValue(event) : undefined;
|
|
109
|
+
var intermediateValue = country === _types.RUS_COUNTRY_CODE ? _phoneInputLogic.phoneInputLogic.formatRusPhoneToUnifiedView(notFormattedValue, moveCaret) : notFormattedValue;
|
|
110
|
+
var isValidInputValue = getIsValidValue(intermediateValue);
|
|
111
|
+
setIsHaveInputError(!isValidInputValue);
|
|
112
|
+
onChange(isValidInputValue ? intermediateValue : '');
|
|
113
|
+
setInputValue(intermediateValue);
|
|
114
|
+
}, [country, getIsValidValue, onChange]);
|
|
115
|
+
var handleChange = (0, _react.useCallback)(function (event) {
|
|
116
|
+
handleInputValueChange(event.target.value, event);
|
|
117
|
+
}, [handleInputValueChange]);
|
|
118
|
+
var handleBlur = (0, _react.useCallback)(function (event) {
|
|
119
|
+
blurHandler(event);
|
|
120
|
+
if (isFirstBlur) {
|
|
121
|
+
setIsFirstBlur(false);
|
|
122
|
+
}
|
|
123
|
+
}, [isFirstBlur, blurHandler]);
|
|
124
|
+
var handleCountryChange = (0, _react.useCallback)(function (countryValue) {
|
|
125
|
+
handleChangeCountry(countryValue);
|
|
126
|
+
var currentCountry = currentCountriesPhoneRules[countryValue];
|
|
127
|
+
var isValidInputValue = _phoneInputLogic.phoneInputLogic.getIsValidPhoneInputByCountry(inputValue, currentCountry);
|
|
128
|
+
setIsFirstBlur(false);
|
|
129
|
+
setIsHaveInputError(!isValidInputValue);
|
|
130
|
+
onChange(isValidInputValue ? inputValue : '');
|
|
131
|
+
setTimeout(function () {
|
|
132
|
+
var _inputRef$current;
|
|
133
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
|
|
134
|
+
}, 0);
|
|
135
|
+
}, [currentCountriesPhoneRules, handleChangeCountry, inputValue, onChange]);
|
|
136
|
+
var handlePaste = (0, _react.useCallback)(function (event) {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
var pasteText = event.clipboardData.getData('Text').trim();
|
|
139
|
+
handleInputValueChange(pasteText);
|
|
140
|
+
}, [handleInputValueChange]);
|
|
141
|
+
return /*#__PURE__*/_react["default"].createElement(_InputLabel.InputLabel, {
|
|
142
|
+
inFocus: inFocus,
|
|
143
|
+
label: label,
|
|
144
|
+
disabled: disabled
|
|
145
|
+
}, /*#__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, {
|
|
146
|
+
minWidth: "350px",
|
|
147
|
+
options: countrySelectOptions,
|
|
148
|
+
onChange: handleCountryChange,
|
|
149
|
+
value: country,
|
|
150
|
+
placeholder: countrySelectProps.placeholder,
|
|
151
|
+
positionVertical: 16,
|
|
152
|
+
positionRight: "0",
|
|
153
|
+
positionLeft: "-20px",
|
|
154
|
+
disabled: disabled,
|
|
155
|
+
selectedLabel: countrySelectProps.selectedLabel
|
|
156
|
+
}))), /*#__PURE__*/_react["default"].createElement(_reactInputMask["default"], {
|
|
157
|
+
value: inputValue,
|
|
158
|
+
onFocus: focusHandler,
|
|
159
|
+
onBlur: handleBlur,
|
|
160
|
+
onChange: handleChange,
|
|
161
|
+
mask: currentCountriesPhoneRules[country].mask,
|
|
162
|
+
maskPlaceholder: null,
|
|
163
|
+
disabled: disabled,
|
|
164
|
+
onPaste: handlePaste,
|
|
165
|
+
placeholder: currentCountriesPhoneRules[country].placeholder,
|
|
166
|
+
ref: inputRef
|
|
167
|
+
}, /*#__PURE__*/_react["default"].createElement(_PureInput.PureInput, {
|
|
168
|
+
id: id,
|
|
169
|
+
hasError: hasError || (isFirstBlur ? false : isHaveInputError),
|
|
170
|
+
inFocus: inFocus,
|
|
171
|
+
name: name,
|
|
172
|
+
paddingLeft: isHaveSelectCountries ? 75 : 18,
|
|
173
|
+
autoComplete: 'off'
|
|
174
|
+
}))));
|
|
175
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
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 MultiCountryWithUnknown: StoryObj<TProps>;
|
|
7
|
+
export declare const DefaultRusCountry: StoryObj<TProps>;
|
|
@@ -0,0 +1,114 @@
|
|
|
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.MultiCountryWithUnknown = 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: 'KGZ'
|
|
80
|
+
}, {
|
|
81
|
+
label: 'Азербайджан',
|
|
82
|
+
value: 'AZE'
|
|
83
|
+
}, {
|
|
84
|
+
label: 'Такджикистан',
|
|
85
|
+
value: 'TJK'
|
|
86
|
+
}, {
|
|
87
|
+
label: 'Узбекистан',
|
|
88
|
+
value: 'UZB'
|
|
89
|
+
}]
|
|
90
|
+
}),
|
|
91
|
+
render: Component
|
|
92
|
+
};
|
|
93
|
+
var MultiCountryWithUnknown = exports.MultiCountryWithUnknown = {
|
|
94
|
+
args: _objectSpread(_objectSpread({}, commonProps), {}, {
|
|
95
|
+
countries: [{
|
|
96
|
+
label: 'Россия',
|
|
97
|
+
value: 'RUS'
|
|
98
|
+
}, {
|
|
99
|
+
label: 'Армения',
|
|
100
|
+
value: 'ARM'
|
|
101
|
+
}, {
|
|
102
|
+
label: 'Белорусь',
|
|
103
|
+
value: 'BLR'
|
|
104
|
+
}, {
|
|
105
|
+
label: 'Другая',
|
|
106
|
+
value: 'UNKNOWN'
|
|
107
|
+
}]
|
|
108
|
+
}),
|
|
109
|
+
render: Component
|
|
110
|
+
};
|
|
111
|
+
var DefaultRusCountry = exports.DefaultRusCountry = {
|
|
112
|
+
args: commonProps,
|
|
113
|
+
render: Component
|
|
114
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TCountryRule, TCountrySelectOption, TSupportedCountries } from './types';
|
|
2
|
+
import { ChangeEvent } from 'react';
|
|
3
|
+
declare class PhoneInputLogic {
|
|
4
|
+
private getCaretPositionByRusValue;
|
|
5
|
+
getIsValidPhoneInputByCountry(value: string, country: TCountryRule): boolean;
|
|
6
|
+
getSupportedCountriesByCountryNames(countries?: Array<TSupportedCountries>): ("RUS" | "BLR" | "KAZ" | "AZE" | "ARM" | "KGZ" | "TJK" | "UZB" | "UNKNOWN")[] | undefined;
|
|
7
|
+
getCountriesSelectOptions(countries?: Array<{
|
|
8
|
+
label: string;
|
|
9
|
+
value: TSupportedCountries;
|
|
10
|
+
}>): {
|
|
11
|
+
description: string;
|
|
12
|
+
flag: "RUS" | "BLR" | "KAZ" | "AZE" | "ARM" | "KGZ" | "MDA" | "TJK" | "UZB" | "CHN" | "ENG" | "ESP" | "UNKNOWN";
|
|
13
|
+
label: string;
|
|
14
|
+
value: TSupportedCountries;
|
|
15
|
+
}[] | undefined;
|
|
16
|
+
getIsHaveCountriesSelectOptions(countrySelectOptions?: Array<TCountrySelectOption | TSupportedCountries>): boolean;
|
|
17
|
+
getCountriesPhoneRulesBySelectOptions(countrySelectOptions?: Array<TCountrySelectOption>): {
|
|
18
|
+
[k: string]: TCountryRule;
|
|
19
|
+
};
|
|
20
|
+
getCountriesPhoneRulesByCountryNames(countrySelectOptions?: Array<TSupportedCountries>): {
|
|
21
|
+
[k: string]: TCountryRule;
|
|
22
|
+
};
|
|
23
|
+
getIsHaveStartSequenceInString(value: string, subsequence: string): boolean;
|
|
24
|
+
formatRusPhoneToUnifiedView(value: string, moveCaret?: (positionCaret: number) => void): string;
|
|
25
|
+
getOnlyNumbersFromString(value: string): string;
|
|
26
|
+
moveCaretByValue(event: ChangeEvent<HTMLInputElement>): (positionCaret: number) => void;
|
|
27
|
+
getIsNeedChangeCountry(inputValue: string, currentCountry: TCountryRule, newCountry?: [string, TCountryRule]): boolean | "" | undefined;
|
|
28
|
+
}
|
|
29
|
+
export declare const phoneInputLogic: PhoneInputLogic;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.phoneInputLogic = void 0;
|
|
7
|
+
var _types = require("./types");
|
|
8
|
+
var _constants = require("./constants");
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
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; }
|
|
12
|
+
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; }
|
|
13
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
14
|
+
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); } }
|
|
15
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
17
|
+
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); }
|
|
18
|
+
var PhoneInputLogic = /*#__PURE__*/function () {
|
|
19
|
+
function PhoneInputLogic() {
|
|
20
|
+
_classCallCheck(this, PhoneInputLogic);
|
|
21
|
+
}
|
|
22
|
+
_createClass(PhoneInputLogic, [{
|
|
23
|
+
key: "getCaretPositionByRusValue",
|
|
24
|
+
value: function getCaretPositionByRusValue(value) {
|
|
25
|
+
var mask = _constants.allCountriesPhoneRules.RUS.mask.split('');
|
|
26
|
+
var counter = 0;
|
|
27
|
+
var position = 0;
|
|
28
|
+
mask.forEach(function (maskItem, index) {
|
|
29
|
+
if (maskItem === _constants.MASK_DIGIT_ITEM) {
|
|
30
|
+
counter += 1;
|
|
31
|
+
if (counter === value.length) {
|
|
32
|
+
position = index + 1;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return position;
|
|
37
|
+
}
|
|
38
|
+
}, {
|
|
39
|
+
key: "getIsValidPhoneInputByCountry",
|
|
40
|
+
value: function getIsValidPhoneInputByCountry(value, country) {
|
|
41
|
+
return !!value.match(country.regexp);
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
key: "getSupportedCountriesByCountryNames",
|
|
45
|
+
value: function getSupportedCountriesByCountryNames(countries) {
|
|
46
|
+
return countries === null || countries === void 0 ? void 0 : countries.filter(function (country) {
|
|
47
|
+
return _constants.allCountriesPhoneRules[country];
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
key: "getCountriesSelectOptions",
|
|
52
|
+
value: function getCountriesSelectOptions(countries) {
|
|
53
|
+
var supportedCountries = countries === null || countries === void 0 ? void 0 : countries.filter(function (country) {
|
|
54
|
+
return _constants.allCountriesPhoneRules[country.value];
|
|
55
|
+
});
|
|
56
|
+
return supportedCountries === null || supportedCountries === void 0 ? void 0 : supportedCountries.map(function (country) {
|
|
57
|
+
var countryRules = _constants.allCountriesPhoneRules[country.value];
|
|
58
|
+
return _objectSpread(_objectSpread({}, country), {}, {
|
|
59
|
+
description: countryRules.startSubsequence ? "+".concat(countryRules.startSubsequence) : '',
|
|
60
|
+
flag: countryRules.flag
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "getIsHaveCountriesSelectOptions",
|
|
66
|
+
value: function getIsHaveCountriesSelectOptions(countrySelectOptions) {
|
|
67
|
+
return !!(countrySelectOptions !== null && countrySelectOptions !== void 0 && countrySelectOptions.length);
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "getCountriesPhoneRulesBySelectOptions",
|
|
71
|
+
value: function getCountriesPhoneRulesBySelectOptions(countrySelectOptions) {
|
|
72
|
+
return this.getIsHaveCountriesSelectOptions(countrySelectOptions) ? Object.fromEntries(Object.entries(_constants.allCountriesPhoneRules).filter(function (ruleItem) {
|
|
73
|
+
return countrySelectOptions === null || countrySelectOptions === void 0 ? void 0 : countrySelectOptions.find(function (countrySelectOption) {
|
|
74
|
+
return countrySelectOption.value === ruleItem[0];
|
|
75
|
+
});
|
|
76
|
+
})) : {
|
|
77
|
+
RUS: _constants.allCountriesPhoneRules.RUS
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "getCountriesPhoneRulesByCountryNames",
|
|
82
|
+
value: function getCountriesPhoneRulesByCountryNames(countrySelectOptions) {
|
|
83
|
+
return this.getIsHaveCountriesSelectOptions(countrySelectOptions) ? Object.fromEntries(Object.entries(_constants.allCountriesPhoneRules).filter(function (ruleItem) {
|
|
84
|
+
return countrySelectOptions === null || countrySelectOptions === void 0 ? void 0 : countrySelectOptions.find(function (countrySelectOption) {
|
|
85
|
+
return countrySelectOption === ruleItem[0];
|
|
86
|
+
});
|
|
87
|
+
})) : {
|
|
88
|
+
RUS: _constants.allCountriesPhoneRules.RUS
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "getIsHaveStartSequenceInString",
|
|
93
|
+
value: function getIsHaveStartSequenceInString(value, subsequence) {
|
|
94
|
+
return value.startsWith(subsequence);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// '8' => '+7', '9' => '+79'
|
|
98
|
+
}, {
|
|
99
|
+
key: "formatRusPhoneToUnifiedView",
|
|
100
|
+
value: function formatRusPhoneToUnifiedView(value, moveCaret) {
|
|
101
|
+
var result = value;
|
|
102
|
+
if (value[0] === '8') {
|
|
103
|
+
result = "7".concat(value.slice(1));
|
|
104
|
+
}
|
|
105
|
+
if (value[0] === '9') {
|
|
106
|
+
var newValue = "79".concat(value.slice(1));
|
|
107
|
+
result = newValue;
|
|
108
|
+
if (moveCaret) {
|
|
109
|
+
// когда пользователь вводит номер с "9", мы подставляем в инпут "79", но каретка не переносится после "9", нужно это делать вручную
|
|
110
|
+
moveCaret(this.getCaretPositionByRusValue(newValue));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
}, {
|
|
116
|
+
key: "getOnlyNumbersFromString",
|
|
117
|
+
value: function getOnlyNumbersFromString(value) {
|
|
118
|
+
var _value$match;
|
|
119
|
+
return ((_value$match = value.match(/\d/g)) === null || _value$match === void 0 ? void 0 : _value$match.join('')) || '';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// хак для того чтобы сдвигать каретку в случае если при вводе "9" надо заменить на "79", каретка не двигается сама и остаётся между "7" и "9" без этой функции
|
|
123
|
+
}, {
|
|
124
|
+
key: "moveCaretByValue",
|
|
125
|
+
value: function moveCaretByValue(event) {
|
|
126
|
+
return function (positionCaret) {
|
|
127
|
+
setTimeout(function () {
|
|
128
|
+
event.target.setSelectionRange(positionCaret, positionCaret);
|
|
129
|
+
}, 0);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "getIsNeedChangeCountry",
|
|
134
|
+
value: function getIsNeedChangeCountry(inputValue, currentCountry, newCountry) {
|
|
135
|
+
return newCountry && currentCountry.startSubsequence !== newCountry[1].startSubsequence && inputValue && (newCountry[0] === _types.UNKNOWN_COUNTRY_CODE ? !this.getIsHaveStartSequenceInString(inputValue, currentCountry.startSubsequence) : true);
|
|
136
|
+
}
|
|
137
|
+
}]);
|
|
138
|
+
return PhoneInputLogic;
|
|
139
|
+
}();
|
|
140
|
+
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,18 @@
|
|
|
1
|
+
import { TFlagKey } from '../../common/Flag';
|
|
2
|
+
export declare const RUS_COUNTRY_CODE = "RUS";
|
|
3
|
+
export declare const UNKNOWN_COUNTRY_CODE = "UNKNOWN";
|
|
4
|
+
export declare const supportedCountries: readonly ["RUS", "BLR", "AZE", "ARM", "KAZ", "TJK", "UZB", "KGZ", "UNKNOWN"];
|
|
5
|
+
export type TSupportedCountries = (typeof supportedCountries)[number];
|
|
6
|
+
export type TCountryRule = {
|
|
7
|
+
placeholder: string;
|
|
8
|
+
mask: string;
|
|
9
|
+
startSubsequence: string;
|
|
10
|
+
regexp: RegExp;
|
|
11
|
+
flag: TFlagKey;
|
|
12
|
+
};
|
|
13
|
+
export type TCountrySelectOption = {
|
|
14
|
+
description: string;
|
|
15
|
+
flag: string;
|
|
16
|
+
label: string;
|
|
17
|
+
value: string;
|
|
18
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.supportedCountries = exports.UNKNOWN_COUNTRY_CODE = exports.RUS_COUNTRY_CODE = void 0;
|
|
7
|
+
var RUS_COUNTRY_CODE = exports.RUS_COUNTRY_CODE = 'RUS';
|
|
8
|
+
var UNKNOWN_COUNTRY_CODE = exports.UNKNOWN_COUNTRY_CODE = 'UNKNOWN';
|
|
9
|
+
var supportedCountries = exports.supportedCountries = [RUS_COUNTRY_CODE, 'BLR', 'AZE', 'ARM', 'KAZ', 'TJK', 'UZB', 'KGZ', UNKNOWN_COUNTRY_CODE];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useFilters = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var useFilters = exports.useFilters = function useFilters(_ref) {
|
|
9
|
+
var max = _ref.max;
|
|
10
|
+
var filterOnlyNumbers = (0, _react.useCallback)(function (value) {
|
|
11
|
+
return value.replace(/[^0-9]/g, '');
|
|
12
|
+
}, []);
|
|
13
|
+
var filterMax = (0, _react.useCallback)(function (value) {
|
|
14
|
+
if (!value) return '';
|
|
15
|
+
return Number(value) > max ? String(max) : value;
|
|
16
|
+
}, [max]);
|
|
17
|
+
var filters = (0, _react.useMemo)(function () {
|
|
18
|
+
return [filterOnlyNumbers, filterMax];
|
|
19
|
+
}, [filterOnlyNumbers, filterMax]);
|
|
20
|
+
return filters;
|
|
21
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useIncrement = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var useIncrement = exports.useIncrement = function useIncrement() {
|
|
9
|
+
var increment = (0, _react.useCallback)(function (v) {
|
|
10
|
+
return v === null ? 1 : v + 1;
|
|
11
|
+
}, []);
|
|
12
|
+
var decrement = (0, _react.useCallback)(function (v) {
|
|
13
|
+
return v === null || v === 0 ? 0 : v - 1;
|
|
14
|
+
}, []);
|
|
15
|
+
var incrementers = (0, _react.useMemo)(function () {
|
|
16
|
+
return {
|
|
17
|
+
increment: increment,
|
|
18
|
+
decrement: decrement
|
|
19
|
+
};
|
|
20
|
+
}, [increment, decrement]);
|
|
21
|
+
return incrementers;
|
|
22
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useIncrementDisabledFlags = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var useIncrementDisabledFlags = exports.useIncrementDisabledFlags = function useIncrementDisabledFlags(_ref) {
|
|
9
|
+
var max = _ref.max,
|
|
10
|
+
value = _ref.value;
|
|
11
|
+
var isIncrementDisabled = (0, _react.useMemo)(function () {
|
|
12
|
+
return value === max;
|
|
13
|
+
}, [max, value]);
|
|
14
|
+
var isDecrementDisabled = (0, _react.useMemo)(function () {
|
|
15
|
+
return value === 0;
|
|
16
|
+
}, [value]);
|
|
17
|
+
var incrementDisabledFlags = (0, _react.useMemo)(function () {
|
|
18
|
+
return {
|
|
19
|
+
isIncrementDisabled: isIncrementDisabled,
|
|
20
|
+
isDecrementDisabled: isDecrementDisabled
|
|
21
|
+
};
|
|
22
|
+
}, [isIncrementDisabled, isDecrementDisabled]);
|
|
23
|
+
return incrementDisabledFlags;
|
|
24
|
+
};
|