{
  "version": 3,
  "sources": ["../src/toggle.tsx"],
  "sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { Primitive } from '@radix-ui/react-primitive';\n\n/* -------------------------------------------------------------------------------------------------\n * Toggle\n * -----------------------------------------------------------------------------------------------*/\n\nconst NAME = 'Toggle';\n\ntype ToggleElement = React.ComponentRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = React.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface ToggleProps extends PrimitiveButtonProps {\n  /**\n   * The controlled state of the toggle.\n   */\n  pressed?: boolean;\n  /**\n   * The state of the toggle when initially rendered. Use `defaultPressed`\n   * if you do not need to control the state of the toggle.\n   * @defaultValue false\n   */\n  defaultPressed?: boolean;\n  /**\n   * The callback that fires when the state of the toggle changes.\n   */\n  onPressedChange?(pressed: boolean): void;\n}\n\nconst Toggle = /* @__PURE__ */ React.forwardRef<ToggleElement, ToggleProps>(\n  function Toggle(props, forwardedRef) {\n    const { pressed: pressedProp, defaultPressed, onPressedChange, ...buttonProps } = props;\n\n    const [pressed, setPressed] = useControllableState({\n      prop: pressedProp,\n      onChange: onPressedChange,\n      defaultProp: defaultPressed ?? false,\n      caller: NAME,\n    });\n\n    return (\n      <Primitive.button\n        type=\"button\"\n        aria-pressed={pressed}\n        data-state={pressed ? 'on' : 'off'}\n        data-disabled={props.disabled ? '' : undefined}\n        {...buttonProps}\n        ref={forwardedRef}\n        onClick={composeEventHandlers(props.onClick, () => {\n          if (!props.disabled) {\n            setPressed(!pressed);\n          }\n        })}\n      />\n    );\n  },\n);\n\n/* ---------------------------------------------------------------------------------------------- */\n\nconst Root = Toggle;\n\nexport {\n  Toggle,\n  //\n  Root,\n};\nexport type { ToggleProps };\n"],
  "mappings": ";;;;;AAAA,YAAY,WAAW;AACvB,SAAS,4BAA4B;AACrC,SAAS,4BAA4B;AACrC,SAAS,iBAAiB;AAuCpB;AAjCN,IAAM,OAAO;AAqBb,IAAM,SAAyB,gBAAM;AAAA,EACnC,gCAASA,QAAO,OAAO,cAAc;AACnC,UAAM,EAAE,SAAS,aAAa,gBAAgB,iBAAiB,GAAG,YAAY,IAAI;AAElF,UAAM,CAAC,SAAS,UAAU,IAAI,qBAAqB;AAAA,MACjD,MAAM;AAAA,MACN,UAAU;AAAA,MACV,aAAa,kBAAkB;AAAA,MAC/B,QAAQ;AAAA,IACV,CAAC;AAED,WACE;AAAA,MAAC,UAAU;AAAA,MAAV;AAAA,QACC,MAAK;AAAA,QACL,gBAAc;AAAA,QACd,cAAY,UAAU,OAAO;AAAA,QAC7B,iBAAe,MAAM,WAAW,KAAK;AAAA,QACpC,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,SAAS,qBAAqB,MAAM,SAAS,MAAM;AACjD,cAAI,CAAC,MAAM,UAAU;AACnB,uBAAW,CAAC,OAAO;AAAA,UACrB;AAAA,QACF,CAAC;AAAA;AAAA,IACH;AAAA,EAEJ,GAzBA;AA0BF;AAIA,IAAM,OAAO;",
  "names": ["Toggle"]
}
