@schematichq/schematic-components 2.1.0 → 2.1.2
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/schematic-components.cjs.js +261 -112
- package/dist/schematic-components.d.ts +148 -12
- package/dist/schematic-components.esm.js +355 -204
- package/package.json +11 -11
|
@@ -4254,6 +4254,7 @@ var initialContext = {
|
|
|
4254
4254
|
setAccessToken: stub,
|
|
4255
4255
|
setLayout: stub,
|
|
4256
4256
|
setCheckoutState: stub,
|
|
4257
|
+
initializeWithPlan: stub,
|
|
4257
4258
|
setData: stub,
|
|
4258
4259
|
updateSettings: stub,
|
|
4259
4260
|
debug: stub,
|
|
@@ -6376,7 +6377,9 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
6376
6377
|
return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
|
|
6377
6378
|
}
|
|
6378
6379
|
static createInstance(options = {}, callback) {
|
|
6379
|
-
|
|
6380
|
+
const instance2 = new _I18n(options, callback);
|
|
6381
|
+
instance2.createInstance = _I18n.createInstance;
|
|
6382
|
+
return instance2;
|
|
6380
6383
|
}
|
|
6381
6384
|
cloneInstance(options = {}, callback = noop) {
|
|
6382
6385
|
const forkResourceStore = options.forkResourceStore;
|
|
@@ -6440,7 +6443,6 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
6440
6443
|
}
|
|
6441
6444
|
};
|
|
6442
6445
|
var instance = I18n.createInstance();
|
|
6443
|
-
instance.createInstance = I18n.createInstance;
|
|
6444
6446
|
var createInstance = instance.createInstance;
|
|
6445
6447
|
var dir = instance.dir;
|
|
6446
6448
|
var init = instance.init;
|
|
@@ -7997,6 +7999,13 @@ function BillingPlanCreditGrantResponseDataFromJSONTyped(json, ignoreDiscriminat
|
|
|
7997
7999
|
return json;
|
|
7998
8000
|
}
|
|
7999
8001
|
return {
|
|
8002
|
+
autoTopupAmount: json["auto_topup_amount"] == null ? void 0 : json["auto_topup_amount"],
|
|
8003
|
+
autoTopupAmountType: json["auto_topup_amount_type"] == null ? void 0 : json["auto_topup_amount_type"],
|
|
8004
|
+
autoTopupEnabled: json["auto_topup_enabled"],
|
|
8005
|
+
autoTopupExpiryType: json["auto_topup_expiry_type"] == null ? void 0 : json["auto_topup_expiry_type"],
|
|
8006
|
+
autoTopupExpiryUnit: json["auto_topup_expiry_unit"] == null ? void 0 : json["auto_topup_expiry_unit"],
|
|
8007
|
+
autoTopupExpiryUnitCount: json["auto_topup_expiry_unit_count"] == null ? void 0 : json["auto_topup_expiry_unit_count"],
|
|
8008
|
+
autoTopupThresholdPercent: json["auto_topup_threshold_percent"] == null ? void 0 : json["auto_topup_threshold_percent"],
|
|
8000
8009
|
createdAt: new Date(json["created_at"]),
|
|
8001
8010
|
creditAmount: json["credit_amount"],
|
|
8002
8011
|
creditId: json["credit_id"],
|
|
@@ -8223,6 +8232,7 @@ function BillingSubscriptionViewFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8223
8232
|
return json;
|
|
8224
8233
|
}
|
|
8225
8234
|
return {
|
|
8235
|
+
applicationId: json["application_id"] == null ? void 0 : json["application_id"],
|
|
8226
8236
|
cancelAt: json["cancel_at"] == null ? void 0 : json["cancel_at"],
|
|
8227
8237
|
cancelAtPeriodEnd: json["cancel_at_period_end"],
|
|
8228
8238
|
companyId: json["company_id"] == null ? void 0 : json["company_id"],
|
|
@@ -8318,6 +8328,7 @@ function CheckoutResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8318
8328
|
return json;
|
|
8319
8329
|
}
|
|
8320
8330
|
return {
|
|
8331
|
+
applicationId: json["application_id"] == null ? void 0 : json["application_id"],
|
|
8321
8332
|
cancelAt: json["cancel_at"] == null ? void 0 : json["cancel_at"],
|
|
8322
8333
|
cancelAtPeriodEnd: json["cancel_at_period_end"],
|
|
8323
8334
|
companyId: json["company_id"] == null ? void 0 : json["company_id"],
|
|
@@ -8432,6 +8443,43 @@ function CompanyEventPeriodMetricsResponseDataFromJSONTyped(json, ignoreDiscrimi
|
|
|
8432
8443
|
};
|
|
8433
8444
|
}
|
|
8434
8445
|
|
|
8446
|
+
// src/api/checkoutexternal/models/PlanCreditGrantView.ts
|
|
8447
|
+
function PlanCreditGrantViewFromJSON(json) {
|
|
8448
|
+
return PlanCreditGrantViewFromJSONTyped(json, false);
|
|
8449
|
+
}
|
|
8450
|
+
function PlanCreditGrantViewFromJSONTyped(json, ignoreDiscriminator) {
|
|
8451
|
+
if (json == null) {
|
|
8452
|
+
return json;
|
|
8453
|
+
}
|
|
8454
|
+
return {
|
|
8455
|
+
billingCreditAutoTopupAmount: json["billing_credit_auto_topup_amount"] == null ? void 0 : json["billing_credit_auto_topup_amount"],
|
|
8456
|
+
billingCreditAutoTopupAmountType: json["billing_credit_auto_topup_amount_type"] == null ? void 0 : json["billing_credit_auto_topup_amount_type"],
|
|
8457
|
+
billingCreditAutoTopupEnabled: json["billing_credit_auto_topup_enabled"],
|
|
8458
|
+
billingCreditAutoTopupExpiryType: json["billing_credit_auto_topup_expiry_type"] == null ? void 0 : json["billing_credit_auto_topup_expiry_type"],
|
|
8459
|
+
billingCreditAutoTopupExpiryUnit: json["billing_credit_auto_topup_expiry_unit"] == null ? void 0 : json["billing_credit_auto_topup_expiry_unit"],
|
|
8460
|
+
billingCreditAutoTopupExpiryUnitCount: json["billing_credit_auto_topup_expiry_unit_count"] == null ? void 0 : json["billing_credit_auto_topup_expiry_unit_count"],
|
|
8461
|
+
billingCreditAutoTopupThresholdPercent: json["billing_credit_auto_topup_threshold_percent"] == null ? void 0 : json["billing_credit_auto_topup_threshold_percent"],
|
|
8462
|
+
createdAt: new Date(json["created_at"]),
|
|
8463
|
+
creditAmount: json["credit_amount"],
|
|
8464
|
+
creditDescription: json["credit_description"],
|
|
8465
|
+
creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
|
|
8466
|
+
creditId: json["credit_id"],
|
|
8467
|
+
creditName: json["credit_name"],
|
|
8468
|
+
expiryType: json["expiry_type"] == null ? void 0 : json["expiry_type"],
|
|
8469
|
+
expiryUnit: json["expiry_unit"] == null ? void 0 : json["expiry_unit"],
|
|
8470
|
+
expiryUnitCount: json["expiry_unit_count"] == null ? void 0 : json["expiry_unit_count"],
|
|
8471
|
+
id: json["id"],
|
|
8472
|
+
planId: json["plan_id"],
|
|
8473
|
+
planName: json["plan_name"],
|
|
8474
|
+
pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
|
|
8475
|
+
resetCadence: json["reset_cadence"],
|
|
8476
|
+
resetStart: json["reset_start"],
|
|
8477
|
+
resetType: json["reset_type"],
|
|
8478
|
+
singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
|
|
8479
|
+
updatedAt: new Date(json["updated_at"])
|
|
8480
|
+
};
|
|
8481
|
+
}
|
|
8482
|
+
|
|
8435
8483
|
// src/api/checkoutexternal/models/CompanyPlanWithBillingSubView.ts
|
|
8436
8484
|
function CompanyPlanWithBillingSubViewFromJSON(json) {
|
|
8437
8485
|
return CompanyPlanWithBillingSubViewFromJSONTyped(json, false);
|
|
@@ -8447,6 +8495,9 @@ function CompanyPlanWithBillingSubViewFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8447
8495
|
description: json["description"] == null ? void 0 : json["description"],
|
|
8448
8496
|
id: json["id"],
|
|
8449
8497
|
imageUrl: json["image_url"] == null ? void 0 : json["image_url"],
|
|
8498
|
+
includedCreditGrants: json["included_credit_grants"].map(
|
|
8499
|
+
PlanCreditGrantViewFromJSON
|
|
8500
|
+
),
|
|
8450
8501
|
name: json["name"],
|
|
8451
8502
|
planPeriod: json["plan_period"] == null ? void 0 : json["plan_period"],
|
|
8452
8503
|
planPrice: json["plan_price"] == null ? void 0 : json["plan_price"]
|
|
@@ -8932,36 +8983,6 @@ function FeatureDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8932
8983
|
};
|
|
8933
8984
|
}
|
|
8934
8985
|
|
|
8935
|
-
// src/api/checkoutexternal/models/PlanCreditGrantView.ts
|
|
8936
|
-
function PlanCreditGrantViewFromJSON(json) {
|
|
8937
|
-
return PlanCreditGrantViewFromJSONTyped(json, false);
|
|
8938
|
-
}
|
|
8939
|
-
function PlanCreditGrantViewFromJSONTyped(json, ignoreDiscriminator) {
|
|
8940
|
-
if (json == null) {
|
|
8941
|
-
return json;
|
|
8942
|
-
}
|
|
8943
|
-
return {
|
|
8944
|
-
createdAt: new Date(json["created_at"]),
|
|
8945
|
-
creditAmount: json["credit_amount"],
|
|
8946
|
-
creditDescription: json["credit_description"],
|
|
8947
|
-
creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
|
|
8948
|
-
creditId: json["credit_id"],
|
|
8949
|
-
creditName: json["credit_name"],
|
|
8950
|
-
expiryType: json["expiry_type"] == null ? void 0 : json["expiry_type"],
|
|
8951
|
-
expiryUnit: json["expiry_unit"] == null ? void 0 : json["expiry_unit"],
|
|
8952
|
-
expiryUnitCount: json["expiry_unit_count"] == null ? void 0 : json["expiry_unit_count"],
|
|
8953
|
-
id: json["id"],
|
|
8954
|
-
planId: json["plan_id"],
|
|
8955
|
-
planName: json["plan_name"],
|
|
8956
|
-
pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
|
|
8957
|
-
resetCadence: json["reset_cadence"],
|
|
8958
|
-
resetStart: json["reset_start"],
|
|
8959
|
-
resetType: json["reset_type"],
|
|
8960
|
-
singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
|
|
8961
|
-
updatedAt: new Date(json["updated_at"])
|
|
8962
|
-
};
|
|
8963
|
-
}
|
|
8964
|
-
|
|
8965
8986
|
// src/api/checkoutexternal/models/PlanResponseData.ts
|
|
8966
8987
|
function PlanResponseDataFromJSON(json) {
|
|
8967
8988
|
return PlanResponseDataFromJSONTyped(json, false);
|
|
@@ -10816,13 +10837,20 @@ function FeatureDetailResponseDataFromJSONTyped6(json, ignoreDiscriminator) {
|
|
|
10816
10837
|
|
|
10817
10838
|
// src/api/componentspublic/models/PlanCreditGrantView.ts
|
|
10818
10839
|
function PlanCreditGrantViewFromJSON2(json) {
|
|
10819
|
-
return
|
|
10840
|
+
return PlanCreditGrantViewFromJSONTyped4(json, false);
|
|
10820
10841
|
}
|
|
10821
|
-
function
|
|
10842
|
+
function PlanCreditGrantViewFromJSONTyped4(json, ignoreDiscriminator) {
|
|
10822
10843
|
if (json == null) {
|
|
10823
10844
|
return json;
|
|
10824
10845
|
}
|
|
10825
10846
|
return {
|
|
10847
|
+
billingCreditAutoTopupAmount: json["billing_credit_auto_topup_amount"] == null ? void 0 : json["billing_credit_auto_topup_amount"],
|
|
10848
|
+
billingCreditAutoTopupAmountType: json["billing_credit_auto_topup_amount_type"] == null ? void 0 : json["billing_credit_auto_topup_amount_type"],
|
|
10849
|
+
billingCreditAutoTopupEnabled: json["billing_credit_auto_topup_enabled"],
|
|
10850
|
+
billingCreditAutoTopupExpiryType: json["billing_credit_auto_topup_expiry_type"] == null ? void 0 : json["billing_credit_auto_topup_expiry_type"],
|
|
10851
|
+
billingCreditAutoTopupExpiryUnit: json["billing_credit_auto_topup_expiry_unit"] == null ? void 0 : json["billing_credit_auto_topup_expiry_unit"],
|
|
10852
|
+
billingCreditAutoTopupExpiryUnitCount: json["billing_credit_auto_topup_expiry_unit_count"] == null ? void 0 : json["billing_credit_auto_topup_expiry_unit_count"],
|
|
10853
|
+
billingCreditAutoTopupThresholdPercent: json["billing_credit_auto_topup_threshold_percent"] == null ? void 0 : json["billing_credit_auto_topup_threshold_percent"],
|
|
10826
10854
|
createdAt: new Date(json["created_at"]),
|
|
10827
10855
|
creditAmount: json["credit_amount"],
|
|
10828
10856
|
creditDescription: json["credit_description"],
|
|
@@ -11173,13 +11201,23 @@ var reducer = (state, action) => {
|
|
|
11173
11201
|
checkoutState: { ...action.state }
|
|
11174
11202
|
};
|
|
11175
11203
|
}
|
|
11204
|
+
case "SET_PLANID_BYPASS": {
|
|
11205
|
+
return {
|
|
11206
|
+
...state,
|
|
11207
|
+
layout: "checkout",
|
|
11208
|
+
checkoutState: {
|
|
11209
|
+
planId: action.planId,
|
|
11210
|
+
bypassPlanSelection: true
|
|
11211
|
+
}
|
|
11212
|
+
};
|
|
11213
|
+
}
|
|
11176
11214
|
}
|
|
11177
11215
|
};
|
|
11178
11216
|
|
|
11179
11217
|
// src/context/EmbedProvider.tsx
|
|
11180
11218
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11181
11219
|
var getCustomHeaders = (sessionId) => ({
|
|
11182
|
-
"X-Schematic-Components-Version": "2.1.
|
|
11220
|
+
"X-Schematic-Components-Version": "2.1.2",
|
|
11183
11221
|
"X-Schematic-Session-ID": sessionId
|
|
11184
11222
|
});
|
|
11185
11223
|
var EmbedProvider = ({
|
|
@@ -11471,6 +11509,9 @@ var EmbedProvider = ({
|
|
|
11471
11509
|
const setCheckoutState = useCallback3((state2) => {
|
|
11472
11510
|
dispatch({ type: "SET_CHECKOUT_STATE", state: state2 });
|
|
11473
11511
|
}, []);
|
|
11512
|
+
const initializeWithPlan = useCallback3((planId) => {
|
|
11513
|
+
dispatch({ type: "SET_PLANID_BYPASS", planId });
|
|
11514
|
+
}, []);
|
|
11474
11515
|
useEffect2(() => {
|
|
11475
11516
|
const element = document.getElementById(
|
|
11476
11517
|
"schematic-fonts"
|
|
@@ -11593,6 +11634,7 @@ var EmbedProvider = ({
|
|
|
11593
11634
|
setAccessToken,
|
|
11594
11635
|
setLayout,
|
|
11595
11636
|
setCheckoutState,
|
|
11637
|
+
initializeWithPlan,
|
|
11596
11638
|
setData,
|
|
11597
11639
|
updateSettings,
|
|
11598
11640
|
debug
|
|
@@ -12327,12 +12369,13 @@ import {
|
|
|
12327
12369
|
// src/components/ui/modal/styles.ts
|
|
12328
12370
|
var Overlay = dt(Box)`
|
|
12329
12371
|
position: absolute;
|
|
12330
|
-
top:
|
|
12331
|
-
|
|
12372
|
+
top: 0;
|
|
12373
|
+
right: 0;
|
|
12374
|
+
bottom: 0;
|
|
12375
|
+
left: 0;
|
|
12332
12376
|
z-index: 999999;
|
|
12333
|
-
transform: translate(-50%, -50%);
|
|
12334
12377
|
width: 100%;
|
|
12335
|
-
height:
|
|
12378
|
+
height: 100dvh;
|
|
12336
12379
|
overflow: hidden;
|
|
12337
12380
|
scrollbar-width: thin;
|
|
12338
12381
|
scrollbar-gutter: stable both-edges;
|
|
@@ -12349,7 +12392,7 @@ var Modal = dt.div.attrs({
|
|
|
12349
12392
|
flex-direction: column;
|
|
12350
12393
|
width: 100%;
|
|
12351
12394
|
height: fit-content;
|
|
12352
|
-
max-height:
|
|
12395
|
+
max-height: 100dvh;
|
|
12353
12396
|
overflow: auto;
|
|
12354
12397
|
background-color: ${({ theme }) => theme.card.background};
|
|
12355
12398
|
box-shadow:
|
|
@@ -12431,7 +12474,7 @@ var ModalContent = forwardRef2(({ children }, ref) => {
|
|
|
12431
12474
|
md: {
|
|
12432
12475
|
$flexDirection: "row",
|
|
12433
12476
|
$height: "calc(100% - 5rem + 3px)",
|
|
12434
|
-
$maxHeight: "calc(
|
|
12477
|
+
$maxHeight: "calc(100dvh - 5rem + 3px)"
|
|
12435
12478
|
}
|
|
12436
12479
|
},
|
|
12437
12480
|
children
|
|
@@ -12981,8 +13024,8 @@ Root.displayName = "Root";
|
|
|
12981
13024
|
|
|
12982
13025
|
// src/components/layout/viewport/Viewport.tsx
|
|
12983
13026
|
var import_debounce3 = __toESM(require_debounce());
|
|
12984
|
-
import { forwardRef as forwardRef8, useLayoutEffect as useLayoutEffect5, useMemo as useMemo15, useRef as
|
|
12985
|
-
import { createPortal as
|
|
13027
|
+
import { forwardRef as forwardRef8, useLayoutEffect as useLayoutEffect5, useMemo as useMemo15, useRef as useRef10, useState as useState14 } from "react";
|
|
13028
|
+
import { createPortal as createPortal3 } from "react-dom";
|
|
12986
13029
|
|
|
12987
13030
|
// src/components/shared/billing-threshold-tooltip/BillingThresholdTooltip.tsx
|
|
12988
13031
|
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
@@ -13016,19 +13059,23 @@ var BillingThresholdTooltip = ({
|
|
|
13016
13059
|
// src/components/shared/checkout-dialog/CheckoutDialog.tsx
|
|
13017
13060
|
import {
|
|
13018
13061
|
useCallback as useCallback10,
|
|
13019
|
-
useEffect as
|
|
13062
|
+
useEffect as useEffect6,
|
|
13020
13063
|
useLayoutEffect as useLayoutEffect4,
|
|
13021
13064
|
useMemo as useMemo9,
|
|
13022
|
-
useRef as
|
|
13023
|
-
useState as
|
|
13065
|
+
useRef as useRef7,
|
|
13066
|
+
useState as useState11
|
|
13024
13067
|
} from "react";
|
|
13025
13068
|
|
|
13026
13069
|
// src/components/shared/sidebar/Sidebar.tsx
|
|
13027
13070
|
import {
|
|
13028
13071
|
forwardRef as forwardRef7,
|
|
13029
13072
|
useCallback as useCallback9,
|
|
13030
|
-
|
|
13073
|
+
useEffect as useEffect4,
|
|
13074
|
+
useMemo as useMemo7,
|
|
13075
|
+
useRef as useRef6,
|
|
13076
|
+
useState as useState8
|
|
13031
13077
|
} from "react";
|
|
13078
|
+
import { createPortal as createPortal2 } from "react-dom";
|
|
13032
13079
|
|
|
13033
13080
|
// src/components/shared/sidebar/EntitlementRow.tsx
|
|
13034
13081
|
import { Fragment as Fragment3, jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
@@ -13151,6 +13198,7 @@ import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
|
13151
13198
|
var NoPaymentRequired = ({
|
|
13152
13199
|
isDisabled,
|
|
13153
13200
|
isLoading,
|
|
13201
|
+
isSticky,
|
|
13154
13202
|
onClick
|
|
13155
13203
|
}) => {
|
|
13156
13204
|
const { t: t2 } = useTranslation();
|
|
@@ -13161,6 +13209,7 @@ var NoPaymentRequired = ({
|
|
|
13161
13209
|
disabled: isDisabled,
|
|
13162
13210
|
onClick,
|
|
13163
13211
|
$isLoading: isLoading,
|
|
13212
|
+
$size: isSticky ? "sm" : "md",
|
|
13164
13213
|
$fullWidth: true,
|
|
13165
13214
|
children: t2("Subscribe and close")
|
|
13166
13215
|
}
|
|
@@ -13177,6 +13226,7 @@ var StageButton = ({
|
|
|
13177
13226
|
hasPlan,
|
|
13178
13227
|
inEditMode,
|
|
13179
13228
|
isLoading,
|
|
13229
|
+
isSticky,
|
|
13180
13230
|
isPaymentMethodRequired,
|
|
13181
13231
|
isSelectedPlanTrialable,
|
|
13182
13232
|
setCheckoutStage,
|
|
@@ -13224,7 +13274,8 @@ var StageButton = ({
|
|
|
13224
13274
|
{
|
|
13225
13275
|
isDisabled,
|
|
13226
13276
|
isLoading,
|
|
13227
|
-
onClick: checkout
|
|
13277
|
+
onClick: checkout,
|
|
13278
|
+
isSticky
|
|
13228
13279
|
}
|
|
13229
13280
|
);
|
|
13230
13281
|
}
|
|
@@ -13240,6 +13291,7 @@ var StageButton = ({
|
|
|
13240
13291
|
},
|
|
13241
13292
|
$isLoading: isLoading,
|
|
13242
13293
|
$fullWidth: true,
|
|
13294
|
+
$size: isSticky ? "sm" : "md",
|
|
13243
13295
|
children: /* @__PURE__ */ jsxs8(Flex, { $gap: "0.5rem", $justifyContent: "center", $alignItems: "center", children: [
|
|
13244
13296
|
t2("Next"),
|
|
13245
13297
|
":",
|
|
@@ -13259,7 +13311,8 @@ var StageButton = ({
|
|
|
13259
13311
|
{
|
|
13260
13312
|
isDisabled,
|
|
13261
13313
|
isLoading,
|
|
13262
|
-
onClick: checkout
|
|
13314
|
+
onClick: checkout,
|
|
13315
|
+
isSticky
|
|
13263
13316
|
}
|
|
13264
13317
|
);
|
|
13265
13318
|
}
|
|
@@ -13275,6 +13328,7 @@ var StageButton = ({
|
|
|
13275
13328
|
},
|
|
13276
13329
|
$isLoading: isLoading,
|
|
13277
13330
|
$fullWidth: true,
|
|
13331
|
+
$size: isSticky ? "sm" : "md",
|
|
13278
13332
|
children: /* @__PURE__ */ jsxs8(
|
|
13279
13333
|
Flex,
|
|
13280
13334
|
{
|
|
@@ -13307,7 +13361,8 @@ var StageButton = ({
|
|
|
13307
13361
|
{
|
|
13308
13362
|
isDisabled,
|
|
13309
13363
|
isLoading,
|
|
13310
|
-
onClick: checkout
|
|
13364
|
+
onClick: checkout,
|
|
13365
|
+
isSticky
|
|
13311
13366
|
}
|
|
13312
13367
|
);
|
|
13313
13368
|
}
|
|
@@ -13349,7 +13404,8 @@ var StageButton = ({
|
|
|
13349
13404
|
{
|
|
13350
13405
|
isDisabled,
|
|
13351
13406
|
isLoading,
|
|
13352
|
-
onClick: checkout
|
|
13407
|
+
onClick: checkout,
|
|
13408
|
+
isSticky
|
|
13353
13409
|
}
|
|
13354
13410
|
);
|
|
13355
13411
|
}
|
|
@@ -13363,6 +13419,7 @@ var StageButton = ({
|
|
|
13363
13419
|
},
|
|
13364
13420
|
$isLoading: isLoading,
|
|
13365
13421
|
$fullWidth: true,
|
|
13422
|
+
$size: isSticky ? "sm" : "md",
|
|
13366
13423
|
children: /* @__PURE__ */ jsxs8(
|
|
13367
13424
|
Flex,
|
|
13368
13425
|
{
|
|
@@ -13388,7 +13445,8 @@ var StageButton = ({
|
|
|
13388
13445
|
{
|
|
13389
13446
|
isDisabled,
|
|
13390
13447
|
isLoading,
|
|
13391
|
-
onClick: checkout
|
|
13448
|
+
onClick: checkout,
|
|
13449
|
+
isSticky
|
|
13392
13450
|
}
|
|
13393
13451
|
);
|
|
13394
13452
|
}
|
|
@@ -13427,7 +13485,8 @@ var StageButton = ({
|
|
|
13427
13485
|
{
|
|
13428
13486
|
isDisabled,
|
|
13429
13487
|
isLoading,
|
|
13430
|
-
onClick: checkout
|
|
13488
|
+
onClick: checkout,
|
|
13489
|
+
isSticky
|
|
13431
13490
|
}
|
|
13432
13491
|
);
|
|
13433
13492
|
}
|
|
@@ -13799,6 +13858,42 @@ var Sidebar = forwardRef7(
|
|
|
13799
13858
|
trialEndsOn.setDate(trialEndsOn.getDate() + selectedPlan.trialDays);
|
|
13800
13859
|
}
|
|
13801
13860
|
const { price: selectedPlanPrice, currency: selectedPlanCurrency } = selectedPlan ? getPlanPrice(selectedPlan, planPeriod) || {} : {};
|
|
13861
|
+
const buttonRef = useRef6(null);
|
|
13862
|
+
const [checkoutButtonInView, setCheckoutButtonInView] = useState8(false);
|
|
13863
|
+
useEffect4(() => {
|
|
13864
|
+
const observer = new IntersectionObserver(
|
|
13865
|
+
([entry]) => setCheckoutButtonInView(entry.isIntersecting),
|
|
13866
|
+
{ threshold: 0 }
|
|
13867
|
+
);
|
|
13868
|
+
if (buttonRef.current) {
|
|
13869
|
+
observer.observe(buttonRef.current);
|
|
13870
|
+
}
|
|
13871
|
+
return () => observer.disconnect();
|
|
13872
|
+
}, []);
|
|
13873
|
+
const StageButtonComponent = () => {
|
|
13874
|
+
return /* @__PURE__ */ jsx15(
|
|
13875
|
+
StageButton,
|
|
13876
|
+
{
|
|
13877
|
+
checkout: handleCheckout,
|
|
13878
|
+
checkoutStage,
|
|
13879
|
+
checkoutStages,
|
|
13880
|
+
hasAddOns: addOns.length > 0,
|
|
13881
|
+
hasPayInAdvanceEntitlements: payInAdvanceEntitlements.length > 0,
|
|
13882
|
+
hasCreditBundles: creditBundles.length > 0,
|
|
13883
|
+
hasPaymentMethod: typeof paymentMethod !== "undefined" || typeof paymentMethodId === "string",
|
|
13884
|
+
hasPlan: typeof selectedPlan !== "undefined",
|
|
13885
|
+
inEditMode: settings.mode === "edit",
|
|
13886
|
+
isLoading,
|
|
13887
|
+
isPaymentMethodRequired,
|
|
13888
|
+
isSelectedPlanTrialable,
|
|
13889
|
+
isSticky: !checkoutButtonInView,
|
|
13890
|
+
setCheckoutStage,
|
|
13891
|
+
trialPaymentMethodRequired,
|
|
13892
|
+
shouldTrial,
|
|
13893
|
+
willTrialWithoutPaymentMethod
|
|
13894
|
+
}
|
|
13895
|
+
);
|
|
13896
|
+
};
|
|
13802
13897
|
return /* @__PURE__ */ jsxs9(
|
|
13803
13898
|
Flex,
|
|
13804
13899
|
{
|
|
@@ -14284,27 +14379,42 @@ var Sidebar = forwardRef7(
|
|
|
14284
14379
|
] }) }),
|
|
14285
14380
|
/* @__PURE__ */ jsx15(Box, { children: /* @__PURE__ */ jsx15(Text, { children: formatCurrency(Math.abs(dueNow), selectedPlanCurrency) }) })
|
|
14286
14381
|
] }),
|
|
14287
|
-
layout === "checkout" && /* @__PURE__ */
|
|
14288
|
-
|
|
14289
|
-
|
|
14290
|
-
|
|
14291
|
-
|
|
14292
|
-
|
|
14293
|
-
|
|
14294
|
-
|
|
14295
|
-
|
|
14296
|
-
|
|
14297
|
-
|
|
14298
|
-
|
|
14299
|
-
|
|
14300
|
-
|
|
14301
|
-
|
|
14302
|
-
|
|
14303
|
-
|
|
14304
|
-
|
|
14305
|
-
|
|
14306
|
-
|
|
14307
|
-
|
|
14382
|
+
layout === "checkout" && /* @__PURE__ */ jsxs9("div", { ref: buttonRef, children: [
|
|
14383
|
+
checkoutButtonInView && /* @__PURE__ */ jsx15(StageButtonComponent, {}),
|
|
14384
|
+
!checkoutButtonInView && createPortal2(
|
|
14385
|
+
/* @__PURE__ */ jsx15(
|
|
14386
|
+
"div",
|
|
14387
|
+
{
|
|
14388
|
+
style: {
|
|
14389
|
+
position: "fixed",
|
|
14390
|
+
bottom: "-1px",
|
|
14391
|
+
left: "0px",
|
|
14392
|
+
zIndex: 9999999,
|
|
14393
|
+
width: "100%",
|
|
14394
|
+
overflow: "hidden",
|
|
14395
|
+
backgroundColor: settings.theme.card.background,
|
|
14396
|
+
borderTopWidth: "1px",
|
|
14397
|
+
borderTopStyle: "solid",
|
|
14398
|
+
borderTopColor: isLightBackground ? "hsla(0, 0%, 0%, 0.1)" : "hsla(0, 0%, 100%, 0.2)"
|
|
14399
|
+
},
|
|
14400
|
+
children: /* @__PURE__ */ jsx15(
|
|
14401
|
+
"div",
|
|
14402
|
+
{
|
|
14403
|
+
style: {
|
|
14404
|
+
display: "flex",
|
|
14405
|
+
justifyContent: "center",
|
|
14406
|
+
alignItems: "center",
|
|
14407
|
+
padding: "1rem 1.5rem",
|
|
14408
|
+
backgroundColor: settings.theme.card.background
|
|
14409
|
+
},
|
|
14410
|
+
children: /* @__PURE__ */ jsx15(StageButtonComponent, {})
|
|
14411
|
+
}
|
|
14412
|
+
)
|
|
14413
|
+
}
|
|
14414
|
+
),
|
|
14415
|
+
document.body
|
|
14416
|
+
)
|
|
14417
|
+
] }),
|
|
14308
14418
|
layout === "unsubscribe" && /* @__PURE__ */ jsx15(
|
|
14309
14419
|
Button,
|
|
14310
14420
|
{
|
|
@@ -14615,7 +14725,7 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
|
|
|
14615
14725
|
};
|
|
14616
14726
|
|
|
14617
14727
|
// src/components/shared/checkout-dialog/Checkout.tsx
|
|
14618
|
-
import { useState as
|
|
14728
|
+
import { useState as useState9 } from "react";
|
|
14619
14729
|
import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
14620
14730
|
var Checkout = ({
|
|
14621
14731
|
isPaymentMethodRequired,
|
|
@@ -14627,7 +14737,7 @@ var Checkout = ({
|
|
|
14627
14737
|
}) => {
|
|
14628
14738
|
const { t: t2 } = useTranslation();
|
|
14629
14739
|
const isLightBackground = useIsLightBackground();
|
|
14630
|
-
const [discount, setDiscount] =
|
|
14740
|
+
const [discount, setDiscount] = useState9("");
|
|
14631
14741
|
if (!isPaymentMethodRequired) {
|
|
14632
14742
|
return null;
|
|
14633
14743
|
}
|
|
@@ -14841,7 +14951,7 @@ var Navigation = ({
|
|
|
14841
14951
|
};
|
|
14842
14952
|
|
|
14843
14953
|
// src/components/shared/checkout-dialog/Plan.tsx
|
|
14844
|
-
import { Fragment as Fragment7, useEffect as
|
|
14954
|
+
import { Fragment as Fragment7, useEffect as useEffect5, useMemo as useMemo8, useState as useState10 } from "react";
|
|
14845
14955
|
|
|
14846
14956
|
// src/components/shared/checkout-dialog/styles.ts
|
|
14847
14957
|
var FlexWithAlignEnd = dt(Flex)`
|
|
@@ -14985,7 +15095,7 @@ var Plan = ({
|
|
|
14985
15095
|
const { t: t2 } = useTranslation();
|
|
14986
15096
|
const { data, settings } = useEmbed();
|
|
14987
15097
|
const isLightBackground = useIsLightBackground();
|
|
14988
|
-
const [entitlementCounts, setEntitlementCounts] =
|
|
15098
|
+
const [entitlementCounts, setEntitlementCounts] = useState10(
|
|
14989
15099
|
() => plans.reduce(entitlementCountsReducer, {})
|
|
14990
15100
|
);
|
|
14991
15101
|
const { isTrialing, showCredits, showPeriodToggle, showZeroPriceAsFree } = useMemo8(() => {
|
|
@@ -15016,7 +15126,7 @@ var Plan = ({
|
|
|
15016
15126
|
return prev2;
|
|
15017
15127
|
});
|
|
15018
15128
|
};
|
|
15019
|
-
|
|
15129
|
+
useEffect5(() => {
|
|
15020
15130
|
setEntitlementCounts(plans.reduce(entitlementCountsReducer, {}));
|
|
15021
15131
|
}, [plans]);
|
|
15022
15132
|
const cardPadding = settings.theme.card.padding / TEXT_BASE_SIZE;
|
|
@@ -15562,19 +15672,19 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15562
15672
|
const { t: t2 } = useTranslation();
|
|
15563
15673
|
const { data, settings, isPending, checkoutState, previewCheckout } = useEmbed();
|
|
15564
15674
|
const isLightBackground = useIsLightBackground();
|
|
15565
|
-
const modalRef =
|
|
15566
|
-
const contentRef =
|
|
15567
|
-
const stageRef =
|
|
15568
|
-
const sidebarRef =
|
|
15569
|
-
const [confirmPaymentIntentProps, setConfirmPaymentIntentProps] =
|
|
15570
|
-
const [charges, setCharges] =
|
|
15571
|
-
const [paymentMethodId, setPaymentMethodId] =
|
|
15675
|
+
const modalRef = useRef7(null);
|
|
15676
|
+
const contentRef = useRef7(null);
|
|
15677
|
+
const stageRef = useRef7(null);
|
|
15678
|
+
const sidebarRef = useRef7(null);
|
|
15679
|
+
const [confirmPaymentIntentProps, setConfirmPaymentIntentProps] = useState11(void 0);
|
|
15680
|
+
const [charges, setCharges] = useState11();
|
|
15681
|
+
const [paymentMethodId, setPaymentMethodId] = useState11(
|
|
15572
15682
|
() => {
|
|
15573
15683
|
return data?.subscription?.paymentMethod?.externalId || data?.company?.defaultPaymentMethod?.externalId;
|
|
15574
15684
|
}
|
|
15575
15685
|
);
|
|
15576
|
-
const [isLoading, setIsLoading] =
|
|
15577
|
-
const [error, setError] =
|
|
15686
|
+
const [isLoading, setIsLoading] = useState11(false);
|
|
15687
|
+
const [error, setError] = useState11();
|
|
15578
15688
|
const {
|
|
15579
15689
|
currentPlanId,
|
|
15580
15690
|
currentEntitlements,
|
|
@@ -15597,7 +15707,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15597
15707
|
() => checkoutState?.period || data?.company?.plan?.planPeriod || "month",
|
|
15598
15708
|
[data?.company?.plan?.planPeriod, checkoutState?.period]
|
|
15599
15709
|
);
|
|
15600
|
-
const [planPeriod, setPlanPeriod] =
|
|
15710
|
+
const [planPeriod, setPlanPeriod] = useState11(currentPeriod);
|
|
15601
15711
|
const {
|
|
15602
15712
|
plans: availablePlans,
|
|
15603
15713
|
addOns: availableAddOns,
|
|
@@ -15605,15 +15715,15 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15605
15715
|
} = useAvailablePlans(planPeriod, {
|
|
15606
15716
|
useSelectedPeriod: showPeriodToggle
|
|
15607
15717
|
});
|
|
15608
|
-
const [selectedPlan, setSelectedPlan] =
|
|
15718
|
+
const [selectedPlan, setSelectedPlan] = useState11(
|
|
15609
15719
|
() => {
|
|
15610
15720
|
return availablePlans.find(
|
|
15611
15721
|
(plan) => checkoutState?.planId ? plan.id === checkoutState.planId : plan.current
|
|
15612
15722
|
);
|
|
15613
15723
|
}
|
|
15614
15724
|
);
|
|
15615
|
-
const [shouldTrial, setShouldTrial] =
|
|
15616
|
-
const [addOns, setAddOns] =
|
|
15725
|
+
const [shouldTrial, setShouldTrial] = useState11(false);
|
|
15726
|
+
const [addOns, setAddOns] = useState11(() => {
|
|
15617
15727
|
return availableAddOns.map((addOn) => ({
|
|
15618
15728
|
...addOn,
|
|
15619
15729
|
isSelected: typeof checkoutState?.addOnId !== "undefined" ? addOn.id === checkoutState.addOnId : (data?.company?.addOns || []).some(
|
|
@@ -15621,13 +15731,13 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15621
15731
|
)
|
|
15622
15732
|
}));
|
|
15623
15733
|
});
|
|
15624
|
-
const [creditBundles, setCreditBundles] =
|
|
15734
|
+
const [creditBundles, setCreditBundles] = useState11(() => {
|
|
15625
15735
|
return (data?.creditBundles || []).map((bundle) => ({
|
|
15626
15736
|
...bundle,
|
|
15627
15737
|
count: 0
|
|
15628
15738
|
}));
|
|
15629
15739
|
});
|
|
15630
|
-
const [usageBasedEntitlements, setUsageBasedEntitlements] =
|
|
15740
|
+
const [usageBasedEntitlements, setUsageBasedEntitlements] = useState11(
|
|
15631
15741
|
() => (selectedPlan?.entitlements || []).reduce(
|
|
15632
15742
|
createActiveUsageBasedEntitlementsReducer(
|
|
15633
15743
|
currentEntitlements,
|
|
@@ -15636,7 +15746,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15636
15746
|
[]
|
|
15637
15747
|
)
|
|
15638
15748
|
);
|
|
15639
|
-
const [addOnUsageBasedEntitlements, setAddOnUsageBasedEntitlements] =
|
|
15749
|
+
const [addOnUsageBasedEntitlements, setAddOnUsageBasedEntitlements] = useState11(() => {
|
|
15640
15750
|
return (data?.company?.addOns || []).flatMap((currentAddOn) => {
|
|
15641
15751
|
const availableAddOn = availableAddOns.find(
|
|
15642
15752
|
(available) => available.id === currentAddOn.id
|
|
@@ -15663,8 +15773,8 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15663
15773
|
),
|
|
15664
15774
|
[addOnUsageBasedEntitlements]
|
|
15665
15775
|
);
|
|
15666
|
-
const [promoCode, setPromoCode] =
|
|
15667
|
-
const [isPaymentMethodRequired, setIsPaymentMethodRequired] =
|
|
15776
|
+
const [promoCode, setPromoCode] = useState11(null);
|
|
15777
|
+
const [isPaymentMethodRequired, setIsPaymentMethodRequired] = useState11(false);
|
|
15668
15778
|
const willTrialWithoutPaymentMethod = useMemo9(
|
|
15669
15779
|
() => shouldTrial && !trialPaymentMethodRequired,
|
|
15670
15780
|
[shouldTrial, trialPaymentMethodRequired]
|
|
@@ -15737,7 +15847,8 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15737
15847
|
creditBundles,
|
|
15738
15848
|
isPaymentMethodRequired
|
|
15739
15849
|
]);
|
|
15740
|
-
const [
|
|
15850
|
+
const [hasSkippedInitialPlan, setHasSkippedInitialPlan] = useState11(false);
|
|
15851
|
+
const [checkoutStage, setCheckoutStage] = useState11(() => {
|
|
15741
15852
|
if (checkoutState?.addOnId) {
|
|
15742
15853
|
return "addons";
|
|
15743
15854
|
}
|
|
@@ -15750,11 +15861,25 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15750
15861
|
if (checkoutState?.credits) {
|
|
15751
15862
|
return "credits";
|
|
15752
15863
|
}
|
|
15753
|
-
if (typeof checkoutState?.planId !== "undefined" && checkoutState.planId !== currentPlanId) {
|
|
15754
|
-
return checkoutStages.some((stage) => stage.id === "usage") ? "usage" : checkoutStages.some((stage) => stage.id === "addons") ? "addons" : checkoutStages.some((stage) => stage.id === "addonsUsage") ? "addonsUsage" : checkoutStages.some((stage) => stage.id === "credits") ? "credits" : "plan";
|
|
15864
|
+
if (typeof checkoutState?.planId !== "undefined" && checkoutState.planId !== currentPlanId || checkoutState?.bypassPlanSelection) {
|
|
15865
|
+
return checkoutStages.some((stage) => stage.id === "usage") ? "usage" : checkoutStages.some((stage) => stage.id === "addons") ? "addons" : checkoutStages.some((stage) => stage.id === "addonsUsage") ? "addonsUsage" : checkoutStages.some((stage) => stage.id === "credits") ? "credits" : checkoutStages.some((stage) => stage.id === "checkout") ? "checkout" : checkoutStages[0]?.id || "plan";
|
|
15755
15866
|
}
|
|
15756
15867
|
return "plan";
|
|
15757
15868
|
});
|
|
15869
|
+
useEffect6(() => {
|
|
15870
|
+
if (checkoutState?.bypassPlanSelection && checkoutStage === "plan" && !hasSkippedInitialPlan) {
|
|
15871
|
+
const nextStage = checkoutStages.find((stage) => stage.id !== "plan");
|
|
15872
|
+
if (nextStage) {
|
|
15873
|
+
setHasSkippedInitialPlan(true);
|
|
15874
|
+
setCheckoutStage(nextStage.id);
|
|
15875
|
+
}
|
|
15876
|
+
}
|
|
15877
|
+
}, [
|
|
15878
|
+
checkoutStages,
|
|
15879
|
+
checkoutState?.bypassPlanSelection,
|
|
15880
|
+
checkoutStage,
|
|
15881
|
+
hasSkippedInitialPlan
|
|
15882
|
+
]);
|
|
15758
15883
|
const handlePreviewCheckout = useCallback10(
|
|
15759
15884
|
async (updates) => {
|
|
15760
15885
|
const period = updates.period || planPeriod;
|
|
@@ -15882,14 +16007,19 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15882
16007
|
const selectPlan = useCallback10(
|
|
15883
16008
|
(updates) => {
|
|
15884
16009
|
const plan = updates.plan;
|
|
15885
|
-
const period = updates.period || planPeriod
|
|
16010
|
+
const period = showPeriodToggle ? updates.period || planPeriod : plan.yearlyPrice && !plan.monthlyPrice ? "year" /* Year */ : "month" /* Month */;
|
|
15886
16011
|
const updatedUsageBasedEntitlements = plan.entitlements.reduce(
|
|
15887
16012
|
createActiveUsageBasedEntitlementsReducer(currentEntitlements, period),
|
|
15888
16013
|
[]
|
|
15889
16014
|
);
|
|
16015
|
+
if (period !== planPeriod || plan.id !== selectedPlan?.id) {
|
|
16016
|
+
setUsageBasedEntitlements(updatedUsageBasedEntitlements);
|
|
16017
|
+
}
|
|
16018
|
+
if (period !== planPeriod) {
|
|
16019
|
+
setPlanPeriod(period);
|
|
16020
|
+
}
|
|
15890
16021
|
if (plan.id !== selectedPlan?.id) {
|
|
15891
16022
|
setSelectedPlan(plan);
|
|
15892
|
-
setUsageBasedEntitlements(updatedUsageBasedEntitlements);
|
|
15893
16023
|
}
|
|
15894
16024
|
const updatedShouldTrial = updates.shouldTrial ?? shouldTrial;
|
|
15895
16025
|
setShouldTrial(updatedShouldTrial);
|
|
@@ -15918,6 +16048,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15918
16048
|
[
|
|
15919
16049
|
selectedPlan?.id,
|
|
15920
16050
|
planPeriod,
|
|
16051
|
+
showPeriodToggle,
|
|
15921
16052
|
currentEntitlements,
|
|
15922
16053
|
shouldTrial,
|
|
15923
16054
|
willTrialWithoutPaymentMethod,
|
|
@@ -16017,18 +16148,35 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16017
16148
|
},
|
|
16018
16149
|
[handlePreviewCheckout]
|
|
16019
16150
|
);
|
|
16020
|
-
|
|
16151
|
+
useEffect6(() => {
|
|
16021
16152
|
if (selectedPlan) {
|
|
16022
16153
|
selectPlan({ plan: selectedPlan, period: currentPeriod });
|
|
16023
16154
|
}
|
|
16024
16155
|
}, []);
|
|
16025
|
-
|
|
16026
|
-
|
|
16027
|
-
|
|
16028
|
-
|
|
16029
|
-
|
|
16156
|
+
useEffect6(() => {
|
|
16157
|
+
if (checkoutState?.planId) {
|
|
16158
|
+
const plan = availablePlans.find(
|
|
16159
|
+
(plan2) => plan2.id === checkoutState.planId
|
|
16160
|
+
);
|
|
16161
|
+
setSelectedPlan(plan);
|
|
16162
|
+
}
|
|
16030
16163
|
}, [availablePlans, checkoutState?.planId]);
|
|
16031
|
-
|
|
16164
|
+
useEffect6(() => {
|
|
16165
|
+
if (checkoutState?.addOnId) {
|
|
16166
|
+
const checkoutStateAddOn = availableAddOns.find(
|
|
16167
|
+
(addOn) => addOn.id === checkoutState.addOnId
|
|
16168
|
+
);
|
|
16169
|
+
setAddOns(
|
|
16170
|
+
(prev2) => prev2.map((addOn) => ({
|
|
16171
|
+
...addOn,
|
|
16172
|
+
...addOn.id === checkoutStateAddOn?.id && {
|
|
16173
|
+
isSelected: true
|
|
16174
|
+
}
|
|
16175
|
+
}))
|
|
16176
|
+
);
|
|
16177
|
+
}
|
|
16178
|
+
}, [availableAddOns, checkoutState?.addOnId]);
|
|
16179
|
+
useEffect6(() => {
|
|
16032
16180
|
setAddOns((prevAddOns) => {
|
|
16033
16181
|
return availableAddOns.filter((availAddOn) => {
|
|
16034
16182
|
if (!selectedPlan) {
|
|
@@ -16050,7 +16198,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16050
16198
|
});
|
|
16051
16199
|
});
|
|
16052
16200
|
}, [data?.addOnCompatibilities, availableAddOns, selectedPlan]);
|
|
16053
|
-
|
|
16201
|
+
useEffect6(() => {
|
|
16054
16202
|
if (charges) {
|
|
16055
16203
|
sidebarRef.current?.scrollTo({
|
|
16056
16204
|
top: 0,
|
|
@@ -16069,7 +16217,30 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16069
16217
|
const activeCheckoutStage = checkoutStages.find(
|
|
16070
16218
|
(stage) => stage.id === checkoutStage
|
|
16071
16219
|
);
|
|
16220
|
+
const shouldShowBypassOverlay = checkoutState?.bypassPlanSelection && checkoutStage === "plan" && !hasSkippedInitialPlan;
|
|
16072
16221
|
return /* @__PURE__ */ jsxs16(Modal2, { ref: modalRef, size: "lg", top, children: [
|
|
16222
|
+
shouldShowBypassOverlay && /* @__PURE__ */ jsx22(
|
|
16223
|
+
Flex,
|
|
16224
|
+
{
|
|
16225
|
+
$position: "absolute",
|
|
16226
|
+
$top: 0,
|
|
16227
|
+
$left: 0,
|
|
16228
|
+
$zIndex: 3,
|
|
16229
|
+
$width: "100%",
|
|
16230
|
+
$height: "100dvh",
|
|
16231
|
+
$justifyContent: "center",
|
|
16232
|
+
$alignItems: "center",
|
|
16233
|
+
$backgroundColor: isLightBackground ? "hsla(0, 0%, 100%, 0.9)" : "hsla(0, 0%, 0%, 0.9)",
|
|
16234
|
+
$backdropFilter: "blur(8px)",
|
|
16235
|
+
$padding: "1rem",
|
|
16236
|
+
$viewport: {
|
|
16237
|
+
md: {
|
|
16238
|
+
$padding: "1.5rem"
|
|
16239
|
+
}
|
|
16240
|
+
},
|
|
16241
|
+
children: /* @__PURE__ */ jsx22(Loader, { $color: settings.theme.primary, $size: "2xl" })
|
|
16242
|
+
}
|
|
16243
|
+
),
|
|
16073
16244
|
/* @__PURE__ */ jsx22(ModalHeader, { bordered: true, children: /* @__PURE__ */ jsx22(
|
|
16074
16245
|
Flex,
|
|
16075
16246
|
{
|
|
@@ -16250,11 +16421,11 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16250
16421
|
};
|
|
16251
16422
|
|
|
16252
16423
|
// src/components/shared/payment-dialog/PaymentDialog.tsx
|
|
16253
|
-
import { useRef as
|
|
16424
|
+
import { useRef as useRef8 } from "react";
|
|
16254
16425
|
import { jsx as jsx23, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
16255
16426
|
var PaymentDialog = ({ top = 0 }) => {
|
|
16256
16427
|
const { t: t2 } = useTranslation();
|
|
16257
|
-
const modalRef =
|
|
16428
|
+
const modalRef = useRef8(null);
|
|
16258
16429
|
return /* @__PURE__ */ jsxs17(Modal2, { ref: modalRef, size: "md", top, children: [
|
|
16259
16430
|
/* @__PURE__ */ jsx23(ModalHeader, { bordered: true, children: /* @__PURE__ */ jsx23(Text, { $size: 18, children: t2("Edit payment method") }) }),
|
|
16260
16431
|
/* @__PURE__ */ jsx23(ModalContent, { children: /* @__PURE__ */ jsx23(Flex, { $position: "relative", $flexGrow: 1, $overflow: "auto", children: /* @__PURE__ */ jsx23(PaymentMethodDetails, {}) }) })
|
|
@@ -16268,7 +16439,7 @@ import {
|
|
|
16268
16439
|
useElements,
|
|
16269
16440
|
useStripe
|
|
16270
16441
|
} from "@stripe/react-stripe-js";
|
|
16271
|
-
import { useState as
|
|
16442
|
+
import { useState as useState12 } from "react";
|
|
16272
16443
|
|
|
16273
16444
|
// src/components/shared/payment-form/styles.ts
|
|
16274
16445
|
var Label = dt.label`
|
|
@@ -16330,12 +16501,12 @@ var PaymentForm = ({ onConfirm, financeData }) => {
|
|
|
16330
16501
|
const stripe = useStripe();
|
|
16331
16502
|
const elements = useElements();
|
|
16332
16503
|
const { data } = useEmbed();
|
|
16333
|
-
const [email, setEmail] =
|
|
16334
|
-
const [message, setMessage] =
|
|
16335
|
-
const [isLoading, setIsLoading] =
|
|
16336
|
-
const [isConfirmed, setIsConfirmed] =
|
|
16337
|
-
const [isPaymentComplete, setIsPaymentComplete] =
|
|
16338
|
-
const [isAddressComplete, setIsAddressComplete] =
|
|
16504
|
+
const [email, setEmail] = useState12("");
|
|
16505
|
+
const [message, setMessage] = useState12();
|
|
16506
|
+
const [isLoading, setIsLoading] = useState12(false);
|
|
16507
|
+
const [isConfirmed, setIsConfirmed] = useState12(false);
|
|
16508
|
+
const [isPaymentComplete, setIsPaymentComplete] = useState12(false);
|
|
16509
|
+
const [isAddressComplete, setIsAddressComplete] = useState12(() => {
|
|
16339
16510
|
const shouldCollectAddress = shouldCollectBillingAddress(
|
|
16340
16511
|
data?.checkoutSettings.collectAddress ?? false,
|
|
16341
16512
|
financeData
|
|
@@ -16464,7 +16635,6 @@ var PeriodToggle = ({
|
|
|
16464
16635
|
const yearly = yearlyBillingPrice?.price ?? 0;
|
|
16465
16636
|
return Math.round((monthly - yearly) / monthly * 1e4) / 100;
|
|
16466
16637
|
}
|
|
16467
|
-
return 0;
|
|
16468
16638
|
}, [selectedPlan]);
|
|
16469
16639
|
return /* @__PURE__ */ jsx25(
|
|
16470
16640
|
Flex,
|
|
@@ -16519,7 +16689,7 @@ var PeriodToggle = ({
|
|
|
16519
16689
|
},
|
|
16520
16690
|
option
|
|
16521
16691
|
);
|
|
16522
|
-
if (option === "year") {
|
|
16692
|
+
if (option === "year" && typeof savingsPercentage === "number") {
|
|
16523
16693
|
return /* @__PURE__ */ jsx25(
|
|
16524
16694
|
Tooltip,
|
|
16525
16695
|
{
|
|
@@ -16748,14 +16918,14 @@ var TieredPricingDetails = ({
|
|
|
16748
16918
|
};
|
|
16749
16919
|
|
|
16750
16920
|
// src/components/shared/unsubscribe-dialog/UnsubscribeDialog.tsx
|
|
16751
|
-
import { useMemo as useMemo14, useRef as
|
|
16921
|
+
import { useMemo as useMemo14, useRef as useRef9, useState as useState13 } from "react";
|
|
16752
16922
|
import { jsx as jsx28, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
16753
16923
|
var UnsubscribeDialog = ({ top = 0 }) => {
|
|
16754
16924
|
const { t: t2 } = useTranslation();
|
|
16755
16925
|
const { data, setCheckoutState } = useEmbed();
|
|
16756
|
-
const modalRef =
|
|
16757
|
-
const [error, setError] =
|
|
16758
|
-
const [isLoading, setIsLoading] =
|
|
16926
|
+
const modalRef = useRef9(null);
|
|
16927
|
+
const [error, setError] = useState13();
|
|
16928
|
+
const [isLoading, setIsLoading] = useState13(false);
|
|
16759
16929
|
const { planPeriod, currentPlan, currentAddOns, featureUsage, cancelDate } = useMemo14(() => {
|
|
16760
16930
|
const cancelDate2 = data?.subscription?.cancelAt || data?.upcomingInvoice?.dueDate;
|
|
16761
16931
|
return {
|
|
@@ -17035,9 +17205,9 @@ var StyledViewport = dt.div.withConfig({
|
|
|
17035
17205
|
import { Fragment as Fragment12, jsx as jsx32, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
17036
17206
|
var Viewport = forwardRef8(
|
|
17037
17207
|
({ children, portal, ...props }, ref) => {
|
|
17038
|
-
const portalRef =
|
|
17208
|
+
const portalRef = useRef10(portal || document.body);
|
|
17039
17209
|
const { data, layout, settings } = useEmbed();
|
|
17040
|
-
const [top, setTop] =
|
|
17210
|
+
const [top, setTop] = useState14(0);
|
|
17041
17211
|
const { canCheckout, isBadgeVisible } = useMemo15(() => {
|
|
17042
17212
|
return {
|
|
17043
17213
|
canCheckout: data?.capabilities?.checkout ?? true,
|
|
@@ -17068,12 +17238,12 @@ var Viewport = forwardRef8(
|
|
|
17068
17238
|
/* @__PURE__ */ jsx32(RenderLayout, { children }),
|
|
17069
17239
|
isBadgeVisible && /* @__PURE__ */ jsx32(Badge, {})
|
|
17070
17240
|
] }),
|
|
17071
|
-
canCheckout && layout === "checkout" &&
|
|
17072
|
-
layout === "unsubscribe" &&
|
|
17241
|
+
canCheckout && layout === "checkout" && createPortal3(/* @__PURE__ */ jsx32(CheckoutDialog, { top }), portal || document.body),
|
|
17242
|
+
layout === "unsubscribe" && createPortal3(
|
|
17073
17243
|
/* @__PURE__ */ jsx32(UnsubscribeDialog, { top }),
|
|
17074
17244
|
portal || document.body
|
|
17075
17245
|
),
|
|
17076
|
-
layout === "payment" &&
|
|
17246
|
+
layout === "payment" && createPortal3(/* @__PURE__ */ jsx32(PaymentDialog, { top }), portal || document.body)
|
|
17077
17247
|
] });
|
|
17078
17248
|
}
|
|
17079
17249
|
);
|
|
@@ -17140,7 +17310,7 @@ var ButtonElement = forwardRef9(({ children, className, ...rest }, ref) => {
|
|
|
17140
17310
|
ButtonElement.displayName = "Button";
|
|
17141
17311
|
|
|
17142
17312
|
// src/components/elements/included-features/IncludedFeatures.tsx
|
|
17143
|
-
import { forwardRef as forwardRef10, useMemo as useMemo17, useRef as
|
|
17313
|
+
import { forwardRef as forwardRef10, useMemo as useMemo17, useRef as useRef11, useState as useState15 } from "react";
|
|
17144
17314
|
|
|
17145
17315
|
// src/components/elements/included-features/UsageDetails.tsx
|
|
17146
17316
|
import { Fragment as Fragment13, useMemo as useMemo16 } from "react";
|
|
@@ -17397,10 +17567,10 @@ var IncludedFeatures = forwardRef10(({ className, ...rest }, ref) => {
|
|
|
17397
17567
|
const props = resolveDesignProps2(rest);
|
|
17398
17568
|
const { t: t2 } = useTranslation();
|
|
17399
17569
|
const { data, settings } = useEmbed();
|
|
17400
|
-
const elementsRef =
|
|
17570
|
+
const elementsRef = useRef11([]);
|
|
17401
17571
|
const shouldWrapChildren = useWrapChildren(elementsRef);
|
|
17402
17572
|
const isLightBackground = useIsLightBackground();
|
|
17403
|
-
const [showCount, setShowCount] =
|
|
17573
|
+
const [showCount, setShowCount] = useState15(VISIBLE_ENTITLEMENT_COUNT);
|
|
17404
17574
|
const { plan, addOns, featureUsage } = useMemo17(() => {
|
|
17405
17575
|
const orderedFeatureUsage = props.visibleFeatures?.reduce(
|
|
17406
17576
|
(acc, id) => {
|
|
@@ -17535,7 +17705,7 @@ var IncludedFeatures = forwardRef10(({ className, ...rest }, ref) => {
|
|
|
17535
17705
|
IncludedFeatures.displayName = "IncludedFeatures";
|
|
17536
17706
|
|
|
17537
17707
|
// src/components/elements/invoices/Invoices.tsx
|
|
17538
|
-
import { forwardRef as forwardRef11, useCallback as useCallback11, useEffect as
|
|
17708
|
+
import { forwardRef as forwardRef11, useCallback as useCallback11, useEffect as useEffect7, useState as useState16 } from "react";
|
|
17539
17709
|
import { Fragment as Fragment15, jsx as jsx36, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
17540
17710
|
function resolveDesignProps3(props) {
|
|
17541
17711
|
return {
|
|
@@ -17574,10 +17744,10 @@ var Invoices = forwardRef11(({ className, data, ...rest }, ref) => {
|
|
|
17574
17744
|
const props = resolveDesignProps3(rest);
|
|
17575
17745
|
const { t: t2 } = useTranslation();
|
|
17576
17746
|
const { listInvoices, settings } = useEmbed();
|
|
17577
|
-
const [isLoading, setIsLoading] =
|
|
17578
|
-
const [error, setError] =
|
|
17579
|
-
const [invoices, setInvoices] =
|
|
17580
|
-
const [listSize, setListSize] =
|
|
17747
|
+
const [isLoading, setIsLoading] = useState16(false);
|
|
17748
|
+
const [error, setError] = useState16();
|
|
17749
|
+
const [invoices, setInvoices] = useState16(() => formatInvoices(data));
|
|
17750
|
+
const [listSize, setListSize] = useState16(props.limit.number);
|
|
17581
17751
|
const getInvoices = useCallback11(async () => {
|
|
17582
17752
|
try {
|
|
17583
17753
|
setError(void 0);
|
|
@@ -17597,10 +17767,10 @@ var Invoices = forwardRef11(({ className, data, ...rest }, ref) => {
|
|
|
17597
17767
|
(prev2) => prev2 !== props.limit.number ? props.limit.number : MAX_VISIBLE_INVOICE_COUNT
|
|
17598
17768
|
);
|
|
17599
17769
|
};
|
|
17600
|
-
|
|
17770
|
+
useEffect7(() => {
|
|
17601
17771
|
getInvoices();
|
|
17602
17772
|
}, [getInvoices]);
|
|
17603
|
-
|
|
17773
|
+
useEffect7(() => {
|
|
17604
17774
|
setInvoices(formatInvoices(data));
|
|
17605
17775
|
}, [data]);
|
|
17606
17776
|
if (invoices.length === 0) {
|
|
@@ -17680,7 +17850,7 @@ var Invoices = forwardRef11(({ className, data, ...rest }, ref) => {
|
|
|
17680
17850
|
Invoices.displayName = "Invoices";
|
|
17681
17851
|
|
|
17682
17852
|
// src/components/elements/metered-features/MeteredFeatures.tsx
|
|
17683
|
-
import { forwardRef as forwardRef12, useCallback as useCallback12, useMemo as useMemo18, useRef as
|
|
17853
|
+
import { forwardRef as forwardRef12, useCallback as useCallback12, useMemo as useMemo18, useRef as useRef12, useState as useState17 } from "react";
|
|
17684
17854
|
|
|
17685
17855
|
// src/components/elements/metered-features/Meter.tsx
|
|
17686
17856
|
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
@@ -17882,7 +18052,7 @@ function resolveDesignProps4(props) {
|
|
|
17882
18052
|
}
|
|
17883
18053
|
var MeteredFeatures = forwardRef12(({ className, ...rest }, ref) => {
|
|
17884
18054
|
const props = resolveDesignProps4(rest);
|
|
17885
|
-
const elementsRef =
|
|
18055
|
+
const elementsRef = useRef12([]);
|
|
17886
18056
|
const shouldWrapChildren = useWrapChildren(elementsRef);
|
|
17887
18057
|
const { t: t2 } = useTranslation();
|
|
17888
18058
|
const { data, settings, setCheckoutState } = useEmbed();
|
|
@@ -17907,7 +18077,7 @@ var MeteredFeatures = forwardRef12(({ className, ...rest }, ref) => {
|
|
|
17907
18077
|
const creditGroups = groupCreditGrants(data?.creditGrants || [], {
|
|
17908
18078
|
groupBy: "credit"
|
|
17909
18079
|
});
|
|
17910
|
-
const [creditVisibility, setCreditVisibility] =
|
|
18080
|
+
const [creditVisibility, setCreditVisibility] = useState17(
|
|
17911
18081
|
creditGroups.map(({ id }) => ({ id, isExpanded: false }))
|
|
17912
18082
|
);
|
|
17913
18083
|
const toggleBalanceDetails = useCallback12((id) => {
|
|
@@ -18468,7 +18638,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
|
18468
18638
|
}
|
|
18469
18639
|
stripe._registerWrapper({
|
|
18470
18640
|
name: "stripe-js",
|
|
18471
|
-
version: "8.
|
|
18641
|
+
version: "8.3.0",
|
|
18472
18642
|
startTime
|
|
18473
18643
|
});
|
|
18474
18644
|
};
|
|
@@ -18543,7 +18713,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
|
|
|
18543
18713
|
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
18544
18714
|
var expectedVersion = RELEASE_TRAIN;
|
|
18545
18715
|
if (isTestKey && version !== expectedVersion) {
|
|
18546
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.
|
|
18716
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("8.3.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
18547
18717
|
}
|
|
18548
18718
|
var stripe = maybeStripe.apply(void 0, args);
|
|
18549
18719
|
registerWrapper(stripe, startTime);
|
|
@@ -18580,7 +18750,7 @@ var loadStripe = function loadStripe2() {
|
|
|
18580
18750
|
};
|
|
18581
18751
|
|
|
18582
18752
|
// src/components/elements/payment-method/PaymentMethodDetails.tsx
|
|
18583
|
-
import { useCallback as useCallback13, useEffect as
|
|
18753
|
+
import { useCallback as useCallback13, useEffect as useEffect8, useMemo as useMemo21, useState as useState18 } from "react";
|
|
18584
18754
|
import { Fragment as Fragment18, jsx as jsx42, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
18585
18755
|
var resolveDesignProps6 = () => {
|
|
18586
18756
|
return {
|
|
@@ -18621,13 +18791,13 @@ var PaymentMethodDetails = ({
|
|
|
18621
18791
|
data?.subscription
|
|
18622
18792
|
]);
|
|
18623
18793
|
const isLightBackground = useIsLightBackground();
|
|
18624
|
-
const [isLoading, setIsLoading] =
|
|
18625
|
-
const [error, setError] =
|
|
18626
|
-
const [showPaymentForm, setShowPaymentForm] =
|
|
18627
|
-
const [stripe, setStripe] =
|
|
18628
|
-
const [setupIntent, setSetupIntent] =
|
|
18629
|
-
const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] =
|
|
18630
|
-
const [currentPaymentMethod, setCurrentPaymentMethod] =
|
|
18794
|
+
const [isLoading, setIsLoading] = useState18(false);
|
|
18795
|
+
const [error, setError] = useState18();
|
|
18796
|
+
const [showPaymentForm, setShowPaymentForm] = useState18(false);
|
|
18797
|
+
const [stripe, setStripe] = useState18(null);
|
|
18798
|
+
const [setupIntent, setSetupIntent] = useState18();
|
|
18799
|
+
const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = useState18(false);
|
|
18800
|
+
const [currentPaymentMethod, setCurrentPaymentMethod] = useState18(subscription?.paymentMethod || defaultPaymentMethod);
|
|
18631
18801
|
const { isConfirming: isConfirmingPayment } = usePaymentConfirmation({
|
|
18632
18802
|
stripe,
|
|
18633
18803
|
clientSecret: confirmPaymentIntentProps?.clientSecret,
|
|
@@ -18714,7 +18884,7 @@ var PaymentMethodDetails = ({
|
|
|
18714
18884
|
},
|
|
18715
18885
|
[t2, deletePaymentMethod]
|
|
18716
18886
|
);
|
|
18717
|
-
|
|
18887
|
+
useEffect8(() => {
|
|
18718
18888
|
if (!stripe && setupIntent) {
|
|
18719
18889
|
let publishableKey = setupIntent.publishableKey || setupIntent.schematicPublishableKey;
|
|
18720
18890
|
const stripeOptions = {};
|
|
@@ -18726,7 +18896,7 @@ var PaymentMethodDetails = ({
|
|
|
18726
18896
|
setStripe(stripePromise2);
|
|
18727
18897
|
}
|
|
18728
18898
|
}, [stripe, setupIntent]);
|
|
18729
|
-
|
|
18899
|
+
useEffect8(() => {
|
|
18730
18900
|
if (!setupIntent && (!currentPaymentMethod || showPaymentForm)) {
|
|
18731
18901
|
initializePaymentMethod();
|
|
18732
18902
|
}
|
|
@@ -19074,7 +19244,7 @@ var resolveDesignProps7 = (props) => {
|
|
|
19074
19244
|
var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) => {
|
|
19075
19245
|
const props = resolveDesignProps7(rest);
|
|
19076
19246
|
const { t: t2 } = useTranslation();
|
|
19077
|
-
const { data, settings,
|
|
19247
|
+
const { data, settings, setLayout } = useEmbed();
|
|
19078
19248
|
const isLightBackground = useIsLightBackground();
|
|
19079
19249
|
const trialEnd = useTrialEnd();
|
|
19080
19250
|
const {
|
|
@@ -19435,11 +19605,7 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
|
|
|
19435
19605
|
{
|
|
19436
19606
|
type: "button",
|
|
19437
19607
|
onClick: () => {
|
|
19438
|
-
|
|
19439
|
-
planId: currentPlan?.id,
|
|
19440
|
-
addOnId: void 0,
|
|
19441
|
-
usage: false
|
|
19442
|
-
});
|
|
19608
|
+
setLayout("checkout");
|
|
19443
19609
|
},
|
|
19444
19610
|
$size: props.callToAction.buttonSize,
|
|
19445
19611
|
$color: props.callToAction.buttonStyle,
|
|
@@ -19459,9 +19625,8 @@ import {
|
|
|
19459
19625
|
Fragment as Fragment25,
|
|
19460
19626
|
forwardRef as forwardRef15,
|
|
19461
19627
|
useCallback as useCallback14,
|
|
19462
|
-
useEffect as
|
|
19463
|
-
|
|
19464
|
-
useState as useState18
|
|
19628
|
+
useEffect as useEffect9,
|
|
19629
|
+
useState as useState19
|
|
19465
19630
|
} from "react";
|
|
19466
19631
|
|
|
19467
19632
|
// src/components/elements/pricing-table/AddOn.tsx
|
|
@@ -20279,30 +20444,14 @@ var PricingTable = forwardRef15(({ className, ...rest }, ref) => {
|
|
|
20279
20444
|
},
|
|
20280
20445
|
[]
|
|
20281
20446
|
);
|
|
20282
|
-
const
|
|
20283
|
-
|
|
20284
|
-
|
|
20285
|
-
currentPeriod: data?.company?.plan?.planPeriod || "month",
|
|
20286
|
-
currentAddOns: data?.company?.addOns || [],
|
|
20287
|
-
canCheckout: isStandalone2 ?? data?.capabilities?.checkout ?? true,
|
|
20288
|
-
isTrialSubscription: data?.company?.billingSubscription?.status === "trialing",
|
|
20289
|
-
willSubscriptionCancel: data?.company?.billingSubscription?.cancelAt,
|
|
20290
|
-
isStandalone: isStandalone2
|
|
20291
|
-
};
|
|
20292
|
-
}, [
|
|
20293
|
-
data?.capabilities?.checkout,
|
|
20294
|
-
data?.company?.addOns,
|
|
20295
|
-
data?.company?.billingSubscription?.cancelAt,
|
|
20296
|
-
data?.company?.billingSubscription?.status,
|
|
20297
|
-
data?.company?.plan?.planPeriod,
|
|
20298
|
-
data?.component
|
|
20299
|
-
]);
|
|
20300
|
-
const [selectedPeriod, setSelectedPeriod] = useState18(currentPeriod);
|
|
20447
|
+
const [selectedPeriod, setSelectedPeriod] = useState19(
|
|
20448
|
+
() => data?.company?.plan?.planPeriod || "month"
|
|
20449
|
+
);
|
|
20301
20450
|
const showPeriodToggle = rest.showPeriodToggle ?? data?.showPeriodToggle ?? true;
|
|
20302
20451
|
const { plans, addOns, periods } = useAvailablePlans(selectedPeriod, {
|
|
20303
20452
|
useSelectedPeriod: showPeriodToggle
|
|
20304
20453
|
});
|
|
20305
|
-
const [entitlementCounts, setEntitlementCounts] =
|
|
20454
|
+
const [entitlementCounts, setEntitlementCounts] = useState19(
|
|
20306
20455
|
() => plans.reduce(entitlementCountsReducer, {})
|
|
20307
20456
|
);
|
|
20308
20457
|
const handleToggleShowAll = (id) => {
|
|
@@ -20320,12 +20469,12 @@ var PricingTable = forwardRef15(({ className, ...rest }, ref) => {
|
|
|
20320
20469
|
return prev2;
|
|
20321
20470
|
});
|
|
20322
20471
|
};
|
|
20323
|
-
|
|
20324
|
-
if (
|
|
20472
|
+
useEffect9(() => {
|
|
20473
|
+
if (typeof data?.component === "undefined") {
|
|
20325
20474
|
hydratePublic();
|
|
20326
20475
|
}
|
|
20327
|
-
}, [
|
|
20328
|
-
|
|
20476
|
+
}, [data?.component, hydratePublic]);
|
|
20477
|
+
useEffect9(() => {
|
|
20329
20478
|
setEntitlementCounts(plans.reduce(entitlementCountsReducer, {}));
|
|
20330
20479
|
}, [plans]);
|
|
20331
20480
|
if (isPending) {
|
|
@@ -20341,12 +20490,13 @@ var PricingTable = forwardRef15(({ className, ...rest }, ref) => {
|
|
|
20341
20490
|
}
|
|
20342
20491
|
);
|
|
20343
20492
|
}
|
|
20493
|
+
const currentPlan = plans.find((plan) => plan.id === data?.company?.plan?.id);
|
|
20344
20494
|
const showCallToAction = typeof data?.component !== "undefined" || typeof rest.callToActionUrl === "string" || typeof rest.onCallToAction === "function";
|
|
20345
20495
|
const callToActionTarget = getCallToActionTarget(
|
|
20346
20496
|
rest.callToActionUrl,
|
|
20347
20497
|
rest.callToActionTarget
|
|
20348
20498
|
);
|
|
20349
|
-
const Wrapper =
|
|
20499
|
+
const Wrapper = typeof data?.component === "undefined" ? Container : Fragment25;
|
|
20350
20500
|
return /* @__PURE__ */ jsx49(Wrapper, { children: /* @__PURE__ */ jsxs38(
|
|
20351
20501
|
FussyChild,
|
|
20352
20502
|
{
|
|
@@ -20379,6 +20529,7 @@ var PricingTable = forwardRef15(({ className, ...rest }, ref) => {
|
|
|
20379
20529
|
{
|
|
20380
20530
|
options: periods,
|
|
20381
20531
|
selectedOption: selectedPeriod,
|
|
20532
|
+
selectedPlan: currentPlan,
|
|
20382
20533
|
onSelect: (period) => {
|
|
20383
20534
|
if (period !== selectedPeriod) {
|
|
20384
20535
|
setSelectedPeriod(period);
|
|
@@ -20491,7 +20642,7 @@ var TextElement = forwardRef16(({ children, className, ...rest }, ref) => {
|
|
|
20491
20642
|
TextElement.displayName = "Text";
|
|
20492
20643
|
|
|
20493
20644
|
// src/components/elements/unsubscribe-button/UnsubscribeButton.tsx
|
|
20494
|
-
import { forwardRef as forwardRef17, useMemo as
|
|
20645
|
+
import { forwardRef as forwardRef17, useMemo as useMemo26 } from "react";
|
|
20495
20646
|
import { jsx as jsx51 } from "react/jsx-runtime";
|
|
20496
20647
|
var buttonStyles = {
|
|
20497
20648
|
primary: {
|
|
@@ -20522,7 +20673,7 @@ var UnsubscribeButton = forwardRef17(({ children, className, ...rest }, ref) =>
|
|
|
20522
20673
|
const props = resolveDesignProps10(rest);
|
|
20523
20674
|
const { t: t2 } = useTranslation();
|
|
20524
20675
|
const { data, setLayout } = useEmbed();
|
|
20525
|
-
const hasActiveSubscription =
|
|
20676
|
+
const hasActiveSubscription = useMemo26(() => {
|
|
20526
20677
|
return data?.subscription && data.subscription.status !== "cancelled" && !data.subscription.cancelAt;
|
|
20527
20678
|
}, [data?.subscription]);
|
|
20528
20679
|
if (!hasActiveSubscription) {
|
|
@@ -20557,7 +20708,7 @@ var UnsubscribeButton = forwardRef17(({ children, className, ...rest }, ref) =>
|
|
|
20557
20708
|
UnsubscribeButton.displayName = "UnsubscribeButton";
|
|
20558
20709
|
|
|
20559
20710
|
// src/components/elements/upcoming-bill/UpcomingBill.tsx
|
|
20560
|
-
import { forwardRef as forwardRef18, useCallback as useCallback15, useEffect as
|
|
20711
|
+
import { forwardRef as forwardRef18, useCallback as useCallback15, useEffect as useEffect10, useMemo as useMemo27, useState as useState20 } from "react";
|
|
20561
20712
|
import { jsx as jsx52, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
20562
20713
|
function resolveDesignProps11(props) {
|
|
20563
20714
|
return {
|
|
@@ -20582,11 +20733,11 @@ var UpcomingBill = forwardRef18(({ className, ...rest }, ref) => {
|
|
|
20582
20733
|
const { t: t2 } = useTranslation();
|
|
20583
20734
|
const { data, settings, debug, getUpcomingInvoice, getCustomerBalance } = useEmbed();
|
|
20584
20735
|
const isLightBackground = useIsLightBackground();
|
|
20585
|
-
const [isLoading, setIsLoading] =
|
|
20586
|
-
const [error, setError] =
|
|
20587
|
-
const [upcomingInvoice, setUpcomingInvoice] =
|
|
20588
|
-
const [balances, setBalances] =
|
|
20589
|
-
const discounts =
|
|
20736
|
+
const [isLoading, setIsLoading] = useState20(false);
|
|
20737
|
+
const [error, setError] = useState20();
|
|
20738
|
+
const [upcomingInvoice, setUpcomingInvoice] = useState20();
|
|
20739
|
+
const [balances, setBalances] = useState20([]);
|
|
20740
|
+
const discounts = useMemo27(() => {
|
|
20590
20741
|
return (data?.subscription?.discounts || []).map((discount) => ({
|
|
20591
20742
|
couponId: discount.couponId,
|
|
20592
20743
|
customerFacingCode: discount.customerFacingCode || void 0,
|
|
@@ -20622,10 +20773,10 @@ var UpcomingBill = forwardRef18(({ className, ...rest }, ref) => {
|
|
|
20622
20773
|
debug("Failed to fetch customer balance.", err2);
|
|
20623
20774
|
}
|
|
20624
20775
|
}, [debug, getCustomerBalance]);
|
|
20625
|
-
|
|
20776
|
+
useEffect10(() => {
|
|
20626
20777
|
getInvoice();
|
|
20627
20778
|
}, [getInvoice]);
|
|
20628
|
-
|
|
20779
|
+
useEffect10(() => {
|
|
20629
20780
|
getBalances();
|
|
20630
20781
|
}, [getBalances]);
|
|
20631
20782
|
if (!data?.subscription || data.subscription.cancelAt) {
|
|
@@ -24937,7 +25088,7 @@ var { Inflate, inflate, inflateRaw, ungzip } = inflate_1$1;
|
|
|
24937
25088
|
var inflate_1 = inflate;
|
|
24938
25089
|
|
|
24939
25090
|
// src/components/embed/Embed.tsx
|
|
24940
|
-
import { useContext as useContext6, useEffect as
|
|
25091
|
+
import { useContext as useContext6, useEffect as useEffect11, useState as useState21 } from "react";
|
|
24941
25092
|
|
|
24942
25093
|
// src/components/embed/renderer.ts
|
|
24943
25094
|
import { createElement as createElement5 } from "react";
|
|
@@ -25053,7 +25204,7 @@ var Error2 = ({ message }) => {
|
|
|
25053
25204
|
);
|
|
25054
25205
|
};
|
|
25055
25206
|
var SchematicEmbed = ({ id, accessToken }) => {
|
|
25056
|
-
const [children, setChildren] =
|
|
25207
|
+
const [children, setChildren] = useState21(/* @__PURE__ */ jsx53(Loading, {}));
|
|
25057
25208
|
const theme = useContext6(et);
|
|
25058
25209
|
const {
|
|
25059
25210
|
data,
|
|
@@ -25065,17 +25216,17 @@ var SchematicEmbed = ({ id, accessToken }) => {
|
|
|
25065
25216
|
setAccessToken,
|
|
25066
25217
|
updateSettings
|
|
25067
25218
|
} = useEmbed();
|
|
25068
|
-
|
|
25219
|
+
useEffect11(() => {
|
|
25069
25220
|
if (accessToken) {
|
|
25070
25221
|
setAccessToken(accessToken);
|
|
25071
25222
|
}
|
|
25072
25223
|
}, [accessToken, setAccessToken]);
|
|
25073
|
-
|
|
25224
|
+
useEffect11(() => {
|
|
25074
25225
|
if (id && stale) {
|
|
25075
25226
|
hydrateComponent(id);
|
|
25076
25227
|
}
|
|
25077
25228
|
}, [id, hydrateComponent, stale]);
|
|
25078
|
-
|
|
25229
|
+
useEffect11(() => {
|
|
25079
25230
|
try {
|
|
25080
25231
|
if (data?.component?.ast) {
|
|
25081
25232
|
const nodes = [];
|