intelicoreact 1.4.76 → 1.4.78
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/dist/Atomic/FormElements/ActionAlert/ActionAlert.js +9 -1
- package/dist/Atomic/FormElements/AdvancedStatus/AdvancedStatus.js +10 -1
- package/dist/Atomic/FormElements/Calendar/Calendar.js +24 -4
- package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.js +10 -1
- package/dist/Atomic/FormElements/CheckboxesLine/CheckboxesLine.js +14 -2
- package/dist/Atomic/FormElements/Datepicker/Datepicker.js +54 -5
- package/dist/Atomic/FormElements/Datepicker/components/Calendar.js +21 -3
- package/dist/Atomic/FormElements/Dropdown/Dropdown.js +145 -52
- package/dist/Atomic/FormElements/Dropdown/components/DropdownLoader.js +7 -1
- package/dist/Atomic/FormElements/DropdownLiveSearch/DropdownLiveSearch.js +91 -25
- package/dist/Atomic/FormElements/FileLoader/FileLoader.js +15 -3
- package/dist/Atomic/FormElements/FileLoader/partial/LoadZone.js +29 -15
- package/dist/Atomic/FormElements/FileLoader/partial/LoadedContent.js +15 -5
- package/dist/Atomic/FormElements/FileLoaderDescription/FileLoaderDescription.js +23 -4
- package/dist/Atomic/FormElements/FileLoaderLocal/FileLoaderLocal.js +26 -6
- package/dist/Atomic/FormElements/FileLoaderLocalGroup/FileLoaderLocalGroup.js +38 -19
- package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN.js +38 -9
- package/dist/Atomic/FormElements/Input/Input.js +60 -25
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +31 -4
- package/dist/Atomic/FormElements/InputColor/InputColor.js +14 -4
- package/dist/Atomic/FormElements/InputCurrency/InputCurrency.js +29 -6
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.js +43 -8
- package/dist/Atomic/FormElements/InputDateRange/components/DateInput.js +21 -3
- package/dist/Atomic/FormElements/InputDateRange/components/Datepicker.js +81 -58
- package/dist/Atomic/FormElements/InputDateRange/components/OpenedPart.js +41 -6
- package/dist/Atomic/FormElements/InputDateRange/components/SelectItem.js +8 -1
- package/dist/Atomic/FormElements/InputDateRange/dependencies.js +46 -16
- package/dist/Atomic/FormElements/InputLink/InputLink.js +23 -6
- package/dist/Atomic/FormElements/InputMask/InputCarretPosition.js +4 -0
- package/dist/Atomic/FormElements/InputMask/InputMask.js +208 -77
- package/dist/Atomic/FormElements/InputMask/functions.js +28 -2
- package/dist/Atomic/FormElements/InputMask2/InputMask2.js +119 -43
- package/dist/Atomic/FormElements/InputMask2/functions.js +28 -2
- package/dist/Atomic/FormElements/InputMask3/InputMask3.js +137 -44
- package/dist/Atomic/FormElements/InputMask3/functions.js +28 -2
- package/dist/Atomic/FormElements/InputWithAction/InputWithAction.js +17 -3
- package/dist/Atomic/FormElements/InputsRow/InputsRow.js +24 -5
- package/dist/Atomic/FormElements/Label/Label.js +9 -1
- package/dist/Atomic/FormElements/MobileCalendar/MobileCalendar.js +73 -35
- package/dist/Atomic/FormElements/MultiSelect/MultiSelect.js +15 -3
- package/dist/Atomic/FormElements/NumericInput/NumericInput.js +44 -23
- package/dist/Atomic/FormElements/RadioGroup/RadioGroup.js +17 -7
- package/dist/Atomic/FormElements/RadioGroupWithInput/RadioGroupWithInput.js +14 -3
- package/dist/Atomic/FormElements/RadioInput/RadioInput.js +10 -1
- package/dist/Atomic/FormElements/RadioRowSwitcher/RadioRowSwitcher.js +14 -3
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.js +23 -3
- package/dist/Atomic/FormElements/RangeInputs/RangeInputs.js +34 -17
- package/dist/Atomic/FormElements/RangeList/RangeList.js +25 -6
- package/dist/Atomic/FormElements/RangeList/partial/RangeListRow.js +11 -1
- package/dist/Atomic/FormElements/RangeSlider/RangeSlider.js +85 -14
- package/dist/Atomic/FormElements/RangeSlider2/RangeSlider2.js +132 -43
- package/dist/Atomic/FormElements/SwitchableRow/SwitchableRow.js +10 -1
- package/dist/Atomic/FormElements/Switcher/Switcher.js +10 -1
- package/dist/Atomic/FormElements/SwitcherCheckbox/SwitcherCheckbox.js +13 -1
- package/dist/Atomic/FormElements/SwitcherHide/SwitcherHide.js +10 -1
- package/dist/Atomic/FormElements/SwitcherRadio/SwitcherRadio.js +17 -2
- package/dist/Atomic/FormElements/SwitcherRange/SwitcherRange.js +17 -3
- package/dist/Atomic/FormElements/SwitcherRangeList/SwitcherRangeList.js +11 -1
- package/dist/Atomic/FormElements/SwitcherTagsDropdown/SwitcherTagsDropdown.js +29 -6
- package/dist/Atomic/FormElements/SwitcherTagsDropdown/partial/States.js +3 -2
- package/dist/Atomic/FormElements/SwitcherTextarea/SwitcherTextarea.js +12 -1
- package/dist/Atomic/FormElements/TagListToDropdown/TagListToDropdown.js +23 -6
- package/dist/Atomic/FormElements/TagsDropdown/TagsDropdown.js +223 -105
- package/dist/Atomic/FormElements/Text/Text.js +16 -10
- package/dist/Atomic/FormElements/TextSwitcher/TextSwitcher.js +9 -1
- package/dist/Atomic/FormElements/Textarea/Textarea.js +16 -5
- package/dist/Atomic/FormElements/TieredCheckboxes/TieredCheckboxes.js +35 -6
- package/dist/Atomic/FormElements/TieredCheckboxes/partial/AccordionWithCheckbox.js +13 -4
- package/dist/Atomic/FormElements/TimeRange/TimeRange.js +21 -7
- package/dist/Atomic/FormElements/UserContacts/UserContacts.js +35 -8
- package/dist/Atomic/FormElements/UserContacts/partial/defaultIcons.js +91 -0
- package/dist/Atomic/FormElements/VariantsListRadio/VariantsListRadio.js +18 -5
- package/dist/Atomic/FormElements/VariantsListRadio/partials/VariantsListRadioItem.js +10 -3
- package/dist/Atomic/FormElements/WidgetPseudoTable/WidgetPseudoTable.js +11 -3
- package/dist/Atomic/FormElements/WidgetPseudoTable/partial/constructor.js +2 -1
- package/dist/Atomic/FormElements/WidgetWithSwitchableRows/WidgetWithSwitchableRows.js +12 -5
- package/dist/Atomic/FormElements/WidgetWithSwitchableRows/partial/constructor.js +3 -3
- package/dist/Atomic/Layout/Header/Header.js +15 -3
- package/dist/Atomic/Layout/MainMenu/MainMenu.js +20 -3
- package/dist/Atomic/Layout/Spinner/Spinner.js +8 -1
- package/dist/Atomic/UI/Accordion/Accordion.js +19 -3
- package/dist/Atomic/UI/Accordion/AccordionItem.js +23 -9
- package/dist/Atomic/UI/AccordionTable/AccordionTable.js +32 -7
- package/dist/Atomic/UI/AccordionText/AccordionText.js +17 -3
- package/dist/Atomic/UI/AdvancedTag/AdvTag.js +21 -4
- package/dist/Atomic/UI/AdvancedTag/AdvancedTags.js +15 -3
- package/dist/Atomic/UI/Alert/Alert.js +19 -3
- package/dist/Atomic/UI/Arrow/Arrow.js +16 -3
- package/dist/Atomic/UI/Box/Box.js +9 -3
- package/dist/Atomic/UI/Button/Button.js +11 -2
- package/dist/Atomic/UI/ButtonsBar/ButtonsBar.js +10 -1
- package/dist/Atomic/UI/Chart/Chart.js +29 -4
- package/dist/Atomic/UI/Chart/partial/Chart.constants.js +19 -11
- package/dist/Atomic/UI/Chart/partial/ChartTypeSwitcherIcon/ChartTypeSwitcherIcon.js +12 -1
- package/dist/Atomic/UI/Chart/partial/datasetSetters.js +34 -11
- package/dist/Atomic/UI/Chart/partial/optionsConstructor.js +56 -82
- package/dist/Atomic/UI/Chart/partial/optionsSetters.js +19 -15
- package/dist/Atomic/UI/Chart/partial/utils.js +20 -6
- package/dist/Atomic/UI/CircleProgressBar/CircleProgressBar.js +13 -3
- package/dist/Atomic/UI/DateTime/DateTime.js +14 -3
- package/dist/Atomic/UI/DebugContainer/DebugContainer.js +16 -4
- package/dist/Atomic/UI/DebugContainer/useDebugContainer.js +11 -3
- package/dist/Atomic/UI/DoubleString/DoubleString.js +17 -5
- package/dist/Atomic/UI/DynamicIcon/DynamicIcon.js +10 -3
- package/dist/Atomic/UI/ExampleChartIntegration/ExampleChartIntegration.js +52 -17
- package/dist/Atomic/UI/ExampleChartIntegration/partial/utils.js +29 -1
- package/dist/Atomic/UI/Hint/Hint.js +39 -13
- package/dist/Atomic/UI/Hint/partials/_utils.js +19 -4
- package/dist/Atomic/UI/Modal/Modal.js +28 -6
- package/dist/Atomic/UI/Modal/ModalHOC.js +9 -1
- package/dist/Atomic/UI/Modal/partials/ModalFooter.js +7 -1
- package/dist/Atomic/UI/Modal/partials/ModalTitle.js +8 -1
- package/dist/Atomic/UI/Modal/partials/useMobileModal.js +49 -32
- package/dist/Atomic/UI/ModalBackup/Modal.js +174 -0
- package/dist/Atomic/UI/ModalBackup/Modal.scss +333 -0
- package/dist/Atomic/UI/ModalBackup/ModalHOC.js +51 -0
- package/dist/Atomic/UI/ModalBackup/partials/ModalFooter.js +24 -0
- package/dist/Atomic/UI/ModalBackup/partials/ModalTitle.js +41 -0
- package/dist/Atomic/UI/MonoAccordion/MonoAccordion.js +21 -6
- package/dist/Atomic/UI/NavLine/NavLine.js +55 -26
- package/dist/Atomic/UI/NavLine/Tabs.js +3 -2
- package/dist/Atomic/UI/PageTitle/PageTitle.js +10 -2
- package/dist/Atomic/UI/PieChart/PieChart.js +10 -1
- package/dist/Atomic/UI/Price/Price.js +8 -3
- package/dist/Atomic/UI/PriceRange/PriceRange.js +7 -1
- package/dist/Atomic/UI/ProgressLine/ProgressLine.js +16 -1
- package/dist/Atomic/UI/Status/Status.js +8 -1
- package/dist/Atomic/UI/Table/Partials/TdCell.js +29 -5
- package/dist/Atomic/UI/Table/Partials/TdHeader.js +11 -1
- package/dist/Atomic/UI/Table/Partials/TdRow.js +17 -5
- package/dist/Atomic/UI/Table/Partials/TdTitle.js +14 -3
- package/dist/Atomic/UI/Table/Table.js +12 -1
- package/dist/Atomic/UI/Table/TdTypes/TdActions.js +18 -2
- package/dist/Atomic/UI/Table/TdTypes/TdPriority.js +9 -1
- package/dist/Atomic/UI/Table/TdTypes/TdRange.js +4 -1
- package/dist/Atomic/UI/Table/TdTypes/TdWeight.js +13 -1
- package/dist/Atomic/UI/Tag/Tag.js +26 -11
- package/dist/Atomic/UI/TagList/TagList.js +52 -21
- package/dist/Atomic/UI/TagList/TagList.scss +3 -2
- package/dist/Atomic/UI/UserBox/UserBox.js +13 -1
- package/dist/Atomic/UI/WizardStepper/constructor.js +11 -3
- package/dist/Atomic/UI/WizardStepper/index.js +5 -1
- package/dist/Atomic/UI/WizardStepper/ui/StateIcon/StateIcon.js +10 -0
- package/dist/Atomic/UI/WizardStepper/ui/StateIcon/index.js +4 -1
- package/dist/Atomic/UI/WizardStepper/ui/StepRow/StepRow.js +17 -2
- package/dist/Atomic/UI/WizardStepper/ui/StepRow/index.js +5 -1
- package/dist/Atomic/UI/WizardStepper/ui/StepWrapper/StepWrapper.js +15 -1
- package/dist/Atomic/UI/WizardStepper/ui/StepWrapper/index.js +5 -1
- package/dist/Atomic/UI/WizardStepper/ui/icons.js +9 -2
- package/dist/Atomic/UI/WizardStepper/ui/index.js +5 -1
- package/dist/Classes/AbortableFetch.js +93 -36
- package/dist/Classes/AnimatedHandler.js +7 -3
- package/dist/Classes/RESTAPI/index.js +43 -39
- package/dist/Classes/RESTAPI/partials/AbortableFetch.js +93 -35
- package/dist/Classes/RESTAPI/partials/ApiBase.js +9 -1
- package/dist/Classes/RESTAPI/partials/ApiRequestCreators.js +32 -24
- package/dist/Classes/RESTAPI/partials/ApiUtils.js +41 -34
- package/dist/Classes/RESTAPI/partials/CredentialsProcessing.js +46 -21
- package/dist/Classes/RESTAPI/partials/Utils.js +19 -6
- package/dist/Classes/RESTAPI/partials/_outerDependencies.js +6 -2
- package/dist/Classes/RESTAPI/partials/_utils.js +39 -16
- package/dist/Constants/index.constants.js +15 -8
- package/dist/Functions/Portal.js +16 -5
- package/dist/Functions/customEventListener.js +17 -4
- package/dist/Functions/fieldValueFormatters.js +83 -43
- package/dist/Functions/hooks/useFormFieldsChangesManager.js +26 -23
- package/dist/Functions/locale/createTranslator.js +9 -4
- package/dist/Functions/operations.js +22 -12
- package/dist/Functions/presets/inputMaskPresets.js +11 -9
- package/dist/Functions/presets/inputPresets.js +11 -8
- package/dist/Functions/presets/mobileKeyboardTypesPresets.js +9 -7
- package/dist/Functions/schemas.js +13 -6
- package/dist/Functions/useBodyScrollLock.js +6 -1
- package/dist/Functions/useClickOutside.js +4 -0
- package/dist/Functions/useDebounce.js +7 -2
- package/dist/Functions/useFieldFocus.js +18 -6
- package/dist/Functions/useFormTools/form-drivers/ArrayWithObjects.js +9 -0
- package/dist/Functions/useFormTools/form-drivers/ObjectWithIterableObjects.js +23 -12
- package/dist/Functions/useFormTools/form-drivers/ObjectWithNamedKeyObjects.js +15 -6
- package/dist/Functions/useFormTools/functions/General.js +28 -18
- package/dist/Functions/useFormTools/functions/RenderFields.js +11 -2
- package/dist/Functions/useFormTools/functions/usePrevious.js +5 -1
- package/dist/Functions/useFormTools/index.js +144 -85
- package/dist/Functions/useInputHighlightError.js +12 -3
- package/dist/Functions/useIsMobile.js +13 -7
- package/dist/Functions/useKeyPress/useHandleKeyPress.js +7 -1
- package/dist/Functions/useKeyPress/useKeyPress.js +9 -1
- package/dist/Functions/useLocalStorage.js +9 -1
- package/dist/Functions/useLocationParams.js +5 -4
- package/dist/Functions/useMediaQuery.js +9 -3
- package/dist/Functions/useMetaInfo.js +10 -3
- package/dist/Functions/useMouseUpOutside.js +3 -0
- package/dist/Functions/useOnlineStatus.js +9 -1
- package/dist/Functions/usePasswordChecker.js +20 -4
- package/dist/Functions/usePrevious.js +5 -1
- package/dist/Functions/useResize.js +10 -2
- package/dist/Functions/useScrollTo.js +7 -2
- package/dist/Functions/useToggle.js +5 -1
- package/dist/Functions/utils.js +131 -56
- package/dist/Molecular/CustomIcons/components/AffiliateNetworks.js +9 -2
- package/dist/Molecular/CustomIcons/components/AlertCircle.js +9 -2
- package/dist/Molecular/CustomIcons/components/AppStore.js +9 -2
- package/dist/Molecular/CustomIcons/components/Arrow.js +9 -2
- package/dist/Molecular/CustomIcons/components/ArrowDown.js +9 -2
- package/dist/Molecular/CustomIcons/components/ArrowLeft.js +9 -2
- package/dist/Molecular/CustomIcons/components/ArrowRight.js +9 -2
- package/dist/Molecular/CustomIcons/components/ArrowUp.js +9 -2
- package/dist/Molecular/CustomIcons/components/Bell.js +9 -2
- package/dist/Molecular/CustomIcons/components/Button.js +9 -2
- package/dist/Molecular/CustomIcons/components/Campaigns.js +9 -2
- package/dist/Molecular/CustomIcons/components/Check.js +9 -2
- package/dist/Molecular/CustomIcons/components/Check2.js +9 -2
- package/dist/Molecular/CustomIcons/components/ChevronDown.js +9 -2
- package/dist/Molecular/CustomIcons/components/ChevronDownDisabled.js +9 -2
- package/dist/Molecular/CustomIcons/components/ChevronLeft.js +9 -2
- package/dist/Molecular/CustomIcons/components/ChevronRight.js +9 -2
- package/dist/Molecular/CustomIcons/components/ChevronUp.js +9 -2
- package/dist/Molecular/CustomIcons/components/ChevronUpDown.js +9 -2
- package/dist/Molecular/CustomIcons/components/Close.js +9 -2
- package/dist/Molecular/CustomIcons/components/ColumnsOrder.js +9 -2
- package/dist/Molecular/CustomIcons/components/Delete.js +9 -2
- package/dist/Molecular/CustomIcons/components/Edit.js +9 -2
- package/dist/Molecular/CustomIcons/components/Email.js +9 -2
- package/dist/Molecular/CustomIcons/components/FinturfLogo.js +9 -2
- package/dist/Molecular/CustomIcons/components/FinturfLogo2.js +9 -2
- package/dist/Molecular/CustomIcons/components/Flows.js +9 -2
- package/dist/Molecular/CustomIcons/components/Gift.js +9 -2
- package/dist/Molecular/CustomIcons/components/GoogleAuth.js +9 -2
- package/dist/Molecular/CustomIcons/components/GooglePlay.js +9 -2
- package/dist/Molecular/CustomIcons/components/HelpCircle.js +9 -2
- package/dist/Molecular/CustomIcons/components/HelpCircle2.js +9 -2
- package/dist/Molecular/CustomIcons/components/HelpCircleFilled.js +9 -2
- package/dist/Molecular/CustomIcons/components/Home.js +9 -2
- package/dist/Molecular/CustomIcons/components/Home2.js +9 -2
- package/dist/Molecular/CustomIcons/components/Key.js +9 -2
- package/dist/Molecular/CustomIcons/components/Landers.js +9 -2
- package/dist/Molecular/CustomIcons/components/Lock.js +9 -2
- package/dist/Molecular/CustomIcons/components/Mail.js +9 -2
- package/dist/Molecular/CustomIcons/components/Mastercard.js +9 -2
- package/dist/Molecular/CustomIcons/components/Minus.js +9 -2
- package/dist/Molecular/CustomIcons/components/Offers.js +9 -2
- package/dist/Molecular/CustomIcons/components/Pause.js +9 -2
- package/dist/Molecular/CustomIcons/components/PayPal.js +9 -2
- package/dist/Molecular/CustomIcons/components/PayPalLightLarge.js +9 -2
- package/dist/Molecular/CustomIcons/components/Phone.js +9 -2
- package/dist/Molecular/CustomIcons/components/Play.js +9 -2
- package/dist/Molecular/CustomIcons/components/Plus.js +9 -2
- package/dist/Molecular/CustomIcons/components/Profile.js +9 -2
- package/dist/Molecular/CustomIcons/components/QRCode.js +9 -2
- package/dist/Molecular/CustomIcons/components/Rectangle.js +9 -2
- package/dist/Molecular/CustomIcons/components/Revert.js +9 -2
- package/dist/Molecular/CustomIcons/components/Star.js +9 -2
- package/dist/Molecular/CustomIcons/components/Star2.js +9 -2
- package/dist/Molecular/CustomIcons/components/TrafficSources.js +9 -2
- package/dist/Molecular/CustomIcons/components/Trash.js +9 -2
- package/dist/Molecular/CustomIcons/components/TrashRed.js +9 -2
- package/dist/Molecular/CustomIcons/components/Triggers.js +9 -2
- package/dist/Molecular/CustomIcons/components/User.js +9 -2
- package/dist/Molecular/CustomIcons/components/Visa.js +9 -2
- package/dist/Molecular/CustomIcons/components/X.js +9 -2
- package/dist/Molecular/CustomIcons/index.js +122 -0
- package/dist/Molecular/FormElement/FormElement.js +12 -1
- package/dist/Molecular/FormWithDependOn/FormWithDependOn.js +31 -30
- package/dist/Molecular/FormWithDependOn/partials/_utils.js +12 -9
- package/dist/Molecular/InputAddress/InputAddress.js +114 -65
- package/dist/Molecular/InputPassword/InputPassword.js +19 -5
- package/dist/index.js +2 -0
- package/package.json +1 -1
- package/dist/Atomic/UI/Hint/partial/_utils.js +0 -52
|
@@ -6,27 +6,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.formatToRemoveComa = exports.formatToPriceWithUSD = exports.formatToPriceWithCurrency = exports.formatToOnlyASCIICodeText = exports.formatToLimitLength = exports.formatToHideValuePartially = exports.formatToHex = exports.formatToAddBitDepthPoints = exports.formatOnlyNumbers = exports.formatNumberValueToMask = exports.formatAsPercentage = exports.filterNumeric = exports.filterFloat = void 0;
|
|
7
7
|
exports.formatToReplaceAllWhiteSpace = formatToReplaceAllWhiteSpace;
|
|
8
8
|
exports.intlNumbersFormatter = exports.getSafelyValue = void 0;
|
|
9
|
+
|
|
9
10
|
var _utils = require("./utils");
|
|
11
|
+
|
|
10
12
|
//? The first word "format" in the function name means a logic
|
|
11
13
|
//? in which the function transforms the incoming value in any case.
|
|
12
|
-
|
|
13
14
|
//? The first word "transform" in the function name means a logic
|
|
14
15
|
//? in which the function converts the whole value, but this is not suitable for sequential input
|
|
15
|
-
|
|
16
16
|
//? The first word "filter" in the function name means a logic
|
|
17
17
|
//? in which the function works as a changer for sequential input
|
|
18
|
-
|
|
19
18
|
// ****************************
|
|
20
19
|
// Base utils
|
|
21
20
|
// ****************************
|
|
22
|
-
|
|
23
21
|
const getSafelyValue = value => {
|
|
24
22
|
var _value$toString;
|
|
25
|
-
return value !== undefined && value !== null ? (value === null || value === void 0 || (_value$toString = value.toString) === null || _value$toString === void 0 ? void 0 : _value$toString.call(value)) || "" : "";
|
|
26
|
-
};
|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
return value !== undefined && value !== null ? (value === null || value === void 0 ? void 0 : (_value$toString = value.toString) === null || _value$toString === void 0 ? void 0 : _value$toString.call(value)) || "" : "";
|
|
25
|
+
}; // базовая реализация
|
|
26
|
+
|
|
27
|
+
|
|
29
28
|
exports.getSafelyValue = getSafelyValue;
|
|
29
|
+
|
|
30
30
|
const intlNumbersFormatter = function (inputValue) {
|
|
31
31
|
let settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
32
32
|
const safelyInputValue = getSafelyValue(inputValue);
|
|
@@ -52,31 +52,40 @@ const intlNumbersFormatter = function (inputValue) {
|
|
|
52
52
|
currencyDisplay: inputCurrencyDisplay
|
|
53
53
|
} = currency;
|
|
54
54
|
let currencyDisplay;
|
|
55
|
+
|
|
55
56
|
switch (inputCurrencyDisplay) {
|
|
56
57
|
case "name":
|
|
57
58
|
currencyDisplay = "name";
|
|
58
59
|
break;
|
|
60
|
+
|
|
59
61
|
case "code":
|
|
60
62
|
currencyDisplay = "code";
|
|
61
63
|
break;
|
|
64
|
+
|
|
62
65
|
case "narrowSymbol":
|
|
63
66
|
currencyDisplay = "narrowSymbol";
|
|
64
67
|
break;
|
|
68
|
+
|
|
65
69
|
default:
|
|
66
70
|
currencyDisplay = "symbol";
|
|
67
71
|
}
|
|
72
|
+
|
|
68
73
|
let numberStyle;
|
|
74
|
+
|
|
69
75
|
switch (withSymbol) {
|
|
70
76
|
case "percent":
|
|
71
77
|
numberStyle = "percent";
|
|
72
78
|
break;
|
|
79
|
+
|
|
73
80
|
case "currency":
|
|
74
81
|
numberStyle = "currency";
|
|
75
82
|
break;
|
|
83
|
+
|
|
76
84
|
default:
|
|
77
85
|
numberStyle = "decimal";
|
|
78
86
|
break;
|
|
79
87
|
}
|
|
88
|
+
|
|
80
89
|
const {
|
|
81
90
|
quantity,
|
|
82
91
|
isRenderAlways = false,
|
|
@@ -86,17 +95,20 @@ const intlNumbersFormatter = function (inputValue) {
|
|
|
86
95
|
} = fractionDigits;
|
|
87
96
|
const dotIndex = safelyInputValue === null || safelyInputValue === void 0 ? void 0 : safelyInputValue.indexOf(".");
|
|
88
97
|
const afterDot = dotIndex !== -1 ? safelyInputValue.slice(dotIndex + 1) : "";
|
|
98
|
+
|
|
89
99
|
const minimumFractionDigits = (() => {
|
|
90
100
|
//? Безусловное минимальное количество. Всегда отрендерит дробную часть, в количестве символов сколько указано
|
|
91
|
-
if (typeof inputMinimumFractionDigits === "number") return inputMinimumFractionDigits;
|
|
92
|
-
|
|
101
|
+
if (typeof inputMinimumFractionDigits === "number") return inputMinimumFractionDigits; //? Условное минимальное количество. Если есть дробная часть, то отрендерит дробных символов сколько указано
|
|
102
|
+
|
|
93
103
|
if (typeof conditionallyMinimumFractionDigits === "number") {
|
|
94
104
|
return afterDot && lastSym !== "." ? conditionallyMinimumFractionDigits : 0;
|
|
95
|
-
}
|
|
96
|
-
//? Дефолтное минимальное количество. Если есть дробная часть, то отрендерит дробных символов столько, сколько есть
|
|
105
|
+
} //? Дефолтное минимальное количество. Если есть дробная часть, то отрендерит дробных символов столько, сколько есть
|
|
97
106
|
//? Флаг isRenderAlways превращает дефолтный кейс в безусловное минимальное количество
|
|
107
|
+
|
|
108
|
+
|
|
98
109
|
return afterDot && lastSym !== "." ? safelyInputValue.slice(dotIndex).length - 1 : isRenderAlways ? quantity : 0;
|
|
99
110
|
})();
|
|
111
|
+
|
|
100
112
|
const priceSettings = {
|
|
101
113
|
useGrouping,
|
|
102
114
|
//группировка разрядов
|
|
@@ -114,33 +126,41 @@ const intlNumbersFormatter = function (inputValue) {
|
|
|
114
126
|
maximumFractionDigits: inputMaximumFractionDigits !== null && inputMaximumFractionDigits !== void 0 ? inputMaximumFractionDigits : quantity
|
|
115
127
|
};
|
|
116
128
|
let output;
|
|
129
|
+
|
|
117
130
|
try {
|
|
118
131
|
output = new Intl.NumberFormat(locale, priceSettings).format(value);
|
|
119
132
|
} catch (e) {
|
|
120
|
-
output = value;
|
|
121
|
-
|
|
133
|
+
output = value; // eslint-disable-next-line no-console
|
|
134
|
+
|
|
122
135
|
console.warn("Intl.NumberFormat error", e);
|
|
123
136
|
}
|
|
124
|
-
return lastSym === "." ? output + lastSym : output;
|
|
125
|
-
};
|
|
126
137
|
|
|
127
|
-
|
|
138
|
+
return lastSym === "." ? output + lastSym : output;
|
|
139
|
+
}; // ****************************
|
|
128
140
|
// format
|
|
129
141
|
// ****************************
|
|
142
|
+
|
|
143
|
+
|
|
130
144
|
exports.intlNumbersFormatter = intlNumbersFormatter;
|
|
145
|
+
|
|
131
146
|
const formatOnlyNumbers = value => getSafelyValue(value).replace(/\D/g, "");
|
|
147
|
+
|
|
132
148
|
exports.formatOnlyNumbers = formatOnlyNumbers;
|
|
149
|
+
|
|
133
150
|
const formatToRemoveComa = value => getSafelyValue(value).replace(/,/g, "");
|
|
151
|
+
|
|
134
152
|
exports.formatToRemoveComa = formatToRemoveComa;
|
|
153
|
+
|
|
135
154
|
const formatToAddBitDepthPoints = (value, settings) => intlNumbersFormatter(getSafelyValue(value), {
|
|
136
155
|
fractionDigits: {
|
|
137
156
|
quantity: (settings === null || settings === void 0 ? void 0 : settings.type) === "int" ? 0 : settings === null || settings === void 0 ? void 0 : settings.decimalPlaces
|
|
138
157
|
}
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
//! Важно! Если придет велью с количеством дробных разрядов БОЛЬШИМ
|
|
158
|
+
}); //! Важно! Если придет велью с количеством дробных разрядов БОЛЬШИМ
|
|
142
159
|
//! чем указано в quantity - округлит по правилам округления
|
|
160
|
+
|
|
161
|
+
|
|
143
162
|
exports.formatToAddBitDepthPoints = formatToAddBitDepthPoints;
|
|
163
|
+
|
|
144
164
|
const formatToPriceWithUSD = value => {
|
|
145
165
|
if (isNaN(Number(value))) return value;
|
|
146
166
|
return intlNumbersFormatter(getSafelyValue(value), {
|
|
@@ -153,13 +173,13 @@ const formatToPriceWithUSD = value => {
|
|
|
153
173
|
conditionallyMinimumFractionDigits: 2
|
|
154
174
|
}
|
|
155
175
|
});
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
//! Важно! Если придет велью с количеством дробных разрядов БОЛЬШИМ
|
|
176
|
+
}; //! Важно! Если придет велью с количеством дробных разрядов БОЛЬШИМ
|
|
159
177
|
//! чем указано в quantity - округлит по правилам округления
|
|
160
|
-
|
|
161
178
|
// ToDo - symbolPosition временно не реализовано
|
|
179
|
+
|
|
180
|
+
|
|
162
181
|
exports.formatToPriceWithUSD = formatToPriceWithUSD;
|
|
182
|
+
|
|
163
183
|
const formatToPriceWithCurrency = function (value, currencyCode) {
|
|
164
184
|
let symbolPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "before";
|
|
165
185
|
if (isNaN(Number(value))) return value;
|
|
@@ -173,27 +193,23 @@ const formatToPriceWithCurrency = function (value, currencyCode) {
|
|
|
173
193
|
conditionallyMinimumFractionDigits: 2
|
|
174
194
|
}
|
|
175
195
|
});
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
//? Добавляет в конец знак %. Работает как с одиночными значениями, так и с диапазонами.
|
|
179
|
-
|
|
196
|
+
}; //? Добавляет в конец знак %. Работает как с одиночными значениями, так и с диапазонами.
|
|
180
197
|
//? value может быть любое, но ожидается что будет
|
|
181
198
|
//? - числом
|
|
182
199
|
//? - строкой в формате "значение"
|
|
183
200
|
//? - строкой в формате "значение - значение" (значение_пробел_тире_пробел_значение)
|
|
184
201
|
//? - объект в формате { from: значение, to: значение }
|
|
185
|
-
|
|
186
202
|
//? Предполагается, что "значение" может быть приведено к числу операторм + (пример: +значение приводится к числу).
|
|
187
203
|
//? Если не может быть приведено, то "значение" вернется как есть, к результату добавится %
|
|
188
|
-
|
|
189
204
|
//? Если "значение" пустое (getSafelyValue(значение) вернет пустую строку),
|
|
190
205
|
//? то это воспринимается как 0, приводится к 0.00%
|
|
191
|
-
|
|
192
206
|
//? Одиноково работает как для ".", так и "," в качестве разделителя дробных разрядов
|
|
193
|
-
|
|
194
207
|
//! Важно! Если придет велью с количеством дробных разрядов БОЛЬШИМ
|
|
195
208
|
//! чем указано в decimalPlaces - округлит по правилам округления
|
|
209
|
+
|
|
210
|
+
|
|
196
211
|
exports.formatToPriceWithCurrency = formatToPriceWithCurrency;
|
|
212
|
+
|
|
197
213
|
const formatAsPercentage = (value, settings) => {
|
|
198
214
|
const {
|
|
199
215
|
isCommonPercentageSymbol = true,
|
|
@@ -202,7 +218,9 @@ const formatAsPercentage = (value, settings) => {
|
|
|
202
218
|
afterValueSymbol = ""
|
|
203
219
|
} = (0, _utils.getIsOnlyAnObject)(settings) ? settings : {};
|
|
204
220
|
let safelyInputValue;
|
|
221
|
+
|
|
205
222
|
const checkValue = value => getSafelyValue(value) || "0";
|
|
223
|
+
|
|
206
224
|
const transform = valueAsSting => {
|
|
207
225
|
const processedValue = valueAsSting.replace(/,/g, ".");
|
|
208
226
|
if (Number.isNaN(Number(processedValue))) return processedValue;
|
|
@@ -213,6 +231,7 @@ const formatAsPercentage = (value, settings) => {
|
|
|
213
231
|
}
|
|
214
232
|
}));
|
|
215
233
|
};
|
|
234
|
+
|
|
216
235
|
if ((0, _utils.getIsOnlyAnObject)(value)) {
|
|
217
236
|
safelyInputValue = {
|
|
218
237
|
from: checkValue(value.from),
|
|
@@ -220,6 +239,7 @@ const formatAsPercentage = (value, settings) => {
|
|
|
220
239
|
};
|
|
221
240
|
} else {
|
|
222
241
|
safelyInputValue = checkValue(value);
|
|
242
|
+
|
|
223
243
|
if (safelyInputValue.includes(" - ")) {
|
|
224
244
|
const valuesArr = safelyInputValue.split(" - ").map(partOfValue => partOfValue.trim());
|
|
225
245
|
safelyInputValue = {
|
|
@@ -230,19 +250,21 @@ const formatAsPercentage = (value, settings) => {
|
|
|
230
250
|
return "".concat(beforeValueSymbol).concat(transform(safelyInputValue)).concat(afterValueSymbol, "%");
|
|
231
251
|
}
|
|
232
252
|
}
|
|
253
|
+
|
|
233
254
|
if (isCommonPercentageSymbol) return "".concat(beforeValueSymbol).concat(transform(safelyInputValue.from), " - ").concat(transform(safelyInputValue.to)).concat(afterValueSymbol, "%");else return "".concat(beforeValueSymbol).concat(transform(safelyInputValue.from), "% - ").concat(transform(safelyInputValue.to), "%").concat(afterValueSymbol);
|
|
234
|
-
};
|
|
255
|
+
}; // eslint-disable-next-line no-control-regex
|
|
256
|
+
|
|
235
257
|
|
|
236
|
-
// eslint-disable-next-line no-control-regex
|
|
237
258
|
exports.formatAsPercentage = formatAsPercentage;
|
|
238
|
-
const formatToOnlyASCIICodeText = text => getSafelyValue(text).replace(/[^\x00-\x7F]+/g, "");
|
|
239
259
|
|
|
240
|
-
// eslint-disable-next-line default-param-last
|
|
260
|
+
const formatToOnlyASCIICodeText = text => getSafelyValue(text).replace(/[^\x00-\x7F]+/g, ""); // eslint-disable-next-line default-param-last
|
|
261
|
+
|
|
262
|
+
|
|
241
263
|
exports.formatToOnlyASCIICodeText = formatToOnlyASCIICodeText;
|
|
264
|
+
|
|
242
265
|
const formatNumberValueToMask = (inputValue, settings) => {
|
|
243
|
-
const safelyInputValue = getSafelyValue(inputValue);
|
|
266
|
+
const safelyInputValue = getSafelyValue(inputValue); // default valueSymbol === 'n', default mask === 'nnn-nnn-nnnn'
|
|
244
267
|
|
|
245
|
-
// default valueSymbol === 'n', default mask === 'nnn-nnn-nnnn'
|
|
246
268
|
const {
|
|
247
269
|
mask = "XXX-XXX-XXXX",
|
|
248
270
|
valueSymbol = "X",
|
|
@@ -262,12 +284,16 @@ const formatNumberValueToMask = (inputValue, settings) => {
|
|
|
262
284
|
cursorPosition: processing.cursorPosition
|
|
263
285
|
} : processing.newValue.join("");
|
|
264
286
|
};
|
|
287
|
+
|
|
265
288
|
exports.formatNumberValueToMask = formatNumberValueToMask;
|
|
289
|
+
|
|
266
290
|
const formatToLimitLength = (inputValue, limit) => {
|
|
267
291
|
const value = getSafelyValue(inputValue);
|
|
268
292
|
return limit && typeof limit === "number" && !Number.isNaN(limit) && (value === null || value === void 0 ? void 0 : value.length) > limit ? value.substr(0, limit) : value;
|
|
269
293
|
};
|
|
294
|
+
|
|
270
295
|
exports.formatToLimitLength = formatToLimitLength;
|
|
296
|
+
|
|
271
297
|
const formatToHex = _ref => {
|
|
272
298
|
let {
|
|
273
299
|
inputValue,
|
|
@@ -277,22 +303,19 @@ const formatToHex = _ref => {
|
|
|
277
303
|
if (withSharp) return "#".concat(value.replace(/[^a-f0-9]/gi, ""));
|
|
278
304
|
return "".concat(value.replace(/[^#a-f0-9]/gi, ""));
|
|
279
305
|
};
|
|
306
|
+
|
|
280
307
|
exports.formatToHex = formatToHex;
|
|
308
|
+
|
|
281
309
|
function formatToReplaceAllWhiteSpace(str) {
|
|
282
310
|
const value = getSafelyValue(str);
|
|
283
311
|
return value.replace(/\s+/g, "");
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// ****************************
|
|
312
|
+
} // ****************************
|
|
287
313
|
// transform
|
|
288
314
|
// ****************************
|
|
289
|
-
|
|
290
315
|
// ...
|
|
291
|
-
|
|
292
316
|
// ****************************
|
|
293
317
|
// filter
|
|
294
318
|
// ****************************
|
|
295
|
-
|
|
296
319
|
// export const filterFloat = (inputValue, decimalPlaces = null) => {
|
|
297
320
|
// const value = getSafelyValue(inputValue);
|
|
298
321
|
// const replaser = input => ('' + input).replace(/[^\.\d]/g, '');
|
|
@@ -314,30 +337,42 @@ function formatToReplaceAllWhiteSpace(str) {
|
|
|
314
337
|
// return replaser(lastSym === '.' && previousValue.includes('.') ? previousValue : output);
|
|
315
338
|
// };
|
|
316
339
|
|
|
340
|
+
|
|
317
341
|
const filterFloat = function (inputValue) {
|
|
318
342
|
var _output, _output2, _output3, _output4;
|
|
343
|
+
|
|
319
344
|
let decimalPlaces = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
320
345
|
const value = getSafelyValue(inputValue);
|
|
346
|
+
|
|
321
347
|
const replacer = input => {
|
|
322
348
|
var _String;
|
|
349
|
+
|
|
323
350
|
return (_String = String(input)) === null || _String === void 0 ? void 0 : _String.replace(/[^\.\d,]/g, "");
|
|
324
351
|
};
|
|
352
|
+
|
|
325
353
|
if (value.length === 1 && (value[0] === "." || value[0] === ",")) return "0.";
|
|
326
354
|
let output = value;
|
|
327
355
|
const previousValue = String((_output = output) === null || _output === void 0 ? void 0 : _output.slice(0, -1));
|
|
328
356
|
const lastSym = String((_output2 = output) === null || _output2 === void 0 ? void 0 : _output2.slice(-1));
|
|
357
|
+
|
|
329
358
|
if (decimalPlaces && typeof decimalPlaces === "number" && previousValue !== null && previousValue !== void 0 && previousValue.includes(".") && (previousValue === null || previousValue === void 0 ? void 0 : previousValue.indexOf(".")) + 1 + decimalPlaces === (previousValue === null || previousValue === void 0 ? void 0 : previousValue.length)) {
|
|
330
359
|
return replacer(previousValue);
|
|
331
360
|
}
|
|
361
|
+
|
|
332
362
|
if ((_output3 = output) !== null && _output3 !== void 0 && _output3.includes(".") && output[((_output4 = output) === null || _output4 === void 0 ? void 0 : _output4.indexOf(".")) + 3] !== undefined && Number(output)) {
|
|
333
363
|
var _Number;
|
|
364
|
+
|
|
334
365
|
output = (_Number = Number(output)) === null || _Number === void 0 ? void 0 : _Number.toFixed(decimalPlaces);
|
|
335
366
|
}
|
|
367
|
+
|
|
336
368
|
return replacer(lastSym === "." && previousValue !== null && previousValue !== void 0 && previousValue.includes(".") ? previousValue : output);
|
|
337
369
|
};
|
|
370
|
+
|
|
338
371
|
exports.filterFloat = filterFloat;
|
|
372
|
+
|
|
339
373
|
const filterNumeric = (value, settings) => {
|
|
340
374
|
var _getSafelyValue;
|
|
375
|
+
|
|
341
376
|
value = (_getSafelyValue = getSafelyValue(value)) === null || _getSafelyValue === void 0 ? void 0 : _getSafelyValue.replace(/,/g, "");
|
|
342
377
|
const {
|
|
343
378
|
type = "float",
|
|
@@ -346,7 +381,9 @@ const filterNumeric = (value, settings) => {
|
|
|
346
381
|
const executor = type === "float" ? filterFloat : formatOnlyNumbers;
|
|
347
382
|
return executor(getSafelyValue(value), decimalPlaces);
|
|
348
383
|
};
|
|
384
|
+
|
|
349
385
|
exports.filterNumeric = filterNumeric;
|
|
386
|
+
|
|
350
387
|
const formatToHideValuePartially = (value, settings) => {
|
|
351
388
|
const {
|
|
352
389
|
showSymbolsCount = 4,
|
|
@@ -356,9 +393,12 @@ const formatToHideValuePartially = (value, settings) => {
|
|
|
356
393
|
const safelyValue = getSafelyValue(value);
|
|
357
394
|
const newValue = isCutOutWhiteSpaces ? safelyValue.replace(/\s/g, "") : safelyValue;
|
|
358
395
|
if (newValue.length <= showSymbolsCount) return newValue;
|
|
396
|
+
|
|
359
397
|
const hide = val => val.split("").map(() => "*").join("");
|
|
398
|
+
|
|
360
399
|
const visiblePart = isVisibleFromFront ? newValue.slice(0, showSymbolsCount) : newValue.slice(-1 * showSymbolsCount);
|
|
361
400
|
const hiddenPart = isVisibleFromFront ? newValue.slice(showSymbolsCount) : newValue.slice(0, -1 * showSymbolsCount);
|
|
362
401
|
return isVisibleFromFront ? "".concat(visiblePart).concat(hide(hiddenPart)) : "".concat(hide(hiddenPart)).concat(visiblePart);
|
|
363
402
|
};
|
|
403
|
+
|
|
364
404
|
exports.formatToHideValuePartially = formatToHideValuePartially;
|
|
@@ -4,15 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
7
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
|
|
9
|
-
function
|
|
9
|
+
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
+
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
|
|
10
14
|
const timeouts = {
|
|
11
15
|
timeoutId: null
|
|
12
16
|
};
|
|
13
|
-
const formChanges = [];
|
|
17
|
+
const formChanges = []; // ? validateField - должен возвращать структуру { field, isValid }
|
|
14
18
|
|
|
15
|
-
// ? validateField - должен возвращать структуру { field, isValid }
|
|
16
19
|
const useFormFieldsChangesManager = _ref => {
|
|
17
20
|
let {
|
|
18
21
|
form,
|
|
@@ -24,26 +27,23 @@ const useFormFieldsChangesManager = _ref => {
|
|
|
24
27
|
const {
|
|
25
28
|
isNotSetForm,
|
|
26
29
|
isUseValidation = false
|
|
27
|
-
} = settings || {};
|
|
28
|
-
|
|
29
|
-
//? Пробовал ставить просто useEffect по formChangesRef.current,
|
|
30
|
+
} = settings || {}; //? Пробовал ставить просто useEffect по formChangesRef.current,
|
|
30
31
|
//? но по какой-то причине после изменении рефки не заходило в useEffect.
|
|
31
32
|
//? Однако если срабатывал useEffect по какой-нибудь другой переменной,
|
|
32
33
|
//? то и в useEffect по formChangesRef.current тоже заходило.
|
|
33
34
|
//? Поэтому тут нужен этот стейт,
|
|
34
35
|
//? хотя по итогу в конечной реализации с ним даже неплохо получилось (но вообще очень странная ерунда...)
|
|
35
|
-
const [isFormMustBeChanget, setIsFormMustBeChanget] = (0, _react.useState)(false);
|
|
36
36
|
|
|
37
|
-
//? Ф-я является ф-ей - постановщиком изменений формы в очередь.
|
|
37
|
+
const [isFormMustBeChanget, setIsFormMustBeChanget] = (0, _react.useState)(false); //? Ф-я является ф-ей - постановщиком изменений формы в очередь.
|
|
38
38
|
//? Ф-я получается самовызывающимся геттером.
|
|
39
39
|
//? Cуть ф-ии:
|
|
40
40
|
//? Для того чтоб не спамить изменениями, если их назначается много в рамках одной итерации,
|
|
41
41
|
//? ипользую прием с переназначением setTimeout
|
|
42
|
-
|
|
43
42
|
//? Чтобы преждевременно не спровацировать сработку useEffect
|
|
44
43
|
//? по стейту фиксирующему "отмашку" к началу изменений (isFormMustBeChanget)
|
|
45
44
|
//? откладываю переназначение этого стейта до приостановки непрерывных вызовов assignChangesToField,
|
|
46
45
|
//? но при этом при каждом ее вызове продолжаю добавлять изменения в массив
|
|
46
|
+
|
|
47
47
|
const assignChangesToField = (() => {
|
|
48
48
|
return (data, key) => {
|
|
49
49
|
clearTimeout(timeouts.timeoutId);
|
|
@@ -55,11 +55,12 @@ const useFormFieldsChangesManager = _ref => {
|
|
|
55
55
|
timeouts.timeoutId = setTimeout(() => setIsFormMustBeChanget(true), 1);
|
|
56
56
|
return formChanges;
|
|
57
57
|
};
|
|
58
|
-
})();
|
|
58
|
+
})(); //? Ф-я применяет "накопленные" изменения
|
|
59
|
+
|
|
59
60
|
|
|
60
|
-
//? Ф-я применяет "накопленные" изменения
|
|
61
61
|
const changeForm = async () => {
|
|
62
62
|
var _modifiedFormFromOuts;
|
|
63
|
+
|
|
63
64
|
let modifiedFormFromOutside;
|
|
64
65
|
const errorsFromChanges = {};
|
|
65
66
|
const newForm = formChanges.reduce((acc, change) => {
|
|
@@ -71,24 +72,23 @@ const useFormFieldsChangesManager = _ref => {
|
|
|
71
72
|
error
|
|
72
73
|
} = data || {};
|
|
73
74
|
const field = acc.find(field => field.key === key);
|
|
75
|
+
|
|
74
76
|
if (field) {
|
|
75
|
-
acc = acc.map(field => field.key === key ? {
|
|
76
|
-
...field,
|
|
77
|
+
acc = acc.map(field => field.key === key ? { ...field,
|
|
77
78
|
...data
|
|
78
79
|
} : field);
|
|
79
80
|
if (error || error !== undefined) errorsFromChanges[key] = error;
|
|
80
81
|
}
|
|
82
|
+
|
|
81
83
|
return acc;
|
|
82
|
-
}, form);
|
|
84
|
+
}, form); // ToDo - порефакторить, не прогонять валидацию всех полей, а только измененных
|
|
83
85
|
|
|
84
|
-
// ToDo - порефакторить, не прогонять валидацию всех полей, а только измененных
|
|
85
86
|
const validatedForm = isUseValidation && typeof validateField === "function" ? newForm.map(field => {
|
|
86
|
-
var _validateField;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
error: ((_validateField = validateField({
|
|
90
|
-
|
|
91
|
-
}, newForm)) === null || _validateField === void 0 || (_validateField = _validateField.field) === null || _validateField === void 0 ? void 0 : _validateField.error) || errorsFromChanges[field.key] || ""
|
|
87
|
+
var _validateField, _validateField$field;
|
|
88
|
+
|
|
89
|
+
return { ...field,
|
|
90
|
+
error: ((_validateField = validateField({ ...field
|
|
91
|
+
}, newForm)) === null || _validateField === void 0 ? void 0 : (_validateField$field = _validateField.field) === null || _validateField$field === void 0 ? void 0 : _validateField$field.error) || errorsFromChanges[field.key] || ""
|
|
92
92
|
};
|
|
93
93
|
}) : newForm;
|
|
94
94
|
if (callback && typeof callback === "function") modifiedFormFromOutside = await callback(validatedForm);
|
|
@@ -96,6 +96,7 @@ const useFormFieldsChangesManager = _ref => {
|
|
|
96
96
|
formChanges.length = 0;
|
|
97
97
|
setIsFormMustBeChanget(false);
|
|
98
98
|
};
|
|
99
|
+
|
|
99
100
|
(0, _react.useEffect)(() => {
|
|
100
101
|
if (isFormMustBeChanget) changeForm();
|
|
101
102
|
}, [isFormMustBeChanget]);
|
|
@@ -106,4 +107,6 @@ const useFormFieldsChangesManager = _ref => {
|
|
|
106
107
|
changesArray: [...formChanges]
|
|
107
108
|
};
|
|
108
109
|
};
|
|
109
|
-
|
|
110
|
+
|
|
111
|
+
var _default = useFormFieldsChangesManager;
|
|
112
|
+
exports.default = _default;
|
|
@@ -4,30 +4,35 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = createTranslator;
|
|
7
|
+
|
|
7
8
|
var _fieldValueFormatters = require("./../fieldValueFormatters");
|
|
9
|
+
|
|
8
10
|
const DEFAULT_CODE = "en";
|
|
11
|
+
|
|
9
12
|
function createTranslator(_ref) {
|
|
10
|
-
let {
|
|
11
|
-
...langCatalogs
|
|
13
|
+
let { ...langCatalogs
|
|
12
14
|
} = _ref;
|
|
13
|
-
const loc = {
|
|
14
|
-
...langCatalogs
|
|
15
|
+
const loc = { ...langCatalogs
|
|
15
16
|
};
|
|
16
17
|
let code = window.localStorage.getItem("lng");
|
|
17
18
|
if (!code) code = window.navigator ? window.navigator.language.split("-")[0] : DEFAULT_CODE;
|
|
18
19
|
if (!loc[code]) code = DEFAULT_CODE;
|
|
19
20
|
return function (text, values) {
|
|
20
21
|
var _Object$keys;
|
|
22
|
+
|
|
21
23
|
const safelyValues = values !== null && values !== void 0 ? values : {};
|
|
22
24
|
const safelyText = (0, _fieldValueFormatters.getSafelyValue)(text);
|
|
23
25
|
let translatedText = loc[code] && loc[code][safelyText] ? loc[code][safelyText] : safelyText;
|
|
26
|
+
|
|
24
27
|
if (Object !== null && Object !== void 0 && (_Object$keys = Object.keys(safelyValues)) !== null && _Object$keys !== void 0 && _Object$keys.length) {
|
|
25
28
|
for (const key in values) {
|
|
26
29
|
var _translatedText;
|
|
30
|
+
|
|
27
31
|
const regex = new RegExp("%".concat(key, "%"), "g");
|
|
28
32
|
translatedText = (_translatedText = translatedText) === null || _translatedText === void 0 ? void 0 : _translatedText.replace(regex, values[key]);
|
|
29
33
|
}
|
|
30
34
|
}
|
|
35
|
+
|
|
31
36
|
return translatedText;
|
|
32
37
|
};
|
|
33
38
|
}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.addRangeDefault = void 0;
|
|
7
|
+
|
|
7
8
|
// Взято из https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Math/round
|
|
8
9
|
// При импорте любой ф-и из этого файла отработает самовызывающаяся ф-я и расширит
|
|
9
10
|
// объект Math 3-мя ф-ми: round10, floor10, ceil10
|
|
@@ -21,39 +22,44 @@ exports.addRangeDefault = void 0;
|
|
|
21
22
|
if (typeof exp === "undefined" || Number(exp) === 0) {
|
|
22
23
|
return Math[type](value);
|
|
23
24
|
}
|
|
25
|
+
|
|
24
26
|
value = Number(value);
|
|
25
|
-
exp = Number(exp);
|
|
26
|
-
|
|
27
|
+
exp = Number(exp); // Если значение не является числом, либо степень не является целым числом...
|
|
28
|
+
|
|
27
29
|
if (isNaN(value) || !(typeof exp === "number" && exp % 1 === 0)) {
|
|
28
30
|
return NaN;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
+
} // Сдвиг разрядов
|
|
32
|
+
|
|
33
|
+
|
|
31
34
|
value = value.toString().split("e");
|
|
32
|
-
value = Math[type](Number(value[0] + "e" + (value[1] ? Number(value[1]) - exp : -exp)));
|
|
33
|
-
|
|
35
|
+
value = Math[type](Number(value[0] + "e" + (value[1] ? Number(value[1]) - exp : -exp))); // Обратный сдвиг
|
|
36
|
+
|
|
34
37
|
value = value.toString().split("e");
|
|
35
38
|
return Number(value[0] + "e" + (value[1] ? Number(value[1]) + exp : exp));
|
|
36
|
-
}
|
|
39
|
+
} // Десятичное округление к ближайшему
|
|
40
|
+
|
|
37
41
|
|
|
38
|
-
// Десятичное округление к ближайшему
|
|
39
42
|
if (!Math.round10) {
|
|
40
43
|
Math.round10 = function (value, exp) {
|
|
41
44
|
return decimalAdjust("round", value, exp);
|
|
42
45
|
};
|
|
43
|
-
}
|
|
44
|
-
|
|
46
|
+
} // Десятичное округление вниз
|
|
47
|
+
|
|
48
|
+
|
|
45
49
|
if (!Math.floor10) {
|
|
46
50
|
Math.floor10 = function (value, exp) {
|
|
47
51
|
return decimalAdjust("floor", value, exp);
|
|
48
52
|
};
|
|
49
|
-
}
|
|
50
|
-
|
|
53
|
+
} // Десятичное округление вверх
|
|
54
|
+
|
|
55
|
+
|
|
51
56
|
if (!Math.ceil10) {
|
|
52
57
|
Math.ceil10 = function (value, exp) {
|
|
53
58
|
return decimalAdjust("ceil", value, exp);
|
|
54
59
|
};
|
|
55
60
|
}
|
|
56
61
|
})();
|
|
62
|
+
|
|
57
63
|
const addRangeDefault = (from, to, currentValues, decimalPlaces) => {
|
|
58
64
|
if (!(currentValues !== null && currentValues !== void 0 && currentValues.length)) return [{
|
|
59
65
|
from,
|
|
@@ -64,8 +70,10 @@ const addRangeDefault = (from, to, currentValues, decimalPlaces) => {
|
|
|
64
70
|
const isIncludesFrom = Boolean(acc.from) && range.from < acc.from && range.to >= acc.from;
|
|
65
71
|
const isIncludesTo = Boolean(acc.to) && range.from <= acc.to && range.to > acc.to;
|
|
66
72
|
const isRangeMustBeIncludet = Boolean(acc.from) && Boolean(acc.to) && acc.from <= range.from && acc.to >= range.to;
|
|
73
|
+
|
|
67
74
|
const processTo = () => {
|
|
68
75
|
const lastAccRange = acc.result[acc.result.length - 1];
|
|
76
|
+
|
|
69
77
|
if (acc.to < range.from) {
|
|
70
78
|
lastAccRange.to = acc.to;
|
|
71
79
|
acc.to = null;
|
|
@@ -82,6 +90,7 @@ const addRangeDefault = (from, to, currentValues, decimalPlaces) => {
|
|
|
82
90
|
acc.to = null;
|
|
83
91
|
}
|
|
84
92
|
};
|
|
93
|
+
|
|
85
94
|
if (!acc.from && !acc.to) acc.result = [...acc.result, range];else if (!acc.from && acc.to) processTo();else if (acc.from && acc.to) {
|
|
86
95
|
if (acc.from <= range.from) {
|
|
87
96
|
acc.result = [...acc.result, {
|
|
@@ -115,4 +124,5 @@ const addRangeDefault = (from, to, currentValues, decimalPlaces) => {
|
|
|
115
124
|
if (!result[result.length - 1].to) result[result.length - 1].to = to;
|
|
116
125
|
return result;
|
|
117
126
|
};
|
|
127
|
+
|
|
118
128
|
exports.addRangeDefault = addRangeDefault;
|