@hitachivantara/app-shell-shared 1.2.2 → 1.3.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.
@@ -1,24 +1,24 @@
1
- import { createContext as C, useContext as M, useMemo as v, useState as H, useEffect as _ } from "react";
2
- import { useLocation as E } from "react-router-dom";
3
- const F = C(void 0), U = C(void 0), x = C(void 0), P = "configTranslations", w = P, z = () => M(F), R = z, N = (n) => {
1
+ import { createContext as I, useContext as v, useMemo as S, useState as H, useEffect as O } from "react";
2
+ import { useLocation as _ } from "react-router-dom";
3
+ const x = I(void 0), Y = I(void 0), E = I(void 0), F = I(void 0), b = "configTranslations", w = b, z = () => v(x), R = z, M = (n) => {
4
4
  const {
5
5
  target: t
6
6
  } = n;
7
- return t || (n.submenus ? N(n.submenus[0]) : "");
8
- }, p = (n) => n.startsWith(".") ? n : `.${n}`, m = (n, t, e, s) => e !== void 0 && e <= 0 ? [] : (t == null ? void 0 : t.reduce((o, i, r) => {
7
+ return t || (n.submenus ? M(n.submenus[0]) : "");
8
+ }, C = (n) => n.startsWith(".") ? n : `.${n}`, N = (n, t, e, s) => e !== void 0 && e <= 0 ? [] : (t == null ? void 0 : t.reduce((o, i, r) => {
9
9
  const d = {
10
10
  id: s ? `${s.id}-${r}` : `${r}`,
11
11
  label: n(i.label),
12
- href: p(N(i)),
12
+ href: C(M(i)),
13
13
  icon: i.icon,
14
14
  parent: s
15
15
  };
16
16
  if (i.submenus) {
17
- const u = e !== void 0 ? e - 1 : void 0, c = m(n, i.submenus, u, d);
17
+ const u = e !== void 0 ? e - 1 : void 0, c = N(n, i.submenus, u, d);
18
18
  c.length > 0 && (d.data = c);
19
19
  }
20
20
  return o.push(d), o;
21
- }, [])) ?? [], T = (n) => n.reduce((t, e) => (e.data ? t.push(...T(e.data)) : t.push(e), t), []), b = (n) => {
21
+ }, [])) ?? [], T = (n) => n.reduce((t, e) => (e.data ? t.push(...T(e.data)) : t.push(e), t), []), y = (n) => {
22
22
  const t = n.split("/").reduce((e, s) => {
23
23
  if (s === "")
24
24
  return e;
@@ -26,23 +26,23 @@ const F = C(void 0), U = C(void 0), x = C(void 0), P = "configTranslations", w =
26
26
  return e.unshift(i), e;
27
27
  }, []);
28
28
  return t.push("./"), t;
29
- }, y = (n, t, e) => {
29
+ }, G = (n, t, e) => {
30
30
  let s, o;
31
- const i = b(t);
31
+ const i = y(t);
32
32
  return T(n).some((r) => {
33
33
  var h, f, a, A;
34
34
  let d, u;
35
35
  const c = (h = r.href) == null ? void 0 : h.indexOf("?");
36
36
  if (c !== -1 ? (d = (f = r.href) == null ? void 0 : f.slice(0, c).toLowerCase(), u = (a = r.href) == null ? void 0 : a.slice(c, r.href.length).toLowerCase()) : (d = (A = r.href) == null ? void 0 : A.toLowerCase(), u = ""), d && d.length > 1 && d.endsWith("/") && (d = d.slice(0, d.length - 1)), `${d}${u}` === e)
37
37
  return s = r.id, !0;
38
- const l = i.find((O) => d === O);
38
+ const l = i.find(($) => d === $);
39
39
  return l && (!o || l.length > (o == null ? void 0 : o.length)) && (s = r.id, o = l), !1;
40
40
  }), s;
41
- }, S = (n, t, e) => {
41
+ }, m = (n, t, e) => {
42
42
  if (!t)
43
43
  return;
44
44
  const s = t.length > 1 && t.endsWith("/") ? t.slice(0, t.length - 1).toLowerCase() : t.toLowerCase(), o = e ? s.concat(e.toLowerCase()) : s;
45
- return y(n, s, o);
45
+ return G(n, s, o);
46
46
  }, g = (n) => {
47
47
  if (n)
48
48
  return n.split("-")[0];
@@ -55,53 +55,55 @@ const F = C(void 0), U = C(void 0), x = C(void 0), P = "configTranslations", w =
55
55
  } = s;
56
56
  return o === t ? (e = s, !0) : i && i.length > 0 ? (e = L(i, t), e !== null) : !1;
57
57
  }), e;
58
- }, $ = (n) => {
58
+ }, P = (n) => {
59
59
  let t = null;
60
- return n.some((e) => !e.data || e.data.length === 0 ? (t = e, !0) : (t = $(e.data), t !== null)), t;
61
- }, G = 2, W = () => {
60
+ return n.some((e) => !e.data || e.data.length === 0 ? (t = e, !0) : (t = P(e.data), t !== null)), t;
61
+ }, W = 2, B = () => {
62
62
  const {
63
63
  pathname: n,
64
64
  search: t,
65
65
  state: e
66
- } = E(), s = R(), {
66
+ } = _(), s = R(), {
67
67
  i18n: o
68
- } = M(x) ?? {}, i = v(() => (o == null ? void 0 : o.getFixedT(o.language, w)) ?? // should not happen, but fallback if the i18n instance is not available
69
- ((l) => l), [o]), r = v(() => {
70
- const l = s.navigationMode === "ONLY_TOP" ? G : void 0;
71
- return m(i, s.menu, l);
72
- }, [s, i]), [d, u] = H(S(r, p(n), t)), [c, I] = H(g(d));
73
- return _(() => {
68
+ } = v(E) ?? {}, i = S(() => (o == null ? void 0 : o.getFixedT(o.language, w)) ?? // should not happen, but fallback if the i18n instance is not available
69
+ ((l) => l), [o]), r = S(() => {
70
+ const l = s.navigationMode === "ONLY_TOP" ? W : void 0;
71
+ return N(i, s.menu, l);
72
+ }, [s, i]), [d, u] = H(m(r, C(n), t)), [c, p] = H(g(d));
73
+ return O(() => {
74
74
  var h;
75
75
  if (!r.length)
76
76
  return;
77
77
  if (e != null && e.selectedItemId) {
78
- I(g(e.selectedItemId));
78
+ p(g(e.selectedItemId));
79
79
  const f = L(r, e.selectedItemId);
80
80
  if ((h = f == null ? void 0 : f.data) != null && h.length) {
81
- const a = $(f.data);
81
+ const a = P(f.data);
82
82
  u(a == null ? void 0 : a.id);
83
83
  } else
84
84
  u(f == null ? void 0 : f.id);
85
85
  return;
86
86
  }
87
- const l = S(r, p(n), t);
87
+ const l = m(r, C(n), t);
88
88
  if (l) {
89
- I(g(l)), u(l);
89
+ p(g(l)), u(l);
90
90
  return;
91
91
  }
92
- I(void 0), u(void 0);
92
+ p(void 0), u(void 0);
93
93
  }, [r, e, n, t]), {
94
94
  items: r,
95
95
  selectedMenuItemId: d,
96
96
  rootMenuItemId: c
97
97
  };
98
- }, X = W;
98
+ }, k = B, D = () => v(F), q = D;
99
99
  export {
100
100
  w as CONFIG_TRANSLATIONS_NAMESPACE,
101
- F as HvAppShellContext,
102
- x as HvAppShellRuntimeContext,
103
- U as HvAppShellViewContext,
101
+ F as HvAppShellCombinedProvidersContext,
102
+ x as HvAppShellContext,
103
+ E as HvAppShellRuntimeContext,
104
+ Y as HvAppShellViewContext,
105
+ q as useHvAppShellCombinedProviders,
104
106
  R as useHvAppShellConfig,
105
- X as useHvMenuItems
107
+ k as useHvMenuItems
106
108
  };
