Skip to content

Commit 7c2d979

Browse files
var-porodpellier
authored andcommitted
feat(tree-view): update typings, enhance callback details, and simplify stories
1 parent ad31edc commit 7c2d979

File tree

5 files changed

+11
-21
lines changed

5 files changed

+11
-21
lines changed

packages/ods-react/src/components/tree-view/src/components/tree-view/TreeView.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ interface TreeViewValueChangeDetail {
99
value: string[];
1010
}
1111

12+
interface TreeViewExpandedChangeDetail {
13+
expandedValue: string[];
14+
}
15+
1216
/**
1317
* @inheritDoc TreeViewRootProp
1418
*/
@@ -64,7 +68,7 @@ const TreeView: FC<TreeViewProp> = forwardRef(({
6468
onValueChange({ value: details.checkedValue });
6569
}
6670

67-
function handleExpandedChange(details: { expandedValue: string[] }): void {
71+
function handleExpandedChange(details: TreeViewExpandedChangeDetail): void {
6872
if (!onExpandedChange) {
6973
return;
7074
}
@@ -110,5 +114,6 @@ TreeView.displayName = 'TreeView';
110114
export {
111115
TreeView,
112116
type TreeViewProp,
117+
type TreeViewExpandedChangeDetail,
113118
type TreeViewValueChangeDetail,
114119
};

packages/ods-react/src/components/tree-view/src/contexts/useTreeView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type JSX, type ReactNode, createContext, useContext } from 'react';
2-
import { type TreeViewValueChangeDetail } from '../components/tree-view/TreeView';
2+
import { type TreeViewExpandedChangeDetail, type TreeViewValueChangeDetail } from '../components/tree-view/TreeView';
33

44
type CustomData = Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any
55

@@ -47,7 +47,7 @@ type TreeViewRootProp = {
4747
/**
4848
* Callback fired when the expanded value(s) changes.
4949
*/
50-
onExpandedChange?: (details: { expandedValue: string[] }) => void;
50+
onExpandedChange?: (details: TreeViewExpandedChangeDetail) => void;
5151
/**
5252
* Callback fired when the value(s) changes.
5353
*/
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { TreeView, type TreeViewProp, type TreeViewValueChangeDetail } from './components/tree-view/TreeView';
1+
export { TreeView, type TreeViewProp, type TreeViewExpandedChangeDetail, type TreeViewValueChangeDetail } from './components/tree-view/TreeView';
22
export { TreeViewNode, type TreeViewNodeProp } from './components/tree-view-node/TreeViewNode';
33
export { TreeViewNodes, type TreeViewNodesProp } from './components/tree-view-nodes/TreeViewNodes';
44
export { type TreeViewCustomRendererArg, type TreeViewItem } from './contexts/useTreeView';

packages/storybook/stories/components/tree-view/technical-information.mdx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ import * as TreeViewStories from './tree-view.stories';
3030

3131
<OdsCanvas of={ TreeViewStories.Default } sourceState="shown" />
3232

33-
<Heading label="Default expand all" level={ 3 } />
34-
35-
<OdsCanvas of={ TreeViewStories.DefaultExpandAll } sourceState="shown" />
36-
3733
<Heading label="Multiple" level={ 3 } />
3834

3935
<OdsCanvas of={ TreeViewStories.Multiple } sourceState="shown" />

packages/storybook/stories/components/tree-view/tree-view.stories.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ import {
1111
type TreeViewValueChangeDetail,
1212
} from '../../../../ods-react/src/components/tree-view/src';
1313
import { CONTROL_CATEGORY } from '../../../src/constants/controls';
14-
import { orderControls } from '../../../src/helpers/controls';
14+
import { excludeFromDemoControls, orderControls } from '../../../src/helpers/controls';
1515
import { staticSourceRenderConfig } from '../../../src/helpers/source';
1616

1717
type Story = StoryObj<TreeViewProp>;
1818

1919
const meta: Meta<TreeViewProp> = {
20+
argTypes: excludeFromDemoControls(['defaultExpandedValue', 'defaultValue', 'items', 'onExpandedChange', 'onValueChange', 'expandedValue', 'value']),
2021
component: TreeView,
2122
subcomponents: { TreeViewNode },
2223
title: 'React Components/Tree View',
@@ -63,24 +64,12 @@ export const Demo: Story = {
6364
);
6465
},
6566
argTypes: orderControls({
66-
defaultExpandedValue: {
67-
table: {
68-
category: CONTROL_CATEGORY.general,
69-
},
70-
control: 'object',
71-
},
7267
disabled: {
7368
table: {
7469
category: CONTROL_CATEGORY.general,
7570
},
7671
control: 'boolean',
7772
},
78-
expandedValue: {
79-
table: {
80-
category: CONTROL_CATEGORY.general,
81-
},
82-
control: 'object',
83-
},
8473
multiple: {
8574
table: {
8675
category: CONTROL_CATEGORY.general,

0 commit comments

Comments
 (0)