Skip to content

Commit

Permalink
Merge branch 'main' into fixes/antd-enum-disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
KingMario authored Jun 24, 2024
2 parents d1a8610 + f8378c4 commit 323ddb1
Show file tree
Hide file tree
Showing 53 changed files with 253 additions and 152 deletions.
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,49 @@ should change the heading of the (upcoming) version to include a major version b
## @rjsf/antd

- Fix disabled property of options in CheckboxesWidget and RadioWidgep ([#4216](https://github.com/rjsf-team/react-jsonschema-form/pull/4216))
- Updated widgets to handle undefined `target` in `onFocus` and `onBlur` handlers

## @rfsf/bootstrap4

- Updated widgets to handle undefined `target` in `onFocus` and `onBlur` handlers

## @rfsf/chakra-ui

- Updated widgets to handle undefined `target` in `onFocus` and `onBlur` handlers

## @rjsf/core

- Fix case where NumberField would not properly reset the field when using programmatic form reset (#4202)[https://github.com/rjsf-team/react-jsonschema-form/issues/4202]
- Updated widgets to handle undefined `target` in `onFocus` and `onBlur` handlers

## @rfsf/fluent-ui

- Updated widgets to handle undefined `target` in `onFocus` and `onBlur` handlers

## @rfsf/fluentui-rc

- Updated widgets to handle undefined `target` in `onFocus` and `onBlur` handlers

## @rfsf/material-ui

- Updated widgets to handle undefined `target` in `onFocus` and `onBlur` handlers

## @rfsf/mui

- Updated widgets to handle undefined `target` in `onFocus` and `onBlur` handlers

## @rfsf/semantic-ui

- Updated widgets to handle undefined `target` in `onFocus` and `onBlur` handlers


## @rjsf/validator-ajv6

- Improved performance issues with large schema dependencies and oneOf conditions [#4203](https://github.com/rjsf-team/react-jsonschema-form/issues/4203).

## @rjsf/validator-ajv8

- Improved performance issues with large schema dependencies and oneOf conditions [#4203](https://github.com/rjsf-team/react-jsonschema-form/issues/4203).

# 5.18.4

Expand Down
26 changes: 13 additions & 13 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions packages/antd/src/templates/BaseInputTemplate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export default function BaseInputTemplate<
? onChangeOverride
: ({ target }: ChangeEvent<HTMLInputElement>) => onChange(target.value === '' ? options.emptyValue : target.value);

const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target.value);
const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);

const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target.value);
const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);

const input =
inputProps.type === 'number' || inputProps.type === 'integer' ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function WrapIfAdditionalTemplate<
);
}

const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) => onKeyChange(target.value);
const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) => onKeyChange(target && target.value);

// The `block` prop is not part of the `IconButtonProps` defined in the template, so put it into the uiSchema instead
const uiOptions = uiSchema ? uiSchema[UI_OPTIONS_KEY] : {};
Expand Down
4 changes: 2 additions & 2 deletions packages/antd/src/widgets/CheckboxWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export default function CheckboxWidget<

const handleChange: NonNullable<CheckboxProps['onChange']> = ({ target }) => onChange(target.checked);

const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target.checked);
const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.checked);

const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target.checked);
const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.checked);

// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
Expand Down
4 changes: 2 additions & 2 deletions packages/antd/src/widgets/RadioWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
onChange(enumOptionsValueForIndex<S>(nextValue, enumOptions, emptyValue));

const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
onBlur(id, enumOptionsValueForIndex<S>(target.value, enumOptions, emptyValue));
onBlur(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));

const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
onFocus(id, enumOptionsValueForIndex<S>(target.value, enumOptions, emptyValue));
onFocus(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));

const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions) as string;

Expand Down
4 changes: 2 additions & 2 deletions packages/antd/src/widgets/TextareaWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export default function TextareaWidget<
const handleChange = ({ target }: ChangeEvent<HTMLTextAreaElement>) =>
onChange(target.value === '' ? options.emptyValue : target.value);

const handleBlur = ({ target }: FocusEvent<HTMLTextAreaElement>) => onBlur(id, target.value);
const handleBlur = ({ target }: FocusEvent<HTMLTextAreaElement>) => onBlur(id, target && target.value);

const handleFocus = ({ target }: FocusEvent<HTMLTextAreaElement>) => onFocus(id, target.value);
const handleFocus = ({ target }: FocusEvent<HTMLTextAreaElement>) => onFocus(id, target && target.value);

// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export default function BaseInputTemplate<
};
const _onChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
onChange(value === '' ? options.emptyValue : value);
const _onBlur = ({ target: { value } }: FocusEvent<HTMLInputElement>) => onBlur(id, value);
const _onFocus = ({ target: { value } }: FocusEvent<HTMLInputElement>) => onFocus(id, value);
const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);

// const classNames = [rawErrors.length > 0 ? "is-invalid" : "", type === 'file' ? 'custom-file-label': ""]
return (
Expand Down
4 changes: 2 additions & 2 deletions packages/bootstrap-4/src/CheckboxWidget/CheckboxWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export default function CheckboxWidget<
);

