@geotab/zenith 3.1.1-beta.6 → 3.2.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/dist/advancedGroupsFilter/advancedGroupsFilter.js +136 -30
- package/dist/advancedGroupsFilter/advancedGroupsFilterForm.js +139 -34
- package/dist/advancedGroupsFilter/advancedGroupsFilterFormSection.js +352 -87
- package/dist/advancedGroupsFilter/advancedGroupsFilterSectionTooltip.d.ts +0 -1
- package/dist/advancedGroupsFilter/advancedGroupsFilterSectionTooltip.js +83 -9
- package/dist/alertRaw/alertRaw.js +175 -54
- package/dist/banner/bannerMultipLine.js +131 -23
- package/dist/banner/bannerSingleLine.js +110 -16
- package/dist/betaPill/betaPill.js +111 -20
- package/dist/bookmark/bookmark.js +95 -28
- package/dist/bulkEditControl/bulkEditControl.js +167 -34
- package/dist/calendar/calendar.js +943 -273
- package/dist/calendar/calendarUtils.js +157 -85
- package/dist/card/card.js +268 -123
- package/dist/chart/accessibleChart/accessibleChartNarrative.js +648 -555
- package/dist/chart/accessibleChart/accessibleChartTable.js +245 -86
- package/dist/chart/chart.js +36 -21
- package/dist/chart/chartAxis/chartAxis.js +85 -7
- package/dist/checkboxListWithAction/checkboxListWithAction.js +224 -69
- package/dist/chip/chip.js +195 -91
- package/dist/columnsSelector/columnsSelector.js +97 -12
- package/dist/columnsSelector/columnsTab/columnsTab.js +59 -15
- package/dist/columnsSelector/columnsTabGroup/columnsTabGroup.js +81 -34
- package/dist/comboboxSelected/comboboxSelected.js +1 -3
- package/dist/dataFeed/feedExpandControl/feedExpandControl.js +25 -10
- package/dist/dataGrid/columns/checkboxColumn/checkboxHeaderCell.js +92 -11
- package/dist/dataGrid/dataGrid.js +227 -117
- package/dist/dataGrid/emptySearchList/emptySearchList.js +56 -9
- package/dist/dataGrid/entitiesListActions/actions/columnsListButton.js +51 -7
- package/dist/dataGrid/entitiesListActions/actions/fullscreenButton.js +64 -18
- package/dist/dataGrid/withFlexibleColumns/components/columnSettings.js +84 -10
- package/dist/dataGrid/withFlexibleColumns/components/columnSettingsSidePanel.js +48 -16
- package/dist/dataGrid/withSelectableRows/components/bulkActions/bulkActions.js +223 -32
- package/dist/dataGrid/withSelectableRows/withSelectableRows.js +286 -213
- package/dist/dataGrid/withSortableColumns/columns/sortableColumnWrapper.js +178 -95
- package/dist/dateInputInner/dateInputInner.js +791 -476
- package/dist/dateInputInner/dateInputInnerControlBlock.js +125 -22
- package/dist/dateInputRaw/dateInputRaw.js +315 -104
- package/dist/dateInputRaw/utils/getLabel.js +38 -7
- package/dist/dateRangeInner/dateRangeInner.js +173 -59
- package/dist/dateRangeRaw/dateRangeRaw.js +601 -239
- package/dist/dateRangeRaw/utils/dateRangeUtils.js +629 -241
- package/dist/dateSelectionWrapper/dateSelectionWrapper.js +152 -14
- package/dist/dialog/dialogContent.js +123 -40
- package/dist/dropdownRaw/dropdownHelper.d.ts +2 -2
- package/dist/dropdownRaw/dropdownHelper.js +9 -9
- package/dist/dropdownRaw/dropdownList.js +447 -78
- package/dist/dropdownRaw/dropdownPopup.js +218 -20
- package/dist/dropdownRaw/dropdownRaw.js +866 -506
- package/dist/dropdownRaw/dropdownSearchableTrigger.js +223 -46
- package/dist/dropdownRaw/stateReducer/stateAction.d.ts +5 -1
- package/dist/dropdownRaw/stateReducer/stateActionType.d.ts +2 -1
- package/dist/dropdownRaw/stateReducer/stateActionType.js +1 -0
- package/dist/dropdownRaw/stateReducer/stateReducer.d.ts +6 -1
- package/dist/dropdownRaw/stateReducer/stateReducer.js +24 -12
- package/dist/dropdownRaw/stateReducer/stateReducerHelper.d.ts +2 -0
- package/dist/dropdownRaw/stateReducer/stateReducerHelper.js +20 -1
- package/dist/dropdownRaw/stateReducer/stateReducerTestData.d.ts +39 -0
- package/dist/dropdownRaw/stateReducer/stateReducerTestData.js +74 -0
- package/dist/dropdownRaw/types.d.ts +1 -0
- package/dist/favoriteButton/favoriteButton.js +59 -10
- package/dist/filters/components/filtersContainer.js +151 -64
- package/dist/filters/components/filtersEmptySelectedList.js +30 -4
- package/dist/filters/components/filtersSaveModal.js +140 -42
- package/dist/filters/components/filtersSavedChipComponent.js +318 -108
- package/dist/filters/components/filtersSearchItemData.js +127 -47
- package/dist/filters/components/filtersSearchList.js +381 -179
- package/dist/filters/components/filtersSelect.js +128 -61
- package/dist/filters/components/filtersSelectListItem.js +125 -13
- package/dist/filters/components/filtersSidePanel.js +510 -178
- package/dist/filters/components/filtersSidePanelDropdown.js +2 -2
- package/dist/filters/filters.js +445 -268
- package/dist/filtersBar/components/filtersBarPeriodPicker/getRangeOption.js +729 -272
- package/dist/filtersBar/components/resetComponentButton.js +45 -5
- package/dist/filtersBar/filtersBarActions/filtersBarActions.js +126 -15
- package/dist/filtersBar/filtersBarSidePanel/components/filtersBarSidePanelRadioGroup/filtersBarSidePanelRadioGroup.js +2 -2
- package/dist/filtersBar/filtersBarSidePanel/components/filtersBarSidePanelRange/filtersBarSidePanelRange.js +155 -49
- package/dist/filtersBar/filtersBarSidePanel/filtersBarSidePanel.js +360 -104
- package/dist/filtersBar/filtersContainer/filtersContainer.js +204 -134
- package/dist/formField/components/formFieldWithLabel.d.ts +2 -1
- package/dist/formField/components/formFieldWithLabel.js +3 -2
- package/dist/formField/components/formFieldWithoutLabel.d.ts +2 -1
- package/dist/formField/components/formFieldWithoutLabel.js +3 -3
- package/dist/formField/components/trailingComponent.d.ts +8 -0
- package/dist/formField/components/trailingComponent.js +11 -0
- package/dist/formField/formField.js +26 -11
- package/dist/formField/hooks/useError.js +100 -36
- package/dist/formGroup/components/reviewListToggle/reviewListToggle.js +72 -7
- package/dist/formGroup/hooks/useToggle.js +37 -11
- package/dist/formGroup/utils/getControls.js +8 -7
- package/dist/formLayout/hooks/useError.js +55 -15
- package/dist/formLayout/hooks/useFormButtons.js +128 -27
- package/dist/formSection/components/formSectionModal.js +1 -1
- package/dist/formSection/formSection.js +1 -1
- package/dist/formSection/hooks/useError.js +70 -22
- package/dist/formStepper/components/formStep.js +65 -10
- package/dist/formStepper/formStepper.js +129 -33
- package/dist/formStepperButtons/formStepperButtons.js +184 -38
- package/dist/groupsFilter/groupsHelper.d.ts +1 -1
- package/dist/groupsFilterRaw/groupsFilterAdjustmentState.js +162 -17
- package/dist/groupsFilterRaw/groupsFilterBox.js +137 -32
- package/dist/groupsFilterRaw/groupsFilterCommon.js +75 -8
- package/dist/groupsFilterRaw/groupsFilterCurrentlySelectedState.js +184 -25
- package/dist/groupsFilterRaw/groupsFilterHelper.d.ts +2 -1
- package/dist/groupsFilterRaw/groupsFilterHelper.js +284 -168
- package/dist/groupsFilterRaw/groupsFilterInitialState.js +266 -18
- package/dist/groupsFilterRaw/groupsFilterMenu.js +124 -9
- package/dist/groupsFilterRaw/groupsFilterRaw.d.ts +1 -0
- package/dist/groupsFilterRaw/groupsFilterRaw.js +816 -308
- package/dist/groupsFilterRaw/groupsFilterTestData.d.ts +155 -2
- package/dist/groupsFilterRaw/groupsFilterTestData.js +153 -58
- package/dist/groupsFilterRaw/groupsFilterTrigger.js +139 -35
- package/dist/groupsFilterRaw/groupsHelper.js +739 -208
- package/dist/groupsFilterRaw/stateReducer/stateReducerHelper.js +3 -1
- package/dist/groupsFilterRaw/types.d.ts +1 -0
- package/dist/header/components/collapsedItemsControl/collapsedItemsControl.js +107 -52
- package/dist/header/components/mobileFilterControl/mobileFilterControl.js +62 -9
- package/dist/header/components/mobileSearchControl/mobileSearchControl.js +119 -14
- package/dist/header/headerBack.js +64 -20
- package/dist/index.css +116 -74
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -1
- package/dist/list/itemData/itemDataInternal.js +216 -51
- package/dist/list/listItem/listItem.js +168 -55
- package/dist/menu/components/menuErrorItem.js +33 -5
- package/dist/mobileSheet/mobileSheet.js +195 -69
- package/dist/modal/modal.js +300 -142
- package/dist/nav/nav.js +1 -1
- package/dist/nav/navFooter/navFooter.js +82 -39
- package/dist/nav/navFooter/navFooterAction/navFooterAction.js +52 -13
- package/dist/nav/navHeader/navHeader.js +86 -36
- package/dist/nav/navHeader/navHeaderSearch/navHeaderSearch.js +88 -29
- package/dist/nav/navItem/navItem.d.ts +3 -3
- package/dist/nav/navItem/navItem.js +35 -33
- package/dist/nav/navMobileBar/navMobileBar.js +67 -21
- package/dist/notification/notification.js +124 -21
- package/dist/pagination/paginationArrow.js +81 -11
- package/dist/pagination/paginationText/paginationText.js +45 -11
- package/dist/pill/components/pillNonActionable/pillNonActionable.js +93 -24
- package/dist/pillBox/components/pillBoxItem.js +52 -9
- package/dist/pillBox/pillBox.js +121 -20
- package/dist/pillExpandable/pillExpandable.js +333 -139
- package/dist/rangeRaw/rangeRaw.js +486 -141
- package/dist/rangeRaw/utils/rangeHelper.js +209 -39
- package/dist/searchInputRaw/searchInputRaw.js +180 -65
- package/dist/skeleton/skeleton.js +51 -6
- package/dist/sortControl/sortControl.js +152 -42
- package/dist/stepperRaw/stepperRaw.js +116 -42
- package/dist/summary/summary.js +94 -8
- package/dist/table/actions/actionsMenu.js +171 -78
- package/dist/table/flexible/columnSettings.js +80 -10
- package/dist/table/flexible/columnsList.js +110 -43
- package/dist/table/flexible/columnsPopup.js +77 -20
- package/dist/table/nested/useNestedRows.js +167 -77
- package/dist/table/selectable/selectableHeader.js +180 -41
- package/dist/table/selectable/useSelectableRows.js +270 -191
- package/dist/table/sortable/sortableHeader.js +153 -75
- package/dist/tabs/tabs.js +227 -118
- package/dist/timePickerRaw/timePickerRaw.js +278 -58
- package/dist/toastRaw/toastRaw.js +138 -32
- package/dist/toggleButton/toggleButton.d.ts +0 -1
- package/dist/toggleButtonRaw/toggleButtonRaw.d.ts +1 -0
- package/dist/toggleButtonRaw/toggleButtonRaw.js +146 -40
- package/dist/utils/formatDate.js +1001 -117
- package/{esm/utils/localization/translations/cs-json.js → dist/utils/localization/translations/cs.json} +11 -12
- package/{esm/utils/localization/translations/da-DK-json.js → dist/utils/localization/translations/da-DK.json} +31 -23
- package/{esm/utils/localization/translations/de-json.js → dist/utils/localization/translations/de.json} +12 -13
- package/dist/utils/localization/translations/en.json +308 -0
- package/{esm/utils/localization/translations/es-json.js → dist/utils/localization/translations/es.json} +11 -12
- package/{esm/utils/localization/translations/fi-FI-json.js → dist/utils/localization/translations/fi-FI.json} +31 -23
- package/{esm/utils/localization/translations/fr-FR-json.js → dist/utils/localization/translations/fr-FR.json} +12 -12
- package/{esm/utils/localization/translations/fr-json.js → dist/utils/localization/translations/fr.json} +11 -12
- package/{esm/utils/localization/translations/hu-HU-json.js → dist/utils/localization/translations/hu-HU.json} +31 -23
- package/{esm/utils/localization/translations/id-json.js → dist/utils/localization/translations/id.json} +11 -13
- package/{esm/utils/localization/translations/it-json.js → dist/utils/localization/translations/it.json} +11 -12
- package/{esm/utils/localization/translations/ja-json.js → dist/utils/localization/translations/ja.json} +11 -12
- package/{esm/utils/localization/translations/ko-KR-json.js → dist/utils/localization/translations/ko-KR.json} +24 -23
- package/{esm/utils/localization/translations/ms-json.js → dist/utils/localization/translations/ms.json} +11 -12
- package/{esm/utils/localization/translations/nb-NO-json.js → dist/utils/localization/translations/nb-NO.json} +31 -23
- package/{esm/utils/localization/translations/nl-json.js → dist/utils/localization/translations/nl.json} +11 -12
- package/{esm/utils/localization/translations/pl-json.js → dist/utils/localization/translations/pl.json} +11 -12
- package/{esm/utils/localization/translations/pt-BR-json.js → dist/utils/localization/translations/pt-BR.json} +11 -12
- package/{esm/utils/localization/translations/sk-SK-json.js → dist/utils/localization/translations/sk-SK.json} +31 -23
- package/{esm/utils/localization/translations/sv-json.js → dist/utils/localization/translations/sv.json} +11 -12
- package/{esm/utils/localization/translations/th-json.js → dist/utils/localization/translations/th.json} +11 -12
- package/{esm/utils/localization/translations/tr-json.js → dist/utils/localization/translations/tr.json} +11 -12
- package/{esm/utils/localization/translations/zh-Hans-json.js → dist/utils/localization/translations/zh-Hans.json} +11 -12
- package/{esm/utils/localization/translations/zh-TW-json.js → dist/utils/localization/translations/zh-TW.json} +11 -23
- package/dist/utils/localization/translationsDictionary.d.ts +2 -0
- package/dist/utils/localization/translationsDictionary.js +63 -0
- package/dist/utils/localization/useLanguage.js +2 -74
- package/esm/advancedGroupsFilter/advancedGroupsFilter.js +130 -29
- package/esm/advancedGroupsFilter/advancedGroupsFilterForm.js +133 -33
- package/esm/advancedGroupsFilter/advancedGroupsFilterFormSection.js +317 -65
- package/esm/advancedGroupsFilter/advancedGroupsFilterSectionTooltip.d.ts +0 -1
- package/esm/advancedGroupsFilter/advancedGroupsFilterSectionTooltip.js +77 -8
- package/esm/alertRaw/alertRaw.js +165 -51
- package/esm/banner/bannerMultipLine.js +121 -20
- package/esm/banner/bannerSingleLine.js +100 -13
- package/esm/betaPill/betaPill.js +105 -19
- package/esm/bookmark/bookmark.js +89 -27
- package/esm/bulkEditControl/bulkEditControl.js +161 -33
- package/esm/calendar/calendar.js +937 -272
- package/esm/calendar/calendarUtils.js +151 -84
- package/esm/card/card.js +233 -101
- package/esm/chart/accessibleChart/accessibleChartNarrative.js +642 -554
- package/esm/chart/accessibleChart/accessibleChartTable.js +239 -85
- package/esm/chart/chart.js +30 -20
- package/esm/chart/chartAxis/chartAxis.js +79 -6
- package/esm/checkboxListWithAction/checkboxListWithAction.js +218 -68
- package/esm/chip/chip.js +189 -90
- package/esm/columnsSelector/columnsSelector.js +91 -11
- package/esm/columnsSelector/columnsTab/columnsTab.js +53 -14
- package/esm/columnsSelector/columnsTabGroup/columnsTabGroup.js +75 -33
- package/esm/comboboxSelected/comboboxSelected.js +1 -3
- package/esm/dataFeed/feedExpandControl/feedExpandControl.js +21 -9
- package/esm/dataGrid/columns/checkboxColumn/checkboxHeaderCell.js +86 -10
- package/esm/dataGrid/dataGrid.js +221 -116
- package/esm/dataGrid/emptySearchList/emptySearchList.js +50 -8
- package/esm/dataGrid/entitiesListActions/actions/columnsListButton.js +45 -6
- package/esm/dataGrid/entitiesListActions/actions/fullscreenButton.js +58 -17
- package/esm/dataGrid/withFlexibleColumns/components/columnSettings.js +78 -9
- package/esm/dataGrid/withFlexibleColumns/components/columnSettingsSidePanel.js +44 -15
- package/esm/dataGrid/withSelectableRows/components/bulkActions/bulkActions.js +217 -31
- package/esm/dataGrid/withSelectableRows/withSelectableRows.js +280 -212
- package/esm/dataGrid/withSortableColumns/columns/sortableColumnWrapper.js +172 -94
- package/esm/dateInputInner/dateInputInner.js +785 -475
- package/esm/dateInputInner/dateInputInnerControlBlock.js +119 -21
- package/esm/dateInputRaw/dateInputRaw.js +309 -103
- package/esm/dateInputRaw/utils/getLabel.js +32 -6
- package/esm/dateRangeInner/dateRangeInner.js +167 -58
- package/esm/dateRangeRaw/dateRangeRaw.js +595 -238
- package/esm/dateRangeRaw/utils/dateRangeUtils.js +622 -239
- package/esm/dateSelectionWrapper/dateSelectionWrapper.js +146 -13
- package/esm/dialog/dialogContent.js +117 -39
- package/esm/dropdownRaw/dropdownHelper.d.ts +2 -2
- package/esm/dropdownRaw/dropdownHelper.js +10 -10
- package/esm/dropdownRaw/dropdownList.js +412 -56
- package/esm/dropdownRaw/dropdownPopup.js +212 -19
- package/esm/dropdownRaw/dropdownRaw.js +862 -507
- package/esm/dropdownRaw/dropdownSearchableTrigger.js +217 -45
- package/esm/dropdownRaw/stateReducer/stateAction.d.ts +5 -1
- package/esm/dropdownRaw/stateReducer/stateActionType.d.ts +2 -1
- package/esm/dropdownRaw/stateReducer/stateActionType.js +1 -0
- package/esm/dropdownRaw/stateReducer/stateReducer.d.ts +6 -1
- package/esm/dropdownRaw/stateReducer/stateReducer.js +24 -12
- package/esm/dropdownRaw/stateReducer/stateReducerHelper.d.ts +2 -0
- package/esm/dropdownRaw/stateReducer/stateReducerHelper.js +18 -0
- package/esm/dropdownRaw/stateReducer/stateReducerTestData.d.ts +39 -0
- package/esm/dropdownRaw/stateReducer/stateReducerTestData.js +71 -0
- package/esm/dropdownRaw/types.d.ts +1 -0
- package/esm/favoriteButton/favoriteButton.js +53 -9
- package/esm/filters/components/filtersContainer.js +141 -61
- package/esm/filters/components/filtersEmptySelectedList.js +24 -3
- package/esm/filters/components/filtersSaveModal.js +134 -41
- package/esm/filters/components/filtersSavedChipComponent.js +312 -107
- package/esm/filters/components/filtersSearchItemData.js +121 -46
- package/esm/filters/components/filtersSearchList.js +375 -178
- package/esm/filters/components/filtersSelect.js +122 -60
- package/esm/filters/components/filtersSelectListItem.js +119 -12
- package/esm/filters/components/filtersSidePanel.js +504 -177
- package/esm/filters/components/filtersSidePanelDropdown.js +2 -2
- package/esm/filters/filters.js +435 -265
- package/esm/filtersBar/components/filtersBarPeriodPicker/getRangeOption.js +722 -270
- package/esm/filtersBar/components/resetComponentButton.js +39 -4
- package/esm/filtersBar/filtersBarActions/filtersBarActions.js +120 -14
- package/esm/filtersBar/filtersBarSidePanel/components/filtersBarSidePanelRadioGroup/filtersBarSidePanelRadioGroup.js +2 -2
- package/esm/filtersBar/filtersBarSidePanel/components/filtersBarSidePanelRange/filtersBarSidePanelRange.js +149 -48
- package/esm/filtersBar/filtersBarSidePanel/filtersBarSidePanel.js +354 -103
- package/esm/filtersBar/filtersContainer/filtersContainer.js +198 -133
- package/esm/formField/components/formFieldWithLabel.d.ts +2 -1
- package/esm/formField/components/formFieldWithLabel.js +3 -2
- package/esm/formField/components/formFieldWithoutLabel.d.ts +2 -1
- package/esm/formField/components/formFieldWithoutLabel.js +3 -3
- package/esm/formField/components/trailingComponent.d.ts +8 -0
- package/esm/formField/components/trailingComponent.js +7 -0
- package/esm/formField/formField.js +27 -12
- package/esm/formField/hooks/useError.js +94 -35
- package/esm/formGroup/components/reviewListToggle/reviewListToggle.js +66 -6
- package/esm/formGroup/hooks/useToggle.js +31 -10
- package/esm/formGroup/utils/getControls.js +8 -7
- package/esm/formLayout/hooks/useError.js +49 -14
- package/esm/formLayout/hooks/useFormButtons.js +122 -26
- package/esm/formSection/components/formSectionModal.js +1 -1
- package/esm/formSection/formSection.js +1 -1
- package/esm/formSection/hooks/useError.js +64 -21
- package/esm/formStepper/components/formStep.js +59 -9
- package/esm/formStepper/formStepper.js +123 -32
- package/esm/formStepperButtons/formStepperButtons.js +178 -37
- package/esm/groupsFilter/groupsHelper.d.ts +1 -1
- package/esm/groupsFilterRaw/groupsFilterAdjustmentState.js +152 -14
- package/esm/groupsFilterRaw/groupsFilterBox.js +131 -31
- package/esm/groupsFilterRaw/groupsFilterCommon.js +69 -7
- package/esm/groupsFilterRaw/groupsFilterCurrentlySelectedState.js +178 -24
- package/esm/groupsFilterRaw/groupsFilterHelper.d.ts +2 -1
- package/esm/groupsFilterRaw/groupsFilterHelper.js +279 -168
- package/esm/groupsFilterRaw/groupsFilterInitialState.js +260 -17
- package/esm/groupsFilterRaw/groupsFilterMenu.js +118 -8
- package/esm/groupsFilterRaw/groupsFilterRaw.d.ts +1 -0
- package/esm/groupsFilterRaw/groupsFilterRaw.js +811 -308
- package/esm/groupsFilterRaw/groupsFilterTestData.d.ts +155 -2
- package/esm/groupsFilterRaw/groupsFilterTestData.js +152 -57
- package/esm/groupsFilterRaw/groupsFilterTrigger.js +133 -34
- package/esm/groupsFilterRaw/groupsHelper.js +733 -207
- package/esm/groupsFilterRaw/stateReducer/stateReducerHelper.js +3 -1
- package/esm/groupsFilterRaw/types.d.ts +1 -0
- package/esm/header/components/collapsedItemsControl/collapsedItemsControl.js +101 -51
- package/esm/header/components/mobileFilterControl/mobileFilterControl.js +56 -8
- package/esm/header/components/mobileSearchControl/mobileSearchControl.js +113 -13
- package/esm/header/headerBack.js +58 -19
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/list/itemData/itemDataInternal.js +210 -50
- package/esm/list/listItem/listItem.js +162 -54
- package/esm/menu/components/menuErrorItem.js +27 -4
- package/esm/mobileSheet/mobileSheet.js +189 -68
- package/esm/modal/modal.js +265 -120
- package/esm/nav/nav.js +1 -1
- package/esm/nav/navFooter/navFooter.js +76 -38
- package/esm/nav/navFooter/navFooterAction/navFooterAction.js +46 -12
- package/esm/nav/navHeader/navHeader.js +80 -35
- package/esm/nav/navHeader/navHeaderSearch/navHeaderSearch.js +82 -28
- package/esm/nav/navItem/navItem.d.ts +3 -3
- package/esm/nav/navItem/navItem.js +35 -33
- package/esm/nav/navMobileBar/navMobileBar.js +61 -20
- package/esm/notification/notification.js +114 -18
- package/esm/pagination/paginationArrow.js +75 -10
- package/esm/pagination/paginationText/paginationText.js +39 -10
- package/esm/pill/components/pillNonActionable/pillNonActionable.js +87 -23
- package/esm/pillBox/components/pillBoxItem.js +46 -8
- package/esm/pillBox/pillBox.js +115 -19
- package/esm/pillExpandable/pillExpandable.js +327 -138
- package/esm/rangeRaw/rangeRaw.js +480 -140
- package/esm/rangeRaw/utils/rangeHelper.js +203 -38
- package/esm/searchInputRaw/searchInputRaw.js +145 -43
- package/esm/skeleton/skeleton.js +45 -5
- package/esm/sortControl/sortControl.js +146 -41
- package/esm/stepperRaw/stepperRaw.js +112 -41
- package/esm/storybookHelpers/dataGridWithDifferentCellOptions/components/EntitiesListAction.js +178 -19
- package/esm/summary/summary.js +88 -7
- package/esm/table/actions/actionsMenu.js +165 -77
- package/esm/table/flexible/columnSettings.js +74 -9
- package/esm/table/flexible/columnsList.js +104 -42
- package/esm/table/flexible/columnsPopup.js +71 -19
- package/esm/table/nested/useNestedRows.js +161 -76
- package/esm/table/selectable/selectableHeader.js +174 -40
- package/esm/table/selectable/useSelectableRows.js +264 -190
- package/esm/table/sortable/sortableHeader.js +147 -74
- package/esm/tabs/tabs.js +221 -117
- package/esm/timePickerRaw/timePickerRaw.js +272 -57
- package/esm/toastRaw/toastRaw.js +132 -31
- package/esm/toggleButton/toggleButton.d.ts +0 -1
- package/esm/toggleButtonRaw/toggleButtonRaw.d.ts +1 -0
- package/esm/toggleButtonRaw/toggleButtonRaw.js +111 -18
- package/esm/utils/formatDate.js +995 -116
- package/{dist/utils/localization/translations/cs-json.js → esm/utils/localization/translations/cs.json} +11 -15
- package/{dist/utils/localization/translations/da-DK-json.js → esm/utils/localization/translations/da-DK.json} +31 -26
- package/{dist/utils/localization/translations/de-json.js → esm/utils/localization/translations/de.json} +12 -16
- package/esm/utils/localization/translations/en.json +308 -0
- package/{dist/utils/localization/translations/es-json.js → esm/utils/localization/translations/es.json} +11 -15
- package/{dist/utils/localization/translations/fi-FI-json.js → esm/utils/localization/translations/fi-FI.json} +31 -26
- package/{dist/utils/localization/translations/fr-FR-json.js → esm/utils/localization/translations/fr-FR.json} +12 -15
- package/{dist/utils/localization/translations/fr-json.js → esm/utils/localization/translations/fr.json} +11 -15
- package/{dist/utils/localization/translations/hu-HU-json.js → esm/utils/localization/translations/hu-HU.json} +31 -26
- package/{dist/utils/localization/translations/id-json.js → esm/utils/localization/translations/id.json} +11 -16
- package/{dist/utils/localization/translations/it-json.js → esm/utils/localization/translations/it.json} +11 -15
- package/{dist/utils/localization/translations/ja-json.js → esm/utils/localization/translations/ja.json} +11 -15
- package/{dist/utils/localization/translations/ko-KR-json.js → esm/utils/localization/translations/ko-KR.json} +24 -26
- package/{dist/utils/localization/translations/ms-json.js → esm/utils/localization/translations/ms.json} +11 -15
- package/{dist/utils/localization/translations/nb-NO-json.js → esm/utils/localization/translations/nb-NO.json} +31 -26
- package/{dist/utils/localization/translations/nl-json.js → esm/utils/localization/translations/nl.json} +11 -15
- package/{dist/utils/localization/translations/pl-json.js → esm/utils/localization/translations/pl.json} +11 -15
- package/{dist/utils/localization/translations/pt-BR-json.js → esm/utils/localization/translations/pt-BR.json} +11 -15
- package/{dist/utils/localization/translations/sk-SK-json.js → esm/utils/localization/translations/sk-SK.json} +31 -26
- package/{dist/utils/localization/translations/sv-json.js → esm/utils/localization/translations/sv.json} +11 -15
- package/{dist/utils/localization/translations/th-json.js → esm/utils/localization/translations/th.json} +11 -15
- package/{dist/utils/localization/translations/tr-json.js → esm/utils/localization/translations/tr.json} +11 -15
- package/{dist/utils/localization/translations/zh-Hans-json.js → esm/utils/localization/translations/zh-Hans.json} +11 -15
- package/{dist/utils/localization/translations/zh-TW-json.js → esm/utils/localization/translations/zh-TW.json} +11 -26
- package/esm/utils/localization/translationsDictionary.d.ts +2 -0
- package/esm/utils/localization/translationsDictionary.js +59 -0
- package/esm/utils/localization/useLanguage.js +1 -50
- package/package.json +19 -12
- package/dist/utils/localization/translations/cs-json.d.ts +0 -251
- package/dist/utils/localization/translations/da-DK-json.d.ts +0 -252
- package/dist/utils/localization/translations/de-json.d.ts +0 -251
- package/dist/utils/localization/translations/en-json.d.ts +0 -314
- package/dist/utils/localization/translations/en-json.js +0 -317
- package/dist/utils/localization/translations/es-json.d.ts +0 -251
- package/dist/utils/localization/translations/fi-FI-json.d.ts +0 -252
- package/dist/utils/localization/translations/fr-FR-json.d.ts +0 -250
- package/dist/utils/localization/translations/fr-json.d.ts +0 -251
- package/dist/utils/localization/translations/hu-HU-json.d.ts +0 -252
- package/dist/utils/localization/translations/id-json.d.ts +0 -252
- package/dist/utils/localization/translations/it-json.d.ts +0 -251
- package/dist/utils/localization/translations/ja-json.d.ts +0 -251
- package/dist/utils/localization/translations/ko-KR-json.d.ts +0 -258
- package/dist/utils/localization/translations/ms-json.d.ts +0 -251
- package/dist/utils/localization/translations/nb-NO-json.d.ts +0 -252
- package/dist/utils/localization/translations/nl-json.d.ts +0 -251
- package/dist/utils/localization/translations/pl-json.d.ts +0 -251
- package/dist/utils/localization/translations/pt-BR-json.d.ts +0 -251
- package/dist/utils/localization/translations/sk-SK-json.d.ts +0 -251
- package/dist/utils/localization/translations/sv-json.d.ts +0 -251
- package/dist/utils/localization/translations/th-json.d.ts +0 -251
- package/dist/utils/localization/translations/tr-json.d.ts +0 -251
- package/dist/utils/localization/translations/zh-Hans-json.d.ts +0 -251
- package/dist/utils/localization/translations/zh-TW-json.d.ts +0 -271
- package/esm/utils/localization/translations/cs-json.d.ts +0 -251
- package/esm/utils/localization/translations/da-DK-json.d.ts +0 -252
- package/esm/utils/localization/translations/de-json.d.ts +0 -251
- package/esm/utils/localization/translations/en-json.d.ts +0 -314
- package/esm/utils/localization/translations/en-json.js +0 -314
- package/esm/utils/localization/translations/es-json.d.ts +0 -251
- package/esm/utils/localization/translations/fi-FI-json.d.ts +0 -252
- package/esm/utils/localization/translations/fr-FR-json.d.ts +0 -250
- package/esm/utils/localization/translations/fr-json.d.ts +0 -251
- package/esm/utils/localization/translations/hu-HU-json.d.ts +0 -252
- package/esm/utils/localization/translations/id-json.d.ts +0 -252
- package/esm/utils/localization/translations/it-json.d.ts +0 -251
- package/esm/utils/localization/translations/ja-json.d.ts +0 -251
- package/esm/utils/localization/translations/ko-KR-json.d.ts +0 -258
- package/esm/utils/localization/translations/ms-json.d.ts +0 -251
- package/esm/utils/localization/translations/nb-NO-json.d.ts +0 -252
- package/esm/utils/localization/translations/nl-json.d.ts +0 -251
- package/esm/utils/localization/translations/pl-json.d.ts +0 -251
- package/esm/utils/localization/translations/pt-BR-json.d.ts +0 -251
- package/esm/utils/localization/translations/sk-SK-json.d.ts +0 -251
- package/esm/utils/localization/translations/sv-json.d.ts +0 -251
- package/esm/utils/localization/translations/th-json.d.ts +0 -251
- package/esm/utils/localization/translations/tr-json.d.ts +0 -251
- package/esm/utils/localization/translations/zh-Hans-json.d.ts +0 -251
- package/esm/utils/localization/translations/zh-TW-json.d.ts +0 -271
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { injectString } from "../utils/localization/translationsDictionary";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
/* eslint-disable complexity */
|
|
3
4
|
import { useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
4
5
|
import { classNames } from "../commonHelpers/classNames/classNames";
|
|
5
6
|
import { DropdownList, EmptyList } from "./dropdownList";
|
|
6
|
-
import { getInitialState, stateReducer } from "./stateReducer/stateReducer";
|
|
7
|
+
import { getInitialState, stateReducer, ROOT_GROUP_ID } from "./stateReducer/stateReducer";
|
|
7
8
|
import { StateActionType } from "./stateReducer/stateActionType";
|
|
8
9
|
import { FOCUSABLE_SELECTOR } from "../utils/focusableSelector";
|
|
9
10
|
import { useEscape } from "../commonHelpers/hooks/useEscape";
|
|
@@ -19,519 +20,873 @@ import { ReviewTextControl } from "../formGroup/components/reviewTextControl";
|
|
|
19
20
|
import { getSelectedValues } from "./utils/getSelectedValues";
|
|
20
21
|
import { Chip } from "../chip/chip";
|
|
21
22
|
import { useChipStatus } from "../chip/chipStatusProvider";
|
|
22
|
-
import {
|
|
23
|
+
import { getGroupDescription } from "../groupsFilterRaw/groupsHelper";
|
|
23
24
|
import { isFormItem } from "../commonHelpers/isFormItem";
|
|
24
25
|
import { useFormField } from "../commonHelpers/hooks/useFormField";
|
|
25
26
|
import { getAriaAttributes } from "../commonHelpers/getAriaAttributes";
|
|
26
27
|
import { useFormFieldValues } from "../commonHelpers/hooks/useFormFieldValues/useFormFieldValues";
|
|
27
28
|
import { FormSectionContext } from "../formSection/utils/formSectionProvider";
|
|
28
29
|
import { LIST_LIMIT } from "../dropdown/dropdown";
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
30
|
+
injectString("cs", "Filter by group", "Filtrovat podle skupiny");
|
|
31
|
+
injectString("da-DK", "Filter by group", "Filtrer efter gruppe");
|
|
32
|
+
injectString("de", "Filter by group", "Nach Gruppe filtern");
|
|
33
|
+
injectString("en", "Filter by group", "Filter by group");
|
|
34
|
+
injectString("es", "Filter by group", "Filtrar por grupo");
|
|
35
|
+
injectString("fi-FI", "Filter by group", "Suodata ryhm\xE4n mukaan");
|
|
36
|
+
injectString("fr", "Filter by group", "Filtrer par groupe");
|
|
37
|
+
injectString("fr-FR", "Filter by group", "Filtrer par groupe");
|
|
38
|
+
injectString("hu-HU", "Filter by group", "Sz\u0171rd csoport alapj\xE1n.");
|
|
39
|
+
injectString("id", "Filter by group", "Filter berdasarkan grup");
|
|
40
|
+
injectString("it", "Filter by group", "Filtrare per gruppo");
|
|
41
|
+
injectString("ja", "Filter by group", "\u30B0\u30EB\u30FC\u30D7\u306B\u3088\u308B\u30D5\u30A3\u30EB\u30BF\u30EA\u30F3\u30B0");
|
|
42
|
+
injectString("ko-KR", "Filter by group", "\uADF8\uB8F9\uBCC4 \uD544\uD130\uB9C1");
|
|
43
|
+
injectString("ms", "Filter by group", "Saring mengikut kumpulan");
|
|
44
|
+
injectString("nb-NO", "Filter by group", "Filtrer etter gruppe");
|
|
45
|
+
injectString("nl", "Filter by group", "Filteren op groep");
|
|
46
|
+
injectString("pl", "Filter by group", "Filtruj wed\u0142ug grupy");
|
|
47
|
+
injectString("pt-BR", "Filter by group", "Filtrar por grupo");
|
|
48
|
+
injectString("sk-SK", "Filter by group", "Filtrova\u0165 pod\u013Ea skupiny");
|
|
49
|
+
injectString("sv", "Filter by group", "Filtrera efter grupp");
|
|
50
|
+
injectString("th", "Filter by group", "\u0E01\u0E23\u0E2D\u0E07\u0E15\u0E32\u0E21\u0E01\u0E25\u0E38\u0E48\u0E21");
|
|
51
|
+
injectString("tr", "Filter by group", "Gruba g\xF6re filtrele");
|
|
52
|
+
injectString("zh-Hans", "Filter by group", "\u6309\u7EC4\u8FC7\u6EE4");
|
|
53
|
+
injectString("zh-TW", "Filter by group", "\u4F9D\u7FA4\u7D44\u7BE9\u9078");
|
|
54
|
+
export const DropdownRaw = props => {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
const {
|
|
57
|
+
className,
|
|
58
|
+
classNamePopup,
|
|
59
|
+
getData,
|
|
60
|
+
errorHandler,
|
|
61
|
+
dataItems,
|
|
62
|
+
onChange,
|
|
63
|
+
defaultValue,
|
|
64
|
+
placeholder,
|
|
65
|
+
dialogAriaLabel,
|
|
66
|
+
width,
|
|
67
|
+
isLoading,
|
|
68
|
+
title,
|
|
69
|
+
triggerAriaLabel,
|
|
70
|
+
inputId,
|
|
71
|
+
filterName,
|
|
72
|
+
showCounterPill = true,
|
|
73
|
+
showSelection,
|
|
74
|
+
fullWidthTriggerButton,
|
|
75
|
+
hasApplyButton,
|
|
76
|
+
searchField = true,
|
|
77
|
+
multiselect = true,
|
|
78
|
+
forceSelection = false,
|
|
79
|
+
selectAllButton = true,
|
|
80
|
+
getNamedItems,
|
|
81
|
+
getSelectedItem,
|
|
82
|
+
buttonType = "secondary",
|
|
83
|
+
listLimit = LIST_LIMIT,
|
|
84
|
+
alignment = "bottom-left",
|
|
85
|
+
isReadOnly,
|
|
86
|
+
sortFn,
|
|
87
|
+
checkboxLabel,
|
|
88
|
+
chip,
|
|
89
|
+
chipId,
|
|
90
|
+
chipName,
|
|
91
|
+
chipIcon,
|
|
92
|
+
setChecked,
|
|
93
|
+
setSearch,
|
|
94
|
+
fetchState,
|
|
95
|
+
isLoadingError,
|
|
96
|
+
mobileSheetStackingClassName,
|
|
97
|
+
isError,
|
|
98
|
+
firstParentNodeIsVisible
|
|
99
|
+
} = props;
|
|
100
|
+
const {
|
|
101
|
+
isFormSection
|
|
102
|
+
} = useContext(FormSectionContext);
|
|
103
|
+
const accessibilityProps = getAriaAttributes(props);
|
|
104
|
+
const isFormItemVal = isFormItem(props);
|
|
105
|
+
const {
|
|
106
|
+
field
|
|
107
|
+
} = useFormField(props.controller);
|
|
108
|
+
const {
|
|
109
|
+
name,
|
|
110
|
+
value = [],
|
|
111
|
+
disabled,
|
|
112
|
+
onBlur
|
|
113
|
+
} = useFormFieldValues(props.controller, props);
|
|
114
|
+
let onChangeInner, defaultValueInner;
|
|
115
|
+
if (isFormItemVal) {
|
|
116
|
+
onChangeInner = val => {
|
|
117
|
+
field === null || field === void 0 ? void 0 : field.onChange(val.map(item => item.id));
|
|
118
|
+
};
|
|
119
|
+
defaultValueInner = ((_a = props.controller) === null || _a === void 0 ? void 0 : _a.defaultValue) || [];
|
|
120
|
+
} else {
|
|
121
|
+
onChangeInner = onChange;
|
|
122
|
+
defaultValueInner = defaultValue;
|
|
123
|
+
}
|
|
124
|
+
const isFullSelectionMode = useMemo(() => typeof value === "object" && "selected" in value && Array.isArray(value.selected) && "isAllSelected" in value && typeof (value === null || value === void 0 ? void 0 : value.isAllSelected) === "boolean", [value]);
|
|
125
|
+
const isQueryMode = useMemo(() => typeof getData === "undefined" && typeof dataItems === "undefined", [getData, dataItems]);
|
|
126
|
+
const isCheckboxMode = useMemo(() => checkboxLabel && typeof value === "object" && "isChecked" in value && typeof value.isChecked === "boolean" || false, [checkboxLabel, value]);
|
|
127
|
+
const [initialInChecked] = useState(isCheckboxMode ? value.isChecked : undefined);
|
|
128
|
+
const [state, dispatchState] = useReducer(stateReducer, getInitialState(isFullSelectionMode, isQueryMode ? (fetchState === null || fetchState === void 0 ? void 0 : fetchState.data) || [] : dataItems || [], isFullSelectionMode || isCheckboxMode ? value.selected : value, listLimit, defaultValue ? isFullSelectionMode || isCheckboxMode ? defaultValue.selected : defaultValue : undefined, isFullSelectionMode ? value.isAllSelected : undefined, defaultValue ? isFullSelectionMode ? defaultValue.isAllSelected : undefined : undefined, isCheckboxMode ? value.isChecked : undefined, isCheckboxMode && defaultValue ? defaultValue.isChecked : undefined, firstParentNodeIsVisible));
|
|
129
|
+
const chipStatus = useChipStatus();
|
|
130
|
+
const isMobile = useMobile();
|
|
131
|
+
const abortToken = useRef(new AbortController());
|
|
132
|
+
const triggerRef = useRef(null);
|
|
133
|
+
const comboboxRef = useRef(null);
|
|
134
|
+
const inputRef = useRef(null);
|
|
135
|
+
const contentRef = useRef(null);
|
|
136
|
+
const prevSelectedIds = useRef({
|
|
137
|
+
selected: [],
|
|
138
|
+
isAllSelected: undefined,
|
|
139
|
+
isChecked: initialInChecked
|
|
140
|
+
});
|
|
141
|
+
const prevSelection = useRef({
|
|
142
|
+
selected: [],
|
|
143
|
+
isAllSelected: undefined,
|
|
144
|
+
isChecked: initialInChecked
|
|
145
|
+
});
|
|
146
|
+
const {
|
|
147
|
+
translate
|
|
148
|
+
} = useLanguage();
|
|
149
|
+
const getNamedItemsHasBeenCalled = useRef(false);
|
|
150
|
+
const selectedItemsLoader = useRef(undefined);
|
|
151
|
+
const previousMapDataItems = useRef(isQueryMode ? (fetchState === null || fetchState === void 0 ? void 0 : fetchState.data) || [] : !getData && (dataItems === null || dataItems === void 0 ? void 0 : dataItems.length) ? dataItems : []);
|
|
152
|
+
const prevIsLoading = useRef(isLoading);
|
|
153
|
+
const prevIsChecked = useRef(isCheckboxMode ? value.isChecked : undefined);
|
|
154
|
+
const currentAllSelected = useMemo(() => state.isNestedList || !multiselect || !isFullSelectionMode ? undefined : state.isAllSelected, [state.isNestedList, state.isAllSelected, multiselect, isFullSelectionMode]);
|
|
155
|
+
const currentIsChecked = useMemo(() => isCheckboxMode ? value.isChecked : undefined, [isCheckboxMode, value]);
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
const timeoutId = setTimeout(() => {
|
|
158
|
+
if (Object.keys(state.groupsMap).length === 0 && getData) {
|
|
159
|
+
const currentAbort = abortToken.current;
|
|
160
|
+
(initialInChecked !== undefined ? getData(currentAbort.signal, undefined, initialInChecked) : getData(currentAbort.signal, undefined)).then(dta => {
|
|
161
|
+
dta.length && dispatchState({
|
|
162
|
+
type: StateActionType.CreateMap,
|
|
163
|
+
payload: dta
|
|
164
|
+
});
|
|
165
|
+
previousMapDataItems.current = [...dta];
|
|
166
|
+
}).catch(errorHandler);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
return () => clearTimeout(timeoutId);
|
|
170
|
+
}, [getData, errorHandler, state.groupsMap, initialInChecked]);
|
|
171
|
+
useEffect(() => {
|
|
172
|
+
const timeoutId = setTimeout(() => {
|
|
173
|
+
if (!getData && dataItems && dataItems.length && !compareObjectsArrays(dataItems, previousMapDataItems.current)) {
|
|
174
|
+
dispatchState({
|
|
175
|
+
type: StateActionType.CreateMap,
|
|
176
|
+
payload: dataItems
|
|
139
177
|
});
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
178
|
+
previousMapDataItems.current = [...dataItems];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
return () => clearTimeout(timeoutId);
|
|
182
|
+
}, [dataItems, getData, state.groupsMap]);
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
if (prevIsLoading.current !== isLoading && Object.keys(state.groupsMap).length !== 0) {
|
|
185
|
+
isLoading === false && dispatchState({
|
|
186
|
+
type: StateActionType.ShowList,
|
|
187
|
+
payload: undefined
|
|
188
|
+
});
|
|
189
|
+
prevIsLoading.current = isLoading;
|
|
190
|
+
}
|
|
191
|
+
}, [isLoading, dataItems, state.groupsMap]);
|
|
192
|
+
useEffect(() => {
|
|
193
|
+
const defaultSelectedValue = defaultValue ? isFullSelectionMode || isCheckboxMode ? defaultValue.selected : defaultValue : [];
|
|
194
|
+
const defaultAllSelectedValue = defaultValue ? isFullSelectionMode ? defaultValue.isAllSelected : undefined : isFullSelectionMode ? false : undefined;
|
|
195
|
+
const defaultIsCheckedValue = defaultValue ? isCheckboxMode ? defaultValue.isChecked || false : undefined : isCheckboxMode ? false : undefined;
|
|
196
|
+
if (defaultIsCheckedValue !== state.defaultValueIsChecked) {
|
|
197
|
+
defaultIsCheckedValue !== undefined && dispatchState({
|
|
198
|
+
type: StateActionType.SetDefaultIsChecked,
|
|
199
|
+
payload: defaultIsCheckedValue
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
if (compareStringsArrays(defaultSelectedValue, state.defaultValue) && defaultAllSelectedValue === state.defaultValueIsAllSelected) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
dispatchState({
|
|
206
|
+
type: StateActionType.SetDefaultValue,
|
|
207
|
+
payload: defaultSelectedValue
|
|
208
|
+
});
|
|
209
|
+
isFullSelectionMode && defaultAllSelectedValue !== state.defaultValueIsAllSelected && dispatchState({
|
|
210
|
+
type: StateActionType.SetDefaultAllSelected,
|
|
211
|
+
payload: defaultAllSelectedValue
|
|
212
|
+
});
|
|
213
|
+
}, [defaultValue, defaultValueInner, isCheckboxMode, isFullSelectionMode, state.defaultValue, state.defaultValueIsAllSelected, state.defaultValueIsChecked]);
|
|
214
|
+
const loadSelectedItems = useCallback(ids => {
|
|
215
|
+
if (!getSelectedItem || !ids.size) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const promises = [];
|
|
219
|
+
Array.from(ids).forEach((id, ind) => {
|
|
220
|
+
if (ind > 99) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const itemOrPromise = getSelectedItem(id);
|
|
224
|
+
promises.push(Promise.resolve(itemOrPromise));
|
|
225
|
+
});
|
|
226
|
+
// eslint-disable-next-line consistent-return
|
|
227
|
+
return Promise.all(promises).then(items => {
|
|
228
|
+
const result = items.filter(el => el !== undefined);
|
|
229
|
+
dispatchState({
|
|
230
|
+
type: StateActionType.UpdateSelectedItems,
|
|
231
|
+
payload: result
|
|
232
|
+
});
|
|
233
|
+
getNamedItemsHasBeenCalled.current = false;
|
|
234
|
+
}).catch(() => {
|
|
235
|
+
dispatchState({
|
|
236
|
+
type: StateActionType.UpdateSelectedItems,
|
|
237
|
+
payload: []
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
}, [getSelectedItem]);
|
|
241
|
+
useEffect(() => {
|
|
242
|
+
if (isLoadingError) {
|
|
243
|
+
dispatchState({
|
|
244
|
+
type: StateActionType.SetIsOpenCombo,
|
|
245
|
+
payload: false
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}, [isLoadingError]);
|
|
249
|
+
useEffect(() => {
|
|
250
|
+
if (!getSelectedItem) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
dispatchState({
|
|
254
|
+
type: StateActionType.UpdateNamelessItems,
|
|
255
|
+
payload: undefined
|
|
256
|
+
});
|
|
257
|
+
}, [getSelectedItem]);
|
|
258
|
+
useEffect(() => {
|
|
259
|
+
if (state.namelessIds.size === 0 || !getSelectedItem || state.pendingNamelessIds) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
selectedItemsLoader.current = loadSelectedItems(state.namelessIds);
|
|
263
|
+
dispatchState({
|
|
264
|
+
type: StateActionType.SetPendingState,
|
|
265
|
+
payload: true
|
|
266
|
+
});
|
|
267
|
+
}, [getSelectedItem, loadSelectedItems, state.namelessIds, state.pendingNamelessIds]);
|
|
268
|
+
useEffect(() => {
|
|
269
|
+
dispatchState({
|
|
270
|
+
type: StateActionType.SetFirstParentNodeIsVisible,
|
|
271
|
+
payload: firstParentNodeIsVisible
|
|
272
|
+
});
|
|
273
|
+
}, [firstParentNodeIsVisible]);
|
|
274
|
+
const handleChangeCurrentId = useCallback(id => {
|
|
275
|
+
dispatchState({
|
|
276
|
+
type: StateActionType.SetCurrentId,
|
|
277
|
+
payload: id
|
|
278
|
+
});
|
|
279
|
+
dispatchState({
|
|
280
|
+
type: StateActionType.SetInputValue,
|
|
281
|
+
payload: ""
|
|
282
|
+
});
|
|
283
|
+
isQueryMode && setSearch && setSearch("");
|
|
284
|
+
}, [isQueryMode, setSearch]);
|
|
285
|
+
const handleBackButtonClick = useCallback(() => {
|
|
286
|
+
var _a, _b;
|
|
287
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
288
|
+
const newCurrentId = state.currentId ? (_b = (_a = state.groupsMap[state.currentId]) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.id : undefined;
|
|
289
|
+
dispatchState({
|
|
290
|
+
type: StateActionType.SetCurrentId,
|
|
291
|
+
payload: newCurrentId === state.rootId || state.inputValue ? undefined : newCurrentId
|
|
292
|
+
});
|
|
293
|
+
}, [state.currentId, state.groupsMap, state.inputValue, state.rootId]);
|
|
294
|
+
const handleSelect = useCallback(val => {
|
|
295
|
+
if (isFullSelectionMode && state.isAllSelected) {
|
|
296
|
+
dispatchState({
|
|
297
|
+
type: StateActionType.DeselectItemsFromAllSelected,
|
|
298
|
+
payload: val.id
|
|
299
|
+
});
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (val.partial) {
|
|
303
|
+
dispatchState({
|
|
304
|
+
type: StateActionType.DeselectAllChildren,
|
|
305
|
+
payload: val.id
|
|
306
|
+
});
|
|
307
|
+
} else {
|
|
308
|
+
dispatchState({
|
|
309
|
+
type: StateActionType.ChangeSelection,
|
|
310
|
+
payload: {
|
|
311
|
+
value: val.state,
|
|
312
|
+
itemId: val.id
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
}, [isFullSelectionMode, state.isAllSelected]);
|
|
317
|
+
const handleClose = useCallback(() => {
|
|
318
|
+
dispatchState({
|
|
319
|
+
type: StateActionType.SetInputValue,
|
|
320
|
+
payload: ""
|
|
321
|
+
});
|
|
322
|
+
if (!triggerRef.current) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (isFocusable(triggerRef.current)) {
|
|
326
|
+
triggerRef.current.focus();
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
const focusable = [...Array.from(triggerRef.current.querySelectorAll(FOCUSABLE_SELECTOR))];
|
|
330
|
+
(focusable[0] || triggerRef.current).focus();
|
|
331
|
+
}, []);
|
|
332
|
+
const handleEscape = useCallback(() => {
|
|
333
|
+
dispatchState({
|
|
334
|
+
type: StateActionType.SetIsOpenCombo,
|
|
335
|
+
payload: false
|
|
336
|
+
});
|
|
337
|
+
dispatchState({
|
|
338
|
+
type: StateActionType.SetCurrentId,
|
|
339
|
+
payload: undefined
|
|
340
|
+
});
|
|
341
|
+
abortToken.current.abort();
|
|
342
|
+
abortToken.current = new AbortController();
|
|
343
|
+
handleClose();
|
|
344
|
+
}, [handleClose]);
|
|
345
|
+
const memoizedAllowClosing = useMemo(() => state.currentId === undefined || state.currentId === state.rootId, [state.currentId, state.rootId]);
|
|
346
|
+
const handleSingleSelection = useCallback((reset, selected) => {
|
|
347
|
+
const shouldBeClosed = !hasApplyButton && memoizedAllowClosing && (!reset && selected || reset);
|
|
348
|
+
dispatchState({
|
|
349
|
+
type: StateActionType.ChangeSingleSelection,
|
|
350
|
+
payload: {
|
|
351
|
+
value: selected,
|
|
352
|
+
reset: reset
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
shouldBeClosed && handleEscape();
|
|
356
|
+
shouldBeClosed && dispatchState({
|
|
357
|
+
type: StateActionType.SetInputValue,
|
|
358
|
+
payload: ""
|
|
359
|
+
});
|
|
360
|
+
}, [handleEscape, hasApplyButton, memoizedAllowClosing]);
|
|
361
|
+
const handleSelectAllClick = useCallback(isAllSelect => {
|
|
362
|
+
if (isFullSelectionMode) {
|
|
363
|
+
dispatchState({
|
|
364
|
+
type: StateActionType.ToggleValueForAllSelected,
|
|
365
|
+
payload: undefined
|
|
366
|
+
});
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
dispatchState({
|
|
370
|
+
type: isAllSelect ? StateActionType.DeselectAllChildren : StateActionType.SelectAllChildren,
|
|
371
|
+
payload: state.currentId || state.rootId
|
|
372
|
+
});
|
|
373
|
+
}, [isFullSelectionMode, state.currentId, state.rootId]);
|
|
374
|
+
const handleSelectAllInSearch = useCallback(isAllSelect => {
|
|
375
|
+
if (isFullSelectionMode && state.isAllSelected) {
|
|
376
|
+
dispatchState({
|
|
377
|
+
type: StateActionType.DeselectItemsFromAllSelected,
|
|
378
|
+
payload: undefined
|
|
379
|
+
});
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
const dataForChange = getDataForChange(getListDataWithDisabled(state.listData, state.isNestedList), state.selectedIds, isAllSelect);
|
|
383
|
+
dispatchState({
|
|
384
|
+
type: StateActionType.ChangeBulkSelection,
|
|
385
|
+
payload: {
|
|
386
|
+
itemsIds: dataForChange,
|
|
387
|
+
value: !isAllSelect
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
}, [isFullSelectionMode, state.isAllSelected, state.listData, state.isNestedList, state.selectedIds]);
|
|
391
|
+
const handleClearClick = useCallback(() => {
|
|
392
|
+
dispatchState({
|
|
393
|
+
type: StateActionType.ResetSelection,
|
|
394
|
+
payload: undefined
|
|
395
|
+
});
|
|
396
|
+
}, []);
|
|
397
|
+
const handleCancelClick = useCallback(() => {
|
|
398
|
+
dispatchState({
|
|
399
|
+
type: StateActionType.ResetStateToGlobal,
|
|
400
|
+
payload: undefined
|
|
401
|
+
});
|
|
402
|
+
dispatchState({
|
|
403
|
+
type: StateActionType.SetIsOpenCombo,
|
|
404
|
+
payload: false
|
|
405
|
+
});
|
|
406
|
+
dispatchState({
|
|
407
|
+
type: StateActionType.SetCurrentId,
|
|
408
|
+
payload: undefined
|
|
409
|
+
});
|
|
410
|
+
abortToken.current.abort();
|
|
411
|
+
abortToken.current = new AbortController();
|
|
412
|
+
handleClose();
|
|
413
|
+
}, [handleClose]);
|
|
414
|
+
const handleApplyClick = useCallback(() => {
|
|
415
|
+
dispatchState({
|
|
416
|
+
type: StateActionType.SetGlobalState,
|
|
417
|
+
payload: Object.assign({
|
|
418
|
+
selected: state.selectedIds,
|
|
419
|
+
isAllSelected: state.isAllSelected
|
|
420
|
+
}, isCheckboxMode ? {
|
|
421
|
+
isChecked: state.isChecked
|
|
422
|
+
} : {})
|
|
423
|
+
});
|
|
424
|
+
dispatchState({
|
|
425
|
+
type: StateActionType.SetIsOpenCombo,
|
|
426
|
+
payload: false
|
|
427
|
+
});
|
|
428
|
+
dispatchState({
|
|
429
|
+
type: StateActionType.SetCurrentId,
|
|
430
|
+
payload: undefined
|
|
431
|
+
});
|
|
432
|
+
abortToken.current.abort();
|
|
433
|
+
abortToken.current = new AbortController();
|
|
434
|
+
handleClose();
|
|
435
|
+
dispatchState({
|
|
436
|
+
type: StateActionType.SetDataProblem,
|
|
437
|
+
payload: checkIsDataProblem(state.selectedIds, state.groupsMap)
|
|
438
|
+
});
|
|
439
|
+
const preparedItems = prepareSelectedIdsToItems(state.selectedIds, state.groupsMap, state.groupsMapSelected);
|
|
440
|
+
if (isFullSelectionMode) {
|
|
441
|
+
const newValue = isCheckboxMode ? {
|
|
442
|
+
selected: preparedItems,
|
|
443
|
+
isAllSelected: state.isAllSelected || false,
|
|
444
|
+
isChecked: state.isChecked
|
|
445
|
+
} : {
|
|
446
|
+
selected: preparedItems,
|
|
447
|
+
isAllSelected: state.isAllSelected || false
|
|
448
|
+
};
|
|
449
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
450
|
+
} else {
|
|
451
|
+
const newValue = isCheckboxMode ? {
|
|
452
|
+
selected: preparedItems,
|
|
453
|
+
isChecked: state.isChecked
|
|
454
|
+
} : preparedItems;
|
|
455
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
456
|
+
}
|
|
457
|
+
}, [state.selectedIds, state.isAllSelected, state.isChecked, state.groupsMap, state.groupsMapSelected, isCheckboxMode, handleClose, isFullSelectionMode, onChange]);
|
|
458
|
+
const customGetData = useCallback(str => str && dataItems ? Promise.resolve(dataItems.filter(el => {
|
|
459
|
+
var _a;
|
|
460
|
+
return (((_a = el.name) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) || "").indexOf(str.trim().toLocaleLowerCase()) > -1;
|
|
461
|
+
})) : Promise.resolve(dataItems || []), [dataItems]);
|
|
462
|
+
const handleData = useCallback((dta, searchVal) => {
|
|
463
|
+
if (dta.length && !searchVal && (getData || dataItems || isQueryMode)) {
|
|
464
|
+
dispatchState({
|
|
465
|
+
type: StateActionType.CreateMap,
|
|
466
|
+
payload: dta
|
|
467
|
+
});
|
|
468
|
+
previousMapDataItems.current = [...dta];
|
|
469
|
+
}
|
|
470
|
+
dispatchState({
|
|
471
|
+
type: StateActionType.SetListData,
|
|
472
|
+
payload: dta
|
|
473
|
+
});
|
|
474
|
+
searchVal && dispatchState({
|
|
475
|
+
type: StateActionType.SetCurrentId,
|
|
476
|
+
payload: undefined
|
|
477
|
+
});
|
|
478
|
+
dta.length ? dispatchState({
|
|
479
|
+
type: StateActionType.ShowList,
|
|
480
|
+
payload: undefined
|
|
481
|
+
}) : dispatchState({
|
|
482
|
+
type: StateActionType.ShowEmptyList,
|
|
483
|
+
payload: undefined
|
|
484
|
+
});
|
|
485
|
+
}, [getData, dataItems, isQueryMode]);
|
|
486
|
+
const handleError = useCallback(e => {
|
|
487
|
+
errorHandler(e);
|
|
488
|
+
dispatchState({
|
|
489
|
+
type: StateActionType.NothingToShow,
|
|
490
|
+
payload: undefined
|
|
491
|
+
});
|
|
492
|
+
}, [errorHandler]);
|
|
493
|
+
const handleDataQuery = useCallback((dta, searchVal) => {
|
|
494
|
+
if (dta.length && !searchVal && !compareObjectsArrays(dta, previousMapDataItems.current)) {
|
|
495
|
+
dispatchState({
|
|
496
|
+
type: StateActionType.CreateMap,
|
|
497
|
+
payload: dta
|
|
498
|
+
});
|
|
499
|
+
previousMapDataItems.current = [...dta];
|
|
500
|
+
}
|
|
501
|
+
dispatchState({
|
|
502
|
+
type: StateActionType.SetListData,
|
|
503
|
+
payload: dta
|
|
504
|
+
});
|
|
505
|
+
searchVal && dispatchState({
|
|
506
|
+
type: StateActionType.SetCurrentId,
|
|
507
|
+
payload: undefined
|
|
508
|
+
});
|
|
509
|
+
dta.length ? dispatchState({
|
|
510
|
+
type: StateActionType.ShowList,
|
|
511
|
+
payload: undefined
|
|
512
|
+
}) : dispatchState({
|
|
513
|
+
type: StateActionType.ShowEmptyList,
|
|
514
|
+
payload: undefined
|
|
515
|
+
});
|
|
516
|
+
}, []);
|
|
517
|
+
const handleQueryMode = useCallback((searchValue, isChecked) => {
|
|
518
|
+
setChecked && isChecked !== undefined && setChecked(isChecked);
|
|
519
|
+
setSearch && setSearch(searchValue || "");
|
|
520
|
+
}, [setChecked, setSearch]);
|
|
521
|
+
const debouncedGetData = useDebounce((signal, searchValue, isChecked) => getData ? (isCheckboxMode ? getData(signal, searchValue, isChecked) : getData(signal, searchValue)).then(dta => handleData(dta, searchValue)).catch(handleError) : customGetData(searchValue).then(dta => handleData(dta, searchValue)).catch(handleError), 200);
|
|
522
|
+
const controlData = useCallback((signal, searchValue, isChecked) => {
|
|
523
|
+
!isQueryMode && dispatchState({
|
|
524
|
+
type: StateActionType.ShowWaiting,
|
|
525
|
+
payload: undefined
|
|
526
|
+
});
|
|
527
|
+
isQueryMode ? handleQueryMode(searchValue, isChecked) : debouncedGetData(signal, searchValue, isChecked);
|
|
528
|
+
}, [debouncedGetData, handleQueryMode, isQueryMode]);
|
|
529
|
+
useEffect(() => {
|
|
530
|
+
const timeoutId = setTimeout(() => {
|
|
531
|
+
if (!isQueryMode || (fetchState === null || fetchState === void 0 ? void 0 : fetchState.isLoading)) {
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
handleDataQuery((fetchState === null || fetchState === void 0 ? void 0 : fetchState.data) || [], state.inputValue);
|
|
535
|
+
});
|
|
536
|
+
return () => clearTimeout(timeoutId);
|
|
537
|
+
}, [fetchState === null || fetchState === void 0 ? void 0 : fetchState.data, handleDataQuery, fetchState === null || fetchState === void 0 ? void 0 : fetchState.isLoading, isQueryMode, state.inputValue]);
|
|
538
|
+
useEffect(() => {
|
|
539
|
+
// when change inside
|
|
540
|
+
if (hasApplyButton) {
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
const prevIsCheckedValue = isCheckboxMode ? prevSelectedIds.current.isChecked : undefined;
|
|
544
|
+
if (compareStringsArrays(prevSelectedIds.current.selected, state.selectedIds) && prevSelectedIds.current.isAllSelected === state.isAllSelected && prevIsCheckedValue === state.isChecked) {
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
prevSelectedIds.current = {
|
|
548
|
+
selected: state.selectedIds,
|
|
549
|
+
isAllSelected: state.isAllSelected,
|
|
550
|
+
isChecked: state.isChecked
|
|
551
|
+
};
|
|
552
|
+
if (compareStringsArrays(state.selectedIds, isFullSelectionMode || isCheckboxMode ? value.selected : value) && state.isAllSelected === (isFullSelectionMode ? value.isAllSelected : undefined) && state.isChecked === (isCheckboxMode ? value.isChecked : undefined)) {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
dispatchState({
|
|
556
|
+
type: StateActionType.SetDataProblem,
|
|
557
|
+
payload: checkIsDataProblem(state.selectedIds, state.groupsMap)
|
|
558
|
+
});
|
|
559
|
+
const preparedItems = prepareSelectedIdsToItems(state.selectedIds, state.groupsMap, state.groupsMapSelected);
|
|
560
|
+
if (isFullSelectionMode) {
|
|
561
|
+
const newValue = isCheckboxMode ? {
|
|
562
|
+
selected: preparedItems,
|
|
563
|
+
isAllSelected: state.isAllSelected || false,
|
|
564
|
+
isChecked: state.isChecked
|
|
565
|
+
} : {
|
|
566
|
+
selected: preparedItems,
|
|
567
|
+
isAllSelected: state.isAllSelected || false
|
|
568
|
+
};
|
|
569
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
570
|
+
} else {
|
|
571
|
+
const newValue = isCheckboxMode ? {
|
|
572
|
+
selected: preparedItems,
|
|
573
|
+
isChecked: state.isChecked
|
|
574
|
+
} : preparedItems;
|
|
575
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
576
|
+
}
|
|
577
|
+
// eslint-disable-next-line max-len
|
|
578
|
+
}, [onChangeInner, value, state.selectedIds, state.groupsMapSelected, state.groupsMap, hasApplyButton, state.isAllSelected, isFullSelectionMode, state.isChecked, isCheckboxMode, onChange]);
|
|
579
|
+
useEffect(() => {
|
|
580
|
+
// when change outside
|
|
581
|
+
const selectedValue = isFullSelectionMode || isCheckboxMode ? value.selected : value;
|
|
582
|
+
const isAllSelectedValue = isFullSelectionMode ? value.isAllSelected : undefined;
|
|
583
|
+
const isCheckedValue = isCheckboxMode ? value.isChecked : undefined;
|
|
584
|
+
if (compareStringsArrays(prevSelection.current.selected, selectedValue) && isAllSelectedValue === prevSelection.current.isAllSelected && prevSelection.current.isChecked === isCheckedValue) {
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
prevSelection.current = {
|
|
588
|
+
selected: selectedValue,
|
|
589
|
+
isAllSelected: isAllSelectedValue,
|
|
590
|
+
isChecked: isCheckedValue
|
|
591
|
+
};
|
|
592
|
+
if (compareStringsArrays(hasApplyButton ? state.globalSelectedIds : state.selectedIds, selectedValue) && isAllSelectedValue === (hasApplyButton ? state.globalIsAllSelected : state.isAllSelected) && isCheckedValue === (hasApplyButton ? state.globalIsChecked : state.isChecked)) {
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
// prevSelectedIds.current = { selected: selectedValue, isAllSelected: isAllSelectedValue, isChecked: isCheckedValue };
|
|
596
|
+
hasApplyButton && dispatchState({
|
|
597
|
+
type: StateActionType.SetGlobalState,
|
|
598
|
+
payload: {
|
|
599
|
+
selected: selectedValue,
|
|
600
|
+
isAllSelected: isAllSelectedValue,
|
|
601
|
+
isChecked: isCheckedValue
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
dispatchState({
|
|
605
|
+
type: StateActionType.SetState,
|
|
606
|
+
payload: {
|
|
607
|
+
selected: selectedValue,
|
|
608
|
+
isAllSelected: isAllSelectedValue
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
isCheckboxMode && isCheckedValue !== undefined && dispatchState({
|
|
612
|
+
type: StateActionType.SetIsChecked,
|
|
613
|
+
payload: isCheckedValue
|
|
614
|
+
});
|
|
615
|
+
}, [value, state.selectedIds, state.globalSelectedIds, hasApplyButton, isFullSelectionMode, state.isAllSelected, state.globalIsAllSelected, isCheckboxMode, state.globalIsChecked, state.isChecked]);
|
|
616
|
+
useEffect(() => {
|
|
617
|
+
if (!isCheckboxMode || prevIsChecked.current === undefined) {
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
if (state.isChecked === prevIsChecked.current) {
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
prevIsChecked.current = state.isChecked;
|
|
624
|
+
const currentAbort = abortToken.current;
|
|
625
|
+
controlData(currentAbort.signal, state.inputValue, state.isChecked);
|
|
626
|
+
}, [controlData, state.inputValue, state.isChecked, isCheckboxMode]);
|
|
627
|
+
useEscape(triggerRef, handleEscape, state.isOpenCombo);
|
|
628
|
+
const onSearchChange = useCallback(event => {
|
|
629
|
+
const newValue = event ? event.currentTarget.value : "";
|
|
630
|
+
dispatchState({
|
|
631
|
+
type: StateActionType.SetInputValue,
|
|
632
|
+
payload: newValue
|
|
633
|
+
});
|
|
634
|
+
const currentAbort = abortToken.current;
|
|
635
|
+
controlData(currentAbort.signal, newValue, state.isChecked);
|
|
636
|
+
}, [controlData, state.isChecked]);
|
|
637
|
+
const onInputChange = useCallback(newValue => {
|
|
638
|
+
dispatchState({
|
|
639
|
+
type: StateActionType.SetInputValue,
|
|
640
|
+
payload: newValue || ""
|
|
641
|
+
});
|
|
642
|
+
const currentAbort = abortToken.current;
|
|
643
|
+
controlData(currentAbort.signal, newValue, state.isChecked);
|
|
644
|
+
}, [controlData, state.isChecked]);
|
|
645
|
+
const containerClassName = classNames(["zen-dropdown", isFormSection ? "zen-dropdown--form-item" : "", "zen-dropdown__container", className || ""]);
|
|
646
|
+
const handleCheckboxChange = useCallback(e => {
|
|
647
|
+
const isChecked = e.target.checked;
|
|
648
|
+
dispatchState({
|
|
649
|
+
type: StateActionType.SetIsChecked,
|
|
650
|
+
payload: isChecked
|
|
651
|
+
});
|
|
652
|
+
prevIsChecked.current = isChecked;
|
|
653
|
+
const currentAbort = abortToken.current;
|
|
654
|
+
controlData(currentAbort.signal, state.inputValue, isChecked);
|
|
655
|
+
}, [controlData, state.inputValue]);
|
|
656
|
+
const handleTriggerClick = useCallback(newVal => {
|
|
657
|
+
const currentAbort = abortToken.current;
|
|
658
|
+
dispatchState({
|
|
659
|
+
type: StateActionType.SetCurrentId,
|
|
660
|
+
payload: undefined
|
|
661
|
+
});
|
|
662
|
+
dispatchState({
|
|
663
|
+
type: StateActionType.SetIsOpenCombo,
|
|
664
|
+
payload: newVal
|
|
665
|
+
});
|
|
666
|
+
newVal && controlData(currentAbort.signal, state.inputValue, state.isChecked);
|
|
667
|
+
!newVal && dispatchState({
|
|
668
|
+
type: StateActionType.SetInputValue,
|
|
669
|
+
payload: ""
|
|
670
|
+
});
|
|
671
|
+
}, [controlData, state.inputValue, state.isChecked]);
|
|
672
|
+
const handleReadyForFocus = useCallback(isCurrentOpen => {
|
|
673
|
+
var _a;
|
|
674
|
+
if (!state.showList) {
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
if (!isCurrentOpen) {
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
const firstFocusable = (_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(FOCUSABLE_SELECTOR);
|
|
681
|
+
if (firstFocusable && (state.currentId || !searchField)) {
|
|
682
|
+
firstFocusable.focus();
|
|
683
|
+
} else {
|
|
684
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
685
|
+
(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) && inputRef.current.focus();
|
|
686
|
+
}
|
|
687
|
+
}, [searchField, state.currentId, state.showList, contentRef]);
|
|
688
|
+
useEffect(() => {
|
|
689
|
+
var _a;
|
|
690
|
+
if (!state.isOpenCombo || !state.showList) {
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
const firstFocusable = (_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(FOCUSABLE_SELECTOR);
|
|
694
|
+
if (firstFocusable && (state.currentId || !searchField)) {
|
|
695
|
+
firstFocusable.focus();
|
|
696
|
+
} else {
|
|
697
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
698
|
+
(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) && inputRef.current.focus();
|
|
699
|
+
}
|
|
700
|
+
}, [state.isOpenCombo, state.currentId, state.showList, searchField]);
|
|
701
|
+
useEffect(() => {
|
|
702
|
+
const shouldExit = !getNamedItems || Object.keys(state.groupsMap).length === 0 && Object.keys(state.groupsMapSelected).length === 0 || getNamedItemsHasBeenCalled.current || state.groupsMapSelected.size === 0;
|
|
703
|
+
if (shouldExit) {
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
getNamedItemsHasBeenCalled.current = true;
|
|
707
|
+
getNamedItems(items => prepareSelectedIdsToItems(items, state.groupsMap, state.groupsMapSelected));
|
|
708
|
+
}, [getNamedItems, state.groupsMap, state.groupsMapSelected, state.namelessIds]);
|
|
709
|
+
useEffect(() => {
|
|
710
|
+
if (state.hasDataProblem && multiselect && state.isNestedList) {
|
|
711
|
+
// eslint-disable-next-line max-len
|
|
712
|
+
console.error("The data retrieved using the getData function could not form a valid object for displaying nested data. The currently displayed data contains nested elements. It is expected that selecting a nested item should deselect its parent, which cannot be achieved with the formed object.");
|
|
713
|
+
}
|
|
714
|
+
}, [state.hasDataProblem, multiselect, state.isNestedList]);
|
|
715
|
+
useEffect(() => {
|
|
716
|
+
if (state.isNestedList && isFullSelectionMode) {
|
|
717
|
+
// eslint-disable-next-line max-len
|
|
718
|
+
console.error("The IDropdownFullSelection interface is not designed to handle nested data. The IDropdownFullSelection interface is intended for use with flat data. If you need to use it with nested data, please use the IDropdown interface instead.");
|
|
719
|
+
}
|
|
720
|
+
}, [state.isNestedList, isFullSelectionMode]);
|
|
721
|
+
const memoizedWithFooter = useMemo(() => !(forceSelection && !state.defaultValue.length && !hasApplyButton), [forceSelection, hasApplyButton, state.defaultValue.length]);
|
|
722
|
+
const memoizedIsClearButtonDisabled = useMemo(() => {
|
|
723
|
+
if (forceSelection && !multiselect && !state.defaultValue.length) {
|
|
724
|
+
return true;
|
|
725
|
+
}
|
|
726
|
+
const isStringsTheSame = compareStringsArrays(state.selectedIds, state.defaultValue);
|
|
727
|
+
const isCheckedEqualDefault = currentIsChecked !== undefined ? currentIsChecked === state.defaultValueIsChecked : true;
|
|
728
|
+
if (currentAllSelected !== undefined && state.defaultValueIsAllSelected !== undefined && state.defaultValueIsAllSelected && isCheckedEqualDefault) {
|
|
729
|
+
return currentAllSelected === state.defaultValueIsAllSelected;
|
|
730
|
+
}
|
|
731
|
+
return currentAllSelected !== undefined ? state.defaultValueIsAllSelected === currentAllSelected && isStringsTheSame && isCheckedEqualDefault : isStringsTheSame && isCheckedEqualDefault;
|
|
732
|
+
}, [currentAllSelected, currentIsChecked, forceSelection, multiselect, state.defaultValue, state.defaultValueIsAllSelected, state.defaultValueIsChecked, state.selectedIds]);
|
|
733
|
+
const memoizedIsApplyButtonDisabled = useMemo(() => compareStringsArrays(state.globalSelectedIds, state.selectedIds) && (isFullSelectionMode ? state.globalIsAllSelected === state.isAllSelected : true) && (isCheckboxMode ? state.globalIsChecked === state.isChecked : true), [isCheckboxMode, isFullSelectionMode, state.globalIsAllSelected, state.globalIsChecked, state.globalSelectedIds, state.isAllSelected, state.isChecked, state.selectedIds]);
|
|
734
|
+
const countSelected = useMemo(() => {
|
|
735
|
+
var _a, _b;
|
|
736
|
+
if (hasApplyButton && state.globalIsAllSelected || !hasApplyButton && state.isAllSelected) {
|
|
737
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
738
|
+
return ((_b = (_a = state.groupsMap[ROOT_GROUP_ID]) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.length) || 0;
|
|
739
|
+
}
|
|
740
|
+
return getSelectedCount(hasApplyButton ? state.globalSelectedIds : state.selectedIds);
|
|
741
|
+
}, [hasApplyButton, state.globalIsAllSelected, state.globalSelectedIds, state.groupsMap, state.isAllSelected, state.selectedIds]);
|
|
742
|
+
// eslint-disable-next-line complexity
|
|
743
|
+
const getPopupContent = useMemo(() => {
|
|
744
|
+
var _a, _b, _c;
|
|
745
|
+
const triggerRefWidth = (_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
|
|
746
|
+
let currentWidth = triggerRefWidth ? Math.round(triggerRefWidth) : undefined;
|
|
747
|
+
if (currentWidth && currentWidth > 420) {
|
|
748
|
+
currentWidth = 420;
|
|
749
|
+
}
|
|
750
|
+
if (currentWidth && currentWidth < 180) {
|
|
751
|
+
currentWidth = 180;
|
|
752
|
+
}
|
|
753
|
+
if (state.showWaiting || isLoading || isQueryMode && (fetchState === null || fetchState === void 0 ? void 0 : fetchState.isLoading)) {
|
|
754
|
+
return _jsx(SkeletonList, {
|
|
755
|
+
className: "zen-dropdown-list__container zen-dropdown-list__container--empty",
|
|
756
|
+
width: currentWidth
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
if (state.showEmptyList || isQueryMode && (fetchState === null || fetchState === void 0 ? void 0 : fetchState.error)) {
|
|
760
|
+
const isClearButtonDisabled = compareStringsArrays(state.selectedIds, state.defaultValue);
|
|
761
|
+
return _jsx(EmptyList, {
|
|
762
|
+
width: currentWidth,
|
|
763
|
+
onClearClick: handleClearClick,
|
|
764
|
+
onCancelClick: handleCancelClick,
|
|
765
|
+
onApplyClick: handleApplyClick,
|
|
766
|
+
hasApplyButton: hasApplyButton,
|
|
767
|
+
isApplyDisabled: compareStringsArrays(state.globalSelectedIds, state.selectedIds),
|
|
768
|
+
isClearButtonDisabled: isClearButtonDisabled,
|
|
769
|
+
isWithFooter: memoizedWithFooter && Object.keys(state.groupsMap).length === 0 && (!hasApplyButton && !isClearButtonDisabled || hasApplyButton || false),
|
|
770
|
+
hasError: state.showEmptyList && isQueryMode && (fetchState === null || fetchState === void 0 ? void 0 : fetchState.error) !== null
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
if (state.showList) {
|
|
774
|
+
const isSearchMode = state.inputValue && !state.currentId;
|
|
775
|
+
const currentListData = createListDataOptions(state, translate, isSearchMode ? sortDropdownItemArray(state.listData, sortFn).slice(0, listLimit).filter(el => el.id !== state.rootId)
|
|
776
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
777
|
+
: sortDropdownItemArray(((_b = state.groupsMap[state.currentId || state.rootId]) === null || _b === void 0 ? void 0 : _b.children) || [], sortFn).slice(0, listLimit) || [], multiselect, currentAllSelected);
|
|
778
|
+
return _jsx(DropdownList, {
|
|
779
|
+
onBackButtonClick: handleBackButtonClick,
|
|
780
|
+
onSelectAllClick: isSearchMode ? handleSelectAllInSearch : handleSelectAllClick,
|
|
781
|
+
onClearClick: handleClearClick,
|
|
782
|
+
onCancelClick: handleCancelClick,
|
|
783
|
+
onApplyClick: handleApplyClick,
|
|
784
|
+
onChange: handleSelect,
|
|
785
|
+
onSelect: handleChangeCurrentId,
|
|
786
|
+
onSingleSelect: handleSingleSelection,
|
|
787
|
+
activeValue: state.selectedIds.length ? state.selectedIds[0] : "root",
|
|
166
788
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
const handleError = useCallback((e) => {
|
|
269
|
-
errorHandler(e);
|
|
270
|
-
dispatchState({ type: StateActionType.NothingToShow, payload: undefined });
|
|
271
|
-
}, [errorHandler]);
|
|
272
|
-
const handleDataQuery = useCallback((dta, searchVal) => {
|
|
273
|
-
if (dta.length && !searchVal && !compareObjectsArrays(dta, previousMapDataItems.current)) {
|
|
274
|
-
dispatchState({ type: StateActionType.CreateMap, payload: dta });
|
|
275
|
-
previousMapDataItems.current = [...dta];
|
|
276
|
-
}
|
|
277
|
-
dispatchState({ type: StateActionType.SetListData, payload: dta });
|
|
278
|
-
searchVal && dispatchState({ type: StateActionType.SetCurrentId, payload: undefined });
|
|
279
|
-
dta.length ? dispatchState({ type: StateActionType.ShowList, payload: undefined }) : dispatchState({ type: StateActionType.ShowEmptyList, payload: undefined });
|
|
280
|
-
}, []);
|
|
281
|
-
const handleQueryMode = useCallback((searchValue, isChecked) => {
|
|
282
|
-
setChecked && isChecked !== undefined && setChecked(isChecked);
|
|
283
|
-
setSearch && setSearch(searchValue || "");
|
|
284
|
-
}, [setChecked, setSearch]);
|
|
285
|
-
const debouncedGetData = useDebounce((signal, searchValue, isChecked) => getData ? (isCheckboxMode ? getData(signal, searchValue, isChecked) : getData(signal, searchValue)).then((dta) => handleData(dta, searchValue)).catch(handleError)
|
|
286
|
-
: customGetData(searchValue).then((dta) => handleData(dta, searchValue)).catch(handleError), 200);
|
|
287
|
-
const controlData = useCallback((signal, searchValue, isChecked) => {
|
|
288
|
-
!isQueryMode && dispatchState({ type: StateActionType.ShowWaiting, payload: undefined });
|
|
289
|
-
isQueryMode ? handleQueryMode(searchValue, isChecked) : debouncedGetData(signal, searchValue, isChecked);
|
|
290
|
-
}, [debouncedGetData, handleQueryMode, isQueryMode]);
|
|
291
|
-
useEffect(() => {
|
|
292
|
-
const timeoutId = setTimeout(() => {
|
|
293
|
-
if (!isQueryMode || (fetchState === null || fetchState === void 0 ? void 0 : fetchState.isLoading)) {
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
handleDataQuery((fetchState === null || fetchState === void 0 ? void 0 : fetchState.data) || [], state.inputValue);
|
|
297
|
-
});
|
|
298
|
-
return () => clearTimeout(timeoutId);
|
|
299
|
-
}, [fetchState === null || fetchState === void 0 ? void 0 : fetchState.data, handleDataQuery, fetchState === null || fetchState === void 0 ? void 0 : fetchState.isLoading, isQueryMode, state.inputValue]);
|
|
300
|
-
useEffect(() => {
|
|
301
|
-
// when change inside
|
|
302
|
-
if (hasApplyButton) {
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
const prevIsCheckedValue = isCheckboxMode ?
|
|
306
|
-
prevSelectedIds.current.isChecked : undefined;
|
|
307
|
-
if (compareStringsArrays(prevSelectedIds.current.selected, state.selectedIds)
|
|
308
|
-
&& prevSelectedIds.current.isAllSelected === state.isAllSelected
|
|
309
|
-
&& prevIsCheckedValue === state.isChecked) {
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
prevSelectedIds.current = { selected: state.selectedIds, isAllSelected: state.isAllSelected, isChecked: state.isChecked };
|
|
313
|
-
if (compareStringsArrays(state.selectedIds, isFullSelectionMode || isCheckboxMode ? value.selected : value)
|
|
314
|
-
&& state.isAllSelected === (isFullSelectionMode ? value.isAllSelected : undefined)
|
|
315
|
-
&& state.isChecked === (isCheckboxMode ? value.isChecked : undefined)) {
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
dispatchState({ type: StateActionType.SetDataProblem, payload: checkIsDataProblem(state.selectedIds, state.groupsMap) });
|
|
319
|
-
const preparedItems = prepareSelectedIdsToItems(state.selectedIds, state.groupsMap, state.groupsMapSelected);
|
|
320
|
-
if (isFullSelectionMode) {
|
|
321
|
-
const newValue = (isCheckboxMode
|
|
322
|
-
? { selected: preparedItems, isAllSelected: state.isAllSelected || false, isChecked: state.isChecked }
|
|
323
|
-
: { selected: preparedItems, isAllSelected: state.isAllSelected || false });
|
|
324
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
const newValue = isCheckboxMode
|
|
328
|
-
? { selected: preparedItems, isChecked: state.isChecked }
|
|
329
|
-
: preparedItems;
|
|
330
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
331
|
-
}
|
|
332
|
-
// eslint-disable-next-line max-len
|
|
333
|
-
}, [onChangeInner, value, state.selectedIds, state.groupsMapSelected, state.groupsMap, hasApplyButton, state.isAllSelected, isFullSelectionMode, state.isChecked, isCheckboxMode, onChange]);
|
|
334
|
-
useEffect(() => {
|
|
335
|
-
// when change outside
|
|
336
|
-
const selectedValue = isFullSelectionMode || isCheckboxMode ? value.selected : value;
|
|
337
|
-
const isAllSelectedValue = isFullSelectionMode ? value.isAllSelected : undefined;
|
|
338
|
-
const isCheckedValue = isCheckboxMode ? value.isChecked : undefined;
|
|
339
|
-
if (compareStringsArrays(prevSelection.current.selected, selectedValue) && isAllSelectedValue === prevSelection.current.isAllSelected && prevSelection.current.isChecked === isCheckedValue) {
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
prevSelection.current = { selected: selectedValue, isAllSelected: isAllSelectedValue, isChecked: isCheckedValue };
|
|
343
|
-
if (compareStringsArrays(hasApplyButton ? state.globalSelectedIds : state.selectedIds, selectedValue)
|
|
344
|
-
&& isAllSelectedValue === (hasApplyButton ? state.globalIsAllSelected : state.isAllSelected)
|
|
345
|
-
&& isCheckedValue === (hasApplyButton ? state.globalIsChecked : state.isChecked)) {
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
// prevSelectedIds.current = { selected: selectedValue, isAllSelected: isAllSelectedValue, isChecked: isCheckedValue };
|
|
349
|
-
hasApplyButton && dispatchState({ type: StateActionType.SetGlobalState,
|
|
350
|
-
payload: { selected: selectedValue, isAllSelected: isAllSelectedValue, isChecked: isCheckedValue } });
|
|
351
|
-
dispatchState({ type: StateActionType.SetState,
|
|
352
|
-
payload: { selected: selectedValue, isAllSelected: isAllSelectedValue } });
|
|
353
|
-
isCheckboxMode && isCheckedValue !== undefined && dispatchState({ type: StateActionType.SetIsChecked, payload: isCheckedValue });
|
|
354
|
-
}, [value, state.selectedIds, state.globalSelectedIds, hasApplyButton, isFullSelectionMode, state.isAllSelected,
|
|
355
|
-
state.globalIsAllSelected, isCheckboxMode, state.globalIsChecked, state.isChecked]);
|
|
356
|
-
useEffect(() => {
|
|
357
|
-
if (!isCheckboxMode || prevIsChecked.current === undefined) {
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
if (state.isChecked === prevIsChecked.current) {
|
|
361
|
-
return;
|
|
362
|
-
}
|
|
363
|
-
prevIsChecked.current = state.isChecked;
|
|
364
|
-
const currentAbort = abortToken.current;
|
|
365
|
-
controlData(currentAbort.signal, state.inputValue, state.isChecked);
|
|
366
|
-
}, [controlData, state.inputValue, state.isChecked, isCheckboxMode]);
|
|
367
|
-
useEscape(triggerRef, handleEscape, state.isOpenCombo);
|
|
368
|
-
const onSearchChange = useCallback((event) => {
|
|
369
|
-
const newValue = event ? event.currentTarget.value : "";
|
|
370
|
-
dispatchState({ type: StateActionType.SetInputValue, payload: newValue });
|
|
371
|
-
const currentAbort = abortToken.current;
|
|
372
|
-
controlData(currentAbort.signal, newValue, state.isChecked);
|
|
373
|
-
}, [controlData, state.isChecked]);
|
|
374
|
-
const onInputChange = useCallback((newValue) => {
|
|
375
|
-
dispatchState({ type: StateActionType.SetInputValue, payload: newValue || "" });
|
|
376
|
-
const currentAbort = abortToken.current;
|
|
377
|
-
controlData(currentAbort.signal, newValue, state.isChecked);
|
|
378
|
-
}, [controlData, state.isChecked]);
|
|
379
|
-
const containerClassName = classNames([
|
|
380
|
-
"zen-dropdown",
|
|
381
|
-
isFormSection ? "zen-dropdown--form-item" : "",
|
|
382
|
-
"zen-dropdown__container",
|
|
383
|
-
className || ""
|
|
384
|
-
]);
|
|
385
|
-
const handleCheckboxChange = useCallback((e) => {
|
|
386
|
-
const isChecked = e.target.checked;
|
|
387
|
-
dispatchState({ type: StateActionType.SetIsChecked, payload: isChecked });
|
|
388
|
-
prevIsChecked.current = isChecked;
|
|
389
|
-
const currentAbort = abortToken.current;
|
|
390
|
-
controlData(currentAbort.signal, state.inputValue, isChecked);
|
|
391
|
-
}, [controlData, state.inputValue]);
|
|
392
|
-
const handleTriggerClick = useCallback((newVal) => {
|
|
393
|
-
const currentAbort = abortToken.current;
|
|
394
|
-
dispatchState({ type: StateActionType.SetCurrentId, payload: undefined });
|
|
395
|
-
dispatchState({ type: StateActionType.SetIsOpenCombo, payload: newVal });
|
|
396
|
-
newVal && controlData(currentAbort.signal, state.inputValue, state.isChecked);
|
|
397
|
-
!newVal && dispatchState({ type: StateActionType.SetInputValue, payload: "" });
|
|
398
|
-
}, [controlData, state.inputValue, state.isChecked]);
|
|
399
|
-
const handleReadyForFocus = useCallback((isCurrentOpen) => {
|
|
400
|
-
var _a;
|
|
401
|
-
if (!state.showList) {
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
if (!isCurrentOpen) {
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
const firstFocusable = (_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(FOCUSABLE_SELECTOR);
|
|
408
|
-
if (firstFocusable && (state.currentId || !searchField)) {
|
|
409
|
-
firstFocusable.focus();
|
|
410
|
-
}
|
|
411
|
-
else {
|
|
412
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
413
|
-
(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) && inputRef.current.focus();
|
|
414
|
-
}
|
|
415
|
-
}, [searchField, state.currentId, state.showList, contentRef]);
|
|
416
|
-
useEffect(() => {
|
|
417
|
-
var _a;
|
|
418
|
-
if (!state.isOpenCombo || !state.showList) {
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
const firstFocusable = (_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(FOCUSABLE_SELECTOR);
|
|
422
|
-
if (firstFocusable && (state.currentId || !searchField)) {
|
|
423
|
-
firstFocusable.focus();
|
|
424
|
-
}
|
|
425
|
-
else {
|
|
426
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
427
|
-
(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) && inputRef.current.focus();
|
|
428
|
-
}
|
|
429
|
-
}, [state.isOpenCombo, state.currentId, state.showList, searchField]);
|
|
430
|
-
useEffect(() => {
|
|
431
|
-
const shouldExit = !getNamedItems ||
|
|
432
|
-
(Object.keys(state.groupsMap).length === 0 && Object.keys(state.groupsMapSelected).length === 0) ||
|
|
433
|
-
getNamedItemsHasBeenCalled.current ||
|
|
434
|
-
state.groupsMapSelected.size === 0;
|
|
435
|
-
if (shouldExit) {
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
getNamedItemsHasBeenCalled.current = true;
|
|
439
|
-
getNamedItems((items) => prepareSelectedIdsToItems(items, state.groupsMap, state.groupsMapSelected));
|
|
440
|
-
}, [getNamedItems, state.groupsMap, state.groupsMapSelected, state.namelessIds]);
|
|
441
|
-
useEffect(() => {
|
|
442
|
-
if (state.hasDataProblem && multiselect && state.isNestedList) {
|
|
443
|
-
// eslint-disable-next-line max-len
|
|
444
|
-
console.error("The data retrieved using the getData function could not form a valid object for displaying nested data. The currently displayed data contains nested elements. It is expected that selecting a nested item should deselect its parent, which cannot be achieved with the formed object.");
|
|
445
|
-
}
|
|
446
|
-
}, [state.hasDataProblem, multiselect, state.isNestedList]);
|
|
447
|
-
useEffect(() => {
|
|
448
|
-
if (state.isNestedList && isFullSelectionMode) {
|
|
449
|
-
// eslint-disable-next-line max-len
|
|
450
|
-
console.error("The IDropdownFullSelection interface is not designed to handle nested data. The IDropdownFullSelection interface is intended for use with flat data. If you need to use it with nested data, please use the IDropdown interface instead.");
|
|
451
|
-
}
|
|
452
|
-
}, [state.isNestedList, isFullSelectionMode]);
|
|
453
|
-
const memoizedWithFooter = useMemo(() => !(forceSelection && !state.defaultValue.length && !hasApplyButton), [forceSelection, hasApplyButton, state.defaultValue.length]);
|
|
454
|
-
const memoizedIsClearButtonDisabled = useMemo(() => {
|
|
455
|
-
if (forceSelection && !multiselect && !state.defaultValue.length) {
|
|
456
|
-
return true;
|
|
457
|
-
}
|
|
458
|
-
const isStringsTheSame = compareStringsArrays(state.selectedIds, state.defaultValue);
|
|
459
|
-
const isCheckedEqualDefault = currentIsChecked !== undefined ? currentIsChecked === state.defaultValueIsChecked : true;
|
|
460
|
-
if (currentAllSelected !== undefined && state.defaultValueIsAllSelected !== undefined && state.defaultValueIsAllSelected && isCheckedEqualDefault) {
|
|
461
|
-
return currentAllSelected === state.defaultValueIsAllSelected;
|
|
462
|
-
}
|
|
463
|
-
return currentAllSelected !== undefined ? state.defaultValueIsAllSelected === currentAllSelected && isStringsTheSame && isCheckedEqualDefault : isStringsTheSame && isCheckedEqualDefault;
|
|
464
|
-
}, [currentAllSelected, currentIsChecked, forceSelection, multiselect, state.defaultValue, state.defaultValueIsAllSelected, state.defaultValueIsChecked, state.selectedIds]);
|
|
465
|
-
const memoizedIsApplyButtonDisabled = useMemo(() => compareStringsArrays(state.globalSelectedIds, state.selectedIds)
|
|
466
|
-
&& (isFullSelectionMode ? state.globalIsAllSelected === state.isAllSelected : true)
|
|
467
|
-
&& (isCheckboxMode ? state.globalIsChecked === state.isChecked : true), [isCheckboxMode, isFullSelectionMode, state.globalIsAllSelected, state.globalIsChecked, state.globalSelectedIds, state.isAllSelected, state.isChecked, state.selectedIds]);
|
|
468
|
-
const countSelected = useMemo(() => {
|
|
469
|
-
var _a, _b;
|
|
470
|
-
if (hasApplyButton && state.globalIsAllSelected || !hasApplyButton && state.isAllSelected) {
|
|
471
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
472
|
-
return ((_b = (_a = state.groupsMap[ENTIRE_ORGANIZATION_GROUP_ID]) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.length) || 0;
|
|
473
|
-
}
|
|
474
|
-
return getSelectedCount(hasApplyButton ? state.globalSelectedIds : state.selectedIds);
|
|
475
|
-
}, [hasApplyButton, state.globalIsAllSelected, state.globalSelectedIds, state.groupsMap, state.isAllSelected, state.selectedIds]);
|
|
476
|
-
// eslint-disable-next-line complexity
|
|
477
|
-
const getPopupContent = useMemo(() => {
|
|
478
|
-
var _a, _b, _c;
|
|
479
|
-
const triggerRefWidth = (_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
|
|
480
|
-
let currentWidth = triggerRefWidth ? Math.round(triggerRefWidth) : undefined;
|
|
481
|
-
if (currentWidth && currentWidth > 420) {
|
|
482
|
-
currentWidth = 420;
|
|
483
|
-
}
|
|
484
|
-
if (currentWidth && currentWidth < 180) {
|
|
485
|
-
currentWidth = 180;
|
|
486
|
-
}
|
|
487
|
-
if (state.showWaiting || isLoading || (isQueryMode && (fetchState === null || fetchState === void 0 ? void 0 : fetchState.isLoading))) {
|
|
488
|
-
return _jsx(SkeletonList, { className: "zen-dropdown-list__container zen-dropdown-list__container--empty", width: currentWidth });
|
|
489
|
-
}
|
|
490
|
-
if (state.showEmptyList || (isQueryMode && (fetchState === null || fetchState === void 0 ? void 0 : fetchState.error))) {
|
|
491
|
-
const isClearButtonDisabled = compareStringsArrays(state.selectedIds, state.defaultValue);
|
|
492
|
-
return _jsx(EmptyList, { width: currentWidth, onClearClick: handleClearClick, onCancelClick: handleCancelClick, onApplyClick: handleApplyClick, hasApplyButton: hasApplyButton, isApplyDisabled: compareStringsArrays(state.globalSelectedIds, state.selectedIds), isClearButtonDisabled: isClearButtonDisabled, isWithFooter: memoizedWithFooter && Object.keys(state.groupsMap).length === 0 && ((!hasApplyButton && !isClearButtonDisabled) || hasApplyButton || false), hasError: state.showEmptyList && (isQueryMode && (fetchState === null || fetchState === void 0 ? void 0 : fetchState.error) !== null) });
|
|
493
|
-
}
|
|
494
|
-
if (state.showList) {
|
|
495
|
-
const isSearchMode = state.inputValue && !state.currentId;
|
|
496
|
-
const currentListData = createListDataOptions(state, translate, isSearchMode ? sortDropdownItemArray(state.listData, sortFn).slice(0, listLimit).filter(el => el.id !== ENTIRE_ORGANIZATION_GROUP_ID)
|
|
497
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
498
|
-
: sortDropdownItemArray(((_b = state.groupsMap[state.currentId || ENTIRE_ORGANIZATION_GROUP_ID]) === null || _b === void 0 ? void 0 : _b.children) || [], sortFn).slice(0, listLimit) || [], multiselect, currentAllSelected);
|
|
499
|
-
return _jsx(DropdownList, { onBackButtonClick: handleBackButtonClick, onSelectAllClick: isSearchMode ? handleSelectAllInSearch : handleSelectAllClick, onClearClick: handleClearClick, onCancelClick: handleCancelClick, onApplyClick: handleApplyClick, onChange: handleSelect, onSelect: handleChangeCurrentId, onSingleSelect: handleSingleSelection, activeValue: state.selectedIds.length ? state.selectedIds[0] : "root",
|
|
500
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
501
|
-
backButtonName: state.currentId && state.groupsMap[state.currentId] ? getGroupDescription(state.groupsMap[state.currentId], translate) : undefined, filterName: isMobile ? undefined : filterName, isAllSelected: currentAllSelected ? currentAllSelected : (isSearchMode ? isEveryItemSelected(getListDataWithDisabled(state.listData, state.isNestedList), state.selectedIds)
|
|
502
|
-
: (currentAllSelected === undefined ? isAllChildrenSelected(state, state.currentId || ENTIRE_ORGANIZATION_GROUP_ID) : false)), isMultiselect: multiselect, forceSelection: forceSelection,
|
|
503
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
504
|
-
listData: currentListData, width: width || currentWidth === 180 ? undefined : currentWidth, minWidth: currentWidth, hasSelectAllButton: selectAllButton && multiselect, hasApplyButton: hasApplyButton, isApplyDisabled: memoizedIsApplyButtonDisabled, isSelectAllButtonDisable: currentListData.length === 0
|
|
505
|
-
|| isSearchMode !== "" && state.isNestedList
|
|
506
|
-
&& isAllItemsHasOneParent(state.listData.filter(el => el.id !== ENTIRE_ORGANIZATION_GROUP_ID),
|
|
507
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
508
|
-
(((_c = state.groupsMap[ENTIRE_ORGANIZATION_GROUP_ID]) === null || _c === void 0 ? void 0 : _c.children) || []).map(el => el.id)), isClearButtonDisabled: memoizedIsClearButtonDisabled, isWithFooter: memoizedWithFooter && !isMobile, isMobile: isMobile, handleCheckboxChange: isCheckboxMode && !isMobile ? handleCheckboxChange : undefined, checkboxLabel: checkboxLabel, isChecked: state.isChecked });
|
|
509
|
-
}
|
|
510
|
-
return null;
|
|
511
|
-
}, [state, isLoading, isQueryMode, fetchState === null || fetchState === void 0 ? void 0 : fetchState.isLoading, fetchState === null || fetchState === void 0 ? void 0 : fetchState.error, handleClearClick, handleCancelClick, handleApplyClick, hasApplyButton,
|
|
512
|
-
memoizedWithFooter, translate, sortFn, listLimit, multiselect, currentAllSelected, handleBackButtonClick, handleSelectAllInSearch,
|
|
513
|
-
handleSelectAllClick, handleSelect, handleChangeCurrentId, handleSingleSelection, isMobile, filterName, forceSelection, width,
|
|
514
|
-
selectAllButton, memoizedIsApplyButtonDisabled, memoizedIsClearButtonDisabled, isCheckboxMode, handleCheckboxChange, checkboxLabel]);
|
|
515
|
-
const currentStringFromSelected = isFullSelectionMode && hasApplyButton && state.globalIsAllSelected ||
|
|
516
|
-
isFullSelectionMode && !hasApplyButton && state.isAllSelected ? getStringFromAllSelected(state.groupsMap, translate)
|
|
517
|
-
: getStringFromSelected(hasApplyButton ? state.globalSelectedIds : state.selectedIds, state.groupsMapSelected, translate);
|
|
518
|
-
const memoizedCurrentSelection = useMemo(() => showSelection && !state.inputValue ? currentStringFromSelected : "", [showSelection, state.inputValue, currentStringFromSelected]);
|
|
519
|
-
const parentTriggerWidth = ((_b = comboboxRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().width) || 420;
|
|
520
|
-
if (isReadOnly) {
|
|
521
|
-
// TODO: how many items should we show?
|
|
522
|
-
return _jsx(ReviewTextControl, { value: getSelectedValues(state.groupsMapSelected) });
|
|
523
|
-
}
|
|
524
|
-
return _jsxs("div", { className: containerClassName, ref: comboboxRef, children: [chip ? _jsx(Chip, { status: memoizedIsClearButtonDisabled ? undefined : chipStatus || "active", isOpen: state.isOpenCombo, disabled: disabled, onClick: handleTriggerClick, onClose: memoizedIsClearButtonDisabled ? undefined : handleClearClick, triggerRef: triggerRef, icon: chipIcon, id: chipId, children: currentStringFromSelected || chipName }) :
|
|
525
|
-
_jsx(DropdownTrigger, Object.assign({ name: name, onBlur: onBlur, className: classNames([!width && !fullWidthTriggerButton && parentTriggerWidth < 420 && !searchField ? "zen-dropdown__trigger-button--width-parent" : ""]), currentSelection: memoizedCurrentSelection, isActive: state.isOpenCombo, id: inputId, disabled: disabled, count: showCounterPill ? countSelected : 0, fullWidth: fullWidthTriggerButton, inputValue: state.inputValue, placeholder: placeholder || translate("Filter by group"), searchField: searchField && !isMobile ? searchField : false, onSearchChange: onSearchChange, handleClick: handleTriggerClick, width: width && width > 420 ? 420 : width, title: title, triggerAriaLabel: triggerAriaLabel, triggerRef: triggerRef, inputRef: inputRef, buttonType: buttonType }, accessibilityProps)), _jsx(DropdownPopup, { alignment: alignment, triggerRef: triggerRef, classNamePopup: classNamePopup, isMobile: isMobile, dialogAriaLabel: dialogAriaLabel, disabled: disabled, filterName: filterName, hasApplyButton: hasApplyButton, inputId: inputId, isClearButtonDisabled: memoizedIsClearButtonDisabled, isApplyButtonDisabled: memoizedIsApplyButtonDisabled, isWithFooter: memoizedWithFooter, isOpenCombo: state.isOpenCombo, searchField: searchField, placeholder: placeholder, inputValue: state.inputValue, handleApplyClick: handleApplyClick, handleClearClick: multiselect ? handleClearClick : handleSingleSelection.bind(this, true), handleTriggerClick: handleTriggerClick, onInputChange: onInputChange, inputRef: inputRef, contentRef: contentRef, onReadyForFocus: handleReadyForFocus, handleCheckboxChange: isCheckboxMode && isMobile ? handleCheckboxChange : undefined, checkboxLabel: checkboxLabel, isChecked: state.isChecked, isSearchInPopup: chip, mobileSheetStackingClassName: mobileSheetStackingClassName, children: getPopupContent })] });
|
|
789
|
+
backButtonName: state.currentId && state.groupsMap[state.currentId] ? getGroupDescription(state.groupsMap[state.currentId], translate) : undefined,
|
|
790
|
+
filterName: isMobile ? undefined : filterName,
|
|
791
|
+
isAllSelected: currentAllSelected ? currentAllSelected : isSearchMode ? isEveryItemSelected(getListDataWithDisabled(state.listData, state.isNestedList), state.selectedIds) : currentAllSelected === undefined ? isAllChildrenSelected(state, state.currentId || state.rootId) : false,
|
|
792
|
+
isMultiselect: multiselect,
|
|
793
|
+
forceSelection: forceSelection,
|
|
794
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
795
|
+
listData: currentListData,
|
|
796
|
+
width: width || currentWidth === 180 ? undefined : currentWidth,
|
|
797
|
+
minWidth: currentWidth,
|
|
798
|
+
hasSelectAllButton: selectAllButton && multiselect,
|
|
799
|
+
hasApplyButton: hasApplyButton,
|
|
800
|
+
isApplyDisabled: memoizedIsApplyButtonDisabled,
|
|
801
|
+
isSelectAllButtonDisable: currentListData.length === 0 || isSearchMode !== "" && state.isNestedList && isAllItemsHasOneParent(state.listData.filter(el => el.id !== state.rootId),
|
|
802
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
803
|
+
(((_c = state.groupsMap[state.rootId]) === null || _c === void 0 ? void 0 : _c.children) || []).map(el => el.id)),
|
|
804
|
+
isClearButtonDisabled: memoizedIsClearButtonDisabled,
|
|
805
|
+
isWithFooter: memoizedWithFooter && !isMobile,
|
|
806
|
+
isMobile: isMobile,
|
|
807
|
+
handleCheckboxChange: isCheckboxMode && !isMobile ? handleCheckboxChange : undefined,
|
|
808
|
+
checkboxLabel: checkboxLabel,
|
|
809
|
+
isChecked: state.isChecked
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
return null;
|
|
813
|
+
}, [state, isLoading, isQueryMode, fetchState === null || fetchState === void 0 ? void 0 : fetchState.isLoading, fetchState === null || fetchState === void 0 ? void 0 : fetchState.error, handleClearClick, handleCancelClick, handleApplyClick, hasApplyButton, memoizedWithFooter, translate, sortFn, listLimit, multiselect, currentAllSelected, handleBackButtonClick, handleSelectAllInSearch, handleSelectAllClick, handleSelect, handleChangeCurrentId, handleSingleSelection, isMobile, filterName, forceSelection, width, selectAllButton, memoizedIsApplyButtonDisabled, memoizedIsClearButtonDisabled, isCheckboxMode, handleCheckboxChange, checkboxLabel]);
|
|
814
|
+
const currentStringFromSelected = isFullSelectionMode && hasApplyButton && state.globalIsAllSelected || isFullSelectionMode && !hasApplyButton && state.isAllSelected ? getStringFromAllSelected(state.groupsMap, translate, state.rootId) : getStringFromSelected(hasApplyButton ? state.globalSelectedIds : state.selectedIds, state.groupsMapSelected, translate, state.rootId);
|
|
815
|
+
const memoizedCurrentSelection = useMemo(() => showSelection && !state.inputValue ? currentStringFromSelected : "", [showSelection, state.inputValue, currentStringFromSelected]);
|
|
816
|
+
const parentTriggerWidth = ((_b = comboboxRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().width) || 420;
|
|
817
|
+
if (isReadOnly) {
|
|
818
|
+
// TODO: how many items should we show?
|
|
819
|
+
return _jsx(ReviewTextControl, {
|
|
820
|
+
value: getSelectedValues(state.groupsMapSelected)
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
return _jsxs("div", {
|
|
824
|
+
className: containerClassName,
|
|
825
|
+
ref: comboboxRef,
|
|
826
|
+
children: [chip ? _jsx(Chip, {
|
|
827
|
+
status: memoizedIsClearButtonDisabled ? undefined : chipStatus || "active",
|
|
828
|
+
isOpen: state.isOpenCombo,
|
|
829
|
+
disabled: disabled,
|
|
830
|
+
onClick: handleTriggerClick,
|
|
831
|
+
onClose: memoizedIsClearButtonDisabled ? undefined : handleClearClick,
|
|
832
|
+
triggerRef: triggerRef,
|
|
833
|
+
icon: chipIcon,
|
|
834
|
+
id: chipId,
|
|
835
|
+
children: currentStringFromSelected || chipName
|
|
836
|
+
}) : _jsx(DropdownTrigger, Object.assign({
|
|
837
|
+
name: name,
|
|
838
|
+
onBlur: onBlur,
|
|
839
|
+
className: classNames([!width && !fullWidthTriggerButton && parentTriggerWidth < 420 && !searchField ? "zen-dropdown__trigger-button--width-parent" : "", isError ? "zen-dropdown__trigger-button--error" : ""]),
|
|
840
|
+
currentSelection: memoizedCurrentSelection,
|
|
841
|
+
isActive: state.isOpenCombo,
|
|
842
|
+
id: inputId,
|
|
843
|
+
isError: isError,
|
|
844
|
+
disabled: disabled,
|
|
845
|
+
count: showCounterPill ? countSelected : 0,
|
|
846
|
+
fullWidth: fullWidthTriggerButton,
|
|
847
|
+
inputValue: state.inputValue,
|
|
848
|
+
placeholder: placeholder || translate("Filter by group"),
|
|
849
|
+
searchField: searchField && !isMobile ? searchField : false,
|
|
850
|
+
onSearchChange: onSearchChange,
|
|
851
|
+
handleClick: handleTriggerClick,
|
|
852
|
+
width: width && width > 420 ? 420 : width,
|
|
853
|
+
title: title,
|
|
854
|
+
triggerAriaLabel: triggerAriaLabel,
|
|
855
|
+
triggerRef: triggerRef,
|
|
856
|
+
inputRef: inputRef,
|
|
857
|
+
buttonType: buttonType
|
|
858
|
+
}, accessibilityProps)), _jsx(DropdownPopup, {
|
|
859
|
+
alignment: alignment,
|
|
860
|
+
triggerRef: triggerRef,
|
|
861
|
+
classNamePopup: classNamePopup,
|
|
862
|
+
isMobile: isMobile,
|
|
863
|
+
dialogAriaLabel: dialogAriaLabel,
|
|
864
|
+
disabled: disabled,
|
|
865
|
+
filterName: filterName,
|
|
866
|
+
hasApplyButton: hasApplyButton,
|
|
867
|
+
inputId: inputId,
|
|
868
|
+
isClearButtonDisabled: memoizedIsClearButtonDisabled,
|
|
869
|
+
isApplyButtonDisabled: memoizedIsApplyButtonDisabled,
|
|
870
|
+
isWithFooter: memoizedWithFooter,
|
|
871
|
+
isOpenCombo: state.isOpenCombo,
|
|
872
|
+
searchField: searchField,
|
|
873
|
+
placeholder: placeholder,
|
|
874
|
+
inputValue: state.inputValue,
|
|
875
|
+
handleApplyClick: handleApplyClick,
|
|
876
|
+
handleClearClick: multiselect ? handleClearClick : handleSingleSelection.bind(this, true),
|
|
877
|
+
handleTriggerClick: handleTriggerClick,
|
|
878
|
+
onInputChange: onInputChange,
|
|
879
|
+
inputRef: inputRef,
|
|
880
|
+
contentRef: contentRef,
|
|
881
|
+
onReadyForFocus: handleReadyForFocus,
|
|
882
|
+
handleCheckboxChange: isCheckboxMode && isMobile ? handleCheckboxChange : undefined,
|
|
883
|
+
checkboxLabel: checkboxLabel,
|
|
884
|
+
isChecked: state.isChecked,
|
|
885
|
+
isSearchInPopup: chip,
|
|
886
|
+
mobileSheetStackingClassName: mobileSheetStackingClassName,
|
|
887
|
+
children: getPopupContent
|
|
888
|
+
})]
|
|
889
|
+
});
|
|
526
890
|
};
|
|
527
891
|
DropdownRaw.displayName = "DropdownRaw";
|
|
528
|
-
export const TRANSLATIONS = [
|
|
529
|
-
"Filter by group",
|
|
530
|
-
"Open filter",
|
|
531
|
-
"Clear search",
|
|
532
|
-
"Select all",
|
|
533
|
-
"Deselect all",
|
|
534
|
-
"Clear",
|
|
535
|
-
"Back",
|
|
536
|
-
"No data"
|
|
537
|
-
];
|
|
892
|
+
export const TRANSLATIONS = ["Filter by group", "Open filter", "Clear search", "Select all", "Deselect all", "Clear", "Back", "No data"];
|