@tamagui/input 1.143.1 → 2.0.0-1767740890268
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/cjs/v1/Input.cjs +190 -0
- package/dist/cjs/v1/Input.js +171 -0
- package/dist/cjs/v1/Input.js.map +6 -0
- package/dist/cjs/v1/Input.native.js +138 -0
- package/dist/cjs/v1/Input.native.js.map +1 -0
- package/dist/cjs/v1/TextArea.cjs +50 -0
- package/dist/cjs/v1/TextArea.js +43 -0
- package/dist/cjs/v1/TextArea.js.map +6 -0
- package/dist/cjs/v1/TextArea.native.js +53 -0
- package/dist/cjs/v1/TextArea.native.js.map +1 -0
- package/dist/cjs/v1/index.cjs +19 -0
- package/dist/cjs/v1/index.js +16 -0
- package/dist/cjs/v1/index.js.map +6 -0
- package/dist/cjs/v1/index.native.js +22 -0
- package/dist/cjs/v1/index.native.js.map +1 -0
- package/dist/cjs/v1/types.cjs +16 -0
- package/dist/cjs/v1/types.js +14 -0
- package/dist/cjs/v1/types.js.map +6 -0
- package/dist/cjs/v1/types.native.js +19 -0
- package/dist/cjs/v1/types.native.js.map +1 -0
- 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/esm/v1/Input.js +151 -0
- package/dist/esm/v1/Input.js.map +6 -0
- package/dist/esm/v1/Input.mjs +156 -0
- package/dist/esm/v1/Input.mjs.map +1 -0
- package/dist/esm/v1/Input.native.js +101 -0
- package/dist/esm/v1/Input.native.js.map +1 -0
- package/dist/esm/v1/TextArea.js +29 -0
- package/dist/esm/v1/TextArea.js.map +6 -0
- package/dist/esm/v1/TextArea.mjs +27 -0
- package/dist/esm/v1/TextArea.mjs.map +1 -0
- package/dist/esm/v1/TextArea.native.js +27 -0
- package/dist/esm/v1/TextArea.native.js.map +1 -0
- package/dist/esm/v1/index.js +3 -0
- package/dist/esm/v1/index.js.map +6 -0
- package/dist/esm/v1/index.mjs +3 -0
- package/dist/esm/v1/index.mjs.map +1 -0
- package/dist/esm/v1/index.native.js +3 -0
- package/dist/esm/v1/index.native.js.map +1 -0
- package/dist/esm/v1/types.js +1 -0
- package/dist/esm/v1/types.js.map +6 -0
- package/dist/esm/v1/types.mjs +2 -0
- package/dist/esm/v1/types.mjs.map +1 -0
- package/dist/esm/v1/types.native.js +2 -0
- package/dist/esm/v1/types.native.js.map +1 -0
- 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/dist/jsx/v1/Input.js +151 -0
- package/dist/jsx/v1/Input.js.map +6 -0
- package/dist/jsx/v1/Input.mjs +156 -0
- package/dist/jsx/v1/Input.mjs.map +1 -0
- package/dist/jsx/v1/Input.native.js +138 -0
- package/dist/jsx/v1/Input.native.js.map +1 -0
- package/dist/jsx/v1/TextArea.js +29 -0
- package/dist/jsx/v1/TextArea.js.map +6 -0
- package/dist/jsx/v1/TextArea.mjs +27 -0
- package/dist/jsx/v1/TextArea.mjs.map +1 -0
- package/dist/jsx/v1/TextArea.native.js +53 -0
- package/dist/jsx/v1/TextArea.native.js.map +1 -0
- package/dist/jsx/v1/index.js +3 -0
- package/dist/jsx/v1/index.js.map +6 -0
- package/dist/jsx/v1/index.mjs +3 -0
- package/dist/jsx/v1/index.mjs.map +1 -0
- package/dist/jsx/v1/index.native.js +22 -0
- package/dist/jsx/v1/index.native.js.map +1 -0
- package/dist/jsx/v1/types.js +1 -0
- package/dist/jsx/v1/types.js.map +6 -0
- package/dist/jsx/v1/types.mjs +2 -0
- package/dist/jsx/v1/types.mjs.map +1 -0
- package/dist/jsx/v1/types.native.js +19 -0
- package/dist/jsx/v1/types.native.js.map +1 -0
- 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.d.ts.map +1 -0
- package/types/v1/Input.native.d.ts +114 -0
- package/types/v1/Input.native.d.ts.map +1 -0
- package/types/v1/TextArea.d.ts +98 -0
- package/types/v1/TextArea.d.ts.map +1 -0
- package/types/v1/index.d.ts +4 -0
- package/types/v1/index.d.ts.map +1 -0
- package/types/v1/types.d.ts +39 -0
- package/types/v1/types.d.ts.map +1 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { styled, useComposedRefs } from '@tamagui/core'
|
|
3
|
+
import { registerFocusable } from '@tamagui/focusable'
|
|
4
|
+
|
|
5
|
+
import type { NativeSyntheticEvent, TextInputChangeEventData } from 'react-native'
|
|
6
|
+
import { TextInput } from 'react-native'
|
|
7
|
+
import { styledBody } from '../shared'
|
|
8
|
+
import type { InputProps } from './types'
|
|
9
|
+
|
|
10
|
+
const StyledInput = styled(TextInput, styledBody[0], styledBody[1])
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Use the new Input from '@tamagui/input' instead
|
|
14
|
+
*/
|
|
15
|
+
export const Input = StyledInput.styleable<InputProps>((inProps, forwardedRef) => {
|
|
16
|
+
const {
|
|
17
|
+
// some of destructed props are just to avoid passing them to ...rest because they are not in native.
|
|
18
|
+
type,
|
|
19
|
+
//@ts-ignore
|
|
20
|
+
dirname,
|
|
21
|
+
max,
|
|
22
|
+
min,
|
|
23
|
+
minLength,
|
|
24
|
+
multiple,
|
|
25
|
+
name,
|
|
26
|
+
required,
|
|
27
|
+
step,
|
|
28
|
+
disabled,
|
|
29
|
+
id,
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
caretColor,
|
|
32
|
+
onChange,
|
|
33
|
+
onInput,
|
|
34
|
+
rows,
|
|
35
|
+
enterKeyHint,
|
|
36
|
+
returnKeyType,
|
|
37
|
+
onKeyDown,
|
|
38
|
+
inputMode,
|
|
39
|
+
tag,
|
|
40
|
+
...rest
|
|
41
|
+
} = inProps
|
|
42
|
+
|
|
43
|
+
const ref = React.useRef<HTMLInputElement>(null)
|
|
44
|
+
|
|
45
|
+
const composedRefs = useComposedRefs<any>(forwardedRef, ref)
|
|
46
|
+
|
|
47
|
+
// TODO: later move most of the logic to the core package
|
|
48
|
+
|
|
49
|
+
let secureTextEntry = false
|
|
50
|
+
let cursorColor = caretColor
|
|
51
|
+
let _returnKeyType = returnKeyType
|
|
52
|
+
let _enterKeyHint = enterKeyHint
|
|
53
|
+
if (enterKeyHint === 'go') {
|
|
54
|
+
_returnKeyType = 'go'
|
|
55
|
+
_enterKeyHint = undefined
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let _inputMode = inputMode
|
|
59
|
+
if (type === 'email') {
|
|
60
|
+
_inputMode = 'email'
|
|
61
|
+
} else if (type === 'tel') {
|
|
62
|
+
_inputMode = 'tel'
|
|
63
|
+
} else if (type === 'search') {
|
|
64
|
+
_inputMode = 'search'
|
|
65
|
+
} else if (type === 'url') {
|
|
66
|
+
_inputMode = 'url'
|
|
67
|
+
} else if (type === 'password') {
|
|
68
|
+
secureTextEntry = true
|
|
69
|
+
_inputMode = 'text'
|
|
70
|
+
} else if (type === 'number') {
|
|
71
|
+
_inputMode = 'numeric'
|
|
72
|
+
} else {
|
|
73
|
+
_inputMode = 'text'
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let showSoftInputOnFocus = true
|
|
77
|
+
if (inputMode === 'none') {
|
|
78
|
+
showSoftInputOnFocus = false
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const finalProps = {
|
|
82
|
+
...rest,
|
|
83
|
+
inputMode: _inputMode,
|
|
84
|
+
showSoftInputOnFocus,
|
|
85
|
+
disabled,
|
|
86
|
+
id,
|
|
87
|
+
cursorColor,
|
|
88
|
+
enterKeyHint: _enterKeyHint,
|
|
89
|
+
returnKeyType: _returnKeyType,
|
|
90
|
+
secureTextEntry,
|
|
91
|
+
numberOfLines: rows || rest.numberOfLines,
|
|
92
|
+
} as any
|
|
93
|
+
|
|
94
|
+
if (tag === 'textarea') {
|
|
95
|
+
finalProps.multiline = true
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (onKeyDown) {
|
|
99
|
+
finalProps.onKeyPress = (e) => {
|
|
100
|
+
const { key } = e.nativeEvent
|
|
101
|
+
if (
|
|
102
|
+
key === 'Backspace' ||
|
|
103
|
+
(tag === 'textarea' && key === 'Enter') ||
|
|
104
|
+
key.length === 1
|
|
105
|
+
) {
|
|
106
|
+
onKeyDown({
|
|
107
|
+
key,
|
|
108
|
+
type: 'keydown',
|
|
109
|
+
} as any)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
finalProps.onSubmitEditing = (e) => {
|
|
113
|
+
onKeyDown({
|
|
114
|
+
key: 'Enter',
|
|
115
|
+
type: 'keydown',
|
|
116
|
+
} as any)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (onChange || onInput) {
|
|
121
|
+
finalProps.onChange = (e: NativeSyntheticEvent<TextInputChangeEventData>) => {
|
|
122
|
+
const { text } = e.nativeEvent
|
|
123
|
+
if (onChange) {
|
|
124
|
+
onChange({
|
|
125
|
+
target: {
|
|
126
|
+
value: text,
|
|
127
|
+
},
|
|
128
|
+
type: 'change',
|
|
129
|
+
} as any)
|
|
130
|
+
}
|
|
131
|
+
if (onInput != null) {
|
|
132
|
+
onInput({
|
|
133
|
+
target: {
|
|
134
|
+
value: text,
|
|
135
|
+
},
|
|
136
|
+
type: 'input',
|
|
137
|
+
} as any)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
React.useEffect(() => {
|
|
143
|
+
if (!id) return
|
|
144
|
+
if (disabled) return
|
|
145
|
+
|
|
146
|
+
return registerFocusable(id, {
|
|
147
|
+
focusAndSelect: () => {
|
|
148
|
+
ref.current?.focus()
|
|
149
|
+
},
|
|
150
|
+
focus: () => {},
|
|
151
|
+
})
|
|
152
|
+
}, [id, disabled])
|
|
153
|
+
return <StyledInput onChange={(e) => {}} ref={composedRefs} {...finalProps} />
|
|
154
|
+
})
|
package/src/v1/Input.tsx
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { View, styled, useComposedRefs, useEvent, useTheme } from '@tamagui/core'
|
|
2
|
+
import { registerFocusable } from '@tamagui/focusable'
|
|
3
|
+
import React, { type HTMLAttributes, type HTMLInputTypeAttribute } from 'react'
|
|
4
|
+
import { styledBody } from '../shared'
|
|
5
|
+
import type { InputProps } from './types'
|
|
6
|
+
|
|
7
|
+
const StyledInput = styled(View, styledBody[0], styledBody[1])
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use the new Input from '@tamagui/input' instead
|
|
11
|
+
* @summary An input is a text field that allows users to enter text.
|
|
12
|
+
* @see — Docs https://tamagui.dev/ui/inputs#input
|
|
13
|
+
*/
|
|
14
|
+
export const Input = StyledInput.styleable<InputProps>((inProps, forwardedRef) => {
|
|
15
|
+
const {
|
|
16
|
+
// some of destructed props are just to avoid passing them to ...rest because they are not in web.
|
|
17
|
+
allowFontScaling,
|
|
18
|
+
selectTextOnFocus,
|
|
19
|
+
showSoftInputOnFocus,
|
|
20
|
+
textContentType,
|
|
21
|
+
passwordRules,
|
|
22
|
+
textBreakStrategy,
|
|
23
|
+
underlineColorAndroid,
|
|
24
|
+
selection,
|
|
25
|
+
lineBreakStrategyIOS,
|
|
26
|
+
returnKeyLabel,
|
|
27
|
+
disabled,
|
|
28
|
+
onSubmitEditing,
|
|
29
|
+
caretHidden,
|
|
30
|
+
clearButtonMode,
|
|
31
|
+
clearTextOnFocus,
|
|
32
|
+
contextMenuHidden,
|
|
33
|
+
dataDetectorTypes,
|
|
34
|
+
id,
|
|
35
|
+
enablesReturnKeyAutomatically,
|
|
36
|
+
importantForAutofill,
|
|
37
|
+
inlineImageLeft,
|
|
38
|
+
inlineImagePadding,
|
|
39
|
+
inputAccessoryViewID,
|
|
40
|
+
keyboardAppearance,
|
|
41
|
+
keyboardType,
|
|
42
|
+
cursorColor,
|
|
43
|
+
disableFullscreenUI,
|
|
44
|
+
editable,
|
|
45
|
+
maxFontSizeMultiplier,
|
|
46
|
+
multiline,
|
|
47
|
+
numberOfLines,
|
|
48
|
+
onChangeText,
|
|
49
|
+
onContentSizeChange,
|
|
50
|
+
onEndEditing,
|
|
51
|
+
onScroll,
|
|
52
|
+
onSelectionChange,
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
caretColor,
|
|
55
|
+
placeholderTextColor,
|
|
56
|
+
blurOnSubmit,
|
|
57
|
+
enterKeyHint,
|
|
58
|
+
returnKeyType,
|
|
59
|
+
rejectResponderTermination,
|
|
60
|
+
scrollEnabled,
|
|
61
|
+
secureTextEntry,
|
|
62
|
+
selectionColor,
|
|
63
|
+
inputMode,
|
|
64
|
+
...rest
|
|
65
|
+
} = inProps
|
|
66
|
+
|
|
67
|
+
const ref = React.useRef<HTMLInputElement>(null)
|
|
68
|
+
const theme = useTheme()
|
|
69
|
+
|
|
70
|
+
const composedRefs = useComposedRefs(forwardedRef, ref)
|
|
71
|
+
|
|
72
|
+
const _onSelectionChange = useEvent(() => {
|
|
73
|
+
const start = ref.current?.selectionStart ?? 0
|
|
74
|
+
const end = ref.current?.selectionEnd ?? 0
|
|
75
|
+
onSelectionChange?.({
|
|
76
|
+
nativeEvent: {
|
|
77
|
+
selection: {
|
|
78
|
+
end,
|
|
79
|
+
start,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
} as any)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
React.useEffect(() => {
|
|
86
|
+
if (onSelectionChange) {
|
|
87
|
+
ref.current?.addEventListener('selectionchange', _onSelectionChange)
|
|
88
|
+
return () => {
|
|
89
|
+
ref.current?.removeEventListener('selectionchange', _onSelectionChange)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, [])
|
|
93
|
+
|
|
94
|
+
React.useEffect(() => {
|
|
95
|
+
if (selection) {
|
|
96
|
+
ref.current?.setSelectionRange(selection.start || null, selection.end || null)
|
|
97
|
+
}
|
|
98
|
+
}, [selection?.start, selection?.end])
|
|
99
|
+
|
|
100
|
+
const finalProps = {
|
|
101
|
+
...rest,
|
|
102
|
+
disabled,
|
|
103
|
+
caretColor,
|
|
104
|
+
id,
|
|
105
|
+
enterKeyHint,
|
|
106
|
+
...(process.env.TAMAGUI_TARGET === 'web'
|
|
107
|
+
? {
|
|
108
|
+
type: (() => {
|
|
109
|
+
if (rest?.type) return rest.type
|
|
110
|
+
if (secureTextEntry) return 'password'
|
|
111
|
+
switch (keyboardType) {
|
|
112
|
+
case 'number-pad':
|
|
113
|
+
case 'numeric':
|
|
114
|
+
return 'number'
|
|
115
|
+
case 'email-address':
|
|
116
|
+
return 'email'
|
|
117
|
+
case 'phone-pad':
|
|
118
|
+
return 'tel'
|
|
119
|
+
case 'url':
|
|
120
|
+
return 'url'
|
|
121
|
+
default:
|
|
122
|
+
return 'text'
|
|
123
|
+
}
|
|
124
|
+
})() satisfies HTMLInputTypeAttribute,
|
|
125
|
+
inputMode: (() => {
|
|
126
|
+
switch (keyboardType) {
|
|
127
|
+
case 'number-pad':
|
|
128
|
+
case 'numeric':
|
|
129
|
+
return 'numeric'
|
|
130
|
+
case 'decimal-pad':
|
|
131
|
+
return 'decimal'
|
|
132
|
+
case 'email-address':
|
|
133
|
+
return 'email'
|
|
134
|
+
case 'phone-pad':
|
|
135
|
+
return 'tel'
|
|
136
|
+
case 'url':
|
|
137
|
+
return 'url'
|
|
138
|
+
default:
|
|
139
|
+
return undefined
|
|
140
|
+
}
|
|
141
|
+
})() satisfies HTMLAttributes<HTMLInputElement>['inputMode'],
|
|
142
|
+
}
|
|
143
|
+
: {
|
|
144
|
+
keyboardType,
|
|
145
|
+
secureTextEntry,
|
|
146
|
+
inputMode,
|
|
147
|
+
}),
|
|
148
|
+
style: {
|
|
149
|
+
...(rest.style as any),
|
|
150
|
+
...(placeholderTextColor && {
|
|
151
|
+
'--placeholderColor':
|
|
152
|
+
theme[placeholderTextColor]?.variable || placeholderTextColor,
|
|
153
|
+
}),
|
|
154
|
+
...(selectionColor && {
|
|
155
|
+
'--selectionColor': theme[selectionColor]?.variable || selectionColor,
|
|
156
|
+
}),
|
|
157
|
+
},
|
|
158
|
+
} as any
|
|
159
|
+
|
|
160
|
+
React.useEffect(() => {
|
|
161
|
+
if (!id) return
|
|
162
|
+
if (disabled) return
|
|
163
|
+
|
|
164
|
+
return registerFocusable(id, {
|
|
165
|
+
focusAndSelect: () => {
|
|
166
|
+
ref.current?.focus()
|
|
167
|
+
},
|
|
168
|
+
focus: () => {},
|
|
169
|
+
})
|
|
170
|
+
}, [id, disabled])
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<>
|
|
174
|
+
{process.env.TAMAGUI_TARGET === 'web' && (
|
|
175
|
+
<style>
|
|
176
|
+
{`
|
|
177
|
+
input::selection, textarea::selection {
|
|
178
|
+
background-color: var(--selectionBackground) !important;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
input::placeholder, textarea::placeholder {
|
|
182
|
+
color: var(--placeholderColor) !important;
|
|
183
|
+
}
|
|
184
|
+
`}
|
|
185
|
+
</style>
|
|
186
|
+
)}
|
|
187
|
+
|
|
188
|
+
<StyledInput ref={composedRefs} {...finalProps} />
|
|
189
|
+
</>
|
|
190
|
+
)
|
|
191
|
+
})
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { styled } from '@tamagui/web'
|
|
2
|
+
import { Input } from './Input'
|
|
3
|
+
import { defaultStyles, textAreaSizeVariant } from '../shared'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use the new TextArea from '@tamagui/input' instead
|
|
7
|
+
* @summary A text area is a multi-line input field that allows users to enter text.
|
|
8
|
+
* @see — Docs https://tamagui.dev/ui/inputs#textarea
|
|
9
|
+
*/
|
|
10
|
+
export const TextArea = styled(Input, {
|
|
11
|
+
name: 'TextArea',
|
|
12
|
+
tag: 'textarea',
|
|
13
|
+
|
|
14
|
+
// this attribute fixes firefox newline issue
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
whiteSpace: 'pre-wrap',
|
|
17
|
+
|
|
18
|
+
variants: {
|
|
19
|
+
unstyled: {
|
|
20
|
+
false: {
|
|
21
|
+
height: 'auto',
|
|
22
|
+
...defaultStyles,
|
|
23
|
+
numberOfLines: 3,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
size: {
|
|
28
|
+
'...size': textAreaSizeVariant,
|
|
29
|
+
},
|
|
30
|
+
} as const,
|
|
31
|
+
|
|
32
|
+
defaultVariants: {
|
|
33
|
+
unstyled: process.env.TAMAGUI_HEADLESS === '1',
|
|
34
|
+
},
|
|
35
|
+
})
|
package/src/v1/index.ts
ADDED
package/src/v1/types.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ColorTokens,
|
|
3
|
+
StackProps,
|
|
4
|
+
TamaguiComponentPropsBase,
|
|
5
|
+
TextProps,
|
|
6
|
+
} from '@tamagui/web'
|
|
7
|
+
import type { TextInputProps, InputModeOptions } from 'react-native'
|
|
8
|
+
|
|
9
|
+
type DetailedInputProps = React.DetailedHTMLProps<
|
|
10
|
+
React.HTMLProps<HTMLInputElement>,
|
|
11
|
+
HTMLInputElement
|
|
12
|
+
>
|
|
13
|
+
|
|
14
|
+
export type InputProps = StackProps &
|
|
15
|
+
Omit<
|
|
16
|
+
DetailedInputProps,
|
|
17
|
+
'className' | 'children' | 'value' | 'size' | keyof StackProps
|
|
18
|
+
> &
|
|
19
|
+
Pick<TextProps, 'color'> &
|
|
20
|
+
Omit<DetailedInputProps['style'], 'color'> &
|
|
21
|
+
Omit<
|
|
22
|
+
TextInputProps,
|
|
23
|
+
| 'inputMode'
|
|
24
|
+
| 'secureTextEntry'
|
|
25
|
+
| 'onChangeText'
|
|
26
|
+
| 'editable'
|
|
27
|
+
| 'enterKeyHint'
|
|
28
|
+
| 'keyboardType'
|
|
29
|
+
| 'placeholderTextColor'
|
|
30
|
+
| 'selectionColor'
|
|
31
|
+
| 'numberOfLines'
|
|
32
|
+
> & {
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated - use `type="password"` instead
|
|
35
|
+
*/
|
|
36
|
+
secureTextEntry?: TextInputProps['secureTextEntry']
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated - use `onChange` instead
|
|
39
|
+
*/
|
|
40
|
+
onChangeText?: TextInputProps['onChangeText']
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated - use `readOnly` instead
|
|
43
|
+
*/
|
|
44
|
+
editable?: TextInputProps['editable']
|
|
45
|
+
enterKeyHint?: 'done' | 'go' | 'next' | 'search' | 'send' | 'enter' | 'previous'
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated - use `type` instead
|
|
48
|
+
*/
|
|
49
|
+
keyboardType?: TextInputProps['keyboardType']
|
|
50
|
+
/**
|
|
51
|
+
* use `type` instead of inputMode for most cases, use `inputMode="none"` to disable the soft keyboard
|
|
52
|
+
*/
|
|
53
|
+
inputMode?: InputModeOptions
|
|
54
|
+
placeholderTextColor?: ColorTokens
|
|
55
|
+
selectionColor?: ColorTokens
|
|
56
|
+
tag?: TamaguiComponentPropsBase['tag']
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated - use `tag='textarea'` instead
|
|
59
|
+
*/
|
|
60
|
+
multiline?: boolean
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated - use `rows` instead
|
|
63
|
+
*/
|
|
64
|
+
numberOfLines?: number
|
|
65
|
+
}
|
package/types/Input.d.ts
CHANGED
|
@@ -1,36 +1,62 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* A web-aligned input component.
|
|
4
4
|
* @see — Docs https://tamagui.dev/ui/inputs#input
|
|
5
5
|
*/
|
|
6
6
|
export declare const Input: import("@tamagui/core").TamaguiComponent<Omit<import("@tamagui/core").GetFinalProps<import("@tamagui/core").RNTamaguiViewNonStyleProps, import("@tamagui/core").StackStyleBase, {
|
|
7
7
|
size?: import("@tamagui/core").SizeTokens | undefined;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
9
|
unstyled?: boolean | undefined;
|
|
10
|
-
}>, "
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
enterKeyHint?: "done" | "go" | "next" | "search" | "send" | "enter" | "previous";
|
|
15
|
-
keyboardType?: import("react-native").TextInputProps["keyboardType"];
|
|
16
|
-
inputMode?: import("react-native").InputModeOptions;
|
|
10
|
+
}>, "color" | `$${string}` | `$${number}` | import("@tamagui/core").GroupMediaKeys | `$theme-${string}` | `$theme-${number}` | "rel" | "dir" | "selectionColor" | "fontFamily" | "fontSize" | "list" | "max" | "min" | "form" | "slot" | "title" | "hidden" | "name" | "accept" | "alt" | "autoComplete" | "capture" | "checked" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "maxLength" | "minLength" | "multiple" | "pattern" | "placeholder" | "readOnly" | "required" | "src" | "step" | "type" | "value" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "contentEditable" | "contextMenu" | "draggable" | "enterKeyHint" | "lang" | "nonce" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "popover" | "popoverTargetAction" | "popoverTarget" | "inert" | "inputMode" | "is" | "exportparts" | "part" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-dropeffect" | "aria-errormessage" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-invalid" | "aria-keyshortcuts" | "aria-level" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-setsize" | "aria-sort" | "onCopyCapture" | "onCutCapture" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlurCapture" | "onChangeCapture" | "onBeforeInputCapture" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenuCapture" | "onDoubleClickCapture" | "onDragCapture" | "onDragEndCapture" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeaveCapture" | "onDragOverCapture" | "onDragStartCapture" | "onDropCapture" | "onMouseDownCapture" | "onMouseMoveCapture" | "onMouseOutCapture" | "onMouseOverCapture" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancelCapture" | "onTouchMoveCapture" | "onTouchStartCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScrollCapture" | "onScrollEnd" | "onScrollEndCapture" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onToggle" | "onBeforeToggle" | "onTransitionCancel" | "onTransitionCancelCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "onTransitionRun" | "onTransitionRunCapture" | "onTransitionStart" | "onTransitionStartCapture" | "placeholderTextColor" | keyof import("@tamagui/core").StackStyleBase | keyof import("@tamagui/core").WithPseudoProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStyleBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStyleBase>>> | "onChangeText" | "onSelectionChange" | "onSubmitEditing" | "selection" | "keyboardAppearance" | keyof import("@tamagui/core").StackNonStyleProps | "rows"> & import("@tamagui/core").StackNonStyleProps & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStyleBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStyleBase>> & import("@tamagui/core").WithPseudoProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStyleBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStyleBase>>> & import("@tamagui/core").WithMediaProps<import("@tamagui/core").WithThemeShorthandsAndPseudos<import("@tamagui/core").StackStyleBase, {}>> & Omit<React.InputHTMLAttributes<HTMLInputElement>, "color" | "size" | "children" | "style" | "className"> & Pick<import("@tamagui/core").TextProps, "color"> & {
|
|
11
|
+
fontSize?: import("@tamagui/core").FontSizeTokens | number;
|
|
12
|
+
fontFamily?: import("@tamagui/core").FontTokens;
|
|
13
|
+
rows?: number;
|
|
17
14
|
placeholderTextColor?: import("@tamagui/core").ColorTokens;
|
|
18
15
|
selectionColor?: import("@tamagui/core").ColorTokens;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
onChangeText?: (text: string) => void;
|
|
17
|
+
onSubmitEditing?: (e: {
|
|
18
|
+
nativeEvent: {
|
|
19
|
+
text: string;
|
|
20
|
+
};
|
|
21
|
+
}) => void;
|
|
22
|
+
selection?: {
|
|
23
|
+
start: number;
|
|
24
|
+
end?: number;
|
|
25
|
+
};
|
|
26
|
+
onSelectionChange?: (e: {
|
|
27
|
+
nativeEvent: {
|
|
28
|
+
selection: {
|
|
29
|
+
start: number;
|
|
30
|
+
end: number;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
}) => void;
|
|
34
|
+
keyboardAppearance?: "default" | "light" | "dark";
|
|
35
|
+
}, import("@tamagui/core").TamaguiElement, import("@tamagui/core").RNTamaguiViewNonStyleProps & import("@tamagui/core").StackNonStyleProps & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStyleBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStyleBase>> & import("@tamagui/core").WithPseudoProps<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStyleBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStyleBase>>> & import("@tamagui/core").WithMediaProps<import("@tamagui/core").WithThemeShorthandsAndPseudos<import("@tamagui/core").StackStyleBase, {}>> & Omit<React.InputHTMLAttributes<HTMLInputElement>, "color" | "size" | "children" | "style" | "className"> & Pick<import("@tamagui/core").TextProps, "color"> & {
|
|
36
|
+
fontSize?: import("@tamagui/core").FontSizeTokens | number;
|
|
37
|
+
fontFamily?: import("@tamagui/core").FontTokens;
|
|
38
|
+
rows?: number;
|
|
29
39
|
placeholderTextColor?: import("@tamagui/core").ColorTokens;
|
|
30
40
|
selectionColor?: import("@tamagui/core").ColorTokens;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
onChangeText?: (text: string) => void;
|
|
42
|
+
onSubmitEditing?: (e: {
|
|
43
|
+
nativeEvent: {
|
|
44
|
+
text: string;
|
|
45
|
+
};
|
|
46
|
+
}) => void;
|
|
47
|
+
selection?: {
|
|
48
|
+
start: number;
|
|
49
|
+
end?: number;
|
|
50
|
+
};
|
|
51
|
+
onSelectionChange?: (e: {
|
|
52
|
+
nativeEvent: {
|
|
53
|
+
selection: {
|
|
54
|
+
start: number;
|
|
55
|
+
end: number;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
}) => void;
|
|
59
|
+
keyboardAppearance?: "default" | "light" | "dark";
|
|
34
60
|
}, import("@tamagui/core").StackStyleBase, {
|
|
35
61
|
size?: import("@tamagui/core").SizeTokens | undefined;
|
|
36
62
|
disabled?: boolean | undefined;
|
package/types/Input.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../src/Input.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../src/Input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB;;;GAGG;AACH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;WAgDD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;WAAD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0DhB,CAAA"}
|