1 | import type { CSSProperties, InputHTMLAttributes, KeyboardEventHandler, MouseEventHandler, ReactElement, ReactNode } from 'react';
|
2 | import type { InputFocusOptions } from './utils/commonUtils';
|
3 | import type { LiteralUnion } from './utils/types';
|
4 | export interface CommonInputProps {
|
5 | prefix?: ReactNode;
|
6 | suffix?: ReactNode;
|
7 | addonBefore?: ReactNode;
|
8 | addonAfter?: ReactNode;
|
9 |
|
10 | classes?: {
|
11 | affixWrapper?: string;
|
12 | group?: string;
|
13 | wrapper?: string;
|
14 | };
|
15 | classNames?: {
|
16 | affixWrapper?: string;
|
17 | prefix?: string;
|
18 | suffix?: string;
|
19 | };
|
20 | styles?: {
|
21 | affixWrapper?: CSSProperties;
|
22 | prefix?: CSSProperties;
|
23 | suffix?: CSSProperties;
|
24 | };
|
25 | allowClear?: boolean | {
|
26 | clearIcon?: ReactNode;
|
27 | };
|
28 | }
|
29 | type DataAttr = Record<`data-${string}`, string>;
|
30 | export type ValueType = InputHTMLAttributes<HTMLInputElement>['value'] | bigint;
|
31 | export interface BaseInputProps extends CommonInputProps {
|
32 | value?: ValueType;
|
33 | inputElement: ReactElement;
|
34 | prefixCls?: string;
|
35 | className?: string;
|
36 | style?: CSSProperties;
|
37 | disabled?: boolean;
|
38 | focused?: boolean;
|
39 | triggerFocus?: () => void;
|
40 | readOnly?: boolean;
|
41 | handleReset?: MouseEventHandler;
|
42 | hidden?: boolean;
|
43 | dataAttrs?: {
|
44 | affixWrapper?: DataAttr;
|
45 | };
|
46 | components?: {
|
47 | affixWrapper?: 'span' | 'div';
|
48 | groupWrapper?: 'span' | 'div';
|
49 | wrapper?: 'span' | 'div';
|
50 | groupAddon?: 'span' | 'div';
|
51 | };
|
52 | }
|
53 | export interface ShowCountProps {
|
54 | formatter: (args: {
|
55 | value: string;
|
56 | count: number;
|
57 | maxLength?: number;
|
58 | }) => ReactNode;
|
59 | }
|
60 | export interface InputProps extends CommonInputProps, Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix' | 'type' | 'value'> {
|
61 | value?: ValueType;
|
62 | prefixCls?: string;
|
63 | type?: LiteralUnion<'button' | 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week', string>;
|
64 | onPressEnter?: KeyboardEventHandler<HTMLInputElement>;
|
65 | showCount?: boolean | ShowCountProps;
|
66 | autoComplete?: string;
|
67 | htmlSize?: number;
|
68 | classNames?: CommonInputProps['classNames'] & {
|
69 | input?: string;
|
70 | count?: string;
|
71 | };
|
72 | styles?: CommonInputProps['styles'] & {
|
73 | input?: CSSProperties;
|
74 | count?: CSSProperties;
|
75 | };
|
76 | }
|
77 | export interface InputRef {
|
78 | focus: (options?: InputFocusOptions) => void;
|
79 | blur: () => void;
|
80 | setSelectionRange: (start: number, end: number, direction?: 'forward' | 'backward' | 'none') => void;
|
81 | select: () => void;
|
82 | input: HTMLInputElement | null;
|
83 | }
|
84 | export {};
|