@cashub/ui 0.21.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 (229) 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 +9 -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 +13 -15
  104. package/form/Label.js +10 -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 +14 -0
  109. package/form/SwitchButton.js +34 -39
  110. package/form/Textarea.js +2 -11
  111. package/form/index.js +9 -19
  112. package/grid/Column.js +17 -17
  113. package/grid/Grid.js +13 -14
  114. package/grid/index.js +2 -5
  115. package/heading/Heading1.js +5 -10
  116. package/heading/Heading2.js +9 -12
  117. package/heading/Heading3.js +21 -18
  118. package/heading/index.js +3 -7
  119. package/helmet/Helmet.js +6 -9
  120. package/helmet/index.js +2 -5
  121. package/iconbox/ApplicationIconBox.js +25 -31
  122. package/iconbox/IconBox.js +11 -24
  123. package/iconbox/IconBoxV2.js +14 -26
  124. package/iconbox/index.js +3 -7
  125. package/iconbox/subComponent/IconBoxFigure.js +25 -20
  126. package/iconbox/subComponent/IconBoxImage.js +15 -18
  127. package/image/ImageFluid.js +2 -10
  128. package/image/UploadImage.js +65 -113
  129. package/image/index.js +2 -5
  130. package/index.js +44 -130
  131. package/jsoneditor/JsonEditor.js +10 -32
  132. package/jsoneditor/index.js +1 -3
  133. package/keyframe/Pulse.js +2 -7
  134. package/keyframe/Spin.js +2 -7
  135. package/link/LinkSpan.js +22 -35
  136. package/link/index.js +1 -3
  137. package/map/GoogleMap.js +122 -175
  138. package/map/GoogleReverseGeolocation.js +79 -186
  139. package/map/LeafletMap.js +78 -132
  140. package/map/LeafletReverseGeolocation.js +49 -121
  141. package/map/index.js +4 -9
  142. package/map/subComponent/BasicLeafletMap.js +8 -14
  143. package/map/subComponent/GoogleMapContainer.js +5 -10
  144. package/map/subComponent/GoogleMapPopup.js +66 -123
  145. package/map/subComponent/GoogleMapWrapper.js +13 -32
  146. package/map/subComponent/GoogleMarkerSpiderfier.js +14 -24
  147. package/map/subComponent/LeafletDrawControl.js +47 -84
  148. package/map/subComponent/LeafletMapContainer.js +5 -10
  149. package/map/subComponent/MapSearchBoxControl.js +24 -70
  150. package/modal/StateModal.js +41 -100
  151. package/modal/TitleModal.js +89 -190
  152. package/modal/index.js +2 -5
  153. package/package.json +1 -1
  154. package/paginate/Paginate.js +40 -54
  155. package/paginate/index.js +1 -3
  156. package/popover/Popover.js +39 -87
  157. package/popover/index.js +1 -3
  158. package/qrcode/QRCode.js +10 -23
  159. package/qrcode/QRCodeContainter.js +8 -16
  160. package/qrcode/index.js +2 -5
  161. package/ribbon/Ribbon.js +4 -15
  162. package/ribbon/index.js +1 -3
  163. package/section/Section.js +57 -39
  164. package/section/SectionBody.js +15 -22
  165. package/section/SectionHeader.js +27 -27
  166. package/section/SectionToolbar.js +2 -9
  167. package/section/SectionToolbarItem.js +2 -9
  168. package/section/index.js +5 -11
  169. package/select/InputSelect.js +103 -215
  170. package/select/Select.js +204 -362
  171. package/select/index.js +2 -5
  172. package/select/subComponent/ListBox.js +9 -12
  173. package/select/subComponent/Option.js +8 -16
  174. package/select/subComponent/OptionGroup.js +2 -9
  175. package/select/subComponent/Options.js +5 -11
  176. package/select/subComponent/SearchBox.js +9 -29
  177. package/select/subComponent/SelectedMultiple.js +8 -16
  178. package/select/subComponent/SelectedSingle.js +2 -9
  179. package/styles/GlobalStyle.js +169 -91
  180. package/styles/config/breakpoint.style.js +2 -3
  181. package/styles/config/header.style.js +2 -3
  182. package/styles/config/sidebar.style.js +2 -3
  183. package/styles/index.js +2 -5
  184. package/styles/mixin/backgroundColor.js +17 -14
  185. package/styles/mixin/borderColor.js +17 -14
  186. package/styles/mixin/color.js +17 -14
  187. package/styles/mixin/colorOnBackground.js +17 -14
  188. package/styles/mixin/inputPlaceholder.js +3 -9
  189. package/styles/mixin/media.js +3 -11
  190. package/styles/mixin/rounded.js +13 -12
  191. package/styles/mixin/scrollbar.js +7 -13
  192. package/styles/theme/dark.theme.js +20 -20
  193. package/styles/theme/light.theme.js +20 -20
  194. package/styles/theme/white.theme.js +20 -20
  195. package/styles/themes.js +2 -8
  196. package/table/GridTable.js +105 -143
  197. package/table/ImageBox.js +8 -18
  198. package/table/PermissionTable.js +25 -25
  199. package/table/Table.js +137 -153
  200. package/table/__mock__/columns.js +2 -3
  201. package/table/__mock__/data.js +2 -3
  202. package/table/hooks/index.js +2 -5
  203. package/table/hooks/useCalculateDataRange.js +9 -36
  204. package/table/hooks/useGenerateSort.js +6 -17
  205. package/table/index.js +4 -9
  206. package/table/subComponent/BaseTableHeadCell.js +15 -21
  207. package/table/subComponent/GridTableFooter.js +5 -10
  208. package/table/subComponent/GridTableHeadCell.js +5 -10
  209. package/table/subComponent/Resizer.js +17 -44
  210. package/table/subComponent/TableFooter.js +5 -10
  211. package/table/subComponent/TableFooterInfo.js +2 -9
  212. package/table/subComponent/TableFooterPager.js +5 -12
  213. package/table/subComponent/TableHeadCell.js +2 -9
  214. package/table/subComponent/TableSort.js +13 -19
  215. package/tagify/TagifyStyle.js +2 -9
  216. package/tagify/Tags.js +15 -37
  217. package/tagify/index.js +2 -5
  218. package/text/Paragraph.js +25 -20
  219. package/text/index.js +1 -3
  220. package/timeline/Timeline.js +28 -37
  221. package/timeline/index.js +1 -3
  222. package/toast/CustomToastContainer.js +2 -9
  223. package/toast/MessageContainer.js +9 -18
  224. package/toast/index.js +3 -8
  225. package/toast/show.js +18 -28
  226. package/tooltip/Tooltip.js +48 -97
  227. package/tooltip/index.js +1 -3
  228. package/wizard/Wizard.js +63 -133
  229. package/wizard/index.js +1 -3
