@momo-kits/calculator-keyboard 0.150.1-beta.2 → 0.150.1-rn80.7
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/lib/commonjs/index.js +24 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +25 -5
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +5 -3
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +5 -3
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +35 -8
package/lib/commonjs/index.js
CHANGED
|
@@ -8,19 +8,39 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
const
|
|
11
|
+
const NAME = 'RCTInputCalculator';
|
|
12
|
+
const NativeInput = (0, _reactNative.requireNativeComponent)(NAME);
|
|
12
13
|
const InputCalculator = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
14
|
+
const nativeRef = _react.default.useRef(null);
|
|
13
15
|
const _onChange = event => {
|
|
14
16
|
const currentText = event.nativeEvent.text;
|
|
15
17
|
props.onChange && props.onChange(event);
|
|
16
18
|
props.onChangeText && props.onChangeText(currentText);
|
|
17
19
|
};
|
|
18
|
-
const text = props.text
|
|
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
|
+
}));
|
|
19
39
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(NativeInput, {
|
|
20
40
|
...props,
|
|
21
|
-
ref:
|
|
41
|
+
ref: nativeRef,
|
|
22
42
|
onChange: _onChange,
|
|
23
|
-
|
|
43
|
+
value: text,
|
|
24
44
|
keybardColor: (0, _reactNative.processColor)(props.keyboardColor)
|
|
25
45
|
});
|
|
26
46
|
});
|
|
@@ -1 +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;
|
|
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,GA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,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
CHANGED
|
@@ -1,22 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { processColor } from 'react-native';
|
|
4
|
+
import { processColor, UIManager, findNodeHandle } from 'react-native';
|
|
5
5
|
import { requireNativeComponent } from 'react-native';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
const
|
|
7
|
+
const NAME = 'RCTInputCalculator';
|
|
8
|
+
const NativeInput = requireNativeComponent(NAME);
|
|
8
9
|
const InputCalculator = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
10
|
+
const nativeRef = React.useRef(null);
|
|
9
11
|
const _onChange = event => {
|
|
10
12
|
const currentText = event.nativeEvent.text;
|
|
11
13
|
props.onChange && props.onChange(event);
|
|
12
14
|
props.onChangeText && props.onChangeText(currentText);
|
|
13
15
|
};
|
|
14
|
-
const text = props.text
|
|
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
|
+
}));
|
|
15
35
|
return /*#__PURE__*/_jsx(NativeInput, {
|
|
16
36
|
...props,
|
|
17
|
-
ref:
|
|
37
|
+
ref: nativeRef,
|
|
18
38
|
onChange: _onChange,
|
|
19
|
-
|
|
39
|
+
value: text,
|
|
20
40
|
keybardColor: processColor(props.keyboardColor)
|
|
21
41
|
});
|
|
22
42
|
});
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +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,
|
|
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,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type TextInputProps, type ColorValue } from 'react-native';
|
|
3
|
-
import { TextInput } from 'react-native';
|
|
4
3
|
interface InputCalculatorProps extends TextInputProps {
|
|
5
4
|
text?: string | undefined;
|
|
6
5
|
keyboardColor?: ColorValue;
|
|
7
6
|
}
|
|
8
|
-
|
|
7
|
+
export type InputCalculatorRef = {
|
|
8
|
+
focus: () => void;
|
|
9
|
+
blur: () => void;
|
|
10
|
+
};
|
|
11
|
+
declare const InputCalculator: React.ForwardRefExoticComponent<InputCalculatorProps & React.RefAttributes<InputCalculatorRef>>;
|
|
9
12
|
export default InputCalculator;
|
|
10
|
-
export type { InputCalculatorProps };
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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,
|
|
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,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type TextInputProps, type ColorValue } from 'react-native';
|
|
3
|
-
import { TextInput } from 'react-native';
|
|
4
3
|
interface InputCalculatorProps extends TextInputProps {
|
|
5
4
|
text?: string | undefined;
|
|
6
5
|
keyboardColor?: ColorValue;
|
|
7
6
|
}
|
|
8
|
-
|
|
7
|
+
export type InputCalculatorRef = {
|
|
8
|
+
focus: () => void;
|
|
9
|
+
blur: () => void;
|
|
10
|
+
};
|
|
11
|
+
declare const InputCalculator: React.ForwardRefExoticComponent<InputCalculatorProps & React.RefAttributes<InputCalculatorRef>>;
|
|
9
12
|
export default InputCalculator;
|
|
10
|
-
export type { InputCalculatorProps };
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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,
|
|
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"}
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -5,18 +5,28 @@ import {
|
|
|
5
5
|
type TextInputProps,
|
|
6
6
|
type ColorValue,
|
|
7
7
|
processColor,
|
|
8
|
+
UIManager,
|
|
9
|
+
findNodeHandle,
|
|
8
10
|
} from 'react-native';
|
|
9
|
-
import { requireNativeComponent
|
|
11
|
+
import { requireNativeComponent } from 'react-native';
|
|
10
12
|
|
|
11
|
-
const
|
|
13
|
+
const NAME = 'RCTInputCalculator';
|
|
14
|
+
const NativeInput = requireNativeComponent<any>(NAME);
|
|
12
15
|
|
|
13
16
|
interface InputCalculatorProps extends TextInputProps {
|
|
14
17
|
text?: string | undefined;
|
|
15
18
|
keyboardColor?: ColorValue;
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
export type InputCalculatorRef = {
|
|
22
|
+
focus: () => void;
|
|
23
|
+
blur: () => void;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const InputCalculator = React.forwardRef<InputCalculatorRef, InputCalculatorProps>(
|
|
19
27
|
(props, ref) => {
|
|
28
|
+
const nativeRef = React.useRef<any>(null);
|
|
29
|
+
|
|
20
30
|
const _onChange = (
|
|
21
31
|
event: NativeSyntheticEvent<TextInputChangeEventData>
|
|
22
32
|
) => {
|
|
@@ -25,14 +35,33 @@ const InputCalculator = React.forwardRef<TextInput, InputCalculatorProps>(
|
|
|
25
35
|
props.onChangeText && props.onChangeText(currentText);
|
|
26
36
|
};
|
|
27
37
|
|
|
28
|
-
const text = props.text
|
|
38
|
+
const text = props.text ?? props.defaultValue ?? '';
|
|
39
|
+
|
|
40
|
+
React.useImperativeHandle(ref, () => ({
|
|
41
|
+
focus() {
|
|
42
|
+
const node = findNodeHandle(nativeRef.current);
|
|
43
|
+
if (!node) return;
|
|
44
|
+
const config = UIManager.getViewManagerConfig(NAME);
|
|
45
|
+
if (config?.Commands?.focus != null) {
|
|
46
|
+
UIManager.dispatchViewManagerCommand(node, config.Commands.focus, []);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
blur() {
|
|
50
|
+
const node = findNodeHandle(nativeRef.current);
|
|
51
|
+
if (!node) return;
|
|
52
|
+
const config = UIManager.getViewManagerConfig(NAME);
|
|
53
|
+
if (config?.Commands?.blur != null) {
|
|
54
|
+
UIManager.dispatchViewManagerCommand(node, config.Commands.blur, []);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
}));
|
|
29
58
|
|
|
30
59
|
return (
|
|
31
60
|
<NativeInput
|
|
32
61
|
{...props}
|
|
33
|
-
ref={
|
|
62
|
+
ref={nativeRef}
|
|
34
63
|
onChange={_onChange}
|
|
35
|
-
|
|
64
|
+
value={text}
|
|
36
65
|
keybardColor={processColor(props.keyboardColor)}
|
|
37
66
|
/>
|
|
38
67
|
);
|
|
@@ -40,5 +69,3 @@ const InputCalculator = React.forwardRef<TextInput, InputCalculatorProps>(
|
|
|
40
69
|
);
|
|
41
70
|
|
|
42
71
|
export default InputCalculator;
|
|
43
|
-
|
|
44
|
-
export type { InputCalculatorProps };
|