Skip to content

Commit

Permalink
feat(useList): added migration guide to set of useList components (#1728
Browse files Browse the repository at this point in the history
)
  • Loading branch information
IsaevAlexandr authored Aug 1, 2024
1 parent 0e22bde commit 69283f1
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 7 deletions.
5 changes: 0 additions & 5 deletions src/components/useList/__stories__/components/ListWithDnd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ export const ListWithDnd = ({size, itemsCount, 'aria-label': ariaLabel}: ListWit
list,
});

console.log(
'🚀 ~ {list.structure.visibleFlattenIds.map ~ props:',
props,
);

return (
<Draggable
draggableId={String(index)}
Expand Down
5 changes: 3 additions & 2 deletions src/components/useList/__stories__/docs/list-item-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const List = () => {
| 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` | |
78 changes: 78 additions & 0 deletions src/components/useList/migration-guide.md
Original file line number Diff line number Diff line change
@@ -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
<ListItemView
- hasSelectionIcon={hasSelectionIcon}
+ selectionViewType="multiple"
selected={selected}
height={height}
active={active}
activeOnHover={activeOnHover}
onClick={handleClick(props)}
- indentation={indentation}
- expanded={selected}
- title={title}
- subtitle={subtitle}
- startSlot={startSlot}
- endSlot={endSlot}
+ content={{
+ isGroup,
+ indentation,
+ expanded,
+ title,
+ subtitle,
+ startSlot,
+ endSlot,
}}
/>
```

## TreeList:

- changed `mapItemDataToProps` prop name to `mapItemDataToContentProps`:

```diff
<TreeList<{title: string}>
size="l"
list={list}
- mapItemDataToProps={item => ({title: item.text})}
+ mapItemDataToContentProps={item => ({title: item.text})}
multiple={multiple}
renderItem={({props, context: {childrenIds}}) => {
return (
<ListItemView
{...props}
- endSlot={childrenIds ? <Label>{childrenIds.length}</Label> : undefined}
+ content={{
+ ...props.content,
+ endSlot: childrenIds ? (
+ <Label>{childrenIds.length}</Label>
+ ) : undefined,
}}
/>
)
})}
/>
```

## getItemRenderState:

- changed `mapItemDataToProps` prop name to `mapItemDataToContentProps`:

```diff
const {props, context} = getItemRenderState({
id,
size,
onItemClick,
- mapItemDataToProps: (x) => x,
+ mapItemDataToContentProps: (x) => x,
list,
});
```

0 comments on commit 69283f1

Please sign in to comment.