107
109
  //# sourceMappingURL=app-shell-shared.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-shell-shared.esm.js","sources":["../../src/AppShellContext.tsx","../../src/AppShellViewContext.tsx","../../src/AppShellRuntimeContext.tsx","../../src/i18n/index.ts","../../src/hooks/useAppShellConfig.tsx","../../src/utils/navigationUtils.tsx","../../src/hooks/useMenuItems.tsx"],"sourcesContent":["import { createContext } from \"react\";\n\nimport { HvAppShellConfig } from \"./types\";\n\nexport type HvAppShellContextValue = HvAppShellConfig;\nexport const HvAppShellContext = createContext<\n HvAppShellContextValue | undefined\n>(undefined);\n","import { createContext } from \"react\";\n\nexport interface HvAppShellViewContextValue {\n id: string;\n}\n\nexport const HvAppShellViewContext = createContext<\n HvAppShellViewContextValue | undefined\n>(undefined);\n","import { createContext } from \"react\";\n\nimport type { i18n } from \"i18next\";\n\nexport interface HvAppShellRuntimeContextValue {\n i18n: i18n;\n}\n\nexport const HvAppShellRuntimeContext = createContext<\n HvAppShellRuntimeContextValue | undefined\n>(undefined);\n","const CONFIG_TRANSLATIONS_NAMESPACE = \"configTranslations\";\nexport default CONFIG_TRANSLATIONS_NAMESPACE;\n","import { useContext } from \"react\";\n\nimport { HvAppShellContext, HvAppShellContextValue } from \"../AppShellContext\";\n\nconst useAppShellConfig = (): HvAppShellContextValue => {\n return useContext(HvAppShellContext) as HvAppShellContextValue;\n};\n\nexport default useAppShellConfig;\n","import { HvAppShellMenuConfig, MenuItem } from \"../types\";\n\n/**\n * Compute the target href for menu item.\n *\n * @param menuItem The root target href.\n *\n * @returns The menu item target href. If empty, returns the first child that has it defined or empty string if none.\n */\nconst getMenuTargetHref = (menuItem: HvAppShellMenuConfig): string => {\n const { target } = menuItem;\n if (target) {\n return target;\n }\n\n if (menuItem.submenus) {\n return getMenuTargetHref(menuItem.submenus[0]);\n }\n\n return \"\";\n};\n\n/**\n * Adds a dot to the href to indicate that it is a relative path.\n */\nconst addPrefixToHref = (href: string): string => {\n return !href.startsWith(\".\") ? `.${href}` : href;\n};\n\n/**\n * Creates a navigation data structure ({@link MenuItem}) from the provided menu configuration ({@link HvAppShellMenuConfig}).\n *\n * @param t\n * @param menuItems The set of menu items from configuration.\n * @param maxDepth The maximum depth up until the recursiveness should occur for the creation of the menu items.\n * @param parentMenuItem The parent menu item of the set of menu items.\n *\n * @returns An array of {@link MenuItem}.\n */\nconst createMenuItems = (\n t: (key: string) => string,\n menuItems?: HvAppShellMenuConfig[],\n maxDepth?: number,\n parentMenuItem?: MenuItem\n): MenuItem[] => {\n if (maxDepth !== undefined && maxDepth <= 0) {\n return [];\n }\n\n return (\n menuItems?.reduce<MenuItem[]>((accumulator, currentValue, index) => {\n const navItem: MenuItem = {\n id: parentMenuItem ? `${parentMenuItem.id}-${index}` : `${index}`,\n label: t(currentValue.label),\n href: addPrefixToHref(getMenuTargetHref(currentValue)),\n icon: currentValue.icon,\n parent: parentMenuItem\n };\n\n if (currentValue.submenus) {\n const updatedDepth = maxDepth !== undefined ? maxDepth - 1 : undefined;\n const data = createMenuItems(\n t,\n currentValue.submenus,\n updatedDepth,\n navItem\n );\n if (data.length > 0) {\n navItem.data = data;\n }\n }\n\n accumulator.push(navItem);\n return accumulator;\n }, []) ?? []\n );\n};\n\n/**\n * Removes the items that do not have path and replaces it by its children, recursively.\n *\n * @param items The list of {@link MenuItem}.\n *\n * @returns A flat array of {@link MenuItem}.\n */\nconst flatMenuItems = (items: MenuItem[]) => {\n return items.reduce<MenuItem[]>((acc, item) => {\n if (item.data) {\n acc.push(...flatMenuItems(item.data));\n } else {\n acc.push(item);\n }\n\n return acc;\n }, []);\n};\n\n/**\n * Helper function that uses a cumulative reduction to derive an array of cumulative hrefs based on the components\n * of the input string.\n * @example\n * // returns ['/', '/app', '/app/details', '/app/details/1']\n * // normalizedHref: \"/app/details/1\"\n *\n * @param normalizedHref The href string to be reduced.\n *\n * @returns the array of cumulative hrefs.\n */\nconst decomposeHrefStringToArray = (normalizedHref: string): string[] => {\n const hrefArray = normalizedHref\n .split(\"/\")\n .reduce<string[]>((accumulator, currentValue) => {\n if (currentValue === \"\") {\n return accumulator;\n }\n\n const prefix = accumulator.length === 0 ? \"\" : accumulator[0];\n const href =\n currentValue === \".\" ? currentValue : `${prefix}/${currentValue}`;\n accumulator.unshift(href);\n return accumulator;\n }, []);\n\n hrefArray.push(\"./\");\n\n return hrefArray;\n};\n\n/**\n * Algorithm implementation of the searchHrefInMenuItems function.\n *\n * @returns An object containing an item id or empty, if no match is found, and a flag to indicate if a\n * full href match was found. If the id is filled but the flag is 'false', then only partial match was found.\n */\nconst searchHrefMatch = (\n items: MenuItem[],\n normalizedHref: string,\n normalizedFullHref: string\n): string | undefined => {\n let toBeSelectedId: string | undefined;\n let toBeSelectedHref: string | undefined;\n\n const reducedNormalizedHref = decomposeHrefStringToArray(normalizedHref);\n\n flatMenuItems(items).some(item => {\n let normalizedItemHref: string | undefined;\n let normalizedItemHrefParams: string | undefined;\n\n const idx = item.href?.indexOf(\"?\");\n if (idx !== -1) {\n normalizedItemHref = item.href?.slice(0, idx).toLowerCase();\n normalizedItemHrefParams = item.href\n ?.slice(idx, item.href.length)\n .toLowerCase();\n } else {\n normalizedItemHref = item.href?.toLowerCase();\n normalizedItemHrefParams = \"\";\n }\n\n if (\n normalizedItemHref &&\n normalizedItemHref.length > 1 &&\n normalizedItemHref.endsWith(\"/\")\n ) {\n normalizedItemHref = normalizedItemHref.slice(\n 0,\n normalizedItemHref.length - 1\n );\n }\n\n const normalizedFullItemHref = `${normalizedItemHref}${normalizedItemHrefParams}`;\n\n // if the normalized full href is met, then search is complete\n if (normalizedFullItemHref === normalizedFullHref) {\n toBeSelectedId = item.id;\n return true;\n }\n\n // since it is not a full href match, we want to keep searching for a full href match,\n // while storing only the first/longer partial match found\n const matchedHref = reducedNormalizedHref.find(\n (href: string) => normalizedItemHref === href\n );\n if (\n matchedHref &&\n (!toBeSelectedHref || matchedHref.length > toBeSelectedHref?.length)\n ) {\n toBeSelectedId = item.id;\n toBeSelectedHref = matchedHref;\n }\n\n return false;\n });\n\n return toBeSelectedId;\n};\n\n/**\n * Searches for the href and parameters on all the menu items and its children until an exact match is found. If no\n * exact match is found but partial is, then the parent id for the first partial match found is returned.\n * @example\n * // returns '2'\n * // href: '/home', parameters: '?x=y', items: [{id:'1', href:'/home?z=v'},{id:'2', href:'/home'}\n *\n * For consistency purposes and based on the Router behavior, if either the href or the item href\n * (stripped of its query params) ends with a forward slash, then the comparison will ignore it\n * @example\n * // returns '1'\n * // href: '/home/', parameters: <empty>, items: [{id:'1', href:'/home'}]\n *\n * @param items The list of menu items to be searched.\n * @param href The url href after the domain up to the query parameters.\n * @param [parameters] The url query string after pathname.\n *\n * @returns The id of a parent menu item or an empty string.\n */\nconst searchHrefInMenuItems = (\n items: MenuItem[],\n href: string,\n parameters?: string\n): string | undefined => {\n if (!href) {\n return undefined;\n }\n\n const normalizedHref =\n href.length > 1 && href.endsWith(\"/\")\n ? href.slice(0, href.length - 1).toLowerCase()\n : href.toLowerCase();\n\n const normalizedFullHref = parameters\n ? normalizedHref.concat(parameters.toLowerCase())\n : normalizedHref;\n\n return searchHrefMatch(items, normalizedHref, normalizedFullHref);\n};\n\n/**\n * Get root menu id from the path (in the format 0-0-0 - id's separated by `-`)\n * @param menuItemId\n * @returns the Id of the first menu or undefined if the provided value is undefined\n */\nconst getRootIdFromItemId = (\n menuItemId: string | undefined\n): string | undefined => {\n if (!menuItemId) {\n return undefined;\n }\n return menuItemId.split(\"-\")[0];\n};\n\n/**\n * Searches for an item with the specified id.\n *\n * @param {MenuItem[]} data - The navigation data structure.\n * @param {string} itemId - The item id.\n * @returns The item with matching id.\n */\nconst findItemById = (data: MenuItem[], itemId: string): MenuItem | null => {\n let foundItem: MenuItem | null = null;\n data.some(obj => {\n const { id: objId, data: childData } = obj;\n if (objId === itemId) {\n foundItem = obj;\n return true;\n }\n if (childData && childData.length > 0) {\n foundItem = findItemById(childData, itemId);\n return foundItem !== null;\n }\n return false;\n });\n return foundItem;\n};\n\n/**\n * Finds the first leaf item (item with children) inside the received structure.\n *\n * @param {MenuItem[]} data - The navigation data structure.\n * @returns - The first leaf item inside the structure.\n */\nconst findFirstLeafItem = (data: MenuItem[]): MenuItem | null => {\n let foundItem: MenuItem | null = null;\n data.some(obj => {\n if (!obj.data || obj.data.length === 0) {\n foundItem = obj;\n return true;\n }\n foundItem = findFirstLeafItem(obj.data);\n return foundItem !== null;\n });\n return foundItem;\n};\n\nexport {\n createMenuItems,\n searchHrefInMenuItems,\n getRootIdFromItemId,\n addPrefixToHref,\n findItemById,\n findFirstLeafItem\n};\n","import { useContext, useEffect, useMemo, useState } from \"react\";\nimport { useLocation } from \"react-router-dom\";\n\nimport { MenuItemsContext } from \"../types\";\nimport {\n addPrefixToHref,\n createMenuItems,\n findFirstLeafItem,\n findItemById,\n getRootIdFromItemId,\n searchHrefInMenuItems\n} from \"../utils/navigationUtils\";\n\nimport CONFIG_TRANSLATIONS_NAMESPACE from \"../i18n\";\nimport useAppShellConfig from \"./useAppShellConfig\";\nimport { HvAppShellRuntimeContext } from \"../AppShellRuntimeContext\";\n\nconst MAX_TOP_MENU_DEPTH = 2;\n\nconst useMenuItems = (): MenuItemsContext => {\n const { pathname, search, state: locationState } = useLocation();\n const appShellContext = useAppShellConfig();\n\n // use the i18n instance from the app shell runtime context to ensure we're using\n // the app shell instance of i18n and not the one from the embedded app\n const { i18n } = useContext(HvAppShellRuntimeContext) ?? {};\n const tConfig = useMemo(\n () =>\n i18n?.getFixedT(i18n.language, CONFIG_TRANSLATIONS_NAMESPACE) ??\n // should not happen, but fallback if the i18n instance is not available\n ((l: string) => l),\n [i18n]\n );\n\n const items = useMemo(() => {\n const menuItemsDepth =\n appShellContext.navigationMode === \"ONLY_TOP\"\n ? MAX_TOP_MENU_DEPTH\n : undefined;\n\n return createMenuItems(tConfig, appShellContext.menu, menuItemsDepth);\n }, [appShellContext, tConfig]);\n\n const [selectedMenuItemId, setSelectedMenuItemId] = useState<\n string | undefined\n >(searchHrefInMenuItems(items, addPrefixToHref(pathname), search));\n\n const [rootMenuItemId, setRootMenuItemId] = useState<string | undefined>(\n getRootIdFromItemId(selectedMenuItemId)\n );\n\n useEffect(() => {\n // no menu items, nothing to select\n if (!items.length) {\n return;\n }\n // state property is used when we already know which menu is to be selected\n if (locationState?.selectedItemId) {\n setRootMenuItemId(getRootIdFromItemId(locationState.selectedItemId));\n // If the selected item has children we want to select the first child instead\n const selectedItem = findItemById(items, locationState.selectedItemId);\n if (selectedItem?.data?.length) {\n const firstItemToSelect = findFirstLeafItem(selectedItem.data);\n setSelectedMenuItemId(firstItemToSelect?.id);\n } else {\n setSelectedMenuItemId(selectedItem?.id);\n }\n return;\n }\n const toBeSelected = searchHrefInMenuItems(\n items,\n addPrefixToHref(pathname),\n search\n );\n if (toBeSelected) {\n setRootMenuItemId(getRootIdFromItemId(toBeSelected));\n setSelectedMenuItemId(toBeSelected);\n return;\n }\n // if none of the previous scenarios, then nothing is marked as selected\n setRootMenuItemId(undefined);\n setSelectedMenuItemId(undefined);\n }, [items, locationState, pathname, search]);\n return {\n items,\n selectedMenuItemId,\n rootMenuItemId\n };\n};\nexport default useMenuItems;\n"],"names":["HvAppShellContext","createContext","undefined","HvAppShellViewContext","HvAppShellRuntimeContext","CONFIG_TRANSLATIONS_NAMESPACE","CONFIG_TRANSLATIONS_NAMESPACE$1","useAppShellConfig","useContext","useAppShellConfig$1","getMenuTargetHref","menuItem","target","submenus","addPrefixToHref","href","startsWith","createMenuItems","t","menuItems","maxDepth","parentMenuItem","reduce","accumulator","currentValue","index","navItem","id","label","icon","parent","updatedDepth","data","length","push","flatMenuItems","items","acc","item","decomposeHrefStringToArray","normalizedHref","hrefArray","split","prefix","unshift","searchHrefMatch","normalizedFullHref","toBeSelectedId","toBeSelectedHref","reducedNormalizedHref","some","normalizedItemHref","normalizedItemHrefParams","idx","indexOf","slice","toLowerCase","endsWith","matchedHref","find","searchHrefInMenuItems","parameters","concat","getRootIdFromItemId","menuItemId","findItemById","itemId","foundItem","obj","objId","childData","findFirstLeafItem","MAX_TOP_MENU_DEPTH","useMenuItems","pathname","search","state","locationState","useLocation","appShellContext","i18n","tConfig","useMemo","getFixedT","language","l","menuItemsDepth","navigationMode","menu","selectedMenuItemId","setSelectedMenuItemId","useState","rootMenuItemId","setRootMenuItemId","useEffect","selectedItemId","selectedItem","firstItemToSelect","toBeSelected","useMenuItems$1"],"mappings":";;AAKaA,MAAAA,IAAoBC,EAE/BC,MAAS,GCDEC,IAAwBF,EAEnCC,MAAS,GCAEE,IAA2BH,EAEtCC,MAAS,GCVLG,IAAgC,sBACtCC,IAAeD,GCGTE,IAAoBA,MACjBC,EAAWR,CAAiB,GAGrCS,IAAeF,GCCTG,IAAoBA,CAACC,MAA2C;AAC9D,QAAA;AAAA,IAAEC,QAAAA;AAAAA,EAAWD,IAAAA;AACnB,SAAIC,MAIAD,EAASE,WACJH,EAAkBC,EAASE,SAAS,CAAC,CAAC,IAGxC;AACT,GAKMC,IAAkBA,CAACC,MACfA,EAAKC,WAAW,GAAG,IAAiBD,IAAZ,IAAGA,CAAK,IAapCE,IAAkBA,CACtBC,GACAC,GACAC,GACAC,MAEID,MAAalB,UAAakB,KAAY,IACjC,MAIPD,KAAAA,gBAAAA,EAAWG,OAAmB,CAACC,GAAaC,GAAcC,MAAU;AAClE,QAAMC,IAAoB;AAAA,IACxBC,IAAIN,IAAkB,GAAEA,EAAeM,EAAG,IAAGF,CAAM,KAAK,GAAEA,CAAM;AAAA,IAChEG,OAAOV,EAAEM,EAAaI,KAAK;AAAA,IAC3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B,cAAc,CAAC;AAEnE,YAAMC,IAAe/B,EAAa7B,GAAOyC,EAAckB,cAAc;AACjEC,WAAAA,IAAAA,KAAAA,gBAAAA,EAAchE,SAAdgE,QAAAA,EAAoB/D,QAAQ;AACxBgE,cAAAA,IAAoB1B,EAAkByB,EAAahE,IAAI;AAC7D0D,QAAAA,EAAsBO,KAAAA,gBAAAA,EAAmBtE,EAAE;AAAA,MAAA;AAE3C+D,QAAAA,EAAsBM,KAAAA,gBAAAA,EAAcrE,EAAE;AAExC;AAAA,IACF;AACA,UAAMuE,IAAetC,EACnBxB,GACAtB,EAAgB4D,CAAQ,GACxBC,CACF;AACA,QAAIuB,GAAc;AACEnC,MAAAA,EAAAA,EAAoBmC,CAAY,CAAC,GACnDR,EAAsBQ,CAAY;AAClC;AAAA,IACF;AAEAL,IAAAA,EAAkB3F,MAAS,GAC3BwF,EAAsBxF,MAAS;AAAA,KAC9B,CAACkC,GAAOyC,GAAeH,GAAUC,CAAM,CAAC,GACpC;AAAA,IACLvC,OAAAA;AAAAA,IACAqD,oBAAAA;AAAAA,IACAG,gBAAAA;AAAAA,EAAAA;AAEJ,GACAO,IAAe1B;"}
