-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Uyarn <[email protected]>
- Loading branch information
1 parent
9fe694d
commit 74cb32c
Showing
10 changed files
with
321 additions
and
78 deletions.
There are no files selected for viewing
Submodule _common
updated
14 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<DateMultipleValue>(['2000-01-04', '2000-01-03', '2000-01-05']); | ||
const [dateValue, setDateValue] = useState<DateMultipleValue>(['2024-10-01', '2024-10-24']); | ||
const [weekValue, setWeekValue] = useState<DateMultipleValue>(['2024-50周', '2024-51周']); | ||
const [yearValue, setYearValue] = useState<DateMultipleValue>(['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 ( | ||
<div> | ||
<Space direction="vertical"> | ||
<DatePicker | ||
value={dateValue} | ||
placeholder="可清除、可输入的日期选择器" | ||
onChange={handleDateChange} | ||
clearable | ||
multiple | ||
/> | ||
<DatePicker | ||
value={weekValue} | ||
placeholder="可清除、可输入的日期选择器" | ||
onChange={handleWeekChange} | ||
clearable | ||
multiple | ||
mode="week" | ||
/> | ||
<DatePicker | ||
value={defaultValue} | ||
value={yearValue} | ||
placeholder="可清除、可输入的日期选择器" | ||
onChange={handleChange} | ||
onChange={handleYearChange} | ||
clearable | ||
multiple | ||
mode="year" | ||
/> | ||
</div> | ||
</Space> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.