@forgedevstack/bear 1.2.0 → 1.2.2
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/dist/components/AnimatedCounter/AnimatedCounter.cjs +1 -0
- package/dist/components/AnimatedCounter/AnimatedCounter.const.cjs +1 -0
- package/dist/components/AnimatedCounter/AnimatedCounter.const.d.ts +5 -0
- package/dist/components/AnimatedCounter/AnimatedCounter.const.js +7 -0
- package/dist/components/AnimatedCounter/AnimatedCounter.d.ts +3 -0
- package/dist/components/AnimatedCounter/AnimatedCounter.js +59 -0
- package/dist/components/AnimatedCounter/AnimatedCounter.types.d.ts +26 -0
- package/dist/components/AnimatedCounter/AnimatedCounter.utils.cjs +1 -0
- package/dist/components/AnimatedCounter/AnimatedCounter.utils.d.ts +6 -0
- package/dist/components/AnimatedCounter/AnimatedCounter.utils.js +13 -0
- package/dist/components/AnimatedCounter/index.d.ts +2 -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/CurrencyInput/CurrencyInput.cjs +1 -0
- package/dist/components/CurrencyInput/CurrencyInput.const.cjs +1 -0
- package/dist/components/CurrencyInput/CurrencyInput.const.d.ts +4 -0
- package/dist/components/CurrencyInput/CurrencyInput.const.js +19 -0
- package/dist/components/CurrencyInput/CurrencyInput.d.ts +3 -0
- package/dist/components/CurrencyInput/CurrencyInput.js +60 -0
- package/dist/components/CurrencyInput/CurrencyInput.types.d.ts +22 -0
- package/dist/components/CurrencyInput/CurrencyInput.utils.cjs +1 -0
- package/dist/components/CurrencyInput/CurrencyInput.utils.d.ts +2 -0
- package/dist/components/CurrencyInput/CurrencyInput.utils.js +14 -0
- package/dist/components/CurrencyInput/index.d.ts +2 -0
- 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/DiffViewer/DiffViewer.cjs +1 -1
- package/dist/components/DiffViewer/DiffViewer.const.cjs +1 -1
- package/dist/components/DiffViewer/DiffViewer.const.d.ts +6 -0
- package/dist/components/DiffViewer/DiffViewer.const.js +17 -4
- package/dist/components/DiffViewer/DiffViewer.d.ts +0 -14
- package/dist/components/DiffViewer/DiffViewer.js +97 -105
- package/dist/components/DiffViewer/DiffViewer.types.d.ts +5 -0
- package/dist/components/DiffViewer/index.d.ts +1 -1
- 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/GlowCard/GlowCard.cjs +1 -0
- package/dist/components/GlowCard/GlowCard.const.cjs +1 -0
- package/dist/components/GlowCard/GlowCard.const.d.ts +11 -0
- package/dist/components/GlowCard/GlowCard.const.js +13 -0
- package/dist/components/GlowCard/GlowCard.d.ts +3 -0
- package/dist/components/GlowCard/GlowCard.js +185 -0
- package/dist/components/GlowCard/GlowCard.types.d.ts +21 -0
- package/dist/components/GlowCard/index.d.ts +2 -0
- package/dist/components/Heatmap/Heatmap.cjs +1 -0
- package/dist/components/Heatmap/Heatmap.const.cjs +1 -0
- package/dist/components/Heatmap/Heatmap.const.d.ts +8 -0
- package/dist/components/Heatmap/Heatmap.const.js +11 -0
- package/dist/components/Heatmap/Heatmap.d.ts +3 -0
- package/dist/components/Heatmap/Heatmap.js +103 -0
- package/dist/components/Heatmap/Heatmap.types.d.ts +34 -0
- package/dist/components/Heatmap/Heatmap.utils.cjs +1 -0
- package/dist/components/Heatmap/Heatmap.utils.d.ts +2 -0
- package/dist/components/Heatmap/Heatmap.utils.js +18 -0
- package/dist/components/Heatmap/index.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/ImageAnnotation/ImageAnnotation.cjs +1 -0
- package/dist/components/ImageAnnotation/ImageAnnotation.const.cjs +1 -0
- package/dist/components/ImageAnnotation/ImageAnnotation.const.d.ts +3 -0
- package/dist/components/ImageAnnotation/ImageAnnotation.const.js +6 -0
- package/dist/components/ImageAnnotation/ImageAnnotation.d.ts +3 -0
- package/dist/components/ImageAnnotation/ImageAnnotation.js +113 -0
- package/dist/components/ImageAnnotation/ImageAnnotation.types.d.ts +28 -0
- package/dist/components/ImageAnnotation/index.d.ts +2 -0
- package/dist/components/MediaPlayer/MediaPlayer.cjs +1 -0
- package/dist/components/MediaPlayer/MediaPlayer.const.cjs +1 -0
- package/dist/components/MediaPlayer/MediaPlayer.const.d.ts +36 -0
- package/dist/components/MediaPlayer/MediaPlayer.const.js +11 -0
- package/dist/components/MediaPlayer/MediaPlayer.d.ts +3 -0
- package/dist/components/MediaPlayer/MediaPlayer.js +279 -0
- package/dist/components/MediaPlayer/MediaPlayer.types.d.ts +69 -0
- package/dist/components/MediaPlayer/MediaPlayer.utils.cjs +1 -0
- package/dist/components/MediaPlayer/MediaPlayer.utils.d.ts +1 -0
- package/dist/components/MediaPlayer/MediaPlayer.utils.js +7 -0
- package/dist/components/MediaPlayer/index.d.ts +2 -0
- 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 +26 -4
- package/dist/components/Stepper/Stepper.const.js +39 -20
- package/dist/components/Stepper/Stepper.d.ts +3 -10
- package/dist/components/Stepper/Stepper.js +189 -130
- package/dist/components/Stepper/Stepper.types.d.ts +14 -0
- package/dist/components/Stepper/Stepper.utils.cjs +1 -0
- package/dist/components/Stepper/Stepper.utils.d.ts +12 -0
- package/dist/components/Stepper/Stepper.utils.js +19 -0
- package/dist/components/Stepper/components/StepperControls.cjs +1 -0
- package/dist/components/Stepper/components/StepperControls.d.ts +2 -0
- package/dist/components/Stepper/components/StepperControls.js +32 -0
- package/dist/components/Stepper/index.d.ts +2 -1
- 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/TagCloud/TagCloud.cjs +1 -0
- package/dist/components/TagCloud/TagCloud.const.cjs +1 -0
- package/dist/components/TagCloud/TagCloud.const.d.ts +5 -0
- package/dist/components/TagCloud/TagCloud.const.js +8 -0
- package/dist/components/TagCloud/TagCloud.d.ts +3 -0
- package/dist/components/TagCloud/TagCloud.js +76 -0
- package/dist/components/TagCloud/TagCloud.types.d.ts +26 -0
- package/dist/components/TagCloud/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/TimelineChart/TimelineChart.cjs +1 -0
- package/dist/components/TimelineChart/TimelineChart.const.cjs +1 -0
- package/dist/components/TimelineChart/TimelineChart.const.d.ts +6 -0
- package/dist/components/TimelineChart/TimelineChart.const.js +9 -0
- package/dist/components/TimelineChart/TimelineChart.d.ts +3 -0
- package/dist/components/TimelineChart/TimelineChart.js +65 -0
- package/dist/components/TimelineChart/TimelineChart.types.d.ts +31 -0
- package/dist/components/TimelineChart/index.d.ts +2 -0
- 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 +22 -4
- package/dist/components/index.js +319 -296
- 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 +412 -388
- package/dist/styles/_effects.css +32 -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
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { jsxs as h, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as R, useState as v, useCallback as u } from "react";
|
|
3
|
+
import { cn as T } from "../../utils/cn.js";
|
|
4
|
+
import { BearIcons as A } from "../Icon/index.js";
|
|
5
|
+
import { Popover as O } from "../Popover/Popover.js";
|
|
6
|
+
import { Input as j } from "../Input/Input.js";
|
|
7
|
+
import { DEFAULT_PIN_COLOR as D, DEFAULT_PIN_SIZE as F, PIN_ICON_RATIO as $ } from "./ImageAnnotation.const.js";
|
|
8
|
+
let z = 1;
|
|
9
|
+
function U(s, n, r, e) {
|
|
10
|
+
return /* @__PURE__ */ l("div", { className: "Bear-ImageAnnotation__edit min-w-[160px]", children: /* @__PURE__ */ l(
|
|
11
|
+
j,
|
|
12
|
+
{
|
|
13
|
+
autoFocus: !0,
|
|
14
|
+
size: "sm",
|
|
15
|
+
value: s,
|
|
16
|
+
onChange: (o) => n(o.target.value),
|
|
17
|
+
onKeyDown: (o) => {
|
|
18
|
+
o.key === "Enter" && r(), o.key === "Escape" && e();
|
|
19
|
+
},
|
|
20
|
+
placeholder: "Add note..."
|
|
21
|
+
}
|
|
22
|
+
) });
|
|
23
|
+
}
|
|
24
|
+
function X(s, n, r, e) {
|
|
25
|
+
return /* @__PURE__ */ h("div", { className: "Bear-ImageAnnotation__label text-xs text-gray-700 dark:text-gray-200 whitespace-nowrap flex items-center gap-1", children: [
|
|
26
|
+
e ?? s.text,
|
|
27
|
+
n && /* @__PURE__ */ l(
|
|
28
|
+
"button",
|
|
29
|
+
{
|
|
30
|
+
type: "button",
|
|
31
|
+
className: "text-red-400 hover:text-red-600 ml-1",
|
|
32
|
+
onClick: (o) => {
|
|
33
|
+
o.stopPropagation(), r(s.id);
|
|
34
|
+
},
|
|
35
|
+
children: /* @__PURE__ */ l(A.XIcon, { size: 12 })
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
] });
|
|
39
|
+
}
|
|
40
|
+
const J = ({
|
|
41
|
+
src: s,
|
|
42
|
+
alt: n = "",
|
|
43
|
+
annotations: r,
|
|
44
|
+
onChange: e,
|
|
45
|
+
editable: o = !0,
|
|
46
|
+
pinColor: k = D,
|
|
47
|
+
pinSize: f = F,
|
|
48
|
+
renderPopover: p,
|
|
49
|
+
testId: y,
|
|
50
|
+
className: N,
|
|
51
|
+
...w
|
|
52
|
+
}) => {
|
|
53
|
+
const x = R(null), [c, a] = v(null), [d, _] = v(""), E = u(
|
|
54
|
+
(t) => {
|
|
55
|
+
if (!o || !e || !x.current || t.target.closest(".Bear-ImageAnnotation__pin")) return;
|
|
56
|
+
const i = x.current.getBoundingClientRect(), I = (t.clientX - i.left) / i.width * 100, g = (t.clientY - i.top) / i.height * 100, m = `ann-${z++}`, P = { id: m, x: I, y: g, text: "" };
|
|
57
|
+
e([...r, P]), a(m), _("");
|
|
58
|
+
},
|
|
59
|
+
[o, e, r]
|
|
60
|
+
), B = u(() => {
|
|
61
|
+
!c || !e || (d.trim() ? e(r.map((t) => t.id === c ? { ...t, text: d } : t)) : e(r.filter((t) => t.id !== c)), a(null));
|
|
62
|
+
}, [c, d, e, r]), b = u(() => a(null), []), L = u(
|
|
63
|
+
(t) => {
|
|
64
|
+
e == null || e(r.filter((i) => i.id !== t)), c === t && a(null);
|
|
65
|
+
},
|
|
66
|
+
[e, r, c]
|
|
67
|
+
);
|
|
68
|
+
return /* @__PURE__ */ h(
|
|
69
|
+
"div",
|
|
70
|
+
{
|
|
71
|
+
ref: x,
|
|
72
|
+
className: T("Bear-ImageAnnotation relative inline-block select-none", o && "cursor-crosshair", N),
|
|
73
|
+
onClick: E,
|
|
74
|
+
"data-testid": y,
|
|
75
|
+
...w,
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ l("img", { src: s, alt: n, className: "w-full h-auto block rounded-lg", draggable: !1 }),
|
|
78
|
+
r.map((t) => {
|
|
79
|
+
const i = c === t.id, I = !!t.text, g = p == null ? void 0 : p(t), m = i ? U(d, _, B, b) : I ? X(t, o, L, g) : null;
|
|
80
|
+
return /* @__PURE__ */ l(
|
|
81
|
+
"div",
|
|
82
|
+
{
|
|
83
|
+
className: "Bear-ImageAnnotation__pin absolute transform -translate-x-1/2 -translate-y-full z-10",
|
|
84
|
+
style: { left: `${t.x}%`, top: `${t.y}%` },
|
|
85
|
+
children: /* @__PURE__ */ l(
|
|
86
|
+
O,
|
|
87
|
+
{
|
|
88
|
+
content: m,
|
|
89
|
+
trigger: i ? "click" : "hover",
|
|
90
|
+
placement: "top",
|
|
91
|
+
open: i || void 0,
|
|
92
|
+
arrow: !1,
|
|
93
|
+
children: /* @__PURE__ */ l(
|
|
94
|
+
"div",
|
|
95
|
+
{
|
|
96
|
+
className: "Bear-ImageAnnotation__marker flex items-center justify-center rounded-full shadow-lg cursor-pointer transition-transform hover:scale-110",
|
|
97
|
+
style: { width: f, height: f, backgroundColor: t.color ?? k },
|
|
98
|
+
children: /* @__PURE__ */ l(A.MapPinIcon, { size: f * $, className: "text-white" })
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
},
|
|
104
|
+
t.id
|
|
105
|
+
);
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
};
|
|
111
|
+
export {
|
|
112
|
+
J as ImageAnnotation
|
|
113
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface Annotation {
|
|
3
|
+
id: string;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
text: string;
|
|
7
|
+
color?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ImageAnnotationProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onChange'> {
|
|
10
|
+
/** Image source URL */
|
|
11
|
+
src: string;
|
|
12
|
+
/** Alt text */
|
|
13
|
+
alt?: string;
|
|
14
|
+
/** Current annotations */
|
|
15
|
+
annotations: Annotation[];
|
|
16
|
+
/** Called when annotations change (add/edit/delete) */
|
|
17
|
+
onChange?: (annotations: Annotation[]) => void;
|
|
18
|
+
/** Whether the user can add new annotations by clicking */
|
|
19
|
+
editable?: boolean;
|
|
20
|
+
/** Pin color */
|
|
21
|
+
pinColor?: string;
|
|
22
|
+
/** Pin size in px */
|
|
23
|
+
pinSize?: number;
|
|
24
|
+
/** Render custom popover content for each annotation */
|
|
25
|
+
renderPopover?: (annotation: Annotation) => ReactNode;
|
|
26
|
+
/** Test ID */
|
|
27
|
+
testId?: string;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),m=require("../../utils/cn.cjs"),r=require("../Icon/index.cjs"),j=require("./MediaPlayer.const.cjs"),C=require("./MediaPlayer.utils.cjs"),Te=require("../../hooks/useBearStyles.cjs"),Re=320,le=16,ze=({src:D,type:T="video",poster:R,autoPlay:z=!1,loop:L=!1,muted:G=!1,nativeControls:k=!1,width:A,height:H,size:ce="md",accentColor:u=j.DEFAULT_ACCENT,playIcon:Y,pauseIcon:Z,muteIcon:de,unmuteIcon:ue,fullscreenIcon:xe,centerOverlay:me=!1,sticky:q=!1,stickyPosition:$="right",stickySize:U=Re,airPlay:he=!1,playlist:w,onTrackChange:I,bis:fe,testId:ye,className:ge,style:ve,...pe})=>{const h=s.useRef(null),W=s.useRef(null),K=s.useRef(null),[b,F]=s.useState(z),[N,V]=s.useState(0),[g,X]=s.useState(0),[S,be]=s.useState(G),[f,J]=s.useState(L),[M,je]=s.useState(!1),[Q,ke]=s.useState(0),[Ne,_]=s.useState(!z),[l,we]=s.useState(0),O=Te.useBearStyles(fe,ve),x=s.useMemo(()=>w&&w.length>0?w:[{src:D,poster:R,type:T,title:void 0,artist:void 0}],[w,D,R,T]),o=x[l],Ie=o.src,B=o.poster??R,c=o.type??T,d=x.length>1,i=j.SIZE_MAP[ce];s.useEffect(()=>{J(L)},[L]),s.useEffect(()=>{const t=h.current;if(!t)return;const n=()=>V(t.currentTime),a=()=>X(t.duration),p=()=>{d&&l<x.length-1?v(l+1):f?d&&v(0):(F(!1),_(!0))};return t.addEventListener("timeupdate",n),t.addEventListener("loadedmetadata",a),t.addEventListener("ended",p),()=>{t.removeEventListener("timeupdate",n),t.removeEventListener("loadedmetadata",a),t.removeEventListener("ended",p)}},[f,d,l,x.length]),s.useEffect(()=>{if(!q||c!=="video")return;const t=K.current;if(!t)return;const n=()=>{const p=t.getBoundingClientRect().bottom<0;je(p),p&&ke(le)};return window.addEventListener("scroll",n,{passive:!0}),n(),()=>window.removeEventListener("scroll",n)},[q,c]);const v=s.useCallback(t=>{const n=Math.max(0,Math.min(x.length-1,t));we(n),V(0),X(0),_(!1),I==null||I(n,x[n]),setTimeout(()=>{const a=h.current;a&&(a.load(),a.play().catch(()=>{}),F(!0))},50)},[x,I]),E=s.useCallback(()=>{const t=h.current;t&&(b?(t.pause(),_(!0)):(t.play().catch(()=>{}),_(!1)),F(!b))},[b]),ee=s.useCallback(t=>{const n=h.current;if(!n||!g)return;const a=t.currentTarget.getBoundingClientRect(),p=Math.max(0,Math.min(1,(t.clientX-a.left)/a.width));n.currentTime=p*g},[g]),te=s.useCallback(()=>{const t=h.current;t&&(t.muted=!S,be(!S))},[S]),se=s.useCallback(()=>{const t=!f;J(t);const n=h.current;n&&(n.loop=t)},[f]),Se=s.useCallback(()=>{var n;const t=W.current;t&&(document.fullscreenElement?document.exitFullscreen():(n=t.requestFullscreen)==null||n.call(t))},[]),Me=s.useCallback(()=>{const t=h.current;t!=null&&t.webkitShowPlaybackTargetPicker&&t.webkitShowPlaybackTargetPicker()},[]),ne=s.useCallback(()=>{if(N>3){const t=h.current;t&&(t.currentTime=0)}else l>0&&v(l-1)},[N,l,v]),ae=s.useCallback(()=>{l<x.length-1&&v(l+1)},[l,x.length,v]),re=g?N/g*100:0,y=i.iconSm,P=i.iconMd,ie=b?Z??e.jsx(r.BearIcons.PauseIcon,{size:P}):Y??e.jsx(r.BearIcons.PlayIcon,{size:P}),oe=S?de??e.jsx(r.BearIcons.VolumeOffIcon,{size:y}):ue??e.jsx(r.BearIcons.VolumeUpIcon,{size:y}),_e=xe??e.jsx(r.BearIcons.MaximizeIcon,{size:y}),Be=c==="video"?"video":"audio",Ee=s.useMemo(()=>M&&c==="video"?{...O,position:"fixed",top:Q,[$==="left"?"left":"right"]:le,width:U,zIndex:50,boxShadow:"0 8px 32px rgba(0,0,0,0.45)",borderRadius:12,transition:"top 0.15s ease-out"}:{...O,width:A??"100%",height:H,maxWidth:A?void 0:i.maxWidth},[M,c,O,A,H,i.maxWidth,Q,$,U]),Pe=s.useMemo(()=>{if(!M)return{aspectRatio:i.aspectRatio}},[M,i.aspectRatio]),Ce=`${u}20`;return e.jsxs(e.Fragment,{children:[q&&e.jsx("div",{ref:K,style:{height:1}}),e.jsxs("div",{ref:W,className:m.cn("Bear-MediaPlayer relative rounded-xl overflow-hidden bg-black",ge),style:Ee,"data-testid":ye,...pe,children:[e.jsx(Be,{ref:h,src:Ie,poster:B,autoPlay:z,loop:f&&!d,muted:G,controls:k,playsInline:!0,className:m.cn(c==="video"?"Bear-MediaPlayer__video w-full object-cover":"hidden"),style:c==="video"?Pe:void 0,onClick:c==="video"?E:void 0}),me&&c==="video"&&Ne&&!k&&e.jsx("button",{type:"button",onClick:E,className:"Bear-MediaPlayer__overlay absolute inset-0 flex items-center justify-center bg-black/30 transition-opacity",children:e.jsx("div",{className:"w-16 h-16 rounded-full bg-white/90 flex items-center justify-center shadow-lg",children:b?Z??e.jsx(r.BearIcons.PauseIcon,{size:j.CENTER_ICON_SIZE,className:"text-gray-900"}):Y??e.jsx(r.BearIcons.PlayIcon,{size:j.CENTER_ICON_SIZE,className:"text-gray-900"})})}),!k&&c==="video"&&e.jsxs("div",{className:m.cn("Bear-MediaPlayer__controls absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/80 to-transparent pt-8",i.padding),children:[e.jsx("div",{className:"Bear-MediaPlayer__progress w-full cursor-pointer mb-2 group",style:{height:j.PROGRESS_HEIGHT},onClick:ee,children:e.jsx("div",{className:"w-full h-full bg-white/30 rounded-full relative overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${re}%`,backgroundColor:u}})})}),e.jsxs("div",{className:m.cn("Bear-MediaPlayer__bar flex items-center",i.gap),children:[d&&e.jsx("button",{type:"button",onClick:ne,className:"text-white hover:text-pink-400 transition-colors",children:e.jsx(r.BearIcons.SkipBackIcon,{size:y})}),e.jsx("button",{type:"button",onClick:E,className:"text-white hover:text-pink-400 transition-colors",children:ie}),d&&e.jsx("button",{type:"button",onClick:ae,className:"text-white hover:text-pink-400 transition-colors",children:e.jsx(r.BearIcons.SkipForwardIcon,{size:y})}),e.jsx("button",{type:"button",onClick:te,className:"text-white hover:text-pink-400 transition-colors",children:oe}),e.jsxs("span",{className:m.cn("Bear-MediaPlayer__time text-white font-mono",i.text),children:[C.formatTime(N)," / ",C.formatTime(g)]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{type:"button",onClick:se,className:"transition-colors",style:{color:f?u:void 0},title:"Loop",children:e.jsx(r.BearIcons.RepeatIcon,{size:y,className:f?void 0:"text-white/60 hover:text-white"})}),he&&e.jsx("button",{type:"button",onClick:Me,className:"text-white hover:text-pink-400 transition-colors",title:"AirPlay",children:e.jsx(r.BearIcons.CastIcon,{size:y})}),e.jsx("button",{type:"button",onClick:Se,className:"text-white hover:text-pink-400 transition-colors",children:_e})]}),d&&o.title&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 truncate",children:[e.jsx("span",{className:"text-white text-xs font-medium truncate",children:o.title}),o.artist&&e.jsxs("span",{className:"text-white/50 text-xs truncate",children:["— ",o.artist]})]})]}),c==="audio"&&!k&&e.jsxs("div",{className:m.cn("Bear-MediaPlayer__audio bg-gray-100 dark:bg-zinc-800 rounded-xl",i.padding),children:[d&&(B||o.title)&&e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[B&&e.jsx("img",{src:B,alt:"",className:"w-12 h-12 rounded-lg object-cover shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[o.title&&e.jsx("p",{className:"text-sm font-semibold text-gray-900 dark:text-white truncate",children:o.title}),o.artist&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.artist})]})]}),e.jsx("div",{className:"Bear-MediaPlayer__progress w-full cursor-pointer mb-1",style:{height:j.PROGRESS_HEIGHT},onClick:ee,children:e.jsx("div",{className:"w-full h-full bg-gray-300 dark:bg-zinc-600 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${re}%`,backgroundColor:u}})})}),e.jsxs("div",{className:"flex justify-between mb-2",children:[e.jsx("span",{className:m.cn("text-gray-500 font-mono",i.text),children:C.formatTime(N)}),e.jsx("span",{className:m.cn("text-gray-500 font-mono",i.text),children:C.formatTime(g)})]}),e.jsxs("div",{className:m.cn("flex items-center justify-center",i.gap),children:[e.jsx("button",{type:"button",onClick:se,className:"transition-colors",style:{color:f?u:void 0},title:"Loop",children:e.jsx(r.BearIcons.RepeatIcon,{size:y,className:f?void 0:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"})}),d&&e.jsx("button",{type:"button",onClick:ne,className:"text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white transition-colors",children:e.jsx(r.BearIcons.SkipBackIcon,{size:P})}),e.jsx("button",{type:"button",onClick:E,className:"Bear-MediaPlayer__play w-10 h-10 rounded-full flex items-center justify-center text-white transition-colors",style:{backgroundColor:u},children:ie}),d&&e.jsx("button",{type:"button",onClick:ae,className:"text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white transition-colors",children:e.jsx(r.BearIcons.SkipForwardIcon,{size:P})}),e.jsx("button",{type:"button",onClick:te,className:"text-gray-500 hover:text-gray-700 dark:hover:text-gray-300",children:oe})]})]}),d&&!k&&e.jsx("div",{className:"Bear-MediaPlayer__playlist bg-gray-50 dark:bg-zinc-900 border-t border-gray-200 dark:border-zinc-700 max-h-48 overflow-y-auto",children:x.map((t,n)=>{const a=n===l;return e.jsxs("button",{type:"button",onClick:()=>v(n),className:m.cn("w-full flex items-center gap-3 px-3 py-2 text-left transition-colors",!a&&"hover:bg-gray-100 dark:hover:bg-zinc-800"),style:a?{backgroundColor:Ce}:void 0,children:[t.poster&&e.jsx("img",{src:t.poster,alt:"",className:"w-8 h-8 rounded object-cover shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs font-medium truncate",style:a?{color:u}:void 0,children:t.title??`Track ${n+1}`}),t.artist&&e.jsx("p",{className:"text-[10px] text-gray-400 truncate",children:t.artist})]}),a&&b&&e.jsxs("div",{className:"flex items-end gap-0.5 h-3",children:[e.jsx("span",{className:"w-0.5 rounded-full animate-pulse",style:{height:"60%",backgroundColor:u}}),e.jsx("span",{className:"w-0.5 rounded-full animate-pulse",style:{height:"100%",backgroundColor:u,animationDelay:"0.2s"}}),e.jsx("span",{className:"w-0.5 rounded-full animate-pulse",style:{height:"40%",backgroundColor:u,animationDelay:"0.4s"}})]}),e.jsx("span",{className:"text-[10px] text-gray-400 tabular-nums shrink-0",children:n+1})]},n)})})]})]})};exports.MediaPlayer=ze;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t="#ec4899",a=4,i=48,e={sm:{maxWidth:360,aspectRatio:"4 / 3",padding:"p-2",gap:"gap-2",text:"text-[10px]",iconSm:14,iconMd:16},md:{maxWidth:640,aspectRatio:"16 / 9",padding:"p-3",gap:"gap-3",text:"text-xs",iconSm:18,iconMd:20},lg:{maxWidth:960,aspectRatio:"21 / 9",padding:"p-4",gap:"gap-4",text:"text-sm",iconSm:20,iconMd:24}};exports.CENTER_ICON_SIZE=i;exports.DEFAULT_ACCENT=t;exports.PROGRESS_HEIGHT=a;exports.SIZE_MAP=e;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const DEFAULT_ACCENT = "#ec4899";
|
|
2
|
+
export declare const PROGRESS_HEIGHT = 4;
|
|
3
|
+
export declare const ICON_SM = 18;
|
|
4
|
+
export declare const ICON_MD = 20;
|
|
5
|
+
export declare const STICKY_WIDTH = 340;
|
|
6
|
+
export declare const STICKY_OFFSET = 16;
|
|
7
|
+
export declare const CENTER_ICON_SIZE = 48;
|
|
8
|
+
export declare const SIZE_MAP: {
|
|
9
|
+
readonly sm: {
|
|
10
|
+
readonly maxWidth: 360;
|
|
11
|
+
readonly aspectRatio: "4 / 3";
|
|
12
|
+
readonly padding: "p-2";
|
|
13
|
+
readonly gap: "gap-2";
|
|
14
|
+
readonly text: "text-[10px]";
|
|
15
|
+
readonly iconSm: 14;
|
|
16
|
+
readonly iconMd: 16;
|
|
17
|
+
};
|
|
18
|
+
readonly md: {
|
|
19
|
+
readonly maxWidth: 640;
|
|
20
|
+
readonly aspectRatio: "16 / 9";
|
|
21
|
+
readonly padding: "p-3";
|
|
22
|
+
readonly gap: "gap-3";
|
|
23
|
+
readonly text: "text-xs";
|
|
24
|
+
readonly iconSm: 18;
|
|
25
|
+
readonly iconMd: 20;
|
|
26
|
+
};
|
|
27
|
+
readonly lg: {
|
|
28
|
+
readonly maxWidth: 960;
|
|
29
|
+
readonly aspectRatio: "21 / 9";
|
|
30
|
+
readonly padding: "p-4";
|
|
31
|
+
readonly gap: "gap-4";
|
|
32
|
+
readonly text: "text-sm";
|
|
33
|
+
readonly iconSm: 20;
|
|
34
|
+
readonly iconMd: 24;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const t = "#ec4899", a = 4, p = 48, i = {
|
|
2
|
+
sm: { maxWidth: 360, aspectRatio: "4 / 3", padding: "p-2", gap: "gap-2", text: "text-[10px]", iconSm: 14, iconMd: 16 },
|
|
3
|
+
md: { maxWidth: 640, aspectRatio: "16 / 9", padding: "p-3", gap: "gap-3", text: "text-xs", iconSm: 18, iconMd: 20 },
|
|
4
|
+
lg: { maxWidth: 960, aspectRatio: "21 / 9", padding: "p-4", gap: "gap-4", text: "text-sm", iconSm: 20, iconMd: 24 }
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
p as CENTER_ICON_SIZE,
|
|
8
|
+
t as DEFAULT_ACCENT,
|
|
9
|
+
a as PROGRESS_HEIGHT,
|
|
10
|
+
i as SIZE_MAP
|
|
11
|
+
};
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { jsx as e, jsxs as s, Fragment as De } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as $, useState as p, useMemo as G, useEffect as U, useCallback as x } from "react";
|
|
3
|
+
import { cn as h } from "../../utils/cn.js";
|
|
4
|
+
import { BearIcons as i } from "../Icon/index.js";
|
|
5
|
+
import { SIZE_MAP as Oe, CENTER_ICON_SIZE as me, PROGRESS_HEIGHT as he, DEFAULT_ACCENT as Ye } from "./MediaPlayer.const.js";
|
|
6
|
+
import { formatTime as C } from "./MediaPlayer.utils.js";
|
|
7
|
+
import { useBearStyles as $e } from "../../hooks/useBearStyles.js";
|
|
8
|
+
const Ge = 320, fe = 16, Xe = ({
|
|
9
|
+
src: W,
|
|
10
|
+
type: R = "video",
|
|
11
|
+
poster: L,
|
|
12
|
+
autoPlay: j = !1,
|
|
13
|
+
loop: A = !1,
|
|
14
|
+
muted: Z = !1,
|
|
15
|
+
nativeControls: w = !1,
|
|
16
|
+
width: F,
|
|
17
|
+
height: q,
|
|
18
|
+
size: ge = "md",
|
|
19
|
+
accentColor: u = Ye,
|
|
20
|
+
playIcon: H,
|
|
21
|
+
pauseIcon: K,
|
|
22
|
+
muteIcon: pe,
|
|
23
|
+
unmuteIcon: xe,
|
|
24
|
+
fullscreenIcon: ye,
|
|
25
|
+
centerOverlay: ve = !1,
|
|
26
|
+
sticky: D = !1,
|
|
27
|
+
stickyPosition: V = "right",
|
|
28
|
+
stickySize: X = Ge,
|
|
29
|
+
airPlay: be = !1,
|
|
30
|
+
playlist: _,
|
|
31
|
+
onTrackChange: M,
|
|
32
|
+
bis: ke,
|
|
33
|
+
testId: Ne,
|
|
34
|
+
className: we,
|
|
35
|
+
style: Ie,
|
|
36
|
+
..._e
|
|
37
|
+
}) => {
|
|
38
|
+
const f = $(null), J = $(null), Q = $(null), [N, O] = p(j), [I, ee] = p(0), [v, te] = p(0), [P, Me] = p(Z), [g, ne] = p(A), [S, Pe] = p(!1), [re, Se] = p(0), [Ee, E] = p(!j), [l, ze] = p(0), Y = $e(ke, Ie), m = G(() => _ && _.length > 0 ? _ : [{ src: W, poster: L, type: R, title: void 0, artist: void 0 }], [_, W, L, R]), a = m[l], Te = a.src, z = a.poster ?? L, c = a.type ?? R, d = m.length > 1, o = Oe[ge];
|
|
39
|
+
U(() => {
|
|
40
|
+
ne(A);
|
|
41
|
+
}, [A]), U(() => {
|
|
42
|
+
const t = f.current;
|
|
43
|
+
if (!t) return;
|
|
44
|
+
const n = () => ee(t.currentTime), r = () => te(t.duration), k = () => {
|
|
45
|
+
d && l < m.length - 1 ? b(l + 1) : g ? d && b(0) : (O(!1), E(!0));
|
|
46
|
+
};
|
|
47
|
+
return t.addEventListener("timeupdate", n), t.addEventListener("loadedmetadata", r), t.addEventListener("ended", k), () => {
|
|
48
|
+
t.removeEventListener("timeupdate", n), t.removeEventListener("loadedmetadata", r), t.removeEventListener("ended", k);
|
|
49
|
+
};
|
|
50
|
+
}, [g, d, l, m.length]), U(() => {
|
|
51
|
+
if (!D || c !== "video") return;
|
|
52
|
+
const t = Q.current;
|
|
53
|
+
if (!t) return;
|
|
54
|
+
const n = () => {
|
|
55
|
+
const k = t.getBoundingClientRect().bottom < 0;
|
|
56
|
+
Pe(k), k && Se(fe);
|
|
57
|
+
};
|
|
58
|
+
return window.addEventListener("scroll", n, { passive: !0 }), n(), () => window.removeEventListener("scroll", n);
|
|
59
|
+
}, [D, c]);
|
|
60
|
+
const b = x((t) => {
|
|
61
|
+
const n = Math.max(0, Math.min(m.length - 1, t));
|
|
62
|
+
ze(n), ee(0), te(0), E(!1), M == null || M(n, m[n]), setTimeout(() => {
|
|
63
|
+
const r = f.current;
|
|
64
|
+
r && (r.load(), r.play().catch(() => {
|
|
65
|
+
}), O(!0));
|
|
66
|
+
}, 50);
|
|
67
|
+
}, [m, M]), T = x(() => {
|
|
68
|
+
const t = f.current;
|
|
69
|
+
t && (N ? (t.pause(), E(!0)) : (t.play().catch(() => {
|
|
70
|
+
}), E(!1)), O(!N));
|
|
71
|
+
}, [N]), se = x((t) => {
|
|
72
|
+
const n = f.current;
|
|
73
|
+
if (!n || !v) return;
|
|
74
|
+
const r = t.currentTarget.getBoundingClientRect(), k = Math.max(0, Math.min(1, (t.clientX - r.left) / r.width));
|
|
75
|
+
n.currentTime = k * v;
|
|
76
|
+
}, [v]), ie = x(() => {
|
|
77
|
+
const t = f.current;
|
|
78
|
+
t && (t.muted = !P, Me(!P));
|
|
79
|
+
}, [P]), oe = x(() => {
|
|
80
|
+
const t = !g;
|
|
81
|
+
ne(t);
|
|
82
|
+
const n = f.current;
|
|
83
|
+
n && (n.loop = t);
|
|
84
|
+
}, [g]), Be = x(() => {
|
|
85
|
+
var n;
|
|
86
|
+
const t = J.current;
|
|
87
|
+
t && (document.fullscreenElement ? document.exitFullscreen() : (n = t.requestFullscreen) == null || n.call(t));
|
|
88
|
+
}, []), Ce = x(() => {
|
|
89
|
+
const t = f.current;
|
|
90
|
+
t != null && t.webkitShowPlaybackTargetPicker && t.webkitShowPlaybackTargetPicker();
|
|
91
|
+
}, []), ae = x(() => {
|
|
92
|
+
if (I > 3) {
|
|
93
|
+
const t = f.current;
|
|
94
|
+
t && (t.currentTime = 0);
|
|
95
|
+
} else l > 0 && b(l - 1);
|
|
96
|
+
}, [I, l, b]), le = x(() => {
|
|
97
|
+
l < m.length - 1 && b(l + 1);
|
|
98
|
+
}, [l, m.length, b]), ce = v ? I / v * 100 : 0, y = o.iconSm, B = o.iconMd, de = N ? K ?? /* @__PURE__ */ e(i.PauseIcon, { size: B }) : H ?? /* @__PURE__ */ e(i.PlayIcon, { size: B }), ue = P ? pe ?? /* @__PURE__ */ e(i.VolumeOffIcon, { size: y }) : xe ?? /* @__PURE__ */ e(i.VolumeUpIcon, { size: y }), Re = ye ?? /* @__PURE__ */ e(i.MaximizeIcon, { size: y }), Le = c === "video" ? "video" : "audio", je = G(() => S && c === "video" ? {
|
|
99
|
+
...Y,
|
|
100
|
+
position: "fixed",
|
|
101
|
+
top: re,
|
|
102
|
+
[V === "left" ? "left" : "right"]: fe,
|
|
103
|
+
width: X,
|
|
104
|
+
zIndex: 50,
|
|
105
|
+
boxShadow: "0 8px 32px rgba(0,0,0,0.45)",
|
|
106
|
+
borderRadius: 12,
|
|
107
|
+
transition: "top 0.15s ease-out"
|
|
108
|
+
} : {
|
|
109
|
+
...Y,
|
|
110
|
+
width: F ?? "100%",
|
|
111
|
+
height: q,
|
|
112
|
+
maxWidth: F ? void 0 : o.maxWidth
|
|
113
|
+
}, [S, c, Y, F, q, o.maxWidth, re, V, X]), Ae = G(() => {
|
|
114
|
+
if (!S)
|
|
115
|
+
return { aspectRatio: o.aspectRatio };
|
|
116
|
+
}, [S, o.aspectRatio]), Fe = `${u}20`;
|
|
117
|
+
return /* @__PURE__ */ s(De, { children: [
|
|
118
|
+
D && /* @__PURE__ */ e("div", { ref: Q, style: { height: 1 } }),
|
|
119
|
+
/* @__PURE__ */ s(
|
|
120
|
+
"div",
|
|
121
|
+
{
|
|
122
|
+
ref: J,
|
|
123
|
+
className: h("Bear-MediaPlayer relative rounded-xl overflow-hidden bg-black", we),
|
|
124
|
+
style: je,
|
|
125
|
+
"data-testid": Ne,
|
|
126
|
+
..._e,
|
|
127
|
+
children: [
|
|
128
|
+
/* @__PURE__ */ e(
|
|
129
|
+
Le,
|
|
130
|
+
{
|
|
131
|
+
ref: f,
|
|
132
|
+
src: Te,
|
|
133
|
+
poster: z,
|
|
134
|
+
autoPlay: j,
|
|
135
|
+
loop: g && !d,
|
|
136
|
+
muted: Z,
|
|
137
|
+
controls: w,
|
|
138
|
+
playsInline: !0,
|
|
139
|
+
className: h(c === "video" ? "Bear-MediaPlayer__video w-full object-cover" : "hidden"),
|
|
140
|
+
style: c === "video" ? Ae : void 0,
|
|
141
|
+
onClick: c === "video" ? T : void 0
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
ve && c === "video" && Ee && !w && /* @__PURE__ */ e(
|
|
145
|
+
"button",
|
|
146
|
+
{
|
|
147
|
+
type: "button",
|
|
148
|
+
onClick: T,
|
|
149
|
+
className: "Bear-MediaPlayer__overlay absolute inset-0 flex items-center justify-center bg-black/30 transition-opacity",
|
|
150
|
+
children: /* @__PURE__ */ e("div", { className: "w-16 h-16 rounded-full bg-white/90 flex items-center justify-center shadow-lg", children: N ? K ?? /* @__PURE__ */ e(i.PauseIcon, { size: me, className: "text-gray-900" }) : H ?? /* @__PURE__ */ e(i.PlayIcon, { size: me, className: "text-gray-900" }) })
|
|
151
|
+
}
|
|
152
|
+
),
|
|
153
|
+
!w && c === "video" && /* @__PURE__ */ s("div", { className: h("Bear-MediaPlayer__controls absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/80 to-transparent pt-8", o.padding), children: [
|
|
154
|
+
/* @__PURE__ */ e(
|
|
155
|
+
"div",
|
|
156
|
+
{
|
|
157
|
+
className: "Bear-MediaPlayer__progress w-full cursor-pointer mb-2 group",
|
|
158
|
+
style: { height: he },
|
|
159
|
+
onClick: se,
|
|
160
|
+
children: /* @__PURE__ */ e("div", { className: "w-full h-full bg-white/30 rounded-full relative overflow-hidden", children: /* @__PURE__ */ e("div", { className: "h-full rounded-full transition-all", style: { width: `${ce}%`, backgroundColor: u } }) })
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
/* @__PURE__ */ s("div", { className: h("Bear-MediaPlayer__bar flex items-center", o.gap), children: [
|
|
164
|
+
d && /* @__PURE__ */ e("button", { type: "button", onClick: ae, className: "text-white hover:text-pink-400 transition-colors", children: /* @__PURE__ */ e(i.SkipBackIcon, { size: y }) }),
|
|
165
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: T, className: "text-white hover:text-pink-400 transition-colors", children: de }),
|
|
166
|
+
d && /* @__PURE__ */ e("button", { type: "button", onClick: le, className: "text-white hover:text-pink-400 transition-colors", children: /* @__PURE__ */ e(i.SkipForwardIcon, { size: y }) }),
|
|
167
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: ie, className: "text-white hover:text-pink-400 transition-colors", children: ue }),
|
|
168
|
+
/* @__PURE__ */ s("span", { className: h("Bear-MediaPlayer__time text-white font-mono", o.text), children: [
|
|
169
|
+
C(I),
|
|
170
|
+
" / ",
|
|
171
|
+
C(v)
|
|
172
|
+
] }),
|
|
173
|
+
/* @__PURE__ */ e("div", { className: "flex-1" }),
|
|
174
|
+
/* @__PURE__ */ e(
|
|
175
|
+
"button",
|
|
176
|
+
{
|
|
177
|
+
type: "button",
|
|
178
|
+
onClick: oe,
|
|
179
|
+
className: "transition-colors",
|
|
180
|
+
style: { color: g ? u : void 0 },
|
|
181
|
+
title: "Loop",
|
|
182
|
+
children: /* @__PURE__ */ e(i.RepeatIcon, { size: y, className: g ? void 0 : "text-white/60 hover:text-white" })
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
be && /* @__PURE__ */ e("button", { type: "button", onClick: Ce, className: "text-white hover:text-pink-400 transition-colors", title: "AirPlay", children: /* @__PURE__ */ e(i.CastIcon, { size: y }) }),
|
|
186
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: Be, className: "text-white hover:text-pink-400 transition-colors", children: Re })
|
|
187
|
+
] }),
|
|
188
|
+
d && a.title && /* @__PURE__ */ s("div", { className: "mt-1 flex items-center gap-2 truncate", children: [
|
|
189
|
+
/* @__PURE__ */ e("span", { className: "text-white text-xs font-medium truncate", children: a.title }),
|
|
190
|
+
a.artist && /* @__PURE__ */ s("span", { className: "text-white/50 text-xs truncate", children: [
|
|
191
|
+
"— ",
|
|
192
|
+
a.artist
|
|
193
|
+
] })
|
|
194
|
+
] })
|
|
195
|
+
] }),
|
|
196
|
+
c === "audio" && !w && /* @__PURE__ */ s("div", { className: h("Bear-MediaPlayer__audio bg-gray-100 dark:bg-zinc-800 rounded-xl", o.padding), children: [
|
|
197
|
+
d && (z || a.title) && /* @__PURE__ */ s("div", { className: "flex items-center gap-3 mb-3", children: [
|
|
198
|
+
z && /* @__PURE__ */ e("img", { src: z, alt: "", className: "w-12 h-12 rounded-lg object-cover shrink-0" }),
|
|
199
|
+
/* @__PURE__ */ s("div", { className: "min-w-0 flex-1", children: [
|
|
200
|
+
a.title && /* @__PURE__ */ e("p", { className: "text-sm font-semibold text-gray-900 dark:text-white truncate", children: a.title }),
|
|
201
|
+
a.artist && /* @__PURE__ */ e("p", { className: "text-xs text-gray-500 dark:text-gray-400 truncate", children: a.artist })
|
|
202
|
+
] })
|
|
203
|
+
] }),
|
|
204
|
+
/* @__PURE__ */ e("div", { className: "Bear-MediaPlayer__progress w-full cursor-pointer mb-1", style: { height: he }, onClick: se, children: /* @__PURE__ */ e("div", { className: "w-full h-full bg-gray-300 dark:bg-zinc-600 rounded-full overflow-hidden", children: /* @__PURE__ */ e("div", { className: "h-full rounded-full", style: { width: `${ce}%`, backgroundColor: u } }) }) }),
|
|
205
|
+
/* @__PURE__ */ s("div", { className: "flex justify-between mb-2", children: [
|
|
206
|
+
/* @__PURE__ */ e("span", { className: h("text-gray-500 font-mono", o.text), children: C(I) }),
|
|
207
|
+
/* @__PURE__ */ e("span", { className: h("text-gray-500 font-mono", o.text), children: C(v) })
|
|
208
|
+
] }),
|
|
209
|
+
/* @__PURE__ */ s("div", { className: h("flex items-center justify-center", o.gap), children: [
|
|
210
|
+
/* @__PURE__ */ e(
|
|
211
|
+
"button",
|
|
212
|
+
{
|
|
213
|
+
type: "button",
|
|
214
|
+
onClick: oe,
|
|
215
|
+
className: "transition-colors",
|
|
216
|
+
style: { color: g ? u : void 0 },
|
|
217
|
+
title: "Loop",
|
|
218
|
+
children: /* @__PURE__ */ e(i.RepeatIcon, { size: y, className: g ? void 0 : "text-gray-400 hover:text-gray-600 dark:hover:text-gray-300" })
|
|
219
|
+
}
|
|
220
|
+
),
|
|
221
|
+
d && /* @__PURE__ */ e("button", { type: "button", onClick: ae, className: "text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white transition-colors", children: /* @__PURE__ */ e(i.SkipBackIcon, { size: B }) }),
|
|
222
|
+
/* @__PURE__ */ e(
|
|
223
|
+
"button",
|
|
224
|
+
{
|
|
225
|
+
type: "button",
|
|
226
|
+
onClick: T,
|
|
227
|
+
className: "Bear-MediaPlayer__play w-10 h-10 rounded-full flex items-center justify-center text-white transition-colors",
|
|
228
|
+
style: { backgroundColor: u },
|
|
229
|
+
children: de
|
|
230
|
+
}
|
|
231
|
+
),
|
|
232
|
+
d && /* @__PURE__ */ e("button", { type: "button", onClick: le, className: "text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white transition-colors", children: /* @__PURE__ */ e(i.SkipForwardIcon, { size: B }) }),
|
|
233
|
+
/* @__PURE__ */ e("button", { type: "button", onClick: ie, className: "text-gray-500 hover:text-gray-700 dark:hover:text-gray-300", children: ue })
|
|
234
|
+
] })
|
|
235
|
+
] }),
|
|
236
|
+
d && !w && /* @__PURE__ */ e("div", { className: "Bear-MediaPlayer__playlist bg-gray-50 dark:bg-zinc-900 border-t border-gray-200 dark:border-zinc-700 max-h-48 overflow-y-auto", children: m.map((t, n) => {
|
|
237
|
+
const r = n === l;
|
|
238
|
+
return /* @__PURE__ */ s(
|
|
239
|
+
"button",
|
|
240
|
+
{
|
|
241
|
+
type: "button",
|
|
242
|
+
onClick: () => b(n),
|
|
243
|
+
className: h(
|
|
244
|
+
"w-full flex items-center gap-3 px-3 py-2 text-left transition-colors",
|
|
245
|
+
!r && "hover:bg-gray-100 dark:hover:bg-zinc-800"
|
|
246
|
+
),
|
|
247
|
+
style: r ? { backgroundColor: Fe } : void 0,
|
|
248
|
+
children: [
|
|
249
|
+
t.poster && /* @__PURE__ */ e("img", { src: t.poster, alt: "", className: "w-8 h-8 rounded object-cover shrink-0" }),
|
|
250
|
+
/* @__PURE__ */ s("div", { className: "min-w-0 flex-1", children: [
|
|
251
|
+
/* @__PURE__ */ e(
|
|
252
|
+
"p",
|
|
253
|
+
{
|
|
254
|
+
className: "text-xs font-medium truncate",
|
|
255
|
+
style: r ? { color: u } : void 0,
|
|
256
|
+
children: t.title ?? `Track ${n + 1}`
|
|
257
|
+
}
|
|
258
|
+
),
|
|
259
|
+
t.artist && /* @__PURE__ */ e("p", { className: "text-[10px] text-gray-400 truncate", children: t.artist })
|
|
260
|
+
] }),
|
|
261
|
+
r && N && /* @__PURE__ */ s("div", { className: "flex items-end gap-0.5 h-3", children: [
|
|
262
|
+
/* @__PURE__ */ e("span", { className: "w-0.5 rounded-full animate-pulse", style: { height: "60%", backgroundColor: u } }),
|
|
263
|
+
/* @__PURE__ */ e("span", { className: "w-0.5 rounded-full animate-pulse", style: { height: "100%", backgroundColor: u, animationDelay: "0.2s" } }),
|
|
264
|
+
/* @__PURE__ */ e("span", { className: "w-0.5 rounded-full animate-pulse", style: { height: "40%", backgroundColor: u, animationDelay: "0.4s" } })
|
|
265
|
+
] }),
|
|
266
|
+
/* @__PURE__ */ e("span", { className: "text-[10px] text-gray-400 tabular-nums shrink-0", children: n + 1 })
|
|
267
|
+
]
|
|
268
|
+
},
|
|
269
|
+
n
|
|
270
|
+
);
|
|
271
|
+
}) })
|
|
272
|
+
]
|
|
273
|
+
}
|
|
274
|
+
)
|
|
275
|
+
] });
|
|
276
|
+
};
|
|
277
|
+
export {
|
|
278
|
+
Xe as MediaPlayer
|
|
279
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { BisProp } from '../../types/bis.types';
|
|
3
|
+
export type MediaType = 'video' | 'audio';
|
|
4
|
+
export type MediaPlayerSize = 'sm' | 'md' | 'lg';
|
|
5
|
+
export type StickyPosition = 'left' | 'right';
|
|
6
|
+
export interface PlaylistItem {
|
|
7
|
+
/** Media source URL */
|
|
8
|
+
src: string;
|
|
9
|
+
/** Track title */
|
|
10
|
+
title?: string;
|
|
11
|
+
/** Artist or subtitle */
|
|
12
|
+
artist?: string;
|
|
13
|
+
/** Poster / cover art */
|
|
14
|
+
poster?: string;
|
|
15
|
+
/** Media type override */
|
|
16
|
+
type?: MediaType;
|
|
17
|
+
}
|
|
18
|
+
export interface MediaPlayerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
19
|
+
/** Media source URL */
|
|
20
|
+
src: string;
|
|
21
|
+
/** Media type */
|
|
22
|
+
type?: MediaType;
|
|
23
|
+
/** Poster image (video only) */
|
|
24
|
+
poster?: string;
|
|
25
|
+
/** Auto-play on mount */
|
|
26
|
+
autoPlay?: boolean;
|
|
27
|
+
/** Loop playback */
|
|
28
|
+
loop?: boolean;
|
|
29
|
+
/** Mute audio */
|
|
30
|
+
muted?: boolean;
|
|
31
|
+
/** Show native controls fallback */
|
|
32
|
+
nativeControls?: boolean;
|
|
33
|
+
/** Video width */
|
|
34
|
+
width?: number | string;
|
|
35
|
+
/** Video height */
|
|
36
|
+
height?: number | string;
|
|
37
|
+
/** Player size preset — controls aspect ratio and UI density */
|
|
38
|
+
size?: MediaPlayerSize;
|
|
39
|
+
/** Accent color for controls */
|
|
40
|
+
accentColor?: string;
|
|
41
|
+
/** Custom play icon */
|
|
42
|
+
playIcon?: ReactNode;
|
|
43
|
+
/** Custom pause icon */
|
|
44
|
+
pauseIcon?: ReactNode;
|
|
45
|
+
/** Custom mute icon */
|
|
46
|
+
muteIcon?: ReactNode;
|
|
47
|
+
/** Custom unmute icon */
|
|
48
|
+
unmuteIcon?: ReactNode;
|
|
49
|
+
/** Custom fullscreen icon */
|
|
50
|
+
fullscreenIcon?: ReactNode;
|
|
51
|
+
/** Show a large centered play/pause overlay on the video */
|
|
52
|
+
centerOverlay?: boolean;
|
|
53
|
+
/** Follow the scroll — player scrolls alongside the page at the given side */
|
|
54
|
+
sticky?: boolean;
|
|
55
|
+
/** Which side the sticky player appears on */
|
|
56
|
+
stickyPosition?: StickyPosition;
|
|
57
|
+
/** Sticky player width in px */
|
|
58
|
+
stickySize?: number;
|
|
59
|
+
/** Show AirPlay button (when browser supports it) */
|
|
60
|
+
airPlay?: boolean;
|
|
61
|
+
/** Playlist items — enables gallery mode */
|
|
62
|
+
playlist?: PlaylistItem[];
|
|
63
|
+
/** Called when active track changes */
|
|
64
|
+
onTrackChange?: (index: number, item: PlaylistItem) => void;
|
|
65
|
+
/** Bear Inner Style overrides */
|
|
66
|
+
bis?: BisProp;
|
|
67
|
+
/** Test ID */
|
|
68
|
+
testId?: string;
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=60,n=2;function a(t){const r=Math.floor(t/o),e=Math.floor(t%o);return`${r}:${e.toString().padStart(n,"0")}`}exports.formatTime=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatTime(s: number): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),r=require("react"),k=require("../../utils/cn.cjs"),W=require("../Portal/Portal.cjs"),Z=require("./MentionsInput.utils.cjs"),G=1e4,J={sm:"bear-h-8 bear-text-sm bear-px-3",md:"bear-h-10 bear-text-base bear-px-4",lg:"bear-h-12 bear-text-lg bear-px-5"},X=({value:x,defaultValue:L="",onChange:o,onMentionSelect:w,options:O,trigger:l="@",placeholder:P="Type @ to mention...",disabled:E=!1,maxSuggestions:D=5,filterOptions:T=Z.defaultFilter,size:A="md",fullWidth:_=!1,className:$})=>{const[B,I]=r.useState(L),[d,K]=r.useState(""),[Q,f]=r.useState(!1),[u,h]=r.useState(0),[p,F]=r.useState(null),q=r.useRef(null),g=r.useRef(null),m=r.useRef(null),z=r.useRef(null),[v,H]=r.useState({top:0,left:0,width:0}),i=x??B,b=T(O,d).slice(0,D),R=Q&&d.length>=0,y=R&&b.length>0,j=r.useCallback(()=>{const e=i.lastIndexOf(l);if(e===-1)return{query:"",start:null};const t=i.slice(e+l.length),n=t.indexOf(" ");return{query:n===-1?t:t.slice(0,n),start:e}},[i,l]);r.useEffect(()=>{const{query:e,start:t}=j();K(e),F(t),f(t!==null&&!e.includes(" "))},[i,j]),r.useEffect(()=>{h(0)},[d]),r.useEffect(()=>{if(u>=0&&m.current){const e=m.current.children[u];e==null||e.scrollIntoView({block:"nearest"})}},[u]),r.useEffect(()=>{if(!y)return;const e=()=>{var n;const t=(n=g.current)==null?void 0:n.getBoundingClientRect();t&&H({top:t.bottom+4,left:Math.max(8,Math.min(t.left,window.innerWidth-t.width-8)),width:t.width})};return e(),window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[y]),r.useEffect(()=>{const e=t=>{var s,c;const n=t.target;(s=q.current)!=null&&s.contains(n)||(c=z.current)!=null&&c.contains(n)||f(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const M=e=>{const t=new RegExp(`${l}(\\w+)`,"g"),n=[];let s;for(;(s=t.exec(e))!==null;)n.push(s[1]);return[...new Set(n)]},U=e=>{const t=e.target.value;x===void 0&&I(t),o==null||o(t,M(t))},N=e=>{var S;if(p==null)return;const t=i.slice(0,p),n=i.slice(p+l.length+d.length),s=`${l}${e.value}`,c=t+s+" "+n;x===void 0&&I(c),o==null||o(c,M(c)),w==null||w(e),f(!1),(S=g.current)==null||S.focus()},V=e=>{if(!(!R||b.length===0)){if(e.key==="ArrowDown"){e.preventDefault(),h(t=>Math.min(t+1,b.length-1));return}if(e.key==="ArrowUp"){e.preventDefault(),h(t=>Math.max(t-1,0));return}if(e.key==="Enter"||e.key==="Tab"){e.preventDefault();const t=b[u];t&&N(t);return}e.key==="Escape"&&f(!1)}};return a.jsxs("div",{ref:q,className:k.cn("Bear-MentionsInput bear-relative",_&&"bear-w-full",$),children:[a.jsx("input",{ref:g,type:"text",value:i,onChange:U,onKeyDown:V,placeholder:P,disabled:E,className:k.cn("bear-w-full bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-900 bear-text-gray-900 dark:bear-text-white placeholder:bear-text-gray-500 dark:placeholder:bear-text-zinc-500 bear-outline-none bear-transition-colors focus:bear-border-bear-500 focus:bear-ring-2 focus:bear-ring-bear-500/20",E&&"bear-opacity-50 bear-cursor-not-allowed",J[A])}),y&&a.jsx(W.Portal,{children:a.jsx("div",{ref:z,className:"bear-fixed bear-rounded-lg bear-border bear-border-gray-200 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-800 bear-shadow-lg",style:{top:v.top,left:v.left,width:v.width,zIndex:G},children:a.jsx("div",{ref:m,className:"bear-max-h-48 bear-overflow-auto bear-py-1",children:b.map((e,t)=>a.jsxs("button",{type:"button",className:k.cn("bear-w-full bear-flex bear-items-center bear-gap-2 bear-px-3 bear-py-2 bear-text-left bear-text-gray-800 dark:bear-text-zinc-200 hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700 bear-transition-colors",t===u&&"bear-bg-gray-100 dark:bear-bg-zinc-700"),onMouseEnter:()=>h(t),onClick:()=>N(e),children:[e.avatar&&a.jsx("span",{className:"bear-shrink-0",children:e.avatar}),a.jsx("span",{children:e.label})]},e.value))})})})]})};exports.MentionsInput=X;
|