UNPKG

@rjsf/antd

Version:

Ant Design theme, fields and widgets for react-jsonschema-form

4 lines 88.4 kB
{ "version": 3, "sources": ["../src/index.ts", "../src/templates/ArrayFieldItemTemplate/index.tsx", "../src/templates/ArrayFieldTemplate/index.tsx", "../src/templates/BaseInputTemplate/index.tsx", "../src/templates/ErrorList/index.tsx", "../src/templates/FieldDescriptionTemplate/index.tsx", "../src/templates/FieldErrorTemplate/index.tsx", "../src/templates/FieldTemplate/index.tsx", "../src/templates/GridTemplate/index.tsx", "../src/templates/IconButton/index.tsx", "../src/templates/MultiSchemaFieldTemplate/index.tsx", "../src/templates/ObjectFieldTemplate/index.tsx", "../src/templates/OptionalDataControlsTemplate/index.tsx", "../src/templates/SubmitButton/index.tsx", "../src/templates/TitleField/index.tsx", "../src/templates/WrapIfAdditionalTemplate/index.tsx", "../src/templates/index.ts", "../src/widgets/AltDateTimeWidget/index.tsx", "../src/widgets/AltDateWidget/index.tsx", "../src/widgets/CheckboxesWidget/index.tsx", "../src/widgets/CheckboxWidget/index.tsx", "../src/widgets/DateWidget/index.tsx", "../src/widgets/DateTimeWidget/index.tsx", "../src/widgets/PasswordWidget/index.tsx", "../src/widgets/RadioWidget/index.tsx", "../src/widgets/RangeWidget/index.tsx", "../src/widgets/SelectWidget/index.tsx", "../src/widgets/TextareaWidget/index.tsx", "../src/widgets/index.ts"], "sourcesContent": ["import type { ComponentType } from 'react';\nimport type { FormProps, ThemeProps } from '@rjsf/core';\nimport { withTheme } from '@rjsf/core';\nimport type { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';\n\nimport Templates, { generateTemplates } from './templates';\nimport Widgets, { generateWidgets } from './widgets';\n\nexport function generateTheme<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(): ThemeProps<T, S, F> {\n return {\n templates: generateTemplates<T, S, F>(),\n widgets: generateWidgets<T, S, F>(),\n };\n}\n\nconst Theme = generateTheme();\n\nexport function generateForm<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(): ComponentType<FormProps<T, S, F>> {\n return withTheme<T, S, F>(generateTheme<T, S, F>());\n}\n\nconst Form = generateForm();\n\nexport { Form, Templates, Theme, Widgets, generateTemplates, generateWidgets };\n\nexport default Form;\n", "import type { ArrayFieldItemTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';\nimport { getUiOptions, getTemplate } from '@rjsf/utils';\nimport { Col, Row, Space } from 'antd';\n\nconst BTN_GRP_STYLE = {\n width: '100%',\n justifyContent: 'flex-end',\n};\n\nconst BTN_STYLE = {\n width: 'calc(100% / 4)',\n};\n\n/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.\n *\n * @param props - The `ArrayFieldItemTemplateProps` props for the component\n */\nexport default function ArrayFieldItemTemplate<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(props: ArrayFieldItemTemplateProps<T, S, F>) {\n const { children, buttonsProps, displayLabel, hasDescription, hasToolbar, index, registry, uiSchema } = props;\n const uiOptions = getUiOptions<T, S, F>(uiSchema);\n const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>(\n 'ArrayFieldItemButtonsTemplate',\n registry,\n uiOptions,\n );\n const { rowGutter = 24, toolbarAlign = displayLabel ? 'middle' : 'top' } = registry.formContext;\n const margin = hasDescription ? -8 : 16;\n\n return (\n <Row align={toolbarAlign} key={`rjsf-array-item-${index}`} gutter={rowGutter}>\n <Col flex='1'>{children}</Col>\n {hasToolbar && (\n <Col flex='120px' style={{ marginTop: displayLabel ? `${margin}px` : undefined }}>\n <Space.Compact style={BTN_GRP_STYLE}>\n <ArrayFieldItemButtonsTemplate {...buttonsProps} style={BTN_STYLE} />\n </Space.Compact>\n </Col>\n )}\n </Row>\n );\n}\n", "import { useContext } from 'react';\nimport type {\n ArrayFieldTemplateProps,\n FormContextType,\n GenericObjectType,\n RJSFSchema,\n StrictRJSFSchema,\n} from '@rjsf/utils';\nimport { getTemplate, getUiOptions, buttonId } from '@rjsf/utils';\nimport { Col, Row, ConfigProvider } from 'antd';\nimport classNames from 'classnames';\n\n/** The `ArrayFieldTemplate` component is the template used to render all items in an array.\n *\n * @param props - The `ArrayFieldTemplateProps` props for the component\n */\nexport default function ArrayFieldTemplate<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(props: ArrayFieldTemplateProps<T, S, F>) {\n const {\n canAdd,\n className,\n disabled,\n fieldPathId,\n items,\n optionalDataControl,\n onAddClick,\n readonly,\n registry,\n required,\n schema,\n title,\n uiSchema,\n } = props;\n const uiOptions = getUiOptions<T, S, F>(uiSchema);\n const ArrayFieldTitleTemplate = getTemplate<'ArrayFieldTitleTemplate', T, S, F>(\n 'ArrayFieldTitleTemplate',\n registry,\n uiOptions,\n );\n const showOptionalDataControlInTitle = !readonly && !disabled;\n const { formContext } = registry;\n // Button templates are not overridden in the uiSchema\n const {\n ButtonTemplates: { AddButton },\n } = registry.templates;\n const { labelAlign = 'right', rowGutter = 24 } = formContext as GenericObjectType;\n\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('form');\n const labelClsBasic = `${prefixCls}-item-label`;\n const labelColClassName = classNames(\n labelClsBasic,\n labelAlign === 'left' && `${labelClsBasic}-left`,\n // labelCol.className,\n );\n\n return (\n <fieldset className={className} id={fieldPathId.$id}>\n <Row gutter={rowGutter}>\n {(uiOptions.title || title) && (\n <Col className={labelColClassName} span={24}>\n <ArrayFieldTitleTemplate\n fieldPathId={fieldPathId}\n required={required}\n title={uiOptions.title || title}\n schema={schema}\n uiSchema={uiSchema}\n registry={registry}\n optionalDataControl={showOptionalDataControlInTitle ? optionalDataControl : undefined}\n />\n </Col>\n )}\n <Col className='row array-item-list' span={24}>\n {!showOptionalDataControlInTitle ? optionalDataControl : undefined}\n {items}\n </Col>\n {canAdd && (\n <Col span={24}>\n <Row gutter={rowGutter} justify='end'>\n <Col flex='120px'>\n <AddButton\n id={buttonId(fieldPathId, 'add')}\n className='rjsf-array-item-add'\n disabled={disabled || readonly}\n onClick={onAddClick}\n uiSchema={uiSchema}\n registry={registry}\n />\n </Col>\n </Row>\n </Col>\n )}\n </Row>\n </fieldset>\n );\n}\n", "import type { ChangeEvent, FocusEvent, MouseEvent } from 'react';\nimport { useCallback } from 'react';\nimport { SchemaExamples } from '@rjsf/core';\nimport type {\n BaseInputTemplateProps,\n FormContextType,\n GenericObjectType,\n RJSFSchema,\n StrictRJSFSchema,\n} from '@rjsf/utils';\nimport { ariaDescribedByIds, examplesId, getInputProps } from '@rjsf/utils';\nimport { Input, InputNumber } from 'antd';\n\nconst INPUT_STYLE = {\n width: '100%',\n};\n\n/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.\n * It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.\n * It can be customized/overridden for other themes or individual implementations as needed.\n *\n * @param props - The `WidgetProps` for this template\n */\nexport default function BaseInputTemplate<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(props: BaseInputTemplateProps<T, S, F>) {\n const {\n disabled,\n registry,\n id,\n htmlName,\n onBlur,\n onChange,\n onChangeOverride,\n onFocus,\n options,\n placeholder,\n readonly,\n required,\n schema,\n value,\n type,\n } = props;\n const { formContext } = registry;\n // InputNumber doesn't use a native <input type=\"number\"> directly - it wraps it and controls the stepping behavior\n // through its own props. The step prop in Ant Design expects a number, not the string \"any\"\n const inputProps = getInputProps<T, S, F>(schema, type, options, false);\n const { readonlyAsDisabled = true } = formContext as GenericObjectType;\n const { ClearButton } = registry.templates.ButtonTemplates;\n\n const handleNumberChange = (nextValue: number | null) => onChange(nextValue);\n\n const handleTextChange =\n onChangeOverride ||\n (({ target }: ChangeEvent<HTMLInputElement>) => onChange(target.value === '' ? options.emptyValue : target.value));\n\n const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);\n\n const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);\n\n const handleClear = useCallback(\n (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onChange(options.emptyValue ?? '');\n },\n [onChange, options.emptyValue],\n );\n\n const { min, max, ...restInputProps } = inputProps;\n\n const input =\n inputProps.type === 'number' || inputProps.type === 'integer' ? (\n <InputNumber\n disabled={disabled || (readonlyAsDisabled && readonly)}\n id={id}\n name={htmlName || id}\n onBlur={!readonly ? handleBlur : undefined}\n onChange={!readonly ? handleNumberChange : undefined}\n onFocus={!readonly ? handleFocus : undefined}\n placeholder={placeholder}\n required={required}\n style={INPUT_STYLE}\n changeOnWheel={false}\n list={schema.examples ? examplesId(id) : undefined}\n {...restInputProps}\n min={typeof min === 'number' ? min : undefined}\n max={typeof max === 'number' ? max : undefined}\n type={undefined}\n value={value}\n aria-describedby={ariaDescribedByIds(id, !!schema.examples)}\n />\n ) : (\n <Input\n disabled={disabled || (readonlyAsDisabled && readonly)}\n id={id}\n name={htmlName || id}\n onBlur={!readonly ? handleBlur : undefined}\n onChange={!readonly ? handleTextChange : undefined}\n onFocus={!readonly ? handleFocus : undefined}\n placeholder={placeholder}\n required={required}\n style={INPUT_STYLE}\n list={schema.examples ? examplesId(id) : undefined}\n {...inputProps}\n value={value}\n aria-describedby={ariaDescribedByIds(id, !!schema.examples)}\n />\n );\n\n return (\n <>\n {input}\n {options.allowClearTextInputs && !readonly && !disabled && value && (\n <ClearButton registry={registry} onClick={handleClear} />\n )}\n <SchemaExamples id={id} schema={schema} />\n </>\n );\n}\n", "import { ExclamationCircleOutlined } from '@ant-design/icons';\nimport type { ErrorListProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';\nimport { TranslatableString } from '@rjsf/utils';\nimport { Alert, Space, theme, version } from 'antd';\n\nconst antdMajor = parseInt(version.split('.')[0], 10);\n\n/** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`\n *\n * @param props - The `ErrorListProps` for this component\n */\nexport default function ErrorList<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({\n errors,\n registry,\n}: ErrorListProps<T, S, F>) {\n const { translateString } = registry;\n // Antd's List component has been deprecated and waiting to be replaced: https://ant.design/components/list#faq-listy-replacement\n // In the meantime we can mimic the Look & Feel of the List component by adding some inline CSS\n const { token } = theme.useToken();\n const itemBorder = `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`;\n const renderErrors = () => (\n <ul style={{ margin: 0, padding: 0, listStyle: 'none' }}>\n {errors.map((error, index) => (\n <li\n // oxlint-disable-next-line react/no-array-index-key\n key={index}\n style={{\n display: 'flex',\n alignItems: 'center',\n padding: `${token.paddingXS}px ${token.padding}px`,\n color: token.colorText,\n borderBlockEnd: index < errors.length - 1 ? itemBorder : 'none',\n }}\n >\n <Space>\n <ExclamationCircleOutlined />\n {error.stack}\n </Space>\n </li>\n ))}\n </ul>\n );\n\n // Deal with the two versions of antd that we support (v5, v6). In RJSF v7, we will drop support for antd 5, so clean this up\n const headerProp =\n antdMajor >= 6\n ? { title: translateString(TranslatableString.ErrorsLabel) }\n : { message: translateString(TranslatableString.ErrorsLabel) };\n\n return <Alert className='panel panel-danger errors' description={renderErrors()} type='error' {...headerProp} />;\n}\n", "import { RichDescription } from '@rjsf/core';\nimport type { DescriptionFieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';\n\n/** The `DescriptionField` is the template to use to render the description of a field\n *\n * @param props - The `DescriptionFieldProps` for this component\n */\nexport default function DescriptionField<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(props: DescriptionFieldProps<T, S, F>) {\n const { id, description, registry, uiSchema } = props;\n if (!description) {\n return null;\n }\n return (\n <span id={id}>\n <RichDescription description={description} registry={registry} uiSchema={uiSchema} />\n </span>\n );\n}\n", "import type { FieldErrorProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';\nimport { errorId } from '@rjsf/utils';\n\n/** The `FieldErrorTemplate` component renders the errors local to the particular field\n *\n * @param props - The `FieldErrorProps` for the errors being rendered\n */\nexport default function FieldErrorTemplate<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(props: FieldErrorProps<T, S, F>) {\n const { errors = [], fieldPathId } = props;\n if (errors.length === 0) {\n return null;\n }\n const id = errorId(fieldPathId);\n\n return (\n <div id={id}>\n {errors.map((error) => (\n <div key={`field-${id}-error-${error}`}>{error}</div>\n ))}\n </div>\n );\n}\n", "import type { FieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema, GenericObjectType } from '@rjsf/utils';\nimport { getTemplate, getUiOptions } from '@rjsf/utils';\nimport { Form } from 'antd';\n\nconst VERTICAL_LABEL_COL = { span: 24 };\nconst VERTICAL_WRAPPER_COL = { span: 24 };\n\n/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field\n * content, (label, description, children, errors and help) inside of a `WrapIfAdditional` component.\n *\n * @param props - The `FieldTemplateProps` for this component\n */\nexport default function FieldTemplate<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(props: FieldTemplateProps<T, S, F>) {\n const {\n children,\n description,\n displayLabel,\n errors,\n help,\n rawHelp,\n hidden,\n id,\n label,\n rawErrors,\n rawDescription,\n registry,\n required,\n schema,\n uiSchema,\n } = props;\n const { formContext } = registry;\n const {\n colon,\n labelCol = VERTICAL_LABEL_COL,\n wrapperCol = VERTICAL_WRAPPER_COL,\n wrapperStyle,\n descriptionLocation = 'below',\n } = formContext as GenericObjectType;\n\n const uiOptions = getUiOptions<T, S, F>(uiSchema);\n\n const WrapIfAdditionalTemplate = getTemplate<'WrapIfAdditionalTemplate', T, S, F>(\n 'WrapIfAdditionalTemplate',\n registry,\n uiOptions,\n );\n\n if (hidden) {\n return <div className='rjsf-field-hidden'>{children}</div>;\n }\n\n // check to see if there is rawDescription(string) before using description(ReactNode)\n // to prevent showing a blank description area\n const descriptionNode = rawDescription ? description : undefined;\n const descriptionProps: GenericObjectType = {};\n switch (descriptionLocation) {\n case 'tooltip':\n descriptionProps.tooltip = descriptionNode;\n break;\n case 'below':\n default:\n descriptionProps.extra = descriptionNode;\n break;\n }\n const isCheckbox = uiOptions.widget === 'checkbox';\n return (\n <WrapIfAdditionalTemplate {...props}>\n <Form.Item\n colon={colon}\n hasFeedback={schema.type !== 'array' && schema.type !== 'object'}\n help={(!!rawHelp && help) || (rawErrors?.length ? errors : undefined)}\n htmlFor={id}\n label={displayLabel && !isCheckbox && label}\n labelCol={labelCol}\n required={required}\n style={wrapperStyle}\n validateStatus={rawErrors?.length ? 'error' : undefined}\n wrapperCol={wrapperCol}\n {...descriptionProps}\n >\n {children}\n </Form.Item>\n </WrapIfAdditionalTemplate>\n );\n}\n", "import type { GridTemplateProps } from '@rjsf/utils';\nimport { Col, Row } from 'antd';\n\n/** Renders a `GridTemplate` for antd, which is expecting the column sizing information coming in via the\n * extra props provided by the caller, which are spread directly on the `Row`/`Col`.\n *\n * @param props - The GridTemplateProps, including the extra props containing the antd grid positioning details\n */\nexport default function GridTemplate(props: GridTemplateProps) {\n const { children, column, ...rest } = props;\n if (column) {\n return <Col {...rest}>{children}</Col>;\n }\n return <Row {...rest}>{children}</Row>;\n}\n", "import type { MouseEventHandler } from 'react';\nimport {\n ArrowDownOutlined,\n ArrowUpOutlined,\n CopyOutlined,\n DeleteOutlined,\n PlusCircleOutlined,\n CloseOutlined,\n} from '@ant-design/icons';\nimport type { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';\nimport { getUiOptions, TranslatableString } from '@rjsf/utils';\nimport type { ButtonProps } from 'antd';\nimport { Button } from 'antd';\n\nexport type AntdIconButtonProps<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n> = IconButtonProps<T, S, F> & Pick<ButtonProps, 'block' | 'danger' | 'size'>;\n\nexport default function IconButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n props: AntdIconButtonProps<T, S, F>,\n) {\n const { iconType = 'default', icon, onClick, uiSchema, registry, color, ...otherProps } = props;\n return (\n <Button\n onClick={onClick as MouseEventHandler<HTMLAnchorElement> & MouseEventHandler<HTMLButtonElement>}\n // @ts-expect-error TS2322, Because even casting as `ButtonProps['type']` has issues\n type={iconType}\n icon={icon}\n color={color as ButtonProps['color']}\n style={{ paddingTop: '4px' /* Center the button */ }}\n {...otherProps}\n />\n );\n}\n\nexport function AddButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n props: AntdIconButtonProps<T, S, F>,\n) {\n const {\n registry: { translateString },\n } = props;\n return (\n <IconButton\n title={translateString(TranslatableString.AddItemButton)}\n iconType='primary'\n block\n {...props}\n icon={<PlusCircleOutlined />}\n />\n );\n}\n\nexport function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n props: AntdIconButtonProps<T, S, F>,\n) {\n const {\n registry: { translateString },\n } = props;\n return <IconButton title={translateString(TranslatableString.CopyButton)} {...props} icon={<CopyOutlined />} />;\n}\n\nexport function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n props: AntdIconButtonProps<T, S, F>,\n) {\n const {\n registry: { translateString },\n } = props;\n return (\n <IconButton title={translateString(TranslatableString.MoveDownButton)} {...props} icon={<ArrowDownOutlined />} />\n );\n}\n\nexport function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n props: AntdIconButtonProps<T, S, F>,\n) {\n const {\n registry: { translateString },\n } = props;\n return <IconButton title={translateString(TranslatableString.MoveUpButton)} {...props} icon={<ArrowUpOutlined />} />;\n}\n\nexport function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n props: AntdIconButtonProps<T, S, F>,\n) {\n // The `block` prop is not part of the `IconButtonProps` defined in the template, so get it from the uiSchema instead\n const options = getUiOptions<T, S, F>(props.uiSchema);\n const {\n registry: { translateString },\n } = props;\n return (\n <IconButton\n title={translateString(TranslatableString.RemoveButton)}\n danger\n block={!!options.block}\n iconType='primary'\n {...props}\n icon={<DeleteOutlined />}\n />\n );\n}\n\nexport function ClearButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n props: AntdIconButtonProps<T, S, F>,\n) {\n const {\n registry: { translateString },\n } = props;\n return (\n <IconButton\n title={translateString(TranslatableString.ClearButton)}\n {...props}\n iconType='link'\n icon={<CloseOutlined />}\n />\n );\n}\n", "import type { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';\n\nexport default function MultiSchemaFieldTemplate<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(props: MultiSchemaFieldTemplateProps<T, S, F>) {\n const { optionSchemaField, selector } = props;\n\n return (\n <div>\n <div>{selector}</div>\n {optionSchemaField}\n </div>\n );\n}\n", "import { useContext } from 'react';\nimport type {\n FormContextType,\n GenericObjectType,\n ObjectFieldTemplateProps,\n ObjectFieldTemplatePropertyType,\n RJSFSchema,\n StrictRJSFSchema,\n UiSchema,\n} from '@rjsf/utils';\nimport { canExpand, getTemplate, getUiOptions, titleId, buttonId } from '@rjsf/utils';\nimport { Col, Row, ConfigProvider } from 'antd';\nimport classNames from 'classnames';\nimport isNumber from 'lodash/isNumber';\nimport isObject from 'lodash/isObject';\nimport isString from 'lodash/isString';\n\n/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the\n * title and description if available. If the object is expandable, then an `AddButton` is also rendered after all\n * the properties.\n *\n * @param props - The `ObjectFieldTemplateProps` for this component\n */\nexport default function ObjectFieldTemplate<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(props: ObjectFieldTemplateProps<T, S, F>) {\n const {\n disabled,\n formData,\n fieldPathId,\n onAddProperty,\n optionalDataControl,\n properties,\n readonly,\n required,\n registry,\n schema,\n title,\n uiSchema,\n } = props;\n const uiOptions = getUiOptions<T, S, F>(uiSchema);\n const TitleFieldTemplate = getTemplate<'TitleFieldTemplate', T, S, F>('TitleFieldTemplate', registry, uiOptions);\n const { formContext } = registry;\n const showOptionalDataControlInTitle = !readonly && !disabled;\n // Button templates are not overridden in the uiSchema\n const {\n ButtonTemplates: { AddButton },\n } = registry.templates;\n const { colSpan = 24, labelAlign = 'right', rowGutter = 24 } = formContext as GenericObjectType;\n\n const findSchema = (element: ObjectFieldTemplatePropertyType): S => element.content.props.schema;\n\n const findSchemaType = (element: ObjectFieldTemplatePropertyType) => findSchema(element).type;\n\n const findUiSchema = (element: ObjectFieldTemplatePropertyType): UiSchema<T, S, F> | undefined =>\n element.content.props.uiSchema;\n\n const findUiSchemaField = (element: ObjectFieldTemplatePropertyType) => getUiOptions(findUiSchema(element)).field;\n\n const findUiSchemaWidget = (element: ObjectFieldTemplatePropertyType) => getUiOptions(findUiSchema(element)).widget;\n\n const calculateColSpan = (element: ObjectFieldTemplatePropertyType) => {\n const type = findSchemaType(element);\n const field = findUiSchemaField(element);\n const widget = findUiSchemaWidget(element);\n\n const defaultColSpan =\n properties.length < 2 || // Single or no field in object.\n type === 'object' ||\n type === 'array' ||\n widget === 'textarea'\n ? 24\n : 12;\n\n if (isObject(colSpan)) {\n const colSpanObj: GenericObjectType = colSpan;\n if (isString(widget)) {\n return colSpanObj[widget];\n }\n if (isString(field)) {\n return colSpanObj[field];\n }\n if (isString(type)) {\n return colSpanObj[type];\n }\n }\n if (isNumber(colSpan)) {\n return colSpan;\n }\n return defaultColSpan;\n };\n\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('form');\n const labelClsBasic = `${prefixCls}-item-label`;\n const labelColClassName = classNames(\n labelClsBasic,\n labelAlign === 'left' && `${labelClsBasic}-left`,\n // labelCol.className,\n );\n\n return (\n <fieldset id={fieldPathId.$id}>\n <Row gutter={rowGutter}>\n {title && (\n <Col className={labelColClassName} span={24}>\n <TitleFieldTemplate\n id={titleId(fieldPathId)}\n title={title}\n required={required}\n schema={schema}\n uiSchema={uiSchema}\n registry={registry}\n optionalDataControl={showOptionalDataControlInTitle ? optionalDataControl : undefined}\n />\n </Col>\n )}\n {!showOptionalDataControlInTitle ? <Col span={24}>{optionalDataControl}</Col> : undefined}\n {properties\n .filter((e) => !e.hidden)\n .map((element: ObjectFieldTemplatePropertyType) => (\n <Col key={element.name} span={calculateColSpan(element)}>\n {element.content}\n </Col>\n ))}\n </Row>\n {canExpand(schema, uiSchema, formData) && (\n <Col span={24}>\n <Row gutter={rowGutter} justify='end'>\n <Col flex='120px'>\n <AddButton\n id={buttonId(fieldPathId, 'add')}\n className='rjsf-object-property-expand'\n disabled={disabled || readonly}\n onClick={onAddProperty}\n uiSchema={uiSchema}\n registry={registry}\n />\n </Col>\n </Row>\n </Col>\n )}\n </fieldset>\n );\n}\n", "import type { FormContextType, OptionalDataControlsTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';\n\nimport { AddButton, RemoveButton } from '../IconButton';\n\n/** The OptionalDataControlsTemplate renders one of three different states. If\n * there is an `onAddClick()` function, it renders the \"Add\" button. If there is\n * an `onRemoveClick()` function, it renders the \"Remove\" button. Otherwise it\n * renders the \"No data found\" section. All of them use the `label` as either\n * the `title` of buttons or simply outputting it.\n *\n * @param props - The `OptionalDataControlsTemplateProps` for the template\n */\nexport default function OptionalDataControlsTemplate<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(props: OptionalDataControlsTemplateProps<T, S, F>) {\n const { id, registry, label, onAddClick, onRemoveClick } = props;\n if (onAddClick) {\n return (\n <AddButton\n id={id}\n registry={registry}\n className='rjsf-add-optional-data'\n onClick={onAddClick}\n title={label}\n size='small'\n iconType='default'\n block={false}\n />\n );\n }\n if (onRemoveClick) {\n return (\n <RemoveButton\n id={id}\n registry={registry}\n className='rjsf-remove-optional-data'\n onClick={onRemoveClick}\n title={label}\n size='small'\n iconType='default'\n block={false}\n />\n );\n }\n return <em id={id}>{label}</em>;\n}\n", "import type { FormContextType, RJSFSchema, StrictRJSFSchema, SubmitButtonProps } from '@rjsf/utils';\nimport { getSubmitButtonOptions } from '@rjsf/utils';\nimport type { ButtonProps } from 'antd';\nimport { Button } from 'antd';\n\ntype ButtonType = NonNullable<ButtonProps['type']>;\n\n/** The `SubmitButton` renders a button that represent the `Submit` action on a form\n */\nexport default function SubmitButton<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>({ uiSchema }: SubmitButtonProps<T, S, F>) {\n const { submitText, norender, props: submitButtonProps } = getSubmitButtonOptions(uiSchema);\n if (norender) {\n return null;\n }\n return (\n <Button type={'submit' as ButtonType} {...submitButtonProps} htmlType='submit'>\n {submitText}\n </Button>\n );\n}\n", "import { useContext } from 'react';\nimport type { FormContextType, TitleFieldProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';\nimport { Col, Divider, Row, ConfigProvider } from 'antd';\nimport classNames from 'classnames';\n\n/** The `TitleField` is the template to use to render the title of a field\n *\n * @param props - The `TitleFieldProps` for this component\n */\nexport default function TitleField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({\n id,\n required,\n registry,\n title,\n optionalDataControl,\n}: TitleFieldProps<T, S, F>) {\n const { formContext } = registry;\n const { colon = true } = formContext;\n\n let labelChildren = title;\n if (colon && typeof title === 'string' && title.trim() !== '') {\n labelChildren = title.replace(/[\uFF1A:]\\s*$/, '');\n }\n\n const handleLabelClick = () => {\n if (!id) {\n return;\n }\n\n const control: HTMLLabelElement | null = document.querySelector(`[id=\"${id}\"]`);\n if (control && control.focus) {\n control.focus();\n }\n };\n\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('form');\n const labelClassName = classNames({\n [`${prefixCls}-item-required`]: required,\n [`${prefixCls}-item-no-colon`]: !colon,\n });\n // The antd theme, for some reason, made its labels cause the associated field to get the focus when clicked (which\n // kinda breaks a11y), but since it's built that way we will honor it until we decided to break it in a major release\n // oxlint-disable jsx-a11y/no-noninteractive-element-interactions -- <label> is interactive; oxlint incorrectly flags it\n let heading = title ? (\n <label\n className={labelClassName}\n htmlFor={id}\n onClick={handleLabelClick}\n onKeyDown={(e) => (e.key === 'Enter' || e.key === ' ') && handleLabelClick()}\n title={typeof title === 'string' ? title : ''}\n >\n {labelChildren}\n </label>\n ) : null;\n if (optionalDataControl) {\n heading = (\n <Row>\n <Col flex='auto'>{heading}</Col>\n <Col flex='none'>{optionalDataControl}</Col>\n </Row>\n );\n }\n\n return (\n <>\n {heading}\n <Divider size='small' style={{ marginBlock: '1px' /* pull the margin right up against the label */ }} />\n </>\n );\n}\n", "import type { FormContextType, RJSFSchema, StrictRJSFSchema, WrapIfAdditionalTemplateProps } from '@rjsf/utils';\nimport { ADDITIONAL_PROPERTY_FLAG, UI_OPTIONS_KEY, TranslatableString, buttonId } from '@rjsf/utils';\nimport { Col, Row, Form, Input } from 'antd';\n\nconst VERTICAL_LABEL_COL = { span: 24 };\nconst VERTICAL_WRAPPER_COL = { span: 24 };\n\nconst INPUT_STYLE = {\n width: '100%',\n};\n\n/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are\n * part of an `additionalProperties` part of a schema.\n *\n * @param props - The `WrapIfAdditionalProps` for this component\n */\nexport default function WrapIfAdditionalTemplate<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(props: WrapIfAdditionalTemplateProps<T, S, F>) {\n const {\n children,\n classNames,\n style,\n disabled,\n displayLabel,\n id,\n label,\n onRemoveProperty,\n onKeyRenameBlur,\n readonly,\n required,\n registry,\n schema,\n uiSchema,\n } = props;\n const {\n colon,\n labelCol = VERTICAL_LABEL_COL,\n readonlyAsDisabled = true,\n rowGutter = 24,\n toolbarAlign = 'top',\n wrapperCol = VERTICAL_WRAPPER_COL,\n wrapperStyle,\n } = registry.formContext;\n const { templates, translateString } = registry;\n // Button templates are not overridden in the uiSchema\n const { RemoveButton } = templates.ButtonTemplates;\n const keyLabel = translateString(TranslatableString.KeyLabel, [label]);\n const additional = ADDITIONAL_PROPERTY_FLAG in schema;\n\n if (!additional) {\n return (\n <div className={classNames} style={style}>\n {children}\n </div>\n );\n }\n\n // The `block` prop is not part of the `IconButtonProps` defined in the template, so put it into the uiSchema instead\n const uiOptions = uiSchema ? uiSchema[UI_OPTIONS_KEY] : {};\n const buttonUiOptions = {\n ...uiSchema,\n [UI_OPTIONS_KEY]: { ...uiOptions, block: true },\n };\n\n return (\n <div className={classNames} style={style}>\n <Row align={toolbarAlign} gutter={rowGutter}>\n <Col className='form-additional' flex='1'>\n <div className='form-group'>\n <Form.Item\n colon={colon}\n className='form-group'\n hasFeedback\n htmlFor={`${id}-key`}\n label={displayLabel ? keyLabel : undefined}\n labelCol={labelCol}\n required={required}\n style={wrapperStyle}\n wrapperCol={wrapperCol}\n >\n <Input\n key={label}\n className='form-control'\n defaultValue={label}\n disabled={disabled || (readonlyAsDisabled && readonly)}\n id={`${id}-key`}\n name={`${id}-key`}\n onBlur={!readonly ? onKeyRenameBlur : undefined}\n style={INPUT_STYLE}\n type='text'\n />\n </Form.Item>\n </div>\n </Col>\n <Col className='form-additional' flex='1'>\n {children}\n </Col>\n <Col flex='120px' style={{ marginTop: displayLabel ? '40px' : undefined }}>\n <RemoveButton\n id={buttonId(id, 'remove')}\n className='rjsf-object-property-remove'\n disabled={disabled || readonly}\n onClick={onRemoveProperty}\n uiSchema={buttonUiOptions}\n registry={registry}\n />\n </Col>\n </Row>\n </div>\n );\n}\n", "import type { FormContextType, RJSFSchema, StrictRJSFSchema, TemplatesType } from '@rjsf/utils';\n\nimport ArrayFieldItemTemplate from './ArrayFieldItemTemplate';\nimport ArrayFieldTemplate from './ArrayFieldTemplate';\nimport BaseInputTemplate from './BaseInputTemplate';\nimport ErrorList from './ErrorList';\nimport DescriptionField from './FieldDescriptionTemplate';\nimport FieldErrorTemplate from './FieldErrorTemplate';\nimport FieldTemplate from './FieldTemplate';\nimport GridTemplate from './GridTemplate';\nimport { AddButton, CopyButton, MoveDownButton, MoveUpButton, RemoveButton, ClearButton } from './IconButton';\nimport MultiSchemaFieldTemplate from './MultiSchemaFieldTemplate';\nimport ObjectFieldTemplate from './ObjectFieldTemplate';\nimport OptionalDataControlsTemplate from './OptionalDataControlsTemplate';\nimport SubmitButton from './SubmitButton';\nimport TitleField from './TitleField';\nimport WrapIfAdditionalTemplate from './WrapIfAdditionalTemplate';\n\nexport function generateTemplates<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(): Partial<TemplatesType<T, S, F>> {\n return {\n ArrayFieldItemTemplate,\n ArrayFieldTemplate,\n BaseInputTemplate,\n ButtonTemplates: {\n AddButton,\n CopyButton,\n MoveDownButton,\n MoveUpButton,\n RemoveButton,\n SubmitButton,\n ClearButton,\n },\n DescriptionFieldTemplate: DescriptionField,\n ErrorListTemplate: ErrorList,\n FieldErrorTemplate,\n FieldTemplate,\n GridTemplate,\n MultiSchemaFieldTemplate,\n ObjectFieldTemplate,\n OptionalDataControlsTemplate,\n TitleFieldTemplate: TitleField,\n WrapIfAdditionalTemplate,\n };\n}\n\nexport default generateTemplates();\n", "import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';\n\nexport default function AltDateTimeWidget<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>({ time = true, ...props }: WidgetProps<T, S, F>) {\n const { AltDateWidget } = props.registry.widgets;\n return <AltDateWidget time={time} {...props} />;\n}\n", "import type { FormContextType, GenericObjectType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';\nimport { DateElement, TranslatableString, useAltDateWidgetProps } from '@rjsf/utils';\nimport { Row, Col, Button } from 'antd';\n\nexport default function AltDateWidget<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>({ autofocus = false, disabled = false, options, readonly = false, time = false, ...props }: WidgetProps<T, S, F>) {\n const { id, name, onBlur, onFocus, registry } = props;\n const { formContext, translateString } = registry;\n const { rowGutter = 24 } = formContext as GenericObjectType;\n const realOptions = { yearsRange: [1900, new Date().getFullYear() + 2], ...options };\n const { elements, handleChange, handleClear, handleSetNow } = useAltDateWidgetProps({\n ...props,\n autofocus,\n options: realOptions,\n });\n\n return (\n <Row gutter={[Math.floor(rowGutter / 2), Math.floor(rowGutter / 2)]}>\n {elements.map((elemProps, i) => {\n const elemId = `${id}_${elemProps.type}`;\n return (\n <Col flex='88px' key={elemId}>\n <DateElement\n rootId={id}\n name={name}\n select={handleChange}\n {...elemProps}\n disabled={disabled}\n readonly={readonly}\n registry={registry}\n onBlur={onBlur}\n onFocus={onFocus}\n autofocus={autofocus && i === 0}\n />\n </Col>\n );\n })}\n {!options.hideNowButton && (\n <Col flex='88px'>\n <Button block className='btn-now' onClick={handleSetNow} type='primary'>\n {translateString(TranslatableString.NowLabel)}\n </Button>\n </Col>\n )}\n {!options.hideClearButton && (\n <Col flex='88px'>\n <Button block className='btn-clear' danger onClick={handleClear} type='primary'>\n {translateString(TranslatableString.ClearLabel)}\n </Button>\n </Col>\n )}\n </Row>\n );\n}\n", "import type { FocusEvent } from 'react';\nimport type { FormContextType, WidgetProps, RJSFSchema, StrictRJSFSchema, GenericObjectType } from '@rjsf/utils';\nimport {\n ariaDescribedByIds,\n enumOptionSelectedValue,\n enumOptionValueDecoder,\n enumOptionValueEncoder,\n getOptionValueFormat,\n optionId,\n} from '@rjsf/utils';\nimport { Checkbox } from 'antd';\n\n/** The `CheckboxesWidget` is a widget for rendering checkbox groups.\n * It is typically used to represent an array of enums.\n *\n * @param props - The `WidgetProps` for this component\n */\nexport default function CheckboxesWidget<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>({\n autofocus,\n disabled,\n registry,\n id,\n htmlName,\n onBlur,\n onChange,\n onFocus,\n options,\n readonly,\n value,\n}: WidgetProps<T, S, F>) {\n const { formContext } = registry;\n const { readonlyAsDisabled = true } = formContext as GenericObjectType;\n\n const { enumOptions, enumDisabled, inline, emptyValue } = options;\n const optionValueFormat = getOptionValueFormat(options);\n\n const handleChange = (nextValue: any) =>\n onChange(enumOptionValueDecoder<S>(nextValue, enumOptions, optionValueFormat, emptyValue));\n\n const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) =>\n onBlur(id, enumOptionValueDecoder<S>(target.value, enumOptions, optionValueFormat, emptyValue));\n\n const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) =>\n onFocus(id, enumOptionValueDecoder<S>(target.value, enumOptions, optionValueFormat, emptyValue));\n\n // Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,\n // they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors\n const extraProps = {\n id,\n onBlur: !readonly ? handleBlur : undefined,\n onFocus: !readonly ? handleFocus : undefined,\n };\n\n const selectValue = enumOptionSelectedValue<S>(value, enumOptions, true, optionValueFormat, []) as string[];\n\n return Array.isArray(enumOptions) && enumOptions.length > 0 ? (\n <Checkbox.Group\n disabled={disabled || (readonlyAsDisabled && readonly)}\n name={htmlName || id}\n onChange={!readonly ? handleChange : undefined}\n value={selectValue}\n {...extraProps}\n aria-describedby={ariaDescribedByIds(id)}\n >\n {Array.isArray(enumOptions) &&\n enumOptions.map((option, i) => (\n // oxlint-disable-next-line react/no-array-index-key\n <span key={i}>\n <Checkbox\n id={optionId(id, i)}\n name={htmlName || id}\n autoFocus={i === 0 ? autofocus : false}\n disabled={Array.isArray(enumDisabled) && enumDisabled.includes(option.value)}\n value={enumOptionValueEncoder(option.value, i, optionValueFormat)}\n >\n {option.label}\n </Checkbox>\n {!inline && <br />}\n </span>\n ))}\n </Checkbox.Group>\n ) : null;\n}\n", "import type { FocusEvent } from 'react';\nimport type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps, GenericObjectType } from '@rjsf/utils';\nimport { ariaDescribedByIds, labelValue } from '@rjsf/utils';\nimport type { CheckboxProps } from 'antd';\nimport { Checkbox } from 'antd';\n\n/** The `CheckBoxWidget` is a widget for rendering boolean properties.\n * It is typically used to represent a boolean.\n *\n * @param props - The `WidgetProps` for this component\n */\nexport default function CheckboxWidget<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(props: WidgetProps<T, S, F>) {\n const { autofocus, disabled, registry, id, htmlName, label, hideLabel, onBlur, onChange, onFocus, readonly, value } =\n props;\n const { formContext } = registry;\n const { readonlyAsDisabled = true } = formContext as GenericObjectType;\n\n const handleChange: NonNullable<CheckboxProps['onChange']> = ({ target }) => onChange(target.checked);\n\n const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.checked);\n\n const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.checked);\n\n // Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,\n // they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors\n const extraProps = {\n onBlur: !readonly ? handleBlur : undefined,\n onFocus: !readonly ? handleFocus : undefined,\n };\n return (\n <Checkbox\n autoFocus={autofocus}\n checked={typeof value === 'undefined' ? false : value}\n disabled={disabled || (readonlyAsDisabled && readonly)}\n id={id}\n name={htmlName || id}\n onChange={!readonly ? handleChange : undefined}\n {...extraProps}\n aria-describedby={ariaDescribedByIds(id)}\n >\n {labelValue(label, hideLabel, '')}\n </Checkbox>\n );\n}\n", "import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps, GenericObjectType } from '@rjsf/utils';\nimport { ariaDescribedByIds } from '@rjsf/utils';\nimport { DatePicker } from 'antd';\nimport dayjs from 'dayjs';\n\nconst DATE_PICKER_STYLE = {\n width: '100%',\n};\n\ntype DateWidgetProps<T, S extends StrictRJSFSchema, F extends FormContextType> = WidgetProps<T, S, F> & {\n showTime?: boolean;\n};\n\n/** The `DateWidget` component uses the `BaseInputTemplate` changing the type to `date` and transforms\n * the value to undefined when it is falsy during the `onChange` handling.\n *\n * @param props - The `WidgetProps` for this component\n */\nexport default function DateWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({\n disabled,\n registry,\n id,\n onBlur,\n onChange,\n onFocus,\n placeholder,\n readonly,\n value,\n showTime = false,\n}: DateWidgetProps<T, S, F>) {\n const { formContext } = registry;\n const { readonlyAsDisabled = true } = formContext as GenericObjectType;\n\n const handleChange = (nextValue: any) =>\n onChange(nextValue && (showTime ? nextValue.toISOString() : nextValue.format('YYYY-MM-DD')));\n\n const handleBlur = () => onBlur(id, value);\n\n const handleFocus = () => onFocus(id, value);\n\n const getPopupContainer = DateWidget.getPopupContainerCallback();\n\n return (\n <DatePicker\n disabled={disabled || (readonlyAsDisabled && readonly)}\n getPopupContainer={getPopupContainer}\n id={id}\n name={id}\n onBlur={!readonly ? handleBlur : undefined}\n onChange={!readonly ? handleChange : undefined}\n onFocus={!readonly ? handleFocus : undefined}\n placeholder={placeholder}\n showTime={showTime}\n style={DATE_PICKER_STYLE}\n value={value && dayjs(value)}\n aria-describedby={ariaDescribedByIds(id)}\n />\n );\n}\n\n/** Give the playground a place to hook into the `getPopupContainer` callback generation function so that it can be\n * disabled while in the playground. Since the callback is a simple function, it can be returned by this static\n * \"generator\" function.\n */\nDateWidget.getPopupContainerCallback = () => (node: any) => node.parentNode;\n", "import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';\n\nimport DateWidget from '../DateWidget';\n\n/** The `DateTimeWidget` component uses the `DateWidget` with `showTime` enabled, transforming\n * the value to/from ISO string format.\n *\n * @param props - The `WidgetProps` for this component\n */\nexport default function DateTimeWidget<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(props: WidgetProps<T, S, F>) {\n return <DateWidget showTime {...props} />;\n}\n", "import type { ChangeEvent, FocusEvent } from 'react';\nimport type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps, GenericObjectType } from '@rjsf/utils';\nimport { ariaDescribedByIds } from '@rjsf/utils';\nimport { Input } from 'antd';\n\n/** The `PasswordWidget` component uses the `BaseInputTemplate` changing the type to `password`.\n *\n * @param props - The `WidgetProps` for this component\n */\nexport default function PasswordWidget<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(props: WidgetProps<T, S, F>) {\n const { disabled, registry, id, onBlur, onChange, onFocus, options, placeholder, readonly, value } = props;\n const { formContext } = registry;\n const { readonlyAsDisabled = true } = formContext as GenericObjectType;\n\n const emptyValue = options.emptyValue || '';\n\n const handleChange = ({ target }: ChangeEvent<HTMLInputElement>) =>\n onChange(target.value === '' ? emptyValue : target.value);\n\n const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target.value);\n\n const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target.value);\n\n return (\n <Input.Password\n disabled={disabled || (readonlyAsDisabled && readonly)}\n id={id}\n name={id}\n onBlur={!readonly ? handleBlur : undefined}\n onChange={!readonly ? handleChange : undefined}\n onFocus={!readonly ? handleFocus : undefined}\n placeholder={placeholder}\n value={value || ''}\n aria-describedby={ariaDescribedByIds(id)}\n />\n );\n}\n", "import type { FocusEvent } fr