@gechiui/components
Version:
UI components for GeChiUI.
36 lines (30 loc) • 706 B
JavaScript
/**
* External dependencies
*/
import { isFunction } from 'lodash';
/**
* GeChiUI dependencies
*/
import { memo } from '@gechiui/element';
/**
* Internal dependencies
*/
import SwitchCell from '../mobile/bottom-sheet/switch-cell';
const ToggleControl = memo(
( { label, checked, help, instanceId, className, onChange, ...props } ) => {
const id = `inspector-toggle-control-${ instanceId }`;
const helpLabel = help && isFunction( help ) ? help( checked ) : help;
return (
<SwitchCell
label={ label }
id={ id }
help={ helpLabel }
className={ className }
value={ checked }
onValueChange={ onChange }
{ ...props }
/>
);
}
);
export default ToggleControl;