@onewelcome/react-lib-components 13.3.0-alpha.2 → 13.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Breadcrumbs/Breadcrumbs.module.scss.cjs.js +2 -2
- package/dist/components/Breadcrumbs/Breadcrumbs.module.scss.es.js +5 -5
- package/dist/components/Button/BaseButton.module.scss.cjs.js +2 -2
- package/dist/components/Button/BaseButton.module.scss.es.js +4 -4
- package/dist/components/Button/Button.module.scss.cjs.js +2 -2
- package/dist/components/Button/Button.module.scss.es.js +17 -17
- package/dist/components/Button/IconButton.module.scss.cjs.js +2 -2
- package/dist/components/Button/IconButton.module.scss.es.js +18 -18
- package/dist/components/ContextMenu/ContextMenu.module.scss.cjs.js +2 -2
- package/dist/components/ContextMenu/ContextMenu.module.scss.es.js +6 -6
- package/dist/components/ContextMenu/ContextMenuDivider.module.scss.cjs.js +2 -2
- package/dist/components/ContextMenu/ContextMenuDivider.module.scss.es.js +2 -2
- package/dist/components/ContextMenu/ContextMenuItem.module.scss.cjs.js +2 -2
- package/dist/components/ContextMenu/ContextMenuItem.module.scss.es.js +3 -3
- package/dist/components/DataGrid/DataGrid.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGrid.module.scss.es.js +8 -8
- package/dist/components/DataGrid/DataGridActions/DataGridActions.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridActions/DataGridActions.module.scss.es.js +6 -6
- package/dist/components/DataGrid/DataGridActions/DataGridColumnsToggle.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridActions/DataGridColumnsToggle.module.scss.es.js +7 -7
- package/dist/components/DataGrid/DataGridBody/DataGridBody.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridBody/DataGridBody.module.scss.es.js +2 -2
- package/dist/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.module.scss.es.js +5 -5
- package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawer.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawer.module.scss.es.js +4 -4
- package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawerItem.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawerItem.module.scss.es.js +5 -5
- package/dist/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.module.scss.es.js +24 -24
- package/dist/components/DataGrid/DataGridFilters/DataGridFilter.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilter.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilter.es.js +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilter.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilter.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridFilters/DataGridFilter.module.scss.es.js +9 -9
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterService.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterService.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterService.es.js +25 -44
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterService.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterTag.es.js +4 -15
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterTag.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterValueSelect.cjs.js +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterValueSelect.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterValueSelect.es.js +6 -56
- package/dist/components/DataGrid/DataGridFilters/DataGridFilterValueSelect.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.cjs.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.es.js.map +1 -1
- package/dist/components/DataGrid/DataGridFilters/DataGridToolbar.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridFilters/DataGridToolbar.module.scss.es.js +10 -10
- package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.es.js +17 -17
- package/dist/components/DataGrid/DataGridHeader/DataGridHeader.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridHeader/DataGridHeader.module.scss.es.js +4 -4
- package/dist/components/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss.cjs.js +2 -2
- package/dist/components/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss.es.js +11 -11
- package/dist/components/DatePicker/DatePicker.module.scss.cjs.js +2 -2
- package/dist/components/DatePicker/DatePicker.module.scss.es.js +31 -31
- package/dist/components/Form/Checkbox/Checkbox.module.scss.cjs.js +2 -2
- package/dist/components/Form/Checkbox/Checkbox.module.scss.es.js +13 -13
- package/dist/components/Form/Fieldset/Fieldset.module.scss.cjs.js +2 -2
- package/dist/components/Form/Fieldset/Fieldset.module.scss.es.js +6 -6
- package/dist/components/Form/FileUpload/FileItem/FileItem.module.scss.cjs.js +2 -2
- package/dist/components/Form/FileUpload/FileItem/FileItem.module.scss.es.js +18 -18
- package/dist/components/Form/FileUpload/FileUpload.module.scss.cjs.js +2 -2
- package/dist/components/Form/FileUpload/FileUpload.module.scss.es.js +16 -16
- package/dist/components/Form/Form.module.scss.cjs.js +2 -2
- package/dist/components/Form/Form.module.scss.es.js +2 -2
- package/dist/components/Form/FormControl/FormControl.module.scss.cjs.js +2 -2
- package/dist/components/Form/FormControl/FormControl.module.scss.es.js +13 -13
- package/dist/components/Form/FormErrorText/FormErrorText.module.scss.cjs.js +2 -2
- package/dist/components/Form/FormErrorText/FormErrorText.module.scss.es.js +6 -6
- package/dist/components/Form/FormGroup/FormGroup.module.scss.cjs.js +2 -2
- package/dist/components/Form/FormGroup/FormGroup.module.scss.es.js +3 -3
- package/dist/components/Form/FormHelperText/FormHelperText.module.scss.cjs.js +2 -2
- package/dist/components/Form/FormHelperText/FormHelperText.module.scss.es.js +4 -4
- package/dist/components/Form/FormSelectorWrapper/FormSelectorWrapper.module.scss.cjs.js +2 -2
- package/dist/components/Form/FormSelectorWrapper/FormSelectorWrapper.module.scss.es.js +6 -6
- package/dist/components/Form/Input/Input.cjs.js +1 -1
- package/dist/components/Form/Input/Input.cjs.js.map +1 -1
- package/dist/components/Form/Input/Input.es.js +46 -4
- package/dist/components/Form/Input/Input.es.js.map +1 -1
- package/dist/components/Form/Input/Input.module.scss.cjs.js +2 -2
- package/dist/components/Form/Input/Input.module.scss.es.js +8 -8
- package/dist/components/Form/Label/Label.module.scss.cjs.js +2 -2
- package/dist/components/Form/Label/Label.module.scss.es.js +2 -2
- package/dist/components/Form/Radio/Radio.module.scss.cjs.js +2 -2
- package/dist/components/Form/Radio/Radio.module.scss.es.js +11 -11
- package/dist/components/Form/Select/MultiSelect/MultiOption.cjs.js +1 -1
- package/dist/components/Form/Select/MultiSelect/MultiOption.cjs.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/MultiOption.es.js +2 -3
- package/dist/components/Form/Select/MultiSelect/MultiOption.es.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/MultiSelect.cjs.js +1 -1
- package/dist/components/Form/Select/MultiSelect/MultiSelect.cjs.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/MultiSelect.es.js +6 -135
- package/dist/components/Form/Select/MultiSelect/MultiSelect.es.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/MultiSelect.module.scss.cjs.js +2 -2
- package/dist/components/Form/Select/MultiSelect/MultiSelect.module.scss.es.js +15 -18
- package/dist/components/Form/Select/MultiSelect/MultiSelect.module.scss.es.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/SelectButton.module.scss.cjs.js +2 -2
- package/dist/components/Form/Select/MultiSelect/SelectButton.module.scss.es.js +2 -2
- package/dist/components/Form/Select/MultiSelect/SelectedOptions.cjs.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/SelectedOptions.es.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/SelectedOptions.module.scss.cjs.js +2 -2
- package/dist/components/Form/Select/MultiSelect/SelectedOptions.module.scss.es.js +4 -4
- package/dist/components/Form/Select/MultiSelect/useSearch.cjs.js +1 -1
- package/dist/components/Form/Select/MultiSelect/useSearch.cjs.js.map +1 -1
- package/dist/components/Form/Select/MultiSelect/useSearch.es.js +2 -35
- package/dist/components/Form/Select/MultiSelect/useSearch.es.js.map +1 -1
- package/dist/components/Form/Select/Select.interfaces.cjs.js.map +1 -1
- package/dist/components/Form/Select/Select.interfaces.es.js.map +1 -1
- package/dist/components/Form/Select/SingleSelect/Option.cjs.js +1 -1
- package/dist/components/Form/Select/SingleSelect/Option.cjs.js.map +1 -1
- package/dist/components/Form/Select/SingleSelect/Option.es.js +2 -3
- package/dist/components/Form/Select/SingleSelect/Option.es.js.map +1 -1
- package/dist/components/Form/Select/SingleSelect/Select.cjs.js +1 -1
- package/dist/components/Form/Select/SingleSelect/Select.cjs.js.map +1 -1
- package/dist/components/Form/Select/SingleSelect/Select.es.js +4 -122
- package/dist/components/Form/Select/SingleSelect/Select.es.js.map +1 -1
- package/dist/components/Form/Select/SingleSelect/Select.module.scss.cjs.js +2 -2
- package/dist/components/Form/Select/SingleSelect/Select.module.scss.es.js +17 -20
- package/dist/components/Form/Select/SingleSelect/Select.module.scss.es.js.map +1 -1
- package/dist/components/Form/Select/SingleSelect/useSearch.cjs.js +1 -1
- package/dist/components/Form/Select/SingleSelect/useSearch.cjs.js.map +1 -1
- package/dist/components/Form/Select/SingleSelect/useSearch.es.js +2 -32
- package/dist/components/Form/Select/SingleSelect/useSearch.es.js.map +1 -1
- package/dist/components/Form/Select/useAddNewBtn.module.scss.cjs.js +2 -2
- package/dist/components/Form/Select/useAddNewBtn.module.scss.es.js +4 -4
- package/dist/components/Form/Textarea/Textarea.module.scss.cjs.js +2 -2
- package/dist/components/Form/Textarea/Textarea.module.scss.es.js +6 -6
- package/dist/components/Form/Toggle/Toggle.module.scss.cjs.js +2 -2
- package/dist/components/Form/Toggle/Toggle.module.scss.es.js +18 -18
- package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.module.scss.cjs.js +2 -2
- package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.module.scss.es.js +5 -5
- package/dist/components/Form/Wrapper/InputWrapper/InputWrapper.module.scss.cjs.js +2 -2
- package/dist/components/Form/Wrapper/InputWrapper/InputWrapper.module.scss.es.js +5 -5
- package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.module.scss.cjs.js +2 -2
- package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.module.scss.es.js +3 -3
- package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.module.scss.cjs.js +2 -2
- package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.module.scss.es.js +5 -5
- package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.module.scss.cjs.js +2 -2
- package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.module.scss.es.js +3 -3
- package/dist/components/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss.cjs.js +2 -2
- package/dist/components/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss.es.js +8 -8
- package/dist/components/Form/Wrapper/Wrapper/Wrapper.module.scss.cjs.js +2 -2
- package/dist/components/Form/Wrapper/Wrapper/Wrapper.module.scss.es.js +6 -6
- package/dist/components/Icon/Icon.module.scss.cjs.js +2 -2
- package/dist/components/Icon/Icon.module.scss.es.js +108 -108
- package/dist/components/Layout/ActionBar/ActionBar.module.scss.cjs.js +2 -2
- package/dist/components/Layout/ActionBar/ActionBar.module.scss.es.js +10 -10
- package/dist/components/Layout/Card/Card.module.scss.cjs.js +2 -2
- package/dist/components/Layout/Card/Card.module.scss.es.js +12 -12
- package/dist/components/Layout/ContentHeader/ContentHeader.module.scss.cjs.js +2 -2
- package/dist/components/Layout/ContentHeader/ContentHeader.module.scss.es.js +19 -19
- package/dist/components/Layout/FormPage/FormWithStepper/FormSection/FormSection.module.scss.cjs.js +2 -2
- package/dist/components/Layout/FormPage/FormWithStepper/FormSection/FormSection.module.scss.es.js +4 -4
- package/dist/components/Layout/FormPage/FormWithStepper/FormStepper/FormStepper.module.scss.cjs.js +2 -2
- package/dist/components/Layout/FormPage/FormWithStepper/FormStepper/FormStepper.module.scss.es.js +2 -2
- package/dist/components/Layout/FormPage/FormWithStepper/FormWithStepper.module.scss.cjs.js +2 -2
- package/dist/components/Layout/FormPage/FormWithStepper/FormWithStepper.module.scss.es.js +3 -3
- package/dist/components/Link/Link.module.scss.cjs.js +2 -2
- package/dist/components/Link/Link.module.scss.es.js +17 -17
- package/dist/components/Notifications/Alert/AlertContainer/AlertContainer.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/Alert/AlertContainer/AlertContainer.module.scss.es.js +11 -11
- package/dist/components/Notifications/Alert/AlertItem/AlertItem.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/Alert/AlertItem/AlertItem.module.scss.es.js +22 -22
- package/dist/components/Notifications/Banner/Banner.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/Banner/Banner.module.scss.es.js +9 -9
- package/dist/components/Notifications/BaseModal/BaseModal.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/BaseModal/BaseModal.module.scss.es.js +5 -5
- package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.module.scss.es.js +4 -4
- package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.module.scss.es.js +2 -2
- package/dist/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.module.scss.es.js +6 -6
- package/dist/components/Notifications/Dialog/Dialog.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/Dialog/Dialog.module.scss.es.js +4 -4
- package/dist/components/Notifications/Dialog/DialogActions/DialogActions.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/Dialog/DialogActions/DialogActions.module.scss.es.js +3 -3
- package/dist/components/Notifications/Dialog/DialogTitle/DialogTitle.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/Dialog/DialogTitle/DialogTitle.module.scss.es.js +10 -10
- package/dist/components/Notifications/SideSheet/SideSheet.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/SideSheet/SideSheet.module.scss.es.js +13 -13
- package/dist/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.es.js +2 -2
- package/dist/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.es.js +2 -2
- package/dist/components/Notifications/SlideInModal/SlideInModal.module.scss.cjs.js +2 -2
- package/dist/components/Notifications/SlideInModal/SlideInModal.module.scss.es.js +10 -10
- package/dist/components/Pagination/Pagination.module.scss.cjs.js +2 -2
- package/dist/components/Pagination/Pagination.module.scss.es.js +15 -15
- package/dist/components/Popover/Popover.module.scss.cjs.js +2 -2
- package/dist/components/Popover/Popover.module.scss.es.js +3 -3
- package/dist/components/ProgressBar/ProgressBar.module.scss.cjs.js +2 -2
- package/dist/components/ProgressBar/ProgressBar.module.scss.es.js +9 -9
- package/dist/components/Skeleton/Skeleton.module.scss.cjs.js +2 -2
- package/dist/components/Skeleton/Skeleton.module.scss.es.js +5 -5
- package/dist/components/Spinner/Spinner.module.scss.cjs.js +2 -2
- package/dist/components/Spinner/Spinner.module.scss.es.js +3 -3
- package/dist/components/Stepper/Step.module.scss.cjs.js +2 -2
- package/dist/components/Stepper/Step.module.scss.es.js +22 -22
- package/dist/components/Stepper/Stepper.module.scss.cjs.js +2 -2
- package/dist/components/Stepper/Stepper.module.scss.es.js +4 -4
- package/dist/components/Tabs/Tab.module.scss.cjs.js +2 -2
- package/dist/components/Tabs/Tab.module.scss.es.js +3 -3
- package/dist/components/Tabs/TabButton.module.scss.cjs.js +2 -2
- package/dist/components/Tabs/TabButton.module.scss.es.js +12 -12
- package/dist/components/Tabs/Tabs.module.scss.cjs.js +2 -2
- package/dist/components/Tabs/Tabs.module.scss.es.js +10 -10
- package/dist/components/Tag/RemoveButton.module.scss.cjs.js +2 -2
- package/dist/components/Tag/RemoveButton.module.scss.es.js +3 -3
- package/dist/components/Tag/Tag.cjs.js +1 -1
- package/dist/components/Tag/Tag.cjs.js.map +1 -1
- package/dist/components/Tag/Tag.es.js +1 -1
- package/dist/components/Tag/Tag.es.js.map +1 -1
- package/dist/components/Tag/Tag.module.scss.cjs.js +2 -2
- package/dist/components/Tag/Tag.module.scss.es.js +6 -6
- package/dist/components/TextEllipsis/TextEllipsis.module.scss.cjs.js +2 -2
- package/dist/components/TextEllipsis/TextEllipsis.module.scss.es.js +3 -3
- package/dist/components/Tiles/Tile.module.scss.cjs.js +2 -2
- package/dist/components/Tiles/Tile.module.scss.es.js +8 -8
- package/dist/components/Tiles/Tiles.module.scss.cjs.js +2 -2
- package/dist/components/Tiles/Tiles.module.scss.es.js +2 -2
- package/dist/components/Tooltip/Tooltip.module.scss.cjs.js +2 -2
- package/dist/components/Tooltip/Tooltip.module.scss.es.js +28 -28
- package/dist/components/Typography/Typography.module.scss.cjs.js +2 -2
- package/dist/components/Typography/Typography.module.scss.es.js +13 -13
- package/dist/components/admin/layout/LeftNav/LeftNav.module.scss.cjs.js +2 -2
- package/dist/components/admin/layout/LeftNav/LeftNav.module.scss.es.js +5 -5
- package/dist/components/admin/layout/LeftNav/LeftNavItem/LeftNavItem.module.scss.cjs.js +2 -2
- package/dist/components/admin/layout/LeftNav/LeftNavItem/LeftNavItem.module.scss.es.js +14 -14
- package/dist/components/admin/layout/MicrofrontendContainer/MicrofrontendContainer.module.scss.cjs.js +2 -2
- package/dist/components/admin/layout/MicrofrontendContainer/MicrofrontendContainer.module.scss.es.js +3 -3
- package/dist/components/admin/layout/ProfileMenu/ProfileMenu.module.scss.cjs.js +2 -2
- package/dist/components/admin/layout/ProfileMenu/ProfileMenu.module.scss.es.js +7 -7
- package/dist/components/admin/layout/TopNavBar/TopNavBar.module.scss.cjs.js +2 -2
- package/dist/components/admin/layout/TopNavBar/TopNavBar.module.scss.es.js +13 -13
- package/dist/components/miscellaneous/IdentityProviderButton.module.scss.cjs.js +2 -2
- package/dist/components/miscellaneous/IdentityProviderButton.module.scss.es.js +3 -3
- package/dist/index.d.ts +2 -62
- package/dist/readyclasses.module.scss.cjs.js +2 -2
- package/dist/readyclasses.module.scss.es.js +5 -5
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
!function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('/*!\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.
|
|
2
|
-
const options = "
|
|
3
|
-
const tag = "
|
|
1
|
+
!function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('/*!\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.SelectedOptions_options_FHLkT{position:relative;display:flex;gap:.375rem;flex-wrap:wrap;cursor:pointer}.SelectedOptions_tag_FHLkT{cursor:text}.SelectedOptions_tag_FHLkT .SelectedOptions_remove-btn_FHLkT{cursor:pointer}[data-readonlyview=true] .SelectedOptions_tag_FHLkT .SelectedOptions_remove-btn_FHLkT{display:none}')),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}}();
|
|
2
|
+
const options = "SelectedOptions_options_FHLkT";
|
|
3
|
+
const tag = "SelectedOptions_tag_FHLkT";
|
|
4
4
|
const classes = {
|
|
5
5
|
options,
|
|
6
6
|
tag,
|
|
7
|
-
"remove-btn": "SelectedOptions_remove-
|
|
7
|
+
"remove-btn": "SelectedOptions_remove-btn_FHLkT"
|
|
8
8
|
};
|
|
9
9
|
export {
|
|
10
10
|
classes as default,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),r=require("../../../../util/helper.cjs.js")
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),r=require("../../../../util/helper.cjs.js");exports.useSearch=({selectId:a,search:t,optionsCount:o,searchInputClassName:s,expanded:l,setFocusedSelectItem:n,focusedSelectItem:c,describedBy:i,error:u=!1,getOptionId:d,getListboxId:p})=>{var h;const[v,f]=e.useState(""),b=e.useRef(null),m=(null==t?void 0:t.renderThreshold)??0,I=o>=m,x=()=>{f(""),n(0)},y=(null==t?void 0:t.enabled)?I:t?t.enabled:o>0;return e.useEffect(()=>{var e;(null==(e=null==t?void 0:t.searchInputProps)?void 0:e.reset)&&x()},[null==(h=null==t?void 0:t.searchInputProps)?void 0:h.reset]),{renderSearch:()=>{var o;const n=r.omitProps((null==t?void 0:t.searchInputProps)??{},/^(reset|prefix|suffix|wrapperProps|labeledBy|readOnlyView|error|success)$/);return e.createElement("input",{...n,ref:b,value:v,onChange:e=>f(e.currentTarget.value),className:[s,null==(o=null==t?void 0:t.searchInputProps)?void 0:o.className].join(" "),style:{display:l?"block":"none"},type:"text",name:"search-option",placeholder:null==t?void 0:t.searchPlaceholder,role:"combobox",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-controls":p(a),"aria-describedby":i,"aria-invalid":u,"aria-autocomplete":"none","aria-expanded":l,"aria-activedescendant":d(a,c),"aria-haspopup":!0})},resetSearchState:x,searchVisible:y,searchThreshold:m,searchInputRef:b,filter:v}};
|
|
2
2
|
//# sourceMappingURL=useSearch.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSearch.cjs.js","sources":["../../../../../src/components/Form/Select/MultiSelect/useSearch.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { SearchProps } from \"../Select.interfaces\";\nimport { omitProps } from \"../../../../util/helper\";\
|
|
1
|
+
{"version":3,"file":"useSearch.cjs.js","sources":["../../../../../src/components/Form/Select/MultiSelect/useSearch.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { SearchProps } from \"../Select.interfaces\";\nimport { omitProps } from \"../../../../util/helper\";\n\ninterface Props {\n selectId: string;\n search?: SearchProps;\n optionsCount: number;\n searchInputClassName: string;\n expanded: boolean;\n setFocusedSelectItem: (idx: number) => void;\n focusedSelectItem: number;\n describedBy?: string;\n error?: boolean;\n getOptionId: (multiSelectId: string, optionIndex: number) => string;\n getListboxId: (multiSelectId: string) => string;\n}\n\n/** @scope .*/\nexport const useSearch = ({\n selectId,\n search,\n optionsCount,\n searchInputClassName,\n expanded,\n setFocusedSelectItem,\n focusedSelectItem,\n describedBy,\n error = false,\n getOptionId,\n getListboxId\n}: Props) => {\n const [filter, setFilter] = useState(\"\");\n\n const DEFAULT_RENDER_THRESHOLD = 0;\n\n const searchInputRef = useRef<HTMLInputElement>(null);\n\n const threshold = search?.renderThreshold ?? DEFAULT_RENDER_THRESHOLD;\n const hasEnoughChildren = optionsCount >= threshold;\n\n const shouldRenderSearch = () => {\n if (search?.enabled) {\n return hasEnoughChildren;\n }\n\n if (search) {\n return search.enabled as boolean;\n }\n\n return optionsCount > DEFAULT_RENDER_THRESHOLD;\n };\n\n const renderSearch = () => {\n // Filter out non-native HTML input attributes\n const filteredProps = omitProps(\n search?.searchInputProps ?? {},\n /^(reset|prefix|suffix|wrapperProps|labeledBy|readOnlyView|error|success)$/\n );\n\n return (\n <input\n {...filteredProps}\n ref={searchInputRef}\n value={filter}\n onChange={event => setFilter(event.currentTarget.value)}\n className={[searchInputClassName, search?.searchInputProps?.className].join(\" \")}\n style={{\n display: expanded ? \"block\" : \"none\"\n }}\n type=\"text\"\n name=\"search-option\"\n placeholder={search?.searchPlaceholder}\n role=\"combobox\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n aria-controls={getListboxId(selectId)}\n aria-describedby={describedBy}\n aria-invalid={error}\n aria-autocomplete=\"none\"\n aria-expanded={expanded}\n aria-activedescendant={getOptionId(selectId, focusedSelectItem)}\n aria-haspopup={true}\n />\n );\n };\n\n const resetSearchState = () => {\n setFilter(\"\");\n setFocusedSelectItem(0);\n };\n\n const visible = shouldRenderSearch();\n\n useEffect(() => {\n if (search?.searchInputProps?.reset) {\n resetSearchState();\n }\n }, [search?.searchInputProps?.reset]);\n\n return {\n renderSearch,\n resetSearchState,\n searchVisible: visible,\n searchThreshold: threshold,\n searchInputRef,\n filter\n };\n};\n"],"names":["selectId","search","optionsCount","searchInputClassName","expanded","setFocusedSelectItem","focusedSelectItem","describedBy","error","getOptionId","getListboxId","filter","setFilter","useState","searchInputRef","useRef","threshold","renderThreshold","hasEnoughChildren","resetSearchState","visible","enabled","useEffect","_a","searchInputProps","reset","renderSearch","filteredProps","omitProps","React","createElement","ref","value","onChange","event","currentTarget","className","join","style","display","type","name","placeholder","searchPlaceholder","role","autoComplete","autoCorrect","spellCheck","searchVisible","searchThreshold"],"mappings":"uKAmCyB,EACvBA,WACAC,SACAC,eACAC,uBACAC,WACAC,uBACAC,oBACAC,cACAC,SAAQ,EACRC,cACAC,yBAEA,MAAOC,EAAQC,GAAaC,EAAAA,SAAS,IAI/BC,EAAiBC,EAAAA,OAAyB,MAE1CC,SAAYf,WAAQgB,kBAJO,EAK3BC,EAAoBhB,GAAgBc,EAiDpCG,EAAmB,KACvBP,EAAU,IACVP,EAAqB,IAGjBe,SAnDAnB,WAAQoB,SACHH,EAGLjB,EACKA,EAAOoB,QAGTnB,EAhBwB,EAmEjC,OANAoB,EAAAA,UAAU,YACJ,OAAAC,EAAA,MAAAtB,OAAA,EAAAA,EAAQuB,uBAAR,EAAAD,EAA0BE,QAC5BN,KAED,CAAC,OAAAI,EAAA,MAAAtB,OAAA,EAAAA,EAAQuB,uBAAR,EAAAD,EAA0BE,QAEvB,CACLC,aAjDmB,WAEnB,MAAMC,EAAgBC,EAAAA,WACpB,MAAA3B,OAAA,EAAAA,EAAQuB,mBAAoB,CAAA,EAC5B,6EAGF,OACEK,EAAAC,cAAC,QAAA,IACKH,EACJI,IAAKjB,EACLkB,MAAOrB,EACPsB,SAAUC,GAAStB,EAAUsB,EAAMC,cAAcH,OACjDI,UAAW,CAACjC,EAAsB,OAAAoB,EAAA,MAAAtB,OAAA,EAAAA,EAAQuB,uBAAR,EAAAD,EAA0Ba,WAAWC,KAAK,KAC5EC,MAAO,CACLC,QAASnC,EAAW,QAAU,QAEhCoC,KAAK,OACLC,KAAK,gBACLC,YAAa,MAAAzC,OAAA,EAAAA,EAAQ0C,kBACrBC,KAAK,WACLC,aAAa,MACbC,YAAY,MACZC,YAAY,EACZ,gBAAerC,EAAaV,GAC5B,mBAAkBO,EAClB,eAAcC,EACd,oBAAkB,OAClB,gBAAeJ,EACf,wBAAuBK,EAAYT,EAAUM,GAC7C,iBAAe,KAoBnBa,mBACA6B,cAAe5B,EACf6B,gBAAiBjC,EACjBF,iBACAH"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useState, useRef, useEffect } from "react";
|
|
2
2
|
import { omitProps } from "../../../../util/helper.es.js";
|
|
3
|
-
import { useDebouncedCallback } from "../../../../hooks/useDebouncedCallback.es.js";
|
|
4
3
|
const useSearch = ({
|
|
5
4
|
selectId,
|
|
6
5
|
search,
|
|
@@ -16,39 +15,11 @@ const useSearch = ({
|
|
|
16
15
|
}) => {
|
|
17
16
|
var _a;
|
|
18
17
|
const [filter, setFilter] = useState("");
|
|
19
|
-
const [isAsyncPending, setIsAsyncPending] = useState(false);
|
|
20
18
|
const DEFAULT_RENDER_THRESHOLD = 0;
|
|
21
|
-
const DEFAULT_DEBOUNCE_TIME = 300;
|
|
22
|
-
const DEFAULT_MIN_SEARCH_LENGTH = 0;
|
|
23
19
|
const searchInputRef = useRef(null);
|
|
24
20
|
const threshold = (search == null ? void 0 : search.renderThreshold) ?? DEFAULT_RENDER_THRESHOLD;
|
|
25
21
|
const hasEnoughChildren = optionsCount >= threshold;
|
|
26
|
-
const asyncSearch = search == null ? void 0 : search.async;
|
|
27
|
-
const debouncedOnSearch = useDebouncedCallback(
|
|
28
|
-
(query) => {
|
|
29
|
-
setIsAsyncPending(false);
|
|
30
|
-
asyncSearch == null ? void 0 : asyncSearch.onSearch(query);
|
|
31
|
-
},
|
|
32
|
-
(asyncSearch == null ? void 0 : asyncSearch.debounceTime) ?? DEFAULT_DEBOUNCE_TIME,
|
|
33
|
-
[asyncSearch == null ? void 0 : asyncSearch.onSearch]
|
|
34
|
-
);
|
|
35
|
-
const filterResults = (event) => {
|
|
36
|
-
var _a2, _b;
|
|
37
|
-
(_b = (_a2 = search == null ? void 0 : search.searchInputProps) == null ? void 0 : _a2.onChange) == null ? void 0 : _b.call(_a2, event);
|
|
38
|
-
const query = event.currentTarget.value;
|
|
39
|
-
setFilter(query);
|
|
40
|
-
if (asyncSearch) {
|
|
41
|
-
const meetsMinLength = query.length >= (asyncSearch.minSearchLength ?? DEFAULT_MIN_SEARCH_LENGTH);
|
|
42
|
-
setIsAsyncPending(meetsMinLength);
|
|
43
|
-
if (meetsMinLength) {
|
|
44
|
-
debouncedOnSearch(query);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
22
|
const shouldRenderSearch = () => {
|
|
49
|
-
if (asyncSearch) {
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
23
|
if (search == null ? void 0 : search.enabled) {
|
|
53
24
|
return hasEnoughChildren;
|
|
54
25
|
}
|
|
@@ -69,7 +40,7 @@ const useSearch = ({
|
|
|
69
40
|
...filteredProps,
|
|
70
41
|
ref: searchInputRef,
|
|
71
42
|
value: filter,
|
|
72
|
-
onChange:
|
|
43
|
+
onChange: (event) => setFilter(event.currentTarget.value),
|
|
73
44
|
className: [searchInputClassName, (_a2 = search == null ? void 0 : search.searchInputProps) == null ? void 0 : _a2.className].join(" "),
|
|
74
45
|
style: {
|
|
75
46
|
display: expanded ? "block" : "none"
|
|
@@ -93,7 +64,6 @@ const useSearch = ({
|
|
|
93
64
|
};
|
|
94
65
|
const resetSearchState = () => {
|
|
95
66
|
setFilter("");
|
|
96
|
-
setIsAsyncPending(false);
|
|
97
67
|
setFocusedSelectItem(0);
|
|
98
68
|
};
|
|
99
69
|
const visible = shouldRenderSearch();
|
|
@@ -109,10 +79,7 @@ const useSearch = ({
|
|
|
109
79
|
searchVisible: visible,
|
|
110
80
|
searchThreshold: threshold,
|
|
111
81
|
searchInputRef,
|
|
112
|
-
filter
|
|
113
|
-
isAsync: !!asyncSearch,
|
|
114
|
-
isAsyncPending,
|
|
115
|
-
asyncMinSearchLength: (asyncSearch == null ? void 0 : asyncSearch.minSearchLength) ?? DEFAULT_MIN_SEARCH_LENGTH
|
|
82
|
+
filter
|
|
116
83
|
};
|
|
117
84
|
};
|
|
118
85
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSearch.es.js","sources":["../../../../../src/components/Form/Select/MultiSelect/useSearch.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { SearchProps } from \"../Select.interfaces\";\nimport { omitProps } from \"../../../../util/helper\";\
|
|
1
|
+
{"version":3,"file":"useSearch.es.js","sources":["../../../../../src/components/Form/Select/MultiSelect/useSearch.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { SearchProps } from \"../Select.interfaces\";\nimport { omitProps } from \"../../../../util/helper\";\n\ninterface Props {\n selectId: string;\n search?: SearchProps;\n optionsCount: number;\n searchInputClassName: string;\n expanded: boolean;\n setFocusedSelectItem: (idx: number) => void;\n focusedSelectItem: number;\n describedBy?: string;\n error?: boolean;\n getOptionId: (multiSelectId: string, optionIndex: number) => string;\n getListboxId: (multiSelectId: string) => string;\n}\n\n/** @scope .*/\nexport const useSearch = ({\n selectId,\n search,\n optionsCount,\n searchInputClassName,\n expanded,\n setFocusedSelectItem,\n focusedSelectItem,\n describedBy,\n error = false,\n getOptionId,\n getListboxId\n}: Props) => {\n const [filter, setFilter] = useState(\"\");\n\n const DEFAULT_RENDER_THRESHOLD = 0;\n\n const searchInputRef = useRef<HTMLInputElement>(null);\n\n const threshold = search?.renderThreshold ?? DEFAULT_RENDER_THRESHOLD;\n const hasEnoughChildren = optionsCount >= threshold;\n\n const shouldRenderSearch = () => {\n if (search?.enabled) {\n return hasEnoughChildren;\n }\n\n if (search) {\n return search.enabled as boolean;\n }\n\n return optionsCount > DEFAULT_RENDER_THRESHOLD;\n };\n\n const renderSearch = () => {\n // Filter out non-native HTML input attributes\n const filteredProps = omitProps(\n search?.searchInputProps ?? {},\n /^(reset|prefix|suffix|wrapperProps|labeledBy|readOnlyView|error|success)$/\n );\n\n return (\n <input\n {...filteredProps}\n ref={searchInputRef}\n value={filter}\n onChange={event => setFilter(event.currentTarget.value)}\n className={[searchInputClassName, search?.searchInputProps?.className].join(\" \")}\n style={{\n display: expanded ? \"block\" : \"none\"\n }}\n type=\"text\"\n name=\"search-option\"\n placeholder={search?.searchPlaceholder}\n role=\"combobox\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n aria-controls={getListboxId(selectId)}\n aria-describedby={describedBy}\n aria-invalid={error}\n aria-autocomplete=\"none\"\n aria-expanded={expanded}\n aria-activedescendant={getOptionId(selectId, focusedSelectItem)}\n aria-haspopup={true}\n />\n );\n };\n\n const resetSearchState = () => {\n setFilter(\"\");\n setFocusedSelectItem(0);\n };\n\n const visible = shouldRenderSearch();\n\n useEffect(() => {\n if (search?.searchInputProps?.reset) {\n resetSearchState();\n }\n }, [search?.searchInputProps?.reset]);\n\n return {\n renderSearch,\n resetSearchState,\n searchVisible: visible,\n searchThreshold: threshold,\n searchInputRef,\n filter\n };\n};\n"],"names":["_a"],"mappings":";;AAmCO,MAAM,YAAY,CAAC;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AACF,MAAa;;AACX,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,EAAE;AAEvC,QAAM,2BAA2B;AAEjC,QAAM,iBAAiB,OAAyB,IAAI;AAEpD,QAAM,aAAY,iCAAQ,oBAAmB;AAC7C,QAAM,oBAAoB,gBAAgB;AAE1C,QAAM,qBAAqB,MAAM;AAC/B,QAAI,iCAAQ,SAAS;AACnB,aAAO;AAAA,IACT;AAEA,QAAI,QAAQ;AACV,aAAO,OAAO;AAAA,IAChB;AAEA,WAAO,eAAe;AAAA,EACxB;AAEA,QAAM,eAAe,MAAM;;AAEzB,UAAM,gBAAgB;AAAA,OACpB,iCAAQ,qBAAoB,CAAA;AAAA,MAC5B;AAAA,IAAA;AAGF,WACE,sBAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACE,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,OAAO;AAAA,QACP,UAAU,CAAA,UAAS,UAAU,MAAM,cAAc,KAAK;AAAA,QACtD,WAAW,CAAC,uBAAsBA,MAAA,iCAAQ,qBAAR,gBAAAA,IAA0B,SAAS,EAAE,KAAK,GAAG;AAAA,QAC/E,OAAO;AAAA,UACL,SAAS,WAAW,UAAU;AAAA,QAAA;AAAA,QAEhC,MAAK;AAAA,QACL,MAAK;AAAA,QACL,aAAa,iCAAQ;AAAA,QACrB,MAAK;AAAA,QACL,cAAa;AAAA,QACb,aAAY;AAAA,QACZ,YAAY;AAAA,QACZ,iBAAe,aAAa,QAAQ;AAAA,QACpC,oBAAkB;AAAA,QAClB,gBAAc;AAAA,QACd,qBAAkB;AAAA,QAClB,iBAAe;AAAA,QACf,yBAAuB,YAAY,UAAU,iBAAiB;AAAA,QAC9D,iBAAe;AAAA,MAAA;AAAA,IAAA;AAAA,EAGrB;AAEA,QAAM,mBAAmB,MAAM;AAC7B,cAAU,EAAE;AACZ,yBAAqB,CAAC;AAAA,EACxB;AAEA,QAAM,UAAU,mBAAA;AAEhB,YAAU,MAAM;;AACd,SAAIA,MAAA,iCAAQ,qBAAR,gBAAAA,IAA0B,OAAO;AACnC,uBAAA;AAAA,IACF;AAAA,EACF,GAAG,EAAC,sCAAQ,qBAAR,mBAA0B,KAAK,CAAC;AAEpC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.interfaces.cjs.js","sources":["../../../../src/components/Form/Select/Select.interfaces.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ComponentPropsWithRef, ReactElement
|
|
1
|
+
{"version":3,"file":"Select.interfaces.cjs.js","sources":["../../../../src/components/Form/Select/Select.interfaces.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ComponentPropsWithRef, ReactElement } from \"react\";\nimport { Props as InputProps } from \"../Input/Input\";\nimport { FormElement } from \"../form.interfaces\";\n\nexport type PartialInputProps = Partial<InputProps>;\n\nexport interface SearchProps {\n enabled?: boolean;\n renderThreshold?: number;\n searchPlaceholder?: string;\n searchInputProps?: PartialInputProps & { reset?: boolean };\n}\n\nexport interface AddNewProps {\n label: string;\n onAddNew: (value: string) => void;\n btnProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n alwaysEnabled?: boolean;\n}\n\nexport interface SelectProps<V extends string | readonly string[] | undefined>\n extends ComponentPropsWithRef<\"select\">, FormElement {\n children: ReactElement[];\n name?: string;\n labeledBy?: string;\n describedBy?: string;\n placeholder?: string;\n selectButtonProps?: ComponentPropsWithRef<\"button\"> & FormElement;\n search?: SearchProps;\n className?: string;\n value: V;\n clearLabel?: string;\n noResultsLabel?: string;\n onChange?: (event: React.ChangeEvent<HTMLSelectElement>, child?: ReactElement) => void;\n addNew?: AddNewProps;\n isReadOnlyView?: boolean;\n domRoot?: HTMLElement;\n}\n\nexport type SingleSelectProps = SelectProps<string>;\nexport type MultiSelectProps = SelectProps<string[]>;\n\nexport enum Position {\n Above = \"Above\",\n Below = \"Below\"\n}\n\nexport interface UseArrowNavigationParams {\n expanded: boolean;\n setExpanded: React.Dispatch<React.SetStateAction<boolean>>;\n isSearching: boolean;\n setIsSearching: React.Dispatch<React.SetStateAction<boolean>>;\n setFocusedSelectItem: React.Dispatch<React.SetStateAction<number>>;\n childrenCount: number;\n setShouldClick: React.Dispatch<React.SetStateAction<boolean>>;\n onOptionChangeHandler: (optionElement: HTMLElement | null) => void;\n searchInputRef: React.RefObject<HTMLInputElement>;\n addBtnRef?: React.RefObject<HTMLButtonElement>;\n renderThreshold: number;\n isReadOnlyView?: boolean;\n}\n\nexport interface UseSelectPositionListParams {\n expanded: boolean;\n optionListReference: React.RefObject<HTMLDivElement>;\n containerReference: React.RefObject<HTMLDivElement>;\n addBtnRef: React.RefObject<HTMLButtonElement>;\n}\n"],"names":["Position"],"mappings":"gFA0DO,IAAKA,GAAAA,IACVA,EAAA,MAAQ,QACRA,EAAA,MAAQ,QAFEA,IAAAA,GAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.interfaces.es.js","sources":["../../../../src/components/Form/Select/Select.interfaces.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ComponentPropsWithRef, ReactElement
|
|
1
|
+
{"version":3,"file":"Select.interfaces.es.js","sources":["../../../../src/components/Form/Select/Select.interfaces.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ComponentPropsWithRef, ReactElement } from \"react\";\nimport { Props as InputProps } from \"../Input/Input\";\nimport { FormElement } from \"../form.interfaces\";\n\nexport type PartialInputProps = Partial<InputProps>;\n\nexport interface SearchProps {\n enabled?: boolean;\n renderThreshold?: number;\n searchPlaceholder?: string;\n searchInputProps?: PartialInputProps & { reset?: boolean };\n}\n\nexport interface AddNewProps {\n label: string;\n onAddNew: (value: string) => void;\n btnProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n alwaysEnabled?: boolean;\n}\n\nexport interface SelectProps<V extends string | readonly string[] | undefined>\n extends ComponentPropsWithRef<\"select\">, FormElement {\n children: ReactElement[];\n name?: string;\n labeledBy?: string;\n describedBy?: string;\n placeholder?: string;\n selectButtonProps?: ComponentPropsWithRef<\"button\"> & FormElement;\n search?: SearchProps;\n className?: string;\n value: V;\n clearLabel?: string;\n noResultsLabel?: string;\n onChange?: (event: React.ChangeEvent<HTMLSelectElement>, child?: ReactElement) => void;\n addNew?: AddNewProps;\n isReadOnlyView?: boolean;\n domRoot?: HTMLElement;\n}\n\nexport type SingleSelectProps = SelectProps<string>;\nexport type MultiSelectProps = SelectProps<string[]>;\n\nexport enum Position {\n Above = \"Above\",\n Below = \"Below\"\n}\n\nexport interface UseArrowNavigationParams {\n expanded: boolean;\n setExpanded: React.Dispatch<React.SetStateAction<boolean>>;\n isSearching: boolean;\n setIsSearching: React.Dispatch<React.SetStateAction<boolean>>;\n setFocusedSelectItem: React.Dispatch<React.SetStateAction<number>>;\n childrenCount: number;\n setShouldClick: React.Dispatch<React.SetStateAction<boolean>>;\n onOptionChangeHandler: (optionElement: HTMLElement | null) => void;\n searchInputRef: React.RefObject<HTMLInputElement>;\n addBtnRef?: React.RefObject<HTMLButtonElement>;\n renderThreshold: number;\n isReadOnlyView?: boolean;\n}\n\nexport interface UseSelectPositionListParams {\n expanded: boolean;\n optionListReference: React.RefObject<HTMLDivElement>;\n containerReference: React.RefObject<HTMLDivElement>;\n addBtnRef: React.RefObject<HTMLButtonElement>;\n}\n"],"names":["Position"],"mappings":"AA0DO,IAAK,6BAAAA,cAAL;AACLA,YAAA,OAAA,IAAQ;AACRA,YAAA,OAAA,IAAQ;AAFE,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("./Select.module.scss.cjs.js"),s=require("../../../../util/helper.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("./Select.module.scss.cjs.js"),s=require("../../../../util/helper.cjs.js"),r=e.forwardRef(({id:r,children:c,className:l,isSelected:n=!1,disableDefaultSelectedStyle:a,shouldClick:o,hasFocus:u,selectOpened:i,isSearching:d,childIndex:f,onOptionSelect:p,onFocusChange:h,disabled:S,value:b,isAddBtnFocused:g,...j},m)=>{const v=e.useRef(s.generateID(20)),x=r??v.current,y=m||e.createRef(),D=[];l&&D.push(l),n&&!a&&D.push(t.default["selected-option"]),S&&D.push(t.default.disabled),e.useEffect(()=>{n&&y.current&&o&&y.current.click()},[n,o]),e.useEffect(()=>{y.current&&u&&i&&!d&&!g&&(h&&f&&h(f),y.current.focus())},[u,y,i,d]);const E=()=>{S||null==p||p(y)};return e.createElement("li",{...j,id:x,ref:y,"data-value":b,className:D.join(" "),onClick:E,onKeyDown:e=>{"Enter"===e.code&&(e.stopPropagation(),e.preventDefault(),E())},"aria-selected":n,"aria-disabled":S,role:"option",tabIndex:S?-1:0},c)});exports.Option=r;
|
|
2
2
|
//# sourceMappingURL=Option.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Option.cjs.js","sources":["../../../../../src/components/Form/Select/SingleSelect/Option.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, {\n ForwardRefRenderFunction,\n ComponentPropsWithRef,\n RefObject,\n useEffect,\n ReactNode,\n useRef\n} from \"react\";\nimport classes from \"./Select.module.scss\";\nimport { generateID } from \"../../../../util/helper\";\n\nexport interface Props extends ComponentPropsWithRef<\"li\"> {\n children: ReactNode;\n value: string;\n disabled?: boolean;\n isSelected?: boolean;\n disableDefaultSelectedStyle?: boolean;\n selectOpened?: boolean;\n hasFocus?: boolean;\n shouldClick?: boolean;\n isSearching?: boolean;\n label?: string;\n childIndex?: number;\n onOptionSelect?: (ref: React.RefObject<HTMLLIElement>) => void;\n onFocusChange?: (childIndex: number) => void;\n isAddBtnFocused?: boolean;\n}\n\nconst OptionComponent: ForwardRefRenderFunction<HTMLLIElement, Props> = (\n {\n id,\n children,\n className,\n isSelected = false,\n disableDefaultSelectedStyle,\n shouldClick,\n hasFocus,\n selectOpened,\n isSearching,\n childIndex,\n onOptionSelect,\n onFocusChange,\n disabled,\n value,\n isAddBtnFocused,\n ...rest\n }: Props,\n ref\n) => {\n const defaultOptionId = useRef(generateID(20));\n const optionId = id ?? defaultOptionId.current;\n
|
|
1
|
+
{"version":3,"file":"Option.cjs.js","sources":["../../../../../src/components/Form/Select/SingleSelect/Option.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, {\n ForwardRefRenderFunction,\n ComponentPropsWithRef,\n createRef,\n RefObject,\n useEffect,\n ReactNode,\n useRef\n} from \"react\";\nimport classes from \"./Select.module.scss\";\nimport { generateID } from \"../../../../util/helper\";\n\nexport interface Props extends ComponentPropsWithRef<\"li\"> {\n children: ReactNode;\n value: string;\n disabled?: boolean;\n isSelected?: boolean;\n disableDefaultSelectedStyle?: boolean;\n selectOpened?: boolean;\n hasFocus?: boolean;\n shouldClick?: boolean;\n isSearching?: boolean;\n label?: string;\n childIndex?: number;\n onOptionSelect?: (ref: React.RefObject<HTMLLIElement>) => void;\n onFocusChange?: (childIndex: number) => void;\n isAddBtnFocused?: boolean;\n}\n\nconst OptionComponent: ForwardRefRenderFunction<HTMLLIElement, Props> = (\n {\n id,\n children,\n className,\n isSelected = false,\n disableDefaultSelectedStyle,\n shouldClick,\n hasFocus,\n selectOpened,\n isSearching,\n childIndex,\n onOptionSelect,\n onFocusChange,\n disabled,\n value,\n isAddBtnFocused,\n ...rest\n }: Props,\n ref\n) => {\n const defaultOptionId = useRef(generateID(20));\n const optionId = id ?? defaultOptionId.current;\n const innerOptionRef = (ref as RefObject<HTMLLIElement>) || createRef<HTMLLIElement>();\n\n const additionalClasses = [];\n className && additionalClasses.push(className);\n isSelected && !disableDefaultSelectedStyle && additionalClasses.push(classes[\"selected-option\"]);\n disabled && additionalClasses.push(classes[\"disabled\"]);\n\n useEffect(() => {\n if (isSelected && innerOptionRef.current && shouldClick) {\n innerOptionRef.current.click();\n }\n }, [isSelected, shouldClick]);\n\n useEffect(() => {\n if (innerOptionRef.current && hasFocus && selectOpened && !isSearching && !isAddBtnFocused) {\n onFocusChange && childIndex && onFocusChange(childIndex);\n innerOptionRef.current.focus();\n }\n }, [hasFocus, innerOptionRef, selectOpened, isSearching]);\n\n const onSelectHandler = () => {\n if (disabled) {\n return;\n }\n onOptionSelect?.(innerOptionRef);\n };\n\n return (\n <li // NOSONAR S6819 - <option> is only valid inside <select>/<optgroup>; this is an ARIA listbox built from <li> elements, so role=\"option\" is the correct authoring practice.\n {...rest}\n id={optionId}\n ref={innerOptionRef}\n data-value={value}\n className={additionalClasses.join(\" \")}\n onClick={onSelectHandler}\n onKeyDown={event => {\n if (event.code === \"Enter\") {\n event.stopPropagation();\n event.preventDefault();\n\n onSelectHandler();\n }\n }}\n aria-selected={isSelected}\n aria-disabled={disabled}\n role=\"option\" // NOSONAR S6842 - required by the ARIA listbox pattern; the parent <ul role=\"listbox\"> needs option-role children, and aria-selected is only valid on this role.\n tabIndex={disabled ? -1 : 0}\n >\n {children}\n </li>\n );\n};\n\nexport const Option = React.forwardRef(OptionComponent);\n"],"names":["Option","React","forwardRef","id","children","className","isSelected","disableDefaultSelectedStyle","shouldClick","hasFocus","selectOpened","isSearching","childIndex","onOptionSelect","onFocusChange","disabled","value","isAddBtnFocused","rest","ref","defaultOptionId","useRef","generateID","optionId","current","innerOptionRef","createRef","additionalClasses","push","classes","useEffect","click","focus","onSelectHandler","createElement","join","onClick","onKeyDown","event","code","stopPropagation","preventDefault","role","tabIndex"],"mappings":"8LAyHaA,EAASC,EAAMC,WA5E4C,EAEpEC,KACAC,WACAC,YACAC,cAAa,EACbC,8BACAC,cACAC,WACAC,eACAC,cACAC,aACAC,iBACAC,gBACAC,WACAC,QACAC,qBACGC,GAELC,KAEA,MAAMC,EAAkBC,EAAAA,OAAOC,EAAAA,WAAW,KACpCC,EAAWpB,GAAMiB,EAAgBI,QACjCC,EAAkBN,GAAoCO,cAEtDC,EAAoB,GAC1BtB,GAAasB,EAAkBC,KAAKvB,GACpCC,IAAeC,GAA+BoB,EAAkBC,KAAKC,EAAAA,QAAQ,oBAC7Ed,GAAYY,EAAkBC,KAAKC,EAAAA,QAAkB,UAErDC,EAAAA,UAAU,KACJxB,GAAcmB,EAAeD,SAAWhB,GAC1CiB,EAAeD,QAAQO,SAExB,CAACzB,EAAYE,IAEhBsB,EAAAA,UAAU,KACJL,EAAeD,SAAWf,GAAYC,IAAiBC,IAAgBM,IACzEH,GAAiBF,GAAcE,EAAcF,GAC7Ca,EAAeD,QAAQQ,UAExB,CAACvB,EAAUgB,EAAgBf,EAAcC,IAE5C,MAAMsB,EAAkB,KAClBlB,GAGJ,MAAAF,GAAAA,EAAiBY,IAGnB,OACExB,EAAAiC,cAAC,KAAA,IACKhB,EACJf,GAAIoB,EACJJ,IAAKM,EACL,aAAYT,EACZX,UAAWsB,EAAkBQ,KAAK,KAClCC,QAASH,EACTI,UAAWC,IACU,UAAfA,EAAMC,OACRD,EAAME,kBACNF,EAAMG,iBAENR,MAGJ,gBAAe3B,EACf,gBAAeS,EACf2B,KAAK,SACLC,SAAU5B,GAAW,EAAK,GAEzBX"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef, useEffect } from "react";
|
|
1
|
+
import React, { useRef, createRef, useEffect } from "react";
|
|
2
2
|
import selectClasses from "./Select.module.scss.es.js";
|
|
3
3
|
import { generateID } from "../../../../util/helper.es.js";
|
|
4
4
|
const OptionComponent = ({
|
|
@@ -21,8 +21,7 @@ const OptionComponent = ({
|
|
|
21
21
|
}, ref) => {
|
|
22
22
|
const defaultOptionId = useRef(generateID(20));
|
|
23
23
|
const optionId = id ?? defaultOptionId.current;
|
|
24
|
-
const
|
|
25
|
-
const innerOptionRef = ref || fallbackRef;
|
|
24
|
+
const innerOptionRef = ref || createRef();
|
|
26
25
|
const additionalClasses = [];
|
|
27
26
|
className && additionalClasses.push(className);
|
|
28
27
|
isSelected && !disableDefaultSelectedStyle && additionalClasses.push(selectClasses["selected-option"]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Option.es.js","sources":["../../../../../src/components/Form/Select/SingleSelect/Option.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, {\n ForwardRefRenderFunction,\n ComponentPropsWithRef,\n RefObject,\n useEffect,\n ReactNode,\n useRef\n} from \"react\";\nimport classes from \"./Select.module.scss\";\nimport { generateID } from \"../../../../util/helper\";\n\nexport interface Props extends ComponentPropsWithRef<\"li\"> {\n children: ReactNode;\n value: string;\n disabled?: boolean;\n isSelected?: boolean;\n disableDefaultSelectedStyle?: boolean;\n selectOpened?: boolean;\n hasFocus?: boolean;\n shouldClick?: boolean;\n isSearching?: boolean;\n label?: string;\n childIndex?: number;\n onOptionSelect?: (ref: React.RefObject<HTMLLIElement>) => void;\n onFocusChange?: (childIndex: number) => void;\n isAddBtnFocused?: boolean;\n}\n\nconst OptionComponent: ForwardRefRenderFunction<HTMLLIElement, Props> = (\n {\n id,\n children,\n className,\n isSelected = false,\n disableDefaultSelectedStyle,\n shouldClick,\n hasFocus,\n selectOpened,\n isSearching,\n childIndex,\n onOptionSelect,\n onFocusChange,\n disabled,\n value,\n isAddBtnFocused,\n ...rest\n }: Props,\n ref\n) => {\n const defaultOptionId = useRef(generateID(20));\n const optionId = id ?? defaultOptionId.current;\n
|
|
1
|
+
{"version":3,"file":"Option.es.js","sources":["../../../../../src/components/Form/Select/SingleSelect/Option.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, {\n ForwardRefRenderFunction,\n ComponentPropsWithRef,\n createRef,\n RefObject,\n useEffect,\n ReactNode,\n useRef\n} from \"react\";\nimport classes from \"./Select.module.scss\";\nimport { generateID } from \"../../../../util/helper\";\n\nexport interface Props extends ComponentPropsWithRef<\"li\"> {\n children: ReactNode;\n value: string;\n disabled?: boolean;\n isSelected?: boolean;\n disableDefaultSelectedStyle?: boolean;\n selectOpened?: boolean;\n hasFocus?: boolean;\n shouldClick?: boolean;\n isSearching?: boolean;\n label?: string;\n childIndex?: number;\n onOptionSelect?: (ref: React.RefObject<HTMLLIElement>) => void;\n onFocusChange?: (childIndex: number) => void;\n isAddBtnFocused?: boolean;\n}\n\nconst OptionComponent: ForwardRefRenderFunction<HTMLLIElement, Props> = (\n {\n id,\n children,\n className,\n isSelected = false,\n disableDefaultSelectedStyle,\n shouldClick,\n hasFocus,\n selectOpened,\n isSearching,\n childIndex,\n onOptionSelect,\n onFocusChange,\n disabled,\n value,\n isAddBtnFocused,\n ...rest\n }: Props,\n ref\n) => {\n const defaultOptionId = useRef(generateID(20));\n const optionId = id ?? defaultOptionId.current;\n const innerOptionRef = (ref as RefObject<HTMLLIElement>) || createRef<HTMLLIElement>();\n\n const additionalClasses = [];\n className && additionalClasses.push(className);\n isSelected && !disableDefaultSelectedStyle && additionalClasses.push(classes[\"selected-option\"]);\n disabled && additionalClasses.push(classes[\"disabled\"]);\n\n useEffect(() => {\n if (isSelected && innerOptionRef.current && shouldClick) {\n innerOptionRef.current.click();\n }\n }, [isSelected, shouldClick]);\n\n useEffect(() => {\n if (innerOptionRef.current && hasFocus && selectOpened && !isSearching && !isAddBtnFocused) {\n onFocusChange && childIndex && onFocusChange(childIndex);\n innerOptionRef.current.focus();\n }\n }, [hasFocus, innerOptionRef, selectOpened, isSearching]);\n\n const onSelectHandler = () => {\n if (disabled) {\n return;\n }\n onOptionSelect?.(innerOptionRef);\n };\n\n return (\n <li // NOSONAR S6819 - <option> is only valid inside <select>/<optgroup>; this is an ARIA listbox built from <li> elements, so role=\"option\" is the correct authoring practice.\n {...rest}\n id={optionId}\n ref={innerOptionRef}\n data-value={value}\n className={additionalClasses.join(\" \")}\n onClick={onSelectHandler}\n onKeyDown={event => {\n if (event.code === \"Enter\") {\n event.stopPropagation();\n event.preventDefault();\n\n onSelectHandler();\n }\n }}\n aria-selected={isSelected}\n aria-disabled={disabled}\n role=\"option\" // NOSONAR S6842 - required by the ARIA listbox pattern; the parent <ul role=\"listbox\"> needs option-role children, and aria-selected is only valid on this role.\n tabIndex={disabled ? -1 : 0}\n >\n {children}\n </li>\n );\n};\n\nexport const Option = React.forwardRef(OptionComponent);\n"],"names":["classes"],"mappings":";;;AA6CA,MAAM,kBAAkE,CACtE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACA,QACG;AACH,QAAM,kBAAkB,OAAO,WAAW,EAAE,CAAC;AAC7C,QAAM,WAAW,MAAM,gBAAgB;AACvC,QAAM,iBAAkB,OAAoC,UAAA;AAE5D,QAAM,oBAAoB,CAAA;AAC1B,eAAa,kBAAkB,KAAK,SAAS;AAC7C,gBAAc,CAAC,+BAA+B,kBAAkB,KAAKA,cAAQ,iBAAiB,CAAC;AAC/F,cAAY,kBAAkB,KAAKA,cAAQ,UAAU,CAAC;AAEtD,YAAU,MAAM;AACd,QAAI,cAAc,eAAe,WAAW,aAAa;AACvD,qBAAe,QAAQ,MAAA;AAAA,IACzB;AAAA,EACF,GAAG,CAAC,YAAY,WAAW,CAAC;AAE5B,YAAU,MAAM;AACd,QAAI,eAAe,WAAW,YAAY,gBAAgB,CAAC,eAAe,CAAC,iBAAiB;AAC1F,uBAAiB,cAAc,cAAc,UAAU;AACvD,qBAAe,QAAQ,MAAA;AAAA,IACzB;AAAA,EACF,GAAG,CAAC,UAAU,gBAAgB,cAAc,WAAW,CAAC;AAExD,QAAM,kBAAkB,MAAM;AAC5B,QAAI,UAAU;AACZ;AAAA,IACF;AACA,qDAAiB;AAAA,EACnB;AAEA,SACE,sBAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,MACJ,IAAI;AAAA,MACJ,KAAK;AAAA,MACL,cAAY;AAAA,MACZ,WAAW,kBAAkB,KAAK,GAAG;AAAA,MACrC,SAAS;AAAA,MACT,WAAW,CAAA,UAAS;AAClB,YAAI,MAAM,SAAS,SAAS;AAC1B,gBAAM,gBAAA;AACN,gBAAM,eAAA;AAEN,0BAAA;AAAA,QACF;AAAA,MACF;AAAA,MACA,iBAAe;AAAA,MACf,iBAAe;AAAA,MACf,MAAK;AAAA,MACL,UAAU,WAAW,KAAK;AAAA,IAAA;AAAA,IAEzB;AAAA,EAAA;AAGP;AAEO,MAAM,SAAS,MAAM,WAAW,eAAe;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Select.module.scss.cjs.js"),t=require("react"),s=require("../../../../hooks/useClickOutside.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Select.module.scss.cjs.js"),t=require("react"),s=require("../../../../hooks/useClickOutside.cjs.js"),a=require("../../../../readyclasses.module.scss.cjs.js"),n=require("../../../../util/helper.cjs.js"),r=require("../../../Icon/Icon.cjs.js"),l=require("../Select.interfaces.cjs.js"),i=require("../useSelectPositionList.cjs.js"),c=require("../useAddNewBtn.cjs.js"),o=require("./useSearch.cjs.js"),d=require("./useArrowNavigation.cjs.js"),u=require("../../../withReadOnly.cjs.js"),p=require("../../../RequiredSign/RequiredSign.cjs.js"),h=require("../../FormStatusIndicator/FormStatusIndicator.cjs.js"),m=require("../../../InlineEditing/InlineEditingContext.cjs.js"),f=(e,s)=>t.Children.map(e,(e,a)=>t.cloneElement(e,{onFocusChange:s.onFocusChange,onOptionSelect:s.onOptionSelect,isSelected:e.props.value===s.value,isSearching:s.isSearching,selectOpened:s.selectOpened,childIndex:a,hasFocus:s.focusedSelectItem===a,shouldClick:s.shouldClick,isAddBtnFocused:s.addBtnRef.current===document.activeElement})),S=u.withReadOnly(t.forwardRef(({children:u,name:S,disabled:g=!1,labeledBy:v,placeholder:b,describedBy:j,selectButtonProps:C,className:y,error:E=!1,success:N=!1,value:w,clearLabel:I="Clear selection",noResultsLabel:R="No results found",onChange:q,addNew:x,search:O,isReadOnlyView:B,...A},k)=>{const F=`${t.useRef(n.generateID(20)).current}_listbox`,[P,L]=t.useState(!1),[$,H]=t.useState(""),T=t.useRef(null),V=t.useRef(null),[D,M]=t.useState(-1),[K,U]=t.useState(!1),[_,z]=t.useState(!1),G=t.Children.count(u),{filter:J,isSearching:Q,renderSearch:W,searchInputRef:X,setIsSearching:Y,searchThreshold:Z,searchVisible:ee}=o.useSearch({expanded:P,search:O,searchInputClassName:e.default["select-search"],optionsCount:G,setFocusedSelectItem:M}),{addBtnRef:te,addNewBtnOptionsContainerClassName:se,renderAddNew:ae}=c.useAddNewBtn({addNew:x,filter:J,focusedSelectItem:D,optionsCount:G,searchInputRef:X}),{inlineClassNames:ne}=m.useInlineEditing(),re=ne?` ${ne}`:"",le=k||t.createRef(),ie=e=>{"true"!==(null==e?void 0:e.getAttribute("aria-disabled"))&&(le.current&&e&&(le.current.value=e.dataset.value,le.current.dispatchEvent(new Event("change",{bubbles:!0}))),L(!1))},ce=e=>{M(e)},oe=e=>{ie(e.current),U(!1)},de=t.useRef(null),{onArrowNavigation:ue}=d.useArrowNavigation({expanded:P,setExpanded:L,isSearching:Q,setIsSearching:Y,setFocusedSelectItem:M,onOptionChangeHandler:ie,childrenCount:G,setShouldClick:U,searchInputRef:X,addBtnRef:te,renderThreshold:Z,isReadOnlyView:B||!!A["data-readonlyview"]}),{listPosition:pe,opacity:he,optionsListMaxHeight:me,setListPosition:fe,setOpacity:Se}=i.useSelectPositionList({expanded:P,optionListReference:V,containerReference:T,addBtnRef:te});t.useEffect(()=>{P&&(M(0),z(!0)),!P&&de.current&&_&&(de.current.focus(),z(!1))},[P,de.current,_]),t.useEffect(()=>{var e;e=w,t.Children.forEach(u,t=>{t.props.value===e&&H(t.props.children)})},[w,u]);const ge=t.useRef(null);s.useClickOutside(ge,()=>{P&&(L(!1),fe(l.Position.Below),Se(0))},[P]);const ve=[];return P&&ve.push(e.default.expanded),E&&ve.push(e.default.error),g&&ve.push(e.default.disabled),y&&ve.push(y),N&&ve.push(e.default.success),t.createElement("div",{ref:ge,className:`${e.default.root}${re}`},t.createElement("select",{...n.omitProps(A,/^data-/),tabIndex:-1,"aria-hidden":"true",ref:le,name:S,onChange:e=>{null==q||q(e)},className:a.default["sr-only"]},t.createElement("option",{value:""}),t.Children.map(u,e=>t.createElement("option",{value:e.props.value}))),t.createElement("div",{...n.pickProps(A,/^data-/),ref:T,onKeyDown:ue,className:`custom-select ${e.default.select} ${ve.join(" ")}`},ee&&W(),t.createElement("button",{...C,onClick:()=>{L(!B&&!A["data-readonlyview"]&&!P)},ref:de,type:"button",name:S,className:`${e.default["custom-select"]} ${ve.join(" ")} `,style:{display:P&&ee?"none":"block"},disabled:g,role:"combobox","aria-disabled":g,"aria-invalid":E,"aria-expanded":P,"aria-controls":F,"aria-haspopup":"listbox","aria-labelledby":v,"aria-describedby":j},t.createElement("div",{"data-display":!0,className:e.default.selected},!w&&b&&t.createElement("span",{className:e.default.placeholder},b),(null==w?void 0:w.length)>0&&t.createElement("span",{"data-display-inner":!0},$),t.createElement(p.RequiredSign,{className:e.default.required})),t.createElement("div",{className:e.default.status},t.createElement(h.FormStatusIndicator,{isReadOnlyView:B,success:N,error:E},P?t.createElement(r.Icon,{className:e.default["chevron-icon"],icon:r.Icons.ChevronUp}):t.createElement(r.Icon,{className:e.default["chevron-icon"],icon:r.Icons.ChevronDown})))),t.createElement("div",{className:"list-wrapper-container"},t.createElement("div",{ref:V,className:`list-wrapper ${e.default["list-wrapper"]}`,style:{display:P?"block":"none",opacity:he,maxHeight:me.wrapper,pointerEvents:P?"auto":"none",bottom:pe===l.Position.Above?"2.85rem":"initial",marginTop:"4px"}},t.createElement("ul",{id:F,className:se,role:"listbox",style:{maxHeight:me.list}},(()=>{const s={onFocusChange:ce,onOptionSelect:oe,value:w,isSearching:Q,selectOpened:P,focusedSelectItem:D,shouldClick:K,addBtnRef:te};if(Q||""!==J){const a=t.Children.toArray(u).filter(e=>{const t=e.props.children;return(Array.isArray(t)?t.map(String).join(""):String(t)).toLowerCase().includes(J.toLowerCase())});return 0===f(a,s).length?t.createElement("li",{className:e.default["no-results"]},R):f(a,s)}return f(u,s)})()),ae()))))}));exports.Select=S;
|
|
2
2
|
//# sourceMappingURL=Select.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.cjs.js","sources":["../../../../../src/components/Form/Select/SingleSelect/Select.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport classes from \"./Select.module.scss\";\n\nimport React, {\n createRef,\n ForwardRefRenderFunction,\n ReactElement,\n useEffect,\n useRef,\n useState\n} from \"react\";\nimport { useClickOutside } from \"../../../../hooks/useClickOutside\";\nimport readyclasses from \"../../../../readyclasses.module.scss\";\nimport { generateID, omitProps, pickProps } from \"../../../../util/helper\";\nimport { Icon, Icons } from \"../../../Icon/Icon\";\nimport { Spinner } from \"../../../Spinner/Spinner\";\nimport { Position, SingleSelectProps } from \"../Select.interfaces\";\nimport { useSelectPositionList } from \"../useSelectPositionList\";\nimport { useAddNewBtn } from \"../useAddNewBtn\";\nimport { useSearch } from \"./useSearch\";\nimport { useArrowNavigation } from \"./useArrowNavigation\";\nimport { withReadOnly } from \"../../../withReadOnly\";\nimport { RequiredSign } from \"../../../RequiredSign/RequiredSign\";\nimport { FormStatusIndicator } from \"../../FormStatusIndicator/FormStatusIndicator\";\nimport { useInlineEditing } from \"../../../InlineEditing/InlineEditingContext\";\n\ninterface OptionRenderProps {\n onFocusChange: (childIndex: number) => void;\n onOptionSelect: (optionRef: React.RefObject<HTMLLIElement>) => void;\n value: string;\n isSearching: boolean;\n selectOpened: boolean;\n focusedSelectItem: number;\n shouldClick: boolean;\n addBtnRef: React.RefObject<HTMLButtonElement>;\n}\n\nconst renderChildOptions = (internalChildren: ReactElement[], optionProps: OptionRenderProps) => {\n return React.Children.map(internalChildren, (child, index) => {\n return React.cloneElement(child, {\n onFocusChange: optionProps.onFocusChange,\n onOptionSelect: optionProps.onOptionSelect,\n isSelected: child.props.value === optionProps.value,\n isSearching: optionProps.isSearching,\n selectOpened: optionProps.selectOpened,\n childIndex: index,\n hasFocus: optionProps.focusedSelectItem === index,\n shouldClick: optionProps.shouldClick,\n isAddBtnFocused: optionProps.addBtnRef.current === document.activeElement\n });\n });\n};\n\nconst SelectComponent: ForwardRefRenderFunction<HTMLSelectElement, SingleSelectProps> = (\n {\n children,\n name,\n disabled = false,\n labeledBy,\n placeholder,\n describedBy,\n selectButtonProps,\n className,\n error = false,\n success = false,\n value,\n clearLabel = \"Clear selection\",\n noResultsLabel = \"No results found\",\n onChange,\n addNew,\n search,\n isReadOnlyView,\n selectedOption,\n ...rest\n }: SingleSelectProps,\n ref\n) => {\n const selectId = useRef(generateID(20));\n const listboxId = `${selectId.current}_listbox`;\n const [expanded, setExpanded] = useState(false);\n const [display, setDisplay] = useState<React.ReactNode>(\"\");\n const containerReference = useRef<HTMLDivElement>(null);\n const optionListReference = useRef<HTMLDivElement>(null);\n const [focusedSelectItem, setFocusedSelectItem] = useState(-1);\n const [shouldClick, setShouldClick] = useState(false);\n /** We need this, because whenever we use the arrow keys to select the select item, and we focus the currently selected item it fires the \"click\" listener in Option component. Instead, we only want this to fire if we press \"enter\" or \"spacebar\" so we set this to true whenever that is the case, and back to false when it has been executed. */\n const [shouldFocusButtonAfterClose, setShouldFocusButtonAfterClose] = useState(false);\n const optionsCount = React.Children.count(children);\n const listRef = useRef<HTMLUListElement>(null);\n const loadMoreSentinelRef = useRef<HTMLLIElement>(null);\n const loadMoreFiredRef = useRef(false);\n const asyncBusyRef = useRef(false);\n const {\n filter,\n isSearching,\n renderSearch,\n searchInputRef,\n setIsSearching,\n searchThreshold,\n searchVisible,\n isAsync,\n isAsyncPending,\n asyncMinSearchLength\n } = useSearch({\n expanded,\n search,\n searchInputClassName: classes[\"select-search\"],\n optionsCount,\n setFocusedSelectItem\n });\n const { addBtnRef, addNewBtnOptionsContainerClassName, renderAddNew } = useAddNewBtn({\n addNew,\n filter,\n focusedSelectItem,\n optionsCount,\n searchInputRef\n });\n\n const { inlineClassNames } = useInlineEditing();\n const rootClassNames = inlineClassNames ? ` ${inlineClassNames}` : \"\";\n\n const nativeSelect = (ref as React.RefObject<HTMLSelectElement>) || createRef();\n\n const onOptionChangeHandler = (optionElement: HTMLElement | null) => {\n if (optionElement?.getAttribute(\"aria-disabled\") === \"true\") {\n return;\n }\n\n if (nativeSelect.current && optionElement) {\n nativeSelect.current.value = optionElement.dataset.value!;\n nativeSelect.current.dispatchEvent(new Event(\"change\", { bubbles: true }));\n }\n\n setExpanded(false);\n };\n\n const handleOptionFocusChange = (childIndex: number) => {\n setFocusedSelectItem(childIndex);\n };\n\n const handleOptionSelect = (optionRef: React.RefObject<HTMLLIElement>) => {\n onOptionChangeHandler(optionRef.current);\n setShouldClick(false);\n };\n\n const customSelectButtonRef = useRef<HTMLButtonElement>(null);\n const { onArrowNavigation } = useArrowNavigation({\n expanded,\n setExpanded,\n isSearching,\n setIsSearching,\n setFocusedSelectItem,\n onOptionChangeHandler,\n childrenCount: optionsCount,\n setShouldClick,\n searchInputRef,\n addBtnRef,\n renderThreshold: searchThreshold,\n isReadOnlyView: isReadOnlyView || !!rest[\"data-readonlyview\"]\n });\n\n const { listPosition, opacity, optionsListMaxHeight, setListPosition, setOpacity } =\n useSelectPositionList({ expanded, optionListReference, containerReference, addBtnRef });\n\n /** Display resolution order: matching child in `children` → `selectedOption` (async mode\n * fallback for a value that isn't in the currently loaded page) → blank (placeholder shows\n * instead, driven by `value` being falsy). */\n const syncDisplayValue = (val: string) => {\n let hasMatchingChild = false;\n React.Children.forEach(children, child => {\n if (child.props.value === val) {\n setDisplay(child.props.children);\n hasMatchingChild = true;\n }\n });\n\n if (hasMatchingChild) {\n return;\n }\n\n if (selectedOption && selectedOption.value === val) {\n setDisplay(selectedOption.label);\n return;\n }\n\n setDisplay(\"\");\n };\n\n /** True while a request is in flight (consumer-reported) or a debounced search is about to fire — keeps the list from flashing stale results for a query that's already been superseded. */\n const asyncBusy = !!search?.async?.loading || isAsyncPending;\n asyncBusyRef.current = asyncBusy;\n\n /** Paging (T4): only enabled once the consumer opts in via `onLoadMore`. `hasMore` additionally\n * gates the sentinel that triggers it — once the consumer reports no more pages, it disappears. */\n const asyncOnLoadMore = search?.async?.onLoadMore;\n const canPaginate = isAsync && !!asyncOnLoadMore;\n /** Only relevant while an actual page of options is being shown — not during the error/idle\n * states, and not when the current page is empty (nothing to scroll to). */\n const showLoadMoreSentinel =\n canPaginate &&\n !!search?.async?.hasMore &&\n !search?.async?.errorLabel &&\n filter.length >= asyncMinSearchLength &&\n React.Children.count(children) > 0;\n\n /**\n * @description We have to modify the children (Option component) to have an additional props that allows us to keep track of which one is selected and focused at all times and if a filter is active.\n * The `children` prop can be either a single object (1 child) or an array of multiple children.\n */\n const renderOptions = () => {\n const optionProps: OptionRenderProps = {\n onFocusChange: handleOptionFocusChange,\n onOptionSelect: handleOptionSelect,\n value,\n isSearching,\n selectOpened: expanded,\n focusedSelectItem,\n shouldClick,\n addBtnRef\n };\n\n if (isAsync) {\n const asyncSearch = search?.async;\n\n if (asyncSearch?.errorLabel) {\n return (\n <li className={classes[\"async-status\"]}>\n {asyncSearch.errorLabel}\n {asyncSearch.onRetry && (\n <button\n type=\"button\"\n className={classes[\"retry-button\"]}\n onClick={asyncSearch.onRetry}\n >\n Retry\n </button>\n )}\n </li>\n );\n }\n\n if (filter.length < asyncMinSearchLength) {\n return (\n <li className={classes[\"async-status\"]}>{asyncSearch?.idleLabel ?? \"Type to search\"}</li>\n );\n }\n\n if (asyncBusy) {\n /* Paging (T4): once a page has already been rendered, a subsequent `loading` (fetching\n * the next page) must append a \"loading more\" row rather than replace the list — that\n * full-list-replace behavior is reserved for the initial/new-query loading state above. */\n if (canPaginate && React.Children.count(children) > 0) {\n return [\n ...renderChildOptions(children, optionProps),\n <li\n key=\"__select-load-more-status__\"\n data-testid=\"select-load-more-status\"\n className={classes[\"async-status\"]}\n >\n <Spinner size={16} />\n </li>\n ];\n }\n\n return (\n <li className={classes[\"async-status\"]}>\n <Spinner size={20} />\n </li>\n );\n }\n\n if (React.Children.count(children) === 0) {\n return <li className={classes[\"no-results\"]}>{noResultsLabel}</li>;\n }\n\n return renderChildOptions(children, optionProps);\n }\n\n if (isSearching || filter !== \"\") {\n const filteredChildren = React.Children.toArray(children).filter(child => {\n const childElement = child as React.ReactElement;\n const innerChildren = childElement.props.children;\n\n const childText = Array.isArray(innerChildren)\n ? innerChildren.map(String).join(\"\")\n : String(innerChildren);\n return childText.toLowerCase().includes(filter.toLowerCase());\n });\n\n const internalChildren = renderChildOptions(filteredChildren as ReactElement[], optionProps);\n\n if (internalChildren.length === 0) {\n return <li className={classes[\"no-results\"]}>{noResultsLabel}</li>;\n }\n\n return renderChildOptions(filteredChildren as ReactElement[], optionProps);\n }\n\n return renderChildOptions(children, optionProps);\n };\n\n const getAsyncStatusMessage = () => {\n const asyncSearch = search?.async;\n if (!asyncSearch) {\n return \"\";\n }\n\n if (asyncSearch.errorLabel) {\n return asyncSearch.errorLabel;\n }\n\n if (filter.length < asyncMinSearchLength) {\n return asyncSearch.idleLabel ?? \"Type to search\";\n }\n\n if (asyncBusy) {\n return \"Loading\";\n }\n\n const resultsCount = React.Children.count(children);\n return resultsCount === 0 ? noResultsLabel : `${resultsCount} results`;\n };\n\n const renderChevronIcon = () => {\n return expanded ? (\n <Icon className={classes[\"chevron-icon\"]} icon={Icons.ChevronUp} />\n ) : (\n <Icon className={classes[\"chevron-icon\"]} icon={Icons.ChevronDown} />\n );\n };\n\n const nativeOnChangeHandler = (event: React.ChangeEvent<HTMLSelectElement>) => {\n onChange?.(event);\n };\n\n useEffect(() => {\n if (expanded) {\n setFocusedSelectItem(0);\n setShouldFocusButtonAfterClose(true);\n }\n\n if (!expanded && customSelectButtonRef.current && shouldFocusButtonAfterClose) {\n customSelectButtonRef.current.focus();\n setShouldFocusButtonAfterClose(false);\n }\n }, [expanded, customSelectButtonRef.current, shouldFocusButtonAfterClose]);\n\n useEffect(() => {\n syncDisplayValue(value);\n }, [value, children, selectedOption]);\n\n /** Paging (T4): observes a sentinel rendered after the last option and calls `onLoadMore` once\n * per bottom-reach while `hasMore` is true. Guarded (via `loadMoreFiredRef`) against firing\n * again for the same reach-end, and (via `asyncBusyRef`) against firing while a page is already\n * loading. No-op — no observer, no calls — whenever `onLoadMore` is omitted or `hasMore` is\n * false, which also covers the sentinel not being rendered/collapsed. */\n useEffect(() => {\n if (!showLoadMoreSentinel || !expanded) {\n loadMoreFiredRef.current = false;\n return;\n }\n\n const sentinel = loadMoreSentinelRef.current;\n if (!sentinel || typeof IntersectionObserver === \"undefined\") {\n return;\n }\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (!entry.isIntersecting) {\n loadMoreFiredRef.current = false;\n return;\n }\n\n if (loadMoreFiredRef.current || asyncBusyRef.current) {\n return;\n }\n\n loadMoreFiredRef.current = true;\n asyncOnLoadMore?.();\n },\n { root: listRef.current, threshold: 0 }\n );\n\n observer.observe(sentinel);\n\n return () => observer.disconnect();\n }, [showLoadMoreSentinel, expanded, asyncOnLoadMore]);\n\n const myElementRef = useRef<HTMLDivElement>(null);\n\n useClickOutside(myElementRef, () => {\n if (!expanded) {\n return;\n }\n setExpanded(false);\n setListPosition(Position.Below);\n setOpacity(0);\n }, [expanded]);\n\n const additionalClasses = [];\n expanded && additionalClasses.push(classes.expanded);\n error && additionalClasses.push(classes.error);\n disabled && additionalClasses.push(classes.disabled);\n className && additionalClasses.push(className);\n success && additionalClasses.push(classes.success);\n\n /** The native select is purely for external form libraries. We use it to emit an onChange with native select event object so they know exactly what's happening. */\n return (\n <div ref={myElementRef} className={`${classes[\"root\"]}${rootClassNames}`}>\n <select\n {...omitProps(rest, /^data-/)}\n tabIndex={-1}\n aria-hidden=\"true\"\n ref={nativeSelect}\n name={name}\n onChange={nativeOnChangeHandler}\n className={readyclasses[\"sr-only\"]}\n >\n <option value=\"\"></option>\n {React.Children.map(children, child => (\n <option value={child.props.value}></option>\n ))}\n </select>\n <div // NOSONAR(S6848) event-delegation wrapper; keys bubble from focusable button/options, adding role/tabIndex would create a spurious tab stop\n {...pickProps(rest, /^data-/)}\n ref={containerReference}\n onKeyDown={onArrowNavigation}\n className={`custom-select ${classes.select} ${additionalClasses.join(\" \")}`}\n >\n {searchVisible && renderSearch()}\n <button // NOSONAR(S6819) no semantic equivalent: <input list>/<select multiple> can't host the search input, add-new button, status icon or custom option markup, and <input> can't contain the trigger's child elements. role=\"combobox\" follows the ARIA APG select-only combobox pattern and is what allows aria-invalid here.\n {...selectButtonProps}\n onClick={() => {\n setExpanded(isReadOnlyView || rest[\"data-readonlyview\"] ? false : !expanded);\n }}\n ref={customSelectButtonRef}\n type=\"button\"\n name={name}\n className={`${classes[\"custom-select\"]} ${additionalClasses.join(\" \")} `}\n style={{ display: expanded && searchVisible ? \"none\" : \"block\" }}\n disabled={disabled}\n /* ARIA 1.2 combobox pattern: the trigger owns the popup state, the invalid state and controls the listbox. */\n role=\"combobox\"\n aria-disabled={disabled}\n aria-invalid={error}\n aria-expanded={expanded}\n aria-controls={listboxId}\n aria-haspopup=\"listbox\"\n aria-labelledby={labeledBy}\n aria-describedby={describedBy}\n >\n <div data-display className={classes[\"selected\"]}>\n {!value && placeholder && <span className={classes[\"placeholder\"]}>{placeholder}</span>}\n {value?.length > 0 && <span data-display-inner>{display}</span>}\n <RequiredSign className={classes[\"required\"]} />\n </div>\n <div className={classes[\"status\"]}>\n <FormStatusIndicator isReadOnlyView={isReadOnlyView} success={success} error={error}>\n {renderChevronIcon()}\n </FormStatusIndicator>\n </div>\n </button>\n <div className=\"list-wrapper-container\">\n <div\n ref={optionListReference}\n className={`list-wrapper ${classes[\"list-wrapper\"]}`}\n style={{\n display: expanded ? \"block\" : \"none\",\n opacity: opacity,\n maxHeight: optionsListMaxHeight.wrapper,\n pointerEvents: expanded ? \"auto\" : \"none\",\n bottom: listPosition === Position.Above ? \"2.85rem\" : \"initial\",\n marginTop: \"4px\"\n }}\n >\n <ul // NOSONAR(S6819) native <select> can't host search, add-new or custom option markup\n ref={listRef}\n id={listboxId}\n className={addNewBtnOptionsContainerClassName}\n role=\"listbox\" // NOSONAR(S6842) required by the ARIA listbox pattern\n style={{ maxHeight: optionsListMaxHeight.list }}\n aria-busy={isAsync ? asyncBusy : undefined}\n >\n {renderOptions()}\n {showLoadMoreSentinel && (\n <li\n ref={loadMoreSentinelRef}\n aria-hidden=\"true\"\n data-testid=\"select-load-more-sentinel\"\n className={classes[\"load-more-sentinel\"]}\n />\n )}\n </ul>\n {isAsync && (\n <span role=\"status\" aria-live=\"polite\" className={readyclasses[\"sr-only\"]}>\n {getAsyncStatusMessage()}\n </span>\n )}\n {renderAddNew()}\n </div>\n </div>\n </div>\n </div>\n );\n};\nexport const Select = withReadOnly(React.forwardRef(SelectComponent));\n"],"names":["renderChildOptions","internalChildren","optionProps","React","Children","map","child","index","cloneElement","onFocusChange","onOptionSelect","isSelected","props","value","isSearching","selectOpened","childIndex","hasFocus","focusedSelectItem","shouldClick","isAddBtnFocused","addBtnRef","current","document","activeElement","Select","withReadOnly","forwardRef","children","name","disabled","labeledBy","placeholder","describedBy","selectButtonProps","className","error","success","clearLabel","noResultsLabel","onChange","addNew","search","isReadOnlyView","selectedOption","rest","ref","listboxId","useRef","generateID","expanded","setExpanded","useState","display","setDisplay","containerReference","optionListReference","setFocusedSelectItem","setShouldClick","shouldFocusButtonAfterClose","setShouldFocusButtonAfterClose","optionsCount","count","listRef","loadMoreSentinelRef","loadMoreFiredRef","asyncBusyRef","filter","renderSearch","searchInputRef","setIsSearching","searchThreshold","searchVisible","isAsync","isAsyncPending","asyncMinSearchLength","useSearch","searchInputClassName","classes","addNewBtnOptionsContainerClassName","renderAddNew","useAddNewBtn","inlineClassNames","useInlineEditing","rootClassNames","nativeSelect","createRef","onOptionChangeHandler","optionElement","getAttribute","dataset","dispatchEvent","Event","bubbles","handleOptionFocusChange","handleOptionSelect","optionRef","customSelectButtonRef","onArrowNavigation","useArrowNavigation","childrenCount","renderThreshold","listPosition","opacity","optionsListMaxHeight","setListPosition","setOpacity","useSelectPositionList","asyncBusy","_a","async","loading","asyncOnLoadMore","_b","onLoadMore","canPaginate","showLoadMoreSentinel","_c","hasMore","_d","errorLabel","length","useEffect","focus","val","hasMatchingChild","forEach","label","syncDisplayValue","sentinel","IntersectionObserver","observer","entry","isIntersecting","root","threshold","observe","disconnect","myElementRef","useClickOutside","Position","Below","additionalClasses","push","createElement","omitProps","tabIndex","event","readyclasses","pickProps","onKeyDown","select","join","onClick","type","style","role","RequiredSign","FormStatusIndicator","Icon","icon","Icons","ChevronUp","ChevronDown","maxHeight","wrapper","pointerEvents","bottom","Above","marginTop","id","list","asyncSearch","onRetry","idleLabel","key","Spinner","size","filteredChildren","toArray","innerChildren","Array","isArray","String","toLowerCase","includes","renderOptions","resultsCount","getAsyncStatusMessage"],"mappings":"uyBAoDMA,EAAqB,CAACC,EAAkCC,IACrDC,EAAMC,SAASC,IAAIJ,EAAkB,CAACK,EAAOC,IAC3CJ,EAAMK,aAAaF,EAAO,CAC/BG,cAAeP,EAAYO,cAC3BC,eAAgBR,EAAYQ,eAC5BC,WAAYL,EAAMM,MAAMC,QAAUX,EAAYW,MAC9CC,YAAaZ,EAAYY,YACzBC,aAAcb,EAAYa,aAC1BC,WAAYT,EACZU,SAAUf,EAAYgB,oBAAsBX,EAC5CY,YAAajB,EAAYiB,YACzBC,gBAAiBlB,EAAYmB,UAAUC,UAAYC,SAASC,iBA0crDC,EAASC,EAAAA,aAAavB,EAAMwB,WArc+C,EAEpFC,WACAC,OACAC,YAAW,EACXC,YACAC,cACAC,cACAC,oBACAC,YACAC,SAAQ,EACRC,WAAU,EACVxB,QACAyB,aAAa,kBACbC,iBAAiB,mBACjBC,WACAC,SACAC,SACAC,iBACAC,oBACGC,GAELC,iBAEA,MACMC,EAAY,GADDC,EAAAA,OAAOC,EAAAA,WAAW,KACL3B,mBACvB4B,EAAUC,GAAeC,EAAAA,UAAS,IAClCC,EAASC,GAAcF,EAAAA,SAA0B,IAClDG,EAAqBP,EAAAA,OAAuB,MAC5CQ,EAAsBR,EAAAA,OAAuB,OAC5C9B,EAAmBuC,GAAwBL,EAAAA,UAAS,IACpDjC,EAAauC,GAAkBN,EAAAA,UAAS,IAExCO,EAA6BC,GAAkCR,EAAAA,UAAS,GACzES,EAAe1D,EAAMC,SAAS0D,MAAMlC,GACpCmC,GAAUf,EAAAA,OAAyB,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B4B,EAAU1B,IA0LzBwL,GACAtE,IACCjH,EAAA6I,cAAC,KAAA,CACClG,IAAKkB,GACL,cAAY,OACZ,cAAY,4BACZ7B,UAAW2C,EAAAA,QAAQ,yBAIxBL,IACCtE,EAAA6I,cAAC,OAAA,CAAKY,KAAK,SAAS,YAAU,SAASzH,UAAWiH,EAAAA,QAAa,YAlM7C,MAC5B,MAAMwB,EAAc,MAAAlI,OAAA,EAAAA,EAAQoE,MAC5B,IAAK8D,EACH,MAAO,GAGT,GAAIA,EAAYpD,WACd,OAAOoD,EAAYpD,WAGrB,GAAIrD,GAAOsD,OAAS9C,GAClB,OAAOiG,EAAYE,WAAa,iBAGlC,GAAIlE,GACF,MAAO,UAGT,MAAM+E,EAAexL,EAAMC,SAAS0D,MAAMlC,GAC1C,OAAwB,IAAjB+J,EAAqBpJ,EAAiB,GAAGoJ,aAgLnCC,IAGJ5G"}
|
|
1
|
+
{"version":3,"file":"Select.cjs.js","sources":["../../../../../src/components/Form/Select/SingleSelect/Select.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport classes from \"./Select.module.scss\";\n\nimport React, {\n createRef,\n ForwardRefRenderFunction,\n ReactElement,\n useEffect,\n useRef,\n useState\n} from \"react\";\nimport { useClickOutside } from \"../../../../hooks/useClickOutside\";\nimport readyclasses from \"../../../../readyclasses.module.scss\";\nimport { generateID, omitProps, pickProps } from \"../../../../util/helper\";\nimport { Icon, Icons } from \"../../../Icon/Icon\";\nimport { Position, SingleSelectProps } from \"../Select.interfaces\";\nimport { useSelectPositionList } from \"../useSelectPositionList\";\nimport { useAddNewBtn } from \"../useAddNewBtn\";\nimport { useSearch } from \"./useSearch\";\nimport { useArrowNavigation } from \"./useArrowNavigation\";\nimport { withReadOnly } from \"../../../withReadOnly\";\nimport { RequiredSign } from \"../../../RequiredSign/RequiredSign\";\nimport { FormStatusIndicator } from \"../../FormStatusIndicator/FormStatusIndicator\";\nimport { useInlineEditing } from \"../../../InlineEditing/InlineEditingContext\";\n\ninterface OptionRenderProps {\n onFocusChange: (childIndex: number) => void;\n onOptionSelect: (optionRef: React.RefObject<HTMLLIElement>) => void;\n value: string;\n isSearching: boolean;\n selectOpened: boolean;\n focusedSelectItem: number;\n shouldClick: boolean;\n addBtnRef: React.RefObject<HTMLButtonElement>;\n}\n\nconst renderChildOptions = (internalChildren: ReactElement[], optionProps: OptionRenderProps) => {\n return React.Children.map(internalChildren, (child, index) => {\n return React.cloneElement(child, {\n onFocusChange: optionProps.onFocusChange,\n onOptionSelect: optionProps.onOptionSelect,\n isSelected: child.props.value === optionProps.value,\n isSearching: optionProps.isSearching,\n selectOpened: optionProps.selectOpened,\n childIndex: index,\n hasFocus: optionProps.focusedSelectItem === index,\n shouldClick: optionProps.shouldClick,\n isAddBtnFocused: optionProps.addBtnRef.current === document.activeElement\n });\n });\n};\n\nconst SelectComponent: ForwardRefRenderFunction<HTMLSelectElement, SingleSelectProps> = (\n {\n children,\n name,\n disabled = false,\n labeledBy,\n placeholder,\n describedBy,\n selectButtonProps,\n className,\n error = false,\n success = false,\n value,\n clearLabel = \"Clear selection\",\n noResultsLabel = \"No results found\",\n onChange,\n addNew,\n search,\n isReadOnlyView,\n ...rest\n }: SingleSelectProps,\n ref\n) => {\n const selectId = useRef(generateID(20));\n const listboxId = `${selectId.current}_listbox`;\n const [expanded, setExpanded] = useState(false);\n const [display, setDisplay] = useState(\"\");\n const containerReference = useRef<HTMLDivElement>(null);\n const optionListReference = useRef<HTMLDivElement>(null);\n const [focusedSelectItem, setFocusedSelectItem] = useState(-1);\n const [shouldClick, setShouldClick] = useState(false);\n /** We need this, because whenever we use the arrow keys to select the select item, and we focus the currently selected item it fires the \"click\" listener in Option component. Instead, we only want this to fire if we press \"enter\" or \"spacebar\" so we set this to true whenever that is the case, and back to false when it has been executed. */\n const [shouldFocusButtonAfterClose, setShouldFocusButtonAfterClose] = useState(false);\n const optionsCount = React.Children.count(children);\n const {\n filter,\n isSearching,\n renderSearch,\n searchInputRef,\n setIsSearching,\n searchThreshold,\n searchVisible\n } = useSearch({\n expanded,\n search,\n searchInputClassName: classes[\"select-search\"],\n optionsCount,\n setFocusedSelectItem\n });\n const { addBtnRef, addNewBtnOptionsContainerClassName, renderAddNew } = useAddNewBtn({\n addNew,\n filter,\n focusedSelectItem,\n optionsCount,\n searchInputRef\n });\n\n const { inlineClassNames } = useInlineEditing();\n const rootClassNames = inlineClassNames ? ` ${inlineClassNames}` : \"\";\n\n const nativeSelect = (ref as React.RefObject<HTMLSelectElement>) || createRef();\n\n const onOptionChangeHandler = (optionElement: HTMLElement | null) => {\n if (optionElement?.getAttribute(\"aria-disabled\") === \"true\") {\n return;\n }\n\n if (nativeSelect.current && optionElement) {\n nativeSelect.current.value = optionElement.dataset.value!;\n nativeSelect.current.dispatchEvent(new Event(\"change\", { bubbles: true }));\n }\n\n setExpanded(false);\n };\n\n const handleOptionFocusChange = (childIndex: number) => {\n setFocusedSelectItem(childIndex);\n };\n\n const handleOptionSelect = (optionRef: React.RefObject<HTMLLIElement>) => {\n onOptionChangeHandler(optionRef.current);\n setShouldClick(false);\n };\n\n const customSelectButtonRef = useRef<HTMLButtonElement>(null);\n const { onArrowNavigation } = useArrowNavigation({\n expanded,\n setExpanded,\n isSearching,\n setIsSearching,\n setFocusedSelectItem,\n onOptionChangeHandler,\n childrenCount: optionsCount,\n setShouldClick,\n searchInputRef,\n addBtnRef,\n renderThreshold: searchThreshold,\n isReadOnlyView: isReadOnlyView || !!rest[\"data-readonlyview\"]\n });\n\n const { listPosition, opacity, optionsListMaxHeight, setListPosition, setOpacity } =\n useSelectPositionList({ expanded, optionListReference, containerReference, addBtnRef });\n\n const syncDisplayValue = (val: string) => {\n React.Children.forEach(children, child => {\n if (child.props.value === val) {\n setDisplay(child.props.children);\n }\n });\n };\n\n /**\n * @description We have to modify the children (Option component) to have an additional props that allows us to keep track of which one is selected and focused at all times and if a filter is active.\n * The `children` prop can be either a single object (1 child) or an array of multiple children.\n */\n const renderOptions = () => {\n const optionProps: OptionRenderProps = {\n onFocusChange: handleOptionFocusChange,\n onOptionSelect: handleOptionSelect,\n value,\n isSearching,\n selectOpened: expanded,\n focusedSelectItem,\n shouldClick,\n addBtnRef\n };\n\n if (isSearching || filter !== \"\") {\n const filteredChildren = React.Children.toArray(children).filter(child => {\n const childElement = child as React.ReactElement;\n const innerChildren = childElement.props.children;\n\n const childText = Array.isArray(innerChildren)\n ? innerChildren.map(String).join(\"\")\n : String(innerChildren);\n return childText.toLowerCase().includes(filter.toLowerCase());\n });\n\n const internalChildren = renderChildOptions(filteredChildren as ReactElement[], optionProps);\n\n if (internalChildren.length === 0) {\n return <li className={classes[\"no-results\"]}>{noResultsLabel}</li>;\n }\n\n return renderChildOptions(filteredChildren as ReactElement[], optionProps);\n }\n\n return renderChildOptions(children, optionProps);\n };\n\n const renderChevronIcon = () => {\n return expanded ? (\n <Icon className={classes[\"chevron-icon\"]} icon={Icons.ChevronUp} />\n ) : (\n <Icon className={classes[\"chevron-icon\"]} icon={Icons.ChevronDown} />\n );\n };\n\n const nativeOnChangeHandler = (event: React.ChangeEvent<HTMLSelectElement>) => {\n onChange?.(event);\n };\n\n useEffect(() => {\n if (expanded) {\n setFocusedSelectItem(0);\n setShouldFocusButtonAfterClose(true);\n }\n\n if (!expanded && customSelectButtonRef.current && shouldFocusButtonAfterClose) {\n customSelectButtonRef.current.focus();\n setShouldFocusButtonAfterClose(false);\n }\n }, [expanded, customSelectButtonRef.current, shouldFocusButtonAfterClose]);\n\n useEffect(() => {\n syncDisplayValue(value);\n }, [value, children]);\n\n const myElementRef = useRef<HTMLDivElement>(null);\n\n useClickOutside(myElementRef, () => {\n if (!expanded) {\n return;\n }\n setExpanded(false);\n setListPosition(Position.Below);\n setOpacity(0);\n }, [expanded]);\n\n const additionalClasses = [];\n expanded && additionalClasses.push(classes.expanded);\n error && additionalClasses.push(classes.error);\n disabled && additionalClasses.push(classes.disabled);\n className && additionalClasses.push(className);\n success && additionalClasses.push(classes.success);\n\n /** The native select is purely for external form libraries. We use it to emit an onChange with native select event object so they know exactly what's happening. */\n return (\n <div ref={myElementRef} className={`${classes[\"root\"]}${rootClassNames}`}>\n <select\n {...omitProps(rest, /^data-/)}\n tabIndex={-1}\n aria-hidden=\"true\"\n ref={nativeSelect}\n name={name}\n onChange={nativeOnChangeHandler}\n className={readyclasses[\"sr-only\"]}\n >\n <option value=\"\"></option>\n {React.Children.map(children, child => (\n <option value={child.props.value}></option>\n ))}\n </select>\n <div // NOSONAR(S6848) event-delegation wrapper; keys bubble from focusable button/options, adding role/tabIndex would create a spurious tab stop\n {...pickProps(rest, /^data-/)}\n ref={containerReference}\n onKeyDown={onArrowNavigation}\n className={`custom-select ${classes.select} ${additionalClasses.join(\" \")}`}\n >\n {searchVisible && renderSearch()}\n <button // NOSONAR(S6819) no semantic equivalent: <input list>/<select multiple> can't host the search input, add-new button, status icon or custom option markup, and <input> can't contain the trigger's child elements. role=\"combobox\" follows the ARIA APG select-only combobox pattern and is what allows aria-invalid here.\n {...selectButtonProps}\n onClick={() => {\n setExpanded(isReadOnlyView || rest[\"data-readonlyview\"] ? false : !expanded);\n }}\n ref={customSelectButtonRef}\n type=\"button\"\n name={name}\n className={`${classes[\"custom-select\"]} ${additionalClasses.join(\" \")} `}\n style={{ display: expanded && searchVisible ? \"none\" : \"block\" }}\n disabled={disabled}\n /* ARIA 1.2 combobox pattern: the trigger owns the popup state, the invalid state and controls the listbox. */\n role=\"combobox\"\n aria-disabled={disabled}\n aria-invalid={error}\n aria-expanded={expanded}\n aria-controls={listboxId}\n aria-haspopup=\"listbox\"\n aria-labelledby={labeledBy}\n aria-describedby={describedBy}\n >\n <div data-display className={classes[\"selected\"]}>\n {!value && placeholder && <span className={classes[\"placeholder\"]}>{placeholder}</span>}\n {value?.length > 0 && <span data-display-inner>{display}</span>}\n <RequiredSign className={classes[\"required\"]} />\n </div>\n <div className={classes[\"status\"]}>\n <FormStatusIndicator isReadOnlyView={isReadOnlyView} success={success} error={error}>\n {renderChevronIcon()}\n </FormStatusIndicator>\n </div>\n </button>\n <div className=\"list-wrapper-container\">\n <div\n ref={optionListReference}\n className={`list-wrapper ${classes[\"list-wrapper\"]}`}\n style={{\n display: expanded ? \"block\" : \"none\",\n opacity: opacity,\n maxHeight: optionsListMaxHeight.wrapper,\n pointerEvents: expanded ? \"auto\" : \"none\",\n bottom: listPosition === Position.Above ? \"2.85rem\" : \"initial\",\n marginTop: \"4px\"\n }}\n >\n <ul // NOSONAR(S6819) native <select> can't host search, add-new or custom option markup\n id={listboxId}\n className={addNewBtnOptionsContainerClassName}\n role=\"listbox\" // NOSONAR(S6842) required by the ARIA listbox pattern\n style={{ maxHeight: optionsListMaxHeight.list }}\n >\n {renderOptions()}\n </ul>\n {renderAddNew()}\n </div>\n </div>\n </div>\n </div>\n );\n};\nexport const Select = withReadOnly(React.forwardRef(SelectComponent));\n"],"names":["renderChildOptions","internalChildren","optionProps","React","Children","map","child","index","cloneElement","onFocusChange","onOptionSelect","isSelected","props","value","isSearching","selectOpened","childIndex","hasFocus","focusedSelectItem","shouldClick","isAddBtnFocused","addBtnRef","current","document","activeElement","Select","withReadOnly","forwardRef","children","name","disabled","labeledBy","placeholder","describedBy","selectButtonProps","className","error","success","clearLabel","noResultsLabel","onChange","addNew","search","isReadOnlyView","rest","ref","listboxId","useRef","generateID","expanded","setExpanded","useState","display","setDisplay","containerReference","optionListReference","setFocusedSelectItem","setShouldClick","shouldFocusButtonAfterClose","setShouldFocusButtonAfterClose","optionsCount","count","filter","renderSearch","searchInputRef","setIsSearching","searchThreshold","searchVisible","useSearch","searchInputClassName","classes","addNewBtnOptionsContainerClassName","renderAddNew","useAddNewBtn","inlineClassNames","useInlineEditing","rootClassNames","nativeSelect","createRef","onOptionChangeHandler","optionElement","getAttribute","dataset","dispatchEvent","Event","bubbles","handleOptionFocusChange","handleOptionSelect","optionRef","customSelectButtonRef","onArrowNavigation","useArrowNavigation","childrenCount","renderThreshold","listPosition","opacity","optionsListMaxHeight","setListPosition","setOpacity","useSelectPositionList","useEffect","focus","val","forEach","myElementRef","useClickOutside","Position","Below","additionalClasses","push","createElement","omitProps","tabIndex","event","readyclasses","pickProps","onKeyDown","select","join","onClick","type","style","role","length","RequiredSign","FormStatusIndicator","Icon","icon","Icons","ChevronUp","ChevronDown","maxHeight","wrapper","pointerEvents","bottom","Above","marginTop","id","list","filteredChildren","toArray","innerChildren","Array","isArray","String","toLowerCase","includes","renderOptions"],"mappings":"0vBAmDMA,EAAqB,CAACC,EAAkCC,IACrDC,EAAMC,SAASC,IAAIJ,EAAkB,CAACK,EAAOC,IAC3CJ,EAAMK,aAAaF,EAAO,CAC/BG,cAAeP,EAAYO,cAC3BC,eAAgBR,EAAYQ,eAC5BC,WAAYL,EAAMM,MAAMC,QAAUX,EAAYW,MAC9CC,YAAaZ,EAAYY,YACzBC,aAAcb,EAAYa,aAC1BC,WAAYT,EACZU,SAAUf,EAAYgB,oBAAsBX,EAC5CY,YAAajB,EAAYiB,YACzBC,gBAAiBlB,EAAYmB,UAAUC,UAAYC,SAASC,iBA6RrDC,EAASC,EAAAA,aAAavB,EAAMwB,WAxR+C,EAEpFC,WACAC,OACAC,YAAW,EACXC,YACAC,cACAC,cACAC,oBACAC,YACAC,SAAQ,EACRC,WAAU,EACVxB,QACAyB,aAAa,kBACbC,iBAAiB,mBACjBC,WACAC,SACAC,SACAC,oBACGC,GAELC,KAEA,MACMC,EAAY,GADDC,EAAAA,OAAOC,EAAAA,WAAW,KACL1B,mBACvB2B,EAAUC,GAAeC,EAAAA,UAAS,IAClCC,EAASC,GAAcF,E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