@proximus/lavender-checkbox-native 0.1.0-alpha.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.
- package/CHANGELOG.md +39 -0
- package/dist/PxCheckBox.d.ts +40 -0
- package/dist/PxCheckBox.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/package.json +39 -0
- package/src/PxCheckBox.tsx +225 -0
- package/src/index.ts +1 -0
- package/tsconfig.json +8 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# 0.1.0-alpha.0 (2025-08-13)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **BCRI-3807748:** fix checkbox android native crash ([f358872](https://github.com/Pxs-Corporate/react-native-lavender/commit/f3588725a8a7440722b6fc13a5586da2da758ea0))
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- **BCRI-000000:** remove default E2E on DEV env build for all components ([a5d27bf](https://github.com/Pxs-Corporate/react-native-lavender/commit/a5d27bfaaebf5b75f3160f31c64b590b7bd00b93))
|
|
15
|
+
- **BCRI-3651613:** checkbox module ([b791f5f](https://github.com/Pxs-Corporate/react-native-lavender/commit/b791f5f9482f1162302826092d946fa364f37e9d))
|
|
16
|
+
- **BCRI-3651673:** entrypoint module ([9a246af](https://github.com/Pxs-Corporate/react-native-lavender/commit/9a246af671f674f0ff768a9b6a72a77d1f12d065))
|
|
17
|
+
- **BCRI-3660857:** cell components ([af9e45c](https://github.com/Pxs-Corporate/react-native-lavender/commit/af9e45cefc20d08d2338380ff4cd8cd6851abe24))
|
|
18
|
+
- **BCRI-3707400:** entrypoint prefix slot ([5f5c4a9](https://github.com/Pxs-Corporate/react-native-lavender/commit/5f5c4a9a973a5168d359f6d4a9413a3b7bf50d48))
|
|
19
|
+
- **BCRI-3810979:** tile components ([46fc5c7](https://github.com/Pxs-Corporate/react-native-lavender/commit/46fc5c7a0ddff6c2db43fba0de9929626092f265))
|
|
20
|
+
- **BCRI-4002610:** update icon handling and remove deprecated font references ([4399fe4](https://github.com/Pxs-Corporate/react-native-lavender/commit/4399fe4bff06aa70f5c29705fcc89d5243b0e3e7))
|
|
21
|
+
- **BCRI-4210372:** automatic versionning ([9c1f0a0](https://github.com/Pxs-Corporate/react-native-lavender/commit/9c1f0a00e19a9d1a277044ea627632032a674102))
|
|
22
|
+
- **BCRI-4210372:** fix bad version numbers ([bc6a8ba](https://github.com/Pxs-Corporate/react-native-lavender/commit/bc6a8ba48c15347442f2ac38dacae7ffba3d95eb))
|
|
23
|
+
|
|
24
|
+
# (2025-08-13)
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
- **BCRI-3807748:** fix checkbox android native crash ([f358872](https://github.com/Pxs-Corporate/react-native-lavender/commit/f3588725a8a7440722b6fc13a5586da2da758ea0))
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
|
|
32
|
+
- **BCRI-000000:** remove default E2E on DEV env build for all components ([a5d27bf](https://github.com/Pxs-Corporate/react-native-lavender/commit/a5d27bfaaebf5b75f3160f31c64b590b7bd00b93))
|
|
33
|
+
- **BCRI-3651613:** checkbox module ([b791f5f](https://github.com/Pxs-Corporate/react-native-lavender/commit/b791f5f9482f1162302826092d946fa364f37e9d))
|
|
34
|
+
- **BCRI-3651673:** entrypoint module ([9a246af](https://github.com/Pxs-Corporate/react-native-lavender/commit/9a246af671f674f0ff768a9b6a72a77d1f12d065))
|
|
35
|
+
- **BCRI-3660857:** cell components ([af9e45c](https://github.com/Pxs-Corporate/react-native-lavender/commit/af9e45cefc20d08d2338380ff4cd8cd6851abe24))
|
|
36
|
+
- **BCRI-3707400:** entrypoint prefix slot ([5f5c4a9](https://github.com/Pxs-Corporate/react-native-lavender/commit/5f5c4a9a973a5168d359f6d4a9413a3b7bf50d48))
|
|
37
|
+
- **BCRI-3810979:** tile components ([46fc5c7](https://github.com/Pxs-Corporate/react-native-lavender/commit/46fc5c7a0ddff6c2db43fba0de9929626092f265))
|
|
38
|
+
- **BCRI-4002610:** update icon handling and remove deprecated font references ([4399fe4](https://github.com/Pxs-Corporate/react-native-lavender/commit/4399fe4bff06aa70f5c29705fcc89d5243b0e3e7))
|
|
39
|
+
- **BCRI-4210372:** automatic versionning ([9c1f0a0](https://github.com/Pxs-Corporate/react-native-lavender/commit/9c1f0a00e19a9d1a277044ea627632032a674102))
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AccessibilityProps, StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
3
|
+
import 'nullthrows';
|
|
4
|
+
export interface ICheckBoxProps {
|
|
5
|
+
/**
|
|
6
|
+
* Common Props
|
|
7
|
+
*/
|
|
8
|
+
checked: boolean;
|
|
9
|
+
onChange?: (value: boolean) => void;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
testID?: string;
|
|
12
|
+
color?: string;
|
|
13
|
+
label?: string;
|
|
14
|
+
hasError?: boolean;
|
|
15
|
+
wrapperStyle?: StyleProp<ViewStyle>;
|
|
16
|
+
checkboxStyle?: StyleProp<ViewStyle>;
|
|
17
|
+
labelStyle?: StyleProp<TextStyle>;
|
|
18
|
+
labelColor?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Check @react-native-community/checkbox for more info
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Android only
|
|
24
|
+
*/
|
|
25
|
+
focusable?: boolean;
|
|
26
|
+
tintColors?: {
|
|
27
|
+
true?: string;
|
|
28
|
+
false?: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* IOS only
|
|
32
|
+
*/
|
|
33
|
+
checkedColor?: string;
|
|
34
|
+
boxType?: 'circle' | 'square';
|
|
35
|
+
tintColor?: string;
|
|
36
|
+
onTintColor?: string;
|
|
37
|
+
checkedBackgroundColor?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare function PxCheckBox({ checked, onChange, testID, label, disabled, checkedColor, tintColor, checkedBackgroundColor, onTintColor, focusable, labelColor, boxType, wrapperStyle, checkboxStyle, labelStyle, ...accessibilityProps }: ICheckBoxProps & AccessibilityProps): React.JSX.Element;
|
|
40
|
+
//# sourceMappingURL=PxCheckBox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PxCheckBox.d.ts","sourceRoot":"","sources":["../src/PxCheckBox.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAChE,OAAO,EACL,kBAAkB,EAElB,SAAS,EAET,SAAS,EAET,SAAS,EACV,MAAM,cAAc,CAAC;AAKtB,OAAO,YAAY,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACpC,aAAa,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACrC,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAID,wBAAgB,UAAU,CAAC,EACzB,OAAO,EACP,QAAQ,EACR,MAAM,EACN,KAAK,EACL,QAAgB,EAChB,YAAY,EACZ,SAAS,EACT,sBAAsB,EACtB,WAAW,EACX,SAAiB,EACjB,UAAU,EACV,OAAkB,EAClB,YAAY,EACZ,aAAa,EACb,UAAU,EACV,GAAG,kBAAkB,EACtB,EAAE,cAAc,GAAG,kBAAkB,qBA2IrC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proximus/lavender-checkbox-native",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"description": "Lavender Checkbox native component",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "src/index.ts",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"clean": "rm -rf dist",
|
|
11
|
+
"prepublish": "yarn clean && yarn build",
|
|
12
|
+
"build": "npx tsc -p tsconfig.json"
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"@proximus/lavender-common-native": "workspace:*",
|
|
16
|
+
"@proximus/lavender-styling-native": "workspace:*",
|
|
17
|
+
"@proximus/lavender-texts-native": "workspace:*"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@proximus/lavender-common-native": "0.1.0-alpha.0",
|
|
21
|
+
"@proximus/lavender-styling-native": "0.1.0-alpha.0",
|
|
22
|
+
"@proximus/lavender-texts-native": "0.1.0-alpha.0"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"lerna": {
|
|
28
|
+
"command": {
|
|
29
|
+
"publish": {
|
|
30
|
+
"assets": [
|
|
31
|
+
"dist",
|
|
32
|
+
"src",
|
|
33
|
+
"package.json"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"gitHead": "27525289a448a6e4f3c2d36a88b9dc54d0f15fbf"
|
|
39
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import CheckBox from '@react-native-community/checkbox';
|
|
2
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
3
|
+
import {
|
|
4
|
+
AccessibilityProps,
|
|
5
|
+
Platform,
|
|
6
|
+
StyleProp,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
TextStyle,
|
|
9
|
+
TouchableOpacity,
|
|
10
|
+
ViewStyle,
|
|
11
|
+
} from 'react-native';
|
|
12
|
+
|
|
13
|
+
import { a11y, e2eID } from '@proximus/lavender-common-native';
|
|
14
|
+
import { Colors, ThemeName, useTheme } from '@proximus/lavender-styling-native';
|
|
15
|
+
import { Body } from '@proximus/lavender-texts-native';
|
|
16
|
+
import 'nullthrows';
|
|
17
|
+
|
|
18
|
+
export interface ICheckBoxProps {
|
|
19
|
+
/**
|
|
20
|
+
* Common Props
|
|
21
|
+
*/
|
|
22
|
+
checked: boolean;
|
|
23
|
+
onChange?: (value: boolean) => void;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
testID?: string;
|
|
26
|
+
color?: string;
|
|
27
|
+
label?: string;
|
|
28
|
+
hasError?: boolean;
|
|
29
|
+
wrapperStyle?: StyleProp<ViewStyle>;
|
|
30
|
+
checkboxStyle?: StyleProp<ViewStyle>;
|
|
31
|
+
labelStyle?: StyleProp<TextStyle>;
|
|
32
|
+
labelColor?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Check @react-native-community/checkbox for more info
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Android only
|
|
38
|
+
*/
|
|
39
|
+
focusable?: boolean;
|
|
40
|
+
tintColors?: {
|
|
41
|
+
true?: string;
|
|
42
|
+
false?: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* IOS only
|
|
46
|
+
*/
|
|
47
|
+
checkedColor?: string;
|
|
48
|
+
boxType?: 'circle' | 'square';
|
|
49
|
+
tintColor?: string;
|
|
50
|
+
onTintColor?: string;
|
|
51
|
+
checkedBackgroundColor?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const isAndroid = Platform.OS === 'android';
|
|
55
|
+
|
|
56
|
+
export function PxCheckBox({
|
|
57
|
+
checked,
|
|
58
|
+
onChange,
|
|
59
|
+
testID,
|
|
60
|
+
label,
|
|
61
|
+
disabled = false,
|
|
62
|
+
checkedColor,
|
|
63
|
+
tintColor,
|
|
64
|
+
checkedBackgroundColor,
|
|
65
|
+
onTintColor,
|
|
66
|
+
focusable = false,
|
|
67
|
+
labelColor,
|
|
68
|
+
boxType = 'square',
|
|
69
|
+
wrapperStyle,
|
|
70
|
+
checkboxStyle,
|
|
71
|
+
labelStyle,
|
|
72
|
+
...accessibilityProps
|
|
73
|
+
}: ICheckBoxProps & AccessibilityProps) {
|
|
74
|
+
const { theme } = useTheme();
|
|
75
|
+
|
|
76
|
+
const isScarlet = theme.name === ThemeName.SCARLET;
|
|
77
|
+
|
|
78
|
+
const onChangeCallback = useCallback(
|
|
79
|
+
(value: boolean) => {
|
|
80
|
+
setInternalChecked(value);
|
|
81
|
+
if (onChange) {
|
|
82
|
+
onChange(value);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
[onChange]
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const [internalChecked, setInternalChecked] = useState(checked);
|
|
89
|
+
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
setInternalChecked(checked);
|
|
92
|
+
}, [checked]);
|
|
93
|
+
|
|
94
|
+
const getColors = () =>
|
|
95
|
+
isScarlet
|
|
96
|
+
? {
|
|
97
|
+
disabledBackgroundColor: Colors.v7.shadesOfGrey.whiteOpacity8,
|
|
98
|
+
checkedBackgroundColor: Colors.v8_1.white,
|
|
99
|
+
backgroundColor: Colors.v7.shadesOfGrey.blackOpacity2,
|
|
100
|
+
errorColor: Colors.v7.status.epicError,
|
|
101
|
+
disabledLabelColor: Colors.v7.shadesOfGrey.whiteOpacity16,
|
|
102
|
+
disabledColor: Colors.v7.shadesOfGrey.whiteOpacity8,
|
|
103
|
+
defaultLabel: '#FFF',
|
|
104
|
+
tintColor: Colors.brand.purple,
|
|
105
|
+
focusColor: Colors.white,
|
|
106
|
+
disabledCheckColor: Colors.v8_1.shadesOfGrey.dark160,
|
|
107
|
+
disabledBorderColor: Colors.v8_1.strokeBlack,
|
|
108
|
+
}
|
|
109
|
+
: {
|
|
110
|
+
disabledBackgroundColor: Colors.v8_1.shadesOfGrey.dark160,
|
|
111
|
+
checkedBackgroundColor: Colors.v8_1.shadesOfPurple.purple,
|
|
112
|
+
tintColor: Colors.v8_1.shadesOfPurple.purple,
|
|
113
|
+
backgroundColor: Colors.v8_1.shadesOfGrey.dark4,
|
|
114
|
+
disabledBorderColor: Colors.v8_1.shadesOfGrey.dark160,
|
|
115
|
+
borderColor: Colors.v8_1.strokeBlack,
|
|
116
|
+
errorColor: Colors.v7.status.error,
|
|
117
|
+
disabledLabelColor: Colors.v7.shadesOfGrey.black0Opacity12,
|
|
118
|
+
disabledColor: Colors.v8_1.shadesOfGrey.dark160,
|
|
119
|
+
defaultLabel: '#0A0A0A',
|
|
120
|
+
checkColor: Colors.v8_1.white,
|
|
121
|
+
disabledCheckColor: Colors.v8_1.shadesOfGrey.dark160,
|
|
122
|
+
focusColor: Colors.v8_1.shadesOfPurple.purple,
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<TouchableOpacity
|
|
127
|
+
style={[
|
|
128
|
+
{
|
|
129
|
+
flexDirection: 'row',
|
|
130
|
+
alignItems: 'center',
|
|
131
|
+
},
|
|
132
|
+
wrapperStyle,
|
|
133
|
+
]}
|
|
134
|
+
onPress={() => {
|
|
135
|
+
onChangeCallback(!internalChecked);
|
|
136
|
+
}}
|
|
137
|
+
{...a11y({
|
|
138
|
+
accessible: false,
|
|
139
|
+
})}
|
|
140
|
+
{...e2eID(testID + '-checkbox')}
|
|
141
|
+
>
|
|
142
|
+
<CheckBox
|
|
143
|
+
lineWidth={disabled || !internalChecked ? 2 : 3}
|
|
144
|
+
style={[
|
|
145
|
+
styles.checkbox,
|
|
146
|
+
{
|
|
147
|
+
backgroundColor: isAndroid
|
|
148
|
+
? 'transparent'
|
|
149
|
+
: disabled
|
|
150
|
+
? getColors().disabledBackgroundColor
|
|
151
|
+
: getColors().backgroundColor,
|
|
152
|
+
}, // Unchecked background color
|
|
153
|
+
checkboxStyle as any,
|
|
154
|
+
]}
|
|
155
|
+
tintColors={{
|
|
156
|
+
true: getColors().tintColor,
|
|
157
|
+
false: getColors().tintColor,
|
|
158
|
+
}}
|
|
159
|
+
tintColor={
|
|
160
|
+
tintColor || disabled
|
|
161
|
+
? internalChecked
|
|
162
|
+
? getColors().backgroundColor
|
|
163
|
+
: getColors().disabledBackgroundColor
|
|
164
|
+
: getColors().borderColor
|
|
165
|
+
} // checkbox border color when unchecked
|
|
166
|
+
onTintColor={onTintColor || getColors().tintColor} // checkbox border color when checked
|
|
167
|
+
onFillColor={
|
|
168
|
+
checkedBackgroundColor || getColors().checkedBackgroundColor
|
|
169
|
+
}
|
|
170
|
+
onCheckColor={
|
|
171
|
+
checkedColor || disabled
|
|
172
|
+
? getColors().disabledCheckColor
|
|
173
|
+
: getColors().checkColor
|
|
174
|
+
}
|
|
175
|
+
animationDuration={0.5}
|
|
176
|
+
value={internalChecked}
|
|
177
|
+
disabled={disabled}
|
|
178
|
+
boxType={boxType}
|
|
179
|
+
onValueChange={onChangeCallback}
|
|
180
|
+
hideBox={isAndroid || (disabled && internalChecked)}
|
|
181
|
+
focusable={focusable}
|
|
182
|
+
{...a11y({
|
|
183
|
+
accessible: accessibilityProps.accessible,
|
|
184
|
+
accessibilityLabel: accessibilityProps.accessibilityLabel || label,
|
|
185
|
+
accessibilityHint: accessibilityProps.accessibilityHint,
|
|
186
|
+
importantForAccessibility:
|
|
187
|
+
accessibilityProps.importantForAccessibility,
|
|
188
|
+
})}
|
|
189
|
+
{...e2eID(testID + '-checkbox')}
|
|
190
|
+
/>
|
|
191
|
+
{label && label.trim() !== '' && (
|
|
192
|
+
<Body
|
|
193
|
+
accessible={false}
|
|
194
|
+
importantForAccessibility={'no'}
|
|
195
|
+
style={[
|
|
196
|
+
styles.label,
|
|
197
|
+
{
|
|
198
|
+
color: labelColor
|
|
199
|
+
? labelColor
|
|
200
|
+
: disabled
|
|
201
|
+
? getColors().disabledLabelColor
|
|
202
|
+
: getColors().defaultLabel,
|
|
203
|
+
},
|
|
204
|
+
labelStyle,
|
|
205
|
+
]}
|
|
206
|
+
>
|
|
207
|
+
{label}
|
|
208
|
+
</Body>
|
|
209
|
+
)}
|
|
210
|
+
</TouchableOpacity>
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const styles = StyleSheet.create({
|
|
215
|
+
checkbox: {
|
|
216
|
+
height: 24,
|
|
217
|
+
width: 24,
|
|
218
|
+
borderRadius: 5,
|
|
219
|
+
},
|
|
220
|
+
label: {
|
|
221
|
+
marginHorizontal: 12,
|
|
222
|
+
fontStyle: 'normal',
|
|
223
|
+
fontWeight: '400',
|
|
224
|
+
},
|
|
225
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PxCheckBox';
|