@cashub/ui-elv 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/Tab/Tab.js +28 -0
  2. package/Tab/TabList.js +167 -0
  3. package/Tab/TabPanel.js +49 -0
  4. package/Tab/TabTab.js +105 -0
  5. package/Tab/index.js +30 -0
  6. package/Tab/subComponent/TabContext.js +9 -0
  7. package/Tab/subComponent/TabListV2.js +25 -0
  8. package/Tab/subComponent/TabPanelV2.js +52 -0
  9. package/Tab/subComponent/TabTabV2.js +63 -0
  10. package/VerticalTab/TabList.js +27 -0
  11. package/VerticalTab/TabPanel.js +52 -0
  12. package/VerticalTab/TabTab.js +70 -0
  13. package/VerticalTab/VerticalTab.js +41 -0
  14. package/VerticalTab/index.js +16 -0
  15. package/VerticalTab/subComponent/TabContext.js +9 -0
  16. package/alert/Alert.js +29 -0
  17. package/alert/index.js +13 -0
  18. package/animate/Collapse.js +71 -0
  19. package/animate/Loader.js +58 -0
  20. package/animate/NumberCounter.js +51 -0
  21. package/animate/PulseRing.js +35 -0
  22. package/animate/Spinner.js +18 -0
  23. package/animate/index.js +41 -0
  24. package/assets/css/autocomplete.css +16 -0
  25. package/assets/css/font.css +4 -0
  26. package/assets/css/global.css +2 -0
  27. package/assets/font/helvetica/Helvetica.ttf +0 -0
  28. package/assets/font/nanumGothic/NanumGothic-Bold.ttf +0 -0
  29. package/assets/font/nanumGothic/NanumGothic-ExtraBold.ttf +0 -0
  30. package/assets/font/nanumGothic/NanumGothic-Regular.ttf +0 -0
  31. package/assets/icons/app-management.png +0 -0
  32. package/assets/icons/burger-black.png +0 -0
  33. package/assets/icons/burger-white.png +0 -0
  34. package/assets/icons/burger.png +0 -0
  35. package/assets/icons/file.svg +1 -0
  36. package/assets/icons/map_icon1.png +0 -0
  37. package/assets/icons/map_icon4.png +0 -0
  38. package/assets/images/bg-aside.png +0 -0
  39. package/assets/images/bg-chart-circle.png +0 -0
  40. package/assets/images/bg-chart-triangle.png +0 -0
  41. package/assets/images/cashub-logo-only.png +0 -0
  42. package/assets/images/default-user.jpg +0 -0
  43. package/assets/images/logo-cashub.png +0 -0
  44. package/assets/images/map.png +0 -0
  45. package/assets/images/qrcode.png +0 -0
  46. package/backdrop/BaseBackdrop.js +18 -0
  47. package/backdrop/LoadingBackdrop.js +17 -0
  48. package/backdrop/ModalBackdrop.js +15 -0
  49. package/backdrop/index.js +27 -0
  50. package/badge/Badge.js +26 -0
  51. package/badge/BadgeDot.js +18 -0
  52. package/badge/BadgeFill.js +49 -0
  53. package/badge/BadgeFillTriangle.js +147 -0
  54. package/badge/BadgeWithText.js +31 -0
  55. package/badge/index.js +41 -0
  56. package/billing/BarChart.js +51 -0
  57. package/billing/Grid.js +45 -0
  58. package/billing/Header2.js +25 -0
  59. package/billing/Header3.js +37 -0
  60. package/billing/Paragraph.js +33 -0
  61. package/billing/ParagraphGroup.js +22 -0
  62. package/billing/ParagraphText.js +26 -0
  63. package/billing/Section.js +50 -0
  64. package/billing/SectionBody.js +17 -0
  65. package/billing/SectionHeader.js +26 -0
  66. package/billing/__stories__/BarChart.stories.js_bak +46 -0
  67. package/billing/__stories__/Grid.stories.js_bak +57 -0
  68. package/billing/__stories__/Header2.stories.js_bak +62 -0
  69. package/billing/__stories__/Header3.stories.js_bak +69 -0
  70. package/billing/__stories__/Paragraph.stories.js_bak +84 -0
  71. package/billing/__stories__/ParagraphGroup.stories.js_bak +68 -0
  72. package/billing/__stories__/ParagraphText.stories.js_bak +64 -0
  73. package/billing/__stories__/Section.stories.js_bak +115 -0
  74. package/billing/__stories__/SectionBody.stories.js_bak +62 -0
  75. package/billing/__stories__/SectionHeader.stories.js-bak +68 -0
  76. package/breadcrumb/Breadcrumb.js +78 -0
  77. package/breadcrumb/index.js +13 -0
  78. package/button/Button.js +154 -0
  79. package/button/ButtonGroup.js +61 -0
  80. package/button/IconButton.js +72 -0
  81. package/button/ScrollToTopButton.js +54 -0
  82. package/button/index.js +34 -0
  83. package/callout/Callout.js +52 -0
  84. package/callout/index.js +13 -0
  85. package/chart/BarChart.js +148 -0
  86. package/chart/DoughnutChart.js +118 -0
  87. package/chart/LineChart.js +146 -0
  88. package/chart/SingleBarChart.js +42 -0
  89. package/chart/index.js +52 -0
  90. package/chart/utils/centerTextPlugin.js +62 -0
  91. package/chart/utils/customTooltip.js +94 -0
  92. package/chart/utils/htmlLegendPlugin.js +89 -0
  93. package/chart/utils/index.js +27 -0
  94. package/chart/utils/padEmptyChartBar.js +53 -0
  95. package/chart/utils/yAxisTopTitlePlugin.js +49 -0
  96. package/container/FlexContainer.js +40 -0
  97. package/container/index.js +13 -0
  98. package/cropper/Cropper.js +54 -0
  99. package/cropper/CropperModalHandler.js +41 -0
  100. package/cropper/index.js +20 -0
  101. package/cropper/subComponent/CropImageModal.js +79 -0
  102. package/datetimePicker/DatePicker.js +363 -0
  103. package/datetimePicker/DatePickerV2.js +407 -0
  104. package/datetimePicker/DatetimePicker.js +240 -0
  105. package/datetimePicker/DatetimePickerV2.js +395 -0
  106. package/datetimePicker/DatetimePickerV3.js +279 -0
  107. package/datetimePicker/TimeInput.js +56 -0
  108. package/datetimePicker/TimePicker.js +317 -0
  109. package/datetimePicker/TimePickerStyle.js +64 -0
  110. package/datetimePicker/TimePickerV2.js +208 -0
  111. package/datetimePicker/accordion/Month.js +254 -0
  112. package/datetimePicker/accordion/Year.js +284 -0
  113. package/datetimePicker/hooks/index.js +27 -0
  114. package/datetimePicker/hooks/useChangeNumber.js +42 -0
  115. package/datetimePicker/hooks/useDecrease.js +38 -0
  116. package/datetimePicker/hooks/useIncrease.js +38 -0
  117. package/datetimePicker/index.js +69 -0
  118. package/datetimePicker/provider/constant.js +43 -0
  119. package/datetimePicker/subComponent/Accordion.js +373 -0
  120. package/datetimePicker/subComponent/CustomTimeInput.js +47 -0
  121. package/datetimePicker/subComponent/DateTimePickerContext.js +9 -0
  122. package/datetimePicker/utils/GMTDate.js +15 -0
  123. package/datetimePicker/utils/pad.js +13 -0
  124. package/datetimePicker/utils/toUTC0.js +13 -0
  125. package/descriptionList/DescriptionDetail.js +28 -0
  126. package/descriptionList/DescriptionList.js +25 -0
  127. package/descriptionList/DescriptionTerm.js +14 -0
  128. package/descriptionList/index.js +27 -0
  129. package/divider/Divider.js +31 -0
  130. package/divider/index.js +13 -0
  131. package/dropdown/Dropdown.js +55 -0
  132. package/dropdown/DropdownButtonOption.js +43 -0
  133. package/dropdown/DropdownContent.js +90 -0
  134. package/dropdown/DropdownDivOption.js +26 -0
  135. package/dropdown/DropdownItem.js +26 -0
  136. package/dropdown/DropdownLinkOption.js +24 -0
  137. package/dropdown/DropdownToggle.js +38 -0
  138. package/dropdown/index.js +42 -0
  139. package/dropdown/subComponent/DropdownContext.js +9 -0
  140. package/dropzone/FileDropzone.js +479 -0
  141. package/dropzone/ImageDropzone.js +334 -0
  142. package/dropzone/index.js +20 -0
  143. package/dropzone/subComponent/Message.js +26 -0
  144. package/figure/IconFigure.js +42 -0
  145. package/figure/ImageFigure.js +38 -0
  146. package/figure/index.js +20 -0
  147. package/file/HiddenFileInput.js +15 -0
  148. package/file/index.js +13 -0
  149. package/form/Checkbox.js +166 -0
  150. package/form/Fieldset.js +18 -0
  151. package/form/FormItem.js +22 -0
  152. package/form/Input.js +66 -0
  153. package/form/Label.js +61 -0
  154. package/form/MutedText.js +21 -0
  155. package/form/PasswordInput.js +47 -0
  156. package/form/RadioButton.js +103 -0
  157. package/form/SearchSelect.js +181 -0
  158. package/form/Searchbox.js +98 -0
  159. package/form/Slider.js +46 -0
  160. package/form/SwitchButton.js +105 -0
  161. package/form/Textarea.js +41 -0
  162. package/form/TreeView.js +73 -0
  163. package/form/index.js +104 -0
  164. package/grid/Column.js +46 -0
  165. package/grid/Grid.js +35 -0
  166. package/grid/index.js +20 -0
  167. package/heading/Heading1.js +21 -0
  168. package/heading/Heading2.js +28 -0
  169. package/heading/Heading3.js +49 -0
  170. package/heading/index.js +27 -0
  171. package/helmet/Helmet.js +23 -0
  172. package/helmet/index.js +20 -0
  173. package/iconbox/ApplicationIconBox.js +81 -0
  174. package/iconbox/IconBox.js +67 -0
  175. package/iconbox/IconBoxV2.js +72 -0
  176. package/iconbox/index.js +27 -0
  177. package/iconbox/subComponent/IconBoxFigure.js +50 -0
  178. package/iconbox/subComponent/IconBoxImage.js +42 -0
  179. package/image/ImageFluid.js +17 -0
  180. package/image/UploadImage.js +250 -0
  181. package/image/index.js +20 -0
  182. package/index.js +568 -0
  183. package/jsoneditor/JsonEditor.js +142 -0
  184. package/jsoneditor/index.js +13 -0
  185. package/keyframe/Pulse.js +21 -0
  186. package/keyframe/Spin.js +13 -0
  187. package/layout/Aside.js +48 -0
  188. package/layout/AsideHeader.jsx +27 -0
  189. package/layout/Backdrop.js +23 -0
  190. package/layout/Container.js +39 -0
  191. package/layout/Footer.js +45 -0
  192. package/layout/Header.jsx +55 -0
  193. package/layout/Layout.jsx +84 -0
  194. package/layout/Logo.jsx +17 -0
  195. package/layout/MenuIcon.jsx +27 -0
  196. package/layout/Sidebar.jsx +271 -0
  197. package/layout/index.js +13 -0
  198. package/link/LinkSpan.js +69 -0
  199. package/link/index.js +13 -0
  200. package/map/GoogleMap.js +448 -0
  201. package/map/GoogleReverseGeolocation.js +200 -0
  202. package/map/LeafletMap.js +231 -0
  203. package/map/LeafletReverseGeolocation.js +101 -0
  204. package/map/index.js +34 -0
  205. package/map/subComponent/BasicLeafletMap.js +34 -0
  206. package/map/subComponent/GoogleMapContainer.js +29 -0
  207. package/map/subComponent/GoogleMapPopup.js +109 -0
  208. package/map/subComponent/GoogleMapWrapper.js +40 -0
  209. package/map/subComponent/LeafletDrawControl.js +127 -0
  210. package/map/subComponent/LeafletMapContainer.js +173 -0
  211. package/map/subComponent/MapSearchBoxControl.js +54 -0
  212. package/modal/StateModal.js +178 -0
  213. package/modal/TitleModal.js +250 -0
  214. package/modal/index.js +20 -0
  215. package/package.json +54 -0
  216. package/page/Disclaimer.js +128 -0
  217. package/page/index.js +13 -0
  218. package/paginate/Paginate.js +137 -0
  219. package/paginate/index.js +13 -0
  220. package/popover/Popover.js +91 -0
  221. package/popover/index.js +13 -0
  222. package/qrcode/QRCode.js +58 -0
  223. package/qrcode/QRCodeContainter.js +34 -0
  224. package/qrcode/index.js +20 -0
  225. package/ribbon/Ribbon.js +42 -0
  226. package/ribbon/index.js +13 -0
  227. package/section/Section.js +133 -0
  228. package/section/SectionBody.js +52 -0
  229. package/section/SectionHeader.js +70 -0
  230. package/section/SectionToolbar.js +18 -0
  231. package/section/SectionToolbarItem.js +17 -0
  232. package/section/index.js +41 -0
  233. package/select/InputSelect.js +270 -0
  234. package/select/Select.js +818 -0
  235. package/select/index.js +20 -0
  236. package/select/subComponent/Checkbox.js +48 -0
  237. package/select/subComponent/Footer.js +13 -0
  238. package/select/subComponent/ListBox.js +30 -0
  239. package/select/subComponent/Option.js +45 -0
  240. package/select/subComponent/OptionGroup.js +23 -0
  241. package/select/subComponent/Options.js +32 -0
  242. package/select/subComponent/SearchBox.js +58 -0
  243. package/select/subComponent/SelectedMultipleCount.js +39 -0
  244. package/select/subComponent/SelectedMultipleTags.js +54 -0
  245. package/select/subComponent/SelectedMultipleText.js +70 -0
  246. package/select/subComponent/SelectedSingle.js +17 -0
  247. package/styles/GlobalStyle.js +334 -0
  248. package/styles/config/breakpoint.style.js +13 -0
  249. package/styles/config/header.style.js +10 -0
  250. package/styles/config/sidebar.style.js +17 -0
  251. package/styles/index.js +20 -0
  252. package/styles/mixin/backgroundColor.js +44 -0
  253. package/styles/mixin/borderColor.js +37 -0
  254. package/styles/mixin/color.js +37 -0
  255. package/styles/mixin/colorOnBackground.js +37 -0
  256. package/styles/mixin/inputPlaceholder.js +30 -0
  257. package/styles/mixin/media.js +21 -0
  258. package/styles/mixin/rounded.js +30 -0
  259. package/styles/mixin/scrollbar.js +32 -0
  260. package/styles/theme/dark.theme.js +97 -0
  261. package/styles/theme/light.theme.js +97 -0
  262. package/styles/theme/white.theme.js +97 -0
  263. package/styles/themes.js +16 -0
  264. package/table/GridTable.js +336 -0
  265. package/table/ImageBox.js +45 -0
  266. package/table/InfiniteGridTable.js +403 -0
  267. package/table/PermissionTable.js +64 -0
  268. package/table/SimpleGridTable.js +143 -0
  269. package/table/Table.js +568 -0
  270. package/table/__mock__/columns.js +70 -0
  271. package/table/__mock__/data.js +536 -0
  272. package/table/hooks/index.js +20 -0
  273. package/table/hooks/useCalculateDataRange.js +28 -0
  274. package/table/hooks/useGenerateSort.js +39 -0
  275. package/table/index.js +48 -0
  276. package/table/subComponent/BaseTableHeadCell.js +62 -0
  277. package/table/subComponent/GridTableFooter.js +24 -0
  278. package/table/subComponent/GridTableHeadCell.js +20 -0
  279. package/table/subComponent/Resizer.js +77 -0
  280. package/table/subComponent/TableFooter.js +31 -0
  281. package/table/subComponent/TableFooterInfo.js +13 -0
  282. package/table/subComponent/TableFooterPager.js +33 -0
  283. package/table/subComponent/TableHeadCell.js +19 -0
  284. package/table/subComponent/TableSort.js +38 -0
  285. package/tagify/TagifyStyle.js +60 -0
  286. package/tagify/Tags.js +56 -0
  287. package/tagify/index.js +27 -0
  288. package/tagify/templates/getCreateButtonTemplate.js +18 -0
  289. package/text/Paragraph.js +86 -0
  290. package/text/index.js +13 -0
  291. package/timeline/Timeline.js +139 -0
  292. package/timeline/index.js +13 -0
  293. package/toast/CustomToastContainer.js +45 -0
  294. package/toast/MessageContainer.js +51 -0
  295. package/toast/index.js +36 -0
  296. package/toast/show.js +39 -0
  297. package/toast/style.css +1 -0
  298. package/tooltip/Tooltip.js +140 -0
  299. package/tooltip/index.js +13 -0
  300. package/treeView/TreeViewV2.js +38 -0
  301. package/treeView/TreeflexStyle.js +49 -0
  302. package/treeView/index.js +20 -0
  303. package/wizard/Wizard.js +251 -0
  304. package/wizard/index.js +13 -0
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
8
+ var _rcTimePicker = _interopRequireDefault(require("rc-time-picker"));
9
+ require("rc-time-picker/assets/index.css");
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ const TimeInput = props => {
13
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapper, {
14
+ disabled: props.disabled,
15
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_rcTimePicker.default, {
16
+ ...props
17
+ })
18
+ });
19
+ };
20
+ const Wrapper = _styledComponents.default.div`
21
+ .rc-time-picker {
22
+ width: 100%;
23
+
24
+ .rc-time-picker-input {
25
+ height: 36px;
26
+ border-radius: var(--border-radius);
27
+ border: var(--border-width) solid var(--border-color);
28
+ padding: 10px var(--spacing-s);
29
+ color: var(--font-on-background);
30
+ background: transparent;
31
+ font-size: var(--font-body1);
32
+
33
+ ${_ref => {
34
+ let {
35
+ disabled
36
+ } = _ref;
37
+ return disabled && 'opacity: 0.5;';
38
+ }}
39
+
40
+ &:focus {
41
+ border: var(--border-width) solid var(--color-primary);
42
+ outline: none;
43
+ }
44
+ }
45
+
46
+ .rc-time-picker-clear {
47
+ top: 6px;
48
+ right: 8px;
49
+
50
+ i:after {
51
+ font-size: var(--font-body1);
52
+ }
53
+ }
54
+ }
55
+ `;
56
+ var _default = exports.default = TimeInput;
@@ -0,0 +1,317 @@
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 _fa = require("react-icons/fa");
9
+ var _moment = _interopRequireDefault(require("moment"));
10
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
11
+ var _lodash = _interopRequireDefault(require("lodash.uniqueid"));
12
+ var _utils = require("@cashub/utils");
13
+ var _hooks = require("./hooks");
14
+ var _pad = _interopRequireDefault(require("./utils/pad"));
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
+ const LENGTH = 2;
18
+ const PAD_STRING = '0';
19
+ const TimePicker = _ref => {
20
+ let {
21
+ labelName = 'Time',
22
+ value,
23
+ onChange,
24
+ showSecond = true
25
+ } = _ref;
26
+ const [hourId] = (0, _react.useState)((0, _lodash.default)('hour-'));
27
+ const [time, setTime] = (0, _react.useState)(() => {
28
+ let time = (0, _moment.default)(value, 'HH:mm:ss');
29
+
30
+ // use current time when time value is invalid
31
+ if (!value || !time.isValid()) {
32
+ time = (0, _moment.default)();
33
+ }
34
+ return {
35
+ hour: (0, _pad.default)(time.hour(), LENGTH, PAD_STRING),
36
+ minute: (0, _pad.default)(time.minute(), LENGTH, PAD_STRING),
37
+ second: (0, _pad.default)(time.second(), LENGTH, PAD_STRING)
38
+ };
39
+ });
40
+ (0, _react.useEffect)(() => {
41
+ if (typeof onChange === 'function' && time.hour && time.minute && time.second) {
42
+ onChange(`${time.hour}:${time.minute}:${time.second}`);
43
+ }
44
+ }, [onChange, time.hour, time.minute, time.second]);
45
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Container, {
46
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Label, {
47
+ htmlFor: hourId,
48
+ children: labelName
49
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Hour, {
50
+ id: hourId,
51
+ value: time.hour,
52
+ setTime: setTime
53
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Minute, {
54
+ value: time.minute,
55
+ setTime: setTime
56
+ }), showSecond === true && /*#__PURE__*/(0, _jsxRuntime.jsx)(Second, {
57
+ value: time.second,
58
+ setTime: setTime
59
+ })]
60
+ });
61
+ };
62
+ const Hour = _ref2 => {
63
+ let {
64
+ id,
65
+ value,
66
+ setTime
67
+ } = _ref2;
68
+ const NAME = 'hour';
69
+ const MIN = 0;
70
+ const MAX = 23;
71
+ const increase = (0, _hooks.useIncrease)(MIN, MAX, setTime, {
72
+ name: NAME,
73
+ length: LENGTH,
74
+ padString: PAD_STRING
75
+ });
76
+ const decrease = (0, _hooks.useDecrease)(MIN, MAX, setTime, {
77
+ name: NAME,
78
+ length: LENGTH,
79
+ padString: PAD_STRING
80
+ });
81
+ const changeNumber = (0, _hooks.useChangeNumber)(MIN, MAX, setTime, NAME);
82
+ const handleKeyUp = useKeyUp(increase, decrease, MIN, MAX, setTime, NAME);
83
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Section, {
84
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Input, {
85
+ type: "text",
86
+ id: id,
87
+ maxLength: "2",
88
+ value: value,
89
+ onChange: event => {
90
+ changeNumber(event.target.value);
91
+ },
92
+ onKeyUp: handleKeyUp,
93
+ onBlur: event => {
94
+ setTime(previous => {
95
+ const newState = {
96
+ ...previous
97
+ };
98
+ newState[NAME] = (0, _pad.default)(event.target.value, LENGTH, PAD_STRING);
99
+ return newState;
100
+ });
101
+ }
102
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Stepper, {
103
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(StepperButton, {
104
+ onClick: increase,
105
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fa.FaAngleUp, {})
106
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(StepperButton, {
107
+ onClick: decrease,
108
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fa.FaAngleDown, {})
109
+ })]
110
+ })]
111
+ });
112
+ };
113
+ const Minute = _ref3 => {
114
+ let {
115
+ value,
116
+ setTime
117
+ } = _ref3;
118
+ const NAME = 'minute';
119
+ const MIN = 0;
120
+ const MAX = 59;
121
+ const [minuteId] = (0, _react.useState)((0, _lodash.default)(`${NAME}-`));
122
+ const increase = (0, _hooks.useIncrease)(MIN, MAX, setTime, {
123
+ name: NAME,
124
+ length: LENGTH,
125
+ padString: PAD_STRING
126
+ });
127
+ const decrease = (0, _hooks.useDecrease)(MIN, MAX, setTime, {
128
+ name: NAME,
129
+ length: LENGTH,
130
+ padString: PAD_STRING
131
+ });
132
+ const changeNumber = (0, _hooks.useChangeNumber)(MIN, MAX, setTime, NAME);
133
+ const handleKeyUp = useKeyUp(increase, decrease, MIN, MAX, setTime, NAME);
134
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
135
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Delimiter, {
136
+ children: ":"
137
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Section, {
138
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Input, {
139
+ type: "text",
140
+ id: minuteId,
141
+ maxLength: "2",
142
+ value: value,
143
+ onChange: event => {
144
+ changeNumber(event.target.value);
145
+ },
146
+ onKeyUp: handleKeyUp,
147
+ onBlur: event => {
148
+ setTime(previous => {
149
+ const newState = {
150
+ ...previous
151
+ };
152
+ newState[NAME] = (0, _pad.default)(event.target.value, LENGTH, PAD_STRING);
153
+ return newState;
154
+ });
155
+ }
156
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Stepper, {
157
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(StepperButton, {
158
+ onClick: increase,
159
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fa.FaAngleUp, {})
160
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(StepperButton, {
161
+ onClick: decrease,
162
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fa.FaAngleDown, {})
163
+ })]
164
+ })]
165
+ })]
166
+ });
167
+ };
168
+ const Second = _ref4 => {
169
+ let {
170
+ value,
171
+ setTime
172
+ } = _ref4;
173
+ const NAME = 'second';
174
+ const MIN = 0;
175
+ const MAX = 59;
176
+ const [secondId] = (0, _react.useState)((0, _lodash.default)(`${NAME}-`));
177
+ const increase = (0, _hooks.useIncrease)(MIN, MAX, setTime, {
178
+ name: NAME,
179
+ length: LENGTH,
180
+ padString: PAD_STRING
181
+ });
182
+ const decrease = (0, _hooks.useDecrease)(MIN, MAX, setTime, {
183
+ name: NAME,
184
+ length: LENGTH,
185
+ padString: PAD_STRING
186
+ });
187
+ const changeNumber = (0, _hooks.useChangeNumber)(MIN, MAX, setTime, NAME);
188
+ const handleKeyUp = useKeyUp(increase, decrease, MIN, MAX, setTime, NAME);
189
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
190
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Delimiter, {
191
+ children: ":"
192
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Section, {
193
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Input, {
194
+ type: "text",
195
+ id: secondId,
196
+ maxLength: "2",
197
+ value: value,
198
+ onChange: event => {
199
+ changeNumber(event.target.value);
200
+ },
201
+ onKeyUp: handleKeyUp,
202
+ onBlur: event => {
203
+ setTime(previous => {
204
+ const newState = {
205
+ ...previous
206
+ };
207
+ newState[NAME] = (0, _pad.default)(event.target.value, LENGTH, PAD_STRING);
208
+ return newState;
209
+ });
210
+ }
211
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Stepper, {
212
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(StepperButton, {
213
+ onClick: increase,
214
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fa.FaAngleUp, {})
215
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(StepperButton, {
216
+ onClick: decrease,
217
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_fa.FaAngleDown, {})
218
+ })]
219
+ })]
220
+ })]
221
+ });
222
+ };
223
+ const useKeyUp = (increase, decrease, min, max, setState, name) => {
224
+ return (0, _react.useCallback)(event => {
225
+ const key = event.keyCode;
226
+ switch (key) {
227
+ case _utils.KEY_CODE.UP:
228
+ increase();
229
+ break;
230
+ case _utils.KEY_CODE.DOWN:
231
+ decrease();
232
+ break;
233
+ case _utils.KEY_CODE.HOME:
234
+ setState(previous => {
235
+ const newState = {
236
+ ...previous
237
+ };
238
+ newState[name] = (0, _pad.default)(min, LENGTH, PAD_STRING);
239
+ return newState;
240
+ });
241
+ break;
242
+ case _utils.KEY_CODE.END:
243
+ setState(previous => {
244
+ const newState = {
245
+ ...previous
246
+ };
247
+ newState[name] = (0, _pad.default)(max, LENGTH, PAD_STRING);
248
+ return newState;
249
+ });
250
+ break;
251
+ default:
252
+ break;
253
+ }
254
+ }, [increase, decrease, min, max, setState, name]);
255
+ };
256
+ const Container = _styledComponents.default.div`
257
+ display: flex;
258
+ align-items: center;
259
+ justify-content: center;
260
+ `;
261
+ const Label = _styledComponents.default.label`
262
+ display: inline-block;
263
+ color: var(--font-on-background);
264
+ font-size: var(--font-body1);
265
+ margin-right: 12px;
266
+ `;
267
+ const Section = _styledComponents.default.div`
268
+ display: inline-flex;
269
+ height: 36px;
270
+ width: 56px;
271
+ padding: calc(var(--spacing-xs) / 2) var(--spacing-xs);
272
+ border: var(--border-width) solid var(--border-color);
273
+ border-radius: var(--border-radius-s);
274
+ background: transparent;
275
+ color: var(--font-on-background);
276
+ `;
277
+ const Input = _styledComponents.default.input`
278
+ width: calc(100% - 4px - 12px);
279
+ border: none;
280
+ background: transparent;
281
+ color: inherit;
282
+
283
+ &:focus {
284
+ outline: none;
285
+ }
286
+ `;
287
+ const StepperButton = _styledComponents.default.div.attrs(() => ({
288
+ role: 'button'
289
+ }))`
290
+ width: 12px;
291
+ height: 12px;
292
+
293
+ > svg {
294
+ width: 100%;
295
+ height: 100%;
296
+ vertical-align: top;
297
+ }
298
+
299
+ &:first-child {
300
+ margin-bottom: 2px;
301
+ }
302
+
303
+ &:hover {
304
+ color: var(--color-primary);
305
+ }
306
+ `;
307
+ const Stepper = _styledComponents.default.div`
308
+ margin-left: calc(var(--spacing-xs) / 2);
309
+ `;
310
+ const Delimiter = _styledComponents.default.span`
311
+ display: inline-block;
312
+ color: var(--font-on-background);
313
+ font-size: var(--font-body1);
314
+ width: 12px;
315
+ text-align: center;
316
+ `;
317
+ var _default = exports.default = TimePicker;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _styledComponents = require("styled-components");
8
+ var _scrollbar = _interopRequireDefault(require("../styles/mixin/scrollbar"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ // integrate rc-time-picker component
11
+ const TimePickerStyle = (0, _styledComponents.createGlobalStyle)`
12
+ .rc-time-picker-panel-narrow {
13
+ max-width: none;
14
+ }
15
+
16
+ .rc-time-picker-panel {
17
+ .rc-time-picker-panel-inner {
18
+ background: transparent;
19
+ border: none;
20
+ box-shadow: none;
21
+
22
+ .rc-time-picker-panel-input-wrap {
23
+ display: none;
24
+ }
25
+
26
+ .rc-time-picker-panel-combobox {
27
+ height: 144px;
28
+ border: var(--border-width) solid var(--border-color);
29
+ color: var(--font-on-background);
30
+ box-shadow: var(--box-shadow);
31
+ border-radius: var(--border-radius);
32
+ background: var(--color-background2);
33
+
34
+ .rc-time-picker-panel-select {
35
+ font-size: var(--font-body1);
36
+
37
+ ${_scrollbar.default}
38
+
39
+ li {
40
+ &:hover {
41
+ background: var(--color-hover);
42
+ }
43
+
44
+ &.rc-time-picker-panel-select-option-selected {
45
+ background: var(--color-hover);
46
+ }
47
+ }
48
+
49
+ &:first-child {
50
+ border-top-left-radius: var(--border-radius);
51
+ border-bottom-left-radius: var(--border-radius);
52
+ }
53
+ }
54
+ }
55
+ }
56
+
57
+ &.rc-time-picker-panel-placement-bottomLeft {
58
+ .rc-time-picker-panel-inner {
59
+ padding-top: calc(36px + var(--spacing-xs));
60
+ }
61
+ }
62
+ }
63
+ `;
64
+ var _default = exports.default = TimePickerStyle;
@@ -0,0 +1,208 @@
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 = _interopRequireWildcard(require("styled-components"));
9
+ var _reactOutsideClickHandler = _interopRequireDefault(require("react-outside-click-handler"));
10
+ var _hooks = require("@cashub/hooks");
11
+ var _utils = require("@cashub/utils");
12
+ var _pad = _interopRequireDefault(require("./utils/pad"));
13
+ var _form = require("../form");
14
+ var _scrollbar = _interopRequireDefault(require("../styles/mixin/scrollbar"));
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
+ 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); }
18
+ 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; }
19
+ const LENGTH = 2;
20
+ const PAD_STRING = '0';
21
+ const HOUR_OPTIONS = (0, _utils.generateRange)(0, 23).map(value => {
22
+ return (0, _pad.default)(value, LENGTH, PAD_STRING);
23
+ });
24
+ const MINUTE_SECOND_OPTIONS = (0, _utils.generateRange)(0, 59).map(value => {
25
+ return (0, _pad.default)(value, LENGTH, PAD_STRING);
26
+ });
27
+ const EMPTY_TIME = {
28
+ hour: '',
29
+ minute: '',
30
+ second: ''
31
+ };
32
+ const getTimeFromSelected = (selected, allowEmpty) => {
33
+ let time = new Date(Date.parse(selected));
34
+ if (isNaN(time)) {
35
+ if (allowEmpty) {
36
+ return EMPTY_TIME;
37
+ }
38
+ time = new Date();
39
+ }
40
+ return {
41
+ hour: (0, _pad.default)(time.getHours(), LENGTH, PAD_STRING),
42
+ minute: (0, _pad.default)(time.getMinutes(), LENGTH, PAD_STRING),
43
+ second: (0, _pad.default)(time.getSeconds(), LENGTH, PAD_STRING)
44
+ };
45
+ };
46
+ const TimePickerV2 = _ref => {
47
+ let {
48
+ selected,
49
+ onSelect,
50
+ allowEmpty = false
51
+ } = _ref;
52
+ const [display, setDisplay] = (0, _react.useState)(false);
53
+ const [targetElement, setTargetElement] = (0, _react.useState)(null);
54
+ const [popperElement, setPopperElement] = (0, _react.useState)(null);
55
+ const [time, setTime] = (0, _react.useState)(() => {
56
+ return getTimeFromSelected(selected, allowEmpty);
57
+ });
58
+ const {
59
+ styles,
60
+ attributes,
61
+ state,
62
+ update
63
+ } = (0, _hooks.useCustomPopper)(targetElement, popperElement, {
64
+ placement: 'bottom-start'
65
+ });
66
+ const handleToggle = () => {
67
+ setDisplay(!display);
68
+ update();
69
+ };
70
+ const handleChange = (type, value) => {
71
+ const next = {
72
+ ...time,
73
+ [type]: value
74
+ };
75
+ setTime(next);
76
+ if (typeof onSelect === 'function' && next.hour && next.minute && next.second) {
77
+ onSelect(`${next.hour}:${next.minute}:${next.second}`);
78
+ }
79
+ };
80
+
81
+ // sync time picker state when selected value changes
82
+ (0, _react.useEffect)(() => {
83
+ setTime(getTimeFromSelected(selected, allowEmpty));
84
+ }, [allowEmpty, selected]);
85
+ (0, _react.useEffect)(() => {
86
+ if (display) {
87
+ const {
88
+ childNodes
89
+ } = popperElement;
90
+ childNodes.forEach(panel => {
91
+ const selectedItem = panel.querySelector('[aria-selected="true"]');
92
+ if (panel.scrollHeight > panel.clientHeight) {
93
+ panel.scrollTop = selectedItem ? selectedItem.offsetTop : 0;
94
+ }
95
+ });
96
+ }
97
+ }, [display, popperElement]);
98
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactOutsideClickHandler.default, {
99
+ onOutsideClick: () => {
100
+ setDisplay(false);
101
+ },
102
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
103
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_form.Input, {
104
+ ref: setTargetElement,
105
+ type: "text",
106
+ readOnly: true,
107
+ onClick: handleToggle,
108
+ value: time.hour && time.minute && time.second ? `${time.hour}:${time.minute}:${time.second}` : ''
109
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Panel, {
110
+ ref: setPopperElement,
111
+ $display: display,
112
+ style: styles.popper,
113
+ ...attributes.popper,
114
+ placement: state && state.placement,
115
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Picker, {
116
+ children: HOUR_OPTIONS.map(option => {
117
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Option, {
118
+ role: "option",
119
+ onClick: () => {
120
+ handleChange('hour', option);
121
+ },
122
+ selected: option === time.hour,
123
+ "aria-selected": option === time.hour,
124
+ children: option
125
+ }, option);
126
+ })
127
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Picker, {
128
+ children: MINUTE_SECOND_OPTIONS.map(option => {
129
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Option, {
130
+ role: "option",
131
+ onClick: () => {
132
+ handleChange('minute', option);
133
+ },
134
+ selected: option === time.minute,
135
+ "aria-selected": option === time.minute,
136
+ children: option
137
+ }, option);
138
+ })
139
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(Picker, {
140
+ children: MINUTE_SECOND_OPTIONS.map(option => {
141
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Option, {
142
+ role: "option",
143
+ onClick: () => {
144
+ handleChange('second', option);
145
+ },
146
+ selected: option === time.second,
147
+ "aria-selected": option === time.second,
148
+ children: option
149
+ }, option);
150
+ })
151
+ })]
152
+ })]
153
+ })
154
+ });
155
+ };
156
+ const Panel = _styledComponents.default.div`
157
+ display: flex;
158
+ visibility: ${_ref2 => {
159
+ let {
160
+ $display
161
+ } = _ref2;
162
+ return $display ? 'visible' : 'hidden';
163
+ }};
164
+ width: 100%;
165
+ max-width: 360px;
166
+ background: var(--color-background1);
167
+ color: var(--font-on-background);
168
+ border: var(--border-width) solid var(--border-color);
169
+ border-radius: var(--border-radius);
170
+ box-shadow: var(--box-shadow);
171
+ z-index: 85;
172
+ `;
173
+ const Picker = _styledComponents.default.ul`
174
+ flex: 1;
175
+ text-align: center;
176
+ max-height: 144px;
177
+ overflow-y: auto;
178
+
179
+ ${_scrollbar.default}
180
+
181
+ &:first-child {
182
+ border-top-left-radius: var(--border-radius);
183
+ border-bottom-left-radius: var(--border-radius);
184
+ }
185
+
186
+ &:not(:last-child) {
187
+ border-right: var(--border-width) solid var(--border-color);
188
+ }
189
+ `;
190
+ const Option = _styledComponents.default.li`
191
+ padding: var(--spacing-xs) 0;
192
+ background: var(--color-background1);
193
+ transition: background 0.3s;
194
+
195
+ &:hover {
196
+ background: var(--color-hover);
197
+ }
198
+
199
+ ${_ref3 => {
200
+ let {
201
+ selected
202
+ } = _ref3;
203
+ return selected && (0, _styledComponents.css)`
204
+ background: var(--color-hover);
205
+ `;
206
+ }}
207
+ `;
208
+ var _default = exports.default = TimePickerV2;