@contentful/f36-menu 4.0.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.
package/dist/main.js ADDED
@@ -0,0 +1,714 @@
1
+ var $6ZrLO$react = require("react");
2
+ var $6ZrLO$contentfulf36core = require("@contentful/f36-core");
3
+ var $6ZrLO$contentfulf36popover = require("@contentful/f36-popover");
4
+ var $6ZrLO$emotion = require("emotion");
5
+ var $6ZrLO$contentfulf36tokens = require("@contentful/f36-tokens");
6
+ var $6ZrLO$contentfulf36typography = require("@contentful/f36-typography");
7
+ var $6ZrLO$contentfulf36icons = require("@contentful/f36-icons");
8
+
9
+ function $parcel$export(e, n, v, s) {
10
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
11
+ }
12
+ function $parcel$interopDefault(a) {
13
+ return a && a.__esModule ? a.default : a;
14
+ }
15
+
16
+ $parcel$export(module.exports, "Menu", () => $c2cdaffe72abf66f$export$d9b273488cd8ce6f);
17
+ $parcel$export(module.exports, "MenuList", () => $c5bfee6901fd5b47$export$d4c4e98c5044dc8);
18
+ $parcel$export(module.exports, "MenuItem", () => $01d29448a29c05b3$export$2ce376c2cc3355c8);
19
+ $parcel$export(module.exports, "MenuTrigger", () => $57a0b88402c05a1e$export$27d2ad3c5815583e);
20
+ $parcel$export(module.exports, "MenuDivider", () => $a8d7f8a94ad9b120$export$acb07b4664ac227c);
21
+ $parcel$export(module.exports, "MenuSectionTitle", () => $a9e47e1a6fcc6dbc$export$5d1e6c648985631e);
22
+ $parcel$export(module.exports, "Submenu", () => $d1c454a08dd2b04a$export$49229ebf838c159b);
23
+ $parcel$export(module.exports, "SubmenuTrigger", () => $68e427819b978177$export$ecabc99eeffab7ca);
24
+
25
+
26
+
27
+ const $9abfe5cafeb7e9d3$var$ARROW_KEY_TYPES = {
28
+ vertical: {
29
+ prev: 'ArrowUp',
30
+ next: 'ArrowDown'
31
+ },
32
+ horizontal: {
33
+ prev: 'ArrowLeft',
34
+ next: 'ArrowRight'
35
+ }
36
+ };
37
+ const $9abfe5cafeb7e9d3$export$e8d01079a7f85a7 = ({ itemsContainerRef: itemsContainerRef , itemsSelector: itemsSelector , keyType: keyType = 'vertical' })=>{
38
+ const [focusedIndex, setFocusedIndex] = $6ZrLO$react.useState(0);
39
+ const handleArrowsKeyDown = $6ZrLO$react.useCallback((event)=>{
40
+ const container = itemsContainerRef.current;
41
+ if (!container) return;
42
+ const items = container.querySelectorAll(itemsSelector);
43
+ if (items.length === 0) return;
44
+ const lastItemIndex = items.length - 1;
45
+ const focusFirstItem = ()=>setFocusedIndex(0)
46
+ ;
47
+ const focusLastItem = ()=>setFocusedIndex(lastItemIndex)
48
+ ;
49
+ const focusNextItem = ()=>{
50
+ if (focusedIndex === lastItemIndex) focusFirstItem();
51
+ else setFocusedIndex(focusedIndex + 1);
52
+ };
53
+ const focusPrevItem = ()=>{
54
+ if (focusedIndex === 0) focusLastItem();
55
+ else setFocusedIndex(focusedIndex - 1);
56
+ };
57
+ const keyToFnMap = {
58
+ [$9abfe5cafeb7e9d3$var$ARROW_KEY_TYPES[keyType].next]: focusNextItem,
59
+ [$9abfe5cafeb7e9d3$var$ARROW_KEY_TYPES[keyType].prev]: focusPrevItem
60
+ };
61
+ const fn = keyToFnMap[event.key];
62
+ if (fn) {
63
+ event.preventDefault();
64
+ fn();
65
+ }
66
+ }, [
67
+ focusedIndex,
68
+ itemsSelector,
69
+ itemsContainerRef,
70
+ keyType
71
+ ]);
72
+ return {
73
+ focusedIndex: focusedIndex,
74
+ handleArrowsKeyDown: handleArrowsKeyDown,
75
+ setFocusedIndex: setFocusedIndex
76
+ };
77
+ };
78
+
79
+
80
+
81
+
82
+ const $31bc1b2a74a830dc$var$MenuContext = ($parcel$interopDefault($6ZrLO$react)).createContext(undefined);
83
+ const $31bc1b2a74a830dc$export$21c7ab35b39f78ec = ()=>{
84
+ const context = ($parcel$interopDefault($6ZrLO$react)).useContext($31bc1b2a74a830dc$var$MenuContext);
85
+ if (context === undefined) throw new Error('useMenuContext must be used within a MenuContextProvider');
86
+ return context;
87
+ };
88
+ const $31bc1b2a74a830dc$export$2cad3fd48ac06579 = $31bc1b2a74a830dc$var$MenuContext.Provider;
89
+
90
+
91
+ const $453ff7c40e833219$var$MENU_ITEMS_SELECTOR = '[role="menuitem"]:not(:disabled)';
92
+ function $453ff7c40e833219$export$d9b273488cd8ce6f(props) {
93
+ const { closeOnSelect: closeOnSelect = true , closeOnBlur: closeOnBlur = true , closeOnEsc: closeOnEsc = true , children: children , onOpen: onOpen , ...otherProps } = props;
94
+ const { isOpen: isOpen , handleOpen: handleOpen , handleClose: handleClose , isControlled: isControlled } = $453ff7c40e833219$var$useMenuOpenState(props);
95
+ const triggerRef = $6ZrLO$react.useRef(null);
96
+ const menuListRef = $6ZrLO$react.useRef(null);
97
+ const menuId = $6ZrLO$contentfulf36core.useId(null, 'menu');
98
+ const { focusedIndex: focusedIndex , handleArrowsKeyDown: handleArrowsKeyDown , setFocusedIndex: setFocusedIndex } = $9abfe5cafeb7e9d3$export$e8d01079a7f85a7({
99
+ itemsContainerRef: menuListRef,
100
+ itemsSelector: $453ff7c40e833219$var$MENU_ITEMS_SELECTOR
101
+ });
102
+ $6ZrLO$react.useEffect(()=>{
103
+ if (isOpen && menuListRef.current) {
104
+ const menuItems = menuListRef.current.querySelectorAll($453ff7c40e833219$var$MENU_ITEMS_SELECTOR);
105
+ if (menuItems.length > 0 && focusedIndex < menuItems.length) // timeout trick to prevent scroll from jumping
106
+ // when the popover is not positioned correctly yet in the opening phase
107
+ setTimeout(()=>{
108
+ menuItems[focusedIndex].focus({
109
+ preventScroll: false
110
+ });
111
+ }, 0);
112
+ }
113
+ }, [
114
+ isOpen,
115
+ focusedIndex
116
+ ]);
117
+ const focusMenuItem = $6ZrLO$react.useCallback((item)=>{
118
+ const menuItems = menuListRef.current.querySelectorAll($453ff7c40e833219$var$MENU_ITEMS_SELECTOR);
119
+ const itemIndex = [
120
+ ...menuItems
121
+ ].findIndex((menuItem)=>item === menuItem
122
+ );
123
+ if (itemIndex !== -1) setFocusedIndex(itemIndex);
124
+ }, [
125
+ setFocusedIndex
126
+ ]);
127
+ const closeAndFocusTrigger = $6ZrLO$react.useCallback(()=>{
128
+ var ref;
129
+ handleClose();
130
+ (ref = triggerRef.current) === null || ref === void 0 ? void 0 : ref.focus({
131
+ preventScroll: true
132
+ });
133
+ }, [
134
+ handleClose
135
+ ]);
136
+ const handleMenuListKeyDown = $6ZrLO$react.useCallback((event)=>{
137
+ if (event.key === 'Tab') {
138
+ event.preventDefault();
139
+ closeAndFocusTrigger();
140
+ return;
141
+ } // we don't want to propagate other keydown events except `Tab`
142
+ event.stopPropagation();
143
+ if (event.key === 'ArrowLeft') {
144
+ event.preventDefault();
145
+ closeAndFocusTrigger();
146
+ return;
147
+ }
148
+ handleArrowsKeyDown(event);
149
+ }, [
150
+ closeAndFocusTrigger,
151
+ handleArrowsKeyDown
152
+ ]);
153
+ const contextValue = $6ZrLO$react.useMemo(()=>{
154
+ return {
155
+ isOpen: isOpen,
156
+ menuId: menuId,
157
+ focusMenuItem: focusMenuItem,
158
+ getTriggerProps: (_props = {
159
+ }, _ref = null)=>{
160
+ return {
161
+ onClick: (event)=>{
162
+ var ref;
163
+ // if the user made component controlled by providing isOpen prop
164
+ // but onOpen callback is not provided, we won't add toggle logic
165
+ // to the trigger component. So they can make any toggle logic on their own.
166
+ const isFullyControlled = isControlled && !onOpen;
167
+ if (!isFullyControlled) {
168
+ if (isOpen) handleClose();
169
+ else handleOpen();
170
+ }
171
+ (ref = _props.onClick) === null || ref === void 0 ? void 0 : ref.call(_props, event);
172
+ },
173
+ ref: $6ZrLO$contentfulf36core.mergeRefs(triggerRef, _ref)
174
+ };
175
+ },
176
+ getMenuListProps: (_props = {
177
+ }, _ref = null)=>{
178
+ return {
179
+ ref: $6ZrLO$contentfulf36core.mergeRefs(menuListRef, _ref),
180
+ onKeyDown: (event)=>{
181
+ var ref;
182
+ handleMenuListKeyDown(event);
183
+ (ref = _props.onKeyDown) === null || ref === void 0 ? void 0 : ref.call(_props, event);
184
+ },
185
+ onBlur: (event)=>{
186
+ var ref, ref1, ref2, ref3;
187
+ (ref = _props.onBlur) === null || ref === void 0 ? void 0 : ref.call(_props, event);
188
+ if (!closeOnBlur) return;
189
+ const relatedTarget = event.relatedTarget;
190
+ const targetIsMenu = menuListRef.current === relatedTarget || ((ref1 = menuListRef.current) === null || ref1 === void 0 ? void 0 : ref1.contains(relatedTarget));
191
+ const targetIsTrigger = triggerRef.current === relatedTarget || ((ref2 = triggerRef.current) === null || ref2 === void 0 ? void 0 : ref2.contains(relatedTarget));
192
+ const targetIsSubmenu = (relatedTarget === null || relatedTarget === void 0 ? void 0 : (ref3 = relatedTarget.parentElement) === null || ref3 === void 0 ? void 0 : ref3.dataset.parentMenu) === menuId;
193
+ if (targetIsMenu || targetIsTrigger || targetIsSubmenu) {
194
+ event.stopPropagation();
195
+ return;
196
+ }
197
+ handleClose();
198
+ }
199
+ };
200
+ },
201
+ getMenuItemProps: (_props = {
202
+ })=>{
203
+ return {
204
+ onClick: (event)=>{
205
+ var ref;
206
+ (ref = _props.onClick) === null || ref === void 0 ? void 0 : ref.call(_props, event);
207
+ const isSubmenuTrigger = Boolean(event.target.getAttribute('aria-haspopup'));
208
+ if (closeOnSelect && !isSubmenuTrigger) closeAndFocusTrigger();
209
+ }
210
+ };
211
+ },
212
+ propsToPropagateToSubmenus: {
213
+ closeOnSelect: closeOnSelect,
214
+ closeOnBlur: closeOnBlur,
215
+ closeOnEsc: closeOnEsc
216
+ }
217
+ };
218
+ }, [
219
+ menuId,
220
+ isOpen,
221
+ handleMenuListKeyDown,
222
+ closeOnSelect,
223
+ handleClose,
224
+ handleOpen,
225
+ focusMenuItem,
226
+ closeOnBlur,
227
+ closeOnEsc,
228
+ closeAndFocusTrigger,
229
+ isControlled,
230
+ onOpen
231
+ ]);
232
+ return(/*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).createElement($31bc1b2a74a830dc$export$2cad3fd48ac06579, {
233
+ value: contextValue
234
+ }, /*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).createElement($6ZrLO$contentfulf36popover.Popover, {
235
+ ...otherProps,
236
+ isOpen: isOpen,
237
+ onClose: handleClose,
238
+ id: menuId,
239
+ closeOnEsc: closeOnEsc,
240
+ autoFocus: false,
241
+ closeOnBlur: false
242
+ }, children)));
243
+ }
244
+ const $453ff7c40e833219$var$useMenuOpenState = (props)=>{
245
+ const { isOpen: isOpen , defaultIsOpen: defaultIsOpen , onOpen: onOpen , onClose: onClose } = props;
246
+ const [isOpenState, setIsOpen] = $6ZrLO$react.useState(defaultIsOpen || false);
247
+ const isControlled = isOpen !== undefined;
248
+ const isOpenValue = isControlled ? isOpen : isOpenState;
249
+ const handleClose = $6ZrLO$react.useCallback(()=>{
250
+ if (!isControlled) setIsOpen(false);
251
+ onClose === null || onClose === void 0 ? void 0 : onClose();
252
+ }, [
253
+ isControlled,
254
+ onClose
255
+ ]);
256
+ const handleOpen = $6ZrLO$react.useCallback(()=>{
257
+ if (!isControlled) setIsOpen(true);
258
+ onOpen === null || onOpen === void 0 ? void 0 : onOpen();
259
+ }, [
260
+ isControlled,
261
+ onOpen
262
+ ]);
263
+ return {
264
+ isOpen: isOpenValue,
265
+ isControlled: isControlled,
266
+ handleClose: handleClose,
267
+ handleOpen: handleOpen
268
+ };
269
+ };
270
+
271
+
272
+
273
+
274
+
275
+
276
+ const $62b35dc82bb7def8$var$SubmenuContext = ($parcel$interopDefault($6ZrLO$react)).createContext(undefined);
277
+ const $62b35dc82bb7def8$export$958673a266cbe049 = ()=>{
278
+ const context = ($parcel$interopDefault($6ZrLO$react)).useContext($62b35dc82bb7def8$var$SubmenuContext);
279
+ return context;
280
+ };
281
+ const $62b35dc82bb7def8$export$81b3dbd1f003f0c7 = $62b35dc82bb7def8$var$SubmenuContext.Provider;
282
+
283
+
284
+
285
+
286
+
287
+ const $ce9788dc1cd48a1b$export$396ce14bde1b7929 = ()=>{
288
+ return(/*#__PURE__*/ $6ZrLO$emotion.css({
289
+ position: 'sticky',
290
+ top: 0,
291
+ left: 0,
292
+ backgroundColor: ($parcel$interopDefault($6ZrLO$contentfulf36tokens)).colorWhite,
293
+ borderBottom: `1px solid ${($parcel$interopDefault($6ZrLO$contentfulf36tokens)).gray300}`,
294
+ padding: `${($parcel$interopDefault($6ZrLO$contentfulf36tokens)).spacingXs} 0`,
295
+ zIndex: 1001
296
+ }));
297
+ };
298
+ const $ce9788dc1cd48a1b$export$fd3dbc8a890448f = ()=>{
299
+ return(/*#__PURE__*/ $6ZrLO$emotion.css({
300
+ position: 'sticky',
301
+ bottom: 0,
302
+ left: 0,
303
+ backgroundColor: ($parcel$interopDefault($6ZrLO$contentfulf36tokens)).colorWhite,
304
+ borderTop: `1px solid ${($parcel$interopDefault($6ZrLO$contentfulf36tokens)).gray300}`,
305
+ padding: `${($parcel$interopDefault($6ZrLO$contentfulf36tokens)).spacingXs} 0`,
306
+ zIndex: 1001
307
+ }));
308
+ };
309
+ const $ce9788dc1cd48a1b$export$10ce7613b0465b57 = (props)=>({
310
+ container: /*#__PURE__*/ $6ZrLO$emotion.css({
311
+ overflowY: 'auto',
312
+ position: 'relative',
313
+ padding: 0,
314
+ paddingTop: props.hasStickyHeader ? 0 : ($parcel$interopDefault($6ZrLO$contentfulf36tokens)).spacingXs,
315
+ paddingBottom: props.hasStickyFooter ? 0 : ($parcel$interopDefault($6ZrLO$contentfulf36tokens)).spacingXs
316
+ })
317
+ })
318
+ ;
319
+
320
+
321
+
322
+
323
+
324
+ const $77fa76994469c42b$export$77451990ddb9d17c = (props)=>{
325
+ const { children: children , testId: testId = 'cf-ui-menu-list-header' , className: className , ...otherProps } = props;
326
+ const styles = $ce9788dc1cd48a1b$export$396ce14bde1b7929();
327
+ return(/*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).createElement("div", {
328
+ "data-test-id": testId,
329
+ className: $6ZrLO$emotion.cx(styles, className),
330
+ ...otherProps
331
+ }, children));
332
+ };
333
+ $77fa76994469c42b$export$77451990ddb9d17c.displayName = 'MenuListHeader';
334
+
335
+
336
+
337
+
338
+
339
+ const $56409107038e75ac$export$3e8a81e7ad0650f4 = (props)=>{
340
+ const { children: children , testId: testId = 'cf-ui-menu-list-footer' , className: className , ...otherProps } = props;
341
+ const styles = $ce9788dc1cd48a1b$export$fd3dbc8a890448f();
342
+ return(/*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).createElement("div", {
343
+ "data-test-id": testId,
344
+ className: $6ZrLO$emotion.cx(styles, className),
345
+ ...otherProps
346
+ }, children));
347
+ };
348
+ $56409107038e75ac$export$3e8a81e7ad0650f4.displayName = 'MenuListFooter';
349
+
350
+
351
+ function $c5bfee6901fd5b47$var$assertChild(child) {
352
+ var ref;
353
+ return Boolean(child === null || child === void 0 ? void 0 : (ref = child.type) === null || ref === void 0 ? void 0 : ref.displayName);
354
+ }
355
+ const $c5bfee6901fd5b47$var$_MenuList = (props, ref)=>{
356
+ const { children: children , testId: testId = 'cf-ui-menu-list' , className: className , ...otherProps } = props;
357
+ const { getMenuListProps: getMenuListProps } = $31bc1b2a74a830dc$export$21c7ab35b39f78ec();
358
+ const submenuContext = $62b35dc82bb7def8$export$958673a266cbe049();
359
+ let header = null;
360
+ let footer = null;
361
+ const items = [];
362
+ ($parcel$interopDefault($6ZrLO$react)).Children.forEach(children, (child)=>{
363
+ let appendChild = true;
364
+ if ($c5bfee6901fd5b47$var$assertChild(child)) {
365
+ if (child.type.displayName === $77fa76994469c42b$export$77451990ddb9d17c.displayName) {
366
+ header = child;
367
+ appendChild = false;
368
+ } else if (child.type.displayName === $56409107038e75ac$export$3e8a81e7ad0650f4.displayName) {
369
+ footer = child;
370
+ appendChild = false;
371
+ }
372
+ }
373
+ if (appendChild) items.push(child);
374
+ });
375
+ const styles = $ce9788dc1cd48a1b$export$10ce7613b0465b57({
376
+ hasStickyHeader: Boolean(header),
377
+ hasStickyFooter: Boolean(footer)
378
+ });
379
+ const extendedOtherProps = submenuContext ? submenuContext.getSubmenuListProps(otherProps) : otherProps;
380
+ return(/*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).createElement($6ZrLO$contentfulf36popover.Popover.Content, {
381
+ role: "menu",
382
+ ...extendedOtherProps,
383
+ ...getMenuListProps(extendedOtherProps, ref),
384
+ className: $6ZrLO$emotion.cx(styles.container, className),
385
+ testId: testId
386
+ }, header, items, footer));
387
+ };
388
+ const $c5bfee6901fd5b47$export$d4c4e98c5044dc8 = /*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).forwardRef($c5bfee6901fd5b47$var$_MenuList);
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+ const $f099c69f76c1082f$export$adaad53e003c74d0 = ()=>{
401
+ return {
402
+ root: /*#__PURE__*/ $6ZrLO$emotion.css({
403
+ display: 'block',
404
+ width: '100%',
405
+ background: 'none',
406
+ border: 0,
407
+ margin: 0,
408
+ outline: 'none',
409
+ fontSize: ($parcel$interopDefault($6ZrLO$contentfulf36tokens)).fontSizeM,
410
+ lineHeight: ($parcel$interopDefault($6ZrLO$contentfulf36tokens)).lineHeightM,
411
+ fontWeight: ($parcel$interopDefault($6ZrLO$contentfulf36tokens)).fontWeightNormal,
412
+ position: 'relative',
413
+ textAlign: 'left',
414
+ padding: `${($parcel$interopDefault($6ZrLO$contentfulf36tokens)).spacingXs} ${($parcel$interopDefault($6ZrLO$contentfulf36tokens)).spacingM}`,
415
+ wordBreak: 'break-word',
416
+ whiteSpace: 'break-spaces',
417
+ cursor: 'pointer',
418
+ hyphens: 'auto',
419
+ minWidth: '150px',
420
+ textDecoration: 'none',
421
+ color: ($parcel$interopDefault($6ZrLO$contentfulf36tokens)).gray800,
422
+ '&:focus, &:hover': {
423
+ backgroundColor: ($parcel$interopDefault($6ZrLO$contentfulf36tokens)).gray100
424
+ },
425
+ '&:active': {
426
+ backgroundColor: ($parcel$interopDefault($6ZrLO$contentfulf36tokens)).gray200
427
+ },
428
+ '&:disabled': {
429
+ opacity: 0.5,
430
+ cursor: 'auto'
431
+ }
432
+ })
433
+ };
434
+ };
435
+
436
+
437
+ const $01d29448a29c05b3$var$MENU_ITEM_DEFAULT_TAG = 'button';
438
+ function $01d29448a29c05b3$var$_MenuItem(props, ref) {
439
+ const { testId: testId , className: className , as: as , isInitiallyFocused: isInitiallyFocused , ...otherProps } = props;
440
+ const id = $6ZrLO$contentfulf36core.useId(null, 'menu-item');
441
+ const itemTestId = testId || `cf-ui-${id}`;
442
+ const styles = $f099c69f76c1082f$export$adaad53e003c74d0();
443
+ const { getMenuItemProps: getMenuItemProps , focusMenuItem: focusMenuItem } = $31bc1b2a74a830dc$export$21c7ab35b39f78ec();
444
+ const itemRef = $6ZrLO$react.useRef(null);
445
+ $6ZrLO$react.useEffect(()=>{
446
+ if (isInitiallyFocused && itemRef.current) focusMenuItem(itemRef.current);
447
+ }, [
448
+ isInitiallyFocused,
449
+ focusMenuItem
450
+ ]);
451
+ const Element = as !== null && as !== void 0 ? as : $01d29448a29c05b3$var$MENU_ITEM_DEFAULT_TAG;
452
+ return(/*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).createElement(Element, {
453
+ role: "menuitem",
454
+ ...otherProps,
455
+ ...getMenuItemProps(otherProps),
456
+ className: $6ZrLO$emotion.cx(styles.root, className),
457
+ "data-test-id": itemTestId,
458
+ ref: $6ZrLO$contentfulf36core.mergeRefs(itemRef, ref),
459
+ tabIndex: -1
460
+ }, props.children));
461
+ }
462
+ const $01d29448a29c05b3$export$2ce376c2cc3355c8 = /*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).forwardRef($01d29448a29c05b3$var$_MenuItem);
463
+
464
+
465
+
466
+
467
+
468
+ const $57a0b88402c05a1e$export$27d2ad3c5815583e = (props)=>{
469
+ const child = ($parcel$interopDefault($6ZrLO$react)).Children.only(props.children);
470
+ const { getTriggerProps: getTriggerProps } = $31bc1b2a74a830dc$export$21c7ab35b39f78ec();
471
+ return(/*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).createElement($6ZrLO$contentfulf36popover.Popover.Trigger, null, /*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).cloneElement(child, {
472
+ ...getTriggerProps(child.props, child.ref),
473
+ ['aria-haspopup']: 'menu'
474
+ })));
475
+ };
476
+
477
+
478
+
479
+
480
+
481
+
482
+ const $f85a558bae23a8bd$export$4605da6f9a8ef405 = ()=>/*#__PURE__*/ $6ZrLO$emotion.css({
483
+ border: 'none',
484
+ width: '100%',
485
+ height: '1px',
486
+ background: ($parcel$interopDefault($6ZrLO$contentfulf36tokens)).gray300,
487
+ margin: `${($parcel$interopDefault($6ZrLO$contentfulf36tokens)).spacingXs} 0`
488
+ })
489
+ ;
490
+
491
+
492
+ const $a8d7f8a94ad9b120$export$acb07b4664ac227c = (props)=>{
493
+ const { children: children , testId: testId = 'cf-ui-menu-divider' , className: className , ...otherProps } = props;
494
+ const styles = $f85a558bae23a8bd$export$4605da6f9a8ef405();
495
+ return(/*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).createElement("hr", {
496
+ "aria-orientation": "horizontal",
497
+ "data-test-id": testId,
498
+ className: $6ZrLO$emotion.cx(styles, className),
499
+ ...otherProps
500
+ }));
501
+ };
502
+
503
+
504
+
505
+
506
+
507
+
508
+ const $80d81cb0da14b65a$export$2698fa8b3a0a79e6 = ()=>/*#__PURE__*/ $6ZrLO$emotion.css({
509
+ textAlign: 'left',
510
+ padding: `${($parcel$interopDefault($6ZrLO$contentfulf36tokens)).spacingXs} ${($parcel$interopDefault($6ZrLO$contentfulf36tokens)).spacingM}`,
511
+ lineHeight: ($parcel$interopDefault($6ZrLO$contentfulf36tokens)).lineHeightM,
512
+ 'hr + &': {
513
+ marginTop: '-8px'
514
+ }
515
+ })
516
+ ;
517
+
518
+
519
+
520
+ const $a9e47e1a6fcc6dbc$export$5d1e6c648985631e = (props)=>{
521
+ const { children: children , testId: testId = 'cf-ui-menu-section-title' , className: className , ...otherProps } = props;
522
+ const styles = $80d81cb0da14b65a$export$2698fa8b3a0a79e6();
523
+ return(/*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).createElement($6ZrLO$contentfulf36typography.SectionHeading // Techincally, menus cannot contain headings according to ARIA.
524
+ , {
525
+ // We hide the heading from assistive technology, and only use it
526
+ // as a label
527
+ "aria-hidden": "true",
528
+ testId: testId,
529
+ className: $6ZrLO$emotion.cx(styles, className),
530
+ marginBottom: "none",
531
+ ...otherProps
532
+ }, children));
533
+ };
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+ const $d1c454a08dd2b04a$var$SUBMENU_OFFSET = [
542
+ -8,
543
+ 2
544
+ ];
545
+ const $d1c454a08dd2b04a$export$49229ebf838c159b = (props)=>{
546
+ const { onClose: onClose , onOpen: onOpen , ...otherProps } = props;
547
+ const { isOpen: isParentMenuOpen , menuId: menuId , propsToPropagateToSubmenus: propsToPropagateToSubmenus } = $31bc1b2a74a830dc$export$21c7ab35b39f78ec();
548
+ const triggerRef = $6ZrLO$react.useRef(null);
549
+ const mouseLeaveTimerRef = $6ZrLO$react.useRef(null);
550
+ const [isOpen, setIsOpen] = $6ZrLO$react.useState(false);
551
+ const handleOpen = $6ZrLO$react.useCallback(()=>{
552
+ setIsOpen(true);
553
+ window.clearTimeout(mouseLeaveTimerRef.current);
554
+ onOpen === null || onOpen === void 0 ? void 0 : onOpen();
555
+ }, [
556
+ onOpen
557
+ ]);
558
+ const handleClose = $6ZrLO$react.useCallback(()=>{
559
+ setIsOpen(false);
560
+ window.clearTimeout(mouseLeaveTimerRef.current);
561
+ onClose === null || onClose === void 0 ? void 0 : onClose();
562
+ }, [
563
+ onClose
564
+ ]);
565
+ const closeAndFocusTrigger = $6ZrLO$react.useCallback(()=>{
566
+ var ref;
567
+ handleClose();
568
+ (ref = triggerRef.current) === null || ref === void 0 ? void 0 : ref.focus({
569
+ preventScroll: true
570
+ });
571
+ }, [
572
+ handleClose
573
+ ]);
574
+ $6ZrLO$react.useEffect(()=>{
575
+ // close when parent menu closed
576
+ if (isParentMenuOpen === false) setIsOpen(false);
577
+ }, [
578
+ isParentMenuOpen
579
+ ]);
580
+ const contextValue = $6ZrLO$react.useMemo(()=>{
581
+ return {
582
+ isOpen: isOpen,
583
+ getSubmenuListProps: (_props)=>{
584
+ return {
585
+ 'data-parent-menu': menuId,
586
+ onMouseOver: (event)=>{
587
+ var ref;
588
+ handleOpen();
589
+ (ref = _props.onMouseOver) === null || ref === void 0 ? void 0 : ref.call(_props, event);
590
+ },
591
+ onMouseLeave: (event)=>{
592
+ var ref;
593
+ closeAndFocusTrigger();
594
+ (ref = _props.onMouseLeave) === null || ref === void 0 ? void 0 : ref.call(_props, event);
595
+ }
596
+ };
597
+ },
598
+ getSubmenuTriggerProps: (_props, _ref)=>{
599
+ return {
600
+ ref: $6ZrLO$contentfulf36core.mergeRefs(triggerRef, _ref),
601
+ onKeyDown: (event)=>{
602
+ var ref;
603
+ if (event.key === 'ArrowRight') {
604
+ event.preventDefault();
605
+ handleOpen();
606
+ }
607
+ (ref = _props.onKeyDown) === null || ref === void 0 ? void 0 : ref.call(_props, event);
608
+ },
609
+ onMouseOver: (event)=>{
610
+ var ref;
611
+ handleOpen();
612
+ (ref = _props.onMouseOver) === null || ref === void 0 ? void 0 : ref.call(_props, event);
613
+ },
614
+ onMouseLeave: (event)=>{
615
+ var ref;
616
+ mouseLeaveTimerRef.current = window.setTimeout(closeAndFocusTrigger, 300);
617
+ (ref = _props.onMouseLeave) === null || ref === void 0 ? void 0 : ref.call(_props, event);
618
+ }
619
+ };
620
+ }
621
+ };
622
+ }, [
623
+ isOpen,
624
+ menuId,
625
+ handleOpen,
626
+ closeAndFocusTrigger
627
+ ]);
628
+ return(/*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).createElement($62b35dc82bb7def8$export$81b3dbd1f003f0c7, {
629
+ value: contextValue
630
+ }, /*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).createElement($453ff7c40e833219$export$d9b273488cd8ce6f, {
631
+ ...propsToPropagateToSubmenus,
632
+ ...otherProps,
633
+ isOpen: isOpen,
634
+ onClose: handleClose,
635
+ onOpen: handleOpen,
636
+ placement: "right-start",
637
+ offset: $d1c454a08dd2b04a$var$SUBMENU_OFFSET,
638
+ isAutoalignmentEnabled: false
639
+ })));
640
+ };
641
+
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+
650
+
651
+ const $440a5860c5fbe4e7$export$ce276565acbba1c9 = ()=>{
652
+ return {
653
+ root: ({ isActive: isActive })=>/*#__PURE__*/ $6ZrLO$emotion.css({
654
+ display: 'flex',
655
+ alignItems: 'center',
656
+ paddingRight: ($parcel$interopDefault($6ZrLO$contentfulf36tokens)).spacingXs,
657
+ ...isActive ? {
658
+ backgroundColor: ($parcel$interopDefault($6ZrLO$contentfulf36tokens)).gray100
659
+ } : {
660
+ }
661
+ })
662
+ ,
663
+ content: /*#__PURE__*/ $6ZrLO$emotion.css({
664
+ marginRight: ($parcel$interopDefault($6ZrLO$contentfulf36tokens)).spacingM
665
+ }),
666
+ icon: /*#__PURE__*/ $6ZrLO$emotion.css({
667
+ name: "1hapt0s",
668
+ styles: "margin-left:auto;fill:currentColor;"
669
+ })
670
+ };
671
+ };
672
+
673
+
674
+ const $68e427819b978177$var$_SubmenuTrigger = (props, ref)=>{
675
+ const { className: className , children: children } = props;
676
+ const { getSubmenuTriggerProps: getSubmenuTriggerProps , isOpen: isOpen } = $62b35dc82bb7def8$export$958673a266cbe049();
677
+ const styles = $440a5860c5fbe4e7$export$ce276565acbba1c9();
678
+ return(/*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).createElement($57a0b88402c05a1e$export$27d2ad3c5815583e, null, /*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).createElement($01d29448a29c05b3$export$2ce376c2cc3355c8, {
679
+ ...props,
680
+ ...getSubmenuTriggerProps(props, ref),
681
+ className: $6ZrLO$emotion.cx(styles.root({
682
+ isActive: isOpen
683
+ }), className)
684
+ }, /*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).createElement("span", {
685
+ className: styles.content
686
+ }, children), /*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).createElement($6ZrLO$contentfulf36icons.ChevronRightIcon, {
687
+ className: styles.icon
688
+ }))));
689
+ };
690
+ const $68e427819b978177$export$ecabc99eeffab7ca = /*#__PURE__*/ ($parcel$interopDefault($6ZrLO$react)).forwardRef($68e427819b978177$var$_SubmenuTrigger);
691
+
692
+
693
+ const $c2cdaffe72abf66f$export$d9b273488cd8ce6f = $453ff7c40e833219$export$d9b273488cd8ce6f;
694
+ $c2cdaffe72abf66f$export$d9b273488cd8ce6f.List = $c5bfee6901fd5b47$export$d4c4e98c5044dc8;
695
+ $c2cdaffe72abf66f$export$d9b273488cd8ce6f.ListHeader = $77fa76994469c42b$export$77451990ddb9d17c;
696
+ $c2cdaffe72abf66f$export$d9b273488cd8ce6f.ListFooter = $56409107038e75ac$export$3e8a81e7ad0650f4;
697
+ $c2cdaffe72abf66f$export$d9b273488cd8ce6f.Item = $01d29448a29c05b3$export$2ce376c2cc3355c8;
698
+ $c2cdaffe72abf66f$export$d9b273488cd8ce6f.Trigger = $57a0b88402c05a1e$export$27d2ad3c5815583e;
699
+ $c2cdaffe72abf66f$export$d9b273488cd8ce6f.Divider = $a8d7f8a94ad9b120$export$acb07b4664ac227c;
700
+ $c2cdaffe72abf66f$export$d9b273488cd8ce6f.SectionTitle = $a9e47e1a6fcc6dbc$export$5d1e6c648985631e;
701
+ $c2cdaffe72abf66f$export$d9b273488cd8ce6f.Submenu = $d1c454a08dd2b04a$export$49229ebf838c159b;
702
+ $c2cdaffe72abf66f$export$d9b273488cd8ce6f.SubmenuTrigger = $68e427819b978177$export$ecabc99eeffab7ca;
703
+
704
+
705
+
706
+
707
+
708
+
709
+
710
+
711
+
712
+
713
+
714
+ //# sourceMappingURL=main.js.map