@talend/react-forms
Version:
React forms library based on json schema form.
45 lines • 1.5 kB
JavaScript
import PropTypes from 'prop-types';
import { Form } from '@talend/design-system';
import { VisuallyHidden } from '@talend/design-system';
import shouldRender from '../../utils/condition';
import Widget from '../../Widget';
import { createElement as _createElement } from "react";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export default function Fieldset(props) {
const {
schema,
...restProps
} = props;
const {
title,
items,
options
} = schema;
const widgets = items.filter(itemSchema => shouldRender(itemSchema.condition, props.properties, itemSchema.key)).map((itemSchema, index) => /*#__PURE__*/_createElement(Widget, {
...restProps,
key: index,
schema: itemSchema
}));
return widgets.length ? /*#__PURE__*/_jsxs(Form.Fieldset, {
legend: !(options !== null && options !== void 0 && options.hideTitle) && title,
children: [(options === null || options === void 0 ? void 0 : options.hideTitle) && /*#__PURE__*/_jsx(VisuallyHidden, {
children: /*#__PURE__*/_jsx("legend", {
children: title
})
}), widgets]
}) : null;
}
if (process.env.NODE_ENV !== 'production') {
Fieldset.propTypes = {
schema: PropTypes.shape({
title: PropTypes.string,
items: PropTypes.array.isRequired,
options: PropTypes.shape({
hideTitle: PropTypes.bool
})
}).isRequired,
properties: PropTypes.object,
...Widget.propTypes
};
}
//# sourceMappingURL=Fieldset.component.js.map