@invoicebox/ui 0.1.0-alpha.7 → 0.1.0-alpha.71
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 +15 -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 +12 -0
- package/dist/components/common/Flag/index.js +51 -0
- package/dist/components/common/Flag/index.stories.d.ts +6 -0
- package/dist/components/common/Flag/index.stories.js +23 -0
- package/dist/components/common/Flag/styles.d.ts +5 -0
- package/dist/components/common/Flag/styles.js +18 -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 +42 -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 +123 -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/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 +179 -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 +31 -0
- package/dist/components/form/PhoneInput/phoneInputLogic.js +117 -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 +17 -0
- package/dist/components/form/PhoneInput/types.js +8 -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/components/form/PureInput/index.js +43 -0
- 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/index.d.ts +36 -1
- package/dist/index.js +164 -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 +18 -6
- package/dist/stories/Button.d.ts +0 -26
- package/dist/stories/Button.js +0 -43
- package/dist/stories/Button.stories.d.ts +0 -21
- package/dist/stories/Button.stories.js +0 -49
- package/dist/stories/styles.d.ts +0 -30
- package/dist/stories/styles.js +0 -36
|
@@ -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,31 @@
|
|
|
1
|
+
import { TCountryRule, TCountrySelectOption, TSupportedCountries } from './types';
|
|
2
|
+
declare class PhoneInputLogic {
|
|
3
|
+
private getCaretPositionByRusValue;
|
|
4
|
+
getIsValidPhoneInputByCountry(value: string, country: TCountryRule): boolean;
|
|
5
|
+
getIsValidPhone(value: string, countries?: Array<{
|
|
6
|
+
label: string;
|
|
7
|
+
value: TSupportedCountries;
|
|
8
|
+
}>): boolean;
|
|
9
|
+
getCountriesSelectOptions(countries?: Array<{
|
|
10
|
+
label: string;
|
|
11
|
+
value: TSupportedCountries;
|
|
12
|
+
}>): {
|
|
13
|
+
description: string;
|
|
14
|
+
flag: "RUS" | "BLR" | "KAZ" | "AZE" | "ARM" | "KGZ" | "MDA" | "TJK" | "UZB" | "CHN" | "ENG" | "ESP" | "UNKNOWN";
|
|
15
|
+
label: string;
|
|
16
|
+
value: TSupportedCountries;
|
|
17
|
+
}[] | undefined;
|
|
18
|
+
getIsHaveCountriesSelectOptions(countrySelectOptions?: Array<TCountrySelectOption>): boolean;
|
|
19
|
+
getCountriesPhoneRules(countrySelectOptions?: Array<TCountrySelectOption>): {
|
|
20
|
+
[k: string]: TCountryRule;
|
|
21
|
+
};
|
|
22
|
+
getIsHaveStartSequenceInString(value: string, subsequence: string): boolean;
|
|
23
|
+
formatRusPhoneToUnifiedView(value: string, moveCaret?: (positionCaret: number) => void): string;
|
|
24
|
+
getOnlyNumbersFromString(value: string): string;
|
|
25
|
+
}
|
|
26
|
+
export declare const phoneInputLogic: PhoneInputLogic;
|
|
27
|
+
export declare const getIsValidPhone: (value: string, countries?: {
|
|
28
|
+
label: string;
|
|
29
|
+
value: TSupportedCountries;
|
|
30
|
+
}[] | undefined) => boolean;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.phoneInputLogic = exports.getIsValidPhone = 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: "getCaretPositionByRusValue",
|
|
23
|
+
value: function getCaretPositionByRusValue(value) {
|
|
24
|
+
var mask = _constants.allCountriesPhoneRules.RUS.mask.split('');
|
|
25
|
+
var counter = 0;
|
|
26
|
+
var position = 0;
|
|
27
|
+
mask.forEach(function (maskItem, index) {
|
|
28
|
+
if (maskItem === _constants.MASK_DIGIT_ITEM) {
|
|
29
|
+
counter += 1;
|
|
30
|
+
if (counter === value.length) {
|
|
31
|
+
position = index + 1;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return position;
|
|
36
|
+
}
|
|
37
|
+
}, {
|
|
38
|
+
key: "getIsValidPhoneInputByCountry",
|
|
39
|
+
value: function getIsValidPhoneInputByCountry(value, country) {
|
|
40
|
+
return !!value.match(country.regexp);
|
|
41
|
+
}
|
|
42
|
+
}, {
|
|
43
|
+
key: "getIsValidPhone",
|
|
44
|
+
value: function getIsValidPhone(value, countries) {
|
|
45
|
+
var notFormattedValue = this.getOnlyNumbersFromString(value);
|
|
46
|
+
var countrySelectOptions = this.getCountriesSelectOptions(countries);
|
|
47
|
+
var currentCountriesPhoneRules = this.getCountriesPhoneRules(countrySelectOptions);
|
|
48
|
+
var country = Object.entries(currentCountriesPhoneRules).find(function (item) {
|
|
49
|
+
return phoneInputLogic.getIsHaveStartSequenceInString(notFormattedValue, item[1].startSubsequence);
|
|
50
|
+
});
|
|
51
|
+
return this.getIsValidPhoneInputByCountry(notFormattedValue, country ? country[1] : _constants.allCountriesPhoneRules.RUS);
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
key: "getCountriesSelectOptions",
|
|
55
|
+
value: function getCountriesSelectOptions(countries) {
|
|
56
|
+
var supportedCountries = countries === null || countries === void 0 ? void 0 : countries.filter(function (country) {
|
|
57
|
+
return _constants.allCountriesPhoneRules[country.value];
|
|
58
|
+
});
|
|
59
|
+
return supportedCountries === null || supportedCountries === void 0 ? void 0 : supportedCountries.map(function (country) {
|
|
60
|
+
var countryRules = _constants.allCountriesPhoneRules[country.value];
|
|
61
|
+
return _objectSpread(_objectSpread({}, country), {}, {
|
|
62
|
+
description: countryRules.startSubsequence ? "+".concat(countryRules.startSubsequence) : '',
|
|
63
|
+
flag: countryRules.flag
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
key: "getIsHaveCountriesSelectOptions",
|
|
69
|
+
value: function getIsHaveCountriesSelectOptions(countrySelectOptions) {
|
|
70
|
+
return !!(countrySelectOptions !== null && countrySelectOptions !== void 0 && countrySelectOptions.length);
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
73
|
+
key: "getCountriesPhoneRules",
|
|
74
|
+
value: function getCountriesPhoneRules(countrySelectOptions) {
|
|
75
|
+
return this.getIsHaveCountriesSelectOptions(countrySelectOptions) ? Object.fromEntries(Object.entries(_constants.allCountriesPhoneRules).filter(function (ruleItem) {
|
|
76
|
+
return countrySelectOptions === null || countrySelectOptions === void 0 ? void 0 : countrySelectOptions.find(function (countrySelectOption) {
|
|
77
|
+
return countrySelectOption.value === ruleItem[0];
|
|
78
|
+
});
|
|
79
|
+
})) : {
|
|
80
|
+
RUS: _constants.allCountriesPhoneRules.RUS
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
key: "getIsHaveStartSequenceInString",
|
|
85
|
+
value: function getIsHaveStartSequenceInString(value, subsequence) {
|
|
86
|
+
return value.startsWith(subsequence);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// '8' => '+7', '9' => '+79'
|
|
90
|
+
}, {
|
|
91
|
+
key: "formatRusPhoneToUnifiedView",
|
|
92
|
+
value: function formatRusPhoneToUnifiedView(value, moveCaret) {
|
|
93
|
+
var result = value;
|
|
94
|
+
if (value[0] === '8') {
|
|
95
|
+
result = "7".concat(value.slice(1));
|
|
96
|
+
}
|
|
97
|
+
if (value[0] === '9') {
|
|
98
|
+
var newValue = "79".concat(value.slice(1));
|
|
99
|
+
result = newValue;
|
|
100
|
+
if (moveCaret) {
|
|
101
|
+
// когда пользователь вводит номер с "9", мы подставляем в инпут "79", но каретка не переносится после "9", нужно это делать вручную
|
|
102
|
+
moveCaret(this.getCaretPositionByRusValue(newValue));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
}, {
|
|
108
|
+
key: "getOnlyNumbersFromString",
|
|
109
|
+
value: function getOnlyNumbersFromString(value) {
|
|
110
|
+
var _value$match;
|
|
111
|
+
return ((_value$match = value.match(/\d/g)) === null || _value$match === void 0 ? void 0 : _value$match.join('')) || '';
|
|
112
|
+
}
|
|
113
|
+
}]);
|
|
114
|
+
return PhoneInputLogic;
|
|
115
|
+
}();
|
|
116
|
+
var phoneInputLogic = exports.phoneInputLogic = new PhoneInputLogic();
|
|
117
|
+
var getIsValidPhone = exports.getIsValidPhone = phoneInputLogic.getIsValidPhone;
|
|
@@ -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,17 @@
|
|
|
1
|
+
import { TFlagKey } from '../../common/Flag';
|
|
2
|
+
export declare const RUS_COUNTRY_CODE = "RUS";
|
|
3
|
+
export declare const supportedCountries: readonly ["RUS", "BLR", "AZE", "ARM", "KAZ", "TJK", "UZB", "KGZ", "UNKNOWN"];
|
|
4
|
+
export type TSupportedCountries = (typeof supportedCountries)[number];
|
|
5
|
+
export type TCountryRule = {
|
|
6
|
+
placeholder: string;
|
|
7
|
+
mask: string;
|
|
8
|
+
startSubsequence: string;
|
|
9
|
+
regexp: RegExp;
|
|
10
|
+
flag: TFlagKey;
|
|
11
|
+
};
|
|
12
|
+
export type TCountrySelectOption = {
|
|
13
|
+
description: string;
|
|
14
|
+
flag: string;
|
|
15
|
+
label: string;
|
|
16
|
+
value: string;
|
|
17
|
+
};
|
|
@@ -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', 'KGZ', 'UNKNOWN'];
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useNormalizers = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var useNormalizers = exports.useNormalizers = function useNormalizers() {
|
|
9
|
+
var normalizeTo = (0, _react.useCallback)(function (v) {
|
|
10
|
+
return !v ? null : Number(v);
|
|
11
|
+
}, []);
|
|
12
|
+
var normalizeFrom = (0, _react.useCallback)(function (v) {
|
|
13
|
+
return v !== null ? String(v) : '';
|
|
14
|
+
}, []);
|
|
15
|
+
var normalizers = (0, _react.useMemo)(function () {
|
|
16
|
+
return {
|
|
17
|
+
normalizeTo: normalizeTo,
|
|
18
|
+
normalizeFrom: normalizeFrom
|
|
19
|
+
};
|
|
20
|
+
}, [normalizeTo, normalizeFrom]);
|
|
21
|
+
return normalizers;
|
|
22
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { TProps as TInputLabelProps } from '../InputLabel';
|
|
3
|
+
import { TProps as TPureInputProps } from '../PureInput';
|
|
4
|
+
export type TProps = {
|
|
5
|
+
value: number | null;
|
|
6
|
+
onChange: (value: number | null) => void;
|
|
7
|
+
max?: number;
|
|
8
|
+
upAndDown?: boolean;
|
|
9
|
+
} & Pick<TInputLabelProps, 'label'> & Pick<TPureInputProps, 'placeholder' | 'hasError' | 'onFocus' | 'onBlur' | 'disabled' | 'name'>;
|
|
10
|
+
export declare const PositiveIntegerInput: FC<TProps>;
|
|
@@ -0,0 +1,94 @@
|
|
|
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.PositiveIntegerInput = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var S = _interopRequireWildcard(require("./styles"));
|
|
10
|
+
var _useInputFocus2 = require("../../../hooks/useInputFocus");
|
|
11
|
+
var _InputLabel = require("../InputLabel");
|
|
12
|
+
var _PureInput = require("../PureInput");
|
|
13
|
+
var _Arrow = require("../../common/Arrow");
|
|
14
|
+
var _useFilters = require("./hooks/useFilters");
|
|
15
|
+
var _useNormalizers2 = require("./hooks/useNormalizers");
|
|
16
|
+
var _useIncrement2 = require("./hooks/useIncrement");
|
|
17
|
+
var _useIncrementDisabledFlags = require("./hooks/useIncrementDisabledFlags");
|
|
18
|
+
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); }
|
|
19
|
+
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; }
|
|
20
|
+
var PositiveIntegerInput = exports.PositiveIntegerInput = function PositiveIntegerInput(_ref) {
|
|
21
|
+
var value = _ref.value,
|
|
22
|
+
onChange = _ref.onChange,
|
|
23
|
+
_ref$max = _ref.max,
|
|
24
|
+
max = _ref$max === void 0 ? Infinity : _ref$max,
|
|
25
|
+
_ref$upAndDown = _ref.upAndDown,
|
|
26
|
+
upAndDown = _ref$upAndDown === void 0 ? false : _ref$upAndDown,
|
|
27
|
+
label = _ref.label,
|
|
28
|
+
placeholder = _ref.placeholder,
|
|
29
|
+
hasError = _ref.hasError,
|
|
30
|
+
onFocus = _ref.onFocus,
|
|
31
|
+
onBlur = _ref.onBlur,
|
|
32
|
+
name = _ref.name;
|
|
33
|
+
var _useInputFocus = (0, _useInputFocus2.useInputFocus)({
|
|
34
|
+
onFocus: onFocus,
|
|
35
|
+
onBlur: onBlur
|
|
36
|
+
}),
|
|
37
|
+
inFocus = _useInputFocus.inFocus,
|
|
38
|
+
handleFocus = _useInputFocus.handleFocus,
|
|
39
|
+
handleBlur = _useInputFocus.handleBlur;
|
|
40
|
+
var filters = (0, _useFilters.useFilters)({
|
|
41
|
+
max: max
|
|
42
|
+
});
|
|
43
|
+
var _useNormalizers = (0, _useNormalizers2.useNormalizers)(),
|
|
44
|
+
normalizeFrom = _useNormalizers.normalizeFrom,
|
|
45
|
+
normalizeTo = _useNormalizers.normalizeTo;
|
|
46
|
+
var _useIncrement = (0, _useIncrement2.useIncrement)(),
|
|
47
|
+
increment = _useIncrement.increment,
|
|
48
|
+
decrement = _useIncrement.decrement;
|
|
49
|
+
var _useIncrementDisabled = (0, _useIncrementDisabledFlags.useIncrementDisabledFlags)({
|
|
50
|
+
max: max,
|
|
51
|
+
value: value
|
|
52
|
+
}),
|
|
53
|
+
isDecrementDisabled = _useIncrementDisabled.isDecrementDisabled,
|
|
54
|
+
isIncrementDisabled = _useIncrementDisabled.isIncrementDisabled;
|
|
55
|
+
var handleChange = (0, _react.useCallback)(function (event) {
|
|
56
|
+
var newValue = event.target.value;
|
|
57
|
+
var filtredValue = filters.reduce(function (acc, fn) {
|
|
58
|
+
return fn(acc);
|
|
59
|
+
}, newValue);
|
|
60
|
+
onChange(normalizeTo(filtredValue));
|
|
61
|
+
}, [normalizeTo, onChange, filters]);
|
|
62
|
+
var handleUp = (0, _react.useCallback)(function () {
|
|
63
|
+
onChange(increment(value));
|
|
64
|
+
}, [increment, value, onChange]);
|
|
65
|
+
var handleDown = (0, _react.useCallback)(function () {
|
|
66
|
+
onChange(decrement(value));
|
|
67
|
+
}, [decrement, value, onChange]);
|
|
68
|
+
return /*#__PURE__*/_react["default"].createElement(_InputLabel.InputLabel, {
|
|
69
|
+
inFocus: inFocus,
|
|
70
|
+
label: label
|
|
71
|
+
}, /*#__PURE__*/_react["default"].createElement(S.ControlWrapper, null, /*#__PURE__*/_react["default"].createElement(_PureInput.PureInput, {
|
|
72
|
+
name: name,
|
|
73
|
+
hasError: hasError,
|
|
74
|
+
inFocus: inFocus,
|
|
75
|
+
placeholder: placeholder,
|
|
76
|
+
onFocus: handleFocus,
|
|
77
|
+
onBlur: handleBlur,
|
|
78
|
+
value: normalizeFrom(value),
|
|
79
|
+
onChange: handleChange,
|
|
80
|
+
paddingRight: upAndDown ? 44 : undefined
|
|
81
|
+
}), upAndDown && /*#__PURE__*/_react["default"].createElement(S.Arrows, null, /*#__PURE__*/_react["default"].createElement(S.Arrow, {
|
|
82
|
+
onClick: handleUp,
|
|
83
|
+
$disabled: isIncrementDisabled
|
|
84
|
+
}, /*#__PURE__*/_react["default"].createElement(_Arrow.Arrow, {
|
|
85
|
+
isOpen: true,
|
|
86
|
+
outterSize: 12
|
|
87
|
+
})), /*#__PURE__*/_react["default"].createElement(S.Arrow, {
|
|
88
|
+
onClick: handleDown,
|
|
89
|
+
$disabled: isDecrementDisabled
|
|
90
|
+
}, /*#__PURE__*/_react["default"].createElement(_Arrow.Arrow, {
|
|
91
|
+
isOpen: false,
|
|
92
|
+
outterSize: 12
|
|
93
|
+
})))));
|
|
94
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
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.Default = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _addonActions = require("@storybook/addon-actions");
|
|
10
|
+
var _ = require(".");
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
|
+
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); }
|
|
14
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
15
|
+
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."); }
|
|
16
|
+
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); }
|
|
17
|
+
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; }
|
|
18
|
+
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; } }
|
|
19
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
+
var meta = {
|
|
21
|
+
title: 'form/PositiveIntegerInput',
|
|
22
|
+
component: _.PositiveIntegerInput,
|
|
23
|
+
tags: ['autodocs']
|
|
24
|
+
};
|
|
25
|
+
var _default = exports["default"] = meta;
|
|
26
|
+
var Component = function Component(props) {
|
|
27
|
+
var _useState = (0, _react.useState)(null),
|
|
28
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
+
value = _useState2[0],
|
|
30
|
+
setValue = _useState2[1];
|
|
31
|
+
var handleChange = (0, _react.useCallback)(function (newValue) {
|
|
32
|
+
setValue(newValue);
|
|
33
|
+
(0, _addonActions.action)('onChange')(newValue);
|
|
34
|
+
}, []);
|
|
35
|
+
return /*#__PURE__*/_react["default"].createElement(_.PositiveIntegerInput, _extends({}, props, {
|
|
36
|
+
value: value,
|
|
37
|
+
onChange: handleChange
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
var Default = exports.Default = {
|
|
41
|
+
args: {
|
|
42
|
+
max: 1000,
|
|
43
|
+
upAndDown: true,
|
|
44
|
+
label: 'Label',
|
|
45
|
+
placeholder: 'Placeholder',
|
|
46
|
+
hasError: false
|
|
47
|
+
},
|
|
48
|
+
render: Component
|
|
49
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Arrows: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
3
|
+
export declare const Arrow: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
4
|
+
$disabled: boolean;
|
|
5
|
+
}>>;
|
|
6
|
+
export declare const ControlWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|