/* jshint esversion: 6 */ import PropTypes from 'prop-types'; import classnames from 'classnames'; import Icons from '../common/icons.js'; import { __ } from '@wordpress/i18n'; const { ButtonGroup, Dashicon, Tooltip, Button } = wp.components; const { Component, Fragment } = wp.element; class CheckIconComponent extends Component { constructor() { super( ...arguments ); this.updateValues = this.updateValues.bind( this ); let value = this.props.control.setting.get(); let defaultParams = { options: { desktop: { name: __( 'Desktop', 'kadence' ), icon: 'desktop', }, tablet: { name: __( 'Tablet', 'kadence' ), icon: 'tablet', }, mobile: { name: __( 'Mobile', 'kadence' ), icon: 'smartphone', }, }, }; this.controlParams = this.props.control.params.input_attrs ? { ...defaultParams, ...this.props.control.params.input_attrs, } : defaultParams; let baseDefault = { 'mobile': true, 'tablet': true, 'desktop': true, }; this.defaultValue = this.props.control.params.default ? this.props.control.params.default : baseDefault; value = value ? { ...JSON.parse( JSON.stringify( this.defaultValue ) ), ...value } : JSON.parse( JSON.stringify( this.defaultValue ) ); this.state = { value: value, }; } render() { const controlLabel = ( { this.props.control.params.label && this.props.control.params.label } ); return (
{ controlLabel }
{ Object.keys( this.controlParams.options ).map( ( item ) => { return ( ); } )} { this.props.control.renderNotice() }
); } updateValues( value ) { this.props.control.setting.set( { ...this.props.control.setting.get(), ...value, flag: !this.props.control.setting.get().flag } ); } } CheckIconComponent.propTypes = { control: PropTypes.object.isRequired }; export default CheckIconComponent;