@stream-io/video-react-bindings 0.0.9 → 0.0.11

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
@@ -2,6 +2,22 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ### [0.0.11](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-bindings-0.0.10...@stream-io/video-react-bindings-0.0.11) (2023-06-13)
6
+
7
+ ### Dependency Updates
8
+
9
+ * `@stream-io/video-client` updated to version `0.0.1`
10
+
11
+ ### Features
12
+
13
+ * add audio room demo app ([#572](https://github.com/GetStream/stream-video-js/issues/572)) ([77f7b65](https://github.com/GetStream/stream-video-js/commit/77f7b6596047d59e10c8e58abad38c4f48cc162f))
14
+
15
+ ### [0.0.10](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-bindings-0.0.9...@stream-io/video-react-bindings-0.0.10) (2023-06-12)
16
+
17
+ ### Dependency Updates
18
+
19
+ * `@stream-io/i18n` updated to version `0.0.3`
20
+ * `@stream-io/video-client` updated to version `0.0.1`
5
21
  ### [0.0.9](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-bindings-0.0.8...@stream-io/video-react-bindings-0.0.9) (2023-06-12)
6
22
 
7
23
  ### Dependency Updates
@@ -4,4 +4,4 @@
4
4
  *
5
5
  * @category Client State
6
6
  */
7
- export declare const useConnectedUser: () => import("@stream-io/video-client").User | undefined;
7
+ export declare const useConnectedUser: () => import("@stream-io/video-client").OwnUserResponse | undefined;
@@ -1,19 +1,27 @@
1
1
  import { OwnCapability } from '@stream-io/video-client';
2
2
  import { PropsWithChildren } from 'react';
3
3
  type RestrictedProps = PropsWithChildren<{
4
+ /**
5
+ * Required grants for the component to be able to render supplied children elements
6
+ */
7
+ requiredGrants: OwnCapability[];
4
8
  /**
5
9
  * OwnCapabilities of the participant - grants they have available
6
10
  */
7
11
  availableGrants?: OwnCapability[];
8
12
  /**
9
- * Required grants for the component to be able to render supplied children elements
13
+ * Render children only if user can request capability, but does not have it
10
14
  */
11
- requiredGrants: OwnCapability[];
15
+ canRequestOnly?: boolean;
16
+ /**
17
+ * Render children only if user has capability
18
+ */
19
+ hasPermissionsOnly?: boolean;
12
20
  /**
13
21
  * Require all grants specified in `requiredGrants` to be available in the `availableGrants`,
14
22
  * component by default requires only one grant to appear in both arrays to render its children
15
23
  */
16
24
  requireAll?: boolean;
17
25
  }>;
18
- export declare const Restricted: ({ availableGrants: availableGrantsFromProps, requiredGrants, requireAll, children, }: RestrictedProps) => JSX.Element | null;
26
+ export declare const Restricted: ({ availableGrants: availableGrantsFromProps, canRequestOnly, hasPermissionsOnly, requiredGrants, requireAll, children, }: RestrictedProps) => JSX.Element | null;
19
27
  export {};
@@ -1,12 +1,16 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useCall } from '../contexts';
3
3
  import { useOwnCapabilities } from '../hooks';
4
- export const Restricted = ({ availableGrants: availableGrantsFromProps, requiredGrants, requireAll = true, children, }) => {
4
+ export const Restricted = ({ availableGrants: availableGrantsFromProps, canRequestOnly, hasPermissionsOnly, requiredGrants, requireAll = true, children, }) => {
5
5
  const call = useCall();
6
6
  const ownCapabilities = useOwnCapabilities();
7
7
  const availableGrants = availableGrantsFromProps !== null && availableGrantsFromProps !== void 0 ? availableGrantsFromProps : ownCapabilities;
8
8
  const hasPermissions = requiredGrants[requireAll ? 'every' : 'some']((capability) => availableGrants.includes(capability));
9
+ if (hasPermissionsOnly)
10
+ return hasPermissions ? _jsx(_Fragment, { children: children }) : null;
9
11
  const canRequest = requiredGrants.some((capability) => !!call && call.permissionsContext.canRequest(capability));
12
+ if (canRequestOnly)
13
+ return canRequest ? _jsx(_Fragment, { children: children }) : null;
10
14
  if (hasPermissions || canRequest)
11
15
  return _jsx(_Fragment, { children: children });
12
16
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"Restricted.js","sourceRoot":"","sources":["../../../src/wrappers/Restricted.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAkB9C,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,eAAe,EAAE,wBAAwB,EACzC,cAAc,EACd,UAAU,GAAG,IAAI,EACjB,QAAQ,GACQ,EAAE,EAAE;IACpB,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAC;IAC7C,MAAM,eAAe,GAAG,wBAAwB,aAAxB,wBAAwB,cAAxB,wBAAwB,GAAI,eAAe,CAAC;IACpE,MAAM,cAAc,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAClE,CAAC,UAAU,EAAE,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,UAAU,CAAC,CACrD,CAAC;IACF,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CACpC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,UAAU,CAAC,CACzE,CAAC;IACF,IAAI,cAAc,IAAI,UAAU;QAAE,OAAO,4BAAG,QAAQ,GAAI,CAAC;IACzD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
1
+ {"version":3,"file":"Restricted.js","sourceRoot":"","sources":["../../../src/wrappers/Restricted.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AA0B9C,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,eAAe,EAAE,wBAAwB,EACzC,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,UAAU,GAAG,IAAI,EACjB,QAAQ,GACQ,EAAE,EAAE;IACpB,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAC;IAC7C,MAAM,eAAe,GAAG,wBAAwB,aAAxB,wBAAwB,cAAxB,wBAAwB,GAAI,eAAe,CAAC;IACpE,MAAM,cAAc,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAClE,CAAC,UAAU,EAAE,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,UAAU,CAAC,CACrD,CAAC;IAEF,IAAI,kBAAkB;QAAE,OAAO,cAAc,CAAC,CAAC,CAAC,4BAAG,QAAQ,GAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAEvE,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CACpC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,UAAU,CAAC,CACzE,CAAC;IAEF,IAAI,cAAc;QAAE,OAAO,UAAU,CAAC,CAAC,CAAC,4BAAG,QAAQ,GAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAE/D,IAAI,cAAc,IAAI,UAAU;QAAE,OAAO,4BAAG,QAAQ,GAAI,CAAC;IAEzD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
package/package.json CHANGED
@@ -23,13 +23,13 @@
23
23
  "rxjs": "~7.8.1"
24
24
  },
25
25
  "peerDependencies": {
26
- "@stream-io/i18n": "^0.0.2",
27
- "@stream-io/video-client": "^0.0.9",
26
+ "@stream-io/i18n": "^0.0.3",
27
+ "@stream-io/video-client": "^0.0.11",
28
28
  "react": ">=17.0.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@stream-io/i18n": "^0.0.2",
32
- "@stream-io/video-client": "^0.0.9",
31
+ "@stream-io/i18n": "^0.0.3",
32
+ "@stream-io/video-client": "^0.0.11",
33
33
  "@types/react": "^18.0.26",
34
34
  "@types/rimraf": "^3.0.2",
35
35
  "react": "^18.2.0",
@@ -39,5 +39,5 @@
39
39
  "typedoc-plugin-markdown": "^3.15.3",
40
40
  "typescript": "^4.9.5"
41
41
  },
42
- "version": "0.0.9"
42
+ "version": "0.0.11"
43
43
  }
@@ -5,14 +5,22 @@ import { useCall } from '../contexts';
5
5
  import { useOwnCapabilities } from '../hooks';
6
6
 
7
7
  type RestrictedProps = PropsWithChildren<{
8
+ /**
9
+ * Required grants for the component to be able to render supplied children elements
10
+ */
11
+ requiredGrants: OwnCapability[];
8
12
  /**
9
13
  * OwnCapabilities of the participant - grants they have available
10
14
  */
11
15
  availableGrants?: OwnCapability[];
12
16
  /**
13
- * Required grants for the component to be able to render supplied children elements
17
+ * Render children only if user can request capability, but does not have it
14
18
  */
15
- requiredGrants: OwnCapability[];
19
+ canRequestOnly?: boolean;
20
+ /**
21
+ * Render children only if user has capability
22
+ */
23
+ hasPermissionsOnly?: boolean;
16
24
  /**
17
25
  * Require all grants specified in `requiredGrants` to be available in the `availableGrants`,
18
26
  * component by default requires only one grant to appear in both arrays to render its children
@@ -22,6 +30,8 @@ type RestrictedProps = PropsWithChildren<{
22
30
 
23
31
  export const Restricted = ({
24
32
  availableGrants: availableGrantsFromProps,
33
+ canRequestOnly,
34
+ hasPermissionsOnly,
25
35
  requiredGrants,
26
36
  requireAll = true,
27
37
  children,
@@ -32,9 +42,16 @@ export const Restricted = ({
32
42
  const hasPermissions = requiredGrants[requireAll ? 'every' : 'some'](
33
43
  (capability) => availableGrants.includes(capability),
34
44
  );
45
+
46
+ if (hasPermissionsOnly) return hasPermissions ? <>{children}</> : null;
47
+
35
48
  const canRequest = requiredGrants.some(
36
49
  (capability) => !!call && call.permissionsContext.canRequest(capability),
37
50
  );
51
+
52
+ if (canRequestOnly) return canRequest ? <>{children}</> : null;
53
+
38
54
  if (hasPermissions || canRequest) return <>{children}</>;
55
+
39
56
  return null;
40
57
  };