@open-formulieren/formio-builder
Version:
An opinionated Formio webform builder for Open Forms
33 lines (32 loc) • 1.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValuesSrc = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_intl_1 = require("react-intl");
const formio_1 = require("../../../components/formio");
const OPTION_LABELS = (0, react_intl_1.defineMessages)({ manual: { id: "sU/n0S", defaultMessage: [{ type: 0, value: "Manually fill in" }] }, variable: { id: "+9x9sg", defaultMessage: [{ type: 0, value: "From variable" }] }, referenceLists: { id: "R25Vbr", defaultMessage: [{ type: 0, value: "Reference lists API" }] } });
// define the values with the the desired correct order
const OPTION_VALUES = ['manual', 'variable', 'referenceLists'];
/**
* The `ValuesSrc` component is used to configure on the component where options/values
* are sourced from.
*
* The available options can be specified manually, or they can be derived from another
* existing 'variable' through a JsonLogic expression.
*
* This component requires a compatible schema like `SelectComponentSchema`,
* `RadioComponentSchema` or `SelectboxesComponentSchema`.
*
* @todo: on change, the *other* configuration aspect needs to be cleared/reset.
*/
const ValuesSrc = () => {
const intl = (0, react_intl_1.useIntl)();
const options = OPTION_VALUES.map(val => ({
value: val,
label: intl.formatMessage(OPTION_LABELS[val]),
}));
const tooltip = intl.formatMessage({ id: "ySkT14", defaultMessage: [{ type: 0, value: "How to specify the available options." }] });
return ((0, jsx_runtime_1.jsx)(formio_1.Select, { name: "openForms.dataSrc", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: 'UmLruQ', defaultMessage: [{ type: 0, value: "Data source" }] }), required: true, tooltip: tooltip, valueProperty: "value", options: options }));
};
exports.ValuesSrc = ValuesSrc;
exports.default = exports.ValuesSrc;