index.mjs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import $5AXX7$babelruntimehelpersesmextends from "@babel/runtime/helpers/esm/extends";
  2. import {forwardRef as $5AXX7$forwardRef, createElement as $5AXX7$createElement} from "react";
  3. import {composeEventHandlers as $5AXX7$composeEventHandlers} from "@radix-ui/primitive";
  4. import {useControllableState as $5AXX7$useControllableState} from "@radix-ui/react-use-controllable-state";
  5. import {Primitive as $5AXX7$Primitive} from "@radix-ui/react-primitive";
  6. /* -------------------------------------------------------------------------------------------------
  7. * Toggle
  8. * -----------------------------------------------------------------------------------------------*/ const $b3bbe2732c13b576$var$NAME = 'Toggle';
  9. const $b3bbe2732c13b576$export$bea8ebba691c5813 = /*#__PURE__*/ $5AXX7$forwardRef((props, forwardedRef)=>{
  10. const { pressed: pressedProp , defaultPressed: defaultPressed = false , onPressedChange: onPressedChange , ...buttonProps } = props;
  11. const [pressed = false, setPressed] = $5AXX7$useControllableState({
  12. prop: pressedProp,
  13. onChange: onPressedChange,
  14. defaultProp: defaultPressed
  15. });
  16. return /*#__PURE__*/ $5AXX7$createElement($5AXX7$Primitive.button, $5AXX7$babelruntimehelpersesmextends({
  17. type: "button",
  18. "aria-pressed": pressed,
  19. "data-state": pressed ? 'on' : 'off',
  20. "data-disabled": props.disabled ? '' : undefined
  21. }, buttonProps, {
  22. ref: forwardedRef,
  23. onClick: $5AXX7$composeEventHandlers(props.onClick, ()=>{
  24. if (!props.disabled) setPressed(!pressed);
  25. })
  26. }));
  27. });
  28. /*#__PURE__*/ Object.assign($b3bbe2732c13b576$export$bea8ebba691c5813, {
  29. displayName: $b3bbe2732c13b576$var$NAME
  30. });
  31. /* ---------------------------------------------------------------------------------------------- */ const $b3bbe2732c13b576$export$be92b6f5f03c0fe9 = $b3bbe2732c13b576$export$bea8ebba691c5813;
  32. export {$b3bbe2732c13b576$export$bea8ebba691c5813 as Toggle, $b3bbe2732c13b576$export$be92b6f5f03c0fe9 as Root};
  33. //# sourceMappingURL=index.mjs.map