@telus-uds/components-base 1.69.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +21 -2
  2. package/jest.setup.js +7 -0
  3. package/lib/Autocomplete/Autocomplete.js +3 -13
  4. package/lib/Card/Card.js +68 -7
  5. package/lib/Card/PressableCardBase.js +2 -0
  6. package/lib/FlexGrid/Col/Col.js +50 -64
  7. package/lib/FlexGrid/FlexGrid.js +37 -40
  8. package/lib/FlexGrid/Row/Row.js +43 -44
  9. package/lib/Icon/IconText.js +9 -2
  10. package/lib/Link/LinkBase.js +10 -3
  11. package/lib/utils/index.js +12 -0
  12. package/lib/utils/ssr-media-query/create-stylesheet.js +76 -0
  13. package/lib/utils/ssr-media-query/hash.js +19 -0
  14. package/lib/utils/ssr-media-query/index.js +19 -0
  15. package/lib/utils/ssr-media-query/utils/common.js +25 -0
  16. package/lib/utils/ssr-media-query/utils/create-declaration-block.js +24 -0
  17. package/lib/utils/ssr-media-query/utils/create-media-query-styles.js +34 -0
  18. package/lib/utils/ssr-media-query/utils/hyphenate-style-name.js +19 -0
  19. package/lib/utils/ssr-media-query/utils/inject.js +49 -0
  20. package/lib/utils/ssr.js +2 -1
  21. package/lib-module/Autocomplete/Autocomplete.js +3 -13
  22. package/lib-module/Card/Card.js +71 -8
  23. package/lib-module/Card/PressableCardBase.js +2 -0
  24. package/lib-module/FlexGrid/Col/Col.js +51 -65
  25. package/lib-module/FlexGrid/FlexGrid.js +38 -41
  26. package/lib-module/FlexGrid/Row/Row.js +44 -45
  27. package/lib-module/Icon/IconText.js +9 -2
  28. package/lib-module/Link/LinkBase.js +10 -3
  29. package/lib-module/utils/index.js +1 -0
  30. package/lib-module/utils/ssr-media-query/create-stylesheet.js +68 -0
  31. package/lib-module/utils/ssr-media-query/hash.js +13 -0
  32. package/lib-module/utils/ssr-media-query/index.js +6 -0
  33. package/lib-module/utils/ssr-media-query/utils/common.js +15 -0
  34. package/lib-module/utils/ssr-media-query/utils/create-declaration-block.js +16 -0
  35. package/lib-module/utils/ssr-media-query/utils/create-media-query-styles.js +30 -0
  36. package/lib-module/utils/ssr-media-query/utils/hyphenate-style-name.js +12 -0
  37. package/lib-module/utils/ssr-media-query/utils/inject.js +39 -0
  38. package/lib-module/utils/ssr.js +3 -1
  39. package/package.json +3 -2
  40. package/src/Autocomplete/Autocomplete.jsx +14 -21
  41. package/src/Card/Card.jsx +73 -11
  42. package/src/Card/PressableCardBase.jsx +2 -0
  43. package/src/FlexGrid/Col/Col.jsx +48 -80
  44. package/src/FlexGrid/FlexGrid.jsx +36 -44
  45. package/src/FlexGrid/Row/Row.jsx +38 -56
  46. package/src/Icon/IconText.jsx +11 -1
  47. package/src/Link/ChevronLink.jsx +1 -0
  48. package/src/Link/LinkBase.jsx +16 -6
  49. package/src/utils/index.js +1 -1
  50. package/src/utils/ssr-media-query/create-stylesheet.js +61 -0
  51. package/src/utils/ssr-media-query/hash.js +16 -0
  52. package/src/utils/ssr-media-query/index.js +8 -0
  53. package/src/utils/ssr-media-query/utils/common.js +20 -0
  54. package/src/utils/ssr-media-query/utils/create-declaration-block.js +21 -0
  55. package/src/utils/ssr-media-query/utils/create-media-query-styles.js +31 -0
  56. package/src/utils/ssr-media-query/utils/hyphenate-style-name.js +15 -0
  57. package/src/utils/ssr-media-query/utils/inject.js +43 -0
  58. package/src/utils/ssr.jsx +3 -1
