@momo-kits/calculator-keyboard 0.150.2-phuc.13 → 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 +184 -95
- 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 +124 -82
- package/android/src/main/java/com/calculatorkeyboard/RCTInputCalculator.kt +0 -339
- package/ios/CalculatorKeyboardView.swift +0 -165
- 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 -68
- 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 -31
- 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 -31
- package/lib/typescript/module/src/index.d.ts.map +0 -1
|
@@ -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: NSNumber? {
|
|
38
|
-
didSet { keyboardView?.customKeyState = customKeyState?.intValue }
|
|
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 = exports.CustomKeyState = exports.CustomKeyBackground = 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
|
-
let CustomKeyBackground = exports.CustomKeyBackground = /*#__PURE__*/function (CustomKeyBackground) {
|
|
14
|
-
CustomKeyBackground[CustomKeyBackground["Default"] = 0] = "Default";
|
|
15
|
-
CustomKeyBackground[CustomKeyBackground["Primary"] = 1] = "Primary";
|
|
16
|
-
return CustomKeyBackground;
|
|
17
|
-
}({});
|
|
18
|
-
let CustomKeyState = exports.CustomKeyState = /*#__PURE__*/function (CustomKeyState) {
|
|
19
|
-
CustomKeyState[CustomKeyState["Default"] = 0] = "Default";
|
|
20
|
-
CustomKeyState[CustomKeyState["Disable"] = 1] = "Disable";
|
|
21
|
-
return CustomKeyState;
|
|
22
|
-
}({});
|
|
23
|
-
const InputCalculator = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
24
|
-
const nativeRef = _react.default.useRef(null);
|
|
25
|
-
const _onChange = event => {
|
|
26
|
-
const currentText = event.nativeEvent.text;
|
|
27
|
-
props.onChange && props.onChange(event);
|
|
28
|
-
props.onChangeText && props.onChangeText(currentText);
|
|
29
|
-
};
|
|
30
|
-
const _onKeyPress = _react.default.useCallback(e => {
|
|
31
|
-
props.onKeyPress?.(e);
|
|
32
|
-
}, [props.onKeyPress]);
|
|
33
|
-
const _onCustomKeyEvent = _react.default.useCallback(() => {
|
|
34
|
-
props.onCustomKeyEvent?.();
|
|
35
|
-
}, [props.onCustomKeyEvent]);
|
|
36
|
-
const text = props.text ?? props.defaultValue ?? '';
|
|
37
|
-
const customKeyBackground = props.customKeyBackground == 0 ? "#D8D8D8" : "#EB2F96";
|
|
38
|
-
const customKeyTextColor = props.customKeyBackground == 0 ? "#FFFFFF" : "#000000";
|
|
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)(props.keyboardColor),
|
|
64
|
-
customKeyText: props.customKeyText,
|
|
65
|
-
customKeyBackground: customKeyBackground,
|
|
66
|
-
customKeyTextColor: customKeyTextColor,
|
|
67
|
-
customKeyState: props.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","CustomKeyBackground","exports","CustomKeyState","InputCalculator","React","forwardRef","props","ref","nativeRef","useRef","_onChange","event","currentText","nativeEvent","text","onChange","onChangeText","_onKeyPress","useCallback","onKeyPress","_onCustomKeyEvent","onCustomKeyEvent","defaultValue","customKeyBackground","customKeyTextColor","useImperativeHandle","focus","node","findNodeHandle","current","config","UIManager","getViewManagerConfig","Commands","dispatchViewManagerCommand","blur","jsx","value","keybardColor","processColor","keyboardColor","customKeyText","customKeyState","_default"],"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;AAAC,IAI1CG,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,0BAAnBA,mBAAmB;EAAnBA,mBAAmB,CAAnBA,mBAAmB;EAAnBA,mBAAmB,CAAnBA,mBAAmB;EAAA,OAAnBA,mBAAmB;AAAA;AAAA,IAInBE,cAAc,GAAAD,OAAA,CAAAC,cAAA,0BAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAmB1B,MAAMC,eAAe,gBAAGC,cAA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EG,QAAQ,EAAEP,KAAK,IAAI,IAAI,EAAE;QACjCK,sBAAS,CAACG,0BAA0B,CAACP,IAAI,EAAEG,MAAM,CAACG,QAAQ,CAACP,KAAK,EAAE,EAAE,CAAC;MACzE;IACJ,CAAC;IACDS,IAAIA,CAAA,EAAG;MACH,MAAMR,IAAI,GAAG,IAAAC,2BAAc,EAACpB,SAAS,CAACqB,OAAO,CAAC;MAC9C,IAAI,CAACF,IAAI,EAAE;MACX,MAAMG,MAAM,GAAGC,sBAAS,CAACC,oBAAoB,CAACnC,IAAI,CAAC;MACnD,IAAIiC,MAAM,EAAEG,QAAQ,EAAEE,IAAI,IAAI,IAAI,EAAE;QAChCJ,sBAAS,CAACG,0BAA0B,CAACP,IAAI,EAAEG,MAAM,CAACG,QAAQ,CAACE,IAAI,EAAE,EAAE,CAAC;MACxE;IACJ;EACJ,CAAC,CAAC,CAAC;EAEH,oBACI,IAAA1C,WAAA,CAAA2C,GAAA,EAACtC,WAAW;IAAA,GACJQ,KAAK;IACTC,GAAG,EAAEC,SAAU;IACfO,QAAQ,EAAEL,SAAU;IACpBS,UAAU,EAAEF,WAAY;IACxBoB,KAAK,EAAEvB,IAAK;IACZwB,YAAY,EAAE,IAAAC,yBAAY,EAACjC,KAAK,CAACkC,aAAa,CAAE;IAChDC,aAAa,EAAEnC,KAAK,CAACmC,aAAc;IACnClB,mBAAmB,EAAEA,mBAAoB;IACzCC,kBAAkB,EAAEA,kBAAmB;IACvCkB,cAAc,EAAEpC,KAAK,CAACoC,cAAe;IACrCrB,gBAAgB,EAAED;EAAkB,CACvC,CAAC;AAEV,CACJ,CAAC;AAAC,IAAAuB,QAAA,GAAA1C,OAAA,CAAAL,OAAA,GAEaO,eAAe","ignoreList":[]}
|
package/lib/module/index.js
DELETED
|
@@ -1,68 +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
|
-
export let CustomKeyBackground = /*#__PURE__*/function (CustomKeyBackground) {
|
|
10
|
-
CustomKeyBackground[CustomKeyBackground["Default"] = 0] = "Default";
|
|
11
|
-
CustomKeyBackground[CustomKeyBackground["Primary"] = 1] = "Primary";
|
|
12
|
-
return CustomKeyBackground;
|
|
13
|
-
}({});
|
|
14
|
-
export let CustomKeyState = /*#__PURE__*/function (CustomKeyState) {
|
|
15
|
-
CustomKeyState[CustomKeyState["Default"] = 0] = "Default";
|
|
16
|
-
CustomKeyState[CustomKeyState["Disable"] = 1] = "Disable";
|
|
17
|
-
return CustomKeyState;
|
|
18
|
-
}({});
|
|
19
|
-
const InputCalculator = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
20
|
-
const nativeRef = React.useRef(null);
|
|
21
|
-
const _onChange = event => {
|
|
22
|
-
const currentText = event.nativeEvent.text;
|
|
23
|
-
props.onChange && props.onChange(event);
|
|
24
|
-
props.onChangeText && props.onChangeText(currentText);
|
|
25
|
-
};
|
|
26
|
-
const _onKeyPress = React.useCallback(e => {
|
|
27
|
-
props.onKeyPress?.(e);
|
|
28
|
-
}, [props.onKeyPress]);
|
|
29
|
-
const _onCustomKeyEvent = React.useCallback(() => {
|
|
30
|
-
props.onCustomKeyEvent?.();
|
|
31
|
-
}, [props.onCustomKeyEvent]);
|
|
32
|
-
const text = props.text ?? props.defaultValue ?? '';
|
|
33
|
-
const customKeyBackground = props.customKeyBackground == 0 ? "#D8D8D8" : "#EB2F96";
|
|
34
|
-
const customKeyTextColor = props.customKeyBackground == 0 ? "#FFFFFF" : "#000000";
|
|
35
|
-
React.useImperativeHandle(ref, () => ({
|
|
36
|
-
focus() {
|
|
37
|
-
const node = findNodeHandle(nativeRef.current);
|
|
38
|
-
if (!node) return;
|
|
39
|
-
const config = UIManager.getViewManagerConfig(NAME);
|
|
40
|
-
if (config?.Commands?.focus != null) {
|
|
41
|
-
UIManager.dispatchViewManagerCommand(node, config.Commands.focus, []);
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
blur() {
|
|
45
|
-
const node = findNodeHandle(nativeRef.current);
|
|
46
|
-
if (!node) return;
|
|
47
|
-
const config = UIManager.getViewManagerConfig(NAME);
|
|
48
|
-
if (config?.Commands?.blur != null) {
|
|
49
|
-
UIManager.dispatchViewManagerCommand(node, config.Commands.blur, []);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}));
|
|
53
|
-
return /*#__PURE__*/_jsx(NativeInput, {
|
|
54
|
-
...props,
|
|
55
|
-
ref: nativeRef,
|
|
56
|
-
onChange: _onChange,
|
|
57
|
-
onKeyPress: _onKeyPress,
|
|
58
|
-
value: text,
|
|
59
|
-
keybardColor: processColor(props.keyboardColor),
|
|
60
|
-
customKeyText: props.customKeyText,
|
|
61
|
-
customKeyBackground: customKeyBackground,
|
|
62
|
-
customKeyTextColor: customKeyTextColor,
|
|
63
|
-
customKeyState: props.customKeyState,
|
|
64
|
-
onCustomKeyEvent: _onCustomKeyEvent
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
export default InputCalculator;
|
|
68
|
-
//# 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","CustomKeyBackground","CustomKeyState","InputCalculator","forwardRef","props","ref","nativeRef","useRef","_onChange","event","currentText","nativeEvent","text","onChange","onChangeText","_onKeyPress","useCallback","e","onKeyPress","_onCustomKeyEvent","onCustomKeyEvent","defaultValue","customKeyBackground","customKeyTextColor","useImperativeHandle","focus","node","current","config","getViewManagerConfig","Commands","dispatchViewManagerCommand","blur","value","keybardColor","keyboardColor","customKeyText","customKeyState"],"source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;IACxBkB,KAAK,EAAErB,IAAK;IACZsB,YAAY,EAAE1C,YAAY,CAACY,KAAK,CAAC+B,aAAa,CAAE;IAChDC,aAAa,EAAEhC,KAAK,CAACgC,aAAc;IACnCd,mBAAmB,EAAEA,mBAAoB;IACzCC,kBAAkB,EAAEA,kBAAmB;IACvCc,cAAc,EAAEjC,KAAK,CAACiC,cAAe;IACrCjB,gBAAgB,EAAED;EAAkB,CACvC,CAAC;AAEV,CACJ,CAAC;AAED,eAAejB,eAAe","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type TextInputProps, type ColorValue } from 'react-native';
|
|
3
|
-
type KeyPressEvent = {
|
|
4
|
-
nativeEvent: {
|
|
5
|
-
key: string;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export declare enum CustomKeyBackground {
|
|
9
|
-
Default = 0,
|
|
10
|
-
Primary = 1
|
|
11
|
-
}
|
|
12
|
-
export declare enum CustomKeyState {
|
|
13
|
-
Default = 0,
|
|
14
|
-
Disable = 1
|
|
15
|
-
}
|
|
16
|
-
interface InputCalculatorProps extends TextInputProps {
|
|
17
|
-
text?: string | undefined;
|
|
18
|
-
keyboardColor?: ColorValue;
|
|
19
|
-
onKeyPress?: (e: KeyPressEvent) => void;
|
|
20
|
-
customKeyText?: string | undefined;
|
|
21
|
-
customKeyBackground?: CustomKeyBackground;
|
|
22
|
-
customKeyState?: CustomKeyState;
|
|
23
|
-
onCustomKeyEvent?: () => void;
|
|
24
|
-
}
|
|
25
|
-
export type InputCalculatorRef = {
|
|
26
|
-
focus: () => void;
|
|
27
|
-
blur: () => void;
|
|
28
|
-
};
|
|
29
|
-
declare const InputCalculator: React.ForwardRefExoticComponent<InputCalculatorProps & React.RefAttributes<InputCalculatorRef>>;
|
|
30
|
-
export default InputCalculator;
|
|
31
|
-
//# 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,EAGH,KAAK,cAAc,EACnB,KAAK,UAAU,EAIlB,MAAM,cAAc,CAAC;AAMtB,KAAK,aAAa,GAAG;IAAE,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAEtD,oBAAY,mBAAmB;IAC3B,OAAO,IAAI;IAAE,OAAO,IAAI;CAC3B;AAED,oBAAY,cAAc;IACtB,OAAO,IAAI;IAAE,OAAO,IAAI;CAC3B;AAED,UAAU,oBAAqB,SAAQ,cAAc;IACjD,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,mBAAmB,CAAC;IAC1C,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CACjC;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC7B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF,QAAA,MAAM,eAAe,iGA2DpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type TextInputProps, type ColorValue } from 'react-native';
|
|
3
|
-
type KeyPressEvent = {
|
|
4
|
-
nativeEvent: {
|
|
5
|
-
key: string;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export declare enum CustomKeyBackground {
|
|
9
|
-
Default = 0,
|
|
10
|
-
Primary = 1
|
|
11
|
-
}
|
|
12
|
-
export declare enum CustomKeyState {
|
|
13
|
-
Default = 0,
|
|
14
|
-
Disable = 1
|
|
15
|
-
}
|
|
16
|
-
interface InputCalculatorProps extends TextInputProps {
|
|
17
|
-
text?: string | undefined;
|
|
18
|
-
keyboardColor?: ColorValue;
|
|
19
|
-
onKeyPress?: (e: KeyPressEvent) => void;
|
|
20
|
-
customKeyText?: string | undefined;
|
|
21
|
-
customKeyBackground?: CustomKeyBackground;
|
|
22
|
-
customKeyState?: CustomKeyState;
|
|
23
|
-
onCustomKeyEvent?: () => void;
|
|
24
|
-
}
|
|
25
|
-
export type InputCalculatorRef = {
|
|
26
|
-
focus: () => void;
|
|
27
|
-
blur: () => void;
|
|
28
|
-
};
|
|
29
|
-
declare const InputCalculator: React.ForwardRefExoticComponent<InputCalculatorProps & React.RefAttributes<InputCalculatorRef>>;
|
|
30
|
-
export default InputCalculator;
|
|
31
|
-
//# 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,EAGH,KAAK,cAAc,EACnB,KAAK,UAAU,EAIlB,MAAM,cAAc,CAAC;AAMtB,KAAK,aAAa,GAAG;IAAE,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAEtD,oBAAY,mBAAmB;IAC3B,OAAO,IAAI;IAAE,OAAO,IAAI;CAC3B;AAED,oBAAY,cAAc;IACtB,OAAO,IAAI;IAAE,OAAO,IAAI;CAC3B;AAED,UAAU,oBAAqB,SAAQ,cAAc;IACjD,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,mBAAmB,CAAC;IAC1C,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CACjC;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC7B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF,QAAA,MAAM,eAAe,iGA2DpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|