@cashub/ui-elv 1.0.1 → 1.0.3
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/chart/BarChart.js +8 -2
- package/chart/DoughnutChart.js +2 -1
- package/chart/LineChart.js +2 -1
- package/chart/utils/customTooltip.js +3 -7
- package/chart/utils/customTooltipLifecyclePlugin.js +21 -0
- package/chart/utils/tooltipElement.js +25 -0
- package/chart/utils/xAxisLabelTooltipPlugin.js +107 -0
- package/datetimePicker/index.js +2 -37
- package/esm/Tab/Tab.js +21 -0
- package/esm/Tab/TabList.js +160 -0
- package/esm/Tab/TabPanel.js +42 -0
- package/esm/Tab/TabTab.js +98 -0
- package/esm/Tab/index.js +23 -0
- package/esm/Tab/subComponent/TabContext.js +3 -0
- package/esm/Tab/subComponent/TabListV2.js +18 -0
- package/esm/Tab/subComponent/TabPanelV2.js +45 -0
- package/esm/Tab/subComponent/TabTabV2.js +56 -0
- package/esm/VerticalTab/TabList.js +20 -0
- package/esm/VerticalTab/TabPanel.js +45 -0
- package/esm/VerticalTab/TabTab.js +63 -0
- package/esm/VerticalTab/VerticalTab.js +34 -0
- package/esm/VerticalTab/index.js +9 -0
- package/esm/VerticalTab/subComponent/TabContext.js +3 -0
- package/esm/alert/Alert.js +22 -0
- package/esm/alert/index.js +1 -0
- package/esm/animate/Collapse.js +65 -0
- package/esm/animate/Loader.js +51 -0
- package/esm/animate/NumberCounter.js +45 -0
- package/esm/animate/PulseRing.js +26 -0
- package/esm/animate/Spinner.js +11 -0
- package/esm/animate/index.js +5 -0
- package/esm/assets/css/autocomplete.css +16 -0
- package/esm/assets/css/font.css +4 -0
- package/esm/assets/css/global.css +2 -0
- package/esm/assets/font/helvetica/Helvetica.ttf +0 -0
- package/esm/assets/font/nanumGothic/NanumGothic-Bold.ttf +0 -0
- package/esm/assets/font/nanumGothic/NanumGothic-ExtraBold.ttf +0 -0
- package/esm/assets/font/nanumGothic/NanumGothic-Regular.ttf +0 -0
- package/esm/assets/icons/app-management.png +0 -0
- package/esm/assets/icons/burger-black.png +0 -0
- package/esm/assets/icons/burger-white.png +0 -0
- package/esm/assets/icons/burger.png +0 -0
- package/esm/assets/icons/file.svg +1 -0
- package/esm/assets/icons/map_icon1.png +0 -0
- package/esm/assets/icons/map_icon4.png +0 -0
- package/esm/assets/images/bg-aside.png +0 -0
- package/esm/assets/images/bg-chart-circle.png +0 -0
- package/esm/assets/images/bg-chart-triangle.png +0 -0
- package/esm/assets/images/cashub-logo-only.png +0 -0
- package/esm/assets/images/default-user.jpg +0 -0
- package/esm/assets/images/logo-cashub.png +0 -0
- package/esm/assets/images/map.png +0 -0
- package/esm/assets/images/qrcode.png +0 -0
- package/esm/backdrop/BaseBackdrop.js +11 -0
- package/esm/backdrop/LoadingBackdrop.js +10 -0
- package/esm/backdrop/ModalBackdrop.js +8 -0
- package/esm/backdrop/index.js +3 -0
- package/esm/badge/Badge.js +19 -0
- package/esm/badge/BadgeDot.js +11 -0
- package/esm/badge/BadgeFill.js +42 -0
- package/esm/badge/BadgeFillTriangle.js +138 -0
- package/esm/badge/BadgeWithText.js +24 -0
- package/esm/badge/index.js +5 -0
- package/esm/billing/BarChart.js +45 -0
- package/esm/billing/Grid.js +38 -0
- package/esm/billing/Header2.js +19 -0
- package/esm/billing/Header3.js +31 -0
- package/esm/billing/Paragraph.js +27 -0
- package/esm/billing/ParagraphGroup.js +16 -0
- package/esm/billing/ParagraphText.js +20 -0
- package/esm/billing/Section.js +44 -0
- package/esm/billing/SectionBody.js +11 -0
- package/esm/billing/SectionHeader.js +20 -0
- package/esm/billing/__stories__/BarChart.stories.js_bak +46 -0
- package/esm/billing/__stories__/Grid.stories.js_bak +57 -0
- package/esm/billing/__stories__/Header2.stories.js_bak +62 -0
- package/esm/billing/__stories__/Header3.stories.js_bak +69 -0
- package/esm/billing/__stories__/Paragraph.stories.js_bak +84 -0
- package/esm/billing/__stories__/ParagraphGroup.stories.js_bak +68 -0
- package/esm/billing/__stories__/ParagraphText.stories.js_bak +64 -0
- package/esm/billing/__stories__/Section.stories.js_bak +115 -0
- package/esm/billing/__stories__/SectionBody.stories.js_bak +62 -0
- package/esm/billing/__stories__/SectionHeader.stories.js-bak +68 -0
- package/esm/breadcrumb/Breadcrumb.js +71 -0
- package/esm/breadcrumb/index.js +1 -0
- package/esm/button/Button.js +145 -0
- package/esm/button/ButtonGroup.js +54 -0
- package/esm/button/IconButton.js +64 -0
- package/esm/button/ScrollToTopButton.js +47 -0
- package/esm/button/index.js +4 -0
- package/esm/callout/Callout.js +45 -0
- package/esm/callout/index.js +1 -0
- package/esm/chart/BarChart.js +147 -0
- package/esm/chart/DoughnutChart.js +110 -0
- package/esm/chart/LineChart.js +140 -0
- package/esm/chart/SingleBarChart.js +35 -0
- package/esm/chart/index.js +5 -0
- package/esm/chart/utils/centerTextPlugin.js +56 -0
- package/esm/chart/utils/customTooltip.js +84 -0
- package/esm/chart/utils/customTooltipLifecyclePlugin.js +16 -0
- package/esm/chart/utils/htmlLegendPlugin.js +83 -0
- package/esm/chart/utils/index.js +3 -0
- package/esm/chart/utils/padEmptyChartBar.js +47 -0
- package/esm/chart/utils/tooltipElement.js +17 -0
- package/esm/chart/utils/xAxisLabelTooltipPlugin.js +101 -0
- package/esm/chart/utils/yAxisTopTitlePlugin.js +43 -0
- package/esm/container/FlexContainer.js +33 -0
- package/esm/container/index.js +1 -0
- package/esm/cropper/Cropper.js +47 -0
- package/esm/cropper/CropperModalHandler.js +34 -0
- package/esm/cropper/index.js +2 -0
- package/esm/cropper/subComponent/CropImageModal.js +72 -0
- package/{datetimePicker/DatetimePicker.js → esm/datetimePicker/DatetimePickerV3.js} +63 -31
- package/esm/datetimePicker/TimeInput.js +49 -0
- package/esm/datetimePicker/TimePickerStyle.js +58 -0
- package/esm/datetimePicker/TimePickerV2.js +199 -0
- package/esm/datetimePicker/accordion/Month.js +245 -0
- package/esm/datetimePicker/accordion/Year.js +275 -0
- package/esm/datetimePicker/index.js +4 -0
- package/esm/datetimePicker/provider/constant.js +38 -0
- package/esm/datetimePicker/subComponent/DateTimePickerContext.js +3 -0
- package/esm/datetimePicker/utils/GMTDate.js +9 -0
- package/esm/datetimePicker/utils/pad.js +7 -0
- package/esm/datetimePicker/utils/toUTC0.js +7 -0
- package/esm/descriptionList/DescriptionDetail.js +21 -0
- package/esm/descriptionList/DescriptionList.js +18 -0
- package/esm/descriptionList/DescriptionTerm.js +7 -0
- package/esm/descriptionList/index.js +3 -0
- package/esm/divider/Divider.js +24 -0
- package/esm/divider/index.js +1 -0
- package/esm/dropdown/Dropdown.js +48 -0
- package/esm/dropdown/DropdownButtonOption.js +36 -0
- package/esm/dropdown/DropdownContent.js +83 -0
- package/esm/dropdown/DropdownDivOption.js +19 -0
- package/esm/dropdown/DropdownItem.js +19 -0
- package/esm/dropdown/DropdownLinkOption.js +17 -0
- package/esm/dropdown/DropdownToggle.js +31 -0
- package/esm/dropdown/index.js +11 -0
- package/esm/dropdown/subComponent/DropdownContext.js +3 -0
- package/esm/dropzone/FileDropzone.js +472 -0
- package/esm/dropzone/ImageDropzone.js +327 -0
- package/esm/dropzone/index.js +2 -0
- package/esm/dropzone/subComponent/Message.js +19 -0
- package/esm/figure/IconFigure.js +35 -0
- package/esm/figure/ImageFigure.js +31 -0
- package/esm/figure/index.js +2 -0
- package/esm/file/HiddenFileInput.js +8 -0
- package/esm/file/index.js +1 -0
- package/esm/form/Checkbox.js +157 -0
- package/esm/form/Fieldset.js +11 -0
- package/esm/form/FormItem.js +15 -0
- package/esm/form/Input.js +59 -0
- package/esm/form/Label.js +54 -0
- package/esm/form/MutedText.js +14 -0
- package/esm/form/PasswordInput.js +40 -0
- package/esm/form/RadioButton.js +94 -0
- package/esm/form/SearchSelect.js +174 -0
- package/esm/form/Searchbox.js +91 -0
- package/esm/form/Slider.js +39 -0
- package/esm/form/SwitchButton.js +97 -0
- package/esm/form/Textarea.js +34 -0
- package/esm/form/TreeView.js +66 -0
- package/esm/form/index.js +14 -0
- package/esm/grid/Column.js +39 -0
- package/esm/grid/Grid.js +28 -0
- package/esm/grid/index.js +2 -0
- package/esm/heading/Heading1.js +14 -0
- package/esm/heading/Heading2.js +21 -0
- package/esm/heading/Heading3.js +42 -0
- package/esm/heading/index.js +3 -0
- package/esm/helmet/Helmet.js +17 -0
- package/esm/helmet/index.js +2 -0
- package/esm/iconbox/ApplicationIconBox.js +74 -0
- package/esm/iconbox/IconBox.js +60 -0
- package/esm/iconbox/IconBoxV2.js +63 -0
- package/esm/iconbox/index.js +3 -0
- package/esm/iconbox/subComponent/IconBoxFigure.js +43 -0
- package/esm/iconbox/subComponent/IconBoxImage.js +35 -0
- package/esm/image/ImageFluid.js +10 -0
- package/esm/image/UploadImage.js +243 -0
- package/esm/image/index.js +2 -0
- package/esm/index.js +47 -0
- package/esm/keyframe/Pulse.js +15 -0
- package/esm/keyframe/Spin.js +7 -0
- package/esm/layout/Aside.js +39 -0
- package/esm/layout/AsideHeader.jsx +27 -0
- package/esm/layout/Backdrop.js +16 -0
- package/esm/layout/Container.js +30 -0
- package/esm/layout/Footer.js +36 -0
- package/esm/layout/Header.jsx +55 -0
- package/esm/layout/Layout.jsx +84 -0
- package/esm/layout/Logo.jsx +17 -0
- package/esm/layout/MenuIcon.jsx +27 -0
- package/esm/layout/Sidebar.jsx +271 -0
- package/esm/layout/index.js +1 -0
- package/esm/link/LinkSpan.js +62 -0
- package/esm/link/index.js +1 -0
- package/esm/map/GoogleMap.js +439 -0
- package/esm/map/GoogleReverseGeolocation.js +193 -0
- package/esm/map/LeafletMap.js +224 -0
- package/esm/map/LeafletReverseGeolocation.js +94 -0
- package/esm/map/index.js +4 -0
- package/esm/map/subComponent/BasicLeafletMap.js +27 -0
- package/esm/map/subComponent/GoogleMapContainer.js +22 -0
- package/esm/map/subComponent/GoogleMapPopup.js +103 -0
- package/esm/map/subComponent/GoogleMapWrapper.js +34 -0
- package/esm/map/subComponent/LeafletDrawControl.js +116 -0
- package/esm/map/subComponent/LeafletMapContainer.js +166 -0
- package/esm/map/subComponent/MapSearchBoxControl.js +47 -0
- package/esm/modal/StateModal.js +169 -0
- package/esm/modal/TitleModal.js +241 -0
- package/esm/modal/index.js +2 -0
- package/esm/page/Disclaimer.js +121 -0
- package/esm/page/index.js +1 -0
- package/esm/paginate/Paginate.js +129 -0
- package/esm/paginate/index.js +1 -0
- package/esm/popover/Popover.js +82 -0
- package/esm/popover/index.js +1 -0
- package/esm/qrcode/QRCode.js +51 -0
- package/esm/qrcode/QRCodeContainter.js +27 -0
- package/esm/qrcode/index.js +2 -0
- package/esm/ribbon/Ribbon.js +35 -0
- package/esm/ribbon/index.js +1 -0
- package/esm/section/Section.js +126 -0
- package/esm/section/SectionBody.js +43 -0
- package/esm/section/SectionHeader.js +61 -0
- package/esm/section/SectionToolbar.js +11 -0
- package/esm/section/SectionToolbarItem.js +10 -0
- package/esm/section/index.js +5 -0
- package/esm/select/InputSelect.js +263 -0
- package/esm/select/Select.js +811 -0
- package/esm/select/index.js +2 -0
- package/esm/select/subComponent/Checkbox.js +40 -0
- package/esm/select/subComponent/Footer.js +6 -0
- package/esm/select/subComponent/ListBox.js +23 -0
- package/esm/select/subComponent/Option.js +37 -0
- package/esm/select/subComponent/OptionGroup.js +16 -0
- package/esm/select/subComponent/Options.js +25 -0
- package/esm/select/subComponent/SearchBox.js +51 -0
- package/esm/select/subComponent/SelectedMultipleCount.js +32 -0
- package/esm/select/subComponent/SelectedMultipleTags.js +47 -0
- package/esm/select/subComponent/SelectedMultipleText.js +63 -0
- package/esm/select/subComponent/SelectedSingle.js +10 -0
- package/esm/styles/GlobalStyle.js +328 -0
- package/esm/styles/config/breakpoint.style.js +7 -0
- package/esm/styles/config/header.style.js +4 -0
- package/esm/styles/config/sidebar.style.js +11 -0
- package/esm/styles/index.js +2 -0
- package/esm/styles/mixin/backgroundColor.js +38 -0
- package/esm/styles/mixin/borderColor.js +31 -0
- package/esm/styles/mixin/color.js +31 -0
- package/esm/styles/mixin/colorOnBackground.js +31 -0
- package/esm/styles/mixin/inputPlaceholder.js +24 -0
- package/esm/styles/mixin/media.js +15 -0
- package/esm/styles/mixin/rounded.js +24 -0
- package/esm/styles/mixin/scrollbar.js +26 -0
- package/esm/styles/theme/dark.theme.js +91 -0
- package/esm/styles/theme/light.theme.js +91 -0
- package/esm/styles/theme/white.theme.js +91 -0
- package/esm/styles/themes.js +9 -0
- package/esm/table/GridTable.js +329 -0
- package/esm/table/ImageBox.js +38 -0
- package/esm/table/InfiniteGridTable.js +396 -0
- package/esm/table/PermissionTable.js +57 -0
- package/esm/table/SimpleGridTable.js +136 -0
- package/esm/table/Table.js +559 -0
- package/esm/table/__mock__/columns.js +64 -0
- package/esm/table/__mock__/data.js +530 -0
- package/esm/table/hooks/index.js +2 -0
- package/esm/table/hooks/useCalculateDataRange.js +22 -0
- package/esm/table/hooks/useGenerateSort.js +32 -0
- package/esm/table/index.js +6 -0
- package/esm/table/subComponent/BaseTableHeadCell.js +54 -0
- package/esm/table/subComponent/GridTableFooter.js +17 -0
- package/esm/table/subComponent/GridTableHeadCell.js +13 -0
- package/esm/table/subComponent/Resizer.js +70 -0
- package/esm/table/subComponent/TableFooter.js +24 -0
- package/esm/table/subComponent/TableFooterInfo.js +6 -0
- package/esm/table/subComponent/TableFooterPager.js +26 -0
- package/esm/table/subComponent/TableHeadCell.js +12 -0
- package/esm/table/subComponent/TableSort.js +31 -0
- package/esm/tagify/TagifyStyle.js +54 -0
- package/esm/tagify/Tags.js +49 -0
- package/esm/tagify/index.js +3 -0
- package/esm/tagify/templates/getCreateButtonTemplate.js +12 -0
- package/esm/text/Paragraph.js +79 -0
- package/esm/text/index.js +1 -0
- package/esm/timeline/Timeline.js +132 -0
- package/esm/timeline/index.js +1 -0
- package/esm/toast/CustomToastContainer.js +38 -0
- package/esm/toast/MessageContainer.js +44 -0
- package/esm/toast/index.js +3 -0
- package/esm/toast/show.js +29 -0
- package/esm/toast/style.css +1 -0
- package/esm/tooltip/Tooltip.js +133 -0
- package/esm/tooltip/index.js +1 -0
- package/esm/treeView/TreeViewV2.js +32 -0
- package/esm/treeView/TreeflexStyle.js +43 -0
- package/esm/treeView/index.js +2 -0
- package/esm/wizard/Wizard.js +244 -0
- package/esm/wizard/index.js +1 -0
- package/index.js +0 -12
- package/layout/Sidebar.jsx +1 -1
- package/package.json +5 -4
- package/datetimePicker/DatePicker.js +0 -363
- package/datetimePicker/DatePickerV2.js +0 -407
- package/datetimePicker/DatetimePickerV2.js +0 -395
- package/datetimePicker/TimePicker.js +0 -317
- package/datetimePicker/hooks/index.js +0 -27
- package/datetimePicker/hooks/useChangeNumber.js +0 -42
- package/datetimePicker/hooks/useDecrease.js +0 -38
- package/datetimePicker/hooks/useIncrease.js +0 -38
- package/datetimePicker/subComponent/Accordion.js +0 -373
- package/datetimePicker/subComponent/CustomTimeInput.js +0 -47
- package/jsoneditor/JsonEditor.js +0 -142
- package/jsoneditor/index.js +0 -13
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as Section } from './Section';
|
|
2
|
+
export { default as SectionBody } from './SectionBody';
|
|
3
|
+
export { default as SectionHeader } from './SectionHeader';
|
|
4
|
+
export { default as SectionToolbar } from './SectionToolbar';
|
|
5
|
+
export { default as SectionToolbarItem } from './SectionToolbarItem';
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import OutsideClickHandler from 'react-outside-click-handler';
|
|
3
|
+
import { useCustomPopper } from '@cashub/hooks';
|
|
4
|
+
import { KEY_CODE } from '@cashub/utils';
|
|
5
|
+
import Input from '../form/Input';
|
|
6
|
+
import ListBox from './subComponent/ListBox';
|
|
7
|
+
import Option from './subComponent/Option';
|
|
8
|
+
import Options from './subComponent/Options';
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
const InputSelect = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
options = [],
|
|
13
|
+
value,
|
|
14
|
+
disabled,
|
|
15
|
+
onChange,
|
|
16
|
+
onSelect,
|
|
17
|
+
...props
|
|
18
|
+
} = _ref;
|
|
19
|
+
const [displayListBox, setDisplayListBox] = useState(false);
|
|
20
|
+
const [filteredOptions, setFilteredOptions] = useState([]);
|
|
21
|
+
const [optionList, setOptionList] = useState([]);
|
|
22
|
+
const [focusedOption, setFocusedOption] = useState(null);
|
|
23
|
+
const optionsElementRef = useRef(null);
|
|
24
|
+
const [listBoxElement, setListBoxElement] = useState(null);
|
|
25
|
+
const [dropdownElement, setDropdownElement] = useState(null);
|
|
26
|
+
const [listBoxWidth, setListBoxWidth] = useState(0);
|
|
27
|
+
const {
|
|
28
|
+
styles,
|
|
29
|
+
attributes,
|
|
30
|
+
state,
|
|
31
|
+
update
|
|
32
|
+
} = useCustomPopper(listBoxElement, dropdownElement);
|
|
33
|
+
const handleKeyUp = event => {
|
|
34
|
+
const key = event.keyCode;
|
|
35
|
+
switch (key) {
|
|
36
|
+
case KEY_CODE.ENTER:
|
|
37
|
+
if (!displayListBox) {
|
|
38
|
+
handleDisplay();
|
|
39
|
+
} else if (focusedOption) {
|
|
40
|
+
handleClickOption(focusedOption.id);
|
|
41
|
+
}
|
|
42
|
+
break;
|
|
43
|
+
case KEY_CODE.ESCAPE:
|
|
44
|
+
setDisplayListBox(false);
|
|
45
|
+
break;
|
|
46
|
+
case KEY_CODE.UP:
|
|
47
|
+
{
|
|
48
|
+
if (!focusedOption) return;
|
|
49
|
+
const previousItem = findPreviousItem(focusedOption);
|
|
50
|
+
if (previousItem) {
|
|
51
|
+
handleFocusItem(previousItem);
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
case KEY_CODE.DOWN:
|
|
56
|
+
{
|
|
57
|
+
if (!focusedOption) return;
|
|
58
|
+
const nextItem = findNextItem(focusedOption);
|
|
59
|
+
if (nextItem) {
|
|
60
|
+
handleFocusItem(nextItem);
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
case KEY_CODE.HOME:
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
focusFirstItem();
|
|
67
|
+
break;
|
|
68
|
+
case KEY_CODE.END:
|
|
69
|
+
{
|
|
70
|
+
event.preventDefault();
|
|
71
|
+
const lastItem = dropdownElement.querySelectorAll('[role="option"]');
|
|
72
|
+
if (lastItem.length) {
|
|
73
|
+
handleFocusItem(lastItem[lastItem.length - 1]);
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
default:
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const handleKeyDown = event => {
|
|
82
|
+
const key = event.keyCode;
|
|
83
|
+
switch (key) {
|
|
84
|
+
case KEY_CODE.ENTER:
|
|
85
|
+
case KEY_CODE.ESCAPE:
|
|
86
|
+
case KEY_CODE.UP:
|
|
87
|
+
case KEY_CODE.DOWN:
|
|
88
|
+
case KEY_CODE.END:
|
|
89
|
+
case KEY_CODE.HOME:
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
break;
|
|
92
|
+
default:
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const findPreviousItem = useCallback(currentItem => {
|
|
97
|
+
const allItem = [...dropdownElement.querySelectorAll('[role="option"]')];
|
|
98
|
+
const currentItemIndex = allItem.indexOf(currentItem);
|
|
99
|
+
let previousItem = null;
|
|
100
|
+
if (currentItemIndex !== -1 && currentItemIndex > 0) {
|
|
101
|
+
previousItem = allItem[currentItemIndex - 1];
|
|
102
|
+
}
|
|
103
|
+
return previousItem;
|
|
104
|
+
}, [dropdownElement]);
|
|
105
|
+
const findNextItem = useCallback(currentItem => {
|
|
106
|
+
const allItem = [...dropdownElement.querySelectorAll('[role="option"]')];
|
|
107
|
+
const currentItemIndex = allItem.indexOf(currentItem);
|
|
108
|
+
let nextItem = null;
|
|
109
|
+
if (currentItemIndex !== -1 && currentItemIndex !== allItem.length - 1) {
|
|
110
|
+
nextItem = allItem[currentItemIndex + 1];
|
|
111
|
+
}
|
|
112
|
+
return nextItem;
|
|
113
|
+
}, [dropdownElement]);
|
|
114
|
+
|
|
115
|
+
// set focused option
|
|
116
|
+
const handleFocusItem = useCallback(element => {
|
|
117
|
+
if (!optionsElementRef.current) return;
|
|
118
|
+
setFocusedOption(element);
|
|
119
|
+
}, []);
|
|
120
|
+
const focusFirstItem = useCallback(() => {
|
|
121
|
+
const firstItem = dropdownElement.querySelector('[role="option"]');
|
|
122
|
+
if (firstItem) {
|
|
123
|
+
handleFocusItem(firstItem);
|
|
124
|
+
}
|
|
125
|
+
}, [dropdownElement, handleFocusItem]);
|
|
126
|
+
const setupFocus = useCallback(() => {
|
|
127
|
+
if (!dropdownElement) return;
|
|
128
|
+
const selectedItem = dropdownElement.querySelector('[aria-selected="true"]');
|
|
129
|
+
if (selectedItem) {
|
|
130
|
+
handleFocusItem(selectedItem);
|
|
131
|
+
} else if (optionList.length > 0) {
|
|
132
|
+
focusFirstItem();
|
|
133
|
+
}
|
|
134
|
+
}, [dropdownElement, focusFirstItem, handleFocusItem, optionList]);
|
|
135
|
+
const handleDisplay = () => {
|
|
136
|
+
if (filteredOptions.length > 0) {
|
|
137
|
+
setDisplayListBox(true);
|
|
138
|
+
update();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const handleClickOption = useCallback(packageName => {
|
|
142
|
+
if (disabled === true) return;
|
|
143
|
+
onSelect(packageName);
|
|
144
|
+
setDisplayListBox(false);
|
|
145
|
+
}, [onSelect, disabled]);
|
|
146
|
+
|
|
147
|
+
// all option
|
|
148
|
+
const optionItem = useMemo(() => {
|
|
149
|
+
return optionList.map(option => /*#__PURE__*/_jsx(Option, {
|
|
150
|
+
role: "option",
|
|
151
|
+
tabIndex: "0",
|
|
152
|
+
id: option.package_name,
|
|
153
|
+
selected: option.selected,
|
|
154
|
+
"aria-selected": option.selected,
|
|
155
|
+
onClick: () => {
|
|
156
|
+
handleClickOption(option.package_name);
|
|
157
|
+
},
|
|
158
|
+
focus: focusedOption && focusedOption.id === option.package_name.toString(),
|
|
159
|
+
children: option.package_name
|
|
160
|
+
}, option.package_name));
|
|
161
|
+
}, [optionList, handleClickOption, focusedOption]);
|
|
162
|
+
|
|
163
|
+
// parse all value to string
|
|
164
|
+
// for subsequently determine whether it is a selected item
|
|
165
|
+
const parsedSelected = useMemo(() => {
|
|
166
|
+
if (value || value === 0) {
|
|
167
|
+
return value.toString();
|
|
168
|
+
}
|
|
169
|
+
}, [value]);
|
|
170
|
+
|
|
171
|
+
// observe element resized
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
if (!listBoxElement) return;
|
|
174
|
+
setListBoxWidth(listBoxElement.clientWidth);
|
|
175
|
+
}, [listBoxElement]);
|
|
176
|
+
|
|
177
|
+
// 過濾搜尋關鍵字資料
|
|
178
|
+
useEffect(() => {
|
|
179
|
+
if (!options.length) return;
|
|
180
|
+
const tmpFilteredChildOptions = options.filter(option => {
|
|
181
|
+
return option.package_name.toLowerCase().includes(value.toLowerCase());
|
|
182
|
+
});
|
|
183
|
+
setFilteredOptions(tmpFilteredChildOptions);
|
|
184
|
+
}, [options, value]);
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
if (update) {
|
|
187
|
+
setTimeout(() => {
|
|
188
|
+
update();
|
|
189
|
+
}, 100);
|
|
190
|
+
}
|
|
191
|
+
}, [update, listBoxWidth]);
|
|
192
|
+
|
|
193
|
+
// observe element resized
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
if (!listBoxElement) return;
|
|
196
|
+
const resizeObserverInstance = new ResizeObserver(entries => {
|
|
197
|
+
for (const entry of entries) {
|
|
198
|
+
if (entry.target) {
|
|
199
|
+
const borderBoxSize = entry.target.clientWidth;
|
|
200
|
+
setListBoxWidth(borderBoxSize);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
resizeObserverInstance.observe(listBoxElement);
|
|
205
|
+
return () => {
|
|
206
|
+
resizeObserverInstance.unobserve(listBoxElement);
|
|
207
|
+
};
|
|
208
|
+
}, [listBoxElement]);
|
|
209
|
+
useEffect(() => {
|
|
210
|
+
let selected = false;
|
|
211
|
+
setOptionList(filteredOptions.map(option => {
|
|
212
|
+
if (parsedSelected === option.package_name) {
|
|
213
|
+
selected = true;
|
|
214
|
+
} else {
|
|
215
|
+
selected = false;
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
...option,
|
|
219
|
+
selected
|
|
220
|
+
};
|
|
221
|
+
}));
|
|
222
|
+
}, [filteredOptions, parsedSelected]);
|
|
223
|
+
useEffect(() => {
|
|
224
|
+
if (displayListBox) {
|
|
225
|
+
setupFocus();
|
|
226
|
+
}
|
|
227
|
+
}, [displayListBox, setupFocus, value]);
|
|
228
|
+
return /*#__PURE__*/_jsxs(OutsideClickHandler, {
|
|
229
|
+
onOutsideClick: () => {
|
|
230
|
+
setDisplayListBox(false);
|
|
231
|
+
},
|
|
232
|
+
children: [/*#__PURE__*/_jsx(Input, {
|
|
233
|
+
autoComplete: "off",
|
|
234
|
+
...props,
|
|
235
|
+
onChange: event => {
|
|
236
|
+
onChange(event);
|
|
237
|
+
if (!displayListBox) setDisplayListBox(true);
|
|
238
|
+
},
|
|
239
|
+
value: value,
|
|
240
|
+
ref: setListBoxElement,
|
|
241
|
+
...attributes.popper,
|
|
242
|
+
placement: state && state.placement,
|
|
243
|
+
onClick: handleDisplay,
|
|
244
|
+
onKeyUp: handleKeyUp,
|
|
245
|
+
onFocus: () => {
|
|
246
|
+
setDisplayListBox(true);
|
|
247
|
+
},
|
|
248
|
+
onKeyDown: handleKeyDown
|
|
249
|
+
}), optionItem.length > 0 && /*#__PURE__*/_jsx(ListBox, {
|
|
250
|
+
style: styles.popper,
|
|
251
|
+
$display: displayListBox,
|
|
252
|
+
ref: setDropdownElement,
|
|
253
|
+
width: listBoxWidth,
|
|
254
|
+
onKeyUp: handleKeyUp,
|
|
255
|
+
onKeyDown: handleKeyDown,
|
|
256
|
+
children: /*#__PURE__*/_jsx(Options, {
|
|
257
|
+
ref: optionsElementRef,
|
|
258
|
+
children: optionItem
|
|
259
|
+
})
|
|
260
|
+
})]
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
export default InputSelect;
|