Skip to content

Commit

Permalink
➕ [open-formulieren/open-forms#5016] Add react-select-event to requir…
Browse files Browse the repository at this point in the history
…ements
  • Loading branch information
stevenbal committed Jan 28, 2025
1 parent fb98c1d commit 7bac4eb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-select-event": "^5.5.1",
"sass": "^1.75.0",
"sass-loader": "^14.2.0",
"storybook": "^8.3.5",
Expand Down
7 changes: 7 additions & 0 deletions src/components/formio/select.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {useField} from 'formik';
import React from 'react';
import {ReactNode} from 'react';
import ReactSelect from 'react-select';
import type {
GroupBase,
Expand Down Expand Up @@ -35,6 +36,12 @@ export interface SelectProps<
onChange?: (event: {target: {name: string; value: ValueType}}) => void;
}

export interface Option {
value: string;
label: ReactNode;
description?: string;
}

function isOption<Option, Group extends GroupBase<Option> = GroupBase<Option>>(
opt: Option | Group
): opt is Option {
Expand Down
3 changes: 2 additions & 1 deletion src/registry/select/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {SelectComponentSchema} from '@open-formulieren/types';
import {useIntl} from 'react-intl';

import {Select} from '@/components/formio';
import {Option} from '@/components/formio/select';

import {ComponentPreviewProps} from '../types';
import {
Expand All @@ -22,7 +23,7 @@ const Preview: React.FC<ComponentPreviewProps<SelectComponentSchema>> = ({compon
const {key, label, description, tooltip, validate, multiple} = component;
const {required = false} = validate || {};

let options;
let options: Option[] = [];
if (checkIsManualOptions(component)) {
options = component?.data?.values || [];
} else if (checkIsReferentielijstenOptions(component)) {
Expand Down

0 comments on commit 7bac4eb

Please sign in to comment.