@etsoo/toolpad 1.0.11 → 1.0.13
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/babel.config.json +11 -0
- package/build/cjs/Account/Account.js +104 -0
- package/build/cjs/Account/Account.test.js +40 -0
- package/build/cjs/Account/AccountPopoverFooter.js +18 -0
- package/build/cjs/Account/AccountPopoverHeader.js +12 -0
- package/build/cjs/Account/AccountPreview.js +96 -0
- package/build/cjs/Account/AccountPreview.test.js +52 -0
- package/build/cjs/Account/SignInButton.js +56 -0
- package/build/cjs/Account/SignOutButton.js +58 -0
- package/build/cjs/Account/index.js +22 -0
- package/build/cjs/AppProvider/AppProvider.js +40 -0
- package/build/cjs/AppProvider/AppProvider.test.js +18 -0
- package/build/cjs/AppProvider/AppProviderComponent.js +33 -0
- package/build/cjs/AppProvider/AppThemeProvider.js +111 -0
- package/build/cjs/AppProvider/index.js +17 -0
- package/build/cjs/DashboardLayout/DashboardLayout.js +230 -0
- package/build/cjs/DashboardLayout/DashboardLayout.test.js +296 -0
- package/build/cjs/DashboardLayout/DashboardSidebarSubNavigation.js +185 -0
- package/build/cjs/DashboardLayout/ThemeSwitcher.js +84 -0
- package/build/cjs/DashboardLayout/TitleBar.d.ts +2 -0
- package/build/cjs/DashboardLayout/TitleBar.js +57 -0
- package/build/cjs/DashboardLayout/ToolbarActions.js +11 -0
- package/build/cjs/DashboardLayout/index.js +19 -0
- package/build/cjs/DashboardLayout/utils.js +20 -0
- package/build/{PageContainer → cjs/PageContainer}/PageContainer.d.ts +4 -0
- package/build/cjs/PageContainer/PageContainer.js +133 -0
- package/build/cjs/PageContainer/PageContainer.test.js +128 -0
- package/build/cjs/PageContainer/PageContainerToolbar.js +26 -0
- package/build/cjs/PageContainer/PageContainerToolbar.test.js +15 -0
- package/build/cjs/PageContainer/index.js +18 -0
- package/build/cjs/index.js +24 -0
- package/build/cjs/nextjs/AppProvider.js +18 -0
- package/build/cjs/nextjs/AppProvider.test.js +71 -0
- package/build/cjs/nextjs/AppProviderNextApp.js +63 -0
- package/build/cjs/nextjs/AppProviderNextPages.js +73 -0
- package/build/cjs/nextjs/index.js +17 -0
- package/build/cjs/persistence/codec.js +60 -0
- package/build/cjs/persistence/index.js +17 -0
- package/build/cjs/persistence/useStorageState.js +153 -0
- package/build/cjs/persistence/useStorageState.test.js +63 -0
- package/build/cjs/react-router-dom/AppProvider.js +64 -0
- package/build/cjs/react-router-dom/AppProvider.test.js +14 -0
- package/build/cjs/react-router-dom/index.js +17 -0
- package/build/cjs/shared/Link.js +55 -0
- package/build/cjs/shared/components.js +30 -0
- package/build/cjs/shared/context.js +46 -0
- package/build/cjs/shared/locales/LocaleContext.js +71 -0
- package/build/cjs/shared/navigation.js +151 -0
- package/build/cjs/useActivePage/index.js +17 -0
- package/build/cjs/useActivePage/useActivePage.js +83 -0
- package/build/cjs/useLocalStorageState/index.js +17 -0
- package/build/cjs/useLocalStorageState/useLocalStorageState.js +17 -0
- package/build/cjs/useSessionStorageState/index.js +17 -0
- package/build/cjs/useSessionStorageState/useSessionStorageState.js +17 -0
- package/build/cjs/utils/collections.js +53 -0
- package/build/cjs/utils/describeConformance.js +6 -0
- package/build/cjs/utils/events.js +58 -0
- package/build/cjs/utils/hooks/index.js +10 -0
- package/build/cjs/utils/hooks/useBoolean.js +47 -0
- package/build/cjs/utils/hooks/useDebounced.js +64 -0
- package/build/cjs/utils/hooks/useDebouncedHandler.js +77 -0
- package/build/cjs/utils/hooks/useLatest.js +44 -0
- package/build/cjs/utils/hooks/usePageTitle.js +49 -0
- package/build/cjs/utils/hooks/useSsr.js +52 -0
- package/build/cjs/utils/hooks/useStorageState.js +86 -0
- package/build/cjs/utils/warnOnce.js +14 -0
- package/build/mjs/Account/Account.d.ts +63 -0
- package/build/mjs/Account/Account.test.d.ts +1 -0
- package/build/mjs/Account/AccountPopoverFooter.d.ts +6 -0
- package/build/mjs/Account/AccountPopoverHeader.d.ts +6 -0
- package/build/mjs/Account/AccountPreview.d.ts +64 -0
- package/build/mjs/Account/AccountPreview.test.d.ts +1 -0
- package/build/mjs/Account/SignInButton.d.ts +2 -0
- package/build/mjs/Account/SignOutButton.d.ts +3 -0
- package/build/mjs/Account/index.js +6 -0
- package/build/mjs/AppProvider/AppProvider.d.ts +105 -0
- package/build/mjs/AppProvider/AppProvider.test.d.ts +4 -0
- package/build/mjs/AppProvider/AppProviderComponent.d.ts +14 -0
- package/build/mjs/AppProvider/AppThemeProvider.d.ts +12 -0
- package/build/mjs/DashboardLayout/DashboardLayout.d.ts +91 -0
- package/build/{DashboardLayout → mjs/DashboardLayout}/DashboardLayout.js +9 -10
- package/build/mjs/DashboardLayout/DashboardLayout.test.d.ts +1 -0
- package/build/mjs/DashboardLayout/DashboardSidebarSubNavigation.d.ts +16 -0
- package/build/mjs/DashboardLayout/ThemeSwitcher.d.ts +5 -0
- package/build/mjs/DashboardLayout/TitleBar.d.ts +2 -0
- package/build/mjs/DashboardLayout/ToolbarActions.d.ts +5 -0
- package/build/mjs/DashboardLayout/index.d.ts +2 -0
- package/build/mjs/DashboardLayout/utils.d.ts +8 -0
- package/build/mjs/PageContainer/PageContainer.d.ts +61 -0
- package/build/{PageContainer → mjs/PageContainer}/PageContainer.js +8 -4
- package/build/mjs/PageContainer/PageContainer.test.d.ts +1 -0
- package/build/mjs/PageContainer/PageContainerToolbar.d.ts +16 -0
- package/build/mjs/PageContainer/PageContainerToolbar.test.d.ts +1 -0
- package/build/mjs/PageContainer/index.js +2 -0
- package/build/mjs/index.js +8 -0
- package/build/mjs/nextjs/AppProvider.d.ts +6 -0
- package/build/mjs/nextjs/AppProvider.test.d.ts +1 -0
- package/build/mjs/nextjs/AppProviderNextApp.d.ts +5 -0
- package/build/mjs/nextjs/AppProviderNextPages.d.ts +5 -0
- package/build/mjs/nextjs/index.js +1 -0
- package/build/mjs/persistence/codec.d.ts +47 -0
- package/build/mjs/persistence/index.js +1 -0
- package/build/mjs/persistence/useStorageState.d.ts +50 -0
- package/build/mjs/persistence/useStorageState.test.d.ts +1 -0
- package/build/mjs/react-router-dom/AppProvider.d.ts +6 -0
- package/build/mjs/react-router-dom/AppProvider.test.d.ts +1 -0
- package/build/mjs/react-router-dom/index.d.ts +1 -0
- package/build/mjs/react-router-dom/index.js +1 -0
- package/build/mjs/shared/Link.d.ts +8 -0
- package/build/mjs/shared/components.d.ts +5 -0
- package/build/mjs/shared/context.d.ts +12 -0
- package/build/mjs/shared/locales/LocaleContext.d.ts +56 -0
- package/build/mjs/shared/navigation.d.ts +16 -0
- package/build/mjs/useActivePage/index.js +1 -0
- package/build/mjs/useActivePage/useActivePage.d.ts +8 -0
- package/build/mjs/useLocalStorageState/index.js +1 -0
- package/build/mjs/useLocalStorageState/useLocalStorageState.d.ts +2 -0
- package/build/mjs/useSessionStorageState/index.js +1 -0
- package/build/mjs/useSessionStorageState/useSessionStorageState.d.ts +2 -0
- package/build/mjs/utils/collections.d.ts +44 -0
- package/build/mjs/utils/describeConformance.d.ts +7 -0
- package/build/mjs/utils/events.d.ts +27 -0
- package/build/mjs/utils/hooks/index.js +2 -0
- package/build/mjs/utils/hooks/useBoolean.d.ts +11 -0
- package/build/mjs/utils/hooks/useDebounced.d.ts +8 -0
- package/build/mjs/utils/hooks/useDebouncedHandler.d.ts +12 -0
- package/build/mjs/utils/hooks/useLatest.d.ts +6 -0
- package/build/mjs/utils/hooks/usePageTitle.d.ts +4 -0
- package/build/mjs/utils/hooks/useSsr.d.ts +4 -0
- package/build/mjs/utils/hooks/useStorageState.d.ts +10 -0
- package/build/mjs/utils/warnOnce.d.ts +5 -0
- package/package.json +33 -23
- package/src/DashboardLayout/DashboardLayout.tsx +13 -12
- package/src/PageContainer/PageContainer.tsx +12 -4
- package/tsconfig.cjs.json +20 -0
- package/tsconfig.json +2 -2
- package/build/DashboardLayout/TitleBar.d.ts +0 -2
- /package/build/{Account → cjs/Account}/Account.d.ts +0 -0
- /package/build/{Account → cjs/Account}/Account.test.d.ts +0 -0
- /package/build/{Account → cjs/Account}/AccountPopoverFooter.d.ts +0 -0
- /package/build/{Account → cjs/Account}/AccountPopoverHeader.d.ts +0 -0
- /package/build/{Account → cjs/Account}/AccountPreview.d.ts +0 -0
- /package/build/{Account → cjs/Account}/AccountPreview.test.d.ts +0 -0
- /package/build/{Account → cjs/Account}/SignInButton.d.ts +0 -0
- /package/build/{Account → cjs/Account}/SignOutButton.d.ts +0 -0
- /package/build/{Account → cjs/Account}/index.d.ts +0 -0
- /package/build/{AppProvider → cjs/AppProvider}/AppProvider.d.ts +0 -0
- /package/build/{AppProvider → cjs/AppProvider}/AppProvider.test.d.ts +0 -0
- /package/build/{AppProvider → cjs/AppProvider}/AppProviderComponent.d.ts +0 -0
- /package/build/{AppProvider → cjs/AppProvider}/AppThemeProvider.d.ts +0 -0
- /package/build/{AppProvider → cjs/AppProvider}/index.d.ts +0 -0
- /package/build/{DashboardLayout → cjs/DashboardLayout}/DashboardLayout.d.ts +0 -0
- /package/build/{DashboardLayout → cjs/DashboardLayout}/DashboardLayout.test.d.ts +0 -0
- /package/build/{DashboardLayout → cjs/DashboardLayout}/DashboardSidebarSubNavigation.d.ts +0 -0
- /package/build/{DashboardLayout → cjs/DashboardLayout}/ThemeSwitcher.d.ts +0 -0
- /package/build/{DashboardLayout → cjs/DashboardLayout}/ToolbarActions.d.ts +0 -0
- /package/build/{DashboardLayout → cjs/DashboardLayout}/index.d.ts +0 -0
- /package/build/{DashboardLayout → cjs/DashboardLayout}/utils.d.ts +0 -0
- /package/build/{PageContainer → cjs/PageContainer}/PageContainer.test.d.ts +0 -0
- /package/build/{PageContainer → cjs/PageContainer}/PageContainerToolbar.d.ts +0 -0
- /package/build/{PageContainer → cjs/PageContainer}/PageContainerToolbar.test.d.ts +0 -0
- /package/build/{PageContainer → cjs/PageContainer}/index.d.ts +0 -0
- /package/build/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/build/{nextjs → cjs/nextjs}/AppProvider.d.ts +0 -0
- /package/build/{nextjs → cjs/nextjs}/AppProvider.test.d.ts +0 -0
- /package/build/{nextjs → cjs/nextjs}/AppProviderNextApp.d.ts +0 -0
- /package/build/{nextjs → cjs/nextjs}/AppProviderNextPages.d.ts +0 -0
- /package/build/{nextjs → cjs/nextjs}/index.d.ts +0 -0
- /package/build/{persistence → cjs/persistence}/codec.d.ts +0 -0
- /package/build/{persistence → cjs/persistence}/index.d.ts +0 -0
- /package/build/{persistence → cjs/persistence}/useStorageState.d.ts +0 -0
- /package/build/{persistence → cjs/persistence}/useStorageState.test.d.ts +0 -0
- /package/build/{react-router-dom → cjs/react-router-dom}/AppProvider.d.ts +0 -0
- /package/build/{react-router-dom → cjs/react-router-dom}/AppProvider.test.d.ts +0 -0
- /package/build/{react-router-dom → cjs/react-router-dom}/index.d.ts +0 -0
- /package/build/{shared → cjs/shared}/Link.d.ts +0 -0
- /package/build/{shared → cjs/shared}/components.d.ts +0 -0
- /package/build/{shared → cjs/shared}/context.d.ts +0 -0
- /package/build/{shared → cjs/shared}/locales/LocaleContext.d.ts +0 -0
- /package/build/{shared → cjs/shared}/navigation.d.ts +0 -0
- /package/build/{useActivePage → cjs/useActivePage}/index.d.ts +0 -0
- /package/build/{useActivePage → cjs/useActivePage}/useActivePage.d.ts +0 -0
- /package/build/{useLocalStorageState → cjs/useLocalStorageState}/index.d.ts +0 -0
- /package/build/{useLocalStorageState → cjs/useLocalStorageState}/useLocalStorageState.d.ts +0 -0
- /package/build/{useSessionStorageState → cjs/useSessionStorageState}/index.d.ts +0 -0
- /package/build/{useSessionStorageState → cjs/useSessionStorageState}/useSessionStorageState.d.ts +0 -0
- /package/build/{utils → cjs/utils}/collections.d.ts +0 -0
- /package/build/{utils → cjs/utils}/describeConformance.d.ts +0 -0
- /package/build/{utils → cjs/utils}/events.d.ts +0 -0
- /package/build/{utils → cjs/utils}/hooks/index.d.ts +0 -0
- /package/build/{utils → cjs/utils}/hooks/useBoolean.d.ts +0 -0
- /package/build/{utils → cjs/utils}/hooks/useDebounced.d.ts +0 -0
- /package/build/{utils → cjs/utils}/hooks/useDebouncedHandler.d.ts +0 -0
- /package/build/{utils → cjs/utils}/hooks/useLatest.d.ts +0 -0
- /package/build/{utils → cjs/utils}/hooks/usePageTitle.d.ts +0 -0
- /package/build/{utils → cjs/utils}/hooks/useSsr.d.ts +0 -0
- /package/build/{utils → cjs/utils}/hooks/useStorageState.d.ts +0 -0
- /package/build/{utils → cjs/utils}/warnOnce.d.ts +0 -0
- /package/build/{Account → mjs/Account}/Account.js +0 -0
- /package/build/{Account → mjs/Account}/Account.test.js +0 -0
- /package/build/{Account → mjs/Account}/AccountPopoverFooter.js +0 -0
- /package/build/{Account → mjs/Account}/AccountPopoverHeader.js +0 -0
- /package/build/{Account → mjs/Account}/AccountPreview.js +0 -0
- /package/build/{Account → mjs/Account}/AccountPreview.test.js +0 -0
- /package/build/{Account → mjs/Account}/SignInButton.js +0 -0
- /package/build/{Account → mjs/Account}/SignOutButton.js +0 -0
- /package/build/{Account/index.js → mjs/Account/index.d.ts} +0 -0
- /package/build/{AppProvider → mjs/AppProvider}/AppProvider.js +0 -0
- /package/build/{AppProvider → mjs/AppProvider}/AppProvider.test.js +0 -0
- /package/build/{AppProvider → mjs/AppProvider}/AppProviderComponent.js +0 -0
- /package/build/{AppProvider → mjs/AppProvider}/AppThemeProvider.js +0 -0
- /package/build/{AppProvider/index.js → mjs/AppProvider/index.d.ts} +0 -0
- /package/build/{nextjs → mjs/AppProvider}/index.js +0 -0
- /package/build/{DashboardLayout → mjs/DashboardLayout}/DashboardLayout.test.js +0 -0
- /package/build/{DashboardLayout → mjs/DashboardLayout}/DashboardSidebarSubNavigation.js +0 -0
- /package/build/{DashboardLayout → mjs/DashboardLayout}/ThemeSwitcher.js +0 -0
- /package/build/{DashboardLayout → mjs/DashboardLayout}/TitleBar.js +0 -0
- /package/build/{DashboardLayout → mjs/DashboardLayout}/ToolbarActions.js +0 -0
- /package/build/{DashboardLayout → mjs/DashboardLayout}/index.js +0 -0
- /package/build/{DashboardLayout → mjs/DashboardLayout}/utils.js +0 -0
- /package/build/{PageContainer → mjs/PageContainer}/PageContainer.test.js +0 -0
- /package/build/{PageContainer → mjs/PageContainer}/PageContainerToolbar.js +0 -0
- /package/build/{PageContainer → mjs/PageContainer}/PageContainerToolbar.test.js +0 -0
- /package/build/{PageContainer/index.js → mjs/PageContainer/index.d.ts} +0 -0
- /package/build/{index.js → mjs/index.d.ts} +0 -0
- /package/build/{nextjs → mjs/nextjs}/AppProvider.js +0 -0
- /package/build/{nextjs → mjs/nextjs}/AppProvider.test.js +0 -0
- /package/build/{nextjs → mjs/nextjs}/AppProviderNextApp.js +0 -0
- /package/build/{nextjs → mjs/nextjs}/AppProviderNextPages.js +0 -0
- /package/build/{react-router-dom/index.js → mjs/nextjs/index.d.ts} +0 -0
- /package/build/{persistence → mjs/persistence}/codec.js +0 -0
- /package/build/{persistence/index.js → mjs/persistence/index.d.ts} +0 -0
- /package/build/{persistence → mjs/persistence}/useStorageState.js +0 -0
- /package/build/{persistence → mjs/persistence}/useStorageState.test.js +0 -0
- /package/build/{react-router-dom → mjs/react-router-dom}/AppProvider.js +0 -0
- /package/build/{react-router-dom → mjs/react-router-dom}/AppProvider.test.js +0 -0
- /package/build/{shared → mjs/shared}/Link.js +0 -0
- /package/build/{shared → mjs/shared}/components.js +0 -0
- /package/build/{shared → mjs/shared}/context.js +0 -0
- /package/build/{shared → mjs/shared}/locales/LocaleContext.js +0 -0
- /package/build/{shared → mjs/shared}/navigation.js +0 -0
- /package/build/{useActivePage/index.js → mjs/useActivePage/index.d.ts} +0 -0
- /package/build/{useActivePage → mjs/useActivePage}/useActivePage.js +0 -0
- /package/build/{useLocalStorageState/index.js → mjs/useLocalStorageState/index.d.ts} +0 -0
- /package/build/{useLocalStorageState → mjs/useLocalStorageState}/useLocalStorageState.js +0 -0
- /package/build/{useSessionStorageState/index.js → mjs/useSessionStorageState/index.d.ts} +0 -0
- /package/build/{useSessionStorageState → mjs/useSessionStorageState}/useSessionStorageState.js +0 -0
- /package/build/{utils → mjs/utils}/collections.js +0 -0
- /package/build/{utils → mjs/utils}/describeConformance.js +0 -0
- /package/build/{utils → mjs/utils}/events.js +0 -0
- /package/build/{utils/hooks/index.js → mjs/utils/hooks/index.d.ts} +0 -0
- /package/build/{utils → mjs/utils}/hooks/useBoolean.js +0 -0
- /package/build/{utils → mjs/utils}/hooks/useDebounced.js +0 -0
- /package/build/{utils → mjs/utils}/hooks/useDebouncedHandler.js +0 -0
- /package/build/{utils → mjs/utils}/hooks/useLatest.js +0 -0
- /package/build/{utils → mjs/utils}/hooks/usePageTitle.js +0 -0
- /package/build/{utils → mjs/utils}/hooks/useSsr.js +0 -0
- /package/build/{utils → mjs/utils}/hooks/useStorageState.js +0 -0
- /package/build/{utils → mjs/utils}/warnOnce.js +0 -0
- /package/{vite.config.ts → vite.config.mts} +0 -0
|
@@ -0,0 +1,104 @@
|
|
|
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.Account = Account;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const Popover_1 = __importDefault(require("@mui/material/Popover"));
|
|
43
|
+
const Divider_1 = __importDefault(require("@mui/material/Divider"));
|
|
44
|
+
const Stack_1 = __importDefault(require("@mui/material/Stack"));
|
|
45
|
+
const SignInButton_1 = require("./SignInButton");
|
|
46
|
+
const SignOutButton_1 = require("./SignOutButton");
|
|
47
|
+
const AccountPreview_1 = require("./AccountPreview");
|
|
48
|
+
const AccountPopoverHeader_1 = require("./AccountPopoverHeader");
|
|
49
|
+
const AccountPopoverFooter_1 = require("./AccountPopoverFooter");
|
|
50
|
+
const AppProvider_1 = require("../AppProvider/AppProvider");
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* Demos:
|
|
54
|
+
*
|
|
55
|
+
* - [Account](https://mui.com/toolpad/core/react-account/)
|
|
56
|
+
* - [Dashboard Layout](https://mui.com/toolpad/core/react-dashboard-layout/)
|
|
57
|
+
* - [Sign-in Page](https://mui.com/toolpad/core/react-sign-in-page/)
|
|
58
|
+
*
|
|
59
|
+
* API:
|
|
60
|
+
*
|
|
61
|
+
* - [Account API](https://mui.com/toolpad/core/api/account)
|
|
62
|
+
*/
|
|
63
|
+
function Account(props) {
|
|
64
|
+
const { slots, slotProps } = props;
|
|
65
|
+
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
66
|
+
const session = React.useContext(AppProvider_1.SessionContext);
|
|
67
|
+
const authentication = React.useContext(AppProvider_1.AuthenticationContext);
|
|
68
|
+
const open = Boolean(anchorEl);
|
|
69
|
+
const handleClick = (event) => {
|
|
70
|
+
setAnchorEl(event.currentTarget);
|
|
71
|
+
};
|
|
72
|
+
const handleClose = () => {
|
|
73
|
+
setAnchorEl(null);
|
|
74
|
+
};
|
|
75
|
+
if (!authentication) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
if (!session?.user) {
|
|
79
|
+
return slots?.signInButton ? ((0, jsx_runtime_1.jsx)(slots.signInButton, { onClick: authentication.signIn })) : ((0, jsx_runtime_1.jsx)(SignInButton_1.SignInButton, { ...slotProps?.signInButton }));
|
|
80
|
+
}
|
|
81
|
+
return ((0, jsx_runtime_1.jsxs)(React.Fragment, { children: [slots?.preview ? ((0, jsx_runtime_1.jsx)(slots.preview, { handleClick: handleClick, open: open })) : ((0, jsx_runtime_1.jsx)(AccountPreview_1.AccountPreview, { variant: "condensed", handleClick: handleClick, open: open, ...slotProps?.preview })), slots?.popover ? ((0, jsx_runtime_1.jsx)(slots.popover, { ...slotProps?.popover })) : ((0, jsx_runtime_1.jsx)(Popover_1.default, { anchorEl: anchorEl, id: "account-menu", open: open, onClose: handleClose, onClick: handleClose, transformOrigin: { horizontal: "right", vertical: "top" }, anchorOrigin: { horizontal: "right", vertical: "bottom" }, ...slotProps?.popover, slotProps: {
|
|
82
|
+
paper: {
|
|
83
|
+
elevation: 0,
|
|
84
|
+
sx: {
|
|
85
|
+
overflow: "visible",
|
|
86
|
+
filter: "drop-shadow(0px 2px 8px rgba(0,0,0,0.32))",
|
|
87
|
+
mt: 1,
|
|
88
|
+
"&::before": {
|
|
89
|
+
content: '""',
|
|
90
|
+
display: "block",
|
|
91
|
+
position: "absolute",
|
|
92
|
+
top: 0,
|
|
93
|
+
right: 14,
|
|
94
|
+
width: 10,
|
|
95
|
+
height: 10,
|
|
96
|
+
bgcolor: "background.paper",
|
|
97
|
+
transform: "translateY(-50%) rotate(45deg)",
|
|
98
|
+
zIndex: 0
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
...slotProps?.popover?.slotProps
|
|
103
|
+
}, children: slots?.popoverContent ? ((0, jsx_runtime_1.jsx)(slots.popoverContent, { ...slotProps?.popoverContent })) : ((0, jsx_runtime_1.jsxs)(Stack_1.default, { direction: "column", ...slotProps?.popoverContent, children: [(0, jsx_runtime_1.jsx)(AccountPopoverHeader_1.AccountPopoverHeader, { children: (0, jsx_runtime_1.jsx)(AccountPreview_1.AccountPreview, { variant: "expanded" }) }), (0, jsx_runtime_1.jsx)(Divider_1.default, {}), (0, jsx_runtime_1.jsx)(AccountPopoverFooter_1.AccountPopoverFooter, { children: (0, jsx_runtime_1.jsx)(SignOutButton_1.SignOutButton, { ...slotProps?.signOutButton }) })] })) }))] }));
|
|
104
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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 user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
10
|
+
const Account_1 = require("./Account");
|
|
11
|
+
const describeConformance_1 = __importDefault(require("../utils/describeConformance"));
|
|
12
|
+
const AppProviderComponent_1 = require("../AppProvider/AppProviderComponent");
|
|
13
|
+
(0, vitest_1.describe)("AppProvider", () => {
|
|
14
|
+
(0, describeConformance_1.default)((0, jsx_runtime_1.jsx)(Account_1.Account, {}), () => ({
|
|
15
|
+
skip: ["themeDefaultProps"]
|
|
16
|
+
}));
|
|
17
|
+
(0, vitest_1.test)("renders nothing in button when no authentication", async () => {
|
|
18
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(Account_1.Account, {}));
|
|
19
|
+
(0, vitest_1.expect)(react_1.screen.queryByRole("button")).not.toBeInTheDocument();
|
|
20
|
+
});
|
|
21
|
+
(0, vitest_1.test)("renders log in button when no session", async () => {
|
|
22
|
+
const auth = { signIn: vitest_1.vi.fn(), signOut: vitest_1.vi.fn() };
|
|
23
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { authentication: auth, children: (0, jsx_runtime_1.jsx)(Account_1.Account, {}) }));
|
|
24
|
+
const loginButton = react_1.screen.getByRole("button", { name: "Sign In" });
|
|
25
|
+
await user_event_1.default.click(loginButton);
|
|
26
|
+
(0, vitest_1.expect)(auth.signIn).toHaveBeenCalled();
|
|
27
|
+
});
|
|
28
|
+
(0, vitest_1.test)("renders content correctly when there is a session", async () => {
|
|
29
|
+
const auth = { signIn: vitest_1.vi.fn(), signOut: vitest_1.vi.fn() };
|
|
30
|
+
const session = { user: { name: "John Doe", email: "john@example.com" } };
|
|
31
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { authentication: auth, session: session, children: (0, jsx_runtime_1.jsx)(Account_1.Account, {}) }));
|
|
32
|
+
const userButton = react_1.screen.getByRole("button", { name: "Current User" });
|
|
33
|
+
await user_event_1.default.click(userButton);
|
|
34
|
+
(0, vitest_1.expect)(react_1.screen.getByText("John Doe")).toBeInTheDocument();
|
|
35
|
+
(0, vitest_1.expect)(react_1.screen.getByText("john@example.com")).toBeInTheDocument();
|
|
36
|
+
const signOutButton = react_1.screen.getByRole("button", { name: "Sign Out" });
|
|
37
|
+
await user_event_1.default.click(signOutButton);
|
|
38
|
+
(0, vitest_1.expect)(auth.signOut).toHaveBeenCalled();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
exports.AccountPopoverFooter = AccountPopoverFooter;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const Box_1 = __importDefault(require("@mui/material/Box"));
|
|
9
|
+
function AccountPopoverFooter(props) {
|
|
10
|
+
const { children, ...rest } = props;
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)(Box_1.default, { ...rest, sx: {
|
|
12
|
+
display: "flex",
|
|
13
|
+
flexDirection: "row",
|
|
14
|
+
p: 1,
|
|
15
|
+
justifyContent: "flex-end",
|
|
16
|
+
...rest.sx
|
|
17
|
+
}, children: children }));
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
exports.AccountPopoverHeader = AccountPopoverHeader;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const Stack_1 = __importDefault(require("@mui/material/Stack"));
|
|
9
|
+
function AccountPopoverHeader(props) {
|
|
10
|
+
const { children, ...rest } = props;
|
|
11
|
+
return (0, jsx_runtime_1.jsx)(Stack_1.default, { ...rest, children: children });
|
|
12
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
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.AccountPreview = AccountPreview;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const Avatar_1 = __importDefault(require("@mui/material/Avatar"));
|
|
43
|
+
const Typography_1 = __importDefault(require("@mui/material/Typography"));
|
|
44
|
+
const Tooltip_1 = __importDefault(require("@mui/material/Tooltip"));
|
|
45
|
+
const Stack_1 = __importDefault(require("@mui/material/Stack"));
|
|
46
|
+
const IconButton_1 = __importDefault(require("@mui/material/IconButton"));
|
|
47
|
+
const MoreVert_1 = __importDefault(require("@mui/icons-material/MoreVert"));
|
|
48
|
+
const AppProvider_1 = require("../AppProvider");
|
|
49
|
+
const LocaleContext_1 = require("../shared/locales/LocaleContext");
|
|
50
|
+
function formatNameInitials(user) {
|
|
51
|
+
if (user == null)
|
|
52
|
+
return null;
|
|
53
|
+
const name = user.latinName || user.name;
|
|
54
|
+
if (name == null)
|
|
55
|
+
return null;
|
|
56
|
+
const chars = name
|
|
57
|
+
.trim()
|
|
58
|
+
.split(/\s+/g)
|
|
59
|
+
.map((part) => {
|
|
60
|
+
const firstChar = part.charAt(0).toUpperCase();
|
|
61
|
+
return firstChar >= "A" && firstChar <= "Z" ? firstChar : "";
|
|
62
|
+
})
|
|
63
|
+
.filter((c) => c)
|
|
64
|
+
.slice(-2);
|
|
65
|
+
if (chars.length === 0)
|
|
66
|
+
return null;
|
|
67
|
+
return chars.join("");
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The AccountPreview component displays user account information.
|
|
71
|
+
*
|
|
72
|
+
* Demos:
|
|
73
|
+
*
|
|
74
|
+
* - [Account](https://mui.com/toolpad/core/react-account/)
|
|
75
|
+
*
|
|
76
|
+
* API:
|
|
77
|
+
*
|
|
78
|
+
* - [AccountPreview API](https://mui.com/toolpad/core/api/account-preview)
|
|
79
|
+
*/
|
|
80
|
+
function AccountPreview(props) {
|
|
81
|
+
const { slots, variant = "condensed", slotProps, open, handleClick } = props;
|
|
82
|
+
const session = React.useContext(AppProvider_1.SessionContext);
|
|
83
|
+
const localeText = (0, LocaleContext_1.useLocaleText)();
|
|
84
|
+
if (!session || !session.user) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const avatarContent = slots?.avatar ? ((0, jsx_runtime_1.jsx)(slots.avatar, {})) : ((0, jsx_runtime_1.jsx)(Avatar_1.default, { src: session.user?.image || "", alt: session.user?.name || session.user?.email || "", sx: {
|
|
88
|
+
height: variant === "expanded" ? 48 : 32,
|
|
89
|
+
width: variant === "expanded" ? 48 : 32
|
|
90
|
+
}, ...slotProps?.avatar, children: session.user?.image ? null : formatNameInitials(session.user) }));
|
|
91
|
+
if (variant === "expanded") {
|
|
92
|
+
return ((0, jsx_runtime_1.jsxs)(Stack_1.default, { direction: "row", justifyContent: "flex-start", spacing: 2, padding: 2, children: [avatarContent, (0, jsx_runtime_1.jsxs)(Stack_1.default, { direction: "column", justifyContent: "space-evenly", children: [(0, jsx_runtime_1.jsx)(Typography_1.default, { variant: "body2", fontWeight: "bolder", noWrap: true, children: session.user?.name }), (0, jsx_runtime_1.jsx)(Typography_1.default, { variant: "caption", noWrap: true, children: session.user?.email })] }), handleClick &&
|
|
93
|
+
(slots?.moreIconButton ? ((0, jsx_runtime_1.jsx)(slots.moreIconButton, {})) : ((0, jsx_runtime_1.jsx)(IconButton_1.default, { size: "small", onClick: handleClick, ...slotProps?.moreIconButton, sx: { alignSelf: "flex-start", ...slotProps?.moreIconButton?.sx }, children: (0, jsx_runtime_1.jsx)(MoreVert_1.default, { fontSize: "small" }) })))] }));
|
|
94
|
+
}
|
|
95
|
+
return ((0, jsx_runtime_1.jsx)(Tooltip_1.default, { title: session.user.name ?? "Account", children: slots?.avatarIconButton ? ((0, jsx_runtime_1.jsx)(slots.avatarIconButton, {})) : ((0, jsx_runtime_1.jsx)(IconButton_1.default, { onClick: handleClick, "aria-label": localeText.accountIconButtonAriaLabel, size: "small", "aria-controls": open ? "account-menu" : undefined, "aria-haspopup": "true", "aria-expanded": open ? "true" : undefined, ...slotProps?.avatarIconButton, children: avatarContent })) }));
|
|
96
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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 user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
10
|
+
const AccountPreview_1 = require("./AccountPreview");
|
|
11
|
+
const AppProviderComponent_1 = require("../AppProvider/AppProviderComponent");
|
|
12
|
+
(0, vitest_1.describe)("AccountPreview", () => {
|
|
13
|
+
const auth = { signIn: vitest_1.vi.fn(), signOut: vitest_1.vi.fn() };
|
|
14
|
+
const session = {
|
|
15
|
+
user: {
|
|
16
|
+
name: "John Doe",
|
|
17
|
+
email: "john@example.com",
|
|
18
|
+
image: "https://example.com/avatar.jpg"
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
(0, vitest_1.test)("renders nothing when no session is provided", () => {
|
|
22
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { authentication: auth, children: (0, jsx_runtime_1.jsx)(AccountPreview_1.AccountPreview, {}) }));
|
|
23
|
+
(0, vitest_1.expect)(react_1.screen.queryByRole("button")).not.toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
(0, vitest_1.test)("displays condensed variant by default", () => {
|
|
26
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { authentication: auth, session: session, children: (0, jsx_runtime_1.jsx)(AccountPreview_1.AccountPreview, {}) }));
|
|
27
|
+
const avatar = react_1.screen.getByRole("img", { name: "John Doe" });
|
|
28
|
+
(0, vitest_1.expect)(avatar).toBeInTheDocument();
|
|
29
|
+
(0, vitest_1.expect)(react_1.screen.queryByText("John Doe")).not.toBeInTheDocument();
|
|
30
|
+
(0, vitest_1.expect)(avatar).toHaveAttribute("src", "https://example.com/avatar.jpg");
|
|
31
|
+
});
|
|
32
|
+
(0, vitest_1.test)("displays user name, email, and avatar in expanded variant", () => {
|
|
33
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { authentication: auth, session: session, children: (0, jsx_runtime_1.jsx)(AccountPreview_1.AccountPreview, { variant: "expanded" }) }));
|
|
34
|
+
(0, vitest_1.expect)(react_1.screen.getByText("John Doe")).toBeInTheDocument();
|
|
35
|
+
(0, vitest_1.expect)(react_1.screen.getByText("john@example.com")).toBeInTheDocument();
|
|
36
|
+
(0, vitest_1.expect)(react_1.screen.getByRole("img", { name: "John Doe" })).toBeInTheDocument();
|
|
37
|
+
});
|
|
38
|
+
(0, vitest_1.test)("calls handleClick when more icon button is clicked in expanded variant", async () => {
|
|
39
|
+
const handleClick = vitest_1.vi.fn();
|
|
40
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { authentication: auth, session: session, children: (0, jsx_runtime_1.jsx)(AccountPreview_1.AccountPreview, { variant: "expanded", handleClick: handleClick }) }));
|
|
41
|
+
const moreButton = react_1.screen.getByRole("button");
|
|
42
|
+
await user_event_1.default.click(moreButton);
|
|
43
|
+
(0, vitest_1.expect)(handleClick).toHaveBeenCalled();
|
|
44
|
+
});
|
|
45
|
+
(0, vitest_1.test)("calls handleClick when avatar is clicked in condensed variant", async () => {
|
|
46
|
+
const handleClick = vitest_1.vi.fn();
|
|
47
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { authentication: auth, session: session, children: (0, jsx_runtime_1.jsx)(AccountPreview_1.AccountPreview, { handleClick: handleClick }) }));
|
|
48
|
+
const avatarButton = react_1.screen.getByRole("button", { name: "Current User" });
|
|
49
|
+
await user_event_1.default.click(avatarButton);
|
|
50
|
+
(0, vitest_1.expect)(handleClick).toHaveBeenCalled();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
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.SignInButton = SignInButton;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const Button_1 = __importDefault(require("@mui/material/Button"));
|
|
43
|
+
const AppProvider_1 = require("../AppProvider/AppProvider");
|
|
44
|
+
const LocaleContext_1 = require("../shared/locales/LocaleContext");
|
|
45
|
+
function SignInButton(props) {
|
|
46
|
+
const authentication = React.useContext(AppProvider_1.AuthenticationContext);
|
|
47
|
+
const localeText = (0, LocaleContext_1.useLocaleText)();
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)(Button_1.default, { disableElevation: true, variant: "contained", size: "small", onClick: authentication?.signIn, sx: {
|
|
49
|
+
textTransform: "capitalize",
|
|
50
|
+
filter: "opacity(0.9)",
|
|
51
|
+
transition: "filter 0.2s ease-in",
|
|
52
|
+
"&:hover": {
|
|
53
|
+
filter: "opacity(1)"
|
|
54
|
+
}
|
|
55
|
+
}, ...props, children: localeText.signInLabel }));
|
|
56
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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.SignOutButton = SignOutButton;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const Button_1 = __importDefault(require("@mui/material/Button"));
|
|
43
|
+
const Logout_1 = __importDefault(require("@mui/icons-material/Logout"));
|
|
44
|
+
const AppProvider_1 = require("../AppProvider/AppProvider");
|
|
45
|
+
const LocaleContext_1 = require("../shared/locales/LocaleContext");
|
|
46
|
+
function SignOutButton(props) {
|
|
47
|
+
const authentication = React.useContext(AppProvider_1.AuthenticationContext);
|
|
48
|
+
const localeText = (0, LocaleContext_1.useLocaleText)();
|
|
49
|
+
return ((0, jsx_runtime_1.jsx)(Button_1.default, { disabled: !authentication, variant: "outlined", size: "small", disableElevation: true, onClick: authentication?.signOut, sx: {
|
|
50
|
+
textTransform: "capitalize",
|
|
51
|
+
fontWeight: "normal",
|
|
52
|
+
filter: "opacity(0.9)",
|
|
53
|
+
transition: "filter 0.2s ease-in",
|
|
54
|
+
"&:hover": {
|
|
55
|
+
filter: "opacity(1)"
|
|
56
|
+
}
|
|
57
|
+
}, startIcon: (0, jsx_runtime_1.jsx)(Logout_1.default, {}), ...props, children: localeText.signOutLabel }));
|
|
58
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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("./Account"), exports);
|
|
18
|
+
__exportStar(require("./AccountPreview"), exports);
|
|
19
|
+
__exportStar(require("./AccountPopoverHeader"), exports);
|
|
20
|
+
__exportStar(require("./AccountPopoverFooter"), exports);
|
|
21
|
+
__exportStar(require("./SignOutButton"), exports);
|
|
22
|
+
__exportStar(require("./SignInButton"), exports);
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.SessionContext = exports.AuthenticationContext = void 0;
|
|
38
|
+
const React = __importStar(require("react"));
|
|
39
|
+
exports.AuthenticationContext = React.createContext(null);
|
|
40
|
+
exports.SessionContext = React.createContext(null);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const react_1 = require("@testing-library/react");
|
|
6
|
+
const styles_1 = require("@mui/material/styles");
|
|
7
|
+
const AppProviderComponent_1 = require("./AppProviderComponent");
|
|
8
|
+
(0, vitest_1.describe)("AppProvider", () => {
|
|
9
|
+
(0, vitest_1.test)("renders content correctly", async () => {
|
|
10
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { children: "Hello world" }));
|
|
11
|
+
(0, vitest_1.expect)(react_1.screen.getByText("Hello world")).toBeTruthy();
|
|
12
|
+
});
|
|
13
|
+
(0, vitest_1.test)("renders content correctly when using legacy theme", async () => {
|
|
14
|
+
const legacyTheme = (0, styles_1.createTheme)();
|
|
15
|
+
(0, react_1.render)((0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { theme: legacyTheme, children: "Hello world" }));
|
|
16
|
+
(0, vitest_1.expect)(react_1.screen.getByText("Hello world")).toBeTruthy();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AppProvider = AppProvider;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const context_1 = require("../shared/context");
|
|
7
|
+
const AppThemeProvider_1 = require("./AppThemeProvider");
|
|
8
|
+
const styles_1 = require("@mui/material/styles");
|
|
9
|
+
const AppProvider_1 = require("./AppProvider");
|
|
10
|
+
const LocaleContext_1 = require("../shared/locales/LocaleContext");
|
|
11
|
+
function createTheme() {
|
|
12
|
+
return (0, styles_1.createTheme)({
|
|
13
|
+
cssVariables: {
|
|
14
|
+
colorSchemeSelector: "data-toolpad-color-scheme"
|
|
15
|
+
},
|
|
16
|
+
colorSchemes: { dark: true }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* Demos:
|
|
22
|
+
*
|
|
23
|
+
* - [App Provider](https://mui.com/toolpad/core/react-app-provider/)
|
|
24
|
+
* - [Dashboard Layout](https://mui.com/toolpad/core/react-dashboard-layout/)
|
|
25
|
+
*
|
|
26
|
+
* API:
|
|
27
|
+
*
|
|
28
|
+
* - [AppProvider API](https://mui.com/toolpad/core/api/app-provider)
|
|
29
|
+
*/
|
|
30
|
+
function AppProvider(props) {
|
|
31
|
+
const { children, theme = createTheme(), branding = null, localeText, navigation = [], router = null, authentication = null, session = null, window: appWindow } = props;
|
|
32
|
+
return ((0, jsx_runtime_1.jsx)(context_1.WindowContext.Provider, { value: appWindow, children: (0, jsx_runtime_1.jsx)(AppProvider_1.AuthenticationContext.Provider, { value: authentication, children: (0, jsx_runtime_1.jsx)(AppProvider_1.SessionContext.Provider, { value: session, children: (0, jsx_runtime_1.jsx)(context_1.RouterContext.Provider, { value: router, children: (0, jsx_runtime_1.jsx)(AppThemeProvider_1.AppThemeProvider, { theme: theme, window: appWindow, children: (0, jsx_runtime_1.jsx)(LocaleContext_1.LocaleProvider, { localeText: localeText, children: (0, jsx_runtime_1.jsx)(context_1.BrandingContext.Provider, { value: branding, children: (0, jsx_runtime_1.jsx)(context_1.NavigationContext.Provider, { value: navigation, children: children }) }) }) }) }) }) }) }));
|
|
33
|
+
}
|