@telus-uds/components-base 1.24.1 → 1.24.2
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 +13 -2
- package/lib/Box/Box.js +3 -1
- package/lib/Divider/Divider.js +3 -0
- package/lib/FlexGrid/FlexGrid.js +3 -1
- package/lib/Link/InlinePressable.js +8 -1
- package/lib/Link/LinkBase.js +6 -8
- package/lib/StackView/StackView.js +3 -1
- package/lib/StackView/StackWrapBox.js +3 -1
- package/lib/StackView/StackWrapGap.js +3 -1
- package/lib/ThemeProvider/utils/styles.js +1 -3
- package/lib/Tooltip/Tooltip.js +85 -158
- package/lib/Tooltip/Tooltip.native.js +357 -0
- package/lib/Tooltip/index.js +6 -1
- package/lib/Tooltip/shared.js +39 -0
- package/lib/Typography/Typography.js +3 -1
- package/lib/utils/floating-ui/index.js +43 -0
- package/lib/utils/floating-ui/index.native.js +43 -0
- package/lib-module/Box/Box.js +3 -1
- package/lib-module/Divider/Divider.js +3 -0
- package/lib-module/FlexGrid/FlexGrid.js +3 -1
- package/lib-module/Link/InlinePressable.js +8 -1
- package/lib-module/Link/LinkBase.js +6 -8
- package/lib-module/StackView/StackView.js +3 -1
- package/lib-module/StackView/StackWrapBox.js +3 -1
- package/lib-module/StackView/StackWrapGap.js +3 -1
- package/lib-module/ThemeProvider/utils/styles.js +1 -3
- package/lib-module/Tooltip/Tooltip.js +85 -155
- package/lib-module/Tooltip/Tooltip.native.js +326 -0
- package/lib-module/Tooltip/index.js +4 -1
- package/lib-module/Tooltip/shared.js +27 -0
- package/lib-module/Typography/Typography.js +3 -1
- package/lib-module/utils/floating-ui/index.js +1 -0
- package/lib-module/utils/floating-ui/index.native.js +1 -0
- package/package.json +4 -2
- package/src/Box/Box.jsx +1 -0
- package/src/Divider/Divider.jsx +3 -0
- package/src/FlexGrid/FlexGrid.jsx +1 -0
- package/src/Link/InlinePressable.jsx +9 -3
- package/src/Link/LinkBase.jsx +17 -10
- package/src/StackView/StackView.jsx +1 -0
- package/src/StackView/StackWrapBox.jsx +1 -0
- package/src/StackView/StackWrapGap.jsx +1 -0
- package/src/ThemeProvider/utils/styles.js +1 -3
- package/src/Tooltip/Tooltip.jsx +79 -156
- package/src/Tooltip/Tooltip.native.jsx +283 -0
- package/src/Tooltip/index.js +5 -1
- package/src/Tooltip/shared.js +27 -0
- package/src/Typography/Typography.jsx +1 -0
- package/src/utils/floating-ui/index.js +1 -0
- package/src/utils/floating-ui/index.native.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-base
|
|
2
2
|
|
|
3
|
-
This log was last generated on Thu,
|
|
3
|
+
This log was last generated on Thu, 19 Jan 2023 21:35:52 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.24.2
|
|
8
|
+
|
|
9
|
+
Thu, 19 Jan 2023 21:35:52 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Tooltip implementation is separated into web and native for a fix on smaller screen size (akshay.pandey@telus.com)
|
|
14
|
+
- fix: remove direct font weight application (ruslan.bredikhin@nearform.com)
|
|
15
|
+
- fix: switch the order of the styling rules on the inline pressable (ruslan.bredikhin@nearform.com)
|
|
16
|
+
- Fix missing passthrough of accessibilityRole in taggable container components (alan.slater@nearform.com)
|
|
17
|
+
|
|
7
18
|
## 1.24.1
|
|
8
19
|
|
|
9
|
-
Thu, 05 Jan 2023 03:
|
|
20
|
+
Thu, 05 Jan 2023 03:43:21 GMT
|
|
10
21
|
|
|
11
22
|
### Patches
|
|
12
23
|
|
package/lib/Box/Box.js
CHANGED
|
@@ -146,7 +146,9 @@ const Box = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
146
146
|
dataSet,
|
|
147
147
|
...rest
|
|
148
148
|
} = _ref;
|
|
149
|
-
const props = {
|
|
149
|
+
const props = {
|
|
150
|
+
accessibilityRole,
|
|
151
|
+
...(0, _utils.getA11yPropsFromHtmlTag)(tag, accessibilityRole),
|
|
150
152
|
...selectProps(rest)
|
|
151
153
|
};
|
|
152
154
|
const themeTokens = (0, _ThemeProvider.useThemeTokens)('Box', tokens, variant);
|
package/lib/Divider/Divider.js
CHANGED
|
@@ -93,7 +93,10 @@ const Divider = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
93
93
|
};
|
|
94
94
|
const a11y = _Platform.default.OS === 'web' ? // There are aria attributes for dividers on web
|
|
95
95
|
{
|
|
96
|
+
// Early versions of React Native Web support 'aria-orientation' while
|
|
97
|
+
// later versions only support accessibilityOrientation and map it. Supply both.
|
|
96
98
|
'aria-orientation': vertical ? 'vertical' : 'horizontal',
|
|
99
|
+
accessibilityOrientation: vertical ? 'vertical' : 'horizontal',
|
|
97
100
|
accessibilityRole: 'separator'
|
|
98
101
|
} : // There are no such equivalent attributes for native
|
|
99
102
|
{};
|
package/lib/FlexGrid/FlexGrid.js
CHANGED
|
@@ -86,7 +86,9 @@ const FlexGrid = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
86
86
|
flexDirection = reverseLevel[4] ? 'column-reverse' : 'column';
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
const props = {
|
|
89
|
+
const props = {
|
|
90
|
+
accessibilityRole,
|
|
91
|
+
...(0, _utils.getA11yPropsFromHtmlTag)(tag, accessibilityRole),
|
|
90
92
|
...selectProps(rest)
|
|
91
93
|
};
|
|
92
94
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GutterContext.default.Provider, {
|
|
@@ -27,6 +27,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
27
27
|
* InlinePressable is an alternative to React Native's Pressable that works better when nested
|
|
28
28
|
* inline inside Text. It accepts the same props as React Native's Pressable.
|
|
29
29
|
*
|
|
30
|
+
* On Web it simply passes its props to Pressable and defaults to `inline-flex` instead of `flex`.
|
|
31
|
+
*
|
|
30
32
|
* @param {PressableProps} PressableProps
|
|
31
33
|
*/
|
|
32
34
|
// React Native exports prop Types but not propTypes, use JSDoc types here rather than duplicate RN
|
|
@@ -34,12 +36,13 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
34
36
|
const InlinePressable = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
35
37
|
let {
|
|
36
38
|
children,
|
|
39
|
+
inlineFlex = true,
|
|
37
40
|
style,
|
|
38
41
|
...props
|
|
39
42
|
} = _ref;
|
|
40
43
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
|
|
41
44
|
ref: ref,
|
|
42
|
-
style: pressState => [
|
|
45
|
+
style: pressState => [typeof style === 'function' ? style(pressState) : style, staticStyles[inlineFlex ? 'inlineFlex' : 'inline']],
|
|
43
46
|
...props,
|
|
44
47
|
children: pressState => typeof children === 'function' ? children(pressState) : children
|
|
45
48
|
});
|
|
@@ -48,7 +51,11 @@ InlinePressable.displayName = 'InlinePressable';
|
|
|
48
51
|
|
|
49
52
|
const staticStyles = _StyleSheet.default.create({
|
|
50
53
|
inline: {
|
|
54
|
+
// Stop Pressable defaulting to (block) flex
|
|
51
55
|
display: 'inline'
|
|
56
|
+
},
|
|
57
|
+
inlineFlex: {
|
|
58
|
+
display: 'inline-flex'
|
|
52
59
|
}
|
|
53
60
|
});
|
|
54
61
|
|
package/lib/Link/LinkBase.js
CHANGED
|
@@ -37,7 +37,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
37
37
|
|
|
38
38
|
const [selectProps, selectedSystemPropTypes] = (0, _props.selectSystemProps)([_props.a11yProps, _props.linkProps, _props.viewProps]);
|
|
39
39
|
|
|
40
|
-
const selectOuterBorderStyles =
|
|
40
|
+
const selectOuterBorderStyles = _ref => {
|
|
41
41
|
let {
|
|
42
42
|
outerBorderColor,
|
|
43
43
|
outerBorderWidth,
|
|
@@ -55,11 +55,7 @@ const selectOuterBorderStyles = (_ref, hasIcon) => {
|
|
|
55
55
|
outerBorderWidth,
|
|
56
56
|
outerBorderGap,
|
|
57
57
|
borderRadius
|
|
58
|
-
})
|
|
59
|
-
// Stops focus ring stretching horizontally if parent has display: block
|
|
60
|
-
// width: fit-content isn't supported on Firefox; can't cascade props like CSS `width: fit-content; width: --moz-fit-content;`
|
|
61
|
-
display: hasIcon ? 'inline-flex' : 'inline' // Stop Pressable defaulting to (block) flex
|
|
62
|
-
|
|
58
|
+
})
|
|
63
59
|
} : {}
|
|
64
60
|
);
|
|
65
61
|
};
|
|
@@ -198,12 +194,14 @@ const LinkBase = /*#__PURE__*/(0, _react.forwardRef)((_ref6, ref) => {
|
|
|
198
194
|
themeOptions
|
|
199
195
|
} = (0, _ThemeProvider.useTheme)();
|
|
200
196
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InlinePressable.default, { ...selectedProps,
|
|
197
|
+
inlineFlex: hasIcon // assuming links without icons should be inline (even if they are long)
|
|
198
|
+
,
|
|
201
199
|
ref: ref,
|
|
202
200
|
style: linkState => {
|
|
203
201
|
const themeTokens = resolveLinkTokens(linkState);
|
|
204
|
-
const outerBorderStyles = selectOuterBorderStyles(themeTokens
|
|
202
|
+
const outerBorderStyles = selectOuterBorderStyles(themeTokens);
|
|
205
203
|
const decorationStyles = selectDecorationStyles(themeTokens);
|
|
206
|
-
return [outerBorderStyles, blockLeftStyle, decorationStyles, staticStyles.rowContainer];
|
|
204
|
+
return [outerBorderStyles, blockLeftStyle, decorationStyles, hasIcon && staticStyles.rowContainer];
|
|
207
205
|
},
|
|
208
206
|
children: linkState => {
|
|
209
207
|
const themeTokens = resolveLinkTokens(linkState);
|
|
@@ -89,7 +89,9 @@ const StackView = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
89
89
|
} = _ref;
|
|
90
90
|
const viewport = (0, _ViewportProvider.useViewport)();
|
|
91
91
|
const direction = (0, _utils.useResponsiveProp)(directionProp, 'column');
|
|
92
|
-
const selectedProps = selectProps({
|
|
92
|
+
const selectedProps = selectProps({
|
|
93
|
+
accessibilityRole,
|
|
94
|
+
...(0, _utils.getA11yPropsFromHtmlTag)(tag, accessibilityRole),
|
|
93
95
|
...rest
|
|
94
96
|
});
|
|
95
97
|
const content = (0, _getStackedContent.default)(children, {
|
|
@@ -73,7 +73,9 @@ const StackWrapBox = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
73
73
|
viewport
|
|
74
74
|
});
|
|
75
75
|
const flexStyles = (0, _common.selectFlexStyles)(themeTokens);
|
|
76
|
-
const selectedProps = selectProps({
|
|
76
|
+
const selectedProps = selectProps({
|
|
77
|
+
accessibilityRole,
|
|
78
|
+
...(0, _utils.getA11yPropsFromHtmlTag)(tag, accessibilityRole),
|
|
77
79
|
...rest
|
|
78
80
|
}); // Mimic CSS `gap` using box spacing on the side after a wrapped row then offsetting it on the last row.
|
|
79
81
|
|
|
@@ -58,7 +58,9 @@ const StackWrapGap = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
58
58
|
viewport
|
|
59
59
|
});
|
|
60
60
|
const flexStyles = (0, _common.selectFlexStyles)(themeTokens);
|
|
61
|
-
const selectedProps = selectProps({
|
|
61
|
+
const selectedProps = selectProps({
|
|
62
|
+
accessibilityRole,
|
|
63
|
+
...(0, _utils.getA11yPropsFromHtmlTag)(tag, accessibilityRole),
|
|
62
64
|
...rest
|
|
63
65
|
});
|
|
64
66
|
const size = (0, _utils.useSpacingScale)(space);
|
|
@@ -59,9 +59,7 @@ function applyTextStyles(_ref) {
|
|
|
59
59
|
// Don't set undefined font families. May need some validation here that the font is available.
|
|
60
60
|
// Android doesn't recognise font weights natively so apply custom font weights via `fontFamily`.
|
|
61
61
|
styles.fontFamily = "".concat(fontName).concat(fontWeight).concat(fontStyle);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (fontWeight) {
|
|
62
|
+
} else if (fontWeight) {
|
|
65
63
|
// If using system default font, apply the font weight directly.
|
|
66
64
|
// Font weight support in Android is limited to 'bold' or anything else === 'normal'.
|
|
67
65
|
styles.fontWeight = _Platform.default.OS === 'android' && Number(fontWeight) > 400 ? 'bold' : fontWeight;
|
package/lib/Tooltip/Tooltip.js
CHANGED
|
@@ -7,8 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
-
var _Dimensions = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Dimensions"));
|
|
11
|
-
|
|
12
10
|
var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
|
|
13
11
|
|
|
14
12
|
var _Pressable = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Pressable"));
|
|
@@ -19,16 +17,14 @@ var _Text = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Te
|
|
|
19
17
|
|
|
20
18
|
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
21
19
|
|
|
22
|
-
var
|
|
20
|
+
var _shared = _interopRequireDefault(require("./shared"));
|
|
21
|
+
|
|
22
|
+
var _floatingUi = require("../utils/floating-ui");
|
|
23
23
|
|
|
24
24
|
var _ThemeProvider = require("../ThemeProvider");
|
|
25
25
|
|
|
26
26
|
var _utils = require("../utils");
|
|
27
27
|
|
|
28
|
-
var _Backdrop = _interopRequireDefault(require("./Backdrop"));
|
|
29
|
-
|
|
30
|
-
var _getTooltipPosition = _interopRequireDefault(require("./getTooltipPosition"));
|
|
31
|
-
|
|
32
28
|
var _TooltipButton = _interopRequireDefault(require("../TooltipButton"));
|
|
33
29
|
|
|
34
30
|
var _useCopy = _interopRequireDefault(require("../utils/useCopy"));
|
|
@@ -75,20 +71,20 @@ const selectTooltipShadowStyles = _ref2 => {
|
|
|
75
71
|
};
|
|
76
72
|
};
|
|
77
73
|
|
|
78
|
-
const
|
|
74
|
+
const selectMobileTooltipPositionStyles = _ref3 => {
|
|
79
75
|
let {
|
|
80
76
|
top,
|
|
81
77
|
left,
|
|
82
|
-
|
|
78
|
+
position
|
|
83
79
|
} = _ref3;
|
|
84
80
|
return {
|
|
85
81
|
top,
|
|
86
82
|
left,
|
|
87
|
-
|
|
83
|
+
position
|
|
88
84
|
};
|
|
89
85
|
};
|
|
90
86
|
|
|
91
|
-
const
|
|
87
|
+
const selectMobileArrowStyles = (_ref4, _ref5) => {
|
|
92
88
|
let {
|
|
93
89
|
backgroundColor,
|
|
94
90
|
arrowWidth,
|
|
@@ -96,56 +92,31 @@ const selectArrowStyles = (_ref4, _ref5) => {
|
|
|
96
92
|
shadow
|
|
97
93
|
} = _ref4;
|
|
98
94
|
let {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
95
|
+
placement,
|
|
96
|
+
x: arrowX,
|
|
97
|
+
y: arrowY
|
|
102
98
|
} = _ref5;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
// calculate the pixel values
|
|
110
|
-
|
|
111
|
-
const directionalStyles = {
|
|
112
|
-
above: {
|
|
113
|
-
bottom: verticalOffset,
|
|
114
|
-
left: tooltipWidth / 2 - horizontalOffset,
|
|
115
|
-
transform: [{
|
|
116
|
-
rotateZ: '45deg'
|
|
117
|
-
}]
|
|
118
|
-
},
|
|
119
|
-
below: {
|
|
120
|
-
top: verticalOffset,
|
|
121
|
-
left: tooltipWidth / 2 - horizontalOffset,
|
|
122
|
-
transform: [{
|
|
123
|
-
rotateZ: '-135deg'
|
|
124
|
-
}]
|
|
125
|
-
},
|
|
126
|
-
left: {
|
|
127
|
-
right: verticalOffset,
|
|
128
|
-
top: tooltipHeight / 2 - horizontalOffset,
|
|
129
|
-
transform: [{
|
|
130
|
-
rotateZ: '-45deg'
|
|
131
|
-
}]
|
|
132
|
-
},
|
|
133
|
-
right: {
|
|
134
|
-
left: verticalOffset,
|
|
135
|
-
top: tooltipHeight / 2 - horizontalOffset,
|
|
136
|
-
transform: [{
|
|
137
|
-
rotateZ: '135deg'
|
|
138
|
-
}]
|
|
139
|
-
}
|
|
140
|
-
};
|
|
99
|
+
const staticSide = {
|
|
100
|
+
top: 'bottom',
|
|
101
|
+
right: 'left',
|
|
102
|
+
bottom: 'top',
|
|
103
|
+
left: 'right'
|
|
104
|
+
}[placement.split('-')[0]];
|
|
141
105
|
return {
|
|
142
106
|
backgroundColor,
|
|
143
|
-
width:
|
|
144
|
-
height:
|
|
107
|
+
width: arrowWidth,
|
|
108
|
+
height: arrowWidth,
|
|
145
109
|
borderBottomRightRadius: arrowBorderRadius,
|
|
146
110
|
// this corner will be the arrow tip after rotation
|
|
111
|
+
transform: [{
|
|
112
|
+
rotateZ: '45deg'
|
|
113
|
+
}],
|
|
147
114
|
...(0, _ThemeProvider.applyShadowToken)(shadow),
|
|
148
|
-
|
|
115
|
+
left: arrowX != null && arrowX,
|
|
116
|
+
top: arrowY != null && arrowY,
|
|
117
|
+
right: '',
|
|
118
|
+
bottom: '',
|
|
119
|
+
[staticSide]: '-4px'
|
|
149
120
|
};
|
|
150
121
|
};
|
|
151
122
|
|
|
@@ -183,41 +154,50 @@ const Tooltip = /*#__PURE__*/(0, _react.forwardRef)((_ref6, ref) => {
|
|
|
183
154
|
...rest
|
|
184
155
|
} = _ref6;
|
|
185
156
|
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
186
|
-
const
|
|
187
|
-
const [controlLayout, setControlLayout] = (0, _react.useState)(null);
|
|
157
|
+
const arrowRef = (0, _react.useRef)();
|
|
188
158
|
const [tooltipDimensions, setTooltipDimensions] = (0, _react.useState)(null);
|
|
189
|
-
const
|
|
190
|
-
|
|
159
|
+
const positions = {
|
|
160
|
+
auto: undefined,
|
|
161
|
+
// Auto needs to specifically bet set to undefined
|
|
162
|
+
above: 'top',
|
|
163
|
+
right: 'right',
|
|
164
|
+
below: 'bottom',
|
|
165
|
+
left: 'left'
|
|
166
|
+
}; // "AutoPlacement" can't be used with "flip"
|
|
167
|
+
|
|
168
|
+
const additionalMiddleware = position !== 'auto' ? _floatingUi.autoPlacement : _floatingUi.flip;
|
|
169
|
+
const {
|
|
170
|
+
x,
|
|
171
|
+
y,
|
|
172
|
+
reference,
|
|
173
|
+
floating,
|
|
174
|
+
strategy,
|
|
175
|
+
placement,
|
|
176
|
+
middlewareData: {
|
|
177
|
+
arrow: arrowData = {}
|
|
178
|
+
}
|
|
179
|
+
} = (0, _floatingUi.useFloating)({
|
|
180
|
+
placement: positions[position],
|
|
181
|
+
middleware: [(0, _floatingUi.shift)(), additionalMiddleware(), (0, _floatingUi.offset)(15), (0, _floatingUi.arrow)({
|
|
182
|
+
element: arrowRef
|
|
183
|
+
})]
|
|
184
|
+
});
|
|
191
185
|
const getCopy = (0, _useCopy.default)({
|
|
192
186
|
dictionary: _dictionary.default,
|
|
193
187
|
copy
|
|
194
188
|
});
|
|
195
189
|
const themeTokens = (0, _ThemeProvider.useThemeTokens)('Tooltip', tokens, variant);
|
|
196
|
-
const {
|
|
197
|
-
arrowWidth,
|
|
198
|
-
arrowOffset
|
|
199
|
-
} = themeTokens;
|
|
200
|
-
(0, _react.useEffect)(() => {
|
|
201
|
-
const subscription = _Dimensions.default.addEventListener('change', _ref7 => {
|
|
202
|
-
let {
|
|
203
|
-
window
|
|
204
|
-
} = _ref7;
|
|
205
|
-
setWindowDimensions(window);
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
return () => subscription === null || subscription === void 0 ? void 0 : subscription.remove();
|
|
209
|
-
});
|
|
210
190
|
|
|
211
191
|
const toggleIsOpen = () => setIsOpen(!isOpen);
|
|
212
192
|
|
|
213
193
|
const close = () => setIsOpen(false);
|
|
214
194
|
|
|
215
|
-
const getPressableState =
|
|
195
|
+
const getPressableState = _ref7 => {
|
|
216
196
|
let {
|
|
217
197
|
pressed,
|
|
218
198
|
hovered,
|
|
219
199
|
focused
|
|
220
|
-
} =
|
|
200
|
+
} = _ref7;
|
|
221
201
|
return {
|
|
222
202
|
pressed,
|
|
223
203
|
hover: hovered,
|
|
@@ -225,7 +205,7 @@ const Tooltip = /*#__PURE__*/(0, _react.forwardRef)((_ref6, ref) => {
|
|
|
225
205
|
};
|
|
226
206
|
};
|
|
227
207
|
|
|
228
|
-
const onTooltipLayout =
|
|
208
|
+
const onTooltipLayout = _ref8 => {
|
|
229
209
|
let {
|
|
230
210
|
nativeEvent: {
|
|
231
211
|
layout: {
|
|
@@ -233,7 +213,7 @@ const Tooltip = /*#__PURE__*/(0, _react.forwardRef)((_ref6, ref) => {
|
|
|
233
213
|
height
|
|
234
214
|
}
|
|
235
215
|
}
|
|
236
|
-
} =
|
|
216
|
+
} = _ref8;
|
|
237
217
|
|
|
238
218
|
if (tooltipDimensions === null || tooltipDimensions.width !== width || tooltipDimensions.height !== height) {
|
|
239
219
|
setTooltipDimensions({
|
|
@@ -248,43 +228,10 @@ const Tooltip = /*#__PURE__*/(0, _react.forwardRef)((_ref6, ref) => {
|
|
|
248
228
|
};
|
|
249
229
|
|
|
250
230
|
(0, _react.useEffect)(() => {
|
|
251
|
-
if (isOpen) {
|
|
252
|
-
controlRef.current.measureInWindow((x, y, width, height) => {
|
|
253
|
-
setControlLayout({
|
|
254
|
-
x,
|
|
255
|
-
y,
|
|
256
|
-
width,
|
|
257
|
-
height
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
} else {
|
|
261
|
-
setControlLayout(null);
|
|
231
|
+
if (!isOpen) {
|
|
262
232
|
setTooltipDimensions(null);
|
|
263
|
-
setTooltipPosition(null);
|
|
264
233
|
}
|
|
265
234
|
}, [isOpen]);
|
|
266
|
-
(0, _react.useEffect)(() => {
|
|
267
|
-
setIsOpen(false);
|
|
268
|
-
}, [windowDimensions]);
|
|
269
|
-
(0, _react.useEffect)(() => {
|
|
270
|
-
if (tooltipPosition !== null && !(tooltipPosition !== null && tooltipPosition !== void 0 && tooltipPosition.isNormalized) || !isOpen || controlLayout === null || tooltipDimensions == null) {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
const updatedPosition = (0, _getTooltipPosition.default)(position, {
|
|
275
|
-
controlLayout,
|
|
276
|
-
tooltipDimensions,
|
|
277
|
-
windowDimensions,
|
|
278
|
-
arrowWidth,
|
|
279
|
-
arrowOffset
|
|
280
|
-
}); // avoid ending up in an infinite normalization loop
|
|
281
|
-
|
|
282
|
-
if (tooltipPosition !== null && tooltipPosition !== void 0 && tooltipPosition.isNormalized && updatedPosition.isNormalized) {
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
setTooltipPosition(updatedPosition);
|
|
287
|
-
}, [isOpen, position, tooltipDimensions, controlLayout, windowDimensions, arrowWidth, arrowOffset, tooltipPosition]);
|
|
288
235
|
const control = children !== undefined ? children : defaultControl;
|
|
289
236
|
const pressableStyles = control === defaultControl ? _Platform.default.select({
|
|
290
237
|
web: {
|
|
@@ -300,69 +247,52 @@ const Tooltip = /*#__PURE__*/(0, _react.forwardRef)((_ref6, ref) => {
|
|
|
300
247
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
301
248
|
style: staticStyles.container,
|
|
302
249
|
...selectProps(rest),
|
|
250
|
+
ref: ref,
|
|
303
251
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
|
|
304
252
|
onPress: toggleIsOpen,
|
|
305
|
-
ref:
|
|
253
|
+
ref: reference,
|
|
306
254
|
onBlur: close,
|
|
307
255
|
style: pressableStyles,
|
|
308
256
|
hitSlop: pressableHitSlop,
|
|
309
257
|
accessibilityLabel: getCopy('a11yText'),
|
|
310
258
|
accessibilityRole: "button",
|
|
311
259
|
children: typeof control === 'function' ? pressableState => control(getPressableState(pressableState), variant) : control
|
|
312
|
-
}), isOpen && /*#__PURE__*/(0, _jsxRuntime.
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
260
|
+
}), isOpen && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
261
|
+
ref: floating,
|
|
262
|
+
style: [selectTooltipShadowStyles(themeTokens), staticStyles.tooltip, // applied separately so that it doesn't cover the arrow
|
|
263
|
+
selectMobileTooltipPositionStyles({
|
|
264
|
+
position: strategy,
|
|
265
|
+
top: y !== null && y !== void 0 ? y : 0,
|
|
266
|
+
left: x !== null && x !== void 0 ? x : 0
|
|
267
|
+
})],
|
|
268
|
+
onLayout: onTooltipLayout,
|
|
269
|
+
accessibilityRole: "alert",
|
|
270
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
271
|
+
style: [staticStyles.arrow, selectMobileArrowStyles(themeTokens, { ...arrowData,
|
|
272
|
+
placement
|
|
273
|
+
})],
|
|
274
|
+
ref: arrowRef
|
|
275
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
276
|
+
style: selectTooltipStyles(themeTokens),
|
|
277
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
278
|
+
style: selectTextStyles(themeTokens),
|
|
279
|
+
children: content
|
|
280
|
+
})
|
|
281
|
+
})]
|
|
331
282
|
})]
|
|
332
283
|
});
|
|
333
284
|
});
|
|
334
285
|
Tooltip.displayName = 'Tooltip';
|
|
335
286
|
Tooltip.propTypes = { ...selectedSystemPropTypes,
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Used to render the control (i.e. tooltip trigger). If a render function is used it will receive the
|
|
339
|
-
* pressable state and tooltip variant as an argument.
|
|
340
|
-
*/
|
|
341
|
-
children: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* The message. Can be raw text or text components.
|
|
345
|
-
*/
|
|
346
|
-
content: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]),
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Select English or French copy for the accessible label.
|
|
350
|
-
*/
|
|
351
|
-
copy: _propTypes.default.oneOf(['en', 'fr']),
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Use to place the tooltip in a specific location (only if it fits within viewport).
|
|
355
|
-
*/
|
|
356
|
-
position: _propTypes.default.oneOf(['auto', 'above', 'right', 'below', 'left']),
|
|
357
|
-
tokens: (0, _utils.getTokensPropType)('Tooltip'),
|
|
358
|
-
variant: _utils.variantProp.propType
|
|
287
|
+
..._shared.default
|
|
359
288
|
};
|
|
360
289
|
var _default = Tooltip;
|
|
361
290
|
exports.default = _default;
|
|
362
291
|
|
|
363
292
|
const staticStyles = _StyleSheet.default.create({
|
|
364
293
|
container: {
|
|
365
|
-
alignItems: 'flex-start'
|
|
294
|
+
alignItems: 'flex-start',
|
|
295
|
+
position: 'absolute'
|
|
366
296
|
},
|
|
367
297
|
tooltip: {
|
|
368
298
|
position: 'absolute',
|
|
@@ -370,9 +300,6 @@ const staticStyles = _StyleSheet.default.create({
|
|
|
370
300
|
top: 0,
|
|
371
301
|
left: 0
|
|
372
302
|
},
|
|
373
|
-
tooltipHidden: {
|
|
374
|
-
opacity: 0
|
|
375
|
-
},
|
|
376
303
|
arrow: {
|
|
377
304
|
position: 'absolute'
|
|
378
305
|
}
|