@deepnoid/ui 0.1.126 → 0.1.127

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.
@@ -8,24 +8,39 @@ import {
8
8
 
9
9
  // src/components/charts/barChart.tsx
10
10
  import { forwardRef, useEffect, useMemo, useRef, useState } from "react";
11
- import { XAxis, YAxis, ResponsiveContainer, CartesianGrid, BarChart, Bar, Tooltip } from "recharts";
11
+ import { XAxis, YAxis, ResponsiveContainer, CartesianGrid, BarChart, Bar } from "recharts";
12
12
  import { jsx, jsxs } from "react/jsx-runtime";
13
13
  var BarChartComponent = forwardRef((originalProps, ref) => {
14
14
  const [props, variantProps] = mapPropsVariants(originalProps, barChartStyle.variantKeys);
15
15
  const {
16
- data,
16
+ data = [],
17
17
  label,
18
18
  classNames,
19
19
  yAxisTicks = [0, 20, 40, 60, 80, 100],
20
20
  yAxisTickFormatter = (value) => `${value}`,
21
21
  yAxisDomain = [-6, 110],
22
- customTooltip
22
+ tooltipFormatter
23
23
  } = { ...props, ...variantProps };
24
24
  const slots = useMemo(() => barChartStyle({ ...variantProps }), [variantProps]);
25
25
  const [tickPositions, setTickPositions] = useState([]);
26
26
  const tickRef = useRef([]);
27
- const CustomBarShape = (barProps) => {
28
- const { x, y, width, height, fill } = barProps;
27
+ const [tooltipState, setTooltipState] = useState(null);
28
+ const handleMouseEnter = (e, dataKey) => {
29
+ if (!tooltipFormatter) return;
30
+ const { payload, x, y } = e;
31
+ if (!payload || !payload[dataKey]) return;
32
+ setTooltipState({
33
+ x,
34
+ y,
35
+ value: payload[dataKey],
36
+ dataKey,
37
+ label: payload.title
38
+ });
39
+ };
40
+ const handleMouseLeave = () => {
41
+ setTooltipState(null);
42
+ };
43
+ const CustomBarShape = ({ x, y, width, height, fill }) => {
29
44
  const radius = 5;
30
45
  const extraHeight = 10;
31
46
  const adjustedHeight = height + extraHeight;
@@ -40,9 +55,7 @@ var BarChartComponent = forwardRef((originalProps, ref) => {
40
55
  ) : /* @__PURE__ */ jsx("rect", { x, y, width, height: 0, fill });
41
56
  };
42
57
  const CustomTick = ({ x, y, payload }) => {
43
- if (x !== void 0) {
44
- tickRef.current.push(x);
45
- }
58
+ if (x !== void 0) tickRef.current.push(x);
46
59
  return /* @__PURE__ */ jsx(
47
60
  "text",
48
61
  {
@@ -57,28 +70,20 @@ var BarChartComponent = forwardRef((originalProps, ref) => {
57
70
  }
58
71
  );
59
72
  };
60
- const CustomYAxisTick = ({ x, y, payload }) => {
61
- return /* @__PURE__ */ jsx(
62
- "text",
63
- {
64
- x: x - 10,
65
- y,
66
- textAnchor: "middle",
67
- fontSize: 12,
68
- fontWeight: 700,
69
- fill: "currentColor",
70
- className: "text-body-foreground",
71
- dy: 4,
72
- children: yAxisTickFormatter(payload.value)
73
- }
74
- );
75
- };
76
- const CustomTooltip = ({ active, payload, label: label2 }) => {
77
- if (customTooltip && active && payload && payload.length) {
78
- return customTooltip({ active, payload, label: label2 });
73
+ const CustomYAxisTick = ({ x, y, payload }) => /* @__PURE__ */ jsx(
74
+ "text",
75
+ {
76
+ x: x - 10,
77
+ y,
78
+ textAnchor: "middle",
79
+ fontSize: 12,
80
+ fontWeight: 700,
81
+ fill: "currentColor",
82
+ className: "text-body-foreground",
83
+ dy: 4,
84
+ children: yAxisTickFormatter(payload.value)
79
85
  }
80
- return null;
81
- };
86
+ );
82
87
  useEffect(() => {
83
88
  const raf = requestAnimationFrame(() => {
84
89
  const unique = [...new Set(tickRef.current)].sort((a, b) => a - b);
@@ -146,13 +151,52 @@ var BarChartComponent = forwardRef((originalProps, ref) => {
146
151
  domain: yAxisDomain
147
152
  }
148
153
  ),
149
- customTooltip && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(CustomTooltip, {}), cursor: { fill: "transparent" } }),
150
- /* @__PURE__ */ jsx(Bar, { dataKey: "blue", fill: "url(#blueGradient)", width: 20, shape: CustomBarShape }),
151
- /* @__PURE__ */ jsx(Bar, { dataKey: "green", fill: "url(#greenGradient)", width: 20, shape: CustomBarShape }),
152
- /* @__PURE__ */ jsx(Bar, { dataKey: "pink", fill: "url(#pinkGradient)", width: 20, shape: CustomBarShape })
154
+ /* @__PURE__ */ jsx(
155
+ Bar,
156
+ {
157
+ dataKey: "blue",
158
+ fill: "url(#blueGradient)",
159
+ shape: CustomBarShape,
160
+ onMouseEnter: (e) => handleMouseEnter(e, "blue"),
161
+ onMouseLeave: handleMouseLeave
162
+ }
163
+ ),
164
+ /* @__PURE__ */ jsx(
165
+ Bar,
166
+ {
167
+ dataKey: "green",
168
+ fill: "url(#greenGradient)",
169
+ shape: CustomBarShape,
170
+ onMouseEnter: (e) => handleMouseEnter(e, "green"),
171
+ onMouseLeave: handleMouseLeave
172
+ }
173
+ ),
174
+ /* @__PURE__ */ jsx(
175
+ Bar,
176
+ {
177
+ dataKey: "pink",
178
+ fill: "url(#pinkGradient)",
179
+ shape: CustomBarShape,
180
+ onMouseEnter: (e) => handleMouseEnter(e, "pink"),
181
+ onMouseLeave: handleMouseLeave
182
+ }
183
+ )
153
184
  ]
154
185
  }
155
- ) })
186
+ ) }),
187
+ tooltipFormatter && tooltipState && /* @__PURE__ */ jsx(
188
+ "div",
189
+ {
190
+ style: {
191
+ position: "absolute",
192
+ left: tooltipState.x + 20,
193
+ top: tooltipState.y - 20,
194
+ transform: "translateX(-50%)",
195
+ pointerEvents: "none"
196
+ },
197
+ children: tooltipFormatter(tooltipState)
198
+ }
199
+ )
156
200
  ] });
