react-native-ui-lib 7.43.0 → 7.44.0-snapshot.7202
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 +2 -2
- package/src/commons/Constants.d.ts +1 -0
- package/src/commons/Constants.js +8 -4
- package/src/components/checkbox/index.d.ts +0 -1
- package/src/components/checkbox/index.js +2 -4
- package/src/components/chip/index.js +37 -14
- package/src/components/expandableSection/index.js +3 -2
- package/src/components/pageControl/index.js +6 -1
- package/src/components/radioButton/index.js +6 -8
- package/src/incubator/dialog/index.js +1 -1
- package/src/style/colors.d.ts +3 -5
- package/src/style/designTokens.js +7 -4
- package/src/utils/styleUtils.d.ts +1 -0
- package/src/utils/styleUtils.js +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-ui-lib",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.44.0-snapshot.7202",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"types": "src/index.d.ts",
|
|
6
6
|
"author": "Ethan Sharabi <ethan.shar@gmail.com>",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@babel/plugin-transform-modules-commonjs": "^7.17.9",
|
|
67
67
|
"@babel/preset-env": "^7.20.0",
|
|
68
68
|
"@babel/preset-react": "^7.10.1",
|
|
69
|
-
"@babel/runtime": "^7.
|
|
69
|
+
"@babel/runtime": "^7.26.10",
|
|
70
70
|
"@formatjs/intl-datetimeformat": "^6.0.3",
|
|
71
71
|
"@formatjs/intl-getcanonicallocales": "^2.0.2",
|
|
72
72
|
"@formatjs/intl-locale": "^3.0.3",
|
|
@@ -43,6 +43,7 @@ declare const constants: {
|
|
|
43
43
|
addDimensionsEventListener: (callback: any) => import("react-native").EmitterSubscription;
|
|
44
44
|
removeDimensionsEventListener: (callback: any) => void;
|
|
45
45
|
readonly accessibility: {
|
|
46
|
+
isReduceMotionEnabled: boolean;
|
|
46
47
|
isScreenReaderEnabled: boolean;
|
|
47
48
|
};
|
|
48
49
|
backspaceKey: string;
|
package/src/commons/Constants.js
CHANGED
|
@@ -44,16 +44,20 @@ export function updateConstants(dimensions) {
|
|
|
44
44
|
setStatusBarHeight();
|
|
45
45
|
}
|
|
46
46
|
const accessibility = {
|
|
47
|
+
isReduceMotionEnabled: false,
|
|
47
48
|
isScreenReaderEnabled: false
|
|
48
49
|
};
|
|
50
|
+
function handleReduceMotionChanged(isReduceMotionEnabled) {
|
|
51
|
+
accessibility.isReduceMotionEnabled = isReduceMotionEnabled;
|
|
52
|
+
}
|
|
49
53
|
function handleScreenReaderChanged(isScreenReaderEnabled) {
|
|
50
54
|
accessibility.isScreenReaderEnabled = isScreenReaderEnabled;
|
|
51
55
|
}
|
|
56
|
+
AccessibilityInfo.addEventListener('reduceMotionChanged', handleReduceMotionChanged);
|
|
52
57
|
AccessibilityInfo.addEventListener('screenReaderChanged', handleScreenReaderChanged);
|
|
53
|
-
function setAccessibility() {
|
|
54
|
-
AccessibilityInfo.
|
|
55
|
-
|
|
56
|
-
});
|
|
58
|
+
async function setAccessibility() {
|
|
59
|
+
accessibility.isReduceMotionEnabled = await AccessibilityInfo.isReduceMotionEnabled();
|
|
60
|
+
accessibility.isScreenReaderEnabled = await AccessibilityInfo.isScreenReaderEnabled();
|
|
57
61
|
}
|
|
58
62
|
setAccessibility();
|
|
59
63
|
const constants = {
|
|
@@ -120,7 +120,6 @@ declare class Checkbox extends Component<CheckboxProps, CheckboxState> {
|
|
|
120
120
|
getLabelStyle: () => {
|
|
121
121
|
color: string;
|
|
122
122
|
};
|
|
123
|
-
getAccessibleHitSlop(size: number): number;
|
|
124
123
|
renderCheckbox(): React.JSX.Element;
|
|
125
124
|
render(): React.JSX.Element;
|
|
126
125
|
validate: () => boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import { Animated, Easing, StyleSheet } from 'react-native';
|
|
3
3
|
import { Colors, Spacings } from "../../style";
|
|
4
|
+
import { StyleUtils } from "../../utils";
|
|
4
5
|
//@ts-ignore
|
|
5
6
|
import Assets from "../../assets";
|
|
6
7
|
import { asBaseComponent } from "../../commons/new";
|
|
@@ -146,9 +147,6 @@ class Checkbox extends Component {
|
|
|
146
147
|
color: this.props.disabled ? Colors.$textDisabled : this.state.showError ? Colors.$textDangerLight : Colors.$textDefault
|
|
147
148
|
};
|
|
148
149
|
};
|
|
149
|
-
getAccessibleHitSlop(size) {
|
|
150
|
-
return Math.max(0, (48 - size) / 2);
|
|
151
|
-
}
|
|
152
150
|
renderCheckbox() {
|
|
153
151
|
const {
|
|
154
152
|
selectedIcon,
|
|
@@ -161,7 +159,7 @@ class Checkbox extends Component {
|
|
|
161
159
|
} = this.props;
|
|
162
160
|
return (
|
|
163
161
|
//@ts-ignore
|
|
164
|
-
<TouchableOpacity {...this.getAccessibilityProps()} activeOpacity={1} testID={testID} {...others} style={[this.getBorderStyle(), style, !label && containerStyle]} onPress={this.onPress} hitSlop={
|
|
162
|
+
<TouchableOpacity {...this.getAccessibilityProps()} activeOpacity={1} testID={testID} {...others} style={[this.getBorderStyle(), style, !label && containerStyle]} onPress={this.onPress} hitSlop={StyleUtils.getAccessibleHitSlop(this.props.size || DEFAULT_SIZE)}>
|
|
165
163
|
{<Animated.View style={[this.styles.container, {
|
|
166
164
|
opacity: this.animationStyle.opacity
|
|
167
165
|
}, {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, { useCallback } from 'react';
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
3
2
|
import { StyleSheet } from 'react-native';
|
|
4
3
|
import Assets from "../../assets";
|
|
5
4
|
import { asBaseComponent } from "../../commons/new";
|
|
@@ -57,8 +56,8 @@ const Chip = ({
|
|
|
57
56
|
}, [badgeProps]);
|
|
58
57
|
const renderOnDismiss = useCallback(() => {
|
|
59
58
|
return <TouchableOpacity style={[getMargins('dismiss'), dismissContainerStyle]} onPress={onDismiss} hitSlop={{
|
|
60
|
-
top:
|
|
61
|
-
bottom:
|
|
59
|
+
top: 16,
|
|
60
|
+
bottom: 16,
|
|
62
61
|
left: 10,
|
|
63
62
|
right: 10
|
|
64
63
|
}} testID={`${testID}.dismiss`}>
|
|
@@ -138,23 +137,47 @@ const Chip = ({
|
|
|
138
137
|
}
|
|
139
138
|
}
|
|
140
139
|
}, [avatarProps, badgeProps, iconSource, rightIconSource, onDismiss]);
|
|
141
|
-
const
|
|
142
|
-
const width =
|
|
143
|
-
const height =
|
|
144
|
-
return
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
} : {
|
|
148
|
-
[width]: size,
|
|
149
|
-
[height]: size
|
|
140
|
+
const chipSize = useMemo(() => {
|
|
141
|
+
const width = typeof size === 'object' ? size.width : size;
|
|
142
|
+
const height = typeof size === 'object' ? size.height : size;
|
|
143
|
+
return {
|
|
144
|
+
width,
|
|
145
|
+
height
|
|
150
146
|
};
|
|
151
147
|
}, [size]);
|
|
148
|
+
const containerSizeStyle = useMemo(() => {
|
|
149
|
+
const {
|
|
150
|
+
width,
|
|
151
|
+
height
|
|
152
|
+
} = chipSize;
|
|
153
|
+
return useSizeAsMinimum ? {
|
|
154
|
+
minWidth: width,
|
|
155
|
+
minHeight: height
|
|
156
|
+
} : {
|
|
157
|
+
width,
|
|
158
|
+
height
|
|
159
|
+
};
|
|
160
|
+
}, [chipSize]);
|
|
152
161
|
const Container = onPress ? TouchableOpacity : View;
|
|
162
|
+
const hitSlop = useMemo(() => {
|
|
163
|
+
const {
|
|
164
|
+
width = 48,
|
|
165
|
+
height = 48
|
|
166
|
+
} = chipSize;
|
|
167
|
+
const verticalHitSlop = Math.max(0, (48 - height) / 2);
|
|
168
|
+
const horizontalHitSlop = Math.max(0, (48 - width) / 2);
|
|
169
|
+
return {
|
|
170
|
+
top: verticalHitSlop,
|
|
171
|
+
bottom: verticalHitSlop,
|
|
172
|
+
left: horizontalHitSlop,
|
|
173
|
+
right: horizontalHitSlop
|
|
174
|
+
};
|
|
175
|
+
}, [chipSize]);
|
|
153
176
|
return <Container activeOpacity={1} onPress={onPress} style={[styles.container, {
|
|
154
177
|
backgroundColor
|
|
155
178
|
}, {
|
|
156
179
|
borderRadius
|
|
157
|
-
}, containerStyle,
|
|
180
|
+
}, containerStyle, containerSizeStyle]} testID={testID} hitSlop={hitSlop} {...others}>
|
|
158
181
|
{avatarProps && renderAvatar()}
|
|
159
182
|
{iconSource && renderIcon('left')}
|
|
160
183
|
{leftElement}
|
|
@@ -58,12 +58,13 @@ function ExpandableSection(props) {
|
|
|
58
58
|
</View>
|
|
59
59
|
</View>;
|
|
60
60
|
};
|
|
61
|
+
const Container = onPress ? TouchableOpacity : View;
|
|
61
62
|
if (shouldShowSectionHeader) {
|
|
62
63
|
return <View style={styles.hidden}>
|
|
63
64
|
{top && renderChildren()}
|
|
64
|
-
<
|
|
65
|
+
<Container onPress={onPress} testID={testID} accessibilityState={accessibilityState}>
|
|
65
66
|
{sectionHeader}
|
|
66
|
-
</
|
|
67
|
+
</Container>
|
|
67
68
|
{!top && renderChildren()}
|
|
68
69
|
</View>;
|
|
69
70
|
} else {
|
|
@@ -5,6 +5,7 @@ import React, { PureComponent } from 'react';
|
|
|
5
5
|
import { StyleSheet, LayoutAnimation } from 'react-native';
|
|
6
6
|
import { asBaseComponent } from "../../commons/new";
|
|
7
7
|
import { Colors } from "../../style";
|
|
8
|
+
import { StyleUtils } from "../../utils";
|
|
8
9
|
import TouchableOpacity from "../touchableOpacity";
|
|
9
10
|
import View from "../view";
|
|
10
11
|
const MAX_SHOWN_PAGES = 7;
|
|
@@ -135,9 +136,13 @@ class PageControl extends PureComponent {
|
|
|
135
136
|
onPagePress,
|
|
136
137
|
spacing = PageControl.DEFAULT_SPACING
|
|
137
138
|
} = this.props;
|
|
139
|
+
const hitSlopValue = StyleUtils.getAccessibleHitSlop(size);
|
|
138
140
|
return <TouchableOpacity customValue={index} onPress={onPagePress && this.onPagePress} key={index} style={[styles.pageIndicator, {
|
|
139
141
|
marginHorizontal: spacing / 2
|
|
140
|
-
}, getColorStyle(index === currentPage, color, inactiveColor), getSizeStyle(size, index, currentPage, enlargeActive)]}
|
|
142
|
+
}, getColorStyle(index === currentPage, color, inactiveColor), getSizeStyle(size, index, currentPage, enlargeActive)]} hitSlop={{
|
|
143
|
+
top: hitSlopValue,
|
|
144
|
+
bottom: hitSlopValue
|
|
145
|
+
}} />;
|
|
141
146
|
}
|
|
142
147
|
renderDifferentSizeIndicators() {
|
|
143
148
|
const {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { PureComponent } from 'react';
|
|
2
2
|
import { StyleSheet, Animated, Easing } from 'react-native';
|
|
3
3
|
import { Colors } from "../../style";
|
|
4
|
+
import { StyleUtils } from "../../utils";
|
|
4
5
|
import { asBaseComponent, forwardRef } from "../../commons/new";
|
|
5
6
|
import TouchableOpacity from "../touchableOpacity";
|
|
6
7
|
import View from "../view";
|
|
@@ -179,13 +180,6 @@ class RadioButton extends PureComponent {
|
|
|
179
180
|
}]} />
|
|
180
181
|
</View>;
|
|
181
182
|
}
|
|
182
|
-
getAccessibleHitSlop(size) {
|
|
183
|
-
const verticalPadding = Math.max(0, (48 - size) / 2);
|
|
184
|
-
return {
|
|
185
|
-
top: verticalPadding,
|
|
186
|
-
bottom: verticalPadding
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
183
|
render() {
|
|
190
184
|
const {
|
|
191
185
|
onPress,
|
|
@@ -195,9 +189,13 @@ class RadioButton extends PureComponent {
|
|
|
195
189
|
...others
|
|
196
190
|
} = this.props;
|
|
197
191
|
const Container = onPress || onValueChange ? TouchableOpacity : View;
|
|
192
|
+
const hitSlopValue = StyleUtils.getAccessibleHitSlop(this.props.size || DEFAULT_SIZE);
|
|
198
193
|
return (
|
|
199
194
|
// @ts-ignore
|
|
200
|
-
<Container row centerV activeOpacity={1} {...others} style={containerStyle} onPress={this.onPress} {...this.getAccessibilityProps()} hitSlop={
|
|
195
|
+
<Container row centerV activeOpacity={1} {...others} style={containerStyle} onPress={this.onPress} {...this.getAccessibilityProps()} hitSlop={{
|
|
196
|
+
top: hitSlopValue,
|
|
197
|
+
bottom: hitSlopValue
|
|
198
|
+
}}>
|
|
201
199
|
{!contentOnLeft && this.renderButton()}
|
|
202
200
|
{this.props.iconOnRight ? this.renderLabel() : this.renderIcon()}
|
|
203
201
|
{this.props.iconOnRight ? this.renderIcon() : this.renderLabel()}
|
|
@@ -183,7 +183,7 @@ const Dialog = (props, ref) => {
|
|
|
183
183
|
dismiss: close
|
|
184
184
|
}));
|
|
185
185
|
const renderDialog = () => <GestureDetector gesture={panGesture}>
|
|
186
|
-
<View {...containerProps} reanimated style={style} onLayout={onLayout} ref={setRef} testID={testID}>
|
|
186
|
+
<View {...containerProps} reanimated={!Constants.accessibility.isReduceMotionEnabled} style={style} onLayout={onLayout} ref={setRef} testID={testID}>
|
|
187
187
|
{renderDialogContent()}
|
|
188
188
|
</View>
|
|
189
189
|
</GestureDetector>;
|
package/src/style/colors.d.ts
CHANGED
|
@@ -253,14 +253,12 @@ declare const colorObject: Colors & {
|
|
|
253
253
|
$iconDisabled: string;
|
|
254
254
|
$outlineDefault: string;
|
|
255
255
|
$outlineDisabled: string;
|
|
256
|
-
/**
|
|
257
|
-
* Load light and dark schemes based on generated design tokens
|
|
258
|
-
* @param color - palette color
|
|
259
|
-
*/
|
|
260
256
|
$outlineDisabledHeavy: string;
|
|
261
257
|
$outlineNeutral: string;
|
|
262
258
|
$outlineNeutralHeavy: string;
|
|
263
|
-
$outlinePrimary: string;
|
|
259
|
+
$outlinePrimary: string; /**
|
|
260
|
+
* Get app's current color scheme
|
|
261
|
+
*/
|
|
264
262
|
$outlinePrimaryMedium: string;
|
|
265
263
|
$outlineGeneral: string;
|
|
266
264
|
$outlineWarning: string;
|
|
@@ -21,7 +21,8 @@ export default {
|
|
|
21
21
|
$backgroundWarningLight: colorsPalette.yellow70,
|
|
22
22
|
$backgroundMajorLight: colorsPalette.orange80,
|
|
23
23
|
$backgroundMajorHeavy: colorsPalette.orange30,
|
|
24
|
-
|
|
24
|
+
//backgroundDangerHeavy should be changed to backgroundDanger
|
|
25
|
+
$backgroundDangerHeavy: colorsPalette.red10,
|
|
25
26
|
$backgroundDangerLight: colorsPalette.red80,
|
|
26
27
|
$backgroundDisabled: colorsPalette.grey50,
|
|
27
28
|
$backgroundDark: colorsPalette.grey10,
|
|
@@ -41,7 +42,8 @@ export default {
|
|
|
41
42
|
$textSuccessLight: colorsPalette.green30,
|
|
42
43
|
$textMajor: colorsPalette.orange10,
|
|
43
44
|
$textDanger: colorsPalette.red10,
|
|
44
|
-
|
|
45
|
+
//textDangerLight should be deprecated
|
|
46
|
+
$textDangerLight: colorsPalette.red10,
|
|
45
47
|
// ICON
|
|
46
48
|
$iconDefault: colorsPalette.grey10,
|
|
47
49
|
$iconNeutral: colorsPalette.grey20,
|
|
@@ -54,7 +56,8 @@ export default {
|
|
|
54
56
|
$iconSuccessLight: colorsPalette.green30,
|
|
55
57
|
$iconMajor: colorsPalette.orange10,
|
|
56
58
|
$iconDanger: colorsPalette.red10,
|
|
57
|
-
|
|
59
|
+
//iconDangerLight should be deprecated
|
|
60
|
+
$iconDangerLight: colorsPalette.red10,
|
|
58
61
|
$iconDisabled: colorsPalette.grey50,
|
|
59
62
|
// OUTLINE
|
|
60
63
|
$outlineDefault: colorsPalette.grey60,
|
|
@@ -66,7 +69,7 @@ export default {
|
|
|
66
69
|
$outlinePrimaryMedium: colorsPalette.blue70,
|
|
67
70
|
$outlineGeneral: colorsPalette.blue30,
|
|
68
71
|
$outlineWarning: colorsPalette.yellow30,
|
|
69
|
-
$outlineDanger: colorsPalette.
|
|
72
|
+
$outlineDanger: colorsPalette.red10,
|
|
70
73
|
$outlineInverted: colorsPalette.white,
|
|
71
74
|
// BLACK AND WHITE
|
|
72
75
|
$black: colorsPalette.black,
|
package/src/utils/styleUtils.js
CHANGED