@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.
Files changed (50) hide show
  1. package/CHANGELOG.md +13 -2
  2. package/lib/Box/Box.js +3 -1
  3. package/lib/Divider/Divider.js +3 -0
  4. package/lib/FlexGrid/FlexGrid.js +3 -1
  5. package/lib/Link/InlinePressable.js +8 -1
  6. package/lib/Link/LinkBase.js +6 -8
  7. package/lib/StackView/StackView.js +3 -1
  8. package/lib/StackView/StackWrapBox.js +3 -1
  9. package/lib/StackView/StackWrapGap.js +3 -1
  10. package/lib/ThemeProvider/utils/styles.js +1 -3
  11. package/lib/Tooltip/Tooltip.js +85 -158
  12. package/lib/Tooltip/Tooltip.native.js +357 -0
  13. package/lib/Tooltip/index.js +6 -1
  14. package/lib/Tooltip/shared.js +39 -0
  15. package/lib/Typography/Typography.js +3 -1
  16. package/lib/utils/floating-ui/index.js +43 -0
  17. package/lib/utils/floating-ui/index.native.js +43 -0
  18. package/lib-module/Box/Box.js +3 -1
  19. package/lib-module/Divider/Divider.js +3 -0
  20. package/lib-module/FlexGrid/FlexGrid.js +3 -1
  21. package/lib-module/Link/InlinePressable.js +8 -1
  22. package/lib-module/Link/LinkBase.js +6 -8
  23. package/lib-module/StackView/StackView.js +3 -1
  24. package/lib-module/StackView/StackWrapBox.js +3 -1
  25. package/lib-module/StackView/StackWrapGap.js +3 -1
  26. package/lib-module/ThemeProvider/utils/styles.js +1 -3
  27. package/lib-module/Tooltip/Tooltip.js +85 -155
  28. package/lib-module/Tooltip/Tooltip.native.js +326 -0
  29. package/lib-module/Tooltip/index.js +4 -1
  30. package/lib-module/Tooltip/shared.js +27 -0
  31. package/lib-module/Typography/Typography.js +3 -1
  32. package/lib-module/utils/floating-ui/index.js +1 -0
  33. package/lib-module/utils/floating-ui/index.native.js +1 -0
  34. package/package.json +4 -2
  35. package/src/Box/Box.jsx +1 -0
  36. package/src/Divider/Divider.jsx +3 -0
  37. package/src/FlexGrid/FlexGrid.jsx +1 -0
  38. package/src/Link/InlinePressable.jsx +9 -3
  39. package/src/Link/LinkBase.jsx +17 -10
  40. package/src/StackView/StackView.jsx +1 -0
  41. package/src/StackView/StackWrapBox.jsx +1 -0
  42. package/src/StackView/StackWrapGap.jsx +1 -0
  43. package/src/ThemeProvider/utils/styles.js +1 -3
  44. package/src/Tooltip/Tooltip.jsx +79 -156
  45. package/src/Tooltip/Tooltip.native.jsx +283 -0
  46. package/src/Tooltip/index.js +5 -1
  47. package/src/Tooltip/shared.js +27 -0
  48. package/src/Typography/Typography.jsx +1 -0
  49. package/src/utils/floating-ui/index.js +1 -0
  50. package/src/utils/floating-ui/index.native.js +1 -0
