@cashub/ui 0.21.0 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/Tab/Tab.js +9 -13
  2. package/Tab/TabList.js +14 -32
  3. package/Tab/TabPanel.js +21 -58
  4. package/Tab/TabTab.js +20 -40
  5. package/Tab/index.js +2 -10
  6. package/Tab/subComponent/TabContext.js +2 -5
  7. package/animate/Collapse.js +26 -53
  8. package/animate/Loader.js +21 -26
  9. package/animate/NumberCounter.js +22 -44
  10. package/animate/PulseRing.js +9 -21
  11. package/animate/Spinner.js +2 -10
  12. package/animate/index.js +5 -11
  13. package/backdrop/BaseBackdrop.js +2 -9
  14. package/backdrop/LoadingBackdrop.js +2 -9
  15. package/backdrop/ModalBackdrop.js +2 -9
  16. package/backdrop/index.js +3 -7
  17. package/badge/Badge.js +2 -11
  18. package/badge/BadgeDot.js +2 -10
  19. package/badge/BadgeFill.js +15 -20
  20. package/badge/BadgeWithText.js +6 -13
  21. package/badge/index.js +4 -9
  22. package/billing/BarChart.js +10 -17
  23. package/billing/Grid.js +11 -15
  24. package/billing/Header2.js +6 -9
  25. package/billing/Header3.js +9 -16
  26. package/billing/Paragraph.js +8 -14
  27. package/billing/ParagraphGroup.js +6 -9
  28. package/billing/ParagraphText.js +7 -12
  29. package/billing/Section.js +13 -23
  30. package/billing/SectionBody.js +5 -8
  31. package/billing/SectionHeader.js +7 -12
  32. package/breadcrumb/Breadcrumb.js +11 -21
  33. package/breadcrumb/index.js +1 -3
  34. package/button/Button.js +41 -38
  35. package/button/ButtonGroup.js +21 -18
  36. package/button/IconButton.js +29 -29
  37. package/button/ScrollToTopButton.js +12 -39
  38. package/button/index.js +4 -9
  39. package/callout/Callout.js +13 -26
  40. package/callout/index.js +1 -3
  41. package/chart/BarChart.js +28 -53
  42. package/chart/DoughnutChart.js +23 -62
  43. package/chart/LineChart.js +33 -55
  44. package/chart/SingleBarChart.js +11 -17
  45. package/chart/index.js +5 -12
  46. package/chart/utils/customTooltip.js +26 -43
  47. package/chart/utils/htmlLegendPlugin.js +24 -30
  48. package/chart/utils/index.js +3 -7
  49. package/chart/utils/padEmptyChartBar.js +24 -22
  50. package/container/FlexContainer.js +9 -12
  51. package/container/index.js +1 -3
  52. package/cropper/Cropper.js +21 -34
  53. package/cropper/CropperModalHandler.js +15 -21
  54. package/cropper/index.js +2 -5
  55. package/cropper/subComponent/CropImageModal.js +23 -58
  56. package/datetimePicker/DatePicker.js +103 -217
  57. package/datetimePicker/DatePickerV2.js +116 -221
  58. package/datetimePicker/DatetimePicker.js +27 -48
  59. package/datetimePicker/DatetimePickerV2.js +115 -231
  60. package/datetimePicker/TimeInput.js +9 -22
  61. package/datetimePicker/TimePicker.js +94 -151
  62. package/datetimePicker/TimePickerStyle.js +2 -9
  63. package/datetimePicker/accordion/Month.js +70 -90
  64. package/datetimePicker/accordion/Year.js +91 -135
  65. package/datetimePicker/hooks/index.js +3 -7
  66. package/datetimePicker/hooks/useChangeNumber.js +14 -27
  67. package/datetimePicker/hooks/useDecrease.js +19 -35
  68. package/datetimePicker/hooks/useIncrease.js +19 -35
  69. package/datetimePicker/index.js +7 -15
  70. package/datetimePicker/provider/constant.js +2 -3
  71. package/datetimePicker/subComponent/Accordion.js +108 -158
  72. package/datetimePicker/subComponent/CustomTimeInput.js +18 -48
  73. package/datetimePicker/subComponent/DateTimePickerContext.js +2 -5
  74. package/datetimePicker/utils/GMTDate.js +3 -7
  75. package/datetimePicker/utils/pad.js +2 -6
  76. package/datetimePicker/utils/toUTC0.js +3 -6
  77. package/descriptionList/DescriptionDetail.js +5 -10
  78. package/descriptionList/DescriptionList.js +5 -10
  79. package/descriptionList/DescriptionTerm.js +2 -9
  80. package/descriptionList/index.js +3 -7
  81. package/divider/Divider.js +9 -12
  82. package/divider/index.js +1 -3
  83. package/dropdown/Dropdown.js +28 -65
  84. package/dropdown/DropdownButtonOption.js +2 -9
  85. package/dropdown/DropdownContent.js +33 -64
  86. package/dropdown/DropdownDivOption.js +2 -9
  87. package/dropdown/DropdownItem.js +10 -16
  88. package/dropdown/DropdownLinkOption.js +2 -9
  89. package/dropdown/DropdownToggle.js +18 -38
  90. package/dropdown/index.js +6 -17
  91. package/dropdown/subComponent/DropdownContext.js +2 -5
  92. package/dropzone/FileDropzone.js +148 -302
  93. package/dropzone/ImageDropzone.js +96 -171
  94. package/dropzone/index.js +2 -5
  95. package/dropzone/subComponent/Message.js +7 -14
  96. package/figure/IconFigure.js +9 -16
  97. package/figure/ImageFigure.js +11 -17
  98. package/figure/index.js +2 -5
  99. package/file/HiddenFileInput.js +5 -14
  100. package/file/index.js +1 -3
  101. package/form/Checkbox.js +34 -43
  102. package/form/FormItem.js +2 -9
  103. package/form/Input.js +13 -15
  104. package/form/Label.js +10 -13
  105. package/form/MutedText.js +5 -10
  106. package/form/RadioButton.js +20 -32
  107. package/form/Searchbox.js +21 -65
  108. package/form/Slider.js +14 -0
  109. package/form/SwitchButton.js +34 -39
  110. package/form/Textarea.js +2 -11
  111. package/form/index.js +9 -19
  112. package/grid/Column.js +17 -17
  113. package/grid/Grid.js +13 -14
  114. package/grid/index.js +2 -5
  115. package/heading/Heading1.js +5 -10
  116. package/heading/Heading2.js +9 -12
  117. package/heading/Heading3.js +21 -18
  118. package/heading/index.js +3 -7
  119. package/helmet/Helmet.js +6 -9
  120. package/helmet/index.js +2 -5
  121. package/iconbox/ApplicationIconBox.js +25 -31
  122. package/iconbox/IconBox.js +11 -24
  123. package/iconbox/IconBoxV2.js +14 -26
  124. package/iconbox/index.js +3 -7
  125. package/iconbox/subComponent/IconBoxFigure.js +25 -20
  126. package/iconbox/subComponent/IconBoxImage.js +15 -18
  127. package/image/ImageFluid.js +2 -10
  128. package/image/UploadImage.js +65 -113
  129. package/image/index.js +2 -5
  130. package/index.js +44 -130
  131. package/jsoneditor/JsonEditor.js +10 -32
  132. package/jsoneditor/index.js +1 -3
  133. package/keyframe/Pulse.js +2 -7
  134. package/keyframe/Spin.js +2 -7
  135. package/link/LinkSpan.js +22 -35
  136. package/link/index.js +1 -3
  137. package/map/GoogleMap.js +122 -175
  138. package/map/GoogleReverseGeolocation.js +79 -186
  139. package/map/LeafletMap.js +78 -132
  140. package/map/LeafletReverseGeolocation.js +49 -121
  141. package/map/index.js +4 -9
  142. package/map/subComponent/BasicLeafletMap.js +8 -14
  143. package/map/subComponent/GoogleMapContainer.js +5 -10
  144. package/map/subComponent/GoogleMapPopup.js +66 -123
  145. package/map/subComponent/GoogleMapWrapper.js +13 -32
  146. package/map/subComponent/GoogleMarkerSpiderfier.js +14 -24
  147. package/map/subComponent/LeafletDrawControl.js +47 -84
  148. package/map/subComponent/LeafletMapContainer.js +5 -10
  149. package/map/subComponent/MapSearchBoxControl.js +24 -70
  150. package/modal/StateModal.js +41 -100
  151. package/modal/TitleModal.js +89 -190
  152. package/modal/index.js +2 -5
  153. package/package.json +1 -1
  154. package/paginate/Paginate.js +40 -54
  155. package/paginate/index.js +1 -3
  156. package/popover/Popover.js +39 -87
  157. package/popover/index.js +1 -3
  158. package/qrcode/QRCode.js +10 -23
  159. package/qrcode/QRCodeContainter.js +8 -16
  160. package/qrcode/index.js +2 -5
  161. package/ribbon/Ribbon.js +4 -15
  162. package/ribbon/index.js +1 -3
  163. package/section/Section.js +57 -39
  164. package/section/SectionBody.js +15 -22
  165. package/section/SectionHeader.js +27 -27
  166. package/section/SectionToolbar.js +2 -9
  167. package/section/SectionToolbarItem.js +2 -9
  168. package/section/index.js +5 -11
  169. package/select/InputSelect.js +103 -215
  170. package/select/Select.js +204 -362
  171. package/select/index.js +2 -5
  172. package/select/subComponent/ListBox.js +9 -12
  173. package/select/subComponent/Option.js +8 -16
  174. package/select/subComponent/OptionGroup.js +2 -9
  175. package/select/subComponent/Options.js +5 -11
  176. package/select/subComponent/SearchBox.js +9 -29
  177. package/select/subComponent/SelectedMultiple.js +8 -16
  178. package/select/subComponent/SelectedSingle.js +2 -9
  179. package/styles/GlobalStyle.js +169 -91
  180. package/styles/config/breakpoint.style.js +2 -3
  181. package/styles/config/header.style.js +2 -3
  182. package/styles/config/sidebar.style.js +2 -3
  183. package/styles/index.js +2 -5
  184. package/styles/mixin/backgroundColor.js +17 -14
  185. package/styles/mixin/borderColor.js +17 -14
  186. package/styles/mixin/color.js +17 -14
  187. package/styles/mixin/colorOnBackground.js +17 -14
  188. package/styles/mixin/inputPlaceholder.js +3 -9
  189. package/styles/mixin/media.js +3 -11
  190. package/styles/mixin/rounded.js +13 -12
  191. package/styles/mixin/scrollbar.js +7 -13
  192. package/styles/theme/dark.theme.js +20 -20
  193. package/styles/theme/light.theme.js +20 -20
  194. package/styles/theme/white.theme.js +20 -20
  195. package/styles/themes.js +2 -8
  196. package/table/GridTable.js +105 -143
  197. package/table/ImageBox.js +8 -18
  198. package/table/PermissionTable.js +25 -25
  199. package/table/Table.js +137 -153
  200. package/table/__mock__/columns.js +2 -3
  201. package/table/__mock__/data.js +2 -3
  202. package/table/hooks/index.js +2 -5
  203. package/table/hooks/useCalculateDataRange.js +9 -36
  204. package/table/hooks/useGenerateSort.js +6 -17
  205. package/table/index.js +4 -9
  206. package/table/subComponent/BaseTableHeadCell.js +15 -21
  207. package/table/subComponent/GridTableFooter.js +5 -10
  208. package/table/subComponent/GridTableHeadCell.js +5 -10
  209. package/table/subComponent/Resizer.js +17 -44
  210. package/table/subComponent/TableFooter.js +5 -10
  211. package/table/subComponent/TableFooterInfo.js +2 -9
  212. package/table/subComponent/TableFooterPager.js +5 -12
  213. package/table/subComponent/TableHeadCell.js +2 -9
  214. package/table/subComponent/TableSort.js +13 -19
  215. package/tagify/TagifyStyle.js +2 -9
  216. package/tagify/Tags.js +15 -37
  217. package/tagify/index.js +2 -5
  218. package/text/Paragraph.js +25 -20
  219. package/text/index.js +1 -3
  220. package/timeline/Timeline.js +28 -37
  221. package/timeline/index.js +1 -3
  222. package/toast/CustomToastContainer.js +2 -9
  223. package/toast/MessageContainer.js +9 -18
  224. package/toast/index.js +3 -8
  225. package/toast/show.js +18 -28
  226. package/tooltip/Tooltip.js +48 -97
  227. package/tooltip/index.js +1 -3
  228. package/wizard/Wizard.js +63 -133
  229. package/wizard/index.js +1 -3
