@cashub/ui 0.20.0 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Tab/Tab.js +9 -13
- package/Tab/TabList.js +14 -32
- package/Tab/TabPanel.js +21 -58
- package/Tab/TabTab.js +20 -40
- package/Tab/index.js +2 -10
- package/Tab/subComponent/TabContext.js +2 -5
- package/animate/Collapse.js +26 -53
- package/animate/Loader.js +21 -26
- package/animate/NumberCounter.js +22 -44
- package/animate/PulseRing.js +9 -21
- package/animate/Spinner.js +2 -10
- package/animate/index.js +5 -11
- package/assets/css/autocomplete.css +16 -16
- package/assets/css/font.css +4 -4
- package/assets/css/global.css +3 -3
- package/assets/css/normalize.css +386 -386
- package/backdrop/BaseBackdrop.js +2 -9
- package/backdrop/LoadingBackdrop.js +2 -9
- package/backdrop/ModalBackdrop.js +2 -9
- package/backdrop/index.js +3 -7
- package/badge/Badge.js +2 -11
- package/badge/BadgeDot.js +2 -10
- package/badge/BadgeFill.js +15 -20
- package/badge/BadgeWithText.js +6 -13
- package/badge/index.js +4 -9
- package/billing/BarChart.js +10 -17
- package/billing/Grid.js +11 -15
- package/billing/Header2.js +6 -9
- package/billing/Header3.js +9 -16
- package/billing/Paragraph.js +8 -14
- package/billing/ParagraphGroup.js +6 -9
- package/billing/ParagraphText.js +7 -12
- package/billing/Section.js +13 -23
- package/billing/SectionBody.js +5 -8
- package/billing/SectionHeader.js +7 -12
- package/breadcrumb/Breadcrumb.js +11 -21
- package/breadcrumb/index.js +1 -3
- package/button/Button.js +41 -38
- package/button/ButtonGroup.js +21 -18
- package/button/IconButton.js +29 -29
- package/button/ScrollToTopButton.js +12 -39
- package/button/index.js +4 -9
- package/callout/Callout.js +13 -26
- package/callout/index.js +1 -3
- package/chart/BarChart.js +28 -53
- package/chart/DoughnutChart.js +23 -62
- package/chart/LineChart.js +33 -55
- package/chart/SingleBarChart.js +11 -17
- package/chart/index.js +5 -12
- package/chart/utils/customTooltip.js +26 -43
- package/chart/utils/htmlLegendPlugin.js +24 -30
- package/chart/utils/index.js +3 -7
- package/chart/utils/padEmptyChartBar.js +24 -22
- package/container/FlexContainer.js +9 -12
- package/container/index.js +1 -3
- package/cropper/Cropper.js +21 -34
- package/cropper/CropperModalHandler.js +15 -21
- package/cropper/index.js +2 -5
- package/cropper/subComponent/CropImageModal.js +23 -58
- package/datetimePicker/DatePicker.js +103 -217
- package/datetimePicker/DatePickerV2.js +116 -221
- package/datetimePicker/DatetimePicker.js +27 -48
- package/datetimePicker/DatetimePickerV2.js +115 -231
- package/datetimePicker/TimeInput.js +9 -22
- package/datetimePicker/TimePicker.js +94 -151
- package/datetimePicker/TimePickerStyle.js +14 -0
- package/datetimePicker/accordion/Month.js +70 -90
- package/datetimePicker/accordion/Year.js +91 -135
- package/datetimePicker/hooks/index.js +3 -7
- package/datetimePicker/hooks/useChangeNumber.js +14 -27
- package/datetimePicker/hooks/useDecrease.js +19 -35
- package/datetimePicker/hooks/useIncrease.js +19 -35
- package/datetimePicker/index.js +13 -13
- package/datetimePicker/provider/constant.js +2 -3
- package/datetimePicker/subComponent/Accordion.js +108 -158
- package/datetimePicker/subComponent/CustomTimeInput.js +18 -48
- package/datetimePicker/subComponent/DateTimePickerContext.js +2 -5
- package/datetimePicker/utils/GMTDate.js +3 -7
- package/datetimePicker/utils/pad.js +2 -6
- package/datetimePicker/utils/toUTC0.js +3 -6
- package/descriptionList/DescriptionDetail.js +5 -10
- package/descriptionList/DescriptionList.js +5 -10
- package/descriptionList/DescriptionTerm.js +2 -9
- package/descriptionList/index.js +3 -7
- package/divider/Divider.js +9 -12
- package/divider/index.js +1 -3
- package/dropdown/Dropdown.js +28 -65
- package/dropdown/DropdownButtonOption.js +2 -9
- package/dropdown/DropdownContent.js +33 -64
- package/dropdown/DropdownDivOption.js +2 -9
- package/dropdown/DropdownItem.js +10 -16
- package/dropdown/DropdownLinkOption.js +2 -9
- package/dropdown/DropdownToggle.js +18 -38
- package/dropdown/index.js +6 -17
- package/dropdown/subComponent/DropdownContext.js +2 -5
- package/dropzone/FileDropzone.js +148 -302
- package/dropzone/ImageDropzone.js +96 -171
- package/dropzone/index.js +2 -5
- package/dropzone/subComponent/Message.js +7 -14
- package/figure/IconFigure.js +9 -16
- package/figure/ImageFigure.js +11 -17
- package/figure/index.js +2 -5
- package/file/HiddenFileInput.js +5 -14
- package/file/index.js +1 -3
- package/form/Checkbox.js +34 -43
- package/form/FormItem.js +2 -9
- package/form/Input.js +13 -15
- package/form/Label.js +10 -13
- package/form/MutedText.js +5 -10
- package/form/RadioButton.js +20 -32
- package/form/Searchbox.js +21 -65
- package/form/Slider.js +14 -0
- package/form/SwitchButton.js +34 -39
- package/form/Textarea.js +2 -11
- package/form/index.js +9 -19
- package/grid/Column.js +17 -17
- package/grid/Grid.js +13 -14
- package/grid/index.js +2 -5
- package/heading/Heading1.js +5 -10
- package/heading/Heading2.js +9 -12
- package/heading/Heading3.js +21 -18
- package/heading/index.js +3 -7
- package/helmet/Helmet.js +6 -9
- package/helmet/index.js +2 -5
- package/iconbox/ApplicationIconBox.js +25 -31
- package/iconbox/IconBox.js +11 -24
- package/iconbox/IconBoxV2.js +14 -26
- package/iconbox/index.js +3 -7
- package/iconbox/subComponent/IconBoxFigure.js +25 -20
- package/iconbox/subComponent/IconBoxImage.js +15 -18
- package/image/ImageFluid.js +2 -10
- package/image/UploadImage.js +65 -113
- package/image/index.js +2 -5
- package/index.js +44 -130
- package/jsoneditor/JsonEditor.js +10 -32
- package/jsoneditor/index.js +1 -3
- package/keyframe/Pulse.js +2 -7
- package/keyframe/Spin.js +2 -7
- package/link/LinkSpan.js +22 -35
- package/link/index.js +1 -3
- package/map/GoogleMap.js +122 -175
- package/map/GoogleReverseGeolocation.js +79 -186
- package/map/LeafletMap.js +78 -132
- package/map/LeafletReverseGeolocation.js +49 -121
- package/map/index.js +4 -9
- package/map/subComponent/BasicLeafletMap.js +8 -14
- package/map/subComponent/GoogleMapContainer.js +5 -10
- package/map/subComponent/GoogleMapPopup.js +66 -123
- package/map/subComponent/GoogleMapWrapper.js +13 -32
- package/map/subComponent/GoogleMarkerSpiderfier.js +14 -24
- package/map/subComponent/LeafletDrawControl.js +47 -84
- package/map/subComponent/LeafletMapContainer.js +5 -10
- package/map/subComponent/MapSearchBoxControl.js +24 -70
- package/modal/StateModal.js +41 -100
- package/modal/TitleModal.js +89 -190
- package/modal/index.js +2 -5
- package/package.json +1 -1
- package/paginate/Paginate.js +40 -54
- package/paginate/index.js +1 -3
- package/popover/Popover.js +39 -87
- package/popover/index.js +1 -3
- package/qrcode/QRCode.js +10 -23
- package/qrcode/QRCodeContainter.js +8 -16
- package/qrcode/index.js +2 -5
- package/ribbon/Ribbon.js +4 -15
- package/ribbon/index.js +1 -3
- package/section/Section.js +57 -39
- package/section/SectionBody.js +15 -22
- package/section/SectionHeader.js +27 -27
- package/section/SectionToolbar.js +2 -9
- package/section/SectionToolbarItem.js +2 -9
- package/section/index.js +5 -11
- package/select/InputSelect.js +103 -215
- package/select/Select.js +204 -362
- package/select/index.js +2 -5
- package/select/subComponent/ListBox.js +9 -12
- package/select/subComponent/Option.js +8 -16
- package/select/subComponent/OptionGroup.js +2 -9
- package/select/subComponent/Options.js +5 -11
- package/select/subComponent/SearchBox.js +9 -29
- package/select/subComponent/SelectedMultiple.js +8 -16
- package/select/subComponent/SelectedSingle.js +2 -9
- package/styles/GlobalStyle.js +169 -91
- package/styles/config/breakpoint.style.js +2 -3
- package/styles/config/header.style.js +2 -3
- package/styles/config/sidebar.style.js +2 -3
- package/styles/index.js +2 -5
- package/styles/mixin/backgroundColor.js +17 -14
- package/styles/mixin/borderColor.js +17 -14
- package/styles/mixin/color.js +17 -14
- package/styles/mixin/colorOnBackground.js +17 -14
- package/styles/mixin/inputPlaceholder.js +3 -9
- package/styles/mixin/media.js +3 -11
- package/styles/mixin/rounded.js +13 -12
- package/styles/mixin/scrollbar.js +7 -13
- package/styles/theme/dark.theme.js +20 -20
- package/styles/theme/light.theme.js +20 -20
- package/styles/theme/white.theme.js +20 -20
- package/styles/themes.js +2 -8
- package/table/GridTable.js +105 -143
- package/table/ImageBox.js +8 -18
- package/table/PermissionTable.js +25 -25
- package/table/Table.js +137 -153
- package/table/__mock__/columns.js +2 -3
- package/table/__mock__/data.js +2 -3
- package/table/hooks/index.js +2 -5
- package/table/hooks/useCalculateDataRange.js +9 -36
- package/table/hooks/useGenerateSort.js +6 -17
- package/table/index.js +4 -9
- package/table/subComponent/BaseTableHeadCell.js +15 -21
- package/table/subComponent/GridTableFooter.js +5 -10
- package/table/subComponent/GridTableHeadCell.js +5 -10
- package/table/subComponent/Resizer.js +17 -44
- package/table/subComponent/TableFooter.js +5 -10
- package/table/subComponent/TableFooterInfo.js +2 -9
- package/table/subComponent/TableFooterPager.js +5 -12
- package/table/subComponent/TableHeadCell.js +2 -9
- package/table/subComponent/TableSort.js +13 -19
- package/tagify/TagifyStyle.js +14 -0
- package/tagify/Tags.js +15 -37
- package/tagify/index.js +8 -3
- package/text/Paragraph.js +25 -20
- package/text/index.js +1 -3
- package/timeline/Timeline.js +28 -37
- package/timeline/index.js +1 -3
- package/toast/CustomToastContainer.js +2 -9
- package/toast/MessageContainer.js +9 -18
- package/toast/index.js +3 -8
- package/toast/show.js +18 -28
- package/tooltip/Tooltip.js +48 -97
- package/tooltip/index.js +1 -3
- package/wizard/Wizard.js +63 -133
- package/wizard/index.js +1 -3
|
@@ -4,16 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
|
|
10
8
|
var _templateObject;
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
var _default = SectionToolbarItem;
|
|
19
|
-
exports.default = _default;
|
|
11
|
+
const SectionToolbarItem = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n\n > *:not(:first-child) {\n margin-left: var(--spacing-s);\n }\n"])));
|
|
12
|
+
var _default = exports.default = SectionToolbarItem;
|
package/section/index.js
CHANGED
|
@@ -5,43 +5,37 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "Section", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: function
|
|
8
|
+
get: function () {
|
|
9
9
|
return _Section.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "SectionBody", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function
|
|
14
|
+
get: function () {
|
|
15
15
|
return _SectionBody.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "SectionHeader", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function
|
|
20
|
+
get: function () {
|
|
21
21
|
return _SectionHeader.default;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "SectionToolbar", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function
|
|
26
|
+
get: function () {
|
|
27
27
|
return _SectionToolbar.default;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "SectionToolbarItem", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function
|
|
32
|
+
get: function () {
|
|
33
33
|
return _SectionToolbarItem.default;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
|
|
37
36
|
var _Section = _interopRequireDefault(require("./Section"));
|
|
38
|
-
|
|
39
37
|
var _SectionBody = _interopRequireDefault(require("./SectionBody"));
|
|
40
|
-
|
|
41
38
|
var _SectionHeader = _interopRequireDefault(require("./SectionHeader"));
|
|
42
|
-
|
|
43
39
|
var _SectionToolbar = _interopRequireDefault(require("./SectionToolbar"));
|
|
44
|
-
|
|
45
40
|
var _SectionToolbarItem = _interopRequireDefault(require("./SectionToolbarItem"));
|
|
46
|
-
|
|
47
41
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/select/InputSelect.js
CHANGED
|
@@ -4,116 +4,41 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _reactOutsideClickHandler = _interopRequireDefault(require("react-outside-click-handler"));
|
|
11
|
-
|
|
12
9
|
var _hooks = require("@cashub/hooks");
|
|
13
|
-
|
|
14
10
|
var _utils = require("@cashub/utils");
|
|
15
|
-
|
|
16
11
|
var _Input = _interopRequireDefault(require("../form/Input"));
|
|
17
|
-
|
|
18
12
|
var _ListBox = _interopRequireDefault(require("./subComponent/ListBox"));
|
|
19
|
-
|
|
20
13
|
var _Option = _interopRequireDefault(require("./subComponent/Option"));
|
|
21
|
-
|
|
22
14
|
var _Options = _interopRequireDefault(require("./subComponent/Options"));
|
|
23
|
-
|
|
24
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
|
-
|
|
26
|
-
var _excluded = ["options", "value", "disabled", "onChange", "onSelect"];
|
|
27
|
-
|
|
28
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
55
|
-
|
|
56
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
57
|
-
|
|
58
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
59
|
-
|
|
60
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
61
|
-
|
|
62
|
-
var InputSelect = function InputSelect(_ref) {
|
|
63
|
-
var _ref$options = _ref.options,
|
|
64
|
-
options = _ref$options === void 0 ? [] : _ref$options,
|
|
65
|
-
value = _ref.value,
|
|
66
|
-
disabled = _ref.disabled,
|
|
67
|
-
_onChange = _ref.onChange,
|
|
68
|
-
onSelect = _ref.onSelect,
|
|
69
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
70
|
-
|
|
71
|
-
var _useState = (0, _react.useState)(false),
|
|
72
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
73
|
-
displayListBox = _useState2[0],
|
|
74
|
-
setDisplayListBox = _useState2[1];
|
|
75
|
-
|
|
76
|
-
var _useState3 = (0, _react.useState)([]),
|
|
77
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
78
|
-
filteredOptions = _useState4[0],
|
|
79
|
-
setFilteredOptions = _useState4[1];
|
|
80
|
-
|
|
81
|
-
var _useState5 = (0, _react.useState)([]),
|
|
82
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
83
|
-
optionList = _useState6[0],
|
|
84
|
-
setOptionList = _useState6[1];
|
|
85
|
-
|
|
86
|
-
var _useState7 = (0, _react.useState)(null),
|
|
87
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
88
|
-
focusedOption = _useState8[0],
|
|
89
|
-
setFocusedOption = _useState8[1];
|
|
90
|
-
|
|
91
|
-
var optionsElementRef = (0, _react.useRef)(null);
|
|
92
|
-
|
|
93
|
-
var _useState9 = (0, _react.useState)(null),
|
|
94
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
95
|
-
listBoxElement = _useState10[0],
|
|
96
|
-
setListBoxElement = _useState10[1];
|
|
97
|
-
|
|
98
|
-
var _useState11 = (0, _react.useState)(null),
|
|
99
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
100
|
-
dropdownElement = _useState12[0],
|
|
101
|
-
setDropdownElement = _useState12[1];
|
|
102
|
-
|
|
103
|
-
var _useState13 = (0, _react.useState)(0),
|
|
104
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
105
|
-
listBoxWidth = _useState14[0],
|
|
106
|
-
setListBoxWidth = _useState14[1];
|
|
107
|
-
|
|
108
|
-
var _useCustomPopper = (0, _hooks.useCustomPopper)(listBoxElement, dropdownElement),
|
|
109
|
-
styles = _useCustomPopper.styles,
|
|
110
|
-
attributes = _useCustomPopper.attributes,
|
|
111
|
-
state = _useCustomPopper.state,
|
|
112
|
-
update = _useCustomPopper.update;
|
|
113
|
-
|
|
114
|
-
var handleKeyUp = function handleKeyUp(event) {
|
|
115
|
-
var key = event.keyCode;
|
|
116
|
-
|
|
17
|
+
const InputSelect = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
options = [],
|
|
20
|
+
value,
|
|
21
|
+
disabled,
|
|
22
|
+
onChange,
|
|
23
|
+
onSelect,
|
|
24
|
+
...props
|
|
25
|
+
} = _ref;
|
|
26
|
+
const [displayListBox, setDisplayListBox] = (0, _react.useState)(false);
|
|
27
|
+
const [filteredOptions, setFilteredOptions] = (0, _react.useState)([]);
|
|
28
|
+
const [optionList, setOptionList] = (0, _react.useState)([]);
|
|
29
|
+
const [focusedOption, setFocusedOption] = (0, _react.useState)(null);
|
|
30
|
+
const optionsElementRef = (0, _react.useRef)(null);
|
|
31
|
+
const [listBoxElement, setListBoxElement] = (0, _react.useState)(null);
|
|
32
|
+
const [dropdownElement, setDropdownElement] = (0, _react.useState)(null);
|
|
33
|
+
const [listBoxWidth, setListBoxWidth] = (0, _react.useState)(0);
|
|
34
|
+
const {
|
|
35
|
+
styles,
|
|
36
|
+
attributes,
|
|
37
|
+
state,
|
|
38
|
+
update
|
|
39
|
+
} = (0, _hooks.useCustomPopper)(listBoxElement, dropdownElement);
|
|
40
|
+
const handleKeyUp = event => {
|
|
41
|
+
const key = event.keyCode;
|
|
117
42
|
switch (key) {
|
|
118
43
|
case _utils.KEY_CODE.ENTER:
|
|
119
44
|
if (!displayListBox) {
|
|
@@ -121,62 +46,47 @@ var InputSelect = function InputSelect(_ref) {
|
|
|
121
46
|
} else if (focusedOption) {
|
|
122
47
|
handleClickOption(focusedOption.id);
|
|
123
48
|
}
|
|
124
|
-
|
|
125
49
|
break;
|
|
126
|
-
|
|
127
50
|
case _utils.KEY_CODE.ESCAPE:
|
|
128
51
|
setDisplayListBox(false);
|
|
129
52
|
break;
|
|
130
|
-
|
|
131
53
|
case _utils.KEY_CODE.UP:
|
|
132
54
|
{
|
|
133
55
|
if (!focusedOption) return;
|
|
134
|
-
|
|
135
|
-
|
|
56
|
+
const previousItem = findPreviousItem(focusedOption);
|
|
136
57
|
if (previousItem) {
|
|
137
58
|
handleFocusItem(previousItem);
|
|
138
59
|
}
|
|
139
|
-
|
|
140
60
|
break;
|
|
141
61
|
}
|
|
142
|
-
|
|
143
62
|
case _utils.KEY_CODE.DOWN:
|
|
144
63
|
{
|
|
145
64
|
if (!focusedOption) return;
|
|
146
|
-
|
|
147
|
-
|
|
65
|
+
const nextItem = findNextItem(focusedOption);
|
|
148
66
|
if (nextItem) {
|
|
149
67
|
handleFocusItem(nextItem);
|
|
150
68
|
}
|
|
151
|
-
|
|
152
69
|
break;
|
|
153
70
|
}
|
|
154
|
-
|
|
155
71
|
case _utils.KEY_CODE.HOME:
|
|
156
72
|
event.preventDefault();
|
|
157
73
|
focusFirstItem();
|
|
158
74
|
break;
|
|
159
|
-
|
|
160
75
|
case _utils.KEY_CODE.END:
|
|
161
76
|
{
|
|
162
77
|
event.preventDefault();
|
|
163
|
-
|
|
164
|
-
|
|
78
|
+
const lastItem = dropdownElement.querySelectorAll('[role="option"]');
|
|
165
79
|
if (lastItem.length) {
|
|
166
80
|
handleFocusItem(lastItem[lastItem.length - 1]);
|
|
167
81
|
}
|
|
168
|
-
|
|
169
82
|
break;
|
|
170
83
|
}
|
|
171
|
-
|
|
172
84
|
default:
|
|
173
85
|
break;
|
|
174
86
|
}
|
|
175
87
|
};
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
var key = event.keyCode;
|
|
179
|
-
|
|
88
|
+
const handleKeyDown = event => {
|
|
89
|
+
const key = event.keyCode;
|
|
180
90
|
switch (key) {
|
|
181
91
|
case _utils.KEY_CODE.ENTER:
|
|
182
92
|
case _utils.KEY_CODE.ESCAPE:
|
|
@@ -186,184 +96,164 @@ var InputSelect = function InputSelect(_ref) {
|
|
|
186
96
|
case _utils.KEY_CODE.HOME:
|
|
187
97
|
event.preventDefault();
|
|
188
98
|
break;
|
|
189
|
-
|
|
190
99
|
default:
|
|
191
100
|
break;
|
|
192
101
|
}
|
|
193
102
|
};
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
var currentItemIndex = allItem.indexOf(currentItem);
|
|
199
|
-
var previousItem = null;
|
|
200
|
-
|
|
103
|
+
const findPreviousItem = (0, _react.useCallback)(currentItem => {
|
|
104
|
+
const allItem = [...dropdownElement.querySelectorAll('[role="option"]')];
|
|
105
|
+
const currentItemIndex = allItem.indexOf(currentItem);
|
|
106
|
+
let previousItem = null;
|
|
201
107
|
if (currentItemIndex !== -1 && currentItemIndex > 0) {
|
|
202
108
|
previousItem = allItem[currentItemIndex - 1];
|
|
203
109
|
}
|
|
204
|
-
|
|
205
110
|
return previousItem;
|
|
206
111
|
}, [dropdownElement]);
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
var nextItem = null;
|
|
212
|
-
|
|
112
|
+
const findNextItem = (0, _react.useCallback)(currentItem => {
|
|
113
|
+
const allItem = [...dropdownElement.querySelectorAll('[role="option"]')];
|
|
114
|
+
const currentItemIndex = allItem.indexOf(currentItem);
|
|
115
|
+
let nextItem = null;
|
|
213
116
|
if (currentItemIndex !== -1 && currentItemIndex !== allItem.length - 1) {
|
|
214
117
|
nextItem = allItem[currentItemIndex + 1];
|
|
215
118
|
}
|
|
216
|
-
|
|
217
119
|
return nextItem;
|
|
218
|
-
}, [dropdownElement]);
|
|
120
|
+
}, [dropdownElement]);
|
|
219
121
|
|
|
220
|
-
|
|
122
|
+
// set focused option
|
|
123
|
+
const handleFocusItem = (0, _react.useCallback)(element => {
|
|
221
124
|
if (!optionsElementRef.current) return;
|
|
222
125
|
setFocusedOption(element);
|
|
223
126
|
}, []);
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
127
|
+
const focusFirstItem = (0, _react.useCallback)(() => {
|
|
128
|
+
const firstItem = dropdownElement.querySelector('[role="option"]');
|
|
227
129
|
if (firstItem) {
|
|
228
130
|
handleFocusItem(firstItem);
|
|
229
131
|
}
|
|
230
132
|
}, [dropdownElement, handleFocusItem]);
|
|
231
|
-
|
|
133
|
+
const setupFocus = (0, _react.useCallback)(() => {
|
|
232
134
|
if (!dropdownElement) return;
|
|
233
|
-
|
|
234
|
-
|
|
135
|
+
const selectedItem = dropdownElement.querySelector('[aria-selected="true"]');
|
|
235
136
|
if (selectedItem) {
|
|
236
137
|
handleFocusItem(selectedItem);
|
|
237
138
|
} else if (optionList.length > 0) {
|
|
238
139
|
focusFirstItem();
|
|
239
140
|
}
|
|
240
141
|
}, [dropdownElement, focusFirstItem, handleFocusItem, optionList]);
|
|
241
|
-
|
|
242
|
-
var handleDisplay = function handleDisplay() {
|
|
142
|
+
const handleDisplay = () => {
|
|
243
143
|
if (filteredOptions.length > 0) {
|
|
244
144
|
setDisplayListBox(true);
|
|
245
145
|
update();
|
|
246
146
|
}
|
|
247
147
|
};
|
|
248
|
-
|
|
249
|
-
var handleClickOption = (0, _react.useCallback)(function (packageName) {
|
|
148
|
+
const handleClickOption = (0, _react.useCallback)(packageName => {
|
|
250
149
|
if (disabled === true) return;
|
|
251
150
|
onSelect(packageName);
|
|
252
151
|
setDisplayListBox(false);
|
|
253
|
-
}, [onSelect, disabled]);
|
|
152
|
+
}, [onSelect, disabled]);
|
|
153
|
+
|
|
154
|
+
// all option
|
|
155
|
+
const optionItem = (0, _react.useMemo)(() => {
|
|
156
|
+
return optionList.map(option => /*#__PURE__*/(0, _jsxRuntime.jsx)(_Option.default, {
|
|
157
|
+
role: "option",
|
|
158
|
+
tabIndex: "0",
|
|
159
|
+
id: option.package_name,
|
|
160
|
+
selected: option.selected,
|
|
161
|
+
"aria-selected": option.selected,
|
|
162
|
+
onClick: () => {
|
|
163
|
+
handleClickOption(option.package_name);
|
|
164
|
+
},
|
|
165
|
+
focus: focusedOption && focusedOption.id === option.package_name.toString(),
|
|
166
|
+
children: option.package_name
|
|
167
|
+
}, option.package_name));
|
|
168
|
+
}, [optionList, handleClickOption, focusedOption]);
|
|
254
169
|
|
|
255
|
-
|
|
256
|
-
return optionList.map(function (option) {
|
|
257
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Option.default, {
|
|
258
|
-
role: "option",
|
|
259
|
-
tabIndex: "0",
|
|
260
|
-
id: option.package_name,
|
|
261
|
-
selected: option.selected,
|
|
262
|
-
"aria-selected": option.selected,
|
|
263
|
-
onClick: function onClick() {
|
|
264
|
-
handleClickOption(option.package_name);
|
|
265
|
-
},
|
|
266
|
-
focus: focusedOption && focusedOption.id === option.package_name.toString(),
|
|
267
|
-
children: option.package_name
|
|
268
|
-
}, option.package_name);
|
|
269
|
-
});
|
|
270
|
-
}, [optionList, handleClickOption, focusedOption]); // parse all value to string
|
|
170
|
+
// parse all value to string
|
|
271
171
|
// for subsequently determine whether it is a selected item
|
|
272
|
-
|
|
273
|
-
var parsedSelected = (0, _react.useMemo)(function () {
|
|
172
|
+
const parsedSelected = (0, _react.useMemo)(() => {
|
|
274
173
|
if (value || value === 0) {
|
|
275
174
|
return value.toString();
|
|
276
175
|
}
|
|
277
|
-
}, [value]);
|
|
176
|
+
}, [value]);
|
|
278
177
|
|
|
279
|
-
|
|
178
|
+
// observe element resized
|
|
179
|
+
(0, _react.useEffect)(() => {
|
|
280
180
|
if (!listBoxElement) return;
|
|
281
181
|
setListBoxWidth(listBoxElement.clientWidth);
|
|
282
|
-
}, [listBoxElement]);
|
|
182
|
+
}, [listBoxElement]);
|
|
283
183
|
|
|
284
|
-
|
|
184
|
+
// 過濾搜尋關鍵字資料
|
|
185
|
+
(0, _react.useEffect)(() => {
|
|
285
186
|
if (!options.length) return;
|
|
286
|
-
|
|
187
|
+
const tmpFilteredChildOptions = options.filter(option => {
|
|
287
188
|
return option.package_name.toLowerCase().includes(value.toLowerCase());
|
|
288
189
|
});
|
|
289
190
|
setFilteredOptions(tmpFilteredChildOptions);
|
|
290
191
|
}, [options, value]);
|
|
291
|
-
(0, _react.useEffect)(
|
|
192
|
+
(0, _react.useEffect)(() => {
|
|
292
193
|
if (update) {
|
|
293
|
-
setTimeout(
|
|
194
|
+
setTimeout(() => {
|
|
294
195
|
update();
|
|
295
196
|
}, 100);
|
|
296
197
|
}
|
|
297
|
-
}, [update, listBoxWidth]);
|
|
198
|
+
}, [update, listBoxWidth]);
|
|
298
199
|
|
|
299
|
-
|
|
200
|
+
// observe element resized
|
|
201
|
+
(0, _react.useEffect)(() => {
|
|
300
202
|
if (!listBoxElement) return;
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
307
|
-
var entry = _step.value;
|
|
308
|
-
|
|
309
|
-
if (entry.target) {
|
|
310
|
-
var borderBoxSize = entry.target.clientWidth;
|
|
311
|
-
setListBoxWidth(borderBoxSize);
|
|
312
|
-
}
|
|
203
|
+
const resizeObserverInstance = new ResizeObserver(entries => {
|
|
204
|
+
for (const entry of entries) {
|
|
205
|
+
if (entry.target) {
|
|
206
|
+
const borderBoxSize = entry.target.clientWidth;
|
|
207
|
+
setListBoxWidth(borderBoxSize);
|
|
313
208
|
}
|
|
314
|
-
} catch (err) {
|
|
315
|
-
_iterator.e(err);
|
|
316
|
-
} finally {
|
|
317
|
-
_iterator.f();
|
|
318
209
|
}
|
|
319
210
|
});
|
|
320
211
|
resizeObserverInstance.observe(listBoxElement);
|
|
321
|
-
return
|
|
212
|
+
return () => {
|
|
322
213
|
resizeObserverInstance.unobserve(listBoxElement);
|
|
323
214
|
};
|
|
324
215
|
}, [listBoxElement]);
|
|
325
|
-
(0, _react.useEffect)(
|
|
326
|
-
|
|
327
|
-
setOptionList(filteredOptions.map(
|
|
216
|
+
(0, _react.useEffect)(() => {
|
|
217
|
+
let selected = false;
|
|
218
|
+
setOptionList(filteredOptions.map(option => {
|
|
328
219
|
if (parsedSelected === option.package_name) {
|
|
329
220
|
selected = true;
|
|
330
221
|
} else {
|
|
331
222
|
selected = false;
|
|
332
223
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
selected
|
|
336
|
-
}
|
|
224
|
+
return {
|
|
225
|
+
...option,
|
|
226
|
+
selected
|
|
227
|
+
};
|
|
337
228
|
}));
|
|
338
229
|
}, [filteredOptions, parsedSelected]);
|
|
339
|
-
(0, _react.useEffect)(
|
|
230
|
+
(0, _react.useEffect)(() => {
|
|
340
231
|
if (displayListBox) {
|
|
341
232
|
setupFocus();
|
|
342
233
|
}
|
|
343
234
|
}, [displayListBox, setupFocus, value]);
|
|
344
235
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactOutsideClickHandler.default, {
|
|
345
|
-
onOutsideClick:
|
|
236
|
+
onOutsideClick: () => {
|
|
346
237
|
setDisplayListBox(false);
|
|
347
238
|
},
|
|
348
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Input.default,
|
|
349
|
-
autoComplete: "off"
|
|
350
|
-
|
|
351
|
-
onChange:
|
|
352
|
-
|
|
353
|
-
|
|
239
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Input.default, {
|
|
240
|
+
autoComplete: "off",
|
|
241
|
+
...props,
|
|
242
|
+
onChange: event => {
|
|
243
|
+
onChange(event);
|
|
354
244
|
if (!displayListBox) setDisplayListBox(true);
|
|
355
245
|
},
|
|
356
246
|
value: value,
|
|
357
|
-
ref: setListBoxElement
|
|
358
|
-
|
|
247
|
+
ref: setListBoxElement,
|
|
248
|
+
...attributes.popper,
|
|
359
249
|
placement: state && state.placement,
|
|
360
250
|
onClick: handleDisplay,
|
|
361
251
|
onKeyUp: handleKeyUp,
|
|
362
|
-
onFocus:
|
|
252
|
+
onFocus: () => {
|
|
363
253
|
setDisplayListBox(true);
|
|
364
254
|
},
|
|
365
255
|
onKeyDown: handleKeyDown
|
|
366
|
-
})
|
|
256
|
+
}), optionItem.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListBox.default, {
|
|
367
257
|
style: styles.popper,
|
|
368
258
|
$display: displayListBox,
|
|
369
259
|
ref: setDropdownElement,
|
|
@@ -377,6 +267,4 @@ var InputSelect = function InputSelect(_ref) {
|
|
|
377
267
|
})]
|
|
378
268
|
});
|
|
379
269
|
};
|
|
380
|
-
|
|
381
|
-
var _default = InputSelect;
|
|
382
|
-
exports.default = _default;
|
|
270
|
+
var _default = exports.default = InputSelect;
|