@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
@@ -0,0 +1,47 @@
1
+ import { useRef, useEffect } from 'react';
2
+ import 'cropperjs/dist/cropper.css';
3
+ import Cropper from 'cropperjs';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ const CropperWrapper = _ref => {
6
+ let {
7
+ src,
8
+ alt = 'picture',
9
+ width,
10
+ height,
11
+ cropBoxResizable = false,
12
+ onInitialized,
13
+ dragMode = 'move'
14
+ } = _ref;
15
+ const imageRef = useRef(null);
16
+ useEffect(() => {
17
+ const node = imageRef.current;
18
+ if (node !== null) {
19
+ const cropper = new Cropper(node, {
20
+ dragMode,
21
+ viewMode: 1,
22
+ initialAspectRatio: 9 / 16,
23
+ background: true,
24
+ cropBoxResizable,
25
+ data: {
26
+ width,
27
+ height
28
+ }
29
+ });
30
+ if (onInitialized) {
31
+ onInitialized(cropper);
32
+ }
33
+ }
34
+ return () => {
35
+ node?.cropper?.destroy();
36
+ };
37
+ }, [onInitialized, dragMode, width, height, cropBoxResizable]);
38
+ return /*#__PURE__*/_jsx("div", {
39
+ children: /*#__PURE__*/_jsx("img", {
40
+ src: src,
41
+ alt: alt,
42
+ ref: imageRef,
43
+ crossOrigin: "anonymous"
44
+ })
45
+ });
46
+ };
47
+ export default CropperWrapper;
@@ -0,0 +1,34 @@
1
+ import TitleModal from '../modal/TitleModal';
2
+ import CropImageModal from './subComponent/CropImageModal';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ const CropperModalHandler = _ref => {
5
+ let {
6
+ src,
7
+ file,
8
+ width,
9
+ height,
10
+ cropBoxResizable = false,
11
+ onCrop,
12
+ onClose
13
+ } = _ref;
14
+ TitleModal({
15
+ size: 'normal',
16
+ children: /*#__PURE__*/_jsx(CropImageModal, {
17
+ src: src,
18
+ mime: file.type,
19
+ alt: file.name,
20
+ file: file,
21
+ width: width,
22
+ height: height,
23
+ cropBoxResizable: cropBoxResizable,
24
+ onCrop: onCrop,
25
+ onClose: onClose
26
+ }),
27
+ onClose: dismiss => {
28
+ if (dismiss === true && onClose) {
29
+ onClose();
30
+ }
31
+ }
32
+ });
33
+ };
34
+ export default CropperModalHandler;
@@ -0,0 +1,2 @@
1
+ export { default as Cropper } from './Cropper';
2
+ export { default as CropperModalHandler } from './CropperModalHandler';
@@ -0,0 +1,72 @@
1
+ import { useCallback, useState, useEffect } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { resizeImage } from '@cashub/utils';
4
+ import Cropper from '../Cropper';
5
+ import Button from '../../button/Button';
6
+ import ButtonGroup from '../../button/ButtonGroup';
7
+ import TitleModal from '../../modal/TitleModal';
8
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
9
+ const CropImageModal = _ref => {
10
+ let {
11
+ src,
12
+ mime,
13
+ alt,
14
+ width,
15
+ height,
16
+ cropBoxResizable = false,
17
+ onCrop,
18
+ onClose,
19
+ close
20
+ } = _ref;
21
+ const {
22
+ t
23
+ } = useTranslation();
24
+ const [instance, setIntance] = useState(null);
25
+ const [resizedImage, setResizedImage] = useState(null);
26
+ const handleCrop = useCallback(() => {
27
+ onCrop(instance.getCroppedCanvas().toDataURL());
28
+ close();
29
+ }, [onCrop, instance, close]);
30
+ const handleInitialized = useCallback(instance => {
31
+ setIntance(instance);
32
+ }, []);
33
+ const handleClose = () => {
34
+ if (onClose) {
35
+ onClose();
36
+ }
37
+ close();
38
+ };
39
+ useEffect(() => {
40
+ resizeImage(src, mime, width > height ? width : height, 'cover', resizedImageUrl => {
41
+ setResizedImage(resizedImageUrl);
42
+ });
43
+ }, [src, mime, height, width]);
44
+ return /*#__PURE__*/_jsxs(_Fragment, {
45
+ children: [/*#__PURE__*/_jsx(TitleModal.Header, {
46
+ handleClose: handleClose,
47
+ children: t('CropImage')
48
+ }), /*#__PURE__*/_jsx(TitleModal.Body, {
49
+ children: resizedImage && /*#__PURE__*/_jsx(Cropper, {
50
+ src: resizedImage,
51
+ alt: alt,
52
+ width: width,
53
+ height: height,
54
+ cropBoxResizable: cropBoxResizable,
55
+ onInitialized: handleInitialized
56
+ })
57
+ }), /*#__PURE__*/_jsx(TitleModal.Footer, {
58
+ children: /*#__PURE__*/_jsxs(ButtonGroup, {
59
+ children: [/*#__PURE__*/_jsx(Button, {
60
+ danger: true,
61
+ onClick: handleClose,
62
+ children: t('button:Cancel')
63
+ }), /*#__PURE__*/_jsx(Button, {
64
+ success: true,
65
+ onClick: handleCrop,
66
+ children: t('button:Confirm')
67
+ })]
68
+ })
69
+ })]
70
+ });
71
+ };
72
+ export default CropImageModal;
@@ -1,17 +1,14 @@
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 _styledComponents = _interopRequireDefault(require("styled-components"));
9
- var _reactDatepicker = _interopRequireDefault(require("react-datepicker"));
10
- require("react-datepicker/dist/react-datepicker.css");
11
- var _CustomTimeInput = _interopRequireDefault(require("./subComponent/CustomTimeInput"));
12
- var _jsxRuntime = require("react/jsx-runtime");
13
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
- const DatetimePicker = _ref => {
1
+ import { useCallback, useEffect, useRef, useMemo } from 'react';
2
+ import styled from 'styled-components';
3
+ import DatePicker from 'react-datepicker';
4
+ import 'react-datepicker/dist/react-datepicker.css';
5
+ import TimePickerV2 from './TimePickerV2';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const setDateTime = (date, value) => {
8
+ const [hh, mm, ss] = value.split(':');
9
+ date.setHours(Number(hh) || 0, Number(mm) || 0, Number(ss) || 0, 0);
10
+ };
11
+ const DatetimePickerV3 = _ref => {
15
12
  let {
16
13
  selected = '',
17
14
  onChange,
@@ -23,46 +20,81 @@ const DatetimePicker = _ref => {
23
20
  disabled,
24
21
  onBlur,
25
22
  allowClear = false,
26
- shouldCloseOnSelect = true
23
+ shouldCloseOnSelect = true,
24
+ placeholderText,
25
+ allowTimeInputEmpty = false
27
26
  } = _ref;
28
- const datepickerRef = (0, _react.useRef)(null);
27
+ const datepickerRef = useRef(null);
28
+ const pendingTimeRef = useRef(null);
29
29
  const handleOnBlur = () => {
30
- onBlur();
30
+ pendingTimeRef.current = null;
31
+ if (typeof onBlur === 'function') {
32
+ onBlur();
33
+ }
31
34
  };
35
+ const selectedDate = useMemo(() => {
36
+ return selected ? new Date(Date.parse(selected)) : '';
37
+ }, [selected]);
38
+ const handleChange = useCallback(date => {
39
+ // when showTimeInput and DatetimePicker no value yet
40
+ if (showTimeInput && !selected && date) {
41
+ // if time selected before date, use selected time
42
+ if (pendingTimeRef.current) {
43
+ setDateTime(date, pendingTimeRef.current);
44
+ pendingTimeRef.current = null;
45
+ } else {
46
+ // if date selected before time, use current time
47
+ const now = new Date();
48
+ date.setHours(now.getHours(), now.getMinutes(), now.getSeconds(), 0);
49
+ }
50
+ }
51
+ onChange(date);
52
+ }, [onChange, selected, showTimeInput]);
32
53
  const datePickerProps = {
33
54
  dateFormat,
34
55
  disabled,
35
- onChange,
36
- selected: selected ? new Date(Date.parse(selected)) : '',
56
+ onChange: handleChange,
57
+ selected: selectedDate,
37
58
  minDate: minDate ? new Date(Date.parse(minDate)) : '',
38
59
  maxDate: maxDate ? new Date(Date.parse(maxDate)) : '',
39
- isClearable: allowClear && selected && !disabled,
40
- shouldCloseOnSelect
60
+ isClearable: allowClear && selected,
61
+ shouldCloseOnSelect,
62
+ placeholderText
41
63
  };
64
+ const handleSelectTime = useCallback(value => {
65
+ if (selectedDate) {
66
+ setDateTime(selectedDate, value);
67
+ onChange(selectedDate);
68
+ } else {
69
+ pendingTimeRef.current = value;
70
+ }
71
+ },
72
+ // NOTE: Adding onChange to the dependency list will cause a rerender loop
73
+ [selectedDate]);
42
74
  if (showTimeInput) {
43
75
  datePickerProps.showTimeInput = true;
44
- datePickerProps.customTimeInput = /*#__PURE__*/(0, _jsxRuntime.jsx)(_CustomTimeInput.default, {
45
- onCustomChange: onChange
76
+ datePickerProps.customTimeInput = /*#__PURE__*/_jsx(TimePickerV2, {
77
+ selected: selected,
78
+ onSelect: handleSelectTime,
79
+ allowEmpty: allowTimeInputEmpty && !selected
46
80
  });
47
81
  }
48
- if (onBlur) {
49
- datePickerProps.onCalendarClose = handleOnBlur;
50
- }
51
- (0, _react.useEffect)(() => {
82
+ datePickerProps.onCalendarClose = handleOnBlur;
83
+ useEffect(() => {
52
84
  // set input to readonly
53
85
  if (datepickerRef && datepickerRef.current && readOnly) {
54
86
  datepickerRef.current.input.readOnly = readOnly;
55
87
  }
56
88
  }, [readOnly]);
57
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapper, {
89
+ return /*#__PURE__*/_jsx(Wrapper, {
58
90
  disabled: disabled,
59
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactDatepicker.default, {
91
+ children: /*#__PURE__*/_jsx(DatePicker, {
60
92
  ...datePickerProps,
61
93
  ref: datepickerRef
62
94
  })
63
95
  });
64
96
  };
65
- const Wrapper = _styledComponents.default.div`
97
+ const Wrapper = styled.div`
66
98
  .react-datepicker-wrapper,
67
99
  .react-datepicker__input-container {
68
100
  width: 100%;
@@ -237,4 +269,4 @@ const Wrapper = _styledComponents.default.div`
237
269
  }
238
270
  }
239
271
  `;
240
- var _default = exports.default = DatetimePicker;
272
+ export default DatetimePickerV3;
@@ -0,0 +1,49 @@
1
+ import styled from 'styled-components';
2
+ import RCTimePicker from 'rc-time-picker';
3
+ import 'rc-time-picker/assets/index.css';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ const TimeInput = props => {
6
+ return /*#__PURE__*/_jsx(Wrapper, {
7
+ disabled: props.disabled,
8
+ children: /*#__PURE__*/_jsx(RCTimePicker, {
9
+ ...props
10
+ })
11
+ });
12
+ };
13
+ const Wrapper = styled.div`
14
+ .rc-time-picker {
15
+ width: 100%;
16
+
17
+ .rc-time-picker-input {
18
+ height: 36px;
19
+ border-radius: var(--border-radius);
20
+ border: var(--border-width) solid var(--border-color);
21
+ padding: 10px var(--spacing-s);
22
+ color: var(--font-on-background);
23
+ background: transparent;
24
+ font-size: var(--font-body1);
25
+
26
+ ${_ref => {
27
+ let {
28
+ disabled
29
+ } = _ref;
30
+ return disabled && 'opacity: 0.5;';
31
+ }}
32
+
33
+ &:focus {
34
+ border: var(--border-width) solid var(--color-primary);
35
+ outline: none;
36
+ }
37
+ }
38
+
39
+ .rc-time-picker-clear {
40
+ top: 6px;
41
+ right: 8px;
42
+
43
+ i:after {
44
+ font-size: var(--font-body1);
45
+ }
46
+ }
47
+ }
48
+ `;
49
+ export default TimeInput;
@@ -0,0 +1,58 @@
1
+ import { createGlobalStyle } from 'styled-components';
2
+ import scrollbar from '../styles/mixin/scrollbar';
3
+
4
+ // integrate rc-time-picker component
5
+ const TimePickerStyle = createGlobalStyle`
6
+ .rc-time-picker-panel-narrow {
7
+ max-width: none;
8
+ }
9
+
10
+ .rc-time-picker-panel {
11
+ .rc-time-picker-panel-inner {
12
+ background: transparent;
13
+ border: none;
14
+ box-shadow: none;
15
+
16
+ .rc-time-picker-panel-input-wrap {
17
+ display: none;
18
+ }
19
+
20
+ .rc-time-picker-panel-combobox {
21
+ height: 144px;
22
+ border: var(--border-width) solid var(--border-color);
23
+ color: var(--font-on-background);
24
+ box-shadow: var(--box-shadow);
25
+ border-radius: var(--border-radius);
26
+ background: var(--color-background2);
27
+
28
+ .rc-time-picker-panel-select {
29
+ font-size: var(--font-body1);
30
+
31
+ ${scrollbar}
32
+
33
+ li {
34
+ &:hover {
35
+ background: var(--color-hover);
36
+ }
37
+
38
+ &.rc-time-picker-panel-select-option-selected {
39
+ background: var(--color-hover);
40
+ }
41
+ }
42
+
43
+ &:first-child {
44
+ border-top-left-radius: var(--border-radius);
45
+ border-bottom-left-radius: var(--border-radius);
46
+ }
47
+ }
48
+ }
49
+ }
50
+
51
+ &.rc-time-picker-panel-placement-bottomLeft {
52
+ .rc-time-picker-panel-inner {
53
+ padding-top: calc(36px + var(--spacing-xs));
54
+ }
55
+ }
56
+ }
57
+ `;
58
+ export default TimePickerStyle;
@@ -0,0 +1,199 @@
1
+ import { useState, useEffect } from 'react';
2
+ import styled, { css } from 'styled-components';
3
+ import OutsideClickHandler from 'react-outside-click-handler';
4
+ import { useCustomPopper } from '@cashub/hooks';
5
+ import { generateRange } from '@cashub/utils';
6
+ import pad from './utils/pad';
7
+ import { Input } from '../form';
8
+ import scrollbar from '../styles/mixin/scrollbar';
9
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
10
+ const LENGTH = 2;
11
+ const PAD_STRING = '0';
12
+ const HOUR_OPTIONS = generateRange(0, 23).map(value => {
13
+ return pad(value, LENGTH, PAD_STRING);
14
+ });
15
+ const MINUTE_SECOND_OPTIONS = generateRange(0, 59).map(value => {
16
+ return pad(value, LENGTH, PAD_STRING);
17
+ });
18
+ const EMPTY_TIME = {
19
+ hour: '',
20
+ minute: '',
21
+ second: ''
22
+ };
23
+ const getTimeFromSelected = (selected, allowEmpty) => {
24
+ let time = new Date(Date.parse(selected));
25
+ if (isNaN(time)) {
26
+ if (allowEmpty) {
27
+ return EMPTY_TIME;
28
+ }
29
+ time = new Date();
30
+ }
31
+ return {
32
+ hour: pad(time.getHours(), LENGTH, PAD_STRING),
33
+ minute: pad(time.getMinutes(), LENGTH, PAD_STRING),
34
+ second: pad(time.getSeconds(), LENGTH, PAD_STRING)
35
+ };
36
+ };
37
+ const TimePickerV2 = _ref => {
38
+ let {
39
+ selected,
40
+ onSelect,
41
+ allowEmpty = false
42
+ } = _ref;
43
+ const [display, setDisplay] = useState(false);
44
+ const [targetElement, setTargetElement] = useState(null);
45
+ const [popperElement, setPopperElement] = useState(null);
46
+ const [time, setTime] = useState(() => {
47
+ return getTimeFromSelected(selected, allowEmpty);
48
+ });
49
+ const {
50
+ styles,
51
+ attributes,
52
+ state,
53
+ update
54
+ } = useCustomPopper(targetElement, popperElement, {
55
+ placement: 'bottom-start'
56
+ });
57
+ const handleToggle = () => {
58
+ setDisplay(!display);
59
+ update();
60
+ };
61
+ const handleChange = (type, value) => {
62
+ const next = {
63
+ ...time,
64
+ [type]: value
65
+ };
66
+ setTime(next);
67
+ if (typeof onSelect === 'function' && next.hour && next.minute && next.second) {
68
+ onSelect(`${next.hour}:${next.minute}:${next.second}`);
69
+ }
70
+ };
71
+
72
+ // sync time picker state when selected value changes
73
+ useEffect(() => {
74
+ setTime(getTimeFromSelected(selected, allowEmpty));
75
+ }, [allowEmpty, selected]);
76
+ useEffect(() => {
77
+ if (display) {
78
+ const {
79
+ childNodes
80
+ } = popperElement;
81
+ childNodes.forEach(panel => {
82
+ const selectedItem = panel.querySelector('[aria-selected="true"]');
83
+ if (panel.scrollHeight > panel.clientHeight) {
84
+ panel.scrollTop = selectedItem ? selectedItem.offsetTop : 0;
85
+ }
86
+ });
87
+ }
88
+ }, [display, popperElement]);
89
+ return /*#__PURE__*/_jsx(OutsideClickHandler, {
90
+ onOutsideClick: () => {
91
+ setDisplay(false);
92
+ },
93
+ children: /*#__PURE__*/_jsxs(_Fragment, {
94
+ children: [/*#__PURE__*/_jsx(Input, {
95
+ ref: setTargetElement,
96
+ type: "text",
97
+ readOnly: true,
98
+ onClick: handleToggle,
99
+ value: time.hour && time.minute && time.second ? `${time.hour}:${time.minute}:${time.second}` : ''
100
+ }), /*#__PURE__*/_jsxs(Panel, {
101
+ ref: setPopperElement,
102
+ $display: display,
103
+ style: styles.popper,
104
+ ...attributes.popper,
105
+ placement: state && state.placement,
106
+ children: [/*#__PURE__*/_jsx(Picker, {
107
+ children: HOUR_OPTIONS.map(option => {
108
+ return /*#__PURE__*/_jsx(Option, {
109
+ role: "option",
110
+ onClick: () => {
111
+ handleChange('hour', option);
112
+ },
113
+ selected: option === time.hour,
114
+ "aria-selected": option === time.hour,
115
+ children: option
116
+ }, option);
117
+ })
118
+ }), /*#__PURE__*/_jsx(Picker, {
119
+ children: MINUTE_SECOND_OPTIONS.map(option => {
120
+ return /*#__PURE__*/_jsx(Option, {
121
+ role: "option",
122
+ onClick: () => {
123
+ handleChange('minute', option);
124
+ },
125
+ selected: option === time.minute,
126
+ "aria-selected": option === time.minute,
127
+ children: option
128
+ }, option);
129
+ })
130
+ }), /*#__PURE__*/_jsx(Picker, {
131
+ children: MINUTE_SECOND_OPTIONS.map(option => {
132
+ return /*#__PURE__*/_jsx(Option, {
133
+ role: "option",
134
+ onClick: () => {
135
+ handleChange('second', option);
136
+ },
137
+ selected: option === time.second,
138
+ "aria-selected": option === time.second,
139
+ children: option
140
+ }, option);
141
+ })
142
+ })]
143
+ })]
144
+ })
145
+ });
146
+ };
147
+ const Panel = styled.div`
148
+ display: flex;
149
+ visibility: ${_ref2 => {
150
+ let {
151
+ $display
152
+ } = _ref2;
153
+ return $display ? 'visible' : 'hidden';
154
+ }};
155
+ width: 100%;
156
+ max-width: 360px;
157
+ background: var(--color-background1);
158
+ color: var(--font-on-background);
159
+ border: var(--border-width) solid var(--border-color);
160
+ border-radius: var(--border-radius);
161
+ box-shadow: var(--box-shadow);
162
+ z-index: 85;
163
+ `;
164
+ const Picker = styled.ul`
165
+ flex: 1;
166
+ text-align: center;
167
+ max-height: 144px;
168
+ overflow-y: auto;
169
+
170
+ ${scrollbar}
171
+
172
+ &:first-child {
173
+ border-top-left-radius: var(--border-radius);
174
+ border-bottom-left-radius: var(--border-radius);
175
+ }
176
+
177
+ &:not(:last-child) {
178
+ border-right: var(--border-width) solid var(--border-color);
179
+ }
180
+ `;
181
+ const Option = styled.li`
182
+ padding: var(--spacing-xs) 0;
183
+ background: var(--color-background1);
184
+ transition: background 0.3s;
185
+
186
+ &:hover {
187
+ background: var(--color-hover);
188
+ }
189
+
190
+ ${_ref3 => {
191
+ let {
192
+ selected
193
+ } = _ref3;
194
+ return selected && css`
195
+ background: var(--color-hover);
196
+ `;
197
+ }}
198
+ `;
199
+ export default TimePickerV2;