@forgedevstack/bear 1.3.3 → 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.
- package/README.md +100 -290
- package/dist/components/Alert/Alert.cjs +1 -1
- package/dist/components/Alert/Alert.const.cjs +1 -1
- package/dist/components/Alert/Alert.const.d.ts +1 -6
- package/dist/components/Alert/Alert.const.js +10 -30
- package/dist/components/Alert/Alert.js +49 -54
- package/dist/components/AlertDialog/AlertDialog.cjs +1 -1
- package/dist/components/AlertDialog/AlertDialog.js +67 -84
- package/dist/components/BottomSheet/BottomSheet.cjs +1 -1
- package/dist/components/BottomSheet/BottomSheet.js +72 -64
- package/dist/components/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.js +122 -112
- package/dist/components/Chart/BarChart.cjs +1 -1
- package/dist/components/Chart/BarChart.js +37 -36
- package/dist/components/Chart/Chart.types.d.ts +2 -0
- package/dist/components/Chart/Chart.utils.cjs +1 -1
- package/dist/components/Chart/Chart.utils.d.ts +2 -0
- package/dist/components/Chart/Chart.utils.js +32 -31
- package/dist/components/Chart/FunnelChart.cjs +1 -1
- package/dist/components/Chart/FunnelChart.js +29 -28
- package/dist/components/Chart/LineChart.cjs +1 -1
- package/dist/components/Chart/LineChart.js +45 -44
- package/dist/components/Chart/PieChart.cjs +1 -1
- package/dist/components/Chart/PieChart.js +52 -51
- package/dist/components/Chart/RadarChart.cjs +1 -1
- package/dist/components/Chart/RadarChart.js +63 -62
- package/dist/components/Chart/index.d.ts +1 -1
- package/dist/components/ChipGroup/ChipGroup.cjs +1 -1
- package/dist/components/ChipGroup/ChipGroup.const.cjs +1 -1
- package/dist/components/ChipGroup/ChipGroup.const.d.ts +2 -0
- package/dist/components/ChipGroup/ChipGroup.const.js +6 -4
- package/dist/components/ChipGroup/ChipGroup.js +52 -48
- package/dist/components/CommandPalette/CommandItem.cjs +1 -0
- package/dist/components/CommandPalette/CommandItem.d.ts +6 -0
- package/dist/components/CommandPalette/CommandItem.js +39 -0
- package/dist/components/CommandPalette/CommandPalette.cjs +1 -1
- package/dist/components/CommandPalette/CommandPalette.js +129 -144
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +72 -66
- package/dist/components/EmptyState/EmptyState.cjs +1 -1
- package/dist/components/EmptyState/EmptyState.const.cjs +1 -1
- package/dist/components/EmptyState/EmptyState.const.d.ts +5 -0
- package/dist/components/EmptyState/EmptyState.const.js +30 -15
- package/dist/components/EmptyState/EmptyState.js +35 -35
- package/dist/components/EmptyState/EmptyState.types.d.ts +2 -2
- package/dist/components/HoverCard/HoverCard.cjs +4 -3
- package/dist/components/HoverCard/HoverCard.const.cjs +1 -0
- package/dist/components/HoverCard/HoverCard.const.d.ts +1 -0
- package/dist/components/HoverCard/HoverCard.const.js +5 -0
- package/dist/components/HoverCard/HoverCard.js +62 -56
- package/dist/components/HoverCard/HoverCard.types.d.ts +7 -0
- package/dist/components/Menu/Menu.cjs +1 -1
- package/dist/components/Menu/Menu.const.cjs +1 -0
- package/dist/components/Menu/Menu.const.d.ts +2 -0
- package/dist/components/Menu/Menu.const.js +7 -0
- package/dist/components/Menu/Menu.d.ts +3 -9
- package/dist/components/Menu/Menu.js +57 -89
- package/dist/components/Menu/Menu.types.d.ts +8 -1
- package/dist/components/Menu/MenuDivider.cjs +1 -0
- package/dist/components/Menu/MenuDivider.d.ts +6 -0
- package/dist/components/Menu/MenuDivider.js +7 -0
- package/dist/components/Menu/MenuItem.cjs +1 -0
- package/dist/components/Menu/MenuItem.d.ts +6 -0
- package/dist/components/Menu/MenuItem.js +46 -0
- package/dist/components/Modal/Modal.cjs +1 -1
- package/dist/components/Modal/Modal.const.cjs +1 -1
- package/dist/components/Modal/Modal.const.d.ts +1 -0
- package/dist/components/Modal/Modal.const.js +15 -12
- package/dist/components/Modal/Modal.js +62 -59
- package/dist/components/Modal/Modal.types.d.ts +7 -0
- package/dist/components/ModalsProvider/components/StackedModal/StackedModal.cjs +1 -1
- package/dist/components/ModalsProvider/components/StackedModal/StackedModal.js +10 -9
- package/dist/components/OverlayPortal/OverlayPortal.cjs +1 -1
- package/dist/components/OverlayPortal/OverlayPortal.const.cjs +1 -1
- package/dist/components/OverlayPortal/OverlayPortal.const.d.ts +4 -0
- package/dist/components/OverlayPortal/OverlayPortal.const.js +21 -5
- package/dist/components/OverlayPortal/OverlayPortal.js +44 -38
- package/dist/components/Popover/Popover.cjs +1 -1
- package/dist/components/Popover/Popover.const.cjs +1 -0
- package/dist/components/Popover/Popover.const.d.ts +15 -1
- package/dist/components/Popover/Popover.const.js +24 -0
- package/dist/components/Popover/Popover.js +77 -73
- package/dist/components/Popover/Popover.types.d.ts +7 -0
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.const.cjs +1 -1
- package/dist/components/Select/Select.const.d.ts +1 -0
- package/dist/components/Select/Select.const.js +7 -6
- package/dist/components/Select/Select.js +101 -96
- package/dist/components/Tabs/TabList.cjs +1 -1
- package/dist/components/Tabs/TabList.js +1 -1
- package/dist/components/Toast/Toast.cjs +1 -1
- package/dist/components/Toast/Toast.const.cjs +1 -1
- package/dist/components/Toast/Toast.const.d.ts +2 -0
- package/dist/components/Toast/Toast.const.js +11 -8
- package/dist/components/Toast/Toast.context.cjs +1 -0
- package/dist/components/Toast/Toast.context.d.ts +3 -0
- package/dist/components/Toast/Toast.context.js +11 -0
- package/dist/components/Toast/Toast.d.ts +4 -3
- package/dist/components/Toast/Toast.icons.cjs +1 -0
- package/dist/components/Toast/Toast.icons.d.ts +4 -0
- package/dist/components/Toast/Toast.icons.js +29 -0
- package/dist/components/Toast/Toast.js +32 -160
- package/dist/components/Toast/ToastContainer.cjs +1 -0
- package/dist/components/Toast/ToastContainer.d.ts +3 -0
- package/dist/components/Toast/ToastContainer.js +39 -0
- package/dist/components/Toast/ToastItem.cjs +1 -0
- package/dist/components/Toast/ToastItem.d.ts +5 -0
- package/dist/components/Toast/ToastItem.js +86 -0
- package/dist/components/ToggleGroup/ToggleGroup.cjs +1 -0
- package/dist/components/ToggleGroup/ToggleGroup.const.cjs +1 -0
- package/dist/components/ToggleGroup/ToggleGroup.const.d.ts +15 -0
- package/dist/components/ToggleGroup/ToggleGroup.const.js +33 -0
- package/dist/components/ToggleGroup/ToggleGroup.context.cjs +1 -0
- package/dist/components/ToggleGroup/ToggleGroup.context.d.ts +2 -0
- package/dist/components/ToggleGroup/ToggleGroup.context.js +5 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +2 -0
- package/dist/components/ToggleGroup/ToggleGroup.js +89 -0
- package/dist/components/ToggleGroup/ToggleGroup.types.d.ts +48 -0
- package/dist/components/ToggleGroup/ToggleGroupItem.cjs +1 -0
- package/dist/components/ToggleGroup/ToggleGroupItem.d.ts +2 -0
- package/dist/components/ToggleGroup/ToggleGroupItem.js +50 -0
- package/dist/components/ToggleGroup/hooks/useToggleGroupContext.cjs +1 -0
- package/dist/components/ToggleGroup/hooks/useToggleGroupContext.d.ts +1 -0
- package/dist/components/ToggleGroup/hooks/useToggleGroupContext.js +6 -0
- package/dist/components/ToggleGroup/index.d.ts +4 -0
- package/dist/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/components/Tooltip/Tooltip.const.cjs +1 -0
- package/dist/components/Tooltip/Tooltip.const.d.ts +8 -0
- package/dist/components/Tooltip/Tooltip.const.js +13 -0
- package/dist/components/Tooltip/Tooltip.js +59 -61
- package/dist/components/Tooltip/Tooltip.types.d.ts +7 -0
- package/dist/components/Transition/Transition.cjs +1 -1
- package/dist/components/Transition/Transition.const.cjs +1 -1
- package/dist/components/Transition/Transition.const.js +26 -8
- package/dist/components/Transition/Transition.js +77 -74
- package/dist/components/Transition/Transition.types.d.ts +8 -2
- package/dist/components/Typography/Typography.const.cjs +1 -1
- package/dist/components/Typography/Typography.const.js +2 -1
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.js +429 -419
- package/dist/constants/generals.const.cjs +1 -1
- package/dist/constants/generals.const.js +85 -86
- package/dist/constants/numbers.const.cjs +1 -1
- package/dist/constants/numbers.const.d.ts +3 -0
- package/dist/constants/numbers.const.js +37 -34
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +6 -4
- package/dist/hooks/useFixedAnchorPosition/index.d.ts +1 -1
- package/dist/hooks/useFixedAnchorPosition/useFixedAnchorPosition.const.cjs +1 -1
- package/dist/hooks/useFixedAnchorPosition/useFixedAnchorPosition.const.d.ts +3 -0
- package/dist/hooks/useFixedAnchorPosition/useFixedAnchorPosition.const.js +17 -14
- package/dist/hooks/useFixedAnchorPosition/useFixedAnchorPosition.types.d.ts +1 -1
- package/dist/hooks/useFocusTrap/index.d.ts +2 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.cjs +1 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.d.ts +3 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.js +41 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.types.d.ts +8 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.utils.cjs +1 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.utils.d.ts +1 -0
- package/dist/hooks/useFocusTrap/useFocusTrap.utils.js +23 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +580 -568
- package/dist/styles/_alerts.css +85 -4
- package/dist/styles/_drawer.css +60 -0
- package/dist/styles/_effects.css +33 -0
- package/dist/styles.css +231 -4
- 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
|
|
6
|
-
import { useBearId as
|
|
7
|
-
import { Box as
|
|
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
|
|
10
|
-
import { CHART as
|
|
11
|
-
import { getChartColor as T } from "./Chart.utils.js";
|
|
12
|
-
const
|
|
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 =
|
|
15
|
+
height: i = r.DEFAULT_HEIGHT,
|
|
16
16
|
showLabels: c = !0,
|
|
17
17
|
showValues: h = !0,
|
|
18
18
|
animated: d = !0,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
motion: p,
|
|
20
|
+
color: u,
|
|
21
|
+
className: f,
|
|
22
|
+
id: C,
|
|
22
23
|
testId: g,
|
|
23
24
|
...B
|
|
24
|
-
} = m,
|
|
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:
|
|
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",
|
|
34
|
-
style:
|
|
34
|
+
className: n("Bear-Chart Bear-Chart--funnel", f),
|
|
35
|
+
style: y,
|
|
35
36
|
...B,
|
|
36
|
-
children: e.map((
|
|
37
|
-
const
|
|
38
|
-
"--Bear-Chart-size": `${Math.max(
|
|
39
|
-
"--Bear-Chart-step-height": `${
|
|
40
|
-
"--Bear-Chart-color": T(
|
|
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
|
-
|
|
45
|
+
F,
|
|
45
46
|
{
|
|
46
|
-
className: n("Bear-Chart__funnel-step bear-rounded-md", d
|
|
47
|
-
style:
|
|
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(
|
|
51
|
-
|
|
52
|
-
h ? ` · ${
|
|
51
|
+
c && /* @__PURE__ */ o(M, { variant: "caption", color: "muted", children: [
|
|
52
|
+
t.label,
|
|
53
|
+
h ? ` · ${t.value}` : ""
|
|
53
54
|
] })
|
|
54
|
-
] },
|
|
55
|
+
] }, t.label);
|
|
55
56
|
})
|
|
56
57
|
}
|
|
57
58
|
);
|
|
58
59
|
};
|
|
59
60
|
export {
|
|
60
|
-
|
|
61
|
+
X as FunnelChart
|
|
61
62
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
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
|
|
3
|
-
import { cn as
|
|
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
|
|
6
|
-
import { useBearId as
|
|
7
|
-
import { CHART as
|
|
8
|
-
import { calculateLinePoints as
|
|
9
|
-
const
|
|
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:
|
|
12
|
-
height:
|
|
11
|
+
data: s,
|
|
12
|
+
height: C = t.DEFAULT_HEIGHT,
|
|
13
13
|
showLabels: y = !0,
|
|
14
|
-
showDots:
|
|
15
|
-
smooth:
|
|
16
|
-
fill:
|
|
17
|
-
stepped:
|
|
18
|
-
strokeWidth:
|
|
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:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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:
|
|
30
|
-
"data-testid":
|
|
31
|
-
className:
|
|
32
|
-
style:
|
|
33
|
-
...
|
|
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 ${
|
|
36
|
-
/* @__PURE__ */ e("defs", { children: /* @__PURE__ */ c("linearGradient", { id:
|
|
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
|
-
|
|
41
|
+
u && /* @__PURE__ */ e(
|
|
41
42
|
"path",
|
|
42
43
|
{
|
|
43
|
-
d:
|
|
44
|
-
fill: `url(#${
|
|
45
|
-
className:
|
|
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:
|
|
52
|
+
d: f,
|
|
52
53
|
fill: "none",
|
|
53
54
|
stroke: r,
|
|
54
|
-
strokeWidth:
|
|
55
|
+
strokeWidth: O / b,
|
|
55
56
|
strokeLinecap: "round",
|
|
56
57
|
strokeLinejoin: "round",
|
|
57
|
-
className:
|
|
58
|
+
className: d(o, i, "animate-draw-line")
|
|
58
59
|
}
|
|
59
60
|
),
|
|
60
|
-
|
|
61
|
-
var
|
|
61
|
+
E && l.map((a, n) => {
|
|
62
|
+
var I;
|
|
62
63
|
return /* @__PURE__ */ e(
|
|
63
64
|
"circle",
|
|
64
65
|
{
|
|
65
|
-
cx:
|
|
66
|
-
cy:
|
|
67
|
-
r:
|
|
66
|
+
cx: a.x,
|
|
67
|
+
cy: a.y,
|
|
68
|
+
r: t.DOT_RADIUS,
|
|
68
69
|
fill: r,
|
|
69
|
-
className:
|
|
70
|
-
style: { animationDelay: `${n *
|
|
70
|
+
className: d(o, i, "animate-scale-in"),
|
|
71
|
+
style: { animationDelay: `${n * x}ms` }
|
|
71
72
|
},
|
|
72
|
-
((
|
|
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:
|
|
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
|
-
|
|
83
|
+
Z as LineChart
|
|
83
84
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),
|
|
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
|
|
3
|
-
import { ZERO as p, ONE as
|
|
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
|
|
6
|
-
import { useBearId as
|
|
7
|
-
import { Portal as
|
|
8
|
-
import { Card as
|
|
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
|
|
11
|
-
import { Typography as
|
|
12
|
-
import { CHART as t, PIE_VIEW_FULL as
|
|
13
|
-
import { getChartColor as S, createArcPath as
|
|
14
|
-
const
|
|
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
|
-
|
|
24
|
-
|
|
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:
|
|
34
|
-
testId:
|
|
35
|
-
...
|
|
36
|
-
} = F,
|
|
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
|
|
41
|
-
N({ x: e, y: a, index: c, label: s.label, value: s.value, pct:
|
|
42
|
-
},
|
|
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":
|
|
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
|
-
...
|
|
56
|
+
...L
|
|
56
57
|
}
|
|
57
58
|
);
|
|
58
|
-
let I =
|
|
59
|
-
const
|
|
60
|
-
const c = T ? w / r.length - _ : e.value / m * w - _, s = I,
|
|
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
|
|
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:
|
|
66
|
+
endAngle: o,
|
|
66
67
|
color: S(a, e.color),
|
|
67
|
-
outerRadius:
|
|
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":
|
|
76
|
-
direction:
|
|
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
|
-
...
|
|
83
|
+
...L,
|
|
83
84
|
children: [
|
|
84
|
-
/* @__PURE__ */ l(
|
|
85
|
-
const c = (e.startAngle + e.endAngle) / 2, s =
|
|
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:
|
|
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
|
-
|
|
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: (
|
|
102
|
-
(
|
|
102
|
+
onKeyDown: (o) => {
|
|
103
|
+
(o.key === "Enter" || o.key === " ") && (o.preventDefault(), i == null || i(r[a], a));
|
|
103
104
|
},
|
|
104
|
-
onMouseEnter: (
|
|
105
|
-
onMouseMove: (
|
|
106
|
-
onMouseLeave:
|
|
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
|
-
!
|
|
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
|
-
|
|
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(
|
|
119
|
-
/* @__PURE__ */ h(
|
|
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
|
-
|
|
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[
|
|
129
|
-
subtitle: E == null ? void 0 : E(r[
|
|
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(
|
|
133
|
-
|
|
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
|
-
|
|
136
|
+
n.pct,
|
|
136
137
|
"%)"
|
|
137
138
|
] }) })
|
|
138
139
|
] }) }) })
|
|
@@ -141,5 +142,5 @@ const Le = (F) => {
|
|
|
141
142
|
);
|
|
142
143
|
};
|
|
143
144
|
export {
|
|
144
|
-
|
|
145
|
+
Re as PieChart
|
|
145
146
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),
|
|
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;
|