@hi-ui/input 4.0.0-alpha.21 → 4.0.0-alpha.22
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/lib/cjs/Input.js +44 -70
- package/lib/cjs/Input.js.map +1 -1
- package/lib/cjs/TextArea.js +102 -0
- package/lib/cjs/TextArea.js.map +1 -0
- package/lib/cjs/index.js +3 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/styles/index.scss.js +1 -1
- package/lib/cjs/use-input.js +98 -0
- package/lib/cjs/use-input.js.map +1 -0
- package/lib/esm/Input.js +43 -69
- package/lib/esm/Input.js.map +1 -1
- package/lib/esm/TextArea.js +81 -0
- package/lib/esm/TextArea.js.map +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/styles/index.scss.js +1 -1
- package/lib/esm/use-input.js +89 -0
- package/lib/esm/use-input.js.map +1 -0
- package/lib/types/MockInput.d.ts +1 -1
- package/lib/types/TextArea.d.ts +22 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/use-input.d.ts +70 -0
- package/package.json +12 -10
@@ -0,0 +1,22 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { HiBaseHTMLFieldProps } from '@hi-ui/core';
|
3
|
+
import { UseInputProps } from './use-input';
|
4
|
+
/**
|
5
|
+
* TODO: What is TextArea
|
6
|
+
*/
|
7
|
+
export declare const TextArea: React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<HTMLTextAreaElement | null>>;
|
8
|
+
export interface TextAreaProps extends HiBaseHTMLFieldProps<'textarea'>, Omit<UseInputProps, 'onFocus' | 'onBlur' | 'onChange'> {
|
9
|
+
/**
|
10
|
+
* 设置输入框尺寸
|
11
|
+
*/
|
12
|
+
size?: 'sm' | 'md' | 'lg';
|
13
|
+
/**
|
14
|
+
* 设置展现形式
|
15
|
+
* 其中 `underline` 内部使用,不对外提供支持(风格去线型化:由线性过渡到面性)
|
16
|
+
*/
|
17
|
+
appearance?: 'outline' | 'unset' | 'filled' | 'underline';
|
18
|
+
/**
|
19
|
+
* 值改变时回调
|
20
|
+
*/
|
21
|
+
onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
22
|
+
}
|
package/lib/types/index.d.ts
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
export declare const useInput: ({ name, autoFocus, disabled, readOnly, maxLength, placeholder, defaultValue, value: valueProp, onChange, onFocus, onBlur, trimValueOnBlur, }: 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>) => 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
|
+
export declare type useInputReturn = ReturnType<typeof useInput>;
|
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.22",
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
5
5
|
"keywords": [],
|
6
6
|
"author": "HIUI <mi-hiui@xiaomi.com>",
|
@@ -43,22 +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": "^4.0.0-alpha.
|
48
|
-
"@hi-ui/core-css": "^4.0.0-alpha.
|
49
|
-
"@hi-ui/
|
50
|
-
"@hi-ui/
|
51
|
-
"@hi-ui/
|
52
|
-
"@hi-ui/use-
|
46
|
+
"@hi-ui/classname": "^4.0.0-alpha.3",
|
47
|
+
"@hi-ui/core": "^4.0.0-alpha.12",
|
48
|
+
"@hi-ui/core-css": "^4.0.0-alpha.10",
|
49
|
+
"@hi-ui/dom-utils": "^4.0.0-alpha.6",
|
50
|
+
"@hi-ui/env": "^4.0.0-alpha.5",
|
51
|
+
"@hi-ui/icons": "^4.0.0-alpha.18",
|
52
|
+
"@hi-ui/use-latest": "^4.0.0-alpha.4",
|
53
|
+
"@hi-ui/use-merge-refs": "^4.0.0-alpha.4",
|
54
|
+
"@hi-ui/use-uncontrolled-state": "^4.0.0-alpha.12"
|
53
55
|
},
|
54
56
|
"peerDependencies": {
|
55
57
|
"react": "^17.0.1",
|
56
58
|
"react-dom": "^17.0.1"
|
57
59
|
},
|
58
60
|
"devDependencies": {
|
59
|
-
"@hi-ui/hi-build": "^4.0.0-alpha.
|
61
|
+
"@hi-ui/hi-build": "^4.0.0-alpha.4",
|
60
62
|
"react": "^17.0.1",
|
61
63
|
"react-dom": "^17.0.1"
|
62
64
|
},
|
63
|
-
"gitHead": "
|
65
|
+
"gitHead": "4fe4855aa7b3180a4e30ffa0972ac39a04947b4b"
|
64
66
|
}
|