@cashub/ui 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) 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/backdrop/BaseBackdrop.js +2 -9
  14. package/backdrop/LoadingBackdrop.js +2 -9
  15. package/backdrop/ModalBackdrop.js +2 -9
  16. package/backdrop/index.js +3 -7
  17. package/badge/Badge.js +2 -11
  18. package/badge/BadgeDot.js +2 -10
  19. package/badge/BadgeFill.js +15 -20
  20. package/badge/BadgeWithText.js +6 -13
  21. package/badge/index.js +4 -9
  22. package/billing/BarChart.js +10 -17
  23. package/billing/Grid.js +11 -15
  24. package/billing/Header2.js +6 -9
  25. package/billing/Header3.js +9 -16
  26. package/billing/Paragraph.js +8 -14
  27. package/billing/ParagraphGroup.js +6 -9
  28. package/billing/ParagraphText.js +7 -12
  29. package/billing/Section.js +13 -23
  30. package/billing/SectionBody.js +5 -8
  31. package/billing/SectionHeader.js +7 -12
  32. package/breadcrumb/Breadcrumb.js +11 -21
  33. package/breadcrumb/index.js +1 -3
  34. package/button/Button.js +41 -38
  35. package/button/ButtonGroup.js +21 -18
  36. package/button/IconButton.js +29 -29
  37. package/button/ScrollToTopButton.js +12 -39
  38. package/button/index.js +4 -9
  39. package/callout/Callout.js +13 -26
  40. package/callout/index.js +1 -3
  41. package/chart/BarChart.js +28 -53
  42. package/chart/DoughnutChart.js +23 -62
  43. package/chart/LineChart.js +33 -55
  44. package/chart/SingleBarChart.js +11 -17
  45. package/chart/index.js +5 -12
  46. package/chart/utils/customTooltip.js +26 -43
  47. package/chart/utils/htmlLegendPlugin.js +24 -30
  48. package/chart/utils/index.js +3 -7
  49. package/chart/utils/padEmptyChartBar.js +24 -22
  50. package/container/FlexContainer.js +14 -12
  51. package/container/index.js +1 -3
  52. package/cropper/Cropper.js +21 -34
  53. package/cropper/CropperModalHandler.js +15 -21
  54. package/cropper/index.js +2 -5
  55. package/cropper/subComponent/CropImageModal.js +23 -58
  56. package/datetimePicker/DatePicker.js +103 -217
  57. package/datetimePicker/DatePickerV2.js +116 -221
  58. package/datetimePicker/DatetimePicker.js +27 -48
  59. package/datetimePicker/DatetimePickerV2.js +115 -231
  60. package/datetimePicker/TimeInput.js +9 -22
  61. package/datetimePicker/TimePicker.js +94 -151
  62. package/datetimePicker/TimePickerStyle.js +2 -9
  63. package/datetimePicker/accordion/Month.js +70 -90
  64. package/datetimePicker/accordion/Year.js +91 -135
  65. package/datetimePicker/hooks/index.js +3 -7
  66. package/datetimePicker/hooks/useChangeNumber.js +14 -27
  67. package/datetimePicker/hooks/useDecrease.js +19 -35
  68. package/datetimePicker/hooks/useIncrease.js +19 -35
  69. package/datetimePicker/index.js +7 -15
  70. package/datetimePicker/provider/constant.js +2 -3
  71. package/datetimePicker/subComponent/Accordion.js +108 -158
  72. package/datetimePicker/subComponent/CustomTimeInput.js +18 -48
  73. package/datetimePicker/subComponent/DateTimePickerContext.js +2 -5
  74. package/datetimePicker/utils/GMTDate.js +3 -7
  75. package/datetimePicker/utils/pad.js +2 -6
  76. package/datetimePicker/utils/toUTC0.js +3 -6
  77. package/descriptionList/DescriptionDetail.js +5 -10
  78. package/descriptionList/DescriptionList.js +5 -10
  79. package/descriptionList/DescriptionTerm.js +2 -9
  80. package/descriptionList/index.js +3 -7
  81. package/divider/Divider.js +9 -12
  82. package/divider/index.js +1 -3
  83. package/dropdown/Dropdown.js +28 -65
  84. package/dropdown/DropdownButtonOption.js +2 -9
  85. package/dropdown/DropdownContent.js +33 -64
  86. package/dropdown/DropdownDivOption.js +2 -9
  87. package/dropdown/DropdownItem.js +10 -16
  88. package/dropdown/DropdownLinkOption.js +2 -9
  89. package/dropdown/DropdownToggle.js +18 -38
  90. package/dropdown/index.js +6 -17
  91. package/dropdown/subComponent/DropdownContext.js +2 -5
  92. package/dropzone/FileDropzone.js +148 -302
  93. package/dropzone/ImageDropzone.js +96 -171
  94. package/dropzone/index.js +2 -5
  95. package/dropzone/subComponent/Message.js +7 -14
  96. package/figure/IconFigure.js +9 -16
  97. package/figure/ImageFigure.js +11 -17
  98. package/figure/index.js +2 -5
  99. package/file/HiddenFileInput.js +5 -14
  100. package/file/index.js +1 -3
  101. package/form/Checkbox.js +34 -43
  102. package/form/FormItem.js +2 -9
  103. package/form/Input.js +18 -15
  104. package/form/Label.js +20 -13
  105. package/form/MutedText.js +5 -10
  106. package/form/RadioButton.js +20 -32
  107. package/form/Searchbox.js +21 -65
  108. package/form/Slider.js +25 -0
  109. package/form/SwitchButton.js +34 -39
  110. package/form/Textarea.js +2 -11
  111. package/form/TreeView.js +64 -0
  112. package/form/index.js +16 -19
  113. package/grid/Column.js +17 -17
  114. package/grid/Grid.js +13 -14
  115. package/grid/index.js +2 -5
  116. package/heading/Heading1.js +5 -10
  117. package/heading/Heading2.js +9 -12
  118. package/heading/Heading3.js +21 -18
  119. package/heading/index.js +3 -7
  120. package/helmet/Helmet.js +6 -9
  121. package/helmet/index.js +2 -5
  122. package/iconbox/ApplicationIconBox.js +25 -31
  123. package/iconbox/IconBox.js +11 -24
  124. package/iconbox/IconBoxV2.js +14 -26
  125. package/iconbox/index.js +3 -7
  126. package/iconbox/subComponent/IconBoxFigure.js +25 -20
  127. package/iconbox/subComponent/IconBoxImage.js +15 -18
  128. package/image/ImageFluid.js +2 -10
  129. package/image/UploadImage.js +65 -113
  130. package/image/index.js +2 -5
  131. package/index.js +44 -130
  132. package/jsoneditor/JsonEditor.js +10 -32
  133. package/jsoneditor/index.js +1 -3
  134. package/keyframe/Pulse.js +2 -7
  135. package/keyframe/Spin.js +2 -7
  136. package/link/LinkSpan.js +22 -35
  137. package/link/index.js +1 -3
  138. package/map/GoogleMap.js +122 -175
  139. package/map/GoogleReverseGeolocation.js +79 -186
  140. package/map/LeafletMap.js +78 -132
  141. package/map/LeafletReverseGeolocation.js +49 -121
  142. package/map/index.js +4 -9
  143. package/map/subComponent/BasicLeafletMap.js +8 -14
  144. package/map/subComponent/GoogleMapContainer.js +5 -10
  145. package/map/subComponent/GoogleMapPopup.js +66 -123
  146. package/map/subComponent/GoogleMapWrapper.js +13 -32
  147. package/map/subComponent/GoogleMarkerSpiderfier.js +14 -24
  148. package/map/subComponent/LeafletDrawControl.js +47 -84
  149. package/map/subComponent/LeafletMapContainer.js +5 -10
  150. package/map/subComponent/MapSearchBoxControl.js +24 -70
  151. package/modal/StateModal.js +41 -100
  152. package/modal/TitleModal.js +89 -190
  153. package/modal/index.js +2 -5
  154. package/package.json +1 -1
  155. package/paginate/Paginate.js +40 -54
  156. package/paginate/index.js +1 -3
  157. package/popover/Popover.js +39 -87
  158. package/popover/index.js +1 -3
  159. package/qrcode/QRCode.js +10 -23
  160. package/qrcode/QRCodeContainter.js +8 -16
  161. package/qrcode/index.js +2 -5
  162. package/ribbon/Ribbon.js +4 -15
  163. package/ribbon/index.js +1 -3
  164. package/section/Section.js +57 -39
  165. package/section/SectionBody.js +15 -22
  166. package/section/SectionHeader.js +27 -27
  167. package/section/SectionToolbar.js +2 -9
  168. package/section/SectionToolbarItem.js +2 -9
  169. package/section/index.js +5 -11
  170. package/select/InputSelect.js +103 -215
  171. package/select/Select.js +204 -362
  172. package/select/index.js +2 -5
  173. package/select/subComponent/ListBox.js +9 -12
  174. package/select/subComponent/Option.js +8 -16
  175. package/select/subComponent/OptionGroup.js +2 -9
  176. package/select/subComponent/Options.js +5 -11
  177. package/select/subComponent/SearchBox.js +9 -29
  178. package/select/subComponent/SelectedMultiple.js +8 -16
  179. package/select/subComponent/SelectedSingle.js +2 -9
  180. package/styles/GlobalStyle.js +169 -91
  181. package/styles/config/breakpoint.style.js +2 -3
  182. package/styles/config/header.style.js +2 -3
  183. package/styles/config/sidebar.style.js +2 -3
  184. package/styles/index.js +2 -5
  185. package/styles/mixin/backgroundColor.js +17 -14
  186. package/styles/mixin/borderColor.js +17 -14
  187. package/styles/mixin/color.js +17 -14
  188. package/styles/mixin/colorOnBackground.js +17 -14
  189. package/styles/mixin/inputPlaceholder.js +3 -9
  190. package/styles/mixin/media.js +3 -11
  191. package/styles/mixin/rounded.js +13 -12
  192. package/styles/mixin/scrollbar.js +7 -13
  193. package/styles/theme/dark.theme.js +20 -20
  194. package/styles/theme/light.theme.js +20 -20
  195. package/styles/theme/white.theme.js +20 -20
  196. package/styles/themes.js +2 -8
  197. package/table/GridTable.js +105 -143
  198. package/table/ImageBox.js +8 -18
  199. package/table/PermissionTable.js +25 -25
  200. package/table/Table.js +137 -153
  201. package/table/__mock__/columns.js +2 -3
  202. package/table/__mock__/data.js +2 -3
  203. package/table/hooks/index.js +2 -5
  204. package/table/hooks/useCalculateDataRange.js +9 -36
  205. package/table/hooks/useGenerateSort.js +6 -17
  206. package/table/index.js +4 -9
  207. package/table/subComponent/BaseTableHeadCell.js +15 -21
  208. package/table/subComponent/GridTableFooter.js +5 -10
  209. package/table/subComponent/GridTableHeadCell.js +5 -10
  210. package/table/subComponent/Resizer.js +17 -44
  211. package/table/subComponent/TableFooter.js +5 -10
  212. package/table/subComponent/TableFooterInfo.js +2 -9
  213. package/table/subComponent/TableFooterPager.js +5 -12
  214. package/table/subComponent/TableHeadCell.js +2 -9
  215. package/table/subComponent/TableSort.js +13 -19
  216. package/tagify/TagifyStyle.js +2 -9
  217. package/tagify/Tags.js +15 -37
  218. package/tagify/index.js +2 -5
  219. package/text/Paragraph.js +25 -20
  220. package/text/index.js +1 -3
  221. package/timeline/Timeline.js +28 -37
  222. package/timeline/index.js +1 -3
  223. package/toast/CustomToastContainer.js +2 -9
  224. package/toast/MessageContainer.js +9 -18
  225. package/toast/index.js +3 -8
  226. package/toast/show.js +18 -28
  227. package/tooltip/Tooltip.js +48 -97
  228. package/tooltip/index.js +1 -3
  229. package/wizard/Wizard.js +63 -133
  230. package/wizard/index.js +1 -3
