@momo-kits/calculator-keyboard 0.150.2-phuc.15 → 0.151.1-beta.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/README.md +45 -3
- package/android/src/main/java/com/calculatorkeyboard/CalculatorKeyboardPackage.kt +1 -1
- package/android/src/main/java/com/calculatorkeyboard/CustomKeyboardView.kt +166 -90
- package/android/src/main/java/com/calculatorkeyboard/Event.kt +36 -0
- package/android/src/main/java/com/calculatorkeyboard/{RCTInputCalculator.kt → InputCalculatorViewManager.kt} +100 -27
- package/ios/CalculatorKeyboardView.h +30 -0
- package/ios/CalculatorKeyboardView.mm +231 -0
- package/ios/NativeInputCalculator.h +11 -0
- package/ios/NativeInputCalculator.mm +369 -0
- package/package.json +21 -131
- package/react-native-calculator-keyboard.podspec +5 -4
- package/src/InputCalculatorNativeComponent.ts +62 -0
- package/src/index.tsx +77 -43
- package/ios/CalculatorKeyboardView.swift +0 -153
- package/ios/InputCalculator-Bridging-Header.h +0 -23
- package/ios/InputCalculator.m +0 -85
- package/ios/InputCalculator.swift +0 -158
- package/ios/extension.swift +0 -23
- package/lib/commonjs/index.js +0 -72
- package/lib/commonjs/index.js.map +0 -1
- package/lib/module/index.js +0 -67
- package/lib/module/index.js.map +0 -1
- package/lib/typescript/commonjs/package.json +0 -1
- package/lib/typescript/commonjs/src/index.d.ts +0 -23
- package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
- package/lib/typescript/module/package.json +0 -1
- package/lib/typescript/module/src/index.d.ts +0 -23
- package/lib/typescript/module/src/index.d.ts.map +0 -1
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
#import "NativeInputCalculator.h"
|
|
2
|
+
#import "CalculatorKeyboardView.h"
|
|
3
|
+
|
|
4
|
+
#import <React/RCTConversions.h>
|
|
5
|
+
#import <React/RCTFabricComponentsPlugins.h>
|
|
6
|
+
#import <react/renderer/components/CalculatorKeyboardSpecs/ComponentDescriptors.h>
|
|
7
|
+
#import <react/renderer/components/CalculatorKeyboardSpecs/EventEmitters.h>
|
|
8
|
+
#import <react/renderer/components/CalculatorKeyboardSpecs/Props.h>
|
|
9
|
+
#import <react/renderer/components/CalculatorKeyboardSpecs/RCTComponentViewHelpers.h>
|
|
10
|
+
|
|
11
|
+
using namespace facebook::react;
|
|
12
|
+
|
|
13
|
+
@interface NativeInputCalculator () <RCTNativeInputCalculatorViewProtocol>
|
|
14
|
+
@end
|
|
15
|
+
|
|
16
|
+
@implementation NativeInputCalculator {
|
|
17
|
+
UITextField *_textField;
|
|
18
|
+
CalculatorKeyboardView *_keyboardView;
|
|
19
|
+
NSString *_lastValue;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
23
|
+
{
|
|
24
|
+
if (self = [super initWithFrame:frame]) {
|
|
25
|
+
static const auto defaultProps = std::make_shared<const NativeInputCalculatorProps>();
|
|
26
|
+
_props = defaultProps;
|
|
27
|
+
|
|
28
|
+
// Create text field
|
|
29
|
+
_textField = [[UITextField alloc] initWithFrame:self.bounds];
|
|
30
|
+
_textField.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
31
|
+
_textField.delegate = (id<UITextFieldDelegate>)self;
|
|
32
|
+
|
|
33
|
+
// Create keyboard view
|
|
34
|
+
CGFloat bottomInset = [self getBottomInset];
|
|
35
|
+
CGRect keyboardFrame = CGRectMake(0, 0, UIScreen.mainScreen.bounds.size.width, 240 + bottomInset);
|
|
36
|
+
_keyboardView = [[CalculatorKeyboardView alloc] initWithFrame:keyboardFrame];
|
|
37
|
+
_keyboardView.input = (id)self; // Bridge pattern
|
|
38
|
+
|
|
39
|
+
// Set custom keyboard
|
|
40
|
+
_textField.inputView = _keyboardView;
|
|
41
|
+
|
|
42
|
+
[self addSubview:_textField];
|
|
43
|
+
}
|
|
44
|
+
return self;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
- (CGFloat)getBottomInset
|
|
48
|
+
{
|
|
49
|
+
UIWindow *window = UIApplication.sharedApplication.windows.firstObject;
|
|
50
|
+
CGFloat bottom = window.safeAreaInsets.bottom > 0 ? 21 : 0;
|
|
51
|
+
return bottom;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
#pragma mark - RCTComponentViewProtocol
|
|
55
|
+
|
|
56
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
57
|
+
{
|
|
58
|
+
return concreteComponentDescriptorProvider<NativeInputCalculatorComponentDescriptor>();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
|
|
62
|
+
{
|
|
63
|
+
const auto &oldViewProps = *std::static_pointer_cast<const NativeInputCalculatorProps>(_props);
|
|
64
|
+
const auto &newViewProps = *std::static_pointer_cast<const NativeInputCalculatorProps>(props);
|
|
65
|
+
|
|
66
|
+
if (oldViewProps.value != newViewProps.value) {
|
|
67
|
+
NSString *newValue = RCTNSStringFromString(newViewProps.value);
|
|
68
|
+
if (![_lastValue isEqualToString:newValue]) {
|
|
69
|
+
_textField.text = newValue;
|
|
70
|
+
_lastValue = newValue;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (oldViewProps.mode != newViewProps.mode) {
|
|
75
|
+
_keyboardView.keyboardMode = RCTNSStringFromString(newViewProps.mode);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (oldViewProps.customKeyText != newViewProps.customKeyText) {
|
|
79
|
+
_keyboardView.customKeyText = RCTNSStringFromString(newViewProps.customKeyText);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (oldViewProps.customKeyBackground != newViewProps.customKeyBackground) {
|
|
83
|
+
_keyboardView.customKeyBackground = RCTNSStringFromString(newViewProps.customKeyBackground);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (oldViewProps.customKeyTextColor != newViewProps.customKeyTextColor) {
|
|
87
|
+
_keyboardView.customKeyTextColor = RCTNSStringFromString(newViewProps.customKeyTextColor);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (oldViewProps.customKeyState != newViewProps.customKeyState) {
|
|
91
|
+
_keyboardView.customKeyState = RCTNSStringFromString(newViewProps.customKeyState);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (oldViewProps.textAttributes.fontSize != newViewProps.textAttributes.fontSize > 0.0f) {
|
|
95
|
+
CGFloat newSize = (CGFloat)newViewProps.textAttributes.fontSize;
|
|
96
|
+
UIFont *current = _textField.font ?: [UIFont systemFontOfSize:UIFont.systemFontSize];
|
|
97
|
+
_textField.font = [current fontWithSize:newSize];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (oldViewProps.textAttributes.fontWeight != newViewProps.textAttributes.fontWeight) {
|
|
101
|
+
UIFontWeight weight = _UIFontWeightFromString(newViewProps.textAttributes.fontWeight);
|
|
102
|
+
CGFloat size = _textField.font ? _textField.font.pointSize : UIFont.systemFontSize;
|
|
103
|
+
_textField.font = [UIFont systemFontOfSize:size weight:weight];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
[super updateProps:props oldProps:oldProps];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static UIFontWeight _UIFontWeightFromString(std::string_view s) {
|
|
110
|
+
std::string v(s);
|
|
111
|
+
for (auto &c : v) c = (char)tolower((unsigned char)c);
|
|
112
|
+
|
|
113
|
+
if (v == "normal" || v == "400") return UIFontWeightRegular;
|
|
114
|
+
if (v == "bold" || v == "700") return UIFontWeightBold;
|
|
115
|
+
if (v == "100") return UIFontWeightUltraLight;
|
|
116
|
+
if (v == "200") return UIFontWeightThin;
|
|
117
|
+
if (v == "300") return UIFontWeightLight;
|
|
118
|
+
if (v == "500") return UIFontWeightMedium;
|
|
119
|
+
if (v == "600") return UIFontWeightSemibold;
|
|
120
|
+
if (v == "800") return UIFontWeightHeavy;
|
|
121
|
+
if (v == "900") return UIFontWeightBlack;
|
|
122
|
+
return UIFontWeightRegular;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
|
|
126
|
+
{
|
|
127
|
+
RCTNativeInputCalculatorHandleCommand(self, commandName, args);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
#pragma mark - RCTNativeInputCalculatorViewProtocol
|
|
131
|
+
|
|
132
|
+
- (void)focus
|
|
133
|
+
{
|
|
134
|
+
[_textField becomeFirstResponder];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
- (void)blur
|
|
138
|
+
{
|
|
139
|
+
[_textField resignFirstResponder];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
#pragma mark - Keyboard callbacks (called by CalculatorKeyboardView)
|
|
143
|
+
|
|
144
|
+
- (void)keyDidPress:(NSString *)key {
|
|
145
|
+
UITextRange *sel = _textField.selectedTextRange;
|
|
146
|
+
if (sel) {
|
|
147
|
+
[_textField replaceRange:sel withText:key];
|
|
148
|
+
} else {
|
|
149
|
+
[_textField insertText:key];
|
|
150
|
+
}
|
|
151
|
+
[self reformatAndKeepSelection];
|
|
152
|
+
[self notifyTextChange];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
- (void)clearText
|
|
156
|
+
{
|
|
157
|
+
_textField.text = @"";
|
|
158
|
+
[self notifyTextChange];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
- (void)onBackSpace {
|
|
162
|
+
NSString *formatted = _textField.text ?: @"";
|
|
163
|
+
if (formatted.length == 0) return;
|
|
164
|
+
|
|
165
|
+
UITextRange *selRange = _textField.selectedTextRange;
|
|
166
|
+
NSInteger caretFmt = (NSInteger)[_textField offsetFromPosition:_textField.beginningOfDocument
|
|
167
|
+
toPosition:selRange.start];
|
|
168
|
+
|
|
169
|
+
NSString *rawBefore = [self stripGroupDots:formatted];
|
|
170
|
+
NSInteger caretRaw = [self formattedCaretToRaw:formatted caret:caretFmt];
|
|
171
|
+
if (caretRaw <= 0) return;
|
|
172
|
+
|
|
173
|
+
NSMutableString *rawAfter = [rawBefore mutableCopy];
|
|
174
|
+
[rawAfter deleteCharactersInRange:NSMakeRange(caretRaw - 1, 1)];
|
|
175
|
+
|
|
176
|
+
NSString *formattedAfter = [self formatNumberGroups:rawAfter];
|
|
177
|
+
_textField.text = formattedAfter;
|
|
178
|
+
|
|
179
|
+
NSInteger newCaretFmt = [self rawCaretToFormatted:(caretRaw - 1) inFormatted:formattedAfter];
|
|
180
|
+
UITextPosition *pos = [_textField positionFromPosition:_textField.beginningOfDocument offset:newCaretFmt];
|
|
181
|
+
if (pos) {
|
|
182
|
+
_textField.selectedTextRange = [_textField textRangeFromPosition:pos toPosition:pos];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
[self notifyTextChange];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
- (void)calculateResult {
|
|
189
|
+
NSString *text = _textField.text ?: @"";
|
|
190
|
+
|
|
191
|
+
text = [self stripGroupDots:text];
|
|
192
|
+
text = [text stringByReplacingOccurrencesOfString:@"×" withString:@"*"];
|
|
193
|
+
text = [text stringByReplacingOccurrencesOfString:@"÷" withString:@"/"];
|
|
194
|
+
|
|
195
|
+
NSString *pattern = @"^\\s*(-?\\d+(\\.\\d+)?\\s*[-+*/]\\s*)*-?\\d+(\\.\\d+)?\\s*$";
|
|
196
|
+
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:nil];
|
|
197
|
+
if (![regex firstMatchInString:text options:0 range:NSMakeRange(0, text.length)]) {
|
|
198
|
+
NSLog(@"Invalid expression");
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@try {
|
|
203
|
+
NSExpression *expr = [NSExpression expressionWithFormat:text];
|
|
204
|
+
id val = [expr expressionValueWithObject:nil context:nil];
|
|
205
|
+
if ([val isKindOfClass:[NSNumber class]]) {
|
|
206
|
+
NSString *result = [(NSNumber *)val stringValue];
|
|
207
|
+
NSString *formatted = [self formatNumberGroups:result];
|
|
208
|
+
_textField.text = formatted;
|
|
209
|
+
|
|
210
|
+
UITextPosition *end = _textField.endOfDocument;
|
|
211
|
+
_textField.selectedTextRange = [_textField textRangeFromPosition:end toPosition:end];
|
|
212
|
+
|
|
213
|
+
[self notifyTextChange];
|
|
214
|
+
}
|
|
215
|
+
} @catch (__unused NSException *e) { }
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
- (void)emitCustomKey
|
|
219
|
+
{
|
|
220
|
+
if (_eventEmitter) {
|
|
221
|
+
auto emitter = std::static_pointer_cast<const NativeInputCalculatorEventEmitter>(_eventEmitter);
|
|
222
|
+
NativeInputCalculatorEventEmitter::OnCustomKeyEvent event{};
|
|
223
|
+
emitter->onCustomKeyEvent(event);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
- (void)emitKeyPress:(NSString *)key
|
|
228
|
+
{
|
|
229
|
+
if (_eventEmitter) {
|
|
230
|
+
auto emitter = std::static_pointer_cast<const NativeInputCalculatorEventEmitter>(_eventEmitter);
|
|
231
|
+
NativeInputCalculatorEventEmitter::OnKeyPress event{
|
|
232
|
+
.key = std::string([key UTF8String])
|
|
233
|
+
};
|
|
234
|
+
emitter->onKeyPress(event);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
- (void)notifyTextChange
|
|
239
|
+
{
|
|
240
|
+
_lastValue = _textField.text;
|
|
241
|
+
|
|
242
|
+
if (_eventEmitter) {
|
|
243
|
+
auto emitter = std::static_pointer_cast<const NativeInputCalculatorEventEmitter>(_eventEmitter);
|
|
244
|
+
NativeInputCalculatorEventEmitter::OnChange event{
|
|
245
|
+
.text = std::string([_textField.text UTF8String])
|
|
246
|
+
};
|
|
247
|
+
emitter->onChange(event);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
#pragma mark - Thousand grouping helpers (strip/format + caret mapping)
|
|
252
|
+
|
|
253
|
+
- (BOOL)isGroupDotAt:(NSInteger)i inString:(NSString *)s {
|
|
254
|
+
if (i < 0 || i >= (NSInteger)s.length) return NO;
|
|
255
|
+
unichar c = [s characterAtIndex:i];
|
|
256
|
+
if (c != '.') return NO;
|
|
257
|
+
BOOL leftIsDigit = (i - 1 >= 0) && [[NSCharacterSet decimalDigitCharacterSet] characterIsMember:[s characterAtIndex:i-1]];
|
|
258
|
+
BOOL rightIsDigit = (i + 1 < (NSInteger)s.length) && [[NSCharacterSet decimalDigitCharacterSet] characterIsMember:[s characterAtIndex:i+1]];
|
|
259
|
+
return leftIsDigit && rightIsDigit;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
- (NSString *)stripGroupDots:(NSString *)input {
|
|
263
|
+
if (input.length == 0) return input;
|
|
264
|
+
NSMutableString *out = [NSMutableString stringWithCapacity:input.length];
|
|
265
|
+
for (NSInteger i = 0; i < (NSInteger)input.length; i++) {
|
|
266
|
+
unichar c = [input characterAtIndex:i];
|
|
267
|
+
if (c == '.' && [self isGroupDotAt:i inString:input]) {
|
|
268
|
+
// skip
|
|
269
|
+
} else {
|
|
270
|
+
[out appendFormat:@"%C", c];
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return out;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
- (NSString *)formatNumberGroups:(NSString *)input {
|
|
277
|
+
NSString *noSep = [self stripGroupDots:input];
|
|
278
|
+
if (noSep.length == 0) return noSep;
|
|
279
|
+
|
|
280
|
+
NSError *err = nil;
|
|
281
|
+
NSRegularExpression *re = [NSRegularExpression regularExpressionWithPattern:@"\\d+" options:0 error:&err];
|
|
282
|
+
if (err) return noSep;
|
|
283
|
+
|
|
284
|
+
NSMutableString *result = [noSep mutableCopy];
|
|
285
|
+
__block NSInteger delta = 0;
|
|
286
|
+
[re enumerateMatchesInString:noSep options:0 range:NSMakeRange(0, noSep.length) usingBlock:^(NSTextCheckingResult * _Nullable match, NSMatchingFlags flags, BOOL * _Nonnull stop) {
|
|
287
|
+
if (!match) return;
|
|
288
|
+
NSRange mr = match.range;
|
|
289
|
+
mr.location += delta;
|
|
290
|
+
|
|
291
|
+
NSString *digits = [result substringWithRange:mr];
|
|
292
|
+
|
|
293
|
+
NSMutableString *rev = [NSMutableString stringWithCapacity:digits.length];
|
|
294
|
+
for (NSInteger i = digits.length - 1; i >= 0; i--) {
|
|
295
|
+
[rev appendFormat:@"%C", [digits characterAtIndex:i]];
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
NSMutableArray<NSString *> *chunks = [NSMutableArray array];
|
|
299
|
+
for (NSInteger i = 0; i < (NSInteger)rev.length; i += 3) {
|
|
300
|
+
NSRange r = NSMakeRange(i, MIN(3, (NSInteger)rev.length - i));
|
|
301
|
+
[chunks addObject:[rev substringWithRange:r]];
|
|
302
|
+
}
|
|
303
|
+
NSString *joined = [chunks componentsJoinedByString:@"."];
|
|
304
|
+
|
|
305
|
+
NSMutableString *final = [NSMutableString stringWithCapacity:joined.length];
|
|
306
|
+
for (NSInteger i = joined.length - 1; i >= 0; i--) {
|
|
307
|
+
[final appendFormat:@"%C", [joined characterAtIndex:i]];
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
[result replaceCharactersInRange:mr withString:final];
|
|
311
|
+
delta += (final.length - mr.length);
|
|
312
|
+
}];
|
|
313
|
+
|
|
314
|
+
return result;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
- (NSInteger)formattedCaretToRaw:(NSString *)formatted caret:(NSInteger)caretFmt {
|
|
318
|
+
NSInteger rawIdx = 0;
|
|
319
|
+
NSInteger limit = MIN(caretFmt, (NSInteger)formatted.length);
|
|
320
|
+
for (NSInteger i = 0; i < limit; i++) {
|
|
321
|
+
unichar c = [formatted characterAtIndex:i];
|
|
322
|
+
if (!(c == '.' && [self isGroupDotAt:i inString:formatted])) {
|
|
323
|
+
rawIdx++;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return rawIdx;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
- (NSInteger)rawCaretToFormatted:(NSInteger)rawCaret inFormatted:(NSString *)formatted {
|
|
330
|
+
NSInteger rawSeen = 0;
|
|
331
|
+
for (NSInteger i = 0; i < (NSInteger)formatted.length; i++) {
|
|
332
|
+
unichar c = [formatted characterAtIndex:i];
|
|
333
|
+
if (!(c == '.' && [self isGroupDotAt:i inString:formatted])) {
|
|
334
|
+
if (rawSeen == rawCaret) return i;
|
|
335
|
+
rawSeen++;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return (NSInteger)formatted.length;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
- (void)reformatAndKeepSelection {
|
|
342
|
+
NSString *formattedBefore = _textField.text ?: @"";
|
|
343
|
+
|
|
344
|
+
UITextRange *selRange = _textField.selectedTextRange;
|
|
345
|
+
NSInteger caretFmtBefore = (NSInteger)[_textField offsetFromPosition:_textField.beginningOfDocument
|
|
346
|
+
toPosition:selRange.start];
|
|
347
|
+
|
|
348
|
+
NSInteger caretRaw = [self formattedCaretToRaw:formattedBefore caret:caretFmtBefore];
|
|
349
|
+
NSString *formattedAfter = [self formatNumberGroups:formattedBefore];
|
|
350
|
+
|
|
351
|
+
if (![formattedAfter isEqualToString:formattedBefore]) {
|
|
352
|
+
_textField.text = formattedAfter;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
NSInteger caretFmtAfter = [self rawCaretToFormatted:caretRaw inFormatted:formattedAfter];
|
|
356
|
+
UITextPosition *pos = [_textField positionFromPosition:_textField.beginningOfDocument offset:caretFmtAfter];
|
|
357
|
+
if (pos) {
|
|
358
|
+
_textField.selectedTextRange = [_textField textRangeFromPosition:pos toPosition:pos];
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
@end
|
|
364
|
+
|
|
365
|
+
Class<RCTNativeInputCalculatorViewProtocol> NativeInputCalculatorCls(void)
|
|
366
|
+
{
|
|
367
|
+
return NativeInputCalculator.class;
|
|
368
|
+
}
|
|
369
|
+
|
package/package.json
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/calculator-keyboard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.151.1-beta.1",
|
|
4
4
|
"description": "react native calculator keyboard",
|
|
5
|
-
"
|
|
6
|
-
"main": "./lib/commonjs/index.js",
|
|
7
|
-
"module": "./lib/module/index.js",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"import": {
|
|
11
|
-
"types": "./lib/typescript/module/src/index.d.ts",
|
|
12
|
-
"default": "./lib/module/index.js"
|
|
13
|
-
},
|
|
14
|
-
"require": {
|
|
15
|
-
"types": "./lib/typescript/commonjs/src/index.d.ts",
|
|
16
|
-
"default": "./lib/commonjs/index.js"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
},
|
|
5
|
+
"main": "./src/index.tsx",
|
|
20
6
|
"files": [
|
|
21
7
|
"src",
|
|
22
8
|
"lib",
|
|
@@ -40,9 +26,7 @@
|
|
|
40
26
|
"test": "jest",
|
|
41
27
|
"typecheck": "tsc",
|
|
42
28
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
43
|
-
"
|
|
44
|
-
"build": "bob build",
|
|
45
|
-
"release": "release-it"
|
|
29
|
+
"build": "echo"
|
|
46
30
|
},
|
|
47
31
|
"keywords": [
|
|
48
32
|
"react-native",
|
|
@@ -62,124 +46,30 @@
|
|
|
62
46
|
"publishConfig": {
|
|
63
47
|
"registry": "https://registry.npmjs.org/"
|
|
64
48
|
},
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
"@types/jest": "^29.5.5",
|
|
72
|
-
"@types/react": "^18.2.44",
|
|
73
|
-
"commitlint": "^17.0.2",
|
|
74
|
-
"del-cli": "^5.1.0",
|
|
75
|
-
"eslint": "^8.51.0",
|
|
76
|
-
"eslint-config-prettier": "^9.0.0",
|
|
77
|
-
"eslint-plugin-prettier": "^5.0.1",
|
|
78
|
-
"jest": "^29.7.0",
|
|
79
|
-
"prettier": "^3.0.3",
|
|
80
|
-
"react": "18.3.1",
|
|
81
|
-
"react-native": "0.76.5",
|
|
82
|
-
"react-native-builder-bob": "^0.32.0",
|
|
83
|
-
"release-it": "^17.10.0",
|
|
84
|
-
"turbo": "^1.10.7",
|
|
85
|
-
"typescript": "^5.2.2"
|
|
86
|
-
},
|
|
87
|
-
"resolutions": {
|
|
88
|
-
"@types/react": "^18.2.44"
|
|
89
|
-
},
|
|
90
|
-
"peerDependencies": {
|
|
91
|
-
"react": "*",
|
|
92
|
-
"react-native": "*"
|
|
93
|
-
},
|
|
94
|
-
"jest": {
|
|
95
|
-
"preset": "react-native",
|
|
96
|
-
"modulePathIgnorePatterns": [
|
|
97
|
-
"<rootDir>/example/node_modules",
|
|
98
|
-
"<rootDir>/lib/"
|
|
99
|
-
]
|
|
100
|
-
},
|
|
101
|
-
"commitlint": {
|
|
102
|
-
"extends": [
|
|
103
|
-
"@commitlint/config-conventional"
|
|
104
|
-
]
|
|
105
|
-
},
|
|
106
|
-
"release-it": {
|
|
107
|
-
"git": {
|
|
108
|
-
"commitMessage": "chore: release ${version}",
|
|
109
|
-
"tagName": "v${version}"
|
|
110
|
-
},
|
|
111
|
-
"npm": {
|
|
112
|
-
"publish": true
|
|
113
|
-
},
|
|
114
|
-
"github": {
|
|
115
|
-
"release": true
|
|
49
|
+
"codegenConfig": {
|
|
50
|
+
"name": "CalculatorKeyboardSpecs",
|
|
51
|
+
"type": "components",
|
|
52
|
+
"jsSrcsDir": "src",
|
|
53
|
+
"android": {
|
|
54
|
+
"javaPackageName": "com.calculatorkeyboard"
|
|
116
55
|
},
|
|
117
|
-
"
|
|
118
|
-
"
|
|
119
|
-
"
|
|
56
|
+
"ios": {
|
|
57
|
+
"componentProvider": {
|
|
58
|
+
"NativeInputCalculator": "NativeInputCalculator"
|
|
120
59
|
}
|
|
121
60
|
}
|
|
122
61
|
},
|
|
123
|
-
"
|
|
124
|
-
"
|
|
125
|
-
"
|
|
126
|
-
"@react-native",
|
|
127
|
-
"prettier"
|
|
128
|
-
],
|
|
129
|
-
"rules": {
|
|
130
|
-
"react/react-in-jsx-scope": "off",
|
|
131
|
-
"prettier/prettier": [
|
|
132
|
-
"error",
|
|
133
|
-
{
|
|
134
|
-
"quoteProps": "consistent",
|
|
135
|
-
"singleQuote": true,
|
|
136
|
-
"tabWidth": 2,
|
|
137
|
-
"trailingComma": "es5",
|
|
138
|
-
"useTabs": false
|
|
139
|
-
}
|
|
140
|
-
]
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
"eslintIgnore": [
|
|
144
|
-
"node_modules/",
|
|
145
|
-
"lib/"
|
|
146
|
-
],
|
|
147
|
-
"prettier": {
|
|
148
|
-
"quoteProps": "consistent",
|
|
149
|
-
"singleQuote": true,
|
|
150
|
-
"tabWidth": 2,
|
|
151
|
-
"trailingComma": "es5",
|
|
152
|
-
"useTabs": false
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"react": "19.0.0",
|
|
64
|
+
"react-native": "0.80.1"
|
|
153
65
|
},
|
|
154
|
-
"
|
|
155
|
-
"
|
|
156
|
-
"
|
|
157
|
-
"
|
|
158
|
-
[
|
|
159
|
-
"commonjs",
|
|
160
|
-
{
|
|
161
|
-
"esm": true
|
|
162
|
-
}
|
|
163
|
-
],
|
|
164
|
-
[
|
|
165
|
-
"module",
|
|
166
|
-
{
|
|
167
|
-
"esm": true
|
|
168
|
-
}
|
|
169
|
-
],
|
|
170
|
-
[
|
|
171
|
-
"typescript",
|
|
172
|
-
{
|
|
173
|
-
"project": "tsconfig.build.json",
|
|
174
|
-
"esm": true
|
|
175
|
-
}
|
|
176
|
-
]
|
|
177
|
-
]
|
|
66
|
+
"peerDependencies": {
|
|
67
|
+
"react": "*",
|
|
68
|
+
"react-native": "*",
|
|
69
|
+
"@momo-kits/foundation": "latest"
|
|
178
70
|
},
|
|
179
|
-
"
|
|
180
|
-
"
|
|
181
|
-
"languages": "kotlin-swift",
|
|
182
|
-
"version": "0.45.5"
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": ">=18.0.0"
|
|
183
73
|
},
|
|
184
74
|
"dependencies": {}
|
|
185
75
|
}
|
|
@@ -5,7 +5,7 @@ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1
|
|
|
5
5
|
|
|
6
6
|
Pod::Spec.new do |s|
|
|
7
7
|
s.name = "react-native-calculator-keyboard"
|
|
8
|
-
s.version = "
|
|
8
|
+
s.version = package["version"]
|
|
9
9
|
s.summary = package["description"]
|
|
10
10
|
s.homepage = package["homepage"]
|
|
11
11
|
s.license = package["license"]
|
|
@@ -14,9 +14,10 @@ Pod::Spec.new do |s|
|
|
|
14
14
|
s.platforms = { :ios => min_ios_version_supported }
|
|
15
15
|
s.source = { :git => "https://github.com/wem2017/react-native-calculator-keyboard.git/react-native-calculator-keyboard.git", :tag => "#{s.version}" }
|
|
16
16
|
|
|
17
|
-
s.source_files = "ios/**/*.{h,m,mm
|
|
18
|
-
s.
|
|
19
|
-
|
|
17
|
+
s.source_files = "ios/**/*.{h,m,mm}"
|
|
18
|
+
# s.public_header_files = "ios/CalculatorKeyboardView.h"
|
|
19
|
+
# s.private_header_files = "ios/NativeInputCalculator.h"
|
|
20
|
+
|
|
20
21
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
21
22
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
22
23
|
if respond_to?(:install_modules_dependencies, true)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
3
|
+
import {
|
|
4
|
+
CodegenTypes,
|
|
5
|
+
codegenNativeComponent,
|
|
6
|
+
codegenNativeCommands,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
|
|
9
|
+
export type CustomKeyBackground = 'primary' | 'default' | string;
|
|
10
|
+
|
|
11
|
+
export enum CustomKeyState {
|
|
12
|
+
Default = 'default',
|
|
13
|
+
Disable = 'disable',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export enum Mode {
|
|
17
|
+
NumDefault = 'NumDefault',
|
|
18
|
+
NumWithCTA = 'NumWithCTA',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type OnKeyPressEvent = Readonly<{
|
|
22
|
+
key: string;
|
|
23
|
+
}>;
|
|
24
|
+
|
|
25
|
+
export type OnChangeEvent = Readonly<{
|
|
26
|
+
text: string;
|
|
27
|
+
}>;
|
|
28
|
+
|
|
29
|
+
export type TextAttributes = Readonly<{
|
|
30
|
+
fontSize?: CodegenTypes.Float;
|
|
31
|
+
fontWeight?: string;
|
|
32
|
+
}>;
|
|
33
|
+
|
|
34
|
+
export interface NativeInputCalculatorProps extends ViewProps {
|
|
35
|
+
value?: string;
|
|
36
|
+
textAttributes?: TextAttributes;
|
|
37
|
+
mode?: string;
|
|
38
|
+
customKeyText?: string;
|
|
39
|
+
customKeyBackground?: string;
|
|
40
|
+
customKeyTextColor?: string;
|
|
41
|
+
customKeyState?: string;
|
|
42
|
+
onChange?: CodegenTypes.BubblingEventHandler<OnChangeEvent>;
|
|
43
|
+
onKeyPress?: CodegenTypes.BubblingEventHandler<OnKeyPressEvent>;
|
|
44
|
+
onCustomKeyEvent?: CodegenTypes.DirectEventHandler<{}>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface NativeInputCalculatorCommands {
|
|
48
|
+
focus(
|
|
49
|
+
viewRef: React.ElementRef<HostComponent<NativeInputCalculatorProps>>,
|
|
50
|
+
): void;
|
|
51
|
+
blur(
|
|
52
|
+
viewRef: React.ElementRef<HostComponent<NativeInputCalculatorProps>>,
|
|
53
|
+
): void;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const Commands = codegenNativeCommands<NativeInputCalculatorCommands>({
|
|
57
|
+
supportedCommands: ['focus', 'blur'],
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export default codegenNativeComponent<NativeInputCalculatorProps>(
|
|
61
|
+
'NativeInputCalculator',
|
|
62
|
+
);
|