import{a as e,n as t}from"./chunk-BneVvdWh.js";import{t as n}from"./react-C7IZe2D1.js";import{t as r}from"./jsx-runtime-C2wGStra.js";import{n as i,t as a}from"./Text-DO3xXyuu.js";import{n as o,t as s}from"./Checkbox-BV4Be-fH.js";var c,l,u,d,f,p,m,h,g,_,v,y;t((()=>{c=e(n(),1),o(),i(),l=r(),{action:u}=__STORYBOOK_MODULE_ACTIONS__,{expect:d,userEvent:f}=__STORYBOOK_MODULE_TEST__,p={title:`components/Checkbox`,component:s,args:{onChange:u(`onChange`),onCheckedChange:u(`onCheckedChange`)}},m={render:function(){return(0,l.jsxs)(`div`,{style:{display:`flex`,gap:`16px`,flexDirection:`column`},children:[(0,l.jsx)(a,{variant:`default-regular-italic`,children:`normal`}),(0,l.jsxs)(`div`,{style:{display:`flex`,gap:`16px`},children:[(0,l.jsx)(s,{"aria-label":`checkbox`}),(0,l.jsx)(s,{"aria-label":`checkbox`,checked:!0}),(0,l.jsx)(s,{"aria-label":`checkbox`,indeterminate:!0}),(0,l.jsx)(s,{"aria-label":`checkbox`,hasError:!0}),(0,l.jsx)(s,{"aria-label":`checkbox`,hasError:!0,checked:!0}),(0,l.jsx)(s,{"aria-label":`checkbox`,hasError:!0,indeterminate:!0}),(0,l.jsx)(s,{"aria-label":`checkbox`,disabled:!0}),(0,l.jsx)(s,{"aria-label":`checkbox`,disabled:!0,checked:!0}),(0,l.jsx)(s,{"aria-label":`checkbox`,disabled:!0,indeterminate:!0})]}),(0,l.jsx)(a,{variant:`default-regular-italic`,children:`focus`}),(0,l.jsxs)(`div`,{style:{display:`flex`,gap:`16px`},"data-focus":!0,children:[(0,l.jsx)(s,{"aria-label":`checkbox`}),(0,l.jsx)(s,{"aria-label":`checkbox`,checked:!0}),(0,l.jsx)(s,{"aria-label":`checkbox`,indeterminate:!0}),(0,l.jsx)(s,{"aria-label":`checkbox`,hasError:!0}),(0,l.jsx)(s,{"aria-label":`checkbox`,checked:!0,hasError:!0}),(0,l.jsx)(s,{"aria-label":`checkbox`,indeterminate:!0,hasError:!0})]})]})}},m.parameters={pseudo:{focusWithin:`[data-focus="true"] > *`}},h={parameters:{chromatic:{disableSnapshot:!0}},render:function(){return(0,l.jsx)(s,{"aria-label":`checkbox`})},play:async({canvas:e,step:t})=>{let n=e.getByRole(`checkbox`);d(n).not.toHaveAttribute(`aria-checked`),await t(`Initial state"`,async()=>{await f.click(n),d(n).toBeChecked(),d(n).not.toHaveAttribute(`aria-checked`)}),await t(`Initial state"`,async()=>{await f.click(n),d(n).not.toBeChecked(),d(n).not.toHaveAttribute(`aria-checked`)})}},g={parameters:{chromatic:{disableSnapshot:!0}},render:function(){let[e,t]=(0,c.useState)(!1);return(0,l.jsx)(s,{"aria-label":`checkbox`,checked:e,onCheckedChange:t})},play:async({canvas:e,step:t})=>{let n=e.getByRole(`checkbox`);await t(`Initial state"`,async()=>{d(n).not.toBeChecked(),d(n).not.toHaveAttribute(`aria-checked`)}),await t(`Click the checkbox"`,async()=>{await f.click(n),d(n).toBeChecked(),d(n).not.toHaveAttribute(`aria-checked`)}),await t(`Click the checkbox"`,async()=>{await f.click(n),d(n).not.toBeChecked(),d(n).not.toHaveAttribute(`aria-checked`)})}},_={parameters:{chromatic:{disableSnapshot:!0}},render:function(){let[e,t]=(0,c.useState)(!1),[n,r]=(0,c.useState)(!1);return(0,l.jsx)(s,{"aria-label":`checkbox`,checked:e,indeterminate:n,onCheckedChange:i=>{e===!1&&n===!1&&i===!0?r(!0):e===!1&&n===!0&&i===!0?(r(!1),t(!0)):e===!0&&n===!1&&i===!1&&t(!1)}})},play:async({canvas:e,step:t})=>{let n=e.getByRole(`checkbox`);if(!(n instanceof HTMLInputElement))throw Error(`Expected Consent all cookies to be an HTMLInputElement`);await t(`Initial state"`,async()=>{d(n).not.toBeChecked(),d(n).not.toHaveAttribute(`aria-checked`),d(n.indeterminate,`Indeterminate check`).toBe(!1)}),await t(`Click the checkbox"`,async()=>{await f.click(n),d(n).not.toBeChecked(),d(n).toHaveAttribute(`aria-checked`,`mixed`),d(n.indeterminate,`Indeterminate check`).toBe(!0)}),await t(`Click the checkbox"`,async()=>{await f.click(n),d(n).toBeChecked(),d(n).not.toHaveAttribute(`aria-checked`),d(n.indeterminate,`Indeterminate check`).toBe(!1)}),await t(`Click the checkbox"`,async()=>{await f.click(n),d(n).not.toBeChecked(),d(n).not.toHaveAttribute(`aria-checked`),d(n.indeterminate,`Indeterminate check`).toBe(!1)})}},v={parameters:{chromatic:{disableSnapshot:!0}},args:{"aria-label":`checkbox`},argTypes:{id:{control:`text`},name:{control:`text`},dataset:{control:`object`},checked:{control:`boolean`},disabled:{control:`boolean`},required:{control:`boolean`},hasError:{control:`boolean`},"aria-label":{control:`text`},indeterminate:{control:`boolean`},defaultChecked:{control:`boolean`},"aria-labelledby":{control:`text`}}},m.parameters={...m.parameters,docs:{...m.parameters?.docs,source:{originalSource:`{
  render: function Story() {
    return <div style={{
      display: 'flex',
      gap: '16px',
      flexDirection: 'column'
    }}>
                <Text variant="default-regular-italic">normal</Text>
                <div style={{
        display: 'flex',
        gap: '16px'
      }}>
                    <Checkbox aria-label="checkbox" />
                    <Checkbox aria-label="checkbox" checked />
                    <Checkbox aria-label="checkbox" indeterminate />
                    <Checkbox aria-label="checkbox" hasError />
                    <Checkbox aria-label="checkbox" hasError checked />
                    <Checkbox aria-label="checkbox" hasError indeterminate />
                    <Checkbox aria-label="checkbox" disabled />
                    <Checkbox aria-label="checkbox" disabled checked />
                    <Checkbox aria-label="checkbox" disabled indeterminate />
                </div>
                <Text variant="default-regular-italic">focus</Text>
                <div style={{
        display: 'flex',
        gap: '16px'
      }} data-focus>
                    <Checkbox aria-label="checkbox" />
                    <Checkbox aria-label="checkbox" checked />
                    <Checkbox aria-label="checkbox" indeterminate />
                    <Checkbox aria-label="checkbox" hasError />
                    <Checkbox aria-label="checkbox" checked hasError />
                    <Checkbox aria-label="checkbox" indeterminate hasError />
                </div>
            </div>;
  }
}`,...m.parameters?.docs?.source}}},h.parameters={...h.parameters,docs:{...h.parameters?.docs,source:{originalSource:`{
  parameters: {
    chromatic: {
      disableSnapshot: true
    }
  },
  render: function Story() {
    return <Checkbox aria-label="checkbox" />;
  },
  play: async ({
    canvas,
    step
  }) => {
    const checkbox = canvas.getByRole('checkbox');
    expect(checkbox).not.toHaveAttribute('aria-checked');
    await step('Initial state"', async () => {
      await userEvent.click(checkbox);
      expect(checkbox).toBeChecked();
      expect(checkbox).not.toHaveAttribute('aria-checked');
    });
    await step('Initial state"', async () => {
      await userEvent.click(checkbox);
      expect(checkbox).not.toBeChecked();
      expect(checkbox).not.toHaveAttribute('aria-checked');
    });
  }
}`,...h.parameters?.docs?.source}}},g.parameters={...g.parameters,docs:{...g.parameters?.docs,source:{originalSource:`{
  parameters: {
    chromatic: {
      disableSnapshot: true
    }
  },
  render: function Story() {
    const [checked, setChecked] = useState(false);
    return <Checkbox aria-label="checkbox" checked={checked} onCheckedChange={setChecked} />;
  },
  play: async ({
    canvas,
    step
  }) => {
    const checkbox = canvas.getByRole('checkbox');
    await step('Initial state"', async () => {
      expect(checkbox).not.toBeChecked();
      expect(checkbox).not.toHaveAttribute('aria-checked');
    });
    await step('Click the checkbox"', async () => {
      await userEvent.click(checkbox);
      expect(checkbox).toBeChecked();
      expect(checkbox).not.toHaveAttribute('aria-checked');
    });
    await step('Click the checkbox"', async () => {
      await userEvent.click(checkbox);
      expect(checkbox).not.toBeChecked();
      expect(checkbox).not.toHaveAttribute('aria-checked');
    });
  }
}`,...g.parameters?.docs?.source}}},_.parameters={..._.parameters,docs:{..._.parameters?.docs,source:{originalSource:`{
  parameters: {
    chromatic: {
      disableSnapshot: true
    }
  },
  render: function Story() {
    const [checked, setChecked] = useState(false);
    const [indeterminate, setIndeterminate] = useState(false);
    return <Checkbox aria-label="checkbox" checked={checked} indeterminate={indeterminate} onCheckedChange={value => {
      if (checked === false && indeterminate === false && value === true) {
        setIndeterminate(true);
      } else if (checked === false && indeterminate === true && value === true) {
        setIndeterminate(false);
        setChecked(true);
      } else if (checked === true && indeterminate === false && value === false) {
        setChecked(false);
      }
    }} />;
  },
  play: async ({
    canvas,
    step
  }) => {
    const checkbox = canvas.getByRole('checkbox');
    if (!(checkbox instanceof HTMLInputElement)) throw new Error('Expected Consent all cookies to be an HTMLInputElement');
    await step('Initial state"', async () => {
      expect(checkbox).not.toBeChecked();
      expect(checkbox).not.toHaveAttribute('aria-checked');
      expect(checkbox.indeterminate, 'Indeterminate check').toBe(false);
    });
    await step('Click the checkbox"', async () => {
      await userEvent.click(checkbox);
      expect(checkbox).not.toBeChecked();
      expect(checkbox).toHaveAttribute('aria-checked', 'mixed');
      expect(checkbox.indeterminate, 'Indeterminate check').toBe(true);
    });
    await step('Click the checkbox"', async () => {
      await userEvent.click(checkbox);
      expect(checkbox).toBeChecked();
      expect(checkbox).not.toHaveAttribute('aria-checked');
      expect(checkbox.indeterminate, 'Indeterminate check').toBe(false);
    });
    await step('Click the checkbox"', async () => {
      await userEvent.click(checkbox);
      expect(checkbox).not.toBeChecked();
      expect(checkbox).not.toHaveAttribute('aria-checked');
      expect(checkbox.indeterminate, 'Indeterminate check').toBe(false);
    });
  }
}`,..._.parameters?.docs?.source}}},v.parameters={...v.parameters,docs:{...v.parameters?.docs,source:{originalSource:`{
  parameters: {
    chromatic: {
      disableSnapshot: true
    }
  },
  args: {
    'aria-label': 'checkbox'
  },
  argTypes: {
    id: {
      control: 'text'
    },
    name: {
      control: 'text'
    },
    dataset: {
      control: 'object'
    },
    checked: {
      control: 'boolean'
    },
    disabled: {
      control: 'boolean'
    },
    required: {
      control: 'boolean'
    },
    hasError: {
      control: 'boolean'
    },
    'aria-label': {
      control: 'text'
    },
    indeterminate: {
      control: 'boolean'
    },
    defaultChecked: {
      control: 'boolean'
    },
    'aria-labelledby': {
      control: 'text'
    }
  }
}`,...v.parameters?.docs?.source}}},y=[`States`,`Uncontrolled`,`Controlled`,`ControlledWithIndeterminate`,`Playground`]}))();export{g as Controlled,_ as ControlledWithIndeterminate,v as Playground,m as States,h as Uncontrolled,y as __namedExportsOrder,p as default};