-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(select): virtualization (#4203)
* fix: should not export list item internal variables type * feat: changeset * feat: integrate virtualized listbox to select component, add more props * feat: update docs for select component * feat: update docs to include API for virtualization * fix: update docs to follow the newest format * fix: update test for disable virtualization, add test for virtualized version * fix: fix typo * fix: type error * fix: code block type error * chore: update docs to use raw jsx instead of template literal * fix: fix code-demo for typecheck * chore: rollback for files * fix: types * chore: remove caret version on tanstack virtual pkg * fix: pnpm lock file * fix: virtualization examples * fix: number of items --------- Co-authored-by: winches <329487092@qq.com> Co-authored-by: Junior Garcia <jrgarciadev@gmail.com>
- Loading branch information
1 parent
44958bf
commit 2d6e577
Showing
27 changed files
with
921 additions
and
265 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
apps/docs/content/components/autocomplete/virtualization-custom-item-height.raw.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import {Autocomplete, AutocompleteItem} from "@nextui-org/react"; | ||
|
||
const generateItems = (n) => { | ||
const items = [ | ||
"Cat", | ||
"Dog", | ||
"Elephant", | ||
"Lion", | ||
"Tiger", | ||
"Giraffe", | ||
"Dolphin", | ||
"Penguin", | ||
"Zebra", | ||
"Shark", | ||
"Whale", | ||
"Otter", | ||
"Crocodile", | ||
]; | ||
|
||
const dataset = []; | ||
|
||
for (let i = 0; i < n; i++) { | ||
const item = items[i % items.length]; | ||
|
||
dataset.push({ | ||
label: `${item}${i}`, | ||
value: `${item.toLowerCase()}${i}`, | ||
description: "Sample description", | ||
}); | ||
} | ||
|
||
return dataset; | ||
}; | ||
|
||
export default function App() { | ||
const items = generateItems(1000); | ||
|
||
return ( | ||
<div className="flex w-full flex-wrap md:flex-nowrap gap-4"> | ||
<Autocomplete | ||
isVirtualized | ||
className="max-w-xs" | ||
defaultItems={items} | ||
itemHeight={40} | ||
label="Search from 1000 items" | ||
maxListboxHeight={400} | ||
placeholder="Search..." | ||
> | ||
{(item) => <AutocompleteItem key={item.value}>{item.label}</AutocompleteItem>} | ||
</Autocomplete> | ||
</div> | ||
); | ||
} |
58 changes: 1 addition & 57 deletions
58
apps/docs/content/components/autocomplete/virtualization-custom-item-height.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
apps/docs/content/components/autocomplete/virtualization-max-listbox-height.raw.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import {Autocomplete, AutocompleteItem} from "@nextui-org/react"; | ||
|
||
const generateItems = (n) => { | ||
const items = [ | ||
"Cat", | ||
"Dog", | ||
"Elephant", | ||
"Lion", | ||
"Tiger", | ||
"Giraffe", | ||
"Dolphin", | ||
"Penguin", | ||
"Zebra", | ||
"Shark", | ||
"Whale", | ||
"Otter", | ||
"Crocodile", | ||
]; | ||
|
||
const dataset = []; | ||
|
||
for (let i = 0; i < n; i++) { | ||
const item = items[i % items.length]; | ||
|
||
dataset.push({ | ||
label: `${item}${i}`, | ||
value: `${item.toLowerCase()}${i}`, | ||
description: "Sample description", | ||
}); | ||
} | ||
|
||
return dataset; | ||
}; | ||
|
||
export default function App() { | ||
const items = generateItems(1000); | ||
|
||
return ( | ||
<div className="flex w-full flex-wrap md:flex-nowrap gap-4"> | ||
<Autocomplete | ||
isVirtualized | ||
className="max-w-xs" | ||
defaultItems={items} | ||
label="Search from 1000 items" | ||
maxListboxHeight={400} | ||
placeholder="Search..." | ||
> | ||
{(item) => <AutocompleteItem key={item.value}>{item.label}</AutocompleteItem>} | ||
</Autocomplete> | ||
</div> | ||
); | ||
} |
57 changes: 1 addition & 56 deletions
57
apps/docs/content/components/autocomplete/virtualization-max-listbox-height.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
apps/docs/content/components/autocomplete/virtualization-ten-thousand.raw.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {Autocomplete, AutocompleteItem} from "@nextui-org/react"; | ||
|
||
const generateItems = (n) => { | ||
const items = [ | ||
"Cat", | ||
"Dog", | ||
"Elephant", | ||
"Lion", | ||
"Tiger", | ||
"Giraffe", | ||
"Dolphin", | ||
"Penguin", | ||
"Zebra", | ||
"Shark", | ||
"Whale", | ||
"Otter", | ||
"Crocodile", | ||
]; | ||
|
||
const dataset = []; | ||
|
||
for (let i = 0; i < n; i++) { | ||
const item = items[i % items.length]; | ||
|
||
dataset.push({ | ||
label: `${item}${i}`, | ||
value: `${item.toLowerCase()}${i}`, | ||
description: "Sample description", | ||
}); | ||
} | ||
|
||
return dataset; | ||
}; | ||
|
||
export default function App() { | ||
const items = generateItems(10000); | ||
|
||
return ( | ||
<div className="flex w-full flex-wrap md:flex-nowrap gap-4"> | ||
<Autocomplete | ||
isVirtualized | ||
className="max-w-xs" | ||
defaultItems={items} | ||
label="Search from 10000 items" | ||
placeholder="Search..." | ||
> | ||
{(item) => <AutocompleteItem key={item.value}>{item.label}</AutocompleteItem>} | ||
</Autocomplete> | ||
</div> | ||
); | ||
} |
56 changes: 1 addition & 55 deletions
56
apps/docs/content/components/autocomplete/virtualization-ten-thousand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
apps/docs/content/components/autocomplete/virtualization.raw.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {Autocomplete, AutocompleteItem} from "@nextui-org/react"; | ||
|
||
const generateItems = (n) => { | ||
const items = [ | ||
"Cat", | ||
"Dog", | ||
"Elephant", | ||
"Lion", | ||
"Tiger", | ||
"Giraffe", | ||
"Dolphin", | ||
"Penguin", | ||
"Zebra", | ||
"Shark", | ||
"Whale", | ||
"Otter", | ||
"Crocodile", | ||
]; | ||
|
||
const dataset = []; | ||
|
||
for (let i = 0; i < n; i++) { | ||
const item = items[i % items.length]; | ||
|
||
dataset.push({ | ||
label: `${item}${i}`, | ||
value: `${item.toLowerCase()}${i}`, | ||
description: "Sample description", | ||
}); | ||
} | ||
|
||
return dataset; | ||
}; | ||
|
||
export default function App() { | ||
const items = generateItems(1000); | ||
|
||
return ( | ||
<div className="flex w-full flex-wrap md:flex-nowrap gap-4"> | ||
<Autocomplete | ||
isVirtualized | ||
className="max-w-xs" | ||
defaultItems={items} | ||
label="Search from 1000 items" | ||
placeholder="Search..." | ||
> | ||
{(item) => <AutocompleteItem key={item.value}>{item.label}</AutocompleteItem>} | ||
</Autocomplete> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.