@telus-uds/components-web 2.5.0 → 2.7.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 (36) hide show
  1. package/CHANGELOG.md +36 -2
  2. package/component-docs.json +9 -12
  3. package/lib/Autocomplete/Autocomplete.js +6 -5
  4. package/lib/ExpandCollapseMini/ExpandCollapseMini.js +3 -1
  5. package/lib/Footnote/Footnote.js +6 -2
  6. package/lib/Listbox/ListboxItem.js +3 -2
  7. package/lib/Listbox/ListboxOverlay.js +3 -1
  8. package/lib/NavigationBar/NavigationItem.js +5 -4
  9. package/lib/Table/Table.js +1 -1
  10. package/lib/WebPortal/WebPortal.js +46 -0
  11. package/lib/WebPortal/index.js +13 -0
  12. package/lib/baseExports.js +6 -0
  13. package/lib/index.js +10 -1
  14. package/lib-module/Autocomplete/Autocomplete.js +6 -5
  15. package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +3 -1
  16. package/lib-module/Footnote/Footnote.js +6 -2
  17. package/lib-module/Listbox/ListboxItem.js +3 -2
  18. package/lib-module/Listbox/ListboxOverlay.js +3 -2
  19. package/lib-module/NavigationBar/NavigationItem.js +6 -3
  20. package/lib-module/Table/Table.js +1 -1
  21. package/lib-module/WebPortal/WebPortal.js +35 -0
  22. package/lib-module/WebPortal/index.js +2 -0
  23. package/lib-module/baseExports.js +1 -1
  24. package/lib-module/index.js +1 -0
  25. package/package.json +3 -3
  26. package/src/Autocomplete/Autocomplete.jsx +3 -2
  27. package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +1 -1
  28. package/src/Footnote/Footnote.jsx +6 -2
  29. package/src/Listbox/ListboxItem.jsx +3 -2
  30. package/src/Listbox/ListboxOverlay.jsx +4 -3
  31. package/src/NavigationBar/NavigationItem.jsx +5 -3
  32. package/src/Table/Table.jsx +1 -1
  33. package/src/WebPortal/WebPortal.jsx +36 -0
  34. package/src/WebPortal/index.js +3 -0
  35. package/src/baseExports.js +2 -1
  36. package/src/index.js +1 -0
package/CHANGELOG.md CHANGED
@@ -1,12 +1,46 @@
1
1
  # Change Log - @telus-uds/components-web
2
2
 
3
- This log was last generated on Fri, 02 Jun 2023 00:27:36 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 09 Jun 2023 00:18:16 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 2.7.0
8
+
9
+ Fri, 09 Jun 2023 00:18:16 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - validation prop implemented for the Autocomplete component (35577399+JoshHC@users.noreply.github.com)
14
+ - expand collapse mini variant introduced (akshay.pandey1@telus.com)
15
+ - exporting useSetTheme (srikanthkhari@gmail.com)
16
+ - Make Table fullWidth by default (wlsdud194@hotmail.com)
17
+ - Fixed bullet alignment within ListItemBase (wlsdud194@hotmail.com)
18
+ - Bump @telus-uds/components-base to v1.49.0
19
+ - Bump @telus-uds/system-theme-tokens to v2.31.0
20
+
21
+ ### Patches
22
+
23
+ - Fix mousedown handling in Footnote (6854874+kyletsang@users.noreply.github.com)
24
+ - Fix `NavigationBar`'s `react-router` integration (shahzaibkhalidmalik@outlook.com)
25
+
26
+ ## 2.6.0
27
+
28
+ Tue, 06 Jun 2023 20:46:12 GMT
29
+
30
+ ### Minor changes
31
+
32
+ - allow 'FootnoteLink' to inherit color (kyle.king2@telus.com)
33
+ - Bump @telus-uds/components-base to v1.48.0
34
+ - Bump @telus-uds/system-theme-tokens to v2.30.0
35
+
36
+ ### Patches
37
+
38
+ - Testing: Snapshots updated (oscar.palencia@telus.com)
39
+ - Fix an issue where `Button` may not align as expected in a flex container (shahzaibkhalidmalik@outlook.com)
40
+
7
41
  ## 2.5.0
8
42
 
9
- Fri, 02 Jun 2023 00:27:36 GMT
43
+ Fri, 02 Jun 2023 00:34:55 GMT
10
44
 
11
45
  ### Minor changes
12
46
 
