Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
484257e
fix(reducer): bring back action props
silviuaavram Mar 17, 2026
2f1315b
fix a test
silviuaavram Mar 17, 2026
2abe9a2
rename utils to utils.legacy
silviuaavram Mar 17, 2026
826e8a8
rename hooks utils to legacy
silviuaavram Mar 17, 2026
8255e96
rename utils-ts to utils
silviuaavram Mar 17, 2026
36f32fd
migrate src utils
silviuaavram Mar 19, 2026
54e1867
getChangesOnSelection and getChangesOnSelection
silviuaavram Mar 20, 2026
325398f
getHighlightedIndexOnOpen
silviuaavram Mar 20, 2026
dc936b4
prettier
silviuaavram Mar 20, 2026
7fb16da
getHighlighted and nonDisabled
silviuaavram Mar 21, 2026
769537b
tests
silviuaavram Mar 21, 2026
bceb1eb
move dropdown utils to hook utils
silviuaavram Mar 21, 2026
7ce8c52
isControlledProps
silviuaavram Mar 21, 2026
33a5cd1
fix import
silviuaavram Mar 21, 2026
7c8c98b
migrate stateChangeTypes
silviuaavram Apr 3, 2026
40694a2
getInitialState
silviuaavram Apr 4, 2026
4b6337d
combobox utils
silviuaavram Apr 4, 2026
919b50e
only combobox index file left to go
silviuaavram Apr 18, 2026
aedc987
more updates to make it ts ready
silviuaavram Apr 20, 2026
a679c9f
useControlPropsValidator & validateControlledUnchanged
silviuaavram Apr 22, 2026
307d9e8
useMouseAndTouchTracker and targetWithinDownshift
silviuaavram Apr 23, 2026
61b8b8f
useGetterPropsCalledChecker
silviuaavram Apr 23, 2026
6ceb29e
create downshift types
silviuaavram Apr 24, 2026
e4eb188
environment is not required
silviuaavram Apr 24, 2026
4cd25c4
refactored useCobobox
silviuaavram Apr 27, 2026
3198a74
useSelect types and stateChangeTypes
silviuaavram Apr 27, 2026
2119d9a
useSelect reducer
silviuaavram Apr 27, 2026
80304e8
useSelect
silviuaavram May 2, 2026
23756dd
last 2 utils
silviuaavram May 5, 2026
b5da552
more tests
silviuaavram May 5, 2026
ecd0375
fix equality issue
silviuaavram May 6, 2026
3c4600c
common reducer
silviuaavram May 6, 2026
7444a89
finish tests for getItemIndexByChar
silviuaavram May 6, 2026
10f89da
refactored tests
silviuaavram May 9, 2026
0ff7b66
move useMultiple types
silviuaavram May 9, 2026
096300c
consolidate types
silviuaavram May 9, 2026
d374459
reexport everything
silviuaavram May 9, 2026
aaa6f9a
prettier
silviuaavram May 9, 2026
2895ba5
fix exports
silviuaavram May 9, 2026
7d2f08a
fix pre-commit
silviuaavram May 9, 2026
557bc0d
add refs to tsx tests
silviuaavram May 9, 2026
bbe0e6e
more types fixes after docusaurus tsx convert
silviuaavram May 9, 2026
2173474
bring back the previous typings folder
silviuaavram May 9, 2026
9ea3c4f
fix exports
silviuaavram May 18, 2026
84c7341
code review
silviuaavram May 23, 2026
44d02a3
fix types generation
silviuaavram May 31, 2026
73e4009
prettier
silviuaavram May 31, 2026
d0cee5a
tsconfig stale
silviuaavram May 31, 2026
777e30d
some type fixes in reducer
silviuaavram May 31, 2026
54e4430
no need for pre-commit fix
silviuaavram May 31, 2026
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
665 changes: 143 additions & 522 deletions .all-contributorsrc

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ learn how: http://kcd.im/pull-request
**Relevant code or config**

```javascript

```

**What you did**:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ jobs:
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
14 changes: 8 additions & 6 deletions docusaurus/pages/combobox.js → docusaurus/pages/combobox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as React from 'react'

import Downshift from '../../src'
import {colors, containerStyles, menuStyles} from '../utils'
import {type ControllerStateAndHelpers} from '../../src/downshift.types'
import {colors} from '../utils'
import './shared.css'

