react-native-ui-lib 7.37.2 → 7.38.0-snapshot.6232
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 +1 -1
- package/src/components/avatar/index.js +2 -1
- package/src/components/colorSwatch/index.js +14 -12
- package/src/components/switch/index.js +16 -5
- package/src/components/switch/switch.driver.d.ts +1 -2
- package/src/components/switch/switch.driver.js +1 -3
- package/src/components/tabController/TabBar.js +1 -1
- package/src/components/tabController/TabBarItem.js +12 -3
- package/src/components/textField/index.js +4 -1
- package/src/incubator/expandableOverlay/index.js +12 -3
- package/src/incubator/toast/index.js +1 -3
- package/src/index.d.ts +1 -1
- package/src/style/colors.js +3 -0
- /package/{demo.js → index.js} +0 -0
package/package.json
CHANGED
|
@@ -58,6 +58,7 @@ const Avatar = forwardRef((props, ref) => {
|
|
|
58
58
|
onPress,
|
|
59
59
|
children
|
|
60
60
|
} = themeProps;
|
|
61
|
+
const hitTargetPadding = Math.max(0, (48 - size) / 2);
|
|
61
62
|
const {
|
|
62
63
|
size: _badgeSize,
|
|
63
64
|
borderWidth: badgeBorderWidth = 0
|
|
@@ -174,7 +175,7 @@ const Avatar = forwardRef((props, ref) => {
|
|
|
174
175
|
}
|
|
175
176
|
};
|
|
176
177
|
const Container = onPress ? TouchableOpacity : View;
|
|
177
|
-
return <Container style={_containerStyle} ref={ref} testID={testID} onPress={onPress} accessible={!_isUndefined(onPress)} accessibilityLabel={'Avatar'} accessibilityRole={onPress ? 'button' : 'image'} {...accessibilityProps}>
|
|
178
|
+
return <Container style={_containerStyle} ref={ref} testID={testID} onPress={onPress} accessible={!_isUndefined(onPress)} accessibilityLabel={'Avatar'} accessibilityRole={onPress ? 'button' : 'image'} hitSlop={onPress ? hitTargetPadding : undefined} {...accessibilityProps}>
|
|
178
179
|
<View testID={`${testID}.container`} style={textContainerStyle}>
|
|
179
180
|
{!_isUndefined(text) && <Text numberOfLines={1} style={textStyle} testID={`${testID}.label`}>
|
|
180
181
|
{text}
|
|
@@ -10,6 +10,7 @@ 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;
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* @description: A color swatch component
|
|
@@ -83,9 +84,8 @@ class ColorSwatch extends PureComponent {
|
|
|
83
84
|
value,
|
|
84
85
|
index
|
|
85
86
|
} = this.props;
|
|
86
|
-
const color = this.color ?? '';
|
|
87
87
|
const tintColor = this.getTintColor(value);
|
|
88
|
-
const result = value || color;
|
|
88
|
+
const result = value || this.color || '';
|
|
89
89
|
const hexString = Colors.getHexString(result);
|
|
90
90
|
this.props.onPress?.(result, {
|
|
91
91
|
tintColor,
|
|
@@ -102,10 +102,14 @@ class ColorSwatch extends PureComponent {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
getAccessibilityInfo() {
|
|
105
|
-
const color = this.color;
|
|
105
|
+
const color = this.color || DEFAULT_COLOR;
|
|
106
|
+
const defaultText = !this.color ? 'default' : '';
|
|
106
107
|
return {
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
accessible: true,
|
|
109
|
+
accessibilityLabel: `${defaultText} color ${Colors.getColorName(color)}`,
|
|
110
|
+
accessibilityState: {
|
|
111
|
+
selected: this.props.selected
|
|
112
|
+
}
|
|
109
113
|
};
|
|
110
114
|
}
|
|
111
115
|
getLayout() {
|
|
@@ -122,13 +126,11 @@ class ColorSwatch extends PureComponent {
|
|
|
122
126
|
size = DEFAULT_SIZE,
|
|
123
127
|
...others
|
|
124
128
|
} = this.props;
|
|
125
|
-
const color = this.color;
|
|
126
129
|
const {
|
|
127
130
|
isSelected
|
|
128
131
|
} = this.state;
|
|
129
132
|
const Container = onPress ? TouchableOpacity : View;
|
|
130
|
-
const tintColor = this.getTintColor(color);
|
|
131
|
-
const accessibilityInfo = Constants.accessibility.isScreenReaderEnabled && this.getAccessibilityInfo();
|
|
133
|
+
const tintColor = this.getTintColor(this.color);
|
|
132
134
|
return <Container {...others} center activeOpacity={1} throttleTime={0} hitSlop={{
|
|
133
135
|
top: 10,
|
|
134
136
|
bottom: 10,
|
|
@@ -138,8 +140,8 @@ class ColorSwatch extends PureComponent {
|
|
|
138
140
|
width: size,
|
|
139
141
|
height: size,
|
|
140
142
|
borderRadius: size / 2
|
|
141
|
-
}, style]} onLayout={this.onLayout} {...
|
|
142
|
-
{Colors.isTransparent(color) && <Image source={transparentImage} style={this.styles.transparentImage} resizeMode={'cover'} />}
|
|
143
|
+
}, style]} onLayout={this.onLayout} {...this.getAccessibilityInfo()}>
|
|
144
|
+
{Colors.isTransparent(this.color) && <Image source={transparentImage} style={this.styles.transparentImage} resizeMode={'cover'} />}
|
|
143
145
|
{unavailable ? <View style={[this.styles.unavailable, {
|
|
144
146
|
backgroundColor: tintColor
|
|
145
147
|
}]} /> : <Animated.Image source={Assets.icons.check} style={{
|
|
@@ -181,12 +183,12 @@ class ColorSwatch extends PureComponent {
|
|
|
181
183
|
}
|
|
182
184
|
export default asBaseComponent(ColorSwatch);
|
|
183
185
|
function createStyles({
|
|
184
|
-
color =
|
|
186
|
+
color = DEFAULT_COLOR
|
|
185
187
|
}) {
|
|
186
188
|
return StyleSheet.create({
|
|
187
189
|
container: {
|
|
188
190
|
backgroundColor: color,
|
|
189
|
-
borderWidth: color
|
|
191
|
+
borderWidth: Colors.isTransparent(color) ? undefined : 1,
|
|
190
192
|
borderColor: Colors.rgba(Colors.$outlineDisabledHeavy, 0.2),
|
|
191
193
|
margin: SWATCH_MARGIN,
|
|
192
194
|
overflow: 'hidden'
|
|
@@ -36,10 +36,7 @@ class Switch extends Component {
|
|
|
36
36
|
accessibilityRole: 'switch',
|
|
37
37
|
accessibilityState: {
|
|
38
38
|
disabled,
|
|
39
|
-
checked: value
|
|
40
|
-
},
|
|
41
|
-
accessibilityValue: {
|
|
42
|
-
text: value ? '1' : '0'
|
|
39
|
+
checked: value
|
|
43
40
|
}
|
|
44
41
|
};
|
|
45
42
|
}
|
|
@@ -114,13 +111,27 @@ class Switch extends Component {
|
|
|
114
111
|
};
|
|
115
112
|
return <Animated.View style={[this.styles.thumb, thumbPositionStyle, thumbStyle]} />;
|
|
116
113
|
}
|
|
114
|
+
getAccessibleHitSlop() {
|
|
115
|
+
const {
|
|
116
|
+
width = DEFAULT_WIDTH,
|
|
117
|
+
height = DEFAULT_HEIGHT
|
|
118
|
+
} = this.props;
|
|
119
|
+
const verticalPadding = Math.max(0, (48 - height) / 2);
|
|
120
|
+
const horizontalPadding = Math.max(0, (48 - width) / 2);
|
|
121
|
+
return {
|
|
122
|
+
top: verticalPadding,
|
|
123
|
+
bottom: verticalPadding,
|
|
124
|
+
left: horizontalPadding,
|
|
125
|
+
right: horizontalPadding
|
|
126
|
+
};
|
|
127
|
+
}
|
|
117
128
|
render() {
|
|
118
129
|
const {
|
|
119
130
|
...others
|
|
120
131
|
} = this.props;
|
|
121
132
|
return (
|
|
122
133
|
// @ts-ignore
|
|
123
|
-
<TouchableOpacity {...this.getAccessibilityProps()} activeOpacity={1} {...others} style={this.getSwitchStyle()} onPress={this.onPress}>
|
|
134
|
+
<TouchableOpacity {...this.getAccessibilityProps()} activeOpacity={1} hitSlop={this.getAccessibleHitSlop()} {...others} style={this.getSwitchStyle()} onPress={this.onPress}>
|
|
124
135
|
{this.renderThumb()}
|
|
125
136
|
</TouchableOpacity>
|
|
126
137
|
);
|
|
@@ -2,9 +2,8 @@ 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;
|
|
6
5
|
isDisabled: () => boolean;
|
|
7
|
-
isChecked: () =>
|
|
6
|
+
isChecked: () => any;
|
|
8
7
|
press: () => void;
|
|
9
8
|
hasOnPress: () => boolean;
|
|
10
9
|
onPressIn: () => void;
|
|
@@ -3,13 +3,11 @@ 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';
|
|
7
6
|
const isDisabled = () => driver.getElement().props.accessibilityState?.disabled === true;
|
|
8
|
-
const isChecked = () => driver.getElement().props.
|
|
7
|
+
const isChecked = () => driver.getElement().props.accessibilityState?.checked;
|
|
9
8
|
return {
|
|
10
9
|
...driver,
|
|
11
10
|
getStyle,
|
|
12
|
-
getAccessibilityValue,
|
|
13
11
|
isDisabled,
|
|
14
12
|
isChecked
|
|
15
13
|
};
|
|
@@ -149,7 +149,7 @@ const TabBar = props => {
|
|
|
149
149
|
}, [labelColor, selectedLabelColor]);
|
|
150
150
|
return <View style={_containerStyle} key={key} bg-$backgroundElevated>
|
|
151
151
|
<FadedScrollView ref={tabBar} horizontal showsHorizontalScrollIndicator={false} showStartFader startFaderProps={faderProps} showEndFader endFaderProps={faderProps} contentContainerStyle={scrollViewContainerStyle} testID={testID} onContentSizeChange={onContentSizeChange} onLayout={onLayout}>
|
|
152
|
-
<View style={tabBarContainerStyle}>{tabBarItems}</View>
|
|
152
|
+
<View style={tabBarContainerStyle} accessibilityRole={Constants.isIOS ? 'tabbar' : 'tablist'}>{tabBarItems}</View>
|
|
153
153
|
{itemsCount > 1 && <Reanimated.View style={[styles.selectedIndicator, indicatorStyle, _indicatorTransitionStyle]} />}
|
|
154
154
|
</FadedScrollView>
|
|
155
155
|
</View>;
|
|
@@ -3,9 +3,9 @@ import _isEmpty from "lodash/isEmpty";
|
|
|
3
3
|
import _isUndefined from "lodash/isUndefined";
|
|
4
4
|
import _cloneDeep from "lodash/cloneDeep";
|
|
5
5
|
// TODO: support commented props
|
|
6
|
-
import React, { useCallback, useContext, useEffect, useRef, useMemo } from 'react';
|
|
6
|
+
import React, { useCallback, useContext, useEffect, useRef, useMemo, useState } from 'react';
|
|
7
7
|
import { StyleSheet } from 'react-native';
|
|
8
|
-
import Reanimated, { runOnJS, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
|
|
8
|
+
import Reanimated, { runOnJS, useAnimatedReaction, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
|
|
9
9
|
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
10
10
|
import { Colors, Typography, Spacings } from "../../style";
|
|
11
11
|
import Badge from "../badge";
|
|
@@ -52,6 +52,7 @@ export default function TabBarItem({
|
|
|
52
52
|
// JSON.parse(JSON.stringify is due to an issue with reanimated
|
|
53
53
|
const sharedLabelStyle = useSharedValue(JSON.parse(JSON.stringify(StyleSheet.flatten(labelStyle))));
|
|
54
54
|
const sharedSelectedLabelStyle = useSharedValue(JSON.parse(JSON.stringify(StyleSheet.flatten(selectedLabelStyle))));
|
|
55
|
+
const [isSelected, setIsSelected] = useState(currentPage.value === index);
|
|
55
56
|
|
|
56
57
|
// NOTE: We clone these color values in refs because they might contain a PlatformColor value
|
|
57
58
|
// which throws an error (see https://github.com/software-mansion/react-native-reanimated/issues/3164)
|
|
@@ -71,6 +72,11 @@ export default function TabBarItem({
|
|
|
71
72
|
}, index);
|
|
72
73
|
}
|
|
73
74
|
}, []);
|
|
75
|
+
useAnimatedReaction(() => currentPage.value === index, (isSelected, prevIsSelected) => {
|
|
76
|
+
if (isSelected !== prevIsSelected) {
|
|
77
|
+
runOnJS(setIsSelected)(isSelected);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
74
80
|
const onLayout = useCallback(event => {
|
|
75
81
|
const {
|
|
76
82
|
width
|
|
@@ -120,6 +126,9 @@ export default function TabBarItem({
|
|
|
120
126
|
flex
|
|
121
127
|
}, style, constantWidthStyle, pressStyle];
|
|
122
128
|
}, [style, spreadItems]);
|
|
129
|
+
const accessibilityState = useMemo(() => ({
|
|
130
|
+
selected: isSelected
|
|
131
|
+
}), [isSelected]);
|
|
123
132
|
const gesture = Gesture.Tap().maxDuration(60000).onEnd(() => {
|
|
124
133
|
if (!ignore) {
|
|
125
134
|
setCurrentIndex(index);
|
|
@@ -133,7 +142,7 @@ export default function TabBarItem({
|
|
|
133
142
|
return <GestureDetector gesture={gesture}>
|
|
134
143
|
<View reanimated
|
|
135
144
|
// @ts-expect-error
|
|
136
|
-
ref={itemRef} style={_style} onLayout={onLayout} testID={testID}>
|
|
145
|
+
ref={itemRef} style={_style} onLayout={onLayout} testID={testID} accessible accessibilityRole="tab" accessibilityState={accessibilityState}>
|
|
137
146
|
{leadingAccessory}
|
|
138
147
|
{icon && <Reanimated.Image source={icon} style={[!_isUndefined(label) && styles.tabItemIconWithLabel, animatedIconStyle]} />}
|
|
139
148
|
{!_isEmpty(label) && <Reanimated.Text {...labelProps} fsTagName={'unmask'} style={[styles.tabItemLabel, labelStyle, animatedLabelStyle, animatedLabelColorStyle]}>
|
|
@@ -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
|
|
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,4 +1,5 @@
|
|
|
1
|
-
import React, { useCallback, useState, forwardRef, useImperativeHandle } from 'react';
|
|
1
|
+
import React, { useCallback, useState, forwardRef, useImperativeHandle, useRef } from 'react';
|
|
2
|
+
import { AccessibilityInfo, findNodeHandle } from 'react-native';
|
|
2
3
|
import TouchableOpacity from "../../components/touchableOpacity";
|
|
3
4
|
import View from "../../components/view";
|
|
4
5
|
import Modal from "../../components/modal";
|
|
@@ -23,14 +24,22 @@ const ExpandableOverlay = (props, ref) => {
|
|
|
23
24
|
...others
|
|
24
25
|
} = props;
|
|
25
26
|
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
|
+
}, []);
|
|
26
34
|
const openExpandable = useCallback(() => {
|
|
27
35
|
setExpandableVisible(true);
|
|
28
36
|
onPress?.(props);
|
|
29
37
|
}, [onPress, customValue]);
|
|
30
38
|
const closeExpandable = useCallback(() => {
|
|
31
39
|
setExpandableVisible(false);
|
|
40
|
+
focusAccessibility();
|
|
32
41
|
useDialog ? dialogProps?.onDismiss?.() : modalProps?.onDismiss?.();
|
|
33
|
-
}, [useDialog, dialogProps?.onDismiss, modalProps?.onDismiss]);
|
|
42
|
+
}, [useDialog, dialogProps?.onDismiss, modalProps?.onDismiss, focusAccessibility]);
|
|
34
43
|
const toggleExpandable = useCallback(() => visible ? closeExpandable() : openExpandable(), [visible, openExpandable, closeExpandable]);
|
|
35
44
|
useImperativeHandle(ref, () => ({
|
|
36
45
|
openExpandable,
|
|
@@ -61,7 +70,7 @@ const ExpandableOverlay = (props, ref) => {
|
|
|
61
70
|
return useDialog ? renderDialog() : renderModal();
|
|
62
71
|
}
|
|
63
72
|
};
|
|
64
|
-
return <TouchableOpacity {...others} onPress={openExpandable} disabled={disabled} testID={testID}>
|
|
73
|
+
return <TouchableOpacity ref={containerRef} {...others} onPress={openExpandable} disabled={disabled} testID={testID}>
|
|
65
74
|
<View pointerEvents="none">{children}</View>
|
|
66
75
|
{renderOverlay()}
|
|
67
76
|
</TouchableOpacity>;
|
|
@@ -57,11 +57,9 @@ const Toast = props => {
|
|
|
57
57
|
});
|
|
58
58
|
const playAccessibilityFeatures = () => {
|
|
59
59
|
if (visible) {
|
|
60
|
-
if (viewRef.current && action) {
|
|
60
|
+
if (viewRef.current && (action || message)) {
|
|
61
61
|
const reactTag = findNodeHandle(viewRef.current);
|
|
62
62
|
AccessibilityInfo.setAccessibilityFocus(reactTag);
|
|
63
|
-
} else if (message) {
|
|
64
|
-
AccessibilityInfo.announceForAccessibility?.(toastPreset.accessibilityMessage);
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
65
|
};
|
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, PieChartSegmentProps } from './components/pieChart';
|
|
71
|
+
export { default as PieChart, type PieChartProps, 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';
|
package/src/style/colors.js
CHANGED
|
@@ -145,6 +145,9 @@ 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
|
+
}
|
|
148
151
|
const color = colorStringValue(colorValue);
|
|
149
152
|
return ColorName.name(color)[1];
|
|
150
153
|
}
|
/package/{demo.js → index.js}
RENAMED
|
File without changes
|