From d4ed5e9c8b4cfc2aca8d2af960f71d16f9f88618 Mon Sep 17 00:00:00 2001 From: WK Wong Date: Sat, 16 Nov 2024 12:12:40 +0800 Subject: [PATCH 1/5] refactor(docs): select dx --- .../select/async-loading-items.raw.jsx | 98 ++++++ .../select/async-loading-items.raw.tsx | 108 ++++++ .../components/select/async-loading-items.ts | 178 +--------- .../content/components/select/colors.raw.jsx | 40 +++ apps/docs/content/components/select/colors.ts | 52 +-- .../components/select/custom-items.raw.jsx | 228 +++++++++++++ .../content/components/select/custom-items.ts | 231 +------------ .../select/custom-render-value.raw.jsx | 247 ++++++++++++++ .../select/custom-render-value.raw.tsx | 259 +++++++++++++++ .../components/select/custom-render-value.ts | 309 +----------------- .../select/custom-sections-style.raw.jsx | 48 +++ .../select/custom-sections-style.ts | 48 +-- .../select/custom-selector-icon.raw.jsx | 55 ++++ .../components/select/custom-selector-icon.ts | 62 +--- .../components/select/custom-styles.raw.jsx | 269 +++++++++++++++ .../components/select/custom-styles.ts | 272 +-------------- .../components/select/description.raw.jsx | 33 ++ .../content/components/select/description.ts | 38 +-- .../components/select/disabled-items.raw.jsx | 32 ++ .../components/select/disabled-items.ts | 37 +-- .../components/select/disabled.raw.jsx | 33 ++ .../content/components/select/disabled.ts | 38 +-- .../content/components/select/dynamic.raw.jsx | 30 ++ .../docs/content/components/select/dynamic.ts | 33 +- .../components/select/error-message.raw.jsx | 43 +++ .../components/select/error-message.ts | 48 +-- .../select/item-start-content.raw.jsx | 68 ++++ .../components/select/item-start-content.ts | 68 +--- .../select/label-placements.raw.jsx | 61 ++++ .../components/select/label-placements.ts | 70 +--- .../components/select/multiple-chips.raw.jsx | 243 ++++++++++++++ .../components/select/multiple-chips.raw.tsx | 255 +++++++++++++++ .../components/select/multiple-chips.ts | 301 +---------------- .../multiple-controlled-onchange.raw.jsx | 43 +++ .../multiple-controlled-onchange.raw.tsx | 46 +++ .../select/multiple-controlled-onchange.ts | 81 +---- .../select/multiple-controlled.raw.jsx | 39 +++ .../select/multiple-controlled.raw.tsx | 42 +++ .../components/select/multiple-controlled.ts | 73 +---- .../components/select/multiple.raw.jsx | 32 ++ .../content/components/select/multiple.ts | 37 +-- .../components/select/open-state.raw.jsx | 41 +++ .../content/components/select/open-state.ts | 46 +-- .../content/components/select/radius.raw.jsx | 40 +++ apps/docs/content/components/select/radius.ts | 51 +-- .../components/select/required.raw.jsx | 33 ++ .../content/components/select/required.ts | 38 +-- .../components/select/sections.raw.jsx | 28 ++ .../content/components/select/sections.ts | 33 +- .../select/single-controlled-onchange.raw.jsx | 43 +++ .../select/single-controlled-onchange.raw.tsx | 44 +++ .../select/single-controlled-onchange.ts | 81 +---- .../select/single-controlled.raw.jsx | 39 +++ .../select/single-controlled.raw.tsx | 40 +++ .../components/select/single-controlled.ts | 73 +---- .../content/components/select/sizes.raw.jsx | 45 +++ .../components/select/start-content.raw.jsx | 67 ++++ .../content/components/select/usage.raw.jsx | 34 ++ .../components/select/variants.raw.jsx | 45 +++ .../select/without-scroll-shadow.raw.jsx | 35 ++ 60 files changed, 2918 insertions(+), 2266 deletions(-) create mode 100644 apps/docs/content/components/select/async-loading-items.raw.jsx create mode 100644 apps/docs/content/components/select/async-loading-items.raw.tsx create mode 100644 apps/docs/content/components/select/colors.raw.jsx create mode 100644 apps/docs/content/components/select/custom-items.raw.jsx create mode 100644 apps/docs/content/components/select/custom-render-value.raw.jsx create mode 100644 apps/docs/content/components/select/custom-render-value.raw.tsx create mode 100644 apps/docs/content/components/select/custom-sections-style.raw.jsx create mode 100644 apps/docs/content/components/select/custom-selector-icon.raw.jsx create mode 100644 apps/docs/content/components/select/custom-styles.raw.jsx create mode 100644 apps/docs/content/components/select/description.raw.jsx create mode 100644 apps/docs/content/components/select/disabled-items.raw.jsx create mode 100644 apps/docs/content/components/select/disabled.raw.jsx create mode 100644 apps/docs/content/components/select/dynamic.raw.jsx create mode 100644 apps/docs/content/components/select/error-message.raw.jsx create mode 100644 apps/docs/content/components/select/item-start-content.raw.jsx create mode 100644 apps/docs/content/components/select/label-placements.raw.jsx create mode 100644 apps/docs/content/components/select/multiple-chips.raw.jsx create mode 100644 apps/docs/content/components/select/multiple-chips.raw.tsx create mode 100644 apps/docs/content/components/select/multiple-controlled-onchange.raw.jsx create mode 100644 apps/docs/content/components/select/multiple-controlled-onchange.raw.tsx create mode 100644 apps/docs/content/components/select/multiple-controlled.raw.jsx create mode 100644 apps/docs/content/components/select/multiple-controlled.raw.tsx create mode 100644 apps/docs/content/components/select/multiple.raw.jsx create mode 100644 apps/docs/content/components/select/open-state.raw.jsx create mode 100644 apps/docs/content/components/select/radius.raw.jsx create mode 100644 apps/docs/content/components/select/required.raw.jsx create mode 100644 apps/docs/content/components/select/sections.raw.jsx create mode 100644 apps/docs/content/components/select/single-controlled-onchange.raw.jsx create mode 100644 apps/docs/content/components/select/single-controlled-onchange.raw.tsx create mode 100644 apps/docs/content/components/select/single-controlled.raw.jsx create mode 100644 apps/docs/content/components/select/single-controlled.raw.tsx create mode 100644 apps/docs/content/components/select/sizes.raw.jsx create mode 100644 apps/docs/content/components/select/start-content.raw.jsx create mode 100644 apps/docs/content/components/select/usage.raw.jsx create mode 100644 apps/docs/content/components/select/variants.raw.jsx create mode 100644 apps/docs/content/components/select/without-scroll-shadow.raw.jsx diff --git a/apps/docs/content/components/select/async-loading-items.raw.jsx b/apps/docs/content/components/select/async-loading-items.raw.jsx new file mode 100644 index 0000000000..d882cd4e03 --- /dev/null +++ b/apps/docs/content/components/select/async-loading-items.raw.jsx @@ -0,0 +1,98 @@ +/* eslint-disable no-console */ + +import {Select, SelectItem} from "@nextui-org/react"; +import {useInfiniteScroll} from "@nextui-org/use-infinite-scroll"; + +export function usePokemonList({fetchDelay = 0} = {}) { + const [items, setItems] = React.useState([]); + const [hasMore, setHasMore] = React.useState(true); + const [isLoading, setIsLoading] = React.useState(false); + const [offset, setOffset] = React.useState(0); + const limit = 10; // Number of items per page, adjust as necessary + + const loadPokemon = async (currentOffset) => { + const controller = new AbortController(); + const {signal} = controller; + + try { + setIsLoading(true); + + if (offset > 0) { + // Delay to simulate network latency + await new Promise((resolve) => setTimeout(resolve, fetchDelay)); + } + + let res = await fetch( + `https://pokeapi.co/api/v2/pokemon?offset=${currentOffset}&limit=${limit}`, + {signal}, + ); + + if (!res.ok) { + throw new Error("Network response was not ok"); + } + + let json = await res.json(); + + setHasMore(json.next !== null); + // Append new results to existing ones + setItems((prevItems) => [...prevItems, ...json.results]); + } catch (error) { + if (error.name === "AbortError") { + console.log("Fetch aborted"); + } else { + console.error("There was an error with the fetch operation:", error); + } + } finally { + setIsLoading(false); + } + }; + + React.useEffect(() => { + loadPokemon(offset); + }, []); + + const onLoadMore = () => { + const newOffset = offset + limit; + + setOffset(newOffset); + loadPokemon(newOffset); + }; + + return { + items, + hasMore, + isLoading, + onLoadMore, + }; +} + +export default function App() { + const [isOpen, setIsOpen] = React.useState(false); + const {items, hasMore, isLoading, onLoadMore} = usePokemonList({fetchDelay: 1500}); + + const [, scrollerRef] = useInfiniteScroll({ + hasMore, + isEnabled: isOpen, + shouldUseLoader: false, // We don't want to show the loader at the bottom of the list + onLoadMore, + }); + + return ( + + ); +} diff --git a/apps/docs/content/components/select/async-loading-items.raw.tsx b/apps/docs/content/components/select/async-loading-items.raw.tsx new file mode 100644 index 0000000000..2a0f49d465 --- /dev/null +++ b/apps/docs/content/components/select/async-loading-items.raw.tsx @@ -0,0 +1,108 @@ +/* eslint-disable no-console */ + +import React from "react"; +import {Select, SelectItem} from "@nextui-org/react"; +import {useInfiniteScroll} from "@nextui-org/use-infinite-scroll"; + +export type Pokemon = { + name: string; + url: string; +}; + +export type UsePokemonListProps = { + /** Delay to wait before fetching more items */ + fetchDelay?: number; +}; + +export function usePokemonList({fetchDelay = 0}: UsePokemonListProps = {}) { + const [items, setItems] = React.useState([]); + const [hasMore, setHasMore] = React.useState(true); + const [isLoading, setIsLoading] = React.useState(false); + const [offset, setOffset] = React.useState(0); + const limit = 10; // Number of items per page, adjust as necessary + + const loadPokemon = async (currentOffset: number) => { + const controller = new AbortController(); + const {signal} = controller; + + try { + setIsLoading(true); + + if (offset > 0) { + // Delay to simulate network latency + await new Promise((resolve) => setTimeout(resolve, fetchDelay)); + } + + let res = await fetch( + `https://pokeapi.co/api/v2/pokemon?offset=${currentOffset}&limit=${limit}`, + {signal}, + ); + + if (!res.ok) { + throw new Error("Network response was not ok"); + } + + let json = await res.json(); + + setHasMore(json.next !== null); + // Append new results to existing ones + setItems((prevItems) => [...prevItems, ...json.results]); + } catch (error) { + if (error.name === "AbortError") { + console.log("Fetch aborted"); + } else { + console.error("There was an error with the fetch operation:", error); + } + } finally { + setIsLoading(false); + } + }; + + React.useEffect(() => { + loadPokemon(offset); + }, []); + + const onLoadMore = () => { + const newOffset = offset + limit; + + setOffset(newOffset); + loadPokemon(newOffset); + }; + + return { + items, + hasMore, + isLoading, + onLoadMore, + }; +} +export default function App() { + const [isOpen, setIsOpen] = React.useState(false); + const {items, hasMore, isLoading, onLoadMore} = usePokemonList({fetchDelay: 1500}); + + const [, scrollerRef] = useInfiniteScroll({ + hasMore, + isEnabled: isOpen, + shouldUseLoader: false, // We don't want to show the loader at the bottom of the list + onLoadMore, + }); + + return ( + + ); +} diff --git a/apps/docs/content/components/select/async-loading-items.ts b/apps/docs/content/components/select/async-loading-items.ts index c6de820cab..a69188c565 100644 --- a/apps/docs/content/components/select/async-loading-items.ts +++ b/apps/docs/content/components/select/async-loading-items.ts @@ -1,184 +1,12 @@ -const usePokemonListTs = `export type Pokemon = { - name: string; - url: string; -}; - -export type UsePokemonListProps = { - /** Delay to wait before fetching more items */ - fetchDelay?: number; -}; - -export function usePokemonList({fetchDelay = 0}: UsePokemonListProps = {}) { - const [items, setItems] = React.useState([]); - const [hasMore, setHasMore] = React.useState(true); - const [isLoading, setIsLoading] = React.useState(false); - const [offset, setOffset] = React.useState(0); - const limit = 10; // Number of items per page, adjust as necessary - - const loadPokemon = async (currentOffset: number) => { - const controller = new AbortController(); - const {signal} = controller; - - try { - setIsLoading(true); - - if (offset > 0) { - // Delay to simulate network latency - await new Promise((resolve) => setTimeout(resolve, fetchDelay)); - } - - let res = await fetch( - \`https://pokeapi.co/api/v2/pokemon?offset=\${currentOffset}&limit=\${limit}\`, - {signal}, - ); - - if (!res.ok) { - throw new Error("Network response was not ok"); - } - - let json = await res.json(); - - setHasMore(json.next !== null); - // Append new results to existing ones - setItems((prevItems) => [...prevItems, ...json.results]); - } catch (error) { - if (error.name === "AbortError") { - console.log("Fetch aborted"); - } else { - console.error("There was an error with the fetch operation:", error); - } - } finally { - setIsLoading(false); - } - }; - - React.useEffect(() => { - loadPokemon(offset); - }, []); - - const onLoadMore = () => { - const newOffset = offset + limit; - - setOffset(newOffset); - loadPokemon(newOffset); - }; - - return { - items, - hasMore, - isLoading, - onLoadMore, - }; -} - -`; - -const usePokemonList = `export function usePokemonList({fetchDelay = 0} = {}) { - const [items, setItems] = React.useState([]); - const [hasMore, setHasMore] = React.useState(true); - const [isLoading, setIsLoading] = React.useState(false); - const [offset, setOffset] = React.useState(0); - const limit = 10; // Number of items per page, adjust as necessary - - const loadPokemon = async (currentOffset) => { - const controller = new AbortController(); - const {signal} = controller; - - try { - setIsLoading(true); - - if (offset > 0) { - // Delay to simulate network latency - await new Promise((resolve) => setTimeout(resolve, fetchDelay)); - } - - let res = await fetch( - \`https://pokeapi.co/api/v2/pokemon?offset=\${currentOffset}&limit=\${limit}\`, - {signal}, - ); - - if (!res.ok) { - throw new Error("Network response was not ok"); - } - - let json = await res.json(); - - setHasMore(json.next !== null); - // Append new results to existing ones - setItems((prevItems) => [...prevItems, ...json.results]); - } catch (error) { - if (error.name === "AbortError") { - console.log("Fetch aborted"); - } else { - console.error("There was an error with the fetch operation:", error); - } - } finally { - setIsLoading(false); - } - }; - - React.useEffect(() => { - loadPokemon(offset); - }, []); - - const onLoadMore = () => { - const newOffset = offset + limit; - - setOffset(newOffset); - loadPokemon(newOffset); - }; - - return { - items, - hasMore, - isLoading, - onLoadMore, - }; -};`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {useInfiniteScroll} from "@nextui-org/use-infinite-scroll"; -import {usePokemonList} from "./usePokemonList"; - -export default function App() { - const [isOpen, setIsOpen] = React.useState(false); - const {items, hasMore, isLoading, onLoadMore} = usePokemonList({fetchDelay: 1500}); - - const [, scrollerRef] = useInfiniteScroll({ - hasMore, - isEnabled: isOpen, - shouldUseLoader: false, // We don't want to show the loader at the bottom of the list - onLoadMore, - }); - - return ( - - ); -}`; +import App from "./async-loading-items.raw.jsx?raw"; +import AppTs from "./async-loading-items.raw.tsx?raw"; const react = { "/App.jsx": App, - "/usePokemonList.js": usePokemonList, }; const reactTs = { - "/App.tsx": App, - "/usePokemonList.ts": usePokemonListTs, + "/App.tsx": AppTs, }; export default { diff --git a/apps/docs/content/components/select/colors.raw.jsx b/apps/docs/content/components/select/colors.raw.jsx new file mode 100644 index 0000000000..1732747ba5 --- /dev/null +++ b/apps/docs/content/components/select/colors.raw.jsx @@ -0,0 +1,40 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + const colors = ["default", "primary", "secondary", "success", "warning", "danger"]; + + return ( +
+ {colors.map((color) => ( + + ))} +
+ ); +} diff --git a/apps/docs/content/components/select/colors.ts b/apps/docs/content/components/select/colors.ts index c830262ca1..d5bef810aa 100644 --- a/apps/docs/content/components/select/colors.ts +++ b/apps/docs/content/components/select/colors.ts @@ -1,57 +1,7 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - const colors = [ - "default", - "primary", - "secondary", - "success", - "warning", - "danger", - ]; - - return ( -
- {colors.map((color) => ( - - ))} -
- ); -}`; +import App from "./colors.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/custom-items.raw.jsx b/apps/docs/content/components/select/custom-items.raw.jsx new file mode 100644 index 0000000000..b1b78c716a --- /dev/null +++ b/apps/docs/content/components/select/custom-items.raw.jsx @@ -0,0 +1,228 @@ +import {Select, SelectItem, Avatar} from "@nextui-org/react"; + +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", + }, +]; + +export default function App() { + return ( + + ); +} diff --git a/apps/docs/content/components/select/custom-items.ts b/apps/docs/content/components/select/custom-items.ts index 66f7d96dd7..26a1e0f9ac 100644 --- a/apps/docs/content/components/select/custom-items.ts +++ b/apps/docs/content/components/select/custom-items.ts @@ -1,236 +1,7 @@ -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 App = `import {Select, SelectItem, Avatar} from "@nextui-org/react"; -import {users} from "./data"; - -export default function App() { - return ( - - ); -}`; +import App from "./custom-items.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/custom-render-value.raw.jsx b/apps/docs/content/components/select/custom-render-value.raw.jsx new file mode 100644 index 0000000000..c038d4d13a --- /dev/null +++ b/apps/docs/content/components/select/custom-render-value.raw.jsx @@ -0,0 +1,247 @@ +import {Select, SelectItem, Avatar} from "@nextui-org/react"; + +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", + }, +]; + +export default function App() { + return ( + + ); +} diff --git a/apps/docs/content/components/select/custom-render-value.raw.tsx b/apps/docs/content/components/select/custom-render-value.raw.tsx new file mode 100644 index 0000000000..b46f9def2c --- /dev/null +++ b/apps/docs/content/components/select/custom-render-value.raw.tsx @@ -0,0 +1,259 @@ +import React from "react"; +import {Select, SelectItem, Avatar, SelectedItems} from "@nextui-org/react"; + +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", + }, +]; + +type User = { + id: number; + name: string; + role: string; + team: string; + status: string; + age: string; + avatar: string; + email: string; +}; + +export default function App() { + return ( + + ); +} diff --git a/apps/docs/content/components/select/custom-render-value.ts b/apps/docs/content/components/select/custom-render-value.ts index dc52e11211..3d16320688 100644 --- a/apps/docs/content/components/select/custom-render-value.ts +++ b/apps/docs/content/components/select/custom-render-value.ts @@ -1,317 +1,12 @@ -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 App = `import {Select, SelectItem, Avatar} from "@nextui-org/react"; -import {users} from "./data"; - -export default function App() { - return ( - - ); -}`; - -const AppTs = `import {Select, SelectItem, Avatar, SelectedItems} from "@nextui-org/react"; -import {users} from "./data"; - -type User = { - id: number; - name: string; - role: string; - team: string; - status: string; - age: string; - avatar: string; - email: string; -}; - -export default function App() { - return ( - - ); -}`; +import App from "./custom-render-value.raw.jsx?raw"; +import AppTs from "./custom-render-value.raw.tsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; const reactTs = { "/App.tsx": AppTs, - "/data.ts": data, }; export default { diff --git a/apps/docs/content/components/select/custom-sections-style.raw.jsx b/apps/docs/content/components/select/custom-sections-style.raw.jsx new file mode 100644 index 0000000000..17826ba15c --- /dev/null +++ b/apps/docs/content/components/select/custom-sections-style.raw.jsx @@ -0,0 +1,48 @@ +import {Select, SelectItem, SelectSection} from "@nextui-org/react"; + +export default function App() { + const headingClasses = + "flex w-full sticky top-1 z-20 py-1.5 px-2 bg-default-100 shadow-small rounded-small"; + + return ( + + ); +} diff --git a/apps/docs/content/components/select/custom-sections-style.ts b/apps/docs/content/components/select/custom-sections-style.ts index 9551a80049..9ba8a6cd9c 100644 --- a/apps/docs/content/components/select/custom-sections-style.ts +++ b/apps/docs/content/components/select/custom-sections-style.ts @@ -1,50 +1,4 @@ -const App = `import {Select, SelectItem, SelectSection} from "@nextui-org/react"; - -export default function App() { - const headingClasses = "flex w-full sticky top-1 z-20 py-1.5 px-2 bg-default-100 shadow-small rounded-small"; - - return ( - - ); -}`; +import App from "./custom-sections-style.raw.jsx?raw"; const react = { "/App.jsx": App, diff --git a/apps/docs/content/components/select/custom-selector-icon.raw.jsx b/apps/docs/content/components/select/custom-selector-icon.raw.jsx new file mode 100644 index 0000000000..1ba88429cb --- /dev/null +++ b/apps/docs/content/components/select/custom-selector-icon.raw.jsx @@ -0,0 +1,55 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const SelectorIcon = (props) => ( + +); + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + return ( + + ); +} diff --git a/apps/docs/content/components/select/custom-selector-icon.ts b/apps/docs/content/components/select/custom-selector-icon.ts index 18770cfb44..ee2c7d9a8b 100644 --- a/apps/docs/content/components/select/custom-selector-icon.ts +++ b/apps/docs/content/components/select/custom-selector-icon.ts @@ -1,67 +1,7 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const SelectorIcon = `export const SelectorIcon = (props) => ( - -);`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {SelectorIcon} from "./SelectorIcon"; -import {animals} from "./data"; - -export default function App() { - return ( - - ); -}`; +import App from "./custom-selector-icon.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, - "/SelectorIcon.jsx": SelectorIcon, }; export default { diff --git a/apps/docs/content/components/select/custom-styles.raw.jsx b/apps/docs/content/components/select/custom-styles.raw.jsx new file mode 100644 index 0000000000..6aad7b60dc --- /dev/null +++ b/apps/docs/content/components/select/custom-styles.raw.jsx @@ -0,0 +1,269 @@ +import {Select, SelectItem, Avatar} from "@nextui-org/react"; + +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", + }, +]; + +export default function App() { + return ( + + ); +} diff --git a/apps/docs/content/components/select/custom-styles.ts b/apps/docs/content/components/select/custom-styles.ts index ae2db45e8a..da3ea9093a 100644 --- a/apps/docs/content/components/select/custom-styles.ts +++ b/apps/docs/content/components/select/custom-styles.ts @@ -1,277 +1,7 @@ -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 App = `import {Select, SelectItem, Avatar} from "@nextui-org/react"; -import {users} from "./data"; - -export default function App() { - return ( - - ); -}`; +import App from "./custom-styles.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/description.raw.jsx b/apps/docs/content/components/select/description.raw.jsx new file mode 100644 index 0000000000..ead30aaa95 --- /dev/null +++ b/apps/docs/content/components/select/description.raw.jsx @@ -0,0 +1,33 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + return ( + + ); +} diff --git a/apps/docs/content/components/select/description.ts b/apps/docs/content/components/select/description.ts index b39c36847d..aeb6340b6b 100644 --- a/apps/docs/content/components/select/description.ts +++ b/apps/docs/content/components/select/description.ts @@ -1,43 +1,7 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - return ( - - ); -}`; +import App from "./description.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/disabled-items.raw.jsx b/apps/docs/content/components/select/disabled-items.raw.jsx new file mode 100644 index 0000000000..fcebedbb83 --- /dev/null +++ b/apps/docs/content/components/select/disabled-items.raw.jsx @@ -0,0 +1,32 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + return ( + + ); +} diff --git a/apps/docs/content/components/select/disabled-items.ts b/apps/docs/content/components/select/disabled-items.ts index 64bed55e89..4ff907eed2 100644 --- a/apps/docs/content/components/select/disabled-items.ts +++ b/apps/docs/content/components/select/disabled-items.ts @@ -1,42 +1,7 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - return ( - - ); -}`; +import App from "./disabled-items.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/disabled.raw.jsx b/apps/docs/content/components/select/disabled.raw.jsx new file mode 100644 index 0000000000..401ae52a4d --- /dev/null +++ b/apps/docs/content/components/select/disabled.raw.jsx @@ -0,0 +1,33 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + return ( + + ); +} diff --git a/apps/docs/content/components/select/disabled.ts b/apps/docs/content/components/select/disabled.ts index dc9b756812..1a215cc91f 100644 --- a/apps/docs/content/components/select/disabled.ts +++ b/apps/docs/content/components/select/disabled.ts @@ -1,43 +1,7 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - return ( - - ); -}`; +import App from "./disabled.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/dynamic.raw.jsx b/apps/docs/content/components/select/dynamic.raw.jsx new file mode 100644 index 0000000000..5796f069eb --- /dev/null +++ b/apps/docs/content/components/select/dynamic.raw.jsx @@ -0,0 +1,30 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + return ( + + ); +} diff --git a/apps/docs/content/components/select/dynamic.ts b/apps/docs/content/components/select/dynamic.ts index 6a7c5304c9..5d3c97bb9a 100644 --- a/apps/docs/content/components/select/dynamic.ts +++ b/apps/docs/content/components/select/dynamic.ts @@ -1,38 +1,7 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - return ( - - ); -}`; +import App from "./dynamic.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/error-message.raw.jsx b/apps/docs/content/components/select/error-message.raw.jsx new file mode 100644 index 0000000000..a4499144e7 --- /dev/null +++ b/apps/docs/content/components/select/error-message.raw.jsx @@ -0,0 +1,43 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + const [value, setValue] = React.useState(new Set([])); + const [touched, setTouched] = React.useState(false); + + const isValid = value.has("cat"); + + return ( + + ); +} diff --git a/apps/docs/content/components/select/error-message.ts b/apps/docs/content/components/select/error-message.ts index 416a1d49bb..fb8101b132 100644 --- a/apps/docs/content/components/select/error-message.ts +++ b/apps/docs/content/components/select/error-message.ts @@ -1,53 +1,7 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - const [value, setValue] = React.useState(new Set([])); - const [touched, setTouched] = React.useState(false); - - const isValid = value.has("cat"); - - return ( - - ); -}`; +import App from "./error-message.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/item-start-content.raw.jsx b/apps/docs/content/components/select/item-start-content.raw.jsx new file mode 100644 index 0000000000..9006a2bf1b --- /dev/null +++ b/apps/docs/content/components/select/item-start-content.raw.jsx @@ -0,0 +1,68 @@ +import {Select, SelectItem, Avatar} from "@nextui-org/react"; + +export default function App() { + return ( + + ); +} diff --git a/apps/docs/content/components/select/item-start-content.ts b/apps/docs/content/components/select/item-start-content.ts index ddf3818b25..294a22e6b2 100644 --- a/apps/docs/content/components/select/item-start-content.ts +++ b/apps/docs/content/components/select/item-start-content.ts @@ -1,70 +1,4 @@ -const App = `import {Select, SelectItem, Avatar} from "@nextui-org/react"; - -export default function App() { - return ( - - ); -}`; +import App from "./item-start-content.raw.jsx?raw"; const react = { "/App.jsx": App, diff --git a/apps/docs/content/components/select/label-placements.raw.jsx b/apps/docs/content/components/select/label-placements.raw.jsx new file mode 100644 index 0000000000..86982bafb1 --- /dev/null +++ b/apps/docs/content/components/select/label-placements.raw.jsx @@ -0,0 +1,61 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + const placements = ["inside", "outside", "outside-left"]; + + return ( +
+
+

Without placeholder

+
+ {placements.map((placement) => ( + + ))} +
+
+
+

With placeholder

+
+ {placements.map((placement) => ( + + ))} +
+
+
+ ); +} diff --git a/apps/docs/content/components/select/label-placements.ts b/apps/docs/content/components/select/label-placements.ts index a147bb84a7..cd2a65d352 100644 --- a/apps/docs/content/components/select/label-placements.ts +++ b/apps/docs/content/components/select/label-placements.ts @@ -1,75 +1,7 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - const placements = [ - "inside", - "outside", - "outside-left", - ]; - - return ( -
-
-

Without placeholder

-
- {placements.map((placement) => ( - - ))} -
-
-
-

With placeholder

-
- {placements.map((placement) => ( - - ))} -
-
-
- ); -}`; +import App from "./label-placements.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/multiple-chips.raw.jsx b/apps/docs/content/components/select/multiple-chips.raw.jsx new file mode 100644 index 0000000000..3c0dd44cad --- /dev/null +++ b/apps/docs/content/components/select/multiple-chips.raw.jsx @@ -0,0 +1,243 @@ +import {Select, SelectItem, Avatar, Chip} from "@nextui-org/react"; + +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", + }, +]; + +export default function App() { + return ( + + ); +} diff --git a/apps/docs/content/components/select/multiple-chips.raw.tsx b/apps/docs/content/components/select/multiple-chips.raw.tsx new file mode 100644 index 0000000000..18f206aed9 --- /dev/null +++ b/apps/docs/content/components/select/multiple-chips.raw.tsx @@ -0,0 +1,255 @@ +import React from "react"; +import {Select, SelectItem, Avatar, Chip, SelectedItems} from "@nextui-org/react"; + +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", + }, +]; + +type User = { + id: number; + name: string; + role: string; + team: string; + status: string; + age: string; + avatar: string; + email: string; +}; + +export default function App() { + return ( + + ); +} diff --git a/apps/docs/content/components/select/multiple-chips.ts b/apps/docs/content/components/select/multiple-chips.ts index 1919c994ea..0c169cde37 100644 --- a/apps/docs/content/components/select/multiple-chips.ts +++ b/apps/docs/content/components/select/multiple-chips.ts @@ -1,309 +1,12 @@ -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 App = `import {Select, SelectItem, Avatar, Chip} from "@nextui-org/react"; -import {users} from "./data"; - -export default function App() { - return ( - - ); -}`; - -const AppTs = `import {Select, SelectItem, Avatar, Chip, SelectedItems} from "@nextui-org/react"; -import {users} from "./data"; - -type User = { - id: number; - name: string; - role: string; - team: string; - status: string; - age: string; - avatar: string; - email: string; -}; - -export default function App() { - return ( - - ); -}`; +import App from "./multiple-chips.raw.jsx?raw"; +import AppTs from "./multiple-chips.raw.tsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; const reactTs = { "/App.tsx": AppTs, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/multiple-controlled-onchange.raw.jsx b/apps/docs/content/components/select/multiple-controlled-onchange.raw.jsx new file mode 100644 index 0000000000..1b79957568 --- /dev/null +++ b/apps/docs/content/components/select/multiple-controlled-onchange.raw.jsx @@ -0,0 +1,43 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + const [values, setValues] = React.useState(new Set([])); + + const handleSelectionChange = (e) => { + setValues(new Set(e.target.value.split(","))); + }; + + return ( +
+ +

Selected: {Array.from(values).join(", ")}

+
+ ); +} diff --git a/apps/docs/content/components/select/multiple-controlled-onchange.raw.tsx b/apps/docs/content/components/select/multiple-controlled-onchange.raw.tsx new file mode 100644 index 0000000000..d171292536 --- /dev/null +++ b/apps/docs/content/components/select/multiple-controlled-onchange.raw.tsx @@ -0,0 +1,46 @@ +import type {Selection} from "@nextui-org/react"; + +import React from "react"; +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + const [values, setValues] = React.useState(new Set([])); + + const handleSelectionChange = (e: React.ChangeEvent) => { + setValues(new Set(e.target.value.split(","))); + }; + + return ( +
+ +

Selected: {Array.from(values).join(", ")}

+
+ ); +} diff --git a/apps/docs/content/components/select/multiple-controlled-onchange.ts b/apps/docs/content/components/select/multiple-controlled-onchange.ts index e12d5cf7d3..a8b2a21759 100644 --- a/apps/docs/content/components/select/multiple-controlled-onchange.ts +++ b/apps/docs/content/components/select/multiple-controlled-onchange.ts @@ -1,89 +1,12 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - const [values, setValues] = React.useState(new Set([])); - - const handleSelectionChange = (e) => { - setValues(new Set(e.target.value.split(","))); - }; - - return ( -
- -

Selected: {Array.from(values).join(", ")}

-
- ); -}`; - -const AppTs = `import {Select, SelectItem, Selection} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - const [values, setValues] = React.useState(new Set([])); - - const handleSelectionChange = (e: React.ChangeEvent) => { - setValues(new Set(e.target.value.split(","))); - }; - - return ( -
- -

Selected: {Array.from(values).join(", ")}

-
- ); -}`; +import App from "./multiple-controlled-onchange.raw.jsx?raw"; +import AppTs from "./multiple-controlled-onchange.raw.tsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; const reactTs = { "/App.tsx": AppTs, - "/data.ts": data, }; export default { diff --git a/apps/docs/content/components/select/multiple-controlled.raw.jsx b/apps/docs/content/components/select/multiple-controlled.raw.jsx new file mode 100644 index 0000000000..0d18ab0e6e --- /dev/null +++ b/apps/docs/content/components/select/multiple-controlled.raw.jsx @@ -0,0 +1,39 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + const [values, setValues] = React.useState(new Set(["cat", "dog"])); + + return ( +
+ +

Selected: {Array.from(values).join(", ")}

+
+ ); +} diff --git a/apps/docs/content/components/select/multiple-controlled.raw.tsx b/apps/docs/content/components/select/multiple-controlled.raw.tsx new file mode 100644 index 0000000000..c9b9d3f8bf --- /dev/null +++ b/apps/docs/content/components/select/multiple-controlled.raw.tsx @@ -0,0 +1,42 @@ +import type {Selection} from "@nextui-org/react"; + +import React from "react"; +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + const [values, setValues] = React.useState(new Set(["cat", "dog"])); + + return ( +
+ +

Selected: {Array.from(values).join(", ")}

+
+ ); +} diff --git a/apps/docs/content/components/select/multiple-controlled.ts b/apps/docs/content/components/select/multiple-controlled.ts index 2bfc63c6c7..ebc28a01db 100644 --- a/apps/docs/content/components/select/multiple-controlled.ts +++ b/apps/docs/content/components/select/multiple-controlled.ts @@ -1,81 +1,12 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - const [values, setValues] = React.useState(new Set(["cat", "dog"])); - - return ( -
- -

Selected: {Array.from(values).join(", ")}

-
- ); -}`; - -const AppTs = `import {Select, SelectItem, Selection} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - const [values, setValues] = React.useState(new Set(["cat", "dog"])); - - return ( -
- -

Selected: {Array.from(values).join(", ")}

-
- ); -}`; +import App from "./multiple-controlled.raw.jsx?raw"; +import AppTs from "./multiple-controlled.raw.tsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; const reactTs = { "/App.tsx": AppTs, - "/data.ts": data, }; export default { diff --git a/apps/docs/content/components/select/multiple.raw.jsx b/apps/docs/content/components/select/multiple.raw.jsx new file mode 100644 index 0000000000..71bf4b1465 --- /dev/null +++ b/apps/docs/content/components/select/multiple.raw.jsx @@ -0,0 +1,32 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + return ( + + ); +} diff --git a/apps/docs/content/components/select/multiple.ts b/apps/docs/content/components/select/multiple.ts index 5edb2da50f..8ad090fa27 100644 --- a/apps/docs/content/components/select/multiple.ts +++ b/apps/docs/content/components/select/multiple.ts @@ -1,42 +1,7 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - return ( - - ); -}`; +import App from "./multiple.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/open-state.raw.jsx b/apps/docs/content/components/select/open-state.raw.jsx new file mode 100644 index 0000000000..bd553f9d07 --- /dev/null +++ b/apps/docs/content/components/select/open-state.raw.jsx @@ -0,0 +1,41 @@ +import {Select, SelectItem, Button} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + const [isOpen, setIsOpen] = React.useState(false); + + return ( +
+ + +
+ ); +} diff --git a/apps/docs/content/components/select/open-state.ts b/apps/docs/content/components/select/open-state.ts index 97e13a99a7..5d40fb0bf0 100644 --- a/apps/docs/content/components/select/open-state.ts +++ b/apps/docs/content/components/select/open-state.ts @@ -1,51 +1,7 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem, Button} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - const [isOpen, setIsOpen] = React.useState(false); - - return ( -
- - -
- ); -}`; +import App from "./open-state.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/radius.raw.jsx b/apps/docs/content/components/select/radius.raw.jsx new file mode 100644 index 0000000000..9375e69cb6 --- /dev/null +++ b/apps/docs/content/components/select/radius.raw.jsx @@ -0,0 +1,40 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + const radius = ["full", "lg", "md", "sm", "none"]; + + return ( +
+ {radius.map((r) => ( + + ))} +
+ ); +} diff --git a/apps/docs/content/components/select/radius.ts b/apps/docs/content/components/select/radius.ts index 543c0c91df..7b78db1ce0 100644 --- a/apps/docs/content/components/select/radius.ts +++ b/apps/docs/content/components/select/radius.ts @@ -1,56 +1,7 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - const radius = [ - "full", - "lg", - "md", - "sm", - "none", - ]; - - return ( -
- {radius.map((r) => ( - - ))} -
- ); -}`; +import App from "./radius.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/required.raw.jsx b/apps/docs/content/components/select/required.raw.jsx new file mode 100644 index 0000000000..9a9f4f0cbd --- /dev/null +++ b/apps/docs/content/components/select/required.raw.jsx @@ -0,0 +1,33 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + return ( + + ); +} diff --git a/apps/docs/content/components/select/required.ts b/apps/docs/content/components/select/required.ts index f6447eba53..b50b781e6f 100644 --- a/apps/docs/content/components/select/required.ts +++ b/apps/docs/content/components/select/required.ts @@ -1,43 +1,7 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - return ( - - ); -}`; +import App from "./required.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/sections.raw.jsx b/apps/docs/content/components/select/sections.raw.jsx new file mode 100644 index 0000000000..30a61aa009 --- /dev/null +++ b/apps/docs/content/components/select/sections.raw.jsx @@ -0,0 +1,28 @@ +import {Select, SelectItem, SelectSection} from "@nextui-org/react"; + +export default function App() { + return ( + + ); +} diff --git a/apps/docs/content/components/select/sections.ts b/apps/docs/content/components/select/sections.ts index e1c02ebdb4..17cd360ea3 100644 --- a/apps/docs/content/components/select/sections.ts +++ b/apps/docs/content/components/select/sections.ts @@ -1,35 +1,4 @@ -const App = `import {Select, SelectItem, SelectSection} from "@nextui-org/react"; - -export default function App() { - return ( - - ); -}`; +import App from "./sections.raw.jsx?raw"; const react = { "/App.jsx": App, diff --git a/apps/docs/content/components/select/single-controlled-onchange.raw.jsx b/apps/docs/content/components/select/single-controlled-onchange.raw.jsx new file mode 100644 index 0000000000..43b41a4e27 --- /dev/null +++ b/apps/docs/content/components/select/single-controlled-onchange.raw.jsx @@ -0,0 +1,43 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + const [value, setValue] = React.useState(""); + + const handleSelectionChange = (e) => { + setValue(e.target.value); + }; + + return ( +
+ +

Selected: {value}

+
+ ); +} diff --git a/apps/docs/content/components/select/single-controlled-onchange.raw.tsx b/apps/docs/content/components/select/single-controlled-onchange.raw.tsx new file mode 100644 index 0000000000..c5199449ce --- /dev/null +++ b/apps/docs/content/components/select/single-controlled-onchange.raw.tsx @@ -0,0 +1,44 @@ +import React from "react"; +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + const [value, setValue] = React.useState(""); + + const handleSelectionChange = (e: React.ChangeEvent) => { + setValue(e.target.value); + }; + + return ( +
+ +

Selected: {value}

+
+ ); +} diff --git a/apps/docs/content/components/select/single-controlled-onchange.ts b/apps/docs/content/components/select/single-controlled-onchange.ts index b74254621a..3b52be133b 100644 --- a/apps/docs/content/components/select/single-controlled-onchange.ts +++ b/apps/docs/content/components/select/single-controlled-onchange.ts @@ -1,89 +1,12 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - const [value, setValue] = React.useState(""); - - const handleSelectionChange = (e) => { - setValue(e.target.value); - }; - - return ( -
- -

Selected: {value}

-
- ); -}`; - -const AppTs = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - const [value, setValue] = React.useState(""); - - const handleSelectionChange = (e: React.ChangeEvent) => { - setValue(e.target.value); - }; - - return ( -
- -

Selected: {value}

-
- ); -}`; +import App from "./single-controlled-onchange.raw.jsx?raw"; +import AppTs from "./single-controlled-onchange.raw.tsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; const reactTs = { "/App.tsx": AppTs, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/single-controlled.raw.jsx b/apps/docs/content/components/select/single-controlled.raw.jsx new file mode 100644 index 0000000000..a066013863 --- /dev/null +++ b/apps/docs/content/components/select/single-controlled.raw.jsx @@ -0,0 +1,39 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + const [value, setValue] = React.useState(new Set([])); + + return ( +
+ +

