react-native-nitro-input 0.3.8 → 0.4.0

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.
Files changed (107) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/README.md +5 -1
  3. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputMeasure.kt +52 -0
  4. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +74 -80
  5. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberView.kt +18 -18
  6. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroTextView.kt +14 -14
  7. package/android/src/main/java/com/margelo/nitro/nitroinput/InputFonts.kt +199 -0
  8. package/android/src/main/java/com/margelo/nitro/nitroinput/InputSizing.kt +398 -0
  9. package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputView.kt +112 -333
  10. package/android/src/main/java/com/margelo/nitro/nitroinput/NitroNumberView.kt +178 -30
  11. package/ios/HybridNitroInputView.swift +69 -75
  12. package/ios/HybridNitroNumberView.swift +18 -18
  13. package/ios/HybridNitroTextView.swift +14 -14
  14. package/ios/InputSizing.swift +534 -0
  15. package/ios/NitroInputView.swift +102 -198
  16. package/ios/NitroNumberView.swift +98 -23
  17. package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +12 -8
  18. package/lib/commonjs/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -6
  19. package/lib/commonjs/nitrogen/generated/shared/json/NitroTextViewConfig.json +6 -6
  20. package/lib/commonjs/src/NitroInput.js +164 -23
  21. package/lib/commonjs/src/NitroNumber.js +1 -1
  22. package/lib/commonjs/src/NitroText.js +6 -6
  23. package/lib/commonjs/src/specs/NitroInputMeasure.nitro.js +2 -0
  24. package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +12 -8
  25. package/lib/module/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -6
  26. package/lib/module/nitrogen/generated/shared/json/NitroTextViewConfig.json +6 -6
  27. package/lib/module/src/NitroInput.js +165 -24
  28. package/lib/module/src/NitroNumber.js +1 -1
  29. package/lib/module/src/NitroText.js +6 -6
  30. package/lib/module/src/specs/NitroInputMeasure.nitro.js +1 -0
  31. package/lib/typescript/src/NitroInput.d.ts +9 -16
  32. package/lib/typescript/src/specs/NitroInput.nitro.d.ts +17 -8
  33. package/lib/typescript/src/specs/NitroInputMeasure.nitro.d.ts +67 -0
  34. package/lib/typescript/src/specs/NitroNumber.nitro.d.ts +6 -6
  35. package/lib/typescript/src/specs/NitroText.nitro.d.ts +6 -6
  36. package/nitro.json +10 -0
  37. package/nitrogen/generated/android/NitroInput+autolinking.cmake +2 -0
  38. package/nitrogen/generated/android/NitroInputOnLoad.cpp +16 -0
  39. package/nitrogen/generated/android/c++/JHybridNitroInputMeasureSpec.cpp +93 -0
  40. package/nitrogen/generated/android/c++/JHybridNitroInputMeasureSpec.hpp +63 -0
  41. package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +76 -40
  42. package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +24 -16
  43. package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.cpp +30 -30
  44. package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.hpp +12 -12
  45. package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.cpp +30 -30
  46. package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.hpp +12 -12
  47. package/nitrogen/generated/android/c++/JNitroInputSize.hpp +61 -0
  48. package/nitrogen/generated/android/c++/JNitroInputSizing.hpp +284 -0
  49. package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +44 -24
  50. package/nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.cpp +18 -18
  51. package/nitrogen/generated/android/c++/views/JHybridNitroTextViewStateUpdater.cpp +18 -18
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputMeasureSpec.kt +56 -0
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +32 -8
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberViewSpec.kt +6 -6
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroTextViewSpec.kt +6 -6
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputSize.kt +56 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputSizing.kt +246 -0
  58. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.cpp +17 -0
  59. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +29 -0
  60. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +11 -0
  61. package/nitrogen/generated/ios/NitroInputAutolinking.mm +8 -0
  62. package/nitrogen/generated/ios/NitroInputAutolinking.swift +12 -0
  63. package/nitrogen/generated/ios/c++/HybridNitroInputMeasureSpecSwift.cpp +11 -0
  64. package/nitrogen/generated/ios/c++/HybridNitroInputMeasureSpecSwift.hpp +112 -0
  65. package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +56 -32
  66. package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.hpp +24 -24
  67. package/nitrogen/generated/ios/c++/HybridNitroTextViewSpecSwift.hpp +24 -24
  68. package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +56 -32
  69. package/nitrogen/generated/ios/c++/views/HybridNitroNumberViewComponent.mm +24 -24
  70. package/nitrogen/generated/ios/c++/views/HybridNitroTextViewComponent.mm +24 -24
  71. package/nitrogen/generated/ios/swift/HybridNitroInputMeasureSpec.swift +55 -0
  72. package/nitrogen/generated/ios/swift/HybridNitroInputMeasureSpec_cxx.swift +138 -0
  73. package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +12 -8
  74. package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +68 -24
  75. package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec.swift +6 -6
  76. package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec_cxx.swift +18 -18
  77. package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec.swift +6 -6
  78. package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec_cxx.swift +18 -18
  79. package/nitrogen/generated/ios/swift/NitroInputSize.swift +34 -0
  80. package/nitrogen/generated/ios/swift/NitroInputSizing.swift +242 -0
  81. package/nitrogen/generated/shared/c++/HybridNitroInputMeasureSpec.cpp +21 -0
  82. package/nitrogen/generated/shared/c++/HybridNitroInputMeasureSpec.hpp +66 -0
  83. package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +24 -16
  84. package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +24 -16
  85. package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.cpp +12 -12
  86. package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.hpp +12 -12
  87. package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.cpp +12 -12
  88. package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.hpp +12 -12
  89. package/nitrogen/generated/shared/c++/NitroInputSize.hpp +87 -0
  90. package/nitrogen/generated/shared/c++/NitroInputSizing.hpp +263 -0
  91. package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +24 -16
  92. package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +36 -24
  93. package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.cpp +12 -12
  94. package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.hpp +18 -18
  95. package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.cpp +12 -12
  96. package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.hpp +18 -18
  97. package/nitrogen/generated/shared/json/NitroInputViewConfig.json +12 -8
  98. package/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -6
  99. package/nitrogen/generated/shared/json/NitroTextViewConfig.json +6 -6
  100. package/package.json +4 -2
  101. package/src/NitroInput.tsx +201 -64
  102. package/src/NitroNumber.tsx +6 -6
  103. package/src/NitroText.tsx +6 -6
  104. package/src/specs/NitroInput.nitro.ts +17 -8
  105. package/src/specs/NitroInputMeasure.nitro.ts +76 -0
  106. package/src/specs/NitroNumber.nitro.ts +6 -6
  107. package/src/specs/NitroText.nitro.ts +6 -6
@@ -40,7 +40,7 @@
40
40
  "signPlacement": true,
41
41
  "prefixAlign": true,
42
42
  "suffixAlign": true,
43
- "letterSpacing": true,
43
+ "textLetterSpacing": true,
44
44
  "prefixSpacing": true,
45
45
  "suffixSpacing": true,
46
46
  "prefixOffset": true,
@@ -51,12 +51,12 @@
51
51
  "easing": true,
52
52
  "bounce": true,
53
53
  "effect": true,
54
- "fontSize": true,
55
- "lineHeight": true,
56
- "fontWeight": true,
57
- "fontFamily": true,
58
- "color": true,
59
- "textAlign": true,
54
+ "textSize": true,
55
+ "textLineHeight": true,
56
+ "textWeight": true,
57
+ "textFamily": true,
58
+ "textColor": true,
59
+ "textAlignment": true,
60
60
  "rightToLeft": true,
