import React from "react"; import {ComponentStory, ComponentMeta} from "@storybook/react"; import {checkbox} from "@nextui-org/theme"; import {CheckboxGroup, Checkbox, CheckboxGroupProps} from "../src"; import { CustomWithClassNames as CheckboxItemWithStyles, CustomWithHooks as CheckboxItemWithHooks, } from "./checkbox.stories"; export default { title: "Components/CheckboxGroup", component: CheckboxGroup, argTypes: { color: { control: { type: "select", options: ["default", "primary", "secondary", "success", "warning", "danger"], }, }, radius: { control: { type: "select", options: ["none", "base", "sm", "md", "lg", "xl", "full"], }, }, size: { control: { type: "select", options: ["xs", "sm", "md", "lg", "xl"], }, }, lineThrough: { control: { type: "boolean", }, }, isDisabled: { control: { type: "boolean", }, }, }, } as ComponentMeta; const defaultProps = { ...checkbox.defaultVariants, }; const Template: ComponentStory = (args: CheckboxGroupProps) => ( Buenos Aires Sydney San Francisco London Tokyo ); export const Default = Template.bind({}); Default.args = { ...defaultProps, }; export const WithLabel = Template.bind({}); WithLabel.args = { label: "Select cities", }; export const DefaultValue = Template.bind({}); DefaultValue.args = { ...defaultProps, label: "Select cities", defaultValue: ["buenos-aires", "london"], }; export const Horizontal = Template.bind({}); Horizontal.args = { label: "Select cities", orientation: "horizontal", }; export const IsDisabled = Template.bind({}); IsDisabled.args = { label: "Select cities", isDisabled: true, }; export const LineThrough = Template.bind({}); LineThrough.args = { label: "Select cities", lineThrough: true, }; export const WithDescription = Template.bind({}); WithDescription.args = { ...defaultProps, description: "Select the cities you want to visit", }; export const Invalid = Template.bind({}); Invalid.args = { ...defaultProps, validationState: "invalid", }; export const WithErrorMessage = Template.bind({}); WithErrorMessage.args = { ...defaultProps, validationState: "invalid", errorMessage: "The selected cities cannot be visited at the same time", }; export const DisableAnimation = Template.bind({}); DisableAnimation.args = { label: "Select cities", disableAnimation: true, }; export const Controlled = () => { const [groupSelected, setGroupSelected] = React.useState(["buenos-aires", "sydney"]); React.useEffect(() => { // eslint-disable-next-line no-console console.log("CheckboxGroup ", groupSelected); }, [groupSelected]); return (
Buenos Aires Sydney London Tokyo
); }; export const CustomWithClassNames = () => { const [groupSelected, setGroupSelected] = React.useState([]); return ( <>

Selected: {groupSelected.join(", ")}

); }; export const CustomWithHooks = () => { const [groupSelected, setGroupSelected] = React.useState([]); return ( <> Wifi TV Kitchen Parking Pool Gym

Selected: {groupSelected.join(", ")}

); };