@proximus/lavender-selectablebox-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 +31 -0
- package/dist/PxSelectableBox.d.ts +19 -0
- package/dist/PxSelectableBox.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/package.json +45 -0
- package/src/PxSelectableBox.tsx +213 -0
- package/src/index.ts +1 -0
- package/tsconfig.json +8 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
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-3651768:** selectable box module ([20a18ab](https://github.com/Pxs-Corporate/react-native-lavender/commit/20a18ab36049889d8860395a3e6ced9469bd6c0c))
|
|
16
|
+
- **BCRI-3810979:** tile components ([46fc5c7](https://github.com/Pxs-Corporate/react-native-lavender/commit/46fc5c7a0ddff6c2db43fba0de9929626092f265))
|
|
17
|
+
- **BCRI-4210372:** automatic versionning ([9c1f0a0](https://github.com/Pxs-Corporate/react-native-lavender/commit/9c1f0a00e19a9d1a277044ea627632032a674102))
|
|
18
|
+
- **BCRI-4210372:** fix bad version numbers ([bc6a8ba](https://github.com/Pxs-Corporate/react-native-lavender/commit/bc6a8ba48c15347442f2ac38dacae7ffba3d95eb))
|
|
19
|
+
|
|
20
|
+
# (2025-08-13)
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
- **BCRI-3807748:** fix checkbox android native crash ([f358872](https://github.com/Pxs-Corporate/react-native-lavender/commit/f3588725a8a7440722b6fc13a5586da2da758ea0))
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
- **BCRI-000000:** remove default E2E on DEV env build for all components ([a5d27bf](https://github.com/Pxs-Corporate/react-native-lavender/commit/a5d27bfaaebf5b75f3160f31c64b590b7bd00b93))
|
|
29
|
+
- **BCRI-3651768:** selectable box module ([20a18ab](https://github.com/Pxs-Corporate/react-native-lavender/commit/20a18ab36049889d8860395a3e6ced9469bd6c0c))
|
|
30
|
+
- **BCRI-3810979:** tile components ([46fc5c7](https://github.com/Pxs-Corporate/react-native-lavender/commit/46fc5c7a0ddff6c2db43fba0de9929626092f265))
|
|
31
|
+
- **BCRI-4210372:** automatic versionning ([9c1f0a0](https://github.com/Pxs-Corporate/react-native-lavender/commit/9c1f0a00e19a9d1a277044ea627632032a674102))
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { AccessibilityProps, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
export interface ISelectableBoxProps {
|
|
4
|
+
selected: boolean;
|
|
5
|
+
label: string;
|
|
6
|
+
onPress: (val: boolean) => void;
|
|
7
|
+
withCheckbox?: boolean;
|
|
8
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
locked?: boolean;
|
|
11
|
+
priceComponent?: ReactNode;
|
|
12
|
+
contentComponent?: ReactNode;
|
|
13
|
+
description?: string;
|
|
14
|
+
testID?: string;
|
|
15
|
+
selectedColor?: string;
|
|
16
|
+
wrapperStyle?: StyleProp<ViewStyle>;
|
|
17
|
+
}
|
|
18
|
+
export declare function PxSelectableBox({ selected, label, onPress, containerStyle, withCheckbox, disabled, locked, priceComponent, contentComponent, description, selectedColor, testID, ...accessibilityProps }: ISelectableBoxProps & AccessibilityProps): React.JSX.Element;
|
|
19
|
+
//# sourceMappingURL=PxSelectableBox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PxSelectableBox.d.ts","sourceRoot":"","sources":["../src/PxSelectableBox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EACL,kBAAkB,EAClB,SAAS,EAIT,SAAS,EACV,MAAM,cAAc,CAAC;AAOtB,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAChC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACrC;AAED,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,KAAK,EACL,OAAO,EACP,cAAc,EACd,YAAY,EACZ,QAAgB,EAChB,MAAM,EACN,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,MAAwB,EACxB,GAAG,kBAAkB,EACtB,EAAE,mBAAmB,GAAG,kBAAkB,qBAmI1C"}
|
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,mBAAmB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proximus/lavender-selectablebox-native",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"description": "Lavender selectable box component",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
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-checkbox-native": "workspace:*",
|
|
16
|
+
"@proximus/lavender-common-native": "workspace:*",
|
|
17
|
+
"@proximus/lavender-icon-native": "workspace:*",
|
|
18
|
+
"@proximus/lavender-radio-native": "workspace:*",
|
|
19
|
+
"@proximus/lavender-styling-native": "workspace:*",
|
|
20
|
+
"@proximus/lavender-texts-native": "workspace:*"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@proximus/lavender-checkbox-native": "0.1.0-alpha.0",
|
|
24
|
+
"@proximus/lavender-common-native": "0.1.0-alpha.0",
|
|
25
|
+
"@proximus/lavender-icon-native": "0.1.0-alpha.0",
|
|
26
|
+
"@proximus/lavender-radio-native": "0.1.0-alpha.0",
|
|
27
|
+
"@proximus/lavender-styling-native": "0.1.0-alpha.0",
|
|
28
|
+
"@proximus/lavender-texts-native": "0.1.0-alpha.0"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"lerna": {
|
|
34
|
+
"command": {
|
|
35
|
+
"publish": {
|
|
36
|
+
"assets": [
|
|
37
|
+
"dist",
|
|
38
|
+
"src",
|
|
39
|
+
"package.json"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"gitHead": "27525289a448a6e4f3c2d36a88b9dc54d0f15fbf"
|
|
45
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
AccessibilityProps,
|
|
4
|
+
StyleProp,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
View,
|
|
8
|
+
ViewStyle,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import { a11y, e2eID } from '@proximus/lavender-common-native';
|
|
11
|
+
import { PxRadioButton } from '@proximus/lavender-radio-native';
|
|
12
|
+
import { PxCheckBox } from '@proximus/lavender-checkbox-native';
|
|
13
|
+
import { Colors, ThemeName, useTheme } from '@proximus/lavender-styling-native';
|
|
14
|
+
import { Body, Header } from '@proximus/lavender-texts-native';
|
|
15
|
+
|
|
16
|
+
export interface ISelectableBoxProps {
|
|
17
|
+
selected: boolean;
|
|
18
|
+
label: string;
|
|
19
|
+
onPress: (val: boolean) => void;
|
|
20
|
+
withCheckbox?: boolean;
|
|
21
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
locked?: boolean;
|
|
24
|
+
priceComponent?: ReactNode;
|
|
25
|
+
contentComponent?: ReactNode;
|
|
26
|
+
description?: string;
|
|
27
|
+
testID?: string;
|
|
28
|
+
selectedColor?: string;
|
|
29
|
+
wrapperStyle?: StyleProp<ViewStyle>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function PxSelectableBox({
|
|
33
|
+
selected,
|
|
34
|
+
label,
|
|
35
|
+
onPress,
|
|
36
|
+
containerStyle,
|
|
37
|
+
withCheckbox,
|
|
38
|
+
disabled = false,
|
|
39
|
+
locked,
|
|
40
|
+
priceComponent,
|
|
41
|
+
contentComponent,
|
|
42
|
+
description,
|
|
43
|
+
selectedColor,
|
|
44
|
+
testID = 'selectableBox',
|
|
45
|
+
...accessibilityProps
|
|
46
|
+
}: ISelectableBoxProps & AccessibilityProps) {
|
|
47
|
+
const { theme } = useTheme();
|
|
48
|
+
const isScarlet = theme.name === ThemeName.SCARLET;
|
|
49
|
+
|
|
50
|
+
const accessibilityRole = locked
|
|
51
|
+
? 'text'
|
|
52
|
+
: withCheckbox
|
|
53
|
+
? 'checkbox'
|
|
54
|
+
: 'radio';
|
|
55
|
+
const accessibilityHint = `Selectable Item ${label}, checked: ${selected}`;
|
|
56
|
+
const computedSelectedColor =
|
|
57
|
+
selectedColor ||
|
|
58
|
+
(isScarlet
|
|
59
|
+
? Colors.v7.status.epicSuccess
|
|
60
|
+
: Colors.v8_1.shadesOfPurple.purple);
|
|
61
|
+
|
|
62
|
+
const getColors = () =>
|
|
63
|
+
isScarlet
|
|
64
|
+
? {
|
|
65
|
+
uncheckedBorderColor: Colors.v7.shadesOfGrey.whiteOpacity12,
|
|
66
|
+
backgroundColor: Colors.v7.shadesOfGrey.whiteOpacity8,
|
|
67
|
+
focusBorderColor: Colors.shadesOfGrey.white,
|
|
68
|
+
disabledBgColor: Colors.v7.shadesOfGrey.whiteOpacity8,
|
|
69
|
+
defaultLabel: Colors.shadesOfGrey.white,
|
|
70
|
+
uncheckedLabel: Colors.v7.shadesOfGrey.whiteOpacity16,
|
|
71
|
+
}
|
|
72
|
+
: {
|
|
73
|
+
uncheckedBorderColor: Colors.v8_1.shadesOfGrey.dark120,
|
|
74
|
+
backgroundColor: Colors.v8_1.white,
|
|
75
|
+
focusBorderColor: Colors.v8_1.shadesOfPurple.purple,
|
|
76
|
+
disabledBgColor: Colors.v8_1.white,
|
|
77
|
+
defaultLabel: Colors.v8_1.shadesOfPurple.purple,
|
|
78
|
+
uncheckedLabel: Colors.v8_1.text.black,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<TouchableOpacity
|
|
83
|
+
onPress={() => {
|
|
84
|
+
onPress?.(!selected);
|
|
85
|
+
}}
|
|
86
|
+
style={[{ width: '100%' }, containerStyle]}
|
|
87
|
+
disabled={disabled || locked}
|
|
88
|
+
{...e2eID(testID)}
|
|
89
|
+
{...a11y({
|
|
90
|
+
accessible: true,
|
|
91
|
+
accessibilityRole,
|
|
92
|
+
accessibilityHint,
|
|
93
|
+
accessibilityLabel: label,
|
|
94
|
+
accessibilityState: {
|
|
95
|
+
checked: selected,
|
|
96
|
+
disabled: disabled || locked,
|
|
97
|
+
},
|
|
98
|
+
...accessibilityProps,
|
|
99
|
+
})}
|
|
100
|
+
>
|
|
101
|
+
<View
|
|
102
|
+
style={[
|
|
103
|
+
styles.container,
|
|
104
|
+
{
|
|
105
|
+
borderColor: selected
|
|
106
|
+
? computedSelectedColor
|
|
107
|
+
: getColors().uncheckedBorderColor,
|
|
108
|
+
backgroundColor: getColors().backgroundColor,
|
|
109
|
+
},
|
|
110
|
+
disabled && {
|
|
111
|
+
borderWidth: 0,
|
|
112
|
+
backgroundColor: getColors().disabledBgColor,
|
|
113
|
+
},
|
|
114
|
+
locked && {
|
|
115
|
+
borderColor: computedSelectedColor,
|
|
116
|
+
},
|
|
117
|
+
]}
|
|
118
|
+
{...a11y({
|
|
119
|
+
accessible: true,
|
|
120
|
+
accessibilityRole,
|
|
121
|
+
accessibilityHint,
|
|
122
|
+
})}
|
|
123
|
+
>
|
|
124
|
+
<View style={styles.topContentContainer}>
|
|
125
|
+
<View style={styles.topContainer}>
|
|
126
|
+
{withCheckbox ? (
|
|
127
|
+
<PxCheckBox
|
|
128
|
+
onChange={onPress}
|
|
129
|
+
checked={selected}
|
|
130
|
+
color={
|
|
131
|
+
selected
|
|
132
|
+
? computedSelectedColor
|
|
133
|
+
: isScarlet
|
|
134
|
+
? Colors.v7.shadesOfGrey.whiteOpacity52
|
|
135
|
+
: Colors.v7.shadesOfGrey.blackOpacity44
|
|
136
|
+
}
|
|
137
|
+
checkedColor={isScarlet ? '#0A0A0A' : undefined}
|
|
138
|
+
disabled={disabled}
|
|
139
|
+
/>
|
|
140
|
+
) : (
|
|
141
|
+
<PxRadioButton
|
|
142
|
+
onPress={() => onPress?.(!selected)}
|
|
143
|
+
color={computedSelectedColor}
|
|
144
|
+
checked={selected}
|
|
145
|
+
disabled={disabled}
|
|
146
|
+
/>
|
|
147
|
+
)}
|
|
148
|
+
<View style={styles.textContainer}>
|
|
149
|
+
<Header
|
|
150
|
+
textBreakStrategy={'balanced'}
|
|
151
|
+
accessible={true}
|
|
152
|
+
style={[
|
|
153
|
+
styles.title,
|
|
154
|
+
{
|
|
155
|
+
color: !selected
|
|
156
|
+
? getColors().uncheckedLabel
|
|
157
|
+
: getColors().defaultLabel,
|
|
158
|
+
},
|
|
159
|
+
]}
|
|
160
|
+
>
|
|
161
|
+
{label}
|
|
162
|
+
</Header>
|
|
163
|
+
<Body style={styles.description}>{description}</Body>
|
|
164
|
+
</View>
|
|
165
|
+
</View>
|
|
166
|
+
{contentComponent && (
|
|
167
|
+
<View style={{ marginTop: 16 }}>{contentComponent}</View>
|
|
168
|
+
)}
|
|
169
|
+
</View>
|
|
170
|
+
|
|
171
|
+
{priceComponent && (
|
|
172
|
+
<View style={styles.priceComponent}>{priceComponent}</View>
|
|
173
|
+
)}
|
|
174
|
+
</View>
|
|
175
|
+
</TouchableOpacity>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const styles = StyleSheet.create({
|
|
180
|
+
container: {
|
|
181
|
+
flexDirection: 'row',
|
|
182
|
+
borderWidth: 2,
|
|
183
|
+
borderRadius: 12,
|
|
184
|
+
},
|
|
185
|
+
title: {
|
|
186
|
+
fontSize: 14,
|
|
187
|
+
},
|
|
188
|
+
priceComponent: {
|
|
189
|
+
padding: 8,
|
|
190
|
+
alignItems: 'center',
|
|
191
|
+
justifyContent: 'center',
|
|
192
|
+
backgroundColor: Colors.v8_1.shadesOfGrey.dark4,
|
|
193
|
+
},
|
|
194
|
+
description: {
|
|
195
|
+
color: Colors.v8_1.text.details,
|
|
196
|
+
fontSize: 12,
|
|
197
|
+
},
|
|
198
|
+
topContentContainer: {
|
|
199
|
+
padding: 16,
|
|
200
|
+
flex: 1,
|
|
201
|
+
},
|
|
202
|
+
topContainer: {
|
|
203
|
+
flexDirection: 'row',
|
|
204
|
+
alignItems: 'center',
|
|
205
|
+
justifyContent: 'flex-start',
|
|
206
|
+
},
|
|
207
|
+
textContainer: {
|
|
208
|
+
flexDirection: 'column',
|
|
209
|
+
marginHorizontal: 16,
|
|
210
|
+
justifyContent: 'center',
|
|
211
|
+
flex: 1,
|
|
212
|
+
},
|
|
213
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PxSelectableBox';
|