File tree Expand file tree Collapse file tree 4 files changed +7
-36
lines changed
Expand file tree Collapse file tree 4 files changed +7
-36
lines changed Original file line number Diff line number Diff line change 4444 "prepare" : " husky install"
4545 },
4646 "dependencies" : {
47- "@rc-component/util" : " ^1.3 .0" ,
47+ "@rc-component/util" : " ^1.4 .0" ,
4848 "clsx" : " ^2.1.1"
4949 },
5050 "devDependencies" : {
Original file line number Diff line number Diff line change @@ -12,8 +12,11 @@ import type { HolderRef } from './BaseInput';
1212import BaseInput from './BaseInput' ;
1313import useCount from './hooks/useCount' ;
1414import type { ChangeEventInfo , InputProps , InputRef } from './interface' ;
15- import type { InputFocusOptions } from './utils/commonUtils' ;
16- import { resolveOnChange , triggerFocus } from './utils/commonUtils' ;
15+ import { resolveOnChange } from './utils/commonUtils' ;
16+ import {
17+ triggerFocus ,
18+ type InputFocusOptions ,
19+ } from '@rc-component/util/lib/Dom/focus' ;
1720
1821const Input = forwardRef < InputRef , InputProps > ( ( props , ref ) => {
1922 const {
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ import type {
66 ReactElement ,
77 ReactNode ,
88} from 'react' ;
9- import type { InputFocusOptions } from './utils/commonUtils' ;
109import type { LiteralUnion } from './utils/types' ;
10+ import type { InputFocusOptions } from '@rc-component/util/lib/Dom/focus' ;
1111
1212export interface CommonInputProps {
1313 prefix ?: ReactNode ;
Original file line number Diff line number Diff line change @@ -90,35 +90,3 @@ export function resolveOnChange<
9090 }
9191 onChange ( event as React . ChangeEvent < E > ) ;
9292}
93-
94- export interface InputFocusOptions extends FocusOptions {
95- cursor ?: 'start' | 'end' | 'all' ;
96- }
97-
98- export function triggerFocus (
99- element ?: HTMLInputElement | HTMLTextAreaElement ,
100- option ?: InputFocusOptions ,
101- ) {
102- if ( ! element ) return ;
103-
104- element . focus ( option ) ;
105-
106- // Selection content
107- const { cursor } = option || { } ;
108- if ( cursor ) {
109- const len = element . value . length ;
110-
111- switch ( cursor ) {
112- case 'start' :
113- element . setSelectionRange ( 0 , 0 ) ;
114- break ;
115-
116- case 'end' :
117- element . setSelectionRange ( len , len ) ;
118- break ;
119-
120- default :
121- element . setSelectionRange ( 0 , len ) ;
122- }
123- }
124- }
You can’t perform that action at this time.
0 commit comments