@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.
Files changed (233) hide show
  1. package/Tab/Tab.js +9 -13
  2. package/Tab/TabList.js +14 -32
  3. package/Tab/TabPanel.js +21 -58
  4. package/Tab/TabTab.js +20 -40
  5. package/Tab/index.js +2 -10
  6. package/Tab/subComponent/TabContext.js +2 -5
  7. package/animate/Collapse.js +26 -53
  8. package/animate/Loader.js +21 -26
  9. package/animate/NumberCounter.js +22 -44
  10. package/animate/PulseRing.js +9 -21
  11. package/animate/Spinner.js +2 -10
  12. package/animate/index.js +5 -11
  13. package/assets/css/autocomplete.css +16 -16
  14. package/assets/css/font.css +4 -4
  15. package/assets/css/global.css +3 -3
  16. package/assets/css/normalize.css +386 -386
  17. package/backdrop/BaseBackdrop.js +2 -9
  18. package/backdrop/LoadingBackdrop.js +2 -9
  19. package/backdrop/ModalBackdrop.js +2 -9
  20. package/backdrop/index.js +3 -7
  21. package/badge/Badge.js +2 -11
  22. package/badge/BadgeDot.js +2 -10
  23. package/badge/BadgeFill.js +15 -20
  24. package/badge/BadgeWithText.js +6 -13
  25. package/badge/index.js +4 -9
  26. package/billing/BarChart.js +10 -17
  27. package/billing/Grid.js +11 -15
  28. package/billing/Header2.js +6 -9
  29. package/billing/Header3.js +9 -16
  30. package/billing/Paragraph.js +8 -14
  31. package/billing/ParagraphGroup.js +6 -9
  32. package/billing/ParagraphText.js +7 -12
  33. package/billing/Section.js +13 -23
  34. package/billing/SectionBody.js +5 -8
  35. package/billing/SectionHeader.js +7 -12
  36. package/breadcrumb/Breadcrumb.js +11 -21
  37. package/breadcrumb/index.js +1 -3
  38. package/button/Button.js +41 -38
  39. package/button/ButtonGroup.js +21 -18
  40. package/button/IconButton.js +29 -29
  41. package/button/ScrollToTopButton.js +12 -39
  42. package/button/index.js +4 -9
  43. package/callout/Callout.js +13 -26
  44. package/callout/index.js +1 -3
  45. package/chart/BarChart.js +28 -53
  46. package/chart/DoughnutChart.js +23 -62
  47. package/chart/LineChart.js +33 -55
  48. package/chart/SingleBarChart.js +11 -17
  49. package/chart/index.js +5 -12
  50. package/chart/utils/customTooltip.js +26 -43
  51. package/chart/utils/htmlLegendPlugin.js +24 -30
  52. package/chart/utils/index.js +3 -7
  53. package/chart/utils/padEmptyChartBar.js +24 -22
  54. package/container/FlexContainer.js +9 -12
  55. package/container/index.js +1 -3
  56. package/cropper/Cropper.js +21 -34
  57. package/cropper/CropperModalHandler.js +15 -21
  58. package/cropper/index.js +2 -5
  59. package/cropper/subComponent/CropImageModal.js +23 -58
  60. package/datetimePicker/DatePicker.js +103 -217
  61. package/datetimePicker/DatePickerV2.js +116 -221
  62. package/datetimePicker/DatetimePicker.js +27 -48
  63. package/datetimePicker/DatetimePickerV2.js +115 -231
  64. package/datetimePicker/TimeInput.js +9 -22
  65. package/datetimePicker/TimePicker.js +94 -151
  66. package/datetimePicker/TimePickerStyle.js +14 -0
  67. package/datetimePicker/accordion/Month.js +70 -90
  68. package/datetimePicker/accordion/Year.js +91 -135
  69. package/datetimePicker/hooks/index.js +3 -7
  70. package/datetimePicker/hooks/useChangeNumber.js +14 -27
  71. package/datetimePicker/hooks/useDecrease.js +19 -35
  72. package/datetimePicker/hooks/useIncrease.js +19 -35
  73. package/datetimePicker/index.js +13 -13
  74. package/datetimePicker/provider/constant.js +2 -3
  75. package/datetimePicker/subComponent/Accordion.js +108 -158
  76. package/datetimePicker/subComponent/CustomTimeInput.js +18 -48
  77. package/datetimePicker/subComponent/DateTimePickerContext.js +2 -5
  78. package/datetimePicker/utils/GMTDate.js +3 -7
  79. package/datetimePicker/utils/pad.js +2 -6
  80. package/datetimePicker/utils/toUTC0.js +3 -6
  81. package/descriptionList/DescriptionDetail.js +5 -10
  82. package/descriptionList/DescriptionList.js +5 -10
  83. package/descriptionList/DescriptionTerm.js +2 -9
  84. package/descriptionList/index.js +3 -7
  85. package/divider/Divider.js +9 -12
  86. package/divider/index.js +1 -3
  87. package/dropdown/Dropdown.js +28 -65
  88. package/dropdown/DropdownButtonOption.js +2 -9
  89. package/dropdown/DropdownContent.js +33 -64
  90. package/dropdown/DropdownDivOption.js +2 -9
  91. package/dropdown/DropdownItem.js +10 -16
  92. package/dropdown/DropdownLinkOption.js +2 -9
  93. package/dropdown/DropdownToggle.js +18 -38
  94. package/dropdown/index.js +6 -17
  95. package/dropdown/subComponent/DropdownContext.js +2 -5
  96. package/dropzone/FileDropzone.js +148 -302
  97. package/dropzone/ImageDropzone.js +96 -171
  98. package/dropzone/index.js +2 -5
  99. package/dropzone/subComponent/Message.js +7 -14
  100. package/figure/IconFigure.js +9 -16
  101. package/figure/ImageFigure.js +11 -17
  102. package/figure/index.js +2 -5
  103. package/file/HiddenFileInput.js +5 -14
  104. package/file/index.js +1 -3
  105. package/form/Checkbox.js +34 -43
  106. package/form/FormItem.js +2 -9
  107. package/form/Input.js +13 -15
  108. package/form/Label.js +10 -13
  109. package/form/MutedText.js +5 -10
  110. package/form/RadioButton.js +20 -32
  111. package/form/Searchbox.js +21 -65
  112. package/form/Slider.js +14 -0
  113. package/form/SwitchButton.js +34 -39
  114. package/form/Textarea.js +2 -11
  115. package/form/index.js +9 -19
  116. package/grid/Column.js +17 -17
  117. package/grid/Grid.js +13 -14
  118. package/grid/index.js +2 -5
  119. package/heading/Heading1.js +5 -10
  120. package/heading/Heading2.js +9 -12
  121. package/heading/Heading3.js +21 -18
  122. package/heading/index.js +3 -7
  123. package/helmet/Helmet.js +6 -9
  124. package/helmet/index.js +2 -5
  125. package/iconbox/ApplicationIconBox.js +25 -31
  126. package/iconbox/IconBox.js +11 -24
  127. package/iconbox/IconBoxV2.js +14 -26
  128. package/iconbox/index.js +3 -7
  129. package/iconbox/subComponent/IconBoxFigure.js +25 -20
  130. package/iconbox/subComponent/IconBoxImage.js +15 -18
  131. package/image/ImageFluid.js +2 -10
  132. package/image/UploadImage.js +65 -113
  133. package/image/index.js +2 -5
  134. package/index.js +44 -130
  135. package/jsoneditor/JsonEditor.js +10 -32
  136. package/jsoneditor/index.js +1 -3
  137. package/keyframe/Pulse.js +2 -7
  138. package/keyframe/Spin.js +2 -7
  139. package/link/LinkSpan.js +22 -35
  140. package/link/index.js +1 -3
  141. package/map/GoogleMap.js +122 -175
  142. package/map/GoogleReverseGeolocation.js +79 -186
  143. package/map/LeafletMap.js +78 -132
  144. package/map/LeafletReverseGeolocation.js +49 -121
  145. package/map/index.js +4 -9
  146. package/map/subComponent/BasicLeafletMap.js +8 -14
  147. package/map/subComponent/GoogleMapContainer.js +5 -10
  148. package/map/subComponent/GoogleMapPopup.js +66 -123
  149. package/map/subComponent/GoogleMapWrapper.js +13 -32
  150. package/map/subComponent/GoogleMarkerSpiderfier.js +14 -24
  151. package/map/subComponent/LeafletDrawControl.js +47 -84
  152. package/map/subComponent/LeafletMapContainer.js +5 -10
  153. package/map/subComponent/MapSearchBoxControl.js +24 -70
  154. package/modal/StateModal.js +41 -100
  155. package/modal/TitleModal.js +89 -190
  156. package/modal/index.js +2 -5
  157. package/package.json +1 -1
  158. package/paginate/Paginate.js +40 -54
  159. package/paginate/index.js +1 -3
  160. package/popover/Popover.js +39 -87
  161. package/popover/index.js +1 -3
  162. package/qrcode/QRCode.js +10 -23
  163. package/qrcode/QRCodeContainter.js +8 -16
  164. package/qrcode/index.js +2 -5
  165. package/ribbon/Ribbon.js +4 -15
  166. package/ribbon/index.js +1 -3
  167. package/section/Section.js +57 -39
  168. package/section/SectionBody.js +15 -22
  169. package/section/SectionHeader.js +27 -27
  170. package/section/SectionToolbar.js +2 -9
  171. package/section/SectionToolbarItem.js +2 -9
  172. package/section/index.js +5 -11
  173. package/select/InputSelect.js +103 -215
  174. package/select/Select.js +204 -362
  175. package/select/index.js +2 -5
  176. package/select/subComponent/ListBox.js +9 -12
  177. package/select/subComponent/Option.js +8 -16
  178. package/select/subComponent/OptionGroup.js +2 -9
  179. package/select/subComponent/Options.js +5 -11
  180. package/select/subComponent/SearchBox.js +9 -29
  181. package/select/subComponent/SelectedMultiple.js +8 -16
  182. package/select/subComponent/SelectedSingle.js +2 -9
  183. package/styles/GlobalStyle.js +169 -91
  184. package/styles/config/breakpoint.style.js +2 -3
  185. package/styles/config/header.style.js +2 -3
  186. package/styles/config/sidebar.style.js +2 -3
  187. package/styles/index.js +2 -5
  188. package/styles/mixin/backgroundColor.js +17 -14
  189. package/styles/mixin/borderColor.js +17 -14
  190. package/styles/mixin/color.js +17 -14
  191. package/styles/mixin/colorOnBackground.js +17 -14
  192. package/styles/mixin/inputPlaceholder.js +3 -9
  193. package/styles/mixin/media.js +3 -11
  194. package/styles/mixin/rounded.js +13 -12
  195. package/styles/mixin/scrollbar.js +7 -13
  196. package/styles/theme/dark.theme.js +20 -20
  197. package/styles/theme/light.theme.js +20 -20
  198. package/styles/theme/white.theme.js +20 -20
  199. package/styles/themes.js +2 -8
  200. package/table/GridTable.js +105 -143
  201. package/table/ImageBox.js +8 -18
  202. package/table/PermissionTable.js +25 -25
  203. package/table/Table.js +137 -153
  204. package/table/__mock__/columns.js +2 -3
  205. package/table/__mock__/data.js +2 -3
  206. package/table/hooks/index.js +2 -5
  207. package/table/hooks/useCalculateDataRange.js +9 -36
  208. package/table/hooks/useGenerateSort.js +6 -17
  209. package/table/index.js +4 -9
  210. package/table/subComponent/BaseTableHeadCell.js +15 -21
  211. package/table/subComponent/GridTableFooter.js +5 -10
  212. package/table/subComponent/GridTableHeadCell.js +5 -10
  213. package/table/subComponent/Resizer.js +17 -44
  214. package/table/subComponent/TableFooter.js +5 -10
  215. package/table/subComponent/TableFooterInfo.js +2 -9
  216. package/table/subComponent/TableFooterPager.js +5 -12
  217. package/table/subComponent/TableHeadCell.js +2 -9
  218. package/table/subComponent/TableSort.js +13 -19
  219. package/tagify/TagifyStyle.js +14 -0
  220. package/tagify/Tags.js +15 -37
  221. package/tagify/index.js +8 -3
  222. package/text/Paragraph.js +25 -20
  223. package/text/index.js +1 -3
  224. package/timeline/Timeline.js +28 -37
  225. package/timeline/index.js +1 -3
  226. package/toast/CustomToastContainer.js +2 -9
  227. package/toast/MessageContainer.js +9 -18
  228. package/toast/index.js +3 -8
  229. package/toast/show.js +18 -28
  230. package/tooltip/Tooltip.js +48 -97
  231. package/tooltip/index.js +1 -3
  232. package/wizard/Wizard.js +63 -133
  233. 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 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"])));
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 get() {
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 get() {
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 get() {
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 get() {
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 get() {
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 }; }
@@ -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
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
31
-
32
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
33
-
34
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
35
-
36
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
37
-
38
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
39
-
40
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
41
-
42
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
43
-
44
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
45
-
46
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
47
-
48
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
49
-
50
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
51
-
52
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
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
- var previousItem = findPreviousItem(focusedOption);
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
- var nextItem = findNextItem(focusedOption);
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
- var lastItem = dropdownElement.querySelectorAll('[role="option"]');
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
- var handleKeyDown = function handleKeyDown(event) {
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
- var findPreviousItem = (0, _react.useCallback)(function (currentItem) {
196
- var allItem = _toConsumableArray(dropdownElement.querySelectorAll('[role="option"]'));
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
- var findNextItem = (0, _react.useCallback)(function (currentItem) {
208
- var allItem = _toConsumableArray(dropdownElement.querySelectorAll('[role="option"]'));
209
-
210
- var currentItemIndex = allItem.indexOf(currentItem);
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]); // set focused option
120
+ }, [dropdownElement]);
219
121
 
220
- var handleFocusItem = (0, _react.useCallback)(function (element) {
122
+ // set focused option
123
+ const handleFocusItem = (0, _react.useCallback)(element => {
221
124
  if (!optionsElementRef.current) return;
222
125
  setFocusedOption(element);
223
126
  }, []);
224
- var focusFirstItem = (0, _react.useCallback)(function () {
225
- var firstItem = dropdownElement.querySelector('[role="option"]');
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
- var setupFocus = (0, _react.useCallback)(function () {
133
+ const setupFocus = (0, _react.useCallback)(() => {
232
134
  if (!dropdownElement) return;
233
- var selectedItem = dropdownElement.querySelector('[aria-selected="true"]');
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]); // all option
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
- var optionItem = (0, _react.useMemo)(function () {
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]); // observe element resized
176
+ }, [value]);
278
177
 
279
- (0, _react.useEffect)(function () {
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
- (0, _react.useEffect)(function () {
184
+ // 過濾搜尋關鍵字資料
185
+ (0, _react.useEffect)(() => {
285
186
  if (!options.length) return;
286
- var tmpFilteredChildOptions = options.filter(function (option) {
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)(function () {
192
+ (0, _react.useEffect)(() => {
292
193
  if (update) {
293
- setTimeout(function () {
194
+ setTimeout(() => {
294
195
  update();
295
196
  }, 100);
296
197
  }
297
- }, [update, listBoxWidth]); // observe element resized
198
+ }, [update, listBoxWidth]);
298
199
 
299
- (0, _react.useEffect)(function () {
200
+ // observe element resized
201
+ (0, _react.useEffect)(() => {
300
202
  if (!listBoxElement) return;
301
- var resizeObserverInstance = new ResizeObserver(function (entries) {
302
- var _iterator = _createForOfIteratorHelper(entries),
303
- _step;
304
-
305
- try {
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 function () {
212
+ return () => {
322
213
  resizeObserverInstance.unobserve(listBoxElement);
323
214
  };
324
215
  }, [listBoxElement]);
325
- (0, _react.useEffect)(function () {
326
- var selected = false;
327
- setOptionList(filteredOptions.map(function (option) {
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
- return _objectSpread(_objectSpread({}, option), {}, {
335
- selected: selected
336
- });
224
+ return {
225
+ ...option,
226
+ selected
227
+ };
337
228
  }));
338
229
  }, [filteredOptions, parsedSelected]);
339
- (0, _react.useEffect)(function () {
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: function onOutsideClick() {
236
+ onOutsideClick: () => {
346
237
  setDisplayListBox(false);
347
238
  },
348
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Input.default, _objectSpread(_objectSpread(_objectSpread({
349
- autoComplete: "off"
350
- }, props), {}, {
351
- onChange: function onChange(event) {
352
- _onChange(event);
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
- }, attributes.popper), {}, {
247
+ ref: setListBoxElement,
248
+ ...attributes.popper,
359
249
  placement: state && state.placement,
360
250
  onClick: handleDisplay,
361
251
  onKeyUp: handleKeyUp,
362
- onFocus: function onFocus() {
252
+ onFocus: () => {
363
253
  setDisplayListBox(true);
364
254
  },
365
255
  onKeyDown: handleKeyDown
366
- })), optionItem.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListBox.default, {
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;