@cashub/ui 0.13.2 → 0.13.4

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.
package/chart/BarChart.js CHANGED
@@ -17,14 +17,28 @@ var _padEmptyChartBar = _interopRequireDefault(require("./utils/padEmptyChartBar
17
17
 
18
18
  var _jsxRuntime = require("react/jsx-runtime");
19
19
 
20
+ var _excluded = ["height", "data", "options"];
21
+
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
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
+
22
34
  var BarChart = function BarChart(_ref) {
23
35
  var _ref$height = _ref.height,
24
36
  height = _ref$height === void 0 ? 300 : _ref$height,
25
37
  data = _ref.data,
26
38
  _ref$options = _ref.options,
27
- options = _ref$options === void 0 ? {} : _ref$options;
39
+ options = _ref$options === void 0 ? {} : _ref$options,
40
+ props = _objectWithoutProperties(_ref, _excluded);
41
+
28
42
  var theme = (0, _react.useContext)(_styledComponents.ThemeContext); // fix: read value from theme
29
43
 
30
44
  _reactChartjs.defaults.font.family = theme.fontFamily;
@@ -73,8 +87,18 @@ var BarChart = function BarChart(_ref) {
73
87
 
74
88
  return label.toString();
75
89
  },
76
- labelTextColor: function labelTextColor() {
77
- return theme.fontOnPrimary;
90
+ labelTextColor: function labelTextColor(context) {
91
+ var color = context.dataset.color;
92
+
93
+ if (!color) {
94
+ return theme.fontOnPrimary;
95
+ }
96
+
97
+ if (color && Array.isArray(color)) {
98
+ return color[context.dataIndex % color.length];
99
+ }
100
+
101
+ return color;
78
102
  }
79
103
  }
80
104
  }
@@ -114,16 +138,12 @@ var BarChart = function BarChart(_ref) {
114
138
  }
115
139
  };
116
140
  }, [customOptions, theme.fontOnPrimary]);
117
- console.log('defaultOptions', defaultOptions);
118
- var Chart = (0, _react.useMemo)(function () {
119
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Bar, {
120
- height: height,
121
- data: data,
122
- options: defaultOptions,
123
- plugins: [_padEmptyChartBar.default]
124
- });
125
- }, [height, data, defaultOptions]);
126
- return Chart;
141
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Bar, _objectSpread({
142
+ height: height,
143
+ data: data,
144
+ options: defaultOptions,
145
+ plugins: [_padEmptyChartBar.default]
146
+ }, props));
127
147
  };
128
148
 
129
149
  var _default = BarChart;
@@ -15,12 +15,26 @@ var _customTooltip = _interopRequireDefault(require("./utils/customTooltip"));
15
15
 
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
 
18
+ var _excluded = ["height", "data"];
19
+
18
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
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
+
20
32
  var DoughnutChart = function DoughnutChart(_ref) {
21
33
  var _ref$height = _ref.height,
22
34
  height = _ref$height === void 0 ? 300 : _ref$height,
23
- data = _ref.data;
35
+ data = _ref.data,
36
+ props = _objectWithoutProperties(_ref, _excluded);
37
+
24
38
  var theme = (0, _react.useContext)(_styledComponents.ThemeContext); // fix: read value from theme
25
39
 
26
40
  _reactChartjs.defaults.font.family = theme.fontFamily;
@@ -40,19 +54,31 @@ var DoughnutChart = function DoughnutChart(_ref) {
40
54
  }
41
55
  },
42
56
  tooltip: {
43
- enabled: false
57
+ enabled: false,
58
+ callbacks: {
59
+ labelTextColor: function labelTextColor(context) {
60
+ var color = context.dataset.color;
61
+
62
+ if (!color) {
63
+ return theme.fontOnPrimary;
64
+ }
65
+
66
+ if (color && Array.isArray(color)) {
67
+ return color[context.dataIndex % color.length];
68
+ }
69
+
70
+ return color;
71
+ }
72
+ }
44
73
  }
45
74
  }
46
75
  };
47
- }, []);
48
- var Chart = (0, _react.useMemo)(function () {
49
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Doughnut, {
50
- height: height,
51
- data: data,
52
- options: defaultOptions
53
- });
54
- }, [height, data, defaultOptions]);
55
- return Chart;
76
+ }, [theme.fontOnPrimary]);
77
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Doughnut, _objectSpread({
78
+ height: height,
79
+ data: data,
80
+ options: defaultOptions
81
+ }, props));
56
82
  };
57
83
 
58
84
  var _default = DoughnutChart;
@@ -15,14 +15,28 @@ var _customTooltip = _interopRequireDefault(require("./utils/customTooltip"));
15
15
 
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
 
18
+ var _excluded = ["height", "data", "options"];
19
+
18
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
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
+
20
32
  var LineChart = function LineChart(_ref) {
21
33
  var _ref$height = _ref.height,
22
34
  height = _ref$height === void 0 ? 300 : _ref$height,
23
35
  data = _ref.data,
24
36
  _ref$options = _ref.options,
25
- options = _ref$options === void 0 ? {} : _ref$options;
37
+ options = _ref$options === void 0 ? {} : _ref$options,
38
+ props = _objectWithoutProperties(_ref, _excluded);
39
+
26
40
  var theme = (0, _react.useContext)(_styledComponents.ThemeContext); // fix: read value from theme
27
41
 
28
42
  _reactChartjs.defaults.font.family = theme.fontFamily;
@@ -74,8 +88,18 @@ var LineChart = function LineChart(_ref) {
74
88
  backgroundColor: borderColor
75
89
  };
76
90
  },
77
- labelTextColor: function labelTextColor() {
78
- return theme.fontOnPrimary;
91
+ labelTextColor: function labelTextColor(context) {
92
+ var color = context.dataset.color;
93
+
94
+ if (!color) {
95
+ return theme.fontOnPrimary;
96
+ }
97
+
98
+ if (color && Array.isArray(color)) {
99
+ return color[context.dataIndex % color.length];
100
+ }
101
+
102
+ return color;
79
103
  }
80
104
  }
81
105
  }
@@ -107,14 +131,11 @@ var LineChart = function LineChart(_ref) {
107
131
  }
108
132
  };
109
133
  }, [customOptions, theme.fontOnPrimary]);
110
- var Chart = (0, _react.useMemo)(function () {
111
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Line, {
112
- height: height,
113
- data: data,
114
- options: defaultOptions
115
- });
116
- }, [height, data, defaultOptions]);
117
- return Chart;
134
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactChartjs.Line, _objectSpread({
135
+ height: height,
136
+ data: data,
137
+ options: defaultOptions
138
+ }, props));
118
139
  };
119
140
 
120
141
  var _default = LineChart;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cashub/ui",
3
- "version": "0.13.2",
3
+ "version": "0.13.4",
4
4
  "private": false,
5
5
  "author": "CASHUB Team",
6
6
  "description": "CASHUB UI components library",