@hi-ui/input 4.0.0-alpha.3 → 4.0.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -7
- package/lib/cjs/Input.js +93 -80
- package/lib/cjs/Input.js.map +1 -1
- package/lib/cjs/MockInput.js +154 -0
- package/lib/cjs/MockInput.js.map +1 -0
- package/lib/cjs/TextArea.js +109 -0
- package/lib/cjs/TextArea.js.map +1 -0
- package/lib/cjs/index.js +7 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/styles/index.scss.js +2 -2
- package/lib/cjs/use-input.js +129 -0
- package/lib/cjs/use-input.js.map +1 -0
- package/lib/cjs/utils/index.js +192 -0
- package/lib/cjs/utils/index.js.map +1 -0
- package/lib/esm/Input.js +93 -79
- package/lib/esm/Input.js.map +1 -1
- package/lib/esm/MockInput.js +132 -0
- package/lib/esm/MockInput.js.map +1 -0
- package/lib/esm/TextArea.js +88 -0
- package/lib/esm/TextArea.js.map +1 -0
- package/lib/esm/index.js +3 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/styles/index.scss.js +2 -2
- package/lib/esm/use-input.js +119 -0
- package/lib/esm/use-input.js.map +1 -0
- package/lib/esm/utils/index.js +176 -0
- package/lib/esm/utils/index.js.map +1 -0
- package/lib/types/Input.d.ts +23 -42
- package/lib/types/MockInput.d.ts +134 -0
- package/lib/types/TextArea.d.ts +29 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/use-input.d.ts +78 -0
- package/lib/types/utils/index.d.ts +9 -1
- package/package.json +14 -11
@@ -0,0 +1,134 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import type { HiBaseAppearanceEnum, HiBaseDataItem, HiBaseHTMLFieldProps } from '@hi-ui/core';
|
3
|
+
/**
|
4
|
+
* 支持自定义渲染输入框内容,暂时仅供内部 Picker 类组件使用,不对外提供
|
5
|
+
*/
|
6
|
+
export declare const MockInput: React.ForwardRefExoticComponent<Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>>, "disabled" | "readOnly" | "placeholder" | "defaultValue" | "value" | "onChange" | "type" | "focused" | "onSelect" | "title" | "size" | "prefix" | "data" | "onClick" | "appearance" | "suffix" | "clearableTrigger" | "clearable" | "displayRender"> & {
|
7
|
+
prefixCls?: string | undefined;
|
8
|
+
role?: string | undefined;
|
9
|
+
} & {
|
10
|
+
/**
|
11
|
+
* 设置当前多选值
|
12
|
+
*/
|
13
|
+
value?: React.ReactText | undefined;
|
14
|
+
/**
|
15
|
+
* 设置当前多选值默认值
|
16
|
+
*/
|
17
|
+
defaultValue?: React.ReactText | undefined;
|
18
|
+
/**
|
19
|
+
* 多选值改变时的回调
|
20
|
+
*/
|
21
|
+
onChange?: ((value: React.ReactText, item: any) => void) | undefined;
|
22
|
+
/**
|
23
|
+
* 是否可清空
|
24
|
+
*/
|
25
|
+
clearable?: boolean | undefined;
|
26
|
+
/**
|
27
|
+
* 清除按钮展示的触发形态
|
28
|
+
*/
|
29
|
+
clearableTrigger?: "always" | "hover" | undefined;
|
30
|
+
/**
|
31
|
+
* 是否禁止使用
|
32
|
+
*/
|
33
|
+
disabled?: boolean | undefined;
|
34
|
+
/**
|
35
|
+
* 自定义选择后触发器所展示的内容
|
36
|
+
*/
|
37
|
+
displayRender?: ((item: HiBaseDataItem) => React.ReactNode) | undefined;
|
38
|
+
/**
|
39
|
+
* 输入框占位符
|
40
|
+
*/
|
41
|
+
placeholder?: string | undefined;
|
42
|
+
/**
|
43
|
+
* 输入框后置内容
|
44
|
+
*/
|
45
|
+
suffix?: React.ReactNode;
|
46
|
+
/**
|
47
|
+
* 点击 Input 时触发回调
|
48
|
+
*/
|
49
|
+
onClick?: ((event: React.MouseEvent<HTMLDivElement>) => void) | undefined;
|
50
|
+
/**
|
51
|
+
* 展示数据源
|
52
|
+
*/
|
53
|
+
data?: HiBaseDataItem[] | undefined;
|
54
|
+
/**
|
55
|
+
* 是否聚焦
|
56
|
+
*/
|
57
|
+
focused?: boolean | undefined;
|
58
|
+
/**
|
59
|
+
* 开启输入框只读
|
60
|
+
*/
|
61
|
+
readOnly?: boolean | undefined;
|
62
|
+
/**
|
63
|
+
* 设置展现形式
|
64
|
+
*/
|
65
|
+
appearance?: HiBaseAppearanceEnum | undefined;
|
66
|
+
/**
|
67
|
+
* 设置输入框尺寸
|
68
|
+
*/
|
69
|
+
size?: "sm" | "md" | "lg" | undefined;
|
70
|
+
} & {
|
71
|
+
invalid?: boolean | undefined;
|
72
|
+
} & React.RefAttributes<HTMLDivElement | null>>;
|
73
|
+
export declare type MockInputProps = HiBaseHTMLFieldProps<'div', {
|
74
|
+
/**
|
75
|
+
* 设置当前多选值
|
76
|
+
*/
|
77
|
+
value?: React.ReactText;
|
78
|
+
/**
|
79
|
+
* 设置当前多选值默认值
|
80
|
+
*/
|
81
|
+
defaultValue?: React.ReactText;
|
82
|
+
/**
|
83
|
+
* 多选值改变时的回调
|
84
|
+
*/
|
85
|
+
onChange?: (value: React.ReactText, item: any) => void;
|
86
|
+
/**
|
87
|
+
* 是否可清空
|
88
|
+
*/
|
89
|
+
clearable?: boolean;
|
90
|
+
/**
|
91
|
+
* 清除按钮展示的触发形态
|
92
|
+
*/
|
93
|
+
clearableTrigger?: 'always' | 'hover';
|
94
|
+
/**
|
95
|
+
* 是否禁止使用
|
96
|
+
*/
|
97
|
+
disabled?: boolean;
|
98
|
+
/**
|
99
|
+
* 自定义选择后触发器所展示的内容
|
100
|
+
*/
|
101
|
+
displayRender?: (item: HiBaseDataItem) => React.ReactNode;
|
102
|
+
/**
|
103
|
+
* 输入框占位符
|
104
|
+
*/
|
105
|
+
placeholder?: string;
|
106
|
+
/**
|
107
|
+
* 输入框后置内容
|
108
|
+
*/
|
109
|
+
suffix?: React.ReactNode;
|
110
|
+
/**
|
111
|
+
* 点击 Input 时触发回调
|
112
|
+
*/
|
113
|
+
onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
114
|
+
/**
|
115
|
+
* 展示数据源
|
116
|
+
*/
|
117
|
+
data?: HiBaseDataItem[];
|
118
|
+
/**
|
119
|
+
* 是否聚焦
|
120
|
+
*/
|
121
|
+
focused?: boolean;
|
122
|
+
/**
|
123
|
+
* 开启输入框只读
|
124
|
+
*/
|
125
|
+
readOnly?: boolean;
|
126
|
+
/**
|
127
|
+
* 设置展现形式
|
128
|
+
*/
|
129
|
+
appearance?: HiBaseAppearanceEnum;
|
130
|
+
/**
|
131
|
+
* 设置输入框尺寸
|
132
|
+
*/
|
133
|
+
size?: 'sm' | 'md' | 'lg';
|
134
|
+
}>;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { HiBaseAppearanceEnum, HiBaseHTMLFieldProps } from '@hi-ui/core';
|
3
|
+
import { UseInputProps } from './use-input';
|
4
|
+
/**
|
5
|
+
* 动态文本域输入框
|
6
|
+
*
|
7
|
+
* @TODO:
|
8
|
+
* 1. 支持带数字展示
|
9
|
+
* 2. 支持自适应行高大小
|
10
|
+
* 3. 支持清空按钮
|
11
|
+
* 4. 支持最大最小行支持
|
12
|
+
* 5. 手动聚焦支持额外配置
|
13
|
+
*/
|
14
|
+
export declare const TextArea: React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<HTMLTextAreaElement | null>>;
|
15
|
+
export interface TextAreaProps extends HiBaseHTMLFieldProps<'textarea'>, Omit<UseInputProps, 'onFocus' | 'onBlur' | 'onChange' | 'type'> {
|
16
|
+
/**
|
17
|
+
* 设置输入框尺寸
|
18
|
+
*/
|
19
|
+
size?: 'sm' | 'md' | 'lg';
|
20
|
+
/**
|
21
|
+
* 设置展现形式
|
22
|
+
* 其中 `underline` 内部使用,不对外提供支持(风格去线型化:由线性过渡到面性)
|
23
|
+
*/
|
24
|
+
appearance?: HiBaseAppearanceEnum | 'underline';
|
25
|
+
/**
|
26
|
+
* 值改变时回调
|
27
|
+
*/
|
28
|
+
onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
29
|
+
}
|
package/lib/types/index.d.ts
CHANGED
@@ -0,0 +1,78 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
export declare const useInput: ({ name, autoFocus, disabled, readOnly, maxLength, placeholder, defaultValue, value: valueProp, onChange, onFocus, onBlur, trimValueOnBlur, type, clearElementRef, }: UseInputProps) => {
|
3
|
+
focused: boolean;
|
4
|
+
value: string;
|
5
|
+
tryChangeValue: (stateOrFunction: React.SetStateAction<string>, ...args: any[]) => void;
|
6
|
+
getInputProps: () => {
|
7
|
+
value: string;
|
8
|
+
onChange: (evt: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, trim?: any) => void;
|
9
|
+
onFocus: (evt: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
10
|
+
onBlur: (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
11
|
+
name: string | undefined;
|
12
|
+
disabled: boolean;
|
13
|
+
readOnly: boolean;
|
14
|
+
autoFocus: boolean;
|
15
|
+
placeholder: string | undefined;
|
16
|
+
maxLength: number | undefined;
|
17
|
+
'data-focused': "" | undefined;
|
18
|
+
};
|
19
|
+
};
|
20
|
+
export interface UseInputProps {
|
21
|
+
/**
|
22
|
+
* 开启输入框只读
|
23
|
+
*/
|
24
|
+
readOnly?: boolean;
|
25
|
+
/**
|
26
|
+
* 是否禁用
|
27
|
+
*/
|
28
|
+
disabled?: boolean;
|
29
|
+
/**
|
30
|
+
* 开启输入框自动聚焦
|
31
|
+
*/
|
32
|
+
autoFocus?: boolean;
|
33
|
+
/**
|
34
|
+
* 输入框字段名称
|
35
|
+
*/
|
36
|
+
name?: string;
|
37
|
+
/**
|
38
|
+
* 设置输入框的值
|
39
|
+
*/
|
40
|
+
value?: string;
|
41
|
+
/**
|
42
|
+
* 设置输入框的默认值
|
43
|
+
*/
|
44
|
+
defaultValue?: string;
|
45
|
+
/**
|
46
|
+
* 输入最大长度
|
47
|
+
*/
|
48
|
+
maxLength?: number;
|
49
|
+
/**
|
50
|
+
* 再失焦时触发对值的 trim onChange 给用户
|
51
|
+
*/
|
52
|
+
trimValueOnBlur?: boolean;
|
53
|
+
/**
|
54
|
+
* 输入框占位符
|
55
|
+
*/
|
56
|
+
placeholder?: string;
|
57
|
+
/**
|
58
|
+
* 值改变时的回调
|
59
|
+
*/
|
60
|
+
onChange?: (value: string, evt: React.ChangeEvent<any>) => void;
|
61
|
+
/**
|
62
|
+
* 输入框聚焦时的回调
|
63
|
+
*/
|
64
|
+
onFocus?: (evt: React.FocusEvent<any>) => void;
|
65
|
+
/**
|
66
|
+
* 输入框失焦时的回调
|
67
|
+
*/
|
68
|
+
onBlur?: (evt: React.FocusEvent<any>) => void;
|
69
|
+
/**
|
70
|
+
* 设置输入框类型,支持原生 input 的 type 属性所有值
|
71
|
+
*/
|
72
|
+
type?: 'text' | 'id' | 'tel' | 'card' | 'amount' | 'email' | string;
|
73
|
+
/**
|
74
|
+
* @private
|
75
|
+
*/
|
76
|
+
clearElementRef?: any;
|
77
|
+
}
|
78
|
+
export declare type useInputReturn = ReturnType<typeof useInput>;
|
@@ -17,7 +17,15 @@ export declare const pureCard: (val: string) => string;
|
|
17
17
|
* 金额自动生成小数
|
18
18
|
* @param {string} val 需要处理的值
|
19
19
|
*/
|
20
|
-
export declare const formatAmount: (val: string) => string;
|
20
|
+
export declare const formatAmount: (val: string, fill?: boolean) => string;
|
21
21
|
export declare const pureAmount: (val: string) => string;
|
22
22
|
export declare const formatEmail: (val: string) => string;
|
23
23
|
export declare const pureEmail: (val: string) => string;
|
24
|
+
/**
|
25
|
+
* 输入规则
|
26
|
+
*/
|
27
|
+
export declare const format: (val: string, type: string) => string;
|
28
|
+
/**
|
29
|
+
* 净化规则
|
30
|
+
*/
|
31
|
+
export declare const pure: (val: string, type: string) => string;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hi-ui/input",
|
3
|
-
"version": "4.0.0-alpha.
|
3
|
+
"version": "4.0.0-alpha.30",
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
5
5
|
"keywords": [],
|
6
6
|
"author": "HIUI <mi-hiui@xiaomi.com>",
|
@@ -43,21 +43,24 @@
|
|
43
43
|
"url": "https://github.com/XiaoMi/hiui/issues"
|
44
44
|
},
|
45
45
|
"dependencies": {
|
46
|
-
"@hi-ui/classname": "^4.0.0-alpha.
|
47
|
-
"@hi-ui/core
|
48
|
-
"@hi-ui/
|
49
|
-
"@hi-ui/
|
50
|
-
"@hi-ui/
|
51
|
-
"@hi-ui/
|
46
|
+
"@hi-ui/classname": "^4.0.0-alpha.3",
|
47
|
+
"@hi-ui/core": "^4.0.0-alpha.18",
|
48
|
+
"@hi-ui/core-css": "^4.0.0-alpha.13",
|
49
|
+
"@hi-ui/dom-utils": "^4.0.0-alpha.7",
|
50
|
+
"@hi-ui/env": "^4.0.0-alpha.5",
|
51
|
+
"@hi-ui/icons": "^4.0.0-alpha.26",
|
52
|
+
"@hi-ui/use-latest": "^4.0.0-alpha.5",
|
53
|
+
"@hi-ui/use-merge-refs": "^4.0.0-alpha.5",
|
54
|
+
"@hi-ui/use-uncontrolled-state": "^4.0.0-alpha.13"
|
52
55
|
},
|
53
56
|
"peerDependencies": {
|
54
|
-
"react": "
|
55
|
-
"react-dom": "
|
57
|
+
"react": ">=16.8.6",
|
58
|
+
"react-dom": ">=16.8.6"
|
56
59
|
},
|
57
60
|
"devDependencies": {
|
58
|
-
"@hi-ui/hi-build": "^4.0.0-alpha.
|
61
|
+
"@hi-ui/hi-build": "^4.0.0-alpha.4",
|
59
62
|
"react": "^17.0.1",
|
60
63
|
"react-dom": "^17.0.1"
|
61
64
|
},
|
62
|
-
"gitHead": "
|
65
|
+
"gitHead": "f001a9fe152b0f84d1a88b8782c38e1527020070"
|
63
66
|
}
|