diff --git a/src/components/TreeList/__stories__/stories/WithGroupSelectionAndCustomIconStory.tsx b/src/components/TreeList/__stories__/stories/WithGroupSelectionAndCustomIconStory.tsx index 54f28ac658..a766f22490 100644 --- a/src/components/TreeList/__stories__/stories/WithGroupSelectionAndCustomIconStory.tsx +++ b/src/components/TreeList/__stories__/stories/WithGroupSelectionAndCustomIconStory.tsx @@ -99,7 +99,7 @@ export const WithGroupSelectionAndCustomIconStory = ({ > ) : undefined, diff --git a/src/components/TreeList/__stories__/stories/WithItemLinksAndActionsStory.tsx b/src/components/TreeList/__stories__/stories/WithItemLinksAndActionsStory.tsx index 996f864e78..ddb8a31677 100644 --- a/src/components/TreeList/__stories__/stories/WithItemLinksAndActionsStory.tsx +++ b/src/components/TreeList/__stories__/stories/WithItemLinksAndActionsStory.tsx @@ -96,7 +96,10 @@ export const WithItemLinksAndActionsStory = (props: WithItemLinksAndActionsStory : expandButtonLabel, }} > - + ) : ( ) : undefined, diff --git a/src/components/TreeSelect/__stories__/components/WithItemLinksAndActionsExample.tsx b/src/components/TreeSelect/__stories__/components/WithItemLinksAndActionsExample.tsx index 4f6f056828..72ba812284 100644 --- a/src/components/TreeSelect/__stories__/components/WithItemLinksAndActionsExample.tsx +++ b/src/components/TreeSelect/__stories__/components/WithItemLinksAndActionsExample.tsx @@ -97,7 +97,10 @@ export const WithItemLinksAndActionsExample = (storyProps: WithItemLinksAndActio })); }} > - + ) : ( {} +export interface ListItemExpandIconProps extends ListItemExpandIconRenderProps {} export const ListItemExpandIcon = ({ expanded, disableTransition, - position = 'start', + usageRole: usage = 'action', disabled, }: ListItemExpandIconProps) => { return ( ; +const DefaultExample = (props: ListItemExpandIconProps) => { + return ; +}; + export const Default = { - render: (args) => ( - - - Position: start - - - - - - - Position: start - - - - - - - ), + render: DefaultExample, } satisfies Story; const InsideButtonExample = (props: ListItemExpandIconProps) => { const [expanded, setExpanded] = React.useState(false); - const [position, setPosition] = React.useState<'start' | 'end'>('start'); return ( - - - Icon position: - - - - Click on button to change state: - - - + ); }; diff --git a/src/components/useList/components/ListItemExpandIcon/__stories__/list-item-expand-icon.md b/src/components/useList/components/ListItemExpandIcon/__stories__/list-item-expand-icon.md index dc62d2fc6e..8a4905fc86 100644 --- a/src/components/useList/components/ListItemExpandIcon/__stories__/list-item-expand-icon.md +++ b/src/components/useList/components/ListItemExpandIcon/__stories__/list-item-expand-icon.md @@ -14,22 +14,9 @@ import { #### Base example: ```jsx - - - Position: start - - - - - - - Position: start - - - - - - +const DefaultExample = (props: ListItemExpandIconProps) => { + return ; +}; ``` @@ -37,34 +24,24 @@ import { #### Render icon inside Button component: ```jsx - const InsideButtonExample = (props: ListItemExpandIconProps) => { const [expanded, setExpanded] = React.useState(false); - const [position, setPosition] = React.useState<'start' | 'end'>('start'); return ( - - - Icon position: - - - - Click on button to change state: - - - + ); }; ``` + +#### Props + +| Name | Description | Type | Default | +| :---------------- | :---------------------------------------------- | :--------------------------------------------------: | :-----: | +| expanded | icon state | `boolean` | | +| disableTransition | disable animation while `expanded` state change | `boolean` | | +| disabled | disabled view type | `boolean` | | +| usageRole | The type of behavior of the component | `state`, `action`, `state-inverse`, `action-inverse` | | diff --git a/src/components/useList/components/ListItemView/ListItemViewContent.tsx b/src/components/useList/components/ListItemView/ListItemViewContent.tsx index aebe10086a..7068c5ef62 100644 --- a/src/components/useList/components/ListItemView/ListItemViewContent.tsx +++ b/src/components/useList/components/ListItemView/ListItemViewContent.tsx @@ -63,10 +63,9 @@ export const ListItemViewContent = ({ }: ListItemViewContentProps) => { const expandIconNode = isGroup ? ( ) : null; diff --git a/src/components/useList/components/ListItemView/__stories__/ListItemView.stories.tsx b/src/components/useList/components/ListItemView/__stories__/ListItemView.stories.tsx index 5163b2e12b..6c01af940e 100644 --- a/src/components/useList/components/ListItemView/__stories__/ListItemView.stories.tsx +++ b/src/components/useList/components/ListItemView/__stories__/ListItemView.stories.tsx @@ -256,7 +256,7 @@ const stories: ListItemViewProps[] = [ expanded: false, expandIconPosition: 'end', renderExpandIcon: (props) => ( - ), diff --git a/src/components/useList/types.ts b/src/components/useList/types.ts index 87c6e7d670..f334644fcd 100644 --- a/src/components/useList/types.ts +++ b/src/components/useList/types.ts @@ -39,13 +39,17 @@ export type ItemState = { indentation: number; }; -type ExpandIconPositionType = 'start' | 'end'; - export interface ListItemExpandIconRenderProps { - position: ExpandIconPositionType; - expanded: boolean | undefined; - disableTransition: boolean | undefined; - disabled: boolean | undefined; + /** + * The type of behavior of the component + * + * - action - to indicate user actions. For example, for an icon inside a button; + * - state - to indicate the current state of the element; + */ + usageRole: 'state' | 'action' | 'state-inverse' | 'action-inverse'; + expanded?: boolean; + disableTransition?: boolean; + disabled?: boolean; } export type ListItemViewContentType = { @@ -65,7 +69,7 @@ export type ListItemViewContentType = { /** * @default - 'start' */ - expandIconPosition?: ExpandIconPositionType; + expandIconPosition?: 'start' | 'end'; /** * Will be applied if `isGroup` props is `true` */