@solidx/checkbox 0.0.0-stage → 0.7.0

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