@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,118 @@
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 _reactChartjs = require("react-chartjs-2");
10
+ var _lodash = _interopRequireDefault(require("lodash.uniqueid"));
11
+ var _htmlLegendPlugin = _interopRequireDefault(require("./utils/htmlLegendPlugin"));
12
+ var _customTooltip = _interopRequireDefault(require("./utils/customTooltip"));
13
+ var _centerTextPlugin = _interopRequireDefault(require("./utils/centerTextPlugin"));
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ 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); }
17
+ 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; }
18
+ const DoughnutChart = _ref => {
19
+ let {
20
+ height = 300,
21
+ data,
22
+ showCenterText = false,
23
+ centerTextTitle,
24
+ ...props
25
+ } = _ref;
26
+ const [legendContainerId] = (0, _react.useState)((0, _lodash.default)('legend-container-'));
27
+ const theme = (0, _react.useContext)(_styledComponents.ThemeContext);
28
+
29
+ // fix: read value from theme
30
+ _reactChartjs.defaults.font.family = theme.fontFamily;
31
+ _reactChartjs.defaults.font.size = 16;
32
+ _reactChartjs.defaults.color = theme.fontOnBg;
33
+ _reactChartjs.defaults.plugins.tooltip.external = (0, _customTooltip.default)(theme);
34
+ const defaultOptions = (0, _react.useMemo)(() => {
35
+ return {
36
+ responsive: true,
37
+ maintainAspectRatio: false,
38
+ aspectRatio: 1,
39
+ plugins: {
40
+ htmlLegend: {
41
+ containerID: legendContainerId
42
+ },
43
+ legend: {
44
+ display: false
45
+ },
46
+ tooltip: {
47
+ enabled: false,
48
+ callbacks: {
49
+ title(context) {
50
+ return context[0] ? context[0].label.match(/(.{1,20})/g) : '';
51
+ },
52
+ label(context) {
53
+ const label = context.dataset.data[context.dataIndex];
54
+ if (context.dataset.customLabel) {
55
+ return context.dataset.customLabel[context.dataIndex].toString();
56
+ }
57
+ return label.toString();
58
+ },
59
+ labelTextColor(context) {
60
+ const {
61
+ color
62
+ } = context.dataset;
63
+ if (!color) {
64
+ return theme.fontOnPrimary;
65
+ }
66
+ if (color && Array.isArray(color)) {
67
+ return color[context.dataIndex % color.length];
68
+ }
69
+ return color;
70
+ }
71
+ }
72
+ },
73
+ centerText: {
74
+ display: showCenterText,
75
+ title: centerTextTitle
76
+ }
77
+ }
78
+ };
79
+ }, [legendContainerId, theme.fontOnPrimary, showCenterText, centerTextTitle]);
80
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
81
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
82
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Doughnut, {
83
+ height: height,
84
+ data: data,
85
+ options: defaultOptions,
86
+ plugins: [_htmlLegendPlugin.default, _centerTextPlugin.default],
87
+ ...props
88
+ })
89
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(LegendWrapper, {
90
+ id: legendContainerId
91
+ })]
92
+ });
93
+ };
94
+ const LegendWrapper = _styledComponents.default.div`
95
+ .custom-legend-tooltip {
96
+ position: relative;
97
+ }
98
+
99
+ .custom-legend-tooltip:hover::after {
100
+ content: attr(data-tooltip);
101
+ position: absolute;
102
+ top: calc(1rem + var(--spacing-xs));
103
+ left: 50%;
104
+ transform: translateX(-50%);
105
+ border: 1px solid var(--border-color);
106
+ color: var(--font-on-background);
107
+ background: var(--color-background2);
108
+ box-shadow: var(--box-shadow);
109
+ border-radius: calc(var(--border-radius) / 2);
110
+ padding: var(--spacing-xs);
111
+ font-size: var(--font-body1);
112
+ font-weight: var(--font-normal);
113
+ text-align: center;
114
+ width: max-content;
115
+ max-width: 50vw;
116
+ }
117
+ `;
118
+ var _default = exports.default = DoughnutChart;
@@ -0,0 +1,146 @@
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 = require("styled-components");
9
+ var _reactChartjs = require("react-chartjs-2");
10
+ var _customTooltip = _interopRequireDefault(require("./utils/customTooltip"));
11
+ var _yAxisTopTitlePlugin = _interopRequireDefault(require("./utils/yAxisTopTitlePlugin"));
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ const LineChart = _ref => {
15
+ let {
16
+ height = 300,
17
+ data,
18
+ options = {},
19
+ ...props
20
+ } = _ref;
21
+ const theme = (0, _react.useContext)(_styledComponents.ThemeContext);
22
+
23
+ // fix: read value from theme
24
+ _reactChartjs.defaults.font.family = theme.fontFamily;
25
+ _reactChartjs.defaults.font.size = 16;
26
+ _reactChartjs.defaults.color = theme.fontOnBg;
27
+ _reactChartjs.defaults.plugins.tooltip.external = (0, _customTooltip.default)(theme);
28
+ const customOptions = (0, _react.useMemo)(() => {
29
+ const {
30
+ yAxisTopTitle
31
+ } = options;
32
+ return {
33
+ suggestedMax: options.suggestedMax ? options.suggestedMax : 10,
34
+ tooltipTitlePrefix: '',
35
+ tooltipLabelPrefix: '',
36
+ tooltipLabelPostfix: '',
37
+ showLegend: options.showLegend === undefined ? false : options.showLegend,
38
+ yAxisTopTitle: yAxisTopTitle ? yAxisTopTitle : ''
39
+ };
40
+ }, [options]);
41
+ if (options.tooltips) {
42
+ const tooltipsOptions = options.tooltips;
43
+ customOptions.tooltipTitlePrefix = tooltipsOptions.titlePrefix || '';
44
+ customOptions.tooltipLabelPrefix = tooltipsOptions.labelPrefix || '';
45
+ customOptions.tooltipLabelPostfix = tooltipsOptions.labelPostfix || '';
46
+ }
47
+ const defaultOptions = (0, _react.useMemo)(() => {
48
+ return {
49
+ responsive: true,
50
+ maintainAspectRatio: false,
51
+ aspectRatio: 1,
52
+ interaction: {
53
+ mode: 'nearest',
54
+ intersect: false
55
+ },
56
+ plugins: {
57
+ legend: {
58
+ display: customOptions.showLegend
59
+ },
60
+ tooltip: {
61
+ enabled: false,
62
+ intersect: false,
63
+ filter(context) {
64
+ return context.label !== 'null';
65
+ },
66
+ callbacks: {
67
+ title(context) {
68
+ const content = context[0] ? context[0].label.match(/(.{1,20})/g) : '';
69
+ return `${customOptions.tooltipTitlePrefix}${content}`;
70
+ },
71
+ label(context) {
72
+ const datasetLabel = context.dataset.label || '';
73
+ const tooltipLabel = context.dataset.tooltipLabels?.[context.dataIndex];
74
+ if (tooltipLabel !== undefined) {
75
+ return datasetLabel ? `${datasetLabel}: ${tooltipLabel}` : `${tooltipLabel}`;
76
+ }
77
+ const content = context.dataset.data[context.dataIndex].toString();
78
+ return datasetLabel ? `${datasetLabel}: ${customOptions.tooltipLabelPrefix}${content}${customOptions.tooltipLabelPostfix}` : `${customOptions.tooltipLabelPrefix}${content}${customOptions.tooltipLabelPostfix}`;
79
+ },
80
+ labelColor(context) {
81
+ const {
82
+ borderColor
83
+ } = context.dataset;
84
+ return {
85
+ borderColor,
86
+ backgroundColor: borderColor
87
+ };
88
+ },
89
+ labelTextColor(context) {
90
+ const {
91
+ color
92
+ } = context.dataset;
93
+ if (!color) {
94
+ return theme.fontOnPrimary;
95
+ }
96
+ if (color && Array.isArray(color)) {
97
+ return color[context.dataIndex % color.length];
98
+ }
99
+ return color;
100
+ }
101
+ }
102
+ },
103
+ yAxisTopTitle: {
104
+ title: customOptions.yAxisTopTitle
105
+ }
106
+ },
107
+ scales: {
108
+ x: {
109
+ grid: {
110
+ display: false,
111
+ drawBorder: false
112
+ }
113
+ },
114
+ y: {
115
+ beginAtZero: true,
116
+ suggestedMax: customOptions.suggestedMax,
117
+ grid: {
118
+ display: false,
119
+ drawBorder: false
120
+ },
121
+ ticks: {
122
+ callback(value) {
123
+ if (value % 1 === 0) {
124
+ return value;
125
+ }
126
+ return null;
127
+ }
128
+ }
129
+ }
130
+ },
131
+ layout: {
132
+ padding: {
133
+ top: 32
134
+ }
135
+ }
136
+ };
137
+ }, [customOptions, theme.fontOnPrimary]);
138
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Line, {
139
+ height: height,
140
+ data: data,
141
+ options: defaultOptions,
142
+ plugins: [_yAxisTopTitlePlugin.default],
143
+ ...props
144
+ });
145
+ };
146
+ var _default = exports.default = LineChart;
@@ -0,0 +1,42 @@
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 _backgroundColor = _interopRequireDefault(require("../styles/mixin/backgroundColor"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ const SingleBarChart = _styledComponents.default.div.attrs(() => ({
11
+ primary: true
12
+ }))`
13
+ position: relative;
14
+ width: 100%;
15
+ height: 1rem;
16
+ border-radius: var(--border-radius);
17
+ background: var(--color-background3);
18
+
19
+ &::before {
20
+ position: absolute;
21
+ content: '';
22
+ width: ${_ref => {
23
+ let {
24
+ percentage
25
+ } = _ref;
26
+ return percentage;
27
+ }}%;
28
+ border-radius: var(--border-radius);
29
+ top: 0;
30
+ bottom: 0;
31
+
32
+ ${_backgroundColor.default}
33
+ }
34
+
35
+ ${_ref2 => {
36
+ let {
37
+ marginTop
38
+ } = _ref2;
39
+ return marginTop && 'margin-top: var(--spacing-s)';
40
+ }}
41
+ `;
42
+ var _default = exports.default = SingleBarChart;
package/chart/index.js ADDED
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ BarChart: true,
8
+ DoughnutChart: true,
9
+ LineChart: true,
10
+ SingleBarChart: true
11
+ };
12
+ Object.defineProperty(exports, "BarChart", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _BarChart.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "DoughnutChart", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _DoughnutChart.default;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "LineChart", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _LineChart.default;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "SingleBarChart", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _SingleBarChart.default;
34
+ }
35
+ });
36
+ var _BarChart = _interopRequireDefault(require("./BarChart"));
37
+ var _DoughnutChart = _interopRequireDefault(require("./DoughnutChart"));
38
+ var _LineChart = _interopRequireDefault(require("./LineChart"));
39
+ var _SingleBarChart = _interopRequireDefault(require("./SingleBarChart"));
40
+ var _utils = require("./utils");
41
+ Object.keys(_utils).forEach(function (key) {
42
+ if (key === "default" || key === "__esModule") return;
43
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
44
+ if (key in exports && exports[key] === _utils[key]) return;
45
+ Object.defineProperty(exports, key, {
46
+ enumerable: true,
47
+ get: function () {
48
+ return _utils[key];
49
+ }
50
+ });
51
+ });
52
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _reactChartjs = require("react-chartjs-2");
8
+ const centerTextPlugin = {
9
+ id: 'centerText',
10
+ beforeDraw: chart => {
11
+ const {
12
+ options,
13
+ data
14
+ } = chart.config;
15
+ const config = options.plugins.centerText;
16
+ if (!config || !config.display) {
17
+ return;
18
+ }
19
+ const {
20
+ ctx,
21
+ chartArea: {
22
+ top,
23
+ width,
24
+ height
25
+ }
26
+ } = chart;
27
+ ctx.save();
28
+
29
+ // calculate center position
30
+ const centerX = width / 2;
31
+ const centerY = height / 2 + top;
32
+
33
+ // font settings
34
+ const {
35
+ font,
36
+ color
37
+ } = _reactChartjs.defaults;
38
+ const {
39
+ family,
40
+ size,
41
+ lineHeight
42
+ } = font;
43
+ const offset = size * lineHeight / 2;
44
+ ctx.textAlign = 'center';
45
+ ctx.textBaseline = 'middle';
46
+ ctx.fillStyle = color;
47
+ const {
48
+ title
49
+ } = config;
50
+ if (title) {
51
+ ctx.font = `bold ${size}px ${family}`;
52
+ ctx.fillText(title, centerX, centerY - offset);
53
+ }
54
+ const total = data.datasets[0].data.reduce((total, current) => {
55
+ return total + current;
56
+ }, 0);
57
+ ctx.font = `${size}px ${family}`;
58
+ ctx.fillText(total.toLocaleString(), centerX, centerY + (title ? offset : 0));
59
+ ctx.restore();
60
+ }
61
+ };
62
+ var _default = exports.default = centerTextPlugin;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const customTooltip = theme => {
8
+ // optimize: render in react way
9
+ return function (context) {
10
+ // Tooltip Element
11
+ let tooltipEl = document.getElementById('chartjs-tooltip');
12
+
13
+ // Create element on first render
14
+ if (!tooltipEl) {
15
+ tooltipEl = document.createElement('div');
16
+ tooltipEl.id = 'chartjs-tooltip';
17
+ tooltipEl.innerHTML = '<table></table>';
18
+ document.body.appendChild(tooltipEl);
19
+ }
20
+
21
+ // Hide tooltip, if no tooltip or no data
22
+ const tooltipModel = context.tooltip;
23
+ if (!tooltipModel || !tooltipModel.dataPoints || !tooltipModel.dataPoints[0] || tooltipModel.opacity === 0) {
24
+ tooltipEl.style.display = 'none';
25
+ return;
26
+ }
27
+
28
+ // Set caret Position
29
+ tooltipEl.classList.remove('above', 'below', 'no-transform');
30
+ if (tooltipModel.yAlign) {
31
+ tooltipEl.classList.add(tooltipModel.yAlign);
32
+ } else {
33
+ tooltipEl.classList.add('no-transform');
34
+ }
35
+
36
+ // Set Text
37
+ if (tooltipModel.body) {
38
+ const titleLines = tooltipModel.title || [];
39
+ const bodyLines = tooltipModel.body.map(bodyItem => {
40
+ return bodyItem.lines || [];
41
+ });
42
+ let innerHtml = '<thead>';
43
+ titleLines.forEach(title => {
44
+ innerHtml += `<tr><th>${title}</th></tr>`;
45
+ });
46
+ innerHtml += '</thead><tbody>';
47
+ bodyLines.forEach(body => {
48
+ if (Array.isArray(body)) {
49
+ body.forEach(line => {
50
+ innerHtml += `<tr><td>${line}</td></tr>`;
51
+ });
52
+ } else {
53
+ innerHtml += `<tr><td>${body}</td></tr>`;
54
+ }
55
+ });
56
+ innerHtml += '</tbody>';
57
+ const tableRoot = tooltipEl.querySelector('table');
58
+ tableRoot.innerHTML = innerHtml;
59
+ }
60
+
61
+ // `this` will be the overall tooltip
62
+ const position = context.chart.canvas.getBoundingClientRect();
63
+
64
+ // Display, position, and set styles for font
65
+ tooltipEl.style.fontFamily = theme.fontFamily;
66
+ tooltipEl.style.fontSize = theme.fontBody1;
67
+ tooltipEl.style.display = 'block';
68
+ tooltipEl.style.position = 'absolute';
69
+ tooltipEl.style.boxShadow = theme.boxShadow;
70
+ [tooltipEl.style.color] = tooltipModel.labelTextColors;
71
+ tooltipEl.style.background = tooltipModel.labelColors[0].backgroundColor;
72
+ tooltipEl.style.borderRadius = theme.borderRadius;
73
+ tooltipEl.style.textAlign = 'center';
74
+ tooltipEl.style.padding = `${theme.spacerXS} ${theme.spacerS}`;
75
+ tooltipEl.style.pointerEvents = 'none';
76
+
77
+ // determine position is left or right
78
+ if (tooltipModel.caretX + tooltipEl.offsetWidth <= this._chart.width) {
79
+ tooltipEl.style.borderTopLeftRadius = 0;
80
+ tooltipEl.style.left = `${position.left + window.pageXOffset + tooltipModel.caretX + 8}px`;
81
+ } else {
82
+ tooltipEl.style.borderTopRightRadius = 0;
83
+ tooltipEl.style.left = `${position.left + window.pageXOffset + tooltipModel.caretX - tooltipModel.width - 16 * 2}px`;
84
+ }
85
+
86
+ // determine position is top or bottom
87
+ if (tooltipModel.caretY + tooltipEl.offsetHeight <= this._chart.height) {
88
+ tooltipEl.style.top = `${position.top + window.pageYOffset + tooltipModel.caretY + 8}px`;
89
+ } else {
90
+ tooltipEl.style.top = `${position.top + window.pageYOffset + tooltipModel.caretY - tooltipModel.width - 16 * 2}px`;
91
+ }
92
+ };
93
+ };
94
+ var _default = exports.default = customTooltip;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _reactChartjs = require("react-chartjs-2");
8
+ const htmlLegendPlugin = {
9
+ id: 'htmlLegend',
10
+ afterUpdate(chart, args, options) {
11
+ const ul = getOrCreateLegendList(chart, options.containerID);
12
+
13
+ // Remove old legend items
14
+ while (ul.firstChild) {
15
+ ul.firstChild.remove();
16
+ }
17
+
18
+ // Reuse the built-in legendItems generator
19
+ const items = chart.options.plugins.legend.labels.generateLabels(chart);
20
+ items.forEach(item => {
21
+ const li = document.createElement('li');
22
+ li.style.alignItems = 'center';
23
+ li.style.cursor = 'pointer';
24
+ li.style.display = 'flex';
25
+ li.style.flexDirection = 'row';
26
+ li.style.marginLeft = '16px';
27
+ li.style.marginTop = '16px';
28
+ li.style.color = _reactChartjs.defaults.color;
29
+ const [dataset] = chart.data.datasets;
30
+ const description = dataset.descriptions ? dataset.descriptions[item.index] : '';
31
+ if (description) {
32
+ li.setAttribute('data-tooltip', description);
33
+ li.classList.add('custom-legend-tooltip');
34
+ }
35
+ li.onclick = () => {
36
+ const {
37
+ type
38
+ } = chart.config;
39
+ if (type === 'pie' || type === 'doughnut') {
40
+ // Pie and doughnut charts only have a single dataset and visibility is per item
41
+ chart.toggleDataVisibility(item.index);
42
+ } else {
43
+ chart.setDatasetVisibility(item.datasetIndex, !chart.isDatasetVisible(item.datasetIndex));
44
+ }
45
+ chart.update();
46
+ };
47
+
48
+ // Color box
49
+ const boxSpan = document.createElement('span');
50
+ boxSpan.style.background = item.fillStyle;
51
+ boxSpan.style.borderColor = item.strokeStyle;
52
+ boxSpan.style.borderWidth = `${item.lineWidth}px`;
53
+ boxSpan.style.borderStyle = 'solid';
54
+ boxSpan.style.display = 'inline-block';
55
+ boxSpan.style.height = '16px';
56
+ boxSpan.style.marginRight = '8px';
57
+ boxSpan.style.width = '32px';
58
+
59
+ // Text
60
+ const textContainer = document.createElement('p');
61
+ textContainer.style.color = item.fontColor;
62
+ textContainer.style.margin = 0;
63
+ textContainer.style.padding = 0;
64
+ textContainer.style.wordBreak = 'break-all';
65
+ textContainer.style.textDecoration = item.hidden ? 'line-through' : '';
66
+ const text = document.createTextNode(item.text);
67
+ textContainer.appendChild(text);
68
+ li.appendChild(boxSpan);
69
+ li.appendChild(textContainer);
70
+ ul.appendChild(li);
71
+ });
72
+ }
73
+ };
74
+ const getOrCreateLegendList = (chart, id) => {
75
+ const legendContainer = document.getElementById(id);
76
+ let listContainer = legendContainer.querySelector('ul');
77
+ if (!listContainer) {
78
+ listContainer = document.createElement('ul');
79
+ listContainer.style.display = 'flex';
80
+ listContainer.style.flexDirection = 'row';
81
+ listContainer.style.flexWrap = 'wrap';
82
+ listContainer.style.justifyContent = 'center';
83
+ listContainer.style.margin = 0;
84
+ listContainer.style.padding = 0;
85
+ legendContainer.appendChild(listContainer);
86
+ }
87
+ return listContainer;
88
+ };
89
+ var _default = exports.default = htmlLegendPlugin;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "customTooltip", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _customTooltip.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "htmlLegendPlugin", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _htmlLegendPlugin.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "padEmptyChartBar", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _padEmptyChartBar.default;
22
+ }
23
+ });
24
+ var _customTooltip = _interopRequireDefault(require("./customTooltip"));
25
+ var _padEmptyChartBar = _interopRequireDefault(require("./padEmptyChartBar"));
26
+ var _htmlLegendPlugin = _interopRequireDefault(require("./htmlLegendPlugin"));
27
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ // make chart bar seem like align left by pad empty bar at the end
8
+ const padEmptyChartBar = {
9
+ id: 'padEmptyChartBar',
10
+ length: -1,
11
+ // pad empty chart bar when data less than max bar number
12
+ beforeUpdate(chart) {
13
+ this.length = -1;
14
+ const {
15
+ data,
16
+ options
17
+ } = chart.config._config;
18
+ const validLabels = data.labels.filter(label => label !== null);
19
+ const {
20
+ maxBarNumber
21
+ } = options.plugins.padEmptyChartBar;
22
+ for (let index = validLabels.length; index < maxBarNumber; index += 1) {
23
+ this.length = this.length === -1 ? index : this.length;
24
+ data.labels[index] = null;
25
+ const [datasets] = data.datasets;
26
+ if (datasets) {
27
+ datasets.data[index] = 0;
28
+ }
29
+ }
30
+ },
31
+ // prevent padded empty chart bar to be drawn
32
+ afterUpdate(chart) {
33
+ const {
34
+ data,
35
+ options
36
+ } = chart.config._config;
37
+ const {
38
+ maxBarNumber
39
+ } = options.plugins.padEmptyChartBar;
40
+ if (this.length === -1) {
41
+ // restore draw function
42
+ for (let index = 0; index < maxBarNumber; index += 1) {
43
+ // delete data.datasets[0]._meta[data.index].data[i].draw;
44
+ }
45
+ } else {
46
+ // prevents new charts to be drawn
47
+ for (let index = this.length; index < data.maxBarNumber; index += 1) {
48
+ data.datasets[0]._meta[data.index].data[index].draw = () => {};
49
+ }
50
+ }
51
+ }
52
+ };
53
+ var _default = exports.default = padEmptyChartBar;