@stigg/react-sdk 5.5.1 → 5.7.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/dist/components/customerPortal/CustomerPortal.d.ts +2 -1
- package/dist/components/customerPortal/CustomerPortalContainer.d.ts +1 -1
- package/dist/components/customerPortal/types.d.ts +1 -0
- package/dist/components/customerPortal/usage/CustomerUsageData.d.ts +3 -2
- package/dist/components/utils/onWheelBlur.d.ts +2 -0
- package/dist/react-sdk.cjs.development.js +20 -12
- package/dist/react-sdk.cjs.development.js.map +1 -1
- package/dist/react-sdk.cjs.production.min.js +1 -1
- package/dist/react-sdk.cjs.production.min.js.map +1 -1
- package/dist/react-sdk.esm.js +20 -12
- package/dist/react-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/checkout/steps/addons/CheckoutAddonsStep.tsx +2 -0
- package/src/components/checkout/steps/plan/CheckoutChargeList.tsx +2 -1
- package/src/components/common/VolumePerUnitInput.tsx +2 -0
- package/src/components/customerPortal/CustomerPortal.tsx +2 -1
- package/src/components/customerPortal/CustomerPortalContainer.tsx +8 -1
- package/src/components/customerPortal/subscriptionOverview/charges/ChargeItem.tsx +3 -1
- package/src/components/customerPortal/types.ts +2 -0
- package/src/components/customerPortal/usage/CustomerUsageData.tsx +8 -5
- package/src/components/utils/onWheelBlur.ts +3 -0
package/package.json
CHANGED
|
@@ -12,6 +12,7 @@ import { usePlanStepModel } from '../../hooks/usePlanStepModel';
|
|
|
12
12
|
import { AddonListItemContainer, CheckoutAddonsContainer, TrashButton } from './CheckoutAddonsStep.style';
|
|
13
13
|
import { CheckoutLocalization } from '../../configurations/textOverrides';
|
|
14
14
|
import { useCheckoutModel, useProgressBarModel } from '../../hooks';
|
|
15
|
+
import { ON_WHEEL_BLUR } from '../../../utils/onWheelBlur';
|
|
15
16
|
|
|
16
17
|
type UseAddonsStepModel = ReturnType<typeof useAddonsStepModel>;
|
|
17
18
|
|
|
@@ -96,6 +97,7 @@ function AddonListItem({
|
|
|
96
97
|
<InputField
|
|
97
98
|
id={`${addon.id}-input`}
|
|
98
99
|
type="number"
|
|
100
|
+
onWheel={ON_WHEEL_BLUR}
|
|
99
101
|
sx={{ width: 120, marginX: 2 }}
|
|
100
102
|
value={addonState?.quantity ?? ''}
|
|
101
103
|
error={!isValid}
|
|
@@ -14,6 +14,7 @@ import { useCheckoutModel, usePlanStepModel, useProgressBarModel } from '../../h
|
|
|
14
14
|
import { TiersSelectContainer } from '../../../common/TiersSelectContainer';
|
|
15
15
|
import { getValidPriceQuantity } from '../../../utils/priceUtils';
|
|
16
16
|
import { getFeatureDisplayNameText } from '../../../utils/getFeatureName';
|
|
17
|
+
import { ON_WHEEL_BLUR } from '../../../utils/onWheelBlur';
|
|
17
18
|
|
|
18
19
|
export type UsePlanStepModel = ReturnType<typeof usePlanStepModel>;
|
|
19
20
|
|
|
@@ -122,12 +123,12 @@ export function PlanCharge({
|
|
|
122
123
|
sx={{ width: 120 }}
|
|
123
124
|
id={`${featureId}-input`}
|
|
124
125
|
type="number"
|
|
126
|
+
onWheel={ON_WHEEL_BLUR}
|
|
125
127
|
error={!isValid}
|
|
126
128
|
helperText={!isValid ? getValidationText(charge, billableFeature?.quantity) : undefined}
|
|
127
129
|
FormHelperTextProps={{ sx: { margin: '4px' } }}
|
|
128
130
|
value={billableFeature?.quantity ?? ''}
|
|
129
131
|
onChange={handleQuantityChange}
|
|
130
|
-
onWheel={(e: React.WheelEvent<HTMLInputElement>) => (e.target as HTMLElement).blur()}
|
|
131
132
|
/>
|
|
132
133
|
);
|
|
133
134
|
}
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { Typography } from './Typography';
|
|
4
4
|
import { InputField } from '../checkout/components';
|
|
5
5
|
import { TiersSelectContainerProps } from './TiersSelectContainer';
|
|
6
|
+
import { ON_WHEEL_BLUR } from '../utils/onWheelBlur';
|
|
6
7
|
|
|
7
8
|
export function VolumePerUnitInput({
|
|
8
9
|
width,
|
|
@@ -15,6 +16,7 @@ export function VolumePerUnitInput({
|
|
|
15
16
|
return (
|
|
16
17
|
<InputField
|
|
17
18
|
type="number"
|
|
19
|
+
onWheel={ON_WHEEL_BLUR}
|
|
18
20
|
fullWidth
|
|
19
21
|
sx={{ minHeight: '46px', width }}
|
|
20
22
|
InputProps={{
|
|
@@ -5,7 +5,7 @@ import { CustomerPortalContainer } from './CustomerPortalContainer';
|
|
|
5
5
|
import { DeepPartial } from '../../types';
|
|
6
6
|
import { CustomerPortalLocalization } from './customerPortalTextOverrides';
|
|
7
7
|
import { CustomerPortalTheme } from './customerPortalTheme';
|
|
8
|
-
import { OnBuyMoreCallbackFn, OnManageSubscriptionFn } from './types';
|
|
8
|
+
import { FilterEntitlementsFn, OnBuyMoreCallbackFn, OnManageSubscriptionFn } from './types';
|
|
9
9
|
|
|
10
10
|
export type CustomerPortalSection =
|
|
11
11
|
| 'usage'
|
|
@@ -24,6 +24,7 @@ export type CustomerPortalProps = {
|
|
|
24
24
|
hiddenSections?: CustomerPortalSection[];
|
|
25
25
|
textOverrides?: DeepPartial<CustomerPortalLocalization>;
|
|
26
26
|
theme?: DeepPartial<CustomerPortalTheme>;
|
|
27
|
+
filterEntitlements?: FilterEntitlementsFn;
|
|
27
28
|
resourceId?: string;
|
|
28
29
|
productId?: string;
|
|
29
30
|
};
|
|
@@ -19,6 +19,7 @@ export function CustomerPortalContainer({
|
|
|
19
19
|
onContactSupport,
|
|
20
20
|
paywallComponent,
|
|
21
21
|
hiddenSections,
|
|
22
|
+
filterEntitlements,
|
|
22
23
|
}: CustomerPortalProps) {
|
|
23
24
|
const { stigg } = useStiggContext();
|
|
24
25
|
const { customerPortal, textOverrides, theme, isLoading } = useCustomerPortalContext();
|
|
@@ -55,7 +56,13 @@ export function CustomerPortalContainer({
|
|
|
55
56
|
hiddenSections={hiddenSections}
|
|
56
57
|
cancelScheduledUpdatesButtonTitle={textOverrides.cancelScheduledUpdatesButtonTitle}
|
|
57
58
|
/>
|
|
58
|
-
{shouldShowUsage &&
|
|
59
|
+
{shouldShowUsage && (
|
|
60
|
+
<CustomerUsageData
|
|
61
|
+
onManageSubscription={onManageClick}
|
|
62
|
+
onBuyMore={onBuyMore}
|
|
63
|
+
filterEntitlements={filterEntitlements}
|
|
64
|
+
/>
|
|
65
|
+
)}
|
|
59
66
|
<CustomerPortalPaywall
|
|
60
67
|
ref={customerPortalSectionRef}
|
|
61
68
|
paywallComponent={paywallComponent}
|
|
@@ -33,7 +33,9 @@ export function ChargeItem({
|
|
|
33
33
|
hasCustomSubscription,
|
|
34
34
|
}: UsageBasedChargeProps) {
|
|
35
35
|
return (
|
|
36
|
-
<div
|
|
36
|
+
<div
|
|
37
|
+
className={`stigg-charge-list-item stigg-charge-list-item-${entitlement.feature!.refId}`}
|
|
38
|
+
style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
|
37
39
|
<div style={{ display: 'flex', justifyContent: 'space-between', gap: 12 }}>
|
|
38
40
|
<div style={{ display: 'flex', gap: 12 }}>
|
|
39
41
|
<LongText variant="body1" color="primary">
|
|
@@ -3,6 +3,8 @@ import { FeatureFragment } from '@stigg/api-client-js/src/generated/sdk';
|
|
|
3
3
|
|
|
4
4
|
export type OnBuyMoreCallbackFn = (feature: FeatureFragment, entitlement: CustomerPortalEntitlement) => void;
|
|
5
5
|
|
|
6
|
+
export type FilterEntitlementsFn = (entitlements: CustomerPortalEntitlement[]) => CustomerPortalEntitlement[];
|
|
7
|
+
|
|
6
8
|
export enum CustomerPortalIntentionType {
|
|
7
9
|
MANAGE_SUBSCRIPTION = 'MANAGE_SUBSCRIPTION',
|
|
8
10
|
UPGRADE_PLAN = 'UPGRADE_PLAN',
|
|
@@ -10,7 +10,7 @@ import { SectionContainer } from '../common/SectionContainer';
|
|
|
10
10
|
import { SectionHeader } from '../common/SectionHeader';
|
|
11
11
|
import { SectionTitle } from '../common/SectionTitle';
|
|
12
12
|
import { StyledButton } from '../common/StyledButton';
|
|
13
|
-
import { OnBuyMoreCallbackFn } from '../types';
|
|
13
|
+
import { FilterEntitlementsFn, OnBuyMoreCallbackFn } from '../types';
|
|
14
14
|
import { OnManageClick } from '../CustomerPortalContainer';
|
|
15
15
|
|
|
16
16
|
const MAX_BOXES = 6;
|
|
@@ -18,9 +18,10 @@ const MAX_BOXES = 6;
|
|
|
18
18
|
export type CustomerUsageDataProps = {
|
|
19
19
|
onManageSubscription?: OnManageClick;
|
|
20
20
|
onBuyMore?: OnBuyMoreCallbackFn;
|
|
21
|
+
filterEntitlements?: FilterEntitlementsFn;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
|
-
export function CustomerUsageData({ onManageSubscription, onBuyMore }: CustomerUsageDataProps) {
|
|
24
|
+
export function CustomerUsageData({ onManageSubscription, onBuyMore, filterEntitlements }: CustomerUsageDataProps) {
|
|
24
25
|
const [showAll, setShowAll] = React.useState(false);
|
|
25
26
|
const { customerPortal, isLoading, textOverrides, theme } = useCustomerPortalContext();
|
|
26
27
|
const isLoadingData = isLoading || !customerPortal;
|
|
@@ -48,10 +49,12 @@ export function CustomerUsageData({ onManageSubscription, onBuyMore }: CustomerU
|
|
|
48
49
|
);
|
|
49
50
|
const sortedEntitlements = [...priceEntitlements, ...otherEntitlements];
|
|
50
51
|
|
|
52
|
+
const filteredEntitlements = filterEntitlements ? filterEntitlements(sortedEntitlements) : sortedEntitlements;
|
|
53
|
+
|
|
51
54
|
// 4 -> 3 per row, 6 -> 2 per row
|
|
52
|
-
const xs =
|
|
55
|
+
const xs = filteredEntitlements.length > 2 ? 4 : 6;
|
|
53
56
|
|
|
54
|
-
const entitlementsToShow = showAll ?
|
|
57
|
+
const entitlementsToShow = showAll ? filteredEntitlements : filteredEntitlements.slice(0, MAX_BOXES);
|
|
55
58
|
|
|
56
59
|
const toggleShowAll = () => setShowAll((prevState) => !prevState);
|
|
57
60
|
|
|
@@ -96,7 +99,7 @@ export function CustomerUsageData({ onManageSubscription, onBuyMore }: CustomerU
|
|
|
96
99
|
))}
|
|
97
100
|
</Grid>
|
|
98
101
|
|
|
99
|
-
{
|
|
102
|
+
{filteredEntitlements.length > MAX_BOXES && (
|
|
100
103
|
<Footer>
|
|
101
104
|
<StyledButton
|
|
102
105
|
className="stigg-usage-toggle-many-button"
|