-
-
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.
- Loading branch information
1 parent
27a142b
commit f1e4f00
Showing
11 changed files
with
397 additions
and
90 deletions.
There are no files selected for viewing
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,7 @@ | ||
--- | ||
"@nextui-org/autocomplete": patch | ||
"@nextui-org/listbox": patch | ||
"@nextui-org/theme": patch | ||
--- | ||
|
||
Virtualization support added to Listbox & Autocomplete |
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
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
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
65 changes: 65 additions & 0 deletions
65
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const App = `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 | ||
label="Search from 1000 items" | ||
className="max-w-xs" | ||
defaultItems={items} | ||
placeholder="Search..." | ||
maxListboxHeight={400} | ||
itemHeight={40} | ||
> | ||
{(item) => ( | ||
<AutocompleteItem key={item.value}> | ||
{item.label} | ||
</AutocompleteItem> | ||
)} | ||
</Autocomplete> | ||
</div> | ||
); | ||
}`; | ||
|
||
const react = { | ||
"/App.jsx": App, | ||
}; | ||
|
||
export default { | ||
...react, | ||
}; |
64 changes: 64 additions & 0 deletions
64
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const App = `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 | ||
label="Search from 1000 items" | ||
className="max-w-xs" | ||
defaultItems={items} | ||
placeholder="Search..." | ||
maxListboxHeight={400} | ||
> | ||
{(item) => ( | ||
<AutocompleteItem key={item.value}> | ||
{item.label} | ||
</AutocompleteItem> | ||
)} | ||
</Autocomplete> | ||
</div> | ||
); | ||
}`; | ||
|
||
const react = { | ||
"/App.jsx": App, | ||
}; | ||
|
||
export default { | ||
...react, | ||
}; |
63 changes: 63 additions & 0 deletions
63
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const App = `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 | ||
label="Search from 1000 items" | ||
className="max-w-xs" | ||
defaultItems={items} | ||
placeholder="Search..." | ||
> | ||
{(item) => ( | ||
<AutocompleteItem key={item.value}> | ||
{item.label} | ||
</AutocompleteItem> | ||
)} | ||
</Autocomplete> | ||
</div> | ||
); | ||
}`; | ||
|
||
const react = { | ||
"/App.jsx": App, | ||
}; | ||
|
||
export default { | ||
...react, | ||
}; |
Oops, something went wrong.