@boxcustodia/library 2.0.0-alpha.12 → 2.0.0-alpha.14
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/index.cjs.js +1 -138
- package/dist/index.d.ts +1087 -720
- package/dist/index.es.js +7011 -56097
- package/dist/theme.css +1 -1
- package/package.json +34 -26
- package/src/__doc__/Examples.tsx +1 -1
- package/src/__doc__/Intro.mdx +3 -3
- package/src/__doc__/Tabs.mdx +112 -0
- package/src/__doc__/V2.mdx +1246 -0
- package/src/components/accordion/accordion.stories.tsx +143 -0
- package/src/components/accordion/accordion.tsx +135 -0
- package/src/components/accordion/index.ts +1 -0
- package/src/components/alert/alert.stories.tsx +24 -4
- package/src/components/alert/alert.tsx +17 -9
- package/src/components/alert-dialog/alert-dialog.stories.tsx +24 -0
- package/src/components/alert-dialog/alert-dialog.test.tsx +1 -1
- package/src/components/alert-dialog/alert-dialog.tsx +58 -10
- package/src/components/auto-complete/auto-complete.stories.tsx +616 -200
- package/src/components/auto-complete/auto-complete.tsx +420 -68
- package/src/components/auto-complete/index.ts +0 -1
- package/src/components/avatar/avatar.stories.tsx +162 -21
- package/src/components/avatar/avatar.tsx +79 -20
- package/src/components/button/button.stories.tsx +219 -294
- package/src/components/button/button.test.tsx +10 -17
- package/src/components/button/button.tsx +78 -19
- package/src/components/button/components/base-button.tsx +30 -53
- package/src/components/button/index.ts +0 -1
- package/src/components/calendar/calendar.stories.tsx +1 -1
- package/src/components/calendar/calendar.tsx +4 -4
- package/src/components/card/card.stories.tsx +141 -69
- package/src/components/card/card.tsx +155 -54
- package/src/components/center/center.stories.tsx +22 -39
- package/src/components/checkbox/checkbox.stories.tsx +25 -5
- package/src/components/checkbox/checkbox.tsx +76 -15
- package/src/components/checkbox-group/checkbox-group.stories.tsx +116 -28
- package/src/components/checkbox-group/checkbox-group.tsx +84 -3
- package/src/components/combobox/combobox.stories.tsx +33 -23
- package/src/components/combobox/combobox.tsx +99 -77
- package/src/components/date-picker/date-input.stories.tsx +14 -6
- package/src/components/date-picker/date-input.tsx +2 -2
- package/src/components/date-picker/date-picker.model.ts +13 -4
- package/src/components/date-picker/date-picker.stories.tsx +38 -12
- package/src/components/date-picker/date-picker.tsx +28 -14
- package/src/components/dialog/dialog.stories.tsx +18 -0
- package/src/components/dialog/dialog.test.tsx +1 -1
- package/src/components/dialog/dialog.tsx +51 -20
- package/src/components/divider/divider.stories.tsx +126 -51
- package/src/components/divider/divider.tsx +16 -16
- package/src/components/dropzone/dropzone.stories.tsx +71 -90
- package/src/components/dropzone/dropzone.tsx +383 -105
- package/src/components/dropzone/index.ts +0 -1
- package/src/components/empty/empty.stories.tsx +165 -0
- package/src/components/empty/empty.tsx +156 -0
- package/src/components/empty/index.ts +1 -0
- package/src/components/field/field.stories.tsx +227 -4
- package/src/components/field/field.tsx +77 -42
- package/src/components/form/form.stories.tsx +320 -197
- package/src/components/form/form.tsx +3 -23
- package/src/components/index.ts +2 -6
- package/src/components/input/input.stories.tsx +5 -5
- package/src/components/input/input.tsx +4 -4
- package/src/components/kbd/kbd.stories.tsx +1 -0
- package/src/components/label/label.stories.tsx +16 -0
- package/src/components/label/label.tsx +13 -2
- package/src/components/loader/loader.stories.tsx +7 -5
- package/src/components/loader/loader.tsx +8 -3
- package/src/components/menu/menu-primitives.tsx +207 -196
- package/src/components/menu/menu.stories.tsx +276 -146
- package/src/components/menu/menu.tsx +146 -54
- package/src/components/number-input/number-input.stories.tsx +27 -4
- package/src/components/number-input/number-input.test.tsx +2 -2
- package/src/components/number-input/number-input.tsx +31 -33
- package/src/components/otp/index.ts +1 -0
- package/src/components/otp/otp.stories.tsx +209 -0
- package/src/components/otp/otp.tsx +100 -0
- package/src/components/pagination/index.ts +1 -0
- package/src/components/pagination/pagination.model.ts +2 -0
- package/src/components/pagination/pagination.stories.tsx +154 -59
- package/src/components/pagination/pagination.test.tsx +122 -57
- package/src/components/pagination/pagination.tsx +575 -77
- package/src/components/password/password.stories.tsx +18 -3
- package/src/components/password/password.tsx +29 -9
- package/src/components/popover/popover.stories.tsx +26 -5
- package/src/components/popover/popover.tsx +15 -23
- package/src/components/progress/progress.stories.tsx +1 -0
- package/src/components/radio-group/index.ts +1 -0
- package/src/components/radio-group/radio-group.stories.tsx +251 -0
- package/src/components/radio-group/radio-group.tsx +212 -0
- package/src/components/scroll-area/scroll-area.stories.tsx +1 -0
- package/src/components/select/select.stories.tsx +118 -19
- package/src/components/select/select.tsx +67 -62
- package/src/components/skeleton/skeleton.stories.tsx +1 -0
- package/src/components/stack/stack.stories.tsx +179 -89
- package/src/components/stack/stack.tsx +2 -2
- package/src/components/stepper/index.ts +1 -1
- package/src/components/stepper/stepper.stories.tsx +767 -83
- package/src/components/stepper/stepper.test.tsx +18 -18
- package/src/components/stepper/stepper.tsx +554 -0
- package/src/components/switch/switch.stories.tsx +15 -1
- package/src/components/switch/switch.tsx +17 -4
- package/src/components/table/index.ts +0 -2
- package/src/components/table/table.stories.tsx +131 -18
- package/src/components/table/table.test.tsx +1 -1
- package/src/components/table/table.tsx +183 -77
- package/src/components/tabs/tabs.stories.tsx +373 -155
- package/src/components/tabs/tabs.test.tsx +12 -12
- package/src/components/tabs/tabs.tsx +72 -149
- package/src/components/tag/index.ts +0 -1
- package/src/components/tag/tag.stories.tsx +155 -120
- package/src/components/tag/tag.tsx +47 -95
- package/src/components/textarea/textarea.stories.tsx +8 -22
- package/src/components/textarea/textarea.tsx +17 -79
- package/src/components/timeline/timeline.stories.tsx +323 -42
- package/src/components/timeline/timeline.tsx +359 -132
- package/src/components/toast/toast.stories.tsx +1 -0
- package/src/components/tooltip/tooltip.tsx +11 -9
- package/src/components/tree/index.ts +0 -1
- package/src/components/tree/tree.stories.tsx +365 -408
- package/src/components/tree/tree.test.tsx +163 -0
- package/src/components/tree/tree.tsx +212 -36
- package/src/hooks/useAsync/__doc__/useAsync.stories.tsx +5 -5
- package/src/hooks/useClipboard/__doc__/useClipboard.stories.tsx +1 -3
- package/src/hooks/useDebounceCallback/__doc__/useDebouncedCallback.stories.tsx +6 -6
- package/src/hooks/useDocumentTitle/__doc__/useDocumentTitle.stories.tsx +1 -1
- package/src/hooks/useEventListener/__test__/useEventListener.test.tsx +1 -1
- package/src/hooks/useLocalStorage/__doc__/useLocalStorage.stories.tsx +1 -1
- package/src/hooks/usePagination/usePagination.tsx +36 -24
- package/src/styles/theme.css +1 -1
- package/src/utils/form.tsx +67 -37
- package/src/utils/index.ts +1 -1
- package/src/__doc__/Migration.mdx +0 -475
- package/src/components/auto-complete/auto-complete-primitives.tsx +0 -155
- package/src/components/background-image/background-image.stories.tsx +0 -21
- package/src/components/background-image/background-image.test.tsx +0 -29
- package/src/components/background-image/background-image.tsx +0 -23
- package/src/components/background-image/index.ts +0 -1
- package/src/components/button/button.variants.ts +0 -44
- package/src/components/button/components/loader-overlay.tsx +0 -21
- package/src/components/button/components/loading-icon.tsx +0 -47
- package/src/components/dropzone/upload-primitives.tsx +0 -310
- package/src/components/dropzone/use-dropzone.ts +0 -122
- package/src/components/empty-state/empty-state.stories.tsx +0 -56
- package/src/components/empty-state/empty-state.tsx +0 -39
- package/src/components/empty-state/index.ts +0 -1
- package/src/components/heading/heading.stories.tsx +0 -74
- package/src/components/heading/heading.tsx +0 -28
- package/src/components/heading/heading.variants.ts +0 -27
- package/src/components/heading/index.ts +0 -1
- package/src/components/kbd/kbd.variants.ts +0 -26
- package/src/components/menu/util/render-menu-item.tsx +0 -54
- package/src/components/multi-select/hooks/use-multi-select.ts +0 -66
- package/src/components/multi-select/index.ts +0 -1
- package/src/components/multi-select/multi-select.stories.tsx +0 -294
- package/src/components/multi-select/multi-select.tsx +0 -300
- package/src/components/multi-select/multi-select.variants.ts +0 -22
- package/src/components/pagination/components/pagination-option.tsx +0 -27
- package/src/components/show/index.ts +0 -1
- package/src/components/show/show.stories.tsx +0 -197
- package/src/components/show/show.test.tsx +0 -41
- package/src/components/show/show.tsx +0 -16
- package/src/components/stepper/Stepper.tsx +0 -190
- package/src/components/stepper/context/stepper-context.tsx +0 -11
- package/src/components/table/table-primitives.tsx +0 -122
- package/src/components/table/table.model.ts +0 -20
- package/src/components/table-pagination/index.ts +0 -2
- package/src/components/table-pagination/table-pagination.model.ts +0 -2
- package/src/components/table-pagination/table-pagination.stories.tsx +0 -23
- package/src/components/table-pagination/table-pagination.test.tsx +0 -32
- package/src/components/table-pagination/table-pagination.tsx +0 -108
- package/src/components/tabs/context/tabs-context.tsx +0 -14
- package/src/components/tag/tag.variants.ts +0 -31
- package/src/components/timeline/timeline-status.ts +0 -5
- package/src/components/tree/hooks/use-controllable-tree-state.ts +0 -80
- package/src/components/tree/tree-primitives.tsx +0 -126
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
2
|
-
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
3
|
-
import { ChangeEvent, HTMLProps } from "react";
|
|
4
|
-
import { ClassName } from "@/models";
|
|
5
|
-
import { usePagination, usePaginationProps } from "../../hooks";
|
|
6
|
-
import { cn } from "../../lib";
|
|
7
|
-
import { Button } from "../button";
|
|
8
|
-
import { PageSize, TABLE_PAGE_SIZES } from "./table-pagination.model";
|
|
9
|
-
|
|
10
|
-
interface TablePaginationExtendedProps {
|
|
11
|
-
containerClassName?: ClassName;
|
|
12
|
-
containerProps?: HTMLProps<HTMLDivElement>;
|
|
13
|
-
selectClassName?: ClassName;
|
|
14
|
-
selectProps?: HTMLProps<HTMLSelectElement>;
|
|
15
|
-
sizes?: PageSize[] | false;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
type Props = {
|
|
19
|
-
setPageSize?: (value: PageSize) => void;
|
|
20
|
-
pageSize?: PageSize;
|
|
21
|
-
} & Omit<usePaginationProps, "pageSize"> &
|
|
22
|
-
TablePaginationExtendedProps;
|
|
23
|
-
|
|
24
|
-
export const TablePagination = ({
|
|
25
|
-
containerClassName,
|
|
26
|
-
containerProps,
|
|
27
|
-
selectClassName,
|
|
28
|
-
selectProps,
|
|
29
|
-
sizes = TABLE_PAGE_SIZES,
|
|
30
|
-
...props
|
|
31
|
-
}: Props) => {
|
|
32
|
-
const [pageSize = TABLE_PAGE_SIZES[0], setPageSize] =
|
|
33
|
-
useControllableState<PageSize>({
|
|
34
|
-
onChange: props?.setPageSize,
|
|
35
|
-
prop: props?.pageSize,
|
|
36
|
-
defaultProp: TABLE_PAGE_SIZES[0],
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const { range, next, prev, isFirstPage, isLastPage, goTo } = usePagination({
|
|
40
|
-
...props,
|
|
41
|
-
pageSize,
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const changePageSize = (event: ChangeEvent<HTMLSelectElement>) => {
|
|
45
|
-
const { value } = event.target;
|
|
46
|
-
const newPageSize = Number(value) as PageSize;
|
|
47
|
-
setPageSize(newPageSize);
|
|
48
|
-
goTo(1);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<div
|
|
53
|
-
data-slot="table-pagination"
|
|
54
|
-
{...containerProps}
|
|
55
|
-
className={cn(
|
|
56
|
-
"flex justify-center items-center gap-x-4 bg-background border border-[#D9D9D9] rounded-2xl py-2",
|
|
57
|
-
containerClassName,
|
|
58
|
-
)}
|
|
59
|
-
>
|
|
60
|
-
{sizes && (
|
|
61
|
-
<select
|
|
62
|
-
data-slot="table-pagination-size-trigger"
|
|
63
|
-
{...selectProps}
|
|
64
|
-
value={pageSize}
|
|
65
|
-
onChange={changePageSize}
|
|
66
|
-
className={cn(
|
|
67
|
-
"border border-input rounded-md w-fit min-w-[3rem] bg-background p-2 ring-offset-background",
|
|
68
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
69
|
-
selectClassName,
|
|
70
|
-
)}
|
|
71
|
-
>
|
|
72
|
-
{sizes.map((option: number, index) => (
|
|
73
|
-
<option
|
|
74
|
-
key={index}
|
|
75
|
-
value={option}
|
|
76
|
-
data-slot="table-pagination-size-option"
|
|
77
|
-
>
|
|
78
|
-
{option}
|
|
79
|
-
</option>
|
|
80
|
-
))}
|
|
81
|
-
</select>
|
|
82
|
-
)}
|
|
83
|
-
<span data-slot="table-pagination-range">
|
|
84
|
-
{range.start} - {range.end} de {props.totalItems}
|
|
85
|
-
</span>
|
|
86
|
-
<div className="flex gap-2">
|
|
87
|
-
<Button
|
|
88
|
-
data-slot="table-pagination-prev"
|
|
89
|
-
size="icon"
|
|
90
|
-
variant="ghost"
|
|
91
|
-
disabled={isFirstPage}
|
|
92
|
-
onClick={prev}
|
|
93
|
-
>
|
|
94
|
-
<ChevronLeft data-slot="table-pagination-prev-icon" />
|
|
95
|
-
</Button>
|
|
96
|
-
<Button
|
|
97
|
-
data-slot="table-pagination-next"
|
|
98
|
-
size="icon"
|
|
99
|
-
variant="ghost"
|
|
100
|
-
disabled={isLastPage}
|
|
101
|
-
onClick={next}
|
|
102
|
-
>
|
|
103
|
-
<ChevronRight data-slot="table-pagination-next-icon" />
|
|
104
|
-
</Button>
|
|
105
|
-
</div>
|
|
106
|
-
</div>
|
|
107
|
-
);
|
|
108
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createSafeContext } from "../../../utils";
|
|
2
|
-
|
|
3
|
-
interface TabsContextProps {
|
|
4
|
-
activeTab: string;
|
|
5
|
-
setActiveTab: (tab: string) => void;
|
|
6
|
-
targetRef: HTMLButtonElement | null;
|
|
7
|
-
setTargetRef: (element: HTMLButtonElement | null) => void;
|
|
8
|
-
variant: "default" | "background";
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const [useTabsContext, TabsContextProvider] =
|
|
12
|
-
createSafeContext<TabsContextProps>();
|
|
13
|
-
|
|
14
|
-
export type { TabsContextProps };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { cva, VariantProps } from "class-variance-authority";
|
|
2
|
-
|
|
3
|
-
export const tagVariants = cva(
|
|
4
|
-
"inline-flex items-center relative overflow-hidden bg-gray-100 gap-1 px-2.5 py-0.5 text-xs font-normal transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
5
|
-
{
|
|
6
|
-
variants: {
|
|
7
|
-
rounded: {
|
|
8
|
-
default: "rounded-(--radius-tag)",
|
|
9
|
-
full: "rounded-full",
|
|
10
|
-
square: "rounded-sm",
|
|
11
|
-
},
|
|
12
|
-
variant: {
|
|
13
|
-
primary:
|
|
14
|
-
"bg-primary border-primary text-primary-foreground hover:bg-primary/80",
|
|
15
|
-
secondary:
|
|
16
|
-
"bg-secondary border-secondary !text-secondary-foreground hover:bg-secondary/80",
|
|
17
|
-
error: "bg-error border-error text-error-foreground hover:bg-error/80",
|
|
18
|
-
success:
|
|
19
|
-
"bg-success border-success text-success-foreground hover:bg-success/80",
|
|
20
|
-
outline: "border border-foreground text-foreground",
|
|
21
|
-
borderless: "text-foreground",
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
defaultVariants: {
|
|
25
|
-
rounded: "default",
|
|
26
|
-
variant: "primary",
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
export type TagVariant = VariantProps<typeof tagVariants>;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
2
|
-
import { useCallback } from "react";
|
|
3
|
-
|
|
4
|
-
interface UseControllableTreeStateProps {
|
|
5
|
-
defaultExpandedKeys: string[];
|
|
6
|
-
defaultSelectedKeys: string[];
|
|
7
|
-
selectedKeys?: string[];
|
|
8
|
-
expandedKeys?: string[];
|
|
9
|
-
multiSelect: boolean;
|
|
10
|
-
onSelect?: (selectedKeys: string[]) => void;
|
|
11
|
-
onExpand?: (expandedKeys: string[]) => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function useControllableTreeState({
|
|
15
|
-
defaultExpandedKeys,
|
|
16
|
-
defaultSelectedKeys,
|
|
17
|
-
selectedKeys: selectedKeysProp,
|
|
18
|
-
expandedKeys: expandedKeysProp,
|
|
19
|
-
multiSelect,
|
|
20
|
-
onSelect,
|
|
21
|
-
onExpand,
|
|
22
|
-
}: UseControllableTreeStateProps) {
|
|
23
|
-
const [expandedKeys = new Set(), setExpandedKeys] = useControllableState<
|
|
24
|
-
Set<string>
|
|
25
|
-
>({
|
|
26
|
-
prop: expandedKeysProp ? new Set(expandedKeysProp) : undefined,
|
|
27
|
-
defaultProp: new Set(defaultExpandedKeys),
|
|
28
|
-
onChange: (keys) => onExpand?.(Array.from(keys)),
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const [selectedKeys = new Set(), setSelectedKeys] = useControllableState<
|
|
32
|
-
Set<string>
|
|
33
|
-
>({
|
|
34
|
-
prop: selectedKeysProp ? new Set(selectedKeysProp) : undefined,
|
|
35
|
-
defaultProp: new Set(defaultSelectedKeys),
|
|
36
|
-
onChange: (keys) => onSelect?.(Array.from(keys)),
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const handleToggle = useCallback(
|
|
40
|
-
(nodeId: string) => {
|
|
41
|
-
setExpandedKeys((prev) => {
|
|
42
|
-
const next = new Set(prev);
|
|
43
|
-
if (next.has(nodeId)) {
|
|
44
|
-
next.delete(nodeId);
|
|
45
|
-
} else {
|
|
46
|
-
next.add(nodeId);
|
|
47
|
-
}
|
|
48
|
-
return next;
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
[setExpandedKeys],
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const handleSelect = useCallback(
|
|
55
|
-
(nodeId: string) => {
|
|
56
|
-
setSelectedKeys((prev) => {
|
|
57
|
-
const next = new Set(prev);
|
|
58
|
-
if (multiSelect) {
|
|
59
|
-
if (next.has(nodeId)) {
|
|
60
|
-
next.delete(nodeId);
|
|
61
|
-
} else {
|
|
62
|
-
next.add(nodeId);
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
next.clear();
|
|
66
|
-
next.add(nodeId);
|
|
67
|
-
}
|
|
68
|
-
return next;
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
[multiSelect, setSelectedKeys],
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
expandedKeys,
|
|
76
|
-
selectedKeys,
|
|
77
|
-
handleToggle,
|
|
78
|
-
handleSelect,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { ChevronRight } from "lucide-react";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import type {
|
|
4
|
-
TreeItemProps as TreeItemPrimitiveProps,
|
|
5
|
-
TreeProps,
|
|
6
|
-
} from "react-aria-components";
|
|
7
|
-
import {
|
|
8
|
-
Button,
|
|
9
|
-
Collection,
|
|
10
|
-
composeRenderProps as cr,
|
|
11
|
-
TreeItemContent as TreeItemContentPrimitive,
|
|
12
|
-
TreeItem as TreeItemPrimitive,
|
|
13
|
-
Tree as TreePrimitive,
|
|
14
|
-
} from "react-aria-components";
|
|
15
|
-
import { tv } from "tailwind-variants";
|
|
16
|
-
import { OverrideProps } from "../../models";
|
|
17
|
-
|
|
18
|
-
const treeStyles = tv({
|
|
19
|
-
base: "flex py-2 rounded-lg bg-bg cursor-default lg:text-sm flex-col overflow-auto outline-none",
|
|
20
|
-
variants: {
|
|
21
|
-
isFocusVisible: {
|
|
22
|
-
true: "outline-offset-[-1px] outline-2 outline-primary",
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const TreeRoot = <T extends object>({ className, ...props }: TreeProps<T>) => {
|
|
28
|
-
return (
|
|
29
|
-
<TreePrimitive
|
|
30
|
-
data-slot="tree"
|
|
31
|
-
className={cr(className, (className, renderProps) =>
|
|
32
|
-
treeStyles({
|
|
33
|
-
...renderProps,
|
|
34
|
-
className,
|
|
35
|
-
}),
|
|
36
|
-
)}
|
|
37
|
-
{...props}
|
|
38
|
-
>
|
|
39
|
-
{props.children}
|
|
40
|
-
</TreePrimitive>
|
|
41
|
-
);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const itemStyles = tv({
|
|
45
|
-
base: [
|
|
46
|
-
"[&_[data-expanded]_[slot=chevron]_[data-slot=icon]]:rotate-90 outline-none [--padding:20px] p-[0.286rem_0.286rem_0.286rem_0.571rem] pl-[calc((var(--tree-item-level)-1)*20px+0.571rem+var(--padding))]",
|
|
47
|
-
"[&_[slot=chevron]]:outline-none [&_[slot=chevron]_[data-slot=icon]]:text-muted-fg",
|
|
48
|
-
"data-[has-child-rows]:[--padding:0px]",
|
|
49
|
-
],
|
|
50
|
-
variants: {
|
|
51
|
-
isExpanded: {
|
|
52
|
-
true: "[&_[slot=chevron]_[data-slot=icon]]:text-fg [&_[slot=chevron]_[data-slot=icon]]:rotate-90 [&_[slot=chevron]_[data-slot=icon]]:transition [&_[slot=chevron]_[data-slot=icon]]:duration-200",
|
|
53
|
-
},
|
|
54
|
-
isFocusVisible: {
|
|
55
|
-
true: "[&_[slot=chevron]_[data-slot=icon]]:text-fg focus:outline-none focus-visible:ring-1 focus-visible:ring-primary",
|
|
56
|
-
},
|
|
57
|
-
isDisabled: {
|
|
58
|
-
true: "opacity-50 forced-colors:text-[GrayText]",
|
|
59
|
-
},
|
|
60
|
-
isSelected: {
|
|
61
|
-
true: "bg-accent text-accent-foreground",
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const TreeItem = <T extends object>({
|
|
67
|
-
className,
|
|
68
|
-
...props
|
|
69
|
-
}: OverrideProps<TreeItemPrimitiveProps<T>, { id: string | number }>) => {
|
|
70
|
-
return (
|
|
71
|
-
<TreeItemPrimitive
|
|
72
|
-
data-slot="tree-item"
|
|
73
|
-
data-key={props.id}
|
|
74
|
-
className={cr(className, (className, renderProps) =>
|
|
75
|
-
itemStyles({
|
|
76
|
-
...renderProps,
|
|
77
|
-
className,
|
|
78
|
-
}),
|
|
79
|
-
)}
|
|
80
|
-
{...props}
|
|
81
|
-
>
|
|
82
|
-
{props.children}
|
|
83
|
-
</TreeItemPrimitive>
|
|
84
|
-
);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const TreeItemContent = (
|
|
88
|
-
props: React.ComponentProps<typeof TreeItemContentPrimitive>,
|
|
89
|
-
) => {
|
|
90
|
-
return (
|
|
91
|
-
<TreeItemContentPrimitive
|
|
92
|
-
data-slot="tree-item-content"
|
|
93
|
-
{...props}
|
|
94
|
-
data-key={props.key}
|
|
95
|
-
>
|
|
96
|
-
<div className="flex items-center gap-x-1">
|
|
97
|
-
{props.children as React.ReactNode}
|
|
98
|
-
</div>
|
|
99
|
-
</TreeItemContentPrimitive>
|
|
100
|
-
);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const TreeItemIndicator = () => {
|
|
104
|
-
return (
|
|
105
|
-
<Button
|
|
106
|
-
data-slot="tree-item-chevron"
|
|
107
|
-
className="shrink-0 relative"
|
|
108
|
-
slot="chevron"
|
|
109
|
-
>
|
|
110
|
-
<ChevronRight className="size-5" data-slot="icon" />
|
|
111
|
-
</Button>
|
|
112
|
-
);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const TreeItemLabel = (props: React.HtmlHTMLAttributes<HTMLSpanElement>) => {
|
|
116
|
-
return <span data-slot="tree-item-label" {...props} />;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export {
|
|
120
|
-
Collection,
|
|
121
|
-
TreeItem,
|
|
122
|
-
TreeItemContent,
|
|
123
|
-
TreeItemIndicator,
|
|
124
|
-
TreeItemLabel,
|
|
125
|
-
TreeRoot,
|
|
126
|
-
};
|