@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.
- package/README.md +112 -155
- 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/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/HoverCard/HoverCard.const.cjs +1 -1
- package/dist/components/HoverCard/HoverCard.const.js +3 -8
- package/dist/components/Menu/Menu.const.cjs +1 -1
- package/dist/components/Menu/Menu.const.js +5 -10
- package/dist/components/Modal/Modal.const.cjs +1 -1
- package/dist/components/Modal/Modal.const.js +14 -19
- 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.const.cjs +1 -1
- package/dist/components/Popover/Popover.const.js +14 -19
- package/dist/components/Tabs/TabList.cjs +1 -1
- package/dist/components/Tabs/TabList.js +1 -1
- package/dist/components/ToggleGroup/ToggleGroup.cjs +1 -1
- package/dist/components/ToggleGroup/ToggleGroup.js +49 -46
- package/dist/components/Tooltip/Tooltip.const.cjs +1 -1
- package/dist/components/Tooltip/Tooltip.const.js +10 -15
- 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 +1 -1
- package/dist/components/index.js +1 -1
- package/dist/constants/generals.const.cjs +1 -1
- package/dist/constants/generals.const.js +85 -86
- 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/index.cjs +1 -1
- package/dist/index.js +557 -557
- 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 +179 -4
- package/package.json +3 -5
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { ZERO as
|
|
4
|
-
import { BOOLEAN_TRUE as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { useBearStyles as
|
|
1
|
+
import { jsxs as c, Fragment as we, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as A, useCallback as m } from "react";
|
|
3
|
+
import { ZERO as oe } from "../../constants/numbers.const.js";
|
|
4
|
+
import { BOOLEAN_TRUE as De } from "../../constants/generals.const.js";
|
|
5
|
+
import { cn as M } from "../../utils/cn.js";
|
|
6
|
+
import { useBearStyles as Oe } from "../../hooks/useBearStyles.js";
|
|
7
7
|
import "../../hooks/useBearComponent/useBearComponent.js";
|
|
8
8
|
import "../../context/BearProvider.js";
|
|
9
9
|
import { OVERLAY_OPEN_EFFECT_NONE as l } from "../../hooks/useFixedAnchorPosition/useFixedAnchorPosition.const.js";
|
|
10
|
-
import { resolveOverlayEffects as
|
|
10
|
+
import { resolveOverlayEffects as Te } from "../../hooks/useFixedAnchorPosition/useFixedAnchorPosition.utils.js";
|
|
11
11
|
import "../FormControl/FormControl.context.js";
|
|
12
|
-
import { ChevronsLeftIcon as
|
|
13
|
-
import { OVERLAY_EFFECT_TRANSITION as
|
|
14
|
-
import { Transition as
|
|
15
|
-
import { DEFAULT_DURATION as
|
|
12
|
+
import { ChevronsLeftIcon as Pe, ChevronLeftIcon as Le, ChevronRightIcon as Re, ChevronsRightIcon as Ye } from "@forgedevstack/bear-icons";
|
|
13
|
+
import { OVERLAY_EFFECT_TRANSITION as S } from "../OverlayPortal/OverlayPortal.const.js";
|
|
14
|
+
import { Transition as ie } from "../Transition/Transition.js";
|
|
15
|
+
import { DEFAULT_DURATION as be } from "../Transition/Transition.const.js";
|
|
16
16
|
import { DEFAULT_WEEKDAYS as Ae, NUMBER as d, CALENDAR_DROPDOWN_Z_INDEX as Me, MONTHS as Se, WEEKEND_LABELS as We } from "./Calendar.const.js";
|
|
17
17
|
import { isSameDay as _, buildCalendarGrid as Fe, reorderWeekdays as Ie, isWeekendDay as je } from "./Calendar.utils.js";
|
|
18
18
|
import { DefaultHeaderLabel as He } from "./Calendar.helpers.js";
|
|
19
|
-
const
|
|
19
|
+
const cr = (W) => {
|
|
20
20
|
const {
|
|
21
|
-
viewDate:
|
|
22
|
-
value:
|
|
21
|
+
viewDate: F,
|
|
22
|
+
value: I = null,
|
|
23
23
|
onSelect: C,
|
|
24
24
|
onViewChange: n,
|
|
25
25
|
minDate: z,
|
|
26
26
|
maxDate: g,
|
|
27
|
-
disabledDates:
|
|
28
|
-
highlightedDates:
|
|
29
|
-
weekdayLabels:
|
|
30
|
-
firstDayOfWeek:
|
|
27
|
+
disabledDates: j = [],
|
|
28
|
+
highlightedDates: H = [],
|
|
29
|
+
weekdayLabels: U = Ae,
|
|
30
|
+
firstDayOfWeek: x = d.ZERO,
|
|
31
31
|
showWeekNumbers: Ue = !1,
|
|
32
32
|
slots: e = {},
|
|
33
|
-
clearable:
|
|
33
|
+
clearable: de = !0,
|
|
34
34
|
onClear: h,
|
|
35
|
-
showTodayButton:
|
|
35
|
+
showTodayButton: se = !0,
|
|
36
36
|
onToday: u,
|
|
37
|
-
bis:
|
|
38
|
-
style:
|
|
39
|
-
inline:
|
|
40
|
-
className:
|
|
41
|
-
open:
|
|
42
|
-
} =
|
|
37
|
+
bis: ce,
|
|
38
|
+
style: le,
|
|
39
|
+
inline: G = !1,
|
|
40
|
+
className: me,
|
|
41
|
+
open: Z
|
|
42
|
+
} = W, { openEffect: y, closeEffect: v } = Te(W), i = F.getFullYear(), K = Oe(ce, le), b = F.getMonth(), he = A(() => /* @__PURE__ */ new Date(), []), B = m(() => {
|
|
43
43
|
n == null || n(new Date(i - d.ONE, b, d.ONE));
|
|
44
|
-
}, [i, b, n]),
|
|
44
|
+
}, [i, b, n]), X = m(() => {
|
|
45
45
|
n == null || n(new Date(i, b - d.ONE, d.ONE));
|
|
46
|
-
}, [i, b, n]),
|
|
46
|
+
}, [i, b, n]), q = m(() => {
|
|
47
47
|
n == null || n(new Date(i, b + d.ONE, d.ONE));
|
|
48
48
|
}, [i, b, n]), E = m(() => {
|
|
49
49
|
n == null || n(new Date(i + d.ONE, b, d.ONE));
|
|
50
|
-
}, [i, b, n]),
|
|
50
|
+
}, [i, b, n]), w = X, D = q, ue = {
|
|
51
51
|
onPrevYear: B,
|
|
52
|
-
onPrevMonth:
|
|
53
|
-
onNextMonth:
|
|
52
|
+
onPrevMonth: X,
|
|
53
|
+
onNextMonth: q,
|
|
54
54
|
onNextYear: E
|
|
55
|
-
},
|
|
56
|
-
(
|
|
57
|
-
[z, g,
|
|
58
|
-
),
|
|
59
|
-
(
|
|
60
|
-
[
|
|
61
|
-
),
|
|
62
|
-
() => Fe(i, b,
|
|
63
|
-
[i, b,
|
|
64
|
-
),
|
|
65
|
-
() => Ie(
|
|
66
|
-
[
|
|
67
|
-
),
|
|
55
|
+
}, ye = m(
|
|
56
|
+
(t) => z && t < z || g && t > g ? !0 : j.some((r) => _(r, t)),
|
|
57
|
+
[z, g, j]
|
|
58
|
+
), ve = m(
|
|
59
|
+
(t) => H.some((r) => _(r, t)),
|
|
60
|
+
[H]
|
|
61
|
+
), pe = A(
|
|
62
|
+
() => Fe(i, b, x),
|
|
63
|
+
[i, b, x]
|
|
64
|
+
), J = A(
|
|
65
|
+
() => Ie(U, x),
|
|
66
|
+
[U, x]
|
|
67
|
+
), Q = Se[b], O = I != null, ke = G ? "Bear-Calendar Bear-Calendar--inline bear-block bear-w-full bear-bg-white dark:bear-bg-zinc-900 bear-rounded-xl bear-shadow-none bear-border bear-border-zinc-200 dark:bear-border-zinc-700 bear-p-4 bear-text-zinc-900 dark:bear-text-zinc-100" : "Bear-Calendar Bear-Calendar--dropdown bear-mt-2 bear-bg-white dark:bear-bg-zinc-900 bear-rounded-xl bear-shadow-xl bear-border bear-border-zinc-200 dark:bear-border-zinc-700 bear-p-4 bear-w-80 bear-text-zinc-900 dark:bear-text-zinc-100", $ = G ? void 0 : { zIndex: Me }, xe = () => {
|
|
68
68
|
if (e.header)
|
|
69
|
-
return e.header({ month:
|
|
70
|
-
const
|
|
71
|
-
return /* @__PURE__ */
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
-
|
|
69
|
+
return e.header({ month: Q, year: i, onPrev: w, onNext: D, nav: ue });
|
|
70
|
+
const t = e.navPrevYear, r = e.navPrev, o = e.navNext, s = e.navNextYear, f = e.headerLabel || He;
|
|
71
|
+
return /* @__PURE__ */ c("div", { className: "Bear-Calendar__header bear-flex bear-items-center bear-justify-between bear-gap-1 bear-mb-4", children: [
|
|
72
|
+
/* @__PURE__ */ c("div", { className: "Bear-Calendar__nav-left bear-flex bear-items-center bear-gap-0.5", children: [
|
|
73
|
+
t ? t({ onClick: B }) : /* @__PURE__ */ a(
|
|
74
74
|
"button",
|
|
75
75
|
{
|
|
76
76
|
type: "button",
|
|
77
77
|
onClick: B,
|
|
78
78
|
className: "Bear-Calendar__nav-btn bear-p-1.5 bear-rounded bear-text-zinc-500 dark:bear-text-zinc-400 hover:bear-bg-zinc-100 dark:hover:bear-bg-zinc-800 bear-transition-colors",
|
|
79
79
|
"aria-label": "Previous year",
|
|
80
|
-
children: /* @__PURE__ */
|
|
80
|
+
children: /* @__PURE__ */ a(Pe, { size: 16 })
|
|
81
81
|
}
|
|
82
82
|
),
|
|
83
|
-
r ? r({ onClick:
|
|
83
|
+
r ? r({ onClick: w }) : /* @__PURE__ */ a(
|
|
84
84
|
"button",
|
|
85
85
|
{
|
|
86
86
|
type: "button",
|
|
87
|
-
onClick:
|
|
87
|
+
onClick: w,
|
|
88
88
|
className: "Bear-Calendar__nav-btn bear-p-1.5 bear-rounded bear-text-zinc-500 dark:bear-text-zinc-400 hover:bear-bg-zinc-100 dark:hover:bear-bg-zinc-800 bear-transition-colors",
|
|
89
89
|
"aria-label": "Previous month",
|
|
90
|
-
children: /* @__PURE__ */
|
|
90
|
+
children: /* @__PURE__ */ a(Le, { size: 16 })
|
|
91
91
|
}
|
|
92
92
|
)
|
|
93
93
|
] }),
|
|
94
|
-
f({ month:
|
|
95
|
-
/* @__PURE__ */
|
|
96
|
-
o ? o({ onClick:
|
|
94
|
+
f({ month: Q, year: i }),
|
|
95
|
+
/* @__PURE__ */ c("div", { className: "Bear-Calendar__nav-right bear-flex bear-items-center bear-gap-0.5", children: [
|
|
96
|
+
o ? o({ onClick: D }) : /* @__PURE__ */ a(
|
|
97
97
|
"button",
|
|
98
98
|
{
|
|
99
99
|
type: "button",
|
|
100
|
-
onClick:
|
|
100
|
+
onClick: D,
|
|
101
101
|
className: "Bear-Calendar__nav-btn bear-p-1.5 bear-rounded bear-text-zinc-500 dark:bear-text-zinc-400 hover:bear-bg-zinc-100 dark:hover:bear-bg-zinc-800 bear-transition-colors",
|
|
102
102
|
"aria-label": "Next month",
|
|
103
|
-
children: /* @__PURE__ */
|
|
103
|
+
children: /* @__PURE__ */ a(Re, { size: 16 })
|
|
104
104
|
}
|
|
105
105
|
),
|
|
106
|
-
|
|
106
|
+
s ? s({ onClick: E }) : /* @__PURE__ */ a(
|
|
107
107
|
"button",
|
|
108
108
|
{
|
|
109
109
|
type: "button",
|
|
110
110
|
onClick: E,
|
|
111
111
|
className: "Bear-Calendar__nav-btn bear-p-1.5 bear-rounded bear-text-zinc-500 dark:bear-text-zinc-400 hover:bear-bg-zinc-100 dark:hover:bear-bg-zinc-800 bear-transition-colors",
|
|
112
112
|
"aria-label": "Next year",
|
|
113
|
-
children: /* @__PURE__ */
|
|
113
|
+
children: /* @__PURE__ */ a(Ye, { size: 16 })
|
|
114
114
|
}
|
|
115
115
|
)
|
|
116
116
|
] })
|
|
117
117
|
] });
|
|
118
|
-
},
|
|
119
|
-
if (e.weekdays) return e.weekdays({ days:
|
|
120
|
-
const
|
|
121
|
-
return /* @__PURE__ */
|
|
122
|
-
(r) =>
|
|
118
|
+
}, fe = () => {
|
|
119
|
+
if (e.weekdays) return e.weekdays({ days: J });
|
|
120
|
+
const t = e.weekday;
|
|
121
|
+
return /* @__PURE__ */ a("div", { className: "Bear-Calendar__weekdays bear-grid bear-grid-cols-7 bear-gap-1 bear-mb-2", children: J.map(
|
|
122
|
+
(r) => t ? /* @__PURE__ */ a("div", { children: t({ label: r }) }, r) : /* @__PURE__ */ a(
|
|
123
123
|
"div",
|
|
124
124
|
{
|
|
125
|
-
className:
|
|
125
|
+
className: M(
|
|
126
126
|
"Bear-Calendar__weekday bear-text-center bear-text-xs bear-font-medium bear-uppercase bear-text-zinc-500 dark:bear-text-zinc-400",
|
|
127
127
|
We.includes(r) && "bear-text-red-500"
|
|
128
128
|
),
|
|
@@ -131,78 +131,88 @@ const sr = (A) => {
|
|
|
131
131
|
r
|
|
132
132
|
)
|
|
133
133
|
) });
|
|
134
|
-
},
|
|
135
|
-
const { date: o, isCurrentMonth:
|
|
134
|
+
}, Ne = (t, r) => {
|
|
135
|
+
const { date: o, isCurrentMonth: s } = t, f = o.getDate(), ge = o.getDay(), Be = je(ge), k = _(I, o), Y = _(he, o), N = ye(o), te = ve(o), ne = () => {
|
|
136
136
|
N || C == null || C(o);
|
|
137
|
-
},
|
|
137
|
+
}, Ee = {
|
|
138
138
|
date: o,
|
|
139
139
|
day: f,
|
|
140
|
-
isCurrentMonth:
|
|
141
|
-
isSelected:
|
|
142
|
-
isToday:
|
|
140
|
+
isCurrentMonth: s,
|
|
141
|
+
isSelected: k,
|
|
142
|
+
isToday: Y,
|
|
143
143
|
isDisabled: N,
|
|
144
|
-
isHighlighted:
|
|
145
|
-
onClick:
|
|
144
|
+
isHighlighted: te,
|
|
145
|
+
onClick: ne
|
|
146
146
|
};
|
|
147
|
-
return e.day ? /* @__PURE__ */
|
|
147
|
+
return e.day ? /* @__PURE__ */ a("span", { children: e.day(Ee) }, r) : /* @__PURE__ */ a(
|
|
148
148
|
"button",
|
|
149
149
|
{
|
|
150
150
|
type: "button",
|
|
151
|
-
onClick:
|
|
151
|
+
onClick: ne,
|
|
152
152
|
disabled: N,
|
|
153
|
-
className:
|
|
153
|
+
className: M(
|
|
154
154
|
"Bear-Calendar__day bear-w-8 bear-h-8 bear-rounded-full bear-text-sm bear-font-medium bear-transition-colors bear-flex bear-items-center bear-justify-center",
|
|
155
|
-
|
|
156
|
-
!
|
|
157
|
-
!
|
|
158
|
-
|
|
155
|
+
k && "Bear-Calendar__day--selected bear-bg-primary-500 bear-text-white hover:bear-bg-primary-600",
|
|
156
|
+
!k && Y && "Bear-Calendar__day--today bear-ring-2 bear-ring-primary-500/50 bear-bg-transparent",
|
|
157
|
+
!k && !Y && (s ? Be ? "Bear-Calendar__day--weekend bear-text-red-500 dark:bear-text-red-400 hover:bear-bg-zinc-100 dark:hover:bear-bg-zinc-800" : "bear-text-zinc-700 dark:bear-text-zinc-300 hover:bear-bg-zinc-100 dark:hover:bear-bg-zinc-800" : "Bear-Calendar__day--other bear-text-zinc-500 dark:bear-text-zinc-600 hover:bear-bg-zinc-50 dark:hover:bear-bg-zinc-800/50"),
|
|
158
|
+
te && !k && "Bear-Calendar__day--highlighted bear-bg-primary-500/15",
|
|
159
159
|
N && "Bear-Calendar__day--disabled bear-opacity-40 bear-cursor-not-allowed"
|
|
160
160
|
),
|
|
161
161
|
children: f
|
|
162
162
|
},
|
|
163
163
|
r
|
|
164
164
|
);
|
|
165
|
-
},
|
|
166
|
-
const
|
|
167
|
-
return e.daysGrid ? e.daysGrid({ children:
|
|
168
|
-
},
|
|
169
|
-
const
|
|
170
|
-
if (!
|
|
165
|
+
}, _e = () => {
|
|
166
|
+
const t = pe.map((r, o) => Ne(r, o));
|
|
167
|
+
return e.daysGrid ? e.daysGrid({ children: t, className: "Bear-Calendar__grid bear-grid bear-grid-cols-7 bear-gap-1" }) : /* @__PURE__ */ a("div", { className: "Bear-Calendar__grid bear-grid bear-grid-cols-7 bear-gap-1", children: t });
|
|
168
|
+
}, Ce = () => {
|
|
169
|
+
const t = de && O && h, r = se && u;
|
|
170
|
+
if (!t && !r) return null;
|
|
171
171
|
if (e.footer) {
|
|
172
|
-
const o = e.clearButton,
|
|
172
|
+
const o = e.clearButton, s = e.todayButton;
|
|
173
173
|
return e.footer({
|
|
174
|
-
children: /* @__PURE__ */
|
|
175
|
-
|
|
176
|
-
r &&
|
|
174
|
+
children: /* @__PURE__ */ c("div", { className: "Bear-Calendar__footer bear-flex bear-justify-between bear-gap-2 bear-mt-4 bear-pt-3 bear-border-t bear-border-zinc-200 dark:bear-border-zinc-700", children: [
|
|
175
|
+
t && o ? o({ onClick: h, hasSelection: O }) : t ? /* @__PURE__ */ a("button", { type: "button", onClick: h, className: "Bear-Calendar__clear-btn bear-text-sm bear-text-zinc-500 dark:bear-text-zinc-400 hover:bear-text-zinc-700 dark:hover:bear-text-zinc-200 bear-transition-colors", children: "Clear" }) : /* @__PURE__ */ a("span", {}),
|
|
176
|
+
r && s ? s({ onClick: u }) : r ? /* @__PURE__ */ a("button", { type: "button", onClick: u, className: "Bear-Calendar__today-btn bear-text-sm bear-text-primary-600 dark:bear-text-primary-400 hover:bear-text-primary-700 dark:hover:bear-text-primary-300 bear-font-medium", children: "Today" }) : null
|
|
177
177
|
] })
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
|
-
return e.clearButton && e.todayButton ? /* @__PURE__ */
|
|
181
|
-
|
|
180
|
+
return e.clearButton && e.todayButton ? /* @__PURE__ */ c("div", { className: "Bear-Calendar__footer bear-flex bear-justify-between bear-gap-2 bear-mt-4 bear-pt-3 bear-border-t bear-border-zinc-200 dark:bear-border-zinc-700", children: [
|
|
181
|
+
t && e.clearButton({ onClick: h, hasSelection: O }),
|
|
182
182
|
r && e.todayButton({ onClick: u })
|
|
183
|
-
] }) : /* @__PURE__ */
|
|
184
|
-
|
|
185
|
-
r ? /* @__PURE__ */
|
|
183
|
+
] }) : /* @__PURE__ */ c("div", { className: "Bear-Calendar__footer bear-flex bear-justify-between bear-gap-2 bear-mt-4 bear-pt-3 bear-border-t bear-border-zinc-200 dark:bear-border-zinc-700", children: [
|
|
184
|
+
t ? /* @__PURE__ */ a("button", { type: "button", onClick: h, className: "Bear-Calendar__clear-btn bear-text-sm bear-text-zinc-500 dark:bear-text-zinc-400 hover:bear-text-zinc-700 dark:hover:bear-text-zinc-200 bear-transition-colors", children: "Clear" }) : /* @__PURE__ */ a("span", {}),
|
|
185
|
+
r ? /* @__PURE__ */ a("button", { type: "button", onClick: u, className: "Bear-Calendar__today-btn bear-text-sm bear-text-primary-400 hover:bear-text-primary-300 bear-font-medium bear-transition-colors", children: "Today" }) : null
|
|
186
186
|
] });
|
|
187
|
-
},
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
] }),
|
|
193
|
-
if (!(
|
|
194
|
-
return
|
|
195
|
-
const
|
|
196
|
-
return
|
|
197
|
-
|
|
187
|
+
}, T = /* @__PURE__ */ c(we, { children: [
|
|
188
|
+
xe(),
|
|
189
|
+
fe(),
|
|
190
|
+
_e(),
|
|
191
|
+
Ce()
|
|
192
|
+
] }), P = M(ke, me), V = Object.keys(K).length ? K : void 0, ee = $ ? { ...V, ...$ } : V, L = e.root ? e.root({ children: T, className: P }) : /* @__PURE__ */ a("div", { className: P, style: ee, children: T }), ze = Z !== void 0, p = Z ?? De;
|
|
193
|
+
if (!(ze && (y !== l || v !== l)))
|
|
194
|
+
return L;
|
|
195
|
+
const re = p ? y : v, R = re === l ? y === l ? v === l ? void 0 : S[v] : S[y] : S[re], ae = p && y === l || !p && v === l;
|
|
196
|
+
return R ? e.root ? /* @__PURE__ */ a(
|
|
197
|
+
ie,
|
|
198
|
+
{
|
|
199
|
+
show: p,
|
|
200
|
+
name: R,
|
|
201
|
+
duration: ae ? oe : be,
|
|
202
|
+
children: L
|
|
203
|
+
}
|
|
204
|
+
) : /* @__PURE__ */ a(
|
|
205
|
+
ie,
|
|
198
206
|
{
|
|
199
|
-
show:
|
|
200
|
-
name:
|
|
201
|
-
duration:
|
|
207
|
+
show: p,
|
|
208
|
+
name: R,
|
|
209
|
+
duration: ae ? oe : be,
|
|
210
|
+
className: P,
|
|
211
|
+
style: ee,
|
|
202
212
|
children: T
|
|
203
213
|
}
|
|
204
|
-
) :
|
|
214
|
+
) : L;
|
|
205
215
|
};
|
|
206
216
|
export {
|
|
207
|
-
|
|
217
|
+
cr as Calendar
|
|
208
218
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("../../constants/numbers.const.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("../../constants/numbers.const.cjs"),m=require("../../utils/cn.cjs");require("react");const w=require("../../utils/generateBearId.utils.cjs"),z=require("../../utils/useBearId.cjs"),c=require("./Chart.const.cjs"),i=require("./Chart.utils.cjs"),D=x=>{const{data:h,height:g=c.CHART.DEFAULT_HEIGHT,showLabels:d=!0,showValues:v=!1,animated:R=!0,motion:$,color:b,orientation:A="vertical",barRadius:r=c.CHART.DEFAULT_BAR_RADIUS,barGap:E=c.CHART.DEFAULT_BAR_GAP,stacked:l=!1,className:N,id:j,testId:T,...O}=x,k=z.useBearId("BarChart"),q=w.resolveBearId(j,k),u=h.map(a=>i.getStackTotal(a.stacks,a.value)),y=Math.max(...u,s.ONE),t=A==="vertical",I={"--Bear-Chart-height":`${g}px`,"--Bear-Chart-gap":`${E}rem`};return e.jsx("div",{id:q,"data-testid":T,className:m.cn("Bear-Chart Bear-Chart--bar",t?"Bear-Chart--vertical":"Bear-Chart--horizontal",N),style:I,...O,children:e.jsx("div",{className:"Bear-Chart__track",children:h.map((a,C)=>{const B=l&&a.stacks&&a.stacks.length>s.ZERO?a.stacks:[a.value],o=u[C],H={"--Bear-Chart-size":`${o/y*c.CHART.VIEWBOX}%`};return e.jsxs("div",{className:"Bear-Chart__col",children:[d&&!t&&e.jsx("span",{className:"Bear-Chart__label",children:a.label}),e.jsx("div",{className:"Bear-Chart__plot",children:e.jsx("div",{className:m.cn("Bear-Chart__stack",i.chartMotionClass(R,$,t?"animate-grow-up":"animate-grow-right")),style:H,children:B.map((S,n)=>{const L=o>s.ZERO?S/o*c.CHART.VIEWBOX:s.ZERO,P=n===s.ZERO,_=n===B.length-s.ONE,p=l?t?_?`${r}px ${r}px 0 0`:"0":_?`0 ${r}px ${r}px 0`:"0":t?`${r}px ${r}px 0 0`:`0 ${r}px ${r}px 0`,V={"--Bear-Chart-segment":`${L}%`,"--Bear-Chart-color":i.getChartColor(l?n:C,a.color||b),"--Bear-Chart-radius":p};return e.jsx("div",{className:"Bear-Chart__segment",style:V},`${a.label}-${n}`)})})}),v&&e.jsx("span",{className:"Bear-Chart__value",children:o}),d&&t&&e.jsx("span",{className:"Bear-Chart__label",children:a.label})]},a.label)})})})};exports.BarChart=D;
|
|
@@ -1,65 +1,66 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
1
|
+
import { jsx as t, jsxs as O } from "react/jsx-runtime";
|
|
2
2
|
import { ONE as _, ZERO as h } from "../../constants/numbers.const.js";
|
|
3
3
|
import { cn as u } from "../../utils/cn.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import { resolveBearId as
|
|
6
|
-
import { useBearId as
|
|
7
|
-
import { CHART as
|
|
8
|
-
import { getStackTotal as
|
|
9
|
-
const
|
|
5
|
+
import { resolveBearId as P } from "../../utils/generateBearId.utils.js";
|
|
6
|
+
import { useBearId as U } from "../../utils/useBearId.js";
|
|
7
|
+
import { CHART as e } from "./Chart.const.js";
|
|
8
|
+
import { getStackTotal as G, getChartColor as H, chartMotionClass as j } from "./Chart.utils.js";
|
|
9
|
+
const aa = ($) => {
|
|
10
10
|
const {
|
|
11
11
|
data: n,
|
|
12
|
-
height: g =
|
|
12
|
+
height: g = e.DEFAULT_HEIGHT,
|
|
13
13
|
showLabels: i = !0,
|
|
14
14
|
showValues: v = !1,
|
|
15
15
|
animated: N = !0,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
motion: b,
|
|
17
|
+
color: x,
|
|
18
|
+
orientation: f = "vertical",
|
|
19
|
+
barRadius: r = e.DEFAULT_BAR_RADIUS,
|
|
20
|
+
barGap: k = e.DEFAULT_BAR_GAP,
|
|
20
21
|
stacked: l = !1,
|
|
21
|
-
className:
|
|
22
|
-
id:
|
|
23
|
-
testId:
|
|
24
|
-
...
|
|
25
|
-
} = $,
|
|
22
|
+
className: A,
|
|
23
|
+
id: E,
|
|
24
|
+
testId: y,
|
|
25
|
+
...I
|
|
26
|
+
} = $, R = U("BarChart"), T = P(E, R), m = n.map((a) => G(a.stacks, a.value)), L = Math.max(...m, _), s = f === "vertical", S = {
|
|
26
27
|
"--Bear-Chart-height": `${g}px`,
|
|
27
|
-
"--Bear-Chart-gap": `${
|
|
28
|
+
"--Bear-Chart-gap": `${k}rem`
|
|
28
29
|
};
|
|
29
30
|
return /* @__PURE__ */ t(
|
|
30
31
|
"div",
|
|
31
32
|
{
|
|
32
|
-
id:
|
|
33
|
-
"data-testid":
|
|
33
|
+
id: T,
|
|
34
|
+
"data-testid": y,
|
|
34
35
|
className: u(
|
|
35
36
|
"Bear-Chart Bear-Chart--bar",
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
s ? "Bear-Chart--vertical" : "Bear-Chart--horizontal",
|
|
38
|
+
A
|
|
38
39
|
),
|
|
39
|
-
style:
|
|
40
|
-
...
|
|
40
|
+
style: S,
|
|
41
|
+
...I,
|
|
41
42
|
children: /* @__PURE__ */ t("div", { className: "Bear-Chart__track", children: n.map((a, p) => {
|
|
42
|
-
const d = l && a.stacks && a.stacks.length > h ? a.stacks : [a.value], o = m[p],
|
|
43
|
-
"--Bear-Chart-size": `${o /
|
|
43
|
+
const d = l && a.stacks && a.stacks.length > h ? a.stacks : [a.value], o = m[p], V = {
|
|
44
|
+
"--Bear-Chart-size": `${o / L * e.VIEWBOX}%`
|
|
44
45
|
};
|
|
45
|
-
return /* @__PURE__ */
|
|
46
|
-
i && !
|
|
46
|
+
return /* @__PURE__ */ O("div", { className: "Bear-Chart__col", children: [
|
|
47
|
+
i && !s && /* @__PURE__ */ t("span", { className: "Bear-Chart__label", children: a.label }),
|
|
47
48
|
/* @__PURE__ */ t("div", { className: "Bear-Chart__plot", children: /* @__PURE__ */ t(
|
|
48
49
|
"div",
|
|
49
50
|
{
|
|
50
|
-
className: u("Bear-Chart__stack", N
|
|
51
|
-
style:
|
|
52
|
-
children: d.map((
|
|
53
|
-
const
|
|
54
|
-
"--Bear-Chart-segment": `${
|
|
55
|
-
"--Bear-Chart-color":
|
|
51
|
+
className: u("Bear-Chart__stack", j(N, b, s ? "animate-grow-up" : "animate-grow-right")),
|
|
52
|
+
style: V,
|
|
53
|
+
children: d.map((w, c) => {
|
|
54
|
+
const z = o > h ? w / o * e.VIEWBOX : h, D = c === h, B = c === d.length - _, C = l ? s ? B ? `${r}px ${r}px 0 0` : "0" : B ? `0 ${r}px ${r}px 0` : "0" : s ? `${r}px ${r}px 0 0` : `0 ${r}px ${r}px 0`, F = {
|
|
55
|
+
"--Bear-Chart-segment": `${z}%`,
|
|
56
|
+
"--Bear-Chart-color": H(l ? c : p, a.color || x),
|
|
56
57
|
"--Bear-Chart-radius": C
|
|
57
58
|
};
|
|
58
59
|
return /* @__PURE__ */ t(
|
|
59
60
|
"div",
|
|
60
61
|
{
|
|
61
62
|
className: "Bear-Chart__segment",
|
|
62
|
-
style:
|
|
63
|
+
style: F
|
|
63
64
|
},
|
|
64
65
|
`${a.label}-${c}`
|
|
65
66
|
);
|
|
@@ -67,12 +68,12 @@ const Q = ($) => {
|
|
|
67
68
|
}
|
|
68
69
|
) }),
|
|
69
70
|
v && /* @__PURE__ */ t("span", { className: "Bear-Chart__value", children: o }),
|
|
70
|
-
i &&
|
|
71
|
+
i && s && /* @__PURE__ */ t("span", { className: "Bear-Chart__label", children: a.label })
|
|
71
72
|
] }, a.label);
|
|
72
73
|
}) })
|
|
73
74
|
}
|
|
74
75
|
);
|
|
75
76
|
};
|
|
76
77
|
export {
|
|
77
|
-
|
|
78
|
+
aa as BarChart
|
|
78
79
|
};
|
|
@@ -2,6 +2,7 @@ import { HTMLAttributes, ReactNode } from 'react';
|
|
|
2
2
|
export type ChartType = 'bar' | 'line' | 'area' | 'pie' | 'donut' | 'radar' | 'funnel' | 'stacked';
|
|
3
3
|
export type PieView = 'full' | 'half' | 'rose';
|
|
4
4
|
export type ChartLegendPosition = 'right' | 'bottom' | 'none';
|
|
5
|
+
export type ChartMotion = 'grow' | 'fade' | 'scale' | 'none';
|
|
5
6
|
export interface ChartDataPoint {
|
|
6
7
|
label: string;
|
|
7
8
|
value: number;
|
|
@@ -16,6 +17,7 @@ export interface ChartProps extends Omit<HTMLAttributes<HTMLDivElement>, 'childr
|
|
|
16
17
|
showLabels?: boolean;
|
|
17
18
|
showValues?: boolean;
|
|
18
19
|
animated?: boolean;
|
|
20
|
+
motion?: ChartMotion;
|
|
19
21
|
color?: string;
|
|
20
22
|
showGrid?: boolean;
|
|
21
23
|
pieView?: PieView;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("../../constants/numbers.const.cjs"),E=require("./Chart.const.cjs"),l=(e,t,a)=>!e||t==="none"?"":t==="fade"?"animate-fade-in":t==="scale"?"animate-scale-in":a,x=(e,t)=>t||E.DEFAULT_COLORS[e%E.DEFAULT_COLORS.length],o=(e,t,a=E.CHART.CENTER)=>{const n=e*Math.PI/E.CHART.HALF_SWEEP;return{x:a+t*Math.cos(n),y:a+t*Math.sin(n)}},T=(e,t)=>{const a=e*Math.PI/E.CHART.HALF_SWEEP;return{x:t*Math.cos(a),y:t*Math.sin(a)}},u=(e,t,a=$.ZERO,n=E.CHART.OUTER_RADIUS)=>{const r=a*n,c=o(e,n),s=o(t,n),R=o(e,r),O=o(t,r),C=t-e>E.CHART.LARGE_ARC_THRESHOLD?$.ONE:$.ZERO;return a>$.ZERO?`M ${c.x},${c.y} A ${n},${n} 0 ${C},1 ${s.x},${s.y} L ${O.x},${O.y} A ${r},${r} 0 ${C},0 ${R.x},${R.y} Z`:`M ${E.CHART.CENTER},${E.CHART.CENTER} L ${c.x},${c.y} A ${n},${n} 0 ${C},1 ${s.x},${s.y} Z`},A=(e,t=!0,a=!1)=>e.length===$.ZERO?"":a?e.reduce((n,r,c,s)=>{if(c===$.ZERO)return`M ${r.x},${r.y}`;const R=s[c-$.ONE];return`${n} L ${r.x},${R.y} L ${r.x},${r.y}`},""):t?e.reduce((n,r,c,s)=>{if(c===$.ZERO)return`M ${r.x},${r.y}`;const R=s[c-$.ONE],O=R.x+(r.x-R.x)/E.CHART.BEZIER_DIVISOR,C=r.x-(r.x-R.x)/E.CHART.BEZIER_DIVISOR;return`${n} C ${O},${R.y} ${C},${r.y} ${r.x},${r.y}`},""):e.reduce((n,r,c)=>`${n} ${c===$.ZERO?"M":"L"} ${r.x},${r.y}`,""),h=e=>{const t=Math.max(...e.map(c=>c.value)),a=Math.min(...e.map(c=>c.value)),n=t-a||$.ONE,r=e.length-$.ONE||$.ONE;return e.map((c,s)=>({x:s/r*E.CHART.VIEWBOX,y:E.CHART.VIEWBOX-(c.value-a)/n*E.CHART.LINE_Y_RANGE-E.CHART.LINE_Y_PAD}))},y=(e,t)=>!e||e.length===$.ZERO?t:e.reduce((a,n)=>a+n,$.ZERO);exports.calculateLinePoints=h;exports.chartMotionClass=l;exports.createArcPath=u;exports.generateLinePath=A;exports.getChartColor=x;exports.getStackTotal=y;exports.polarOffset=T;exports.polarToCartesian=o;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ChartMotion } from './Chart.types';
|
|
2
|
+
export declare const chartMotionClass: (animated: boolean, motion: ChartMotion | undefined, fallback: string) => string;
|
|
1
3
|
export declare const getChartColor: (index: number, customColor?: string) => string;
|
|
2
4
|
export declare const polarToCartesian: (angle: number, radius: number, center?: number) => {
|
|
3
5
|
x: number;
|
|
@@ -1,41 +1,42 @@
|
|
|
1
|
-
import { ZERO as
|
|
2
|
-
import { DEFAULT_COLORS as
|
|
3
|
-
const M = (
|
|
4
|
-
const
|
|
1
|
+
import { ZERO as s, ONE as f } from "../../constants/numbers.const.js";
|
|
2
|
+
import { DEFAULT_COLORS as h, CHART as a } from "./Chart.const.js";
|
|
3
|
+
const L = (r, t, c) => !r || t === "none" ? "" : t === "fade" ? "animate-fade-in" : t === "scale" ? "animate-scale-in" : c, M = (r, t) => t || h[r % h.length], y = (r, t, c = a.CENTER) => {
|
|
4
|
+
const n = r * Math.PI / a.HALF_SWEEP;
|
|
5
5
|
return {
|
|
6
|
-
x: c +
|
|
7
|
-
y: c +
|
|
6
|
+
x: c + t * Math.cos(n),
|
|
7
|
+
y: c + t * Math.sin(n)
|
|
8
8
|
};
|
|
9
|
-
},
|
|
10
|
-
const c =
|
|
9
|
+
}, _ = (r, t) => {
|
|
10
|
+
const c = r * Math.PI / a.HALF_SWEEP;
|
|
11
11
|
return {
|
|
12
|
-
x:
|
|
13
|
-
y:
|
|
12
|
+
x: t * Math.cos(c),
|
|
13
|
+
y: t * Math.sin(c)
|
|
14
14
|
};
|
|
15
|
-
},
|
|
16
|
-
const
|
|
17
|
-
return c >
|
|
18
|
-
},
|
|
19
|
-
if (
|
|
20
|
-
const
|
|
21
|
-
return `${
|
|
22
|
-
}, "") :
|
|
23
|
-
if (
|
|
24
|
-
const
|
|
25
|
-
return `${
|
|
26
|
-
}, "") :
|
|
27
|
-
const
|
|
28
|
-
return
|
|
29
|
-
x:
|
|
30
|
-
y:
|
|
15
|
+
}, m = (r, t, c = s, n = a.OUTER_RADIUS) => {
|
|
16
|
+
const e = c * n, $ = y(r, n), x = y(t, n), E = y(r, e), u = y(t, e), l = t - r > a.LARGE_ARC_THRESHOLD ? f : s;
|
|
17
|
+
return c > s ? `M ${$.x},${$.y} A ${n},${n} 0 ${l},1 ${x.x},${x.y} L ${u.x},${u.y} A ${e},${e} 0 ${l},0 ${E.x},${E.y} Z` : `M ${a.CENTER},${a.CENTER} L ${$.x},${$.y} A ${n},${n} 0 ${l},1 ${x.x},${x.y} Z`;
|
|
18
|
+
}, C = (r, t = !0, c = !1) => r.length === s ? "" : c ? r.reduce((n, e, $, x) => {
|
|
19
|
+
if ($ === s) return `M ${e.x},${e.y}`;
|
|
20
|
+
const E = x[$ - f];
|
|
21
|
+
return `${n} L ${e.x},${E.y} L ${e.x},${e.y}`;
|
|
22
|
+
}, "") : t ? r.reduce((n, e, $, x) => {
|
|
23
|
+
if ($ === s) return `M ${e.x},${e.y}`;
|
|
24
|
+
const E = x[$ - f], u = E.x + (e.x - E.x) / a.BEZIER_DIVISOR, l = e.x - (e.x - E.x) / a.BEZIER_DIVISOR;
|
|
25
|
+
return `${n} C ${u},${E.y} ${l},${e.y} ${e.x},${e.y}`;
|
|
26
|
+
}, "") : r.reduce((n, e, $) => `${n} ${$ === s ? "M" : "L"} ${e.x},${e.y}`, ""), O = (r) => {
|
|
27
|
+
const t = Math.max(...r.map(($) => $.value)), c = Math.min(...r.map(($) => $.value)), n = t - c || f, e = r.length - f || f;
|
|
28
|
+
return r.map(($, x) => ({
|
|
29
|
+
x: x / e * a.VIEWBOX,
|
|
30
|
+
y: a.VIEWBOX - ($.value - c) / n * a.LINE_Y_RANGE - a.LINE_Y_PAD
|
|
31
31
|
}));
|
|
32
|
-
}, A = (
|
|
32
|
+
}, A = (r, t) => !r || r.length === s ? t : r.reduce((c, n) => c + n, s);
|
|
33
33
|
export {
|
|
34
34
|
O as calculateLinePoints,
|
|
35
|
-
|
|
36
|
-
m as
|
|
35
|
+
L as chartMotionClass,
|
|
36
|
+
m as createArcPath,
|
|
37
|
+
C as generateLinePath,
|
|
37
38
|
M as getChartColor,
|
|
38
39
|
A as getStackTotal,
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
_ as polarOffset,
|
|
41
|
+
y as polarToCartesian
|
|
41
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),n=require("../../constants/numbers.const.cjs"),s=require("../../utils/cn.cjs");require("react");const b=require("../../utils/generateBearId.utils.cjs"),F=require("../../utils/useBearId.cjs"),j=require("../Box/Box.cjs"),o=require("../Flex/Flex.cjs"),E=require("../Typography/Typography.cjs"),r=require("./Chart.const.cjs"),l=require("./Chart.utils.cjs"),H=c=>{const{data:a,height:u=r.CHART.DEFAULT_HEIGHT,showLabels:i=!0,showValues:h=!0,animated:d=!0,motion:C,color:m,className:g,id:x,testId:B,...p}=c,I=F.useBearId("FunnelChart"),q=b.resolveBearId(x,I),y=Math.max(...a.map(e=>e.value),n.ONE),T={"--Bear-Chart-height":`${u}px`};return t.jsx(o.Flex,{id:q,"data-testid":B,direction:"column",gap:1,justify:"center",className:s.cn("Bear-Chart Bear-Chart--funnel",g),style:T,...p,children:a.map((e,N)=>{const _={"--Bear-Chart-size":`${Math.max(e.value/y*r.CHART.VIEWBOX,r.CHART.FUNNEL_MIN_WIDTH)}%`,"--Bear-Chart-step-height":`${r.CHART.VIEWBOX/Math.max(a.length,n.ONE)/2}%`,"--Bear-Chart-color":l.getChartColor(N,e.color||m)};return t.jsxs(o.Flex,{direction:"column",align:"center",gap:1,className:"bear-w-full",children:[t.jsx(j.Box,{className:s.cn("Bear-Chart__funnel-step bear-rounded-md",l.chartMotionClass(d,C,"animate-grow-right")),style:_}),i&&t.jsxs(E.Typography,{variant:"caption",color:"muted",children:[e.label,h?` · ${e.value}`:""]})]},e.label)})})};exports.FunnelChart=H;
|