61
61
  "caretColor": true,
62
62
  "selectionColor": true,
@@ -72,7 +72,11 @@
72
72
  "editable": true,
73
73
  "multiline": true,
74
74
  "numberOfLines": true,
75
- "textAlignVertical": true,
75
+ "textVerticalAlignment": true,
76
+ "textInsetLeft": true,
77
+ "textInsetTop": true,
78
+ "textInsetRight": true,
79
+ "textInsetBottom": true,
76
80
  "scrollEnabled": true,
77
81
  "autoFocus": true,
78
82
  "fieldTestID": true,
@@ -37,13 +37,13 @@
37
37
  "shimmerBaseColor": true,
38
38
  "shimmerDirection": true,
39
39
  "shimmerDelay": true,
40
- "fontSize": true,
40
+ "textSize": true,
41
41
  "prefixFontSize": true,
42
42
  "suffixFontSize": true,
43
43
  "affixAlign": true,
44
44
  "prefixAlign": true,
45
45
  "suffixAlign": true,
46
- "letterSpacing": true,
46
+ "textLetterSpacing": true,
47
47
  "prefixSpacing": true,
48
48
  "suffixSpacing": true,
49
49
  "prefixOffset": true,
@@ -66,10 +66,10 @@
66
66
  "minimumFontScale": true,
67
67
  "allowFontScaling": true,
68
68
  "maxFontSizeMultiplier": true,
69
- "fontWeight": true,
70
- "fontFamily": true,
71
- "color": true,
72
- "textAlign": true,
69
+ "textWeight": true,
70
+ "textFamily": true,
71
+ "textColor": true,
72
+ "textAlignment": true,
73
73
  "rightToLeft": true,
74
74
  "onSizeChange": true,
75
75
  "onRevealEnd": true,
@@ -5,12 +5,12 @@
5
5
  "directEventTypes": {},
6
6
  "validAttributes": {
7
7
  "text": true,
8
- "fontSize": true,
9
- "fontWeight": true,
10
- "fontFamily": true,
11
- "color": true,
12
- "letterSpacing": true,
13
- "textAlign": true,
8
+ "textSize": true,
9
+ "textWeight": true,
10
+ "textFamily": true,
11
+ "textColor": true,
12
+ "textLetterSpacing": true,
13
+ "textAlignment": true,
14
14
  "rightToLeft": true,
15
15
  "duration": true,
16
16
  "easing": true,
@@ -1,6 +1,6 @@
1
1
  import React, { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, } from 'react';
2
2
  import { I18nManager, StyleSheet, } from 'react-native';
3
- import { callback, getHostComponent, } from 'react-native-nitro-modules';
3
+ import { callback, getHostComponent, NitroModules, } from 'react-native-nitro-modules';
4
4
  import NitroInputViewConfig from '../nitrogen/generated/shared/json/NitroInputViewConfig.json';
5
5
  import { allocateWorkletId, isWorklet, registerFocusChange, registerKeyPress, registerSelectionChange, registerTextEvent, registerCallback, registerTransform, unregisterWorklet, } from './worklets';
6
6
  import { toNumericWeight, toProcessedColor } from './styleHelpers';
@@ -145,21 +145,75 @@ function warnIncompatible(what) {
145
145
  'field is drawn by the system view, and an amount, a mask and their ' +
146
146
  'affixes are single-line. Drop one of the two.');
147
147
  }
148
+ const NO_INSETS = { left: 0, top: 0, right: 0, bottom: 0 };
148
149
  /**
149
- * A native text input: a system field (`UITextField` / `EditText`) that owns
150
- * the keyboard, editing, selection, paste and accessibility, with native
151
- * formatting (`mode="number"`), native masking (`mode="mask"`), an outlined
152
- * or filled frame with a floating label, and optionally the glyph engine
153
- * (`transition="reflow"`), under which characters that stay glide to their new place, new
154
- * ones slide or fade in and removed ones leave alongside their neighbours.
155
- * In `'number'` mode every edit is formatted on the native side before a
156
- * frame is drawn, with the caret kept in place, so there is never an
157
- * unformatted frame and never a round trip through JS.
158
- *
159
- * Like a `TextInput`, it takes its width from its parent; `autoWidth` sizes
160
- * it to its content instead, and is on by default when the text reflows.
150
+ * The style's padding plus border per edge, resolved the way Yoga does: a
151
+ * start / end edge before left / right, then horizontal / vertical, then all.
152
+ * A size measured for the text gets them added, as `TextInput`'s is, so a
153
+ * padded field grows rather than squeezing its text. Percentages are not
154
+ * resolved here (they need the parent's size) and count as 0.
161
155
  */
