UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

52 lines (50 loc) 3.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const jsx_runtime_1 = require("react/jsx-runtime"); const react_intl_1 = require("react-intl"); const builder_1 = require("../../components/builder"); const messages_1 = require("../../components/builder/messages"); const formio_1 = require("../../components/formio"); const errors_1 = require("../../utils/errors"); /** * Form to configure a Formio 'fieldset' type component. */ const EditForm = () => { const intl = (0, react_intl_1.useIntl)(); const [isKeyManuallySetRef, generatedKey] = (0, builder_1.useDeriveComponentKey)(); const { hasAnyError } = (0, errors_1.useErrorChecker)(); return ((0, jsx_runtime_1.jsxs)(formio_1.Tabs, { children: [(0, jsx_runtime_1.jsxs)(formio_1.TabList, { children: [(0, jsx_runtime_1.jsx)(builder_1.BuilderTabs.Basic, { hasErrors: hasAnyError('label', 'key', 'tooltip', 'hidden', 'clearOnHide', 'hideHeader') }), (0, jsx_runtime_1.jsx)(builder_1.BuilderTabs.Advanced, { hasErrors: hasAnyError('conditional') }), (0, jsx_runtime_1.jsx)(builder_1.BuilderTabs.Translations, { hasErrors: hasAnyError('openForms.translations') })] }), (0, jsx_runtime_1.jsxs)(formio_1.TabPanel, { children: [(0, jsx_runtime_1.jsx)(builder_1.Label, {}), (0, jsx_runtime_1.jsx)(builder_1.Key, { isManuallySetRef: isKeyManuallySetRef, generatedValue: generatedKey }), (0, jsx_runtime_1.jsx)(builder_1.Tooltip, {}), (0, jsx_runtime_1.jsx)(builder_1.Hidden, {}), (0, jsx_runtime_1.jsx)(builder_1.ClearOnHide, {}), (0, jsx_runtime_1.jsx)(HideHeader, {})] }), (0, jsx_runtime_1.jsx)(formio_1.TabPanel, { children: (0, jsx_runtime_1.jsx)(builder_1.SimpleConditional, {}) }), (0, jsx_runtime_1.jsx)(formio_1.TabPanel, { children: (0, jsx_runtime_1.jsx)(builder_1.Translations.ComponentTranslations, { propertyLabels: { label: intl.formatMessage(messages_1.LABELS.label), // FIXME: should be translatable in the type // tooltip: intl.formatMessage(LABELS.tooltip), } }) })] })); }; /* Making this introspected or declarative doesn't seem advisable, as React is calling React.Children and related API's legacy API - this may get removed in future versions. Explicitly specifying the schema and default values is therefore probbaly best, at the cost of some repetition. */ EditForm.defaultValues = { components: [], // basic tab label: '', key: '', tooltip: '', hidden: false, clearOnHide: true, hideHeader: false, // Advanced tab conditional: { show: undefined, when: '', eq: '', }, }; const HideHeader = () => { const intl = (0, react_intl_1.useIntl)(); const tooltip = intl.formatMessage({ id: "unjdIB", defaultMessage: [{ type: 0, value: "Do not display the configured label and top line as the header in the fieldset." }] }); return ((0, jsx_runtime_1.jsx)(formio_1.Checkbox, { name: "hideHeader", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: '2Lg8Vc', defaultMessage: [{ type: 0, value: "Hide fieldset header" }] }), tooltip: tooltip })); }; exports.default = EditForm;