const _onChange = ({ target: { checked } }: FocusEvent<HTMLInputElement>) => onChange(checked);
const _onBlur = ({ target: { checked } }: FocusEvent<HTMLInputElement>) => onBlur(id, checked);
const _onFocus = ({ target: { checked } }: FocusEvent<HTMLInputElement>) => onFocus(id, checked);
const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.checked);
const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.checked);

const description = options.description || schema.description;
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export default function CheckboxesWidget<
}
};

const _onBlur = ({ target: { value } }: FocusEvent<HTMLInputElement>) =>
onBlur(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue));
const _onFocus = ({ target: { value } }: FocusEvent<HTMLInputElement>) =>
onFocus(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue));
const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
onBlur(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));
const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
onFocus(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));

return (
<Form.Group>
Expand Down
8 changes: 4 additions & 4 deletions packages/bootstrap-4/src/RadioWidget/RadioWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc

const _onChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
onChange(enumOptionsValueForIndex<S>(value, enumOptions, emptyValue));
const _onBlur = ({ target: { value } }: FocusEvent<HTMLInputElement>) =>
onBlur(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue));
const _onFocus = ({ target: { value } }: FocusEvent<HTMLInputElement>) =>
onFocus(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue));
const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
onBlur(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));
const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
onFocus(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));

const inline = Boolean(options && options.inline);

Expand Down
4 changes: 2 additions & 2 deletions packages/bootstrap-4/src/TextareaWidget/TextareaWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export default function TextareaWidget<
}: CustomWidgetProps<T, S, F>) {
const _onChange = ({ target: { value } }: ChangeEvent<HTMLTextAreaElement>) =>
onChange(value === '' ? options.emptyValue : value);
const _onBlur = ({ target: { value } }: FocusEvent<HTMLTextAreaElement>) => onBlur(id, value);
const _onFocus = ({ target: { value } }: FocusEvent<HTMLTextAreaElement>) => onFocus(id, value);
const _onBlur = ({ target }: FocusEvent<HTMLTextAreaElement>) => onBlur(id, target && target.value);
const _onFocus = ({ target }: FocusEvent<HTMLTextAreaElement>) => onFocus(id, target && target.value);

return (
<InputGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export default function BaseInputTemplate<

const _onChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
onChange(value === '' ? options.emptyValue : value);
const _onBlur = ({ target: { value } }: FocusEvent<HTMLInputElement>) => onBlur(id, value);
const _onFocus = ({ target: { value } }: FocusEvent<HTMLInputElement>) => onFocus(id, value);
const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);

return (
<FormControl
Expand Down
4 changes: 2 additions & 2 deletions packages/chakra-ui/src/CheckboxWidget/CheckboxWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export default function CheckboxWidget<
const description = options.description || schema.description;

const _onChange = ({ target: { checked } }: ChangeEvent<HTMLInputElement>) => onChange(checked);
const _onBlur = ({ target: { value } }: FocusEvent<HTMLInputElement | any>) => onBlur(id, value);
const _onFocus = ({ target: { value } }: FocusEvent<HTMLInputElement | any>) => onFocus(id, value);
const _onBlur = ({ target }: FocusEvent<HTMLInputElement | any>) => onBlur(id, target && target.value);
const _onFocus = ({ target }: FocusEvent<HTMLInputElement | any>) => onFocus(id, target && target.value);

return (
<FormControl mb={1} {...chakraProps} isRequired={required}>
Expand Down
8 changes: 4 additions & 4 deletions packages/chakra-ui/src/CheckboxesWidget/CheckboxesWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export default function CheckboxesWidget<
const chakraProps = getChakra({ uiSchema });
const checkboxesValues = Array.isArray(value) ? value : [value];

const _onBlur = ({ target: { value } }: FocusEvent<HTMLInputElement | any>) =>
onBlur(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue));
const _onFocus = ({ target: { value } }: FocusEvent<HTMLInputElement | any>) =>
onFocus(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue));
const _onBlur = ({ target }: FocusEvent<HTMLInputElement | any>) =>
onBlur(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));
const _onFocus = ({ target }: FocusEvent<HTMLInputElement | any>) =>
onFocus(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));

const row = options ? options.inline : false;
const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions, true) as string[];
Expand Down
4 changes: 2 additions & 2 deletions packages/chakra-ui/src/RangeWidget/RangeWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSc
const sliderWidgetProps = { value, label, id, ...rangeSpec<S>(schema) };

const _onChange = (value: undefined | number) => onChange(value === undefined ? options.emptyValue : value);
const _onBlur = ({ target: { value } }: FocusEvent<HTMLInputElement>) => onBlur(id, value);
const _onFocus = ({ target: { value } }: FocusEvent<HTMLInputElement>) => onFocus(id, value);
const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);

