@forgedevstack/bear 1.0.7 → 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 -1
- package/dist/components/BottomSheet/BottomSheet.js +39 -38
- 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 -45
- package/dist/components/Button/Button.types.d.ts +22 -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/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 -1
- package/dist/components/Kanban/Kanban.js +18 -17
- 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/Spinner/Spinner.types.d.ts +2 -2
- 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/index.cjs +1 -1
- package/dist/components/index.d.ts +19 -1
- package/dist/components/index.js +242 -218
- 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 +14 -0
- package/dist/hooks/index.js +56 -39
- 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/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/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 +324 -283
- 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,29 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { QRCodeProps } from './QRCode.types';
|
|
3
|
+
/**
|
|
4
|
+
* QRCode - QR code generator component
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* // Basic usage
|
|
9
|
+
* <QRCode value="https://forgestack.dev" />
|
|
10
|
+
*
|
|
11
|
+
* // Custom styling
|
|
12
|
+
* <QRCode
|
|
13
|
+
* value="Hello World"
|
|
14
|
+
* size={200}
|
|
15
|
+
* fgColor="#ec4899"
|
|
16
|
+
* bgColor="transparent"
|
|
17
|
+
* />
|
|
18
|
+
*
|
|
19
|
+
* // With center logo
|
|
20
|
+
* <QRCode
|
|
21
|
+
* value="https://forgestack.dev"
|
|
22
|
+
* imageUrl="/logo.png"
|
|
23
|
+
* imageSize={0.25}
|
|
24
|
+
* level="H"
|
|
25
|
+
* />
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const QRCode: FC<QRCodeProps>;
|
|
29
|
+
export default QRCode;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsxs as x, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as u } from "react";
|
|
3
|
+
import { cn as w } from "../../utils/cn.js";
|
|
4
|
+
import { QRCODE_DEFAULTS as r } from "./QRCode.const.js";
|
|
5
|
+
import { generateQRMatrix as C, matrixToSvgPath as D } from "./QRCode.utils.js";
|
|
6
|
+
const Q = ({
|
|
7
|
+
value: n,
|
|
8
|
+
size: t = r.SIZE,
|
|
9
|
+
level: c = r.LEVEL,
|
|
10
|
+
bgColor: s = r.BG_COLOR,
|
|
11
|
+
fgColor: g = r.FG_COLOR,
|
|
12
|
+
includeMargin: d = r.INCLUDE_MARGIN,
|
|
13
|
+
imageUrl: f,
|
|
14
|
+
imageSize: E = r.IMAGE_SIZE,
|
|
15
|
+
className: R,
|
|
16
|
+
style: L,
|
|
17
|
+
testId: M
|
|
18
|
+
}) => {
|
|
19
|
+
const l = u(() => {
|
|
20
|
+
if (!n) return null;
|
|
21
|
+
const h = C(n, c), m = d ? 4 : 0, p = h.size + m * 2, a = t / p, O = D(h, a, m * a);
|
|
22
|
+
return { matrix: h, path: O, cellSize: a, margin: m, totalModules: p };
|
|
23
|
+
}, [n, c, t, d]);
|
|
24
|
+
if (!l) return null;
|
|
25
|
+
const o = t * E, i = (t - o) / 2;
|
|
26
|
+
return /* @__PURE__ */ x(
|
|
27
|
+
"svg",
|
|
28
|
+
{
|
|
29
|
+
className: w("Bear-QRCode", R),
|
|
30
|
+
width: t,
|
|
31
|
+
height: t,
|
|
32
|
+
viewBox: `0 0 ${t} ${t}`,
|
|
33
|
+
style: L,
|
|
34
|
+
"data-testid": M,
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ e("rect", { width: t, height: t, fill: s }),
|
|
37
|
+
/* @__PURE__ */ e("path", { d: l.path, fill: g }),
|
|
38
|
+
f && /* @__PURE__ */ x("g", { children: [
|
|
39
|
+
/* @__PURE__ */ e(
|
|
40
|
+
"rect",
|
|
41
|
+
{
|
|
42
|
+
x: i - 4,
|
|
43
|
+
y: i - 4,
|
|
44
|
+
width: o + 8,
|
|
45
|
+
height: o + 8,
|
|
46
|
+
fill: s,
|
|
47
|
+
rx: 4
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
/* @__PURE__ */ e(
|
|
51
|
+
"image",
|
|
52
|
+
{
|
|
53
|
+
href: f,
|
|
54
|
+
x: i,
|
|
55
|
+
y: i,
|
|
56
|
+
width: o,
|
|
57
|
+
height: o,
|
|
58
|
+
preserveAspectRatio: "xMidYMid slice"
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
] })
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
export {
|
|
67
|
+
Q as QRCode
|
|
68
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
export interface QRCodeProps {
|
|
3
|
+
/** The value to encode in the QR code */
|
|
4
|
+
value: string;
|
|
5
|
+
/** Size in pixels */
|
|
6
|
+
size?: number;
|
|
7
|
+
/** Error correction level */
|
|
8
|
+
level?: 'L' | 'M' | 'Q' | 'H';
|
|
9
|
+
/** Background color */
|
|
10
|
+
bgColor?: string;
|
|
11
|
+
/** Foreground color */
|
|
12
|
+
fgColor?: string;
|
|
13
|
+
/** Include margin (quiet zone) */
|
|
14
|
+
includeMargin?: boolean;
|
|
15
|
+
/** Center image URL */
|
|
16
|
+
imageUrl?: string;
|
|
17
|
+
/** Center image size (as percentage of QR code size) */
|
|
18
|
+
imageSize?: number;
|
|
19
|
+
/** Render as canvas or SVG */
|
|
20
|
+
renderAs?: 'canvas' | 'svg';
|
|
21
|
+
/** Custom class name */
|
|
22
|
+
className?: string;
|
|
23
|
+
/** Custom style */
|
|
24
|
+
style?: CSSProperties;
|
|
25
|
+
/** Test ID */
|
|
26
|
+
testId?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface QRCodeCell {
|
|
29
|
+
row: number;
|
|
30
|
+
col: number;
|
|
31
|
+
isDark: boolean;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function y(a,i){const f=[17,32,53,78,106,134,154,192,230],r=i==="L"?1:i==="M"?.85:i==="Q"?.65:.5;for(let e=1;e<=9;e++)if(a<=f[e-1]*r)return e;return 9}function v(a,i="M"){const f=y(a.length,i),r=f*4+17,e=Array(r).fill(null).map(()=>Array(r).fill(!1)),h=(t,n)=>{for(let o=-1;o<=7;o++)for(let s=-1;s<=7;s++){const c=t+o,d=n+s;if(c>=0&&c<r&&d>=0&&d<r){const M=o===-1||o===7||s===-1||s===7,p=o>=1&&o<=5&&s>=1&&s<=5,x=o>=2&&o<=4&&s>=2&&s<=4;e[c][d]=!M&&(x||!p)}}};h(0,0),h(0,r-7),h(r-7,0);for(let t=8;t<r-8;t++)e[6][t]=t%2===0,e[t][6]=t%2===0;if(f>=2){const t=r-7;for(let n=-2;n<=2;n++)for(let o=-2;o<=2;o++){const s=t+n,c=t+o;if(s>=0&&s<r&&c>=0&&c<r){const d=Math.abs(n)===2||Math.abs(o)===2,M=n===0&&o===0;e[s][c]=d||M}}}const l=new TextEncoder().encode(a);let u=0,g=0;for(let t=r-1;t>=1;t-=2){t===6&&(t=5);for(let n=0;n<r;n++)for(let o=0;o<2;o++){const s=t-o,c=(t+1)%4<2?r-1-n:n;if(!b(c,s,r,f))if(u<l.length){const d=l[u]>>7-g&1;e[c][s]=d===1,g++,g===8&&(g=0,u++)}else e[c][s]=(c+s)%2===0}}for(let t=0;t<r;t++)for(let n=0;n<r;n++)b(t,n,r,f)||(t+n)%2===0&&(e[t][n]=!e[t][n]);return{size:r,modules:e}}function b(a,i,f,r){if(a<=8&&i<=8||a<=8&&i>=f-8||a>=f-8&&i<=8||a===6||i===6)return!0;if(r>=2){const e=f-7;if(Math.abs(a-e)<=2&&Math.abs(i-e)<=2)return!0}return!1}function P(a,i,f){const{size:r,modules:e}=a;let h="";for(let l=0;l<r;l++)for(let u=0;u<r;u++)if(e[l][u]){const g=f+u*i,t=f+l*i;h+=`M${g},${t}h${i}v${i}h-${i}z`}return h}exports.generateQRMatrix=v;exports.matrixToSvgPath=P;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simplified QR Code generator utilities
|
|
3
|
+
* Note: For production, consider using a dedicated library like 'qrcode'
|
|
4
|
+
* This is a basic implementation for demonstration purposes
|
|
5
|
+
*/
|
|
6
|
+
interface QRMatrix {
|
|
7
|
+
size: number;
|
|
8
|
+
modules: boolean[][];
|
|
9
|
+
}
|
|
10
|
+
export declare function generateQRMatrix(text: string, level?: string): QRMatrix;
|
|
11
|
+
export declare function matrixToSvgPath(matrix: QRMatrix, cellSize: number, margin: number): string;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
function y(c, f) {
|
|
2
|
+
const i = [17, 32, 53, 78, 106, 134, 154, 192, 230], n = f === "L" ? 1 : f === "M" ? 0.85 : f === "Q" ? 0.65 : 0.5;
|
|
3
|
+
for (let r = 1; r <= 9; r++)
|
|
4
|
+
if (c <= i[r - 1] * n) return r;
|
|
5
|
+
return 9;
|
|
6
|
+
}
|
|
7
|
+
function $(c, f = "M") {
|
|
8
|
+
const i = y(c.length, f), n = i * 4 + 17, r = Array(n).fill(null).map(() => Array(n).fill(!1)), h = (t, e) => {
|
|
9
|
+
for (let o = -1; o <= 7; o++)
|
|
10
|
+
for (let s = -1; s <= 7; s++) {
|
|
11
|
+
const a = t + o, d = e + s;
|
|
12
|
+
if (a >= 0 && a < n && d >= 0 && d < n) {
|
|
13
|
+
const M = o === -1 || o === 7 || s === -1 || s === 7, x = o >= 1 && o <= 5 && s >= 1 && s <= 5, g = o >= 2 && o <= 4 && s >= 2 && s <= 4;
|
|
14
|
+
r[a][d] = !M && (g || !x);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
h(0, 0), h(0, n - 7), h(n - 7, 0);
|
|
19
|
+
for (let t = 8; t < n - 8; t++)
|
|
20
|
+
r[6][t] = t % 2 === 0, r[t][6] = t % 2 === 0;
|
|
21
|
+
if (i >= 2) {
|
|
22
|
+
const t = n - 7;
|
|
23
|
+
for (let e = -2; e <= 2; e++)
|
|
24
|
+
for (let o = -2; o <= 2; o++) {
|
|
25
|
+
const s = t + e, a = t + o;
|
|
26
|
+
if (s >= 0 && s < n && a >= 0 && a < n) {
|
|
27
|
+
const d = Math.abs(e) === 2 || Math.abs(o) === 2, M = e === 0 && o === 0;
|
|
28
|
+
r[s][a] = d || M;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const l = new TextEncoder().encode(c);
|
|
33
|
+
let u = 0, p = 0;
|
|
34
|
+
for (let t = n - 1; t >= 1; t -= 2) {
|
|
35
|
+
t === 6 && (t = 5);
|
|
36
|
+
for (let e = 0; e < n; e++)
|
|
37
|
+
for (let o = 0; o < 2; o++) {
|
|
38
|
+
const s = t - o, a = (t + 1) % 4 < 2 ? n - 1 - e : e;
|
|
39
|
+
if (!b(a, s, n, i))
|
|
40
|
+
if (u < l.length) {
|
|
41
|
+
const d = l[u] >> 7 - p & 1;
|
|
42
|
+
r[a][s] = d === 1, p++, p === 8 && (p = 0, u++);
|
|
43
|
+
} else
|
|
44
|
+
r[a][s] = (a + s) % 2 === 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
for (let t = 0; t < n; t++)
|
|
48
|
+
for (let e = 0; e < n; e++)
|
|
49
|
+
b(t, e, n, i) || (t + e) % 2 === 0 && (r[t][e] = !r[t][e]);
|
|
50
|
+
return { size: n, modules: r };
|
|
51
|
+
}
|
|
52
|
+
function b(c, f, i, n) {
|
|
53
|
+
if (c <= 8 && f <= 8 || c <= 8 && f >= i - 8 || c >= i - 8 && f <= 8 || c === 6 || f === 6) return !0;
|
|
54
|
+
if (n >= 2) {
|
|
55
|
+
const r = i - 7;
|
|
56
|
+
if (Math.abs(c - r) <= 2 && Math.abs(f - r) <= 2) return !0;
|
|
57
|
+
}
|
|
58
|
+
return !1;
|
|
59
|
+
}
|
|
60
|
+
function v(c, f, i) {
|
|
61
|
+
const { size: n, modules: r } = c;
|
|
62
|
+
let h = "";
|
|
63
|
+
for (let l = 0; l < n; l++)
|
|
64
|
+
for (let u = 0; u < n; u++)
|
|
65
|
+
if (r[l][u]) {
|
|
66
|
+
const p = i + u * f, t = i + l * f;
|
|
67
|
+
h += `M${p},${t}h${f}v${f}h-${f}z`;
|
|
68
|
+
}
|
|
69
|
+
return h;
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
$ as generateQRMatrix,
|
|
73
|
+
v as matrixToSvgPath
|
|
74
|
+
};
|
|
@@ -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 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
|
+
};
|
|
@@ -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
|
+
};
|