@@ -0,0 +1,357 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _Dimensions = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Dimensions"));
11
+
12
+ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
13
+
14
+ var _Pressable = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Pressable"));
15
+
16
+ var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
17
+
18
+ var _Text = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Text"));
19
+
20
+ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
21
+
22
+ var _shared = _interopRequireDefault(require("./shared"));
23
+
24
+ var _ThemeProvider = require("../ThemeProvider");
25
+
26
+ var _utils = require("../utils");
27
+
28
+ var _Backdrop = _interopRequireDefault(require("./Backdrop"));
29
+
30
+ var _getTooltipPosition = _interopRequireDefault(require("./getTooltipPosition"));
31
+
32
+ var _TooltipButton = _interopRequireDefault(require("../TooltipButton"));
33
+
34
+ var _useCopy = _interopRequireDefault(require("../utils/useCopy"));
35
+
36
+ var _dictionary = _interopRequireDefault(require("./dictionary"));
37
+
38
+ var _jsxRuntime = require("react/jsx-runtime");
39
+
40
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
41
+
42
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
43
+
44
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
45
+
46
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
47
+
48
+ const selectTooltipStyles = _ref => {
49
+ let {
50
+ backgroundColor,
51
+ paddingTop,
52
+ paddingBottom,
53
+ paddingLeft,
54
+ paddingRight,
55
+ borderRadius
56
+ } = _ref;
57
+ return {
58
+ backgroundColor,
59
+ paddingTop,
60
+ paddingBottom,
61
+ paddingLeft,
62
+ paddingRight,
63
+ borderRadius
64
+ };
65
+ };
66
+
67
+ const selectTooltipShadowStyles = _ref2 => {
68
+ let {
69
+ shadow,
70
+ borderRadius
71
+ } = _ref2;
72
+ return {
73
+ borderRadius,
74
+ ...(0, _ThemeProvider.applyShadowToken)(shadow)
75
+ };
76
+ };
77
+
78
+ const selectTooltipPositionStyles = _ref3 => {
79
+ let {
80
+ top,
81
+ left,
82
+ width
83
+ } = _ref3;
84
+ return {
85
+ top,
86
+ left,
87
+ width
88
+ };
89
+ };
90
+
91
+ const selectArrowStyles = (_ref4, _ref5) => {
92
+ let {
93
+ backgroundColor,
94
+ arrowWidth,
95
+ arrowBorderRadius,
96
+ shadow
97
+ } = _ref4;
98
+ let {
99
+ position,
100
+ width: tooltipWidth,
101
+ height: tooltipHeight
102
+ } = _ref5;
103
+ // the arrow width is actually a diagonal of the rectangle that we'll use as a tip
104
+ const rectangleSide = Math.sqrt(arrowWidth * arrowWidth / 2); // position the arrow at the side and center of the tooltip - this happens before rotation
105
+ // so we use the rectangle size as basis
106
+
107
+ const verticalOffset = -1 * rectangleSide / 2;
108
+ const horizontalOffset = rectangleSide / 2; // percentage-based absolute positioning doesn't act well on native, so we have to
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
+ };
141
+ return {
142
+ backgroundColor,
143
+ width: rectangleSide,
144
+ height: rectangleSide,
145
+ borderBottomRightRadius: arrowBorderRadius,
146
+ // this corner will be the arrow tip after rotation
147
+ ...(0, _ThemeProvider.applyShadowToken)(shadow),
148
+ ...directionalStyles[position]
149
+ };
150
+ };
151
+
152
+ const selectTextStyles = tokens => (0, _ThemeProvider.applyTextStyles)((0, _utils.selectTokens)('Typography', tokens));
153
+
154
+ const defaultControl = (pressableState, variant) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_TooltipButton.default, {
155
+ pressableState: pressableState,
156
+ variant: variant
157
+ });
158
+ /**
159
+ * Tooltip provides a descriptive and detailed explanation or instructions. It can be used next to an input label
160
+ * to help a user fill it in, or as a standalone component.
161
+ *
162
+ * By default the TooltipButton component will be used as a control for triggering the tooltip, but you may attach
163
+ * a tooltip to any other component. A render function can be used to adjust the control's styling on state changes (hover, focus, etc.).
164
+ *
165
+ * ### Positioning
166
+ * By default a Tooltip will be automatically positioned in a way that ensures it fits within the viewport.
167
+ * You may suggest a position with a prop - it will be used, unless the tooltip would end up outside the viewport.
168
+ *
169
+ * ### Usage criteria
170
+ * - You may use one when the information is useful only to a small percentage of users (ie. tech savvy people wouldn't need this info).
171
+ * - Tooltips may also be useful when vertical space is an issue.
172
+ */
173
+
174
+
175
+ const Tooltip = /*#__PURE__*/(0, _react.forwardRef)((_ref6, ref) => {
176
+ let {
177
+ children,
178
+ content,
179
+ position = 'auto',
180
+ copy = 'en',
181
+ tokens,
182
+ variant,
183
+ ...rest
184
+ } = _ref6;
185
+ const [isOpen, setIsOpen] = (0, _react.useState)(false);
186
+ const controlRef = (0, _react.useRef)();
187
+ const [controlLayout, setControlLayout] = (0, _react.useState)(null);
188
+ const [tooltipDimensions, setTooltipDimensions] = (0, _react.useState)(null);
189
+ const [windowDimensions, setWindowDimensions] = (0, _react.useState)(_Dimensions.default.get('window'));
190
+ const [tooltipPosition, setTooltipPosition] = (0, _react.useState)(null);
191
+ const getCopy = (0, _useCopy.default)({
192
+ dictionary: _dictionary.default,
193
+ copy
194
+ });
195
+ 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
+
211
+ const toggleIsOpen = () => setIsOpen(!isOpen);
212
+
213
+ const close = () => setIsOpen(false);
214
+
215
+ const getPressableState = _ref8 => {
216
+ let {
217
+ pressed,
218
+ hovered,
219
+ focused
220
+ } = _ref8;
221
+ return {
222
+ pressed,
223
+ hover: hovered,
224
+ focus: focused
225
+ };
226
+ };
227
+
228
+ const onTooltipLayout = _ref9 => {
229
+ let {
230
+ nativeEvent: {
231
+ layout: {
232
+ width,
233
+ height
234
+ }
235
+ }
236
+ } = _ref9;
237
+
238
+ if (tooltipDimensions === null || tooltipDimensions.width !== width || tooltipDimensions.height !== height) {
239
+ setTooltipDimensions({
240
+ width: _Platform.default.select({
241
+ web: width + 0.3,
242
+ // avoids often unnecessary line breaks due to subpixel rendering of fonts
243
+ native: width
244
+ }),
245
+ height
246
+ });
247
+ }
248
+ };
249
+
250
+ (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);
262
+ setTooltipDimensions(null);
263
+ setTooltipPosition(null);
264
+ }
265
+ }, [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
+ const control = children !== undefined ? children : defaultControl;
289
+ const pressableStyles = control === defaultControl ? _Platform.default.select({
290
+ web: {
291
+ outline: 'none'
292
+ }
293
+ }) : undefined;
294
+ const pressableHitSlop = control === defaultControl ? {
295
+ top: 10,
296
+ bottom: 10,
297
+ left: 10,
298
+ right: 10
299
+ } : undefined;
300
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
301
+ style: staticStyles.container,
302
+ ...selectProps(rest),
303
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Pressable.default, {
304
+ onPress: toggleIsOpen,
305
+ ref: controlRef,
306
+ onBlur: close,
307
+ style: pressableStyles,
308
+ hitSlop: pressableHitSlop,
309
+ accessibilityLabel: getCopy('a11yText'),
310
+ accessibilityRole: "button",
311
+ children: typeof control === 'function' ? pressableState => control(getPressableState(pressableState), variant) : control
312
+ }), isOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Backdrop.default, {
313
+ onPress: close,
314
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
315
+ ref: ref,
316
+ style: [staticStyles.tooltip, selectTooltipShadowStyles(themeTokens), // applied separately so that it doesn't cover the arrow
317
+ tooltipPosition && selectTooltipPositionStyles(tooltipPosition), (tooltipPosition === null || (tooltipPosition === null || tooltipPosition === void 0 ? void 0 : tooltipPosition.isNormalized)) && staticStyles.tooltipHidden // visually hide the tooltip until we have a final measurement
318
+ ],
319
+ onLayout: onTooltipLayout,
320
+ accessibilityRole: "alert",
321
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
322
+ style: [staticStyles.arrow, tooltipPosition && selectArrowStyles(themeTokens, tooltipPosition)]
323
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
324
+ style: selectTooltipStyles(themeTokens),
325
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
326
+ style: selectTextStyles(themeTokens),
327
+ children: content
328
+ })
329
+ })]
330
+ })
331
+ })]
332
+ });
333
+ });
334
+ Tooltip.displayName = 'NativeTooltip';
335
+ Tooltip.propTypes = { ...selectedSystemPropTypes,
336
+ ..._shared.default
337
+ };
338
+ var _default = Tooltip;
339
+ exports.default = _default;
340
+
341
+ const staticStyles = _StyleSheet.default.create({
342
+ container: {
343
+ alignItems: 'flex-start'
344
+ },
345
+ tooltip: {
346
+ position: 'absolute',
347
+ maxWidth: 240,
348
+ top: 0,
349
+ left: 0
350
+ },
351
+ tooltipHidden: {
352
+ opacity: 0
353
+ },
354
+ arrow: {
355
+ position: 'absolute'
356
+ }
357
+ });
@@ -5,9 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
+ var _Dimensions = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Dimensions"));
9
+
8
10
  var _Tooltip = _interopRequireDefault(require("./Tooltip"));
