@wallarm-org/design-system 0.67.2 → 0.68.0
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/AnimatedBackground/AnimatedBackground.d.ts +8 -1
- package/dist/components/AnimatedBackground/AnimatedBackground.js +9 -118
- package/dist/components/AnimatedBackground/blur/BlurBackground.d.ts +6 -0
- package/dist/components/AnimatedBackground/blur/BlurBackground.js +129 -0
- package/dist/components/AnimatedBackground/blur/index.d.ts +1 -0
- package/dist/components/AnimatedBackground/blur/index.js +2 -0
- package/dist/components/AnimatedBackground/index.d.ts +3 -2
- package/dist/components/AnimatedBackground/index.js +3 -1
- package/dist/components/AnimatedBackground/{GameHud.js → pixel/GameHud.js} +1 -1
- package/dist/components/AnimatedBackground/pixel/PixelBackground.d.ts +11 -0
- package/dist/components/AnimatedBackground/pixel/PixelBackground.js +102 -0
- package/dist/components/AnimatedBackground/pixel/index.d.ts +1 -0
- package/dist/components/AnimatedBackground/pixel/index.js +2 -0
- package/dist/components/AnimatedBackground/{module → pixel/module}/game-logic.js +1 -1
- package/dist/components/AnimatedBackground/{module → pixel/module}/index.d.ts +1 -1
- package/dist/components/AnimatedBackground/pixel/module/lib.d.ts +2 -0
- package/dist/components/AnimatedBackground/pixel/module/lib.js +16 -0
- package/dist/components/AnimatedBackground/pixel/module/types.d.ts +38 -0
- package/dist/components/Calendar/CalendarInputHeader.js +31 -5
- package/dist/components/FilterInput/lib/constants.js +10 -10
- package/dist/components/InputGroup/InputGroup.js +1 -1
- package/dist/components/InputGroup/InputGroupAddon.d.ts +1 -1
- package/dist/components/InputGroup/InputGroupAddon.js +3 -2
- package/dist/components/NavPanel/NavPanelContext.d.ts +9 -1
- package/dist/components/NavPanel/NavPanelContext.js +14 -1
- package/dist/components/NavPanel/NavPanelGroup.d.ts +1 -3
- package/dist/components/NavPanel/NavPanelGroup.js +1 -5
- package/dist/components/NavPanel/NavPanelGroupContent.d.ts +1 -1
- package/dist/components/NavPanel/NavPanelGroupContent.js +21 -19
- package/dist/components/NavPanel/NavPanelGroupItem.js +3 -2
- package/dist/components/NavPanel/NavPanelGroupLabel.js +4 -2
- package/dist/components/Textarea/Textarea.d.ts +8 -8
- package/dist/components/Textarea/Textarea.js +24 -17
- package/dist/components/Textarea/classes.d.ts +6 -0
- package/dist/components/Textarea/classes.js +20 -0
- package/dist/components/Textarea/useAutoResize.d.ts +4 -0
- package/dist/components/Textarea/useAutoResize.js +34 -0
- package/dist/components/Tree/Tree.d.ts +9 -0
- package/dist/components/Tree/Tree.js +48 -0
- package/dist/components/Tree/TreeContext.d.ts +11 -0
- package/dist/components/Tree/TreeContext.js +19 -0
- package/dist/components/Tree/TreeItem.d.ts +10 -0
- package/dist/components/Tree/TreeItem.js +46 -0
- package/dist/components/Tree/TreeItemContent.d.ts +6 -0
- package/dist/components/Tree/TreeItemContent.js +26 -0
- package/dist/components/Tree/TreeItemContext.d.ts +8 -0
- package/dist/components/Tree/TreeItemContext.js +11 -0
- package/dist/components/Tree/TreeItemHeader.d.ts +8 -0
- package/dist/components/Tree/TreeItemHeader.js +57 -0
- package/dist/components/Tree/TreeItemIcon.d.ts +5 -0
- package/dist/components/Tree/TreeItemIcon.js +40 -0
- package/dist/components/Tree/index.d.ts +5 -0
- package/dist/components/Tree/index.js +6 -0
- package/dist/components/TreeBase/TreeBase.d.ts +31 -0
- package/dist/components/TreeBase/TreeBase.js +56 -0
- package/dist/components/TreeBase/classes.d.ts +7 -0
- package/dist/components/TreeBase/classes.js +10 -0
- package/dist/components/TreeBase/index.d.ts +1 -0
- package/dist/components/TreeBase/index.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/metadata/components.json +3561 -1486
- package/dist/theme/components/animated-background.css +117 -0
- package/dist/theme/index.css +1 -1
- package/package.json +1 -1
- package/dist/components/AnimatedBackground/module/lib.d.ts +0 -2
- package/dist/components/AnimatedBackground/module/lib.js +0 -32
- package/dist/components/AnimatedBackground/module/types.d.ts +0 -79
- package/dist/theme/components/login-background.css +0 -45
- /package/dist/components/AnimatedBackground/{GameHud.d.ts → pixel/GameHud.d.ts} +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/celebration-renderer.d.ts +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/celebration-renderer.js +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/celebration.d.ts +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/celebration.js +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/constants.d.ts +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/constants.js +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/engine-colors.d.ts +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/engine-colors.js +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/engine-grid.d.ts +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/engine-grid.js +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/engine.d.ts +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/engine.js +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/game-logic.d.ts +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/game-plugins.d.ts +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/game-plugins.js +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/game-renderer.d.ts +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/game-renderer.js +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/index.js +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/math.d.ts +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/math.js +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/sfx.d.ts +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/sfx.js +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/types.js +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/useGame.d.ts +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/useGame.js +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/useGameKeyboard.d.ts +0 -0
- /package/dist/components/AnimatedBackground/{module → pixel/module}/useGameKeyboard.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ComponentProps, FC } from 'react';
|
|
2
2
|
import { type VariantProps } from 'class-variance-authority';
|
|
3
3
|
declare const inputGroupAddonVariants: (props?: ({
|
|
4
|
-
align?: "inline-end" | "inline-start" | null | undefined;
|
|
4
|
+
align?: "inline-end" | "inline-start" | "block-end" | null | undefined;
|
|
5
5
|
variant?: "outline" | "ghost" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
export declare const InputGroupAddon: FC<ComponentProps<'div'> & VariantProps<typeof inputGroupAddonVariants>>;
|
|
@@ -17,7 +17,8 @@ const inputGroupAddonVariants = cva(cn([
|
|
|
17
17
|
variants: {
|
|
18
18
|
align: {
|
|
19
19
|
'inline-start': 'order-first pl-12 has-[>kbd]:pl-8',
|
|
20
|
-
'inline-end': 'order-last pr-12 has-[>kbd]:pr-8'
|
|
20
|
+
'inline-end': 'order-last pr-12 has-[>kbd]:pr-8',
|
|
21
|
+
'block-end': 'order-last w-full px-8 pb-8 h-auto justify-start'
|
|
21
22
|
},
|
|
22
23
|
variant: {
|
|
23
24
|
outline: 'px-12 bg-states-primary-default-alt border-border-primary',
|
|
@@ -54,7 +55,7 @@ const InputGroupAddon = ({ align = 'inline-start', variant = 'ghost', ...props }
|
|
|
54
55
|
const testId = useTestId('addon');
|
|
55
56
|
const handleClick = (event)=>{
|
|
56
57
|
if (event.target.closest('button')) return;
|
|
57
|
-
event.currentTarget.parentElement?.querySelector('input')?.focus();
|
|
58
|
+
event.currentTarget.parentElement?.querySelector('input, textarea')?.focus();
|
|
58
59
|
};
|
|
59
60
|
return /*#__PURE__*/ jsx("div", {
|
|
60
61
|
...props,
|
|
@@ -9,4 +9,12 @@ interface NavPanelInternalContextValue {
|
|
|
9
9
|
}
|
|
10
10
|
export declare const NavPanelInternalProvider: import("react").Provider<NavPanelInternalContextValue | null>;
|
|
11
11
|
export declare function useNavPanelInternalContext(): NavPanelInternalContextValue;
|
|
12
|
-
|
|
12
|
+
declare const NAV_PANEL_BASE_PADDING = 8;
|
|
13
|
+
interface NavPanelDepthContextValue {
|
|
14
|
+
depth: number;
|
|
15
|
+
indent: number;
|
|
16
|
+
}
|
|
17
|
+
export declare const NavPanelDepthProvider: import("react").Provider<NavPanelDepthContextValue>;
|
|
18
|
+
export declare function useNavPanelDepth(): number;
|
|
19
|
+
export declare function useNavPanelIndent(): number;
|
|
20
|
+
export { NAV_PANEL_BASE_PADDING };
|
|
@@ -6,4 +6,17 @@ function useNavPanelInternalContext() {
|
|
|
6
6
|
if (!ctx) throw new Error('useNavPanelInternalContext must be used within NavPanelInternalProvider');
|
|
7
7
|
return ctx;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
const NAV_PANEL_BASE_PADDING = 8;
|
|
10
|
+
const NAV_PANEL_DEFAULT_INDENT = 24;
|
|
11
|
+
const NavPanelDepthContext = /*#__PURE__*/ createContext({
|
|
12
|
+
depth: 0,
|
|
13
|
+
indent: NAV_PANEL_DEFAULT_INDENT
|
|
14
|
+
});
|
|
15
|
+
const NavPanelDepthProvider = NavPanelDepthContext.Provider;
|
|
16
|
+
function useNavPanelDepth() {
|
|
17
|
+
return useContext(NavPanelDepthContext).depth;
|
|
18
|
+
}
|
|
19
|
+
function useNavPanelIndent() {
|
|
20
|
+
return useContext(NavPanelDepthContext).indent;
|
|
21
|
+
}
|
|
22
|
+
export { NAV_PANEL_BASE_PADDING, NavPanelDepthProvider, NavPanelInternalProvider, useNavPanelDepth, useNavPanelIndent, useNavPanelInternalContext };
|
|
@@ -5,9 +5,6 @@ interface NavPanelGroupContextValue {
|
|
|
5
5
|
contentId: string;
|
|
6
6
|
}
|
|
7
7
|
export declare function useNavPanelGroupContext(): NavPanelGroupContextValue;
|
|
8
|
-
declare const NavPanelDepthContext: import("react").Context<number>;
|
|
9
|
-
export declare function useNavPanelDepth(): number;
|
|
10
|
-
export { NavPanelDepthContext };
|
|
11
8
|
export interface NavPanelGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
12
9
|
ref?: Ref<HTMLDivElement>;
|
|
13
10
|
expanded?: boolean;
|
|
@@ -16,3 +13,4 @@ export interface NavPanelGroupProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
16
13
|
children: ReactNode;
|
|
17
14
|
}
|
|
18
15
|
export declare const NavPanelGroup: FC<NavPanelGroupProps>;
|
|
16
|
+
export {};
|
|
@@ -10,10 +10,6 @@ const NavPanelGroupContext = /*#__PURE__*/ createContext({
|
|
|
10
10
|
function useNavPanelGroupContext() {
|
|
11
11
|
return useContext(NavPanelGroupContext);
|
|
12
12
|
}
|
|
13
|
-
const NavPanelDepthContext = /*#__PURE__*/ createContext(0);
|
|
14
|
-
function useNavPanelDepth() {
|
|
15
|
-
return useContext(NavPanelDepthContext);
|
|
16
|
-
}
|
|
17
13
|
const NavPanelGroup = ({ ref, expanded: controlledExpanded, defaultExpanded = false, onExpandedChange, className, children, ...props })=>{
|
|
18
14
|
const [uncontrolledExpanded, setUncontrolledExpanded] = useState(defaultExpanded);
|
|
19
15
|
const isControlled = void 0 !== controlledExpanded;
|
|
@@ -46,4 +42,4 @@ const NavPanelGroup = ({ ref, expanded: controlledExpanded, defaultExpanded = fa
|
|
|
46
42
|
});
|
|
47
43
|
};
|
|
48
44
|
NavPanelGroup.displayName = 'NavPanelGroup';
|
|
49
|
-
export {
|
|
45
|
+
export { NavPanelGroup, useNavPanelGroupContext };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FC, HTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
2
|
export interface NavPanelGroupContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
3
|
ref?: Ref<HTMLDivElement>;
|
|
4
4
|
children?: ReactNode;
|
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useRef } from "react";
|
|
3
2
|
import { cn } from "../../utils/cn.js";
|
|
4
|
-
import {
|
|
3
|
+
import { NAV_PANEL_BASE_PADDING, NavPanelDepthProvider, useNavPanelDepth, useNavPanelIndent } from "./NavPanelContext.js";
|
|
4
|
+
import { useNavPanelGroupContext } from "./NavPanelGroup.js";
|
|
5
5
|
const NavPanelGroupContent = ({ ref, className, children, ...props })=>{
|
|
6
6
|
const { expanded, contentId } = useNavPanelGroupContext();
|
|
7
7
|
const parentDepth = useNavPanelDepth();
|
|
8
|
+
const indent = useNavPanelIndent();
|
|
8
9
|
const depth = parentDepth + 1;
|
|
9
|
-
|
|
10
|
-
return /*#__PURE__*/ jsxs("div", {
|
|
10
|
+
return /*#__PURE__*/ jsx("div", {
|
|
11
11
|
...props,
|
|
12
12
|
ref: ref,
|
|
13
13
|
id: contentId,
|
|
14
14
|
role: "group",
|
|
15
15
|
"data-slot": "nav-panel-group-content",
|
|
16
|
-
className: cn('
|
|
17
|
-
children:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
className: cn('grid transition-[grid-template-rows] duration-150 ease-out', expanded ? 'grid-rows-[1fr] mt-2' : 'grid-rows-[0fr]', className),
|
|
17
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
18
|
+
className: "relative flex flex-col gap-2 overflow-hidden",
|
|
19
|
+
children: [
|
|
20
|
+
/*#__PURE__*/ jsx("div", {
|
|
21
|
+
className: "absolute top-0 bottom-0 w-px bg-border-primary-light",
|
|
22
|
+
style: {
|
|
23
|
+
left: indent * parentDepth + (indent - NAV_PANEL_BASE_PADDING)
|
|
24
|
+
}
|
|
25
|
+
}),
|
|
26
|
+
/*#__PURE__*/ jsx(NavPanelDepthProvider, {
|
|
27
|
+
value: {
|
|
28
|
+
depth,
|
|
29
|
+
indent
|
|
30
|
+
},
|
|
29
31
|
children: children
|
|
30
32
|
})
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
]
|
|
34
|
+
})
|
|
33
35
|
});
|
|
34
36
|
};
|
|
35
37
|
NavPanelGroupContent.displayName = 'NavPanelGroupContent';
|
|
@@ -4,10 +4,11 @@ import { cn } from "../../utils/cn.js";
|
|
|
4
4
|
import { useTestId } from "../../utils/testId.js";
|
|
5
5
|
import { Text } from "../Text/index.js";
|
|
6
6
|
import { navPanelGroupItemVariants } from "./classes.js";
|
|
7
|
-
import { useNavPanelDepth } from "./
|
|
7
|
+
import { useNavPanelDepth, useNavPanelIndent } from "./NavPanelContext.js";
|
|
8
8
|
const NavPanelGroupItem = ({ ref, asChild = false, icon: Icon, active = false, className, children, ...props })=>{
|
|
9
9
|
const testId = useTestId('group-item');
|
|
10
10
|
const depth = useNavPanelDepth();
|
|
11
|
+
const indent = useNavPanelIndent();
|
|
11
12
|
const Comp = asChild ? Slot : 'a';
|
|
12
13
|
return /*#__PURE__*/ jsxs(Comp, {
|
|
13
14
|
...props,
|
|
@@ -19,7 +20,7 @@ const NavPanelGroupItem = ({ ref, asChild = false, icon: Icon, active = false, c
|
|
|
19
20
|
active
|
|
20
21
|
}), className),
|
|
21
22
|
style: {
|
|
22
|
-
paddingLeft: 8 +
|
|
23
|
+
paddingLeft: 8 + depth * indent
|
|
23
24
|
},
|
|
24
25
|
children: [
|
|
25
26
|
Icon && /*#__PURE__*/ jsx("span", {
|
|
@@ -3,10 +3,12 @@ import { ChevronRight } from "../../icons/index.js";
|
|
|
3
3
|
import { cn } from "../../utils/cn.js";
|
|
4
4
|
import { useTestId } from "../../utils/testId.js";
|
|
5
5
|
import { Text } from "../Text/index.js";
|
|
6
|
-
import { useNavPanelDepth,
|
|
6
|
+
import { useNavPanelDepth, useNavPanelIndent } from "./NavPanelContext.js";
|
|
7
|
+
import { useNavPanelGroupContext } from "./NavPanelGroup.js";
|
|
7
8
|
const NavPanelGroupLabel = ({ ref, icon: Icon, className, children, ...props })=>{
|
|
8
9
|
const { expanded, toggle, contentId } = useNavPanelGroupContext();
|
|
9
10
|
const depth = useNavPanelDepth();
|
|
11
|
+
const indent = useNavPanelIndent();
|
|
10
12
|
const testId = useTestId('group-label');
|
|
11
13
|
return /*#__PURE__*/ jsxs("button", {
|
|
12
14
|
...props,
|
|
@@ -18,7 +20,7 @@ const NavPanelGroupLabel = ({ ref, icon: Icon, className, children, ...props })=
|
|
|
18
20
|
"data-testid": testId,
|
|
19
21
|
onClick: toggle,
|
|
20
22
|
style: {
|
|
21
|
-
paddingLeft: 8 +
|
|
23
|
+
paddingLeft: 8 + depth * indent
|
|
22
24
|
},
|
|
23
25
|
className: cn('overlay flex h-32 shrink-0 w-full cursor-pointer items-center gap-8 rounded-6 py-8 pr-8 text-sm text-text-primary opacity-64 transition-colors outline-none hover:opacity-100 hover:overlay-states-primary-hover focus-visible:opacity-100 focus-visible:overlay-states-primary-hover active:overlay-states-primary-pressed', className),
|
|
24
26
|
children: [
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { FC, Ref, TextareaHTMLAttributes } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { VariantProps } from 'class-variance-authority';
|
|
3
3
|
import type { TestableProps } from '../../utils/testId';
|
|
4
4
|
import { inputVariants } from '../Input';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type TextareaNativeProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'className'>;
|
|
9
|
-
type TextareaVariantsProps = VariantProps<typeof textareaVariants>;
|
|
5
|
+
import { textareaPaddingVariants } from './classes';
|
|
6
|
+
type TextareaNativeProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'className' | 'children'>;
|
|
7
|
+
type TextareaVariantsProps = VariantProps<typeof textareaPaddingVariants>;
|
|
10
8
|
type InputVariantsProps = VariantProps<typeof inputVariants>;
|
|
11
|
-
export
|
|
9
|
+
export interface TextareaProps extends TextareaNativeProps, TextareaVariantsProps, InputVariantsProps, TestableProps {
|
|
12
10
|
ref?: Ref<HTMLTextAreaElement>;
|
|
13
|
-
|
|
11
|
+
minRows?: number;
|
|
12
|
+
maxRows?: number;
|
|
13
|
+
}
|
|
14
14
|
export declare const Textarea: FC<TextareaProps>;
|
|
15
15
|
export {};
|
|
@@ -1,38 +1,45 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useFieldContext } from "@ark-ui/react/field";
|
|
3
3
|
import { mergeProps } from "@ark-ui/react/utils";
|
|
4
|
-
import {
|
|
4
|
+
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
5
5
|
import { SvgIcon } from "../../icons/SvgIcon.js";
|
|
6
6
|
import { cn } from "../../utils/cn.js";
|
|
7
7
|
import { inputVariants } from "../Input/index.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
small: 'py-0 min-h-[60px]',
|
|
12
|
-
medium: 'py-6 min-h-[72px]',
|
|
13
|
-
default: 'py-8 min-h-[76px]'
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
const Textarea = ({ error = false, disabled = false, size = 'default', ...props })=>{
|
|
8
|
+
import { textareaHeightVariants, textareaPaddingVariants } from "./classes.js";
|
|
9
|
+
import { useAutoResize } from "./useAutoResize.js";
|
|
10
|
+
const Textarea = ({ error = false, disabled = false, size = 'default', minRows, maxRows, ref, ...props })=>{
|
|
18
11
|
const field = useFieldContext();
|
|
19
12
|
const mergedProps = mergeProps(field?.getTextareaProps());
|
|
13
|
+
const autoResize = null != maxRows;
|
|
14
|
+
const effectiveMinRows = minRows ?? (autoResize ? 1 : void 0);
|
|
15
|
+
const { ref: autoResizeRef, adjustHeight } = useAutoResize(autoResize, effectiveMinRows ?? 1, maxRows ?? 1, props.value);
|
|
20
16
|
return /*#__PURE__*/ jsxs("div", {
|
|
21
17
|
className: "relative",
|
|
18
|
+
"data-slot": "textarea",
|
|
22
19
|
children: [
|
|
23
20
|
/*#__PURE__*/ jsx("textarea", {
|
|
24
21
|
...mergedProps,
|
|
25
22
|
...props,
|
|
23
|
+
ref: composeRefs(autoResizeRef, ref),
|
|
24
|
+
disabled: disabled,
|
|
25
|
+
"aria-invalid": Boolean(error),
|
|
26
|
+
"aria-disabled": disabled,
|
|
27
|
+
rows: effectiveMinRows,
|
|
28
|
+
...autoResize && {
|
|
29
|
+
onInput: (e)=>{
|
|
30
|
+
adjustHeight();
|
|
31
|
+
props.onInput?.(e);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
26
34
|
className: cn(inputVariants({
|
|
27
35
|
error
|
|
28
|
-
}),
|
|
36
|
+
}), textareaPaddingVariants({
|
|
29
37
|
size
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"aria-disabled": disabled
|
|
38
|
+
}), '[scrollbar-width:thin]', !autoResize && textareaHeightVariants({
|
|
39
|
+
size
|
|
40
|
+
}), autoResize && 'resize-none')
|
|
34
41
|
}),
|
|
35
|
-
/*#__PURE__*/ jsx(SvgIcon, {
|
|
42
|
+
!autoResize && /*#__PURE__*/ jsx(SvgIcon, {
|
|
36
43
|
className: "w-12 h-12 absolute bottom-0 right-0 text-icon-secondary pointer-events-none",
|
|
37
44
|
viewBox: "0 0 12 12",
|
|
38
45
|
children: /*#__PURE__*/ jsx("path", {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const textareaPaddingVariants: (props?: ({
|
|
2
|
+
size?: "small" | "medium" | "default" | null | undefined;
|
|
3
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
4
|
+
export declare const textareaHeightVariants: (props?: ({
|
|
5
|
+
size?: "small" | "medium" | "default" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
const textareaPaddingVariants = cva('', {
|
|
3
|
+
variants: {
|
|
4
|
+
size: {
|
|
5
|
+
small: 'py-0',
|
|
6
|
+
medium: 'py-6',
|
|
7
|
+
default: 'py-8'
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const textareaHeightVariants = cva('min-h-[60px]', {
|
|
12
|
+
variants: {
|
|
13
|
+
size: {
|
|
14
|
+
small: 'min-h-[60px]',
|
|
15
|
+
medium: 'min-h-[72px]',
|
|
16
|
+
default: 'min-h-[76px]'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
export { textareaHeightVariants, textareaPaddingVariants };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useCallback, useLayoutEffect, useRef } from "react";
|
|
2
|
+
function adjustTextareaHeight(textarea, minRows, maxRows) {
|
|
3
|
+
const style = window.getComputedStyle(textarea);
|
|
4
|
+
const lineHeight = Number.parseInt(style.lineHeight, 10) || 20;
|
|
5
|
+
const paddingY = (Number.parseInt(style.paddingTop, 10) || 0) + (Number.parseInt(style.paddingBottom, 10) || 0);
|
|
6
|
+
const minHeight = lineHeight * minRows + paddingY;
|
|
7
|
+
const maxHeight = lineHeight * maxRows + paddingY;
|
|
8
|
+
textarea.style.height = '0';
|
|
9
|
+
const scrollHeight = textarea.scrollHeight;
|
|
10
|
+
textarea.style.height = `${Math.min(Math.max(scrollHeight, minHeight), maxHeight)}px`;
|
|
11
|
+
textarea.style.overflowY = scrollHeight > maxHeight ? 'auto' : 'hidden';
|
|
12
|
+
}
|
|
13
|
+
function useAutoResize(enabled, minRows, maxRows, value) {
|
|
14
|
+
const ref = useRef(null);
|
|
15
|
+
const adjustHeight = useCallback(()=>{
|
|
16
|
+
if (!enabled || !ref.current) return;
|
|
17
|
+
adjustTextareaHeight(ref.current, minRows, maxRows);
|
|
18
|
+
}, [
|
|
19
|
+
enabled,
|
|
20
|
+
minRows,
|
|
21
|
+
maxRows
|
|
22
|
+
]);
|
|
23
|
+
useLayoutEffect(()=>{
|
|
24
|
+
adjustHeight();
|
|
25
|
+
}, [
|
|
26
|
+
adjustHeight,
|
|
27
|
+
value
|
|
28
|
+
]);
|
|
29
|
+
return {
|
|
30
|
+
ref,
|
|
31
|
+
adjustHeight
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export { useAutoResize };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FC, HTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
|
+
import { type TestableProps } from '../../utils/testId';
|
|
3
|
+
export interface TreeProps extends HTMLAttributes<HTMLDivElement>, TestableProps {
|
|
4
|
+
ref?: Ref<HTMLDivElement>;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
indent?: number;
|
|
7
|
+
gap?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const Tree: FC<TreeProps>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { TestIdProvider } from "../../utils/testId.js";
|
|
4
|
+
import { TREE_BASE_PADDING, TreeDepthProvider, useTreeDepth, useTreeGap, useTreeIndent } from "./TreeContext.js";
|
|
5
|
+
const Tree = ({ ref, children, indent, gap, 'data-testid': testId, className, style, ...props })=>{
|
|
6
|
+
const parentDepth = useTreeDepth();
|
|
7
|
+
const parentIndent = useTreeIndent();
|
|
8
|
+
const parentGap = useTreeGap();
|
|
9
|
+
const isRoot = 0 === parentDepth;
|
|
10
|
+
const resolvedIndent = indent ?? parentIndent;
|
|
11
|
+
const resolvedGap = gap ?? parentGap;
|
|
12
|
+
const depth = isRoot ? 0 : parentDepth;
|
|
13
|
+
const lineLeft = isRoot ? resolvedIndent - TREE_BASE_PADDING : resolvedIndent - 2 * TREE_BASE_PADDING;
|
|
14
|
+
const content = /*#__PURE__*/ jsxs("div", {
|
|
15
|
+
ref: ref,
|
|
16
|
+
"data-slot": "tree",
|
|
17
|
+
"data-testid": testId,
|
|
18
|
+
className: cn('relative flex flex-col', className),
|
|
19
|
+
style: {
|
|
20
|
+
gap: resolvedGap,
|
|
21
|
+
...style
|
|
22
|
+
},
|
|
23
|
+
...props,
|
|
24
|
+
children: [
|
|
25
|
+
/*#__PURE__*/ jsx("div", {
|
|
26
|
+
className: "absolute top-0 bottom-0 w-px bg-border-primary-light",
|
|
27
|
+
style: {
|
|
28
|
+
left: lineLeft
|
|
29
|
+
}
|
|
30
|
+
}),
|
|
31
|
+
/*#__PURE__*/ jsx(TreeDepthProvider, {
|
|
32
|
+
value: {
|
|
33
|
+
depth: depth + 1,
|
|
34
|
+
indent: resolvedIndent,
|
|
35
|
+
gap: resolvedGap
|
|
36
|
+
},
|
|
37
|
+
children: children
|
|
38
|
+
})
|
|
39
|
+
]
|
|
40
|
+
});
|
|
41
|
+
if (void 0 !== testId) return /*#__PURE__*/ jsx(TestIdProvider, {
|
|
42
|
+
value: testId,
|
|
43
|
+
children: content
|
|
44
|
+
});
|
|
45
|
+
return content;
|
|
46
|
+
};
|
|
47
|
+
Tree.displayName = 'Tree';
|
|
48
|
+
export { Tree };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const TREE_BASE_PADDING = 8;
|
|
2
|
+
interface TreeDepthContextValue {
|
|
3
|
+
depth: number;
|
|
4
|
+
indent: number;
|
|
5
|
+
gap: number | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare const TreeDepthProvider: import("react").Provider<TreeDepthContextValue>;
|
|
8
|
+
export declare function useTreeDepth(): number;
|
|
9
|
+
export declare function useTreeIndent(): number;
|
|
10
|
+
export declare function useTreeGap(): number | undefined;
|
|
11
|
+
export { TREE_BASE_PADDING };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
const TREE_BASE_PADDING = 8;
|
|
3
|
+
const TREE_DEFAULT_INDENT = 24;
|
|
4
|
+
const TreeDepthContext = createContext({
|
|
5
|
+
depth: 0,
|
|
6
|
+
indent: TREE_DEFAULT_INDENT,
|
|
7
|
+
gap: void 0
|
|
8
|
+
});
|
|
9
|
+
const TreeDepthProvider = TreeDepthContext.Provider;
|
|
10
|
+
function useTreeDepth() {
|
|
11
|
+
return useContext(TreeDepthContext).depth;
|
|
12
|
+
}
|
|
13
|
+
function useTreeIndent() {
|
|
14
|
+
return useContext(TreeDepthContext).indent;
|
|
15
|
+
}
|
|
16
|
+
function useTreeGap() {
|
|
17
|
+
return useContext(TreeDepthContext).gap;
|
|
18
|
+
}
|
|
19
|
+
export { TREE_BASE_PADDING, TreeDepthProvider, useTreeDepth, useTreeGap, useTreeIndent };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type FC, type HTMLAttributes, type ReactNode, type Ref } from 'react';
|
|
2
|
+
export interface TreeItemProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
3
|
+
ref?: Ref<HTMLDivElement>;
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
collapsible?: boolean;
|
|
6
|
+
open?: boolean;
|
|
7
|
+
defaultOpen?: boolean;
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const TreeItem: FC<TreeItemProps>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
import { useTestId } from "../../utils/testId.js";
|
|
4
|
+
import { TREE_BASE_PADDING, useTreeDepth, useTreeGap, useTreeIndent } from "./TreeContext.js";
|
|
5
|
+
import { TreeItemProvider } from "./TreeItemContext.js";
|
|
6
|
+
const TreeItem = ({ ref, children, collapsible = false, open: controlledOpen, defaultOpen = true, onOpenChange, style, ...props })=>{
|
|
7
|
+
const depth = useTreeDepth();
|
|
8
|
+
const indent = useTreeIndent();
|
|
9
|
+
const gap = useTreeGap();
|
|
10
|
+
const testId = useTestId('item');
|
|
11
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
12
|
+
const isControlled = void 0 !== controlledOpen;
|
|
13
|
+
const isOpen = isControlled ? controlledOpen : internalOpen;
|
|
14
|
+
const toggle = useCallback(()=>{
|
|
15
|
+
const next = !isOpen;
|
|
16
|
+
if (!isControlled) setInternalOpen(next);
|
|
17
|
+
onOpenChange?.(next);
|
|
18
|
+
}, [
|
|
19
|
+
isOpen,
|
|
20
|
+
isControlled,
|
|
21
|
+
onOpenChange
|
|
22
|
+
]);
|
|
23
|
+
const paddingLeft = 1 === depth ? TREE_BASE_PADDING + indent : indent;
|
|
24
|
+
const itemGap = collapsible && gap ? gap / 2 : void 0;
|
|
25
|
+
return /*#__PURE__*/ jsx(TreeItemProvider, {
|
|
26
|
+
value: {
|
|
27
|
+
collapsible,
|
|
28
|
+
open: isOpen,
|
|
29
|
+
toggle
|
|
30
|
+
},
|
|
31
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
32
|
+
ref: ref,
|
|
33
|
+
"data-slot": "tree-item",
|
|
34
|
+
"data-testid": testId,
|
|
35
|
+
style: {
|
|
36
|
+
paddingLeft,
|
|
37
|
+
gap: itemGap,
|
|
38
|
+
...style
|
|
39
|
+
},
|
|
40
|
+
...props,
|
|
41
|
+
children: children
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
TreeItem.displayName = 'TreeItem';
|
|
46
|
+
export { TreeItem };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { useTreeItemContext } from "./TreeItemContext.js";
|
|
4
|
+
const TreeItemContent = ({ ref, children, className, ...props })=>{
|
|
5
|
+
const { collapsible, open } = useTreeItemContext();
|
|
6
|
+
if (!collapsible) return /*#__PURE__*/ jsx("div", {
|
|
7
|
+
ref: ref,
|
|
8
|
+
"data-slot": "tree-item-content",
|
|
9
|
+
className: className,
|
|
10
|
+
...props,
|
|
11
|
+
children: children
|
|
12
|
+
});
|
|
13
|
+
return /*#__PURE__*/ jsx("div", {
|
|
14
|
+
ref: ref,
|
|
15
|
+
"data-slot": "tree-item-content",
|
|
16
|
+
"data-state": open ? 'open' : 'closed',
|
|
17
|
+
className: cn('grid transition-[grid-template-rows] duration-[220ms] ease-[cubic-bezier(0.4,0,0.2,1)] motion-reduce:transition-none', open ? 'grid-rows-[1fr]' : 'grid-rows-[0fr]', className),
|
|
18
|
+
...props,
|
|
19
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
20
|
+
className: "overflow-hidden",
|
|
21
|
+
children: children
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
TreeItemContent.displayName = 'TreeItemContent';
|
|
26
|
+
export { TreeItemContent };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface TreeItemContextValue {
|
|
2
|
+
collapsible: boolean;
|
|
3
|
+
open: boolean;
|
|
4
|
+
toggle: () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const TreeItemProvider: import("react").Provider<TreeItemContextValue>;
|
|
7
|
+
export declare function useTreeItemContext(): TreeItemContextValue;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
const TreeItemContext = createContext({
|
|
3
|
+
collapsible: false,
|
|
4
|
+
open: false,
|
|
5
|
+
toggle: ()=>{}
|
|
6
|
+
});
|
|
7
|
+
const TreeItemProvider = TreeItemContext.Provider;
|
|
8
|
+
function useTreeItemContext() {
|
|
9
|
+
return useContext(TreeItemContext);
|
|
10
|
+
}
|
|
11
|
+
export { TreeItemProvider, useTreeItemContext };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FC, HTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
|
+
export interface TreeItemHeaderProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
ref?: Ref<HTMLDivElement>;
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
action?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const TreeItemHeader: FC<TreeItemHeaderProps>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../utils/cn.js";
|
|
3
|
+
import { useTreeItemContext } from "./TreeItemContext.js";
|
|
4
|
+
import { TreeItemIcon } from "./TreeItemIcon.js";
|
|
5
|
+
const TreeItemHeader = ({ ref, children, icon, action, className, ...props })=>{
|
|
6
|
+
const { collapsible, open, toggle } = useTreeItemContext();
|
|
7
|
+
if (collapsible) return /*#__PURE__*/ jsxs("div", {
|
|
8
|
+
ref: ref,
|
|
9
|
+
"data-slot": "tree-item-header",
|
|
10
|
+
"data-state": open ? 'open' : 'closed',
|
|
11
|
+
className: cn('group/trigger relative pt-2 pb-4 flex min-w-0 w-full items-center', className),
|
|
12
|
+
...props,
|
|
13
|
+
children: [
|
|
14
|
+
/*#__PURE__*/ jsxs("button", {
|
|
15
|
+
type: "button",
|
|
16
|
+
className: cn('flex min-w-0 flex-1 items-center text-left cursor-pointer', 'before:absolute before:inset-y-0 before:left-0 before:right-0'),
|
|
17
|
+
onClick: toggle,
|
|
18
|
+
children: [
|
|
19
|
+
/*#__PURE__*/ jsx(TreeItemIcon, {
|
|
20
|
+
icon: icon
|
|
21
|
+
}),
|
|
22
|
+
/*#__PURE__*/ jsx("div", {
|
|
23
|
+
className: "min-w-0 flex-1",
|
|
24
|
+
children: children
|
|
25
|
+
})
|
|
26
|
+
]
|
|
27
|
+
}),
|
|
28
|
+
action && /*#__PURE__*/ jsx("div", {
|
|
29
|
+
className: "relative ml-2 shrink-0",
|
|
30
|
+
"data-slot": "tree-item-action",
|
|
31
|
+
children: action
|
|
32
|
+
})
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
36
|
+
ref: ref,
|
|
37
|
+
"data-slot": "tree-item-header",
|
|
38
|
+
className: cn('group relative pt-2 pb-4 flex w-full items-start justify-between', className),
|
|
39
|
+
...props,
|
|
40
|
+
children: [
|
|
41
|
+
/*#__PURE__*/ jsx(TreeItemIcon, {
|
|
42
|
+
icon: icon
|
|
43
|
+
}),
|
|
44
|
+
/*#__PURE__*/ jsx("div", {
|
|
45
|
+
className: "min-w-0 flex-1",
|
|
46
|
+
children: children
|
|
47
|
+
}),
|
|
48
|
+
action && /*#__PURE__*/ jsx("div", {
|
|
49
|
+
className: "ml-2 shrink-0",
|
|
50
|
+
"data-slot": "tree-item-action",
|
|
51
|
+
children: action
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
TreeItemHeader.displayName = 'TreeItemHeader';
|
|
57
|
+
export { TreeItemHeader };
|