@equinor/cpl-top-bar-react 0.5.7 → 0.6.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/index.js +28 -2
- package/dist/index.mjs +29 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -311,7 +311,7 @@ function MenuList({
|
|
|
311
311
|
}) {
|
|
312
312
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { children: items.map((menuItem) => {
|
|
313
313
|
if (isMenuItemGroup(menuItem)) {
|
|
314
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react4.Accordion, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(AccordionItem, { isExpanded: menuItem.isExpanded, children: [
|
|
314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { "data-active-catalogue": String(menuItem.isExpanded), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react4.Accordion, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(AccordionItem, { isExpanded: menuItem.isExpanded, children: [
|
|
315
315
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react4.Accordion.Header, { onToggle: onToggleMenuGroup, children: menuItem.title }),
|
|
316
316
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_eds_core_react4.Accordion.Panel, { "aria-label": `Links for ${menuItem.title}`, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { children: menuItem.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
317
317
|
MenuLink,
|
|
@@ -405,6 +405,32 @@ function SideMenu({
|
|
|
405
405
|
const [hasOverflow, setHasOverflow] = (0, import_react.useState)(false);
|
|
406
406
|
const [scrolledDown, setScrolledDown] = (0, import_react.useState)(false);
|
|
407
407
|
const containerRef = (0, import_react.useRef)(null);
|
|
408
|
+
const mainMenuItemsWithActiveCatalogue = (0, import_react.useMemo)(() => {
|
|
409
|
+
const pathname = typeof window !== "undefined" ? window.location.pathname : void 0;
|
|
410
|
+
if (!pathname) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
return mainMenuItems.map((menuItem) => {
|
|
414
|
+
if ("items" in menuItem) {
|
|
415
|
+
return __spreadProps(__spreadValues({}, menuItem), {
|
|
416
|
+
isExpanded: menuItem.items.some((item) => pathname === item.url)
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
return menuItem;
|
|
420
|
+
});
|
|
421
|
+
}, [mainMenuItems]);
|
|
422
|
+
(0, import_react.useEffect)(() => {
|
|
423
|
+
const container = containerRef.current;
|
|
424
|
+
if (!container) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
const activeCatalogueElement = container.querySelector(
|
|
428
|
+
'[data-active-catalogue="true"]'
|
|
429
|
+
);
|
|
430
|
+
if (activeCatalogueElement) {
|
|
431
|
+
activeCatalogueElement.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
432
|
+
}
|
|
433
|
+
}, []);
|
|
408
434
|
const checkOverflow = (0, import_react.useCallback)(() => {
|
|
409
435
|
requestAnimationFrame(() => {
|
|
410
436
|
const element = containerRef.current;
|
|
@@ -449,7 +475,7 @@ function SideMenu({
|
|
|
449
475
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
450
476
|
MenuList,
|
|
451
477
|
{
|
|
452
|
-
items:
|
|
478
|
+
items: mainMenuItemsWithActiveCatalogue != null ? mainMenuItemsWithActiveCatalogue : [],
|
|
453
479
|
currentEnvironment,
|
|
454
480
|
appUrls,
|
|
455
481
|
onToggleMenuGroup: checkOverflow,
|
package/dist/index.mjs
CHANGED
|
@@ -173,7 +173,7 @@ var LogoStyle = styled2.div`
|
|
|
173
173
|
import { Button as Button2, Divider, Icon as Icon4, Typography as Typography2 } from "@equinor/eds-core-react";
|
|
174
174
|
import { collapse } from "@equinor/eds-icons";
|
|
175
175
|
import { tokens as tokens5 } from "@equinor/eds-tokens";
|
|
176
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
176
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
177
177
|
import styled5 from "styled-components";
|
|
178
178
|
|
|
179
179
|
// src/SideMenu/components/MenuList.tsx
|
|
@@ -277,7 +277,7 @@ function MenuList({
|
|
|
277
277
|
}) {
|
|
278
278
|
return /* @__PURE__ */ jsx5("ul", { children: items.map((menuItem) => {
|
|
279
279
|
if (isMenuItemGroup(menuItem)) {
|
|
280
|
-
return /* @__PURE__ */ jsx5("li", { children: /* @__PURE__ */ jsx5(Accordion, { children: /* @__PURE__ */ jsxs5(AccordionItem, { isExpanded: menuItem.isExpanded, children: [
|
|
280
|
+
return /* @__PURE__ */ jsx5("li", { "data-active-catalogue": String(menuItem.isExpanded), children: /* @__PURE__ */ jsx5(Accordion, { children: /* @__PURE__ */ jsxs5(AccordionItem, { isExpanded: menuItem.isExpanded, children: [
|
|
281
281
|
/* @__PURE__ */ jsx5(Accordion.Header, { onToggle: onToggleMenuGroup, children: menuItem.title }),
|
|
282
282
|
/* @__PURE__ */ jsx5(Accordion.Panel, { "aria-label": `Links for ${menuItem.title}`, children: /* @__PURE__ */ jsx5("ul", { children: menuItem.items.map((item) => /* @__PURE__ */ jsx5("li", { children: /* @__PURE__ */ jsx5(
|
|
283
283
|
MenuLink,
|
|
@@ -371,6 +371,32 @@ function SideMenu({
|
|
|
371
371
|
const [hasOverflow, setHasOverflow] = useState(false);
|
|
372
372
|
const [scrolledDown, setScrolledDown] = useState(false);
|
|
373
373
|
const containerRef = useRef(null);
|
|
374
|
+
const mainMenuItemsWithActiveCatalogue = useMemo(() => {
|
|
375
|
+
const pathname = typeof window !== "undefined" ? window.location.pathname : void 0;
|
|
376
|
+
if (!pathname) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
return mainMenuItems.map((menuItem) => {
|
|
380
|
+
if ("items" in menuItem) {
|
|
381
|
+
return __spreadProps(__spreadValues({}, menuItem), {
|
|
382
|
+
isExpanded: menuItem.items.some((item) => pathname === item.url)
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
return menuItem;
|
|
386
|
+
});
|
|
387
|
+
}, [mainMenuItems]);
|
|
388
|
+
useEffect(() => {
|
|
389
|
+
const container = containerRef.current;
|
|
390
|
+
if (!container) {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
const activeCatalogueElement = container.querySelector(
|
|
394
|
+
'[data-active-catalogue="true"]'
|
|
395
|
+
);
|
|
396
|
+
if (activeCatalogueElement) {
|
|
397
|
+
activeCatalogueElement.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
398
|
+
}
|
|
399
|
+
}, []);
|
|
374
400
|
const checkOverflow = useCallback(() => {
|
|
375
401
|
requestAnimationFrame(() => {
|
|
376
402
|
const element = containerRef.current;
|
|
@@ -415,7 +441,7 @@ function SideMenu({
|
|
|
415
441
|
/* @__PURE__ */ jsx6(
|
|
416
442
|
MenuList,
|
|
417
443
|
{
|
|
418
|
-
items:
|
|
444
|
+
items: mainMenuItemsWithActiveCatalogue != null ? mainMenuItemsWithActiveCatalogue : [],
|
|
419
445
|
currentEnvironment,
|
|
420
446
|
appUrls,
|
|
421
447
|
onToggleMenuGroup: checkOverflow,
|