From 05533e40bfddc0c86e931ab8b8ffb5bb37736322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E8=8F=9C=20Cai?= Date: Wed, 18 Dec 2024 21:38:59 +0800 Subject: [PATCH 01/61] test(Alert): add unit tests for className and style (#3284) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test(Alert): type optimization for test and add test `className`、`style` * chore: 恢复之前的 `@test/utils` 引用 --- src/alert/__tests__/alert.test.tsx | 38 ++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/alert/__tests__/alert.test.tsx b/src/alert/__tests__/alert.test.tsx index cc42f15381..e0b7918784 100644 --- a/src/alert/__tests__/alert.test.tsx +++ b/src/alert/__tests__/alert.test.tsx @@ -30,9 +30,13 @@ describe('Alert 组件测试', () => { expect(container.querySelector('.t-alert--error')).not.toBeNull(); expect(container.querySelector('.t-alert--error')).toBeInTheDocument(); - act(() => { - fireEvent.click(queryByTestId(testId)); - }); + const element = queryByTestId(testId); + if (element) { + // 在 react 18.3.1之后 可以在 react 中导出 act,且在18.3.1 之后应该在react中使用 act + act(() => fireEvent.click(element)); + } else { + throw new Error(`Element with testId ${testId} not found`); + } expect(container.querySelector('.t-alert--closing')).toBeInTheDocument(); expect(onClose).toHaveBeenCalledTimes(1); @@ -116,9 +120,11 @@ describe('Alert 组件测试', () => { expect(element).toBeNull(); const btn = await waitFor(() => queryByText('展开更多')); - act(() => { - fireEvent.click(btn); - }); + if (btn) { + act(() => fireEvent.click(btn)); + } else { + throw new Error(`Button with text '展开更多' not found`); + } expect(queryByText('收起')).not.toBeNull(); expect(queryByText('收起')).toBeInTheDocument(); @@ -126,11 +132,23 @@ describe('Alert 组件测试', () => { expect(element1).not.toBeNull(); const btn1 = await waitFor(() => queryByText('收起')); - act(() => { - fireEvent.click(btn1); - }); - + if (btn1) { + act(() => fireEvent.click(btn1)); + } else { + throw new Error(`Button with text '收起' not found`); + } const element3 = await waitFor(() => queryByTestId(testId)); expect(element3).toBeNull(); }); + + test('className', () => { + const { container } = render(); + expect(container.querySelector('.custom-class')).not.toBeNull(); + }); + + test('style', () => { + const { container } = render(); + const element = container.querySelector('.t-alert') as HTMLElement; + expect(element?.style.color).toBe('red'); + }); }); From 9fe694d3a6f981426440f63be6f070075f45657b Mon Sep 17 00:00:00 2001 From: Haixing <65376724+HaixingOoO@users.noreply.github.com> Date: Wed, 18 Dec 2024 23:59:57 +0800 Subject: [PATCH 02/61] perf(textarea): optimize TextArea init load autosize (#3286) --- src/textarea/Textarea.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/textarea/Textarea.tsx b/src/textarea/Textarea.tsx index 5e29dcb019..8ce2fea3e4 100644 --- a/src/textarea/Textarea.tsx +++ b/src/textarea/Textarea.tsx @@ -9,6 +9,7 @@ import { getCharacterLength, getUnicodeLength, limitUnicodeMaxLength } from '../ import calcTextareaHeight from '../_common/js/utils/calcTextareaHeight'; import { textareaDefaultProps } from './defaultProps'; import useDefaultProps from '../hooks/useDefaultProps'; +import useIsomorphicLayoutEffect from '../hooks/useLayoutEffect'; export interface TextareaProps extends Omit< @@ -22,7 +23,7 @@ export interface TextareaRefInterface extends React.RefObject { textareaElement: HTMLTextAreaElement; } -const Textarea = forwardRef((originalProps: TextareaProps, ref: TextareaRefInterface) => { +const Textarea = forwardRef((originalProps, ref) => { const props = useDefaultProps(originalProps, textareaDefaultProps); const { disabled, @@ -92,11 +93,6 @@ const Textarea = forwardRef((originalProps: TextareaProps, ref: TextareaRefInter } }, [autosize]); - useEffect(() => { - adjustTextareaHeight(); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [textareaRef?.current]); - function inputValueChangeHandle(e: React.FormEvent) { const { target } = e; let val = (target as HTMLInputElement).value; @@ -114,7 +110,7 @@ const Textarea = forwardRef((originalProps: TextareaProps, ref: TextareaRefInter composingRef.current = true; } - function handleCompositionEnd(e) { + function handleCompositionEnd(e: React.FormEvent) { if (composingRef.current) { composingRef.current = false; inputValueChangeHandle(e); @@ -132,7 +128,12 @@ const Textarea = forwardRef((originalProps: TextareaProps, ref: TextareaRefInter ); - useEffect(() => { + useIsomorphicLayoutEffect(() => { + adjustTextareaHeight(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [textareaRef?.current]); + + useIsomorphicLayoutEffect(() => { // 当未设置 autosize 时,需要将 textarea 的 height 设置为 auto,以支持原生的 textarea rows 属性 if (autosize === false) { setTextareaStyle({ height: 'auto', minHeight: 'auto' }); From 74cb32c51f7986674efe9fbb25e64f22209116cf Mon Sep 17 00:00:00 2001 From: Haixing <65376724+HaixingOoO@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:14:30 +0800 Subject: [PATCH 03/61] feat(DatePicker): support week and year multiple (#3264) * feat(datepicker): support week multiple * docs(datepicker): add week and year multiple example * fix(datepicker): fix PanelContent multiple type * test(datepicker): fix multiple test * docs(DatePicker): optimize DatePicker example * chore: update common * fix(datepicker): fix DatePicker week test * test(datepicker): update test snap * fix(datepicker): fix DatePicker week multiple judgment * chore: correct demo init value * chore: fix cross year week * chore: fix cross year week * chore: update snapshot * chore: update snapshot * chore: optimize --------- Co-authored-by: Heising Co-authored-by: github-actions[bot] Co-authored-by: Uyarn --- src/_common | 2 +- src/date-picker/DatePicker.tsx | 18 +- src/date-picker/_example/multiple.tsx | 44 +++- src/date-picker/base/Table.tsx | 26 +- src/date-picker/hooks/useSingleValue.tsx | 8 +- src/date-picker/panel/PanelContent.tsx | 3 +- src/select-input/useMultiple.tsx | 2 +- src/tag-input/useTagList.tsx | 1 + test/snap/__snapshots__/csr.test.jsx.snap | 293 ++++++++++++++++++---- test/snap/__snapshots__/ssr.test.jsx.snap | 2 +- 10 files changed, 321 insertions(+), 78 deletions(-) diff --git a/src/_common b/src/_common index 94e21e27e2..b0815e9e96 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 94e21e27e2aba45cc0da263d424537f453055180 +Subproject commit b0815e9e960d2c44e5fa076a877568fa9121b0bf diff --git a/src/date-picker/DatePicker.tsx b/src/date-picker/DatePicker.tsx index 5c2f35cdd3..f61413ccf1 100644 --- a/src/date-picker/DatePicker.tsx +++ b/src/date-picker/DatePicker.tsx @@ -15,6 +15,7 @@ import useDefaultProps from '../hooks/useDefaultProps'; import useLatest from '../hooks/useLatest'; import useUpdateEffect from '../hooks/useUpdateEffect'; import type { TagInputRemoveContext } from '../tag-input'; +import { useLocaleReceiver } from '../locale/LocalReceiver'; export interface DatePickerProps extends TdDatePickerProps, StyledProps {} @@ -64,6 +65,7 @@ const DatePicker = forwardRef((originalProps, r setCacheValue, } = useSingle(props); + const [local] = useLocaleReceiver('datePicker'); const { format, timeFormat, valueType } = getDefaultFormat({ mode, format: props.format, @@ -241,20 +243,28 @@ const DatePicker = forwardRef((originalProps, r }, []); function processDate(date: Date) { - const isSameDate = (value as DateMultipleValue).some((val) => isSame(dayjs(val).toDate(), date)); + let isSameDate: boolean; + const currentValue = (value || []) as DateMultipleValue; + if (mode !== 'week') + isSameDate = currentValue.some((val) => + isSame(parseToDayjs(val, format).toDate(), date, mode, local.dayjsLocale), + ); + else { + isSameDate = currentValue.some((val) => val === dayjs(date).locale(local.dayjsLocale).format(format)); + } let currentDate: DateMultipleValue; if (!isSameDate) { - currentDate = (value as DateMultipleValue).concat(formatDate(date, { format, targetFormat: valueType })); + currentDate = currentValue.concat(formatDate(date, { format, targetFormat: valueType })); } else { - currentDate = (value as DateMultipleValue).filter( + currentDate = currentValue.filter( (val) => formatDate(val, { format, targetFormat: valueType }) !== formatDate(date, { format, targetFormat: valueType }), ); } - return currentDate.sort((a, b) => dayjs(a).valueOf() - dayjs(b).valueOf()); + return currentDate?.sort((a, b) => dayjs(a).valueOf() - dayjs(b).valueOf()); } const onTagRemoveClick = (ctx: TagInputRemoveContext) => { diff --git a/src/date-picker/_example/multiple.tsx b/src/date-picker/_example/multiple.tsx index ad047fdd74..39c76df6ee 100644 --- a/src/date-picker/_example/multiple.tsx +++ b/src/date-picker/_example/multiple.tsx @@ -1,24 +1,52 @@ import React, { useState } from 'react'; -import { DatePicker } from 'tdesign-react'; +import { DatePicker, Space } from 'tdesign-react'; import type { DatePickerProps, DateMultipleValue } from 'tdesign-react'; export default function YearDatePicker() { - const [defaultValue, setDefaultValue] = useState(['2000-01-04', '2000-01-03', '2000-01-05']); + const [dateValue, setDateValue] = useState(['2024-10-01', '2024-10-24']); + const [weekValue, setWeekValue] = useState(['2024-50周', '2024-51周']); + const [yearValue, setYearValue] = useState(['2022', '2023', '2024']); - const handleChange: DatePickerProps['onChange'] = (value: DateMultipleValue, context) => { + const handleDateChange: DatePickerProps['onChange'] = (value: DateMultipleValue, context) => { console.log('onChange:', value, context); - setDefaultValue(value); + setDateValue(value); + }; + + const handleWeekChange: DatePickerProps['onChange'] = (value: DateMultipleValue, context) => { + console.log('onChange:', value, context); + setWeekValue(value); + }; + + const handleYearChange: DatePickerProps['onChange'] = (value: DateMultipleValue, context) => { + console.log('onChange:', value, context); + setYearValue(value); }; return ( -
+ + + -
+ ); } diff --git a/src/date-picker/base/Table.tsx b/src/date-picker/base/Table.tsx index a65a9eefc4..a6ae6aa701 100644 --- a/src/date-picker/base/Table.tsx +++ b/src/date-picker/base/Table.tsx @@ -2,18 +2,22 @@ import React, { useMemo } from 'react'; import classNames from 'classnames'; import dayjs from 'dayjs'; import isoWeek from 'dayjs/plugin/isoWeek'; + +import type { Dayjs } from 'dayjs'; import { useLocaleReceiver } from '../../locale/LocalReceiver'; import useConfig from '../../hooks/useConfig'; import DatePickerCell from './Cell'; -import { TdDatePickerProps } from '../type'; + import { SinglePanelProps } from '../panel/SinglePanel'; import { PanelContentProps } from '../panel/PanelContent'; import { parseToDayjs } from '../../_common/js/date-picker/format'; +import type { DateMultipleValue, DateRangeValue, DateValue, TdDatePickerProps } from '../type'; + dayjs.extend(isoWeek); export interface DatePickerTableProps - extends Pick, + extends Pick, Pick, Pick { data?: Array; @@ -60,7 +64,7 @@ const DatePickerTable = (props: DatePickerTableProps) => { }, [mode, value, format]); // 高亮周区间 - const weekRowClass = (value, targetDayjs) => { + const weekRowClass = (value: DateValue | DateRangeValue, targetDayjs: Dayjs) => { if (mode !== 'week' || !value) return {}; if (Array.isArray(value)) { @@ -90,6 +94,20 @@ const DatePickerTable = (props: DatePickerTableProps) => { }; }; + // multiple + const multipleWeekRowClass = (value: DateMultipleValue, targetDayjs: Dayjs) => { + if (mode !== 'week' || (Array.isArray(value) && !value.length)) return {}; + const isSomeYearWeek = value + .map((v) => parseToDayjs(v, format)) + .some((item) => item.isoWeek() === targetDayjs.isoWeek() && item.isoWeekYear() === targetDayjs.isoWeekYear()); + + return { + [`${classPrefix}-date-picker__table-${mode}-row--active`]: isSomeYearWeek, + }; + }; + + const activeRowCss = props.multiple ? multipleWeekRowClass : weekRowClass; + return (
onCellMouseLeave?.({ e })}> @@ -107,7 +125,7 @@ const DatePickerTable = (props: DatePickerTableProps) => { {row.map((col: any, j: number) => ( diff --git a/src/date-picker/hooks/useSingleValue.tsx b/src/date-picker/hooks/useSingleValue.tsx index e1bdcecdb9..c7970663af 100644 --- a/src/date-picker/hooks/useSingleValue.tsx +++ b/src/date-picker/hooks/useSingleValue.tsx @@ -26,11 +26,11 @@ export default function useSingleValue(props: TdDatePickerProps) { } const [time, setTime] = useState(() => - formatTime(props.multiple ? value[0] : value, format, timeFormat, props.defaultTime), + formatTime(props.multiple ? value?.[0] : value, format, timeFormat, props.defaultTime), ); - const [month, setMonth] = useState(() => parseToDayjs(props.multiple ? value[0] : value, format).month()); - const [year, setYear] = useState(() => parseToDayjs(props.multiple ? value[0] : value, format).year()); - const [cacheValue, setCacheValue] = useState(() => formatDate(props.multiple ? value[0] : value, { format })); // 缓存选中值,panel 点击时更改 + const [month, setMonth] = useState(() => parseToDayjs(props.multiple ? value?.[0] : value, format).month()); + const [year, setYear] = useState(() => parseToDayjs(props.multiple ? value?.[0] : value, format).year()); + const [cacheValue, setCacheValue] = useState(() => formatDate(props.multiple ? value?.[0] : value, { format })); // 缓存选中值,panel 点击时更改 // 输入框响应 value 变化 useEffect(() => { diff --git a/src/date-picker/panel/PanelContent.tsx b/src/date-picker/panel/PanelContent.tsx index a9c19cfbe5..44db079d2e 100644 --- a/src/date-picker/panel/PanelContent.tsx +++ b/src/date-picker/panel/PanelContent.tsx @@ -19,7 +19,7 @@ export interface PanelContentProps { timePickerProps: SinglePanelProps['timePickerProps']; firstDayOfWeek: SinglePanelProps['firstDayOfWeek']; time: SinglePanelProps['time']; - + multiple?: SinglePanelProps['multiple']; popupVisible?: boolean; tableData: any[]; onMonthChange: SinglePanelProps['onMonthChange'] | RangePanelProps['onMonthChange']; @@ -104,6 +104,7 @@ export default function PanelContent(props: PanelContentProps) { time={time} format={format} firstDayOfWeek={firstDayOfWeek} + multiple={props.multiple} onCellClick={(date: Date, { e }) => onCellClick?.(date, { e, partial })} onCellMouseEnter={(date: Date) => onCellMouseEnter?.(date, { partial })} onCellMouseLeave={onCellMouseLeave} diff --git a/src/select-input/useMultiple.tsx b/src/select-input/useMultiple.tsx index e589271d36..8146a01b21 100644 --- a/src/select-input/useMultiple.tsx +++ b/src/select-input/useMultiple.tsx @@ -35,12 +35,12 @@ export default function useMultiple(props: SelectInputProps) { const getTags = () => { if (!(value instanceof Array)) { + if (['', null, undefined].includes(value as any)) return []; return isObject(value) ? [value[iKeys.label]] : [value]; } return value.map((item: SelectInputValue) => (isObject(item) ? item[iKeys.label] : item)); }; const tags = getTags(); - const tPlaceholder = !tags || !tags.length ? props.placeholder : ''; const onTagInputChange = (val: TagInputValue, context: SelectInputChangeContext) => { diff --git a/src/tag-input/useTagList.tsx b/src/tag-input/useTagList.tsx index 721669dd7e..354efd5f3d 100644 --- a/src/tag-input/useTagList.tsx +++ b/src/tag-input/useTagList.tsx @@ -73,6 +73,7 @@ export default function useTagList(props: TagInputProps) { const renderLabel = ({ displayNode, label }: { displayNode: ReactNode; label: ReactNode }) => { const newList = minCollapsedNum ? tagValue.slice(0, minCollapsedNum) : tagValue; + const list = displayNode ? [{displayNode}] : newList?.map((item, index) => { diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index 8d392daf75..b8ea2bc8c1 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -32636,109 +32636,294 @@ exports[`csr snapshot test > csr test src/date-picker/_example/month.tsx 1`] = ` exports[`csr snapshot test > csr test src/date-picker/_example/multiple.tsx 1`] = `
-
+
- - 2000-01-04 - + + 2024-10-01 + + + + +
+
+ + 2024-10-24 + + + + +
+
+ + 可清除、可输入的日期选择器 + + -
+ +
+
+
+
+
+
+
+
+
+
- - 2000-01-03 - + + 2024-50周 + + + + +
+
+ + 2024-51周 + + + + +
+
+ + 可清除、可输入的日期选择器 + + -
+ +
+
+
+
+ +
+
+
+
+
- - 2000-01-05 - + + 2022 + + + + +
+
+ + 2023 + + + + +
+
+ + 2024 + + + + +
+
+ + 可清除、可输入的日期选择器 + + -
+
- - 可清除、可输入的日期选择器 - - - - - -
@@ -134333,7 +134518,7 @@ exports[`ssr snapshot test > ssr test src/date-picker/_example/first-day-of-week exports[`ssr snapshot test > ssr test src/date-picker/_example/month.tsx 1`] = `"
~
"`; -exports[`ssr snapshot test > ssr test src/date-picker/_example/multiple.tsx 1`] = `"
2000-01-04
2000-01-03
2000-01-05
可清除、可输入的日期选择器
"`; +exports[`ssr snapshot test > ssr test src/date-picker/_example/multiple.tsx 1`] = `"
2024-10-01
2024-10-24
可清除、可输入的日期选择器
2024-50周
2024-51周
可清除、可输入的日期选择器
2022
2023
2024
可清除、可输入的日期选择器
"`; exports[`ssr snapshot test > ssr test src/date-picker/_example/panel.tsx 1`] = `"
MonTueWedThuFriSatSun
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
MonTueWedThuFriSatSun
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
00:00:00
MonTueWedThuFriSatSun
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
MonTueWedThuFriSatSun
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
MonTueWedThuFriSatSun
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
00:00:00
"`; diff --git a/test/snap/__snapshots__/ssr.test.jsx.snap b/test/snap/__snapshots__/ssr.test.jsx.snap index 337aa9e608..4876c2d2c9 100644 --- a/test/snap/__snapshots__/ssr.test.jsx.snap +++ b/test/snap/__snapshots__/ssr.test.jsx.snap @@ -292,7 +292,7 @@ exports[`ssr snapshot test > ssr test src/date-picker/_example/first-day-of-week exports[`ssr snapshot test > ssr test src/date-picker/_example/month.tsx 1`] = `"
~
"`; -exports[`ssr snapshot test > ssr test src/date-picker/_example/multiple.tsx 1`] = `"
2000-01-04
2000-01-03
2000-01-05
可清除、可输入的日期选择器
"`; +exports[`ssr snapshot test > ssr test src/date-picker/_example/multiple.tsx 1`] = `"
2024-10-01
2024-10-24
可清除、可输入的日期选择器
2024-50周
2024-51周
可清除、可输入的日期选择器
2022
2023
2024
可清除、可输入的日期选择器
"`; exports[`ssr snapshot test > ssr test src/date-picker/_example/panel.tsx 1`] = `"
MonTueWedThuFriSatSun
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
MonTueWedThuFriSatSun
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
00:00:00
MonTueWedThuFriSatSun
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
MonTueWedThuFriSatSun
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
MonTueWedThuFriSatSun
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
00:00:00
"`; From e8b89c18b6a4f2c84e16772f753d309eca8bbbe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E8=8F=9C=20Cai?= Date: Thu, 19 Dec 2024 14:37:33 +0800 Subject: [PATCH 04/61] fix(form): `value: [{ min: 0 }]` invalid rules and add test (#3283) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(form): `value: [{ min: 0 }]` invalid and add test * chore: optimize --------- Co-authored-by: wū yāng --- src/form/__tests__/form.test.tsx | 57 ++++++++++++++++++++++++++++++++ src/form/formModel.ts | 4 +-- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/form/__tests__/form.test.tsx b/src/form/__tests__/form.test.tsx index f516f5f0aa..5bc6481f1c 100644 --- a/src/form/__tests__/form.test.tsx +++ b/src/form/__tests__/form.test.tsx @@ -7,6 +7,7 @@ import Input from '../../input'; import Button from '../../button'; import Radio from '../../radio'; import { HelpCircleIcon } from 'tdesign-icons-react'; +import InputNumber from '../../input-number'; const { FormItem, FormList } = Form; @@ -423,6 +424,62 @@ describe('Form 组件测试', () => { expect(container.querySelector('.t-input__extra').innerHTML).toBe('please input username'); }); + test('FormItem rules min max', async () => { + const TestForm = () => { + const initialValues = { + year1: -2, + year2: 1, + year3: 4, + year4: -4, + year5: -1, + year6: 2, + }; + return ( +
+ + + + + + + + + + + + + + + + + + + + + +
+ ); + }; + const { container, getByText, getByPlaceholderText } = render(); + fireEvent.click(getByText('提交')); + await mockDelay(); + expect(container.querySelector('.t-input__extra')).toBeNull(); + + // 错误验证 + fireEvent.change(getByPlaceholderText('year1'), { target: { value: -4 } }); + fireEvent.change(getByPlaceholderText('year2'), { target: { value: -1 } }); + fireEvent.change(getByPlaceholderText('year3'), { target: { value: 2 } }); + fireEvent.change(getByPlaceholderText('year4'), { target: { value: -2 } }); + fireEvent.change(getByPlaceholderText('year5'), { target: { value: 1 } }); + fireEvent.change(getByPlaceholderText('year6'), { target: { value: 4 } }); + fireEvent.click(getByText('提交')); + await mockDelay(); + const input__extraList = container.querySelectorAll('.t-input__extra'); + input__extraList.forEach((item: { innerHTML: string }, index: number) => { + expect(item.innerHTML).toBe(`year${index + 1} error`); + }); + }); + test('动态渲染并初始赋值', () => { const TestForm = () => { const [form] = Form.useForm(); diff --git a/src/form/formModel.ts b/src/form/formModel.ts index 42fe38a684..3dc8fc65ab 100644 --- a/src/form/formModel.ts +++ b/src/form/formModel.ts @@ -54,7 +54,7 @@ const VALIDATE_MAP = { validator: (val: ValueType, validate: CustomValidator): ReturnType => validate(val), }; -export type ValidateFuncType = typeof VALIDATE_MAP[keyof typeof VALIDATE_MAP]; +export type ValidateFuncType = (typeof VALIDATE_MAP)[keyof typeof VALIDATE_MAP]; /** * 校验某一条数据的某一条规则,一种校验规则不满足则不再进行校验。 @@ -75,7 +75,7 @@ export async function validateOneRule(value: ValueType, rule: FormRule): Promise } const validateRule: ValidateFuncType = VALIDATE_MAP[key]; // 找到一个校验规则,则无需再找,因为参数只允许对一个规则进行校验 - if (validateRule && rule[key]) { + if (validateRule && ![undefined, null].includes(rule[key])) { // rule 值为 true 则表示没有校验参数,只是对值进行默认规则校验 vOptions = rule[key] === true ? undefined : rule[key]; vValidateFun = validateRule; From 4282c4bd763880c0befb951275fee4d3e76498d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?w=C5=AB=20y=C4=81ng?= Date: Thu, 19 Dec 2024 15:35:37 +0800 Subject: [PATCH 05/61] feat(Tree): support setItem indeterminate (#3261) * feat(Tree): support set indeterminate * feat(Tree): support set indeterminate * chore: support set indeterminate * chore: update common * chore: fix test --- src/_common | 2 +- src/cascader/core/effect.ts | 2 +- src/dialog/Dialog.tsx | 2 +- src/select/base/Select.tsx | 1 - src/tree/Tree.tsx | 28 ++++++++++++++++++++++++++-- src/tree/hooks/useControllable.ts | 17 ++++++++++++++--- src/tree/hooks/useStore.ts | 22 +++++++++++++++++++--- 7 files changed, 62 insertions(+), 12 deletions(-) diff --git a/src/_common b/src/_common index b0815e9e96..53786c5875 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit b0815e9e960d2c44e5fa076a877568fa9121b0bf +Subproject commit 53786c58752401e648cc45918f2a4dbb9e8cecfa diff --git a/src/cascader/core/effect.ts b/src/cascader/core/effect.ts index 7f30f6ef05..c17b1d4394 100644 --- a/src/cascader/core/effect.ts +++ b/src/cascader/core/effect.ts @@ -45,7 +45,7 @@ export function expendClickEffect( // 非受控状态下更新状态 setValue(valueType === 'single' ? value : node.getPath().map((item) => item.value), 'check', node.getModel()); - // 当 trigger 为 hover 时 ,点击节点一定是关闭 panel 的操作 + // 当 trigger 为 hover 时 ,点击节点一定是关闭 panel 的操作 if (!checkStrictly || propsTrigger === 'hover') { setVisible(false, {}); } diff --git a/src/dialog/Dialog.tsx b/src/dialog/Dialog.tsx index 0a10d28bcb..abe521b9f3 100644 --- a/src/dialog/Dialog.tsx +++ b/src/dialog/Dialog.tsx @@ -157,7 +157,7 @@ const Dialog = forwardRef((originalProps, ref) => { const onAnimateStart = () => { if (!wrapRef.current) return; - onBeforeOpen?.() + onBeforeOpen?.(); wrapRef.current.style.display = 'block'; }; diff --git a/src/select/base/Select.tsx b/src/select/base/Select.tsx index 8da32842c7..7bebf676ee 100644 --- a/src/select/base/Select.tsx +++ b/src/select/base/Select.tsx @@ -192,7 +192,6 @@ const Select = forwardRefWithStatics( return; } - const values = currentOptions .filter((option) => !option.checkAll && !option.disabled) .map((option) => option[keys?.value || 'value']); diff --git a/src/tree/Tree.tsx b/src/tree/Tree.tsx index 7b322d6fb9..a641397af7 100644 --- a/src/tree/Tree.tsx +++ b/src/tree/Tree.tsx @@ -67,7 +67,8 @@ const Tree = forwardRef, TreeProps>((origi allowDrop, } = props; - const { value, onChange, expanded, onExpand, onActive, actived } = useControllable(props); + const { value, onChange, expanded, onExpand, onActive, actived, setTreeIndeterminate, indeterminate } = + useControllable(props); // 国际化文本初始化 const emptyText = locale('empty'); @@ -81,6 +82,8 @@ const Tree = forwardRef, TreeProps>((origi onExpand, onActive, actived, + indeterminate, + setTreeIndeterminate, }, initial, ); @@ -104,6 +107,21 @@ const Tree = forwardRef, TreeProps>((origi return expanded; }, ); + + // 因为是被 useImperativeHandle 依赖的方法,使用 usePersistFn 变成持久化的。或者也可以使用 useCallback + const setIndeterminate = usePersistFn( + ( + node: TreeNode, + isIndeterminate: boolean, + ctx: { e?: MouseEvent; trigger: 'node-click' | 'icon-click' | 'setItem' }, + ) => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { e, trigger } = ctx; + const indeterminate = node.setIndeterminate(isIndeterminate); + return indeterminate; + }, + ); + const treeRef = useRef(null); const { @@ -254,11 +272,17 @@ const Tree = forwardRef, TreeProps>((origi setChecked(node, spec.checked, { trigger: 'setItem' }); delete spec.checked; } + if ('indeterminate' in options) { + // @ts-ignore + setTreeIndeterminate((prevIndeterminate: TreeNodeValue[]) => [...prevIndeterminate, value]); + setIndeterminate(node, spec.indeterminate, { trigger: 'setItem' }); + delete spec.indeterminate; + } node.set(spec); } }, }), - [store, setExpanded, setActived, setChecked, handleScrollToElement], + [store, setExpanded, setActived, setTreeIndeterminate, setChecked, setIndeterminate, handleScrollToElement], ); /* ======== render ======= */ diff --git a/src/tree/hooks/useControllable.ts b/src/tree/hooks/useControllable.ts index 2286e775fa..a4185ccef0 100644 --- a/src/tree/hooks/useControllable.ts +++ b/src/tree/hooks/useControllable.ts @@ -1,15 +1,24 @@ +import { useState } from 'react'; import useControlled from '../../hooks/useControlled'; import { TdTreeProps } from '../type'; +import type { TreeNodeValue } from '../../_common/js/tree-v1/types'; -export default function useControllable( - props: TdTreeProps, -): Pick { +export default function useControllable(props: TdTreeProps): Pick< + TdTreeProps, + 'value' | 'onChange' | 'expanded' | 'onExpand' | 'actived' | 'onActive' +> & { + setTreeIndeterminate: (value: Array) => void; + indeterminate: Array; +} { const [value, onChange] = useControlled(props, 'value', props.onChange); const [expanded, onExpand] = useControlled(props, 'expanded', props.onExpand); const [actived, onActive] = useControlled(props, 'actived', props.onActive); + // Indeterminate state + const [indeterminate, setTreeIndeterminate] = useState([]); + return { value, onChange, @@ -17,5 +26,7 @@ export default function useControllable( onExpand, actived, onActive, + setTreeIndeterminate, + indeterminate, }; } diff --git a/src/tree/hooks/useStore.ts b/src/tree/hooks/useStore.ts index 613809aab5..0e6826a127 100644 --- a/src/tree/hooks/useStore.ts +++ b/src/tree/hooks/useStore.ts @@ -7,9 +7,13 @@ import { usePersistFn } from '../../hooks/usePersistFn'; import type { TdTreeProps } from '../type'; import type { TypeEventState } from '../interface'; -import type { TypeTreeNodeData } from '../../_common/js/tree-v1/types'; +import type { TreeNodeValue, TypeTreeNodeData } from '../../_common/js/tree-v1/types'; +import TreeNode from '../../_common/js/tree-v1/tree-node'; -export function useStore(props: TdTreeProps, refresh: () => void): TreeStore { +export function useStore( + props: TdTreeProps & { indeterminate: any; setTreeIndeterminate: any }, + refresh: () => void, +): TreeStore { const storeRef = useRef(); const [filterChanged, toggleFilterChanged] = useState(false); const [prevExpanded, changePrevExpanded] = useState(null); @@ -34,6 +38,8 @@ export function useStore(props: TdTreeProps, refresh: () => void): TreeStore { valueMode, filter, onLoad, + indeterminate, + setTreeIndeterminate, allowFoldNodeOnFilter = false, } = props; @@ -129,7 +135,6 @@ export function useStore(props: TdTreeProps, refresh: () => void): TreeStore { // 刷新节点,必须在配置选中之前执行 // 这样选中态联动判断才能找到父节点 store.refreshNodes(); - // 初始化选中状态 if (Array.isArray(value)) { store.setChecked(value); @@ -223,6 +228,11 @@ export function useStore(props: TdTreeProps, refresh: () => void): TreeStore { useUpdateLayoutEffect(() => { if (Array.isArray(value)) { store.replaceChecked(value); + const checkedValue = store.getCheckedNodes().map((v: TreeNode) => v.data[keys?.value || 'value']); + const indeterminateConflict = checkedValue.filter((v) => indeterminate.includes(v)); + if (indeterminateConflict.length) { + setTreeIndeterminate(indeterminate.filter((v: TreeNodeValue) => !indeterminateConflict.includes(v))); + } } }, [store, value, data]); @@ -239,6 +249,12 @@ export function useStore(props: TdTreeProps, refresh: () => void): TreeStore { } }, [actived, store]); + useUpdateLayoutEffect(() => { + if (Array.isArray(indeterminate)) { + store.replaceIndeterminate(indeterminate); + } + }, [indeterminate, store, data]); + useUpdateLayoutEffect(() => { store.setConfig({ filter, From 0cb41bc829866648d33152afdce25d71a3d9c48c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?w=C5=AB=20y=C4=81ng?= Date: Thu, 19 Dec 2024 17:24:46 +0800 Subject: [PATCH 06/61] fix(Select): fix object type select all and callback params (#3287) * fix(Select): fix object type selectall and callback params * chore: comment * chore: comment --- src/select/base/PopupContent.tsx | 5 ++-- src/select/base/Select.tsx | 51 ++++++++++++++++++++++++-------- src/select/util/helper.ts | 17 +++++++++-- 3 files changed, 56 insertions(+), 17 deletions(-) diff --git a/src/select/base/PopupContent.tsx b/src/select/base/PopupContent.tsx index 2bd4a10714..caaaae7182 100644 --- a/src/select/base/PopupContent.tsx +++ b/src/select/base/PopupContent.tsx @@ -30,6 +30,7 @@ interface SelectPopupProps value: SelectValue, context?: { label?: string | number; + value?: SelectValue; restData?: Record; e: React.MouseEvent; trigger: SelectValueChangeTrigger; @@ -109,12 +110,12 @@ const PopupContent = React.forwardRef((props, if (multiple) { // calc multiple select values const values = getSelectValueArr(value, selectedValue, selected, valueType, keys, objVal); - onChange(values, { label, e: event, trigger: 'check' }); + onChange(values, { label, value: selectedValue, e: event, trigger: 'check' }); } else { // calc single select value const selectVal = valueType === 'object' ? objVal : selectedValue; - onChange(selectVal, { label, e: event, trigger: 'check' }); + onChange(selectVal, { label, value: selectVal, e: event, trigger: 'check' }); setShowPopup(!showPopup); } }; diff --git a/src/select/base/Select.tsx b/src/select/base/Select.tsx index 7bebf676ee..e0e3f975b8 100644 --- a/src/select/base/Select.tsx +++ b/src/select/base/Select.tsx @@ -28,7 +28,7 @@ import Option from './Option'; import OptionGroup from './OptionGroup'; import PopupContent from './PopupContent'; import Tag from '../../tag'; -import { TdSelectProps, TdOptionProps, SelectOption, SelectValueChangeTrigger } from '../type'; +import { TdSelectProps, TdOptionProps, SelectOption, SelectValueChangeTrigger, SelectValue } from '../type'; import { StyledProps } from '../../common'; import { selectDefaultProps } from '../defaultProps'; import { PopupVisibleChangeContext } from '../../popup'; @@ -157,7 +157,7 @@ const Select = forwardRefWithStatics( const values = getSelectValueArr(value, value[closest], true, valueType, keys); // 处理onChange回调中的selectedOptions参数 - const currentSelectedOptions = getSelectedOptions(values, multiple, valueType, keys, tmpPropOptions); + const { currentSelectedOptions } = getSelectedOptions(values, multiple, valueType, keys, tmpPropOptions); onChange(values, { e, trigger, selectedOptions: currentSelectedOptions }); return; } @@ -172,7 +172,7 @@ const Select = forwardRefWithStatics( e?.stopPropagation?.(); const values = getSelectValueArr(value, value[index], true, valueType, keys); // 处理onChange回调中的selectedOptions参数 - const currentSelectedOptions = getSelectedOptions(values, multiple, valueType, keys, tmpPropOptions); + const { currentSelectedOptions } = getSelectedOptions(values, multiple, valueType, keys, tmpPropOptions); onChange(values, { e, trigger, selectedOptions: currentSelectedOptions }); if (isFunction(onRemove)) { @@ -194,19 +194,22 @@ const Select = forwardRefWithStatics( const values = currentOptions .filter((option) => !option.checkAll && !option.disabled) - .map((option) => option[keys?.value || 'value']); + .map((option) => (valueType === 'object' ? option : option[keys?.value || 'value'])); - const selectableOptions = getSelectedOptions(values, multiple, valueType, keys, tmpPropOptions); + const { currentSelectedOptions } = getSelectedOptions(values, multiple, valueType, keys, tmpPropOptions); const checkAllValue = - !checkAll && selectableOptions.length !== (props.value as Array)?.length ? selectableOptions : []; + !checkAll && currentSelectedOptions.length !== (props.value as Array)?.length + ? currentSelectedOptions + : []; + onChange?.(checkAllValue, { e, trigger: checkAll ? 'check' : 'uncheck', selectedOptions: checkAllValue }); }; // 选中 Popup 某项 const handleChange = ( value: string | number | Array>, - context: { e: React.MouseEvent; trigger: SelectValueChangeTrigger }, + context: { e: React.MouseEvent; trigger: SelectValueChangeTrigger; value?: SelectValue }, ) => { if (multiple) { !reserveKeyword && inputValue && onInputChange('', { e: context.e, trigger: 'change' }); @@ -217,9 +220,22 @@ const Select = forwardRefWithStatics( } } // 处理onChange回调中的selectedOptions参数 - const currentSelectedOptions = getSelectedOptions(value, multiple, valueType, keys, tmpPropOptions); - - onChange?.(value, { ...context, selectedOptions: currentSelectedOptions }); + const selectedValue = multiple ? context.value : value; + const { currentSelectedOptions, currentOption } = getSelectedOptions( + value, + multiple, + valueType, + keys, + tmpPropOptions, + selectedValue, + ); + + onChange?.(value, { + e: context.e, + trigger: context.trigger, + selectedOptions: currentSelectedOptions, + option: currentOption, + }); }; // 处理filter逻辑 @@ -352,8 +368,19 @@ const Select = forwardRefWithStatics( e.stopPropagation(); const values = getSelectValueArr(value, value[key], true, valueType, keys); - const selectedOptions = getSelectedOptions(values, multiple, valueType, keys, tmpPropOptions); - onChange(values, { e, selectedOptions, trigger: 'uncheck' }); + const { currentSelectedOptions } = getSelectedOptions( + values, + multiple, + valueType, + keys, + tmpPropOptions, + value, + ); + onChange(values, { + e, + selectedOptions: currentSelectedOptions, + trigger: 'uncheck', + }); tagProps?.onClose?.({ e }); onRemove?.({ diff --git a/src/select/util/helper.ts b/src/select/util/helper.ts index 0beb1940e7..4d51d493ad 100644 --- a/src/select/util/helper.ts +++ b/src/select/util/helper.ts @@ -4,7 +4,7 @@ import get from 'lodash/get'; import OptionGroup from '../base/OptionGroup'; import Option from '../base/Option'; -import { SelectValue, TdOptionProps, SelectKeysType, TdSelectProps } from '../type'; +import { SelectValue, TdOptionProps, SelectKeysType, TdSelectProps, SelectOption } from '../type'; type SelectLabeledValue = Required>; @@ -192,17 +192,28 @@ export const getSelectedOptions = ( valueType: TdSelectProps['valueType'], keys: SelectKeysType, tmpPropOptions: Array, + selectedValue?: SelectValue, ) => { const isObjectType = valueType === 'object'; + // 当前所有选中的选项 let currentSelectedOptions = []; + // 当前选中的选项 + let currentOption: SelectOption; if (multiple) { currentSelectedOptions = isObjectType - ? (value as Array) + ? (value as Array) : tmpPropOptions?.filter?.((v) => (value as Array).includes?.(v[keys?.value || 'value'])); + currentOption = isObjectType + ? (value as Array).find((v) => v[keys?.value || 'value'] === selectedValue) + : currentSelectedOptions.find((option) => option[keys?.value || 'value'] === selectedValue); } else { currentSelectedOptions = isObjectType ? [value] : tmpPropOptions?.filter?.((v) => value === v[keys?.value || 'value']) || []; + currentOption = isObjectType + ? value + : currentSelectedOptions.find((option) => option[keys?.value || 'value'] === selectedValue); } - return currentSelectedOptions; + + return { currentSelectedOptions, currentOption }; }; From e430b52ebc88259dbaff815b9b8411b6bd08a1ac Mon Sep 17 00:00:00 2001 From: Haixing <65376724+HaixingOoO@users.noreply.github.com> Date: Thu, 19 Dec 2024 18:01:58 +0800 Subject: [PATCH 07/61] release:1.10.2 (#3288) * release/1.10.2 * chore: changelog's changes --------- Co-authored-by: github-actions[bot] --- CHANGELOG.md | 30 ++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c57c2720de..3ef8201f8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,36 @@ toc: false spline: explain --- +## 🌈 1.10.2 `2024-12-19` + +### 🚀 Features + +- `Alert`: 在 `maxLine >= message` 数组长度的情况下,不再展示 `展开更多/收起` 的按钮 @miownag ([#3281](https://github.com/Tencent/tdesign-react/pull/3281)) +- `ConfigProvider`: `attach` 属性支持配置 `drawer` 组件,支持全局配置`drawer`的挂载位置 @HaixingOoO ([#3272](https://github.com/Tencent/tdesign-react/pull/3272)) +- `DatePicker`: 多选模式支持周选择和年选择的场景 @HaixingOoO @uyarn ([#3264](https://github.com/Tencent/tdesign-react/pull/3264)) +- `Form`: 新增`supportNumberKey` API,支持在`1.9.3`版本后不支持数字键值的场景使用,若不需要支持数字类型作为表单键值请关闭此 API @uyarn ([#3277](https://github.com/Tencent/tdesign-react/pull/3277)) +- `Radio`: 新增 `Radio` 及 `RadioGroup` 的 `reaonly`属性的支持 @liweijie0812 ([#3280](https://github.com/Tencent/tdesign-react/pull/3280)) +- `Tree`: 实例新增 `setIndeterminate` 方法,支持手动设置半选的功能 @uyarn ([#3261](https://github.com/Tencent/tdesign-react/pull/3261)) +- `label`: `DatePicker`、`TimePicker`、`RangeInput`支持`label` API @liweijie0812 ([#3276](https://github.com/Tencent/tdesign-react/pull/3276)) + +### 🐞 Bug Fixes + +- `DateRangePicker`: 修复日期区间选择器在跨年的场景下的展示异常问题 @huangchen1031 ([#3275](https://github.com/Tencent/tdesign-react/pull/3275)) +- `Menu`: 优化菜单项点击事件的绑定问题避免边界触发异常的问题 @huangchen1031 ([#3241](https://github.com/Tencent/tdesign-react/pull/3241)) +- `ImageViewer`: 修复不受控时,`visable`改变时都会触发`onClose`的问题 @HaixingOoO ([#3244](https://github.com/Tencent/tdesign-react/pull/3244)) +- `CheckboxGroup`: 修复复选框组的子元素不是复选框导致的问题 @HaixingOoO ([#3253](https://github.com/Tencent/tdesign-react/pull/3253)) +- `Form`: 修复`1.9.3`版本后,多级表单字段使用 `setFieldValues` 功能异常的问题 @l123wx ([#3279](https://github.com/Tencent/tdesign-react/pull/3279)) +- `Form`: 修复当规则为 `value: [{ min: 0 }]` 时,验证不生效的问题 @RSS1102 ([#3283](https://github.com/Tencent/tdesign-react/pull/3283)) +- `Select`: 修复 `valueType` 为 `object`选中全选的展示异常及回调参数缺少的问题 @uyarn ([#3287](https://github.com/Tencent/tdesign-react/pull/3287)) +- `SelectInput`: 修复没有 `label` 都会渲染节点导致垂直对齐的问题 @huangchen1031 ([#3278](https://github.com/Tencent/tdesign-react/pull/3278)) +- `TextArea`: 优化 `TextArea` 初始化时 `autosize` 下计算高度的逻辑 @HaixingOoO ([#3286](https://github.com/Tencent/tdesign-react/pull/3286)) + +### 🚧 Others +- `Alert`: 优化测试用例代码类型和添加对于 `className`、`style` 的测试 @RSS1102 ([#3284](https://github.com/Tencent/tdesign-react/pull/3284)) + + + + ## 🌈 1.10.1 `2024-11-28` ### 🚀 Features - `DatePicker`: 新增`multiple` API,用于支持日期选择器多选功能,具体使用请参考示例 @HaixingOoO ([#3199](https://github.com/Tencent/tdesign-react/pull/3199)) diff --git a/package.json b/package.json index 0279e72c62..26bdb95795 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tdesign-react", "purename": "tdesign", - "version": "1.10.1", + "version": "1.10.2", "description": "TDesign Component for React", "title": "tdesign-react", "main": "lib/index.js", From 02d14d0e930c961d3d34afb7cddef9f5c36707af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?w=C5=AB=20y=C4=81ng?= Date: Thu, 19 Dec 2024 18:22:07 +0800 Subject: [PATCH 08/61] chore: fix build (#3289) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ef8201f8a..e634fcc4b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ spline: explain - `ImageViewer`: 修复不受控时,`visable`改变时都会触发`onClose`的问题 @HaixingOoO ([#3244](https://github.com/Tencent/tdesign-react/pull/3244)) - `CheckboxGroup`: 修复复选框组的子元素不是复选框导致的问题 @HaixingOoO ([#3253](https://github.com/Tencent/tdesign-react/pull/3253)) - `Form`: 修复`1.9.3`版本后,多级表单字段使用 `setFieldValues` 功能异常的问题 @l123wx ([#3279](https://github.com/Tencent/tdesign-react/pull/3279)) -- `Form`: 修复当规则为 `value: [{ min: 0 }]` 时,验证不生效的问题 @RSS1102 ([#3283](https://github.com/Tencent/tdesign-react/pull/3283)) +- `Form`: 修复当规则为中涉及 `0` 判断时,验证不生效的问题 @RSS1102 ([#3283](https://github.com/Tencent/tdesign-react/pull/3283)) - `Select`: 修复 `valueType` 为 `object`选中全选的展示异常及回调参数缺少的问题 @uyarn ([#3287](https://github.com/Tencent/tdesign-react/pull/3287)) - `SelectInput`: 修复没有 `label` 都会渲染节点导致垂直对齐的问题 @huangchen1031 ([#3278](https://github.com/Tencent/tdesign-react/pull/3278)) - `TextArea`: 优化 `TextArea` 初始化时 `autosize` 下计算高度的逻辑 @HaixingOoO ([#3286](https://github.com/Tencent/tdesign-react/pull/3286)) From a2e730d1df8327350cc6167a17904bb58ed0981d Mon Sep 17 00:00:00 2001 From: huangchen1031 Date: Fri, 20 Dec 2024 13:45:28 +0800 Subject: [PATCH 09/61] =?UTF-8?q?fix(upload):=20=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=9B=BE=E7=89=87=E5=B1=95=E7=A4=BA=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E4=BC=98=E5=8C=96=20(#3290)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(upload): 上传组件图片展示样式优化 * chore: update snapshot --------- Co-authored-by: github-actions[bot] --- .../__snapshots__/vitest-upload.test.jsx.snap | 6 +++--- src/upload/themes/ImageCard.tsx | 8 +++++++- src/upload/themes/MultipleFlowList.tsx | 8 +++++++- test/snap/__snapshots__/csr.test.jsx.snap | 18 +++++++++--------- test/snap/__snapshots__/ssr.test.jsx.snap | 6 +++--- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/upload/__tests__/__snapshots__/vitest-upload.test.jsx.snap b/src/upload/__tests__/__snapshots__/vitest-upload.test.jsx.snap index 004849975e..e810930a89 100644 --- a/src/upload/__tests__/__snapshots__/vitest-upload.test.jsx.snap +++ b/src/upload/__tests__/__snapshots__/vitest-upload.test.jsx.snap @@ -879,7 +879,7 @@ exports[`Upload Component > props.theme: theme=image-flow works fine 1`] = ` class="t-image__wrapper t-image__wrapper--shape-square t-upload__card-image" >
props.theme: theme=image-flow works fine 1`] = ` class="t-image__wrapper t-image__wrapper--shape-square t-upload__card-image" >
props.theme: theme=image-flow works fine 1`] = ` class="t-image__wrapper t-image__wrapper--shape-square t-upload__card-image" >
{ const renderMainContent = (file: UploadFile, index: number) => (
- +
e.stopPropagation()}> {
)} {(['waiting', 'success'].includes(file.status) || (!file.status && file.url)) && ( - + )}
{(file.url || file.raw) && !['progress', 'fail'].includes(file.status) && ( diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index b8ea2bc8c1..812b610844 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -43515,7 +43515,7 @@ exports[`csr snapshot test > csr test src/form/_example/disabled.tsx 1`] = ` class="t-image__wrapper t-image__wrapper--shape-square t-upload__card-image" >
csr test src/upload/_example/image.tsx 1`] = ` class="t-image__wrapper t-image__wrapper--shape-square t-upload__card-image" >
csr test src/upload/_example/img-flow-list.tsx 1`] class="t-image__wrapper t-image__wrapper--shape-square t-upload__card-image" >
csr test src/upload/_example/img-flow-list.tsx 1`] class="t-image__wrapper t-image__wrapper--shape-square t-upload__card-image" >
csr test src/upload/_example/img-flow-list.tsx 1`] class="t-image__wrapper t-image__wrapper--shape-square t-upload__card-image" >
csr test src/upload/_example/img-flow-list.tsx 1`] class="t-image__wrapper t-image__wrapper--shape-square t-upload__card-image" >
ssr test src/form/_example/custom-validator.tsx 1`] exports[`ssr snapshot test > ssr test src/form/_example/customized-form-controls.tsx 1`] = `"
:
"`; -exports[`ssr snapshot test > ssr test src/form/_example/disabled.tsx 1`] = `"
:
:
:
:
:
:
:
:
:
:
:
请选择单张图片文件上传
提交
重置
"`; +exports[`ssr snapshot test > ssr test src/form/_example/disabled.tsx 1`] = `"
:
:
:
:
:
:
:
:
:
:
:
请选择单张图片文件上传
提交
重置
"`; exports[`ssr snapshot test > ssr test src/form/_example/error-message.tsx 1`] = `"
一句话介绍自己
"`; @@ -135450,9 +135450,9 @@ exports[`ssr snapshot test > ssr test src/upload/_example/draggable.tsx 1`] = `" exports[`ssr snapshot test > ssr test src/upload/_example/file-flow-list.tsx 1`] = `"

支持批量上传文件,文件格式不限,最多只能上传 10 份文件
Click "Upload" or Drag file to this area to upload
Cancel
Upload
"`; -exports[`ssr snapshot test > ssr test src/upload/_example/image.tsx 1`] = `"

  • 请选择图片

请选择单张图片文件上传(上传成功状态演示)
  • Click to upload

单张图片文件上传(上传失败状态演示)
  • Click to upload

允许选择多张图片文件上传,最多只能上传 3 张图片
"`; +exports[`ssr snapshot test > ssr test src/upload/_example/image.tsx 1`] = `"

  • 请选择图片

请选择单张图片文件上传(上传成功状态演示)
  • Click to upload

单张图片文件上传(上传失败状态演示)
  • Click to upload

允许选择多张图片文件上传,最多只能上传 3 张图片
"`; -exports[`ssr snapshot test > ssr test src/upload/_example/img-flow-list.tsx 1`] = `"
AutoUpload

支持批量上传图片文件
  • demo…-1.png

  • avatar.jpg

取消上传

Different Status Images
  • loading.svg

  • loading.svg

  • Uploading

    loading.svg

  • Failed

    loading.svg

"`; +exports[`ssr snapshot test > ssr test src/upload/_example/img-flow-list.tsx 1`] = `"
AutoUpload

支持批量上传图片文件
  • demo…-1.png

  • avatar.jpg

取消上传

Different Status Images
  • loading.svg

  • loading.svg

  • Uploading

    loading.svg

  • Failed

    loading.svg

"`; exports[`ssr snapshot test > ssr test src/upload/_example/request-method.tsx 1`] = `"
自定义上传方法需要返回成功或失败信息
"`; diff --git a/test/snap/__snapshots__/ssr.test.jsx.snap b/test/snap/__snapshots__/ssr.test.jsx.snap index 4876c2d2c9..754a7d3644 100644 --- a/test/snap/__snapshots__/ssr.test.jsx.snap +++ b/test/snap/__snapshots__/ssr.test.jsx.snap @@ -410,7 +410,7 @@ exports[`ssr snapshot test > ssr test src/form/_example/custom-validator.tsx 1`] exports[`ssr snapshot test > ssr test src/form/_example/customized-form-controls.tsx 1`] = `"
:
"`; -exports[`ssr snapshot test > ssr test src/form/_example/disabled.tsx 1`] = `"
:
:
:
:
:
:
:
:
:
:
:
请选择单张图片文件上传
提交
重置
"`; +exports[`ssr snapshot test > ssr test src/form/_example/disabled.tsx 1`] = `"
:
:
:
:
:
:
:
:
:
:
:
请选择单张图片文件上传
提交
重置
"`; exports[`ssr snapshot test > ssr test src/form/_example/error-message.tsx 1`] = `"
一句话介绍自己
"`; @@ -1224,9 +1224,9 @@ exports[`ssr snapshot test > ssr test src/upload/_example/draggable.tsx 1`] = `" exports[`ssr snapshot test > ssr test src/upload/_example/file-flow-list.tsx 1`] = `"

支持批量上传文件,文件格式不限,最多只能上传 10 份文件
Click "Upload" or Drag file to this area to upload
Cancel
Upload
"`; -exports[`ssr snapshot test > ssr test src/upload/_example/image.tsx 1`] = `"

  • 请选择图片

请选择单张图片文件上传(上传成功状态演示)
  • Click to upload

单张图片文件上传(上传失败状态演示)
  • Click to upload

允许选择多张图片文件上传,最多只能上传 3 张图片
"`; +exports[`ssr snapshot test > ssr test src/upload/_example/image.tsx 1`] = `"

  • 请选择图片

请选择单张图片文件上传(上传成功状态演示)
  • Click to upload

单张图片文件上传(上传失败状态演示)
  • Click to upload

允许选择多张图片文件上传,最多只能上传 3 张图片
"`; -exports[`ssr snapshot test > ssr test src/upload/_example/img-flow-list.tsx 1`] = `"
AutoUpload

支持批量上传图片文件
  • demo…-1.png

  • avatar.jpg

取消上传

Different Status Images
  • loading.svg

  • loading.svg

  • Uploading

    loading.svg

  • Failed

    loading.svg

"`; +exports[`ssr snapshot test > ssr test src/upload/_example/img-flow-list.tsx 1`] = `"
AutoUpload

支持批量上传图片文件
  • demo…-1.png

  • avatar.jpg

取消上传

Different Status Images
  • loading.svg

  • loading.svg

  • Uploading

    loading.svg

  • Failed

    loading.svg

"`; exports[`ssr snapshot test > ssr test src/upload/_example/request-method.tsx 1`] = `"
自定义上传方法需要返回成功或失败信息
"`; From fffe54a43c56c35586285a1874f079ed099b2ee0 Mon Sep 17 00:00:00 2001 From: Haixing <65376724+HaixingOoO@users.noreply.github.com> Date: Tue, 24 Dec 2024 00:32:26 +0800 Subject: [PATCH 10/61] feat(tree): add Tree onScroll api (#3295) * feat(tree): add Tree onScroll api * chore(tree): adjustment onScroll * perf(tree): code clean * perf(tree): code perf --- src/tree/Tree.tsx | 2 ++ src/tree/hooks/useTreeVirtualScroll.ts | 21 +++++++++++---------- src/tree/type.ts | 4 ++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/tree/Tree.tsx b/src/tree/Tree.tsx index a641397af7..83c019a1c3 100644 --- a/src/tree/Tree.tsx +++ b/src/tree/Tree.tsx @@ -65,6 +65,7 @@ const Tree = forwardRef, TreeProps>((origi className, style, allowDrop, + onScroll, } = props; const { value, onChange, expanded, onExpand, onActive, actived, setTreeIndeterminate, indeterminate } = @@ -135,6 +136,7 @@ const Tree = forwardRef, TreeProps>((origi treeRef, scroll, data: visibleNodes, + onScroll, }); const setActived = usePersistFn( diff --git a/src/tree/hooks/useTreeVirtualScroll.ts b/src/tree/hooks/useTreeVirtualScroll.ts index 8f6662f44f..17a077be0e 100644 --- a/src/tree/hooks/useTreeVirtualScroll.ts +++ b/src/tree/hooks/useTreeVirtualScroll.ts @@ -2,15 +2,19 @@ import { useMemo, useEffect, CSSProperties } from 'react'; import useVirtualScroll from '../../hooks/useVirtualScroll'; import TreeNode from '../../_common/js/tree-v1/tree-node'; import { TScroll } from '../../common'; +import type { TdTreeProps } from '../type'; +import useEventCallback from '../../hooks/useEventCallback'; export default function useTreeVirtualScroll({ treeRef, scroll, data = [], + onScroll, }: { data: TreeNode[]; scroll: TScroll; treeRef: React.MutableRefObject; + onScroll: TdTreeProps['onScroll']; }) { const scrollThreshold = scroll?.threshold || 100; const scrollType = scroll?.type; @@ -45,7 +49,8 @@ export default function useTreeVirtualScroll({ }); let lastScrollY = -1; - const onInnerVirtualScroll = (e: WheelEvent) => { + const onInnerVirtualScroll = useEventCallback((e: WheelEvent) => { + onScroll?.({ e }); if (!isVirtual) { return; } @@ -58,21 +63,17 @@ export default function useTreeVirtualScroll({ lastScrollY = -1; } lastScrollY = top; - }; + }); useEffect(() => { const treeList = treeRef?.current; - if (isVirtual) { - treeList?.addEventListener?.('scroll', onInnerVirtualScroll); - } + treeList?.addEventListener?.('scroll', onInnerVirtualScroll); + return () => { // 卸载时取消监听 - if (isVirtual) { - treeList?.removeEventListener?.('scroll', onInnerVirtualScroll); - } + treeList?.removeEventListener?.('scroll', onInnerVirtualScroll); }; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [isVirtual, onInnerVirtualScroll]); + }, [treeRef, onInnerVirtualScroll]); const cursorStyle = { position: 'absolute', diff --git a/src/tree/type.ts b/src/tree/type.ts index deba736d66..582267f1ed 100644 --- a/src/tree/type.ts +++ b/src/tree/type.ts @@ -6,7 +6,7 @@ import { CheckboxProps } from '../checkbox'; import { TNode, TreeOptionData, TScroll, ComponentScrollToElementParams } from '../common'; -import { MouseEvent, WheelEvent, DragEvent } from 'react'; +import { MouseEvent, DragEvent } from 'react'; export interface TdTreeProps { /** @@ -238,7 +238,7 @@ export interface TdTreeProps { /** * 滚动事件 */ - onScroll?: (params: { e: WheelEvent }) => void; + onScroll?: (params: { e: WheelEvent }) => void; } /** 组件实例方法 */ From 49e7019e46d80ff7654dca6f41a7afe1095d9ff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?w=C5=AB=20y=C4=81ng?= Date: Tue, 24 Dec 2024 17:18:35 +0800 Subject: [PATCH 11/61] chore: fix box demo start up (#3297) * fix: upgrade stackblitz demo * chore: fix box demo --- site/src/components/stackblitz/content.js | 69 ++++++++++++++++++----- site/src/components/stackblitz/index.jsx | 30 +++++++--- src/form/_example/form-field-linkage.tsx | 4 +- 3 files changed, 80 insertions(+), 23 deletions(-) diff --git a/site/src/components/stackblitz/content.js b/site/src/components/stackblitz/content.js index c70c8b56d6..21ebbe5e95 100644 --- a/site/src/components/stackblitz/content.js +++ b/site/src/components/stackblitz/content.js @@ -1,18 +1,26 @@ import orgPkg from '../../../../package.json'; export const htmlContent = ` -
+
+ `; export const mainJsContent = ` - import React from 'react'; - import ReactDOM from 'react-dom'; + import React, { StrictMode } from 'react'; + import { createRoot } from 'react-dom/client'; + import Demo from './demo'; import './index.css'; import 'tdesign-react/dist/tdesign.css'; const rootElement = document.getElementById('app'); - ReactDOM.render(, rootElement); + const root = createRoot(rootElement); + + root.render( + + + , + ); `; export const styleContent = ` @@ -66,12 +74,47 @@ export const tsconfigContent = `{ } `; -export const dependenciesContent = JSON.stringify({ - 'tdesign-react': orgPkg.version, - 'tdesign-icons-react': orgPkg.dependencies['tdesign-icons-react'], - dayjs: orgPkg.dependencies.dayjs, - react: orgPkg.devDependencies.react, - 'react-dom': orgPkg.devDependencies['react-dom'], - '@types/react': orgPkg.devDependencies['@types/react'], - '@types/react-dom': orgPkg.devDependencies['@types/react-dom'], -}); +export const stackblitzRc = ` + { + "installDependencies": true, + "startCommand": "npm run dev" + } +`; + +export const viteConfigContent = ` + import { defineConfig } from 'vite'; + import react from '@vitejs/plugin-react'; + + export default defineConfig({ + plugins: [react()], + }); +`; + +export const packageJSONContent = JSON.stringify( + { + name: 'tdesign-react-demo', + version: '0.0.0', + private: true, + scripts: { + dev: 'vite', + build: 'vite build', + serve: 'vite preview', + }, + dependencies: { + react: orgPkg.devDependencies.react, + dayjs: orgPkg.dependencies.dayjs, + 'react-dom': orgPkg.devDependencies['react-dom'], + 'tdesign-react': orgPkg.version, + 'tdesign-icons-react': orgPkg.dependencies['tdesign-icons-react'], + '@types/react': orgPkg.devDependencies['@types/react'], + '@types/react-dom': orgPkg.devDependencies['@types/react-dom'], + }, + devDependencies: { + vite: orgPkg.devDependencies.vite, + '@vitejs/plugin-react': orgPkg.devDependencies['@vitejs/plugin-react'], + typescript: orgPkg.devDependencies.typescript, + }, + }, + null, + 2, +); diff --git a/site/src/components/stackblitz/index.jsx b/site/src/components/stackblitz/index.jsx index 2e2b6b4502..2a4c118fcb 100644 --- a/site/src/components/stackblitz/index.jsx +++ b/site/src/components/stackblitz/index.jsx @@ -1,7 +1,15 @@ import React, { useRef, useState } from 'react'; import Tooltip from 'tdesign-react/tooltip'; -import { htmlContent, mainJsContent, styleContent, dependenciesContent, tsconfigContent } from './content'; +import { + htmlContent, + mainJsContent, + styleContent, + tsconfigContent, + viteConfigContent, + packageJSONContent, + stackblitzRc, +} from './content'; const TypeScriptType = 0; @@ -23,20 +31,28 @@ export default function Stackblitz(props) { return ( -
+ {isTypeScriptDemo ? ( <> - + ) : ( )} - - - - + + + + + +
diff --git a/src/form/_example/form-field-linkage.tsx b/src/form/_example/form-field-linkage.tsx index 69f7790e74..5eee192845 100644 --- a/src/form/_example/form-field-linkage.tsx +++ b/src/form/_example/form-field-linkage.tsx @@ -1,7 +1,5 @@ import React from 'react'; -import Form from '../Form'; -import Radio from '../../radio'; -import Button from '../../button'; +import { Form, Radio, Button } from 'tdesign-react'; const { FormItem } = Form; From 39b9139b6c7be3511b4343ba9dc75e72ed750064 Mon Sep 17 00:00:00 2001 From: moecasts <37169906+moecasts@users.noreply.github.com> Date: Wed, 25 Dec 2024 00:03:58 +0800 Subject: [PATCH 12/61] =?UTF-8?q?feat(tooltip):=20tooltip-lite=20mouse=20?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E8=B7=9F=E9=9A=8F=E9=BC=A0=E6=A0=87=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=20(#3267)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #3225 --- src/_common | 2 +- src/tooltip/TooltipLite.tsx | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/_common b/src/_common index 53786c5875..4aca77834a 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 53786c58752401e648cc45918f2a4dbb9e8cecfa +Subproject commit 4aca77834aace03d2fa17573c232584e781366f0 diff --git a/src/tooltip/TooltipLite.tsx b/src/tooltip/TooltipLite.tsx index bc5368435b..0aafc13f36 100644 --- a/src/tooltip/TooltipLite.tsx +++ b/src/tooltip/TooltipLite.tsx @@ -1,6 +1,7 @@ -import React, { ReactNode, useState, useRef, useEffect } from 'react'; +import React, { ReactNode, useState, useRef, useEffect, useCallback } from 'react'; import classnames from 'classnames'; import { CSSTransition } from 'react-transition-group'; +import throttle from 'lodash/throttle'; import { StyledProps } from '../common'; import useSwitch from '../hooks/useSwitch'; import useAnimation from '../hooks/useAnimation'; @@ -27,26 +28,39 @@ const TooltipLite: React.FC = (originalProps) => { const { classPrefix } = useConfig(); const [hover, hoverAction] = useSwitch(); const [clientX, setHoverClientX] = useState(0); + const [clientY, setHoverClientY] = useState(0); const [position, setPosition] = useState(null); const { keepFade } = useAnimation(); useEffect(() => { if (triggerRef.current && contentRef.current) { - setPosition(getPosition(triggerRef.current, contentRef.current, placement, clientX)); + setPosition(getPosition(triggerRef.current, contentRef.current, placement, clientX, clientY)); } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [triggerRef.current, contentRef.current, placement, hover]); + }, [triggerRef.current, contentRef.current, placement, hover, clientX, clientY]); - const onSwitchHover = (action: String, e: MouseEvent) => { + const updatePosition = (e: MouseEvent) => { setHoverClientX(e.clientX); + setHoverClientY(e.clientY); + }; + + const onSwitchHover = (action: String, e: MouseEvent) => { + updatePosition(e); hoverAction.set(action === 'on'); }; const showTipArrow = showArrow && placement !== 'mouse'; + // eslint-disable-next-line react-hooks/exhaustive-deps + const onSwitchMove = useCallback( + throttle((e) => updatePosition(e), 16.7, { trailing: true }), + [], + ); + const getTriggerChildren = (children) => { const appendProps = { ref: triggerRef, + onMouseMove: onSwitchMove, onMouseEnter: (e) => onSwitchHover('on', e), onMouseLeave: (e) => onSwitchHover('off', e), }; From 2b79edb364ba0554c83e18367e685879479a5e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?w=C5=AB=20y=C4=81ng?= Date: Wed, 25 Dec 2024 18:45:35 +0800 Subject: [PATCH 13/61] fix(Select): fix checkall default value (#3298) --- src/select/util/helper.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/select/util/helper.ts b/src/select/util/helper.ts index 4d51d493ad..09a46b51cc 100644 --- a/src/select/util/helper.ts +++ b/src/select/util/helper.ts @@ -202,7 +202,9 @@ export const getSelectedOptions = ( if (multiple) { currentSelectedOptions = isObjectType ? (value as Array) - : tmpPropOptions?.filter?.((v) => (value as Array).includes?.(v[keys?.value || 'value'])); + : tmpPropOptions + ?.filter?.((v) => (value as Array).includes?.(v[keys?.value || 'value'])) + .map((v) => v[keys?.value || 'value']); currentOption = isObjectType ? (value as Array).find((v) => v[keys?.value || 'value'] === selectedValue) : currentSelectedOptions.find((option) => option[keys?.value || 'value'] === selectedValue); From 469e666708bd2c1615bf90d1b1b7195ac9be51e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?w=C5=AB=20y=C4=81ng?= Date: Wed, 25 Dec 2024 19:03:03 +0800 Subject: [PATCH 14/61] chore: release 1.10.3 (#3299) * chore: release 1.10.3 * chore: changelog's changes --------- Co-authored-by: github-actions[bot] --- CHANGELOG.md | 12 ++++++++++++ package.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e634fcc4b1..b2d7f771ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,18 @@ toc: false spline: explain --- +## 🌈 1.10.3 `2024-12-25` +### 🚀 Features +- `Tree`: 支持 `onScroll` API,用于处理滚动事件回调 @HaixingOoO ([#3295](https://github.com/Tencent/tdesign-react/pull/3295)) +- `Tooltip`: tooltip-lite 的`mouse` 模式下优化为完全跟随鼠标位置,更符合 API 描述 @moecasts ([#3267](https://github.com/Tencent/tdesign-react/pull/3267)) +### 🐞 Bug Fixes +- `Select`: 修复全选默认返回值错误的问题 @uyarn ([#3298](https://github.com/Tencent/tdesign-react/pull/3298)) +- `Upload`: 优化部分尺寸上传组件图片展示的样式问题 @huangchen1031 ([#3290](https://github.com/Tencent/tdesign-react/pull/3290)) +### 📝 Documentation +- `Stackblitz`: 调整`Stackblitz`示例的启动方式,并修复部分示例无法使用`stackblitz`或`codesandbox`运行的问题 @uyarn ([#3297](https://github.com/Tencent/tdesign-react/pull/3297)) + + + ## 🌈 1.10.2 `2024-12-19` ### 🚀 Features diff --git a/package.json b/package.json index 26bdb95795..569f41963a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tdesign-react", "purename": "tdesign", - "version": "1.10.2", + "version": "1.10.3", "description": "TDesign Component for React", "title": "tdesign-react", "main": "lib/index.js", From 9b74c848e6ce563fd7bd865362a4f6ad41f3573f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?w=C5=AB=20y=C4=81ng?= Date: Wed, 25 Dec 2024 19:21:03 +0800 Subject: [PATCH 15/61] chore: release 1.10.4 (#3300) * chore: release 1.10.4 * chore: update changelog --- CHANGELOG.md | 2 +- package.json | 2 +- src/select/util/helper.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2d7f771ad..4badc18834 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ toc: false spline: explain --- -## 🌈 1.10.3 `2024-12-25` +## 🌈 1.10.4 `2024-12-25` ### 🚀 Features - `Tree`: 支持 `onScroll` API,用于处理滚动事件回调 @HaixingOoO ([#3295](https://github.com/Tencent/tdesign-react/pull/3295)) - `Tooltip`: tooltip-lite 的`mouse` 模式下优化为完全跟随鼠标位置,更符合 API 描述 @moecasts ([#3267](https://github.com/Tencent/tdesign-react/pull/3267)) diff --git a/package.json b/package.json index 569f41963a..a64a9ce49d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tdesign-react", "purename": "tdesign", - "version": "1.10.3", + "version": "1.10.4", "description": "TDesign Component for React", "title": "tdesign-react", "main": "lib/index.js", diff --git a/src/select/util/helper.ts b/src/select/util/helper.ts index 09a46b51cc..b69fcda2ec 100644 --- a/src/select/util/helper.ts +++ b/src/select/util/helper.ts @@ -207,14 +207,14 @@ export const getSelectedOptions = ( .map((v) => v[keys?.value || 'value']); currentOption = isObjectType ? (value as Array).find((v) => v[keys?.value || 'value'] === selectedValue) - : currentSelectedOptions.find((option) => option[keys?.value || 'value'] === selectedValue); + : currentSelectedOptions?.find((option) => option[keys?.value || 'value'] === selectedValue); } else { currentSelectedOptions = isObjectType ? [value] : tmpPropOptions?.filter?.((v) => value === v[keys?.value || 'value']) || []; currentOption = isObjectType ? value - : currentSelectedOptions.find((option) => option[keys?.value || 'value'] === selectedValue); + : currentSelectedOptions?.find((option) => option[keys?.value || 'value'] === selectedValue); } return { currentSelectedOptions, currentOption }; From 4c45f9dcfc3851938819007e409b0fa3ea60d271 Mon Sep 17 00:00:00 2001 From: Haixing <65376724+HaixingOoO@users.noreply.github.com> Date: Thu, 26 Dec 2024 22:53:18 +0800 Subject: [PATCH 16/61] feat(form): optimize setField same not rerender (#3302) --- src/form/FormItem.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/form/FormItem.tsx b/src/form/FormItem.tsx index 262c7f9969..affa3da3b0 100644 --- a/src/form/FormItem.tsx +++ b/src/form/FormItem.tsx @@ -9,6 +9,7 @@ import { CloseCircleFilledIcon as TdCloseCircleFilledIcon, ErrorCircleFilledIcon as TdErrorCircleFilledIcon, } from 'tdesign-icons-react'; +import isEqual from 'lodash/isEqual'; import { calcFieldValue } from './utils'; import useConfig from '../hooks/useConfig'; import useGlobalIcon from '../hooks/useGlobalIcon'; @@ -165,7 +166,9 @@ const FormItem = forwardRef((originalProps, ref isUpdatedRef.current = true; shouldValidate.current = validate; valueRef.current = newVal; - setFormValue(newVal); + if (!isEqual(formValue, newVal)) { + setFormValue(newVal); + } }; // 初始化 rules,最终以 formItem 上优先级最高 From 1a4d630b03a4f981064ce833c2095d08f75f8972 Mon Sep 17 00:00:00 2001 From: Haixing <65376724+HaixingOoO@users.noreply.github.com> Date: Mon, 30 Dec 2024 13:01:55 +0800 Subject: [PATCH 17/61] feat(radio): radio-group support theme api (#3303) --- src/radio/RadioGroup.tsx | 4 +- src/radio/__tests__/radio.test.tsx | 25 +++- src/radio/_example/group.tsx | 4 +- src/radio/defaultProps.ts | 1 + src/radio/radio.en-US.md | 1 + src/radio/radio.md | 1 + src/radio/type.ts | 5 + test/snap/__snapshots__/csr.test.jsx.snap | 156 +++++++++++----------- test/snap/__snapshots__/ssr.test.jsx.snap | 10 +- 9 files changed, 120 insertions(+), 87 deletions(-) diff --git a/src/radio/RadioGroup.tsx b/src/radio/RadioGroup.tsx index a089c18a34..b56227a204 100644 --- a/src/radio/RadioGroup.tsx +++ b/src/radio/RadioGroup.tsx @@ -27,7 +27,7 @@ const RadioGroup: React.FC = (originalProps) => { const props = useDefaultProps(originalProps, radioGroupDefaultProps); - const { disabled, readonly, children, onChange, size, variant, options = [], className, style } = props; + const { disabled, readonly, children, onChange, size, variant, options = [], className, style, theme } = props; const [internalValue, setInternalValue] = useControlled(props, 'value', onChange); const [barStyle, setBarStyle] = useState({}); @@ -97,7 +97,7 @@ const RadioGroup: React.FC = (originalProps) => { }; const renderOptions = () => { - const Comp = variant.includes('filled') ? Radio.Button : Radio; + const Comp = theme === 'button' ? Radio.Button : Radio; return options.map((item, index) => { let label: ReactNode; let value: string | number | boolean; diff --git a/src/radio/__tests__/radio.test.tsx b/src/radio/__tests__/radio.test.tsx index 896ae94d17..1d439df299 100644 --- a/src/radio/__tests__/radio.test.tsx +++ b/src/radio/__tests__/radio.test.tsx @@ -87,7 +87,7 @@ describe('RadioGroup', () => { options={[{ value: '上海', label: '上海' }, { value: '广州', label: '广州', disabled: true }, '北京', 1]} />, ); - expect(container.firstChild.firstChild).toHaveClass('t-radio-button'); + expect(container.firstChild.firstChild).toHaveClass('t-radio'); }); test('value is string', () => { @@ -111,4 +111,27 @@ describe('RadioGroup', () => { ); expect(container.firstChild.firstChild).toHaveClass('t-is-checked'); }); + + test('theme radio', () => { + const { container } = render( + , + ); + expect(container.firstChild.firstChild).toHaveClass('t-radio'); + }); + + test('theme button', () => { + const { container } = render( + , + ); + expect(container.firstChild.firstChild).toHaveClass('t-radio-button'); + }); }); diff --git a/src/radio/_example/group.tsx b/src/radio/_example/group.tsx index c2a0e1d608..3c4f57de08 100644 --- a/src/radio/_example/group.tsx +++ b/src/radio/_example/group.tsx @@ -43,14 +43,16 @@ export default function RadioExample() { setCity2(val)} /> setCity2(val)} /> - setCity3(val)} /> + setCity3(val)} /> setCity3(val)} diff --git a/src/radio/defaultProps.ts b/src/radio/defaultProps.ts index ff466903e2..15ebd6ca5e 100644 --- a/src/radio/defaultProps.ts +++ b/src/radio/defaultProps.ts @@ -18,4 +18,5 @@ export const radioGroupDefaultProps: TdRadioGroupProps = { readonly: undefined, size: 'medium', variant: 'outline', + theme: 'radio', }; diff --git a/src/radio/radio.en-US.md b/src/radio/radio.en-US.md index 4fbc440d45..30494b4e07 100644 --- a/src/radio/radio.en-US.md +++ b/src/radio/radio.en-US.md @@ -32,6 +32,7 @@ disabled | Boolean | undefined | \- | N name | String | - | \- | N options | Array | - | Typescript:`Array` `type RadioOption = string \| number \| RadioOptionObj` `interface RadioOptionObj { label?: string \| TNode; value?: string \| number \| boolean; disabled?: boolean }`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts)。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/radio/type.ts) | N readonly | Boolean | undefined | \- | N +theme | String | radio | options:radio/button。 | N size | String | medium | options: small/medium/large。Typescript:`SizeEnum`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N value | String / Number / Boolean | - | Typescript:`T` `type RadioValue = string \| number \| boolean`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/radio/type.ts) | N defaultValue | String / Number / Boolean | - | uncontrolled property。Typescript:`T` `type RadioValue = string \| number \| boolean`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/radio/type.ts) | N diff --git a/src/radio/radio.md b/src/radio/radio.md index 42809b5a20..631df32e80 100644 --- a/src/radio/radio.md +++ b/src/radio/radio.md @@ -32,6 +32,7 @@ disabled | Boolean | undefined | 是否禁用全部子单选框。优先级:Ra name | String | - | HTML 元素原生属性 | N options | Array | - | 单选组件按钮形式。RadioOption 数据类型为 string 或 number 时,表示 label 和 value 值相同。TS 类型:`Array` `type RadioOption = string \| number \| RadioOptionObj` `interface RadioOptionObj { label?: string \| TNode; value?: string \| number \| boolean; disabled?: boolean }`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts)。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/radio/type.ts) | N readonly | Boolean | undefined | 只读状态 | N +theme | String | radio | 组件风格,可选项:radio/button。 | N size | String | medium | 组件尺寸【讨论中】。可选项:small/medium/large。TS 类型:`SizeEnum`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N value | String / Number / Boolean | - | 选中的值。TS 类型:`T` `type RadioValue = string \| number \| boolean`。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/radio/type.ts) | N defaultValue | String / Number / Boolean | - | 选中的值。非受控属性。TS 类型:`T` `type RadioValue = string \| number \| boolean`。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/radio/type.ts) | N diff --git a/src/radio/type.ts b/src/radio/type.ts index 1af86f0976..0a6311cd06 100644 --- a/src/radio/type.ts +++ b/src/radio/type.ts @@ -86,6 +86,11 @@ export interface TdRadioGroupProps { * @default medium */ size?: SizeEnum; + /** + * 组件风格 + * @default radio + */ + theme?: 'radio' | 'button'; /** * 选中的值 */ diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index 812b610844..1efe8df9a0 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -38200,69 +38200,69 @@ exports[`csr snapshot test > csr test src/descriptions/_example/column.tsx 1`] = class="t-radio-group t-size-m t-radio-group--filled" > 2
@@ -38530,49 +38530,49 @@ exports[`csr snapshot test > csr test src/descriptions/_example/layout.tsx 1`] = class="t-radio-group t-size-m t-radio-group--filled" >
@@ -38601,49 +38601,49 @@ exports[`csr snapshot test > csr test src/descriptions/_example/layout.tsx 1`] = class="t-radio-group t-size-m t-radio-group--filled" >
@@ -38857,69 +38857,69 @@ exports[`csr snapshot test > csr test src/descriptions/_example/size.tsx 1`] = ` class="t-radio-group t-size-m t-radio-group--filled" >
@@ -40841,69 +40841,69 @@ exports[`csr snapshot test > csr test src/empty/_example/size.tsx 1`] = ` class="t-radio-group t-size-m t-radio-group--filled" >
@@ -69253,82 +69253,82 @@ exports[`csr snapshot test > csr test src/radio/_example/group.tsx 1`] = ` class="t-radio-group t-size-m t-radio-group__outline" >
`; +exports[`csr snapshot test > csr test src/notification/_example/attach.tsx 1`] = ` +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+`; + exports[`csr snapshot test > csr test src/notification/_example/base.tsx 1`] = `
ssr test src/message/_example/methods.tsx 1`] = `"< exports[`ssr snapshot test > ssr test src/message/_example/offset.tsx 1`] = `"
"`; +exports[`ssr snapshot test > ssr test src/notification/_example/attach.tsx 1`] = `"
"`; + exports[`ssr snapshot test > ssr test src/notification/_example/base.tsx 1`] = `"
标题名称
这是一条消息通知
"`; exports[`ssr snapshot test > ssr test src/notification/_example/close-all.tsx 1`] = `"
"`; diff --git a/test/snap/__snapshots__/ssr.test.jsx.snap b/test/snap/__snapshots__/ssr.test.jsx.snap index 2e7ddf50f2..968bc058dd 100644 --- a/test/snap/__snapshots__/ssr.test.jsx.snap +++ b/test/snap/__snapshots__/ssr.test.jsx.snap @@ -660,6 +660,8 @@ exports[`ssr snapshot test > ssr test src/message/_example/methods.tsx 1`] = `"< exports[`ssr snapshot test > ssr test src/message/_example/offset.tsx 1`] = `"
"`; +exports[`ssr snapshot test > ssr test src/notification/_example/attach.tsx 1`] = `"
"`; + exports[`ssr snapshot test > ssr test src/notification/_example/base.tsx 1`] = `"
标题名称
这是一条消息通知
"`; exports[`ssr snapshot test > ssr test src/notification/_example/close-all.tsx 1`] = `"
"`; From 6f1a2f1d8c6e68da26f46c987d43daaaab260074 Mon Sep 17 00:00:00 2001 From: Haixing <65376724+HaixingOoO@users.noreply.github.com> Date: Wed, 8 Jan 2025 14:19:13 +0800 Subject: [PATCH 22/61] feat(Upload): image-card support imageProps (#3317) * feat(upload): image-card support imageProps #3271 * test(upload): update test snap * chore: text starts with lowercase letters --------- Co-authored-by: Heising --- src/upload/__tests__/upload.test.tsx | 35 +++++++++++++++++++++++ src/upload/themes/ImageCard.tsx | 19 +++++++++--- src/upload/type.ts | 5 ++++ src/upload/upload.en-US.md | 1 + src/upload/upload.md | 1 + src/upload/upload.tsx | 3 +- test/snap/__snapshots__/csr.test.jsx.snap | 14 +++++++-- test/snap/__snapshots__/ssr.test.jsx.snap | 4 +-- 8 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 src/upload/__tests__/upload.test.tsx diff --git a/src/upload/__tests__/upload.test.tsx b/src/upload/__tests__/upload.test.tsx new file mode 100644 index 0000000000..5cd19b3f4d --- /dev/null +++ b/src/upload/__tests__/upload.test.tsx @@ -0,0 +1,35 @@ +import React from 'react'; +import { render, vi, mockDelay } from '@test/utils'; +import Upload from '../upload'; + +const files = [ + { + url: 'https://tdesign.gtimg.com/demo/demo-image-1.png', + name: 'default.jpeg', + status: 'success', + }, +]; + +describe('upload 组件测试', () => { + afterEach(() => { + vi.restoreAllMocks(); + }); + + test('imageProps', async () => { + const { container } = render( + , + ); + + await mockDelay(); + expect(container).toBeInTheDocument(); + expect(container.querySelector('.tdesign')).toBeInTheDocument(); + }); +}); diff --git a/src/upload/themes/ImageCard.tsx b/src/upload/themes/ImageCard.tsx index 246add8742..c5167e4988 100644 --- a/src/upload/themes/ImageCard.tsx +++ b/src/upload/themes/ImageCard.tsx @@ -26,16 +26,28 @@ export interface ImageCardUploadProps extends CommonDisplayFileProps { cancelUpload?: (context: { e: MouseEvent; file: UploadFile }) => void; onPreview?: TdUploadProps['onPreview']; showImageFileName?: boolean; + imageProps?: TdUploadProps['imageProps']; } const ImageCard = (props: ImageCardUploadProps) => { - const { displayFiles, locale, classPrefix, multiple, max = 0, onRemove, disabled, fileListDisplay } = props; + const { + displayFiles, + locale, + classPrefix, + multiple, + max = 0, + onRemove, + disabled, + fileListDisplay, + imageProps = {}, + } = props; const { BrowseIcon, DeleteIcon, AddIcon, ErrorCircleFilledIcon } = useGlobalIcon({ AddIcon: TdAddIcon, BrowseIcon: TdBrowseIcon, DeleteIcon: TdDeleteIcon, ErrorCircleFilledIcon: TdErrorCircleFilledIcon, }); + const { className: imageClassName, ...restImageProps } = imageProps; const showTrigger = React.useMemo(() => { if (multiple) { @@ -47,11 +59,10 @@ const ImageCard = (props: ImageCardUploadProps) => { const renderMainContent = (file: UploadFile, index: number) => (
e.stopPropagation()}> diff --git a/src/upload/type.ts b/src/upload/type.ts index ba1f35c4bd..158929e81e 100644 --- a/src/upload/type.ts +++ b/src/upload/type.ts @@ -9,6 +9,7 @@ import { UploadConfig } from '../config-provider/type'; import { ButtonProps } from '../button'; import { PlainObject, TNode, UploadDisplayDragEvents } from '../common'; import { CSSProperties, MouseEvent, DragEvent } from 'react'; +import { ImageProps } from '../image'; export interface TdUploadProps { /** @@ -100,6 +101,10 @@ export interface TdUploadProps { * 设置上传的请求头部,`action` 存在时有效 */ headers?: { [key: string]: string }; + /** + * 用于在上传图片场景下,透传属性配置至 Image 组件 + */ + imageProps?: ImageProps; /** * 透传图片预览组件全部属性 */ diff --git a/src/upload/upload.en-US.md b/src/upload/upload.en-US.md index 9242e0f84d..182d3d707c 100644 --- a/src/upload/upload.en-US.md +++ b/src/upload/upload.en-US.md @@ -27,6 +27,7 @@ format | Function | - | to redefine `UploadFile` data structure。Typescript: formatRequest | Function | - | redefine request data。Typescript:`(requestData: { [key: string]: any }) => { [key: string]: any }` | N formatResponse | Function | - | redefine response data structure。Typescript:`(response: any, context: FormatResponseContext) => ResponseType ` `type ResponseType = { error?: string; url?: string; status?: 'fail' \| 'success'; files?: UploadFile[] } & Record` `interface FormatResponseContext { file: UploadFile; currentFiles?: UploadFile[] }`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/upload/type.ts) | N headers | Object | - | HTTP Request Header。Typescript:`{[key: string]: string}` | N +imageProps | Object | - | \- | N imageViewerProps | Object | - | ImageViewer Component Props。Typescript:`ImageViewerProps`,[ImageViewer API Documents](./image-viewer?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/upload/type.ts) | N inputAttributes | Object | - | add attributes to HTML element `input`。Typescript:`CSSProperties` | N isBatchUpload | Boolean | false | make all files to be a whole package, files can only be replaced or deleted together, can not add more files | N diff --git a/src/upload/upload.md b/src/upload/upload.md index a429a16788..39c0d48fc8 100644 --- a/src/upload/upload.md +++ b/src/upload/upload.md @@ -27,6 +27,7 @@ format | Function | - | 转换文件 `UploadFile` 的数据结构,可新增或 formatRequest | Function | - | 用于新增或修改文件上传请求 参数。`action` 存在时有效。一个请求上传一个文件时,默认请求字段有 `file`。
一个请求上传多个文件时,默认字段有 `file[0]/file[1]/file[2]/.../length`,其中 `length` 表示本次上传的文件数量。
⚠️非常注意,此处的 `file[0]/file[1]` 仅仅是一个字段名,并非表示 `file` 是一个数组,接口获取字段时注意区分。
可以使用 `name` 定义 `file` 字段的别名。
也可以使用 `formatRequest` 自定义任意字段,如添加一个字段 `fileList` ,存储文件数组。TS 类型:`(requestData: { [key: string]: any }) => { [key: string]: any }` | N formatResponse | Function | - | 用于格式化文件上传后的接口响应数据,`response` 便是接口响应的原始数据。`action` 存在时有效。
示例返回值:`{ error, url, status, files }`
此函数的返回值 `error` 会作为错误文本提醒,表示上传失败的原因,如果存在会判定为本次上传失败。
此函数的返回值 `url` 会作为单个文件上传成功后的链接。
`files` 表示一个请求同时上传多个文件后的文件列表。TS 类型:`(response: any, context: FormatResponseContext) => ResponseType ` `type ResponseType = { error?: string; url?: string; status?: 'fail' \| 'success'; files?: UploadFile[] } & Record` `interface FormatResponseContext { file: UploadFile; currentFiles?: UploadFile[] }`。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/upload/type.ts) | N headers | Object | - | 设置上传的请求头部,`action` 存在时有效。TS 类型:`{[key: string]: string}` | N +imageProps | Object | - | 用于在上传图片场景下,透传属性配置至 Image 组件 | N imageViewerProps | Object | - | 透传图片预览组件全部属性。TS 类型:`ImageViewerProps`,[ImageViewer API Documents](./image-viewer?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/upload/type.ts) | N inputAttributes | Object | - | 用于添加属性到 HTML 元素 `input`。TS 类型:`CSSProperties` | N isBatchUpload | Boolean | false | 多个文件是否作为一个独立文件包,整体替换,整体删除。不允许追加文件,只允许替换文件。`theme=file-flow` 时有效 | N diff --git a/src/upload/upload.tsx b/src/upload/upload.tsx index 6d1062e3c0..80f7a8d61e 100644 --- a/src/upload/upload.tsx +++ b/src/upload/upload.tsx @@ -20,7 +20,7 @@ import useGlobalIcon from '../hooks/useGlobalIcon'; // const Upload = forwardRef((props: UploadProps, ref) => { function TdUpload(originalProps: UploadProps, ref: ForwardedRef) { const props = useDefaultProps>(originalProps, uploadDefaultProps); - const { theme } = props; + const { theme, imageProps } = props; const { locale, classPrefix, @@ -141,6 +141,7 @@ function TdUpload(originalProps: UploadProps< cancelUpload={cancelUpload} onPreview={props.onPreview} showImageFileName={props.showImageFileName} + imageProps={imageProps} /> ); diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index 9230044531..4f0d777e5a 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -43542,6 +43542,11 @@ exports[`csr snapshot test > csr test src/form/_example/disabled.tsx 1`] = ` />
+
+ loading +
@@ -133138,6 +133143,11 @@ exports[`csr snapshot test > csr test src/upload/_example/image.tsx 1`] = ` />
+
+ loading +
@@ -134702,7 +134712,7 @@ exports[`ssr snapshot test > ssr test src/form/_example/custom-validator.tsx 1`] exports[`ssr snapshot test > ssr test src/form/_example/customized-form-controls.tsx 1`] = `"
:
"`; -exports[`ssr snapshot test > ssr test src/form/_example/disabled.tsx 1`] = `"
:
:
:
:
:
:
:
:
:
:
:
请选择单张图片文件上传
提交
重置
"`; +exports[`ssr snapshot test > ssr test src/form/_example/disabled.tsx 1`] = `"
:
:
:
:
:
:
:
:
:
:
:
请选择单张图片文件上传
提交
重置
"`; exports[`ssr snapshot test > ssr test src/form/_example/error-message.tsx 1`] = `"
一句话介绍自己
"`; @@ -135518,7 +135528,7 @@ exports[`ssr snapshot test > ssr test src/upload/_example/draggable.tsx 1`] = `" exports[`ssr snapshot test > ssr test src/upload/_example/file-flow-list.tsx 1`] = `"

支持批量上传文件,文件格式不限,最多只能上传 10 份文件
Click "Upload" or Drag file to this area to upload
Cancel
Upload
"`; -exports[`ssr snapshot test > ssr test src/upload/_example/image.tsx 1`] = `"

  • 请选择图片

请选择单张图片文件上传(上传成功状态演示)
  • Click to upload

单张图片文件上传(上传失败状态演示)
  • Click to upload

允许选择多张图片文件上传,最多只能上传 3 张图片
"`; +exports[`ssr snapshot test > ssr test src/upload/_example/image.tsx 1`] = `"

  • 请选择图片

请选择单张图片文件上传(上传成功状态演示)
  • Click to upload

单张图片文件上传(上传失败状态演示)
  • Click to upload

允许选择多张图片文件上传,最多只能上传 3 张图片
"`; exports[`ssr snapshot test > ssr test src/upload/_example/img-flow-list.tsx 1`] = `"
AutoUpload

支持批量上传图片文件
  • demo…-1.png

  • avatar.jpg

取消上传

Different Status Images
  • loading.svg

  • loading.svg

  • Uploading

    loading.svg

  • Failed

    loading.svg

"`; diff --git a/test/snap/__snapshots__/ssr.test.jsx.snap b/test/snap/__snapshots__/ssr.test.jsx.snap index 968bc058dd..f6b5f35a79 100644 --- a/test/snap/__snapshots__/ssr.test.jsx.snap +++ b/test/snap/__snapshots__/ssr.test.jsx.snap @@ -410,7 +410,7 @@ exports[`ssr snapshot test > ssr test src/form/_example/custom-validator.tsx 1`] exports[`ssr snapshot test > ssr test src/form/_example/customized-form-controls.tsx 1`] = `"
:
"`; -exports[`ssr snapshot test > ssr test src/form/_example/disabled.tsx 1`] = `"
:
:
:
:
:
:
:
:
:
:
:
请选择单张图片文件上传
提交
重置
"`; +exports[`ssr snapshot test > ssr test src/form/_example/disabled.tsx 1`] = `"
:
:
:
:
:
:
:
:
:
:
:
请选择单张图片文件上传
提交
重置
"`; exports[`ssr snapshot test > ssr test src/form/_example/error-message.tsx 1`] = `"
一句话介绍自己
"`; @@ -1226,7 +1226,7 @@ exports[`ssr snapshot test > ssr test src/upload/_example/draggable.tsx 1`] = `" exports[`ssr snapshot test > ssr test src/upload/_example/file-flow-list.tsx 1`] = `"

支持批量上传文件,文件格式不限,最多只能上传 10 份文件
Click "Upload" or Drag file to this area to upload
Cancel
Upload
"`; -exports[`ssr snapshot test > ssr test src/upload/_example/image.tsx 1`] = `"

  • 请选择图片

请选择单张图片文件上传(上传成功状态演示)
  • Click to upload

单张图片文件上传(上传失败状态演示)
  • Click to upload

允许选择多张图片文件上传,最多只能上传 3 张图片
"`; +exports[`ssr snapshot test > ssr test src/upload/_example/image.tsx 1`] = `"

  • 请选择图片

请选择单张图片文件上传(上传成功状态演示)
  • Click to upload

单张图片文件上传(上传失败状态演示)
  • Click to upload

允许选择多张图片文件上传,最多只能上传 3 张图片
"`; exports[`ssr snapshot test > ssr test src/upload/_example/img-flow-list.tsx 1`] = `"
AutoUpload

支持批量上传图片文件
  • demo…-1.png

  • avatar.jpg

取消上传

Different Status Images
  • loading.svg

  • loading.svg

  • Uploading

    loading.svg

  • Failed

    loading.svg

"`; From e24d41c4daa570cdde3a0ce0e21e183d4b48ef9a Mon Sep 17 00:00:00 2001 From: betavs <34408516+betavs@users.noreply.github.com> Date: Wed, 8 Jan 2025 21:04:37 +0800 Subject: [PATCH 23/61] fix(auto-complete): the display effect is abnormal when the option is empty (#3316) --- src/_common | 2 +- src/auto-complete/AutoComplete.tsx | 2 +- src/auto-complete/OptionList.tsx | 13 ++++++++----- src/config-provider/type.ts | 12 ++++++++++++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/_common b/src/_common index 4aca77834a..17d0a74f75 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 4aca77834aace03d2fa17573c232584e781366f0 +Subproject commit 17d0a74f75281bb4abff81ed90184cc78c568aae diff --git a/src/auto-complete/AutoComplete.tsx b/src/auto-complete/AutoComplete.tsx index 0aceba8e7e..87ccc57424 100644 --- a/src/auto-complete/AutoComplete.tsx +++ b/src/auto-complete/AutoComplete.tsx @@ -157,7 +157,7 @@ const AutoComplete = forwardRef((originalPro const bottomContent = props.panelBottomContent; const panelContent = topContent || listContent || bottomContent ? ( -
+
{topContent} {listContent} {bottomContent} diff --git a/src/auto-complete/OptionList.tsx b/src/auto-complete/OptionList.tsx index 9aa7c169bc..cbd64e0bfc 100644 --- a/src/auto-complete/OptionList.tsx +++ b/src/auto-complete/OptionList.tsx @@ -8,6 +8,7 @@ import { CommonClassNameType } from '../hooks/useCommonClassName'; import { AutoCompleteOptionObj, TdAutoCompleteProps } from './type'; import HighlightOption from './HighlightOption'; import { on, off } from '../_util/dom'; +import { useLocaleReceiver } from '../locale/LocalReceiver'; export interface OptionsListProps { sizeClassNames: CommonClassNameType['sizeClassNames']; @@ -18,7 +19,7 @@ export interface OptionsListProps { highlightKeyword: boolean; filterable: boolean; filter: TdAutoCompleteProps['filter']; - onSelect?: (keyword: string, context: { e: MouseEvent | KeyboardEvent | any }) => void; + onSelect: (keyword: string, context: { e: MouseEvent | KeyboardEvent | any }) => void; } export interface OptionsListRef { @@ -32,6 +33,8 @@ const OptionsList = forwardRef((props: Options const [active, setActive] = useState(''); const activeIndexRef = useRef(-1); + const [global] = useLocaleReceiver('autoComplete'); + const classes = `${classPrefix}-select__list`; const optionClasses = [ `${classPrefix}-select-option`, @@ -81,7 +84,7 @@ const OptionsList = forwardRef((props: Options } const keyword = liNode.getAttribute('title'); setActive(keyword); - onSelect?.(keyword, { e }); + onSelect(keyword, { e }); }; // 键盘事件,上下选择 @@ -90,10 +93,10 @@ const OptionsList = forwardRef((props: Options const currentIndex = activeIndexRef.current; if (currentIndex === -1) { - return + return; } - onSelect?.(tOptions[activeIndexRef.current].text, { e }); + onSelect(tOptions[activeIndexRef.current].text, { e }); } else { const index = activeIndexRef.current; let newIndex; @@ -141,7 +144,7 @@ const OptionsList = forwardRef((props: Options activeIndexRef.current = tOptions.findIndex((item) => item.text === active); }, [active, tOptions]); - if (!tOptions.length) return null; + if (!tOptions.length) return
{global.empty}
; return (
    {tOptions.map((item) => { diff --git a/src/config-provider/type.ts b/src/config-provider/type.ts index 7bc3452f33..142933a288 100644 --- a/src/config-provider/type.ts +++ b/src/config-provider/type.ts @@ -13,6 +13,10 @@ import { ImageProps } from '../image'; import { TNode, TElement, SizeEnum, AttachNode } from '../common'; export interface GlobalConfigProvider { + /** + * 自动填充全局配置 + */ + autoComplete?: AutoCompleteConfig; /** * 警告全局配置 */ @@ -152,6 +156,14 @@ export interface GlobalConfigProvider { upload?: UploadConfig; } +export interface AutoCompleteConfig { + /** + * 语言配置,“暂无数据”描述文本 + * @default '' + */ + empty?: string; +} + export interface InputConfig { /** * 是否开启自动填充功能 From 47b0a80b1e9492ba7cdf89ab1f79bc78d63de647 Mon Sep 17 00:00:00 2001 From: liweijie0812 <674416404@qq.com> Date: Wed, 8 Jan 2025 23:10:27 +0800 Subject: [PATCH 24/61] feat(auto-complete): support empty api (#3319) * feat(auto-complete): support empty api * chore: update doc * chore: update --- src/auto-complete/AutoComplete.tsx | 1 + src/auto-complete/OptionList.tsx | 5 +++- src/auto-complete/auto-complete.en-US.md | 1 + src/auto-complete/auto-complete.md | 3 ++- src/auto-complete/type.ts | 6 ++++- src/config-provider/config-provider.en-US.md | 7 ++++++ src/config-provider/config-provider.md | 7 ++++++ src/config-provider/type.ts | 24 ++++++++++---------- 8 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/auto-complete/AutoComplete.tsx b/src/auto-complete/AutoComplete.tsx index 87ccc57424..1dacbfb774 100644 --- a/src/auto-complete/AutoComplete.tsx +++ b/src/auto-complete/AutoComplete.tsx @@ -151,6 +151,7 @@ const AutoComplete = forwardRef((originalPro highlightKeyword={props.highlightKeyword} filterable={props.filterable} filter={props.filter} + empty={props.empty} /> ); const topContent = props.panelTopContent; diff --git a/src/auto-complete/OptionList.tsx b/src/auto-complete/OptionList.tsx index cbd64e0bfc..6ed131af1e 100644 --- a/src/auto-complete/OptionList.tsx +++ b/src/auto-complete/OptionList.tsx @@ -19,6 +19,7 @@ export interface OptionsListProps { highlightKeyword: boolean; filterable: boolean; filter: TdAutoCompleteProps['filter']; + empty: TdAutoCompleteProps['empty']; onSelect: (keyword: string, context: { e: MouseEvent | KeyboardEvent | any }) => void; } @@ -144,7 +145,9 @@ const OptionsList = forwardRef((props: Options activeIndexRef.current = tOptions.findIndex((item) => item.text === active); }, [active, tOptions]); - if (!tOptions.length) return
    {global.empty}
    ; + if (!tOptions.length) { + return
    {props.empty || global.empty}
    ; + } return (
      {tOptions.map((item) => { diff --git a/src/auto-complete/auto-complete.en-US.md b/src/auto-complete/auto-complete.en-US.md index e7351aefae..ead6e2d60f 100644 --- a/src/auto-complete/auto-complete.en-US.md +++ b/src/auto-complete/auto-complete.en-US.md @@ -13,6 +13,7 @@ borderless | Boolean | false | \- | N children | TNode | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N clearable | Boolean | - | \- | N disabled | Boolean | - | \- | N +empty | TNode | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N filter | Function | - | Typescript:`(filterWords: string, option: T) => boolean \| Promise` | N filterable | Boolean | true | \- | N highlightKeyword | Boolean | true | \- | N diff --git a/src/auto-complete/auto-complete.md b/src/auto-complete/auto-complete.md index 8f7e7e818b..44b6ab1404 100644 --- a/src/auto-complete/auto-complete.md +++ b/src/auto-complete/auto-complete.md @@ -13,6 +13,7 @@ borderless | Boolean | false | 无边框模式 | N children | TNode | - | 触发显示联想词下拉框的元素,同 `triggerElement`。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N clearable | Boolean | - | 是否允许清空 | N disabled | Boolean | - | 是否禁用 | N +empty | TNode | - | 当下拉联想词列表为空时显示的内容。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N filter | Function | - | 自定义过滤规则,用于对现有数据进行搜索过滤,判断是否过滤某一项数据。参数 `filterWords` 表示搜索词,`option`表示单个选项内容,返回值为 `true` 保留该选项,返回值为 `false` 则隐藏该选项。使用该方法时无需设置 `filterable`。TS 类型:`(filterWords: string, option: T) => boolean \| Promise` | N filterable | Boolean | true | 是否根据输入内容过滤联想词。默认过滤规则不区分大小写,全文本任意位置匹配。如果默认搜索规则不符合业务需求,可以更为使用 `filter` 自定义过滤规则。部分场景下输入关键词和下拉联想词完全不同,此时可以设置为 `false` | N highlightKeyword | Boolean | true | 是否高亮联想词中和输入值的相同部分 | N @@ -21,7 +22,7 @@ options | Array | - | 下拉联想词列表。示例一:`['联想词一', '联 panelBottomContent | TNode | - | 面板内的底部内容。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N panelTopContent | TNode | - | 面板内的顶部内容。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N placeholder | String | undefined | 输入框为空时的占位提示。组件本身默认值为 `undefined`,但全局配置存在默认值,不同语言全局默认值不同 | N -popupProps | Object | - | 透传 Popup 组件全部特性。TS 类型:`PopupProps`,[Popup API Documents](./popup?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/auto-complete/type.ts) | N +popupProps | Object | - | 透传 Popup 组件全部属性。TS 类型:`PopupProps`,[Popup API Documents](./popup?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/auto-complete/type.ts) | N readonly | Boolean | - | 是否只读 | N size | String | medium | 组件尺寸。可选项:small/medium/large。TS 类型:`SizeEnum`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N status | String | default | 输入框状态。可选项:default/success/warning/error | N diff --git a/src/auto-complete/type.ts b/src/auto-complete/type.ts index b67866c94e..32aacdc9c6 100644 --- a/src/auto-complete/type.ts +++ b/src/auto-complete/type.ts @@ -32,6 +32,10 @@ export interface TdAutoCompleteProps>>` `type AnimationType = 'ripple' \| 'expand' \| 'fade'`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/config-provider/type.ts) | N attach | String / Object / Function | - | Typescript:`AttachNode \| { imageViewer?: AttachNode; popup?: AttachNode; dialog?: AttachNode; drawer?: AttachNode; }`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N +autoComplete | Object | - | AutoComplete global configs。Typescript:`AutoCompleteConfig` | N calendar | Object | - | Calendar global configs。Typescript:`CalendarConfig` | N cascader | Object | - | Cascader global configs。Typescript:`CascaderConfig` | N classPrefix | String | t | \- | N @@ -354,3 +355,9 @@ name | type | default | description | required collapseText | String | - | collapse text | N copiedText | String | - | copied text | N expandText | String | - | expand text | N + +### AutoCompleteConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +empty | String | - | \- | N diff --git a/src/config-provider/config-provider.md b/src/config-provider/config-provider.md index c6906be094..ad71f25e19 100644 --- a/src/config-provider/config-provider.md +++ b/src/config-provider/config-provider.md @@ -39,6 +39,7 @@ alert | Object | - | 警告全局配置。TS 类型:`AlertConfig` | N anchor | Object | - | 锚点全局配置。TS 类型:`AnchorConfig` | N animation | Object | - | 动画效果控制,`ripple` 指波纹动画, `expand` 指展开动画,`fade` 指渐变动画。默认为 `{ include: ['ripple','expand','fade'], exclude: [] }`。TS 类型:`Partial>>` `type AnimationType = 'ripple' \| 'expand' \| 'fade'`。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/config-provider/type.ts) | N attach | String / Object / Function | - | TS 类型:`AttachNode \| { imageViewer?: AttachNode; popup?: AttachNode; dialog?: AttachNode; drawer?: AttachNode; }`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N +autoComplete | Object | - | 自动填充组件全局配置。TS 类型:`AutoCompleteConfig` | N calendar | Object | - | 日历组件全局配置。TS 类型:`CalendarConfig` | N cascader | Object | - | 级联选择器全局配置。TS 类型:`CascaderConfig` | N classPrefix | String | t | CSS 类名前缀 | N @@ -384,3 +385,9 @@ titleText | Object | - | 空状态组件各类型的标题文本配置。TS 类 collapseText | String | - | 语言配置,“收起”描述文本 | N copiedText | String | - | 语言配置,“复制成功”描述文本 | N expandText | String | - | 语言配置,“展开”描述文本 | N + +### AutoCompleteConfig + +名称 | 类型 | 默认值 | 描述 | 必传 +-- | -- | -- | -- | -- +empty | String | - | 语言配置,“暂无数据”描述文本 | N diff --git a/src/config-provider/type.ts b/src/config-provider/type.ts index 142933a288..9cfa7217ae 100644 --- a/src/config-provider/type.ts +++ b/src/config-provider/type.ts @@ -13,10 +13,6 @@ import { ImageProps } from '../image'; import { TNode, TElement, SizeEnum, AttachNode } from '../common'; export interface GlobalConfigProvider { - /** - * 自动填充全局配置 - */ - autoComplete?: AutoCompleteConfig; /** * 警告全局配置 */ @@ -33,6 +29,10 @@ export interface GlobalConfigProvider { * null */ attach?: AttachNode | { imageViewer?: AttachNode; popup?: AttachNode; dialog?: AttachNode; drawer?: AttachNode }; + /** + * 自动填充组件全局配置 + */ + autoComplete?: AutoCompleteConfig; /** * 日历组件全局配置 */ @@ -156,14 +156,6 @@ export interface GlobalConfigProvider { upload?: UploadConfig; } -export interface AutoCompleteConfig { - /** - * 语言配置,“暂无数据”描述文本 - * @default '' - */ - empty?: string; -} - export interface InputConfig { /** * 是否开启自动填充功能 @@ -972,6 +964,14 @@ export interface TypographyConfig { expandText?: string; } +export interface AutoCompleteConfig { + /** + * 语言配置,“暂无数据”描述文本 + * @default '' + */ + empty?: string; +} + export type AnimationType = 'ripple' | 'expand' | 'fade'; export type IconConfig = GlobalIconConfig; From 116cb4752ee462471013f7af25136ff261e1b037 Mon Sep 17 00:00:00 2001 From: Haixing <65376724+HaixingOoO@users.noreply.github.com> Date: Thu, 9 Jan 2025 19:07:22 +0800 Subject: [PATCH 25/61] fix(menu): fix head-menu not render icon (#3320) * fix(menu): fix head-menu not render icon * chore(menu): change parseTNode render icon * test(menu): update test snap --- src/_common | 2 +- src/menu/SubMenu.tsx | 7 ++- src/menu/__tests__/menu.test.tsx | 16 +++++++ test/snap/__snapshots__/csr.test.jsx.snap | 57 ++++++++++++----------- test/snap/__snapshots__/ssr.test.jsx.snap | 10 ++-- 5 files changed, 56 insertions(+), 36 deletions(-) diff --git a/src/_common b/src/_common index 17d0a74f75..c569a218ec 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 17d0a74f75281bb4abff81ed90184cc78c568aae +Subproject commit c569a218ec1547b4924c429337237ebdcf3b23d3 diff --git a/src/menu/SubMenu.tsx b/src/menu/SubMenu.tsx index ac161cbec9..682394c1be 100644 --- a/src/menu/SubMenu.tsx +++ b/src/menu/SubMenu.tsx @@ -12,6 +12,7 @@ import FakeArrow from '../common/FakeArrow'; import { checkIsSubMenu, checkIsMenuGroup } from './_util/checkMenuType'; import { cacularPaddingLeft } from './_util/cacularPaddingLeft'; import { Popup, PopupPlacement } from '../popup'; +import parseTNode from '../_util/parseTNode'; export interface SubMenuProps extends TdSubmenuProps, StyledProps {} @@ -107,7 +108,8 @@ const SubAccordion: FC = (props) => { })} onClick={handleClick} > - {icon} {title} + {parseTNode(icon)} + {title}
{!isPopUp && ( @@ -153,7 +155,7 @@ const SubAccordion: FC = (props) => { }; const SubTitleMenu: FC = (props) => { - const { className, style, children, disabled, title, value, level = 1, popupProps } = props; + const { className, style, children, disabled, icon, title, value, level = 1, popupProps } = props; const { overlayClassName, overlayInnerClassName, ...restPopupProps } = popupProps || {}; @@ -224,6 +226,7 @@ const SubTitleMenu: FC = (props) => { onClick={handleClick} style={style} > + {parseTNode(icon)} {title} {isPopUp && }
diff --git a/src/menu/__tests__/menu.test.tsx b/src/menu/__tests__/menu.test.tsx index 1c131d961d..f10004b30b 100644 --- a/src/menu/__tests__/menu.test.tsx +++ b/src/menu/__tests__/menu.test.tsx @@ -1,5 +1,6 @@ import { render, fireEvent, vi, waitFor } from '@test/utils'; import React from 'react'; +import { UserIcon } from 'tdesign-icons-react'; import Menu from '../index'; describe('Menu 组件测试', () => { @@ -192,4 +193,19 @@ describe('Menu 组件测试', () => { fireEvent.click(getByText('仪表盘')); expect(clickFn).toHaveBeenCalledTimes(1); }); + + test('menu head-menu render icon', async () => { + const { container, getByText } = render( + + }> + + 苹果 + + + , + ); + + expect(getByText('水果蔬菜')).toBeInTheDocument(); + expect(container.querySelector('.t-icon-user')).toBeInTheDocument(); + }); }); diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index 4f0d777e5a..eb55b0d59c 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -60037,7 +60037,6 @@ exports[`csr snapshot test > csr test src/menu/_example/closable-side.tsx 1`] = fill="currentColor" /> - @@ -60080,7 +60079,6 @@ exports[`csr snapshot test > csr test src/menu/_example/closable-side.tsx 1`] = fill="currentColor" /> - @@ -60123,7 +60121,6 @@ exports[`csr snapshot test > csr test src/menu/_example/closable-side.tsx 1`] = fill="currentColor" /> - @@ -60187,7 +60184,6 @@ exports[`csr snapshot test > csr test src/menu/_example/closable-side.tsx 1`] = fill="currentColor" /> - @@ -61096,7 +61092,6 @@ exports[`csr snapshot test > csr test src/menu/_example/group-side.tsx 1`] = ` fill="currentColor" /> - @@ -61354,7 +61349,6 @@ exports[`csr snapshot test > csr test src/menu/_example/multi-side.tsx 1`] = ` fill="currentColor" /> - @@ -61413,7 +61407,6 @@ exports[`csr snapshot test > csr test src/menu/_example/multi-side.tsx 1`] = ` fill="currentColor" /> - @@ -61447,7 +61440,6 @@ exports[`csr snapshot test > csr test src/menu/_example/multi-side.tsx 1`] = `
- @@ -61533,7 +61525,6 @@ exports[`csr snapshot test > csr test src/menu/_example/multi-side.tsx 1`] = ` fill="currentColor" /> - @@ -61624,7 +61615,6 @@ exports[`csr snapshot test > csr test src/menu/_example/multi-side.tsx 1`] = ` fill="currentColor" /> - @@ -61749,7 +61739,6 @@ exports[`csr snapshot test > csr test src/menu/_example/multi-side.tsx 1`] = ` fill="currentColor" /> - @@ -61783,7 +61772,6 @@ exports[`csr snapshot test > csr test src/menu/_example/multi-side.tsx 1`] = `
- @@ -61858,7 +61846,6 @@ exports[`csr snapshot test > csr test src/menu/_example/multi-side.tsx 1`] = ` fill="currentColor" /> - @@ -61928,7 +61915,6 @@ exports[`csr snapshot test > csr test src/menu/_example/multi-side.tsx 1`] = ` fill="currentColor" /> - @@ -62019,7 +62005,6 @@ exports[`csr snapshot test > csr test src/menu/_example/multi-side.tsx 1`] = ` fill="currentColor" /> - @@ -62164,6 +62149,18 @@ exports[`csr snapshot test > csr test src/menu/_example/multiple.tsx 1`] = `
+ + + 水果蔬菜 @@ -62256,6 +62253,18 @@ exports[`csr snapshot test > csr test src/menu/_example/multiple.tsx 1`] = `
+ + + 水果蔬菜 @@ -62342,7 +62351,6 @@ exports[`csr snapshot test > csr test src/menu/_example/popup-side.tsx 1`] = ` fill="currentColor" /> - @@ -62385,7 +62393,6 @@ exports[`csr snapshot test > csr test src/menu/_example/popup-side.tsx 1`] = ` fill="currentColor" /> - @@ -62428,7 +62435,6 @@ exports[`csr snapshot test > csr test src/menu/_example/popup-side.tsx 1`] = ` fill="currentColor" /> - @@ -62492,7 +62498,6 @@ exports[`csr snapshot test > csr test src/menu/_example/popup-side.tsx 1`] = ` fill="currentColor" /> - @@ -62585,7 +62590,6 @@ exports[`csr snapshot test > csr test src/menu/_example/popup-side.tsx 1`] = ` fill="currentColor" /> - @@ -62628,7 +62632,6 @@ exports[`csr snapshot test > csr test src/menu/_example/popup-side.tsx 1`] = ` fill="currentColor" /> - @@ -62671,7 +62674,6 @@ exports[`csr snapshot test > csr test src/menu/_example/popup-side.tsx 1`] = ` fill="currentColor" /> - @@ -62735,7 +62737,6 @@ exports[`csr snapshot test > csr test src/menu/_example/popup-side.tsx 1`] = ` fill="currentColor" /> - @@ -134924,7 +134925,7 @@ exports[`ssr snapshot test > ssr test src/loading/_example/text.tsx 1`] = `"
ssr test src/loading/_example/wrap.tsx 1`] = `"
this is loading component
this is loading component
this is loading component
this is loading component
this is loading component
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/closable-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/closable-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
"`; exports[`ssr snapshot test > ssr test src/menu/_example/custom-header.tsx 1`] = `"
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
"`; @@ -134932,13 +134933,13 @@ exports[`ssr snapshot test > ssr test src/menu/_example/custom-side.tsx 1`] = `" exports[`ssr snapshot test > ssr test src/menu/_example/double.tsx 1`] = `"
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
    子菜单1
    子菜单2
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
    子菜单1
    子菜单2
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/group-side.tsx 1`] = `"
    主导航
  • 仪表盘
  • 组件
  • 列表项
    • 基础列表项
    • 卡片列表项
    • 筛选列表项
    • 树状筛选列表项
  • 表单项
  • 详情页
  • 结果页
  • 更多
  • 个人页
  • 登录页
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/group-side.tsx 1`] = `"
    主导航
  • 仪表盘
  • 组件
  • 列表项
    • 基础列表项
    • 卡片列表项
    • 筛选列表项
    • 树状筛选列表项
  • 表单项
  • 详情页
  • 结果页
  • 更多
  • 个人页
  • 登录页
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/multi-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
    • 菜单二
  • 调度平台
    • 二级菜单-1
      • 三级菜单-1
      • 三级菜单-2
      • 三级菜单-3
    • 二级菜单-2
  • 精准监控
    • 二级菜单-1
    • 二级菜单-2
  • 根目录
  • 消息区
    • 二级菜单-1
    • 二级菜单-2
  • 仪表盘
  • 资源列表
    • 二级菜单-1
      • 三级菜单-1
      • 三级菜单-2
      • 三级菜单-3
  • 调度平台
    • 二级菜单-1
    • 二级菜单-2
  • 精准监控
    • 二级菜单-1
    • 二级菜单-2
  • 根目录
  • 消息区
    • 二级菜单-1
    • 二级菜单-2
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/multi-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
    • 菜单二
  • 调度平台
    • 二级菜单-1
      • 三级菜单-1
      • 三级菜单-2
      • 三级菜单-3
    • 二级菜单-2
  • 精准监控
    • 二级菜单-1
    • 二级菜单-2
  • 根目录
  • 消息区
    • 二级菜单-1
    • 二级菜单-2
  • 仪表盘
  • 资源列表
    • 二级菜单-1
      • 三级菜单-1
      • 三级菜单-2
      • 三级菜单-3
  • 调度平台
    • 二级菜单-1
    • 二级菜单-2
  • 精准监控
    • 二级菜单-1
    • 二级菜单-2
  • 根目录
  • 消息区
    • 二级菜单-1
    • 二级菜单-2
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/multiple.tsx 1`] = `"
  • 电器
  • 女装
  • 水果蔬菜
  • 其他
  • 电器
  • 女装
  • 水果蔬菜
  • 其他
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/multiple.tsx 1`] = `"
  • 电器
  • 女装
  • 水果蔬菜
  • 其他
  • 电器
  • 女装
  • 水果蔬菜
  • 其他
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/popup-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/popup-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
"`; exports[`ssr snapshot test > ssr test src/menu/_example/single.tsx 1`] = `"
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
"`; diff --git a/test/snap/__snapshots__/ssr.test.jsx.snap b/test/snap/__snapshots__/ssr.test.jsx.snap index f6b5f35a79..3cd515a58f 100644 --- a/test/snap/__snapshots__/ssr.test.jsx.snap +++ b/test/snap/__snapshots__/ssr.test.jsx.snap @@ -622,7 +622,7 @@ exports[`ssr snapshot test > ssr test src/loading/_example/text.tsx 1`] = `"
ssr test src/loading/_example/wrap.tsx 1`] = `"
this is loading component
this is loading component
this is loading component
this is loading component
this is loading component
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/closable-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/closable-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
"`; exports[`ssr snapshot test > ssr test src/menu/_example/custom-header.tsx 1`] = `"
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
"`; @@ -630,13 +630,13 @@ exports[`ssr snapshot test > ssr test src/menu/_example/custom-side.tsx 1`] = `" exports[`ssr snapshot test > ssr test src/menu/_example/double.tsx 1`] = `"
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
    子菜单1
    子菜单2
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
    子菜单1
    子菜单2
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/group-side.tsx 1`] = `"
    主导航
  • 仪表盘
  • 组件
  • 列表项
    • 基础列表项
    • 卡片列表项
    • 筛选列表项
    • 树状筛选列表项
  • 表单项
  • 详情页
  • 结果页
  • 更多
  • 个人页
  • 登录页
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/group-side.tsx 1`] = `"
    主导航
  • 仪表盘
  • 组件
  • 列表项
    • 基础列表项
    • 卡片列表项
    • 筛选列表项
    • 树状筛选列表项
  • 表单项
  • 详情页
  • 结果页
  • 更多
  • 个人页
  • 登录页
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/multi-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
    • 菜单二
  • 调度平台
    • 二级菜单-1
      • 三级菜单-1
      • 三级菜单-2
      • 三级菜单-3
    • 二级菜单-2
  • 精准监控
    • 二级菜单-1
    • 二级菜单-2
  • 根目录
  • 消息区
    • 二级菜单-1
    • 二级菜单-2
  • 仪表盘
  • 资源列表
    • 二级菜单-1
      • 三级菜单-1
      • 三级菜单-2
      • 三级菜单-3
  • 调度平台
    • 二级菜单-1
    • 二级菜单-2
  • 精准监控
    • 二级菜单-1
    • 二级菜单-2
  • 根目录
  • 消息区
    • 二级菜单-1
    • 二级菜单-2
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/multi-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
    • 菜单二
  • 调度平台
    • 二级菜单-1
      • 三级菜单-1
      • 三级菜单-2
      • 三级菜单-3
    • 二级菜单-2
  • 精准监控
    • 二级菜单-1
    • 二级菜单-2
  • 根目录
  • 消息区
    • 二级菜单-1
    • 二级菜单-2
  • 仪表盘
  • 资源列表
    • 二级菜单-1
      • 三级菜单-1
      • 三级菜单-2
      • 三级菜单-3
  • 调度平台
    • 二级菜单-1
    • 二级菜单-2
  • 精准监控
    • 二级菜单-1
    • 二级菜单-2
  • 根目录
  • 消息区
    • 二级菜单-1
    • 二级菜单-2
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/multiple.tsx 1`] = `"
  • 电器
  • 女装
  • 水果蔬菜
  • 其他
  • 电器
  • 女装
  • 水果蔬菜
  • 其他
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/multiple.tsx 1`] = `"
  • 电器
  • 女装
  • 水果蔬菜
  • 其他
  • 电器
  • 女装
  • 水果蔬菜
  • 其他
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/popup-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/popup-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
"`; exports[`ssr snapshot test > ssr test src/menu/_example/single.tsx 1`] = `"
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
"`; From 2298158e793b1c7e05b55759c082173f5629c792 Mon Sep 17 00:00:00 2001 From: huangchen1031 Date: Sat, 11 Jan 2025 17:40:10 +0800 Subject: [PATCH 26/61] =?UTF-8?q?feat(drawer):=20sizeDraggable=E6=94=AF?= =?UTF-8?q?=E6=8C=81SizeDragLimit=E7=B1=BB=E5=9E=8B=20(#3323)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(drawer): sizeDraggable支持SizeDragLimit类型 * fix: delete comment --- src/drawer/hooks/useDrag.ts | 40 ++++++++++++++++++++++++------------- src/drawer/type.ts | 7 ++++++- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/drawer/hooks/useDrag.ts b/src/drawer/hooks/useDrag.ts index 3913f1e7c7..0549a24c9d 100644 --- a/src/drawer/hooks/useDrag.ts +++ b/src/drawer/hooks/useDrag.ts @@ -1,6 +1,7 @@ import { useMemo, useState } from 'react'; import { TdDrawerProps } from '../type'; import { Styles } from '../../common'; +import { getSizeDraggable, calcMoveSize } from '../../_common/js/drawer/utils'; const useDrag = ( placement: TdDrawerProps['placement'], @@ -12,20 +13,31 @@ const useDrag = ( const handleMousemove = (e: MouseEvent) => { // 鼠标移动时计算draggedSizeValue的值 const { x, y } = e; - if (sizeDraggable) { - if (placement === 'right') { - changeDragSizeValue(`${document.documentElement.clientWidth - x + 8}px`); - } - if (placement === 'left') { - changeDragSizeValue(`${x + 8}px`); - } - if (placement === 'top') { - changeDragSizeValue(`${y + 8}px`); - } - if (placement === 'bottom') { - changeDragSizeValue(`${document.documentElement.clientHeight - y + 8}px`); - } - } + + const maxHeight = document.documentElement.clientHeight; + const maxWidth = document.documentElement.clientWidth; + const offsetHeight = 8; + const offsetWidth = 8; + // x 轴方向使用最大宽度,y轴方向使用最大高度 + const max = placement === 'left' || placement === 'right' ? maxWidth : maxHeight; + // x 轴方向使用默认最小宽度,y轴方向使用默认最小高度 + const min = placement === 'left' || placement === 'right' ? offsetWidth : offsetHeight; + + const { allowSizeDraggable, max: limitMax, min: limitMin } = getSizeDraggable(sizeDraggable, { max, min }); + + if (!allowSizeDraggable) return; + + const moveSize = calcMoveSize(placement, { + x, + y, + maxWidth, + maxHeight, + max: limitMax, + min: limitMin, + }); + + if (typeof moveSize === 'undefined') return; + changeDragSizeValue(`${moveSize}px`); }; const draggableLineStyles: Styles = useMemo(() => { // 设置拖拽control的样式 diff --git a/src/drawer/type.ts b/src/drawer/type.ts index 4ef0133e1f..b620e766e4 100644 --- a/src/drawer/type.ts +++ b/src/drawer/type.ts @@ -94,7 +94,7 @@ export interface TdDrawerProps { * 抽屉大小可拖拽调整,横向抽屉调整宽度 * @default false */ - sizeDraggable?: boolean; + sizeDraggable?: boolean | SizeDragLimit; /** * 组件是否可见 * @default false @@ -180,6 +180,11 @@ export interface DrawerInstance { export type FooterButton = string | ButtonProps | TNode; +export interface SizeDragLimit { + max: number; + min: number; +} + export type DrawerEventSource = 'esc' | 'close-btn' | 'cancel' | 'overlay'; export interface DrawerCloseContext { From ae4e703fd590c65d214c9d930c8b93da0efc37f0 Mon Sep 17 00:00:00 2001 From: TDesign bot <93915689+tdesign-bot@users.noreply.github.com> Date: Mon, 13 Jan 2025 18:18:22 +0800 Subject: [PATCH 27/61] feat(Icon): tdesign-icons-react update to 0.4.3 (#3326) * chore: update tdesign-icons-react to 0.4.3 * chore: update snapshot --------- Co-authored-by: liweijie0812 <674416404@qq.com> Co-authored-by: github-actions[bot] --- package.json | 4 +- test/snap/__snapshots__/csr.test.jsx.snap | 95 +++++++++++------------ test/snap/__snapshots__/ssr.test.jsx.snap | 28 +++---- 3 files changed, 63 insertions(+), 64 deletions(-) diff --git a/package.json b/package.json index a64a9ce49d..6d91fbaecb 100644 --- a/package.json +++ b/package.json @@ -185,7 +185,7 @@ "rollup-plugin-typescript2": "^0.31.2", "semver": "^7.6.3", "start-server-and-test": "^1.14.0", - "tdesign-icons-view": "^0.3.0", + "tdesign-icons-view": "^0.3.4", "tdesign-publish-cli": "^0.0.12", "tdesign-site-components": "^0.15.3", "tdesign-theme-generator": "^1.0.0", @@ -215,7 +215,7 @@ "react-popper": "~2.3.0", "react-transition-group": "~4.4.1", "sortablejs": "^1.15.0", - "tdesign-icons-react": "^0.3.4", + "tdesign-icons-react": "^0.4.3", "tinycolor2": "^1.4.2", "tslib": "~2.3.1", "validator": "~13.7.0" diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index eb55b0d59c..748fe8931d 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -28420,7 +28420,7 @@ exports[`csr snapshot test > csr test src/comment/_example/reply.tsx 1`] = ` width="1em" > @@ -30863,7 +30863,7 @@ exports[`csr snapshot test > csr test src/config-provider/_example/table.tsx 1`] width="1em" > @@ -30880,7 +30880,7 @@ exports[`csr snapshot test > csr test src/config-provider/_example/table.tsx 1`] width="1em" > @@ -30967,7 +30967,7 @@ exports[`csr snapshot test > csr test src/config-provider/_example/table.tsx 1`] width="1em" > @@ -30984,7 +30984,7 @@ exports[`csr snapshot test > csr test src/config-provider/_example/table.tsx 1`] width="1em" > @@ -31098,7 +31098,7 @@ exports[`csr snapshot test > csr test src/config-provider/_example/table.tsx 1`] width="1em" > @@ -31115,7 +31115,7 @@ exports[`csr snapshot test > csr test src/config-provider/_example/table.tsx 1`] width="1em" > @@ -31202,7 +31202,7 @@ exports[`csr snapshot test > csr test src/config-provider/_example/table.tsx 1`] width="1em" > @@ -31219,7 +31219,7 @@ exports[`csr snapshot test > csr test src/config-provider/_example/table.tsx 1`] width="1em" > @@ -60009,7 +60009,7 @@ exports[`csr snapshot test > csr test src/menu/_example/closable-side.tsx 1`] = width="1em" > @@ -61054,7 +61054,7 @@ exports[`csr snapshot test > csr test src/menu/_example/group-side.tsx 1`] = ` width="1em" > @@ -61321,7 +61321,7 @@ exports[`csr snapshot test > csr test src/menu/_example/multi-side.tsx 1`] = ` width="1em" > @@ -61711,7 +61711,7 @@ exports[`csr snapshot test > csr test src/menu/_example/multi-side.tsx 1`] = ` width="1em" > @@ -62323,7 +62323,7 @@ exports[`csr snapshot test > csr test src/menu/_example/popup-side.tsx 1`] = ` width="1em" > @@ -62562,7 +62562,7 @@ exports[`csr snapshot test > csr test src/menu/_example/popup-side.tsx 1`] = ` width="1em" > @@ -82369,7 +82369,7 @@ exports[`csr snapshot test > csr test src/steps/_example/icon.tsx 1`] = ` width="1em" > @@ -90554,7 +90554,7 @@ exports[`csr snapshot test > csr test src/table/_example/data-sort.tsx 1`] = ` width="1em" > @@ -90571,7 +90571,7 @@ exports[`csr snapshot test > csr test src/table/_example/data-sort.tsx 1`] = ` width="1em" > @@ -90616,7 +90616,7 @@ exports[`csr snapshot test > csr test src/table/_example/data-sort.tsx 1`] = ` width="1em" > @@ -90633,7 +90633,7 @@ exports[`csr snapshot test > csr test src/table/_example/data-sort.tsx 1`] = ` width="1em" > @@ -95087,7 +95087,7 @@ exports[`csr snapshot test > csr test src/table/_example/filter-controlled.tsx 1 width="1em" > @@ -95104,7 +95104,7 @@ exports[`csr snapshot test > csr test src/table/_example/filter-controlled.tsx 1 width="1em" > @@ -106583,7 +106583,6 @@ exports[`csr snapshot test > csr test src/table/_example/loading.tsx 1`] = `    @@ -107342,7 +107341,7 @@ exports[`csr snapshot test > csr test src/table/_example/multi-header.tsx 1`] = width="1em" > @@ -107359,7 +107358,7 @@ exports[`csr snapshot test > csr test src/table/_example/multi-header.tsx 1`] = width="1em" > @@ -109354,7 +109353,7 @@ exports[`csr snapshot test > csr test src/table/_example/multiple-sort.tsx 1`] = width="1em" > @@ -109371,7 +109370,7 @@ exports[`csr snapshot test > csr test src/table/_example/multiple-sort.tsx 1`] = width="1em" > @@ -109416,7 +109415,7 @@ exports[`csr snapshot test > csr test src/table/_example/multiple-sort.tsx 1`] = width="1em" > @@ -109433,7 +109432,7 @@ exports[`csr snapshot test > csr test src/table/_example/multiple-sort.tsx 1`] = width="1em" > @@ -111559,7 +111558,7 @@ exports[`csr snapshot test > csr test src/table/_example/single-sort.tsx 1`] = ` width="1em" > @@ -111576,7 +111575,7 @@ exports[`csr snapshot test > csr test src/table/_example/single-sort.tsx 1`] = ` width="1em" > @@ -111621,7 +111620,7 @@ exports[`csr snapshot test > csr test src/table/_example/single-sort.tsx 1`] = ` width="1em" > @@ -111638,7 +111637,7 @@ exports[`csr snapshot test > csr test src/table/_example/single-sort.tsx 1`] = ` width="1em" > @@ -131169,7 +131168,7 @@ exports[`csr snapshot test > csr test src/tree-select/_example/prefixsuffix.tsx width="1em" > @@ -134557,7 +134556,7 @@ exports[`ssr snapshot test > ssr test src/comment/_example/operation.tsx 1`] = ` exports[`ssr snapshot test > ssr test src/comment/_example/quote.tsx 1`] = `"
评论作者名A今天16:38
A评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容。
引用内容标题
引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容。
"`; -exports[`ssr snapshot test > ssr test src/comment/_example/reply.tsx 1`] = `"
评论作者名A今天16:38
A评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容。
评论作者名B评论作者名A今天16:38
B评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容。
"`; +exports[`ssr snapshot test > ssr test src/comment/_example/reply.tsx 1`] = `"
评论作者名A今天16:38
A评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容。
评论作者名B评论作者名A今天16:38
B评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容。
"`; exports[`ssr snapshot test > ssr test src/comment/_example/reply-form.tsx 1`] = `"
"`; @@ -134575,7 +134574,7 @@ exports[`ssr snapshot test > ssr test src/config-provider/_example/pagination.ts exports[`ssr snapshot test > ssr test src/config-provider/_example/popconfirm.tsx 1`] = `"
"`; -exports[`ssr snapshot test > ssr test src/config-provider/_example/table.tsx 1`] = `"
Type
Platform
Property
Empty Data
Type
Platform
Property
ArrayVue(PC)A
StringReact(PC)B
ObjectMiniprogramC
"`; +exports[`ssr snapshot test > ssr test src/config-provider/_example/table.tsx 1`] = `"
Type
Platform
Property
Empty Data
Type
Platform
Property
ArrayVue(PC)A
StringReact(PC)B
ObjectMiniprogramC
"`; exports[`ssr snapshot test > ssr test src/date-picker/_example/base.tsx 1`] = `"
"`; @@ -134925,7 +134924,7 @@ exports[`ssr snapshot test > ssr test src/loading/_example/text.tsx 1`] = `"
ssr test src/loading/_example/wrap.tsx 1`] = `"
this is loading component
this is loading component
this is loading component
this is loading component
this is loading component
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/closable-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/closable-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
"`; exports[`ssr snapshot test > ssr test src/menu/_example/custom-header.tsx 1`] = `"
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
"`; @@ -134933,13 +134932,13 @@ exports[`ssr snapshot test > ssr test src/menu/_example/custom-side.tsx 1`] = `" exports[`ssr snapshot test > ssr test src/menu/_example/double.tsx 1`] = `"
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
    子菜单1
    子菜单2
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
    子菜单1
    子菜单2
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/group-side.tsx 1`] = `"
    主导航
  • 仪表盘
  • 组件
  • 列表项
    • 基础列表项
    • 卡片列表项
    • 筛选列表项
    • 树状筛选列表项
  • 表单项
  • 详情页
  • 结果页
  • 更多
  • 个人页
  • 登录页
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/group-side.tsx 1`] = `"
    主导航
  • 仪表盘
  • 组件
  • 列表项
    • 基础列表项
    • 卡片列表项
    • 筛选列表项
    • 树状筛选列表项
  • 表单项
  • 详情页
  • 结果页
  • 更多
  • 个人页
  • 登录页
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/multi-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
    • 菜单二
  • 调度平台
    • 二级菜单-1
      • 三级菜单-1
      • 三级菜单-2
      • 三级菜单-3
    • 二级菜单-2
  • 精准监控
    • 二级菜单-1
    • 二级菜单-2
  • 根目录
  • 消息区
    • 二级菜单-1
    • 二级菜单-2
  • 仪表盘
  • 资源列表
    • 二级菜单-1
      • 三级菜单-1
      • 三级菜单-2
      • 三级菜单-3
  • 调度平台
    • 二级菜单-1
    • 二级菜单-2
  • 精准监控
    • 二级菜单-1
    • 二级菜单-2
  • 根目录
  • 消息区
    • 二级菜单-1
    • 二级菜单-2
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/multi-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
    • 菜单二
  • 调度平台
    • 二级菜单-1
      • 三级菜单-1
      • 三级菜单-2
      • 三级菜单-3
    • 二级菜单-2
  • 精准监控
    • 二级菜单-1
    • 二级菜单-2
  • 根目录
  • 消息区
    • 二级菜单-1
    • 二级菜单-2
  • 仪表盘
  • 资源列表
    • 二级菜单-1
      • 三级菜单-1
      • 三级菜单-2
      • 三级菜单-3
  • 调度平台
    • 二级菜单-1
    • 二级菜单-2
  • 精准监控
    • 二级菜单-1
    • 二级菜单-2
  • 根目录
  • 消息区
    • 二级菜单-1
    • 二级菜单-2
"`; exports[`ssr snapshot test > ssr test src/menu/_example/multiple.tsx 1`] = `"
  • 电器
  • 女装
  • 水果蔬菜
  • 其他
  • 电器
  • 女装
  • 水果蔬菜
  • 其他
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/popup-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/popup-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
"`; exports[`ssr snapshot test > ssr test src/menu/_example/single.tsx 1`] = `"
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
"`; @@ -135205,7 +135204,7 @@ exports[`ssr snapshot test > ssr test src/statistic/_example/trend.tsx 1`] = `"< exports[`ssr snapshot test > ssr test src/steps/_example/extra.tsx 1`] = `"
步骤1
这里是提示文字
2
步骤2
这里是提示文字
3
步骤3
这里是提示文字
4
步骤4
这里是提示文字
"`; -exports[`ssr snapshot test > ssr test src/steps/_example/icon.tsx 1`] = `"
登录
已完成状态
购物
进行中状态
支付
未开始
完成
未开始
"`; +exports[`ssr snapshot test > ssr test src/steps/_example/icon.tsx 1`] = `"
登录
已完成状态
购物
进行中状态
支付
未开始
完成
未开始
"`; exports[`ssr snapshot test > ssr test src/steps/_example/no-sequence.tsx 1`] = `"
已完成的步骤
这里是提示文字
进行中的步骤
这里是提示文字
未进行的步骤
这里是提示文字
未进行的步骤
这里是提示文字
"`; @@ -135265,7 +135264,7 @@ exports[`ssr snapshot test > ssr test src/table/_example/custom-footer.tsx 1`] = exports[`ssr snapshot test > ssr test src/table/_example/custom-header.tsx 1`] = `"
申请人
申请事项
审批状态
邮箱地址
申请时间
贾明宣传物料制作费用
审批通过
w.cezkdudy@lhll.au2022-01-01
张三algolia 服务报销
审批失败
r.nmgw@peurezgn.sl2022-02-01
王芳相关周边制作费
审批过期
p.cumx@rampblpa.ru2022-03-01
贾明激励奖品快递费
审批通过
w.cezkdudy@lhll.au2022-04-01
张三宣传物料制作费用
审批失败
r.nmgw@peurezgn.sl2022-01-01
"`; -exports[`ssr snapshot test > ssr test src/table/_example/data-sort.tsx 1`] = `"
申请人
申请状态
申请耗时(天)
签署方式
邮箱地址
申请时间
贾明
审批通过
2电子签署
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
3纸质签署
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
1纸质签署
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
4电子签署
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
2纸质签署
r.nmgw@peurezgn.sl
2022-01-01
"`; +exports[`ssr snapshot test > ssr test src/table/_example/data-sort.tsx 1`] = `"
申请人
申请状态
申请耗时(天)
签署方式
邮箱地址
申请时间
贾明
审批通过
2电子签署
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
3纸质签署
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
1纸质签署
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
4电子签署
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
2纸质签署
r.nmgw@peurezgn.sl
2022-01-01
"`; exports[`ssr snapshot test > ssr test src/table/_example/drag-col-sort.tsx 1`] = `"
申请人
申请状态
签署方式
邮箱地址
申请时间
贾明
审批通过
电子签署
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
纸质签署
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
纸质签署
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
电子签署
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
纸质签署
r.nmgw@peurezgn.sl
2022-01-01
"`; @@ -135283,7 +135282,7 @@ exports[`ssr snapshot test > ssr test src/table/_example/empty.tsx 1`] = `"
ssr test src/table/_example/expandable.tsx 1`] = `"
申请人
申请状态
签署方式
邮箱地址
申请时间
操作
贾明
审批通过
电子签署
w.cezkdudy@lhll.au
2022-01-01查看详情
张三
审批失败
纸质签署
r.nmgw@peurezgn.sl
2022-02-01再次申请
王芳
审批过期
纸质签署
p.cumx@rampblpa.ru
2022-03-01再次申请
贾明
审批通过
电子签署
w.cezkdudy@lhll.au
2022-04-01查看详情
张三
审批失败
纸质签署
r.nmgw@peurezgn.sl
2022-01-01再次申请
"`; -exports[`ssr snapshot test > ssr test src/table/_example/filter-controlled.tsx 1`] = `"
已选筛选条件:{"lastName":[]}
申请人
申请状态
签署方式
Email
Date
Search "". Find 5 items.
贾明
审批通过
电子签署w.cezkdudy@lhll.au2022-01-01
张三
审批失败
纸质签署r.nmgw@peurezgn.sl2022-02-01
王芳
审批过期
纸质签署p.cumx@rampblpa.ru2022-03-01
贾明
审批通过
电子签署w.cezkdudy@lhll.au2022-04-01
张三
审批失败
纸质签署r.nmgw@peurezgn.sl2022-01-01
Total 0 items
please select
  • 1
jump to
/ 1
"`; +exports[`ssr snapshot test > ssr test src/table/_example/filter-controlled.tsx 1`] = `"
已选筛选条件:{"lastName":[]}
申请人
申请状态
签署方式
Email
Date
Search "". Find 5 items.
贾明
审批通过
电子签署w.cezkdudy@lhll.au2022-01-01
张三
审批失败
纸质签署r.nmgw@peurezgn.sl2022-02-01
王芳
审批过期
纸质签署p.cumx@rampblpa.ru2022-03-01
贾明
审批通过
电子签署w.cezkdudy@lhll.au2022-04-01
张三
审批失败
纸质签署r.nmgw@peurezgn.sl2022-01-01
Total 0 items
please select
  • 1
jump to
/ 1
"`; exports[`ssr snapshot test > ssr test src/table/_example/fixed-column.tsx 1`] = `"
申请人
审批状态
邮箱地址
申请事项
申请日期
操作
贾明
审批通过
w.cezkdudy@lhll.au宣传物料制作费用2022-01-01查看详情
张三
审批失败
r.nmgw@peurezgn.slalgolia 服务报销2022-02-01再次申请
王芳
审批过期
p.cumx@rampblpa.ru相关周边制作费2022-03-01再次申请
贾明
审批通过
w.cezkdudy@lhll.au激励奖品快递费2022-04-01查看详情
张三
审批失败
r.nmgw@peurezgn.sl宣传物料制作费用2022-01-01再次申请
"`; @@ -135293,13 +135292,13 @@ exports[`ssr snapshot test > ssr test src/table/_example/fixed-header-col.tsx 1` exports[`ssr snapshot test > ssr test src/table/_example/lazy.tsx 1`] = `"
申请人
申请状态
申请事项
邮箱地址
申请时间
"`; -exports[`ssr snapshot test > ssr test src/table/_example/loading.tsx 1`] = `"
集群名称
状态
管理员
描述
集群名称
状态
管理员
描述
自定义加载状态文本
集群名称
状态
管理员
描述
  渲染函数自定义加载中(可单独去除内置加载图标)
"`; +exports[`ssr snapshot test > ssr test src/table/_example/loading.tsx 1`] = `"
集群名称
状态
管理员
描述
集群名称
状态
管理员
描述
自定义加载状态文本
集群名称
状态
管理员
描述
  渲染函数自定义加载中(可单独去除内置加载图标)
"`; exports[`ssr snapshot test > ssr test src/table/_example/merge-cells.tsx 1`] = `"
申请人
申请状态
审批事项
邮箱地址
其他信息
"`; -exports[`ssr snapshot test > ssr test src/table/_example/multi-header.tsx 1`] = `"
申请人
申请汇总
住宿费
交通费
物料费
奖品激励费
审批汇总
申请时间
申请状态
申请渠道和金额
审批状态
说明
类型
申请耗时(天)
审批单号
邮箱地址
贾明
审批通过
电子签署3100100100100组长审批审批单号001
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
纸质签署2200200200200部门审批审批单号002
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
纸质签署4400400400400财务审批审批单号003
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
电子签署1500500500500组长审批审批单号004
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
纸质签署3100100100100部门审批审批单号005
r.nmgw@peurezgn.sl
2022-01-01
王芳
审批过期
纸质签署2200200200200财务审批审批单号006
p.cumx@rampblpa.ru
2022-02-01
贾明
审批通过
电子签署4400400400400组长审批审批单号007
w.cezkdudy@lhll.au
2022-03-01
张三
审批失败
纸质签署1500500500500部门审批审批单号008
r.nmgw@peurezgn.sl
2022-04-01
王芳
审批过期
纸质签署3100100100100财务审批审批单号009
p.cumx@rampblpa.ru
2022-01-01
贾明
审批通过
电子签署2200200200200组长审批审批单号0010
w.cezkdudy@lhll.au
2022-02-01
张三
审批失败
纸质签署4400400400400部门审批审批单号0011
r.nmgw@peurezgn.sl
2022-03-01
王芳
审批过期
纸质签署1500500500500财务审批审批单号0012
p.cumx@rampblpa.ru
2022-04-01
贾明
审批通过
电子签署3100100100100组长审批审批单号0013
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
纸质签署2200200200200部门审批审批单号0014
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
纸质签署4400400400400财务审批审批单号0015
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
电子签署1500500500500组长审批审批单号0016
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
纸质签署3100100100100部门审批审批单号0017
r.nmgw@peurezgn.sl
2022-01-01
王芳
审批过期
纸质签署2200200200200财务审批审批单号0018
p.cumx@rampblpa.ru
2022-02-01
贾明
审批通过
电子签署4400400400400组长审批审批单号0019
w.cezkdudy@lhll.au
2022-03-01
张三
审批失败
纸质签署1500500500500部门审批审批单号0020
r.nmgw@peurezgn.sl
2022-04-01
"`; +exports[`ssr snapshot test > ssr test src/table/_example/multi-header.tsx 1`] = `"
申请人
申请汇总
住宿费
交通费
物料费
奖品激励费
审批汇总
申请时间
申请状态
申请渠道和金额
审批状态
说明
类型
申请耗时(天)
审批单号
邮箱地址
贾明
审批通过
电子签署3100100100100组长审批审批单号001
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
纸质签署2200200200200部门审批审批单号002
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
纸质签署4400400400400财务审批审批单号003
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
电子签署1500500500500组长审批审批单号004
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
纸质签署3100100100100部门审批审批单号005
r.nmgw@peurezgn.sl
2022-01-01
王芳
审批过期
纸质签署2200200200200财务审批审批单号006
p.cumx@rampblpa.ru
2022-02-01
贾明
审批通过
电子签署4400400400400组长审批审批单号007
w.cezkdudy@lhll.au
2022-03-01
张三
审批失败
纸质签署1500500500500部门审批审批单号008
r.nmgw@peurezgn.sl
2022-04-01
王芳
审批过期
纸质签署3100100100100财务审批审批单号009
p.cumx@rampblpa.ru
2022-01-01
贾明
审批通过
电子签署2200200200200组长审批审批单号0010
w.cezkdudy@lhll.au
2022-02-01
张三
审批失败
纸质签署4400400400400部门审批审批单号0011
r.nmgw@peurezgn.sl
2022-03-01
王芳
审批过期
纸质签署1500500500500财务审批审批单号0012
p.cumx@rampblpa.ru
2022-04-01
贾明
审批通过
电子签署3100100100100组长审批审批单号0013
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
纸质签署2200200200200部门审批审批单号0014
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
纸质签署4400400400400财务审批审批单号0015
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
电子签署1500500500500组长审批审批单号0016
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
纸质签署3100100100100部门审批审批单号0017
r.nmgw@peurezgn.sl
2022-01-01
王芳
审批过期
纸质签署2200200200200财务审批审批单号0018
p.cumx@rampblpa.ru
2022-02-01
贾明
审批通过
电子签署4400400400400组长审批审批单号0019
w.cezkdudy@lhll.au
2022-03-01
张三
审批失败
纸质签署1500500500500部门审批审批单号0020
r.nmgw@peurezgn.sl
2022-04-01
"`; -exports[`ssr snapshot test > ssr test src/table/_example/multiple-sort.tsx 1`] = `"
排序方式:[{"sortBy":"status","descending":true},{"sortBy":"survivalTime","descending":false}]
申请人
申请状态
申请耗时(天)
签署方式
邮箱地址
申请时间
贾明
审批通过
2电子签署
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
3纸质签署
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
1纸质签署
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
4电子签署
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
2纸质签署
r.nmgw@peurezgn.sl
2022-01-01
"`; +exports[`ssr snapshot test > ssr test src/table/_example/multiple-sort.tsx 1`] = `"
排序方式:[{"sortBy":"status","descending":true},{"sortBy":"survivalTime","descending":false}]
申请人
申请状态
申请耗时(天)
签署方式
邮箱地址
申请时间
贾明
审批通过
2电子签署
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
3纸质签署
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
1纸质签署
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
4电子签署
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
2纸质签署
r.nmgw@peurezgn.sl
2022-01-01
"`; exports[`ssr snapshot test > ssr test src/table/_example/pagination.tsx 1`] = `"
序号
申请人
申请状态
签署方式
申请时间
6贾明
审批通过
电子签署2022-01-01
7张三
审批失败
纸质签署2022-02-01
8王芳
审批过期
纸质签署2022-03-01
9贾明
审批通过
电子签署2022-04-01
10张三
审批失败
纸质签署2022-01-01
11王芳
审批过期
纸质签署2022-02-01
12贾明
审批通过
电子签署2022-03-01
13张三
审批失败
纸质签署2022-04-01
14王芳
审批过期
纸质签署2022-01-01
15贾明
审批通过
电子签署2022-02-01
16张三
审批失败
纸质签署2022-03-01
17王芳
审批过期
纸质签署2022-04-01
18贾明
审批通过
电子签署2022-01-01
19张三
审批失败
纸质签署2022-02-01
20王芳
审批过期
纸质签署2022-03-01
21贾明
审批通过
电子签署2022-04-01
22张三
审批失败
纸质签署2022-01-01
23王芳
审批过期
纸质签署2022-02-01
24贾明
审批通过
电子签署2022-03-01
25张三
审批失败
纸质签署2022-04-01
26王芳
审批过期
纸质签署2022-01-01
27贾明
审批通过
电子签署2022-02-01
28张三
审批失败
纸质签署2022-03-01
29王芳
审批过期
纸质签署2022-04-01
30贾明
审批通过
电子签署2022-01-01
31张三
审批失败
纸质签署2022-02-01
32王芳
审批过期
纸质签署2022-03-01
33贾明
审批通过
电子签署2022-04-01
34张三
审批失败
纸质签署2022-01-01
35王芳
审批过期
纸质签署2022-02-01
36贾明
审批通过
电子签署2022-03-01
37张三
审批失败
纸质签署2022-04-01
38王芳
审批过期
纸质签署2022-01-01
39贾明
审批通过
电子签署2022-02-01
40张三
审批失败
纸质签署2022-03-01
41王芳
审批过期
纸质签署2022-04-01
42贾明
审批通过
电子签署2022-01-01
43张三
审批失败
纸质签署2022-02-01
44王芳
审批过期
纸质签署2022-03-01
45贾明
审批通过
电子签署2022-04-01
46张三
审批失败
纸质签署2022-01-01
47王芳
审批过期
纸质签署2022-02-01
48贾明
审批通过
电子签署2022-03-01
49张三
审批失败
纸质签署2022-04-01
50王芳
审批过期
纸质签署2022-01-01
51贾明
审批通过
电子签署2022-02-01
52张三
审批失败
纸质签署2022-03-01
53王芳
审批过期
纸质签署2022-04-01
54贾明
审批通过
电子签署2022-01-01
55张三
审批失败
纸质签署2022-02-01
56王芳
审批过期
纸质签署2022-03-01
57贾明
审批通过
电子签署2022-04-01
58张三
审批失败
纸质签署2022-01-01
59王芳
审批过期
纸质签署2022-02-01
60贾明
审批通过
电子签署2022-03-01
61张三
审批失败
纸质签署2022-04-01
62王芳
审批过期
纸质签署2022-01-01
63贾明
审批通过
电子签署2022-02-01
64张三
审批失败
纸质签署2022-03-01
Total 59 items
please select
  • 1
  • 2
  • 3
  • 4
  • 5
  • 12
jump to
/ 12
"`; @@ -135307,7 +135306,7 @@ exports[`ssr snapshot test > ssr test src/table/_example/select-multiple.tsx 1`] exports[`ssr snapshot test > ssr test src/table/_example/select-single.tsx 1`] = `"
申请人
申请状态
签署方式
邮箱地址
申请时间
贾明
审批通过
电子签署
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
纸质签署
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
纸质签署
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
电子签署
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
纸质签署
r.nmgw@peurezgn.sl
2022-01-01
"`; -exports[`ssr snapshot test > ssr test src/table/_example/single-sort.tsx 1`] = `"
排序方式:{"sortBy":"status","descending":true}
申请人
申请状态
申请耗时(天)
签署方式
申请时间
贾明
审批通过
2电子签署2022-01-01
张三
审批失败
3纸质签署2022-02-01
王芳
审批过期
1纸质签署2022-03-01
贾明
审批通过
4电子签署2022-04-01
"`; +exports[`ssr snapshot test > ssr test src/table/_example/single-sort.tsx 1`] = `"
排序方式:{"sortBy":"status","descending":true}
申请人
申请状态
申请耗时(天)
签署方式
申请时间
贾明
审批通过
2电子签署2022-01-01
张三
审批失败
3纸质签署2022-02-01
王芳
审批过期
1纸质签署2022-03-01
贾明
审批通过
4电子签署2022-04-01
"`; exports[`ssr snapshot test > ssr test src/table/_example/style.tsx 1`] = `"
申请人
审批状态
申请耗时(天)
签署方式
邮箱地址
申请时间
贾明
审批通过
2电子签署
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
10纸质签署
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
1纸质签署
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
2电子签署
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
10纸质签署
r.nmgw@peurezgn.sl
2022-01-01
汇总:近期数据波动较大
"`; @@ -135503,7 +135502,7 @@ exports[`ssr snapshot test > ssr test src/tree-select/_example/panelContent.tsx exports[`ssr snapshot test > ssr test src/tree-select/_example/prefix.tsx 1`] = `"
"`; -exports[`ssr snapshot test > ssr test src/tree-select/_example/prefixsuffix.tsx 1`] = `"
"`; +exports[`ssr snapshot test > ssr test src/tree-select/_example/prefixsuffix.tsx 1`] = `"
"`; exports[`ssr snapshot test > ssr test src/tree-select/_example/props.tsx 1`] = `"
"`; diff --git a/test/snap/__snapshots__/ssr.test.jsx.snap b/test/snap/__snapshots__/ssr.test.jsx.snap index 3cd515a58f..bd535011b8 100644 --- a/test/snap/__snapshots__/ssr.test.jsx.snap +++ b/test/snap/__snapshots__/ssr.test.jsx.snap @@ -254,7 +254,7 @@ exports[`ssr snapshot test > ssr test src/comment/_example/operation.tsx 1`] = ` exports[`ssr snapshot test > ssr test src/comment/_example/quote.tsx 1`] = `"
评论作者名A今天16:38
A评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容。
引用内容标题
引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容引用内容。
"`; -exports[`ssr snapshot test > ssr test src/comment/_example/reply.tsx 1`] = `"
评论作者名A今天16:38
A评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容。
评论作者名B评论作者名A今天16:38
B评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容。
"`; +exports[`ssr snapshot test > ssr test src/comment/_example/reply.tsx 1`] = `"
评论作者名A今天16:38
A评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容。
评论作者名B评论作者名A今天16:38
B评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容评论内容。
"`; exports[`ssr snapshot test > ssr test src/comment/_example/reply-form.tsx 1`] = `"
"`; @@ -272,7 +272,7 @@ exports[`ssr snapshot test > ssr test src/config-provider/_example/pagination.ts exports[`ssr snapshot test > ssr test src/config-provider/_example/popconfirm.tsx 1`] = `"
"`; -exports[`ssr snapshot test > ssr test src/config-provider/_example/table.tsx 1`] = `"
Type
Platform
Property
Empty Data
Type
Platform
Property
ArrayVue(PC)A
StringReact(PC)B
ObjectMiniprogramC
"`; +exports[`ssr snapshot test > ssr test src/config-provider/_example/table.tsx 1`] = `"
Type
Platform
Property
Empty Data
Type
Platform
Property
ArrayVue(PC)A
StringReact(PC)B
ObjectMiniprogramC
"`; exports[`ssr snapshot test > ssr test src/date-picker/_example/base.tsx 1`] = `"
"`; @@ -622,7 +622,7 @@ exports[`ssr snapshot test > ssr test src/loading/_example/text.tsx 1`] = `"
ssr test src/loading/_example/wrap.tsx 1`] = `"
this is loading component
this is loading component
this is loading component
this is loading component
this is loading component
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/closable-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/closable-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
"`; exports[`ssr snapshot test > ssr test src/menu/_example/custom-header.tsx 1`] = `"
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
"`; @@ -630,13 +630,13 @@ exports[`ssr snapshot test > ssr test src/menu/_example/custom-side.tsx 1`] = `" exports[`ssr snapshot test > ssr test src/menu/_example/double.tsx 1`] = `"
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
    子菜单1
    子菜单2
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
    子菜单1
    子菜单2
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/group-side.tsx 1`] = `"
    主导航
  • 仪表盘
  • 组件
  • 列表项
    • 基础列表项
    • 卡片列表项
    • 筛选列表项
    • 树状筛选列表项
  • 表单项
  • 详情页
  • 结果页
  • 更多
  • 个人页
  • 登录页
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/group-side.tsx 1`] = `"
    主导航
  • 仪表盘
  • 组件
  • 列表项
    • 基础列表项
    • 卡片列表项
    • 筛选列表项
    • 树状筛选列表项
  • 表单项
  • 详情页
  • 结果页
  • 更多
  • 个人页
  • 登录页
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/multi-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
    • 菜单二
  • 调度平台
    • 二级菜单-1
      • 三级菜单-1
      • 三级菜单-2
      • 三级菜单-3
    • 二级菜单-2
  • 精准监控
    • 二级菜单-1
    • 二级菜单-2
  • 根目录
  • 消息区
    • 二级菜单-1
    • 二级菜单-2
  • 仪表盘
  • 资源列表
    • 二级菜单-1
      • 三级菜单-1
      • 三级菜单-2
      • 三级菜单-3
  • 调度平台
    • 二级菜单-1
    • 二级菜单-2
  • 精准监控
    • 二级菜单-1
    • 二级菜单-2
  • 根目录
  • 消息区
    • 二级菜单-1
    • 二级菜单-2
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/multi-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
    • 菜单二
  • 调度平台
    • 二级菜单-1
      • 三级菜单-1
      • 三级菜单-2
      • 三级菜单-3
    • 二级菜单-2
  • 精准监控
    • 二级菜单-1
    • 二级菜单-2
  • 根目录
  • 消息区
    • 二级菜单-1
    • 二级菜单-2
  • 仪表盘
  • 资源列表
    • 二级菜单-1
      • 三级菜单-1
      • 三级菜单-2
      • 三级菜单-3
  • 调度平台
    • 二级菜单-1
    • 二级菜单-2
  • 精准监控
    • 二级菜单-1
    • 二级菜单-2
  • 根目录
  • 消息区
    • 二级菜单-1
    • 二级菜单-2
"`; exports[`ssr snapshot test > ssr test src/menu/_example/multiple.tsx 1`] = `"
  • 电器
  • 女装
  • 水果蔬菜
  • 其他
  • 电器
  • 女装
  • 水果蔬菜
  • 其他
"`; -exports[`ssr snapshot test > ssr test src/menu/_example/popup-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
"`; +exports[`ssr snapshot test > ssr test src/menu/_example/popup-side.tsx 1`] = `"
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
  • 仪表盘
  • 资源列表
  • 调度平台
  • 精准监控
  • 根目录
  • 消息区
"`; exports[`ssr snapshot test > ssr test src/menu/_example/single.tsx 1`] = `"
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
  • 菜单1
  • 菜单2
  • 菜单3
  • 菜单4
"`; @@ -902,7 +902,7 @@ exports[`ssr snapshot test > ssr test src/statistic/_example/trend.tsx 1`] = `"< exports[`ssr snapshot test > ssr test src/steps/_example/extra.tsx 1`] = `"
步骤1
这里是提示文字
2
步骤2
这里是提示文字
3
步骤3
这里是提示文字
4
步骤4
这里是提示文字
"`; -exports[`ssr snapshot test > ssr test src/steps/_example/icon.tsx 1`] = `"
登录
已完成状态
购物
进行中状态
支付
未开始
完成
未开始
"`; +exports[`ssr snapshot test > ssr test src/steps/_example/icon.tsx 1`] = `"
登录
已完成状态
购物
进行中状态
支付
未开始
完成
未开始
"`; exports[`ssr snapshot test > ssr test src/steps/_example/no-sequence.tsx 1`] = `"
已完成的步骤
这里是提示文字
进行中的步骤
这里是提示文字
未进行的步骤
这里是提示文字
未进行的步骤
这里是提示文字
"`; @@ -962,7 +962,7 @@ exports[`ssr snapshot test > ssr test src/table/_example/custom-footer.tsx 1`] = exports[`ssr snapshot test > ssr test src/table/_example/custom-header.tsx 1`] = `"
申请人
申请事项
审批状态
邮箱地址
申请时间
贾明宣传物料制作费用
审批通过
w.cezkdudy@lhll.au2022-01-01
张三algolia 服务报销
审批失败
r.nmgw@peurezgn.sl2022-02-01
王芳相关周边制作费
审批过期
p.cumx@rampblpa.ru2022-03-01
贾明激励奖品快递费
审批通过
w.cezkdudy@lhll.au2022-04-01
张三宣传物料制作费用
审批失败
r.nmgw@peurezgn.sl2022-01-01
"`; -exports[`ssr snapshot test > ssr test src/table/_example/data-sort.tsx 1`] = `"
申请人
申请状态
申请耗时(天)
签署方式
邮箱地址
申请时间
贾明
审批通过
2电子签署
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
3纸质签署
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
1纸质签署
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
4电子签署
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
2纸质签署
r.nmgw@peurezgn.sl
2022-01-01
"`; +exports[`ssr snapshot test > ssr test src/table/_example/data-sort.tsx 1`] = `"
申请人
申请状态
申请耗时(天)
签署方式
邮箱地址
申请时间
贾明
审批通过
2电子签署
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
3纸质签署
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
1纸质签署
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
4电子签署
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
2纸质签署
r.nmgw@peurezgn.sl
2022-01-01
"`; exports[`ssr snapshot test > ssr test src/table/_example/drag-col-sort.tsx 1`] = `"
申请人
申请状态
签署方式
邮箱地址
申请时间
贾明
审批通过
电子签署
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
纸质签署
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
纸质签署
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
电子签署
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
纸质签署
r.nmgw@peurezgn.sl
2022-01-01
"`; @@ -980,7 +980,7 @@ exports[`ssr snapshot test > ssr test src/table/_example/empty.tsx 1`] = `"
ssr test src/table/_example/expandable.tsx 1`] = `"
申请人
申请状态
签署方式
邮箱地址
申请时间
操作
贾明
审批通过
电子签署
w.cezkdudy@lhll.au
2022-01-01查看详情
张三
审批失败
纸质签署
r.nmgw@peurezgn.sl
2022-02-01再次申请
王芳
审批过期
纸质签署
p.cumx@rampblpa.ru
2022-03-01再次申请
贾明
审批通过
电子签署
w.cezkdudy@lhll.au
2022-04-01查看详情
张三
审批失败
纸质签署
r.nmgw@peurezgn.sl
2022-01-01再次申请
"`; -exports[`ssr snapshot test > ssr test src/table/_example/filter-controlled.tsx 1`] = `"
已选筛选条件:{"lastName":[]}
申请人
申请状态
签署方式
Email
Date
Search "". Find 5 items.
贾明
审批通过
电子签署w.cezkdudy@lhll.au2022-01-01
张三
审批失败
纸质签署r.nmgw@peurezgn.sl2022-02-01
王芳
审批过期
纸质签署p.cumx@rampblpa.ru2022-03-01
贾明
审批通过
电子签署w.cezkdudy@lhll.au2022-04-01
张三
审批失败
纸质签署r.nmgw@peurezgn.sl2022-01-01
Total 0 items
please select
  • 1
jump to
/ 1
"`; +exports[`ssr snapshot test > ssr test src/table/_example/filter-controlled.tsx 1`] = `"
已选筛选条件:{"lastName":[]}
申请人
申请状态
签署方式
Email
Date
Search "". Find 5 items.
贾明
审批通过
电子签署w.cezkdudy@lhll.au2022-01-01
张三
审批失败
纸质签署r.nmgw@peurezgn.sl2022-02-01
王芳
审批过期
纸质签署p.cumx@rampblpa.ru2022-03-01
贾明
审批通过
电子签署w.cezkdudy@lhll.au2022-04-01
张三
审批失败
纸质签署r.nmgw@peurezgn.sl2022-01-01
Total 0 items
please select
  • 1
jump to
/ 1
"`; exports[`ssr snapshot test > ssr test src/table/_example/fixed-column.tsx 1`] = `"
申请人
审批状态
邮箱地址
申请事项
申请日期
操作
贾明
审批通过
w.cezkdudy@lhll.au宣传物料制作费用2022-01-01查看详情
张三
审批失败
r.nmgw@peurezgn.slalgolia 服务报销2022-02-01再次申请
王芳
审批过期
p.cumx@rampblpa.ru相关周边制作费2022-03-01再次申请
贾明
审批通过
w.cezkdudy@lhll.au激励奖品快递费2022-04-01查看详情
张三
审批失败
r.nmgw@peurezgn.sl宣传物料制作费用2022-01-01再次申请
"`; @@ -990,13 +990,13 @@ exports[`ssr snapshot test > ssr test src/table/_example/fixed-header-col.tsx 1` exports[`ssr snapshot test > ssr test src/table/_example/lazy.tsx 1`] = `"
申请人
申请状态
申请事项
邮箱地址
申请时间
"`; -exports[`ssr snapshot test > ssr test src/table/_example/loading.tsx 1`] = `"
集群名称
状态
管理员
描述
集群名称
状态
管理员
描述
自定义加载状态文本
集群名称
状态
管理员
描述
  渲染函数自定义加载中(可单独去除内置加载图标)
"`; +exports[`ssr snapshot test > ssr test src/table/_example/loading.tsx 1`] = `"
集群名称
状态
管理员
描述
集群名称
状态
管理员
描述
自定义加载状态文本
集群名称
状态
管理员
描述
  渲染函数自定义加载中(可单独去除内置加载图标)
"`; exports[`ssr snapshot test > ssr test src/table/_example/merge-cells.tsx 1`] = `"
申请人
申请状态
审批事项
邮箱地址
其他信息
"`; -exports[`ssr snapshot test > ssr test src/table/_example/multi-header.tsx 1`] = `"
申请人
申请汇总
住宿费
交通费
物料费
奖品激励费
审批汇总
申请时间
申请状态
申请渠道和金额
审批状态
说明
类型
申请耗时(天)
审批单号
邮箱地址
贾明
审批通过
电子签署3100100100100组长审批审批单号001
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
纸质签署2200200200200部门审批审批单号002
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
纸质签署4400400400400财务审批审批单号003
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
电子签署1500500500500组长审批审批单号004
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
纸质签署3100100100100部门审批审批单号005
r.nmgw@peurezgn.sl
2022-01-01
王芳
审批过期
纸质签署2200200200200财务审批审批单号006
p.cumx@rampblpa.ru
2022-02-01
贾明
审批通过
电子签署4400400400400组长审批审批单号007
w.cezkdudy@lhll.au
2022-03-01
张三
审批失败
纸质签署1500500500500部门审批审批单号008
r.nmgw@peurezgn.sl
2022-04-01
王芳
审批过期
纸质签署3100100100100财务审批审批单号009
p.cumx@rampblpa.ru
2022-01-01
贾明
审批通过
电子签署2200200200200组长审批审批单号0010
w.cezkdudy@lhll.au
2022-02-01
张三
审批失败
纸质签署4400400400400部门审批审批单号0011
r.nmgw@peurezgn.sl
2022-03-01
王芳
审批过期
纸质签署1500500500500财务审批审批单号0012
p.cumx@rampblpa.ru
2022-04-01
贾明
审批通过
电子签署3100100100100组长审批审批单号0013
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
纸质签署2200200200200部门审批审批单号0014
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
纸质签署4400400400400财务审批审批单号0015
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
电子签署1500500500500组长审批审批单号0016
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
纸质签署3100100100100部门审批审批单号0017
r.nmgw@peurezgn.sl
2022-01-01
王芳
审批过期
纸质签署2200200200200财务审批审批单号0018
p.cumx@rampblpa.ru
2022-02-01
贾明
审批通过
电子签署4400400400400组长审批审批单号0019
w.cezkdudy@lhll.au
2022-03-01
张三
审批失败
纸质签署1500500500500部门审批审批单号0020
r.nmgw@peurezgn.sl
2022-04-01
"`; +exports[`ssr snapshot test > ssr test src/table/_example/multi-header.tsx 1`] = `"
申请人
申请汇总
住宿费
交通费
物料费
奖品激励费
审批汇总
申请时间
申请状态
申请渠道和金额
审批状态
说明
类型
申请耗时(天)
审批单号
邮箱地址
贾明
审批通过
电子签署3100100100100组长审批审批单号001
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
纸质签署2200200200200部门审批审批单号002
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
纸质签署4400400400400财务审批审批单号003
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
电子签署1500500500500组长审批审批单号004
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
纸质签署3100100100100部门审批审批单号005
r.nmgw@peurezgn.sl
2022-01-01
王芳
审批过期
纸质签署2200200200200财务审批审批单号006
p.cumx@rampblpa.ru
2022-02-01
贾明
审批通过
电子签署4400400400400组长审批审批单号007
w.cezkdudy@lhll.au
2022-03-01
张三
审批失败
纸质签署1500500500500部门审批审批单号008
r.nmgw@peurezgn.sl
2022-04-01
王芳
审批过期
纸质签署3100100100100财务审批审批单号009
p.cumx@rampblpa.ru
2022-01-01
贾明
审批通过
电子签署2200200200200组长审批审批单号0010
w.cezkdudy@lhll.au
2022-02-01
张三
审批失败
纸质签署4400400400400部门审批审批单号0011
r.nmgw@peurezgn.sl
2022-03-01
王芳
审批过期
纸质签署1500500500500财务审批审批单号0012
p.cumx@rampblpa.ru
2022-04-01
贾明
审批通过
电子签署3100100100100组长审批审批单号0013
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
纸质签署2200200200200部门审批审批单号0014
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
纸质签署4400400400400财务审批审批单号0015
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
电子签署1500500500500组长审批审批单号0016
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
纸质签署3100100100100部门审批审批单号0017
r.nmgw@peurezgn.sl
2022-01-01
王芳
审批过期
纸质签署2200200200200财务审批审批单号0018
p.cumx@rampblpa.ru
2022-02-01
贾明
审批通过
电子签署4400400400400组长审批审批单号0019
w.cezkdudy@lhll.au
2022-03-01
张三
审批失败
纸质签署1500500500500部门审批审批单号0020
r.nmgw@peurezgn.sl
2022-04-01
"`; -exports[`ssr snapshot test > ssr test src/table/_example/multiple-sort.tsx 1`] = `"
排序方式:[{"sortBy":"status","descending":true},{"sortBy":"survivalTime","descending":false}]
申请人
申请状态
申请耗时(天)
签署方式
邮箱地址
申请时间
贾明
审批通过
2电子签署
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
3纸质签署
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
1纸质签署
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
4电子签署
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
2纸质签署
r.nmgw@peurezgn.sl
2022-01-01
"`; +exports[`ssr snapshot test > ssr test src/table/_example/multiple-sort.tsx 1`] = `"
排序方式:[{"sortBy":"status","descending":true},{"sortBy":"survivalTime","descending":false}]
申请人
申请状态
申请耗时(天)
签署方式
邮箱地址
申请时间
贾明
审批通过
2电子签署
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
3纸质签署
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
1纸质签署
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
4电子签署
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
2纸质签署
r.nmgw@peurezgn.sl
2022-01-01
"`; exports[`ssr snapshot test > ssr test src/table/_example/pagination.tsx 1`] = `"
序号
申请人
申请状态
签署方式
申请时间
6贾明
审批通过
电子签署2022-01-01
7张三
审批失败
纸质签署2022-02-01
8王芳
审批过期
纸质签署2022-03-01
9贾明
审批通过
电子签署2022-04-01
10张三
审批失败
纸质签署2022-01-01
11王芳
审批过期
纸质签署2022-02-01
12贾明
审批通过
电子签署2022-03-01
13张三
审批失败
纸质签署2022-04-01
14王芳
审批过期
纸质签署2022-01-01
15贾明
审批通过
电子签署2022-02-01
16张三
审批失败
纸质签署2022-03-01
17王芳
审批过期
纸质签署2022-04-01
18贾明
审批通过
电子签署2022-01-01
19张三
审批失败
纸质签署2022-02-01
20王芳
审批过期
纸质签署2022-03-01
21贾明
审批通过
电子签署2022-04-01
22张三
审批失败
纸质签署2022-01-01
23王芳
审批过期
纸质签署2022-02-01
24贾明
审批通过
电子签署2022-03-01
25张三
审批失败
纸质签署2022-04-01
26王芳
审批过期
纸质签署2022-01-01
27贾明
审批通过
电子签署2022-02-01
28张三
审批失败
纸质签署2022-03-01
29王芳
审批过期
纸质签署2022-04-01
30贾明
审批通过
电子签署2022-01-01
31张三
审批失败
纸质签署2022-02-01
32王芳
审批过期
纸质签署2022-03-01
33贾明
审批通过
电子签署2022-04-01
34张三
审批失败
纸质签署2022-01-01
35王芳
审批过期
纸质签署2022-02-01
36贾明
审批通过
电子签署2022-03-01
37张三
审批失败
纸质签署2022-04-01
38王芳
审批过期
纸质签署2022-01-01
39贾明
审批通过
电子签署2022-02-01
40张三
审批失败
纸质签署2022-03-01
41王芳
审批过期
纸质签署2022-04-01
42贾明
审批通过
电子签署2022-01-01
43张三
审批失败
纸质签署2022-02-01
44王芳
审批过期
纸质签署2022-03-01
45贾明
审批通过
电子签署2022-04-01
46张三
审批失败
纸质签署2022-01-01
47王芳
审批过期
纸质签署2022-02-01
48贾明
审批通过
电子签署2022-03-01
49张三
审批失败
纸质签署2022-04-01
50王芳
审批过期
纸质签署2022-01-01
51贾明
审批通过
电子签署2022-02-01
52张三
审批失败
纸质签署2022-03-01
53王芳
审批过期
纸质签署2022-04-01
54贾明
审批通过
电子签署2022-01-01
55张三
审批失败
纸质签署2022-02-01
56王芳
审批过期
纸质签署2022-03-01
57贾明
审批通过
电子签署2022-04-01
58张三
审批失败
纸质签署2022-01-01
59王芳
审批过期
纸质签署2022-02-01
60贾明
审批通过
电子签署2022-03-01
61张三
审批失败
纸质签署2022-04-01
62王芳
审批过期
纸质签署2022-01-01
63贾明
审批通过
电子签署2022-02-01
64张三
审批失败
纸质签署2022-03-01
Total 59 items
please select
  • 1
  • 2
  • 3
  • 4
  • 5
  • 12
jump to
/ 12
"`; @@ -1004,7 +1004,7 @@ exports[`ssr snapshot test > ssr test src/table/_example/select-multiple.tsx 1`] exports[`ssr snapshot test > ssr test src/table/_example/select-single.tsx 1`] = `"
申请人
申请状态
签署方式
邮箱地址
申请时间
贾明
审批通过
电子签署
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
纸质签署
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
纸质签署
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
电子签署
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
纸质签署
r.nmgw@peurezgn.sl
2022-01-01
"`; -exports[`ssr snapshot test > ssr test src/table/_example/single-sort.tsx 1`] = `"
排序方式:{"sortBy":"status","descending":true}
申请人
申请状态
申请耗时(天)
签署方式
申请时间
贾明
审批通过
2电子签署2022-01-01
张三
审批失败
3纸质签署2022-02-01
王芳
审批过期
1纸质签署2022-03-01
贾明
审批通过
4电子签署2022-04-01
"`; +exports[`ssr snapshot test > ssr test src/table/_example/single-sort.tsx 1`] = `"
排序方式:{"sortBy":"status","descending":true}
申请人
申请状态
申请耗时(天)
签署方式
申请时间
贾明
审批通过
2电子签署2022-01-01
张三
审批失败
3纸质签署2022-02-01
王芳
审批过期
1纸质签署2022-03-01
贾明
审批通过
4电子签署2022-04-01
"`; exports[`ssr snapshot test > ssr test src/table/_example/style.tsx 1`] = `"
申请人
审批状态
申请耗时(天)
签署方式
邮箱地址
申请时间
贾明
审批通过
2电子签署
w.cezkdudy@lhll.au
2022-01-01
张三
审批失败
10纸质签署
r.nmgw@peurezgn.sl
2022-02-01
王芳
审批过期
1纸质签署
p.cumx@rampblpa.ru
2022-03-01
贾明
审批通过
2电子签署
w.cezkdudy@lhll.au
2022-04-01
张三
审批失败
10纸质签署
r.nmgw@peurezgn.sl
2022-01-01
汇总:近期数据波动较大
"`; @@ -1200,7 +1200,7 @@ exports[`ssr snapshot test > ssr test src/tree-select/_example/panelContent.tsx exports[`ssr snapshot test > ssr test src/tree-select/_example/prefix.tsx 1`] = `"
"`; -exports[`ssr snapshot test > ssr test src/tree-select/_example/prefixsuffix.tsx 1`] = `"
"`; +exports[`ssr snapshot test > ssr test src/tree-select/_example/prefixsuffix.tsx 1`] = `"
"`; exports[`ssr snapshot test > ssr test src/tree-select/_example/props.tsx 1`] = `"
"`; From 80f67ca17bf8b7a47fa4003f581c00598be247d0 Mon Sep 17 00:00:00 2001 From: lifeiFront Date: Thu, 16 Jan 2025 15:31:44 +0800 Subject: [PATCH 28/61] chore(site): fix effect deps lint miss dep --- site/src/App.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/site/src/App.jsx b/site/src/App.jsx index 153e727177..02f8d626d9 100644 --- a/site/src/App.jsx +++ b/site/src/App.jsx @@ -97,6 +97,7 @@ function Components() { }; initHistoryVersions(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); useEffect(() => { From 02953a17d024bdba6b1887a45a181cc774455d63 Mon Sep 17 00:00:00 2001 From: huangchen1031 Date: Thu, 16 Jan 2025 15:32:16 +0800 Subject: [PATCH 29/61] =?UTF-8?q?fix(statistic):=20decimalPlaces=3D0?= =?UTF-8?q?=E6=97=B6=E6=95=B0=E5=80=BC=E5=8A=A8=E7=94=BB=E6=9C=9F=E9=97=B4?= =?UTF-8?q?=E7=B2=BE=E5=BA=A6=E9=94=99=E8=AF=AF=20(#3327)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(statistic): decimalPlaces=0时数值动画期间精度错误 * fix(statistic): 改为使用getFormatValue方法 --- src/statistic/Statistic.tsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/statistic/Statistic.tsx b/src/statistic/Statistic.tsx index 9961b26d05..f78a22cdd0 100644 --- a/src/statistic/Statistic.tsx +++ b/src/statistic/Statistic.tsx @@ -16,7 +16,7 @@ import useIsFirstRender from '../hooks/useIsFirstRender'; import Skeleton from '../skeleton'; import Tween from '../_common/js/statistic/tween'; -import { COLOR_MAP } from '../_common/js/statistic/utils'; +import { COLOR_MAP, getFormatValue } from '../_common/js/statistic/utils'; export interface StatisticProps extends TdStatisticProps, StyledProps {} @@ -85,13 +85,9 @@ const Statistic = forwardRef((props, ref) => { if (isFunction(format)) { return format(formatInnerValue); } - const options = { - minimumFractionDigits: decimalPlaces || 0, - maximumFractionDigits: decimalPlaces || 20, - useGrouping: !!separator, - }; + // replace的替换的方案仅能应对大部分地区 - formatInnerValue = formatInnerValue.toLocaleString(undefined, options).replace(/,|,/g, separator); + formatInnerValue = getFormatValue(formatInnerValue, decimalPlaces, separator); return formatInnerValue; }, [innerValue, decimalPlaces, separator, format]); From d9176bff3e38aab6d7023342181655ce8d5ca92d Mon Sep 17 00:00:00 2001 From: huangchen1031 Date: Thu, 16 Jan 2025 16:54:35 +0800 Subject: [PATCH 30/61] fix(color-picker): coloerInstanceRef value is not updated, causing re-render problems --- src/color-picker/components/panel/index.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/color-picker/components/panel/index.tsx b/src/color-picker/components/panel/index.tsx index 8c17bf47d7..a7b785fe58 100644 --- a/src/color-picker/components/panel/index.tsx +++ b/src/color-picker/components/panel/index.tsx @@ -56,7 +56,6 @@ const Panel = forwardRef((props, ref) => { const [recentlyUsedColors, setRecentlyUsedColors] = useControlled(props, 'recentColors', onRecentColorsChange, { defaultRecentColors: colorPickerDefaultProps.recentColors, }); - const colorInstanceRef = useRef(new Color(innerValue || defaultEmptyColor)); const getModeByColor = colorInstanceRef.current.isGradient ? 'linear-gradient' : 'monochrome'; const formatRef = useRef(colorInstanceRef.current.isGradient ? 'CSS' : format ?? 'RGB'); @@ -80,12 +79,14 @@ const Panel = forwardRef((props, ref) => { const emitColorChange = useCallback( (trigger?: ColorPickerChangeTrigger) => { - setInnerValue(formatValue(), { + const value = formatValue(); + setInnerValue(value, { color: getColorObject(colorInstanceRef.current), trigger: trigger || 'palette-saturation-brightness', }); + update(value); }, - [formatValue, setInnerValue], + [formatValue, setInnerValue, update], ); useEffect(() => { From be7722bd3d13ca8343e37c7da0879afe12ed4d84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?w=C5=AB=20y=C4=81ng?= Date: Thu, 16 Jan 2025 18:16:01 +0800 Subject: [PATCH 31/61] chore: remove unsupported demo and update common (#3333) --- src/_common | 2 +- src/form/_example/customized-form-controls.tsx | 11 ----------- test/snap/__snapshots__/csr.test.jsx.snap | 13 +------------ test/snap/__snapshots__/ssr.test.jsx.snap | 2 +- 4 files changed, 3 insertions(+), 25 deletions(-) diff --git a/src/_common b/src/_common index c569a218ec..01a5dbe678 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit c569a218ec1547b4924c429337237ebdcf3b23d3 +Subproject commit 01a5dbe6785dea1897f0298812c63a5c90dfe0c2 diff --git a/src/form/_example/customized-form-controls.tsx b/src/form/_example/customized-form-controls.tsx index 43a5340001..3ec0aca4a3 100644 --- a/src/form/_example/customized-form-controls.tsx +++ b/src/form/_example/customized-form-controls.tsx @@ -60,14 +60,6 @@ export default function BaseForm() { MessagePlugin.info('提交成功'); } }; - const setData = () => { - form.setFieldsValue?.({ - course: { - type: 'math', - name: '线性代数', - }, - }); - }; return (
@@ -78,9 +70,6 @@ export default function BaseForm() { -
); diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index 748fe8931d..9fb7f36a1b 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -42826,17 +42826,6 @@ exports[`csr snapshot test > csr test src/form/_example/customized-form-controls 提交 -
@@ -134710,7 +134699,7 @@ exports[`ssr snapshot test > ssr test src/form/_example/clear-validate.tsx 1`] = exports[`ssr snapshot test > ssr test src/form/_example/custom-validator.tsx 1`] = `"
"`; -exports[`ssr snapshot test > ssr test src/form/_example/customized-form-controls.tsx 1`] = `"
:
"`; +exports[`ssr snapshot test > ssr test src/form/_example/customized-form-controls.tsx 1`] = `"
:
"`; exports[`ssr snapshot test > ssr test src/form/_example/disabled.tsx 1`] = `"
:
:
:
:
:
:
:
:
:
:
:
请选择单张图片文件上传
提交
重置
"`; diff --git a/test/snap/__snapshots__/ssr.test.jsx.snap b/test/snap/__snapshots__/ssr.test.jsx.snap index bd535011b8..2a0afcba17 100644 --- a/test/snap/__snapshots__/ssr.test.jsx.snap +++ b/test/snap/__snapshots__/ssr.test.jsx.snap @@ -408,7 +408,7 @@ exports[`ssr snapshot test > ssr test src/form/_example/clear-validate.tsx 1`] = exports[`ssr snapshot test > ssr test src/form/_example/custom-validator.tsx 1`] = `"
"`; -exports[`ssr snapshot test > ssr test src/form/_example/customized-form-controls.tsx 1`] = `"
:
"`; +exports[`ssr snapshot test > ssr test src/form/_example/customized-form-controls.tsx 1`] = `"
:
"`; exports[`ssr snapshot test > ssr test src/form/_example/disabled.tsx 1`] = `"
:
:
:
:
:
:
:
:
:
:
:
请选择单张图片文件上传
提交
重置
"`; From 178b5ef1f0d119f04169e556a2bf0605e1f580bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?w=C5=AB=20y=C4=81ng?= Date: Thu, 16 Jan 2025 18:44:51 +0800 Subject: [PATCH 32/61] Revert "feat(form): optimize setField same not rerender (#3302)" (#3336) This reverts commit 4c45f9dcfc3851938819007e409b0fa3ea60d271. --- src/form/FormItem.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/form/FormItem.tsx b/src/form/FormItem.tsx index affa3da3b0..262c7f9969 100644 --- a/src/form/FormItem.tsx +++ b/src/form/FormItem.tsx @@ -9,7 +9,6 @@ import { CloseCircleFilledIcon as TdCloseCircleFilledIcon, ErrorCircleFilledIcon as TdErrorCircleFilledIcon, } from 'tdesign-icons-react'; -import isEqual from 'lodash/isEqual'; import { calcFieldValue } from './utils'; import useConfig from '../hooks/useConfig'; import useGlobalIcon from '../hooks/useGlobalIcon'; @@ -166,9 +165,7 @@ const FormItem = forwardRef((originalProps, ref isUpdatedRef.current = true; shouldValidate.current = validate; valueRef.current = newVal; - if (!isEqual(formValue, newVal)) { - setFormValue(newVal); - } + setFormValue(newVal); }; // 初始化 rules,最终以 formItem 上优先级最高 From 46596c177cbe2a73fcf874f4fce014300afc1d2a Mon Sep 17 00:00:00 2001 From: Haixing <65376724+HaixingOoO@users.noreply.github.com> Date: Thu, 16 Jan 2025 18:50:15 +0800 Subject: [PATCH 33/61] Release 1.10.5 (#3335) * release 1.10.5 * chore: changelog's changes --------- Co-authored-by: github-actions[bot] --- CHANGELOG.md | 17 +++++++++++++++++ package.json | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4badc18834..c47f58a283 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,23 @@ toc: false spline: explain --- +## 🌈 1.10.5 `2025-01-16` +### 🚀 Features +- `Radio`: `RadioGroup` 新增 `theme` API,用于决定使用 options 时渲染的子组件样式 @HaixingOoO ([#3303](https://github.com/Tencent/tdesign-react/pull/3303)) +- `Upload`: 新增`imageProps` API,用于在上传图片场景下透传 `Image` 组件的相关属性 @HaixingOoO ([#3317](https://github.com/Tencent/tdesign-react/pull/3317)) +- `AutoComplete`: 新增 `empty` API ,用于支持自定义空节点内容 @liweijie0812 ([#3319](https://github.com/Tencent/tdesign-react/pull/3319)) +- `drawer`: `sizeDraggable`新增支持`SizeDragLimit`类型的功能实现 @huangchen1031 ([#3323](https://github.com/Tencent/tdesign-react/pull/3323)) +- `Icon`: 新增`logo-alipay`、`logo-behance-filled`等图标,修改`logo-wecom`图标,移除不合理的`logo-wecom-filled`图标 @uyarn ([#3326](https://github.com/Tencent/tdesign-react/pull/3326)) +### 🐞 Bug Fixes +- `Select`: 修复`onChange`回调 `context` 中的全部选项的值没有包含选项本身全部内容的问题 @uyarn ([#3305](https://github.com/Tencent/tdesign-react/pull/3305)) +- `DateRangePicker`: 开始结束值同时存在的逻辑判断错误问题 @betavs ([#3301](https://github.com/Tencent/tdesign-react/pull/3301)) +- `Notification`: 修复使用`attach`属性配置导致渲染节点异常的问题 @centuryPark ([#3306](https://github.com/Tencent/tdesign-react/pull/3306)) +- `AutoComplete`: 修复当选项为空时显示效果异常的问题 @betavs ([#3316](https://github.com/Tencent/tdesign-react/pull/3316)) +- `Menu`: 修复 `head-menu` 不渲染 `icon` 的问题 @HaixingOoO ([#3320](https://github.com/Tencent/tdesign-react/pull/3320)) +- `Statistic`: 修复`decimalPlaces=0`时数值动画期间精度错误的问题 @huangchen1031 ([#3327](https://github.com/Tencent/tdesign-react/pull/3327)) +- `ImageVewer`: 修复开启`closeOnOverlay`时,点击蒙层关闭存在闪烁情况的问题 @huangchen1031 + + ## 🌈 1.10.4 `2024-12-25` ### 🚀 Features - `Tree`: 支持 `onScroll` API,用于处理滚动事件回调 @HaixingOoO ([#3295](https://github.com/Tencent/tdesign-react/pull/3295)) diff --git a/package.json b/package.json index 6d91fbaecb..cad62c3841 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tdesign-react", "purename": "tdesign", - "version": "1.10.4", + "version": "1.10.5", "description": "TDesign Component for React", "title": "tdesign-react", "main": "lib/index.js", From c61eeae0694bbb3bffd227a18b8e4f27931927df Mon Sep 17 00:00:00 2001 From: TDesign bot <93915689+tdesign-bot@users.noreply.github.com> Date: Tue, 21 Jan 2025 20:14:43 +0800 Subject: [PATCH 34/61] chore(submodule): update _common (#3338) --- src/_common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_common b/src/_common index 01a5dbe678..a8825cc1b8 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 01a5dbe6785dea1897f0298812c63a5c90dfe0c2 +Subproject commit a8825cc1b8f0e97e9862dbea7da3436f4818f4c1 From 7e116d508c3852995f7bd8cb50b45f46b7a0f0f2 Mon Sep 17 00:00:00 2001 From: Haixing <65376724+HaixingOoO@users.noreply.github.com> Date: Wed, 22 Jan 2025 14:43:46 +0800 Subject: [PATCH 35/61] fix(Transfer): fix transfetItem not working (#3339) * fix(transfer): fix transfetItem not working * test(transfer): update test snap --- src/transfer/Transfer.tsx | 11 +- src/transfer/TransferList.tsx | 7 +- src/transfer/__tests__/transfer.test.tsx | 53 +++++- test/snap/__snapshots__/csr.test.jsx.snap | 202 +++------------------- test/snap/__snapshots__/ssr.test.jsx.snap | 2 +- 5 files changed, 83 insertions(+), 192 deletions(-) diff --git a/src/transfer/Transfer.tsx b/src/transfer/Transfer.tsx index edab3f18ae..4dbf8bd0c3 100644 --- a/src/transfer/Transfer.tsx +++ b/src/transfer/Transfer.tsx @@ -1,7 +1,6 @@ import React, { useState, useMemo, useEffect } from 'react'; import difference from 'lodash/difference'; import classnames from 'classnames'; -import isFunction from 'lodash/isFunction'; import isArray from 'lodash/isArray'; import { ChevronRightIcon as TdChevronRightIcon, ChevronLeftIcon as TdChevronLeftIcon } from 'tdesign-icons-react'; import { TdTransferProps, DataOption, TransferValue, TransferListType } from './type'; @@ -98,9 +97,7 @@ const Transfer: React.FunctionComponent = (originalProps) => { () => , ]).map((item) => getJSX(item)); const [sourceFooter, targetFooter] = getDefaultValue(footer as any).map((item) => getJSX(item)); - const [sourceTransferItem, targetTransferItem] = getDefaultValue( - isFunction(transferItem) ? transferItem({ data, index: undefined, type: undefined }) : transferItem, - ); + const [sourceContent, targetContent] = getDefaultValue(content); const [showCheckAllSource, showCheckAllTarget] = useMemo( @@ -243,6 +240,7 @@ const Transfer: React.FunctionComponent = (originalProps) => { > = (originalProps) => { pagination={sourcePagination} title={sourceTitle} footer={sourceFooter} - transferItem={sourceTransferItem} + transferItem={transferItem} content={sourceContent} onCheckbox={(value) => handleCheckChange(value, 'source')} onSearch={(val: string) => setSearchState({ ...searchState, source: val })} @@ -261,6 +259,7 @@ const Transfer: React.FunctionComponent = (originalProps) => { {OperationsCmp()} = (originalProps) => { pagination={targetPagination} title={targetTitle} footer={targetFooter} - transferItem={targetTransferItem} + transferItem={transferItem} content={targetContent} onCheckbox={(value) => handleCheckChange(value, 'target')} onSearch={(val: string) => setSearchState({ ...searchState, target: val })} diff --git a/src/transfer/TransferList.tsx b/src/transfer/TransferList.tsx index 3807c59931..7f8bb5bbbc 100644 --- a/src/transfer/TransferList.tsx +++ b/src/transfer/TransferList.tsx @@ -7,12 +7,13 @@ import { SearchIcon as TdSearchIcon } from 'tdesign-icons-react'; import { getLeafNodes } from './utils'; import useConfig from '../hooks/useConfig'; import useGlobalIcon from '../hooks/useGlobalIcon'; -import { TdTransferProps, TransferValue } from './type'; +import { TdTransferProps, TransferListType, TransferValue } from './type'; import { TNode, StyledProps } from '../common'; import Checkbox from '../checkbox'; import Input from '../input'; import Pagination, { PaginationProps } from '../pagination'; import { useLocaleReceiver } from '../locale/LocalReceiver'; +import { parseContentTNode } from '../_util/parseTNode'; interface TransferListProps extends Pick, @@ -26,6 +27,7 @@ interface TransferListProps onCheckbox?: (checked: Array) => void; onSearch?: (value: string) => void; showCheckAll?: boolean; + listType: TransferListType; } const TransferList: React.FunctionComponent = (props) => { @@ -46,6 +48,7 @@ const TransferList: React.FunctionComponent = (props) => { transferItem, tree: treeNode, showCheckAll, + listType, } = props; const notDisabledData = !treeNode ? data.filter((item) => !item.disabled) @@ -130,7 +133,7 @@ const TransferList: React.FunctionComponent = (props) => { {viewData.map((item, index) => ( - {typeof transferItem === 'function' ? transferItem({ data: item, index, type: 'source' }) : item.label} + {transferItem ? parseContentTNode(transferItem, { data: item, index, type: listType }) : item.label} ))} diff --git a/src/transfer/__tests__/transfer.test.tsx b/src/transfer/__tests__/transfer.test.tsx index 656af4e783..d878362b24 100644 --- a/src/transfer/__tests__/transfer.test.tsx +++ b/src/transfer/__tests__/transfer.test.tsx @@ -1,6 +1,7 @@ import React, { useState } from 'react'; import { render, fireEvent, waitFor } from '@test/utils'; import Transfer from '../index'; +import type { TransferValue, DataOption } from '../index'; import Tree from '../../tree'; describe('Transfer 测试', () => { @@ -16,7 +17,7 @@ describe('Transfer 测试', () => { }); } function TestComponent() { - const [value, setValue] = useState(['2']); + const [value, setValue] = useState(['2']); return ( { }); } function TestComponent() { - const [value, setValue] = useState(['2', '5']); + const [value, setValue] = useState(['2', '5']); return setValue(v)}>; } const { container, getByText } = render(); @@ -118,4 +119,52 @@ describe('Transfer 测试', () => { // fireEvent.click(getByText('加入')); // fireEvent.click(getByText('移除')); // }); + + test('Transfer transferItem ReactElement', async () => { + const list = [ + { + value: '0', + label: `点击test0`, + }, + { + value: '1', + label: `点击test1`, + }, + ]; + + const TransferItem = ({ data }: { data?: DataOption }) =>
{data.label}
; + + function TestComponent() { + const [value, setValue] = useState(['1']); + return setValue(v)} transferItem={} />; + } + const { getByText } = render(); + + expect(getByText('点击test0')).toBeInTheDocument(); + expect(getByText('点击test1')).toBeInTheDocument(); + }); + + test('Transfer transferItem Function', async () => { + const list = [ + { + value: '0', + label: `点击test0`, + }, + { + value: '1', + label: `点击test1`, + }, + ]; + + const TransferItem = ({ data }: { data?: DataOption }) =>
{data.label}
; + + function TestComponent() { + const [value, setValue] = useState(['1']); + return setValue(v)} transferItem={TransferItem} />; + } + const { getByText } = render(); + + expect(getByText('点击test0')).toBeInTheDocument(); + expect(getByText('点击test1')).toBeInTheDocument(); + }); }); diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index 9fb7f36a1b..b2bfda5345 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -126574,15 +126574,7 @@ exports[`csr snapshot test > csr test src/transfer/_example/custom-render.tsx 1` - - - 内容1 - - - 第1段信息 - - +
@@ -135427,7 +135267,7 @@ exports[`ssr snapshot test > ssr test src/transfer/_example/checked.tsx 1`] = `" exports[`ssr snapshot test > ssr test src/transfer/_example/custom.tsx 1`] = `""`; -exports[`ssr snapshot test > ssr test src/transfer/_example/custom-render.tsx 1`] = `"
0 / 20
0 / 0
Empty Data
"`; +exports[`ssr snapshot test > ssr test src/transfer/_example/custom-render.tsx 1`] = `"
0 / 20
0 / 0
Empty Data
"`; exports[`ssr snapshot test > ssr test src/transfer/_example/empty.tsx 1`] = `"

默认暂无数据

0 / 0
Empty Data
0 / 0
Empty Data

自定义暂无数据

0 / 0
No Source
0 / 0
No Target
"`; diff --git a/test/snap/__snapshots__/ssr.test.jsx.snap b/test/snap/__snapshots__/ssr.test.jsx.snap index 2a0afcba17..a4696e5329 100644 --- a/test/snap/__snapshots__/ssr.test.jsx.snap +++ b/test/snap/__snapshots__/ssr.test.jsx.snap @@ -1136,7 +1136,7 @@ exports[`ssr snapshot test > ssr test src/transfer/_example/checked.tsx 1`] = `" exports[`ssr snapshot test > ssr test src/transfer/_example/custom.tsx 1`] = `""`; -exports[`ssr snapshot test > ssr test src/transfer/_example/custom-render.tsx 1`] = `"
0 / 20
0 / 0
Empty Data
"`; +exports[`ssr snapshot test > ssr test src/transfer/_example/custom-render.tsx 1`] = `"
0 / 20
0 / 0
Empty Data
"`; exports[`ssr snapshot test > ssr test src/transfer/_example/empty.tsx 1`] = `"

默认暂无数据

0 / 0
Empty Data
0 / 0
Empty Data

自定义暂无数据

0 / 0
No Source
0 / 0
No Target
"`; From 95388af63469128c9d1ecd124de440090b4a7b3a Mon Sep 17 00:00:00 2001 From: TDesign bot <93915689+tdesign-bot@users.noreply.github.com> Date: Thu, 23 Jan 2025 14:46:55 +0800 Subject: [PATCH 36/61] chore(submodule): update _common (#3343) --- src/_common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_common b/src/_common index a8825cc1b8..58ffcb16f6 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit a8825cc1b8f0e97e9862dbea7da3436f4818f4c1 +Subproject commit 58ffcb16f6c310b678604a5b3309c280df669fad From 49d056caa6a6f9886fe634bc8a6251415c4c7679 Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Sat, 25 Jan 2025 11:28:52 +0800 Subject: [PATCH 37/61] refactor: lodash-es instead of lodash (#3345) * refactor: lodash-es instead of lodash * chore: update common * chore: remove packageManager --- package.json | 4 ++-- script/init-component/index.js | 6 +++--- script/rollup.config.js | 4 ++-- site/src/components/codesandbox/content.js | 4 ++-- src/_common | 2 +- src/_util/dom.ts | 2 +- src/_util/helper.ts | 2 +- src/_util/parseTNode.ts | 2 +- src/affix/Affix.tsx | 2 +- src/anchor/Anchor.tsx | 3 +-- src/auto-complete/HighlightOption.tsx | 2 +- src/auto-complete/OptionList.tsx | 3 +-- src/auto-complete/_example/filter.tsx | 2 +- src/breadcrumb/BreadcrumbItem.tsx | 2 +- src/cascader/Cascader.tsx | 3 +-- src/cascader/CascaderPanel.tsx | 2 +- src/cascader/components/Item.tsx | 2 +- src/cascader/core/effect.ts | 4 +--- src/cascader/core/helper.ts | 2 +- src/cascader/hooks.tsx | 3 +-- src/checkbox/CheckboxGroup.tsx | 2 +- src/color-picker/components/panel/format/index.tsx | 2 +- src/color-picker/components/panel/format/inputs.tsx | 2 +- src/color-picker/components/panel/linear-gradient.tsx | 2 +- src/common/Check.tsx | 2 +- src/config-provider/ConfigContext.tsx | 2 +- src/config-provider/ConfigProvider.tsx | 2 +- src/config-provider/_example/calendar.tsx | 2 +- src/config-provider/_example/date-picker.tsx | 2 +- src/config-provider/_example/dialog.tsx | 2 +- src/config-provider/_example/global.tsx | 2 +- src/config-provider/_example/others.tsx | 2 +- src/config-provider/_example/pagination.tsx | 2 +- src/config-provider/_example/popconfirm.tsx | 2 +- src/config-provider/_example/table.tsx | 2 +- src/date-picker/DatePicker.tsx | 2 +- src/date-picker/hooks/useDisableDate.ts | 2 +- src/date-picker/hooks/useSingle.tsx | 2 +- src/date-picker/panel/RangePanel.tsx | 2 +- src/date-picker/panel/SinglePanel.tsx | 2 +- src/date-picker/utils.ts | 2 +- src/descriptions/Descriptions.tsx | 3 +-- src/dialog/DialogCard.tsx | 4 +--- src/drawer/Drawer.tsx | 4 +--- src/dropdown/Dropdown.tsx | 2 +- src/dropdown/DropdownMenu.tsx | 2 +- src/empty/Empty.tsx | 3 +-- src/form/FormItem.tsx | 6 +----- src/form/FormList.tsx | 3 +-- src/form/_example/validator.tsx | 2 +- src/form/formModel.ts | 3 +-- src/form/hooks/useFormItemInitialData.ts | 4 +--- src/form/hooks/useInstance.tsx | 7 +------ src/form/hooks/useWatch.ts | 3 +-- src/form/utils/index.ts | 6 +----- src/grid/Col.tsx | 2 +- src/grid/Row.tsx | 2 +- src/guide/Guide.tsx | 2 +- src/hooks/useControlled.ts | 2 +- src/hooks/useDebounce.ts | 2 +- src/hooks/useMutationObserver.ts | 3 +-- src/hooks/useResizeObserver.ts | 2 +- src/hooks/useWindowSize.ts | 2 +- src/image-viewer/ImageViewer.tsx | 2 +- src/image-viewer/ImageViewerModal.tsx | 3 +-- src/image-viewer/hooks/useList.ts | 3 +-- src/image-viewer/hooks/usePosition.ts | 2 +- src/image/Image.tsx | 2 +- src/input-adornment/InputAdornment.tsx | 3 +-- src/input/Input.tsx | 2 +- src/list/List.tsx | 2 +- src/menu/HeadMenu.tsx | 2 +- src/menu/hooks/useMenuContext.ts | 2 +- src/pagination/Pagination.tsx | 3 +-- src/pagination/PaginationMini.tsx | 2 +- src/popconfirm/Popcontent.tsx | 2 +- src/popup/Popup.tsx | 3 +-- src/popup/PopupPlugin.tsx | 2 +- src/range-input/RangeInput.tsx | 2 +- src/select-input/useMultiple.tsx | 2 +- src/select-input/useOverlayInnerStyle.ts | 3 +-- src/select-input/useSingle.tsx | 3 +-- src/select/base/Option.tsx | 4 +--- src/select/base/Select.tsx | 4 +--- src/select/hooks/useOptions.ts | 2 +- src/select/util/helper.ts | 3 +-- src/skeleton/Skeleton.tsx | 2 +- src/slider/Slider.tsx | 3 +-- src/statistic/Statistic.tsx | 3 +-- src/table/BaseTable.tsx | 2 +- src/table/Cell.tsx | 3 +-- src/table/EditableCell.tsx | 5 +---- src/table/EnhancedTable.tsx | 2 +- src/table/FilterController.tsx | 2 +- src/table/PrimaryTable.tsx | 2 +- src/table/TBody.tsx | 4 +--- src/table/TFoot.tsx | 3 +-- src/table/THead.tsx | 2 +- src/table/TR.tsx | 2 +- src/table/_example/filter-controlled.tsx | 2 +- src/table/_example/tree-select.tsx | 2 +- src/table/hooks/tree-store.ts | 2 +- src/table/hooks/useAsyncLoading.tsx | 2 +- src/table/hooks/useColumnController.tsx | 3 +-- src/table/hooks/useColumnResize.tsx | 2 +- src/table/hooks/useDragSort.ts | 2 +- src/table/hooks/useEditableRow.ts | 3 +-- src/table/hooks/useFilter.tsx | 2 +- src/table/hooks/useFixed.ts | 4 +--- src/table/hooks/useRowExpand.tsx | 3 +-- src/table/hooks/useRowSelect.tsx | 4 +--- src/table/hooks/useRowspanAndColspan.ts | 2 +- src/table/hooks/useSorter.tsx | 2 +- src/table/hooks/useTableHeader.tsx | 2 +- src/table/hooks/useTreeData.tsx | 2 +- src/table/hooks/useTreeSelect.tsx | 3 +-- src/table/utils.ts | 4 +--- src/tabs/TabNav.tsx | 3 +-- src/tag-input/TagInput.tsx | 2 +- src/tag-input/useTagList.tsx | 2 +- src/tag-input/useTagScroll.ts | 2 +- src/time-picker/TimeRangePicker.tsx | 2 +- src/time-picker/panel/SinglePanel.tsx | 3 +-- src/timeline/TimelineItem.tsx | 2 +- src/tooltip/TooltipLite.tsx | 2 +- src/transfer/Transfer.tsx | 3 +-- src/transfer/TransferList.tsx | 4 +--- src/transfer/utils.ts | 4 +--- src/tree-select/TreeSelect.tsx | 2 +- src/tree-select/hooks/useTreeSelectPassthroughProps.ts | 2 +- src/tree/Tree.tsx | 2 +- src/tree/TreeItem.tsx | 2 +- src/tree/_example/state.tsx | 2 +- src/tree/hooks/useDraggable.tsx | 2 +- src/tree/hooks/useStore.ts | 2 +- src/typography/ellipsis/Truncate.tsx | 4 ++-- src/typography/ellipsis/useEllipsis.tsx | 2 +- src/upload/hooks/useUpload.ts | 2 +- src/upload/themes/MultipleFlowList.tsx | 3 +-- 139 files changed, 145 insertions(+), 215 deletions(-) diff --git a/package.json b/package.json index cad62c3841..69a86f0f83 100644 --- a/package.json +++ b/package.json @@ -121,7 +121,7 @@ "@testing-library/user-event": "^14.4.3", "@types/estree": "1.0.6", "@types/hoist-non-react-statics": "^3.3.1", - "@types/lodash": "4.17.13", + "@types/lodash-es": "^4.17.12", "@types/node": "^22.7.0", "@types/raf": "^3.4.0", "@types/react": "~18.2.0", @@ -208,7 +208,7 @@ "classnames": "~2.5.1", "dayjs": "1.11.10", "hoist-non-react-statics": "~3.3.2", - "lodash": "~4.17.15", + "lodash-es": "^4.17.21", "mitt": "^3.0.0", "raf": "~3.4.1", "react-is": "^18.2.0", diff --git a/script/init-component/index.js b/script/init-component/index.js index 679de08810..68b60e4c2c 100644 --- a/script/init-component/index.js +++ b/script/init-component/index.js @@ -13,7 +13,7 @@ const fs = require('fs'); const path = require('path'); -const _ = require('lodash'); +const { startCase, camelCase, template } = require('lodash-es'); const config = require('./config'); const cwdPath = process.cwd(); @@ -29,13 +29,13 @@ function createFile(path, data = '', desc) { } function getPascalCase(name) { - return _.startCase(_.camelCase(name)).replace(/ /g, ''); + return startCase(camelCase(name)).replace(/ /g, ''); } function outputFileWithTemplate(item, component, desc, _d) { const tplPath = path.resolve(__dirname, `./tpl/${item.template}`); let data = fs.readFileSync(tplPath).toString(); - const compiled = _.template(data); + const compiled = template(data); data = compiled({ component, PascalCaseComponent: getPascalCase(component), diff --git a/script/rollup.config.js b/script/rollup.config.js index 278d5e84ab..d228063782 100644 --- a/script/rollup.config.js +++ b/script/rollup.config.js @@ -215,7 +215,7 @@ const umdConfig = { banner, format: 'umd', exports: 'named', - globals: { react: 'React', lodash: '_' }, + globals: { react: 'React' }, sourcemap: true, file: `dist/${name}.js`, }, @@ -234,7 +234,7 @@ const umdMinConfig = { banner, format: 'umd', exports: 'named', - globals: { react: 'React', lodash: '_' }, + globals: { react: 'React' }, sourcemap: true, file: `dist/${name}.min.js`, }, diff --git a/site/src/components/codesandbox/content.js b/site/src/components/codesandbox/content.js index 6d4ce19b6b..255c8bd4db 100644 --- a/site/src/components/codesandbox/content.js +++ b/site/src/components/codesandbox/content.js @@ -80,11 +80,11 @@ export const pkgContent = JSON.stringify( 'react-scripts': '^5.0.0', '@types/react': orgPkg.devDependencies['@types/react'], '@types/react-dom': orgPkg.devDependencies['@types/react-dom'], - lodash: orgPkg.dependencies.lodash, + 'lodash-es': orgPkg.dependencies['lodash-es'], }, devDependencies: { typescript: '^4.4.4', - '@types/lodash': orgPkg.devDependencies['@types/lodash'], + '@types/lodash-es': orgPkg.devDependencies['@types/lodash-es'], }, scripts: { start: 'react-scripts start', diff --git a/src/_common b/src/_common index 58ffcb16f6..e23ad04213 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 58ffcb16f6c310b678604a5b3309c280df669fad +Subproject commit e23ad04213d64f3b7161cc4cc758f8ca03d06ae9 diff --git a/src/_util/dom.ts b/src/_util/dom.ts index 65865a9b8f..cdc0374d1c 100644 --- a/src/_util/dom.ts +++ b/src/_util/dom.ts @@ -1,5 +1,5 @@ import raf from 'raf'; -import isString from 'lodash/isString'; +import { isString } from 'lodash-es'; import { easeInOutCubic, EasingFunction } from './easing'; import { ScrollContainer, ScrollContainerElement } from '../common'; diff --git a/src/_util/helper.ts b/src/_util/helper.ts index c86070d6d6..24a6c20dc9 100644 --- a/src/_util/helper.ts +++ b/src/_util/helper.ts @@ -1,4 +1,4 @@ -import camelCase from 'lodash/camelCase'; +import { camelCase } from 'lodash-es'; export function omit(obj: object, fields: string[]): object { const shallowCopy = { diff --git a/src/_util/parseTNode.ts b/src/_util/parseTNode.ts index 468639ee23..7dc12e870f 100644 --- a/src/_util/parseTNode.ts +++ b/src/_util/parseTNode.ts @@ -1,5 +1,5 @@ import React, { ReactElement, ReactNode } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { TNode } from '../common'; import log from '../_common/js/log'; diff --git a/src/affix/Affix.tsx b/src/affix/Affix.tsx index d0db2483fa..8413a40937 100644 --- a/src/affix/Affix.tsx +++ b/src/affix/Affix.tsx @@ -1,5 +1,5 @@ import React, { useEffect, forwardRef, useCallback, useImperativeHandle, useRef } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { StyledProps, ScrollContainerElement } from '../common'; import { TdAffixProps } from './type'; import { getScrollContainer } from '../_util/dom'; diff --git a/src/anchor/Anchor.tsx b/src/anchor/Anchor.tsx index c93d77efa4..330d0501a6 100644 --- a/src/anchor/Anchor.tsx +++ b/src/anchor/Anchor.tsx @@ -1,7 +1,6 @@ import React, { useState, useRef, useEffect, useCallback, useImperativeHandle } from 'react'; import classNames from 'classnames'; -import isEmpty from 'lodash/isEmpty'; -import isFunction from 'lodash/isFunction'; +import { isEmpty , isFunction } from 'lodash-es'; import { StyledProps } from '../common'; import { TdAnchorProps } from './type'; import useConfig from '../hooks/useConfig'; diff --git a/src/auto-complete/HighlightOption.tsx b/src/auto-complete/HighlightOption.tsx index b53a8a798a..e51064024c 100644 --- a/src/auto-complete/HighlightOption.tsx +++ b/src/auto-complete/HighlightOption.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import escapeRegExp from 'lodash/escapeRegExp'; +import { escapeRegExp } from 'lodash-es'; import useConfig from '../hooks/useConfig'; export interface TdHighlightOptionProps { diff --git a/src/auto-complete/OptionList.tsx b/src/auto-complete/OptionList.tsx index 6ed131af1e..73ad75c040 100644 --- a/src/auto-complete/OptionList.tsx +++ b/src/auto-complete/OptionList.tsx @@ -1,7 +1,6 @@ import React, { useMemo, useState, useRef, MouseEvent, useEffect, useImperativeHandle, forwardRef } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; -import escapeRegExp from 'lodash/escapeRegExp'; +import { isFunction , escapeRegExp } from 'lodash-es'; import useConfig from '../hooks/useConfig'; import log from '../_common/js/log'; import { CommonClassNameType } from '../hooks/useCommonClassName'; diff --git a/src/auto-complete/_example/filter.tsx b/src/auto-complete/_example/filter.tsx index b54d00ab1a..2379263524 100644 --- a/src/auto-complete/_example/filter.tsx +++ b/src/auto-complete/_example/filter.tsx @@ -1,7 +1,7 @@ import React, { useState } from 'react'; import { Space, AutoComplete } from 'tdesign-react'; import type { AutoCompleteProps } from 'tdesign-react'; -import escapeRegExp from 'lodash/escapeRegExp'; +import { escapeRegExp } from 'lodash-es'; const LIST = ['第一个 AutoComplete 默认联想词', '第二个 AutoComplete 默认联想词', '第三个 AutoComplete 默认联想词']; diff --git a/src/breadcrumb/BreadcrumbItem.tsx b/src/breadcrumb/BreadcrumbItem.tsx index 26bb5ea55d..0004dc1783 100644 --- a/src/breadcrumb/BreadcrumbItem.tsx +++ b/src/breadcrumb/BreadcrumbItem.tsx @@ -1,7 +1,7 @@ import React, { forwardRef, useContext, useEffect, useMemo, useRef, useState } from 'react'; import classNames from 'classnames'; import { ChevronRightIcon as TdChevronRightIcon } from 'tdesign-icons-react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import useConfig from '../hooks/useConfig'; import useGlobalIcon from '../hooks/useGlobalIcon'; import useCommonClassName from '../hooks/useCommonClassName'; diff --git a/src/cascader/Cascader.tsx b/src/cascader/Cascader.tsx index 1d907e57f2..febd1f0535 100644 --- a/src/cascader/Cascader.tsx +++ b/src/cascader/Cascader.tsx @@ -1,7 +1,6 @@ import React, { useMemo } from 'react'; import classNames from 'classnames'; -import pick from 'lodash/pick'; -import omit from 'lodash/omit'; +import { pick , omit } from 'lodash-es'; import Panel from './components/Panel'; import SelectInput from '../select-input'; import FakeArrow from '../common/FakeArrow'; diff --git a/src/cascader/CascaderPanel.tsx b/src/cascader/CascaderPanel.tsx index feff148f44..3f76758523 100644 --- a/src/cascader/CascaderPanel.tsx +++ b/src/cascader/CascaderPanel.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import pick from 'lodash/pick'; +import { pick } from 'lodash-es'; import classNames from 'classnames'; import Panel from './components/Panel'; import { TdCascaderProps } from './interface'; diff --git a/src/cascader/components/Item.tsx b/src/cascader/components/Item.tsx index d8184cd2e8..970247d5ac 100644 --- a/src/cascader/components/Item.tsx +++ b/src/cascader/components/Item.tsx @@ -2,7 +2,7 @@ import React, { forwardRef, useMemo } from 'react'; import classNames from 'classnames'; import { ChevronRightIcon as TdChevronRightIcon } from 'tdesign-icons-react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import TLoading from '../../loading'; import Checkbox from '../../checkbox'; diff --git a/src/cascader/core/effect.ts b/src/cascader/core/effect.ts index c17b1d4394..70e5eb183b 100644 --- a/src/cascader/core/effect.ts +++ b/src/cascader/core/effect.ts @@ -1,6 +1,4 @@ -import isNumber from 'lodash/isNumber'; -import isFunction from 'lodash/isFunction'; -import cloneDeep from 'lodash/cloneDeep'; +import { isNumber , isFunction , cloneDeep } from 'lodash-es'; import { TreeNode, CascaderContextType, TdCascaderProps, TreeNodeValue, TreeNodeModel } from '../interface'; import { getFullPathLabel, getTreeValue } from './helper'; diff --git a/src/cascader/core/helper.ts b/src/cascader/core/helper.ts index 8f64ddce8b..1960aa11da 100644 --- a/src/cascader/core/helper.ts +++ b/src/cascader/core/helper.ts @@ -1,4 +1,4 @@ -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import { TreeNode, CascaderContextType, diff --git a/src/cascader/hooks.tsx b/src/cascader/hooks.tsx index b6f62e70a8..6b80a84398 100644 --- a/src/cascader/hooks.tsx +++ b/src/cascader/hooks.tsx @@ -1,7 +1,6 @@ import { useState, useEffect, useMemo } from 'react'; -import isEqual from 'lodash/isEqual'; -import isFunction from 'lodash/isFunction'; +import { isEqual , isFunction } from 'lodash-es'; import TreeStore from '../_common/js/tree-v1/tree-store'; import { getTreeValue, getCascaderValue, isEmptyValues, isValueInvalid } from './core/helper'; diff --git a/src/checkbox/CheckboxGroup.tsx b/src/checkbox/CheckboxGroup.tsx index eed7e1216f..42a0d44b45 100644 --- a/src/checkbox/CheckboxGroup.tsx +++ b/src/checkbox/CheckboxGroup.tsx @@ -1,6 +1,6 @@ import React, { ReactElement, useCallback, useEffect, useMemo, useState } from 'react'; import classNames from 'classnames'; -import isNumber from 'lodash/isNumber'; +import { isNumber } from 'lodash-es'; import useConfig from '../hooks/useConfig'; import { CheckContext, CheckContextValue, CheckProps } from '../common/Check'; import { CheckboxGroupValue, CheckboxOption, CheckboxOptionObj, TdCheckboxGroupProps, TdCheckboxProps } from './type'; diff --git a/src/color-picker/components/panel/format/index.tsx b/src/color-picker/components/panel/format/index.tsx index bb4c3e1685..35d93cc08c 100644 --- a/src/color-picker/components/panel/format/index.tsx +++ b/src/color-picker/components/panel/format/index.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import upperCase from 'lodash/upperCase'; +import { upperCase } from 'lodash-es'; import Select from '../../../../select'; import FormatInput from './inputs'; import Color from '../../../../_common/js/color-picker/color'; diff --git a/src/color-picker/components/panel/format/inputs.tsx b/src/color-picker/components/panel/format/inputs.tsx index f85cdbaae8..10a97442ad 100644 --- a/src/color-picker/components/panel/format/inputs.tsx +++ b/src/color-picker/components/panel/format/inputs.tsx @@ -1,5 +1,5 @@ import React, { useRef, useEffect } from 'react'; -import throttle from 'lodash/throttle'; +import { throttle } from 'lodash-es'; import Color from '../../../../_common/js/color-picker/color'; import Input from '../../../../input'; import InputNumber from '../../../../input-number'; diff --git a/src/color-picker/components/panel/linear-gradient.tsx b/src/color-picker/components/panel/linear-gradient.tsx index b16b89ee72..cd8cdb10bc 100644 --- a/src/color-picker/components/panel/linear-gradient.tsx +++ b/src/color-picker/components/panel/linear-gradient.tsx @@ -1,5 +1,5 @@ import React, { KeyboardEvent, MouseEvent as ReactMouseEvent, useCallback, useEffect, useRef, useState } from 'react'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; import classNames from 'classnames'; import useClassName from '../../hooks/useClassNames'; import { genGradientPoint, gradientColors2string } from '../../../_common/js/color-picker/color'; diff --git a/src/common/Check.tsx b/src/common/Check.tsx index f2a0f07cbc..ea6d36cbb4 100644 --- a/src/common/Check.tsx +++ b/src/common/Check.tsx @@ -1,6 +1,6 @@ import React, { forwardRef, useContext, MouseEvent, ChangeEvent } from 'react'; import classNames from 'classnames'; -import isBoolean from 'lodash/isBoolean'; +import { isBoolean } from 'lodash-es'; import { omit } from '../_util/helper'; import { StyledProps } from '../common'; import useConfig from '../hooks/useConfig'; diff --git a/src/config-provider/ConfigContext.tsx b/src/config-provider/ConfigContext.tsx index 92d8a1fb7e..20b2ee3d75 100644 --- a/src/config-provider/ConfigContext.tsx +++ b/src/config-provider/ConfigContext.tsx @@ -1,5 +1,5 @@ import { createContext } from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import defaultLocale from '../locale/zh_CN'; import defaultConfig from '../_common/js/global-config/default-config'; import { GlobalConfigProvider } from './type'; diff --git a/src/config-provider/ConfigProvider.tsx b/src/config-provider/ConfigProvider.tsx index 27891d94c4..e512800f54 100644 --- a/src/config-provider/ConfigProvider.tsx +++ b/src/config-provider/ConfigProvider.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import _mergeWith from 'lodash/mergeWith'; +import { mergeWith as _mergeWith } from 'lodash-es'; import ConfigContext, { defaultGlobalConfig, Config } from './ConfigContext'; import { GlobalConfigProvider } from './type'; diff --git a/src/config-provider/_example/calendar.tsx b/src/config-provider/_example/calendar.tsx index 15c9d8c636..cb697bdb32 100644 --- a/src/config-provider/_example/calendar.tsx +++ b/src/config-provider/_example/calendar.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { ConfigProvider, Calendar } from 'tdesign-react'; import enConfig from 'tdesign-react/es/locale/en_US'; diff --git a/src/config-provider/_example/date-picker.tsx b/src/config-provider/_example/date-picker.tsx index c7074f0c82..93b1de9552 100644 --- a/src/config-provider/_example/date-picker.tsx +++ b/src/config-provider/_example/date-picker.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { ConfigProvider, DatePicker, DateRangePicker, Space } from 'tdesign-react'; import enConfig from 'tdesign-react/es/locale/en_US'; diff --git a/src/config-provider/_example/dialog.tsx b/src/config-provider/_example/dialog.tsx index f7d13377c7..1e8e3bb0ec 100644 --- a/src/config-provider/_example/dialog.tsx +++ b/src/config-provider/_example/dialog.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { ConfigProvider, DialogCard, Space } from 'tdesign-react'; import enConfig from 'tdesign-react/es/locale/en_US'; diff --git a/src/config-provider/_example/global.tsx b/src/config-provider/_example/global.tsx index 1a18faf60a..90bb968544 100644 --- a/src/config-provider/_example/global.tsx +++ b/src/config-provider/_example/global.tsx @@ -1,6 +1,6 @@ /* eslint-disable react/no-unescaped-entities */ import React from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { ConfigProvider, Space } from 'tdesign-react'; import enConfig from 'tdesign-react/es/locale/en_US'; diff --git a/src/config-provider/_example/others.tsx b/src/config-provider/_example/others.tsx index 2835533a76..127bfc469a 100644 --- a/src/config-provider/_example/others.tsx +++ b/src/config-provider/_example/others.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { ConfigProvider, Form, diff --git a/src/config-provider/_example/pagination.tsx b/src/config-provider/_example/pagination.tsx index aa14399f6d..3ffff40dcd 100644 --- a/src/config-provider/_example/pagination.tsx +++ b/src/config-provider/_example/pagination.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { ConfigProvider, Pagination } from 'tdesign-react'; import enConfig from 'tdesign-react/es/locale/en_US'; diff --git a/src/config-provider/_example/popconfirm.tsx b/src/config-provider/_example/popconfirm.tsx index 46e82a1ac9..06a3c90f87 100644 --- a/src/config-provider/_example/popconfirm.tsx +++ b/src/config-provider/_example/popconfirm.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { ConfigProvider, Popconfirm, Button, Space } from 'tdesign-react'; import enConfig from 'tdesign-react/es/locale/en_US'; diff --git a/src/config-provider/_example/table.tsx b/src/config-provider/_example/table.tsx index 7515a585b6..cee62c4874 100644 --- a/src/config-provider/_example/table.tsx +++ b/src/config-provider/_example/table.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { ConfigProvider, Table, Space } from 'tdesign-react'; import { ChevronRightIcon, CaretDownSmallIcon } from 'tdesign-icons-react'; import enConfig from 'tdesign-react/es/locale/en_US'; diff --git a/src/date-picker/DatePicker.tsx b/src/date-picker/DatePicker.tsx index f61413ccf1..ae81f04642 100644 --- a/src/date-picker/DatePicker.tsx +++ b/src/date-picker/DatePicker.tsx @@ -1,7 +1,7 @@ import React, { forwardRef, useEffect, useCallback } from 'react'; import classNames from 'classnames'; import dayjs from 'dayjs'; -import isDate from 'lodash/isDate'; +import { isDate } from 'lodash-es'; import useConfig from '../hooks/useConfig'; import { StyledProps } from '../common'; import { TdDatePickerProps, PresetDate, DateMultipleValue, DateValue } from './type'; diff --git a/src/date-picker/hooks/useDisableDate.ts b/src/date-picker/hooks/useDisableDate.ts index 8670dda675..2e09ec0a3e 100644 --- a/src/date-picker/hooks/useDisableDate.ts +++ b/src/date-picker/hooks/useDisableDate.ts @@ -1,4 +1,4 @@ -import isObject from 'lodash/isObject'; +import { isObject } from 'lodash-es'; import type { TdDatePickerProps, TdDateRangePickerProps } from '../type'; import { isEnabledDate } from '../../_common/js/date-picker/utils'; diff --git a/src/date-picker/hooks/useSingle.tsx b/src/date-picker/hooks/useSingle.tsx index 85d31d169b..1e859e60f8 100644 --- a/src/date-picker/hooks/useSingle.tsx +++ b/src/date-picker/hooks/useSingle.tsx @@ -2,7 +2,7 @@ import React, { useState, useEffect, useRef } from 'react'; import { CalendarIcon as TdCalendarIcon } from 'tdesign-icons-react'; import dayjs from 'dayjs'; import classNames from 'classnames'; -import omit from 'lodash/omit'; +import { omit } from 'lodash-es'; import useConfig from '../../hooks/useConfig'; import useGlobalIcon from '../../hooks/useGlobalIcon'; import { TdDatePickerProps } from '../type'; diff --git a/src/date-picker/panel/RangePanel.tsx b/src/date-picker/panel/RangePanel.tsx index 85d42a60d3..3bf7eb226e 100644 --- a/src/date-picker/panel/RangePanel.tsx +++ b/src/date-picker/panel/RangePanel.tsx @@ -1,6 +1,6 @@ import React, { forwardRef } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import useConfig from '../../hooks/useConfig'; import { StyledProps } from '../../common'; import PanelContent from './PanelContent'; diff --git a/src/date-picker/panel/SinglePanel.tsx b/src/date-picker/panel/SinglePanel.tsx index 96fc61a625..5402b8d421 100644 --- a/src/date-picker/panel/SinglePanel.tsx +++ b/src/date-picker/panel/SinglePanel.tsx @@ -1,6 +1,6 @@ import React, { forwardRef } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import useConfig from '../../hooks/useConfig'; import { StyledProps } from '../../common'; import PanelContent from './PanelContent'; diff --git a/src/date-picker/utils.ts b/src/date-picker/utils.ts index 90df439244..3d7737f8c4 100644 --- a/src/date-picker/utils.ts +++ b/src/date-picker/utils.ts @@ -1,4 +1,4 @@ -import isNil from 'lodash/isNil'; +import { isNil } from 'lodash-es'; import { parseToDayjs } from '../_common/js/date-picker/format'; // 用于头部日期切换修正 diff --git a/src/descriptions/Descriptions.tsx b/src/descriptions/Descriptions.tsx index e0a72636ae..0af1b2f237 100644 --- a/src/descriptions/Descriptions.tsx +++ b/src/descriptions/Descriptions.tsx @@ -1,7 +1,6 @@ import React from 'react'; import classNames from 'classnames'; -import isArray from 'lodash/isArray'; -import assign from 'lodash/assign'; +import { isArray , assign } from 'lodash-es'; import { TdDescriptionItemProps, TdDescriptionsProps } from './type'; import { descriptionItemDefaultProps, descriptionsDefaultProps } from './defaultProps'; import useDefaultProps from '../hooks/useDefaultProps'; diff --git a/src/dialog/DialogCard.tsx b/src/dialog/DialogCard.tsx index 42de883326..198eff6d8f 100644 --- a/src/dialog/DialogCard.tsx +++ b/src/dialog/DialogCard.tsx @@ -1,8 +1,6 @@ import React, { forwardRef, isValidElement } from 'react'; import classNames from 'classnames'; -import isString from 'lodash/isString'; -import isObject from 'lodash/isObject'; -import isFunction from 'lodash/isFunction'; +import { isString , isObject , isFunction } from 'lodash-es'; import { CloseIcon as TdCloseIcon, InfoCircleFilledIcon as TdInfoCircleFilledIcon, diff --git a/src/drawer/Drawer.tsx b/src/drawer/Drawer.tsx index 9b48802511..bbb0c18c23 100644 --- a/src/drawer/Drawer.tsx +++ b/src/drawer/Drawer.tsx @@ -1,8 +1,6 @@ import React, { forwardRef, useState, useEffect, useImperativeHandle, useRef, useMemo, isValidElement } from 'react'; import classnames from 'classnames'; -import isString from 'lodash/isString'; -import isObject from 'lodash/isObject'; -import isFunction from 'lodash/isFunction'; +import { isString , isObject , isFunction } from 'lodash-es'; import { CSSTransition } from 'react-transition-group'; import { CloseIcon as TdCloseIcon } from 'tdesign-icons-react'; diff --git a/src/dropdown/Dropdown.tsx b/src/dropdown/Dropdown.tsx index 06bbe046af..6900ea98c2 100644 --- a/src/dropdown/Dropdown.tsx +++ b/src/dropdown/Dropdown.tsx @@ -1,6 +1,6 @@ import React, { isValidElement, useState } from 'react'; import classNames from 'classnames'; -import omit from 'lodash/omit'; +import { omit } from 'lodash-es'; import { DropdownOption, TdDropdownProps } from './type'; import { StyledProps } from '../common'; import Popup, { PopupVisibleChangeContext } from '../popup'; diff --git a/src/dropdown/DropdownMenu.tsx b/src/dropdown/DropdownMenu.tsx index 89662249dd..1261d975b2 100644 --- a/src/dropdown/DropdownMenu.tsx +++ b/src/dropdown/DropdownMenu.tsx @@ -1,6 +1,6 @@ import React, { ReactElement, useEffect, useRef, useState } from 'react'; import classNames from 'classnames'; -import throttle from 'lodash/throttle'; +import { throttle } from 'lodash-es'; import { ChevronRightIcon as TdIconChevronRight } from 'tdesign-icons-react'; import useConfig from '../hooks/useConfig'; import { DropdownProps } from './Dropdown'; diff --git a/src/empty/Empty.tsx b/src/empty/Empty.tsx index ff8367a7d1..a5cff98dc4 100644 --- a/src/empty/Empty.tsx +++ b/src/empty/Empty.tsx @@ -1,8 +1,7 @@ import React, { isValidElement } from 'react'; import type { ReactNode } from 'react'; import cls from 'classnames'; -import isObject from 'lodash/isObject'; -import isString from 'lodash/isString'; +import { isObject , isString } from 'lodash-es'; import useDefaultProps from '../hooks/useDefaultProps'; import useConfig from '../hooks/useConfig'; import { useLocaleReceiver } from '../locale/LocalReceiver'; diff --git a/src/form/FormItem.tsx b/src/form/FormItem.tsx index 262c7f9969..2e539e7f8f 100644 --- a/src/form/FormItem.tsx +++ b/src/form/FormItem.tsx @@ -1,9 +1,5 @@ import React, { forwardRef, ReactNode, useState, useImperativeHandle, useEffect, useRef, useMemo } from 'react'; -import isObject from 'lodash/isObject'; -import isString from 'lodash/isString'; -import get from 'lodash/get'; -import merge from 'lodash/merge'; -import isFunction from 'lodash/isFunction'; +import { isObject , isString , get , merge , isFunction } from 'lodash-es'; import { CheckCircleFilledIcon as TdCheckCircleFilledIcon, CloseCircleFilledIcon as TdCloseCircleFilledIcon, diff --git a/src/form/FormList.tsx b/src/form/FormList.tsx index d1dd6ed630..708d0cffb5 100644 --- a/src/form/FormList.tsx +++ b/src/form/FormList.tsx @@ -1,6 +1,5 @@ import React, { useState, useEffect, useRef, useImperativeHandle } from 'react'; -import merge from 'lodash/merge'; -import get from 'lodash/get'; +import { merge , get } from 'lodash-es'; import { FormListContext, useFormContext } from './FormContext'; import { FormItemInstance } from './FormItem'; import { HOOK_MARK } from './hooks/useForm'; diff --git a/src/form/_example/validator.tsx b/src/form/_example/validator.tsx index 401d65cb6e..5383d353e9 100644 --- a/src/form/_example/validator.tsx +++ b/src/form/_example/validator.tsx @@ -1,7 +1,7 @@ import React, { useRef } from 'react'; import { Form, Input, Radio, Checkbox, Button, MessagePlugin } from 'tdesign-react'; import type { FormProps, CustomValidator } from 'tdesign-react'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; const { FormItem } = Form; diff --git a/src/form/formModel.ts b/src/form/formModel.ts index 3dc8fc65ab..d85dc106b6 100644 --- a/src/form/formModel.ts +++ b/src/form/formModel.ts @@ -2,9 +2,8 @@ import isDate from 'validator/lib/isDate'; import isEmail from 'validator/lib/isEmail'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty , isNumber } from 'lodash-es'; import isURL from 'validator/lib/isURL'; -import isNumber from 'lodash/isNumber'; import { getCharacterLength } from '../_common/js/utils/helper'; import { CustomValidator, diff --git a/src/form/hooks/useFormItemInitialData.ts b/src/form/hooks/useFormItemInitialData.ts index 9ff275729a..34ca15c5bf 100644 --- a/src/form/hooks/useFormItemInitialData.ts +++ b/src/form/hooks/useFormItemInitialData.ts @@ -1,7 +1,5 @@ import React, { useEffect } from 'react'; -import get from 'lodash/get'; -import unset from 'lodash/unset'; -import isEmpty from 'lodash/isEmpty'; +import { get , unset , isEmpty } from 'lodash-es'; // 兼容特殊数据结构和受控 key import Tree from '../../tree/Tree'; diff --git a/src/form/hooks/useInstance.tsx b/src/form/hooks/useInstance.tsx index a4d006f78d..491f96d097 100644 --- a/src/form/hooks/useInstance.tsx +++ b/src/form/hooks/useInstance.tsx @@ -1,9 +1,4 @@ -import isEmpty from 'lodash/isEmpty'; -import isFunction from 'lodash/isFunction'; -import isEqual from 'lodash/isEqual'; -import merge from 'lodash/merge'; -import get from 'lodash/get'; -import set from 'lodash/set'; +import { isEmpty , isFunction , isEqual , merge , get , set } from 'lodash-es'; import type { TdFormProps, FormValidateResult, diff --git a/src/form/hooks/useWatch.ts b/src/form/hooks/useWatch.ts index 725fc12814..acb761f914 100644 --- a/src/form/hooks/useWatch.ts +++ b/src/form/hooks/useWatch.ts @@ -1,6 +1,5 @@ import { useState, useEffect, useMemo, useRef } from 'react'; -import get from 'lodash/get'; -import isUndefined from 'lodash/isUndefined'; +import { get , isUndefined } from 'lodash-es'; import type { NamePath } from '../type'; import type { InternalFormInstance } from './interface'; import { HOOK_MARK } from './useForm'; diff --git a/src/form/utils/index.ts b/src/form/utils/index.ts index fbb94f7428..fdcaa3b3ef 100644 --- a/src/form/utils/index.ts +++ b/src/form/utils/index.ts @@ -1,8 +1,4 @@ -import has from 'lodash/has'; -import get from 'lodash/get'; -import isObject from 'lodash/isObject'; -import isArray from 'lodash/isArray'; -import isEmpty from 'lodash/isEmpty'; +import { has , get , isObject , isArray , isEmpty } from 'lodash-es'; import type { NamePath } from '../type'; // 获取 formMap 管理的数据 diff --git a/src/grid/Col.tsx b/src/grid/Col.tsx index 31f434721a..4ce6e62c17 100644 --- a/src/grid/Col.tsx +++ b/src/grid/Col.tsx @@ -1,6 +1,6 @@ import React, { useContext, forwardRef } from 'react'; import classNames from 'classnames'; -import isObject from 'lodash/isObject'; +import { isObject } from 'lodash-es'; import useConfig from '../hooks/useConfig'; import { StyledProps } from '../common'; import { TdColProps, TdRowProps } from './type'; diff --git a/src/grid/Row.tsx b/src/grid/Row.tsx index 91bfbefb02..cb77a09d50 100644 --- a/src/grid/Row.tsx +++ b/src/grid/Row.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState, forwardRef, createContext } from 'react'; import classNames from 'classnames'; -import isObject from 'lodash/isObject'; +import { isObject } from 'lodash-es'; import useConfig from '../hooks/useConfig'; import { StyledProps } from '../common'; import { TdRowProps } from './type'; diff --git a/src/guide/Guide.tsx b/src/guide/Guide.tsx index 6a24181a60..f73043a848 100644 --- a/src/guide/Guide.tsx +++ b/src/guide/Guide.tsx @@ -1,5 +1,5 @@ import React, { useMemo, useEffect, useRef, useState } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import cx from 'classnames'; import { createPortal } from 'react-dom'; import Button from '../button'; diff --git a/src/hooks/useControlled.ts b/src/hooks/useControlled.ts index a34cc539af..e3c3eb1c97 100644 --- a/src/hooks/useControlled.ts +++ b/src/hooks/useControlled.ts @@ -1,5 +1,5 @@ import { useState } from 'react'; -import upperFirst from 'lodash/upperFirst'; +import { upperFirst } from 'lodash-es'; import noop from '../_util/noop'; export interface ChangeHandler { diff --git a/src/hooks/useDebounce.ts b/src/hooks/useDebounce.ts index eab6c01a93..8b543faf15 100644 --- a/src/hooks/useDebounce.ts +++ b/src/hooks/useDebounce.ts @@ -1,4 +1,4 @@ -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; import type { DebounceSettingsLeading } from 'lodash'; import { useCallback, useEffect } from 'react'; import { usePersistFn } from './usePersistFn'; diff --git a/src/hooks/useMutationObserver.ts b/src/hooks/useMutationObserver.ts index 699f9e2ec5..de92137d8c 100644 --- a/src/hooks/useMutationObserver.ts +++ b/src/hooks/useMutationObserver.ts @@ -1,6 +1,5 @@ import { useRef, useEffect } from 'react'; -import debounce from 'lodash/debounce'; -import isEqual from 'lodash/isEqual'; +import { debounce , isEqual } from 'lodash-es'; import useLatest from './useLatest'; const DEFAULT_OPTIONS = { diff --git a/src/hooks/useResizeObserver.ts b/src/hooks/useResizeObserver.ts index 06041f08df..51d139096d 100644 --- a/src/hooks/useResizeObserver.ts +++ b/src/hooks/useResizeObserver.ts @@ -1,5 +1,5 @@ import { useLayoutEffect } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; export default function useResizeObserver(container: HTMLElement, callback: (data: [ResizeObserverEntry]) => void) { let containerObserver: ResizeObserver = null; diff --git a/src/hooks/useWindowSize.ts b/src/hooks/useWindowSize.ts index 551ab93f9f..7f06636f02 100644 --- a/src/hooks/useWindowSize.ts +++ b/src/hooks/useWindowSize.ts @@ -1,5 +1,5 @@ import { useCallback, useEffect, useState } from 'react'; -import debounce from 'lodash/debounce'; +import { debounce } from 'lodash-es'; export interface WindowSize { width: number; diff --git a/src/image-viewer/ImageViewer.tsx b/src/image-viewer/ImageViewer.tsx index 5e338c5745..2db2f26f00 100644 --- a/src/image-viewer/ImageViewer.tsx +++ b/src/image-viewer/ImageViewer.tsx @@ -1,6 +1,6 @@ import React, { useMemo, useState } from 'react'; import { createPortal } from 'react-dom'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { ImageModal } from './ImageViewerModal'; import { imageViewerDefaultProps } from './defaultProps'; import type { TdImageViewerProps } from './type'; diff --git a/src/image-viewer/ImageViewerModal.tsx b/src/image-viewer/ImageViewerModal.tsx index cb7df7e438..65d402fd5c 100644 --- a/src/image-viewer/ImageViewerModal.tsx +++ b/src/image-viewer/ImageViewerModal.tsx @@ -1,6 +1,5 @@ import React, { useState, useEffect, useCallback, MouseEvent, KeyboardEvent, useRef } from 'react'; -import isArray from 'lodash/isArray'; -import isFunction from 'lodash/isFunction'; +import { isArray , isFunction } from 'lodash-es'; import { ImageErrorIcon as TdImageErrorIcon, ImageIcon as TdImageIcon, diff --git a/src/image-viewer/hooks/useList.ts b/src/image-viewer/hooks/useList.ts index f90e7bb37d..25c14a0873 100644 --- a/src/image-viewer/hooks/useList.ts +++ b/src/image-viewer/hooks/useList.ts @@ -1,6 +1,5 @@ import { useMemo } from 'react'; -import isString from 'lodash/isString'; -import isArray from 'lodash/isArray'; +import { isString , isArray } from 'lodash-es'; import type { ImageInfo, TdImageViewerProps } from '../type'; const isImageInfo = (image: string | File | ImageInfo): image is ImageInfo => diff --git a/src/image-viewer/hooks/usePosition.ts b/src/image-viewer/hooks/usePosition.ts index 173e16245d..cd5d117e3d 100644 --- a/src/image-viewer/hooks/usePosition.ts +++ b/src/image-viewer/hooks/usePosition.ts @@ -1,5 +1,5 @@ import { MouseEventHandler, useCallback, useEffect, useRef, useState } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; export type PositionType = [number, number]; diff --git a/src/image/Image.tsx b/src/image/Image.tsx index 35aea54f88..54803dd60e 100644 --- a/src/image/Image.tsx +++ b/src/image/Image.tsx @@ -1,6 +1,6 @@ import React, { Fragment, useEffect, useRef, useState, SyntheticEvent, MouseEvent } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { ImageErrorIcon as TdImageErrorIcon, ImageIcon as TdImageIcon } from 'tdesign-icons-react'; import observe from '../_common/js/utils/observe'; import useConfig from '../hooks/useConfig'; diff --git a/src/input-adornment/InputAdornment.tsx b/src/input-adornment/InputAdornment.tsx index f715fbcdec..a473786b5c 100644 --- a/src/input-adornment/InputAdornment.tsx +++ b/src/input-adornment/InputAdornment.tsx @@ -1,7 +1,6 @@ import React, { forwardRef } from 'react'; import classNames from 'classnames'; -import isString from 'lodash/isString'; -import isNumber from 'lodash/isNumber'; +import { isString , isNumber } from 'lodash-es'; import useConfig from '../hooks/useConfig'; import { TdInputAdornmentProps } from './type'; import { StyledProps } from '../common'; diff --git a/src/input/Input.tsx b/src/input/Input.tsx index 1291f438b1..9835ac355f 100644 --- a/src/input/Input.tsx +++ b/src/input/Input.tsx @@ -5,7 +5,7 @@ import { BrowseOffIcon as TdBrowseOffIcon, CloseCircleFilledIcon as TdCloseCircleFilledIcon, } from 'tdesign-icons-react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import useLayoutEffect from '../hooks/useLayoutEffect'; import forwardRefWithStatics from '../_util/forwardRefWithStatics'; import useConfig from '../hooks/useConfig'; diff --git a/src/list/List.tsx b/src/list/List.tsx index e44b0794bb..bf875c4ef6 100644 --- a/src/list/List.tsx +++ b/src/list/List.tsx @@ -1,7 +1,7 @@ import React, { MouseEvent, WheelEvent } from 'react'; import classNames from 'classnames'; -import isString from 'lodash/isString'; +import { isString } from 'lodash-es'; import useConfig from '../hooks/useConfig'; import { useLocaleReceiver } from '../locale/LocalReceiver'; import forwardRefWithStatics from '../_util/forwardRefWithStatics'; diff --git a/src/menu/HeadMenu.tsx b/src/menu/HeadMenu.tsx index d4fa900280..936e0095c7 100644 --- a/src/menu/HeadMenu.tsx +++ b/src/menu/HeadMenu.tsx @@ -1,6 +1,6 @@ import classNames from 'classnames'; import React, { FC, ReactElement, useMemo } from 'react'; -import isObject from 'lodash/isObject'; +import { isObject } from 'lodash-es'; import Tabs from '../tabs'; import { StyledProps } from '../common'; import { TdHeadMenuProps } from './type'; diff --git a/src/menu/hooks/useMenuContext.ts b/src/menu/hooks/useMenuContext.ts index 3332e718b7..db976519a2 100644 --- a/src/menu/hooks/useMenuContext.ts +++ b/src/menu/hooks/useMenuContext.ts @@ -1,4 +1,4 @@ -import noop from 'lodash/noop'; +import { noop } from 'lodash-es'; import { useState, ReactNode } from 'react'; import { MenuState, SetMenuState, MenuMode } from '../MenuContext'; import checkSubMenuChildExpanded from '../_util/checkSubMenuChildExpanded'; diff --git a/src/pagination/Pagination.tsx b/src/pagination/Pagination.tsx index 06514ed87c..9d043af24b 100644 --- a/src/pagination/Pagination.tsx +++ b/src/pagination/Pagination.tsx @@ -1,7 +1,6 @@ import React, { useState, useMemo, forwardRef, useEffect } from 'react'; import classNames from 'classnames'; -import omit from 'lodash/omit'; -import isNaN from 'lodash/isNaN'; +import { omit , isNaN } from 'lodash-es'; import noop from '../_util/noop'; import useConfig from '../hooks/useConfig'; diff --git a/src/pagination/PaginationMini.tsx b/src/pagination/PaginationMini.tsx index 1ff910e5ca..598a2dfb5d 100644 --- a/src/pagination/PaginationMini.tsx +++ b/src/pagination/PaginationMini.tsx @@ -1,6 +1,6 @@ import React, { forwardRef, useMemo } from 'react'; import classNames from 'classnames'; -import isObject from 'lodash/isObject'; +import { isObject } from 'lodash-es'; import { RoundIcon as TdRoundIcon, ChevronUpIcon as TdChevronUpIcon, diff --git a/src/popconfirm/Popcontent.tsx b/src/popconfirm/Popcontent.tsx index 10abb01ce0..c06a51f0a8 100644 --- a/src/popconfirm/Popcontent.tsx +++ b/src/popconfirm/Popcontent.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import isString from 'lodash/isString'; +import { isString } from 'lodash-es'; import classNames from 'classnames'; import { InfoCircleFilledIcon as TdInfoCircleFilledIcon } from 'tdesign-icons-react'; import Button, { ButtonProps } from '../button'; diff --git a/src/popup/Popup.tsx b/src/popup/Popup.tsx index 797812f7b5..6c3e8305e9 100644 --- a/src/popup/Popup.tsx +++ b/src/popup/Popup.tsx @@ -1,7 +1,6 @@ import React, { forwardRef, useState, useRef, useMemo, useEffect, useImperativeHandle } from 'react'; import { CSSTransition } from 'react-transition-group'; -import isFunction from 'lodash/isFunction'; -import debounce from 'lodash/debounce'; +import { isFunction , debounce } from 'lodash-es'; import classNames from 'classnames'; import { usePopper } from 'react-popper'; import { Placement } from '@popperjs/core'; diff --git a/src/popup/PopupPlugin.tsx b/src/popup/PopupPlugin.tsx index 3e180c076b..4ef6b47310 100644 --- a/src/popup/PopupPlugin.tsx +++ b/src/popup/PopupPlugin.tsx @@ -1,6 +1,6 @@ import React, { useLayoutEffect, useMemo, useRef, useState } from 'react'; import { createPopper, Instance, Placement } from '@popperjs/core'; -import isString from 'lodash/isString'; +import { isString } from 'lodash-es'; import classNames from 'classnames'; import { CSSTransition } from 'react-transition-group'; import { render, unmount } from '../_util/react-render'; diff --git a/src/range-input/RangeInput.tsx b/src/range-input/RangeInput.tsx index b0c838bf14..6a21a8bb7c 100644 --- a/src/range-input/RangeInput.tsx +++ b/src/range-input/RangeInput.tsx @@ -1,6 +1,6 @@ import React, { useState, useRef, useImperativeHandle } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { CloseCircleFilledIcon as TdCloseCircleFilledIcon } from 'tdesign-icons-react'; import Input, { InputRef } from '../input'; import useConfig from '../hooks/useConfig'; diff --git a/src/select-input/useMultiple.tsx b/src/select-input/useMultiple.tsx index 8146a01b21..5bf3e0af33 100644 --- a/src/select-input/useMultiple.tsx +++ b/src/select-input/useMultiple.tsx @@ -1,5 +1,5 @@ import React, { useRef, MouseEvent } from 'react'; -import isObject from 'lodash/isObject'; +import { isObject } from 'lodash-es'; import classNames from 'classnames'; import { TdSelectInputProps, SelectInputChangeContext, SelectInputKeys, SelectInputValue } from './type'; import TagInput, { TagInputValue } from '../tag-input'; diff --git a/src/select-input/useOverlayInnerStyle.ts b/src/select-input/useOverlayInnerStyle.ts index 213f88ec87..5a58546c3d 100644 --- a/src/select-input/useOverlayInnerStyle.ts +++ b/src/select-input/useOverlayInnerStyle.ts @@ -1,6 +1,5 @@ import React, { useMemo } from 'react'; -import isObject from 'lodash/isObject'; -import isFunction from 'lodash/isFunction'; +import { isObject , isFunction } from 'lodash-es'; import useControlled from '../hooks/useControlled'; diff --git a/src/select-input/useSingle.tsx b/src/select-input/useSingle.tsx index 64e75b5896..1d433c61a0 100644 --- a/src/select-input/useSingle.tsx +++ b/src/select-input/useSingle.tsx @@ -1,6 +1,5 @@ import React, { useRef, MouseEvent } from 'react'; -import isObject from 'lodash/isObject'; -import pick from 'lodash/pick'; +import { isObject , pick } from 'lodash-es'; import classNames from 'classnames'; import { SelectInputCommonProperties } from './interface'; import Input, { InputRef, TdInputProps } from '../input'; diff --git a/src/select/base/Option.tsx b/src/select/base/Option.tsx index 3077247aee..f7381c217d 100644 --- a/src/select/base/Option.tsx +++ b/src/select/base/Option.tsx @@ -1,8 +1,6 @@ import React, { useEffect, useMemo } from 'react'; import classNames from 'classnames'; -import isNumber from 'lodash/isNumber'; -import isString from 'lodash/isString'; -import get from 'lodash/get'; +import { isNumber , isString , get } from 'lodash-es'; import useConfig from '../../hooks/useConfig'; import useDomRefCallback from '../../hooks/useDomRefCallback'; diff --git a/src/select/base/Select.tsx b/src/select/base/Select.tsx index 4f440dff7b..b27b2989f6 100644 --- a/src/select/base/Select.tsx +++ b/src/select/base/Select.tsx @@ -11,9 +11,7 @@ import React, { useState, } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; -import get from 'lodash/get'; -import debounce from 'lodash/debounce'; +import { isFunction , get , debounce } from 'lodash-es'; import { getOffsetTopToContainer } from '../../_util/helper'; import useControlled from '../../hooks/useControlled'; import { useLocaleReceiver } from '../../locale/LocalReceiver'; diff --git a/src/select/hooks/useOptions.ts b/src/select/hooks/useOptions.ts index 60dc6443a0..d55902bca6 100644 --- a/src/select/hooks/useOptions.ts +++ b/src/select/hooks/useOptions.ts @@ -1,5 +1,5 @@ import React, { useState, useEffect, ReactNode, ReactElement } from 'react'; -import get from 'lodash/get'; +import { get } from 'lodash-es'; import { SelectKeysType, SelectOption, SelectValue } from '../type'; import { getValueToOption } from '../util/helper'; import Option from '../base/Option'; diff --git a/src/select/util/helper.ts b/src/select/util/helper.ts index 1a0f689738..42859ee49d 100644 --- a/src/select/util/helper.ts +++ b/src/select/util/helper.ts @@ -1,6 +1,5 @@ import { ReactElement } from 'react'; -import isPlainObject from 'lodash/isPlainObject'; -import get from 'lodash/get'; +import { isPlainObject , get } from 'lodash-es'; import OptionGroup from '../base/OptionGroup'; import Option from '../base/Option'; diff --git a/src/skeleton/Skeleton.tsx b/src/skeleton/Skeleton.tsx index 815204c0e0..a959935dff 100644 --- a/src/skeleton/Skeleton.tsx +++ b/src/skeleton/Skeleton.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import isNumber from 'lodash/isNumber'; +import { isNumber } from 'lodash-es'; import classNames from 'classnames'; import { SkeletonRowCol, SkeletonRowColObj, TdSkeletonProps } from './type'; diff --git a/src/slider/Slider.tsx b/src/slider/Slider.tsx index bfabe398d9..1897f28a9f 100644 --- a/src/slider/Slider.tsx +++ b/src/slider/Slider.tsx @@ -1,7 +1,6 @@ import React, { useMemo, useRef } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; -import isString from 'lodash/isString'; +import { isFunction , isString } from 'lodash-es'; import { TdSliderProps } from './type'; import useConfig from '../hooks/useConfig'; import useControlled from '../hooks/useControlled'; diff --git a/src/statistic/Statistic.tsx b/src/statistic/Statistic.tsx index f78a22cdd0..529fcf5db7 100644 --- a/src/statistic/Statistic.tsx +++ b/src/statistic/Statistic.tsx @@ -1,7 +1,6 @@ import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react'; import classNames from 'classnames'; -import isNumber from 'lodash/isNumber'; -import isFunction from 'lodash/isFunction'; +import { isNumber , isFunction } from 'lodash-es'; import { ArrowTriangleDownFilledIcon as TDArrowTriangleDownFilledIcon, ArrowTriangleUpFilledIcon as TDArrowTriangleUpFilledIcon, diff --git a/src/table/BaseTable.tsx b/src/table/BaseTable.tsx index 712749f988..2d1d8bc197 100644 --- a/src/table/BaseTable.tsx +++ b/src/table/BaseTable.tsx @@ -8,7 +8,7 @@ import React, { WheelEvent, RefAttributes, } from 'react'; -import pick from 'lodash/pick'; +import { pick } from 'lodash-es'; import classNames from 'classnames'; import TBody, { extendTableProps, TableBodyProps } from './TBody'; import { Affix, AffixRef } from '../affix'; diff --git a/src/table/Cell.tsx b/src/table/Cell.tsx index 34fce64796..7bef7e35a0 100644 --- a/src/table/Cell.tsx +++ b/src/table/Cell.tsx @@ -1,7 +1,6 @@ import React, { MouseEvent, MutableRefObject, ReactNode } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; -import get from 'lodash/get'; +import { isFunction , get } from 'lodash-es'; import TEllipsis from './Ellipsis'; import { BaseTableCellParams, RowspanColspan, TableRowData, TdBaseTableProps } from './type'; import { RowAndColFixedPosition } from './interface'; diff --git a/src/table/EditableCell.tsx b/src/table/EditableCell.tsx index 831a81da09..6e8cf081f4 100644 --- a/src/table/EditableCell.tsx +++ b/src/table/EditableCell.tsx @@ -1,8 +1,5 @@ import React, { useEffect, useMemo, useRef, useState, MouseEvent } from 'react'; -import get from 'lodash/get'; -import set from 'lodash/set'; -import isFunction from 'lodash/isFunction'; -import cloneDeep from 'lodash/cloneDeep'; +import { get , set , isFunction , cloneDeep } from 'lodash-es'; import { Edit1Icon as TdEdit1Icon } from 'tdesign-icons-react'; import classNames from 'classnames'; import { diff --git a/src/table/EnhancedTable.tsx b/src/table/EnhancedTable.tsx index 0c2316ea8b..a4f714e136 100644 --- a/src/table/EnhancedTable.tsx +++ b/src/table/EnhancedTable.tsx @@ -1,5 +1,5 @@ import React, { RefAttributes, forwardRef, useImperativeHandle, useRef } from 'react'; -import get from 'lodash/get'; +import { get } from 'lodash-es'; import PrimaryTable from './PrimaryTable'; import { PrimaryTableCol, TableRowData, DragSortContext, TdPrimaryTableProps } from './type'; import useTreeData from './hooks/useTreeData'; diff --git a/src/table/FilterController.tsx b/src/table/FilterController.tsx index a44f20ffd2..742459c8c2 100644 --- a/src/table/FilterController.tsx +++ b/src/table/FilterController.tsx @@ -1,6 +1,6 @@ import React, { useState, useRef } from 'react'; import { FilterIcon as TdFilterIcon } from 'tdesign-icons-react'; -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash-es'; import classNames from 'classnames'; import Popup, { PopupProps } from '../popup'; import Checkbox from '../checkbox'; diff --git a/src/table/PrimaryTable.tsx b/src/table/PrimaryTable.tsx index 259faa4b38..93030733b0 100644 --- a/src/table/PrimaryTable.tsx +++ b/src/table/PrimaryTable.tsx @@ -1,5 +1,5 @@ import React, { useRef, forwardRef, useImperativeHandle, ReactNode, RefAttributes } from 'react'; -import get from 'lodash/get'; +import { get } from 'lodash-es'; import classNames from 'classnames'; import BaseTable from './BaseTable'; import useColumnController from './hooks/useColumnController'; diff --git a/src/table/TBody.tsx b/src/table/TBody.tsx index 2dac7828a7..c82d29b3a6 100644 --- a/src/table/TBody.tsx +++ b/src/table/TBody.tsx @@ -1,7 +1,5 @@ import React, { CSSProperties, MutableRefObject, ReactNode, useMemo } from 'react'; -import camelCase from 'lodash/camelCase'; -import get from 'lodash/get'; -import pick from 'lodash/pick'; +import { camelCase , get , pick } from 'lodash-es'; import classNames from 'classnames'; import TR, { ROW_LISTENERS, TABLE_PROPS } from './TR'; import { useLocaleReceiver } from '../locale/LocalReceiver'; diff --git a/src/table/TFoot.tsx b/src/table/TFoot.tsx index 5356397ea0..5852657be6 100644 --- a/src/table/TFoot.tsx +++ b/src/table/TFoot.tsx @@ -1,7 +1,6 @@ import React, { CSSProperties, useRef } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction , get } from 'lodash-es'; import classNames from 'classnames'; -import get from 'lodash/get'; import { BaseTableCellParams, RowspanColspan, TableRowData, TdBaseTableProps } from './type'; import { formatRowAttributes, formatRowClassNames } from './utils'; import { RowAndColFixedPosition } from './interface'; diff --git a/src/table/THead.tsx b/src/table/THead.tsx index dae5c9bd2b..485ceef961 100644 --- a/src/table/THead.tsx +++ b/src/table/THead.tsx @@ -1,5 +1,5 @@ import React, { useRef, MutableRefObject, CSSProperties, useMemo } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import classNames from 'classnames'; import { getColumnFixedStyles } from './hooks/useFixed'; import { RowAndColFixedPosition } from './interface'; diff --git a/src/table/TR.tsx b/src/table/TR.tsx index cf4ae5dbe3..cd165b005a 100644 --- a/src/table/TR.tsx +++ b/src/table/TR.tsx @@ -1,5 +1,5 @@ import React, { useMemo, useRef, MouseEvent, useEffect, MutableRefObject } from 'react'; -import get from 'lodash/get'; +import { get } from 'lodash-es'; import classnames from 'classnames'; import { formatRowAttributes, formatRowClassNames } from './utils'; import { getRowFixedStyles } from './hooks/useFixed'; diff --git a/src/table/_example/filter-controlled.tsx b/src/table/_example/filter-controlled.tsx index e38b886fa8..a877f9fca3 100644 --- a/src/table/_example/filter-controlled.tsx +++ b/src/table/_example/filter-controlled.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import isNumber from 'lodash/isNumber'; +import { isNumber } from 'lodash-es'; import { Table, Button, DateRangePickerPanel, Space, Tag } from 'tdesign-react'; import { ErrorCircleFilledIcon, CheckCircleFilledIcon, CloseCircleFilledIcon } from 'tdesign-icons-react'; diff --git a/src/table/_example/tree-select.tsx b/src/table/_example/tree-select.tsx index 7b0d26fd3e..5b205bfc4e 100644 --- a/src/table/_example/tree-select.tsx +++ b/src/table/_example/tree-select.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useRef } from 'react'; import { EnhancedTable, Radio, Space, Button, MessagePlugin, Tag } from 'tdesign-react'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; import { ErrorCircleFilledIcon, CheckCircleFilledIcon, CloseCircleFilledIcon } from 'tdesign-icons-react'; import type { EnhancedTableProps, TableProps } from 'tdesign-react'; diff --git a/src/table/hooks/tree-store.ts b/src/table/hooks/tree-store.ts index e176ba2149..c6e3048bc9 100644 --- a/src/table/hooks/tree-store.ts +++ b/src/table/hooks/tree-store.ts @@ -1,6 +1,6 @@ /* eslint-disable class-methods-use-this */ /* eslint-disable no-param-reassign */ -import get from 'lodash/get'; +import { get } from 'lodash-es'; import { isRowSelectedDisabled } from '../../_common/js/table/utils'; import { PrimaryTableCol, TableRowState, TableRowValue, TableRowData } from '../type'; import log from '../../_common/js/log'; diff --git a/src/table/hooks/useAsyncLoading.tsx b/src/table/hooks/useAsyncLoading.tsx index 993e6ff574..d356875cd2 100644 --- a/src/table/hooks/useAsyncLoading.tsx +++ b/src/table/hooks/useAsyncLoading.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import isString from 'lodash/isString'; +import { isString } from 'lodash-es'; import classNames from 'classnames'; import { TdPrimaryTableProps } from '../type'; import Loading from '../../loading'; diff --git a/src/table/hooks/useColumnController.tsx b/src/table/hooks/useColumnController.tsx index 01f0acf10f..6da7810929 100644 --- a/src/table/hooks/useColumnController.tsx +++ b/src/table/hooks/useColumnController.tsx @@ -3,8 +3,7 @@ */ import React, { useEffect, ChangeEvent, useRef } from 'react'; import { SettingIcon as TdSettingIcon } from 'tdesign-icons-react'; -import intersection from 'lodash/intersection'; -import xorWith from 'lodash/xorWith'; +import { intersection , xorWith } from 'lodash-es'; import classNames from 'classnames'; import Checkbox, { CheckboxGroupValue, CheckboxOptionObj, CheckboxGroupChangeContext } from '../../checkbox'; import { DialogPlugin } from '../../dialog/plugin'; diff --git a/src/table/hooks/useColumnResize.tsx b/src/table/hooks/useColumnResize.tsx index 25d4e00d21..eea87bc2f5 100644 --- a/src/table/hooks/useColumnResize.tsx +++ b/src/table/hooks/useColumnResize.tsx @@ -6,7 +6,7 @@ * - 当表格内容超出,出现横向滚动条时,会自动调整当前列宽和表格总列宽,不影响相邻列宽 */ import React, { useState, useRef, MutableRefObject, CSSProperties, useEffect } from 'react'; -import isNumber from 'lodash/isNumber'; +import { isNumber } from 'lodash-es'; import { BaseTableCol, TableRowData, TdBaseTableProps } from '../type'; import { on, off } from '../../_util/dom'; diff --git a/src/table/hooks/useDragSort.ts b/src/table/hooks/useDragSort.ts index 908030919f..84e1dbaef0 100644 --- a/src/table/hooks/useDragSort.ts +++ b/src/table/hooks/useDragSort.ts @@ -1,7 +1,7 @@ // 表格 行拖拽 + 列拖拽功能 import { MutableRefObject, useEffect, useMemo, useRef, useState } from 'react'; import Sortable, { SortableEvent, SortableOptions, MoveEvent } from 'sortablejs'; -import get from 'lodash/get'; +import { get } from 'lodash-es'; import { PaginationProps } from '../../pagination'; import { TableRowData, TdPrimaryTableProps, DragSortContext } from '../type'; import useClassName from './useClassName'; diff --git a/src/table/hooks/useEditableRow.ts b/src/table/hooks/useEditableRow.ts index 01687c4214..7a8814d1da 100644 --- a/src/table/hooks/useEditableRow.ts +++ b/src/table/hooks/useEditableRow.ts @@ -1,6 +1,5 @@ import { useState, useMemo } from 'react'; -import get from 'lodash/get'; -import isFunction from 'lodash/isFunction'; +import { get , isFunction } from 'lodash-es'; import { PrimaryTableProps } from '../interface'; import { validate } from '../../form/formModel'; import { AllValidateResult } from '../../form'; diff --git a/src/table/hooks/useFilter.tsx b/src/table/hooks/useFilter.tsx index 619a885ff8..da7763a687 100644 --- a/src/table/hooks/useFilter.tsx +++ b/src/table/hooks/useFilter.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState, MutableRefObject } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import useClassName from './useClassName'; import TButton from '../../button'; import { TdPrimaryTableProps, PrimaryTableCol, TableRowData, FilterValue, TableFilterChangeContext } from '../type'; diff --git a/src/table/hooks/useFixed.ts b/src/table/hooks/useFixed.ts index af57a45ebd..f1441305b5 100644 --- a/src/table/hooks/useFixed.ts +++ b/src/table/hooks/useFixed.ts @@ -1,7 +1,5 @@ import { useEffect, useState, useMemo, useRef, WheelEvent } from 'react'; -import get from 'lodash/get'; -import pick from 'lodash/pick'; -import xorWith from 'lodash/xorWith'; +import { get , pick , xorWith } from 'lodash-es'; import { getIEVersion } from '../../_common/js/utils/helper'; import log from '../../_common/js/log'; import { ClassName, Styles } from '../../common'; diff --git a/src/table/hooks/useRowExpand.tsx b/src/table/hooks/useRowExpand.tsx index 2aa8b61fb9..cf7878a8d9 100644 --- a/src/table/hooks/useRowExpand.tsx +++ b/src/table/hooks/useRowExpand.tsx @@ -1,7 +1,6 @@ import React, { MouseEvent, ReactNode, useCallback } from 'react'; import { ChevronRightCircleIcon as TdChevronRightCircleIcon } from 'tdesign-icons-react'; -import get from 'lodash/get'; -import isFunction from 'lodash/isFunction'; +import { get , isFunction } from 'lodash-es'; import classNames from 'classnames'; import { TdPrimaryTableProps, diff --git a/src/table/hooks/useRowSelect.tsx b/src/table/hooks/useRowSelect.tsx index 94db1f483f..d6e3596821 100644 --- a/src/table/hooks/useRowSelect.tsx +++ b/src/table/hooks/useRowSelect.tsx @@ -1,9 +1,7 @@ // 行选中相关功能:单选 + 多选 import React, { useEffect, useState, MouseEvent, useMemo } from 'react'; -import intersection from 'lodash/intersection'; -import get from 'lodash/get'; -import isFunction from 'lodash/isFunction'; +import { intersection , get , isFunction } from 'lodash-es'; import useControlled from '../../hooks/useControlled'; import { PrimaryTableCellParams, diff --git a/src/table/hooks/useRowspanAndColspan.ts b/src/table/hooks/useRowspanAndColspan.ts index 44b52b2083..3698cdcc6a 100644 --- a/src/table/hooks/useRowspanAndColspan.ts +++ b/src/table/hooks/useRowspanAndColspan.ts @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react'; -import get from 'lodash/get'; +import { get } from 'lodash-es'; import log from '../../_common/js/log'; import { BaseTableCellParams, BaseTableCol, TableRowData, TableRowspanAndColspanFunc } from '../type'; diff --git a/src/table/hooks/useSorter.tsx b/src/table/hooks/useSorter.tsx index 814642cae5..c63c820742 100644 --- a/src/table/hooks/useSorter.tsx +++ b/src/table/hooks/useSorter.tsx @@ -1,5 +1,5 @@ import React, { useState, MouseEvent, useEffect } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { SortInfo, TdPrimaryTableProps, PrimaryTableCol, TableRowData } from '../type'; import SorterButton from '../SorterButton'; import useControlled from '../../hooks/useControlled'; diff --git a/src/table/hooks/useTableHeader.tsx b/src/table/hooks/useTableHeader.tsx index f547560ffd..f5df4190b6 100644 --- a/src/table/hooks/useTableHeader.tsx +++ b/src/table/hooks/useTableHeader.tsx @@ -1,5 +1,5 @@ import React, { ReactNode, useMemo } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import classNames from 'classnames'; import { BaseTableCol, PrimaryTableCol, TableRowData, TdBaseTableProps } from '../type'; import { TableColumns, getThRowspanAndColspan, getThList } from './useMultiHeader'; diff --git a/src/table/hooks/useTreeData.tsx b/src/table/hooks/useTreeData.tsx index c4961c8b54..a34791c90a 100644 --- a/src/table/hooks/useTreeData.tsx +++ b/src/table/hooks/useTreeData.tsx @@ -3,7 +3,7 @@ import { AddRectangleIcon as TdAddRectangleIcon, MinusRectangleIcon as TdMinusRectangleIcon, } from 'tdesign-icons-react'; -import get from 'lodash/get'; +import { get } from 'lodash-es'; import classNames from 'classnames'; import TableTreeStore, { SwapParams } from '../../_common/js/table/tree-store'; import { TdEnhancedTableProps, PrimaryTableCol, TableRowData, TableRowValue, TableRowState } from '../type'; diff --git a/src/table/hooks/useTreeSelect.tsx b/src/table/hooks/useTreeSelect.tsx index d7d273757b..98fbfec8a7 100644 --- a/src/table/hooks/useTreeSelect.tsx +++ b/src/table/hooks/useTreeSelect.tsx @@ -1,6 +1,5 @@ import { useMemo, useState, useEffect } from 'react'; -import get from 'lodash/get'; -import intersection from 'lodash/intersection'; +import { get , intersection } from 'lodash-es'; import { TdEnhancedTableProps, TdPrimaryTableProps, TableRowData, PrimaryTableCol } from '../type'; import { KeysType, TableTreeDataMap, TreeDataMapType } from '../../_common/js/table/tree-store'; import useControlled from '../../hooks/useControlled'; diff --git a/src/table/utils.ts b/src/table/utils.ts index 32fb09024d..0e7ffe3a41 100644 --- a/src/table/utils.ts +++ b/src/table/utils.ts @@ -1,6 +1,4 @@ -import isFunction from 'lodash/isFunction'; -import get from 'lodash/get'; -import isObject from 'lodash/isObject'; +import { isFunction , get , isObject } from 'lodash-es'; import { BaseTableCellParams, CellData, diff --git a/src/tabs/TabNav.tsx b/src/tabs/TabNav.tsx index 45e0c5a8a6..d9f19c9d2c 100644 --- a/src/tabs/TabNav.tsx +++ b/src/tabs/TabNav.tsx @@ -5,8 +5,7 @@ import { ChevronLeftIcon as TdChevronLeftIcon, ChevronRightIcon as TdChevronRightIcon, } from 'tdesign-icons-react'; -import omit from 'lodash/omit'; -import debounce from 'lodash/debounce'; +import { omit , debounce } from 'lodash-es'; import { TdTabsProps, TdTabPanelProps, TabValue } from './type'; import noop from '../_util/noop'; import { useTabClass } from './useTabClass'; diff --git a/src/tag-input/TagInput.tsx b/src/tag-input/TagInput.tsx index 2dd097b912..6760d66bdb 100644 --- a/src/tag-input/TagInput.tsx +++ b/src/tag-input/TagInput.tsx @@ -1,6 +1,6 @@ import React, { CompositionEvent, KeyboardEvent, useRef, useImperativeHandle, forwardRef, MouseEvent } from 'react'; import { CloseCircleFilledIcon as TdCloseCircleFilledIcon } from 'tdesign-icons-react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import classnames from 'classnames'; import useConfig from '../hooks/useConfig'; import useGlobalIcon from '../hooks/useGlobalIcon'; diff --git a/src/tag-input/useTagList.tsx b/src/tag-input/useTagList.tsx index 354efd5f3d..0f239406bf 100644 --- a/src/tag-input/useTagList.tsx +++ b/src/tag-input/useTagList.tsx @@ -1,5 +1,5 @@ import React, { useState, MouseEvent, KeyboardEvent, ReactNode, Fragment } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { TagInputChangeContext, TagInputValue, TdTagInputProps } from './type'; import { InputValue } from '../input'; import Tag from '../tag'; diff --git a/src/tag-input/useTagScroll.ts b/src/tag-input/useTagScroll.ts index 298e31a9f6..7e91a0c9e7 100644 --- a/src/tag-input/useTagScroll.ts +++ b/src/tag-input/useTagScroll.ts @@ -3,7 +3,7 @@ * 如果标签过多时的处理方式,是标签省略,则不需要此功能 */ -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { useRef, useEffect, RefObject, useState, WheelEvent } from 'react'; import { TdTagInputProps } from './type'; diff --git a/src/time-picker/TimeRangePicker.tsx b/src/time-picker/TimeRangePicker.tsx index 94298678f9..4a1e476d6e 100644 --- a/src/time-picker/TimeRangePicker.tsx +++ b/src/time-picker/TimeRangePicker.tsx @@ -3,7 +3,7 @@ import classNames from 'classnames'; import dayjs from 'dayjs'; import { TimeIcon as TdTimeIcon } from 'tdesign-icons-react'; -import isArray from 'lodash/isArray'; +import { isArray } from 'lodash-es'; import noop from '../_util/noop'; import useControlled from '../hooks/useControlled'; import useConfig from '../hooks/useConfig'; diff --git a/src/time-picker/panel/SinglePanel.tsx b/src/time-picker/panel/SinglePanel.tsx index c1d965a037..89206fefd0 100644 --- a/src/time-picker/panel/SinglePanel.tsx +++ b/src/time-picker/panel/SinglePanel.tsx @@ -12,8 +12,7 @@ import React, { import classNames from 'classnames'; import dayjs from 'dayjs'; import customParseFormat from 'dayjs/plugin/customParseFormat'; -import padStart from 'lodash/padStart'; -import range from 'lodash/range'; +import { padStart , range } from 'lodash-es'; import useConfig from '../../hooks/useConfig'; import noop from '../../_util/noop'; diff --git a/src/timeline/TimelineItem.tsx b/src/timeline/TimelineItem.tsx index 38127876b4..b243bb1d80 100644 --- a/src/timeline/TimelineItem.tsx +++ b/src/timeline/TimelineItem.tsx @@ -1,6 +1,6 @@ import React, { useContext, useMemo } from 'react'; import classNames from 'classnames'; -import omit from 'lodash/omit'; +import { omit } from 'lodash-es'; import { TdTimelineItemProps } from './type'; import { StyledProps } from '../common'; import useConfig from '../hooks/useConfig'; diff --git a/src/tooltip/TooltipLite.tsx b/src/tooltip/TooltipLite.tsx index 0aafc13f36..4dd1bd04cf 100644 --- a/src/tooltip/TooltipLite.tsx +++ b/src/tooltip/TooltipLite.tsx @@ -1,7 +1,7 @@ import React, { ReactNode, useState, useRef, useEffect, useCallback } from 'react'; import classnames from 'classnames'; import { CSSTransition } from 'react-transition-group'; -import throttle from 'lodash/throttle'; +import { throttle } from 'lodash-es'; import { StyledProps } from '../common'; import useSwitch from '../hooks/useSwitch'; import useAnimation from '../hooks/useAnimation'; diff --git a/src/transfer/Transfer.tsx b/src/transfer/Transfer.tsx index 4dbf8bd0c3..e3e260ce4a 100644 --- a/src/transfer/Transfer.tsx +++ b/src/transfer/Transfer.tsx @@ -1,7 +1,6 @@ import React, { useState, useMemo, useEffect } from 'react'; -import difference from 'lodash/difference'; +import { difference , isArray } from 'lodash-es'; import classnames from 'classnames'; -import isArray from 'lodash/isArray'; import { ChevronRightIcon as TdChevronRightIcon, ChevronLeftIcon as TdChevronLeftIcon } from 'tdesign-icons-react'; import { TdTransferProps, DataOption, TransferValue, TransferListType } from './type'; import useConfig from '../hooks/useConfig'; diff --git a/src/transfer/TransferList.tsx b/src/transfer/TransferList.tsx index 7f8bb5bbbc..2b2258f992 100644 --- a/src/transfer/TransferList.tsx +++ b/src/transfer/TransferList.tsx @@ -1,8 +1,6 @@ import React, { useMemo, useState } from 'react'; import classnames from 'classnames'; -import isFunction from 'lodash/isFunction'; -import isEmpty from 'lodash/isEmpty'; -import isString from 'lodash/isString'; +import { isFunction , isEmpty , isString } from 'lodash-es'; import { SearchIcon as TdSearchIcon } from 'tdesign-icons-react'; import { getLeafNodes } from './utils'; import useConfig from '../hooks/useConfig'; diff --git a/src/transfer/utils.ts b/src/transfer/utils.ts index b3926a967b..50b694d6f2 100644 --- a/src/transfer/utils.ts +++ b/src/transfer/utils.ts @@ -1,6 +1,4 @@ -import isEmpty from 'lodash/isEmpty'; -import isFunction from 'lodash/isFunction'; -import isString from 'lodash/isString'; +import { isEmpty , isFunction , isString } from 'lodash-es'; import React from 'react'; import { DataOption, TransferValue } from './type'; import { TNode } from '../common'; diff --git a/src/tree-select/TreeSelect.tsx b/src/tree-select/TreeSelect.tsx index f9c66e3ad2..d0ac9d8b3b 100644 --- a/src/tree-select/TreeSelect.tsx +++ b/src/tree-select/TreeSelect.tsx @@ -1,5 +1,5 @@ import React, { useCallback, useMemo, useRef, forwardRef, ElementRef, useImperativeHandle } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import classNames from 'classnames'; import type { TdTreeSelectProps, TreeSelectValue } from './type'; import type { StyledProps, TreeOptionData } from '../common'; diff --git a/src/tree-select/hooks/useTreeSelectPassthroughProps.ts b/src/tree-select/hooks/useTreeSelectPassthroughProps.ts index 6cc9b8ea29..16665c44d5 100644 --- a/src/tree-select/hooks/useTreeSelectPassthroughProps.ts +++ b/src/tree-select/hooks/useTreeSelectPassthroughProps.ts @@ -1,4 +1,4 @@ -import pick from 'lodash/pick'; +import { pick } from 'lodash-es'; import classNames from 'classnames'; import useConfig from '../../hooks/useConfig'; import type { TreeSelectProps } from '../TreeSelect'; diff --git a/src/tree/Tree.tsx b/src/tree/Tree.tsx index 83c019a1c3..1453cfeb87 100644 --- a/src/tree/Tree.tsx +++ b/src/tree/Tree.tsx @@ -10,7 +10,7 @@ import React, { } from 'react'; import { CSSTransition, TransitionGroup } from 'react-transition-group'; import classNames from 'classnames'; -import get from 'lodash/get'; +import { get } from 'lodash-es'; import TreeNode from '../_common/js/tree-v1/tree-node'; import { TreeOptionData, StyledProps, ComponentScrollToElementParams } from '../common'; diff --git a/src/tree/TreeItem.tsx b/src/tree/TreeItem.tsx index 3871ddc3a7..e681a0190a 100644 --- a/src/tree/TreeItem.tsx +++ b/src/tree/TreeItem.tsx @@ -11,7 +11,7 @@ import React, { useState, } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { CaretRightSmallIcon as TdCaretRightSmallIcon } from 'tdesign-icons-react'; import Loading from '../loading'; import useRipple from '../hooks/useRipple'; diff --git a/src/tree/_example/state.tsx b/src/tree/_example/state.tsx index 58928d7f4d..3c82fc1b03 100644 --- a/src/tree/_example/state.tsx +++ b/src/tree/_example/state.tsx @@ -1,7 +1,7 @@ import React, { useRef, useState } from 'react'; import { Button, Tree, Space, TreeInstanceFunctions, TreeNodeModel } from 'tdesign-react'; import { Icon } from 'tdesign-icons-react'; -import cloneDeepWith from 'lodash/cloneDeepWith'; +import { cloneDeepWith } from 'lodash-es'; import { TreeOptionData } from '../../common'; let idx = 2; diff --git a/src/tree/hooks/useDraggable.tsx b/src/tree/hooks/useDraggable.tsx index 6c69179dbd..47a7a0da46 100644 --- a/src/tree/hooks/useDraggable.tsx +++ b/src/tree/hooks/useDraggable.tsx @@ -1,4 +1,4 @@ -import throttle from 'lodash/throttle'; +import { throttle } from 'lodash-es'; import { RefObject, DragEvent, useState, useRef } from 'react'; import { TreeNode } from '../../_common/js/tree-v1/tree-node'; import { useTreeDraggableContext } from './TreeDraggableContext'; diff --git a/src/tree/hooks/useStore.ts b/src/tree/hooks/useStore.ts index 0e6826a127..f014ff68e7 100644 --- a/src/tree/hooks/useStore.ts +++ b/src/tree/hooks/useStore.ts @@ -1,5 +1,5 @@ import { useEffect, useRef, useState } from 'react'; -import cloneDeep from 'lodash/cloneDeep'; +import { cloneDeep } from 'lodash-es'; import useUpdateLayoutEffect from '../../hooks/useUpdateLayoutEffect'; import usePrevious from '../../hooks/usePrevious'; import TreeStore from '../../_common/js/tree-v1/tree-store'; diff --git a/src/typography/ellipsis/Truncate.tsx b/src/typography/ellipsis/Truncate.tsx index 1c93406bf6..ab8718e3b1 100644 --- a/src/typography/ellipsis/Truncate.tsx +++ b/src/typography/ellipsis/Truncate.tsx @@ -3,7 +3,7 @@ * https://github.com/pablosichert/react-truncate/blob/master/LICENSE.md * * ISC License - * + * Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. @@ -14,7 +14,7 @@ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ import React from 'react'; -import omit from 'lodash/omit'; +import { omit } from 'lodash-es'; import PropTypes from 'prop-types'; export type TruncateProps = { diff --git a/src/typography/ellipsis/useEllipsis.tsx b/src/typography/ellipsis/useEllipsis.tsx index 37188347e2..f23405a336 100644 --- a/src/typography/ellipsis/useEllipsis.tsx +++ b/src/typography/ellipsis/useEllipsis.tsx @@ -1,6 +1,6 @@ /* eslint-disable no-nested-ternary */ import React, { useState } from 'react'; -import isFunction from 'lodash/isFunction'; +import { isFunction } from 'lodash-es'; import { TypographyEllipsis } from '../type'; import Tooltip from '../../tooltip'; diff --git a/src/upload/hooks/useUpload.ts b/src/upload/hooks/useUpload.ts index 72dc032a0a..2166b81e71 100644 --- a/src/upload/hooks/useUpload.ts +++ b/src/upload/hooks/useUpload.ts @@ -1,5 +1,5 @@ import { useRef, useState, useMemo, ChangeEventHandler, MouseEvent, useEffect, ClipboardEventHandler } from 'react'; -import merge from 'lodash/merge'; +import { merge } from 'lodash-es'; import { SizeLimitObj, TdUploadProps, UploadChangeContext, UploadFile, UploadRemoveContext } from '../type'; import { getFilesAndErrors, diff --git a/src/upload/themes/MultipleFlowList.tsx b/src/upload/themes/MultipleFlowList.tsx index f3531b5366..45cf798448 100644 --- a/src/upload/themes/MultipleFlowList.tsx +++ b/src/upload/themes/MultipleFlowList.tsx @@ -1,7 +1,6 @@ import React, { MouseEvent, useMemo, useState } from 'react'; import classNames from 'classnames'; -import isFunction from 'lodash/isFunction'; -import isObject from 'lodash/isObject'; +import { isFunction , isObject } from 'lodash-es'; import { BrowseIcon as TdBrowseIcon, DeleteIcon as TdDeleteIcon, From 834d94121c1f364c5bed37c4b0b0dd54a303c0ac Mon Sep 17 00:00:00 2001 From: liweijie0812 <674416404@qq.com> Date: Sun, 26 Jan 2025 11:27:54 +0800 Subject: [PATCH 38/61] chore(eslint): restricted import lodash (#3347) * chore(eslint): restricted import lodash * chore: fix lint --- .eslintrc.js | 13 ++++++++++++- src/hooks/useDebounce.ts | 7 +++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index b86c9c3283..c96cf4fd54 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -27,7 +27,7 @@ module.exports = { }, }, rules: { - "no-use-before-define": "off", + 'no-use-before-define': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/ban-types': 'off', '@typescript-eslint/explicit-function-return-type': 'off', @@ -72,5 +72,16 @@ module.exports = { 'func-names': 'off', 'consistent-return': 'off', 'default-case': 'off', + 'no-restricted-imports': [ + 'error', + { + paths: [ + { + name: 'lodash', + message: 'Please use lodash-es instead.', + }, + ], + }, + ], }, }; diff --git a/src/hooks/useDebounce.ts b/src/hooks/useDebounce.ts index 8b543faf15..664c91acb0 100644 --- a/src/hooks/useDebounce.ts +++ b/src/hooks/useDebounce.ts @@ -1,8 +1,11 @@ -import { debounce } from 'lodash-es'; -import type { DebounceSettingsLeading } from 'lodash'; +import { debounce, DebounceSettings } from 'lodash-es'; import { useCallback, useEffect } from 'react'; import { usePersistFn } from './usePersistFn'; +interface DebounceSettingsLeading extends DebounceSettings { + leading: true; +} + const useDebounce = any>(func: T, delay: number, options?: DebounceSettingsLeading) => { const callback = usePersistFn(func); From 262cce95740f5588a70074fdab85595e55402e62 Mon Sep 17 00:00:00 2001 From: Shabix <131671885+Shabi-x@users.noreply.github.com> Date: Sun, 26 Jan 2025 11:40:07 +0800 Subject: [PATCH 39/61] feat(TagInput): enhance max rows for TagInput component#3025 (#3293) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(TagInput): enhance max rows functionality and styling #3025 * docs(tag-input): update documentation for max rows and tag input example * feat: 同步common提交内容 * chore: update snapshot * docs: 补充tag-input api文档说明 * chore: update common --------- Co-authored-by: dundun003 Co-authored-by: 黎伟杰 <674416404@qq.com> Co-authored-by: Uyarn --- src/tag-input/TagInput.tsx | 14 +- src/tag-input/_example/max-row.tsx | 63 + src/tag-input/tag-input.en-US.md | 1 + src/tag-input/tag-input.md | 1 + src/tag-input/type.ts | 5 + test/snap/__snapshots__/csr.test.jsx.snap | 1266 +++++++++++++++++++++ test/snap/__snapshots__/ssr.test.jsx.snap | 2 + 7 files changed, 1351 insertions(+), 1 deletion(-) create mode 100644 src/tag-input/_example/max-row.tsx diff --git a/src/tag-input/TagInput.tsx b/src/tag-input/TagInput.tsx index 6760d66bdb..7175ed9d12 100644 --- a/src/tag-input/TagInput.tsx +++ b/src/tag-input/TagInput.tsx @@ -43,6 +43,7 @@ const TagInput = forwardRef((originalProps, ref) => { suffixIcon, suffix, prefixIcon, + maxRows, onClick, onPaste, onFocus, @@ -133,10 +134,18 @@ const TagInput = forwardRef((originalProps, ref) => { [WITH_SUFFIX_ICON_CLASS]: !!suffixIconNode, [`${prefix}-is-empty`]: isEmpty, [`${prefix}-tag-input--with-tag`]: !isEmpty, + [`${prefix}-tag-input--max-rows`]: excessTagsDisplayType === 'break-line' && maxRows, }, props.className, ]; + const maxRowsStyle = maxRows + ? ({ + '--max-rows': maxRows, + '--tag-input-size': size, + } as React.CSSProperties) + : {}; + return ( } @@ -152,7 +161,10 @@ const TagInput = forwardRef((originalProps, ref) => { disabled={disabled} label={renderLabel({ displayNode, label })} className={classnames(classes)} - style={props.style} + style={{ + ...props.style, + ...maxRowsStyle, + }} tips={tips} status={status} placeholder={tagInputPlaceholder} diff --git a/src/tag-input/_example/max-row.tsx b/src/tag-input/_example/max-row.tsx new file mode 100644 index 0000000000..404933666c --- /dev/null +++ b/src/tag-input/_example/max-row.tsx @@ -0,0 +1,63 @@ +import React, { useState } from 'react'; +import { TagInput, Space } from 'tdesign-react'; + +export default function TagInputMaxRowExample() { + const [tags, setTags] = useState([ + 'Vue', + 'React', + 'Angular', + 'Svelte', + 'Solid', + 'MiniProgram', + 'Flutter', + 'UniApp', + 'Html5', + 'Css3', + 'JavaScript', + 'TypeScript', + 'Node.js', + 'Python', + 'Java', + 'Go', + 'Rust', + 'C++', + ]); + + return ( + +

最大高度为2

+ setTags(val.map(String))} + clearable + onPaste={(context) => console.log(context)} + onEnter={(val, context) => console.log(val, context)} + label="小尺寸: " + placeholder="最大高度为2行,超出部分滚动显示" + /> + +

最大高度为3

+ setTags(val.map(String))} + label="中等尺寸: " + clearable + placeholder="最大高度为3行,超出部分滚动显示" + /> + +

最大高度为4

+ setTags(val.map(String))} + label="大尺寸: " + clearable + placeholder="最大高度为4行,超出部分换行显示" + /> +
+ ); +} diff --git a/src/tag-input/tag-input.en-US.md b/src/tag-input/tag-input.en-US.md index 9c108fc202..26958271b7 100644 --- a/src/tag-input/tag-input.en-US.md +++ b/src/tag-input/tag-input.en-US.md @@ -20,6 +20,7 @@ inputValue | String / Number | '' | input value。Typescript:`string` | N defaultInputValue | String / Number | '' | input value。uncontrolled property。Typescript:`string` | N label | TNode | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N max | Number | - | max tag number | N +maxRows | Number | - | max tag rows | N minCollapsedNum | Number | 0 | \- | N placeholder | String | undefined | placeholder description | N prefixIcon | TElement | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N diff --git a/src/tag-input/tag-input.md b/src/tag-input/tag-input.md index 048389ecac..21d14b4934 100644 --- a/src/tag-input/tag-input.md +++ b/src/tag-input/tag-input.md @@ -20,6 +20,7 @@ inputValue | String / Number | '' | 输入框的值。TS 类型:`string` | N defaultInputValue | String / Number | '' | 输入框的值。非受控属性。TS 类型:`string` | N label | TNode | - | 左侧文本。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N max | Number | - | 最大允许输入的标签数量 | N +maxRows | Number | - | 最大允许显示的行数,超出会出现滚动条,默认为不限制。 | N minCollapsedNum | Number | 0 | 最小折叠数量,用于标签数量过多的情况下折叠选中项,超出该数值的选中项折叠。值为 0 则表示不折叠 | N placeholder | String | undefined | 占位符 | N prefixIcon | TElement | - | 组件前置图标。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/src/common.ts) | N diff --git a/src/tag-input/type.ts b/src/tag-input/type.ts index f7ebb16022..8348aae09a 100644 --- a/src/tag-input/type.ts +++ b/src/tag-input/type.ts @@ -48,6 +48,11 @@ export interface TdTagInputProps { * @default break-line */ excessTagsDisplayType?: 'scroll' | 'break-line'; + /** + * 标签最大换行数 + * @default 1 + */ + maxRows?: number; /** * 透传 Input 输入框组件全部属性 */ diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index b2bfda5345..756cd533f7 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -120011,6 +120011,1270 @@ exports[`csr snapshot test > csr test src/tag-input/_example/max.tsx 1`] = `
`; +exports[`csr snapshot test > csr test src/tag-input/_example/max-row.tsx 1`] = ` +
+
+
+

+ 最大高度为2 +

+
+
+
+
+
+
+ 小尺寸: +
+
+ + Vue + + + + +
+
+ + React + + + + +
+
+ + Angular + + + + +
+
+ + Svelte + + + + +
+
+ + Solid + + + + +
+
+ + MiniProgram + + + + +
+
+ + Flutter + + + + +
+
+ + UniApp + + + + +
+
+ + Html5 + + + + +
+
+ + Css3 + + + + +
+
+ + JavaScript + + + + +
+
+ + TypeScript + + + + +
+
+ + Node.js + + + + +
+
+ + Python + + + + +
+
+ + Java + + + + +
+
+ + Go + + + + +
+
+ + Rust + + + + +
+
+ + C++ + + + + +
+
+ + +
+
+
+
+

+ 最大高度为3 +

+
+
+
+
+
+
+ 中等尺寸: +
+
+ + Vue + + + + +
+
+ + React + + + + +
+
+ + Angular + + + + +
+
+ + Svelte + + + + +
+
+ + Solid + + + + +
+
+ + MiniProgram + + + + +
+
+ + Flutter + + + + +
+
+ + UniApp + + + + +
+
+ + Html5 + + + + +
+
+ + Css3 + + + + +
+
+ + JavaScript + + + + +
+
+ + TypeScript + + + + +
+
+ + Node.js + + + + +
+
+ + Python + + + + +
+
+ + Java + + + + +
+
+ + Go + + + + +
+
+ + Rust + + + + +
+
+ + C++ + + + + +
+
+ + +
+
+
+
+

+ 最大高度为4 +

+
+
+
+
+
+
+ 大尺寸: +
+
+ + Vue + + + + +
+
+ + React + + + + +
+
+ + Angular + + + + +
+
+ + Svelte + + + + +
+
+ + Solid + + + + +
+
+ + MiniProgram + + + + +
+
+ + Flutter + + + + +
+
+ + UniApp + + + + +
+
+ + Html5 + + + + +
+
+ + Css3 + + + + +
+
+ + JavaScript + + + + +
+
+ + TypeScript + + + + +
+
+ + Node.js + + + + +
+
+ + Python + + + + +
+
+ + Java + + + + +
+
+ + Go + + + + +
+
+ + Rust + + + + +
+
+ + C++ + + + + +
+
+ + +
+
+
+
+
+`; + exports[`csr snapshot test > csr test src/tag-input/_example/size.tsx 1`] = `
ssr test src/tag-input/_example/excess.tsx 1`] = `" exports[`ssr snapshot test > ssr test src/tag-input/_example/max.tsx 1`] = `"
最多只能输入 3 个标签
"`; +exports[`ssr snapshot test > ssr test src/tag-input/_example/max-row.tsx 1`] = `"

最大高度为2

小尺寸:
Vue
React
Angular
Svelte
Solid
MiniProgram
Flutter
UniApp
Html5
Css3
JavaScript
TypeScript
Node.js
Python
Java
Go
Rust
C++

最大高度为3

中等尺寸:
Vue
React
Angular
Svelte
Solid
MiniProgram
Flutter
UniApp
Html5
Css3
JavaScript
TypeScript
Node.js
Python
Java
Go
Rust
C++

最大高度为4

大尺寸:
Vue
React
Angular
Svelte
Solid
MiniProgram
Flutter
UniApp
Html5
Css3
JavaScript
TypeScript
Node.js
Python
Java
Go
Rust
C++
"`; + exports[`ssr snapshot test > ssr test src/tag-input/_example/size.tsx 1`] = `"
Vue
React
Vue
React
Vue
React
"`; exports[`ssr snapshot test > ssr test src/tag-input/_example/status.tsx 1`] = `"
Vue
React
Miniprogram
Vue
React
Miniprogram
这是普通文本提示
Vue
React
Miniprogram
校验通过文本提示
Vue
React
Miniprogram
校验不通过文本提示
Vue
React
Miniprogram
校验存在严重问题文本提示
"`; diff --git a/test/snap/__snapshots__/ssr.test.jsx.snap b/test/snap/__snapshots__/ssr.test.jsx.snap index a4696e5329..b39d9e95bf 100644 --- a/test/snap/__snapshots__/ssr.test.jsx.snap +++ b/test/snap/__snapshots__/ssr.test.jsx.snap @@ -1066,6 +1066,8 @@ exports[`ssr snapshot test > ssr test src/tag-input/_example/excess.tsx 1`] = `" exports[`ssr snapshot test > ssr test src/tag-input/_example/max.tsx 1`] = `"
最多只能输入 3 个标签
"`; +exports[`ssr snapshot test > ssr test src/tag-input/_example/max-row.tsx 1`] = `"

最大高度为2

小尺寸:
Vue
React
Angular
Svelte
Solid
MiniProgram
Flutter
UniApp
Html5
Css3
JavaScript
TypeScript
Node.js
Python
Java
Go
Rust
C++

最大高度为3

中等尺寸:
Vue
React
Angular
Svelte
Solid
MiniProgram
Flutter
UniApp
Html5
Css3
JavaScript
TypeScript
Node.js
Python
Java
Go
Rust
C++

最大高度为4

大尺寸:
Vue
React
Angular
Svelte
Solid
MiniProgram
Flutter
UniApp
Html5
Css3
JavaScript
TypeScript
Node.js
Python
Java
Go
Rust
C++
"`; + exports[`ssr snapshot test > ssr test src/tag-input/_example/size.tsx 1`] = `"
Vue
React
Vue
React
Vue
React
"`; exports[`ssr snapshot test > ssr test src/tag-input/_example/status.tsx 1`] = `"
Vue
React
Miniprogram
Vue
React
Miniprogram
这是普通文本提示
Vue
React
Miniprogram
校验通过文本提示
Vue
React
Miniprogram
校验不通过文本提示
Vue
React
Miniprogram
校验存在严重问题文本提示
"`; From f2590821ff8bf1fa59d22b822a20b8b42a480b2a Mon Sep 17 00:00:00 2001 From: Haixing <65376724+HaixingOoO@users.noreply.github.com> Date: Wed, 29 Jan 2025 13:08:57 +0800 Subject: [PATCH 40/61] fix(Checkbox): fix checkboxGroup onChange context option param --- src/checkbox/CheckboxGroup.tsx | 3 +++ src/checkbox/type.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/src/checkbox/CheckboxGroup.tsx b/src/checkbox/CheckboxGroup.tsx index 42a0d44b45..fd6350aa91 100644 --- a/src/checkbox/CheckboxGroup.tsx +++ b/src/checkbox/CheckboxGroup.tsx @@ -138,11 +138,14 @@ const CheckboxGroup = (props: checkedSet.delete(checkValue); } + const currentOptionChecked = optionsWithoutCheckAll.find((item) => item.value === checkValue); + // 此处 `as` 是因为 `Array.from` 会导致 `checkSet` 的 generic type 丢失 setInternalValue(Array.from(checkedSet) as T, { e, current: checkProps.checkAll ? undefined : (checkValue as TdCheckboxProps), type: checked ? 'check' : 'uncheck', + option: checkProps.checkAll ? undefined : currentOptionChecked, }); }, }; diff --git a/src/checkbox/type.ts b/src/checkbox/type.ts index 46972166ec..2fc5c5e6b2 100644 --- a/src/checkbox/type.ts +++ b/src/checkbox/type.ts @@ -118,5 +118,6 @@ export type CheckboxGroupValue = Array; export interface CheckboxGroupChangeContext { e: ChangeEvent; current: CheckboxOption | TdCheckboxProps; + option: CheckboxOption | TdCheckboxProps; type: 'check' | 'uncheck'; } From 34272fa859dbf21b3bdb3c08db5695dc4ece346c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?w=C5=AB=20y=C4=81ng?= Date: Wed, 5 Feb 2025 17:54:33 +0800 Subject: [PATCH 41/61] feat(cascader): support auto scroll to first selected element (#3357) --- src/cascader/Cascader.tsx | 27 ++++++- src/cascader/_example/multiple.tsx | 86 ++++++++++++++++++++++- test/snap/__snapshots__/csr.test.jsx.snap | 4 +- 3 files changed, 113 insertions(+), 4 deletions(-) diff --git a/src/cascader/Cascader.tsx b/src/cascader/Cascader.tsx index febd1f0535..8171f16602 100644 --- a/src/cascader/Cascader.tsx +++ b/src/cascader/Cascader.tsx @@ -1,6 +1,6 @@ import React, { useMemo } from 'react'; import classNames from 'classnames'; -import { pick , omit } from 'lodash-es'; +import { pick, omit } from 'lodash-es'; import Panel from './components/Panel'; import SelectInput from '../select-input'; import FakeArrow from '../common/FakeArrow'; @@ -91,6 +91,30 @@ const Cascader: React.FC = (originalProps) => { const renderValueDisplay = () => parseContentTNode(props.valueDisplay, valueDisplayParams); const { setVisible, visible, inputVal, setInputVal } = cascaderContext; + + const updateScrollTop = (content: HTMLDivElement) => { + const cascaderMenuList = content.querySelectorAll(`.${COMPONENT_NAME}__menu`); + requestAnimationFrame(() => { + cascaderMenuList.forEach((menu: HTMLDivElement) => { + const firstSelectedNode: HTMLDivElement = + menu?.querySelector(`.${classPrefix}-is-selected`) || menu?.querySelector(`.${classPrefix}-is-expanded`); + if (!firstSelectedNode || !menu) return; + + const { paddingBottom } = getComputedStyle(firstSelectedNode); + const { marginBottom } = getComputedStyle(menu); + const elementBottomHeight = parseInt(paddingBottom, 10) + parseInt(marginBottom, 10); + + const updateValue = + firstSelectedNode.offsetTop - + menu.offsetTop - + (menu.clientHeight - firstSelectedNode.clientHeight) + + elementBottomHeight; + // eslint-disable-next-line no-param-reassign + menu.scrollTop = updateValue; + }); + }); + }; + return ( = (originalProps) => { valueDisplay={renderValueDisplay()} suffix={props.suffix} suffixIcon={renderSuffixIcon()} + updateScrollTop={updateScrollTop} popupProps={{ ...props.popupProps, overlayInnerStyle: panels.length && !props.loading ? { width: 'auto' } : {}, diff --git a/src/cascader/_example/multiple.tsx b/src/cascader/_example/multiple.tsx index 611bf03513..6cf85f0afd 100644 --- a/src/cascader/_example/multiple.tsx +++ b/src/cascader/_example/multiple.tsx @@ -3,7 +3,7 @@ import { Cascader } from 'tdesign-react'; import type { CascaderProps, CascaderValue } from 'tdesign-react'; export default function Example() { - const [value, setValue] = useState(['1.1']); + const [value, setValue] = useState(['8.1']); const options = [ { label: '选项一', @@ -37,6 +37,90 @@ export default function Example() { }, ], }, + { + label: '选项三', + value: '3', + children: [ + { + label: '子选项一', + value: '3.1', + }, + { + label: '子选项二', + value: '3.2', + }, + ], + }, + { + label: '选项四', + value: '4', + children: [ + { + label: '子选项一', + value: '4.1', + }, + { + label: '子选项二', + value: '4.2', + }, + ], + }, + { + label: '选项五', + value: '5', + children: [ + { + label: '子选项一', + value: '5.1', + }, + { + label: '子选项二', + value: '5.2', + }, + ], + }, + { + label: '选项六', + value: '6', + children: [ + { + label: '子选项一', + value: '6.1', + }, + { + label: '子选项二', + value: '6.2', + }, + ], + }, + { + label: '选项七', + value: '7', + children: [ + { + label: '子选项一', + value: '7.1', + }, + { + label: '子选项二', + value: '7.2', + }, + ], + }, + { + label: '选项8', + value: '8', + children: [ + { + label: '子选项一', + value: '8.1', + }, + { + label: '子选项二', + value: '8.2', + }, + ], + }, ]; const onChange: CascaderProps['onChange'] = (value) => { diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index 756cd533f7..affcb4103f 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -19620,9 +19620,9 @@ exports[`csr snapshot test > csr test src/cascader/_example/multiple.tsx 1`] = ` class="t-tag t-tag--default t-tag--dark" > - 选项一/子选项一 + 选项8/子选项一 Date: Wed, 5 Feb 2025 19:54:10 +0800 Subject: [PATCH 42/61] build(deps): bump @babel/runtime from 7.24.8 to 7.26.7 (#3351) Bumps [@babel/runtime](https://github.com/babel/babel/tree/HEAD/packages/babel-runtime) from 7.24.8 to 7.26.7. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.26.7/packages/babel-runtime) --- updated-dependencies: - dependency-name: "@babel/runtime" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 69a86f0f83..5a9c5e8987 100644 --- a/package.json +++ b/package.json @@ -200,7 +200,7 @@ "workbox-precaching": "^7.0.0" }, "dependencies": { - "@babel/runtime": "~7.24.7", + "@babel/runtime": "~7.26.7", "@popperjs/core": "~2.11.2", "@types/sortablejs": "^1.10.7", "@types/tinycolor2": "^1.4.3", From 645858e39415f552d1e05eb30c81635df075b21b Mon Sep 17 00:00:00 2001 From: Haixing <65376724+HaixingOoO@users.noreply.github.com> Date: Thu, 6 Feb 2025 12:34:15 +0800 Subject: [PATCH 43/61] fix(textarea): fix autofocus cursor at the end (#3358) --- src/textarea/Textarea.tsx | 10 ++++++++-- src/textarea/__tests__/textarea.test.tsx | 7 +++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/textarea/Textarea.tsx b/src/textarea/Textarea.tsx index 8ce2fea3e4..331d67985c 100644 --- a/src/textarea/Textarea.tsx +++ b/src/textarea/Textarea.tsx @@ -130,8 +130,14 @@ const Textarea = forwardRef((originalProps, useIsomorphicLayoutEffect(() => { adjustTextareaHeight(); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [textareaRef?.current]); + if (autofocus && textareaRef.current) { + const textarea = textareaRef.current; + textarea.focus(); + // 将光标移到内容的末尾 + textarea.selectionStart = textarea.value.length; + textarea.selectionEnd = textarea.value.length; + } + }, []); useIsomorphicLayoutEffect(() => { // 当未设置 autosize 时,需要将 textarea 的 height 设置为 auto,以支持原生的 textarea rows 属性 diff --git a/src/textarea/__tests__/textarea.test.tsx b/src/textarea/__tests__/textarea.test.tsx index 3c2691879e..d69488f6e4 100644 --- a/src/textarea/__tests__/textarea.test.tsx +++ b/src/textarea/__tests__/textarea.test.tsx @@ -85,4 +85,11 @@ describe('Textarea 组件测试', () => { expect(changeValue).not.toBeNull(); expect(event).not.toBeNull(); }); + + test('autofocus cursor end', async () => { + const value = 'test autofocus'; + const { container } = render(); + + expect(container.getElementsByTagName('textarea')[0].selectionStart).toBe(value.length); + }); }); From 6f18786f1d25e4b72a1fdd7071b7adedc1cbef05 Mon Sep 17 00:00:00 2001 From: hd10180 <898052669@qq.com> Date: Thu, 6 Feb 2025 15:22:49 +0800 Subject: [PATCH 44/61] feat(Menu): add menu collapse animation (#3342) * refactor(menu): menu collapse animation menu collapse animation * refactor(menu): menu collapse animation add menu collapse animation * chore: update common * chore: update submodule util path --------- Co-authored-by: github-actions[bot] Co-authored-by: Uyarn --- src/_common | 2 +- src/guide/Guide.tsx | 2 +- src/menu/SubMenu.tsx | 43 ++++++++++++++++---- test/snap/__snapshots__/csr.test.jsx.snap | 48 +++++++++++------------ test/snap/__snapshots__/ssr.test.jsx.snap | 4 +- 5 files changed, 63 insertions(+), 36 deletions(-) diff --git a/src/_common b/src/_common index e23ad04213..6da840b64f 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit e23ad04213d64f3b7161cc4cc758f8ca03d06ae9 +Subproject commit 6da840b64f5947a0c99bbaa3d51e4687ea880e5a diff --git a/src/guide/Guide.tsx b/src/guide/Guide.tsx index f73043a848..5d597a28e5 100644 --- a/src/guide/Guide.tsx +++ b/src/guide/Guide.tsx @@ -8,7 +8,7 @@ import Popup, { PopupProps } from '../popup'; import { StepPopupPlacement, TdGuideProps, GuideStep } from './type'; import { addClass, removeClass, isFixed, getWindowScroll, canUseDocument } from '../_util/dom'; import { scrollToParentVisibleArea, getRelativePosition, getTargetElm, scrollToElm } from './utils'; -import setStyle from '../_common/js/utils/set-style'; +import setStyle from '../_common/js/utils/setStyle'; import useControlled from '../hooks/useControlled'; import { guideDefaultProps } from './defaultProps'; import useDefaultProps from '../hooks/useDefaultProps'; diff --git a/src/menu/SubMenu.tsx b/src/menu/SubMenu.tsx index 682394c1be..04466be7fa 100644 --- a/src/menu/SubMenu.tsx +++ b/src/menu/SubMenu.tsx @@ -1,5 +1,6 @@ -import React, { FC, useContext, useState, ReactElement, useMemo } from 'react'; +import React, { FC, useContext, useState, ReactElement, useMemo, useRef } from 'react'; import classNames from 'classnames'; +import { CSSTransition } from 'react-transition-group'; import { StyledProps } from '../common'; import { TdSubmenuProps } from './type'; import useConfig from '../hooks/useConfig'; @@ -79,6 +80,23 @@ const SubAccordion: FC = (props) => { const fakeArrowStyle = isPopUp && level > 1 ? { transform: 'rotate(-90deg)' } : {}; + const contentRef = useRef(); + + const transitionCallbacks = { + onEnter: () => { + contentRef.current.style.height = `${contentRef?.current.scrollHeight}px`; + }, + onEntered: () => { + contentRef.current.style.height = 'auto'; + }, + onExit: () => { + contentRef.current.style.height = `${contentRef?.current.scrollHeight}px`; + }, + onExiting: () => { + contentRef.current.style.height = '0px'; + }, + }; + const pupContent = (
    = (props) => {
{!isPopUp && ( -
    - {childrens} -
+ +
    + {childrens} +
+
)} ); diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index affcb4103f..45540764ba 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -61103,8 +61103,8 @@ exports[`csr snapshot test > csr test src/menu/_example/group-side.tsx 1`] = `
  • csr test src/menu/_example/multi-side.tsx 1`] = `
  • csr test src/menu/_example/multi-side.tsx 1`] = `
  • csr test src/menu/_example/multi-side.tsx 1`] = `
  • csr test src/menu/_example/multi-side.tsx 1`] = `
  • csr test src/menu/_example/multi-side.tsx 1`] = `
  • csr test src/menu/_example/multi-side.tsx 1`] = `
  • csr test src/menu/_example/multi-side.tsx 1`] = `