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

antd v5 migration #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
957 changes: 671 additions & 286 deletions packages/antd/package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/antd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@ant-design/icons": "^4.0.0",
"@rjsf/core": "5.7.x",
"@rjsf/utils": "5.7.x",
"antd": "^4.0.0",
"antd": "^5.0.0",
"dayjs": "^1.8.0",
"react": "^16.14.0 || >=17"
},
Expand Down Expand Up @@ -60,7 +60,7 @@
"@types/react": "^17.0.59",
"@types/react-dom": "^17.0.20",
"@types/react-test-renderer": "^17.0.2",
"antd": "^4.24.10",
"antd": "^5.0.0",
"atob": "^2.1.2",
"dayjs": "^1.11.7",
"dts-cli": "^1.6.3",
Expand Down Expand Up @@ -96,4 +96,4 @@
"publishConfig": {
"access": "public"
}
}
}
6 changes: 0 additions & 6 deletions packages/antd/src/components/DatePicker/index.ts

This file was deleted.

13 changes: 5 additions & 8 deletions packages/antd/src/index.less → packages/antd/src/index.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~antd/lib/style/themes/default.less';
@import '~antd/dist/reset.css';

.field-hidden {
display: none;
Expand All @@ -9,30 +9,27 @@
}

.form-group:not(.field) {
// Add margin below oneOf / anyOf dropdown.
margin-bottom: @form-item-margin-bottom;
margin-bottom: 24px;
}

.object-property-expand {
// Add margin below the `additionalProperties` related add button.
margin-bottom: @form-item-margin-bottom;
margin-bottom: 24px;
}

// .panel.panel-default.panel-body > .ant-row > fieldset > .ant-col.ant-form-item-label {
.panel.panel-default.panel-body fieldset > .ant-col.ant-form-item-label {
// Hide oneOf / anyOf object title.
display: none;
}

.panel.panel-danger.errors {
margin-bottom: @form-item-margin-bottom;
margin-bottom: 24px;

.list-group .ant-list-item {
margin-left: 0;
margin-right: 0;

.anticon.anticon-exclamation-circle {
color: @red-6;
color: #f5222d;
}
}
}
14 changes: 11 additions & 3 deletions packages/antd/src/templates/IconButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
StrictRJSFSchema,
TranslatableString,
} from '@rjsf/utils';
import { MouseEventHandler } from 'react';

// The `type` for IconButtonProps collides with the `type` for `ButtonProps` so omit it to avoid Typescript issue
export type AntdIconButtonProps<
Expand All @@ -21,10 +22,17 @@ export type AntdIconButtonProps<
> = Omit<IconButtonProps<T, S, F>, 'type'>;

export default function IconButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
props: AntdIconButtonProps<T, S, F> & ButtonProps
props: AntdIconButtonProps<T, S, F> & Omit<ButtonProps, 'onClick'>
) {
const { iconType = 'default', icon, uiSchema, registry, ...otherProps } = props;
return <Button type={iconType as ButtonType} icon={icon} {...otherProps} />;
const { iconType = 'default', icon, onClick, uiSchema, registry, ...otherProps } = props;
return (
<Button
onClick={onClick as MouseEventHandler<HTMLAnchorElement> & MouseEventHandler<HTMLButtonElement>}
type={iconType as ButtonType}
icon={icon}
{...otherProps}
/>
);
}

export function AddButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
Expand Down
4 changes: 2 additions & 2 deletions packages/antd/src/widgets/AltDateWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default function AltDateWidget<
}
};

const handleNow = (event: MouseEvent<HTMLButtonElement>) => {
const handleNow = (event: MouseEvent) => {
event.preventDefault();
if (disabled || readonly) {
return;
Expand All @@ -113,7 +113,7 @@ export default function AltDateWidget<
onChange(toDateString(nextState, showTime));
};

const handleClear = (event: MouseEvent<HTMLButtonElement>) => {
const handleClear = (event: MouseEvent) => {
event.preventDefault();
if (disabled || readonly) {
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/antd/src/widgets/DateTimeWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
WidgetProps,
} from '@rjsf/utils';

import DatePicker from '../../components/DatePicker';
import DatePicker from 'antd/lib/date-picker';

const DATE_PICKER_STYLE = {
width: '100%',
Expand Down
2 changes: 1 addition & 1 deletion packages/antd/src/widgets/DateWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
GenericObjectType,
} from '@rjsf/utils';

import DatePicker from '../../components/DatePicker';
import DatePicker from 'antd/lib/date-picker';

const DATE_PICKER_STYLE = {
width: '100%',
Expand Down
Loading