@@ -3100,7 +3100,7 @@
3100
3100
  "props": {
3101
3101
  "fullWidth": {
3102
3102
  "defaultValue": {
3103
- "value": "false",
3103
+ "value": "true",
3104
3104
  "computed": false
3105
3105
  },
3106
3106
  "required": false
@@ -4435,7 +4435,6 @@
4435
4435
  "color": "color",
4436
4436
  "lineHeight": "lineHeight",
4437
4437
  "textAlign": "flexJustifyContent",
4438
- "alignSelf": "flexAlign",
4439
4438
  "fontName": "fontName",
4440
4439
  "fontWeight": "fontWeight",
4441
4440
  "backgroundColor": "color",
@@ -4634,7 +4633,6 @@
4634
4633
  "color": "color",
4635
4634
  "lineHeight": "lineHeight",
4636
4635
  "textAlign": "flexJustifyContent",
4637
- "alignSelf": "flexAlign",
4638
4636
  "fontName": "fontName",
4639
4637
  "fontWeight": "fontWeight",
4640
4638
  "backgroundColor": "color",
@@ -5060,7 +5058,6 @@
5060
5058
  "color": "color",
5061
5059
  "lineHeight": "lineHeight",
5062
5060
  "textAlign": "flexJustifyContent",
5063
- "alignSelf": "flexAlign",
5064
5061
  "fontName": "fontName",
5065
5062
  "fontWeight": "fontWeight",
5066
5063
  "backgroundColor": "color",
@@ -6862,13 +6859,6 @@
6862
6859
  "required": false,
6863
6860
  "description": "Array of the ids of currently open groups"
6864
6861
  },
6865
- "isMiniExpandCollapse": {
6866
- "defaultValue": {
6867
- "value": "false",
6868
- "computed": false
6869
- },
6870
- "required": false
6871
- },
6872
6862
  "variant": {
6873
6863
  "type": {
6874
6864
  "name": "objectOf",
@@ -6973,7 +6963,12 @@
6973
6963
  "paddingBottom": "size",
6974
6964
  "borderWidth": "border",
6975
6965
  "borderColor": "color",
6976
- "backgroundColor": "color"
6966
+ "backgroundColor": "color",
6967
+ "borderTopLeftRadius": "radius",
6968
+ "borderBottomLeftRadius": "radius",
6969
+ "borderTopRightRadius": "radius",
6970
+ "borderBottomRightRadius": "radius",
6971
+ "textLine": "textLine"
6977
6972
  }
6978
6973
  },
6979
6974
  "required": false,
@@ -11078,6 +11073,8 @@
11078
11073
  "name": "custom",
11079
11074
  "raw": {
11080
11075
  "color": "color",
11076
+ "secondColor": "color",
11077
+ "animationDuration": "integer",
11081
11078
  "size": "size",
11082
11079
  "radius": "radius",
11083
11080
  "baseWidth": "size",
@@ -34,10 +34,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
34
34
  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; }
35
35
 
36
36
  /* eslint-disable react/require-default-props */
37
- const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs, _componentsBase.inputSupportsProps, _componentsBase.textInputHandlerProps, _componentsBase.textInputProps]);
38
- const inputTokens = {
39
- paddingLeft: _constants.INPUT_LEFT_PADDING
40
- }; // Returns JSX to display a bold string `str` with unbolded occurrences of the
37
+ const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs, _componentsBase.inputSupportsProps, _componentsBase.textInputHandlerProps, _componentsBase.textInputProps]); // Returns JSX to display a bold string `str` with unbolded occurrences of the
41
38
  // `substring` based in the array of `matchIndexes` provided
42
39
 
