pixelize-design-library 2.2.145 → 2.2.146

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 (29) hide show
  1. package/dist/Components/Apexcharts/ApexBarChart/ApexBarChart.js +72 -18
  2. package/dist/Components/Apexcharts/ApexLineChart/ApexLineChart.js +37 -26
  3. package/dist/Components/Apexcharts/ApexPieChart/ApexPieChart.js +168 -121
  4. package/dist/Components/Apexcharts/ApexPolarCharts/ApexPolarCharts.js +93 -44
  5. package/dist/Components/Common/ErrorComponent.d.ts +2 -2
  6. package/dist/Components/Common/ErrorComponent.js +12 -6
  7. package/dist/Components/Common/Label.d.ts +2 -2
  8. package/dist/Components/Common/Label.js +8 -2
  9. package/dist/Components/DatePicker/CalendarPanel.js +2 -2
  10. package/dist/Components/FilterSidebar/FilterSidebar.js +8 -6
  11. package/dist/Components/Input/Input/Input.d.ts +1 -1
  12. package/dist/Components/Input/Input/Input.js +29 -6
  13. package/dist/Components/Loading/Loading.js +4 -2
  14. package/dist/Components/PinInputs/PinInputs.d.ts +2 -2
  15. package/dist/Components/PinInputs/PinInputs.js +19 -4
  16. package/dist/Components/ProductCard/ProductPrice.js +2 -2
  17. package/dist/Components/ProductCard/ProductTags.js +7 -3
  18. package/dist/Components/ProfileCard/ProfileCard.js +8 -4
  19. package/dist/Components/ProfilePhotoViewer/ProfilePhotoViewer.js +4 -4
  20. package/dist/Components/SelectSearch/SelectSearch.js +14 -4
  21. package/dist/Components/Table/Components/TableHeader.js +3 -3
  22. package/dist/Components/Table/LeftFilterPane.js +5 -5
  23. package/dist/Components/Timeline/Timeline.js +15 -15
  24. package/dist/Components/Trail/TrailWorks.js +13 -206
  25. package/dist/Theme/chartColorsFromTheme.d.ts +18 -0
  26. package/dist/Theme/chartColorsFromTheme.js +39 -0
  27. package/dist/Theme/chartColorsFromTheme.test.d.ts +1 -0
  28. package/dist/Theme/chartColorsFromTheme.test.js +35 -0
  29. package/package.json +1 -1
@@ -1,23 +1,68 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
2
46
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
47
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
48
  };
5
49
  Object.defineProperty(exports, "__esModule", { value: true });
6
50
  exports.default = ApexBarChart;
7
- var react_1 = __importDefault(require("react"));
51
+ var react_1 = __importStar(require("react"));
8
52
  var react_apexcharts_1 = __importDefault(require("react-apexcharts"));
