@telus-uds/components-web 1.10.0 → 1.11.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 (77) hide show
  1. package/CHANGELOG.md +26 -2
  2. package/lib/Breadcrumbs/Item/Item.js +31 -6
  3. package/lib/Callout/Callout.js +24 -3
  4. package/lib/Disclaimer/Disclaimer.js +72 -0
  5. package/lib/Disclaimer/index.js +15 -0
  6. package/lib/Footnote/Footnote.js +3 -4
  7. package/lib/Footnote/FootnoteLink.js +11 -13
  8. package/lib/NavigationBar/NavigationBar.js +231 -0
  9. package/lib/NavigationBar/NavigationItem.js +111 -0
  10. package/lib/NavigationBar/NavigationSubMenu.js +179 -0
  11. package/lib/NavigationBar/collapseItems.js +51 -0
  12. package/lib/NavigationBar/index.js +13 -0
  13. package/lib/PriceLockup/PriceLockup.js +40 -17
  14. package/lib/PriceLockup/tokens.js +49 -116
  15. package/lib/Progress/ProgressBar.js +100 -0
  16. package/lib/Progress/index.js +16 -0
  17. package/lib/Ribbon/Ribbon.js +53 -32
  18. package/lib/Spinner/Spinner.js +18 -14
  19. package/lib/Table/Cell.js +15 -1
  20. package/lib/VideoPicker/VideoPicker.js +177 -0
  21. package/lib/VideoPicker/VideoPickerPlayer.js +54 -0
  22. package/lib/VideoPicker/VideoPickerThumbnail.js +201 -0
  23. package/lib/VideoPicker/VideoSlider.js +100 -0
  24. package/lib/VideoPicker/index.js +13 -0
  25. package/lib/VideoPicker/videoPropType.js +25 -0
  26. package/lib/index.js +37 -1
  27. package/lib-module/Breadcrumbs/Item/Item.js +32 -7
  28. package/lib-module/Callout/Callout.js +24 -3
  29. package/lib-module/Disclaimer/Disclaimer.js +54 -0
  30. package/lib-module/Disclaimer/index.js +1 -0
  31. package/lib-module/Footnote/Footnote.js +3 -3
  32. package/lib-module/Footnote/FootnoteLink.js +12 -14
  33. package/lib-module/NavigationBar/NavigationBar.js +207 -0
  34. package/lib-module/NavigationBar/NavigationItem.js +87 -0
  35. package/lib-module/NavigationBar/NavigationSubMenu.js +161 -0
  36. package/lib-module/NavigationBar/collapseItems.js +43 -0
  37. package/lib-module/NavigationBar/index.js +2 -0
  38. package/lib-module/PriceLockup/PriceLockup.js +42 -19
  39. package/lib-module/PriceLockup/tokens.js +54 -119
  40. package/lib-module/Progress/ProgressBar.js +83 -0
  41. package/lib-module/Progress/index.js +4 -0
  42. package/lib-module/Ribbon/Ribbon.js +53 -32
  43. package/lib-module/Spinner/Spinner.js +17 -14
  44. package/lib-module/Table/Cell.js +15 -1
  45. package/lib-module/VideoPicker/VideoPicker.js +151 -0
  46. package/lib-module/VideoPicker/VideoPickerPlayer.js +41 -0
  47. package/lib-module/VideoPicker/VideoPickerThumbnail.js +180 -0
  48. package/lib-module/VideoPicker/VideoSlider.js +83 -0
  49. package/lib-module/VideoPicker/index.js +2 -0
  50. package/lib-module/VideoPicker/videoPropType.js +9 -0
  51. package/lib-module/index.js +4 -0
  52. package/package.json +3 -3
  53. package/src/Breadcrumbs/Item/Item.jsx +18 -4
  54. package/src/Callout/Callout.jsx +27 -3
  55. package/src/Disclaimer/Disclaimer.jsx +39 -0
  56. package/src/Disclaimer/index.js +1 -0
  57. package/src/Footnote/Footnote.jsx +3 -3
  58. package/src/Footnote/FootnoteLink.jsx +28 -18
  59. package/src/NavigationBar/NavigationBar.jsx +217 -0
  60. package/src/NavigationBar/NavigationItem.jsx +83 -0
  61. package/src/NavigationBar/NavigationSubMenu.jsx +121 -0
  62. package/src/NavigationBar/collapseItems.js +29 -0
  63. package/src/NavigationBar/index.js +3 -0
  64. package/src/PriceLockup/PriceLockup.jsx +47 -21
  65. package/src/PriceLockup/tokens.js +34 -54
  66. package/src/Progress/ProgressBar.jsx +67 -0
  67. package/src/Progress/index.js +6 -0
  68. package/src/Ribbon/Ribbon.jsx +21 -9
  69. package/src/Spinner/Spinner.jsx +20 -17
  70. package/src/Table/Cell.jsx +22 -5
  71. package/src/VideoPicker/VideoPicker.jsx +144 -0
  72. package/src/VideoPicker/VideoPickerPlayer.jsx +21 -0
  73. package/src/VideoPicker/VideoPickerThumbnail.jsx +182 -0
  74. package/src/VideoPicker/VideoSlider.jsx +85 -0
  75. package/src/VideoPicker/index.js +3 -0
  76. package/src/VideoPicker/videoPropType.js +12 -0
  77. package/src/index.js +4 -0
