react-native-ui-lib 7.37.2-snapshot.6147 → 7.37.2-snapshot.6172

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ui-lib",
3
- "version": "7.37.2-snapshot.6147",
3
+ "version": "7.37.2-snapshot.6172",
4
4
  "main": "src/index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
@@ -10,7 +10,6 @@ const transparentImage = require("./assets/transparentSwatch/TransparentSwatch.p
10
10
  const DEFAULT_SIZE = Constants.isTablet ? 44 : 36;
11
11
  export const SWATCH_MARGIN = 12;
12
12
  export const SWATCH_SIZE = DEFAULT_SIZE;
13
- const DEFAULT_COLOR = Colors.grey30;
14
13
 
15
14
  /**
16
15
  * @description: A color swatch component
@@ -84,8 +83,9 @@ class ColorSwatch extends PureComponent {
84
83
  value,
85
84
  index
86
85
  } = this.props;
86
+ const color = this.color ?? '';
87
87
  const tintColor = this.getTintColor(value);
88
- const result = value || this.color || '';
88
+ const result = value || color;
89
89
  const hexString = Colors.getHexString(result);
90
90
  this.props.onPress?.(result, {
91
91
  tintColor,
@@ -102,14 +102,10 @@ class ColorSwatch extends PureComponent {
102
102
  }
103
103
  }
104
104
  getAccessibilityInfo() {
105
- const color = this.color || DEFAULT_COLOR;
106
- const defaultText = !this.color ? 'default' : '';
105
+ const color = this.color;
107
106
  return {
108
- accessible: true,
109
- accessibilityLabel: `${defaultText} color ${Colors.getColorName(color)}`,
110
- accessibilityState: {
111
- selected: this.props.selected
112
- }
107
+ accessibilityLabel: color && Colors.getColorName(color),
108
+ accessibilityStates: this.props.selected ? ['selected'] : []
113
109
  };
114
110
  }
115
111
  getLayout() {
@@ -126,11 +122,13 @@ class ColorSwatch extends PureComponent {
126
122
  size = DEFAULT_SIZE,
127
123
  ...others
128
124
  } = this.props;
125
+ const color = this.color;
129
126
  const {
130
127
  isSelected
131
128
  } = this.state;
132
129
  const Container = onPress ? TouchableOpacity : View;
133
- const tintColor = this.getTintColor(this.color);
130
+ const tintColor = this.getTintColor(color);
131
+ const accessibilityInfo = Constants.accessibility.isScreenReaderEnabled && this.getAccessibilityInfo();
134
132
  return <Container {...others} center activeOpacity={1} throttleTime={0} hitSlop={{
135
133
  top: 10,
136
134
  bottom: 10,
@@ -140,8 +138,8 @@ class ColorSwatch extends PureComponent {
140
138
  width: size,
141
139
  height: size,
142
140
  borderRadius: size / 2
143
- }, style]} onLayout={this.onLayout} {...this.getAccessibilityInfo()}>
144
- {Colors.isTransparent(this.color) && <Image source={transparentImage} style={this.styles.transparentImage} resizeMode={'cover'} />}
141
+ }, style]} onLayout={this.onLayout} {...accessibilityInfo}>
142
+ {Colors.isTransparent(color) && <Image source={transparentImage} style={this.styles.transparentImage} resizeMode={'cover'} />}
145
143
  {unavailable ? <View style={[this.styles.unavailable, {
146
144
  backgroundColor: tintColor
147
145
  }]} /> : <Animated.Image source={Assets.icons.check} style={{
@@ -183,12 +181,12 @@ class ColorSwatch extends PureComponent {
183
181
  }
184
182
  export default asBaseComponent(ColorSwatch);
185
183
  function createStyles({
186
- color = DEFAULT_COLOR
184
+ color = Colors.grey30
187
185
  }) {
188
186
  return StyleSheet.create({
189
187
  container: {
190
188
  backgroundColor: color,
191
- borderWidth: Colors.isTransparent(color) ? undefined : 1,
189
+ borderWidth: color === 'transparent' ? undefined : 1,
192
190
  borderColor: Colors.rgba(Colors.$outlineDisabledHeavy, 0.2),
193
191
  margin: SWATCH_MARGIN,
194
192
  overflow: 'hidden'
@@ -36,7 +36,10 @@ class Switch extends Component {
36
36
  accessibilityRole: 'switch',
37
37
  accessibilityState: {
38
38
  disabled,
39
- checked: value
39
+ checked: value ? 'checked' : 'unchecked'
40
+ },
41
+ accessibilityValue: {
42
+ text: value ? '1' : '0'
40
43
  }
41
44
  };
42
45
  }
@@ -2,8 +2,9 @@ import { ViewStyle } from 'react-native';
2
2
  import { ComponentProps } from '../../testkit/new/Component.driver';
3
3
  export declare const SwitchDriver: (props: ComponentProps) => {
4
4
  getStyle: () => ViewStyle;
5
+ getAccessibilityValue: () => boolean;
5
6
  isDisabled: () => boolean;
6
- isChecked: () => any;
7
+ isChecked: () => boolean;
7
8
  press: () => void;
8
9
  hasOnPress: () => boolean;
9
10
  onPressIn: () => void;
@@ -3,11 +3,13 @@ import { usePressableDriver } from "../../testkit/new/usePressable.driver";
3
3
  export const SwitchDriver = props => {
4
4
  const driver = usePressableDriver(useComponentDriver(props));
5
5
  const getStyle = () => driver.getElement().props.style;
6
+ const getAccessibilityValue = () => driver.getElement().props.accessibilityValue?.text === '1';
6
7
  const isDisabled = () => driver.getElement().props.accessibilityState?.disabled === true;
7
- const isChecked = () => driver.getElement().props.accessibilityState?.checked;
8
+ const isChecked = () => driver.getElement().props.accessibilityValue?.text === '1';
8
9
  return {
9
10
  ...driver,
10
11
  getStyle,
12
+ getAccessibilityValue,
11
13
  isDisabled,
12
14
  isChecked
13
15
  };
@@ -159,7 +159,10 @@ const TextField = props => {
159
159
  {placeholder}
160
160
  </Text>}
161
161
  {floatingPlaceholder && <FloatingPlaceholder defaultValue={others.defaultValue} placeholder={placeholder} floatingPlaceholderStyle={_floatingPlaceholderStyle} floatingPlaceholderColor={floatingPlaceholderColor} floatOnFocus={floatOnFocus} validationMessagePosition={validationMessagePosition} extraOffset={leadingAccessoryMeasurements?.width} testID={`${props.testID}.floatingPlaceholder`} showMandatoryIndication={showMandatoryIndication} />}
162
- <Input placeholderTextColor={hidePlaceholder ? 'transparent' : placeholderTextColor} value={fieldState.value} {...others} readonly={readonly} style={inputStyle} onFocus={onFocus} onBlur={onBlur} onChangeText={onChangeText} placeholder={placeholder} hint={hint} showMandatoryIndication={showMandatoryIndication && !label} />
162
+ <Input hitSlop={{
163
+ top: 20,
164
+ bottom: 20
165
+ }} placeholderTextColor={hidePlaceholder ? 'transparent' : placeholderTextColor} value={fieldState.value} {...others} readonly={readonly} style={inputStyle} onFocus={onFocus} onBlur={onBlur} onChangeText={onChangeText} placeholder={placeholder} hint={hint} showMandatoryIndication={showMandatoryIndication && !label} />
163
166
  </View>}
164
167
  {showClearButton && <ClearButton onClear={onClear} testID={`${props.testID}.clearButton`} onChangeText={onChangeText} clearButtonStyle={clearButtonStyle} />}
165
168
  {trailingAccessory}
@@ -1,5 +1,4 @@
1
- import React, { useCallback, useState, forwardRef, useImperativeHandle, useRef } from 'react';
2
- import { AccessibilityInfo, findNodeHandle } from 'react-native';
1
+ import React, { useCallback, useState, forwardRef, useImperativeHandle } from 'react';
3
2
  import TouchableOpacity from "../../components/touchableOpacity";
4
3
  import View from "../../components/view";
5
4
  import Modal from "../../components/modal";
@@ -24,22 +23,14 @@ const ExpandableOverlay = (props, ref) => {
24
23
  ...others
25
24
  } = props;
26
25
  const [visible, setExpandableVisible] = useState(false);
27
- const containerRef = useRef(null);
28
- const focusAccessibility = useCallback(() => {
29
- const reactTag = findNodeHandle(containerRef.current);
30
- if (reactTag) {
31
- AccessibilityInfo.setAccessibilityFocus(reactTag);
32
- }
33
- }, []);
34
26
  const openExpandable = useCallback(() => {
35
27
  setExpandableVisible(true);
36
28
  onPress?.(props);
37
29
  }, [onPress, customValue]);
38
30
  const closeExpandable = useCallback(() => {
39
31
  setExpandableVisible(false);
40
- focusAccessibility();
41
32
  useDialog ? dialogProps?.onDismiss?.() : modalProps?.onDismiss?.();
42
- }, [useDialog, dialogProps?.onDismiss, modalProps?.onDismiss, focusAccessibility]);
33
+ }, [useDialog, dialogProps?.onDismiss, modalProps?.onDismiss]);
43
34
  const toggleExpandable = useCallback(() => visible ? closeExpandable() : openExpandable(), [visible, openExpandable, closeExpandable]);
44
35
  useImperativeHandle(ref, () => ({
45
36
  openExpandable,
@@ -70,7 +61,7 @@ const ExpandableOverlay = (props, ref) => {
70
61
  return useDialog ? renderDialog() : renderModal();
71
62
  }
72
63
  };
73
- return <TouchableOpacity ref={containerRef} {...others} onPress={openExpandable} disabled={disabled} testID={testID}>
64
+ return <TouchableOpacity {...others} onPress={openExpandable} disabled={disabled} testID={testID}>
74
65
  <View pointerEvents="none">{children}</View>
75
66
  {renderOverlay()}
76
67
  </TouchableOpacity>;
@@ -57,9 +57,11 @@ const Toast = props => {
57
57
  });
58
58
  const playAccessibilityFeatures = () => {
59
59
  if (visible) {
60
- if (viewRef.current && (action || message)) {
60
+ if (viewRef.current && action) {
61
61
  const reactTag = findNodeHandle(viewRef.current);
62
62
  AccessibilityInfo.setAccessibilityFocus(reactTag);
63
+ } else if (message) {
64
+ AccessibilityInfo.announceForAccessibility?.(toastPreset.accessibilityMessage);
63
65
  }
64
66
  }
65
67
  };
package/src/index.d.ts CHANGED
@@ -68,7 +68,7 @@ export { default as PanningProvider, PanningDirections, PanLocationProps, PanAmo
68
68
  export { default as PanResponderView, PanResponderViewProps } from './components/panningViews/panResponderView';
69
69
  export { default as asPanViewConsumer } from './components/panningViews/asPanViewConsumer';
70
70
  export { default as Picker, PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, RenderCustomModalProps, PickerItemsListProps, PickerMethods } from './components/picker';
71
- export { default as PieChart, type PieChartProps, PieChartSegmentProps } from './components/pieChart';
71
+ export { default as PieChart, PieChartSegmentProps } from './components/pieChart';
72
72
  export { default as ProgressBar, ProgressBarProps } from './components/progressBar';
73
73
  export { default as ProgressiveImage, ProgressiveImageProps } from './components/progressiveImage';
74
74
  export { default as RadioButton, RadioButtonProps } from './components/radioButton';
@@ -145,9 +145,6 @@ export class Colors {
145
145
  return Scheme.getScheme(schemeType)[colorKey];
146
146
  }
147
147
  getColorName(colorValue) {
148
- if (this.isTransparent(colorValue)) {
149
- return 'transparent';
150
- }
151
148
  const color = colorStringValue(colorValue);
152
149
  return ColorName.name(color)[1];
153
150
  }
File without changes