@forgedevstack/bear 1.3.4 → 1.3.5

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 (68) hide show
  1. package/README.md +112 -155
  2. package/dist/components/Alert/Alert.cjs +1 -1
  3. package/dist/components/Alert/Alert.const.cjs +1 -1
  4. package/dist/components/Alert/Alert.const.d.ts +1 -6
  5. package/dist/components/Alert/Alert.const.js +10 -30
  6. package/dist/components/Alert/Alert.js +49 -54
  7. package/dist/components/Calendar/Calendar.cjs +1 -1
  8. package/dist/components/Calendar/Calendar.js +122 -112
  9. package/dist/components/Chart/BarChart.cjs +1 -1
  10. package/dist/components/Chart/BarChart.js +37 -36
  11. package/dist/components/Chart/Chart.types.d.ts +2 -0
  12. package/dist/components/Chart/Chart.utils.cjs +1 -1
  13. package/dist/components/Chart/Chart.utils.d.ts +2 -0
  14. package/dist/components/Chart/Chart.utils.js +32 -31
  15. package/dist/components/Chart/FunnelChart.cjs +1 -1
  16. package/dist/components/Chart/FunnelChart.js +29 -28
  17. package/dist/components/Chart/LineChart.cjs +1 -1
  18. package/dist/components/Chart/LineChart.js +45 -44
  19. package/dist/components/Chart/PieChart.cjs +1 -1
  20. package/dist/components/Chart/PieChart.js +52 -51
  21. package/dist/components/Chart/RadarChart.cjs +1 -1
  22. package/dist/components/Chart/RadarChart.js +63 -62
  23. package/dist/components/Chart/index.d.ts +1 -1
  24. package/dist/components/HoverCard/HoverCard.const.cjs +1 -1
  25. package/dist/components/HoverCard/HoverCard.const.js +3 -8
  26. package/dist/components/Menu/Menu.const.cjs +1 -1
  27. package/dist/components/Menu/Menu.const.js +5 -10
  28. package/dist/components/Modal/Modal.const.cjs +1 -1
  29. package/dist/components/Modal/Modal.const.js +14 -19
  30. package/dist/components/ModalsProvider/components/StackedModal/StackedModal.cjs +1 -1
  31. package/dist/components/ModalsProvider/components/StackedModal/StackedModal.js +10 -9
  32. package/dist/components/OverlayPortal/OverlayPortal.cjs +1 -1
  33. package/dist/components/OverlayPortal/OverlayPortal.const.cjs +1 -1
  34. package/dist/components/OverlayPortal/OverlayPortal.const.d.ts +4 -0
  35. package/dist/components/OverlayPortal/OverlayPortal.const.js +21 -5
  36. package/dist/components/OverlayPortal/OverlayPortal.js +44 -38
  37. package/dist/components/Popover/Popover.const.cjs +1 -1
  38. package/dist/components/Popover/Popover.const.js +14 -19
  39. package/dist/components/Tabs/TabList.cjs +1 -1
  40. package/dist/components/Tabs/TabList.js +1 -1
  41. package/dist/components/ToggleGroup/ToggleGroup.cjs +1 -1
  42. package/dist/components/ToggleGroup/ToggleGroup.js +49 -46
  43. package/dist/components/Tooltip/Tooltip.const.cjs +1 -1
  44. package/dist/components/Tooltip/Tooltip.const.js +10 -15
  45. package/dist/components/Transition/Transition.cjs +1 -1
  46. package/dist/components/Transition/Transition.const.cjs +1 -1
  47. package/dist/components/Transition/Transition.const.js +26 -8
  48. package/dist/components/Transition/Transition.js +77 -74
  49. package/dist/components/Transition/Transition.types.d.ts +8 -2
  50. package/dist/components/Typography/Typography.const.cjs +1 -1
  51. package/dist/components/Typography/Typography.const.js +2 -1
  52. package/dist/components/index.cjs +1 -1
  53. package/dist/components/index.d.ts +1 -1
  54. package/dist/components/index.js +1 -1
  55. package/dist/constants/generals.const.cjs +1 -1
  56. package/dist/constants/generals.const.js +85 -86
  57. package/dist/hooks/useFixedAnchorPosition/index.d.ts +1 -1
  58. package/dist/hooks/useFixedAnchorPosition/useFixedAnchorPosition.const.cjs +1 -1
  59. package/dist/hooks/useFixedAnchorPosition/useFixedAnchorPosition.const.d.ts +3 -0
  60. package/dist/hooks/useFixedAnchorPosition/useFixedAnchorPosition.const.js +17 -14
  61. package/dist/hooks/useFixedAnchorPosition/useFixedAnchorPosition.types.d.ts +1 -1
  62. package/dist/index.cjs +1 -1
  63. package/dist/index.js +557 -557
  64. package/dist/styles/_alerts.css +85 -4
  65. package/dist/styles/_drawer.css +60 -0
  66. package/dist/styles/_effects.css +33 -0
  67. package/dist/styles.css +179 -4
  68. package/package.json +3 -5
@@ -2,60 +2,61 @@ import { jsx as a, jsxs as o } from "react/jsx-runtime";
2
2
  import { ONE as l } from "../../constants/numbers.const.js";
3
3
  import { cn as n } from "../../utils/cn.js";
4
4
  import "react";
5
- import { resolveBearId as E } from "../../utils/generateBearId.utils.js";
6
- import { useBearId as b } from "../../utils/useBearId.js";
7
- import { Box as v } from "../Box/Box.js";
5
+ import { resolveBearId as b } from "../../utils/generateBearId.utils.js";
6
+ import { useBearId as v } from "../../utils/useBearId.js";
7
+ import { Box as F } from "../Box/Box.js";
8
8
  import { Flex as s } from "../Flex/Flex.js";