162
- export const NitroInput = forwardRef(function NitroInput({ value, defaultValue, mode, fractionDigits, maxIntegerDigits, groupingSeparator, decimalSeparator, prefix, suffix, prefixFontSize, suffixFontSize, affixAlign, signPlacement, prefixAlign, suffixAlign, letterSpacing, prefixSpacing, suffixSpacing, prefixOffset, suffixOffset, format, placeholder, placeholderTextColor, duration, easing, bounce, effect, fontSize, lineHeight, fontWeight, fontFamily, color, textAlign, cursorColor, selectionColor, caretHidden, adjustsFontSizeToFit, minimumFontScale, allowFontScaling, maxFontSizeMultiplier, variant, label, labelBehavior, labelColor, labelFocusedColor, labelFontSize, strokeColor, focusedStrokeColor, strokeWidth, cornerRadius, fillColor, keyboardType, inputMode, enterKeyHint, mask, maskNotations, maskAutocomplete, maskAutoSkip, maskAffinityFormats, maskAffinityStrategy, maskTextCase, maskCharacterMap, maskSlotPlaceholder, keepPlaceholder, returnKeyType, autoCapitalize, autoCorrect, editable, multiline, numberOfLines, rows, textAlignVertical, scrollEnabled, autoFocus, transition, autoWidth: autoWidthProp, submitBehavior, blurOnSubmit, secureTextEntry, keyboardAppearance, textContentType, autoComplete, enablesReturnKeyAutomatically, showSoftInputOnFocus, selectTextOnFocus, clearTextOnFocus, keyboardHandoffMs, returnKeyBar, contextMenuHidden, spellCheck, readOnly, selection, onEndEditing, onSelectionChange, onKeyPress, maxLength, transform, onChangeText, onChange, onChangeValue, onChangeMask, onFocus, onBlur, focusedValue, onSubmitEditing, onNativeRef, style, ...viewProps }, ref) {
156
+ function styleInsets(flat, rightToLeft) {
157
+ if (flat == null)
158
+ return NO_INSETS;
159
+ const n = (key) => {
160
+ const value = flat[key];
161
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
162
+ };
163
+ const start = rightToLeft ? 'End' : 'Start';
164
+ const end = rightToLeft ? 'Start' : 'End';
165
+ const insets = {
166
+ left: (n(`padding${start}`) ?? n('paddingLeft') ?? n('paddingHorizontal') ?? n('padding') ?? 0) +
167
+ (n(`border${start}Width`) ?? n('borderLeftWidth') ?? n('borderWidth') ?? 0),
168
+ right: (n(`padding${end}`) ?? n('paddingRight') ?? n('paddingHorizontal') ?? n('padding') ?? 0) +
169
+ (n(`border${end}Width`) ?? n('borderRightWidth') ?? n('borderWidth') ?? 0),
170
+ top: (n('paddingTop') ?? n('paddingVertical') ?? n('padding') ?? 0) + (n('borderTopWidth') ?? n('borderWidth') ?? 0),
171
+ bottom: (n('paddingBottom') ?? n('paddingVertical') ?? n('padding') ?? 0) +
172
+ (n('borderBottomWidth') ?? n('borderWidth') ?? 0),
173
+ };
174
+ return insets.left === 0 && insets.right === 0 && insets.top === 0 && insets.bottom === 0 ? NO_INSETS : insets;
175
+ }
176
+ function styleTextAlign(value, rightToLeft) {
177
+ switch (value) {
178
+ case undefined:
179
+ return undefined;
180
+ // `justify` has no meaning on one line: the start edge, as on a TextInput.
181
+ case 'start':
182
+ case 'justify':
183
+ return 'auto';
184
+ case 'end':
185
+ return rightToLeft ? 'left' : 'right';
186
+ default:
187
+ return value;
188
+ }
189
+ }
190
+ function styleTextAlignVertical(value) {
191
+ return value ?? undefined;
192
+ }
193
+ // One per app, made on first use. `null` when the native side has none (an
194
+ // app built against an older version, or a test without native modules): the
195
+ // field then takes its size from the view's first report, as it used to.
196
+ let measurer;
197
+ function measureSizing(sizing) {
198
+ if (measurer === undefined) {
199
+ try {
200
+ const made = NitroModules.createHybridObject('NitroInputMeasure');
201
+ measurer = typeof made?.measure === 'function' ? made : null;
202
+ }
203
+ catch {
204
+ measurer = null;
205
+ }
206
+ }
207
+ if (measurer === null)
208
+ return null;
209
+ try {
210
+ return measurer.measure(sizing);
211
+ }
212
+ catch {
213
+ return null;
214
+ }
215
+ }
216
+ export const NitroInput = forwardRef(function NitroInput({ value, defaultValue, mode, fractionDigits, maxIntegerDigits, groupingSeparator, decimalSeparator, prefix, suffix, prefixFontSize, suffixFontSize, affixAlign, signPlacement, prefixAlign, suffixAlign, letterSpacing: letterSpacingProp, prefixSpacing, suffixSpacing, prefixOffset, suffixOffset, format, placeholder, placeholderTextColor, duration, easing, bounce, effect, fontSize: fontSizeProp, lineHeight: lineHeightProp, fontWeight: fontWeightProp, fontFamily: fontFamilyProp, color: colorProp, textAlign: textAlignProp, cursorColor, selectionColor, caretHidden, adjustsFontSizeToFit, minimumFontScale, allowFontScaling, maxFontSizeMultiplier, variant, label, labelBehavior, labelColor, labelFocusedColor, labelFontSize, strokeColor, focusedStrokeColor, strokeWidth, cornerRadius, fillColor, keyboardType, inputMode, enterKeyHint, mask, maskNotations, maskAutocomplete, maskAutoSkip, maskAffinityFormats, maskAffinityStrategy, maskTextCase, maskCharacterMap, maskSlotPlaceholder, keepPlaceholder, returnKeyType, autoCapitalize, autoCorrect, editable, multiline, numberOfLines, rows, textAlignVertical: textAlignVerticalProp, scrollEnabled, autoFocus, transition, autoWidth: autoWidthProp, submitBehavior, blurOnSubmit, secureTextEntry, keyboardAppearance, textContentType, autoComplete, enablesReturnKeyAutomatically, showSoftInputOnFocus, selectTextOnFocus, clearTextOnFocus, keyboardHandoffMs, returnKeyBar, contextMenuHidden, spellCheck, readOnly, selection, onEndEditing, onSelectionChange, onKeyPress, maxLength, transform, onChangeText, onChange, onChangeValue, onChangeMask, onFocus, onBlur, focusedValue, onSubmitEditing, onNativeRef, style, ...viewProps }, ref) {
163
217
  const nativeRef = useRef(null);
164
218
  // `keyboardHandoffMs`: hand the keyboard off while this field still has it.
165
219
  // A layout-effect cleanup runs in React's commit, so the native call is
@@ -222,6 +276,11 @@ export const NitroInput = forwardRef(function NitroInput({ value, defaultValue,
222
276
  if (value != null)
223
277
  textRef.current = value;
224
278
  const [size, setSize] = useState(null);
279
+ // The size measured before the view existed (see `measureSizing`), and
280
+ // whether the view has reported its own since.
281
+ const seedRef = useRef(null);
282
+ const seedKeyRef = useRef('');
283
+ const reportedRef = useRef(false);
225
284
  // Worklets are registered on the UI runtime and referenced by id; a
226
285
  // handler marked 'worklet' runs there instead of on the JS thread.
227
286
  const transformId = useWorkletId(transform, registerTransform);
@@ -327,11 +386,24 @@ export const NitroInput = forwardRef(function NitroInput({ value, defaultValue,
327
386
  // A field with a width of its own (the usual case) never needs a React
328
387
  // commit per keystroke: only the height (font-dependent) is taken from native.
329
388
  const flat = useMemo(() => StyleSheet.flatten(style), [style]);
389
+ // `TextInput` takes its typography from `style`; so does this, under the
390
+ // props of the same name, which win. (Fabric hands a view its style's keys
391
+ // as props too; the view's own are named so that none can be one of them -
392
+ // see PropNameCollisions.test.)
393
+ const fontSize = fontSizeProp ?? flat?.fontSize;
394
+ const lineHeight = lineHeightProp ?? flat?.lineHeight;
395
+ const fontWeight = fontWeightProp ?? flat?.fontWeight;
396
+ const fontFamily = fontFamilyProp ?? flat?.fontFamily;
397
+ const color = colorProp ?? flat?.color;
398
+ const letterSpacing = letterSpacingProp ?? flat?.letterSpacing;
399
+ const textAlignVertical = textAlignVerticalProp ?? styleTextAlignVertical(flat?.textAlignVertical);
330
400
  // The layout direction, resolved the way React Native resolves it for its
331
401
  // own views: the field's `style.direction` if it says, else the app's.
332
402
  // Fabric does not hand a Hybrid View its resolved direction, so native is
333
403
  // told outright.
334
404
  const rightToLeft = flat?.direction === 'rtl' || (flat?.direction !== 'ltr' && I18nManager.isRTL);
405
+ const textAlign = textAlignProp ?? styleTextAlign(flat?.textAlign, rightToLeft);
406
+ const insets = useMemo(() => styleInsets(flat, rightToLeft), [flat, rightToLeft]);
335
407
  // `TextInput` stretches to its parent; sizing to content is this
336
408
  // component's own behaviour, and it is what stops it being a drop-in.
337
409
  // `NitroInput` turns it off so flexbox gives it the parent's width, the
@@ -349,13 +421,17 @@ export const NitroInput = forwardRef(function NitroInput({ value, defaultValue,
349
421
  const measuredRef = useRef(measured);
350
422
  measuredRef.current = measured;
351
423
  const onSizeChange = useMemo(() => callback((width, height) => {
424
+ reportedRef.current = true;
352
425
  if (!measuredRef.current)
353
426
  return;
354
427
  setSize((previous) => {
428
+ // Until the first report the field shows the seed; a report that
429
+ // matches it leaves `size` as it is, and costs no commit.
430
+ const shown = previous ?? seedRef.current;
355
431
  if (!autoWidthRef.current) {
356
- return previous !== null && previous.height === height ? previous : { width: previous?.width ?? width, height };
432
+ return shown !== null && shown.height === height ? previous : { width: shown?.width ?? width, height };
357
433
  }
358
- return previous !== null && previous.width === width && previous.height === height
434
+ return shown !== null && shown.width === width && shown.height === height
359
435
  ? previous
360
436
  : { width, height };
361
437
  });
@@ -600,15 +676,80 @@ export const NitroInput = forwardRef(function NitroInput({ value, defaultValue,
600
676
  hostViewProps.importantForAccessibility = resolvedImportance;
601
677
  if (resolvedLabelledBy != null)
602
678
  hostViewProps.accessibilityLabelledBy = resolvedLabelledBy;
603
- const autoSize = useMemo(() => size !== null
604
- ? autoWidth
605
- ? { width: size.width, height: size.height }
606
- : { height: size.height }
607
- : { height: resolvedFontSize * 1.25 }, [size, resolvedFontSize, autoWidth]);
608
- return (React.createElement(NativeNitroInputView, { ...hostViewProps, ref: hostRef, style: [autoSize, style], hybridRef: hybridRef, text: value ?? uncontrolledText,
679
+ // What the field's size follows. Sent to the view as props and, before
680
+ // the view exists, to `measureSizing`, so the two see the same values.
681
+ const sizing = {
682
+ text: value ?? uncontrolledText,
683
+ mode: resolvedMode,
684
+ plain: !reflows,
685
+ multiline: isMultiline,
686
+ secureTextEntry: secureTextEntry ?? false,
687
+ maxLength: maxLength ?? 0,
688
+ fractionDigits: resolvedFractionDigits,
689
+ maxIntegerDigits: maxIntegerDigits ?? 15,
690
+ groupingSeparator: groupingSeparator ?? derived?.groupingSeparator ?? ',',
691
+ decimalSeparator: decimalSeparator ?? derived?.decimalSeparator ?? '.',
692
+ prefix: resolvedPrefix,
693
+ suffix: resolvedSuffix,
694
+ signPlacement: signPlacement ?? derived?.signPlacement ?? 'beforeAffix',
695
+ placeholder: placeholder ?? '',
696
+ mask: resolvedMode === 'mask' ? (mask ?? '') : '',
697
+ maskNotations: stableNotations,
698
+ maskAutocomplete: maskAutocomplete ?? true,
699
+ maskAutoSkip: maskAutoSkip ?? false,
700
+ maskAffinityFormats: stableAffinityFormats,
701
+ maskAffinityStrategy: maskAffinityStrategy ?? 'wholeString',
702
+ maskTextCase: maskTextCase ?? 'none',
703
+ maskCharacterMap: stableCharacterMap,
704
+ maskSlotPlaceholder: maskSlotPlaceholder ?? (keepPlaceholder ? '_' : ''),
705
+ keepPlaceholder: keepPlaceholder ?? false,
706
+ textSize: resolvedFontSize,
707
+ textLineHeight: Math.max(0, lineHeight ?? 0),
708
+ prefixFontSize: prefixFontSize ?? resolvedFontSize,
709
+ suffixFontSize: suffixFontSize ?? resolvedFontSize,
710
+ textWeight: numericWeight,
711
+ textFamily: fontFamily ?? '',
712
+ textLetterSpacing: letterSpacing ?? 0,
713
+ prefixSpacing: prefixSpacing ?? Infinity,
714
+ suffixSpacing: suffixSpacing ?? Infinity,
715
+ allowFontScaling: allowFontScaling ?? false,
716
+ maxFontSizeMultiplier: maxFontSizeMultiplier ?? 0,
717
+ variant: variant ?? 'none',
718
+ label: label ?? '',
719
+ labelBehavior: labelBehavior ?? 'float',
720
+ labelFontSize: labelFontSize ?? 0,
721
+ cornerRadius: cornerRadius ?? 8,
722
+ };
723
+ // Until the view reports its size, the field lays out at the size it will
724
+ // report, measured now with the view's own code - as `TextInput` measures
725
+ // in its shadow node - rather than at its parent's width for the commit
726
+ // the report takes. Not for a wrapping field (its height needs the width
727
+ // it will get), a `transform` (a worklet, run on the UI thread) or a
728
+ // style that sets both dimensions. Measured again only when what it
729
+ // follows changes.
730
+ if (!reportedRef.current) {
731
+ const seedKey = measured && !isMultiline && transformId === 0 ? JSON.stringify(sizing) : '';
732
+ if (seedKey !== seedKeyRef.current) {
733
+ seedKeyRef.current = seedKey;
734
+ seedRef.current = seedKey === '' ? null : measureSizing(sizing);
735
+ }
736
+ }
737
+ const shownSize = size ?? seedRef.current;
738
+ // The size measured for the text, plus the style's padding and border
739
+ // (Yoga's box includes them; `TextInput`'s measured size gets them too).
740
+ const autoSize = useMemo(() => {
741
+ const extraWidth = insets.left + insets.right;
742
+ const extraHeight = insets.top + insets.bottom;
743
+ return shownSize !== null
744
+ ? autoWidth
745
+ ? { width: shownSize.width + extraWidth, height: shownSize.height + extraHeight }
746
+ : { height: shownSize.height + extraHeight }
747
+ : { height: resolvedFontSize * 1.25 + extraHeight };
748
+ }, [shownSize, resolvedFontSize, autoWidth, insets]);
749
+ return (React.createElement(NativeNitroInputView, { ...hostViewProps, ...sizing, ref: hostRef, style: [autoSize, style], hybridRef: hybridRef,
609
750
  // An uncontrolled field's `text` is its initial text: a count of 0 is
610
751
  // never caught up after the first edit, so native never puts it back.
611
- mostRecentEventCount: value != null ? eventCountRef.current : 0, mode: resolvedMode, plain: !reflows, fractionDigits: resolvedFractionDigits, maxIntegerDigits: maxIntegerDigits ?? 15, groupingSeparator: groupingSeparator ?? derived?.groupingSeparator ?? ',', decimalSeparator: decimalSeparator ?? derived?.decimalSeparator ?? '.', prefix: resolvedPrefix, suffix: resolvedSuffix, prefixFontSize: prefixFontSize ?? resolvedFontSize, suffixFontSize: suffixFontSize ?? resolvedFontSize, signPlacement: signPlacement ?? derived?.signPlacement ?? 'beforeAffix', prefixAlign: prefixAlign ?? resolvedAffixAlign, suffixAlign: suffixAlign ?? resolvedAffixAlign, letterSpacing: letterSpacing ?? 0, prefixSpacing: prefixSpacing ?? Infinity, suffixSpacing: suffixSpacing ?? Infinity, prefixOffset: prefixOffset ?? 0, suffixOffset: suffixOffset ?? 0, placeholder: placeholder ?? '', placeholderColor: processedPlaceholderColor, duration: duration ?? 400, easing: easing ?? 'expo', bounce: bounce ?? 0.15, effect: effect ?? 'auto', fontSize: resolvedFontSize, lineHeight: Math.max(0, lineHeight ?? 0), fontWeight: numericWeight, fontFamily: fontFamily ?? '', color: processedColor, textAlign: textAlign ?? 'auto', rightToLeft: rightToLeft, caretColor: processedCursorColor, selectionColor: processedSelectionColor, caretHidden: caretHidden ?? false, adjustsFontSizeToFit: adjustsFontSizeToFit ?? false, minimumFontScale: minimumFontScale ?? 0.5, allowFontScaling: allowFontScaling ?? false, maxFontSizeMultiplier: maxFontSizeMultiplier ?? 0, variant: variant ?? 'none', label: label ?? '', labelBehavior: labelBehavior ?? 'float', labelColor: processedLabelColor, labelFocusedColor: processedLabelFocusedColor, labelFontSize: labelFontSize ?? 0, strokeColor: processedStrokeColor, focusedStrokeColor: processedFocusedStrokeColor, strokeWidth: strokeWidth ?? 1, cornerRadius: cornerRadius ?? 8, fillColor: processedFillColor, mask: resolvedMode === 'mask' ? (mask ?? '') : '', maskNotations: stableNotations, maskAutocomplete: maskAutocomplete ?? true, maskAutoSkip: maskAutoSkip ?? false, maskAffinityFormats: stableAffinityFormats, maskAffinityStrategy: maskAffinityStrategy ?? 'wholeString', maskTextCase: maskTextCase ?? 'none', maskCharacterMap: stableCharacterMap, maskSlotPlaceholder: maskSlotPlaceholder ?? (keepPlaceholder ? '_' : ''), keepPlaceholder: keepPlaceholder ?? false, onChangeMask: onChangeMaskCallback, keyboardType: resolvedKeyboardType, returnKeyType: resolvedReturnKeyType, autoCapitalize: autoCapitalize ?? 'sentences', autoCorrect: autoCorrect ?? true, editable: (editable ?? true) && !(readOnly ?? false), multiline: isMultiline, numberOfLines: Math.max(0, Math.trunc(numberOfLines ?? rows ?? 0)), textAlignVertical: textAlignVertical ?? 'auto', scrollEnabled: scrollEnabled ?? true, autoFocus: autoFocus ?? false, fieldTestID: viewProps.testID ?? '', fieldAccessibilityLabel: resolvedAccessibilityLabel ?? '', submitBehavior: submitBehavior ??
752
+ mostRecentEventCount: value != null ? eventCountRef.current : 0, prefixAlign: prefixAlign ?? resolvedAffixAlign, suffixAlign: suffixAlign ?? resolvedAffixAlign, prefixOffset: prefixOffset ?? 0, suffixOffset: suffixOffset ?? 0, placeholderColor: processedPlaceholderColor, duration: duration ?? 400, easing: easing ?? 'expo', bounce: bounce ?? 0.15, effect: effect ?? 'auto', textColor: processedColor, textAlignment: textAlign ?? 'auto', rightToLeft: rightToLeft, caretColor: processedCursorColor, selectionColor: processedSelectionColor, caretHidden: caretHidden ?? false, adjustsFontSizeToFit: adjustsFontSizeToFit ?? false, minimumFontScale: minimumFontScale ?? 0.5, labelColor: processedLabelColor, labelFocusedColor: processedLabelFocusedColor, strokeColor: processedStrokeColor, focusedStrokeColor: processedFocusedStrokeColor, strokeWidth: strokeWidth ?? 1, fillColor: processedFillColor, onChangeMask: onChangeMaskCallback, keyboardType: resolvedKeyboardType, returnKeyType: resolvedReturnKeyType, autoCapitalize: autoCapitalize ?? 'sentences', autoCorrect: autoCorrect ?? true, editable: (editable ?? true) && !(readOnly ?? false), numberOfLines: Math.max(0, Math.trunc(numberOfLines ?? rows ?? 0)), textVerticalAlignment: textAlignVertical ?? 'auto', textInsetLeft: insets.left, textInsetTop: insets.top, textInsetRight: insets.right, textInsetBottom: insets.bottom, scrollEnabled: scrollEnabled ?? true, autoFocus: autoFocus ?? false, fieldTestID: viewProps.testID ?? '', fieldAccessibilityLabel: resolvedAccessibilityLabel ?? '', submitBehavior: submitBehavior ??
612
753
  // As `TextInput` resolves the legacy `blurOnSubmit`: a multiline
613
754
  // field's return key inserts a line break unless told to blur.
614
755
  (multiline
@@ -617,7 +758,7 @@ export const NitroInput = forwardRef(function NitroInput({ value, defaultValue,
617
758
  : 'newline'
618
759
  : blurOnSubmit === false
619
760
  ? 'submit'
620
- : 'blurAndSubmit'), secureTextEntry: secureTextEntry ?? false, keyboardAppearance: keyboardAppearance ?? 'default', textContentType: textContentType ?? autoComplete ?? '', enablesReturnKeyAutomatically: enablesReturnKeyAutomatically ?? false, showSoftInputOnFocus: resolvedShowSoftInput, selectTextOnFocus: selectTextOnFocus ?? false, clearTextOnFocus: clearTextOnFocus ?? false, keyboardHandoffMs: keyboardHandoffMs ?? 0, returnKeyBar: returnKeyBar ?? true, contextMenuHidden: contextMenuHidden ?? false, spellCheck: spellCheck ?? autoCorrect ?? true, selectionStart: selection?.start ?? -1, selectionEnd: selection?.end ?? selection?.start ?? -1, maxLength: maxLength ?? 0, transformWorklet: transformId, onChangeTextWorklet: onChangeTextId, onChangeValueWorklet: onChangeValueId, onFocusChangeWorklet: onFocusId, onSelectionChangeWorklet: onSelectionChangeId, onSubmitEditingWorklet: onSubmitEditingId, onEndEditingWorklet: onEndEditingId, onKeyPressWorklet: onKeyPressId, onChangeText: onChangeTextCallback, onChangeValue: onChangeValueCallback, onFocusChange: onFocusChangeCallback, onSubmitEditing: onSubmitEditingCallback, onEndEditing: onEndEditingCallback, onSelectionChange: onSelectionChangeCallback, onKeyPress: onKeyPressCallback, onSizeChange: onSizeChange }));
761
+ : 'blurAndSubmit'), keyboardAppearance: keyboardAppearance ?? 'default', textContentType: textContentType ?? autoComplete ?? '', enablesReturnKeyAutomatically: enablesReturnKeyAutomatically ?? false, showSoftInputOnFocus: resolvedShowSoftInput, selectTextOnFocus: selectTextOnFocus ?? false, clearTextOnFocus: clearTextOnFocus ?? false, keyboardHandoffMs: keyboardHandoffMs ?? 0, returnKeyBar: returnKeyBar ?? true, contextMenuHidden: contextMenuHidden ?? false, spellCheck: spellCheck ?? autoCorrect ?? true, selectionStart: selection?.start ?? -1, selectionEnd: selection?.end ?? selection?.start ?? -1, transformWorklet: transformId, onChangeTextWorklet: onChangeTextId, onChangeValueWorklet: onChangeValueId, onFocusChangeWorklet: onFocusId, onSelectionChangeWorklet: onSelectionChangeId, onSubmitEditingWorklet: onSubmitEditingId, onEndEditingWorklet: onEndEditingId, onKeyPressWorklet: onKeyPressId, onChangeText: onChangeTextCallback, onChangeValue: onChangeValueCallback, onFocusChange: onFocusChangeCallback, onSubmitEditing: onSubmitEditingCallback, onEndEditing: onEndEditingCallback, onSelectionChange: onSelectionChangeCallback, onKeyPress: onKeyPressCallback, onSizeChange: onSizeChange }));
621
762
  });
622
763
  // The name DevTools and error stacks show, as `TextInput` names itself.
623
764
  NitroInput.displayName = 'NitroInput';
@@ -155,5 +155,5 @@ export const NitroNumber = forwardRef(function NitroNumber({ value, minorDigits,
155
155
  // does not hand a Hybrid View its resolved direction, so native is told.
156
156
  const layoutDirection = useMemo(() => StyleSheet.flatten(style)?.direction, [style]);
157
157
  const rightToLeft = layoutDirection === 'rtl' || (layoutDirection !== 'ltr' && I18nManager.isRTL);
158
- return (React.createElement(NativeNitroNumberView, { ...viewProps, style: [autoSize, style], hybridRef: hybridRef, value: shownValue, fractionDigits: fractionDigits ?? figure?.fractionDigits ?? 0, minimumIntegerDigits: minimumIntegerDigits ?? derived?.minimumIntegerDigits ?? 1, groupingSeparator: groupingSeparator ?? derived?.groupingSeparator ?? '', decimalSeparator: decimalSeparator ?? derived?.decimalSeparator ?? '.', prefix: prefix ?? compact?.prefix ?? derived?.prefix ?? '', suffix: suffix ?? compact?.suffix ?? derived?.suffix ?? '', transition: transition ?? 'roll', flashUpColor: processedFlashUp, flashDownColor: processedFlashDown, flashDuration: flashDuration ?? 600, popOnChange: popOnChange ?? 0, duration: still ? 0 : duration ?? TRANSITION_DEFAULTS[transition ?? 'roll'].duration, easing: easing ?? TRANSITION_DEFAULTS[transition ?? 'roll'].easing, bounce: bounce ?? 0.15, stagger: stagger ?? TRANSITION_DEFAULTS[transition ?? 'roll'].stagger, rollDirection: direction ?? compactDirection ?? 'auto', revealState: reveal === undefined ? 0 : reveal ? 2 : 1, revealStyle: revealStyle ?? 'count', revealDuration: still ? 0 : revealDuration ?? 2200, revealBounce: revealBounce ?? 0.12, revealGrow: revealGrow ?? 0.2, revealStagger: revealStagger ?? 200, revealMilestones: stableMilestones, revealMilestoneHold: revealMilestoneHold ?? 0, onRevealEnd: onRevealEndCallback, onRevealMilestone: onRevealMilestoneCallback, onAnimationStart: onAnimationStartCallback, onAnimationEnd: onAnimationEndCallback, loading: loading ?? false, shimmerColor: processedShimmerColor, shimmerDuration: shimmerDuration ?? 950, shimmerAngle: shimmerAngle ?? 31, shimmerWidth: shimmerWidth ?? 1, shimmerBaseColor: processedShimmerBase, shimmerDirection: shimmerDirection ?? 'auto', shimmerDelay: shimmerDelay ?? 0, fontSize: resolvedFontSize, prefixFontSize: prefixFontSize ?? resolvedFontSize, suffixFontSize: suffixFontSize ?? resolvedFontSize, affixAlign: resolvedAffixAlign, prefixAlign: prefixAlign ?? resolvedAffixAlign, suffixAlign: suffixAlign ?? resolvedAffixAlign, letterSpacing: letterSpacing ?? 0, prefixSpacing: prefixSpacing ?? Infinity, suffixSpacing: suffixSpacing ?? Infinity, prefixOffset: prefixOffset ?? 0, suffixOffset: suffixOffset ?? 0, tabularNums: tabularNums ?? true, signDisplay: signDisplay ?? derived?.signDisplay ?? 'auto', plusSign: plusSign ?? derived?.plusSign ?? '+', minusSign: minusSign ?? derived?.minusSign ?? '-', digitGlyphs: stableGlyphs, groupingSizes: stableGroups, digitMax: digitMax, continuous: continuous ?? false, prefixColor: processedPrefixColor, suffixColor: processedSuffixColor, fractionColor: processedFractionColor, fractionFontSize: fractionFontSize ?? Infinity, fractionAlign: fractionAlign ?? 'baseline', respectReduceMotion: respectReduceMotion ?? true, adjustsFontSizeToFit: adjustsFontSizeToFit ?? false, minimumFontScale: minimumFontScale ?? 0.5, allowFontScaling: allowFontScaling ?? false, maxFontSizeMultiplier: maxFontSizeMultiplier ?? 0, fontWeight: numericWeight, fontFamily: fontFamily ?? '', color: processedColor, textAlign: textAlign ?? 'auto', rightToLeft: rightToLeft, onSizeChange: onSizeChange }));
158
+ return (React.createElement(NativeNitroNumberView, { ...viewProps, style: [autoSize, style], hybridRef: hybridRef, value: shownValue, fractionDigits: fractionDigits ?? figure?.fractionDigits ?? 0, minimumIntegerDigits: minimumIntegerDigits ?? derived?.minimumIntegerDigits ?? 1, groupingSeparator: groupingSeparator ?? derived?.groupingSeparator ?? '', decimalSeparator: decimalSeparator ?? derived?.decimalSeparator ?? '.', prefix: prefix ?? compact?.prefix ?? derived?.prefix ?? '', suffix: suffix ?? compact?.suffix ?? derived?.suffix ?? '', transition: transition ?? 'roll', flashUpColor: processedFlashUp, flashDownColor: processedFlashDown, flashDuration: flashDuration ?? 600, popOnChange: popOnChange ?? 0, duration: still ? 0 : duration ?? TRANSITION_DEFAULTS[transition ?? 'roll'].duration, easing: easing ?? TRANSITION_DEFAULTS[transition ?? 'roll'].easing, bounce: bounce ?? 0.15, stagger: stagger ?? TRANSITION_DEFAULTS[transition ?? 'roll'].stagger, rollDirection: direction ?? compactDirection ?? 'auto', revealState: reveal === undefined ? 0 : reveal ? 2 : 1, revealStyle: revealStyle ?? 'count', revealDuration: still ? 0 : revealDuration ?? 2200, revealBounce: revealBounce ?? 0.12, revealGrow: revealGrow ?? 0.2, revealStagger: revealStagger ?? 200, revealMilestones: stableMilestones, revealMilestoneHold: revealMilestoneHold ?? 0, onRevealEnd: onRevealEndCallback, onRevealMilestone: onRevealMilestoneCallback, onAnimationStart: onAnimationStartCallback, onAnimationEnd: onAnimationEndCallback, loading: loading ?? false, shimmerColor: processedShimmerColor, shimmerDuration: shimmerDuration ?? 950, shimmerAngle: shimmerAngle ?? 31, shimmerWidth: shimmerWidth ?? 1, shimmerBaseColor: processedShimmerBase, shimmerDirection: shimmerDirection ?? 'auto', shimmerDelay: shimmerDelay ?? 0, textSize: resolvedFontSize, prefixFontSize: prefixFontSize ?? resolvedFontSize, suffixFontSize: suffixFontSize ?? resolvedFontSize, affixAlign: resolvedAffixAlign, prefixAlign: prefixAlign ?? resolvedAffixAlign, suffixAlign: suffixAlign ?? resolvedAffixAlign, textLetterSpacing: letterSpacing ?? 0, prefixSpacing: prefixSpacing ?? Infinity, suffixSpacing: suffixSpacing ?? Infinity, prefixOffset: prefixOffset ?? 0, suffixOffset: suffixOffset ?? 0, tabularNums: tabularNums ?? true, signDisplay: signDisplay ?? derived?.signDisplay ?? 'auto', plusSign: plusSign ?? derived?.plusSign ?? '+', minusSign: minusSign ?? derived?.minusSign ?? '-', digitGlyphs: stableGlyphs, groupingSizes: stableGroups, digitMax: digitMax, continuous: continuous ?? false, prefixColor: processedPrefixColor, suffixColor: processedSuffixColor, fractionColor: processedFractionColor, fractionFontSize: fractionFontSize ?? Infinity, fractionAlign: fractionAlign ?? 'baseline', respectReduceMotion: respectReduceMotion ?? true, adjustsFontSizeToFit: adjustsFontSizeToFit ?? false, minimumFontScale: minimumFontScale ?? 0.5, allowFontScaling: allowFontScaling ?? false, maxFontSizeMultiplier: maxFontSizeMultiplier ?? 0, textWeight: numericWeight, textFamily: fontFamily ?? '', textColor: processedColor, textAlignment: textAlign ?? 'auto', rightToLeft: rightToLeft, onSizeChange: onSizeChange }));
159
159
  });
@@ -46,18 +46,18 @@ export function NitroText({ children, fontSize, fontWeight, fontFamily, color, l
46
46
  native.text = text;
47
47
  native.style = style == null ? { width: Math.ceil(width), height } : [{ width: Math.ceil(width), height }, style];
48
48
  if (size !== 17)
49
- native.fontSize = size;
49
+ native.textSize = size;
50
50
  if (weight !== 400)
51
- native.fontWeight = weight;
51
+ native.textWeight = weight;
52
52
  if (family !== '')
53
- native.fontFamily = family;
53
+ native.textFamily = family;
54
54
  if (spacing !== 0)
55
- native.letterSpacing = spacing;
55
+ native.textLetterSpacing = spacing;
56
56
  const processedColor = toProcessedColor(color);
57
57
  if (processedColor !== undefined)
58
- native.color = processedColor;
58
+ native.textColor = processedColor;
59
59
  if (textAlign !== undefined)
60
- native.textAlign = textAlign;
60
+ native.textAlignment = textAlign;
61
61
  if (duration !== undefined)
62
62
  native.duration = duration;
63
63
  if (easing !== undefined)
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { type ColorValue, type TextStyle, type ViewProps } from 'react-native';
2
+ import { type ColorValue, type StyleProp, type TextStyle, type ViewProps } from 'react-native';
3
3
  import { type HybridRef } from 'react-native-nitro-modules';
4
4
  import type { NitroInputAffixAlign, NitroInputAutoCapitalize, NitroInputEasing, NitroInputEffect, NitroInputKeyboardAppearance, NitroInputKeyboardType, NitroInputLabelBehavior, NitroInputMethods, NitroInputMode, NitroInputProps as NativeNitroInputProps, NitroInputReturnKeyType, NitroInputSubmitBehavior, NitroInputTextAlign, NitroInputTextAlignVertical, NitroInputSignPlacement, NitroInputVariant, NitroInputNotation, NitroInputMaskAffinity, NitroInputTextCase } from './specs/NitroInput.nitro';
5
5
  import { type NitroInputSelection, type NitroInputTransform } from './worklets';
@@ -67,7 +67,14 @@ export interface NitroInputKeyPressEvent {
67
67
  target: number;
68
68
  };
69
69
  }
70
- export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus' | 'onBlur'> {
70
+ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus' | 'onBlur' | 'style'> {
71
+ /**
72
+ * As `TextInput`'s: a view style, and the text styles it reads its
73
+ * typography from (`fontSize`, `fontWeight`, `fontFamily`, `color`,
74
+ * `letterSpacing`, `lineHeight`, `textAlign`, `textAlignVertical`). The props
75
+ * of the same name win over it.
76
+ */
77
+ style?: StyleProp<TextStyle>;
71
78
  /**
72
79
  * The text to show (controlled). The native side formats and shows what the
73
80
  * user types on its own; this prop is applied when it changes to something
@@ -494,18 +501,4 @@ export interface NitroInputHandle {
494
501
  * the glyph engine (`'reflow'`).
495
502
  */
496
503
  export type NitroInputTransition = 'none' | 'reflow';
497
- /**
498
- * A native text input: a system field (`UITextField` / `EditText`) that owns
499
- * the keyboard, editing, selection, paste and accessibility, with native
500
- * formatting (`mode="number"`), native masking (`mode="mask"`), an outlined
501
- * or filled frame with a floating label, and optionally the glyph engine
502
- * (`transition="reflow"`), under which characters that stay glide to their new place, new
503
- * ones slide or fade in and removed ones leave alongside their neighbours.
504
- * In `'number'` mode every edit is formatted on the native side before a
505
- * frame is drawn, with the caret kept in place, so there is never an
506
- * unformatted frame and never a round trip through JS.
507
- *
508
- * Like a `TextInput`, it takes its width from its parent; `autoWidth` sizes
509
- * it to its content instead, and is on by default when the text reflows.
510
- */
511
504
  export declare const NitroInput: React.ForwardRefExoticComponent<NitroInputProps & React.RefAttributes<NitroInputHandle>>;
@@ -220,7 +220,7 @@ export interface NitroInputProps extends HybridViewProps {
220
220
  /** Vertical alignment of `suffix` relative to the text (the wrapper folds its `affixAlign` into this). */
221
221
  suffixAlign: NitroInputAffixAlign;
222
222
  /** Points added after every glyph, like `Text`'s `letterSpacing`; an affix gets it in proportion to its size. */
223
- letterSpacing: number;
223
+ textLetterSpacing: number;
224
224
  /** Points between the prefix and the text, in place of the letter spacing there. Not finite: the letter spacing. */
225
225
  prefixSpacing: number;
226
226
  /** Points between the text and the suffix, in place of the letter spacing there. Not finite: the letter spacing. */
@@ -242,7 +242,7 @@ export interface NitroInputProps extends HybridViewProps {
242
242
  /** How characters enter and leave. Default: `'auto'`. */
243
243
  effect: NitroInputEffect;
244
244
  /** Font size of the text in points. Default: `32`. */
245
- fontSize: number;
245
+ textSize: number;
246
246
  /**
247
247
  * Height of the line box in points — the CSS meaning: the total height a
248
248
  * line occupies, not extra leading. `0` (the default) uses the font's own.
@@ -255,15 +255,15 @@ export interface NitroInputProps extends HybridViewProps {
255
255
  * `lineHeight < font.lineHeight`), and the reason a compressed `lineHeight`
256
256
  * renders off-centre on a `TextInput`.
257
257
  */
258
- lineHeight: number;
258
+ textLineHeight: number;
259
259
  /** Numeric font weight, `100`–`900`. Default: `400`. */
260
- fontWeight: number;
260
+ textWeight: number;
261
261
  /** Font family name; empty = system font. */
262
- fontFamily: string;
262
+ textFamily: string;
263
263
  /** Text color as a processed ARGB integer; `NaN` = platform label color. */
264
- color: number;
264
+ textColor: number;
265
265
  /** Where the text sits when the view is wider than it. Default: `'auto'`, the start edge. */
266
- textAlign: NitroInputTextAlign;
266
+ textAlignment: NitroInputTextAlign;
267
267
  /**
268
268
  * Lay the field out right-to-left: `'auto'` alignment resolves to the right
269
269
  * edge, the prefix moves to the right and the suffix to the left, and a
@@ -314,7 +314,16 @@ export interface NitroInputProps extends HybridViewProps {
314
314
  */
315
315
  numberOfLines: number;
316
316
  /** `multiline`: where the text sits in the box. Default: `'auto'` (top). */
317
- textAlignVertical: NitroInputTextAlignVertical;
317
+ textVerticalAlignment: NitroInputTextAlignVertical;
318
+ /**
319
+ * The style's padding and border, in points, resolved per edge by
320
+ * `NitroInput`. Android insets the text, the overlay and the frame by them;
321
+ * on iOS React Native already lays the view's content out inside them.
322
+ */
323
+ textInsetLeft: number;
324
+ textInsetTop: number;
325
+ textInsetRight: number;
326
+ textInsetBottom: number;
318
327
  /**
319
328
  * `multiline`: whether the field scrolls once the text is taller than it.
320
329
  * Turning it off lets a growing field drive its own height. Default: `true`.
@@ -0,0 +1,67 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules';
2
+ import type { NitroInputCharacterMapping, NitroInputLabelBehavior, NitroInputMaskAffinity, NitroInputMode, NitroInputNotation, NitroInputSignPlacement, NitroInputTextCase, NitroInputVariant } from './NitroInput.nitro';
3
+ /**
4
+ * What a field's size follows: the subset of `NitroInputProps` the
5
+ * native views read when they report `onSizeChange`, under the same names and
6
+ * already resolved the same way by `NitroInput`.
7
+ */
8
+ export interface NitroInputSizing {
9
+ text: string;
10
+ mode: NitroInputMode;
11
+ plain: boolean;
12
+ multiline: boolean;
13
+ secureTextEntry: boolean;
14
+ maxLength: number;
15
+ fractionDigits: number;
16
+ maxIntegerDigits: number;
17
+ groupingSeparator: string;
18
+ decimalSeparator: string;
19
+ prefix: string;
20
+ suffix: string;
21
+ signPlacement: NitroInputSignPlacement;
22
+ placeholder: string;
23
+ mask: string;
24
+ maskNotations: NitroInputNotation[];
25
+ maskAutocomplete: boolean;
26
+ maskAutoSkip: boolean;
27
+ maskAffinityFormats: string[];
28
+ maskAffinityStrategy: NitroInputMaskAffinity;
29
+ maskTextCase: NitroInputTextCase;
30
+ maskCharacterMap: NitroInputCharacterMapping[];
31
+ maskSlotPlaceholder: string;
32
+ keepPlaceholder: boolean;
33
+ textSize: number;
34
+ textLineHeight: number;
35
+ prefixFontSize: number;
36
+ suffixFontSize: number;
37
+ textWeight: number;
38
+ textFamily: string;
39
+ textLetterSpacing: number;
40
+ prefixSpacing: number;
41
+ suffixSpacing: number;
42
+ allowFontScaling: boolean;
43
+ maxFontSizeMultiplier: number;
44
+ variant: NitroInputVariant;
45
+ label: string;
46
+ labelBehavior: NitroInputLabelBehavior;
47
+ labelFontSize: number;
48
+ cornerRadius: number;
49
+ }
50
+ /** A size in points (iOS) or dp (Android). */
51
+ export interface NitroInputSize {
52
+ width: number;
53
+ height: number;
54
+ }
55
+ /**
56
+ * Measures a single-line field on the JS thread, before its view exists, with
57
+ * the code the view sizes itself with: `NitroInput` lays out at its real size
58
+ * in the commit that mounts it, as React Native's `TextInput` does, instead of
59
+ * at its parent's width until the view's first `onSizeChange` arrives.
60
+ */
61
+ export interface NitroInputMeasure extends HybridObject<{
62
+ ios: 'swift';
63
+ android: 'kotlin';
64
+ }> {
65
+ /** What the field reports through `onSizeChange` once mounted, unfocused. */
66
+ measure(sizing: NitroInputSizing): NitroInputSize;
67
+ }
@@ -178,7 +178,7 @@ export interface NitroNumberProps extends HybridViewProps {
178
178
  /** A pause after each sweep, in ms. Default: `0`. */
179
179
  shimmerDelay?: number;
180
180
  /** Font size of the digits in points. Default: `32`. */
181
- fontSize?: number;
181
+ textSize?: number;
182
182
  /** Font size of `prefix` in points. Defaults to `fontSize`. */
183
183
  prefixFontSize?: number;
184
184
  /** Font size of `suffix` in points. Defaults to `fontSize`. */
@@ -190,7 +190,7 @@ export interface NitroNumberProps extends HybridViewProps {
190
190
  /** Vertical alignment of `suffix` only. Defaults to `affixAlign`. */
191
191
  suffixAlign?: NitroNumberAffixAlign;
192
192
  /** Points added after every glyph, like `Text`'s `letterSpacing`; an affix gets it in proportion to its size. Default: `0`. */
193
- letterSpacing?: number;
193
+ textLetterSpacing?: number;
194
194
  /** Points between the prefix and the digits, in place of the letter spacing there. Not finite: the letter spacing. */
195
195
  prefixSpacing?: number;
196
196
  /** Points between the digits and the suffix, in place of the letter spacing there. Not finite: the letter spacing. */
@@ -256,13 +256,13 @@ export interface NitroNumberProps extends HybridViewProps {
256
256
  /** Upper bound for `allowFontScaling`, e.g. `1.3`. `0` means no cap. Default: `0`. */
257
257
  maxFontSizeMultiplier?: number;
258
258
  /** Numeric font weight, `100`–`900`. Default: `400`. */
259
- fontWeight?: number;
259
+ textWeight?: number;
260
260
  /** Font family name. Defaults to the system font. */
261
- fontFamily?: string;
261
+ textFamily?: string;
262
262
  /** Text color as a processed ARGB integer (from `processColor`). Defaults to the platform label color. */
263
- color?: number;
263
+ textColor?: number;
264
264
  /** Where the number sits inside the view when the view is wider than the number. Default: `'auto'`, the start edge. */
265
- textAlign?: NitroNumberTextAlign;
265
+ textAlignment?: NitroNumberTextAlign;
266
266
  /**
267
267
  * Lay the figure out right-to-left: `'auto'` alignment resolves to the right
268
268
  * edge, the prefix moves to the right and the suffix to the left, and the
@@ -15,16 +15,16 @@ import type { NitroInputEasing, NitroInputEffect } from './NitroInput.nitro';
15
15
  export interface NitroTextProps extends HybridViewProps {
16
16
  text: string;
17
17
  /** In points, already scaled for the system text size when the wrapper was asked to. Default 17. */
18
- fontSize?: number;
18
+ textSize?: number;
19
19
  /** Numeric weight, 100–900. Default 400. */
20
- fontWeight?: number;
20
+ textWeight?: number;
21
21
  /** Default: the system font. */
22
- fontFamily?: string;
22
+ textFamily?: string;
23
23
  /** Processed ARGB. Default: the platform label colour. */
24
- color?: number;
24
+ textColor?: number;
25
25
  /** Points after every character. */
26
- letterSpacing?: number;
27
- textAlign?: NitroNumberTextAlign;
26
+ textLetterSpacing?: number;
27
+ textAlignment?: NitroNumberTextAlign;
28
28
  rightToLeft?: boolean;
29
29
  /** Of a morph, in ms. Default 400. */
30
30
  duration?: number;