return (
<FormControl mb={1} {...chakraProps}>
Expand Down
8 changes: 4 additions & 4 deletions packages/chakra-ui/src/SelectWidget/SelectWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFS
return onChange(enumOptionsValueForIndex<S>(e.value, enumOptions, emptyValue));
};

const _onBlur = ({ target: { value } }: FocusEvent<HTMLInputElement>) =>
onBlur(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue));
const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
onBlur(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));

const _onFocus = ({ target: { value } }: FocusEvent<HTMLInputElement>) =>
onFocus(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue));
const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
onFocus(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue));

const _valueLabelMap: any = {};
const displayEnumOptions: OptionsOrGroups<any, any> = Array.isArray(enumOptions)
Expand Down
4 changes: 2 additions & 2 deletions packages/chakra-ui/src/TextareaWidget/TextareaWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export default function TextareaWidget<

const _onChange = ({ target: { value } }: ChangeEvent<HTMLTextAreaElement>) =>
onChange(value === '' ? options.emptyValue : value);
const _onBlur = ({ target: { value } }: FocusEvent<HTMLTextAreaElement>) => onBlur(id, value);
const _onFocus = ({ target: { value } }: FocusEvent<HTMLTextAreaElement>) => onFocus(id, value);
const _onBlur = ({ target }: FocusEvent<HTMLTextAreaElement>) => onBlur(id, target && target.value);
const _onFocus = ({ target }: FocusEvent<HTMLTextAreaElement>) => onFocus(id, target && target.value);

return (
<FormControl
Expand Down
4 changes: 2 additions & 2 deletions packages/chakra-ui/src/UpDownWidget/UpDownWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export default function UpDownWidget<T = any, S extends StrictRJSFSchema = RJSFS
const chakraProps = getChakra({ uiSchema });

const _onChange = (value: string | number) => onChange(value);
const _onBlur = ({ target: { value } }: FocusEvent<HTMLInputElement | any>) => onBlur(id, value);
const _onFocus = ({ target: { value } }: FocusEvent<HTMLInputElement | any>) => onFocus(id, value);
const _onBlur = ({ target }: FocusEvent<HTMLInputElement | any>) => onBlur(id, target && target.value);
const _onFocus = ({ target }: FocusEvent<HTMLInputElement | any>) => onFocus(id, target && target.value);

return (
<FormControl
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/fields/NumberField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function NumberField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
// Construct a regular expression that checks for a string that consists
// of the formData value suffixed with zero or one '.' characters and zero
// or more '0' characters
const re = new RegExp(`${value}`.replace('.', '\\.') + '\\.?0*$');
const re = new RegExp(`^(${String(value).replace('.', '\\.')})?\\.?0*$`);

// If the cached "lastValue" is a match, use that instead of the formData
// value to prevent the input value from changing in the UI
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/components/templates/BaseInputTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ export default function BaseInputTemplate<
({ target: { value } }: ChangeEvent<HTMLInputElement>) => onChange(value === '' ? options.emptyValue : value),
[onChange, options]
);
const _onBlur = useCallback(({ target: { value } }: FocusEvent<HTMLInputElement>) => onBlur(id, value), [onBlur, id]);
const _onBlur = useCallback(
({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value),
[onBlur, id]
);
const _onFocus = useCallback(
({ target: { value } }: FocusEvent<HTMLInputElement>) => onFocus(id, value),
({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value),
[onFocus, id]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function WrapIfAdditionalTemplate<
className='form-control'
type='text'
id={`${id}-key`}
onBlur={(event) => onKeyChange(event.target.value)}
onBlur={({ target }) => onKeyChange(target && target.value)}
defaultValue={label}
/>
</div>
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/components/widgets/CheckboxesWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ function CheckboxesWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
const checkboxesValues = Array.isArray(value) ? value : [value];

const handleBlur = useCallback(
({ target: { value } }: FocusEvent<HTMLInputElement>) =>
onBlur(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue)),
({ target }: FocusEvent<HTMLInputElement>) =>
onBlur(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue)),
[onBlur, id]
);

const handleFocus = useCallback(
({ target: { value } }: FocusEvent<HTMLInputElement>) =>
onFocus(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue)),
({ target }: FocusEvent<HTMLInputElement>) =>
onFocus(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue)),
[onFocus, id]
);
return (
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/components/widgets/RadioWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
const { enumOptions, enumDisabled, inline, emptyValue } = options;

const handleBlur = useCallback(
({ target: { value } }: FocusEvent<HTMLInputElement>) =>
onBlur(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue)),
({ target }: FocusEvent<HTMLInputElement>) =>
onBlur(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue)),
[onBlur, id]
);

const handleFocus = useCallback(
({ target: { value } }: FocusEvent<HTMLInputElement>) =>
onFocus(id, enumOptionsValueForIndex<S>(value, enumOptions, emptyValue)),
({ target }: FocusEvent<HTMLInputElement>) =>
onFocus(id, enumOptionsValueForIndex<S>(target && target.value, enumOptions, emptyValue)),
[onFocus, id]
);

Expand Down
Loading

0 comments on commit 323ddb1

Please sign in to comment.