@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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
HEIGHT: 400,
|
|
3
|
+
USER: "user",
|
|
4
|
+
HOST: "localhost",
|
|
5
|
+
CWD: "~",
|
|
6
|
+
TITLE: "Terminal"
|
|
7
|
+
}, a = {
|
|
8
|
+
input: "inherit",
|
|
9
|
+
output: "inherit",
|
|
10
|
+
error: "#ef4444",
|
|
11
|
+
success: "#22c55e",
|
|
12
|
+
warning: "#f59e0b",
|
|
13
|
+
info: "#3b82f6",
|
|
14
|
+
system: "#a855f7"
|
|
15
|
+
}, r = {
|
|
16
|
+
dark: {
|
|
17
|
+
bg: "#1a1a2e",
|
|
18
|
+
text: "#eaeaea",
|
|
19
|
+
prompt: "#22c55e",
|
|
20
|
+
border: "#2d2d44",
|
|
21
|
+
header: "#16162a"
|
|
22
|
+
},
|
|
23
|
+
light: {
|
|
24
|
+
bg: "#fafafa",
|
|
25
|
+
text: "#1a1a2e",
|
|
26
|
+
prompt: "#16a34a",
|
|
27
|
+
border: "#e5e5e5",
|
|
28
|
+
header: "#f0f0f0"
|
|
29
|
+
},
|
|
30
|
+
matrix: {
|
|
31
|
+
bg: "#0d0d0d",
|
|
32
|
+
text: "#00ff00",
|
|
33
|
+
prompt: "#00ff00",
|
|
34
|
+
border: "#003300",
|
|
35
|
+
header: "#0a0a0a"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
a as LINE_TYPE_COLORS,
|
|
40
|
+
e as TERMINAL_DEFAULTS,
|
|
41
|
+
r as TERMINAL_THEMES
|
|
42
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { TerminalProps } from './Terminal.types';
|
|
3
|
+
/**
|
|
4
|
+
* Terminal - Console/terminal emulator component
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* const [lines, setLines] = useState<TerminalLine[]>([
|
|
9
|
+
* { id: '1', type: 'output', content: 'Welcome to Bear Terminal!' },
|
|
10
|
+
* ]);
|
|
11
|
+
*
|
|
12
|
+
* <Terminal
|
|
13
|
+
* lines={lines}
|
|
14
|
+
* onCommand={(cmd) => {
|
|
15
|
+
* setLines([
|
|
16
|
+
* ...lines,
|
|
17
|
+
* { id: Date.now().toString(), type: 'input', content: cmd },
|
|
18
|
+
* { id: (Date.now() + 1).toString(), type: 'output', content: `Executed: ${cmd}` },
|
|
19
|
+
* ]);
|
|
20
|
+
* }}
|
|
21
|
+
* user="bear"
|
|
22
|
+
* host="forge"
|
|
23
|
+
* />
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare const Terminal: FC<TerminalProps>;
|
|
27
|
+
export default Terminal;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { jsxs as r, jsx as t, Fragment as z } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u, useRef as I, useEffect as G, useCallback as y } from "react";
|
|
3
|
+
import { cn as O } from "../../utils/cn.js";
|
|
4
|
+
import { Typography as W } from "../Typography/Typography.js";
|
|
5
|
+
import { Spinner as Y } from "../Spinner/Spinner.js";
|
|
6
|
+
import { TERMINAL_DEFAULTS as p, TERMINAL_THEMES as q, LINE_TYPE_COLORS as J } from "./Terminal.const.js";
|
|
7
|
+
const se = ({
|
|
8
|
+
lines: x,
|
|
9
|
+
onCommand: m,
|
|
10
|
+
cwd: C = p.CWD,
|
|
11
|
+
user: H = p.USER,
|
|
12
|
+
host: S = p.HOST,
|
|
13
|
+
prompt: g,
|
|
14
|
+
title: D = p.TITLE,
|
|
15
|
+
showHeader: N = !0,
|
|
16
|
+
showLineNumbers: L = !1,
|
|
17
|
+
showTimestamps: R = !1,
|
|
18
|
+
readOnly: f = !1,
|
|
19
|
+
height: h = p.HEIGHT,
|
|
20
|
+
theme: A = "dark",
|
|
21
|
+
history: M,
|
|
22
|
+
onHistoryChange: _,
|
|
23
|
+
autoScroll: v = !0,
|
|
24
|
+
className: $,
|
|
25
|
+
testId: K,
|
|
26
|
+
isLoading: b = !1
|
|
27
|
+
}) => {
|
|
28
|
+
const l = q[A], [o, a] = u(""), [c, i] = u(-1), [U, j] = u([]), n = M ?? U, w = _ ?? j, T = I(null), d = I(null);
|
|
29
|
+
G(() => {
|
|
30
|
+
v && d.current && (d.current.scrollTop = d.current.scrollHeight);
|
|
31
|
+
}, [x, v]);
|
|
32
|
+
const B = y(() => {
|
|
33
|
+
var e;
|
|
34
|
+
f || (e = T.current) == null || e.focus();
|
|
35
|
+
}, [f]), E = y(() => {
|
|
36
|
+
o.trim() && m && (m(o.trim()), w([...n, o.trim()]), i(-1), a(""));
|
|
37
|
+
}, [o, m, n, w]), F = y((e) => {
|
|
38
|
+
if (e.key === "Enter")
|
|
39
|
+
E();
|
|
40
|
+
else if (e.key === "ArrowUp") {
|
|
41
|
+
if (e.preventDefault(), n.length > 0) {
|
|
42
|
+
const s = c === -1 ? n.length - 1 : Math.max(0, c - 1);
|
|
43
|
+
i(s), a(n[s]);
|
|
44
|
+
}
|
|
45
|
+
} else if (e.key === "ArrowDown") {
|
|
46
|
+
if (e.preventDefault(), c !== -1) {
|
|
47
|
+
const s = c + 1;
|
|
48
|
+
s >= n.length ? (i(-1), a("")) : (i(s), a(n[s]));
|
|
49
|
+
}
|
|
50
|
+
} else e.key === "c" && e.ctrlKey && (a(""), i(-1));
|
|
51
|
+
}, [E, n, c]), k = () => g || /* @__PURE__ */ r(z, { children: [
|
|
52
|
+
/* @__PURE__ */ r("span", { style: { color: l.prompt }, children: [
|
|
53
|
+
H,
|
|
54
|
+
"@",
|
|
55
|
+
S
|
|
56
|
+
] }),
|
|
57
|
+
/* @__PURE__ */ t("span", { className: "opacity-50", children: ":" }),
|
|
58
|
+
/* @__PURE__ */ t("span", { className: "text-blue-400", children: C }),
|
|
59
|
+
/* @__PURE__ */ t("span", { className: "opacity-50", children: "$" })
|
|
60
|
+
] }), P = (e, s) => {
|
|
61
|
+
const V = J[e.type];
|
|
62
|
+
return /* @__PURE__ */ r(
|
|
63
|
+
"div",
|
|
64
|
+
{
|
|
65
|
+
className: "flex gap-2 py-0.5 hover:bg-white/5",
|
|
66
|
+
children: [
|
|
67
|
+
L && /* @__PURE__ */ t("span", { className: "opacity-30 w-8 text-right select-none", children: s + 1 }),
|
|
68
|
+
R && e.timestamp && /* @__PURE__ */ r("span", { className: "opacity-30 select-none", children: [
|
|
69
|
+
"[",
|
|
70
|
+
e.timestamp.toLocaleTimeString(),
|
|
71
|
+
"]"
|
|
72
|
+
] }),
|
|
73
|
+
e.type === "input" ? /* @__PURE__ */ r("div", { className: "flex gap-2", children: [
|
|
74
|
+
/* @__PURE__ */ t("span", { className: "flex gap-1 select-none", children: e.prefix || k() }),
|
|
75
|
+
/* @__PURE__ */ t("span", { children: e.content })
|
|
76
|
+
] }) : /* @__PURE__ */ t("span", { style: { color: V }, children: e.content })
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
e.id
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
return /* @__PURE__ */ r(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
className: O(
|
|
86
|
+
"Bear-Terminal",
|
|
87
|
+
"rounded-lg overflow-hidden font-mono text-sm",
|
|
88
|
+
$
|
|
89
|
+
),
|
|
90
|
+
style: {
|
|
91
|
+
backgroundColor: l.bg,
|
|
92
|
+
color: l.text,
|
|
93
|
+
border: `1px solid ${l.border}`,
|
|
94
|
+
height: typeof h == "number" ? `${h}px` : h
|
|
95
|
+
},
|
|
96
|
+
"data-testid": K,
|
|
97
|
+
onClick: B,
|
|
98
|
+
children: [
|
|
99
|
+
N && /* @__PURE__ */ r(
|
|
100
|
+
"div",
|
|
101
|
+
{
|
|
102
|
+
className: "flex items-center gap-2 px-4 py-2",
|
|
103
|
+
style: { backgroundColor: l.header, borderBottom: `1px solid ${l.border}` },
|
|
104
|
+
children: [
|
|
105
|
+
/* @__PURE__ */ r("div", { className: "flex gap-1.5", children: [
|
|
106
|
+
/* @__PURE__ */ t("div", { className: "w-3 h-3 rounded-full bg-red-500" }),
|
|
107
|
+
/* @__PURE__ */ t("div", { className: "w-3 h-3 rounded-full bg-yellow-500" }),
|
|
108
|
+
/* @__PURE__ */ t("div", { className: "w-3 h-3 rounded-full bg-green-500" })
|
|
109
|
+
] }),
|
|
110
|
+
/* @__PURE__ */ t(W, { variant: "caption", className: "flex-1 text-center opacity-60", children: D }),
|
|
111
|
+
/* @__PURE__ */ t("div", { className: "w-14" }),
|
|
112
|
+
" "
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
),
|
|
116
|
+
/* @__PURE__ */ r(
|
|
117
|
+
"div",
|
|
118
|
+
{
|
|
119
|
+
ref: d,
|
|
120
|
+
className: "overflow-y-auto p-4",
|
|
121
|
+
style: { height: N ? "calc(100% - 40px)" : "100%" },
|
|
122
|
+
children: [
|
|
123
|
+
x.map((e, s) => P(e, s)),
|
|
124
|
+
b && /* @__PURE__ */ r("div", { className: "flex items-center gap-2 py-0.5", children: [
|
|
125
|
+
/* @__PURE__ */ t(Y, { size: "sm" }),
|
|
126
|
+
/* @__PURE__ */ t("span", { className: "opacity-50", children: "Processing..." })
|
|
127
|
+
] }),
|
|
128
|
+
!f && /* @__PURE__ */ r("div", { className: "flex gap-2 py-0.5", children: [
|
|
129
|
+
/* @__PURE__ */ t("span", { className: "flex gap-1 select-none", children: k() }),
|
|
130
|
+
/* @__PURE__ */ t(
|
|
131
|
+
"input",
|
|
132
|
+
{
|
|
133
|
+
ref: T,
|
|
134
|
+
type: "text",
|
|
135
|
+
value: o,
|
|
136
|
+
onChange: (e) => a(e.target.value),
|
|
137
|
+
onKeyDown: F,
|
|
138
|
+
className: "flex-1 bg-transparent outline-none caret-current",
|
|
139
|
+
style: { color: "inherit" },
|
|
140
|
+
autoComplete: "off",
|
|
141
|
+
spellCheck: !1,
|
|
142
|
+
disabled: b
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
] })
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
)
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
export {
|
|
154
|
+
se as Terminal
|
|
155
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type TerminalLineType = 'input' | 'output' | 'error' | 'success' | 'warning' | 'info' | 'system';
|
|
3
|
+
export interface TerminalLine {
|
|
4
|
+
id: string;
|
|
5
|
+
type: TerminalLineType;
|
|
6
|
+
content: string | ReactNode;
|
|
7
|
+
timestamp?: Date;
|
|
8
|
+
prefix?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface TerminalProps {
|
|
11
|
+
/** Array of terminal lines */
|
|
12
|
+
lines: TerminalLine[];
|
|
13
|
+
/** Callback when user submits a command */
|
|
14
|
+
onCommand?: (command: string) => void;
|
|
15
|
+
/** Current working directory to display */
|
|
16
|
+
cwd?: string;
|
|
17
|
+
/** Username to display */
|
|
18
|
+
user?: string;
|
|
19
|
+
/** Hostname to display */
|
|
20
|
+
host?: string;
|
|
21
|
+
/** Shell prompt prefix (overrides user@host) */
|
|
22
|
+
prompt?: string | ReactNode;
|
|
23
|
+
/** Title in the header */
|
|
24
|
+
title?: string;
|
|
25
|
+
/** Show header with controls */
|
|
26
|
+
showHeader?: boolean;
|
|
27
|
+
/** Show line numbers */
|
|
28
|
+
showLineNumbers?: boolean;
|
|
29
|
+
/** Show timestamps */
|
|
30
|
+
showTimestamps?: boolean;
|
|
31
|
+
/** Read-only mode (no input) */
|
|
32
|
+
readOnly?: boolean;
|
|
33
|
+
/** Height of the terminal */
|
|
34
|
+
height?: number | string;
|
|
35
|
+
/** Theme variant */
|
|
36
|
+
theme?: 'dark' | 'light' | 'matrix';
|
|
37
|
+
/** Command history */
|
|
38
|
+
history?: string[];
|
|
39
|
+
/** Callback when history changes */
|
|
40
|
+
onHistoryChange?: (history: string[]) => void;
|
|
41
|
+
/** Auto-scroll to bottom */
|
|
42
|
+
autoScroll?: boolean;
|
|
43
|
+
/** Custom class name */
|
|
44
|
+
className?: string;
|
|
45
|
+
/** Test ID */
|
|
46
|
+
testId?: string;
|
|
47
|
+
/** Loading state */
|
|
48
|
+
isLoading?: boolean;
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),s=require("react"),L=require("../../utils/cn.cjs"),U=require("../Button/Button.cjs"),v=require("../Typography/Typography.cjs"),a=require("./Tour.const.cjs"),G=({steps:T,open:u=!1,current:A,onClose:d,onStepChange:b,onFinish:f,showIndicators:N=a.TOUR_DEFAULTS.SHOW_INDICATORS,showCloseButton:I=a.TOUR_DEFAULTS.SHOW_CLOSE_BUTTON,showSkipButton:w=a.TOUR_DEFAULTS.SHOW_SKIP_BUTTON,showPrevButton:P=a.TOUR_DEFAULTS.SHOW_PREV_BUTTON,finishText:D=a.TOUR_DEFAULTS.FINISH_TEXT,skipText:y=a.TOUR_DEFAULTS.SKIP_TEXT,maskOpacity:g=a.TOUR_DEFAULTS.MASK_OPACITY,maskColor:m=a.TOUR_DEFAULTS.MASK_COLOR,animated:E=a.TOUR_DEFAULTS.ANIMATED,className:k,testId:j})=>{const[B,x]=s.useState(0),[r,F]=s.useState(null),[R,M]=s.useState({top:0,left:0}),z=s.useRef(null),c=A??B,e=T[c],_=c===T.length-1,H=c===0,O=s.useCallback(()=>e?typeof e.target=="function"?e.target():document.querySelector(e.target):null,[e]),S=s.useCallback(()=>{const t=O();if(t){const i=t.getBoundingClientRect();F(i)}},[O]);s.useEffect(()=>{if(!r||!e)return;const t=e.placement||a.TOUR_DEFAULTS.PLACEMENT,i=e.spotlightPadding??a.TOUR_DEFAULTS.SPOTLIGHT_PADDING;let l=0,n=0;switch(t){case"top":case"top-start":case"top-end":l=r.top-a.TOUR_TOOLTIP_OFFSET-i,n=t==="top"?r.left+r.width/2:t==="top-start"?r.left:r.right;break;case"bottom":case"bottom-start":case"bottom-end":l=r.bottom+a.TOUR_TOOLTIP_OFFSET+i,n=t==="bottom"?r.left+r.width/2:t==="bottom-start"?r.left:r.right;break;case"left":case"left-start":case"left-end":n=r.left-a.TOUR_TOOLTIP_OFFSET-i,l=t==="left"?r.top+r.height/2:t==="left-start"?r.top:r.bottom;break;case"right":case"right-start":case"right-end":n=r.right+a.TOUR_TOOLTIP_OFFSET+i,l=t==="right"?r.top+r.height/2:t==="right-start"?r.top:r.bottom;break}M({top:l,left:n})},[r,e]),s.useEffect(()=>{if(!u)return;S();const t=()=>S();return window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[u,c,S]),s.useEffect(()=>{if(!u)return;const t=O();t&&t.scrollIntoView({behavior:"smooth",block:"center"})},[u,c,O]);const X=s.useCallback(async()=>{var t,i,l;if(e!=null&&e.onAfterStep&&await e.onAfterStep(),_)f==null||f(),d==null||d();else{const n=c+1;x(n),b==null||b(n),(t=T[n])!=null&&t.onBeforeStep&&await((l=(i=T[n]).onBeforeStep)==null?void 0:l.call(i))}},[c,_,e,T,f,d,b]),q=s.useCallback(async()=>{var i,l,n;e!=null&&e.onAfterStep&&await e.onAfterStep();const t=c-1;x(t),b==null||b(t),(i=T[t])!=null&&i.onBeforeStep&&await((n=(l=T[t]).onBeforeStep)==null?void 0:n.call(l))},[c,e,T,b]),p=s.useCallback(()=>{d==null||d()},[d]),W=(e==null?void 0:e.placement)||a.TOUR_DEFAULTS.PLACEMENT,h=(e==null?void 0:e.spotlightPadding)??a.TOUR_DEFAULTS.SPOTLIGHT_PADDING;return!u||!e?null:o.jsxs("div",{className:L.cn("Bear-Tour",k),"data-testid":j,children:[o.jsx("div",{className:"Bear-Tour__overlay bear-fixed bear-inset-0",style:{zIndex:a.TOUR_Z_INDEX.OVERLAY,backgroundColor:m,opacity:g,transition:E?"opacity 0.3s":"none"},onClick:p}),r&&o.jsx("div",{className:"Bear-Tour__spotlight bear-fixed bear-pointer-events-none",style:{zIndex:a.TOUR_Z_INDEX.SPOTLIGHT,top:r.top-h,left:r.left-h,width:r.width+h*2,height:r.height+h*2,borderRadius:8,boxShadow:`0 0 0 9999px ${m}`,opacity:g,transition:E?"all 0.3s ease":"none"}}),o.jsxs("div",{ref:z,className:"Bear-Tour__tooltip bear-fixed bear-bg-white dark:bear-bg-neutral-800 bear-rounded-lg bear-shadow-xl bear-p-4",style:{zIndex:a.TOUR_Z_INDEX.TOOLTIP,top:R.top,left:R.left,minWidth:280,maxWidth:360,...a.TOUR_PLACEMENT_STYLES[W],transition:E?"all 0.3s ease":"none"},children:[I&&o.jsx("button",{className:"Bear-Tour__close bear-absolute bear-top-2 bear-right-2 bear-p-1 bear-text-neutral-400 hover:bear-text-neutral-600 dark:hover:bear-text-neutral-300 bear-cursor-pointer bear-bg-transparent bear-border-none",onClick:p,"aria-label":"Close tour",children:o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:o.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})}),o.jsxs("div",{className:"Bear-Tour__content bear-pr-6",children:[e.title&&o.jsx(v.Typography,{variant:"h6",className:"bear-mb-2",children:e.title}),e.description&&o.jsx(v.Typography,{variant:"body2",color:"secondary",className:"bear-mb-4",children:e.description}),e.content]}),o.jsxs("div",{className:"Bear-Tour__footer bear-flex bear-items-center bear-justify-between bear-mt-4 bear-pt-3 bear-border-t bear-border-neutral-200 dark:bear-border-neutral-700",children:[N&&o.jsx("div",{className:"bear-flex bear-gap-1.5",children:T.map((t,i)=>o.jsx("div",{className:L.cn("bear-w-2 bear-h-2 bear-rounded-full bear-transition-colors",i===c?"bear-bg-[var(--bear-primary-500)]":"bear-bg-neutral-300 dark:bear-bg-neutral-600")},i))}),o.jsxs("div",{className:"bear-flex bear-gap-2 bear-ml-auto",children:[w&&!_&&o.jsx(U.Button,{variant:"ghost",size:"sm",onClick:p,children:y}),P&&!H&&o.jsx(U.Button,{variant:"outline",size:"sm",onClick:q,children:e.prevText||a.TOUR_DEFAULTS.PREV_TEXT}),o.jsx(U.Button,{variant:"primary",size:"sm",onClick:X,children:_?D:e.nextText||a.TOUR_DEFAULTS.NEXT_TEXT})]})]})]})]})};exports.Tour=G;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t={SHOW_INDICATORS:!0,SHOW_CLOSE_BUTTON:!0,SHOW_SKIP_BUTTON:!0,SHOW_PREV_BUTTON:!0,FINISH_TEXT:"Finish",SKIP_TEXT:"Skip",NEXT_TEXT:"Next",PREV_TEXT:"Back",MASK_OPACITY:.5,MASK_COLOR:"#000000",SPOTLIGHT_PADDING:8,ANIMATED:!0,PLACEMENT:"bottom"},r={OVERLAY:99990,SPOTLIGHT:99991,TOOLTIP:99992},T=12,a={top:{transform:"translate(-50%, -100%)"},"top-start":{transform:"translate(0, -100%)"},"top-end":{transform:"translate(-100%, -100%)"},bottom:{transform:"translate(-50%, 0)"},"bottom-start":{transform:"translate(0, 0)"},"bottom-end":{transform:"translate(-100%, 0)"},left:{transform:"translate(-100%, -50%)"},"left-start":{transform:"translate(-100%, 0)"},"left-end":{transform:"translate(-100%, -100%)"},right:{transform:"translate(0, -50%)"},"right-start":{transform:"translate(0, 0)"},"right-end":{transform:"translate(0, -100%)"}};exports.TOUR_DEFAULTS=t;exports.TOUR_PLACEMENT_STYLES=a;exports.TOUR_TOOLTIP_OFFSET=T;exports.TOUR_Z_INDEX=r;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TourPlacement } from './Tour.types';
|
|
2
|
+
export declare const TOUR_DEFAULTS: {
|
|
3
|
+
readonly SHOW_INDICATORS: true;
|
|
4
|
+
readonly SHOW_CLOSE_BUTTON: true;
|
|
5
|
+
readonly SHOW_SKIP_BUTTON: true;
|
|
6
|
+
readonly SHOW_PREV_BUTTON: true;
|
|
7
|
+
readonly FINISH_TEXT: "Finish";
|
|
8
|
+
readonly SKIP_TEXT: "Skip";
|
|
9
|
+
readonly NEXT_TEXT: "Next";
|
|
10
|
+
readonly PREV_TEXT: "Back";
|
|
11
|
+
readonly MASK_OPACITY: 0.5;
|
|
12
|
+
readonly MASK_COLOR: "#000000";
|
|
13
|
+
readonly SPOTLIGHT_PADDING: 8;
|
|
14
|
+
readonly ANIMATED: true;
|
|
15
|
+
readonly PLACEMENT: TourPlacement;
|
|
16
|
+
};
|
|
17
|
+
export declare const TOUR_Z_INDEX: {
|
|
18
|
+
readonly OVERLAY: 99990;
|
|
19
|
+
readonly SPOTLIGHT: 99991;
|
|
20
|
+
readonly TOOLTIP: 99992;
|
|
21
|
+
};
|
|
22
|
+
export declare const TOUR_TOOLTIP_OFFSET = 12;
|
|
23
|
+
export declare const TOUR_PLACEMENT_STYLES: Record<TourPlacement, {
|
|
24
|
+
transform: string;
|
|
25
|
+
}>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const t = {
|
|
2
|
+
SHOW_INDICATORS: !0,
|
|
3
|
+
SHOW_CLOSE_BUTTON: !0,
|
|
4
|
+
SHOW_SKIP_BUTTON: !0,
|
|
5
|
+
SHOW_PREV_BUTTON: !0,
|
|
6
|
+
FINISH_TEXT: "Finish",
|
|
7
|
+
SKIP_TEXT: "Skip",
|
|
8
|
+
NEXT_TEXT: "Next",
|
|
9
|
+
PREV_TEXT: "Back",
|
|
10
|
+
MASK_OPACITY: 0.5,
|
|
11
|
+
MASK_COLOR: "#000000",
|
|
12
|
+
SPOTLIGHT_PADDING: 8,
|
|
13
|
+
ANIMATED: !0,
|
|
14
|
+
PLACEMENT: "bottom"
|
|
15
|
+
}, r = {
|
|
16
|
+
OVERLAY: 99990,
|
|
17
|
+
SPOTLIGHT: 99991,
|
|
18
|
+
TOOLTIP: 99992
|
|
19
|
+
}, a = 12, T = {
|
|
20
|
+
top: { transform: "translate(-50%, -100%)" },
|
|
21
|
+
"top-start": { transform: "translate(0, -100%)" },
|
|
22
|
+
"top-end": { transform: "translate(-100%, -100%)" },
|
|
23
|
+
bottom: { transform: "translate(-50%, 0)" },
|
|
24
|
+
"bottom-start": { transform: "translate(0, 0)" },
|
|
25
|
+
"bottom-end": { transform: "translate(-100%, 0)" },
|
|
26
|
+
left: { transform: "translate(-100%, -50%)" },
|
|
27
|
+
"left-start": { transform: "translate(-100%, 0)" },
|
|
28
|
+
"left-end": { transform: "translate(-100%, -100%)" },
|
|
29
|
+
right: { transform: "translate(0, -50%)" },
|
|
30
|
+
"right-start": { transform: "translate(0, 0)" },
|
|
31
|
+
"right-end": { transform: "translate(0, -100%)" }
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
t as TOUR_DEFAULTS,
|
|
35
|
+
T as TOUR_PLACEMENT_STYLES,
|
|
36
|
+
a as TOUR_TOOLTIP_OFFSET,
|
|
37
|
+
r as TOUR_Z_INDEX
|
|
38
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { TourProps } from './Tour.types';
|
|
3
|
+
/**
|
|
4
|
+
* Tour - Feature tour/onboarding walkthrough
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* const steps = [
|
|
9
|
+
* { target: '#welcome-btn', title: 'Welcome!', description: 'Click here to start' },
|
|
10
|
+
* { target: '#settings', title: 'Settings', description: 'Configure your preferences' },
|
|
11
|
+
* ];
|
|
12
|
+
*
|
|
13
|
+
* <Tour steps={steps} open={showTour} onClose={() => setShowTour(false)} />
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const Tour: FC<TourProps>;
|
|
17
|
+
export default Tour;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { jsxs as u, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useState as w, useRef as F, useCallback as T, useEffect as x } from "react";
|
|
3
|
+
import { cn as y } from "../../utils/cn.js";
|
|
4
|
+
import { Button as O } from "../Button/Button.js";
|
|
5
|
+
import { Typography as A } from "../Typography/Typography.js";
|
|
6
|
+
import { TOUR_DEFAULTS as o, TOUR_TOOLTIP_OFFSET as _, TOUR_Z_INDEX as S, TOUR_PLACEMENT_STYLES as J } from "./Tour.const.js";
|
|
7
|
+
const ot = ({
|
|
8
|
+
steps: s,
|
|
9
|
+
open: f = !1,
|
|
10
|
+
current: B,
|
|
11
|
+
onClose: d,
|
|
12
|
+
onStepChange: b,
|
|
13
|
+
onFinish: m,
|
|
14
|
+
showIndicators: R = o.SHOW_INDICATORS,
|
|
15
|
+
showCloseButton: U = o.SHOW_CLOSE_BUTTON,
|
|
16
|
+
showSkipButton: z = o.SHOW_SKIP_BUTTON,
|
|
17
|
+
showPrevButton: D = o.SHOW_PREV_BUTTON,
|
|
18
|
+
finishText: H = o.FINISH_TEXT,
|
|
19
|
+
skipText: M = o.SKIP_TEXT,
|
|
20
|
+
maskOpacity: I = o.MASK_OPACITY,
|
|
21
|
+
maskColor: P = o.MASK_COLOR,
|
|
22
|
+
animated: v = o.ANIMATED,
|
|
23
|
+
className: W,
|
|
24
|
+
testId: X
|
|
25
|
+
}) => {
|
|
26
|
+
const [G, L] = w(0), [r, K] = w(null), [k, V] = w({ top: 0, left: 0 }), j = F(null), c = B ?? G, t = s[c], h = c === s.length - 1, Y = c === 0, p = T(() => t ? typeof t.target == "function" ? t.target() : document.querySelector(t.target) : null, [t]), E = T(() => {
|
|
27
|
+
const e = p();
|
|
28
|
+
if (e) {
|
|
29
|
+
const a = e.getBoundingClientRect();
|
|
30
|
+
K(a);
|
|
31
|
+
}
|
|
32
|
+
}, [p]);
|
|
33
|
+
x(() => {
|
|
34
|
+
if (!r || !t) return;
|
|
35
|
+
const e = t.placement || o.PLACEMENT, a = t.spotlightPadding ?? o.SPOTLIGHT_PADDING;
|
|
36
|
+
let l = 0, i = 0;
|
|
37
|
+
switch (e) {
|
|
38
|
+
case "top":
|
|
39
|
+
case "top-start":
|
|
40
|
+
case "top-end":
|
|
41
|
+
l = r.top - _ - a, i = e === "top" ? r.left + r.width / 2 : e === "top-start" ? r.left : r.right;
|
|
42
|
+
break;
|
|
43
|
+
case "bottom":
|
|
44
|
+
case "bottom-start":
|
|
45
|
+
case "bottom-end":
|
|
46
|
+
l = r.bottom + _ + a, i = e === "bottom" ? r.left + r.width / 2 : e === "bottom-start" ? r.left : r.right;
|
|
47
|
+
break;
|
|
48
|
+
case "left":
|
|
49
|
+
case "left-start":
|
|
50
|
+
case "left-end":
|
|
51
|
+
i = r.left - _ - a, l = e === "left" ? r.top + r.height / 2 : e === "left-start" ? r.top : r.bottom;
|
|
52
|
+
break;
|
|
53
|
+
case "right":
|
|
54
|
+
case "right-start":
|
|
55
|
+
case "right-end":
|
|
56
|
+
i = r.right + _ + a, l = e === "right" ? r.top + r.height / 2 : e === "right-start" ? r.top : r.bottom;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
V({ top: l, left: i });
|
|
60
|
+
}, [r, t]), x(() => {
|
|
61
|
+
if (!f) return;
|
|
62
|
+
E();
|
|
63
|
+
const e = () => E();
|
|
64
|
+
return window.addEventListener("resize", e), window.addEventListener("scroll", e, !0), () => {
|
|
65
|
+
window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
|
|
66
|
+
};
|
|
67
|
+
}, [f, c, E]), x(() => {
|
|
68
|
+
if (!f) return;
|
|
69
|
+
const e = p();
|
|
70
|
+
e && e.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
71
|
+
}, [f, c, p]);
|
|
72
|
+
const q = T(async () => {
|
|
73
|
+
var e, a, l;
|
|
74
|
+
if (t != null && t.onAfterStep && await t.onAfterStep(), h)
|
|
75
|
+
m == null || m(), d == null || d();
|
|
76
|
+
else {
|
|
77
|
+
const i = c + 1;
|
|
78
|
+
L(i), b == null || b(i), (e = s[i]) != null && e.onBeforeStep && await ((l = (a = s[i]).onBeforeStep) == null ? void 0 : l.call(a));
|
|
79
|
+
}
|
|
80
|
+
}, [c, h, t, s, m, d, b]), Z = T(async () => {
|
|
81
|
+
var a, l, i;
|
|
82
|
+
t != null && t.onAfterStep && await t.onAfterStep();
|
|
83
|
+
const e = c - 1;
|
|
84
|
+
L(e), b == null || b(e), (a = s[e]) != null && a.onBeforeStep && await ((i = (l = s[e]).onBeforeStep) == null ? void 0 : i.call(l));
|
|
85
|
+
}, [c, t, s, b]), N = T(() => {
|
|
86
|
+
d == null || d();
|
|
87
|
+
}, [d]), $ = (t == null ? void 0 : t.placement) || o.PLACEMENT, g = (t == null ? void 0 : t.spotlightPadding) ?? o.SPOTLIGHT_PADDING;
|
|
88
|
+
return !f || !t ? null : /* @__PURE__ */ u(
|
|
89
|
+
"div",
|
|
90
|
+
{
|
|
91
|
+
className: y("Bear-Tour", W),
|
|
92
|
+
"data-testid": X,
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ n(
|
|
95
|
+
"div",
|
|
96
|
+
{
|
|
97
|
+
className: "Bear-Tour__overlay bear-fixed bear-inset-0",
|
|
98
|
+
style: {
|
|
99
|
+
zIndex: S.OVERLAY,
|
|
100
|
+
backgroundColor: P,
|
|
101
|
+
opacity: I,
|
|
102
|
+
transition: v ? "opacity 0.3s" : "none"
|
|
103
|
+
},
|
|
104
|
+
onClick: N
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
r && /* @__PURE__ */ n(
|
|
108
|
+
"div",
|
|
109
|
+
{
|
|
110
|
+
className: "Bear-Tour__spotlight bear-fixed bear-pointer-events-none",
|
|
111
|
+
style: {
|
|
112
|
+
zIndex: S.SPOTLIGHT,
|
|
113
|
+
top: r.top - g,
|
|
114
|
+
left: r.left - g,
|
|
115
|
+
width: r.width + g * 2,
|
|
116
|
+
height: r.height + g * 2,
|
|
117
|
+
borderRadius: 8,
|
|
118
|
+
boxShadow: `0 0 0 9999px ${P}`,
|
|
119
|
+
opacity: I,
|
|
120
|
+
transition: v ? "all 0.3s ease" : "none"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
/* @__PURE__ */ u(
|
|
125
|
+
"div",
|
|
126
|
+
{
|
|
127
|
+
ref: j,
|
|
128
|
+
className: "Bear-Tour__tooltip bear-fixed bear-bg-white dark:bear-bg-neutral-800 bear-rounded-lg bear-shadow-xl bear-p-4",
|
|
129
|
+
style: {
|
|
130
|
+
zIndex: S.TOOLTIP,
|
|
131
|
+
top: k.top,
|
|
132
|
+
left: k.left,
|
|
133
|
+
minWidth: 280,
|
|
134
|
+
maxWidth: 360,
|
|
135
|
+
...J[$],
|
|
136
|
+
transition: v ? "all 0.3s ease" : "none"
|
|
137
|
+
},
|
|
138
|
+
children: [
|
|
139
|
+
U && /* @__PURE__ */ n(
|
|
140
|
+
"button",
|
|
141
|
+
{
|
|
142
|
+
className: "Bear-Tour__close bear-absolute bear-top-2 bear-right-2 bear-p-1 bear-text-neutral-400 hover:bear-text-neutral-600 dark:hover:bear-text-neutral-300 bear-cursor-pointer bear-bg-transparent bear-border-none",
|
|
143
|
+
onClick: N,
|
|
144
|
+
"aria-label": "Close tour",
|
|
145
|
+
children: /* @__PURE__ */ n("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ n("path", { d: "M18 6L6 18M6 6l12 12" }) })
|
|
146
|
+
}
|
|
147
|
+
),
|
|
148
|
+
/* @__PURE__ */ u("div", { className: "Bear-Tour__content bear-pr-6", children: [
|
|
149
|
+
t.title && /* @__PURE__ */ n(A, { variant: "h6", className: "bear-mb-2", children: t.title }),
|
|
150
|
+
t.description && /* @__PURE__ */ n(A, { variant: "body2", color: "secondary", className: "bear-mb-4", children: t.description }),
|
|
151
|
+
t.content
|
|
152
|
+
] }),
|
|
153
|
+
/* @__PURE__ */ u("div", { className: "Bear-Tour__footer bear-flex bear-items-center bear-justify-between bear-mt-4 bear-pt-3 bear-border-t bear-border-neutral-200 dark:bear-border-neutral-700", children: [
|
|
154
|
+
R && /* @__PURE__ */ n("div", { className: "bear-flex bear-gap-1.5", children: s.map((e, a) => /* @__PURE__ */ n(
|
|
155
|
+
"div",
|
|
156
|
+
{
|
|
157
|
+
className: y(
|
|
158
|
+
"bear-w-2 bear-h-2 bear-rounded-full bear-transition-colors",
|
|
159
|
+
a === c ? "bear-bg-[var(--bear-primary-500)]" : "bear-bg-neutral-300 dark:bear-bg-neutral-600"
|
|
160
|
+
)
|
|
161
|
+
},
|
|
162
|
+
a
|
|
163
|
+
)) }),
|
|
164
|
+
/* @__PURE__ */ u("div", { className: "bear-flex bear-gap-2 bear-ml-auto", children: [
|
|
165
|
+
z && !h && /* @__PURE__ */ n(O, { variant: "ghost", size: "sm", onClick: N, children: M }),
|
|
166
|
+
D && !Y && /* @__PURE__ */ n(O, { variant: "outline", size: "sm", onClick: Z, children: t.prevText || o.PREV_TEXT }),
|
|
167
|
+
/* @__PURE__ */ n(O, { variant: "primary", size: "sm", onClick: q, children: h ? H : t.nextText || o.NEXT_TEXT })
|
|
168
|
+
] })
|
|
169
|
+
] })
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
export {
|
|
178
|
+
ot as Tour
|
|
179
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface TourStep {
|
|
3
|
+
/** Target element selector or ref */
|
|
4
|
+
target: string | (() => HTMLElement | null);
|
|
5
|
+
/** Step title */
|
|
6
|
+
title?: ReactNode;
|
|
7
|
+
/** Step description */
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
/** Custom content */
|
|
10
|
+
content?: ReactNode;
|
|
11
|
+
/** Placement of the tooltip */
|
|
12
|
+
placement?: TourPlacement;
|
|
13
|
+
/** Disable interaction with target */
|
|
14
|
+
disableInteraction?: boolean;
|
|
15
|
+
/** Show spotlight on target */
|
|
16
|
+
spotlightPadding?: number;
|
|
17
|
+
/** Custom next button text */
|
|
18
|
+
nextText?: string;
|
|
19
|
+
/** Custom prev button text */
|
|
20
|
+
prevText?: string;
|
|
21
|
+
/** Before step callback */
|
|
22
|
+
onBeforeStep?: () => Promise<void> | void;
|
|
23
|
+
/** After step callback */
|
|
24
|
+
onAfterStep?: () => Promise<void> | void;
|
|
25
|
+
}
|
|
26
|
+
export type TourPlacement = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end';
|
|
27
|
+
export interface TourProps {
|
|
28
|
+
/** Array of tour steps */
|
|
29
|
+
steps: TourStep[];
|
|
30
|
+
/** Whether tour is open */
|
|
31
|
+
open?: boolean;
|
|
32
|
+
/** Current step index */
|
|
33
|
+
current?: number;
|
|
34
|
+
/** Called when tour closes */
|
|
35
|
+
onClose?: () => void;
|
|
36
|
+
/** Called when step changes */
|
|
37
|
+
onStepChange?: (current: number) => void;
|
|
38
|
+
/** Called when tour finishes */
|
|
39
|
+
onFinish?: () => void;
|
|
40
|
+
/** Show step indicators */
|
|
41
|
+
showIndicators?: boolean;
|
|
42
|
+
/** Show close button */
|
|
43
|
+
showCloseButton?: boolean;
|
|
44
|
+
/** Show skip button */
|
|
45
|
+
showSkipButton?: boolean;
|
|
46
|
+
/** Show prev button */
|
|
47
|
+
showPrevButton?: boolean;
|
|
48
|
+
/** Finish button text */
|
|
49
|
+
finishText?: string;
|
|
50
|
+
/** Skip button text */
|
|
51
|
+
skipText?: string;
|
|
52
|
+
/** Custom class name */
|
|
53
|
+
className?: string;
|
|
54
|
+
/** Mask/overlay opacity */
|
|
55
|
+
maskOpacity?: number;
|
|
56
|
+
/** Mask color */
|
|
57
|
+
maskColor?: string;
|
|
58
|
+
/** Animation enabled */
|
|
59
|
+
animated?: boolean;
|
|
60
|
+
/** Test ID */
|
|
61
|
+
testId?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface UseTourReturn {
|
|
64
|
+
/** Start the tour */
|
|
65
|
+
start: () => void;
|
|
66
|
+
/** Stop the tour */
|
|
67
|
+
stop: () => void;
|
|
68
|
+
/** Go to next step */
|
|
69
|
+
next: () => void;
|
|
70
|
+
/** Go to previous step */
|
|
71
|
+
prev: () => void;
|
|
72
|
+
/** Go to specific step */
|
|
73
|
+
goTo: (step: number) => void;
|
|
74
|
+
/** Whether tour is active */
|
|
75
|
+
isActive: boolean;
|
|
76
|
+
/** Current step index */
|
|
77
|
+
currentStep: number;
|
|
78
|
+
/** Total steps count */
|
|
79
|
+
totalSteps: number;
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),b=l=>{const[o,a]=t.useState(!1),[c,n]=t.useState(0),u=t.useCallback(()=>{n(0),a(!0)},[]),s=t.useCallback(()=>{a(!1),n(0)},[]),r=t.useCallback(()=>{c<l.length-1?n(e=>e+1):s()},[c,l.length,s]),i=t.useCallback(()=>{c>0&&n(e=>e-1)},[c]),g=t.useCallback(e=>{e>=0&&e<l.length&&n(e)},[l.length]);return{start:u,stop:s,next:r,prev:i,goTo:g,isActive:o,currentStep:c,totalSteps:l.length}};exports.useTour=b;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { UseTourReturn, TourStep } from './Tour.types';
|
|
2
|
+
/**
|
|
3
|
+
* useTour - Hook to control tour programmatically
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const steps = [...];
|
|
8
|
+
* const { start, stop, next, prev, isActive, currentStep } = useTour(steps);
|
|
9
|
+
*
|
|
10
|
+
* <Tour steps={steps} open={isActive} current={currentStep} onClose={stop} />
|
|
11
|
+
* <Button onClick={start}>Start Tour</Button>
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const useTour: (steps: TourStep[]) => UseTourReturn;
|