export default function ComboBox() {
return (
Expand All @@ -18,8 +20,8 @@ export default function ComboBox() {
selectedItem,
getRootProps,
clearSelection,
}) => (
<div style={containerStyles}>
}: ControllerStateAndHelpers<string>) => (
<div className="container">
<label
style={{
fontWeight: 'bolder',
Expand Down Expand Up @@ -47,12 +49,12 @@ export default function ComboBox() {
style={{padding: '4px 8px'}}
aria-label="toggle menu"
data-testid="clear-button"
onClick={clearSelection}
onClick={() => clearSelection()}
>
&#10007;
</button>
</div>
<ul {...getMenuProps()} style={menuStyles}>
<ul {...getMenuProps()} className="menu">
{isOpen
? (inputValue
? colors.filter(i =>
Expand All @@ -64,7 +66,7 @@ export default function ComboBox() {
style={{
padding: '4px',
backgroundColor:
highlightedIndex === index ? '#bde4ff' : null,
highlightedIndex === index ? '#bde4ff' : undefined,
}}
key={`${item}${index}`}
{...getItemProps({
Expand Down
File renamed without changes.
18 changes: 18 additions & 0 deletions docusaurus/pages/useTagGroup.css → docusaurus/pages/shared.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
.container {
display: flex;
flex-direction: column;
width: fit-content;
justify-content: center;
margin-top: 100px;
align-self: center;
}

.menu {
list-style: none;
width: 100%;
padding: 0;
margin: 4px 0 0 0;
max-height: 120px;
overflow-y: scroll;
}

.tag-group {
display: inline-flex;
gap: 8px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react'

import {useCombobox} from '../../src'
import {colors, containerStyles, menuStyles} from '../utils'
import {colors} from '../utils'
import './shared.css'

export default function DropdownCombobox() {
const [inputItems, setInputItems] = React.useState(colors)
Expand All @@ -26,7 +27,7 @@ export default function DropdownCombobox() {
},
})
return (
<div style={containerStyles}>
<div className="container">
<label
style={{
fontWeight: 'bolder',
Expand All @@ -52,31 +53,33 @@ export default function DropdownCombobox() {
</button>
<button
style={{padding: '4px 8px'}}
aria-label="toggle menu"
aria-label="clear selection"
data-testid="clear-button"
onClick={() => selectItem(null)}
>
&#10007;
</button>
</div>
<ul {...getMenuProps()} style={menuStyles}>
{isOpen ?
inputItems.map((item, index) => (
<li
style={{
padding: '4px',
backgroundColor: highlightedIndex === index ? '#bde4ff' : null,
}}
key={`${item}${index}`}
{...getItemProps({
item,
index,
'data-testid': `downshift-item-${index}`,
})}
>
{item}
</li>
)) : null}
<ul {...getMenuProps()} className="menu">
{isOpen
? inputItems.map((item, index) => (
<li
style={{
padding: '4px',
backgroundColor:
highlightedIndex === index ? '#bde4ff' : undefined,
}}
key={`${item}${index}`}
{...getItemProps({
item,
index,
'data-testid': `downshift-item-${index}`,
})}
>
{item}
</li>
))
: null}
</ul>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import * as React from 'react'

import {useCombobox, useMultipleSelection} from '../../src'
import {
colors,
containerStyles,
menuStyles,
tagGroupSyles,
tagStyles,
} from '../utils'
import {type UseMultipleSelectionReturnValue} from '../../src/hooks/useMultipleSelection/index.types'
import {colors} from '../utils'
import './shared.css'

const initialSelectedItems = [colors[0], colors[1]]
const initialSelectedItems = colors.slice(0, 2)

function getFilteredItems(selectedItems, inputValue) {
function getFilteredItems(selectedItems: string[], inputValue: string) {
const lowerCasedInputValue = inputValue.toLowerCase()

return colors.filter(
Expand All @@ -31,21 +27,8 @@ export default function DropdownMultipleCombobox() {

const {getSelectedItemProps, getDropdownProps, removeSelectedItem} =
useMultipleSelection({
selectedItems,
onStateChange({selectedItems: newSelectedItems, type}) {
switch (type) {
case useMultipleSelection.stateChangeTypes
.SelectedItemKeyDownBackspace:
case useMultipleSelection.stateChangeTypes.SelectedItemKeyDownDelete:
case useMultipleSelection.stateChangeTypes.DropdownKeyDownBackspace:
case useMultipleSelection.stateChangeTypes.FunctionRemoveSelectedItem:
setSelectedItems(newSelectedItems)
break
default:
break
}
},
})
initialSelectedItems,
}) as unknown as UseMultipleSelectionReturnValue<string>
const {
isOpen,
getToggleButtonProps,
Expand All @@ -55,7 +38,7 @@ export default function DropdownMultipleCombobox() {
highlightedIndex,
getItemProps,
selectedItem,
clearSelection,
reset,
} = useCombobox({
items,
inputValue,
Expand Down Expand Up @@ -83,19 +66,19 @@ export default function DropdownMultipleCombobox() {
switch (type) {
case useCombobox.stateChangeTypes.InputKeyDownEnter:
case useCombobox.stateChangeTypes.ItemClick:
setSelectedItems([...selectedItems, newSelectedItem])
setSelectedItems([...selectedItems, newSelectedItem as string])

break
case useCombobox.stateChangeTypes.InputChange:
setInputValue(newInputValue)
setInputValue(newInputValue as string)
break
default:
break
}
},
})
return (
<div style={containerStyles}>
<div className="container">
<label
style={{
fontWeight: 'bolder',
Expand All @@ -105,14 +88,14 @@ export default function DropdownMultipleCombobox() {
>
Choose an element:
</label>
<div style={tagGroupSyles}>
<div className="tag-group">
{selectedItems.map(function renderSelectedItem(
selectedItemForRender,
index,
selectedItemForRender: string,
index: number,
) {
return (
<span
style={tagStyles}
className="tag"
key={`selected-item-${index}`}
{...getSelectedItemProps({
selectedItem: selectedItemForRender,
Expand Down Expand Up @@ -151,20 +134,20 @@ export default function DropdownMultipleCombobox() {
style={{padding: '4px 8px'}}
aria-label="clear selection"
data-testid="clear-button"
onClick={clearSelection}
onClick={() => reset()}
>
&#10007;
</button>
</div>
</div>
<ul {...getMenuProps()} style={menuStyles}>
<ul {...getMenuProps()} className="menu">
{isOpen
? items.map((item, index) => (
<li
style={{
padding: '4px',
backgroundColor:
highlightedIndex === index ? '#bde4ff' : null,
highlightedIndex === index ? '#bde4ff' : undefined,
}}
key={`${item}${index}`}
{...getItemProps({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import * as React from 'react'

import {useSelect, useMultipleSelection} from '../../src'
import {
colors,
containerStyles,
menuStyles,
tagGroupSyles,
tagStyles,
} from '../utils'
import {type UseMultipleSelectionReturnValue} from '../../src/hooks/useMultipleSelection/index.types'
import {colors} from '../utils'
import './shared.css'

const initialSelectedItems = [colors[0], colors[1]]
const initialSelectedItems = colors.slice(0, 2)

function getFilteredItems(selectedItems) {
function getFilteredItems(selectedItems: string[]) {
return colors.filter(colour => !selectedItems.includes(colour))
}

Expand All @@ -22,7 +18,9 @@ export default function DropdownMultipleSelect() {
addSelectedItem,
removeSelectedItem,
selectedItems,
} = useMultipleSelection({initialSelectedItems})
} = useMultipleSelection({
initialSelectedItems,
}) as unknown as UseMultipleSelectionReturnValue<string>
const items = getFilteredItems(selectedItems)
const {
isOpen,
Expand Down Expand Up @@ -66,7 +64,7 @@ export default function DropdownMultipleSelect() {
})

return (
<div style={containerStyles}>
<div className="container">
<label
style={{
fontWeight: 'bolder',
Expand All @@ -76,14 +74,14 @@ export default function DropdownMultipleSelect() {
>
Choose an element:
</label>
<div style={tagGroupSyles}>
<div className="tag-group">
{selectedItems.map(function renderSelectedItem(
selectedItemForRender,
index,
selectedItemForRender: string,
index: number,
) {
return (
<span
style={tagStyles}
className="tag"
key={`selected-item-${index}`}
{...getSelectedItemProps({
selectedItem: selectedItemForRender,
Expand Down Expand Up @@ -112,22 +110,21 @@ export default function DropdownMultipleSelect() {
backgroundColor: 'lightgray',
cursor: 'pointer',
}}
type="button"
{...getToggleButtonProps(
getDropdownProps({preventKeyAction: isOpen}),
)}
>
Pick some colors {isOpen ? <>&#8593;</> : <>&#8595;</>}
</div>
</div>
<ul {...getMenuProps()} style={menuStyles}>
<ul {...getMenuProps()} className="menu">
{isOpen
? items.map((item, index) => (
<li
style={{
padding: '4px',
backgroundColor:
highlightedIndex === index ? '#bde4ff' : null,
highlightedIndex === index ? '#bde4ff' : undefined,
}}
key={`${item}${index}`}
{...getItemProps({
Expand Down
Loading
Loading