@schematichq/schematic-components 2.1.1 → 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 +255 -107
- package/dist/schematic-components.d.ts +147 -11
- package/dist/schematic-components.esm.js +349 -199
- package/package.json +3 -3
|
@@ -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
|
|
@@ -12333,7 +12375,7 @@ var Overlay = dt(Box)`
|
|
|
12333
12375
|
left: 0;
|
|
12334
12376
|
z-index: 999999;
|
|
12335
12377
|
width: 100%;
|
|
12336
|
-
height:
|
|
12378
|
+
height: 100dvh;
|
|
12337
12379
|
overflow: hidden;
|
|
12338
12380
|
scrollbar-width: thin;
|
|
12339
12381
|
scrollbar-gutter: stable both-edges;
|
|
@@ -12350,7 +12392,7 @@ var Modal = dt.div.attrs({
|
|
|
12350
12392
|
flex-direction: column;
|
|
12351
12393
|
width: 100%;
|
|
12352
12394
|
height: fit-content;
|
|
12353
|
-
max-height:
|
|
12395
|
+
max-height: 100dvh;
|
|
12354
12396
|
overflow: auto;
|
|
12355
12397
|
background-color: ${({ theme }) => theme.card.background};
|
|
12356
12398
|
box-shadow:
|
|
@@ -12432,7 +12474,7 @@ var ModalContent = forwardRef2(({ children }, ref) => {
|
|
|
12432
12474
|
md: {
|
|
12433
12475
|
$flexDirection: "row",
|
|
12434
12476
|
$height: "calc(100% - 5rem + 3px)",
|
|
12435
|
-
$maxHeight: "calc(
|
|
12477
|
+
$maxHeight: "calc(100dvh - 5rem + 3px)"
|
|
12436
12478
|
}
|
|
12437
12479
|
},
|
|
12438
12480
|
children
|
|
@@ -12982,8 +13024,8 @@ Root.displayName = "Root";
|
|
|
12982
13024
|
|
|
12983
13025
|
// src/components/layout/viewport/Viewport.tsx
|
|
12984
13026
|
var import_debounce3 = __toESM(require_debounce());
|
|
12985
|
-
import { forwardRef as forwardRef8, useLayoutEffect as useLayoutEffect5, useMemo as useMemo15, useRef as
|
|
12986
|
-
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";
|
|
12987
13029
|
|
|
12988
13030
|
// src/components/shared/billing-threshold-tooltip/BillingThresholdTooltip.tsx
|
|
12989
13031
|
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
@@ -13017,19 +13059,23 @@ var BillingThresholdTooltip = ({
|
|
|
13017
13059
|
// src/components/shared/checkout-dialog/CheckoutDialog.tsx
|
|
13018
13060
|
import {
|
|
13019
13061
|
useCallback as useCallback10,
|
|
13020
|
-
useEffect as
|
|
13062
|
+
useEffect as useEffect6,
|
|
13021
13063
|
useLayoutEffect as useLayoutEffect4,
|
|
13022
13064
|
useMemo as useMemo9,
|
|
13023
|
-
useRef as
|
|
13024
|
-
useState as
|
|
13065
|
+
useRef as useRef7,
|
|
13066
|
+
useState as useState11
|
|
13025
13067
|
} from "react";
|
|
13026
13068
|
|
|
13027
13069
|
// src/components/shared/sidebar/Sidebar.tsx
|
|
13028
13070
|
import {
|
|
13029
13071
|
forwardRef as forwardRef7,
|
|
13030
13072
|
useCallback as useCallback9,
|
|
13031
|
-
|
|
13073
|
+
useEffect as useEffect4,
|
|
13074
|
+
useMemo as useMemo7,
|
|
13075
|
+
useRef as useRef6,
|
|
13076
|
+
useState as useState8
|
|
13032
13077
|
} from "react";
|
|
13078
|
+
import { createPortal as createPortal2 } from "react-dom";
|
|
13033
13079
|
|
|
13034
13080
|
// src/components/shared/sidebar/EntitlementRow.tsx
|
|
13035
13081
|
import { Fragment as Fragment3, jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
@@ -13152,6 +13198,7 @@ import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
|
13152
13198
|
var NoPaymentRequired = ({
|
|
13153
13199
|
isDisabled,
|
|
13154
13200
|
isLoading,
|
|
13201
|
+
isSticky,
|
|
13155
13202
|
onClick
|
|
13156
13203
|
}) => {
|
|
13157
13204
|
const { t: t2 } = useTranslation();
|
|
@@ -13162,6 +13209,7 @@ var NoPaymentRequired = ({
|
|
|
13162
13209
|
disabled: isDisabled,
|
|
13163
13210
|
onClick,
|
|
13164
13211
|
$isLoading: isLoading,
|
|
13212
|
+
$size: isSticky ? "sm" : "md",
|
|
13165
13213
|
$fullWidth: true,
|
|
13166
13214
|
children: t2("Subscribe and close")
|
|
13167
13215
|
}
|
|
@@ -13178,6 +13226,7 @@ var StageButton = ({
|
|
|
13178
13226
|
hasPlan,
|
|
13179
13227
|
inEditMode,
|
|
13180
13228
|
isLoading,
|
|
13229
|
+
isSticky,
|
|
13181
13230
|
isPaymentMethodRequired,
|
|
13182
13231
|
isSelectedPlanTrialable,
|
|
13183
13232
|
setCheckoutStage,
|
|
@@ -13225,7 +13274,8 @@ var StageButton = ({
|
|
|
13225
13274
|
{
|
|
13226
13275
|
isDisabled,
|
|
13227
13276
|
isLoading,
|
|
13228
|
-
onClick: checkout
|
|
13277
|
+
onClick: checkout,
|
|
13278
|
+
isSticky
|
|
13229
13279
|
}
|
|
13230
13280
|
);
|
|
13231
13281
|
}
|
|
@@ -13241,6 +13291,7 @@ var StageButton = ({
|
|
|
13241
13291
|
},
|
|
13242
13292
|
$isLoading: isLoading,
|
|
13243
13293
|
$fullWidth: true,
|
|
13294
|
+
$size: isSticky ? "sm" : "md",
|
|
13244
13295
|
children: /* @__PURE__ */ jsxs8(Flex, { $gap: "0.5rem", $justifyContent: "center", $alignItems: "center", children: [
|
|
13245
13296
|
t2("Next"),
|
|
13246
13297
|
":",
|
|
@@ -13260,7 +13311,8 @@ var StageButton = ({
|
|
|
13260
13311
|
{
|
|
13261
13312
|
isDisabled,
|
|
13262
13313
|
isLoading,
|
|
13263
|
-
onClick: checkout
|
|
13314
|
+
onClick: checkout,
|
|
13315
|
+
isSticky
|
|
13264
13316
|
}
|
|
13265
13317
|
);
|
|
13266
13318
|
}
|
|
@@ -13276,6 +13328,7 @@ var StageButton = ({
|
|
|
13276
13328
|
},
|
|
13277
13329
|
$isLoading: isLoading,
|
|
13278
13330
|
$fullWidth: true,
|
|
13331
|
+
$size: isSticky ? "sm" : "md",
|
|
13279
13332
|
children: /* @__PURE__ */ jsxs8(
|
|
13280
13333
|
Flex,
|
|
13281
13334
|
{
|
|
@@ -13308,7 +13361,8 @@ var StageButton = ({
|
|
|
13308
13361
|
{
|
|
13309
13362
|
isDisabled,
|
|
13310
13363
|
isLoading,
|
|
13311
|
-
onClick: checkout
|
|
13364
|
+
onClick: checkout,
|
|
13365
|
+
isSticky
|
|
13312
13366
|
}
|
|
13313
13367
|
);
|
|
13314
13368
|
}
|
|
@@ -13350,7 +13404,8 @@ var StageButton = ({
|
|
|
13350
13404
|
{
|
|
13351
13405
|
isDisabled,
|
|
13352
13406
|
isLoading,
|
|
13353
|
-
onClick: checkout
|
|
13407
|
+
onClick: checkout,
|
|
13408
|
+
isSticky
|
|
13354
13409
|
}
|
|
13355
13410
|
);
|
|
13356
13411
|
}
|
|
@@ -13364,6 +13419,7 @@ var StageButton = ({
|
|
|
13364
13419
|
},
|
|
13365
13420
|
$isLoading: isLoading,
|
|
13366
13421
|
$fullWidth: true,
|
|
13422
|
+
$size: isSticky ? "sm" : "md",
|
|
13367
13423
|
children: /* @__PURE__ */ jsxs8(
|
|
13368
13424
|
Flex,
|
|
13369
13425
|
{
|
|
@@ -13389,7 +13445,8 @@ var StageButton = ({
|
|
|
13389
13445
|
{
|
|
13390
13446
|
isDisabled,
|
|
13391
13447
|
isLoading,
|
|
13392
|
-
onClick: checkout
|
|
13448
|
+
onClick: checkout,
|
|
13449
|
+
isSticky
|
|
13393
13450
|
}
|
|
13394
13451
|
);
|
|
13395
13452
|
}
|
|
@@ -13428,7 +13485,8 @@ var StageButton = ({
|
|
|
13428
13485
|
{
|
|
13429
13486
|
isDisabled,
|
|
13430
13487
|
isLoading,
|
|
13431
|
-
onClick: checkout
|
|
13488
|
+
onClick: checkout,
|
|
13489
|
+
isSticky
|
|
13432
13490
|
}
|
|
13433
13491
|
);
|
|
13434
13492
|
}
|
|
@@ -13800,6 +13858,42 @@ var Sidebar = forwardRef7(
|
|
|
13800
13858
|
trialEndsOn.setDate(trialEndsOn.getDate() + selectedPlan.trialDays);
|
|
13801
13859
|
}
|
|
13802
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
|
+
};
|
|
13803
13897
|
return /* @__PURE__ */ jsxs9(
|
|
13804
13898
|
Flex,
|
|
13805
13899
|
{
|
|
@@ -14285,27 +14379,42 @@ var Sidebar = forwardRef7(
|
|
|
14285
14379
|
] }) }),
|
|
14286
14380
|
/* @__PURE__ */ jsx15(Box, { children: /* @__PURE__ */ jsx15(Text, { children: formatCurrency(Math.abs(dueNow), selectedPlanCurrency) }) })
|
|
14287
14381
|
] }),
|
|
14288
|
-
layout === "checkout" && /* @__PURE__ */
|
|
14289
|
-
|
|
14290
|
-
|
|
14291
|
-
|
|
14292
|
-
|
|
14293
|
-
|
|
14294
|
-
|
|
14295
|
-
|
|
14296
|
-
|
|
14297
|
-
|
|
14298
|
-
|
|
14299
|
-
|
|
14300
|
-
|
|
14301
|
-
|
|
14302
|
-
|
|
14303
|
-
|
|
14304
|
-
|
|
14305
|
-
|
|
14306
|
-
|
|
14307
|
-
|
|
14308
|
-
|
|
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
|
+
] }),
|
|
14309
14418
|
layout === "unsubscribe" && /* @__PURE__ */ jsx15(
|
|
14310
14419
|
Button,
|
|
14311
14420
|
{
|
|
@@ -14616,7 +14725,7 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
|
|
|
14616
14725
|
};
|
|
14617
14726
|
|
|
14618
14727
|
// src/components/shared/checkout-dialog/Checkout.tsx
|
|
14619
|
-
import { useState as
|
|
14728
|
+
import { useState as useState9 } from "react";
|
|
14620
14729
|
import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
14621
14730
|
var Checkout = ({
|
|
14622
14731
|
isPaymentMethodRequired,
|
|
@@ -14628,7 +14737,7 @@ var Checkout = ({
|
|
|
14628
14737
|
}) => {
|
|
14629
14738
|
const { t: t2 } = useTranslation();
|
|
14630
14739
|
const isLightBackground = useIsLightBackground();
|
|
14631
|
-
const [discount, setDiscount] =
|
|
14740
|
+
const [discount, setDiscount] = useState9("");
|
|
14632
14741
|
if (!isPaymentMethodRequired) {
|
|
14633
14742
|
return null;
|
|
14634
14743
|
}
|
|
@@ -14842,7 +14951,7 @@ var Navigation = ({
|
|
|
14842
14951
|
};
|
|
14843
14952
|
|
|
14844
14953
|
// src/components/shared/checkout-dialog/Plan.tsx
|
|
14845
|
-
import { Fragment as Fragment7, useEffect as
|
|
14954
|
+
import { Fragment as Fragment7, useEffect as useEffect5, useMemo as useMemo8, useState as useState10 } from "react";
|
|
14846
14955
|
|
|
14847
14956
|
// src/components/shared/checkout-dialog/styles.ts
|
|
14848
14957
|
var FlexWithAlignEnd = dt(Flex)`
|
|
@@ -14986,7 +15095,7 @@ var Plan = ({
|
|
|
14986
15095
|
const { t: t2 } = useTranslation();
|
|
14987
15096
|
const { data, settings } = useEmbed();
|
|
14988
15097
|
const isLightBackground = useIsLightBackground();
|
|
14989
|
-
const [entitlementCounts, setEntitlementCounts] =
|
|
15098
|
+
const [entitlementCounts, setEntitlementCounts] = useState10(
|
|
14990
15099
|
() => plans.reduce(entitlementCountsReducer, {})
|
|
14991
15100
|
);
|
|
14992
15101
|
const { isTrialing, showCredits, showPeriodToggle, showZeroPriceAsFree } = useMemo8(() => {
|
|
@@ -15017,7 +15126,7 @@ var Plan = ({
|
|
|
15017
15126
|
return prev2;
|
|
15018
15127
|
});
|
|
15019
15128
|
};
|
|
15020
|
-
|
|
15129
|
+
useEffect5(() => {
|
|
15021
15130
|
setEntitlementCounts(plans.reduce(entitlementCountsReducer, {}));
|
|
15022
15131
|
}, [plans]);
|
|
15023
15132
|
const cardPadding = settings.theme.card.padding / TEXT_BASE_SIZE;
|
|
@@ -15563,19 +15672,19 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15563
15672
|
const { t: t2 } = useTranslation();
|
|
15564
15673
|
const { data, settings, isPending, checkoutState, previewCheckout } = useEmbed();
|
|
15565
15674
|
const isLightBackground = useIsLightBackground();
|
|
15566
|
-
const modalRef =
|
|
15567
|
-
const contentRef =
|
|
15568
|
-
const stageRef =
|
|
15569
|
-
const sidebarRef =
|
|
15570
|
-
const [confirmPaymentIntentProps, setConfirmPaymentIntentProps] =
|
|
15571
|
-
const [charges, setCharges] =
|
|
15572
|
-
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(
|
|
15573
15682
|
() => {
|
|
15574
15683
|
return data?.subscription?.paymentMethod?.externalId || data?.company?.defaultPaymentMethod?.externalId;
|
|
15575
15684
|
}
|
|
15576
15685
|
);
|
|
15577
|
-
const [isLoading, setIsLoading] =
|
|
15578
|
-
const [error, setError] =
|
|
15686
|
+
const [isLoading, setIsLoading] = useState11(false);
|
|
15687
|
+
const [error, setError] = useState11();
|
|
15579
15688
|
const {
|
|
15580
15689
|
currentPlanId,
|
|
15581
15690
|
currentEntitlements,
|
|
@@ -15598,7 +15707,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15598
15707
|
() => checkoutState?.period || data?.company?.plan?.planPeriod || "month",
|
|
15599
15708
|
[data?.company?.plan?.planPeriod, checkoutState?.period]
|
|
15600
15709
|
);
|
|
15601
|
-
const [planPeriod, setPlanPeriod] =
|
|
15710
|
+
const [planPeriod, setPlanPeriod] = useState11(currentPeriod);
|
|
15602
15711
|
const {
|
|
15603
15712
|
plans: availablePlans,
|
|
15604
15713
|
addOns: availableAddOns,
|
|
@@ -15606,15 +15715,15 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15606
15715
|
} = useAvailablePlans(planPeriod, {
|
|
15607
15716
|
useSelectedPeriod: showPeriodToggle
|
|
15608
15717
|
});
|
|
15609
|
-
const [selectedPlan, setSelectedPlan] =
|
|
15718
|
+
const [selectedPlan, setSelectedPlan] = useState11(
|
|
15610
15719
|
() => {
|
|
15611
15720
|
return availablePlans.find(
|
|
15612
15721
|
(plan) => checkoutState?.planId ? plan.id === checkoutState.planId : plan.current
|
|
15613
15722
|
);
|
|
15614
15723
|
}
|
|
15615
15724
|
);
|
|
15616
|
-
const [shouldTrial, setShouldTrial] =
|
|
15617
|
-
const [addOns, setAddOns] =
|
|
15725
|
+
const [shouldTrial, setShouldTrial] = useState11(false);
|
|
15726
|
+
const [addOns, setAddOns] = useState11(() => {
|
|
15618
15727
|
return availableAddOns.map((addOn) => ({
|
|
15619
15728
|
...addOn,
|
|
15620
15729
|
isSelected: typeof checkoutState?.addOnId !== "undefined" ? addOn.id === checkoutState.addOnId : (data?.company?.addOns || []).some(
|
|
@@ -15622,13 +15731,13 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15622
15731
|
)
|
|
15623
15732
|
}));
|
|
15624
15733
|
});
|
|
15625
|
-
const [creditBundles, setCreditBundles] =
|
|
15734
|
+
const [creditBundles, setCreditBundles] = useState11(() => {
|
|
15626
15735
|
return (data?.creditBundles || []).map((bundle) => ({
|
|
15627
15736
|
...bundle,
|
|
15628
15737
|
count: 0
|
|
15629
15738
|
}));
|
|
15630
15739
|
});
|
|
15631
|
-
const [usageBasedEntitlements, setUsageBasedEntitlements] =
|
|
15740
|
+
const [usageBasedEntitlements, setUsageBasedEntitlements] = useState11(
|
|
15632
15741
|
() => (selectedPlan?.entitlements || []).reduce(
|
|
15633
15742
|
createActiveUsageBasedEntitlementsReducer(
|
|
15634
15743
|
currentEntitlements,
|
|
@@ -15637,7 +15746,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15637
15746
|
[]
|
|
15638
15747
|
)
|
|
15639
15748
|
);
|
|
15640
|
-
const [addOnUsageBasedEntitlements, setAddOnUsageBasedEntitlements] =
|
|
15749
|
+
const [addOnUsageBasedEntitlements, setAddOnUsageBasedEntitlements] = useState11(() => {
|
|
15641
15750
|
return (data?.company?.addOns || []).flatMap((currentAddOn) => {
|
|
15642
15751
|
const availableAddOn = availableAddOns.find(
|
|
15643
15752
|
(available) => available.id === currentAddOn.id
|
|
@@ -15664,8 +15773,8 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15664
15773
|
),
|
|
15665
15774
|
[addOnUsageBasedEntitlements]
|
|
15666
15775
|
);
|
|
15667
|
-
const [promoCode, setPromoCode] =
|
|
15668
|
-
const [isPaymentMethodRequired, setIsPaymentMethodRequired] =
|
|
15776
|
+
const [promoCode, setPromoCode] = useState11(null);
|
|
15777
|
+
const [isPaymentMethodRequired, setIsPaymentMethodRequired] = useState11(false);
|
|
15669
15778
|
const willTrialWithoutPaymentMethod = useMemo9(
|
|
15670
15779
|
() => shouldTrial && !trialPaymentMethodRequired,
|
|
15671
15780
|
[shouldTrial, trialPaymentMethodRequired]
|
|
@@ -15738,7 +15847,8 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15738
15847
|
creditBundles,
|
|
15739
15848
|
isPaymentMethodRequired
|
|
15740
15849
|
]);
|
|
15741
|
-
const [
|
|
15850
|
+
const [hasSkippedInitialPlan, setHasSkippedInitialPlan] = useState11(false);
|
|
15851
|
+
const [checkoutStage, setCheckoutStage] = useState11(() => {
|
|
15742
15852
|
if (checkoutState?.addOnId) {
|
|
15743
15853
|
return "addons";
|
|
15744
15854
|
}
|
|
@@ -15751,11 +15861,25 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15751
15861
|
if (checkoutState?.credits) {
|
|
15752
15862
|
return "credits";
|
|
15753
15863
|
}
|
|
15754
|
-
if (typeof checkoutState?.planId !== "undefined" && checkoutState.planId !== currentPlanId) {
|
|
15755
|
-
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";
|
|
15756
15866
|
}
|
|
15757
15867
|
return "plan";
|
|
15758
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
|
+
]);
|
|
15759
15883
|
const handlePreviewCheckout = useCallback10(
|
|
15760
15884
|
async (updates) => {
|
|
15761
15885
|
const period = updates.period || planPeriod;
|
|
@@ -15883,14 +16007,19 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15883
16007
|
const selectPlan = useCallback10(
|
|
15884
16008
|
(updates) => {
|
|
15885
16009
|
const plan = updates.plan;
|
|
15886
|
-
const period = updates.period || planPeriod
|
|
16010
|
+
const period = showPeriodToggle ? updates.period || planPeriod : plan.yearlyPrice && !plan.monthlyPrice ? "year" /* Year */ : "month" /* Month */;
|
|
15887
16011
|
const updatedUsageBasedEntitlements = plan.entitlements.reduce(
|
|
15888
16012
|
createActiveUsageBasedEntitlementsReducer(currentEntitlements, period),
|
|
15889
16013
|
[]
|
|
15890
16014
|
);
|
|
16015
|
+
if (period !== planPeriod || plan.id !== selectedPlan?.id) {
|
|
16016
|
+
setUsageBasedEntitlements(updatedUsageBasedEntitlements);
|
|
16017
|
+
}
|
|
16018
|
+
if (period !== planPeriod) {
|
|
16019
|
+
setPlanPeriod(period);
|
|
16020
|
+
}
|
|
15891
16021
|
if (plan.id !== selectedPlan?.id) {
|
|
15892
16022
|
setSelectedPlan(plan);
|
|
15893
|
-
setUsageBasedEntitlements(updatedUsageBasedEntitlements);
|
|
15894
16023
|
}
|
|
15895
16024
|
const updatedShouldTrial = updates.shouldTrial ?? shouldTrial;
|
|
15896
16025
|
setShouldTrial(updatedShouldTrial);
|
|
@@ -15919,6 +16048,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
15919
16048
|
[
|
|
15920
16049
|
selectedPlan?.id,
|
|
15921
16050
|
planPeriod,
|
|
16051
|
+
showPeriodToggle,
|
|
15922
16052
|
currentEntitlements,
|
|
15923
16053
|
shouldTrial,
|
|
15924
16054
|
willTrialWithoutPaymentMethod,
|
|
@@ -16018,18 +16148,35 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16018
16148
|
},
|
|
16019
16149
|
[handlePreviewCheckout]
|
|
16020
16150
|
);
|
|
16021
|
-
|
|
16151
|
+
useEffect6(() => {
|
|
16022
16152
|
if (selectedPlan) {
|
|
16023
16153
|
selectPlan({ plan: selectedPlan, period: currentPeriod });
|
|
16024
16154
|
}
|
|
16025
16155
|
}, []);
|
|
16026
|
-
|
|
16027
|
-
|
|
16028
|
-
|
|
16029
|
-
|
|
16030
|
-
|
|
16156
|
+
useEffect6(() => {
|
|
16157
|
+
if (checkoutState?.planId) {
|
|
16158
|
+
const plan = availablePlans.find(
|
|
16159
|
+
(plan2) => plan2.id === checkoutState.planId
|
|
16160
|
+
);
|
|
16161
|
+
setSelectedPlan(plan);
|
|
16162
|
+
}
|
|
16031
16163
|
}, [availablePlans, checkoutState?.planId]);
|
|
16032
|
-
|
|
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(() => {
|
|
16033
16180
|
setAddOns((prevAddOns) => {
|
|
16034
16181
|
return availableAddOns.filter((availAddOn) => {
|
|
16035
16182
|
if (!selectedPlan) {
|
|
@@ -16051,7 +16198,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16051
16198
|
});
|
|
16052
16199
|
});
|
|
16053
16200
|
}, [data?.addOnCompatibilities, availableAddOns, selectedPlan]);
|
|
16054
|
-
|
|
16201
|
+
useEffect6(() => {
|
|
16055
16202
|
if (charges) {
|
|
16056
16203
|
sidebarRef.current?.scrollTo({
|
|
16057
16204
|
top: 0,
|
|
@@ -16070,7 +16217,30 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16070
16217
|
const activeCheckoutStage = checkoutStages.find(
|
|
16071
16218
|
(stage) => stage.id === checkoutStage
|
|
16072
16219
|
);
|
|
16220
|
+
const shouldShowBypassOverlay = checkoutState?.bypassPlanSelection && checkoutStage === "plan" && !hasSkippedInitialPlan;
|
|
16073
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
|
+
),
|
|
16074
16244
|
/* @__PURE__ */ jsx22(ModalHeader, { bordered: true, children: /* @__PURE__ */ jsx22(
|
|
16075
16245
|
Flex,
|
|
16076
16246
|
{
|
|
@@ -16251,11 +16421,11 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16251
16421
|
};
|
|
16252
16422
|
|
|
16253
16423
|
// src/components/shared/payment-dialog/PaymentDialog.tsx
|
|
16254
|
-
import { useRef as
|
|
16424
|
+
import { useRef as useRef8 } from "react";
|
|
16255
16425
|
import { jsx as jsx23, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
16256
16426
|
var PaymentDialog = ({ top = 0 }) => {
|
|
16257
16427
|
const { t: t2 } = useTranslation();
|
|
16258
|
-
const modalRef =
|
|
16428
|
+
const modalRef = useRef8(null);
|
|
16259
16429
|
return /* @__PURE__ */ jsxs17(Modal2, { ref: modalRef, size: "md", top, children: [
|
|
16260
16430
|
/* @__PURE__ */ jsx23(ModalHeader, { bordered: true, children: /* @__PURE__ */ jsx23(Text, { $size: 18, children: t2("Edit payment method") }) }),
|
|
16261
16431
|
/* @__PURE__ */ jsx23(ModalContent, { children: /* @__PURE__ */ jsx23(Flex, { $position: "relative", $flexGrow: 1, $overflow: "auto", children: /* @__PURE__ */ jsx23(PaymentMethodDetails, {}) }) })
|
|
@@ -16269,7 +16439,7 @@ import {
|
|
|
16269
16439
|
useElements,
|
|
16270
16440
|
useStripe
|
|
16271
16441
|
} from "@stripe/react-stripe-js";
|
|
16272
|
-
import { useState as
|
|
16442
|
+
import { useState as useState12 } from "react";
|
|
16273
16443
|
|
|
16274
16444
|
// src/components/shared/payment-form/styles.ts
|
|
16275
16445
|
var Label = dt.label`
|
|
@@ -16331,12 +16501,12 @@ var PaymentForm = ({ onConfirm, financeData }) => {
|
|
|
16331
16501
|
const stripe = useStripe();
|
|
16332
16502
|
const elements = useElements();
|
|
16333
16503
|
const { data } = useEmbed();
|
|
16334
|
-
const [email, setEmail] =
|
|
16335
|
-
const [message, setMessage] =
|
|
16336
|
-
const [isLoading, setIsLoading] =
|
|
16337
|
-
const [isConfirmed, setIsConfirmed] =
|
|
16338
|
-
const [isPaymentComplete, setIsPaymentComplete] =
|
|
16339
|
-
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(() => {
|
|
16340
16510
|
const shouldCollectAddress = shouldCollectBillingAddress(
|
|
16341
16511
|
data?.checkoutSettings.collectAddress ?? false,
|
|
16342
16512
|
financeData
|
|
@@ -16465,7 +16635,6 @@ var PeriodToggle = ({
|
|
|
16465
16635
|
const yearly = yearlyBillingPrice?.price ?? 0;
|
|
16466
16636
|
return Math.round((monthly - yearly) / monthly * 1e4) / 100;
|
|
16467
16637
|
}
|
|
16468
|
-
return 0;
|
|
16469
16638
|
}, [selectedPlan]);
|
|
16470
16639
|
return /* @__PURE__ */ jsx25(
|
|
16471
16640
|
Flex,
|
|
@@ -16520,7 +16689,7 @@ var PeriodToggle = ({
|
|
|
16520
16689
|
},
|
|
16521
16690
|
option
|
|
16522
16691
|
);
|
|
16523
|
-
if (option === "year") {
|
|
16692
|
+
if (option === "year" && typeof savingsPercentage === "number") {
|
|
16524
16693
|
return /* @__PURE__ */ jsx25(
|
|
16525
16694
|
Tooltip,
|
|
16526
16695
|
{
|
|
@@ -16749,14 +16918,14 @@ var TieredPricingDetails = ({
|
|
|
16749
16918
|
};
|
|
16750
16919
|
|
|
16751
16920
|
// src/components/shared/unsubscribe-dialog/UnsubscribeDialog.tsx
|
|
16752
|
-
import { useMemo as useMemo14, useRef as
|
|
16921
|
+
import { useMemo as useMemo14, useRef as useRef9, useState as useState13 } from "react";
|
|
16753
16922
|
import { jsx as jsx28, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
16754
16923
|
var UnsubscribeDialog = ({ top = 0 }) => {
|
|
16755
16924
|
const { t: t2 } = useTranslation();
|
|
16756
16925
|
const { data, setCheckoutState } = useEmbed();
|
|
16757
|
-
const modalRef =
|
|
16758
|
-
const [error, setError] =
|
|
16759
|
-
const [isLoading, setIsLoading] =
|
|
16926
|
+
const modalRef = useRef9(null);
|
|
16927
|
+
const [error, setError] = useState13();
|
|
16928
|
+
const [isLoading, setIsLoading] = useState13(false);
|
|
16760
16929
|
const { planPeriod, currentPlan, currentAddOns, featureUsage, cancelDate } = useMemo14(() => {
|
|
16761
16930
|
const cancelDate2 = data?.subscription?.cancelAt || data?.upcomingInvoice?.dueDate;
|
|
16762
16931
|
return {
|
|
@@ -17036,9 +17205,9 @@ var StyledViewport = dt.div.withConfig({
|
|
|
17036
17205
|
import { Fragment as Fragment12, jsx as jsx32, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
17037
17206
|
var Viewport = forwardRef8(
|
|
17038
17207
|
({ children, portal, ...props }, ref) => {
|
|
17039
|
-
const portalRef =
|
|
17208
|
+
const portalRef = useRef10(portal || document.body);
|
|
17040
17209
|
const { data, layout, settings } = useEmbed();
|
|
17041
|
-
const [top, setTop] =
|
|
17210
|
+
const [top, setTop] = useState14(0);
|
|
17042
17211
|
const { canCheckout, isBadgeVisible } = useMemo15(() => {
|
|
17043
17212
|
return {
|
|
17044
17213
|
canCheckout: data?.capabilities?.checkout ?? true,
|
|
@@ -17069,12 +17238,12 @@ var Viewport = forwardRef8(
|
|
|
17069
17238
|
/* @__PURE__ */ jsx32(RenderLayout, { children }),
|
|
17070
17239
|
isBadgeVisible && /* @__PURE__ */ jsx32(Badge, {})
|
|
17071
17240
|
] }),
|
|
17072
|
-
canCheckout && layout === "checkout" &&
|
|
17073
|
-
layout === "unsubscribe" &&
|
|
17241
|
+
canCheckout && layout === "checkout" && createPortal3(/* @__PURE__ */ jsx32(CheckoutDialog, { top }), portal || document.body),
|
|
17242
|
+
layout === "unsubscribe" && createPortal3(
|
|
17074
17243
|
/* @__PURE__ */ jsx32(UnsubscribeDialog, { top }),
|
|
17075
17244
|
portal || document.body
|
|
17076
17245
|
),
|
|
17077
|
-
layout === "payment" &&
|
|
17246
|
+
layout === "payment" && createPortal3(/* @__PURE__ */ jsx32(PaymentDialog, { top }), portal || document.body)
|
|
17078
17247
|
] });
|
|
17079
17248
|
}
|
|
17080
17249
|
);
|
|
@@ -17141,7 +17310,7 @@ var ButtonElement = forwardRef9(({ children, className, ...rest }, ref) => {
|
|
|
17141
17310
|
ButtonElement.displayName = "Button";
|
|
17142
17311
|
|
|
17143
17312
|
// src/components/elements/included-features/IncludedFeatures.tsx
|
|
17144
|
-
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";
|
|
17145
17314
|
|
|
17146
17315
|
// src/components/elements/included-features/UsageDetails.tsx
|
|
17147
17316
|
import { Fragment as Fragment13, useMemo as useMemo16 } from "react";
|
|
@@ -17398,10 +17567,10 @@ var IncludedFeatures = forwardRef10(({ className, ...rest }, ref) => {
|
|
|
17398
17567
|
const props = resolveDesignProps2(rest);
|
|
17399
17568
|
const { t: t2 } = useTranslation();
|
|
17400
17569
|
const { data, settings } = useEmbed();
|
|
17401
|
-
const elementsRef =
|
|
17570
|
+
const elementsRef = useRef11([]);
|
|
17402
17571
|
const shouldWrapChildren = useWrapChildren(elementsRef);
|
|
17403
17572
|
const isLightBackground = useIsLightBackground();
|
|
17404
|
-
const [showCount, setShowCount] =
|
|
17573
|
+
const [showCount, setShowCount] = useState15(VISIBLE_ENTITLEMENT_COUNT);
|
|
17405
17574
|
const { plan, addOns, featureUsage } = useMemo17(() => {
|
|
17406
17575
|
const orderedFeatureUsage = props.visibleFeatures?.reduce(
|
|
17407
17576
|
(acc, id) => {
|
|
@@ -17536,7 +17705,7 @@ var IncludedFeatures = forwardRef10(({ className, ...rest }, ref) => {
|
|
|
17536
17705
|
IncludedFeatures.displayName = "IncludedFeatures";
|
|
17537
17706
|
|
|
17538
17707
|
// src/components/elements/invoices/Invoices.tsx
|
|
17539
|
-
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";
|
|
17540
17709
|
import { Fragment as Fragment15, jsx as jsx36, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
17541
17710
|
function resolveDesignProps3(props) {
|
|
17542
17711
|
return {
|
|
@@ -17575,10 +17744,10 @@ var Invoices = forwardRef11(({ className, data, ...rest }, ref) => {
|
|
|
17575
17744
|
const props = resolveDesignProps3(rest);
|
|
17576
17745
|
const { t: t2 } = useTranslation();
|
|
17577
17746
|
const { listInvoices, settings } = useEmbed();
|
|
17578
|
-
const [isLoading, setIsLoading] =
|
|
17579
|
-
const [error, setError] =
|
|
17580
|
-
const [invoices, setInvoices] =
|
|
17581
|
-
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);
|
|
17582
17751
|
const getInvoices = useCallback11(async () => {
|
|
17583
17752
|
try {
|
|
17584
17753
|
setError(void 0);
|
|
@@ -17598,10 +17767,10 @@ var Invoices = forwardRef11(({ className, data, ...rest }, ref) => {
|
|
|
17598
17767
|
(prev2) => prev2 !== props.limit.number ? props.limit.number : MAX_VISIBLE_INVOICE_COUNT
|
|
17599
17768
|
);
|
|
17600
17769
|
};
|
|
17601
|
-
|
|
17770
|
+
useEffect7(() => {
|
|
17602
17771
|
getInvoices();
|
|
17603
17772
|
}, [getInvoices]);
|
|
17604
|
-
|
|
17773
|
+
useEffect7(() => {
|
|
17605
17774
|
setInvoices(formatInvoices(data));
|
|
17606
17775
|
}, [data]);
|
|
17607
17776
|
if (invoices.length === 0) {
|
|
@@ -17681,7 +17850,7 @@ var Invoices = forwardRef11(({ className, data, ...rest }, ref) => {
|
|
|
17681
17850
|
Invoices.displayName = "Invoices";
|
|
17682
17851
|
|
|
17683
17852
|
// src/components/elements/metered-features/MeteredFeatures.tsx
|
|
17684
|
-
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";
|
|
17685
17854
|
|
|
17686
17855
|
// src/components/elements/metered-features/Meter.tsx
|
|
17687
17856
|
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
@@ -17883,7 +18052,7 @@ function resolveDesignProps4(props) {
|
|
|
17883
18052
|
}
|
|
17884
18053
|
var MeteredFeatures = forwardRef12(({ className, ...rest }, ref) => {
|
|
17885
18054
|
const props = resolveDesignProps4(rest);
|
|
17886
|
-
const elementsRef =
|
|
18055
|
+
const elementsRef = useRef12([]);
|
|
17887
18056
|
const shouldWrapChildren = useWrapChildren(elementsRef);
|
|
17888
18057
|
const { t: t2 } = useTranslation();
|
|
17889
18058
|
const { data, settings, setCheckoutState } = useEmbed();
|
|
@@ -17908,7 +18077,7 @@ var MeteredFeatures = forwardRef12(({ className, ...rest }, ref) => {
|
|
|
17908
18077
|
const creditGroups = groupCreditGrants(data?.creditGrants || [], {
|
|
17909
18078
|
groupBy: "credit"
|
|
17910
18079
|
});
|
|
17911
|
-
const [creditVisibility, setCreditVisibility] =
|
|
18080
|
+
const [creditVisibility, setCreditVisibility] = useState17(
|
|
17912
18081
|
creditGroups.map(({ id }) => ({ id, isExpanded: false }))
|
|
17913
18082
|
);
|
|
17914
18083
|
const toggleBalanceDetails = useCallback12((id) => {
|
|
@@ -18581,7 +18750,7 @@ var loadStripe = function loadStripe2() {
|
|
|
18581
18750
|
};
|
|
18582
18751
|
|
|
18583
18752
|
// src/components/elements/payment-method/PaymentMethodDetails.tsx
|
|
18584
|
-
import { useCallback as useCallback13, useEffect as
|
|
18753
|
+
import { useCallback as useCallback13, useEffect as useEffect8, useMemo as useMemo21, useState as useState18 } from "react";
|
|
18585
18754
|
import { Fragment as Fragment18, jsx as jsx42, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
18586
18755
|
var resolveDesignProps6 = () => {
|
|
18587
18756
|
return {
|
|
@@ -18622,13 +18791,13 @@ var PaymentMethodDetails = ({
|
|
|
18622
18791
|
data?.subscription
|
|
18623
18792
|
]);
|
|
18624
18793
|
const isLightBackground = useIsLightBackground();
|
|
18625
|
-
const [isLoading, setIsLoading] =
|
|
18626
|
-
const [error, setError] =
|
|
18627
|
-
const [showPaymentForm, setShowPaymentForm] =
|
|
18628
|
-
const [stripe, setStripe] =
|
|
18629
|
-
const [setupIntent, setSetupIntent] =
|
|
18630
|
-
const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] =
|
|
18631
|
-
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);
|
|
18632
18801
|
const { isConfirming: isConfirmingPayment } = usePaymentConfirmation({
|
|
18633
18802
|
stripe,
|
|
18634
18803
|
clientSecret: confirmPaymentIntentProps?.clientSecret,
|
|
@@ -18715,7 +18884,7 @@ var PaymentMethodDetails = ({
|
|
|
18715
18884
|
},
|
|
18716
18885
|
[t2, deletePaymentMethod]
|
|
18717
18886
|
);
|
|
18718
|
-
|
|
18887
|
+
useEffect8(() => {
|
|
18719
18888
|
if (!stripe && setupIntent) {
|
|
18720
18889
|
let publishableKey = setupIntent.publishableKey || setupIntent.schematicPublishableKey;
|
|
18721
18890
|
const stripeOptions = {};
|
|
@@ -18727,7 +18896,7 @@ var PaymentMethodDetails = ({
|
|
|
18727
18896
|
setStripe(stripePromise2);
|
|
18728
18897
|
}
|
|
18729
18898
|
}, [stripe, setupIntent]);
|
|
18730
|
-
|
|
18899
|
+
useEffect8(() => {
|
|
18731
18900
|
if (!setupIntent && (!currentPaymentMethod || showPaymentForm)) {
|
|
18732
18901
|
initializePaymentMethod();
|
|
18733
18902
|
}
|
|
@@ -19075,7 +19244,7 @@ var resolveDesignProps7 = (props) => {
|
|
|
19075
19244
|
var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) => {
|
|
19076
19245
|
const props = resolveDesignProps7(rest);
|
|
19077
19246
|
const { t: t2 } = useTranslation();
|
|
19078
|
-
const { data, settings,
|
|
19247
|
+
const { data, settings, setLayout } = useEmbed();
|
|
19079
19248
|
const isLightBackground = useIsLightBackground();
|
|
19080
19249
|
const trialEnd = useTrialEnd();
|
|
19081
19250
|
const {
|
|
@@ -19436,11 +19605,7 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
|
|
|
19436
19605
|
{
|
|
19437
19606
|
type: "button",
|
|
19438
19607
|
onClick: () => {
|
|
19439
|
-
|
|
19440
|
-
planId: currentPlan?.id,
|
|
19441
|
-
addOnId: void 0,
|
|
19442
|
-
usage: false
|
|
19443
|
-
});
|
|
19608
|
+
setLayout("checkout");
|
|
19444
19609
|
},
|
|
19445
19610
|
$size: props.callToAction.buttonSize,
|
|
19446
19611
|
$color: props.callToAction.buttonStyle,
|
|
@@ -19460,9 +19625,8 @@ import {
|
|
|
19460
19625
|
Fragment as Fragment25,
|
|
19461
19626
|
forwardRef as forwardRef15,
|
|
19462
19627
|
useCallback as useCallback14,
|
|
19463
|
-
useEffect as
|
|
19464
|
-
|
|
19465
|
-
useState as useState18
|
|
19628
|
+
useEffect as useEffect9,
|
|
19629
|
+
useState as useState19
|
|
19466
19630
|
} from "react";
|
|
19467
19631
|
|
|
19468
19632
|
// src/components/elements/pricing-table/AddOn.tsx
|
|
@@ -20280,30 +20444,14 @@ var PricingTable = forwardRef15(({ className, ...rest }, ref) => {
|
|
|
20280
20444
|
},
|
|
20281
20445
|
[]
|
|
20282
20446
|
);
|
|
20283
|
-
const
|
|
20284
|
-
|
|
20285
|
-
|
|
20286
|
-
currentPeriod: data?.company?.plan?.planPeriod || "month",
|
|
20287
|
-
currentAddOns: data?.company?.addOns || [],
|
|
20288
|
-
canCheckout: isStandalone2 ?? data?.capabilities?.checkout ?? true,
|
|
20289
|
-
isTrialSubscription: data?.company?.billingSubscription?.status === "trialing",
|
|
20290
|
-
willSubscriptionCancel: data?.company?.billingSubscription?.cancelAt,
|
|
20291
|
-
isStandalone: isStandalone2
|
|
20292
|
-
};
|
|
20293
|
-
}, [
|
|
20294
|
-
data?.capabilities?.checkout,
|
|
20295
|
-
data?.company?.addOns,
|
|
20296
|
-
data?.company?.billingSubscription?.cancelAt,
|
|
20297
|
-
data?.company?.billingSubscription?.status,
|
|
20298
|
-
data?.company?.plan?.planPeriod,
|
|
20299
|
-
data?.component
|
|
20300
|
-
]);
|
|
20301
|
-
const [selectedPeriod, setSelectedPeriod] = useState18(currentPeriod);
|
|
20447
|
+
const [selectedPeriod, setSelectedPeriod] = useState19(
|
|
20448
|
+
() => data?.company?.plan?.planPeriod || "month"
|
|
20449
|
+
);
|
|
20302
20450
|
const showPeriodToggle = rest.showPeriodToggle ?? data?.showPeriodToggle ?? true;
|
|
20303
20451
|
const { plans, addOns, periods } = useAvailablePlans(selectedPeriod, {
|
|
20304
20452
|
useSelectedPeriod: showPeriodToggle
|
|
20305
20453
|
});
|
|
20306
|
-
const [entitlementCounts, setEntitlementCounts] =
|
|
20454
|
+
const [entitlementCounts, setEntitlementCounts] = useState19(
|
|
20307
20455
|
() => plans.reduce(entitlementCountsReducer, {})
|
|
20308
20456
|
);
|
|
20309
20457
|
const handleToggleShowAll = (id) => {
|
|
@@ -20321,12 +20469,12 @@ var PricingTable = forwardRef15(({ className, ...rest }, ref) => {
|
|
|
20321
20469
|
return prev2;
|
|
20322
20470
|
});
|
|
20323
20471
|
};
|
|
20324
|
-
|
|
20325
|
-
if (
|
|
20472
|
+
useEffect9(() => {
|
|
20473
|
+
if (typeof data?.component === "undefined") {
|
|
20326
20474
|
hydratePublic();
|
|
20327
20475
|
}
|
|
20328
|
-
}, [
|
|
20329
|
-
|
|
20476
|
+
}, [data?.component, hydratePublic]);
|
|
20477
|
+
useEffect9(() => {
|
|
20330
20478
|
setEntitlementCounts(plans.reduce(entitlementCountsReducer, {}));
|
|
20331
20479
|
}, [plans]);
|
|
20332
20480
|
if (isPending) {
|
|
@@ -20342,12 +20490,13 @@ var PricingTable = forwardRef15(({ className, ...rest }, ref) => {
|
|
|
20342
20490
|
}
|
|
20343
20491
|
);
|
|
20344
20492
|
}
|
|
20493
|
+
const currentPlan = plans.find((plan) => plan.id === data?.company?.plan?.id);
|
|
20345
20494
|
const showCallToAction = typeof data?.component !== "undefined" || typeof rest.callToActionUrl === "string" || typeof rest.onCallToAction === "function";
|
|
20346
20495
|
const callToActionTarget = getCallToActionTarget(
|
|
20347
20496
|
rest.callToActionUrl,
|
|
20348
20497
|
rest.callToActionTarget
|
|
20349
20498
|
);
|
|
20350
|
-
const Wrapper =
|
|
20499
|
+
const Wrapper = typeof data?.component === "undefined" ? Container : Fragment25;
|
|
20351
20500
|
return /* @__PURE__ */ jsx49(Wrapper, { children: /* @__PURE__ */ jsxs38(
|
|
20352
20501
|
FussyChild,
|
|
20353
20502
|
{
|
|
@@ -20380,6 +20529,7 @@ var PricingTable = forwardRef15(({ className, ...rest }, ref) => {
|
|
|
20380
20529
|
{
|
|
20381
20530
|
options: periods,
|
|
20382
20531
|
selectedOption: selectedPeriod,
|
|
20532
|
+
selectedPlan: currentPlan,
|
|
20383
20533
|
onSelect: (period) => {
|
|
20384
20534
|
if (period !== selectedPeriod) {
|
|
20385
20535
|
setSelectedPeriod(period);
|
|
@@ -20492,7 +20642,7 @@ var TextElement = forwardRef16(({ children, className, ...rest }, ref) => {
|
|
|
20492
20642
|
TextElement.displayName = "Text";
|
|
20493
20643
|
|
|
20494
20644
|
// src/components/elements/unsubscribe-button/UnsubscribeButton.tsx
|
|
20495
|
-
import { forwardRef as forwardRef17, useMemo as
|
|
20645
|
+
import { forwardRef as forwardRef17, useMemo as useMemo26 } from "react";
|
|
20496
20646
|
import { jsx as jsx51 } from "react/jsx-runtime";
|
|
20497
20647
|
var buttonStyles = {
|
|
20498
20648
|
primary: {
|
|
@@ -20523,7 +20673,7 @@ var UnsubscribeButton = forwardRef17(({ children, className, ...rest }, ref) =>
|
|
|
20523
20673
|
const props = resolveDesignProps10(rest);
|
|
20524
20674
|
const { t: t2 } = useTranslation();
|
|
20525
20675
|
const { data, setLayout } = useEmbed();
|
|
20526
|
-
const hasActiveSubscription =
|
|
20676
|
+
const hasActiveSubscription = useMemo26(() => {
|
|
20527
20677
|
return data?.subscription && data.subscription.status !== "cancelled" && !data.subscription.cancelAt;
|
|
20528
20678
|
}, [data?.subscription]);
|
|
20529
20679
|
if (!hasActiveSubscription) {
|
|
@@ -20558,7 +20708,7 @@ var UnsubscribeButton = forwardRef17(({ children, className, ...rest }, ref) =>
|
|
|
20558
20708
|
UnsubscribeButton.displayName = "UnsubscribeButton";
|
|
20559
20709
|
|
|
20560
20710
|
// src/components/elements/upcoming-bill/UpcomingBill.tsx
|
|
20561
|
-
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";
|
|
20562
20712
|
import { jsx as jsx52, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
20563
20713
|
function resolveDesignProps11(props) {
|
|
20564
20714
|
return {
|
|
@@ -20583,11 +20733,11 @@ var UpcomingBill = forwardRef18(({ className, ...rest }, ref) => {
|
|
|
20583
20733
|
const { t: t2 } = useTranslation();
|
|
20584
20734
|
const { data, settings, debug, getUpcomingInvoice, getCustomerBalance } = useEmbed();
|
|
20585
20735
|
const isLightBackground = useIsLightBackground();
|
|
20586
|
-
const [isLoading, setIsLoading] =
|
|
20587
|
-
const [error, setError] =
|
|
20588
|
-
const [upcomingInvoice, setUpcomingInvoice] =
|
|
20589
|
-
const [balances, setBalances] =
|
|
20590
|
-
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(() => {
|
|
20591
20741
|
return (data?.subscription?.discounts || []).map((discount) => ({
|
|
20592
20742
|
couponId: discount.couponId,
|
|
20593
20743
|
customerFacingCode: discount.customerFacingCode || void 0,
|
|
@@ -20623,10 +20773,10 @@ var UpcomingBill = forwardRef18(({ className, ...rest }, ref) => {
|
|
|
20623
20773
|
debug("Failed to fetch customer balance.", err2);
|
|
20624
20774
|
}
|
|
20625
20775
|
}, [debug, getCustomerBalance]);
|
|
20626
|
-
|
|
20776
|
+
useEffect10(() => {
|
|
20627
20777
|
getInvoice();
|
|
20628
20778
|
}, [getInvoice]);
|
|
20629
|
-
|
|
20779
|
+
useEffect10(() => {
|
|
20630
20780
|
getBalances();
|
|
20631
20781
|
}, [getBalances]);
|
|
20632
20782
|
if (!data?.subscription || data.subscription.cancelAt) {
|
|
@@ -24938,7 +25088,7 @@ var { Inflate, inflate, inflateRaw, ungzip } = inflate_1$1;
|
|
|
24938
25088
|
var inflate_1 = inflate;
|
|
24939
25089
|
|
|
24940
25090
|
// src/components/embed/Embed.tsx
|
|
24941
|
-
import { useContext as useContext6, useEffect as
|
|
25091
|
+
import { useContext as useContext6, useEffect as useEffect11, useState as useState21 } from "react";
|
|
24942
25092
|
|
|
24943
25093
|
// src/components/embed/renderer.ts
|
|
24944
25094
|
import { createElement as createElement5 } from "react";
|
|
@@ -25054,7 +25204,7 @@ var Error2 = ({ message }) => {
|
|
|
25054
25204
|
);
|
|
25055
25205
|
};
|
|
25056
25206
|
var SchematicEmbed = ({ id, accessToken }) => {
|
|
25057
|
-
const [children, setChildren] =
|
|
25207
|
+
const [children, setChildren] = useState21(/* @__PURE__ */ jsx53(Loading, {}));
|
|
25058
25208
|
const theme = useContext6(et);
|
|
25059
25209
|
const {
|
|
25060
25210
|
data,
|
|
@@ -25066,17 +25216,17 @@ var SchematicEmbed = ({ id, accessToken }) => {
|
|
|
25066
25216
|
setAccessToken,
|
|
25067
25217
|
updateSettings
|
|
25068
25218
|
} = useEmbed();
|
|
25069
|
-
|
|
25219
|
+
useEffect11(() => {
|
|
25070
25220
|
if (accessToken) {
|
|
25071
25221
|
setAccessToken(accessToken);
|
|
25072
25222
|
}
|
|
25073
25223
|
}, [accessToken, setAccessToken]);
|
|
25074
|
-
|
|
25224
|
+
useEffect11(() => {
|
|
25075
25225
|
if (id && stale) {
|
|
25076
25226
|
hydrateComponent(id);
|
|
25077
25227
|
}
|
|
25078
25228
|
}, [id, hydrateComponent, stale]);
|
|
25079
|
-
|
|
25229
|
+
useEffect11(() => {
|
|
25080
25230
|
try {
|
|
25081
25231
|
if (data?.component?.ast) {
|
|
25082
25232
|
const nodes = [];
|