UNPKG

@tomino/dynamic-form-semantic-ui

Version:

Semantic UI form renderer based on dynamic form generation

37 lines 1.49 kB
import { prop } from '../common'; import { getValue, setValue, isNullOrEmpty } from '../helpers'; export { addButton, celled, controlMargin, styledTableRow, tableHeader, tableRowAuto, tableRowFull, tableRowWithDelete } from './properties_styles'; export function parseProps(props, editorState, resolveBoundProperty = false, propName = undefined) { let value = getValue(props, editorState, propName, undefined, props.extra ? `.${props.extra}` : ''); if (resolveBoundProperty && value && Object.keys(value).indexOf('source') >= 0) { if (!isNullOrEmpty(value.value)) { value = value.value; } else if (!isNullOrEmpty(value.source)) { value = value.source; } else if (!isNullOrEmpty(value.handler)) { value = value.handler; } else { value = null; } } return { props: props.formElement.props, value, error: prop(props.formElement) ? props.owner.getError(prop(props.formElement)) : null }; } export function onChangeHandler(e, sui) { let currentValue = e.currentTarget.type === 'checkbox' ? e.currentTarget.checked : sui ? sui.value : e.currentTarget.value; setValue(this.props, this.editorState, currentValue, this.propName, this.props.extra ? `.${this.props.extra}` : ''); } export function clearHandler() { setValue(this.props, null, ''); } //# sourceMappingURL=properties_common.js.map