@laerdal/life-react-components 2.3.1-dev.16 → 2.3.1-dev.19

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.
@@ -31,7 +31,7 @@ var SubMenuWrapper = _styledComponents.default.div(_templateObject || (_template
31
31
  return !props.visible ? 'display: none;' : '';
32
32
  });
33
33
  exports.SubMenuWrapper = SubMenuWrapper;
34
- var SubMenu = function SubMenu(_ref) {
34
+ var SubMenu = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
35
35
  var item = _ref.item,
36
36
  index = _ref.index,
37
37
  topLevel = _ref.topLevel,
@@ -39,11 +39,33 @@ var SubMenu = function SubMenu(_ref) {
39
39
  onSubMenuHidden = _ref.onSubMenuHidden,
40
40
  onSubMenuOpened = _ref.onSubMenuOpened,
41
41
  onItemStateChanged = _ref.onItemStateChanged,
42
+ focusedItemId = _ref.focusedItemId,
42
43
  activeItemId = _ref.activeItemId,
43
- nestPath = _ref.nestPath;
44
+ nestPath = _ref.nestPath,
45
+ ariaLabelledBy = _ref.ariaLabelledBy,
46
+ onItemFocused = _ref.onItemFocused;
44
47
  var _React$useState = React.useState({}),
45
48
  _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
46
49
  forceUpdate = _React$useState2[1];
50
+ var focusedRef = React.useRef({
51
+ index: -1
52
+ });
53
+ var _React$useState3 = React.useState([]),
54
+ _React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
55
+ allRefs = _React$useState4[0],
56
+ setAllRefs = _React$useState4[1];
57
+ var _React$useState5 = React.useState([]),
58
+ _React$useState6 = (0, _slicedToArray2.default)(_React$useState5, 2),
59
+ subMenuRefs = _React$useState6[0],
60
+ setAllSubMenuRefs = _React$useState6[1];
61
+ React.useEffect(function () {
62
+ setAllRefs(item.items.map(function (x) {
63
+ return x.type == 'desktopgroup' ? /*#__PURE__*/React.createRef() : /*#__PURE__*/React.createRef();
64
+ }));
65
+ setAllSubMenuRefs(item.items.map(function (x) {
66
+ return x.type == 'desktopgroup' ? /*#__PURE__*/React.createRef() : undefined;
67
+ }));
68
+ }, [item]);
47
69
  var existingRef = dropdownMenusOpenedArray.current.find(function (x) {
48
70
  return x == item.id;
49
71
  });
@@ -68,30 +90,77 @@ var SubMenu = function SubMenu(_ref) {
68
90
  forceUpdate({});
69
91
  }
70
92
  };
71
- var _onKeyDown = function onKeyDown(event, entryId) {
72
- if (event.key == 'Enter' || event.code == 'Space') {
73
- dropdownMenusOpenedArray.current = [].concat((0, _toConsumableArray2.default)(dropdownMenusOpenedArray.current), [entryId]);
93
+ var _onKeyDown = function onKeyDown(e) {
94
+ if (e.key === 'ArrowUp' || e.key === 'Up') {
95
+ e.stopPropagation();
96
+ e.preventDefault();
97
+ if (focusedRef.current.index > 0) {
98
+ setNewFocusedElement(focusedRef.current.index - 1);
99
+ }
100
+ } else if (e.key === 'ArrowDown' || e.key === 'Down') {
101
+ e.stopPropagation();
102
+ e.preventDefault();
103
+ if (focusedRef.current.index < allRefs.length - 1) setNewFocusedElement(focusedRef.current.index + 1);
104
+ } else if (e.key == 'Enter' || e.code == 'Space') {
105
+ e.stopPropagation();
106
+ if (focusedRef.current.index < 0) return;
107
+ var focusedItem = item.items[focusedRef.current.index];
108
+ if (focusedItem.type == 'desktopgroup') {
109
+ dropdownMenusOpenedArray.current = [].concat((0, _toConsumableArray2.default)(dropdownMenusOpenedArray.current), [focusedItem.id]);
110
+ forceUpdate({});
111
+ } else {
112
+ var _allRefs$focusedRef$c;
113
+ (_allRefs$focusedRef$c = allRefs[focusedRef.current.index].current) === null || _allRefs$focusedRef$c === void 0 ? void 0 : _allRefs$focusedRef$c.click();
114
+ forceUpdate({});
115
+ }
116
+
74
117
  //just trigger rerendering
75
- forceUpdate({});
76
118
  }
77
119
  };
120
+
121
+ var setNewFocusedElement = function setNewFocusedElement(index) {
122
+ var _oldFocusedElement$cu;
123
+ var newFocusedElement = index >= 0 ? allRefs[index] : null;
124
+ var oldFocusedElement = focusedRef.current.index >= 0 ? allRefs[focusedRef.current.index] : null;
125
+ focusedRef.current.index = index;
126
+ if (oldFocusedElement) oldFocusedElement === null || oldFocusedElement === void 0 ? void 0 : (_oldFocusedElement$cu = oldFocusedElement.current) === null || _oldFocusedElement$cu === void 0 ? void 0 : _oldFocusedElement$cu.classList.remove('dropdown-hover');
127
+ if (newFocusedElement && newFocusedElement !== oldFocusedElement) {
128
+ var _newFocusedElement$cu, _item$items$index$id;
129
+ (_newFocusedElement$cu = newFocusedElement.current) === null || _newFocusedElement$cu === void 0 ? void 0 : _newFocusedElement$cu.classList.add('dropdown-hover');
130
+ console.log(item.items[index].id);
131
+ onItemFocused && onItemFocused((_item$items$index$id = item.items[index].id) !== null && _item$items$index$id !== void 0 ? _item$items$index$id : '');
132
+ } else if (onItemFocused) onItemFocused('');
133
+ };
78
134
  var onFocus = function onFocus(event) {
135
+ event.stopPropagation();
79
136
  dropdownMenusOpenedArray.current = (0, _toConsumableArray2.default)(nestPath !== null && nestPath !== void 0 ? nestPath : []);
137
+ setNewFocusedElement(0);
80
138
  forceUpdate({});
81
139
  };
140
+ var onBlur = function onBlur(event) {
141
+ event.stopPropagation();
142
+ setNewFocusedElement(-1);
143
+ };
82
144
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(SubMenuWrapper, {
83
145
  id: item.id,
84
146
  className: existingRef ? 'open' : '',
85
147
  topLevel: topLevel,
86
148
  visible: Boolean(existingRef),
87
149
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExtendedMainMenu.Menu, {
88
- role: "menu",
89
- "aria-labelledby": "UserMenuButton",
150
+ role: "group",
151
+ ref: ref,
152
+ "aria-labelledby": ariaLabelledBy,
153
+ onBlur: onBlur,
154
+ onFocus: onFocus,
155
+ onKeyDown: function onKeyDown(event) {
156
+ return _onKeyDown(event);
157
+ },
158
+ tabIndex: 0,
90
159
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExtendedMainMenu.MenuSection, {
91
160
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExtendedMainMenu.MenuSectionList, {
92
161
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tabs.default, {
93
162
  size: _types.Size.Medium,
94
- children: item.items.map(function (entry) {
163
+ children: item.items.map(function (entry, index) {
95
164
  var _entry$label2;
96
165
  var isGroup = entry.type == 'desktopgroup';
97
166
  var key = isGroup ? entry.id : entry.type == 'item' ? entry.to : '';
@@ -99,7 +168,7 @@ var SubMenu = function SubMenu(_ref) {
99
168
  return x == entry.id;
100
169
  }));
101
170
  if (isGroup) {
102
- var _entry$label;
171
+ var _entry$items$find$id, _entry$items$find, _entry$label;
103
172
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
104
173
  style: {
105
174
  position: 'relative'
@@ -111,12 +180,17 @@ var SubMenu = function SubMenu(_ref) {
111
180
  return _onMouseLeave(event, entry.id);
112
181
  },
113
182
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_MenuItem.MenuItem, {
114
- tabIndex: 0,
115
- onFocus: onFocus,
116
- onKeyDown: function onKeyDown(event) {
117
- return _onKeyDown(event, entry.id);
118
- },
119
- id: entry.id,
183
+ id: entry.id + '_parentOption',
184
+ "aria-expanded": Boolean(SubItemOpened),
185
+ "aria-activedescendant": (_entry$items$find$id = (_entry$items$find = entry.items.find(function (x) {
186
+ return x.id == focusedItemId;
187
+ })) === null || _entry$items$find === void 0 ? void 0 : _entry$items$find.id) !== null && _entry$items$find$id !== void 0 ? _entry$items$find$id : '',
188
+ tabIndex: -1,
189
+ ref: allRefs[index],
190
+ "aria-controls": entry.id,
191
+ role: "group"
192
+ //id={entry.id} removing this can break something
193
+ ,
120
194
  item: {
121
195
  value: (_entry$label = entry.label) !== null && _entry$label !== void 0 ? _entry$label : ''
122
196
  },
@@ -126,6 +200,10 @@ var SubMenu = function SubMenu(_ref) {
126
200
  active: SubItemOpened || Boolean(activeItemId) && activeItemId != '' && (0, _utils.checkIfContainsItem)(entry, activeItemId),
127
201
  onClickHandler: function onClickHandler() {}
128
202
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(SubMenu, {
203
+ ariaLabelledBy: entry.id + '_parentOption',
204
+ onItemFocused: onItemFocused,
205
+ focusedItemId: focusedItemId,
206
+ ref: subMenuRefs[index],
129
207
  nestPath: [].concat((0, _toConsumableArray2.default)(nestPath !== null && nestPath !== void 0 ? nestPath : []), [entry.id]),
130
208
  onItemStateChanged: onItemStateChanged,
131
209
  activeItemId: activeItemId,
@@ -138,8 +216,10 @@ var SubMenu = function SubMenu(_ref) {
138
216
  }
139
217
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
140
218
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TabLink.default, {
219
+ id: entry.id,
220
+ tabIndex: -1,
141
221
  to: isGroup ? '' : key,
142
- onFocus: onFocus,
222
+ ref: allRefs[index],
143
223
  onActiveStateChanged: function onActiveStateChanged(state) {
144
224
  return onItemStateChanged && entry.type == 'item' && onItemStateChanged(entry.to, state);
145
225
  },
@@ -162,7 +242,7 @@ var SubMenu = function SubMenu(_ref) {
162
242
  })
163
243
  })
164
244
  });
165
- };
245
+ });
166
246
  exports.SubMenu = SubMenu;
167
247
  SubMenu.propTypes = {
168
248
  index: _propTypes.default.number.isRequired,
@@ -170,7 +250,10 @@ SubMenu.propTypes = {
170
250
  onSubMenuOpened: _propTypes.default.func,
171
251
  onSubMenuHidden: _propTypes.default.func,
172
252
  onItemStateChanged: _propTypes.default.func,
253
+ onItemFocused: _propTypes.default.func,
254
+ focusedItemId: _propTypes.default.string,
173
255
  activeItemId: _propTypes.default.string,
174
- nestPath: _propTypes.default.arrayOf(_propTypes.default.string)
256
+ nestPath: _propTypes.default.arrayOf(_propTypes.default.string),
257
+ ariaLabelledBy: _propTypes.default.string
175
258
  };
176
259
  //# sourceMappingURL=SubMenu.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"SubMenu.cjs","names":["SubMenuWrapper","styled","div","Menu","props","topLevel","visible","SubMenu","item","index","dropdownMenusOpenedArray","onSubMenuHidden","onSubMenuOpened","onItemStateChanged","activeItemId","nestPath","React","useState","forceUpdate","existingRef","current","find","x","id","onMouseLeave","event","filter","containActiveItem","type","checkIfContainsItem","onMouseEnter","existingRefForId","onKeyDown","entryId","key","code","onFocus","Boolean","Size","Medium","items","map","entry","isGroup","to","SubItemOpened","position","value","label","state","disabled"],"sources":["../../../src/GlobalNavigationBar/desktop/SubMenu.tsx"],"sourcesContent":["import * as React from 'react';\nimport styled from 'styled-components';\n\nimport { Menu, MenuSection, MenuSectionList } from './ExtendedMainMenu';\nimport { MenuNavigationItemTypeDesktopGroup } from '../types';\nimport { Size } from '../../types';\nimport { SystemIcons } from '../../icons';\nimport { checkIfContainsItem } from '../utils';\nimport Tabs from '../../Tabs/Tabs';\nimport TabLink from '../../Tabs/TabLink';\nimport { MenuItem } from '../../MenuItem';\n\nexport type SubMenuProps = {\n item: MenuNavigationItemTypeDesktopGroup;\n index: number;\n topLevel: boolean;\n dropdownMenusOpenedArray: React.MutableRefObject<string[]>;\n onSubMenuOpened?: (item: string) => void;\n onSubMenuHidden?: (item: string) => void;\n onItemStateChanged?: (item: string, state: boolean) => void;\n activeItemId?: string;\n nestPath?: string[];\n};\n\nexport const SubMenuWrapper = styled.div<{ topLevel: boolean, visible: boolean }>`\n ${Menu} {\n top: ${(props) => (props.topLevel ? '100%' : '0px')};\n left: ${(props) => (props.topLevel ? '0px' : 'calc(100% - 12px)')};\n }\n\n ${props => !props.visible ? 'display: none;' : ''}\n\n button {\n padding-left: 0px;\n }\n`;\n\nexport const SubMenu = ({ item, index, topLevel, dropdownMenusOpenedArray, onSubMenuHidden, onSubMenuOpened, onItemStateChanged, activeItemId, nestPath }: SubMenuProps): React.ReactElement<SubMenuProps> => {\n const [, forceUpdate] = React.useState({});\n\n const existingRef = dropdownMenusOpenedArray.current.find((x) => x == item.id);\n const onMouseLeave = (event: any, id: string) => {\n dropdownMenusOpenedArray.current = [...dropdownMenusOpenedArray.current.filter((x) => x != id)];\n //just trigger rerendering\n onSubMenuHidden && onSubMenuHidden(id);\n forceUpdate({});\n };\n let containActiveItem = false;\n if(item.type == 'desktopgroup' && activeItemId)\n containActiveItem = checkIfContainsItem(item, activeItemId);\n\n const onMouseEnter = (event: any, id: string) => {\n const existingRefForId = dropdownMenusOpenedArray.current.find((x) => x == id);\n if (existingRefForId == null) {\n dropdownMenusOpenedArray.current = [...dropdownMenusOpenedArray.current, id];\n //just trigger rerendering\n onSubMenuOpened && onSubMenuOpened(id);\n forceUpdate({});\n }\n };\n\n const onKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>, entryId: string) => {\n if(event.key == 'Enter' || event.code == 'Space')\n {\n dropdownMenusOpenedArray.current = [...dropdownMenusOpenedArray.current, entryId];\n //just trigger rerendering\n forceUpdate({});\n }\n };\n\n const onFocus = (event: React.FocusEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n dropdownMenusOpenedArray.current = [...(nestPath ?? [])];\n forceUpdate({});\n }\n\n return <SubMenuWrapper id={item.id} className={existingRef ? 'open' : ''} topLevel={topLevel} visible={Boolean(existingRef)}>\n <Menu role=\"menu\" aria-labelledby=\"UserMenuButton\">\n <MenuSection>\n <MenuSectionList>\n <Tabs size={Size.Medium}>\n {item.items.map((entry) => {\n const isGroup = entry.type == 'desktopgroup';\n const key = isGroup ? entry.id : entry.type == 'item' ? entry.to : '';\n const SubItemOpened = Boolean(dropdownMenusOpenedArray.current.find((x) => x == entry.id));\n if (isGroup) {\n return (\n <div style={{ position: 'relative' }} onMouseEnter={(event) => onMouseEnter(event, entry.id)} onMouseLeave={(event) => onMouseLeave(event, entry.id)}>\n <MenuItem\n tabIndex={0}\n onFocus={onFocus}\n onKeyDown={(event) => onKeyDown(event, entry.id)}\n id={entry.id}\n item={{\n value: entry.label ?? '',\n }}\n iconRight={<SystemIcons.ArrowDropRight size=\"24px\" />}\n active={SubItemOpened || (Boolean(activeItemId) && activeItemId != '' && checkIfContainsItem(entry, activeItemId!))}\n onClickHandler={() => {}}\n />\n <SubMenu nestPath={[...(nestPath ?? []), entry.id]} onItemStateChanged={onItemStateChanged} activeItemId={activeItemId} dropdownMenusOpenedArray={dropdownMenusOpenedArray} item={entry as MenuNavigationItemTypeDesktopGroup} index={index + 1} topLevel={false} />\n </div>\n );\n }\n return (\n <>\n <TabLink\n key={key}\n to={isGroup ? '' : key}\n onFocus={onFocus}\n onActiveStateChanged={(state) => onItemStateChanged && entry.type == 'item' && onItemStateChanged(entry.to, state)}\n forceDeactivate={isGroup}\n requiredLine={entry.label ?? ''}\n optionalLine={''}\n endLineIcon={isGroup ? <SystemIcons.ArrowDropRight size=\"24px\" /> : null}\n OptionalLineIcon={''}\n disabled={entry.disabled}\n showNotificationDot={false}\n size={Size.Medium}\n variant=\"positive\"\n />\n </>\n );\n })}\n </Tabs>\n </MenuSectionList>\n </MenuSection>\n </Menu>\n </SubMenuWrapper>;\n};\n"],"mappings":";;;;;;;;;;;;AAAA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AAA0C;AAAA;AAAA;AAAA;AAcnC,IAAMA,cAAc,GAAGC,yBAAM,CAACC,GAAG,2LACpCC,sBAAI,EACG,UAACC,KAAK;EAAA,OAAMA,KAAK,CAACC,QAAQ,GAAG,MAAM,GAAG,KAAK;AAAA,CAAC,EAC3C,UAACD,KAAK;EAAA,OAAMA,KAAK,CAACC,QAAQ,GAAG,KAAK,GAAG,mBAAmB;AAAA,CAAC,EAGjE,UAAAD,KAAK;EAAA,OAAI,CAACA,KAAK,CAACE,OAAO,GAAG,gBAAgB,GAAG,EAAE;AAAA,EAKlD;AAAC;AAEK,IAAMC,OAAO,GAAG,SAAVA,OAAO,OAA0L;EAAA,IAApLC,IAAI,QAAJA,IAAI;IAAEC,KAAK,QAALA,KAAK;IAAEJ,QAAQ,QAARA,QAAQ;IAAEK,wBAAwB,QAAxBA,wBAAwB;IAAEC,eAAe,QAAfA,eAAe;IAAEC,eAAe,QAAfA,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AQ,EAAE;kBAAM,EAAG;gBAAA,EAChQ;cAEV;cACA,oBACE;gBAAA,uBACE,qBAAC,gBAAO;kBAEN,EAAE,EAAEkC,OAAO,GAAG,EAAE,GAAGT,GAAI;kBACvB,OAAO,EAAEE,OAAQ;kBACjB,oBAAoB,EAAE,8BAACa,KAAK;oBAAA,OAAKpC,kBAAkB,IAAI6B,KAAK,CAACd,IAAI,IAAI,MAAM,IAAIf,kBAAkB,CAAC6B,KAAK,CAACE,EAAE,EAAEK,KAAK,CAAC;kBAAA,CAAC;kBACnH,eAAe,EAAEN,OAAQ;kBACzB,YAAY,mBAAED,KAAK,CAACM,KAAK,yDAAI,EAAG;kBAChC,YAAY,EAAE,EAAG;kBACjB,WAAW,EAAEL,OAAO,gBAAG,qBAAC,kBAAW,CAAC,cAAc;oBAAC,IAAI,EAAC;kBAAM,EAAG,GAAG,IAAK;kBACzE,gBAAgB,EAAE,EAAG;kBACrB,QAAQ,EAAED,KAAK,CAACQ,QAAS;kBACzB,mBAAmB,EAAE,KAAM;kBAC3B,IAAI,EAAEZ,WAAI,CAACC,MAAO;kBAClB,OAAO,EAAC;gBAAU,GAZbL,GAAG;cAaR,EACD;YAEP,CAAC;UAAC;QACG;MACS;IACN;EACT,EACQ;AACrB,CAAC;AAAC;AAAA;EAlHAzB,KAAK;EACLJ,QAAQ;EAERO,eAAe;EACfD,eAAe;EACfE,kBAAkB;EAClBC,YAAY;EACZC,QAAQ;AAAA"}
1
+ {"version":3,"file":"SubMenu.cjs","names":["SubMenuWrapper","styled","div","Menu","props","topLevel","visible","SubMenu","React","forwardRef","ref","item","index","dropdownMenusOpenedArray","onSubMenuHidden","onSubMenuOpened","onItemStateChanged","focusedItemId","activeItemId","nestPath","ariaLabelledBy","onItemFocused","useState","forceUpdate","focusedRef","useRef","allRefs","setAllRefs","subMenuRefs","setAllSubMenuRefs","useEffect","items","map","x","type","createRef","undefined","existingRef","current","find","id","onMouseLeave","event","filter","containActiveItem","checkIfContainsItem","onMouseEnter","existingRefForId","onKeyDown","e","key","stopPropagation","preventDefault","setNewFocusedElement","length","code","focusedItem","click","newFocusedElement","oldFocusedElement","classList","remove","add","console","log","onFocus","onBlur","Boolean","Size","Medium","entry","isGroup","to","SubItemOpened","position","value","label","state","disabled"],"sources":["../../../src/GlobalNavigationBar/desktop/SubMenu.tsx"],"sourcesContent":["import * as React from 'react';\nimport styled from 'styled-components';\n\nimport { Menu, MenuSection, MenuSectionList } from './ExtendedMainMenu';\nimport { MenuNavigationItemTypeDesktopGroup } from '../types';\nimport { Size } from '../../types';\nimport { SystemIcons } from '../../icons';\nimport { checkIfContainsItem } from '../utils';\nimport Tabs from '../../Tabs/Tabs';\nimport TabLink from '../../Tabs/TabLink';\nimport { MenuItem } from '../../MenuItem';\n\nexport type SubMenuProps = {\n item: MenuNavigationItemTypeDesktopGroup;\n index: number;\n topLevel: boolean;\n dropdownMenusOpenedArray: React.MutableRefObject<string[]>;\n onSubMenuOpened?: (item: string) => void;\n onSubMenuHidden?: (item: string) => void;\n onItemStateChanged?: (item: string, state: boolean) => void;\n onItemFocused?: (item: string) => void;\n focusedItemId?: string;\n activeItemId?: string;\n nestPath?: string[];\n ariaLabelledBy?: string;\n};\n\nexport const SubMenuWrapper = styled.div<{ topLevel: boolean; visible: boolean }>`\n ${Menu} {\n top: ${(props) => (props.topLevel ? '100%' : '0px')};\n left: ${(props) => (props.topLevel ? '0px' : 'calc(100% - 12px)')};\n }\n\n ${(props) => (!props.visible ? 'display: none;' : '')}\n\n button {\n padding-left: 0px;\n }\n`;\n\nexport const SubMenu = React.forwardRef<HTMLUListElement, SubMenuProps>(({\n item,\n index,\n topLevel,\n dropdownMenusOpenedArray,\n onSubMenuHidden,\n onSubMenuOpened,\n onItemStateChanged,\n focusedItemId,\n activeItemId,\n nestPath,\n ariaLabelledBy,\n onItemFocused\n}: SubMenuProps, ref): React.ReactElement<SubMenuProps> => {\n const [, forceUpdate] = React.useState({});\n const focusedRef = React.useRef<{ index: number }>({ index: -1 });\n const [allRefs, setAllRefs] = React.useState<React.RefObject<HTMLButtonElement | HTMLAnchorElement>[]>([]);\n const [subMenuRefs, setAllSubMenuRefs] = React.useState<(React.RefObject<HTMLUListElement> | undefined)[]>([]);\n\n React.useEffect(() => {\n setAllRefs(item.items.map((x) => (x.type == 'desktopgroup' ? React.createRef<HTMLButtonElement>() : React.createRef<HTMLAnchorElement>())));\n setAllSubMenuRefs(item.items.map((x) => (x.type == 'desktopgroup' ? React.createRef<HTMLUListElement>() : undefined)));\n }, [item]);\n\n const existingRef = dropdownMenusOpenedArray.current.find((x) => x == item.id);\n const onMouseLeave = (event: any, id: string) => {\n dropdownMenusOpenedArray.current = [...dropdownMenusOpenedArray.current.filter((x) => x != id)];\n //just trigger rerendering\n onSubMenuHidden && onSubMenuHidden(id);\n forceUpdate({});\n };\n let containActiveItem = false;\n if (item.type == 'desktopgroup' && activeItemId) containActiveItem = checkIfContainsItem(item, activeItemId);\n\n const onMouseEnter = (event: any, id: string) => {\n const existingRefForId = dropdownMenusOpenedArray.current.find((x) => x == id);\n if (existingRefForId == null) {\n dropdownMenusOpenedArray.current = [...dropdownMenusOpenedArray.current, id];\n //just trigger rerendering\n onSubMenuOpened && onSubMenuOpened(id);\n forceUpdate({});\n }\n };\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLUListElement>) => {\n \n if (e.key === 'ArrowUp' || e.key === 'Up') {\n e.stopPropagation();\n e.preventDefault();\n if (focusedRef.current.index > 0) {\n setNewFocusedElement(focusedRef.current.index - 1);\n }\n } else if (e.key === 'ArrowDown' || e.key === 'Down') {\n e.stopPropagation();\n e.preventDefault();\n if(focusedRef.current.index < allRefs.length - 1)\n setNewFocusedElement(focusedRef.current.index + 1);\n } \n else\n if (e.key == 'Enter' || e.code == 'Space') {\n e.stopPropagation();\n if(focusedRef.current.index < 0)\n return;\n \n const focusedItem = item.items[focusedRef.current.index];\n if(focusedItem.type == 'desktopgroup')\n {\n dropdownMenusOpenedArray.current = [...dropdownMenusOpenedArray.current, focusedItem.id];\n forceUpdate({});\n }\n else\n {\n allRefs[focusedRef.current.index].current?.click();\n forceUpdate({});\n }\n\n //just trigger rerendering\n \n }\n };\n\n const setNewFocusedElement = (index: number) => {\n const newFocusedElement = index >= 0 ? allRefs[index] : null;\n const oldFocusedElement = focusedRef.current.index >= 0 ? allRefs[focusedRef.current.index] : null;\n focusedRef.current.index = index;\n\n if(oldFocusedElement)\n oldFocusedElement?.current?.classList.remove('dropdown-hover');\n\n if (newFocusedElement && newFocusedElement !== oldFocusedElement) {\n newFocusedElement.current?.classList.add('dropdown-hover');\n console.log(item.items[index].id);\n onItemFocused && onItemFocused(item.items[index].id ?? '');\n }\n else if(onItemFocused)\n onItemFocused('');\n };\n\n const onFocus = (event: React.FocusEvent<HTMLUListElement>) => {\n event.stopPropagation();\n dropdownMenusOpenedArray.current = [...(nestPath ?? [])];\n setNewFocusedElement(0);\n forceUpdate({});\n \n };\n\n const onBlur = (event: React.FocusEvent<HTMLUListElement>) => {\n event.stopPropagation();\n setNewFocusedElement(-1);\n };\n\n return (\n <SubMenuWrapper id={item.id} className={existingRef ? 'open' : '' } topLevel={topLevel} visible={Boolean(existingRef)}>\n <Menu role=\"group\" ref={ref} aria-labelledby={ariaLabelledBy} onBlur={onBlur} onFocus={onFocus} onKeyDown={(event) => onKeyDown(event)} tabIndex={0}>\n <MenuSection>\n <MenuSectionList>\n <Tabs size={Size.Medium}>\n {item.items.map((entry, index) => {\n const isGroup = entry.type == 'desktopgroup';\n const key = isGroup ? entry.id : entry.type == 'item' ? entry.to : '';\n const SubItemOpened = Boolean(dropdownMenusOpenedArray.current.find((x) => x == entry.id));\n if (isGroup) {\n return (\n <div style={{ position: 'relative' }} onMouseEnter={(event) => onMouseEnter(event, entry.id)} onMouseLeave={(event) => onMouseLeave(event, entry.id)}>\n <MenuItem\n id={entry.id + '_parentOption'}\n aria-expanded={Boolean(SubItemOpened)}\n aria-activedescendant={entry.items.find(x => x.id == focusedItemId)?.id ?? ''}\n tabIndex={-1}\n ref={allRefs[index] as React.Ref<HTMLButtonElement>}\n \n aria-controls={entry.id}\n role=\"group\"\n //id={entry.id} removing this can break something\n item={{\n value: entry.label ?? '',\n }}\n iconRight={<SystemIcons.ArrowDropRight size=\"24px\" />}\n active={SubItemOpened || (Boolean(activeItemId) && activeItemId != '' && checkIfContainsItem(entry, activeItemId!))}\n onClickHandler={() => {}}\n />\n <SubMenu\n ariaLabelledBy={entry.id + '_parentOption'}\n onItemFocused={onItemFocused}\n focusedItemId={focusedItemId}\n ref={subMenuRefs[index]}\n nestPath={[...(nestPath ?? []), entry.id]}\n onItemStateChanged={onItemStateChanged}\n activeItemId={activeItemId}\n dropdownMenusOpenedArray={dropdownMenusOpenedArray}\n item={entry as MenuNavigationItemTypeDesktopGroup}\n index={index + 1}\n topLevel={false}\n />\n </div>\n );\n }\n return (\n <>\n <TabLink\n id={entry.id}\n tabIndex={-1}\n key={key}\n to={isGroup ? '' : key}\n ref={allRefs[index] as React.Ref<HTMLAnchorElement>}\n onActiveStateChanged={(state) => onItemStateChanged && entry.type == 'item' && onItemStateChanged(entry.to, state)}\n forceDeactivate={isGroup}\n requiredLine={entry.label ?? ''}\n optionalLine={''}\n endLineIcon={isGroup ? <SystemIcons.ArrowDropRight size=\"24px\" /> : null}\n OptionalLineIcon={''}\n disabled={entry.disabled}\n showNotificationDot={false}\n size={Size.Medium}\n variant=\"positive\"\n />\n </>\n );\n })}\n </Tabs>\n </MenuSectionList>\n </MenuSection>\n </Menu>\n </SubMenuWrapper>\n );\n});\n"],"mappings":";;;;;;;;;;;;AAAA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AAA0C;AAAA;AAAA;AAAA;AAiBnC,IAAMA,cAAc,GAAGC,yBAAM,CAACC,GAAG,2LACpCC,sBAAI,EACG,UAACC,KAAK;EAAA,OAAMA,KAAK,CAACC,QAAQ,GAAG,MAAM,GAAG,KAAK;AAAA,CAAC,EAC3C,UAACD,KAAK;EAAA,OAAMA,KAA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Q;AAErB,CAAC,CAAC;AAAC;AAAA;EAnNDtC,KAAK;EACLP,QAAQ;EAERU,eAAe;EACfD,eAAe;EACfE,kBAAkB;EAClBK,aAAa;EACbJ,aAAa;EACbC,YAAY;EACZC,QAAQ;EACRC,cAAc;AAAA"}
@@ -8,11 +8,14 @@ export type SubMenuProps = {
8
8
  onSubMenuOpened?: (item: string) => void;
9
9
  onSubMenuHidden?: (item: string) => void;
10
10
  onItemStateChanged?: (item: string, state: boolean) => void;
11
+ onItemFocused?: (item: string) => void;
12
+ focusedItemId?: string;
11
13
  activeItemId?: string;
12
14
  nestPath?: string[];
15
+ ariaLabelledBy?: string;
13
16
  };
14
17
  export declare const SubMenuWrapper: import("styled-components").StyledComponent<"div", any, {
15
18
  topLevel: boolean;
16
19
  visible: boolean;
17
20
  }, never>;
18
- export declare const SubMenu: ({ item, index, topLevel, dropdownMenusOpenedArray, onSubMenuHidden, onSubMenuOpened, onItemStateChanged, activeItemId, nestPath }: SubMenuProps) => React.ReactElement<SubMenuProps>;
21
+ export declare const SubMenu: React.ForwardRefExoticComponent<SubMenuProps & React.RefAttributes<HTMLUListElement>>;
@@ -22,7 +22,7 @@ export var SubMenuWrapper = styled.div(_templateObject || (_templateObject = _ta
22
22
  }, function (props) {
23
23
  return !props.visible ? 'display: none;' : '';
24
24
  });
25
- export var SubMenu = function SubMenu(_ref) {
25
+ export var SubMenu = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
26
26
  var item = _ref.item,
27
27
  index = _ref.index,
28
28
  topLevel = _ref.topLevel,
@@ -30,11 +30,33 @@ export var SubMenu = function SubMenu(_ref) {
30
30
  onSubMenuHidden = _ref.onSubMenuHidden,
31
31
  onSubMenuOpened = _ref.onSubMenuOpened,
32
32
  onItemStateChanged = _ref.onItemStateChanged,
33
+ focusedItemId = _ref.focusedItemId,
33
34
  activeItemId = _ref.activeItemId,
34
- nestPath = _ref.nestPath;
35
+ nestPath = _ref.nestPath,
36
+ ariaLabelledBy = _ref.ariaLabelledBy,
37
+ onItemFocused = _ref.onItemFocused;
35
38
  var _React$useState = React.useState({}),
36
39
  _React$useState2 = _slicedToArray(_React$useState, 2),
37
40
  forceUpdate = _React$useState2[1];
41
+ var focusedRef = React.useRef({
42
+ index: -1
43
+ });
44
+ var _React$useState3 = React.useState([]),
45
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
46
+ allRefs = _React$useState4[0],
47
+ setAllRefs = _React$useState4[1];
48
+ var _React$useState5 = React.useState([]),
49
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
50
+ subMenuRefs = _React$useState6[0],
51
+ setAllSubMenuRefs = _React$useState6[1];
52
+ React.useEffect(function () {
53
+ setAllRefs(item.items.map(function (x) {
54
+ return x.type == 'desktopgroup' ? /*#__PURE__*/React.createRef() : /*#__PURE__*/React.createRef();
55
+ }));
56
+ setAllSubMenuRefs(item.items.map(function (x) {
57
+ return x.type == 'desktopgroup' ? /*#__PURE__*/React.createRef() : undefined;
58
+ }));
59
+ }, [item]);
38
60
  var existingRef = dropdownMenusOpenedArray.current.find(function (x) {
39
61
  return x == item.id;
40
62
  });
@@ -59,30 +81,77 @@ export var SubMenu = function SubMenu(_ref) {
59
81
  forceUpdate({});
60
82
  }
61
83
  };
62
- var _onKeyDown = function onKeyDown(event, entryId) {
63
- if (event.key == 'Enter' || event.code == 'Space') {
64
- dropdownMenusOpenedArray.current = [].concat(_toConsumableArray(dropdownMenusOpenedArray.current), [entryId]);
84
+ var _onKeyDown = function onKeyDown(e) {
85
+ if (e.key === 'ArrowUp' || e.key === 'Up') {
86
+ e.stopPropagation();
87
+ e.preventDefault();
88
+ if (focusedRef.current.index > 0) {
89
+ setNewFocusedElement(focusedRef.current.index - 1);
90
+ }
91
+ } else if (e.key === 'ArrowDown' || e.key === 'Down') {
92
+ e.stopPropagation();
93
+ e.preventDefault();
94
+ if (focusedRef.current.index < allRefs.length - 1) setNewFocusedElement(focusedRef.current.index + 1);
95
+ } else if (e.key == 'Enter' || e.code == 'Space') {
96
+ e.stopPropagation();
97
+ if (focusedRef.current.index < 0) return;
98
+ var focusedItem = item.items[focusedRef.current.index];
99
+ if (focusedItem.type == 'desktopgroup') {
100
+ dropdownMenusOpenedArray.current = [].concat(_toConsumableArray(dropdownMenusOpenedArray.current), [focusedItem.id]);
101
+ forceUpdate({});
102
+ } else {
103
+ var _allRefs$focusedRef$c;
104
+ (_allRefs$focusedRef$c = allRefs[focusedRef.current.index].current) === null || _allRefs$focusedRef$c === void 0 ? void 0 : _allRefs$focusedRef$c.click();
105
+ forceUpdate({});
106
+ }
107
+
65
108
  //just trigger rerendering
66
- forceUpdate({});
67
109
  }
68
110
  };
111
+
112
+ var setNewFocusedElement = function setNewFocusedElement(index) {
113
+ var _oldFocusedElement$cu;
114
+ var newFocusedElement = index >= 0 ? allRefs[index] : null;
115
+ var oldFocusedElement = focusedRef.current.index >= 0 ? allRefs[focusedRef.current.index] : null;
116
+ focusedRef.current.index = index;
117
+ if (oldFocusedElement) oldFocusedElement === null || oldFocusedElement === void 0 ? void 0 : (_oldFocusedElement$cu = oldFocusedElement.current) === null || _oldFocusedElement$cu === void 0 ? void 0 : _oldFocusedElement$cu.classList.remove('dropdown-hover');
118
+ if (newFocusedElement && newFocusedElement !== oldFocusedElement) {
119
+ var _newFocusedElement$cu, _item$items$index$id;
120
+ (_newFocusedElement$cu = newFocusedElement.current) === null || _newFocusedElement$cu === void 0 ? void 0 : _newFocusedElement$cu.classList.add('dropdown-hover');
121
+ console.log(item.items[index].id);
122
+ onItemFocused && onItemFocused((_item$items$index$id = item.items[index].id) !== null && _item$items$index$id !== void 0 ? _item$items$index$id : '');
123
+ } else if (onItemFocused) onItemFocused('');
124
+ };
69
125
  var onFocus = function onFocus(event) {
126
+ event.stopPropagation();
70
127
  dropdownMenusOpenedArray.current = _toConsumableArray(nestPath !== null && nestPath !== void 0 ? nestPath : []);
128
+ setNewFocusedElement(0);
71
129
  forceUpdate({});
72
130
  };
131
+ var onBlur = function onBlur(event) {
132
+ event.stopPropagation();
133
+ setNewFocusedElement(-1);
134
+ };
73
135
  return /*#__PURE__*/_jsx(SubMenuWrapper, {
74
136
  id: item.id,
75
137
  className: existingRef ? 'open' : '',
76
138
  topLevel: topLevel,
77
139
  visible: Boolean(existingRef),
78
140
  children: /*#__PURE__*/_jsx(Menu, {
79
- role: "menu",
80
- "aria-labelledby": "UserMenuButton",
141
+ role: "group",
142
+ ref: ref,
143
+ "aria-labelledby": ariaLabelledBy,
144
+ onBlur: onBlur,
145
+ onFocus: onFocus,
146
+ onKeyDown: function onKeyDown(event) {
147
+ return _onKeyDown(event);
148
+ },
149
+ tabIndex: 0,
81
150
  children: /*#__PURE__*/_jsx(MenuSection, {
82
151
  children: /*#__PURE__*/_jsx(MenuSectionList, {
83
152
  children: /*#__PURE__*/_jsx(Tabs, {
84
153
  size: Size.Medium,
85
- children: item.items.map(function (entry) {
154
+ children: item.items.map(function (entry, index) {
86
155
  var _entry$label2;
87
156
  var isGroup = entry.type == 'desktopgroup';
88
157
  var key = isGroup ? entry.id : entry.type == 'item' ? entry.to : '';
@@ -90,7 +159,7 @@ export var SubMenu = function SubMenu(_ref) {
90
159
  return x == entry.id;
91
160
  }));
92
161
  if (isGroup) {
93
- var _entry$label;
162
+ var _entry$items$find$id, _entry$items$find, _entry$label;
94
163
  return /*#__PURE__*/_jsxs("div", {
95
164
  style: {
96
165
  position: 'relative'
@@ -102,12 +171,17 @@ export var SubMenu = function SubMenu(_ref) {
102
171
  return _onMouseLeave(event, entry.id);
103
172
  },
104
173
  children: [/*#__PURE__*/_jsx(MenuItem, {
105
- tabIndex: 0,
106
- onFocus: onFocus,
107
- onKeyDown: function onKeyDown(event) {
108
- return _onKeyDown(event, entry.id);
109
- },
110
- id: entry.id,
174
+ id: entry.id + '_parentOption',
175
+ "aria-expanded": Boolean(SubItemOpened),
176
+ "aria-activedescendant": (_entry$items$find$id = (_entry$items$find = entry.items.find(function (x) {
177
+ return x.id == focusedItemId;
178
+ })) === null || _entry$items$find === void 0 ? void 0 : _entry$items$find.id) !== null && _entry$items$find$id !== void 0 ? _entry$items$find$id : '',
179
+ tabIndex: -1,
180
+ ref: allRefs[index],
181
+ "aria-controls": entry.id,
182
+ role: "group"
183
+ //id={entry.id} removing this can break something
184
+ ,
111
185
  item: {
112
186
  value: (_entry$label = entry.label) !== null && _entry$label !== void 0 ? _entry$label : ''
113
187
  },
@@ -117,6 +191,10 @@ export var SubMenu = function SubMenu(_ref) {
117
191
  active: SubItemOpened || Boolean(activeItemId) && activeItemId != '' && checkIfContainsItem(entry, activeItemId),
118
192
  onClickHandler: function onClickHandler() {}
119
193
  }), /*#__PURE__*/_jsx(SubMenu, {
194
+ ariaLabelledBy: entry.id + '_parentOption',
195
+ onItemFocused: onItemFocused,
196
+ focusedItemId: focusedItemId,
197
+ ref: subMenuRefs[index],
120
198
  nestPath: [].concat(_toConsumableArray(nestPath !== null && nestPath !== void 0 ? nestPath : []), [entry.id]),
121
199
  onItemStateChanged: onItemStateChanged,
122
200
  activeItemId: activeItemId,
@@ -129,8 +207,10 @@ export var SubMenu = function SubMenu(_ref) {
129
207
  }
130
208
  return /*#__PURE__*/_jsx(_Fragment, {
131
209
  children: /*#__PURE__*/_jsx(TabLink, {
210
+ id: entry.id,
211
+ tabIndex: -1,
132
212
  to: isGroup ? '' : key,
133
- onFocus: onFocus,
213
+ ref: allRefs[index],
134
214
  onActiveStateChanged: function onActiveStateChanged(state) {
135
215
  return onItemStateChanged && entry.type == 'item' && onItemStateChanged(entry.to, state);
136
216
  },
@@ -153,14 +233,17 @@ export var SubMenu = function SubMenu(_ref) {
153
233
  })
154
234
  })
155
235
  });
156
- };
236
+ });
157
237
  SubMenu.propTypes = {
158
238
  index: _pt.number.isRequired,
159
239
  topLevel: _pt.bool.isRequired,
160
240
  onSubMenuOpened: _pt.func,
161
241
  onSubMenuHidden: _pt.func,
162
242
  onItemStateChanged: _pt.func,
243
+ onItemFocused: _pt.func,
244
+ focusedItemId: _pt.string,
163
245
  activeItemId: _pt.string,
164
- nestPath: _pt.arrayOf(_pt.string)
246
+ nestPath: _pt.arrayOf(_pt.string),
247
+ ariaLabelledBy: _pt.string
165
248
  };
166
249
  //# sourceMappingURL=SubMenu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SubMenu.js","names":["React","styled","Menu","MenuSection","MenuSectionList","Size","SystemIcons","checkIfContainsItem","Tabs","TabLink","MenuItem","SubMenuWrapper","div","props","topLevel","visible","SubMenu","item","index","dropdownMenusOpenedArray","onSubMenuHidden","onSubMenuOpened","onItemStateChanged","activeItemId","nestPath","useState","forceUpdate","existingRef","current","find","x","id","onMouseLeave","event","filter","containActiveItem","type","onMouseEnter","existingRefForId","onKeyDown","entryId","key","code","onFocus","Boolean","Medium","items","map","entry","isGroup","to","SubItemOpened","position","value","label","state","disabled"],"sources":["../../../src/GlobalNavigationBar/desktop/SubMenu.tsx"],"sourcesContent":["import * as React from 'react';\nimport styled from 'styled-components';\n\nimport { Menu, MenuSection, MenuSectionList } from './ExtendedMainMenu';\nimport { MenuNavigationItemTypeDesktopGroup } from '../types';\nimport { Size } from '../../types';\nimport { SystemIcons } from '../../icons';\nimport { checkIfContainsItem } from '../utils';\nimport Tabs from '../../Tabs/Tabs';\nimport TabLink from '../../Tabs/TabLink';\nimport { MenuItem } from '../../MenuItem';\n\nexport type SubMenuProps = {\n item: MenuNavigationItemTypeDesktopGroup;\n index: number;\n topLevel: boolean;\n dropdownMenusOpenedArray: React.MutableRefObject<string[]>;\n onSubMenuOpened?: (item: string) => void;\n onSubMenuHidden?: (item: string) => void;\n onItemStateChanged?: (item: string, state: boolean) => void;\n activeItemId?: string;\n nestPath?: string[];\n};\n\nexport const SubMenuWrapper = styled.div<{ topLevel: boolean, visible: boolean }>`\n ${Menu} {\n top: ${(props) => (props.topLevel ? '100%' : '0px')};\n left: ${(props) => (props.topLevel ? '0px' : 'calc(100% - 12px)')};\n }\n\n ${props => !props.visible ? 'display: none;' : ''}\n\n button {\n padding-left: 0px;\n }\n`;\n\nexport const SubMenu = ({ item, index, topLevel, dropdownMenusOpenedArray, onSubMenuHidden, onSubMenuOpened, onItemStateChanged, activeItemId, nestPath }: SubMenuProps): React.ReactElement<SubMenuProps> => {\n const [, forceUpdate] = React.useState({});\n\n const existingRef = dropdownMenusOpenedArray.current.find((x) => x == item.id);\n const onMouseLeave = (event: any, id: string) => {\n dropdownMenusOpenedArray.current = [...dropdownMenusOpenedArray.current.filter((x) => x != id)];\n //just trigger rerendering\n onSubMenuHidden && onSubMenuHidden(id);\n forceUpdate({});\n };\n let containActiveItem = false;\n if(item.type == 'desktopgroup' && activeItemId)\n containActiveItem = checkIfContainsItem(item, activeItemId);\n\n const onMouseEnter = (event: any, id: string) => {\n const existingRefForId = dropdownMenusOpenedArray.current.find((x) => x == id);\n if (existingRefForId == null) {\n dropdownMenusOpenedArray.current = [...dropdownMenusOpenedArray.current, id];\n //just trigger rerendering\n onSubMenuOpened && onSubMenuOpened(id);\n forceUpdate({});\n }\n };\n\n const onKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>, entryId: string) => {\n if(event.key == 'Enter' || event.code == 'Space')\n {\n dropdownMenusOpenedArray.current = [...dropdownMenusOpenedArray.current, entryId];\n //just trigger rerendering\n forceUpdate({});\n }\n };\n\n const onFocus = (event: React.FocusEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n dropdownMenusOpenedArray.current = [...(nestPath ?? [])];\n forceUpdate({});\n }\n\n return <SubMenuWrapper id={item.id} className={existingRef ? 'open' : ''} topLevel={topLevel} visible={Boolean(existingRef)}>\n <Menu role=\"menu\" aria-labelledby=\"UserMenuButton\">\n <MenuSection>\n <MenuSectionList>\n <Tabs size={Size.Medium}>\n {item.items.map((entry) => {\n const isGroup = entry.type == 'desktopgroup';\n const key = isGroup ? entry.id : entry.type == 'item' ? entry.to : '';\n const SubItemOpened = Boolean(dropdownMenusOpenedArray.current.find((x) => x == entry.id));\n if (isGroup) {\n return (\n <div style={{ position: 'relative' }} onMouseEnter={(event) => onMouseEnter(event, entry.id)} onMouseLeave={(event) => onMouseLeave(event, entry.id)}>\n <MenuItem\n tabIndex={0}\n onFocus={onFocus}\n onKeyDown={(event) => onKeyDown(event, entry.id)}\n id={entry.id}\n item={{\n value: entry.label ?? '',\n }}\n iconRight={<SystemIcons.ArrowDropRight size=\"24px\" />}\n active={SubItemOpened || (Boolean(activeItemId) && activeItemId != '' && checkIfContainsItem(entry, activeItemId!))}\n onClickHandler={() => {}}\n />\n <SubMenu nestPath={[...(nestPath ?? []), entry.id]} onItemStateChanged={onItemStateChanged} activeItemId={activeItemId} dropdownMenusOpenedArray={dropdownMenusOpenedArray} item={entry as MenuNavigationItemTypeDesktopGroup} index={index + 1} topLevel={false} />\n </div>\n );\n }\n return (\n <>\n <TabLink\n key={key}\n to={isGroup ? '' : key}\n onFocus={onFocus}\n onActiveStateChanged={(state) => onItemStateChanged && entry.type == 'item' && onItemStateChanged(entry.to, state)}\n forceDeactivate={isGroup}\n requiredLine={entry.label ?? ''}\n optionalLine={''}\n endLineIcon={isGroup ? <SystemIcons.ArrowDropRight size=\"24px\" /> : null}\n OptionalLineIcon={''}\n disabled={entry.disabled}\n showNotificationDot={false}\n size={Size.Medium}\n variant=\"positive\"\n />\n </>\n );\n })}\n </Tabs>\n </MenuSectionList>\n </MenuSection>\n </Menu>\n </SubMenuWrapper>;\n};\n"],"mappings":";;;;;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,MAAM,MAAM,mBAAmB;AAEtC,SAASC,IAAI,EAAEC,WAAW,EAAEC,eAAe,QAAQ,oBAAoB;AAEvE,SAASC,IAAI,QAAQ,aAAa;AAClC,SAASC,WAAW,QAAQ,aAAa;AACzC,SAASC,mBAAmB,QAAQ,UAAU;AAC9C,OAAOC,IAAI,MAAM,iBAAiB;AAClC,OAAOC,OAAO,MAAM,oBAAoB;AACxC,SAASC,QAAQ,QAAQ,gBAAgB;AAAC;AAAA;AAAA;AAc1C,OAAO,IAAMC,cAAc,GAAGV,MAAM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;UAAC;QACG;MACS;IACN;EACT,EACQ;AACrB,CAAC;AAAC;EAlHAvB,KAAK;EACLJ,QAAQ;EAERO,eAAe;EACfD,eAAe;EACfE,kBAAkB;EAClBC,YAAY;EACZC,QAAQ;AAAA"}
1
+ {"version":3,"file":"SubMenu.js","names":["React","styled","Menu","MenuSection","MenuSectionList","Size","SystemIcons","checkIfContainsItem","Tabs","TabLink","MenuItem","SubMenuWrapper","div","props","topLevel","visible","SubMenu","forwardRef","ref","item","index","dropdownMenusOpenedArray","onSubMenuHidden","onSubMenuOpened","onItemStateChanged","focusedItemId","activeItemId","nestPath","ariaLabelledBy","onItemFocused","useState","forceUpdate","focusedRef","useRef","allRefs","setAllRefs","subMenuRefs","setAllSubMenuRefs","useEffect","items","map","x","type","createRef","undefined","existingRef","current","find","id","onMouseLeave","event","filter","containActiveItem","onMouseEnter","existingRefForId","onKeyDown","e","key","stopPropagation","preventDefault","setNewFocusedElement","length","code","focusedItem","click","newFocusedElement","oldFocusedElement","classList","remove","add","console","log","onFocus","onBlur","Boolean","Medium","entry","isGroup","to","SubItemOpened","position","value","label","state","disabled"],"sources":["../../../src/GlobalNavigationBar/desktop/SubMenu.tsx"],"sourcesContent":["import * as React from 'react';\nimport styled from 'styled-components';\n\nimport { Menu, MenuSection, MenuSectionList } from './ExtendedMainMenu';\nimport { MenuNavigationItemTypeDesktopGroup } from '../types';\nimport { Size } from '../../types';\nimport { SystemIcons } from '../../icons';\nimport { checkIfContainsItem } from '../utils';\nimport Tabs from '../../Tabs/Tabs';\nimport TabLink from '../../Tabs/TabLink';\nimport { MenuItem } from '../../MenuItem';\n\nexport type SubMenuProps = {\n item: MenuNavigationItemTypeDesktopGroup;\n index: number;\n topLevel: boolean;\n dropdownMenusOpenedArray: React.MutableRefObject<string[]>;\n onSubMenuOpened?: (item: string) => void;\n onSubMenuHidden?: (item: string) => void;\n onItemStateChanged?: (item: string, state: boolean) => void;\n onItemFocused?: (item: string) => void;\n focusedItemId?: string;\n activeItemId?: string;\n nestPath?: string[];\n ariaLabelledBy?: string;\n};\n\nexport const SubMenuWrapper = styled.div<{ topLevel: boolean; visible: boolean }>`\n ${Menu} {\n top: ${(props) => (props.topLevel ? '100%' : '0px')};\n left: ${(props) => (props.topLevel ? '0px' : 'calc(100% - 12px)')};\n }\n\n ${(props) => (!props.visible ? 'display: none;' : '')}\n\n button {\n padding-left: 0px;\n }\n`;\n\nexport const SubMenu = React.forwardRef<HTMLUListElement, SubMenuProps>(({\n item,\n index,\n topLevel,\n dropdownMenusOpenedArray,\n onSubMenuHidden,\n onSubMenuOpened,\n onItemStateChanged,\n focusedItemId,\n activeItemId,\n nestPath,\n ariaLabelledBy,\n onItemFocused\n}: SubMenuProps, ref): React.ReactElement<SubMenuProps> => {\n const [, forceUpdate] = React.useState({});\n const focusedRef = React.useRef<{ index: number }>({ index: -1 });\n const [allRefs, setAllRefs] = React.useState<React.RefObject<HTMLButtonElement | HTMLAnchorElement>[]>([]);\n const [subMenuRefs, setAllSubMenuRefs] = React.useState<(React.RefObject<HTMLUListElement> | undefined)[]>([]);\n\n React.useEffect(() => {\n setAllRefs(item.items.map((x) => (x.type == 'desktopgroup' ? React.createRef<HTMLButtonElement>() : React.createRef<HTMLAnchorElement>())));\n setAllSubMenuRefs(item.items.map((x) => (x.type == 'desktopgroup' ? React.createRef<HTMLUListElement>() : undefined)));\n }, [item]);\n\n const existingRef = dropdownMenusOpenedArray.current.find((x) => x == item.id);\n const onMouseLeave = (event: any, id: string) => {\n dropdownMenusOpenedArray.current = [...dropdownMenusOpenedArray.current.filter((x) => x != id)];\n //just trigger rerendering\n onSubMenuHidden && onSubMenuHidden(id);\n forceUpdate({});\n };\n let containActiveItem = false;\n if (item.type == 'desktopgroup' && activeItemId) containActiveItem = checkIfContainsItem(item, activeItemId);\n\n const onMouseEnter = (event: any, id: string) => {\n const existingRefForId = dropdownMenusOpenedArray.current.find((x) => x == id);\n if (existingRefForId == null) {\n dropdownMenusOpenedArray.current = [...dropdownMenusOpenedArray.current, id];\n //just trigger rerendering\n onSubMenuOpened && onSubMenuOpened(id);\n forceUpdate({});\n }\n };\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLUListElement>) => {\n \n if (e.key === 'ArrowUp' || e.key === 'Up') {\n e.stopPropagation();\n e.preventDefault();\n if (focusedRef.current.index > 0) {\n setNewFocusedElement(focusedRef.current.index - 1);\n }\n } else if (e.key === 'ArrowDown' || e.key === 'Down') {\n e.stopPropagation();\n e.preventDefault();\n if(focusedRef.current.index < allRefs.length - 1)\n setNewFocusedElement(focusedRef.current.index + 1);\n } \n else\n if (e.key == 'Enter' || e.code == 'Space') {\n e.stopPropagation();\n if(focusedRef.current.index < 0)\n return;\n \n const focusedItem = item.items[focusedRef.current.index];\n if(focusedItem.type == 'desktopgroup')\n {\n dropdownMenusOpenedArray.current = [...dropdownMenusOpenedArray.current, focusedItem.id];\n forceUpdate({});\n }\n else\n {\n allRefs[focusedRef.current.index].current?.click();\n forceUpdate({});\n }\n\n //just trigger rerendering\n \n }\n };\n\n const setNewFocusedElement = (index: number) => {\n const newFocusedElement = index >= 0 ? allRefs[index] : null;\n const oldFocusedElement = focusedRef.current.index >= 0 ? allRefs[focusedRef.current.index] : null;\n focusedRef.current.index = index;\n\n if(oldFocusedElement)\n oldFocusedElement?.current?.classList.remove('dropdown-hover');\n\n if (newFocusedElement && newFocusedElement !== oldFocusedElement) {\n newFocusedElement.current?.classList.add('dropdown-hover');\n console.log(item.items[index].id);\n onItemFocused && onItemFocused(item.items[index].id ?? '');\n }\n else if(onItemFocused)\n onItemFocused('');\n };\n\n const onFocus = (event: React.FocusEvent<HTMLUListElement>) => {\n event.stopPropagation();\n dropdownMenusOpenedArray.current = [...(nestPath ?? [])];\n setNewFocusedElement(0);\n forceUpdate({});\n \n };\n\n const onBlur = (event: React.FocusEvent<HTMLUListElement>) => {\n event.stopPropagation();\n setNewFocusedElement(-1);\n };\n\n return (\n <SubMenuWrapper id={item.id} className={existingRef ? 'open' : '' } topLevel={topLevel} visible={Boolean(existingRef)}>\n <Menu role=\"group\" ref={ref} aria-labelledby={ariaLabelledBy} onBlur={onBlur} onFocus={onFocus} onKeyDown={(event) => onKeyDown(event)} tabIndex={0}>\n <MenuSection>\n <MenuSectionList>\n <Tabs size={Size.Medium}>\n {item.items.map((entry, index) => {\n const isGroup = entry.type == 'desktopgroup';\n const key = isGroup ? entry.id : entry.type == 'item' ? entry.to : '';\n const SubItemOpened = Boolean(dropdownMenusOpenedArray.current.find((x) => x == entry.id));\n if (isGroup) {\n return (\n <div style={{ position: 'relative' }} onMouseEnter={(event) => onMouseEnter(event, entry.id)} onMouseLeave={(event) => onMouseLeave(event, entry.id)}>\n <MenuItem\n id={entry.id + '_parentOption'}\n aria-expanded={Boolean(SubItemOpened)}\n aria-activedescendant={entry.items.find(x => x.id == focusedItemId)?.id ?? ''}\n tabIndex={-1}\n ref={allRefs[index] as React.Ref<HTMLButtonElement>}\n \n aria-controls={entry.id}\n role=\"group\"\n //id={entry.id} removing this can break something\n item={{\n value: entry.label ?? '',\n }}\n iconRight={<SystemIcons.ArrowDropRight size=\"24px\" />}\n active={SubItemOpened || (Boolean(activeItemId) && activeItemId != '' && checkIfContainsItem(entry, activeItemId!))}\n onClickHandler={() => {}}\n />\n <SubMenu\n ariaLabelledBy={entry.id + '_parentOption'}\n onItemFocused={onItemFocused}\n focusedItemId={focusedItemId}\n ref={subMenuRefs[index]}\n nestPath={[...(nestPath ?? []), entry.id]}\n onItemStateChanged={onItemStateChanged}\n activeItemId={activeItemId}\n dropdownMenusOpenedArray={dropdownMenusOpenedArray}\n item={entry as MenuNavigationItemTypeDesktopGroup}\n index={index + 1}\n topLevel={false}\n />\n </div>\n );\n }\n return (\n <>\n <TabLink\n id={entry.id}\n tabIndex={-1}\n key={key}\n to={isGroup ? '' : key}\n ref={allRefs[index] as React.Ref<HTMLAnchorElement>}\n onActiveStateChanged={(state) => onItemStateChanged && entry.type == 'item' && onItemStateChanged(entry.to, state)}\n forceDeactivate={isGroup}\n requiredLine={entry.label ?? ''}\n optionalLine={''}\n endLineIcon={isGroup ? <SystemIcons.ArrowDropRight size=\"24px\" /> : null}\n OptionalLineIcon={''}\n disabled={entry.disabled}\n showNotificationDot={false}\n size={Size.Medium}\n variant=\"positive\"\n />\n </>\n );\n })}\n </Tabs>\n </MenuSectionList>\n </MenuSection>\n </Menu>\n </SubMenuWrapper>\n );\n});\n"],"mappings":";;;;;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,MAAM,MAAM,mBAAmB;AAEtC,SAASC,IAAI,EAAEC,WAAW,EAAEC,eAAe,QAAQ,oBAAoB;AAEvE,SAASC,IAAI,QAAQ,aAAa;AAClC,SAASC,WAAW,QAAQ,aAAa;AACzC,SAASC,mBAAmB,QAAQ,UAAU;AAC9C,OAAOC,IAAI,MAAM,iBAAiB;AAClC,OAAOC,OAAO,MAAM,oBAAoB;AACxC,SAASC,QAAQ,QAAQ,gBAAgB;AAAC;AAAA;AAAA;AAiB1C,OAAO,IAAMC,cAAc,GAAGV,MAAM,CAACW,GAAG,6KACpCV,IAAI,EACG,UAACW,KAAK;EAAA,OAAMA,KAAK,CAACC,QAAQ,GAAG,MAAM,GAAG,KAAK;AAAA,CAAC,EAC3C,UAACD,KAAK;EAAA,OAAMA,KAAK,CAACC,QAAQ,GAAG,KAAK,GAAG,mBAAmB;AAAA,CAAC,EAGjE,UAACD,KAAK;EAAA,OAAM,CAACA,KAAK,CAACE,OAAO,GAAG,gBAAgB,GAAG,EAAE;AAAA,CAAC,CAKtD;AAED,OAAO,IAAMC,OAAO,gBAAGhB,KAAK,CAACiB,UAAU,CAAiC,gBAavDC,GAAG,EAAuC;EAAA,IAZzDC,IAAI,QAAJA,IAAI;IACJC,KAAK,QAALA,KAAK;IACLN,QAAQ,QAARA,QAAQ;IACRO,wBAAwB,QAAxBA,wBAAwB;IACxBC,eAAe,QAAfA,eAAe;IACfC,eAAe,QAAfA,eAAe;IACfC,kBAAkB,QAAlBA,kBA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E,EAAEwD,KAAK,CAAC5B,EAAG;kBACb,QAAQ,EAAE,CAAC,CAAE;kBAEb,EAAE,EAAE6B,OAAO,GAAG,EAAE,GAAGpB,GAAI;kBACvB,GAAG,EAAEvB,OAAO,CAACd,KAAK,CAAkC;kBACpD,oBAAoB,EAAE,8BAAC+D,KAAK;oBAAA,OAAK3D,kBAAkB,IAAIoD,KAAK,CAAClC,IAAI,IAAI,MAAM,IAAIlB,kBAAkB,CAACoD,KAAK,CAACE,EAAE,EAAEK,KAAK,CAAC;kBAAA,CAAC;kBACnH,eAAe,EAAEN,OAAQ;kBACzB,YAAY,mBAAED,KAAK,CAACM,KAAK,yDAAI,EAAG;kBAChC,YAAY,EAAE,EAAG;kBACjB,WAAW,EAAEL,OAAO,gBAAG,KAAC,WAAW,CAAC,cAAc;oBAAC,IAAI,EAAC;kBAAM,EAAG,GAAG,IAAK;kBACzE,gBAAgB,EAAE,EAAG;kBACrB,QAAQ,EAAED,KAAK,CAACQ,QAAS;kBACzB,mBAAmB,EAAE,KAAM;kBAC3B,IAAI,EAAE/E,IAAI,CAACsE,MAAO;kBAClB,OAAO,EAAC;gBAAU,GAZblB,GAAG;cAaR,EACD;YAEP,CAAC;UAAC;QACG;MACS;IACN;EACT,EACQ;AAErB,CAAC,CAAC;AAAC;EAnNDrC,KAAK;EACLN,QAAQ;EAERS,eAAe;EACfD,eAAe;EACfE,kBAAkB;EAClBK,aAAa;EACbJ,aAAa;EACbC,YAAY;EACZC,QAAQ;EACRC,cAAc;AAAA"}
@@ -24,9 +24,9 @@ var _excluded = ["items", "order"],
24
24
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _Panel$propTypes;
25
25
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
26
26
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
- var Wrapper = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n background: ", ";\n min-height: 100%;\n align-items: flex-end;\n box-sizing: border-box;\n overflow: hidden;\n\n gap: 24px;\n padding: 56px 32px 120px 32px;\n\n p {\n flex: 1;\n color: ", ";\n }\n\n ", " {\n gap: 32px;\n padding: 56px 64px 120px 64px;\n }\n\n &.reverse {\n align-items: flex-start;\n }\n"])), _styles.COLORS.neutral_20, _styles.COLORS.neutral_600, _styles.BREAKPOINTS.LARGE);
27
+ var Wrapper = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n background: ", ";\n min-height: 100%;\n align-items: flex-end;\n box-sizing: border-box;\n overflow: hidden;\n\n gap: 24px;\n padding: 24px 32px 64px;\n\n ", " {\n gap: 32px;\n padding: 32px 64px 128px;\n }\n\n &.reverse {\n align-items: flex-start;\n }\n"])), _styles.COLORS.neutral_20, _styles.BREAKPOINTS.LARGE);
28
28
  var Media = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n width: 320px;\n height: 200px;\n\n\n img {\n object-fit: contain;\n }\n\n img.fit {\n object-fit: contain;\n }\n\n img.fill {\n object-fit: cover;\n }\n\n max-width: 100%;\n\n img {\n max-width: 100%;\n width: 320px;\n height: 200px;\n }\n\n ", " {\n width: 488px;\n height: 280px;\n\n img {\n width: 488px;\n height: 280px;\n }\n }\n\n"])), _styles.BREAKPOINTS.LARGE);
29
- var Body = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n text-align: center;\n\n max-width: 320px;\n\n ", " {\n max-width: 488px;\n }\n\n"])), _styles.BREAKPOINTS.LARGE);
29
+ var Body = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n text-align: center;\n\n width: 100%;\n max-width: 320px;\n\n ", " {\n max-width: 488px;\n }\n \n p:not(:first-of-type) {\n flex: 1;\n color: ", ";\n }\n\n\n"])), _styles.BREAKPOINTS.LARGE, _styles.COLORS.neutral_600);
30
30
  var Footer = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n\n max-width: 320px;\n\n ", " {\n max-width: 488px;\n }\n\n .progress {\n width: max-content;\n }\n"])), _styles.BREAKPOINTS.LARGE);
31
31
  var Panel = function Panel(props) {
32
32
  var _currentItem$media, _currentItem$media2;
@@ -82,7 +82,7 @@ var Panel = function Panel(props) {
82
82
  alt: currentItem.media.alt
83
83
  }), ((_currentItem$media2 = currentItem.media) === null || _currentItem$media2 === void 0 ? void 0 : _currentItem$media2.type) === 'custom' && currentItem.media.content]
84
84
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Body, {
85
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h1", {
85
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.Quote, {
86
86
  children: currentItem.title
87
87
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
88
88
  children: currentItem.content
@@ -94,7 +94,7 @@ var Panel = function Panel(props) {
94
94
  shape: 'circular',
95
95
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.SystemIcons.ChevronLeft, {})
96
96
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_LinearProgress.LinearProgress, {
97
- size: isLargeScreen ? _types.Size.Medium : _types.Size.Small,
97
+ size: isLargeScreen ? _types.Size.Large : _types.Size.Small,
98
98
  className: 'progress',
99
99
  value: currentImage + 1,
100
100
  max: props.items.length,