@hitachivantara/app-shell-ui 1.4.1 → 1.4.3
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,5 +1,5 @@
|
|
|
1
1
|
import { jsx as i } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { useContext as w, useState as d, useEffect as
|
|
2
|
+
import { useContext as w, useState as d, useEffect as a, useMemo as S } from "react";
|
|
3
3
|
import { HvAppShellContext as L, HvAppShellRuntimeContext as O, CONFIG_TRANSLATIONS_NAMESPACE as H } from "@hitachivantara/app-shell-shared";
|
|
4
4
|
import { BrowserRouter as N } from "react-router-dom";
|
|
5
5
|
import { I18nContext as B } from "react-i18next";
|
|
@@ -15,46 +15,46 @@ const V = ({
|
|
|
15
15
|
}) => {
|
|
16
16
|
var v, f, P, I;
|
|
17
17
|
const {
|
|
18
|
-
i18n:
|
|
18
|
+
i18n: l
|
|
19
19
|
} = w(B), {
|
|
20
20
|
value: A
|
|
21
|
-
} = F("COLOR_MODE"), [p, h] = d(void 0), [$,
|
|
22
|
-
|
|
21
|
+
} = F("COLOR_MODE"), [p, h] = d(void 0), [$, b] = d(!1);
|
|
22
|
+
a(() => {
|
|
23
23
|
!m && n && fetch(new URL(n)).then((r) => r.json()).then((r) => h(r)).catch((r) => {
|
|
24
|
-
console.error(`It was not possible to obtain the context from: ${n}`, r), h(void 0),
|
|
24
|
+
console.error(`It was not possible to obtain the context from: ${n}`, r), h(void 0), b(!0);
|
|
25
25
|
});
|
|
26
26
|
}, [m, n]);
|
|
27
27
|
const e = S(() => m ?? p, [m, p]);
|
|
28
28
|
if ($)
|
|
29
29
|
throw Error("It was not possible to obtain the configuration");
|
|
30
|
-
e != null && e.translations && D(
|
|
31
|
-
const [c,
|
|
32
|
-
|
|
33
|
-
var r,
|
|
34
|
-
(r = e == null ? void 0 : e.theming) != null && r.themes && Promise.all((
|
|
30
|
+
e != null && e.translations && D(l, e.translations, H);
|
|
31
|
+
const [c, E] = d(void 0), [u, M] = d(void 0);
|
|
32
|
+
a(() => {
|
|
33
|
+
var r, o;
|
|
34
|
+
(r = e == null ? void 0 : e.theming) != null && r.themes && Promise.all((o = e.theming.themes) == null ? void 0 : o.map((t) => T[t] ?? import(
|
|
35
35
|
/* @vite-ignore */
|
|
36
|
-
|
|
36
|
+
t
|
|
37
37
|
).then((s) => s.default).catch((s) => {
|
|
38
|
-
console.error(`Import of theme bundle ${
|
|
39
|
-
}))).then((
|
|
40
|
-
|
|
41
|
-
}).catch((
|
|
42
|
-
console.error(`Import of themes failed! ${
|
|
38
|
+
console.error(`Import of theme bundle ${t} failed! ${s}`);
|
|
39
|
+
}))).then((t) => {
|
|
40
|
+
E(t.filter((s) => !!s));
|
|
41
|
+
}).catch((t) => {
|
|
42
|
+
console.error(`Import of themes failed! ${t}`);
|
|
43
43
|
});
|
|
44
|
-
}, [(v = e == null ? void 0 : e.theming) == null ? void 0 : v.themes]),
|
|
44
|
+
}, [(v = e == null ? void 0 : e.theming) == null ? void 0 : v.themes]), a(() => {
|
|
45
45
|
e != null && e.providers && Promise.all(e.providers.map((r) => import(
|
|
46
46
|
/* @vite-ignore */
|
|
47
47
|
r.bundle
|
|
48
|
-
).then((
|
|
49
|
-
console.error(`Import of provider '${r.bundle}' failed! ${
|
|
50
|
-
}))).then((r) =>
|
|
48
|
+
).then((o) => o.default).catch((o) => {
|
|
49
|
+
console.error(`Import of provider '${r.bundle}' failed! ${o}`);
|
|
50
|
+
}))).then((r) => M(r.filter((o) => !!o))).catch((r) => {
|
|
51
51
|
console.error("Import of providers failed!", r);
|
|
52
52
|
});
|
|
53
53
|
}, [e == null ? void 0 : e.providers]);
|
|
54
|
-
const
|
|
55
|
-
i18n:
|
|
56
|
-
}), [
|
|
57
|
-
return !e || (f = e.theming) != null && f.themes && !c || e.providers != null && u === void 0 ? null : /* @__PURE__ */ i(L.Provider, { value: e, children: /* @__PURE__ */ i(O.Provider, { value:
|
|
54
|
+
const R = S(() => ({
|
|
55
|
+
i18n: l
|
|
56
|
+
}), [l]);
|
|
57
|
+
return !e || (f = e.theming) != null && f.themes && !c || e.providers != null && u === void 0 ? null : /* @__PURE__ */ i(L.Provider, { value: e, children: /* @__PURE__ */ i(O.Provider, { value: R, children: /* @__PURE__ */ i(_, { themes: c, theme: (P = e.theming) == null ? void 0 : P.theme, colorMode: A ?? ((I = e.theming) == null ? void 0 : I.colorMode), children: /* @__PURE__ */ i(N, { basename: j(e), children: /* @__PURE__ */ i(G, { providers: u, children: x }) }) }) }) });
|
|
58
58
|
}, Y = V;
|
|
59
59
|
export {
|
|
60
60
|
Y as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppShellProvider.js","sources":["../../../../src/components/AppShellProvider/AppShellProvider.tsx"],"sourcesContent":["import {\n ComponentType,\n ReactNode,\n useContext,\n useEffect,\n useMemo,\n useState\n} from \"react\";\nimport {\n CONFIG_TRANSLATIONS_NAMESPACE,\n HvAppShellConfig,\n HvAppShellContext,\n HvAppShellContextValue,\n HvAppShellRuntimeContext\n} from \"@hitachivantara/app-shell-shared\";\nimport { BrowserRouter } from \"react-router-dom\";\nimport { I18nContext } from \"react-i18next\";\n\nimport {\n HvProvider,\n
|
|
1
|
+
{"version":3,"file":"AppShellProvider.js","sources":["../../../../src/components/AppShellProvider/AppShellProvider.tsx"],"sourcesContent":["import {\n ComponentType,\n ReactNode,\n useContext,\n useEffect,\n useMemo,\n useState\n} from \"react\";\nimport {\n CONFIG_TRANSLATIONS_NAMESPACE,\n HvAppShellConfig,\n HvAppShellContext,\n HvAppShellContextValue,\n HvAppShellRuntimeContext\n} from \"@hitachivantara/app-shell-shared\";\nimport { BrowserRouter } from \"react-router-dom\";\nimport { I18nContext } from \"react-i18next\";\n\nimport {\n HvProvider,\n HvProviderProps,\n themes as baseThemes\n} from \"@hitachivantara/uikit-react-core\";\n\nimport getBasePath from \"../../lib/utils/basePathUtils\";\nimport { addResourceBundles } from \"../../lib/i18n\";\nimport useLocalStorage from \"../../lib/hooks/useLocalStorage\";\nimport CombinedProviders from \"../../lib/utils/CombinedProviders\";\n\nexport type AppShellProviderProps = {\n children: ReactNode;\n config?: Partial<HvAppShellConfig>;\n configUrl?: string;\n};\n\nconst AppShellProvider = ({\n children,\n config: localConfig,\n configUrl\n}: AppShellProviderProps) => {\n const { i18n } = useContext(I18nContext);\n const { value: storedColorModeValue } = useLocalStorage(\"COLOR_MODE\");\n const [loadedConfig, setLoadedConfig] = useState<\n HvAppShellConfig | undefined\n >(undefined);\n\n const [hasError, setHasError] = useState<boolean>(false);\n\n useEffect(() => {\n if (!localConfig && configUrl) {\n fetch(new URL(configUrl))\n .then(result => {\n return result.json();\n })\n .then(data => setLoadedConfig(data))\n .catch(e => {\n console.error(\n `It was not possible to obtain the context from: ${configUrl}`,\n e\n );\n setLoadedConfig(undefined);\n setHasError(true);\n });\n }\n }, [localConfig, configUrl]);\n\n const theConfig: HvAppShellContextValue | undefined = useMemo(\n () => localConfig ?? loadedConfig,\n [localConfig, loadedConfig]\n );\n\n if (hasError) {\n throw Error(\"It was not possible to obtain the configuration\");\n }\n\n if (theConfig?.translations) {\n addResourceBundles(\n i18n,\n theConfig.translations,\n CONFIG_TRANSLATIONS_NAMESPACE\n );\n }\n\n const [themes, setThemes] = useState<HvProviderProps[\"themes\"]>(undefined);\n const [providers, setProviders] = useState<\n ComponentType<{ children: ReactNode }>[] | undefined\n >(undefined);\n\n useEffect(() => {\n if (theConfig?.theming?.themes) {\n Promise.all(\n theConfig.theming.themes?.map(bundle => {\n return (\n baseThemes[bundle as keyof typeof baseThemes] ??\n import(/* @vite-ignore */ bundle)\n .then(module => module.default)\n .catch(e => {\n console.error(`Import of theme bundle ${bundle} failed! ${e}`);\n })\n );\n })\n )\n .then(loadedThemes => {\n setThemes(loadedThemes.filter(theme => !!theme));\n })\n .catch(e => {\n console.error(`Import of themes failed! ${e}`);\n });\n }\n }, [theConfig?.theming?.themes]);\n\n useEffect(() => {\n if (theConfig?.providers) {\n Promise.all(\n theConfig.providers.map(provider => {\n return import(/* @vite-ignore */ provider.bundle)\n .then(module => module.default)\n .catch(e => {\n console.error(\n `Import of provider '${provider.bundle}' failed! ${e}`\n );\n });\n })\n )\n .then(loadedProviders =>\n setProviders(loadedProviders.filter(provider => !!provider))\n )\n .catch(e => {\n console.error(`Import of providers failed!`, e);\n });\n }\n }, [theConfig?.providers]);\n\n const runtimeContext = useMemo(\n () => ({\n i18n\n }),\n [i18n]\n );\n if (\n !theConfig ||\n (theConfig.theming?.themes && !themes) ||\n (theConfig.providers != null && providers === undefined)\n ) {\n return null;\n }\n\n return (\n <HvAppShellContext.Provider value={theConfig}>\n <HvAppShellRuntimeContext.Provider value={runtimeContext}>\n <HvProvider\n themes={themes}\n theme={theConfig.theming?.theme}\n colorMode={storedColorModeValue ?? theConfig.theming?.colorMode}>\n <BrowserRouter basename={getBasePath(theConfig)}>\n <CombinedProviders providers={providers}>\n {children}\n </CombinedProviders>\n </BrowserRouter>\n </HvProvider>\n </HvAppShellRuntimeContext.Provider>\n </HvAppShellContext.Provider>\n );\n};\n\nexport default AppShellProvider;\n"],"names":["AppShellProvider","children","config","localConfig","configUrl","i18n","useContext","I18nContext","value","storedColorModeValue","useLocalStorage","loadedConfig","setLoadedConfig","useState","undefined","hasError","setHasError","useEffect","fetch","URL","then","result","json","data","catch","e","console","error","theConfig","useMemo","Error","translations","CONFIG_TRANSLATIONS_NAMESPACE","themes","setThemes","providers","setProviders","theming","Promise","all","map","bundle","baseThemes","module","default","loadedThemes","filter","theme","provider","loadedProviders","runtimeContext","HvAppShellContext","jsx","HvAppShellRuntimeContext","HvProvider","colorMode","BrowserRouter","getBasePath","CombinedProviders","AppShellProvider$1"],"mappings":";;;;;;;;;;AAmCA,MAAMA,IAAmBA,CAAC;AAAA,EACxBC,UAAAA;AAAAA,EACAC,QAAQC;AAAAA,EACRC,WAAAA;AACqB,MAAM;;AACrB,QAAA;AAAA,IAAEC,MAAAA;AAAAA,EAAAA,IAASC,EAAW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AAWtC,OAAwBmB,IAAAA,EAAUS,YAAVT,gBAAAA,EAAmB2B,YACtD,UAAA,gBAAAH,EAACI,KAAc,UAAUC,EAAY7B,CAAS,GAC5C,4BAAC8B,GAAkB,EAAA,WAAAvB,GAChBlC,UAAAA,GACH,EACF,CAAA,EACF,CAAA,GACF,EACF,CAAA;AAEJ,GAEA0D,IAAe3D;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/app-shell-ui",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "AppShell Component",
|
|
5
5
|
"author": "Hitachi Vantara - Boba Fett Team",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"@emotion/css": "^11.10.5",
|
|
39
39
|
"@emotion/react": "^11.10.5",
|
|
40
40
|
"@emotion/styled": "^11.10.5",
|
|
41
|
-
"@hitachivantara/app-shell-events": "1.0.
|
|
42
|
-
"@hitachivantara/app-shell-navigation": "1.2.
|
|
43
|
-
"@hitachivantara/app-shell-shared": "1.2.
|
|
44
|
-
"@hitachivantara/uikit-react-core": "^5.
|
|
45
|
-
"@hitachivantara/uikit-react-icons": "^5.
|
|
41
|
+
"@hitachivantara/app-shell-events": "1.0.2",
|
|
42
|
+
"@hitachivantara/app-shell-navigation": "1.2.4",
|
|
43
|
+
"@hitachivantara/app-shell-shared": "1.2.2",
|
|
44
|
+
"@hitachivantara/uikit-react-core": "^5.66.7",
|
|
45
|
+
"@hitachivantara/uikit-react-icons": "^5.10.1",
|
|
46
46
|
"@mui/material": "^5.12.3",
|
|
47
47
|
"i18next": "^23.7.7",
|
|
48
48
|
"i18next-browser-languagedetector": "^7.0.1",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"vite-plugin-dts": "^3.6.4",
|
|
69
69
|
"vite-tsconfig-paths": "^4.0.5"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "d53c73bcb11dd17fb2f61b727c6442706c33ac5d"
|
|
72
72
|
}
|