9
11
 
12
+ var _Tooltip2 = _interopRequireDefault(require("./Tooltip.native"));
13
+
10
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
15
 
12
- var _default = _Tooltip.default;
16
+ const Tooltip = !_Dimensions.default.get('screen').width <= 340 ? _Tooltip2.default : _Tooltip.default;
17
+ var _default = Tooltip;
13
18
  exports.default = _default;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+
10
+ var _utils = require("../utils");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ const propTypes = {
15
+ /**
16
+ * Used to render the control (i.e. tooltip trigger). If a render function is used it will receive the
17
+ * pressable state and tooltip variant as an argument.
18
+ */
19
+ children: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
20
+
21
+ /**
22
+ * The message. Can be raw text or text components.
23
+ */
24
+ content: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]),
25
+
26
+ /**
27
+ * Select English or French copy for the accessible label.
28
+ */
29
+ copy: _propTypes.default.oneOf(['en', 'fr']),
30
+
31
+ /**
32
+ * Use to place the tooltip in a specific location (only if it fits within viewport).
33
+ */
34
+ position: _propTypes.default.oneOf(['auto', 'above', 'right', 'below', 'left']),
35
+ tokens: (0, _utils.getTokensPropType)('Tooltip'),
36
+ variant: _utils.variantProp.propType
37
+ };
38
+ var _default = propTypes;
39
+ exports.default = _default;
@@ -87,7 +87,9 @@ const Typography = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
87
87
  dataSet,
