@tamagui/input 1.143.0 → 2.0.0-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/cjs/Input.cjs +57 -122
- package/dist/cjs/Input.js +46 -115
- package/dist/cjs/Input.js.map +1 -1
- package/dist/cjs/Input.native.js +133 -71
- package/dist/cjs/Input.native.js.map +1 -1
- package/dist/cjs/TextArea.cjs +1 -1
- package/dist/cjs/TextArea.js +1 -1
- package/dist/cjs/TextArea.js.map +1 -1
- package/dist/cjs/TextArea.native.js +1 -1
- package/dist/cjs/TextArea.native.js.map +1 -1
- package/dist/esm/Input.js +47 -116
- package/dist/esm/Input.js.map +1 -1
- package/dist/esm/Input.mjs +58 -123
- package/dist/esm/Input.mjs.map +1 -1
- package/dist/esm/Input.native.js +134 -72
- package/dist/esm/Input.native.js.map +1 -1
- package/dist/esm/TextArea.js +1 -1
- package/dist/esm/TextArea.js.map +1 -1
- package/dist/esm/TextArea.mjs +1 -1
- package/dist/esm/TextArea.mjs.map +1 -1
- package/dist/esm/TextArea.native.js +1 -1
- package/dist/esm/TextArea.native.js.map +1 -1
- package/dist/jsx/Input.js +47 -116
- package/dist/jsx/Input.js.map +1 -1
- package/dist/jsx/Input.mjs +58 -123
- package/dist/jsx/Input.mjs.map +1 -1
- package/dist/jsx/Input.native.js +133 -71
- package/dist/jsx/Input.native.js.map +1 -1
- package/dist/jsx/TextArea.js +1 -1
- package/dist/jsx/TextArea.js.map +1 -1
- package/dist/jsx/TextArea.mjs +1 -1
- package/dist/jsx/TextArea.mjs.map +1 -1
- package/dist/jsx/TextArea.native.js +1 -1
- package/dist/jsx/TextArea.native.js.map +1 -1
- package/package.json +13 -13
- package/src/Input.native.tsx +145 -110
- package/src/Input.tsx +67 -137
- package/src/TextArea.tsx +4 -2
- package/src/types.ts +52 -41
- package/src/v1/Input.native.tsx +154 -0
- package/src/v1/Input.tsx +191 -0
- package/src/v1/TextArea.tsx +35 -0
- package/src/v1/index.ts +3 -0
- package/src/v1/types.ts +65 -0
- package/types/Input.d.ts +47 -21
- package/types/Input.d.ts.map +1 -1
- package/types/Input.native.d.ts +52 -22
- package/types/Input.native.d.ts.map +1 -1
- package/types/TextArea.d.ts +25 -11
- package/types/TextArea.d.ts.map +1 -1
- package/types/types.d.ts +47 -21
- package/types/types.d.ts.map +1 -1
- package/types/v1/Input.d.ts +115 -0
- package/types/v1/Input.native.d.ts +114 -0
- package/types/v1/TextArea.d.ts +98 -0
- package/types/v1/index.d.ts +4 -0
- package/types/v1/types.d.ts +39 -0
- package/types/v1/types.d.ts.map +1 -1
package/dist/cjs/Input.cjs
CHANGED
|
@@ -40,147 +40,82 @@ var import_core = require("@tamagui/core"),
|
|
|
40
40
|
import_shared = require("./shared.cjs"),
|
|
41
41
|
import_jsx_runtime = require("react/jsx-runtime");
|
|
42
42
|
const StyledInput = (0, import_core.styled)(import_core.View, import_shared.styledBody[0], import_shared.styledBody[1]),
|
|
43
|
-
Input = StyledInput.styleable((
|
|
43
|
+
Input = StyledInput.styleable((props, forwardedRef) => {
|
|
44
44
|
const {
|
|
45
|
-
// some of destructed props are just to avoid passing them to ...rest because they are not in web.
|
|
46
|
-
allowFontScaling,
|
|
47
|
-
selectTextOnFocus,
|
|
48
|
-
showSoftInputOnFocus,
|
|
49
|
-
textContentType,
|
|
50
|
-
passwordRules,
|
|
51
|
-
textBreakStrategy,
|
|
52
|
-
underlineColorAndroid,
|
|
53
|
-
selection,
|
|
54
|
-
lineBreakStrategyIOS,
|
|
55
|
-
returnKeyLabel,
|
|
56
45
|
disabled,
|
|
57
|
-
onSubmitEditing,
|
|
58
|
-
caretHidden,
|
|
59
|
-
clearButtonMode,
|
|
60
|
-
clearTextOnFocus,
|
|
61
|
-
contextMenuHidden,
|
|
62
|
-
dataDetectorTypes,
|
|
63
46
|
id,
|
|
64
|
-
enablesReturnKeyAutomatically,
|
|
65
|
-
importantForAutofill,
|
|
66
|
-
inlineImageLeft,
|
|
67
|
-
inlineImagePadding,
|
|
68
|
-
inputAccessoryViewID,
|
|
69
|
-
keyboardAppearance,
|
|
70
|
-
keyboardType,
|
|
71
|
-
cursorColor,
|
|
72
|
-
disableFullscreenUI,
|
|
73
|
-
editable,
|
|
74
|
-
maxFontSizeMultiplier,
|
|
75
|
-
multiline,
|
|
76
|
-
numberOfLines,
|
|
77
47
|
onChangeText,
|
|
78
|
-
|
|
79
|
-
onEndEditing,
|
|
80
|
-
onScroll,
|
|
48
|
+
onSubmitEditing,
|
|
81
49
|
onSelectionChange,
|
|
82
|
-
|
|
50
|
+
selection,
|
|
83
51
|
placeholderTextColor,
|
|
84
|
-
blurOnSubmit,
|
|
85
|
-
enterKeyHint,
|
|
86
|
-
returnKeyType,
|
|
87
|
-
rejectResponderTermination,
|
|
88
|
-
scrollEnabled,
|
|
89
|
-
secureTextEntry,
|
|
90
52
|
selectionColor,
|
|
91
|
-
|
|
53
|
+
rows,
|
|
92
54
|
...rest
|
|
93
|
-
} =
|
|
55
|
+
} = props,
|
|
94
56
|
ref = import_react.default.useRef(null),
|
|
95
57
|
theme = (0, import_core.useTheme)(),
|
|
96
|
-
composedRefs = (0, import_core.useComposedRefs)(forwardedRef, ref)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
58
|
+
composedRefs = (0, import_core.useComposedRefs)(forwardedRef, ref);
|
|
59
|
+
import_react.default.useEffect(() => {
|
|
60
|
+
if (!onSelectionChange) return;
|
|
61
|
+
const node = ref.current;
|
|
62
|
+
if (!node) return;
|
|
63
|
+
const handleSelectionChange = () => {
|
|
64
|
+
onSelectionChange({
|
|
101
65
|
nativeEvent: {
|
|
102
66
|
selection: {
|
|
103
|
-
|
|
104
|
-
|
|
67
|
+
start: node.selectionStart ?? 0,
|
|
68
|
+
end: node.selectionEnd ?? 0
|
|
105
69
|
}
|
|
106
70
|
}
|
|
107
71
|
});
|
|
108
|
-
});
|
|
109
|
-
import_react.default.useEffect(() => {
|
|
110
|
-
if (onSelectionChange) return ref.current?.addEventListener("selectionchange", _onSelectionChange), () => {
|
|
111
|
-
ref.current?.removeEventListener("selectionchange", _onSelectionChange);
|
|
112
72
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
id,
|
|
121
|
-
enterKeyHint,
|
|
122
|
-
type: (() => {
|
|
123
|
-
if (rest?.type) return rest.type;
|
|
124
|
-
if (secureTextEntry) return "password";
|
|
125
|
-
switch (keyboardType) {
|
|
126
|
-
case "number-pad":
|
|
127
|
-
case "numeric":
|
|
128
|
-
return "number";
|
|
129
|
-
case "email-address":
|
|
130
|
-
return "email";
|
|
131
|
-
case "phone-pad":
|
|
132
|
-
return "tel";
|
|
133
|
-
case "url":
|
|
134
|
-
return "url";
|
|
135
|
-
default:
|
|
136
|
-
return "text";
|
|
137
|
-
}
|
|
138
|
-
})(),
|
|
139
|
-
inputMode: (() => {
|
|
140
|
-
switch (keyboardType) {
|
|
141
|
-
case "number-pad":
|
|
142
|
-
case "numeric":
|
|
143
|
-
return "numeric";
|
|
144
|
-
case "decimal-pad":
|
|
145
|
-
return "decimal";
|
|
146
|
-
case "email-address":
|
|
147
|
-
return "email";
|
|
148
|
-
case "phone-pad":
|
|
149
|
-
return "tel";
|
|
150
|
-
case "url":
|
|
151
|
-
return "url";
|
|
152
|
-
default:
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
})(),
|
|
156
|
-
style: {
|
|
157
|
-
...rest.style,
|
|
158
|
-
...(placeholderTextColor && {
|
|
159
|
-
"--placeholderColor": theme[placeholderTextColor]?.variable || placeholderTextColor
|
|
160
|
-
}),
|
|
161
|
-
...(selectionColor && {
|
|
162
|
-
"--selectionColor": theme[selectionColor]?.variable || selectionColor
|
|
163
|
-
})
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
return import_react.default.useEffect(() => {
|
|
167
|
-
if (id && !disabled) return (0, import_focusable.registerFocusable)(id, {
|
|
168
|
-
focusAndSelect: () => {
|
|
169
|
-
ref.current?.focus();
|
|
170
|
-
},
|
|
171
|
-
focus: () => {}
|
|
73
|
+
return node.addEventListener("select", handleSelectionChange), () => node.removeEventListener("select", handleSelectionChange);
|
|
74
|
+
}, [onSelectionChange]), import_react.default.useEffect(() => {
|
|
75
|
+
selection && ref.current && ref.current.setSelectionRange(selection.start, selection.end ?? selection.start);
|
|
76
|
+
}, [selection?.start, selection?.end]), import_react.default.useEffect(() => {
|
|
77
|
+
if (!(!id || disabled)) return (0, import_focusable.registerFocusable)(id, {
|
|
78
|
+
focusAndSelect: () => ref.current?.focus(),
|
|
79
|
+
focus: () => ref.current?.focus()
|
|
172
80
|
});
|
|
173
|
-
}, [id, disabled])
|
|
81
|
+
}, [id, disabled]);
|
|
82
|
+
const handleKeyDown = e => {
|
|
83
|
+
e.key === "Enter" && onSubmitEditing && onSubmitEditing({
|
|
84
|
+
nativeEvent: {
|
|
85
|
+
text: e.target.value
|
|
86
|
+
}
|
|
87
|
+
}), rest.onKeyDown?.(e);
|
|
88
|
+
},
|
|
89
|
+
handleChange = e => {
|
|
90
|
+
onChangeText?.(e.target.value), rest.onChange?.(e);
|
|
91
|
+
},
|
|
92
|
+
finalProps = {
|
|
93
|
+
...rest,
|
|
94
|
+
disabled,
|
|
95
|
+
id,
|
|
96
|
+
rows,
|
|
97
|
+
onKeyDown: onSubmitEditing ? handleKeyDown : rest.onKeyDown,
|
|
98
|
+
onChange: onChangeText ? handleChange : rest.onChange,
|
|
99
|
+
style: {
|
|
100
|
+
...rest.style,
|
|
101
|
+
...(placeholderTextColor && {
|
|
102
|
+
"--placeholderColor": theme[placeholderTextColor]?.variable || placeholderTextColor
|
|
103
|
+
}),
|
|
104
|
+
...(selectionColor && {
|
|
105
|
+
"--selectionColor": theme[selectionColor]?.variable || selectionColor
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
174
110
|
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)("style", {
|
|
175
111
|
children: `
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
`
|
|
112
|
+
input::selection, textarea::selection {
|
|
113
|
+
background-color: var(--selectionColor) !important;
|
|
114
|
+
}
|
|
115
|
+
input::placeholder, textarea::placeholder {
|
|
116
|
+
color: var(--placeholderColor) !important;
|
|
117
|
+
}
|
|
118
|
+
`
|
|
184
119
|
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(StyledInput, {
|
|
185
120
|
ref: composedRefs,
|
|
186
121
|
...finalProps
|
package/dist/cjs/Input.js
CHANGED
|
@@ -26,115 +26,56 @@ __export(Input_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(Input_exports);
|
|
28
28
|
var import_core = require("@tamagui/core"), import_focusable = require("@tamagui/focusable"), import_react = __toESM(require("react"), 1), import_shared = require("./shared"), import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
-
const StyledInput = (0, import_core.styled)(import_core.View, import_shared.styledBody[0], import_shared.styledBody[1]), Input = StyledInput.styleable((
|
|
29
|
+
const StyledInput = (0, import_core.styled)(import_core.View, import_shared.styledBody[0], import_shared.styledBody[1]), Input = StyledInput.styleable((props, forwardedRef) => {
|
|
30
30
|
const {
|
|
31
|
-
// some of destructed props are just to avoid passing them to ...rest because they are not in web.
|
|
32
|
-
allowFontScaling,
|
|
33
|
-
selectTextOnFocus,
|
|
34
|
-
showSoftInputOnFocus,
|
|
35
|
-
textContentType,
|
|
36
|
-
passwordRules,
|
|
37
|
-
textBreakStrategy,
|
|
38
|
-
underlineColorAndroid,
|
|
39
|
-
selection,
|
|
40
|
-
lineBreakStrategyIOS,
|
|
41
|
-
returnKeyLabel,
|
|
42
31
|
disabled,
|
|
43
|
-
onSubmitEditing,
|
|
44
|
-
caretHidden,
|
|
45
|
-
clearButtonMode,
|
|
46
|
-
clearTextOnFocus,
|
|
47
|
-
contextMenuHidden,
|
|
48
|
-
dataDetectorTypes,
|
|
49
32
|
id,
|
|
50
|
-
enablesReturnKeyAutomatically,
|
|
51
|
-
importantForAutofill,
|
|
52
|
-
inlineImageLeft,
|
|
53
|
-
inlineImagePadding,
|
|
54
|
-
inputAccessoryViewID,
|
|
55
|
-
keyboardAppearance,
|
|
56
|
-
keyboardType,
|
|
57
|
-
cursorColor,
|
|
58
|
-
disableFullscreenUI,
|
|
59
|
-
editable,
|
|
60
|
-
maxFontSizeMultiplier,
|
|
61
|
-
multiline,
|
|
62
|
-
numberOfLines,
|
|
63
33
|
onChangeText,
|
|
64
|
-
|
|
65
|
-
onEndEditing,
|
|
66
|
-
onScroll,
|
|
34
|
+
onSubmitEditing,
|
|
67
35
|
onSelectionChange,
|
|
68
|
-
|
|
36
|
+
selection,
|
|
69
37
|
placeholderTextColor,
|
|
70
|
-
blurOnSubmit,
|
|
71
|
-
enterKeyHint,
|
|
72
|
-
returnKeyType,
|
|
73
|
-
rejectResponderTermination,
|
|
74
|
-
scrollEnabled,
|
|
75
|
-
secureTextEntry,
|
|
76
38
|
selectionColor,
|
|
77
|
-
|
|
39
|
+
rows,
|
|
78
40
|
...rest
|
|
79
|
-
} =
|
|
80
|
-
const start = ref.current?.selectionStart ?? 0, end = ref.current?.selectionEnd ?? 0;
|
|
81
|
-
onSelectionChange?.({
|
|
82
|
-
nativeEvent: {
|
|
83
|
-
selection: {
|
|
84
|
-
end,
|
|
85
|
-
start
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
});
|
|
41
|
+
} = props, ref = import_react.default.useRef(null), theme = (0, import_core.useTheme)(), composedRefs = (0, import_core.useComposedRefs)(forwardedRef, ref);
|
|
90
42
|
import_react.default.useEffect(() => {
|
|
91
|
-
if (onSelectionChange)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
43
|
+
if (!onSelectionChange) return;
|
|
44
|
+
const node = ref.current;
|
|
45
|
+
if (!node) return;
|
|
46
|
+
const handleSelectionChange = () => {
|
|
47
|
+
onSelectionChange({
|
|
48
|
+
nativeEvent: {
|
|
49
|
+
selection: {
|
|
50
|
+
start: node.selectionStart ?? 0,
|
|
51
|
+
end: node.selectionEnd ?? 0
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
return node.addEventListener("select", handleSelectionChange), () => node.removeEventListener("select", handleSelectionChange);
|
|
57
|
+
}, [onSelectionChange]), import_react.default.useEffect(() => {
|
|
58
|
+
selection && ref.current && ref.current.setSelectionRange(selection.start, selection.end ?? selection.start);
|
|
59
|
+
}, [selection?.start, selection?.end]), import_react.default.useEffect(() => {
|
|
60
|
+
if (!(!id || disabled))
|
|
61
|
+
return (0, import_focusable.registerFocusable)(id, {
|
|
62
|
+
focusAndSelect: () => ref.current?.focus(),
|
|
63
|
+
focus: () => ref.current?.focus()
|
|
64
|
+
});
|
|
65
|
+
}, [id, disabled]);
|
|
66
|
+
const handleKeyDown = (e) => {
|
|
67
|
+
e.key === "Enter" && onSubmitEditing && onSubmitEditing({
|
|
68
|
+
nativeEvent: { text: e.target.value }
|
|
69
|
+
}), rest.onKeyDown?.(e);
|
|
70
|
+
}, handleChange = (e) => {
|
|
71
|
+
onChangeText?.(e.target.value), rest.onChange?.(e);
|
|
72
|
+
}, finalProps = {
|
|
99
73
|
...rest,
|
|
100
74
|
disabled,
|
|
101
|
-
caretColor,
|
|
102
75
|
id,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (secureTextEntry) return "password";
|
|
107
|
-
switch (keyboardType) {
|
|
108
|
-
case "number-pad":
|
|
109
|
-
case "numeric":
|
|
110
|
-
return "number";
|
|
111
|
-
case "email-address":
|
|
112
|
-
return "email";
|
|
113
|
-
case "phone-pad":
|
|
114
|
-
return "tel";
|
|
115
|
-
case "url":
|
|
116
|
-
return "url";
|
|
117
|
-
default:
|
|
118
|
-
return "text";
|
|
119
|
-
}
|
|
120
|
-
})(),
|
|
121
|
-
inputMode: (() => {
|
|
122
|
-
switch (keyboardType) {
|
|
123
|
-
case "number-pad":
|
|
124
|
-
case "numeric":
|
|
125
|
-
return "numeric";
|
|
126
|
-
case "decimal-pad":
|
|
127
|
-
return "decimal";
|
|
128
|
-
case "email-address":
|
|
129
|
-
return "email";
|
|
130
|
-
case "phone-pad":
|
|
131
|
-
return "tel";
|
|
132
|
-
case "url":
|
|
133
|
-
return "url";
|
|
134
|
-
default:
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
})(),
|
|
76
|
+
rows,
|
|
77
|
+
onKeyDown: onSubmitEditing ? handleKeyDown : rest.onKeyDown,
|
|
78
|
+
onChange: onChangeText ? handleChange : rest.onChange,
|
|
138
79
|
style: {
|
|
139
80
|
...rest.style,
|
|
140
81
|
...placeholderTextColor && {
|
|
@@ -145,25 +86,15 @@ const StyledInput = (0, import_core.styled)(import_core.View, import_shared.styl
|
|
|
145
86
|
}
|
|
146
87
|
}
|
|
147
88
|
};
|
|
148
|
-
return
|
|
149
|
-
if (id && !disabled)
|
|
150
|
-
return (0, import_focusable.registerFocusable)(id, {
|
|
151
|
-
focusAndSelect: () => {
|
|
152
|
-
ref.current?.focus();
|
|
153
|
-
},
|
|
154
|
-
focus: () => {
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
}, [id, disabled]), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
89
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
158
90
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { children: `
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
` }),
|
|
91
|
+
input::selection, textarea::selection {
|
|
92
|
+
background-color: var(--selectionColor) !important;
|
|
93
|
+
}
|
|
94
|
+
input::placeholder, textarea::placeholder {
|
|
95
|
+
color: var(--placeholderColor) !important;
|
|
96
|
+
}
|
|
97
|
+
` }),
|
|
167
98
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StyledInput, { ref: composedRefs, ...finalProps })
|
|
168
99
|
] });
|
|
169
100
|
});
|
package/dist/cjs/Input.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Input.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwD,0BACxD,mBAAkC,+BAClC,eAAkB,8BAClB,gBAA2B,qBAqGvB;AAlGJ,MAAM,kBAAc,oBAAO,kBAAM,yBAAW,CAAC,GAAG,yBAAW,CAAC,CAAC,GAMhD,QAAQ,YAAY,UAAsB,CAAC,OAAO,iBAAiB;AAC9E,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI,OAEE,MAAM,aAAAA,QAAM,OAAyB,IAAI,GACzC,YAAQ,sBAAS,GACjB,mBAAe,6BAAgB,cAAc,GAAG;AAGtD,eAAAA,QAAM,UAAU,MAAM;AACpB,QAAI,CAAC,kBAAmB;AAExB,UAAM,OAAO,IAAI;AACjB,QAAI,CAAC,KAAM;AAEX,UAAM,wBAAwB,MAAM;AAClC,wBAAkB;AAAA,QAChB,aAAa;AAAA,UACX,WAAW;AAAA,YACT,OAAO,KAAK,kBAAkB;AAAA,YAC9B,KAAK,KAAK,gBAAgB;AAAA,UAC5B;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAEA,gBAAK,iBAAiB,UAAU,qBAAqB,GAC9C,MAAM,KAAK,oBAAoB,UAAU,qBAAqB;AAAA,EACvE,GAAG,CAAC,iBAAiB,CAAC,GAGtB,aAAAA,QAAM,UAAU,MAAM;AACpB,IAAI,aAAa,IAAI,WACnB,IAAI,QAAQ,kBAAkB,UAAU,OAAO,UAAU,OAAO,UAAU,KAAK;AAAA,EAEnF,GAAG,CAAC,WAAW,OAAO,WAAW,GAAG,CAAC,GAGrC,aAAAA,QAAM,UAAU,MAAM;AACpB,QAAI,GAAC,MAAM;AACX,iBAAO,oCAAkB,IAAI;AAAA,QAC3B,gBAAgB,MAAM,IAAI,SAAS,MAAM;AAAA,QACzC,OAAO,MAAM,IAAI,SAAS,MAAM;AAAA,MAClC,CAAC;AAAA,EACH,GAAG,CAAC,IAAI,QAAQ,CAAC;AAGjB,QAAM,gBAAgB,CAAC,MAA6C;AAClE,IAAI,EAAE,QAAQ,WAAW,mBACvB,gBAAgB;AAAA,MACd,aAAa,EAAE,MAAO,EAAE,OAA4B,MAAM;AAAA,IAC5D,CAAC,GAEH,KAAK,YAAY,CAAC;AAAA,EACpB,GAGM,eAAe,CAAC,MAA2C;AAC/D,mBAAe,EAAE,OAAO,KAAK,GAC7B,KAAK,WAAW,CAAC;AAAA,EACnB,GAEM,aAAa;AAAA,IACjB,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW,kBAAkB,gBAAgB,KAAK;AAAA,IAClD,UAAU,eAAe,eAAe,KAAK;AAAA,IAC7C,OAAO;AAAA,MACL,GAAI,KAAK;AAAA,MACT,GAAI,wBAAwB;AAAA,QAC1B,sBACE,MAAM,oBAAoB,GAAG,YAAY;AAAA,MAC7C;AAAA,MACA,GAAI,kBAAkB;AAAA,QACpB,oBAAoB,MAAM,cAAc,GAAG,YAAY;AAAA,MACzD;AAAA,IACF;AAAA,EACF;AAEA,SACE,4EACE;AAAA,gDAAC,WACE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAQH;AAAA,IACA,4CAAC,eAAY,KAAK,cAAe,GAAG,YAAY;AAAA,KAClD;AAEJ,CAAC;",
|
|
5
5
|
"names": ["React"]
|
|
6
6
|
}
|
package/dist/cjs/Input.native.js
CHANGED
|
@@ -38,98 +38,160 @@ __export(Input_native_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(Input_native_exports);
|
|
39
39
|
var import_jsx_runtime = require("react/jsx-runtime"),
|
|
40
40
|
import_react = __toESM(require("react"), 1),
|
|
41
|
+
import_react_native = require("react-native"),
|
|
41
42
|
import_core = require("@tamagui/core"),
|
|
42
43
|
import_focusable = require("@tamagui/focusable"),
|
|
43
|
-
import_react_native = require("react-native"),
|
|
44
44
|
import_shared = require("./shared.native.js"),
|
|
45
45
|
StyledInput = (0, import_core.styled)(import_react_native.TextInput, import_shared.styledBody[0], import_shared.styledBody[1]),
|
|
46
|
-
Input = StyledInput.styleable(function (
|
|
47
|
-
var
|
|
48
|
-
|
|
46
|
+
Input = StyledInput.styleable(function (props, forwardedRef) {
|
|
47
|
+
var _theme_placeholderTextColor,
|
|
48
|
+
_theme_selectionColor,
|
|
49
|
+
{
|
|
50
|
+
// Web props we need to convert
|
|
49
51
|
type,
|
|
50
|
-
|
|
52
|
+
disabled,
|
|
53
|
+
readOnly,
|
|
54
|
+
id,
|
|
55
|
+
rows,
|
|
56
|
+
autoComplete,
|
|
57
|
+
enterKeyHint,
|
|
58
|
+
// Tamagui color props
|
|
59
|
+
placeholderTextColor,
|
|
60
|
+
selectionColor,
|
|
61
|
+
// Callbacks
|
|
62
|
+
onChange,
|
|
63
|
+
onInput,
|
|
64
|
+
onKeyDown,
|
|
65
|
+
onChangeText,
|
|
66
|
+
onSubmitEditing,
|
|
67
|
+
onSelectionChange,
|
|
68
|
+
selection,
|
|
69
|
+
// Web-only props to filter out
|
|
70
|
+
// @ts-ignore
|
|
51
71
|
dirname,
|
|
52
|
-
max,
|
|
53
72
|
min,
|
|
73
|
+
max,
|
|
54
74
|
minLength,
|
|
55
75
|
multiple,
|
|
56
76
|
name,
|
|
77
|
+
pattern,
|
|
57
78
|
required,
|
|
58
79
|
step,
|
|
59
|
-
disabled,
|
|
60
|
-
id,
|
|
61
|
-
caretColor,
|
|
62
|
-
onChange,
|
|
63
|
-
onInput,
|
|
64
|
-
rows,
|
|
65
|
-
enterKeyHint,
|
|
66
|
-
returnKeyType,
|
|
67
|
-
onKeyDown,
|
|
68
|
-
inputMode,
|
|
69
80
|
tag,
|
|
70
81
|
...rest
|
|
71
|
-
} =
|
|
82
|
+
} = props,
|
|
72
83
|
ref = import_react.default.useRef(null),
|
|
84
|
+
theme = (0, import_core.useTheme)(),
|
|
73
85
|
composedRefs = (0, import_core.useComposedRefs)(forwardedRef, ref),
|
|
74
86
|
secureTextEntry = !1,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
type: "input"
|
|
122
|
-
});
|
|
123
|
-
}), import_react.default.useEffect(function () {
|
|
124
|
-
if (id && !disabled) return (0, import_focusable.registerFocusable)(id, {
|
|
87
|
+
keyboardType = "default",
|
|
88
|
+
inputMode = void 0;
|
|
89
|
+
switch (type) {
|
|
90
|
+
case "password":
|
|
91
|
+
secureTextEntry = !0;
|
|
92
|
+
break;
|
|
93
|
+
case "email":
|
|
94
|
+
keyboardType = "email-address", inputMode = "email";
|
|
95
|
+
break;
|
|
96
|
+
case "tel":
|
|
97
|
+
keyboardType = "phone-pad", inputMode = "tel";
|
|
98
|
+
break;
|
|
99
|
+
case "number":
|
|
100
|
+
keyboardType = "numeric", inputMode = "numeric";
|
|
101
|
+
break;
|
|
102
|
+
case "url":
|
|
103
|
+
keyboardType = "url", inputMode = "url";
|
|
104
|
+
break;
|
|
105
|
+
case "search":
|
|
106
|
+
inputMode = "search";
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
var returnKeyType = void 0;
|
|
110
|
+
switch (enterKeyHint) {
|
|
111
|
+
case "done":
|
|
112
|
+
returnKeyType = "done";
|
|
113
|
+
break;
|
|
114
|
+
case "go":
|
|
115
|
+
returnKeyType = "go";
|
|
116
|
+
break;
|
|
117
|
+
case "next":
|
|
118
|
+
returnKeyType = "next";
|
|
119
|
+
break;
|
|
120
|
+
case "search":
|
|
121
|
+
returnKeyType = "search";
|
|
122
|
+
break;
|
|
123
|
+
case "send":
|
|
124
|
+
returnKeyType = "send";
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
var _theme_placeholderTextColor_val,
|
|
128
|
+
resolvedPlaceholderColor = placeholderTextColor ? (0, import_core.getTokenValue)((_theme_placeholderTextColor_val = (_theme_placeholderTextColor = theme[placeholderTextColor]) === null || _theme_placeholderTextColor === void 0 ? void 0 : _theme_placeholderTextColor.val) !== null && _theme_placeholderTextColor_val !== void 0 ? _theme_placeholderTextColor_val : placeholderTextColor, "color") : void 0,
|
|
129
|
+
_theme_selectionColor_val,
|
|
130
|
+
resolvedSelectionColor = selectionColor ? (0, import_core.getTokenValue)((_theme_selectionColor_val = (_theme_selectionColor = theme[selectionColor]) === null || _theme_selectionColor === void 0 ? void 0 : _theme_selectionColor.val) !== null && _theme_selectionColor_val !== void 0 ? _theme_selectionColor_val : selectionColor, "color") : void 0;
|
|
131
|
+
import_react.default.useEffect(function () {
|
|
132
|
+
if (!(!id || disabled)) return (0, import_focusable.registerFocusable)(id, {
|
|
125
133
|
focusAndSelect: function () {
|
|
126
134
|
var _ref_current;
|
|
127
|
-
(_ref_current = ref.current) === null || _ref_current === void 0
|
|
135
|
+
return (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.focus();
|
|
128
136
|
},
|
|
129
|
-
focus: function () {
|
|
137
|
+
focus: function () {
|
|
138
|
+
var _ref_current;
|
|
139
|
+
return (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.focus();
|
|
140
|
+
}
|
|
130
141
|
});
|
|
131
|
-
}, [id, disabled])
|
|
132
|
-
|
|
142
|
+
}, [id, disabled]);
|
|
143
|
+
var handleChangeText = function (text) {
|
|
144
|
+
onChangeText?.(text), onChange && onChange({
|
|
145
|
+
target: {
|
|
146
|
+
value: text
|
|
147
|
+
},
|
|
148
|
+
type: "change"
|
|
149
|
+
}), onInput && onInput({
|
|
150
|
+
target: {
|
|
151
|
+
value: text
|
|
152
|
+
},
|
|
153
|
+
type: "input"
|
|
154
|
+
});
|
|
155
|
+
},
|
|
156
|
+
handleKeyPress = function (e) {
|
|
157
|
+
if (onKeyDown) {
|
|
158
|
+
var {
|
|
159
|
+
key
|
|
160
|
+
} = e.nativeEvent;
|
|
161
|
+
(key === "Backspace" || key === "Enter" || key.length === 1) && onKeyDown({
|
|
162
|
+
key,
|
|
163
|
+
type: "keydown"
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
handleSubmitEditing = function (e) {
|
|
168
|
+
onKeyDown && onKeyDown({
|
|
169
|
+
key: "Enter",
|
|
170
|
+
type: "keydown"
|
|
171
|
+
}), onSubmitEditing && onSubmitEditing(e);
|
|
172
|
+
},
|
|
173
|
+
handleSelectionChange = function (e) {
|
|
174
|
+
onSelectionChange?.(e);
|
|
175
|
+
},
|
|
176
|
+
finalProps = {
|
|
177
|
+
...rest,
|
|
178
|
+
editable: !disabled && !readOnly,
|
|
179
|
+
secureTextEntry,
|
|
180
|
+
keyboardType,
|
|
181
|
+
inputMode,
|
|
182
|
+
returnKeyType,
|
|
183
|
+
multiline: tag === "textarea" || rows && rows > 1,
|
|
184
|
+
numberOfLines: rows,
|
|
185
|
+
selection,
|
|
186
|
+
placeholderTextColor: resolvedPlaceholderColor,
|
|
187
|
+
selectionColor: resolvedSelectionColor,
|
|
188
|
+
onChangeText: handleChangeText,
|
|
189
|
+
onKeyPress: onKeyDown ? handleKeyPress : void 0,
|
|
190
|
+
onSubmitEditing: onKeyDown || onSubmitEditing ? handleSubmitEditing : void 0,
|
|
191
|
+
onSelectionChange: onSelectionChange ? handleSelectionChange : void 0,
|
|
192
|
+
autoComplete
|
|
193
|
+
};
|
|
194
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(StyledInput, {
|
|
133
195
|
ref: composedRefs,
|
|
134
196
|
...finalProps
|
|
135
197
|
});
|