Sha256: 59e582626bf7bcc0c3545d518bc17307a3956df8022b28c8b3c285cdeb229859
Contents?: true
Size: 940 Bytes
Versions: 19
Compression:
Stored size: 940 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} 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
19 entries across 19 versions & 1 rubygems