1 line
1.8 KiB
JSON
1 line
1.8 KiB
JSON
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nimport classNames from 'classnames';\nimport React, { useState, useCallback } from 'react';\nimport Button from './Button';\n\nvar noop = function noop() {};\n\nvar ToggleButton = React.forwardRef(function (_ref, ref) {\n var children = _ref.children,\n name = _ref.name,\n className = _ref.className,\n checked = _ref.checked,\n type = _ref.type,\n onChange = _ref.onChange,\n value = _ref.value,\n disabled = _ref.disabled,\n inputRef = _ref.inputRef,\n props = _objectWithoutPropertiesLoose(_ref, [\"children\", \"name\", \"className\", \"checked\", \"type\", \"onChange\", \"value\", \"disabled\", \"inputRef\"]);\n\n var _useState = useState(false),\n focused = _useState[0],\n setFocused = _useState[1];\n\n var handleFocus = useCallback(function (e) {\n if (e.target.tagName === 'INPUT') setFocused(true);\n }, []);\n var handleBlur = useCallback(function (e) {\n if (e.target.tagName === 'INPUT') setFocused(false);\n }, []);\n return React.createElement(Button, _extends({}, props, {\n ref: ref,\n className: classNames(className, focused && 'focus', disabled && 'disabled'),\n type: null,\n active: !!checked,\n as: \"label\"\n }), React.createElement(\"input\", {\n name: name,\n type: type,\n value: value,\n ref: inputRef,\n autoComplete: \"off\",\n checked: !!checked,\n disabled: !!disabled,\n onFocus: handleFocus,\n onBlur: handleBlur,\n onChange: onChange || noop\n }), children);\n});\nToggleButton.displayName = 'ToggleButton';\nexport default ToggleButton;","map":null,"metadata":{},"sourceType":"module"} |