Skip to content

Commit 459ab78

Browse files
committed
feat: add low level List.renderList()
1 parent 780b24a commit 459ab78

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

Diff for: packages/react-widgets/src/List.tsx

+18-18
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ const List: List = React.forwardRef(function List<TDataItem>(
208208
groupBy,
209209
elementRef,
210210
optionComponent: Option = ListOption,
211+
renderList,
211212
// onKeyDown,
212213
...props
213214
}: ListProps<TDataItem>,
@@ -263,7 +264,7 @@ const List: List = React.forwardRef(function List<TDataItem>(
263264
)
264265
}
265266

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

277-
return (
278-
<div
279-
id={id}
280-
tabIndex={0}
281-
ref={divRef}
282-
{...elementProps}
283-
aria-multiselectable={!!multiple}
284-
className={cn(className, 'rw-list')}
285-
role={elementProps.role ?? 'listbox'}
286-
>
287-
{React.Children.count(children) ? (
288-
children
289-
) : (
290-
<div className="rw-list-empty">{emptyList()}</div>
291-
)}
292-
</div>
293-
)
278+
const rootProps = {
279+
id,
280+
tabIndex: 0,
281+
ref: divRef,
282+
...elementProps,
283+
'aria-multiselectable': !!multiple,
284+
className: cn(className, 'rw-list'),
285+
role: elementProps.role ?? 'listbox',
286+
children: React.Children.count(items) ? (
287+
items
288+
) : (
289+
<div className="rw-list-empty">{emptyList()}</div>
290+
),
291+
}
292+
293+
return renderList ? renderList(rootProps) : <div {...rootProps} />
294294
})
295295

296296
List.displayName = 'List'

Diff for: packages/react-widgets/src/scss/number-picker.scss

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
@use 'sass:math';
21
@use './variables.scss' as *;
32

43
@mixin NumberPicker() {
54
.rw-number-picker {
6-
$half-width: math.div($input-height, 2);
5+
$half-width: $input-height * 0.5;
76
}
87

98
.rw-number-picker-spinners {

0 commit comments

Comments
 (0)