@@ -1,297 +1,184 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.default = void 0;
9
-
10
7
  var _react = require("react");
11
-
12
8
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
13
-
14
9
  var _reactI18next = require("react-i18next");
15
-
16
10
  var _reactOutsideClickHandler = _interopRequireDefault(require("react-outside-click-handler"));
17
-
18
11
  var _hooks = require("@cashub/hooks");
19
-
20
12
  var _utils = require("@cashub/utils");
21
-
22
13
  var _Button = _interopRequireDefault(require("../button/Button"));
23
-
24
14
  var _Accordion = _interopRequireDefault(require("./subComponent/Accordion"));
25
-
26
15
  var _Input = _interopRequireDefault(require("../form/Input"));
27
-
28
16
  var _jsxRuntime = require("react/jsx-runtime");
29
-
30
17
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
31
-
32
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
-
34
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
35
-
36
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
37
-
19
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
20
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
38
21
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
39
-
40
- 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; }
41
-
42
- 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; }
43
-
44
- 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; }
45
-
46
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
47
-
48
- 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."); }
49
-
50
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
51
-
52
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
53
-
54
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
55
-
56
- 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."); }
57
-
58
- 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); }
59
-
60
- 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; }
61
-
62
- 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; }
63
-
64
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
65
-
66
- var DatePicker = function DatePicker(_ref) {
67
- var onConfirm = _ref.onConfirm,
68
- selected = _ref.selected,
69
- minDate = _ref.minDate,
70
- maxDate = _ref.maxDate,
71
- fixedYear = _ref.fixedYear,
72
- disabled = _ref.disabled;
73
-
74
- var _useTranslation = (0, _reactI18next.useTranslation)(),
75
- t = _useTranslation.t;
76
-
77
- var _useState = (0, _react.useState)(null),
78
- _useState2 = _slicedToArray(_useState, 2),
79
- currentDisplayType = _useState2[0],
80
- setCurrentDisplayType = _useState2[1];
81
-
82
- var _useState3 = (0, _react.useState)(false),
83
- _useState4 = _slicedToArray(_useState3, 2),
84
- displayPicker = _useState4[0],
85
- setDisplayPicker = _useState4[1];
86
-
87
- var _useState5 = (0, _react.useState)(selected ? new Date(selected).getFullYear() : new Date().getFullYear()),
88
- _useState6 = _slicedToArray(_useState5, 2),
89
- selectedYear = _useState6[0],
90
- setSelectedYear = _useState6[1];
91
-
92
- var _useState7 = (0, _react.useState)(selected ? new Date(selected).getMonth() : new Date().getMonth()),
93
- _useState8 = _slicedToArray(_useState7, 2),
94
- selectedMonth = _useState8[0],
95
- setSelectedMonth = _useState8[1];
96
-
97
- var _useState9 = (0, _react.useState)(selected ? new Date(selected).getDate() : new Date().getDate()),
98
- _useState10 = _slicedToArray(_useState9, 2),
99
- selectedDay = _useState10[0],
100
- setSelectedDay = _useState10[1];
101
-
102
- var _useState11 = (0, _react.useState)(selected ? new Date(selected).getFullYear() : ''),
103
- _useState12 = _slicedToArray(_useState11, 2),
104
- confirmYear = _useState12[0],
105
- setConfirmYear = _useState12[1];
106
-
107
- var _useState13 = (0, _react.useState)(selected ? new Date(selected).getMonth() : ''),
108
- _useState14 = _slicedToArray(_useState13, 2),
109
- confirmMonth = _useState14[0],
110
- setConfirmMonth = _useState14[1];
111
-
112
- var _useState15 = (0, _react.useState)(selected ? new Date(selected).getDate() : ''),
113
- _useState16 = _slicedToArray(_useState15, 2),
114
- confirmDay = _useState16[0],
115
- setConfirmDay = _useState16[1];
116
-
117
- var _useState17 = (0, _react.useState)(selected ? selected : ''),
118
- _useState18 = _slicedToArray(_useState17, 2),
119
- inputValue = _useState18[0],
120
- setInputValue = _useState18[1];
121
-
122
- var _useState19 = (0, _react.useState)(null),
123
- _useState20 = _slicedToArray(_useState19, 2),
124
- toggleElement = _useState20[0],
125
- setToggleElement = _useState20[1];
126
-
127
- var _useState21 = (0, _react.useState)(null),
128
- _useState22 = _slicedToArray(_useState21, 2),
129
- contentElement = _useState22[0],
130
- setContentElement = _useState22[1];
131
-
132
- var _useCustomPopper = (0, _hooks.useCustomPopper)(toggleElement, contentElement, {
22
+ const DatePicker = _ref => {
23
+ let {
24
+ onConfirm,
25
+ selected,
26
+ minDate,
27
+ maxDate,
28
+ fixedYear,
29
+ disabled
30
+ } = _ref;
31
+ const {
32
+ t
33
+ } = (0, _reactI18next.useTranslation)();
34
+ const [currentDisplayType, setCurrentDisplayType] = (0, _react.useState)(null);
35
+ const [displayPicker, setDisplayPicker] = (0, _react.useState)(false);
36
+ const [selectedYear, setSelectedYear] = (0, _react.useState)(selected ? new Date(selected).getFullYear() : new Date().getFullYear());
37
+ const [selectedMonth, setSelectedMonth] = (0, _react.useState)(selected ? new Date(selected).getMonth() : new Date().getMonth());
38
+ const [selectedDay, setSelectedDay] = (0, _react.useState)(selected ? new Date(selected).getDate() : new Date().getDate());
39
+ const [confirmYear, setConfirmYear] = (0, _react.useState)(selected ? new Date(selected).getFullYear() : '');
40
+ const [confirmMonth, setConfirmMonth] = (0, _react.useState)(selected ? new Date(selected).getMonth() : '');
41
+ const [confirmDay, setConfirmDay] = (0, _react.useState)(selected ? new Date(selected).getDate() : '');
42
+ const [inputValue, setInputValue] = (0, _react.useState)(selected ? selected : '');
43
+ const [toggleElement, setToggleElement] = (0, _react.useState)(null);
44
+ const [contentElement, setContentElement] = (0, _react.useState)(null);
45
+ const {
46
+ styles,
47
+ attributes,
48
+ state,
49
+ update
50
+ } = (0, _hooks.useCustomPopper)(toggleElement, contentElement, {
133
51
  strategy: 'absolute',
134
52
  placement: 'bottom-start'
135
- }),
136
- styles = _useCustomPopper.styles,
137
- attributes = _useCustomPopper.attributes,
138
- state = _useCustomPopper.state,
139
- update = _useCustomPopper.update;
140
-
141
- var weeks = (0, _react.useMemo)(function () {
142
- return ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'].map(function (week) {
143
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Week, {
144
- children: week
145
- }, week);
146
- });
53
+ });
54
+ const weeks = (0, _react.useMemo)(() => {
55
+ return ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'].map(week => /*#__PURE__*/(0, _jsxRuntime.jsx)(Week, {
56
+ children: week
57
+ }, week));
147
58
  }, []);