1
+ {"version":3,"file":"app-shell-shared.esm.js","sources":["../../src/AppShellContext.tsx","../../src/AppShellViewContext.tsx","../../src/AppShellRuntimeContext.tsx","../../src/AppShellCombinedProvidersContext.tsx","../../src/i18n/index.ts","../../src/hooks/useAppShellConfig.tsx","../../src/utils/navigationUtils.tsx","../../src/hooks/useMenuItems.tsx","../../src/hooks/useAppShellCombinedProviders.tsx"],"sourcesContent":["import { createContext } from \"react\";\n\nimport { HvAppShellConfig } from \"./types\";\n\nexport type HvAppShellContextValue = HvAppShellConfig;\nexport const HvAppShellContext = createContext<\n HvAppShellContextValue | undefined\n>(undefined);\n","import { createContext } from \"react\";\n\nexport interface HvAppShellViewContextValue {\n id: string;\n}\n\nexport const HvAppShellViewContext = createContext<\n HvAppShellViewContextValue | undefined\n>(undefined);\n","import { createContext } from \"react\";\n\nimport type { i18n } from \"i18next\";\n\nexport interface HvAppShellRuntimeContextValue {\n i18n: i18n;\n}\n\nexport const HvAppShellRuntimeContext = createContext<\n HvAppShellRuntimeContextValue | undefined\n>(undefined);\n","import { createContext } from \"react\";\n\nexport interface HvAppShellCombinedProvidersContextValue {\n providers?: React.ComponentType<{\n children: React.ReactNode;\n }>[];\n}\n\nexport const HvAppShellCombinedProvidersContext = createContext<\n HvAppShellCombinedProvidersContextValue | undefined\n>(undefined);\n","const CONFIG_TRANSLATIONS_NAMESPACE = \"configTranslations\";\nexport default CONFIG_TRANSLATIONS_NAMESPACE;\n","import { useContext } from \"react\";\n\nimport { HvAppShellContext, HvAppShellContextValue } from \"../AppShellContext\";\n\nconst useAppShellConfig = (): HvAppShellContextValue => {\n return useContext(HvAppShellContext) as HvAppShellContextValue;\n};\n\nexport default useAppShellConfig;\n","import { HvAppShellMenuConfig, MenuItem } from \"../types\";\n\n/**\n * Compute the target href for menu item.\n *\n * @param menuItem The root target href.\n *\n * @returns The menu item target href. If empty, returns the first child that has it defined or empty string if none.\n */\nconst getMenuTargetHref = (menuItem: HvAppShellMenuConfig): string => {\n const { target } = menuItem;\n if (target) {\n return target;\n }\n\n if (menuItem.submenus) {\n return getMenuTargetHref(menuItem.submenus[0]);\n }\n\n return \"\";\n};\n\n/**\n * Adds a dot to the href to indicate that it is a relative path.\n */\nconst addPrefixToHref = (href: string): string => {\n return !href.startsWith(\".\") ? `.${href}` : href;\n};\n\n/**\n * Creates a navigation data structure ({@link MenuItem}) from the provided menu configuration ({@link HvAppShellMenuConfig}).\n *\n * @param t\n * @param menuItems The set of menu items from configuration.\n * @param maxDepth The maximum depth up until the recursiveness should occur for the creation of the menu items.\n * @param parentMenuItem The parent menu item of the set of menu items.\n *\n * @returns An array of {@link MenuItem}.\n */\nconst createMenuItems = (\n t: (key: string) => string,\n menuItems?: HvAppShellMenuConfig[],\n maxDepth?: number,\n parentMenuItem?: MenuItem\n): MenuItem[] => {\n if (maxDepth !== undefined && maxDepth <= 0) {\n return [];\n }\n\n return (\n menuItems?.reduce<MenuItem[]>((accumulator, currentValue, index) => {\n const navItem: MenuItem = {\n id: parentMenuItem ? `${parentMenuItem.id}-${index}` : `${index}`,\n label: t(currentValue.label),\n href: addPrefixToHref(getMenuTargetHref(currentValue)),\n icon: currentValue.icon,\n parent: parentMenuItem\n };\n\n if (currentValue.submenus) {\n const updatedDepth = maxDepth !== undefined ? maxDepth - 1 : undefined;\n const data = createMenuItems(\n t,\n currentValue.submenus,\n updatedDepth,\n navItem\n );\n if (data.length > 0) {\n navItem.data = data;\n }\n }\n\n accumulator.push(navItem);\n return accumulator;\n }, []) ?? []\n );\n};\n\n/**\n * Removes the items that do not have path and replaces it by its children, recursively.\n *\n * @param items The list of {@link MenuItem}.\n *\n * @returns A flat array of {@link MenuItem}.\n */\nconst flatMenuItems = (items: MenuItem[]) => {\n return items.reduce<MenuItem[]>((acc, item) => {\n if (item.data) {\n acc.push(...flatMenuItems(item.data));\n } else {\n acc.push(item);\n }\n\n return acc;\n }, []);\n};\n\n/**\n * Helper function that uses a cumulative reduction to derive an array of cumulative hrefs based on the components\n * of the input string.\n * @example\n * // returns ['/', '/app', '/app/details', '/app/details/1']\n * // normalizedHref: \"/app/details/1\"\n *\n * @param normalizedHref The href string to be reduced.\n *\n * @returns the array of cumulative hrefs.\n */\nconst decomposeHrefStringToArray = (normalizedHref: string): string[] => {\n const hrefArray = normalizedHref\n .split(\"/\")\n .reduce<string[]>((accumulator, currentValue) => {\n if (currentValue === \"\") {\n return accumulator;\n }\n\n const prefix = accumulator.length === 0 ? \"\" : accumulator[0];\n const href =\n currentValue === \".\" ? currentValue : `${prefix}/${currentValue}`;\n accumulator.unshift(href);\n return accumulator;\n }, []);\n\n hrefArray.push(\"./\");\n\n return hrefArray;\n};\n\n/**\n * Algorithm implementation of the searchHrefInMenuItems function.\n *\n * @returns An object containing an item id or empty, if no match is found, and a flag to indicate if a\n * full href match was found. If the id is filled but the flag is 'false', then only partial match was found.\n */\nconst searchHrefMatch = (\n items: MenuItem[],\n normalizedHref: string,\n normalizedFullHref: string\n): string | undefined => {\n let toBeSelectedId: string | undefined;\n let toBeSelectedHref: string | undefined;\n\n const reducedNormalizedHref = decomposeHrefStringToArray(normalizedHref);\n\n flatMenuItems(items).some(item => {\n let normalizedItemHref: string | undefined;\n let normalizedItemHrefParams: string | undefined;\n\n const idx = item.href?.indexOf(\"?\");\n if (idx !== -1) {\n normalizedItemHref = item.href?.slice(0, idx).toLowerCase();\n normalizedItemHrefParams = item.href\n ?.slice(idx, item.href.length)\n .toLowerCase();\n } else {\n normalizedItemHref = item.href?.toLowerCase();\n normalizedItemHrefParams = \"\";\n }\n\n if (\n normalizedItemHref &&\n normalizedItemHref.length > 1 &&\n normalizedItemHref.endsWith(\"/\")\n ) {\n normalizedItemHref = normalizedItemHref.slice(\n 0,\n normalizedItemHref.length - 1\n );\n }\n\n const normalizedFullItemHref = `${normalizedItemHref}${normalizedItemHrefParams}`;\n\n // if the normalized full href is met, then search is complete\n if (normalizedFullItemHref === normalizedFullHref) {\n toBeSelectedId = item.id;\n return true;\n }\n\n // since it is not a full href match, we want to keep searching for a full href match,\n // while storing only the first/longer partial match found\n const matchedHref = reducedNormalizedHref.find(\n (href: string) => normalizedItemHref === href\n );\n if (\n matchedHref &&\n (!toBeSelectedHref || matchedHref.length > toBeSelectedHref?.length)\n ) {\n toBeSelectedId = item.id;\n toBeSelectedHref = matchedHref;\n }\n\n return false;\n });\n\n return toBeSelectedId;\n};\n\n/**\n * Searches for the href and parameters on all the menu items and its children until an exact match is found. If no\n * exact match is found but partial is, then the parent id for the first partial match found is returned.\n * @example\n * // returns '2'\n * // href: '/home', parameters: '?x=y', items: [{id:'1', href:'/home?z=v'},{id:'2', href:'/home'}\n *\n * For consistency purposes and based on the Router behavior, if either the href or the item href\n * (stripped of its query params) ends with a forward slash, then the comparison will ignore it\n * @example\n * // returns '1'\n * // href: '/home/', parameters: <empty>, items: [{id:'1', href:'/home'}]\n *\n * @param items The list of menu items to be searched.\n * @param href The url href after the domain up to the query parameters.\n * @param [parameters] The url query string after pathname.\n *\n * @returns The id of a parent menu item or an empty string.\n */\nconst searchHrefInMenuItems = (\n items: MenuItem[],\n href: string,\n parameters?: string\n): string | undefined => {\n if (!href) {\n return undefined;\n }\n\n const normalizedHref =\n href.length > 1 && href.endsWith(\"/\")\n ? href.slice(0, href.length - 1).toLowerCase()\n : href.toLowerCase();\n\n const normalizedFullHref = parameters\n ? normalizedHref.concat(parameters.toLowerCase())\n : normalizedHref;\n\n return searchHrefMatch(items, normalizedHref, normalizedFullHref);\n};\n\n/**\n * Get root menu id from the path (in the format 0-0-0 - id's separated by `-`)\n * @param menuItemId\n * @returns the Id of the first menu or undefined if the provided value is undefined\n */\nconst getRootIdFromItemId = (\n menuItemId: string | undefined\n): string | undefined => {\n if (!menuItemId) {\n return undefined;\n }\n return menuItemId.split(\"-\")[0];\n};\n\n/**\n * Searches for an item with the specified id.\n *\n * @param {MenuItem[]} data - The navigation data structure.\n * @param {string} itemId - The item id.\n * @returns The item with matching id.\n */\nconst findItemById = (data: MenuItem[], itemId: string): MenuItem | null => {\n let foundItem: MenuItem | null = null;\n data.some(obj => {\n const { id: objId, data: childData } = obj;\n if (objId === itemId) {\n foundItem = obj;\n return true;\n }\n if (childData && childData.length > 0) {\n foundItem = findItemById(childData, itemId);\n return foundItem !== null;\n }\n return false;\n });\n return foundItem;\n};\n\n/**\n * Finds the first leaf item (item with children) inside the received structure.\n *\n * @param {MenuItem[]} data - The navigation data structure.\n * @returns - The first leaf item inside the structure.\n */\nconst findFirstLeafItem = (data: MenuItem[]): MenuItem | null => {\n let foundItem: MenuItem | null = null;\n data.some(obj => {\n if (!obj.data || obj.data.length === 0) {\n foundItem = obj;\n return true;\n }\n foundItem = findFirstLeafItem(obj.data);\n return foundItem !== null;\n });\n return foundItem;\n};\n\nexport {\n createMenuItems,\n searchHrefInMenuItems,\n getRootIdFromItemId,\n addPrefixToHref,\n findItemById,\n findFirstLeafItem\n};\n","import { useContext, useEffect, useMemo, useState } from \"react\";\nimport { useLocation } from \"react-router-dom\";\n\nimport { MenuItemsContext } from \"../types\";\nimport {\n addPrefixToHref,\n createMenuItems,\n findFirstLeafItem,\n findItemById,\n getRootIdFromItemId,\n searchHrefInMenuItems\n} from \"../utils/navigationUtils\";\n\nimport CONFIG_TRANSLATIONS_NAMESPACE from \"../i18n\";\nimport useAppShellConfig from \"./useAppShellConfig\";\nimport { HvAppShellRuntimeContext } from \"../AppShellRuntimeContext\";\n\nconst MAX_TOP_MENU_DEPTH = 2;\n\nconst useMenuItems = (): MenuItemsContext => {\n const { pathname, search, state: locationState } = useLocation();\n const appShellContext = useAppShellConfig();\n\n // use the i18n instance from the app shell runtime context to ensure we're using\n // the app shell instance of i18n and not the one from the embedded app\n const { i18n } = useContext(HvAppShellRuntimeContext) ?? {};\n const tConfig = useMemo(\n () =>\n i18n?.getFixedT(i18n.language, CONFIG_TRANSLATIONS_NAMESPACE) ??\n // should not happen, but fallback if the i18n instance is not available\n ((l: string) => l),\n [i18n]\n );\n\n const items = useMemo(() => {\n const menuItemsDepth =\n appShellContext.navigationMode === \"ONLY_TOP\"\n ? MAX_TOP_MENU_DEPTH\n : undefined;\n\n return createMenuItems(tConfig, appShellContext.menu, menuItemsDepth);\n }, [appShellContext, tConfig]);\n\n const [selectedMenuItemId, setSelectedMenuItemId] = useState<\n string | undefined\n >(searchHrefInMenuItems(items, addPrefixToHref(pathname), search));\n\n const [rootMenuItemId, setRootMenuItemId] = useState<string | undefined>(\n getRootIdFromItemId(selectedMenuItemId)\n );\n\n useEffect(() => {\n // no menu items, nothing to select\n if (!items.length) {\n return;\n }\n // state property is used when we already know which menu is to be selected\n if (locationState?.selectedItemId) {\n setRootMenuItemId(getRootIdFromItemId(locationState.selectedItemId));\n // If the selected item has children we want to select the first child instead\n const selectedItem = findItemById(items, locationState.selectedItemId);\n if (selectedItem?.data?.length) {\n const firstItemToSelect = findFirstLeafItem(selectedItem.data);\n setSelectedMenuItemId(firstItemToSelect?.id);\n } else {\n setSelectedMenuItemId(selectedItem?.id);\n }\n return;\n }\n const toBeSelected = searchHrefInMenuItems(\n items,\n addPrefixToHref(pathname),\n search\n );\n if (toBeSelected) {\n setRootMenuItemId(getRootIdFromItemId(toBeSelected));\n setSelectedMenuItemId(toBeSelected);\n return;\n }\n // if none of the previous scenarios, then nothing is marked as selected\n setRootMenuItemId(undefined);\n setSelectedMenuItemId(undefined);\n }, [items, locationState, pathname, search]);\n return {\n items,\n selectedMenuItemId,\n rootMenuItemId\n };\n};\nexport default useMenuItems;\n","import { useContext } from \"react\";\n\nimport {\n HvAppShellCombinedProvidersContext,\n HvAppShellCombinedProvidersContextValue\n} from \"../AppShellCombinedProvidersContext\";\n\nconst useAppShellCombinedProviders =\n (): HvAppShellCombinedProvidersContextValue => {\n return useContext(\n HvAppShellCombinedProvidersContext\n ) as HvAppShellCombinedProvidersContextValue;\n };\n\nexport default useAppShellCombinedProviders;\n"],"names":["HvAppShellContext","createContext","undefined","HvAppShellViewContext","HvAppShellRuntimeContext","HvAppShellCombinedProvidersContext","CONFIG_TRANSLATIONS_NAMESPACE","CONFIG_TRANSLATIONS_NAMESPACE$1","useAppShellConfig","useContext","useAppShellConfig$1","getMenuTargetHref","menuItem","target","submenus","addPrefixToHref","href","startsWith","createMenuItems","t","menuItems","maxDepth","parentMenuItem","reduce","accumulator","currentValue","index","navItem","id","label","icon","parent","updatedDepth","data","length","push","flatMenuItems","items","acc","item","decomposeHrefStringToArray","normalizedHref","hrefArray","split","prefix","unshift","searchHrefMatch","normalizedFullHref","toBeSelectedId","toBeSelectedHref","reducedNormalizedHref","some","normalizedItemHref","normalizedItemHrefParams","idx","indexOf","slice","toLowerCase","endsWith","matchedHref","find","searchHrefInMenuItems","parameters","concat","getRootIdFromItemId","menuItemId","findItemById","itemId","foundItem","obj","objId","childData","findFirstLeafItem","MAX_TOP_MENU_DEPTH","useMenuItems","pathname","search","state","locationState","useLocation","appShellContext","i18n","tConfig","useMemo","getFixedT","language","l","menuItemsDepth","navigationMode","menu","selectedMenuItemId","setSelectedMenuItemId","useState","rootMenuItemId","setRootMenuItemId","useEffect","selectedItemId","selectedItem","firstItemToSelect","toBeSelected","useMenuItems$1","useAppShellCombinedProviders","useAppShellCombinedProviders$1"],"mappings":";;AAKaA,MAAAA,IAAoBC,EAE/BC,MAAS,GCDEC,IAAwBF,EAEnCC,MAAS,GCAEE,IAA2BH,EAEtCC,MAAS,GCFEG,IAAqCJ,EAEhDC,MAAS,GCVLI,IAAgC,sBACtCC,IAAeD,GCGTE,IAAoBA,MACjBC,EAAWT,CAAiB,GAGrCU,IAAeF,GCCTG,IAAoBA,CAACC,MAA2C;AAC9D,QAAA;AAAA,IAAEC,QAAAA;AAAAA,EAAWD,IAAAA;AACnB,SAAIC,MAIAD,EAASE,WACJH,EAAkBC,EAASE,SAAS,CAAC,CAAC,IAGxC;AACT,GAKMC,IAAkBA,CAACC,MACfA,EAAKC,WAAW,GAAG,IAAiBD,IAAZ,IAAGA,CAAK,IAapCE,IAAkBA,CACtBC,GACAC,GACAC,GACAC,MAEID,MAAanB,UAAamB,KAAY,IACjC,MAIPD,KAAAA,gBAAAA,EAAWG,OAAmB,CAACC,GAAaC,GAAcC,MAAU;AAClE,QAAMC,IAAoB;AAAA,IACxBC,IAAIN,IAAkB,GAAEA,EAAeM,EAAG,IAAGF,CAAM,KAAK,GAAEA,CAAM;AAAA,IAChEG,OAAOV,EAAEM,EAAaI,KAAK;AAAA,IAC3Bb,MAAMD,EAAgBJ,EAAkBc,CAAY,CAAC;AAAA,IACrDK,MAAML,EAAaK;AAAAA,IACnBC,QAAQT;AAAAA,EAAAA;AAGV,MAAIG,EAAaX,UAAU;AACzB,UAAMkB,IAAeX,MAAanB,SAAYmB,IAAW,IAAInB,QACvD+B,IAAOf,EACXC,GACAM,EAAaX,UACbkB,GACAL,CACF;AACIM,IAAAA,EAAKC,SAAS,MAChBP,EAAQM,OAAOA;AAAAA,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gBAAAA,EAAcrE,EAAE;AAExC;AAAA,IACF;AACA,UAAMuE,IAAetC,EACnBxB,GACAtB,EAAgB4D,CAAQ,GACxBC,CACF;AACA,QAAIuB,GAAc;AACEnC,MAAAA,EAAAA,EAAoBmC,CAAY,CAAC,GACnDR,EAAsBQ,CAAY;AAClC;AAAA,IACF;AAEAL,IAAAA,EAAkB5F,MAAS,GAC3ByF,EAAsBzF,MAAS;AAAA,KAC9B,CAACmC,GAAOyC,GAAeH,GAAUC,CAAM,CAAC,GACpC;AAAA,IACLvC,OAAAA;AAAAA,IACAqD,oBAAAA;AAAAA,IACAG,gBAAAA;AAAAA,EAAAA;AAEJ,GACAO,IAAe1B,GClFT2B,IACJA,MACS5F,EACLJ,CACF,GAGJiG,IAAeD;"}
@@ -17,6 +17,14 @@ export declare type HvAppShellAppSwitcherItemConfig = {
17
17
  icon?: HvAppShellIcon;
18
18
  };