88
88
  maxFontSizeMultiplier: (0, _utils2.getMaxFontMultiplier)(themeTokens)
89
89
  };
90
- const containerProps = { ...(0, _utils2.getA11yPropsFromHtmlTag)(tag, accessibilityRole),
90
+ const containerProps = {
91
+ accessibilityRole,
92
+ ...(0, _utils2.getA11yPropsFromHtmlTag)(tag, accessibilityRole),
91
93
  ...selectContainerProps(rest)
92
94
  };
93
95
  return block ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "arrow", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _reactDom.arrow;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "autoPlacement", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _reactDom.autoPlacement;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "flip", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _reactDom.flip;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "offset", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _reactDom.offset;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "shift", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _reactDom.shift;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "useFloating", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _reactDom.useFloating;
40
+ }
41
+ });
42
+
43
+ var _reactDom = require("@floating-ui/react-dom");
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "arrow", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _reactNative.arrow;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "autoPlacement", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _reactNative.autoPlacement;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "flip", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _reactNative.flip;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "offset", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _reactNative.offset;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "shift", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _reactNative.shift;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "useFloating", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _reactNative.useFloating;
40
+ }
41
+ });
42
+
43
+ var _reactNative = require("@floating-ui/react-native");
@@ -126,7 +126,9 @@ const Box = /*#__PURE__*/forwardRef((_ref, ref) => {
126
126
  dataSet,
127
127
  ...rest
128
128
  } = _ref;
129
- const props = { ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
129
+ const props = {
130
+ accessibilityRole,
131
+ ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
130
132
  ...selectProps(rest)
131
133
  };
132
134
  const themeTokens = useThemeTokens('Box', tokens, variant);
@@ -73,7 +73,10 @@ const Divider = /*#__PURE__*/forwardRef((_ref, ref) => {
73
73
  };
74
74
  const a11y = Platform.OS === 'web' ? // There are aria attributes for dividers on web
75
75
  {
76
+ // Early versions of React Native Web support 'aria-orientation' while
77
+ // later versions only support accessibilityOrientation and map it. Supply both.
76
78
  'aria-orientation': vertical ? 'vertical' : 'horizontal',
79
+ accessibilityOrientation: vertical ? 'vertical' : 'horizontal',
77
80
  accessibilityRole: 'separator'
78
81
  } : // There are no such equivalent attributes for native
79
82
  {};
@@ -62,7 +62,9 @@ const FlexGrid = /*#__PURE__*/forwardRef((_ref, ref) => {
62
62
  flexDirection = reverseLevel[4] ? 'column-reverse' : 'column';
63
63
  }
64
64
 
65
- const props = { ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
65
+ const props = {
66
+ accessibilityRole,
67
+ ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
66
68
  ...selectProps(rest)
67
69
  };
68
70
  return /*#__PURE__*/_jsx(GutterContext.Provider, {
@@ -9,6 +9,8 @@ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
9
9
  * InlinePressable is an alternative to React Native's Pressable that works better when nested
10
10
  * inline inside Text. It accepts the same props as React Native's Pressable.
11
11
  *
12
+ * On Web it simply passes its props to Pressable and defaults to `inline-flex` instead of `flex`.
13
+ *
12
14
  * @param {PressableProps} PressableProps
13
15
  */
14
16
  // React Native exports prop Types but not propTypes, use JSDoc types here rather than duplicate RN
@@ -18,12 +20,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
18
20
  const InlinePressable = /*#__PURE__*/forwardRef((_ref, ref) => {
19
21
  let {
20
22
  children,
23
+ inlineFlex = true,
21
24
  style,
22
25
  ...props
23
26
  } = _ref;
24
27
  return /*#__PURE__*/_jsx(Pressable, {
25
28
  ref: ref,
26
- style: pressState => [staticStyles.inline, typeof style === 'function' ? style(pressState) : style],
29
+ style: pressState => [typeof style === 'function' ? style(pressState) : style, staticStyles[inlineFlex ? 'inlineFlex' : 'inline']],
27
30
  ...props,
28
31
  children: pressState => typeof children === 'function' ? children(pressState) : children
29
32
  });
@@ -31,7 +34,11 @@ const InlinePressable = /*#__PURE__*/forwardRef((_ref, ref) => {
31
34
  InlinePressable.displayName = 'InlinePressable';
32
35
  const staticStyles = StyleSheet.create({
33
36
  inline: {
37
+ // Stop Pressable defaulting to (block) flex
34
38
  display: 'inline'
39
+ },
40
+ inlineFlex: {
41
+ display: 'inline-flex'
35
42
  }
36
43
  });
37
44
  export default InlinePressable;
@@ -12,7 +12,7 @@ import { IconText, iconComponentPropTypes } from '../Icon';
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, linkProps, viewProps]);
14
14
 
15
- const selectOuterBorderStyles = (_ref, hasIcon) => {
15
+ const selectOuterBorderStyles = _ref => {
16
16
  let {
17
17
  outerBorderColor,
18
18
  outerBorderWidth,
@@ -30,11 +30,7 @@ const selectOuterBorderStyles = (_ref, hasIcon) => {
30
30
  outerBorderWidth,
31
31
  outerBorderGap,
32
32
  borderRadius
33
- }),
34
- // Stops focus ring stretching horizontally if parent has display: block
35
- // width: fit-content isn't supported on Firefox; can't cascade props like CSS `width: fit-content; width: --moz-fit-content;`
36
- display: hasIcon ? 'inline-flex' : 'inline' // Stop Pressable defaulting to (block) flex
37
-
33
+ })
38
34
  } : {}
39
35
  );
40
36
  };
@@ -170,12 +166,14 @@ const LinkBase = /*#__PURE__*/forwardRef((_ref6, ref) => {
170
166
  themeOptions
171
167
  } = useTheme();
172
168
  return /*#__PURE__*/_jsx(InlinePressable, { ...selectedProps,
169
+ inlineFlex: hasIcon // assuming links without icons should be inline (even if they are long)
170
+ ,
173
171
  ref: ref,
174
172
  style: linkState => {
175
173
  const themeTokens = resolveLinkTokens(linkState);
176
- const outerBorderStyles = selectOuterBorderStyles(themeTokens, hasIcon);
174
+ const outerBorderStyles = selectOuterBorderStyles(themeTokens);
177
175
  const decorationStyles = selectDecorationStyles(themeTokens);
178
- return [outerBorderStyles, blockLeftStyle, decorationStyles, staticStyles.rowContainer];
176
+ return [outerBorderStyles, blockLeftStyle, decorationStyles, hasIcon && staticStyles.rowContainer];
179
177
  },
180
178
  children: linkState => {
181
179
  const themeTokens = resolveLinkTokens(linkState);
@@ -66,7 +66,9 @@ const StackView = /*#__PURE__*/forwardRef((_ref, ref) => {
66
66
  } = _ref;
67
67
  const viewport = useViewport();
68
68
  const direction = useResponsiveProp(directionProp, 'column');
69
- const selectedProps = selectProps({ ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
69
+ const selectedProps = selectProps({
70
+ accessibilityRole,
71
+ ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
70
72
  ...rest
71
73
  });
72
74
  const content = getStackedContent(children, {
@@ -51,7 +51,9 @@ const StackWrapBox = /*#__PURE__*/forwardRef((_ref, ref) => {
51
51
  viewport
52
52
  });
53
53
  const flexStyles = selectFlexStyles(themeTokens);
54
- const selectedProps = selectProps({ ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
54
+ const selectedProps = selectProps({
55
+ accessibilityRole,
56
+ ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
55
57
  ...rest
56
58
  }); // Mimic CSS `gap` using box spacing on the side after a wrapped row then offsetting it on the last row.
57
59
 
@@ -36,7 +36,9 @@ const StackWrapGap = /*#__PURE__*/forwardRef((_ref, ref) => {
36
36
  viewport
37
37
  });
38
38
  const flexStyles = selectFlexStyles(themeTokens);
39
- const selectedProps = selectProps({ ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
39
+ const selectedProps = selectProps({
40
+ accessibilityRole,
41
+ ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
40
42
  ...rest
41
43
  });
42
44
  const size = useSpacingScale(space);
@@ -45,9 +45,7 @@ export function applyTextStyles(_ref) {
45
45
  // Don't set undefined font families. May need some validation here that the font is available.
46
46
  // Android doesn't recognise font weights natively so apply custom font weights via `fontFamily`.
47
47
  styles.fontFamily = "".concat(fontName).concat(fontWeight).concat(fontStyle);
48
- }
49
-
50
- if (fontWeight) {
48
+ } else if (fontWeight) {
51
49
  // If using system default font, apply the font weight directly.
52
50
  // Font weight support in Android is limited to 'bold' or anything else === 'normal'.
53
51
  styles.fontWeight = Platform.OS === 'android' && Number(fontWeight) > 400 ? 'bold' : fontWeight;