148
-
149
- var _handleDisplayAccordionContent = (0, _react.useCallback)(function (type) {
59
+ const handleDisplayAccordionContent = (0, _react.useCallback)(type => {
150
60
  if (currentDisplayType === type) {
151
61
  setCurrentDisplayType(null);
152
62
  } else {
153
63
  setCurrentDisplayType(type);
154
64
  }
155
65
  }, [currentDisplayType]);
156
-
157
- var handleChangeYear = function handleChangeYear(selected) {
66
+ const handleChangeYear = selected => {
158
67
  if (selected === 'previous') {
159
- setSelectedYear(function (previousParams) {
68
+ setSelectedYear(previousParams => {
160
69
  if (previousParams <= 1) {
161
70
  return previousParams;
162
71
  }
163
-
164
72
  return previousParams - 1;
165
73
  });
166
74
  } else if (selected === 'next') {
167
- setSelectedYear(function (previousParams) {
75
+ setSelectedYear(previousParams => {
168
76
  return previousParams + 1;
169
77
  });
170
78
  }
171
-
172
79
  setCurrentDisplayType(null);
173
80
  };
174
-
175
- var handleChangeMonth = function handleChangeMonth(selected) {
81
+ const handleChangeMonth = selected => {
176
82
  if (selected === 'previous') {
177
- setSelectedMonth(function (previousParams) {
83
+ setSelectedMonth(previousParams => {
178
84
  if (previousParams <= 0) {
179
85
  return 11;
180
86
  }
181
-
182
87
  return previousParams - 1;
183
88
  });
184
89
  } else if (selected === 'next') {
185
- setSelectedMonth(function (previousParams) {
90
+ setSelectedMonth(previousParams => {
186
91
  if (previousParams >= 11) {
187
92
  return 0;
188
93
  }
189
-
190
94
  return previousParams + 1;
191
95
  });
192
96
  }
193
-
194
97
  setCurrentDisplayType(null);
195
98
  };
196
-
197
- var handleDisabled = (0, _react.useCallback)(function (firstWeekOfMonth, daysOfMonthForSelectedDate, dayIndex, day) {
198
- var selectedDate = (0, _utils.formatDate)(new Date(selectedYear, firstWeekOfMonth >= dayIndex + 1 ? selectedMonth - 1 : daysOfMonthForSelectedDate + firstWeekOfMonth < dayIndex + 1 ? selectedMonth + 1 : selectedMonth, day).getTime() + 86399 * 1000);
199
-
99
+ const handleDisabled = (0, _react.useCallback)((firstWeekOfMonth, daysOfMonthForSelectedDate, dayIndex, day) => {
100
+ const selectedDate = (0, _utils.formatDate)(new Date(selectedYear, firstWeekOfMonth >= dayIndex + 1 ? selectedMonth - 1 : daysOfMonthForSelectedDate + firstWeekOfMonth < dayIndex + 1 ? selectedMonth + 1 : selectedMonth, day).getTime() + 86399 * 1000);
200
101
  if (minDate && minDate > selectedDate || maxDate && maxDate < selectedDate) {
201
102
  return true;
202
103
  }
203
-
204
104
  if (fixedYear) {
205
- var disabledDateInDec = selectedMonth === 11 && dayIndex >= daysOfMonthForSelectedDate + firstWeekOfMonth;
206
- var disabledDateInJan = selectedMonth === 0 && dayIndex < firstWeekOfMonth;
105
+ const disabledDateInDec = selectedMonth === 11 && dayIndex >= daysOfMonthForSelectedDate + firstWeekOfMonth;
106
+ const disabledDateInJan = selectedMonth === 0 && dayIndex < firstWeekOfMonth;
207
107
  return !!(disabledDateInDec || disabledDateInJan);
208
108
  }
209
-
210
109
  return false;
211
110
  }, [fixedYear, minDate, maxDate, selectedMonth, selectedYear]);
212
- var handleChangeDate = (0, _react.useCallback)(function (daysOfMonthForSelectedDate, firstWeekOfMonth, dayIndex, day) {
111
+ const handleChangeDate = (0, _react.useCallback)((daysOfMonthForSelectedDate, firstWeekOfMonth, dayIndex, day) => {
213
112
  if (!fixedYear) {
214
- setSelectedYear(function () {
113
+ setSelectedYear(() => {
215
114
  if (selectedMonth === 0 && dayIndex < firstWeekOfMonth && selectedYear > 1) {
216
115
  return selectedYear - 1;
217
116
  } else if (selectedMonth === 11 && dayIndex >= daysOfMonthForSelectedDate + firstWeekOfMonth) {
218
117
  return selectedYear + 1;
219
118
  }
220
-
221
119
  return selectedYear;
222
120
  });
223
- setConfirmYear(function () {
121
+ setConfirmYear(() => {
224
122
  if (selectedMonth === 0 && dayIndex < firstWeekOfMonth && selectedYear > 1) {
225
123
  return selectedYear - 1;
226
124
  } else if (selectedMonth === 11 && dayIndex >= daysOfMonthForSelectedDate + firstWeekOfMonth) {
227
125
  return selectedYear + 1;
228
126
  }
229
-
230
127
  return selectedYear;
231
128
  });
232
129
  }
233
-
234
- setSelectedMonth(function () {
130
+ setSelectedMonth(() => {
235
131
  if (firstWeekOfMonth > dayIndex) {
236
132
  return selectedMonth !== 0 ? selectedMonth - 1 : 11;
237
133
  } else if (daysOfMonthForSelectedDate + firstWeekOfMonth <= dayIndex) {
238
134
  return selectedMonth !== 11 ? selectedMonth + 1 : 0;
239
135
  }
240
-
241
136
  return selectedMonth;
242
137
  });
243
- setConfirmMonth(function () {
138
+ setConfirmMonth(() => {
244
139
  if (firstWeekOfMonth > dayIndex) {
245
140
  return selectedMonth !== 0 ? selectedMonth - 1 : 11;
246
141
  } else if (daysOfMonthForSelectedDate + firstWeekOfMonth <= dayIndex) {
247
142
  return selectedMonth !== 11 ? selectedMonth + 1 : 0;
248
143
  }
249
-
250
144
  return selectedMonth;
251
145
  });
252
146
  setConfirmDay(day);
253
147
  }, [fixedYear, selectedMonth, selectedYear]);
254
- var handleSelectedDay = (0, _react.useCallback)(function (day, daysOfMonthForSelectedDate, index, firstWeekOfMonth, lastWeekOfMonth) {
148
+ const handleSelectedDay = (0, _react.useCallback)((day, daysOfMonthForSelectedDate, index, firstWeekOfMonth, lastWeekOfMonth) => {
255
149
  if (confirmDay === day && confirmYear === selectedYear && confirmMonth === selectedMonth) {
256
150
  if (firstWeekOfMonth === 6 && lastWeekOfMonth === 6) {
257
151
  return true;
258
152
  } else if (firstWeekOfMonth !== 6 && lastWeekOfMonth === 6) {
259
153
  return index + 1 > firstWeekOfMonth;
260
154
  }
261
-
262
155
  return !!(index + 1 >= firstWeekOfMonth && index + 1 <= daysOfMonthForSelectedDate + firstWeekOfMonth);
263
156
  }
264
-
265
157
  return false;
266
158
  }, [confirmYear, confirmMonth, confirmDay, selectedYear, selectedMonth]);
267
- var handleDisplayDays = (0, _react.useMemo)(function () {
268
- var daysOfMonthForSelectedDate = new Date(selectedYear, selectedMonth + 1, 0).getDate();
269
- var daysOfPrevioueMonthForSelectedDate = new Date(selectedYear, selectedMonth + 1 - 1, 0).getDate();
270
- var firstWeekOfMonth = new Date("".concat(selectedYear, "/").concat(selectedMonth + 1, "/1")).getDay();
271
- var lastWeekOfMonth = new Date("".concat(selectedYear, "/").concat(selectedMonth + 1, "/").concat(daysOfMonthForSelectedDate)).getDay();
272
- var days = [];
273
-
274
- for (var _i2 = 0, _arr2 = _toConsumableArray(Array(daysOfMonthForSelectedDate).keys()); _i2 < _arr2.length; _i2++) {
275
- var day = _arr2[_i2];
159
+ const handleDisplayDays = (0, _react.useMemo)(() => {
160
+ const daysOfMonthForSelectedDate = new Date(selectedYear, selectedMonth + 1, 0).getDate();
161
+ const daysOfPrevioueMonthForSelectedDate = new Date(selectedYear, selectedMonth + 1 - 1, 0).getDate();
162
+ const firstWeekOfMonth = new Date("".concat(selectedYear, "/").concat(selectedMonth + 1, "/1")).getDay();
163
+ const lastWeekOfMonth = new Date("".concat(selectedYear, "/").concat(selectedMonth + 1, "/").concat(daysOfMonthForSelectedDate)).getDay();
164
+ const days = [];
165
+ for (const day of [...Array(daysOfMonthForSelectedDate).keys()]) {
276
166
  days.push(day + 1);
277
167
  }
278
-
279
168
  if (firstWeekOfMonth !== 0) {
280
- for (var index = daysOfPrevioueMonthForSelectedDate; index > daysOfPrevioueMonthForSelectedDate - firstWeekOfMonth; index -= 1) {
169
+ for (let index = daysOfPrevioueMonthForSelectedDate; index > daysOfPrevioueMonthForSelectedDate - firstWeekOfMonth; index -= 1) {
281
170
  days.unshift(index);
282
171
  }
283
172
  }
284
-
285
173
  if (lastWeekOfMonth !== 6) {
286
- for (var _index = 1; _index <= 6 - lastWeekOfMonth; _index += 1) {
287
- days.push(_index);
174
+ for (let index = 1; index <= 6 - lastWeekOfMonth; index += 1) {
175
+ days.push(index);
288
176
  }
289
177
  }
290
-
291
- return days.map(function (day, index) {
178
+ return days.map((day, index) => {
292
179
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Day, {
293
180
  disabled: handleDisabled(firstWeekOfMonth, daysOfMonthForSelectedDate, index, day),
294
- onClick: function onClick() {
181
+ onClick: () => {
295
182
  handleChangeDate(daysOfMonthForSelectedDate, firstWeekOfMonth, index, day);
296
183
  },
297
184
  selected: handleSelectedDay(day, daysOfMonthForSelectedDate, index, firstWeekOfMonth, lastWeekOfMonth),
@@ -299,21 +186,18 @@ var DatePicker = function DatePicker(_ref) {
299
186
  }, index);
300
187
  });
301
188
  }, [selectedMonth, selectedYear, handleDisabled, handleChangeDate, handleSelectedDay]);
302
-
303
- var handleToggle = function handleToggle() {
189
+ const handleToggle = () => {
304
190
  setDisplayPicker(!displayPicker);
305
191
  update();
306
192
  };
307
-
308
- var handleConfirm = function handleConfirm() {
193
+ const handleConfirm = () => {
309
194
  onConfirm(inputValue);
310
195
  setDisplayPicker(false);
311
196
  setCurrentDisplayType(null);
312
197
  };
313
-
314
- (0, _react.useEffect)(function () {
198
+ (0, _react.useEffect)(() => {
315
199
  if (!selected) return;
316
- var date = new Date(selected);
200
+ const date = new Date(selected);
317
201
  setSelectedYear(date.getFullYear());
318
202
  setSelectedMonth(date.getMonth());
319
203
  setSelectedDay(date.getDate());
@@ -322,7 +206,7 @@ var DatePicker = function DatePicker(_ref) {
322
206
  setConfirmDay(date.getDate());
323
207
  setInputValue(selected);
324
208
  }, [selected]);
325
- (0, _react.useEffect)(function () {
209
+ (0, _react.useEffect)(() => {
326
210
  if (!(confirmYear && confirmMonth && confirmDay)) return;
327
211
  setInputValue((0, _utils.formatDate)(new Date(confirmYear, confirmMonth, confirmDay), 'date'));
328
212
  }, [confirmYear, confirmMonth, confirmDay]);
@@ -334,7 +218,8 @@ var DatePicker = function DatePicker(_ref) {
334
218
  onClick: handleToggle,
335
219
  readOnly: true,
336
220
  disabled: disabled
337
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Wrapper, _objectSpread(_objectSpread({}, attributes.popper), {}, {
221
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Wrapper, {
222
+ ...attributes.popper,
338
223
  style: styles.popper,
339
224
  placement: state && state.placement,
340
225
  ref: setContentElement,
@@ -343,8 +228,8 @@ var DatePicker = function DatePicker(_ref) {
343
228
  displayType: currentDisplayType,
344
229
  children: [!fixedYear && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Accordion.default, {
345
230
  type: "year",
346
- handleDisplayAccordionContent: function handleDisplayAccordionContent() {
347
- _handleDisplayAccordionContent('year');
231
+ handleDisplayAccordionContent: () => {
232
+ handleDisplayAccordionContent('year');
348
233
  },
349
234
  handleChangeTitle: handleChangeYear,
350
235
  setCurrentDisplayType: setCurrentDisplayType,
@@ -357,8 +242,8 @@ var DatePicker = function DatePicker(_ref) {
357
242
  fixedYear: fixedYear
358
243
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Accordion.default, {
359
244
  type: "month",
360
- handleDisplayAccordionContent: function handleDisplayAccordionContent() {
361
- _handleDisplayAccordionContent('month');
245
+ handleDisplayAccordionContent: () => {
246
+ handleDisplayAccordionContent('month');
362
247
  },
363
248
  handleChangeTitle: handleChangeMonth,
364
249
  setCurrentDisplayType: setCurrentDisplayType,
@@ -381,39 +266,40 @@ var DatePicker = function DatePicker(_ref) {
381
266
  children: t('Confirm')
382
267
  })
383
268
  })]
384
- }))]
269
+ })]
385
270
  });
386
271
  };
387
-
388
- var Wrapper = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding-bottom: var(--spacing-s);\n background: var(--color-background1);\n border-radius: var(--border-radius);\n border: var(--border-width) solid var(--border-color);\n box-shadow: var(--box-shadow);\n overflow: hidden;\n width: 286px;\n z-index: 1;\n color: var(--font-on-background);\n\n display: ", ";\n"])), function (_ref2) {
389
- var displayPicker = _ref2.displayPicker;
272
+ const Wrapper = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding-bottom: var(--spacing-s);\n background: var(--color-background1);\n border-radius: var(--border-radius);\n border: var(--border-width) solid var(--border-color);\n box-shadow: var(--box-shadow);\n overflow: hidden;\n width: 286px;\n z-index: 1;\n color: var(--font-on-background);\n\n display: ", ";\n"])), _ref2 => {
273
+ let {
274
+ displayPicker
275
+ } = _ref2;
390
276
  return displayPicker ? 'block' : 'none';
391
277
  });
392
-
393
- var Week = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n min-width: 36px;\n height: 36px;\n border-radius: var(--border-radius-s);\n line-height: 36px;\n text-align: center;\n"])));
394
-
395
- var Day = _styledComponents.default.button(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n min-width: 36px;\n height: 36px;\n border-radius: var(--border-radius-s);\n line-height: 36px;\n text-align: center;\n padding: 0;\n border: 0;\n background: var(--color-background1);\n color: var(--font-on-background);\n &:hover {\n background: var(--color-primary);\n }\n\n ", "\n\n ", "\n"])), function (_ref3) {
396
- var selected = _ref3.selected;
278
+ const Week = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n min-width: 36px;\n height: 36px;\n border-radius: var(--border-radius-s);\n line-height: 36px;\n text-align: center;\n"])));
279
+ const Day = _styledComponents.default.button(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n min-width: 36px;\n height: 36px;\n border-radius: var(--border-radius-s);\n line-height: 36px;\n text-align: center;\n padding: 0;\n border: 0;\n background: var(--color-background1);\n color: var(--font-on-background);\n &:hover {\n background: var(--color-primary);\n }\n\n ", "\n\n ", "\n"])), _ref3 => {
280
+ let {
281
+ selected
282
+ } = _ref3;
397
283
  return selected && 'background: var(--color-hover);';
398
- }, function (_ref4) {
399
- var disabled = _ref4.disabled;
284
+ }, _ref4 => {
285
+ let {
286
+ disabled
287
+ } = _ref4;
400
288
  return disabled && (0, _styledComponents.css)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n color: var(--font-on-mute);\n background: none;\n &:hover {\n background: none;\n }\n "])));
401
289
  });
402
-
403
- var DateContent = _styledComponents.default.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: wrap;\n"])));
404
-
405
- var PickerInput = (0, _styledComponents.default)(_Input.default)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n &:disabled {\n cursor: not-allowed;\n opacity: 0.5;\n }\n"])));
406
- var ConfirmButton = (0, _styledComponents.default)(_Button.default)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n margin: 16px auto 0;\n"])));
407
-
408
- var Body = _styledComponents.default.div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n ", "\n\n overflow: hidden;\n padding: ", ";\n"])), function (_ref5) {
409
- var displayType = _ref5.displayType;
290
+ const DateContent = _styledComponents.default.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: wrap;\n"])));
291
+ const PickerInput = (0, _styledComponents.default)(_Input.default)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n &:disabled {\n cursor: not-allowed;\n opacity: 0.5;\n }\n"])));
292
+ const ConfirmButton = (0, _styledComponents.default)(_Button.default)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n margin: 16px auto 0;\n"])));
293
+ const Body = _styledComponents.default.div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n ", "\n\n overflow: hidden;\n padding: ", ";\n"])), _ref5 => {
294
+ let {
295
+ displayType
296
+ } = _ref5;
410
297
  return displayType && (0, _styledComponents.css)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n height: 216px;\n "])));
411
- }, function (_ref6) {
412
- var displayType = _ref6.displayType;
298
+ }, _ref6 => {
299
+ let {
300
+ displayType
301
+ } = _ref6;
413
302
  return displayType === 'year' ? ' 0 4px var(--spacing-s) var(--spacing-s)' : '0 var(--spacing-s) 0 var(--spacing-s)';
414
303
  });
415
-
416
- var Footer = _styledComponents.default.div(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n padding: 0 var(--spacing-s);\n"])));
417
-
418
- var _default = DatePicker;
419
- exports.default = _default;
304
+ const Footer = _styledComponents.default.div(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n padding: 0 var(--spacing-s);\n"])));
305
+ var _default = exports.default = DatePicker;