@solidx/checkbox 0.7.0 → 0.7.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/LICENSE +21 -0
- package/NuGet.config +11 -0
- package/RNCCheckbox.podspec +3 -3
- package/android/build.gradle +19 -8
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/com/reactnativecommunity/checkbox/ReactCheckBoxEvent.java +3 -8
- package/android/src/main/java/com/reactnativecommunity/checkbox/ReactCheckBoxManager.java +7 -13
- package/dist/js/AndroidCheckBoxNativeComponent.d.ts +2 -0
- package/dist/{AndroidCheckBoxNativeComponent.js → js/AndroidCheckBoxNativeComponent.js} +1 -1
- package/dist/{CheckBox.android.d.ts → js/CheckBox.android.d.ts} +13 -13
- package/dist/{CheckBox.android.js → js/CheckBox.android.js} +7 -5
- package/dist/js/CheckBox.d.ts +5 -0
- package/dist/{CheckBox.ios.d.ts → js/CheckBox.ios.d.ts} +25 -25
- package/dist/{CheckBox.ios.js → js/CheckBox.ios.js} +11 -5
- package/dist/js/CheckBox.js +27 -0
- package/dist/js/CheckBox.windows.d.ts +95 -0
- package/dist/{CheckBox.windows.js → js/CheckBox.windows.js} +20 -21
- package/dist/js/CheckboxNativeComponent.d.ts +11 -0
- package/dist/js/CheckboxNativeComponent.js +22 -0
- package/dist/js/IOSCheckBoxNativeComponent.d.ts +2 -0
- package/dist/{IOSCheckBoxNativeComponent.js → js/IOSCheckBoxNativeComponent.js} +1 -1
- package/dist/js/NativeCheckboxModule.d.ts +11 -0
- package/dist/js/NativeCheckboxModule.js +10 -0
- package/dist/js/RNCCheckboxNativeComponent.d.ts +48 -0
- package/dist/js/RNCCheckboxNativeComponent.js +12 -0
- package/dist/js/index.d.ts +11 -0
- package/dist/js/index.js +34 -0
- package/dist/{setAndForwardRef.d.ts → js/setAndForwardRef.d.ts} +1 -1
- package/dist/{setAndForwardRef.js → js/setAndForwardRef.js} +2 -1
- package/jest.config.windows.js +3 -0
- package/js/AndroidCheckBoxNativeComponent.ts +12 -0
- package/js/CheckBox.android.tsx +217 -0
- package/js/CheckBox.ios.tsx +175 -0
- package/js/CheckBox.ts +9 -0
- package/js/CheckBox.windows.tsx +158 -0
- package/js/CheckboxNativeComponent.ts +25 -0
- package/js/IOSCheckBoxNativeComponent.ts +12 -0
- package/js/NativeCheckboxModule.ts +15 -0
- package/js/RNCCheckboxNativeComponent.ts +68 -0
- package/js/index.ts +17 -0
- package/js/setAndForwardRef.ts +64 -0
- package/metro.config.js +45 -0
- package/package.json +61 -53
- package/react-native.config.js +22 -0
- package/typings/index.d.ts +5 -5
- package/windows/Checkbox/Checkbox.cpp +20 -0
- package/windows/Checkbox/Checkbox.h +26 -0
- package/windows/Checkbox/Checkbox.rc +0 -0
- package/windows/Checkbox/Checkbox.vcxproj +146 -0
- package/windows/Checkbox/Checkbox.vcxproj.filters +56 -0
- package/windows/Checkbox/CheckboxView.cpp +186 -0
- package/windows/Checkbox/CheckboxView.h +59 -0
- package/windows/Checkbox/ReactPackageProvider.cpp +24 -0
- package/windows/Checkbox/ReactPackageProvider.h +24 -0
- package/windows/Checkbox/ReactPackageProvider.idl +9 -0
- package/windows/Checkbox/codegen/.clang-format +2 -0
- package/windows/Checkbox/codegen/NativeCheckboxModuleSpec.g.h +31 -0
- package/windows/Checkbox/codegen_manual/react/components/RNCCheckboxSpec/RNCCheckbox.g.h +232 -0
- package/windows/Checkbox/packages.lock.json +151 -0
- package/windows/Checkbox/pch.cpp +1 -0
- package/windows/Checkbox/pch.h +43 -0
- package/windows/Checkbox/resource.h +5 -0
- package/windows/Checkbox/targetver.h +8 -0
- package/windows/Checkbox.sln +43 -0
- package/windows/ExperimentalFeatures.props +33 -0
- package/dist/AndroidCheckBoxNativeComponent.d.ts +0 -2
- package/dist/CheckBox.d.ts +0 -1
- package/dist/CheckBox.js +0 -2
- package/dist/CheckBox.windows.d.ts +0 -77
- package/dist/IOSCheckBoxNativeComponent.d.ts +0 -2
- package/dist/WindowsCheckBoxComponent.d.ts +0 -2
- package/dist/WindowsCheckBoxComponent.js +0 -6
- package/windows/CheckboxWindows/CheckboxView.cpp +0 -116
- package/windows/CheckboxWindows/CheckboxView.h +0 -33
- package/windows/CheckboxWindows/CheckboxView.idl +0 -11
- package/windows/CheckboxWindows/CheckboxViewManager.cpp +0 -73
- package/windows/CheckboxWindows/CheckboxViewManager.h +0 -44
- package/windows/CheckboxWindows/CheckboxWindows.rc +0 -0
- package/windows/CheckboxWindows/CheckboxWindows.vcxproj +0 -189
- package/windows/CheckboxWindows/CheckboxWindows.vcxproj.filters +0 -43
- package/windows/CheckboxWindows/PropertySheet.props +0 -16
- package/windows/CheckboxWindows/ReactPackageProvider.cpp +0 -18
- package/windows/CheckboxWindows/ReactPackageProvider.h +0 -23
- package/windows/CheckboxWindows/ReactPackageProvider.idl +0 -9
- package/windows/CheckboxWindows/packages.config +0 -4
- package/windows/CheckboxWindows/pch.cpp +0 -1
- package/windows/CheckboxWindows/pch.h +0 -4
- package/windows/CheckboxWindows/readme.txt +0 -23
- package/windows/CheckboxWindows/resource.h +0 -14
- package/windows/CheckboxWindows.sln +0 -226
- package/windows/CheckboxWindows62.sln +0 -254
- /package/windows/{CheckboxWindows/CheckboxWindows.def → Checkbox/Checkbox.def} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 react-native-community
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NuGet.config
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<configuration>
|
|
3
|
+
<packageSources>
|
|
4
|
+
<clear />
|
|
5
|
+
<add key="react-native" value="https://pkgs.dev.azure.com/ms/react-native/_packaging/react-native-public/nuget/v3/index.json" />
|
|
6
|
+
<add key="Nuget.org" value="https://api.nuget.org/v3/index.json" />
|
|
7
|
+
</packageSources>
|
|
8
|
+
<disabledPackageSources>
|
|
9
|
+
<clear />
|
|
10
|
+
</disabledPackageSources>
|
|
11
|
+
</configuration>
|
package/RNCCheckbox.podspec
CHANGED
|
@@ -12,11 +12,11 @@ Pod::Spec.new do |s|
|
|
|
12
12
|
s.homepage = package['homepage']
|
|
13
13
|
|
|
14
14
|
s.description = package['description']
|
|
15
|
-
s.
|
|
15
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
16
16
|
|
|
17
|
-
s.source = { :git => "https://github.com/
|
|
17
|
+
s.source = { :git => "https://github.com/dsolimando/react-native-checkbox.git", :tag => "v#{s.version}" }
|
|
18
18
|
s.source_files = "ios/**/*.{h,m}"
|
|
19
19
|
s.dependency 'BEMCheckBox', '~> 1.4'
|
|
20
|
-
s
|
|
20
|
+
install_modules_dependencies(s)
|
|
21
21
|
|
|
22
22
|
end
|
package/android/build.gradle
CHANGED
|
@@ -11,6 +11,7 @@ buildscript {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
apply plugin: 'com.android.library'
|
|
14
|
+
apply plugin: 'com.facebook.react'
|
|
14
15
|
|
|
15
16
|
def getExtOrDefault(name) {
|
|
16
17
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativeCheckBox_' + name]
|
|
@@ -20,22 +21,33 @@ def getExtOrIntegerDefault(name) {
|
|
|
20
21
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['ReactNativeCheckBox_' + name]).toInteger()
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
def
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
def supportsNamespace() {
|
|
25
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
26
|
+
def major = parsed[0].toInteger()
|
|
27
|
+
def minor = parsed[1].toInteger()
|
|
28
|
+
|
|
29
|
+
// Namespace support was added in 7.3.0
|
|
30
|
+
if (major == 7 && minor >= 3) {
|
|
31
|
+
return true
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return major >= 8
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
android {
|
|
38
|
+
buildFeatures {
|
|
39
|
+
buildConfig = true
|
|
40
|
+
}
|
|
41
|
+
if (supportsNamespace()) {
|
|
42
|
+
namespace "com.reactnativecommunity.checkbox"
|
|
43
|
+
}
|
|
32
44
|
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
|
|
33
45
|
buildToolsVersion getExtOrDefault('buildToolsVersion')
|
|
34
46
|
|
|
35
47
|
defaultConfig {
|
|
36
48
|
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
|
|
37
49
|
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
38
|
-
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED",
|
|
50
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", "true"
|
|
39
51
|
}
|
|
40
52
|
|
|
41
53
|
lintOptions {
|
|
@@ -51,4 +63,3 @@ repositories {
|
|
|
51
63
|
dependencies {
|
|
52
64
|
implementation 'com.facebook.react:react-native:+'
|
|
53
65
|
}
|
|
54
|
-
|
|
@@ -9,7 +9,6 @@ package com.reactnativecommunity.checkbox;
|
|
|
9
9
|
import com.facebook.react.bridge.Arguments;
|
|
10
10
|
import com.facebook.react.bridge.WritableMap;
|
|
11
11
|
import com.facebook.react.uimanager.events.Event;
|
|
12
|
-
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
|
13
12
|
|
|
14
13
|
/** Event emitted by a CheckBoxManager once a checkbox is manipulated. */
|
|
15
14
|
/*package*/ class ReactCheckBoxEvent extends Event<ReactCheckBoxEvent> {
|
|
@@ -18,8 +17,8 @@ import com.facebook.react.uimanager.events.RCTEventEmitter;
|
|
|
18
17
|
|
|
19
18
|
private final boolean mIsChecked;
|
|
20
19
|
|
|
21
|
-
public ReactCheckBoxEvent(int viewId, boolean isChecked) {
|
|
22
|
-
super(viewId);
|
|
20
|
+
public ReactCheckBoxEvent(int surfaceId, int viewId, boolean isChecked) {
|
|
21
|
+
super(surfaceId, viewId);
|
|
23
22
|
mIsChecked = isChecked;
|
|
24
23
|
}
|
|
25
24
|
|
|
@@ -39,11 +38,7 @@ import com.facebook.react.uimanager.events.RCTEventEmitter;
|
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
@Override
|
|
42
|
-
|
|
43
|
-
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData());
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
private WritableMap serializeEventData() {
|
|
41
|
+
protected WritableMap getEventData() {
|
|
47
42
|
WritableMap eventData = Arguments.createMap();
|
|
48
43
|
eventData.putInt("target", getViewTag());
|
|
49
44
|
eventData.putBoolean("value", getIsChecked());
|
|
@@ -18,10 +18,8 @@ import com.facebook.react.bridge.ReadableMap;
|
|
|
18
18
|
import com.facebook.react.uimanager.SimpleViewManager;
|
|
19
19
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
20
20
|
import com.facebook.react.uimanager.UIManagerHelper;
|
|
21
|
-
import com.facebook.react.uimanager.UIManagerModule;
|
|
22
21
|
import com.facebook.react.uimanager.ViewProps;
|
|
23
22
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
24
|
-
import com.facebook.react.uimanager.common.UIManagerType;
|
|
25
23
|
import com.facebook.react.uimanager.events.EventDispatcher;
|
|
26
24
|
|
|
27
25
|
import javax.annotation.Nullable;
|
|
@@ -36,18 +34,14 @@ public class ReactCheckBoxManager extends SimpleViewManager<ReactCheckBox> {
|
|
|
36
34
|
@Override
|
|
37
35
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
38
36
|
ReactContext reactContext = getReactContext(buttonView);
|
|
39
|
-
EventDispatcher eventDispatcher
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
eventDispatcher = reactContext
|
|
45
|
-
.getNativeModule(UIManagerModule.class).getEventDispatcher();
|
|
46
|
-
}
|
|
47
|
-
eventDispatcher.dispatchEvent(new ReactCheckBoxEvent(buttonView.getId(), isChecked));
|
|
48
|
-
} catch (Exception e) {
|
|
49
|
-
throw new RuntimeException(e);
|
|
37
|
+
EventDispatcher eventDispatcher =
|
|
38
|
+
UIManagerHelper.getEventDispatcherForReactTag(reactContext, buttonView.getId());
|
|
39
|
+
if (eventDispatcher == null) {
|
|
40
|
+
android.util.Log.e("ReactCheckBoxManager", "No event dispatcher for checkbox " + buttonView.getId());
|
|
41
|
+
return;
|
|
50
42
|
}
|
|
43
|
+
eventDispatcher.dispatchEvent(new ReactCheckBoxEvent(
|
|
44
|
+
UIManagerHelper.getSurfaceId(reactContext), buttonView.getId(), isChecked));
|
|
51
45
|
}
|
|
52
46
|
|
|
53
47
|
private ReactContext getReactContext(CompoundButton buttonView) {
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
'use strict';
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
var react_native_1 = require("react-native");
|
|
11
|
-
exports.default = react_native_1.requireNativeComponent('AndroidCheckBox');
|
|
11
|
+
exports.default = (0, react_native_1.requireNativeComponent)('AndroidCheckBox');
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ViewProps,
|
|
3
|
-
|
|
2
|
+
import { ViewProps, HostInstance, NativeSyntheticEvent } from 'react-native';
|
|
3
|
+
type CheckBoxEvent = NativeSyntheticEvent<Readonly<{
|
|
4
4
|
target: number;
|
|
5
5
|
value: boolean;
|
|
6
6
|
}>>;
|
|
7
|
-
|
|
7
|
+
type CommonProps = Readonly<ViewProps & {
|
|
8
8
|
/**
|
|
9
9
|
* Used in case the props change removes the component.
|
|
10
10
|
*/
|
|
@@ -23,8 +23,8 @@ declare type CommonProps = Readonly<ViewProps & {
|
|
|
23
23
|
*/
|
|
24
24
|
testID?: string;
|
|
25
25
|
}>;
|
|
26
|
-
|
|
27
|
-
export
|
|
26
|
+
type CheckBoxNativeType = HostInstance;
|
|
27
|
+
export type Props = Readonly<CommonProps & {
|
|
28
28
|
/**
|
|
29
29
|
* The value of the checkbox. If true the checkbox will be turned on.
|
|
30
30
|
* Default value is false.
|
|
@@ -47,30 +47,30 @@ declare const CheckBoxWithRef: React.ForwardRefExoticComponent<Readonly<Readonly
|
|
|
47
47
|
/**
|
|
48
48
|
* Used in case the props change removes the component.
|
|
49
49
|
*/
|
|
50
|
-
onChange?: (
|
|
50
|
+
onChange?: (event: CheckBoxEvent) => void;
|
|
51
51
|
/**
|
|
52
52
|
* Invoked with the new value when the value changes.
|
|
53
53
|
*/
|
|
54
|
-
onValueChange?: (
|
|
54
|
+
onValueChange?: (value: boolean) => void;
|
|
55
55
|
/**
|
|
56
56
|
* If true the user won't be able to toggle the checkbox.
|
|
57
57
|
* Default value is false.
|
|
58
58
|
*/
|
|
59
|
-
disabled?: boolean
|
|
59
|
+
disabled?: boolean;
|
|
60
60
|
/**
|
|
61
61
|
* Used to locate this view in end-to-end tests.
|
|
62
62
|
*/
|
|
63
|
-
testID?: string
|
|
63
|
+
testID?: string;
|
|
64
64
|
}> & {
|
|
65
65
|
/**
|
|
66
66
|
* The value of the checkbox. If true the checkbox will be turned on.
|
|
67
67
|
* Default value is false.
|
|
68
68
|
*/
|
|
69
|
-
value?: boolean
|
|
69
|
+
value?: boolean;
|
|
70
70
|
/**
|
|
71
71
|
* Used to get the ref for the native checkbox
|
|
72
72
|
*/
|
|
73
|
-
forwardedRef?:
|
|
73
|
+
forwardedRef?: React.Ref<CheckBoxNativeType>;
|
|
74
74
|
/**
|
|
75
75
|
* Controls the colors the checkbox has in checked and unchecked states.
|
|
76
76
|
* TODO: improve this type
|
|
@@ -78,6 +78,6 @@ declare const CheckBoxWithRef: React.ForwardRefExoticComponent<Readonly<Readonly
|
|
|
78
78
|
tintColors?: {
|
|
79
79
|
true?: any;
|
|
80
80
|
false?: any;
|
|
81
|
-
}
|
|
82
|
-
}> & React.RefAttributes<
|
|
81
|
+
};
|
|
82
|
+
}> & React.RefAttributes<import("node_modules/react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default>>;
|
|
83
83
|
export default CheckBoxWithRef;
|
|
@@ -10,10 +10,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
10
10
|
var extendStatics = function (d, b) {
|
|
11
11
|
extendStatics = Object.setPrototypeOf ||
|
|
12
12
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
13
|
-
function (d, b) { for (var p in b) if (
|
|
13
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
14
14
|
return extendStatics(d, b);
|
|
15
15
|
};
|
|
16
16
|
return function (d, b) {
|
|
17
|
+
if (typeof b !== "function" && b !== null)
|
|
18
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
17
19
|
extendStatics(d, b);
|
|
18
20
|
function __() { this.constructor = d; }
|
|
19
21
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -111,7 +113,7 @@ var CheckBox = /** @class */ (function (_super) {
|
|
|
111
113
|
function CheckBox() {
|
|
112
114
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
113
115
|
_this._nativeRef = null;
|
|
114
|
-
_this._setNativeRef = setAndForwardRef_1.default({
|
|
116
|
+
_this._setNativeRef = (0, setAndForwardRef_1.default)({
|
|
115
117
|
getForwardedRef: function () { return _this.props.forwardedRef; },
|
|
116
118
|
setLocalRef: function (ref) {
|
|
117
119
|
_this._nativeRef = ref;
|
|
@@ -120,7 +122,7 @@ var CheckBox = /** @class */ (function (_super) {
|
|
|
120
122
|
_this._onChange = function (event) {
|
|
121
123
|
var value = _this.props.value || false;
|
|
122
124
|
// @ts-ignore
|
|
123
|
-
nullthrows_1.default(_this._nativeRef).setNativeProps({
|
|
125
|
+
(0, nullthrows_1.default)(_this._nativeRef).setNativeProps({ on: value });
|
|
124
126
|
// Change the props after the native props are set in case the props
|
|
125
127
|
// change removes the component
|
|
126
128
|
_this.props.onChange && _this.props.onChange(event);
|
|
@@ -132,8 +134,8 @@ var CheckBox = /** @class */ (function (_super) {
|
|
|
132
134
|
CheckBox.prototype.getTintColors = function (tintColors) {
|
|
133
135
|
return tintColors
|
|
134
136
|
? {
|
|
135
|
-
true: react_native_1.processColor(tintColors.true),
|
|
136
|
-
false: react_native_1.processColor(tintColors.false),
|
|
137
|
+
true: (0, react_native_1.processColor)(tintColors.true),
|
|
138
|
+
false: (0, react_native_1.processColor)(tintColors.false),
|
|
137
139
|
}
|
|
138
140
|
: undefined;
|
|
139
141
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from './CheckBox';
|
|
2
|
+
export { default as RNCCheckbox } from './RNCCheckboxNativeComponent';
|
|
3
|
+
export type { RNCCheckboxNativeProps } from './RNCCheckboxNativeComponent';
|
|
4
|
+
export { default as NativeCheckboxModule } from './NativeCheckboxModule';
|
|
5
|
+
export type { Spec as NativeCheckboxModuleSpec } from './NativeCheckboxModule';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ViewProps,
|
|
3
|
-
|
|
2
|
+
import { ViewProps, HostInstance, NativeSyntheticEvent } from 'react-native';
|
|
3
|
+
type CheckBoxEvent = NativeSyntheticEvent<Readonly<{
|
|
4
4
|
target: number;
|
|
5
5
|
value: boolean;
|
|
6
6
|
name: 'animation' | 'tap';
|
|
7
7
|
}>>;
|
|
8
|
-
|
|
8
|
+
type CommonProps = Readonly<ViewProps & {
|
|
9
9
|
/**
|
|
10
10
|
* Used to get the ref for the native checkbox
|
|
11
11
|
*/
|
|
@@ -33,10 +33,10 @@ declare type CommonProps = Readonly<ViewProps & {
|
|
|
33
33
|
*/
|
|
34
34
|
testID?: string;
|
|
35
35
|
}>;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export
|
|
36
|
+
type CheckBoxNativeType = HostInstance;
|
|
37
|
+
type BoxType = 'circle' | 'square';
|
|
38
|
+
type AnimationType = 'stroke' | 'fill' | 'bounce' | 'flat' | 'one-stroke' | 'fade';
|
|
39
|
+
export type Props = Readonly<CommonProps & {
|
|
40
40
|
onAnimationDidStop?: Function;
|
|
41
41
|
lineWidth?: number;
|
|
42
42
|
hideBox?: boolean;
|
|
@@ -53,40 +53,40 @@ declare const CheckBoxWithRef: React.ForwardRefExoticComponent<Readonly<Readonly
|
|
|
53
53
|
/**
|
|
54
54
|
* Used to get the ref for the native checkbox
|
|
55
55
|
*/
|
|
56
|
-
forwardedRef?:
|
|
56
|
+
forwardedRef?: React.Ref<CheckBoxNativeType>;
|
|
57
57
|
/**
|
|
58
58
|
* The value of the checkbox. If true the checkbox will be turned on.
|
|
59
59
|
* Default value is false.
|
|
60
60
|
*/
|
|
61
|
-
value?: boolean
|
|
61
|
+
value?: boolean;
|
|
62
62
|
/**
|
|
63
63
|
* Used in case the props change removes the component.
|
|
64
64
|
*/
|
|
65
|
-
onChange?: (
|
|
65
|
+
onChange?: (event: CheckBoxEvent) => void;
|
|
66
66
|
/**
|
|
67
67
|
* Invoked with the new value when the value changes.
|
|
68
68
|
*/
|
|
69
|
-
onValueChange?: (
|
|
69
|
+
onValueChange?: (value: boolean) => void;
|
|
70
70
|
/**
|
|
71
71
|
* If true the user won't be able to toggle the checkbox.
|
|
72
72
|
* Default value is false.
|
|
73
73
|
*/
|
|
74
|
-
disabled?: boolean
|
|
74
|
+
disabled?: boolean;
|
|
75
75
|
/**
|
|
76
76
|
* Used to locate this view in end-to-end tests.
|
|
77
77
|
*/
|
|
78
|
-
testID?: string
|
|
78
|
+
testID?: string;
|
|
79
79
|
}> & {
|
|
80
|
-
onAnimationDidStop?: Function
|
|
81
|
-
lineWidth?: number
|
|
82
|
-
hideBox?: boolean
|
|
83
|
-
boxType?:
|
|
84
|
-
tintColor?: string
|
|
85
|
-
onCheckColor?: string
|
|
86
|
-
onFillColor?: string
|
|
87
|
-
onTintColor?: string
|
|
88
|
-
animationDuration?: number
|
|
89
|
-
onAnimationType?:
|
|
90
|
-
offAnimationType?:
|
|
91
|
-
}> & React.RefAttributes<
|
|
80
|
+
onAnimationDidStop?: Function;
|
|
81
|
+
lineWidth?: number;
|
|
82
|
+
hideBox?: boolean;
|
|
83
|
+
boxType?: BoxType;
|
|
84
|
+
tintColor?: string;
|
|
85
|
+
onCheckColor?: string;
|
|
86
|
+
onFillColor?: string;
|
|
87
|
+
onTintColor?: string;
|
|
88
|
+
animationDuration?: number;
|
|
89
|
+
onAnimationType?: AnimationType;
|
|
90
|
+
offAnimationType?: AnimationType;
|
|
91
|
+
}> & React.RefAttributes<import("node_modules/react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default>>;
|
|
92
92
|
export default CheckBoxWithRef;
|
|
@@ -11,10 +11,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
11
11
|
var extendStatics = function (d, b) {
|
|
12
12
|
extendStatics = Object.setPrototypeOf ||
|
|
13
13
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
14
|
-
function (d, b) { for (var p in b) if (
|
|
14
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
15
15
|
return extendStatics(d, b);
|
|
16
16
|
};
|
|
17
17
|
return function (d, b) {
|
|
18
|
+
if (typeof b !== "function" && b !== null)
|
|
19
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
18
20
|
extendStatics(d, b);
|
|
19
21
|
function __() { this.constructor = d; }
|
|
20
22
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -57,7 +59,7 @@ var CheckBox = /** @class */ (function (_super) {
|
|
|
57
59
|
function CheckBox() {
|
|
58
60
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
59
61
|
_this._nativeRef = null;
|
|
60
|
-
_this._setNativeRef = setAndForwardRef_1.default({
|
|
62
|
+
_this._setNativeRef = (0, setAndForwardRef_1.default)({
|
|
61
63
|
getForwardedRef: function () { return _this.props.forwardedRef; },
|
|
62
64
|
setLocalRef: function (ref) {
|
|
63
65
|
_this._nativeRef = ref;
|
|
@@ -65,11 +67,15 @@ var CheckBox = /** @class */ (function (_super) {
|
|
|
65
67
|
});
|
|
66
68
|
_this._onChange = function (event) {
|
|
67
69
|
var _a = _this.props, onValueChange = _a.onValueChange, onChange = _a.onChange;
|
|
68
|
-
|
|
70
|
+
// Reset the native checkbox back to the controlled `value` prop so the
|
|
71
|
+
// component behaves as a controlled input. Without this, iOS would keep
|
|
72
|
+
// whatever state the native tap produced, ignoring the `value` prop.
|
|
73
|
+
// This mirrors the Android implementation.
|
|
74
|
+
var value = _this.props.value || false;
|
|
69
75
|
// @ts-ignore
|
|
70
|
-
nullthrows_1.default(_this._nativeRef).setNativeProps({ value: value });
|
|
76
|
+
(0, nullthrows_1.default)(_this._nativeRef).setNativeProps({ value: value });
|
|
71
77
|
onChange && onChange(event);
|
|
72
|
-
onValueChange && onValueChange(value);
|
|
78
|
+
onValueChange && onValueChange(event.nativeEvent.value);
|
|
73
79
|
};
|
|
74
80
|
return _this;
|
|
75
81
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.NativeCheckboxModule = exports.RNCCheckbox = void 0;
|
|
21
|
+
__exportStar(require("./CheckBox"), exports);
|
|
22
|
+
// Export the native component and its types (for Windows/New Architecture)
|
|
23
|
+
var RNCCheckboxNativeComponent_1 = require("./RNCCheckboxNativeComponent");
|
|
24
|
+
Object.defineProperty(exports, "RNCCheckbox", { enumerable: true, get: function () { return __importDefault(RNCCheckboxNativeComponent_1).default; } });
|
|
25
|
+
// Re-export the native module for direct access
|
|
26
|
+
var NativeCheckboxModule_1 = require("./NativeCheckboxModule");
|
|
27
|
+
Object.defineProperty(exports, "NativeCheckboxModule", { enumerable: true, get: function () { return __importDefault(NativeCheckboxModule_1).default; } });
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewProps, HostInstance, NativeSyntheticEvent } from 'react-native';
|
|
3
|
+
type CheckBoxEvent = NativeSyntheticEvent<Readonly<{
|
|
4
|
+
value: boolean;
|
|
5
|
+
}>>;
|
|
6
|
+
type CheckBoxNativeType = HostInstance;
|
|
7
|
+
export type Props = Readonly<ViewProps & {
|
|
8
|
+
/**
|
|
9
|
+
* Used to get the ref for the native checkbox
|
|
10
|
+
*/
|
|
11
|
+
forwardedRef?: React.Ref<CheckBoxNativeType>;
|
|
12
|
+
/**
|
|
13
|
+
* The value of the checkbox. If true the checkbox will be turned on.
|
|
14
|
+
* Default value is false.
|
|
15
|
+
*/
|
|
16
|
+
value?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* If true the user won't be able to toggle the checkbox.
|
|
19
|
+
* Default value is false.
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Used in case the props change removes the component.
|
|
24
|
+
*/
|
|
25
|
+
onChange?: (event: CheckBoxEvent) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Invoked with the new value when the value changes.
|
|
28
|
+
*/
|
|
29
|
+
onValueChange?: (value: boolean) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Used to set the color of the box when unchecked.
|
|
32
|
+
*/
|
|
33
|
+
tintColor?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Used to set the color of the check mark when the checkbox is checked.
|
|
36
|
+
*/
|
|
37
|
+
onCheckColor?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Used to set the tint color of the checkbox border when it is checked.
|
|
40
|
+
*/
|
|
41
|
+
onTintColor?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Used to set the fill color of the checkbox when it is checked.
|
|
44
|
+
*/
|
|
45
|
+
onFillColor?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Used to locate this view in end-to-end tests.
|
|
48
|
+
*/
|
|
49
|
+
testID?: string;
|
|
50
|
+
}>;
|
|
51
|
+
declare const CheckBoxWithRef: React.ForwardRefExoticComponent<Readonly<ViewProps & {
|
|
52
|
+
/**
|
|
53
|
+
* Used to get the ref for the native checkbox
|
|
54
|
+
*/
|
|
55
|
+
forwardedRef?: React.Ref<CheckBoxNativeType>;
|
|
56
|
+
/**
|
|
57
|
+
* The value of the checkbox. If true the checkbox will be turned on.
|
|
58
|
+
* Default value is false.
|
|
59
|
+
*/
|
|
60
|
+
value?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* If true the user won't be able to toggle the checkbox.
|
|
63
|
+
* Default value is false.
|
|
64
|
+
*/
|
|
65
|
+
disabled?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Used in case the props change removes the component.
|
|
68
|
+
*/
|
|
69
|
+
onChange?: (event: CheckBoxEvent) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Invoked with the new value when the value changes.
|
|
72
|
+
*/
|
|
73
|
+
onValueChange?: (value: boolean) => void;
|
|
74
|
+
/**
|
|
75
|
+
* Used to set the color of the box when unchecked.
|
|
76
|
+
*/
|
|
77
|
+
tintColor?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Used to set the color of the check mark when the checkbox is checked.
|
|
80
|
+
*/
|
|
81
|
+
onCheckColor?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Used to set the tint color of the checkbox border when it is checked.
|
|
84
|
+
*/
|
|
85
|
+
onTintColor?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Used to set the fill color of the checkbox when it is checked.
|
|
88
|
+
*/
|
|
89
|
+
onFillColor?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Used to locate this view in end-to-end tests.
|
|
92
|
+
*/
|
|
93
|
+
testID?: string;
|
|
94
|
+
}> & React.RefAttributes<import("node_modules/react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default>>;
|
|
95
|
+
export default CheckBoxWithRef;
|