mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
import React from 'react';
|
|
import { resolve, resolve_references } from '@/_helpers/utils';
|
|
|
|
export const Checkbox = function Checkbox({ id, width, height, component, onComponentClick, currentState, onComponentOptionChanged, onEvent }) {
|
|
|
|
console.log('currentState', currentState);
|
|
|
|
const label = component.definition.properties.label.value;
|
|
|
|
function toggleValue(e) {
|
|
const checked = e.target.checked;
|
|
onComponentOptionChanged(component, 'value', checked);
|
|
if(checked) {
|
|
onEvent('onCheck', { component })
|
|
} else {
|
|
onEvent('onUnCheck', { component })
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div style={{width, height}} onClick={() => onComponentClick(id, component) }>
|
|
<label class="form-check form-check-inline">
|
|
<input
|
|
class="form-check-input"
|
|
type="checkbox"
|
|
onClick={(e) => { toggleValue(e)}}
|
|
/>
|
|
<span class="form-check-label">{label}</span>
|
|
</label>
|
|
</div>
|
|
);
|
|
};
|