@proximus/lavender-checkbox-native 0.1.0-alpha.4 → 0.1.0-beta.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.
@@ -0,0 +1,88 @@
1
+ import CheckBox from '@react-native-community/checkbox';
2
+ import React, { useCallback, useEffect, useState } from 'react';
3
+ import { StyleSheet, TouchableOpacity, } from 'react-native';
4
+ import { a11y, e2eID } from '@proximus/lavender-common-native';
5
+ import { useTheme } from '@proximus/lavender-styling-native';
6
+ import { Body } from '@proximus/lavender-texts-native';
7
+ import 'nullthrows';
8
+ export function PxCheckBox({ checked, onChange, testID, label, disabled = false, wrapperStyle, ...accessibilityProps }) {
9
+ const { theme } = useTheme();
10
+ const onChangeCallback = useCallback((value) => {
11
+ setInternalChecked(value);
12
+ if (onChange) {
13
+ onChange(value);
14
+ }
15
+ }, [onChange]);
16
+ const [internalChecked, setInternalChecked] = useState(checked);
17
+ useEffect(() => {
18
+ setInternalChecked(checked);
19
+ }, [checked]);
20
+ const colors = {
21
+ disabledBackgroundColor: theme.t('ColorBackgroundStateDisabledDefault'),
22
+ disabledLabelColor: theme.t('ColorTextStateDisabledDefault'),
23
+ disabledCheckColor: 'rgba(255, 255, 255, 0.3)',
24
+ disabledBorderColor: theme.t('ColorBorderMainDefault'),
25
+ checkedBackgroundColor: theme.t('ColorBackgroundContainerPrimaryDefault'),
26
+ checkColor: '#FFFFFF',
27
+ tintColor: theme.t('ColorIconBrandDefault'),
28
+ backgroundColor: theme.t('ColorBackgroundContainerLightDefault'),
29
+ borderColor: theme.t('ColorBorderNeutralDefault'),
30
+ defaultLabelColor: theme.t('ColorTextNeutralDefault'),
31
+ };
32
+ return (React.createElement(TouchableOpacity, { style: [
33
+ {
34
+ flexDirection: 'row',
35
+ alignItems: 'center',
36
+ },
37
+ wrapperStyle,
38
+ ], onPress: () => {
39
+ onChangeCallback(!internalChecked);
40
+ }, ...a11y({
41
+ accessible: false,
42
+ }), ...(testID && e2eID(testID + '-checkbox-wrapper')), disabled: disabled },
43
+ React.createElement(CheckBox, { lineWidth: 2, style: [
44
+ styles.checkbox,
45
+ {
46
+ // @ts-ignore
47
+ width: theme.t('SizeM').number,
48
+ // @ts-ignore
49
+ height: theme.t('SizeM').number,
50
+ }, // Unchecked background color
51
+ ], tintColors: {
52
+ // Android only
53
+ true: disabled ? colors.disabledBackgroundColor : colors.tintColor,
54
+ false: disabled ? colors.disabledBackgroundColor : colors.tintColor,
55
+ }, tintColor:
56
+ // iOS only
57
+ disabled ? colors.disabledBackgroundColor : colors.borderColor // enabled
58
+ , onTintColor:
59
+ // iOS only
60
+ disabled
61
+ ? colors.disabledBackgroundColor
62
+ : colors.checkedBackgroundColor, onFillColor: disabled
63
+ ? colors.disabledBackgroundColor
64
+ : colors.checkedBackgroundColor, onCheckColor: disabled ? colors.disabledCheckColor : colors.checkColor, animationDuration: 0.2, value: internalChecked, disabled: disabled, boxType: 'square', onValueChange: onChangeCallback, focusable: true, ...a11y({
65
+ accessible: accessibilityProps.accessible,
66
+ accessibilityLabel: accessibilityProps.accessibilityLabel || label,
67
+ accessibilityHint: accessibilityProps.accessibilityHint,
68
+ importantForAccessibility: accessibilityProps.importantForAccessibility,
69
+ }), ...(testID && e2eID(testID + '-checkbox')) }),
70
+ label && label.trim() !== '' && (React.createElement(Body, { accessible: false, importantForAccessibility: 'no', style: [
71
+ styles.label,
72
+ {
73
+ color: disabled
74
+ ? colors.disabledLabelColor
75
+ : colors.defaultLabelColor,
76
+ },
77
+ ] }, label))));
78
+ }
79
+ const styles = StyleSheet.create({
80
+ checkbox: {
81
+ borderRadius: 5,
82
+ },
83
+ label: {
84
+ marginHorizontal: 12,
85
+ fontStyle: 'normal',
86
+ fontWeight: '400',
87
+ },
88
+ });
package/package.json CHANGED
@@ -1,38 +1,19 @@
1
1
  {
2
2
  "name": "@proximus/lavender-checkbox-native",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.1.0-beta.0",
4
4
  "description": "Lavender Checkbox native component",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "main": "src/index.ts",
8
- "scripts": {
9
- "clean": "rm -rf dist",
10
- "prepublish": "yarn clean && yarn build",
11
- "build": "npx tsc -p tsconfig.json"
12
- },
7
+ "main": "dist/index.js",
8
+ "files": [
9
+ "dist"
10
+ ],
13
11
  "peerDependencies": {
14
- "@proximus/lavender-common-native": "workspace:*",
15
- "@proximus/lavender-styling-native": "workspace:*",
16
- "@proximus/lavender-texts-native": "workspace:*"
17
- },
18
- "devDependencies": {
19
- "@proximus/lavender-common-native": "0.1.0-alpha.4",
20
- "@proximus/lavender-styling-native": "0.1.0-alpha.3",
21
- "@proximus/lavender-texts-native": "0.1.0-alpha.4"
12
+ "@proximus/lavender-common-native": "*",
13
+ "@proximus/lavender-styling-native": "*",
14
+ "@proximus/lavender-texts-native": "*"
22
15
  },
23
16
  "publishConfig": {
24
17
  "access": "public"
25
- },
26
- "lerna": {
27
- "command": {
28
- "publish": {
29
- "assets": [
30
- "dist",
31
- "src",
32
- "package.json"
33
- ]
34
- }
35
- }
36
- },
37
- "gitHead": "6e9252a716a08ededdfbfd6f5b1db70ab21e026e"
18
+ }
38
19
  }
