@telus-uds/components-base 1.70.0 → 1.71.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.
@@ -265,21 +265,11 @@ const Autocomplete = /*#__PURE__*/forwardRef((_ref2, ref) => {
265
265
  }, [nestedSelectedValue, items]);
266
266
  const handleClose = event => {
267
267
  var _openOverlayRef$curre, _openOverlayRef$curre2;
268
- if (event.type === 'keydown') {
269
- if (event.key === 'Escape' || event.key === 27) {
270
- setIsExpanded(false);
271
- setNestedSelectedValue(null);
272
- } else if (event.key === 'ArrowDown' && isExpanded && !isLoading && targetRef !== null && targetRef !== void 0 && targetRef.current) {
273
- targetRef.current.focus();
274
- }
275
- } else if (event.type === 'click' && openOverlayRef !== null && openOverlayRef !== void 0 && openOverlayRef.current && event.target && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre = openOverlayRef.current) !== null && _openOverlayRef$curre !== void 0 && _openOverlayRef$curre.contains(event.target))) {
276
- setIsExpanded(false);
277
- } else if (event.type === 'touchstart' && openOverlayRef !== null && openOverlayRef !== void 0 && openOverlayRef.current && event.touches[0].target && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre2 = openOverlayRef.current) !== null && _openOverlayRef$curre2 !== void 0 && _openOverlayRef$curre2.contains(event.touches[0].target))) {
278
- setIsExpanded(false);
279
- } else if (Platform.OS === 'web') {
280
- // needed for dropdown to be collapsed when clicking outside on web
268
+ if (event.type === 'keydown' && (event.key === 'Escape' || event.key === '27') || event.type === 'click' && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre = openOverlayRef.current) !== null && _openOverlayRef$curre !== void 0 && _openOverlayRef$curre.contains(event.target)) || event.type === 'touchstart' && openOverlayRef !== null && openOverlayRef !== void 0 && openOverlayRef.current && event.touches[0].target && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre2 = openOverlayRef.current) !== null && _openOverlayRef$curre2 !== void 0 && _openOverlayRef$curre2.contains(event.touches[0].target))) {
281
269
  setIsExpanded(false);
282
270
  setNestedSelectedValue(null);
271
+ } else if (event.type === 'keydown' && event.key === 'ArrowDown' && isExpanded && !isLoading && targetRef !== null && targetRef !== void 0 && targetRef.current) {
272
+ targetRef.current.focus();
283
273
  }
284
274
  };
285
275
  const itemsToShow = currentValue ? itemsToSuggest(highlight(isControlled ? items : currentItems, currentValue, resultsTextColor)) : [];
