Skip to content

Commit

Permalink
feat: add low level List.renderList()
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Jul 7, 2021
1 parent 780b24a commit c76e0f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
36 changes: 18 additions & 18 deletions packages/react-widgets/src/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ const List: List = React.forwardRef(function List<TDataItem>(
groupBy,
elementRef,
optionComponent: Option = ListOption,
renderList,
// onKeyDown,
...props
}: ListProps<TDataItem>,
Expand Down Expand Up @@ -263,7 +264,7 @@ const List: List = React.forwardRef(function List<TDataItem>(
)
}

const children = groupedData
const items = groupedData
? groupedData.map(([group, items], idx) => (
<div role="group" key={`group_${idx}`}>
<ListOptionGroup>
Expand All @@ -274,23 +275,22 @@ const List: List = React.forwardRef(function List<TDataItem>(
))
: data.map(renderOption)

return (
<div
id={id}
tabIndex={0}
ref={divRef}
{...elementProps}
aria-multiselectable={!!multiple}
className={cn(className, 'rw-list')}
role={elementProps.role ?? 'listbox'}
>
{React.Children.count(children) ? (
children
) : (
<div className="rw-list-empty">{emptyList()}</div>
)}
</div>
)
const rootProps = {
id,
tabIndex: 0,
ref: divRef,
...elementProps,
'aria-multiselectable': !!multiple,
className: cn(className, 'rw-list'),
role: elementProps.role ?? 'listbox',
children: React.Children.count(items) ? (
items
) : (
<div className="rw-list-empty">{emptyList()}</div>
),
}

return renderList ? renderList(rootProps) : <div {...rootProps} />
})

List.displayName = 'List'
Expand Down
2 changes: 1 addition & 1 deletion packages/react-widgets/src/scss/number-picker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

@mixin NumberPicker() {
.rw-number-picker {
$half-width: math.div($input-height, 2);
$half-width: $input-height * 0.5;
}

.rw-number-picker-spinners {
Expand Down

0 comments on commit c76e0f3

Please sign in to comment.