package/CHANGELOG.md CHANGED
@@ -1,12 +1,36 @@
1
1
  # Change Log - @telus-uds/components-web
2
2
 
3
- This log was last generated on Mon, 01 May 2023 22:02:12 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 09 May 2023 00:20:29 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.11.0
8
+
9
+ Tue, 09 May 2023 00:20:29 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - Fix to import icon from palette (wlsdud194@hotmail.com)
14
+ - make ProgressBar component to multibrand (mauricio.batresmontejo@telus.com)
15
+ - Add fontWeight, fontName, color, currentColor to component implementation (kyle.king2@telus.com)
16
+ - Callout has a new prop - textAlign that centers or left aligns text (akshay.pandey1@telus.com)
17
+ - refactor 'PriceLockup' & 'FootnoteLink' to take additional properties/tokens (kyle.king2@telus.com)
18
+ - font color as a property to follow the standarization guidelines in the brands for the ribbon components (35577399+JoshHC@users.noreply.github.com)
19
+ - Updated snapshots for components that depend on 'Typography' (kyle.king2@telus.com)
20
+ - added font props to Cell component (ignacio.cuyun@telus.com)
21
+ - makes navigation bar component multibrand (mauricio.batresmontejo@telus.com)
22
+ - moved 'Disclaimer' to components-web from ds-allium (kyle.king2@telus.com)
23
+ - move 'VideoPicker' to components-web (kyle.king2@telus.com)
24
+ - Bump @telus-uds/components-base to v1.40.0
25
+ - Bump @telus-uds/system-theme-tokens to v2.25.0
26
+
27
+ ### Patches
28
+
29
+ - Fix an issue where `Spinner` might not render correctly in `fullScreen` mode (shahzaibkhalidmalik@outlook.com)
30
+
7
31
  ## 1.10.0
8
32
 
9
- Mon, 01 May 2023 22:02:12 GMT
33
+ Mon, 01 May 2023 22:09:07 GMT
10
34
 
11
35
  ### Minor changes
12
36
 
@@ -55,10 +55,20 @@ const IconContainer = /*#__PURE__*/_styledComponents.default.span.withConfig({
55
55
  iconPadding
56
56
  } = _ref3;
57
57
  return `${iconPadding}px`;
58
+ },
59
+ fontFamily: _ref4 => {
60
+ let {
61
+ fontName,
62
+ fontWeight
63
+ } = _ref4;
64
+ return (0, _componentsBase.applyTextStyles)({
65
+ fontName,
66
+ fontWeight
67
+ }).fontFamily;
58
68
  }
