@tamagui/input 1.99.0 → 1.99.1
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/dist/esm/Input.native.mjs +98 -0
- package/dist/jsx/Input.native.mjs +98 -0
- package/package.json +9 -9
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { styled, useComposedRefs } from "@tamagui/core";
|
|
2
|
+
import { registerFocusable } from "@tamagui/focusable";
|
|
3
|
+
import React, { useEffect } from "react";
|
|
4
|
+
import { TextInput } from "react-native";
|
|
5
|
+
import { styledBody } from "./shared.mjs";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
const StyledInput = styled(TextInput, styledBody[0], styledBody[1]),
|
|
8
|
+
Input = StyledInput.styleable((inProps, forwardedRef) => {
|
|
9
|
+
const {
|
|
10
|
+
// some of destructed props are just to avoid passing them to ...rest because they are not in native.
|
|
11
|
+
type,
|
|
12
|
+
//@ts-ignore
|
|
13
|
+
dirname,
|
|
14
|
+
max,
|
|
15
|
+
min,
|
|
16
|
+
minLength,
|
|
17
|
+
multiple,
|
|
18
|
+
name,
|
|
19
|
+
required,
|
|
20
|
+
step,
|
|
21
|
+
disabled,
|
|
22
|
+
id,
|
|
23
|
+
caretColor,
|
|
24
|
+
onChange,
|
|
25
|
+
onInput,
|
|
26
|
+
rows,
|
|
27
|
+
enterKeyHint,
|
|
28
|
+
returnKeyType,
|
|
29
|
+
onKeyDown,
|
|
30
|
+
inputMode,
|
|
31
|
+
tag,
|
|
32
|
+
...rest
|
|
33
|
+
} = inProps,
|
|
34
|
+
ref = React.useRef(null),
|
|
35
|
+
composedRefs = useComposedRefs(forwardedRef, ref);
|
|
36
|
+
let secureTextEntry = !1,
|
|
37
|
+
cursorColor = caretColor,
|
|
38
|
+
_returnKeyType = returnKeyType,
|
|
39
|
+
_enterKeyHint = enterKeyHint;
|
|
40
|
+
enterKeyHint === "go" && (_returnKeyType = "go", _enterKeyHint = void 0);
|
|
41
|
+
let _inputMode = inputMode;
|
|
42
|
+
type === "email" ? _inputMode = "email" : type === "tel" ? _inputMode = "tel" : type === "search" ? _inputMode = "search" : type === "url" ? _inputMode = "url" : type === "password" ? (secureTextEntry = !0, _inputMode = "text") : type === "number" ? _inputMode = "numeric" : _inputMode = "text";
|
|
43
|
+
let showSoftInputOnFocus = !0;
|
|
44
|
+
inputMode === "none" && (showSoftInputOnFocus = !1);
|
|
45
|
+
const finalProps = {
|
|
46
|
+
...rest,
|
|
47
|
+
inputMode: _inputMode,
|
|
48
|
+
showSoftInputOnFocus,
|
|
49
|
+
disabled,
|
|
50
|
+
id,
|
|
51
|
+
cursorColor,
|
|
52
|
+
enterKeyHint: _enterKeyHint,
|
|
53
|
+
returnKeyType: _returnKeyType,
|
|
54
|
+
secureTextEntry,
|
|
55
|
+
numberOfLines: rows || rest.numberOfLines
|
|
56
|
+
};
|
|
57
|
+
return tag === "textarea" && (finalProps.multiline = !0), onKeyDown && (finalProps.onKeyPress = e => {
|
|
58
|
+
const {
|
|
59
|
+
key
|
|
60
|
+
} = e.nativeEvent;
|
|
61
|
+
(key === "Backspace" || tag === "textarea" && key === "Enter" || key.length === 1) && onKeyDown({
|
|
62
|
+
key,
|
|
63
|
+
type: "keydown"
|
|
64
|
+
});
|
|
65
|
+
}, finalProps.onSubmitEditing = e => {
|
|
66
|
+
onKeyDown({
|
|
67
|
+
key: "Enter",
|
|
68
|
+
type: "keydown"
|
|
69
|
+
});
|
|
70
|
+
}), (onChange || onInput) && (finalProps.onChange = e => {
|
|
71
|
+
const {
|
|
72
|
+
text
|
|
73
|
+
} = e.nativeEvent;
|
|
74
|
+
onChange && onChange({
|
|
75
|
+
target: {
|
|
76
|
+
value: text
|
|
77
|
+
},
|
|
78
|
+
type: "change"
|
|
79
|
+
}), onInput?.({
|
|
80
|
+
target: {
|
|
81
|
+
value: text
|
|
82
|
+
},
|
|
83
|
+
type: "input"
|
|
84
|
+
});
|
|
85
|
+
}), useEffect(() => {
|
|
86
|
+
if (id && !disabled) return registerFocusable(id, {
|
|
87
|
+
focusAndSelect: () => {
|
|
88
|
+
ref.current?.focus();
|
|
89
|
+
},
|
|
90
|
+
focus: () => {}
|
|
91
|
+
});
|
|
92
|
+
}, [id, disabled]), /* @__PURE__ */jsx(StyledInput, {
|
|
93
|
+
onChange: e => {},
|
|
94
|
+
ref: composedRefs,
|
|
95
|
+
...finalProps
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
export { Input };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { styled, useComposedRefs } from "@tamagui/core";
|
|
2
|
+
import { registerFocusable } from "@tamagui/focusable";
|
|
3
|
+
import React, { useEffect } from "react";
|
|
4
|
+
import { TextInput } from "react-native";
|
|
5
|
+
import { styledBody } from "./shared.mjs";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
const StyledInput = styled(TextInput, styledBody[0], styledBody[1]),
|
|
8
|
+
Input = StyledInput.styleable((inProps, forwardedRef) => {
|
|
9
|
+
const {
|
|
10
|
+
// some of destructed props are just to avoid passing them to ...rest because they are not in native.
|
|
11
|
+
type,
|
|
12
|
+
//@ts-ignore
|
|
13
|
+
dirname,
|
|
14
|
+
max,
|
|
15
|
+
min,
|
|
16
|
+
minLength,
|
|
17
|
+
multiple,
|
|
18
|
+
name,
|
|
19
|
+
required,
|
|
20
|
+
step,
|
|
21
|
+
disabled,
|
|
22
|
+
id,
|
|
23
|
+
caretColor,
|
|
24
|
+
onChange,
|
|
25
|
+
onInput,
|
|
26
|
+
rows,
|
|
27
|
+
enterKeyHint,
|
|
28
|
+
returnKeyType,
|
|
29
|
+
onKeyDown,
|
|
30
|
+
inputMode,
|
|
31
|
+
tag,
|
|
32
|
+
...rest
|
|
33
|
+
} = inProps,
|
|
34
|
+
ref = React.useRef(null),
|
|
35
|
+
composedRefs = useComposedRefs(forwardedRef, ref);
|
|
36
|
+
let secureTextEntry = !1,
|
|
37
|
+
cursorColor = caretColor,
|
|
38
|
+
_returnKeyType = returnKeyType,
|
|
39
|
+
_enterKeyHint = enterKeyHint;
|
|
40
|
+
enterKeyHint === "go" && (_returnKeyType = "go", _enterKeyHint = void 0);
|
|
41
|
+
let _inputMode = inputMode;
|
|
42
|
+
type === "email" ? _inputMode = "email" : type === "tel" ? _inputMode = "tel" : type === "search" ? _inputMode = "search" : type === "url" ? _inputMode = "url" : type === "password" ? (secureTextEntry = !0, _inputMode = "text") : type === "number" ? _inputMode = "numeric" : _inputMode = "text";
|
|
43
|
+
let showSoftInputOnFocus = !0;
|
|
44
|
+
inputMode === "none" && (showSoftInputOnFocus = !1);
|
|
45
|
+
const finalProps = {
|
|
46
|
+
...rest,
|
|
47
|
+
inputMode: _inputMode,
|
|
48
|
+
showSoftInputOnFocus,
|
|
49
|
+
disabled,
|
|
50
|
+
id,
|
|
51
|
+
cursorColor,
|
|
52
|
+
enterKeyHint: _enterKeyHint,
|
|
53
|
+
returnKeyType: _returnKeyType,
|
|
54
|
+
secureTextEntry,
|
|
55
|
+
numberOfLines: rows || rest.numberOfLines
|
|
56
|
+
};
|
|
57
|
+
return tag === "textarea" && (finalProps.multiline = !0), onKeyDown && (finalProps.onKeyPress = e => {
|
|
58
|
+
const {
|
|
59
|
+
key
|
|
60
|
+
} = e.nativeEvent;
|
|
61
|
+
(key === "Backspace" || tag === "textarea" && key === "Enter" || key.length === 1) && onKeyDown({
|
|
62
|
+
key,
|
|
63
|
+
type: "keydown"
|
|
64
|
+
});
|
|
65
|
+
}, finalProps.onSubmitEditing = e => {
|
|
66
|
+
onKeyDown({
|
|
67
|
+
key: "Enter",
|
|
68
|
+
type: "keydown"
|
|
69
|
+
});
|
|
70
|
+
}), (onChange || onInput) && (finalProps.onChange = e => {
|
|
71
|
+
const {
|
|
72
|
+
text
|
|
73
|
+
} = e.nativeEvent;
|
|
74
|
+
onChange && onChange({
|
|
75
|
+
target: {
|
|
76
|
+
value: text
|
|
77
|
+
},
|
|
78
|
+
type: "change"
|
|
79
|
+
}), onInput?.({
|
|
80
|
+
target: {
|
|
81
|
+
value: text
|
|
82
|
+
},
|
|
83
|
+
type: "input"
|
|
84
|
+
});
|
|
85
|
+
}), useEffect(() => {
|
|
86
|
+
if (id && !disabled) return registerFocusable(id, {
|
|
87
|
+
focusAndSelect: () => {
|
|
88
|
+
ref.current?.focus();
|
|
89
|
+
},
|
|
90
|
+
focus: () => {}
|
|
91
|
+
});
|
|
92
|
+
}, [id, disabled]), /* @__PURE__ */jsx(StyledInput, {
|
|
93
|
+
onChange: e => {},
|
|
94
|
+
ref: composedRefs,
|
|
95
|
+
...finalProps
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
export { Input };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/input",
|
|
3
|
-
"version": "1.99.
|
|
3
|
+
"version": "1.99.1",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@tamagui/font-size": "1.99.
|
|
36
|
-
"@tamagui/get-button-sized": "1.99.
|
|
37
|
-
"@tamagui/helpers": "1.99.
|
|
38
|
-
"@tamagui/helpers-tamagui": "1.99.
|
|
39
|
-
"@tamagui/stacks": "1.99.
|
|
40
|
-
"@tamagui/text": "1.99.
|
|
41
|
-
"@tamagui/web": "1.99.
|
|
35
|
+
"@tamagui/font-size": "1.99.1",
|
|
36
|
+
"@tamagui/get-button-sized": "1.99.1",
|
|
37
|
+
"@tamagui/helpers": "1.99.1",
|
|
38
|
+
"@tamagui/helpers-tamagui": "1.99.1",
|
|
39
|
+
"@tamagui/stacks": "1.99.1",
|
|
40
|
+
"@tamagui/text": "1.99.1",
|
|
41
|
+
"@tamagui/web": "1.99.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@tamagui/build": "1.99.
|
|
44
|
+
"@tamagui/build": "1.99.1",
|
|
45
45
|
"react": "^18.2.0",
|
|
46
46
|
"vitest": "^0.34.3"
|
|
47
47
|
},
|