mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
* fix(status): normalize 'status' value to lowercase in page.tsx * fix(status): normalize 'status' value to lowercase in use-case.ts * fix(status): normalize 'status' value to lowercase in custom-render-value.ts * fix(status): normalize 'status' value to lowercase in top-content.ts * fix(status): normalize 'status' value to lowercase in multiple-chips.ts * fix(status): normalize 'status' value to lowercase in custom-items.ts * fix(status): normalize 'status' value to lowercase in data.ts * fix(status): normalize 'status' value to lowercase in custom-styles.ts * fix(status): normalize 'status' value to lowercase in page.tsx * fix(status): normalize 'status' value to lowercase in custom-styles.ts * fix(status): normalize 'status' value to lowercase in custom-items.ts * fix(status): normalize 'status' value to lowercase in page.tsx * fix(status): normalize 'status' value to lowercase in custom-styles.ts
348 lines
8.8 KiB
TypeScript
348 lines
8.8 KiB
TypeScript
const data = `export const users = [
|
|
{
|
|
id: 1,
|
|
name: "Tony Reichert",
|
|
role: "CEO",
|
|
team: "Management",
|
|
status: "active",
|
|
age: "29",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/male/1.png",
|
|
email: "tony.reichert@example.com",
|
|
},
|
|
{
|
|
id: 2,
|
|
name: "Zoey Lang",
|
|
role: "Tech Lead",
|
|
team: "Development",
|
|
status: "paused",
|
|
age: "25",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/female/1.png",
|
|
email: "zoey.lang@example.com",
|
|
},
|
|
{
|
|
id: 3,
|
|
name: "Jane Fisher",
|
|
role: "Sr. Dev",
|
|
team: "Development",
|
|
status: "active",
|
|
age: "22",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/female/2.png",
|
|
email: "jane.fisher@example.com",
|
|
},
|
|
{
|
|
id: 4,
|
|
name: "William Howard",
|
|
role: "C.M.",
|
|
team: "Marketing",
|
|
status: "vacation",
|
|
age: "28",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/male/2.png",
|
|
email: "william.howard@example.com",
|
|
},
|
|
{
|
|
id: 5,
|
|
name: "Kristen Copper",
|
|
role: "S. Manager",
|
|
team: "Sales",
|
|
status: "active",
|
|
age: "24",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/female/3.png",
|
|
email: "kristen.cooper@example.com",
|
|
},
|
|
{
|
|
id: 6,
|
|
name: "Brian Kim",
|
|
role: "P. Manager",
|
|
team: "Management",
|
|
age: "29",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/male/3.png",
|
|
email: "brian.kim@example.com",
|
|
status: "active",
|
|
},
|
|
{
|
|
id: 7,
|
|
name: "Michael Hunt",
|
|
role: "Designer",
|
|
team: "Design",
|
|
status: "paused",
|
|
age: "27",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/male/4.png",
|
|
email: "michael.hunt@example.com",
|
|
},
|
|
{
|
|
id: 8,
|
|
name: "Samantha Brooks",
|
|
role: "HR Manager",
|
|
team: "HR",
|
|
status: "active",
|
|
age: "31",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/female/4.png",
|
|
email: "samantha.brooks@example.com",
|
|
},
|
|
{
|
|
id: 9,
|
|
name: "Frank Harrison",
|
|
role: "F. Manager",
|
|
team: "Finance",
|
|
status: "vacation",
|
|
age: "33",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/male/5.png",
|
|
email: "frank.harrison@example.com",
|
|
},
|
|
{
|
|
id: 10,
|
|
name: "Emma Adams",
|
|
role: "Ops Manager",
|
|
team: "Operations",
|
|
status: "active",
|
|
age: "35",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/female/5.png",
|
|
email: "emma.adams@example.com",
|
|
},
|
|
{
|
|
id: 11,
|
|
name: "Brandon Stevens",
|
|
role: "Jr. Dev",
|
|
team: "Development",
|
|
status: "active",
|
|
age: "22",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/male/7.png",
|
|
email: "brandon.stevens@example.com",
|
|
},
|
|
{
|
|
id: 12,
|
|
name: "Megan Richards",
|
|
role: "P. Manager",
|
|
team: "Product",
|
|
status: "paused",
|
|
age: "28",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/female/7.png",
|
|
email: "megan.richards@example.com",
|
|
},
|
|
{
|
|
id: 13,
|
|
name: "Oliver Scott",
|
|
role: "S. Manager",
|
|
team: "Security",
|
|
status: "active",
|
|
age: "37",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/male/8.png",
|
|
email: "oliver.scott@example.com",
|
|
},
|
|
{
|
|
id: 14,
|
|
name: "Grace Allen",
|
|
role: "M. Specialist",
|
|
team: "Marketing",
|
|
status: "active",
|
|
age: "30",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/female/8.png",
|
|
email: "grace.allen@example.com",
|
|
},
|
|
{
|
|
id: 15,
|
|
name: "Noah Carter",
|
|
role: "IT Specialist",
|
|
team: "I. Technology",
|
|
status: "paused",
|
|
age: "31",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/male/9.png",
|
|
email: "noah.carter@example.com",
|
|
},
|
|
{
|
|
id: 16,
|
|
name: "Ava Perez",
|
|
role: "Manager",
|
|
team: "Sales",
|
|
status: "active",
|
|
age: "29",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/female/9.png",
|
|
email: "ava.perez@example.com",
|
|
},
|
|
{
|
|
id: 17,
|
|
name: "Liam Johnson",
|
|
role: "Data Analyst",
|
|
team: "Analysis",
|
|
status: "active",
|
|
age: "28",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/male/11.png",
|
|
email: "liam.johnson@example.com",
|
|
},
|
|
{
|
|
id: 18,
|
|
name: "Sophia Taylor",
|
|
role: "QA Analyst",
|
|
team: "Testing",
|
|
status: "active",
|
|
age: "27",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/female/11.png",
|
|
email: "sophia.taylor@example.com",
|
|
},
|
|
{
|
|
id: 19,
|
|
name: "Lucas Harris",
|
|
role: "Administrator",
|
|
team: "Information Technology",
|
|
status: "paused",
|
|
age: "32",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/male/12.png",
|
|
email: "lucas.harris@example.com",
|
|
},
|
|
{
|
|
id: 20,
|
|
name: "Mia Robinson",
|
|
role: "Coordinator",
|
|
team: "Operations",
|
|
status: "active",
|
|
age: "26",
|
|
avatar: "https://d2u8k2ocievbld.cloudfront.net/memojis/female/12.png",
|
|
email: "mia.robinson@example.com",
|
|
},
|
|
];`;
|
|
|
|
const ListboxWrapper = `export const ListboxWrapper = ({children}) => (
|
|
<div className="w-full max-w-[260px] border-small px-1 py-2 rounded-small border-default-200 dark:border-default-100">
|
|
{children}
|
|
</div>
|
|
);`;
|
|
|
|
const ListboxWrapperTs = `export const ListboxWrapper = ({children}: { children: React.ReactNode }) => (
|
|
<div className="w-full max-w-[260px] border-small px-1 py-2 rounded-small border-default-200 dark:border-default-100">
|
|
{children}
|
|
</div>
|
|
);`;
|
|
|
|
const App = `import {Listbox, ListboxItem, Chip, ScrollShadow, Avatar} from "@nextui-org/react";
|
|
import {ListboxWrapper} from "./ListboxWrapper";
|
|
import {users} from "./data";
|
|
|
|
export default function App() {
|
|
const [values, setValues] = React.useState(new Set(["1"]));
|
|
|
|
const arrayValues = Array.from(values);
|
|
|
|
const topContent = React.useMemo(() => {
|
|
if (!arrayValues.length) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<ScrollShadow
|
|
hideScrollBar
|
|
className="w-full flex py-0.5 px-2 gap-1"
|
|
orientation="horizontal"
|
|
>
|
|
{arrayValues.map((value) => (
|
|
<Chip key={value}>{users.find((user) => \`\${user.id}\` === \`\${value}\`).name}</Chip>
|
|
))}
|
|
</ScrollShadow>
|
|
);
|
|
}, [arrayValues.length]);
|
|
|
|
return (
|
|
<ListboxWrapper>
|
|
<Listbox
|
|
topContent={topContent}
|
|
classNames={{
|
|
base: "max-w-xs",
|
|
list: "max-h-[300px] overflow-scroll",
|
|
}}
|
|
defaultSelectedKeys={["1"]}
|
|
items={users}
|
|
label="Assigned to"
|
|
selectionMode="multiple"
|
|
onSelectionChange={setValues}
|
|
variant="flat"
|
|
>
|
|
{(item) => (
|
|
<ListboxItem key={item.id} textValue={item.name}>
|
|
<div className="flex gap-2 items-center">
|
|
<Avatar alt={item.name} className="flex-shrink-0" size="sm" src={item.avatar} />
|
|
<div className="flex flex-col">
|
|
<span className="text-small">{item.name}</span>
|
|
<span className="text-tiny text-default-400">{item.email}</span>
|
|
</div>
|
|
</div>
|
|
</ListboxItem>
|
|
)}
|
|
</Listbox>
|
|
</ListboxWrapper>
|
|
);
|
|
}`;
|
|
|
|
const AppTs = `import {Listbox, ListboxItem, Chip, ScrollShadow, Avatar, Selection} from "@nextui-org/react";
|
|
import {ListboxWrapper} from "./ListboxWrapper";
|
|
import {users} from "./data";
|
|
|
|
export default function App() {
|
|
const [values, setValues] = React.useState<Selection>(new Set(["1"]));
|
|
|
|
const arrayValues = Array.from(values);
|
|
|
|
const topContent = React.useMemo(() => {
|
|
if (!arrayValues.length) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<ScrollShadow
|
|
hideScrollBar
|
|
className="w-full flex py-0.5 px-2 gap-1"
|
|
orientation="horizontal"
|
|
>
|
|
{arrayValues.map((value) => (
|
|
<Chip key={value}>{users.find((user) => \`\${user.id}\` === \`\${value}\`).name}</Chip>
|
|
))}
|
|
</ScrollShadow>
|
|
);
|
|
}, [arrayValues.length]);
|
|
|
|
return (
|
|
<ListboxWrapper>
|
|
<Listbox
|
|
topContent={topContent}
|
|
classNames={{
|
|
base: "max-w-xs",
|
|
list: "max-h-[300px] overflow-scroll",
|
|
}}
|
|
defaultSelectedKeys={["1"]}
|
|
items={users}
|
|
label="Assigned to"
|
|
selectionMode="multiple"
|
|
onSelectionChange={setValues}
|
|
variant="flat"
|
|
>
|
|
{(item) => (
|
|
<ListboxItem key={item.id} textValue={item.name}>
|
|
<div className="flex gap-2 items-center">
|
|
<Avatar alt={item.name} className="flex-shrink-0" size="sm" src={item.avatar} />
|
|
<div className="flex flex-col">
|
|
<span className="text-small">{item.name}</span>
|
|
<span className="text-tiny text-default-400">{item.email}</span>
|
|
</div>
|
|
</div>
|
|
</ListboxItem>
|
|
)}
|
|
</Listbox>
|
|
</ListboxWrapper>
|
|
);
|
|
}`;
|
|
|
|
const react = {
|
|
"/App.jsx": App,
|
|
"/ListboxWrapper.jsx": ListboxWrapper,
|
|
"/data.js": data,
|
|
};
|
|
|
|
const reactTs = {
|
|
"/App.tsx": AppTs,
|
|
"/ListboxWrapper.tsx": ListboxWrapperTs,
|
|
"/data.ts": data,
|
|
};
|
|
|
|
export default {
|
|
...react,
|
|
...reactTs,
|
|
};
|