59
69
  });
60
70
 
61
- const Item = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
71
+ const Item = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
62
72
  let {
63
73
  href,
64
74
  reactRouterLinkComponent: ReactRouterLink,
@@ -70,10 +80,14 @@ const Item = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
70
80
  },
71
81
  // `light` variant (shared with the `Link` component) is default by design
72
82
  ...rest
73
- } = _ref4;
83
+ } = _ref5;
74
84
  const {
75
85
  iconColor,
76
86
  icon: ChevronRightIcon,
87
+ currentColor,
88
+ color,
89
+ iconSize,
90
+ fontSize,
77
91
  ...themeTokens
78
92
  } = (0, _componentsBase.useThemeTokens)('Breadcrumbs', tokens, variant);
79
93
 
@@ -87,14 +101,21 @@ const Item = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
87
101
 
88
102
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledItemContainer, { ...themeTokens,
89
103
  children: current ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
90
- variant: { ...variant,
91
- secondary: true
104
+ tokens: {
105
+ color: currentColor,
106
+ fontSize
107
+ },
108
+ variant: { ...variant
92
109
  },
93
110
  children: children
94
111
  }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
95
112
  children: [ReactRouterLink ? /*#__PURE__*/(0, _jsxRuntime.jsx)(ReactRouterLink, { ...linkOptions,
96
- // TODO refactor
113
+ tokens: {
114
+ color,
115
+ blockFontSize: fontSize
116
+ } // TODO refactor
97
117
  // eslint-disable-next-line react/no-unstable-nested-components
118
+ ,
98
119
  component: props => {
99
120
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Link, { ...props,
100
121
  variant: variant
@@ -103,12 +124,16 @@ const Item = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
103
124
  ref: ref,
104
125
  children: children
105
126
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Link, { ...linkOptions,
127
+ tokens: {
128
+ color,
129
+ blockFontSize: fontSize
130
+ },
106
131
  ref: ref,
107
132
  variant: variant,
108
133
  children: children
109
134
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(IconContainer, { ...themeTokens,
110
135
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ChevronRightIcon, {
111
- size: 16,
136
+ size: iconSize,
112
137
  color: iconColor
113
138
  })
114
139
  })]
@@ -21,6 +21,23 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
21
21
 
22
22
  const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]);
23
23
 
24
+ const getAlignment = (rounded, textAlignToFlex) => {
25
+ if (textAlignToFlex) {
26
+ switch (textAlignToFlex) {
27
+ case 'left':
28
+ return 'flex-star';
29
+
30
+ case 'center':
31
+ return 'center';
32
+
33
+ default:
34
+ return 'flex-start';
35
+ }
36
+ }
37
+
38
+ return rounded ? 'center' : ' flex-start';
39
+ };
40
+
24
41
  const verticalAlignToFlex = verticalAlign => {
25
42
  switch (verticalAlign) {
26
43
  case 'top':
@@ -43,7 +60,8 @@ const CalloutContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
43
60
  })(_ref => {
44
61
  let {
45
62
  rounded,
46
- verticalAlign = 'top',
63
+ verticalAlign,
64
+ textAlignToFlex,
47
65
  background,
48
66
  gap,
49
67
  borderRadius,
@@ -55,7 +73,7 @@ const CalloutContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
55
73
  gap,
56
74
  borderRadius,
57
75
  padding,
58
- justifyContent: `${rounded ? 'center' : 'flex-start'}`,
76
+ justifyContent: getAlignment(rounded, textAlignToFlex),
59
77
  alignItems: verticalAlignToFlex(verticalAlign)
60
78
  };
61
79
  });
@@ -64,7 +82,8 @@ const Callout = _ref2 => {
64
82
  let {
65
83
  icon,
66
84
  children,
67
- verticalAlign = 'top',
85
+ verticalAlign,
86
+ textAlignToFlex,
68
87
  tokens,
69
88
  variant = {},
70
89
  ...rest
@@ -88,6 +107,7 @@ const Callout = _ref2 => {
88
107
  rounded: rounded,
89
108
  "data-testid": "callout-container",
90
109
  verticalAlign: verticalAlign,
110
+ textAlignToFlex: textAlignToFlex,
91
111
  background: background,
92
112
  gap: gap,
93
113
  borderRadius: borderRadius,
@@ -118,6 +138,7 @@ const Callout = _ref2 => {
118
138
  Callout.propTypes = { ...selectedSystemPropTypes,
119
139
  icon: _propTypes.default.elementType,
120
140
  children: _propTypes.default.node.isRequired,
141
+ textAlignToFlex: _propTypes.default.oneOf(['center', 'left']),
121
142
  verticalAlign: _propTypes.default.oneOf(['top', 'middle', 'bottom'])
122
143
  };
123
144
  var _default = Callout;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
13
+
14
+ var _componentsBase = require("@telus-uds/components-base");
15
+
16
+ var _utils = require("../utils");
17
+
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]);
23
+
24
+ const StyledDisclaimer = /*#__PURE__*/_styledComponents.default.p.withConfig({
25
+ displayName: "Disclaimer__StyledDisclaimer",
26
+ componentId: "components-web__sc-1l4xf7u-0"
27
+ })(_ref => {
28
+ let {
29
+ fontName,
30
+ fontWeight,
31
+ fontSize,
32
+ ...tokens
33
+ } = _ref;
34
+ const {
35
+ fontFamily
36
+ } = (0, _componentsBase.applyTextStyles)({
37
+ fontName,
38
+ fontWeight
39
+ });
40
+ return {
41
+ fontSize: `${fontSize}px`,
42
+ fontFamily,
43
+ ...tokens
44
+ };
45
+ });
46
+ /**
47
+ * Use Disclaimer to display singular legal statement and must be displayed
48
+ * immediately adjacent to the related, originating content.
49
+ */
50
+
51
+
52
+ const Disclaimer = _ref2 => {
53
+ let {
54
+ children,
55
+ ...rest
56
+ } = _ref2;
57
+ const themeTokens = (0, _componentsBase.useThemeTokens)('Disclaimer');
58
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledDisclaimer, { ...selectProps(rest),
59
+ ...themeTokens,
60
+ children: children
61
+ });
62
+ };
63
+
64
+ Disclaimer.propTypes = { ...selectedSystemPropTypes,
65
+
66
+ /**
67
+ * The content
68
+ */
69
+ children: _propTypes.default.node.isRequired
70
+ };
71
+ var _default = Disclaimer;
72
+ exports.default = _default;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "default", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _Disclaimer.default;
10
+ }
11
+ });
12
+
13
+ var _Disclaimer = _interopRequireDefault(require("./Disclaimer"));
14
+
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -13,8 +13,6 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
13
13
 
14
14
  var _componentsBase = require("@telus-uds/components-base");
15
15
 
16
- var _Close = _interopRequireDefault(require("../../__fixtures__/icons/Close"));
17
-
18
16
  var _OrderedListBase = _interopRequireDefault(require("../OrderedList/OrderedListBase"));
19
17
 
20
18
  var _utils = require("../utils");
@@ -312,7 +310,8 @@ const Footnote = props => {
312
310
  closeButtonMarginRight,
313
311
  closeButtonMarginBottom,
314
312
  closeButtonWidth,
315
- closeButtonIconSize
313
+ closeButtonIconSize,
314
+ closeIcon
316
315
  } = (0, _componentsBase.useThemeTokens)('Footnote', tokens, variant);
317
316
  const footnoteRef = (0, _react.useRef)(null);
318
317
  const headerRef = (0, _react.useRef)(null);
@@ -528,7 +527,7 @@ const Footnote = props => {
528
527
  },
529
528
  "aria-label": getCopy('close'),
530
529
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Icon, {
531
- icon: _Close.default,
530
+ icon: closeIcon,
532
531
  tokens: {
533
532
  size: `${closeButtonIconSize}px`
534
533
  }
@@ -28,22 +28,26 @@ const StyledSup = /*#__PURE__*/_styledComponents.default.sup.withConfig({
28
28
  componentId: "components-web__sc-17nd7xo-0"
29
29
  })(_ref => {
30
30
  let {
31
- fontSize = 'smaller',
31
+ fontSize,
32
32
  lineHeight,
33
33
  paddingLeft,
34
- paddingRight
34
+ paddingRight,
35
+ ...fontNameAndWeight
35
36
  } = _ref;
36
37
  return {
37
38
  border: 0,
38
39
  color: 'inherit',
39
40
  cursor: 'pointer',
40
- fontSize,
41
+ // we want to fallback on 'smaller' but have a valid size when a custom font size is provided.
42
+ fontSize: fontSize ? `${fontSize}px` : 'smaller',
41
43
  lineHeight,
42
44
  margin: 0,
43
45
  paddingVertical: 0,
44
46
  paddingLeft,
45
47
  paddingRight,
46
- textDecoration: 'underline'
48
+ textDecoration: 'underline',
49
+ // apply font family
50
+ ...(0, _componentsBase.applyTextStyles)(fontNameAndWeight)
47
51
  };
48
52
  });
49
53
  /**
@@ -67,11 +71,7 @@ const FootnoteLink = _ref2 => {
67
71
  variant = {},
68
72
  ...rest
69
73
  } = _ref2;
70
- const {
71
- lineHeight,
72
- paddingLeft,
73
- paddingRight
74
- } = (0, _componentsBase.useThemeTokens)('FootnoteLink', tokens, variant);
74
+ const themeTokens = (0, _componentsBase.useThemeTokens)('FootnoteLink', tokens, variant);
75
75
  const numbers = Array.isArray(number) ? number : [number];
76
76
  const refs = numbers.map(() => /*#__PURE__*/_react.default.createRef());
77
77
 
@@ -103,11 +103,9 @@ const FootnoteLink = _ref2 => {
103
103
  "aria-label": getCopy('a11yLabel'),
104
104
  ref: refs[index],
105
105
  onClick: event => handleOnClick(event, index),
106
- fontSize: fontSize,
107
- lineHeight: lineHeight,
108
- paddingLeft: paddingLeft,
109
- paddingRight: paddingRight,
110
106
  ...selectProps(rest),
107
+ ...themeTokens,
108
+ fontSize: fontSize,
111
109
  children: `${num}${index !== numbers.length - 1 ? ',' : ''}`
112
110
  }, num))