53
+ var react_2 = require("@chakra-ui/react");
54
+ var chartColorsFromTheme_1 = require("../../../Theme/chartColorsFromTheme");
9
55
  function ApexBarChart(_a) {
10
- var data = _a.data, labels = _a.labels, title = _a.title, titlePosition = _a.titlePosition, _b = _a.height, height = _b === void 0 ? 400 : _b, _c = _a.width, width = _c === void 0 ? 500 : _c, _d = _a.barColor, barColor = _d === void 0 ? ["#3182ce"] : _d, _e = _a.xAxisStyle, xAxisStyle = _e === void 0 ? {
11
- color: "#ffffff",
12
- } : _e, _f = _a.yAxisStyle, yAxisStyle = _f === void 0 ? {
13
- color: "#ffffff",
14
- } : _f, _g = _a.titleStyle, titleStyle = _g === void 0 ? {
15
- color: "#3182ce",
16
- fontSize: "16px",
17
- fontWeight: 600,
18
- fontFamily: "Arial",
19
- } : _g;
20
- var options = {
56
+ var data = _a.data, labels = _a.labels, title = _a.title, titlePosition = _a.titlePosition, _b = _a.height, height = _b === void 0 ? 400 : _b, _c = _a.width, width = _c === void 0 ? 500 : _c, barColor = _a.barColor, xAxisStyle = _a.xAxisStyle, yAxisStyle = _a.yAxisStyle, titleStyle = _a.titleStyle;
57
+ var theme = (0, react_2.useTheme)();
58
+ var palette = theme.colors;
59
+ var resolvedBarColors = barColor !== null && barColor !== void 0 ? barColor : [(0, chartColorsFromTheme_1.getDefaultSeriesColors)(palette)[0]];
60
+ var axisColor = (0, chartColorsFromTheme_1.chartAxisLabelColor)(palette);
61
+ var mergedXAxis = (0, react_1.useMemo)(function () { var _a; return (__assign(__assign({}, xAxisStyle), { color: (_a = xAxisStyle === null || xAxisStyle === void 0 ? void 0 : xAxisStyle.color) !== null && _a !== void 0 ? _a : axisColor })); }, [axisColor, xAxisStyle]);
62
+ var mergedYAxis = (0, react_1.useMemo)(function () { var _a; return (__assign(__assign({}, yAxisStyle), { color: (_a = yAxisStyle === null || yAxisStyle === void 0 ? void 0 : yAxisStyle.color) !== null && _a !== void 0 ? _a : axisColor })); }, [axisColor, yAxisStyle]);
63
+ var mergedTitleStyle = (0, react_1.useMemo)(function () { return (0, chartColorsFromTheme_1.mergeChartTitleStyle)(palette, titleStyle); }, [palette, titleStyle]);
64
+ var dataLabelColor = palette.primary[500];
65
+ var options = (0, react_1.useMemo)(function () { return ({
21
66
  chart: {
22
67
  type: "bar",
23
68
  height: 350,
@@ -32,27 +77,36 @@ function ApexBarChart(_a) {
32
77
  enabled: false,
33
78
  style: {
34
79
  fontSize: "12px",
35
- colors: ["#00E396"], //data label color
80
+ colors: [dataLabelColor],
36
81
  },
37
82
  },
38
83
  xaxis: {
39
84
  categories: labels,
40
85
  labels: {
41
- style: xAxisStyle,
86
+ style: mergedXAxis,
42
87
  },
43
88
  },
44
89
  yaxis: {
45
90
  labels: {
46
- style: yAxisStyle,
91
+ style: mergedYAxis,
47
92
  },
48
93
  },
49
94
  title: {
50
95
  text: title,
51
96
  align: titlePosition,
52
- style: titleStyle,
97
+ style: mergedTitleStyle,
53
98
  },
54
- colors: barColor, //bar color
55
- };
99
+ colors: resolvedBarColors,
100
+ }); }, [
101
+ labels,
102
+ mergedXAxis,
103
+ mergedYAxis,
104
+ title,
105
+ titlePosition,
106
+ mergedTitleStyle,
107
+ resolvedBarColors,
108
+ dataLabelColor,
109
+ ]);
56
110
  var series = [
57
111
  {
58
112
  name: "Data",
@@ -47,29 +47,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
48
  var react_1 = __importStar(require("react"));
49
49
  var react_apexcharts_1 = __importDefault(require("react-apexcharts"));
50
+ var react_2 = require("@chakra-ui/react");
50
51
  var ToolTip_1 = __importDefault(require("../../ToolTip/ToolTip"));
52
+ var chartColorsFromTheme_1 = require("../../../Theme/chartColorsFromTheme");
51
53
  var ApexLineChart = function (_a) {
52
- var data = _a.data, labels = _a.labels, title = _a.title, height = _a.height, width = _a.width, _b = _a.lineColors, lineColors = _b === void 0 ? ["#3182ce", "#e53e3e", "#38a169"] : _b, _c = _a.titlePosition, titlePosition = _c === void 0 ? "center" : _c, _d = _a.titleStyle, titleStyle = _d === void 0 ? {
53
- color: "#3182ce",
54
- fontSize: "16px",
55
- fontWeight: 600,
56
- fontFamily: "Arial",
57
- } : _d, _e = _a.compact, compact = _e === void 0 ? false : _e, _f = _a.toolbarBreakpointPct, toolbarBreakpointPct = _f === void 0 ? 0.6 : _f, titleClampLines = _a.titleClampLines, _g = _a.showTitleEllipsis, showTitleEllipsis = _g === void 0 ? true : _g, _h = _a.showSeries, showSeries = _h === void 0 ? true : _h, seriesNames = _a.series, _j = _a.variant, variant = _j === void 0 ? "basic" : _j;
54
+ var data = _a.data, labels = _a.labels, title = _a.title, height = _a.height, width = _a.width, lineColors = _a.lineColors, _b = _a.titlePosition, titlePosition = _b === void 0 ? "center" : _b, titleStyle = _a.titleStyle, _c = _a.compact, compact = _c === void 0 ? false : _c, _d = _a.toolbarBreakpointPct, toolbarBreakpointPct = _d === void 0 ? 0.6 : _d, titleClampLines = _a.titleClampLines, _e = _a.showTitleEllipsis, showTitleEllipsis = _e === void 0 ? true : _e, _f = _a.showSeries, showSeries = _f === void 0 ? true : _f, seriesNames = _a.series, _g = _a.variant, variant = _g === void 0 ? "basic" : _g;
55
+ var theme = (0, react_2.useTheme)();
56
+ var palette = theme.colors;
57
+ var resolvedLineColors = lineColors !== null && lineColors !== void 0 ? lineColors : (0, chartColorsFromTheme_1.getDefaultSeriesColors)(palette);
58
+ var resolvedTitleStyle = (0, react_1.useMemo)(function () { return (0, chartColorsFromTheme_1.mergeChartTitleStyle)(palette, titleStyle); }, [palette, titleStyle]);
58
59
  var initialName = Array.isArray(seriesNames) && seriesNames.length ? seriesNames[0] : "Series 1";
59
- var _k = (0, react_1.useState)([
60
+ var _h = (0, react_1.useState)([
60
61
  {
61
62
  name: initialName,
62
63
  data: Array.isArray(data) ? data : [],
63
64
  },
64
- ]), apexSeries = _k[0], setApexSeries = _k[1];
65
+ ]), apexSeries = _h[0], setApexSeries = _h[1];
65
66
  (0, react_1.useEffect)(function () {
66
67
  if (variant === "realtime") {
67
68
  var interval_1 = setInterval(function () {
68
69
  setApexSeries(function (prev) {
69
70
  var newData = __spreadArray([], prev[0].data, true);
70
- newData.push(Math.floor(Math.random() * 100) + 10); // simulate
71
+ newData.push(Math.floor(Math.random() * 100) + 10);
71
72
  if (newData.length > 20)
72
- newData.shift(); // keep window size
73
+ newData.shift();
73
74
  return [{ name: prev[0].name, data: newData }];
74
75
  });
75
76
  }, 1000);
@@ -77,7 +78,7 @@ var ApexLineChart = function (_a) {
77
78
  }
78
79
  }, [variant]);
79
80
  var wrapperRef = (0, react_1.useRef)(null);
80
- var _l = (0, react_1.useState)(0), containerW = _l[0], setContainerW = _l[1];
81
+ var _j = (0, react_1.useState)(0), containerW = _j[0], setContainerW = _j[1];
81
82
  (0, react_1.useEffect)(function () {
82
83
  if (!wrapperRef.current)
83
84
  return;
@@ -90,7 +91,7 @@ var ApexLineChart = function (_a) {
90
91
  return function () { return ro.disconnect(); };
91
92
  }, []);
92
93
  var parsePercent = function (v) {
93
- var n = parseFloat(v.replace('%', ''));
94
+ var n = parseFloat(v.replace("%", ""));
94
95
  return isNaN(n) ? 0 : n / 100;
95
96
  };
96
97
  var chartW = typeof width === "number"
@@ -98,17 +99,15 @@ var ApexLineChart = function (_a) {
98
99
  : typeof width === "string" && width.trim().endsWith("%")
99
100
  ? containerW * parsePercent(width.trim())
100
101
  : containerW;
101
- var hNum = typeof height === "number"
102
- ? height
103
- : 0;
102
+ var hNum = typeof height === "number" ? height : 0;
104
103
  var isSmall = compact || (chartW > 0 && chartW < 280) || (hNum > 0 && hNum < 220);
105
- var computedFontSize = (titleStyle === null || titleStyle === void 0 ? void 0 : titleStyle.fontSize) ||
104
+ var computedFontSize = (resolvedTitleStyle === null || resolvedTitleStyle === void 0 ? void 0 : resolvedTitleStyle.fontSize) ||
106
105
  (chartW
107
106
  ? "".concat(Math.max(12, Math.min(18, Math.floor(chartW / 18))), "px")
108
107
  : "14px");
109
108
  var clampLines = titleClampLines !== null && titleClampLines !== void 0 ? titleClampLines : (isSmall ? 2 : 1);
110
109
  var titleRef = (0, react_1.useRef)(null);
111
- var _m = (0, react_1.useState)(false), isTruncated = _m[0], setIsTruncated = _m[1];
110
+ var _k = (0, react_1.useState)(false), isTruncated = _k[0], setIsTruncated = _k[1];
112
111
  (0, react_1.useEffect)(function () {
113
112
  var el = titleRef.current;
114
113
  if (!el)
@@ -126,7 +125,7 @@ var ApexLineChart = function (_a) {
126
125
  ? parsePercent(width.trim())
127
126
  : 1;
128
127
  var showToolbar = !isSmall && ratio >= toolbarBreakpointPct;
129
- var options = {
128
+ var options = (0, react_1.useMemo)(function () { return ({
130
129
  chart: {
131
130
  type: "line",
132
131
  animations: variant === "realtime"
@@ -140,31 +139,43 @@ var ApexLineChart = function (_a) {
140
139
  toolbar: { show: showToolbar },
141
140
  },
142
141
  stroke: { curve: "smooth" },
143
- colors: lineColors,
142
+ colors: resolvedLineColors,
144
143
  xaxis: labels
145
144
  ? { categories: labels }
146
145
  : { type: variant === "realtime" ? "numeric" : "category" },
147
146
  title: {
148
147
  text: isSmall ? undefined : title,
149
148
  align: titlePosition !== null && titlePosition !== void 0 ? titlePosition : "center",
150
- style: titleStyle,
149
+ style: resolvedTitleStyle,
151
150
  },
152
151
  tooltip: {
153
- enabled: !!showSeries, // 👈 THIS is the key
152
+ enabled: !!showSeries,
154
153
  marker: { show: !!showSeries },
155
154
  },
156
155
  markers: { size: showSeries ? 4 : 0, hover: { size: showSeries ? 4 : 0 } },
157
156
  dataLabels: { enabled: false },
158
157
  grid: { padding: { top: isSmall ? 6 : 16, right: 8, left: 8 } },
159
- };
158
+ }); }, [
159
+ variant,
160
+ showToolbar,
161
+ resolvedLineColors,
162
+ labels,
163
+ isSmall,
164
+ title,
165
+ titlePosition,
166
+ resolvedTitleStyle,
167
+ showSeries,
168
+ ]);
169
+ var tooltipBg = (0, chartColorsFromTheme_1.chartTooltipBackground)(palette);
170
+ var tooltipFg = (0, chartColorsFromTheme_1.chartTooltipForeground)(palette);
160
171
  return (react_1.default.createElement("div", { ref: wrapperRef },
161
- title && isSmall && (react_1.default.createElement(ToolTip_1.default, { label: title, placement: "top", hasArrow: true, fontSize: "0.75rem", bg: "#4A5568", color: "#fff", isDisabled: !isTruncated },
172
+ title && isSmall && (react_1.default.createElement(ToolTip_1.default, { label: title, placement: "top", hasArrow: true, fontSize: "0.75rem", bg: tooltipBg, color: tooltipFg, isDisabled: !isTruncated },
162
173
  react_1.default.createElement("div", { ref: titleRef, style: {
163
174
  textAlign: "left",
164
- color: titleStyle === null || titleStyle === void 0 ? void 0 : titleStyle.color,
175
+ color: resolvedTitleStyle === null || resolvedTitleStyle === void 0 ? void 0 : resolvedTitleStyle.color,
165
176
  fontSize: computedFontSize,
166
- fontWeight: titleStyle === null || titleStyle === void 0 ? void 0 : titleStyle.fontWeight,
167
- fontFamily: titleStyle === null || titleStyle === void 0 ? void 0 : titleStyle.fontFamily,
177
+ fontWeight: resolvedTitleStyle === null || resolvedTitleStyle === void 0 ? void 0 : resolvedTitleStyle.fontWeight,
178
+ fontFamily: resolvedTitleStyle === null || resolvedTitleStyle === void 0 ? void 0 : resolvedTitleStyle.fontFamily,
168
179
  marginBottom: 4,
169
180
  width: typeof width === "string"
170
181
  ? width
@@ -10,143 +10,190 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
13
46
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
47
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
48
  };
16
49
  Object.defineProperty(exports, "__esModule", { value: true });
17
- var react_1 = __importDefault(require("react"));
50
+ var react_1 = __importStar(require("react"));
18
51
  var react_apexcharts_1 = __importDefault(require("react-apexcharts"));
52
+ var react_2 = require("@chakra-ui/react");
53
+ var chartColorsFromTheme_1 = require("../../../Theme/chartColorsFromTheme");
54
+ var getValidLegendPosition = function (position) {
55
+ var validPositions = ["left", "right", "top", "bottom"];
56
+ if (validPositions.includes(position)) {
57
+ return position;
58
+ }
59
+ console.warn("Invalid legend position: ".concat(position, ". Defaulting to 'bottom'."));
60
+ return "bottom";
61
+ };
19
62
  var ApexPieChart = function (_a) {
20
- var _b, _c;
21
- var data = _a.data, labels = _a.labels, title = _a.title, _d = _a.height, height = _d === void 0 ? 400 : _d, _e = _a.width, width = _e === void 0 ? 500 : _e, donutColors = _a.donutColors, chartColor = _a.chartColor, _f = _a.titlePosition, titlePosition = _f === void 0 ? "center" : _f, _g = _a.titleStyle, titleStyle = _g === void 0 ? {
22
- color: "#3182ce",
23
- fontSize: "16px",
24
- fontWeight: 600,
25
- fontFamily: "Arial",
26
- } : _g, _h = _a.legendPosition, legendPosition = _h === void 0 ? "bottom" : _h, _j = _a.legendStyle, legendStyle = _j === void 0 ? {
27
- colors: "#000",
28
- useSeriesColors: false,
29
- horizontalGap: 10,
30
- verticalGap: 5,
31
- markerSize: 8,
32
- markerOffsetX: -5,
33
- markerOffsetY: 0,
34
- } : _j, _k = _a.variant, variant = _k === void 0 ? "pie" : _k;
35
- var extraOptions = {};
36
- // Your switch cases for different variants
37
- switch (variant) {
38
- case "semi-donut":
39
- extraOptions = {
40
- plotOptions: {
41
- pie: {
42
- startAngle: -90,
43
- endAngle: 90,
44
- offsetY: 10,
63
+ var _b;
64
+ var data = _a.data, labels = _a.labels, title = _a.title, _c = _a.height, height = _c === void 0 ? 400 : _c, _d = _a.width, width = _d === void 0 ? 500 : _d, donutColors = _a.donutColors, chartColor = _a.chartColor, _e = _a.titlePosition, titlePosition = _e === void 0 ? "center" : _e, titleStyle = _a.titleStyle, _f = _a.legendPosition, legendPosition = _f === void 0 ? "bottom" : _f, legendStyle = _a.legendStyle, _g = _a.variant, variant = _g === void 0 ? "pie" : _g;
65
+ var theme = (0, react_2.useTheme)();
66
+ var palette = theme.colors;
67
+ var mergedTitleStyle = (0, react_1.useMemo)(function () { return (0, chartColorsFromTheme_1.mergeChartTitleStyle)(palette, titleStyle); }, [palette, titleStyle]);
68
+ var mergedLegendStyle = (0, react_1.useMemo)(function () {
69
+ var defaults = {
70
+ colors: palette.text[900],
71
+ useSeriesColors: false,
72
+ horizontalGap: 10,
73
+ verticalGap: 5,
74
+ markerSize: 8,
75
+ markerOffsetX: -5,
76
+ markerOffsetY: 0,
77
+ };
78
+ return __assign(__assign({}, defaults), legendStyle);
79
+ }, [palette, legendStyle]);
80
+ var seriesColors = (0, react_1.useMemo)(function () { var _a; return (_a = chartColor !== null && chartColor !== void 0 ? chartColor : donutColors) !== null && _a !== void 0 ? _a : (0, chartColorsFromTheme_1.getDefaultSeriesColors)(palette); }, [chartColor, donutColors, palette]);
81
+ var validLegendPosition = getValidLegendPosition(legendPosition);
82
+ var options = (0, react_1.useMemo)(function () {
83
+ var extraOptions = {};
84
+ switch (variant) {
85
+ case "semi-donut":
86
+ extraOptions = {
87
+ plotOptions: {
88
+ pie: {
89
+ startAngle: -90,
90
+ endAngle: 90,
91
+ offsetY: 10,
92
+ },
45
93
  },
46
- },
47
- };
48
- break;
49
- case "monochrome-pie":
50
- extraOptions = {
51
- theme: {
52
- monochrome: {
53
- enabled: true,
54
- shadeTo: "light",
55
- shadeIntensity: 0.65,
94
+ };
95
+ break;
96
+ case "monochrome-pie":
97
+ extraOptions = {
98
+ theme: {
99
+ monochrome: {
100
+ enabled: true,
101
+ shadeTo: "light",
102
+ shadeIntensity: 0.65,
103
+ },
56
104
  },
57
- },
58
- };
59
- break;
60
- case "gradient-donut":
61
- extraOptions = {
62
- fill: {
63
- type: "gradient",
64
- },
65
- };
66
- break;
67
- case "donut-with-pattern":
68
- extraOptions = {
69
- fill: {
70
- type: "pattern",
71
- pattern: {
72
- style: ["verticalLines", "squares", "horizontalLines", "circles"],
105
+ };
106
+ break;
107
+ case "gradient-donut":
108
+ extraOptions = {
109
+ fill: {
110
+ type: "gradient",
73
111
  },
74
- },
75
- };
76
- break;
77
- case "pie-with-image":
78
- extraOptions = {
79
- fill: {
80
- type: "image",
81
- image: {
82
- src: [
83
- "https://i.imgur.com/UM3mrju.jpg",
84
- "https://i.imgur.com/NpPOqQq.jpg",
85
- ],
112
+ };
113
+ break;
114
+ case "donut-with-pattern":
115
+ extraOptions = {
116
+ fill: {
117
+ type: "pattern",
118
+ pattern: {
119
+ style: ["verticalLines", "squares", "horizontalLines", "circles"],
120
+ },
86
121
  },
87
- },
88
- };
89
- break;
90
- case "update-donut":
91
- extraOptions = {
92
- plotOptions: {
93
- pie: {
94
- donut: {
95
- labels: {
96
- show: true,
97
- total: {
122
+ };
123
+ break;
124
+ case "pie-with-image":
125
+ extraOptions = {
126
+ fill: {
127
+ type: "image",
128
+ image: {
129
+ src: [
130
+ "https://i.imgur.com/UM3mrju.jpg",
131
+ "https://i.imgur.com/NpPOqQq.jpg",
132
+ ],
133
+ },
134
+ },
135
+ };
136
+ break;
137
+ case "update-donut":
138
+ extraOptions = {
139
+ plotOptions: {
140
+ pie: {
141
+ donut: {
142
+ labels: {
98
143
  show: true,
99
- label: "Total",
144
+ total: {
145
+ show: true,
146
+ label: "Total",
147
+ },
100
148
  },
101
149
  },
102
150
  },
103
151
  },
104
- },
105
- };
106
- break;
107
- case "pie":
108
- extraOptions = {
109
- chart: { type: "pie" },
110
- };
111
- break;
112
- default:
113
- break;
114
- }
115
- // Validate and normalize legend position
116
- var getValidLegendPosition = function (position) {
117
- var validPositions = ["left", "right", "top", "bottom"];
118
- if (validPositions.includes(position)) {
119
- return position;
152
+ };
153
+ break;
154
+ case "pie":
155
+ extraOptions = {
156
+ chart: { type: "pie" },
157
+ };
158
+ break;
159
+ default:
160
+ break;
120
161
  }
121
- console.warn("Invalid legend position: ".concat(position, ". Defaulting to 'bottom'."));
122
- return "bottom";
123
- };
124
- var validLegendPosition = getValidLegendPosition(legendPosition);
125
- var options = __assign({ chart: {
126
- type: variant.includes("pie") ? "pie" : "donut",
127
- }, labels: labels, colors: (_b = chartColor !== null && chartColor !== void 0 ? chartColor : donutColors) !== null && _b !== void 0 ? _b : ["#3182ce", "#e53e3e", "#38a169", "#dd6b20"], legend: {
128
- position: validLegendPosition,
129
- labels: {
130
- colors: legendStyle.colors,
131
- useSeriesColors: legendStyle.useSeriesColors,
132
- },
133
- markers: {
134
- size: legendStyle.markerSize,
135
- offsetX: legendStyle.markerOffsetX,
136
- offsetY: legendStyle.markerOffsetY,
137
- strokeWidth: 0,
138
- shape: 'circle',
139
- },
140
- itemMargin: {
141
- horizontal: legendStyle.horizontalGap,
142
- vertical: legendStyle.verticalGap,
143
- },
144
- }, title: {
145
- text: title,
146
- align: titlePosition,
147
- style: titleStyle,
148
- }, dataLabels: { enabled: true } }, extraOptions);
162
+ return __assign({ chart: {
163
+ type: variant.includes("pie") ? "pie" : "donut",
164
+ }, labels: labels, colors: seriesColors, legend: {
165
+ position: validLegendPosition,
166
+ labels: {
167
+ colors: mergedLegendStyle.colors,
168
+ useSeriesColors: mergedLegendStyle.useSeriesColors,
169
+ },
170
+ markers: {
171
+ size: mergedLegendStyle.markerSize,
172
+ offsetX: mergedLegendStyle.markerOffsetX,
173
+ offsetY: mergedLegendStyle.markerOffsetY,
174
+ strokeWidth: 0,
175
+ shape: "circle",
176
+ },
177
+ itemMargin: {
178
+ horizontal: mergedLegendStyle.horizontalGap,
179
+ vertical: mergedLegendStyle.verticalGap,
180
+ },
181
+ }, title: {
182
+ text: title,
183
+ align: titlePosition,
184
+ style: mergedTitleStyle,
185
+ }, dataLabels: { enabled: true } }, extraOptions);
186
+ }, [
187
+ variant,
188
+ labels,
189
+ seriesColors,
190
+ validLegendPosition,
191
+ mergedLegendStyle,
192
+ title,
193
+ titlePosition,
194
+ mergedTitleStyle,
195
+ ]);
149
196
  return (react_1.default.createElement("div", null,
150
- react_1.default.createElement(react_apexcharts_1.default, { options: options, series: data, type: (_c = options.chart) === null || _c === void 0 ? void 0 : _c.type, height: height, width: width })));
197
+ react_1.default.createElement(react_apexcharts_1.default, { options: options, series: data, type: (_b = options.chart) === null || _b === void 0 ? void 0 : _b.type, height: height, width: width })));
151
198
  };
152
199
  exports.default = ApexPieChart;