157
201
  });
158
202
  BarChartComponent.displayName = "barChart";
@@ -163,9 +207,7 @@ var barChartStyle = tv({
163
207
  label: ["text-md", "font-bold", "text-body-foreground"]
164
208
  },
165
209
  variants: {},
166
- defaultVariants: {
167
- color: "primary"
168
- }
210
+ defaultVariants: {}
169
211
  });
170
212
 
171
213
  export {
@@ -69,7 +69,7 @@ var CircularProgress = forwardRef((originalProps, ref) => {
69
69
  cx: size / 2,
70
70
  cy: size / 2,
71
71
  r: OUTER_RADIUS + BORDER_MARGIN,
72
- fill: "none",
72
+ fill: "#fff",
73
73
  stroke: "#DFE2E7",
74
74
  strokeWidth: "1"
75
75
  }
@@ -0,0 +1,138 @@
1
+ "use client";
2
+ import {
3
+ tv
4
+ } from "./chunk-76QIZILI.mjs";
5
+ import {
6
+ clsx
7
+ } from "./chunk-27Y6K5NK.mjs";
8
+
9
+ // src/components/table/definition-table.tsx
10
+ import { forwardRef, useMemo } from "react";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
12
+ var DEFAULT_CELL_CLASSES = "px-[10px] py-[8px] text-md border-r border-neutral-light h-[50px]";
13
+ var FIRST_CELL_WIDTH_CLASS = "w-[120px] font-bold text-md text-body-foreground";
14
+ var renderColGroup = (rows) => {
15
+ let maxCols = 0;
16
+ const colWidths = [];
17
+ rows.forEach((row) => {
18
+ let currentColCount = 0;
19
+ row.cells.forEach((cell) => {
20
+ currentColCount += cell.colSpan || 1;
21
+ });
22
+ maxCols = Math.max(maxCols, currentColCount);
23
+ });
24
+ colWidths[0] = "120px";
25
+ rows.forEach((row) => {
26
+ let colIndex = 0;
27
+ row.cells.forEach((cell) => {
28
+ const span = cell.colSpan || 1;
29
+ if (colIndex > 0 && cell.width && cell.width !== "auto" && colIndex < maxCols) {
30
+ colWidths[colIndex] = cell.width;
31
+ }
32
+ colIndex += span;
33
+ });
34
+ });
35
+ const cols = [];
36
+ for (let i = 0; i < maxCols; i++) {
37
+ cols.push(/* @__PURE__ */ jsx("col", { style: { width: colWidths[i] || "auto" } }, i));
38
+ }
39
+ return /* @__PURE__ */ jsx("colgroup", { children: cols });
40
+ };
41
+ var getHighlightColumnIndex = (rows, key) => {
42
+ if (!key) return null;
43
+ for (const row of rows) {
44
+ let colIndex = 0;
45
+ for (const cell of row.cells) {
46
+ const span = cell.colSpan || 1;
47
+ if (cell.key === key) return colIndex;
48
+ colIndex += span;
49
+ }
50
+ }
51
+ return null;
52
+ };
53
+ var DefinitionTableRow = ({
54
+ cells,
55
+ className,
56
+ rowIndex = 0,
57
+ rowCount = 0,
58
+ highlightColumnIndex
59
+ }) => /* @__PURE__ */ jsx("tr", { className: clsx("border-neutral-light border-b", className), children: cells.map((cell, colIndex) => {
60
+ const isFirstCell = colIndex === 0;
61
+ const isHighlighted = colIndex === highlightColumnIndex;
62
+ const isFirstRow = rowIndex === 0;
63
+ const isLastRow = rowIndex === rowCount - 1;
64
+ const borderHighlightClass = isHighlighted ? clsx(
65
+ "border-l-[2px] border-r-[2px] border-primary-main bg-neutral-soft",
66
+ isFirstRow && "border-t-[2px]",
67
+ isLastRow && "border-b-[2px]"
68
+ ) : "";
69
+ const combinedClassName = clsx(
70
+ DEFAULT_CELL_CLASSES,
71
+ isFirstCell && FIRST_CELL_WIDTH_CLASS,
72
+ cell.className,
73
+ borderHighlightClass
74
+ );
75
+ let cellStyle;
76
+ if (isFirstCell) {
77
+ cellStyle = {
78
+ width: "120px",
79
+ minWidth: "120px",
80
+ maxWidth: "120px"
81
+ };
82
+ } else if (cell.width && cell.width !== "auto") {
83
+ cellStyle = {
84
+ width: cell.width,
85
+ minWidth: cell.width,
86
+ maxWidth: cell.width
87
+ };
88
+ } else {
89
+ cellStyle = { width: "100%" };
90
+ }
91
+ return /* @__PURE__ */ jsx(
92
+ "td",
93
+ {
94
+ className: combinedClassName,
95
+ colSpan: cell.colSpan,
96
+ rowSpan: cell.rowSpan,
97
+ style: { ...cellStyle, height: "50px" },
98
+ children: cell.content
99
+ },
100
+ colIndex
101
+ );
102
+ }) });
103
+ var DefinitionTable = forwardRef(
104
+ ({ rows = [], footer, highlightColumnKey, classNames }, ref) => {
105
+ const slots = useMemo(() => DefinitionTableStyle(), []);
106
+ const highlightColumnIndex = useMemo(
107
+ () => getHighlightColumnIndex(rows, highlightColumnKey),
108
+ [rows, highlightColumnKey]
109
+ );
110
+ return /* @__PURE__ */ jsx("div", { ref, className: clsx(slots.base(), classNames == null ? void 0 : classNames.base), children: /* @__PURE__ */ jsxs("table", { className: clsx(slots.table(), classNames == null ? void 0 : classNames.table), children: [
111
+ renderColGroup(rows),
112
+ /* @__PURE__ */ jsx("tbody", { children: rows.map((row, i) => /* @__PURE__ */ jsx(
113
+ DefinitionTableRow,
114
+ {
115
+ ...row,
116
+ rowIndex: i,
117
+ rowCount: rows.length,
118
+ highlightColumnIndex,
119
+ className: row.className
120
+ },
121
+ i
122
+ )) }),
123
+ footer && /* @__PURE__ */ jsx("tfoot", { children: footer })
124
+ ] }) });
125
+ }
126
+ );
127
+ DefinitionTable.displayName = "DefinitionTable";
128
+ var definition_table_default = DefinitionTable;
129
+ var DefinitionTableStyle = tv({
130
+ slots: {
131
+ base: ["flex", "flex-col", "gap-[30px]"],
132
+ table: ["w-full", "table-auto", "border", "border-neutral-light"]
133
+ }
134
+ });
135
+
136
+ export {
137
+ definition_table_default
138
+ };
@@ -10,9 +10,9 @@ type BarData = {
10
10
  green: number;
11
11
  pink: number;
12
12
  };
13
- type TooltipProps = {
14
- active: boolean;
15
- payload: any[];
13
+ type TooltipFormatterParams = {
14
+ dataKey: string;
15
+ value: number;
16
16
  label: string;
17
17
  };
18
18
  type Props = {
@@ -22,7 +22,7 @@ type Props = {
22
22
  yAxisTicks?: number[];
23
23
  yAxisTickFormatter?: (value: number) => string;
24
24
  yAxisDomain?: [number, number];
25
- customTooltip?: (props: TooltipProps) => ReactNode;
25
+ tooltipFormatter?: (params: TooltipFormatterParams) => ReactNode;
26
26
  };
27
27
  type barChartProps = Props & barChartVariantProps;
28
28
  declare const BarChartComponent: react.ForwardRefExoticComponent<Props & barChartVariantProps & react.RefAttributes<HTMLDivElement>>;
@@ -10,9 +10,9 @@ type BarData = {
10
10
  green: number;
11
11
  pink: number;
12
12
  };
13
- type TooltipProps = {
14
- active: boolean;
15
- payload: any[];
13
+ type TooltipFormatterParams = {
14
+ dataKey: string;
15
+ value: number;
16
16
  label: string;
17
17
  };
18
18
  type Props = {
@@ -22,7 +22,7 @@ type Props = {
22
22
  yAxisTicks?: number[];
23
23
  yAxisTickFormatter?: (value: number) => string;
24
24
  yAxisDomain?: [number, number];
25
- customTooltip?: (props: TooltipProps) => ReactNode;
25
+ tooltipFormatter?: (params: TooltipFormatterParams) => ReactNode;
26
26
  };
27
27
  type barChartProps = Props & barChartVariantProps;
28
28
  declare const BarChartComponent: react.ForwardRefExoticComponent<Props & barChartVariantProps & react.RefAttributes<HTMLDivElement>>;
@@ -106,6 +106,7 @@ __export(barChart_exports, {
106
106
  });
107
107
  module.exports = __toCommonJS(barChart_exports);
108
108
  var import_react = require("react");
109
+ var import_recharts = require("recharts");
109
110
 
110
111
  // src/utils/tailwind-variants.ts
111
112
  var import_tailwind_variants = require("tailwind-variants");
@@ -347,9 +348,6 @@ var tv = (0, import_tailwind_variants.createTV)({
347
348
  }
348
349
  });
349
350
 
350
- // src/components/charts/barChart.tsx
351
- var import_recharts = require("recharts");
352
-
353
351
  // src/utils/props.ts
354
352
  var mapPropsVariants = (props, variantKeys, removeVariantProps = true) => {
355
353
  if (!variantKeys) {
@@ -375,19 +373,34 @@ var import_jsx_runtime = require("react/jsx-runtime");
375
373
  var BarChartComponent = (0, import_react.forwardRef)((originalProps, ref) => {
376
374
  const [props, variantProps] = mapPropsVariants(originalProps, barChartStyle.variantKeys);
377
375
  const {
378
- data,
376
+ data = [],
379
377
  label,
380
378
  classNames,
381
379
  yAxisTicks = [0, 20, 40, 60, 80, 100],
382
380
  yAxisTickFormatter = (value) => `${value}`,
383
381
  yAxisDomain = [-6, 110],
384
- customTooltip
382
+ tooltipFormatter
385
383
  } = { ...props, ...variantProps };
386
384
  const slots = (0, import_react.useMemo)(() => barChartStyle({ ...variantProps }), [variantProps]);
387
385
  const [tickPositions, setTickPositions] = (0, import_react.useState)([]);
388
386
  const tickRef = (0, import_react.useRef)([]);
389
- const CustomBarShape = (barProps) => {
390
- const { x, y, width, height, fill } = barProps;
387
+ const [tooltipState, setTooltipState] = (0, import_react.useState)(null);
388
+ const handleMouseEnter = (e, dataKey) => {
389
+ if (!tooltipFormatter) return;
390
+ const { payload, x, y } = e;
391
+ if (!payload || !payload[dataKey]) return;
392
+ setTooltipState({
393
+ x,
394
+ y,
395
+ value: payload[dataKey],
396
+ dataKey,
397
+ label: payload.title
398
+ });
399
+ };
400
+ const handleMouseLeave = () => {
401
+ setTooltipState(null);
402
+ };
403
+ const CustomBarShape = ({ x, y, width, height, fill }) => {
391
404
  const radius = 5;
392
405
  const extraHeight = 10;
393
406
  const adjustedHeight = height + extraHeight;
@@ -402,9 +415,7 @@ var BarChartComponent = (0, import_react.forwardRef)((originalProps, ref) => {
402
415
  ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x, y, width, height: 0, fill });
403
416
  };
404
417
  const CustomTick = ({ x, y, payload }) => {
405
- if (x !== void 0) {
406
- tickRef.current.push(x);
407
- }
418
+ if (x !== void 0) tickRef.current.push(x);
408
419
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
409
420
  "text",
410
421
  {
@@ -419,28 +430,20 @@ var BarChartComponent = (0, import_react.forwardRef)((originalProps, ref) => {
419
430
  }
420
431
  );
421
432
  };
422
- const CustomYAxisTick = ({ x, y, payload }) => {
423
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
424
- "text",
425
- {
426
- x: x - 10,
427
- y,
428
- textAnchor: "middle",
429
- fontSize: 12,
430
- fontWeight: 700,
431
- fill: "currentColor",
432
- className: "text-body-foreground",
433
- dy: 4,
434
- children: yAxisTickFormatter(payload.value)
435
- }
436
- );
437
- };
438
- const CustomTooltip = ({ active, payload, label: label2 }) => {
439
- if (customTooltip && active && payload && payload.length) {
440
- return customTooltip({ active, payload, label: label2 });
433
+ const CustomYAxisTick = ({ x, y, payload }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
434
+ "text",
435
+ {
436
+ x: x - 10,
437
+ y,
438
+ textAnchor: "middle",
439
+ fontSize: 12,
440
+ fontWeight: 700,
441
+ fill: "currentColor",
442
+ className: "text-body-foreground",
443
+ dy: 4,
444
+ children: yAxisTickFormatter(payload.value)
441
445
  }
442
- return null;
443
- };
446
+ );
444
447
  (0, import_react.useEffect)(() => {
445
448
  const raf = requestAnimationFrame(() => {
446
449
  const unique = [...new Set(tickRef.current)].sort((a, b) => a - b);
@@ -508,13 +511,52 @@ var BarChartComponent = (0, import_react.forwardRef)((originalProps, ref) => {
508
511
  domain: yAxisDomain
509
512
  }
510
513
  ),
511
- customTooltip && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_recharts.Tooltip, { content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CustomTooltip, {}), cursor: { fill: "transparent" } }),
512
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_recharts.Bar, { dataKey: "blue", fill: "url(#blueGradient)", width: 20, shape: CustomBarShape }),
513
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_recharts.Bar, { dataKey: "green", fill: "url(#greenGradient)", width: 20, shape: CustomBarShape }),
514
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_recharts.Bar, { dataKey: "pink", fill: "url(#pinkGradient)", width: 20, shape: CustomBarShape })
514
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
515
+ import_recharts.Bar,
516
+ {
517
+ dataKey: "blue",
518
+ fill: "url(#blueGradient)",
519
+ shape: CustomBarShape,
520
+ onMouseEnter: (e) => handleMouseEnter(e, "blue"),
521
+ onMouseLeave: handleMouseLeave
522
+ }
523
+ ),
524
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
525
+ import_recharts.Bar,
526
+ {
527
+ dataKey: "green",
528
+ fill: "url(#greenGradient)",
529
+ shape: CustomBarShape,
530
+ onMouseEnter: (e) => handleMouseEnter(e, "green"),
531
+ onMouseLeave: handleMouseLeave
532
+ }
533
+ ),
534
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
535
+ import_recharts.Bar,
536
+ {
537
+ dataKey: "pink",
538
+ fill: "url(#pinkGradient)",
539
+ shape: CustomBarShape,
540
+ onMouseEnter: (e) => handleMouseEnter(e, "pink"),
541
+ onMouseLeave: handleMouseLeave
542
+ }
543
+ )
515
544
  ]
516
545
  }
517
- ) })
546
+ ) }),
547
+ tooltipFormatter && tooltipState && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
548
+ "div",
549
+ {
550
+ style: {
551
+ position: "absolute",
552
+ left: tooltipState.x + 20,
553
+ top: tooltipState.y - 20,
554
+ transform: "translateX(-50%)",
555
+ pointerEvents: "none"
556
+ },
557
+ children: tooltipFormatter(tooltipState)
558
+ }
559
+ )
518
560
  ] });
