@stigg/react-sdk 5.27.0 → 5.28.0

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.27.0",
2
+ "version": "5.28.0",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { GetNumericEntitlement } from '@stigg/js-client-sdk';
3
+ import { useNumericEntitlement } from '../hooks';
4
+
5
+ type NumericEntitlementGuardProps = GetNumericEntitlement & {
6
+ noAccessComponent?: React.ReactNode;
7
+ children: React.ReactElement;
8
+ };
9
+
10
+ export function NumericEntitlementGuard({
11
+ noAccessComponent,
12
+ children,
13
+ ...rest
14
+ }: NumericEntitlementGuardProps): JSX.Element {
15
+ const { hasAccess } = useNumericEntitlement(rest);
16
+
17
+ if (!hasAccess) {
18
+ return <>{noAccessComponent ?? null}</>;
19
+ }
20
+
21
+ return children;
22
+ }
package/src/index.ts CHANGED
@@ -63,4 +63,5 @@ export {
63
63
  export { HorizontalAlignment, TextAlignment, FontVariant, FontWeight, StiggTheme } from './theme/types';
64
64
  export { CustomizedTheme as Theme } from './theme/Theme';
65
65
  export { BooleanEntitlementGuard } from './components/BooleanEntitlementGuard';
66
+ export { NumericEntitlementGuard } from './components/NumericEntitlementGuard';
66
67
  export { MeteredEntitlementGuard } from './components/MeteredEntitlementGuard';