index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. var $kLydb$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
  2. var $kLydb$react = require("react");
  3. var $kLydb$radixuiprimitive = require("@radix-ui/primitive");
  4. var $kLydb$radixuireactusecontrollablestate = require("@radix-ui/react-use-controllable-state");
  5. var $kLydb$radixuireactprimitive = require("@radix-ui/react-primitive");
  6. function $parcel$export(e, n, v, s) {
  7. Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
  8. }
  9. function $parcel$interopDefault(a) {
  10. return a && a.__esModule ? a.default : a;
  11. }
  12. $parcel$export(module.exports, "Toggle", () => $7d30e3d88c861f40$export$bea8ebba691c5813);
  13. $parcel$export(module.exports, "Root", () => $7d30e3d88c861f40$export$be92b6f5f03c0fe9);
  14. /* -------------------------------------------------------------------------------------------------
  15. * Toggle
  16. * -----------------------------------------------------------------------------------------------*/ const $7d30e3d88c861f40$var$NAME = 'Toggle';
  17. const $7d30e3d88c861f40$export$bea8ebba691c5813 = /*#__PURE__*/ $kLydb$react.forwardRef((props, forwardedRef)=>{
  18. const { pressed: pressedProp , defaultPressed: defaultPressed = false , onPressedChange: onPressedChange , ...buttonProps } = props;
  19. const [pressed = false, setPressed] = $kLydb$radixuireactusecontrollablestate.useControllableState({
  20. prop: pressedProp,
  21. onChange: onPressedChange,
  22. defaultProp: defaultPressed
  23. });
  24. return /*#__PURE__*/ $kLydb$react.createElement($kLydb$radixuireactprimitive.Primitive.button, ($parcel$interopDefault($kLydb$babelruntimehelpersextends))({
  25. type: "button",
  26. "aria-pressed": pressed,
  27. "data-state": pressed ? 'on' : 'off',
  28. "data-disabled": props.disabled ? '' : undefined
  29. }, buttonProps, {
  30. ref: forwardedRef,
  31. onClick: $kLydb$radixuiprimitive.composeEventHandlers(props.onClick, ()=>{
  32. if (!props.disabled) setPressed(!pressed);
  33. })
  34. }));
  35. });
  36. /*#__PURE__*/ Object.assign($7d30e3d88c861f40$export$bea8ebba691c5813, {
  37. displayName: $7d30e3d88c861f40$var$NAME
  38. });
  39. /* ---------------------------------------------------------------------------------------------- */ const $7d30e3d88c861f40$export$be92b6f5f03c0fe9 = $7d30e3d88c861f40$export$bea8ebba691c5813;
  40. //# sourceMappingURL=index.js.map