@forgedevstack/bear 1.0.9 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -1
- package/dist/components/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.js +56 -55
- package/dist/components/Button/Button.types.d.ts +7 -0
- package/dist/components/FileTree/FileTree.cjs +1 -0
- package/dist/components/FileTree/FileTree.d.ts +3 -0
- package/dist/components/FileTree/FileTree.js +46 -0
- package/dist/components/FileTree/FileTree.types.d.ts +30 -0
- package/dist/components/FileTree/index.d.ts +2 -0
- package/dist/components/ResizablePanel/ResizablePanel.cjs +1 -0
- package/dist/components/ResizablePanel/ResizablePanel.const.cjs +1 -0
- package/dist/components/ResizablePanel/ResizablePanel.const.d.ts +11 -0
- package/dist/components/ResizablePanel/ResizablePanel.const.js +11 -0
- package/dist/components/ResizablePanel/ResizablePanel.d.ts +17 -0
- package/dist/components/ResizablePanel/ResizablePanel.js +70 -0
- package/dist/components/ResizablePanel/ResizablePanel.types.d.ts +21 -0
- package/dist/components/ResizablePanel/ResizablePanel.utils.cjs +1 -0
- package/dist/components/ResizablePanel/ResizablePanel.utils.d.ts +10 -0
- package/dist/components/ResizablePanel/ResizablePanel.utils.js +11 -0
- package/dist/components/ResizablePanel/index.d.ts +2 -0
- package/dist/components/ResizableTextarea/ResizableTextarea.cjs +1 -0
- package/dist/components/ResizableTextarea/ResizableTextarea.const.cjs +1 -0
- package/dist/components/ResizableTextarea/ResizableTextarea.const.d.ts +2 -0
- package/dist/components/ResizableTextarea/ResizableTextarea.const.js +5 -0
- package/dist/components/ResizableTextarea/ResizableTextarea.d.ts +3 -0
- package/dist/components/ResizableTextarea/ResizableTextarea.js +60 -0
- package/dist/components/ResizableTextarea/ResizableTextarea.types.d.ts +15 -0
- package/dist/components/ResizableTextarea/index.d.ts +2 -0
- package/dist/components/Typewriter/Typewriter.cjs +1 -1
- package/dist/components/Typewriter/Typewriter.js +59 -65
- package/dist/components/Typography/Typography.cjs +1 -1
- package/dist/components/Typography/Typography.const.cjs +1 -0
- package/dist/components/Typography/Typography.const.d.ts +22 -0
- package/dist/components/Typography/Typography.const.js +91 -0
- package/dist/components/Typography/Typography.js +75 -138
- package/dist/components/Typography/Typography.types.d.ts +17 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.js +245 -239
- package/dist/index.cjs +1 -1
- package/dist/index.js +277 -271
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,6 +62,7 @@ function App() {
|
|
|
62
62
|
- `Container` - Responsive container with max-width constraints
|
|
63
63
|
- `Flex` - Flexible box layout component
|
|
64
64
|
- `Grid` / `GridItem` - CSS Grid layout system
|
|
65
|
+
- `ResizablePanel` - Two-pane resizable layout with draggable divider (horizontal/vertical)
|
|
65
66
|
|
|
66
67
|
### UI Components
|
|
67
68
|
|
|
@@ -70,7 +71,7 @@ function App() {
|
|
|
70
71
|
- `Badge` - Status indicators and labels
|
|
71
72
|
- `Paper` - Elevated surface component
|
|
72
73
|
- `Divider` - Visual separator
|
|
73
|
-
- `Typography` - Text styling
|
|
74
|
+
- `Typography` - Text styling with gradient text and typewriter effect
|
|
74
75
|
- `Link` - Styled link component
|
|
75
76
|
|
|
76
77
|
### Form Components
|
|
@@ -120,6 +121,7 @@ function App() {
|
|
|
120
121
|
- `Avatar` / `AvatarGroup` - User avatar display
|
|
121
122
|
- `Chip` - Compact element for input, attribute, or action
|
|
122
123
|
- `TreeView` - Hierarchical tree structure
|
|
124
|
+
- `FileTree` - File/folder tree with selection and expand/collapse
|
|
123
125
|
- `Timeline` - Timeline component
|
|
124
126
|
- `Statistic` - Statistical display
|
|
125
127
|
- `EmptyState` - Empty state placeholder
|
|
@@ -153,8 +155,16 @@ import { Button } from '@forgedevstack/bear';
|
|
|
153
155
|
<Button variant="secondary">Secondary</Button>
|
|
154
156
|
<Button variant="outline">Outline</Button>
|
|
155
157
|
<Button variant="ghost">Ghost</Button>
|
|
158
|
+
|
|
159
|
+
// With icon (icon size matches text)
|
|
160
|
+
<Button variant="primary" leftIcon={<PlayIcon />}>View Demos</Button>
|
|
161
|
+
|
|
162
|
+
// Button label using Typography variant (h1, h2, body1, etc.)
|
|
163
|
+
<Button variant="primary" textVariant="subtitle1">Heading-style label</Button>
|
|
156
164
|
```
|
|
157
165
|
|
|
166
|
+
**Custom variants** (via `BearProvider`): pass `customVariants={{ myBrand: { bg: '#...', text: '#fff' } }}` and use `<Button variant="myBrand">`. Use `customTypography` for custom text styles and set `textVariant` on Button to use them.
|
|
167
|
+
|
|
158
168
|
### Card
|
|
159
169
|
|
|
160
170
|
```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),r=require("react"),A=require("../../utils/cn.cjs"),re=require("../Spinner/Spinner.cjs"),ne=require("../Typography/Typography.cjs"),se=require("../../hooks/useBearStyles.cjs");require("../../hooks/useBearComponent/useBearComponent.cjs");const oe=require("../../context/BearProvider.cjs"),b=require("./Button.constants.cjs"),V=B=>B in b.BUTTON_VARIANT,k=r.forwardRef((B,i)=>{var w,j;const{variant:e="primary",size:C="md",loading:d=!1,fullWidth:q=!1,icon:g,iconPosition:N="left",leftIcon:M,rightIcon:P,textVariant:z="inherit",spotlight:l=!1,spotlightColor:E="rgba(255, 255, 255, 0.35)",spotlightSize:f=150,disabled:U,className:O,children:D,testId:L,bis:F,style:H,onMouseMove:h,onMouseEnter:m,onMouseLeave:p,...X}=B,Y=U||d,v=se.useBearStyles(F,H),S=M??(g&&N==="left"?g:void 0),I=P??(g&&N==="right"?g:void 0),o=r.useContext(oe.BearContext),y=((j=(w=o==null?void 0:o.components)==null?void 0:w.Button)==null?void 0:j.root)||{},T=(o==null?void 0:o.customVariants)||{},x=!V(e)&&e in T,n=x?T[e]:null,c=r.useRef(null),[R,_]=r.useState({x:-1e3,y:-1e3}),[W,$]=r.useState(!1),Z=r.useCallback(t=>{if(l&&c.current){const u=c.current.getBoundingClientRect(),ee=t.clientX-u.left,te=t.clientY-u.top;_({x:ee,y:te})}h==null||h(t)},[l,h]),G=r.useCallback(t=>{if(l&&($(!0),c.current)){const u=c.current.getBoundingClientRect();_({x:t.clientX-u.left,y:t.clientY-u.top})}m==null||m(t)},[l,m]),J=r.useCallback(t=>{$(!1),_({x:-1e3,y:-1e3}),p==null||p(t)},[p]),a=b.VARIANT_DEFAULTS[e]||b.VARIANT_DEFAULTS.primary,K=r.useMemo(()=>x&&n?{backgroundColor:`var(--bear-${e}-bg, ${n.bg})`,color:n.text||"#ffffff",borderColor:n.border,"--bear-ring-color":n.ring||n.bg,...y,...v}:{backgroundColor:`var(--bear-btn-${e}-bg, ${a.bg})`,color:e==="outline"||e==="ghost"?`var(--bear-btn-${e}-text, ${a.text||"inherit"})`:"white",borderColor:e==="outline"?`var(--bear-btn-${e}-border, ${a.border||a.bg})`:void 0,"--bear-ring-color":`var(--bear-btn-${e}-ring, ${a.ring})`,...y,...v},[e,a,y,v,x,n]),Q=r.useCallback(t=>{c.current=t,typeof i=="function"?i(t):i&&(i.current=t)},[i]);return s.jsxs("button",{ref:Q,disabled:Y,style:K,className:A.cn("Bear-Button","bear-inline-flex bear-items-center bear-justify-center bear-font-medium bear-rounded-lg bear-transition-all bear-duration-200 bear-outline-none bear-relative bear-overflow-hidden",b.BUTTON_SIZE[C],V(e)?b.BUTTON_VARIANT[e]:"bear-btn-custom bear-text-white focus:bear-ring-2 focus:bear-ring-offset-2 disabled:bear-opacity-50 disabled:bear-cursor-not-allowed hover:bear-brightness-110 active:bear-brightness-95",q&&"bear-w-full",d&&"bear-cursor-wait",O),"data-testid":L,onMouseMove:Z,onMouseEnter:G,onMouseLeave:J,...X,children:[l&&s.jsx("span",{className:"Bear-Button__spotlight","aria-hidden":"true",style:{position:"absolute",pointerEvents:"none",left:0,top:0,width:f,height:f,borderRadius:"50%",background:`radial-gradient(circle at center, ${E} 0%, transparent 70%)`,opacity:W?1:0,transform:`translate(${R.x-f/2}px, ${R.y-f/2}px)`,transition:"opacity 0.15s ease-out",zIndex:1,mixBlendMode:"overlay"}}),d&&s.jsx(re.Spinner,{size:C==="xs"?"xs":"sm",className:"Bear-Button__spinner bear-absolute"}),s.jsxs("span",{className:A.cn("Bear-Button__content bear-inline-flex bear-items-center bear-gap-inherit bear-relative bear-z-10",d&&"bear-invisible"),children:[S&&s.jsx("span",{className:"Bear-Button__icon Bear-Button__icon--left bear-inline-flex bear-shrink-0 [&_svg]:bear-w-[1em] [&_svg]:bear-h-[1em] [&_svg]:bear-min-w-[1em]",children:S}),s.jsx(ne.Typography,{variant:z,className:"Bear-Button__text",children:D}),I&&s.jsx("span",{className:"Bear-Button__icon Bear-Button__icon--right bear-inline-flex bear-shrink-0 [&_svg]:bear-w-[1em] [&_svg]:bear-h-[1em] [&_svg]:bear-min-w-[1em]",children:I})]})]})});k.displayName="Button";exports.Button=k;
|
|
@@ -1,92 +1,93 @@
|
|
|
1
1
|
import { jsxs as V, jsx as c } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as
|
|
2
|
+
import { forwardRef as oe, useContext as ae, useRef as ie, useState as k, useCallback as p, useMemo as se } from "react";
|
|
3
3
|
import { cn as M } from "../../utils/cn.js";
|
|
4
|
-
import { Spinner as
|
|
5
|
-
import { Typography as
|
|
6
|
-
import { useBearStyles as
|
|
4
|
+
import { Spinner as le } from "../Spinner/Spinner.js";
|
|
5
|
+
import { Typography as ce } from "../Typography/Typography.js";
|
|
6
|
+
import { useBearStyles as be } from "../../hooks/useBearStyles.js";
|
|
7
7
|
import "../../hooks/useBearComponent/useBearComponent.js";
|
|
8
|
-
import { BearContext as
|
|
9
|
-
import { VARIANT_DEFAULTS as z, BUTTON_VARIANT as P, BUTTON_SIZE as
|
|
10
|
-
const A = (h) => h in P,
|
|
8
|
+
import { BearContext as ue } from "../../context/BearProvider.js";
|
|
9
|
+
import { VARIANT_DEFAULTS as z, BUTTON_VARIANT as P, BUTTON_SIZE as de } from "./Button.constants.js";
|
|
10
|
+
const A = (h) => h in P, me = oe(
|
|
11
11
|
(h, a) => {
|
|
12
|
-
var
|
|
12
|
+
var R, T;
|
|
13
13
|
const {
|
|
14
14
|
variant: e = "primary",
|
|
15
|
-
size:
|
|
15
|
+
size: x = "md",
|
|
16
16
|
loading: b = !1,
|
|
17
17
|
fullWidth: E = !1,
|
|
18
18
|
icon: u,
|
|
19
19
|
iconPosition: C = "left",
|
|
20
20
|
leftIcon: j,
|
|
21
21
|
rightIcon: U,
|
|
22
|
+
textVariant: D = "inherit",
|
|
22
23
|
spotlight: i = !1,
|
|
23
|
-
spotlightColor:
|
|
24
|
+
spotlightColor: H = "rgba(255, 255, 255, 0.35)",
|
|
24
25
|
spotlightSize: d = 150,
|
|
25
|
-
disabled:
|
|
26
|
-
className:
|
|
27
|
-
children:
|
|
28
|
-
testId:
|
|
29
|
-
bis:
|
|
30
|
-
style:
|
|
31
|
-
onMouseMove:
|
|
32
|
-
onMouseEnter:
|
|
33
|
-
onMouseLeave:
|
|
34
|
-
...
|
|
35
|
-
} = h,
|
|
26
|
+
disabled: L,
|
|
27
|
+
className: O,
|
|
28
|
+
children: X,
|
|
29
|
+
testId: Y,
|
|
30
|
+
bis: F,
|
|
31
|
+
style: W,
|
|
32
|
+
onMouseMove: m,
|
|
33
|
+
onMouseEnter: f,
|
|
34
|
+
onMouseLeave: g,
|
|
35
|
+
...Z
|
|
36
|
+
} = h, q = L || b, v = be(F, W), I = j ?? (u && C === "left" ? u : void 0), N = U ?? (u && C === "right" ? u : void 0), n = ae(ue), B = ((T = (R = n == null ? void 0 : n.components) == null ? void 0 : R.Button) == null ? void 0 : T.root) || {}, $ = (n == null ? void 0 : n.customVariants) || {}, y = !A(e) && e in $, r = y ? $[e] : null, s = ie(null), [w, _] = k({ x: -1e3, y: -1e3 }), [G, S] = k(!1), J = p((t) => {
|
|
36
37
|
if (i && s.current) {
|
|
37
|
-
const l = s.current.getBoundingClientRect(),
|
|
38
|
-
|
|
38
|
+
const l = s.current.getBoundingClientRect(), re = t.clientX - l.left, ne = t.clientY - l.top;
|
|
39
|
+
_({ x: re, y: ne });
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
}, [i,
|
|
42
|
-
if (i && (
|
|
41
|
+
m == null || m(t);
|
|
42
|
+
}, [i, m]), K = p((t) => {
|
|
43
|
+
if (i && (S(!0), s.current)) {
|
|
43
44
|
const l = s.current.getBoundingClientRect();
|
|
44
|
-
|
|
45
|
+
_({
|
|
45
46
|
x: t.clientX - l.left,
|
|
46
47
|
y: t.clientY - l.top
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
}, [i,
|
|
51
|
-
|
|
52
|
-
}, [
|
|
50
|
+
f == null || f(t);
|
|
51
|
+
}, [i, f]), Q = p((t) => {
|
|
52
|
+
S(!1), _({ x: -1e3, y: -1e3 }), g == null || g(t);
|
|
53
|
+
}, [g]), o = z[e] || z.primary, ee = se(() => y && r ? {
|
|
53
54
|
backgroundColor: `var(--bear-${e}-bg, ${r.bg})`,
|
|
54
55
|
color: r.text || "#ffffff",
|
|
55
56
|
borderColor: r.border,
|
|
56
57
|
"--bear-ring-color": r.ring || r.bg,
|
|
57
|
-
...
|
|
58
|
-
...
|
|
58
|
+
...B,
|
|
59
|
+
...v
|
|
59
60
|
} : {
|
|
60
61
|
backgroundColor: `var(--bear-btn-${e}-bg, ${o.bg})`,
|
|
61
62
|
color: e === "outline" || e === "ghost" ? `var(--bear-btn-${e}-text, ${o.text || "inherit"})` : "white",
|
|
62
63
|
borderColor: e === "outline" ? `var(--bear-btn-${e}-border, ${o.border || o.bg})` : void 0,
|
|
63
64
|
"--bear-ring-color": `var(--bear-btn-${e}-ring, ${o.ring})`,
|
|
64
|
-
...
|
|
65
|
-
...
|
|
66
|
-
}, [e, o,
|
|
65
|
+
...B,
|
|
66
|
+
...v
|
|
67
|
+
}, [e, o, B, v, y, r]), te = p((t) => {
|
|
67
68
|
s.current = t, typeof a == "function" ? a(t) : a && (a.current = t);
|
|
68
69
|
}, [a]);
|
|
69
70
|
return /* @__PURE__ */ V(
|
|
70
71
|
"button",
|
|
71
72
|
{
|
|
72
|
-
ref:
|
|
73
|
-
disabled:
|
|
74
|
-
style:
|
|
73
|
+
ref: te,
|
|
74
|
+
disabled: q,
|
|
75
|
+
style: ee,
|
|
75
76
|
className: M(
|
|
76
77
|
"Bear-Button",
|
|
77
78
|
"bear-inline-flex bear-items-center bear-justify-center bear-font-medium bear-rounded-lg bear-transition-all bear-duration-200 bear-outline-none bear-relative bear-overflow-hidden",
|
|
78
|
-
|
|
79
|
+
de[x],
|
|
79
80
|
// Use built-in variant classes or custom variant base classes
|
|
80
81
|
A(e) ? P[e] : "bear-btn-custom bear-text-white focus:bear-ring-2 focus:bear-ring-offset-2 disabled:bear-opacity-50 disabled:bear-cursor-not-allowed hover:bear-brightness-110 active:bear-brightness-95",
|
|
81
82
|
E && "bear-w-full",
|
|
82
83
|
b && "bear-cursor-wait",
|
|
83
|
-
|
|
84
|
+
O
|
|
84
85
|
),
|
|
85
|
-
"data-testid":
|
|
86
|
-
onMouseMove:
|
|
87
|
-
onMouseEnter:
|
|
88
|
-
onMouseLeave:
|
|
89
|
-
...
|
|
86
|
+
"data-testid": Y,
|
|
87
|
+
onMouseMove: J,
|
|
88
|
+
onMouseEnter: K,
|
|
89
|
+
onMouseLeave: Q,
|
|
90
|
+
...Z,
|
|
90
91
|
children: [
|
|
91
92
|
i && /* @__PURE__ */ c(
|
|
92
93
|
"span",
|
|
@@ -101,16 +102,16 @@ const A = (h) => h in P, de = ne(
|
|
|
101
102
|
width: d,
|
|
102
103
|
height: d,
|
|
103
104
|
borderRadius: "50%",
|
|
104
|
-
background: `radial-gradient(circle at center, ${
|
|
105
|
-
opacity:
|
|
106
|
-
transform: `translate(${
|
|
105
|
+
background: `radial-gradient(circle at center, ${H} 0%, transparent 70%)`,
|
|
106
|
+
opacity: G ? 1 : 0,
|
|
107
|
+
transform: `translate(${w.x - d / 2}px, ${w.y - d / 2}px)`,
|
|
107
108
|
transition: "opacity 0.15s ease-out",
|
|
108
109
|
zIndex: 1,
|
|
109
110
|
mixBlendMode: "overlay"
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
),
|
|
113
|
-
b && /* @__PURE__ */ c(
|
|
114
|
+
b && /* @__PURE__ */ c(le, { size: x === "xs" ? "xs" : "sm", className: "Bear-Button__spinner bear-absolute" }),
|
|
114
115
|
/* @__PURE__ */ V(
|
|
115
116
|
"span",
|
|
116
117
|
{
|
|
@@ -119,9 +120,9 @@ const A = (h) => h in P, de = ne(
|
|
|
119
120
|
b && "bear-invisible"
|
|
120
121
|
),
|
|
121
122
|
children: [
|
|
122
|
-
I && /* @__PURE__ */ c("span", { className: "Bear-Button__icon Bear-Button__icon--left bear-inline-flex bear-shrink-0", children: I }),
|
|
123
|
-
/* @__PURE__ */ c(
|
|
124
|
-
N && /* @__PURE__ */ c("span", { className: "Bear-Button__icon Bear-Button__icon--right bear-inline-flex bear-shrink-0", children: N })
|
|
123
|
+
I && /* @__PURE__ */ c("span", { className: "Bear-Button__icon Bear-Button__icon--left bear-inline-flex bear-shrink-0 [&_svg]:bear-w-[1em] [&_svg]:bear-h-[1em] [&_svg]:bear-min-w-[1em]", children: I }),
|
|
124
|
+
/* @__PURE__ */ c(ce, { variant: D, className: "Bear-Button__text", children: X }),
|
|
125
|
+
N && /* @__PURE__ */ c("span", { className: "Bear-Button__icon Bear-Button__icon--right bear-inline-flex bear-shrink-0 [&_svg]:bear-w-[1em] [&_svg]:bear-h-[1em] [&_svg]:bear-min-w-[1em]", children: N })
|
|
125
126
|
]
|
|
126
127
|
}
|
|
127
128
|
)
|
|
@@ -130,7 +131,7 @@ const A = (h) => h in P, de = ne(
|
|
|
130
131
|
);
|
|
131
132
|
}
|
|
132
133
|
);
|
|
133
|
-
|
|
134
|
+
me.displayName = "Button";
|
|
134
135
|
export {
|
|
135
|
-
|
|
136
|
+
me as Button
|
|
136
137
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
import { BearSize, BearVariant } from '../../types';
|
|
3
3
|
import { BisProp } from '../../types/bis.types';
|
|
4
|
+
import { TypographyVariant } from '../Typography/Typography.types';
|
|
4
5
|
export interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'style'> {
|
|
5
6
|
/**
|
|
6
7
|
* Button variant style
|
|
@@ -30,6 +31,12 @@ export interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement
|
|
|
30
31
|
leftIcon?: ReactNode;
|
|
31
32
|
/** Icon to show after text */
|
|
32
33
|
rightIcon?: ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* Typography variant for the button label (e.g. h1, h2, body1).
|
|
36
|
+
* Use with BearProvider customTypography to add your own variants.
|
|
37
|
+
* @default 'inherit'
|
|
38
|
+
*/
|
|
39
|
+
textVariant?: TypographyVariant;
|
|
33
40
|
/** Enable mouse-follow spotlight hover effect */
|
|
34
41
|
spotlight?: boolean;
|
|
35
42
|
/** Spotlight color (default: rgba(255, 255, 255, 0.15)) */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),x=require("react"),b=require("../TreeView/TreeView.cjs"),T=require("../Icon/index.cjs"),j=()=>t.jsx(T.BearIcons.ArticleIcon,{size:"xs",className:"bear-text-gray-400"});function l(e,a=0){var r;const s=e.children&&e.children.length>0,i=e.type==="folder"||s;return{id:e.id,label:e.label,disabled:e.disabled,data:e.data,icon:e.icon??(i?void 0:t.jsx(j,{})),children:(r=e.children)==null?void 0:r.map(c=>l(c,a+1))}}const m=({items:e,selectedId:a,defaultExpandedIds:s=[],onSelect:i,onExpand:r,size:c="md",showLines:d=!1,className:n,testId:o})=>{const u=x.useMemo(()=>e.map(l),[e]);return t.jsx("div",{"data-testid":o,children:t.jsx(b.TreeView,{data:u,selectedId:a,defaultExpandedIds:s,onSelect:i?h=>i(h.data):void 0,onExpand:r,size:c,showLines:d,className:n})})};exports.FileTree=m;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as h } from "react";
|
|
3
|
+
import { TreeView as p } from "../TreeView/TreeView.js";
|
|
4
|
+
import { BearIcons as b } from "../Icon/index.js";
|
|
5
|
+
const u = () => /* @__PURE__ */ t(b.ArticleIcon, { size: "xs", className: "bear-text-gray-400" });
|
|
6
|
+
function c(e, a = 0) {
|
|
7
|
+
var i;
|
|
8
|
+
const l = e.children && e.children.length > 0, r = e.type === "folder" || l;
|
|
9
|
+
return {
|
|
10
|
+
id: e.id,
|
|
11
|
+
label: e.label,
|
|
12
|
+
disabled: e.disabled,
|
|
13
|
+
data: e.data,
|
|
14
|
+
icon: e.icon ?? (r ? void 0 : /* @__PURE__ */ t(u, {})),
|
|
15
|
+
children: (i = e.children) == null ? void 0 : i.map((o) => c(o, a + 1))
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const I = ({
|
|
19
|
+
items: e,
|
|
20
|
+
selectedId: a,
|
|
21
|
+
defaultExpandedIds: l = [],
|
|
22
|
+
onSelect: r,
|
|
23
|
+
onExpand: i,
|
|
24
|
+
size: o = "md",
|
|
25
|
+
showLines: d = !1,
|
|
26
|
+
className: s,
|
|
27
|
+
testId: n
|
|
28
|
+
}) => {
|
|
29
|
+
const m = h(() => e.map(c), [e]);
|
|
30
|
+
return /* @__PURE__ */ t("div", { "data-testid": n, children: /* @__PURE__ */ t(
|
|
31
|
+
p,
|
|
32
|
+
{
|
|
33
|
+
data: m,
|
|
34
|
+
selectedId: a,
|
|
35
|
+
defaultExpandedIds: l,
|
|
36
|
+
onSelect: r ? (f) => r(f.data) : void 0,
|
|
37
|
+
onExpand: i,
|
|
38
|
+
size: o,
|
|
39
|
+
showLines: d,
|
|
40
|
+
className: s
|
|
41
|
+
}
|
|
42
|
+
) });
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
I as FileTree
|
|
46
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface FileTreeNode {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
type: 'file' | 'folder';
|
|
6
|
+
children?: FileTreeNode[];
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
data?: unknown;
|
|
10
|
+
}
|
|
11
|
+
export interface FileTreeProps {
|
|
12
|
+
/** Tree data (files and folders) */
|
|
13
|
+
items: FileTreeNode[];
|
|
14
|
+
/** Selected node id */
|
|
15
|
+
selectedId?: string;
|
|
16
|
+
/** Initially expanded folder ids */
|
|
17
|
+
defaultExpandedIds?: string[];
|
|
18
|
+
/** Called when a node is selected */
|
|
19
|
+
onSelect?: (node: FileTreeNode) => void;
|
|
20
|
+
/** Called when a folder is expanded/collapsed */
|
|
21
|
+
onExpand?: (nodeId: string, expanded: boolean) => void;
|
|
22
|
+
/** Size variant */
|
|
23
|
+
size?: 'sm' | 'md' | 'lg';
|
|
24
|
+
/** Show connecting lines */
|
|
25
|
+
showLines?: boolean;
|
|
26
|
+
/** Class name */
|
|
27
|
+
className?: string;
|
|
28
|
+
/** Test ID */
|
|
29
|
+
testId?: string;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),l=require("react"),e=require("./ResizablePanel.const.cjs"),v=require("./ResizablePanel.utils.cjs"),_=require("../../utils/cn.cjs"),L=P=>{const{first:I,second:N,direction:c=e.DEFAULT_DIRECTION,defaultSize:R=e.DEFAULT_FIRST_SIZE,minSize:d=e.MIN_SIZE,maxSize:b=e.MAX_SIZE,onResize:s,className:z,testId:T}=P,[t,g]=l.useState(R),u=l.useRef(null),h=l.useCallback(r=>v.clampSize(r,d,b),[d,b]),S=l.useCallback(r=>{var m;r.preventDefault();const n=r.target;(m=n.setPointerCapture)==null||m.call(n,r.pointerId);const E=i=>{if(!u.current)return;const D=u.current.getBoundingClientRect(),y=v.getResizePercentage(D,c,i.clientX,i.clientY),f=h(y);g(f),s==null||s(f)},w=()=>{var i;(i=n.releasePointerCapture)==null||i.call(n,r.pointerId),window.removeEventListener(e.EVENT_POINTER_MOVE,E),window.removeEventListener(e.EVENT_POINTER_UP,w)};window.addEventListener(e.EVENT_POINTER_MOVE,E),window.addEventListener(e.EVENT_POINTER_UP,w)},[c,h,s]),a=c==="horizontal",p=a?{width:`${t}%`,minWidth:0}:{height:`${t}%`,minHeight:0},x=a?{width:`${100-t}%`,minWidth:0}:{height:`${100-t}%`,minHeight:0};return o.jsxs("div",{ref:u,"data-testid":T,className:_.cn("Bear-ResizablePanel bear-flex bear-w-full bear-h-full bear-overflow-hidden",a?"bear-flex-row":"bear-flex-col",z),children:[o.jsx("div",{className:"bear-overflow-auto bear-shrink-0",style:p,children:I}),o.jsx("div",{role:"separator","aria-valuenow":t,"aria-valuemin":d,"aria-valuemax":b,tabIndex:0,onPointerDown:S,className:_.cn("Bear-ResizablePanel__handle bear-shrink-0 bear-bg-gray-200 dark:bear-bg-gray-700 hover:bear-bg-pink-500/30 bear-transition-colors bear-cursor-col-resize",a?"bear-w-1.5":"bear-h-1.5 bear-w-full bear-cursor-row-resize"),style:a?{width:e.HANDLE_WIDTH}:{height:e.HANDLE_WIDTH}}),o.jsx("div",{className:"bear-overflow-auto bear-shrink-0 bear-flex-1",style:x,children:N})]})};exports.ResizablePanel=L;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=50,_=10,T=90,I=6,o="horizontal",t="pointermove",N="pointerup",n=100;exports.DEFAULT_DIRECTION=o;exports.DEFAULT_FIRST_SIZE=E;exports.EVENT_POINTER_MOVE=t;exports.EVENT_POINTER_UP=N;exports.HANDLE_WIDTH=I;exports.MAX_SIZE=T;exports.MIN_SIZE=_;exports.PERCENTAGE_SCALE=n;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const DEFAULT_FIRST_SIZE = 50;
|
|
2
|
+
export declare const MIN_SIZE = 10;
|
|
3
|
+
export declare const MAX_SIZE = 90;
|
|
4
|
+
export declare const HANDLE_WIDTH = 6;
|
|
5
|
+
/** Default layout direction */
|
|
6
|
+
export declare const DEFAULT_DIRECTION = "horizontal";
|
|
7
|
+
/** DOM event names for resize listeners */
|
|
8
|
+
export declare const EVENT_POINTER_MOVE = "pointermove";
|
|
9
|
+
export declare const EVENT_POINTER_UP = "pointerup";
|
|
10
|
+
/** Percentage scale for size calculation */
|
|
11
|
+
export declare const PERCENTAGE_SCALE = 100;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const E = 50, o = 10, t = 90, n = 6, _ = "horizontal", I = "pointermove", T = "pointerup", c = 100;
|
|
2
|
+
export {
|
|
3
|
+
_ as DEFAULT_DIRECTION,
|
|
4
|
+
E as DEFAULT_FIRST_SIZE,
|
|
5
|
+
I as EVENT_POINTER_MOVE,
|
|
6
|
+
T as EVENT_POINTER_UP,
|
|
7
|
+
n as HANDLE_WIDTH,
|
|
8
|
+
t as MAX_SIZE,
|
|
9
|
+
o as MIN_SIZE,
|
|
10
|
+
c as PERCENTAGE_SCALE
|
|
11
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ResizablePanelProps } from './ResizablePanel.types';
|
|
3
|
+
/**
|
|
4
|
+
* Two-pane resizable layout with a draggable divider.
|
|
5
|
+
* Supports horizontal and vertical directions; respects min/max size and dark/light theme.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* <ResizablePanel
|
|
10
|
+
* first={<Sidebar />}
|
|
11
|
+
* second={<Main />}
|
|
12
|
+
* direction="horizontal"
|
|
13
|
+
* defaultSize={30}
|
|
14
|
+
* />
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const ResizablePanel: FC<ResizablePanelProps>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsxs as k, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { useState as C, useRef as H, useCallback as w } from "react";
|
|
3
|
+
import { DEFAULT_DIRECTION as A, DEFAULT_FIRST_SIZE as M, MIN_SIZE as O, MAX_SIZE as U, EVENT_POINTER_MOVE as p, EVENT_POINTER_UP as v, HANDLE_WIDTH as E } from "./ResizablePanel.const.js";
|
|
4
|
+
import { clampSize as $, getResizePercentage as B } from "./ResizablePanel.utils.js";
|
|
5
|
+
import { cn as I } from "../../utils/cn.js";
|
|
6
|
+
const X = (z) => {
|
|
7
|
+
const {
|
|
8
|
+
first: g,
|
|
9
|
+
second: N,
|
|
10
|
+
direction: o = A,
|
|
11
|
+
defaultSize: S = M,
|
|
12
|
+
minSize: s = O,
|
|
13
|
+
maxSize: l = U,
|
|
14
|
+
onResize: i,
|
|
15
|
+
className: _,
|
|
16
|
+
testId: P
|
|
17
|
+
} = z, [t, x] = C(S), c = H(null), b = w((e) => $(e, s, l), [s, l]), R = w(
|
|
18
|
+
(e) => {
|
|
19
|
+
var f;
|
|
20
|
+
e.preventDefault();
|
|
21
|
+
const r = e.target;
|
|
22
|
+
(f = r.setPointerCapture) == null || f.call(r, e.pointerId);
|
|
23
|
+
const m = (a) => {
|
|
24
|
+
if (!c.current) return;
|
|
25
|
+
const y = c.current.getBoundingClientRect(), L = B(y, o, a.clientX, a.clientY), u = b(L);
|
|
26
|
+
x(u), i == null || i(u);
|
|
27
|
+
}, h = () => {
|
|
28
|
+
var a;
|
|
29
|
+
(a = r.releasePointerCapture) == null || a.call(r, e.pointerId), window.removeEventListener(p, m), window.removeEventListener(v, h);
|
|
30
|
+
};
|
|
31
|
+
window.addEventListener(p, m), window.addEventListener(v, h);
|
|
32
|
+
},
|
|
33
|
+
[o, b, i]
|
|
34
|
+
), n = o === "horizontal", T = n ? { width: `${t}%`, minWidth: 0 } : { height: `${t}%`, minHeight: 0 }, D = n ? { width: `${100 - t}%`, minWidth: 0 } : { height: `${100 - t}%`, minHeight: 0 };
|
|
35
|
+
return /* @__PURE__ */ k(
|
|
36
|
+
"div",
|
|
37
|
+
{
|
|
38
|
+
ref: c,
|
|
39
|
+
"data-testid": P,
|
|
40
|
+
className: I(
|
|
41
|
+
"Bear-ResizablePanel bear-flex bear-w-full bear-h-full bear-overflow-hidden",
|
|
42
|
+
n ? "bear-flex-row" : "bear-flex-col",
|
|
43
|
+
_
|
|
44
|
+
),
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ d("div", { className: "bear-overflow-auto bear-shrink-0", style: T, children: g }),
|
|
47
|
+
/* @__PURE__ */ d(
|
|
48
|
+
"div",
|
|
49
|
+
{
|
|
50
|
+
role: "separator",
|
|
51
|
+
"aria-valuenow": t,
|
|
52
|
+
"aria-valuemin": s,
|
|
53
|
+
"aria-valuemax": l,
|
|
54
|
+
tabIndex: 0,
|
|
55
|
+
onPointerDown: R,
|
|
56
|
+
className: I(
|
|
57
|
+
"Bear-ResizablePanel__handle bear-shrink-0 bear-bg-gray-200 dark:bear-bg-gray-700 hover:bear-bg-pink-500/30 bear-transition-colors bear-cursor-col-resize",
|
|
58
|
+
n ? "bear-w-1.5" : "bear-h-1.5 bear-w-full bear-cursor-row-resize"
|
|
59
|
+
),
|
|
60
|
+
style: n ? { width: E } : { height: E }
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
/* @__PURE__ */ d("div", { className: "bear-overflow-auto bear-shrink-0 bear-flex-1", style: D, children: N })
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
export {
|
|
69
|
+
X as ResizablePanel
|
|
70
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface ResizablePanelProps {
|
|
3
|
+
/** First pane content */
|
|
4
|
+
first: ReactNode;
|
|
5
|
+
/** Second pane content */
|
|
6
|
+
second: ReactNode;
|
|
7
|
+
/** Layout direction */
|
|
8
|
+
direction?: 'horizontal' | 'vertical';
|
|
9
|
+
/** Default size of first pane (0–100, percentage) */
|
|
10
|
+
defaultSize?: number;
|
|
11
|
+
/** Minimum size of first pane (percentage) */
|
|
12
|
+
minSize?: number;
|
|
13
|
+
/** Maximum size of first pane (percentage) */
|
|
14
|
+
maxSize?: number;
|
|
15
|
+
/** Called when resize ends with new size (0–100) */
|
|
16
|
+
onResize?: (size: number) => void;
|
|
17
|
+
/** Class name for the root container */
|
|
18
|
+
className?: string;
|
|
19
|
+
/** Test ID */
|
|
20
|
+
testId?: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./ResizablePanel.const.cjs");function r(e,t,i,a){return t==="horizontal"?(i-e.left)/e.width*n.PERCENTAGE_SCALE:(a-e.top)/e.height*n.PERCENTAGE_SCALE}function o(e,t,i){return Math.min(i,Math.max(t,e))}exports.clampSize=o;exports.getResizePercentage=r;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ResizablePanelProps } from './ResizablePanel.types';
|
|
2
|
+
/**
|
|
3
|
+
* Compute first pane size as a percentage (0–100) from pointer position and container rect.
|
|
4
|
+
* Used for both horizontal and vertical layouts.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getResizePercentage(rect: DOMRect, direction: NonNullable<ResizablePanelProps['direction']>, clientX: number, clientY: number): number;
|
|
7
|
+
/**
|
|
8
|
+
* Clamp a value between min and max (inclusive).
|
|
9
|
+
*/
|
|
10
|
+
export declare function clampSize(value: number, min: number, max: number): number;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PERCENTAGE_SCALE as n } from "./ResizablePanel.const.js";
|
|
2
|
+
function a(t, e, i, o) {
|
|
3
|
+
return e === "horizontal" ? (i - t.left) / t.width * n : (o - t.top) / t.height * n;
|
|
4
|
+
}
|
|
5
|
+
function h(t, e, i) {
|
|
6
|
+
return Math.min(i, Math.max(e, t));
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
h as clampSize,
|
|
10
|
+
a as getResizePercentage
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),o=require("react"),f=require("../../utils/cn.cjs"),w=require("./ResizableTextarea.const.cjs"),k=({minHeight:e=w.DEFAULT_MIN_HEIGHT,maxHeight:t=w.DEFAULT_MAX_HEIGHT,resizable:a=!0,className:x,style:y,testId:R,...T})=>{const h=o.useRef(null),[c,E]=o.useState(e),b=o.useRef(0),d=o.useRef(e),_=o.useCallback(r=>{var v,g;if(!a)return;r.preventDefault(),b.current=r.clientY,d.current=c,(g=(v=r.target).setPointerCapture)==null||g.call(v,r.pointerId);const l=s=>{const i=s.clientY-b.current;let n=d.current+i;e>0&&(n=Math.max(e,n)),t>0&&(n=Math.min(t,n)),E(n)},p=()=>{var s,i;(i=(s=r.target).releasePointerCapture)==null||i.call(s,r.pointerId),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",p)};window.addEventListener("pointermove",l),window.addEventListener("pointerup",p)},[a,c,e,t]);return u.jsxs("div",{className:f.cn("Bear-ResizableTextarea bear-relative",x),"data-testid":R,children:[u.jsx("textarea",{ref:h,className:f.cn("bear-w-full bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-gray-600","bear-bg-white dark:bear-bg-gray-900 bear-text-gray-900 dark:bear-text-gray-100","bear-p-3 bear-resize-none focus:bear-outline-none focus:bear-ring-2 focus:bear-ring-pink-500/50"),style:{...y,minHeight:a?e:void 0,height:a?c:void 0,maxHeight:t>0?t:void 0},...T}),a&&u.jsx("div",{role:"separator",onPointerDown:_,className:"Bear-ResizableTextarea__handle bear-absolute bear-right-0 bear-bottom-0 bear-w-4 bear-h-4 bear-cursor-s-resize bear-opacity-50 hover:bear-opacity-100",style:{background:"linear-gradient(135deg, transparent 50%, currentColor 50%)"}})]})};exports.ResizableTextarea=k;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=80,t=400;exports.DEFAULT_MAX_HEIGHT=t;exports.DEFAULT_MIN_HEIGHT=T;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsxs as k, jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as d, useState as L, useCallback as _ } from "react";
|
|
3
|
+
import { cn as g } from "../../utils/cn.js";
|
|
4
|
+
import { DEFAULT_MIN_HEIGHT as D, DEFAULT_MAX_HEIGHT as I } from "./ResizableTextarea.const.js";
|
|
5
|
+
const P = ({
|
|
6
|
+
minHeight: e = D,
|
|
7
|
+
maxHeight: t = I,
|
|
8
|
+
resizable: a = !0,
|
|
9
|
+
className: w,
|
|
10
|
+
style: m,
|
|
11
|
+
testId: y,
|
|
12
|
+
...x
|
|
13
|
+
}) => {
|
|
14
|
+
const h = d(null), [i, E] = L(e), b = d(0), c = d(e), T = _((r) => {
|
|
15
|
+
var p, v;
|
|
16
|
+
if (!a) return;
|
|
17
|
+
r.preventDefault(), b.current = r.clientY, c.current = i, (v = (p = r.target).setPointerCapture) == null || v.call(p, r.pointerId);
|
|
18
|
+
const u = (n) => {
|
|
19
|
+
const s = n.clientY - b.current;
|
|
20
|
+
let o = c.current + s;
|
|
21
|
+
e > 0 && (o = Math.max(e, o)), t > 0 && (o = Math.min(t, o)), E(o);
|
|
22
|
+
}, l = () => {
|
|
23
|
+
var n, s;
|
|
24
|
+
(s = (n = r.target).releasePointerCapture) == null || s.call(n, r.pointerId), window.removeEventListener("pointermove", u), window.removeEventListener("pointerup", l);
|
|
25
|
+
};
|
|
26
|
+
window.addEventListener("pointermove", u), window.addEventListener("pointerup", l);
|
|
27
|
+
}, [a, i, e, t]);
|
|
28
|
+
return /* @__PURE__ */ k("div", { className: g("Bear-ResizableTextarea bear-relative", w), "data-testid": y, children: [
|
|
29
|
+
/* @__PURE__ */ f(
|
|
30
|
+
"textarea",
|
|
31
|
+
{
|
|
32
|
+
ref: h,
|
|
33
|
+
className: g(
|
|
34
|
+
"bear-w-full bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-gray-600",
|
|
35
|
+
"bear-bg-white dark:bear-bg-gray-900 bear-text-gray-900 dark:bear-text-gray-100",
|
|
36
|
+
"bear-p-3 bear-resize-none focus:bear-outline-none focus:bear-ring-2 focus:bear-ring-pink-500/50"
|
|
37
|
+
),
|
|
38
|
+
style: {
|
|
39
|
+
...m,
|
|
40
|
+
minHeight: a ? e : void 0,
|
|
41
|
+
height: a ? i : void 0,
|
|
42
|
+
maxHeight: t > 0 ? t : void 0
|
|
43
|
+
},
|
|
44
|
+
...x
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
a && /* @__PURE__ */ f(
|
|
48
|
+
"div",
|
|
49
|
+
{
|
|
50
|
+
role: "separator",
|
|
51
|
+
onPointerDown: T,
|
|
52
|
+
className: "Bear-ResizableTextarea__handle bear-absolute bear-right-0 bear-bottom-0 bear-w-4 bear-h-4 bear-cursor-s-resize bear-opacity-50 hover:bear-opacity-100",
|
|
53
|
+
style: { background: "linear-gradient(135deg, transparent 50%, currentColor 50%)" }
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
] });
|
|
57
|
+
};
|
|
58
|
+
export {
|
|
59
|
+
P as ResizableTextarea
|
|
60
|
+
};
|