Skip to content

Commit f3df5aa

Browse files
committed
feat: 更新antd库到6.0
1 parent b58d148 commit f3df5aa

File tree

15 files changed

+887
-809
lines changed

15 files changed

+887
-809
lines changed

client/packages/barda-design/src/components/CustomModal.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ const DEFAULT_PROPS = {
216216
function CustomModalRender(props: Omit<CustomModalProps & ModalFuncProps, 'width'> & { width?: string | number }) {
217217
const nodeRef = React.useRef(null);
218218
const [enableDrag, setEnableDrag] = useState(true)
219+
220+
const bodyStyles = typeof props.styles === 'object' && props.styles !== null && 'body' in props.styles
221+
? props.styles.body
222+
: undefined;
223+
219224
return (
220225
<Draggable nodeRef={nodeRef} disabled={enableDrag || !props.draggable}>
221226
<ModalWrapper $width={props.width} ref={nodeRef}>
@@ -234,7 +239,7 @@ function CustomModalRender(props: Omit<CustomModalProps & ModalFuncProps, 'width
234239
/>
235240
</ModalHeaderWrapper>
236241

237-
<div style={{ padding: "0 16px", ...props.styles?.body }}>{props.children}</div>
242+
<div style={{ padding: "0 16px", ...bodyStyles }}>{props.children}</div>
238243

239244
{props.footer === null || props.footer ? (
240245
props.footer
@@ -331,7 +336,9 @@ CustomModal.confirm = (props: {
331336
okText={props.okText}
332337
styles={{
333338
body: {
334-
...defaultConfirmProps.styles?.body,
339+
...(typeof defaultConfirmProps.styles === 'object' && defaultConfirmProps.styles !== null && 'body' in defaultConfirmProps.styles
340+
? defaultConfirmProps.styles.body
341+
: undefined),
335342
...props.bodyStyle,
336343
}
337344
}}

client/packages/barda-design/src/components/Dropdown.tsx

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -173,28 +173,29 @@ export function Dropdown<T extends OptionsType>(props: DropdownProps<T>) {
173173
open={props.open}
174174
listHeight={props.lineHeight}
175175
classNames={{ popup: { root: "ob-dropdown-control-select" } }}
176-
showSearch={props.showSearch}
177-
filterOption={(input, option) => {
178-
if (props.optionFilterProp) {
179-
const value = (option as any)[props.optionFilterProp];
180-
if (value && typeof value === "string") {
181-
return value.toLowerCase().includes(input.toLowerCase());
176+
showSearch={props.showSearch ? {
177+
filterOption: (input, option) => {
178+
if (props.optionFilterProp && typeof props.optionFilterProp === "string") {
179+
const value = (option as any)[props.optionFilterProp];
180+
if (value && typeof value === "string") {
181+
return value.toLowerCase().includes(input.toLowerCase());
182+
}
182183
}
183-
}
184184

185-
if (!option?.value) {
185+
if (!option?.value) {
186+
return false;
187+
}
188+
const label = valueInfoMap[option.value].label;
189+
if (
190+
typeof label === "number" ||
191+
typeof label === "string" ||
192+
typeof label === "boolean"
193+
) {
194+
return label.toString().toLowerCase().includes(input.toLowerCase());
195+
}
186196
return false;
187197
}
188-
const label = valueInfoMap[option.value].label;
189-
if (
190-
typeof label === "number" ||
191-
typeof label === "string" ||
192-
typeof label === "boolean"
193-
) {
194-
return label.toString().toLowerCase().includes(input.toLowerCase());
195-
}
196-
return false;
197-
}}
198+
} : false}
198199
border={props.border}
199200
defaultValue={props.defaultValue}
200201
value={props.value}

client/packages/barda-design/src/components/Modal/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,18 @@ export function Modal(props: ModalProps) {
5353
refreshRate: 50
5454
});
5555
// log.info("Modal. modalWidth: ", modalWidth, " width: ", size?.w, " detectWidth: ", detectWidth);
56+
57+
const bodyStyles = typeof styles === 'object' && styles !== null && 'body' in styles
58+
? styles.body
59+
: undefined;
60+
5661
return (
5762
<AntdModal
5863
width={width ?? modalWidth}
5964
styles={{
6065
body: {
6166
height: height ?? modalHeight,
62-
...styles?.body,
67+
...bodyStyles,
6368
}
6469
}}
6570
{...otherProps}

client/packages/barda/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@types/react-signature-canvas": "^1.0.2",
3838
"@types/react-test-renderer": "^18.0.0",
3939
"@types/react-virtualized": "^9.21.21",
40-
"antd": "^5.24.5",
40+
"antd": "^6.1.2",
4141
"axios": "^1.6.2",
4242
"barda-core": "workspace:^",
4343
"barda-design": "workspace:^",
@@ -64,6 +64,7 @@
6464
"prettier": "2.7.0",
6565
"qrcode.react": "^3.1.0",
6666
"rc-trigger": "^5.3.1",
67+
"rc-virtual-list": "^3.19.2",
6768
"react": "^18.2.0",
6869
"react-colorful": "^5.5.1",
6970
"react-countup": "6.5.3",

client/packages/barda/src/components/PermissionDialog/Permission.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,21 @@ import {
2020
StyledRoleSelect,
2121
} from "./commonComponents";
2222
import { getInitialsAndColorCode } from "util/stringUtils";
23-
import { CustomTagProps } from "rc-select/lib/BaseSelect";
2423
import { Tag } from "antd";
24+
import type { ReactNode, MouseEvent } from "react";
2525
import { User } from "constants/userConstants";
2626
import { getUser } from "redux/selectors/usersSelectors";
2727
import { EmptyContent } from "pages/common/styledComponent";
2828
import { trans } from "i18n";
2929
import { PermissionItem } from "./PermissionList";
3030

31+
interface CustomTagProps {
32+
label: ReactNode;
33+
value: any;
34+
closable: boolean;
35+
onClose?: (event?: MouseEvent<HTMLElement>) => void;
36+
}
37+
3138
const AddAppUserContent = styled.div`
3239
display: flex;
3340
flex-direction: column;

client/packages/barda/src/comps/comps/autoCompleteComp/autoCompleteComp.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getDayJSLocale } from "@barda/i18n/dayjsLocale";
22
import { InputRef } from "antd";
33
import { default as AntAutoComplete } from "antd/es/auto-complete";
44
import { default as AntInput } from "antd/es/input";
5-
import { BaseOptionType, DefaultOptionType } from "antd/es/select";
5+
import { BaseOptionType } from "antd/es/select";
66
import { Input, Section, sectionNames } from "barda-design";
77
import { BoolControl } from "comps/controls/boolControl";
88
import { jsonControl } from "comps/controls/codeControl";
@@ -23,7 +23,6 @@ import { allowClearPropertyView, hiddenPropertyView } from "comps/utils/property
2323
import { trans } from "i18n";
2424
import _ from "lodash";
2525
import { pinyin } from "pinyin-pro";
26-
import { FilterFunc } from "rc-select/lib/Select";
2726
import { useCallback, useEffect, useState } from "react";
2827
import styled from "styled-components";
2928
import { UICompBuilder, withDefault } from "../../generators";
@@ -241,10 +240,10 @@ let AutoCompleteCompBase = (function () {
241240
props.onEvent("submit");
242241
};
243242

244-
const filterOption: FilterFunc<DefaultOptionType | BaseOptionType> = (
243+
const filterOption = (
245244
inputValue: string,
246245
option?: BaseOptionType
247-
) => {
246+
): boolean => {
248247
var InputValueLowerCase = inputValue.toLowerCase();
249248
if (ignoreCase) {
250249
if (option!.label.toLowerCase().indexOf(InputValueLowerCase) !== -1) return true;

client/packages/barda/src/comps/comps/dateComp/dateUIView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const DatePickerStyled = styled(DatePicker) <{ $style: DateTimeStyleType }>`
1616

1717
export interface DataUIViewProps extends DateCompViewProps {
1818
value: dayjs.Dayjs | null;
19-
onChange: (date: unknown, dateString: string | string[]) => void;
19+
onChange: (date: unknown, dateString: string | string[] | null) => void;
2020
onPanelChange: () => void;
2121
}
2222

client/packages/barda/src/comps/comps/dividerComp.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import _ from "lodash";
99
import styled from "styled-components";
1010
import { styleControl } from "comps/controls/styleControl";
1111
import { DividerStyle, DividerStyleType } from "comps/controls/styleControlConstants";
12-
import { migrateOldData } from "comps/generators/simpleGenerators";
1312
import { hiddenPropertyView } from "comps/utils/propertyUtils";
1413
import { trans } from "i18n";
1514

@@ -41,7 +40,7 @@ const childrenMap = {
4140
// Compatible with historical style data 2022-8-26
4241
export const DividerComp = new UICompBuilder(childrenMap, (props) => {
4342
return (
44-
<StyledDivider orientation={props.align} $dashed={props.dashed} $style={props.style}>
43+
<StyledDivider titlePlacement={props.align} $dashed={props.dashed} $style={props.style}>
4544
{props.title}
4645
</StyledDivider>
4746
);

client/packages/barda/src/comps/comps/fileComp/fileComp.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
RecordConstructorToComp,
2222
RecordConstructorToView,
2323
} from "barda-core";
24-
import { UploadRequestOption } from "rc-upload/lib/interface";
2524
import { useEffect, useState } from "react";
2625
import styled, { css } from "styled-components";
2726
import { JSONObject, JSONValue } from "../../../util/jsonTypes";
@@ -40,6 +39,8 @@ import { CommonNameConfig, NameConfig, withExposingConfigs } from "../../generat
4039
import { formDataChildren, FormDataPropertyView } from "../formComp/formDataConstants";
4140
import { messageInstance } from "barda-design";
4241

42+
type UploadRequestOption = Parameters<NonNullable<UploadProps['customRequest']>>[0];
43+
4344
const FileSizeControl = codeControl((value) => {
4445
if (typeof value === "number") {
4546
return value;

client/packages/barda/src/comps/comps/selectInputComp/selectCompConstants.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { SelectOptionControl, optionsControl } from "../../controls/optionsContr
1919
import { SelectEventHandlerControl } from "../../controls/eventHandlerControl";
2020
import { Select as AntdSelect } from "antd";
2121
import { ControlParams } from "../../controls/controlParams";
22-
import { ReactNode } from "react";
22+
import { ReactNode, ComponentRef } from "react";
2323
import styled, { css } from "styled-components";
2424
import { MultiCompBuilder } from "../../generators";
2525
import { IconControl } from "../../controls/iconControl";
@@ -46,7 +46,6 @@ import {
4646
import { trans } from "i18n";
4747
import { hasIcon } from "comps/utils";
4848
import { RefControl } from "comps/controls/refControl";
49-
import { BaseSelectRef } from "rc-select";
5049
import { refMethods } from "comps/generators/withMethodExposing";
5150
import { blurMethod, focusMethod } from "comps/utils/methodUtils";
5251
import { pinyin } from "pinyin-pro";
@@ -176,7 +175,7 @@ export const SelectChildrenMap = {
176175
allowClear: BoolControl,
177176
inputValue: stateComp<string>(""), // user's input value when search
178177
showSearch: BoolControl.DEFAULT_TRUE,
179-
viewRef: RefControl<BaseSelectRef>,
178+
viewRef: RefControl<ComponentRef<typeof AntdSelect>>,
180179
...SelectInputValidationChildren,
181180
...formDataChildren,
182181
};
@@ -283,7 +282,7 @@ export const SelectPropertyView = (
283282
</>
284283
);
285284

286-
export const baseSelectRefMethods = refMethods<BaseSelectRef>([focusMethod, blurMethod]);
285+
export const baseSelectRefMethods = refMethods<ComponentRef<typeof AntdSelect>>([focusMethod, blurMethod]);
287286

288287
// ColorMapOption for color mapping
289288
let ColorMapOption = new MultiCompBuilder(

0 commit comments

Comments
 (0)