react-native-ui-lib 7.37.0-snapshot.6100 → 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.
Files changed (28) hide show
  1. package/package.json +1 -1
  2. package/src/components/hint/Hint.driver.new.d.ts +19 -0
  3. package/src/components/hint/Hint.driver.new.js +19 -0
  4. package/src/components/hint/HintAnchor.d.ts +13 -0
  5. package/src/components/hint/HintAnchor.js +47 -0
  6. package/src/components/hint/HintBubble.d.ts +12 -0
  7. package/src/components/hint/HintBubble.js +64 -0
  8. package/src/components/hint/HintMockChildren.d.ts +8 -0
  9. package/src/components/hint/HintMockChildren.js +49 -0
  10. package/src/components/hint/HintOld.d.ts +196 -0
  11. package/src/components/hint/HintOld.js +549 -0
  12. package/src/components/hint/hooks/useHintAccessibility.d.ts +10 -0
  13. package/src/components/hint/hooks/useHintAccessibility.js +26 -0
  14. package/src/components/hint/hooks/useHintLayout.d.ts +13 -0
  15. package/src/components/hint/hooks/useHintLayout.js +66 -0
  16. package/src/components/hint/hooks/useHintPosition.d.ts +29 -0
  17. package/src/components/hint/hooks/useHintPosition.js +119 -0
  18. package/src/components/hint/hooks/useHintVisibility.d.ts +6 -0
  19. package/src/components/hint/hooks/useHintVisibility.js +26 -0
  20. package/src/components/hint/index.d.ts +17 -186
  21. package/src/components/hint/index.js +150 -403
  22. package/src/components/hint/types.d.ts +106 -0
  23. package/src/components/hint/types.js +11 -0
  24. package/src/components/tabController/TabBar.js +1 -2
  25. package/src/components/tabController/TabBarItem.js +1 -1
  26. package/src/components/view/View.driver.new.js +2 -1
  27. package/src/incubator/expandableOverlay/index.d.ts +1 -0
  28. package/src/incubator/expandableOverlay/index.js +17 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ui-lib",
3
- "version": "7.37.0-snapshot.6100",
3
+ "version": "7.37.0-snapshot.6102",
4
4
  "main": "src/index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