9
- import { Typography as F } from "../Typography/Typography.js";
10
- import { CHART as t } from "./Chart.const.js";
11
- import { getChartColor as T } from "./Chart.utils.js";
12
- const S = (m) => {
9
+ import { Typography as M } from "../Typography/Typography.js";
10
+ import { CHART as r } from "./Chart.const.js";
11
+ import { getChartColor as T, chartMotionClass as _ } from "./Chart.utils.js";
12
+ const X = (m) => {
13
13
  const {
14
14
  data: e,
15
- height: i = t.DEFAULT_HEIGHT,
15
+ height: i = r.DEFAULT_HEIGHT,
16
16
  showLabels: c = !0,
17
17
  showValues: h = !0,
18
18
  animated: d = !0,
19
- color: p,
20
- className: u,
21
- id: f,
19
+ motion: p,
20
+ color: u,
21
+ className: f,
22
+ id: C,
22
23
  testId: g,
23
24
  ...B
24
- } = m, C = b("FunnelChart"), x = E(f, C), I = Math.max(...e.map((r) => r.value), l), N = { "--Bear-Chart-height": `${i}px` };
25
+ } = m, x = v("FunnelChart"), I = b(C, x), N = Math.max(...e.map((t) => t.value), l), y = { "--Bear-Chart-height": `${i}px` };
25
26
  return /* @__PURE__ */ a(
26
27
  s,
27
28
  {
28
- id: x,
29
+ id: I,
29
30
  "data-testid": g,
30
31
  direction: "column",
31
32
  gap: 1,
32
33
  justify: "center",
33
- className: n("Bear-Chart Bear-Chart--funnel", u),
34
- style: N,
34
+ className: n("Bear-Chart Bear-Chart--funnel", f),
35
+ style: y,
35
36
  ...B,
36
- children: e.map((r, y) => {
37
- const w = {
38
- "--Bear-Chart-size": `${Math.max(r.value / I * t.VIEWBOX, t.FUNNEL_MIN_WIDTH)}%`,
39
- "--Bear-Chart-step-height": `${t.VIEWBOX / Math.max(e.length, l) / 2}%`,
40
- "--Bear-Chart-color": T(y, r.color || p)
37
+ children: e.map((t, w) => {
38
+ const E = {
39
+ "--Bear-Chart-size": `${Math.max(t.value / N * r.VIEWBOX, r.FUNNEL_MIN_WIDTH)}%`,
40
+ "--Bear-Chart-step-height": `${r.VIEWBOX / Math.max(e.length, l) / 2}%`,
41
+ "--Bear-Chart-color": T(w, t.color || u)
41
42
  };
42
43
  return /* @__PURE__ */ o(s, { direction: "column", align: "center", gap: 1, className: "bear-w-full", children: [
43
44
  /* @__PURE__ */ a(
44
- v,
45
+ F,
45
46
  {
46
- className: n("Bear-Chart__funnel-step bear-rounded-md", d && "animate-grow-right"),
47
- style: w
47
+ className: n("Bear-Chart__funnel-step bear-rounded-md", _(d, p, "animate-grow-right")),
48
+ style: E
48
49
  }
49
50
  ),
50
- c && /* @__PURE__ */ o(F, { variant: "caption", color: "muted", children: [
51
- r.label,
52
- h ? ` · ${r.value}` : ""
51
+ c && /* @__PURE__ */ o(M, { variant: "caption", color: "muted", children: [
52
+ t.label,
53
+ h ? ` · ${t.value}` : ""
53
54
  ] })
54
- ] }, r.label);
55
+ ] }, t.label);
55
56
  })
56
57
  }
57
58
  );
58
59
  };
59
60
  export {
60
- S as FunnelChart
61
+ X as FunnelChart
61
62
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("../../constants/numbers.const.cjs"),r=require("../../utils/cn.cjs");require("react");const O=require("../../utils/generateBearId.utils.cjs"),b=require("../../utils/useBearId.cjs"),t=require("./Chart.const.cjs"),C=require("./Chart.utils.cjs"),$=I=>{const{data:n,height:T=t.CHART.DEFAULT_HEIGHT,showLabels:x=!0,showDots:B=!0,smooth:j=!0,fill:_=!1,stepped:d=!1,strokeWidth:f=t.CHART.DEFAULT_STROKE_WIDTH,color:a="var(--bear-primary-500, #ec4899)",animated:i=!0,className:y,id:R,testId:g,...A}=I,L=b.useBearId("LineChart"),h=O.resolveBearId(R,L),u=`${h}-gradient`,o=C.calculateLinePoints(n),p=C.generateLinePath(o,j&&!d,d),E=o.length===c.ZERO?"":`${p} L ${t.CHART.VIEWBOX},${t.CHART.VIEWBOX} L 0,${t.CHART.VIEWBOX} Z`,H={"--Bear-Chart-height":`${T}px`};return e.jsxs("div",{id:h,"data-testid":g,className:r.cn("Bear-Chart Bear-Chart--line",y),style:H,...A,children:[e.jsxs("svg",{viewBox:`0 0 ${t.CHART.VIEWBOX} ${t.CHART.VIEWBOX}`,preserveAspectRatio:"none",className:"Bear-Chart__svg",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:u,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:a,stopOpacity:"0.3"}),e.jsx("stop",{offset:"100%",stopColor:a,stopOpacity:"0"})]})}),_&&e.jsx("path",{d:E,fill:`url(#${u})`,className:r.cn(i&&"animate-fade-in")}),e.jsx("path",{d:p,fill:"none",stroke:a,strokeWidth:f/c.TEN,strokeLinecap:"round",strokeLinejoin:"round",className:r.cn(i&&"animate-draw-line")}),B&&o.map((s,l)=>{var m;return e.jsx("circle",{cx:s.x,cy:s.y,r:t.CHART.DOT_RADIUS,fill:a,className:r.cn(i&&"animate-scale-in"),style:{animationDelay:`${l*c.FIFTY}ms`}},((m=n[l])==null?void 0:m.label)??l)})]}),x&&e.jsx("div",{className:"Bear-Chart__labels",children:n.map(s=>e.jsx("span",{className:"Bear-Chart__label",children:s.label},s.label))})]})};exports.LineChart=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("../../constants/numbers.const.cjs"),O=require("../../utils/cn.cjs");require("react");const b=require("../../utils/generateBearId.utils.cjs"),$=require("../../utils/useBearId.cjs"),t=require("./Chart.const.cjs"),a=require("./Chart.utils.cjs"),v=I=>{const{data:n,height:T=t.CHART.DEFAULT_HEIGHT,showLabels:x=!0,showDots:B=!0,smooth:j=!0,fill:_=!1,stepped:h=!1,strokeWidth:f=t.CHART.DEFAULT_STROKE_WIDTH,color:r="var(--bear-primary-500, #ec4899)",animated:o=!0,motion:i,className:y,id:R,testId:g,...A}=I,L=$.useBearId("LineChart"),u=b.resolveBearId(R,L),C=`${u}-gradient`,l=a.calculateLinePoints(n),m=a.generateLinePath(l,j&&!h,h),E=l.length===d.ZERO?"":`${m} L ${t.CHART.VIEWBOX},${t.CHART.VIEWBOX} L 0,${t.CHART.VIEWBOX} Z`,H={"--Bear-Chart-height":`${T}px`};return e.jsxs("div",{id:u,"data-testid":g,className:O.cn("Bear-Chart Bear-Chart--line",y),style:H,...A,children:[e.jsxs("svg",{viewBox:`0 0 ${t.CHART.VIEWBOX} ${t.CHART.VIEWBOX}`,preserveAspectRatio:"none",className:"Bear-Chart__svg",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:C,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:r,stopOpacity:"0.3"}),e.jsx("stop",{offset:"100%",stopColor:r,stopOpacity:"0"})]})}),_&&e.jsx("path",{d:E,fill:`url(#${C})`,className:a.chartMotionClass(o,i,"animate-fade-in")}),e.jsx("path",{d:m,fill:"none",stroke:r,strokeWidth:f/d.TEN,strokeLinecap:"round",strokeLinejoin:"round",className:a.chartMotionClass(o,i,"animate-draw-line")}),B&&l.map((s,c)=>{var p;return e.jsx("circle",{cx:s.x,cy:s.y,r:t.CHART.DOT_RADIUS,fill:r,className:a.chartMotionClass(o,i,"animate-scale-in"),style:{animationDelay:`${c*d.FIFTY}ms`}},((p=n[c])==null?void 0:p.label)??c)})]}),x&&e.jsx("div",{className:"Bear-Chart__labels",children:n.map(s=>e.jsx("span",{className:"Bear-Chart__label",children:s.label},s.label))})]})};exports.LineChart=v;
@@ -1,83 +1,84 @@
1
1
  import { jsxs as c, jsx as e } from "react/jsx-runtime";
