forked from XiaoMi/hiui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(time-picker): 新增自定义触发器(XiaoMi#2899)
- Loading branch information
yangxuexue
committed
Jun 14, 2024
1 parent
9416cd0
commit 83c933a
Showing
3 changed files
with
102 additions
and
38 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React, { useState } from 'react' | ||
import TimePicker from '../src' | ||
import Input from '@hi-ui/input' | ||
|
||
/** | ||
* @title 新增自定义触发器 | ||
*/ | ||
export const CustomRender = () => { | ||
const [basicValue, setBasicValue] = useState<string | string[]>(['12:00:00']) | ||
const [rangeValue, setRangeValue] = useState<string | string[]>(['11:11:11', '12:00:00']) | ||
|
||
return ( | ||
<> | ||
<h1>CustomRender-Basic</h1> | ||
<div className="time-picker-basic__wrap"> | ||
<TimePicker | ||
placeholder={['请选择时间']} | ||
value={basicValue} | ||
onChange={(e) => { | ||
console.log('basic-default', e) | ||
setBasicValue(e) | ||
}} | ||
customRender={(data) => { | ||
return <Input value={data[0]} readOnly placeholder="请选择" /> | ||
}} | ||
/> | ||
</div> | ||
<h1>CustomRender-Range</h1> | ||
<div className="time-picker-range__wrap"> | ||
<TimePicker | ||
value={rangeValue} | ||
placeholder={['请选择开始时间', '请选择结束时间']} | ||
onChange={(value) => { | ||
console.log('range-value', value) | ||
setRangeValue(value) | ||
}} | ||
type="range" | ||
customRender={(data) => { | ||
return <Input value={data.join('-')} readOnly placeholder="请选择" /> | ||
}} | ||
/> | ||
</div> | ||
</> | ||
) | ||
} |
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