Gazebo_simulation-Frontend/node_modules/.cache/babel-loader/488316db197416ae6f39e7ce10bd72af.json
2020-12-22 09:59:14 -05:00

1 line
2.5 KiB
JSON

{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nimport React from 'react';\nimport invariant from 'invariant';\nimport { useUncontrolled } from 'uncontrollable';\nimport chainFunction from './createChainedFunction';\nimport { map } from './ElementChildren';\nimport ButtonGroup from './ButtonGroup';\nimport ToggleButton from './ToggleButton';\nvar defaultProps = {\n type: 'radio'\n};\nvar ToggleButtonGroup = React.forwardRef(function (props, ref) {\n var _useUncontrolled = useUncontrolled(props, {\n value: 'onChange'\n }),\n children = _useUncontrolled.children,\n type = _useUncontrolled.type,\n name = _useUncontrolled.name,\n value = _useUncontrolled.value,\n onChange = _useUncontrolled.onChange,\n controlledProps = _objectWithoutPropertiesLoose(_useUncontrolled, [\"children\", \"type\", \"name\", \"value\", \"onChange\"]);\n\n var getValues = function getValues() {\n return value == null ? [] : [].concat(value);\n };\n\n var handleToggle = function handleToggle(inputVal, event) {\n var values = getValues();\n var isActive = values.indexOf(inputVal) !== -1;\n\n if (type === 'radio') {\n if (!isActive) onChange(inputVal, event);\n return;\n }\n\n if (isActive) {\n onChange(values.filter(function (n) {\n return n !== inputVal;\n }), event);\n } else {\n onChange([].concat(values, [inputVal]), event);\n }\n };\n\n !(type !== 'radio' || !!name) ? process.env.NODE_ENV !== \"production\" ? invariant(false, 'A `name` is required to group the toggle buttons when the `type` ' + 'is set to \"radio\"') : invariant(false) : void 0;\n return React.createElement(ButtonGroup, _extends({}, controlledProps, {\n ref: ref,\n toggle: true\n }), map(children, function (child) {\n var values = getValues();\n var _child$props = child.props,\n childVal = _child$props.value,\n childOnChange = _child$props.onChange;\n\n var handler = function handler(e) {\n return handleToggle(childVal, e);\n };\n\n return React.cloneElement(child, {\n type: type,\n name: child.name || name,\n checked: values.indexOf(childVal) !== -1,\n onChange: chainFunction(childOnChange, handler)\n });\n }));\n});\nToggleButtonGroup.defaultProps = defaultProps;\nToggleButtonGroup.Button = ToggleButton;\nexport default ToggleButtonGroup;","map":null,"metadata":{},"sourceType":"module"}