@open-formulieren/formio-builder
Version:
An opinionated Formio webform builder for Open Forms
29 lines (28 loc) • 1.57 kB
JavaScript
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import clsx from 'clsx';
import { useValidationErrors } from '../../utils/errors';
import { ErrorList } from '../../utils/errors';
import ComponentLabel from './component-label';
const Component = (_a) => {
var { type, field = '', required = false, label, tooltip = '', children, className: extraClassName = '' } = _a, props = __rest(_a, ["type", "field", "required", "label", "tooltip", "children", "className"]);
const { errors } = useValidationErrors(field);
const className = clsx('form-group', 'has-feedback', 'formio-component', 'offb-component', {
[`formio-component-${type}`]: type,
'has-error': field && errors.length > 0,
required: required,
[extraClassName]: !!extraClassName,
});
return (_jsxs("div", Object.assign({ className: className }, { children: [label && (_jsx(ComponentLabel, { label: label, required: required, htmlId: props.htmlId, tooltip: tooltip })), children, _jsx(ErrorList, { errors: errors })] })));
};
export default Component;