generated from react-component/footer
-
-
Notifications
You must be signed in to change notification settings - Fork 334
feat: support focus options #767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zombieJ
merged 16 commits into
react-component:master
from
crazyair:support-focus-options
Mar 1, 2024
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5284dfc
feat: support focus options
crazyair 2f842d3
feat: demo
crazyair 2f7f588
feat: 类型合并
crazyair 7a22de9
feat: 默认值
crazyair ed529d1
feat: 优化代码
crazyair 586e951
feat: type
crazyair 1cedd01
feat: type
crazyair b1b0f10
feat: type
crazyair 21604ec
feat: type
crazyair e66ca8a
feat: type
crazyair b5b4409
feat: type
crazyair 178ae21
feat: type
crazyair bd0b023
feat: type
crazyair 2740040
chore: merge usePickerRef
zombieJ b03c4e4
chore: fix null type
zombieJ ef7d6dd
chore: simplify ts
zombieJ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,8 @@ | ||
--- | ||
title: focus | ||
nav: | ||
title: Demo | ||
path: /demo | ||
--- | ||
|
||
<code src="../examples/focus.tsx"></code> |
This file contains hidden or 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,55 @@ | ||
import React, { useLayoutEffect, useRef, useState } from 'react'; | ||
import '../../assets/index.less'; | ||
import { Picker, RangePicker, type PickerRef } from '../../src'; | ||
import momentGenerateConfig from '../../src/generate/moment'; | ||
import zhCN from '../../src/locale/zh_CN'; | ||
import type { RangePickerRef } from '../../src/interface'; | ||
|
||
const MyPicker = () => { | ||
const ref = useRef<PickerRef>(null); | ||
useLayoutEffect(() => { | ||
if (ref.current) { | ||
ref.current.focus({ preventScroll: true }); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<Picker open locale={zhCN} generateConfig={momentGenerateConfig} ref={ref} /> | ||
</div> | ||
); | ||
}; | ||
|
||
const MyRangePicker = () => { | ||
const ref = useRef<RangePickerRef>(null); | ||
useLayoutEffect(() => { | ||
if (ref.current) { | ||
ref.current.focus({ preventScroll: true, index: 1 }); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<RangePicker open locale={zhCN} generateConfig={momentGenerateConfig} ref={ref} /> | ||
</div> | ||
); | ||
}; | ||
|
||
const Demo = () => { | ||
const [open, setOpen] = useState(false); | ||
const [open2, setOpen2] = useState(false); | ||
return ( | ||
<div> | ||
<div style={{ height: '50vh' }} /> | ||
<a onClick={() => setOpen(!open)}>picker {`${open}`}</a> | ||
<br /> | ||
<a onClick={() => setOpen2(!open2)}>rangePicker {`${open2}`}</a> | ||
<div style={{ height: '80vh' }} /> | ||
{open && <MyPicker />} | ||
{open2 && <MyRangePicker />} | ||
<div style={{ height: '30vh' }} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Demo; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.