react-native-nitro-input 0.2.0 → 0.3.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.
- package/CHANGELOG.md +38 -0
- package/README.md +43 -1
- package/android/CMakeLists.txt +4 -0
- package/android/gradle.properties +1 -1
- package/android/src/main/cpp/JRollingEngine.cpp +3 -2
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +20 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberFormatPlatform.kt +209 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberView.kt +25 -0
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputView.kt +69 -10
- package/android/src/main/java/com/margelo/nitro/nitroinput/NitroNumberView.kt +164 -24
- package/android/src/main/java/com/margelo/nitro/nitroinput/RollingEngine.kt +2 -1
- package/cpp/RollingEngine.cpp +12 -2
- package/cpp/RollingEngine.hpp +8 -1
- package/cpp/numberformat/HybridNitroNumberFormat.cpp +498 -0
- package/cpp/numberformat/HybridNitroNumberFormat.hpp +74 -0
- package/cpp/numberformat/HybridNitroNumberFormatFactory.hpp +11 -0
- package/cpp/numberformat/NumberFormatCore.cpp +629 -0
- package/cpp/numberformat/NumberFormatCore.hpp +154 -0
- package/cpp/numberformat/NumberFormatProbe.cpp +354 -0
- package/cpp/numberformat/NumberFormatProbe.hpp +63 -0
- package/ios/HybridNitroInputView.swift +15 -0
- package/ios/HybridNitroNumberFormatPlatform.swift +348 -0
- package/ios/HybridNitroNumberView.swift +19 -0
- package/ios/NitroInputView.swift +79 -19
- package/ios/NitroNumberView.swift +171 -31
- package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
- package/lib/commonjs/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -0
- package/lib/commonjs/src/NitroInput.js +8 -6
- package/lib/commonjs/src/NitroNumber.js +4 -2
- package/lib/commonjs/src/NumberFormat.js +525 -0
- package/lib/commonjs/src/formatProps.js +48 -0
- package/lib/commonjs/src/index.js +3 -1
- package/lib/commonjs/src/specs/NumberFormat.nitro.js +2 -0
- package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
- package/lib/module/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -0
- package/lib/module/src/NitroInput.js +8 -6
- package/lib/module/src/NitroNumber.js +4 -2
- package/lib/module/src/NumberFormat.js +521 -0
- package/lib/module/src/formatProps.js +45 -0
- package/lib/module/src/index.js +1 -0
- package/lib/module/src/specs/NumberFormat.nitro.js +1 -0
- package/lib/typescript/src/NitroInput.d.ts +22 -0
- package/lib/typescript/src/NitroNumber.d.ts +36 -1
- package/lib/typescript/src/NumberFormat.d.ts +47 -0
- package/lib/typescript/src/formatProps.d.ts +21 -0
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/specs/NitroInput.nitro.d.ts +10 -0
- package/lib/typescript/src/specs/NitroNumber.nitro.d.ts +13 -1
- package/lib/typescript/src/specs/NumberFormat.nitro.d.ts +139 -0
- package/nitro.json +16 -0
- package/nitrogen/generated/android/NitroInput+autolinking.cmake +6 -0
- package/nitrogen/generated/android/NitroInputOnLoad.cpp +28 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +45 -0
- package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +10 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberFormatPlatformSpec.cpp +118 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberFormatPlatformSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.cpp +54 -0
- package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.hpp +12 -0
- package/nitrogen/generated/android/c++/JHybridNitroPlatformNumberFormatterSpec.cpp +65 -0
- package/nitrogen/generated/android/c++/JHybridNitroPlatformNumberFormatterSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroNumberDirection.hpp +3 -0
- package/nitrogen/generated/android/c++/JNumberFormatCompactDisplay.hpp +58 -0
- package/nitrogen/generated/android/c++/JNumberFormatCurrencyDisplay.hpp +64 -0
- package/nitrogen/generated/android/c++/JNumberFormatCurrencySign.hpp +58 -0
- package/nitrogen/generated/android/c++/JNumberFormatNotation.hpp +64 -0
- package/nitrogen/generated/android/c++/JNumberFormatPlatformOptions.hpp +161 -0
- package/nitrogen/generated/android/c++/JNumberFormatPlatformSymbols.hpp +89 -0
- package/nitrogen/generated/android/c++/JNumberFormatRoundingMode.hpp +79 -0
- package/nitrogen/generated/android/c++/JNumberFormatSignDisplay.hpp +67 -0
- package/nitrogen/generated/android/c++/JNumberFormatStyle.hpp +64 -0
- package/nitrogen/generated/android/c++/JNumberFormatUnitDisplay.hpp +61 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +25 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.cpp +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberFormatPlatformSpec.kt +60 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberViewSpec.kt +36 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroPlatformNumberFormatterSpec.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroNumberDirection.kt +2 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCompactDisplay.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCurrencyDisplay.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatCurrencySign.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatNotation.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatPlatformOptions.kt +136 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatPlatformSymbols.kt +91 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatRoundingMode.kt +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatSignDisplay.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatStyle.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NumberFormatUnitDisplay.kt +24 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.cpp +34 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +63 -0
- package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +40 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.mm +18 -0
- package/nitrogen/generated/ios/NitroInputAutolinking.swift +12 -0
- package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +30 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberFormatPlatformSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberFormatPlatformSpecSwift.hpp +122 -0
- package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.hpp +42 -0
- package/nitrogen/generated/ios/c++/HybridNitroPlatformNumberFormatterSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroPlatformNumberFormatterSpecSwift.hpp +94 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +30 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroNumberViewComponent.mm +36 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +5 -0
- package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +55 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberFormatPlatformSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberFormatPlatformSpec_cxx.swift +159 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec.swift +6 -0
- package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec_cxx.swift +144 -0
- package/nitrogen/generated/ios/swift/HybridNitroPlatformNumberFormatterSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridNitroPlatformNumberFormatterSpec_cxx.swift +155 -0
- package/nitrogen/generated/ios/swift/NitroNumberDirection.swift +4 -0
- package/nitrogen/generated/ios/swift/NumberFormatCompactDisplay.swift +40 -0
- package/nitrogen/generated/ios/swift/NumberFormatCurrencyDisplay.swift +48 -0
- package/nitrogen/generated/ios/swift/NumberFormatCurrencySign.swift +40 -0
- package/nitrogen/generated/ios/swift/NumberFormatNotation.swift +48 -0
- package/nitrogen/generated/ios/swift/NumberFormatPlatformOptions.swift +159 -0
- package/nitrogen/generated/ios/swift/NumberFormatPlatformSymbols.swift +69 -0
- package/nitrogen/generated/ios/swift/NumberFormatRoundingMode.swift +68 -0
- package/nitrogen/generated/ios/swift/NumberFormatSignDisplay.swift +52 -0
- package/nitrogen/generated/ios/swift/NumberFormatStyle.swift +48 -0
- package/nitrogen/generated/ios/swift/NumberFormatUnitDisplay.swift +44 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +10 -0
- package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +10 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatFactorySpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatFactorySpec.hpp +70 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatPlatformSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatPlatformSpec.hpp +70 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberFormatSpec.hpp +71 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.cpp +12 -0
- package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.hpp +12 -0
- package/nitrogen/generated/shared/c++/HybridNitroPlatformNumberFormatterSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridNitroPlatformNumberFormatterSpec.hpp +65 -0
- package/nitrogen/generated/shared/c++/NitroNumberDirection.hpp +4 -0
- package/nitrogen/generated/shared/c++/NumberFormatCompactDisplay.hpp +76 -0
- package/nitrogen/generated/shared/c++/NumberFormatCurrencyDisplay.hpp +84 -0
- package/nitrogen/generated/shared/c++/NumberFormatCurrencySign.hpp +76 -0
- package/nitrogen/generated/shared/c++/NumberFormatGrouping.hpp +80 -0
- package/nitrogen/generated/shared/c++/NumberFormatNotation.hpp +84 -0
- package/nitrogen/generated/shared/c++/NumberFormatOptions.hpp +193 -0
- package/nitrogen/generated/shared/c++/NumberFormatPart.hpp +87 -0
- package/nitrogen/generated/shared/c++/NumberFormatPlatformOptions.hpp +176 -0
- package/nitrogen/generated/shared/c++/NumberFormatPlatformSymbols.hpp +115 -0
- package/nitrogen/generated/shared/c++/NumberFormatRoundingMode.hpp +104 -0
- package/nitrogen/generated/shared/c++/NumberFormatRoundingPriority.hpp +80 -0
- package/nitrogen/generated/shared/c++/NumberFormatSignDisplay.hpp +88 -0
- package/nitrogen/generated/shared/c++/NumberFormatStyle.hpp +84 -0
- package/nitrogen/generated/shared/c++/NumberFormatTrailingZeroDisplay.hpp +76 -0
- package/nitrogen/generated/shared/c++/NumberFormatUnitDisplay.hpp +80 -0
- package/nitrogen/generated/shared/c++/ResolvedNumberFormatOptions.hpp +197 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +10 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +15 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.cpp +12 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.hpp +18 -0
- package/nitrogen/generated/shared/json/NitroInputViewConfig.json +5 -0
- package/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -0
- package/package.json +2 -2
- package/src/NitroInput.tsx +42 -7
- package/src/NitroNumber.tsx +57 -7
- package/src/NumberFormat.ts +563 -0
- package/src/formatProps.ts +59 -0
- package/src/index.ts +18 -0
- package/src/specs/NitroInput.nitro.ts +10 -0
- package/src/specs/NitroNumber.nitro.ts +13 -1
- package/src/specs/NumberFormat.nitro.ts +145 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { sharedFormatterOf } from './NumberFormat';
|
|
2
|
+
const NUMBER_PARTS = new Set(['integer', 'group', 'decimal', 'fraction']);
|
|
3
|
+
// By the native formatter, which instances built with the same locales and options share.
|
|
4
|
+
const cache = new WeakMap();
|
|
5
|
+
/**
|
|
6
|
+
* The prefix, suffix, separators and digit counts of `format`, read off its
|
|
7
|
+
* parts once and cached per formatter. The components keep their own model
|
|
8
|
+
* (a sign, a prefix, digits grouped in threes, a suffix), so a format outside
|
|
9
|
+
* it (Indian grouping, native digits, accounting parentheses) is followed as
|
|
10
|
+
* far as that model goes.
|
|
11
|
+
*/
|
|
12
|
+
export function formatProps(format) {
|
|
13
|
+
const key = sharedFormatterOf(format) ?? format;
|
|
14
|
+
const cached = cache.get(key);
|
|
15
|
+
if (cached)
|
|
16
|
+
return cached;
|
|
17
|
+
const resolved = format.resolvedOptions();
|
|
18
|
+
const fractionDigits = resolved.maximumFractionDigits ?? 0;
|
|
19
|
+
// A value with every part: groups, and a fraction when the format has one.
|
|
20
|
+
const parts = format.formatToParts(fractionDigits > 0 ? 1234567.5 : 1234567);
|
|
21
|
+
const first = parts.findIndex((p) => NUMBER_PARTS.has(p.type));
|
|
22
|
+
let last = first;
|
|
23
|
+
parts.forEach((p, i) => {
|
|
24
|
+
if (NUMBER_PARTS.has(p.type))
|
|
25
|
+
last = i;
|
|
26
|
+
});
|
|
27
|
+
const text = (from, to) => parts
|
|
28
|
+
.slice(from, to)
|
|
29
|
+
.map((p) => p.value)
|
|
30
|
+
.join('');
|
|
31
|
+
const negative = format.formatToParts(-1);
|
|
32
|
+
const minus = negative.findIndex((p) => p.type === 'minusSign');
|
|
33
|
+
const currency = negative.findIndex((p) => p.type === 'currency' || p.type === 'percentSign');
|
|
34
|
+
const props = {
|
|
35
|
+
prefix: first < 0 ? '' : text(0, first),
|
|
36
|
+
suffix: first < 0 ? '' : text(last + 1, parts.length),
|
|
37
|
+
groupingSeparator: parts.find((p) => p.type === 'group')?.value ?? '',
|
|
38
|
+
decimalSeparator: parts.find((p) => p.type === 'decimal')?.value ?? '.',
|
|
39
|
+
fractionDigits,
|
|
40
|
+
minimumIntegerDigits: resolved.minimumIntegerDigits,
|
|
41
|
+
signPlacement: minus >= 0 && currency >= 0 && minus > currency ? 'afterAffix' : 'beforeAffix',
|
|
42
|
+
};
|
|
43
|
+
cache.set(key, props);
|
|
44
|
+
return props;
|
|
45
|
+
}
|
package/lib/module/src/index.js
CHANGED
|
@@ -2,3 +2,4 @@ export { NitroInput, NativeNitroInputView, } from './NitroInput';
|
|
|
2
2
|
export { isWorklet, } from './worklets';
|
|
3
3
|
export { useNitroInputState, } from './useNitroInputState';
|
|
4
4
|
export { NitroNumber, NativeNitroNumberView, } from './NitroNumber';
|
|
5
|
+
export { NumberFormat } from './NumberFormat';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,6 +3,7 @@ import { type ColorValue, 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 } from './specs/NitroInput.nitro';
|
|
5
5
|
import { type NitroInputSelection, type NitroInputTransform } from './worklets';
|
|
6
|
+
import type { NumberFormat } from './NumberFormat';
|
|
6
7
|
/** React Native's `inputMode`, the HTML-aligned alias for `keyboardType`. */
|
|
7
8
|
export type InputMode = 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';
|
|
8
9
|
/** React Native's `enterKeyHint`, the HTML-aligned alias for `returnKeyType`. */
|
|
@@ -176,6 +177,27 @@ export interface NitroInputProps extends Omit<ViewProps, 'children' | 'onFocus'
|
|
|
176
177
|
prefixAlign?: NitroInputAffixAlign;
|
|
177
178
|
/** Alignment of `suffix` only. Defaults to `affixAlign`. */
|
|
178
179
|
suffixAlign?: NitroInputAffixAlign;
|
|
180
|
+
/**
|
|
181
|
+
* Points added after every glyph, like `Text`'s `letterSpacing` (negative
|
|
182
|
+
* tightens). A smaller prefix or suffix gets it in proportion to its size.
|
|
183
|
+
* Default: `0`.
|
|
184
|
+
*/
|
|
185
|
+
letterSpacing?: number;
|
|
186
|
+
/** Points between the prefix and the text, in place of the letter spacing there. Defaults to the letter spacing. */
|
|
187
|
+
prefixSpacing?: number;
|
|
188
|
+
/** Points between the text and the suffix, in place of the letter spacing there. Defaults to the letter spacing. */
|
|
189
|
+
suffixSpacing?: number;
|
|
190
|
+
/** Points the prefix is moved down after `prefixAlign` places it (negative: up). Default: `0`. */
|
|
191
|
+
prefixOffset?: number;
|
|
192
|
+
/** Points the suffix is moved down after `suffixAlign` places it (negative: up). Default: `0`. */
|
|
193
|
+
suffixOffset?: number;
|
|
194
|
+
/**
|
|
195
|
+
* A `NumberFormat` the amount follows: its prefix and suffix (the currency
|
|
196
|
+
* where the locale puts it), grouping and decimal separators, fraction
|
|
197
|
+
* digits and where the sign goes. Sets `mode` to `'number'` unless it is
|
|
198
|
+
* given. The individual props override what it says.
|
|
199
|
+
*/
|
|
200
|
+
format?: NumberFormat;
|
|
179
201
|
/** Shown while the field is empty and reflowed away by the first character. In `'number'` mode `'0'` reads well. */
|
|
180
202
|
placeholder?: string;
|
|
181
203
|
/** Color of the placeholder. Defaults to the platform placeholder color. */
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { type ColorValue, type TextStyle, type ViewProps } from 'react-native';
|
|
3
3
|
import { type HybridRef } from 'react-native-nitro-modules';
|
|
4
4
|
import type { NitroNumberAffixAlign, NitroNumberDirection, NitroNumberTransition, NitroNumberEasing, NitroNumberMethods, NitroNumberProps as NativeNitroNumberProps, NitroNumberRevealStyle, NitroNumberTextAlign } from './specs/NitroNumber.nitro';
|
|
5
|
+
import type { NumberFormat } from './NumberFormat';
|
|
5
6
|
/**
|
|
6
7
|
* The raw Nitro host component. Prefer {@link NitroNumber}, which adds
|
|
7
8
|
* auto-sizing, color/weight conversion and a convenient handle.
|
|
@@ -75,7 +76,12 @@ export interface NitroNumberProps extends Omit<ViewProps, 'children'> {
|
|
|
75
76
|
* (`150` for the numeric transition).
|
|
76
77
|
*/
|
|
77
78
|
stagger?: number;
|
|
78
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Which way the digits roll. `'auto'` follows the sign of the change;
|
|
81
|
+
* `'up'` / `'down'` force one; `'shortest'` rolls each digit its own
|
|
82
|
+
* shorter way round (1 → 2 is one step up even when the value falls, where
|
|
83
|
+
* `'auto'` rolls nine steps down), which is calmer on big jumps. The numeric transition and the reveal ignore it. Default: `'auto'`.
|
|
84
|
+
*/
|
|
79
85
|
direction?: NitroNumberDirection;
|
|
80
86
|
/**
|
|
81
87
|
* Jackpot reveal, the casino "you won" presentation. While `false` the view
|
|
@@ -149,6 +155,35 @@ export interface NitroNumberProps extends Omit<ViewProps, 'children'> {
|
|
|
149
155
|
prefixAlign?: NitroNumberAffixAlign;
|
|
150
156
|
/** Alignment of `suffix` only. Defaults to `affixAlign`. */
|
|
151
157
|
suffixAlign?: NitroNumberAffixAlign;
|
|
158
|
+
/**
|
|
159
|
+
* Points added after every glyph, like `Text`'s `letterSpacing` (negative
|
|
160
|
+
* tightens). A smaller prefix or suffix gets it in proportion to its size.
|
|
161
|
+
* Default: `0`.
|
|
162
|
+
*/
|
|
163
|
+
letterSpacing?: number;
|
|
164
|
+
/** Points between the prefix and the digits, in place of the letter spacing there. Defaults to the letter spacing. */
|
|
165
|
+
prefixSpacing?: number;
|
|
166
|
+
/** Points between the digits and the suffix, in place of the letter spacing there. Defaults to the letter spacing. */
|
|
167
|
+
suffixSpacing?: number;
|
|
168
|
+
/** Points the prefix is moved down after `prefixAlign` places it (negative: up). Default: `0`. */
|
|
169
|
+
prefixOffset?: number;
|
|
170
|
+
/** Points the suffix is moved down after `suffixAlign` places it (negative: up). Default: `0`. */
|
|
171
|
+
suffixOffset?: number;
|
|
172
|
+
/**
|
|
173
|
+
* `true` (the default): every digit as wide as the widest, so columns never
|
|
174
|
+
* move, what a ticker or a price wants. `false`: each digit at its own
|
|
175
|
+
* width, the font's proportional figures, for a face whose "1" is narrow
|
|
176
|
+
* (or that has no tabular figures at all); a changing column's width
|
|
177
|
+
* then eases once from the old digit's to the new one's.
|
|
178
|
+
*/
|
|
179
|
+
tabularNums?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* A `NumberFormat` the number follows: its prefix and suffix (the currency
|
|
182
|
+
* where the locale puts it), grouping and decimal separators, fraction
|
|
183
|
+
* digits and minimum integer digits. The individual props override what it
|
|
184
|
+
* says.
|
|
185
|
+
*/
|
|
186
|
+
format?: NumberFormat;
|
|
152
187
|
/**
|
|
153
188
|
* Scale the number down when the view is narrower than its content, and back
|
|
154
189
|
* up (never above `fontSize`) when it fits again. Give the view a fixed
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { NumberFormatOptions, NumberFormatPart, ResolvedNumberFormatOptions } from './specs/NumberFormat.nitro';
|
|
2
|
+
/**
|
|
3
|
+
* A number formatter with the API of `Intl.NumberFormat`, formatted natively.
|
|
4
|
+
*
|
|
5
|
+
* The locale's format is learned once from the platform (Foundation on iOS,
|
|
6
|
+
* ICU on Android, the same data Hermes' `Intl` uses) and every number after
|
|
7
|
+
* that is formatted in C++, without calling into the platform. Building a
|
|
8
|
+
* formatter with locales and options seen before reuses the native one, so
|
|
9
|
+
* there is no need to memoize them.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const php = new NumberFormat('en-PH', { style: 'currency', currency: 'PHP' })
|
|
13
|
+
* php.format(1234.5) // "₱1,234.50"
|
|
14
|
+
* php.formatToParts(-12) // works on iOS too
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* It behaves as ECMA-402 specifies `Intl.NumberFormat` (options are read,
|
|
18
|
+
* coerced and checked in the specified order, `format` is a bound getter,
|
|
19
|
+
* `NumberFormat()` works without `new`), and is checked against test262.
|
|
20
|
+
*/
|
|
21
|
+
export interface NumberFormat {
|
|
22
|
+
/** Formats a number, a bigint, or a decimal string (exactly, without going through a double). A bound function: `values.map(nf.format)` works. */
|
|
23
|
+
readonly format: (value: number | bigint | string) => string;
|
|
24
|
+
formatToParts(value: number | bigint | string): NumberFormatPart[];
|
|
25
|
+
formatRange(start: number | bigint | string, end: number | bigint | string): string;
|
|
26
|
+
formatRangeToParts(start: number | bigint | string, end: number | bigint | string): NumberFormatRangePart[];
|
|
27
|
+
resolvedOptions(): ResolvedNumberFormatOptions;
|
|
28
|
+
}
|
|
29
|
+
export interface NumberFormatRangePart extends NumberFormatPart {
|
|
30
|
+
source: 'startRange' | 'endRange' | 'shared';
|
|
31
|
+
}
|
|
32
|
+
export interface NumberFormatConstructor {
|
|
33
|
+
new (locales?: string | readonly string[], options?: NumberFormatOptions): NumberFormat;
|
|
34
|
+
(locales?: string | readonly string[], options?: NumberFormatOptions): NumberFormat;
|
|
35
|
+
readonly prototype: NumberFormat;
|
|
36
|
+
/** The given locales that have number data, as `Intl.NumberFormat.supportedLocalesOf` returns them. */
|
|
37
|
+
supportedLocalesOf(locales: string | readonly string[], options?: {
|
|
38
|
+
localeMatcher?: 'lookup' | 'best fit';
|
|
39
|
+
}): string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The native formatter behind a `NumberFormat`, which every instance with the
|
|
43
|
+
* same locales and options shares: a key for caching what is derived from one.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export declare function sharedFormatterOf(value: unknown): object | undefined;
|
|
47
|
+
export declare const NumberFormat: NumberFormatConstructor;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type NumberFormat } from './NumberFormat';
|
|
2
|
+
/** What `NitroNumber` and `NitroInput` take from a `NumberFormat` through their `format` prop. */
|
|
3
|
+
export interface FormatProps {
|
|
4
|
+
prefix: string;
|
|
5
|
+
suffix: string;
|
|
6
|
+
groupingSeparator: string;
|
|
7
|
+
decimalSeparator: string;
|
|
8
|
+
/** The digits after the decimal separator: the format's maximum. */
|
|
9
|
+
fractionDigits: number;
|
|
10
|
+
minimumIntegerDigits: number;
|
|
11
|
+
/** Whether a negative amount's sign comes before the prefix ("-$5") or after it ("$-5"). */
|
|
12
|
+
signPlacement: 'beforeAffix' | 'afterAffix';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The prefix, suffix, separators and digit counts of `format`, read off its
|
|
16
|
+
* parts once and cached per formatter. The components keep their own model
|
|
17
|
+
* (a sign, a prefix, digits grouped in threes, a suffix), so a format outside
|
|
18
|
+
* it (Indian grouping, native digits, accounting parentheses) is followed as
|
|
19
|
+
* far as that model goes.
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatProps(format: NumberFormat): FormatProps;
|
|
@@ -5,3 +5,5 @@ export type { NitroInputLabelBehavior, NitroInputMode, NitroInputNotation, Nitro
|
|
|
5
5
|
export type { NitroInputWorklets } from './specs/NitroInputWorklets.nitro';
|
|
6
6
|
export { NitroNumber, NativeNitroNumberView, type NitroNumberProps, type NitroNumberHandle, type NitroNumberRef, } from './NitroNumber';
|
|
7
7
|
export type { NitroNumberAffixAlign, NitroNumberDirection, NitroNumberTransition, NitroNumberEasing, NitroNumberRevealStyle, NitroNumberTextAlign, NitroNumberMethods, NitroNumberProps as NativeNitroNumberProps, NitroNumberView, } from './specs/NitroNumber.nitro';
|
|
8
|
+
export { NumberFormat, type NumberFormatConstructor, type NumberFormatRangePart } from './NumberFormat';
|
|
9
|
+
export type { NumberFormatOptions, NumberFormatPart, ResolvedNumberFormatOptions, NumberFormatStyle, NumberFormatCurrencyDisplay, NumberFormatCurrencySign, NumberFormatUnitDisplay, NumberFormatNotation, NumberFormatCompactDisplay, NumberFormatSignDisplay, NumberFormatRoundingMode, NumberFormatRoundingPriority, NumberFormatTrailingZeroDisplay, NumberFormatGrouping, } from './specs/NumberFormat.nitro';
|
|
@@ -176,6 +176,16 @@ export interface NitroInputProps extends HybridViewProps {
|
|
|
176
176
|
prefixAlign: NitroInputAffixAlign;
|
|
177
177
|
/** Vertical alignment of `suffix` relative to the text (the wrapper folds its `affixAlign` into this). */
|
|
178
178
|
suffixAlign: NitroInputAffixAlign;
|
|
179
|
+
/** Points added after every glyph, like `Text`'s `letterSpacing`; an affix gets it in proportion to its size. */
|
|
180
|
+
letterSpacing: number;
|
|
181
|
+
/** Points between the prefix and the text, in place of the letter spacing there. Not finite: the letter spacing. */
|
|
182
|
+
prefixSpacing: number;
|
|
183
|
+
/** Points between the text and the suffix, in place of the letter spacing there. Not finite: the letter spacing. */
|
|
184
|
+
suffixSpacing: number;
|
|
185
|
+
/** Points the prefix is moved down after its alignment (negative: up). */
|
|
186
|
+
prefixOffset: number;
|
|
187
|
+
/** Points the suffix is moved down after its alignment (negative: up). */
|
|
188
|
+
suffixOffset: number;
|
|
179
189
|
/** Shown (and reflowed away) while the field is empty. Default: `''`. */
|
|
180
190
|
placeholder: string;
|
|
181
191
|
/** Color of the placeholder as a processed ARGB integer; `NaN` = platform default. */
|
|
@@ -11,7 +11,7 @@ export type NitroNumberTextAlign = 'auto' | 'left' | 'center' | 'right';
|
|
|
11
11
|
/** Timing curve used when a value change is rolled natively. */
|
|
12
12
|
export type NitroNumberEasing = 'linear' | 'easeIn' | 'easeOut' | 'easeInOut' | 'spring';
|
|
13
13
|
/** Which way the digits roll: `'auto'` follows the sign of the change. */
|
|
14
|
-
export type NitroNumberDirection = 'auto' | 'up' | 'down';
|
|
14
|
+
export type NitroNumberDirection = 'auto' | 'up' | 'down' | 'shortest';
|
|
15
15
|
/**
|
|
16
16
|
* How a value change plays. `'roll'` is the odometer: every changed digit
|
|
17
17
|
* rolls through the digits between its old and new glyph. `'numeric'` is the
|
|
@@ -169,6 +169,18 @@ export interface NitroNumberProps extends HybridViewProps {
|
|
|
169
169
|
prefixAlign?: NitroNumberAffixAlign;
|
|
170
170
|
/** Vertical alignment of `suffix` only. Defaults to `affixAlign`. */
|
|
171
171
|
suffixAlign?: NitroNumberAffixAlign;
|
|
172
|
+
/** Points added after every glyph, like `Text`'s `letterSpacing`; an affix gets it in proportion to its size. Default: `0`. */
|
|
173
|
+
letterSpacing?: number;
|
|
174
|
+
/** Points between the prefix and the digits, in place of the letter spacing there. Not finite: the letter spacing. */
|
|
175
|
+
prefixSpacing?: number;
|
|
176
|
+
/** Points between the digits and the suffix, in place of the letter spacing there. Not finite: the letter spacing. */
|
|
177
|
+
suffixSpacing?: number;
|
|
178
|
+
/** Points the prefix is moved down after its alignment (negative: up). Default: `0`. */
|
|
179
|
+
prefixOffset?: number;
|
|
180
|
+
/** Points the suffix is moved down after its alignment (negative: up). Default: `0`. */
|
|
181
|
+
suffixOffset?: number;
|
|
182
|
+
/** Every digit as wide as the widest (`true`, the default), or each digit at its own width. */
|
|
183
|
+
tabularNums?: boolean;
|
|
172
184
|
/**
|
|
173
185
|
* When the view is narrower than the number (e.g. it has a fixed `width` or
|
|
174
186
|
* `maxWidth`), scale the whole number down so it fits. Default: `false`.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { HybridObject, Int64 } from 'react-native-nitro-modules';
|
|
2
|
+
export type NumberFormatStyle = 'decimal' | 'currency' | 'percent' | 'unit';
|
|
3
|
+
export type NumberFormatCurrencyDisplay = 'symbol' | 'narrowSymbol' | 'code' | 'name';
|
|
4
|
+
export type NumberFormatCurrencySign = 'standard' | 'accounting';
|
|
5
|
+
export type NumberFormatUnitDisplay = 'short' | 'narrow' | 'long';
|
|
6
|
+
export type NumberFormatNotation = 'standard' | 'scientific' | 'engineering' | 'compact';
|
|
7
|
+
export type NumberFormatCompactDisplay = 'short' | 'long';
|
|
8
|
+
export type NumberFormatSignDisplay = 'auto' | 'never' | 'always' | 'exceptZero' | 'negative';
|
|
9
|
+
export type NumberFormatRoundingMode = 'ceil' | 'floor' | 'expand' | 'trunc' | 'halfCeil' | 'halfFloor' | 'halfExpand' | 'halfTrunc' | 'halfEven';
|
|
10
|
+
export type NumberFormatRoundingPriority = 'auto' | 'morePrecision' | 'lessPrecision';
|
|
11
|
+
export type NumberFormatTrailingZeroDisplay = 'auto' | 'stripIfInteger';
|
|
12
|
+
export type NumberFormatGrouping = 'always' | 'auto' | 'min2';
|
|
13
|
+
/** `Intl.NumberFormatOptions`, less `localeMatcher` (the lookup matcher is always used). */
|
|
14
|
+
export interface NumberFormatOptions {
|
|
15
|
+
numberingSystem?: string;
|
|
16
|
+
style?: NumberFormatStyle;
|
|
17
|
+
currency?: string;
|
|
18
|
+
currencyDisplay?: NumberFormatCurrencyDisplay;
|
|
19
|
+
currencySign?: NumberFormatCurrencySign;
|
|
20
|
+
unit?: string;
|
|
21
|
+
unitDisplay?: NumberFormatUnitDisplay;
|
|
22
|
+
minimumIntegerDigits?: number;
|
|
23
|
+
minimumFractionDigits?: number;
|
|
24
|
+
maximumFractionDigits?: number;
|
|
25
|
+
minimumSignificantDigits?: number;
|
|
26
|
+
maximumSignificantDigits?: number;
|
|
27
|
+
roundingPriority?: NumberFormatRoundingPriority;
|
|
28
|
+
roundingIncrement?: number;
|
|
29
|
+
roundingMode?: NumberFormatRoundingMode;
|
|
30
|
+
trailingZeroDisplay?: NumberFormatTrailingZeroDisplay;
|
|
31
|
+
notation?: NumberFormatNotation;
|
|
32
|
+
compactDisplay?: NumberFormatCompactDisplay;
|
|
33
|
+
useGrouping?: boolean | NumberFormatGrouping;
|
|
34
|
+
signDisplay?: NumberFormatSignDisplay;
|
|
35
|
+
}
|
|
36
|
+
/** `Intl.ResolvedNumberFormatOptions`. */
|
|
37
|
+
export interface ResolvedNumberFormatOptions {
|
|
38
|
+
locale: string;
|
|
39
|
+
numberingSystem: string;
|
|
40
|
+
style: NumberFormatStyle;
|
|
41
|
+
currency?: string;
|
|
42
|
+
currencyDisplay?: NumberFormatCurrencyDisplay;
|
|
43
|
+
currencySign?: NumberFormatCurrencySign;
|
|
44
|
+
unit?: string;
|
|
45
|
+
unitDisplay?: NumberFormatUnitDisplay;
|
|
46
|
+
minimumIntegerDigits: number;
|
|
47
|
+
minimumFractionDigits?: number;
|
|
48
|
+
maximumFractionDigits?: number;
|
|
49
|
+
minimumSignificantDigits?: number;
|
|
50
|
+
maximumSignificantDigits?: number;
|
|
51
|
+
useGrouping: boolean | NumberFormatGrouping;
|
|
52
|
+
notation: NumberFormatNotation;
|
|
53
|
+
compactDisplay?: NumberFormatCompactDisplay;
|
|
54
|
+
signDisplay: NumberFormatSignDisplay;
|
|
55
|
+
roundingIncrement: number;
|
|
56
|
+
roundingMode: NumberFormatRoundingMode;
|
|
57
|
+
roundingPriority: NumberFormatRoundingPriority;
|
|
58
|
+
trailingZeroDisplay: NumberFormatTrailingZeroDisplay;
|
|
59
|
+
}
|
|
60
|
+
/** One piece of a formatted number, as `Intl.NumberFormat#formatToParts` reports it. */
|
|
61
|
+
export interface NumberFormatPart {
|
|
62
|
+
type: string;
|
|
63
|
+
value: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A number formatter with the API of `Intl.NumberFormat`. It learns a
|
|
67
|
+
* locale's format once from the platform (Foundation on iOS, ICU on Android)
|
|
68
|
+
* and formats in C++ from then on, without calling into the platform per
|
|
69
|
+
* number. Instances are immutable and shared: the same locales and options
|
|
70
|
+
* return the same object.
|
|
71
|
+
*/
|
|
72
|
+
export interface NitroNumberFormat extends HybridObject<{
|
|
73
|
+
ios: 'c++';
|
|
74
|
+
android: 'c++';
|
|
75
|
+
}> {
|
|
76
|
+
format(value: number | Int64 | string): string;
|
|
77
|
+
formatToParts(value: number | Int64 | string): NumberFormatPart[];
|
|
78
|
+
resolvedOptions(): ResolvedNumberFormatOptions;
|
|
79
|
+
}
|
|
80
|
+
export interface NitroNumberFormatFactory extends HybridObject<{
|
|
81
|
+
ios: 'c++';
|
|
82
|
+
android: 'c++';
|
|
83
|
+
}> {
|
|
84
|
+
create(locales: string[], options: NumberFormatOptions): NitroNumberFormat;
|
|
85
|
+
supportedLocalesOf(locales: string[]): string[];
|
|
86
|
+
}
|
|
87
|
+
export interface NumberFormatPlatformOptions {
|
|
88
|
+
locales: string[];
|
|
89
|
+
numberingSystem?: string;
|
|
90
|
+
style: NumberFormatStyle;
|
|
91
|
+
currency?: string;
|
|
92
|
+
currencyDisplay: NumberFormatCurrencyDisplay;
|
|
93
|
+
currencySign: NumberFormatCurrencySign;
|
|
94
|
+
unit?: string;
|
|
95
|
+
unitDisplay: NumberFormatUnitDisplay;
|
|
96
|
+
notation: NumberFormatNotation;
|
|
97
|
+
compactDisplay: NumberFormatCompactDisplay;
|
|
98
|
+
useGrouping: boolean;
|
|
99
|
+
minimumIntegerDigits: number;
|
|
100
|
+
minimumFractionDigits: number;
|
|
101
|
+
maximumFractionDigits: number;
|
|
102
|
+
/** 0 when significant digits are not used. */
|
|
103
|
+
minimumSignificantDigits: number;
|
|
104
|
+
maximumSignificantDigits: number;
|
|
105
|
+
roundingMode: NumberFormatRoundingMode;
|
|
106
|
+
signDisplay: NumberFormatSignDisplay;
|
|
107
|
+
}
|
|
108
|
+
export interface NumberFormatPlatformSymbols {
|
|
109
|
+
/** The locale the platform resolved the request to, as a BCP 47 tag. */
|
|
110
|
+
locale: string;
|
|
111
|
+
numberingSystem: string;
|
|
112
|
+
minusSign: string;
|
|
113
|
+
plusSign: string;
|
|
114
|
+
percentSign: string;
|
|
115
|
+
/** The currency as this formatter shows it (symbol, narrow symbol or code). */
|
|
116
|
+
currency: string;
|
|
117
|
+
/** The locale's symbol for NaN. */
|
|
118
|
+
nan: string;
|
|
119
|
+
/** The locale's symbol for infinity, without a sign. */
|
|
120
|
+
infinity: string;
|
|
121
|
+
/** The "E" of scientific notation. */
|
|
122
|
+
exponentSeparator: string;
|
|
123
|
+
}
|
|
124
|
+
export interface NitroPlatformNumberFormatter extends HybridObject<{
|
|
125
|
+
ios: 'swift';
|
|
126
|
+
android: 'kotlin';
|
|
127
|
+
}> {
|
|
128
|
+
readonly symbols: NumberFormatPlatformSymbols;
|
|
129
|
+
format(value: number): string;
|
|
130
|
+
/** A decimal string, formatted without going through a double. */
|
|
131
|
+
formatDecimal(value: string): string;
|
|
132
|
+
}
|
|
133
|
+
export interface NitroNumberFormatPlatform extends HybridObject<{
|
|
134
|
+
ios: 'swift';
|
|
135
|
+
android: 'kotlin';
|
|
136
|
+
}> {
|
|
137
|
+
create(options: NumberFormatPlatformOptions): NitroPlatformNumberFormatter;
|
|
138
|
+
supportedLocalesOf(locales: string[]): string[];
|
|
139
|
+
}
|
package/nitro.json
CHANGED
|
@@ -38,6 +38,22 @@
|
|
|
38
38
|
"language": "kotlin",
|
|
39
39
|
"implementationClassName": "HybridNitroNumberView"
|
|
40
40
|
}
|
|
41
|
+
},
|
|
42
|
+
"NitroNumberFormatFactory": {
|
|
43
|
+
"all": {
|
|
44
|
+
"language": "c++",
|
|
45
|
+
"implementationClassName": "HybridNitroNumberFormatFactory"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"NitroNumberFormatPlatform": {
|
|
49
|
+
"ios": {
|
|
50
|
+
"language": "swift",
|
|
51
|
+
"implementationClassName": "HybridNitroNumberFormatPlatform"
|
|
52
|
+
},
|
|
53
|
+
"android": {
|
|
54
|
+
"language": "kotlin",
|
|
55
|
+
"implementationClassName": "HybridNitroNumberFormatPlatform"
|
|
56
|
+
}
|
|
41
57
|
}
|
|
42
58
|
},
|
|
43
59
|
"ignorePaths": [
|
|
@@ -38,11 +38,17 @@ target_sources(
|
|
|
38
38
|
../nitrogen/generated/shared/c++/HybridNitroInputWorkletsSpec.cpp
|
|
39
39
|
../nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.cpp
|
|
40
40
|
../nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.cpp
|
|
41
|
+
../nitrogen/generated/shared/c++/HybridNitroNumberFormatSpec.cpp
|
|
42
|
+
../nitrogen/generated/shared/c++/HybridNitroNumberFormatFactorySpec.cpp
|
|
43
|
+
../nitrogen/generated/shared/c++/HybridNitroPlatformNumberFormatterSpec.cpp
|
|
44
|
+
../nitrogen/generated/shared/c++/HybridNitroNumberFormatPlatformSpec.cpp
|
|
41
45
|
# Android-specific Nitrogen C++ sources
|
|
42
46
|
../nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp
|
|
43
47
|
../nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp
|
|
44
48
|
../nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.cpp
|
|
45
49
|
../nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.cpp
|
|
50
|
+
../nitrogen/generated/android/c++/JHybridNitroPlatformNumberFormatterSpec.cpp
|
|
51
|
+
../nitrogen/generated/android/c++/JHybridNitroNumberFormatPlatformSpec.cpp
|
|
46
52
|
)
|
|
47
53
|
|
|
48
54
|
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
@@ -26,8 +26,11 @@
|
|
|
26
26
|
#include "JHybridNitroNumberViewSpec.hpp"
|
|
27
27
|
#include "JFunc_void.hpp"
|
|
28
28
|
#include "views/JHybridNitroNumberViewStateUpdater.hpp"
|
|
29
|
+
#include "JHybridNitroPlatformNumberFormatterSpec.hpp"
|
|
30
|
+
#include "JHybridNitroNumberFormatPlatformSpec.hpp"
|
|
29
31
|
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
30
32
|
#include "HybridNitroInputWorklets.hpp"
|
|
33
|
+
#include "HybridNitroNumberFormatFactory.hpp"
|
|
31
34
|
|
|
32
35
|
namespace margelo::nitro::nitroinput {
|
|
33
36
|
|
|
@@ -53,6 +56,14 @@ struct JHybridNitroNumberViewSpecImpl: public jni::JavaClass<JHybridNitroNumberV
|
|
|
53
56
|
return javaPart->getJHybridNitroNumberViewSpec();
|
|
54
57
|
}
|
|
55
58
|
};
|
|
59
|
+
struct JHybridNitroNumberFormatPlatformSpecImpl: public jni::JavaClass<JHybridNitroNumberFormatPlatformSpecImpl, JHybridNitroNumberFormatPlatformSpec::JavaPart> {
|
|
60
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroinput/HybridNitroNumberFormatPlatform;";
|
|
61
|
+
static std::shared_ptr<JHybridNitroNumberFormatPlatformSpec> create() {
|
|
62
|
+
static const auto constructorFn = javaClassStatic()->getConstructor<JHybridNitroNumberFormatPlatformSpecImpl::javaobject()>();
|
|
63
|
+
jni::local_ref<JHybridNitroNumberFormatPlatformSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
|
|
64
|
+
return javaPart->getJHybridNitroNumberFormatPlatformSpec();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
56
67
|
|
|
57
68
|
void registerAllNatives() {
|
|
58
69
|
using namespace margelo::nitro;
|
|
@@ -70,6 +81,8 @@ void registerAllNatives() {
|
|
|
70
81
|
margelo::nitro::nitroinput::JHybridNitroNumberViewSpec::CxxPart::registerNatives();
|
|
71
82
|
margelo::nitro::nitroinput::JFunc_void_cxx::registerNatives();
|
|
72
83
|
margelo::nitro::nitroinput::views::JHybridNitroNumberViewStateUpdater::registerNatives();
|
|
84
|
+
margelo::nitro::nitroinput::JHybridNitroPlatformNumberFormatterSpec::CxxPart::registerNatives();
|
|
85
|
+
margelo::nitro::nitroinput::JHybridNitroNumberFormatPlatformSpec::CxxPart::registerNatives();
|
|
73
86
|
|
|
74
87
|
// Register Nitro Hybrid Objects
|
|
75
88
|
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
@@ -93,6 +106,21 @@ void registerAllNatives() {
|
|
|
93
106
|
return JHybridNitroNumberViewSpecImpl::create();
|
|
94
107
|
}
|
|
95
108
|
);
|
|
109
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
110
|
+
"NitroNumberFormatFactory",
|
|
111
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
112
|
+
static_assert(std::is_default_constructible_v<HybridNitroNumberFormatFactory>,
|
|
113
|
+
"The HybridObject \"HybridNitroNumberFormatFactory\" is not default-constructible! "
|
|
114
|
+
"Create a public constructor that takes zero arguments to be able to autolink this HybridObject.");
|
|
115
|
+
return std::make_shared<HybridNitroNumberFormatFactory>();
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
119
|
+
"NitroNumberFormatPlatform",
|
|
120
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
121
|
+
return JHybridNitroNumberFormatPlatformSpecImpl::create();
|
|
122
|
+
}
|
|
123
|
+
);
|
|
96
124
|
}
|
|
97
125
|
|
|
98
126
|
} // namespace margelo::nitro::nitroinput
|
|
@@ -398,6 +398,51 @@ namespace margelo::nitro::nitroinput {
|
|
|
398
398
|
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JNitroInputAffixAlign> /* suffixAlign */)>("setSuffixAlign");
|
|
399
399
|
method(_javaPart, JNitroInputAffixAlign::fromCpp(suffixAlign));
|
|
400
400
|
}
|
|
401
|
+
double JHybridNitroInputViewSpec::getLetterSpacing() {
|
|
402
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getLetterSpacing");
|
|
403
|
+
auto __result = method(_javaPart);
|
|
404
|
+
return __result;
|
|
405
|
+
}
|
|
406
|
+
void JHybridNitroInputViewSpec::setLetterSpacing(double letterSpacing) {
|
|
407
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* letterSpacing */)>("setLetterSpacing");
|
|
408
|
+
method(_javaPart, letterSpacing);
|
|
409
|
+
}
|
|
410
|
+
double JHybridNitroInputViewSpec::getPrefixSpacing() {
|
|
411
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getPrefixSpacing");
|
|
412
|
+
auto __result = method(_javaPart);
|
|
413
|
+
return __result;
|
|
414
|
+
}
|
|
415
|
+
void JHybridNitroInputViewSpec::setPrefixSpacing(double prefixSpacing) {
|
|
416
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* prefixSpacing */)>("setPrefixSpacing");
|
|
417
|
+
method(_javaPart, prefixSpacing);
|
|
418
|
+
}
|
|
419
|
+
double JHybridNitroInputViewSpec::getSuffixSpacing() {
|
|
420
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getSuffixSpacing");
|
|
421
|
+
auto __result = method(_javaPart);
|
|
422
|
+
return __result;
|
|
423
|
+
}
|
|
424
|
+
void JHybridNitroInputViewSpec::setSuffixSpacing(double suffixSpacing) {
|
|
425
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* suffixSpacing */)>("setSuffixSpacing");
|
|
426
|
+
method(_javaPart, suffixSpacing);
|
|
427
|
+
}
|
|
428
|
+
double JHybridNitroInputViewSpec::getPrefixOffset() {
|
|
429
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getPrefixOffset");
|
|
430
|
+
auto __result = method(_javaPart);
|
|
431
|
+
return __result;
|
|
432
|
+
}
|
|
433
|
+
void JHybridNitroInputViewSpec::setPrefixOffset(double prefixOffset) {
|
|
434
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* prefixOffset */)>("setPrefixOffset");
|
|
435
|
+
method(_javaPart, prefixOffset);
|
|
436
|
+
}
|
|
437
|
+
double JHybridNitroInputViewSpec::getSuffixOffset() {
|
|
438
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<double()>("getSuffixOffset");
|
|
439
|
+
auto __result = method(_javaPart);
|
|
440
|
+
return __result;
|
|
441
|
+
}
|
|
442
|
+
void JHybridNitroInputViewSpec::setSuffixOffset(double suffixOffset) {
|
|
443
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* suffixOffset */)>("setSuffixOffset");
|
|
444
|
+
method(_javaPart, suffixOffset);
|
|
445
|
+
}
|
|
401
446
|
std::string JHybridNitroInputViewSpec::getPlaceholder() {
|
|
402
447
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getPlaceholder");
|
|
403
448
|
auto __result = method(_javaPart);
|
|
@@ -110,6 +110,16 @@ namespace margelo::nitro::nitroinput {
|
|
|
110
110
|
void setPrefixAlign(NitroInputAffixAlign prefixAlign) override;
|
|
111
111
|
NitroInputAffixAlign getSuffixAlign() override;
|
|
112
112
|
void setSuffixAlign(NitroInputAffixAlign suffixAlign) override;
|
|
113
|
+
double getLetterSpacing() override;
|
|
114
|
+
void setLetterSpacing(double letterSpacing) override;
|
|
115
|
+
double getPrefixSpacing() override;
|
|
116
|
+
void setPrefixSpacing(double prefixSpacing) override;
|
|
117
|
+
double getSuffixSpacing() override;
|
|
118
|
+
void setSuffixSpacing(double suffixSpacing) override;
|
|
119
|
+
double getPrefixOffset() override;
|
|
120
|
+
void setPrefixOffset(double prefixOffset) override;
|
|
121
|
+
double getSuffixOffset() override;
|
|
122
|
+
void setSuffixOffset(double suffixOffset) override;
|
|
113
123
|
std::string getPlaceholder() override;
|
|
114
124
|
void setPlaceholder(const std::string& placeholder) override;
|
|
115
125
|
double getPlaceholderColor() override;
|