@open-formulieren/formio-builder
Version:
An opinionated Formio webform builder for Open Forms
29 lines (28 loc) • 1.68 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
import { Select } from '../../../components/formio';
const OPTION_LABELS = 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.
*/
export const ValuesSrc = () => {
const intl = 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 (_jsx(Select, { name: "openForms.dataSrc", label: _jsx(FormattedMessage, { id: 'UmLruQ', defaultMessage: [{ type: 0, value: "Data source" }] }), required: true, tooltip: tooltip, valueProperty: "value", options: options }));
};
export default ValuesSrc;