@@ -0,0 +1,19 @@
1
+ import { ComponentProps } from '../../testkit/new/Component.driver';
2
+ export declare const HintDriver: (props: ComponentProps) => {
3
+ getHintBubble: () => {
4
+ getStyle: () => any;
5
+ getElement: () => import("react-test-renderer").ReactTestInstance;
6
+ queryElement: () => import("react-test-renderer").ReactTestInstance | undefined;
7
+ exists: () => boolean;
8
+ };
9
+ getModal: () => {
10
+ isVisible: () => boolean;
11
+ pressOnBackground: () => void;
12
+ getElement: () => import("react-test-renderer").ReactTestInstance;
13
+ queryElement: () => import("react-test-renderer").ReactTestInstance | undefined;
14
+ exists: () => boolean;
15
+ };
16
+ getElement: () => import("react-test-renderer").ReactTestInstance;
17
+ queryElement: () => import("react-test-renderer").ReactTestInstance | undefined;
18
+ exists: () => boolean;
19
+ };
@@ -0,0 +1,19 @@
1
+ import { useComponentDriver } from "../../testkit/new/Component.driver";
2
+ import { ModalDriver } from "../modal/Modal.driver.new";
3
+ import { ViewDriver } from "../view/View.driver.new";
4
+ export const HintDriver = props => {
5
+ const driver = useComponentDriver(props);
6
+ const hintBubbleDriver = ViewDriver({
7
+ renderTree: props.renderTree,
8
+ testID: `${props.testID}.message`
9
+ });
10
+ const modalDriver = ModalDriver({
11
+ renderTree: props.renderTree,
12
+ testID: `${props.testID}.message`
13
+ });
14
+ return {
15
+ ...driver,
16
+ getHintBubble: () => hintBubbleDriver,
17
+ getModal: () => modalDriver
18
+ };
19
+ };
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { type LayoutRectangle } from 'react-native';
3
+ import { LayoutStyle, HintProps, PaddingsStyle } from './types';
4
+ interface HintAnchorProps extends HintProps {
5
+ showHint: boolean;
6
+ isUsingModal: boolean;
7
+ targetLayout?: LayoutRectangle;
8
+ hintContainerLayout: LayoutStyle;
9
+ hintPadding: PaddingsStyle;
10
+ hintAnimatedStyle: any;
11
+ }
12
+ export default function HintAnchor({ children, showHint, isUsingModal, targetLayout, containerWidth, testID, hintContainerLayout, hintPadding, hintAnimatedStyle, style, ...others }: HintAnchorProps): React.JSX.Element;
13
+ export {};
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import { StyleSheet } from 'react-native';
3
+ import View from "../view";
4
+ export default function HintAnchor({
5
+ children,
6
+ showHint,
7
+ isUsingModal,
8
+ targetLayout,
9
+ containerWidth,
10
+ testID,
11
+ hintContainerLayout,
12
+ hintPadding,
13
+ hintAnimatedStyle,
14
+ style,
15
+ ...others
16
+ }) {
17
+ const renderHintContainer = () => {
18
+ if (showHint) {
19
+ return <View animated style={[{
20
+ width: containerWidth
21
+ }, styles.animatedContainer, hintContainerLayout, hintPadding, hintAnimatedStyle]} pointerEvents="box-none" testID={testID}>
22
+ {children}
23
+ </View>;
24
+ }
25
+ };
26
+ return <View {...others}
27
+ // Note: this view must be collapsable, don't pass testID or backgroundColor etc'.
28
+ collapsable testID={undefined} style={[styles.anchor, style, /* containerPosition, */
29
+ {
30
+ left: targetLayout?.x,
31
+ top: targetLayout?.y
32
+ }, !isUsingModal && styles.anchorForScreenOverlay]}>
33
+ {renderHintContainer()}
34
+ </View>;
35
+ }
36
+ const styles = StyleSheet.create({
37
+ anchor: {
38
+ position: 'absolute'
39
+ },
40
+ anchorForScreenOverlay: {
41
+ zIndex: 10,
42
+ elevation: 10
43
+ },
44
+ animatedContainer: {
45
+ position: 'absolute'
46
+ }
47
+ });
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { View as RNView, LayoutChangeEvent } from 'react-native';
3
+ import { HintProps } from './types';
4
+ interface HintBubbleProps extends Pick<HintProps, 'testID' | 'visible' | 'message' | 'messageStyle' | 'color' | 'removePaddings' | 'enableShadow' | 'borderRadius' | 'iconStyle' | 'icon' | 'customContent'> {
5
+ hintRef: React.RefObject<RNView>;
6
+ setHintLayout: (layoutChangeEvent: LayoutChangeEvent) => void;
7
+ hintPositionStyle: {
8
+ left: number;
9
+ };
10
+ }
11
+ export default function HintBubble({ visible, message, messageStyle, icon, iconStyle, borderRadius, removePaddings, enableShadow, color, customContent, testID, hintRef, hintPositionStyle, setHintLayout }: HintBubbleProps): React.JSX.Element;
12
+ export {};
@@ -0,0 +1,64 @@
1
+ import _isUndefined from "lodash/isUndefined";
2
+ import React from 'react';
3
+ import { StyleSheet } from 'react-native';
4
+ import { Constants } from "../../commons/new";
5
+ import { BorderRadiuses, Colors, Shadows, Spacings, Typography } from "../../style";
6
+ import View from "../view";
7
+ import Text from "../text";
8
+ import Image from "../image";
9
+ const DEFAULT_COLOR = Colors.$backgroundPrimaryHeavy;
10
+ // const HINT_MIN_WIDTH = 68;
11
+
12
+ export default function HintBubble({
13
+ visible,
14
+ message,
15
+ messageStyle,
16
+ icon,
17
+ iconStyle,
18
+ borderRadius,
19
+ removePaddings,
20
+ enableShadow,
21
+ color,
22
+ customContent,
23
+ testID,
24
+ hintRef,
25
+ hintPositionStyle,
26
+ setHintLayout
27
+ }) {
28
+ return <View testID={`${testID}.message`} row centerV style={[styles.hint, !removePaddings && styles.hintPaddings, visible && enableShadow && styles.containerShadow, {
29
+ backgroundColor: color
30
+ }, !_isUndefined(borderRadius) && {
31
+ borderRadius
32
+ }, hintPositionStyle]} onLayout={setHintLayout} ref={hintRef}>
33
+ {customContent}
34
+ {!customContent && icon && <Image source={icon} style={[styles.icon, iconStyle]} />}
35
+ {!customContent && <Text recorderTag={'unmask'} style={[styles.hintMessage, messageStyle]} testID={`${testID}.message.text`}>
36
+ {message}
37
+ </Text>}
38
+ </View>;
39
+ }
40
+ const styles = StyleSheet.create({
41
+ hint: {
42
+ // minWidth: HINT_MIN_WIDTH,
43
+ maxWidth: Math.min(Constants.windowWidth - 2 * Spacings.s4, 400),
44
+ borderRadius: BorderRadiuses.br60,
45
+ backgroundColor: DEFAULT_COLOR
46
+ },
47
+ hintPaddings: {
48
+ paddingHorizontal: Spacings.s5,
49
+ paddingTop: Spacings.s3,
50
+ paddingBottom: Spacings.s4
51
+ },
52
+ containerShadow: {
53
+ ...Shadows.sh30.bottom
54
+ },
55
+ hintMessage: {
56
+ ...Typography.text70,
57
+ color: Colors.white,
58
+ flexShrink: 1
59
+ },
60
+ icon: {
61
+ marginRight: Spacings.s4,
62
+ tintColor: Colors.white
63
+ }
64
+ });
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { LayoutRectangle } from 'react-native';
3
+ import { HintProps } from './types';
4
+ interface HintMockChildrenProps extends Pick<HintProps, 'children' | 'backdropColor'> {
5
+ targetLayout?: LayoutRectangle;
6
+ }
7
+ export default function HintMockChildren({ children, backdropColor, targetLayout }: HintMockChildrenProps): React.JSX.Element | null;
8
+ export {};
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import { StyleSheet } from 'react-native';
3
+ import { Constants } from "../../commons/new";
4
+ import View from "../view";
5
+ export default function HintMockChildren({
6
+ children,
7
+ backdropColor,
8
+ targetLayout
9
+ }) {
10
+ const isBackdropColorPassed = backdropColor !== undefined;
11
+ if (children && React.isValidElement(children)) {
12
+ const layout = {
13
+ width: targetLayout?.width,
14
+ height: targetLayout?.height,
15
+ right: Constants.isRTL ? targetLayout?.x : undefined,
16
+ top: targetLayout?.y,
17
+ left: Constants.isRTL ? undefined : targetLayout?.x
18
+ };
19
+ return <View style={[styles.mockChildrenContainer, layout, !isBackdropColorPassed && styles.hidden]}>
20
+ {React.cloneElement(children, {
21
+ collapsable: false,
22
+ key: 'mock',
23
+ style: [children.props.style, styles.mockChildren]
24
+ })}
25
+ </View>;
26
+ }
27
+ return null;
28
+ }
29
+ const styles = StyleSheet.create({
30
+ hidden: {
31
+ opacity: 0
32
+ },
33
+ mockChildrenContainer: {
34
+ position: 'absolute'
35
+ },
36
+ mockChildren: {
37
+ margin: undefined,
38
+ marginVertical: undefined,
39
+ marginHorizontal: undefined,
40
+ marginTop: undefined,
41
+ marginRight: undefined,
42
+ marginBottom: undefined,
43
+ marginLeft: undefined,
44
+ top: undefined,
45
+ left: undefined,
46
+ right: undefined,
47
+ bottom: undefined
48
+ }
49
+ });
@@ -0,0 +1,196 @@
1
+ import React, { Component, ReactElement, ElementRef } from 'react';
2
+ import { Animated, GestureResponderEvent, ImageSourcePropType, ImageStyle, StyleProp, TextStyle, ViewStyle, LayoutChangeEvent, View as RNView } from 'react-native';
3
+ declare enum TARGET_POSITIONS {
4
+ LEFT = "left",
5
+ RIGHT = "right",
6
+ CENTER = "center"
7
+ }
8
+ declare enum HintPositions {
9
+ TOP = "top",
10
+ BOTTOM = "bottom"
11
+ }
12
+ interface HintTargetFrame {
13
+ x?: number;
14
+ y?: number;
15
+ width?: number;
16
+ height?: number;
17
+ }
18
+ type Position = Pick<ViewStyle, 'top' | 'bottom' | 'left' | 'right'>;
19
+ type HintPositionStyle = Position & Pick<ViewStyle, 'alignItems'>;
20
+ type Paddings = Pick<ViewStyle, 'paddingLeft' | 'paddingRight' | 'paddingVertical' | 'paddingHorizontal'>;
21
+ type ContentType = string | ReactElement;
22
+ export interface HintProps {
23
+ /**
24
+ * Control the visibility of the hint
25
+ */
26
+ visible?: boolean;
27
+ /**
28
+ * The hint background color
29
+ */
30
+ color?: string;
31
+ /**
32
+ * The hint message
33
+ */
34
+ message?: ContentType | ContentType[];
35
+ /**
36
+ * The hint message custom style
37
+ */
38
+ messageStyle?: StyleProp<TextStyle>;
39
+ /**
40
+ * Icon to show next to the hint's message
41
+ */
42
+ icon?: ImageSourcePropType;
43
+ /**
44
+ * The icon's style
45
+ */
46
+ iconStyle?: StyleProp<ImageStyle>;
47
+ /**
48
+ * The hint's position
49
+ */
50
+ position?: HintPositions;
51
+ /**
52
+ * Provide custom target position instead of wrapping a child
53
+ */
54
+ targetFrame?: HintTargetFrame;
55
+ /**
56
+ * Open the hint using a Modal component
57
+ */
58
+ useModal?: boolean;
59
+ /**
60
+ * Show side tips instead of the middle tip
61
+ */
62
+ useSideTip?: boolean;
63
+ /**
64
+ * The hint's border radius
65
+ */
66
+ borderRadius?: number;
67
+ /**
68
+ * Hint margins from screen edges
69
+ */
70
+ edgeMargins?: number;
71
+ /**
72
+ * Hint offset from target
73
+ */
74
+ offset?: number;
75
+ /**
76
+ * Callback for Hint press
77
+ */
78
+ onPress?: () => void;
79
+ /**
80
+ * Callback for the background press
81
+ */
82
+ onBackgroundPress?: (event: GestureResponderEvent) => void;
83
+ /**
84
+ * Color for background overlay (require onBackgroundPress)
85
+ */
86
+ backdropColor?: string;
87
+ /**
88
+ * The hint container width
89
+ */
90
+ containerWidth?: number;
91
+ /**
92
+ * Custom content element to render inside the hint container
93
+ */
94
+ customContent?: JSX.Element;
95
+ /**
96
+ * Remove all hint's paddings
97
+ */
98
+ removePaddings?: boolean;
99
+ /**
100
+ * Enable shadow (for hint with white background only)
101
+ */
102
+ enableShadow?: boolean;
103
+ /**
104
+ * The hint's test identifier
105
+ */
106
+ testID?: string;
107
+ /**
108
+ * Additional styling
109
+ */
110
+ style?: StyleProp<ViewStyle>;
111
+ children?: React.ReactNode;
112
+ }
113
+ interface HintState {
114
+ targetLayout?: HintTargetFrame;
115
+ targetLayoutInWindow?: HintTargetFrame;
116
+ hintUnmounted: boolean;
117
+ hintMessageWidth?: number;
118
+ }
119
+ /**
120
+ * @description: Hint component for displaying a tooltip over wrapped component
121
+ * @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/HintsScreen.tsx
122
+ * @notes: You can either wrap a component or pass a specific targetFrame
123
+ * @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/Hint/Hint.gif?raw=true
124
+ */
125
+ declare class Hint extends Component<HintProps, HintState> {
126
+ static displayName: string;
127
+ static defaultProps: {
128
+ position: HintPositions;
129
+ useModal: boolean;
130
+ };
131
+ static positions: typeof HintPositions;
132
+ targetRef: ElementRef<typeof RNView> | null;
133
+ hintRef: React.RefObject<RNView>;
134
+ animationDuration: number;
135
+ state: {
136
+ targetLayoutInWindow: {
137
+ x: number;
138
+ y: number;
139
+ width: number;
140
+ height: number;
141
+ } | undefined;
142
+ targetLayout: HintTargetFrame | undefined;
143
+ hintUnmounted: boolean;
144
+ hintMessageWidth: undefined;
145
+ };
146
+ visibleAnimated: Animated.Value;
147
+ componentDidMount(): void;
148
+ componentDidUpdate(prevProps: HintProps): void;
149
+ animateHint: () => void;
150
+ toggleAnimationEndedToRemoveHint: () => void;
151
+ focusAccessibilityOnHint: () => void;
152
+ setTargetRef: (ref: ElementRef<typeof RNView>) => void;
153
+ setHintLayout: ({ nativeEvent: { layout } }: LayoutChangeEvent) => void;
154
+ onTargetLayout: ({ nativeEvent: { layout } }: LayoutChangeEvent) => void;
155
+ getAccessibilityInfo(): {
156
+ accessible: boolean;
157
+ accessibilityLabel: string;
158
+ } | undefined;
159
+ get containerWidth(): number;
160
+ get targetLayout(): HintTargetFrame | undefined;
161
+ get showHint(): boolean;
162
+ get tipSize(): {
163
+ width: number;
164
+ height: number;
165
+ };
166
+ get hintOffset(): number;
167
+ get edgeMargins(): number;
168
+ get shouldUseSideTip(): boolean;
169
+ get isShortMessage(): undefined;
170
+ getTargetPositionOnScreen(): TARGET_POSITIONS;
171
+ getContainerPosition(): {
172
+ top: number | undefined;
173
+ left: number | undefined;
174
+ } | undefined;
175
+ getHintPosition(): HintPositionStyle;
176
+ getHintPadding(): Paddings;
177
+ getHintAnimatedStyle: () => {
178
+ opacity: Animated.Value;
179
+ transform: {
180
+ translateY: Animated.AnimatedInterpolation<string | number>;
181
+ }[];
182
+ };
183
+ getTipPosition(): Position;
184
+ getHintOffsetForShortMessage: () => number;
185
+ isUsingModal: () => boolean | undefined;
186
+ renderOverlay(): React.JSX.Element | undefined;
187
+ renderHintTip(): React.JSX.Element;
188
+ renderHint(): React.JSX.Element;
189
+ renderHintContainer(): React.JSX.Element | undefined;
190
+ renderHintAnchor(): React.JSX.Element;
191
+ renderMockChildren(): React.JSX.Element | undefined;
192
+ renderChildren(): React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
193
+ render(): string | number | true | React.JSX.Element | Iterable<React.ReactNode> | null;
194
+ }
195
+ declare const _default: React.ForwardRefExoticComponent<HintProps & React.RefAttributes<any>> & typeof Hint;
196
+ export default _default;