@@ -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
  };
@@ -4,6 +4,7 @@ export * from './children';
4
4
  export * from './input';
5
5
  export * from './pressability';
6
6
  export * from './props';
7
+ export * from './ssr-media-query';
7
8
  export { default as info } from './info';
8
9
  export { default as useCopy } from './useCopy';
9
10
  export { default as useHash } from './useHash';
@@ -0,0 +1,68 @@
1
+ import mediaQuery from 'css-mediaquery';
2
+ import Dimensions from "react-native-web/dist/exports/Dimensions";
3
+ import Platform from "react-native-web/dist/exports/Platform";
4
+ import { addCss } from './utils/inject';
5
+ import createDeclarationBlock from './utils/create-declaration-block';
6
+ import hash from './hash';
7
+ import { isMediaOrPseudo, isMedia, deepClone, createCssRule } from './utils/common';
8
+ const createStyleSheet = stylesWithQuery => {
9
+ if (!stylesWithQuery) return {
10
+ ids: {},
11
+ styles: {},
12
+ fullStyles: {}
13
+ };
14
+ let cleanStyles;
15
+ let ids = {};
16
+ Object.keys(stylesWithQuery).forEach(key => {
17
+ if (!(stylesWithQuery !== null && stylesWithQuery !== void 0 && stylesWithQuery[key])) return;
18
+ const mediaQueriesAndPseudoClasses = Object.keys(stylesWithQuery[key]).filter(isMediaOrPseudo);
19
+ if (Platform.OS === 'web') {
20
+ cleanStyles = deepClone(stylesWithQuery);
21
+ mediaQueriesAndPseudoClasses.forEach(query => {
22
+ var _ids;
23
+ const css = createDeclarationBlock(stylesWithQuery[key][query]);
24
+ const stringHash = `rnmq-${hash(`${key}${query}${css}`)}`;
25
+ const rule = createCssRule(query, stringHash, css);
26
+ addCss(`${stringHash}`, rule);
27
+ delete cleanStyles[key][query];
28
+ ids = {
29
+ ...ids,
30
+ [key]: `${(_ids = ids) !== null && _ids !== void 0 && _ids[key] ? `${ids[key]} ` : ''}${stringHash}`
31
+ };
32
+ });
33
+ } else {
34
+ cleanStyles = JSON.parse(JSON.stringify(stylesWithQuery));
35
+ mediaQueriesAndPseudoClasses.forEach(str => {
36
+ if (isMedia(str)) {
37
+ const mqStr = str.replace('@media', '');
38
+ const {
39
+ width,
40
+ height
41
+ } = Dimensions.get('window');
42
+ const isMatchingMediaQuery = mediaQuery.match(mqStr, {
43
+ width,
44
+ height,
45
+ orientation: width > height ? 'landscape' : 'portrait',
46
+ 'aspect-ratio': width / height
47
+ });
48
+ if (isMatchingMediaQuery) {
49
+ cleanStyles = {
50
+ ...cleanStyles,
51
+ [key]: {
52
+ ...cleanStyles[key],
53
+ ...stylesWithQuery[key][str]
54
+ }
55
+ };
56
+ }
57
+ }
58
+ delete cleanStyles[key][str];
59
+ });
60
+ }
61
+ });
62
+ return {
63
+ ids,
64
+ styles: cleanStyles,
65
+ fullStyles: stylesWithQuery
66
+ };
67
+ };
68
+ export default createStyleSheet;
@@ -0,0 +1,13 @@
1
+ /* eslint-disable no-bitwise */
2
+ export default function hash(text) {
3
+ if (!text) {
4
+ return '';
5
+ }
6
+ let hashValue = 5381;
7
+ let index = text.length - 1;
8
+ while (index) {
9
+ hashValue = hashValue * 33 ^ text.charCodeAt(index);
10
+ index -= 1;
11
+ }
12
+ return (hashValue >>> 0).toString(16);
13
+ }
@@ -0,0 +1,6 @@
1
+ import createStyleSheet from './create-stylesheet';
2
+ import createMediaQueryStyles from './utils/create-media-query-styles';
3
+ const StyleSheet = {
4
+ create: createStyleSheet
5
+ };
6
+ export { StyleSheet, createMediaQueryStyles };
@@ -0,0 +1,15 @@
1
+ const isMedia = query => query.indexOf('@media') === 0;
2
+ const isPseudo = query => query.indexOf(':') === 0;
3
+ const isMediaOrPseudo = query => isMedia(query) || isPseudo(query);
4
+ const deepClone = obj => JSON.parse(JSON.stringify(obj));
5
+ const createCssRule = (query, stringHash, css) => {
6
+ let rule;
7
+ const dataMediaSelector = `[data-media~="${stringHash}"]`;
8
+ if (isMedia(query)) {
9
+ rule = `${query} {${dataMediaSelector} ${css}}`;
10
+ } else {
11
+ rule = `${dataMediaSelector}${query} ${css}`;
12
+ }
13
+ return rule;
14
+ };
15
+ export { isMedia, isPseudo, isMediaOrPseudo, deepClone, createCssRule };
@@ -0,0 +1,16 @@
1
+ import createReactDOMStyle from 'react-native-web/dist/cjs/exports/StyleSheet/compiler/createReactDOMStyle';
2
+ import prefixStyles from 'react-native-web/dist/cjs/modules/prefixStyles';
3
+ import hyphenateStyleName from './hyphenate-style-name';
4
+ const createDeclarationBlock = style => {
5
+ const domStyle = prefixStyles(createReactDOMStyle(style));
6
+ const declarationsString = Object.keys(domStyle).map(property => {
7
+ const value = domStyle[property];
8
+ const prop = hyphenateStyleName(property);
9
+ if (Array.isArray(value)) {
10
+ return value.map(v => `${prop}:${v}`).join(';');
11
+ }
12
+ return `${prop}:${value} !important`;
13
+ }).sort().join(';');
14
+ return `{${declarationsString};}`;
15
+ };
16
+ export default createDeclarationBlock;
@@ -0,0 +1,30 @@
1
+ import { viewports } from '@telus-uds/system-constants';
2
+
3
+ /**
4
+ * @typedef { Object } CssStyles
5
+ * @typedef { Record<"xs" | "sm" | "md" | "lg" | "xl", CssStyles> } ViewportStyles
6
+ * @typedef { Record<String, CssStyles> } MediaQueryStyles
7
+ */
8
+
9
+ /**
10
+ * Generates media query styles based on specified viewport styles.
11
+ * @param {ViewportStyles} viewportStyles
12
+ * @returns { MediaQueryStyles }
13
+ */
14
+
15
+ function createMediaQueryStyles(viewportStyles) {
16
+ const viewportsArray = Object.keys(viewportStyles);
17
+ const mediaQueries = Object.entries(viewportStyles).reduce((acc, _ref) => {
18
+ let [viewport, styles] = _ref;
19
+ const minWidth = viewports.map.get(viewport);
20
+ const nextViewport = viewportsArray[viewportsArray.indexOf(viewport) + 1];
21
+ const maxWidth = viewports.map.get(nextViewport);
22
+ const mediaQuery = `@media (min-width: ${minWidth}px)${maxWidth ? ` and (max-width: ${maxWidth}px)` : ''}`;
23
+ return {
24
+ ...acc,
25
+ [mediaQuery]: styles
26
+ };
27
+ }, {});
28
+ return mediaQueries;
29
+ }
30
+ export default createMediaQueryStyles;
@@ -0,0 +1,12 @@
1
+ const uppercasePattern = /[A-Z]/g;
2
+ const msPattern = /^ms-/;
3
+ const cache = {};
4
+ const toHyphenLower = match => `-${match.toLowerCase()}`;
5
+ const hyphenateStyleName = name => {
6
+ if (Object.prototype.hasOwnProperty.call(cache, name)) {
7
+ return cache[name];
8
+ }
9
+ const hName = name.replace(uppercasePattern, toHyphenLower);
10
+ return cache[name] === msPattern.test(hName) ? `-${hName}` : hName;
11
+ };
12
+ export default hyphenateStyleName;
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ import Platform from "react-native-web/dist/exports/Platform";
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
+ }
14
+ export const hasCss = (id, text) => {
15
+ var _rules$id$text, _rules$id$text$includ;
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));
17
+ };
18
+ export const addCss = (id, text) => {
19
+ if (!hasCss(id, text)) {
20
+ var _rules$id;
21
+ rules[id] = (rules === null || rules === void 0 ? void 0 : rules[id]) || {};
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
+ }
26
+ }
27
+ };
28
+ export const flush = () => {
29
+ if (Platform.OS === 'web') {
30
+ return /*#__PURE__*/React.createElement('style', {
31
+ id: 'rnmq',
32
+ key: 'rnmq',
33
+ dangerouslySetInnerHTML: {
34
+ __html: Object.keys(rules).map(key => rules[key].text).join('\n')
35
+ }
36
+ });
37
+ }
38
+ return {};
39
+ };
@@ -1,7 +1,9 @@
1
1
  import React from 'react';
