@cashub/ui-elv 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. package/chart/BarChart.js +8 -2
  2. package/chart/DoughnutChart.js +2 -1
  3. package/chart/LineChart.js +2 -1
  4. package/chart/utils/customTooltip.js +3 -7
  5. package/chart/utils/customTooltipLifecyclePlugin.js +21 -0
  6. package/chart/utils/tooltipElement.js +25 -0
  7. package/chart/utils/xAxisLabelTooltipPlugin.js +107 -0
  8. package/datetimePicker/index.js +2 -37
  9. package/esm/Tab/Tab.js +21 -0
  10. package/esm/Tab/TabList.js +160 -0
  11. package/esm/Tab/TabPanel.js +42 -0
  12. package/esm/Tab/TabTab.js +98 -0
  13. package/esm/Tab/index.js +23 -0
  14. package/esm/Tab/subComponent/TabContext.js +3 -0
  15. package/esm/Tab/subComponent/TabListV2.js +18 -0
  16. package/esm/Tab/subComponent/TabPanelV2.js +45 -0
  17. package/esm/Tab/subComponent/TabTabV2.js +56 -0
  18. package/esm/VerticalTab/TabList.js +20 -0
  19. package/esm/VerticalTab/TabPanel.js +45 -0
  20. package/esm/VerticalTab/TabTab.js +63 -0
  21. package/esm/VerticalTab/VerticalTab.js +34 -0
  22. package/esm/VerticalTab/index.js +9 -0
  23. package/esm/VerticalTab/subComponent/TabContext.js +3 -0
  24. package/esm/alert/Alert.js +22 -0
  25. package/esm/alert/index.js +1 -0
  26. package/esm/animate/Collapse.js +65 -0
  27. package/esm/animate/Loader.js +51 -0
  28. package/esm/animate/NumberCounter.js +45 -0
  29. package/esm/animate/PulseRing.js +26 -0
  30. package/esm/animate/Spinner.js +11 -0
  31. package/esm/animate/index.js +5 -0
  32. package/esm/assets/css/autocomplete.css +16 -0
  33. package/esm/assets/css/font.css +4 -0
  34. package/esm/assets/css/global.css +2 -0
  35. package/esm/assets/font/helvetica/Helvetica.ttf +0 -0
  36. package/esm/assets/font/nanumGothic/NanumGothic-Bold.ttf +0 -0
  37. package/esm/assets/font/nanumGothic/NanumGothic-ExtraBold.ttf +0 -0
  38. package/esm/assets/font/nanumGothic/NanumGothic-Regular.ttf +0 -0
  39. package/esm/assets/icons/app-management.png +0 -0
  40. package/esm/assets/icons/burger-black.png +0 -0
  41. package/esm/assets/icons/burger-white.png +0 -0
  42. package/esm/assets/icons/burger.png +0 -0
  43. package/esm/assets/icons/file.svg +1 -0
  44. package/esm/assets/icons/map_icon1.png +0 -0
  45. package/esm/assets/icons/map_icon4.png +0 -0
  46. package/esm/assets/images/bg-aside.png +0 -0
  47. package/esm/assets/images/bg-chart-circle.png +0 -0
  48. package/esm/assets/images/bg-chart-triangle.png +0 -0
  49. package/esm/assets/images/cashub-logo-only.png +0 -0
  50. package/esm/assets/images/default-user.jpg +0 -0
  51. package/esm/assets/images/logo-cashub.png +0 -0
  52. package/esm/assets/images/map.png +0 -0
  53. package/esm/assets/images/qrcode.png +0 -0
  54. package/esm/backdrop/BaseBackdrop.js +11 -0
  55. package/esm/backdrop/LoadingBackdrop.js +10 -0
  56. package/esm/backdrop/ModalBackdrop.js +8 -0
  57. package/esm/backdrop/index.js +3 -0
  58. package/esm/badge/Badge.js +19 -0
  59. package/esm/badge/BadgeDot.js +11 -0
  60. package/esm/badge/BadgeFill.js +42 -0
  61. package/esm/badge/BadgeFillTriangle.js +138 -0
  62. package/esm/badge/BadgeWithText.js +24 -0
  63. package/esm/badge/index.js +5 -0
  64. package/esm/billing/BarChart.js +45 -0
  65. package/esm/billing/Grid.js +38 -0
  66. package/esm/billing/Header2.js +19 -0
  67. package/esm/billing/Header3.js +31 -0
  68. package/esm/billing/Paragraph.js +27 -0
  69. package/esm/billing/ParagraphGroup.js +16 -0
  70. package/esm/billing/ParagraphText.js +20 -0
  71. package/esm/billing/Section.js +44 -0
  72. package/esm/billing/SectionBody.js +11 -0
  73. package/esm/billing/SectionHeader.js +20 -0
  74. package/esm/billing/__stories__/BarChart.stories.js_bak +46 -0
  75. package/esm/billing/__stories__/Grid.stories.js_bak +57 -0
  76. package/esm/billing/__stories__/Header2.stories.js_bak +62 -0
  77. package/esm/billing/__stories__/Header3.stories.js_bak +69 -0
  78. package/esm/billing/__stories__/Paragraph.stories.js_bak +84 -0
  79. package/esm/billing/__stories__/ParagraphGroup.stories.js_bak +68 -0
  80. package/esm/billing/__stories__/ParagraphText.stories.js_bak +64 -0
  81. package/esm/billing/__stories__/Section.stories.js_bak +115 -0
  82. package/esm/billing/__stories__/SectionBody.stories.js_bak +62 -0
  83. package/esm/billing/__stories__/SectionHeader.stories.js-bak +68 -0
  84. package/esm/breadcrumb/Breadcrumb.js +71 -0
  85. package/esm/breadcrumb/index.js +1 -0
  86. package/esm/button/Button.js +145 -0
  87. package/esm/button/ButtonGroup.js +54 -0
  88. package/esm/button/IconButton.js +64 -0
  89. package/esm/button/ScrollToTopButton.js +47 -0
  90. package/esm/button/index.js +4 -0
  91. package/esm/callout/Callout.js +45 -0
  92. package/esm/callout/index.js +1 -0
  93. package/esm/chart/BarChart.js +147 -0
  94. package/esm/chart/DoughnutChart.js +110 -0
  95. package/esm/chart/LineChart.js +140 -0
  96. package/esm/chart/SingleBarChart.js +35 -0
  97. package/esm/chart/index.js +5 -0
  98. package/esm/chart/utils/centerTextPlugin.js +56 -0
  99. package/esm/chart/utils/customTooltip.js +84 -0
  100. package/esm/chart/utils/customTooltipLifecyclePlugin.js +16 -0
  101. package/esm/chart/utils/htmlLegendPlugin.js +83 -0
  102. package/esm/chart/utils/index.js +3 -0
  103. package/esm/chart/utils/padEmptyChartBar.js +47 -0
  104. package/esm/chart/utils/tooltipElement.js +17 -0
  105. package/esm/chart/utils/xAxisLabelTooltipPlugin.js +101 -0
  106. package/esm/chart/utils/yAxisTopTitlePlugin.js +43 -0
  107. package/esm/container/FlexContainer.js +33 -0
  108. package/esm/container/index.js +1 -0
  109. package/esm/cropper/Cropper.js +47 -0
  110. package/esm/cropper/CropperModalHandler.js +34 -0
  111. package/esm/cropper/index.js +2 -0
  112. package/esm/cropper/subComponent/CropImageModal.js +72 -0
  113. package/{datetimePicker/DatetimePicker.js → esm/datetimePicker/DatetimePickerV3.js} +63 -31
  114. package/esm/datetimePicker/TimeInput.js +49 -0
  115. package/esm/datetimePicker/TimePickerStyle.js +58 -0
  116. package/esm/datetimePicker/TimePickerV2.js +199 -0
  117. package/esm/datetimePicker/accordion/Month.js +245 -0
  118. package/esm/datetimePicker/accordion/Year.js +275 -0
  119. package/esm/datetimePicker/index.js +4 -0
  120. package/esm/datetimePicker/provider/constant.js +38 -0
  121. package/esm/datetimePicker/subComponent/DateTimePickerContext.js +3 -0
  122. package/esm/datetimePicker/utils/GMTDate.js +9 -0
  123. package/esm/datetimePicker/utils/pad.js +7 -0
  124. package/esm/datetimePicker/utils/toUTC0.js +7 -0
  125. package/esm/descriptionList/DescriptionDetail.js +21 -0
  126. package/esm/descriptionList/DescriptionList.js +18 -0
  127. package/esm/descriptionList/DescriptionTerm.js +7 -0
  128. package/esm/descriptionList/index.js +3 -0
  129. package/esm/divider/Divider.js +24 -0
  130. package/esm/divider/index.js +1 -0
  131. package/esm/dropdown/Dropdown.js +48 -0
  132. package/esm/dropdown/DropdownButtonOption.js +36 -0
  133. package/esm/dropdown/DropdownContent.js +83 -0
  134. package/esm/dropdown/DropdownDivOption.js +19 -0
  135. package/esm/dropdown/DropdownItem.js +19 -0
  136. package/esm/dropdown/DropdownLinkOption.js +17 -0
  137. package/esm/dropdown/DropdownToggle.js +31 -0
  138. package/esm/dropdown/index.js +11 -0
  139. package/esm/dropdown/subComponent/DropdownContext.js +3 -0
  140. package/esm/dropzone/FileDropzone.js +472 -0
  141. package/esm/dropzone/ImageDropzone.js +327 -0
  142. package/esm/dropzone/index.js +2 -0
  143. package/esm/dropzone/subComponent/Message.js +19 -0
  144. package/esm/figure/IconFigure.js +35 -0
  145. package/esm/figure/ImageFigure.js +31 -0
  146. package/esm/figure/index.js +2 -0
  147. package/esm/file/HiddenFileInput.js +8 -0
  148. package/esm/file/index.js +1 -0
  149. package/esm/form/Checkbox.js +157 -0
  150. package/esm/form/Fieldset.js +11 -0
  151. package/esm/form/FormItem.js +15 -0
  152. package/esm/form/Input.js +59 -0
  153. package/esm/form/Label.js +54 -0
  154. package/esm/form/MutedText.js +14 -0
  155. package/esm/form/PasswordInput.js +40 -0
  156. package/esm/form/RadioButton.js +94 -0
  157. package/esm/form/SearchSelect.js +174 -0
  158. package/esm/form/Searchbox.js +91 -0
  159. package/esm/form/Slider.js +39 -0
  160. package/esm/form/SwitchButton.js +97 -0
  161. package/esm/form/Textarea.js +34 -0
  162. package/esm/form/TreeView.js +66 -0
  163. package/esm/form/index.js +14 -0
  164. package/esm/grid/Column.js +39 -0
  165. package/esm/grid/Grid.js +28 -0
  166. package/esm/grid/index.js +2 -0
  167. package/esm/heading/Heading1.js +14 -0
  168. package/esm/heading/Heading2.js +21 -0
  169. package/esm/heading/Heading3.js +42 -0
  170. package/esm/heading/index.js +3 -0
  171. package/esm/helmet/Helmet.js +17 -0
  172. package/esm/helmet/index.js +2 -0
  173. package/esm/iconbox/ApplicationIconBox.js +74 -0
  174. package/esm/iconbox/IconBox.js +60 -0
  175. package/esm/iconbox/IconBoxV2.js +63 -0
  176. package/esm/iconbox/index.js +3 -0
  177. package/esm/iconbox/subComponent/IconBoxFigure.js +43 -0
  178. package/esm/iconbox/subComponent/IconBoxImage.js +35 -0
  179. package/esm/image/ImageFluid.js +10 -0
  180. package/esm/image/UploadImage.js +243 -0
  181. package/esm/image/index.js +2 -0
  182. package/esm/index.js +47 -0
  183. package/esm/keyframe/Pulse.js +15 -0
  184. package/esm/keyframe/Spin.js +7 -0
  185. package/esm/layout/Aside.js +39 -0
  186. package/esm/layout/AsideHeader.jsx +27 -0
  187. package/esm/layout/Backdrop.js +16 -0
  188. package/esm/layout/Container.js +30 -0
  189. package/esm/layout/Footer.js +36 -0
  190. package/esm/layout/Header.jsx +55 -0
  191. package/esm/layout/Layout.jsx +84 -0
  192. package/esm/layout/Logo.jsx +17 -0
  193. package/esm/layout/MenuIcon.jsx +27 -0
  194. package/esm/layout/Sidebar.jsx +271 -0
  195. package/esm/layout/index.js +1 -0
  196. package/esm/link/LinkSpan.js +62 -0
  197. package/esm/link/index.js +1 -0
  198. package/esm/map/GoogleMap.js +439 -0
  199. package/esm/map/GoogleReverseGeolocation.js +193 -0
  200. package/esm/map/LeafletMap.js +224 -0
  201. package/esm/map/LeafletReverseGeolocation.js +94 -0
  202. package/esm/map/index.js +4 -0
  203. package/esm/map/subComponent/BasicLeafletMap.js +27 -0
  204. package/esm/map/subComponent/GoogleMapContainer.js +22 -0
  205. package/esm/map/subComponent/GoogleMapPopup.js +103 -0
  206. package/esm/map/subComponent/GoogleMapWrapper.js +34 -0
  207. package/esm/map/subComponent/LeafletDrawControl.js +116 -0
  208. package/esm/map/subComponent/LeafletMapContainer.js +166 -0
  209. package/esm/map/subComponent/MapSearchBoxControl.js +47 -0
  210. package/esm/modal/StateModal.js +169 -0
  211. package/esm/modal/TitleModal.js +241 -0
  212. package/esm/modal/index.js +2 -0
  213. package/esm/page/Disclaimer.js +121 -0
  214. package/esm/page/index.js +1 -0
  215. package/esm/paginate/Paginate.js +129 -0
  216. package/esm/paginate/index.js +1 -0
  217. package/esm/popover/Popover.js +82 -0
  218. package/esm/popover/index.js +1 -0
  219. package/esm/qrcode/QRCode.js +51 -0
  220. package/esm/qrcode/QRCodeContainter.js +27 -0
  221. package/esm/qrcode/index.js +2 -0
  222. package/esm/ribbon/Ribbon.js +35 -0
  223. package/esm/ribbon/index.js +1 -0
  224. package/esm/section/Section.js +126 -0
  225. package/esm/section/SectionBody.js +43 -0
  226. package/esm/section/SectionHeader.js +61 -0
  227. package/esm/section/SectionToolbar.js +11 -0
  228. package/esm/section/SectionToolbarItem.js +10 -0
  229. package/esm/section/index.js +5 -0
  230. package/esm/select/InputSelect.js +263 -0
  231. package/esm/select/Select.js +811 -0
  232. package/esm/select/index.js +2 -0
  233. package/esm/select/subComponent/Checkbox.js +40 -0
  234. package/esm/select/subComponent/Footer.js +6 -0
  235. package/esm/select/subComponent/ListBox.js +23 -0
  236. package/esm/select/subComponent/Option.js +37 -0
  237. package/esm/select/subComponent/OptionGroup.js +16 -0
  238. package/esm/select/subComponent/Options.js +25 -0
  239. package/esm/select/subComponent/SearchBox.js +51 -0
  240. package/esm/select/subComponent/SelectedMultipleCount.js +32 -0
  241. package/esm/select/subComponent/SelectedMultipleTags.js +47 -0
  242. package/esm/select/subComponent/SelectedMultipleText.js +63 -0
  243. package/esm/select/subComponent/SelectedSingle.js +10 -0
  244. package/esm/styles/GlobalStyle.js +328 -0
  245. package/esm/styles/config/breakpoint.style.js +7 -0
  246. package/esm/styles/config/header.style.js +4 -0
  247. package/esm/styles/config/sidebar.style.js +11 -0
  248. package/esm/styles/index.js +2 -0
  249. package/esm/styles/mixin/backgroundColor.js +38 -0
  250. package/esm/styles/mixin/borderColor.js +31 -0
  251. package/esm/styles/mixin/color.js +31 -0
  252. package/esm/styles/mixin/colorOnBackground.js +31 -0
  253. package/esm/styles/mixin/inputPlaceholder.js +24 -0
  254. package/esm/styles/mixin/media.js +15 -0
  255. package/esm/styles/mixin/rounded.js +24 -0
  256. package/esm/styles/mixin/scrollbar.js +26 -0
  257. package/esm/styles/theme/dark.theme.js +91 -0
  258. package/esm/styles/theme/light.theme.js +91 -0
  259. package/esm/styles/theme/white.theme.js +91 -0
  260. package/esm/styles/themes.js +9 -0
  261. package/esm/table/GridTable.js +329 -0
  262. package/esm/table/ImageBox.js +38 -0
  263. package/esm/table/InfiniteGridTable.js +396 -0
  264. package/esm/table/PermissionTable.js +57 -0
  265. package/esm/table/SimpleGridTable.js +136 -0
  266. package/esm/table/Table.js +559 -0
  267. package/esm/table/__mock__/columns.js +64 -0
  268. package/esm/table/__mock__/data.js +530 -0
  269. package/esm/table/hooks/index.js +2 -0
  270. package/esm/table/hooks/useCalculateDataRange.js +22 -0
  271. package/esm/table/hooks/useGenerateSort.js +32 -0
  272. package/esm/table/index.js +6 -0
  273. package/esm/table/subComponent/BaseTableHeadCell.js +54 -0
  274. package/esm/table/subComponent/GridTableFooter.js +17 -0
  275. package/esm/table/subComponent/GridTableHeadCell.js +13 -0
  276. package/esm/table/subComponent/Resizer.js +70 -0
  277. package/esm/table/subComponent/TableFooter.js +24 -0
  278. package/esm/table/subComponent/TableFooterInfo.js +6 -0
  279. package/esm/table/subComponent/TableFooterPager.js +26 -0
  280. package/esm/table/subComponent/TableHeadCell.js +12 -0
  281. package/esm/table/subComponent/TableSort.js +31 -0
  282. package/esm/tagify/TagifyStyle.js +54 -0
  283. package/esm/tagify/Tags.js +49 -0
  284. package/esm/tagify/index.js +3 -0
  285. package/esm/tagify/templates/getCreateButtonTemplate.js +12 -0
  286. package/esm/text/Paragraph.js +79 -0
  287. package/esm/text/index.js +1 -0
  288. package/esm/timeline/Timeline.js +132 -0
  289. package/esm/timeline/index.js +1 -0
  290. package/esm/toast/CustomToastContainer.js +38 -0
  291. package/esm/toast/MessageContainer.js +44 -0
  292. package/esm/toast/index.js +3 -0
  293. package/esm/toast/show.js +29 -0
  294. package/esm/toast/style.css +1 -0
  295. package/esm/tooltip/Tooltip.js +133 -0
  296. package/esm/tooltip/index.js +1 -0
  297. package/esm/treeView/TreeViewV2.js +32 -0
  298. package/esm/treeView/TreeflexStyle.js +43 -0
  299. package/esm/treeView/index.js +2 -0
  300. package/esm/wizard/Wizard.js +244 -0
  301. package/esm/wizard/index.js +1 -0
  302. package/index.js +0 -12
  303. package/layout/Sidebar.jsx +1 -1
  304. package/package.json +5 -4
  305. package/datetimePicker/DatePicker.js +0 -363
  306. package/datetimePicker/DatePickerV2.js +0 -407
  307. package/datetimePicker/DatetimePickerV2.js +0 -395
  308. package/datetimePicker/TimePicker.js +0 -317
  309. package/datetimePicker/hooks/index.js +0 -27
  310. package/datetimePicker/hooks/useChangeNumber.js +0 -42
  311. package/datetimePicker/hooks/useDecrease.js +0 -38
  312. package/datetimePicker/hooks/useIncrease.js +0 -38
  313. package/datetimePicker/subComponent/Accordion.js +0 -373
  314. package/datetimePicker/subComponent/CustomTimeInput.js +0 -47
  315. package/jsoneditor/JsonEditor.js +0 -142
  316. package/jsoneditor/index.js +0 -13
