@dxos/react-ui 0.9.1-main.c7dcc2e112 → 0.9.1-staging.ee54ba693a
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/lib/browser/{chunk-HFJYTGHU.mjs → chunk-CMHHVHX3.mjs} +4 -1
- package/dist/lib/browser/chunk-CMHHVHX3.mjs.map +7 -0
- package/dist/lib/browser/{chunk-F3PLXTDA.mjs → chunk-GTHV4WYK.mjs} +123 -232
- package/dist/lib/browser/chunk-GTHV4WYK.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1069 -976
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +5 -5
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/browser/translations.mjs +1 -1
- package/dist/lib/node-esm/{chunk-LLVUYLAM.mjs → chunk-3VSKWNCQ.mjs} +123 -232
- package/dist/lib/node-esm/chunk-3VSKWNCQ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OJYUPUCY.mjs → chunk-P4KFQGJI.mjs} +4 -1
- package/dist/lib/node-esm/chunk-P4KFQGJI.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1069 -976
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +5 -5
- package/dist/lib/node-esm/testing/index.mjs.map +2 -2
- package/dist/lib/node-esm/translations.mjs +1 -1
- package/dist/types/src/components/Avatars/Avatar.d.ts +1 -1
- package/dist/types/src/components/Avatars/Avatar.d.ts.map +1 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.d.ts +3 -3
- package/dist/types/src/components/Breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/types/src/components/Button/Button.d.ts +2 -2
- package/dist/types/src/components/Button/Button.d.ts.map +1 -1
- package/dist/types/src/components/Button/IconButton.stories.d.ts +3 -0
- package/dist/types/src/components/Button/IconButton.stories.d.ts.map +1 -1
- package/dist/types/src/components/Button/MicButton.d.ts +24 -0
- package/dist/types/src/components/Button/MicButton.d.ts.map +1 -0
- package/dist/types/src/components/Button/MicButton.stories.d.ts +57 -0
- package/dist/types/src/components/Button/MicButton.stories.d.ts.map +1 -0
- package/dist/types/src/components/Button/SystemIconButton.d.ts +15 -2
- package/dist/types/src/components/Button/SystemIconButton.d.ts.map +1 -1
- package/dist/types/src/components/Button/SystemIconButton.stories.d.ts +51 -0
- package/dist/types/src/components/Button/SystemIconButton.stories.d.ts.map +1 -0
- package/dist/types/src/components/Button/ToggleGroup.d.ts +2 -2
- package/dist/types/src/components/Button/ToggleGroup.d.ts.map +1 -1
- package/dist/types/src/components/Button/index.d.ts +1 -0
- package/dist/types/src/components/Button/index.d.ts.map +1 -1
- package/dist/types/src/components/Calendar/Calendar.d.ts.map +1 -1
- package/dist/types/src/components/Calendar/Calendar.theme.d.ts.map +1 -1
- package/dist/types/src/components/Card/Card.d.ts +8 -8
- package/dist/types/src/components/Card/Card.d.ts.map +1 -1
- package/dist/types/src/components/Card/Card.stories.d.ts +2 -2
- package/dist/types/src/components/Card/Card.stories.d.ts.map +1 -1
- package/dist/types/src/components/Carousel/Carousel.d.ts +29 -6
- package/dist/types/src/components/Carousel/Carousel.d.ts.map +1 -1
- package/dist/types/src/components/Carousel/Carousel.stories.d.ts +48 -2
- package/dist/types/src/components/Carousel/Carousel.stories.d.ts.map +1 -1
- package/dist/types/src/components/Column/Column.d.ts +2 -2
- package/dist/types/src/components/Column/Column.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/AlertDialog.d.ts +2 -2
- package/dist/types/src/components/Dialog/AlertDialog.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/Dialog.d.ts +1 -1
- package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts +2 -2
- package/dist/types/src/components/Dialog/Dialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/Icon/Icon.stories.d.ts +5 -0
- package/dist/types/src/components/Icon/Icon.stories.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.d.ts +4 -1
- package/dist/types/src/components/Input/Input.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +3 -3
- package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.theme.d.ts +10 -10
- package/dist/types/src/components/Input/Input.theme.d.ts.map +1 -1
- package/dist/types/src/components/Input/SegmentedInput.d.ts +8 -8
- package/dist/types/src/components/Input/SegmentedInput.d.ts.map +1 -1
- package/dist/types/src/components/Input/index.d.ts +0 -1
- package/dist/types/src/components/Input/index.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.d.ts +3 -3
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/dist/types/src/components/Menu/ContextMenu.d.ts +1 -1
- package/dist/types/src/components/Menu/ContextMenu.d.ts.map +1 -1
- package/dist/types/src/components/Menu/DropdownMenu.d.ts +2 -2
- package/dist/types/src/components/Menu/DropdownMenu.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.d.ts +1 -1
- package/dist/types/src/components/Message/Message.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.stories.d.ts +2 -2
- package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/components/Panel/Panel.d.ts +1 -1
- package/dist/types/src/components/Panel/Panel.d.ts.map +1 -1
- package/dist/types/src/components/Panel/Panel.theme.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts +2 -2
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts +2 -0
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts +1 -0
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScrollContainer/ScrollContainer.stories.d.ts +2 -2
- package/dist/types/src/components/ScrollContainer/ScrollContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/Select/Select.d.ts +1 -1
- package/dist/types/src/components/Select/Select.d.ts.map +1 -1
- package/dist/types/src/components/Select/Select.stories.d.ts +2 -2
- package/dist/types/src/components/Select/Select.stories.d.ts.map +1 -1
- package/dist/types/src/components/Separator/Separator.d.ts.map +1 -1
- package/dist/types/src/components/Splitter/Splitter.d.ts +30 -16
- package/dist/types/src/components/Splitter/Splitter.d.ts.map +1 -1
- package/dist/types/src/components/Splitter/Splitter.stories.d.ts +6 -1
- package/dist/types/src/components/Splitter/Splitter.stories.d.ts.map +1 -1
- package/dist/types/src/components/Splitter/Splitter.theme.d.ts +3 -1
- package/dist/types/src/components/Splitter/Splitter.theme.d.ts.map +1 -1
- package/dist/types/src/components/Tag/Tag.d.ts +1 -1
- package/dist/types/src/components/Tag/Tag.d.ts.map +1 -1
- package/dist/types/src/components/Tag/Tag.theme.d.ts +1 -1
- package/dist/types/src/components/Tag/Tag.theme.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.d.ts +1 -1
- package/dist/types/src/components/Toast/Toast.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.theme.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.d.ts +3 -3
- package/dist/types/src/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts +2 -2
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/primitives/ThemeProvider/TranslationsProvider.d.ts +1 -8
- package/dist/types/src/primitives/ThemeProvider/TranslationsProvider.d.ts.map +1 -1
- package/dist/types/src/theme/defaultTheme.d.ts.map +1 -1
- package/dist/types/src/theme/index.d.ts +0 -2
- package/dist/types/src/theme/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util/slots.d.ts +1 -1
- package/dist/types/src/util/slots.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -21
- package/src/components/Avatars/Avatar.stories.tsx +2 -2
- package/src/components/Avatars/Avatar.theme.ts +1 -1
- package/src/components/Avatars/Avatar.tsx +3 -3
- package/src/components/Breadcrumb/Breadcrumb.tsx +6 -6
- package/src/components/Button/Button.tsx +2 -2
- package/src/components/Button/MicButton.stories.tsx +60 -0
- package/src/components/Button/MicButton.tsx +117 -0
- package/src/components/Button/SystemIconButton.stories.tsx +91 -0
- package/src/components/Button/SystemIconButton.tsx +113 -2
- package/src/components/Button/ToggleGroup.tsx +2 -2
- package/src/components/Button/index.ts +1 -0
- package/src/components/Calendar/Calendar.theme.ts +2 -0
- package/src/components/Calendar/Calendar.tsx +3 -3
- package/src/components/Card/Card.stories.tsx +2 -2
- package/src/components/Card/Card.tsx +11 -11
- package/src/components/Carousel/Carousel.stories.tsx +42 -18
- package/src/components/Carousel/Carousel.tsx +169 -33
- package/src/components/Column/Column.tsx +4 -7
- package/src/components/Dialog/AlertDialog.stories.tsx +2 -2
- package/src/components/Dialog/AlertDialog.tsx +13 -13
- package/src/components/Dialog/Dialog.stories.tsx +3 -4
- package/src/components/Dialog/Dialog.theme.ts +1 -1
- package/src/components/Dialog/Dialog.tsx +12 -12
- package/src/components/Icon/Icon.stories.tsx +23 -0
- package/src/components/Icon/Icon.theme.ts +1 -1
- package/src/components/Input/Input.stories.tsx +13 -5
- package/src/components/Input/Input.theme.ts +17 -39
- package/src/components/Input/Input.tsx +30 -13
- package/src/components/Input/SegmentedInput.tsx +50 -41
- package/src/components/Input/index.ts +0 -1
- package/src/components/Main/Main.tsx +3 -3
- package/src/components/MediaPlayer/MediaPlayer.tsx +4 -4
- package/src/components/Menu/ContextMenu.tsx +8 -8
- package/src/components/Menu/DropdownMenu.tsx +12 -13
- package/src/components/Message/Message.stories.tsx +2 -2
- package/src/components/Message/Message.theme.ts +1 -1
- package/src/components/Message/Message.tsx +2 -2
- package/src/components/Panel/Panel.theme.ts +2 -1
- package/src/components/Panel/Panel.tsx +1 -1
- package/src/components/Popover/Popover.tsx +9 -9
- package/src/components/ScrollArea/ScrollArea.tsx +7 -4
- package/src/components/ScrollContainer/ScrollContainer.stories.tsx +2 -2
- package/src/components/ScrollContainer/ScrollContainer.tsx +2 -2
- package/src/components/Select/Select.stories.tsx +2 -2
- package/src/components/Select/Select.theme.ts +1 -1
- package/src/components/Select/Select.tsx +14 -14
- package/src/components/Separator/Separator.tsx +1 -0
- package/src/components/Splitter/Splitter.stories.tsx +84 -20
- package/src/components/Splitter/Splitter.theme.ts +20 -3
- package/src/components/Splitter/Splitter.tsx +320 -47
- package/src/components/Tag/Tag.stories.tsx +1 -1
- package/src/components/Tag/Tag.theme.ts +1 -1
- package/src/components/Tag/Tag.tsx +3 -5
- package/src/components/Toast/Toast.theme.ts +3 -2
- package/src/components/Toast/Toast.tsx +5 -5
- package/src/components/Toolbar/Toolbar.tsx +10 -10
- package/src/components/Tooltip/Tooltip.stories.tsx +2 -2
- package/src/components/Tooltip/Tooltip.tsx +3 -3
- package/src/components/index.ts +0 -1
- package/src/exemplars/tabster.stories.tsx +1 -1
- package/src/index.ts +1 -1
- package/src/primitives/ThemeProvider/TranslationsProvider.tsx +10 -30
- package/src/testing/decorators/withLayout.tsx +4 -4
- package/src/theme/defaultTheme.ts +0 -4
- package/src/theme/index.ts +0 -2
- package/src/translations.ts +8 -0
- package/src/util/slots.ts +5 -5
- package/dist/lib/browser/chunk-F3PLXTDA.mjs.map +0 -7
- package/dist/lib/browser/chunk-HFJYTGHU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LLVUYLAM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OJYUPUCY.mjs.map +0 -7
- package/dist/types/src/components/Input/constants.d.ts +0 -5
- package/dist/types/src/components/Input/constants.d.ts.map +0 -1
- package/dist/types/src/components/List/List.d.ts +0 -29
- package/dist/types/src/components/List/List.d.ts.map +0 -1
- package/dist/types/src/components/List/List.stories.d.ts +0 -16
- package/dist/types/src/components/List/List.stories.d.ts.map +0 -1
- package/dist/types/src/components/List/List.theme.d.ts +0 -7
- package/dist/types/src/components/List/List.theme.d.ts.map +0 -1
- package/dist/types/src/components/List/ListDropIndicator.d.ts +0 -13
- package/dist/types/src/components/List/ListDropIndicator.d.ts.map +0 -1
- package/dist/types/src/components/List/Tree.d.ts +0 -23
- package/dist/types/src/components/List/Tree.d.ts.map +0 -1
- package/dist/types/src/components/List/Tree.stories.d.ts +0 -15
- package/dist/types/src/components/List/Tree.stories.d.ts.map +0 -1
- package/dist/types/src/components/List/TreeDropIndicator.d.ts +0 -8
- package/dist/types/src/components/List/TreeDropIndicator.d.ts.map +0 -1
- package/dist/types/src/components/List/Treegrid.d.ts +0 -33
- package/dist/types/src/components/List/Treegrid.d.ts.map +0 -1
- package/dist/types/src/components/List/Treegrid.stories.d.ts +0 -12
- package/dist/types/src/components/List/Treegrid.stories.d.ts.map +0 -1
- package/dist/types/src/components/List/Treegrid.theme.d.ts +0 -7
- package/dist/types/src/components/List/Treegrid.theme.d.ts.map +0 -1
- package/dist/types/src/components/List/index.d.ts +0 -4
- package/dist/types/src/components/List/index.d.ts.map +0 -1
- package/src/components/Input/constants.ts +0 -8
- package/src/components/List/List.stories.tsx +0 -234
- package/src/components/List/List.theme.ts +0 -47
- package/src/components/List/List.tsx +0 -171
- package/src/components/List/ListDropIndicator.tsx +0 -69
- package/src/components/List/Tree.stories.tsx +0 -87
- package/src/components/List/Tree.tsx +0 -74
- package/src/components/List/TreeDropIndicator.tsx +0 -70
- package/src/components/List/Treegrid.stories.tsx +0 -156
- package/src/components/List/Treegrid.theme.ts +0 -35
- package/src/components/List/Treegrid.tsx +0 -187
- package/src/components/List/index.ts +0 -7
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
|
|
8
|
-
import { withTheme } from '../../testing';
|
|
9
|
-
import { Tree, TreeItem } from './Tree';
|
|
10
|
-
|
|
11
|
-
type StorybookTreeProps = {
|
|
12
|
-
data: any;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type StorybookTreeItemProps = {
|
|
16
|
-
data: any;
|
|
17
|
-
prefix?: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const isScalar = (data: any) => !(typeof data === 'object' || Array.isArray(data));
|
|
21
|
-
|
|
22
|
-
const createKey = (key: string, prefix?: string) => (prefix === undefined ? key : `${prefix}.${key}`);
|
|
23
|
-
|
|
24
|
-
const StorybookTreeItem = ({ data, prefix }: StorybookTreeItemProps) => {
|
|
25
|
-
const keys = Array.isArray(data) ? Array.from(data.keys()) : Object.keys(data);
|
|
26
|
-
return (
|
|
27
|
-
<Tree.Root>
|
|
28
|
-
{keys.map((key) => {
|
|
29
|
-
const id = createKey(String(key), prefix);
|
|
30
|
-
const value = data[key as keyof typeof data];
|
|
31
|
-
const valueIsScalar = isScalar(value);
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<TreeItem.Root key={id} id={id} collapsible={!valueIsScalar} defaultOpen>
|
|
35
|
-
<div className='grow flex'>
|
|
36
|
-
{valueIsScalar ? <TreeItem.MockOpenTrigger /> : <TreeItem.OpenTrigger />}
|
|
37
|
-
<TreeItem.Heading classNames='grow pt-1'>{valueIsScalar ? String(value) : key}</TreeItem.Heading>
|
|
38
|
-
</div>
|
|
39
|
-
{!valueIsScalar && (
|
|
40
|
-
<TreeItem.Body className='ps-2'>
|
|
41
|
-
<Tree.Branch>
|
|
42
|
-
<StorybookTreeItem data={value} prefix={id} />
|
|
43
|
-
</Tree.Branch>
|
|
44
|
-
</TreeItem.Body>
|
|
45
|
-
)}
|
|
46
|
-
</TreeItem.Root>
|
|
47
|
-
);
|
|
48
|
-
})}
|
|
49
|
-
</Tree.Root>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const DefaultStory = ({ data }: StorybookTreeProps) => {
|
|
54
|
-
return <StorybookTreeItem data={data} />;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const meta = {
|
|
58
|
-
title: 'ui/react-ui-core/components/Tree',
|
|
59
|
-
component: Tree as any,
|
|
60
|
-
render: DefaultStory,
|
|
61
|
-
decorators: [withTheme()],
|
|
62
|
-
} satisfies Meta<typeof DefaultStory>;
|
|
63
|
-
|
|
64
|
-
export default meta;
|
|
65
|
-
|
|
66
|
-
type Story = StoryObj<typeof meta>;
|
|
67
|
-
|
|
68
|
-
export const Default: Story = {
|
|
69
|
-
args: {
|
|
70
|
-
data: {
|
|
71
|
-
foo: 100,
|
|
72
|
-
bar: {
|
|
73
|
-
zoo: 200,
|
|
74
|
-
},
|
|
75
|
-
tags: ['a', 'b', 'c'],
|
|
76
|
-
items: [
|
|
77
|
-
{
|
|
78
|
-
a: true,
|
|
79
|
-
b: 100,
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
c: 200,
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { type ComponentPropsWithoutRef, type FC, type ForwardRefExoticComponent, forwardRef } from 'react';
|
|
6
|
-
|
|
7
|
-
import { type ThemedClassName } from '../../util';
|
|
8
|
-
import {
|
|
9
|
-
LIST_ITEM_NAME,
|
|
10
|
-
List,
|
|
11
|
-
ListItem,
|
|
12
|
-
type ListItemCollapsibleContentProps,
|
|
13
|
-
type ListItemHeadingProps,
|
|
14
|
-
type ListItemOpenTriggerProps,
|
|
15
|
-
type ListItemRootProps,
|
|
16
|
-
type ListProps,
|
|
17
|
-
type ListScopedProps,
|
|
18
|
-
useListItemContext,
|
|
19
|
-
} from './List';
|
|
20
|
-
import { TreeDropIndicator } from './TreeDropIndicator';
|
|
21
|
-
|
|
22
|
-
type TreeRootProps = ListProps;
|
|
23
|
-
|
|
24
|
-
type TreeItemProps = ListItemRootProps;
|
|
25
|
-
|
|
26
|
-
const TreeRoot = forwardRef<HTMLOListElement, TreeRootProps>((props, forwardedRef) => {
|
|
27
|
-
return <List {...props} ref={forwardedRef} />;
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
type TreeBranchProps = TreeRootProps;
|
|
31
|
-
|
|
32
|
-
const TreeBranch = forwardRef<HTMLOListElement, ListScopedProps<TreeBranchProps>>(
|
|
33
|
-
({ __listScope, ...props }, forwardedRef) => {
|
|
34
|
-
const { headingId } = useListItemContext(LIST_ITEM_NAME, __listScope);
|
|
35
|
-
return <List {...props} aria-labelledby={headingId} ref={forwardedRef} />;
|
|
36
|
-
},
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
const TreeItemRoot = forwardRef<HTMLLIElement, ListItemRootProps>((props, forwardedRef) => {
|
|
40
|
-
return <ListItem.Root role='treeitem' {...props} ref={forwardedRef} />;
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
type TreeItemHeadingProps = ListItemHeadingProps;
|
|
44
|
-
|
|
45
|
-
const TreeItemHeading = ListItem.Heading;
|
|
46
|
-
|
|
47
|
-
type TreeItemOpenTriggerProps = ListItemOpenTriggerProps;
|
|
48
|
-
|
|
49
|
-
const TreeItemOpenTrigger = ListItem.OpenTrigger;
|
|
50
|
-
|
|
51
|
-
const MockTreeItemOpenTrigger = ListItem.MockOpenTrigger;
|
|
52
|
-
|
|
53
|
-
type TreeItemBodyProps = ListItemCollapsibleContentProps;
|
|
54
|
-
|
|
55
|
-
const TreeItemBody: ForwardRefExoticComponent<TreeItemBodyProps> = ListItem.CollapsibleContent;
|
|
56
|
-
|
|
57
|
-
export const Tree = { Root: TreeRoot, Branch: TreeBranch };
|
|
58
|
-
export const TreeItem: {
|
|
59
|
-
Root: ForwardRefExoticComponent<TreeItemProps>;
|
|
60
|
-
Heading: ForwardRefExoticComponent<TreeItemHeadingProps>;
|
|
61
|
-
Body: ForwardRefExoticComponent<TreeItemBodyProps>;
|
|
62
|
-
OpenTrigger: ForwardRefExoticComponent<TreeItemOpenTriggerProps>;
|
|
63
|
-
MockOpenTrigger: FC<ThemedClassName<Omit<ComponentPropsWithoutRef<'div'>, 'children'>>>;
|
|
64
|
-
DropIndicator: typeof TreeDropIndicator;
|
|
65
|
-
} = {
|
|
66
|
-
Root: TreeItemRoot,
|
|
67
|
-
Heading: TreeItemHeading,
|
|
68
|
-
Body: TreeItemBody,
|
|
69
|
-
OpenTrigger: TreeItemOpenTrigger,
|
|
70
|
-
MockOpenTrigger: MockTreeItemOpenTrigger,
|
|
71
|
-
DropIndicator: TreeDropIndicator,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export type { TreeRootProps, TreeItemProps, TreeItemHeadingProps, TreeItemBodyProps, TreeItemOpenTriggerProps };
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Instruction } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
|
|
6
|
-
import React, { type CSSProperties, type HTMLAttributes } from 'react';
|
|
7
|
-
|
|
8
|
-
// Tree item hitbox
|
|
9
|
-
// https://github.com/atlassian/pragmatic-drag-and-drop/blob/main/packages/hitbox/constellation/index/about.mdx#tree-item
|
|
10
|
-
|
|
11
|
-
type InstructionType = Exclude<Instruction, { type: 'instruction-blocked' }>['type'];
|
|
12
|
-
type Orientation = 'sibling' | 'child';
|
|
13
|
-
|
|
14
|
-
const edgeToOrientationMap: Record<InstructionType, Orientation> = {
|
|
15
|
-
'reorder-above': 'sibling',
|
|
16
|
-
'reorder-below': 'sibling',
|
|
17
|
-
'make-child': 'child',
|
|
18
|
-
reparent: 'child',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const orientationStyles: Record<Orientation, HTMLAttributes<HTMLElement>['className']> = {
|
|
22
|
-
// TODO(wittjosiah): Stop using left/right here.
|
|
23
|
-
sibling:
|
|
24
|
-
'h-(--line-thickness) left-(--horizontal-indent) right-0 bg-accent-bg before:left-(--negative-terminal-size)',
|
|
25
|
-
child: 'inset-0 border-[length:var(--line-thickness)] before:invisible',
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const instructionStyles: Record<InstructionType, HTMLAttributes<HTMLElement>['className']> = {
|
|
29
|
-
'reorder-above': 'top-(--line-offset) before:top-(--offset-terminal)',
|
|
30
|
-
'reorder-below': 'bottom-(--line-offset) before:bottom-(--offset-terminal)',
|
|
31
|
-
'make-child': 'border-accent-bg',
|
|
32
|
-
// TODO(wittjosiah): This is not occurring in the current implementation.
|
|
33
|
-
reparent: '',
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const strokeSize = 2;
|
|
37
|
-
const terminalSize = 8;
|
|
38
|
-
const offsetToAlignTerminalWithLine = (strokeSize - terminalSize) / 2;
|
|
39
|
-
|
|
40
|
-
export type DropIndicatorProps = {
|
|
41
|
-
instruction: Instruction;
|
|
42
|
-
gap?: number;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const TreeDropIndicator = ({ instruction, gap = 0 }: DropIndicatorProps) => {
|
|
46
|
-
const lineOffset = `calc(-0.5 * (${gap}px + ${strokeSize}px))`;
|
|
47
|
-
const isBlocked = instruction.type === 'instruction-blocked';
|
|
48
|
-
const desiredInstruction = isBlocked ? instruction.desired : instruction;
|
|
49
|
-
const orientation = edgeToOrientationMap[desiredInstruction.type];
|
|
50
|
-
if (isBlocked) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<div
|
|
56
|
-
style={
|
|
57
|
-
{
|
|
58
|
-
'--line-thickness': `${strokeSize}px`,
|
|
59
|
-
'--line-offset': `${lineOffset}`,
|
|
60
|
-
'--terminal-size': `${terminalSize}px`,
|
|
61
|
-
'--terminal-radius': `${terminalSize / 2}px`,
|
|
62
|
-
'--negative-terminal-size': `-${terminalSize}px`,
|
|
63
|
-
'--offset-terminal': `${offsetToAlignTerminalWithLine}px`,
|
|
64
|
-
'--horizontal-indent': `${desiredInstruction.currentLevel * desiredInstruction.indentPerLevel + 4}px`,
|
|
65
|
-
} as CSSProperties
|
|
66
|
-
}
|
|
67
|
-
className={`absolute z-10 pointer-events-none before:w-(--terminal-size) before:h-(--terminal-size) box-border before:absolute before:border-[length:--line-thickness] before:border-solid before:border-accent-bg before:rounded-full ${orientationStyles[orientation]} ${instructionStyles[desiredInstruction.type]}`}
|
|
68
|
-
></div>
|
|
69
|
-
);
|
|
70
|
-
};
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
|
|
8
|
-
import { random } from '@dxos/random';
|
|
9
|
-
|
|
10
|
-
import { withTheme } from '../../testing';
|
|
11
|
-
import { Icon } from '../Icon';
|
|
12
|
-
import { Treegrid, TREEGRID_PARENT_OF_SEPARATOR, TREEGRID_PATH_SEPARATOR } from './Treegrid';
|
|
13
|
-
|
|
14
|
-
random.seed(1234);
|
|
15
|
-
|
|
16
|
-
type StorybookNode = {
|
|
17
|
-
id: string;
|
|
18
|
-
title: string;
|
|
19
|
-
icon?: string;
|
|
20
|
-
nodes?: StorybookNode[];
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type StorybookIteratorNode = {
|
|
24
|
-
node: StorybookNode;
|
|
25
|
-
path: string[];
|
|
26
|
-
parentOf?: string[];
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const content = {
|
|
30
|
-
id: 'root',
|
|
31
|
-
title: 'Root',
|
|
32
|
-
nodes: [
|
|
33
|
-
{
|
|
34
|
-
id: random.string.uuid(),
|
|
35
|
-
title: 'Personal Space',
|
|
36
|
-
icon: 'ph--house--regular',
|
|
37
|
-
nodes: [
|
|
38
|
-
{
|
|
39
|
-
id: random.string.uuid(),
|
|
40
|
-
title: random.commerce.productName(),
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
id: random.string.uuid(),
|
|
44
|
-
title: random.commerce.productName(),
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
id: random.string.uuid(),
|
|
48
|
-
title: random.commerce.productName(),
|
|
49
|
-
nodes: [
|
|
50
|
-
{
|
|
51
|
-
id: random.string.uuid(),
|
|
52
|
-
title: random.commerce.productName(),
|
|
53
|
-
nodes: [
|
|
54
|
-
{
|
|
55
|
-
id: random.string.uuid(),
|
|
56
|
-
title: random.commerce.productName(),
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
id: random.string.uuid(),
|
|
60
|
-
title: random.commerce.productName(),
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
id: random.string.uuid(),
|
|
70
|
-
title: random.commerce.productName(),
|
|
71
|
-
icon: 'ph--planet--regular',
|
|
72
|
-
nodes: [
|
|
73
|
-
{
|
|
74
|
-
id: random.string.uuid(),
|
|
75
|
-
title: random.commerce.productName(),
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
id: random.string.uuid(),
|
|
81
|
-
title: random.commerce.productName(),
|
|
82
|
-
icon: 'ph--sailboat--regular',
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
id: random.string.uuid(),
|
|
86
|
-
title: random.commerce.productName(),
|
|
87
|
-
icon: 'ph--planet--regular',
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
} as StorybookNode;
|
|
91
|
-
|
|
92
|
-
function* visitor(node: StorybookNode, isOpen?: (node: StorybookNode) => boolean): Generator<StorybookIteratorNode> {
|
|
93
|
-
const stack: StorybookIteratorNode[] = [
|
|
94
|
-
{
|
|
95
|
-
node,
|
|
96
|
-
path: [node.id],
|
|
97
|
-
parentOf: (node.nodes ?? []).map(({ id }) => id),
|
|
98
|
-
},
|
|
99
|
-
];
|
|
100
|
-
while (stack.length > 0) {
|
|
101
|
-
const { node, path, parentOf } = stack.pop()!;
|
|
102
|
-
if (path.length > 1) {
|
|
103
|
-
yield { node, path, parentOf };
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const children = Array.from(node.nodes ?? []);
|
|
107
|
-
if (path.length === 1 || isOpen?.(node)) {
|
|
108
|
-
for (let i = children.length - 1; i >= 0; i--) {
|
|
109
|
-
const child = children[i];
|
|
110
|
-
stack.push({
|
|
111
|
-
node: child,
|
|
112
|
-
path: [...path, child.id],
|
|
113
|
-
...((child.nodes?.length ?? 0) > 0 && {
|
|
114
|
-
parentOf: child.nodes!.map(({ id }) => id),
|
|
115
|
-
}),
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const flattenedContent = Array.from(visitor(content, () => true));
|
|
123
|
-
|
|
124
|
-
const DefaultStory = () => {
|
|
125
|
-
return (
|
|
126
|
-
<Treegrid.Root gridTemplateColumns='1fr'>
|
|
127
|
-
{flattenedContent.map(({ node, parentOf, path }) => {
|
|
128
|
-
return (
|
|
129
|
-
<Treegrid.Row
|
|
130
|
-
key={node.id}
|
|
131
|
-
id={path.join(TREEGRID_PATH_SEPARATOR)}
|
|
132
|
-
{...(parentOf && { parentOf: parentOf.join(TREEGRID_PARENT_OF_SEPARATOR) })}
|
|
133
|
-
>
|
|
134
|
-
<Treegrid.Cell indent classNames='flex items-center'>
|
|
135
|
-
{node.icon && <Icon icon={node.icon} classNames='w-[1em] h-[1em] my-1' />}
|
|
136
|
-
{node.title}
|
|
137
|
-
</Treegrid.Cell>
|
|
138
|
-
</Treegrid.Row>
|
|
139
|
-
);
|
|
140
|
-
})}
|
|
141
|
-
</Treegrid.Root>
|
|
142
|
-
);
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const meta = {
|
|
146
|
-
title: 'ui/react-ui-core/components/Treegrid',
|
|
147
|
-
component: Treegrid.Root as any,
|
|
148
|
-
render: DefaultStory,
|
|
149
|
-
decorators: [withTheme()],
|
|
150
|
-
} satisfies Meta<typeof DefaultStory>;
|
|
151
|
-
|
|
152
|
-
export default meta;
|
|
153
|
-
|
|
154
|
-
type Story = StoryObj<typeof meta>;
|
|
155
|
-
|
|
156
|
-
export const Default: Story = {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { mx } from '@dxos/ui-theme';
|
|
6
|
-
import type { ComponentFunction, Theme } from '@dxos/ui-types';
|
|
7
|
-
|
|
8
|
-
export type TreegridStyleProps = Partial<{
|
|
9
|
-
level: number;
|
|
10
|
-
indent: boolean;
|
|
11
|
-
}>;
|
|
12
|
-
|
|
13
|
-
const levelStyles = new Map<number, string>([
|
|
14
|
-
[1, '[&>.indent:first-of-type]:pl-0 font-medium'],
|
|
15
|
-
[2, '[&>.indent:first-of-type]:pl-0'],
|
|
16
|
-
[3, '[&>.indent:first-of-type]:pl-1'],
|
|
17
|
-
[4, '[&>.indent:first-of-type]:pl-2'],
|
|
18
|
-
[5, '[&>.indent:first-of-type]:pl-3'],
|
|
19
|
-
[6, '[&>.indent:first-of-type]:pl-4'],
|
|
20
|
-
[7, '[&>.indent:first-of-type]:pl-5'],
|
|
21
|
-
[8, '[&>.indent:first-of-type]:pl-6'],
|
|
22
|
-
]);
|
|
23
|
-
|
|
24
|
-
const root: ComponentFunction<TreegridStyleProps> = (_, ...etc) => mx('grid', ...etc);
|
|
25
|
-
|
|
26
|
-
const row: ComponentFunction<TreegridStyleProps> = ({ level = 1 }, ...etc) =>
|
|
27
|
-
mx(levelStyles.get(Math.min(Math.max(Math.round(level), 1), 8)), ...etc);
|
|
28
|
-
|
|
29
|
-
const cell: ComponentFunction<TreegridStyleProps> = ({ indent }, ...etc) => mx(indent && 'indent', ...etc);
|
|
30
|
-
|
|
31
|
-
export const treegridTheme: Theme<TreegridStyleProps> = {
|
|
32
|
-
root,
|
|
33
|
-
row,
|
|
34
|
-
cell,
|
|
35
|
-
};
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { useFocusFinders } from '@fluentui/react-tabster';
|
|
6
|
-
import { type Scope, createContextScope } from '@radix-ui/react-context';
|
|
7
|
-
import { Primitive } from '@radix-ui/react-primitive';
|
|
8
|
-
import { Slot } from '@radix-ui/react-slot';
|
|
9
|
-
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
10
|
-
import React, {
|
|
11
|
-
type CSSProperties,
|
|
12
|
-
type ComponentPropsWithRef,
|
|
13
|
-
type KeyboardEvent,
|
|
14
|
-
forwardRef,
|
|
15
|
-
useCallback,
|
|
16
|
-
} from 'react';
|
|
17
|
-
|
|
18
|
-
import { useThemeContext } from '../../hooks';
|
|
19
|
-
import { composable, composableProps } from '../../util';
|
|
20
|
-
import { type ThemedClassName } from '../../util';
|
|
21
|
-
|
|
22
|
-
// TODO(thure): https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/treegrid_role
|
|
23
|
-
|
|
24
|
-
const TREEGRID_ROW_NAME = 'Treegrid.Row';
|
|
25
|
-
|
|
26
|
-
type TreegridRowScopedProps<P> = P & { __treegridRowScope?: Scope };
|
|
27
|
-
|
|
28
|
-
const [createTreegridRowContext, createTreegridRowScope] = createContextScope(TREEGRID_ROW_NAME, []);
|
|
29
|
-
|
|
30
|
-
type TreegridRowContextValue = {
|
|
31
|
-
open?: boolean;
|
|
32
|
-
onOpenChange?: (nextOpen: boolean) => void;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const [TreegridRowProvider, useTreegridRowContext] =
|
|
36
|
-
createTreegridRowContext<TreegridRowContextValue>(TREEGRID_ROW_NAME);
|
|
37
|
-
|
|
38
|
-
// TODO(burdon): Replace with functions.
|
|
39
|
-
export const TREEGRID_PATH_SEPARATOR = '~';
|
|
40
|
-
export const TREEGRID_PARENT_OF_SEPARATOR = ' ';
|
|
41
|
-
|
|
42
|
-
type TreegridRootProps = ThemedClassName<ComponentPropsWithRef<typeof Primitive.div>> & {
|
|
43
|
-
gridTemplateColumns?: CSSProperties['gridTemplateColumns'];
|
|
44
|
-
asChild?: boolean;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const TreegridRoot = composable<HTMLDivElement, TreegridRootProps>(
|
|
48
|
-
({ asChild, classNames, children, style, gridTemplateColumns, onKeyDown: onKeyDownProp, ...props }, forwardedRef) => {
|
|
49
|
-
const { tx } = useThemeContext();
|
|
50
|
-
const { className, role: _role, ...rest } = composableProps<HTMLDivElement>(props, { classNames });
|
|
51
|
-
const Comp = asChild ? Slot : Primitive.div;
|
|
52
|
-
const { findFirstFocusable } = useFocusFinders();
|
|
53
|
-
|
|
54
|
-
const handleKeyDown = useCallback(
|
|
55
|
-
(event: KeyboardEvent<HTMLDivElement>) => {
|
|
56
|
-
switch (event.key) {
|
|
57
|
-
case 'ArrowDown':
|
|
58
|
-
case 'ArrowUp': {
|
|
59
|
-
const direction = event.key === 'ArrowDown' ? 'down' : 'up';
|
|
60
|
-
const target = event.target as HTMLElement;
|
|
61
|
-
|
|
62
|
-
// Find ancestor with data-arrow-keys containing the relevant direction.
|
|
63
|
-
const ancestorWithArrowKeys = target.closest(`[data-arrow-keys*="${direction}"], [data-arrow-keys="all"]`);
|
|
64
|
-
|
|
65
|
-
// If no ancestor with data-arrow-keys found, proceed with row navigation.
|
|
66
|
-
if (!ancestorWithArrowKeys) {
|
|
67
|
-
// Find the closest row
|
|
68
|
-
const currentRow = target.closest('[role="row"]');
|
|
69
|
-
if (currentRow) {
|
|
70
|
-
// Find the treegrid container.
|
|
71
|
-
const treegrid = currentRow.closest('[role="treegrid"]');
|
|
72
|
-
if (treegrid) {
|
|
73
|
-
// Get all rows in the treegrid.
|
|
74
|
-
const rows = Array.from(treegrid.querySelectorAll('[role="row"]'));
|
|
75
|
-
const currentIndex = rows.indexOf(currentRow as Element);
|
|
76
|
-
|
|
77
|
-
// Find next or previous row.
|
|
78
|
-
const nextIndex = direction === 'down' ? currentIndex + 1 : currentIndex - 1;
|
|
79
|
-
const targetRow = rows[nextIndex];
|
|
80
|
-
|
|
81
|
-
if (targetRow) {
|
|
82
|
-
// Focus the first focusable element in the target row.
|
|
83
|
-
const firstFocusable = findFirstFocusable(targetRow as HTMLElement);
|
|
84
|
-
if (firstFocusable) {
|
|
85
|
-
event.preventDefault();
|
|
86
|
-
firstFocusable.focus();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
onKeyDownProp?.(event);
|
|
96
|
-
},
|
|
97
|
-
[findFirstFocusable, onKeyDownProp],
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
return (
|
|
101
|
-
<Comp
|
|
102
|
-
role='treegrid'
|
|
103
|
-
{...rest}
|
|
104
|
-
className={tx('treegrid.root', {}, className)}
|
|
105
|
-
style={{ ...style, gridTemplateColumns }}
|
|
106
|
-
onKeyDown={handleKeyDown}
|
|
107
|
-
ref={forwardedRef}
|
|
108
|
-
>
|
|
109
|
-
{children}
|
|
110
|
-
</Comp>
|
|
111
|
-
);
|
|
112
|
-
},
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
type TreegridRowProps = ThemedClassName<ComponentPropsWithRef<typeof Primitive.div>> & {
|
|
116
|
-
id: string;
|
|
117
|
-
asChild?: boolean;
|
|
118
|
-
parentOf?: string;
|
|
119
|
-
defaultOpen?: boolean;
|
|
120
|
-
open?: boolean;
|
|
121
|
-
onOpenChange?(open: boolean): void;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const TreegridRow = forwardRef<HTMLDivElement, TreegridRowScopedProps<TreegridRowProps>>(
|
|
125
|
-
(
|
|
126
|
-
{
|
|
127
|
-
__treegridRowScope,
|
|
128
|
-
asChild,
|
|
129
|
-
classNames,
|
|
130
|
-
children,
|
|
131
|
-
id,
|
|
132
|
-
parentOf,
|
|
133
|
-
open: propsOpen,
|
|
134
|
-
defaultOpen,
|
|
135
|
-
onOpenChange: propsOnOpenChange,
|
|
136
|
-
...props
|
|
137
|
-
},
|
|
138
|
-
forwardedRef,
|
|
139
|
-
) => {
|
|
140
|
-
const { tx } = useThemeContext();
|
|
141
|
-
const Comp = asChild ? Slot : Primitive.div;
|
|
142
|
-
const pathParts = id.split(TREEGRID_PATH_SEPARATOR);
|
|
143
|
-
const level = pathParts.length - 1;
|
|
144
|
-
const [open, onOpenChange] = useControllableState({
|
|
145
|
-
prop: propsOpen,
|
|
146
|
-
onChange: propsOnOpenChange,
|
|
147
|
-
defaultProp: defaultOpen,
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
return (
|
|
151
|
-
<TreegridRowProvider open={open} onOpenChange={onOpenChange} scope={__treegridRowScope}>
|
|
152
|
-
<Comp
|
|
153
|
-
role='row'
|
|
154
|
-
aria-level={level}
|
|
155
|
-
className={tx('treegrid.row', { level }, classNames)}
|
|
156
|
-
{...(parentOf && { 'aria-expanded': open, 'aria-owns': parentOf })}
|
|
157
|
-
{...props}
|
|
158
|
-
id={id}
|
|
159
|
-
ref={forwardedRef}
|
|
160
|
-
>
|
|
161
|
-
{children}
|
|
162
|
-
</Comp>
|
|
163
|
-
</TreegridRowProvider>
|
|
164
|
-
);
|
|
165
|
-
},
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
type TreegridCellProps = ThemedClassName<ComponentPropsWithRef<typeof Primitive.div>> & { indent?: boolean };
|
|
169
|
-
|
|
170
|
-
const TreegridCell = forwardRef<HTMLDivElement, TreegridCellProps>(
|
|
171
|
-
({ classNames, children, indent, ...props }, forwardedRef) => {
|
|
172
|
-
const { tx } = useThemeContext();
|
|
173
|
-
return (
|
|
174
|
-
<div role='gridcell' className={tx('treegrid.cell', { indent }, classNames)} {...props} ref={forwardedRef}>
|
|
175
|
-
{children}
|
|
176
|
-
</div>
|
|
177
|
-
);
|
|
178
|
-
},
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
export type { TreegridRootProps, TreegridRowProps };
|
|
182
|
-
|
|
183
|
-
export const Treegrid = {
|
|
184
|
-
Root: TreegridRoot,
|
|
185
|
-
Row: TreegridRow,
|
|
186
|
-
Cell: TreegridCell,
|
|
187
|
-
};
|