Skip to content

Commit a4ecb96

Browse files
authored
Merge pull request #1102 from lowcoder-org/antd-upgrade-5.19.4
Antd upgrade 5.20.0
2 parents 29ee629 + 7e8dfe0 commit a4ecb96

File tree

24 files changed

+561
-349
lines changed

24 files changed

+561
-349
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export function Dropdown<T extends OptionsType>(props: DropdownProps<T>) {
235235
<SegmentedWrapper $placement={placement}>
236236
<Segmented
237237
block={true}
238-
onChange={(value) => props.onChange(value.toString())}
238+
onChange={(value) => props.onChange(String(value))}
239239
defaultValue={props.defaultValue}
240240
value={props.value}
241241
options={props.options as any}

client/packages/lowcoder-design/src/components/button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ const TacoButton = forwardRef(
181181
props: Omit<ButtonProps, "type"> & {
182182
buttonType?: TacoButtonType;
183183
},
184-
ref: React.Ref<HTMLElement>
184+
ref: React.Ref<HTMLButtonElement>
185185
) => {
186186
const { buttonType, ...restProps } = props;
187187
let loadingBackground;

client/packages/lowcoder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@types/react-test-renderer": "^18.0.0",
3838
"@types/react-virtualized": "^9.21.21",
3939
"animate.css": "^4.1.1",
40-
"antd": "5.13.2",
40+
"antd": "^5.20.0",
4141
"axios": "^1.6.2",
4242
"buffer": "^6.0.3",
4343
"clsx": "^2.0.0",

client/packages/lowcoder/src/components/Segmented.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { default as AntdSegmented } from "antd/es/segmented";
2+
import type { SegmentedProps } from "antd/es/segmented";
23
import styled from "styled-components";
34

4-
type PropsType<T extends React.ForwardRefExoticComponent<any>> =
5-
T extends React.ForwardRefExoticComponent<infer R> ? R : never;
6-
type SegmentedProps = PropsType<typeof AntdSegmented>;
5+
// type PropsType<T extends React.ForwardRefExoticComponent<any>> =
6+
// T extends React.ForwardRefExoticComponent<infer R> ? R : never;
7+
// type SegmentedProps = PropsType<typeof AntdSegmented>;
78

8-
const StyledSegmented = styled(AntdSegmented)<PropsType<typeof AntdSegmented>>`
9+
const StyledSegmented = styled(AntdSegmented)<SegmentedProps>`
910
width: 100%;
1011
height: 28px;
1112
border-radius: 6px;

client/packages/lowcoder/src/comps/comps/buttonComp/scannerComp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { trans } from "i18n";
2121
import React, { Suspense, useEffect, useRef, useState, useContext } from "react";
2222
import { arrayStringExposingStateControl } from "comps/controls/codeStateControl";
2323
import { BoolControl } from "comps/controls/boolControl";
24-
import type { ItemType } from "antd/es/menu/hooks/useItems";
24+
import type { ItemType } from "antd/es/menu/interface";
2525
import { RefControl } from "comps/controls/refControl";
2626
import { EditorContext } from "comps/editorState";
2727
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";

client/packages/lowcoder/src/comps/comps/dateComp/dateComp.tsx

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,19 @@ import {
3737
} from "comps/utils/propertyUtils";
3838
import { trans } from "i18n";
3939
import { DATE_FORMAT, DATE_TIME_FORMAT, DateParser, PickerMode } from "util/dateTimeUtils";
40-
import React, { ReactNode, useContext, useEffect } from "react";
40+
import React, { ReactNode, useContext, useEffect, useState } from "react";
4141
import { IconControl } from "comps/controls/iconControl";
4242
import { hasIcon } from "comps/utils";
4343
import { Section, sectionNames } from "components/Section";
44-
import { dateRefMethods, disabledTime, handleDateChange } from "comps/comps/dateComp/dateCompUtil";
44+
import { CommonPickerMethods, dateRefMethods, disabledTime, handleDateChange } from "comps/comps/dateComp/dateCompUtil";
4545
import { DateUIView } from "./dateUIView";
4646
import { useIsMobile } from "util/hooks";
4747
import { RefControl } from "comps/controls/refControl";
48-
import { CommonPickerMethods } from "antd/es/date-picker/generatePicker/interface";
48+
// import { CommonPickerMethods } from "antd/es/date-picker/generatePicker/interface";
4949
import { DateRangeUIView } from "comps/comps/dateComp/dateRangeUIView";
5050
import { EditorContext } from "comps/editorState";
5151
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
5252

53-
const defaultStyle = {
54-
borderStyle: 'solid',
55-
borderWidth: '1px',
56-
}
57-
5853
const EventOptions = [changeEvent, focusEvent, blurEvent] as const;
5954

6055
const validationChildren = {
@@ -169,30 +164,39 @@ export type DateCompViewProps = Pick<
169164
};
170165

171166
export const datePickerControl = new UICompBuilder(childrenMap, (props, dispatch) => {
172-
useMergeCompStyles(props as Record<string, any>, dispatch);
173-
174-
let time = null;
167+
useMergeCompStyles(props as Record<string, any>, dispatch);
168+
169+
let time: dayjs.Dayjs | null = null;
175170
if (props.value.value !== '') {
176171
time = dayjs(props.value.value, DateParser);
177172
}
173+
174+
const [tempValue, setTempValue] = useState<dayjs.Dayjs | null>(time);
175+
176+
useEffect(() => {
177+
const value = props.value.value ? dayjs(props.value.value, DateParser) : null;
178+
setTempValue(value);
179+
}, [props.value.value])
178180

179181
return props.label({
180182
required: props.required,
181183
style: props.style,
182184
labelStyle: props.labelStyle,
183185
inputFieldStyle:props.inputFieldStyle,
184186
animationStyle:props.animationStyle,
187+
onMouseDown: (e) => e.stopPropagation(),
185188
children: (
186189
<DateUIView
187190
viewRef={props.viewRef}
188191
disabledTime={() => disabledTime(props.minTime, props.maxTime)}
189192
$style={props.inputFieldStyle}
190193
disabled={props.disabled}
191194
{...datePickerProps(props)}
195+
hourStep={props.hourStep}
192196
minDate={props.minDate}
193197
maxDate={props.maxDate}
194198
placeholder={props.placeholder}
195-
value={time?.isValid() ? time : null}
199+
value={tempValue?.isValid() ? tempValue : null}
196200
onChange={(time) => {
197201
handleDateChange(
198202
time && time.isValid()
@@ -293,24 +297,37 @@ export const dateRangeControl = (function () {
293297
return new UICompBuilder(childrenMap, (props, dispatch) => {
294298
useMergeCompStyles(props as Record<string, any>, dispatch);
295299

296-
let start = null;
297-
let end = null;
300+
let start: dayjs.Dayjs | null = null;
298301
if (props.start.value !== '') {
299302
start = dayjs(props.start.value, DateParser);
300303
}
301-
304+
305+
let end: dayjs.Dayjs | null = null;
302306
if (props.end.value !== '') {
303307
end = dayjs(props.end.value, DateParser);
304308
}
305309

310+
const [tempStartValue, setTempStartValue] = useState<dayjs.Dayjs | null>(start);
311+
const [tempEndValue, setTempEndValue] = useState<dayjs.Dayjs | null>(end);
312+
313+
useEffect(() => {
314+
const value = props.start.value ? dayjs(props.start.value, DateParser) : null;
315+
setTempStartValue(value);
316+
}, [props.start.value])
317+
318+
useEffect(() => {
319+
const value = props.end.value ? dayjs(props.end.value, DateParser) : null;
320+
setTempEndValue(value);
321+
}, [props.end.value])
322+
306323
const children = (
307324
<DateRangeUIView
308325
viewRef={props.viewRef}
309326
$style={props.inputFieldStyle}
310327
disabled={props.disabled}
311328
{...datePickerProps(props)}
312-
start={start?.isValid() ? start : null}
313-
end={end?.isValid() ? end : null}
329+
start={tempStartValue?.isValid() ? tempStartValue : null}
330+
end={tempEndValue?.isValid() ? tempEndValue : null}
314331
minDate={props.minDate}
315332
maxDate={props.maxDate}
316333
placeholder={[props.placeholder, props.placeholder]}
@@ -345,6 +362,7 @@ export const dateRangeControl = (function () {
345362
labelStyle:props.labelStyle,
346363
children: children,
347364
inputFieldStyle:props.inputFieldStyle,
365+
onMouseDown: (e) => e.stopPropagation(),
348366
...(startResult.validateStatus !== "success"
349367
? startResult
350368
: endResult.validateStatus !== "success"

client/packages/lowcoder/src/comps/comps/dateComp/dateCompUtil.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ import { range } from "lodash";
44
import { DateTimeStyleType } from "../../controls/styleControlConstants";
55
import { css } from "styled-components";
66
import { isDarkColor, lightenColor } from "components/colorSelect/colorUtils";
7-
import { CommonPickerMethods } from "antd/es/date-picker/generatePicker/interface";
7+
// import { CommonPickerMethods } from "antd/es/date-picker/generatePicker/interface";
88
import { blurMethod, focusMethod } from "comps/utils/methodUtils";
99
import { refMethods } from "comps/generators/withMethodExposing";
1010

11+
export interface CommonPickerMethods {
12+
focus: (options?: FocusOptions) => void;
13+
blur: VoidFunction;
14+
};
15+
1116
export const handleDateChange = (
1217
time: string,
1318
onChange: (value: string) => Promise<unknown>,

client/packages/lowcoder/src/comps/comps/dateComp/dateMobileUIView.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,21 @@ import { DataUIViewProps } from "comps/comps/dateComp/dateUIView";
1010
import { default as SwapRightOutlined } from "@ant-design/icons/SwapRightOutlined"
1111
import { DateRangeUIViewProps } from "comps/comps/dateComp/dateRangeUIView";
1212
import { DateCompViewProps } from "comps/comps/dateComp/dateComp";
13+
import type { DatePickerProps } from "antd/es/date-picker";
14+
import type { Dayjs } from "dayjs";
15+
16+
interface DateMobileUIViewProps extends Omit<DataUIViewProps, 'onChange'> {
17+
onChange: (value: dayjs.Dayjs | null) => void;
18+
}
1319

1420
const handleClick = async (
1521
params: Pick<
1622
DateCompViewProps,
1723
"showTime" | "minDate" | "maxDate" | "disabledTime" | "onFocus" | "onBlur"
1824
> & {
19-
value: dayjs.Dayjs | null;
20-
onChange: (value: dayjs.Dayjs | null) => void;
25+
value?: dayjs.Dayjs | null;
26+
// onChange: (value: dayjs.Dayjs | null) => void;
27+
onChange: DatePickerProps<Dayjs>['onChange'];
2128
}
2229
) => {
2330
const MobileDatePicker = (await import("antd-mobile/es/components/date-picker")).default;
@@ -45,7 +52,8 @@ const handleClick = async (
4552
},
4653
onConfirm: (value) => {
4754
const time = dayjs(value);
48-
params.onChange(time);
55+
const timeString = time.format(params.showTime ? DATE_TIME_FORMAT : DATE_FORMAT);
56+
params.onChange?.(time, timeString);
4957
},
5058
onClose: params.onBlur,
5159
});

client/packages/lowcoder/src/comps/comps/dateComp/dateRangeUIView.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { EditorContext } from "../../editorState";
1010
import { default as DatePicker } from "antd/es/date-picker";
1111
import { hasIcon } from "comps/utils";
1212
import { omit } from "lodash";
13+
import { DateParser } from "@lowcoder-ee/util/dateTimeUtils";
1314

1415
const { RangePicker } = DatePicker;
1516

@@ -57,6 +58,11 @@ export const DateRangeUIView = (props: DateRangeUIViewProps) => {
5758
inputReadOnly={checkIsMobile(editorState?.getAppSettings().maxWidth)}
5859
suffixIcon={hasIcon(props.suffixIcon) && props.suffixIcon}
5960
placeholder={placeholders}
61+
minDate={props.minDate ? dayjs(props.minDate, DateParser) : undefined}
62+
maxDate={props.maxDate ? dayjs(props.maxDate, DateParser) : undefined}
63+
hourStep={props.hourStep as any}
64+
minuteStep={props.minuteStep as any}
65+
secondStep={props.secondStep as any}
6066
/>
6167
);
6268
};

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@ import styled from "styled-components";
88
import type { DateTimeStyleType } from "../../controls/styleControlConstants";
99
import { EditorContext } from "../../editorState";
1010
import { default as DatePicker } from "antd/es/date-picker";
11+
import type { DatePickerProps } from "antd/es/date-picker";
12+
import type { Dayjs } from 'dayjs';
13+
import { DateParser } from "@lowcoder-ee/util/dateTimeUtils";
1114

12-
const DatePickerStyled = styled(DatePicker)<{ $style: DateTimeStyleType }>`
15+
const DatePickerStyled = styled(DatePicker<Dayjs>)<{ $style: DateTimeStyleType }>`
1316
width: 100%;
1417
box-shadow: ${props=>`${props.$style.boxShadow} ${props.$style.boxShadowColor}`};
1518
${(props) => props.$style && getStyle(props.$style)}
1619
`;
1720

21+
1822
export interface DataUIViewProps extends DateCompViewProps {
19-
value: dayjs.Dayjs | null;
20-
onChange: (value: dayjs.Dayjs | null) => void;
23+
value?: DatePickerProps<Dayjs>['value'];
24+
onChange: DatePickerProps<Dayjs>['onChange'];
2125
onPanelChange: () => void;
2226
}
2327

@@ -29,12 +33,17 @@ export const DateUIView = (props: DataUIViewProps) => {
2933
const editorState = useContext(EditorContext);
3034

3135
const placeholder = Array.isArray(props.placeholder) ? props.placeholder[0] : props.placeholder;
32-
3336
return useUIView(
3437
<DateMobileUIView {...props} />,
3538
<DatePickerStyled
3639
{...props}
40+
multiple={false}
3741
ref={props.viewRef as any}
42+
minDate={props.minDate ? dayjs(props.minDate, DateParser) : undefined}
43+
maxDate={props.maxDate ? dayjs(props.maxDate, DateParser) : undefined}
44+
hourStep={props.hourStep as any}
45+
minuteStep={props.minuteStep as any}
46+
secondStep={props.secondStep as any}
3847
disabledDate={(current) => disabledDate(current, props.minDate, props.maxDate)}
3948
picker={"date"}
4049
inputReadOnly={checkIsMobile(editorState?.getAppSettings().maxWidth)}

client/packages/lowcoder/src/comps/comps/dateComp/timeComp.tsx

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ import {
4040
} from "comps/utils/propertyUtils";
4141
import { trans } from "i18n";
4242
import { TIME_FORMAT, TimeParser } from "util/dateTimeUtils";
43-
import React, { ReactNode, useContext, useEffect } from "react";
43+
import React, { ReactNode, useContext, useEffect, useState } from "react";
4444
import { IconControl } from "comps/controls/iconControl";
4545
import { hasIcon } from "comps/utils";
4646
import { Section, sectionNames } from "components/Section";
47-
import { dateRefMethods, disabledTime, handleDateChange } from "comps/comps/dateComp/dateCompUtil";
47+
import { CommonPickerMethods, dateRefMethods, disabledTime, handleDateChange } from "comps/comps/dateComp/dateCompUtil";
4848
import { TimeUIView } from "./timeUIView";
4949
import { TimeRangeUIView } from "comps/comps/dateComp/timeRangeUIView";
5050
import { RefControl } from "comps/controls/refControl";
51-
import { CommonPickerMethods } from "antd/es/date-picker/generatePicker/interface";
51+
// import { CommonPickerMethods } from "antd/es/date-picker/generatePicker/interface";
5252
import { TimePickerProps } from "antd/es/time-picker";
5353

5454
import { EditorContext } from "comps/editorState";
@@ -146,23 +146,31 @@ export type TimeCompViewProps = Pick<
146146
export const timePickerControl = new UICompBuilder(childrenMap, (props, dispatch) => {
147147
useMergeCompStyles(props as Record<string, any>, dispatch);
148148

149-
let time = null;
149+
let time: dayjs.Dayjs | null = null;
150150
if(props.value.value !== '') {
151151
time = dayjs(props.value.value, TimeParser);
152152
}
153+
154+
const [tempValue, setTempValue] = useState<dayjs.Dayjs | null>(time);
155+
156+
useEffect(() => {
157+
const value = props.value.value ? dayjs(props.value.value, TimeParser) : null;
158+
setTempValue(value);
159+
}, [props.value.value])
153160

154161
return props.label({
155162
required: props.required,
156163
style: props.style,
157164
labelStyle: props.labelStyle,
158165
inputFieldStyle:props.inputFieldStyle,
159166
animationStyle:props.animationStyle,
167+
onMouseDown: (e) => e.stopPropagation(),
160168
children: (
161169
<TimeUIView
162170
viewRef={props.viewRef}
163171
$style={props.inputFieldStyle}
164172
disabled={props.disabled}
165-
value={time?.isValid() ? time : null}
173+
value={tempValue?.isValid() ? tempValue : null}
166174
disabledTime={() => disabledTime(props.minTime, props.maxTime)}
167175
{...timePickerComps(props)}
168176
hourStep={props.hourStep as hourStepType}
@@ -258,22 +266,35 @@ export const timeRangeControl = (function () {
258266
return new UICompBuilder(childrenMap, (props, dispatch) => {
259267
useMergeCompStyles(props as Record<string, any>, dispatch);
260268

261-
let start = null;
269+
let start: dayjs.Dayjs | null = null;
262270
if(props.start.value !== '') {
263271
start = dayjs(props.start.value, TimeParser);
264272
}
265-
let end = null;
273+
let end: dayjs.Dayjs | null = null;
266274
if(props.end.value !== '') {
267275
end = dayjs(props.end.value, TimeParser);
268276
}
269277

278+
const [tempStartValue, setTempStartValue] = useState<dayjs.Dayjs | null>(start);
279+
const [tempEndValue, setTempEndValue] = useState<dayjs.Dayjs | null>(end);
280+
281+
useEffect(() => {
282+
const value = props.start.value ? dayjs(props.start.value, TimeParser) : null;
283+
setTempStartValue(value);
284+
}, [props.start.value])
285+
286+
useEffect(() => {
287+
const value = props.end.value ? dayjs(props.end.value, TimeParser) : null;
288+
setTempEndValue(value);
289+
}, [props.end.value])
290+
270291
const children = (
271292
<TimeRangeUIView
272293
viewRef={props.viewRef}
273294
$style={props.inputFieldStyle}
274295
disabled={props.disabled}
275-
start={start?.isValid() ? start : null}
276-
end={end?.isValid() ? end : null}
296+
start={tempStartValue?.isValid() ? tempStartValue : null}
297+
end={tempEndValue?.isValid() ? tempEndValue : null}
277298
disabledTime={() => disabledTime(props.minTime, props.maxTime)}
278299
{...timePickerComps(props)}
279300
hourStep={props.hourStep as hourStepType}
@@ -301,6 +322,7 @@ export const timeRangeControl = (function () {
301322
inputFieldStyle:props.inputFieldStyle,
302323
animationStyle:props.animationStyle,
303324
children: children,
325+
onMouseDown: (e) => e.stopPropagation(),
304326
...(startResult.validateStatus !== "success"
305327
? startResult
306328
: endResult.validateStatus !== "success"

0 commit comments

Comments
 (0)