From 77ba528e995f328220de71473645a0973ddb449e Mon Sep 17 00:00:00 2001 From: Alexandr Isaev Date: Thu, 1 Aug 2024 15:29:26 +0300 Subject: [PATCH] feat(useList): added migration guide to set of useList components --- .../__stories__/components/ListWithDnd.tsx | 5 -- .../__stories__/docs/list-item-view.md | 5 +- src/components/useList/migration-guide.md | 78 +++++++++++++++++++ 3 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 src/components/useList/migration-guide.md diff --git a/src/components/useList/__stories__/components/ListWithDnd.tsx b/src/components/useList/__stories__/components/ListWithDnd.tsx index d2fad034a9..1b21848011 100644 --- a/src/components/useList/__stories__/components/ListWithDnd.tsx +++ b/src/components/useList/__stories__/components/ListWithDnd.tsx @@ -81,11 +81,6 @@ export const ListWithDnd = ({size, itemsCount, 'aria-label': ariaLabel}: ListWit list, }); - console.log( - '🚀 ~ {list.structure.visibleFlattenIds.map ~ props:', - props, - ); - return ( { | dragging | manage view of dragging element. Required for draggable list implementation | `boolean` | | | indentation | Affects the visual indentation of the element content | `number ` | | | hasSelectionIcon | Show selected icon if selected and reserve space for this icon | `boolean ` | | -| endSlot | Custom slot before `title` | `React.ReactNode` | | -| expanded | Adds a visual representation of a group element if the value is different from `undefined` | `string \| undefined` | | +| isGroup | Applies group styles view to list element | `boolean` | | +| expanded | Control group item view state expended/closed | `string \| undefined` | | | startSlot | Custom slot before `title` | `React.ReactNode` | | +| endSlot | Custom slot after `title` | `React.ReactNode` | | diff --git a/src/components/useList/migration-guide.md b/src/components/useList/migration-guide.md new file mode 100644 index 0000000000..7985e60b19 --- /dev/null +++ b/src/components/useList/migration-guide.md @@ -0,0 +1,78 @@ +# 6.23 + +## ListItemView: + +- changed prop `hasSelectionIcon?: boolean` to prop `selectionViewType?: 'multiple' | 'single'` with default value `multiple`; +- now mix of ccs class works that applied at root of component; +- ability to set item height by css custom property `--g-list-item-height`; +- new ability to pass custom react node as `content` prop; + +```diff + +``` + +## TreeList: + +- changed `mapItemDataToProps` prop name to `mapItemDataToContentProps`: + +```diff + + size="l" + list={list} +- mapItemDataToProps={item => ({title: item.text})} ++ mapItemDataToContentProps={item => ({title: item.text})} + multiple={multiple} + renderItem={({props, context: {childrenIds}}) => { + return ( + {childrenIds.length} : undefined} ++ content={{ ++ ...props.content, ++ endSlot: childrenIds ? ( ++ ++ ) : undefined, + }} + /> + ) + })} + /> +``` + +## getItemRenderState: + +- changed `mapItemDataToProps` prop name to `mapItemDataToContentProps`: + +```diff +const {props, context} = getItemRenderState({ + id, + size, + onItemClick, +- mapItemDataToProps: (x) => x, ++ mapItemDataToContentProps: (x) => x, + list, +}); +```