@@ -1,184 +1,105 @@
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 _reactI18next = require("react-i18next");
13
-
14
9
  var _reactOutsideClickHandler = _interopRequireDefault(require("react-outside-click-handler"));
15
-
16
10
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
17
-
18
11
  var _md = require("react-icons/md");
19
-
20
12
  var _hooks = require("@cashub/hooks");
21
-
22
13
  var _utils = require("@cashub/utils");
23
-
24
14
  var _Button = _interopRequireDefault(require("../button/Button"));
25
-
26
15
  var _Input = _interopRequireDefault(require("../form/Input"));
27
-
28
16
  var _Month = _interopRequireDefault(require("./accordion/Month"));
29
-
30
17
  var _Year = _interopRequireDefault(require("./accordion/Year"));
31
-
32
18
  var _DateTimePickerContext = _interopRequireDefault(require("./subComponent/DateTimePickerContext"));
33
-
34
19
  var _toUTC = _interopRequireDefault(require("./utils/toUTC0"));
35
-
36
20
  var _jsxRuntime = require("react/jsx-runtime");
37
-
38
21
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
39
-
40
- 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); }
41
-
42
- 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; }
43
-
22
+ 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); }
23
+ 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; }
44
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
45
-
46
25
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
47
-
48
- 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; }
49
-
50
- 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; }
51
-
52
- 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; }
53
-
54
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
55
-
56
- 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."); }
57
-
58
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
59
-
60
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
61
-
62
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
63
-
64
- 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."); }
65
-
66
- 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); }
67
-
68
- 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; }
69
-
70
- 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; }
71
-
72
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
73
-
74
- var DEFAULT_TIME = '00:00:00';
75
-
76
- var DatePickerV2 = function DatePickerV2(_ref) {
77
- var selected = _ref.selected,
78
- fixedYear = _ref.fixedYear,
79
- allowClear = _ref.allowClear,
80
- minDate = _ref.minDate,
81
- maxDate = _ref.maxDate,
82
- onConfirm = _ref.onConfirm,
83
- disabled = _ref.disabled;
84
-
85
- var _useTranslation = (0, _reactI18next.useTranslation)(),
86
- t = _useTranslation.t;
87
-
88
- var _useState = (0, _react.useState)(null),
89
- _useState2 = _slicedToArray(_useState, 2),
90
- toggleElement = _useState2[0],
91
- setToggleElement = _useState2[1];
92
-
93
- var _useState3 = (0, _react.useState)(null),
94
- _useState4 = _slicedToArray(_useState3, 2),
95
- contentElement = _useState4[0],
96
- setContentElement = _useState4[1];
97
-
98
- var _useState5 = (0, _react.useState)(function () {
99
- var defaultDate = selected ? new Date(selected) : new Date();
26
+ const DEFAULT_TIME = '00:00:00';
27
+ const DatePickerV2 = _ref => {
28
+ let {
29
+ selected,
30
+ fixedYear,
31
+ allowClear,
32
+ minDate,
33
+ maxDate,
34
+ onConfirm,
35
+ disabled
36
+ } = _ref;
37
+ const {
38
+ t
39
+ } = (0, _reactI18next.useTranslation)();
40
+ const [toggleElement, setToggleElement] = (0, _react.useState)(null);
41
+ const [contentElement, setContentElement] = (0, _react.useState)(null);
42
+ const [selectedDate, setSelectedDate] = (0, _react.useState)(() => {
43
+ const defaultDate = selected ? new Date(selected) : new Date();
100
44
  return "".concat((0, _utils.formatDate)((0, _toUTC.default)(defaultDate), 'date'), " ").concat(DEFAULT_TIME);
101
- }),
102
- _useState6 = _slicedToArray(_useState5, 2),
103
- selectedDate = _useState6[0],
104
- setSelectedDate = _useState6[1];
105
-
106
- var _useState7 = (0, _react.useState)(selected ? (0, _utils.formatDate)((0, _toUTC.default)(selected), 'date') : ''),
107
- _useState8 = _slicedToArray(_useState7, 2),
108
- confirmDate = _useState8[0],
109
- setConfirmDate = _useState8[1];
110
-
111
- var _useState9 = (0, _react.useState)(false),
112
- _useState10 = _slicedToArray(_useState9, 2),
113
- displayPicker = _useState10[0],
114
- setDisplayPicker = _useState10[1];
115
-
116
- var _useState11 = (0, _react.useState)(null),
117
- _useState12 = _slicedToArray(_useState11, 2),
118
- accordionCurrentDisplayType = _useState12[0],
119
- setAccordionCurrentDisplayType = _useState12[1];
120
-
121
- var weeks = (0, _react.useMemo)(function () {
122
- return ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'].map(function (week) {
123
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Week, {
124
- children: week
125
- }, week);
126
- });
45
+ });
46
+ const [confirmDate, setConfirmDate] = (0, _react.useState)(selected ? (0, _utils.formatDate)((0, _toUTC.default)(selected), 'date') : '');
47
+ const [displayPicker, setDisplayPicker] = (0, _react.useState)(false);
48
+ const [accordionCurrentDisplayType, setAccordionCurrentDisplayType] = (0, _react.useState)(null);
49
+ const weeks = (0, _react.useMemo)(() => {
50
+ return ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'].map(week => /*#__PURE__*/(0, _jsxRuntime.jsx)(Week, {
51
+ children: week
52
+ }, week));
127
53
  }, []);
