@momo-kits/calculator-keyboard 0.150.2-beta.3 → 0.150.2-beta.31
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 +225 -90
- package/android/src/main/java/com/calculatorkeyboard/Event.kt +36 -0
- package/android/src/main/java/com/calculatorkeyboard/InputCalculatorViewManager.kt +270 -0
- package/android/src/main/java/com/calculatorkeyboard/KeyboardOverplayHost.kt +232 -0
- 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 +104 -31
- package/android/src/main/java/com/calculatorkeyboard/RCTInputCalculator.kt +0 -179
- package/ios/CalculatorKeyboardView.swift +0 -115
- package/ios/InputCalculator-Bridging-Header.h +0 -23
- package/ios/InputCalculator.m +0 -79
- package/ios/InputCalculator.swift +0 -138
- package/ios/extension.swift +0 -23
- package/lib/commonjs/index.js +0 -48
- package/lib/commonjs/index.js.map +0 -1
- package/lib/module/index.js +0 -44
- 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 -13
- 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 -13
- package/lib/typescript/module/src/index.d.ts.map +0 -1
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import UIKit
|
|
2
|
-
import Foundation
|
|
3
|
-
|
|
4
|
-
import UIKit
|
|
5
|
-
import Foundation
|
|
6
|
-
|
|
7
|
-
class CalculatorKeyboardView: UIView {
|
|
8
|
-
weak var input: InputCalculator?
|
|
9
|
-
|
|
10
|
-
private let keys: [[String]] = [
|
|
11
|
-
["AC", "÷", "×", "back"],
|
|
12
|
-
["7", "8", "9", "-"],
|
|
13
|
-
["4", "5", "6", "+"],
|
|
14
|
-
["1", "2", "3", "="],
|
|
15
|
-
["000", "0"]
|
|
16
|
-
]
|
|
17
|
-
private let SEPARATOR_WIDTH: CGFloat = 4
|
|
18
|
-
private let specialKeys: Set<String> = ["=", "-", "×", "÷", "AC", "back", "+"]
|
|
19
|
-
|
|
20
|
-
override init(frame: CGRect) {
|
|
21
|
-
super.init(frame: frame)
|
|
22
|
-
setup()
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
required init?(coder aDecoder: NSCoder) {
|
|
26
|
-
fatalError("init(coder:) has not been implemented")
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public func setKeyboardColor(_ color: UIColor) {
|
|
30
|
-
self.setup(color)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
private func setup(_ color: UIColor = UIColor(hex: "#d8d8d8")) {
|
|
34
|
-
self.subviews.forEach { $0.removeFromSuperview() }
|
|
35
|
-
|
|
36
|
-
backgroundColor = UIColor(hex: "#f2f2f6")
|
|
37
|
-
let buttonWidth = (UIScreen.main.bounds.width - SEPARATOR_WIDTH * 2 - 3 * SEPARATOR_WIDTH) / 4
|
|
38
|
-
let buttonHeight: CGFloat = (290 - SEPARATOR_WIDTH * 2 - 4 * SEPARATOR_WIDTH) / 5
|
|
39
|
-
|
|
40
|
-
// Create a wrapper view
|
|
41
|
-
let contentView = UIView()
|
|
42
|
-
contentView.translatesAutoresizingMaskIntoConstraints = false
|
|
43
|
-
addSubview(contentView)
|
|
44
|
-
|
|
45
|
-
// Set contentView constraints
|
|
46
|
-
NSLayoutConstraint.activate([
|
|
47
|
-
contentView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: SEPARATOR_WIDTH),
|
|
48
|
-
contentView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -SEPARATOR_WIDTH),
|
|
49
|
-
contentView.topAnchor.constraint(equalTo: topAnchor, constant: SEPARATOR_WIDTH),
|
|
50
|
-
contentView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -SEPARATOR_WIDTH)
|
|
51
|
-
])
|
|
52
|
-
|
|
53
|
-
// Add buttons to the wrapper view
|
|
54
|
-
var yOffset: CGFloat = 0
|
|
55
|
-
for row in keys {
|
|
56
|
-
var xOffset: CGFloat = 0
|
|
57
|
-
for key in row {
|
|
58
|
-
let button = UIButton(type: .system)
|
|
59
|
-
button.backgroundColor = UIColor.white
|
|
60
|
-
button.layer.cornerRadius = 8
|
|
61
|
-
button.setTitle(key, for: .normal)
|
|
62
|
-
button.setTitleColor(.black, for: .normal)
|
|
63
|
-
button.titleLabel?.font = UIFont.systemFont(ofSize: 24, weight: .medium)
|
|
64
|
-
button.nativeID = key
|
|
65
|
-
|
|
66
|
-
var buttonFrame = CGRect(x: xOffset, y: yOffset, width: buttonWidth, height: buttonHeight)
|
|
67
|
-
if key == "=" {
|
|
68
|
-
buttonFrame.size.height = buttonHeight * 2 + SEPARATOR_WIDTH
|
|
69
|
-
}
|
|
70
|
-
if key == "000" {
|
|
71
|
-
buttonFrame.size.width = buttonWidth * 2 + SEPARATOR_WIDTH
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
button.frame = buttonFrame
|
|
75
|
-
|
|
76
|
-
if key == "back" {
|
|
77
|
-
button.setTitle("", for: .normal)
|
|
78
|
-
let image = UIImage(systemName: "delete.backward", withConfiguration: UIImage.SymbolConfiguration(weight: .bold))
|
|
79
|
-
button.setImage(image, for: .normal)
|
|
80
|
-
button.tintColor = .black
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if specialKeys.contains(key) {
|
|
84
|
-
button.setTitleColor(.black, for: .normal)
|
|
85
|
-
button.backgroundColor = color
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
button.addTarget(self, action: #selector(keyPressed(_:)), for: .touchUpInside)
|
|
89
|
-
contentView.addSubview(button)
|
|
90
|
-
|
|
91
|
-
// Adjust xOffset for the next button in the row
|
|
92
|
-
xOffset += buttonFrame.width + SEPARATOR_WIDTH
|
|
93
|
-
}
|
|
94
|
-
// Adjust yOffset for the next row
|
|
95
|
-
yOffset += buttonHeight + SEPARATOR_WIDTH
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
@objc private func keyPressed(_ sender: UIButton) {
|
|
101
|
-
guard let key = sender.nativeID else { return }
|
|
102
|
-
switch key {
|
|
103
|
-
case "AC":
|
|
104
|
-
input?.clearText()
|
|
105
|
-
case "back":
|
|
106
|
-
input?.onBackSpace()
|
|
107
|
-
case "=":
|
|
108
|
-
input?.calculateResult()
|
|
109
|
-
case "+", "-", "÷", "×":
|
|
110
|
-
input?.keyDidPress(" \(key) ")
|
|
111
|
-
default:
|
|
112
|
-
input?.keyDidPress(key)
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#import <React/RCTBridgeModule.h>
|
|
2
|
-
#import <React/RCTViewManager.h>
|
|
3
|
-
#import <React/RCTBaseTextInputViewManager.h>
|
|
4
|
-
#import <React/RCTSinglelineTextInputView.h>
|
|
5
|
-
#import <React/RCTUITextField.h>
|
|
6
|
-
#import <React/RCTBaseTextInputViewManager.h>
|
|
7
|
-
|
|
8
|
-
#import <React/RCTBridge.h>
|
|
9
|
-
#import <React/RCTConvert.h>
|
|
10
|
-
#import <React/RCTFont.h>
|
|
11
|
-
#import <React/RCTShadowView+Layout.h>
|
|
12
|
-
#import <React/RCTShadowView.h>
|
|
13
|
-
#import <React/RCTUIManager.h>
|
|
14
|
-
#import <React/RCTUIManagerObserverCoordinator.h>
|
|
15
|
-
#import <React/RCTUIManagerUtils.h>
|
|
16
|
-
|
|
17
|
-
#import <React/RCTBaseTextInputShadowView.h>
|
|
18
|
-
#import <React/RCTBaseTextInputView.h>
|
|
19
|
-
#import <React/RCTConvert+Text.h>
|
|
20
|
-
|
|
21
|
-
@interface Calculator : NSObject <RCTBridgeModule>
|
|
22
|
-
|
|
23
|
-
@end
|
package/ios/InputCalculator.m
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
#import <InputCalculator-Bridging-Header.h>
|
|
2
|
-
|
|
3
|
-
@implementation Calculator
|
|
4
|
-
|
|
5
|
-
- (dispatch_queue_t)methodQueue
|
|
6
|
-
{
|
|
7
|
-
return dispatch_get_main_queue();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
RCT_EXPORT_MODULE()
|
|
11
|
-
|
|
12
|
-
@end
|
|
13
|
-
|
|
14
|
-
@interface RCT_EXTERN_MODULE(RCTInputCalculator, RCTViewManager)
|
|
15
|
-
|
|
16
|
-
RCT_REMAP_VIEW_PROPERTY(autoCapitalize, backedTextInputView.autocapitalizationType, UITextAutocapitalizationType)
|
|
17
|
-
RCT_REMAP_VIEW_PROPERTY(autoCorrect, backedTextInputView.autocorrectionType, UITextAutocorrectionType)
|
|
18
|
-
RCT_REMAP_VIEW_PROPERTY(contextMenuHidden, backedTextInputView.contextMenuHidden, BOOL)
|
|
19
|
-
RCT_REMAP_VIEW_PROPERTY(editable, backedTextInputView.editable, BOOL)
|
|
20
|
-
RCT_REMAP_VIEW_PROPERTY(enablesReturnKeyAutomatically, backedTextInputView.enablesReturnKeyAutomatically, BOOL)
|
|
21
|
-
RCT_REMAP_VIEW_PROPERTY(keyboardAppearance, backedTextInputView.keyboardAppearance, UIKeyboardAppearance)
|
|
22
|
-
RCT_REMAP_VIEW_PROPERTY(placeholder, backedTextInputView.placeholder, NSString)
|
|
23
|
-
RCT_REMAP_VIEW_PROPERTY(placeholderTextColor, backedTextInputView.placeholderColor, UIColor)
|
|
24
|
-
RCT_REMAP_VIEW_PROPERTY(returnKeyType, backedTextInputView.returnKeyType, UIReturnKeyType)
|
|
25
|
-
RCT_REMAP_VIEW_PROPERTY(selectionColor, backedTextInputView.tintColor, UIColor)
|
|
26
|
-
RCT_REMAP_VIEW_PROPERTY(spellCheck, backedTextInputView.spellCheckingType, UITextSpellCheckingType)
|
|
27
|
-
RCT_REMAP_VIEW_PROPERTY(caretHidden, backedTextInputView.caretHidden, BOOL)
|
|
28
|
-
RCT_REMAP_VIEW_PROPERTY(clearButtonMode, backedTextInputView.clearButtonMode, UITextFieldViewMode)
|
|
29
|
-
RCT_REMAP_VIEW_PROPERTY(scrollEnabled, backedTextInputView.scrollEnabled, BOOL)
|
|
30
|
-
RCT_REMAP_VIEW_PROPERTY(secureTextEntry, backedTextInputView.secureTextEntry, BOOL)
|
|
31
|
-
RCT_REMAP_VIEW_PROPERTY(smartInsertDelete, backedTextInputView.smartInsertDeleteType, UITextSmartInsertDeleteType)
|
|
32
|
-
|
|
33
|
-
RCT_EXPORT_VIEW_PROPERTY(autoFocus, BOOL)
|
|
34
|
-
RCT_EXPORT_VIEW_PROPERTY(submitBehavior, NSString)
|
|
35
|
-
RCT_EXPORT_VIEW_PROPERTY(clearTextOnFocus, BOOL)
|
|
36
|
-
RCT_EXPORT_VIEW_PROPERTY(keyboardType, UIKeyboardType)
|
|
37
|
-
RCT_EXPORT_VIEW_PROPERTY(showSoftInputOnFocus, BOOL)
|
|
38
|
-
RCT_EXPORT_VIEW_PROPERTY(maxLength, NSNumber)
|
|
39
|
-
RCT_EXPORT_VIEW_PROPERTY(selectTextOnFocus, BOOL)
|
|
40
|
-
RCT_EXPORT_VIEW_PROPERTY(selection, RCTTextSelection)
|
|
41
|
-
RCT_EXPORT_VIEW_PROPERTY(inputAccessoryViewID, NSString)
|
|
42
|
-
RCT_EXPORT_VIEW_PROPERTY(textContentType, NSString)
|
|
43
|
-
RCT_EXPORT_VIEW_PROPERTY(passwordRules, NSString)
|
|
44
|
-
|
|
45
|
-
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
|
|
46
|
-
RCT_EXPORT_VIEW_PROPERTY(onKeyPressSync, RCTDirectEventBlock)
|
|
47
|
-
RCT_EXPORT_VIEW_PROPERTY(onChangeSync, RCTDirectEventBlock)
|
|
48
|
-
RCT_EXPORT_VIEW_PROPERTY(onSelectionChange, RCTDirectEventBlock)
|
|
49
|
-
RCT_EXPORT_VIEW_PROPERTY(onScroll, RCTDirectEventBlock)
|
|
50
|
-
|
|
51
|
-
RCT_EXPORT_VIEW_PROPERTY(mostRecentEventCount, NSInteger)
|
|
52
|
-
|
|
53
|
-
RCT_EXPORT_SHADOW_PROPERTY(text, NSString)
|
|
54
|
-
RCT_EXPORT_SHADOW_PROPERTY(placeholder, NSString)
|
|
55
|
-
RCT_EXPORT_SHADOW_PROPERTY(onContentSizeChange, RCTDirectEventBlock)
|
|
56
|
-
RCT_EXPORT_VIEW_PROPERTY(value, NSString)
|
|
57
|
-
RCT_EXPORT_VIEW_PROPERTY(onFocus, RCTBubblingEventBlock)
|
|
58
|
-
RCT_EXPORT_VIEW_PROPERTY(onBlur, RCTBubblingEventBlock)
|
|
59
|
-
|
|
60
|
-
RCT_EXPORT_METHOD(focus : (nonnull NSNumber *)viewTag)
|
|
61
|
-
{
|
|
62
|
-
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
63
|
-
UIView *view = viewRegistry[viewTag];
|
|
64
|
-
[view reactFocus];
|
|
65
|
-
}];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
RCT_EXPORT_METHOD(blur : (nonnull NSNumber *)viewTag)
|
|
69
|
-
{
|
|
70
|
-
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
71
|
-
UIView *view = viewRegistry[viewTag];
|
|
72
|
-
[view reactBlur];
|
|
73
|
-
}];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
RCT_EXPORT_VIEW_PROPERTY(keyboardColor, UIColor)
|
|
77
|
-
|
|
78
|
-
@end
|
|
79
|
-
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
import UIKit
|
|
3
|
-
|
|
4
|
-
@objc(RCTInputCalculator)
|
|
5
|
-
class RCTInputCalculator: RCTBaseTextInputViewManager {
|
|
6
|
-
override func view() -> UIView! {
|
|
7
|
-
return InputCalculator(bridge: bridge)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
override static func requiresMainQueueSetup() -> Bool {
|
|
11
|
-
return true
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
class InputCalculator: RCTSinglelineTextInputView {
|
|
17
|
-
var bridge: RCTBridge?
|
|
18
|
-
var keyboardView: CalculatorKeyboardView?
|
|
19
|
-
|
|
20
|
-
@objc var onFocus: RCTBubblingEventBlock?
|
|
21
|
-
@objc var onBlur: RCTBubblingEventBlock?
|
|
22
|
-
|
|
23
|
-
@objc func beginEditingInput(_ note: Notification) { onFocus?([:]) }
|
|
24
|
-
@objc func endEditingInput(_ note: Notification) { onBlur?([:]) }
|
|
25
|
-
|
|
26
|
-
@objc var value: String = "" {
|
|
27
|
-
didSet {
|
|
28
|
-
guard let tf = backedTextInputView as? UITextField else { return }
|
|
29
|
-
let old = tf.text ?? ""
|
|
30
|
-
if old == value { return }
|
|
31
|
-
|
|
32
|
-
let isFirstResponder = tf.isFirstResponder
|
|
33
|
-
let atEnd = isFirstResponder && tf.offset(from: tf.beginningOfDocument, to: tf.selectedTextRange?.start ?? tf.endOfDocument) == old.count
|
|
34
|
-
tf.text = value
|
|
35
|
-
if !isFirstResponder || atEnd,
|
|
36
|
-
let end = tf.position(from: tf.beginningOfDocument, offset: value.count) {
|
|
37
|
-
tf.selectedTextRange = tf.textRange(from: end, to: end)
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@objc var keyboardColor: UIColor = UIColor(hex: "#d9d9d9") {
|
|
43
|
-
didSet {
|
|
44
|
-
self.keyboardView?.setKeyboardColor(keyboardColor)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
override init(bridge: RCTBridge) {
|
|
50
|
-
super.init(bridge: bridge)
|
|
51
|
-
self.bridge = bridge
|
|
52
|
-
self.keyboardView = CalculatorKeyboardView()
|
|
53
|
-
self.keyboardView!.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: 290 + getbottomInset())
|
|
54
|
-
self.keyboardView!.input = self
|
|
55
|
-
|
|
56
|
-
backedTextInputView.inputView = self.keyboardView
|
|
57
|
-
backedTextInputView.inputView?.reloadInputViews()
|
|
58
|
-
|
|
59
|
-
NotificationCenter.default.addObserver(
|
|
60
|
-
self,
|
|
61
|
-
selector: #selector(beginEditingInput(_:)),
|
|
62
|
-
name: UITextField.textDidBeginEditingNotification,
|
|
63
|
-
object: backedTextInputView
|
|
64
|
-
)
|
|
65
|
-
NotificationCenter.default.addObserver(
|
|
66
|
-
self,
|
|
67
|
-
selector: #selector(endEditingInput(_:)),
|
|
68
|
-
name: UITextField.textDidEndEditingNotification,
|
|
69
|
-
object: backedTextInputView
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
func getbottomInset() -> CGFloat {
|
|
74
|
-
let window = UIApplication.shared.windows.first?.rootViewController?.view
|
|
75
|
-
let bottom = (window?.safeAreaInsets.bottom ?? 0) > 0 ? 21 : 0
|
|
76
|
-
return CGFloat(bottom)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
func keyDidPress(_ key: String) {
|
|
80
|
-
backedTextInputView.insertText(key)
|
|
81
|
-
value += key
|
|
82
|
-
if let bridge = bridge {
|
|
83
|
-
bridge.eventDispatcher().sendTextEvent(with: .change, reactTag: reactTag, text: value, key: "\(key)", eventCount: 1)
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
func clearText() {
|
|
88
|
-
value = ""
|
|
89
|
-
(backedTextInputView as? UITextField)?.text = ""
|
|
90
|
-
if let bridge = bridge {
|
|
91
|
-
bridge.eventDispatcher().sendTextEvent(with: .change, reactTag: reactTag, text: value, key: "clear", eventCount: 1)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
func onBackSpace() {
|
|
96
|
-
value = value.dropLast().description
|
|
97
|
-
DispatchQueue.main.async {
|
|
98
|
-
if let range = self.backedTextInputView.selectedTextRange,
|
|
99
|
-
let fromRange = self.backedTextInputView.position(from: range.start, offset: -1),
|
|
100
|
-
let newRange = self.backedTextInputView.textRange(from: fromRange, to: range.start)
|
|
101
|
-
{
|
|
102
|
-
self.backedTextInputView.replace(newRange, withText: "")
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if let bridge = bridge {
|
|
107
|
-
bridge.eventDispatcher().sendTextEvent(with: .change, reactTag: reactTag, text: value, key: "back", eventCount: 1)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
func calculateResult() {
|
|
112
|
-
guard let textField = backedTextInputView as? UITextField,
|
|
113
|
-
let text = textField.text?.replacingOccurrences(of: "×", with: "*").replacingOccurrences(of: "÷", with: "/")
|
|
114
|
-
else {
|
|
115
|
-
return
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
let pattern = "^\\s*(-?\\d+(\\.\\d+)?\\s*[-+*/]\\s*)*-?\\d+(\\.\\d+)?\\s*$"
|
|
119
|
-
let regex = try? NSRegularExpression(pattern: pattern)
|
|
120
|
-
let range = NSRange(location: 0, length: text.utf16.count)
|
|
121
|
-
|
|
122
|
-
if regex?.firstMatch(in: text, options: [], range: range) != nil {
|
|
123
|
-
let expression = NSExpression(format: text)
|
|
124
|
-
if let result = expression.expressionValue(with: nil, context: nil) as? NSNumber {
|
|
125
|
-
textField.text = result.stringValue
|
|
126
|
-
value = result.stringValue
|
|
127
|
-
if let bridge = bridge {
|
|
128
|
-
bridge.eventDispatcher().sendTextEvent(with: .change, reactTag: reactTag, text: value, key: "=", eventCount: 1)
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
print("Invalid expression")
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
package/ios/extension.swift
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import Foundation
|
|
3
|
-
import UIKit
|
|
4
|
-
|
|
5
|
-
extension UIColor {
|
|
6
|
-
convenience init(hex: String) {
|
|
7
|
-
let hex = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
|
|
8
|
-
var int = UInt64()
|
|
9
|
-
Scanner(string: hex).scanHexInt64(&int)
|
|
10
|
-
let a, r, g, b: UInt64
|
|
11
|
-
switch hex.count {
|
|
12
|
-
case 3: // RGB (12-bit)
|
|
13
|
-
(a, r, g, b) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17)
|
|
14
|
-
case 6: // RGB (24-bit)
|
|
15
|
-
(a, r, g, b) = (255, int >> 16, int >> 8 & 0xFF, int & 0xFF)
|
|
16
|
-
case 8: // ARGB (32-bit)
|
|
17
|
-
(a, r, g, b) = (int >> 24, int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF)
|
|
18
|
-
default:
|
|
19
|
-
(a, r, g, b) = (255, 0, 0, 0)
|
|
20
|
-
}
|
|
21
|
-
self.init(red: CGFloat(r) / 255, green: CGFloat(g) / 255, blue: CGFloat(b) / 255, alpha: CGFloat(a) / 255)
|
|
22
|
-
}
|
|
23
|
-
}
|
package/lib/commonjs/index.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
const NAME = 'RCTInputCalculator';
|
|
12
|
-
const NativeInput = (0, _reactNative.requireNativeComponent)(NAME);
|
|
13
|
-
const InputCalculator = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
14
|
-
const nativeRef = _react.default.useRef(null);
|
|
15
|
-
const _onChange = event => {
|
|
16
|
-
const currentText = event.nativeEvent.text;
|
|
17
|
-
props.onChange && props.onChange(event);
|
|
18
|
-
props.onChangeText && props.onChangeText(currentText);
|
|
19
|
-
};
|
|
20
|
-
const text = props.text ?? props.defaultValue ?? '';
|
|
21
|
-
_react.default.useImperativeHandle(ref, () => ({
|
|
22
|
-
focus() {
|
|
23
|
-
const node = (0, _reactNative.findNodeHandle)(nativeRef.current);
|
|
24
|
-
if (!node) return;
|
|
25
|
-
const config = _reactNative.UIManager.getViewManagerConfig(NAME);
|
|
26
|
-
if (config?.Commands?.focus != null) {
|
|
27
|
-
_reactNative.UIManager.dispatchViewManagerCommand(node, config.Commands.focus, []);
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
blur() {
|
|
31
|
-
const node = (0, _reactNative.findNodeHandle)(nativeRef.current);
|
|
32
|
-
if (!node) return;
|
|
33
|
-
const config = _reactNative.UIManager.getViewManagerConfig(NAME);
|
|
34
|
-
if (config?.Commands?.blur != null) {
|
|
35
|
-
_reactNative.UIManager.dispatchViewManagerCommand(node, config.Commands.blur, []);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}));
|
|
39
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(NativeInput, {
|
|
40
|
-
...props,
|
|
41
|
-
ref: nativeRef,
|
|
42
|
-
onChange: _onChange,
|
|
43
|
-
value: text,
|
|
44
|
-
keybardColor: (0, _reactNative.processColor)(props.keyboardColor)
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
var _default = exports.default = InputCalculator;
|
|
48
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_jsxRuntime","e","__esModule","default","NAME","NativeInput","requireNativeComponent","InputCalculator","React","forwardRef","props","ref","nativeRef","useRef","_onChange","event","currentText","nativeEvent","text","onChange","onChangeText","defaultValue","useImperativeHandle","focus","node","findNodeHandle","current","config","UIManager","getViewManagerConfig","Commands","dispatchViewManagerCommand","blur","jsx","value","keybardColor","processColor","keyboardColor","_default","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAQsB,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGtB,MAAMG,IAAI,GAAG,oBAAoB;AACjC,MAAMC,WAAW,GAAG,IAAAC,mCAAsB,EAAMF,IAAI,CAAC;AAYrD,MAAMG,eAAe,gBAAGC,cAAK,CAACC,UAAU,CACtC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACd,MAAMC,SAAS,GAAGJ,cAAK,CAACK,MAAM,CAAM,IAAI,CAAC;EAEzC,MAAMC,SAAS,GACbC,KAAqD,IAClD;IACH,MAAMC,WAAW,GAAGD,KAAK,CAACE,WAAW,CAACC,IAAI;IAC1CR,KAAK,CAACS,QAAQ,IAAIT,KAAK,CAACS,QAAQ,CAACJ,KAAK,CAAC;IACvCL,KAAK,CAACU,YAAY,IAAIV,KAAK,CAACU,YAAY,CAACJ,WAAW,CAAC;EACvD,CAAC;EAED,MAAME,IAAI,GAAGR,KAAK,CAACQ,IAAI,IAAIR,KAAK,CAACW,YAAY,IAAI,EAAE;EAEnDb,cAAK,CAACc,mBAAmB,CAACX,GAAG,EAAE,OAAO;IACpCY,KAAKA,CAAA,EAAG;MACN,MAAMC,IAAI,GAAG,IAAAC,2BAAc,EAACb,SAAS,CAACc,OAAO,CAAC;MAC9C,IAAI,CAACF,IAAI,EAAE;MACX,MAAMG,MAAM,GAAGC,sBAAS,CAACC,oBAAoB,CAACzB,IAAI,CAAC;MACnD,IAAIuB,MAAM,EAAEG,QAAQ,EAAEP,KAAK,IAAI,IAAI,EAAE;QACnCK,sBAAS,CAACG,0BAA0B,CAACP,IAAI,EAAEG,MAAM,CAACG,QAAQ,CAACP,KAAK,EAAE,EAAE,CAAC;MACvE;IACF,CAAC;IACDS,IAAIA,CAAA,EAAG;MACL,MAAMR,IAAI,GAAG,IAAAC,2BAAc,EAACb,SAAS,CAACc,OAAO,CAAC;MAC9C,IAAI,CAACF,IAAI,EAAE;MACX,MAAMG,MAAM,GAAGC,sBAAS,CAACC,oBAAoB,CAACzB,IAAI,CAAC;MACnD,IAAIuB,MAAM,EAAEG,QAAQ,EAAEE,IAAI,IAAI,IAAI,EAAE;QAClCJ,sBAAS,CAACG,0BAA0B,CAACP,IAAI,EAAEG,MAAM,CAACG,QAAQ,CAACE,IAAI,EAAE,EAAE,CAAC;MACtE;IACF;EACF,CAAC,CAAC,CAAC;EAEH,oBACE,IAAAhC,WAAA,CAAAiC,GAAA,EAAC5B,WAAW;IAAA,GACNK,KAAK;IACTC,GAAG,EAAEC,SAAU;IACfO,QAAQ,EAAEL,SAAU;IACpBoB,KAAK,EAAEhB,IAAK;IACZiB,YAAY,EAAE,IAAAC,yBAAY,EAAC1B,KAAK,CAAC2B,aAAa;EAAE,CACjD,CAAC;AAEN,CACF,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAApC,OAAA,GAEaI,eAAe","ignoreList":[]}
|
package/lib/module/index.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { processColor, UIManager, findNodeHandle } from 'react-native';
|
|
5
|
-
import { requireNativeComponent } from 'react-native';
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
const NAME = 'RCTInputCalculator';
|
|
8
|
-
const NativeInput = requireNativeComponent(NAME);
|
|
9
|
-
const InputCalculator = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
10
|
-
const nativeRef = React.useRef(null);
|
|
11
|
-
const _onChange = event => {
|
|
12
|
-
const currentText = event.nativeEvent.text;
|
|
13
|
-
props.onChange && props.onChange(event);
|
|
14
|
-
props.onChangeText && props.onChangeText(currentText);
|
|
15
|
-
};
|
|
16
|
-
const text = props.text ?? props.defaultValue ?? '';
|
|
17
|
-
React.useImperativeHandle(ref, () => ({
|
|
18
|
-
focus() {
|
|
19
|
-
const node = findNodeHandle(nativeRef.current);
|
|
20
|
-
if (!node) return;
|
|
21
|
-
const config = UIManager.getViewManagerConfig(NAME);
|
|
22
|
-
if (config?.Commands?.focus != null) {
|
|
23
|
-
UIManager.dispatchViewManagerCommand(node, config.Commands.focus, []);
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
blur() {
|
|
27
|
-
const node = findNodeHandle(nativeRef.current);
|
|
28
|
-
if (!node) return;
|
|
29
|
-
const config = UIManager.getViewManagerConfig(NAME);
|
|
30
|
-
if (config?.Commands?.blur != null) {
|
|
31
|
-
UIManager.dispatchViewManagerCommand(node, config.Commands.blur, []);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}));
|
|
35
|
-
return /*#__PURE__*/_jsx(NativeInput, {
|
|
36
|
-
...props,
|
|
37
|
-
ref: nativeRef,
|
|
38
|
-
onChange: _onChange,
|
|
39
|
-
value: text,
|
|
40
|
-
keybardColor: processColor(props.keyboardColor)
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
export default InputCalculator;
|
|
44
|
-
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","processColor","UIManager","findNodeHandle","requireNativeComponent","jsx","_jsx","NAME","NativeInput","InputCalculator","forwardRef","props","ref","nativeRef","useRef","_onChange","event","currentText","nativeEvent","text","onChange","onChangeText","defaultValue","useImperativeHandle","focus","node","current","config","getViewManagerConfig","Commands","dispatchViewManagerCommand","blur","value","keybardColor","keyboardColor"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAKEC,YAAY,EACZC,SAAS,EACTC,cAAc,QACT,cAAc;AACrB,SAASC,sBAAsB,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEtD,MAAMC,IAAI,GAAG,oBAAoB;AACjC,MAAMC,WAAW,GAAGJ,sBAAsB,CAAMG,IAAI,CAAC;AAYrD,MAAME,eAAe,gBAAGT,KAAK,CAACU,UAAU,CACtC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACd,MAAMC,SAAS,GAAGb,KAAK,CAACc,MAAM,CAAM,IAAI,CAAC;EAEzC,MAAMC,SAAS,GACbC,KAAqD,IAClD;IACH,MAAMC,WAAW,GAAGD,KAAK,CAACE,WAAW,CAACC,IAAI;IAC1CR,KAAK,CAACS,QAAQ,IAAIT,KAAK,CAACS,QAAQ,CAACJ,KAAK,CAAC;IACvCL,KAAK,CAACU,YAAY,IAAIV,KAAK,CAACU,YAAY,CAACJ,WAAW,CAAC;EACvD,CAAC;EAED,MAAME,IAAI,GAAGR,KAAK,CAACQ,IAAI,IAAIR,KAAK,CAACW,YAAY,IAAI,EAAE;EAEnDtB,KAAK,CAACuB,mBAAmB,CAACX,GAAG,EAAE,OAAO;IACpCY,KAAKA,CAAA,EAAG;MACN,MAAMC,IAAI,GAAGtB,cAAc,CAACU,SAAS,CAACa,OAAO,CAAC;MAC9C,IAAI,CAACD,IAAI,EAAE;MACX,MAAME,MAAM,GAAGzB,SAAS,CAAC0B,oBAAoB,CAACrB,IAAI,CAAC;MACnD,IAAIoB,MAAM,EAAEE,QAAQ,EAAEL,KAAK,IAAI,IAAI,EAAE;QACnCtB,SAAS,CAAC4B,0BAA0B,CAACL,IAAI,EAAEE,MAAM,CAACE,QAAQ,CAACL,KAAK,EAAE,EAAE,CAAC;MACvE;IACF,CAAC;IACDO,IAAIA,CAAA,EAAG;MACL,MAAMN,IAAI,GAAGtB,cAAc,CAACU,SAAS,CAACa,OAAO,CAAC;MAC9C,IAAI,CAACD,IAAI,EAAE;MACX,MAAME,MAAM,GAAGzB,SAAS,CAAC0B,oBAAoB,CAACrB,IAAI,CAAC;MACnD,IAAIoB,MAAM,EAAEE,QAAQ,EAAEE,IAAI,IAAI,IAAI,EAAE;QAClC7B,SAAS,CAAC4B,0BAA0B,CAACL,IAAI,EAAEE,MAAM,CAACE,QAAQ,CAACE,IAAI,EAAE,EAAE,CAAC;MACtE;IACF;EACF,CAAC,CAAC,CAAC;EAEH,oBACEzB,IAAA,CAACE,WAAW;IAAA,GACNG,KAAK;IACTC,GAAG,EAAEC,SAAU;IACfO,QAAQ,EAAEL,SAAU;IACpBiB,KAAK,EAAEb,IAAK;IACZc,YAAY,EAAEhC,YAAY,CAACU,KAAK,CAACuB,aAAa;EAAE,CACjD,CAAC;AAEN,CACF,CAAC;AAED,eAAezB,eAAe","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type TextInputProps, type ColorValue } from 'react-native';
|
|
3
|
-
interface InputCalculatorProps extends TextInputProps {
|
|
4
|
-
text?: string | undefined;
|
|
5
|
-
keyboardColor?: ColorValue;
|
|
6
|
-
}
|
|
7
|
-
export type InputCalculatorRef = {
|
|
8
|
-
focus: () => void;
|
|
9
|
-
blur: () => void;
|
|
10
|
-
};
|
|
11
|
-
declare const InputCalculator: React.ForwardRefExoticComponent<InputCalculatorProps & React.RefAttributes<InputCalculatorRef>>;
|
|
12
|
-
export default InputCalculator;
|
|
13
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,UAAU,EAIhB,MAAM,cAAc,CAAC;AAMtB,UAAU,oBAAqB,SAAQ,cAAc;IACnD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,UAAU,CAAC;CAC5B;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,eAAe,iGA2CpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type TextInputProps, type ColorValue } from 'react-native';
|
|
3
|
-
interface InputCalculatorProps extends TextInputProps {
|
|
4
|
-
text?: string | undefined;
|
|
5
|
-
keyboardColor?: ColorValue;
|
|
6
|
-
}
|
|
7
|
-
export type InputCalculatorRef = {
|
|
8
|
-
focus: () => void;
|
|
9
|
-
blur: () => void;
|
|
10
|
-
};
|
|
11
|
-
declare const InputCalculator: React.ForwardRefExoticComponent<InputCalculatorProps & React.RefAttributes<InputCalculatorRef>>;
|
|
12
|
-
export default InputCalculator;
|
|
13
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,UAAU,EAIhB,MAAM,cAAc,CAAC;AAMtB,UAAU,oBAAqB,SAAQ,cAAc;IACnD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,UAAU,CAAC;CAC5B;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,eAAe,iGA2CpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|