@forgedevstack/bear 1.2.0 → 1.2.1
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 +4 -0
- package/dist/components/Autocomplete/Autocomplete.cjs +1 -1
- package/dist/components/Autocomplete/Autocomplete.const.cjs +1 -0
- package/dist/components/Autocomplete/Autocomplete.const.d.ts +1 -0
- package/dist/components/Autocomplete/Autocomplete.const.js +4 -0
- package/dist/components/Autocomplete/Autocomplete.js +110 -72
- package/dist/components/BottomSheet/BottomSheet.cjs +1 -1
- package/dist/components/BottomSheet/BottomSheet.js +74 -53
- package/dist/components/BottomSheet/BottomSheet.types.d.ts +2 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js +126 -46
- package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +11 -4
- package/dist/components/Breadcrumbs/index.d.ts +1 -1
- package/dist/components/Cascader/Cascader.cjs +1 -1
- package/dist/components/Cascader/Cascader.const.cjs +1 -1
- package/dist/components/Cascader/Cascader.const.d.ts +1 -1
- package/dist/components/Cascader/Cascader.const.js +1 -1
- package/dist/components/Cascader/Cascader.js +109 -146
- package/dist/components/Cascader/components/CascaderPanel/CascaderPanel.cjs +1 -0
- package/dist/components/Cascader/components/CascaderPanel/CascaderPanel.d.ts +3 -0
- package/dist/components/Cascader/components/CascaderPanel/CascaderPanel.js +50 -0
- package/dist/components/Cascader/components/CascaderPanel/index.d.ts +1 -0
- package/dist/components/Chart/BarChart.cjs +1 -0
- package/dist/components/Chart/BarChart.d.ts +3 -0
- package/dist/components/Chart/BarChart.js +65 -0
- package/dist/components/Chart/Chart.cjs +1 -1
- package/dist/components/Chart/Chart.const.cjs +1 -1
- package/dist/components/Chart/Chart.const.d.ts +7 -0
- package/dist/components/Chart/Chart.const.js +12 -2
- package/dist/components/Chart/Chart.d.ts +1 -13
- package/dist/components/Chart/Chart.js +18 -204
- package/dist/components/Chart/Chart.types.d.ts +7 -1
- package/dist/components/Chart/LineChart.cjs +1 -0
- package/dist/components/Chart/LineChart.d.ts +3 -0
- package/dist/components/Chart/LineChart.js +73 -0
- package/dist/components/Chart/PieChart.cjs +1 -0
- package/dist/components/Chart/PieChart.d.ts +3 -0
- package/dist/components/Chart/PieChart.js +110 -0
- package/dist/components/Chart/index.d.ts +4 -1
- package/dist/components/ColorPicker/ColorPicker.cjs +1 -1
- package/dist/components/ColorPicker/ColorPicker.const.cjs +1 -1
- package/dist/components/ColorPicker/ColorPicker.const.d.ts +4 -2
- package/dist/components/ColorPicker/ColorPicker.const.js +8 -6
- package/dist/components/ColorPicker/ColorPicker.js +135 -73
- package/dist/components/ColorPicker/ColorPicker.utils.cjs +1 -0
- package/dist/components/ColorPicker/ColorPicker.utils.d.ts +17 -0
- package/dist/components/ColorPicker/ColorPicker.utils.js +43 -0
- package/dist/components/CountdownTimer/CountdownTimer.cjs +1 -1
- package/dist/components/CountdownTimer/CountdownTimer.const.cjs +1 -1
- package/dist/components/CountdownTimer/CountdownTimer.const.d.ts +2 -0
- package/dist/components/CountdownTimer/CountdownTimer.const.js +29 -17
- package/dist/components/CountdownTimer/CountdownTimer.js +91 -61
- package/dist/components/CountdownTimer/CountdownTimer.types.d.ts +11 -2
- package/dist/components/CreditInput/CreditInput.cjs +1 -1
- package/dist/components/CreditInput/CreditInput.js +80 -78
- package/dist/components/DateRangePicker/DateRangePicker.cjs +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.js +89 -84
- package/dist/components/DiffSquares/DiffSquares.cjs +1 -0
- package/dist/components/DiffSquares/DiffSquares.const.cjs +1 -0
- package/dist/components/DiffSquares/DiffSquares.const.d.ts +3 -0
- package/dist/components/DiffSquares/DiffSquares.const.js +6 -0
- package/dist/components/DiffSquares/DiffSquares.d.ts +3 -0
- package/dist/components/DiffSquares/DiffSquares.js +70 -0
- package/dist/components/DiffSquares/DiffSquares.types.d.ts +23 -0
- package/dist/components/DiffSquares/DiffSquares.utils.cjs +1 -0
- package/dist/components/DiffSquares/DiffSquares.utils.d.ts +3 -0
- package/dist/components/DiffSquares/DiffSquares.utils.js +12 -0
- package/dist/components/DiffSquares/index.d.ts +2 -0
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +41 -41
- package/dist/components/Dropdown/Dropdown.cjs +1 -1
- package/dist/components/Dropdown/Dropdown.const.cjs +1 -0
- package/dist/components/Dropdown/Dropdown.const.d.ts +7 -0
- package/dist/components/Dropdown/Dropdown.const.js +10 -0
- package/dist/components/Dropdown/Dropdown.d.ts +0 -1
- package/dist/components/Dropdown/Dropdown.js +102 -92
- package/dist/components/Dropdown/Dropdown.types.d.ts +2 -0
- package/dist/components/Gauge/Gauge.cjs +1 -1
- package/dist/components/Gauge/Gauge.js +61 -50
- package/dist/components/Gauge/Gauge.types.d.ts +2 -0
- package/dist/components/HoverCard/HoverCard.cjs +6 -6
- package/dist/components/HoverCard/HoverCard.js +72 -54
- package/dist/components/Icon/icons/status.js +1 -1
- package/dist/components/MentionsInput/MentionsInput.cjs +1 -1
- package/dist/components/MentionsInput/MentionsInput.js +106 -83
- package/dist/components/Menu/Menu.cjs +1 -1
- package/dist/components/Menu/Menu.js +91 -80
- 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 -1
- package/dist/components/Modal/Modal.const.js +1 -1
- package/dist/components/Modal/Modal.js +50 -44
- package/dist/components/Modal/Modal.types.d.ts +6 -0
- package/dist/components/MultiSelect/MultiSelect.cjs +1 -1
- package/dist/components/MultiSelect/MultiSelect.js +123 -78
- package/dist/components/NavigableSelect/NavigableSelect.cjs +1 -1
- package/dist/components/NavigableSelect/NavigableSelect.const.cjs +1 -1
- package/dist/components/NavigableSelect/NavigableSelect.const.d.ts +1 -1
- package/dist/components/NavigableSelect/NavigableSelect.const.js +1 -1
- package/dist/components/NavigableSelect/NavigableSelect.js +167 -143
- package/dist/components/NotificationCenter/NotificationCenter.cjs +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.const.cjs +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.const.d.ts +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.const.js +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.js +87 -81
- package/dist/components/OTPInput/OTPInput.cjs +1 -1
- package/dist/components/OTPInput/OTPInput.const.cjs +1 -0
- package/dist/components/OTPInput/OTPInput.const.d.ts +6 -0
- package/dist/components/OTPInput/OTPInput.const.js +14 -0
- package/dist/components/OTPInput/OTPInput.js +99 -65
- package/dist/components/OTPInput/OTPInput.types.d.ts +7 -0
- package/dist/components/PhoneInput/PhoneInput.cjs +1 -1
- package/dist/components/PhoneInput/PhoneInput.const.cjs +1 -1
- package/dist/components/PhoneInput/PhoneInput.const.d.ts +1 -1
- package/dist/components/PhoneInput/PhoneInput.const.js +1 -1
- package/dist/components/PhoneInput/PhoneInput.js +88 -83
- package/dist/components/Popconfirm/Popconfirm.cjs +1 -1
- package/dist/components/Popconfirm/Popconfirm.const.cjs +1 -1
- package/dist/components/Popconfirm/Popconfirm.const.d.ts +1 -3
- package/dist/components/Popconfirm/Popconfirm.const.js +12 -18
- package/dist/components/Popconfirm/Popconfirm.js +71 -51
- package/dist/components/Popover/Popover.cjs +1 -1
- package/dist/components/Popover/Popover.js +36 -31
- package/dist/components/Portal/Portal.cjs +1 -1
- package/dist/components/Portal/Portal.d.ts +0 -3
- package/dist/components/Portal/Portal.js +4 -10
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.js +71 -51
- package/dist/components/Stepper/Stepper.cjs +1 -1
- package/dist/components/Stepper/Stepper.const.cjs +1 -1
- package/dist/components/Stepper/Stepper.const.d.ts +3 -2
- package/dist/components/Stepper/Stepper.const.js +15 -14
- package/dist/components/Stepper/Stepper.d.ts +0 -7
- package/dist/components/Stepper/Stepper.js +164 -117
- package/dist/components/Stepper/Stepper.types.d.ts +3 -0
- package/dist/components/Tabs/TabList.cjs +1 -1
- package/dist/components/Tabs/TabList.js +72 -57
- package/dist/components/Tabs/Tabs.types.d.ts +4 -2
- package/dist/components/Tabs/index.d.ts +2 -2
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.cjs +1 -1
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.js +26 -26
- package/dist/components/TimePicker/helpers/ClockFaceSvg.cjs +1 -1
- package/dist/components/TimePicker/helpers/ClockFaceSvg.js +17 -17
- package/dist/components/Toast/Toast.cjs +1 -1
- package/dist/components/Toast/Toast.js +86 -82
- package/dist/components/Toast/Toast.types.d.ts +2 -0
- package/dist/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/components/Tooltip/Tooltip.js +52 -44
- package/dist/components/TreeSelect/TreeSelect.cjs +1 -1
- package/dist/components/TreeSelect/TreeSelect.const.cjs +1 -1
- package/dist/components/TreeSelect/TreeSelect.const.d.ts +1 -1
- package/dist/components/TreeSelect/TreeSelect.const.js +3 -3
- package/dist/components/TreeSelect/TreeSelect.js +120 -88
- package/dist/components/Watermark/Watermark.cjs +1 -1
- package/dist/components/Watermark/Watermark.const.cjs +1 -1
- package/dist/components/Watermark/Watermark.const.d.ts +6 -3
- package/dist/components/Watermark/Watermark.const.js +13 -11
- package/dist/components/Watermark/Watermark.js +87 -61
- package/dist/components/Watermark/Watermark.types.d.ts +2 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +5 -3
- package/dist/components/index.js +292 -286
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +55 -54
- package/dist/hooks/useClickOutside.cjs +1 -1
- package/dist/hooks/useClickOutside.d.ts +4 -11
- package/dist/hooks/useClickOutside.js +26 -7
- package/dist/index.cjs +1 -1
- package/dist/index.js +386 -379
- package/dist/styles/_effects.css +17 -0
- package/dist/styles.css +1 -1
- package/dist/utils/maxVisible.utils.cjs +1 -0
- package/dist/utils/maxVisible.utils.d.ts +12 -0
- package/dist/utils/maxVisible.utils.js +15 -0
- package/package.json +1 -1
- package/dist/components/HoverCard/HoverCard.utils.cjs +0 -1
- package/dist/components/HoverCard/HoverCard.utils.js +0 -23
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
1
|
+
import { jsxs as d, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as h, useRef as P, useEffect as T, useCallback as _ } from "react";
|
|
3
|
+
import { createPortal as le } from "react-dom";
|
|
4
4
|
import { cn as p } from "../../utils/cn.js";
|
|
5
|
-
import { getDefaultPresets as
|
|
6
|
-
import { formatDate as
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
return
|
|
10
|
-
/* @__PURE__ */
|
|
11
|
-
/* @__PURE__ */ t("button", { type: "button", onClick: () =>
|
|
12
|
-
/* @__PURE__ */
|
|
13
|
-
|
|
5
|
+
import { getDefaultPresets as ie, LABEL_CLASSES as ce, SIZE_CLASSES as de, TRIGGER_CLASSES as be, PRESET_BTN_CLASSES as $, ERROR_CLASSES as me, HELPER_CLASSES as ue, ROOT_CLASSES as he, CALENDAR_HEADER_CLASSES as pe, NAV_BTN_CLASSES as G, MONTH_LABELS as Se, DAY_LABELS as fe, DAY_TODAY_CLASSES as we, DAY_IN_RANGE_CLASSES as Ee, DAY_SELECTED_CLASSES as ge, DAY_DISABLED_CLASSES as Le, DAY_HOVER_CLASSES as ve, DAY_BASE_CLASSES as Ae } from "./DateRangePicker.const.js";
|
|
6
|
+
import { formatDate as F, getCalendarDays as ke, isSameDay as Y, isInRange as xe } from "./DateRangePicker.utils.js";
|
|
7
|
+
const Z = ({ year: L, month: c, range: r, onDayClick: v, onNav: A, minDate: b, maxDate: k }) => {
|
|
8
|
+
const x = ke(L, c), S = /* @__PURE__ */ new Date();
|
|
9
|
+
return S.setHours(0, 0, 0, 0), /* @__PURE__ */ d("div", { className: "bear-w-64", children: [
|
|
10
|
+
/* @__PURE__ */ d("div", { className: pe, children: [
|
|
11
|
+
/* @__PURE__ */ t("button", { type: "button", onClick: () => A(-1), className: G, "aria-label": "Previous month", children: /* @__PURE__ */ t("svg", { className: "bear-w-4 bear-h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) }) }),
|
|
12
|
+
/* @__PURE__ */ d("span", { className: "bear-text-sm bear-font-semibold bear-text-gray-900 dark:bear-text-white", children: [
|
|
13
|
+
Se[c],
|
|
14
14
|
" ",
|
|
15
|
-
|
|
15
|
+
L
|
|
16
16
|
] }),
|
|
17
|
-
/* @__PURE__ */ t("button", { type: "button", onClick: () =>
|
|
17
|
+
/* @__PURE__ */ t("button", { type: "button", onClick: () => A(1), className: G, "aria-label": "Next month", children: /* @__PURE__ */ t("svg", { className: "bear-w-4 bear-h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" }) }) })
|
|
18
18
|
] }),
|
|
19
|
-
/* @__PURE__ */ t("div", { className: "bear-grid bear-grid-cols-7 bear-gap-0.5 bear-mb-1", children:
|
|
20
|
-
/* @__PURE__ */ t("div", { className: "bear-grid bear-grid-cols-7 bear-gap-0.5", children:
|
|
21
|
-
if (!a) return /* @__PURE__ */ t("div", {}, `e-${
|
|
22
|
-
const
|
|
19
|
+
/* @__PURE__ */ t("div", { className: "bear-grid bear-grid-cols-7 bear-gap-0.5 bear-mb-1", children: fe.map((a) => /* @__PURE__ */ t("div", { className: "bear-text-xs bear-text-center bear-font-medium bear-text-gray-400 dark:bear-text-zinc-500 bear-py-1", children: a }, a)) }),
|
|
20
|
+
/* @__PURE__ */ t("div", { className: "bear-grid bear-grid-cols-7 bear-gap-0.5", children: x.map((a, D) => {
|
|
21
|
+
if (!a) return /* @__PURE__ */ t("div", {}, `e-${D}`);
|
|
22
|
+
const f = b && a < b || k && a > k, l = Y(a, r.start) || Y(a, r.end), m = xe(a, r.start, r.end), R = Y(a, S);
|
|
23
23
|
return /* @__PURE__ */ t(
|
|
24
24
|
"button",
|
|
25
25
|
{
|
|
26
26
|
type: "button",
|
|
27
|
-
disabled: !!
|
|
28
|
-
onClick: () =>
|
|
27
|
+
disabled: !!f,
|
|
28
|
+
onClick: () => v(a),
|
|
29
29
|
className: p(
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
Ae,
|
|
31
|
+
f ? Le : ve,
|
|
32
32
|
l && ge,
|
|
33
|
-
!l &&
|
|
34
|
-
!l && !
|
|
35
|
-
!l && !
|
|
33
|
+
!l && m && Ee,
|
|
34
|
+
!l && !m && R && we,
|
|
35
|
+
!l && !m && !f && "bear-text-gray-700 dark:bear-text-zinc-300"
|
|
36
36
|
),
|
|
37
37
|
children: a.getDate()
|
|
38
38
|
},
|
|
@@ -40,102 +40,107 @@ const F = ({ year: E, month: c, range: r, onDayClick: L, onNav: k, minDate: d, m
|
|
|
40
40
|
);
|
|
41
41
|
}) })
|
|
42
42
|
] });
|
|
43
|
-
},
|
|
43
|
+
}, Pe = (L) => {
|
|
44
44
|
const {
|
|
45
45
|
value: c,
|
|
46
46
|
onChange: r,
|
|
47
|
-
label:
|
|
48
|
-
placeholder:
|
|
49
|
-
disabled:
|
|
50
|
-
clearable:
|
|
51
|
-
minDate:
|
|
52
|
-
maxDate:
|
|
47
|
+
label: v,
|
|
48
|
+
placeholder: A = "Select date range",
|
|
49
|
+
disabled: b = !1,
|
|
50
|
+
clearable: k = !0,
|
|
51
|
+
minDate: x,
|
|
52
|
+
maxDate: S,
|
|
53
53
|
presets: a,
|
|
54
|
-
showPresets:
|
|
55
|
-
size:
|
|
54
|
+
showPresets: D = !0,
|
|
55
|
+
size: f = "md",
|
|
56
56
|
error: l,
|
|
57
|
-
helperText:
|
|
58
|
-
className:
|
|
59
|
-
testId:
|
|
60
|
-
...
|
|
61
|
-
} =
|
|
57
|
+
helperText: m,
|
|
58
|
+
className: R,
|
|
59
|
+
testId: q,
|
|
60
|
+
...J
|
|
61
|
+
} = L, [N, y] = h(!1), [z, K] = h({ top: 0, left: 0 }), [s, w] = h(c ?? { start: null, end: null }), [H, C] = h("start"), O = P(null), M = P(null), I = P(null), W = /* @__PURE__ */ new Date(), [u, Q] = h(W.getMonth()), [E, U] = h(W.getFullYear()), X = u === 11 ? 0 : u + 1, ee = u === 11 ? E + 1 : E;
|
|
62
62
|
T(() => {
|
|
63
|
-
c &&
|
|
63
|
+
c && w(c);
|
|
64
64
|
}, [c]), T(() => {
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
if (!N || !M.current) return;
|
|
66
|
+
const e = 8, n = 420, o = () => {
|
|
67
|
+
const i = M.current.getBoundingClientRect(), g = window.innerHeight;
|
|
68
|
+
let B = g - i.bottom < n && i.top > n ? i.top - n - e : i.bottom + e;
|
|
69
|
+
B = Math.max(8, Math.min(B, g - n - 8));
|
|
70
|
+
const se = Math.min(640, window.innerWidth - 16);
|
|
71
|
+
let oe = Math.max(8, Math.min(i.left, window.innerWidth - se - 8));
|
|
72
|
+
K({ top: B, left: oe });
|
|
73
|
+
};
|
|
74
|
+
return o(), window.addEventListener("resize", o), window.addEventListener("scroll", o, !0), () => {
|
|
75
|
+
window.removeEventListener("resize", o), window.removeEventListener("scroll", o, !0);
|
|
76
|
+
};
|
|
77
|
+
}, [N]), T(() => {
|
|
73
78
|
const e = (n) => {
|
|
74
|
-
var
|
|
79
|
+
var i, g;
|
|
75
80
|
const o = n.target;
|
|
76
|
-
(
|
|
81
|
+
(i = O.current) != null && i.contains(o) || (g = I.current) != null && g.contains(o) || y(!1);
|
|
77
82
|
};
|
|
78
83
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
79
84
|
}, []);
|
|
80
|
-
const j =
|
|
81
|
-
if (
|
|
82
|
-
|
|
85
|
+
const j = _((e) => {
|
|
86
|
+
if (H === "start")
|
|
87
|
+
w({ start: e, end: null }), C("end");
|
|
83
88
|
else {
|
|
84
89
|
const n = e >= (s.start ?? e) ? { start: s.start, end: e } : { start: e, end: s.start };
|
|
85
|
-
|
|
90
|
+
w(n), C("start"), r == null || r(n);
|
|
86
91
|
}
|
|
87
|
-
}, [
|
|
88
|
-
|
|
89
|
-
}, [r]),
|
|
92
|
+
}, [H, s.start, r]), te = _((e) => {
|
|
93
|
+
w(e), r == null || r(e), y(!1), C("start");
|
|
94
|
+
}, [r]), re = _(() => {
|
|
90
95
|
const e = { start: null, end: null };
|
|
91
|
-
|
|
92
|
-
}, [r]),
|
|
93
|
-
let n =
|
|
94
|
-
n < 0 && (n = 11, o--), n > 11 && (n = 0, o++),
|
|
95
|
-
}, [
|
|
96
|
-
return /* @__PURE__ */
|
|
97
|
-
|
|
98
|
-
/* @__PURE__ */
|
|
96
|
+
w(e), r == null || r(e), C("start");
|
|
97
|
+
}, [r]), ae = _((e) => {
|
|
98
|
+
let n = u + e, o = E;
|
|
99
|
+
n < 0 && (n = 11, o--), n > 11 && (n = 0, o++), Q(n), U(o);
|
|
100
|
+
}, [u, E]), V = a ?? (D ? ie() : []), ne = s.start ? `${F(s.start)}${s.end ? ` – ${F(s.end)}` : ""}` : A;
|
|
101
|
+
return /* @__PURE__ */ d("div", { ref: O, className: p(he, R), "data-testid": q, ...J, children: [
|
|
102
|
+
v && /* @__PURE__ */ t("label", { className: ce, children: v }),
|
|
103
|
+
/* @__PURE__ */ d(
|
|
99
104
|
"button",
|
|
100
105
|
{
|
|
101
|
-
ref:
|
|
106
|
+
ref: M,
|
|
102
107
|
type: "button",
|
|
103
|
-
disabled:
|
|
104
|
-
onClick: () => !
|
|
105
|
-
className: p(
|
|
108
|
+
disabled: b,
|
|
109
|
+
onClick: () => !b && y(!N),
|
|
110
|
+
className: p(be, de[f], b && "bear-opacity-50 bear-cursor-not-allowed"),
|
|
106
111
|
children: [
|
|
107
|
-
/* @__PURE__ */ t("span", { className: p(!s.start && "bear-text-gray-400 dark:bear-text-zinc-500"), children:
|
|
112
|
+
/* @__PURE__ */ t("span", { className: p(!s.start && "bear-text-gray-400 dark:bear-text-zinc-500"), children: ne }),
|
|
108
113
|
/* @__PURE__ */ t("svg", { className: "bear-w-4 bear-h-4 bear-ml-2 bear-text-gray-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" }) })
|
|
109
114
|
]
|
|
110
115
|
}
|
|
111
116
|
),
|
|
112
|
-
|
|
117
|
+
N && typeof document < "u" && le(
|
|
113
118
|
/* @__PURE__ */ t(
|
|
114
119
|
"div",
|
|
115
120
|
{
|
|
116
|
-
ref:
|
|
121
|
+
ref: I,
|
|
117
122
|
"data-bear-daterangepicker-dropdown": !0,
|
|
118
123
|
className: p(
|
|
119
|
-
"bear-fixed bear-z-[
|
|
124
|
+
"bear-fixed bear-z-[10000] bear-max-w-[calc(100vw-16px)] bear-bg-white dark:bear-bg-zinc-800 bear-border bear-border-gray-200 dark:bear-border-zinc-700 bear-rounded-xl bear-shadow-xl bear-p-4 bear-overflow-x-auto"
|
|
120
125
|
),
|
|
121
|
-
style: { top:
|
|
122
|
-
children: /* @__PURE__ */
|
|
123
|
-
V.length > 0 && /* @__PURE__ */
|
|
124
|
-
V.map((e) => /* @__PURE__ */ t("button", { type: "button", onClick: () =>
|
|
125
|
-
|
|
126
|
+
style: { top: z.top, left: z.left },
|
|
127
|
+
children: /* @__PURE__ */ d("div", { className: "bear-flex bear-gap-4", children: [
|
|
128
|
+
V.length > 0 && /* @__PURE__ */ d("div", { className: "bear-border-r bear-border-gray-200 dark:bear-border-zinc-700 bear-pr-3 bear-space-y-1 bear-min-w-[120px]", children: [
|
|
129
|
+
V.map((e) => /* @__PURE__ */ t("button", { type: "button", onClick: () => te(e.range()), className: $, children: e.label }, e.label)),
|
|
130
|
+
k && s.start && /* @__PURE__ */ t("button", { type: "button", onClick: re, className: p($, "bear-text-red-500"), children: "Clear" })
|
|
126
131
|
] }),
|
|
127
|
-
/* @__PURE__ */ t(
|
|
128
|
-
/* @__PURE__ */ t(
|
|
129
|
-
}, minDate:
|
|
132
|
+
/* @__PURE__ */ t(Z, { year: E, month: u, range: s, onDayClick: j, onNav: ae, minDate: x, maxDate: S }),
|
|
133
|
+
/* @__PURE__ */ t(Z, { year: ee, month: X, range: s, onDayClick: j, onNav: () => {
|
|
134
|
+
}, minDate: x, maxDate: S })
|
|
130
135
|
] })
|
|
131
136
|
}
|
|
132
137
|
),
|
|
133
138
|
document.body
|
|
134
139
|
),
|
|
135
|
-
l && /* @__PURE__ */ t("p", { className:
|
|
136
|
-
!l &&
|
|
140
|
+
l && /* @__PURE__ */ t("p", { className: me, children: l }),
|
|
141
|
+
!l && m && /* @__PURE__ */ t("p", { className: ue, children: m })
|
|
137
142
|
] });
|
|
138
143
|
};
|
|
139
144
|
export {
|
|
140
|
-
|
|
145
|
+
Pe as DateRangePicker
|
|
141
146
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),A=require("react"),D=require("../../utils/cn.cjs"),F=require("../Typography/Typography.cjs"),S=require("./DiffSquares.const.cjs"),E=require("./DiffSquares.utils.cjs"),N=({additionsText:n,deletionsText:t,cubeCount:c=S.DIFF_SQUARES_DEFAULT_COUNT,cubes:r,additionColor:m="var(--bear-colors-success-500, #22c55e)",deletionColor:q="var(--bear-colors-danger-500, #ef4444)",gap:_=S.DIFF_SQUARES_GAP,summaryTypographyProps:s,onCubeClick:i,onCubeHover:e,className:h,testId:j,...x})=>{const d=A.useMemo(()=>r!=null&&r.length?r:Array.from({length:c},()=>({fill:"full"})),[r,c]),g={variant:"body2",component:"span",...s,className:D.cn("bear-flex bear-shrink-0 bear-items-baseline bear-gap-1.5 bear-font-mono bear-font-semibold",s==null?void 0:s.className)};return l.jsxs("div",{className:D.cn("Bear-DiffSquares bear-inline-flex bear-min-w-0 bear-max-w-full bear-items-center bear-gap-2",h),"data-testid":j,...x,children:[(n!=null||t!=null)&&l.jsxs(F.Typography,{...g,children:[n!=null&&l.jsx("span",{style:{color:m},children:n}),t!=null&&l.jsx("span",{style:{color:q},children:t})]}),l.jsx("span",{className:"bear-inline-flex bear-items-center bear-flex-shrink-0",style:{gap:_},role:"img","aria-label":"Change density",children:d.map((a,f)=>l.jsx("span",{className:S.DIFF_SQUARES_CUBE_CLASS,style:E.getDiffCubeStyle(a,m,q),"aria-hidden":!(a!=null&&a.ariaLabel),title:a==null?void 0:a.ariaLabel,onMouseEnter:()=>e==null?void 0:e(a,f),onMouseLeave:()=>e==null?void 0:e(null,null),onClick:()=>i==null?void 0:i(a,f)},f))})]})};exports.DiffSquares=N;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=5,r="Bear-DiffSquares__cube bear-inline-block bear-w-2.5 bear-h-2.5 sm:bear-w-3 sm:bear-h-3 bear-rounded bear-shrink-0 bear-ring-1 bear-ring-inset bear-ring-black/18 dark:bear-ring-white/22 motion-reduce:bear-animate-none",a=4;exports.DIFF_SQUARES_CUBE_CLASS=r;exports.DIFF_SQUARES_DEFAULT_COUNT=e;exports.DIFF_SQUARES_GAP=a;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const DIFF_SQUARES_DEFAULT_COUNT = 5;
|
|
2
|
+
export declare const DIFF_SQUARES_CUBE_CLASS = "Bear-DiffSquares__cube bear-inline-block bear-w-2.5 bear-h-2.5 sm:bear-w-3 sm:bear-h-3 bear-rounded bear-shrink-0 bear-ring-1 bear-ring-inset bear-ring-black/18 dark:bear-ring-white/22 motion-reduce:bear-animate-none";
|
|
3
|
+
export declare const DIFF_SQUARES_GAP = 4;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const e = 5, r = "Bear-DiffSquares__cube bear-inline-block bear-w-2.5 bear-h-2.5 sm:bear-w-3 sm:bear-h-3 bear-rounded bear-shrink-0 bear-ring-1 bear-ring-inset bear-ring-black/18 dark:bear-ring-white/22 motion-reduce:bear-animate-none", a = 4;
|
|
2
|
+
export {
|
|
3
|
+
r as DIFF_SQUARES_CUBE_CLASS,
|
|
4
|
+
e as DIFF_SQUARES_DEFAULT_COUNT,
|
|
5
|
+
a as DIFF_SQUARES_GAP
|
|
6
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsxs as h, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as L } from "react";
|
|
3
|
+
import { cn as A } from "../../utils/cn.js";
|
|
4
|
+
import { Typography as g } from "../Typography/Typography.js";
|
|
5
|
+
import { DIFF_SQUARES_DEFAULT_COUNT as p, DIFF_SQUARES_GAP as x, DIFF_SQUARES_CUBE_CLASS as I } from "./DiffSquares.const.js";
|
|
6
|
+
import { getDiffCubeStyle as M } from "./DiffSquares.utils.js";
|
|
7
|
+
const B = ({
|
|
8
|
+
additionsText: s,
|
|
9
|
+
deletionsText: t,
|
|
10
|
+
cubeCount: m = p,
|
|
11
|
+
cubes: r,
|
|
12
|
+
additionColor: S = "var(--bear-colors-success-500, #22c55e)",
|
|
13
|
+
deletionColor: _ = "var(--bear-colors-danger-500, #ef4444)",
|
|
14
|
+
gap: D = x,
|
|
15
|
+
summaryTypographyProps: n,
|
|
16
|
+
onCubeClick: i,
|
|
17
|
+
onCubeHover: l,
|
|
18
|
+
className: F,
|
|
19
|
+
testId: E,
|
|
20
|
+
...N
|
|
21
|
+
}) => {
|
|
22
|
+
const U = L(() => r != null && r.length ? r : Array.from({ length: m }, () => ({ fill: "full" })), [r, m]), d = {
|
|
23
|
+
variant: "body2",
|
|
24
|
+
component: "span",
|
|
25
|
+
...n,
|
|
26
|
+
className: A(
|
|
27
|
+
"bear-flex bear-shrink-0 bear-items-baseline bear-gap-1.5 bear-font-mono bear-font-semibold",
|
|
28
|
+
n == null ? void 0 : n.className
|
|
29
|
+
)
|
|
30
|
+
};
|
|
31
|
+
return /* @__PURE__ */ h(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
className: A("Bear-DiffSquares bear-inline-flex bear-min-w-0 bear-max-w-full bear-items-center bear-gap-2", F),
|
|
35
|
+
"data-testid": E,
|
|
36
|
+
...N,
|
|
37
|
+
children: [
|
|
38
|
+
(s != null || t != null) && /* @__PURE__ */ h(g, { ...d, children: [
|
|
39
|
+
s != null && /* @__PURE__ */ e("span", { style: { color: S }, children: s }),
|
|
40
|
+
t != null && /* @__PURE__ */ e("span", { style: { color: _ }, children: t })
|
|
41
|
+
] }),
|
|
42
|
+
/* @__PURE__ */ e(
|
|
43
|
+
"span",
|
|
44
|
+
{
|
|
45
|
+
className: "bear-inline-flex bear-items-center bear-flex-shrink-0",
|
|
46
|
+
style: { gap: D },
|
|
47
|
+
role: "img",
|
|
48
|
+
"aria-label": "Change density",
|
|
49
|
+
children: U.map((a, f) => /* @__PURE__ */ e(
|
|
50
|
+
"span",
|
|
51
|
+
{
|
|
52
|
+
className: I,
|
|
53
|
+
style: M(a, S, _),
|
|
54
|
+
"aria-hidden": !(a != null && a.ariaLabel),
|
|
55
|
+
title: a == null ? void 0 : a.ariaLabel,
|
|
56
|
+
onMouseEnter: () => l == null ? void 0 : l(a, f),
|
|
57
|
+
onMouseLeave: () => l == null ? void 0 : l(null, null),
|
|
58
|
+
onClick: () => i == null ? void 0 : i(a, f)
|
|
59
|
+
},
|
|
60
|
+
f
|
|
61
|
+
))
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
export {
|
|
69
|
+
B as DiffSquares
|
|
70
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { TypographyProps } from '../Typography/Typography.types';
|
|
3
|
+
export type DiffCubeFill = 'full' | 'empty' | 'half' | 'striped';
|
|
4
|
+
export interface DiffCube {
|
|
5
|
+
fill?: DiffCubeFill;
|
|
6
|
+
color?: string;
|
|
7
|
+
secondaryColor?: string;
|
|
8
|
+
gradient?: string;
|
|
9
|
+
ariaLabel?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DiffSquaresProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
12
|
+
additionsText?: ReactNode;
|
|
13
|
+
deletionsText?: ReactNode;
|
|
14
|
+
cubeCount?: number;
|
|
15
|
+
cubes?: DiffCube[];
|
|
16
|
+
additionColor?: string;
|
|
17
|
+
deletionColor?: string;
|
|
18
|
+
gap?: number;
|
|
19
|
+
summaryTypographyProps?: Partial<TypographyProps>;
|
|
20
|
+
onCubeClick?: (cube: DiffCube, index: number) => void;
|
|
21
|
+
onCubeHover?: (cube: DiffCube | null, index: number | null) => void;
|
|
22
|
+
testId?: string;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function l(r,i,a){const t=(r==null?void 0:r.fill)??"full",n=(r==null?void 0:r.color)??i,o=(r==null?void 0:r.secondaryColor)??a;return r!=null&&r.gradient?{background:r.gradient}:t==="empty"?{backgroundColor:"transparent",boxShadow:`inset 0 0 0 1px ${n}55`}:t==="half"?{background:`linear-gradient(90deg, ${n} 50%, ${o} 50%)`}:t==="striped"?{background:`repeating-linear-gradient(135deg, ${n}, ${n} 2px, ${o} 2px, ${o} 4px)`}:{backgroundColor:n}}exports.getDiffCubeStyle=l;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function d(r, a, i) {
|
|
2
|
+
const o = (r == null ? void 0 : r.fill) ?? "full", n = (r == null ? void 0 : r.color) ?? a, t = (r == null ? void 0 : r.secondaryColor) ?? i;
|
|
3
|
+
return r != null && r.gradient ? { background: r.gradient } : o === "empty" ? {
|
|
4
|
+
backgroundColor: "transparent",
|
|
5
|
+
boxShadow: `inset 0 0 0 1px ${n}55`
|
|
6
|
+
} : o === "half" ? { background: `linear-gradient(90deg, ${n} 50%, ${t} 50%)` } : o === "striped" ? {
|
|
7
|
+
background: `repeating-linear-gradient(135deg, ${n}, ${n} 2px, ${t} 2px, ${t} 4px)`
|
|
8
|
+
} : { backgroundColor: n };
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
d as getDiffCubeStyle
|
|
12
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),a=require("react"),j=require("react-dom"),x=require("../../utils/cn.cjs"),N=require("../Icon/index.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),a=require("react"),j=require("react-dom"),x=require("../../utils/cn.cjs"),N=require("../Icon/index.cjs"),m=300,q={left:{sm:"bear-w-full sm:bear-w-64 bear-max-w-full sm:bear-max-w-none",md:"bear-w-full sm:bear-w-80 bear-max-w-full sm:bear-max-w-none",lg:"bear-w-full sm:bear-w-96 bear-max-w-full sm:bear-max-w-none",xl:"bear-w-full sm:bear-w-[32rem] bear-max-w-full sm:bear-max-w-none"},right:{sm:"bear-w-full sm:bear-w-64 bear-max-w-full sm:bear-max-w-none",md:"bear-w-full sm:bear-w-80 bear-max-w-full sm:bear-max-w-none",lg:"bear-w-full sm:bear-w-96 bear-max-w-full sm:bear-max-w-none",xl:"bear-w-full sm:bear-w-[32rem] bear-max-w-full sm:bear-max-w-none"},top:{sm:"bear-h-32",md:"bear-h-48",lg:"bear-h-64",xl:"bear-h-96"},bottom:{sm:"bear-h-32",md:"bear-h-48",lg:"bear-h-64",xl:"bear-h-96"}},C={left:"bear-left-0 bear-top-0 bear-h-full",right:"bear-right-0 bear-top-0 bear-h-full",top:"bear-top-0 bear-left-0 bear-w-full",bottom:"bear-bottom-0 bear-left-0 bear-w-full"},D={left:"bear-translate-x-0",right:"bear-translate-x-0",top:"bear-translate-y-0",bottom:"bear-translate-y-0"},E={left:"-bear-translate-x-full",right:"bear-translate-x-full",top:"-bear-translate-y-full",bottom:"bear-translate-y-full"},S=({isOpen:n,onClose:l,title:s,children:h,side:e="right",size:g="md",showCloseButton:i=!0,closeOnBackdrop:y=!0,closeOnEscape:d=!0,className:p})=>{const[t,f]=a.useState(n),[c,o]=a.useState(!1),[v,w]=a.useState(!1);a.useEffect(()=>{if(n){f(!0),o(!1);const b=requestAnimationFrame(()=>w(!0));return()=>cancelAnimationFrame(b)}if(t){w(!1),o(!0);const b=setTimeout(()=>{f(!1),o(!1)},m);return()=>clearTimeout(b)}},[n,t]);const u=a.useCallback(b=>{d&&b.key==="Escape"&&l()},[d,l]);if(a.useEffect(()=>(t&&(document.addEventListener("keydown",u),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",u),document.body.style.overflow=""}),[t,u]),!t)return null;const k=r.jsxs("div",{className:"bear-fixed bear-inset-0 bear-z-[11000]",children:[r.jsx("div",{className:x.cn("bear-absolute bear-inset-0 bear-bg-black/60 bear-backdrop-blur-sm bear-transition-opacity",c?"bear-opacity-0":"bear-opacity-100"),style:{transitionDuration:`${m}ms`},onClick:y?l:void 0,"aria-hidden":"true"}),r.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":s?"drawer-title":void 0,className:x.cn("bear-absolute bear-bg-white dark:bear-bg-neutral-900 bear-shadow-2xl","bear-border-neutral-200 dark:bear-border-neutral-700 bear-overflow-hidden","bear-transform bear-transition-transform",e==="left"&&"bear-border-r",e==="right"&&"bear-border-l",e==="top"&&"bear-border-b",e==="bottom"&&"bear-border-t",C[e],q[e][g],v&&!c?D[e]:E[e],p),style:{transitionDuration:`${m}ms`},children:[(s||i)&&r.jsxs("div",{className:"bear-flex bear-items-center bear-justify-between bear-px-4 bear-py-3 bear-border-b bear-border-neutral-200 dark:bear-border-neutral-700",children:[s&&r.jsx("h2",{id:"drawer-title",className:"bear-text-lg bear-font-semibold bear-text-neutral-900 dark:bear-text-white",children:s}),i&&r.jsx("button",{onClick:l,className:"bear-p-1 bear-rounded-lg bear-text-neutral-500 dark:bear-text-neutral-400 hover:bear-text-neutral-900 dark:hover:bear-text-white hover:bear-bg-neutral-100 dark:hover:bear-bg-neutral-700 bear-transition-colors","aria-label":"Close drawer",children:r.jsx(N.XIcon,{className:"bear-w-5 bear-h-5"})})]}),r.jsx("div",{className:"bear-flex-1 bear-overflow-y-auto bear-p-4 bear-text-neutral-700 dark:bear-text-neutral-300",children:h})]})]});return j.createPortal(k,document.body)};exports.Drawer=S;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsxs as m, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u, useEffect as h, useCallback as A } from "react";
|
|
3
3
|
import { createPortal as E } from "react-dom";
|
|
4
|
-
import { cn as
|
|
4
|
+
import { cn as p } from "../../utils/cn.js";
|
|
5
5
|
import { XIcon as I } from "../Icon/index.js";
|
|
6
|
-
const
|
|
6
|
+
const i = 300, D = {
|
|
7
7
|
left: {
|
|
8
|
-
sm: "bear-w-64",
|
|
9
|
-
md: "bear-w-80",
|
|
10
|
-
lg: "bear-w-96",
|
|
11
|
-
xl: "bear-w-[32rem]"
|
|
8
|
+
sm: "bear-w-full sm:bear-w-64 bear-max-w-full sm:bear-max-w-none",
|
|
9
|
+
md: "bear-w-full sm:bear-w-80 bear-max-w-full sm:bear-max-w-none",
|
|
10
|
+
lg: "bear-w-full sm:bear-w-96 bear-max-w-full sm:bear-max-w-none",
|
|
11
|
+
xl: "bear-w-full sm:bear-w-[32rem] bear-max-w-full sm:bear-max-w-none"
|
|
12
12
|
},
|
|
13
13
|
right: {
|
|
14
|
-
sm: "bear-w-64",
|
|
15
|
-
md: "bear-w-80",
|
|
16
|
-
lg: "bear-w-96",
|
|
17
|
-
xl: "bear-w-[32rem]"
|
|
14
|
+
sm: "bear-w-full sm:bear-w-64 bear-max-w-full sm:bear-max-w-none",
|
|
15
|
+
md: "bear-w-full sm:bear-w-80 bear-max-w-full sm:bear-max-w-none",
|
|
16
|
+
lg: "bear-w-full sm:bear-w-96 bear-max-w-full sm:bear-max-w-none",
|
|
17
|
+
xl: "bear-w-full sm:bear-w-[32rem] bear-max-w-full sm:bear-max-w-none"
|
|
18
18
|
},
|
|
19
19
|
top: {
|
|
20
20
|
sm: "bear-h-32",
|
|
@@ -44,61 +44,61 @@ const m = 300, D = {
|
|
|
44
44
|
top: "-bear-translate-y-full",
|
|
45
45
|
bottom: "bear-translate-y-full"
|
|
46
46
|
}, _ = ({
|
|
47
|
-
isOpen:
|
|
47
|
+
isOpen: o,
|
|
48
48
|
onClose: b,
|
|
49
|
-
title:
|
|
49
|
+
title: l,
|
|
50
50
|
children: g,
|
|
51
51
|
side: e = "right",
|
|
52
52
|
size: y = "md",
|
|
53
|
-
showCloseButton:
|
|
53
|
+
showCloseButton: d = !0,
|
|
54
54
|
closeOnBackdrop: v = !0,
|
|
55
|
-
closeOnEscape:
|
|
55
|
+
closeOnEscape: f = !0,
|
|
56
56
|
className: k
|
|
57
57
|
}) => {
|
|
58
|
-
const [r,
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
const a = requestAnimationFrame(() =>
|
|
58
|
+
const [r, w] = u(o), [c, n] = u(!1), [N, x] = u(!1);
|
|
59
|
+
h(() => {
|
|
60
|
+
if (o) {
|
|
61
|
+
w(!0), n(!1);
|
|
62
|
+
const a = requestAnimationFrame(() => x(!0));
|
|
63
63
|
return () => cancelAnimationFrame(a);
|
|
64
64
|
}
|
|
65
65
|
if (r) {
|
|
66
|
-
|
|
66
|
+
x(!1), n(!0);
|
|
67
67
|
const a = setTimeout(() => {
|
|
68
|
-
|
|
69
|
-
},
|
|
68
|
+
w(!1), n(!1);
|
|
69
|
+
}, i);
|
|
70
70
|
return () => clearTimeout(a);
|
|
71
71
|
}
|
|
72
|
-
}, [
|
|
72
|
+
}, [o, r]);
|
|
73
73
|
const s = A(
|
|
74
74
|
(a) => {
|
|
75
|
-
|
|
75
|
+
f && a.key === "Escape" && b();
|
|
76
76
|
},
|
|
77
|
-
[
|
|
77
|
+
[f, b]
|
|
78
78
|
);
|
|
79
|
-
if (
|
|
79
|
+
if (h(() => (r && (document.addEventListener("keydown", s), document.body.style.overflow = "hidden"), () => {
|
|
80
80
|
document.removeEventListener("keydown", s), document.body.style.overflow = "";
|
|
81
81
|
}), [r, s]), !r) return null;
|
|
82
|
-
const C = /* @__PURE__ */
|
|
82
|
+
const C = /* @__PURE__ */ m("div", { className: "bear-fixed bear-inset-0 bear-z-[11000]", children: [
|
|
83
83
|
/* @__PURE__ */ t(
|
|
84
84
|
"div",
|
|
85
85
|
{
|
|
86
|
-
className:
|
|
86
|
+
className: p(
|
|
87
87
|
"bear-absolute bear-inset-0 bear-bg-black/60 bear-backdrop-blur-sm bear-transition-opacity",
|
|
88
|
-
|
|
88
|
+
c ? "bear-opacity-0" : "bear-opacity-100"
|
|
89
89
|
),
|
|
90
|
-
style: { transitionDuration: `${
|
|
90
|
+
style: { transitionDuration: `${i}ms` },
|
|
91
91
|
onClick: v ? b : void 0,
|
|
92
92
|
"aria-hidden": "true"
|
|
93
93
|
}
|
|
94
94
|
),
|
|
95
|
-
/* @__PURE__ */
|
|
95
|
+
/* @__PURE__ */ m(
|
|
96
96
|
"div",
|
|
97
97
|
{
|
|
98
98
|
role: "dialog",
|
|
99
99
|
"aria-modal": "true",
|
|
100
|
-
"aria-labelledby":
|
|
101
|
-
className:
|
|
100
|
+
"aria-labelledby": l ? "drawer-title" : void 0,
|
|
101
|
+
className: p(
|
|
102
102
|
"bear-absolute bear-bg-white dark:bear-bg-neutral-900 bear-shadow-2xl",
|
|
103
103
|
"bear-border-neutral-200 dark:bear-border-neutral-700 bear-overflow-hidden",
|
|
104
104
|
"bear-transform bear-transition-transform",
|
|
@@ -108,21 +108,21 @@ const m = 300, D = {
|
|
|
108
108
|
e === "bottom" && "bear-border-t",
|
|
109
109
|
M[e],
|
|
110
110
|
D[e][y],
|
|
111
|
-
N && !
|
|
111
|
+
N && !c ? j[e] : T[e],
|
|
112
112
|
k
|
|
113
113
|
),
|
|
114
|
-
style: { transitionDuration: `${
|
|
114
|
+
style: { transitionDuration: `${i}ms` },
|
|
115
115
|
children: [
|
|
116
|
-
(
|
|
117
|
-
|
|
116
|
+
(l || d) && /* @__PURE__ */ m("div", { className: "bear-flex bear-items-center bear-justify-between bear-px-4 bear-py-3 bear-border-b bear-border-neutral-200 dark:bear-border-neutral-700", children: [
|
|
117
|
+
l && /* @__PURE__ */ t(
|
|
118
118
|
"h2",
|
|
119
119
|
{
|
|
120
120
|
id: "drawer-title",
|
|
121
121
|
className: "bear-text-lg bear-font-semibold bear-text-neutral-900 dark:bear-text-white",
|
|
122
|
-
children:
|
|
122
|
+
children: l
|
|
123
123
|
}
|
|
124
124
|
),
|
|
125
|
-
|
|
125
|
+
d && /* @__PURE__ */ t(
|
|
126
126
|
"button",
|
|
127
127
|
{
|
|
128
128
|
onClick: b,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),t=require("react"),E=require("../../utils/cn.cjs"),J=require("../../hooks/useClickOutside.cjs");require("../../context/BearProvider.cjs");require("../../hooks/useBearComponent/useBearComponent.cjs");const Q=require("../Portal/Portal.cjs"),X=require("./Dropdown.const.cjs"),Y=({trigger:x,items:c,open:j,defaultOpen:q=!1,placement:i="bottom-start",offset:v=4,matchWidth:C=!1,minWidth:h=150,maxHeight:M=300,size:S="md",closeOnSelect:I=!0,closeOnClickOutside:g=!0,disabled:R=!1,onOpenChange:f,className:P,testId:W,...z})=>{const[A,U]=t.useState(q),[b,u]=t.useState(-1),[k,B]=t.useState({top:0,left:0,minWidth:h}),D=t.useRef(null),L=t.useRef(null),N=t.useRef(null),w=j!==void 0,n=w?j:A,p=t.useCallback(e=>{w||U(e),f==null||f(e)},[w,f]),F=t.useCallback(()=>{R||p(!n)},[R,n,p]),d=t.useCallback(()=>{p(!1),u(-1)},[p]),y=t.useCallback(e=>{var r;e.disabled||e.divider||e.header||((r=e.onClick)==null||r.call(e),I&&!e.items&&d())},[I,d]),T=t.useCallback(()=>{n&&g&&d()},[n,g,d]);J.useClickOutsideMultiple([D,L],T,{enabled:n&&g}),t.useEffect(()=>{if(!n)return;const e=c.filter(a=>!a.disabled&&!a.divider&&!a.header),r=a=>{switch(a.key){case"Escape":a.preventDefault(),d();break;case"ArrowDown":a.preventDefault(),u(o=>{const l=o+1;return l>=e.length?0:l});break;case"ArrowUp":a.preventDefault(),u(o=>{const l=o-1;return l<0?e.length-1:l});break;case"Enter":case" ":a.preventDefault(),b>=0&&b<e.length&&y(e[b]);break}};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[n,c,b,d,y]),t.useEffect(()=>{if(!n)return;const e=()=>{var m;const r=(m=N.current)==null?void 0:m.getBoundingClientRect();if(!r)return;const a=window.innerWidth,o=C?r.width:h,Z=i.endsWith("end")?r.right-o:i==="top"||i==="bottom"?r.left+r.width/2-o/2:r.left,G=Math.min(Math.max(8,Z),Math.max(8,a-o-8)),H=i.startsWith("top")?r.top-v:r.bottom+v;B({top:H,left:G,minWidth:o})};return e(),window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[n,C,h,i,v]),t.useEffect(()=>{n||u(-1)},[n]);const _=t.useMemo(()=>c.map((e,r)=>({item:e,index:r})).filter(({item:e})=>!e.disabled&&!e.divider&&!e.header),[c]),K=(e,r)=>{if(e.divider)return s.jsx("div",{className:"bear-my-1 bear-mx-2 bear-h-px",style:{backgroundColor:"var(--bear-border-default)"},role:"separator"},e.key);if(e.header)return s.jsx("div",{className:"bear-px-3 bear-py-1.5 bear-text-xs bear-font-semibold bear-uppercase bear-tracking-wider",style:{color:"var(--bear-text-muted)"},children:e.label},e.key);const a=_.findIndex(l=>l.index===r),o=b===a;return s.jsxs("button",{type:"button",role:"menuitem",disabled:e.disabled,onClick:()=>y(e),onMouseEnter:()=>u(a),className:E.cn("bear-w-full bear-flex bear-items-center bear-gap-2 bear-text-left bear-border-none bear-bg-transparent",X.SIZE_CLASSES[S],"bear-transition-colors bear-cursor-pointer",e.selected&&!e.danger&&"bear-bg-[var(--bear-bg-tertiary)] bear-text-[var(--bear-text-primary)]",o&&!e.danger&&"bear-bg-[var(--bear-bg-tertiary)]",e.danger&&"bear-text-red-600 dark:bear-text-red-400 hover:bear-bg-red-50 dark:hover:bear-bg-red-900/20",!e.danger&&!e.disabled&&"hover:bear-bg-[var(--bear-bg-tertiary)]",e.disabled&&"bear-opacity-50 bear-cursor-not-allowed bear-pointer-events-none"),style:e.disabled?{color:"var(--bear-text-muted)"}:e.danger?void 0:{color:"var(--bear-text-secondary)"},children:[e.icon&&s.jsx("span",{className:"bear-flex-shrink-0 bear-w-5 bear-h-5 bear-flex bear-items-center bear-justify-center",children:e.icon}),s.jsx("span",{className:"bear-flex-1",children:e.label}),e.trailing&&s.jsx("span",{className:"bear-flex-shrink-0",style:{color:"var(--bear-text-muted)"},children:e.trailing}),e.items&&s.jsx("svg",{className:"bear-w-4 bear-h-4 bear-flex-shrink-0",style:{color:"var(--bear-text-muted)"},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"9 18 15 12 9 6"})})]},e.key)},V=t.isValidElement(x)?t.cloneElement(x,{onClick:F,ref:N,"aria-expanded":n,"aria-haspopup":!0}):x;return s.jsxs("div",{ref:D,className:E.cn("bear-relative bear-inline-block",P),"data-testid":W,...z,children:[V,n&&s.jsx(Q.Portal,{children:s.jsx("div",{ref:L,role:"menu",className:E.cn("bear-fixed","bear-border bear-rounded-lg bear-shadow-lg","bear-py-1 bear-overflow-y-auto","bear-duration-100"),style:{backgroundColor:"var(--bear-bg-primary)",borderColor:"var(--bear-border-default)",minWidth:k.minWidth,maxHeight:M,top:k.top,left:k.left,zIndex:11e3},children:c.map((e,r)=>K(e,r))})})]})};exports.Dropdown=Y;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={xs:"bear-text-xs bear-py-1 bear-px-2",sm:"bear-text-sm bear-py-1.5 bear-px-3",md:"bear-text-sm bear-py-2 bear-px-3",lg:"bear-text-base bear-py-2.5 bear-px-4",xl:"bear-text-lg bear-py-3 bear-px-5"};exports.SIZE_CLASSES=e;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const SIZE_CLASSES: {
|
|
2
|
+
readonly xs: "bear-text-xs bear-py-1 bear-px-2";
|
|
3
|
+
readonly sm: "bear-text-sm bear-py-1.5 bear-px-3";
|
|
4
|
+
readonly md: "bear-text-sm bear-py-2 bear-px-3";
|
|
5
|
+
readonly lg: "bear-text-base bear-py-2.5 bear-px-4";
|
|
6
|
+
readonly xl: "bear-text-lg bear-py-3 bear-px-5";
|
|
7
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
xs: "bear-text-xs bear-py-1 bear-px-2",
|
|
3
|
+
sm: "bear-text-sm bear-py-1.5 bear-px-3",
|
|
4
|
+
md: "bear-text-sm bear-py-2 bear-px-3",
|
|
5
|
+
lg: "bear-text-base bear-py-2.5 bear-px-4",
|
|
6
|
+
xl: "bear-text-lg bear-py-3 bear-px-5"
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
e as SIZE_CLASSES
|
|
10
|
+
};
|