@stream-io/video-react-bindings 0.0.1-alpha.39 → 0.0.1-alpha.41

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,24 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.0.1-alpha.41](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-bindings-0.0.1-alpha.40...@stream-io/video-react-bindings-0.0.1-alpha.41) (2023-05-17)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * reorganize call control buttons ([#514](https://github.com/GetStream/stream-video-js/issues/514)) ([ed1df9c](https://github.com/GetStream/stream-video-js/commit/ed1df9c230d20c2f08d0d97e2eaa962d22c7fc36))
11
+
12
+
13
+
14
+ ## [0.0.1-alpha.40](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-bindings-0.0.1-alpha.39...@stream-io/video-react-bindings-0.0.1-alpha.40) (2023-05-17)
15
+
16
+
17
+ ### Features
18
+
19
+ * **react-native:** add reactions support ([#440](https://github.com/GetStream/stream-video-js/issues/440)) ([353a9c9](https://github.com/GetStream/stream-video-js/commit/353a9c99d8b954267191f44168cb21a6490a3eeb))
20
+
21
+
22
+
5
23
  ## [0.0.1-alpha.39](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-bindings-0.0.1-alpha.38...@stream-io/video-react-bindings-0.0.1-alpha.39) (2023-05-17)
6
24
 
7
25
 
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './src/contexts';
2
2
  export * from './src/hooks';
3
+ export * from './src/wrappers';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './src/contexts';
2
2
  export * from './src/hooks';
3
+ export * from './src/wrappers';
3
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../../src/hooks/permissions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAG,WAA4B,EAAE,EAAE;IACnE,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5B,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE,CACtC,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAC/C,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,OAAO,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,gBAAgB,KAAI,EAAE,CAAC;AAC1C,CAAC,CAAC"}
1
+ {"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../../src/hooks/permissions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAG,WAA4B,EAAE,EAAE;IACnE,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5B,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE,CACtC,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAC/C,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAoB,EAAE;IACtD,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,OAAO,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,gBAAgB,KAAI,EAAE,CAAC;AAC1C,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { OwnCapability } from '@stream-io/video-client';
2
+ import { PropsWithChildren } from 'react';
3
+ type RestrictedProps = PropsWithChildren<{
4
+ /**
5
+ * OwnCapabilities of the participant - grants they have available
6
+ */
7
+ availableGrants?: OwnCapability[];
8
+ /**
9
+ * Required grants for the component to be able to render supplied children elements
10
+ */
11
+ requiredGrants: OwnCapability[];
12
+ /**
13
+ * Require all grants specified in `requiredGrants` to be available in the `availableGrants`,
14
+ * component by default requires only one grant to appear in both arrays to render its children
15
+ */
16
+ requireAll?: boolean;
17
+ }>;
18
+ export declare const Restricted: ({ availableGrants: availableGrantsFromProps, requiredGrants, requireAll, children, }: RestrictedProps) => JSX.Element | null;
19
+ export {};
@@ -0,0 +1,14 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCall } from '../contexts';
3
+ import { useOwnCapabilities } from '../hooks';
4
+ export const Restricted = ({ availableGrants: availableGrantsFromProps, requiredGrants, requireAll = true, children, }) => {
5
+ const call = useCall();
6
+ const ownCapabilities = useOwnCapabilities();
7
+ const availableGrants = availableGrantsFromProps !== null && availableGrantsFromProps !== void 0 ? availableGrantsFromProps : ownCapabilities;
8
+ const hasPermissions = requiredGrants[requireAll ? 'every' : 'some']((capability) => availableGrants.includes(capability));
9
+ const canRequest = requiredGrants.some((capability) => !!call && call.permissionsContext.canRequest(capability));
10
+ if (hasPermissions || canRequest)
11
+ return _jsx(_Fragment, { children: children });
12
+ return null;
13
+ };
14
+ //# sourceMappingURL=Restricted.js.map
@@ -0,0 +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"}
@@ -0,0 +1 @@
1
+ export * from './Restricted';
@@ -0,0 +1,2 @@
1
+ export * from './Restricted';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/wrappers/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
package/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './src/contexts';
2
2
  export * from './src/hooks';
3
+ export * from './src/wrappers';
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.1-alpha.28",
27
- "@stream-io/video-client": "^0.0.1-alpha.152",
26
+ "@stream-io/i18n": "^0.0.1-alpha.30",
27
+ "@stream-io/video-client": "^0.0.1-alpha.154",
28
28
  "react": ">=17.0.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@stream-io/i18n": "^0.0.1-alpha.28",
32
- "@stream-io/video-client": "^0.0.1-alpha.152",
31
+ "@stream-io/i18n": "^0.0.1-alpha.30",
32
+ "@stream-io/video-client": "^0.0.1-alpha.154",
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.1-alpha.39"
42
+ "version": "0.0.1-alpha.41"
43
43
  }
@@ -21,7 +21,7 @@ export const useHasPermissions = (...permissions: OwnCapability[]) => {
21
21
  *
22
22
  * @category Call State
23
23
  */
24
- export const useOwnCapabilities = () => {
24
+ export const useOwnCapabilities = (): OwnCapability[] => {
25
25
  const metadata = useCallMetadata();
26
26
  return metadata?.own_capabilities || [];
27
27
  };
@@ -0,0 +1,40 @@
1
+ import { OwnCapability } from '@stream-io/video-client';
2
+
3
+ import { PropsWithChildren } from 'react';
4
+ import { useCall } from '../contexts';
5
+ import { useOwnCapabilities } from '../hooks';
6
+
7
+ type RestrictedProps = PropsWithChildren<{
8
+ /**
9
+ * OwnCapabilities of the participant - grants they have available
10
+ */
11
+ availableGrants?: OwnCapability[];
12
+ /**
13
+ * Required grants for the component to be able to render supplied children elements
14
+ */
15
+ requiredGrants: OwnCapability[];
16
+ /**
17
+ * Require all grants specified in `requiredGrants` to be available in the `availableGrants`,
18
+ * component by default requires only one grant to appear in both arrays to render its children
19
+ */
20
+ requireAll?: boolean;
21
+ }>;
22
+
23
+ export const Restricted = ({
24
+ availableGrants: availableGrantsFromProps,
25
+ requiredGrants,
26
+ requireAll = true,
27
+ children,
28
+ }: RestrictedProps) => {
29
+ const call = useCall();
30
+ const ownCapabilities = useOwnCapabilities();
31
+ const availableGrants = availableGrantsFromProps ?? ownCapabilities;
32
+ const hasPermissions = requiredGrants[requireAll ? 'every' : 'some'](
33
+ (capability) => availableGrants.includes(capability),
34
+ );
35
+ const canRequest = requiredGrants.some(
36
+ (capability) => !!call && call.permissionsContext.canRequest(capability),
37
+ );
38
+ if (hasPermissions || canRequest) return <>{children}</>;
39
+ return null;
40
+ };
@@ -0,0 +1 @@
1
+ export * from './Restricted';