From c7e0ad79b8c0b04261c512ca21001ed957b8ba75 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Mon, 11 Dec 2023 10:57:19 +0000 Subject: [PATCH] tests passing! --- src/npm-fastui/src/components/FormField.tsx | 12 +- src/npm-fastui/src/components/Iframe.tsx | 7 + src/npm-fastui/src/components/display.tsx | 1 + src/npm-fastui/src/components/form.tsx | 1 + src/npm-fastui/src/components/heading.tsx | 4 + src/npm-fastui/src/components/image.tsx | 2 + src/npm-fastui/src/components/pagination.tsx | 4 + .../fastui/components/__init__.py | 69 +++++----- .../fastui/components/display.py | 8 +- src/python-fastui/fastui/components/forms.py | 13 +- src/python-fastui/fastui/components/tables.py | 2 +- src/python-fastui/fastui/events.py | 6 +- src/python-fastui/fastui/forms.py | 5 +- .../tests/react-fastui-json-schema.json | 123 ++++++++++-------- .../tests/test_json_schema_match.py | 114 +++++++++++----- 15 files changed, 232 insertions(+), 139 deletions(-) diff --git a/src/npm-fastui/src/components/FormField.tsx b/src/npm-fastui/src/components/FormField.tsx index aa8a4edd..0fd0e44e 100644 --- a/src/npm-fastui/src/components/FormField.tsx +++ b/src/npm-fastui/src/components/FormField.tsx @@ -5,16 +5,18 @@ import Select, { StylesConfig } from 'react-select' import { ClassName, useClassName } from '../hooks/className' import { debounce, useRequest } from '../tools' +type PrivateOnChange = () => void + interface BaseFormFieldProps { name: string - title: string[] + title: string | string[] required: boolean locked: boolean error?: string description?: string displayMode?: 'default' | 'inline' className?: ClassName - onChange?: () => void + onChange?: PrivateOnChange } export type FormFieldProps = @@ -239,6 +241,7 @@ function findDefault(options: SelectOptions, value?: string): SelectOption | und interface FormFieldSelectSearchProps extends BaseFormFieldProps { type: 'FormFieldSelectSearch' searchUrl: string + /** @TJS-type integer */ debounce?: number initial?: SelectOption multiple?: boolean @@ -302,7 +305,10 @@ export const FormFieldSelectSearchComp: FC = (props) } const Label: FC = (props) => { - const { title } = props + let { title } = props + if (!Array.isArray(title)) { + title = [title] + } return (