@@ -1,407 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = require("react");
8
- var _reactI18next = require("react-i18next");
9
- var _reactOutsideClickHandler = _interopRequireDefault(require("react-outside-click-handler"));
10
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
11
- var _md = require("react-icons/md");
12
- var _hooks = require("@cashub/hooks");
13
- var _utils = require("@cashub/utils");
14
- var _Button = _interopRequireDefault(require("../button/Button"));
15
- var _Input = _interopRequireDefault(require("../form/Input"));
16
- var _Month = _interopRequireDefault(require("./accordion/Month"));
17
- var _Year = _interopRequireDefault(require("./accordion/Year"));
18
- var _DateTimePickerContext = _interopRequireDefault(require("./subComponent/DateTimePickerContext"));
19
- var _toUTC = _interopRequireDefault(require("./utils/toUTC0"));
20
- var _jsxRuntime = require("react/jsx-runtime");
21
- 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); }
22
- 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 && {}.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; }
23
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
24
- const DEFAULT_TIME = '00:00:00';
25
- const DatePickerV2 = _ref => {
26
- let {
27
- selected,
28
- fixedYear,
29
- allowClear,
30
- minDate,
31
- maxDate,
32
- onConfirm,
33
- disabled
34
- } = _ref;
35
- const {
36
- t
37
- } = (0, _reactI18next.useTranslation)();
38
- const [toggleElement, setToggleElement] = (0, _react.useState)(null);
39
- const [contentElement, setContentElement] = (0, _react.useState)(null);
40
- const [selectedDate, setSelectedDate] = (0, _react.useState)(() => {
41
- const defaultDate = selected ? new Date(selected) : new Date();
42
- return `${(0, _utils.formatDate)((0, _toUTC.default)(defaultDate), 'date')} ${DEFAULT_TIME}`;
43
- });
44
- const [confirmDate, setConfirmDate] = (0, _react.useState)(selected ? (0, _utils.formatDate)((0, _toUTC.default)(selected), 'date') : '');
45
- const [displayPicker, setDisplayPicker] = (0, _react.useState)(false);
46
- const [accordionCurrentDisplayType, setAccordionCurrentDisplayType] = (0, _react.useState)(null);
47
- const weeks = (0, _react.useMemo)(() => {
48
- return ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'].map(week => /*#__PURE__*/(0, _jsxRuntime.jsx)(Week, {
49
- children: week
50
- }, week));
51
- }, []);
52
- const minDateWithTime = (0, _react.useMemo)(() => {
53
- if (!minDate) return;
54
- return `${minDate} 00:00:00`;
55
- }, [minDate]);
56
- const maxDateWithTime = (0, _react.useMemo)(() => {
57
- if (!maxDate) return;
58
- return `${maxDate} 00:00:00`;
59
- }, [maxDate]);
60
- const {
61
- styles,
62
- attributes,
63
- state,
64
- update
65
- } = (0, _hooks.useCustomPopper)(toggleElement, contentElement, {
66
- strategy: 'absolute',
67
- placement: 'bottom-start'
68
- });
69
- const context = {
70
- fixedYear,
71
- minDate: minDateWithTime,
72
- maxDate: maxDateWithTime,
73
- selectedDate,
74
- setSelectedDate,
75
- setAccordionCurrentDisplayType
76
- };
77
- const handleToggle = () => {
78
- setDisplayPicker(!displayPicker);
79
- update();
80
- };
81
- const changeDisplayAccordion = (0, _react.useCallback)(type => {
82
- if (accordionCurrentDisplayType === type) {
83
- setAccordionCurrentDisplayType(null);
84
- } else {
85
- setAccordionCurrentDisplayType(type);
86
- }
87
- }, [accordionCurrentDisplayType]);
88
- const handleConfirm = (0, _react.useCallback)(() => {
89
- if (confirmDate) {
90
- onConfirm(confirmDate);
91
- }
92
- setDisplayPicker(false);
93
- setAccordionCurrentDisplayType(null);
94
- }, [confirmDate, onConfirm]);
95
- const handleChangeDate = (0, _react.useCallback)((daysOfMonthForSelectedDate, firstWeekOfMonth, dayIndex, day) => {
96
- const date = new Date(selectedDate);
97
- // 先把日期設定成所有月分都有的日期,設定月份時才不會設定到非預期的date
98
- date.setDate(1);
99
- const selectedYear = date.getFullYear();
100
- const selectedMonth = date.getMonth();
101
- if (!fixedYear) {
102
- if (dayIndex < firstWeekOfMonth && selectedYear >= 1) {
103
- if (selectedMonth === 0) {
104
- date.setFullYear(selectedYear - 1);
105
- date.setMonth(11);
106
- } else {
107
- date.setMonth(selectedMonth - 1);
108
- }
109
- } else if (dayIndex >= daysOfMonthForSelectedDate + firstWeekOfMonth) {
110
- if (selectedMonth === 11) {
111
- date.setFullYear(selectedYear + 1);
112
- date.setMonth(0);
113
- } else {
114
- date.setMonth(selectedMonth + 1);
115
- }
116
- }
117
- date.setDate(day);
118
- } else if (fixedYear) {
119
- if (dayIndex < firstWeekOfMonth) {
120
- if (selectedMonth === 0) {
121
- return;
122
- }
123
- date.setMonth(selectedMonth - 1);
124
- } else if (dayIndex >= daysOfMonthForSelectedDate + firstWeekOfMonth) {
125
- if (selectedMonth === 11) {
126
- return;
127
- }
128
- date.setMonth(selectedMonth + 1);
129
- }
130
- date.setDate(day);
131
- }
132
- const formattedDate = (0, _utils.formatDate)(date, 'date');
133
- setSelectedDate(`${formattedDate} ${DEFAULT_TIME}`);
134
- setConfirmDate(formattedDate);
135
- }, [fixedYear, selectedDate]);
136
- const handleDisabled = (0, _react.useCallback)((firstDayOfMonth, lastDayOfMonth, daysOfMonthForSelectedDate, dayIndex, day) => {
137
- let [year, month] = selectedDate.split('-');
138
-
139
- // disabled date before first month of first year
140
- if (year === '0001' && month === '01' && dayIndex < firstDayOfMonth) {
141
- return true;
142
- }
143
- let myDay = day.toString();
144
- if (myDay.length === 1) myDay = `0${myDay}`;
145
- if (fixedYear) {
146
- if (month === '01') {
147
- // disabled date before first month
148
- return dayIndex < firstDayOfMonth;
149
- } else if (month === '12') {
150
- // disabled date in december
151
- return dayIndex >= daysOfMonthForSelectedDate + firstDayOfMonth;
152
- }
153
- }
154
-
155
- // previous year's date
156
- if (month === '01' && firstDayOfMonth !== 0 && dayIndex + 1 <= firstDayOfMonth) {
157
- year = +year - 1;
158
- }
159
-
160
- // next year's date
161
- if (month === '12' && lastDayOfMonth !== 6 && day + firstDayOfMonth < dayIndex + 1) {
162
- year = +year + 1;
163
- }
164
- month = firstDayOfMonth >= dayIndex + 1 ? +month - 1 : daysOfMonthForSelectedDate + firstDayOfMonth < dayIndex + 1 ? +month + 1 : +month;
165
- if (month < 1) {
166
- month = 12;
167
- } else if (month > 12) {
168
- month = 1;
169
- }
170
- month = month.toString();
171
- if (month.length === 1) {
172
- month = `0${month}`;
173
- }
174
- year = year.toString();
175
- if (year.length === 1) year = `000${year}`;
176
- if (year.length === 2) year = `00${year}`;
177
- if (year.length === 3) year = `0${year}`;
178
- const currentDate = `${year}-${month}-${myDay} ${DEFAULT_TIME}`;
179
- if (minDateWithTime && currentDate < minDateWithTime) {
180
- return true;
181
- }
182
- if (maxDateWithTime && currentDate > maxDateWithTime) {
183
- return true;
184
- }
185
- return false;
186
- }, [fixedYear, minDateWithTime, maxDateWithTime, selectedDate]);
187
- const isSelectedDay = (0, _react.useCallback)((day, index, firstDayOfMonth, daysOfMonthForSelectedDate) => {
188
- const selectedDateObj = new Date(selectedDate);
189
- const confirmDateObj = (0, _toUTC.default)(new Date(confirmDate));
190
- if (confirmDateObj.getFullYear() === selectedDateObj.getFullYear() && confirmDateObj.getMonth() === selectedDateObj.getMonth() && confirmDateObj.getDate() === day) {
191
- if (index + 1 > firstDayOfMonth && index < daysOfMonthForSelectedDate + firstDayOfMonth) {
192
- return true;
193
- }
194
- return false;
195
- }
196
- return false;
197
- }, [selectedDate, confirmDate]);
198
- const getLastDateOfMonth = selectedDate => {
199
- const date = new Date(selectedDate);
200
-
201
- // 先把日期設定成所有月分都有的日期,設定月份時才不會設定到非預期的date
202
- date.setDate(1);
203
- date.setMonth(date.getMonth() + 1);
204
- date.setDate(0);
205
- return date;
206
- };
207
- const days = (0, _react.useMemo)(() => {
208
- const lastDateOfSelectedDate = getLastDateOfMonth(selectedDate);
209
- const daysOfMonthForSelectedDate = lastDateOfSelectedDate.getDate();
210
- const lastDayOfMonth = lastDateOfSelectedDate.getDay();
211
- let date = new Date(selectedDate);
212
- date.setMonth(date.getMonth() + 1 - 1);
213
- date.setDate(0);
214
- const daysOfPrevioueMonthForSelectedDate = date.getDate();
215
- date = new Date(selectedDate);
216
- // 先把日期設定成所有月分都有的日期,設定月份時才不會設定到非預期的date
217
- date.setDate(1);
218
- const firstDayOfMonth = date.getDay();
219
- const days = [...Array(daysOfMonthForSelectedDate)].map((value, index) => {
220
- return index + 1;
221
- });
222
- if (firstDayOfMonth !== 0) {
223
- for (let index = daysOfPrevioueMonthForSelectedDate; index > daysOfPrevioueMonthForSelectedDate - firstDayOfMonth; index -= 1) {
224
- if (date.getFullYear() === 1 && date.getMonth() === 0) {
225
- days.unshift(null);
226
- } else {
227
- days.unshift(index);
228
- }
229
- }
230
- }
231
- if (lastDayOfMonth !== 6) {
232
- for (let index = 1; index <= 6 - lastDayOfMonth; index += 1) {
233
- days.push(index);
234
- }
235
- }
236
- return days.map((day, index) => {
237
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Day, {
238
- disabled: handleDisabled(firstDayOfMonth, lastDayOfMonth, daysOfMonthForSelectedDate, index, day),
239
- onClick: () => {
240
- handleChangeDate(daysOfMonthForSelectedDate, firstDayOfMonth, index, day);
241
- },
242
- selected: isSelectedDay(day, index, firstDayOfMonth, daysOfMonthForSelectedDate),
243
- children: day
244
- }, index);
245
- });
246
- }, [selectedDate, handleChangeDate, isSelectedDay, handleDisabled]);
247
- (0, _react.useEffect)(() => {
248
- if (selected) {
249
- const formattedDate = (0, _utils.formatDate)((0, _toUTC.default)(selected), 'date');
250
- setSelectedDate(`${formattedDate} ${DEFAULT_TIME}`);
251
- setConfirmDate(formattedDate);
252
- } else {
253
- setConfirmDate('');
254
- }
255
- }, [selected]);
256
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePickerContext.default.Provider, {
257
- value: context,
258
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactOutsideClickHandler.default, {
259
- onOutsideClick: handleConfirm,
260
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(Wrapper, {
261
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Input.default, {
262
- disabled: disabled,
263
- ref: setToggleElement,
264
- value: confirmDate,
265
- onClick: handleToggle,
266
- readOnly: true
267
- }), confirmDate && !disabled && allowClear && /*#__PURE__*/(0, _jsxRuntime.jsx)(CloseButton, {
268
- onClick: () => {
269
- setConfirmDate('');
270
- onConfirm('');
271
- }
272
- })]
273
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Picker, {
274
- ...attributes.popper,
275
- style: styles.popper,
276
- placement: state && state.placement,
277
- ref: setContentElement,
278
- displayPicker: displayPicker,
279
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(Body, {
280
- accordionCurrentDisplayType: accordionCurrentDisplayType,
281
- children: [!fixedYear && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Year.default, {
282
- expand: accordionCurrentDisplayType === 'year',
283
- handleDisplayAccordionContent: () => {
284
- changeDisplayAccordion('year');
285
- }
286
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Month.default, {
287
- expand: accordionCurrentDisplayType === 'month',
288
- handleDisplayAccordionContent: () => {
289
- changeDisplayAccordion('month');
290
- },
291
- confirmDate: confirmDate
292
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(DateContent, {
293
- children: [weeks, days]
294
- })]
295
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Footer, {
296
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ConfirmButton, {
297
- fullWidth: true,
298
- alignCenter: true,
299
- onClick: handleConfirm,
300
- children: t('Confirm')
301
- })
302
- })]
303
- })]
304
- })
305
- });
306
- };
307
- const Wrapper = _styledComponents.default.div`
308
- position: relative;
309
- `;
310
- const CloseButton = (0, _styledComponents.default)(_md.MdClose)`
311
- position: absolute;
312
- top: 50%;
313
- transform: translateY(-50%);
314
- color: var(--font-on-background);
315
- font-size: var(--font-body1);
316
- right: var(--spacing-s);
317
- cursor: pointer;
318
- `;
319
- CloseButton.displayName = 'CloseButton';
320
- const Picker = _styledComponents.default.div`
321
- padding-bottom: var(--spacing-s);
322
- background: var(--color-background1);
323
- border-radius: var(--border-radius);
324
- border: var(--border-width) solid var(--border-color);
325
- box-shadow: var(--box-shadow);
326
- overflow: hidden;
327
- width: 286px;
328
- z-index: 1;
329
- color: var(--font-on-background);
330
-
331
- display: ${_ref2 => {
332
- let {
333
- displayPicker
334
- } = _ref2;
335
- return displayPicker ? 'block' : 'none';
336
- }};
337
- `;
338
- const Week = _styledComponents.default.div`
339
- width: calc(100% / 7);
340
- height: 36px;
341
- border-radius: var(--border-radius-s);
342
- line-height: 36px;
343
- text-align: center;
344
- `;
345
- const Body = _styledComponents.default.div`
346
- ${_ref3 => {
347
- let {
348
- accordionCurrentDisplayType
349
- } = _ref3;
350
- return accordionCurrentDisplayType && (0, _styledComponents.css)`
351
- height: 216px;
352
- `;
353
- }}
354
-
355
- overflow: hidden;
356
- padding: ${_ref4 => {
357
- let {
358
- accordionCurrentDisplayType
359
- } = _ref4;
360
- return accordionCurrentDisplayType === 'year' ? ' 0 4px var(--spacing-s) var(--spacing-s)' : '0 var(--spacing-s) 0 var(--spacing-s)';
361
- }};
362
- `;
363
- const Footer = _styledComponents.default.div`
364
- padding: 0 var(--spacing-s);
365
- `;
366
- const Day = _styledComponents.default.button`
367
- width: calc(100% / 7);
368
- height: 36px;
369
- border-radius: var(--border-radius-s);
370
- line-height: 36px;
371
- text-align: center;
372
- padding: 0;
373
- border: 0;
374
- background: var(--color-background1);
375
- color: var(--font-on-background);
376
- &:hover {
377
- background: var(--color-primary);
378
- }
379
-
380
- ${_ref5 => {
381
- let {
382
- selected
383
- } = _ref5;
384
- return selected && 'background: var(--color-hover);';
385
- }}
386
-
387
- ${_ref6 => {
388
- let {
389
- disabled
390
- } = _ref6;
391
- return disabled && (0, _styledComponents.css)`
392
- color: var(--font-on-mute);
393
- background: none;
394
- &:hover {
395
- background: none;
396
- }
397
- `;
398
- }}
399
- `;
400
- const ConfirmButton = (0, _styledComponents.default)(_Button.default)`
401
- margin: 16px auto 0;
402
- `;
403
- const DateContent = _styledComponents.default.div`
404
- display: flex;
405
- flex-wrap: wrap;
406
- `;
407
- var _default = exports.default = DatePickerV2;