2
2
  import AppRegistry from "react-native-web/dist/exports/AppRegistry";
3
+ import { flush } from './ssr-media-query/utils/inject';
3
4
  /** @typedef {import('react').ComponentType} ReactComponent */
4
5
  /** @typedef {import('react').ReactElement} ReactElement */
6
+
5
7
  /**
6
8
  * Returns object with `renderApp` and `getStyles` functions.
7
9
  * Weave these into your app's server-side render process:
@@ -94,7 +96,7 @@ export const ssrStyles = function () {
94
96
  for (var _len = arguments.length, existingStyles = new Array(_len), _key = 0; _key < _len; _key++) {
95
97
  existingStyles[_key] = arguments[_key];
96
98
  }
97
- return [...existingStyles, ...styleGetters.flatMap(getter => getter())];
99
+ return [...existingStyles, ...styleGetters.flatMap(getter => getter()), flush()];
98
100
  }
99
101
  };
100
102
  };
package/package.json CHANGED
@@ -11,8 +11,9 @@
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
+ "css-mediaquery": "^0.1.2",
16
17
  "lodash.debounce": "^4.0.8",
17
18
  "lodash.merge": "^4.6.2",
18
19
  "lodash.throttle": "^4.1.1",
@@ -73,5 +74,5 @@
73
74
  "standard-engine": {
74
75
  "skip": true
75
76
  },
76
- "version": "1.69.0"
77
+ "version": "1.71.0"
77
78
  }
@@ -241,31 +241,24 @@ const Autocomplete = forwardRef(
241
241
  }, [nestedSelectedValue, items])
242
242
 
243
243
  const handleClose = (event) => {
244
- if (event.type === 'keydown') {
245
- if (event.key === 'Escape' || event.key === 27) {
246
- setIsExpanded(false)
247
- setNestedSelectedValue(null)
248
- } else if (event.key === 'ArrowDown' && isExpanded && !isLoading && targetRef?.current) {
249
- targetRef.current.focus()
250
- }
251
- } else if (
252
- event.type === 'click' &&
253
- openOverlayRef?.current &&
254
- event.target &&
255
- !openOverlayRef?.current?.contains(event.target)
244
+ if (
245
+ (event.type === 'keydown' && (event.key === 'Escape' || event.key === '27')) ||
246
+ (event.type === 'click' && !openOverlayRef?.current?.contains(event.target)) ||
247
+ (event.type === 'touchstart' &&
248
+ openOverlayRef?.current &&
249
+ event.touches[0].target &&
250
+ !openOverlayRef?.current?.contains(event.touches[0].target))
256
251
  ) {
257
252
  setIsExpanded(false)
253
+ setNestedSelectedValue(null)
258
254
  } else if (
259
- event.type === 'touchstart' &&
260
- openOverlayRef?.current &&
261
- event.touches[0].target &&
262
- !openOverlayRef?.current?.contains(event.touches[0].target)
255
+ event.type === 'keydown' &&
256
+ event.key === 'ArrowDown' &&
257
+ isExpanded &&
258
+ !isLoading &&
259
+ targetRef?.current
263
260
  ) {
264
- setIsExpanded(false)
265
- } else if (Platform.OS === 'web') {
266
- // needed for dropdown to be collapsed when clicking outside on web
267
- setIsExpanded(false)
268
- setNestedSelectedValue(null)
261
+ targetRef.current.focus()
269
262
  }
270
263
  }
271
264
  const itemsToShow = currentValue