2
- import { ZERO as v, TEN as W, FIFTY as b } from "../../constants/numbers.const.js";
3
- import { cn as s } from "../../utils/cn.js";
2
+ import { ZERO as W, TEN as b, FIFTY as x } from "../../constants/numbers.const.js";
3
+ import { cn as k } from "../../utils/cn.js";
4
4
  import "react";
5
- import { resolveBearId as x } from "../../utils/generateBearId.utils.js";
6
- import { useBearId as k } from "../../utils/useBearId.js";
7
- import { CHART as a } from "./Chart.const.js";
8
- import { calculateLinePoints as A, generateLinePath as R } from "./Chart.utils.js";
9
- const G = (I) => {
5
+ import { resolveBearId as A } from "../../utils/generateBearId.utils.js";
6
+ import { useBearId as R } from "../../utils/useBearId.js";
7
+ import { CHART as t } from "./Chart.const.js";
8
+ import { calculateLinePoints as V, generateLinePath as X, chartMotionClass as d } from "./Chart.utils.js";
9
+ const Z = (B) => {
10
10
  const {
11
- data: o,
12
- height: B = a.DEFAULT_HEIGHT,
11
+ data: s,
12
+ height: C = t.DEFAULT_HEIGHT,
13
13
  showLabels: y = !0,
14
- showDots: C = !0,
15
- smooth: E = !0,
16
- fill: L = !1,
17
- stepped: d = !1,
18
- strokeWidth: u = a.DEFAULT_STROKE_WIDTH,
14
+ showDots: E = !0,
15
+ smooth: L = !0,
16
+ fill: u = !1,
17
+ stepped: m = !1,
18
+ strokeWidth: O = t.DEFAULT_STROKE_WIDTH,
19
19
  color: r = "var(--bear-primary-500, #ec4899)",
20
- animated: i = !0,
21
- className: O,
22
- id: _,
23
- testId: $,
24
- ...g
25
- } = I, D = k("LineChart"), m = x(_, D), p = `${m}-gradient`, l = A(o), h = R(l, E && !d, d), N = l.length === v ? "" : `${h} L ${a.VIEWBOX},${a.VIEWBOX} L 0,${a.VIEWBOX} Z`, T = { "--Bear-Chart-height": `${B}px` };
20
+ animated: o = !0,
21
+ motion: i,
22
+ className: _,
23
+ id: $,
24
+ testId: g,
25
+ ...D
26
+ } = B, N = R("LineChart"), p = A($, N), h = `${p}-gradient`, l = V(s), f = X(l, L && !m, m), T = l.length === W ? "" : `${f} L ${t.VIEWBOX},${t.VIEWBOX} L 0,${t.VIEWBOX} Z`, v = { "--Bear-Chart-height": `${C}px` };
26
27
  return /* @__PURE__ */ c(
27
28
  "div",
28
29
  {
29
- id: m,
30
- "data-testid": $,
31
- className: s("Bear-Chart Bear-Chart--line", O),
32
- style: T,
33
- ...g,
30
+ id: p,
31
+ "data-testid": g,
32
+ className: k("Bear-Chart Bear-Chart--line", _),
33
+ style: v,
34
+ ...D,
34
35
  children: [
35
- /* @__PURE__ */ c("svg", { viewBox: `0 0 ${a.VIEWBOX} ${a.VIEWBOX}`, preserveAspectRatio: "none", className: "Bear-Chart__svg", children: [
36
- /* @__PURE__ */ e("defs", { children: /* @__PURE__ */ c("linearGradient", { id: p, x1: "0%", y1: "0%", x2: "0%", y2: "100%", children: [
36
+ /* @__PURE__ */ c("svg", { viewBox: `0 0 ${t.VIEWBOX} ${t.VIEWBOX}`, preserveAspectRatio: "none", className: "Bear-Chart__svg", children: [
37
+ /* @__PURE__ */ e("defs", { children: /* @__PURE__ */ c("linearGradient", { id: h, x1: "0%", y1: "0%", x2: "0%", y2: "100%", children: [
37
38
  /* @__PURE__ */ e("stop", { offset: "0%", stopColor: r, stopOpacity: "0.3" }),
38
39
  /* @__PURE__ */ e("stop", { offset: "100%", stopColor: r, stopOpacity: "0" })
39
40
  ] }) }),
40
- L && /* @__PURE__ */ e(
41
+ u && /* @__PURE__ */ e(
41
42
  "path",
42
43
  {
43
- d: N,
44
- fill: `url(#${p})`,
45
- className: s(i && "animate-fade-in")
44
+ d: T,
45
+ fill: `url(#${h})`,
46
+ className: d(o, i, "animate-fade-in")
46
47
  }
47
48
  ),
48
49
  /* @__PURE__ */ e(
49
50
  "path",
50
51
  {
51
- d: h,
52
+ d: f,
52
53
  fill: "none",
53
54
  stroke: r,
54
- strokeWidth: u / W,
55
+ strokeWidth: O / b,
55
56
  strokeLinecap: "round",
56
57
  strokeLinejoin: "round",
57
- className: s(i && "animate-draw-line")
58
+ className: d(o, i, "animate-draw-line")
58
59
  }
59
60
  ),
60
- C && l.map((t, n) => {
61
- var f;
61
+ E && l.map((a, n) => {
62
+ var I;
62
63
  return /* @__PURE__ */ e(
63
64
  "circle",
64
65
  {
65
- cx: t.x,
66
- cy: t.y,
67
- r: a.DOT_RADIUS,
66
+ cx: a.x,
67
+ cy: a.y,
68
+ r: t.DOT_RADIUS,
68
69
  fill: r,
69
- className: s(i && "animate-scale-in"),
70
- style: { animationDelay: `${n * b}ms` }
70
+ className: d(o, i, "animate-scale-in"),
71
+ style: { animationDelay: `${n * x}ms` }
71
72
  },
72
- ((f = o[n]) == null ? void 0 : f.label) ?? n
73
+ ((I = s[n]) == null ? void 0 : I.label) ?? n
73
74
  );
74
75
  })
75
76
  ] }),
76
- y && /* @__PURE__ */ e("div", { className: "Bear-Chart__labels", children: o.map((t) => /* @__PURE__ */ e("span", { className: "Bear-Chart__label", children: t.label }, t.label)) })
77
+ y && /* @__PURE__ */ e("div", { className: "Bear-Chart__labels", children: s.map((a) => /* @__PURE__ */ e("span", { className: "Bear-Chart__label", children: a.label }, a.label)) })
77
78
  ]
78
79
  }
79
80
  );
80
81
  };
81
82
  export {
82
- G as LineChart
83
+ Z as LineChart
83
84
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),J=require("react"),d=require("../../constants/numbers.const.cjs"),_=require("../../utils/cn.cjs"),Q=require("../../utils/generateBearId.utils.cjs"),ee=require("../../utils/useBearId.cjs"),te=require("../Portal/Portal.cjs"),T=require("../Card/Card.cjs"),p=require("../Flex/Flex.cjs"),w=require("../Box/Box.cjs"),D=require("../Typography/Typography.cjs"),t=require("./Chart.const.cjs"),R=require("./Chart.utils.cjs"),ae=S=>{const{data:s,height:y=t.CHART.DEFAULT_HEIGHT,showLabels:f=!0,innerRadius:q=d.ZERO,startAngle:M,padAngle:x=t.CHART.DEFAULT_PAD_ANGLE,animated:U=!0,pieView:I=t.PIE_VIEW_FULL,explodeIndex:V,legendPosition:B="right",onSliceClick:i,onSliceHover:u,showSliceTooltip:m=!0,sliceTooltipTitle:A,sliceTooltipDescription:E,sliceTooltipContent:C,className:O,id:W,testId:b,...H}=S,$=ee.useBearId("PieChart"),v=Q.resolveBearId(W,$),h=s.reduce((e,a)=>e+a.value,d.ZERO),[l,j]=J.useState(null),L=I===t.PIE_VIEW_HALF,N=I===t.PIE_VIEW_ROSE,P=L?t.CHART.HALF_SWEEP:t.CHART.FULL_SWEEP,X=M??(L?t.CHART.HALF_PIE_START:t.CHART.DEFAULT_START_ANGLE),Z=Math.max(...s.map(e=>e.value),d.ONE),G=B===t.CHART_LEGEND_NONE||!f,Y=B===t.CHART_LEGEND_BOTTOM,F=(e,a,c)=>{const o=s[c];if(u==null||u(o,c),!m)return;const n=Math.round(o.value/h*t.CHART.VIEWBOX);j({x:e,y:a,index:c,label:o.label,value:o.value,pct:n})},k=()=>{j(null),u==null||u(null,null)};if(s.length===d.ZERO||h===d.ZERO)return r.jsx(p.Flex,{id:v,"data-testid":b,align:"center",justify:"center",className:_.cn("Bear-Chart Bear-Chart--pie Bear-Chart--empty",O),style:{"--Bear-Chart-height":`${y}px`},...H});let g=X;const z=s.map((e,a)=>{const c=N?P/s.length-x:e.value/h*P-x,o=g,n=g+c;g+=c+x;const K=N?t.CHART.ROSE_MIN_RADIUS+e.value/Z*(t.CHART.OUTER_RADIUS-t.CHART.ROSE_MIN_RADIUS):t.CHART.OUTER_RADIUS;return{startAngle:o,endAngle:n,color:R.getChartColor(a,e.color),outerRadius:K,...e}});return r.jsxs(p.Flex,{id:v,"data-testid":b,direction:Y?"column":"row",align:"center",gap:4,wrap:"wrap",className:_.cn("Bear-Chart Bear-Chart--pie",O),style:{"--Bear-Chart-height":`${y}px`},...H,children:[r.jsx(w.Box,{className:"Bear-Chart__pie-canvas",children:r.jsx("svg",{viewBox:`0 0 ${t.CHART.VIEWBOX} ${t.CHART.VIEWBOX}`,className:"Bear-Chart__svg",children:z.map((e,a)=>{const c=(e.startAngle+e.endAngle)/2,o=V===a?R.polarOffset(c,t.CHART.EXPLODE_OFFSET):{x:d.ZERO,y:d.ZERO};return r.jsx("g",{transform:`translate(${o.x} ${o.y})`,children:r.jsx("path",{d:R.createArcPath(e.startAngle,e.endAngle,q,e.outerRadius),fill:e.color,className:_.cn(i&&"bear-cursor-pointer","bear-transition-opacity hover:bear-opacity-80",U&&"animate-scale-in"),style:{animationDelay:`${a*t.CHART.SLICE_DELAY_MS}ms`},onClick:()=>i==null?void 0:i(s[a],a),tabIndex:0,role:"button","aria-label":`${s[a].label} ${Math.round(s[a].value/h*t.CHART.VIEWBOX)}%`,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),i==null||i(s[a],a))},onMouseEnter:n=>F(n.clientX,n.clientY,a),onMouseMove:n=>F(n.clientX,n.clientY,a),onMouseLeave:k})},e.label)})})}),!G&&r.jsx(p.Flex,{direction:"column",gap:2,children:s.map((e,a)=>r.jsxs(p.Flex,{align:"center",gap:2,children:[r.jsx(w.Box,{className:"Bear-Chart__swatch",style:{"--Bear-Chart-color":R.getChartColor(a,e.color)}}),r.jsx(D.Typography,{variant:"body2",color:"muted",children:e.label}),r.jsxs(D.Typography,{variant:"body2",color:"muted",children:[Math.round(e.value/h*t.CHART.VIEWBOX),"%"]})]},e.label))}),l&&m&&r.jsx(te.Portal,{children:r.jsx("div",{className:"pointer-events-none fixed z-[11500] w-56 max-w-[calc(100vw-24px)]",style:{left:l.x+12,top:l.y+12},children:r.jsxs(T.Card,{variant:"elevated",padding:"none",children:[(A||E)&&r.jsx(T.CardHeader,{title:(A==null?void 0:A(s[l.index],l.index))??l.label,subtitle:E==null?void 0:E(s[l.index],l.index)}),r.jsx(T.CardBody,{className:"bear-text-xs bear-text-gray-500 dark:bear-text-slate-400",children:(C==null?void 0:C(s[l.index],l.index))??r.jsxs("span",{children:[l.value," (",l.pct,"%)"]})})]})})})]})};exports.PieChart=ae;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),Q=require("react"),d=require("../../constants/numbers.const.cjs"),_=require("../../utils/cn.cjs"),ee=require("../../utils/generateBearId.utils.cjs"),te=require("../../utils/useBearId.cjs"),ae=require("../Portal/Portal.cjs"),T=require("../Card/Card.cjs"),C=require("../Flex/Flex.cjs"),w=require("../Box/Box.cjs"),D=require("../Typography/Typography.cjs"),t=require("./Chart.const.cjs"),A=require("./Chart.utils.cjs"),re=M=>{const{data:s,height:y=t.CHART.DEFAULT_HEIGHT,showLabels:S=!0,innerRadius:f=d.ZERO,startAngle:q,padAngle:R=t.CHART.DEFAULT_PAD_ANGLE,animated:U=!0,motion:V,pieView:I=t.PIE_VIEW_FULL,explodeIndex:W,legendPosition:m="right",onSliceClick:i,onSliceHover:u,showSliceTooltip:B=!0,sliceTooltipTitle:E,sliceTooltipDescription:p,sliceTooltipContent:x,className:O,id:$,testId:b,...H}=M,X=te.useBearId("PieChart"),v=ee.resolveBearId($,X),h=s.reduce((e,a)=>e+a.value,d.ZERO),[l,j]=Q.useState(null),L=I===t.PIE_VIEW_HALF,N=I===t.PIE_VIEW_ROSE,P=L?t.CHART.HALF_SWEEP:t.CHART.FULL_SWEEP,Z=q??(L?t.CHART.HALF_PIE_START:t.CHART.DEFAULT_START_ANGLE),G=Math.max(...s.map(e=>e.value),d.ONE),Y=m===t.CHART_LEGEND_NONE||!S,k=m===t.CHART_LEGEND_BOTTOM,F=(e,a,c)=>{const o=s[c];if(u==null||u(o,c),!B)return;const n=Math.round(o.value/h*t.CHART.VIEWBOX);j({x:e,y:a,index:c,label:o.label,value:o.value,pct:n})},z=()=>{j(null),u==null||u(null,null)};if(s.length===d.ZERO||h===d.ZERO)return r.jsx(C.Flex,{id:v,"data-testid":b,align:"center",justify:"center",className:_.cn("Bear-Chart Bear-Chart--pie Bear-Chart--empty",O),style:{"--Bear-Chart-height":`${y}px`},...H});let g=Z;const K=s.map((e,a)=>{const c=N?P/s.length-R:e.value/h*P-R,o=g,n=g+c;g+=c+R;const J=N?t.CHART.ROSE_MIN_RADIUS+e.value/G*(t.CHART.OUTER_RADIUS-t.CHART.ROSE_MIN_RADIUS):t.CHART.OUTER_RADIUS;return{startAngle:o,endAngle:n,color:A.getChartColor(a,e.color),outerRadius:J,...e}});return r.jsxs(C.Flex,{id:v,"data-testid":b,direction:k?"column":"row",align:"center",gap:4,wrap:"wrap",className:_.cn("Bear-Chart Bear-Chart--pie",O),style:{"--Bear-Chart-height":`${y}px`},...H,children:[r.jsx(w.Box,{className:"Bear-Chart__pie-canvas",children:r.jsx("svg",{viewBox:`0 0 ${t.CHART.VIEWBOX} ${t.CHART.VIEWBOX}`,className:"Bear-Chart__svg",children:K.map((e,a)=>{const c=(e.startAngle+e.endAngle)/2,o=W===a?A.polarOffset(c,t.CHART.EXPLODE_OFFSET):{x:d.ZERO,y:d.ZERO};return r.jsx("g",{transform:`translate(${o.x} ${o.y})`,children:r.jsx("path",{d:A.createArcPath(e.startAngle,e.endAngle,f,e.outerRadius),fill:e.color,className:_.cn(i&&"bear-cursor-pointer","bear-transition-opacity hover:bear-opacity-80",A.chartMotionClass(U,V,"animate-scale-in")),style:{animationDelay:`${a*t.CHART.SLICE_DELAY_MS}ms`},onClick:()=>i==null?void 0:i(s[a],a),tabIndex:0,role:"button","aria-label":`${s[a].label} ${Math.round(s[a].value/h*t.CHART.VIEWBOX)}%`,onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),i==null||i(s[a],a))},onMouseEnter:n=>F(n.clientX,n.clientY,a),onMouseMove:n=>F(n.clientX,n.clientY,a),onMouseLeave:z})},e.label)})})}),!Y&&r.jsx(C.Flex,{direction:"column",gap:2,children:s.map((e,a)=>r.jsxs(C.Flex,{align:"center",gap:2,children:[r.jsx(w.Box,{className:"Bear-Chart__swatch",style:{"--Bear-Chart-color":A.getChartColor(a,e.color)}}),r.jsx(D.Typography,{variant:"body2",color:"muted",children:e.label}),r.jsxs(D.Typography,{variant:"body2",color:"muted",children:[Math.round(e.value/h*t.CHART.VIEWBOX),"%"]})]},e.label))}),l&&B&&r.jsx(ae.Portal,{children:r.jsx("div",{className:"pointer-events-none fixed z-[11500] w-56 max-w-[calc(100vw-24px)]",style:{left:l.x+12,top:l.y+12},children:r.jsxs(T.Card,{variant:"elevated",padding:"none",children:[(E||p)&&r.jsx(T.CardHeader,{title:(E==null?void 0:E(s[l.index],l.index))??l.label,subtitle:p==null?void 0:p(s[l.index],l.index)}),r.jsx(T.CardBody,{className:"bear-text-xs bear-text-gray-500 dark:bear-text-slate-400",children:(x==null?void 0:x(s[l.index],l.index))??r.jsxs("span",{children:[l.value," (",l.pct,"%)"]})})]})})})]})};exports.PieChart=re;
@@ -1,17 +1,17 @@
1
1
  import { jsx as l, jsxs as h } from "react/jsx-runtime";
2
- import { useState as J } from "react";
3
- import { ZERO as p, ONE as Q } from "../../constants/numbers.const.js";
2
+ import { useState as Q } from "react";
3
+ import { ZERO as p, ONE as ee } from "../../constants/numbers.const.js";
4
4
  import { cn as f } from "../../utils/cn.js";
5
- import { resolveBearId as ee } from "../../utils/generateBearId.utils.js";
6
- import { useBearId as ae } from "../../utils/useBearId.js";
7
- import { Portal as te } from "../Portal/Portal.js";
8
- import { Card as re, CardHeader as ne, CardBody as oe } from "../Card/Card.js";
5
+ import { resolveBearId as ae } from "../../utils/generateBearId.utils.js";
6
+ import { useBearId as te } from "../../utils/useBearId.js";
7
+ import { Portal as re } from "../Portal/Portal.js";
8
+ import { Card as oe, CardHeader as ne, CardBody as le } from "../Card/Card.js";
9
9
  import { Flex as g } from "../Flex/Flex.js";
10
- import { Box as P } from "../Box/Box.js";
11
- import { Typography as M } from "../Typography/Typography.js";
12
- import { CHART as t, PIE_VIEW_FULL as le, PIE_VIEW_ROSE as se, CHART_LEGEND_NONE as ce, CHART_LEGEND_BOTTOM as ie, PIE_VIEW_HALF as de } from "./Chart.const.js";
13
- import { getChartColor as S, createArcPath as pe, polarOffset as me } from "./Chart.utils.js";
14
- const Le = (F) => {
10
+ import { Box as M } from "../Box/Box.js";
11
+ import { Typography as P } from "../Typography/Typography.js";
12
+ import { CHART as t, PIE_VIEW_FULL as se, PIE_VIEW_ROSE as ce, CHART_LEGEND_NONE as ie, CHART_LEGEND_BOTTOM as de, PIE_VIEW_HALF as pe } from "./Chart.const.js";
13
+ import { getChartColor as S, chartMotionClass as me, createArcPath as he, polarOffset as ue } from "./Chart.utils.js";
14
+ const Re = (F) => {
15
15
  const {
16
16
  data: r,
17
17
  height: y = t.DEFAULT_HEIGHT,
@@ -20,8 +20,9 @@ const Le = (F) => {
20
20
  startAngle: W,
21
21
  padAngle: _ = t.DEFAULT_PAD_ANGLE,
22
22
  animated: $ = !0,
23
- pieView: B = le,
24
- explodeIndex: X,
23
+ motion: X,
24
+ pieView: B = se,
25
+ explodeIndex: H,
25
26
  legendPosition: b = "right",
26
27
  onSliceClick: i,
27
28
  onSliceHover: d,
@@ -30,16 +31,16 @@ const Le = (F) => {
30
31
  sliceTooltipDescription: E,
31
32
  sliceTooltipContent: A,
32
33
  className: x,
33
- id: H,
34
- testId: L,
35
- ...C
36
- } = F, G = ae("PieChart"), R = ee(H, G), m = r.reduce((e, a) => e + a.value, p), [o, N] = J(null), O = B === de, T = B === se, w = O ? t.HALF_SWEEP : t.FULL_SWEEP, j = W ?? (O ? t.HALF_PIE_START : t.DEFAULT_START_ANGLE), Y = Math.max(...r.map((e) => e.value), Q), k = b === ce || !U, z = b === ie, D = (e, a, c) => {
34
+ id: G,
35
+ testId: C,
36
+ ...L
37
+ } = F, j = te("PieChart"), R = ae(G, j), m = r.reduce((e, a) => e + a.value, p), [n, N] = Q(null), O = B === pe, T = B === ce, w = O ? t.HALF_SWEEP : t.FULL_SWEEP, Y = W ?? (O ? t.HALF_PIE_START : t.DEFAULT_START_ANGLE), k = Math.max(...r.map((e) => e.value), ee), z = b === ie || !U, K = b === de, D = (e, a, c) => {
37
38
  const s = r[c];
38
39
  if (d == null || d(s, c), !v)
39
40
  return;
40
- const n = Math.round(s.value / m * t.VIEWBOX);
41
- N({ x: e, y: a, index: c, label: s.label, value: s.value, pct: n });
42
- }, K = () => {
41
+ const o = Math.round(s.value / m * t.VIEWBOX);
42
+ N({ x: e, y: a, index: c, label: s.label, value: s.value, pct: o });
43
+ }, Z = () => {
43
44
  N(null), d == null || d(null, null);
44
45
  };
45
46
  if (r.length === p || m === p)
@@ -47,24 +48,24 @@ const Le = (F) => {
47
48
  g,
48
49
  {
49
50
  id: R,
50
- "data-testid": L,
51
+ "data-testid": C,
51
52
  align: "center",
52
53
  justify: "center",
53
54
  className: f("Bear-Chart Bear-Chart--pie Bear-Chart--empty", x),
54
55
  style: { "--Bear-Chart-height": `${y}px` },
55
- ...C
56
+ ...L
56
57
  }
57
58
  );
58
- let I = j;
59
- const Z = r.map((e, a) => {
60
- const c = T ? w / r.length - _ : e.value / m * w - _, s = I, n = I + c;
59
+ let I = Y;
60
+ const q = r.map((e, a) => {
61
+ const c = T ? w / r.length - _ : e.value / m * w - _, s = I, o = I + c;
61
62
  I += c + _;
62
- const q = T ? t.ROSE_MIN_RADIUS + e.value / Y * (t.OUTER_RADIUS - t.ROSE_MIN_RADIUS) : t.OUTER_RADIUS;
63
+ const J = T ? t.ROSE_MIN_RADIUS + e.value / k * (t.OUTER_RADIUS - t.ROSE_MIN_RADIUS) : t.OUTER_RADIUS;
63
64
  return {
64
65
  startAngle: s,
65
- endAngle: n,
66
+ endAngle: o,
66
67
  color: S(a, e.color),
67
- outerRadius: q,
68
+ outerRadius: J,
68
69
  ...e
69
70
  };
70
71
  });
@@ -72,67 +73,67 @@ const Le = (F) => {
72
73
  g,
73
74
  {
74
75
  id: R,
75
- "data-testid": L,
76
- direction: z ? "column" : "row",
76
+ "data-testid": C,
77
+ direction: K ? "column" : "row",
77
78
  align: "center",
78
79
  gap: 4,
79
80
  wrap: "wrap",
80
81
  className: f("Bear-Chart Bear-Chart--pie", x),
81
82
  style: { "--Bear-Chart-height": `${y}px` },
82
- ...C,
83
+ ...L,
83
84
  children: [
84
- /* @__PURE__ */ l(P, { className: "Bear-Chart__pie-canvas", children: /* @__PURE__ */ l("svg", { viewBox: `0 0 ${t.VIEWBOX} ${t.VIEWBOX}`, className: "Bear-Chart__svg", children: Z.map((e, a) => {
85
- const c = (e.startAngle + e.endAngle) / 2, s = X === a ? me(c, t.EXPLODE_OFFSET) : { x: p, y: p };
85
+ /* @__PURE__ */ l(M, { className: "Bear-Chart__pie-canvas", children: /* @__PURE__ */ l("svg", { viewBox: `0 0 ${t.VIEWBOX} ${t.VIEWBOX}`, className: "Bear-Chart__svg", children: q.map((e, a) => {
86
+ const c = (e.startAngle + e.endAngle) / 2, s = H === a ? ue(c, t.EXPLODE_OFFSET) : { x: p, y: p };
86
87
  return /* @__PURE__ */ l("g", { transform: `translate(${s.x} ${s.y})`, children: /* @__PURE__ */ l(
87
88
  "path",
88
89
  {
89
- d: pe(e.startAngle, e.endAngle, V, e.outerRadius),
90
+ d: he(e.startAngle, e.endAngle, V, e.outerRadius),
90
91
  fill: e.color,
91
92
  className: f(
92
93
  i && "bear-cursor-pointer",
93
94
  "bear-transition-opacity hover:bear-opacity-80",
94
- $ && "animate-scale-in"
95
+ me($, X, "animate-scale-in")
95
96
  ),
96
97
  style: { animationDelay: `${a * t.SLICE_DELAY_MS}ms` },
97
98
  onClick: () => i == null ? void 0 : i(r[a], a),
98
99
  tabIndex: 0,
99
100
  role: "button",
100
101
  "aria-label": `${r[a].label} ${Math.round(r[a].value / m * t.VIEWBOX)}%`,
101
- onKeyDown: (n) => {
102
- (n.key === "Enter" || n.key === " ") && (n.preventDefault(), i == null || i(r[a], a));
102
+ onKeyDown: (o) => {
103
+ (o.key === "Enter" || o.key === " ") && (o.preventDefault(), i == null || i(r[a], a));
103
104
  },
104
- onMouseEnter: (n) => D(n.clientX, n.clientY, a),
105
- onMouseMove: (n) => D(n.clientX, n.clientY, a),
106
- onMouseLeave: K
105
+ onMouseEnter: (o) => D(o.clientX, o.clientY, a),
106
+ onMouseMove: (o) => D(o.clientX, o.clientY, a),
107
+ onMouseLeave: Z
107
108
  }
108
109
  ) }, e.label);
109
110
  }) }) }),
110
- !k && /* @__PURE__ */ l(g, { direction: "column", gap: 2, children: r.map((e, a) => /* @__PURE__ */ h(g, { align: "center", gap: 2, children: [
111
+ !z && /* @__PURE__ */ l(g, { direction: "column", gap: 2, children: r.map((e, a) => /* @__PURE__ */ h(g, { align: "center", gap: 2, children: [
111
112
  /* @__PURE__ */ l(
112
- P,
113
+ M,
113
114
  {
114
115
  className: "Bear-Chart__swatch",
115
116
  style: { "--Bear-Chart-color": S(a, e.color) }
116
117
  }
117
118
  ),
118
- /* @__PURE__ */ l(M, { variant: "body2", color: "muted", children: e.label }),
119
- /* @__PURE__ */ h(M, { variant: "body2", color: "muted", children: [
119
+ /* @__PURE__ */ l(P, { variant: "body2", color: "muted", children: e.label }),
120
+ /* @__PURE__ */ h(P, { variant: "body2", color: "muted", children: [
120
121
  Math.round(e.value / m * t.VIEWBOX),
121
122
  "%"
122
123
  ] })
123
124
  ] }, e.label)) }),
124
- o && v && /* @__PURE__ */ l(te, { children: /* @__PURE__ */ l("div", { className: "pointer-events-none fixed z-[11500] w-56 max-w-[calc(100vw-24px)]", style: { left: o.x + 12, top: o.y + 12 }, children: /* @__PURE__ */ h(re, { variant: "elevated", padding: "none", children: [
125
+ n && v && /* @__PURE__ */ l(re, { children: /* @__PURE__ */ l("div", { className: "pointer-events-none fixed z-[11500] w-56 max-w-[calc(100vw-24px)]", style: { left: n.x + 12, top: n.y + 12 }, children: /* @__PURE__ */ h(oe, { variant: "elevated", padding: "none", children: [
125
126
  (u || E) && /* @__PURE__ */ l(
126
127
  ne,
127
128
  {
128
- title: (u == null ? void 0 : u(r[o.index], o.index)) ?? o.label,
129
- subtitle: E == null ? void 0 : E(r[o.index], o.index)
129
+ title: (u == null ? void 0 : u(r[n.index], n.index)) ?? n.label,
130
+ subtitle: E == null ? void 0 : E(r[n.index], n.index)
130
131
  }
131
132
  ),
132
- /* @__PURE__ */ l(oe, { className: "bear-text-xs bear-text-gray-500 dark:bear-text-slate-400", children: (A == null ? void 0 : A(r[o.index], o.index)) ?? /* @__PURE__ */ h("span", { children: [
133
- o.value,
133
+ /* @__PURE__ */ l(le, { className: "bear-text-xs bear-text-gray-500 dark:bear-text-slate-400", children: (A == null ? void 0 : A(r[n.index], n.index)) ?? /* @__PURE__ */ h("span", { children: [
134
+ n.value,
134
135
  " (",
135
- o.pct,
136
+ n.pct,
136
137
  "%)"
137
138
  ] }) })
138
139
  ] }) }) })
@@ -141,5 +142,5 @@ const Le = (F) => {
141
142
  );
142
143
  };
143
144
  export {
144
- Le as PieChart
145
+ Re as PieChart
145
146
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),c=require("../../constants/numbers.const.cjs"),T=require("../../utils/cn.cjs");require("react");const U=require("../../utils/generateBearId.utils.cjs"),D=require("../../utils/useBearId.cjs"),a=require("./Chart.const.cjs"),l=require("./Chart.utils.cjs"),L=m=>{const{data:n,height:g=a.CHART.DEFAULT_HEIGHT,showLabels:x=!0,showValues:y=!1,animated:p=!0,color:R,className:d,id:H,testId:C,...u}=m,S=D.useBearId("RadarChart"),h=U.resolveBearId(H,S),A=n.length,E={"--Bear-Chart-height":`${g}px`};if(A===c.ZERO)return o.jsx("div",{id:h,"data-testid":C,className:T.cn("Bear-Chart Bear-Chart--radar Bear-Chart--empty",d),style:E,...u});const I=Math.max(...n.map(e=>e.value),c.ONE),i=a.CHART.FULL_SWEEP/A,_=n.map((e,r)=>{const t=a.CHART.DEFAULT_START_ANGLE+r*i,s=e.value/I*a.CHART.OUTER_RADIUS;return l.polarToCartesian(t,s)}),b=_.map(e=>`${e.x},${e.y}`).join(" "),B=Array.from({length:a.CHART.RADAR_RINGS},(e,r)=>{const t=(r+c.ONE)/a.CHART.RADAR_RINGS*a.CHART.OUTER_RADIUS;return Array.from({length:A},(s,N)=>{const O=a.CHART.DEFAULT_START_ANGLE+N*i;return l.polarToCartesian(O,t)})});return o.jsx("div",{id:h,"data-testid":C,className:T.cn("Bear-Chart Bear-Chart--radar",d),style:E,...u,children:o.jsxs("svg",{viewBox:`0 0 ${a.CHART.VIEWBOX} ${a.CHART.VIEWBOX}`,className:"Bear-Chart__svg",children:[B.map((e,r)=>o.jsx("polygon",{points:e.map(t=>`${t.x},${t.y}`).join(" "),fill:"none",stroke:"var(--bear-border-default, #e5e5e5)",strokeWidth:.4},r)),n.map((e,r)=>{const t=a.CHART.DEFAULT_START_ANGLE+r*i,s=l.polarToCartesian(t,a.CHART.OUTER_RADIUS);return o.jsx("line",{x1:a.CHART.CENTER,y1:a.CHART.CENTER,x2:s.x,y2:s.y,stroke:"var(--bear-border-default, #e5e5e5)",strokeWidth:.4},e.label)}),o.jsx("polygon",{points:b,fill:l.getChartColor(c.ZERO,R),fillOpacity:.25,stroke:l.getChartColor(c.ZERO,R),strokeWidth:.8,className:T.cn(p&&"animate-scale-in")}),_.map((e,r)=>o.jsx("circle",{cx:e.x,cy:e.y,r:a.CHART.DOT_RADIUS,fill:l.getChartColor(r,n[r].color||R)},n[r].label)),x&&n.map((e,r)=>{const t=a.CHART.DEFAULT_START_ANGLE+r*i,s=l.polarToCartesian(t,a.CHART.OUTER_RADIUS+a.CHART.RADAR_LABEL_OFFSET);return o.jsxs("text",{x:s.x,y:s.y,textAnchor:"middle",dominantBaseline:"middle",className:"bear-fill-[var(--bear-text-secondary)]",fontSize:4,children:[e.label,y?` ${e.value}`:""]},`${e.label}-label`)})]})})};exports.RadarChart=L;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),i=require("../../constants/numbers.const.cjs"),_=require("../../utils/cn.cjs");require("react");const D=require("../../utils/generateBearId.utils.cjs"),L=require("../../utils/useBearId.cjs"),a=require("./Chart.const.cjs"),n=require("./Chart.utils.cjs"),f=m=>{const{data:l,height:g=a.CHART.DEFAULT_HEIGHT,showLabels:x=!0,showValues:y=!1,animated:p=!0,motion:H,color:R,className:T,id:S,testId:d,...C}=m,I=L.useBearId("RadarChart"),u=D.resolveBearId(S,I),A=l.length,h={"--Bear-Chart-height":`${g}px`};if(A===i.ZERO)return o.jsx("div",{id:u,"data-testid":d,className:_.cn("Bear-Chart Bear-Chart--radar Bear-Chart--empty",T),style:h,...C});const b=Math.max(...l.map(e=>e.value),i.ONE),c=a.CHART.FULL_SWEEP/A,E=l.map((e,r)=>{const t=a.CHART.DEFAULT_START_ANGLE+r*c,s=e.value/b*a.CHART.OUTER_RADIUS;return n.polarToCartesian(t,s)}),B=E.map(e=>`${e.x},${e.y}`).join(" "),N=Array.from({length:a.CHART.RADAR_RINGS},(e,r)=>{const t=(r+i.ONE)/a.CHART.RADAR_RINGS*a.CHART.OUTER_RADIUS;return Array.from({length:A},(s,O)=>{const U=a.CHART.DEFAULT_START_ANGLE+O*c;return n.polarToCartesian(U,t)})});return o.jsx("div",{id:u,"data-testid":d,className:_.cn("Bear-Chart Bear-Chart--radar",T),style:h,...C,children:o.jsxs("svg",{viewBox:`0 0 ${a.CHART.VIEWBOX} ${a.CHART.VIEWBOX}`,className:"Bear-Chart__svg",children:[N.map((e,r)=>o.jsx("polygon",{points:e.map(t=>`${t.x},${t.y}`).join(" "),fill:"none",stroke:"var(--bear-border-default, #e5e5e5)",strokeWidth:.4},r)),l.map((e,r)=>{const t=a.CHART.DEFAULT_START_ANGLE+r*c,s=n.polarToCartesian(t,a.CHART.OUTER_RADIUS);return o.jsx("line",{x1:a.CHART.CENTER,y1:a.CHART.CENTER,x2:s.x,y2:s.y,stroke:"var(--bear-border-default, #e5e5e5)",strokeWidth:.4},e.label)}),o.jsx("polygon",{points:B,fill:n.getChartColor(i.ZERO,R),fillOpacity:.25,stroke:n.getChartColor(i.ZERO,R),strokeWidth:.8,className:n.chartMotionClass(p,H,"animate-scale-in")}),E.map((e,r)=>o.jsx("circle",{cx:e.x,cy:e.y,r:a.CHART.DOT_RADIUS,fill:n.getChartColor(r,l[r].color||R)},l[r].label)),x&&l.map((e,r)=>{const t=a.CHART.DEFAULT_START_ANGLE+r*c,s=n.polarToCartesian(t,a.CHART.OUTER_RADIUS+a.CHART.RADAR_LABEL_OFFSET);return o.jsxs("text",{x:s.x,y:s.y,textAnchor:"middle",dominantBaseline:"middle",className:"bear-fill-[var(--bear-text-secondary)]",fontSize:4,children:[e.label,y?` ${e.value}`:""]},`${e.label}-label`)})]})})};exports.RadarChart=f;