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 459ab78
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 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
3 changes: 1 addition & 2 deletions packages/react-widgets/src/scss/number-picker.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
@use 'sass:math';
@use './variables.scss' as *;

@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 459ab78

Please sign in to comment.