@etsoo/toolpad 1.0.12 → 1.0.14

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.
Files changed (260) hide show
  1. package/babel.config.json +11 -0
  2. package/build/cjs/Account/Account.js +104 -0
  3. package/build/cjs/Account/Account.test.js +40 -0
  4. package/build/cjs/Account/AccountPopoverFooter.js +18 -0
  5. package/build/cjs/Account/AccountPopoverHeader.js +12 -0
  6. package/build/cjs/Account/AccountPreview.js +96 -0
  7. package/build/cjs/Account/AccountPreview.test.js +52 -0
  8. package/build/cjs/Account/SignInButton.js +56 -0
  9. package/build/cjs/Account/SignOutButton.js +58 -0
  10. package/build/cjs/Account/index.js +22 -0
  11. package/build/cjs/AppProvider/AppProvider.js +40 -0
  12. package/build/cjs/AppProvider/AppProvider.test.js +18 -0
  13. package/build/cjs/AppProvider/AppProviderComponent.js +33 -0
  14. package/build/cjs/AppProvider/AppThemeProvider.js +111 -0
  15. package/build/cjs/AppProvider/index.js +17 -0
  16. package/build/cjs/DashboardLayout/DashboardLayout.js +230 -0
  17. package/build/cjs/DashboardLayout/DashboardLayout.test.js +296 -0
  18. package/build/cjs/DashboardLayout/DashboardSidebarSubNavigation.js +185 -0
  19. package/build/cjs/DashboardLayout/ThemeSwitcher.js +84 -0
  20. package/build/cjs/DashboardLayout/TitleBar.d.ts +2 -0
  21. package/build/cjs/DashboardLayout/TitleBar.js +57 -0
  22. package/build/cjs/DashboardLayout/ToolbarActions.js +11 -0
  23. package/build/cjs/DashboardLayout/index.js +19 -0
  24. package/build/cjs/DashboardLayout/utils.js +20 -0
  25. package/build/{PageContainer → cjs/PageContainer}/PageContainer.d.ts +4 -0
  26. package/build/cjs/PageContainer/PageContainer.js +133 -0
  27. package/build/cjs/PageContainer/PageContainer.test.js +128 -0
  28. package/build/cjs/PageContainer/PageContainerToolbar.js +26 -0
  29. package/build/cjs/PageContainer/PageContainerToolbar.test.js +15 -0
  30. package/build/cjs/PageContainer/index.js +18 -0
  31. package/build/cjs/index.js +24 -0
  32. package/build/cjs/nextjs/AppProvider.js +18 -0
  33. package/build/cjs/nextjs/AppProvider.test.js +71 -0
  34. package/build/cjs/nextjs/AppProviderNextApp.js +63 -0
  35. package/build/cjs/nextjs/AppProviderNextPages.js +73 -0
  36. package/build/cjs/nextjs/index.js +17 -0
  37. package/build/cjs/persistence/codec.js +60 -0
  38. package/build/cjs/persistence/index.js +17 -0
  39. package/build/cjs/persistence/useStorageState.js +153 -0
  40. package/build/cjs/persistence/useStorageState.test.js +63 -0
  41. package/build/cjs/react-router-dom/AppProvider.js +64 -0
  42. package/build/cjs/react-router-dom/AppProvider.test.js +14 -0
  43. package/build/cjs/react-router-dom/index.js +17 -0
  44. package/build/cjs/shared/Link.js +55 -0
  45. package/build/cjs/shared/components.js +30 -0
  46. package/build/cjs/shared/context.js +46 -0
  47. package/build/cjs/shared/locales/LocaleContext.js +71 -0
  48. package/build/cjs/shared/navigation.js +151 -0
  49. package/build/cjs/useActivePage/index.js +17 -0
  50. package/build/cjs/useActivePage/useActivePage.js +83 -0
  51. package/build/cjs/useLocalStorageState/index.js +17 -0
  52. package/build/cjs/useLocalStorageState/useLocalStorageState.js +17 -0
  53. package/build/cjs/useSessionStorageState/index.js +17 -0
  54. package/build/cjs/useSessionStorageState/useSessionStorageState.js +17 -0
  55. package/build/cjs/utils/collections.js +53 -0
  56. package/build/cjs/utils/describeConformance.js +6 -0
  57. package/build/cjs/utils/events.js +58 -0
  58. package/build/cjs/utils/hooks/index.js +10 -0
  59. package/build/cjs/utils/hooks/useBoolean.js +47 -0
  60. package/build/cjs/utils/hooks/useDebounced.js +64 -0
  61. package/build/cjs/utils/hooks/useDebouncedHandler.js +77 -0
  62. package/build/cjs/utils/hooks/useLatest.js +44 -0
  63. package/build/cjs/utils/hooks/usePageTitle.js +49 -0
  64. package/build/cjs/utils/hooks/useSsr.js +52 -0
  65. package/build/cjs/utils/hooks/useStorageState.js +86 -0
  66. package/build/cjs/utils/warnOnce.js +14 -0
  67. package/build/mjs/Account/Account.d.ts +63 -0
  68. package/build/mjs/Account/Account.test.d.ts +1 -0
  69. package/build/mjs/Account/AccountPopoverFooter.d.ts +6 -0
  70. package/build/mjs/Account/AccountPopoverHeader.d.ts +6 -0
  71. package/build/mjs/Account/AccountPreview.d.ts +64 -0
  72. package/build/mjs/Account/AccountPreview.test.d.ts +1 -0
  73. package/build/mjs/Account/SignInButton.d.ts +2 -0
  74. package/build/mjs/Account/SignOutButton.d.ts +3 -0
  75. package/build/mjs/Account/index.js +6 -0
  76. package/build/mjs/AppProvider/AppProvider.d.ts +105 -0
  77. package/build/mjs/AppProvider/AppProvider.test.d.ts +4 -0
  78. package/build/mjs/AppProvider/AppProviderComponent.d.ts +14 -0
  79. package/build/mjs/AppProvider/AppThemeProvider.d.ts +12 -0
  80. package/build/mjs/DashboardLayout/DashboardLayout.d.ts +91 -0
  81. package/build/{DashboardLayout → mjs/DashboardLayout}/DashboardLayout.js +9 -10
  82. package/build/mjs/DashboardLayout/DashboardLayout.test.d.ts +1 -0
  83. package/build/mjs/DashboardLayout/DashboardSidebarSubNavigation.d.ts +16 -0
  84. package/build/mjs/DashboardLayout/ThemeSwitcher.d.ts +5 -0
  85. package/build/mjs/DashboardLayout/TitleBar.d.ts +2 -0
  86. package/build/mjs/DashboardLayout/ToolbarActions.d.ts +5 -0
  87. package/build/mjs/DashboardLayout/index.d.ts +2 -0
  88. package/build/mjs/DashboardLayout/utils.d.ts +8 -0
  89. package/build/mjs/PageContainer/PageContainer.d.ts +61 -0
  90. package/build/{PageContainer → mjs/PageContainer}/PageContainer.js +8 -4
  91. package/build/mjs/PageContainer/PageContainer.test.d.ts +1 -0
  92. package/build/mjs/PageContainer/PageContainerToolbar.d.ts +16 -0
  93. package/build/mjs/PageContainer/PageContainerToolbar.test.d.ts +1 -0
  94. package/build/mjs/PageContainer/index.js +2 -0
  95. package/build/mjs/index.js +8 -0
  96. package/build/mjs/nextjs/AppProvider.d.ts +6 -0
  97. package/build/mjs/nextjs/AppProvider.test.d.ts +1 -0
  98. package/build/mjs/nextjs/AppProviderNextApp.d.ts +5 -0
  99. package/build/mjs/nextjs/AppProviderNextPages.d.ts +5 -0
  100. package/build/mjs/nextjs/index.js +1 -0
  101. package/build/mjs/persistence/codec.d.ts +47 -0
  102. package/build/mjs/persistence/index.js +1 -0
  103. package/build/mjs/persistence/useStorageState.d.ts +50 -0
  104. package/build/mjs/persistence/useStorageState.test.d.ts +1 -0
  105. package/build/mjs/react-router-dom/AppProvider.d.ts +6 -0
  106. package/build/mjs/react-router-dom/AppProvider.test.d.ts +1 -0
  107. package/build/mjs/react-router-dom/index.d.ts +1 -0
  108. package/build/mjs/react-router-dom/index.js +1 -0
  109. package/build/mjs/shared/Link.d.ts +8 -0
  110. package/build/mjs/shared/components.d.ts +5 -0
  111. package/build/mjs/shared/context.d.ts +12 -0
  112. package/build/mjs/shared/locales/LocaleContext.d.ts +56 -0
  113. package/build/mjs/shared/navigation.d.ts +16 -0
  114. package/build/mjs/useActivePage/index.js +1 -0
  115. package/build/mjs/useActivePage/useActivePage.d.ts +8 -0
  116. package/build/mjs/useLocalStorageState/index.js +1 -0
  117. package/build/mjs/useLocalStorageState/useLocalStorageState.d.ts +2 -0
  118. package/build/mjs/useSessionStorageState/index.js +1 -0
  119. package/build/mjs/useSessionStorageState/useSessionStorageState.d.ts +2 -0
  120. package/build/mjs/utils/collections.d.ts +44 -0
  121. package/build/mjs/utils/describeConformance.d.ts +7 -0
  122. package/build/mjs/utils/events.d.ts +27 -0
  123. package/build/mjs/utils/hooks/index.js +2 -0
  124. package/build/mjs/utils/hooks/useBoolean.d.ts +11 -0
  125. package/build/mjs/utils/hooks/useDebounced.d.ts +8 -0
  126. package/build/mjs/utils/hooks/useDebouncedHandler.d.ts +12 -0
  127. package/build/mjs/utils/hooks/useLatest.d.ts +6 -0
  128. package/build/mjs/utils/hooks/usePageTitle.d.ts +4 -0
  129. package/build/mjs/utils/hooks/useSsr.d.ts +4 -0
  130. package/build/mjs/utils/hooks/useStorageState.d.ts +10 -0
  131. package/build/mjs/utils/warnOnce.d.ts +5 -0
  132. package/package.json +33 -23
  133. package/src/DashboardLayout/DashboardLayout.tsx +13 -12
  134. package/src/PageContainer/PageContainer.tsx +12 -4
  135. package/tsconfig.cjs.json +20 -0
  136. package/tsconfig.json +2 -2
  137. package/build/DashboardLayout/TitleBar.d.ts +0 -2
  138. /package/build/{Account → cjs/Account}/Account.d.ts +0 -0
  139. /package/build/{Account → cjs/Account}/Account.test.d.ts +0 -0
  140. /package/build/{Account → cjs/Account}/AccountPopoverFooter.d.ts +0 -0
  141. /package/build/{Account → cjs/Account}/AccountPopoverHeader.d.ts +0 -0
  142. /package/build/{Account → cjs/Account}/AccountPreview.d.ts +0 -0
  143. /package/build/{Account → cjs/Account}/AccountPreview.test.d.ts +0 -0
  144. /package/build/{Account → cjs/Account}/SignInButton.d.ts +0 -0
  145. /package/build/{Account → cjs/Account}/SignOutButton.d.ts +0 -0
  146. /package/build/{Account → cjs/Account}/index.d.ts +0 -0
  147. /package/build/{AppProvider → cjs/AppProvider}/AppProvider.d.ts +0 -0
  148. /package/build/{AppProvider → cjs/AppProvider}/AppProvider.test.d.ts +0 -0
  149. /package/build/{AppProvider → cjs/AppProvider}/AppProviderComponent.d.ts +0 -0
  150. /package/build/{AppProvider → cjs/AppProvider}/AppThemeProvider.d.ts +0 -0
  151. /package/build/{AppProvider → cjs/AppProvider}/index.d.ts +0 -0
  152. /package/build/{DashboardLayout → cjs/DashboardLayout}/DashboardLayout.d.ts +0 -0
  153. /package/build/{DashboardLayout → cjs/DashboardLayout}/DashboardLayout.test.d.ts +0 -0
  154. /package/build/{DashboardLayout → cjs/DashboardLayout}/DashboardSidebarSubNavigation.d.ts +0 -0
  155. /package/build/{DashboardLayout → cjs/DashboardLayout}/ThemeSwitcher.d.ts +0 -0
  156. /package/build/{DashboardLayout → cjs/DashboardLayout}/ToolbarActions.d.ts +0 -0
  157. /package/build/{DashboardLayout → cjs/DashboardLayout}/index.d.ts +0 -0
  158. /package/build/{DashboardLayout → cjs/DashboardLayout}/utils.d.ts +0 -0
  159. /package/build/{PageContainer → cjs/PageContainer}/PageContainer.test.d.ts +0 -0
  160. /package/build/{PageContainer → cjs/PageContainer}/PageContainerToolbar.d.ts +0 -0
  161. /package/build/{PageContainer → cjs/PageContainer}/PageContainerToolbar.test.d.ts +0 -0
  162. /package/build/{PageContainer → cjs/PageContainer}/index.d.ts +0 -0
  163. /package/build/{index.d.ts → cjs/index.d.ts} +0 -0
  164. /package/build/{nextjs → cjs/nextjs}/AppProvider.d.ts +0 -0
  165. /package/build/{nextjs → cjs/nextjs}/AppProvider.test.d.ts +0 -0
  166. /package/build/{nextjs → cjs/nextjs}/AppProviderNextApp.d.ts +0 -0
  167. /package/build/{nextjs → cjs/nextjs}/AppProviderNextPages.d.ts +0 -0
  168. /package/build/{nextjs → cjs/nextjs}/index.d.ts +0 -0
  169. /package/build/{persistence → cjs/persistence}/codec.d.ts +0 -0
  170. /package/build/{persistence → cjs/persistence}/index.d.ts +0 -0
  171. /package/build/{persistence → cjs/persistence}/useStorageState.d.ts +0 -0
  172. /package/build/{persistence → cjs/persistence}/useStorageState.test.d.ts +0 -0
  173. /package/build/{react-router-dom → cjs/react-router-dom}/AppProvider.d.ts +0 -0
  174. /package/build/{react-router-dom → cjs/react-router-dom}/AppProvider.test.d.ts +0 -0
  175. /package/build/{react-router-dom → cjs/react-router-dom}/index.d.ts +0 -0
  176. /package/build/{shared → cjs/shared}/Link.d.ts +0 -0
  177. /package/build/{shared → cjs/shared}/components.d.ts +0 -0
  178. /package/build/{shared → cjs/shared}/context.d.ts +0 -0
  179. /package/build/{shared → cjs/shared}/locales/LocaleContext.d.ts +0 -0
  180. /package/build/{shared → cjs/shared}/navigation.d.ts +0 -0
  181. /package/build/{useActivePage → cjs/useActivePage}/index.d.ts +0 -0
  182. /package/build/{useActivePage → cjs/useActivePage}/useActivePage.d.ts +0 -0
  183. /package/build/{useLocalStorageState → cjs/useLocalStorageState}/index.d.ts +0 -0
  184. /package/build/{useLocalStorageState → cjs/useLocalStorageState}/useLocalStorageState.d.ts +0 -0
  185. /package/build/{useSessionStorageState → cjs/useSessionStorageState}/index.d.ts +0 -0
  186. /package/build/{useSessionStorageState → cjs/useSessionStorageState}/useSessionStorageState.d.ts +0 -0
  187. /package/build/{utils → cjs/utils}/collections.d.ts +0 -0
  188. /package/build/{utils → cjs/utils}/describeConformance.d.ts +0 -0
  189. /package/build/{utils → cjs/utils}/events.d.ts +0 -0
  190. /package/build/{utils → cjs/utils}/hooks/index.d.ts +0 -0
  191. /package/build/{utils → cjs/utils}/hooks/useBoolean.d.ts +0 -0
  192. /package/build/{utils → cjs/utils}/hooks/useDebounced.d.ts +0 -0
  193. /package/build/{utils → cjs/utils}/hooks/useDebouncedHandler.d.ts +0 -0
  194. /package/build/{utils → cjs/utils}/hooks/useLatest.d.ts +0 -0
  195. /package/build/{utils → cjs/utils}/hooks/usePageTitle.d.ts +0 -0
  196. /package/build/{utils → cjs/utils}/hooks/useSsr.d.ts +0 -0
  197. /package/build/{utils → cjs/utils}/hooks/useStorageState.d.ts +0 -0
  198. /package/build/{utils → cjs/utils}/warnOnce.d.ts +0 -0
  199. /package/build/{Account → mjs/Account}/Account.js +0 -0
  200. /package/build/{Account → mjs/Account}/Account.test.js +0 -0
  201. /package/build/{Account → mjs/Account}/AccountPopoverFooter.js +0 -0
  202. /package/build/{Account → mjs/Account}/AccountPopoverHeader.js +0 -0
  203. /package/build/{Account → mjs/Account}/AccountPreview.js +0 -0
  204. /package/build/{Account → mjs/Account}/AccountPreview.test.js +0 -0
  205. /package/build/{Account → mjs/Account}/SignInButton.js +0 -0
  206. /package/build/{Account → mjs/Account}/SignOutButton.js +0 -0
  207. /package/build/{Account/index.js → mjs/Account/index.d.ts} +0 -0
  208. /package/build/{AppProvider → mjs/AppProvider}/AppProvider.js +0 -0
  209. /package/build/{AppProvider → mjs/AppProvider}/AppProvider.test.js +0 -0
  210. /package/build/{AppProvider → mjs/AppProvider}/AppProviderComponent.js +0 -0
  211. /package/build/{AppProvider → mjs/AppProvider}/AppThemeProvider.js +0 -0
  212. /package/build/{AppProvider/index.js → mjs/AppProvider/index.d.ts} +0 -0
  213. /package/build/{nextjs → mjs/AppProvider}/index.js +0 -0
  214. /package/build/{DashboardLayout → mjs/DashboardLayout}/DashboardLayout.test.js +0 -0
  215. /package/build/{DashboardLayout → mjs/DashboardLayout}/DashboardSidebarSubNavigation.js +0 -0
  216. /package/build/{DashboardLayout → mjs/DashboardLayout}/ThemeSwitcher.js +0 -0
  217. /package/build/{DashboardLayout → mjs/DashboardLayout}/TitleBar.js +0 -0
  218. /package/build/{DashboardLayout → mjs/DashboardLayout}/ToolbarActions.js +0 -0
  219. /package/build/{DashboardLayout → mjs/DashboardLayout}/index.js +0 -0
  220. /package/build/{DashboardLayout → mjs/DashboardLayout}/utils.js +0 -0
  221. /package/build/{PageContainer → mjs/PageContainer}/PageContainer.test.js +0 -0
  222. /package/build/{PageContainer → mjs/PageContainer}/PageContainerToolbar.js +0 -0
  223. /package/build/{PageContainer → mjs/PageContainer}/PageContainerToolbar.test.js +0 -0
  224. /package/build/{PageContainer/index.js → mjs/PageContainer/index.d.ts} +0 -0
  225. /package/build/{index.js → mjs/index.d.ts} +0 -0
  226. /package/build/{nextjs → mjs/nextjs}/AppProvider.js +0 -0
  227. /package/build/{nextjs → mjs/nextjs}/AppProvider.test.js +0 -0
  228. /package/build/{nextjs → mjs/nextjs}/AppProviderNextApp.js +0 -0
  229. /package/build/{nextjs → mjs/nextjs}/AppProviderNextPages.js +0 -0
  230. /package/build/{react-router-dom/index.js → mjs/nextjs/index.d.ts} +0 -0
  231. /package/build/{persistence → mjs/persistence}/codec.js +0 -0
  232. /package/build/{persistence/index.js → mjs/persistence/index.d.ts} +0 -0
  233. /package/build/{persistence → mjs/persistence}/useStorageState.js +0 -0
  234. /package/build/{persistence → mjs/persistence}/useStorageState.test.js +0 -0
  235. /package/build/{react-router-dom → mjs/react-router-dom}/AppProvider.js +0 -0
  236. /package/build/{react-router-dom → mjs/react-router-dom}/AppProvider.test.js +0 -0
  237. /package/build/{shared → mjs/shared}/Link.js +0 -0
  238. /package/build/{shared → mjs/shared}/components.js +0 -0
  239. /package/build/{shared → mjs/shared}/context.js +0 -0
  240. /package/build/{shared → mjs/shared}/locales/LocaleContext.js +0 -0
  241. /package/build/{shared → mjs/shared}/navigation.js +0 -0
  242. /package/build/{useActivePage/index.js → mjs/useActivePage/index.d.ts} +0 -0
  243. /package/build/{useActivePage → mjs/useActivePage}/useActivePage.js +0 -0
  244. /package/build/{useLocalStorageState/index.js → mjs/useLocalStorageState/index.d.ts} +0 -0
  245. /package/build/{useLocalStorageState → mjs/useLocalStorageState}/useLocalStorageState.js +0 -0
  246. /package/build/{useSessionStorageState/index.js → mjs/useSessionStorageState/index.d.ts} +0 -0
  247. /package/build/{useSessionStorageState → mjs/useSessionStorageState}/useSessionStorageState.js +0 -0
  248. /package/build/{utils → mjs/utils}/collections.js +0 -0
  249. /package/build/{utils → mjs/utils}/describeConformance.js +0 -0
  250. /package/build/{utils → mjs/utils}/events.js +0 -0
  251. /package/build/{utils/hooks/index.js → mjs/utils/hooks/index.d.ts} +0 -0
  252. /package/build/{utils → mjs/utils}/hooks/useBoolean.js +0 -0
  253. /package/build/{utils → mjs/utils}/hooks/useDebounced.js +0 -0
  254. /package/build/{utils → mjs/utils}/hooks/useDebouncedHandler.js +0 -0
  255. /package/build/{utils → mjs/utils}/hooks/useLatest.js +0 -0
  256. /package/build/{utils → mjs/utils}/hooks/usePageTitle.js +0 -0
  257. /package/build/{utils → mjs/utils}/hooks/useSsr.js +0 -0
  258. /package/build/{utils → mjs/utils}/hooks/useStorageState.js +0 -0
  259. /package/build/{utils → mjs/utils}/warnOnce.js +0 -0
  260. /package/{vite.config.ts → vite.config.mts} +0 -0
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.AppThemeProvider = AppThemeProvider;
40
+ const jsx_runtime_1 = require("react/jsx-runtime");
41
+ const React = __importStar(require("react"));
42
+ const material_1 = require("@mui/material");
43
+ const styles_1 = require("@mui/material/styles");
44
+ const InitColorSchemeScript_1 = __importDefault(require("@mui/material/InitColorSchemeScript"));
45
+ const CssBaseline_1 = __importDefault(require("@mui/material/CssBaseline"));
46
+ const invariant_1 = __importDefault(require("invariant"));
47
+ const useLocalStorageState_1 = require("../useLocalStorageState");
48
+ const context_1 = require("../shared/context");
49
+ const COLOR_SCHEME_ATTRIBUTE = "data-toolpad-color-scheme";
50
+ const COLOR_SCHEME_STORAGE_KEY = "toolpad-color-scheme";
51
+ const MODE_STORAGE_KEY = "toolpad-mode";
52
+ function usePreferredMode(window) {
53
+ const prefersDarkMode = (0, material_1.useMediaQuery)("(prefers-color-scheme: dark)", window && {
54
+ matchMedia: window.matchMedia
55
+ });
56
+ return prefersDarkMode ? "dark" : "light";
57
+ }
58
+ function isCssVarsTheme(theme) {
59
+ return "vars" in theme;
60
+ }
61
+ /**
62
+ * Compatibility layer for classic v5 themes. It will handle state management for the theme switcher.
63
+ * In the v6 theme, this state management is handled by `useColorScheme`. But this hook will crash if
64
+ * not run under context with a css vars theme.
65
+ */
66
+ function LegacyThemeProvider(props) {
67
+ const { children, theme, window: appWindow } = props;
68
+ (0, invariant_1.default)(!isCssVarsTheme(theme), "This provider only accepts legacy themes.");
69
+ const isDualTheme = "light" in theme || "dark" in theme;
70
+ const preferredMode = usePreferredMode(appWindow);
71
+ const [userMode, setUserMode] = (0, useLocalStorageState_1.useLocalStorageState)(MODE_STORAGE_KEY, "system");
72
+ const paletteMode = !userMode || userMode === "system" ? preferredMode : userMode;
73
+ const dualAwareTheme = React.useMemo(() => isDualTheme
74
+ ? theme[paletteMode === "dark" ? "dark" : "light"] ??
75
+ theme[paletteMode === "dark" ? "light" : "dark"]
76
+ : theme, [isDualTheme, paletteMode, theme]);
77
+ // The v5 shim, based on local state
78
+ const paletteModeContextValue = React.useMemo(() => ({
79
+ paletteMode,
80
+ setPaletteMode: setUserMode,
81
+ isDualTheme
82
+ }), [isDualTheme, paletteMode, setUserMode]);
83
+ return ((0, jsx_runtime_1.jsx)(styles_1.ThemeProvider, { theme: dualAwareTheme, children: (0, jsx_runtime_1.jsxs)(context_1.PaletteModeContext.Provider, { value: paletteModeContextValue, children: [(0, jsx_runtime_1.jsx)(CssBaseline_1.default, { enableColorScheme: true }), children] }) }));
84
+ }
85
+ function CssVarsPaletteModeProvider(props) {
86
+ const { children, window: appWindow } = props;
87
+ const preferredMode = usePreferredMode(appWindow);
88
+ const { mode, setMode, allColorSchemes } = (0, styles_1.useColorScheme)();
89
+ // The v6 API, based on `useColorScheme`
90
+ const paletteModeContextValue = React.useMemo(() => {
91
+ return {
92
+ paletteMode: !mode || mode === "system" ? preferredMode : mode,
93
+ setPaletteMode: setMode,
94
+ isDualTheme: allColorSchemes.length > 1
95
+ };
96
+ }, [allColorSchemes, mode, preferredMode, setMode]);
97
+ return ((0, jsx_runtime_1.jsx)(context_1.PaletteModeContext.Provider, { value: paletteModeContextValue, children: children }));
98
+ }
99
+ function CssVarsThemeProvider(props) {
100
+ const { children, theme, window: appWindow } = props;
101
+ (0, invariant_1.default)(isCssVarsTheme(theme), "This provider only accepts CSS vars themes.");
102
+ return ((0, jsx_runtime_1.jsxs)(styles_1.ThemeProvider, { theme: theme, documentNode: appWindow?.document, colorSchemeNode: appWindow?.document.documentElement, disableNestedContext: true, colorSchemeStorageKey: COLOR_SCHEME_STORAGE_KEY, modeStorageKey: MODE_STORAGE_KEY, children: [(0, jsx_runtime_1.jsx)(InitColorSchemeScript_1.default, { attribute: COLOR_SCHEME_ATTRIBUTE, colorSchemeStorageKey: COLOR_SCHEME_STORAGE_KEY, modeStorageKey: MODE_STORAGE_KEY }), (0, jsx_runtime_1.jsxs)(CssVarsPaletteModeProvider, { window: appWindow, children: [(0, jsx_runtime_1.jsx)(CssBaseline_1.default, { enableColorScheme: true }), children] })] }));
103
+ }
104
+ /**
105
+ * @ignore - internal component.
106
+ */
107
+ function AppThemeProvider(props) {
108
+ const { children, theme, ...rest } = props;
109
+ const useCssVarsProvider = isCssVarsTheme(theme);
110
+ return useCssVarsProvider ? ((0, jsx_runtime_1.jsx)(CssVarsThemeProvider, { theme: theme, ...rest, children: children })) : ((0, jsx_runtime_1.jsx)(LegacyThemeProvider, { theme: theme, ...rest, children: children }));
111
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AppProvider"), exports);
@@ -0,0 +1,230 @@
1
+ "use client";
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.DashboardLayout = DashboardLayout;
41
+ const jsx_runtime_1 = require("react/jsx-runtime");
42
+ const React = __importStar(require("react"));
43
+ const material_1 = require("@mui/material");
44
+ const AppBar_1 = __importDefault(require("@mui/material/AppBar"));
45
+ const Box_1 = __importDefault(require("@mui/material/Box"));
46
+ const Drawer_1 = __importDefault(require("@mui/material/Drawer"));
47
+ const IconButton_1 = __importDefault(require("@mui/material/IconButton"));
48
+ const Stack_1 = __importDefault(require("@mui/material/Stack"));
49
+ const Toolbar_1 = __importDefault(require("@mui/material/Toolbar"));
50
+ const Tooltip_1 = __importDefault(require("@mui/material/Tooltip"));
51
+ const useMediaQuery_1 = __importDefault(require("@mui/material/useMediaQuery"));
52
+ const Menu_1 = __importDefault(require("@mui/icons-material/Menu"));
53
+ const MenuOpen_1 = __importDefault(require("@mui/icons-material/MenuOpen"));
54
+ const context_1 = require("../shared/context");
55
+ const Account_1 = require("../Account");
56
+ const DashboardSidebarSubNavigation_1 = require("./DashboardSidebarSubNavigation");
57
+ const ToolbarActions_1 = require("./ToolbarActions");
58
+ const ThemeSwitcher_1 = require("./ThemeSwitcher");
59
+ const utils_1 = require("./utils");
60
+ const TitleBar_1 = require("./TitleBar");
61
+ const LocaleContext_1 = require("../shared/locales/LocaleContext");
62
+ /**
63
+ *
64
+ * Demos:
65
+ *
66
+ * - [Dashboard Layout](https://mui.com/toolpad/core/react-dashboard-layout/)
67
+ *
68
+ * API:
69
+ *
70
+ * - [DashboardLayout API](https://mui.com/toolpad/core/api/dashboard-layout)
71
+ */
72
+ function DashboardLayout(props) {
73
+ const { children, disableCollapsibleSidebar = false, defaultSidebarCollapsed = false, hideNavigation = false, showThemeSwitcher = false, sidebarExpandedWidth = 320, slots, slotProps, sx } = props;
74
+ const theme = (0, material_1.useTheme)();
75
+ const navigation = React.useContext(context_1.NavigationContext);
76
+ const appWindow = React.useContext(context_1.WindowContext);
77
+ const localeText = (0, LocaleContext_1.useLocaleText)();
78
+ const [isDesktopNavigationExpanded, setIsDesktopNavigationExpanded] = React.useState(!defaultSidebarCollapsed);
79
+ const [isMobileNavigationExpanded, setIsMobileNavigationExpanded] = React.useState(false);
80
+ const isUnderMdViewport = (0, useMediaQuery_1.default)(theme.breakpoints.down("md"), appWindow && {
81
+ matchMedia: appWindow.matchMedia
82
+ });
83
+ const isOverSmViewport = (0, useMediaQuery_1.default)(theme.breakpoints.up("sm"), appWindow && {
84
+ matchMedia: appWindow.matchMedia
85
+ });
86
+ const isNavigationExpanded = isUnderMdViewport
87
+ ? isMobileNavigationExpanded
88
+ : isDesktopNavigationExpanded;
89
+ const setIsNavigationExpanded = React.useCallback((newExpanded) => {
90
+ if (isUnderMdViewport) {
91
+ setIsMobileNavigationExpanded(newExpanded);
92
+ }
93
+ else {
94
+ setIsDesktopNavigationExpanded(newExpanded);
95
+ }
96
+ }, [isUnderMdViewport]);
97
+ const [isNavigationFullyExpanded, setIsNavigationFullyExpanded] = React.useState(isNavigationExpanded);
98
+ React.useEffect(() => {
99
+ if (isNavigationExpanded) {
100
+ const drawerWidthTransitionTimeout = setTimeout(() => {
101
+ setIsNavigationFullyExpanded(true);
102
+ }, theme.transitions.duration.enteringScreen);
103
+ return () => clearTimeout(drawerWidthTransitionTimeout);
104
+ }
105
+ setIsNavigationFullyExpanded(false);
106
+ return () => { };
107
+ }, [isNavigationExpanded, theme]);
108
+ const selectedItemIdRef = React.useRef("");
109
+ const handleSetNavigationExpanded = React.useCallback((newExpanded) => () => {
110
+ setIsNavigationExpanded(newExpanded);
111
+ }, [setIsNavigationExpanded]);
112
+ const toggleNavigationExpanded = React.useCallback(() => {
113
+ setIsNavigationExpanded(!isNavigationExpanded);
114
+ }, [isNavigationExpanded, setIsNavigationExpanded]);
115
+ const handleNavigationLinkClick = React.useCallback(() => {
116
+ selectedItemIdRef.current = "";
117
+ setIsMobileNavigationExpanded(false);
118
+ }, [setIsMobileNavigationExpanded]);
119
+ // If useEffect was used, the reset would also happen on the client render after SSR which we don't need
120
+ React.useMemo(() => {
121
+ if (navigation) {
122
+ selectedItemIdRef.current = "";
123
+ }
124
+ }, [navigation]);
125
+ const isDesktopMini = !disableCollapsibleSidebar && !isDesktopNavigationExpanded;
126
+ const isMobileMini = !disableCollapsibleSidebar && !isMobileNavigationExpanded;
127
+ const getMenuIcon = React.useCallback((isExpanded) => {
128
+ return ((0, jsx_runtime_1.jsx)(Tooltip_1.default, { title: isExpanded
129
+ ? localeText.collapseMenuTitle
130
+ : localeText.expandMenuTitle, enterDelay: 1000, children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(IconButton_1.default, { "aria-label": isExpanded
131
+ ? localeText.collapseNavMenuAriaLabel
132
+ : localeText.expandNavMenuAriaLabel, onClick: toggleNavigationExpanded, children: isExpanded ? (0, jsx_runtime_1.jsx)(MenuOpen_1.default, {}) : (0, jsx_runtime_1.jsx)(Menu_1.default, {}) }) }) }));
133
+ }, [toggleNavigationExpanded]);
134
+ const hasDrawerTransitions = isOverSmViewport && (disableCollapsibleSidebar || !isUnderMdViewport);
135
+ const TitlebarSlot = slots?.titlebar ?? TitleBar_1.TitleBar;
136
+ const ToolbarActionsSlot = slots?.toolbarActions ?? ToolbarActions_1.ToolbarActions;
137
+ const ToolbarAccountSlot = slots?.toolbarAccount ?? Account_1.Account;
138
+ const SidebarFooterSlot = slots?.sidebarFooter ?? null;
139
+ const getDrawerContent = React.useCallback((isMini, viewport) => ((0, jsx_runtime_1.jsxs)(React.Fragment, { children: [(0, jsx_runtime_1.jsx)(Toolbar_1.default, {}), (0, jsx_runtime_1.jsxs)(Box_1.default, { component: "nav", "aria-label": `${viewport.charAt(0).toUpperCase()}${viewport.slice(1)}`, sx: {
140
+ height: "100%",
141
+ display: "flex",
142
+ flexDirection: "column",
143
+ justifyContent: "space-between",
144
+ overflow: "auto",
145
+ pt: navigation[0]?.kind === "header" && !isMini ? 0 : 2,
146
+ ...(hasDrawerTransitions
147
+ ? (0, utils_1.getDrawerSxTransitionMixin)(isNavigationFullyExpanded, "padding")
148
+ : {})
149
+ }, children: [(0, jsx_runtime_1.jsx)(DashboardSidebarSubNavigation_1.DashboardSidebarSubNavigation, { subNavigation: navigation, onLinkClick: handleNavigationLinkClick, isMini: isMini, isFullyExpanded: isNavigationFullyExpanded, hasDrawerTransitions: hasDrawerTransitions, selectedItemId: selectedItemIdRef.current }), SidebarFooterSlot ? ((0, jsx_runtime_1.jsx)(SidebarFooterSlot, { mini: isMini, ...slotProps?.sidebarFooter })) : null] })] })), [
150
+ SidebarFooterSlot,
151
+ handleNavigationLinkClick,
152
+ hasDrawerTransitions,
153
+ isNavigationFullyExpanded,
154
+ navigation,
155
+ slotProps?.sidebarFooter
156
+ ]);
157
+ const getDrawerSharedSx = React.useCallback((isMini, isTemporary) => {
158
+ const drawerWidth = isMini ? 64 : sidebarExpandedWidth;
159
+ return {
160
+ width: drawerWidth,
161
+ flexShrink: 0,
162
+ ...(0, utils_1.getDrawerWidthTransitionMixin)(isNavigationExpanded),
163
+ ...(isTemporary ? { position: "absolute" } : {}),
164
+ [`& .MuiDrawer-paper`]: {
165
+ position: "absolute",
166
+ width: drawerWidth,
167
+ boxSizing: "border-box",
168
+ backgroundImage: "none",
169
+ ...(0, utils_1.getDrawerWidthTransitionMixin)(isNavigationExpanded)
170
+ }
171
+ };
172
+ }, [isNavigationExpanded, sidebarExpandedWidth]);
173
+ const layoutRef = React.useRef(null);
174
+ return ((0, jsx_runtime_1.jsxs)(Box_1.default, { ref: layoutRef, sx: {
175
+ position: "relative",
176
+ display: "flex",
177
+ overflow: "hidden",
178
+ height: "100vh",
179
+ width: "100vw",
180
+ ...sx
181
+ }, children: [(0, jsx_runtime_1.jsx)(AppBar_1.default, { color: "inherit", position: "absolute", sx: (theme) => ({
182
+ borderWidth: 0,
183
+ borderBottomWidth: 1,
184
+ borderStyle: "solid",
185
+ borderColor: theme.palette.divider,
186
+ boxShadow: "none",
187
+ zIndex: theme.zIndex.drawer + 1
188
+ }), children: (0, jsx_runtime_1.jsxs)(Toolbar_1.default, { sx: { backgroundColor: "inherit", mx: { xs: -0.75, sm: -1.5 } }, children: [!hideNavigation ? ((0, jsx_runtime_1.jsxs)(React.Fragment, { children: [(0, jsx_runtime_1.jsx)(Box_1.default, { sx: {
189
+ mr: { sm: disableCollapsibleSidebar ? 0 : 1 },
190
+ display: { md: "none" }
191
+ }, children: getMenuIcon(isMobileNavigationExpanded) }), (0, jsx_runtime_1.jsx)(Box_1.default, { sx: {
192
+ display: {
193
+ xs: "none",
194
+ md: disableCollapsibleSidebar ? "none" : "block"
195
+ },
196
+ mr: disableCollapsibleSidebar ? 0 : 1
197
+ }, children: getMenuIcon(isDesktopNavigationExpanded) })] })) : null, (0, jsx_runtime_1.jsx)(Box_1.default, { sx: {
198
+ position: { xs: "absolute", md: "static" },
199
+ left: { xs: "50%", md: "auto" },
200
+ transform: { xs: "translateX(-50%)", md: "none" }
201
+ }, children: (0, jsx_runtime_1.jsx)(TitlebarSlot, { ...slotProps?.titlebar }) }), (0, jsx_runtime_1.jsx)(Box_1.default, { sx: { flexGrow: 1 } }), (0, jsx_runtime_1.jsxs)(Stack_1.default, { direction: "row", spacing: 1, children: [(0, jsx_runtime_1.jsx)(ToolbarActionsSlot, { ...slotProps?.toolbarActions }), showThemeSwitcher && (0, jsx_runtime_1.jsx)(ThemeSwitcher_1.ThemeSwitcher, {}), (0, jsx_runtime_1.jsx)(ToolbarAccountSlot, { ...slotProps?.toolbarAccount })] })] }) }), !hideNavigation ? ((0, jsx_runtime_1.jsxs)(React.Fragment, { children: [(0, jsx_runtime_1.jsx)(Drawer_1.default, { container: layoutRef.current, variant: "temporary", open: isMobileNavigationExpanded, onClose: handleSetNavigationExpanded(false), ModalProps: {
202
+ keepMounted: true // Better open performance on mobile.
203
+ }, sx: {
204
+ display: {
205
+ xs: "block",
206
+ sm: disableCollapsibleSidebar ? "block" : "none",
207
+ md: "none"
208
+ },
209
+ ...getDrawerSharedSx(false, true)
210
+ }, children: getDrawerContent(false, "phone") }), (0, jsx_runtime_1.jsx)(Drawer_1.default, { variant: "permanent", sx: {
211
+ display: {
212
+ xs: "none",
213
+ sm: disableCollapsibleSidebar ? "none" : "block",
214
+ md: "none"
215
+ },
216
+ ...getDrawerSharedSx(isMobileMini, false)
217
+ }, children: getDrawerContent(isMobileMini, "tablet") }), (0, jsx_runtime_1.jsx)(Drawer_1.default, { variant: "permanent", sx: {
218
+ display: { xs: "none", md: "block" },
219
+ ...getDrawerSharedSx(isDesktopMini, false)
220
+ }, children: getDrawerContent(isDesktopMini, "desktop") })] })) : null, (0, jsx_runtime_1.jsxs)(Box_1.default, { sx: {
221
+ display: "flex",
222
+ flexDirection: "column",
223
+ flex: 1
224
+ }, children: [(0, jsx_runtime_1.jsx)(Toolbar_1.default, {}), (0, jsx_runtime_1.jsx)(Box_1.default, { component: "main", sx: {
225
+ display: "flex",
226
+ flexDirection: "column",
227
+ flex: 1,
228
+ overflow: "auto"
229
+ }, children: children })] })] }));
230
+ }
@@ -0,0 +1,296 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const vitest_1 = require("vitest");
8
+ const react_1 = require("@testing-library/react");
9
+ const Dashboard_1 = __importDefault(require("@mui/icons-material/Dashboard"));
10
+ const ShoppingCart_1 = __importDefault(require("@mui/icons-material/ShoppingCart"));
11
+ const BarChart_1 = __importDefault(require("@mui/icons-material/BarChart"));
12
+ const Description_1 = __importDefault(require("@mui/icons-material/Description"));
13
+ const Layers_1 = __importDefault(require("@mui/icons-material/Layers"));
14
+ const user_event_1 = __importDefault(require("@testing-library/user-event"));
15
+ require("@testing-library/jest-dom/vitest");
16
+ const DashboardLayout_1 = require("./DashboardLayout");
17
+ const AppProviderComponent_1 = require("../AppProvider/AppProviderComponent");
18
+ (0, vitest_1.describe)("DashboardLayout", () => {
19
+ (0, vitest_1.test)("renders content correctly", async () => {
20
+ (0, react_1.render)((0, jsx_runtime_1.jsx)(DashboardLayout_1.DashboardLayout, { children: "Hello world" }));
21
+ (0, vitest_1.expect)(react_1.screen.getByText("Hello world")).toBeTruthy();
22
+ });
23
+ (0, vitest_1.test)("renders branding correctly in header", async () => {
24
+ const BRANDING = {
25
+ title: "My Company",
26
+ logo: (0, jsx_runtime_1.jsx)("img", { src: "https://placehold.co/600x400", alt: "Placeholder Logo" })
27
+ };
28
+ (0, react_1.render)((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { branding: BRANDING, children: (0, jsx_runtime_1.jsx)(DashboardLayout_1.DashboardLayout, { children: "Hello world" }) }));
29
+ const header = react_1.screen.getByRole("banner");
30
+ (0, vitest_1.expect)((0, react_1.within)(header).getByText("My Company")).toBeTruthy();
31
+ (0, vitest_1.expect)((0, react_1.within)(header).getByAltText("Placeholder Logo")).toBeTruthy();
32
+ });
33
+ (0, vitest_1.test)("can switch theme", async () => {
34
+ const user = user_event_1.default.setup();
35
+ (0, react_1.render)((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { children: (0, jsx_runtime_1.jsx)(DashboardLayout_1.DashboardLayout, { showThemeSwitcher: true, children: "Hello world" }) }));
36
+ const getBackgroundColorCSSVariable = () => getComputedStyle(document.documentElement).getPropertyValue("--mui-palette-common-background");
37
+ const header = react_1.screen.getByRole("banner");
38
+ const themeSwitcherButton = (0, react_1.within)(header).getByLabelText("Switch to dark mode");
39
+ (0, vitest_1.expect)(getBackgroundColorCSSVariable()).toBe("#fff");
40
+ await user.click(themeSwitcherButton);
41
+ (0, vitest_1.expect)(getBackgroundColorCSSVariable()).toBe("#000");
42
+ await user.click(themeSwitcherButton);
43
+ (0, vitest_1.expect)(getBackgroundColorCSSVariable()).toBe("#fff");
44
+ });
45
+ (0, vitest_1.test)("navigation works correctly", async () => {
46
+ const NAVIGATION = [
47
+ {
48
+ kind: "header",
49
+ title: "Main items"
50
+ },
51
+ {
52
+ title: "Dashboard",
53
+ segment: "dashboard",
54
+ icon: (0, jsx_runtime_1.jsx)(Dashboard_1.default, {})
55
+ },
56
+ {
57
+ title: "Orders",
58
+ segment: "orders",
59
+ icon: (0, jsx_runtime_1.jsx)(ShoppingCart_1.default, {})
60
+ },
61
+ {
62
+ kind: "divider"
63
+ },
64
+ {
65
+ kind: "header",
66
+ title: "Analytics"
67
+ },
68
+ {
69
+ segment: "reports",
70
+ title: "Reports",
71
+ icon: (0, jsx_runtime_1.jsx)(BarChart_1.default, {}),
72
+ children: [
73
+ {
74
+ segment: "sales",
75
+ title: "Sales",
76
+ icon: (0, jsx_runtime_1.jsx)(Description_1.default, {})
77
+ },
78
+ {
79
+ segment: "traffic",
80
+ title: "Traffic",
81
+ icon: (0, jsx_runtime_1.jsx)(Description_1.default, {})
82
+ }
83
+ ]
84
+ },
85
+ {
86
+ segment: "integrations",
87
+ title: "Integrations",
88
+ icon: (0, jsx_runtime_1.jsx)(Layers_1.default, {})
89
+ }
90
+ ];
91
+ const user = user_event_1.default.setup();
92
+ (0, react_1.render)((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { navigation: NAVIGATION, children: (0, jsx_runtime_1.jsx)(DashboardLayout_1.DashboardLayout, { children: "Hello world" }) }));
93
+ const desktopNavigation = react_1.screen.getByRole("navigation", {
94
+ name: "Desktop"
95
+ });
96
+ // List subheaders are present
97
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByText("Main items")).toBeTruthy();
98
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByText("Analytics")).toBeTruthy();
99
+ // List items and their links are present
100
+ const dashboardLink = (0, react_1.within)(desktopNavigation).getByRole("link", {
101
+ name: "Dashboard"
102
+ });
103
+ const ordersLink = (0, react_1.within)(desktopNavigation).getByRole("link", {
104
+ name: "Orders"
105
+ });
106
+ (0, vitest_1.expect)(dashboardLink.getAttribute("href")).toBe("/dashboard");
107
+ (0, vitest_1.expect)(ordersLink.getAttribute("href")).toBe("/orders");
108
+ const reportsItem = (0, react_1.within)(desktopNavigation).getByText("Reports");
109
+ (0, vitest_1.expect)(reportsItem).toBeTruthy();
110
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByText("Integrations")).toBeTruthy();
111
+ // Nested list items show when parent item is clicked
112
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).queryByText("Sales")).toBeNull();
113
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).queryByText("Traffic")).toBeNull();
114
+ await user.click(reportsItem);
115
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByText("Sales")).toBeTruthy();
116
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByText("Traffic")).toBeTruthy();
117
+ });
118
+ (0, vitest_1.test)("starts with parent items expanded if any of their children is the current page", () => {
119
+ const NAVIGATION = [
120
+ {
121
+ segment: "reports",
122
+ title: "Reports",
123
+ icon: (0, jsx_runtime_1.jsx)(BarChart_1.default, {}),
124
+ children: [
125
+ {
126
+ segment: "sales",
127
+ title: "Sales",
128
+ icon: (0, jsx_runtime_1.jsx)(Description_1.default, {})
129
+ },
130
+ {
131
+ segment: "traffic",
132
+ title: "Traffic",
133
+ icon: (0, jsx_runtime_1.jsx)(Description_1.default, {})
134
+ }
135
+ ]
136
+ }
137
+ ];
138
+ const mockRouter = {
139
+ pathname: "/reports/sales",
140
+ searchParams: new URLSearchParams(),
141
+ navigate: vitest_1.vi.fn()
142
+ };
143
+ (0, react_1.render)((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { navigation: NAVIGATION, router: mockRouter, children: (0, jsx_runtime_1.jsx)(DashboardLayout_1.DashboardLayout, { children: "Hello world" }) }));
144
+ const desktopNavigation = react_1.screen.getByRole("navigation", {
145
+ name: "Desktop"
146
+ });
147
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByText("Sales")).toBeTruthy();
148
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByText("Traffic")).toBeTruthy();
149
+ });
150
+ (0, vitest_1.test)("shows correct selected page item", () => {
151
+ const NAVIGATION = [
152
+ {
153
+ title: "Dashboard",
154
+ segment: "dashboard",
155
+ icon: (0, jsx_runtime_1.jsx)(Dashboard_1.default, {})
156
+ },
157
+ {
158
+ title: "Orders",
159
+ segment: "orders",
160
+ icon: (0, jsx_runtime_1.jsx)(ShoppingCart_1.default, {})
161
+ },
162
+ {
163
+ segment: "dynamic",
164
+ title: "Dynamic",
165
+ icon: (0, jsx_runtime_1.jsx)(BarChart_1.default, {}),
166
+ pattern: "dynamic/:dynamicId"
167
+ },
168
+ {
169
+ segment: "optional",
170
+ title: "Optional",
171
+ pattern: "optional{/:optionalId}?"
172
+ },
173
+ {
174
+ segment: "oneOrMore",
175
+ title: "One or more",
176
+ pattern: "oneormore{/:oneormoreId}+"
177
+ },
178
+ {
179
+ segment: "zeroOrMore",
180
+ title: "Zero or more",
181
+ pattern: "zeroormore{/:zeroormoreId}*"
182
+ }
183
+ ];
184
+ function AppWithPathname({ pathname }) {
185
+ const mockRouter = {
186
+ pathname,
187
+ searchParams: new URLSearchParams(),
188
+ navigate: vitest_1.vi.fn()
189
+ };
190
+ return ((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { navigation: NAVIGATION, router: mockRouter, children: (0, jsx_runtime_1.jsx)(DashboardLayout_1.DashboardLayout, { children: "Hello world" }) }));
191
+ }
192
+ const { rerender } = (0, react_1.render)((0, jsx_runtime_1.jsx)(AppWithPathname, { pathname: "/dashboard" }));
193
+ const desktopNavigation = react_1.screen.getByRole("navigation", {
194
+ name: "Desktop"
195
+ });
196
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByRole("link", { name: "Dashboard" })).toHaveClass("Mui-selected");
197
+ rerender((0, jsx_runtime_1.jsx)(AppWithPathname, { pathname: "/orders" }));
198
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByRole("link", { name: "Dashboard" })).not.toHaveClass("Mui-selected");
199
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByRole("link", { name: "Orders" })).toHaveClass("Mui-selected");
200
+ rerender((0, jsx_runtime_1.jsx)(AppWithPathname, { pathname: "/dynamic" }));
201
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByRole("link", { name: "Dynamic" })).not.toHaveClass("Mui-selected");
202
+ rerender((0, jsx_runtime_1.jsx)(AppWithPathname, { pathname: "/dynamic/123" }));
203
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByRole("link", { name: "Dynamic" })).toHaveClass("Mui-selected");
204
+ rerender((0, jsx_runtime_1.jsx)(AppWithPathname, { pathname: "/dynamic/123/456" }));
205
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByRole("link", { name: "Dynamic" })).not.toHaveClass("Mui-selected");
206
+ rerender((0, jsx_runtime_1.jsx)(AppWithPathname, { pathname: "/optional" }));
207
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByRole("link", { name: "Optional" })).toHaveClass("Mui-selected");
208
+ rerender((0, jsx_runtime_1.jsx)(AppWithPathname, { pathname: "/optional/123" }));
209
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByRole("link", { name: "Optional" })).toHaveClass("Mui-selected");
210
+ rerender((0, jsx_runtime_1.jsx)(AppWithPathname, { pathname: "/optional/123/456" }));
211
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByRole("link", { name: "Optional" })).not.toHaveClass("Mui-selected");
212
+ rerender((0, jsx_runtime_1.jsx)(AppWithPathname, { pathname: "/oneormore" }));
213
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByRole("link", { name: "One or more" })).not.toHaveClass("Mui-selected");
214
+ rerender((0, jsx_runtime_1.jsx)(AppWithPathname, { pathname: "/oneormore/123" }));
215
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByRole("link", { name: "One or more" })).toHaveClass("Mui-selected");
216
+ rerender((0, jsx_runtime_1.jsx)(AppWithPathname, { pathname: "/oneormore/123/456" }));
217
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByRole("link", { name: "One or more" })).toHaveClass("Mui-selected");
218
+ rerender((0, jsx_runtime_1.jsx)(AppWithPathname, { pathname: "/zeroormore" }));
219
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByRole("link", { name: "Zero or more" })).toHaveClass("Mui-selected");
220
+ rerender((0, jsx_runtime_1.jsx)(AppWithPathname, { pathname: "/zeroormore/123" }));
221
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByRole("link", { name: "Zero or more" })).toHaveClass("Mui-selected");
222
+ rerender((0, jsx_runtime_1.jsx)(AppWithPathname, { pathname: "/zeroormore/123/456" }));
223
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByRole("link", { name: "Zero or more" })).toHaveClass("Mui-selected");
224
+ });
225
+ (0, vitest_1.test)("renders navigation actions", async () => {
226
+ const NAVIGATION = [
227
+ {
228
+ title: "Item 1",
229
+ segment: "item1",
230
+ icon: (0, jsx_runtime_1.jsx)(Description_1.default, {}),
231
+ action: (0, jsx_runtime_1.jsx)("div", { children: "Action 1" })
232
+ },
233
+ {
234
+ title: "Item",
235
+ segment: "item2",
236
+ icon: (0, jsx_runtime_1.jsx)(Description_1.default, {}),
237
+ action: (0, jsx_runtime_1.jsx)("div", { children: "Action 2" })
238
+ }
239
+ ];
240
+ (0, react_1.render)((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { navigation: NAVIGATION, children: (0, jsx_runtime_1.jsx)(DashboardLayout_1.DashboardLayout, { children: "Hello world" }) }));
241
+ const desktopNavigation = react_1.screen.getByRole("navigation", {
242
+ name: "Desktop"
243
+ });
244
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByText("Action 1")).toBeTruthy();
245
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByText("Action 2")).toBeTruthy();
246
+ });
247
+ (0, vitest_1.test)("renders sidebar footer slot content", async () => {
248
+ function SidebarFooter() {
249
+ return (0, jsx_runtime_1.jsx)("div", { children: "I am footer" });
250
+ }
251
+ (0, react_1.render)((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { children: (0, jsx_runtime_1.jsx)(DashboardLayout_1.DashboardLayout, { slots: { sidebarFooter: SidebarFooter }, children: "Hello world" }) }));
252
+ const desktopNavigation = react_1.screen.getByRole("navigation", {
253
+ name: "Desktop"
254
+ });
255
+ (0, vitest_1.expect)((0, react_1.within)(desktopNavigation).getByText("I am footer")).toBeTruthy();
256
+ });
257
+ (0, vitest_1.test)("renders without the navigation and toggle button", async () => {
258
+ const NAVIGATION = [
259
+ {
260
+ title: "Dashboard",
261
+ segment: "dashboard",
262
+ icon: (0, jsx_runtime_1.jsx)(Dashboard_1.default, {})
263
+ },
264
+ {
265
+ title: "Orders",
266
+ segment: "orders",
267
+ icon: (0, jsx_runtime_1.jsx)(ShoppingCart_1.default, {})
268
+ }
269
+ ];
270
+ (0, react_1.render)((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { navigation: NAVIGATION, children: (0, jsx_runtime_1.jsx)(DashboardLayout_1.DashboardLayout, { hideNavigation: true, children: "Hello world" }) }));
271
+ const desktopNavigation = react_1.screen.queryByRole("navigation", {
272
+ name: "Desktop"
273
+ });
274
+ const navigationToggle = react_1.screen.queryByLabelText("Collapse menu");
275
+ // Expect that navigation and menu button are not rendered
276
+ (0, vitest_1.expect)(desktopNavigation).toBeNull();
277
+ (0, vitest_1.expect)(navigationToggle).toBeNull();
278
+ // Ensure that main content is still rendered
279
+ (0, vitest_1.expect)(react_1.screen.getByText("Hello world")).toBeTruthy();
280
+ });
281
+ (0, vitest_1.test)("renders without default collapsed navigation on desktop", async () => {
282
+ const NAVIGATION = [
283
+ {
284
+ title: "Dashboard",
285
+ segment: "dashboard",
286
+ icon: (0, jsx_runtime_1.jsx)(Dashboard_1.default, {})
287
+ }
288
+ ];
289
+ (0, react_1.render)((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { navigation: NAVIGATION, children: (0, jsx_runtime_1.jsx)(DashboardLayout_1.DashboardLayout, { defaultSidebarCollapsed: true, children: "Hello world" }) }));
290
+ // Expect that menu button has expand action
291
+ (0, vitest_1.expect)(react_1.screen.getAllByLabelText("Expand menu")).toBeTruthy();
292
+ (0, vitest_1.expect)(react_1.screen.queryByLabelText("Collapse menu")).toBeNull();
293
+ // Ensure that main content is still rendered
294
+ (0, vitest_1.expect)(react_1.screen.getByText("Hello world")).toBeTruthy();
295
+ });
296
+ });