519
561
  });
520
562
  BarChartComponent.displayName = "barChart";
@@ -525,7 +567,5 @@ var barChartStyle = tv({
525
567
  label: ["text-md", "font-bold", "text-body-foreground"]
526
568
  },
527
569
  variants: {},
528
- defaultVariants: {
529
- color: "primary"
530
- }
570
+ defaultVariants: {}
531
571
  });
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  barChart_default
4
- } from "../../chunk-WNNOVISA.mjs";
4
+ } from "../../chunk-FQJD2IY3.mjs";
5
5
  import "../../chunk-E3G5QXSH.mjs";
6
6
  import "../../chunk-76QIZILI.mjs";
7
7
  import "../../chunk-AC6TWLRT.mjs";
@@ -429,7 +429,7 @@ var CircularProgress = (0, import_react.forwardRef)((originalProps, ref) => {
429
429
  cx: size / 2,
430
430
  cy: size / 2,
431
431
  r: OUTER_RADIUS + BORDER_MARGIN,
432
- fill: "none",
432
+ fill: "#fff",
433
433
  stroke: "#DFE2E7",
434
434
  strokeWidth: "1"
435
435
  }
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  circularProgress_default
4
- } from "../../chunk-5XW5QDIW.mjs";
4
+ } from "../../chunk-NCK5E2NL.mjs";
5
5
  import "../../chunk-E3G5QXSH.mjs";
6
6
  import "../../chunk-76QIZILI.mjs";
7
7
  import "../../chunk-AC6TWLRT.mjs";