@hero-design/rn 8.132.0 → 8.133.0
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/CHANGELOG.md +12 -0
- package/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/es/index.js +118 -112
- package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/lib/index.js +118 -112
- package/package.json +1 -1
- package/src/components/AppCue/SpotlightBackdrop.tsx +60 -0
- package/src/components/AppCue/StyledAppCue.tsx +6 -3
- package/src/components/AppCue/index.tsx +54 -23
- package/src/components/AppCue/utils.ts +26 -76
- package/src/theme/components/appCue.ts +1 -0
- package/types/components/AppCue/SpotlightBackdrop.d.ts +12 -0
- package/types/components/AppCue/StyledAppCue.d.ts +7 -1
- package/types/components/AppCue/index.d.ts +11 -1
- package/types/components/AppCue/utils.d.ts +4 -38
- package/types/theme/components/appCue.d.ts +1 -0
|
@@ -1,24 +1,5 @@
|
|
|
1
1
|
import type { Placement } from './StyledAppCue';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Calculates the position of an element based on its placement relative to a reference position.
|
|
5
|
-
*
|
|
6
|
-
* @param {Object} params - The parameters for calculating the position.
|
|
7
|
-
* @param {Object} params.position - The position and size of target element.
|
|
8
|
-
* @param {number} params.position.pageX - The X coordinate of the target position.
|
|
9
|
-
* @param {number} params.position.pageY - The Y coordinate of the target position.
|
|
10
|
-
* @param {number} params.position.width - The width of the reference element.
|
|
11
|
-
* @param {number} params.position.height - The height of the reference element.
|
|
12
|
-
* @param {Object} params.contentSize - The size of the App Cue content.
|
|
13
|
-
* @param {number} params.contentSize.width - The width of the content.
|
|
14
|
-
* @param {number} params.contentSize.height - The height of the content.
|
|
15
|
-
* @param {Placement} params.placement - The placement of the content relative to the reference position ('top', 'bottom', 'right', 'left').
|
|
16
|
-
* @param {number} params.offset - The offset distance to display an arrow.
|
|
17
|
-
*
|
|
18
|
-
* @returns {Object} The calculated position of the App Cue.
|
|
19
|
-
* @returns {number} return.x - The X coordinate of the App Cue.
|
|
20
|
-
* @returns {number} return.y - The Y coordinate of the App Cue.
|
|
21
|
-
*/
|
|
22
3
|
export const calculatePosition = ({
|
|
23
4
|
placement,
|
|
24
5
|
position,
|
|
@@ -27,8 +8,8 @@ export const calculatePosition = ({
|
|
|
27
8
|
windowWidth,
|
|
28
9
|
}: {
|
|
29
10
|
position: {
|
|
30
|
-
|
|
31
|
-
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
32
13
|
width: number;
|
|
33
14
|
height: number;
|
|
34
15
|
};
|
|
@@ -48,86 +29,55 @@ export const calculatePosition = ({
|
|
|
48
29
|
switch (placement) {
|
|
49
30
|
case 'top': {
|
|
50
31
|
return {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// The Y coordinate is calculated by subtracting the height of the content and the offset from the Y coordinate of the target element
|
|
54
|
-
top: position.pageY - contentSize.height - offset,
|
|
32
|
+
left: position.x + (position.width - contentSize.width) / 2,
|
|
33
|
+
top: position.y - contentSize.height - offset,
|
|
55
34
|
};
|
|
56
35
|
}
|
|
57
36
|
case 'bottom': {
|
|
58
37
|
return {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// The Y coordinate is calculated by adding the height of the target element and the offset to the Y coordinate of the target element.
|
|
62
|
-
top: position.pageY + position.height + offset,
|
|
38
|
+
left: position.x + (position.width - contentSize.width) / 2,
|
|
39
|
+
top: position.y + position.height + offset,
|
|
63
40
|
};
|
|
64
41
|
}
|
|
65
42
|
case 'right': {
|
|
66
43
|
return {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// The Y coordinate is calculated by adding half of the height of the target element to the Y coordinate of the target element.
|
|
70
|
-
top: position.pageY + (position.height - contentSize.height) / 2,
|
|
44
|
+
left: position.x + position.width + offset,
|
|
45
|
+
top: position.y + (position.height - contentSize.height) / 2,
|
|
71
46
|
};
|
|
72
47
|
}
|
|
73
48
|
case 'left': {
|
|
74
49
|
return {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// The Y coordinate is calculated by adding half of the height of the target element to the Y coordinate of the target element.
|
|
78
|
-
top: position.pageY + (position.height - contentSize.height) / 2,
|
|
50
|
+
left: position.x - contentSize.width - offset,
|
|
51
|
+
top: position.y + (position.height - contentSize.height) / 2,
|
|
79
52
|
};
|
|
80
53
|
}
|
|
81
54
|
case 'top-left': {
|
|
82
55
|
return {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// The Y coordinate is calculated by subtracting the height of the content and the offset from the Y coordinate of the target element
|
|
86
|
-
top: position.pageY - contentSize.height - offset,
|
|
56
|
+
right: windowWidth - position.x - position.width,
|
|
57
|
+
top: position.y - contentSize.height - offset,
|
|
87
58
|
};
|
|
88
59
|
}
|
|
89
60
|
case 'top-right': {
|
|
90
61
|
return {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
// The Y coordinate is calculated by subtracting the height of the content and the offset from the Y coordinate of the target element.
|
|
94
|
-
top: position.pageY - contentSize.height - offset,
|
|
62
|
+
left: position.x,
|
|
63
|
+
top: position.y - contentSize.height - offset,
|
|
95
64
|
};
|
|
96
65
|
}
|
|
97
66
|
case 'bottom-left': {
|
|
98
67
|
return {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// The Y coordinate is calculated by adding the height of the target element and the offset to the Y coordinate of the target element.
|
|
102
|
-
top: position.pageY + position.height + offset,
|
|
68
|
+
right: windowWidth - position.x - position.width,
|
|
69
|
+
top: position.y + position.height + offset,
|
|
103
70
|
};
|
|
104
71
|
}
|
|
105
72
|
case 'bottom-right': {
|
|
106
73
|
return {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
// The Y coordinate is calculated by adding the height of the target element and the offset to the Y coordinate of the target element.
|
|
110
|
-
top: position.pageY + position.height + offset,
|
|
74
|
+
left: position.x,
|
|
75
|
+
top: position.y + position.height + offset,
|
|
111
76
|
};
|
|
112
77
|
}
|
|
113
78
|
}
|
|
114
79
|
};
|
|
115
80
|
|
|
116
|
-
/**
|
|
117
|
-
* Calculates the maximum width of the content based on its position, offset, placement, and window width.
|
|
118
|
-
*
|
|
119
|
-
* @param {Object} params - The parameters for the calculation.
|
|
120
|
-
* @param {Object} params.position - The position and dimensions of the target element.
|
|
121
|
-
* @param {number} params.position.pageX - The X coordinate of the target element.
|
|
122
|
-
* @param {number} params.position.pageY - The Y coordinate of the target element.
|
|
123
|
-
* @param {number} params.position.width - The width of the target element.
|
|
124
|
-
* @param {number} params.position.height - The height of the target element.
|
|
125
|
-
* @param {number} params.offset - The offset value to display an arrow.
|
|
126
|
-
* @param {Placement} params.placement - The placement of the content relative to the element.
|
|
127
|
-
* @param {number} params.windowWidth - The width of the window.
|
|
128
|
-
*
|
|
129
|
-
* @returns {number | undefined} The maximum width of the content.
|
|
130
|
-
*/
|
|
131
81
|
export const calulateContentMaxWidth = ({
|
|
132
82
|
position,
|
|
133
83
|
offset,
|
|
@@ -135,8 +85,8 @@ export const calulateContentMaxWidth = ({
|
|
|
135
85
|
windowWidth,
|
|
136
86
|
}: {
|
|
137
87
|
position: {
|
|
138
|
-
|
|
139
|
-
|
|
88
|
+
x: number;
|
|
89
|
+
y: number;
|
|
140
90
|
width: number;
|
|
141
91
|
height: number;
|
|
142
92
|
};
|
|
@@ -152,22 +102,22 @@ export const calulateContentMaxWidth = ({
|
|
|
152
102
|
return undefined;
|
|
153
103
|
}
|
|
154
104
|
case 'right': {
|
|
155
|
-
return windowWidth - position.
|
|
105
|
+
return windowWidth - position.x - position.width - offset;
|
|
156
106
|
}
|
|
157
107
|
case 'left': {
|
|
158
|
-
return position.
|
|
108
|
+
return position.x - offset;
|
|
159
109
|
}
|
|
160
110
|
case 'top-left': {
|
|
161
|
-
return position.
|
|
111
|
+
return position.x + position.width;
|
|
162
112
|
}
|
|
163
113
|
case 'top-right': {
|
|
164
|
-
return windowWidth - position.
|
|
114
|
+
return windowWidth - position.x;
|
|
165
115
|
}
|
|
166
116
|
case 'bottom-left': {
|
|
167
|
-
return position.
|
|
117
|
+
return position.x + position.width;
|
|
168
118
|
}
|
|
169
119
|
case 'bottom-right': {
|
|
170
|
-
return windowWidth - position.
|
|
120
|
+
return windowWidth - position.x;
|
|
171
121
|
}
|
|
172
122
|
}
|
|
173
123
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface SpotlightBackdropProps {
|
|
3
|
+
bounds: {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
};
|
|
9
|
+
testID?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const SpotlightBackdrop: ({ bounds, testID }: SpotlightBackdropProps) => React.JSX.Element;
|
|
12
|
+
export default SpotlightBackdrop;
|
|
@@ -6,7 +6,13 @@ export declare const StyledContent: import("@emotion/native").StyledComponent<im
|
|
|
6
6
|
}, {}, {
|
|
7
7
|
ref?: import("react").Ref<View> | undefined;
|
|
8
8
|
}>;
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const StyledModalContainer: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
|
|
10
|
+
theme?: import("@emotion/react").Theme;
|
|
11
|
+
as?: React.ElementType;
|
|
12
|
+
}, {}, {
|
|
13
|
+
ref?: import("react").Ref<View> | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const StyledContentPositioner: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
|
|
10
16
|
theme?: import("@emotion/react").Theme;
|
|
11
17
|
as?: React.ElementType;
|
|
12
18
|
}, {}, {
|
|
@@ -19,6 +19,16 @@ export interface AppCueProps {
|
|
|
19
19
|
* Testing ID of the component.
|
|
20
20
|
*/
|
|
21
21
|
testID?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Controls visibility externally. When provided, the component becomes controlled
|
|
24
|
+
* and will not toggle open/closed on target press.
|
|
25
|
+
*/
|
|
26
|
+
visible?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Called when the backdrop is pressed. Use this in controlled mode to update
|
|
29
|
+
* the `visible` prop.
|
|
30
|
+
*/
|
|
31
|
+
onDismiss?: () => void;
|
|
22
32
|
}
|
|
23
|
-
declare const AppCue: ({ target, content, placement, style, testID, }: AppCueProps) => React.JSX.Element;
|
|
33
|
+
declare const AppCue: ({ target, content, placement, style, testID, visible: controlledVisible, onDismiss, }: AppCueProps) => React.JSX.Element;
|
|
24
34
|
export default AppCue;
|
|
@@ -1,27 +1,8 @@
|
|
|
1
1
|
import type { Placement } from './StyledAppCue';
|
|
2
|
-
/**
|
|
3
|
-
* Calculates the position of an element based on its placement relative to a reference position.
|
|
4
|
-
*
|
|
5
|
-
* @param {Object} params - The parameters for calculating the position.
|
|
6
|
-
* @param {Object} params.position - The position and size of target element.
|
|
7
|
-
* @param {number} params.position.pageX - The X coordinate of the target position.
|
|
8
|
-
* @param {number} params.position.pageY - The Y coordinate of the target position.
|
|
9
|
-
* @param {number} params.position.width - The width of the reference element.
|
|
10
|
-
* @param {number} params.position.height - The height of the reference element.
|
|
11
|
-
* @param {Object} params.contentSize - The size of the App Cue content.
|
|
12
|
-
* @param {number} params.contentSize.width - The width of the content.
|
|
13
|
-
* @param {number} params.contentSize.height - The height of the content.
|
|
14
|
-
* @param {Placement} params.placement - The placement of the content relative to the reference position ('top', 'bottom', 'right', 'left').
|
|
15
|
-
* @param {number} params.offset - The offset distance to display an arrow.
|
|
16
|
-
*
|
|
17
|
-
* @returns {Object} The calculated position of the App Cue.
|
|
18
|
-
* @returns {number} return.x - The X coordinate of the App Cue.
|
|
19
|
-
* @returns {number} return.y - The Y coordinate of the App Cue.
|
|
20
|
-
*/
|
|
21
2
|
export declare const calculatePosition: ({ placement, position, contentSize, offset, windowWidth, }: {
|
|
22
3
|
position: {
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
25
6
|
width: number;
|
|
26
7
|
height: number;
|
|
27
8
|
};
|
|
@@ -38,25 +19,10 @@ export declare const calculatePosition: ({ placement, position, contentSize, off
|
|
|
38
19
|
bottom?: number;
|
|
39
20
|
right?: number;
|
|
40
21
|
};
|
|
41
|
-
/**
|
|
42
|
-
* Calculates the maximum width of the content based on its position, offset, placement, and window width.
|
|
43
|
-
*
|
|
44
|
-
* @param {Object} params - The parameters for the calculation.
|
|
45
|
-
* @param {Object} params.position - The position and dimensions of the target element.
|
|
46
|
-
* @param {number} params.position.pageX - The X coordinate of the target element.
|
|
47
|
-
* @param {number} params.position.pageY - The Y coordinate of the target element.
|
|
48
|
-
* @param {number} params.position.width - The width of the target element.
|
|
49
|
-
* @param {number} params.position.height - The height of the target element.
|
|
50
|
-
* @param {number} params.offset - The offset value to display an arrow.
|
|
51
|
-
* @param {Placement} params.placement - The placement of the content relative to the element.
|
|
52
|
-
* @param {number} params.windowWidth - The width of the window.
|
|
53
|
-
*
|
|
54
|
-
* @returns {number | undefined} The maximum width of the content.
|
|
55
|
-
*/
|
|
56
22
|
export declare const calulateContentMaxWidth: ({ position, offset, placement, windowWidth, }: {
|
|
57
23
|
position: {
|
|
58
|
-
|
|
59
|
-
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
60
26
|
width: number;
|
|
61
27
|
height: number;
|
|
62
28
|
};
|