@andreagiugni/tailwind-dashboard-ui 1.0.9 → 1.0.11

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/README.md CHANGED
@@ -221,7 +221,7 @@ in [Peer dependencies](#peer-dependencies)).
221
221
 
222
222
  | Component | Key props |
223
223
  |---|---|
224
- | `BarChart` | `series`, `categories`, `colors?`, `height?`, `options?` (merged over defaults) |
224
+ | `BarChart` | `series`, `categories`, `colors?`, `height?`, `horizontal?`, `showBarValues?`, `showBarPercentages?`, `percentageMode?`, `barValueFormatter?`, `barPercentageFormatter?`, `options?` (merged over defaults) |
225
225
  | `LineChart` | `series`, `categories`, `colors?`, `height?`, `options?` |
226
226
  | `Calendar` | `events`, `onEventClick`, `onDateSelect`, `initialView` |
227
227
  | `Editor` (WYSIWYG) | `content`, `onChange(html)`, `placeholder?`, `editable?`, `toolbar?`, `rows?` — Tiptap-powered, customizable toolbar |
@@ -0,0 +1,323 @@
1
+ "use client";
2
+ import Chart from 'react-apexcharts';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+ var defaultOptions = {
6
+ colors: ["#465fff"],
7
+ chart: {
8
+ fontFamily: "Outfit, sans-serif",
9
+ type: "bar",
10
+ height: 180,
11
+ toolbar: {
12
+ show: false
13
+ }
14
+ },
15
+ plotOptions: {
16
+ bar: {
17
+ horizontal: false,
18
+ columnWidth: "39%",
19
+ borderRadius: 5,
20
+ borderRadiusApplication: "end"
21
+ }
22
+ },
23
+ dataLabels: {
24
+ enabled: false
25
+ },
26
+ // No transparent stroke around the columns: it shrinks and shifts the
27
+ // painted bar inside its allocated slot, so the hover highlight band
28
+ // (crosshairs width "barWidth" = the allocated width) would render wider
29
+ // than — and offset from — the visible bar.
30
+ stroke: {
31
+ show: false
32
+ },
33
+ xaxis: {
34
+ categories: [
35
+ "Jan",
36
+ "Feb",
37
+ "Mar",
38
+ "Apr",
39
+ "May",
40
+ "Jun",
41
+ "Jul",
42
+ "Aug",
43
+ "Sep",
44
+ "Oct",
45
+ "Nov",
46
+ "Dec"
47
+ ],
48
+ axisBorder: {
49
+ show: false
50
+ },
51
+ axisTicks: {
52
+ show: false
53
+ },
54
+ // Match the hover highlight band to the bar width (the default band spans
55
+ // the whole category slot, looking ~3x wider than the 39% columns).
56
+ crosshairs: {
57
+ width: "barWidth"
58
+ }
59
+ },
60
+ legend: {
61
+ show: true,
62
+ position: "top",
63
+ horizontalAlign: "left",
64
+ fontFamily: "Outfit",
65
+ // Rounded, border-less swatches that echo the column styling. ApexCharts
66
+ // sets the marker span's `color` to the series color, so `currentColor`
67
+ // picks it up; `customHTML` lets us round the corners (the built-in shapes
68
+ // are sharp SVG paths that CSS border-radius can't touch).
69
+ markers: {
70
+ size: 7,
71
+ strokeWidth: 0,
72
+ customHTML: () => '<span style="display:block;height:100%;width:100%;border-radius:3px;background:currentColor"></span>'
73
+ }
74
+ },
75
+ yaxis: {
76
+ title: {
77
+ text: void 0
78
+ }
79
+ },
80
+ grid: {
81
+ yaxis: {
82
+ lines: {
83
+ show: true
84
+ }
85
+ }
86
+ },
87
+ fill: {
88
+ opacity: 1
89
+ },
90
+ tooltip: {
91
+ x: {
92
+ show: false
93
+ },
94
+ y: {
95
+ formatter: (val) => `${val}`
96
+ }
97
+ }
98
+ };
99
+ var defaultSeries = [
100
+ {
101
+ name: "Sales",
102
+ data: [168, 385, 201, 298, 187, 195, 291, 110, 215, 390, 280, 112]
103
+ }
104
+ ];
105
+ var horizontalGridOptions = {
106
+ borderColor: "transparent",
107
+ xaxis: {
108
+ lines: {
109
+ show: false
110
+ }
111
+ },
112
+ yaxis: {
113
+ lines: {
114
+ show: false
115
+ }
116
+ }
117
+ };
118
+ function mergeGridOptions(base, override) {
119
+ return {
120
+ ...base,
121
+ ...override,
122
+ xaxis: {
123
+ ...base?.xaxis,
124
+ ...override?.xaxis,
125
+ lines: {
126
+ ...base?.xaxis?.lines,
127
+ ...override?.xaxis?.lines
128
+ }
129
+ },
130
+ yaxis: {
131
+ ...base?.yaxis,
132
+ ...override?.yaxis,
133
+ lines: {
134
+ ...base?.yaxis?.lines,
135
+ ...override?.yaxis?.lines
136
+ }
137
+ }
138
+ };
139
+ }
140
+ function getDataValue(value) {
141
+ if (typeof value === "number") return value;
142
+ if (Array.isArray(value) && typeof value[1] === "number") return value[1];
143
+ if (value && typeof value === "object" && "y" in value) {
144
+ const y = value.y;
145
+ return typeof y === "number" ? y : null;
146
+ }
147
+ return null;
148
+ }
149
+ function getValueMatrix(series) {
150
+ return series.map((item) => item.data.map((value) => getDataValue(value) ?? 0));
151
+ }
152
+ function getSeriesTotal(matrix) {
153
+ return matrix.reduce(
154
+ (seriesTotal, data) => seriesTotal + data.reduce((total, value) => total + value, 0),
155
+ 0
156
+ );
157
+ }
158
+ function getCategoryTotal(matrix, dataPointIndex) {
159
+ return matrix.reduce((total, data) => total + (data[dataPointIndex] ?? 0), 0);
160
+ }
161
+ function mergeDataLabels(base, override, generated) {
162
+ return {
163
+ ...base,
164
+ ...override,
165
+ ...generated,
166
+ style: {
167
+ ...base?.style,
168
+ ...override?.style,
169
+ ...generated?.style
170
+ },
171
+ background: {
172
+ ...base?.background,
173
+ ...override?.background,
174
+ ...generated?.background
175
+ }
176
+ };
177
+ }
178
+ function mergeAnnotations(override, generated) {
179
+ if (!override && !generated) return void 0;
180
+ return {
181
+ ...override,
182
+ ...generated,
183
+ points: [...override?.points ?? [], ...generated?.points ?? []]
184
+ };
185
+ }
186
+ var BarChart = ({
187
+ series,
188
+ categories,
189
+ colors,
190
+ height,
191
+ horizontal,
192
+ showBarValues = false,
193
+ showBarPercentages = false,
194
+ percentageMode = "total",
195
+ barValueFormatter,
196
+ barPercentageFormatter,
197
+ options
198
+ }) => {
199
+ const effectiveSeries = series ?? defaultSeries;
200
+ const effectiveCategories = categories ?? options?.xaxis?.categories;
201
+ const valueMatrix = getValueMatrix(effectiveSeries);
202
+ const seriesTotal = getSeriesTotal(valueMatrix);
203
+ const isHorizontal = horizontal ?? options?.plotOptions?.bar?.horizontal === true;
204
+ const hasGeneratedLabels = showBarValues || showBarPercentages;
205
+ const baseGridOptions = isHorizontal ? mergeGridOptions(defaultOptions.grid, horizontalGridOptions) : defaultOptions.grid;
206
+ const getLabelContext = (seriesIndex, dataPointIndex, total) => ({
207
+ seriesIndex,
208
+ dataPointIndex,
209
+ seriesName: effectiveSeries[seriesIndex]?.name,
210
+ category: effectiveCategories?.[dataPointIndex],
211
+ total
212
+ });
213
+ const generatedDataLabels = hasGeneratedLabels ? {
214
+ enabled: true,
215
+ textAnchor: "middle",
216
+ offsetX: 0,
217
+ offsetY: 0,
218
+ background: {
219
+ enabled: false
220
+ },
221
+ style: {
222
+ fontSize: "12px",
223
+ fontWeight: 600,
224
+ colors: [showBarPercentages ? "#ffffff" : "#344054"]
225
+ },
226
+ formatter: (value, opts) => {
227
+ const seriesIndex = opts?.seriesIndex ?? 0;
228
+ const dataPointIndex = opts?.dataPointIndex ?? 0;
229
+ const numericValue = typeof value === "number" ? value : valueMatrix[seriesIndex]?.[dataPointIndex] ?? 0;
230
+ const total = percentageMode === "category" ? getCategoryTotal(valueMatrix, dataPointIndex) : seriesTotal;
231
+ const context = getLabelContext(seriesIndex, dataPointIndex, total);
232
+ if (showBarPercentages) {
233
+ const percentage = total > 0 ? numericValue / total * 100 : 0;
234
+ return barPercentageFormatter ? barPercentageFormatter(percentage, numericValue, context) : `${Math.round(percentage)}%`;
235
+ }
236
+ return barValueFormatter ? barValueFormatter(numericValue, context) : `${numericValue}`;
237
+ }
238
+ } : void 0;
239
+ const generatedAnnotations = isHorizontal && showBarValues ? {
240
+ points: effectiveSeries.flatMap(
241
+ (item, seriesIndex) => item.data.map((dataPoint, dataPointIndex) => {
242
+ const value = getDataValue(dataPoint) ?? 0;
243
+ const total = percentageMode === "category" ? getCategoryTotal(valueMatrix, dataPointIndex) : seriesTotal;
244
+ const context = getLabelContext(seriesIndex, dataPointIndex, total);
245
+ return {
246
+ x: value,
247
+ y: dataPointIndex,
248
+ seriesIndex,
249
+ marker: {
250
+ size: 0
251
+ },
252
+ label: {
253
+ text: barValueFormatter ? barValueFormatter(value, context) : `${value}`,
254
+ borderWidth: 0,
255
+ offsetY: -12,
256
+ style: {
257
+ background: "transparent",
258
+ color: "#344054",
259
+ fontSize: "12px",
260
+ fontWeight: 600,
261
+ padding: {
262
+ left: 0,
263
+ right: 0,
264
+ top: 0,
265
+ bottom: 0
266
+ }
267
+ }
268
+ }
269
+ };
270
+ })
271
+ )
272
+ } : void 0;
273
+ const mergedOptions = {
274
+ ...defaultOptions,
275
+ ...options,
276
+ colors: colors ?? options?.colors ?? defaultOptions.colors,
277
+ chart: {
278
+ ...defaultOptions.chart,
279
+ ...options?.chart,
280
+ height: height ?? options?.chart?.height ?? defaultOptions.chart?.height
281
+ },
282
+ plotOptions: {
283
+ ...defaultOptions.plotOptions,
284
+ ...options?.plotOptions,
285
+ bar: {
286
+ ...defaultOptions.plotOptions?.bar,
287
+ ...options?.plotOptions?.bar,
288
+ horizontal: isHorizontal,
289
+ ...hasGeneratedLabels && {
290
+ dataLabels: {
291
+ ...options?.plotOptions?.bar?.dataLabels,
292
+ position: showBarPercentages ? "center" : "top"
293
+ }
294
+ }
295
+ }
296
+ },
297
+ dataLabels: mergeDataLabels(
298
+ defaultOptions.dataLabels,
299
+ options?.dataLabels,
300
+ generatedDataLabels
301
+ ),
302
+ xaxis: {
303
+ ...defaultOptions.xaxis,
304
+ ...options?.xaxis,
305
+ categories: categories ?? options?.xaxis?.categories ?? defaultOptions.xaxis?.categories
306
+ },
307
+ grid: mergeGridOptions(baseGridOptions, options?.grid),
308
+ annotations: mergeAnnotations(options?.annotations, generatedAnnotations)
309
+ };
310
+ return /* @__PURE__ */ jsx(
311
+ Chart,
312
+ {
313
+ options: mergedOptions,
314
+ series: effectiveSeries,
315
+ type: "bar",
316
+ height: height ?? 180
317
+ }
318
+ );
319
+ };
320
+
321
+ export { BarChart };
322
+ //# sourceMappingURL=chunk-ELKZHROK.js.map
323
+ //# sourceMappingURL=chunk-ELKZHROK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Charts/BarChart.tsx"],"names":[],"mappings":";;;AA+BA,IAAM,cAAA,GAA8B;AAAA,EAClC,MAAA,EAAQ,CAAC,SAAS,CAAA;AAAA,EAClB,KAAA,EAAO;AAAA,IACL,UAAA,EAAY,oBAAA;AAAA,IACZ,IAAA,EAAM,KAAA;AAAA,IACN,MAAA,EAAQ,GAAA;AAAA,IACR,OAAA,EAAS;AAAA,MACP,IAAA,EAAM;AAAA;AACR,GACF;AAAA,EACA,WAAA,EAAa;AAAA,IACX,GAAA,EAAK;AAAA,MACH,UAAA,EAAY,KAAA;AAAA,MACZ,WAAA,EAAa,KAAA;AAAA,MACb,YAAA,EAAc,CAAA;AAAA,MACd,uBAAA,EAAyB;AAAA;AAC3B,GACF;AAAA,EACA,UAAA,EAAY;AAAA,IACV,OAAA,EAAS;AAAA,GACX;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM;AAAA,GACR;AAAA,EACA,KAAA,EAAO;AAAA,IACL,UAAA,EAAY;AAAA,MACV,KAAA;AAAA,MACA,KAAA;AAAA,MACA,KAAA;AAAA,MACA,KAAA;AAAA,MACA,KAAA;AAAA,MACA,KAAA;AAAA,MACA,KAAA;AAAA,MACA,KAAA;AAAA,MACA,KAAA;AAAA,MACA,KAAA;AAAA,MACA,KAAA;AAAA,MACA;AAAA,KACF;AAAA,IACA,UAAA,EAAY;AAAA,MACV,IAAA,EAAM;AAAA,KACR;AAAA,IACA,SAAA,EAAW;AAAA,MACT,IAAA,EAAM;AAAA,KACR;AAAA;AAAA;AAAA,IAGA,UAAA,EAAY;AAAA,MACV,KAAA,EAAO;AAAA;AACT,GACF;AAAA,EACA,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,IAAA;AAAA,IACN,QAAA,EAAU,KAAA;AAAA,IACV,eAAA,EAAiB,MAAA;AAAA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A,EAAY;AAAA,YACV,GAAG,OAAA,EAAS,WAAA,EAAa,GAAA,EAAK,UAAA;AAAA,YAC9B,QAAA,EAAU,qBAAqB,QAAA,GAAW;AAAA;AAC5C;AACF;AACF,KACF;AAAA,IACA,UAAA,EAAY,eAAA;AAAA,MACV,cAAA,CAAe,UAAA;AAAA,MACf,OAAA,EAAS,UAAA;AAAA,MACT;AAAA,KACF;AAAA,IACA,KAAA,EAAO;AAAA,MACL,GAAG,cAAA,CAAe,KAAA;AAAA,MAClB,GAAG,OAAA,EAAS,KAAA;AAAA,MACZ,YACE,UAAA,IACA,OAAA,EAAS,KAAA,EAAO,UAAA,IAChB,eAAe,KAAA,EAAO;AAAA,KAC1B;AAAA,IACA,IAAA,EAAM,gBAAA,CAAiB,eAAA,EAAiB,OAAA,EAAS,IAAI,CAAA;AAAA,IACrD,WAAA,EAAa,gBAAA,CAAiB,OAAA,EAAS,WAAA,EAAa,oBAAoB;AAAA,GAC1E;AAEA,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,OAAA,EAAS,aAAA;AAAA,MACT,MAAA,EAAQ,eAAA;AAAA,MACR,IAAA,EAAK,KAAA;AAAA,MACL,QAAQ,MAAA,IAAU;AAAA;AAAA,GACpB;AAEJ","file":"chunk-ELKZHROK.js","sourcesContent":["\"use client\";\nimport React from \"react\";\nimport Chart from \"react-apexcharts\";\nimport type { ApexOptions } from \"apexcharts\";\n\nexport interface BarChartProps {\n series?: ApexAxisChartSeries;\n categories?: string[];\n colors?: string[];\n height?: number;\n horizontal?: boolean;\n showBarValues?: boolean;\n showBarPercentages?: boolean;\n percentageMode?: \"total\" | \"category\";\n barValueFormatter?: (value: number, context: BarChartLabelContext) => string;\n barPercentageFormatter?: (\n percentage: number,\n value: number,\n context: BarChartLabelContext\n ) => string;\n options?: ApexOptions;\n}\n\nexport interface BarChartLabelContext {\n seriesIndex: number;\n dataPointIndex: number;\n seriesName?: string;\n category?: string;\n total: number;\n}\n\nconst defaultOptions: ApexOptions = {\n colors: [\"#465fff\"],\n chart: {\n fontFamily: \"Outfit, sans-serif\",\n type: \"bar\",\n height: 180,\n toolbar: {\n show: false,\n },\n },\n plotOptions: {\n bar: {\n horizontal: false,\n columnWidth: \"39%\",\n borderRadius: 5,\n borderRadiusApplication: \"end\",\n },\n },\n dataLabels: {\n enabled: false,\n },\n // No transparent stroke around the columns: it shrinks and shifts the\n // painted bar inside its allocated slot, so the hover highlight band\n // (crosshairs width \"barWidth\" = the allocated width) would render wider\n // than — and offset from — the visible bar.\n stroke: {\n show: false,\n },\n xaxis: {\n categories: [\n \"Jan\",\n \"Feb\",\n \"Mar\",\n \"Apr\",\n \"May\",\n \"Jun\",\n \"Jul\",\n \"Aug\",\n \"Sep\",\n \"Oct\",\n \"Nov\",\n \"Dec\",\n ],\n axisBorder: {\n show: false,\n },\n axisTicks: {\n show: false,\n },\n // Match the hover highlight band to the bar width (the default band spans\n // the whole category slot, looking ~3x wider than the 39% columns).\n crosshairs: {\n width: \"barWidth\",\n },\n },\n legend: {\n show: true,\n position: \"top\",\n horizontalAlign: \"left\",\n fontFamily: \"Outfit\",\n // Rounded, border-less swatches that echo the column styling. ApexCharts\n // sets the marker span's `color` to the series color, so `currentColor`\n // picks it up; `customHTML` lets us round the corners (the built-in shapes\n // are sharp SVG paths that CSS border-radius can't touch).\n markers: {\n size: 7,\n strokeWidth: 0,\n customHTML: () =>\n '<span style=\"display:block;height:100%;width:100%;border-radius:3px;background:currentColor\"></span>',\n },\n },\n yaxis: {\n title: {\n text: undefined,\n },\n },\n grid: {\n yaxis: {\n lines: {\n show: true,\n },\n },\n },\n fill: {\n opacity: 1,\n },\n tooltip: {\n x: {\n show: false,\n },\n y: {\n formatter: (val: number) => `${val}`,\n },\n },\n};\n\nconst defaultSeries: ApexAxisChartSeries = [\n {\n name: \"Sales\",\n data: [168, 385, 201, 298, 187, 195, 291, 110, 215, 390, 280, 112],\n },\n];\n\nconst horizontalGridOptions: ApexOptions[\"grid\"] = {\n borderColor: \"transparent\",\n xaxis: {\n lines: {\n show: false,\n },\n },\n yaxis: {\n lines: {\n show: false,\n },\n },\n};\n\nfunction mergeGridOptions(\n base: ApexOptions[\"grid\"],\n override: ApexOptions[\"grid\"]\n): ApexOptions[\"grid\"] {\n return {\n ...base,\n ...override,\n xaxis: {\n ...base?.xaxis,\n ...override?.xaxis,\n lines: {\n ...base?.xaxis?.lines,\n ...override?.xaxis?.lines,\n },\n },\n yaxis: {\n ...base?.yaxis,\n ...override?.yaxis,\n lines: {\n ...base?.yaxis?.lines,\n ...override?.yaxis?.lines,\n },\n },\n };\n}\n\nfunction getDataValue(value: unknown): number | null {\n if (typeof value === \"number\") return value;\n if (Array.isArray(value) && typeof value[1] === \"number\") return value[1];\n if (value && typeof value === \"object\" && \"y\" in value) {\n const y = (value as { y: unknown }).y;\n return typeof y === \"number\" ? y : null;\n }\n return null;\n}\n\nfunction getValueMatrix(series: ApexAxisChartSeries): number[][] {\n return series.map((item) => item.data.map((value) => getDataValue(value) ?? 0));\n}\n\nfunction getSeriesTotal(matrix: number[][]): number {\n return matrix.reduce(\n (seriesTotal, data) => seriesTotal + data.reduce((total, value) => total + value, 0),\n 0\n );\n}\n\nfunction getCategoryTotal(matrix: number[][], dataPointIndex: number): number {\n return matrix.reduce((total, data) => total + (data[dataPointIndex] ?? 0), 0);\n}\n\nfunction mergeDataLabels(\n base: ApexOptions[\"dataLabels\"],\n override: ApexOptions[\"dataLabels\"],\n generated: ApexOptions[\"dataLabels\"]\n): ApexOptions[\"dataLabels\"] {\n return {\n ...base,\n ...override,\n ...generated,\n style: {\n ...base?.style,\n ...override?.style,\n ...generated?.style,\n },\n background: {\n ...base?.background,\n ...override?.background,\n ...generated?.background,\n },\n };\n}\n\nfunction mergeAnnotations(\n override: ApexOptions[\"annotations\"],\n generated: ApexOptions[\"annotations\"]\n): ApexOptions[\"annotations\"] | undefined {\n if (!override && !generated) return undefined;\n return {\n ...override,\n ...generated,\n points: [...(override?.points ?? []), ...(generated?.points ?? [])],\n };\n}\n\nexport const BarChart: React.FC<BarChartProps> = ({\n series,\n categories,\n colors,\n height,\n horizontal,\n showBarValues = false,\n showBarPercentages = false,\n percentageMode = \"total\",\n barValueFormatter,\n barPercentageFormatter,\n options,\n}) => {\n const effectiveSeries = series ?? defaultSeries;\n const effectiveCategories =\n categories ?? (options?.xaxis?.categories as string[] | undefined);\n const valueMatrix = getValueMatrix(effectiveSeries);\n const seriesTotal = getSeriesTotal(valueMatrix);\n const isHorizontal = horizontal ?? (options?.plotOptions?.bar?.horizontal === true);\n const hasGeneratedLabels = showBarValues || showBarPercentages;\n const baseGridOptions = isHorizontal\n ? mergeGridOptions(defaultOptions.grid, horizontalGridOptions)\n : defaultOptions.grid;\n const getLabelContext = (\n seriesIndex: number,\n dataPointIndex: number,\n total: number\n ): BarChartLabelContext => ({\n seriesIndex,\n dataPointIndex,\n seriesName: effectiveSeries[seriesIndex]?.name,\n category: effectiveCategories?.[dataPointIndex],\n total,\n });\n const generatedDataLabels: ApexOptions[\"dataLabels\"] | undefined = hasGeneratedLabels\n ? {\n enabled: true,\n textAnchor: \"middle\",\n offsetX: 0,\n offsetY: 0,\n background: {\n enabled: false,\n },\n style: {\n fontSize: \"12px\",\n fontWeight: 600,\n colors: [showBarPercentages ? \"#ffffff\" : \"#344054\"],\n },\n formatter: (value, opts) => {\n const seriesIndex = opts?.seriesIndex ?? 0;\n const dataPointIndex = opts?.dataPointIndex ?? 0;\n const numericValue =\n typeof value === \"number\"\n ? value\n : valueMatrix[seriesIndex]?.[dataPointIndex] ?? 0;\n const total =\n percentageMode === \"category\"\n ? getCategoryTotal(valueMatrix, dataPointIndex)\n : seriesTotal;\n const context = getLabelContext(seriesIndex, dataPointIndex, total);\n\n if (showBarPercentages) {\n const percentage = total > 0 ? (numericValue / total) * 100 : 0;\n return barPercentageFormatter\n ? barPercentageFormatter(percentage, numericValue, context)\n : `${Math.round(percentage)}%`;\n }\n\n return barValueFormatter\n ? barValueFormatter(numericValue, context)\n : `${numericValue}`;\n },\n }\n : undefined;\n const generatedAnnotations: ApexOptions[\"annotations\"] | undefined =\n isHorizontal && showBarValues\n ? {\n points: effectiveSeries.flatMap((item, seriesIndex) =>\n item.data.map((dataPoint, dataPointIndex) => {\n const value = getDataValue(dataPoint) ?? 0;\n const total =\n percentageMode === \"category\"\n ? getCategoryTotal(valueMatrix, dataPointIndex)\n : seriesTotal;\n const context = getLabelContext(seriesIndex, dataPointIndex, total);\n return {\n x: value,\n y: dataPointIndex,\n seriesIndex,\n marker: {\n size: 0,\n },\n label: {\n text: barValueFormatter ? barValueFormatter(value, context) : `${value}`,\n borderWidth: 0,\n offsetY: -12,\n style: {\n background: \"transparent\",\n color: \"#344054\",\n fontSize: \"12px\",\n fontWeight: 600,\n padding: {\n left: 0,\n right: 0,\n top: 0,\n bottom: 0,\n },\n },\n },\n };\n })\n ),\n }\n : undefined;\n const mergedOptions: ApexOptions = {\n ...defaultOptions,\n ...options,\n colors: colors ?? options?.colors ?? defaultOptions.colors,\n chart: {\n ...defaultOptions.chart,\n ...options?.chart,\n height: height ?? options?.chart?.height ?? defaultOptions.chart?.height,\n },\n plotOptions: {\n ...defaultOptions.plotOptions,\n ...options?.plotOptions,\n bar: {\n ...defaultOptions.plotOptions?.bar,\n ...options?.plotOptions?.bar,\n horizontal: isHorizontal,\n ...(hasGeneratedLabels && {\n dataLabels: {\n ...options?.plotOptions?.bar?.dataLabels,\n position: showBarPercentages ? \"center\" : \"top\",\n },\n }),\n },\n },\n dataLabels: mergeDataLabels(\n defaultOptions.dataLabels,\n options?.dataLabels,\n generatedDataLabels\n ),\n xaxis: {\n ...defaultOptions.xaxis,\n ...options?.xaxis,\n categories:\n categories ??\n options?.xaxis?.categories ??\n defaultOptions.xaxis?.categories,\n },\n grid: mergeGridOptions(baseGridOptions, options?.grid),\n annotations: mergeAnnotations(options?.annotations, generatedAnnotations),\n };\n\n return (\n <Chart\n options={mergedOptions}\n series={effectiveSeries}\n type=\"bar\"\n height={height ?? 180}\n />\n );\n};\n"]}
@@ -0,0 +1,329 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var Chart = require('react-apexcharts');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var Chart__default = /*#__PURE__*/_interopDefault(Chart);
10
+
11
+ var defaultOptions = {
12
+ colors: ["#465fff"],
13
+ chart: {
14
+ fontFamily: "Outfit, sans-serif",
15
+ type: "bar",
16
+ height: 180,
17
+ toolbar: {
18
+ show: false
19
+ }
20
+ },
21
+ plotOptions: {
22
+ bar: {
23
+ horizontal: false,
24
+ columnWidth: "39%",
25
+ borderRadius: 5,
26
+ borderRadiusApplication: "end"
27
+ }
28
+ },
29
+ dataLabels: {
30
+ enabled: false
31
+ },
32
+ // No transparent stroke around the columns: it shrinks and shifts the
33
+ // painted bar inside its allocated slot, so the hover highlight band
34
+ // (crosshairs width "barWidth" = the allocated width) would render wider
35
+ // than — and offset from — the visible bar.
36
+ stroke: {
37
+ show: false
38
+ },
39
+ xaxis: {
40
+ categories: [
41
+ "Jan",
42
+ "Feb",
43
+ "Mar",
44
+ "Apr",
45
+ "May",
46
+ "Jun",
47
+ "Jul",
48
+ "Aug",
49
+ "Sep",
50
+ "Oct",
51
+ "Nov",
52
+ "Dec"
53
+ ],
54
+ axisBorder: {
55
+ show: false
56
+ },
57
+ axisTicks: {
58
+ show: false
59
+ },
60
+ // Match the hover highlight band to the bar width (the default band spans
61
+ // the whole category slot, looking ~3x wider than the 39% columns).
62
+ crosshairs: {
63
+ width: "barWidth"
64
+ }
65
+ },
66
+ legend: {
67
+ show: true,
68
+ position: "top",
69
+ horizontalAlign: "left",
70
+ fontFamily: "Outfit",
71
+ // Rounded, border-less swatches that echo the column styling. ApexCharts
72
+ // sets the marker span's `color` to the series color, so `currentColor`
73
+ // picks it up; `customHTML` lets us round the corners (the built-in shapes
74
+ // are sharp SVG paths that CSS border-radius can't touch).
75
+ markers: {
76
+ size: 7,
77
+ strokeWidth: 0,
78
+ customHTML: () => '<span style="display:block;height:100%;width:100%;border-radius:3px;background:currentColor"></span>'
79
+ }
80
+ },
81
+ yaxis: {
82
+ title: {
83
+ text: void 0
84
+ }
85
+ },
86
+ grid: {
87
+ yaxis: {
88
+ lines: {
89
+ show: true
90
+ }
91
+ }
92
+ },
93
+ fill: {
94
+ opacity: 1
95
+ },
96
+ tooltip: {
97
+ x: {
98
+ show: false
99
+ },
100
+ y: {
101
+ formatter: (val) => `${val}`
102
+ }
103
+ }
104
+ };
105
+ var defaultSeries = [
106
+ {
107
+ name: "Sales",
108
+ data: [168, 385, 201, 298, 187, 195, 291, 110, 215, 390, 280, 112]
109
+ }
110
+ ];
111
+ var horizontalGridOptions = {
112
+ borderColor: "transparent",
113
+ xaxis: {
114
+ lines: {
115
+ show: false
116
+ }
117
+ },
118
+ yaxis: {
119
+ lines: {
120
+ show: false
121
+ }
122
+ }
123
+ };
124
+ function mergeGridOptions(base, override) {
125
+ return {
126
+ ...base,
127
+ ...override,
128
+ xaxis: {
129
+ ...base?.xaxis,
130
+ ...override?.xaxis,
131
+ lines: {
132
+ ...base?.xaxis?.lines,
133
+ ...override?.xaxis?.lines
134
+ }
135
+ },
136
+ yaxis: {
137
+ ...base?.yaxis,
138
+ ...override?.yaxis,
139
+ lines: {
140
+ ...base?.yaxis?.lines,
141
+ ...override?.yaxis?.lines
142
+ }
143
+ }
144
+ };
145
+ }
146
+ function getDataValue(value) {
147
+ if (typeof value === "number") return value;
148
+ if (Array.isArray(value) && typeof value[1] === "number") return value[1];
149
+ if (value && typeof value === "object" && "y" in value) {
150
+ const y = value.y;
151
+ return typeof y === "number" ? y : null;
152
+ }
153
+ return null;
154
+ }
155
+ function getValueMatrix(series) {
156
+ return series.map((item) => item.data.map((value) => getDataValue(value) ?? 0));
157
+ }
158
+ function getSeriesTotal(matrix) {
159
+ return matrix.reduce(
160
+ (seriesTotal, data) => seriesTotal + data.reduce((total, value) => total + value, 0),
161
+ 0
162
+ );
163
+ }
164
+ function getCategoryTotal(matrix, dataPointIndex) {
165
+ return matrix.reduce((total, data) => total + (data[dataPointIndex] ?? 0), 0);
166
+ }
167
+ function mergeDataLabels(base, override, generated) {
168
+ return {
169
+ ...base,
170
+ ...override,
171
+ ...generated,
172
+ style: {
173
+ ...base?.style,
174
+ ...override?.style,
175
+ ...generated?.style
176
+ },
177
+ background: {
178
+ ...base?.background,
179
+ ...override?.background,
180
+ ...generated?.background
181
+ }
182
+ };
183
+ }
184
+ function mergeAnnotations(override, generated) {
185
+ if (!override && !generated) return void 0;
186
+ return {
187
+ ...override,
188
+ ...generated,
189
+ points: [...override?.points ?? [], ...generated?.points ?? []]
190
+ };
191
+ }
192
+ var BarChart = ({
193
+ series,
194
+ categories,
195
+ colors,
196
+ height,
197
+ horizontal,
198
+ showBarValues = false,
199
+ showBarPercentages = false,
200
+ percentageMode = "total",
201
+ barValueFormatter,
202
+ barPercentageFormatter,
203
+ options
204
+ }) => {
205
+ const effectiveSeries = series ?? defaultSeries;
206
+ const effectiveCategories = categories ?? options?.xaxis?.categories;
207
+ const valueMatrix = getValueMatrix(effectiveSeries);
208
+ const seriesTotal = getSeriesTotal(valueMatrix);
209
+ const isHorizontal = horizontal ?? options?.plotOptions?.bar?.horizontal === true;
210
+ const hasGeneratedLabels = showBarValues || showBarPercentages;
211
+ const baseGridOptions = isHorizontal ? mergeGridOptions(defaultOptions.grid, horizontalGridOptions) : defaultOptions.grid;
212
+ const getLabelContext = (seriesIndex, dataPointIndex, total) => ({
213
+ seriesIndex,
214
+ dataPointIndex,
215
+ seriesName: effectiveSeries[seriesIndex]?.name,
216
+ category: effectiveCategories?.[dataPointIndex],
217
+ total
218
+ });
219
+ const generatedDataLabels = hasGeneratedLabels ? {
220
+ enabled: true,
221
+ textAnchor: "middle",
222
+ offsetX: 0,
223
+ offsetY: 0,
224
+ background: {
225
+ enabled: false
226
+ },
227
+ style: {
228
+ fontSize: "12px",
229
+ fontWeight: 600,
230
+ colors: [showBarPercentages ? "#ffffff" : "#344054"]
231
+ },
232
+ formatter: (value, opts) => {
233
+ const seriesIndex = opts?.seriesIndex ?? 0;
234
+ const dataPointIndex = opts?.dataPointIndex ?? 0;
235
+ const numericValue = typeof value === "number" ? value : valueMatrix[seriesIndex]?.[dataPointIndex] ?? 0;
236
+ const total = percentageMode === "category" ? getCategoryTotal(valueMatrix, dataPointIndex) : seriesTotal;
237
+ const context = getLabelContext(seriesIndex, dataPointIndex, total);
238
+ if (showBarPercentages) {
239
+ const percentage = total > 0 ? numericValue / total * 100 : 0;
240
+ return barPercentageFormatter ? barPercentageFormatter(percentage, numericValue, context) : `${Math.round(percentage)}%`;
241
+ }
242
+ return barValueFormatter ? barValueFormatter(numericValue, context) : `${numericValue}`;
243
+ }
244
+ } : void 0;
245
+ const generatedAnnotations = isHorizontal && showBarValues ? {
246
+ points: effectiveSeries.flatMap(
247
+ (item, seriesIndex) => item.data.map((dataPoint, dataPointIndex) => {
248
+ const value = getDataValue(dataPoint) ?? 0;
249
+ const total = percentageMode === "category" ? getCategoryTotal(valueMatrix, dataPointIndex) : seriesTotal;
250
+ const context = getLabelContext(seriesIndex, dataPointIndex, total);
251
+ return {
252
+ x: value,
253
+ y: dataPointIndex,
254
+ seriesIndex,
255
+ marker: {
256
+ size: 0
257
+ },
258
+ label: {
259
+ text: barValueFormatter ? barValueFormatter(value, context) : `${value}`,
260
+ borderWidth: 0,
261
+ offsetY: -12,
262
+ style: {
263
+ background: "transparent",
264
+ color: "#344054",
265
+ fontSize: "12px",
266
+ fontWeight: 600,
267
+ padding: {
268
+ left: 0,
269
+ right: 0,
270
+ top: 0,
271
+ bottom: 0
272
+ }
273
+ }
274
+ }
275
+ };
276
+ })
277
+ )
278
+ } : void 0;
279
+ const mergedOptions = {
280
+ ...defaultOptions,
281
+ ...options,
282
+ colors: colors ?? options?.colors ?? defaultOptions.colors,
283
+ chart: {
284
+ ...defaultOptions.chart,
285
+ ...options?.chart,
286
+ height: height ?? options?.chart?.height ?? defaultOptions.chart?.height
287
+ },
288
+ plotOptions: {
289
+ ...defaultOptions.plotOptions,
290
+ ...options?.plotOptions,
291
+ bar: {
292
+ ...defaultOptions.plotOptions?.bar,
293
+ ...options?.plotOptions?.bar,
294
+ horizontal: isHorizontal,
295
+ ...hasGeneratedLabels && {
296
+ dataLabels: {
297
+ ...options?.plotOptions?.bar?.dataLabels,
298
+ position: showBarPercentages ? "center" : "top"
299
+ }
300
+ }
301
+ }
302
+ },
303
+ dataLabels: mergeDataLabels(
304
+ defaultOptions.dataLabels,
305
+ options?.dataLabels,
306
+ generatedDataLabels
307
+ ),
308
+ xaxis: {
309
+ ...defaultOptions.xaxis,
310
+ ...options?.xaxis,
311
+ categories: categories ?? options?.xaxis?.categories ?? defaultOptions.xaxis?.categories
312
+ },
313
+ grid: mergeGridOptions(baseGridOptions, options?.grid),
314
+ annotations: mergeAnnotations(options?.annotations, generatedAnnotations)
315
+ };
316
+ return /* @__PURE__ */ jsxRuntime.jsx(
317
+ Chart__default.default,
318
+ {
319
+ options: mergedOptions,
320
+ series: effectiveSeries,
321
+ type: "bar",
322
+ height: height ?? 180
323
+ }
324
+ );
325
+ };
326
+
327
+ exports.BarChart = BarChart;
328
+ //# sourceMappingURL=chunk-GLCAXT55.cjs.map
329
+ //# sourceMappingURL=chunk-GLCAXT55.cjs.map