import { InputField } from '@components/common/form/InputField.js'; import { NumberField } from '@components/common/form/NumberField.js'; import { RadioGroupField } from '@components/common/form/RadioGroupField.js'; import { Card, CardContent, CardTitle } from '@components/common/ui/Card.js'; import React from 'react'; import { useFormContext, Controller, Control } from 'react-hook-form'; import Select from 'react-select'; import CreatableSelect from 'react-select/creatable'; const components = { DropdownIndicator: null }; const createOption = (label) => ({ label, value: label }); const AreaInput: React.FC<{ values: { label: string; value: string; }[]; control: Control; }> = ({ values, control }) => { const [inputValue, setInputValue] = React.useState(''); const handleKeyDown = (event, onChange, value) => { if (!inputValue) return; switch (event.key) { case 'Enter': case 'Tab': const newOption = createOption(inputValue); onChange([...value, newOption]); setInputValue(''); event.preventDefault(); break; default: break; } }; return ( v.value)} render={({ field }) => ( { const stringArray = newValue ? newValue.map((option) => option.value) : []; field.onChange(stringArray); }} onInputChange={(newValue) => setInputValue(newValue)} onKeyDown={(event) => handleKeyDown( event, (newOptions) => { const stringArray = newOptions.map((option) => option.value); field.onChange(stringArray); }, field.value ? field.value.map((val) => typeof val === 'string' ? createOption(val) : val ) : [] ) } placeholder="Type area and press enter..." value={ field.value ? field.value.map((val) => typeof val === 'string' ? createOption(val) : val ) : [] } /> )} /> ); }; interface GeneralProps { widget?: { name?: string; status?: number; sortOrder?: number; area?: string[]; route?: string[]; }; routes: Array<{ value: string; label: string; isApi: boolean; isAdmin: boolean; method: string[]; }>; } export default function General({ widget, routes }: GeneralProps) { const { register, control } = useFormContext(); const allRoutes = [ { value: 'all', label: 'All', isAdmin: false, isApi: false, method: ['GET'] }, ...routes ]; return (
({ value: a, label: a })) : [] } />
(