1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | import React from 'react';
|
7 | import { LabIcon } from '../icon';
|
8 | import { classes } from '../utils';
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | export interface IInputGroupProps
|
14 | extends React.InputHTMLAttributes<HTMLInputElement> {
|
15 | |
16 |
|
17 |
|
18 | inputRef?: React.RefObject<HTMLInputElement>;
|
19 | |
20 |
|
21 |
|
22 | rightIcon?: string | LabIcon;
|
23 | }
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | export function InputGroup(props: IInputGroupProps): JSX.Element {
|
32 | const { className, inputRef, rightIcon, ...others } = props;
|
33 | return (
|
34 | <div className={classes('jp-InputGroup', className)}>
|
35 | <input ref={inputRef} {...others}></input>
|
36 | {rightIcon && (
|
37 | <span className="jp-InputGroupAction">
|
38 | {typeof rightIcon === 'string' ? (
|
39 | <LabIcon.resolveReact
|
40 | icon={rightIcon}
|
41 | elementPosition="center"
|
42 | tag="span"
|
43 | />
|
44 | ) : (
|
45 | <rightIcon.react elementPosition="center" tag="span" />
|
46 | )}
|
47 | </span>
|
48 | )}
|
49 | </div>
|
50 | );
|
51 | }
|