43
40
  const highlightAllMatches = function (str) {
@@ -119,7 +116,10 @@ const Autocomplete = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
119
116
 
120
117
  const [currentItems, setCurrentItems] = (0, _react.useState)(initialItems); // We need to store the current value as well to be able to highlight it
121
118
 
122
- const [currentValue, setCurrentValue] = (0, _react.useState)(value ?? initialValue); // Setting up the overlay
119
+ const [currentValue, setCurrentValue] = (0, _react.useState)(value ?? initialValue);
120
+ const inputTokens = {
121
+ paddingLeft: _constants.INPUT_LEFT_PADDING
122
+ }; // Setting up the overlay
123
123
 
124
124
  const openOverlayRef = (0, _react.useRef)();
125
125
  const [isExpanded, setIsExpanded] = (0, _react.useState)(((_ref3 = value ?? initialValue) === null || _ref3 === void 0 ? void 0 : _ref3.length) >= minToSuggestion);
@@ -261,6 +261,7 @@ const Autocomplete = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
261
261
  readOnly: readOnly,
262
262
  ref: inputRef,
263
263
  tokens: inputTokens,
264
+ validation: validation,
264
265
  ...selectedProps,
265
266
  ...props,
266
267
  ...(isControlled ? {
@@ -49,7 +49,9 @@ const ExpandCollapseMini = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
49
49
  onChange: handleChange,
50
50
  children: expandProps => /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.ExpandCollapse.Panel, { ...expandProps,
51
51
  panelId: "ExpandCollapseMiniPanel",
52
- isMiniExpandCollapse: true,
52
+ variant: {
53
+ mini: true
54
+ },
53
55
  controlTokens: {
54
56
  icon: null
55
57
  } // TODO refactor
@@ -354,6 +354,10 @@ const Footnote = props => {
354
354
  const handleClose = (0, _react.useCallback)(event => {
355
355
  var _footnoteRef$current, _footnoteRef$current2;
356
356
 
357
+ if (!isVisible) {
358
+ return;
359
+ }
360
+
357
361
  if (event.type === 'keydown') {
358
362
  if (event.key === 'Escape' || event.key === 27) {
359
363
  closeFootnote(event, {
@@ -369,7 +373,7 @@ const Footnote = props => {
369
373
  returnFocus: false
370
374
  });
371
375
  }
372
- }, [closeFootnote]);
376
+ }, [closeFootnote, isVisible]);
373
377
 
374
378
  const saveCurrentHeight = () => {
375
379
  const oldHeight = contentRef.current.offsetHeight;
@@ -450,7 +454,7 @@ const Footnote = props => {
450
454
 
451
455
  return () => {
452
456
  if (isOpen) {
453
- document.addEventListener('mousedown', handleClose);
457
+ document.removeEventListener('mousedown', handleClose);
454
458
  window.removeEventListener('click', handleClose);
455
459
  window.removeEventListener('keydown', handleClose);
456
460
  window.removeEventListener('touchstart', handleClose);
@@ -93,6 +93,8 @@ const ListboxItem = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
93
93
  prevItemRef,
94
94
  tokens,
95
95
  variant = {},
96
+ LinkRouter,
97
+ linkRouterProps,
96
98
  ...rest
97
99
  } = _ref4;
98
100
  const selectedProps = selectProps(rest);
@@ -128,8 +130,7 @@ ListboxItem.propTypes = { ...selectedSystemPropTypes,
128
130
  nextItemRef: _propTypes.default.object,
129
131
  prevItemRef: _propTypes.default.object,
130
132
  onPress: _propTypes.default.func,
131
- selected: _propTypes.default.bool,
132
- reactRouterLinkComponent: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object])
133
+ selected: _propTypes.default.bool
133
134
  };
134
135
 
135
136
  var _default = (0, _componentsBase.withLinkRouter)(ListboxItem);
@@ -15,6 +15,8 @@ var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Vi
15
15
 
16
16
  var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
17
17
 
18
+ var _WebPortal = _interopRequireDefault(require("../WebPortal"));
19
+
18
20
  var _jsxRuntime = require("react/jsx-runtime");
19
21
 
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -51,7 +53,7 @@ const DropdownOverlay = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
51
53
  onLayout
52
54
  } = _ref;
53
55
  const systemTokens = (0, _componentsBase.useThemeTokens)('ListBox', {}, {});
54
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Portal, {
56
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_WebPortal.default, {
55
57
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
56
58
  ref: ref,
57
59
  onLayout: onLayout,
@@ -63,6 +63,8 @@ const NavigationItem = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
63
63
  href,
64
64
  tokens,
65
65
  variant = {},
66
+ LinkRouter,
67
+ linkRouterProps,
66
68
  ...rest
67
69
  } = _ref2;
68
70
  const selectedProps = selectProps(rest);
@@ -89,6 +91,8 @@ const NavigationItem = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
89
91
  selected
90
92
  },
91
93
  href: href,
94
+ LinkRouter: LinkRouter,
95
+ linkRouterProps: linkRouterProps,
92
96
  ...selectedProps,
93
97
  children: children
94
98
  })
@@ -96,7 +100,6 @@ const NavigationItem = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
96
100
  });
97
101
  NavigationItem.displayName = 'NavigationItem';
98
102
  NavigationItem.propTypes = { ...selectedSystemPropTypes,
99
- ..._componentsBase.withLinkRouter.propTypes,
100
103
  onClick: _propTypes.default.func,
101
104
  selected: _propTypes.default.bool,
102
105
  children: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]).isRequired
@@ -105,7 +108,5 @@ NavigationItem.defaultProps = {
105
108
  onClick: () => {},
106
109
  selected: false
107
110
  };
108
-
109
- var _default = (0, _componentsBase.withLinkRouter)(NavigationItem);
110
-
111
+ var _default = NavigationItem;
111
112
  exports.default = _default;
