react-native-nitro-input 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +2 -1
- package/android/src/main/java/com/margelo/nitro/nitroinput/DigitSlots.kt +143 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +6 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/InputFonts.kt +50 -5
- package/android/src/main/java/com/margelo/nitro/nitroinput/InputSizing.kt +7 -1
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputView.kt +57 -6
- package/ios/HybridNitroInputView.swift +4 -0
- package/ios/InputSizing.swift +98 -4
- package/ios/NitroInputView.swift +79 -12
- package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +2 -0
- package/lib/commonjs/src/NitroInput.js +3 -1
- package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +2 -0
- package/lib/module/src/NitroInput.js +3 -1
- package/lib/typescript/src/NitroInput.d.ts +11 -0
- package/lib/typescript/src/specs/NitroInput.nitro.d.ts +4 -0
- package/lib/typescript/src/specs/NitroInputMeasure.nitro.d.ts +2 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +18 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +4 -0
- package/nitrogen/generated/android/c++/JNitroInputSizing.hpp +9 -1
- package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +10 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +12 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputSizing.kt +12 -2
- package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +12 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +12 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +22 -0
- package/nitrogen/generated/ios/swift/NitroInputSizing.swift +12 -2
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/NitroInputSizing.hpp +9 -1
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +6 -0
- package/nitrogen/generated/shared/json/NitroInputViewConfig.json +2 -0
- package/package.json +1 -1
- package/src/NitroInput.tsx +14 -0
- package/src/specs/NitroInput.nitro.ts +4 -0
- package/src/specs/NitroInputMeasure.nitro.ts +2 -0
|
@@ -94,6 +94,8 @@ namespace margelo::nitro::nitroinput {
|
|
|
94
94
|
double textWeight SWIFT_PRIVATE;
|
|
95
95
|
std::string textFamily SWIFT_PRIVATE;
|
|
96
96
|
double textLetterSpacing SWIFT_PRIVATE;
|
|
97
|
+
bool tabularNums SWIFT_PRIVATE;
|
|
98
|
+
bool slotDigits SWIFT_PRIVATE;
|
|
97
99
|
double prefixSpacing SWIFT_PRIVATE;
|
|
98
100
|
double suffixSpacing SWIFT_PRIVATE;
|
|
99
101
|
bool allowFontScaling SWIFT_PRIVATE;
|
|
@@ -106,7 +108,7 @@ namespace margelo::nitro::nitroinput {
|
|
|
106
108
|
|
|
107
109
|
public:
|
|
108
110
|
NitroInputSizing() = default;
|
|
109
|
-
explicit NitroInputSizing(std::string text, NitroInputMode mode, bool plain, bool multiline, bool secureTextEntry, double maxLength, double fractionDigits, double maxIntegerDigits, std::string groupingSeparator, std::string decimalSeparator, std::string prefix, std::string suffix, NitroInputSignPlacement signPlacement, std::string placeholder, std::string mask, std::vector<NitroInputNotation> maskNotations, bool maskAutocomplete, bool maskAutoSkip, std::vector<std::string> maskAffinityFormats, NitroInputMaskAffinity maskAffinityStrategy, NitroInputTextCase maskTextCase, std::vector<NitroInputCharacterMapping> maskCharacterMap, std::string maskSlotPlaceholder, bool keepPlaceholder, double textSize, double textLineHeight, double prefixFontSize, double suffixFontSize, double textWeight, std::string textFamily, double textLetterSpacing, double prefixSpacing, double suffixSpacing, bool allowFontScaling, double maxFontSizeMultiplier, NitroInputVariant variant, std::string label, NitroInputLabelBehavior labelBehavior, double labelFontSize, double cornerRadius): text(text), mode(mode), plain(plain), multiline(multiline), secureTextEntry(secureTextEntry), maxLength(maxLength), fractionDigits(fractionDigits), maxIntegerDigits(maxIntegerDigits), groupingSeparator(groupingSeparator), decimalSeparator(decimalSeparator), prefix(prefix), suffix(suffix), signPlacement(signPlacement), placeholder(placeholder), mask(mask), maskNotations(maskNotations), maskAutocomplete(maskAutocomplete), maskAutoSkip(maskAutoSkip), maskAffinityFormats(maskAffinityFormats), maskAffinityStrategy(maskAffinityStrategy), maskTextCase(maskTextCase), maskCharacterMap(maskCharacterMap), maskSlotPlaceholder(maskSlotPlaceholder), keepPlaceholder(keepPlaceholder), textSize(textSize), textLineHeight(textLineHeight), prefixFontSize(prefixFontSize), suffixFontSize(suffixFontSize), textWeight(textWeight), textFamily(textFamily), textLetterSpacing(textLetterSpacing), prefixSpacing(prefixSpacing), suffixSpacing(suffixSpacing), allowFontScaling(allowFontScaling), maxFontSizeMultiplier(maxFontSizeMultiplier), variant(variant), label(label), labelBehavior(labelBehavior), labelFontSize(labelFontSize), cornerRadius(cornerRadius) {}
|
|
111
|
+
explicit NitroInputSizing(std::string text, NitroInputMode mode, bool plain, bool multiline, bool secureTextEntry, double maxLength, double fractionDigits, double maxIntegerDigits, std::string groupingSeparator, std::string decimalSeparator, std::string prefix, std::string suffix, NitroInputSignPlacement signPlacement, std::string placeholder, std::string mask, std::vector<NitroInputNotation> maskNotations, bool maskAutocomplete, bool maskAutoSkip, std::vector<std::string> maskAffinityFormats, NitroInputMaskAffinity maskAffinityStrategy, NitroInputTextCase maskTextCase, std::vector<NitroInputCharacterMapping> maskCharacterMap, std::string maskSlotPlaceholder, bool keepPlaceholder, double textSize, double textLineHeight, double prefixFontSize, double suffixFontSize, double textWeight, std::string textFamily, double textLetterSpacing, bool tabularNums, bool slotDigits, double prefixSpacing, double suffixSpacing, bool allowFontScaling, double maxFontSizeMultiplier, NitroInputVariant variant, std::string label, NitroInputLabelBehavior labelBehavior, double labelFontSize, double cornerRadius): text(text), mode(mode), plain(plain), multiline(multiline), secureTextEntry(secureTextEntry), maxLength(maxLength), fractionDigits(fractionDigits), maxIntegerDigits(maxIntegerDigits), groupingSeparator(groupingSeparator), decimalSeparator(decimalSeparator), prefix(prefix), suffix(suffix), signPlacement(signPlacement), placeholder(placeholder), mask(mask), maskNotations(maskNotations), maskAutocomplete(maskAutocomplete), maskAutoSkip(maskAutoSkip), maskAffinityFormats(maskAffinityFormats), maskAffinityStrategy(maskAffinityStrategy), maskTextCase(maskTextCase), maskCharacterMap(maskCharacterMap), maskSlotPlaceholder(maskSlotPlaceholder), keepPlaceholder(keepPlaceholder), textSize(textSize), textLineHeight(textLineHeight), prefixFontSize(prefixFontSize), suffixFontSize(suffixFontSize), textWeight(textWeight), textFamily(textFamily), textLetterSpacing(textLetterSpacing), tabularNums(tabularNums), slotDigits(slotDigits), prefixSpacing(prefixSpacing), suffixSpacing(suffixSpacing), allowFontScaling(allowFontScaling), maxFontSizeMultiplier(maxFontSizeMultiplier), variant(variant), label(label), labelBehavior(labelBehavior), labelFontSize(labelFontSize), cornerRadius(cornerRadius) {}
|
|
110
112
|
|
|
111
113
|
public:
|
|
112
114
|
friend bool operator==(const NitroInputSizing& lhs, const NitroInputSizing& rhs) = default;
|
|
@@ -153,6 +155,8 @@ namespace margelo::nitro {
|
|
|
153
155
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "textWeight"))),
|
|
154
156
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "textFamily"))),
|
|
155
157
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "textLetterSpacing"))),
|
|
158
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tabularNums"))),
|
|
159
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "slotDigits"))),
|
|
156
160
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "prefixSpacing"))),
|
|
157
161
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "suffixSpacing"))),
|
|
158
162
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowFontScaling"))),
|
|
@@ -197,6 +201,8 @@ namespace margelo::nitro {
|
|
|
197
201
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "textWeight"), JSIConverter<double>::toJSI(runtime, arg.textWeight));
|
|
198
202
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "textFamily"), JSIConverter<std::string>::toJSI(runtime, arg.textFamily));
|
|
199
203
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "textLetterSpacing"), JSIConverter<double>::toJSI(runtime, arg.textLetterSpacing));
|
|
204
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "tabularNums"), JSIConverter<bool>::toJSI(runtime, arg.tabularNums));
|
|
205
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "slotDigits"), JSIConverter<bool>::toJSI(runtime, arg.slotDigits));
|
|
200
206
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "prefixSpacing"), JSIConverter<double>::toJSI(runtime, arg.prefixSpacing));
|
|
201
207
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "suffixSpacing"), JSIConverter<double>::toJSI(runtime, arg.suffixSpacing));
|
|
202
208
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "allowFontScaling"), JSIConverter<bool>::toJSI(runtime, arg.allowFontScaling));
|
|
@@ -247,6 +253,8 @@ namespace margelo::nitro {
|
|
|
247
253
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "textWeight")))) return false;
|
|
248
254
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "textFamily")))) return false;
|
|
249
255
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "textLetterSpacing")))) return false;
|
|
256
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tabularNums")))) return false;
|
|
257
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "slotDigits")))) return false;
|
|
250
258
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "prefixSpacing")))) return false;
|
|
251
259
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "suffixSpacing")))) return false;
|
|
252
260
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowFontScaling")))) return false;
|
|
@@ -57,6 +57,8 @@ namespace margelo::nitro::nitroinput::views {
|
|
|
57
57
|
prefixAlign(nitro::ReactProp<NitroInputAffixAlign>::fromRawValue("NitroInputView", "prefixAlign", rawProps, sourceProps.prefixAlign)),
|
|
58
58
|
suffixAlign(nitro::ReactProp<NitroInputAffixAlign>::fromRawValue("NitroInputView", "suffixAlign", rawProps, sourceProps.suffixAlign)),
|
|
59
59
|
textLetterSpacing(nitro::ReactProp<double>::fromRawValue("NitroInputView", "textLetterSpacing", rawProps, sourceProps.textLetterSpacing)),
|
|
60
|
+
tabularNums(nitro::ReactProp<bool>::fromRawValue("NitroInputView", "tabularNums", rawProps, sourceProps.tabularNums)),
|
|
61
|
+
slotDigits(nitro::ReactProp<bool>::fromRawValue("NitroInputView", "slotDigits", rawProps, sourceProps.slotDigits)),
|
|
60
62
|
prefixSpacing(nitro::ReactProp<double>::fromRawValue("NitroInputView", "prefixSpacing", rawProps, sourceProps.prefixSpacing)),
|
|
61
63
|
suffixSpacing(nitro::ReactProp<double>::fromRawValue("NitroInputView", "suffixSpacing", rawProps, sourceProps.suffixSpacing)),
|
|
62
64
|
prefixOffset(nitro::ReactProp<double>::fromRawValue("NitroInputView", "prefixOffset", rawProps, sourceProps.prefixOffset)),
|
|
@@ -170,6 +172,8 @@ namespace margelo::nitro::nitroinput::views {
|
|
|
170
172
|
case hashString("prefixAlign"): return true;
|
|
171
173
|
case hashString("suffixAlign"): return true;
|
|
172
174
|
case hashString("textLetterSpacing"): return true;
|
|
175
|
+
case hashString("tabularNums"): return true;
|
|
176
|
+
case hashString("slotDigits"): return true;
|
|
173
177
|
case hashString("prefixSpacing"): return true;
|
|
174
178
|
case hashString("suffixSpacing"): return true;
|
|
175
179
|
case hashString("prefixOffset"): return true;
|
|
@@ -99,6 +99,8 @@ namespace margelo::nitro::nitroinput::views {
|
|
|
99
99
|
nitro::ReactProp<NitroInputAffixAlign> prefixAlign;
|
|
100
100
|
nitro::ReactProp<NitroInputAffixAlign> suffixAlign;
|
|
101
101
|
nitro::ReactProp<double> textLetterSpacing;
|
|
102
|
+
nitro::ReactProp<bool> tabularNums;
|
|
103
|
+
nitro::ReactProp<bool> slotDigits;
|
|
102
104
|
nitro::ReactProp<double> prefixSpacing;
|
|
103
105
|
nitro::ReactProp<double> suffixSpacing;
|
|
104
106
|
nitro::ReactProp<double> prefixOffset;
|
|
@@ -212,6 +214,8 @@ namespace margelo::nitro::nitroinput::views {
|
|
|
212
214
|
prefixAlign.hasSameValue(other.prefixAlign) &&
|
|
213
215
|
suffixAlign.hasSameValue(other.suffixAlign) &&
|
|
214
216
|
textLetterSpacing.hasSameValue(other.textLetterSpacing) &&
|
|
217
|
+
tabularNums.hasSameValue(other.tabularNums) &&
|
|
218
|
+
slotDigits.hasSameValue(other.slotDigits) &&
|
|
215
219
|
prefixSpacing.hasSameValue(other.prefixSpacing) &&
|
|
216
220
|
suffixSpacing.hasSameValue(other.suffixSpacing) &&
|
|
217
221
|
prefixOffset.hasSameValue(other.prefixOffset) &&
|
|
@@ -326,6 +330,8 @@ namespace margelo::nitro::nitroinput::views {
|
|
|
326
330
|
prefixAlign.isProvided() ||
|
|
327
331
|
suffixAlign.isProvided() ||
|
|
328
332
|
textLetterSpacing.isProvided() ||
|
|
333
|
+
tabularNums.isProvided() ||
|
|
334
|
+
slotDigits.isProvided() ||
|
|
329
335
|
prefixSpacing.isProvided() ||
|
|
330
336
|
suffixSpacing.isProvided() ||
|
|
331
337
|
prefixOffset.isProvided() ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-input",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Native text for React Native, built with Nitro: a text and amount input with native formatting, masks and a Torph-style reflow, and an animated number (odometer, SwiftUI-style numeric text, ticker) whose digits roll or swap natively, with currency layouts and animated currency switches, shrink-to-fit, a loading shimmer and a jackpot reveal.",
|
|
5
5
|
"main": "lib/commonjs/src/index.js",
|
|
6
6
|
"module": "lib/module/src/index.js",
|
package/src/NitroInput.tsx
CHANGED
|
@@ -445,6 +445,17 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
445
445
|
* Default: `0`.
|
|
446
446
|
*/
|
|
447
447
|
letterSpacing?: number
|
|
448
|
+
/**
|
|
449
|
+
* Unset (the default): the font's tabular figures, where it has them (the
|
|
450
|
+
* system fonts do), at no cost. `true`: every digit as wide as the widest
|
|
451
|
+
* even in a font without them (Open Runde), laid out that wide and centred,
|
|
452
|
+
* so typing over a `keepPlaceholder` mask never moves what is still to come
|
|
453
|
+
* and an amount keeps its width as its digits change; that layout costs a
|
|
454
|
+
* little on each change. `false`: the font's proportional figures. A
|
|
455
|
+
* style's `fontVariant: ['proportional-nums']` is `false` too, as on a
|
|
456
|
+
* `TextInput`; the prop wins.
|
|
457
|
+
*/
|
|
458
|
+
tabularNums?: boolean
|
|
448
459
|
/** Points between the prefix and the text, in place of the letter spacing there. Defaults to the letter spacing. */
|
|
449
460
|
prefixSpacing?: number
|
|
450
461
|
/** Points between the text and the suffix, in place of the letter spacing there. Defaults to the letter spacing. */
|
|
@@ -842,6 +853,7 @@ export const NitroInput = forwardRef<NitroInputHandle, NitroInputProps>(
|
|
|
842
853
|
prefixAlign,
|
|
843
854
|
suffixAlign,
|
|
844
855
|
letterSpacing: letterSpacingProp,
|
|
856
|
+
tabularNums,
|
|
845
857
|
prefixSpacing,
|
|
846
858
|
suffixSpacing,
|
|
847
859
|
prefixOffset,
|
|
@@ -1537,6 +1549,8 @@ export const NitroInput = forwardRef<NitroInputHandle, NitroInputProps>(
|
|
|
1537
1549
|
textWeight: numericWeight,
|
|
1538
1550
|
textFamily: fontFamily ?? '',
|
|
1539
1551
|
textLetterSpacing: letterSpacing ?? 0,
|
|
1552
|
+
tabularNums: tabularNums ?? !flat?.fontVariant?.includes('proportional-nums'),
|
|
1553
|
+
slotDigits: tabularNums === true,
|
|
1540
1554
|
prefixSpacing: prefixSpacing ?? Infinity,
|
|
1541
1555
|
suffixSpacing: suffixSpacing ?? Infinity,
|
|
1542
1556
|
allowFontScaling: allowFontScaling ?? false,
|
|
@@ -268,6 +268,10 @@ export interface NitroInputProps extends HybridViewProps {
|
|
|
268
268
|
suffixAlign: NitroInputAffixAlign
|
|
269
269
|
/** Points added after every glyph, like `Text`'s `letterSpacing`; an affix gets it in proportion to its size. */
|
|
270
270
|
textLetterSpacing: number
|
|
271
|
+
/** The font's tabular figures (`tnum`) rather than its proportional ones. */
|
|
272
|
+
tabularNums: boolean
|
|
273
|
+
/** Every digit laid out as wide as the widest, centred: tabular figures for a font without them. */
|
|
274
|
+
slotDigits: boolean
|
|
271
275
|
/** Points between the prefix and the text, in place of the letter spacing there. Not finite: the letter spacing. */
|
|
272
276
|
prefixSpacing: number
|
|
273
277
|
/** Points between the text and the suffix, in place of the letter spacing there. Not finite: the letter spacing. */
|