@royaloperahouse/chord 2.3.0 → 2.3.1

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.
package/dist/chord.esm.js CHANGED
@@ -10060,55 +10060,92 @@ var ReadMore = function ReadMore(_ref) {
10060
10060
  }, isFullTextOpen ? "" + hideText : "" + showMoreText)));
10061
10061
  };
10062
10062
 
10063
- var _templateObject$1g, _templateObject2$V, _templateObject3$M, _templateObject4$B;
10064
- var MenuContainer$2 = /*#__PURE__*/styled.menu(_templateObject$1g || (_templateObject$1g = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n padding: 0;\n margin: 0;\n"])));
10065
- var MenuList = /*#__PURE__*/styled.ul(_templateObject2$V || (_templateObject2$V = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n padding: 0;\n margin: 0;\n list-style: none;\n border-right: 1px solid var(--base-color-", ");\n li {\n margin-left: -5px;\n @media ", " {\n margin-left: 0px;\n }\n }\n @media ", " {\n display: ", ";\n background: var(--base-color-", ");\n border: 1px solid var(--base-color-", ");\n border-top: 0;\n position: absolute;\n top: 100%;\n left: 0;\n right: 0;\n }\n"])), Colors.LightGrey, devices.mobile, devices.mobile, function (_ref) {
10066
- var mobileOpen = _ref.mobileOpen;
10067
- return mobileOpen ? "block" : 'none';
10068
- }, Colors.White, Colors.DarkGrey);
10069
- var MenuItem$1 = /*#__PURE__*/styled.button(_templateObject3$M || (_templateObject3$M = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n line-height: var(--line-height-navigation);\n font-size: var(--font-size-navigation);\n font-family: var(--font-family-navigation);\n font-weight: var(--font-weight-navigation);\n letter-spacing: var(--letter-spacing-navigation);\n color: var(--base-color-", ");\n text-transform: uppercase;\n margin: 0;\n padding: 16px 20px 15px 5px;\n border: 0;\n border-radius: 0;\n display: block;\n width: 100%;\n text-align: left;\n background: ", ";\n cursor: pointer;\n &:hover {\n background: var(--base-color-", ");\n }\n @media ", " {\n padding: 16px 20px 15px 20px;\n }\n"])), Colors.Black, function (_ref2) {
10070
- var active = _ref2.active;
10071
- return active ? "var(--base-color-" + Colors.MidGrey + ")" : 'none';
10072
- }, Colors.MidGrey, devices.mobile);
10073
- var MobileButton = /*#__PURE__*/styled.button(_templateObject4$B || (_templateObject4$B = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n line-height: var(--line-height-navigation);\n font-size: var(--font-size-navigation);\n font-family: var(--font-family-navigation);\n font-weight: var(--font-weight-navigation);\n letter-spacing: var(--letter-spacing-navigation);\n color: var(--base-color-", ");\n text-transform: uppercase;\n margin: 0;\n padding: 16px 46px 14px 20px;\n background: var(--base-color-", ");\n border: 1px solid var(--base-color-", ");\n border-radius: 0;\n display: none;\n width: 100%;\n text-align: left;\n cursor: pointer;\n position: relative;\n span {\n width: 25px;\n height: 25px;\n position: absolute;\n top: 50%;\n margin-top: -12px;\n right: 10px;\n }\n @media ", " {\n display: block;\n }\n"])), Colors.Black, Colors.White, Colors.DarkGrey, devices.mobile);
10063
+ var _templateObject$1g, _templateObject2$V, _templateObject3$M, _templateObject4$B, _templateObject5$r;
10064
+ var MenuContainer$2 = /*#__PURE__*/styled.nav(_templateObject$1g || (_templateObject$1g = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n padding: 0;\n margin: 0;\n"])));
10065
+ var MenuList = /*#__PURE__*/styled.ul(_templateObject2$V || (_templateObject2$V = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n padding: 0;\n margin: 0;\n list-style: none;\n border-right: 1px solid var(--base-color-", ");\n li {\n margin-left: -5px;\n }\n"])), Colors.LightGrey);
10066
+ var MobileButton = /*#__PURE__*/styled.button(_templateObject3$M || (_templateObject3$M = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n line-height: var(--line-height-navigation);\n font-size: var(--font-size-navigation);\n font-family: var(--font-family-navigation);\n font-weight: var(--font-weight-navigation);\n letter-spacing: var(--letter-spacing-navigation);\n color: var(--base-color-", ");\n text-transform: uppercase;\n margin: 0;\n padding: 16px 46px 14px 20px;\n background: var(--base-color-", ");\n border: 1px solid var(--base-color-", ");\n border-radius: 0;\n display: block;\n width: 100%;\n text-align: left;\n cursor: pointer;\n position: relative;\n span {\n width: 25px;\n height: 25px;\n position: absolute;\n top: 50%;\n margin-top: -12px;\n right: 10px;\n }\n"])), Colors.Black, Colors.White, Colors.DarkGrey);
10067
+ var MenuItem$1 = /*#__PURE__*/styled.a(_templateObject4$B || (_templateObject4$B = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n line-height: var(--line-height-navigation);\n font-size: var(--font-size-navigation);\n font-family: var(--font-family-navigation);\n font-weight: var(--font-weight-navigation);\n letter-spacing: var(--letter-spacing-navigation);\n color: var(--base-color-", ");\n text-transform: uppercase;\n text-decoration: none;\n margin: 0;\n padding: 16px 20px 15px 5px;\n display: block;\n background: ", ";\n cursor: pointer;\n &:hover {\n background: var(--base-color-", ");\n }\n"])), Colors.Black, function (_ref) {
10068
+ var isActive = _ref.isActive;
10069
+ return isActive ? "var(--base-color-" + Colors.MidGrey + ")" : 'none';
10070
+ }, Colors.MidGrey);
10071
+ var MobileMenuList = /*#__PURE__*/styled.ul(_templateObject5$r || (_templateObject5$r = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n padding: 0;\n margin: 0;\n list-style: none;\n display: ", ";\n background: var(--base-color-", ");\n border: 1px solid var(--base-color-", ");\n border-top: 0;\n position: absolute;\n top: 100%;\n left: 0;\n right: 0;\n ", " {\n padding: 16px 20px 15px 20px;\n }\n"])), function (_ref2) {
10072
+ var isOpen = _ref2.isOpen;
10073
+ return isOpen ? 'block' : 'none';
10074
+ }, Colors.White, Colors.DarkGrey, MenuItem$1);
10075
+
10076
+ var NavItem = function NavItem(_ref) {
10077
+ var text = _ref.text,
10078
+ href = _ref.href,
10079
+ onClick = _ref.onClick,
10080
+ isActive = _ref.isActive,
10081
+ isMobile = _ref.isMobile;
10074
10082
 
10075
- /**
10076
- * Vertical menu component uses for navigation
10077
- * inside website chapter. It looks like a vertical
10078
- * list with clickable items on desktop and dropdown
10079
- * list on mobile.
10080
- *
10081
- * ## Menu items
10082
- * Menu items should be passed as `items` prop. This
10083
- * should be an array of objects. Each object should
10084
- * have `text` (text displayed as a menu item) and
10085
- * `onClick` (click handler function)
10086
- *
10087
- * ## Active menu item
10088
- * Active menu item should be passed as component `activeItem`
10089
- * prop. This indicates on which menu item should be highlighted
10090
- * as active one. Should be equal to `text` prop from one of the `items`
10091
- */
10083
+ var clickHandler = function () {
10084
+ if (!onClick) return undefined;
10085
+ return function (e) {
10086
+ e.preventDefault();
10087
+ onClick();
10088
+ };
10089
+ }();
10090
+
10091
+ var ariaCurrent = isMobile ? undefined : isActive;
10092
+ var ariaSelected = isMobile ? isActive : undefined;
10093
+ var role = isMobile ? 'option' : undefined;
10094
+ return /*#__PURE__*/React__default.createElement("li", {
10095
+ "aria-current": ariaCurrent,
10096
+ "aria-selected": ariaSelected,
10097
+ role: role
10098
+ }, /*#__PURE__*/React__default.createElement(MenuItem$1, {
10099
+ onClick: clickHandler,
10100
+ href: href,
10101
+ isActive: isActive,
10102
+ "data-testid": "nav-menu-item" + (isActive ? '-active' : '')
10103
+ }, text));
10104
+ };
10105
+
10106
+ var DesktopNav = function DesktopNav(_ref2) {
10107
+ var items = _ref2.items,
10108
+ activeItem = _ref2.activeItem,
10109
+ ariaLabel = _ref2.ariaLabel;
10110
+ return /*#__PURE__*/React__default.createElement(MenuContainer$2, {
10111
+ "data-testid": "nav-menu-container-desktop",
10112
+ "aria-label": ariaLabel
10113
+ }, /*#__PURE__*/React__default.createElement(MenuList, {
10114
+ "data-testid": "nav-menu-list"
10115
+ }, items.map(function (_ref3, idx) {
10116
+ var text = _ref3.text,
10117
+ href = _ref3.href,
10118
+ onClick = _ref3.onClick;
10119
+ return /*#__PURE__*/React__default.createElement(NavItem, {
10120
+ key: text + "-" + idx,
10121
+ text: text,
10122
+ href: href,
10123
+ onClick: onClick,
10124
+ isActive: text === activeItem
10125
+ });
10126
+ })));
10127
+ };
10092
10128
 
10093
- var AuxiliaryNav = function AuxiliaryNav(_ref) {
10094
- var items = _ref.items,
10095
- activeItem = _ref.activeItem;
10129
+ var MobileNav = function MobileNav(_ref4) {
10130
+ var items = _ref4.items,
10131
+ activeItem = _ref4.activeItem,
10132
+ ariaLabel = _ref4.ariaLabel;
10096
10133
 
10097
10134
  var _useState = useState(false),
10098
- mobileOpen = _useState[0],
10099
- setMobileOpen = _useState[1];
10135
+ isOpen = _useState[0],
10136
+ setIsOpen = _useState[1];
10100
10137
 
10101
10138
  var containerRef = useRef(null);
10102
10139
 
10103
- var mobileButtonClickHandler = function mobileButtonClickHandler() {
10104
- setMobileOpen(function (prev) {
10140
+ var buttonClickHandler = function buttonClickHandler() {
10141
+ setIsOpen(function (prev) {
10105
10142
  return !prev;
10106
10143
  });
10107
10144
  };
10108
10145
 
10109
10146
  var outsideClickHandler = function outsideClickHandler(event) {
10110
10147
  if (containerRef.current && !containerRef.current.contains(event.target)) {
10111
- setMobileOpen(false);
10148
+ setIsOpen(false);
10112
10149
  }
10113
10150
  };
10114
10151
 
@@ -10120,29 +10157,79 @@ var AuxiliaryNav = function AuxiliaryNav(_ref) {
10120
10157
  }, [containerRef]);
10121
10158
  return /*#__PURE__*/React__default.createElement(MenuContainer$2, {
10122
10159
  ref: containerRef,
10123
- "data-testid": "nav-menu-container"
10160
+ "data-testid": "nav-menu-container-mobile",
10161
+ "aria-label": ariaLabel
10124
10162
  }, /*#__PURE__*/React__default.createElement(MobileButton, {
10125
- mobileOpen: mobileOpen,
10126
- onClick: mobileButtonClickHandler,
10127
- "data-testid": "nav-menu-mobile-button"
10163
+ onClick: buttonClickHandler,
10164
+ "data-testid": "nav-menu-mobile-button",
10165
+ "aria-expanded": isOpen,
10166
+ "aria-controls": "auxiliary-nav-list",
10167
+ "aria-haspopup": "listbox",
10168
+ role: 'combobox'
10128
10169
  }, activeItem, /*#__PURE__*/React__default.createElement(Icon, {
10129
10170
  iconName: "DropdownArrow",
10130
- direction: mobileOpen ? 'left' : 'right'
10131
- })), /*#__PURE__*/React__default.createElement(MenuList, {
10132
- mobileOpen: mobileOpen,
10133
- "data-testid": "nav-menu-list"
10134
- }, items.map(function (item, idx) {
10135
- return /*#__PURE__*/React__default.createElement("li", {
10136
- key: item.text + "-" + idx
10137
- }, /*#__PURE__*/React__default.createElement(MenuItem$1, {
10138
- onClick: item.onClick,
10139
- active: item.text === activeItem,
10140
- "data-testid": "nav-menu-item" + (item.text === activeItem ? '-active' : '')
10141
- }, item.text));
10171
+ direction: isOpen ? 'left' : 'right'
10172
+ })), /*#__PURE__*/React__default.createElement(MobileMenuList, {
10173
+ id: 'auxiliary-nav-list',
10174
+ "data-testid": "nav-menu-list",
10175
+ isOpen: isOpen,
10176
+ "aria-hidden": !isOpen,
10177
+ role: 'listbox'
10178
+ }, items.map(function (_ref5, idx) {
10179
+ var text = _ref5.text,
10180
+ href = _ref5.href,
10181
+ onClick = _ref5.onClick;
10182
+ return /*#__PURE__*/React__default.createElement(NavItem, {
10183
+ key: text + "-" + idx,
10184
+ text: text,
10185
+ href: href,
10186
+ onClick: onClick,
10187
+ isActive: text === activeItem,
10188
+ isMobile: true
10189
+ });
10142
10190
  })));
10143
10191
  };
10192
+ /**
10193
+ * Vertical menu component uses for navigation
10194
+ * inside website chapter. It looks like a vertical
10195
+ * list with clickable items on desktop and dropdown
10196
+ * list on mobile.
10197
+ *
10198
+ * ## Menu items
10199
+ * Menu items should be passed as `items` prop. This
10200
+ * should be an array of objects. Each object should
10201
+ * have `text` (text displayed as a menu item) and
10202
+ * `onClick` (click handler function)
10203
+ *
10204
+ * ## Active menu item
10205
+ * Active menu item should be passed as component `activeItem`
10206
+ * prop. This indicates on which menu item should be highlighted
10207
+ * as active one. Should be equal to `text` prop from one of the `items`
10208
+ */
10209
+
10210
+
10211
+ var AuxiliaryNav = function AuxiliaryNav(_ref6) {
10212
+ var items = _ref6.items,
10213
+ activeItem = _ref6.activeItem,
10214
+ isMobile = _ref6.isMobile,
10215
+ ariaLabel = _ref6.ariaLabel;
10216
+
10217
+ if (isMobile) {
10218
+ return /*#__PURE__*/React__default.createElement(MobileNav, {
10219
+ items: items,
10220
+ activeItem: activeItem,
10221
+ ariaLabel: ariaLabel
10222
+ });
10223
+ }
10224
+
10225
+ return /*#__PURE__*/React__default.createElement(DesktopNav, {
10226
+ items: items,
10227
+ activeItem: activeItem,
10228
+ ariaLabel: ariaLabel
10229
+ });
10230
+ };
10144
10231
 
10145
- var _templateObject$1h, _templateObject2$W, _templateObject3$N, _templateObject4$C, _templateObject5$r, _templateObject6$m;
10232
+ var _templateObject$1h, _templateObject2$W, _templateObject3$N, _templateObject4$C, _templateObject5$s, _templateObject6$m;
10146
10233
  var Container$5 = /*#__PURE__*/styled.div(_templateObject$1h || (_templateObject$1h = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n gap: 10px;\n"])));
10147
10234
  var Sections = /*#__PURE__*/styled.div(_templateObject2$W || (_templateObject2$W = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: row;\n gap: 8px;\n"])));
10148
10235
  var Section = /*#__PURE__*/styled.div(_templateObject3$N || (_templateObject3$N = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n flex: 1;\n height: 2px;\n background-color: ", ";\n"])), function (_ref) {
@@ -10150,7 +10237,7 @@ var Section = /*#__PURE__*/styled.div(_templateObject3$N || (_templateObject3$N
10150
10237
  return "var(--base-color-" + color + ")";
10151
10238
  });
10152
10239
  var BottomLine = /*#__PURE__*/styled.div(_templateObject4$C || (_templateObject4$C = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n gap: 20px;\n"])));
10153
- var Text = /*#__PURE__*/styled.div(_templateObject5$r || (_templateObject5$r = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n color: ", ";\n"])), function (_ref2) {
10240
+ var Text = /*#__PURE__*/styled.div(_templateObject5$s || (_templateObject5$s = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n color: ", ";\n"])), function (_ref2) {
10154
10241
  var color = _ref2.color;
10155
10242
  return "var(--base-color-" + color + ")";
10156
10243
  });
@@ -10240,14 +10327,14 @@ var PasswordStrength = function PasswordStrength(_ref) {
10240
10327
  }, strengthLabel))));
10241
10328
  };
10242
10329
 
10243
- var _templateObject$1i, _templateObject2$X, _templateObject3$O, _templateObject4$D, _templateObject5$s, _templateObject6$n, _templateObject7$f, _templateObject8$c, _templateObject9$7, _templateObject10$7;
10330
+ var _templateObject$1i, _templateObject2$X, _templateObject3$O, _templateObject4$D, _templateObject5$t, _templateObject6$n, _templateObject7$f, _templateObject8$c, _templateObject9$7, _templateObject10$7;
10244
10331
  var TableContainer = /*#__PURE__*/styled.table(_templateObject$1i || (_templateObject$1i = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border-collapse: collapse;\n"])));
10245
10332
  var Container$6 = /*#__PURE__*/styled.div(_templateObject2$X || (_templateObject2$X = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n overflow-x: auto;\n"])));
10246
10333
  var Wrapper$7 = /*#__PURE__*/styled.div(_templateObject3$O || (_templateObject3$O = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 100%;\n"])));
10247
10334
  var TableHeader = /*#__PURE__*/styled.th(_templateObject4$D || (_templateObject4$D = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: var(--font-size-subtitle-2);\n font-family: var(--font-family-subtitle);\n font-feature-settings: var(--font-feature-settings-subtitle);\n font-weight: var(--font-weight-subtitle-2);\n letter-spacing: var(--letter-spacing-subtitle-2);\n line-height: var(--line-height-subtitle-2);\n padding: 30px 30px 30px 0;\n text-align: left;\n text-transform: uppercase;\n\n &:last-child {\n white-space: nowrap;\n width: auto;\n }\n\n &:not(:last-child) {\n width: ", ";\n }\n\n @media ", " {\n &:last-child {\n white-space: nowrap;\n }\n }\n\n @media ", " {\n padding: 20px 20px 20px 0;\n\n &:last-child {\n white-space: normal;\n }\n }\n"])), function (props) {
10248
10335
  return "calc(100% / " + (props.columns - 1) + ")";
10249
10336
  }, devices.tablet, devices.mobile);
10250
- var TableCell = /*#__PURE__*/styled.td(_templateObject5$s || (_templateObject5$s = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: var(--font-size-body-1);\n font-family: var(--font-family-body);\n font-feature-settings: var(--font-feature-settings-body);\n font-weight: var(--font-weight-body-1);\n letter-spacing: var(--letter-spacing-body-1);\n line-height: var(--line-height-body-1);\n padding: 30px 30px 30px 0;\n text-align: left;\n vertical-align: top;\n\n &:last-child {\n width: auto;\n }\n\n &:not(:last-child) {\n width: ", ";\n }\n\n > span > svg {\n width: 24px;\n height: 24px;\n }\n\n @media ", " {\n padding: 20px 20px 20px 0;\n }\n"])), function (props) {
10337
+ var TableCell = /*#__PURE__*/styled.td(_templateObject5$t || (_templateObject5$t = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: var(--font-size-body-1);\n font-family: var(--font-family-body);\n font-feature-settings: var(--font-feature-settings-body);\n font-weight: var(--font-weight-body-1);\n letter-spacing: var(--letter-spacing-body-1);\n line-height: var(--line-height-body-1);\n padding: 30px 30px 30px 0;\n text-align: left;\n vertical-align: top;\n\n &:last-child {\n width: auto;\n }\n\n &:not(:last-child) {\n width: ", ";\n }\n\n > span > svg {\n width: 24px;\n height: 24px;\n }\n\n @media ", " {\n padding: 20px 20px 20px 0;\n }\n"])), function (props) {
10251
10338
  return "calc(100% / " + (props.columns - 1) + ")";
10252
10339
  }, devices.mobile);
10253
10340
  var LineContainer$1 = /*#__PURE__*/styled.div(_templateObject6$n || (_templateObject6$n = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n height: 1px;\n background-color: ", ";\n width: 100%;\n"])), function (props) {