@momo-kits/calculator-keyboard 0.112.1-rc.9 → 0.112.1-rn76.9
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/LICENSE +20 -0
- package/README.md +33 -0
- package/android/build.gradle +101 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/calculatorkeyboard/CalculatorKeyboardPackage.kt +17 -0
- package/android/src/main/java/com/calculatorkeyboard/CustomEditText.kt +28 -0
- package/android/src/main/java/com/calculatorkeyboard/CustomKeyboardView.kt +242 -0
- package/android/src/main/java/com/calculatorkeyboard/RCTInputCalculator.kt +128 -0
- package/ios/CalculatorKeyboardView.swift +118 -0
- package/ios/InputCalculator-Bridging-Header.h +23 -0
- package/ios/InputCalculator.m +76 -0
- package/ios/InputCalculator.swift +100 -0
- package/ios/extension.swift +23 -0
- package/lib/commonjs/index.js +28 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/index.js +24 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +11 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/index.d.ts +11 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +181 -12
- package/react-native-calculator-keyboard.podspec +43 -0
- package/src/index.tsx +44 -0
- package/index.tsx +0 -135
- package/publish.sh +0 -28
- package/styles.ts +0 -18
- package/types.ts +0 -7
|
@@ -0,0 +1,118 @@
|
|
|
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: "#d9d9d9")) {
|
|
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 = .white
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if specialKeys.contains(key) {
|
|
84
|
+
button.setTitleColor(.white, for: .normal)
|
|
85
|
+
button.backgroundColor = color.withAlphaComponent(0.5)
|
|
86
|
+
if key == "=" {
|
|
87
|
+
button.backgroundColor = color
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
button.addTarget(self, action: #selector(keyPressed(_:)), for: .touchUpInside)
|
|
92
|
+
contentView.addSubview(button)
|
|
93
|
+
|
|
94
|
+
// Adjust xOffset for the next button in the row
|
|
95
|
+
xOffset += buttonFrame.width + SEPARATOR_WIDTH
|
|
96
|
+
}
|
|
97
|
+
// Adjust yOffset for the next row
|
|
98
|
+
yOffset += buttonHeight + SEPARATOR_WIDTH
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@objc private func keyPressed(_ sender: UIButton) {
|
|
104
|
+
guard let key = sender.nativeID else { return }
|
|
105
|
+
switch key {
|
|
106
|
+
case "AC":
|
|
107
|
+
input?.clearText()
|
|
108
|
+
case "back":
|
|
109
|
+
input?.onBackSpace()
|
|
110
|
+
case "=":
|
|
111
|
+
input?.calculateResult()
|
|
112
|
+
case "+", "-", "÷", "×":
|
|
113
|
+
input?.keyDidPress(" \(key) ")
|
|
114
|
+
default:
|
|
115
|
+
input?.keyDidPress(key)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
|
|
57
|
+
RCT_EXPORT_METHOD(focus : (nonnull NSNumber *)viewTag)
|
|
58
|
+
{
|
|
59
|
+
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
60
|
+
UIView *view = viewRegistry[viewTag];
|
|
61
|
+
[view reactFocus];
|
|
62
|
+
}];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
RCT_EXPORT_METHOD(blur : (nonnull NSNumber *)viewTag)
|
|
66
|
+
{
|
|
67
|
+
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
68
|
+
UIView *view = viewRegistry[viewTag];
|
|
69
|
+
[view reactBlur];
|
|
70
|
+
}];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
RCT_EXPORT_VIEW_PROPERTY(keyboardColor, UIColor)
|
|
74
|
+
|
|
75
|
+
@end
|
|
76
|
+
|
|
@@ -0,0 +1,100 @@
|
|
|
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 value: String = ""
|
|
21
|
+
|
|
22
|
+
@objc var keyboardColor: UIColor = UIColor(hex: "#d9d9d9") {
|
|
23
|
+
didSet {
|
|
24
|
+
self.keyboardView?.setKeyboardColor(keyboardColor)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
override init(bridge: RCTBridge) {
|
|
29
|
+
super.init(bridge: bridge)
|
|
30
|
+
self.bridge = bridge
|
|
31
|
+
self.keyboardView = CalculatorKeyboardView()
|
|
32
|
+
self.keyboardView!.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: 290)
|
|
33
|
+
self.keyboardView!.input = self
|
|
34
|
+
|
|
35
|
+
backedTextInputView.inputView = self.keyboardView
|
|
36
|
+
backedTextInputView.inputView?.reloadInputViews()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
func keyDidPress(_ key: String) {
|
|
41
|
+
backedTextInputView.insertText(key)
|
|
42
|
+
value += key
|
|
43
|
+
if let bridge = bridge {
|
|
44
|
+
bridge.eventDispatcher().sendTextEvent(with: .change, reactTag: reactTag, text: value, key: "\(key)", eventCount: 1)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
func clearText() {
|
|
49
|
+
value = ""
|
|
50
|
+
(backedTextInputView as? UITextField)?.text = ""
|
|
51
|
+
if let bridge = bridge {
|
|
52
|
+
bridge.eventDispatcher().sendTextEvent(with: .change, reactTag: reactTag, text: value, key: "clear", eventCount: 1)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
func onBackSpace() {
|
|
57
|
+
value = value.dropLast().description
|
|
58
|
+
DispatchQueue.main.async {
|
|
59
|
+
if let range = self.backedTextInputView.selectedTextRange,
|
|
60
|
+
let fromRange = self.backedTextInputView.position(from: range.start, offset: -1),
|
|
61
|
+
let newRange = self.backedTextInputView.textRange(from: fromRange, to: range.start)
|
|
62
|
+
{
|
|
63
|
+
self.backedTextInputView.replace(newRange, withText: "")
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if let bridge = bridge {
|
|
68
|
+
bridge.eventDispatcher().sendTextEvent(with: .change, reactTag: reactTag, text: value, key: "back", eventCount: 1)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
func calculateResult() {
|
|
73
|
+
guard let textField = backedTextInputView as? UITextField,
|
|
74
|
+
let text = textField.text?.replacingOccurrences(of: "×", with: "*").replacingOccurrences(of: "÷", with: "/")
|
|
75
|
+
else {
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let pattern = "^\\s*(-?\\d+(\\.\\d+)?\\s*[-+*/]\\s*)*-?\\d+(\\.\\d+)?\\s*$"
|
|
80
|
+
let regex = try? NSRegularExpression(pattern: pattern)
|
|
81
|
+
let range = NSRange(location: 0, length: text.utf16.count)
|
|
82
|
+
|
|
83
|
+
if regex?.firstMatch(in: text, options: [], range: range) != nil {
|
|
84
|
+
let expression = NSExpression(format: text)
|
|
85
|
+
if let result = expression.expressionValue(with: nil, context: nil) as? NSNumber {
|
|
86
|
+
textField.text = result.stringValue
|
|
87
|
+
value = result.stringValue
|
|
88
|
+
if let bridge = bridge {
|
|
89
|
+
bridge.eventDispatcher().sendTextEvent(with: .change, reactTag: reactTag, text: value, key: "=", eventCount: 1)
|
|
90
|
+
textField.reactBlur()
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
print("Invalid expression")
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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 NativeInput = (0, _reactNative.requireNativeComponent)('RCTInputCalculator');
|
|
12
|
+
const InputCalculator = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
13
|
+
const _onChange = event => {
|
|
14
|
+
const currentText = event.nativeEvent.text;
|
|
15
|
+
props.onChange && props.onChange(event);
|
|
16
|
+
props.onChangeText && props.onChangeText(currentText);
|
|
17
|
+
};
|
|
18
|
+
const text = props.text || props.defaultValue || '';
|
|
19
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(NativeInput, {
|
|
20
|
+
...props,
|
|
21
|
+
ref: ref,
|
|
22
|
+
onChange: _onChange,
|
|
23
|
+
text: text,
|
|
24
|
+
keybardColor: (0, _reactNative.processColor)(props.keyboardColor)
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
var _default = exports.default = InputCalculator;
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_jsxRuntime","e","__esModule","default","NativeInput","requireNativeComponent","InputCalculator","React","forwardRef","props","ref","_onChange","event","currentText","nativeEvent","text","onChange","onChangeText","defaultValue","jsx","keybardColor","processColor","keyboardColor","_default","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAMsB,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGtB,MAAMG,WAAW,GAAG,IAAAC,mCAAsB,EAAM,oBAAoB,CAAC;AAOrE,MAAMC,eAAe,gBAAGC,cAAK,CAACC,UAAU,CACtC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACd,MAAMC,SAAS,GACbC,KAAqD,IAClD;IACH,MAAMC,WAAW,GAAGD,KAAK,CAACE,WAAW,CAACC,IAAI;IAC1CN,KAAK,CAACO,QAAQ,IAAIP,KAAK,CAACO,QAAQ,CAACJ,KAAK,CAAC;IACvCH,KAAK,CAACQ,YAAY,IAAIR,KAAK,CAACQ,YAAY,CAACJ,WAAW,CAAC;EACvD,CAAC;EAED,MAAME,IAAI,GAAGN,KAAK,CAACM,IAAI,IAAIN,KAAK,CAACS,YAAY,IAAI,EAAE;EAEnD,oBACE,IAAAlB,WAAA,CAAAmB,GAAA,EAACf,WAAW;IAAA,GACNK,KAAK;IACTC,GAAG,EAAEA,GAAI;IACTM,QAAQ,EAAEL,SAAU;IACpBI,IAAI,EAAEA,IAAK;IACXK,YAAY,EAAE,IAAAC,yBAAY,EAACZ,KAAK,CAACa,aAAa;EAAE,CACjD,CAAC;AAEN,CACF,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAArB,OAAA,GAEaG,eAAe","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { processColor } from 'react-native';
|
|
5
|
+
import { requireNativeComponent } from 'react-native';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
const NativeInput = requireNativeComponent('RCTInputCalculator');
|
|
8
|
+
const InputCalculator = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
9
|
+
const _onChange = event => {
|
|
10
|
+
const currentText = event.nativeEvent.text;
|
|
11
|
+
props.onChange && props.onChange(event);
|
|
12
|
+
props.onChangeText && props.onChangeText(currentText);
|
|
13
|
+
};
|
|
14
|
+
const text = props.text || props.defaultValue || '';
|
|
15
|
+
return /*#__PURE__*/_jsx(NativeInput, {
|
|
16
|
+
...props,
|
|
17
|
+
ref: ref,
|
|
18
|
+
onChange: _onChange,
|
|
19
|
+
text: text,
|
|
20
|
+
keybardColor: processColor(props.keyboardColor)
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
export default InputCalculator;
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","processColor","requireNativeComponent","jsx","_jsx","NativeInput","InputCalculator","forwardRef","props","ref","_onChange","event","currentText","nativeEvent","text","onChange","onChangeText","defaultValue","keybardColor","keyboardColor"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAKEC,YAAY,QACP,cAAc;AACrB,SAASC,sBAAsB,QAAmB,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEjE,MAAMC,WAAW,GAAGH,sBAAsB,CAAM,oBAAoB,CAAC;AAOrE,MAAMI,eAAe,gBAAGN,KAAK,CAACO,UAAU,CACtC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACd,MAAMC,SAAS,GACbC,KAAqD,IAClD;IACH,MAAMC,WAAW,GAAGD,KAAK,CAACE,WAAW,CAACC,IAAI;IAC1CN,KAAK,CAACO,QAAQ,IAAIP,KAAK,CAACO,QAAQ,CAACJ,KAAK,CAAC;IACvCH,KAAK,CAACQ,YAAY,IAAIR,KAAK,CAACQ,YAAY,CAACJ,WAAW,CAAC;EACvD,CAAC;EAED,MAAME,IAAI,GAAGN,KAAK,CAACM,IAAI,IAAIN,KAAK,CAACS,YAAY,IAAI,EAAE;EAEnD,oBACEb,IAAA,CAACC,WAAW;IAAA,GACNG,KAAK;IACTC,GAAG,EAAEA,GAAI;IACTM,QAAQ,EAAEL,SAAU;IACpBI,IAAI,EAAEA,IAAK;IACXI,YAAY,EAAEjB,YAAY,CAACO,KAAK,CAACW,aAAa;EAAE,CACjD,CAAC;AAEN,CACF,CAAC;AAED,eAAeb,eAAe","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type TextInputProps, type ColorValue } from 'react-native';
|
|
3
|
+
import { TextInput } from 'react-native';
|
|
4
|
+
interface InputCalculatorProps extends TextInputProps {
|
|
5
|
+
text?: string | undefined;
|
|
6
|
+
keyboardColor?: ColorValue;
|
|
7
|
+
}
|
|
8
|
+
declare const InputCalculator: React.ForwardRefExoticComponent<InputCalculatorProps & React.RefAttributes<TextInput>>;
|
|
9
|
+
export default InputCalculator;
|
|
10
|
+
export type { InputCalculatorProps };
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,EAEhB,MAAM,cAAc,CAAC;AACtB,OAAO,EAA0B,SAAS,EAAE,MAAM,cAAc,CAAC;AAIjE,UAAU,oBAAqB,SAAQ,cAAc;IACnD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,UAAU,CAAC;CAC5B;AAED,QAAA,MAAM,eAAe,wFAsBpB,CAAC;AAEF,eAAe,eAAe,CAAC;AAE/B,YAAY,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type TextInputProps, type ColorValue } from 'react-native';
|
|
3
|
+
import { TextInput } from 'react-native';
|
|
4
|
+
interface InputCalculatorProps extends TextInputProps {
|
|
5
|
+
text?: string | undefined;
|
|
6
|
+
keyboardColor?: ColorValue;
|
|
7
|
+
}
|
|
8
|
+
declare const InputCalculator: React.ForwardRefExoticComponent<InputCalculatorProps & React.RefAttributes<TextInput>>;
|
|
9
|
+
export default InputCalculator;
|
|
10
|
+
export type { InputCalculatorProps };
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,EAEhB,MAAM,cAAc,CAAC;AACtB,OAAO,EAA0B,SAAS,EAAE,MAAM,cAAc,CAAC;AAIjE,UAAU,oBAAqB,SAAQ,cAAc;IACnD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,UAAU,CAAC;CAC5B;AAED,QAAA,MAAM,eAAe,wFAsBpB,CAAC;AAEF,eAAe,eAAe,CAAC;AAE/B,YAAY,EAAE,oBAAoB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,20 +1,189 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/calculator-keyboard",
|
|
3
|
-
"version": "0.112.1-
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
3
|
+
"version": "0.112.1-rn76.9",
|
|
4
|
+
"description": "react native calculator keyboard",
|
|
5
|
+
"source": "./src/index.tsx",
|
|
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
|
+
}
|
|
11
19
|
},
|
|
12
|
-
"
|
|
13
|
-
"
|
|
20
|
+
"files": [
|
|
21
|
+
"src",
|
|
22
|
+
"lib",
|
|
23
|
+
"android",
|
|
24
|
+
"ios",
|
|
25
|
+
"cpp",
|
|
26
|
+
"*.podspec",
|
|
27
|
+
"react-native.config.js",
|
|
28
|
+
"!ios/build",
|
|
29
|
+
"!android/build",
|
|
30
|
+
"!android/gradle",
|
|
31
|
+
"!android/gradlew",
|
|
32
|
+
"!android/gradlew.bat",
|
|
33
|
+
"!android/local.properties",
|
|
34
|
+
"!**/__tests__",
|
|
35
|
+
"!**/__fixtures__",
|
|
36
|
+
"!**/__mocks__",
|
|
37
|
+
"!**/.*"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"example": "yarn workspace react-native-calculator-keyboard-example",
|
|
41
|
+
"test": "jest",
|
|
42
|
+
"typecheck": "tsc",
|
|
43
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
44
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
45
|
+
"prepare": "bob build",
|
|
46
|
+
"release": "release-it"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"react-native",
|
|
50
|
+
"ios",
|
|
51
|
+
"android"
|
|
52
|
+
],
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "git+https://github.com/wem2017/react-native-calculator-keyboard.git/react-native-calculator-keyboard.git"
|
|
56
|
+
},
|
|
57
|
+
"author": "Dũng (Wem) <huynh.developer@gmail.com> (https://github.com/wem2017/react-native-calculator-keyboard.git)",
|
|
58
|
+
"license": "MIT",
|
|
59
|
+
"bugs": {
|
|
60
|
+
"url": "https://github.com/wem2017/react-native-calculator-keyboard.git/react-native-calculator-keyboard/issues"
|
|
14
61
|
},
|
|
15
|
-
"
|
|
62
|
+
"homepage": "https://github.com/wem2017/react-native-calculator-keyboard.git/react-native-calculator-keyboard#readme",
|
|
16
63
|
"publishConfig": {
|
|
17
64
|
"registry": "https://registry.npmjs.org/"
|
|
18
65
|
},
|
|
19
|
-
"
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@commitlint/config-conventional": "^17.0.2",
|
|
68
|
+
"@evilmartians/lefthook": "^1.5.0",
|
|
69
|
+
"@react-native-community/cli": "15.0.1",
|
|
70
|
+
"@react-native/eslint-config": "^0.73.1",
|
|
71
|
+
"@release-it/conventional-changelog": "^9.0.2",
|
|
72
|
+
"@types/jest": "^29.5.5",
|
|
73
|
+
"@types/react": "^18.2.44",
|
|
74
|
+
"commitlint": "^17.0.2",
|
|
75
|
+
"del-cli": "^5.1.0",
|
|
76
|
+
"eslint": "^8.51.0",
|
|
77
|
+
"eslint-config-prettier": "^9.0.0",
|
|
78
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
79
|
+
"jest": "^29.7.0",
|
|
80
|
+
"prettier": "^3.0.3",
|
|
81
|
+
"react": "18.3.1",
|
|
82
|
+
"react-native": "0.76.5",
|
|
83
|
+
"react-native-builder-bob": "^0.32.0",
|
|
84
|
+
"release-it": "^17.10.0",
|
|
85
|
+
"turbo": "^1.10.7",
|
|
86
|
+
"typescript": "^5.2.2"
|
|
87
|
+
},
|
|
88
|
+
"resolutions": {
|
|
89
|
+
"@types/react": "^18.2.44"
|
|
90
|
+
},
|
|
91
|
+
"peerDependencies": {
|
|
92
|
+
"react": "*",
|
|
93
|
+
"react-native": "*"
|
|
94
|
+
},
|
|
95
|
+
"workspaces": [
|
|
96
|
+
"example"
|
|
97
|
+
],
|
|
98
|
+
"packageManager": "yarn@3.6.1",
|
|
99
|
+
"jest": {
|
|
100
|
+
"preset": "react-native",
|
|
101
|
+
"modulePathIgnorePatterns": [
|
|
102
|
+
"<rootDir>/example/node_modules",
|
|
103
|
+
"<rootDir>/lib/"
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
"commitlint": {
|
|
107
|
+
"extends": [
|
|
108
|
+
"@commitlint/config-conventional"
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
"release-it": {
|
|
112
|
+
"git": {
|
|
113
|
+
"commitMessage": "chore: release ${version}",
|
|
114
|
+
"tagName": "v${version}"
|
|
115
|
+
},
|
|
116
|
+
"npm": {
|
|
117
|
+
"publish": true
|
|
118
|
+
},
|
|
119
|
+
"github": {
|
|
120
|
+
"release": true
|
|
121
|
+
},
|
|
122
|
+
"plugins": {
|
|
123
|
+
"@release-it/conventional-changelog": {
|
|
124
|
+
"preset": "angular"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"eslintConfig": {
|
|
129
|
+
"root": true,
|
|
130
|
+
"extends": [
|
|
131
|
+
"@react-native",
|
|
132
|
+
"prettier"
|
|
133
|
+
],
|
|
134
|
+
"rules": {
|
|
135
|
+
"react/react-in-jsx-scope": "off",
|
|
136
|
+
"prettier/prettier": [
|
|
137
|
+
"error",
|
|
138
|
+
{
|
|
139
|
+
"quoteProps": "consistent",
|
|
140
|
+
"singleQuote": true,
|
|
141
|
+
"tabWidth": 2,
|
|
142
|
+
"trailingComma": "es5",
|
|
143
|
+
"useTabs": false
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"eslintIgnore": [
|
|
149
|
+
"node_modules/",
|
|
150
|
+
"lib/"
|
|
151
|
+
],
|
|
152
|
+
"prettier": {
|
|
153
|
+
"quoteProps": "consistent",
|
|
154
|
+
"singleQuote": true,
|
|
155
|
+
"tabWidth": 2,
|
|
156
|
+
"trailingComma": "es5",
|
|
157
|
+
"useTabs": false
|
|
158
|
+
},
|
|
159
|
+
"react-native-builder-bob": {
|
|
160
|
+
"source": "src",
|
|
161
|
+
"output": "lib",
|
|
162
|
+
"targets": [
|
|
163
|
+
[
|
|
164
|
+
"commonjs",
|
|
165
|
+
{
|
|
166
|
+
"esm": true
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
[
|
|
170
|
+
"module",
|
|
171
|
+
{
|
|
172
|
+
"esm": true
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
[
|
|
176
|
+
"typescript",
|
|
177
|
+
{
|
|
178
|
+
"project": "tsconfig.build.json",
|
|
179
|
+
"esm": true
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
]
|
|
183
|
+
},
|
|
184
|
+
"create-react-native-library": {
|
|
185
|
+
"type": "legacy-view",
|
|
186
|
+
"languages": "kotlin-swift",
|
|
187
|
+
"version": "0.45.5"
|
|
188
|
+
}
|
|
20
189
|
}
|