@@ -66,7 +66,7 @@ exports.useTableContext = useTableContext;
66
66
  const Table = _ref2 => {
67
67
  let {
68
68
  children,
69
- fullWidth = false,
69
+ fullWidth = true,
70
70
  text = 'medium',
71
71
  tokens,
72
72
  variant,
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ var _reactDom = _interopRequireDefault(require("react-dom"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ /**
15
+ * WebPortal component renders its children in a separate portal container appended to the document body.
16
+ *
17
+ * While `@gorhom/portal` works well for a lot of use-cases, there are some issues with it, particularly around
18
+ * reading context values (see issues below). For web-only components, it is safe to replace `Portal` from `@gorhom/portal`
19
+ * to `WebPortal` to solve such issues
20
+ *
21
+ * https://github.com/gorhom/react-native-portal/issues/34
22
+ * https://github.com/gorhom/react-native-portal/issues/2
23
+ * https://github.com/gorhom/react-native-portal/issues/3
24
+ * https://github.com/gorhom/react-native-portal/issues/31
25
+ *
26
+ * @component
27
+ * @param {object} props - The component props.
28
+ * @param {React.ReactNode} props.children - The content to render within the portal.
29
+ * @returns {React.ReactPortal} The React portal component.
30
+ */
31
+ const WebPortal = _ref => {
32
+ let {
33
+ children
34
+ } = _ref;
35
+ const portalContainer = document.createElement('div');
36
+ (0, _react.useEffect)(() => {
37
+ document.body.appendChild(portalContainer);
38
+ return () => {
39
+ document.body.removeChild(portalContainer);
40
+ };
41
+ }, [portalContainer]);
42
+ return /*#__PURE__*/_reactDom.default.createPortal(children, portalContainer);
43
+ };
44
+
45
+ var _default = WebPortal;
46
+ exports.default = _default;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _WebPortal = _interopRequireDefault(require("./WebPortal"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ var _default = _WebPortal.default;
13
+ exports.default = _default;
@@ -345,6 +345,12 @@ Object.defineProperty(exports, "useResponsiveProp", {
345
345
  return _componentsBase.useResponsiveProp;
346
346
  }
347
347
  });
348
+ Object.defineProperty(exports, "useSetTheme", {
349
+ enumerable: true,
350
+ get: function () {
351
+ return _componentsBase.useSetTheme;
352
+ }
353
+ });
348
354
  Object.defineProperty(exports, "useViewport", {
349
355
  enumerable: true,
350
356
  get: function () {
package/lib/index.js CHANGED
@@ -43,7 +43,8 @@ var _exportNames = {
43
43
  TermsAndConditions: true,
44
44
  NavigationBar: true,
45
45
  Progress: true,
46
- SkeletonProvider: true
46
+ SkeletonProvider: true,
47
+ WebPortal: true
47
48
  };
48
49
  Object.defineProperty(exports, "Autocomplete", {
49
50
  enumerable: true,
@@ -267,6 +268,12 @@ Object.defineProperty(exports, "WaffleGrid", {
267
268
  return _WaffleGrid.default;
268
269
  }
269
270
  });
271
+ Object.defineProperty(exports, "WebPortal", {
272
+ enumerable: true,
273
+ get: function () {
274
+ return _WebPortal.default;
275
+ }
276
+ });
270
277
  Object.defineProperty(exports, "WebVideo", {
271
278
  enumerable: true,
272
279
  get: function () {
@@ -364,6 +371,8 @@ var _Progress = _interopRequireDefault(require("./Progress"));
364
371
 
365
372
  var _SkeletonProvider = _interopRequireDefault(require("./SkeletonProvider"));
366
373
 
374
+ var _WebPortal = _interopRequireDefault(require("./WebPortal"));
375
+
367
376
  var _baseExports = require("./baseExports");
368
377
 
369
378
  Object.keys(_baseExports).forEach(function (key) {
@@ -12,10 +12,7 @@ import dictionary from './dictionary';
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
- const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs, inputSupportsProps, textInputHandlerProps, textInputProps]);
16
- const inputTokens = {
17
- paddingLeft: INPUT_LEFT_PADDING
18
- }; // Returns JSX to display a bold string `str` with unbolded occurrences of the
15
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs, inputSupportsProps, textInputHandlerProps, textInputProps]); // Returns JSX to display a bold string `str` with unbolded occurrences of the
19
16
  // `substring` based in the array of `matchIndexes` provided
20
17
 
21
18
  const highlightAllMatches = function (str) {
@@ -97,7 +94,10 @@ const Autocomplete = /*#__PURE__*/forwardRef((_ref2, ref) => {
97
94
 
98
95
  const [currentItems, setCurrentItems] = useState(initialItems); // We need to store the current value as well to be able to highlight it
99
96
 
100
- const [currentValue, setCurrentValue] = useState(value ?? initialValue); // Setting up the overlay
97
+ const [currentValue, setCurrentValue] = useState(value ?? initialValue);
98
+ const inputTokens = {
99
+ paddingLeft: INPUT_LEFT_PADDING
100
+ }; // Setting up the overlay
101
101
 
102
102
  const openOverlayRef = useRef();
103
103
  const [isExpanded, setIsExpanded] = useState(((_ref3 = value ?? initialValue) === null || _ref3 === void 0 ? void 0 : _ref3.length) >= minToSuggestion);
@@ -239,6 +239,7 @@ const Autocomplete = /*#__PURE__*/forwardRef((_ref2, ref) => {
239
239
  readOnly: readOnly,
240
240
  ref: inputRef,
241
241
  tokens: inputTokens,
242
+ validation: validation,
242
243
  ...selectedProps,
243
244
  ...props,
244
245
  ...(isControlled ? {
@@ -31,7 +31,9 @@ const ExpandCollapseMini = /*#__PURE__*/forwardRef((_ref, ref) => {
31
31
  onChange: handleChange,
32
32
  children: expandProps => /*#__PURE__*/_jsx(ExpandCollapse.Panel, { ...expandProps,
33
33
  panelId: "ExpandCollapseMiniPanel",
34
- isMiniExpandCollapse: true,
34
+ variant: {
35
+ mini: true
36
+ },
35
37
  controlTokens: {
36
38
  icon: null
37
39
  } // TODO refactor
@@ -326,6 +326,10 @@ const Footnote = props => {
326
326
  const handleClose = useCallback(event => {
327
327
  var _footnoteRef$current, _footnoteRef$current2;
328
328
 
329
+ if (!isVisible) {
330
+ return;
331
+ }
332
+
329
333
  if (event.type === 'keydown') {
330
334
  if (event.key === 'Escape' || event.key === 27) {
331
335
  closeFootnote(event, {
@@ -341,7 +345,7 @@ const Footnote = props => {
341
345
  returnFocus: false
342
346
  });
343
347
  }
344
- }, [closeFootnote]);
348
+ }, [closeFootnote, isVisible]);
345
349
 
346
350
  const saveCurrentHeight = () => {
347
351
  const oldHeight = contentRef.current.offsetHeight;
@@ -422,7 +426,7 @@ const Footnote = props => {
422
426
 
423
427
  return () => {
424
428
  if (isOpen) {
425
- document.addEventListener('mousedown', handleClose);
429
+ document.removeEventListener('mousedown', handleClose);
426
430
  window.removeEventListener('click', handleClose);
427
431
  window.removeEventListener('keydown', handleClose);
428
432
  window.removeEventListener('touchstart', handleClose);
@@ -71,6 +71,8 @@ const ListboxItem = /*#__PURE__*/forwardRef((_ref4, ref) => {
71
71
  prevItemRef,
72
72
  tokens,
73
73
  variant = {},
74
+ LinkRouter,
75
+ linkRouterProps,
74
76
  ...rest
75
77
  } = _ref4;
76
78
  const selectedProps = selectProps(rest);
@@ -106,7 +108,6 @@ ListboxItem.propTypes = { ...selectedSystemPropTypes,
106
108
  nextItemRef: PropTypes.object,
107
109
  prevItemRef: PropTypes.object,
108
110
  onPress: PropTypes.func,
109
- selected: PropTypes.bool,
110
- reactRouterLinkComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
111
+ selected: PropTypes.bool
111
112
  };
112
113
  export default withLinkRouter(ListboxItem);
@@ -1,9 +1,10 @@
1
1
  /* eslint-disable react/require-default-props */
2
2
  import React, { forwardRef } from 'react';
3
- import { Card, Portal, useThemeTokens } from '@telus-uds/components-base';
3
+ import { Card, useThemeTokens } from '@telus-uds/components-base';
4
4
  import PropTypes from 'prop-types';
5
5
  import View from "react-native-web/dist/exports/View";
6
6
  import StyleSheet from "react-native-web/dist/exports/StyleSheet";
7
+ import WebPortal from '../WebPortal';
7
8
  import { jsx as _jsx } from "react/jsx-runtime";
8
9
  const staticStyles = StyleSheet.create({
9
10
  positioner: {
@@ -31,7 +32,7 @@ const DropdownOverlay = /*#__PURE__*/forwardRef((_ref, ref) => {
31
32
  onLayout
32
33
  } = _ref;
33
34
  const systemTokens = useThemeTokens('ListBox', {}, {});
34
- return /*#__PURE__*/_jsx(Portal, {
35
+ return /*#__PURE__*/_jsx(WebPortal, {
35
36
  children: /*#__PURE__*/_jsx(View, {
36
37
  ref: ref,
37
38
  onLayout: onLayout,
@@ -1,6 +1,6 @@
1
1
  import React, { forwardRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { Button, selectSystemProps, useResponsiveProp, useViewport, withLinkRouter, useThemeTokensCallback } from '@telus-uds/components-base';
3
+ import { Button, selectSystemProps, useResponsiveProp, useViewport, useThemeTokensCallback } from '@telus-uds/components-base';
4
4
  import styled from 'styled-components';
5
5
  import { htmlAttrs } from '../utils';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -42,6 +42,8 @@ const NavigationItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
42
42
  href,
43
43
  tokens,
44
44
  variant = {},
45
+ LinkRouter,
46
+ linkRouterProps,
45
47
  ...rest
46
48
  } = _ref2;
47
49
  const selectedProps = selectProps(rest);
@@ -68,6 +70,8 @@ const NavigationItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
68
70
  selected
69
71
  },
70
72
  href: href,
73
+ LinkRouter: LinkRouter,
74
+ linkRouterProps: linkRouterProps,
71
75
  ...selectedProps,
72
76
  children: children
73
77
  })
@@ -75,7 +79,6 @@ const NavigationItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
75
79
  });
76
80
  NavigationItem.displayName = 'NavigationItem';
77
81
  NavigationItem.propTypes = { ...selectedSystemPropTypes,
78
- ...withLinkRouter.propTypes,
79
82
  onClick: PropTypes.func,
80
83
  selected: PropTypes.bool,
81
84
  children: PropTypes.oneOfType([PropTypes.string, PropTypes.func]).isRequired
@@ -84,4 +87,4 @@ NavigationItem.defaultProps = {
84
87
  onClick: () => {},
85
88
  selected: false
86
89
  };
87
- export default withLinkRouter(NavigationItem);
90
+ export default NavigationItem;
@@ -39,7 +39,7 @@ export const useTableContext = () => useContext(TableContext);
39
39
  const Table = _ref2 => {
40
40
  let {
41
41
  children,
42
- fullWidth = false,
42
+ fullWidth = true,
43
43
  text = 'medium',
44
44
  tokens,
45
45
  variant,
@@ -0,0 +1,35 @@
1
+ import { useEffect } from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ /**
4
+ * WebPortal component renders its children in a separate portal container appended to the document body.
5
+ *
6
+ * While `@gorhom/portal` works well for a lot of use-cases, there are some issues with it, particularly around
7
+ * reading context values (see issues below). For web-only components, it is safe to replace `Portal` from `@gorhom/portal`
8
+ * to `WebPortal` to solve such issues
9
+ *
10
+ * https://github.com/gorhom/react-native-portal/issues/34
11
+ * https://github.com/gorhom/react-native-portal/issues/2
12
+ * https://github.com/gorhom/react-native-portal/issues/3
13
+ * https://github.com/gorhom/react-native-portal/issues/31
14
+ *
15
+ * @component
16
+ * @param {object} props - The component props.
17
+ * @param {React.ReactNode} props.children - The content to render within the portal.
18
+ * @returns {React.ReactPortal} The React portal component.
19
+ */
20
+
21
+ const WebPortal = _ref => {
22
+ let {
23
+ children
24
+ } = _ref;
25
+ const portalContainer = document.createElement('div');
26
+ useEffect(() => {
27
+ document.body.appendChild(portalContainer);
28
+ return () => {
29
+ document.body.removeChild(portalContainer);
30
+ };
31
+ }, [portalContainer]);
32
+ return /*#__PURE__*/ReactDOM.createPortal(children, portalContainer);
33
+ };
34
+
35
+ export default WebPortal;
@@ -0,0 +1,2 @@
1
+ import WebPortal from './WebPortal';
2
+ export default WebPortal;
@@ -12,4 +12,4 @@ A11yText, ActivityIndicator, Box, Button, BaseProvider, A11yInfoProvider, Viewpo
12
12
  */
13
13
  // Enable access to the viewports system for app-specific responsive layouts and features
14
14
  useResponsiveProp, useViewport, // TODO reenable ViewportContext once published from base // enable localised viewport overrides e.g. in tests, narrow columns, etc
15
- useCarousel } from '@telus-uds/components-base';
15
+ useCarousel, useSetTheme } from '@telus-uds/components-base';
@@ -37,5 +37,6 @@ export { default as TermsAndConditions } from './TermsAndConditions';
37
37
  export { default as NavigationBar } from './NavigationBar';
38
38
  export { default as Progress } from './Progress';
39
39
  export { default as SkeletonProvider } from './SkeletonProvider';
40
+ export { default as WebPortal } from './WebPortal';
40
41
  export { ssrStyles } from './utils';
41
42
  export * from './baseExports';
package/package.json CHANGED
@@ -5,14 +5,14 @@
5
5
  ],
6
6
  "dependencies": {
7
7
  "@gorhom/portal": "^1.0.14",
8
- "@telus-uds/components-base": "1.47.0",
8
+ "@telus-uds/components-base": "1.49.0",
9
9
  "@telus-uds/system-constants": "^1.2.1",
10
10
  "fscreen": "^1.2.0",
11
11
  "lodash.omit": "^4.5.0",
12
12
  "react-dates": "^21.8.0",
13
13
  "react-helmet-async": "^1.3.0",
14
14
  "react-moment-proptypes": "^1.8.1",
15
- "@telus-uds/system-theme-tokens": "^2.29.0",
15
+ "@telus-uds/system-theme-tokens": "^2.31.0",
16
16
  "prop-types": "^15.7.2",
17
17
  "lodash.throttle": "^4.1.1",
18
18
  "react-youtube": "^10.1.0"
@@ -62,5 +62,5 @@
62
62
  "skip": true
63
63
  },
64
64
  "types": "types/index.d.ts",
65
- "version": "2.5.0"
65
+ "version": "2.7.0"
66
66
  }
@@ -32,8 +32,6 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([
32
32
  textInputProps
33
33
  ])
34
34
 
35
- const inputTokens = { paddingLeft: INPUT_LEFT_PADDING }
36
-
37
35
  // Returns JSX to display a bold string `str` with unbolded occurrences of the
38
36
  // `substring` based in the array of `matchIndexes` provided
39
37
  const highlightAllMatches = (str, substring = '', matchIndexes = []) => (
@@ -104,6 +102,8 @@ const Autocomplete = forwardRef(
104
102
  // We need to store the current value as well to be able to highlight it
105
103
  const [currentValue, setCurrentValue] = useState(value ?? initialValue)
106
104
 
105
+ const inputTokens = { paddingLeft: INPUT_LEFT_PADDING }
106
+
107
107
  // Setting up the overlay
108
108
  const openOverlayRef = useRef()
109
109
  const [isExpanded, setIsExpanded] = useState((value ?? initialValue)?.length >= minToSuggestion)
@@ -229,6 +229,7 @@ const Autocomplete = forwardRef(
229
229
  readOnly={readOnly}
230
230
  ref={inputRef}
231
231
  tokens={inputTokens}
232
+ validation={validation}
232
233
  {...selectedProps}
233
234
  {...props}
234
235
  {...(isControlled ? { value } : { initialValue })}
@@ -20,7 +20,7 @@ const ExpandCollapseMini = forwardRef(({ children, onToggle, tokens, ...rest },
20
20
  <ExpandCollapse.Panel
21
21
  {...expandProps}
22
22
  panelId="ExpandCollapseMiniPanel"
23
- isMiniExpandCollapse={true}
23
+ variant={{ mini: true }}
24
24
  controlTokens={{ icon: null }}
25
25
  // TODO refactor
26
26
  // eslint-disable-next-line react/no-unstable-nested-components
@@ -271,6 +271,10 @@ const Footnote = (props) => {
271
271
  // Listen for ESCAPE, close button clicks, and clicks outside of the Footnote. Call onClose.
272
272
  const handleClose = useCallback(
273
273
  (event) => {
274
+ if (!isVisible) {
275
+ return
276
+ }
277
+
274
278
  if (event.type === 'keydown') {
275
279
  if (event.key === 'Escape' || event.key === 27) {
276
280
  closeFootnote(event, { returnFocus: true })
@@ -293,7 +297,7 @@ const Footnote = (props) => {
293
297
  closeFootnote(event, { returnFocus: false })
294
298
  }
295
299
  },
296
- [closeFootnote]
300
+ [closeFootnote, isVisible]
297
301
  )
298
302
 
299
303
  const saveCurrentHeight = () => {
@@ -365,7 +369,7 @@ const Footnote = (props) => {
365
369
  }
366
370
  return () => {
367
371
  if (isOpen) {
368
- document.addEventListener('mousedown', handleClose)
372
+ document.removeEventListener('mousedown', handleClose)
369
373
  window.removeEventListener('click', handleClose)
370
374
  window.removeEventListener('keydown', handleClose)
371
375
  window.removeEventListener('touchstart', handleClose)
@@ -53,6 +53,8 @@ const ListboxItem = forwardRef(
53
53
  prevItemRef,
54
54
  tokens,
55
55
  variant = {},
56
+ LinkRouter,
57
+ linkRouterProps,
56
58
  ...rest
57
59
  },
58
60
  ref
@@ -94,8 +96,7 @@ ListboxItem.propTypes = {
94
96
  nextItemRef: PropTypes.object,
95
97
  prevItemRef: PropTypes.object,
96
98
  onPress: PropTypes.func,
97
- selected: PropTypes.bool,
98
- reactRouterLinkComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
99
+ selected: PropTypes.bool
99
100
  }
100
101
 
101
102
  export default withLinkRouter(ListboxItem)
@@ -1,8 +1,9 @@
1
1
  /* eslint-disable react/require-default-props */
2
2
  import React, { forwardRef } from 'react'
3
- import { Card, Portal, useThemeTokens } from '@telus-uds/components-base'
3
+ import { Card, useThemeTokens } from '@telus-uds/components-base'
4
4
  import PropTypes from 'prop-types'
5
5
  import { View, StyleSheet } from 'react-native-web'
6
+ import WebPortal from '../WebPortal'
6
7
 
7
8
  const staticStyles = StyleSheet.create({
8
9
  positioner: {
@@ -25,7 +26,7 @@ const DropdownOverlay = forwardRef(
25
26
  const systemTokens = useThemeTokens('ListBox', {}, {})
26
27
 
27
28
  return (
28
- <Portal>
29
+ <WebPortal>
29
30
  <View
30
31
  ref={ref}
31
32
  onLayout={onLayout}
@@ -48,7 +49,7 @@ const DropdownOverlay = forwardRef(
48
49
  {children}
49
50
  </Card>
50
51
  </View>
51
- </Portal>
52
+ </WebPortal>
52
53
  )
53
54
  }
54
55
  )
@@ -5,7 +5,6 @@ import {
5
5
  selectSystemProps,
6
6
  useResponsiveProp,
7
7
  useViewport,
8
- withLinkRouter,
9
8
  useThemeTokensCallback
10
9
  } from '@telus-uds/components-base'
11
10
  import styled from 'styled-components'
@@ -41,6 +40,8 @@ const NavigationItem = forwardRef(
41
40
  href,
42
41
  tokens,
43
42
  variant = {},
43
+ LinkRouter,
44
+ linkRouterProps,
44
45
  ...rest
45
46
  },
46
47
  ref
@@ -61,6 +62,8 @@ const NavigationItem = forwardRef(
61
62
  tokens={getStateTokens}
62
63
  variant={{ selected }}
63
64
  href={href}
65
+ LinkRouter={LinkRouter}
66
+ linkRouterProps={linkRouterProps}
64
67
  {...selectedProps}
65
68
  >
66
69
  {children}
@@ -73,11 +76,10 @@ NavigationItem.displayName = 'NavigationItem'
73
76
 
74
77
  NavigationItem.propTypes = {
75
78
  ...selectedSystemPropTypes,
76
- ...withLinkRouter.propTypes,
77
79
  onClick: PropTypes.func,
78
80
  selected: PropTypes.bool,
79
81
  children: PropTypes.oneOfType([PropTypes.string, PropTypes.func]).isRequired
80
82
  }
81
83
  NavigationItem.defaultProps = { onClick: () => {}, selected: false }
82
84
 
83
- export default withLinkRouter(NavigationItem)
85
+ export default NavigationItem
@@ -36,7 +36,7 @@ export const useTableContext = () => useContext(TableContext)
36
36
  * - Use `Table.Row` and `Table.Cell` to build up the tabular data
37
37
  * - Use `Cell`'s `type` prop to visually mark it as a row heading (`type="rowHeading"`)
38
38
  */
39
- const Table = ({ children, fullWidth = false, text = 'medium', tokens, variant, ...rest }) => {
39
+ const Table = ({ children, fullWidth = true, text = 'medium', tokens, variant, ...rest }) => {
40
40
  const { tablePaddingBottom } = useThemeTokens('Table', tokens, variant)
41
41
  const containerRef = useRef()
42
42
  const tableRef = useRef()
@@ -0,0 +1,36 @@
1
+ import { useEffect } from 'react'
2
+ import ReactDOM from 'react-dom'
3
+
4
+ /**
5
+ * WebPortal component renders its children in a separate portal container appended to the document body.
6
+ *
7
+ * While `@gorhom/portal` works well for a lot of use-cases, there are some issues with it, particularly around
8
+ * reading context values (see issues below). For web-only components, it is safe to replace `Portal` from `@gorhom/portal`
9
+ * to `WebPortal` to solve such issues
10
+ *
11
+ * https://github.com/gorhom/react-native-portal/issues/34
12
+ * https://github.com/gorhom/react-native-portal/issues/2
13
+ * https://github.com/gorhom/react-native-portal/issues/3
14
+ * https://github.com/gorhom/react-native-portal/issues/31
15
+ *
16
+ * @component
17
+ * @param {object} props - The component props.
18
+ * @param {React.ReactNode} props.children - The content to render within the portal.
19
+ * @returns {React.ReactPortal} The React portal component.
20
+ */
21
+
22
+ const WebPortal = ({ children }) => {
23
+ const portalContainer = document.createElement('div')
24
+
25
+ useEffect(() => {
26
+ document.body.appendChild(portalContainer)
27
+
28
+ return () => {
29
+ document.body.removeChild(portalContainer)
30
+ }
31
+ }, [portalContainer])
32
+
33
+ return ReactDOM.createPortal(children, portalContainer)
34
+ }
35
+
36
+ export default WebPortal
@@ -0,0 +1,3 @@
1
+ import WebPortal from './WebPortal'
2
+
3
+ export default WebPortal
@@ -67,5 +67,6 @@ export {
67
67
  // Enable access to the viewports system for app-specific responsive layouts and features
68
68
  useResponsiveProp,
69
69
  useViewport, // TODO reenable ViewportContext once published from base // enable localised viewport overrides e.g. in tests, narrow columns, etc
70
- useCarousel
70
+ useCarousel,
71
+ useSetTheme
71
72
  } from '@telus-uds/components-base'
package/src/index.js CHANGED
@@ -37,6 +37,7 @@ export { default as TermsAndConditions } from './TermsAndConditions'
37
37
  export { default as NavigationBar } from './NavigationBar'
38
38
  export { default as Progress } from './Progress'
39
39
  export { default as SkeletonProvider } from './SkeletonProvider'
40
+ export { default as WebPortal } from './WebPortal'
40
41
 
41
42
  export { ssrStyles } from './utils'
42
43