Add form select field (#14538)

- create a WorkflowFormFieldInput component that takes a fieldMetadataId
as input and display a form field input
- add a select field for forms


https://github.com/user-attachments/assets/42f8ce98-c17a-4809-b1be-032e3066a596
This commit is contained in:
Thomas Trompette
2025-09-16 16:26:36 +02:00
committed by GitHub
parent 4f63f55686
commit e9f277fe93
10 changed files with 258 additions and 6 deletions
@@ -13,7 +13,6 @@ import { useTheme } from '@emotion/react';
import { useId, useState } from 'react';
import { Key } from 'ts-key-enum';
import { isDefined } from 'twenty-shared/utils';
import { IconCircleOff } from 'twenty-ui/display';
import { type SelectOption } from 'twenty-ui/input';
type FormSelectFieldInputProps = {
@@ -92,12 +91,19 @@ export const FormSelectFieldInput = ({
(option) => option.value === draftValue.value,
);
const emptyOption = {
label: `No ${label}`,
const defaultEmptyOption = {
label: `No ${label ?? 'value'}`,
value: '',
Icon: IconCircleOff,
};
const existingEmptyOption = options.find(
(option) => !isDefined(option.value) || option.value === '',
);
const optionsWithEmptyOption = isDefined(existingEmptyOption)
? options
: [defaultEmptyOption, ...options];
const handleUnlinkVariable = () => {
setDraftValue({
type: 'static',
@@ -132,10 +138,10 @@ export const FormSelectFieldInput = ({
{draftValue.type === 'static' ? (
<Select
dropdownId={`${instanceId}-select-display`}
options={options}
options={optionsWithEmptyOption}
value={selectedOption?.value}
onChange={onSelect}
emptyOption={emptyOption}
emptyOption={existingEmptyOption ?? defaultEmptyOption}
fullWidth
hasRightElement={isDefined(VariablePicker) && !readonly}
withSearchInput