UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

62 lines (61 loc) 3.8 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { FormattedMessage, useIntl } from 'react-intl'; import { BuilderTabs, ClearOnHide, Description, Hidden, IsSensitiveData, Key, Label, PresentationConfig, Registration, SimpleConditional, Tooltip, Translations, Validate, useDeriveComponentKey, } from '../../components/builder'; import { LABELS } from '../../components/builder/messages'; import { Checkbox, TabList, TabPanel, Tabs } from '../../components/formio'; import { useErrorChecker } from '../../utils/errors'; /** * Form to configure a Formio 'npFamilyMembers' type component. */ const EditForm = () => { const intl = useIntl(); const [isKeyManuallySetRef, generatedKey] = useDeriveComponentKey(); const { hasAnyError } = useErrorChecker(); Validate.useManageValidatorsTranslations(['required']); return (_jsxs(Tabs, { children: [_jsxs(TabList, { children: [_jsx(BuilderTabs.Basic, { hasErrors: hasAnyError('label', 'key', 'description', 'tooltip', 'showInSummary', 'showInEmail', 'showInPDF', 'hidden', 'clearOnHide', 'isSensitiveData', 'includePartners', 'includeChildren') }), _jsx(BuilderTabs.Advanced, { hasErrors: hasAnyError('conditional') }), _jsx(BuilderTabs.Validation, { hasErrors: hasAnyError('validate') }), _jsx(BuilderTabs.Registration, { hasErrors: hasAnyError('registration') }), _jsx(BuilderTabs.Translations, { hasErrors: hasAnyError('openForms.translations') })] }), _jsxs(TabPanel, { children: [_jsx(Label, {}), _jsx(Key, { isManuallySetRef: isKeyManuallySetRef, generatedValue: generatedKey }), _jsx(Description, {}), _jsx(Tooltip, {}), _jsx(PresentationConfig, {}), _jsx(Hidden, {}), _jsx(ClearOnHide, {}), _jsx(IsSensitiveData, {}), _jsx(IncludePartners, {}), _jsx(IncludeChildren, {})] }), _jsx(TabPanel, { children: _jsx(SimpleConditional, {}) }), _jsxs(TabPanel, { children: [_jsx(Validate.Required, {}), _jsx(Validate.ValidatorPluginSelect, {}), _jsx(Validate.ValidationErrorTranslations, {})] }), _jsx(TabPanel, { children: _jsx(Registration.RegistrationAttributeSelect, {}) }), _jsx(TabPanel, { children: _jsx(Translations.ComponentTranslations, { propertyLabels: { label: intl.formatMessage(LABELS.label), description: intl.formatMessage(LABELS.description), tooltip: intl.formatMessage(LABELS.tooltip), } }) })] })); }; EditForm.defaultValues = { // basic tab label: '', key: '', description: '', tooltip: '', showInSummary: true, showInEmail: false, showInPDF: true, hidden: false, clearOnHide: true, isSensitiveData: true, includeChildren: true, includePartners: true, // Advanced tab conditional: { show: undefined, when: '', eq: '', }, // Validation tab validate: { required: false, plugins: [], }, translatedErrors: {}, registration: { attribute: '', }, }; const IncludePartners = () => { const intl = useIntl(); const tooltip = intl.formatMessage({ id: "ZOytnI", defaultMessage: [{ type: 0, value: "Whether to add partners information to the component." }] }); return (_jsx(Checkbox, { name: "includePartners", label: _jsx(FormattedMessage, { id: 'qmBAmr', defaultMessage: [{ type: 0, value: "Include partners" }] }), tooltip: tooltip })); }; const IncludeChildren = () => { const intl = useIntl(); const tooltip = intl.formatMessage({ id: "nC9GEx", defaultMessage: [{ type: 0, value: "Whether to add children information to the component." }] }); return (_jsx(Checkbox, { name: "includeChildren", label: _jsx(FormattedMessage, { id: 'o5Mfn3', defaultMessage: [{ type: 0, value: "Include children" }] }), tooltip: tooltip })); }; export default EditForm;