intelicoreact 1.6.20 → 1.6.21
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 +1 -102
- package/dist/Atomic/FormElements/AdvancedStatus/AdvancedStatus.js +1 -89
- package/dist/Atomic/FormElements/Calendar/Calendar.js +1 -232
- package/dist/Atomic/FormElements/Calendar/Calendar.props.js +1 -3
- package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.js +1 -101
- package/dist/Atomic/FormElements/CheckboxesLine/CheckboxesLine.js +1 -70
- package/dist/Atomic/FormElements/Datepicker/Datepicker.js +1 -350
- package/dist/Atomic/FormElements/Datepicker/Datepicker.props.js +1 -3
- package/dist/Atomic/FormElements/Datepicker/components/DatepickerCalendar.js +1 -177
- package/dist/Atomic/FormElements/Datepicker/components/DatepickerCalendar.props.js +1 -3
- package/dist/Atomic/FormElements/Dropdown/Dropdown.js +1 -561
- package/dist/Atomic/FormElements/Dropdown/components/DropdownLoader.js +1 -20
- package/dist/Atomic/FormElements/DropdownLiveSearch/DropdownLiveSearch.js +1 -405
- package/dist/Atomic/FormElements/FileLoader/FileLoader.js +1 -94
- package/dist/Atomic/FormElements/FileLoader/partial/LoadZone.js +1 -105
- package/dist/Atomic/FormElements/FileLoader/partial/LoadedContent.js +1 -67
- package/dist/Atomic/FormElements/FileLoaderDescription/FileLoaderDescription.js +1 -247
- package/dist/Atomic/FormElements/FileLoaderLocal/FileLoaderLocal.js +1 -160
- package/dist/Atomic/FormElements/FileLoaderLocalGroup/FileLoaderLocalGroup.js +1 -193
- package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN.js +1 -135
- package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN_old.js +1 -116
- package/dist/Atomic/FormElements/Input/Input.js +1 -467
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +1 -161
- package/dist/Atomic/FormElements/InputColor/InputColor.js +1 -64
- package/dist/Atomic/FormElements/InputCurrency/InputCurrency.js +1 -166
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.js +1 -354
- package/dist/Atomic/FormElements/InputDateRange/components/DateInput.js +1 -71
- package/dist/Atomic/FormElements/InputDateRange/components/Datepicker.js +1 -693
- package/dist/Atomic/FormElements/InputDateRange/components/OpenedPart.js +1 -254
- package/dist/Atomic/FormElements/InputDateRange/components/SelectItem.js +1 -32
- package/dist/Atomic/FormElements/InputDateRange/dependencies.js +1 -200
- package/dist/Atomic/FormElements/InputLink/InputLink.js +1 -99
- package/dist/Atomic/FormElements/InputMask/InputCarretPosition.js +1 -37
- package/dist/Atomic/FormElements/InputMask/InputMask.js +1 -1214
- package/dist/Atomic/FormElements/InputMask/config.js +1 -15
- package/dist/Atomic/FormElements/InputMask/functions.js +1 -58
- package/dist/Atomic/FormElements/InputMask2/InputMask2.js +1 -674
- package/dist/Atomic/FormElements/InputMask2/config.js +1 -15
- package/dist/Atomic/FormElements/InputMask2/functions.js +1 -58
- package/dist/Atomic/FormElements/InputMask3/InputMask3.js +1 -766
- package/dist/Atomic/FormElements/InputMask3/config.js +1 -15
- package/dist/Atomic/FormElements/InputMask3/functions.js +1 -58
- package/dist/Atomic/FormElements/InputWithAction/InputWithAction.js +1 -114
- package/dist/Atomic/FormElements/InputsRow/InputsRow.js +1 -140
- package/dist/Atomic/FormElements/Label/Label.js +1 -82
- package/dist/Atomic/FormElements/MobileCalendar/MobileCalendar.js +1 -506
- package/dist/Atomic/FormElements/MultiSelect/MultiSelect.js +1 -45
- package/dist/Atomic/FormElements/NumericInput/NumericInput.js +1 -331
- package/dist/Atomic/FormElements/RadioGroup/RadioGroup.js +1 -66
- package/dist/Atomic/FormElements/RadioGroupWithInput/RadioGroupWithInput.js +1 -80
- package/dist/Atomic/FormElements/RadioInput/RadioInput.js +1 -64
- package/dist/Atomic/FormElements/RadioRowSwitcher/RadioRowSwitcher.js +1 -54
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.js +1 -183
- package/dist/Atomic/FormElements/RangeInputs/RangeInputs.js +1 -209
- package/dist/Atomic/FormElements/RangeList/RangeList.js +1 -175
- package/dist/Atomic/FormElements/RangeList/partial/RangeListRow.js +1 -43
- package/dist/Atomic/FormElements/RangeSlider/RangeSlider.js +1 -443
- package/dist/Atomic/FormElements/RangeSlider2/RangeSlider2.js +1 -858
- package/dist/Atomic/FormElements/SwitchableRow/SwitchableRow.js +1 -39
- package/dist/Atomic/FormElements/Switcher/Switcher.js +1 -59
- package/dist/Atomic/FormElements/SwitcherCheckbox/SwitcherCheckbox.js +1 -50
- package/dist/Atomic/FormElements/SwitcherHide/SwitcherHide.js +1 -47
- package/dist/Atomic/FormElements/SwitcherRadio/SwitcherRadio.js +1 -96
- package/dist/Atomic/FormElements/SwitcherRange/SwitcherRange.js +1 -40
- package/dist/Atomic/FormElements/SwitcherRangeList/SwitcherRangeList.js +1 -64
- package/dist/Atomic/FormElements/SwitcherTagsDropdown/SwitcherTagsDropdown.js +1 -170
- package/dist/Atomic/FormElements/SwitcherTagsDropdown/partial/States.js +1 -202
- package/dist/Atomic/FormElements/SwitcherTextarea/SwitcherTextarea.js +1 -67
- package/dist/Atomic/FormElements/TagListToDropdown/TagListToDropdown.js +1 -115
- package/dist/Atomic/FormElements/TagsDropdown/TagsDropdown.js +1 -826
- package/dist/Atomic/FormElements/Text/Text.js +1 -125
- package/dist/Atomic/FormElements/TextSwitcher/TextSwitcher.js +1 -45
- package/dist/Atomic/FormElements/Textarea/Textarea.js +1 -80
- package/dist/Atomic/FormElements/TieredCheckboxes/TieredCheckboxes.js +1 -176
- package/dist/Atomic/FormElements/TieredCheckboxes/partial/AccordionWithCheckbox.js +1 -62
- package/dist/Atomic/FormElements/TimeRange/TimeRange.js +1 -127
- package/dist/Atomic/FormElements/UserContacts/UserContacts.js +1 -220
- package/dist/Atomic/FormElements/VariantsListRadio/VariantsListRadio.js +1 -83
- package/dist/Atomic/FormElements/VariantsListRadio/partials/VariantsListRadioItem.js +1 -82
- package/dist/Atomic/FormElements/WidgetPseudoTable/WidgetPseudoTable.js +1 -101
- package/dist/Atomic/FormElements/WidgetPseudoTable/partial/constructor.js +1 -29
- package/dist/Atomic/FormElements/WidgetWithSwitchableRows/WidgetWithSwitchableRows.js +1 -113
- package/dist/Atomic/FormElements/WidgetWithSwitchableRows/partial/constructor.js +1 -30
- package/dist/Atomic/Layout/Header/Header.js +1 -85
- package/dist/Atomic/Layout/Spinner/Spinner.js +1 -39
- package/dist/Atomic/UI/Accordion/Accordion.js +1 -118
- package/dist/Atomic/UI/Accordion/AccordionItem.js +1 -181
- package/dist/Atomic/UI/AccordionTable/AccordionTable.js +1 -238
- package/dist/Atomic/UI/AccordionText/AccordionText.js +1 -69
- package/dist/Atomic/UI/AdvancedTag/AdvTag.js +1 -207
- package/dist/Atomic/UI/AdvancedTag/AdvancedTags.js +1 -56
- package/dist/Atomic/UI/Alert/Alert.js +1 -72
- package/dist/Atomic/UI/Arrow/Arrow.js +1 -132
- package/dist/Atomic/UI/Box/Box.js +1 -52
- package/dist/Atomic/UI/Button/Button.js +1 -89
- package/dist/Atomic/UI/ButtonsBar/ButtonsBar.js +1 -72
- package/dist/Atomic/UI/Chart/Chart.js +1 -172
- package/dist/Atomic/UI/Chart/partial/Chart.constants.js +1 -95
- package/dist/Atomic/UI/Chart/partial/ChartTypeSwitcherIcon/ChartTypeSwitcherIcon.js +1 -80
- package/dist/Atomic/UI/Chart/partial/datasetSetters.js +1 -188
- package/dist/Atomic/UI/Chart/partial/optionsConstructor.js +1 -335
- package/dist/Atomic/UI/Chart/partial/optionsSetters.js +1 -43
- package/dist/Atomic/UI/Chart/partial/utils.js +1 -60
- package/dist/Atomic/UI/CircleProgressBar/CircleProgressBar.js +1 -109
- package/dist/Atomic/UI/DateTime/DateTime.js +1 -57
- package/dist/Atomic/UI/DebugContainer/DebugContainer.js +1 -44
- package/dist/Atomic/UI/DebugContainer/useDebugContainer.js +1 -15
- package/dist/Atomic/UI/DoubleString/DoubleString.js +1 -102
- package/dist/Atomic/UI/DynamicIcon/DynamicIcon.js +1 -226
- package/dist/Atomic/UI/ExampleChartIntegration/ExampleChartIntegration.js +1 -221
- package/dist/Atomic/UI/ExampleChartIntegration/partial/utils.js +1 -106
- package/dist/Atomic/UI/Hint/Hint.js +1 -193
- package/dist/Atomic/UI/Hint/partials/_utils.js +1 -51
- package/dist/Atomic/UI/Modal/Modal.js +1 -188
- package/dist/Atomic/UI/Modal/ModalHOC.js +1 -72
- package/dist/Atomic/UI/Modal/partials/ModalFooter.js +1 -46
- package/dist/Atomic/UI/Modal/partials/ModalTitle.js +1 -83
- package/dist/Atomic/UI/Modal/partials/useMobileModal.js +1 -200
- package/dist/Atomic/UI/MonoAccordion/MonoAccordion._test.js +1 -75
- package/dist/Atomic/UI/MonoAccordion/MonoAccordion.js +1 -80
- package/dist/Atomic/UI/NavLine/NavLine.js +1 -293
- package/dist/Atomic/UI/PageTitle/PageTitle.js +1 -75
- package/dist/Atomic/UI/PieChart/PieChart.js +1 -42
- package/dist/Atomic/UI/Price/Price.js +1 -22
- package/dist/Atomic/UI/PriceRange/PriceRange.js +1 -36
- package/dist/Atomic/UI/ProgressLine/ProgressLine.js +1 -71
- package/dist/Atomic/UI/Status/Status.js +1 -59
- package/dist/Atomic/UI/Table/Partials/TdCell.js +1 -87
- package/dist/Atomic/UI/Table/Partials/TdHeader.js +1 -38
- package/dist/Atomic/UI/Table/Partials/TdRow.js +1 -99
- package/dist/Atomic/UI/Table/Partials/TdTitle.js +1 -52
- package/dist/Atomic/UI/Table/Table.js +1 -63
- package/dist/Atomic/UI/Table/TdTypes/TdActions.js +1 -80
- package/dist/Atomic/UI/Table/TdTypes/TdPriority.js +1 -28
- package/dist/Atomic/UI/Table/TdTypes/TdRange.js +1 -13
- package/dist/Atomic/UI/Table/TdTypes/TdWeight.js +1 -53
- package/dist/Atomic/UI/Tag/Tag.js +1 -160
- package/dist/Atomic/UI/TagList/TagList.js +1 -251
- package/dist/Atomic/UI/UserBox/UserBox.js +1 -73
- package/dist/Atomic/UI/WizardStepper/constructor.js +1 -84
- package/dist/Atomic/UI/WizardStepper/index.js +1 -3
- package/dist/Atomic/UI/WizardStepper/ui/StateIcon/StateIcon.js +1 -37
- package/dist/Atomic/UI/WizardStepper/ui/StateIcon/index.js +1 -3
- package/dist/Atomic/UI/WizardStepper/ui/StepRow/StepRow.js +1 -61
- package/dist/Atomic/UI/WizardStepper/ui/StepRow/index.js +1 -3
- package/dist/Atomic/UI/WizardStepper/ui/StepWrapper/StepWrapper.js +1 -39
- package/dist/Atomic/UI/WizardStepper/ui/StepWrapper/index.js +1 -3
- package/dist/Atomic/UI/WizardStepper/ui/icons.js +1 -49
- package/dist/Atomic/UI/WizardStepper/ui/index.js +1 -3
- package/dist/Classes/AbortableFetch.js +1 -454
- package/dist/Classes/AnimatedHandler.js +1 -47
- package/dist/Classes/RESTAPI/index.js +1 -228
- package/dist/Classes/RESTAPI/partials/AbortableFetch.js +1 -457
- package/dist/Classes/RESTAPI/partials/ApiBase.js +1 -48
- package/dist/Classes/RESTAPI/partials/ApiRequestCreators.js +1 -112
- package/dist/Classes/RESTAPI/partials/ApiUtils.js +1 -189
- package/dist/Classes/RESTAPI/partials/CredentialsProcessing.js +1 -252
- package/dist/Classes/RESTAPI/partials/Utils.js +1 -92
- package/dist/Classes/RESTAPI/partials/_outerDependencies.js +1 -3
- package/dist/Classes/RESTAPI/partials/_utils.js +1 -197
- package/dist/Constants/index.constants.js +1 -78
- package/dist/Functions/Portal.js +1 -22
- package/dist/Functions/customEventListener.js +1 -96
- package/dist/Functions/dateTime.js +1 -149
- package/dist/Functions/fieldValueFormatters.js +1 -405
- package/dist/Functions/guards/assertions.js +1 -66
- package/dist/Functions/guards/safeValue.js +1 -30
- package/dist/Functions/guards/typeGuards.js +1 -116
- package/dist/Functions/hooks/useFormFieldsChangesManager.js +1 -95
- package/dist/Functions/locale/createTranslator.js +1 -32
- package/dist/Functions/operations.js +1 -130
- package/dist/Functions/presets/inputMaskPresets.js +1 -170
- package/dist/Functions/presets/inputPresets.js +1 -60
- package/dist/Functions/presets/mobileKeyboardTypesPresets.js +1 -45
- package/dist/Functions/schemas.js +1 -31
- package/dist/Functions/useBodyScrollLock.js +1 -17
- package/dist/Functions/useClickOutside.js +1 -15
- package/dist/Functions/useDebounce.js +1 -17
- package/dist/Functions/useFieldFocus.js +1 -84
- package/dist/Functions/useFormTools/form-drivers/ArrayWithObjects.js +1 -39
- package/dist/Functions/useFormTools/form-drivers/ObjectWithIterableObjects.js +1 -159
- package/dist/Functions/useFormTools/form-drivers/ObjectWithNamedKeyObjects.js +1 -78
- package/dist/Functions/useFormTools/functions/General.js +1 -134
- package/dist/Functions/useFormTools/functions/RenderFields.js +1 -111
- package/dist/Functions/useFormTools/functions/usePrevious.js +1 -12
- package/dist/Functions/useFormTools/index.js +1 -778
- package/dist/Functions/useInputHighlightError.js +1 -67
- package/dist/Functions/useIsMobile/useIsMobile.js +1 -53
- package/dist/Functions/useKeyPress/useHandleKeyPress.js +1 -21
- package/dist/Functions/useKeyPress/useKeyPress.js +1 -75
- package/dist/Functions/useLocalStorage.js +1 -34
- package/dist/Functions/useLocationParams.js +1 -27
- package/dist/Functions/useMediaQuery.js +1 -17
- package/dist/Functions/useMetaInfo.js +1 -43
- package/dist/Functions/useMouseUpOutside.js +1 -16
- package/dist/Functions/useOnlineStatus.js +1 -29
- package/dist/Functions/usePasswordChecker.js +1 -110
- package/dist/Functions/usePrevious.js +1 -12
- package/dist/Functions/useResize.js +1 -31
- package/dist/Functions/useScrollTo.js +1 -17
- package/dist/Functions/useToggle.js +1 -17
- package/dist/Functions/utils.js +1 -522
- package/dist/Langs.js +1 -168
- package/dist/Molecular/CustomIcons/components/AffiliateNetworks.js +1 -21
- package/dist/Molecular/CustomIcons/components/AlertCircle.js +1 -23
- package/dist/Molecular/CustomIcons/components/AppStore.js +1 -29
- package/dist/Molecular/CustomIcons/components/Arrow.js +1 -32
- package/dist/Molecular/CustomIcons/components/ArrowDown.js +1 -17
- package/dist/Molecular/CustomIcons/components/ArrowLeft.js +1 -22
- package/dist/Molecular/CustomIcons/components/ArrowRight.js +1 -22
- package/dist/Molecular/CustomIcons/components/ArrowUp.js +1 -17
- package/dist/Molecular/CustomIcons/components/Bell.js +1 -15
- package/dist/Molecular/CustomIcons/components/Button.js +1 -12
- package/dist/Molecular/CustomIcons/components/Campaigns.js +1 -16
- package/dist/Molecular/CustomIcons/components/Check.js +1 -14
- package/dist/Molecular/CustomIcons/components/Check2.js +1 -12
- package/dist/Molecular/CustomIcons/components/ChevronDown.js +1 -12
- package/dist/Molecular/CustomIcons/components/ChevronDownDisabled.js +1 -11
- package/dist/Molecular/CustomIcons/components/ChevronLeft.js +1 -11
- package/dist/Molecular/CustomIcons/components/ChevronRight.js +1 -11
- package/dist/Molecular/CustomIcons/components/ChevronUp.js +1 -11
- package/dist/Molecular/CustomIcons/components/ChevronUpDown.js +1 -27
- package/dist/Molecular/CustomIcons/components/Close.js +1 -14
- package/dist/Molecular/CustomIcons/components/ColumnsOrder.js +1 -17
- package/dist/Molecular/CustomIcons/components/Delete.js +1 -16
- package/dist/Molecular/CustomIcons/components/Edit.js +1 -15
- package/dist/Molecular/CustomIcons/components/Email.js +1 -31
- package/dist/Molecular/CustomIcons/components/FinturfLogo.js +1 -18
- package/dist/Molecular/CustomIcons/components/FinturfLogo2.js +1 -35
- package/dist/Molecular/CustomIcons/components/Flows.js +1 -15
- package/dist/Molecular/CustomIcons/components/Gift.js +1 -25
- package/dist/Molecular/CustomIcons/components/GoogleAuth.js +1 -29
- package/dist/Molecular/CustomIcons/components/GooglePlay.js +1 -29
- package/dist/Molecular/CustomIcons/components/HelpCircle.js +1 -19
- package/dist/Molecular/CustomIcons/components/HelpCircle2.js +1 -20
- package/dist/Molecular/CustomIcons/components/HelpCircleFilled.js +1 -19
- package/dist/Molecular/CustomIcons/components/Home.js +1 -16
- package/dist/Molecular/CustomIcons/components/Home2.js +1 -22
- package/dist/Molecular/CustomIcons/components/Key.js +1 -23
- package/dist/Molecular/CustomIcons/components/Landers.js +1 -20
- package/dist/Molecular/CustomIcons/components/Lock.js +1 -15
- package/dist/Molecular/CustomIcons/components/Mail.js +1 -26
- package/dist/Molecular/CustomIcons/components/Mastercard.js +1 -73
- package/dist/Molecular/CustomIcons/components/Minus.js +1 -25
- package/dist/Molecular/CustomIcons/components/Offers.js +1 -16
- package/dist/Molecular/CustomIcons/components/Pause.js +1 -28
- package/dist/Molecular/CustomIcons/components/PayPal.js +1 -41
- package/dist/Molecular/CustomIcons/components/PayPalLightLarge.js +1 -28
- package/dist/Molecular/CustomIcons/components/Phone.js +1 -30
- package/dist/Molecular/CustomIcons/components/Play.js +1 -25
- package/dist/Molecular/CustomIcons/components/Plus.js +1 -25
- package/dist/Molecular/CustomIcons/components/Profile.js +1 -16
- package/dist/Molecular/CustomIcons/components/QRCode.js +1 -29
- package/dist/Molecular/CustomIcons/components/Rectangle.js +1 -12
- package/dist/Molecular/CustomIcons/components/Revert.js +1 -13
- package/dist/Molecular/CustomIcons/components/Star.js +1 -14
- package/dist/Molecular/CustomIcons/components/Star2.js +1 -16
- package/dist/Molecular/CustomIcons/components/TrafficSources.js +1 -14
- package/dist/Molecular/CustomIcons/components/Trash.js +1 -15
- package/dist/Molecular/CustomIcons/components/TrashRed.js +1 -15
- package/dist/Molecular/CustomIcons/components/Triggers.js +1 -15
- package/dist/Molecular/CustomIcons/components/User.js +1 -25
- package/dist/Molecular/CustomIcons/components/Visa.js +1 -31
- package/dist/Molecular/CustomIcons/components/X.js +1 -12
- package/dist/Molecular/CustomIcons/index.js +1 -61
- package/dist/Molecular/FormElement/FormElement.js +1 -54
- package/dist/Molecular/FormWithDependOn/FormWithDependOn.js +1 -184
- package/dist/Molecular/FormWithDependOn/partials/_utils.js +1 -53
- package/dist/Molecular/InputAddress/InputAddress.js +1 -620
- package/dist/Molecular/InputPassword/InputPassword.js +1 -48
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,405 +1 @@
|
|
|
1
|
-
function e(e, t) {
|
|
2
|
-
(null == t || t > e.length) && (t = e.length);
|
|
3
|
-
for(var n = 0, l = Array(t); n < t; n++)l[n] = e[n];
|
|
4
|
-
return l;
|
|
5
|
-
}
|
|
6
|
-
function t(e, t, n) {
|
|
7
|
-
return t in e ? Object.defineProperty(e, t, {
|
|
8
|
-
value: n,
|
|
9
|
-
enumerable: !0,
|
|
10
|
-
configurable: !0,
|
|
11
|
-
writable: !0
|
|
12
|
-
}) : e[t] = n, e;
|
|
13
|
-
}
|
|
14
|
-
function n(e) {
|
|
15
|
-
for(var n = 1; n < arguments.length; n++){
|
|
16
|
-
var l = null != arguments[n] ? arguments[n] : {}, r = Object.keys(l);
|
|
17
|
-
"function" == typeof Object.getOwnPropertySymbols && (r = r.concat(Object.getOwnPropertySymbols(l).filter(function(e) {
|
|
18
|
-
return Object.getOwnPropertyDescriptor(l, e).enumerable;
|
|
19
|
-
}))), r.forEach(function(n) {
|
|
20
|
-
t(e, n, l[n]);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
return e;
|
|
24
|
-
}
|
|
25
|
-
function l(t, n) {
|
|
26
|
-
return function(e) {
|
|
27
|
-
if (Array.isArray(e)) return e;
|
|
28
|
-
}(t) || function(e, t) {
|
|
29
|
-
var n, l, r = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
|
|
30
|
-
if (null != r) {
|
|
31
|
-
var o = [], u = !0, i = !1;
|
|
32
|
-
try {
|
|
33
|
-
for(r = r.call(e); !(u = (n = r.next()).done) && (o.push(n.value), !t || o.length !== t); u = !0);
|
|
34
|
-
} catch (e) {
|
|
35
|
-
i = !0, l = e;
|
|
36
|
-
} finally{
|
|
37
|
-
try {
|
|
38
|
-
u || null == r.return || r.return();
|
|
39
|
-
} finally{
|
|
40
|
-
if (i) throw l;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return o;
|
|
44
|
-
}
|
|
45
|
-
}(t, n) || function(t, n) {
|
|
46
|
-
if (t) {
|
|
47
|
-
if ("string" == typeof t) return e(t, n);
|
|
48
|
-
var l = Object.prototype.toString.call(t).slice(8, -1);
|
|
49
|
-
if ("Object" === l && t.constructor && (l = t.constructor.name), "Map" === l || "Set" === l) return Array.from(l);
|
|
50
|
-
if ("Arguments" === l || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)) return e(t, n);
|
|
51
|
-
}
|
|
52
|
-
}(t, n) || function() {
|
|
53
|
-
throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
54
|
-
}();
|
|
55
|
-
}
|
|
56
|
-
Object.defineProperty(exports, "__esModule", {
|
|
57
|
-
value: !0
|
|
58
|
-
}), Object.defineProperty(exports, "default", {
|
|
59
|
-
enumerable: !0,
|
|
60
|
-
get: function() {
|
|
61
|
-
return b;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
var r = require("react/jsx-runtime"), o = p(require("classnames")), u = function(e, t) {
|
|
65
|
-
if (e && e.__esModule) return e;
|
|
66
|
-
if (null === e || (void 0 === e ? "undefined" : e && "undefined" != typeof Symbol && e.constructor === Symbol ? "symbol" : typeof e) != "object" && "function" != typeof e) return {
|
|
67
|
-
default: e
|
|
68
|
-
};
|
|
69
|
-
var n = m(t);
|
|
70
|
-
if (n && n.has(e)) return n.get(e);
|
|
71
|
-
var l = {
|
|
72
|
-
__proto__: null
|
|
73
|
-
}, r = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
74
|
-
for(var o in e)if ("default" !== o && Object.prototype.hasOwnProperty.call(e, o)) {
|
|
75
|
-
var u = r ? Object.getOwnPropertyDescriptor(e, o) : null;
|
|
76
|
-
u && (u.get || u.set) ? Object.defineProperty(l, o, u) : l[o] = e[o];
|
|
77
|
-
}
|
|
78
|
-
return l.default = e, n && n.set(e, l), l;
|
|
79
|
-
}(require("react")), i = require("react-dom"), c = require("react-feather"), a = require("../../../Functions/fieldValueFormatters"), s = require("../../../Functions/useDebounce"), d = p(require("../../../Functions/useIsMobile/useIsMobile")), f = p(require("../../Layout/Spinner/Spinner")), v = p(require("../RadioInput/RadioInput"));
|
|
80
|
-
function p(e) {
|
|
81
|
-
return e && e.__esModule ? e : {
|
|
82
|
-
default: e
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
function m(e) {
|
|
86
|
-
if ("function" != typeof WeakMap) return null;
|
|
87
|
-
var t = new WeakMap(), n = new WeakMap();
|
|
88
|
-
return (m = function(e) {
|
|
89
|
-
return e ? n : t;
|
|
90
|
-
})(e);
|
|
91
|
-
}
|
|
92
|
-
require("./DropdownLiveSearch.scss");
|
|
93
|
-
var h = 'dropdown-live-search', b = function(e) {
|
|
94
|
-
var p, m, b, g, _ = e.label, w = e.value, y = e.error, x = e.disabled, j = e.onChange, E = e.placeholder, S = e.className, L = e.isSearchable, N = e.doRequest, C = e.isLoading, I = e.options, k = e.fieldKey, O = e.id, M = e.isListTop, q = e.attributesOfNativeInput, P = e.withMobileLogic, R = e.tabIndex, H = e.isNotValidateASCII, D = void 0 !== H && H, A = e.noOptionsText, T = void 0 === A ? 'No options available' : A, F = e.testId, B = void 0 === F ? 'dropdown-live-search' : F, W = l((0, u.useState)(O || k || Math.random().toString(16).slice(2)), 1)[0], V = l((0, u.useState)(!1), 2), $ = V[0], U = V[1], z = l((0, u.useState)(!1), 2), K = z[0], X = z[1], G = (0, d.default)().isMobile && P && window.screen.width <= 768, J = (0, u.useMemo)(function() {
|
|
95
|
-
var e, t;
|
|
96
|
-
return null != (t = null == I || null == (e = I.find(function(e) {
|
|
97
|
-
return e.value === w;
|
|
98
|
-
})) ? void 0 : e.label) ? t : '';
|
|
99
|
-
}, [
|
|
100
|
-
w,
|
|
101
|
-
I
|
|
102
|
-
]), Q = l((0, u.useState)(''), 2), Y = Q[0], Z = Q[1], ee = l((0, u.useState)(!1), 2), et = ee[0], en = ee[1], el = (0, u.useRef)(null), er = (0, u.useRef)(null), eo = (0, u.useRef)(null), eu = (0, u.useRef)(null), ei = (0, u.useRef)(null), ec = (0, u.useRef)(null), ea = (0, u.useRef)(null), es = (0, u.useRef)(null), ed = l((0, u.useState)(!1), 2), ef = ed[0], ev = ed[1], ep = l((0, u.useState)(null), 2), em = ep[0], eh = ep[1], eb = l((0, u.useState)(!1), 2), eg = eb[0], e_ = eb[1], ew = l((0, u.useState)(0), 2), ey = ew[0], ex = ew[1], ej = l((0, u.useState)(1), 2), eE = ej[0], eS = ej[1], eL = (0, s.useDebounce)({
|
|
103
|
-
searchValue: Y,
|
|
104
|
-
delay: 600
|
|
105
|
-
}), eN = (0, u.useCallback)(function(e) {
|
|
106
|
-
if (N && 'function' == typeof N) {
|
|
107
|
-
var t, n = null == e ? void 0 : e.target;
|
|
108
|
-
Math.round(n.clientHeight + n.scrollTop) === n.scrollHeight && N(null != (t = ea.current) ? t : '', !0);
|
|
109
|
-
}
|
|
110
|
-
}, [
|
|
111
|
-
I
|
|
112
|
-
]), eC = function(e) {
|
|
113
|
-
var t = !(arguments.length > 1) || void 0 === arguments[1] || arguments[1];
|
|
114
|
-
t && en(!0), Z(e), ea.current = e;
|
|
115
|
-
}, eI = function(e) {
|
|
116
|
-
U(e), eC('', !1), e || en(!1);
|
|
117
|
-
}, ek = function() {
|
|
118
|
-
var e, t;
|
|
119
|
-
return null != (t = null != (e = document.querySelector('div#root')) ? e : document.querySelector('div#app')) ? t : document.querySelector('div#storybook-root');
|
|
120
|
-
}, eO = function() {
|
|
121
|
-
return document.getElementById(null == W ? void 0 : W.toString());
|
|
122
|
-
}, eM = function(e) {
|
|
123
|
-
e.target === (null == es ? void 0 : es.current) && (e.stopPropagation(), e.preventDefault(), eI(!1));
|
|
124
|
-
}, eq = function(e) {
|
|
125
|
-
$ || (e.preventDefault(), e.stopPropagation());
|
|
126
|
-
}, eP = function(e) {
|
|
127
|
-
var t;
|
|
128
|
-
!el.current || el.current.contains(e.target) || eO() && (null == (t = eO()) ? void 0 : t.contains(e.target)) || eI(!1);
|
|
129
|
-
}, eR = function(e) {
|
|
130
|
-
[
|
|
131
|
-
27
|
|
132
|
-
].includes(e.keyCode) && eI(!1);
|
|
133
|
-
}, eH = $ ? eP : function() {}, eD = function(e) {
|
|
134
|
-
var t, n = null == (t = e.target) ? void 0 : t.value;
|
|
135
|
-
D || (n = (0, a.formatToOnlyASCIICodeText)(n)), eC(n), !Y && et || e.target.value ? X(!1) : (null == j || j(''), eC(''), X(!0));
|
|
136
|
-
}, eA = function(e, t) {
|
|
137
|
-
if (!L) return e;
|
|
138
|
-
var n = et || G && P ? Y : J;
|
|
139
|
-
return e = e.replace(/["&<>]/g, function(e) {
|
|
140
|
-
var t;
|
|
141
|
-
return null != (t = ({
|
|
142
|
-
'"': '"',
|
|
143
|
-
'&': '&',
|
|
144
|
-
'<': '<',
|
|
145
|
-
'>': '>'
|
|
146
|
-
})[e]) ? t : '';
|
|
147
|
-
}), (n ? null == e ? void 0 : e.replace(RegExp(null == n ? void 0 : n.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&'), 'i'), function(e) {
|
|
148
|
-
return '<span class="bg--yellow">'.concat(e, "</span>");
|
|
149
|
-
}) : e) + (t ? '<span class="dropdown__list-item-postfix">'.concat(t, "</span>") : '');
|
|
150
|
-
}, eT = function(e, n, l) {
|
|
151
|
-
var u, i, a, s, d = e.label.toLowerCase(), f = null == Y ? void 0 : Y.toLowerCase();
|
|
152
|
-
return (0, r.jsxs)("button", {
|
|
153
|
-
type: "button",
|
|
154
|
-
"data-testid": "".concat(B, "-").concat(l || n, "-option"),
|
|
155
|
-
onClick: function() {
|
|
156
|
-
null == j || j(e.value), eI(!1);
|
|
157
|
-
},
|
|
158
|
-
className: (0, o.default)("".concat(h, "__list-item"), (t(s = {}, "".concat(h, "__list-item_active"), e.value === w), t(s, "".concat(h, "__list-item_disabled"), e.disabled), s), e.className),
|
|
159
|
-
children: [
|
|
160
|
-
!G || G && !P && (0, r.jsx)("span", {
|
|
161
|
-
className: (0, o.default)("".concat(h, "__active-icon"), t({}, "".concat(h, "__active-icon_active"), d === f)),
|
|
162
|
-
children: (0, r.jsx)(c.Check, {})
|
|
163
|
-
}),
|
|
164
|
-
(0, r.jsx)("p", {
|
|
165
|
-
title: e.label,
|
|
166
|
-
className: e.labelClassName || '',
|
|
167
|
-
dangerouslySetInnerHTML: {
|
|
168
|
-
__html: eA(e.label, e.postfix)
|
|
169
|
-
}
|
|
170
|
-
}),
|
|
171
|
-
G ? null != (a = null == e ? void 0 : e.customMobileIcon) ? a : (0, r.jsx)(v.default, {
|
|
172
|
-
value: e.value,
|
|
173
|
-
checked: null == w ? void 0 : w.toString()
|
|
174
|
-
}) : ''
|
|
175
|
-
]
|
|
176
|
-
}, null == (i = e.value) || null == (u = i.toString()) ? void 0 : u.replace(/ /g, '_'));
|
|
177
|
-
}, eF = function() {
|
|
178
|
-
var e, l, u;
|
|
179
|
-
return (0, r.jsx)("div", {
|
|
180
|
-
className: (0, o.default)("".concat(h, "__container-wrapper")),
|
|
181
|
-
ref: es,
|
|
182
|
-
onClick: G ? eM : function() {},
|
|
183
|
-
children: (0, r.jsx)("div", {
|
|
184
|
-
className: (0, o.default)("".concat(h, "__list-wrapper"), (t(l = {}, "".concat(h, "__list-wrapper--fixed-height"), eg), t(l, "".concat(h, "__list-wrapper--with-bottom-shadow"), em && G), t(l, "".concat(h, "__list-wrapper--with-bottom-shadow-hidden"), ey === eE), l)),
|
|
185
|
-
children: (0, r.jsxs)("div", {
|
|
186
|
-
id: "dropdown-live-search-list",
|
|
187
|
-
className: (0, o.default)("".concat(h, "__container"), t({}, "".concat(h, "__list-top"), M)),
|
|
188
|
-
ref: er,
|
|
189
|
-
children: [
|
|
190
|
-
G && (0, r.jsxs)("div", {
|
|
191
|
-
ref: eu,
|
|
192
|
-
className: (0, o.default)("".concat(h, "__list-header"), (t(u = {}, "".concat(h, "__list-header-with-shadow"), em && G), t(u, "".concat(h, "__list-header-with-shadow-hidden"), 0 === ey), u)),
|
|
193
|
-
children: [
|
|
194
|
-
(0, r.jsxs)("div", {
|
|
195
|
-
className: (0, o.default)("".concat(h, "__list-header-row")),
|
|
196
|
-
children: [
|
|
197
|
-
(0, r.jsx)("div", {
|
|
198
|
-
className: (0, o.default)("".concat(h, "__list-label")),
|
|
199
|
-
children: _
|
|
200
|
-
}),
|
|
201
|
-
(0, r.jsx)("div", {
|
|
202
|
-
className: (0, o.default)("".concat(h, "__list-close-icon")),
|
|
203
|
-
onClick: function() {
|
|
204
|
-
return eI(!1);
|
|
205
|
-
},
|
|
206
|
-
children: (0, r.jsx)(c.X, {
|
|
207
|
-
onClick: function() {
|
|
208
|
-
return eI(!1);
|
|
209
|
-
}
|
|
210
|
-
})
|
|
211
|
-
})
|
|
212
|
-
]
|
|
213
|
-
}),
|
|
214
|
-
L && (0, r.jsx)("input", n({
|
|
215
|
-
ref: ec,
|
|
216
|
-
className: "".concat(h, "__input"),
|
|
217
|
-
value: $ ? Y : J,
|
|
218
|
-
onChange: eD,
|
|
219
|
-
placeholder: E,
|
|
220
|
-
onFocus: eq,
|
|
221
|
-
tabIndex: -1
|
|
222
|
-
}, q))
|
|
223
|
-
]
|
|
224
|
-
}),
|
|
225
|
-
(0, r.jsxs)("div", {
|
|
226
|
-
className: (0, o.default)("".concat(h, "__list"), {
|
|
227
|
-
disabled: C
|
|
228
|
-
}),
|
|
229
|
-
ref: eo,
|
|
230
|
-
children: [
|
|
231
|
-
null == I ? void 0 : I.map(function(e) {
|
|
232
|
-
return eT(e);
|
|
233
|
-
}),
|
|
234
|
-
!(null == I ? void 0 : I.length) && (0, r.jsx)("div", {
|
|
235
|
-
className: "".concat(h, "__list-item ").concat(h, "__list-item--no-options"),
|
|
236
|
-
children: T
|
|
237
|
-
})
|
|
238
|
-
]
|
|
239
|
-
}),
|
|
240
|
-
C && $ && (0, r.jsx)(f.default, {
|
|
241
|
-
size: (null != (e = null == I ? void 0 : I.length) ? e : 0) <= 3 ? 'small' : null
|
|
242
|
-
})
|
|
243
|
-
]
|
|
244
|
-
})
|
|
245
|
-
})
|
|
246
|
-
});
|
|
247
|
-
}, eB = function() {
|
|
248
|
-
var e = document.createElement('div');
|
|
249
|
-
e.setAttribute('id', null == W ? void 0 : W.toString()), e.classList.add('dropdown__container'), G && e.addEventListener('click', function(e) {
|
|
250
|
-
e.target.id === W && eI(!1);
|
|
251
|
-
});
|
|
252
|
-
try {
|
|
253
|
-
null == (t = eO()) || t.remove();
|
|
254
|
-
} finally{
|
|
255
|
-
if (G) {
|
|
256
|
-
try {
|
|
257
|
-
null == (r = document.getElementById("mlw-".concat(W))) || r.remove();
|
|
258
|
-
} catch (e) {}
|
|
259
|
-
var t, n, l, r, o = document.createElement('div');
|
|
260
|
-
o.classList.add('dropdown-live-search-mobile'), o.setAttribute('id', "mlw-".concat(W)), null == o || o.append(e), null == (l = ek()) || l.append(o);
|
|
261
|
-
} else null == (n = ek()) || n.append(e);
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
return ((0, u.useEffect)(function() {
|
|
265
|
-
return document.addEventListener('click', eP, !0), function() {
|
|
266
|
-
return document.removeEventListener('click', eP, !0);
|
|
267
|
-
};
|
|
268
|
-
}, []), (0, u.useEffect)(function() {
|
|
269
|
-
(null == I ? void 0 : I.length) === 1 && Y === I[0].label && (eC(I[0].label), null == j || j(I[0].value));
|
|
270
|
-
}, [
|
|
271
|
-
I
|
|
272
|
-
]), (0, u.useEffect)(function() {
|
|
273
|
-
L && (eL || K) && (null == N || N(eL), K && X(!1));
|
|
274
|
-
}, [
|
|
275
|
-
eL,
|
|
276
|
-
K
|
|
277
|
-
]), (0, u.useEffect)(function() {
|
|
278
|
-
G && P && eB();
|
|
279
|
-
}, [
|
|
280
|
-
G,
|
|
281
|
-
P
|
|
282
|
-
]), (0, u.useEffect)(function() {
|
|
283
|
-
if ($ && G && (null == eo ? void 0 : eo.current) && !Y) {
|
|
284
|
-
var e, t, n, l;
|
|
285
|
-
eh((null == eo || null == (e = eo.current) ? void 0 : e.scrollHeight) > (null == eo || null == (t = eo.current) ? void 0 : t.clientHeight)), e_(em || (null == eo || null == (n = eo.current) ? void 0 : n.scrollHeight) > (null == eo || null == (l = eo.current) ? void 0 : l.clientHeight));
|
|
286
|
-
}
|
|
287
|
-
}, [
|
|
288
|
-
$,
|
|
289
|
-
G,
|
|
290
|
-
em,
|
|
291
|
-
null == eo ? void 0 : eo.current,
|
|
292
|
-
null == eo || null == (m = eo.current) ? void 0 : m.scrollHeight,
|
|
293
|
-
null == eo || null == (b = eo.current) ? void 0 : b.clientHeight
|
|
294
|
-
]), (0, u.useLayoutEffect)(function() {
|
|
295
|
-
var e = document.getElementById('dropdown-live-search-list');
|
|
296
|
-
if ((e || $) && (!P || !G)) {
|
|
297
|
-
var t, n = null == el || null == (t = el.current) ? void 0 : t.clientWidth;
|
|
298
|
-
e && (e.style.minWidth = "".concat(n, "px"));
|
|
299
|
-
}
|
|
300
|
-
}, [
|
|
301
|
-
el,
|
|
302
|
-
$,
|
|
303
|
-
P
|
|
304
|
-
]), (0, u.useEffect)(function() {
|
|
305
|
-
if (!$ && (ev(!1), P && G && eC('')), $ && eo && eo.current) {
|
|
306
|
-
if (G && P) {
|
|
307
|
-
var e;
|
|
308
|
-
null == N || N('').then(function() {
|
|
309
|
-
setTimeout(function() {
|
|
310
|
-
if (eo.current && (null == er ? void 0 : er.current) && (null == eu ? void 0 : eu.current)) {
|
|
311
|
-
var e, t, n, l;
|
|
312
|
-
eo.current.style.maxHeight = "".concat((null == er || null == (t = er.current) || null == (e = t.getBoundingClientRect()) ? void 0 : e.height) - (null == eu || null == (l = eu.current) || null == (n = l.getBoundingClientRect()) ? void 0 : n.height), "px");
|
|
313
|
-
}
|
|
314
|
-
}, 1);
|
|
315
|
-
}), null == ec || null == (e = ec.current) || e.focus();
|
|
316
|
-
}
|
|
317
|
-
eo.current.addEventListener('scroll', eN);
|
|
318
|
-
}
|
|
319
|
-
return function() {
|
|
320
|
-
removeEventListener('scroll', eN);
|
|
321
|
-
};
|
|
322
|
-
}, [
|
|
323
|
-
$,
|
|
324
|
-
eo
|
|
325
|
-
]), (0, u.useLayoutEffect)(function() {
|
|
326
|
-
var e;
|
|
327
|
-
return G ? (window.removeEventListener('mousewheel', eH), window.removeEventListener('scroll', eH), window.removeEventListener('touchmove', eH)) : (window.addEventListener('mousewheel', eH), window.addEventListener('scroll', eH), window.addEventListener('touchmove', eH)), null == (e = eO()) || e.addEventListener('click', eH), window.addEventListener('keyup', eR), function() {
|
|
328
|
-
var e;
|
|
329
|
-
window.removeEventListener('mousewheel', eH), window.removeEventListener('scroll', eH), window.removeEventListener('touchmove', eH), window.removeEventListener('keyup', eR), null == (e = eO()) || e.removeEventListener('click', eH);
|
|
330
|
-
};
|
|
331
|
-
}, [
|
|
332
|
-
eO
|
|
333
|
-
]), (0, u.useEffect)(function() {
|
|
334
|
-
var e, t = function(e) {
|
|
335
|
-
var t, n;
|
|
336
|
-
ex(Number.parseInt(null == (n = e.target) || null == (t = n.scrollTop) ? void 0 : t.toString(), 10));
|
|
337
|
-
};
|
|
338
|
-
return $ && G && (null == eo ? void 0 : eo.current) && (null == eo || null == (e = eo.current) || e.addEventListener('scroll', t)), function() {
|
|
339
|
-
var e;
|
|
340
|
-
null == eo || null == (e = eo.current) || e.removeEventListener('scroll', t);
|
|
341
|
-
};
|
|
342
|
-
}, [
|
|
343
|
-
$,
|
|
344
|
-
G,
|
|
345
|
-
null == eo ? void 0 : eo.current
|
|
346
|
-
]), (0, u.useEffect)(function() {
|
|
347
|
-
if (null == eo ? void 0 : eo.current) {
|
|
348
|
-
var e, t, n;
|
|
349
|
-
eS(Number.parseInt((e = (null == eo || null == (t = eo.current) ? void 0 : t.scrollHeight) - (null == eo || null == (n = eo.current) ? void 0 : n.clientHeight), e.toString()), 10));
|
|
350
|
-
}
|
|
351
|
-
}, [
|
|
352
|
-
ey,
|
|
353
|
-
null == eo ? void 0 : eo.current
|
|
354
|
-
]), I) ? (0, r.jsxs)("div", {
|
|
355
|
-
className: (0, o.default)(h, S, (t(g = {
|
|
356
|
-
disabled: x
|
|
357
|
-
}, "".concat(h, "-mobile"), G), t(g, "".concat(h, "--focused"), $), g)),
|
|
358
|
-
ref: el,
|
|
359
|
-
children: [
|
|
360
|
-
(0, r.jsxs)("button", {
|
|
361
|
-
type: "button",
|
|
362
|
-
"data-testid": B,
|
|
363
|
-
className: "".concat(h, "__trigger input__wrap ").concat($ ? 'input__wrap--focus' : '', " ").concat(!w ? 'placeholder' : '', " ").concat(y ? 'error' : ''),
|
|
364
|
-
onClick: function() {
|
|
365
|
-
return L ? null : eI(!$);
|
|
366
|
-
},
|
|
367
|
-
onMouseDown: function() {
|
|
368
|
-
return ev(!0);
|
|
369
|
-
},
|
|
370
|
-
onFocus: function() {
|
|
371
|
-
return ef ? null : eI(!0);
|
|
372
|
-
},
|
|
373
|
-
tabIndex: R,
|
|
374
|
-
children: [
|
|
375
|
-
L ? (0, r.jsx)("input", n({
|
|
376
|
-
ref: ei,
|
|
377
|
-
className: "".concat(h, "__input"),
|
|
378
|
-
value: $ ? G && P || !et ? J : Y : J,
|
|
379
|
-
onChange: eD,
|
|
380
|
-
placeholder: E,
|
|
381
|
-
onFocus: eq,
|
|
382
|
-
onClick: function(e) {
|
|
383
|
-
var t, n;
|
|
384
|
-
$ || eI(!0), G && P ? (e.preventDefault(), e.stopPropagation(), e.target && (null == (t = e.target) || t.blur())) : e.target && (null == (n = e.target) || n.select());
|
|
385
|
-
},
|
|
386
|
-
tabIndex: -1
|
|
387
|
-
}, q)) : (0, r.jsx)("span", {
|
|
388
|
-
className: "text",
|
|
389
|
-
children: J || E
|
|
390
|
-
}),
|
|
391
|
-
(0, r.jsx)("span", {
|
|
392
|
-
className: (0, o.default)("".concat(h, "__arrow"), t({}, "".concat(h, "__arrow_active"), $)),
|
|
393
|
-
onClick: function() {
|
|
394
|
-
return eI(!$);
|
|
395
|
-
},
|
|
396
|
-
children: G ? (0, r.jsx)(c.Code, {
|
|
397
|
-
className: "mobile-icon"
|
|
398
|
-
}) : $ ? (0, r.jsx)(c.ChevronUp, {}) : (0, r.jsx)(c.ChevronDown, {})
|
|
399
|
-
})
|
|
400
|
-
]
|
|
401
|
-
}),
|
|
402
|
-
$ && (G && P ? (p = eO()) ? (0, i.createPortal)(eF(), p) : null : eF())
|
|
403
|
-
]
|
|
404
|
-
}) : null;
|
|
405
|
-
};
|
|
1
|
+
function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,l=Array(t);n<t;n++)l[n]=e[n];return l}function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e){for(var n=1;n<arguments.length;n++){var l=null!=arguments[n]?arguments[n]:{},r=Object.keys(l);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(l).filter(function(e){return Object.getOwnPropertyDescriptor(l,e).enumerable}))),r.forEach(function(n){t(e,n,l[n])})}return e}function l(t,n){return function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,l,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],u=!0,i=!1;try{for(r=r.call(e);!(u=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);u=!0);}catch(e){i=!0,l=e}finally{try{u||null==r.return||r.return()}finally{if(i)throw l}}return o}}(t,n)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var l=Object.prototype.toString.call(t).slice(8,-1);if("Object"===l&&t.constructor&&(l=t.constructor.name),"Map"===l||"Set"===l)return Array.from(l);if("Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l))return e(t,n)}}(t,n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return b}});var r=require("react/jsx-runtime"),o=p(require("classnames")),u=function(e,t){if(e&&e.__esModule)return e;if(null===e||(void 0===e?"undefined":e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)!="object"&&"function"!=typeof e)return{default:e};var n=m(t);if(n&&n.has(e))return n.get(e);var l={__proto__:null},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var u=r?Object.getOwnPropertyDescriptor(e,o):null;u&&(u.get||u.set)?Object.defineProperty(l,o,u):l[o]=e[o]}return l.default=e,n&&n.set(e,l),l}(require("react")),i=require("react-dom"),c=require("react-feather"),a=require("../../../Functions/fieldValueFormatters"),s=require("../../../Functions/useDebounce"),d=p(require("../../../Functions/useIsMobile/useIsMobile")),f=p(require("../../Layout/Spinner/Spinner")),v=p(require("../RadioInput/RadioInput"));function p(e){return e&&e.__esModule?e:{default:e}}function m(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(m=function(e){return e?n:t})(e)}require("./DropdownLiveSearch.scss");var h="dropdown-live-search",b=function(e){var p,m,b,g,_=e.label,w=e.value,y=e.error,x=e.disabled,j=e.onChange,E=e.placeholder,S=e.className,L=e.isSearchable,N=e.doRequest,C=e.isLoading,I=e.options,k=e.fieldKey,O=e.id,M=e.isListTop,q=e.attributesOfNativeInput,P=e.withMobileLogic,R=e.tabIndex,H=e.isNotValidateASCII,D=void 0!==H&&H,A=e.noOptionsText,T=void 0===A?"No options available":A,F=e.testId,B=void 0===F?"dropdown-live-search":F,W=l((0,u.useState)(O||k||Math.random().toString(16).slice(2)),1)[0],V=l((0,u.useState)(!1),2),$=V[0],U=V[1],z=l((0,u.useState)(!1),2),K=z[0],X=z[1],G=(0,d.default)().isMobile&&P&&window.screen.width<=768,J=(0,u.useMemo)(function(){var e,t;return null!=(t=null==I||null==(e=I.find(function(e){return e.value===w}))?void 0:e.label)?t:""},[w,I]),Q=l((0,u.useState)(""),2),Y=Q[0],Z=Q[1],ee=l((0,u.useState)(!1),2),et=ee[0],en=ee[1],el=(0,u.useRef)(null),er=(0,u.useRef)(null),eo=(0,u.useRef)(null),eu=(0,u.useRef)(null),ei=(0,u.useRef)(null),ec=(0,u.useRef)(null),ea=(0,u.useRef)(null),es=(0,u.useRef)(null),ed=l((0,u.useState)(!1),2),ef=ed[0],ev=ed[1],ep=l((0,u.useState)(null),2),em=ep[0],eh=ep[1],eb=l((0,u.useState)(!1),2),eg=eb[0],e_=eb[1],ew=l((0,u.useState)(0),2),ey=ew[0],ex=ew[1],ej=l((0,u.useState)(1),2),eE=ej[0],eS=ej[1],eL=(0,s.useDebounce)({searchValue:Y,delay:600}),eN=(0,u.useCallback)(function(e){if(N&&"function"==typeof N){var t,n=null==e?void 0:e.target;Math.round(n.clientHeight+n.scrollTop)===n.scrollHeight&&N(null!=(t=ea.current)?t:"",!0)}},[I]),eC=function(e){var t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];t&&en(!0),Z(e),ea.current=e},eI=function(e){U(e),eC("",!1),e||en(!1)},ek=function(){var e,t;return null!=(t=null!=(e=document.querySelector("div#root"))?e:document.querySelector("div#app"))?t:document.querySelector("div#storybook-root")},eO=function(){return document.getElementById(null==W?void 0:W.toString())},eM=function(e){e.target===(null==es?void 0:es.current)&&(e.stopPropagation(),e.preventDefault(),eI(!1))},eq=function(e){$||(e.preventDefault(),e.stopPropagation())},eP=function(e){var t;!el.current||el.current.contains(e.target)||eO()&&(null==(t=eO())?void 0:t.contains(e.target))||eI(!1)},eR=function(e){[27].includes(e.keyCode)&&eI(!1)},eH=$?eP:function(){},eD=function(e){var t,n=null==(t=e.target)?void 0:t.value;D||(n=(0,a.formatToOnlyASCIICodeText)(n)),eC(n),!Y&&et||e.target.value?X(!1):(null==j||j(""),eC(""),X(!0))},eA=function(e,t){if(!L)return e;var n=et||G&&P?Y:J;return e=e.replace(/["&<>]/g,function(e){var t;return null!=(t=({'"':""","&":"&","<":"<",">":">"})[e])?t:""}),(n?null==e?void 0:e.replace(RegExp(null==n?void 0:n.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&"),"i"),function(e){return'<span class="bg--yellow">'.concat(e,"</span>")}):e)+(t?'<span class="dropdown__list-item-postfix">'.concat(t,"</span>"):"")},eT=function(e,n,l){var u,i,a,s,d=e.label.toLowerCase(),f=null==Y?void 0:Y.toLowerCase();return(0,r.jsxs)("button",{type:"button","data-testid":"".concat(B,"-").concat(l||n,"-option"),onClick:function(){null==j||j(e.value),eI(!1)},className:(0,o.default)("".concat(h,"__list-item"),(t(s={},"".concat(h,"__list-item_active"),e.value===w),t(s,"".concat(h,"__list-item_disabled"),e.disabled),s),e.className),children:[!G||G&&!P&&(0,r.jsx)("span",{className:(0,o.default)("".concat(h,"__active-icon"),t({},"".concat(h,"__active-icon_active"),d===f)),children:(0,r.jsx)(c.Check,{})}),(0,r.jsx)("p",{title:e.label,className:e.labelClassName||"",dangerouslySetInnerHTML:{__html:eA(e.label,e.postfix)}}),G?null!=(a=null==e?void 0:e.customMobileIcon)?a:(0,r.jsx)(v.default,{value:e.value,checked:null==w?void 0:w.toString()}):""]},null==(i=e.value)||null==(u=i.toString())?void 0:u.replace(/ /g,"_"))},eF=function(){var e,l,u;return(0,r.jsx)("div",{className:(0,o.default)("".concat(h,"__container-wrapper")),ref:es,onClick:G?eM:function(){},children:(0,r.jsx)("div",{className:(0,o.default)("".concat(h,"__list-wrapper"),(t(l={},"".concat(h,"__list-wrapper--fixed-height"),eg),t(l,"".concat(h,"__list-wrapper--with-bottom-shadow"),em&&G),t(l,"".concat(h,"__list-wrapper--with-bottom-shadow-hidden"),ey===eE),l)),children:(0,r.jsxs)("div",{id:"dropdown-live-search-list",className:(0,o.default)("".concat(h,"__container"),t({},"".concat(h,"__list-top"),M)),ref:er,children:[G&&(0,r.jsxs)("div",{ref:eu,className:(0,o.default)("".concat(h,"__list-header"),(t(u={},"".concat(h,"__list-header-with-shadow"),em&&G),t(u,"".concat(h,"__list-header-with-shadow-hidden"),0===ey),u)),children:[(0,r.jsxs)("div",{className:(0,o.default)("".concat(h,"__list-header-row")),children:[(0,r.jsx)("div",{className:(0,o.default)("".concat(h,"__list-label")),children:_}),(0,r.jsx)("div",{className:(0,o.default)("".concat(h,"__list-close-icon")),onClick:function(){return eI(!1)},children:(0,r.jsx)(c.X,{onClick:function(){return eI(!1)}})})]}),L&&(0,r.jsx)("input",n({ref:ec,className:"".concat(h,"__input"),value:$?Y:J,onChange:eD,placeholder:E,onFocus:eq,tabIndex:-1},q))]}),(0,r.jsxs)("div",{className:(0,o.default)("".concat(h,"__list"),{disabled:C}),ref:eo,children:[null==I?void 0:I.map(function(e){return eT(e)}),!(null==I?void 0:I.length)&&(0,r.jsx)("div",{className:"".concat(h,"__list-item ").concat(h,"__list-item--no-options"),children:T})]}),C&&$&&(0,r.jsx)(f.default,{size:(null!=(e=null==I?void 0:I.length)?e:0)<=3?"small":null})]})})})},eB=function(){var e=document.createElement("div");e.setAttribute("id",null==W?void 0:W.toString()),e.classList.add("dropdown__container"),G&&e.addEventListener("click",function(e){e.target.id===W&&eI(!1)});try{null==(t=eO())||t.remove()}finally{if(G){try{null==(r=document.getElementById("mlw-".concat(W)))||r.remove()}catch(e){}var t,n,l,r,o=document.createElement("div");o.classList.add("dropdown-live-search-mobile"),o.setAttribute("id","mlw-".concat(W)),null==o||o.append(e),null==(l=ek())||l.append(o)}else null==(n=ek())||n.append(e)}};return((0,u.useEffect)(function(){return document.addEventListener("click",eP,!0),function(){return document.removeEventListener("click",eP,!0)}},[]),(0,u.useEffect)(function(){(null==I?void 0:I.length)===1&&Y===I[0].label&&(eC(I[0].label),null==j||j(I[0].value))},[I]),(0,u.useEffect)(function(){L&&(eL||K)&&(null==N||N(eL),K&&X(!1))},[eL,K]),(0,u.useEffect)(function(){G&&P&&eB()},[G,P]),(0,u.useEffect)(function(){if($&&G&&(null==eo?void 0:eo.current)&&!Y){var e,t,n,l;eh((null==eo||null==(e=eo.current)?void 0:e.scrollHeight)>(null==eo||null==(t=eo.current)?void 0:t.clientHeight)),e_(em||(null==eo||null==(n=eo.current)?void 0:n.scrollHeight)>(null==eo||null==(l=eo.current)?void 0:l.clientHeight))}},[$,G,em,null==eo?void 0:eo.current,null==eo||null==(m=eo.current)?void 0:m.scrollHeight,null==eo||null==(b=eo.current)?void 0:b.clientHeight]),(0,u.useLayoutEffect)(function(){var e=document.getElementById("dropdown-live-search-list");if((e||$)&&(!P||!G)){var t,n=null==el||null==(t=el.current)?void 0:t.clientWidth;e&&(e.style.minWidth="".concat(n,"px"))}},[el,$,P]),(0,u.useEffect)(function(){if(!$&&(ev(!1),P&&G&&eC("")),$&&eo&&eo.current){if(G&&P){var e;null==N||N("").then(function(){setTimeout(function(){if(eo.current&&(null==er?void 0:er.current)&&(null==eu?void 0:eu.current)){var e,t,n,l;eo.current.style.maxHeight="".concat((null==er||null==(t=er.current)||null==(e=t.getBoundingClientRect())?void 0:e.height)-(null==eu||null==(l=eu.current)||null==(n=l.getBoundingClientRect())?void 0:n.height),"px")}},1)}),null==ec||null==(e=ec.current)||e.focus()}eo.current.addEventListener("scroll",eN)}return function(){removeEventListener("scroll",eN)}},[$,eo]),(0,u.useLayoutEffect)(function(){var e;return G?(window.removeEventListener("mousewheel",eH),window.removeEventListener("scroll",eH),window.removeEventListener("touchmove",eH)):(window.addEventListener("mousewheel",eH),window.addEventListener("scroll",eH),window.addEventListener("touchmove",eH)),null==(e=eO())||e.addEventListener("click",eH),window.addEventListener("keyup",eR),function(){var e;window.removeEventListener("mousewheel",eH),window.removeEventListener("scroll",eH),window.removeEventListener("touchmove",eH),window.removeEventListener("keyup",eR),null==(e=eO())||e.removeEventListener("click",eH)}},[eO]),(0,u.useEffect)(function(){var e,t=function(e){var t,n;ex(Number.parseInt(null==(n=e.target)||null==(t=n.scrollTop)?void 0:t.toString(),10))};return $&&G&&(null==eo?void 0:eo.current)&&(null==eo||null==(e=eo.current)||e.addEventListener("scroll",t)),function(){var e;null==eo||null==(e=eo.current)||e.removeEventListener("scroll",t)}},[$,G,null==eo?void 0:eo.current]),(0,u.useEffect)(function(){if(null==eo?void 0:eo.current){var e,t,n;eS(Number.parseInt((e=(null==eo||null==(t=eo.current)?void 0:t.scrollHeight)-(null==eo||null==(n=eo.current)?void 0:n.clientHeight),e.toString()),10))}},[ey,null==eo?void 0:eo.current]),I)?(0,r.jsxs)("div",{className:(0,o.default)(h,S,(t(g={disabled:x},"".concat(h,"-mobile"),G),t(g,"".concat(h,"--focused"),$),g)),ref:el,children:[(0,r.jsxs)("button",{type:"button","data-testid":B,className:"".concat(h,"__trigger input__wrap ").concat($?"input__wrap--focus":""," ").concat(!w?"placeholder":""," ").concat(y?"error":""),onClick:function(){return L?null:eI(!$)},onMouseDown:function(){return ev(!0)},onFocus:function(){return ef?null:eI(!0)},tabIndex:R,children:[L?(0,r.jsx)("input",n({ref:ei,className:"".concat(h,"__input"),value:$?G&&P||!et?J:Y:J,onChange:eD,placeholder:E,onFocus:eq,onClick:function(e){var t,n;$||eI(!0),G&&P?(e.preventDefault(),e.stopPropagation(),e.target&&(null==(t=e.target)||t.blur())):e.target&&(null==(n=e.target)||n.select())},tabIndex:-1},q)):(0,r.jsx)("span",{className:"text",children:J||E}),(0,r.jsx)("span",{className:(0,o.default)("".concat(h,"__arrow"),t({},"".concat(h,"__arrow_active"),$)),onClick:function(){return eI(!$)},children:G?(0,r.jsx)(c.Code,{className:"mobile-icon"}):$?(0,r.jsx)(c.ChevronUp,{}):(0,r.jsx)(c.ChevronDown,{})})]}),$&&(G&&P?(p=eO())?(0,i.createPortal)(eF(),p):null:eF())]}):null};
|
|
@@ -1,94 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import cn from "classnames";
|
|
4
|
-
|
|
5
|
-
import LoadZone from "./partial/LoadZone";
|
|
6
|
-
import LoadedContent from "./partial/LoadedContent";
|
|
7
|
-
|
|
8
|
-
import "./FileLoader.scss";
|
|
9
|
-
|
|
10
|
-
const RC = "file-loader";
|
|
11
|
-
|
|
12
|
-
const FileLoader = (props) => {
|
|
13
|
-
const {
|
|
14
|
-
// будет использован в качестве id инпута в LoadZone, обязателен для корректной работы
|
|
15
|
-
fieldKey,
|
|
16
|
-
// null или структура { name, path, ... остальное по желанию }
|
|
17
|
-
value,
|
|
18
|
-
disabled,
|
|
19
|
-
error,
|
|
20
|
-
|
|
21
|
-
className,
|
|
22
|
-
placeholder,
|
|
23
|
-
|
|
24
|
-
onChange,
|
|
25
|
-
doLoad,
|
|
26
|
-
filterFiles,
|
|
27
|
-
processErrors,
|
|
28
|
-
|
|
29
|
-
isBlockNullValues,
|
|
30
|
-
isDisableErrorsClass = true,
|
|
31
|
-
|
|
32
|
-
uploadIcon,
|
|
33
|
-
downloadIcon,
|
|
34
|
-
deleteIcon,
|
|
35
|
-
spiner,
|
|
36
|
-
|
|
37
|
-
isIconAfter,
|
|
38
|
-
isLinkTypeDownload = false,
|
|
39
|
-
isUseLinkTitle = false,
|
|
40
|
-
attributesOfNativeInput = {},
|
|
41
|
-
} = props;
|
|
42
|
-
|
|
43
|
-
const [isLoadContent, setIsLoadContent] = useState(false);
|
|
44
|
-
const [dragenter, setDragenter] = useState(false);
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<div
|
|
48
|
-
className={cn(RC, className, {
|
|
49
|
-
[`${RC}_load-content`]: isLoadContent,
|
|
50
|
-
[`${RC}_load-zone`]: !value,
|
|
51
|
-
[`${RC}_hover`]: dragenter,
|
|
52
|
-
[`${RC}_disabled`]: disabled,
|
|
53
|
-
[`${RC}_error`]: !isDisableErrorsClass && Boolean(error),
|
|
54
|
-
})}
|
|
55
|
-
>
|
|
56
|
-
{isLoadContent && spiner}
|
|
57
|
-
|
|
58
|
-
{!doLoad && "develop error: no doLoad"}
|
|
59
|
-
|
|
60
|
-
{Boolean(doLoad) && Boolean(value) && (
|
|
61
|
-
<LoadedContent
|
|
62
|
-
RC={RC}
|
|
63
|
-
value={value}
|
|
64
|
-
onDelete={() => onChange(null)}
|
|
65
|
-
icon={downloadIcon}
|
|
66
|
-
isIconAfter={isIconAfter}
|
|
67
|
-
deleteIcon={deleteIcon}
|
|
68
|
-
isUseLinkTitle={isUseLinkTitle}
|
|
69
|
-
isLinkTypeDownload={isLinkTypeDownload}
|
|
70
|
-
/>
|
|
71
|
-
)}
|
|
72
|
-
|
|
73
|
-
{Boolean(doLoad) && !value && (
|
|
74
|
-
<LoadZone
|
|
75
|
-
RC={RC}
|
|
76
|
-
fieldKey={fieldKey}
|
|
77
|
-
onChange={onChange}
|
|
78
|
-
icon={uploadIcon}
|
|
79
|
-
doLoad={doLoad}
|
|
80
|
-
dragenter={dragenter}
|
|
81
|
-
setDragenter={setDragenter}
|
|
82
|
-
setIsLoadContent={setIsLoadContent}
|
|
83
|
-
placeholder={placeholder}
|
|
84
|
-
filterFiles={filterFiles}
|
|
85
|
-
processErrors={processErrors}
|
|
86
|
-
isBlockNullValues={isBlockNullValues}
|
|
87
|
-
attributesOfNativeInput={attributesOfNativeInput}
|
|
88
|
-
/>
|
|
89
|
-
)}
|
|
90
|
-
</div>
|
|
91
|
-
);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export default FileLoader;
|
|
1
|
+
function e(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=Array(r);t<r;t++)o[t]=e[t];return o}function r(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function t(r,t){return function(e){if(Array.isArray(e))return e}(r)||function(e,r){var t,o,n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var a=[],i=!0,l=!1;try{for(n=n.call(e);!(i=(t=n.next()).done)&&(a.push(t.value),!r||a.length!==r);i=!0);}catch(e){l=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(l)throw o}}return a}}(r,t)||function(r,t){if(r){if("string"==typeof r)return e(r,t);var o=Object.prototype.toString.call(r).slice(8,-1);if("Object"===o&&r.constructor&&(o=r.constructor.name),"Map"===o||"Set"===o)return Array.from(o);if("Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return e(r,t)}}(r,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}import{jsx as o,jsxs as n}from"react/jsx-runtime";import{useState as a}from"react";import i from"classnames";import l from"./partial/LoadZone";import s from"./partial/LoadedContent";import"./FileLoader.scss";var c="file-loader";export default function(e){var u,d=e.fieldKey,f=e.value,p=e.disabled,m=e.error,y=e.className,v=e.placeholder,b=e.onChange,h=e.doLoad,I=e.filterFiles,g=e.processErrors,L=e.isBlockNullValues,A=e.isDisableErrorsClass,C=e.uploadIcon,j=e.downloadIcon,k=e.deleteIcon,w=e.spiner,N=e.isIconAfter,x=e.isLinkTypeDownload,D=e.isUseLinkTitle,O=e.attributesOfNativeInput,S=t(a(!1),2),T=S[0],_=S[1],E=t(a(!1),2),F=E[0],U=E[1];return n("div",{className:i(c,y,(r(u={},"".concat(c,"_load-content"),T),r(u,"".concat(c,"_load-zone"),!f),r(u,"".concat(c,"_hover"),F),r(u,"".concat(c,"_disabled"),p),r(u,"".concat(c,"_error"),!(void 0===A||A)&&!!m),u)),children:[T&&w,!h&&"develop error: no doLoad",!!h&&!!f&&o(s,{RC:c,value:f,onDelete:function(){return b(null)},icon:j,isIconAfter:N,deleteIcon:k,isUseLinkTitle:void 0!==D&&D,isLinkTypeDownload:void 0!==x&&x}),!!h&&!f&&o(l,{RC:c,fieldKey:d,onChange:b,icon:C,doLoad:h,dragenter:F,setDragenter:U,setIsLoadContent:_,placeholder:v,filterFiles:I,processErrors:g,isBlockNullValues:L,attributesOfNativeInput:void 0===O?{}:O})]})}
|
|
@@ -1,105 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import cn from "classnames";
|
|
4
|
-
|
|
5
|
-
import "../FileLoader.scss";
|
|
6
|
-
|
|
7
|
-
const DEFAULT_MAX_FILE_SIZE = 1024 * 1024; //1Мб
|
|
8
|
-
const FILTER_FILES_DEFAULT = (file) =>
|
|
9
|
-
file.size <= DEFAULT_MAX_FILE_SIZE ? file : null;
|
|
10
|
-
|
|
11
|
-
const LoadZone = ({
|
|
12
|
-
RC,
|
|
13
|
-
fieldKey,
|
|
14
|
-
onChange,
|
|
15
|
-
doLoad,
|
|
16
|
-
setDragenter,
|
|
17
|
-
setIsLoadContent,
|
|
18
|
-
icon,
|
|
19
|
-
placeholder = "",
|
|
20
|
-
filterFiles = FILTER_FILES_DEFAULT,
|
|
21
|
-
processErrors,
|
|
22
|
-
isBlockNullValues,
|
|
23
|
-
attributesOfNativeInput = {},
|
|
24
|
-
}) => {
|
|
25
|
-
const dropZoneId = `dropZone-${fieldKey}`;
|
|
26
|
-
|
|
27
|
-
const handle = {
|
|
28
|
-
change: async (e) => {
|
|
29
|
-
setIsLoadContent?.(true);
|
|
30
|
-
const file =
|
|
31
|
-
e.type === "change" ? e.target.files[0] : e.dataTransfer.files[0];
|
|
32
|
-
const validatedFile = filterFiles ? await filterFiles(file) : file;
|
|
33
|
-
if (processErrors && !validatedFile) await processErrors(file);
|
|
34
|
-
if (!isBlockNullValues || validatedFile) {
|
|
35
|
-
onChange(await doLoad(validatedFile).catch(() => null));
|
|
36
|
-
}
|
|
37
|
-
setIsLoadContent?.(false);
|
|
38
|
-
},
|
|
39
|
-
dragover: (e) => {
|
|
40
|
-
e.stopPropagation();
|
|
41
|
-
e.preventDefault();
|
|
42
|
-
return false;
|
|
43
|
-
},
|
|
44
|
-
dragenter: (e) => {
|
|
45
|
-
e.stopPropagation();
|
|
46
|
-
e.preventDefault();
|
|
47
|
-
setDragenter(true);
|
|
48
|
-
return false;
|
|
49
|
-
},
|
|
50
|
-
dragleave: (e) => {
|
|
51
|
-
e.stopPropagation();
|
|
52
|
-
e.preventDefault();
|
|
53
|
-
setDragenter(false);
|
|
54
|
-
return false;
|
|
55
|
-
},
|
|
56
|
-
drop: (e) => {
|
|
57
|
-
e.stopPropagation();
|
|
58
|
-
e.preventDefault();
|
|
59
|
-
setDragenter(false);
|
|
60
|
-
handle.change(e);
|
|
61
|
-
return false;
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
const dropbox = document.getElementById(dropZoneId);
|
|
67
|
-
dropbox?.addEventListener("dragenter", handle.dragenter, false);
|
|
68
|
-
dropbox?.addEventListener("dragover", handle.dragover, false);
|
|
69
|
-
dropbox?.addEventListener("dragleave", handle.dragleave, false);
|
|
70
|
-
dropbox?.addEventListener("drop", handle.drop, false);
|
|
71
|
-
dropbox?.addEventListener("dragend", handle.dragleave, false);
|
|
72
|
-
|
|
73
|
-
return () => {
|
|
74
|
-
dropbox?.removeEventListener("dragenter", handle.dragenter, false);
|
|
75
|
-
dropbox?.removeEventListener("dragover", handle.dragover, false);
|
|
76
|
-
dropbox?.removeEventListener("dragleave", handle.dragleave, false);
|
|
77
|
-
dropbox?.removeEventListener("drop", handle.drop, false);
|
|
78
|
-
dropbox?.removeEventListener("dragend", handle.dragleave, false);
|
|
79
|
-
};
|
|
80
|
-
}, [fieldKey, doLoad]);
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<>
|
|
84
|
-
{icon && <div className={cn(`${RC}__icon-block`)}>{icon}</div>}
|
|
85
|
-
<label
|
|
86
|
-
id={dropZoneId}
|
|
87
|
-
className={cn(`${RC}__input-label`, {
|
|
88
|
-
[`${RC}__input-label_no-icon`]: !icon,
|
|
89
|
-
})}
|
|
90
|
-
htmlFor={fieldKey}
|
|
91
|
-
>
|
|
92
|
-
{placeholder}
|
|
93
|
-
<input
|
|
94
|
-
id={fieldKey}
|
|
95
|
-
className={cn(`${RC}__input`)}
|
|
96
|
-
type="file"
|
|
97
|
-
onChange={handle.change}
|
|
98
|
-
{...attributesOfNativeInput}
|
|
99
|
-
/>
|
|
100
|
-
</label>
|
|
101
|
-
</>
|
|
102
|
-
);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export default LoadZone;
|
|
1
|
+
function e(e,r,n,t,a,o,l){try{var i=e[o](l),u=i.value}catch(e){n(e);return}i.done?r(u):Promise.resolve(u).then(t,a)}function r(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}import{jsx as n,jsxs as t,Fragment as a}from"react/jsx-runtime";import{useEffect as o}from"react";import l from"classnames";import"../FileLoader.scss";var i=function(e){return e.size<=1048576?e:null};export default function(u){var c,s,d=u.RC,f=u.fieldKey,p=u.onChange,v=u.doLoad,g=u.setDragenter,b=u.setIsLoadContent,h=u.icon,m=u.placeholder,y=u.filterFiles,E=void 0===y?i:y,w=u.processErrors,L=u.isBlockNullValues,O=u.attributesOfNativeInput,j="dropZone-".concat(f),P={change:(c=function(e){var r,n,t;return function(e,r){var n,t,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return l.next=i(0),l.throw=i(1),l.return=i(2),"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(i){return function(u){var c=[i,u];if(n)throw TypeError("Generator is already executing.");for(;l&&(l=0,c[0]&&(o=0)),o;)try{if(n=1,t&&(a=2&c[0]?t.return:c[0]?t.throw||((a=t.return)&&a.call(t),0):t.next)&&!(a=a.call(t,c[1])).done)return a;switch(t=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,t=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){o=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){o.label=c[1];break}if(6===c[0]&&o.label<a[1]){o.label=a[1],a=c;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(c);break}a[2]&&o.ops.pop(),o.trys.pop();continue}c=r.call(e,o)}catch(e){c=[6,e],t=0}finally{n=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(a){switch(a.label){case 0:if(null==b||b(!0),r="change"===e.type?e.target.files[0]:e.dataTransfer.files[0],!E)return[3,2];return[4,E(r)];case 1:return t=a.sent(),[3,3];case 2:t=r,a.label=3;case 3:if(n=t,!(w&&!n))return[3,5];return[4,w(r)];case 4:a.sent(),a.label=5;case 5:if(!(!L||n))return[3,7];return[4,v(n).catch(function(){return null})];case 6:p.apply(void 0,[a.sent()]),a.label=7;case 7:return null==b||b(!1),[2]}})},s=function(){var r=this,n=arguments;return new Promise(function(t,a){var o=c.apply(r,n);function l(r){e(o,t,a,l,i,"next",r)}function i(r){e(o,t,a,l,i,"throw",r)}l(void 0)})},function(e){return s.apply(this,arguments)}),dragover:function(e){return e.stopPropagation(),e.preventDefault(),!1},dragenter:function(e){return e.stopPropagation(),e.preventDefault(),g(!0),!1},dragleave:function(e){return e.stopPropagation(),e.preventDefault(),g(!1),!1},drop:function(e){return e.stopPropagation(),e.preventDefault(),g(!1),P.change(e),!1}};return o(function(){var e=document.getElementById(j);return null==e||e.addEventListener("dragenter",P.dragenter,!1),null==e||e.addEventListener("dragover",P.dragover,!1),null==e||e.addEventListener("dragleave",P.dragleave,!1),null==e||e.addEventListener("drop",P.drop,!1),null==e||e.addEventListener("dragend",P.dragleave,!1),function(){null==e||e.removeEventListener("dragenter",P.dragenter,!1),null==e||e.removeEventListener("dragover",P.dragover,!1),null==e||e.removeEventListener("dragleave",P.dragleave,!1),null==e||e.removeEventListener("drop",P.drop,!1),null==e||e.removeEventListener("dragend",P.dragleave,!1)}},[f,v]),t(a,{children:[h&&n("div",{className:l("".concat(d,"__icon-block")),children:h}),t("label",{id:j,className:l("".concat(d,"__input-label"),r({},"".concat(d,"__input-label_no-icon"),!h)),htmlFor:f,children:[void 0===m?"":m,n("input",function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},a=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),a.forEach(function(n){r(e,n,t[n])})}return e}({id:f,className:l("".concat(d,"__input")),type:"file",onChange:P.change},void 0===O?{}:O))]})]})}
|