@contember/react-identity 2.0.0-alpha.4 → 2.0.0-alpha.40
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/api-extractor.json +3 -0
- package/dist/development/index.cjs +9 -10
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +5 -5
- package/dist/development/{components → src/components}/HasRole.cjs +2 -2
- package/dist/development/src/components/HasRole.cjs.map +1 -0
- package/dist/development/{components → src/components}/HasRole.js +2 -2
- package/dist/development/src/components/HasRole.js.map +1 -0
- package/dist/development/{components → src/components}/IdentityEnvironmentProvider.cjs +1 -1
- package/dist/development/src/components/IdentityEnvironmentProvider.cjs.map +1 -0
- package/dist/development/{components → src/components}/IdentityEnvironmentProvider.js +1 -1
- package/dist/development/src/components/IdentityEnvironmentProvider.js.map +1 -0
- package/dist/development/src/environment/IdentityEnvironmentExtension.cjs.map +1 -0
- package/dist/development/src/environment/IdentityEnvironmentExtension.js.map +1 -0
- package/dist/development/src/environment/ProjectEnvironmentExtension.cjs.map +1 -0
- package/dist/development/src/environment/ProjectEnvironmentExtension.js.map +1 -0
- package/dist/{production → development/src}/hooks/useProjectUserRoles.cjs +2 -2
- package/dist/development/src/hooks/useProjectUserRoles.cjs.map +1 -0
- package/dist/development/src/hooks/useProjectUserRoles.js.map +1 -0
- package/dist/production/index.cjs +9 -10
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +5 -5
- package/dist/production/src/components/HasRole.cjs.map +1 -0
- package/dist/production/src/components/HasRole.js.map +1 -0
- package/dist/production/src/components/IdentityEnvironmentProvider.cjs.map +1 -0
- package/dist/production/src/components/IdentityEnvironmentProvider.js.map +1 -0
- package/dist/production/src/environment/IdentityEnvironmentExtension.cjs.map +1 -0
- package/dist/production/src/environment/IdentityEnvironmentExtension.js.map +1 -0
- package/dist/production/src/environment/ProjectEnvironmentExtension.cjs.map +1 -0
- package/dist/production/src/environment/ProjectEnvironmentExtension.js.map +1 -0
- package/dist/{development → production/src}/hooks/useProjectUserRoles.cjs +2 -2
- package/dist/production/src/hooks/useProjectUserRoles.cjs.map +1 -0
- package/dist/production/src/hooks/useProjectUserRoles.js.map +1 -0
- package/dist/types/hooks/useProjectUserRoles.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -16
- package/tsconfig.json +7 -0
- package/tsdoc.json +6 -0
- package/dist/development/components/HasRole.cjs.map +0 -1
- package/dist/development/components/HasRole.js.map +0 -1
- package/dist/development/components/IdentityEnvironmentProvider.cjs.map +0 -1
- package/dist/development/components/IdentityEnvironmentProvider.js.map +0 -1
- package/dist/development/environment/IdentityEnvironmentExtension.cjs.map +0 -1
- package/dist/development/environment/IdentityEnvironmentExtension.js.map +0 -1
- package/dist/development/environment/ProjectEnvironmentExtension.cjs.map +0 -1
- package/dist/development/environment/ProjectEnvironmentExtension.js.map +0 -1
- package/dist/development/hooks/useProjectUserRoles.cjs.map +0 -1
- package/dist/development/hooks/useProjectUserRoles.js.map +0 -1
- package/dist/production/components/HasRole.cjs.map +0 -1
- package/dist/production/components/HasRole.js.map +0 -1
- package/dist/production/components/IdentityEnvironmentProvider.cjs.map +0 -1
- package/dist/production/components/IdentityEnvironmentProvider.js.map +0 -1
- package/dist/production/environment/IdentityEnvironmentExtension.cjs.map +0 -1
- package/dist/production/environment/IdentityEnvironmentExtension.js.map +0 -1
- package/dist/production/environment/ProjectEnvironmentExtension.cjs.map +0 -1
- package/dist/production/environment/ProjectEnvironmentExtension.js.map +0 -1
- package/dist/production/hooks/useProjectUserRoles.cjs.map +0 -1
- package/dist/production/hooks/useProjectUserRoles.js.map +0 -1
- /package/dist/development/{environment → src/environment}/IdentityEnvironmentExtension.cjs +0 -0
- /package/dist/development/{environment → src/environment}/IdentityEnvironmentExtension.js +0 -0
- /package/dist/development/{environment → src/environment}/ProjectEnvironmentExtension.cjs +0 -0
- /package/dist/development/{environment → src/environment}/ProjectEnvironmentExtension.js +0 -0
- /package/dist/development/{hooks → src/hooks}/useProjectUserRoles.js +0 -0
- /package/dist/production/{components → src/components}/HasRole.cjs +0 -0
- /package/dist/production/{components → src/components}/HasRole.js +0 -0
- /package/dist/production/{components → src/components}/IdentityEnvironmentProvider.cjs +0 -0
- /package/dist/production/{components → src/components}/IdentityEnvironmentProvider.js +0 -0
- /package/dist/production/{environment → src/environment}/IdentityEnvironmentExtension.cjs +0 -0
- /package/dist/production/{environment → src/environment}/IdentityEnvironmentExtension.js +0 -0
- /package/dist/production/{environment → src/environment}/ProjectEnvironmentExtension.cjs +0 -0
- /package/dist/production/{environment → src/environment}/ProjectEnvironmentExtension.js +0 -0
- /package/dist/production/{hooks → src/hooks}/useProjectUserRoles.js +0 -0
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const reactClientTenant = require("@contember/react-client-tenant");
|
|
4
|
-
const HasRole = require("./components/HasRole.cjs");
|
|
5
|
-
const IdentityEnvironmentProvider = require("./components/IdentityEnvironmentProvider.cjs");
|
|
6
|
-
const useProjectUserRoles = require("./hooks/useProjectUserRoles.cjs");
|
|
7
|
-
const IdentityEnvironmentExtension = require("./environment/IdentityEnvironmentExtension.cjs");
|
|
8
|
-
const ProjectEnvironmentExtension = require("./environment/ProjectEnvironmentExtension.cjs");
|
|
4
|
+
const HasRole = require("./src/components/HasRole.cjs");
|
|
5
|
+
const IdentityEnvironmentProvider = require("./src/components/IdentityEnvironmentProvider.cjs");
|
|
6
|
+
const useProjectUserRoles = require("./src/hooks/useProjectUserRoles.cjs");
|
|
7
|
+
const IdentityEnvironmentExtension = require("./src/environment/IdentityEnvironmentExtension.cjs");
|
|
8
|
+
const ProjectEnvironmentExtension = require("./src/environment/ProjectEnvironmentExtension.cjs");
|
|
9
9
|
exports.HasRole = HasRole.HasRole;
|
|
10
10
|
exports.IdentityEnvironmentProvider = IdentityEnvironmentProvider.IdentityEnvironmentProvider;
|
|
11
11
|
exports.useProjectUserRoles = useProjectUserRoles.useProjectUserRoles;
|
|
12
12
|
exports.identityEnvironmentExtension = IdentityEnvironmentExtension.identityEnvironmentExtension;
|
|
13
13
|
exports.projectEnvironmentExtension = ProjectEnvironmentExtension.projectEnvironmentExtension;
|
|
14
14
|
Object.keys(reactClientTenant).forEach((k) => {
|
|
15
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
15
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: () => reactClientTenant[k]
|
|
18
|
+
});
|
|
20
19
|
});
|
|
21
20
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export * from "@contember/react-client-tenant";
|
|
2
|
-
import { HasRole } from "./components/HasRole.js";
|
|
3
|
-
import { IdentityEnvironmentProvider } from "./components/IdentityEnvironmentProvider.js";
|
|
4
|
-
import { useProjectUserRoles } from "./hooks/useProjectUserRoles.js";
|
|
5
|
-
import { identityEnvironmentExtension } from "./environment/IdentityEnvironmentExtension.js";
|
|
6
|
-
import { projectEnvironmentExtension } from "./environment/ProjectEnvironmentExtension.js";
|
|
2
|
+
import { HasRole } from "./src/components/HasRole.js";
|
|
3
|
+
import { IdentityEnvironmentProvider } from "./src/components/IdentityEnvironmentProvider.js";
|
|
4
|
+
import { useProjectUserRoles } from "./src/hooks/useProjectUserRoles.js";
|
|
5
|
+
import { identityEnvironmentExtension } from "./src/environment/IdentityEnvironmentExtension.js";
|
|
6
|
+
import { projectEnvironmentExtension } from "./src/environment/ProjectEnvironmentExtension.js";
|
|
7
7
|
export {
|
|
8
8
|
HasRole,
|
|
9
9
|
IdentityEnvironmentProvider,
|
|
@@ -8,7 +8,7 @@ const ProjectEnvironmentExtension = require("../environment/ProjectEnvironmentEx
|
|
|
8
8
|
const HasRole = reactBinding.Component(({ children, role }) => {
|
|
9
9
|
const projectRoles = useProjectUserRoles.useProjectUserRoles();
|
|
10
10
|
return evaluateCondition(role, projectRoles) ? /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children }, void 0, false, {
|
|
11
|
-
fileName: "/
|
|
11
|
+
fileName: "/home/runner/work/contember/contember/packages/react-identity/src/components/HasRole.tsx",
|
|
12
12
|
lineNumber: 19,
|
|
13
13
|
columnNumber: 49
|
|
14
14
|
}, void 0) : null;
|
|
@@ -17,7 +17,7 @@ const HasRole = reactBinding.Component(({ children, role }) => {
|
|
|
17
17
|
const project = env.getExtension(ProjectEnvironmentExtension.projectEnvironmentExtension).slug;
|
|
18
18
|
const projectRoles = new Set(identity?.projects.find((it) => it.slug === project)?.roles ?? []);
|
|
19
19
|
return evaluateCondition(role, projectRoles) ? /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children }, void 0, false, {
|
|
20
|
-
fileName: "/
|
|
20
|
+
fileName: "/home/runner/work/contember/contember/packages/react-identity/src/components/HasRole.tsx",
|
|
21
21
|
lineNumber: 25,
|
|
22
22
|
columnNumber: 49
|
|
23
23
|
}, void 0) : null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HasRole.cjs","sources":["../../../../../packages/react-identity/src/components/HasRole.tsx"],"sourcesContent":["import { Component } from '@contember/react-binding'\nimport { ReactNode } from 'react'\nimport { useProjectUserRoles } from '../hooks'\nimport { identityEnvironmentExtension, projectEnvironmentExtension } from '../environment'\n\nexport type RoleCondition = string | ((roles: Set<string>) => boolean)\n\nexport interface HasRoleProps {\n\tchildren?: ReactNode\n\trole: RoleCondition\n}\n\n/**\n * @group Logic Components\n */\nexport const HasRole = Component<HasRoleProps>(({ children, role }) => {\n\tconst projectRoles = useProjectUserRoles()\n\n\treturn evaluateCondition(role, projectRoles) ? <>{children}</> : null\n}, ({ children, role }, env) => {\n\tconst identity = env.getExtension(identityEnvironmentExtension).identity\n\tconst project = env.getExtension(projectEnvironmentExtension).slug\n\tconst projectRoles = new Set(identity?.projects.find(it => it.slug === project)?.roles ?? [])\n\n\treturn evaluateCondition(role, projectRoles) ? <>{children}</> : null\n})\n\nconst evaluateCondition = (condition: RoleCondition, roles: Set<string>) => {\n\tif (typeof condition === 'string') {\n\t\treturn roles.has(condition)\n\t}\n\treturn condition(roles)\n}\n"],"names":["Component","useProjectUserRoles","this","identityEnvironmentExtension","projectEnvironmentExtension"],"mappings":";;;;;;;AAeO,MAAM,UAAUA,aAAAA,UAAwB,CAAC,EAAE,UAAU,WAAW;AACtE,QAAM,eAAeC,oBAAAA,oBAAoB;AAEzC,SAAO,kBAAkB,MAAM,YAAY,mEAAO,SAAH,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAAY,IAAM;AAClE,GAAG,CAAC,EAAE,UAAU,KAAA,GAAQ,QAAQ;AAC/B,QAAM,WAAW,IAAI,aAAaC,6BAAAA,4BAA4B,EAAE;AAChE,QAAM,UAAU,IAAI,aAAaC,4BAAAA,2BAA2B,EAAE;AAC9D,QAAM,eAAe,IAAI,IAAI,UAAU,SAAS,KAAK,CAAM,OAAA,GAAG,SAAS,OAAO,GAAG,SAAS,CAAA,CAAE;AAE5F,SAAO,kBAAkB,MAAM,YAAY,mEAAO,SAAH,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAF,MAAY,IAAM;AAClE,CAAC;AAED,MAAM,oBAAoB,CAAC,WAA0B,UAAuB;AACvE,MAAA,OAAO,cAAc,UAAU;AAC3B,WAAA,MAAM,IAAI,SAAS;AAAA,EAAA;AAE3B,SAAO,UAAU,KAAK;AACvB;;"}
|
|
@@ -6,7 +6,7 @@ import { projectEnvironmentExtension } from "../environment/ProjectEnvironmentEx
|
|
|
6
6
|
const HasRole = Component(({ children, role }) => {
|
|
7
7
|
const projectRoles = useProjectUserRoles();
|
|
8
8
|
return evaluateCondition(role, projectRoles) ? /* @__PURE__ */ jsxDEV(Fragment, { children }, void 0, false, {
|
|
9
|
-
fileName: "/
|
|
9
|
+
fileName: "/home/runner/work/contember/contember/packages/react-identity/src/components/HasRole.tsx",
|
|
10
10
|
lineNumber: 19,
|
|
11
11
|
columnNumber: 49
|
|
12
12
|
}, void 0) : null;
|
|
@@ -15,7 +15,7 @@ const HasRole = Component(({ children, role }) => {
|
|
|
15
15
|
const project = env.getExtension(projectEnvironmentExtension).slug;
|
|
16
16
|
const projectRoles = new Set(identity?.projects.find((it) => it.slug === project)?.roles ?? []);
|
|
17
17
|
return evaluateCondition(role, projectRoles) ? /* @__PURE__ */ jsxDEV(Fragment, { children }, void 0, false, {
|
|
18
|
-
fileName: "/
|
|
18
|
+
fileName: "/home/runner/work/contember/contember/packages/react-identity/src/components/HasRole.tsx",
|
|
19
19
|
lineNumber: 25,
|
|
20
20
|
columnNumber: 49
|
|
21
21
|
}, void 0) : null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HasRole.js","sources":["../../../../../packages/react-identity/src/components/HasRole.tsx"],"sourcesContent":["import { Component } from '@contember/react-binding'\nimport { ReactNode } from 'react'\nimport { useProjectUserRoles } from '../hooks'\nimport { identityEnvironmentExtension, projectEnvironmentExtension } from '../environment'\n\nexport type RoleCondition = string | ((roles: Set<string>) => boolean)\n\nexport interface HasRoleProps {\n\tchildren?: ReactNode\n\trole: RoleCondition\n}\n\n/**\n * @group Logic Components\n */\nexport const HasRole = Component<HasRoleProps>(({ children, role }) => {\n\tconst projectRoles = useProjectUserRoles()\n\n\treturn evaluateCondition(role, projectRoles) ? <>{children}</> : null\n}, ({ children, role }, env) => {\n\tconst identity = env.getExtension(identityEnvironmentExtension).identity\n\tconst project = env.getExtension(projectEnvironmentExtension).slug\n\tconst projectRoles = new Set(identity?.projects.find(it => it.slug === project)?.roles ?? [])\n\n\treturn evaluateCondition(role, projectRoles) ? <>{children}</> : null\n})\n\nconst evaluateCondition = (condition: RoleCondition, roles: Set<string>) => {\n\tif (typeof condition === 'string') {\n\t\treturn roles.has(condition)\n\t}\n\treturn condition(roles)\n}\n"],"names":["this"],"mappings":";;;;;AAeO,MAAM,UAAU,UAAwB,CAAC,EAAE,UAAU,WAAW;AACtE,QAAM,eAAe,oBAAoB;AAEzC,SAAO,kBAAkB,MAAM,YAAY,uCAAO,SAAH,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAAY,IAAM;AAClE,GAAG,CAAC,EAAE,UAAU,KAAA,GAAQ,QAAQ;AAC/B,QAAM,WAAW,IAAI,aAAa,4BAA4B,EAAE;AAChE,QAAM,UAAU,IAAI,aAAa,2BAA2B,EAAE;AAC9D,QAAM,eAAe,IAAI,IAAI,UAAU,SAAS,KAAK,CAAM,OAAA,GAAG,SAAS,OAAO,GAAG,SAAS,CAAA,CAAE;AAE5F,SAAO,kBAAkB,MAAM,YAAY,uCAAO,SAAH,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAAY,IAAM;AAClE,CAAC;AAED,MAAM,oBAAoB,CAAC,WAA0B,UAAuB;AACvE,MAAA,OAAO,cAAc,UAAU;AAC3B,WAAA,MAAM,IAAI,SAAS;AAAA,EAAA;AAE3B,SAAO,UAAU,KAAK;AACvB;"}
|
|
@@ -7,7 +7,7 @@ const IdentityEnvironmentExtension = require("../environment/IdentityEnvironment
|
|
|
7
7
|
const IdentityEnvironmentProvider = ({ children }) => {
|
|
8
8
|
const identity = reactClientTenant.useIdentity();
|
|
9
9
|
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.EnvironmentExtensionProvider, { extension: IdentityEnvironmentExtension.identityEnvironmentExtension, state: identity ?? null, children }, void 0, false, {
|
|
10
|
-
fileName: "/
|
|
10
|
+
fileName: "/home/runner/work/contember/contember/packages/react-identity/src/components/IdentityEnvironmentProvider.tsx",
|
|
11
11
|
lineNumber: 14,
|
|
12
12
|
columnNumber: 3
|
|
13
13
|
}, void 0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdentityEnvironmentProvider.cjs","sources":["../../../../../packages/react-identity/src/components/IdentityEnvironmentProvider.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport { EnvironmentExtensionProvider } from '@contember/react-binding'\nimport { identityEnvironmentExtension } from '../environment'\nimport { useIdentity } from '@contember/react-client-tenant'\n\n\nexport interface IdentityEnvironmentProviderProps {\n\tchildren: ReactNode\n}\n\nexport const IdentityEnvironmentProvider: React.FC<IdentityEnvironmentProviderProps> = ({ children }) => {\n\tconst identity = useIdentity()\n\treturn (\n\t\t<EnvironmentExtensionProvider extension={identityEnvironmentExtension} state={identity ?? null}>\n\t\t\t{children}\n\t\t</EnvironmentExtensionProvider>\n\n\t)\n}\n"],"names":["useIdentity","EnvironmentExtensionProvider","identityEnvironmentExtension","this"],"mappings":";;;;;;AAUO,MAAM,8BAA0E,CAAC,EAAE,eAAe;AACxG,QAAM,WAAWA,kBAAAA,YAAY;AAC7B,8CACEC,aAAAA,8BAA6B,EAAA,WAAWC,6BAAAA,8BAA8B,OAAO,YAAY,MACxF,SADF,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAEA,GAAAC,MAAA;AAGF;;"}
|
|
@@ -5,7 +5,7 @@ import { identityEnvironmentExtension } from "../environment/IdentityEnvironment
|
|
|
5
5
|
const IdentityEnvironmentProvider = ({ children }) => {
|
|
6
6
|
const identity = useIdentity();
|
|
7
7
|
return /* @__PURE__ */ jsxDEV(EnvironmentExtensionProvider, { extension: identityEnvironmentExtension, state: identity ?? null, children }, void 0, false, {
|
|
8
|
-
fileName: "/
|
|
8
|
+
fileName: "/home/runner/work/contember/contember/packages/react-identity/src/components/IdentityEnvironmentProvider.tsx",
|
|
9
9
|
lineNumber: 14,
|
|
10
10
|
columnNumber: 3
|
|
11
11
|
}, void 0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdentityEnvironmentProvider.js","sources":["../../../../../packages/react-identity/src/components/IdentityEnvironmentProvider.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport { EnvironmentExtensionProvider } from '@contember/react-binding'\nimport { identityEnvironmentExtension } from '../environment'\nimport { useIdentity } from '@contember/react-client-tenant'\n\n\nexport interface IdentityEnvironmentProviderProps {\n\tchildren: ReactNode\n}\n\nexport const IdentityEnvironmentProvider: React.FC<IdentityEnvironmentProviderProps> = ({ children }) => {\n\tconst identity = useIdentity()\n\treturn (\n\t\t<EnvironmentExtensionProvider extension={identityEnvironmentExtension} state={identity ?? null}>\n\t\t\t{children}\n\t\t</EnvironmentExtensionProvider>\n\n\t)\n}\n"],"names":["this"],"mappings":";;;;AAUO,MAAM,8BAA0E,CAAC,EAAE,eAAe;AACxG,QAAM,WAAW,YAAY;AAC7B,gCACE,8BAA6B,EAAA,WAAW,8BAA8B,OAAO,YAAY,MACxF,SADF,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAEA,GAAAA,MAAA;AAGF;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdentityEnvironmentExtension.cjs","sources":["../../../../../packages/react-identity/src/environment/IdentityEnvironmentExtension.ts"],"sourcesContent":["import { BindingError, Environment } from '@contember/react-binding'\nimport { Identity } from '@contember/react-client-tenant'\n\nexport const identityEnvironmentExtension = Environment.createExtension((state: Identity | null | undefined) => {\n\tif (state === undefined) {\n\t\tthrow new BindingError('Environment does not contain identity state.')\n\t}\n\n\treturn {\n\t\tidentity: state ?? undefined,\n\t}\n})\n"],"names":["Environment","BindingError"],"mappings":";;;AAGO,MAAM,+BAA+BA,aAAA,YAAY,gBAAgB,CAAC,UAAuC;AAC/G,MAAI,UAAU,QAAW;AAClB,UAAA,IAAIC,0BAAa,8CAA8C;AAAA,EAAA;AAG/D,SAAA;AAAA,IACN,UAAU,SAAS;AAAA,EACpB;AACD,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdentityEnvironmentExtension.js","sources":["../../../../../packages/react-identity/src/environment/IdentityEnvironmentExtension.ts"],"sourcesContent":["import { BindingError, Environment } from '@contember/react-binding'\nimport { Identity } from '@contember/react-client-tenant'\n\nexport const identityEnvironmentExtension = Environment.createExtension((state: Identity | null | undefined) => {\n\tif (state === undefined) {\n\t\tthrow new BindingError('Environment does not contain identity state.')\n\t}\n\n\treturn {\n\t\tidentity: state ?? undefined,\n\t}\n})\n"],"names":[],"mappings":";AAGO,MAAM,+BAA+B,YAAY,gBAAgB,CAAC,UAAuC;AAC/G,MAAI,UAAU,QAAW;AAClB,UAAA,IAAI,aAAa,8CAA8C;AAAA,EAAA;AAG/D,SAAA;AAAA,IACN,UAAU,SAAS;AAAA,EACpB;AACD,CAAC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectEnvironmentExtension.cjs","sources":["../../../../../packages/react-identity/src/environment/ProjectEnvironmentExtension.tsx"],"sourcesContent":["import { BindingError, Environment } from '@contember/react-binding'\n\nexport const projectEnvironmentExtension = Environment.createExtension((slug: string | null | undefined) => {\n\tif (slug === undefined) {\n\t\tthrow new BindingError('Environment does not contain project slug state.')\n\t}\n\treturn {\n\t\tslug: slug ?? undefined,\n\t}\n})\n"],"names":["Environment","BindingError"],"mappings":";;;AAEO,MAAM,8BAA8BA,aAAA,YAAY,gBAAgB,CAAC,SAAoC;AAC3G,MAAI,SAAS,QAAW;AACjB,UAAA,IAAIC,0BAAa,kDAAkD;AAAA,EAAA;AAEnE,SAAA;AAAA,IACN,MAAM,QAAQ;AAAA,EACf;AACD,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectEnvironmentExtension.js","sources":["../../../../../packages/react-identity/src/environment/ProjectEnvironmentExtension.tsx"],"sourcesContent":["import { BindingError, Environment } from '@contember/react-binding'\n\nexport const projectEnvironmentExtension = Environment.createExtension((slug: string | null | undefined) => {\n\tif (slug === undefined) {\n\t\tthrow new BindingError('Environment does not contain project slug state.')\n\t}\n\treturn {\n\t\tslug: slug ?? undefined,\n\t}\n})\n"],"names":[],"mappings":";AAEO,MAAM,8BAA8B,YAAY,gBAAgB,CAAC,SAAoC;AAC3G,MAAI,SAAS,QAAW;AACjB,UAAA,IAAI,aAAa,kDAAkD;AAAA,EAAA;AAEnE,SAAA;AAAA,IACN,MAAM,QAAQ;AAAA,EACf;AACD,CAAC;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const React = require("react");
|
|
4
4
|
const reactClient = require("@contember/react-client");
|
|
5
5
|
const reactClientTenant = require("@contember/react-client-tenant");
|
|
6
6
|
const useProjectUserRoles = () => {
|
|
7
7
|
const identity = reactClientTenant.useIdentity();
|
|
8
8
|
const projectSlug = reactClient.useProjectSlug();
|
|
9
|
-
return
|
|
9
|
+
return React.useMemo(() => {
|
|
10
10
|
if (!projectSlug) {
|
|
11
11
|
return /* @__PURE__ */ new Set();
|
|
12
12
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useProjectUserRoles.cjs","sources":["../../../../../packages/react-identity/src/hooks/useProjectUserRoles.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { useProjectSlug } from '@contember/react-client'\nimport { useIdentity } from '@contember/react-client-tenant'\n\nexport type ProjectUserRoles = Set<string>\n\nexport const useProjectUserRoles = (): ProjectUserRoles => {\n\tconst identity = useIdentity()\n\tconst projectSlug = useProjectSlug()\n\treturn useMemo(() => {\n\t\tif (!projectSlug) {\n\t\t\treturn new Set()\n\t\t}\n\t\tconst targetProject = identity?.projects.find(project => project.slug === projectSlug)\n\t\tif (targetProject === undefined) {\n\t\t\treturn new Set()\n\t\t}\n\n\t\treturn new Set(targetProject.roles)\n\t}, [identity?.projects, projectSlug])\n}\n"],"names":["useIdentity","useProjectSlug","useMemo"],"mappings":";;;;;AAMO,MAAM,sBAAsB,MAAwB;AAC1D,QAAM,WAAWA,kBAAAA,YAAY;AAC7B,QAAM,cAAcC,YAAAA,eAAe;AACnC,SAAOC,cAAQ,MAAM;AACpB,QAAI,CAAC,aAAa;AACjB,iCAAW,IAAI;AAAA,IAAA;AAEhB,UAAM,gBAAgB,UAAU,SAAS,KAAK,CAAW,YAAA,QAAQ,SAAS,WAAW;AACrF,QAAI,kBAAkB,QAAW;AAChC,iCAAW,IAAI;AAAA,IAAA;AAGT,WAAA,IAAI,IAAI,cAAc,KAAK;AAAA,EAChC,GAAA,CAAC,UAAU,UAAU,WAAW,CAAC;AACrC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useProjectUserRoles.js","sources":["../../../../../packages/react-identity/src/hooks/useProjectUserRoles.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { useProjectSlug } from '@contember/react-client'\nimport { useIdentity } from '@contember/react-client-tenant'\n\nexport type ProjectUserRoles = Set<string>\n\nexport const useProjectUserRoles = (): ProjectUserRoles => {\n\tconst identity = useIdentity()\n\tconst projectSlug = useProjectSlug()\n\treturn useMemo(() => {\n\t\tif (!projectSlug) {\n\t\t\treturn new Set()\n\t\t}\n\t\tconst targetProject = identity?.projects.find(project => project.slug === projectSlug)\n\t\tif (targetProject === undefined) {\n\t\t\treturn new Set()\n\t\t}\n\n\t\treturn new Set(targetProject.roles)\n\t}, [identity?.projects, projectSlug])\n}\n"],"names":[],"mappings":";;;AAMO,MAAM,sBAAsB,MAAwB;AAC1D,QAAM,WAAW,YAAY;AAC7B,QAAM,cAAc,eAAe;AACnC,SAAO,QAAQ,MAAM;AACpB,QAAI,CAAC,aAAa;AACjB,iCAAW,IAAI;AAAA,IAAA;AAEhB,UAAM,gBAAgB,UAAU,SAAS,KAAK,CAAW,YAAA,QAAQ,SAAS,WAAW;AACrF,QAAI,kBAAkB,QAAW;AAChC,iCAAW,IAAI;AAAA,IAAA;AAGT,WAAA,IAAI,IAAI,cAAc,KAAK;AAAA,EAChC,GAAA,CAAC,UAAU,UAAU,WAAW,CAAC;AACrC;"}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const reactClientTenant = require("@contember/react-client-tenant");
|
|
4
|
-
const HasRole = require("./components/HasRole.cjs");
|
|
5
|
-
const IdentityEnvironmentProvider = require("./components/IdentityEnvironmentProvider.cjs");
|
|
6
|
-
const useProjectUserRoles = require("./hooks/useProjectUserRoles.cjs");
|
|
7
|
-
const IdentityEnvironmentExtension = require("./environment/IdentityEnvironmentExtension.cjs");
|
|
8
|
-
const ProjectEnvironmentExtension = require("./environment/ProjectEnvironmentExtension.cjs");
|
|
4
|
+
const HasRole = require("./src/components/HasRole.cjs");
|
|
5
|
+
const IdentityEnvironmentProvider = require("./src/components/IdentityEnvironmentProvider.cjs");
|
|
6
|
+
const useProjectUserRoles = require("./src/hooks/useProjectUserRoles.cjs");
|
|
7
|
+
const IdentityEnvironmentExtension = require("./src/environment/IdentityEnvironmentExtension.cjs");
|
|
8
|
+
const ProjectEnvironmentExtension = require("./src/environment/ProjectEnvironmentExtension.cjs");
|
|
9
9
|
exports.HasRole = HasRole.HasRole;
|
|
10
10
|
exports.IdentityEnvironmentProvider = IdentityEnvironmentProvider.IdentityEnvironmentProvider;
|
|
11
11
|
exports.useProjectUserRoles = useProjectUserRoles.useProjectUserRoles;
|
|
12
12
|
exports.identityEnvironmentExtension = IdentityEnvironmentExtension.identityEnvironmentExtension;
|
|
13
13
|
exports.projectEnvironmentExtension = ProjectEnvironmentExtension.projectEnvironmentExtension;
|
|
14
14
|
Object.keys(reactClientTenant).forEach((k) => {
|
|
15
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
15
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: () => reactClientTenant[k]
|
|
18
|
+
});
|
|
20
19
|
});
|
|
21
20
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
package/dist/production/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export * from "@contember/react-client-tenant";
|
|
2
|
-
import { HasRole } from "./components/HasRole.js";
|
|
3
|
-
import { IdentityEnvironmentProvider } from "./components/IdentityEnvironmentProvider.js";
|
|
4
|
-
import { useProjectUserRoles } from "./hooks/useProjectUserRoles.js";
|
|
5
|
-
import { identityEnvironmentExtension } from "./environment/IdentityEnvironmentExtension.js";
|
|
6
|
-
import { projectEnvironmentExtension } from "./environment/ProjectEnvironmentExtension.js";
|
|
2
|
+
import { HasRole } from "./src/components/HasRole.js";
|
|
3
|
+
import { IdentityEnvironmentProvider } from "./src/components/IdentityEnvironmentProvider.js";
|
|
4
|
+
import { useProjectUserRoles } from "./src/hooks/useProjectUserRoles.js";
|
|
5
|
+
import { identityEnvironmentExtension } from "./src/environment/IdentityEnvironmentExtension.js";
|
|
6
|
+
import { projectEnvironmentExtension } from "./src/environment/ProjectEnvironmentExtension.js";
|
|
7
7
|
export {
|
|
8
8
|
HasRole,
|
|
9
9
|
IdentityEnvironmentProvider,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HasRole.cjs","sources":["../../../../../packages/react-identity/src/components/HasRole.tsx"],"sourcesContent":["import { Component } from '@contember/react-binding'\nimport { ReactNode } from 'react'\nimport { useProjectUserRoles } from '../hooks'\nimport { identityEnvironmentExtension, projectEnvironmentExtension } from '../environment'\n\nexport type RoleCondition = string | ((roles: Set<string>) => boolean)\n\nexport interface HasRoleProps {\n\tchildren?: ReactNode\n\trole: RoleCondition\n}\n\n/**\n * @group Logic Components\n */\nexport const HasRole = Component<HasRoleProps>(({ children, role }) => {\n\tconst projectRoles = useProjectUserRoles()\n\n\treturn evaluateCondition(role, projectRoles) ? <>{children}</> : null\n}, ({ children, role }, env) => {\n\tconst identity = env.getExtension(identityEnvironmentExtension).identity\n\tconst project = env.getExtension(projectEnvironmentExtension).slug\n\tconst projectRoles = new Set(identity?.projects.find(it => it.slug === project)?.roles ?? [])\n\n\treturn evaluateCondition(role, projectRoles) ? <>{children}</> : null\n})\n\nconst evaluateCondition = (condition: RoleCondition, roles: Set<string>) => {\n\tif (typeof condition === 'string') {\n\t\treturn roles.has(condition)\n\t}\n\treturn condition(roles)\n}\n"],"names":["Component","useProjectUserRoles","jsx","Fragment","identityEnvironmentExtension","projectEnvironmentExtension"],"mappings":";;;;;;;AAeO,MAAM,UAAUA,aAAAA,UAAwB,CAAC,EAAE,UAAU,WAAW;AACtE,QAAM,eAAeC,oBAAAA,oBAAoB;AAEzC,SAAO,kBAAkB,MAAM,YAAY,IAAIC,2BAAA,IAAAC,qBAAA,EAAG,SAAS,CAAA,IAAM;AAClE,GAAG,CAAC,EAAE,UAAU,KAAA,GAAQ,QAAQ;AAC/B,QAAM,WAAW,IAAI,aAAaC,6BAAAA,4BAA4B,EAAE;AAChE,QAAM,UAAU,IAAI,aAAaC,4BAAAA,2BAA2B,EAAE;AAC9D,QAAM,eAAe,IAAI,IAAI,UAAU,SAAS,KAAK,CAAM,OAAA,GAAG,SAAS,OAAO,GAAG,SAAS,CAAA,CAAE;AAE5F,SAAO,kBAAkB,MAAM,YAAY,IAAIH,2BAAA,IAAAC,qBAAA,EAAG,SAAS,CAAA,IAAM;AAClE,CAAC;AAED,MAAM,oBAAoB,CAAC,WAA0B,UAAuB;AACvE,MAAA,OAAO,cAAc,UAAU;AAC3B,WAAA,MAAM,IAAI,SAAS;AAAA,EAAA;AAE3B,SAAO,UAAU,KAAK;AACvB;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HasRole.js","sources":["../../../../../packages/react-identity/src/components/HasRole.tsx"],"sourcesContent":["import { Component } from '@contember/react-binding'\nimport { ReactNode } from 'react'\nimport { useProjectUserRoles } from '../hooks'\nimport { identityEnvironmentExtension, projectEnvironmentExtension } from '../environment'\n\nexport type RoleCondition = string | ((roles: Set<string>) => boolean)\n\nexport interface HasRoleProps {\n\tchildren?: ReactNode\n\trole: RoleCondition\n}\n\n/**\n * @group Logic Components\n */\nexport const HasRole = Component<HasRoleProps>(({ children, role }) => {\n\tconst projectRoles = useProjectUserRoles()\n\n\treturn evaluateCondition(role, projectRoles) ? <>{children}</> : null\n}, ({ children, role }, env) => {\n\tconst identity = env.getExtension(identityEnvironmentExtension).identity\n\tconst project = env.getExtension(projectEnvironmentExtension).slug\n\tconst projectRoles = new Set(identity?.projects.find(it => it.slug === project)?.roles ?? [])\n\n\treturn evaluateCondition(role, projectRoles) ? <>{children}</> : null\n})\n\nconst evaluateCondition = (condition: RoleCondition, roles: Set<string>) => {\n\tif (typeof condition === 'string') {\n\t\treturn roles.has(condition)\n\t}\n\treturn condition(roles)\n}\n"],"names":[],"mappings":";;;;;AAeO,MAAM,UAAU,UAAwB,CAAC,EAAE,UAAU,WAAW;AACtE,QAAM,eAAe,oBAAoB;AAEzC,SAAO,kBAAkB,MAAM,YAAY,IAAI,oBAAA,UAAA,EAAG,SAAS,CAAA,IAAM;AAClE,GAAG,CAAC,EAAE,UAAU,KAAA,GAAQ,QAAQ;AAC/B,QAAM,WAAW,IAAI,aAAa,4BAA4B,EAAE;AAChE,QAAM,UAAU,IAAI,aAAa,2BAA2B,EAAE;AAC9D,QAAM,eAAe,IAAI,IAAI,UAAU,SAAS,KAAK,CAAM,OAAA,GAAG,SAAS,OAAO,GAAG,SAAS,CAAA,CAAE;AAE5F,SAAO,kBAAkB,MAAM,YAAY,IAAI,oBAAA,UAAA,EAAG,SAAS,CAAA,IAAM;AAClE,CAAC;AAED,MAAM,oBAAoB,CAAC,WAA0B,UAAuB;AACvE,MAAA,OAAO,cAAc,UAAU;AAC3B,WAAA,MAAM,IAAI,SAAS;AAAA,EAAA;AAE3B,SAAO,UAAU,KAAK;AACvB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdentityEnvironmentProvider.cjs","sources":["../../../../../packages/react-identity/src/components/IdentityEnvironmentProvider.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport { EnvironmentExtensionProvider } from '@contember/react-binding'\nimport { identityEnvironmentExtension } from '../environment'\nimport { useIdentity } from '@contember/react-client-tenant'\n\n\nexport interface IdentityEnvironmentProviderProps {\n\tchildren: ReactNode\n}\n\nexport const IdentityEnvironmentProvider: React.FC<IdentityEnvironmentProviderProps> = ({ children }) => {\n\tconst identity = useIdentity()\n\treturn (\n\t\t<EnvironmentExtensionProvider extension={identityEnvironmentExtension} state={identity ?? null}>\n\t\t\t{children}\n\t\t</EnvironmentExtensionProvider>\n\n\t)\n}\n"],"names":["useIdentity","EnvironmentExtensionProvider","identityEnvironmentExtension"],"mappings":";;;;;;AAUO,MAAM,8BAA0E,CAAC,EAAE,eAAe;AACxG,QAAM,WAAWA,kBAAAA,YAAY;AAC7B,wCACEC,2CAA6B,EAAA,WAAWC,6BAAAA,8BAA8B,OAAO,YAAY,MACxF,UACF;AAGF;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdentityEnvironmentProvider.js","sources":["../../../../../packages/react-identity/src/components/IdentityEnvironmentProvider.tsx"],"sourcesContent":["import { ReactNode } from 'react'\nimport { EnvironmentExtensionProvider } from '@contember/react-binding'\nimport { identityEnvironmentExtension } from '../environment'\nimport { useIdentity } from '@contember/react-client-tenant'\n\n\nexport interface IdentityEnvironmentProviderProps {\n\tchildren: ReactNode\n}\n\nexport const IdentityEnvironmentProvider: React.FC<IdentityEnvironmentProviderProps> = ({ children }) => {\n\tconst identity = useIdentity()\n\treturn (\n\t\t<EnvironmentExtensionProvider extension={identityEnvironmentExtension} state={identity ?? null}>\n\t\t\t{children}\n\t\t</EnvironmentExtensionProvider>\n\n\t)\n}\n"],"names":[],"mappings":";;;;AAUO,MAAM,8BAA0E,CAAC,EAAE,eAAe;AACxG,QAAM,WAAW,YAAY;AAC7B,6BACE,8BAA6B,EAAA,WAAW,8BAA8B,OAAO,YAAY,MACxF,UACF;AAGF;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdentityEnvironmentExtension.cjs","sources":["../../../../../packages/react-identity/src/environment/IdentityEnvironmentExtension.ts"],"sourcesContent":["import { BindingError, Environment } from '@contember/react-binding'\nimport { Identity } from '@contember/react-client-tenant'\n\nexport const identityEnvironmentExtension = Environment.createExtension((state: Identity | null | undefined) => {\n\tif (state === undefined) {\n\t\tthrow new BindingError('Environment does not contain identity state.')\n\t}\n\n\treturn {\n\t\tidentity: state ?? undefined,\n\t}\n})\n"],"names":["Environment","BindingError"],"mappings":";;;AAGO,MAAM,+BAA+BA,aAAA,YAAY,gBAAgB,CAAC,UAAuC;AAC/G,MAAI,UAAU,QAAW;AAClB,UAAA,IAAIC,0BAAa,8CAA8C;AAAA,EAAA;AAG/D,SAAA;AAAA,IACN,UAAU,SAAS;AAAA,EACpB;AACD,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdentityEnvironmentExtension.js","sources":["../../../../../packages/react-identity/src/environment/IdentityEnvironmentExtension.ts"],"sourcesContent":["import { BindingError, Environment } from '@contember/react-binding'\nimport { Identity } from '@contember/react-client-tenant'\n\nexport const identityEnvironmentExtension = Environment.createExtension((state: Identity | null | undefined) => {\n\tif (state === undefined) {\n\t\tthrow new BindingError('Environment does not contain identity state.')\n\t}\n\n\treturn {\n\t\tidentity: state ?? undefined,\n\t}\n})\n"],"names":[],"mappings":";AAGO,MAAM,+BAA+B,YAAY,gBAAgB,CAAC,UAAuC;AAC/G,MAAI,UAAU,QAAW;AAClB,UAAA,IAAI,aAAa,8CAA8C;AAAA,EAAA;AAG/D,SAAA;AAAA,IACN,UAAU,SAAS;AAAA,EACpB;AACD,CAAC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectEnvironmentExtension.cjs","sources":["../../../../../packages/react-identity/src/environment/ProjectEnvironmentExtension.tsx"],"sourcesContent":["import { BindingError, Environment } from '@contember/react-binding'\n\nexport const projectEnvironmentExtension = Environment.createExtension((slug: string | null | undefined) => {\n\tif (slug === undefined) {\n\t\tthrow new BindingError('Environment does not contain project slug state.')\n\t}\n\treturn {\n\t\tslug: slug ?? undefined,\n\t}\n})\n"],"names":["Environment","BindingError"],"mappings":";;;AAEO,MAAM,8BAA8BA,aAAA,YAAY,gBAAgB,CAAC,SAAoC;AAC3G,MAAI,SAAS,QAAW;AACjB,UAAA,IAAIC,0BAAa,kDAAkD;AAAA,EAAA;AAEnE,SAAA;AAAA,IACN,MAAM,QAAQ;AAAA,EACf;AACD,CAAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectEnvironmentExtension.js","sources":["../../../../../packages/react-identity/src/environment/ProjectEnvironmentExtension.tsx"],"sourcesContent":["import { BindingError, Environment } from '@contember/react-binding'\n\nexport const projectEnvironmentExtension = Environment.createExtension((slug: string | null | undefined) => {\n\tif (slug === undefined) {\n\t\tthrow new BindingError('Environment does not contain project slug state.')\n\t}\n\treturn {\n\t\tslug: slug ?? undefined,\n\t}\n})\n"],"names":[],"mappings":";AAEO,MAAM,8BAA8B,YAAY,gBAAgB,CAAC,SAAoC;AAC3G,MAAI,SAAS,QAAW;AACjB,UAAA,IAAI,aAAa,kDAAkD;AAAA,EAAA;AAEnE,SAAA;AAAA,IACN,MAAM,QAAQ;AAAA,EACf;AACD,CAAC;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const React = require("react");
|
|
4
4
|
const reactClient = require("@contember/react-client");
|
|
5
5
|
const reactClientTenant = require("@contember/react-client-tenant");
|
|
6
6
|
const useProjectUserRoles = () => {
|
|
7
7
|
const identity = reactClientTenant.useIdentity();
|
|
8
8
|
const projectSlug = reactClient.useProjectSlug();
|
|
9
|
-
return
|
|
9
|
+
return React.useMemo(() => {
|
|
10
10
|
if (!projectSlug) {
|
|
11
11
|
return /* @__PURE__ */ new Set();
|
|
12
12
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useProjectUserRoles.cjs","sources":["../../../../../packages/react-identity/src/hooks/useProjectUserRoles.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { useProjectSlug } from '@contember/react-client'\nimport { useIdentity } from '@contember/react-client-tenant'\n\nexport type ProjectUserRoles = Set<string>\n\nexport const useProjectUserRoles = (): ProjectUserRoles => {\n\tconst identity = useIdentity()\n\tconst projectSlug = useProjectSlug()\n\treturn useMemo(() => {\n\t\tif (!projectSlug) {\n\t\t\treturn new Set()\n\t\t}\n\t\tconst targetProject = identity?.projects.find(project => project.slug === projectSlug)\n\t\tif (targetProject === undefined) {\n\t\t\treturn new Set()\n\t\t}\n\n\t\treturn new Set(targetProject.roles)\n\t}, [identity?.projects, projectSlug])\n}\n"],"names":["useIdentity","useProjectSlug","useMemo"],"mappings":";;;;;AAMO,MAAM,sBAAsB,MAAwB;AAC1D,QAAM,WAAWA,kBAAAA,YAAY;AAC7B,QAAM,cAAcC,YAAAA,eAAe;AACnC,SAAOC,cAAQ,MAAM;AACpB,QAAI,CAAC,aAAa;AACjB,iCAAW,IAAI;AAAA,IAAA;AAEhB,UAAM,gBAAgB,UAAU,SAAS,KAAK,CAAW,YAAA,QAAQ,SAAS,WAAW;AACrF,QAAI,kBAAkB,QAAW;AAChC,iCAAW,IAAI;AAAA,IAAA;AAGT,WAAA,IAAI,IAAI,cAAc,KAAK;AAAA,EAChC,GAAA,CAAC,UAAU,UAAU,WAAW,CAAC;AACrC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useProjectUserRoles.js","sources":["../../../../../packages/react-identity/src/hooks/useProjectUserRoles.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { useProjectSlug } from '@contember/react-client'\nimport { useIdentity } from '@contember/react-client-tenant'\n\nexport type ProjectUserRoles = Set<string>\n\nexport const useProjectUserRoles = (): ProjectUserRoles => {\n\tconst identity = useIdentity()\n\tconst projectSlug = useProjectSlug()\n\treturn useMemo(() => {\n\t\tif (!projectSlug) {\n\t\t\treturn new Set()\n\t\t}\n\t\tconst targetProject = identity?.projects.find(project => project.slug === projectSlug)\n\t\tif (targetProject === undefined) {\n\t\t\treturn new Set()\n\t\t}\n\n\t\treturn new Set(targetProject.roles)\n\t}, [identity?.projects, projectSlug])\n}\n"],"names":[],"mappings":";;;AAMO,MAAM,sBAAsB,MAAwB;AAC1D,QAAM,WAAW,YAAY;AAC7B,QAAM,cAAc,eAAe;AACnC,SAAO,QAAQ,MAAM;AACpB,QAAI,CAAC,aAAa;AACjB,iCAAW,IAAI;AAAA,IAAA;AAEhB,UAAM,gBAAgB,UAAU,SAAS,KAAK,CAAW,YAAA,QAAQ,SAAS,WAAW;AACrF,QAAI,kBAAkB,QAAW;AAChC,iCAAW,IAAI;AAAA,IAAA;AAGT,WAAA,IAAI,IAAI,cAAc,KAAK;AAAA,EAChC,GAAA,CAAC,UAAU,UAAU,WAAW,CAAC;AACrC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProjectUserRoles.d.ts","sourceRoot":"","sources":["../../../src/hooks/useProjectUserRoles.tsx"],"names":[],"mappings":"AAIA,MAAM,MAAM,gBAAgB,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;AAE1C,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"useProjectUserRoles.d.ts","sourceRoot":"","sources":["../../../src/hooks/useProjectUserRoles.tsx"],"names":[],"mappings":"AAIA,MAAM,MAAM,gBAAgB,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;AAE1C,eAAO,MAAM,mBAAmB,QAAO,gBActC,CAAA"}
|