128
- var minDateWithTime = (0, _react.useMemo)(function () {
54
+ const minDateWithTime = (0, _react.useMemo)(() => {
129
55
  if (!minDate) return;
130
56
  return "".concat(minDate, " 00:00:00");
131
57
  }, [minDate]);
132
- var maxDateWithTime = (0, _react.useMemo)(function () {
58
+ const maxDateWithTime = (0, _react.useMemo)(() => {
133
59
  if (!maxDate) return;
134
60
  return "".concat(maxDate, " 00:00:00");
135
61
  }, [maxDate]);
136
-
137
- var _useCustomPopper = (0, _hooks.useCustomPopper)(toggleElement, contentElement, {
62
+ const {
63
+ styles,
64
+ attributes,
65
+ state,
66
+ update
67
+ } = (0, _hooks.useCustomPopper)(toggleElement, contentElement, {
138
68
  strategy: 'absolute',
139
69
  placement: 'bottom-start'
140
- }),
141
- styles = _useCustomPopper.styles,
142
- attributes = _useCustomPopper.attributes,
143
- state = _useCustomPopper.state,
144
- update = _useCustomPopper.update;
145
-
146
- var context = {
147
- fixedYear: fixedYear,
70
+ });
71
+ const context = {
72
+ fixedYear,
148
73
  minDate: minDateWithTime,
149
74
  maxDate: maxDateWithTime,
150
- selectedDate: selectedDate,
151
- setSelectedDate: setSelectedDate,
152
- setAccordionCurrentDisplayType: setAccordionCurrentDisplayType
75
+ selectedDate,
76
+ setSelectedDate,
77
+ setAccordionCurrentDisplayType
153
78
  };
154
-
155
- var handleToggle = function handleToggle() {
79
+ const handleToggle = () => {
156
80
  setDisplayPicker(!displayPicker);
157
81
  update();
158
82
  };
159
-
160
- var changeDisplayAccordion = (0, _react.useCallback)(function (type) {
83
+ const changeDisplayAccordion = (0, _react.useCallback)(type => {
161
84
  if (accordionCurrentDisplayType === type) {
162
85
  setAccordionCurrentDisplayType(null);
163
86
  } else {
164
87
  setAccordionCurrentDisplayType(type);
165
88
  }
166
89
  }, [accordionCurrentDisplayType]);
167
- var handleConfirm = (0, _react.useCallback)(function () {
90
+ const handleConfirm = (0, _react.useCallback)(() => {
168
91
  if (confirmDate) {
169
92
  onConfirm(confirmDate);
170
93
  }
171
-
172
94
  setDisplayPicker(false);
173
95
  setAccordionCurrentDisplayType(null);
174
96
  }, [confirmDate, onConfirm]);
175
- var handleChangeDate = (0, _react.useCallback)(function (daysOfMonthForSelectedDate, firstWeekOfMonth, dayIndex, day) {
176
- var date = new Date(selectedDate); // 先把日期設定成所有月分都有的日期,設定月份時才不會設定到非預期的date
177
-
97
+ const handleChangeDate = (0, _react.useCallback)((daysOfMonthForSelectedDate, firstWeekOfMonth, dayIndex, day) => {
98
+ const date = new Date(selectedDate);
99
+ // 先把日期設定成所有月分都有的日期,設定月份時才不會設定到非預期的date
178
100
  date.setDate(1);
179
- var selectedYear = date.getFullYear();
180
- var selectedMonth = date.getMonth();
181
-
101
+ const selectedYear = date.getFullYear();
102
+ const selectedMonth = date.getMonth();
182
103
  if (!fixedYear) {
183
104
  if (dayIndex < firstWeekOfMonth && selectedYear >= 1) {
184
105
  if (selectedMonth === 0) {
@@ -195,44 +116,34 @@ var DatePickerV2 = function DatePickerV2(_ref) {
195
116
  date.setMonth(selectedMonth + 1);
196
117
  }
197
118
  }
198
-
199
119
  date.setDate(day);
200
120
  } else if (fixedYear) {
201
121
  if (dayIndex < firstWeekOfMonth) {
202
122
  if (selectedMonth === 0) {
203
123
  return;
204
124
  }
205
-
206
125
  date.setMonth(selectedMonth - 1);
207
126
  } else if (dayIndex >= daysOfMonthForSelectedDate + firstWeekOfMonth) {
208
127
  if (selectedMonth === 11) {
209
128
  return;
210
129
  }
211
-
212
130
  date.setMonth(selectedMonth + 1);
213
131
  }
214
-
215
132
  date.setDate(day);
216
133
  }
217
-
218
- var formattedDate = (0, _utils.formatDate)(date, 'date');
134
+ const formattedDate = (0, _utils.formatDate)(date, 'date');
219
135
  setSelectedDate("".concat(formattedDate, " ").concat(DEFAULT_TIME));
220
136
  setConfirmDate(formattedDate);
221
137
  }, [fixedYear, selectedDate]);
222
- var handleDisabled = (0, _react.useCallback)(function (firstDayOfMonth, lastDayOfMonth, daysOfMonthForSelectedDate, dayIndex, day) {
223
- var _selectedDate$split = selectedDate.split('-'),
224
- _selectedDate$split2 = _slicedToArray(_selectedDate$split, 2),
225
- year = _selectedDate$split2[0],
226
- month = _selectedDate$split2[1]; // disabled date before first month of first year
227
-
138
+ const handleDisabled = (0, _react.useCallback)((firstDayOfMonth, lastDayOfMonth, daysOfMonthForSelectedDate, dayIndex, day) => {
139
+ let [year, month] = selectedDate.split('-');
228
140
 
141
+ // disabled date before first month of first year
229
142
  if (year === '0001' && month === '01' && dayIndex < firstDayOfMonth) {
230
143
  return true;
231
144
  }
232
-
233
- var myDay = day.toString();
145
+ let myDay = day.toString();
234
146
  if (myDay.length === 1) myDay = "0".concat(myDay);
235
-
236
147
  if (fixedYear) {
237
148
  if (month === '01') {
238
149
  // disabled date before first month
@@ -241,91 +152,77 @@ var DatePickerV2 = function DatePickerV2(_ref) {
241
152
  // disabled date in december
242
153
  return dayIndex >= daysOfMonthForSelectedDate + firstDayOfMonth;
243
154
  }
244
- } // previous year's date
245
-
155
+ }
246
156
 
157
+ // previous year's date
247
158
  if (month === '01' && firstDayOfMonth !== 0 && dayIndex + 1 <= firstDayOfMonth) {
248
159
  year = +year - 1;
249
- } // next year's date
250
-
160
+ }
251
161
 
162
+ // next year's date
252
163
  if (month === '12' && lastDayOfMonth !== 6 && day + firstDayOfMonth < dayIndex + 1) {
253
164
  year = +year + 1;
254
165
  }
255
-
256
166
  month = firstDayOfMonth >= dayIndex + 1 ? +month - 1 : daysOfMonthForSelectedDate + firstDayOfMonth < dayIndex + 1 ? +month + 1 : +month;
257
-
258
167
  if (month < 1) {
259
168
  month = 12;
260
169
  } else if (month > 12) {
261
170
  month = 1;
262
171
  }
263
-
264
172
  month = month.toString();
265
-
266
173
  if (month.length === 1) {
267
174
  month = "0".concat(month);
268
175
  }
269
-
270
176
  year = year.toString();
271
177
  if (year.length === 1) year = "000".concat(year);
272
178
  if (year.length === 2) year = "00".concat(year);
273
179
  if (year.length === 3) year = "0".concat(year);
274
- var currentDate = "".concat(year, "-").concat(month, "-").concat(myDay, " ").concat(DEFAULT_TIME);
275
-
180
+ const currentDate = "".concat(year, "-").concat(month, "-").concat(myDay, " ").concat(DEFAULT_TIME);
276
181
  if (minDateWithTime && currentDate < minDateWithTime) {
277
182
  return true;
278
183
  }
279
-
280
184
  if (maxDateWithTime && currentDate > maxDateWithTime) {
281
185
  return true;
282
186
  }
283
-
284
187
  return false;
285
188
  }, [fixedYear, minDateWithTime, maxDateWithTime, selectedDate]);
286
- var isSelectedDay = (0, _react.useCallback)(function (day, index, firstDayOfMonth, daysOfMonthForSelectedDate) {
287
- var selectedDateObj = new Date(selectedDate);
288
- var confirmDateObj = (0, _toUTC.default)(new Date(confirmDate));
289
-
189
+ const isSelectedDay = (0, _react.useCallback)((day, index, firstDayOfMonth, daysOfMonthForSelectedDate) => {
190
+ const selectedDateObj = new Date(selectedDate);
191
+ const confirmDateObj = (0, _toUTC.default)(new Date(confirmDate));
290
192
  if (confirmDateObj.getFullYear() === selectedDateObj.getFullYear() && confirmDateObj.getMonth() === selectedDateObj.getMonth() && confirmDateObj.getDate() === day) {
291
193
  if (index + 1 > firstDayOfMonth && index < daysOfMonthForSelectedDate + firstDayOfMonth) {
292
194
  return true;
293
195
  }
294
-
295
196
  return false;
296
197
  }
297
-
298
198
  return false;
299
199
  }, [selectedDate, confirmDate]);
200
+ const getLastDateOfMonth = selectedDate => {
201
+ const date = new Date(selectedDate);
300
202
 
301
- var getLastDateOfMonth = function getLastDateOfMonth(selectedDate) {
302
- var date = new Date(selectedDate); // 先把日期設定成所有月分都有的日期,設定月份時才不會設定到非預期的date
303
-
203
+ // 先把日期設定成所有月分都有的日期,設定月份時才不會設定到非預期的date
304
204
  date.setDate(1);
305
205
  date.setMonth(date.getMonth() + 1);
306
206
  date.setDate(0);
307
207
  return date;
308
208
  };
309
-
310
- var days = (0, _react.useMemo)(function () {
311
- var lastDateOfSelectedDate = getLastDateOfMonth(selectedDate);
312
- var daysOfMonthForSelectedDate = lastDateOfSelectedDate.getDate();
313
- var lastDayOfMonth = lastDateOfSelectedDate.getDay();
314
- var date = new Date(selectedDate);
209
+ const days = (0, _react.useMemo)(() => {
210
+ const lastDateOfSelectedDate = getLastDateOfMonth(selectedDate);
211
+ const daysOfMonthForSelectedDate = lastDateOfSelectedDate.getDate();
212
+ const lastDayOfMonth = lastDateOfSelectedDate.getDay();
213
+ let date = new Date(selectedDate);
315
214
  date.setMonth(date.getMonth() + 1 - 1);
316
215
  date.setDate(0);
317
- var daysOfPrevioueMonthForSelectedDate = date.getDate();
318
- date = new Date(selectedDate); // 先把日期設定成所有月分都有的日期,設定月份時才不會設定到非預期的date
319
-
216
+ const daysOfPrevioueMonthForSelectedDate = date.getDate();
217
+ date = new Date(selectedDate);
218
+ // 先把日期設定成所有月分都有的日期,設定月份時才不會設定到非預期的date
320
219
  date.setDate(1);
321
- var firstDayOfMonth = date.getDay();
322
-
323
- var days = _toConsumableArray(Array(daysOfMonthForSelectedDate)).map(function (value, index) {
220
+ const firstDayOfMonth = date.getDay();
221
+ const days = [...Array(daysOfMonthForSelectedDate)].map((value, index) => {
324
222
  return index + 1;
325
223
  });
326
-
327
224
  if (firstDayOfMonth !== 0) {
328
- for (var index = daysOfPrevioueMonthForSelectedDate; index > daysOfPrevioueMonthForSelectedDate - firstDayOfMonth; index -= 1) {
225
+ for (let index = daysOfPrevioueMonthForSelectedDate; index > daysOfPrevioueMonthForSelectedDate - firstDayOfMonth; index -= 1) {
329
226
  if (date.getFullYear() === 1 && date.getMonth() === 0) {
330
227
  days.unshift(null);
331
228
  } else {
@@ -333,17 +230,15 @@ var DatePickerV2 = function DatePickerV2(_ref) {
333
230
  }
334
231
  }
335
232
  }
336
-
337
233
  if (lastDayOfMonth !== 6) {
338
- for (var _index = 1; _index <= 6 - lastDayOfMonth; _index += 1) {
339
- days.push(_index);
234
+ for (let index = 1; index <= 6 - lastDayOfMonth; index += 1) {
235
+ days.push(index);
340
236
  }
341
237
  }
342
-
343
- return days.map(function (day, index) {
238
+ return days.map((day, index) => {
344
239
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Day, {
345
240
  disabled: handleDisabled(firstDayOfMonth, lastDayOfMonth, daysOfMonthForSelectedDate, index, day),
346
- onClick: function onClick() {
241
+ onClick: () => {
347
242
  handleChangeDate(daysOfMonthForSelectedDate, firstDayOfMonth, index, day);
348
243
  },
349
244
  selected: isSelectedDay(day, index, firstDayOfMonth, daysOfMonthForSelectedDate),
@@ -351,9 +246,9 @@ var DatePickerV2 = function DatePickerV2(_ref) {
351
246
  }, index);
352
247
  });
353
248
  }, [selectedDate, handleChangeDate, isSelectedDay, handleDisabled]);
354
- (0, _react.useEffect)(function () {
249
+ (0, _react.useEffect)(() => {
355
250
  if (selected) {
356
- var formattedDate = (0, _utils.formatDate)((0, _toUTC.default)(selected), 'date');
251
+ const formattedDate = (0, _utils.formatDate)((0, _toUTC.default)(selected), 'date');
357
252
  setSelectedDate("".concat(formattedDate, " ").concat(DEFAULT_TIME));
358
253
  setConfirmDate(formattedDate);
359
254
  } else {
@@ -372,12 +267,13 @@ var DatePickerV2 = function DatePickerV2(_ref) {
372
267
  onClick: handleToggle,
373
268
  readOnly: true
374
269
  }), confirmDate && !disabled && allowClear && /*#__PURE__*/(0, _jsxRuntime.jsx)(CloseButton, {
375
- onClick: function onClick() {
270
+ onClick: () => {
376
271
  setConfirmDate('');
377
272
  onConfirm('');
378
273
  }
379
274
  })]
380
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Picker, _objectSpread(_objectSpread({}, attributes.popper), {}, {
275
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Picker, {
276
+ ...attributes.popper,
381
277
  style: styles.popper,
382
278
  placement: state && state.placement,
383
279
  ref: setContentElement,
@@ -386,12 +282,12 @@ var DatePickerV2 = function DatePickerV2(_ref) {
386
282
  accordionCurrentDisplayType: accordionCurrentDisplayType,
387
283
  children: [!fixedYear && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Year.default, {
388
284
  expand: accordionCurrentDisplayType === 'year',
389
- handleDisplayAccordionContent: function handleDisplayAccordionContent() {
285
+ handleDisplayAccordionContent: () => {
390
286
  changeDisplayAccordion('year');
391
287
  }
392
288
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Month.default, {
393
289
  expand: accordionCurrentDisplayType === 'month',
394
- handleDisplayAccordionContent: function handleDisplayAccordionContent() {
290
+ handleDisplayAccordionContent: () => {
395
291
  changeDisplayAccordion('month');
396
292
  },
397
293
  confirmDate: confirmDate
@@ -406,44 +302,43 @@ var DatePickerV2 = function DatePickerV2(_ref) {
406
302
  children: t('Confirm')
407
303
  })
408
304
  })]
409
- }))]
305
+ })]
410
306
  })
411
307
  });
412
308
  };
413
-
414
- var Wrapper = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n"])));
415
-
416
- var CloseButton = (0, _styledComponents.default)(_md.MdClose)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n color: var(--font-on-background);\n font-size: var(--font-body1);\n right: var(--spacing-s);\n cursor: pointer;\n"])));
309
+ const Wrapper = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n"])));
310
+ const CloseButton = (0, _styledComponents.default)(_md.MdClose)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n color: var(--font-on-background);\n font-size: var(--font-body1);\n right: var(--spacing-s);\n cursor: pointer;\n"])));
417
311
  CloseButton.displayName = 'CloseButton';
418
-
419
- var Picker = _styledComponents.default.div(_templateObject3 || (_templateObject3 = _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) {
420
- var displayPicker = _ref2.displayPicker;
312
+ const Picker = _styledComponents.default.div(_templateObject3 || (_templateObject3 = _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 => {
313
+ let {
314
+ displayPicker
315
+ } = _ref2;
421
316
  return displayPicker ? 'block' : 'none';
422
317
  });
423
-
424
- var Week = _styledComponents.default.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n width: calc(100% / 7);\n height: 36px;\n border-radius: var(--border-radius-s);\n line-height: 36px;\n text-align: center;\n"])));
425
-
426
- var Body = _styledComponents.default.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n ", "\n\n overflow: hidden;\n padding: ", ";\n"])), function (_ref3) {
427
- var accordionCurrentDisplayType = _ref3.accordionCurrentDisplayType;
318
+ const Week = _styledComponents.default.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n width: calc(100% / 7);\n height: 36px;\n border-radius: var(--border-radius-s);\n line-height: 36px;\n text-align: center;\n"])));
319
+ const Body = _styledComponents.default.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n ", "\n\n overflow: hidden;\n padding: ", ";\n"])), _ref3 => {
320
+ let {
321
+ accordionCurrentDisplayType
322
+ } = _ref3;
428
323
  return accordionCurrentDisplayType && (0, _styledComponents.css)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n height: 216px;\n "])));
429
- }, function (_ref4) {
430
- var accordionCurrentDisplayType = _ref4.accordionCurrentDisplayType;
324
+ }, _ref4 => {
325
+ let {
326
+ accordionCurrentDisplayType
327
+ } = _ref4;
431
328
  return accordionCurrentDisplayType === 'year' ? ' 0 4px var(--spacing-s) var(--spacing-s)' : '0 var(--spacing-s) 0 var(--spacing-s)';
432
329
  });
433
-
434
- var Footer = _styledComponents.default.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n padding: 0 var(--spacing-s);\n"])));
435
-
436
- var Day = _styledComponents.default.button(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n width: calc(100% / 7);\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 (_ref5) {
437
- var selected = _ref5.selected;
330
+ const Footer = _styledComponents.default.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n padding: 0 var(--spacing-s);\n"])));
331
+ const Day = _styledComponents.default.button(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n width: calc(100% / 7);\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"])), _ref5 => {
332
+ let {
333
+ selected
334
+ } = _ref5;
438
335
  return selected && 'background: var(--color-hover);';
439
- }, function (_ref6) {
440
- var disabled = _ref6.disabled;
336
+ }, _ref6 => {
337
+ let {
338
+ disabled
339
+ } = _ref6;
441
340
  return disabled && (0, _styledComponents.css)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n color: var(--font-on-mute);\n background: none;\n &:hover {\n background: none;\n }\n "])));
442
341
  });
443
-
444
- var ConfirmButton = (0, _styledComponents.default)(_Button.default)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n margin: 16px auto 0;\n"])));
445
-
446
- var DateContent = _styledComponents.default.div(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: wrap;\n"])));
447
-
448
- var _default = DatePickerV2;
449
- exports.default = _default;
342
+ const ConfirmButton = (0, _styledComponents.default)(_Button.default)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n margin: 16px auto 0;\n"])));
343
+ const DateContent = _styledComponents.default.div(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n display: flex;\n flex-wrap: wrap;\n"])));
344
+ var _default = exports.default = DatePickerV2;