113
111
  });
@@ -0,0 +1,231 @@
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 _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _componentsBase = require("@telus-uds/components-base");
13
+
14
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
15
+
16
+ var _utils = require("../utils");
17
+
18
+ var _NavigationItem = _interopRequireDefault(require("./NavigationItem"));
19
+
20
+ var _NavigationSubMenu = _interopRequireDefault(require("./NavigationSubMenu"));
21
+
22
+ var _collapseItems = _interopRequireDefault(require("./collapseItems"));
23
+
24
+ var _jsxRuntime = require("react/jsx-runtime");
25
+
26
+ var _withLinkRouter$propT, _withLinkRouter$propT2, _withLinkRouter$propT3, _withLinkRouter$propT4;
27
+
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+
30
+ 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); }
31
+
32
+ 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; }
33
+
34
+ const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]);
35
+
36
+ const Heading = /*#__PURE__*/_styledComponents.default.div.withConfig({
37
+ displayName: "NavigationBar__Heading",
38
+ componentId: "components-web__sc-1vis1gt-0"
39
+ })({
40
+ alignItems: 'center',
41
+ display: 'flex',
42
+ flex: 1,
43
+ justifyContent: 'flex-start',
44
+ '> *': {
45
+ display: 'contents',
46
+ letterSpacing: 0
47
+ }
48
+ });
49
+ /**
50
+ * NavigationBar can be used to allow customers to consistently navigate across
51
+ * key pages within a specific product line
52
+ */
53
+
54
+
55
+ const NavigationBar = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
56
+ let {
57
+ accessibilityRole = 'navigation',
58
+ heading,
59
+ headingLevel = 'h1',
60
+ items,
61
+ onChange = () => {},
62
+ selectedId,
63
+ LinkRouter,
64
+ linkRouterProps,
65
+ ...rest
66
+ } = _ref;
67
+ const direction = (0, _componentsBase.useResponsiveProp)({
68
+ xs: 'column',
69
+ sm: 'row'
70
+ });
71
+ const itemsForViewport = (0, _componentsBase.useResponsiveProp)({
72
+ xs: (0, _collapseItems.default)(items, selectedId),
73
+ lg: items
74
+ });
75
+ const openOverlayRef = (0, _react.useRef)(null);
76
+ const [openSubMenuId, setOpenSubMenuId] = (0, _react.useState)(null);
77
+
78
+ const handleSubMenuClose = event => {
79
+ var _openOverlayRef$curre, _openOverlayRef$curre2;
80
+
81
+ if (event.type === 'keydown') {
82
+ if (event.key === 'Escape' || event.key === 27) {
83
+ setOpenSubMenuId(null);
84
+ }
85
+ } 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))) {
86
+ setOpenSubMenuId(null);
87
+ } 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))) {
88
+ setOpenSubMenuId(null);
89
+ }
90
+ }; // Add listeners for mouse clicks outside and for ESCAPE key presses
91
+ // TODO: create a custom hook for that and use here and in the Footnote
92
+
93
+
94
+ (0, _react.useEffect)(() => {
95
+ if (openSubMenuId !== null) {
96
+ window.addEventListener('click', handleSubMenuClose);
97
+ window.addEventListener('keydown', handleSubMenuClose);
98
+ window.addEventListener('touchstart', handleSubMenuClose);
99
+ }
100
+
101
+ return () => {
102
+ if (openSubMenuId !== null) {
103
+ window.removeEventListener('click', handleSubMenuClose);
104
+ window.removeEventListener('keydown', handleSubMenuClose);
105
+ window.removeEventListener('touchstart', handleSubMenuClose);
106
+ }
107
+ };
108
+ }, [openSubMenuId]);
109
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_componentsBase.StackView, {
110
+ accessibilityRole: accessibilityRole,
111
+ direction: direction,
112
+ ref: ref,
113
+ space: 2,
114
+ tokens: {
115
+ alignItems: direction === 'column' ? 'flex-start' : 'center',
116
+ justifyContent: 'flex-end'
117
+ },
118
+ ...selectProps(rest),
119
+ children: [heading && /*#__PURE__*/(0, _jsxRuntime.jsx)(Heading, {
120
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
121
+ variant: {
122
+ size: 'h5'
123
+ },
124
+ heading: headingLevel,
125
+ children: heading
126
+ })
127
+ }), itemsForViewport === null || itemsForViewport === void 0 ? void 0 : itemsForViewport.map((_ref2, index) => {
128
+ let {
129
+ href,
130
+ label,
131
+ id,
132
+ onClick,
133
+ ref: itemRef,
134
+ LinkRouter: ItemLinkRouter = LinkRouter,
135
+ linkRouterProps: itemLinkRouterProps,
136
+ items: nestedItems,
137
+ ...itemRest
138
+ } = _ref2;
139
+ const itemId = id ?? label;
140
+
141
+ const handleClick = event => {
142
+ if (nestedItems) {
143
+ setOpenSubMenuId(openSubMenuId !== itemId ? itemId : null);
144
+ }
145
+
146
+ onClick === null || onClick === void 0 ? void 0 : onClick(event);
147
+ onChange === null || onChange === void 0 ? void 0 : onChange(itemId, event);
148
+ };
149
+
150
+ const ItemComponent = nestedItems ? _NavigationSubMenu.default : _NavigationItem.default;
151
+ const isOpen = itemId === openSubMenuId;
152
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(ItemComponent, {
153
+ ref: itemRef,
154
+ href: href,
155
+ onClick: handleClick // TODO: refactor to pass selected ID via context
156
+ ,
157
+ selectedId: selectedId,
158
+ index: index,
159
+ LinkRouter: ItemLinkRouter,
160
+ linkRouterProps: { ...linkRouterProps,
161
+ ...itemLinkRouterProps
162
+ },
163
+ items: nestedItems,
164
+ selected: itemId === selectedId,
165
+ ...itemRest,
166
+ ...(nestedItems && {
167
+ isOpen
168
+ }),
169
+ ...(nestedItems && isOpen && {
170
+ openOverlayRef
171
+ }),
172
+ children: label
173
+ }, itemId);
174
+ })]
175
+ });
176
+ });
177
+ NavigationBar.displayName = 'NavigationBar';
178
+ NavigationBar.propTypes = { ...selectedSystemPropTypes,
179
+ ..._componentsBase.withLinkRouter.propTypes,
180
+
181
+ /**
182
+ * NavigationBar pages
183
+ *
184
+ * Each `item` object must contain:
185
+ * - `heading` - user-facing text in the tab link
186
+ * - `href` - the URL of the page linked to. Do not use hash links, for content within a page, use `Tabs`.
187
+ * - `id` - a stable, unique identifier of the page within the set. Not written into the HTML.
188
+ */
189
+ items: _propTypes.default.arrayOf(_propTypes.default.shape({
190
+ label: _propTypes.default.string.isRequired,
191
+ href: _propTypes.default.string,
192
+ id: _propTypes.default.string.isRequired,
193
+ onClick: _propTypes.default.func,
194
+ selected: _propTypes.default.bool,
195
+ LinkRouter: (_withLinkRouter$propT = _componentsBase.withLinkRouter.propTypes) === null || _withLinkRouter$propT === void 0 ? void 0 : _withLinkRouter$propT.LinkRouter,
196
+ linkRouterProps: (_withLinkRouter$propT2 = _componentsBase.withLinkRouter.propTypes) === null || _withLinkRouter$propT2 === void 0 ? void 0 : _withLinkRouter$propT2.linkRouterProps,
197
+ // One layer of nested links is allowed
198
+ items: _propTypes.default.arrayOf(_propTypes.default.shape({
199
+ label: _propTypes.default.string.isRequired,
200
+ href: _propTypes.default.string,
201
+ id: _propTypes.default.string.isRequired,
202
+ onClick: _propTypes.default.func,
203
+ selected: _propTypes.default.bool,
204
+ LinkRouter: (_withLinkRouter$propT3 = _componentsBase.withLinkRouter.propTypes) === null || _withLinkRouter$propT3 === void 0 ? void 0 : _withLinkRouter$propT3.LinkRouter,
205
+ linkRouterProps: (_withLinkRouter$propT4 = _componentsBase.withLinkRouter.propTypes) === null || _withLinkRouter$propT4 === void 0 ? void 0 : _withLinkRouter$propT4.linkRouterProps
206
+ }))
207
+ })).isRequired,
208
+
209
+ /**
210
+ * Common navigation bar heading.
211
+ */
212
+ heading: _propTypes.default.string,
213
+ headingLevel: _propTypes.default.oneOf(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
214
+
215
+ /**
216
+ * Matches the `id` property of the item in `items` corresponding to the current page
217
+ */
218
+ selectedId: _propTypes.default.string.isRequired,
219
+
220
+ /**
221
+ * Optional function to be called on pressing a link
222
+ */
223
+ onChange: _propTypes.default.func
224
+ };
225
+ NavigationBar.defaultProps = {
226
+ heading: undefined,
227
+ headingLevel: 'h1',
228
+ onChange: () => {}
229
+ };
230
+ var _default = NavigationBar;
231
+ exports.default = _default;