@hi-ui/input 4.0.0-beta.16 → 4.0.0-beta.19
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/use-input.js +4 -0
- package/lib/esm/use-input.js +3 -0
- package/lib/types/Input.d.ts +3 -3
- package/lib/types/index.d.ts +1 -0
- package/lib/types/types.d.ts +1 -0
- package/lib/types/use-input.d.ts +1 -0
- package/package.json +3 -3
package/lib/cjs/use-input.js
CHANGED
@@ -23,6 +23,8 @@ var domUtils = require('@hi-ui/dom-utils');
|
|
23
23
|
|
24
24
|
var index = require('./utils/index.js');
|
25
25
|
|
26
|
+
var EXTRA_TYPE = ['text', 'id', 'tel', 'card', 'amount', 'email'];
|
27
|
+
|
26
28
|
var useInput = function useInput(_ref) {
|
27
29
|
var name = _ref.name,
|
28
30
|
_ref$autoFocus = _ref.autoFocus,
|
@@ -110,8 +112,10 @@ var useInput = function useInput(_ref) {
|
|
110
112
|
};
|
111
113
|
}, [disabled, readOnly, autoFocus, placeholder, maxLength, name, focused]);
|
112
114
|
var getInputProps = React.useCallback(function () {
|
115
|
+
var nativeType = EXTRA_TYPE.includes(type) ? undefined : type;
|
113
116
|
return Object.assign(Object.assign({}, nativeInputProps), {
|
114
117
|
value: index.format(value, type),
|
118
|
+
type: nativeType,
|
115
119
|
onChange: handleChange,
|
116
120
|
onFocus: handleFocus,
|
117
121
|
onBlur: handleBlur
|
package/lib/esm/use-input.js
CHANGED
@@ -12,6 +12,7 @@ import { useUncontrolledState } from '@hi-ui/use-uncontrolled-state';
|
|
12
12
|
import { useLatestCallback } from '@hi-ui/use-latest';
|
13
13
|
import { setAttrStatus } from '@hi-ui/dom-utils';
|
14
14
|
import { pure, format, formatAmount } from './utils/index.js';
|
15
|
+
var EXTRA_TYPE = ['text', 'id', 'tel', 'card', 'amount', 'email'];
|
15
16
|
|
16
17
|
var useInput = function useInput(_ref) {
|
17
18
|
var name = _ref.name,
|
@@ -100,8 +101,10 @@ var useInput = function useInput(_ref) {
|
|
100
101
|
};
|
101
102
|
}, [disabled, readOnly, autoFocus, placeholder, maxLength, name, focused]);
|
102
103
|
var getInputProps = useCallback(function () {
|
104
|
+
var nativeType = EXTRA_TYPE.includes(type) ? undefined : type;
|
103
105
|
return Object.assign(Object.assign({}, nativeInputProps), {
|
104
106
|
value: format(value, type),
|
107
|
+
type: nativeType,
|
105
108
|
onChange: handleChange,
|
106
109
|
onFocus: handleFocus,
|
107
110
|
onBlur: handleBlur
|
package/lib/types/Input.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { HiBaseHTMLFieldProps } from '@hi-ui/core';
|
3
|
-
import { InputAppearanceEnum } from './types';
|
3
|
+
import { InputAppearanceEnum, InputTypeEnum } from './types';
|
4
4
|
/**
|
5
5
|
* 输入框
|
6
6
|
*
|
@@ -34,9 +34,9 @@ export interface InputProps extends HiBaseHTMLFieldProps<'input'> {
|
|
34
34
|
*/
|
35
35
|
defaultValue?: string;
|
36
36
|
/**
|
37
|
-
*
|
37
|
+
* 设置输入框类型
|
38
38
|
*/
|
39
|
-
type?:
|
39
|
+
type?: InputTypeEnum;
|
40
40
|
/**
|
41
41
|
* 输入最大长度
|
42
42
|
*/
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/types.d.ts
CHANGED
package/lib/types/use-input.d.ts
CHANGED
@@ -5,6 +5,7 @@ export declare const useInput: ({ name, autoFocus, disabled, readOnly, maxLength
|
|
5
5
|
tryChangeValue: (stateOrFunction: React.SetStateAction<string>, ...args: any[]) => void;
|
6
6
|
getInputProps: () => {
|
7
7
|
value: string;
|
8
|
+
type: string | undefined;
|
8
9
|
onChange: (evt: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, trim?: any) => void;
|
9
10
|
onFocus: (evt: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
10
11
|
onBlur: (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hi-ui/input",
|
3
|
-
"version": "4.0.0-beta.
|
3
|
+
"version": "4.0.0-beta.19",
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
5
5
|
"keywords": [],
|
6
6
|
"author": "HIUI <mi-hiui@xiaomi.com>",
|
@@ -48,7 +48,7 @@
|
|
48
48
|
"@hi-ui/core-css": "^4.0.0-beta.5",
|
49
49
|
"@hi-ui/dom-utils": "^4.0.0-beta.6",
|
50
50
|
"@hi-ui/env": "^4.0.0-beta.1",
|
51
|
-
"@hi-ui/icons": "^4.0.0-beta.
|
51
|
+
"@hi-ui/icons": "^4.0.0-beta.12",
|
52
52
|
"@hi-ui/use-latest": "^4.0.0-beta.5",
|
53
53
|
"@hi-ui/use-merge-refs": "^4.0.0-beta.5",
|
54
54
|
"@hi-ui/use-uncontrolled-state": "^4.0.0-beta.5"
|
@@ -62,5 +62,5 @@
|
|
62
62
|
"react": "^17.0.1",
|
63
63
|
"react-dom": "^17.0.1"
|
64
64
|
},
|
65
|
-
"gitHead": "
|
65
|
+
"gitHead": "3180ed00bbe4a23ff0d5bfa1f5ca95f39ff9f494"
|
66
66
|
}
|