@proximus/lavender-checkbox-native 2.1.0-alpha.0 → 2.1.1-alpha.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.
@@ -1 +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,EAClB,SAAS,EAGT,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,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACrC;AAED,wBAAgB,UAAU,CAAC,EACzB,OAAO,EACP,QAAQ,EACR,MAAM,EACN,KAAK,EACL,QAAgB,EAChB,YAAY,EACZ,GAAG,kBAAkB,EACtB,EAAE,cAAc,GAAG,kBAAkB,qBAmHrC"}
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,EAGT,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,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACrC;AAED,wBAAgB,UAAU,CAAC,EACzB,OAAO,EACP,QAAQ,EACR,MAAM,EACN,KAAK,EACL,QAAgB,EAChB,YAAY,EACZ,GAAG,kBAAkB,EACtB,EAAE,cAAc,GAAG,kBAAkB,qBAuHrC"}
@@ -1,22 +1,22 @@
1
1
  import CheckBox from '@react-native-community/checkbox';
2
2
  import React, { useCallback, useEffect, useState } from 'react';
3
- import { StyleSheet, TouchableOpacity, } from 'react-native';
3
+ import { Platform, StyleSheet, TouchableOpacity, } from 'react-native';
4
4
  import { a11y, e2eID } from '@proximus/lavender-common-native';
5
5
  import { useTheme } from '@proximus/lavender-styling-native';
6
6
  import { Body } from '@proximus/lavender-texts-native';
7
7
  import 'nullthrows';
8
8
  export function PxCheckBox({ checked, onChange, testID, label, disabled = false, wrapperStyle, ...accessibilityProps }) {
9
9
  const { theme } = useTheme();
10
+ const [internalChecked, setInternalChecked] = useState(checked);
11
+ useEffect(() => {
12
+ setInternalChecked(checked);
13
+ }, [checked, setInternalChecked]);
10
14
  const onChangeCallback = useCallback((value) => {
11
15
  setInternalChecked(value);
12
16
  if (onChange) {
13
17
  onChange(value);
14
18
  }
15
- }, [onChange]);
16
- const [internalChecked, setInternalChecked] = useState(checked);
17
- useEffect(() => {
18
- setInternalChecked(checked);
19
- }, [checked]);
19
+ }, [onChange, setInternalChecked]);
20
20
  const colors = {
21
21
  disabledBackgroundColor: theme.t('ColorBackgroundStateDisabledDefault'),
22
22
  disabledLabelColor: theme.t('ColorTextStateDisabledDefault'),
@@ -61,7 +61,11 @@ export function PxCheckBox({ checked, onChange, testID, label, disabled = false,
61
61
  ? colors.disabledBackgroundColor
62
62
  : colors.checkedBackgroundColor, onFillColor: disabled
63
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({
64
+ : colors.checkedBackgroundColor, onCheckColor: disabled ? colors.disabledCheckColor : colors.checkColor, animationDuration: 0.2, value: internalChecked, disabled: disabled, boxType: 'square', ...(Platform.OS === 'android' && {
65
+ // on Android, native checkbox grabs all touch events and TouchableOpacity onpress not called
66
+ // so need to rely on native onValueChange
67
+ onValueChange: onChangeCallback,
68
+ }), focusable: true, ...a11y({
65
69
  accessible: accessibilityProps.accessible,
66
70
  accessibilityLabel: accessibilityProps.accessibilityLabel || label,
67
71
  accessibilityHint: accessibilityProps.accessibilityHint,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proximus/lavender-checkbox-native",
3
- "version": "2.1.0-alpha.0",
3
+ "version": "2.1.1-alpha.1",
4
4
  "description": "Lavender Checkbox native component",
5
5
  "license": "MIT",
6
6
  "type": "module",