@cashub/ui 0.22.7 → 0.22.9
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/package.json +50 -0
- package/{table → dist/table}/Table.js +6 -5
- package/package.json +59 -50
- package/setupTests.js +9 -0
- package/src/Tab/Tab.js +11 -0
- package/src/Tab/TabList.js +20 -0
- package/src/Tab/TabPanel.js +35 -0
- package/src/Tab/TabTab.js +42 -0
- package/src/Tab/__stories__/Tab.stories.js +48 -0
- package/src/Tab/__stories__/TabList.stories.js +26 -0
- package/src/Tab/__stories__/TabPanel.stories.js +45 -0
- package/src/Tab/__stories__/TabTab.stories.js +30 -0
- package/src/Tab/__test__/Tab.test.js +43 -0
- package/src/Tab/__test__/TabList.test.js +22 -0
- package/src/Tab/__test__/TabPanel.test.js +27 -0
- package/src/Tab/__test__/TabTab.test.js +58 -0
- package/src/Tab/index.js +10 -0
- package/src/Tab/subComponent/TabContext.js +5 -0
- package/src/animate/Collapse.js +68 -0
- package/src/animate/Loader.js +36 -0
- package/src/animate/NumberCounter.js +49 -0
- package/src/animate/PulseRing.js +25 -0
- package/src/animate/Spinner.js +13 -0
- package/src/animate/__stories__/Collapse.stories.js +60 -0
- package/src/animate/__stories__/Loader.stories.js +33 -0
- package/src/animate/__stories__/NumberCounter.stories.js +29 -0
- package/src/animate/__stories__/PulseRing.stories.js +17 -0
- package/src/animate/__stories__/Spinner.stories.js +13 -0
- package/src/animate/__test__/Collapse.test.js +125 -0
- package/src/animate/__test__/Loader.test.js +42 -0
- package/src/animate/__test__/NumberCounter.test.js +71 -0
- package/src/animate/__test__/PulseRing.test.js +37 -0
- package/src/animate/__test__/Spinner.test.js +18 -0
- package/src/animate/index.js +5 -0
- package/src/assets/css/autocomplete.css +16 -0
- package/src/assets/css/font.css +4 -0
- package/src/assets/css/global.css +3 -0
- package/src/assets/css/normalize.css +386 -0
- package/src/assets/font/helvetica/Helvetica.ttf +0 -0
- package/src/assets/font/nanumGothic/NanumGothic-Bold.ttf +0 -0
- package/src/assets/font/nanumGothic/NanumGothic-ExtraBold.ttf +0 -0
- package/src/assets/font/nanumGothic/NanumGothic-Regular.ttf +0 -0
- package/src/assets/icons/app-management.png +0 -0
- package/src/assets/icons/burger.png +0 -0
- package/src/assets/icons/file.svg +1 -0
- package/src/assets/icons/map_icon1.png +0 -0
- package/src/assets/icons/map_icon4.png +0 -0
- package/src/assets/images/bg-chart-circle.png +0 -0
- package/src/assets/images/bg-chart-triangle.png +0 -0
- package/src/assets/images/cashub-logo-only.png +0 -0
- package/src/assets/images/default-user.jpg +0 -0
- package/src/assets/images/logo-cashub.png +0 -0
- package/src/assets/images/map.png +0 -0
- package/src/assets/images/qrcode.png +0 -0
- package/src/backdrop/BaseBackdrop.js +13 -0
- package/src/backdrop/LoadingBackdrop.js +12 -0
- package/src/backdrop/ModalBackdrop.js +10 -0
- package/src/backdrop/__test__/BaseBackdrop.test.js +10 -0
- package/src/backdrop/__test__/LoadingBackdrop.test.js +9 -0
- package/src/backdrop/__test__/ModalBackdrop.test.js +8 -0
- package/src/backdrop/index.js +3 -0
- package/src/badge/Badge.js +21 -0
- package/src/badge/BadgeDot.js +13 -0
- package/src/badge/BadgeFill.js +29 -0
- package/src/badge/BadgeWithText.js +21 -0
- package/src/badge/__stories__/Badge.stories.js +43 -0
- package/src/badge/__stories__/BadgeDot.stories.js +23 -0
- package/src/badge/__stories__/BadgeFill.stories.js +29 -0
- package/src/badge/__stories__/BadgeWithText.stories.js +26 -0
- package/src/badge/__test__/Badge.test.js +19 -0
- package/src/badge/__test__/BadgeDot.test.js +22 -0
- package/src/badge/__test__/BadgeFill.test.js +41 -0
- package/src/badge/__test__/BadgeWithText.test.js +22 -0
- package/src/badge/index.js +4 -0
- package/src/billing/BarChart.js +42 -0
- package/src/billing/Grid.js +30 -0
- package/src/billing/Header2.js +15 -0
- package/src/billing/Header3.js +32 -0
- package/src/billing/Paragraph.js +27 -0
- package/src/billing/ParagraphGroup.js +12 -0
- package/src/billing/ParagraphText.js +16 -0
- package/src/billing/Section.js +48 -0
- package/src/billing/SectionBody.js +7 -0
- package/src/billing/SectionHeader.js +16 -0
- package/src/billing/__stories__/BarChart.stories.js_bak +46 -0
- package/src/billing/__stories__/Grid.stories.js_bak +57 -0
- package/src/billing/__stories__/Header2.stories.js_bak +62 -0
- package/src/billing/__stories__/Header3.stories.js_bak +69 -0
- package/src/billing/__stories__/Paragraph.stories.js_bak +84 -0
- package/src/billing/__stories__/ParagraphGroup.stories.js_bak +68 -0
- package/src/billing/__stories__/ParagraphText.stories.js_bak +64 -0
- package/src/billing/__stories__/Section.stories.js_bak +115 -0
- package/src/billing/__stories__/SectionBody.stories.js_bak +62 -0
- package/src/billing/__stories__/SectionHeader.stories.js-bak +68 -0
- package/src/breadcrumb/Breadcrumb.js +66 -0
- package/src/breadcrumb/__stories__/Breadcrumb.stories.js +31 -0
- package/src/breadcrumb/__test__/breadcrumb.test.js +27 -0
- package/src/breadcrumb/index.js +1 -0
- package/src/button/Button.js +80 -0
- package/src/button/ButtonGroup.js +33 -0
- package/src/button/IconButton.js +40 -0
- package/src/button/ScrollToTopButton.js +48 -0
- package/src/button/__stories__/Button.stories.js +70 -0
- package/src/button/__stories__/ButtonGroup.stories.js +48 -0
- package/src/button/__stories__/IconButton.stories.js +30 -0
- package/src/button/__stories__/ScrollToTopButton.stories.js +22 -0
- package/src/button/__test__/Button.test.js +32 -0
- package/src/button/__test__/ButtonGroup.test.js +25 -0
- package/src/button/__test__/IconButton.test.js +34 -0
- package/src/button/__test__/ScrollToTopButton.test.js +19 -0
- package/src/button/index.js +4 -0
- package/src/callout/Callout.js +52 -0
- package/src/callout/__stories__/Callout.stories.js +23 -0
- package/src/callout/__test__/Callout.test.js +29 -0
- package/src/callout/index.js +1 -0
- package/src/chart/BarChart.js +134 -0
- package/src/chart/DoughnutChart.js +82 -0
- package/src/chart/LineChart.js +114 -0
- package/src/chart/SingleBarChart.js +27 -0
- package/src/chart/__stories__/BarChart.stories.js +54 -0
- package/src/chart/__stories__/DoughnutChart.stories.js +33 -0
- package/src/chart/__stories__/LineChart.stories.js +73 -0
- package/src/chart/__stories__/SingleBarChart.stories.js +22 -0
- package/src/chart/index.js +5 -0
- package/src/chart/utils/customTooltip.js +108 -0
- package/src/chart/utils/htmlLegendPlugin.js +88 -0
- package/src/chart/utils/index.js +3 -0
- package/src/chart/utils/padEmptyChartBar.js +37 -0
- package/src/container/FlexContainer.js +13 -0
- package/src/container/__stories__/FlexContainer.stories.js +39 -0
- package/src/container/__test__/FlexContainer.test.js +21 -0
- package/src/container/index.js +1 -0
- package/src/cropper/Cropper.js +49 -0
- package/src/cropper/CropperModalHandler.js +36 -0
- package/src/cropper/__stories__/Cropper.stories.js +32 -0
- package/src/cropper/__test__/Cropper.test.js +90 -0
- package/src/cropper/index.js +2 -0
- package/src/cropper/subComponent/CropImageModal.js +84 -0
- package/src/datetimePicker/DatePicker.js +493 -0
- package/src/datetimePicker/DatePickerV2.js +500 -0
- package/src/datetimePicker/DatetimePicker.js +218 -0
- package/src/datetimePicker/DatetimePickerV2.js +512 -0
- package/src/datetimePicker/TimeInput.js +45 -0
- package/src/datetimePicker/TimePicker.js +318 -0
- package/src/datetimePicker/TimePickerStyle.js +59 -0
- package/src/datetimePicker/__stories__/DatePicker.stories.js +51 -0
- package/src/datetimePicker/__stories__/DatePickerV2.stories.js +73 -0
- package/src/datetimePicker/__stories__/DatetimePicker.stories.js +71 -0
- package/src/datetimePicker/__stories__/DatetimePickerV2.stories.js +91 -0
- package/src/datetimePicker/__stories__/TimeInput.stories.js +67 -0
- package/src/datetimePicker/__stories__/TimePicker.stories.js +29 -0
- package/src/datetimePicker/__test__/CustomTimeInput.test.js +25 -0
- package/src/datetimePicker/__test__/DatetimePicker.test.js +121 -0
- package/src/datetimePicker/__test__/TimeInput.test.js +22 -0
- package/src/datetimePicker/accordion/Month.js +258 -0
- package/src/datetimePicker/accordion/Year.js +307 -0
- package/src/datetimePicker/hooks/index.js +3 -0
- package/src/datetimePicker/hooks/useChangeNumber.js +42 -0
- package/src/datetimePicker/hooks/useDecrease.js +31 -0
- package/src/datetimePicker/hooks/useIncrease.js +31 -0
- package/src/datetimePicker/index.js +7 -0
- package/src/datetimePicker/provider/constant.js +16 -0
- package/src/datetimePicker/subComponent/Accordion.js +407 -0
- package/src/datetimePicker/subComponent/CustomTimeInput.js +48 -0
- package/src/datetimePicker/subComponent/DateTimePickerContext.js +5 -0
- package/src/datetimePicker/utils/GMTDate.js +13 -0
- package/src/datetimePicker/utils/pad.js +9 -0
- package/src/datetimePicker/utils/toUTC0.js +10 -0
- package/src/descriptionList/DescriptionDetail.js +18 -0
- package/src/descriptionList/DescriptionList.js +15 -0
- package/src/descriptionList/DescriptionTerm.js +9 -0
- package/src/descriptionList/__stories__/DescriptionDetail.stories.js +39 -0
- package/src/descriptionList/__stories__/DescriptionList.stories.js +39 -0
- package/src/descriptionList/__stories__/DescriptionTerm.stories.js +13 -0
- package/src/descriptionList/__test__/DescriptionDetail.test.js +13 -0
- package/src/descriptionList/__test__/DescriptionList.test.js +12 -0
- package/src/descriptionList/__test__/DescriptionTerm.test.js +7 -0
- package/src/descriptionList/index.js +3 -0
- package/src/divider/Divider.js +21 -0
- package/src/divider/__stories__/Divider.stories.js +23 -0
- package/src/divider/__test__/Divider.test.js +24 -0
- package/src/divider/index.js +1 -0
- package/src/dropdown/Dropdown.js +50 -0
- package/src/dropdown/DropdownButtonOption.js +25 -0
- package/src/dropdown/DropdownContent.js +78 -0
- package/src/dropdown/DropdownDivOption.js +21 -0
- package/src/dropdown/DropdownItem.js +17 -0
- package/src/dropdown/DropdownLinkOption.js +19 -0
- package/src/dropdown/DropdownToggle.js +26 -0
- package/src/dropdown/__stories__/Dropdown.stories.js +46 -0
- package/src/dropdown/__stories__/DropdownButtonOption.stories.js +33 -0
- package/src/dropdown/__stories__/DropdownContent.stories.js +34 -0
- package/src/dropdown/__stories__/DropdownDivOption.stories.js +27 -0
- package/src/dropdown/__stories__/DropdownItem.stories.js +48 -0
- package/src/dropdown/__stories__/DropdownLinkOption.stories.js +63 -0
- package/src/dropdown/__stories__/DropdownToggle.stories.js +40 -0
- package/src/dropdown/__test__/Dropdown.test.js +132 -0
- package/src/dropdown/__test__/DropdownButtonOption.test.js +8 -0
- package/src/dropdown/__test__/DropdownContent.test.js +85 -0
- package/src/dropdown/__test__/DropdownDivOption.test.js +8 -0
- package/src/dropdown/__test__/DropdownItem.test.js +55 -0
- package/src/dropdown/__test__/DropdownLinkOption.test.js +14 -0
- package/src/dropdown/__test__/DropdownToggle.test.js +53 -0
- package/src/dropdown/index.js +12 -0
- package/src/dropdown/subComponent/DropdownContext.js +5 -0
- package/src/dropzone/FileDropzone.js +543 -0
- package/src/dropzone/ImageDropzone.js +365 -0
- package/src/dropzone/__stories__/FileDropzone.stories.js +148 -0
- package/src/dropzone/__stories__/ImageDropzone.stories.js +101 -0
- package/src/dropzone/__test__/FileDropzone.test.js +382 -0
- package/src/dropzone/__test__/ImageDropzone.test.js +290 -0
- package/src/dropzone/__test__/Message.test.js +14 -0
- package/src/dropzone/index.js +2 -0
- package/src/dropzone/subComponent/Message.js +16 -0
- package/src/figure/IconFigure.js +31 -0
- package/src/figure/ImageFigure.js +25 -0
- package/src/figure/__stories__/IconFigure.stories.js +25 -0
- package/src/figure/__stories__/ImageFigure.stories.js +26 -0
- package/src/figure/__test__/IconFigure.test.js +28 -0
- package/src/figure/__test__/ImageFigure.test.js +38 -0
- package/src/figure/index.js +2 -0
- package/src/file/HiddenFileInput.js +10 -0
- package/src/file/index.js +1 -0
- package/src/form/Checkbox.js +127 -0
- package/src/form/FormItem.js +7 -0
- package/src/form/Input.js +42 -0
- package/src/form/Label.js +33 -0
- package/src/form/MutedText.js +11 -0
- package/src/form/RadioButton.js +80 -0
- package/src/form/Searchbox.js +95 -0
- package/src/form/Slider.js +34 -0
- package/src/form/SwitchButton.js +86 -0
- package/src/form/Textarea.js +36 -0
- package/src/form/TreeView.js +77 -0
- package/src/form/__stories__/Checkbox.stories.js +63 -0
- package/src/form/__stories__/FormItem.stories.js +28 -0
- package/src/form/__stories__/Input.stories.js +30 -0
- package/src/form/__stories__/Label.stories.js +38 -0
- package/src/form/__stories__/MutedText.stories.js +27 -0
- package/src/form/__stories__/RadioButton.stories.js +48 -0
- package/src/form/__stories__/Searchbox.stories.js +24 -0
- package/src/form/__stories__/Slider.stories.js +46 -0
- package/src/form/__stories__/SwitchButton.stories.js +48 -0
- package/src/form/__stories__/Textarea.stories.js +19 -0
- package/src/form/__stories__/TreeView.stories.js +76 -0
- package/src/form/__test__/Checkbox.test.js +68 -0
- package/src/form/__test__/FormItem.test.js +8 -0
- package/src/form/__test__/Input.test.js +28 -0
- package/src/form/__test__/Label.test.js +33 -0
- package/src/form/__test__/MutedText.test.js +18 -0
- package/src/form/__test__/RadioButton.test.js +57 -0
- package/src/form/__test__/Searchbox.test.js +50 -0
- package/src/form/__test__/Textarea.test.js +25 -0
- package/src/form/index.js +11 -0
- package/src/grid/Column.js +36 -0
- package/src/grid/Grid.js +15 -0
- package/src/grid/__stories__/Grid.stories.js +38 -0
- package/src/grid/__test__/Grid.test.js +44 -0
- package/src/grid/index.js +2 -0
- package/src/heading/Heading1.js +11 -0
- package/src/heading/Heading2.js +13 -0
- package/src/heading/Heading3.js +21 -0
- package/src/heading/__stories__/Heading1.stories.js +24 -0
- package/src/heading/__stories__/Heading2.stories.js +24 -0
- package/src/heading/__stories__/Heading3.stories.js +24 -0
- package/src/heading/__test__/Heading1.test.js +21 -0
- package/src/heading/__test__/Heading2.test.js +34 -0
- package/src/heading/__test__/Heading3.test.js +46 -0
- package/src/heading/index.js +3 -0
- package/src/helmet/Helmet.js +12 -0
- package/src/helmet/__test__/Helmet.test.js +38 -0
- package/src/helmet/index.js +2 -0
- package/src/iconbox/ApplicationIconBox.js +62 -0
- package/src/iconbox/IconBox.js +54 -0
- package/src/iconbox/IconBoxV2.js +49 -0
- package/src/iconbox/__stories__/ApplicationIconBox.stories.js +53 -0
- package/src/iconbox/__stories__/IconBox.stories.js +34 -0
- package/src/iconbox/__stories__/IconBoxFigure.stories.js +67 -0
- package/src/iconbox/__stories__/IconBoxFigure.stories_V2.stories.js +41 -0
- package/src/iconbox/__stories__/IconBoxImage.stories.js +32 -0
- package/src/iconbox/__stories__/IconBoxV2.stories.js +60 -0
- package/src/iconbox/__test__/ApplicationIconBox.test.js +77 -0
- package/src/iconbox/__test__/IconBox.test.js +22 -0
- package/src/iconbox/__test__/IconBoxFigure.test.js +37 -0
- package/src/iconbox/__test__/IconBoxImage.test.js +32 -0
- package/src/iconbox/__test__/IconBoxV2.test.js +51 -0
- package/src/iconbox/index.js +3 -0
- package/src/iconbox/subComponent/IconBoxFigure.js +16 -0
- package/src/iconbox/subComponent/IconBoxImage.js +26 -0
- package/src/image/ImageFluid.js +12 -0
- package/src/image/UploadImage.js +287 -0
- package/src/image/__stories__/ImageFluid.stories.js +25 -0
- package/src/image/__stories__/UploadImage.stories.js +56 -0
- package/src/image/__test__/ImageFluid.test.js +44 -0
- package/src/image/__test__/UploadImage.test.js +315 -0
- package/src/image/index.js +2 -0
- package/src/index.js +42 -0
- package/src/jsoneditor/JsonEditor.js +132 -0
- package/src/jsoneditor/__stories__/JsonEditor.stories.js +55 -0
- package/src/jsoneditor/__test__/JsonEditor.test.js +52 -0
- package/src/jsoneditor/index.js +1 -0
- package/src/keyframe/Pulse.js +17 -0
- package/src/keyframe/Spin.js +9 -0
- package/src/link/LinkSpan.js +44 -0
- package/src/link/__stories__/LinkSpan.stories.js +27 -0
- package/src/link/__test__/LinkSpan.test.js +52 -0
- package/src/link/index.js +1 -0
- package/src/map/GoogleMap.js +383 -0
- package/src/map/GoogleReverseGeolocation.js +197 -0
- package/src/map/LeafletMap.js +264 -0
- package/src/map/LeafletReverseGeolocation.js +89 -0
- package/src/map/__stories__/GoogleMap.stories.js +137 -0
- package/src/map/__stories__/GoogleReverseGeolocation.stories.js +95 -0
- package/src/map/__stories__/LeafletMap.stories.js +136 -0
- package/src/map/__stories__/LeafletReverseGeolocation.stories.js +91 -0
- package/src/map/__test__/LeafletReverseGeolocation.test.js +245 -0
- package/src/map/__test__/MapSearchBoxControl.test.js +89 -0
- package/src/map/index.js +4 -0
- package/src/map/subComponent/BasicLeafletMap.js +33 -0
- package/src/map/subComponent/GoogleMapContainer.js +19 -0
- package/src/map/subComponent/GoogleMapPopup.js +115 -0
- package/src/map/subComponent/GoogleMapWrapper.js +27 -0
- package/src/map/subComponent/GoogleMarkerSpiderfier.js +13 -0
- package/src/map/subComponent/LeafletDrawControl.js +133 -0
- package/src/map/subComponent/LeafletMapContainer.js +163 -0
- package/src/map/subComponent/MapSearchBoxControl.js +43 -0
- package/src/modal/StateModal.js +139 -0
- package/src/modal/TitleModal.js +229 -0
- package/src/modal/__stories__/StateModal.stories.js +46 -0
- package/src/modal/__stories__/TitleModal.stories.js +56 -0
- package/src/modal/__test__/StateModal.test.js +144 -0
- package/src/modal/index.js +2 -0
- package/src/paginate/Paginate.js +132 -0
- package/src/paginate/__stories__/Paginate.stories.js +49 -0
- package/src/paginate/__test__/Paginate.test.js +124 -0
- package/src/paginate/index.js +1 -0
- package/src/popover/Popover.js +82 -0
- package/src/popover/__stories__/Popover.stories.js +44 -0
- package/src/popover/index.js +1 -0
- package/src/qrcode/QRCode.js +54 -0
- package/src/qrcode/QRCodeContainter.js +25 -0
- package/src/qrcode/__stories__/QRCode.stories.js +36 -0
- package/src/qrcode/__stories__/QRCodeContainter.stories.js +28 -0
- package/src/qrcode/index.js +2 -0
- package/src/ribbon/Ribbon.js +38 -0
- package/src/ribbon/__stories__/Ribbon.stories.js +25 -0
- package/src/ribbon/index.js +1 -0
- package/src/section/Section.js +66 -0
- package/src/section/SectionBody.js +34 -0
- package/src/section/SectionHeader.js +41 -0
- package/src/section/SectionToolbar.js +13 -0
- package/src/section/SectionToolbarItem.js +12 -0
- package/src/section/__stories__/Section.stories.js +52 -0
- package/src/section/__stories__/SectionBody.stories.js +40 -0
- package/src/section/__stories__/SectionHeader.stories.js +67 -0
- package/src/section/__stories__/SectionToolbar.stories.js +43 -0
- package/src/section/__test__/Section.test.js +98 -0
- package/src/section/__test__/SectionBody.test.js +89 -0
- package/src/section/__test__/SectionHeader.test.js +35 -0
- package/src/section/__test__/SectionToolbar.test.js +17 -0
- package/src/section/index.js +5 -0
- package/src/select/InputSelect.js +314 -0
- package/src/select/Select.js +764 -0
- package/src/select/__stories__/InputSelect.stories.js +60 -0
- package/src/select/__stories__/Select.stories.js +132 -0
- package/src/select/__test__/Select.test.js +219 -0
- package/src/select/index.js +2 -0
- package/src/select/subComponent/ListBox.js +15 -0
- package/src/select/subComponent/Option.js +22 -0
- package/src/select/subComponent/OptionGroup.js +18 -0
- package/src/select/subComponent/Options.js +24 -0
- package/src/select/subComponent/SearchBox.js +53 -0
- package/src/select/subComponent/SelectedMultiple.js +39 -0
- package/src/select/subComponent/SelectedSingle.js +10 -0
- package/src/styles/GlobalStyle.js +59 -0
- package/src/styles/config/breakpoint.style.js +8 -0
- package/src/styles/config/header.style.js +5 -0
- package/src/styles/config/sidebar.style.js +12 -0
- package/src/styles/index.js +2 -0
- package/src/styles/mixin/backgroundColor.js +13 -0
- package/src/styles/mixin/borderColor.js +13 -0
- package/src/styles/mixin/color.js +13 -0
- package/src/styles/mixin/colorOnBackground.js +13 -0
- package/src/styles/mixin/inputPlaceholder.js +26 -0
- package/src/styles/mixin/media.js +14 -0
- package/src/styles/mixin/rounded.js +12 -0
- package/src/styles/mixin/scrollbar.js +26 -0
- package/src/styles/theme/dark.theme.js +95 -0
- package/src/styles/theme/light.theme.js +95 -0
- package/src/styles/theme/white.theme.js +95 -0
- package/src/styles/themes.js +11 -0
- package/src/table/GridTable.js +325 -0
- package/src/table/ImageBox.js +37 -0
- package/src/table/PermissionTable.js +36 -0
- package/src/table/Table.js +441 -0
- package/src/table/__mock__/columns.js +28 -0
- package/src/table/__mock__/data.js +334 -0
- package/src/table/__stories__/GridTable.stories.js +129 -0
- package/src/table/__stories__/ImageBox.stories.js +27 -0
- package/src/table/__stories__/PermissionTable.stories.js +52 -0
- package/src/table/__stories__/Table.stories.js +138 -0
- package/src/table/hooks/index.js +2 -0
- package/src/table/hooks/useCalculateDataRange.js +26 -0
- package/src/table/hooks/useGenerateSort.js +37 -0
- package/src/table/index.js +4 -0
- package/src/table/subComponent/BaseTableHeadCell.js +48 -0
- package/src/table/subComponent/GridTableFooter.js +18 -0
- package/src/table/subComponent/GridTableHeadCell.js +14 -0
- package/src/table/subComponent/Resizer.js +79 -0
- package/src/table/subComponent/TableFooter.js +16 -0
- package/src/table/subComponent/TableFooterInfo.js +8 -0
- package/src/table/subComponent/TableFooterPager.js +26 -0
- package/src/table/subComponent/TableHeadCell.js +14 -0
- package/src/table/subComponent/TableSort.js +25 -0
- package/src/tagify/TagifyStyle.js +35 -0
- package/src/tagify/Tags.js +46 -0
- package/src/tagify/__stories__/Tags.stories.js +28 -0
- package/src/tagify/index.js +2 -0
- package/src/text/Paragraph.js +34 -0
- package/src/text/__stories__/Paragraph.stories.js +40 -0
- package/src/text/index.js +1 -0
- package/src/timeline/Timeline.js +98 -0
- package/src/timeline/__stories__/Timeline.stories.js +49 -0
- package/src/timeline/index.js +1 -0
- package/src/toast/CustomToastContainer.js +30 -0
- package/src/toast/MessageContainer.js +40 -0
- package/src/toast/__stories__/MessageContainer.stories.js +35 -0
- package/src/toast/index.js +3 -0
- package/src/toast/show.js +34 -0
- package/src/toast/style.css +1 -0
- package/src/tooltip/Tooltip.js +146 -0
- package/src/tooltip/__stories__/Tooltip.stories.js +49 -0
- package/src/tooltip/__test__/tooltip.test.js +130 -0
- package/src/tooltip/index.js +1 -0
- package/src/wizard/Wizard.js +276 -0
- package/src/wizard/__stories__/Wizard.stories.js +81 -0
- package/src/wizard/__test__/Wizard.test.js +173 -0
- package/src/wizard/index.js +1 -0
- package/transformer/fileTransformer.js +9 -0
- /package/{Tab → dist/Tab}/Tab.js +0 -0
- /package/{Tab → dist/Tab}/TabList.js +0 -0
- /package/{Tab → dist/Tab}/TabPanel.js +0 -0
- /package/{Tab → dist/Tab}/TabTab.js +0 -0
- /package/{Tab → dist/Tab}/index.js +0 -0
- /package/{Tab → dist/Tab}/subComponent/TabContext.js +0 -0
- /package/{animate → dist/animate}/Collapse.js +0 -0
- /package/{animate → dist/animate}/Loader.js +0 -0
- /package/{animate → dist/animate}/NumberCounter.js +0 -0
- /package/{animate → dist/animate}/PulseRing.js +0 -0
- /package/{animate → dist/animate}/Spinner.js +0 -0
- /package/{animate → dist/animate}/index.js +0 -0
- /package/{assets → dist/assets}/css/autocomplete.css +0 -0
- /package/{assets → dist/assets}/css/font.css +0 -0
- /package/{assets → dist/assets}/css/global.css +0 -0
- /package/{assets → dist/assets}/css/normalize.css +0 -0
- /package/{assets → dist/assets}/font/helvetica/Helvetica.ttf +0 -0
- /package/{assets → dist/assets}/font/nanumGothic/NanumGothic-Bold.ttf +0 -0
- /package/{assets → dist/assets}/font/nanumGothic/NanumGothic-ExtraBold.ttf +0 -0
- /package/{assets → dist/assets}/font/nanumGothic/NanumGothic-Regular.ttf +0 -0
- /package/{assets → dist/assets}/icons/app-management.png +0 -0
- /package/{assets → dist/assets}/icons/burger.png +0 -0
- /package/{assets → dist/assets}/icons/file.svg +0 -0
- /package/{assets → dist/assets}/icons/map_icon1.png +0 -0
- /package/{assets → dist/assets}/icons/map_icon4.png +0 -0
- /package/{assets → dist/assets}/images/bg-chart-circle.png +0 -0
- /package/{assets → dist/assets}/images/bg-chart-triangle.png +0 -0
- /package/{assets → dist/assets}/images/cashub-logo-only.png +0 -0
- /package/{assets → dist/assets}/images/default-user.jpg +0 -0
- /package/{assets → dist/assets}/images/logo-cashub.png +0 -0
- /package/{assets → dist/assets}/images/map.png +0 -0
- /package/{assets → dist/assets}/images/qrcode.png +0 -0
- /package/{backdrop → dist/backdrop}/BaseBackdrop.js +0 -0
- /package/{backdrop → dist/backdrop}/LoadingBackdrop.js +0 -0
- /package/{backdrop → dist/backdrop}/ModalBackdrop.js +0 -0
- /package/{backdrop → dist/backdrop}/index.js +0 -0
- /package/{badge → dist/badge}/Badge.js +0 -0
- /package/{badge → dist/badge}/BadgeDot.js +0 -0
- /package/{badge → dist/badge}/BadgeFill.js +0 -0
- /package/{badge → dist/badge}/BadgeWithText.js +0 -0
- /package/{badge → dist/badge}/index.js +0 -0
- /package/{billing → dist/billing}/BarChart.js +0 -0
- /package/{billing → dist/billing}/Grid.js +0 -0
- /package/{billing → dist/billing}/Header2.js +0 -0
- /package/{billing → dist/billing}/Header3.js +0 -0
- /package/{billing → dist/billing}/Paragraph.js +0 -0
- /package/{billing → dist/billing}/ParagraphGroup.js +0 -0
- /package/{billing → dist/billing}/ParagraphText.js +0 -0
- /package/{billing → dist/billing}/Section.js +0 -0
- /package/{billing → dist/billing}/SectionBody.js +0 -0
- /package/{billing → dist/billing}/SectionHeader.js +0 -0
- /package/{billing → dist/billing}/__stories__/BarChart.stories.js_bak +0 -0
- /package/{billing → dist/billing}/__stories__/Grid.stories.js_bak +0 -0
- /package/{billing → dist/billing}/__stories__/Header2.stories.js_bak +0 -0
- /package/{billing → dist/billing}/__stories__/Header3.stories.js_bak +0 -0
- /package/{billing → dist/billing}/__stories__/Paragraph.stories.js_bak +0 -0
- /package/{billing → dist/billing}/__stories__/ParagraphGroup.stories.js_bak +0 -0
- /package/{billing → dist/billing}/__stories__/ParagraphText.stories.js_bak +0 -0
- /package/{billing → dist/billing}/__stories__/Section.stories.js_bak +0 -0
- /package/{billing → dist/billing}/__stories__/SectionBody.stories.js_bak +0 -0
- /package/{billing → dist/billing}/__stories__/SectionHeader.stories.js-bak +0 -0
- /package/{breadcrumb → dist/breadcrumb}/Breadcrumb.js +0 -0
- /package/{breadcrumb → dist/breadcrumb}/index.js +0 -0
- /package/{button → dist/button}/Button.js +0 -0
- /package/{button → dist/button}/ButtonGroup.js +0 -0
- /package/{button → dist/button}/IconButton.js +0 -0
- /package/{button → dist/button}/ScrollToTopButton.js +0 -0
- /package/{button → dist/button}/index.js +0 -0
- /package/{callout → dist/callout}/Callout.js +0 -0
- /package/{callout → dist/callout}/index.js +0 -0
- /package/{chart → dist/chart}/BarChart.js +0 -0
- /package/{chart → dist/chart}/DoughnutChart.js +0 -0
- /package/{chart → dist/chart}/LineChart.js +0 -0
- /package/{chart → dist/chart}/SingleBarChart.js +0 -0
- /package/{chart → dist/chart}/index.js +0 -0
- /package/{chart → dist/chart}/utils/customTooltip.js +0 -0
- /package/{chart → dist/chart}/utils/htmlLegendPlugin.js +0 -0
- /package/{chart → dist/chart}/utils/index.js +0 -0
- /package/{chart → dist/chart}/utils/padEmptyChartBar.js +0 -0
- /package/{container → dist/container}/FlexContainer.js +0 -0
- /package/{container → dist/container}/index.js +0 -0
- /package/{cropper → dist/cropper}/Cropper.js +0 -0
- /package/{cropper → dist/cropper}/CropperModalHandler.js +0 -0
- /package/{cropper → dist/cropper}/index.js +0 -0
- /package/{cropper → dist/cropper}/subComponent/CropImageModal.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/DatePicker.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/DatePickerV2.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/DatetimePicker.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/DatetimePickerV2.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/TimeInput.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/TimePicker.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/TimePickerStyle.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/accordion/Month.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/accordion/Year.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/hooks/index.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/hooks/useChangeNumber.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/hooks/useDecrease.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/hooks/useIncrease.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/index.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/provider/constant.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/subComponent/Accordion.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/subComponent/CustomTimeInput.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/subComponent/DateTimePickerContext.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/utils/GMTDate.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/utils/pad.js +0 -0
- /package/{datetimePicker → dist/datetimePicker}/utils/toUTC0.js +0 -0
- /package/{descriptionList → dist/descriptionList}/DescriptionDetail.js +0 -0
- /package/{descriptionList → dist/descriptionList}/DescriptionList.js +0 -0
- /package/{descriptionList → dist/descriptionList}/DescriptionTerm.js +0 -0
- /package/{descriptionList → dist/descriptionList}/index.js +0 -0
- /package/{divider → dist/divider}/Divider.js +0 -0
- /package/{divider → dist/divider}/index.js +0 -0
- /package/{dropdown → dist/dropdown}/Dropdown.js +0 -0
- /package/{dropdown → dist/dropdown}/DropdownButtonOption.js +0 -0
- /package/{dropdown → dist/dropdown}/DropdownContent.js +0 -0
- /package/{dropdown → dist/dropdown}/DropdownDivOption.js +0 -0
- /package/{dropdown → dist/dropdown}/DropdownItem.js +0 -0
- /package/{dropdown → dist/dropdown}/DropdownLinkOption.js +0 -0
- /package/{dropdown → dist/dropdown}/DropdownToggle.js +0 -0
- /package/{dropdown → dist/dropdown}/index.js +0 -0
- /package/{dropdown → dist/dropdown}/subComponent/DropdownContext.js +0 -0
- /package/{dropzone → dist/dropzone}/FileDropzone.js +0 -0
- /package/{dropzone → dist/dropzone}/ImageDropzone.js +0 -0
- /package/{dropzone → dist/dropzone}/index.js +0 -0
- /package/{dropzone → dist/dropzone}/subComponent/Message.js +0 -0
- /package/{figure → dist/figure}/IconFigure.js +0 -0
- /package/{figure → dist/figure}/ImageFigure.js +0 -0
- /package/{figure → dist/figure}/index.js +0 -0
- /package/{file → dist/file}/HiddenFileInput.js +0 -0
- /package/{file → dist/file}/index.js +0 -0
- /package/{form → dist/form}/Checkbox.js +0 -0
- /package/{form → dist/form}/FormItem.js +0 -0
- /package/{form → dist/form}/Input.js +0 -0
- /package/{form → dist/form}/Label.js +0 -0
- /package/{form → dist/form}/MutedText.js +0 -0
- /package/{form → dist/form}/RadioButton.js +0 -0
- /package/{form → dist/form}/Searchbox.js +0 -0
- /package/{form → dist/form}/Slider.js +0 -0
- /package/{form → dist/form}/SwitchButton.js +0 -0
- /package/{form → dist/form}/Textarea.js +0 -0
- /package/{form → dist/form}/TreeView.js +0 -0
- /package/{form → dist/form}/index.js +0 -0
- /package/{grid → dist/grid}/Column.js +0 -0
- /package/{grid → dist/grid}/Grid.js +0 -0
- /package/{grid → dist/grid}/index.js +0 -0
- /package/{heading → dist/heading}/Heading1.js +0 -0
- /package/{heading → dist/heading}/Heading2.js +0 -0
- /package/{heading → dist/heading}/Heading3.js +0 -0
- /package/{heading → dist/heading}/index.js +0 -0
- /package/{helmet → dist/helmet}/Helmet.js +0 -0
- /package/{helmet → dist/helmet}/index.js +0 -0
- /package/{iconbox → dist/iconbox}/ApplicationIconBox.js +0 -0
- /package/{iconbox → dist/iconbox}/IconBox.js +0 -0
- /package/{iconbox → dist/iconbox}/IconBoxV2.js +0 -0
- /package/{iconbox → dist/iconbox}/index.js +0 -0
- /package/{iconbox → dist/iconbox}/subComponent/IconBoxFigure.js +0 -0
- /package/{iconbox → dist/iconbox}/subComponent/IconBoxImage.js +0 -0
- /package/{image → dist/image}/ImageFluid.js +0 -0
- /package/{image → dist/image}/UploadImage.js +0 -0
- /package/{image → dist/image}/index.js +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{jsoneditor → dist/jsoneditor}/JsonEditor.js +0 -0
- /package/{jsoneditor → dist/jsoneditor}/index.js +0 -0
- /package/{keyframe → dist/keyframe}/Pulse.js +0 -0
- /package/{keyframe → dist/keyframe}/Spin.js +0 -0
- /package/{link → dist/link}/LinkSpan.js +0 -0
- /package/{link → dist/link}/index.js +0 -0
- /package/{map → dist/map}/GoogleMap.js +0 -0
- /package/{map → dist/map}/GoogleReverseGeolocation.js +0 -0
- /package/{map → dist/map}/LeafletMap.js +0 -0
- /package/{map → dist/map}/LeafletReverseGeolocation.js +0 -0
- /package/{map → dist/map}/index.js +0 -0
- /package/{map → dist/map}/subComponent/BasicLeafletMap.js +0 -0
- /package/{map → dist/map}/subComponent/GoogleMapContainer.js +0 -0
- /package/{map → dist/map}/subComponent/GoogleMapPopup.js +0 -0
- /package/{map → dist/map}/subComponent/GoogleMapWrapper.js +0 -0
- /package/{map → dist/map}/subComponent/GoogleMarkerSpiderfier.js +0 -0
- /package/{map → dist/map}/subComponent/LeafletDrawControl.js +0 -0
- /package/{map → dist/map}/subComponent/LeafletMapContainer.js +0 -0
- /package/{map → dist/map}/subComponent/MapSearchBoxControl.js +0 -0
- /package/{modal → dist/modal}/StateModal.js +0 -0
- /package/{modal → dist/modal}/TitleModal.js +0 -0
- /package/{modal → dist/modal}/index.js +0 -0
- /package/{paginate → dist/paginate}/Paginate.js +0 -0
- /package/{paginate → dist/paginate}/index.js +0 -0
- /package/{popover → dist/popover}/Popover.js +0 -0
- /package/{popover → dist/popover}/index.js +0 -0
- /package/{qrcode → dist/qrcode}/QRCode.js +0 -0
- /package/{qrcode → dist/qrcode}/QRCodeContainter.js +0 -0
- /package/{qrcode → dist/qrcode}/index.js +0 -0
- /package/{ribbon → dist/ribbon}/Ribbon.js +0 -0
- /package/{ribbon → dist/ribbon}/index.js +0 -0
- /package/{section → dist/section}/Section.js +0 -0
- /package/{section → dist/section}/SectionBody.js +0 -0
- /package/{section → dist/section}/SectionHeader.js +0 -0
- /package/{section → dist/section}/SectionToolbar.js +0 -0
- /package/{section → dist/section}/SectionToolbarItem.js +0 -0
- /package/{section → dist/section}/index.js +0 -0
- /package/{select → dist/select}/InputSelect.js +0 -0
- /package/{select → dist/select}/Select.js +0 -0
- /package/{select → dist/select}/index.js +0 -0
- /package/{select → dist/select}/subComponent/ListBox.js +0 -0
- /package/{select → dist/select}/subComponent/Option.js +0 -0
- /package/{select → dist/select}/subComponent/OptionGroup.js +0 -0
- /package/{select → dist/select}/subComponent/Options.js +0 -0
- /package/{select → dist/select}/subComponent/SearchBox.js +0 -0
- /package/{select → dist/select}/subComponent/SelectedMultiple.js +0 -0
- /package/{select → dist/select}/subComponent/SelectedSingle.js +0 -0
- /package/{styles → dist/styles}/GlobalStyle.js +0 -0
- /package/{styles → dist/styles}/config/breakpoint.style.js +0 -0
- /package/{styles → dist/styles}/config/header.style.js +0 -0
- /package/{styles → dist/styles}/config/sidebar.style.js +0 -0
- /package/{styles → dist/styles}/index.js +0 -0
- /package/{styles → dist/styles}/mixin/backgroundColor.js +0 -0
- /package/{styles → dist/styles}/mixin/borderColor.js +0 -0
- /package/{styles → dist/styles}/mixin/color.js +0 -0
- /package/{styles → dist/styles}/mixin/colorOnBackground.js +0 -0
- /package/{styles → dist/styles}/mixin/inputPlaceholder.js +0 -0
- /package/{styles → dist/styles}/mixin/media.js +0 -0
- /package/{styles → dist/styles}/mixin/rounded.js +0 -0
- /package/{styles → dist/styles}/mixin/scrollbar.js +0 -0
- /package/{styles → dist/styles}/theme/dark.theme.js +0 -0
- /package/{styles → dist/styles}/theme/light.theme.js +0 -0
- /package/{styles → dist/styles}/theme/white.theme.js +0 -0
- /package/{styles → dist/styles}/themes.js +0 -0
- /package/{table → dist/table}/GridTable.js +0 -0
- /package/{table → dist/table}/ImageBox.js +0 -0
- /package/{table → dist/table}/PermissionTable.js +0 -0
- /package/{table → dist/table}/__mock__/columns.js +0 -0
- /package/{table → dist/table}/__mock__/data.js +0 -0
- /package/{table → dist/table}/hooks/index.js +0 -0
- /package/{table → dist/table}/hooks/useCalculateDataRange.js +0 -0
- /package/{table → dist/table}/hooks/useGenerateSort.js +0 -0
- /package/{table → dist/table}/index.js +0 -0
- /package/{table → dist/table}/subComponent/BaseTableHeadCell.js +0 -0
- /package/{table → dist/table}/subComponent/GridTableFooter.js +0 -0
- /package/{table → dist/table}/subComponent/GridTableHeadCell.js +0 -0
- /package/{table → dist/table}/subComponent/Resizer.js +0 -0
- /package/{table → dist/table}/subComponent/TableFooter.js +0 -0
- /package/{table → dist/table}/subComponent/TableFooterInfo.js +0 -0
- /package/{table → dist/table}/subComponent/TableFooterPager.js +0 -0
- /package/{table → dist/table}/subComponent/TableHeadCell.js +0 -0
- /package/{table → dist/table}/subComponent/TableSort.js +0 -0
- /package/{tagify → dist/tagify}/TagifyStyle.js +0 -0
- /package/{tagify → dist/tagify}/Tags.js +0 -0
- /package/{tagify → dist/tagify}/index.js +0 -0
- /package/{text → dist/text}/Paragraph.js +0 -0
- /package/{text → dist/text}/index.js +0 -0
- /package/{timeline → dist/timeline}/Timeline.js +0 -0
- /package/{timeline → dist/timeline}/index.js +0 -0
- /package/{toast → dist/toast}/CustomToastContainer.js +0 -0
- /package/{toast → dist/toast}/MessageContainer.js +0 -0
- /package/{toast → dist/toast}/index.js +0 -0
- /package/{toast → dist/toast}/show.js +0 -0
- /package/{toast → dist/toast}/style.css +0 -0
- /package/{tooltip → dist/tooltip}/Tooltip.js +0 -0
- /package/{tooltip → dist/tooltip}/index.js +0 -0
- /package/{wizard → dist/wizard}/Wizard.js +0 -0
- /package/{wizard → dist/wizard}/index.js +0 -0
|
@@ -0,0 +1,764 @@
|
|
|
1
|
+
import { useState, useEffect, useMemo, useCallback, useRef } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import OutsideClickHandler from 'react-outside-click-handler';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import uniqueId from 'lodash.uniqueid';
|
|
6
|
+
import { TiArrowSortedDown } from 'react-icons/ti';
|
|
7
|
+
import { MdClose } from 'react-icons/md';
|
|
8
|
+
import { useCustomPopper } from '@cashub/hooks';
|
|
9
|
+
import { KEY_CODE } from '@cashub/utils';
|
|
10
|
+
import media from '../styles/mixin/media';
|
|
11
|
+
import SelectedSingle from './subComponent/SelectedSingle';
|
|
12
|
+
import SelectedMultiple from './subComponent/SelectedMultiple';
|
|
13
|
+
import ListBox from './subComponent/ListBox';
|
|
14
|
+
import SearchBox from './subComponent/SearchBox';
|
|
15
|
+
import Options from './subComponent/Options';
|
|
16
|
+
import OptionGroup from './subComponent/OptionGroup';
|
|
17
|
+
import Option from './subComponent/Option';
|
|
18
|
+
|
|
19
|
+
const Select = ({
|
|
20
|
+
options,
|
|
21
|
+
enableSelectAll = false,
|
|
22
|
+
selected,
|
|
23
|
+
onSelect,
|
|
24
|
+
onDeselect,
|
|
25
|
+
multiple = false,
|
|
26
|
+
allowClear = false,
|
|
27
|
+
allowSearch = true,
|
|
28
|
+
disabled,
|
|
29
|
+
placeholder = '',
|
|
30
|
+
fullWidth,
|
|
31
|
+
large,
|
|
32
|
+
fill,
|
|
33
|
+
fillReverse,
|
|
34
|
+
onBlur,
|
|
35
|
+
onSearch,
|
|
36
|
+
}) => {
|
|
37
|
+
const { t } = useTranslation();
|
|
38
|
+
const [id] = useState(uniqueId('select-'));
|
|
39
|
+
const [allOptionId] = useState(uniqueId('allOptons-'));
|
|
40
|
+
const [display, setDisplay] = useState(false);
|
|
41
|
+
const [comboboxElement, setComboboxElement] = useState(null);
|
|
42
|
+
const [listBoxElement, setListBoxElement] = useState(null);
|
|
43
|
+
const optionsElementRef = useRef(null);
|
|
44
|
+
const searchBoxElement = useRef(null);
|
|
45
|
+
const [listBoxWidth, setListBoxWidth] = useState(0);
|
|
46
|
+
const [optionList, setOptionList] = useState([]);
|
|
47
|
+
const [focusedOption, setFocusedOption] = useState(null);
|
|
48
|
+
const [isFocusCombobox, setIsFocusCombobox] = useState(false);
|
|
49
|
+
const [selectedOptions, setSelectedOptions] = useState([]);
|
|
50
|
+
const [filteredOptions, setFilteredOptions] = useState(options);
|
|
51
|
+
const [search, setSearch] = useState('');
|
|
52
|
+
|
|
53
|
+
const { styles, attributes, state, update } = useCustomPopper(
|
|
54
|
+
comboboxElement,
|
|
55
|
+
listBoxElement,
|
|
56
|
+
);
|
|
57
|
+
const newOptions = useMemo(() => {
|
|
58
|
+
if (!options) return;
|
|
59
|
+
const newOptions = [...options];
|
|
60
|
+
if (options.length > 0 && multiple && enableSelectAll) {
|
|
61
|
+
newOptions.unshift({ id: allOptionId, text: t('All') });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return newOptions;
|
|
65
|
+
}, [options, multiple, enableSelectAll, allOptionId]);
|
|
66
|
+
|
|
67
|
+
// parse all value to string
|
|
68
|
+
// for subsequently determine whether it is a selected item
|
|
69
|
+
const parsedSelected = useMemo(() => {
|
|
70
|
+
if (selected || selected === 0) {
|
|
71
|
+
// multiple value
|
|
72
|
+
if (Array.isArray(selected)) {
|
|
73
|
+
return selected.map((value) => value.toString());
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// single value
|
|
77
|
+
return selected.toString();
|
|
78
|
+
}
|
|
79
|
+
return '';
|
|
80
|
+
}, [selected]);
|
|
81
|
+
|
|
82
|
+
const selectedAllOptions = useMemo(() => {
|
|
83
|
+
if (
|
|
84
|
+
multiple &&
|
|
85
|
+
enableSelectAll &&
|
|
86
|
+
parsedSelected.length + 1 === newOptions.length
|
|
87
|
+
) {
|
|
88
|
+
const selectedAllOptions = [...parsedSelected];
|
|
89
|
+
selectedAllOptions.unshift(allOptionId);
|
|
90
|
+
return selectedAllOptions;
|
|
91
|
+
}
|
|
92
|
+
return parsedSelected;
|
|
93
|
+
}, [
|
|
94
|
+
multiple,
|
|
95
|
+
enableSelectAll,
|
|
96
|
+
newOptions.length,
|
|
97
|
+
parsedSelected,
|
|
98
|
+
allOptionId,
|
|
99
|
+
]);
|
|
100
|
+
|
|
101
|
+
// set focused option
|
|
102
|
+
const handleFocusItem = useCallback((element) => {
|
|
103
|
+
if (!optionsElementRef.current) return;
|
|
104
|
+
|
|
105
|
+
setFocusedOption(element);
|
|
106
|
+
|
|
107
|
+
const container = optionsElementRef.current;
|
|
108
|
+
if (container.scrollHeight > container.clientHeight) {
|
|
109
|
+
const scrollBottom = container.clientHeight + container.scrollTop;
|
|
110
|
+
const elementBottom = element.offsetTop + element.offsetHeight;
|
|
111
|
+
if (elementBottom > scrollBottom) {
|
|
112
|
+
container.scrollTop = elementBottom - container.clientHeight;
|
|
113
|
+
} else if (element.offsetTop < container.scrollTop) {
|
|
114
|
+
container.scrollTop = element.offsetTop;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}, []);
|
|
118
|
+
|
|
119
|
+
const focusFirstItem = useCallback(() => {
|
|
120
|
+
const firstItem = listBoxElement.querySelector('[role="option"]');
|
|
121
|
+
|
|
122
|
+
if (firstItem) {
|
|
123
|
+
handleFocusItem(firstItem);
|
|
124
|
+
}
|
|
125
|
+
}, [listBoxElement, handleFocusItem]);
|
|
126
|
+
|
|
127
|
+
const setupFocus = useCallback(() => {
|
|
128
|
+
if (!listBoxElement) return;
|
|
129
|
+
|
|
130
|
+
const selectedItem = listBoxElement.querySelector('[aria-selected="true"]');
|
|
131
|
+
|
|
132
|
+
if (selectedItem) {
|
|
133
|
+
handleFocusItem(selectedItem);
|
|
134
|
+
} else if (optionList.length > 0) {
|
|
135
|
+
focusFirstItem();
|
|
136
|
+
} else {
|
|
137
|
+
setFocusedOption(null);
|
|
138
|
+
}
|
|
139
|
+
}, [listBoxElement, handleFocusItem, focusFirstItem, optionList]);
|
|
140
|
+
|
|
141
|
+
const findPreviousItem = useCallback(
|
|
142
|
+
(currentItem) => {
|
|
143
|
+
const allItem = [...listBoxElement.querySelectorAll('[role="option"]')];
|
|
144
|
+
const currentItemIndex = allItem.indexOf(currentItem);
|
|
145
|
+
let previousItem = null;
|
|
146
|
+
|
|
147
|
+
if (currentItemIndex !== -1 && currentItemIndex > 0) {
|
|
148
|
+
previousItem = allItem[currentItemIndex - 1];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return previousItem;
|
|
152
|
+
},
|
|
153
|
+
[listBoxElement],
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
const findNextItem = useCallback(
|
|
157
|
+
(currentItem) => {
|
|
158
|
+
const allItem = [...listBoxElement.querySelectorAll('[role="option"]')];
|
|
159
|
+
const currentItemIndex = allItem.indexOf(currentItem);
|
|
160
|
+
let nextItem = null;
|
|
161
|
+
|
|
162
|
+
if (currentItemIndex !== -1 && currentItemIndex < allItem.length - 1) {
|
|
163
|
+
nextItem = allItem[currentItemIndex + 1];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return nextItem;
|
|
167
|
+
},
|
|
168
|
+
[listBoxElement],
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
const handleOnSelect = useCallback(
|
|
172
|
+
(event, value) => {
|
|
173
|
+
event.stopPropagation();
|
|
174
|
+
if (disabled === true) return;
|
|
175
|
+
|
|
176
|
+
// 選取選項
|
|
177
|
+
// 點選 all 全選
|
|
178
|
+
if (multiple) {
|
|
179
|
+
if (
|
|
180
|
+
value.toString() === allOptionId &&
|
|
181
|
+
selectedAllOptions.length < newOptions.length
|
|
182
|
+
) {
|
|
183
|
+
for (let index = 1; index < newOptions.length; index += 1) {
|
|
184
|
+
onSelect(newOptions[index].id);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (
|
|
189
|
+
value.toString() !== allOptionId &&
|
|
190
|
+
!selectedAllOptions.includes(value.toString())
|
|
191
|
+
) {
|
|
192
|
+
// 選取一個選項,變成全選
|
|
193
|
+
if (selectedAllOptions.length + 2 === newOptions.length) {
|
|
194
|
+
onSelect(value);
|
|
195
|
+
} else {
|
|
196
|
+
// 選取特定選項
|
|
197
|
+
onSelect(value);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// 刪除選項
|
|
202
|
+
// 點選 all 刪除全選
|
|
203
|
+
if (
|
|
204
|
+
value.toString() === allOptionId &&
|
|
205
|
+
selectedAllOptions.length === newOptions.length
|
|
206
|
+
) {
|
|
207
|
+
for (let index = 0; index < newOptions.length; index += 1) {
|
|
208
|
+
onDeselect(newOptions[index].id);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (
|
|
213
|
+
value.toString() !== allOptionId &&
|
|
214
|
+
selectedAllOptions.includes(value.toString())
|
|
215
|
+
) {
|
|
216
|
+
// 原本是 all 全選後來刪除其中一個選項
|
|
217
|
+
if (selectedAllOptions.length === newOptions.length) {
|
|
218
|
+
onDeselect(value);
|
|
219
|
+
} else {
|
|
220
|
+
// 刪除特定選項
|
|
221
|
+
onDeselect(value);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
setDisplay(true);
|
|
225
|
+
} else {
|
|
226
|
+
onSelect(value);
|
|
227
|
+
setDisplay(false);
|
|
228
|
+
}
|
|
229
|
+
comboboxElement.focus();
|
|
230
|
+
setSearch('');
|
|
231
|
+
},
|
|
232
|
+
[
|
|
233
|
+
disabled,
|
|
234
|
+
onSelect,
|
|
235
|
+
comboboxElement,
|
|
236
|
+
selectedAllOptions,
|
|
237
|
+
onDeselect,
|
|
238
|
+
newOptions,
|
|
239
|
+
allOptionId,
|
|
240
|
+
multiple,
|
|
241
|
+
],
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
const handleOnDeselect = useCallback(
|
|
245
|
+
(event, value) => {
|
|
246
|
+
event.stopPropagation();
|
|
247
|
+
if (disabled === true) return;
|
|
248
|
+
|
|
249
|
+
if (multiple) {
|
|
250
|
+
if (value.toString() === allOptionId) {
|
|
251
|
+
for (let index = 0; index < optionList.length; index += 1) {
|
|
252
|
+
onDeselect(optionList[index].id);
|
|
253
|
+
}
|
|
254
|
+
} else {
|
|
255
|
+
onDeselect(value);
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
onDeselect(value);
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
[disabled, onDeselect, optionList, allOptionId, multiple],
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
// list all selected option
|
|
265
|
+
const selectedItem = useMemo(() => {
|
|
266
|
+
if (selectedOptions.length > 0) {
|
|
267
|
+
if (multiple) {
|
|
268
|
+
if (selectedOptions[0].id === allOptionId) {
|
|
269
|
+
return (
|
|
270
|
+
<SelectedMultiple
|
|
271
|
+
content={selectedOptions[0].text}
|
|
272
|
+
key={selectedOptions[0].id}
|
|
273
|
+
onClick={(event) =>
|
|
274
|
+
handleOnDeselect(event, selectedOptions[0].id)
|
|
275
|
+
}
|
|
276
|
+
disabled={disabled}
|
|
277
|
+
/>
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
return selectedOptions.map((value) => {
|
|
281
|
+
return (
|
|
282
|
+
<SelectedMultiple
|
|
283
|
+
content={value.text}
|
|
284
|
+
key={value.id}
|
|
285
|
+
onClick={(event) => handleOnDeselect(event, value.id)}
|
|
286
|
+
disabled={disabled}
|
|
287
|
+
/>
|
|
288
|
+
);
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return <SelectedSingle>{selectedOptions[0].text}</SelectedSingle>;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return placeholder;
|
|
296
|
+
}, [
|
|
297
|
+
placeholder,
|
|
298
|
+
handleOnDeselect,
|
|
299
|
+
multiple,
|
|
300
|
+
selectedOptions,
|
|
301
|
+
disabled,
|
|
302
|
+
allOptionId,
|
|
303
|
+
]);
|
|
304
|
+
|
|
305
|
+
const optionItem = useMemo(() => {
|
|
306
|
+
if (optionList.length <= 0) return null;
|
|
307
|
+
return optionList.map((option) => {
|
|
308
|
+
if (option.child && option.child.length > 0) {
|
|
309
|
+
return (
|
|
310
|
+
<OptionGroup aria-labelledby={option.text} key={option.text}>
|
|
311
|
+
<Option role='presentation' id={option.text}>
|
|
312
|
+
{option.text}
|
|
313
|
+
</Option>
|
|
314
|
+
|
|
315
|
+
{option.child.map((option) => {
|
|
316
|
+
return (
|
|
317
|
+
<Option
|
|
318
|
+
role='option'
|
|
319
|
+
tabIndex='0'
|
|
320
|
+
id={option.id}
|
|
321
|
+
key={option.id}
|
|
322
|
+
onClick={(event) => handleOnSelect(event, option.id)}
|
|
323
|
+
focus={
|
|
324
|
+
focusedOption && focusedOption.id === option.id.toString()
|
|
325
|
+
}
|
|
326
|
+
selected={option.selected}
|
|
327
|
+
aria-selected={option.selected}
|
|
328
|
+
>
|
|
329
|
+
{option.text}
|
|
330
|
+
</Option>
|
|
331
|
+
);
|
|
332
|
+
})}
|
|
333
|
+
</OptionGroup>
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
return (
|
|
338
|
+
<Option
|
|
339
|
+
role='option'
|
|
340
|
+
tabIndex='0'
|
|
341
|
+
id={option.id}
|
|
342
|
+
key={option.id}
|
|
343
|
+
onClick={(event) => handleOnSelect(event, option.id)}
|
|
344
|
+
focus={focusedOption && focusedOption.id === option.id.toString()}
|
|
345
|
+
selected={option.selected}
|
|
346
|
+
aria-selected={option.selected}
|
|
347
|
+
>
|
|
348
|
+
{option.text}
|
|
349
|
+
</Option>
|
|
350
|
+
);
|
|
351
|
+
});
|
|
352
|
+
}, [optionList, focusedOption, handleOnSelect]);
|
|
353
|
+
|
|
354
|
+
// show or hide listbox
|
|
355
|
+
// and set listbox width according to combobox current width
|
|
356
|
+
const handleToggle = () => {
|
|
357
|
+
if (disabled === true) return;
|
|
358
|
+
|
|
359
|
+
const tmpDisplay = !display;
|
|
360
|
+
if (!tmpDisplay) {
|
|
361
|
+
setFocusedOption(null);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
setDisplay(tmpDisplay);
|
|
365
|
+
update();
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
// handle keyboard interaction
|
|
369
|
+
const handleKeyUp = (event) => {
|
|
370
|
+
const key = event.keyCode;
|
|
371
|
+
|
|
372
|
+
switch (key) {
|
|
373
|
+
case KEY_CODE.ENTER:
|
|
374
|
+
if (!display) {
|
|
375
|
+
handleToggle();
|
|
376
|
+
} else if (focusedOption) {
|
|
377
|
+
handleOnSelect(event, focusedOption.id);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
break;
|
|
381
|
+
case KEY_CODE.ESCAPE:
|
|
382
|
+
if (display) {
|
|
383
|
+
handleToggle();
|
|
384
|
+
}
|
|
385
|
+
break;
|
|
386
|
+
case KEY_CODE.UP: {
|
|
387
|
+
if (!focusedOption) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const previousItem = findPreviousItem(focusedOption);
|
|
392
|
+
if (previousItem) {
|
|
393
|
+
handleFocusItem(previousItem);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
case KEY_CODE.DOWN: {
|
|
399
|
+
if (!focusedOption) {
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
const nextItem = findNextItem(focusedOption);
|
|
404
|
+
if (nextItem) {
|
|
405
|
+
handleFocusItem(nextItem);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
case KEY_CODE.END: {
|
|
411
|
+
event.preventDefault();
|
|
412
|
+
const itemList = listBoxElement.querySelectorAll('[role="option"]');
|
|
413
|
+
|
|
414
|
+
if (itemList.length) {
|
|
415
|
+
handleFocusItem(itemList[itemList.length - 1]);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
case KEY_CODE.HOME:
|
|
421
|
+
event.preventDefault();
|
|
422
|
+
focusFirstItem();
|
|
423
|
+
break;
|
|
424
|
+
default:
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
const handleKeyDown = (event) => {
|
|
430
|
+
const key = event.keyCode;
|
|
431
|
+
|
|
432
|
+
switch (key) {
|
|
433
|
+
case KEY_CODE.ENTER:
|
|
434
|
+
case KEY_CODE.ESCAPE:
|
|
435
|
+
case KEY_CODE.UP:
|
|
436
|
+
case KEY_CODE.DOWN:
|
|
437
|
+
case KEY_CODE.END:
|
|
438
|
+
case KEY_CODE.HOME:
|
|
439
|
+
event.preventDefault();
|
|
440
|
+
break;
|
|
441
|
+
default:
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
// handle search keyword change
|
|
447
|
+
const handleSearchChange = (event) => {
|
|
448
|
+
if (onSearch) {
|
|
449
|
+
onSearch(event.target.value);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
setSearch(event.target.value);
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
const handleFocus = (event) => {
|
|
456
|
+
event.preventDefault();
|
|
457
|
+
event.stopPropagation();
|
|
458
|
+
|
|
459
|
+
setIsFocusCombobox(true);
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
// determine selected option(s)
|
|
463
|
+
useEffect(() => {
|
|
464
|
+
if (!newOptions) return;
|
|
465
|
+
|
|
466
|
+
const tmpSelectedOptions = [];
|
|
467
|
+
|
|
468
|
+
newOptions.forEach((option) => {
|
|
469
|
+
if (option.child && option.child.length > 0) {
|
|
470
|
+
option.child.forEach((option) => {
|
|
471
|
+
if (multiple && selectedAllOptions.includes(option.id.toString())) {
|
|
472
|
+
tmpSelectedOptions.push(option);
|
|
473
|
+
} else if (selectedAllOptions === option.id.toString()) {
|
|
474
|
+
tmpSelectedOptions.push(option);
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
} else {
|
|
478
|
+
if (multiple && selectedAllOptions.includes(option.id.toString())) {
|
|
479
|
+
tmpSelectedOptions.push(option);
|
|
480
|
+
} else if (selectedAllOptions === option.id.toString()) {
|
|
481
|
+
tmpSelectedOptions.push(option);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return false;
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
setSelectedOptions(tmpSelectedOptions);
|
|
488
|
+
}, [newOptions, selectedAllOptions, multiple]);
|
|
489
|
+
|
|
490
|
+
useEffect(() => {
|
|
491
|
+
if (update) {
|
|
492
|
+
setTimeout(() => {
|
|
493
|
+
update();
|
|
494
|
+
}, 100);
|
|
495
|
+
}
|
|
496
|
+
}, [update, listBoxWidth]);
|
|
497
|
+
|
|
498
|
+
// observe element resized
|
|
499
|
+
useEffect(() => {
|
|
500
|
+
if (!comboboxElement) return;
|
|
501
|
+
|
|
502
|
+
const resizeObserverInstance = new ResizeObserver((entries) => {
|
|
503
|
+
for (const entry of entries) {
|
|
504
|
+
if (entry.target) {
|
|
505
|
+
const borderBoxSize = entry.target.clientWidth;
|
|
506
|
+
|
|
507
|
+
setListBoxWidth(borderBoxSize);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
resizeObserverInstance.observe(comboboxElement);
|
|
513
|
+
|
|
514
|
+
return () => {
|
|
515
|
+
// unobserve element
|
|
516
|
+
resizeObserverInstance.unobserve(comboboxElement);
|
|
517
|
+
};
|
|
518
|
+
}, [comboboxElement]);
|
|
519
|
+
|
|
520
|
+
// re-setup focus when option list changed and update popper position
|
|
521
|
+
useEffect(() => {
|
|
522
|
+
setupFocus();
|
|
523
|
+
if (update) update();
|
|
524
|
+
}, [setupFocus, optionList, update]);
|
|
525
|
+
|
|
526
|
+
// parse option list when filtered options change
|
|
527
|
+
useEffect(() => {
|
|
528
|
+
if (!filteredOptions) return;
|
|
529
|
+
|
|
530
|
+
setOptionList(
|
|
531
|
+
filteredOptions.map((option) => {
|
|
532
|
+
if (option.child && option.child.length > 0) {
|
|
533
|
+
return {
|
|
534
|
+
...option,
|
|
535
|
+
child: option.child.map((option) => {
|
|
536
|
+
let selected = false;
|
|
537
|
+
if (
|
|
538
|
+
multiple &&
|
|
539
|
+
selectedAllOptions.includes(option.id.toString())
|
|
540
|
+
) {
|
|
541
|
+
selected = true;
|
|
542
|
+
} else if (selectedAllOptions === option.id.toString()) {
|
|
543
|
+
selected = true;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
return {
|
|
547
|
+
...option,
|
|
548
|
+
selected,
|
|
549
|
+
};
|
|
550
|
+
}),
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
let selected = false;
|
|
555
|
+
|
|
556
|
+
if (multiple && selectedAllOptions.includes(option.id.toString())) {
|
|
557
|
+
selected = true;
|
|
558
|
+
} else if (selectedAllOptions === option.id.toString()) {
|
|
559
|
+
selected = true;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
return {
|
|
563
|
+
...option,
|
|
564
|
+
selected,
|
|
565
|
+
};
|
|
566
|
+
}),
|
|
567
|
+
);
|
|
568
|
+
}, [filteredOptions, multiple, selectedAllOptions]);
|
|
569
|
+
|
|
570
|
+
// filter options on search keyword changed
|
|
571
|
+
useEffect(() => {
|
|
572
|
+
const tmpFilteredOptions = [];
|
|
573
|
+
|
|
574
|
+
newOptions.forEach((option) => {
|
|
575
|
+
if (option.child && option.child.length > 0) {
|
|
576
|
+
const tmpFilteredChildOptions = option.child.filter(
|
|
577
|
+
(option) =>
|
|
578
|
+
option.text.toLowerCase().indexOf(search.toLowerCase().trim()) !==
|
|
579
|
+
-1,
|
|
580
|
+
);
|
|
581
|
+
if (tmpFilteredChildOptions.length > 0) {
|
|
582
|
+
tmpFilteredOptions.push({
|
|
583
|
+
...option,
|
|
584
|
+
child: tmpFilteredChildOptions,
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
} else if (
|
|
588
|
+
option.text.toLowerCase().indexOf(search.toLowerCase().trim()) !== -1
|
|
589
|
+
) {
|
|
590
|
+
tmpFilteredOptions.push(option);
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
setFilteredOptions(tmpFilteredOptions);
|
|
594
|
+
}, [search, newOptions]);
|
|
595
|
+
|
|
596
|
+
useEffect(() => {
|
|
597
|
+
if (display) {
|
|
598
|
+
setupFocus();
|
|
599
|
+
|
|
600
|
+
if (allowSearch) {
|
|
601
|
+
searchBoxElement.current.focus();
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}, [setupFocus, display, allowSearch]);
|
|
605
|
+
|
|
606
|
+
return (
|
|
607
|
+
<OutsideClickHandler
|
|
608
|
+
onOutsideClick={() => {
|
|
609
|
+
setDisplay(false);
|
|
610
|
+
if (onBlur) onBlur();
|
|
611
|
+
setIsFocusCombobox(false);
|
|
612
|
+
}}
|
|
613
|
+
disabled={!isFocusCombobox}
|
|
614
|
+
>
|
|
615
|
+
<Combobox
|
|
616
|
+
role='combobox'
|
|
617
|
+
tabIndex='0'
|
|
618
|
+
aria-haspopup='listbox'
|
|
619
|
+
aria-expanded={display}
|
|
620
|
+
aria-owns={id}
|
|
621
|
+
ref={setComboboxElement}
|
|
622
|
+
onClick={handleToggle}
|
|
623
|
+
onKeyUp={handleKeyUp}
|
|
624
|
+
onKeyDown={handleKeyDown}
|
|
625
|
+
$display={display}
|
|
626
|
+
disabled={disabled}
|
|
627
|
+
fullWidth={fullWidth}
|
|
628
|
+
large={large}
|
|
629
|
+
$fill={fill}
|
|
630
|
+
fillReverse={fillReverse}
|
|
631
|
+
onFocus={handleFocus}
|
|
632
|
+
placeholder={placeholder}
|
|
633
|
+
>
|
|
634
|
+
{selectedItem}
|
|
635
|
+
|
|
636
|
+
{selectedOptions.length > 0 && !multiple && !disabled && allowClear && (
|
|
637
|
+
<CloseButton
|
|
638
|
+
onClick={() => {
|
|
639
|
+
onSelect('');
|
|
640
|
+
}}
|
|
641
|
+
/>
|
|
642
|
+
)}
|
|
643
|
+
<ExpandArrow aria-haspopup='listbox' aria-expanded={display} />
|
|
644
|
+
</Combobox>
|
|
645
|
+
<ListBox
|
|
646
|
+
role='listbox'
|
|
647
|
+
tabIndex='0'
|
|
648
|
+
id={id}
|
|
649
|
+
ref={setListBoxElement}
|
|
650
|
+
onKeyUp={handleKeyUp}
|
|
651
|
+
onKeyDown={handleKeyDown}
|
|
652
|
+
width={listBoxWidth}
|
|
653
|
+
$display={display}
|
|
654
|
+
style={styles.popper}
|
|
655
|
+
{...attributes.popper}
|
|
656
|
+
placement={state && state.placement}
|
|
657
|
+
>
|
|
658
|
+
{allowSearch && (
|
|
659
|
+
<SearchBox
|
|
660
|
+
ref={searchBoxElement}
|
|
661
|
+
placeholder='Search'
|
|
662
|
+
onChange={handleSearchChange}
|
|
663
|
+
value={search}
|
|
664
|
+
/>
|
|
665
|
+
)}
|
|
666
|
+
|
|
667
|
+
<Options ref={optionsElementRef} allowSearch={allowSearch}>
|
|
668
|
+
{optionItem || <Message>No results found</Message>}
|
|
669
|
+
</Options>
|
|
670
|
+
</ListBox>
|
|
671
|
+
</OutsideClickHandler>
|
|
672
|
+
);
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
const Combobox = styled.div`
|
|
676
|
+
display: flex;
|
|
677
|
+
flex-wrap: wrap;
|
|
678
|
+
align-items: center;
|
|
679
|
+
min-height: 36px;
|
|
680
|
+
min-width: 160px;
|
|
681
|
+
cursor: pointer;
|
|
682
|
+
position: relative;
|
|
683
|
+
background: transparent;
|
|
684
|
+
color: var(--font-on-background);
|
|
685
|
+
font-size: var(--font-body1);
|
|
686
|
+
border: var(--border-width) solid var(--border-color);
|
|
687
|
+
border-radius: var(--border-radius-l);
|
|
688
|
+
padding: 0 calc(var(--spacing-s) * 2 + 8px) 0 var(--spacing-s);
|
|
689
|
+
|
|
690
|
+
&:focus {
|
|
691
|
+
${({ disabled }) =>
|
|
692
|
+
!disabled &&
|
|
693
|
+
`
|
|
694
|
+
border-color: var(--color-primary);
|
|
695
|
+
outline: none;
|
|
696
|
+
`};
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
${({ $display }) =>
|
|
700
|
+
$display &&
|
|
701
|
+
`
|
|
702
|
+
border-color: var(--color-primary);
|
|
703
|
+
outline: none;
|
|
704
|
+
`}
|
|
705
|
+
|
|
706
|
+
${({ disabled }) => disabled && 'cursor: not-allowed;opacity: 0.5;'}
|
|
707
|
+
${({ placeholder }) => placeholder && 'color: var(--font-on-mute);'}
|
|
708
|
+
|
|
709
|
+
${({ fullWidth }) => (fullWidth ? 'width: 100%' : 'max-width: 320px')};
|
|
710
|
+
|
|
711
|
+
${({ large }) =>
|
|
712
|
+
large &&
|
|
713
|
+
`
|
|
714
|
+
height: 40px;
|
|
715
|
+
padding: 12px calc(var(--spacing-s) * 2 + 8px) 12px var(--spacing-s);
|
|
716
|
+
`}
|
|
717
|
+
|
|
718
|
+
${({ $fill }) =>
|
|
719
|
+
$fill &&
|
|
720
|
+
`
|
|
721
|
+
background: var(--color-background2);
|
|
722
|
+
border-color: transparent;
|
|
723
|
+
`}
|
|
724
|
+
|
|
725
|
+
${({ fillReverse }) =>
|
|
726
|
+
fillReverse &&
|
|
727
|
+
`
|
|
728
|
+
background: var(--color-background1);
|
|
729
|
+
border-color: transparent;
|
|
730
|
+
`}
|
|
731
|
+
`;
|
|
732
|
+
Combobox.displayName = 'Combobox';
|
|
733
|
+
|
|
734
|
+
const CloseButton = styled(MdClose)`
|
|
735
|
+
position: absolute;
|
|
736
|
+
top: 50%;
|
|
737
|
+
transform: translateY(-50%);
|
|
738
|
+
color: var(--color-primary);
|
|
739
|
+
font-size: var(--font-body1);
|
|
740
|
+
right: var(--spacing-l);
|
|
741
|
+
|
|
742
|
+
${media.tablet`
|
|
743
|
+
right: calc(var(--spacing) + var(--spacing-s));
|
|
744
|
+
`};
|
|
745
|
+
`;
|
|
746
|
+
CloseButton.displayName = 'CloseButton';
|
|
747
|
+
|
|
748
|
+
const ExpandArrow = styled(TiArrowSortedDown)`
|
|
749
|
+
position: absolute;
|
|
750
|
+
top: 50%;
|
|
751
|
+
transform: translateY(-50%);
|
|
752
|
+
color: var(--color-primary);
|
|
753
|
+
font-size: var(--font-body1);
|
|
754
|
+
right: var(--spacing-s);
|
|
755
|
+
`;
|
|
756
|
+
ExpandArrow.displayName = 'ExpandArrow';
|
|
757
|
+
|
|
758
|
+
const Message = styled.p`
|
|
759
|
+
margin: 0;
|
|
760
|
+
padding: 12px var(--spacing-s);
|
|
761
|
+
`;
|
|
762
|
+
Message.displayName = 'Message';
|
|
763
|
+
|
|
764
|
+
export default Select;
|