Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(useList): added migration guide to set of useList components #1728

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
});
```
Loading