Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade @fluentui/react to 8.x version #3546

Merged
merged 6 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ should change the heading of the (upcoming) version to include a major version b
## @rjsf/fluent-ui

- Added support for `additionalProperties` to fluent-ui theme, fixing [#2777](https://github.com/rjsf-team/react-jsonschema-form/issues/2777).
- Upgraded to `8.x` version of `@fluentui/react`, fixing [#3463](https://github.com/rjsf-team/react-jsonschema-form/issues/3463)

## @rjsf/utils

Expand Down
951 changes: 516 additions & 435 deletions packages/fluent-ui/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/fluent-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"node": ">=14"
},
"peerDependencies": {
"@fluentui/react": "^7.190.3",
"@fluentui/react": ">= 7",
"@rjsf/core": "5.6.x",
"@rjsf/utils": "5.6.x",
"react": "^16.14.0 || >=17"
Expand All @@ -40,7 +40,7 @@
"@babel/plugin-transform-modules-commonjs": "^7.21.2",
"@babel/preset-env": "^7.21.4",
"@babel/preset-react": "^7.18.6",
"@fluentui/react": "^7.204.0",
"@fluentui/react": "^8.1.0",
"@rjsf/core": "^5.6.2",
"@rjsf/utils": "^5.6.2",
"@rjsf/validator-ajv8": "^5.6.2",
Expand Down
21 changes: 15 additions & 6 deletions packages/fluent-ui/src/CheckboxWidget/CheckboxWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FocusEvent, useCallback } from 'react';
import { Checkbox } from '@fluentui/react';
import { Checkbox, ICheckboxProps } from '@fluentui/react';
import {
ariaDescribedByIds,
descriptionId,
Expand All @@ -13,7 +13,7 @@ import {
import _pick from 'lodash/pick';

// Keys of ICheckboxProps from @fluentui/react
export const allowedProps = [
export const allowedProps: (keyof ICheckboxProps)[] = [
'ariaDescribedBy',
'ariaLabel',
'ariaPositionInSet',
Expand All @@ -28,7 +28,8 @@ export const allowedProps = [
'disabled',
'indeterminate',
'inputProps',
'keytipProps',
/* Backward compatibility with fluentui v7 */
'keytipProps' as any,
'label',
'onChange',
'onRenderLabel',
Expand Down Expand Up @@ -93,13 +94,21 @@ export default function CheckboxWidget<
name={id}
label={labelValue(label || undefined, hideLabel)}
disabled={disabled || readonly}
autoFocus={autofocus}
onBlur={_onBlur}
onFocus={_onFocus}
inputProps={{
autoFocus: autofocus,
onBlur: _onBlur,
onFocus: _onFocus,
}}
checked={typeof value === 'undefined' ? false : value}
onChange={_onChange}
{...uiProps}
aria-describedby={ariaDescribedByIds<T>(id)}
/* Backward compatibility with fluentui v7 */
{...{
autoFocus: autofocus,
onBlur: _onBlur,
onFocus: _onFocus,
}}
/>
</>
);
Expand Down
14 changes: 11 additions & 3 deletions packages/fluent-ui/src/CheckboxesWidget/CheckboxesWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,21 @@ export default function CheckboxesWidget<
checked={checked}
label={option.label}
disabled={disabled || itemDisabled || readonly}
autoFocus={autofocus && index === 0}
inputProps={{
autoFocus: autofocus && index === 0,
onBlur: _onBlur,
onFocus: _onFocus,
}}
onChange={_onChange(index)}
onBlur={_onBlur}
onFocus={_onFocus}
key={index}
{...uiProps}
aria-describedby={ariaDescribedByIds<T>(id)}
/* Backward compatibility with fluentui v7 */
{...{
autoFocus: autofocus && index === 0,
onBlur: _onBlur,
onFocus: _onFocus,
}}
/>
);
})}
Expand Down
3 changes: 2 additions & 1 deletion packages/fluent-ui/src/RadioWidget/RadioWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const allowedProps: (keyof IChoiceGroupProps)[] = [
'selectedKey',
'onChange',
'label',
'onChanged',
/* Backward compatibility with fluentui v7 */
'onChanged' as any,
'theme',
'styles',
'ariaLabelledBy',
Expand Down
18 changes: 13 additions & 5 deletions packages/fluent-ui/src/UpDownWidget/UpDownWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChangeEvent, FocusEvent } from 'react';
import { SpinButton } from '@fluentui/react';
import { ChangeEvent, FocusEvent, SyntheticEvent } from 'react';
import { ISpinButtonProps, SpinButton } from '@fluentui/react';
import {
ariaDescribedByIds,
FormContextType,
Expand All @@ -15,7 +15,7 @@ import _pick from 'lodash/pick';
import FluentLabel from '../FluentLabel/FluentLabel';

// Keys of ISpinButtonProps from @fluentui/react
const allowedProps = [
const allowedProps: (keyof ISpinButtonProps)[] = [
'ariaDescribedBy',
'ariaLabel',
'ariaPositionInSet',
Expand All @@ -29,7 +29,8 @@ const allowedProps = [
'defaultValue',
'disabled',
'downArrowButtonStyles',
'getClassNames',
/* Backward compatibility with fluentui v7 */
'getClassNames' as any,
'iconButtonProps',
'iconProps',
'incrementButtonAriaLabel',
Expand Down Expand Up @@ -74,7 +75,14 @@ export default function UpDownWidget<
registry,
}: WidgetProps<T, S, F>) {
const { translateString } = registry;
const _onChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) => onChange(Number(value));
const _onChange = (ev: ChangeEvent<HTMLInputElement> | SyntheticEvent<HTMLElement>, newValue?: string) => {
if (newValue) {
onChange(Number(newValue));
} else if ('value' in ev.target) {
/* Backward compatibility with fluentui v7 */
onChange(Number(ev.target.value));
}
};

let { min, max, step } = rangeSpec<S>(schema);
if (min === undefined) {
Expand Down
Loading