@forgedevstack/bear 1.1.9 → 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/AlertDialog/AlertDialog.cjs +1 -1
- package/dist/components/AlertDialog/AlertDialog.const.cjs +1 -1
- package/dist/components/AlertDialog/AlertDialog.const.d.ts +2 -2
- package/dist/components/AlertDialog/AlertDialog.const.js +4 -4
- package/dist/components/AlertDialog/AlertDialog.js +76 -62
- 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/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.js +3 -2
- 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/CloseButton/CloseButton.cjs +1 -0
- package/dist/components/CloseButton/CloseButton.d.ts +4 -0
- package/dist/components/CloseButton/CloseButton.js +60 -0
- package/dist/components/CloseButton/CloseButton.types.d.ts +15 -0
- package/dist/components/CloseButton/index.d.ts +2 -0
- 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/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/DatePicker/DatePicker.js +12 -11
- 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/commerce.cjs +1 -0
- package/dist/components/Icon/icons/commerce.d.ts +25 -0
- package/dist/components/Icon/icons/commerce.js +124 -0
- package/dist/components/Icon/icons/device.cjs +1 -0
- package/dist/components/Icon/icons/device.d.ts +27 -0
- package/dist/components/Icon/icons/device.js +122 -0
- package/dist/components/Icon/icons/file.cjs +1 -0
- package/dist/components/Icon/icons/file.d.ts +25 -0
- package/dist/components/Icon/icons/file.js +120 -0
- package/dist/components/Icon/icons/social.cjs +1 -0
- package/dist/components/Icon/icons/social.d.ts +24 -0
- package/dist/components/Icon/icons/social.js +89 -0
- package/dist/components/Icon/icons/status.js +1 -1
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.d.ts +93 -56
- package/dist/components/Icon/index.js +38 -26
- 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/Overlay/Overlay.cjs +1 -0
- package/dist/components/Overlay/Overlay.d.ts +4 -0
- package/dist/components/Overlay/Overlay.js +38 -0
- package/dist/components/Overlay/Overlay.types.d.ts +23 -0
- package/dist/components/Overlay/index.d.ts +2 -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 -0
- package/dist/components/Portal/Portal.d.ts +8 -0
- package/dist/components/Portal/Portal.js +6 -0
- package/dist/components/Portal/index.d.ts +2 -0
- 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/ThemeIcon/ThemeIcon.cjs +1 -0
- package/dist/components/ThemeIcon/ThemeIcon.d.ts +4 -0
- package/dist/components/ThemeIcon/ThemeIcon.js +54 -0
- package/dist/components/ThemeIcon/ThemeIcon.types.d.ts +22 -0
- package/dist/components/ThemeIcon/index.d.ts +2 -0
- 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/VisuallyHidden/VisuallyHidden.cjs +1 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +6 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.js +22 -0
- package/dist/components/VisuallyHidden/index.d.ts +2 -0
- 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 +15 -3
- package/dist/components/index.js +296 -280
- package/dist/hooks/bearStyled.cjs +1 -1
- package/dist/hooks/bearStyled.d.ts +31 -9
- package/dist/hooks/bearStyled.js +17 -12
- 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/hooks/useMediaQuery/useMediaQuery.d.ts +9 -1
- package/dist/hooks/useResponsive.cjs +1 -1
- package/dist/hooks/useResponsive.d.ts +2 -17
- package/dist/hooks/useResponsive.js +47 -41
- package/dist/index.cjs +1 -1
- package/dist/index.js +383 -366
- package/dist/styles/_effects.css +26 -0
- package/dist/styles.css +1 -1
- package/dist/types/theme.types.d.ts +1 -0
- 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,81 +1,89 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { cn as
|
|
5
|
-
const
|
|
1
|
+
import { jsxs as k, Fragment as L, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { useState as w, useRef as h, useCallback as C, useEffect as b } from "react";
|
|
3
|
+
import { createPortal as _ } from "react-dom";
|
|
4
|
+
import { cn as z } from "../../utils/cn.js";
|
|
5
|
+
const V = ({
|
|
6
6
|
content: x,
|
|
7
|
-
children:
|
|
8
|
-
position:
|
|
9
|
-
placement:
|
|
10
|
-
delay:
|
|
11
|
-
className:
|
|
12
|
-
disabled:
|
|
7
|
+
children: v,
|
|
8
|
+
position: y,
|
|
9
|
+
placement: M,
|
|
10
|
+
delay: R = 200,
|
|
11
|
+
className: T,
|
|
12
|
+
disabled: B = !1
|
|
13
13
|
}) => {
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
16
|
-
const e =
|
|
14
|
+
const c = M || y || "top", [i, m] = w(!1), [f, E] = w({ x: 0, y: 0 }), l = h(null), u = h(null), n = h(), a = C(() => {
|
|
15
|
+
if (!l.current || !u.current) return;
|
|
16
|
+
const e = l.current.getBoundingClientRect(), t = u.current.getBoundingClientRect(), s = 8;
|
|
17
17
|
let r = 0, o = 0;
|
|
18
|
-
switch (
|
|
18
|
+
switch (c) {
|
|
19
19
|
case "top":
|
|
20
|
-
r = e.left + (e.width - t.width) / 2, o = e.top - t.height -
|
|
20
|
+
r = e.left + (e.width - t.width) / 2, o = e.top - t.height - s;
|
|
21
21
|
break;
|
|
22
22
|
case "bottom":
|
|
23
|
-
r = e.left + (e.width - t.width) / 2, o = e.bottom +
|
|
23
|
+
r = e.left + (e.width - t.width) / 2, o = e.bottom + s;
|
|
24
24
|
break;
|
|
25
25
|
case "left":
|
|
26
|
-
r = e.left - t.width -
|
|
26
|
+
r = e.left - t.width - s, o = e.top + (e.height - t.height) / 2;
|
|
27
27
|
break;
|
|
28
28
|
case "right":
|
|
29
|
-
r = e.right +
|
|
29
|
+
r = e.right + s, o = e.top + (e.height - t.height) / 2;
|
|
30
30
|
break;
|
|
31
31
|
}
|
|
32
|
-
r = Math.max(8, Math.min(r, window.innerWidth - t.width - 8)), o = Math.max(8, Math.min(o, window.innerHeight - t.height - 8)),
|
|
33
|
-
}, [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
32
|
+
r = Math.max(8, Math.min(r, window.innerWidth - t.width - 8)), o = Math.max(8, Math.min(o, window.innerHeight - t.height - 8)), E({ x: r, y: o });
|
|
33
|
+
}, [c]), g = () => {
|
|
34
|
+
B || (n.current = setTimeout(() => {
|
|
35
|
+
m(!0);
|
|
36
|
+
}, R));
|
|
37
37
|
}, p = () => {
|
|
38
|
-
|
|
38
|
+
n.current && clearTimeout(n.current), m(!1);
|
|
39
39
|
};
|
|
40
|
-
return
|
|
41
|
-
|
|
42
|
-
}, [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
return b(() => {
|
|
41
|
+
i && a();
|
|
42
|
+
}, [i, a]), b(() => {
|
|
43
|
+
if (!i) return;
|
|
44
|
+
const e = () => {
|
|
45
|
+
requestAnimationFrame(() => a());
|
|
46
|
+
};
|
|
47
|
+
return e(), window.addEventListener("resize", e), window.addEventListener("scroll", e, !0), () => {
|
|
48
|
+
window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
|
|
49
|
+
};
|
|
50
|
+
}, [i, a]), b(() => () => {
|
|
51
|
+
n.current && clearTimeout(n.current);
|
|
52
|
+
}, []), /* @__PURE__ */ k(L, { children: [
|
|
53
|
+
/* @__PURE__ */ d(
|
|
46
54
|
"div",
|
|
47
55
|
{
|
|
48
|
-
ref:
|
|
56
|
+
ref: l,
|
|
49
57
|
onMouseEnter: g,
|
|
50
58
|
onMouseLeave: p,
|
|
51
59
|
onFocus: g,
|
|
52
60
|
onBlur: p,
|
|
53
61
|
className: "Bear-Tooltip__trigger bear-inline-block",
|
|
54
|
-
children:
|
|
62
|
+
children: v
|
|
55
63
|
}
|
|
56
64
|
),
|
|
57
|
-
|
|
58
|
-
/* @__PURE__ */
|
|
65
|
+
i && _(
|
|
66
|
+
/* @__PURE__ */ d(
|
|
59
67
|
"div",
|
|
60
68
|
{
|
|
61
|
-
ref:
|
|
69
|
+
ref: u,
|
|
62
70
|
role: "tooltip",
|
|
63
71
|
style: {
|
|
64
|
-
left:
|
|
65
|
-
top:
|
|
72
|
+
left: f.x,
|
|
73
|
+
top: f.y
|
|
66
74
|
},
|
|
67
|
-
className:
|
|
68
|
-
"bear-fixed bear-z-[
|
|
75
|
+
className: z(
|
|
76
|
+
"bear-fixed bear-z-[11000]",
|
|
69
77
|
"Bear-Tooltip",
|
|
70
|
-
`Bear-Tooltip--${
|
|
78
|
+
`Bear-Tooltip--${c}`,
|
|
71
79
|
"bear-px-3 bear-py-2 bear-rounded-lg",
|
|
72
80
|
"bear-bg-gray-800 bear-text-white bear-text-sm",
|
|
73
81
|
"bear-border bear-border-gray-700",
|
|
74
82
|
"bear-shadow-lg",
|
|
75
83
|
"bear-animate-in bear-fade-in bear-duration-150",
|
|
76
|
-
|
|
84
|
+
T
|
|
77
85
|
),
|
|
78
|
-
children: /* @__PURE__ */
|
|
86
|
+
children: /* @__PURE__ */ d("span", { className: "Bear-Tooltip__content", children: x })
|
|
79
87
|
}
|
|
80
88
|
),
|
|
81
89
|
document.body
|
|
@@ -83,5 +91,5 @@ const z = ({
|
|
|
83
91
|
] });
|
|
84
92
|
};
|
|
85
93
|
export {
|
|
86
|
-
|
|
94
|
+
V as Tooltip
|
|
87
95
|
};
|
|
@@ -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"),l=require("react"),x=require("../../utils/cn.cjs"),Z=require("../Portal/Portal.cjs"),s=require("./TreeSelect.const.cjs"),N=require("./TreeSelect.utils.cjs"),U=1e4,I=({node:a,depth:i,selected:d,expanded:n,multiple:o,onToggleExpand:f,onSelect:p})=>{const u=a.children&&a.children.length>0,E=n.has(a.id),h=d.has(a.id);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:x.cn(s.NODE_CLASSES,h&&s.NODE_SELECTED_CLASSES,a.disabled&&s.NODE_DISABLED_CLASSES),style:{paddingLeft:i*s.INDENT_PX+12},onClick:()=>!a.disabled&&p(a.id),role:"treeitem","aria-selected":h,"aria-expanded":u?E:void 0,children:[u?e.jsx("svg",{className:x.cn(s.CHEVRON_CLASSES,E&&"bear-rotate-90"),onClick:m=>{m.stopPropagation(),f(a.id)},fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}):e.jsx("span",{className:"bear-w-4 bear-mr-1"}),o&&e.jsx("span",{className:x.cn("bear-w-4 bear-h-4 bear-mr-2 bear-border bear-rounded bear-flex bear-items-center bear-justify-center bear-text-xs",h?"bear-bg-pink-500 bear-border-pink-500 bear-text-white":"bear-border-gray-300 dark:bear-border-zinc-600"),children:h&&"✓"}),a.icon&&e.jsx("span",{className:"bear-mr-1.5",children:a.icon}),e.jsx("span",{className:"bear-truncate",children:a.label})]}),u&&E&&a.children.map(m=>e.jsx(I,{node:m,depth:i+1,selected:d,expanded:n,multiple:o,onToggleExpand:f,onSelect:p},m.id))]})},J=a=>{const{nodes:i,value:d,onChange:n,multiple:o=!1,label:f,placeholder:p="Select…",disabled:u=!1,clearable:E=!0,searchable:h=!0,expandAll:m=!1,size:O="md",error:w,helperText:C,maxHeight:P=s.DEFAULT_MAX_HEIGHT,className:D,testId:M,...z}=a,[b,j]=l.useState(!1),[L,v]=l.useState(""),y=l.useRef(null),_=l.useRef(null),g=l.useRef(null),[A,B]=l.useState({top:0,left:0,width:0}),q=l.useMemo(()=>N.collectAllIds(i),[i]),[H,G]=l.useState(()=>m?q:new Set),S=l.useMemo(()=>d?new Set(Array.isArray(d)?d:[d]):new Set,[d]);l.useEffect(()=>{if(!b)return;const r=()=>{var c;const t=(c=_.current)==null?void 0:c.getBoundingClientRect();t&&B({top:t.bottom+4,left:Math.max(8,Math.min(t.left,window.innerWidth-t.width-8)),width:t.width})};return r(),window.addEventListener("resize",r),window.addEventListener("scroll",r,!0),()=>{window.removeEventListener("resize",r),window.removeEventListener("scroll",r,!0)}},[b]),l.useEffect(()=>{if(!b)return;const r=t=>{var k,T;const c=t.target;(k=y.current)!=null&&k.contains(c)||(T=g.current)!=null&&T.contains(c)||(j(!1),v(""))};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[b]);const W=l.useCallback(r=>{G(t=>{const c=new Set(t);return c.has(r)?c.delete(r):c.add(r),c})},[]),F=l.useCallback(r=>{if(o){const t=new Set(S);t.has(r)?t.delete(r):t.add(r),n==null||n(Array.from(t))}else n==null||n(r),j(!1),v("")},[o,S,n]),V=l.useCallback(()=>{n==null||n(o?[]:"")},[o,n]),R=L?N.filterNodes(i,L):i,X=()=>{if(S.size===0)return e.jsx("span",{className:"bear-text-gray-400 dark:bear-text-zinc-500",children:p});if(o)return e.jsx("div",{className:"bear-flex bear-flex-wrap bear-gap-1",children:Array.from(S).map(t=>{const c=N.findNodeById(i,t);return c?e.jsx("span",{className:s.TAG_CLASSES,children:c.label},t):null})});const r=N.findNodeById(i,Array.from(S)[0]);return(r==null?void 0:r.label)??p};return e.jsxs("div",{ref:y,className:x.cn(s.ROOT_CLASSES,D),"data-testid":M,...z,children:[f&&e.jsx("label",{className:s.LABEL_CLASSES,children:f}),e.jsxs("button",{ref:_,type:"button",disabled:u,onClick:()=>!u&&j(!b),className:x.cn(s.TRIGGER_CLASSES,s.SIZE_CLASSES[O],u&&"bear-opacity-50 bear-cursor-not-allowed"),children:[e.jsx("span",{className:"bear-flex-1 bear-text-left bear-truncate",children:X()}),e.jsxs("div",{className:"bear-flex bear-items-center bear-gap-1",children:[E&&S.size>0&&e.jsx("span",{className:"bear-text-gray-400 hover:bear-text-gray-600 bear-cursor-pointer",onClick:r=>{r.stopPropagation(),V()},children:"✕"}),e.jsx("svg",{className:x.cn("bear-w-4 bear-h-4 bear-text-gray-400 bear-transition-transform",b&&"bear-rotate-180"),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),b&&e.jsx(Z.Portal,{children:e.jsxs("div",{ref:g,className:x.cn(s.DROPDOWN_CLASSES,"bear-fixed"),style:{top:A.top,left:A.left,width:A.width,zIndex:U},children:[h&&e.jsx("input",{className:s.SEARCH_CLASSES,placeholder:"Search…",value:L,onChange:r=>v(r.target.value),autoFocus:!0}),e.jsx("div",{style:{maxHeight:P},className:"bear-overflow-y-auto",role:"tree",children:R.length>0?R.map(r=>e.jsx(I,{node:r,depth:0,selected:S,expanded:H,multiple:o,onToggleExpand:W,onSelect:F},r.id)):e.jsx("div",{className:"bear-py-6 bear-text-center bear-text-sm bear-text-gray-400",children:"No results"})})]})}),w&&e.jsx("p",{className:s.ERROR_CLASSES,children:w}),!w&&C&&e.jsx("p",{className:s.HELPER_CLASSES,children:C})]})};exports.TreeSelect=J;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=280,r=20,a={sm:"bear-py-1.5 bear-px-3 bear-text-sm",md:"bear-py-2 bear-px-4 bear-text-base",lg:"bear-py-2.5 bear-px-5 bear-text-lg"},b="Bear-TreeSelect bear-relative bear-inline-block bear-w-full",t="bear-w-full bear-flex bear-items-center bear-justify-between bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-800 bear-text-gray-900 dark:bear-text-white bear-transition-colors focus:bear-ring-2 focus:bear-ring-pink-500 bear-outline-none",S="bear-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=280,r=20,a={sm:"bear-py-1.5 bear-px-3 bear-text-sm",md:"bear-py-2 bear-px-4 bear-text-base",lg:"bear-py-2.5 bear-px-5 bear-text-lg"},b="Bear-TreeSelect bear-relative bear-inline-block bear-w-full",t="bear-w-full bear-flex bear-items-center bear-justify-between bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-800 bear-text-gray-900 dark:bear-text-white bear-transition-colors focus:bear-ring-2 focus:bear-ring-pink-500 bear-outline-none",S="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-overflow-hidden",n="bear-w-full bear-px-3 bear-py-2 bear-text-sm bear-bg-transparent bear-border-b bear-border-gray-200 dark:bear-border-zinc-700 bear-outline-none bear-text-gray-900 dark:bear-text-white",E="bear-flex bear-items-center bear-py-1.5 bear-px-3 bear-cursor-pointer bear-transition-colors hover:bear-bg-gray-50 dark:hover:bear-bg-zinc-700 bear-text-sm bear-text-gray-700 dark:bear-text-zinc-300",o="bear-bg-pink-50 dark:bear-bg-pink-900/20 bear-text-pink-700 dark:bear-text-pink-300",i="bear-opacity-40 bear-cursor-not-allowed",s="bear-w-4 bear-h-4 bear-mr-1 bear-text-gray-400 dark:bear-text-zinc-500 bear-transition-transform bear-cursor-pointer",c="bear-inline-flex bear-items-center bear-gap-1 bear-bg-pink-100 dark:bear-bg-pink-900/30 bear-text-pink-700 dark:bear-text-pink-300 bear-rounded bear-px-1.5 bear-py-0.5 bear-text-xs",d="Bear-TreeSelect__label bear-block bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-zinc-300 bear-mb-1.5",x="bear-mt-1 bear-text-xs bear-text-red-500",A="bear-mt-1 bear-text-xs bear-text-gray-500 dark:bear-text-zinc-500";exports.CHEVRON_CLASSES=s;exports.DEFAULT_MAX_HEIGHT=e;exports.DROPDOWN_CLASSES=S;exports.ERROR_CLASSES=x;exports.HELPER_CLASSES=A;exports.INDENT_PX=r;exports.LABEL_CLASSES=d;exports.NODE_CLASSES=E;exports.NODE_DISABLED_CLASSES=i;exports.NODE_SELECTED_CLASSES=o;exports.ROOT_CLASSES=b;exports.SEARCH_CLASSES=n;exports.SIZE_CLASSES=a;exports.TAG_CLASSES=c;exports.TRIGGER_CLASSES=t;
|
|
@@ -7,7 +7,7 @@ export declare const SIZE_CLASSES: {
|
|
|
7
7
|
};
|
|
8
8
|
export declare const ROOT_CLASSES = "Bear-TreeSelect bear-relative bear-inline-block bear-w-full";
|
|
9
9
|
export declare const TRIGGER_CLASSES = "bear-w-full bear-flex bear-items-center bear-justify-between bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-800 bear-text-gray-900 dark:bear-text-white bear-transition-colors focus:bear-ring-2 focus:bear-ring-pink-500 bear-outline-none";
|
|
10
|
-
export declare const DROPDOWN_CLASSES = "bear-
|
|
10
|
+
export declare const DROPDOWN_CLASSES = "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-overflow-hidden";
|
|
11
11
|
export declare const SEARCH_CLASSES = "bear-w-full bear-px-3 bear-py-2 bear-text-sm bear-bg-transparent bear-border-b bear-border-gray-200 dark:bear-border-zinc-700 bear-outline-none bear-text-gray-900 dark:bear-text-white";
|
|
12
12
|
export declare const NODE_CLASSES = "bear-flex bear-items-center bear-py-1.5 bear-px-3 bear-cursor-pointer bear-transition-colors hover:bear-bg-gray-50 dark:hover:bear-bg-zinc-700 bear-text-sm bear-text-gray-700 dark:bear-text-zinc-300";
|
|
13
13
|
export declare const NODE_SELECTED_CLASSES = "bear-bg-pink-50 dark:bear-bg-pink-900/20 bear-text-pink-700 dark:bear-text-pink-300";
|
|
@@ -2,13 +2,13 @@ const e = 280, r = 20, a = {
|
|
|
2
2
|
sm: "bear-py-1.5 bear-px-3 bear-text-sm",
|
|
3
3
|
md: "bear-py-2 bear-px-4 bear-text-base",
|
|
4
4
|
lg: "bear-py-2.5 bear-px-5 bear-text-lg"
|
|
5
|
-
}, b = "Bear-TreeSelect bear-relative bear-inline-block bear-w-full", t = "bear-w-full bear-flex bear-items-center bear-justify-between bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-800 bear-text-gray-900 dark:bear-text-white bear-transition-colors focus:bear-ring-2 focus:bear-ring-pink-500 bear-outline-none", n = "bear-
|
|
5
|
+
}, b = "Bear-TreeSelect bear-relative bear-inline-block bear-w-full", t = "bear-w-full bear-flex bear-items-center bear-justify-between bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-800 bear-text-gray-900 dark:bear-text-white bear-transition-colors focus:bear-ring-2 focus:bear-ring-pink-500 bear-outline-none", n = "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-overflow-hidden", o = "bear-w-full bear-px-3 bear-py-2 bear-text-sm bear-bg-transparent bear-border-b bear-border-gray-200 dark:bear-border-zinc-700 bear-outline-none bear-text-gray-900 dark:bear-text-white", i = "bear-flex bear-items-center bear-py-1.5 bear-px-3 bear-cursor-pointer bear-transition-colors hover:bear-bg-gray-50 dark:hover:bear-bg-zinc-700 bear-text-sm bear-text-gray-700 dark:bear-text-zinc-300", S = "bear-bg-pink-50 dark:bear-bg-pink-900/20 bear-text-pink-700 dark:bear-text-pink-300", s = "bear-opacity-40 bear-cursor-not-allowed", x = "bear-w-4 bear-h-4 bear-mr-1 bear-text-gray-400 dark:bear-text-zinc-500 bear-transition-transform bear-cursor-pointer", c = "bear-inline-flex bear-items-center bear-gap-1 bear-bg-pink-100 dark:bear-bg-pink-900/30 bear-text-pink-700 dark:bear-text-pink-300 bear-rounded bear-px-1.5 bear-py-0.5 bear-text-xs", d = "Bear-TreeSelect__label bear-block bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-zinc-300 bear-mb-1.5", E = "bear-mt-1 bear-text-xs bear-text-red-500", l = "bear-mt-1 bear-text-xs bear-text-gray-500 dark:bear-text-zinc-500";
|
|
6
6
|
export {
|
|
7
7
|
x as CHEVRON_CLASSES,
|
|
8
8
|
e as DEFAULT_MAX_HEIGHT,
|
|
9
9
|
n as DROPDOWN_CLASSES,
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
E as ERROR_CLASSES,
|
|
11
|
+
l as HELPER_CLASSES,
|
|
12
12
|
r as INDENT_PX,
|
|
13
13
|
d as LABEL_CLASSES,
|
|
14
14
|
i as NODE_CLASSES,
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { cn as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { jsxs as p, jsx as r, Fragment as Q } from "react/jsx-runtime";
|
|
2
|
+
import { useState as N, useRef as C, useMemo as D, useEffect as P, useCallback as y } from "react";
|
|
3
|
+
import { cn as m } from "../../utils/cn.js";
|
|
4
|
+
import { Portal as Y } from "../Portal/Portal.js";
|
|
5
|
+
import { DEFAULT_MAX_HEIGHT as $, LABEL_CLASSES as ee, SIZE_CLASSES as re, TRIGGER_CLASSES as te, SEARCH_CLASSES as ae, DROPDOWN_CLASSES as se, ERROR_CLASSES as ne, HELPER_CLASSES as le, ROOT_CLASSES as ie, TAG_CLASSES as oe, CHEVRON_CLASSES as ce, INDENT_PX as de, NODE_DISABLED_CLASSES as be, NODE_SELECTED_CLASSES as me, NODE_CLASSES as ue } from "./TreeSelect.const.js";
|
|
6
|
+
import { collectAllIds as he, filterNodes as pe, findNodeById as z } from "./TreeSelect.utils.js";
|
|
7
|
+
const Se = 1e4, M = ({ node: a, depth: l, selected: o, expanded: s, multiple: i, onToggleExpand: S, onSelect: f }) => {
|
|
8
|
+
const c = a.children && a.children.length > 0, E = s.has(a.id), u = o.has(a.id);
|
|
9
|
+
return /* @__PURE__ */ p(Q, { children: [
|
|
10
|
+
/* @__PURE__ */ p(
|
|
10
11
|
"div",
|
|
11
12
|
{
|
|
12
|
-
className:
|
|
13
|
-
style: { paddingLeft: l *
|
|
14
|
-
onClick: () => !a.disabled &&
|
|
13
|
+
className: m(ue, u && me, a.disabled && be),
|
|
14
|
+
style: { paddingLeft: l * de + 12 },
|
|
15
|
+
onClick: () => !a.disabled && f(a.id),
|
|
15
16
|
role: "treeitem",
|
|
16
|
-
"aria-selected":
|
|
17
|
-
"aria-expanded":
|
|
17
|
+
"aria-selected": u,
|
|
18
|
+
"aria-expanded": c ? E : void 0,
|
|
18
19
|
children: [
|
|
19
|
-
|
|
20
|
+
c ? /* @__PURE__ */ r(
|
|
20
21
|
"svg",
|
|
21
22
|
{
|
|
22
|
-
className:
|
|
23
|
-
onClick: (
|
|
24
|
-
|
|
23
|
+
className: m(ce, E && "bear-rotate-90"),
|
|
24
|
+
onClick: (h) => {
|
|
25
|
+
h.stopPropagation(), S(a.id);
|
|
25
26
|
},
|
|
26
27
|
fill: "none",
|
|
27
28
|
viewBox: "0 0 24 24",
|
|
@@ -29,100 +30,131 @@ const R = ({ node: a, depth: l, selected: c, expanded: t, multiple: n, onToggleE
|
|
|
29
30
|
children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" })
|
|
30
31
|
}
|
|
31
32
|
) : /* @__PURE__ */ r("span", { className: "bear-w-4 bear-mr-1" }),
|
|
32
|
-
|
|
33
|
+
i && /* @__PURE__ */ r("span", { className: m("bear-w-4 bear-h-4 bear-mr-2 bear-border bear-rounded bear-flex bear-items-center bear-justify-center bear-text-xs", u ? "bear-bg-pink-500 bear-border-pink-500 bear-text-white" : "bear-border-gray-300 dark:bear-border-zinc-600"), children: u && "✓" }),
|
|
33
34
|
a.icon && /* @__PURE__ */ r("span", { className: "bear-mr-1.5", children: a.icon }),
|
|
34
35
|
/* @__PURE__ */ r("span", { className: "bear-truncate", children: a.label })
|
|
35
36
|
]
|
|
36
37
|
}
|
|
37
38
|
),
|
|
38
|
-
|
|
39
|
+
c && E && a.children.map((h) => /* @__PURE__ */ r(M, { node: h, depth: l + 1, selected: o, expanded: s, multiple: i, onToggleExpand: S, onSelect: f }, h.id))
|
|
39
40
|
] });
|
|
40
|
-
},
|
|
41
|
+
}, Ae = (a) => {
|
|
41
42
|
const {
|
|
42
43
|
nodes: l,
|
|
43
|
-
value:
|
|
44
|
-
onChange:
|
|
45
|
-
multiple:
|
|
46
|
-
label:
|
|
47
|
-
placeholder:
|
|
48
|
-
disabled:
|
|
49
|
-
clearable:
|
|
50
|
-
searchable:
|
|
51
|
-
expandAll:
|
|
52
|
-
size:
|
|
53
|
-
error:
|
|
54
|
-
helperText:
|
|
55
|
-
maxHeight:
|
|
56
|
-
className:
|
|
57
|
-
testId:
|
|
58
|
-
...
|
|
59
|
-
} = a, [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
44
|
+
value: o,
|
|
45
|
+
onChange: s,
|
|
46
|
+
multiple: i = !1,
|
|
47
|
+
label: S,
|
|
48
|
+
placeholder: f = "Select…",
|
|
49
|
+
disabled: c = !1,
|
|
50
|
+
clearable: E = !0,
|
|
51
|
+
searchable: u = !0,
|
|
52
|
+
expandAll: h = !1,
|
|
53
|
+
size: B = "md",
|
|
54
|
+
error: w,
|
|
55
|
+
helperText: _,
|
|
56
|
+
maxHeight: H = $,
|
|
57
|
+
className: j,
|
|
58
|
+
testId: G,
|
|
59
|
+
...W
|
|
60
|
+
} = a, [d, x] = N(!1), [L, A] = N(""), g = C(null), k = C(null), R = C(null), [v, F] = N({ top: 0, left: 0, width: 0 }), V = D(() => he(l), [l]), [X, Z] = N(() => h ? V : /* @__PURE__ */ new Set()), b = D(() => o ? new Set(Array.isArray(o) ? o : [o]) : /* @__PURE__ */ new Set(), [o]);
|
|
61
|
+
P(() => {
|
|
62
|
+
if (!d) return;
|
|
63
|
+
const e = () => {
|
|
64
|
+
var n;
|
|
65
|
+
const t = (n = k.current) == null ? void 0 : n.getBoundingClientRect();
|
|
66
|
+
t && F({
|
|
67
|
+
top: t.bottom + 4,
|
|
68
|
+
left: Math.max(8, Math.min(t.left, window.innerWidth - t.width - 8)),
|
|
69
|
+
width: t.width
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
return e(), window.addEventListener("resize", e), window.addEventListener("scroll", e, !0), () => {
|
|
73
|
+
window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
|
|
74
|
+
};
|
|
75
|
+
}, [d]), P(() => {
|
|
76
|
+
if (!d) return;
|
|
77
|
+
const e = (t) => {
|
|
78
|
+
var I, O;
|
|
79
|
+
const n = t.target;
|
|
80
|
+
(I = g.current) != null && I.contains(n) || (O = R.current) != null && O.contains(n) || (x(!1), A(""));
|
|
63
81
|
};
|
|
64
82
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
65
|
-
}, []);
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
return
|
|
83
|
+
}, [d]);
|
|
84
|
+
const U = y((e) => {
|
|
85
|
+
Z((t) => {
|
|
86
|
+
const n = new Set(t);
|
|
87
|
+
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
70
88
|
});
|
|
71
|
-
}, []),
|
|
72
|
-
if (
|
|
73
|
-
const
|
|
74
|
-
|
|
89
|
+
}, []), q = y((e) => {
|
|
90
|
+
if (i) {
|
|
91
|
+
const t = new Set(b);
|
|
92
|
+
t.has(e) ? t.delete(e) : t.add(e), s == null || s(Array.from(t));
|
|
75
93
|
} else
|
|
76
|
-
|
|
77
|
-
}, [
|
|
78
|
-
|
|
79
|
-
}, [
|
|
80
|
-
if (
|
|
81
|
-
if (
|
|
82
|
-
return /* @__PURE__ */ r("div", { className: "bear-flex bear-flex-wrap bear-gap-1", children: Array.from(
|
|
83
|
-
const
|
|
84
|
-
return
|
|
94
|
+
s == null || s(e), x(!1), A("");
|
|
95
|
+
}, [i, b, s]), J = y(() => {
|
|
96
|
+
s == null || s(i ? [] : "");
|
|
97
|
+
}, [i, s]), T = L ? pe(l, L) : l, K = () => {
|
|
98
|
+
if (b.size === 0) return /* @__PURE__ */ r("span", { className: "bear-text-gray-400 dark:bear-text-zinc-500", children: f });
|
|
99
|
+
if (i)
|
|
100
|
+
return /* @__PURE__ */ r("div", { className: "bear-flex bear-flex-wrap bear-gap-1", children: Array.from(b).map((t) => {
|
|
101
|
+
const n = z(l, t);
|
|
102
|
+
return n ? /* @__PURE__ */ r("span", { className: oe, children: n.label }, t) : null;
|
|
85
103
|
}) });
|
|
86
|
-
const e =
|
|
87
|
-
return (e == null ? void 0 : e.label) ??
|
|
104
|
+
const e = z(l, Array.from(b)[0]);
|
|
105
|
+
return (e == null ? void 0 : e.label) ?? f;
|
|
88
106
|
};
|
|
89
|
-
return /* @__PURE__ */
|
|
90
|
-
|
|
91
|
-
/* @__PURE__ */
|
|
107
|
+
return /* @__PURE__ */ p("div", { ref: g, className: m(ie, j), "data-testid": G, ...W, children: [
|
|
108
|
+
S && /* @__PURE__ */ r("label", { className: ee, children: S }),
|
|
109
|
+
/* @__PURE__ */ p(
|
|
92
110
|
"button",
|
|
93
111
|
{
|
|
112
|
+
ref: k,
|
|
94
113
|
type: "button",
|
|
95
|
-
disabled:
|
|
96
|
-
onClick: () => !
|
|
97
|
-
className:
|
|
114
|
+
disabled: c,
|
|
115
|
+
onClick: () => !c && x(!d),
|
|
116
|
+
className: m(te, re[B], c && "bear-opacity-50 bear-cursor-not-allowed"),
|
|
98
117
|
children: [
|
|
99
|
-
/* @__PURE__ */ r("span", { className: "bear-flex-1 bear-text-left bear-truncate", children:
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
-
|
|
102
|
-
e.stopPropagation(),
|
|
118
|
+
/* @__PURE__ */ r("span", { className: "bear-flex-1 bear-text-left bear-truncate", children: K() }),
|
|
119
|
+
/* @__PURE__ */ p("div", { className: "bear-flex bear-items-center bear-gap-1", children: [
|
|
120
|
+
E && b.size > 0 && /* @__PURE__ */ r("span", { className: "bear-text-gray-400 hover:bear-text-gray-600 bear-cursor-pointer", onClick: (e) => {
|
|
121
|
+
e.stopPropagation(), J();
|
|
103
122
|
}, children: "✕" }),
|
|
104
|
-
/* @__PURE__ */ r("svg", { className:
|
|
123
|
+
/* @__PURE__ */ r("svg", { className: m("bear-w-4 bear-h-4 bear-text-gray-400 bear-transition-transform", d && "bear-rotate-180"), fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ r("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }) })
|
|
105
124
|
] })
|
|
106
125
|
]
|
|
107
126
|
}
|
|
108
127
|
),
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
128
|
+
d && /* @__PURE__ */ r(Y, { children: /* @__PURE__ */ p(
|
|
129
|
+
"div",
|
|
130
|
+
{
|
|
131
|
+
ref: R,
|
|
132
|
+
className: m(se, "bear-fixed"),
|
|
133
|
+
style: {
|
|
134
|
+
top: v.top,
|
|
135
|
+
left: v.left,
|
|
136
|
+
width: v.width,
|
|
137
|
+
zIndex: Se
|
|
138
|
+
},
|
|
139
|
+
children: [
|
|
140
|
+
u && /* @__PURE__ */ r(
|
|
141
|
+
"input",
|
|
142
|
+
{
|
|
143
|
+
className: ae,
|
|
144
|
+
placeholder: "Search…",
|
|
145
|
+
value: L,
|
|
146
|
+
onChange: (e) => A(e.target.value),
|
|
147
|
+
autoFocus: !0
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
/* @__PURE__ */ r("div", { style: { maxHeight: H }, className: "bear-overflow-y-auto", role: "tree", children: T.length > 0 ? T.map((e) => /* @__PURE__ */ r(M, { node: e, depth: 0, selected: b, expanded: X, multiple: i, onToggleExpand: U, onSelect: q }, e.id)) : /* @__PURE__ */ r("div", { className: "bear-py-6 bear-text-center bear-text-sm bear-text-gray-400", children: "No results" }) })
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
) }),
|
|
154
|
+
w && /* @__PURE__ */ r("p", { className: ne, children: w }),
|
|
155
|
+
!w && _ && /* @__PURE__ */ r("p", { className: le, children: _ })
|
|
124
156
|
] });
|
|
125
157
|
};
|
|
126
158
|
export {
|
|
127
|
-
|
|
159
|
+
Ae as TreeSelect
|
|
128
160
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),t=({children:e})=>i.jsx("span",{className:"Bear-VisuallyHidden",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:0},children:e});exports.VisuallyHidden=t;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
const d = ({ children: i }) => /* @__PURE__ */ e(
|
|
3
|
+
"span",
|
|
4
|
+
{
|
|
5
|
+
className: "Bear-VisuallyHidden",
|
|
6
|
+
style: {
|
|
7
|
+
position: "absolute",
|
|
8
|
+
width: 1,
|
|
9
|
+
height: 1,
|
|
10
|
+
padding: 0,
|
|
11
|
+
margin: -1,
|
|
12
|
+
overflow: "hidden",
|
|
13
|
+
clip: "rect(0, 0, 0, 0)",
|
|
14
|
+
whiteSpace: "nowrap",
|
|
15
|
+
borderWidth: 0
|
|
16
|
+
},
|
|
17
|
+
children: i
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
export {
|
|
21
|
+
d as VisuallyHidden
|
|
22
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("react/jsx-runtime"),s=require("react"),z=require("../../context/BearProvider.cjs"),C=require("../../utils/cn.cjs"),t=require("./Watermark.const.cjs"),Y=w=>{const{children:S,text:c,image:d,fontSize:E=t.DEFAULT_FONT_SIZE,color:T,rotate:g=t.DEFAULT_ROTATE,opacity:_=t.DEFAULT_OPACITY,patternRepeat:v=t.PATTERN_REPEAT_MIN,gap:F=t.DEFAULT_GAP,offset:D=t.DEFAULT_OFFSET,zIndex:U=t.DEFAULT_Z_INDEX,fontFamily:L,fontWeight:k=t.DEFAULT_FONT_WEIGHT,visible:b=!0,className:W,style:G,testId:q}=w,i=s.useRef(null),R=s.useRef(null),m=s.useContext(z.BearContext),[$,B]=s.useState(!1);s.useEffect(()=>{if(m)return;const r=window.matchMedia("(prefers-color-scheme: dark)"),e=()=>{const o=document.documentElement,h=o.classList.contains("dark")||o.classList.contains("bear-dark")||r.matches;B(h)};e();const n=new MutationObserver(e);return n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),r.addEventListener("change",e),()=>{n.disconnect(),r.removeEventListener("change",e)}},[m]);const I=m?m.mode==="dark":$,p=s.useMemo(()=>{if(L)return L;if(typeof window<"u"){const r=document.documentElement,e=getComputedStyle(r).getPropertyValue("--bear-font-sans");if(e.trim())return e.trim();const n=getComputedStyle(r).getPropertyValue("--bear-font-family");if(n.trim())return n.trim()}return t.DEFAULT_FONT_FAMILY},[L]),y=s.useMemo(()=>T||(I?t.DEFAULT_COLOR_DARK:t.DEFAULT_COLOR_LIGHT),[T,I]),x=s.useCallback(()=>{if(!b||!c&&!d)return"";const r=document.createElement("canvas"),e=r.getContext("2d");if(!e)return"";const n=Array.isArray(c)?c:c?[c]:[],o=E*t.LINE_HEIGHT_MULTIPLIER,h=n.length*o,A=F[0]+t.CANVAS_WIDTH_OFFSET,f=F[1]+h+t.CANVAS_EXTRA_PADDING;r.width=A,r.height=f;const l=Math.min(t.PATTERN_REPEAT_MAX,Math.max(t.PATTERN_REPEAT_MIN,Math.floor(v))),O=A/l,N=f/l,M=(a,u)=>{e.save(),e.translate(a,u),e.rotate(g*t.DEG_TO_RAD),e.font=`${k} ${E}px ${p}`,e.fillStyle=y,e.globalAlpha=_,e.textAlign="center",e.textBaseline="middle",n.forEach((j,V)=>{const X=(V-(n.length-1)/t.HALF)*o;e.fillText(j,0,X)}),e.restore()};if(d){e.save(),e.translate(A/t.HALF,f/t.HALF),e.rotate(g*t.DEG_TO_RAD);const a=new Image;a.crossOrigin="anonymous",a.src=d,e.globalAlpha=_,e.drawImage(a,-a.width/t.HALF,-a.height/t.HALF),e.restore()}else if(l<=1)M(A/t.HALF,f/t.HALF);else for(let a=0;a<l;a++)for(let u=0;u<l;u++)M(u*O+O/t.HALF,a*N+N/t.HALF);return r.toDataURL()},[c,d,E,y,g,_,F,p,k,b,v]),H=s.useMemo(()=>x(),[x]);return s.useEffect(()=>{const r=R.current;if(!r)return;const e=new MutationObserver(()=>{var n,o;(n=i.current)!=null&&n.contains(r)||(o=i.current)==null||o.appendChild(r)});return i.current&&e.observe(i.current,{childList:!0}),()=>e.disconnect()},[]),P.jsxs("div",{ref:i,className:C.cn("Bear-Watermark","bear-relative",W),style:G,"data-testid":q,children:[S,b&&H&&P.jsx("div",{ref:R,className:C.cn("Bear-Watermark__overlay","bear-absolute bear-inset-0 bear-pointer-events-none bear-bg-repeat"),style:{backgroundImage:`url(${H})`,backgroundPosition:`${D[0]}px ${D[1]}px`,zIndex:U},"aria-hidden":"true"})]})};exports.Watermark=Y;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=16,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=16,A=-22,_=.22,E=[100,100],F=[0,0],L=9,D=400,I="rgba(0, 0, 0, 0.28)",s="rgba(255, 255, 255, 0.22)",t="system-ui, -apple-system, sans-serif",O=1.5,N=40,R=200,U=2,o=Math.PI/180,n=1,c=4;exports.CANVAS_EXTRA_PADDING=N;exports.CANVAS_WIDTH_OFFSET=R;exports.DEFAULT_COLOR_DARK=s;exports.DEFAULT_COLOR_LIGHT=I;exports.DEFAULT_FONT_FAMILY=t;exports.DEFAULT_FONT_SIZE=T;exports.DEFAULT_FONT_WEIGHT=D;exports.DEFAULT_GAP=E;exports.DEFAULT_OFFSET=F;exports.DEFAULT_OPACITY=_;exports.DEFAULT_ROTATE=A;exports.DEFAULT_Z_INDEX=L;exports.DEG_TO_RAD=o;exports.HALF=U;exports.LINE_HEIGHT_MULTIPLIER=O;exports.PATTERN_REPEAT_MAX=c;exports.PATTERN_REPEAT_MIN=n;
|
|
@@ -3,7 +3,7 @@ export declare const DEFAULT_FONT_SIZE = 16;
|
|
|
3
3
|
/** Default rotation in degrees */
|
|
4
4
|
export declare const DEFAULT_ROTATE = -22;
|
|
5
5
|
/** Default opacity */
|
|
6
|
-
export declare const DEFAULT_OPACITY = 0.
|
|
6
|
+
export declare const DEFAULT_OPACITY = 0.22;
|
|
7
7
|
/** Default gap [horizontal, vertical] in pixels */
|
|
8
8
|
export declare const DEFAULT_GAP: [number, number];
|
|
9
9
|
/** Default offset [x, y] in pixels */
|
|
@@ -13,9 +13,9 @@ export declare const DEFAULT_Z_INDEX = 9;
|
|
|
13
13
|
/** Default font weight */
|
|
14
14
|
export declare const DEFAULT_FONT_WEIGHT = 400;
|
|
15
15
|
/** Default light mode color */
|
|
16
|
-
export declare const DEFAULT_COLOR_LIGHT = "rgba(0, 0, 0, 0.
|
|
16
|
+
export declare const DEFAULT_COLOR_LIGHT = "rgba(0, 0, 0, 0.28)";
|
|
17
17
|
/** Default dark mode color */
|
|
18
|
-
export declare const DEFAULT_COLOR_DARK = "rgba(255, 255, 255, 0.
|
|
18
|
+
export declare const DEFAULT_COLOR_DARK = "rgba(255, 255, 255, 0.22)";
|
|
19
19
|
/** Default font family */
|
|
20
20
|
export declare const DEFAULT_FONT_FAMILY = "system-ui, -apple-system, sans-serif";
|
|
21
21
|
/** Line height multiplier */
|
|
@@ -28,3 +28,6 @@ export declare const CANVAS_WIDTH_OFFSET = 200;
|
|
|
28
28
|
export declare const HALF = 2;
|
|
29
29
|
/** Degrees to radians conversion */
|
|
30
30
|
export declare const DEG_TO_RAD: number;
|
|
31
|
+
/** Min / max pattern repeat per axis */
|
|
32
|
+
export declare const PATTERN_REPEAT_MIN = 1;
|
|
33
|
+
export declare const PATTERN_REPEAT_MAX = 4;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
const T = 16,
|
|
1
|
+
const T = 16, A = -22, _ = 0.22, E = [100, 100], s = [0, 0], t = 9, F = 400, n = "rgba(0, 0, 0, 0.28)", o = "rgba(255, 255, 255, 0.22)", L = "system-ui, -apple-system, sans-serif", c = 1.5, D = 40, I = 200, O = 2, N = Math.PI / 180, R = 1, U = 4;
|
|
2
2
|
export {
|
|
3
|
-
|
|
3
|
+
D as CANVAS_EXTRA_PADDING,
|
|
4
4
|
I as CANVAS_WIDTH_OFFSET,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
o as DEFAULT_COLOR_DARK,
|
|
6
|
+
n as DEFAULT_COLOR_LIGHT,
|
|
7
|
+
L as DEFAULT_FONT_FAMILY,
|
|
8
8
|
T as DEFAULT_FONT_SIZE,
|
|
9
9
|
F as DEFAULT_FONT_WEIGHT,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
E as DEFAULT_GAP,
|
|
11
|
+
s as DEFAULT_OFFSET,
|
|
12
|
+
_ as DEFAULT_OPACITY,
|
|
13
|
+
A as DEFAULT_ROTATE,
|
|
14
14
|
t as DEFAULT_Z_INDEX,
|
|
15
|
-
|
|
15
|
+
N as DEG_TO_RAD,
|
|
16
16
|
O as HALF,
|
|
17
|
-
|
|
17
|
+
c as LINE_HEIGHT_MULTIPLIER,
|
|
18
|
+
U as PATTERN_REPEAT_MAX,
|
|
19
|
+
R as PATTERN_REPEAT_MIN
|
|
18
20
|
};
|