@@ -1,11 +1,15 @@
1
1
  import React, { forwardRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { useThemeTokens } from '../ThemeProvider';
3
+ import View from "react-native-web/dist/exports/View";
4
+ import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider';
4
5
  import { getTokensPropType, variantProp } from '../utils';
5
6
  import { useViewport } from '../ViewportProvider';
6
7
  import { a11yProps, selectSystemProps, viewProps } from '../utils/props';
7
8
  import CardBase from './CardBase';
9
+ import PressableCardBase from './PressableCardBase';
8
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { Fragment as _Fragment } from "react/jsx-runtime";
12
+ import { jsxs as _jsxs } from "react/jsx-runtime";
9
13
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
10
14
 
11
15
  /**
@@ -62,25 +66,84 @@ const Card = /*#__PURE__*/forwardRef((_ref, ref) => {
62
66
  tokens,
63
67
  variant,
64
68
  dataSet,
69
+ onPress,
70
+ interactiveCard,
65
71
  ...rest
66
72
  } = _ref;
67
73
  const viewport = useViewport();
68
74
  const themeTokens = useThemeTokens('Card', tokens, variant, {
69
75
  viewport
70
76
  });
71
- return /*#__PURE__*/_jsx(CardBase, {
72
- ref: ref,
73
- tokens: themeTokens,
74
- dataSet: dataSet,
75
- ...selectProps(rest),
76
- children: children
77
+ const getThemeTokens = useThemeTokensCallback('Card', interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.tokens, {
78
+ interactive: true,
79
+ ...((interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.variant) || {})
80
+ });
81
+ // When interactive area is present, spacing tokens should only be applied
82
+ // to individual Card sections, not Card as a whole
83
+ const {
84
+ paddingTop,
85
+ paddingBottom,
86
+ paddingLeft,
87
+ paddingRight,
88
+ ...restOfTokens
89
+ } = themeTokens;
90
+ return /*#__PURE__*/_jsx(_Fragment, {
91
+ children: /*#__PURE__*/_jsx(CardBase, {
92
+ ref: ref,
93
+ tokens: interactiveCard !== null && interactiveCard !== void 0 && interactiveCard.body ? restOfTokens : themeTokens,
94
+ dataSet: dataSet,
95
+ ...selectProps(rest),
96
+ children: interactiveCard !== null && interactiveCard !== void 0 && interactiveCard.body ? /*#__PURE__*/_jsxs(_Fragment, {
97
+ children: [/*#__PURE__*/_jsx(PressableCardBase, {
98
+ ref: ref,
99
+ tokens: getThemeTokens,
100
+ dataSet: dataSet,
101
+ onPress: onPress,
102
+ ...selectProps(rest),
103
+ children: interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.body
104
+ }), children ? /*#__PURE__*/_jsx(View, {
105
+ style: {
106
+ paddingTop,
107
+ paddingBottom,
108
+ paddingLeft,
109
+ paddingRight
110
+ },
111
+ children: children
112
+ }) : null]
113
+ }) : children
114
+ })
77
115
  });
78
116
  });
79
117
  Card.displayName = 'Card';
80
118
  Card.propTypes = {
81
119
  ...selectedSystemPropTypes,
120
+ /**
121
+ * Card content.
122
+ */
82
123
  children: PropTypes.node,
124
+ /**
125
+ * Card tokens.
126
+ */
83
127
  tokens: getTokensPropType('Card'),
84
- variant: variantProp.propType
128
+ /**
129
+ * Card variant.
130
+ */
131
+ variant: variantProp.propType,
132
+ /**
133
+ * Function to call on pressing the card.
134
+ * Note: This is only available when `interactiveCard` prop is used.
135
+ */
136
+ onPress: PropTypes.func,
137
+ /**
138
+ * Object to set interactive card's properties
139
+ * - body: The body of the interactive card, can be any renderable node
140
+ * - tokens: The tokens to be used for the interactive card
141
+ * - variant: The variant to be used for the interactive card
142
+ */
143
+ interactiveCard: PropTypes.shape({
144
+ body: PropTypes.node,
145
+ tokens: getTokensPropType('Card'),
146
+ variant: variantProp.propType
147
+ })
85
148
  };
86
149
  export default Card;
@@ -28,6 +28,7 @@ const PressableCardBase = /*#__PURE__*/forwardRef((_ref, ref) => {
28
28
  inactive,
29
29
  href,
30
30
  hrefAttrs,
31
+ dataSet,
31
32
  accessibilityRole = href ? 'link' : undefined,
32
33
  ...rawRest
33
34
  } = _ref;
@@ -87,6 +88,7 @@ const PressableCardBase = /*#__PURE__*/forwardRef((_ref, ref) => {
87
88
  onKeyDown: handleKeyDown,
88
89
  hrefAttrs: hrefAttrs,
89
90
  style: getOuterBorderStyle,
91
+ dataSet: dataSet,
90
92
  ...selectProps({
91
93
  ...rest,
92
94
  accessibilityRole
@@ -1,12 +1,9 @@
1
1
  import React, { forwardRef, useContext } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Platform from "react-native-web/dist/exports/Platform";
4
- import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
- import { viewports } from '@telus-uds/system-constants';
6
4
  import GutterContext from '../providers/GutterContext';
7
- import { useViewport } from '../../ViewportProvider';
8
5
  import applyInheritance from '../helpers';
9
- import { responsiveProps, BaseView } from '../../utils';
6
+ import { responsiveProps, BaseView, StyleSheet, createMediaQueryStyles } from '../../utils';
10
7
  import { jsx as _jsx } from "react/jsx-runtime";
11
8
  const Col = /*#__PURE__*/forwardRef((_ref, ref) => {
12
9
  let {
@@ -26,7 +23,6 @@ const Col = /*#__PURE__*/forwardRef((_ref, ref) => {
26
23
  ...viewProps
27
24
  } = _ref;
28
25
  const gutter = useContext(GutterContext);
29
- const viewPort = useViewport();
30
26
  const hiddenLevels = applyInheritance([xs, sm, md, lg, xl]);
31
27
  const getHorizontalAlignLevel = () => {
32
28
  if (typeof horizontalAlign === 'object') {
@@ -67,60 +63,11 @@ const Col = /*#__PURE__*/forwardRef((_ref, ref) => {
67
63
  }
68
64
  return {};
69
65
  };
70
- const sizeStyles = sizes => {
71
- const currViewport = Object.keys(sizes).find(key => key.startsWith(viewPort));
72
- const currSize = sizes[currViewport];
73
- return {
74
- ...calculateWidth(currSize)
75
- };
76
- };
77
- const offsetStyles = offsets => {
78
- const currViewport = Object.keys(offsets).find(key => key.startsWith(viewPort));
79
- const currOffset = offsets[currViewport];
80
- return {
81
- ...calculateOffset(currOffset)
82
- };
83
- };
84
- const gutterPadding = {
85
- paddingLeft: gutter ? 16 : 0,
86
- paddingRight: gutter ? 16 : 0
87
- };
88
- let hidingStyles = {};
89
66
 
90
67
  // TODO: consider setting this to always 'flex' in a major release.
91
68
  // `display: block` is invalid in native apps.
92
69
  // See https://telusdigital.atlassian.net/browse/UDS1-92
93
70
  const shown = !flex && Platform.OS === 'web' ? 'block' : 'flex';
94
- if (viewPort === viewports.xs) {
95
- hidingStyles = {
96
- display: hiddenLevels[0] === 0 ? 'none' : shown,
97
- textAlign: horizontalAlignLevel[0]
98
- };
99
- }
100
- if (viewPort === viewports.sm) {
101
- hidingStyles = {
102
- display: hiddenLevels[1] === 0 ? 'none' : shown,
103
- textAlign: horizontalAlignLevel[1]
104
- };
105
- }
106
- if (viewPort === viewports.md) {
107
- hidingStyles = {
108
- display: hiddenLevels[2] === 0 ? 'none' : shown,
109
- textAlign: horizontalAlignLevel[2]
110
- };
111
- }
112
- if (viewPort === viewports.lg) {
113
- hidingStyles = {
114
- display: hiddenLevels[3] === 0 ? 'none' : shown,
115
- textAlign: horizontalAlignLevel[3]
116
- };
117
- }
118
- if (viewPort === viewports.xl) {
119
- hidingStyles = {
120
- display: hiddenLevels[4] === 0 ? 'none' : shown,
121
- textAlign: horizontalAlignLevel[4]
122
- };
123
- }
124
71
  const sizesArray = [xs, sm, md, lg, xl];
125
72
  const offSetsArray = [xsOffset, smOffset, mdOffset, lgOffset, xlOffset];
126
73
  const sizesWithIheritance = applyInheritance(sizesArray);
@@ -139,24 +86,63 @@ const Col = /*#__PURE__*/forwardRef((_ref, ref) => {
139
86
  lg: offsetsWithIheritance[3],
140
87
  xl: offsetsWithIheritance[4]
141
88
  };
89
+ const mediaQueryStyles = createMediaQueryStyles({
90
+ xs: {
91
+ display: hiddenLevels[0] === 0 ? 'none' : shown,
92
+ textAlign: horizontalAlignLevel[0],
93
+ ...calculateWidth(sizes.xs),
94
+ ...calculateOffset(offsets.xs)
95
+ },
96
+ sm: {
97
+ display: hiddenLevels[1] === 0 ? 'none' : shown,
98
+ textAlign: horizontalAlignLevel[1],
99
+ ...calculateWidth(sizes.sm),
100
+ ...calculateOffset(offsets.sm)
101
+ },
102
+ md: {
103
+ display: hiddenLevels[2] === 0 ? 'none' : shown,
104
+ textAlign: horizontalAlignLevel[2],
105
+ ...calculateWidth(sizes.md),
106
+ ...calculateOffset(offsets.md)
107
+ },
108
+ lg: {
109
+ display: hiddenLevels[3] === 0 ? 'none' : shown,
110
+ textAlign: horizontalAlignLevel[3],
111
+ ...calculateWidth(sizes.lg),
112
+ ...calculateOffset(offsets.lg)
113
+ },
114
+ xl: {
115
+ display: hiddenLevels[4] === 0 ? 'none' : shown,
116
+ textAlign: horizontalAlignLevel[4],
117
+ ...calculateWidth(sizes.xl),
118
+ ...calculateOffset(offsets.xl)
119
+ }
120
+ });
121
+ const {
122
+ ids,
123
+ styles
124
+ } = StyleSheet.create({
125
+ col: {
126
+ flexGrow: 1,
127
+ flexShrink: 0,
128
+ flexBasis: 'auto',
129
+ maxWidth: '100%',
130
+ paddingLeft: gutter ? 16 : 0,
131
+ paddingRight: gutter ? 16 : 0,
132
+ ...mediaQueryStyles
133
+ }
134
+ });
142
135
  return /*#__PURE__*/_jsx(BaseView, {
143
136
  ref: ref,
144
137
  ...viewProps,
145
- style: [styles.col, gutterPadding, offsetStyles(offsets), sizeStyles(sizes), {
146
- ...hidingStyles
147
- }],
138
+ style: [styles.col],
139
+ dataSet: {
140
+ media: ids.col
141
+ },
148
142
  children: children
149
143
  });
150
144
  });
151
145
  Col.displayName = 'Col';
152
- const styles = StyleSheet.create({
153
- col: {
154
- flexGrow: 1,
155
- flexShrink: 0,
156
- flexBasis: 'auto',
157
- maxWidth: '100%'
158
- }
159
- });
160
146
 
161
147
  /*
162
148
  * We're disabling default props since passing undefined props to
@@ -1,11 +1,9 @@
1
1
  import React, { forwardRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import StyleSheet from "react-native-web/dist/exports/StyleSheet";
4
3
  import { viewports } from '@telus-uds/system-constants';
5
- import { a11yProps, viewProps, getA11yPropsFromHtmlTag, layoutTags, selectSystemProps, BaseView } from '../utils';
4
+ import { a11yProps, viewProps, getA11yPropsFromHtmlTag, layoutTags, selectSystemProps, BaseView, StyleSheet, createMediaQueryStyles } from '../utils';
6
5
  import Row from './Row';
7
6
  import Col from './Col';
8
- import { useViewport } from '../ViewportProvider';
9
7
  import GutterContext from './providers/GutterContext';
10
8
  import applyInheritance from './helpers';
11
9
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -30,33 +28,40 @@ const FlexGrid = /*#__PURE__*/forwardRef((_ref, ref) => {
30
28
  children,
31
29
  ...rest
32
30
  } = _ref;
33
- const viewPort = useViewport();
34
31
  const reverseLevel = applyInheritance([xsReverse, smReverse, mdReverse, lgReverse, xlReverse]);
35
- const marginVertical = 0;
36
- const marginHorizontal = outsideGutter ? 'auto' : -16;
37
- const width = outsideGutter ? '100%' : 'auto';
38
- let flexDirection;
39
- let maxWidth;
40
- if (viewPort === viewports.xs) {
41
- // no maxWidth for xs
42
- flexDirection = reverseLevel[0] ? 'column-reverse' : 'column';
43
- }
44
- if (viewPort === viewports.sm) {
45
- maxWidth = limitWidth && viewports.map.get(viewports.sm);
46
- flexDirection = reverseLevel[1] ? 'column-reverse' : 'column';
47
- }
48
- if (viewPort === viewports.md) {
49
- maxWidth = limitWidth && viewports.map.get(viewports.md);
50
- flexDirection = reverseLevel[2] ? 'column-reverse' : 'column';
51
- }
52
- if (viewPort === viewports.lg) {
53
- maxWidth = limitWidth && viewports.map.get(viewports.lg);
54
- flexDirection = reverseLevel[3] ? 'column-reverse' : 'column';
55
- }
56
- if (viewPort === viewports.xl) {
57
- maxWidth = limitWidth && viewports.map.get(viewports.xl);
58
- flexDirection = reverseLevel[4] ? 'column-reverse' : 'column';
59
- }
32
+ const mediaQueryStyles = createMediaQueryStyles({
33
+ xs: {
34
+ flexDirection: reverseLevel[0] ? 'column-reverse' : 'column'
35
+ },
36
+ sm: {
37
+ maxWidth: limitWidth && viewports.map.get('sm'),
38
+ flexDirection: reverseLevel[1] ? 'column-reverse' : 'column'
39
+ },
40
+ md: {
41
+ maxWidth: limitWidth && viewports.map.get('md'),
42
+ flexDirection: reverseLevel[2] ? 'column-reverse' : 'column'
43
+ },
44
+ lg: {
45
+ maxWidth: limitWidth && viewports.map.get('lg'),
46
+ flexDirection: reverseLevel[3] ? 'column-reverse' : 'column'
47
+ },
48
+ xl: {
49
+ maxWidth: limitWidth && viewports.map.get('xl'),
50
+ flexDirection: reverseLevel[4] ? 'column-reverse' : 'column'
51
+ }
52
+ });
53
+ const {
54
+ ids,
55
+ styles
56
+ } = StyleSheet.create({
57
+ flexgrid: {
58
+ flexWrap: 'wrap',
59
+ width: outsideGutter ? '100%' : 'auto',
60
+ marginVertical: 0,
61
+ marginHorizontal: outsideGutter ? 'auto' : -16,
62
+ ...mediaQueryStyles
63
+ }
64
+ });
60
65
  const props = {
61
66
  accessibilityRole,
62
67
  ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
@@ -67,23 +72,15 @@ const FlexGrid = /*#__PURE__*/forwardRef((_ref, ref) => {
67
72
  children: /*#__PURE__*/_jsx(BaseView, {
68
73
  ref: ref,
69
74
  ...props,
70
- style: [styles.grid, {
71
- marginHorizontal,
72
- marginVertical,
73
- width,
74
- flexDirection,
75
- maxWidth
76
- }],
75
+ style: [styles.flexgrid],
76
+ dataSet: {
77
+ media: ids.flexgrid
78
+ },
77
79
  children: children
78
80
  })
79
81
  });
80
82
  });
81
83
  FlexGrid.displayName = 'FlexGrid';
82
- const styles = StyleSheet.create({
83
- grid: {
84
- flexWrap: 'wrap'
85
- }
86
- });
87
84
  FlexGrid.propTypes = {
88
85
  ...selectedSystemPropTypes,
89
86
  /**
@@ -1,10 +1,7 @@
1
1
  import React, { forwardRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import StyleSheet from "react-native-web/dist/exports/StyleSheet";
4
- import { viewports } from '@telus-uds/system-constants';
5
- import { useViewport } from '../../ViewportProvider';
6
3
  import applyInheritance from '../helpers';
7
- import { BaseView } from '../../utils';
4
+ import { BaseView, StyleSheet, createMediaQueryStyles } from '../../utils';
8
5
  import { jsx as _jsx } from "react/jsx-runtime";
9
6
  const horizontalAlignStyles = horizontalAlign => {
10
7
  switch (horizontalAlign) {
@@ -72,55 +69,57 @@ const Row = /*#__PURE__*/forwardRef((_ref, ref) => {
72
69
  children,
73
70
  ...rest
74
71
  } = _ref;
75
- const viewPort = useViewport();
76
72
  const reverseLevel = applyInheritance([xsReverse, smReverse, mdReverse, lgReverse, xlReverse]);
77
- let flexDirection = '';
78
- let flexWrap = '';
79
- if (viewPort === viewports.xs) {
80
- flexDirection = reverseLevel[0] ? 'row-reverse' : 'row';
81
- flexWrap = reverseLevel[0] ? 'wrap-reverse' : 'wrap';
82
- }
83
- if (viewPort === viewports.sm) {
84
- flexDirection = reverseLevel[1] ? 'row-reverse' : 'row';
85
- flexWrap = reverseLevel[1] ? 'wrap-reverse' : 'wrap';
86
- }
87
- if (viewPort === viewports.md) {
88
- flexDirection = reverseLevel[2] ? 'row-reverse' : 'row';
89
- flexWrap = reverseLevel[2] ? 'wrap-reverse' : 'wrap';
90
- }
91
- if (viewPort === viewports.lg) {
92
- flexDirection = reverseLevel[3] ? 'row-reverse' : 'row';
93
- flexWrap = reverseLevel[3] ? 'wrap-reverse' : 'wrap';
94
- }
95
- if (viewPort === viewports.xl) {
96
- flexDirection = reverseLevel[4] ? 'row-reverse' : 'row';
97
- flexWrap = reverseLevel[4] ? 'wrap-reverse' : 'wrap';
98
- }
73
+ const mediaQueryStyles = createMediaQueryStyles({
74
+ xs: {
75
+ flexDirection: reverseLevel[0] ? 'row-reverse' : 'row',
76
+ flexWrap: reverseLevel[0] ? 'wrap-reverse' : 'wrap'
77
+ },
78
+ sm: {
79
+ flexDirection: reverseLevel[1] ? 'row-reverse' : 'row',
80
+ flexWrap: reverseLevel[1] ? 'wrap-reverse' : 'wrap'
81
+ },
82
+ md: {
83
+ flexDirection: reverseLevel[2] ? 'row-reverse' : 'row',
84
+ flexWrap: reverseLevel[2] ? 'wrap-reverse' : 'wrap'
85
+ },
86
+ lg: {
87
+ flexDirection: reverseLevel[3] ? 'row-reverse' : 'row',
88
+ flexWrap: reverseLevel[3] ? 'wrap-reverse' : 'wrap'
89
+ },
90
+ xl: {
91
+ flexDirection: reverseLevel[4] ? 'row-reverse' : 'row',
92
+ flexWrap: reverseLevel[4] ? 'wrap-reverse' : 'wrap'
93
+ }
94
+ });
95
+ const {
96
+ ids,
97
+ styles
98
+ } = StyleSheet.create({
99
+ row: {
100
+ width: '100%',
101
+ marginVertical: 0,
102
+ marginHorizontal: 'auto',
103
+ flexGrow: 0,
104
+ flexShrink: 1,
105
+ flexBasis: 'auto',
106
+ ...horizontalAlignStyles(horizontalAlign),
107
+ ...verticalAlignStyles(verticalAlign),
108
+ ...distributeStyles(distribute),
109
+ ...mediaQueryStyles
110
+ }
111
+ });
99
112
  return /*#__PURE__*/_jsx(BaseView, {
100
113
  ref: ref,
101
114
  ...rest,
102
- style: [styles.row, {
103
- flexDirection,
104
- flexWrap,
105
- ...horizontalAlignStyles(horizontalAlign),
106
- ...verticalAlignStyles(verticalAlign),
107
- ...distributeStyles(distribute)
108
- }],
115
+ style: [styles.row],
116
+ dataSet: {
117
+ media: ids.row
118
+ },
109
119
  children: children
110
120
  });
111
121
  });
112
122
  Row.displayName = 'Row';
113
- const styles = StyleSheet.create({
114
- row: {
115
- width: '100%',
116
- marginVertical: 0,
117
- marginHorizontal: 'auto',
118
- flexGrow: 0,
119
- flexShrink: 1,
120
- flexBasis: 'auto',
121
- flexDirection: 'row'
122
- }
123
- });
124
123
  Row.propTypes = {
125
124
  /**
126
125
  * Align columns horizontally within their row.
@@ -16,7 +16,7 @@ import { spacingProps } from '../utils';
16
16
  */
17
17
  import { jsx as _jsx } from "react/jsx-runtime";
18
18
  const IconText = /*#__PURE__*/forwardRef((_ref, ref) => {
19
- var _iconProps$tokens;
19
+ var _iconProps$tokens, _iconProps$tokens2;
20
20
  let {
21
21
  space,
22
22
  iconPosition = 'left',
@@ -34,6 +34,13 @@ const IconText = /*#__PURE__*/forwardRef((_ref, ref) => {
34
34
  // Inline images on Android are always baseline-aligned which makes them look misaligned - offset it.
35
35
  // See abandoned issue https://github.com/facebook/react-native/issues/6529
36
36
  const size = (iconProps === null || iconProps === void 0 ? void 0 : (_iconProps$tokens = iconProps.tokens) === null || _iconProps$tokens === void 0 ? void 0 : _iconProps$tokens.size) ?? 0;
37
+ const valueTranslateY = iconProps === null || iconProps === void 0 ? void 0 : (_iconProps$tokens2 = iconProps.tokens) === null || _iconProps$tokens2 === void 0 ? void 0 : _iconProps$tokens2.translateY;
38
+ /**
39
+ * These calculations were carried out using a set of linear equations to calculate that the
40
+ * position of the icon "->"" is aligned to the first line of the tooltip text on IOS and Android.
41
+ * The issue was mainly on IOS, the translateY style didn't match with the old calculations.
42
+ */
43
+ const resultY = valueTranslateY ? Math.floor(-1 * (valueTranslateY - 4)) : 0;
37
44
  const iconAdjustedAndriod = /*#__PURE__*/_jsx(View, {
38
45
  style: {
39
46
  transform: [{
@@ -45,7 +52,7 @@ const IconText = /*#__PURE__*/forwardRef((_ref, ref) => {
45
52
  const iconAdjustedIOS = /*#__PURE__*/_jsx(View, {
46
53
  style: {
47
54
  transform: [{
48
- translateY: size * 0.01
55
+ translateY: valueTranslateY ? resultY : size * 0.01
49
56
  }]
50
57
  },
51
58
  children: iconContent
@@ -91,13 +91,20 @@ const selectIconTokens = _ref5 => {
91
91
  let {
92
92
  color,
93
93
  iconSize,
94
- iconTranslateX,
95
- iconTranslateY
94
+ blockFontSize,
95
+ iconTranslateX
96
96
  } = _ref5;
97
+ /**
98
+ * These calculations were carried out using a set of linear equations to calculate that the
99
+ * position of the icon "->"" is aligned to the first line of the tooltip text.
100
+ * The base equation is: X/4 + Y/4 - 4 - |X - Y| = Z
101
+ * where X = blockFontSize, Y = iconSize and Z = translateY
102
+ */
103
+ const translateY = blockFontSize / 4 + iconSize / 4 - 4 - Math.abs(iconSize - blockFontSize);
97
104
  return {
98
105
  color,
99
106
  translateX: iconTranslateX,
100
- translateY: iconTranslateY,
107
+ translateY: translateY < 0 ? 0 : translateY,
101
108
  size: iconSize
102
109
  };
103
110
  };
@@ -1,6 +1,16 @@
1
1
  import React from 'react';
2
2
  import Platform from "react-native-web/dist/exports/Platform";
3
3
  const rules = {};
4
+ let styleSheet;
5
+ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
6
+ styleSheet = (() => {
7
+ const style = document.createElement('style');
8
+ style.id = 'RNMQCSS';
9
+ style.appendChild(document.createTextNode(''));
10
+ document.head.appendChild(style);
11
+ return style.sheet;
12
+ })();
13
+ }
4
14
  export const hasCss = (id, text) => {
5
15
  var _rules$id$text, _rules$id$text$includ;
6
16
  return !!rules[id] && !!((_rules$id$text = rules[id].text) !== null && _rules$id$text !== void 0 && (_rules$id$text$includ = _rules$id$text.includes) !== null && _rules$id$text$includ !== void 0 && _rules$id$text$includ.call(_rules$id$text, text));
@@ -10,6 +20,9 @@ export const addCss = (id, text) => {
10
20
  var _rules$id;
11
21
  rules[id] = (rules === null || rules === void 0 ? void 0 : rules[id]) || {};
12
22
  rules[id].text = (((_rules$id = rules[id]) === null || _rules$id === void 0 ? void 0 : _rules$id.text) || '') + text;
23
+ if (styleSheet) {
24
+ styleSheet.insertRule(text, Object.keys(rules).length - 1);
25
+ }
13
26
  }
14
27
  };
15
28
  export const flush = () => {
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "@floating-ui/react-native": "^0.8.1",
12
12
  "@gorhom/portal": "^1.0.14",
13
13
  "@telus-uds/system-constants": "^1.3.0",
14
- "@telus-uds/system-theme-tokens": "^2.46.0",
14
+ "@telus-uds/system-theme-tokens": "^2.47.0",
15
15
  "airbnb-prop-types": "^2.16.0",
16
16
  "css-mediaquery": "^0.1.2",
17
17
  "lodash.debounce": "^4.0.8",
@@ -74,5 +74,5 @@
74
74
  "standard-engine": {
75
75
  "skip": true
76
76
  },
77
- "version": "1.70.0"
77
+ "version": "1.71.0"
78
78
  }