@open-formulieren/formio-builder
Version:
An opinionated Formio webform builder for Open Forms
93 lines (92 loc) • 5.04 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
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");
const file_tab_1 = __importDefault(require("./file-tab"));
const registration_tab_1 = __importDefault(require("./registration-tab"));
/**
* Form to configure a Formio 'file' type component.
*/
const EditForm = () => {
const intl = (0, react_intl_1.useIntl)();
const [isKeyManuallySetRef, generatedKey] = (0, builder_1.useDeriveComponentKey)();
const { hasAnyError } = (0, errors_1.useErrorChecker)();
builder_1.Validate.useManageValidatorsTranslations(['required']);
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', 'description', 'tooltip', 'showInSummary', 'showInEmail', 'showInPDF', 'multiple', 'hidden', 'clearOnHide', 'isSensitiveData') }), (0, jsx_runtime_1.jsx)(builder_1.BuilderTabs.Advanced, { hasErrors: hasAnyError('conditional') }), (0, jsx_runtime_1.jsx)(builder_1.BuilderTabs.Validation, { hasErrors: hasAnyError('validate') }), (0, jsx_runtime_1.jsx)(formio_1.Tab, Object.assign({ hasErrors: hasAnyError('file', 'useConfigFiletypes', 'of', 'fileMaxSize', 'maxNumberOfFiles') }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: 'UxTJsK', defaultMessage: [{ type: 0, value: "File" }] }) })), (0, jsx_runtime_1.jsx)(builder_1.BuilderTabs.Registration, { hasErrors: hasAnyError('registration') }), (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.Description, {}), (0, jsx_runtime_1.jsx)(builder_1.Tooltip, {}), (0, jsx_runtime_1.jsx)(builder_1.PresentationConfig, {}), (0, jsx_runtime_1.jsx)(builder_1.Multiple, { updateDefaultValue: false }), (0, jsx_runtime_1.jsx)(builder_1.Hidden, {}), (0, jsx_runtime_1.jsx)(builder_1.ClearOnHide, {}), (0, jsx_runtime_1.jsx)(builder_1.IsSensitiveData, {})] }), (0, jsx_runtime_1.jsx)(formio_1.TabPanel, { children: (0, jsx_runtime_1.jsx)(builder_1.SimpleConditional, {}) }), (0, jsx_runtime_1.jsxs)(formio_1.TabPanel, { children: [(0, jsx_runtime_1.jsx)(builder_1.Validate.Required, {}), (0, jsx_runtime_1.jsx)(builder_1.Validate.SoftRequired, {}), (0, jsx_runtime_1.jsx)(builder_1.Validate.ValidationErrorTranslations, {})] }), (0, jsx_runtime_1.jsx)(formio_1.TabPanel, { children: (0, jsx_runtime_1.jsx)(file_tab_1.default, {}) }), (0, jsx_runtime_1.jsx)(formio_1.TabPanel, { children: (0, jsx_runtime_1.jsx)(registration_tab_1.default, {}) }), (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),
description: intl.formatMessage(messages_1.LABELS.description),
tooltip: intl.formatMessage(messages_1.LABELS.tooltip),
} }) })] }));
};
/**
*
* @todo options.withCredentials: true seems to be set somewhere -> session cookie
* needs to be sent by the SDK/client!
*/
EditForm.defaultValues = {
storage: 'url',
url: '',
options: { withCredentials: true },
webcam: false,
// basic tab
label: '',
key: '',
description: '',
tooltip: '',
showInSummary: true,
showInEmail: false,
showInPDF: true,
multiple: false,
hidden: false,
clearOnHide: true,
isSensitiveData: true,
// Advanced tab
conditional: {
show: undefined,
when: '',
eq: '',
},
// Validation tab
validate: {
required: false,
},
translatedErrors: {},
openForms: {
softRequired: false,
translations: {},
},
// file tab
file: {
name: '',
type: [],
allowedTypesLabels: [],
},
filePattern: '*',
useConfigFiletypes: true,
of: {
image: {
resize: {
apply: false,
width: 2000,
height: 2000,
},
},
},
fileMaxSize: '10MB',
maxNumberOfFiles: null,
// registration tab
registration: {
informatieobjecttype: '',
bronorganisatie: '',
docVertrouwelijkheidaanduiding: '',
titel: '',
},
};
exports.default = EditForm;