diff --git a/src/components/TreeList/__stories__/stories/WithGroupSelectionAndCustomIconStory.tsx b/src/components/TreeList/__stories__/stories/WithGroupSelectionAndCustomIconStory.tsx index a766f22490..f5003e04a0 100644 --- a/src/components/TreeList/__stories__/stories/WithGroupSelectionAndCustomIconStory.tsx +++ b/src/components/TreeList/__stories__/stories/WithGroupSelectionAndCustomIconStory.tsx @@ -97,10 +97,12 @@ export const WithGroupSelectionAndCustomIconStory = ({ : expandButtonLabel, }} > - + + + ) : undefined, }} diff --git a/src/components/TreeList/__stories__/stories/WithItemLinksAndActionsStory.tsx b/src/components/TreeList/__stories__/stories/WithItemLinksAndActionsStory.tsx index ddb8a31677..caed3f9f40 100644 --- a/src/components/TreeList/__stories__/stories/WithItemLinksAndActionsStory.tsx +++ b/src/components/TreeList/__stories__/stories/WithItemLinksAndActionsStory.tsx @@ -96,10 +96,12 @@ 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 72ba812284..fc15d491e9 100644 --- a/src/components/TreeSelect/__stories__/components/WithItemLinksAndActionsExample.tsx +++ b/src/components/TreeSelect/__stories__/components/WithItemLinksAndActionsExample.tsx @@ -97,10 +97,12 @@ export const WithItemLinksAndActionsExample = (storyProps: WithItemLinksAndActio })); }} > - + + + ) : ( { return ( - ); }; -// For correct rendering inside `Button` component -ListItemExpandIcon.displayName = 'Icon'; +function getIconDirection({ + kind, + expanded, +}: Pick): ArrowToggleProps['direction'] { + if (expanded && kind === 'action') { + return 'top'; + } else if (expanded && kind === 'state') { + return 'bottom'; + } else if (expanded && kind === 'state-inverse') { + return 'bottom'; + } else if (kind === 'action') { + return 'bottom'; + } else if (kind === 'state') { + return 'right'; + } else if (kind === 'state-inverse') { + return 'left'; + } + + return 'bottom'; +} diff --git a/src/components/useList/components/ListItemExpandIcon/__stories__/ListItemExpandIcon.stories.tsx b/src/components/useList/components/ListItemExpandIcon/__stories__/ListItemExpandIcon.stories.tsx index ca354759ec..c91fbfe361 100644 --- a/src/components/useList/components/ListItemExpandIcon/__stories__/ListItemExpandIcon.stories.tsx +++ b/src/components/useList/components/ListItemExpandIcon/__stories__/ListItemExpandIcon.stories.tsx @@ -28,7 +28,9 @@ const InsideButtonExample = (props: ListItemExpandIconProps) => { return ( ); }; 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 8a4905fc86..ad23c42fd6 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 @@ -29,7 +29,9 @@ const InsideButtonExample = (props: ListItemExpandIconProps) => { return ( ); }; @@ -39,9 +41,9 @@ const InsideButtonExample = (props: ListItemExpandIconProps) => { #### 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` | | +| Name | Description | Type | Default | +| :---------------- | :---------------------------------------------- | :-------------------------------: | :-----: | +| expanded | icon state | `boolean` | | +| disableTransition | disable animation while `expanded` state change | `boolean` | | +| disabled | disabled view type | `boolean` | | +| kind | The type of behavior of the component | `state`, `state-inverse`,`action` | | diff --git a/src/components/useList/components/ListItemView/ListItemViewContent.tsx b/src/components/useList/components/ListItemView/ListItemViewContent.tsx index 7068c5ef62..8c0ff41e1f 100644 --- a/src/components/useList/components/ListItemView/ListItemViewContent.tsx +++ b/src/components/useList/components/ListItemView/ListItemViewContent.tsx @@ -58,12 +58,12 @@ export const ListItemViewContent = ({ expanded, selected, title, - expandIconPosition = 'start', + expandIconPlacement = 'start', renderExpandIcon: RenderExpandIcon = ListItemExpandIcon, }: ListItemViewContentProps) => { const expandIconNode = isGroup ? ( @@ -83,7 +83,7 @@ export const ListItemViewContent = ({ {renderSafeIndentation(indentation)} - {expandIconPosition === 'start' && expandIconNode} + {expandIconPlacement === 'start' && expandIconNode} {startSlot} @@ -110,7 +110,7 @@ export const ListItemViewContent = ({ - {expandIconPosition === 'end' && expandIconNode} + {expandIconPlacement === 'end' && expandIconNode} {endSlot} diff --git a/src/components/useList/components/ListItemView/__stories__/ListItemView.stories.tsx b/src/components/useList/components/ListItemView/__stories__/ListItemView.stories.tsx index 6c01af940e..0412881670 100644 --- a/src/components/useList/components/ListItemView/__stories__/ListItemView.stories.tsx +++ b/src/components/useList/components/ListItemView/__stories__/ListItemView.stories.tsx @@ -244,7 +244,7 @@ const stories: ListItemViewProps[] = [ indentation: 1, isGroup: true, expanded: false, - expandIconPosition: 'end', + expandIconPlacement: 'end', }, }, { @@ -254,10 +254,12 @@ const stories: ListItemViewProps[] = [ title: 'Custom icon end', isGroup: true, expanded: false, - expandIconPosition: 'end', + expandIconPlacement: 'end', renderExpandIcon: (props) => ( ), }, diff --git a/src/components/useList/types.ts b/src/components/useList/types.ts index f334644fcd..1914462aae 100644 --- a/src/components/useList/types.ts +++ b/src/components/useList/types.ts @@ -46,9 +46,10 @@ export interface ListItemExpandIconRenderProps { * - 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; + kind: 'state' | 'state-inverse' | 'action'; + disableTransition?: boolean; + expanded?: boolean; disabled?: boolean; } @@ -69,7 +70,7 @@ export type ListItemViewContentType = { /** * @default - 'start' */ - expandIconPosition?: 'start' | 'end'; + expandIconPlacement?: 'start' | 'end'; /** * Will be applied if `isGroup` props is `true` */