Selected: {value}

+
+ ); +} diff --git a/apps/docs/content/components/select/single-controlled.raw.tsx b/apps/docs/content/components/select/single-controlled.raw.tsx new file mode 100644 index 0000000000..58b292ea79 --- /dev/null +++ b/apps/docs/content/components/select/single-controlled.raw.tsx @@ -0,0 +1,40 @@ +import React from "react"; +import {Select, SelectItem, Selection} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + const [value, setValue] = React.useState(new Set([])); + + return ( +
+ +

Selected: {value}

+
+ ); +} diff --git a/apps/docs/content/components/select/single-controlled.ts b/apps/docs/content/components/select/single-controlled.ts index cae9bd5401..44c55e0568 100644 --- a/apps/docs/content/components/select/single-controlled.ts +++ b/apps/docs/content/components/select/single-controlled.ts @@ -1,81 +1,12 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const AppTs = `import {Select, SelectItem, Selection} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - const [value, setValue] = React.useState(new Set([])); - - return ( -
- -

Selected: {value}

-
- ); -}`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - const [value, setValue] = React.useState(new Set([])); - - return ( -
- -

Selected: {value}

-
- ); -}`; +import App from "./single-controlled.raw.jsx?raw"; +import AppTs from "./single-controlled.raw.tsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; const reactTs = { "/App.tsx": AppTs, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/sizes.raw.jsx b/apps/docs/content/components/select/sizes.raw.jsx new file mode 100644 index 0000000000..afaeafc7a0 --- /dev/null +++ b/apps/docs/content/components/select/sizes.raw.jsx @@ -0,0 +1,45 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + const sizes = ["sm", "md", "lg"]; + + return ( +
+ {sizes.map((size) => ( +
+ + +
+ ))} +
+ ); +} diff --git a/apps/docs/content/components/select/start-content.raw.jsx b/apps/docs/content/components/select/start-content.raw.jsx new file mode 100644 index 0000000000..99b6568b6d --- /dev/null +++ b/apps/docs/content/components/select/start-content.raw.jsx @@ -0,0 +1,67 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const PetIcon = (props) => ( + +); + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + return ( + + ); +} diff --git a/apps/docs/content/components/select/usage.raw.jsx b/apps/docs/content/components/select/usage.raw.jsx new file mode 100644 index 0000000000..1337231116 --- /dev/null +++ b/apps/docs/content/components/select/usage.raw.jsx @@ -0,0 +1,34 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + return ( +
+ + +
+ ); +} diff --git a/apps/docs/content/components/select/variants.raw.jsx b/apps/docs/content/components/select/variants.raw.jsx new file mode 100644 index 0000000000..78c5577ca7 --- /dev/null +++ b/apps/docs/content/components/select/variants.raw.jsx @@ -0,0 +1,45 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + const variants = ["flat", "bordered", "underlined", "faded"]; + + return ( +
+ {variants.map((variant) => ( +
+ + +
+ ))} +
+ ); +} diff --git a/apps/docs/content/components/select/without-scroll-shadow.raw.jsx b/apps/docs/content/components/select/without-scroll-shadow.raw.jsx new file mode 100644 index 0000000000..3aab534e2b --- /dev/null +++ b/apps/docs/content/components/select/without-scroll-shadow.raw.jsx @@ -0,0 +1,35 @@ +import {Select, SelectItem} from "@nextui-org/react"; + +export const animals = [ + {key: "cat", label: "Cat"}, + {key: "dog", label: "Dog"}, + {key: "elephant", label: "Elephant"}, + {key: "lion", label: "Lion"}, + {key: "tiger", label: "Tiger"}, + {key: "giraffe", label: "Giraffe"}, + {key: "dolphin", label: "Dolphin"}, + {key: "penguin", label: "Penguin"}, + {key: "zebra", label: "Zebra"}, + {key: "shark", label: "Shark"}, + {key: "whale", label: "Whale"}, + {key: "otter", label: "Otter"}, + {key: "crocodile", label: "Crocodile"}, +]; + +export default function App() { + return ( + + ); +} From 1445c55d99eff643b94fea0fdd228cafd1dc0140 Mon Sep 17 00:00:00 2001 From: WK Wong Date: Sat, 16 Nov 2024 12:45:10 +0800 Subject: [PATCH 2/5] refactor(docs): select dx --- apps/docs/content/components/select/sizes.ts | 56 +------------- .../components/select/start-content.ts | 73 +------------------ apps/docs/content/components/select/usage.ts | 48 +----------- .../content/components/select/variants.ts | 56 +------------- 4 files changed, 4 insertions(+), 229 deletions(-) diff --git a/apps/docs/content/components/select/sizes.ts b/apps/docs/content/components/select/sizes.ts index 02b1cde2d0..85a2f5b30b 100644 --- a/apps/docs/content/components/select/sizes.ts +++ b/apps/docs/content/components/select/sizes.ts @@ -1,61 +1,7 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - const sizes = ["sm", "md", "lg"]; - - return ( -
- {sizes.map((size) => ( -
- - -
- ))} -
- ); -}`; +import App from "./sizes.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/start-content.ts b/apps/docs/content/components/select/start-content.ts index 7b896eaf3f..59191d72a7 100644 --- a/apps/docs/content/components/select/start-content.ts +++ b/apps/docs/content/components/select/start-content.ts @@ -1,78 +1,7 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const PetIcon = `export const PetIcon = (props) => ( - -);`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {PetIcon} from "./PetIcon"; -import {animals} from "./data"; - -export default function App() { - return ( - - ); -} -`; +import App from "./start-content.raw.jsx?raw"; const react = { "/App.jsx": App, - "/PetIcon.jsx": PetIcon, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/usage.ts b/apps/docs/content/components/select/usage.ts index d676e3edb7..1118304c37 100644 --- a/apps/docs/content/components/select/usage.ts +++ b/apps/docs/content/components/select/usage.ts @@ -1,53 +1,7 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - return ( -
- - -
- ); -}`; +import App from "./usage.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; export default { diff --git a/apps/docs/content/components/select/variants.ts b/apps/docs/content/components/select/variants.ts index 040be0e123..ddea95fb2e 100644 --- a/apps/docs/content/components/select/variants.ts +++ b/apps/docs/content/components/select/variants.ts @@ -1,61 +1,7 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - const variants = ["flat", "bordered", "underlined", "faded"]; - - return ( -
- {variants.map((variant) => ( -
- - -
- ))} -
- ); -}`; +import App from "./variants.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; export default { From 4c4fb11e03c081504662a27711247abaf714a9c9 Mon Sep 17 00:00:00 2001 From: WK Wong Date: Sat, 16 Nov 2024 12:56:27 +0800 Subject: [PATCH 3/5] refactor(docs): select dx --- .../select/custom-selector-icon.raw.jsx | 42 ++++++------ .../components/select/start-content.raw.jsx | 68 ++++++++++--------- apps/docs/content/docs/components/select.mdx | 14 ++-- 3 files changed, 64 insertions(+), 60 deletions(-) diff --git a/apps/docs/content/components/select/custom-selector-icon.raw.jsx b/apps/docs/content/components/select/custom-selector-icon.raw.jsx index 1ba88429cb..f63192b0b5 100644 --- a/apps/docs/content/components/select/custom-selector-icon.raw.jsx +++ b/apps/docs/content/components/select/custom-selector-icon.raw.jsx @@ -1,25 +1,27 @@ import {Select, SelectItem} from "@nextui-org/react"; -export const SelectorIcon = (props) => ( - -); +export const SelectorIcon = (props) => { + return ( + + ); +}; export const animals = [ {key: "cat", label: "Cat"}, diff --git a/apps/docs/content/components/select/start-content.raw.jsx b/apps/docs/content/components/select/start-content.raw.jsx index 99b6568b6d..9164a68d79 100644 --- a/apps/docs/content/components/select/start-content.raw.jsx +++ b/apps/docs/content/components/select/start-content.raw.jsx @@ -1,38 +1,40 @@ import {Select, SelectItem} from "@nextui-org/react"; -export const PetIcon = (props) => ( - -); +export const PetIcon = (props) => { + return ( + + ); +}; export const animals = [ {key: "cat", label: "Cat"}, diff --git a/apps/docs/content/docs/components/select.mdx b/apps/docs/content/docs/components/select.mdx index 0469b09cab..55b476c101 100644 --- a/apps/docs/content/docs/components/select.mdx +++ b/apps/docs/content/docs/components/select.mdx @@ -54,7 +54,7 @@ Select follows the [Collection Components API](https://react-spectrum.adobe.com/ - **Static**: The usage example above shows the static implementation, which can be used when the full list of options is known ahead of time. - **Dynamic**: The example below can be used when the options come from an external data source such as an API call, or update over time. - + ### Multiple Selection @@ -64,24 +64,24 @@ You can use the `selectionMode="multiple"` property to allow multiple selection. ### Disabled - + ### Disabled Items You can disable specific items by using the `disabledKeys` property. - + ### Required If you pass the `isRequired` property to the select, it will have a `danger` asterisk at the end of the label and the select will be required. - + ### Sizes - + ### Colors @@ -99,7 +99,7 @@ the end of the label and the select will be required. You can change the position of the label by setting the `labelPlacement` property to `inside`, `outside` or `outside-left`. - + > **Note**: If the `label` is not passed, the `labelPlacement` property will be `outside` by default. @@ -108,7 +108,7 @@ You can change the position of the label by setting the `labelPlacement` propert You can use the `startContent` and `endContent` properties to add content to the start and end of the select. - + ### Item Start & End Content From 0293b31990c5c799de1aeebb283514200fbf8734 Mon Sep 17 00:00:00 2001 From: WK Wong Date: Sat, 16 Nov 2024 14:43:21 +0800 Subject: [PATCH 4/5] refactor(docs): select dx --- .../select/without-scroll-shadow.ts | 40 +------------------ 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/apps/docs/content/components/select/without-scroll-shadow.ts b/apps/docs/content/components/select/without-scroll-shadow.ts index 7a4d8b585d..1cfe3080fa 100644 --- a/apps/docs/content/components/select/without-scroll-shadow.ts +++ b/apps/docs/content/components/select/without-scroll-shadow.ts @@ -1,45 +1,7 @@ -const data = `export const animals = [ - {key: "cat", label: "Cat"}, - {key: "dog", label: "Dog"}, - {key: "elephant", label: "Elephant"}, - {key: "lion", label: "Lion"}, - {key: "tiger", label: "Tiger"}, - {key: "giraffe", label: "Giraffe"}, - {key: "dolphin", label: "Dolphin"}, - {key: "penguin", label: "Penguin"}, - {key: "zebra", label: "Zebra"}, - {key: "shark", label: "Shark"}, - {key: "whale", label: "Whale"}, - {key: "otter", label: "Otter"}, - {key: "crocodile", label: "Crocodile"} -];`; - -const App = `import {Select, SelectItem} from "@nextui-org/react"; -import {animals} from "./data"; - -export default function App() { - return ( - - ); -}`; +import App from "./without-scroll-shadow.raw.jsx?raw"; const react = { "/App.jsx": App, - "/data.js": data, }; export default { From 695ef4868ad0513e72f7cee145884a5e6f8fb3ae Mon Sep 17 00:00:00 2001 From: WK Wong Date: Sat, 16 Nov 2024 14:46:45 +0800 Subject: [PATCH 5/5] refactor(docs): select dx --- .../content/components/select/async-loading-items.raw.jsx | 4 ++-- .../content/components/select/async-loading-items.raw.tsx | 4 ++-- apps/docs/content/components/select/single-controlled.raw.tsx | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/docs/content/components/select/async-loading-items.raw.jsx b/apps/docs/content/components/select/async-loading-items.raw.jsx index d882cd4e03..9e6e7713b8 100644 --- a/apps/docs/content/components/select/async-loading-items.raw.jsx +++ b/apps/docs/content/components/select/async-loading-items.raw.jsx @@ -1,5 +1,3 @@ -/* eslint-disable no-console */ - import {Select, SelectItem} from "@nextui-org/react"; import {useInfiniteScroll} from "@nextui-org/use-infinite-scroll"; @@ -38,8 +36,10 @@ export function usePokemonList({fetchDelay = 0} = {}) { setItems((prevItems) => [...prevItems, ...json.results]); } catch (error) { if (error.name === "AbortError") { + // eslint-disable-next-line no-console console.log("Fetch aborted"); } else { + // eslint-disable-next-line no-console console.error("There was an error with the fetch operation:", error); } } finally { diff --git a/apps/docs/content/components/select/async-loading-items.raw.tsx b/apps/docs/content/components/select/async-loading-items.raw.tsx index 2a0f49d465..1353c9b5e2 100644 --- a/apps/docs/content/components/select/async-loading-items.raw.tsx +++ b/apps/docs/content/components/select/async-loading-items.raw.tsx @@ -1,5 +1,3 @@ -/* eslint-disable no-console */ - import React from "react"; import {Select, SelectItem} from "@nextui-org/react"; import {useInfiniteScroll} from "@nextui-org/use-infinite-scroll"; @@ -49,8 +47,10 @@ export function usePokemonList({fetchDelay = 0}: UsePokemonListProps = {}) { setItems((prevItems) => [...prevItems, ...json.results]); } catch (error) { if (error.name === "AbortError") { + // eslint-disable-next-line no-console console.log("Fetch aborted"); } else { + // eslint-disable-next-line no-console console.error("There was an error with the fetch operation:", error); } } finally { diff --git a/apps/docs/content/components/select/single-controlled.raw.tsx b/apps/docs/content/components/select/single-controlled.raw.tsx index 58b292ea79..13a1a847c0 100644 --- a/apps/docs/content/components/select/single-controlled.raw.tsx +++ b/apps/docs/content/components/select/single-controlled.raw.tsx @@ -1,5 +1,7 @@ +import type {Selection} from "@nextui-org/react"; + import React from "react"; -import {Select, SelectItem, Selection} from "@nextui-org/react"; +import {Select, SelectItem} from "@nextui-org/react"; export const animals = [ {key: "cat", label: "Cat"},