package/chart/BarChart.js CHANGED
@@ -4,48 +4,28 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _react = require("react");
9
-
10
8
  var _styledComponents = require("styled-components");
11
-
12
9
  var _reactChartjs = require("react-chartjs-2");
13
-
14
10
  var _customTooltip = _interopRequireDefault(require("./utils/customTooltip"));
15
-
16
11
  var _padEmptyChartBar = _interopRequireDefault(require("./utils/padEmptyChartBar"));
17
-
18
12
  var _jsxRuntime = require("react/jsx-runtime");
19
-
20
- var _excluded = ["height", "data", "options"];
21
-
22
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
24
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
-
26
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
-
28
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
29
-
30
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
31
-
32
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
33
-
34
- var BarChart = function BarChart(_ref) {
35
- var _ref$height = _ref.height,
36
- height = _ref$height === void 0 ? 300 : _ref$height,
37
- data = _ref.data,
38
- _ref$options = _ref.options,
39
- options = _ref$options === void 0 ? {} : _ref$options,
40
- props = _objectWithoutProperties(_ref, _excluded);
41
-
42
- var theme = (0, _react.useContext)(_styledComponents.ThemeContext); // fix: read value from theme
43
-
14
+ const BarChart = _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
44
24
  _reactChartjs.defaults.font.family = theme.fontFamily;
45
25
  _reactChartjs.defaults.font.size = 16;
46
26
  _reactChartjs.defaults.color = theme.fontOnBg;
47
27
  _reactChartjs.defaults.plugins.tooltip.external = (0, _customTooltip.default)(theme);
48
- var customOptions = (0, _react.useMemo)(function () {
28
+ const customOptions = (0, _react.useMemo)(() => {
49
29
  return {
50
30
  onlyFirstTooltips: options.onlyFirstTooltips === undefined ? true : options.onlyFirstTooltips,
51
31
  maxBarNumber: options.maxBarNumber === undefined ? 5 : options.maxBarNumber,
@@ -55,7 +35,7 @@ var BarChart = function BarChart(_ref) {
55
35
  rotateLabel: options.rotateLabel === undefined ? true : options.rotateLabel
56
36
  };
57
37
  }, [options]);
58
- var defaultOptions = (0, _react.useMemo)(function () {
38
+ const defaultOptions = (0, _react.useMemo)(() => {
59
39
  return {
60
40
  responsive: true,
61
41
  maintainAspectRatio: false,
@@ -71,33 +51,30 @@ var BarChart = function BarChart(_ref) {
71
51
  tooltip: {
72
52
  enabled: false,
73
53
  intersect: false,
74
- filter: function filter(context) {
54
+ filter(context) {
75
55
  return !customOptions.onlyFirstTooltips || context.datasetIndex === 0 && context.label !== 'null';
76
56
  },
77
57
  callbacks: {
78
- title: function title(context) {
58
+ title(context) {
79
59
  return context[0] ? context[0].label.match(/(.{1,20})/g) : '';
80
60
  },
81
- label: function label(context) {
82
- var label = context.dataset.data[context.dataIndex];
83
-
61
+ label(context) {
62
+ const label = context.dataset.data[context.dataIndex];
84
63
  if (context.dataset.customLabel) {
85
64
  return context.dataset.customLabel[context.dataIndex].toString();
86
65
  }
87
-
88
66
  return label.toString();
89
67
  },
90
- labelTextColor: function labelTextColor(context) {
91
- var color = context.dataset.color;
92
-
68
+ labelTextColor(context) {
69
+ const {
70
+ color
71
+ } = context.dataset;
93
72
  if (!color) {
94
73
  return theme.fontOnPrimary;
95
74
  }
96
-
97
75
  if (color && Array.isArray(color)) {
98
76
  return color[context.dataIndex % color.length];
99
77
  }
100
-
101
78
  return color;
102
79
  }
103
80
  }
@@ -112,8 +89,8 @@ var BarChart = function BarChart(_ref) {
112
89
  },
113
90
  ticks: {
114
91
  minRotation: customOptions.rotateLabel ? 15 : 0,
115
- callback: function callback(value) {
116
- var label = this.getLabelForValue(value);
92
+ callback(value) {
93
+ const label = this.getLabelForValue(value);
117
94
  return label && label.length > 11 ? "".concat(label.substr(0, 11), "...") : label;
118
95
  }
119
96
  }
@@ -126,11 +103,10 @@ var BarChart = function BarChart(_ref) {
126
103
  drawBorder: false
127
104
  },
128
105
  ticks: {
129
- callback: function callback(value) {
106
+ callback(value) {
130
107
  if (value % 1 === 0) {
131
108
  return value;
132
109
  }
133
-
134
110
  return null;
135
111
  }
136
112
  }
@@ -138,13 +114,12 @@ var BarChart = function BarChart(_ref) {
138
114
  }
139
115
  };
140
116
  }, [customOptions, theme.fontOnPrimary]);
141
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Bar, _objectSpread({
117
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Bar, {
142
118
  height: height,
143
119
  data: data,
144
120
  options: defaultOptions,
145
- plugins: [_padEmptyChartBar.default]
146
- }, props));
121
+ plugins: [_padEmptyChartBar.default],
122
+ ...props
123
+ });
147
124
  };
148
-
149
- var _default = BarChart;
150
- exports.default = _default;
125
+ var _default = exports.default = BarChart;
@@ -4,64 +4,29 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _react = require("react");
9
-
10
8
  var _styledComponents = require("styled-components");
11
-
12
9
  var _reactChartjs = require("react-chartjs-2");
13
-
14
10
  var _lodash = _interopRequireDefault(require("lodash.uniqueid"));
15
-
16
11
  var _htmlLegendPlugin = _interopRequireDefault(require("./utils/htmlLegendPlugin"));
17
-
18
12
  var _customTooltip = _interopRequireDefault(require("./utils/customTooltip"));
19
-
20
13
  var _jsxRuntime = require("react/jsx-runtime");
21
-
22
- var _excluded = ["height", "data"];
23
-
24
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
-
28
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
-
30
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
31
-
32
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
33
-
34
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
35
-
36
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
37
-
38
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
39
-
40
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
41
-
42
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
43
-
44
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
45
-
46
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
47
-
48
- var DoughnutChart = function DoughnutChart(_ref) {
49
- var _ref$height = _ref.height,
50
- height = _ref$height === void 0 ? 300 : _ref$height,
51
- data = _ref.data,
52
- props = _objectWithoutProperties(_ref, _excluded);
53
-
54
- var _useState = (0, _react.useState)((0, _lodash.default)('legend-container-')),
55
- _useState2 = _slicedToArray(_useState, 1),
56
- legendContainerId = _useState2[0];
57
-
58
- var theme = (0, _react.useContext)(_styledComponents.ThemeContext); // fix: read value from theme
59
-
15
+ const DoughnutChart = _ref => {
16
+ let {
17
+ height = 300,
18
+ data,
19
+ ...props
20
+ } = _ref;
21
+ const [legendContainerId] = (0, _react.useState)((0, _lodash.default)('legend-container-'));
22
+ const theme = (0, _react.useContext)(_styledComponents.ThemeContext);
23
+
24
+ // fix: read value from theme
60
25
  _reactChartjs.defaults.font.family = theme.fontFamily;
61
26
  _reactChartjs.defaults.font.size = 16;
62
27
  _reactChartjs.defaults.color = theme.fontOnBg;
63
28
  _reactChartjs.defaults.plugins.tooltip.external = (0, _customTooltip.default)(theme);
64
- var defaultOptions = (0, _react.useMemo)(function () {
29
+ const defaultOptions = (0, _react.useMemo)(() => {
65
30
  return {
66
31
  responsive: true,
67
32
  maintainAspectRatio: false,
@@ -76,29 +41,26 @@ var DoughnutChart = function DoughnutChart(_ref) {
76
41
  tooltip: {
77
42
  enabled: false,
78
43
  callbacks: {
79
- title: function title(context) {
44
+ title(context) {
80
45
  return context[0] ? context[0].label.match(/(.{1,20})/g) : '';
81
46
  },
82
- label: function label(context) {
83
- var label = context.dataset.data[context.dataIndex];
84
-
47
+ label(context) {
48
+ const label = context.dataset.data[context.dataIndex];
85
49
  if (context.dataset.customLabel) {
86
50
  return context.dataset.customLabel[context.dataIndex].toString();
87
51
  }
88
-
89
52
  return label.toString();
90
53
  },
91
- labelTextColor: function labelTextColor(context) {
92
- var color = context.dataset.color;
93
-
54
+ labelTextColor(context) {
55
+ const {
56
+ color
57
+ } = context.dataset;
94
58
  if (!color) {
95
59
  return theme.fontOnPrimary;
96
60
  }
97
-
98
61
  if (color && Array.isArray(color)) {
99
62
  return color[context.dataIndex % color.length];
100
63
  }
101
-
102
64
  return color;
103
65
  }
104
66
  }
@@ -108,17 +70,16 @@ var DoughnutChart = function DoughnutChart(_ref) {
108
70
  }, [legendContainerId, theme.fontOnPrimary]);
109
71
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
110
72
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
111
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Doughnut, _objectSpread({
73
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Doughnut, {
112
74
  height: height,
113
75
  data: data,
114
76
  options: defaultOptions,
115
- plugins: [_htmlLegendPlugin.default]
116
- }, props))
77
+ plugins: [_htmlLegendPlugin.default],
78
+ ...props
79
+ })
117
80
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
118
81
  id: legendContainerId
119
82
  })]
120
83
  });
121
84
  };
122
-
123
- var _default = DoughnutChart;
124
- exports.default = _default;
85
+ var _default = exports.default = DoughnutChart;
@@ -4,60 +4,39 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _react = require("react");
9
-
10
8
  var _styledComponents = require("styled-components");
11
-
12
9
  var _reactChartjs = require("react-chartjs-2");
13
-
14
10
  var _customTooltip = _interopRequireDefault(require("./utils/customTooltip"));
15
-
16
11
  var _jsxRuntime = require("react/jsx-runtime");
17
-
18
- var _excluded = ["height", "data", "options"];
19
-
20
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
-
24
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
25
-
26
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
-
28
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
29
-
30
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
31
-
32
- var LineChart = function LineChart(_ref) {
33
- var _ref$height = _ref.height,
34
- height = _ref$height === void 0 ? 300 : _ref$height,
35
- data = _ref.data,
36
- _ref$options = _ref.options,
37
- options = _ref$options === void 0 ? {} : _ref$options,
38
- props = _objectWithoutProperties(_ref, _excluded);
39
-
40
- var theme = (0, _react.useContext)(_styledComponents.ThemeContext); // fix: read value from theme
41
-
13
+ const LineChart = _ref => {
14
+ let {
15
+ height = 300,
16
+ data,
17
+ options = {},
18
+ ...props
19
+ } = _ref;
20
+ const theme = (0, _react.useContext)(_styledComponents.ThemeContext);
21
+
22
+ // fix: read value from theme
42
23
  _reactChartjs.defaults.font.family = theme.fontFamily;
43
24
  _reactChartjs.defaults.font.size = 16;
44
25
  _reactChartjs.defaults.color = theme.fontOnBg;
45
26
  _reactChartjs.defaults.plugins.tooltip.external = (0, _customTooltip.default)(theme);
46
- var customOptions = (0, _react.useMemo)(function () {
27
+ const customOptions = (0, _react.useMemo)(() => {
47
28
  return {
48
29
  suggestedMax: options.suggestedMax ? options.suggestedMax : 10,
49
30
  tooltipTitlePrefix: '',
50
31
  tooltipLabelPrefix: ''
51
32
  };
52
33
  }, [options]);
53
-
54
34
  if (options.tooltips) {
55
- var tooltipsOptions = options.tooltips;
35
+ const tooltipsOptions = options.tooltips;
56
36
  customOptions.tooltipTitlePrefix = tooltipsOptions.titlePrefix || '';
57
37
  customOptions.tooltipLabelPrefix = tooltipsOptions.labelPrefix || '';
58
38
  }
59
-
60
- var defaultOptions = (0, _react.useMemo)(function () {
39
+ const defaultOptions = (0, _react.useMemo)(() => {
61
40
  return {
62
41
  responsive: true,
63
42
  maintainAspectRatio: false,
@@ -69,36 +48,37 @@ var LineChart = function LineChart(_ref) {
69
48
  tooltip: {
70
49
  enabled: false,
71
50
  intersect: false,
72
- filter: function filter(context) {
51
+ filter(context) {
73
52
  return context.datasetIndex === 0 && context.label !== 'null';
74
53
  },
75
54
  callbacks: {
76
- title: function title(context) {
77
- var content = context[0] ? context[0].label.match(/(.{1,20})/g) : '';
55
+ title(context) {
56
+ const content = context[0] ? context[0].label.match(/(.{1,20})/g) : '';
78
57
  return "".concat(customOptions.tooltipTitlePrefix).concat(content);
79
58
  },
80
- label: function label(context) {
81
- var content = context.dataset.data[context.dataIndex].toString();
59
+ label(context) {
60
+ const content = context.dataset.data[context.dataIndex].toString();
82
61
  return "".concat(customOptions.tooltipLabelPrefix).concat(content);
83
62
  },
84
- labelColor: function labelColor(context) {
85
- var borderColor = context.dataset.borderColor;
63
+ labelColor(context) {
64
+ const {
65
+ borderColor
66
+ } = context.dataset;
86
67
  return {
87
- borderColor: borderColor,
68
+ borderColor,
88
69
  backgroundColor: borderColor
89
70
  };
90
71
  },
91
- labelTextColor: function labelTextColor(context) {
92
- var color = context.dataset.color;
93
-
72
+ labelTextColor(context) {
73
+ const {
74
+ color
75
+ } = context.dataset;
94
76
  if (!color) {
95
77
  return theme.fontOnPrimary;
96
78
  }
97
-
98
79
  if (color && Array.isArray(color)) {
99
80
  return color[context.dataIndex % color.length];
100
81
  }
101
-
102
82
  return color;
103
83
  }
104
84
  }
@@ -119,11 +99,10 @@ var LineChart = function LineChart(_ref) {
119
99
  drawBorder: false
120
100
  },
121
101
  ticks: {
122
- callback: function callback(value) {
102
+ callback(value) {
123
103
  if (value % 1 === 0) {
124
104
  return value;
125
105
  }
126
-
127
106
  return null;
128
107
  }
129
108
  }
@@ -131,12 +110,11 @@ var LineChart = function LineChart(_ref) {
131
110
  }
132
111
  };
133
112
  }, [customOptions, theme.fontOnPrimary]);
134
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Line, _objectSpread({
113
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Line, {
135
114
  height: height,
136
115
  data: data,
137
- options: defaultOptions
138
- }, props));
116
+ options: defaultOptions,
117
+ ...props
118
+ });
139
119
  };
140
-
141
- var _default = LineChart;
142
- exports.default = _default;
120
+ var _default = exports.default = LineChart;
@@ -4,28 +4,22 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _styledComponents = _interopRequireDefault(require("styled-components"));
9
-
10
8
  var _backgroundColor = _interopRequireDefault(require("../styles/mixin/backgroundColor"));
11
-
12
9
  var _templateObject;
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
17
-
18
- var SingleBarChart = _styledComponents.default.div.attrs(function () {
19
- return {
20
- primary: true
21
- };
22
- })(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n width: 100%;\n height: 1rem;\n border-radius: var(--border-radius);\n background: var(--color-background3);\n\n &::before {\n position: absolute;\n content: '';\n width: ", "%;\n border-radius: var(--border-radius);\n top: 0;\n bottom: 0;\n\n ", "\n }\n\n ", "\n"])), function (_ref) {
23
- var percentage = _ref.percentage;
12
+ const SingleBarChart = _styledComponents.default.div.attrs(() => ({
13
+ primary: true
14
+ }))(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n width: 100%;\n height: 1rem;\n border-radius: var(--border-radius);\n background: var(--color-background3);\n\n &::before {\n position: absolute;\n content: '';\n width: ", "%;\n border-radius: var(--border-radius);\n top: 0;\n bottom: 0;\n\n ", "\n }\n\n ", "\n"])), _ref => {
15
+ let {
16
+ percentage
17
+ } = _ref;
24
18
  return percentage;
25
- }, _backgroundColor.default, function (_ref2) {
26
- var marginTop = _ref2.marginTop;
19
+ }, _backgroundColor.default, _ref2 => {
20
+ let {
21
+ marginTop
22
+ } = _ref2;
27
23
  return marginTop && 'margin-top: var(--spacing-s)';
28
24
  });
29
-
30
- var _default = SingleBarChart;
31
- exports.default = _default;
25
+ var _default = exports.default = SingleBarChart;
package/chart/index.js CHANGED
@@ -11,49 +11,42 @@ var _exportNames = {
11
11
  };
12
12
  Object.defineProperty(exports, "BarChart", {
13
13
  enumerable: true,
14
- get: function get() {
14
+ get: function () {
15
15
  return _BarChart.default;
16
16
  }
17
17
  });
18
18
  Object.defineProperty(exports, "DoughnutChart", {
19
19
  enumerable: true,
20
- get: function get() {
20
+ get: function () {
21
21
  return _DoughnutChart.default;
22
22
  }
23
23
  });
24
24
  Object.defineProperty(exports, "LineChart", {
25
25
  enumerable: true,
26
- get: function get() {
26
+ get: function () {
27
27
  return _LineChart.default;
28
28
  }
29
29
  });
30
30
  Object.defineProperty(exports, "SingleBarChart", {
31
31
  enumerable: true,
32
- get: function get() {
32
+ get: function () {
33
33
  return _SingleBarChart.default;
34
34
  }
35
35
  });
36
-
37
36
  var _BarChart = _interopRequireDefault(require("./BarChart"));
38
-
39
37
  var _DoughnutChart = _interopRequireDefault(require("./DoughnutChart"));
40
-
41
38
  var _LineChart = _interopRequireDefault(require("./LineChart"));
42
-
43
39
  var _SingleBarChart = _interopRequireDefault(require("./SingleBarChart"));
44
-
45
40
  var _utils = require("./utils");
46
-
47
41
  Object.keys(_utils).forEach(function (key) {
48
42
  if (key === "default" || key === "__esModule") return;
49
43
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
50
44
  if (key in exports && exports[key] === _utils[key]) return;
51
45
  Object.defineProperty(exports, key, {
52
46
  enumerable: true,
53
- get: function get() {
47
+ get: function () {
54
48
  return _utils[key];
55
49
  }
56
50
  });
57
51
  });
58
-
59
52
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }