react-native-ui-lib 7.36.0 → 7.37.0-snapshot.6102
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/README.md +7 -0
- package/package.json +2 -2
- package/src/components/floatingButton/index.js +0 -1
- package/src/components/hint/Hint.driver.new.d.ts +19 -0
- package/src/components/hint/Hint.driver.new.js +19 -0
- package/src/components/hint/HintAnchor.d.ts +13 -0
- package/src/components/hint/HintAnchor.js +47 -0
- package/src/components/hint/HintBubble.d.ts +12 -0
- package/src/components/hint/HintBubble.js +64 -0
- package/src/components/hint/HintMockChildren.d.ts +8 -0
- package/src/components/hint/HintMockChildren.js +49 -0
- package/src/components/hint/HintOld.d.ts +196 -0
- package/src/components/hint/HintOld.js +549 -0
- package/src/components/hint/hooks/useHintAccessibility.d.ts +10 -0
- package/src/components/hint/hooks/useHintAccessibility.js +26 -0
- package/src/components/hint/hooks/useHintLayout.d.ts +13 -0
- package/src/components/hint/hooks/useHintLayout.js +66 -0
- package/src/components/hint/hooks/useHintPosition.d.ts +29 -0
- package/src/components/hint/hooks/useHintPosition.js +119 -0
- package/src/components/hint/hooks/useHintVisibility.d.ts +6 -0
- package/src/components/hint/hooks/useHintVisibility.js +26 -0
- package/src/components/hint/index.d.ts +17 -186
- package/src/components/hint/index.js +150 -403
- package/src/components/hint/types.d.ts +106 -0
- package/src/components/hint/types.js +11 -0
- package/src/components/picker/PickerItemsList.js +12 -3
- package/src/components/view/View.driver.new.js +2 -1
- package/src/incubator/expandableOverlay/index.d.ts +1 -0
- package/src/incubator/expandableOverlay/index.js +17 -5
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { GestureResponderEvent, ImageSourcePropType, ImageStyle, LayoutRectangle, StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
3
|
+
export type PositionStyle = Pick<ViewStyle, 'top' | 'bottom' | 'left' | 'right'>;
|
|
4
|
+
export type LayoutStyle = PositionStyle & Pick<ViewStyle, 'alignItems'>;
|
|
5
|
+
export type PaddingsStyle = Pick<ViewStyle, 'paddingLeft' | 'paddingRight' | 'paddingVertical' | 'paddingHorizontal'>;
|
|
6
|
+
export type ContentType = string | ReactElement;
|
|
7
|
+
export declare enum TargetAlignments {
|
|
8
|
+
LEFT = "left",
|
|
9
|
+
RIGHT = "right",
|
|
10
|
+
CENTER = "center"
|
|
11
|
+
}
|
|
12
|
+
export declare enum HintPositions {
|
|
13
|
+
TOP = "top",
|
|
14
|
+
BOTTOM = "bottom"
|
|
15
|
+
}
|
|
16
|
+
export interface HintProps {
|
|
17
|
+
/**
|
|
18
|
+
* Control the visibility of the hint
|
|
19
|
+
*/
|
|
20
|
+
visible?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The hint background color
|
|
23
|
+
*/
|
|
24
|
+
color?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The hint message
|
|
27
|
+
*/
|
|
28
|
+
message?: ContentType | ContentType[];
|
|
29
|
+
/**
|
|
30
|
+
* The hint message custom style
|
|
31
|
+
*/
|
|
32
|
+
messageStyle?: StyleProp<TextStyle>;
|
|
33
|
+
/**
|
|
34
|
+
* Icon to show next to the hint's message
|
|
35
|
+
*/
|
|
36
|
+
icon?: ImageSourcePropType;
|
|
37
|
+
/**
|
|
38
|
+
* The icon's style
|
|
39
|
+
*/
|
|
40
|
+
iconStyle?: StyleProp<ImageStyle>;
|
|
41
|
+
/**
|
|
42
|
+
* The hint's position
|
|
43
|
+
*/
|
|
44
|
+
position?: HintPositions;
|
|
45
|
+
/**
|
|
46
|
+
* Provide custom target position instead of wrapping a child
|
|
47
|
+
*/
|
|
48
|
+
targetFrame?: LayoutRectangle;
|
|
49
|
+
/**
|
|
50
|
+
* Open the hint using a Modal component
|
|
51
|
+
*/
|
|
52
|
+
useModal?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Show side tips instead of the middle tip
|
|
55
|
+
*/
|
|
56
|
+
useSideTip?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* The hint's border radius
|
|
59
|
+
*/
|
|
60
|
+
borderRadius?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Hint margins from screen edges
|
|
63
|
+
*/
|
|
64
|
+
edgeMargins?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Hint offset from target
|
|
67
|
+
*/
|
|
68
|
+
offset?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Callback for Hint press
|
|
71
|
+
*/
|
|
72
|
+
onPress?: () => void;
|
|
73
|
+
/**
|
|
74
|
+
* Callback for the background press
|
|
75
|
+
*/
|
|
76
|
+
onBackgroundPress?: (event: GestureResponderEvent) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Color for background overlay (require onBackgroundPress)
|
|
79
|
+
*/
|
|
80
|
+
backdropColor?: string;
|
|
81
|
+
/**
|
|
82
|
+
* The hint container width
|
|
83
|
+
*/
|
|
84
|
+
containerWidth?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Custom content element to render inside the hint container
|
|
87
|
+
*/
|
|
88
|
+
customContent?: JSX.Element;
|
|
89
|
+
/**
|
|
90
|
+
* Remove all hint's paddings
|
|
91
|
+
*/
|
|
92
|
+
removePaddings?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Enable shadow (for hint with white background only)
|
|
95
|
+
*/
|
|
96
|
+
enableShadow?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* The hint's test identifier
|
|
99
|
+
*/
|
|
100
|
+
testID?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Additional styling
|
|
103
|
+
*/
|
|
104
|
+
style?: StyleProp<ViewStyle>;
|
|
105
|
+
children?: React.ReactNode;
|
|
106
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export let TargetAlignments = /*#__PURE__*/function (TargetAlignments) {
|
|
2
|
+
TargetAlignments["LEFT"] = "left";
|
|
3
|
+
TargetAlignments["RIGHT"] = "right";
|
|
4
|
+
TargetAlignments["CENTER"] = "center";
|
|
5
|
+
return TargetAlignments;
|
|
6
|
+
}({});
|
|
7
|
+
export let HintPositions = /*#__PURE__*/function (HintPositions) {
|
|
8
|
+
HintPositions["TOP"] = "top";
|
|
9
|
+
HintPositions["BOTTOM"] = "bottom";
|
|
10
|
+
return HintPositions;
|
|
11
|
+
}({});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _times from "lodash/times";
|
|
2
2
|
import _throttle from "lodash/throttle";
|
|
3
3
|
import _isFunction from "lodash/isFunction";
|
|
4
|
-
import React, { useCallback, useContext, useState } from 'react';
|
|
4
|
+
import React, { useCallback, useContext, useMemo, useState } from 'react';
|
|
5
5
|
import { StyleSheet, FlatList, TextInput, ActivityIndicator } from 'react-native';
|
|
6
6
|
import { Typography, Colors } from "../../style";
|
|
7
7
|
import Assets from "../../assets";
|
|
@@ -66,13 +66,19 @@ const PickerItemsList = props => {
|
|
|
66
66
|
}) => {
|
|
67
67
|
return <PickerItem {...item} />;
|
|
68
68
|
}, []);
|
|
69
|
+
const _listProps = useMemo(() => {
|
|
70
|
+
return {
|
|
71
|
+
...listProps,
|
|
72
|
+
style: [styles.list, listProps?.style]
|
|
73
|
+
};
|
|
74
|
+
}, [listProps]);
|
|
69
75
|
const renderList = () => {
|
|
70
76
|
if (items) {
|
|
71
|
-
return <FlatList testID={`${testID}.list`} data={items} renderItem={renderPropItems} keyExtractor={keyExtractor} {...
|
|
77
|
+
return <FlatList testID={`${testID}.list`} data={items} renderItem={renderPropItems} keyExtractor={keyExtractor} {..._listProps} />;
|
|
72
78
|
}
|
|
73
79
|
return <FlatList data={_times(React.Children.count(children))}
|
|
74
80
|
// @ts-expect-error
|
|
75
|
-
renderItem={renderItem} keyExtractor={keyExtractor} testID={`${testID}.list`} {...
|
|
81
|
+
renderItem={renderItem} keyExtractor={keyExtractor} testID={`${testID}.list`} {..._listProps} />;
|
|
76
82
|
};
|
|
77
83
|
const renderCancel = () => {
|
|
78
84
|
const {
|
|
@@ -158,6 +164,9 @@ const styles = StyleSheet.create({
|
|
|
158
164
|
paddingRight: 16,
|
|
159
165
|
flex: 1,
|
|
160
166
|
...Typography.text70
|
|
167
|
+
},
|
|
168
|
+
list: {
|
|
169
|
+
height: '100%'
|
|
161
170
|
}
|
|
162
171
|
});
|
|
163
172
|
export default PickerItemsList;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
1
2
|
import { useComponentDriver } from "../../testkit/new/Component.driver";
|
|
2
3
|
export const ViewDriver = props => {
|
|
3
4
|
const driver = useComponentDriver(props);
|
|
4
5
|
const getStyle = () => {
|
|
5
|
-
return driver.getElement().props.style;
|
|
6
|
+
return StyleSheet.flatten(driver.getElement().props.style);
|
|
6
7
|
};
|
|
7
8
|
return {
|
|
8
9
|
...driver,
|
|
@@ -6,6 +6,7 @@ export interface ExpandableOverlayMethods {
|
|
|
6
6
|
openExpandable: () => void;
|
|
7
7
|
closeExpandable: () => void;
|
|
8
8
|
toggleExpandable: () => void;
|
|
9
|
+
focusAccessibility: () => void;
|
|
9
10
|
}
|
|
10
11
|
export interface RenderCustomOverlayProps extends ExpandableOverlayMethods {
|
|
11
12
|
visible: boolean;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React, { useCallback, useState, forwardRef, useImperativeHandle } from 'react';
|
|
1
|
+
import React, { useCallback, useState, forwardRef, useImperativeHandle, useRef } from 'react';
|
|
2
2
|
import TouchableOpacity from "../../components/touchableOpacity";
|
|
3
3
|
import View from "../../components/view";
|
|
4
4
|
import Modal from "../../components/modal";
|
|
5
5
|
import DialogOld from "../../components/dialog";
|
|
6
6
|
import DialogNew from "../dialog";
|
|
7
7
|
import { Colors } from "../../style";
|
|
8
|
+
import { AccessibilityInfo, findNodeHandle } from 'react-native';
|
|
8
9
|
const ExpandableOverlay = (props, ref) => {
|
|
9
10
|
const {
|
|
10
11
|
children,
|
|
@@ -23,19 +24,29 @@ 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
|
+
console.log(`Nitzan - focs reac`, reactTag);
|
|
31
|
+
if (reactTag) {
|
|
32
|
+
AccessibilityInfo.setAccessibilityFocus(reactTag);
|
|
33
|
+
}
|
|
34
|
+
}, [containerRef]);
|
|
26
35
|
const openExpandable = useCallback(() => {
|
|
27
36
|
setExpandableVisible(true);
|
|
28
37
|
onPress?.(props);
|
|
29
38
|
}, [onPress, customValue]);
|
|
30
39
|
const closeExpandable = useCallback(() => {
|
|
31
40
|
setExpandableVisible(false);
|
|
41
|
+
focusAccessibility();
|
|
32
42
|
useDialog ? dialogProps?.onDismiss?.() : modalProps?.onDismiss?.();
|
|
33
|
-
}, [useDialog, dialogProps?.onDismiss, modalProps?.onDismiss]);
|
|
43
|
+
}, [useDialog, dialogProps?.onDismiss, modalProps?.onDismiss, focusAccessibility]);
|
|
34
44
|
const toggleExpandable = useCallback(() => visible ? closeExpandable() : openExpandable(), [visible, openExpandable, closeExpandable]);
|
|
35
45
|
useImperativeHandle(ref, () => ({
|
|
36
46
|
openExpandable,
|
|
37
47
|
closeExpandable,
|
|
38
|
-
toggleExpandable
|
|
48
|
+
toggleExpandable,
|
|
49
|
+
focusAccessibility
|
|
39
50
|
}));
|
|
40
51
|
const renderModal = () => {
|
|
41
52
|
return <Modal testID={`${testID}.overlay`} overlayBackgroundColor={Colors.$backgroundDefault} {...modalProps} visible={visible} onDismiss={closeExpandable} onRequestClose={closeExpandable} onBackgroundPress={closeExpandable}>
|
|
@@ -55,13 +66,14 @@ const ExpandableOverlay = (props, ref) => {
|
|
|
55
66
|
visible,
|
|
56
67
|
openExpandable,
|
|
57
68
|
closeExpandable,
|
|
58
|
-
toggleExpandable
|
|
69
|
+
toggleExpandable,
|
|
70
|
+
focusAccessibility
|
|
59
71
|
});
|
|
60
72
|
} else {
|
|
61
73
|
return useDialog ? renderDialog() : renderModal();
|
|
62
74
|
}
|
|
63
75
|
};
|
|
64
|
-
return <TouchableOpacity {...others} onPress={openExpandable} disabled={disabled} testID={testID}>
|
|
76
|
+
return <TouchableOpacity ref={containerRef} {...others} onPress={openExpandable} disabled={disabled} testID={testID}>
|
|
65
77
|
<View pointerEvents="none">{children}</View>
|
|
66
78
|
{renderOverlay()}
|
|
67
79
|
</TouchableOpacity>;
|