@momo-kits/calculator-keyboard 0.150.2-phuc.15 → 0.151.1-beta.2
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 +242 -108
- package/android/src/main/java/com/calculatorkeyboard/Event.kt +129 -0
- package/android/src/main/java/com/calculatorkeyboard/{RCTInputCalculator.kt → InputCalculatorViewManager.kt} +105 -33
- package/ios/CalculatorKeyboardView.h +32 -0
- package/ios/CalculatorKeyboardView.mm +274 -0
- package/ios/NativeInputCalculator.h +11 -0
- package/ios/NativeInputCalculator.mm +500 -0
- package/ios/Utils.h +10 -0
- package/ios/Utils.mm +25 -0
- package/package.json +21 -131
- package/react-native-calculator-keyboard.podspec +5 -4
- package/src/InputCalculatorNativeComponent.ts +71 -0
- package/src/index.tsx +93 -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
package/ios/InputCalculator.m
DELETED
|
@@ -1,85 +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
|
-
RCT_EXPORT_VIEW_PROPERTY(onKeyPress, RCTBubblingEventBlock)
|
|
60
|
-
RCT_EXPORT_VIEW_PROPERTY(onCustomKeyEvent, RCTDirectEventBlock)
|
|
61
|
-
|
|
62
|
-
RCT_EXPORT_METHOD(focus : (nonnull NSNumber *)viewTag)
|
|
63
|
-
{
|
|
64
|
-
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
65
|
-
UIView *view = viewRegistry[viewTag];
|
|
66
|
-
[view reactFocus];
|
|
67
|
-
}];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
RCT_EXPORT_METHOD(blur : (nonnull NSNumber *)viewTag)
|
|
71
|
-
{
|
|
72
|
-
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
73
|
-
UIView *view = viewRegistry[viewTag];
|
|
74
|
-
[view reactBlur];
|
|
75
|
-
}];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
RCT_EXPORT_VIEW_PROPERTY(keyboardColor, UIColor)
|
|
79
|
-
RCT_EXPORT_VIEW_PROPERTY(customKeyText, NSString)
|
|
80
|
-
RCT_EXPORT_VIEW_PROPERTY(customKeyBackground, NSString)
|
|
81
|
-
RCT_EXPORT_VIEW_PROPERTY(customKeyTextColor, NSString)
|
|
82
|
-
RCT_EXPORT_VIEW_PROPERTY(customKeyState, NSString)
|
|
83
|
-
|
|
84
|
-
@end
|
|
85
|
-
|
|
@@ -1,158 +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
|
-
@objc var onKeyPress: RCTBubblingEventBlock?
|
|
23
|
-
@objc var onCustomKeyEvent: RCTDirectEventBlock?
|
|
24
|
-
|
|
25
|
-
@objc var customKeyText: String? {
|
|
26
|
-
didSet { keyboardView?.customKeyText = customKeyText as String? }
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@objc var customKeyBackground: String? {
|
|
30
|
-
didSet { keyboardView?.customKeyBackground = customKeyBackground }
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@objc var customKeyTextColor: String? {
|
|
34
|
-
didSet { keyboardView?.customKeyTextColor = customKeyTextColor }
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@objc var customKeyState: String? {
|
|
38
|
-
didSet { keyboardView?.customKeyState = customKeyState }
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@objc func beginEditingInput(_ note: Notification) { onFocus?([:]) }
|
|
42
|
-
@objc func endEditingInput(_ note: Notification) { onBlur?([:]) }
|
|
43
|
-
|
|
44
|
-
@objc var value: String = "" {
|
|
45
|
-
didSet {
|
|
46
|
-
guard let tf = backedTextInputView as? UITextField else { return }
|
|
47
|
-
let old = tf.text ?? ""
|
|
48
|
-
if old == value { return }
|
|
49
|
-
|
|
50
|
-
let isFirstResponder = tf.isFirstResponder
|
|
51
|
-
let atEnd = isFirstResponder && tf.offset(from: tf.beginningOfDocument, to: tf.selectedTextRange?.start ?? tf.endOfDocument) == old.count
|
|
52
|
-
tf.text = value
|
|
53
|
-
if !isFirstResponder || atEnd,
|
|
54
|
-
let end = tf.position(from: tf.beginningOfDocument, offset: value.count) {
|
|
55
|
-
tf.selectedTextRange = tf.textRange(from: end, to: end)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
@objc var keyboardColor: UIColor = UIColor(hex: "#d9d9d9") {
|
|
61
|
-
didSet {
|
|
62
|
-
self.keyboardView?.setKeyboardColor(keyboardColor)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
override init(bridge: RCTBridge) {
|
|
68
|
-
super.init(bridge: bridge)
|
|
69
|
-
self.bridge = bridge
|
|
70
|
-
self.keyboardView = CalculatorKeyboardView()
|
|
71
|
-
self.keyboardView!.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: 240 + getbottomInset())
|
|
72
|
-
self.keyboardView!.input = self
|
|
73
|
-
|
|
74
|
-
backedTextInputView.inputView = self.keyboardView
|
|
75
|
-
backedTextInputView.inputView?.reloadInputViews()
|
|
76
|
-
|
|
77
|
-
NotificationCenter.default.addObserver(
|
|
78
|
-
self,
|
|
79
|
-
selector: #selector(beginEditingInput(_:)),
|
|
80
|
-
name: UITextField.textDidBeginEditingNotification,
|
|
81
|
-
object: backedTextInputView
|
|
82
|
-
)
|
|
83
|
-
NotificationCenter.default.addObserver(
|
|
84
|
-
self,
|
|
85
|
-
selector: #selector(endEditingInput(_:)),
|
|
86
|
-
name: UITextField.textDidEndEditingNotification,
|
|
87
|
-
object: backedTextInputView
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
func getbottomInset() -> CGFloat {
|
|
92
|
-
let window = UIApplication.shared.windows.first?.rootViewController?.view
|
|
93
|
-
let bottom = (window?.safeAreaInsets.bottom ?? 0) > 0 ? 21 : 0
|
|
94
|
-
return CGFloat(bottom)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
func keyDidPress(_ key: String) {
|
|
98
|
-
backedTextInputView.insertText(key)
|
|
99
|
-
value += key
|
|
100
|
-
|
|
101
|
-
if let bridge = bridge {
|
|
102
|
-
bridge.eventDispatcher().sendTextEvent(with: .change, reactTag: reactTag, text: value, key: "\(key)", eventCount: 1)
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
func onBackSpace() {
|
|
107
|
-
value = value.dropLast().description
|
|
108
|
-
DispatchQueue.main.async {
|
|
109
|
-
if let range = self.backedTextInputView.selectedTextRange,
|
|
110
|
-
let fromRange = self.backedTextInputView.position(from: range.start, offset: -1),
|
|
111
|
-
let newRange = self.backedTextInputView.textRange(from: fromRange, to: range.start)
|
|
112
|
-
{
|
|
113
|
-
self.backedTextInputView.replace(newRange, withText: "")
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if let bridge = bridge {
|
|
118
|
-
bridge.eventDispatcher().sendTextEvent(with: .change, reactTag: reactTag, text: value, key: "back", eventCount: 1)
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
func calculateResult() {
|
|
123
|
-
guard let textField = backedTextInputView as? UITextField,
|
|
124
|
-
let text = textField.text?.replacingOccurrences(of: "×", with: "*").replacingOccurrences(of: "÷", with: "/")
|
|
125
|
-
else {
|
|
126
|
-
return
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
let pattern = "^\\s*(-?\\d+(\\.\\d+)?\\s*[-+*/]\\s*)*-?\\d+(\\.\\d+)?\\s*$"
|
|
130
|
-
let regex = try? NSRegularExpression(pattern: pattern)
|
|
131
|
-
let range = NSRange(location: 0, length: text.utf16.count)
|
|
132
|
-
|
|
133
|
-
if regex?.firstMatch(in: text, options: [], range: range) != nil {
|
|
134
|
-
let expression = NSExpression(format: text)
|
|
135
|
-
if let result = expression.expressionValue(with: nil, context: nil) as? NSNumber {
|
|
136
|
-
textField.text = result.stringValue
|
|
137
|
-
value = result.stringValue
|
|
138
|
-
|
|
139
|
-
if let bridge = bridge {
|
|
140
|
-
bridge.eventDispatcher().sendTextEvent(with: .change, reactTag: reactTag, text: value, key: "=", eventCount: 1)
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
print("Invalid expression")
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
func emitCustomKey() {
|
|
150
|
-
onCustomKeyEvent?([:])
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
func emitKeyPress(_ key: String) {
|
|
154
|
-
onKeyPress?(["key": key])
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
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,72 +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(({
|
|
14
|
-
customKeyBackground = 'default',
|
|
15
|
-
keyboardColor = '',
|
|
16
|
-
customKeyText,
|
|
17
|
-
onKeyPress,
|
|
18
|
-
customKeyState = 'default',
|
|
19
|
-
onCustomKeyEvent,
|
|
20
|
-
...props
|
|
21
|
-
}, ref) => {
|
|
22
|
-
const nativeRef = _react.default.useRef(null);
|
|
23
|
-
const _onChange = event => {
|
|
24
|
-
const currentText = event.nativeEvent.text;
|
|
25
|
-
props.onChange && props.onChange(event);
|
|
26
|
-
props.onChangeText && props.onChangeText(currentText);
|
|
27
|
-
};
|
|
28
|
-
const text = props.text ?? props.defaultValue ?? '';
|
|
29
|
-
let keyBackground = '#D8D8D8';
|
|
30
|
-
let textKeyColor = '#000000';
|
|
31
|
-
if (customKeyBackground === 'primary') {
|
|
32
|
-
keyBackground = '#EB2F96';
|
|
33
|
-
textKeyColor = '#FFFFFF';
|
|
34
|
-
}
|
|
35
|
-
if (customKeyState === 'disable') {
|
|
36
|
-
keyBackground = '#EBEBF2';
|
|
37
|
-
textKeyColor = '#FFFFFF';
|
|
38
|
-
}
|
|
39
|
-
_react.default.useImperativeHandle(ref, () => ({
|
|
40
|
-
focus() {
|
|
41
|
-
const node = (0, _reactNative.findNodeHandle)(nativeRef.current);
|
|
42
|
-
if (!node) return;
|
|
43
|
-
const config = _reactNative.UIManager.getViewManagerConfig(NAME);
|
|
44
|
-
if (config?.Commands?.focus != null) {
|
|
45
|
-
_reactNative.UIManager.dispatchViewManagerCommand(node, config.Commands.focus, []);
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
blur() {
|
|
49
|
-
const node = (0, _reactNative.findNodeHandle)(nativeRef.current);
|
|
50
|
-
if (!node) return;
|
|
51
|
-
const config = _reactNative.UIManager.getViewManagerConfig(NAME);
|
|
52
|
-
if (config?.Commands?.blur != null) {
|
|
53
|
-
_reactNative.UIManager.dispatchViewManagerCommand(node, config.Commands.blur, []);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}));
|
|
57
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(NativeInput, {
|
|
58
|
-
...props,
|
|
59
|
-
ref: nativeRef,
|
|
60
|
-
onChange: _onChange,
|
|
61
|
-
onKeyPress: onKeyPress,
|
|
62
|
-
value: text,
|
|
63
|
-
keybardColor: (0, _reactNative.processColor)(keyboardColor),
|
|
64
|
-
customKeyText: customKeyText,
|
|
65
|
-
customKeyBackground: keyBackground,
|
|
66
|
-
customKeyTextColor: textKeyColor,
|
|
67
|
-
customKeyState: customKeyState,
|
|
68
|
-
onCustomKeyEvent: onCustomKeyEvent
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
var _default = exports.default = InputCalculator;
|
|
72
|
-
//# 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","customKeyBackground","keyboardColor","customKeyText","onKeyPress","customKeyState","onCustomKeyEvent","props","ref","nativeRef","useRef","_onChange","event","currentText","nativeEvent","text","onChange","onChangeText","defaultValue","keyBackground","textKeyColor","useImperativeHandle","focus","node","findNodeHandle","current","config","UIManager","getViewManagerConfig","Commands","dispatchViewManagerCommand","blur","jsx","value","keybardColor","processColor","customKeyTextColor","_default","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AASsB,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEtB,MAAMG,IAAI,GAAG,oBAAoB;AACjC,MAAMC,WAAW,GAAG,IAAAC,mCAAsB,EAAMF,IAAI,CAAC;AAmBrD,MAAMG,eAAe,gBAAGC,cAAK,CAACC,UAAU,CAItC,CACE;EACEC,mBAAmB,GAAG,SAAS;EAC/BC,aAAa,GAAG,EAAE;EAClBC,aAAa;EACbC,UAAU;EACVC,cAAc,GAAG,SAAS;EAC1BC,gBAAgB;EAChB,GAAGC;AACL,CAAC,EACDC,GAAG,KACA;EACH,MAAMC,SAAS,GAAGV,cAAK,CAACW,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,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AAEC,SAAU;IACfO,QAAQ,EAAEL,SAAU;IACpBP,UAAU,EAAEA,UAAW;IACvB6B,KAAK,EAAElB,IAAK;IACZmB,YAAY,EAAE,IAAAC,yBAAY,EAACjC,aAAa,CAAE;IAC1CC,aAAa,EAAEA,aAAc;IAC7BF,mBAAmB,EAAEkB,aAAc;IACnCiB,kBAAkB,EAAEhB,YAAa;IACjCf,cAAc,EAAEA,cAAe;IAC/BC,gBAAgB,EAAEA;EAAiB,CACpC,CAAC;AAEN,CACF,CAAC;AAAC,IAAA+B,QAAA,GAAAC,OAAA,CAAA5C,OAAA,GAEaI,eAAe","ignoreList":[]}
|
package/lib/module/index.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { findNodeHandle, processColor, requireNativeComponent, UIManager } from 'react-native';
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
const NAME = 'RCTInputCalculator';
|
|
7
|
-
const NativeInput = requireNativeComponent(NAME);
|
|
8
|
-
const InputCalculator = /*#__PURE__*/React.forwardRef(({
|
|
9
|
-
customKeyBackground = 'default',
|
|
10
|
-
keyboardColor = '',
|
|
11
|
-
customKeyText,
|
|
12
|
-
onKeyPress,
|
|
13
|
-
customKeyState = 'default',
|
|
14
|
-
onCustomKeyEvent,
|
|
15
|
-
...props
|
|
16
|
-
}, ref) => {
|
|
17
|
-
const nativeRef = React.useRef(null);
|
|
18
|
-
const _onChange = event => {
|
|
19
|
-
const currentText = event.nativeEvent.text;
|
|
20
|
-
props.onChange && props.onChange(event);
|
|
21
|
-
props.onChangeText && props.onChangeText(currentText);
|
|
22
|
-
};
|
|
23
|
-
const text = props.text ?? props.defaultValue ?? '';
|
|
24
|
-
let keyBackground = '#D8D8D8';
|
|
25
|
-
let textKeyColor = '#000000';
|
|
26
|
-
if (customKeyBackground === 'primary') {
|
|
27
|
-
keyBackground = '#EB2F96';
|
|
28
|
-
textKeyColor = '#FFFFFF';
|
|
29
|
-
}
|
|
30
|
-
if (customKeyState === 'disable') {
|
|
31
|
-
keyBackground = '#EBEBF2';
|
|
32
|
-
textKeyColor = '#FFFFFF';
|
|
33
|
-
}
|
|
34
|
-
React.useImperativeHandle(ref, () => ({
|
|
35
|
-
focus() {
|
|
36
|
-
const node = findNodeHandle(nativeRef.current);
|
|
37
|
-
if (!node) return;
|
|
38
|
-
const config = UIManager.getViewManagerConfig(NAME);
|
|
39
|
-
if (config?.Commands?.focus != null) {
|
|
40
|
-
UIManager.dispatchViewManagerCommand(node, config.Commands.focus, []);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
blur() {
|
|
44
|
-
const node = findNodeHandle(nativeRef.current);
|
|
45
|
-
if (!node) return;
|
|
46
|
-
const config = UIManager.getViewManagerConfig(NAME);
|
|
47
|
-
if (config?.Commands?.blur != null) {
|
|
48
|
-
UIManager.dispatchViewManagerCommand(node, config.Commands.blur, []);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}));
|
|
52
|
-
return /*#__PURE__*/_jsx(NativeInput, {
|
|
53
|
-
...props,
|
|
54
|
-
ref: nativeRef,
|
|
55
|
-
onChange: _onChange,
|
|
56
|
-
onKeyPress: onKeyPress,
|
|
57
|
-
value: text,
|
|
58
|
-
keybardColor: processColor(keyboardColor),
|
|
59
|
-
customKeyText: customKeyText,
|
|
60
|
-
customKeyBackground: keyBackground,
|
|
61
|
-
customKeyTextColor: textKeyColor,
|
|
62
|
-
customKeyState: customKeyState,
|
|
63
|
-
onCustomKeyEvent: onCustomKeyEvent
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
export default InputCalculator;
|
|
67
|
-
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","findNodeHandle","processColor","requireNativeComponent","UIManager","jsx","_jsx","NAME","NativeInput","InputCalculator","forwardRef","customKeyBackground","keyboardColor","customKeyText","onKeyPress","customKeyState","onCustomKeyEvent","props","ref","nativeRef","useRef","_onChange","event","currentText","nativeEvent","text","onChange","onChangeText","defaultValue","keyBackground","textKeyColor","useImperativeHandle","focus","node","current","config","getViewManagerConfig","Commands","dispatchViewManagerCommand","blur","value","keybardColor","customKeyTextColor"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAEEC,cAAc,EAEdC,YAAY,EACZC,sBAAsB,EAGtBC,SAAS,QACJ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEtB,MAAMC,IAAI,GAAG,oBAAoB;AACjC,MAAMC,WAAW,GAAGL,sBAAsB,CAAMI,IAAI,CAAC;AAmBrD,MAAME,eAAe,gBAAGT,KAAK,CAACU,UAAU,CAItC,CACE;EACEC,mBAAmB,GAAG,SAAS;EAC/BC,aAAa,GAAG,EAAE;EAClBC,aAAa;EACbC,UAAU;EACVC,cAAc,GAAG,SAAS;EAC1BC,gBAAgB;EAChB,GAAGC;AACL,CAAC,EACDC,GAAG,KACA;EACH,MAAMC,SAAS,GAAGnB,KAAK,CAACoB,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;EACnD,IAAIC,aAAa,GAAG,SAAS;EAC7B,IAAIC,YAAY,GAAG,SAAS;EAE5B,IAAInB,mBAAmB,KAAK,SAAS,EAAE;IACrCkB,aAAa,GAAG,SAAS;IACzBC,YAAY,GAAG,SAAS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;IAC/BC,gBAAgB,EAAEA;EAAiB,CACpC,CAAC;AAEN,CACF,CAAC;AAED,eAAeP,eAAe","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type ColorValue, type TextInputProps } from 'react-native';
|
|
3
|
-
type KeyPressEvent = {
|
|
4
|
-
nativeEvent: {
|
|
5
|
-
key: string;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
interface InputCalculatorProps extends TextInputProps {
|
|
9
|
-
text?: string | undefined;
|
|
10
|
-
keyboardColor?: ColorValue;
|
|
11
|
-
onKeyPress?: (e: KeyPressEvent) => void;
|
|
12
|
-
customKeyText?: string | undefined;
|
|
13
|
-
customKeyBackground?: string | undefined;
|
|
14
|
-
customKeyState?: string | undefined;
|
|
15
|
-
onCustomKeyEvent?: () => void;
|
|
16
|
-
}
|
|
17
|
-
export type InputCalculatorRef = {
|
|
18
|
-
focus: () => void;
|
|
19
|
-
blur: () => void;
|
|
20
|
-
};
|
|
21
|
-
declare const InputCalculator: React.ForwardRefExoticComponent<InputCalculatorProps & React.RefAttributes<InputCalculatorRef>>;
|
|
22
|
-
export default InputCalculator;
|
|
23
|
-
//# 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,EACL,KAAK,UAAU,EAMf,KAAK,cAAc,EAEpB,MAAM,cAAc,CAAC;AAKtB,KAAK,aAAa,GAAG;IAAE,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAEtD,UAAU,oBAAqB,SAAQ,cAAc;IACnD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,eAAe,iGA2EpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type ColorValue, type TextInputProps } from 'react-native';
|
|
3
|
-
type KeyPressEvent = {
|
|
4
|
-
nativeEvent: {
|
|
5
|
-
key: string;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
interface InputCalculatorProps extends TextInputProps {
|
|
9
|
-
text?: string | undefined;
|
|
10
|
-
keyboardColor?: ColorValue;
|
|
11
|
-
onKeyPress?: (e: KeyPressEvent) => void;
|
|
12
|
-
customKeyText?: string | undefined;
|
|
13
|
-
customKeyBackground?: string | undefined;
|
|
14
|
-
customKeyState?: string | undefined;
|
|
15
|
-
onCustomKeyEvent?: () => void;
|
|
16
|
-
}
|
|
17
|
-
export type InputCalculatorRef = {
|
|
18
|
-
focus: () => void;
|
|
19
|
-
blur: () => void;
|
|
20
|
-
};
|
|
21
|
-
declare const InputCalculator: React.ForwardRefExoticComponent<InputCalculatorProps & React.RefAttributes<InputCalculatorRef>>;
|
|
22
|
-
export default InputCalculator;
|
|
23
|
-
//# 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,EACL,KAAK,UAAU,EAMf,KAAK,cAAc,EAEpB,MAAM,cAAc,CAAC;AAKtB,KAAK,aAAa,GAAG;IAAE,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAEtD,UAAU,oBAAqB,SAAQ,cAAc;IACnD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,eAAe,iGA2EpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|