@contember/react-identity 2.1.0-beta.2 → 2.2.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +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<string>(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,oBAAA;AAErB,SAAO,kBAAkB,MAAM,YAAY,mEAAO,SAAA,GAAH,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,IAAY,UAAU,SAAS,KAAK,CAAA,OAAM,GAAG,SAAS,OAAO,GAAG,SAAS,CAAA,CAAE;AAEpG,SAAO,kBAAkB,MAAM,YAAY,mEAAO,SAAA,GAAH,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAF,MAAY,IAAM;AAClE,CAAC;AAED,MAAM,oBAAoB,CAAC,WAA0B,UAAuB;AAC3E,MAAI,OAAO,cAAc,UAAU;AAClC,WAAO,MAAM,IAAI,SAAS;AAAA,EAC3B;AACA,SAAO,UAAU,KAAK;AACvB;;"}
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/index.js'\nimport { identityEnvironmentExtension, projectEnvironmentExtension } from '../environment/index.js'\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<string>(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,oBAAA;AAErB,SAAO,kBAAkB,MAAM,YAAY,mEAAO,SAAA,GAAH,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,IAAY,UAAU,SAAS,KAAK,CAAA,OAAM,GAAG,SAAS,OAAO,GAAG,SAAS,CAAA,CAAE;AAEpG,SAAO,kBAAkB,MAAM,YAAY,mEAAO,SAAA,GAAH,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAF,MAAY,IAAM;AAClE,CAAC;AAED,MAAM,oBAAoB,CAAC,WAA0B,UAAuB;AAC3E,MAAI,OAAO,cAAc,UAAU;AAClC,WAAO,MAAM,IAAI,SAAS;AAAA,EAC3B;AACA,SAAO,UAAU,KAAK;AACvB;;"}
@@ -1 +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<string>(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,oBAAA;AAErB,SAAO,kBAAkB,MAAM,YAAY,uCAAO,SAAA,GAAH,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,IAAY,UAAU,SAAS,KAAK,CAAA,OAAM,GAAG,SAAS,OAAO,GAAG,SAAS,CAAA,CAAE;AAEpG,SAAO,kBAAkB,MAAM,YAAY,uCAAO,SAAA,GAAH,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAAY,IAAM;AAClE,CAAC;AAED,MAAM,oBAAoB,CAAC,WAA0B,UAAuB;AAC3E,MAAI,OAAO,cAAc,UAAU;AAClC,WAAO,MAAM,IAAI,SAAS;AAAA,EAC3B;AACA,SAAO,UAAU,KAAK;AACvB;"}
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/index.js'\nimport { identityEnvironmentExtension, projectEnvironmentExtension } from '../environment/index.js'\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<string>(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,oBAAA;AAErB,SAAO,kBAAkB,MAAM,YAAY,uCAAO,SAAA,GAAH,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,IAAY,UAAU,SAAS,KAAK,CAAA,OAAM,GAAG,SAAS,OAAO,GAAG,SAAS,CAAA,CAAE;AAEpG,SAAO,kBAAkB,MAAM,YAAY,uCAAO,SAAA,GAAH,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAAY,IAAM;AAClE,CAAC;AAED,MAAM,oBAAoB,CAAC,WAA0B,UAAuB;AAC3E,MAAI,OAAO,cAAc,UAAU;AAClC,WAAO,MAAM,IAAI,SAAS;AAAA,EAC3B;AACA,SAAO,UAAU,KAAK;AACvB;"}
@@ -1 +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\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\t)\n}\n"],"names":["useIdentity","EnvironmentExtensionProvider","identityEnvironmentExtension","this"],"mappings":";;;;;;AASO,MAAM,8BAA0E,CAAC,EAAE,eAAe;AACxG,QAAM,WAAWA,kBAAAA,YAAA;AACjB,8CACEC,aAAAA,8BAAA,EAA6B,WAAWC,6BAAAA,8BAA8B,OAAO,YAAY,MACxF,YADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAEA;AAEF;;"}
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/index.js'\nimport { useIdentity } from '@contember/react-client-tenant'\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\t)\n}\n"],"names":["useIdentity","EnvironmentExtensionProvider","identityEnvironmentExtension","this"],"mappings":";;;;;;AASO,MAAM,8BAA0E,CAAC,EAAE,eAAe;AACxG,QAAM,WAAWA,kBAAAA,YAAA;AACjB,8CACEC,aAAAA,8BAAA,EAA6B,WAAWC,6BAAAA,8BAA8B,OAAO,YAAY,MACxF,YADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAEA;AAEF;;"}
@@ -1 +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\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\t)\n}\n"],"names":["this"],"mappings":";;;;AASO,MAAM,8BAA0E,CAAC,EAAE,eAAe;AACxG,QAAM,WAAW,YAAA;AACjB,gCACE,8BAAA,EAA6B,WAAW,8BAA8B,OAAO,YAAY,MACxF,YADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAEA;AAEF;"}
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/index.js'\nimport { useIdentity } from '@contember/react-client-tenant'\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\t)\n}\n"],"names":["this"],"mappings":";;;;AASO,MAAM,8BAA0E,CAAC,EAAE,eAAe;AACxG,QAAM,WAAW,YAAA;AACjB,gCACE,8BAAA,EAA6B,WAAW,8BAA8B,OAAO,YAAY,MACxF,YADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAEA;AAEF;"}
@@ -1 +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<string>(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,oBAAA;AAErB,SAAO,kBAAkB,MAAM,YAAY,IAAIC,2BAAAA,IAAAC,qBAAA,EAAG,UAAS,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,IAAY,UAAU,SAAS,KAAK,CAAA,OAAM,GAAG,SAAS,OAAO,GAAG,SAAS,CAAA,CAAE;AAEpG,SAAO,kBAAkB,MAAM,YAAY,IAAIH,2BAAAA,IAAAC,qBAAA,EAAG,UAAS,IAAM;AAClE,CAAC;AAED,MAAM,oBAAoB,CAAC,WAA0B,UAAuB;AAC3E,MAAI,OAAO,cAAc,UAAU;AAClC,WAAO,MAAM,IAAI,SAAS;AAAA,EAC3B;AACA,SAAO,UAAU,KAAK;AACvB;;"}
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/index.js'\nimport { identityEnvironmentExtension, projectEnvironmentExtension } from '../environment/index.js'\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<string>(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,oBAAA;AAErB,SAAO,kBAAkB,MAAM,YAAY,IAAIC,2BAAAA,IAAAC,qBAAA,EAAG,UAAS,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,IAAY,UAAU,SAAS,KAAK,CAAA,OAAM,GAAG,SAAS,OAAO,GAAG,SAAS,CAAA,CAAE;AAEpG,SAAO,kBAAkB,MAAM,YAAY,IAAIH,2BAAAA,IAAAC,qBAAA,EAAG,UAAS,IAAM;AAClE,CAAC;AAED,MAAM,oBAAoB,CAAC,WAA0B,UAAuB;AAC3E,MAAI,OAAO,cAAc,UAAU;AAClC,WAAO,MAAM,IAAI,SAAS;AAAA,EAC3B;AACA,SAAO,UAAU,KAAK;AACvB;;"}
@@ -1 +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<string>(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,oBAAA;AAErB,SAAO,kBAAkB,MAAM,YAAY,IAAI,oBAAA,UAAA,EAAG,UAAS,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,IAAY,UAAU,SAAS,KAAK,CAAA,OAAM,GAAG,SAAS,OAAO,GAAG,SAAS,CAAA,CAAE;AAEpG,SAAO,kBAAkB,MAAM,YAAY,IAAI,oBAAA,UAAA,EAAG,UAAS,IAAM;AAClE,CAAC;AAED,MAAM,oBAAoB,CAAC,WAA0B,UAAuB;AAC3E,MAAI,OAAO,cAAc,UAAU;AAClC,WAAO,MAAM,IAAI,SAAS;AAAA,EAC3B;AACA,SAAO,UAAU,KAAK;AACvB;"}
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/index.js'\nimport { identityEnvironmentExtension, projectEnvironmentExtension } from '../environment/index.js'\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<string>(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,oBAAA;AAErB,SAAO,kBAAkB,MAAM,YAAY,IAAI,oBAAA,UAAA,EAAG,UAAS,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,IAAY,UAAU,SAAS,KAAK,CAAA,OAAM,GAAG,SAAS,OAAO,GAAG,SAAS,CAAA,CAAE;AAEpG,SAAO,kBAAkB,MAAM,YAAY,IAAI,oBAAA,UAAA,EAAG,UAAS,IAAM;AAClE,CAAC;AAED,MAAM,oBAAoB,CAAC,WAA0B,UAAuB;AAC3E,MAAI,OAAO,cAAc,UAAU;AAClC,WAAO,MAAM,IAAI,SAAS;AAAA,EAC3B;AACA,SAAO,UAAU,KAAK;AACvB;"}
@@ -1 +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\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\t)\n}\n"],"names":["useIdentity","EnvironmentExtensionProvider","identityEnvironmentExtension"],"mappings":";;;;;;AASO,MAAM,8BAA0E,CAAC,EAAE,eAAe;AACxG,QAAM,WAAWA,kBAAAA,YAAA;AACjB,wCACEC,2CAAA,EAA6B,WAAWC,6BAAAA,8BAA8B,OAAO,YAAY,MACxF,UACF;AAEF;;"}
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/index.js'\nimport { useIdentity } from '@contember/react-client-tenant'\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\t)\n}\n"],"names":["useIdentity","EnvironmentExtensionProvider","identityEnvironmentExtension"],"mappings":";;;;;;AASO,MAAM,8BAA0E,CAAC,EAAE,eAAe;AACxG,QAAM,WAAWA,kBAAAA,YAAA;AACjB,wCACEC,2CAAA,EAA6B,WAAWC,6BAAAA,8BAA8B,OAAO,YAAY,MACxF,UACF;AAEF;;"}
@@ -1 +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\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\t)\n}\n"],"names":[],"mappings":";;;;AASO,MAAM,8BAA0E,CAAC,EAAE,eAAe;AACxG,QAAM,WAAW,YAAA;AACjB,6BACE,8BAAA,EAA6B,WAAW,8BAA8B,OAAO,YAAY,MACxF,UACF;AAEF;"}
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/index.js'\nimport { useIdentity } from '@contember/react-client-tenant'\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\t)\n}\n"],"names":[],"mappings":";;;;AASO,MAAM,8BAA0E,CAAC,EAAE,eAAe;AACxG,QAAM,WAAW,YAAA;AACjB,6BACE,8BAAA,EAA6B,WAAW,8BAA8B,OAAO,YAAY,MACxF,UACF;AAEF;"}
@@ -1,3 +1,3 @@
1
- export * from './HasRole';
2
- export * from './IdentityEnvironmentProvider';
1
+ export * from './HasRole.js';
2
+ export * from './IdentityEnvironmentProvider.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,+BAA+B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,kCAAkC,CAAA"}
@@ -1,3 +1,3 @@
1
- export * from './IdentityEnvironmentExtension';
2
- export * from './ProjectEnvironmentExtension';
1
+ export * from './IdentityEnvironmentExtension.js';
2
+ export * from './ProjectEnvironmentExtension.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/environment/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAA;AAC9C,cAAc,+BAA+B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/environment/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAA;AACjD,cAAc,kCAAkC,CAAA"}
@@ -1,2 +1,2 @@
1
- export * from './useProjectUserRoles';
1
+ export * from './useProjectUserRoles.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA"}
@@ -1,5 +1,5 @@
1
- export * from './components';
2
- export * from './hooks';
3
- export * from './environment';
1
+ export * from './components/index.js';
2
+ export * from './hooks/index.js';
3
+ export * from './environment/index.js';
4
4
  export * from '@contember/react-client-tenant';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe,CAAA;AAC7B,cAAc,gCAAgC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,gCAAgC,CAAA"}