@momo-kits/calculator-keyboard 0.125.4-rc.6 → 0.150.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.
@@ -0,0 +1,43 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "react-native-calculator-keyboard"
8
+ s.version = "0.0.1"
9
+ s.summary = package["description"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
12
+ s.authors = package["author"]
13
+
14
+ s.platforms = { :ios => min_ios_version_supported }
15
+ s.source = { :git => "https://github.com/wem2017/react-native-calculator-keyboard.git/react-native-calculator-keyboard.git", :tag => "#{s.version}" }
16
+
17
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
18
+ s.resources = "**/Assets/**/*.{json}"
19
+
20
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
21
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
22
+ if respond_to?(:install_modules_dependencies, true)
23
+ install_modules_dependencies(s)
24
+ else
25
+ s.dependency "React-Core"
26
+
27
+ # Don't install the dependencies when we run `pod install` in the old architecture.
28
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
29
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
30
+ s.pod_target_xcconfig = {
31
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
32
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
33
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
34
+ }
35
+ s.dependency "React-RCTFabric"
36
+ s.dependency "React-Codegen"
37
+ s.dependency "RCT-Folly"
38
+ s.dependency "RCTRequired"
39
+ s.dependency "RCTTypeSafety"
40
+ s.dependency "ReactCommon/turbomodule/core"
41
+ end
42
+ end
43
+ end
package/src/index.tsx ADDED
@@ -0,0 +1,44 @@
1
+ import React from 'react';
2
+ import {
3
+ type NativeSyntheticEvent,
4
+ type TextInputChangeEventData,
5
+ type TextInputProps,
6
+ type ColorValue,
7
+ processColor,
8
+ } from 'react-native';
9
+ import { requireNativeComponent, TextInput } from 'react-native';
10
+
11
+ const NativeInput = requireNativeComponent<any>('RCTInputCalculator');
12
+
13
+ interface InputCalculatorProps extends TextInputProps {
14
+ text?: string | undefined;
15
+ keyboardColor?: ColorValue;
16
+ }
17
+
18
+ const InputCalculator = React.forwardRef<TextInput, InputCalculatorProps>(
19
+ (props, ref) => {
20
+ const _onChange = (
21
+ event: NativeSyntheticEvent<TextInputChangeEventData>
22
+ ) => {
23
+ const currentText = event.nativeEvent.text;
24
+ props.onChange && props.onChange(event);
25
+ props.onChangeText && props.onChangeText(currentText);
26
+ };
27
+
28
+ const text = props.text || props.defaultValue || '';
29
+
30
+ return (
31
+ <NativeInput
32
+ {...props}
33
+ ref={ref}
34
+ onChange={_onChange}
35
+ text={text}
36
+ keybardColor={processColor(props.keyboardColor)}
37
+ />
38
+ );
39
+ }
40
+ );
41
+
42
+ export default InputCalculator;
43
+
44
+ export type { InputCalculatorProps };
package/index.tsx DELETED
@@ -1,135 +0,0 @@
1
- import React, {useEffect, useRef, useState} from 'react';
2
- import {
3
- AppState,
4
- Platform,
5
- requireNativeComponent,
6
- TextInput,
7
- } from 'react-native';
8
- import {InputCalculatorProps} from './types';
9
-
10
- const {State: TextInputState} = TextInput;
11
-
12
- export const Keys = {
13
- CALCULATOR_TEXT_INPUT_FOCUSED: 'CALCULATOR_TEXT_INPUT_FOCUSED',
14
- CALCULATOR_TEXT_INPUT_UNFOCUSED: 'CALCULATOR_TEXT_INPUT_UNFOCUSED',
15
- CALCULATOR_DISMISS: 'CALCULATOR_DISMISS',
16
- CALCULATOR_CALCULATE: 'CALCULATOR_CALCULATE',
17
- CALCULATOR_HEIGHT_UPDATED: 'CALCULATOR_HEIGHT_UPDATED',
18
- CALULATOR_PUSH_KEY: 'CALULATOR_PUSH_KEY',
19
- };
20
-
21
- const CalculatorKeyboard: React.FC<InputCalculatorProps> = props => {
22
- // const [isFocus, setIsFocus] = useState(false);
23
- const [lastNativeText, setLastNativeText] = useState(props.value);
24
- const inputRef = useRef<TextInput>(null);
25
-
26
- useEffect(() => {
27
- const nativeProps = {};
28
- if (lastNativeText !== props.value && typeof props.value === 'string') {
29
- // @ts-ignore
30
- nativeProps.text = props.value;
31
- }
32
- if (
33
- Object.keys(nativeProps).length > 0 &&
34
- inputRef.current &&
35
- inputRef.current.setNativeProps
36
- ) {
37
- inputRef.current.setNativeProps(nativeProps);
38
- }
39
-
40
- if (props.selectionState && props.selection && props.selection.end) {
41
- props.selectionState.update(props.selection.start, props.selection.end);
42
- }
43
- }, [props.value, props.selection, props.selectionState, lastNativeText]);
44
-
45
- useEffect(() => {
46
- AppState.addEventListener('change', handleAppStateChange);
47
- return () => {
48
- AppState.addEventListener('change', handleAppStateChange);
49
- };
50
- }, []);
51
-
52
- const handleAppStateChange = (nextAppState: string) => {
53
- if (nextAppState === 'background' && Platform.OS === 'android') {
54
- blur();
55
- }
56
- };
57
-
58
- const blur = () => {
59
- if (inputRef.current && typeof inputRef.current.blur === 'function') {
60
- inputRef.current.blur();
61
- }
62
- };
63
-
64
- // const focus = () => {
65
- // if (inputRef.current && typeof inputRef.current.focus === 'function') {
66
- // inputRef.current.focus();
67
- // }
68
- // };
69
-
70
- const getText = () => {
71
- if (typeof props.value === 'string') {
72
- console.log('props.value', props.value);
73
- return props.value;
74
- }
75
- if (typeof props.defaultValue === 'string') {
76
- return props.defaultValue;
77
- }
78
-
79
- return '';
80
- };
81
-
82
- const onFocus = (event: any) => {
83
- // setIsFocus(true);
84
- if (props.onFocus) {
85
- props.onFocus(event);
86
- }
87
- if (inputRef.current != null && TextInputState) {
88
- TextInputState.focusTextInput(inputRef.current);
89
- }
90
- };
91
-
92
- const onBlur = (event: any) => {
93
- // setIsFocus(false);
94
- if (props.onBlur) {
95
- props.onBlur(event);
96
- }
97
- };
98
-
99
- const onChange = (event: any) => {
100
- if (inputRef.current && inputRef.current.setNativeProps) {
101
- inputRef.current.setNativeProps({
102
- mostRecentEventCount: event.nativeEvent.eventCount,
103
- });
104
- }
105
-
106
- const {text} = event.nativeEvent;
107
- if (props.onChange) {
108
- props.onChange(event);
109
- }
110
- if (props.onChangeText) {
111
- props.onChangeText(text);
112
- }
113
- if (!inputRef) {
114
- return;
115
- }
116
- setLastNativeText(text);
117
- };
118
-
119
- return (
120
- <RCTInputCalculator
121
- {...props}
122
- ref={inputRef}
123
- onFocus={onFocus}
124
- onBlur={onBlur}
125
- onChange={onChange}
126
- text={getText()}
127
- />
128
- );
129
- };
130
-
131
- // @ts-ignore
132
- const RCTInputCalculator =
133
- requireNativeComponent<InputCalculatorProps>('RCTInputCalculator');
134
-
135
- export default CalculatorKeyboard;
package/publish.sh DELETED
@@ -1,28 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Prepare dist files
4
- rm -rf dist
5
- mkdir dist
6
- rsync -r --exclude=/dist ./* dist
7
- cd dist
8
-
9
-
10
- if [ "$1" == "stable" ]; then
11
- npm version $(npm view @momo-kits/foundation@stable version)
12
- npm version patch
13
- npm publish --tag stable --access=public
14
- elif [ "$1" == "latest" ]; then
15
- npm version $(npm view @momo-kits/foundation@latest version)
16
- npm publish --tag latest --access=public
17
- else
18
- npm version $(npm view @momo-kits/avatar@beta version)
19
- npm version prerelease --preid=beta
20
- npm publish --tag beta --access=public
21
- fi
22
-
23
- PACKAGE_NAME=$(npm pkg get name)
24
- NEW_PACKAGE_VERSION=$(npm pkg get version)
25
-
26
- # Clean up
27
- cd ..
28
- rm -rf dist
package/styles.ts DELETED
@@ -1,18 +0,0 @@
1
- import {StyleSheet} from 'react-native';
2
-
3
- export default StyleSheet.create({
4
- icon: {
5
- position: 'absolute',
6
- overflow: 'hidden',
7
- },
8
-
9
- container: {
10
- alignItems: 'center',
11
- justifyContent: 'center',
12
- borderWidth: 1,
13
- },
14
- image: {
15
- width: '100%',
16
- height: '100%',
17
- },
18
- });
package/types.ts DELETED
@@ -1,7 +0,0 @@
1
- import {TextInputProps} from 'react-native';
2
- import React from 'react';
3
-
4
- export interface InputCalculatorProps extends TextInputProps {
5
- text?: string;
6
- forwardedRef?: React.Ref<any>;
7
- }