package/CHANGELOG.md DELETED
@@ -1,59 +0,0 @@
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.4](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-checkbox-native@0.1.0-alpha.3...@proximus/lavender-checkbox-native@0.1.0-alpha.4) (2025-09-19)
7
-
8
- **Note:** Version bump only for package @proximus/lavender-checkbox-native
9
-
10
- # [0.1.0-alpha.3](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-checkbox-native@0.1.0-alpha.2...@proximus/lavender-checkbox-native@0.1.0-alpha.3) (2025-09-12)
11
-
12
- **Note:** Version bump only for package @proximus/lavender-checkbox-native
13
-
14
- # [0.1.0-alpha.2](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-checkbox-native@0.1.0-alpha.1...@proximus/lavender-checkbox-native@0.1.0-alpha.2) (2025-09-05)
15
-
16
- ### Features
17
-
18
- - **BCRI-4279213:** update token architecture and component styles ([#18](https://github.com/Pxs-Corporate/react-native-lavender/issues/18)) ([2fabf41](https://github.com/Pxs-Corporate/react-native-lavender/commit/2fabf416ce069e9756daa868c3012181db87e7f5))
19
-
20
- # [0.1.0-alpha.1](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-checkbox-native@0.1.0-alpha.0...@proximus/lavender-checkbox-native@0.1.0-alpha.1) (2025-08-13)
21
-
22
- ### Bug Fixes
23
-
24
- - **BCRI-4210372:** fix types field in modules ([68ac126](https://github.com/Pxs-Corporate/react-native-lavender/commit/68ac12657112473ae9e0e683076b1d9172be9ce6))
25
-
26
- # 0.1.0-alpha.0 (2025-08-13)
27
-
28
- ### Bug Fixes
29
-
30
- - **BCRI-3807748:** fix checkbox android native crash ([f358872](https://github.com/Pxs-Corporate/react-native-lavender/commit/f3588725a8a7440722b6fc13a5586da2da758ea0))
31
-
32
- ### Features
33
-
34
- - **BCRI-000000:** remove default E2E on DEV env build for all components ([a5d27bf](https://github.com/Pxs-Corporate/react-native-lavender/commit/a5d27bfaaebf5b75f3160f31c64b590b7bd00b93))
35
- - **BCRI-3651613:** checkbox module ([b791f5f](https://github.com/Pxs-Corporate/react-native-lavender/commit/b791f5f9482f1162302826092d946fa364f37e9d))
36
- - **BCRI-3651673:** entrypoint module ([9a246af](https://github.com/Pxs-Corporate/react-native-lavender/commit/9a246af671f674f0ff768a9b6a72a77d1f12d065))
37
- - **BCRI-3660857:** cell components ([af9e45c](https://github.com/Pxs-Corporate/react-native-lavender/commit/af9e45cefc20d08d2338380ff4cd8cd6851abe24))
38
- - **BCRI-3707400:** entrypoint prefix slot ([5f5c4a9](https://github.com/Pxs-Corporate/react-native-lavender/commit/5f5c4a9a973a5168d359f6d4a9413a3b7bf50d48))
39
- - **BCRI-3810979:** tile components ([46fc5c7](https://github.com/Pxs-Corporate/react-native-lavender/commit/46fc5c7a0ddff6c2db43fba0de9929626092f265))
40
- - **BCRI-4002610:** update icon handling and remove deprecated font references ([4399fe4](https://github.com/Pxs-Corporate/react-native-lavender/commit/4399fe4bff06aa70f5c29705fcc89d5243b0e3e7))
41
- - **BCRI-4210372:** automatic versionning ([9c1f0a0](https://github.com/Pxs-Corporate/react-native-lavender/commit/9c1f0a00e19a9d1a277044ea627632032a674102))
42
- - **BCRI-4210372:** fix bad version numbers ([bc6a8ba](https://github.com/Pxs-Corporate/react-native-lavender/commit/bc6a8ba48c15347442f2ac38dacae7ffba3d95eb))
43
-
44
- # (2025-08-13)
45
-
46
- ### Bug Fixes
47
-
48
- - **BCRI-3807748:** fix checkbox android native crash ([f358872](https://github.com/Pxs-Corporate/react-native-lavender/commit/f3588725a8a7440722b6fc13a5586da2da758ea0))
49
-
50
- ### Features
51
-
52
- - **BCRI-000000:** remove default E2E on DEV env build for all components ([a5d27bf](https://github.com/Pxs-Corporate/react-native-lavender/commit/a5d27bfaaebf5b75f3160f31c64b590b7bd00b93))
53
- - **BCRI-3651613:** checkbox module ([b791f5f](https://github.com/Pxs-Corporate/react-native-lavender/commit/b791f5f9482f1162302826092d946fa364f37e9d))
54
- - **BCRI-3651673:** entrypoint module ([9a246af](https://github.com/Pxs-Corporate/react-native-lavender/commit/9a246af671f674f0ff768a9b6a72a77d1f12d065))
55
- - **BCRI-3660857:** cell components ([af9e45c](https://github.com/Pxs-Corporate/react-native-lavender/commit/af9e45cefc20d08d2338380ff4cd8cd6851abe24))
56
- - **BCRI-3707400:** entrypoint prefix slot ([5f5c4a9](https://github.com/Pxs-Corporate/react-native-lavender/commit/5f5c4a9a973a5168d359f6d4a9413a3b7bf50d48))
57
- - **BCRI-3810979:** tile components ([46fc5c7](https://github.com/Pxs-Corporate/react-native-lavender/commit/46fc5c7a0ddff6c2db43fba0de9929626092f265))
58
- - **BCRI-4002610:** update icon handling and remove deprecated font references ([4399fe4](https://github.com/Pxs-Corporate/react-native-lavender/commit/4399fe4bff06aa70f5c29705fcc89d5243b0e3e7))
59
- - **BCRI-4210372:** automatic versionning ([9c1f0a0](https://github.com/Pxs-Corporate/react-native-lavender/commit/9c1f0a00e19a9d1a277044ea627632032a674102))
@@ -1,163 +0,0 @@
1
- import CheckBox from '@react-native-community/checkbox';
2
- import React, { useCallback, useEffect, useState } from 'react';
3
- import {
4
- AccessibilityProps,
5
- StyleProp,
6
- StyleSheet,
7
- TouchableOpacity,
8
- ViewStyle,
9
- } from 'react-native';
10
-
11
- import { a11y, e2eID } from '@proximus/lavender-common-native';
12
- import { useTheme } from '@proximus/lavender-styling-native';
13
- import { Body } from '@proximus/lavender-texts-native';
14
- import 'nullthrows';
15
-
16
- export interface ICheckBoxProps {
17
- /**
18
- * Common Props
19
- */
20
- checked: boolean;
21
- onChange?: (value: boolean) => void;
22
- disabled?: boolean;
23
- testID?: string;
24
- label?: string;
25
- hasError?: boolean;
26
- wrapperStyle?: StyleProp<ViewStyle>;
27
- }
28
-
29
- export function PxCheckBox({
30
- checked,
31
- onChange,
32
- testID,
33
- label,
34
- disabled = false,
35
- wrapperStyle,
36
- ...accessibilityProps
37
- }: ICheckBoxProps & AccessibilityProps) {
38
- const { theme } = useTheme();
39
-
40
- const onChangeCallback = useCallback(
41
- (value: boolean) => {
42
- setInternalChecked(value);
43
- if (onChange) {
44
- onChange(value);
45
- }
46
- },
47
- [onChange]
48
- );
49
-
50
- const [internalChecked, setInternalChecked] = useState(checked);
51
-
52
- useEffect(() => {
53
- setInternalChecked(checked);
54
- }, [checked]);
55
-
56
- const colors = {
57
- disabledBackgroundColor: theme.t('ColorBackgroundStateDisabledDefault'),
58
- disabledLabelColor: theme.t('ColorTextStateDisabledDefault'),
59
- disabledCheckColor: 'rgba(255, 255, 255, 0.3)',
60
- disabledBorderColor: theme.t('ColorBorderMainDefault'),
61
- checkedBackgroundColor: theme.t('ColorBackgroundContainerPrimaryDefault'),
62
- checkColor: '#FFFFFF',
63
- tintColor: theme.t('ColorIconBrandDefault'),
64
- backgroundColor: theme.t('ColorBackgroundContainerLightDefault'),
65
- borderColor: theme.t('ColorBorderNeutralDefault'),
66
- defaultLabelColor: theme.t('ColorTextNeutralDefault'),
67
- };
68
-
69
- return (
70
- <TouchableOpacity
71
- style={[
72
- {
73
- flexDirection: 'row',
74
- alignItems: 'center',
75
- },
76
- wrapperStyle,
77
- ]}
78
- onPress={() => {
79
- onChangeCallback(!internalChecked);
80
- }}
81
- {...a11y({
82
- accessible: false,
83
- })}
84
- {...e2eID(testID + '-checkbox')}
85
- disabled={disabled}
86
- >
87
- <CheckBox
88
- lineWidth={2}
89
- style={[
90
- styles.checkbox,
91
- {
92
- // @ts-ignore
93
- width: theme.t('SizeM').number,
94
- // @ts-ignore
95
- height: theme.t('SizeM').number,
96
- }, // Unchecked background color
97
- ]}
98
- tintColors={{
99
- // Android only
100
- true: disabled ? colors.disabledBackgroundColor : colors.tintColor,
101
- false: disabled ? colors.disabledBackgroundColor : colors.tintColor,
102
- }}
103
- tintColor={
104
- // iOS only
105
- disabled ? colors.disabledBackgroundColor : colors.borderColor // enabled
106
- } // checkbox border color when unchecked
107
- onTintColor={
108
- // iOS only
109
- disabled
110
- ? colors.disabledBackgroundColor
111
- : colors.checkedBackgroundColor
112
- } // checkbox border color when checked
113
- onFillColor={
114
- disabled
115
- ? colors.disabledBackgroundColor
116
- : colors.checkedBackgroundColor
117
- }
118
- onCheckColor={disabled ? colors.disabledCheckColor : colors.checkColor}
119
- animationDuration={0.2}
120
- value={internalChecked}
121
- disabled={disabled}
122
- boxType={'square'}
123
- onValueChange={onChangeCallback}
124
- focusable={true}
125
- {...a11y({
126
- accessible: accessibilityProps.accessible,
127
- accessibilityLabel: accessibilityProps.accessibilityLabel || label,
128
- accessibilityHint: accessibilityProps.accessibilityHint,
129
- importantForAccessibility:
130
- accessibilityProps.importantForAccessibility,
131
- })}
132
- {...e2eID(testID + '-checkbox')}
133
- />
134
- {label && label.trim() !== '' && (
135
- <Body
136
- accessible={false}
137
- importantForAccessibility={'no'}
138
- style={[
139
- styles.label,
140
- {
141
- color: disabled
142
- ? colors.disabledLabelColor
143
- : colors.defaultLabelColor,
144
- },
145
- ]}
146
- >
147
- {label}
148
- </Body>
149
- )}
150
- </TouchableOpacity>
151
- );
152
- }
153
-
154
- const styles = StyleSheet.create({
155
- checkbox: {
156
- borderRadius: 5,
157
- },
158
- label: {
159
- marginHorizontal: 12,
160
- fontStyle: 'normal',
161
- fontWeight: '400',
162
- },
163
- });
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.npm.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- },
6
- "include": ["src","../../../lib.d.ts"],
7
- "exclude": ["dist", "node_modules", "src/**/*.test.ts", "src/**/*.spec.ts"]
8
- }
File without changes