@forgedevstack/bear 1.0.6 → 1.0.8
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/Alert/Alert.cjs +1 -1
- package/dist/components/Alert/Alert.const.cjs +1 -1
- package/dist/components/Alert/Alert.const.d.ts +4 -0
- package/dist/components/Alert/Alert.const.js +9 -15
- package/dist/components/Alert/Alert.js +43 -38
- package/dist/components/AppBar/AppBar.cjs +1 -1
- package/dist/components/AppBar/AppBar.js +20 -16
- package/dist/components/BackTop/BackTop.cjs +1 -0
- package/dist/components/BackTop/BackTop.const.cjs +1 -0
- package/dist/components/BackTop/BackTop.const.d.ts +34 -0
- package/dist/components/BackTop/BackTop.const.js +29 -0
- package/dist/components/BackTop/BackTop.d.ts +21 -0
- package/dist/components/BackTop/BackTop.js +87 -0
- package/dist/components/BackTop/BackTop.types.d.ts +28 -0
- package/dist/components/BackTop/index.d.ts +3 -0
- package/dist/components/Badge/Badge.constants.d.ts +4 -4
- package/dist/components/Badge/Badge.types.d.ts +3 -3
- package/dist/components/BottomSheet/BottomSheet.cjs +1 -0
- package/dist/components/BottomSheet/BottomSheet.d.ts +3 -0
- package/dist/components/BottomSheet/BottomSheet.js +103 -0
- package/dist/components/BottomSheet/BottomSheet.types.d.ts +13 -0
- package/dist/components/BottomSheet/index.d.ts +2 -0
- package/dist/components/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.constants.cjs +38 -48
- package/dist/components/Button/Button.constants.d.ts +22 -3
- package/dist/components/Button/Button.constants.js +51 -50
- package/dist/components/Button/Button.d.ts +14 -7
- package/dist/components/Button/Button.js +123 -43
- package/dist/components/Button/Button.types.d.ts +26 -4
- package/dist/components/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.js +3 -2
- package/dist/components/Card/Card.const.d.ts +2 -2
- package/dist/components/Card/Card.types.d.ts +2 -2
- package/dist/components/Chat/Chat.cjs +1 -0
- package/dist/components/Chat/Chat.const.cjs +1 -0
- package/dist/components/Chat/Chat.const.d.ts +26 -0
- package/dist/components/Chat/Chat.const.js +29 -0
- package/dist/components/Chat/Chat.d.ts +21 -0
- package/dist/components/Chat/Chat.js +179 -0
- package/dist/components/Chat/Chat.types.d.ts +55 -0
- package/dist/components/Chat/index.d.ts +2 -0
- package/dist/components/Confetti/Confetti.cjs +1 -0
- package/dist/components/Confetti/Confetti.const.cjs +1 -0
- package/dist/components/Confetti/Confetti.const.d.ts +16 -0
- package/dist/components/Confetti/Confetti.const.js +36 -0
- package/dist/components/Confetti/Confetti.d.ts +23 -0
- package/dist/components/Confetti/Confetti.js +94 -0
- package/dist/components/Confetti/Confetti.types.d.ts +50 -0
- package/dist/components/Confetti/index.d.ts +4 -0
- package/dist/components/Confetti/useConfetti.cjs +1 -0
- package/dist/components/Confetti/useConfetti.d.ts +13 -0
- package/dist/components/Confetti/useConfetti.js +12 -0
- package/dist/components/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/DatePicker/DatePicker.js +3 -2
- package/dist/components/DiffViewer/DiffViewer.cjs +1 -0
- package/dist/components/DiffViewer/DiffViewer.const.cjs +1 -0
- package/dist/components/DiffViewer/DiffViewer.const.d.ts +18 -0
- package/dist/components/DiffViewer/DiffViewer.const.js +21 -0
- package/dist/components/DiffViewer/DiffViewer.d.ts +18 -0
- package/dist/components/DiffViewer/DiffViewer.js +127 -0
- package/dist/components/DiffViewer/DiffViewer.types.d.ts +40 -0
- package/dist/components/DiffViewer/DiffViewer.utils.cjs +3 -0
- package/dist/components/DiffViewer/DiffViewer.utils.d.ts +9 -0
- package/dist/components/DiffViewer/DiffViewer.utils.js +39 -0
- package/dist/components/DiffViewer/index.d.ts +2 -0
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +35 -35
- package/dist/components/EmojiPicker/EmojiPicker.cjs +1 -0
- package/dist/components/EmojiPicker/EmojiPicker.const.cjs +1 -0
- package/dist/components/EmojiPicker/EmojiPicker.const.d.ts +5 -0
- package/dist/components/EmojiPicker/EmojiPicker.const.js +10 -0
- package/dist/components/EmojiPicker/EmojiPicker.d.ts +3 -0
- package/dist/components/EmojiPicker/EmojiPicker.js +63 -0
- package/dist/components/EmojiPicker/EmojiPicker.types.d.ts +6 -0
- package/dist/components/EmojiPicker/index.d.ts +3 -0
- package/dist/components/FloatingChat/FloatingChat.cjs +1 -0
- package/dist/components/FloatingChat/FloatingChat.const.cjs +1 -0
- package/dist/components/FloatingChat/FloatingChat.const.d.ts +12 -0
- package/dist/components/FloatingChat/FloatingChat.const.js +15 -0
- package/dist/components/FloatingChat/FloatingChat.d.ts +19 -0
- package/dist/components/FloatingChat/FloatingChat.js +144 -0
- package/dist/components/FloatingChat/FloatingChat.types.d.ts +44 -0
- package/dist/components/FloatingChat/index.d.ts +2 -0
- package/dist/components/JsonViewer/JsonViewer.cjs +1 -0
- package/dist/components/JsonViewer/JsonViewer.const.cjs +1 -0
- package/dist/components/JsonViewer/JsonViewer.const.d.ts +4 -0
- package/dist/components/JsonViewer/JsonViewer.const.js +24 -0
- package/dist/components/JsonViewer/JsonViewer.d.ts +17 -0
- package/dist/components/JsonViewer/JsonViewer.js +195 -0
- package/dist/components/JsonViewer/JsonViewer.types.d.ts +54 -0
- package/dist/components/JsonViewer/index.d.ts +2 -0
- package/dist/components/Kanban/Kanban.cjs +1 -0
- package/dist/components/Kanban/Kanban.d.ts +3 -0
- package/dist/components/Kanban/Kanban.js +91 -0
- package/dist/components/Kanban/Kanban.types.d.ts +21 -0
- package/dist/components/Kanban/index.d.ts +2 -0
- package/dist/components/MentionsInput/MentionsInput.cjs +1 -0
- package/dist/components/MentionsInput/MentionsInput.d.ts +3 -0
- package/dist/components/MentionsInput/MentionsInput.js +140 -0
- package/dist/components/MentionsInput/MentionsInput.types.d.ts +21 -0
- package/dist/components/MentionsInput/index.d.ts +2 -0
- package/dist/components/QRCode/QRCode.cjs +1 -0
- package/dist/components/QRCode/QRCode.const.cjs +1 -0
- package/dist/components/QRCode/QRCode.const.d.ts +21 -0
- package/dist/components/QRCode/QRCode.const.js +11 -0
- package/dist/components/QRCode/QRCode.d.ts +29 -0
- package/dist/components/QRCode/QRCode.js +68 -0
- package/dist/components/QRCode/QRCode.types.d.ts +32 -0
- package/dist/components/QRCode/QRCode.utils.cjs +1 -0
- package/dist/components/QRCode/QRCode.utils.d.ts +12 -0
- package/dist/components/QRCode/QRCode.utils.js +74 -0
- package/dist/components/QRCode/index.d.ts +3 -0
- package/dist/components/RichEditor/RichEditor.cjs +1 -1
- package/dist/components/RichEditor/RichEditor.const.cjs +2 -2
- package/dist/components/RichEditor/RichEditor.const.d.ts +4 -1
- package/dist/components/RichEditor/RichEditor.const.js +51 -18
- package/dist/components/RichEditor/RichEditor.js +106 -105
- package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.cjs +1 -1
- package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.js +105 -95
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.cjs +1 -1
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.d.ts +2 -0
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.js +47 -29
- package/dist/components/SegmentedControl/SegmentedControl.cjs +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +3 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +58 -0
- package/dist/components/SegmentedControl/SegmentedControl.types.d.ts +16 -0
- package/dist/components/SegmentedControl/index.d.ts +2 -0
- package/dist/components/SignPad/SignPad.cjs +1 -1
- package/dist/components/SignPad/SignPad.js +98 -90
- package/dist/components/SliderRange/SliderRange.cjs +1 -0
- package/dist/components/SliderRange/SliderRange.d.ts +3 -0
- package/dist/components/SliderRange/SliderRange.js +142 -0
- package/dist/components/SliderRange/SliderRange.types.d.ts +17 -0
- package/dist/components/SliderRange/index.d.ts +2 -0
- package/dist/components/Spinner/Spinner.types.d.ts +2 -2
- package/dist/components/TagsInput/TagsInput.cjs +1 -0
- package/dist/components/TagsInput/TagsInput.d.ts +3 -0
- package/dist/components/TagsInput/TagsInput.js +100 -0
- package/dist/components/TagsInput/TagsInput.types.d.ts +16 -0
- package/dist/components/TagsInput/index.d.ts +2 -0
- package/dist/components/Terminal/Terminal.cjs +1 -0
- package/dist/components/Terminal/Terminal.const.cjs +1 -0
- package/dist/components/Terminal/Terminal.const.d.ts +32 -0
- package/dist/components/Terminal/Terminal.const.js +42 -0
- package/dist/components/Terminal/Terminal.d.ts +27 -0
- package/dist/components/Terminal/Terminal.js +155 -0
- package/dist/components/Terminal/Terminal.types.d.ts +49 -0
- package/dist/components/Terminal/index.d.ts +2 -0
- package/dist/components/Tour/Tour.cjs +1 -0
- package/dist/components/Tour/Tour.const.cjs +1 -0
- package/dist/components/Tour/Tour.const.d.ts +25 -0
- package/dist/components/Tour/Tour.const.js +38 -0
- package/dist/components/Tour/Tour.d.ts +17 -0
- package/dist/components/Tour/Tour.js +179 -0
- package/dist/components/Tour/Tour.types.d.ts +80 -0
- package/dist/components/Tour/index.d.ts +4 -0
- package/dist/components/Tour/useTour.cjs +1 -0
- package/dist/components/Tour/useTour.d.ts +14 -0
- package/dist/components/Tour/useTour.js +27 -0
- package/dist/components/Typography/Typography.cjs +1 -1
- package/dist/components/Typography/Typography.d.ts +5 -1
- package/dist/components/Typography/Typography.js +93 -57
- package/dist/components/Typography/Typography.types.d.ts +29 -2
- package/dist/components/VirtualList/VirtualList.cjs +1 -0
- package/dist/components/VirtualList/VirtualList.d.ts +3 -0
- package/dist/components/VirtualList/VirtualList.js +68 -0
- package/dist/components/VirtualList/VirtualList.types.d.ts +10 -0
- package/dist/components/VirtualList/index.d.ts +2 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +35 -1
- package/dist/components/index.js +240 -198
- package/dist/context/BearProvider.cjs +1 -1
- package/dist/context/BearProvider.d.ts +110 -5
- package/dist/context/BearProvider.js +198 -53
- package/dist/context/defaultTheme.cjs +1 -1
- package/dist/context/defaultTheme.js +11 -11
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +18 -0
- package/dist/hooks/index.js +56 -35
- package/dist/hooks/useBearComponent/index.d.ts +2 -0
- package/dist/hooks/useBearComponent/useBearComponent.cjs +1 -0
- package/dist/hooks/useBearComponent/useBearComponent.d.ts +71 -0
- package/dist/hooks/useBearComponent/useBearComponent.js +54 -0
- package/dist/hooks/useBearComponent/useBearComponent.types.d.ts +40 -0
- package/dist/hooks/useDragDrop/index.d.ts +2 -0
- package/dist/hooks/useDragDrop/useDragDrop.cjs +1 -0
- package/dist/hooks/useDragDrop/useDragDrop.d.ts +22 -0
- package/dist/hooks/useDragDrop/useDragDrop.js +56 -0
- package/dist/hooks/useDragDrop/useDragDrop.types.d.ts +55 -0
- package/dist/hooks/useIdle/index.d.ts +2 -0
- package/dist/hooks/useIdle/useIdle.cjs +1 -0
- package/dist/hooks/useIdle/useIdle.d.ts +22 -0
- package/dist/hooks/useIdle/useIdle.js +66 -0
- package/dist/hooks/useIdle/useIdle.types.d.ts +29 -0
- package/dist/hooks/useLazyLoad/index.d.ts +2 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.cjs +1 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.d.ts +26 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.js +27 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.types.d.ts +25 -0
- package/dist/hooks/useLongPress/index.d.ts +2 -0
- package/dist/hooks/useLongPress/useLongPress.cjs +1 -0
- package/dist/hooks/useLongPress/useLongPress.d.ts +17 -0
- package/dist/hooks/useLongPress/useLongPress.js +44 -0
- package/dist/hooks/useLongPress/useLongPress.types.d.ts +26 -0
- package/dist/hooks/useOnline/index.d.ts +2 -0
- package/dist/hooks/useOnline/useOnline.cjs +1 -0
- package/dist/hooks/useOnline/useOnline.d.ts +16 -0
- package/dist/hooks/useOnline/useOnline.js +25 -0
- package/dist/hooks/useOnline/useOnline.types.d.ts +15 -0
- package/dist/hooks/usePageVisibility/index.d.ts +2 -0
- package/dist/hooks/usePageVisibility/usePageVisibility.cjs +1 -0
- package/dist/hooks/usePageVisibility/usePageVisibility.d.ts +19 -0
- package/dist/hooks/usePageVisibility/usePageVisibility.js +26 -0
- package/dist/hooks/usePageVisibility/usePageVisibility.types.d.ts +15 -0
- package/dist/hooks/useSpotlight/index.d.ts +2 -0
- package/dist/hooks/useSpotlight/useSpotlight.cjs +1 -0
- package/dist/hooks/useSpotlight/useSpotlight.d.ts +24 -0
- package/dist/hooks/useSpotlight/useSpotlight.js +49 -0
- package/dist/hooks/useSpotlight/useSpotlight.types.d.ts +23 -0
- package/dist/hooks/useWebSocket/index.d.ts +2 -0
- package/dist/hooks/useWebSocket/useWebSocket.cjs +1 -0
- package/dist/hooks/useWebSocket/useWebSocket.d.ts +22 -0
- package/dist/hooks/useWebSocket/useWebSocket.js +75 -0
- package/dist/hooks/useWebSocket/useWebSocket.types.d.ts +44 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +327 -264
- package/dist/styles.css +1 -1
- package/dist/types/component.types.d.ts +125 -42
- package/dist/types/theme.types.d.ts +82 -0
- package/package.json +1 -1
|
@@ -1,153 +1,161 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as J, useState as
|
|
3
|
-
import { cn as
|
|
1
|
+
import { jsxs as p, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as J, useState as m, useEffect as L, useCallback as u } from "react";
|
|
3
|
+
import { cn as d } from "../../utils/cn.js";
|
|
4
4
|
import { Button as O } from "../Button/Button.js";
|
|
5
|
-
import { SIGN_PAD_DEFAULT_WIDTH as q, SIGN_PAD_DEFAULT_HEIGHT as Z, SIGN_PAD_DEFAULT_STROKE_WIDTH as $, SIGN_PAD_DEFAULT_PLACEHOLDER as
|
|
6
|
-
const
|
|
5
|
+
import { SIGN_PAD_DEFAULT_WIDTH as q, SIGN_PAD_DEFAULT_HEIGHT as Z, SIGN_PAD_DEFAULT_STROKE_WIDTH as $, SIGN_PAD_DEFAULT_PLACEHOLDER as ee, SIGN_PAD_DEFAULT_OUTPUT_FORMAT as te, SIGN_PAD_DEFAULT_OUTPUT_QUALITY as ne, SIGN_PAD_BG_DARK as re, SIGN_PAD_BG_LIGHT as oe, SIGN_PAD_STROKE_DARK as ae, SIGN_PAD_STROKE_LIGHT as se, SIGN_PAD_PLACEHOLDER_CLASSES as ce, SIGN_PAD_LINE_CLASSES as ie, SIGN_PAD_X_MARK_CLASSES as le, SIGN_PAD_CANVAS_WRAPPER_HOVER as ue, SIGN_PAD_CANVAS_WRAPPER_CLASSES as de, SIGN_PAD_ACTIONS_CLASSES as _e, SIGN_PAD_ROOT_CLASSES as Se } from "./SignPad.const.js";
|
|
6
|
+
const ve = (U) => {
|
|
7
7
|
const {
|
|
8
|
-
onChange:
|
|
8
|
+
onChange: o,
|
|
9
9
|
width: S = q,
|
|
10
|
-
height:
|
|
10
|
+
height: h = Z,
|
|
11
11
|
strokeColor: B,
|
|
12
|
-
strokeWidth:
|
|
12
|
+
strokeWidth: N = $,
|
|
13
13
|
backgroundColor: M,
|
|
14
|
-
placeholder: F =
|
|
15
|
-
disabled:
|
|
16
|
-
readOnly:
|
|
17
|
-
showClear:
|
|
18
|
-
showSave:
|
|
14
|
+
placeholder: F = ee,
|
|
15
|
+
disabled: r = !1,
|
|
16
|
+
readOnly: a = !1,
|
|
17
|
+
showClear: I = !0,
|
|
18
|
+
showSave: b = !1,
|
|
19
19
|
clearText: H = "Clear",
|
|
20
20
|
saveText: K = "Save",
|
|
21
|
-
outputFormat:
|
|
22
|
-
outputQuality:
|
|
21
|
+
outputFormat: f = te,
|
|
22
|
+
outputQuality: A = ne,
|
|
23
23
|
className: W,
|
|
24
24
|
testId: X,
|
|
25
25
|
id: Y,
|
|
26
26
|
...V
|
|
27
|
-
} = U, s = J(null), [
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
j(
|
|
27
|
+
} = U, s = J(null), [D, C] = m(!1), [c, R] = m(!1), [P, E] = m(null), [g, j] = m(!1);
|
|
28
|
+
L(() => {
|
|
29
|
+
const e = () => {
|
|
30
|
+
const n = document.documentElement.classList.contains("dark");
|
|
31
|
+
j(n);
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
return
|
|
33
|
+
e();
|
|
34
|
+
const t = new MutationObserver(e);
|
|
35
|
+
return t.observe(document.documentElement, { attributes: !0, attributeFilter: ["class"] }), () => t.disconnect();
|
|
36
36
|
}, []);
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
}, [S,
|
|
44
|
-
const m = d((t) => {
|
|
37
|
+
const w = B || (g ? ae : se), _ = M || (g ? re : oe);
|
|
38
|
+
L(() => {
|
|
39
|
+
const e = s.current;
|
|
40
|
+
if (!e) return;
|
|
41
|
+
const t = e.getContext("2d");
|
|
42
|
+
t && (e.width = S, e.height = h, t.fillStyle = _, t.fillRect(0, 0, S, h));
|
|
43
|
+
}, [S, h, _, g]), L(() => {
|
|
45
44
|
const e = s.current;
|
|
46
|
-
if (!e
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
if (!e || r || a) return;
|
|
46
|
+
const t = (n) => n.preventDefault();
|
|
47
|
+
return e.addEventListener("touchstart", t, { passive: !1 }), e.addEventListener("touchmove", t, { passive: !1 }), () => {
|
|
48
|
+
e.removeEventListener("touchstart", t), e.removeEventListener("touchmove", t);
|
|
49
|
+
};
|
|
50
|
+
}, [r, a]);
|
|
51
|
+
const v = u((e) => {
|
|
52
|
+
const t = s.current;
|
|
53
|
+
if (!t) return { x: 0, y: 0 };
|
|
54
|
+
const n = t.getBoundingClientRect(), i = t.width / n.width, x = t.height / n.height;
|
|
55
|
+
if ("touches" in e) {
|
|
56
|
+
const y = e.touches[0];
|
|
50
57
|
return {
|
|
51
|
-
x: (
|
|
52
|
-
y: (
|
|
58
|
+
x: (y.clientX - n.left) * i,
|
|
59
|
+
y: (y.clientY - n.top) * x
|
|
53
60
|
};
|
|
54
61
|
}
|
|
55
62
|
return {
|
|
56
|
-
x: (
|
|
57
|
-
y: (
|
|
63
|
+
x: (e.clientX - n.left) * i,
|
|
64
|
+
y: (e.clientY - n.top) * x
|
|
58
65
|
};
|
|
59
|
-
}, []),
|
|
60
|
-
if (
|
|
61
|
-
const
|
|
62
|
-
C(!0), E(
|
|
63
|
-
}, [
|
|
64
|
-
if (!
|
|
65
|
-
const
|
|
66
|
-
if (!
|
|
67
|
-
const i =
|
|
68
|
-
|
|
69
|
-
}, [
|
|
70
|
-
if (
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
const
|
|
74
|
-
|
|
66
|
+
}, []), G = u((e) => {
|
|
67
|
+
if (r || a) return;
|
|
68
|
+
const t = v(e);
|
|
69
|
+
C(!0), E(t);
|
|
70
|
+
}, [r, a, v]), k = u((e) => {
|
|
71
|
+
if (!D || r || a) return;
|
|
72
|
+
const t = s.current, n = t == null ? void 0 : t.getContext("2d");
|
|
73
|
+
if (!t || !n || !P) return;
|
|
74
|
+
const i = v(e);
|
|
75
|
+
n.beginPath(), n.moveTo(P.x, P.y), n.lineTo(i.x, i.y), n.strokeStyle = w, n.lineWidth = N, n.lineCap = "round", n.lineJoin = "round", n.stroke(), E(i), R(!0);
|
|
76
|
+
}, [D, r, a, P, w, N, v]), T = u(() => {
|
|
77
|
+
if (D && c) {
|
|
78
|
+
const e = s.current;
|
|
79
|
+
if (e && o) {
|
|
80
|
+
const t = e.toDataURL(f, A);
|
|
81
|
+
o(t);
|
|
75
82
|
}
|
|
76
83
|
}
|
|
77
84
|
C(!1), E(null);
|
|
78
|
-
}, [
|
|
79
|
-
const
|
|
80
|
-
!
|
|
81
|
-
}, [
|
|
82
|
-
const
|
|
83
|
-
if (!
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
}, [c,
|
|
87
|
-
return /* @__PURE__ */
|
|
85
|
+
}, [D, c, o, f, A]), z = u(() => {
|
|
86
|
+
const e = s.current, t = e == null ? void 0 : e.getContext("2d");
|
|
87
|
+
!e || !t || (t.fillStyle = _ === "transparent" ? "rgba(0,0,0,0)" : _, t.clearRect(0, 0, e.width, e.height), t.fillRect(0, 0, e.width, e.height), R(!1), o == null || o(null));
|
|
88
|
+
}, [_, o]), Q = u(() => {
|
|
89
|
+
const e = s.current;
|
|
90
|
+
if (!e || !c) return;
|
|
91
|
+
const t = e.toDataURL(f, A);
|
|
92
|
+
o == null || o(t);
|
|
93
|
+
}, [c, o, f, A]);
|
|
94
|
+
return /* @__PURE__ */ p(
|
|
88
95
|
"div",
|
|
89
96
|
{
|
|
90
97
|
id: Y,
|
|
91
98
|
"data-testid": X,
|
|
92
|
-
className:
|
|
99
|
+
className: d(
|
|
93
100
|
"Bear-SignPad bear-max-w-full bear-w-full",
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
101
|
+
Se,
|
|
102
|
+
r && "Bear-SignPad--disabled bear-opacity-50",
|
|
103
|
+
a && "Bear-SignPad--readonly",
|
|
97
104
|
W
|
|
98
105
|
),
|
|
99
106
|
...V,
|
|
100
107
|
children: [
|
|
101
|
-
/* @__PURE__ */
|
|
108
|
+
/* @__PURE__ */ p(
|
|
102
109
|
"div",
|
|
103
110
|
{
|
|
104
|
-
className:
|
|
111
|
+
className: d(
|
|
105
112
|
"Bear-SignPad__canvas-wrapper bear-max-w-full bear-overflow-hidden",
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
a &&
|
|
109
|
-
|
|
113
|
+
"touch-none",
|
|
114
|
+
de,
|
|
115
|
+
!r && !a && ue,
|
|
116
|
+
r && "bear-cursor-not-allowed",
|
|
117
|
+
!r && !a && "bear-cursor-crosshair"
|
|
110
118
|
),
|
|
111
119
|
children: [
|
|
112
120
|
/* @__PURE__ */ l(
|
|
113
121
|
"canvas",
|
|
114
122
|
{
|
|
115
123
|
ref: s,
|
|
116
|
-
className: "Bear-SignPad__canvas bear-block bear-rounded-lg bear-max-w-full",
|
|
117
|
-
style: { width: S, height:
|
|
118
|
-
onMouseDown:
|
|
119
|
-
onMouseMove:
|
|
124
|
+
className: "Bear-SignPad__canvas bear-block bear-rounded-lg bear-max-w-full touch-none",
|
|
125
|
+
style: { width: S, height: h, touchAction: "none" },
|
|
126
|
+
onMouseDown: G,
|
|
127
|
+
onMouseMove: k,
|
|
120
128
|
onMouseUp: T,
|
|
121
129
|
onMouseLeave: T,
|
|
122
|
-
onTouchStart:
|
|
123
|
-
onTouchMove:
|
|
130
|
+
onTouchStart: G,
|
|
131
|
+
onTouchMove: k,
|
|
124
132
|
onTouchEnd: T
|
|
125
133
|
}
|
|
126
134
|
),
|
|
127
|
-
!c && /* @__PURE__ */ l("div", { className:
|
|
128
|
-
/* @__PURE__ */ l("div", { className:
|
|
129
|
-
/* @__PURE__ */ l("span", { className:
|
|
135
|
+
!c && /* @__PURE__ */ l("div", { className: d("Bear-SignPad__placeholder", ce), children: F }),
|
|
136
|
+
/* @__PURE__ */ l("div", { className: d("Bear-SignPad__line", ie) }),
|
|
137
|
+
/* @__PURE__ */ l("span", { className: d("Bear-SignPad__x-mark", le), children: "×" })
|
|
130
138
|
]
|
|
131
139
|
}
|
|
132
140
|
),
|
|
133
|
-
(
|
|
134
|
-
|
|
141
|
+
(I || b) && /* @__PURE__ */ p("div", { className: d("Bear-SignPad__actions", _e), children: [
|
|
142
|
+
I && /* @__PURE__ */ l(
|
|
135
143
|
O,
|
|
136
144
|
{
|
|
137
145
|
size: "sm",
|
|
138
146
|
variant: "ghost",
|
|
139
147
|
onClick: z,
|
|
140
|
-
disabled:
|
|
148
|
+
disabled: r || !c,
|
|
141
149
|
children: H
|
|
142
150
|
}
|
|
143
151
|
),
|
|
144
|
-
|
|
152
|
+
b && /* @__PURE__ */ l(
|
|
145
153
|
O,
|
|
146
154
|
{
|
|
147
155
|
size: "sm",
|
|
148
156
|
variant: "primary",
|
|
149
157
|
onClick: Q,
|
|
150
|
-
disabled:
|
|
158
|
+
disabled: r || !c,
|
|
151
159
|
children: K
|
|
152
160
|
}
|
|
153
161
|
)
|
|
@@ -157,5 +165,5 @@ const mt = (U) => {
|
|
|
157
165
|
);
|
|
158
166
|
};
|
|
159
167
|
export {
|
|
160
|
-
|
|
168
|
+
ve as SignPad
|
|
161
169
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),u=require("react"),d=require("../../utils/cn.cjs"),X={xs:{track:"bear-h-1",thumb:"bear-w-3 bear-h-3",height:"bear-h-6"},sm:{track:"bear-h-1.5",thumb:"bear-w-4 bear-h-4",height:"bear-h-8"},md:{track:"bear-h-2",thumb:"bear-w-5 bear-h-5",height:"bear-h-10"},lg:{track:"bear-h-2.5",thumb:"bear-w-6 bear-h-6",height:"bear-h-12"},xl:{track:"bear-h-3",thumb:"bear-w-7 bear-h-7",height:"bear-h-14"}},Y={primary:{track:"bear-bg-bear-500",thumb:"bear-bg-bear-500 bear-border-bear-600"},secondary:{track:"bear-bg-gray-500",thumb:"bear-bg-gray-500 bear-border-gray-600"},success:{track:"bear-bg-green-500",thumb:"bear-bg-green-500 bear-border-green-600"},warning:{track:"bear-bg-amber-500",thumb:"bear-bg-amber-500 bear-border-amber-600"},error:{track:"bear-bg-red-500",thumb:"bear-bg-red-500 bear-border-red-600"},danger:{track:"bear-bg-red-500",thumb:"bear-bg-red-500 bear-border-red-600"},info:{track:"bear-bg-blue-500",thumb:"bear-bg-blue-500 bear-border-blue-600"},ghost:{track:"bear-bg-gray-400",thumb:"bear-bg-gray-400 bear-border-gray-500"},outline:{track:"bear-bg-gray-600",thumb:"bear-bg-white dark:bear-bg-gray-200 bear-border-gray-600 dark:bear-border-gray-400"}},_=(c,f,e,r)=>{const l=Math.round(c/r)*r;return Math.max(f,Math.min(e,l))},A=({value:c,defaultValue:f=[20,80],min:e=0,max:r=100,step:l=1,size:$="md",color:q="primary",disabled:b=!1,onChange:s,onChangeCommitted:g,valueFormatter:B=w=>String(w),className:z,...O})=>{const[w,L]=u.useState(f),[t,E]=u.useState(null),y=u.useRef(null),k=c??w,[n,o]=k,x=(n-e)/(r-e)*100,j=(o-e)/(r-e)*100,m=X[$],M=Y[q],S=u.useCallback((a,v)=>{if(!y.current||b)return;const T=y.current.getBoundingClientRect(),P=Math.max(0,Math.min(1,(a-T.left)/T.width)),V=e+P*(r-e),D=_(V,e,r,l);if(v==="min"){const i=[Math.min(D,o-l),o];c===void 0&&L(i),s==null||s(i)}else{const I=Math.max(D,n+l),i=[n,I];c===void 0&&L(i),s==null||s(i)}},[e,r,l,n,o,b,c,s]),N=(a,v)=>{b||(a.preventDefault(),E(v),S(a.clientX,v))},p=u.useCallback(a=>{t&&S(a.clientX,t)},[t,S]),R=u.useCallback(()=>{t&&(E(null),g==null||g(k))},[t,k,g]);return u.useEffect(()=>{if(t)return document.addEventListener("mousemove",p),document.addEventListener("mouseup",R),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",R)}},[t,p,R]),h.jsx("div",{className:d.cn("bear-relative bear-w-full bear-flex bear-items-center",m.height,b&&"bear-opacity-50 bear-cursor-not-allowed",z),"data-testid":"slider-range",...O,children:h.jsxs("div",{ref:y,className:d.cn("bear-relative bear-w-full bear-rounded-full bear-bg-gray-200 dark:bear-bg-gray-700",m.track,!b&&"bear-cursor-pointer"),children:[h.jsx("div",{className:d.cn("bear-absolute bear-inset-y-0 bear-left-0 bear-rounded-full",M.track),style:{left:`${x}%`,width:`${j-x}%`}}),h.jsx("div",{role:"slider",tabIndex:b?-1:0,"aria-valuemin":e,"aria-valuemax":r,"aria-valuenow":n,"aria-label":"Range minimum",className:d.cn("bear-absolute bear-top-1/2 bear--translate-y-1/2 bear--translate-x-1/2 bear-rounded-full bear-border-2 bear-shadow-md",m.thumb,M.thumb,!b&&"bear-cursor-grab active:bear-cursor-grabbing hover:bear-scale-110",t==="min"&&"bear-scale-125 bear-z-10"),style:{left:`${x}%`},onMouseDown:a=>N(a,"min")}),h.jsx("div",{role:"slider",tabIndex:b?-1:0,"aria-valuemin":e,"aria-valuemax":r,"aria-valuenow":o,"aria-label":"Range maximum",className:d.cn("bear-absolute bear-top-1/2 bear--translate-y-1/2 bear--translate-x-1/2 bear-rounded-full bear-border-2 bear-shadow-md",m.thumb,M.thumb,!b&&"bear-cursor-grab active:bear-cursor-grabbing hover:bear-scale-110",t==="max"&&"bear-scale-125 bear-z-10"),style:{left:`${j}%`},onMouseDown:a=>N(a,"max")})]})})};exports.SliderRange=A;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
2
|
+
import { useState as z, useRef as A, useCallback as L, useEffect as B } from "react";
|
|
3
|
+
import { cn as i } from "../../utils/cn.js";
|
|
4
|
+
const F = {
|
|
5
|
+
xs: { track: "bear-h-1", thumb: "bear-w-3 bear-h-3", height: "bear-h-6" },
|
|
6
|
+
sm: { track: "bear-h-1.5", thumb: "bear-w-4 bear-h-4", height: "bear-h-8" },
|
|
7
|
+
md: { track: "bear-h-2", thumb: "bear-w-5 bear-h-5", height: "bear-h-10" },
|
|
8
|
+
lg: { track: "bear-h-2.5", thumb: "bear-w-6 bear-h-6", height: "bear-h-12" },
|
|
9
|
+
xl: { track: "bear-h-3", thumb: "bear-w-7 bear-h-7", height: "bear-h-14" }
|
|
10
|
+
}, H = {
|
|
11
|
+
primary: { track: "bear-bg-bear-500", thumb: "bear-bg-bear-500 bear-border-bear-600" },
|
|
12
|
+
secondary: { track: "bear-bg-gray-500", thumb: "bear-bg-gray-500 bear-border-gray-600" },
|
|
13
|
+
success: { track: "bear-bg-green-500", thumb: "bear-bg-green-500 bear-border-green-600" },
|
|
14
|
+
warning: { track: "bear-bg-amber-500", thumb: "bear-bg-amber-500 bear-border-amber-600" },
|
|
15
|
+
error: { track: "bear-bg-red-500", thumb: "bear-bg-red-500 bear-border-red-600" },
|
|
16
|
+
danger: { track: "bear-bg-red-500", thumb: "bear-bg-red-500 bear-border-red-600" },
|
|
17
|
+
info: { track: "bear-bg-blue-500", thumb: "bear-bg-blue-500 bear-border-blue-600" },
|
|
18
|
+
ghost: { track: "bear-bg-gray-400", thumb: "bear-bg-gray-400 bear-border-gray-500" },
|
|
19
|
+
outline: { track: "bear-bg-gray-600", thumb: "bear-bg-white dark:bear-bg-gray-200 bear-border-gray-600 dark:bear-border-gray-400" }
|
|
20
|
+
}, U = (s, v, e, r) => {
|
|
21
|
+
const o = Math.round(s / r) * r;
|
|
22
|
+
return Math.max(v, Math.min(e, o));
|
|
23
|
+
}, K = ({
|
|
24
|
+
value: s,
|
|
25
|
+
defaultValue: v = [20, 80],
|
|
26
|
+
min: e = 0,
|
|
27
|
+
max: r = 100,
|
|
28
|
+
step: o = 1,
|
|
29
|
+
size: j = "md",
|
|
30
|
+
color: O = "primary",
|
|
31
|
+
disabled: b = !1,
|
|
32
|
+
onChange: u,
|
|
33
|
+
onChangeCommitted: h,
|
|
34
|
+
valueFormatter: Z = (f) => String(f),
|
|
35
|
+
className: P,
|
|
36
|
+
...V
|
|
37
|
+
}) => {
|
|
38
|
+
const [f, E] = z(v), [t, R] = z(null), w = A(null), y = s ?? f, [c, l] = y, k = (c - e) / (r - e) * 100, N = (l - e) / (r - e) * 100, m = F[j], p = H[O], x = L(
|
|
39
|
+
(a, d) => {
|
|
40
|
+
if (!w.current || b) return;
|
|
41
|
+
const I = w.current.getBoundingClientRect(), X = Math.max(0, Math.min(1, (a - I.left) / I.width)), Y = e + X * (r - e), T = U(Y, e, r, o);
|
|
42
|
+
if (d === "min") {
|
|
43
|
+
const n = [Math.min(T, l - o), l];
|
|
44
|
+
s === void 0 && E(n), u == null || u(n);
|
|
45
|
+
} else {
|
|
46
|
+
const $ = Math.max(T, c + o), n = [c, $];
|
|
47
|
+
s === void 0 && E(n), u == null || u(n);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
[e, r, o, c, l, b, s, u]
|
|
51
|
+
), D = (a, d) => {
|
|
52
|
+
b || (a.preventDefault(), R(d), x(a.clientX, d));
|
|
53
|
+
}, M = L(
|
|
54
|
+
(a) => {
|
|
55
|
+
t && x(a.clientX, t);
|
|
56
|
+
},
|
|
57
|
+
[t, x]
|
|
58
|
+
), S = L(() => {
|
|
59
|
+
t && (R(null), h == null || h(y));
|
|
60
|
+
}, [t, y, h]);
|
|
61
|
+
return B(() => {
|
|
62
|
+
if (t)
|
|
63
|
+
return document.addEventListener("mousemove", M), document.addEventListener("mouseup", S), () => {
|
|
64
|
+
document.removeEventListener("mousemove", M), document.removeEventListener("mouseup", S);
|
|
65
|
+
};
|
|
66
|
+
}, [t, M, S]), /* @__PURE__ */ g(
|
|
67
|
+
"div",
|
|
68
|
+
{
|
|
69
|
+
className: i(
|
|
70
|
+
"bear-relative bear-w-full bear-flex bear-items-center",
|
|
71
|
+
m.height,
|
|
72
|
+
b && "bear-opacity-50 bear-cursor-not-allowed",
|
|
73
|
+
P
|
|
74
|
+
),
|
|
75
|
+
"data-testid": "slider-range",
|
|
76
|
+
...V,
|
|
77
|
+
children: /* @__PURE__ */ _(
|
|
78
|
+
"div",
|
|
79
|
+
{
|
|
80
|
+
ref: w,
|
|
81
|
+
className: i(
|
|
82
|
+
"bear-relative bear-w-full bear-rounded-full bear-bg-gray-200 dark:bear-bg-gray-700",
|
|
83
|
+
m.track,
|
|
84
|
+
!b && "bear-cursor-pointer"
|
|
85
|
+
),
|
|
86
|
+
children: [
|
|
87
|
+
/* @__PURE__ */ g(
|
|
88
|
+
"div",
|
|
89
|
+
{
|
|
90
|
+
className: i("bear-absolute bear-inset-y-0 bear-left-0 bear-rounded-full", p.track),
|
|
91
|
+
style: { left: `${k}%`, width: `${N - k}%` }
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
/* @__PURE__ */ g(
|
|
95
|
+
"div",
|
|
96
|
+
{
|
|
97
|
+
role: "slider",
|
|
98
|
+
tabIndex: b ? -1 : 0,
|
|
99
|
+
"aria-valuemin": e,
|
|
100
|
+
"aria-valuemax": r,
|
|
101
|
+
"aria-valuenow": c,
|
|
102
|
+
"aria-label": "Range minimum",
|
|
103
|
+
className: i(
|
|
104
|
+
"bear-absolute bear-top-1/2 bear--translate-y-1/2 bear--translate-x-1/2 bear-rounded-full bear-border-2 bear-shadow-md",
|
|
105
|
+
m.thumb,
|
|
106
|
+
p.thumb,
|
|
107
|
+
!b && "bear-cursor-grab active:bear-cursor-grabbing hover:bear-scale-110",
|
|
108
|
+
t === "min" && "bear-scale-125 bear-z-10"
|
|
109
|
+
),
|
|
110
|
+
style: { left: `${k}%` },
|
|
111
|
+
onMouseDown: (a) => D(a, "min")
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
/* @__PURE__ */ g(
|
|
115
|
+
"div",
|
|
116
|
+
{
|
|
117
|
+
role: "slider",
|
|
118
|
+
tabIndex: b ? -1 : 0,
|
|
119
|
+
"aria-valuemin": e,
|
|
120
|
+
"aria-valuemax": r,
|
|
121
|
+
"aria-valuenow": l,
|
|
122
|
+
"aria-label": "Range maximum",
|
|
123
|
+
className: i(
|
|
124
|
+
"bear-absolute bear-top-1/2 bear--translate-y-1/2 bear--translate-x-1/2 bear-rounded-full bear-border-2 bear-shadow-md",
|
|
125
|
+
m.thumb,
|
|
126
|
+
p.thumb,
|
|
127
|
+
!b && "bear-cursor-grab active:bear-cursor-grabbing hover:bear-scale-110",
|
|
128
|
+
t === "max" && "bear-scale-125 bear-z-10"
|
|
129
|
+
),
|
|
130
|
+
style: { left: `${N}%` },
|
|
131
|
+
onMouseDown: (a) => D(a, "max")
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
export {
|
|
141
|
+
K as SliderRange
|
|
142
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
import { BearSize, BearVariant } from '../../types';
|
|
3
|
+
export type SliderRangeValue = [number, number];
|
|
4
|
+
export interface SliderRangeProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {
|
|
5
|
+
value?: SliderRangeValue;
|
|
6
|
+
defaultValue?: SliderRangeValue;
|
|
7
|
+
min?: number;
|
|
8
|
+
max?: number;
|
|
9
|
+
step?: number;
|
|
10
|
+
size?: BearSize;
|
|
11
|
+
color?: BearVariant;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
onChange?: (value: SliderRangeValue) => void;
|
|
14
|
+
onChangeCommitted?: (value: SliderRangeValue) => void;
|
|
15
|
+
valueFormatter?: (value: number) => string;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BearSize } from '../../types';
|
|
2
2
|
export interface SpinnerProps {
|
|
3
3
|
/** Spinner size */
|
|
4
|
-
size?:
|
|
4
|
+
size?: BearSize;
|
|
5
5
|
/** Additional class names */
|
|
6
6
|
className?: string;
|
|
7
7
|
/** Spinner color (CSS color value) */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),b=require("react"),M=require("../../utils/cn.cjs"),$=require("../Chip/Chip.cjs"),O={sm:"bear-h-8 bear-text-sm bear-gap-1.5 bear-px-2",md:"bear-h-10 bear-text-base bear-gap-2 bear-px-3",lg:"bear-h-12 bear-text-lg bear-gap-2.5 bear-px-4"},P={sm:"sm",md:"md",lg:"lg"},_=({value:c,defaultValue:z=[],onChange:a,onAdd:u,onRemove:p,placeholder:I="Add tags...",disabled:o=!1,maxTags:n,minLength:y=1,maxLength:d,separators:k=[",","Enter"],size:m="md",fullWidth:S=!1,className:q})=>{const[B,w]=b.useState(z),[l,f]=b.useState(""),v=b.useRef(null),t=c??B,D=!n||t.length<n,g=b.useCallback(e=>{const r=e.trim().slice(0,d??e.length);if(!r||r.length<y||t.includes(r)||n!=null&&t.length>=n)return;const s=[...t,r];c===void 0&&w(s),a==null||a(s),u==null||u(r)},[t,c,y,d,n,a,u]),j=b.useCallback((e,r)=>{const s=t.filter((h,i)=>i!==r);c===void 0&&w(s),a==null||a(s),p==null||p(e,r)},[t,c,a,p]),T=e=>{k.includes(e.key)?(e.preventDefault(),l.trim()&&(g(l),f(""))):e.key==="Backspace"&&!l&&t.length&&j(t[t.length-1],t.length-1)},N=e=>{var h;const r=e.target.value,s=k.find(i=>r.includes(i));if(s){const i=r.split(s);i.slice(0,-1).forEach(K=>g(K)),f(((h=i[i.length-1])==null?void 0:h.trim())??"")}else f(r)},E=()=>{l.trim()&&(g(l),f(""))};return x.jsxs("div",{className:M.cn("Bear-TagsInput bear-flex bear-flex-wrap bear-items-center bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-900 bear-transition-colors focus-within:bear-border-bear-500 focus-within:bear-ring-2 focus-within:bear-ring-bear-500/20",o&&"bear-opacity-50 bear-cursor-not-allowed",S&&"bear-w-full",O[m],q),onClick:()=>{var e;return(e=v.current)==null?void 0:e.focus()},children:[t.map((e,r)=>x.jsx($.Chip,{variant:"soft",color:"primary",size:P[m],onDelete:o?void 0:()=>j(e,r),className:"bear-shrink-0",children:e},`${e}-${r}`)),D&&x.jsx("input",{ref:v,type:"text",value:l,onChange:N,onKeyDown:T,onBlur:E,placeholder:t.length?"":I,disabled:o,maxLength:d,className:"bear-min-w-[80px] bear-flex-1 bear-bg-transparent bear-outline-none bear-text-gray-900 dark:bear-text-white placeholder:bear-text-gray-500 dark:placeholder:bear-text-zinc-500"})]})};exports.TagsInput=_;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { jsxs as _, jsx as v } from "react/jsx-runtime";
|
|
2
|
+
import { useState as z, useRef as q, useCallback as B } from "react";
|
|
3
|
+
import { cn as F } from "../../utils/cn.js";
|
|
4
|
+
import { Chip as G } from "../Chip/Chip.js";
|
|
5
|
+
const H = {
|
|
6
|
+
sm: "bear-h-8 bear-text-sm bear-gap-1.5 bear-px-2",
|
|
7
|
+
md: "bear-h-10 bear-text-base bear-gap-2 bear-px-3",
|
|
8
|
+
lg: "bear-h-12 bear-text-lg bear-gap-2.5 bear-px-4"
|
|
9
|
+
}, J = { sm: "sm", md: "md", lg: "lg" }, W = ({
|
|
10
|
+
value: c,
|
|
11
|
+
defaultValue: D = [],
|
|
12
|
+
onChange: a,
|
|
13
|
+
onAdd: b,
|
|
14
|
+
onRemove: p,
|
|
15
|
+
placeholder: I = "Add tags...",
|
|
16
|
+
disabled: u = !1,
|
|
17
|
+
maxTags: n,
|
|
18
|
+
minLength: h = 1,
|
|
19
|
+
maxLength: o,
|
|
20
|
+
separators: m = [",", "Enter"],
|
|
21
|
+
size: x = "md",
|
|
22
|
+
fullWidth: N = !1,
|
|
23
|
+
className: j
|
|
24
|
+
}) => {
|
|
25
|
+
const [E, k] = z(D), [l, f] = z(""), w = q(null), t = c ?? E, K = !n || t.length < n, d = B(
|
|
26
|
+
(e) => {
|
|
27
|
+
const r = e.trim().slice(0, o ?? e.length);
|
|
28
|
+
if (!r || r.length < h || t.includes(r) || n != null && t.length >= n) return;
|
|
29
|
+
const s = [...t, r];
|
|
30
|
+
c === void 0 && k(s), a == null || a(s), b == null || b(r);
|
|
31
|
+
},
|
|
32
|
+
[t, c, h, o, n, a, b]
|
|
33
|
+
), y = B(
|
|
34
|
+
(e, r) => {
|
|
35
|
+
const s = t.filter((g, i) => i !== r);
|
|
36
|
+
c === void 0 && k(s), a == null || a(s), p == null || p(e, r);
|
|
37
|
+
},
|
|
38
|
+
[t, c, a, p]
|
|
39
|
+
), S = (e) => {
|
|
40
|
+
m.includes(e.key) ? (e.preventDefault(), l.trim() && (d(l), f(""))) : e.key === "Backspace" && !l && t.length && y(t[t.length - 1], t.length - 1);
|
|
41
|
+
}, T = (e) => {
|
|
42
|
+
var g;
|
|
43
|
+
const r = e.target.value, s = m.find((i) => r.includes(i));
|
|
44
|
+
if (s) {
|
|
45
|
+
const i = r.split(s);
|
|
46
|
+
i.slice(0, -1).forEach((M) => d(M)), f(((g = i[i.length - 1]) == null ? void 0 : g.trim()) ?? "");
|
|
47
|
+
} else
|
|
48
|
+
f(r);
|
|
49
|
+
}, $ = () => {
|
|
50
|
+
l.trim() && (d(l), f(""));
|
|
51
|
+
};
|
|
52
|
+
return /* @__PURE__ */ _(
|
|
53
|
+
"div",
|
|
54
|
+
{
|
|
55
|
+
className: F(
|
|
56
|
+
"Bear-TagsInput bear-flex bear-flex-wrap bear-items-center bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-900 bear-transition-colors focus-within:bear-border-bear-500 focus-within:bear-ring-2 focus-within:bear-ring-bear-500/20",
|
|
57
|
+
u && "bear-opacity-50 bear-cursor-not-allowed",
|
|
58
|
+
N && "bear-w-full",
|
|
59
|
+
H[x],
|
|
60
|
+
j
|
|
61
|
+
),
|
|
62
|
+
onClick: () => {
|
|
63
|
+
var e;
|
|
64
|
+
return (e = w.current) == null ? void 0 : e.focus();
|
|
65
|
+
},
|
|
66
|
+
children: [
|
|
67
|
+
t.map((e, r) => /* @__PURE__ */ v(
|
|
68
|
+
G,
|
|
69
|
+
{
|
|
70
|
+
variant: "soft",
|
|
71
|
+
color: "primary",
|
|
72
|
+
size: J[x],
|
|
73
|
+
onDelete: u ? void 0 : () => y(e, r),
|
|
74
|
+
className: "bear-shrink-0",
|
|
75
|
+
children: e
|
|
76
|
+
},
|
|
77
|
+
`${e}-${r}`
|
|
78
|
+
)),
|
|
79
|
+
K && /* @__PURE__ */ v(
|
|
80
|
+
"input",
|
|
81
|
+
{
|
|
82
|
+
ref: w,
|
|
83
|
+
type: "text",
|
|
84
|
+
value: l,
|
|
85
|
+
onChange: T,
|
|
86
|
+
onKeyDown: S,
|
|
87
|
+
onBlur: $,
|
|
88
|
+
placeholder: t.length ? "" : I,
|
|
89
|
+
disabled: u,
|
|
90
|
+
maxLength: o,
|
|
91
|
+
className: "bear-min-w-[80px] bear-flex-1 bear-bg-transparent bear-outline-none bear-text-gray-900 dark:bear-text-white placeholder:bear-text-gray-500 dark:placeholder:bear-text-zinc-500"
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
export {
|
|
99
|
+
W as TagsInput
|
|
100
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface TagsInputProps {
|
|
2
|
+
value?: string[];
|
|
3
|
+
defaultValue?: string[];
|
|
4
|
+
onChange?: (tags: string[]) => void;
|
|
5
|
+
onAdd?: (tag: string) => void;
|
|
6
|
+
onRemove?: (tag: string, index: number) => void;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
maxTags?: number;
|
|
10
|
+
minLength?: number;
|
|
11
|
+
maxLength?: number;
|
|
12
|
+
separators?: string[];
|
|
13
|
+
size?: 'sm' | 'md' | 'lg';
|
|
14
|
+
fullWidth?: boolean;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),K=require("../../utils/cn.cjs"),P=require("../Typography/Typography.cjs"),B=require("../Spinner/Spinner.cjs"),l=require("./Terminal.const.cjs"),O=({lines:m,onCommand:u,cwd:E=l.TERMINAL_DEFAULTS.CWD,user:S=l.TERMINAL_DEFAULTS.USER,host:w=l.TERMINAL_DEFAULTS.HOST,prompt:h,title:I=l.TERMINAL_DEFAULTS.TITLE,showHeader:y=!0,showLineNumbers:L=!1,showTimestamps:R=!1,readOnly:x=!1,height:f=l.TERMINAL_DEFAULTS.HEIGHT,theme:k="dark",history:A,onHistoryChange:C,autoScroll:g=!0,className:D,testId:M,isLoading:j=!1})=>{const a=l.TERMINAL_THEMES[k],[o,c]=n.useState(""),[i,p]=n.useState(-1),[_,H]=n.useState([]),r=A??_,N=C??H,T=n.useRef(null),d=n.useRef(null);n.useEffect(()=>{g&&d.current&&(d.current.scrollTop=d.current.scrollHeight)},[m,g]);const U=n.useCallback(()=>{var s;x||(s=T.current)==null||s.focus()},[x]),b=n.useCallback(()=>{o.trim()&&u&&(u(o.trim()),N([...r,o.trim()]),p(-1),c(""))},[o,u,r,N]),q=n.useCallback(s=>{if(s.key==="Enter")b();else if(s.key==="ArrowUp"){if(s.preventDefault(),r.length>0){const t=i===-1?r.length-1:Math.max(0,i-1);p(t),c(r[t])}}else if(s.key==="ArrowDown"){if(s.preventDefault(),i!==-1){const t=i+1;t>=r.length?(p(-1),c("")):(p(t),c(r[t]))}}else s.key==="c"&&s.ctrlKey&&(c(""),p(-1))},[b,r,i]),v=()=>h||e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{color:a.prompt},children:[S,"@",w]}),e.jsx("span",{className:"opacity-50",children:":"}),e.jsx("span",{className:"text-blue-400",children:E}),e.jsx("span",{className:"opacity-50",children:"$"})]}),F=(s,t)=>{const $=l.LINE_TYPE_COLORS[s.type];return e.jsxs("div",{className:"flex gap-2 py-0.5 hover:bg-white/5",children:[L&&e.jsx("span",{className:"opacity-30 w-8 text-right select-none",children:t+1}),R&&s.timestamp&&e.jsxs("span",{className:"opacity-30 select-none",children:["[",s.timestamp.toLocaleTimeString(),"]"]}),s.type==="input"?e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"flex gap-1 select-none",children:s.prefix||v()}),e.jsx("span",{children:s.content})]}):e.jsx("span",{style:{color:$},children:s.content})]},s.id)};return e.jsxs("div",{className:K.cn("Bear-Terminal","rounded-lg overflow-hidden font-mono text-sm",D),style:{backgroundColor:a.bg,color:a.text,border:`1px solid ${a.border}`,height:typeof f=="number"?`${f}px`:f},"data-testid":M,onClick:U,children:[y&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2",style:{backgroundColor:a.header,borderBottom:`1px solid ${a.border}`},children:[e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"}),e.jsx("div",{className:"w-3 h-3 rounded-full bg-yellow-500"}),e.jsx("div",{className:"w-3 h-3 rounded-full bg-green-500"})]}),e.jsx(P.Typography,{variant:"caption",className:"flex-1 text-center opacity-60",children:I}),e.jsx("div",{className:"w-14"})," "]}),e.jsxs("div",{ref:d,className:"overflow-y-auto p-4",style:{height:y?"calc(100% - 40px)":"100%"},children:[m.map((s,t)=>F(s,t)),j&&e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx(B.Spinner,{size:"sm"}),e.jsx("span",{className:"opacity-50",children:"Processing..."})]}),!x&&e.jsxs("div",{className:"flex gap-2 py-0.5",children:[e.jsx("span",{className:"flex gap-1 select-none",children:v()}),e.jsx("input",{ref:T,type:"text",value:o,onChange:s=>c(s.target.value),onKeyDown:q,className:"flex-1 bg-transparent outline-none caret-current",style:{color:"inherit"},autoComplete:"off",spellCheck:!1,disabled:j})]})]})]})};exports.Terminal=O;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={HEIGHT:400,USER:"user",HOST:"localhost",CWD:"~",TITLE:"Terminal"},a={input:"inherit",output:"inherit",error:"#ef4444",success:"#22c55e",warning:"#f59e0b",info:"#3b82f6",system:"#a855f7"},t={dark:{bg:"#1a1a2e",text:"#eaeaea",prompt:"#22c55e",border:"#2d2d44",header:"#16162a"},light:{bg:"#fafafa",text:"#1a1a2e",prompt:"#16a34a",border:"#e5e5e5",header:"#f0f0f0"},matrix:{bg:"#0d0d0d",text:"#00ff00",prompt:"#00ff00",border:"#003300",header:"#0a0a0a"}};exports.LINE_TYPE_COLORS=a;exports.TERMINAL_DEFAULTS=e;exports.TERMINAL_THEMES=t;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TerminalLineType } from './Terminal.types';
|
|
2
|
+
export declare const TERMINAL_DEFAULTS: {
|
|
3
|
+
readonly HEIGHT: 400;
|
|
4
|
+
readonly USER: "user";
|
|
5
|
+
readonly HOST: "localhost";
|
|
6
|
+
readonly CWD: "~";
|
|
7
|
+
readonly TITLE: "Terminal";
|
|
8
|
+
};
|
|
9
|
+
export declare const LINE_TYPE_COLORS: Record<TerminalLineType, string>;
|
|
10
|
+
export declare const TERMINAL_THEMES: {
|
|
11
|
+
readonly dark: {
|
|
12
|
+
readonly bg: "#1a1a2e";
|
|
13
|
+
readonly text: "#eaeaea";
|
|
14
|
+
readonly prompt: "#22c55e";
|
|
15
|
+
readonly border: "#2d2d44";
|
|
16
|
+
readonly header: "#16162a";
|
|
17
|
+
};
|
|
18
|
+
readonly light: {
|
|
19
|
+
readonly bg: "#fafafa";
|
|
20
|
+
readonly text: "#1a1a2e";
|
|
21
|
+
readonly prompt: "#16a34a";
|
|
22
|
+
readonly border: "#e5e5e5";
|
|
23
|
+
readonly header: "#f0f0f0";
|
|
24
|
+
};
|
|
25
|
+
readonly matrix: {
|
|
26
|
+
readonly bg: "#0d0d0d";
|
|
27
|
+
readonly text: "#00ff00";
|
|
28
|
+
readonly prompt: "#00ff00";
|
|
29
|
+
readonly border: "#003300";
|
|
30
|
+
readonly header: "#0a0a0a";
|
|
31
|
+
};
|
|
32
|
+
};
|