@startupjs-ui/text-input 0.3.1 → 0.3.5
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/CHANGELOG.md +16 -0
- package/README.mdx +10 -1
- package/index.cssx.styl +3 -1
- package/index.tsx +33 -3
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.3.5](https://github.com/startupjs/startupjs-ui/compare/v0.3.4...v0.3.5) (2026-06-19)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @startupjs-ui/text-input
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.3.4](https://github.com/startupjs/startupjs-ui/compare/v0.3.3...v0.3.4) (2026-06-18)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @startupjs-ui/text-input
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [0.3.1](https://github.com/startupjs/startupjs-ui/compare/v0.3.0...v0.3.1) (2026-06-08)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @startupjs-ui/text-input
|
package/README.mdx
CHANGED
|
@@ -3,7 +3,7 @@ import TextInput, { _PropsJsonSchema as TextInputPropsJsonSchema } from './index
|
|
|
3
3
|
import Div from '@startupjs-ui/div'
|
|
4
4
|
import Br from '@startupjs-ui/br'
|
|
5
5
|
import { faSearch } from '@fortawesome/free-solid-svg-icons/faSearch'
|
|
6
|
-
import { faTimesCircle } from '@fortawesome/free-solid-svg-icons
|
|
6
|
+
import { faTimesCircle } from '@fortawesome/free-solid-svg-icons'
|
|
7
7
|
import { Sandbox } from '@startupjs-ui/docs'
|
|
8
8
|
import './index.mdx.cssx.styl'
|
|
9
9
|
|
|
@@ -122,6 +122,15 @@ return (
|
|
|
122
122
|
)
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
+
## Custom styles and theme configuration
|
|
126
|
+
|
|
127
|
+
Use `style` for the wrapper, `inputStyle` for the underlying input element, `iconStyle` for the primary icon, and `secondaryIconStyle` for the secondary icon.
|
|
128
|
+
|
|
129
|
+
TextInput also exposes CSSX theme configuration for app-wide visual tuning:
|
|
130
|
+
|
|
131
|
+
- **$UI.TextInput.iconColor** -- default icon color. It uses `var(--color-text-secondary)` by default.
|
|
132
|
+
- **$UI.TextInput.lineHeights** -- optional per-size line heights. When both `heights[size]` and `lineHeights[size]` are numeric, TextInput uses them to calculate vertical padding and multiline height.
|
|
133
|
+
|
|
125
134
|
## Number of lines
|
|
126
135
|
|
|
127
136
|
Pass `numberOfLines` to set the number of visible lines. This makes the input multiline.
|
package/index.cssx.styl
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// ----- CONFIG: $UI.TextInput
|
|
2
2
|
$this = merge({
|
|
3
3
|
textColor: var(--TextInput-text-color),
|
|
4
|
+
iconColor: var(--color-text-secondary),
|
|
4
5
|
borderWidth: 1,
|
|
5
6
|
heights: {
|
|
6
7
|
s: 2u,
|
|
@@ -16,7 +17,8 @@ $this = merge({
|
|
|
16
17
|
s: 0.5u,
|
|
17
18
|
m: 0.75u,
|
|
18
19
|
l: 1u
|
|
19
|
-
}
|
|
20
|
+
},
|
|
21
|
+
lineHeights: null
|
|
20
22
|
}, $UI.TextInput, true)
|
|
21
23
|
|
|
22
24
|
$this.caretColor = $this.textColor
|
package/index.tsx
CHANGED
|
@@ -23,7 +23,10 @@ import STYLES from './index.cssx.styl'
|
|
|
23
23
|
const {
|
|
24
24
|
config: {
|
|
25
25
|
caretColor,
|
|
26
|
+
iconColor,
|
|
27
|
+
borderWidth,
|
|
26
28
|
heights,
|
|
29
|
+
lineHeights,
|
|
27
30
|
paddings
|
|
28
31
|
}
|
|
29
32
|
} = STYLES
|
|
@@ -92,6 +95,9 @@ export interface UITextInputProps extends Omit<TextInputProps, 'placeholder' | '
|
|
|
92
95
|
function TextInput ({
|
|
93
96
|
ref,
|
|
94
97
|
style,
|
|
98
|
+
inputStyle,
|
|
99
|
+
iconStyle,
|
|
100
|
+
secondaryIconStyle,
|
|
95
101
|
placeholder,
|
|
96
102
|
value = '',
|
|
97
103
|
size = 'm',
|
|
@@ -174,9 +180,29 @@ function TextInput ({
|
|
|
174
180
|
return resize || numberOfLines > 1
|
|
175
181
|
}, [resize, numberOfLines])
|
|
176
182
|
|
|
183
|
+
const legacySizing = useMemo(() => {
|
|
184
|
+
const inputHeight = heights[size]
|
|
185
|
+
const lineHeight = lineHeights?.[size]
|
|
186
|
+
if (typeof inputHeight !== 'number' || typeof lineHeight !== 'number') return
|
|
187
|
+
|
|
188
|
+
const inputBorderWidth = typeof borderWidth === 'number' ? borderWidth : 0
|
|
189
|
+
const verticalPadding = Math.max((inputHeight - lineHeight) / 2 - inputBorderWidth, 0)
|
|
190
|
+
const fullHeight = currentNumberOfLines * lineHeight + 2 * (verticalPadding + inputBorderWidth)
|
|
191
|
+
|
|
192
|
+
return {
|
|
193
|
+
fullHeight,
|
|
194
|
+
inputStyle: {
|
|
195
|
+
lineHeight,
|
|
196
|
+
paddingTop: verticalPadding,
|
|
197
|
+
paddingBottom: verticalPadding
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}, [currentNumberOfLines, size])
|
|
201
|
+
|
|
177
202
|
const fullHeight = useMemo(() => {
|
|
203
|
+
if (legacySizing) return legacySizing.fullHeight
|
|
178
204
|
return currentNumberOfLines * (heights[size] as number) + (paddings[size] as number) * 2
|
|
179
|
-
}, [currentNumberOfLines, size])
|
|
205
|
+
}, [currentNumberOfLines, legacySizing, size])
|
|
180
206
|
|
|
181
207
|
function onLayoutIcon (e: any) {
|
|
182
208
|
if (IS_WEB) {
|
|
@@ -187,6 +213,8 @@ function TextInput ({
|
|
|
187
213
|
|
|
188
214
|
const inputExtraProps: Record<string, any> = {}
|
|
189
215
|
if (IS_ANDROID && multiline) inputExtraProps.textAlignVertical = 'top'
|
|
216
|
+
const inputMinHeightStyle = legacySizing ? null : { minHeight: fullHeight }
|
|
217
|
+
const resolvedIconColor = getColor(iconColor) || iconColor
|
|
190
218
|
|
|
191
219
|
const inputStyleName = [
|
|
192
220
|
size,
|
|
@@ -206,7 +234,7 @@ function TextInput ({
|
|
|
206
234
|
}
|
|
207
235
|
|
|
208
236
|
return _renderWrapper({
|
|
209
|
-
style: [style]
|
|
237
|
+
style: legacySizing ? [{ minHeight: fullHeight }, style] : [style]
|
|
210
238
|
}, pug`
|
|
211
239
|
RNTextInput.input-input(
|
|
212
240
|
part=['input', {
|
|
@@ -214,7 +242,7 @@ function TextInput ({
|
|
|
214
242
|
inputIconRight: icon && iconPosition === 'right'
|
|
215
243
|
}]
|
|
216
244
|
ref=inputRef
|
|
217
|
-
style=
|
|
245
|
+
style=[inputMinHeightStyle, legacySizing?.inputStyle, inputStyle]
|
|
218
246
|
styleName=inputStyleName
|
|
219
247
|
selectionColor=caretColor
|
|
220
248
|
placeholder=placeholder
|
|
@@ -241,6 +269,7 @@ function TextInput ({
|
|
|
241
269
|
part='icon'
|
|
242
270
|
icon=icon
|
|
243
271
|
size=ICON_SIZES[size]
|
|
272
|
+
style=[{ color: resolvedIconColor }, iconStyle]
|
|
244
273
|
)
|
|
245
274
|
if secondaryIcon
|
|
246
275
|
Div.input-icon(
|
|
@@ -254,6 +283,7 @@ function TextInput ({
|
|
|
254
283
|
part='secondaryIcon'
|
|
255
284
|
icon=secondaryIcon
|
|
256
285
|
size=ICON_SIZES[size]
|
|
286
|
+
style=[{ color: resolvedIconColor }, secondaryIconStyle]
|
|
257
287
|
)
|
|
258
288
|
`)
|
|
259
289
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startupjs-ui/text-input",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@startupjs-ui/core": "^0.3.0",
|
|
12
|
-
"@startupjs-ui/div": "^0.3.
|
|
13
|
-
"@startupjs-ui/icon": "^0.3.
|
|
14
|
-
"@startupjs-ui/span": "^0.3.
|
|
12
|
+
"@startupjs-ui/div": "^0.3.4",
|
|
13
|
+
"@startupjs-ui/icon": "^0.3.5",
|
|
14
|
+
"@startupjs-ui/span": "^0.3.4"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"react": "*",
|
|
18
18
|
"react-native": "*",
|
|
19
19
|
"startupjs": "*"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "8fc799070c16fb24de4ad0dbd6054108fe342d7c"
|
|
22
22
|
}
|