Sha256: bf6aacbf37ba84494b01b833c82430e9448a8cbf22014a20e3db590f2f9220cd
Contents?: true
Size: 978 Bytes
Versions: 44
Compression:
Stored size: 978 Bytes
Contents
import React from 'react'; import { Switch } from '@patternfly/react-core'; import { noop } from 'foremanReact/common/helpers'; import PropTypes from 'prop-types'; const EditableSwitch = ({ value, attribute, onEdit, disabled, setCurrentAttribute, }) => { const identifier = `${attribute} switch`; const onSwitch = (val) => { if (setCurrentAttribute) setCurrentAttribute(attribute); onEdit(val, attribute); }; return ( <Switch id={identifier} aria-label={identifier} ouiaId={`switch-${identifier}`} isChecked={value} onChange={onSwitch} disabled={disabled} /> ); }; EditableSwitch.propTypes = { value: PropTypes.bool.isRequired, attribute: PropTypes.string, onEdit: PropTypes.func, disabled: PropTypes.bool, setCurrentAttribute: PropTypes.func, }; EditableSwitch.defaultProps = { attribute: '', onEdit: noop, disabled: false, setCurrentAttribute: undefined, }; export default EditableSwitch;
Version data entries
44 entries across 44 versions & 1 rubygems