19
19
 
20
+ export declare const HvAppShellCombinedProvidersContext: Context<HvAppShellCombinedProvidersContextValue | undefined>;
21
+
22
+ export declare interface HvAppShellCombinedProvidersContextValue {
23
+ providers?: React.ComponentType<{
24
+ children: React.ReactNode;
25
+ }>[];
26
+ }
27
+
20
28
  export declare type HvAppShellConfig = {
21
29
  baseUrl?: string;
22
30
  name?: string;
@@ -119,6 +127,8 @@ export declare interface MenuItemsContext {
119
127
 
120
128
  declare type RouteString = `/${string}`;
121
129
 
130
+ export declare const useHvAppShellCombinedProviders: () => HvAppShellCombinedProvidersContextValue;
131
+
122
132
  export declare const useHvAppShellConfig: () => HvAppShellContextValue;
123
133
 
124
134
  export declare const useHvMenuItems: () => MenuItemsContext;
@@ -0,0 +1,6 @@
1
+ import { createContext as o } from "react";
2
+ const t = o(void 0);
3
+ export {
4
+ t as HvAppShellCombinedProvidersContext
5
+ };
6
+ //# sourceMappingURL=AppShellCombinedProvidersContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppShellCombinedProvidersContext.js","sources":["../../src/AppShellCombinedProvidersContext.tsx"],"sourcesContent":["import { createContext } from \"react\";\n\nexport interface HvAppShellCombinedProvidersContextValue {\n providers?: React.ComponentType<{\n children: React.ReactNode;\n }>[];\n}\n\nexport const HvAppShellCombinedProvidersContext = createContext<\n HvAppShellCombinedProvidersContextValue | undefined\n>(undefined);\n"],"names":["HvAppShellCombinedProvidersContext","createContext","undefined"],"mappings":";AAQaA,MAAAA,IAAqCC,EAEhDC,MAAS;"}
@@ -0,0 +1,7 @@
1
+ import { useContext as e } from "react";
2
+ import { HvAppShellCombinedProvidersContext as o } from "../AppShellCombinedProvidersContext.js";
3
+ const r = () => e(o), s = r;
4
+ export {
5
+ s as default
6
+ };
7
+ //# sourceMappingURL=useAppShellCombinedProviders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAppShellCombinedProviders.js","sources":["../../../src/hooks/useAppShellCombinedProviders.tsx"],"sourcesContent":["import { useContext } from \"react\";\n\nimport {\n HvAppShellCombinedProvidersContext,\n HvAppShellCombinedProvidersContextValue\n} from \"../AppShellCombinedProvidersContext\";\n\nconst useAppShellCombinedProviders =\n (): HvAppShellCombinedProvidersContextValue => {\n return useContext(\n HvAppShellCombinedProvidersContext\n ) as HvAppShellCombinedProvidersContextValue;\n };\n\nexport default useAppShellCombinedProviders;\n"],"names":["useAppShellCombinedProviders","useContext","HvAppShellCombinedProvidersContext","useAppShellCombinedProviders$1"],"mappings":";;AAOA,MAAMA,IACJA,MACSC,EACLC,CACF,GAGJC,IAAeH;"}
package/dist/esm/index.js CHANGED
@@ -1,15 +1,19 @@
1
- import { HvAppShellContext as o } from "./AppShellContext.js";
1
+ import { HvAppShellContext as t } from "./AppShellContext.js";
2
2
  import { HvAppShellViewContext as r } from "./AppShellViewContext.js";
3
3
  import { HvAppShellRuntimeContext as f } from "./AppShellRuntimeContext.js";
4
- import { default as m } from "./i18n/index.js";
4
+ import { HvAppShellCombinedProvidersContext as x } from "./AppShellCombinedProvidersContext.js";
5
+ import { default as A } from "./i18n/index.js";
5
6
  import { default as u } from "./hooks/useAppShellConfig.js";
6
- import { default as a } from "./hooks/useMenuItems.js";
7
+ import { default as C } from "./hooks/useMenuItems.js";
8
+ import { default as a } from "./hooks/useAppShellCombinedProviders.js";
7
9
  export {
8
- m as CONFIG_TRANSLATIONS_NAMESPACE,
9
- o as HvAppShellContext,
10
+ A as CONFIG_TRANSLATIONS_NAMESPACE,
11
+ x as HvAppShellCombinedProvidersContext,
12
+ t as HvAppShellContext,
10
13
  f as HvAppShellRuntimeContext,
11
14
  r as HvAppShellViewContext,
15
+ a as useHvAppShellCombinedProviders,
12
16
  u as useHvAppShellConfig,
13
- a as useHvMenuItems
17
+ C as useHvMenuItems
14
18
  };
15
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitachivantara/app-shell-shared",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "description": "App Shell Shared",
5
5
  "author": "Hitachi Vantara - Boba Fett Team",
6
6
  "license": "Apache-2.0",
@@ -53,5 +53,5 @@
53
53
  "dependencies": {
54
54
  "@hitachivantara/uikit-react-core": "^5.66.7"
55
55
  },
56
- "gitHead": "d53c73bcb11dd17fb2f61b727c6442706c33ac5d"
56
+ "gitHead": "0e7f62ae71bf4f6626445c977518a90be50a7e1c"
57
57
  }