@solidx/checkbox 0.0.0-stage → 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 +22 -0
- package/android/build.gradle +65 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/android/gradle.properties +4 -0
- package/android/gradlew +172 -0
- package/android/gradlew.bat +84 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/java/com/reactnativecommunity/checkbox/ReactCheckBox.java +43 -0
- package/android/src/main/java/com/reactnativecommunity/checkbox/ReactCheckBoxEvent.java +47 -0
- package/android/src/main/java/com/reactnativecommunity/checkbox/ReactCheckBoxManager.java +128 -0
- package/android/src/main/java/com/reactnativecommunity/checkbox/ReactCheckBoxPackage.java +29 -0
- package/dist/js/AndroidCheckBoxNativeComponent.d.ts +2 -0
- package/dist/js/AndroidCheckBoxNativeComponent.js +11 -0
- package/dist/js/CheckBox.android.d.ts +83 -0
- package/dist/js/CheckBox.android.js +162 -0
- package/dist/js/CheckBox.d.ts +5 -0
- package/dist/js/CheckBox.ios.d.ts +92 -0
- package/dist/js/CheckBox.ios.js +109 -0
- package/dist/js/CheckBox.js +27 -0
- package/dist/js/CheckBox.windows.d.ts +95 -0
- package/dist/js/CheckBox.windows.js +95 -0
- 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/js/IOSCheckBoxNativeComponent.js +11 -0
- 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/js/setAndForwardRef.d.ts +40 -0
- package/dist/js/setAndForwardRef.js +53 -0
- package/ios/Podfile +3 -0
- package/ios/Podfile.lock +16 -0
- package/ios/RNCCheckbox.h +16 -0
- package/ios/RNCCheckbox.m +13 -0
- package/ios/RNCCheckbox.xcodeproj/project.pbxproj +322 -0
- package/ios/RNCCheckbox.xcodeproj/xcshareddata/xcschemes/RNCCheckbox.xcscheme +67 -0
- package/ios/RNCCheckbox.xcworkspace/contents.xcworkspacedata +10 -0
- package/ios/RNCCheckbox.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/RNCCheckbox.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +10 -0
- package/ios/RNCCheckboxManager.h +12 -0
- package/ios/RNCCheckboxManager.m +86 -0
- 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 +84 -4
- package/react-native.config.js +22 -0
- package/typings/index.d.ts +14 -0
- package/windows/Checkbox/Checkbox.cpp +20 -0
- package/windows/Checkbox/Checkbox.def +3 -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/README.md +0 -3
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewProps, HostInstance, NativeSyntheticEvent } from 'react-native';
|
|
3
|
+
type CheckBoxEvent = NativeSyntheticEvent<Readonly<{
|
|
4
|
+
target: number;
|
|
5
|
+
value: boolean;
|
|
6
|
+
}>>;
|
|
7
|
+
type CommonProps = Readonly<ViewProps & {
|
|
8
|
+
/**
|
|
9
|
+
* Used in case the props change removes the component.
|
|
10
|
+
*/
|
|
11
|
+
onChange?: (event: CheckBoxEvent) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Invoked with the new value when the value changes.
|
|
14
|
+
*/
|
|
15
|
+
onValueChange?: (value: boolean) => void;
|
|
16
|
+
/**
|
|
17
|
+
* If true the user won't be able to toggle the checkbox.
|
|
18
|
+
* Default value is false.
|
|
19
|
+
*/
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Used to locate this view in end-to-end tests.
|
|
23
|
+
*/
|
|
24
|
+
testID?: string;
|
|
25
|
+
}>;
|
|
26
|
+
type CheckBoxNativeType = HostInstance;
|
|
27
|
+
export type Props = Readonly<CommonProps & {
|
|
28
|
+
/**
|
|
29
|
+
* The value of the checkbox. If true the checkbox will be turned on.
|
|
30
|
+
* Default value is false.
|
|
31
|
+
*/
|
|
32
|
+
value?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Used to get the ref for the native checkbox
|
|
35
|
+
*/
|
|
36
|
+
forwardedRef?: React.Ref<CheckBoxNativeType>;
|
|
37
|
+
/**
|
|
38
|
+
* Controls the colors the checkbox has in checked and unchecked states.
|
|
39
|
+
* TODO: improve this type
|
|
40
|
+
*/
|
|
41
|
+
tintColors?: {
|
|
42
|
+
true?: any;
|
|
43
|
+
false?: any;
|
|
44
|
+
};
|
|
45
|
+
}>;
|
|
46
|
+
declare const CheckBoxWithRef: React.ForwardRefExoticComponent<Readonly<Readonly<ViewProps & {
|
|
47
|
+
/**
|
|
48
|
+
* Used in case the props change removes the component.
|
|
49
|
+
*/
|
|
50
|
+
onChange?: (event: CheckBoxEvent) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Invoked with the new value when the value changes.
|
|
53
|
+
*/
|
|
54
|
+
onValueChange?: (value: boolean) => void;
|
|
55
|
+
/**
|
|
56
|
+
* If true the user won't be able to toggle the checkbox.
|
|
57
|
+
* Default value is false.
|
|
58
|
+
*/
|
|
59
|
+
disabled?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Used to locate this view in end-to-end tests.
|
|
62
|
+
*/
|
|
63
|
+
testID?: string;
|
|
64
|
+
}> & {
|
|
65
|
+
/**
|
|
66
|
+
* The value of the checkbox. If true the checkbox will be turned on.
|
|
67
|
+
* Default value is false.
|
|
68
|
+
*/
|
|
69
|
+
value?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Used to get the ref for the native checkbox
|
|
72
|
+
*/
|
|
73
|
+
forwardedRef?: React.Ref<CheckBoxNativeType>;
|
|
74
|
+
/**
|
|
75
|
+
* Controls the colors the checkbox has in checked and unchecked states.
|
|
76
|
+
* TODO: improve this type
|
|
77
|
+
*/
|
|
78
|
+
tintColors?: {
|
|
79
|
+
true?: any;
|
|
80
|
+
false?: any;
|
|
81
|
+
};
|
|
82
|
+
}> & React.RefAttributes<import("node_modules/react-native/types_generated/src/private/webapis/dom/nodes/ReactNativeElement").default>>;
|
|
83
|
+
export default CheckBoxWithRef;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
'use strict';
|
|
9
|
+
var __extends = (this && this.__extends) || (function () {
|
|
10
|
+
var extendStatics = function (d, b) {
|
|
11
|
+
extendStatics = Object.setPrototypeOf ||
|
|
12
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
13
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
14
|
+
return extendStatics(d, b);
|
|
15
|
+
};
|
|
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");
|
|
19
|
+
extendStatics(d, b);
|
|
20
|
+
function __() { this.constructor = d; }
|
|
21
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __assign = (this && this.__assign) || function () {
|
|
25
|
+
__assign = Object.assign || function(t) {
|
|
26
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
27
|
+
s = arguments[i];
|
|
28
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
29
|
+
t[p] = s[p];
|
|
30
|
+
}
|
|
31
|
+
return t;
|
|
32
|
+
};
|
|
33
|
+
return __assign.apply(this, arguments);
|
|
34
|
+
};
|
|
35
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
36
|
+
var t = {};
|
|
37
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
38
|
+
t[p] = s[p];
|
|
39
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
40
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
41
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
42
|
+
t[p[i]] = s[p[i]];
|
|
43
|
+
}
|
|
44
|
+
return t;
|
|
45
|
+
};
|
|
46
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
var nullthrows_1 = __importDefault(require("nullthrows"));
|
|
51
|
+
var react_1 = __importDefault(require("react"));
|
|
52
|
+
var react_native_1 = require("react-native");
|
|
53
|
+
// @ts-ignore setAndForwardRef type does not exist in @types/react-native
|
|
54
|
+
var setAndForwardRef_1 = __importDefault(require("./setAndForwardRef"));
|
|
55
|
+
var AndroidCheckBoxNativeComponent_1 = __importDefault(require("./AndroidCheckBoxNativeComponent"));
|
|
56
|
+
/**
|
|
57
|
+
* Renders a boolean input (Android only).
|
|
58
|
+
*
|
|
59
|
+
* This is a controlled component that requires an `onValueChange` callback that
|
|
60
|
+
* updates the `value` prop in order for the component to reflect user actions.
|
|
61
|
+
* If the `value` prop is not updated, the component will continue to render
|
|
62
|
+
* the supplied `value` prop instead of the expected result of any user actions.
|
|
63
|
+
*
|
|
64
|
+
* ```
|
|
65
|
+
* import React from 'react';
|
|
66
|
+
* import { AppRegistry, StyleSheet, Text, View, CheckBox } from 'react-native';
|
|
67
|
+
*
|
|
68
|
+
* export default class App extends React.Component {
|
|
69
|
+
* constructor(props) {
|
|
70
|
+
* super(props);
|
|
71
|
+
* this.state = {
|
|
72
|
+
* checked: false
|
|
73
|
+
* }
|
|
74
|
+
* }
|
|
75
|
+
*
|
|
76
|
+
* toggle() {
|
|
77
|
+
* this.setState(({checked}) => {
|
|
78
|
+
* return {
|
|
79
|
+
* checked: !checked
|
|
80
|
+
* };
|
|
81
|
+
* });
|
|
82
|
+
* }
|
|
83
|
+
*
|
|
84
|
+
* render() {
|
|
85
|
+
* const {checked} = this.state;
|
|
86
|
+
* return (
|
|
87
|
+
* <View style={styles.container}>
|
|
88
|
+
* <Text>Checked</Text>
|
|
89
|
+
* <CheckBox value={checked} onChange={this.toggle.bind(this)} />
|
|
90
|
+
* </View>
|
|
91
|
+
* );
|
|
92
|
+
* }
|
|
93
|
+
* }
|
|
94
|
+
*
|
|
95
|
+
* const styles = StyleSheet.create({
|
|
96
|
+
* container: {
|
|
97
|
+
* flex: 1,
|
|
98
|
+
* flexDirection: 'row',
|
|
99
|
+
* alignItems: 'center',
|
|
100
|
+
* justifyContent: 'center',
|
|
101
|
+
* },
|
|
102
|
+
* });
|
|
103
|
+
*
|
|
104
|
+
* // skip this line if using Create React Native App
|
|
105
|
+
* AppRegistry.registerComponent('App', () => App);
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @keyword checkbox
|
|
109
|
+
* @keyword toggle
|
|
110
|
+
*/
|
|
111
|
+
var CheckBox = /** @class */ (function (_super) {
|
|
112
|
+
__extends(CheckBox, _super);
|
|
113
|
+
function CheckBox() {
|
|
114
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
115
|
+
_this._nativeRef = null;
|
|
116
|
+
_this._setNativeRef = (0, setAndForwardRef_1.default)({
|
|
117
|
+
getForwardedRef: function () { return _this.props.forwardedRef; },
|
|
118
|
+
setLocalRef: function (ref) {
|
|
119
|
+
_this._nativeRef = ref;
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
_this._onChange = function (event) {
|
|
123
|
+
var value = _this.props.value || false;
|
|
124
|
+
// @ts-ignore
|
|
125
|
+
(0, nullthrows_1.default)(_this._nativeRef).setNativeProps({ on: value });
|
|
126
|
+
// Change the props after the native props are set in case the props
|
|
127
|
+
// change removes the component
|
|
128
|
+
_this.props.onChange && _this.props.onChange(event);
|
|
129
|
+
_this.props.onValueChange &&
|
|
130
|
+
_this.props.onValueChange(event.nativeEvent.value);
|
|
131
|
+
};
|
|
132
|
+
return _this;
|
|
133
|
+
}
|
|
134
|
+
CheckBox.prototype.getTintColors = function (tintColors) {
|
|
135
|
+
return tintColors
|
|
136
|
+
? {
|
|
137
|
+
true: (0, react_native_1.processColor)(tintColors.true),
|
|
138
|
+
false: (0, react_native_1.processColor)(tintColors.false),
|
|
139
|
+
}
|
|
140
|
+
: undefined;
|
|
141
|
+
};
|
|
142
|
+
CheckBox.prototype.render = function () {
|
|
143
|
+
var _a = this.props, tintColors = _a.tintColors, style = _a.style, props = __rest(_a, ["tintColors", "style"]);
|
|
144
|
+
var disabled = this.props.disabled || false;
|
|
145
|
+
var value = this.props.value || false;
|
|
146
|
+
var nativeProps = __assign(__assign({}, props), { onStartShouldSetResponder: function () { return true; }, onResponderTerminationRequest: function () { return false; }, enabled: !disabled, on: value, tintColors: this.getTintColors(tintColors), style: [styles.rctCheckBox, style] });
|
|
147
|
+
return (react_1.default.createElement(AndroidCheckBoxNativeComponent_1.default, __assign({}, nativeProps, { ref: this._setNativeRef,
|
|
148
|
+
// @ts-ignore TODO: implement the type of AndroidCheckBoxNativeComponent
|
|
149
|
+
onChange: this._onChange })));
|
|
150
|
+
};
|
|
151
|
+
return CheckBox;
|
|
152
|
+
}(react_1.default.Component));
|
|
153
|
+
var styles = react_native_1.StyleSheet.create({
|
|
154
|
+
rctCheckBox: {
|
|
155
|
+
height: 32,
|
|
156
|
+
width: 32,
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
var CheckBoxWithRef = react_1.default.forwardRef(function CheckBoxWithRef(props, ref) {
|
|
160
|
+
return react_1.default.createElement(CheckBox, __assign({}, props, { forwardedRef: ref }));
|
|
161
|
+
});
|
|
162
|
+
exports.default = CheckBoxWithRef;
|
|
@@ -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';
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewProps, HostInstance, NativeSyntheticEvent } from 'react-native';
|
|
3
|
+
type CheckBoxEvent = NativeSyntheticEvent<Readonly<{
|
|
4
|
+
target: number;
|
|
5
|
+
value: boolean;
|
|
6
|
+
name: 'animation' | 'tap';
|
|
7
|
+
}>>;
|
|
8
|
+
type CommonProps = Readonly<ViewProps & {
|
|
9
|
+
/**
|
|
10
|
+
* Used to get the ref for the native checkbox
|
|
11
|
+
*/
|
|
12
|
+
forwardedRef?: React.Ref<CheckBoxNativeType>;
|
|
13
|
+
/**
|
|
14
|
+
* The value of the checkbox. If true the checkbox will be turned on.
|
|
15
|
+
* Default value is false.
|
|
16
|
+
*/
|
|
17
|
+
value?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Used in case the props change removes the component.
|
|
20
|
+
*/
|
|
21
|
+
onChange?: (event: CheckBoxEvent) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Invoked with the new value when the value changes.
|
|
24
|
+
*/
|
|
25
|
+
onValueChange?: (value: boolean) => void;
|
|
26
|
+
/**
|
|
27
|
+
* If true the user won't be able to toggle the checkbox.
|
|
28
|
+
* Default value is false.
|
|
29
|
+
*/
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Used to locate this view in end-to-end tests.
|
|
33
|
+
*/
|
|
34
|
+
testID?: string;
|
|
35
|
+
}>;
|
|
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
|
+
onAnimationDidStop?: Function;
|
|
41
|
+
lineWidth?: number;
|
|
42
|
+
hideBox?: boolean;
|
|
43
|
+
boxType?: BoxType;
|
|
44
|
+
tintColor?: string;
|
|
45
|
+
onCheckColor?: string;
|
|
46
|
+
onFillColor?: string;
|
|
47
|
+
onTintColor?: string;
|
|
48
|
+
animationDuration?: number;
|
|
49
|
+
onAnimationType?: AnimationType;
|
|
50
|
+
offAnimationType?: AnimationType;
|
|
51
|
+
}>;
|
|
52
|
+
declare const CheckBoxWithRef: React.ForwardRefExoticComponent<Readonly<Readonly<ViewProps & {
|
|
53
|
+
/**
|
|
54
|
+
* Used to get the ref for the native checkbox
|
|
55
|
+
*/
|
|
56
|
+
forwardedRef?: React.Ref<CheckBoxNativeType>;
|
|
57
|
+
/**
|
|
58
|
+
* The value of the checkbox. If true the checkbox will be turned on.
|
|
59
|
+
* Default value is false.
|
|
60
|
+
*/
|
|
61
|
+
value?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Used in case the props change removes the component.
|
|
64
|
+
*/
|
|
65
|
+
onChange?: (event: CheckBoxEvent) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Invoked with the new value when the value changes.
|
|
68
|
+
*/
|
|
69
|
+
onValueChange?: (value: boolean) => void;
|
|
70
|
+
/**
|
|
71
|
+
* If true the user won't be able to toggle the checkbox.
|
|
72
|
+
* Default value is false.
|
|
73
|
+
*/
|
|
74
|
+
disabled?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Used to locate this view in end-to-end tests.
|
|
77
|
+
*/
|
|
78
|
+
testID?: string;
|
|
79
|
+
}> & {
|
|
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
|
+
export default CheckBoxWithRef;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*/
|
|
9
|
+
'use strict';
|
|
10
|
+
var __extends = (this && this.__extends) || (function () {
|
|
11
|
+
var extendStatics = function (d, b) {
|
|
12
|
+
extendStatics = Object.setPrototypeOf ||
|
|
13
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
14
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
15
|
+
return extendStatics(d, b);
|
|
16
|
+
};
|
|
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");
|
|
20
|
+
extendStatics(d, b);
|
|
21
|
+
function __() { this.constructor = d; }
|
|
22
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
var __assign = (this && this.__assign) || function () {
|
|
26
|
+
__assign = Object.assign || function(t) {
|
|
27
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
28
|
+
s = arguments[i];
|
|
29
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
30
|
+
t[p] = s[p];
|
|
31
|
+
}
|
|
32
|
+
return t;
|
|
33
|
+
};
|
|
34
|
+
return __assign.apply(this, arguments);
|
|
35
|
+
};
|
|
36
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
37
|
+
var t = {};
|
|
38
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
39
|
+
t[p] = s[p];
|
|
40
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
41
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
42
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
43
|
+
t[p[i]] = s[p[i]];
|
|
44
|
+
}
|
|
45
|
+
return t;
|
|
46
|
+
};
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
var nullthrows_1 = __importDefault(require("nullthrows"));
|
|
52
|
+
var react_1 = __importDefault(require("react"));
|
|
53
|
+
var react_native_1 = require("react-native");
|
|
54
|
+
var IOSCheckBoxNativeComponent_1 = __importDefault(require("./IOSCheckBoxNativeComponent"));
|
|
55
|
+
// @ts-ignore setAndForwardRef type does not exist in @types/react-native
|
|
56
|
+
var setAndForwardRef_1 = __importDefault(require("./setAndForwardRef"));
|
|
57
|
+
var CheckBox = /** @class */ (function (_super) {
|
|
58
|
+
__extends(CheckBox, _super);
|
|
59
|
+
function CheckBox() {
|
|
60
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
61
|
+
_this._nativeRef = null;
|
|
62
|
+
_this._setNativeRef = (0, setAndForwardRef_1.default)({
|
|
63
|
+
getForwardedRef: function () { return _this.props.forwardedRef; },
|
|
64
|
+
setLocalRef: function (ref) {
|
|
65
|
+
_this._nativeRef = ref;
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
_this._onChange = function (event) {
|
|
69
|
+
var _a = _this.props, onValueChange = _a.onValueChange, onChange = _a.onChange;
|
|
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;
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
(0, nullthrows_1.default)(_this._nativeRef).setNativeProps({ value: value });
|
|
77
|
+
onChange && onChange(event);
|
|
78
|
+
onValueChange && onValueChange(event.nativeEvent.value);
|
|
79
|
+
};
|
|
80
|
+
return _this;
|
|
81
|
+
}
|
|
82
|
+
CheckBox.prototype.render = function () {
|
|
83
|
+
var _a = this.props, accessible = _a.accessible, style = _a.style,
|
|
84
|
+
// Do not use onValueChange directly from props
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
86
|
+
onValueChange = _a.onValueChange, disabled = _a.disabled, value = _a.value, testID = _a.testID, props = __rest(_a, ["accessible", "style", "onValueChange", "disabled", "value", "testID"]);
|
|
87
|
+
return (react_1.default.createElement(react_native_1.View, { testID: testID, pointerEvents: disabled ? 'none' : 'auto', accessible: accessible != null ? accessible : true, accessibilityRole: "checkbox", accessibilityState: {
|
|
88
|
+
checked: value || false,
|
|
89
|
+
disabled: disabled || false,
|
|
90
|
+
}, accessibilityValue: { text: value || false ? 'on' : 'off' } },
|
|
91
|
+
react_1.default.createElement(IOSCheckBoxNativeComponent_1.default, __assign({}, props, {
|
|
92
|
+
// @ts-ignore TODO: implement the value type of IOSCheckBoxNativeComponent
|
|
93
|
+
value: value,
|
|
94
|
+
// @ts-ignore TODO: implement the style type of IOSCheckBoxNativeComponent
|
|
95
|
+
style: [styles.rctCheckBox, style], ref: this._setNativeRef, onValueChange: this._onChange }))));
|
|
96
|
+
};
|
|
97
|
+
return CheckBox;
|
|
98
|
+
}(react_1.default.Component));
|
|
99
|
+
var styles = react_native_1.StyleSheet.create({
|
|
100
|
+
rctCheckBox: {
|
|
101
|
+
height: 32,
|
|
102
|
+
width: 32,
|
|
103
|
+
backgroundColor: 'transparent',
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
var CheckBoxWithRef = react_1.default.forwardRef(function CheckBoxWithRef(props, ref) {
|
|
107
|
+
return react_1.default.createElement(CheckBox, __assign({}, props, { forwardedRef: ref }));
|
|
108
|
+
});
|
|
109
|
+
exports.default = CheckBoxWithRef;
|
|
@@ -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;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
var __extends = (this && this.__extends) || (function () {
|
|
9
|
+
var extendStatics = function (d, b) {
|
|
10
|
+
extendStatics = Object.setPrototypeOf ||
|
|
11
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
12
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
13
|
+
return extendStatics(d, b);
|
|
14
|
+
};
|
|
15
|
+
return function (d, b) {
|
|
16
|
+
if (typeof b !== "function" && b !== null)
|
|
17
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
18
|
+
extendStatics(d, b);
|
|
19
|
+
function __() { this.constructor = d; }
|
|
20
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
21
|
+
};
|
|
22
|
+
})();
|
|
23
|
+
var __assign = (this && this.__assign) || function () {
|
|
24
|
+
__assign = Object.assign || function(t) {
|
|
25
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
26
|
+
s = arguments[i];
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
}
|
|
30
|
+
return t;
|
|
31
|
+
};
|
|
32
|
+
return __assign.apply(this, arguments);
|
|
33
|
+
};
|
|
34
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
35
|
+
var t = {};
|
|
36
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
37
|
+
t[p] = s[p];
|
|
38
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
39
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
40
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
41
|
+
t[p[i]] = s[p[i]];
|
|
42
|
+
}
|
|
43
|
+
return t;
|
|
44
|
+
};
|
|
45
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
46
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
47
|
+
};
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
var react_1 = __importDefault(require("react"));
|
|
50
|
+
var react_native_1 = require("react-native");
|
|
51
|
+
var RNCCheckboxNativeComponent_1 = __importDefault(require("./RNCCheckboxNativeComponent"));
|
|
52
|
+
// @ts-ignore setAndForwardRef type does not exist in @types/react-native
|
|
53
|
+
var setAndForwardRef_1 = __importDefault(require("./setAndForwardRef"));
|
|
54
|
+
/**
|
|
55
|
+
* Renders a boolean checkbox input (Windows).
|
|
56
|
+
*
|
|
57
|
+
* This is a controlled component that requires an `onValueChange` callback that
|
|
58
|
+
* updates the `value` prop in order for the component to reflect user actions.
|
|
59
|
+
* If the `value` prop is not updated, the component will continue to render
|
|
60
|
+
* the supplied `value` prop instead of the expected result of any user actions.
|
|
61
|
+
*/
|
|
62
|
+
var CheckBox = /** @class */ (function (_super) {
|
|
63
|
+
__extends(CheckBox, _super);
|
|
64
|
+
function CheckBox() {
|
|
65
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
66
|
+
_this._nativeRef = null;
|
|
67
|
+
_this._setNativeRef = (0, setAndForwardRef_1.default)({
|
|
68
|
+
getForwardedRef: function () { return _this.props.forwardedRef; },
|
|
69
|
+
setLocalRef: function (ref) {
|
|
70
|
+
_this._nativeRef = ref;
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
_this._onChange = function (event) {
|
|
74
|
+
var _a = _this.props, onChange = _a.onChange, onValueChange = _a.onValueChange;
|
|
75
|
+
onChange && onChange(event);
|
|
76
|
+
onValueChange && onValueChange(event.nativeEvent.value);
|
|
77
|
+
};
|
|
78
|
+
return _this;
|
|
79
|
+
}
|
|
80
|
+
CheckBox.prototype.render = function () {
|
|
81
|
+
var _a = this.props, style = _a.style, value = _a.value, disabled = _a.disabled, tintColor = _a.tintColor, onCheckColor = _a.onCheckColor, onTintColor = _a.onTintColor, onFillColor = _a.onFillColor, testID = _a.testID, props = __rest(_a, ["style", "value", "disabled", "tintColor", "onCheckColor", "onTintColor", "onFillColor", "testID"]);
|
|
82
|
+
return (react_1.default.createElement(RNCCheckboxNativeComponent_1.default, __assign({}, props, { testID: testID, value: value !== null && value !== void 0 ? value : false, disabled: disabled !== null && disabled !== void 0 ? disabled : false, tintColor: tintColor, onCheckColor: onCheckColor, onTintColor: onTintColor, onFillColor: onFillColor, style: [styles.rctCheckBox, style], ref: this._setNativeRef, onChange: this._onChange })));
|
|
83
|
+
};
|
|
84
|
+
return CheckBox;
|
|
85
|
+
}(react_1.default.Component));
|
|
86
|
+
var styles = react_native_1.StyleSheet.create({
|
|
87
|
+
rctCheckBox: {
|
|
88
|
+
height: 32,
|
|
89
|
+
width: 32,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
var CheckBoxWithRef = react_1.default.forwardRef(function CheckBoxWithRef(props, ref) {
|
|
93
|
+
return react_1.default.createElement(CheckBox, __assign({}, props, { forwardedRef: ref }));
|
|
94
|
+
});
|
|
95
|
+
exports.default = CheckBoxWithRef;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*/
|
|
9
|
+
import type { HostComponent } from 'react-native';
|
|
10
|
+
declare let CheckboxNativeComponent: HostComponent<any>;
|
|
11
|
+
export default CheckboxNativeComponent;
|