@deix/rossini-core 0.5.4 → 0.6.1
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/lib/package.json +1 -1
- package/lib/src/components/buttons/Avatar/Avatar.d.ts +1 -1
- package/lib/src/components/buttons/Avatar/Avatar.js +8 -8
- package/lib/src/components/buttons/LanguageSelect/LanguageSelect.d.ts +2 -2
- package/lib/src/components/buttons/LanguageSelect/LanguageSelect.d.ts.map +1 -1
- package/lib/src/components/buttons/LanguageSelect/LanguageSelect.js +13 -12
- package/lib/src/components/layout/components/Sidebar/Sidebar.d.ts +3 -3
- package/lib/src/components/layout/components/Sidebar/Sidebar.js +52 -52
- package/lib/src/components/layout/components/Topbar/Topbar.d.ts +5 -3
- package/lib/src/components/layout/components/Topbar/Topbar.d.ts.map +1 -1
- package/lib/src/components/layout/components/Topbar/Topbar.js +8 -8
- package/lib/src/types/palette.d.ts +3 -3
- package/lib/src/types/palette.d.ts.map +1 -1
- package/lib/src/utils/hooks/usePersistedState.d.ts +2 -1
- package/lib/src/utils/hooks/usePersistedState.d.ts.map +1 -1
- package/lib/src/utils/hooks/usePersistedState.js +31 -7
- package/lib/src/utils/theme/palette/index.d.ts +2 -2
- package/lib/src/utils/theme/palette/index.d.ts.map +1 -1
- package/lib/src/utils/theme/palette/index.js +45 -35
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/lib/package.json
CHANGED
|
@@ -49,21 +49,21 @@ const Avatar = ({ logoutUrl, accountSettingsUrl, }) => {
|
|
|
49
49
|
const apiClient = (0, utils_1.useAPI)(accountSettingsUrl);
|
|
50
50
|
const { data: userInfo } = (0, useKeycloak_1.useUserInfo)(apiClient);
|
|
51
51
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
52
|
-
react_1.default.createElement(material_1.Tooltip, { title: userInfo?.preferredUserName ||
|
|
53
|
-
react_1.default.createElement(material_1.Avatar, { alt: userInfo?.preferredUserName ||
|
|
54
|
-
bgcolor: muiTheme.palette.primary.main,
|
|
52
|
+
react_1.default.createElement(material_1.Tooltip, { title: userInfo?.preferredUserName || "Anonymous User" },
|
|
53
|
+
react_1.default.createElement(material_1.Avatar, { alt: userInfo?.preferredUserName || "user-name", sx: {
|
|
55
54
|
width: 24,
|
|
56
55
|
height: 24,
|
|
56
|
+
bgcolor: muiTheme.palette.topbar.contrastText,
|
|
57
57
|
}, onClick: handleClick })),
|
|
58
58
|
react_1.default.createElement(material_1.Menu, { anchorEl: anchorEl, open: open, onClose: handleClose, anchorOrigin: {
|
|
59
|
-
vertical:
|
|
60
|
-
horizontal:
|
|
59
|
+
vertical: "bottom",
|
|
60
|
+
horizontal: "right",
|
|
61
61
|
}, transformOrigin: {
|
|
62
|
-
vertical:
|
|
63
|
-
horizontal:
|
|
62
|
+
vertical: "top",
|
|
63
|
+
horizontal: "right",
|
|
64
64
|
}, PaperProps: {
|
|
65
65
|
sx: {
|
|
66
|
-
padding:
|
|
66
|
+
padding: "4px",
|
|
67
67
|
},
|
|
68
68
|
} },
|
|
69
69
|
accountSettingsUrl && (react_1.default.createElement(link_1.default, { href: accountSettingsUrl },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FunctionComponent } from
|
|
2
|
-
import { Language, Locale } from
|
|
1
|
+
import { FunctionComponent } from "react";
|
|
2
|
+
import { Language, Locale } from "../../../types/languages";
|
|
3
3
|
export interface LanguageSelectProps {
|
|
4
4
|
/**
|
|
5
5
|
* Internationalization locale.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LanguageSelect.d.ts","sourceRoot":"","sources":["../../../../../src/components/buttons/LanguageSelect/LanguageSelect.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LanguageSelect.d.ts","sourceRoot":"","sources":["../../../../../src/components/buttons/LanguageSelect/LanguageSelect.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAiBjD,OAAO,EAGL,QAAQ,EACR,MAAM,EACP,MAAM,0BAA0B,CAAC;AAGlC,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;CACxB;AAED,eAAO,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,CA+EjE,CAAC"}
|
|
@@ -11,14 +11,15 @@ const Language_1 = __importDefault(require("@mui/icons-material/Language"));
|
|
|
11
11
|
const material_1 = require("@mui/material");
|
|
12
12
|
const languages_1 = require("../../../types/languages");
|
|
13
13
|
const translations_json_1 = __importDefault(require("./translations.json"));
|
|
14
|
-
const LanguageSelect = ({ locale =
|
|
14
|
+
const LanguageSelect = ({ locale = "en", languages = [
|
|
15
15
|
{
|
|
16
|
-
id:
|
|
17
|
-
label:
|
|
18
|
-
countryCode:
|
|
19
|
-
MUILocale:
|
|
16
|
+
id: "en",
|
|
17
|
+
label: "English",
|
|
18
|
+
countryCode: "us",
|
|
19
|
+
MUILocale: "enUS",
|
|
20
20
|
},
|
|
21
21
|
], }) => {
|
|
22
|
+
const muiTheme = (0, material_1.useTheme)();
|
|
22
23
|
// Menu controls
|
|
23
24
|
const [anchorEl, setAnchorEl] = react_1.default.useState(null);
|
|
24
25
|
const open = Boolean(anchorEl);
|
|
@@ -34,18 +35,18 @@ const LanguageSelect = ({ locale = 'en', languages = [
|
|
|
34
35
|
};
|
|
35
36
|
const router = (0, router_1.useRouter)();
|
|
36
37
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
37
|
-
react_1.default.createElement(material_1.Tooltip, { title: translations_json_1.default[
|
|
38
|
+
react_1.default.createElement(material_1.Tooltip, { title: translations_json_1.default["tooltip"][locale] },
|
|
38
39
|
react_1.default.createElement(material_1.IconButton, { component: 'span', "aria-label": 'language', onClick: openOptions },
|
|
39
|
-
react_1.default.createElement(Language_1.default,
|
|
40
|
+
react_1.default.createElement(Language_1.default, { htmlColor: muiTheme.palette.topbar.contrastText }))),
|
|
40
41
|
react_1.default.createElement(material_1.Menu, { anchorEl: anchorEl, id: 'language-menu', open: open, onClose: closeOptions, onClick: closeOptions, anchorOrigin: {
|
|
41
|
-
vertical:
|
|
42
|
-
horizontal:
|
|
42
|
+
vertical: "bottom",
|
|
43
|
+
horizontal: "right",
|
|
43
44
|
}, transformOrigin: {
|
|
44
|
-
vertical:
|
|
45
|
-
horizontal:
|
|
45
|
+
vertical: "top",
|
|
46
|
+
horizontal: "right",
|
|
46
47
|
}, PaperProps: {
|
|
47
48
|
sx: {
|
|
48
|
-
padding:
|
|
49
|
+
padding: "4px",
|
|
49
50
|
},
|
|
50
51
|
} },
|
|
51
52
|
react_1.default.createElement(material_1.MenuList, { dense: true }, languages?.map((lang) => (react_1.default.createElement(link_1.default, { key: lang.id, href: router.asPath, locale: lang.id },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { ReactElement } from
|
|
2
|
-
import { Variant } from
|
|
3
|
-
import { Locale, StringTranslation } from
|
|
1
|
+
import React, { ReactElement } from "react";
|
|
2
|
+
import { Variant } from "@mui/material/styles/createTypography";
|
|
3
|
+
import { Locale, StringTranslation } from "../../../../types/languages";
|
|
4
4
|
export interface SidebarLink {
|
|
5
5
|
/**
|
|
6
6
|
* Unique identifier of the link.
|
|
@@ -42,12 +42,12 @@ const Sidebar = ({ links, open, isMobile, logo, locale, onClose, }) => {
|
|
|
42
42
|
// Handle default item icon and change color according to selection
|
|
43
43
|
const icons = (link, selected) => {
|
|
44
44
|
const color = selected
|
|
45
|
-
? muiTheme.palette.
|
|
46
|
-
: muiTheme.palette.
|
|
45
|
+
? muiTheme.palette.sidebar.contrastText
|
|
46
|
+
: muiTheme.palette.sidebar.light;
|
|
47
47
|
return (react_1.default.createElement(material_1.ListItemIcon, { color: color }, link.sidebarIcon ? (link.sidebarIcon(color)) : (react_1.default.createElement(ArrowRightOutlined_1.default, { htmlColor: color }))));
|
|
48
48
|
};
|
|
49
49
|
// Persist which items of the sidebar are open to avoid resetting on page change
|
|
50
|
-
const [sidebarItemOpen, setSidebarItemOpen] = (0, utils_1.usePersistedState)(
|
|
50
|
+
const [sidebarItemOpen, setSidebarItemOpen] = (0, utils_1.usePersistedState)("sidebarItemOpen", {});
|
|
51
51
|
const handleOpenSidebarItem = (item) => {
|
|
52
52
|
const oldOpenState = { ...sidebarItemOpen };
|
|
53
53
|
oldOpenState[item] =
|
|
@@ -81,39 +81,39 @@ const Sidebar = ({ links, open, isMobile, logo, locale, onClose, }) => {
|
|
|
81
81
|
}
|
|
82
82
|
})
|
|
83
83
|
.map((link) => {
|
|
84
|
-
const selected = link.path ===
|
|
85
|
-
? pathname ===
|
|
84
|
+
const selected = link.path === "/"
|
|
85
|
+
? pathname === "/"
|
|
86
86
|
: pathname.slice(1).startsWith(link.path.slice(1));
|
|
87
87
|
if (!link.subPages) {
|
|
88
88
|
return (react_1.default.createElement(link_1.default, { key: link.id, href: link.path },
|
|
89
89
|
react_1.default.createElement(material_1.ListItemButton, { selected: selected, style: {
|
|
90
|
-
paddingLeft: options.level === 1 && open ?
|
|
90
|
+
paddingLeft: options.level === 1 && open ? "32px" : "22px",
|
|
91
91
|
paddingTop: options.level === 1 ? 0 : 8,
|
|
92
92
|
paddingBottom: options.level === 1 ? 0 : 8,
|
|
93
|
-
borderTopRightRadius:
|
|
94
|
-
borderBottomRightRadius:
|
|
93
|
+
borderTopRightRadius: "20px",
|
|
94
|
+
borderBottomRightRadius: "20px",
|
|
95
95
|
} },
|
|
96
96
|
icons(link, selected),
|
|
97
97
|
react_1.default.createElement(material_1.ListItemText, { style: {
|
|
98
98
|
color: selected
|
|
99
|
-
? `${muiTheme.palette.
|
|
100
|
-
: `${muiTheme.palette.
|
|
101
|
-
marginLeft:
|
|
102
|
-
visibility:
|
|
103
|
-
}, disableTypography: true, primary: react_1.default.createElement(material_1.Typography, { variant: link.labelVariant ||
|
|
104
|
-
? { color: muiTheme.palette.
|
|
105
|
-
: { color: muiTheme.palette.
|
|
99
|
+
? `${muiTheme.palette.sidebar.contrastText} !important`
|
|
100
|
+
: `${muiTheme.palette.sidebar.light} !important`,
|
|
101
|
+
marginLeft: "-20px",
|
|
102
|
+
visibility: "visible",
|
|
103
|
+
}, disableTypography: true, primary: react_1.default.createElement(material_1.Typography, { variant: link.labelVariant || "h6", style: selected
|
|
104
|
+
? { color: muiTheme.palette.sidebar.contrastText }
|
|
105
|
+
: { color: muiTheme.palette.sidebar.light } }, (0, languages_1.isStringTranslation)(link.label)
|
|
106
106
|
? link.label[locale]
|
|
107
107
|
: link.label) }))));
|
|
108
108
|
}
|
|
109
109
|
return (react_1.default.createElement("div", { key: link.id },
|
|
110
110
|
react_1.default.createElement(link_1.default, { href: link.path },
|
|
111
111
|
react_1.default.createElement(material_1.ListItemButton, { key: link.id, selected: selected, style: {
|
|
112
|
-
paddingLeft:
|
|
112
|
+
paddingLeft: "22px",
|
|
113
113
|
paddingTop: 8,
|
|
114
114
|
paddingBottom: 8,
|
|
115
|
-
borderTopRightRadius:
|
|
116
|
-
borderBottomRightRadius:
|
|
115
|
+
borderTopRightRadius: "20px",
|
|
116
|
+
borderBottomRightRadius: "20px",
|
|
117
117
|
}, onClick: (_evt) => {
|
|
118
118
|
if (!sidebarItemOpen[link.id]) {
|
|
119
119
|
handleOpenSidebarItem(link.id);
|
|
@@ -122,13 +122,13 @@ const Sidebar = ({ links, open, isMobile, logo, locale, onClose, }) => {
|
|
|
122
122
|
icons(link, selected),
|
|
123
123
|
react_1.default.createElement(material_1.ListItemText, { style: {
|
|
124
124
|
color: selected
|
|
125
|
-
? `${muiTheme.palette.
|
|
126
|
-
: `${muiTheme.palette.
|
|
127
|
-
marginLeft:
|
|
128
|
-
visibility:
|
|
129
|
-
}, disableTypography: true, primary: react_1.default.createElement(material_1.Typography, { variant: link.labelVariant ||
|
|
130
|
-
? { color: muiTheme.palette.
|
|
131
|
-
: { color: muiTheme.palette.
|
|
125
|
+
? `${muiTheme.palette.sidebar.contrastText} !important`
|
|
126
|
+
: `${muiTheme.palette.sidebar.light} !important`,
|
|
127
|
+
marginLeft: "-20px",
|
|
128
|
+
visibility: "visible",
|
|
129
|
+
}, disableTypography: true, primary: react_1.default.createElement(material_1.Typography, { variant: link.labelVariant || "h6", style: selected
|
|
130
|
+
? { color: muiTheme.palette.sidebar.contrastText }
|
|
131
|
+
: { color: muiTheme.palette.sidebar.light } }, (0, languages_1.isStringTranslation)(link.label)
|
|
132
132
|
? link.label[locale]
|
|
133
133
|
: link.label) }),
|
|
134
134
|
sidebarItemOpen[link.id] ? (react_1.default.createElement(material_1.IconButton, { onClick: (e) => {
|
|
@@ -156,40 +156,40 @@ const Sidebar = ({ links, open, isMobile, logo, locale, onClose, }) => {
|
|
|
156
156
|
})
|
|
157
157
|
// .filter((l) => l.id !== 'settings')
|
|
158
158
|
.map((link) => {
|
|
159
|
-
const selected = link.path ===
|
|
160
|
-
? pathname ===
|
|
159
|
+
const selected = link.path === "/"
|
|
160
|
+
? pathname === "/"
|
|
161
161
|
: pathname.slice(1).startsWith(link.path.slice(1));
|
|
162
162
|
if (link.subPages) {
|
|
163
163
|
return (react_1.default.createElement("div", { key: link.id },
|
|
164
164
|
react_1.default.createElement(material_1.ListItemButton, { selected: selected, style: {
|
|
165
|
-
paddingLeft:
|
|
165
|
+
paddingLeft: "22px",
|
|
166
166
|
paddingTop: 8,
|
|
167
167
|
paddingBottom: 8,
|
|
168
|
-
borderTopRightRadius:
|
|
169
|
-
borderBottomRightRadius:
|
|
168
|
+
borderTopRightRadius: "20px",
|
|
169
|
+
borderBottomRightRadius: "20px",
|
|
170
170
|
}, onClick: (evt) => handleOpenSidebarMenu(link.id, evt) },
|
|
171
171
|
react_1.default.createElement(material_1.Tooltip, { title: (0, languages_1.isStringTranslation)(link.label)
|
|
172
172
|
? link.label[locale]
|
|
173
173
|
: link.label, placement: 'right', enterDelay: 600, enterNextDelay: 600, arrow: true }, icons(link, selected))),
|
|
174
174
|
react_1.default.createElement(material_1.Menu, { id: `${link.id}-subpages-menu`, anchorEl: subPagesMenuAnchorEl[link.id], open: Boolean(subPagesMenuAnchorEl[link.id]), onClose: (_evt) => handleCloseSidebarMenu(link.id), anchorOrigin: {
|
|
175
|
-
vertical:
|
|
176
|
-
horizontal:
|
|
175
|
+
vertical: "top",
|
|
176
|
+
horizontal: "right",
|
|
177
177
|
}, transformOrigin: {
|
|
178
|
-
vertical:
|
|
179
|
-
horizontal:
|
|
178
|
+
vertical: "top",
|
|
179
|
+
horizontal: "left",
|
|
180
180
|
}, PaperProps: {
|
|
181
181
|
sx: {
|
|
182
|
-
borderRadius:
|
|
183
|
-
padding:
|
|
184
|
-
overflow:
|
|
182
|
+
borderRadius: "2px",
|
|
183
|
+
padding: "2px",
|
|
184
|
+
overflow: "visible",
|
|
185
185
|
},
|
|
186
186
|
} }, link.subPages.map((subPage) => (react_1.default.createElement(link_1.default, { key: subPage.id, href: subPage.path },
|
|
187
187
|
react_1.default.createElement(material_1.MenuItem, null,
|
|
188
188
|
icons(subPage, selected),
|
|
189
189
|
react_1.default.createElement(material_1.ListItemText, { style: {
|
|
190
190
|
color: selected
|
|
191
|
-
? `${muiTheme.palette.
|
|
192
|
-
: `${muiTheme.palette.
|
|
191
|
+
? `${muiTheme.palette.sidebar.contrastText} !important`
|
|
192
|
+
: `${muiTheme.palette.sidebar.light} !important`,
|
|
193
193
|
} }, (0, languages_1.isStringTranslation)(subPage.label)
|
|
194
194
|
? subPage.label[locale]
|
|
195
195
|
: subPage.label))))))));
|
|
@@ -197,11 +197,11 @@ const Sidebar = ({ links, open, isMobile, logo, locale, onClose, }) => {
|
|
|
197
197
|
else {
|
|
198
198
|
return (react_1.default.createElement(link_1.default, { key: link.id, href: link.path },
|
|
199
199
|
react_1.default.createElement(material_1.ListItemButton, { selected: selected, style: {
|
|
200
|
-
paddingLeft:
|
|
200
|
+
paddingLeft: "22px",
|
|
201
201
|
paddingTop: 8,
|
|
202
202
|
paddingBottom: 8,
|
|
203
|
-
borderTopRightRadius:
|
|
204
|
-
borderBottomRightRadius:
|
|
203
|
+
borderTopRightRadius: "20px",
|
|
204
|
+
borderBottomRightRadius: "20px",
|
|
205
205
|
} },
|
|
206
206
|
react_1.default.createElement(material_1.Tooltip, { title: (0, languages_1.isStringTranslation)(link.label)
|
|
207
207
|
? link.label[locale]
|
|
@@ -210,27 +210,27 @@ const Sidebar = ({ links, open, isMobile, logo, locale, onClose, }) => {
|
|
|
210
210
|
}));
|
|
211
211
|
}
|
|
212
212
|
};
|
|
213
|
-
return (react_1.default.createElement(material_1.Drawer, { anchor: 'left', onClose: onClose, open: open, variant: isMobile ?
|
|
213
|
+
return (react_1.default.createElement(material_1.Drawer, { anchor: 'left', onClose: onClose, open: open, variant: isMobile ? "temporary" : "permanent", sx: {
|
|
214
214
|
flexShrink: 0,
|
|
215
|
-
whiteSpace:
|
|
216
|
-
height:
|
|
215
|
+
whiteSpace: "nowrap",
|
|
216
|
+
height: "100%",
|
|
217
217
|
width: {
|
|
218
|
-
xs: open ?
|
|
219
|
-
sm: open ?
|
|
220
|
-
md: open ?
|
|
218
|
+
xs: open ? "65%" : `${parseInt(muiTheme.spacing(10), 10) + 1}px`,
|
|
219
|
+
sm: open ? "50%" : `${parseInt(muiTheme.spacing(10), 10) + 1}px`,
|
|
220
|
+
md: open ? "300px" : `${parseInt(muiTheme.spacing(10), 10) + 1}px`,
|
|
221
221
|
},
|
|
222
222
|
}, PaperProps: {
|
|
223
223
|
sx: {
|
|
224
224
|
// pr: 1,
|
|
225
225
|
width: {
|
|
226
|
-
xs: open ?
|
|
227
|
-
sm: open ?
|
|
228
|
-
md: open ?
|
|
226
|
+
xs: open ? "65%" : `${parseInt(muiTheme.spacing(10), 10) + 1}px`,
|
|
227
|
+
sm: open ? "50%" : `${parseInt(muiTheme.spacing(10), 10) + 1}px`,
|
|
228
|
+
md: open ? "300px" : `${parseInt(muiTheme.spacing(10), 10) + 1}px`,
|
|
229
229
|
},
|
|
230
230
|
background: muiTheme.palette.sidebar.main,
|
|
231
231
|
},
|
|
232
232
|
} },
|
|
233
|
-
react_1.default.createElement(material_1.List, { style: { marginTop:
|
|
233
|
+
react_1.default.createElement(material_1.List, { style: { marginTop: "19px" } }, handler(links, { level: 0 })),
|
|
234
234
|
react_1.default.createElement("div", { style: { flexGrow: 1 } }),
|
|
235
235
|
logo));
|
|
236
236
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Language, Locale } from
|
|
3
|
-
import { AvatarProps } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Language, Locale } from "../../../../types/languages";
|
|
3
|
+
import { AvatarProps } from "../../../buttons/Avatar/Avatar";
|
|
4
4
|
interface TopbarProps {
|
|
5
5
|
/**
|
|
6
6
|
* If true the layout has a sidebar.
|
|
@@ -30,6 +30,8 @@ interface TopbarProps {
|
|
|
30
30
|
* The props to be passed to the Avatar button component.
|
|
31
31
|
*/
|
|
32
32
|
avatar?: AvatarProps;
|
|
33
|
+
backgroundColor?: string;
|
|
34
|
+
iconsColor?: string;
|
|
33
35
|
}
|
|
34
36
|
declare const Topbar: React.FC<TopbarProps>;
|
|
35
37
|
export default Topbar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Topbar.d.ts","sourceRoot":"","sources":["../../../../../../src/components/layout/components/Topbar/Topbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAU,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAIrE,UAAU,WAAW;IACnB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB;;OAEG;IACH,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B;;OAEG;IACH,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"Topbar.d.ts","sourceRoot":"","sources":["../../../../../../src/components/layout/components/Topbar/Topbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAU,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAIrE,UAAU,WAAW;IACnB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB;;OAEG;IACH,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B;;OAEG;IACH,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,QAAA,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAgEjC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -38,11 +38,11 @@ const ElevationScroll_1 = __importDefault(require("./ElevationScroll"));
|
|
|
38
38
|
const S = __importStar(require("./Topbar.styles"));
|
|
39
39
|
const translations_json_1 = __importDefault(require("./translations.json"));
|
|
40
40
|
const Topbar = (props) => {
|
|
41
|
-
const { hasSidebar = false, onSidebarClose, onSidebarOpen, open, locale, languages, avatar, } = props;
|
|
41
|
+
const { hasSidebar = false, onSidebarClose, onSidebarOpen, open, locale, languages, avatar, backgroundColor, iconsColor, } = props;
|
|
42
42
|
const { resolvedTheme, setTheme } = (0, next_themes_1.useTheme)();
|
|
43
43
|
const muiTheme = (0, material_1.useTheme)();
|
|
44
|
-
const SidebarIcon = open ? (react_1.default.createElement(MenuOpenTwoTone_1.default, {
|
|
45
|
-
const menuMessage = open ? translations_json_1.default[
|
|
44
|
+
const SidebarIcon = open ? (react_1.default.createElement(MenuOpenTwoTone_1.default, { htmlColor: muiTheme.palette.topbar.contrastText })) : (react_1.default.createElement(MenuTwoTone_1.default, { htmlColor: muiTheme.palette.topbar.contrastText }));
|
|
45
|
+
const menuMessage = open ? translations_json_1.default["menuClose"][locale] : translations_json_1.default["menuOpen"][locale];
|
|
46
46
|
return (react_1.default.createElement(ElevationScroll_1.default, { ...props },
|
|
47
47
|
react_1.default.createElement(S.StyledAppBar, { position: 'static', theme: muiTheme },
|
|
48
48
|
react_1.default.createElement(material_1.Toolbar, null,
|
|
@@ -52,10 +52,10 @@ const Topbar = (props) => {
|
|
|
52
52
|
react_1.default.createElement(index_1.LanguageSelect, { locale: locale, languages: languages }),
|
|
53
53
|
react_1.default.createElement(material_1.IconButton, { component: 'span', "aria-label": 'user options' },
|
|
54
54
|
react_1.default.createElement(Avatar_1.Avatar, { ...avatar })),
|
|
55
|
-
react_1.default.createElement(material_1.Tooltip, { title: resolvedTheme ===
|
|
56
|
-
? translations_json_1.default[
|
|
57
|
-
: translations_json_1.default[
|
|
58
|
-
react_1.default.createElement(material_1.IconButton, { component: 'span', "aria-label": 'toggle dark mode', onClick: () => setTheme(resolvedTheme ===
|
|
59
|
-
react_1.default.createElement(ModeNight_1.default,
|
|
55
|
+
react_1.default.createElement(material_1.Tooltip, { title: resolvedTheme === "light"
|
|
56
|
+
? translations_json_1.default["enableDark"][locale]
|
|
57
|
+
: translations_json_1.default["disableDark"][locale] },
|
|
58
|
+
react_1.default.createElement(material_1.IconButton, { component: 'span', "aria-label": 'toggle dark mode', onClick: () => setTheme(resolvedTheme === "light" ? "dark" : "light") },
|
|
59
|
+
react_1.default.createElement(ModeNight_1.default, { htmlColor: muiTheme.palette.topbar.contrastText })))))));
|
|
60
60
|
};
|
|
61
61
|
exports.default = Topbar;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
declare module
|
|
1
|
+
declare module "@mui/material/styles/createPalette" {
|
|
2
2
|
interface Palette {
|
|
3
3
|
gradient: SimplePaletteColorOptions;
|
|
4
4
|
linkNotActive: SimplePaletteColorOptions;
|
|
5
|
-
sidebar: SimplePaletteColorOptions
|
|
5
|
+
sidebar: Required<SimplePaletteColorOptions>;
|
|
6
6
|
topbar: SimplePaletteColorOptions;
|
|
7
7
|
}
|
|
8
8
|
interface PaletteOptions {
|
|
9
9
|
gradient: SimplePaletteColorOptions;
|
|
10
10
|
linkNotActive: SimplePaletteColorOptions;
|
|
11
|
-
sidebar: SimplePaletteColorOptions
|
|
11
|
+
sidebar: Required<SimplePaletteColorOptions>;
|
|
12
12
|
topbar: SimplePaletteColorOptions;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../../src/types/palette.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,oCAAoC,CAAC;IAClD,UAAU,OAAO;QACf,QAAQ,EAAE,yBAAyB,CAAC;QACpC,aAAa,EAAE,yBAAyB,CAAC;QACzC,OAAO,EAAE,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../../src/types/palette.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,oCAAoC,CAAC;IAClD,UAAU,OAAO;QACf,QAAQ,EAAE,yBAAyB,CAAC;QACpC,aAAa,EAAE,yBAAyB,CAAC;QACzC,OAAO,EAAE,QAAQ,CAAC,yBAAyB,CAAC,CAAC;QAC7C,MAAM,EAAE,yBAAyB,CAAC;KACnC;IACD,UAAU,cAAc;QACtB,QAAQ,EAAE,yBAAyB,CAAC;QACpC,aAAa,EAAE,yBAAyB,CAAC;QACzC,OAAO,EAAE,QAAQ,CAAC,yBAAyB,CAAC,CAAC;QAC7C,MAAM,EAAE,yBAAyB,CAAC;KACnC;CACF;AAED,OAAO,EAAE,CAAC"}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {string} name the name of the variable in local storage.
|
|
5
5
|
* @param {T} defaultValue the default value
|
|
6
|
+
* @param {"local" | "session"} storage the type of storage where to persist the state
|
|
6
7
|
*/
|
|
7
|
-
declare function usePersistedState<T>(name: string, defaultValue: T): [T, (value: T) => void];
|
|
8
|
+
declare function usePersistedState<T>(name: string, defaultValue: T, storage?: "local" | "session"): [T, (value: T) => void];
|
|
8
9
|
export default usePersistedState;
|
|
9
10
|
//# sourceMappingURL=usePersistedState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePersistedState.d.ts","sourceRoot":"","sources":["../../../../src/utils/hooks/usePersistedState.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePersistedState.d.ts","sourceRoot":"","sources":["../../../../src/utils/hooks/usePersistedState.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,iBAAS,iBAAiB,CAAC,CAAC,EAC1B,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,CAAC,EACf,OAAO,GAAE,OAAO,GAAG,SAAmB,GACrC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,CA8CzB;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,26 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const react_1 = require("react");
|
|
4
|
+
const storageMap = {
|
|
5
|
+
local: "localStorage",
|
|
6
|
+
session: "sessionStorage",
|
|
7
|
+
};
|
|
4
8
|
/**
|
|
5
9
|
* Use a variable stored persistently on local storage.
|
|
6
10
|
*
|
|
7
11
|
* @param {string} name the name of the variable in local storage.
|
|
8
12
|
* @param {T} defaultValue the default value
|
|
13
|
+
* @param {"local" | "session"} storage the type of storage where to persist the state
|
|
9
14
|
*/
|
|
10
|
-
function usePersistedState(name, defaultValue) {
|
|
15
|
+
function usePersistedState(name, defaultValue, storage = "local") {
|
|
11
16
|
const [value, setValue] = (0, react_1.useState)(defaultValue);
|
|
12
17
|
const firstRender = (0, react_1.useRef)(true);
|
|
13
18
|
(0, react_1.useEffect)(() => {
|
|
14
19
|
try {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
if (storage === "local") {
|
|
21
|
+
const localValueString = window.localStorage.getItem(name);
|
|
22
|
+
if (localValueString) {
|
|
23
|
+
const localValue = JSON.parse(localValueString);
|
|
24
|
+
setValue(localValue);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const localValueString = window.sessionStorage.getItem(name);
|
|
29
|
+
if (localValueString) {
|
|
30
|
+
const localValue = JSON.parse(localValueString);
|
|
31
|
+
setValue(localValue);
|
|
32
|
+
}
|
|
19
33
|
}
|
|
20
34
|
}
|
|
21
35
|
catch (err) {
|
|
22
36
|
console.log(err);
|
|
23
|
-
|
|
37
|
+
if (storage === "local") {
|
|
38
|
+
window.localStorage.removeItem(name);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
window.sessionStorage.removeItem(name);
|
|
42
|
+
}
|
|
24
43
|
}
|
|
25
44
|
}, [name, setValue]);
|
|
26
45
|
(0, react_1.useEffect)(() => {
|
|
@@ -29,7 +48,12 @@ function usePersistedState(name, defaultValue) {
|
|
|
29
48
|
return;
|
|
30
49
|
}
|
|
31
50
|
try {
|
|
32
|
-
|
|
51
|
+
if (storage === "local") {
|
|
52
|
+
window.localStorage.setItem(name, JSON.stringify(value));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
window.sessionStorage.setItem(name, JSON.stringify(value));
|
|
56
|
+
}
|
|
33
57
|
}
|
|
34
58
|
catch (err) {
|
|
35
59
|
console.error(err);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PaletteOptions } from
|
|
2
|
-
export type AllowedTheme = NonNullable<PaletteOptions[
|
|
1
|
+
import { PaletteOptions } from "@mui/material/styles";
|
|
2
|
+
export type AllowedTheme = NonNullable<PaletteOptions["mode"]>;
|
|
3
3
|
export declare const DEFAULT_THEME: AllowedTheme;
|
|
4
4
|
export declare const defaultLightPalette: PaletteOptions;
|
|
5
5
|
export declare const defaultDarkPalette: PaletteOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/utils/theme/palette/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;AAE/D,eAAO,MAAM,aAAa,EAAE,YAAsB,CAAC;AAEnD,eAAO,MAAM,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/utils/theme/palette/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;AAE/D,eAAO,MAAM,aAAa,EAAE,YAAsB,CAAC;AAEnD,eAAO,MAAM,mBAAmB,EAAE,cA2CjC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,cAyChC,CAAC;AAEF,eAAO,MAAM,eAAe,SACpB,YAAY,iBACH,cAAc,gBACf,cAAc,KAC3B,cAQF,CAAC"}
|