@proteinjs/ui 2.0.5 → 2.0.7

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/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.0.7](https://github.com/proteinjs/ui/compare/@proteinjs/ui@2.0.6...@proteinjs/ui@2.0.7) (2024-05-21)
7
+
8
+ **Note:** Version bump only for package @proteinjs/ui
9
+
10
+
11
+
12
+
13
+
14
+ ## [2.0.6](https://github.com/proteinjs/ui/compare/@proteinjs/ui@2.0.5...@proteinjs/ui@2.0.6) (2024-05-17)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * allow custom account menu in page container ([9fdb291](https://github.com/proteinjs/ui/commit/9fdb291e8595d9ec8a05b395a413e4bc05ead59b))
20
+
21
+
22
+
23
+
24
+
6
25
  ## [2.0.4](https://github.com/proteinjs/ui/compare/@proteinjs/ui@2.0.3...@proteinjs/ui@2.0.4) (2024-05-10)
7
26
 
8
27
 
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Brent Bahry
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -30,7 +30,7 @@ require("react-router");
30
30
  require("react-router-dom");
31
31
  require("string");
32
32
  /** Generate Source Graph */
33
- var sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/ui/Page\",\"value\":{\"packageName\":\"@proteinjs/ui\",\"name\":\"Page\",\"filePath\":\"/Users/veronica/Documents/n3xa/n3xa-meta-repo/packages/proteinjs/packages/ui/packages/ui/src/router/Page.ts\",\"qualifiedName\":\"@proteinjs/ui/Page\",\"properties\":[{\"name\":\"name\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"path\",\"type\":{\"packageName\":\"\",\"name\":\"string | string[]\",\"filePath\":null,\"qualifiedName\":\"/string | string[]\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"component\",\"type\":{\"packageName\":\"\",\"name\":\"React.ComponentType<PageComponentProps>\",\"filePath\":null,\"qualifiedName\":\"/React.ComponentType<PageComponentProps>\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"noPageContainer\",\"type\":{\"packageName\":\"\",\"name\":\"boolean\",\"filePath\":null,\"qualifiedName\":\"/boolean\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":true,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"auth\",\"type\":{\"packageName\":\"@proteinjs/ui\",\"name\":\"{\\n /** If true, the user does not need to be logged in or have any roles to access this page. If blank, defaults to false. */\\n public?: boolean;\\n /** If true, the user does not need to have any roles to access this page, but must be logged in. If blank, defaults to false. */\\n allUsers?: boolean;\\n /** The user must be logged in and have these roles to access this page. If blank, defaults to requiring the 'admin' role. */\\n roles?: string[];\\n }\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/ui/{\\n /** If true, the user does not need to be logged in or have any roles to access this page. If blank, defaults to false. */\\n public?: boolean;\\n /** If true, the user does not need to have any roles to access this page, but must be logged in. If blank, defaults to false. */\\n allUsers?: boolean;\\n /** The user must be logged in and have these roles to access this page. If blank, defaults to requiring the 'admin' role. */\\n roles?: string[];\\n }\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":true,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"pageContainerSxProps\",\"type\":{\"packageName\":\"\",\"name\":\"(theme: Theme) => SxProps\",\"filePath\":null,\"qualifiedName\":\"/(theme: Theme) => SxProps\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":true,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[],\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/reflection\",\"name\":\"Loadable\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/reflection/Loadable\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"sourceType\":3}},{\"v\":\"@proteinjs/reflection/Loadable\"},{\"v\":\"/string | React.ComponentType\"},{\"v\":\"/React.FC\"},{\"v\":\"/Partial\"},{\"v\":\"/React.Component\"}],\"edges\":[{\"v\":\"@proteinjs/ui/Page\",\"w\":\"@proteinjs/reflection/Loadable\",\"value\":\"extends interface\"}]}";
33
+ var sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/ui/Page\",\"value\":{\"packageName\":\"@proteinjs/ui\",\"name\":\"Page\",\"filePath\":\"/home/runner/work/ui/ui/packages/ui/src/router/Page.ts\",\"qualifiedName\":\"@proteinjs/ui/Page\",\"properties\":[{\"name\":\"name\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"path\",\"type\":{\"packageName\":\"\",\"name\":\"string | string[]\",\"filePath\":null,\"qualifiedName\":\"/string | string[]\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"component\",\"type\":{\"packageName\":\"\",\"name\":\"React.ComponentType<PageComponentProps>\",\"filePath\":null,\"qualifiedName\":\"/React.ComponentType<PageComponentProps>\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"noPageContainer\",\"type\":{\"packageName\":\"\",\"name\":\"boolean\",\"filePath\":null,\"qualifiedName\":\"/boolean\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":true,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"auth\",\"type\":{\"packageName\":\"@proteinjs/ui\",\"name\":\"{\\n /** If true, the user does not need to be logged in or have any roles to access this page. If blank, defaults to false. */\\n public?: boolean;\\n /** If true, the user does not need to have any roles to access this page, but must be logged in. If blank, defaults to false. */\\n allUsers?: boolean;\\n /** The user must be logged in and have these roles to access this page. If blank, defaults to requiring the 'admin' role. */\\n roles?: string[];\\n }\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/ui/{\\n /** If true, the user does not need to be logged in or have any roles to access this page. If blank, defaults to false. */\\n public?: boolean;\\n /** If true, the user does not need to have any roles to access this page, but must be logged in. If blank, defaults to false. */\\n allUsers?: boolean;\\n /** The user must be logged in and have these roles to access this page. If blank, defaults to requiring the 'admin' role. */\\n roles?: string[];\\n }\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":true,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"pageContainerSxProps\",\"type\":{\"packageName\":\"\",\"name\":\"(theme: Theme) => SxProps\",\"filePath\":null,\"qualifiedName\":\"/(theme: Theme) => SxProps\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":true,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[],\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/reflection\",\"name\":\"Loadable\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/reflection/Loadable\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"sourceType\":3}},{\"v\":\"@proteinjs/reflection/Loadable\"},{\"v\":\"/string | React.ComponentType\"},{\"v\":\"/React.FC\"},{\"v\":\"/Partial\"},{\"v\":\"/React.Component\"}],\"edges\":[{\"v\":\"@proteinjs/ui/Page\",\"w\":\"@proteinjs/reflection/Loadable\",\"value\":\"extends interface\"}]}";
34
34
  /** Generate Source Links */
35
35
  var sourceLinks = {};
36
36
  /** Load Source Graph and Links */
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;;;;;;;;;;;;;;AAEpC,0BAAwB;AACxB,2BAAyB;AACzB,+BAA6B;AAC7B,yBAAuB;AACvB,iCAA+B;AAC/B,2BAAyB;AACzB,mBAAiB;AACjB,kBAAgB;AAChB,wBAAsB;AACtB,iBAAe;AACf,qBAAmB;AACnB,wBAAsB;AACtB,4BAA0B;AAC1B,kBAAgB;AAGhB,4BAA4B;AAE5B,IAAM,WAAW,GAAG,w/GAAw/G,CAAC;AAG7gH,4BAA4B;AAG5B,IAAM,WAAW,GAAG,EACnB,CAAC;AAGF,kCAAkC;AAElC,oDAAyD;AACzD,6BAAgB,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAGjD,2CAAyB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;;;;;;;;;;;;;;AAEpC,0BAAwB;AACxB,2BAAyB;AACzB,+BAA6B;AAC7B,yBAAuB;AACvB,iCAA+B;AAC/B,2BAAyB;AACzB,mBAAiB;AACjB,kBAAgB;AAChB,wBAAsB;AACtB,iBAAe;AACf,qBAAmB;AACnB,wBAAsB;AACtB,4BAA0B;AAC1B,kBAAgB;AAGhB,4BAA4B;AAE5B,IAAM,WAAW,GAAG,m8GAAm8G,CAAC;AAGx9G,4BAA4B;AAG5B,IAAM,WAAW,GAAG,EACnB,CAAC;AAGF,kCAAkC;AAElC,oDAAyD;AACzD,6BAAgB,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAGjD,2CAAyB"}
package/dist/index.d.ts CHANGED
@@ -7,8 +7,8 @@ export * from './src/form/fields/TextField';
7
7
  export * from './src/form/container/FormPaper';
8
8
  export * from './src/form/container/FormPage';
9
9
  export * from './src/container/PageContainer';
10
+ export * from './src/container/AccountAuth';
10
11
  export * from './src/container/NavMenu';
11
- export * from './src/list/NestedList';
12
12
  export * from './src/table/Table';
13
13
  export * from './src/table/TableButton';
14
14
  export * from './src/table/TableLoader';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAElC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAE9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AAExC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAElC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAE9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AAExC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -23,8 +23,8 @@ __exportStar(require("./src/form/fields/TextField"), exports);
23
23
  __exportStar(require("./src/form/container/FormPaper"), exports);
24
24
  __exportStar(require("./src/form/container/FormPage"), exports);
25
25
  __exportStar(require("./src/container/PageContainer"), exports);
26
+ __exportStar(require("./src/container/AccountAuth"), exports);
26
27
  __exportStar(require("./src/container/NavMenu"), exports);
27
- __exportStar(require("./src/list/NestedList"), exports);
28
28
  __exportStar(require("./src/table/Table"), exports);
29
29
  __exportStar(require("./src/table/TableButton"), exports);
30
30
  __exportStar(require("./src/table/TableLoader"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,oDAAkC;AAElC,kDAAgC;AAChC,mDAAiC;AACjC,wDAAsC;AAEtC,8DAA4C;AAE5C,iEAA+C;AAC/C,gEAA8C;AAE9C,gEAA8C;AAC9C,0DAAwC;AAExC,wDAAsC;AAEtC,oDAAkC;AAClC,0DAAwC;AACxC,0DAAwC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,oDAAkC;AAElC,kDAAgC;AAChC,mDAAiC;AACjC,wDAAsC;AAEtC,8DAA4C;AAE5C,iEAA+C;AAC/C,gEAA8C;AAE9C,gEAA8C;AAC9C,8DAA4C;AAC5C,0DAAwC;AAExC,oDAAkC;AAClC,0DAAwC;AACxC,0DAAwC"}
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { Page } from '../router/Page';
3
+ import { LinkOrDialog } from './NavMenu';
4
+ export type AccountAuth = {
5
+ isLoggedIn: boolean;
6
+ canViewPage: (page: Page) => boolean;
7
+ /** Either a dialog component, or a path to be redirected to */
8
+ login: LinkOrDialog;
9
+ logout: () => Promise<string>;
10
+ };
11
+ interface LoginProps {
12
+ auth: AccountAuth;
13
+ loginClicked: boolean;
14
+ setLoginClicked: React.Dispatch<React.SetStateAction<boolean>>;
15
+ }
16
+ export declare function LoginComponent({ auth, loginClicked, setLoginClicked }: LoginProps): React.JSX.Element | null;
17
+ export declare function useAuthActions(auth: AccountAuth | undefined, loginClicked: boolean, setLoginClicked: React.Dispatch<React.SetStateAction<boolean>>): {
18
+ login: () => void;
19
+ logout: () => Promise<void>;
20
+ };
21
+ export declare function qualifiedPath(path: string): string;
22
+ export {};
23
+ //# sourceMappingURL=AccountAuth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountAuth.d.ts","sourceRoot":"","sources":["../../../src/container/AccountAuth.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;IACrC,+DAA+D;IAC/D,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CAC/B,CAAC;AAEF,UAAU,UAAU;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;CAChE;AAED,wBAAgB,cAAc,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,eAAe,EAAE,EAAE,UAAU,4BAQjF;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,YAAY,EAAE,OAAO,EACrB,eAAe,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;;;EAqB/D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,UAMzC"}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.qualifiedPath = exports.useAuthActions = exports.LoginComponent = void 0;
43
+ var react_1 = __importDefault(require("react"));
44
+ var react_router_dom_1 = require("react-router-dom");
45
+ function LoginComponent(_a) {
46
+ var auth = _a.auth, loginClicked = _a.loginClicked, setLoginClicked = _a.setLoginClicked;
47
+ if (!loginClicked || !auth || typeof auth.login === 'string') {
48
+ return null;
49
+ }
50
+ var LoginComponent = auth.login;
51
+ return react_1.default.createElement(LoginComponent, { onClose: function () { return setLoginClicked(false); } });
52
+ }
53
+ exports.LoginComponent = LoginComponent;
54
+ function useAuthActions(auth, loginClicked, setLoginClicked) {
55
+ var _this = this;
56
+ var navigate = (0, react_router_dom_1.useNavigate)();
57
+ var logout = function () { return __awaiter(_this, void 0, void 0, function () {
58
+ var redirectPath;
59
+ return __generator(this, function (_a) {
60
+ switch (_a.label) {
61
+ case 0:
62
+ if (!auth) {
63
+ return [2 /*return*/];
64
+ }
65
+ return [4 /*yield*/, auth.logout()];
66
+ case 1:
67
+ redirectPath = _a.sent();
68
+ navigate(qualifiedPath(redirectPath));
69
+ return [2 /*return*/];
70
+ }
71
+ });
72
+ }); };
73
+ var login = function () {
74
+ if (auth && typeof auth.login === 'string') {
75
+ navigate(qualifiedPath(auth.login));
76
+ }
77
+ else {
78
+ setLoginClicked(!loginClicked);
79
+ }
80
+ };
81
+ return { login: login, logout: logout };
82
+ }
83
+ exports.useAuthActions = useAuthActions;
84
+ function qualifiedPath(path) {
85
+ if (path.startsWith('/')) {
86
+ return path;
87
+ }
88
+ return "/".concat(path);
89
+ }
90
+ exports.qualifiedPath = qualifiedPath;
91
+ //# sourceMappingURL=AccountAuth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountAuth.js","sourceRoot":"","sources":["../../../src/container/AccountAuth.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAG1B,qDAA+C;AAgB/C,SAAgB,cAAc,CAAC,EAAmD;QAAjD,IAAI,UAAA,EAAE,YAAY,kBAAA,EAAE,eAAe,qBAAA;IAClE,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE;QAC5D,OAAO,IAAI,CAAC;KACb;IAED,IAAM,cAAc,GAAG,IAAI,CAAC,KAAqD,CAAC;IAElF,OAAO,8BAAC,cAAc,IAAC,OAAO,EAAE,cAAM,OAAA,eAAe,CAAC,KAAK,CAAC,EAAtB,CAAsB,GAAI,CAAC;AACnE,CAAC;AARD,wCAQC;AAED,SAAgB,cAAc,CAC5B,IAA6B,EAC7B,YAAqB,EACrB,eAA8D;IAHhE,iBAwBC;IAnBC,IAAM,QAAQ,GAAG,IAAA,8BAAW,GAAE,CAAC;IAE/B,IAAM,MAAM,GAAG;;;;;oBACb,IAAI,CAAC,IAAI,EAAE;wBACT,sBAAO;qBACR;oBACoB,qBAAM,IAAI,CAAC,MAAM,EAAE,EAAA;;oBAAlC,YAAY,GAAG,SAAmB;oBACxC,QAAQ,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;;;;SACvC,CAAC;IAEF,IAAM,KAAK,GAAG;QACZ,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE;YAC1C,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;SACrC;aAAM;YACL,eAAe,CAAC,CAAC,YAAY,CAAC,CAAC;SAChC;IACH,CAAC,CAAC;IAEF,OAAO,EAAE,KAAK,OAAA,EAAE,MAAM,QAAA,EAAE,CAAC;AAC3B,CAAC;AAxBD,wCAwBC;AAED,SAAgB,aAAa,CAAC,IAAY;IACxC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QACxB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,WAAI,IAAI,CAAE,CAAC;AACpB,CAAC;AAND,sCAMC"}
@@ -1,19 +1,13 @@
1
1
  import React from 'react';
2
2
  import { LinkOrDialog } from './NavMenu';
3
- import { Page } from '../router/Page';
3
+ import { AccountAuth } from './AccountAuth';
4
4
  export type AccountIconButtonProps = {
5
5
  loginClicked: boolean;
6
6
  setLoginClicked: React.Dispatch<React.SetStateAction<boolean>>;
7
- auth?: {
8
- isLoggedIn: boolean;
9
- canViewPage: (page: Page) => boolean;
10
- /** Either a dialog component, or a path to be redirected to */
11
- login: LinkOrDialog;
12
- logout: () => Promise<string>;
13
- };
7
+ auth?: AccountAuth;
14
8
  profileMenuItems?: {
15
9
  menuItemChildren: React.ReactNode;
16
- action: LinkOrDialog | (() => void);
10
+ action?: LinkOrDialog;
17
11
  }[];
18
12
  };
19
13
  export declare const AccountIconButton: ({ loginClicked, setLoginClicked, auth, profileMenuItems, }: AccountIconButtonProps) => React.JSX.Element | null;
@@ -1 +1 @@
1
- {"version":3,"file":"AccountIconButton.d.ts","sourceRoot":"","sources":["../../../src/container/AccountIconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAGtC,MAAM,MAAM,sBAAsB,GAAG;IACnC,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/D,IAAI,CAAC,EAAE;QACL,UAAU,EAAE,OAAO,CAAC;QACpB,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;QACrC,+DAA+D;QAC/D,KAAK,EAAE,YAAY,CAAC;QACpB,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;KAC/B,CAAC;IACF,gBAAgB,CAAC,EAAE;QAAE,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC;QAAC,MAAM,EAAE,YAAY,GAAG,CAAC,MAAM,IAAI,CAAC,CAAA;KAAE,EAAE,CAAC;CACjG,CAAC;AAEF,eAAO,MAAM,iBAAiB,+DAK3B,sBAAsB,6BA+GxB,CAAC"}
1
+ {"version":3,"file":"AccountIconButton.d.ts","sourceRoot":"","sources":["../../../src/container/AccountIconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAiD,MAAM,eAAe,CAAC;AAE3F,MAAM,MAAM,sBAAsB,GAAG;IACnC,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/D,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,gBAAgB,CAAC,EAAE;QAAE,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC;QAAC,MAAM,CAAC,EAAE,YAAY,CAAA;KAAE,EAAE,CAAC;CACnF,CAAC;AAEF,eAAO,MAAM,iBAAiB,+DAK3B,sBAAsB,6BAqFxB,CAAC"}
@@ -1,40 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
39
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
4
  };
@@ -45,12 +9,14 @@ var material_1 = require("@mui/material");
45
9
  var AccountCircle_1 = __importDefault(require("@mui/icons-material/AccountCircle"));
46
10
  var react_router_dom_1 = require("react-router-dom");
47
11
  var Logout_1 = __importDefault(require("@mui/icons-material/Logout"));
12
+ var AccountAuth_1 = require("./AccountAuth");
48
13
  var AccountIconButton = function (_a) {
49
14
  var loginClicked = _a.loginClicked, setLoginClicked = _a.setLoginClicked, auth = _a.auth, profileMenuItems = _a.profileMenuItems;
50
15
  var navigate = (0, react_router_dom_1.useNavigate)();
51
- var _b = react_1.default.useState(-1), selectedProfileMenuItem = _b[0], setSelectedProfileMenuItem = _b[1];
52
- var _c = react_1.default.useState(1), selectedIndex = _c[0], setSelectedIndex = _c[1];
53
- var _d = react_1.default.useState(null), anchorEl = _d[0], setAccountMenuAnchorEl = _d[1];
16
+ var _b = (0, AccountAuth_1.useAuthActions)(auth, loginClicked, setLoginClicked), logout = _b.logout, login = _b.login;
17
+ var _c = react_1.default.useState(-1), selectedProfileMenuItem = _c[0], setSelectedProfileMenuItem = _c[1];
18
+ var _d = react_1.default.useState(1), selectedIndex = _d[0], setSelectedIndex = _d[1];
19
+ var _e = react_1.default.useState(null), anchorEl = _e[0], setAccountMenuAnchorEl = _e[1];
54
20
  var open = Boolean(anchorEl);
55
21
  if (!auth) {
56
22
  return null;
@@ -69,7 +35,7 @@ var AccountIconButton = function (_a) {
69
35
  profileMenuItems &&
70
36
  profileMenuItems.map(function (profileMenuItem, index) { return (react_1.default.createElement(material_1.MenuItem, { key: index, onClick: function (event) {
71
37
  if (typeof profileMenuItem.action === 'string') {
72
- navigate(qualifiedPath(profileMenuItem.action));
38
+ navigate((0, AccountAuth_1.qualifiedPath)(profileMenuItem.action));
73
39
  return;
74
40
  }
75
41
  else if (isFunction(profileMenuItem.action)) {
@@ -80,28 +46,15 @@ var AccountIconButton = function (_a) {
80
46
  setSelectedIndex(index);
81
47
  }
82
48
  }, selected: selectedIndex === index }, profileMenuItem.menuItemChildren)); }),
83
- react_1.default.createElement(material_1.MenuItem, { key: 'logout', onClick: function (event) { return __awaiter(void 0, void 0, void 0, function () {
84
- var redirectPath;
85
- return __generator(this, function (_a) {
86
- switch (_a.label) {
87
- case 0: return [4 /*yield*/, auth.logout()];
88
- case 1:
89
- redirectPath = _a.sent();
90
- navigate(qualifiedPath(redirectPath));
91
- return [2 /*return*/];
92
- }
93
- });
94
- }); } },
49
+ react_1.default.createElement(material_1.MenuItem, { key: 'logout', onClick: logout },
95
50
  react_1.default.createElement(material_1.ListItemIcon, null,
96
51
  react_1.default.createElement(Logout_1.default, null)),
97
52
  react_1.default.createElement(material_1.Typography, null, "Logout"))),
98
53
  react_1.default.createElement(ProfileMenuItemAction, null)));
99
54
  }
100
55
  return (react_1.default.createElement("div", null,
101
- react_1.default.createElement(material_1.Button, { color: 'inherit', onClick: function (event) {
102
- return auth && typeof auth.login === 'string' ? navigate(qualifiedPath(auth.login)) : setLoginClicked(!loginClicked);
103
- } }, "Login"),
104
- react_1.default.createElement(Login, null)));
56
+ react_1.default.createElement(material_1.Button, { color: 'inherit', onClick: login }, "Login"),
57
+ react_1.default.createElement(AccountAuth_1.LoginComponent, { auth: auth, loginClicked: loginClicked, setLoginClicked: setLoginClicked })));
105
58
  function ProfileMenuItemAction() {
106
59
  if (selectedProfileMenuItem == -1 || !auth || !profileMenuItems) {
107
60
  return null;
@@ -115,18 +68,6 @@ var AccountIconButton = function (_a) {
115
68
  }
116
69
  return null;
117
70
  }
118
- function Login() {
119
- if (!loginClicked || !auth || typeof auth.login === 'string') {
120
- return null;
121
- }
122
- return react_1.default.createElement(auth.login, { onClose: function () { return setLoginClicked(false); } });
123
- }
124
- function qualifiedPath(path) {
125
- if (path.startsWith('/')) {
126
- return path;
127
- }
128
- return "/".concat(path);
129
- }
130
71
  };
131
72
  exports.AccountIconButton = AccountIconButton;
132
73
  function isDialog(prop) {
@@ -1 +1 @@
1
- {"version":3,"file":"AccountIconButton.js","sourceRoot":"","sources":["../../../src/container/AccountIconButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,0CAA6F;AAC7F,oFAA8D;AAC9D,qDAA+C;AAG/C,sEAAoD;AAe7C,IAAM,iBAAiB,GAAG,UAAC,EAKT;QAJvB,YAAY,kBAAA,EACZ,eAAe,qBAAA,EACf,IAAI,UAAA,EACJ,gBAAgB,sBAAA;IAEhB,IAAM,QAAQ,GAAG,IAAA,8BAAW,GAAE,CAAC;IACzB,IAAA,KAAwD,eAAK,CAAC,QAAQ,CAAS,CAAC,CAAC,CAAC,EAAjF,uBAAuB,QAAA,EAAE,0BAA0B,QAA8B,CAAC;IACnF,IAAA,KAAoC,eAAK,CAAC,QAAQ,CAAS,CAAC,CAAC,EAA5D,aAAa,QAAA,EAAE,gBAAgB,QAA6B,CAAC;IAC9D,IAAA,KAAqC,eAAK,CAAC,QAAQ,CAAqB,IAAI,CAAC,EAA5E,QAAQ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AAI,IAAI,CAAC,SAAS,CAAC;AACnE,CAAC;AAED,SAAS,UAAU,CAAC,IAAS;IAC3B,OAAO,OAAO,IAAI,KAAK,UAAU,CAAC;AACpC,CAAC"}
@@ -3,24 +3,22 @@ import { AppBarProps, ToolbarProps } from '@mui/material';
3
3
  import { NavigateFunction } from 'react-router-dom';
4
4
  import { Page } from '../router/Page';
5
5
  import { LinkOrDialog, NavMenuItem } from './NavMenu';
6
+ import { AccountIconButtonProps } from './AccountIconButton';
7
+ import { AccountAuth } from './AccountAuth';
6
8
  export type PageContainerProps = {
7
9
  page: Page;
8
- auth?: {
9
- isLoggedIn: boolean;
10
- canViewPage: (page: Page) => boolean;
11
- login: LinkOrDialog;
12
- logout: () => Promise<string>;
13
- };
10
+ auth?: AccountAuth;
14
11
  appName?: string;
15
12
  toolbarChildren?: React.ReactNode;
16
13
  /** An array of menu items, each containing a React node and an action triggered when selected, either a string, dialog component, or a function. */
17
14
  profileMenuItems?: {
18
15
  menuItemChildren: React.ReactNode;
19
- action: LinkOrDialog | (() => void);
16
+ action?: LinkOrDialog;
20
17
  }[];
21
18
  navMenuItems?: NavMenuItem[];
22
19
  appBarProps?: AppBarProps;
23
20
  toolbarProps?: ToolbarProps;
21
+ CustomAccountIconButton?: React.ComponentType<AccountIconButtonProps>;
24
22
  };
25
23
  declare const Page: React.MemoExoticComponent<({ auth, page, navigate, loginClicked, setLoginClicked, }: {
26
24
  auth: PageContainerProps['auth'];
@@ -1 +1 @@
1
- {"version":3,"file":"PageContainer.d.ts","sourceRoot":"","sources":["../../../src/container/PageContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAgE,WAAW,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAExH,OAAO,EAAE,gBAAgB,EAAe,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAW,WAA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AW,CAAC;AAC/D,OAAO,EAAqB,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAU5C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAClC,oJAAoJ;IACpJ,gBAAgB,CAAC,EAAE;QAAE,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC;QAAC,MAAM,CAAC,EAAE,YAAY,CAAA;KAAE,EAAE,CAAC;IAClF,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAC7B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,uBAAuB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,sBAAsB,CAAC,CAAC;CACvE,CAAC;AAEF,QAAA,MAAM,IAAI;UAQA,kBAAkB,CAAC,MAAM,CAAC;UAC1B,kBAAkB,CAAC,MAAM,CAAC;cACtB,gBAAgB;kBACZ,OAAO;oCACW,OAAO,KAAK,IAAI;+BAiBnD,CAAC;AAEF,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,qBAqFtD"}
@@ -44,7 +44,7 @@ var Page = react_1.default.memo(function (_a) {
44
44
  });
45
45
  function PageContainer(props) {
46
46
  var navigate = (0, react_router_dom_1.useNavigate)();
47
- var page = props.page, auth = props.auth, navMenuItems = props.navMenuItems, appName = props.appName, toolbarChildren = props.toolbarChildren, profileMenuItems = props.profileMenuItems, appBarProps = props.appBarProps, toolbarProps = props.toolbarProps;
47
+ var page = props.page, auth = props.auth, navMenuItems = props.navMenuItems, appName = props.appName, toolbarChildren = props.toolbarChildren, profileMenuItems = props.profileMenuItems, appBarProps = props.appBarProps, toolbarProps = props.toolbarProps, CustomAccountIconButton = props.CustomAccountIconButton;
48
48
  var _a = react_1.default.useState(false), loginClicked = _a[0], setLoginClicked = _a[1];
49
49
  var _b = react_1.default.useState(false), navMenuOpen = _b[0], setNavMenuOpen = _b[1];
50
50
  react_1.default.useEffect(function () {
@@ -79,7 +79,7 @@ function PageContainer(props) {
79
79
  appName && (react_1.default.createElement(material_1.Typography, { variant: 'h5', sx: { flexGrow: 1, color: 'common.white' } }, appName)),
80
80
  toolbarChildren,
81
81
  react_1.default.createElement("div", { style: { flexGrow: 1 } }),
82
- react_1.default.createElement(AccountIconButton_1.AccountIconButton, __assign({ loginClicked: loginClicked, setLoginClicked: setLoginClicked, auth: auth }, (profileMenuItems ? { profileMenuItems: profileMenuItems } : {}))))),
82
+ CustomAccountIconButton ? (react_1.default.createElement(CustomAccountIconButton, { loginClicked: loginClicked, setLoginClicked: setLoginClicked, auth: auth })) : (react_1.default.createElement(AccountIconButton_1.AccountIconButton, __assign({ loginClicked: loginClicked, setLoginClicked: setLoginClicked, auth: auth }, (profileMenuItems ? { profileMenuItems: profileMenuItems } : {})))))),
83
83
  navMenuItems && (react_1.default.createElement(NavMenu_1.NavMenu, { navMenuItems: navMenuItems, navMenuOpen: navMenuOpen, setNavMenuOpen: setNavMenuOpen })),
84
84
  react_1.default.createElement(Page, { auth: auth, page: page, navigate: navigate, loginClicked: loginClicked, setLoginClicked: setLoginClicked })));
85
85
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PageContainer.js","sourceRoot":"","sources":["../../../src/container/PageContainer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,0CAAwH;AACxH,kEAAgD;AAChD,qDAAiE;AAEjE,6DAA4D;AAC5D,qCAA+D;AAC/D,yDAAwD;AAExD,SAAS,aAAa,CAAC,IAAY;IACjC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QACxB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,WAAI,IAAI,CAAE,CAAC;A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8BAAC,qBAAU,IAAC,OAAO,EAAC,IAAI,EAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,IAChE,OAAO,CACG,CACd;gBACA,eAAe;gBAChB,uCAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAQ;gBAClC,uBAAuB,CAAC,CAAC,CAAC,CACzB,8BAAC,uBAAuB,IAAC,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,GAAI,CACtG,CAAC,CAAC,CAAC,CACF,8BAAC,qCAAiB,aAChB,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,IAAI,IACN,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,kBAAA,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAClD,CACH,CACO,CACH;QACR,YAAY,IAAI,CACf,8BAAC,iBAAO,IAAC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,GAAI,CAClG;QACD,8BAAC,IAAI,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,GAAI,CAC9G,CACP,CAAC;AACJ,CAAC;AArFD,sCAqFC"}
@@ -18,7 +18,7 @@ import 'string';
18
18
 
19
19
  /** Generate Source Graph */
20
20
 
21
- const sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/ui/Page\",\"value\":{\"packageName\":\"@proteinjs/ui\",\"name\":\"Page\",\"filePath\":\"/Users/veronica/Documents/n3xa/n3xa-meta-repo/packages/proteinjs/packages/ui/packages/ui/src/router/Page.ts\",\"qualifiedName\":\"@proteinjs/ui/Page\",\"properties\":[{\"name\":\"name\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"path\",\"type\":{\"packageName\":\"\",\"name\":\"string | string[]\",\"filePath\":null,\"qualifiedName\":\"/string | string[]\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"component\",\"type\":{\"packageName\":\"\",\"name\":\"React.ComponentType<PageComponentProps>\",\"filePath\":null,\"qualifiedName\":\"/React.ComponentType<PageComponentProps>\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"noPageContainer\",\"type\":{\"packageName\":\"\",\"name\":\"boolean\",\"filePath\":null,\"qualifiedName\":\"/boolean\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":true,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"auth\",\"type\":{\"packageName\":\"@proteinjs/ui\",\"name\":\"{\\n /** If true, the user does not need to be logged in or have any roles to access this page. If blank, defaults to false. */\\n public?: boolean;\\n /** If true, the user does not need to have any roles to access this page, but must be logged in. If blank, defaults to false. */\\n allUsers?: boolean;\\n /** The user must be logged in and have these roles to access this page. If blank, defaults to requiring the 'admin' role. */\\n roles?: string[];\\n }\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/ui/{\\n /** If true, the user does not need to be logged in or have any roles to access this page. If blank, defaults to false. */\\n public?: boolean;\\n /** If true, the user does not need to have any roles to access this page, but must be logged in. If blank, defaults to false. */\\n allUsers?: boolean;\\n /** The user must be logged in and have these roles to access this page. If blank, defaults to requiring the 'admin' role. */\\n roles?: string[];\\n }\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":true,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"pageContainerSxProps\",\"type\":{\"packageName\":\"\",\"name\":\"(theme: Theme) => SxProps\",\"filePath\":null,\"qualifiedName\":\"/(theme: Theme) => SxProps\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":true,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[],\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/reflection\",\"name\":\"Loadable\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/reflection/Loadable\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"sourceType\":3}},{\"v\":\"@proteinjs/reflection/Loadable\"},{\"v\":\"/string | React.ComponentType\"},{\"v\":\"/React.FC\"},{\"v\":\"/Partial\"},{\"v\":\"/React.Component\"}],\"edges\":[{\"v\":\"@proteinjs/ui/Page\",\"w\":\"@proteinjs/reflection/Loadable\",\"value\":\"extends interface\"}]}";
21
+ const sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/ui/Page\",\"value\":{\"packageName\":\"@proteinjs/ui\",\"name\":\"Page\",\"filePath\":\"/home/runner/work/ui/ui/packages/ui/src/router/Page.ts\",\"qualifiedName\":\"@proteinjs/ui/Page\",\"properties\":[{\"name\":\"name\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"path\",\"type\":{\"packageName\":\"\",\"name\":\"string | string[]\",\"filePath\":null,\"qualifiedName\":\"/string | string[]\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"component\",\"type\":{\"packageName\":\"\",\"name\":\"React.ComponentType<PageComponentProps>\",\"filePath\":null,\"qualifiedName\":\"/React.ComponentType<PageComponentProps>\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"noPageContainer\",\"type\":{\"packageName\":\"\",\"name\":\"boolean\",\"filePath\":null,\"qualifiedName\":\"/boolean\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":true,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"auth\",\"type\":{\"packageName\":\"@proteinjs/ui\",\"name\":\"{\\n /** If true, the user does not need to be logged in or have any roles to access this page. If blank, defaults to false. */\\n public?: boolean;\\n /** If true, the user does not need to have any roles to access this page, but must be logged in. If blank, defaults to false. */\\n allUsers?: boolean;\\n /** The user must be logged in and have these roles to access this page. If blank, defaults to requiring the 'admin' role. */\\n roles?: string[];\\n }\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/ui/{\\n /** If true, the user does not need to be logged in or have any roles to access this page. If blank, defaults to false. */\\n public?: boolean;\\n /** If true, the user does not need to have any roles to access this page, but must be logged in. If blank, defaults to false. */\\n allUsers?: boolean;\\n /** The user must be logged in and have these roles to access this page. If blank, defaults to requiring the 'admin' role. */\\n roles?: string[];\\n }\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":true,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"pageContainerSxProps\",\"type\":{\"packageName\":\"\",\"name\":\"(theme: Theme) => SxProps\",\"filePath\":null,\"qualifiedName\":\"/(theme: Theme) => SxProps\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":true,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[],\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/reflection\",\"name\":\"Loadable\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/reflection/Loadable\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"sourceType\":3}},{\"v\":\"@proteinjs/reflection/Loadable\"},{\"v\":\"/string | React.ComponentType\"},{\"v\":\"/React.FC\"},{\"v\":\"/Partial\"},{\"v\":\"/React.Component\"}],\"edges\":[{\"v\":\"@proteinjs/ui/Page\",\"w\":\"@proteinjs/reflection/Loadable\",\"value\":\"extends interface\"}]}";
22
22
 
23
23
 
24
24
  /** Generate Source Links */
package/index.ts CHANGED
@@ -11,10 +11,9 @@ export * from './src/form/container/FormPaper';
11
11
  export * from './src/form/container/FormPage';
12
12
 
13
13
  export * from './src/container/PageContainer';
14
+ export * from './src/container/AccountAuth';
14
15
  export * from './src/container/NavMenu';
15
16
 
16
- export * from './src/list/NestedList';
17
-
18
17
  export * from './src/table/Table';
19
18
  export * from './src/table/TableButton';
20
19
  export * from './src/table/TableLoader';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proteinjs/ui",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "UI libs",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -52,5 +52,6 @@
52
52
  "typescript": "5.2.2"
53
53
  },
54
54
  "main": "./dist/generated/index.js",
55
- "types": "./dist/generated/index.d.ts"
56
- }
55
+ "types": "./dist/generated/index.d.ts",
56
+ "gitHead": "49ab325eb7fdf9e48b0401f9a5c4a433bc5a442e"
57
+ }
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import { Page } from '../router/Page';
3
+ import { LinkOrDialog } from './NavMenu';
4
+ import { useNavigate } from 'react-router-dom';
5
+
6
+ export type AccountAuth = {
7
+ isLoggedIn: boolean;
8
+ canViewPage: (page: Page) => boolean;
9
+ /** Either a dialog component, or a path to be redirected to */
10
+ login: LinkOrDialog;
11
+ logout: () => Promise<string>;
12
+ };
13
+
14
+ interface LoginProps {
15
+ auth: AccountAuth;
16
+ loginClicked: boolean;
17
+ setLoginClicked: React.Dispatch<React.SetStateAction<boolean>>;
18
+ }
19
+
20
+ export function LoginComponent({ auth, loginClicked, setLoginClicked }: LoginProps) {
21
+ if (!loginClicked || !auth || typeof auth.login === 'string') {
22
+ return null;
23
+ }
24
+
25
+ const LoginComponent = auth.login as React.ComponentType<{ onClose: () => void }>;
26
+
27
+ return <LoginComponent onClose={() => setLoginClicked(false)} />;
28
+ }
29
+
30
+ export function useAuthActions(
31
+ auth: AccountAuth | undefined,
32
+ loginClicked: boolean,
33
+ setLoginClicked: React.Dispatch<React.SetStateAction<boolean>>
34
+ ) {
35
+ const navigate = useNavigate();
36
+
37
+ const logout = async () => {
38
+ if (!auth) {
39
+ return;
40
+ }
41
+ const redirectPath = await auth.logout();
42
+ navigate(qualifiedPath(redirectPath));
43
+ };
44
+
45
+ const login = () => {
46
+ if (auth && typeof auth.login === 'string') {
47
+ navigate(qualifiedPath(auth.login));
48
+ } else {
49
+ setLoginClicked(!loginClicked);
50
+ }
51
+ };
52
+
53
+ return { login, logout };
54
+ }
55
+
56
+ export function qualifiedPath(path: string) {
57
+ if (path.startsWith('/')) {
58
+ return path;
59
+ }
60
+
61
+ return `/${path}`;
62
+ }
@@ -3,20 +3,14 @@ import { Button, IconButton, ListItemIcon, Menu, MenuItem, Typography } from '@m
3
3
  import AccountCircle from '@mui/icons-material/AccountCircle';
4
4
  import { useNavigate } from 'react-router-dom';
5
5
  import { LinkOrDialog } from './NavMenu';
6
- import { Page } from '../router/Page';
7
6
  import LogoutIcon from '@mui/icons-material/Logout';
7
+ import { AccountAuth, LoginComponent, qualifiedPath, useAuthActions } from './AccountAuth';
8
8
 
9
9
  export type AccountIconButtonProps = {
10
10
  loginClicked: boolean;
11
11
  setLoginClicked: React.Dispatch<React.SetStateAction<boolean>>;
12
- auth?: {
13
- isLoggedIn: boolean;
14
- canViewPage: (page: Page) => boolean;
15
- /** Either a dialog component, or a path to be redirected to */
16
- login: LinkOrDialog;
17
- logout: () => Promise<string>;
18
- };
19
- profileMenuItems?: { menuItemChildren: React.ReactNode; action: LinkOrDialog | (() => void) }[];
12
+ auth?: AccountAuth;
13
+ profileMenuItems?: { menuItemChildren: React.ReactNode; action?: LinkOrDialog }[];
20
14
  };
21
15
 
22
16
  export const AccountIconButton = ({
@@ -26,6 +20,7 @@ export const AccountIconButton = ({
26
20
  profileMenuItems,
27
21
  }: AccountIconButtonProps) => {
28
22
  const navigate = useNavigate();
23
+ const { logout, login } = useAuthActions(auth, loginClicked, setLoginClicked);
29
24
  const [selectedProfileMenuItem, setSelectedProfileMenuItem] = React.useState<number>(-1);
30
25
  const [selectedIndex, setSelectedIndex] = React.useState<number>(1);
31
26
  const [anchorEl, setAccountMenuAnchorEl] = React.useState<null | HTMLElement>(null);
@@ -71,13 +66,7 @@ export const AccountIconButton = ({
71
66
  {profileMenuItem.menuItemChildren}
72
67
  </MenuItem>
73
68
  ))}
74
- <MenuItem
75
- key='logout'
76
- onClick={async (event) => {
77
- const redirectPath = await auth.logout();
78
- navigate(qualifiedPath(redirectPath));
79
- }}
80
- >
69
+ <MenuItem key='logout' onClick={logout}>
81
70
  <ListItemIcon>
82
71
  <LogoutIcon />
83
72
  </ListItemIcon>
@@ -91,15 +80,10 @@ export const AccountIconButton = ({
91
80
 
92
81
  return (
93
82
  <div>
94
- <Button
95
- color='inherit'
96
- onClick={(event) =>
97
- auth && typeof auth.login === 'string' ? navigate(qualifiedPath(auth.login)) : setLoginClicked(!loginClicked)
98
- }
99
- >
83
+ <Button color='inherit' onClick={login}>
100
84
  Login
101
85
  </Button>
102
- <Login />
86
+ <LoginComponent auth={auth} loginClicked={loginClicked} setLoginClicked={setLoginClicked} />
103
87
  </div>
104
88
  );
105
89
 
@@ -119,22 +103,6 @@ export const AccountIconButton = ({
119
103
 
120
104
  return null;
121
105
  }
122
-
123
- function Login() {
124
- if (!loginClicked || !auth || typeof auth.login === 'string') {
125
- return null;
126
- }
127
-
128
- return <auth.login onClose={() => setLoginClicked(false)} />;
129
- }
130
-
131
- function qualifiedPath(path: string) {
132
- if (path.startsWith('/')) {
133
- return path;
134
- }
135
-
136
- return `/${path}`;
137
- }
138
106
  };
139
107
 
140
108
  function isDialog(prop: any): prop is React.ComponentType<{ onClose: () => void }> {
@@ -1,11 +1,12 @@
1
1
  import React from 'react';
2
- import { AppBar, Toolbar, Box, IconButton, Typography, Theme, SxProps, AppBarProps, ToolbarProps } from '@mui/material';
2
+ import { AppBar, Toolbar, Box, IconButton, Typography, AppBarProps, ToolbarProps, MenuProps } from '@mui/material';
3
3
  import MenuIcon from '@mui/icons-material/Menu';
4
4
  import { NavigateFunction, useNavigate } from 'react-router-dom';
5
5
  import { Page } from '../router/Page';
6
6
  import { createUrlParams } from '../router/createUrlParams';
7
7
  import { LinkOrDialog, NavMenu, NavMenuItem } from './NavMenu';
8
- import { AccountIconButton } from './AccountIconButton';
8
+ import { AccountIconButton, AccountIconButtonProps } from './AccountIconButton';
9
+ import { AccountAuth } from './AccountAuth';
9
10
 
10
11
  function qualifiedPath(path: string) {
11
12
  if (path.startsWith('/')) {
@@ -17,19 +18,15 @@ function qualifiedPath(path: string) {
17
18
 
18
19
  export type PageContainerProps = {
19
20
  page: Page;
20
- auth?: {
21
- isLoggedIn: boolean;
22
- canViewPage: (page: Page) => boolean;
23
- login: LinkOrDialog;
24
- logout: () => Promise<string>;
25
- };
21
+ auth?: AccountAuth;
26
22
  appName?: string;
27
23
  toolbarChildren?: React.ReactNode;
28
24
  /** An array of menu items, each containing a React node and an action triggered when selected, either a string, dialog component, or a function. */
29
- profileMenuItems?: { menuItemChildren: React.ReactNode; action: LinkOrDialog | (() => void) }[];
25
+ profileMenuItems?: { menuItemChildren: React.ReactNode; action?: LinkOrDialog }[];
30
26
  navMenuItems?: NavMenuItem[];
31
27
  appBarProps?: AppBarProps;
32
28
  toolbarProps?: ToolbarProps;
29
+ CustomAccountIconButton?: React.ComponentType<AccountIconButtonProps>;
33
30
  };
34
31
 
35
32
  const Page = React.memo(
@@ -65,7 +62,17 @@ const Page = React.memo(
65
62
 
66
63
  export function PageContainer(props: PageContainerProps) {
67
64
  const navigate = useNavigate();
68
- const { page, auth, navMenuItems, appName, toolbarChildren, profileMenuItems, appBarProps, toolbarProps } = props;
65
+ const {
66
+ page,
67
+ auth,
68
+ navMenuItems,
69
+ appName,
70
+ toolbarChildren,
71
+ profileMenuItems,
72
+ appBarProps,
73
+ toolbarProps,
74
+ CustomAccountIconButton,
75
+ } = props;
69
76
  const [loginClicked, setLoginClicked] = React.useState(false);
70
77
  const [navMenuOpen, setNavMenuOpen] = React.useState(false);
71
78
 
@@ -120,12 +127,16 @@ export function PageContainer(props: PageContainerProps) {
120
127
  )}
121
128
  {toolbarChildren}
122
129
  <div style={{ flexGrow: 1 }}></div>
123
- <AccountIconButton
124
- loginClicked={loginClicked}
125
- setLoginClicked={setLoginClicked}
126
- auth={auth}
127
- {...(profileMenuItems ? { profileMenuItems } : {})}
128
- />
130
+ {CustomAccountIconButton ? (
131
+ <CustomAccountIconButton loginClicked={loginClicked} setLoginClicked={setLoginClicked} auth={auth} />
132
+ ) : (
133
+ <AccountIconButton
134
+ loginClicked={loginClicked}
135
+ setLoginClicked={setLoginClicked}
136
+ auth={auth}
137
+ {...(profileMenuItems ? { profileMenuItems } : {})}
138
+ />
139
+ )}
129
140
  </Toolbar>
130
141
  </AppBar>
131
142
  {navMenuItems && (
@@ -1,14 +0,0 @@
1
- import React, { ReactElement } from 'react';
2
- export type NestedListItem = {
3
- element: ReactElement;
4
- children?: NestedListItem[];
5
- renderChildren?: boolean;
6
- };
7
- type NestedListProps = {
8
- items: NestedListItem[];
9
- level?: number;
10
- levelColors?: string[];
11
- };
12
- export declare const NestedList: ({ items, level, levelColors }: NestedListProps) => React.JSX.Element;
13
- export {};
14
- //# sourceMappingURL=NestedList.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NestedList.d.ts","sourceRoot":"","sources":["../../../src/list/NestedList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG5C,MAAM,MAAM,cAAc,GAAG;IAAE,OAAO,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAC9G,KAAK,eAAe,GAAG;IAAE,KAAK,EAAE,cAAc,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAO3F,eAAO,MAAM,UAAU,kCAAmC,eAAe,sBA8CxE,CAAC"}
@@ -1,44 +0,0 @@
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.NestedList = void 0;
7
- var react_1 = __importDefault(require("react"));
8
- var material_1 = require("@mui/material");
9
- var blue = '#1976d2';
10
- var green = '#76d275';
11
- var orange = '#ffa726';
12
- var purple = '#ab47bc';
13
- var defaultLevelColors = [blue, green, orange, purple];
14
- var NestedList = function (_a) {
15
- var items = _a.items, level = _a.level, levelColors = _a.levelColors;
16
- var isRoot = typeof level === 'undefined';
17
- var resolvedLevel = level ? level : 0;
18
- var resolvedLevelColors = levelColors ? levelColors : defaultLevelColors;
19
- var flattenedItems = flattenItems(items);
20
- function flattenItems(items) {
21
- var flattened = [];
22
- for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
23
- var item = items_1[_i];
24
- flattened.push(item);
25
- if (item.children && (item.renderChildren || typeof item.renderChildren === 'undefined')) {
26
- flattened.push(item.children);
27
- }
28
- }
29
- return flattened;
30
- }
31
- return (react_1.default.createElement(material_1.Box, { component: 'ul', sx: {
32
- padding: isRoot ? 0 : undefined,
33
- margin: isRoot ? 0 : undefined,
34
- } }, flattenedItems.map(function (item, index) {
35
- return Array.isArray(item) ? (react_1.default.createElement(exports.NestedList, { key: index, items: item, level: resolvedLevel + 1 })) : (react_1.default.createElement(material_1.Box, { key: index, component: 'li', sx: function (theme) { return ({
36
- borderLeft: 3,
37
- borderLeftColor: resolvedLevelColors[resolvedLevel % resolvedLevelColors.length],
38
- listStyleType: 'none',
39
- marginTop: !(isRoot && index == 0) ? theme.spacing(1) : undefined,
40
- }); } }, item.element));
41
- })));
42
- };
43
- exports.NestedList = NestedList;
44
- //# sourceMappingURL=NestedList.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NestedList.js","sourceRoot":"","sources":["../../../src/list/NestedList.tsx"],"names":[],"mappings":";;;;;;AAAA,gDAA4C;AAC5C,0CAAoC;AAIpC,IAAM,IAAI,GAAG,SAAS,CAAC;AACvB,IAAM,KAAK,GAAG,SAAS,CAAC;AACxB,IAAM,MAAM,GAAG,SAAS,CAAC;AACzB,IAAM,MAAM,GAAG,SAAS,CAAC;AACzB,IAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAElD,IAAM,UAAU,GAAG,UAAC,EAA8C;QAA5C,KAAK,WAAA,EAAE,KAAK,WAAA,EAAE,WAAW,iBAAA;IACpD,IAAM,MAAM,GAAG,OAAO,KAAK,KAAK,WAAW,CAAC;IAC5C,IAAM,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,IAAM,mBAAmB,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,kBAAkB,CAAC;IAC3E,IAAM,cAAc,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IAE3C,SAAS,YAAY,CAAC,KAAuB;QAC3C,IAAM,SAAS,GAAG,EAAE,CAAC;QACrB,KAAmB,UAAK,EAAL,eAAK,EAAL,mBAAK,EAAL,IAAK,EAAE;YAArB,IAAM,IAAI,cAAA;YACb,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrB,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,cAAc,IAAI,OAAO,IAAI,CAAC,cAAc,KAAK,WAAW,CAAC,EAAE;gBACxF,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aAC/B;SACF;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,CACL,8BAAC,cAAG,IACF,SAAS,EAAC,IAAI,EACd,EAAE,EAAE;YACF,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;YAC/B,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;SAC/B,IAEA,cAAc,CAAC,GAAG,CAAC,UAAC,IAAI,EAAE,KAAK;QAC9B,OAAA,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CACpB,8BAAC,kBAAU,IAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,GAAG,CAAC,GAAI,CAClE,CAAC,CAAC,CAAC,CACF,8BAAC,cAAG,IACF,GAAG,EAAE,KAAK,EACV,SAAS,EAAC,IAAI,EACd,EAAE,EAAE,UAAC,KAAK,IAAK,OAAA,CAAC;gBACd,UAAU,EAAE,CAAC;gBACb,eAAe,EAAE,mBAAmB,CAAC,aAAa,GAAG,mBAAmB,CAAC,MAAM,CAAC;gBAChF,aAAa,EAAE,MAAM;gBACrB,SAAS,EAAE,CAAC,CAAC,MAAM,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;aAClE,CAAC,EALa,CAKb,IAED,IAAI,CAAC,OAAO,CACT,CACP;IAfD,CAeC,CACF,CACG,CACP,CAAC;AACJ,CAAC,CAAC;AA9CW,QAAA,UAAU,cA8CrB"}
@@ -1,58 +0,0 @@
1
- import React, { ReactElement } from 'react';
2
- import { Box } from '@mui/material';
3
-
4
- export type NestedListItem = { element: ReactElement; children?: NestedListItem[]; renderChildren?: boolean };
5
- type NestedListProps = { items: NestedListItem[]; level?: number; levelColors?: string[] };
6
- const blue = '#1976d2';
7
- const green = '#76d275';
8
- const orange = '#ffa726';
9
- const purple = '#ab47bc';
10
- const defaultLevelColors = [blue, green, orange, purple];
11
-
12
- export const NestedList = ({ items, level, levelColors }: NestedListProps) => {
13
- const isRoot = typeof level === 'undefined';
14
- const resolvedLevel = level ? level : 0;
15
- const resolvedLevelColors = levelColors ? levelColors : defaultLevelColors;
16
- const flattenedItems = flattenItems(items);
17
-
18
- function flattenItems(items: NestedListItem[]): (NestedListItem | NestedListItem[])[] {
19
- const flattened = [];
20
- for (const item of items) {
21
- flattened.push(item);
22
- if (item.children && (item.renderChildren || typeof item.renderChildren === 'undefined')) {
23
- flattened.push(item.children);
24
- }
25
- }
26
-
27
- return flattened;
28
- }
29
-
30
- return (
31
- <Box
32
- component='ul'
33
- sx={{
34
- padding: isRoot ? 0 : undefined,
35
- margin: isRoot ? 0 : undefined,
36
- }}
37
- >
38
- {flattenedItems.map((item, index) =>
39
- Array.isArray(item) ? (
40
- <NestedList key={index} items={item} level={resolvedLevel + 1} />
41
- ) : (
42
- <Box
43
- key={index}
44
- component='li'
45
- sx={(theme) => ({
46
- borderLeft: 3,
47
- borderLeftColor: resolvedLevelColors[resolvedLevel % resolvedLevelColors.length],
48
- listStyleType: 'none',
49
- marginTop: !(isRoot && index == 0) ? theme.spacing(1) : undefined,
50
- })}
51
- >
52
- {item.element}
53
- </Box>
54
- )
55
- )}
56
- </Box>
57
- );
58
- };