@schematichq/schematic-components 0.4.2 → 0.4.4-rc.1
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 +353 -171
- package/dist/schematic-components.d.ts +109 -2
- package/dist/schematic-components.esm.js +354 -172
- package/package.json +10 -11
|
@@ -3781,18 +3781,22 @@ function useAvailablePlans(activePeriod) {
|
|
|
3781
3781
|
}, [data.activePlans, data.activeAddOns]);
|
|
3782
3782
|
const getActivePlans = (0, import_react10.useCallback)(
|
|
3783
3783
|
(plans) => {
|
|
3784
|
-
const
|
|
3784
|
+
const customPlanExist = plans.some((plan) => plan.custom);
|
|
3785
|
+
let plansWithSelected = mode === "edit" ? plans.slice() : plans.filter(
|
|
3785
3786
|
(plan) => activePeriod === "month" && plan.monthlyPrice || activePeriod === "year" && plan.yearlyPrice
|
|
3786
|
-
)
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3787
|
+
);
|
|
3788
|
+
if (!customPlanExist) {
|
|
3789
|
+
plansWithSelected = plansWithSelected.sort((a2, b2) => {
|
|
3790
|
+
if (activePeriod === "year") {
|
|
3791
|
+
return (a2.yearlyPrice?.price ?? 0) - (b2.yearlyPrice?.price ?? 0);
|
|
3792
|
+
}
|
|
3793
|
+
if (activePeriod === "month") {
|
|
3794
|
+
return (a2.monthlyPrice?.price ?? 0) - (b2.monthlyPrice?.price ?? 0);
|
|
3795
|
+
}
|
|
3796
|
+
return 0;
|
|
3797
|
+
});
|
|
3798
|
+
}
|
|
3799
|
+
return plansWithSelected.map((plan) => ({ ...plan, isSelected: false }));
|
|
3796
3800
|
},
|
|
3797
3801
|
[activePeriod, mode]
|
|
3798
3802
|
);
|
|
@@ -11254,6 +11258,21 @@ function PlanEntitlementResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
11254
11258
|
};
|
|
11255
11259
|
}
|
|
11256
11260
|
|
|
11261
|
+
// src/api/models/CustomPlanConfig.ts
|
|
11262
|
+
function CustomPlanConfigFromJSON(json) {
|
|
11263
|
+
return CustomPlanConfigFromJSONTyped(json, false);
|
|
11264
|
+
}
|
|
11265
|
+
function CustomPlanConfigFromJSONTyped(json, ignoreDiscriminator) {
|
|
11266
|
+
if (json == null) {
|
|
11267
|
+
return json;
|
|
11268
|
+
}
|
|
11269
|
+
return {
|
|
11270
|
+
ctaText: json["cta_text"],
|
|
11271
|
+
ctaWebSite: json["cta_web_site"],
|
|
11272
|
+
priceText: json["price_text"]
|
|
11273
|
+
};
|
|
11274
|
+
}
|
|
11275
|
+
|
|
11257
11276
|
// src/api/models/CompanyPlanDetailResponseData.ts
|
|
11258
11277
|
function CompanyPlanDetailResponseDataFromJSON(json) {
|
|
11259
11278
|
return CompanyPlanDetailResponseDataFromJSONTyped(json, false);
|
|
@@ -11269,6 +11288,8 @@ function CompanyPlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
11269
11288
|
companyCount: json["company_count"],
|
|
11270
11289
|
createdAt: new Date(json["created_at"]),
|
|
11271
11290
|
current: json["current"],
|
|
11291
|
+
custom: json["custom"],
|
|
11292
|
+
customPlanConfig: json["custom_plan_config"] == null ? void 0 : CustomPlanConfigFromJSON(json["custom_plan_config"]),
|
|
11272
11293
|
description: json["description"],
|
|
11273
11294
|
entitlements: json["entitlements"].map(
|
|
11274
11295
|
PlanEntitlementResponseDataFromJSON
|
|
@@ -11278,6 +11299,7 @@ function CompanyPlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
11278
11299
|
),
|
|
11279
11300
|
icon: json["icon"],
|
|
11280
11301
|
id: json["id"],
|
|
11302
|
+
isCustom: json["is_custom"],
|
|
11281
11303
|
isDefault: json["is_default"],
|
|
11282
11304
|
isFree: json["is_free"],
|
|
11283
11305
|
isTrialable: json["is_trialable"],
|
|
@@ -11919,6 +11941,8 @@ var en_default = {
|
|
|
11919
11941
|
"Error retrieving plan details. Please try again in a moment.": "Error retrieving plan details. Please try again in a moment.",
|
|
11920
11942
|
"Error updating payment method. Please try again.": "Error updating payment method. Please try again.",
|
|
11921
11943
|
"Estimated bill.": "Estimated bill.",
|
|
11944
|
+
"Custom Plan Price": "Custom price",
|
|
11945
|
+
"Custom Plan CTA": "Talk to support",
|
|
11922
11946
|
"Everything in": "Everything in {{plan}}, plus",
|
|
11923
11947
|
Expired: "Expired",
|
|
11924
11948
|
"Expires in x months": "Expires in {{months}} mo",
|
|
@@ -12526,8 +12550,12 @@ function isEditorState(obj) {
|
|
|
12526
12550
|
});
|
|
12527
12551
|
}
|
|
12528
12552
|
function getEditorState(json) {
|
|
12529
|
-
|
|
12530
|
-
|
|
12553
|
+
if (json) {
|
|
12554
|
+
const obj = JSON.parse(json);
|
|
12555
|
+
if (isEditorState(obj)) {
|
|
12556
|
+
return obj;
|
|
12557
|
+
}
|
|
12558
|
+
}
|
|
12531
12559
|
}
|
|
12532
12560
|
function parseEditorState(data) {
|
|
12533
12561
|
const initialMap = {};
|
|
@@ -12707,7 +12735,7 @@ var EmbedProvider = ({
|
|
|
12707
12735
|
(0, import_react11.useEffect)(() => {
|
|
12708
12736
|
if (accessToken) {
|
|
12709
12737
|
const { headers = {} } = apiConfig ?? {};
|
|
12710
|
-
headers["X-Schematic-Components-Version"] = "0.4.
|
|
12738
|
+
headers["X-Schematic-Components-Version"] = "0.4.4-rc.1";
|
|
12711
12739
|
headers["X-Schematic-Session-ID"] = sessionIdRef.current;
|
|
12712
12740
|
const config = new Configuration({
|
|
12713
12741
|
...apiConfig,
|
|
@@ -12888,7 +12916,7 @@ function camelToHyphen(str) {
|
|
|
12888
12916
|
function formatNumber(num) {
|
|
12889
12917
|
return new Intl.NumberFormat("en-US").format(num);
|
|
12890
12918
|
}
|
|
12891
|
-
function formatCurrency(amount) {
|
|
12919
|
+
function formatCurrency(amount, currency = "USD") {
|
|
12892
12920
|
try {
|
|
12893
12921
|
const dollars = amount / 100;
|
|
12894
12922
|
const formatValue = (value, symbol) => {
|
|
@@ -12896,6 +12924,9 @@ function formatCurrency(amount) {
|
|
|
12896
12924
|
if (formatted.endsWith(".0")) {
|
|
12897
12925
|
formatted = formatted.slice(0, -2);
|
|
12898
12926
|
}
|
|
12927
|
+
if (currency.toUpperCase() !== "USD") {
|
|
12928
|
+
return `${currency.toUpperCase()}${formatted}${symbol}`;
|
|
12929
|
+
}
|
|
12899
12930
|
return `$${formatted}${symbol}`;
|
|
12900
12931
|
};
|
|
12901
12932
|
if (dollars >= 1e6) {
|
|
@@ -12905,14 +12936,14 @@ function formatCurrency(amount) {
|
|
|
12905
12936
|
} else {
|
|
12906
12937
|
return new Intl.NumberFormat("en-US", {
|
|
12907
12938
|
style: "currency",
|
|
12908
|
-
currency:
|
|
12939
|
+
currency: currency.toUpperCase()
|
|
12909
12940
|
}).format(dollars);
|
|
12910
12941
|
}
|
|
12911
12942
|
} catch (error) {
|
|
12912
12943
|
console.error("Error formatting currency", error);
|
|
12913
12944
|
return new Intl.NumberFormat("en-US", {
|
|
12914
12945
|
style: "currency",
|
|
12915
|
-
currency:
|
|
12946
|
+
currency: currency.toUpperCase()
|
|
12916
12947
|
}).format(amount / 100);
|
|
12917
12948
|
}
|
|
12918
12949
|
}
|
|
@@ -14439,6 +14470,7 @@ var Sidebar = ({
|
|
|
14439
14470
|
}
|
|
14440
14471
|
let total = 0;
|
|
14441
14472
|
const planPrice = (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price;
|
|
14473
|
+
const currency = (planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.currency;
|
|
14442
14474
|
if (planPrice) {
|
|
14443
14475
|
total += planPrice;
|
|
14444
14476
|
}
|
|
@@ -14452,7 +14484,7 @@ var Sidebar = ({
|
|
|
14452
14484
|
0
|
|
14453
14485
|
);
|
|
14454
14486
|
total += payInAdvanceCost;
|
|
14455
|
-
return formatCurrency(total);
|
|
14487
|
+
return formatCurrency(total, currency);
|
|
14456
14488
|
}, [selectedPlan, addOns, payInAdvanceEntitlements, planPeriod]);
|
|
14457
14489
|
const { amountOff, dueNow, newCharges, percentOff, periodStart, proration } = (0, import_react21.useMemo)(() => {
|
|
14458
14490
|
return {
|
|
@@ -14687,7 +14719,10 @@ var Sidebar = ({
|
|
|
14687
14719
|
$weight: theme.typography.text.fontWeight,
|
|
14688
14720
|
$color: theme.typography.text.color,
|
|
14689
14721
|
children: [
|
|
14690
|
-
formatCurrency(
|
|
14722
|
+
formatCurrency(
|
|
14723
|
+
data.company.plan.planPrice,
|
|
14724
|
+
data.company.billingSubscription?.currency
|
|
14725
|
+
),
|
|
14691
14726
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("sub", { children: [
|
|
14692
14727
|
"/",
|
|
14693
14728
|
shortenPeriod(
|
|
@@ -14747,7 +14782,8 @@ var Sidebar = ({
|
|
|
14747
14782
|
$color: theme.typography.text.color,
|
|
14748
14783
|
children: [
|
|
14749
14784
|
formatCurrency(
|
|
14750
|
-
(planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
|
|
14785
|
+
(planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0,
|
|
14786
|
+
(planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.currency
|
|
14751
14787
|
),
|
|
14752
14788
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("sub", { children: [
|
|
14753
14789
|
"/",
|
|
@@ -14810,14 +14846,20 @@ var Sidebar = ({
|
|
|
14810
14846
|
$color: theme.typography.text.color,
|
|
14811
14847
|
children: [
|
|
14812
14848
|
entitlement.priceBehavior === "pay_in_advance" && typeof price === "number" && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
14813
|
-
formatCurrency(
|
|
14849
|
+
formatCurrency(
|
|
14850
|
+
price * quantity,
|
|
14851
|
+
(planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
|
|
14852
|
+
),
|
|
14814
14853
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("sub", { children: [
|
|
14815
14854
|
"/",
|
|
14816
14855
|
shortenPeriod(planPeriod)
|
|
14817
14856
|
] })
|
|
14818
14857
|
] }),
|
|
14819
14858
|
entitlement.priceBehavior === "pay_as_you_go" && typeof price === "number" && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
14820
|
-
formatCurrency(
|
|
14859
|
+
formatCurrency(
|
|
14860
|
+
price,
|
|
14861
|
+
(planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
|
|
14862
|
+
),
|
|
14821
14863
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("sub", { children: [
|
|
14822
14864
|
"/",
|
|
14823
14865
|
(0, import_pluralize.default)(
|
|
@@ -14877,7 +14919,8 @@ var Sidebar = ({
|
|
|
14877
14919
|
$color: theme.typography.text.color,
|
|
14878
14920
|
children: [
|
|
14879
14921
|
formatCurrency(
|
|
14880
|
-
((planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * previous.quantity
|
|
14922
|
+
((planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * previous.quantity,
|
|
14923
|
+
(planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
|
|
14881
14924
|
),
|
|
14882
14925
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("sub", { children: [
|
|
14883
14926
|
"/",
|
|
@@ -14919,7 +14962,8 @@ var Sidebar = ({
|
|
|
14919
14962
|
$color: theme.typography.text.color,
|
|
14920
14963
|
children: [
|
|
14921
14964
|
formatCurrency(
|
|
14922
|
-
((planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * next2.quantity
|
|
14965
|
+
((planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * next2.quantity,
|
|
14966
|
+
(planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
|
|
14923
14967
|
),
|
|
14924
14968
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("sub", { children: [
|
|
14925
14969
|
"/",
|
|
@@ -14973,14 +15017,20 @@ var Sidebar = ({
|
|
|
14973
15017
|
$color: theme.typography.text.color,
|
|
14974
15018
|
children: [
|
|
14975
15019
|
entitlement.priceBehavior === "pay_in_advance" && typeof price === "number" && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
14976
|
-
formatCurrency(
|
|
15020
|
+
formatCurrency(
|
|
15021
|
+
price * quantity,
|
|
15022
|
+
(planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
|
|
15023
|
+
),
|
|
14977
15024
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("sub", { children: [
|
|
14978
15025
|
"/",
|
|
14979
15026
|
shortenPeriod(planPeriod)
|
|
14980
15027
|
] })
|
|
14981
15028
|
] }),
|
|
14982
15029
|
entitlement.priceBehavior === "pay_as_you_go" && typeof price === "number" && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
14983
|
-
formatCurrency(
|
|
15030
|
+
formatCurrency(
|
|
15031
|
+
price,
|
|
15032
|
+
(planPeriod === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
|
|
15033
|
+
),
|
|
14984
15034
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("sub", { children: [
|
|
14985
15035
|
"/",
|
|
14986
15036
|
(0, import_pluralize.default)(
|
|
@@ -15041,7 +15091,8 @@ var Sidebar = ({
|
|
|
15041
15091
|
children: [
|
|
15042
15092
|
"-",
|
|
15043
15093
|
formatCurrency(
|
|
15044
|
-
(planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0
|
|
15094
|
+
(planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.price ?? 0,
|
|
15095
|
+
(planPeriod === "month" ? selectedPlan.monthlyPrice : selectedPlan.yearlyPrice)?.currency
|
|
15045
15096
|
),
|
|
15046
15097
|
"/",
|
|
15047
15098
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("sub", { children: shortenPeriod(planPeriod) })
|
|
@@ -15091,7 +15142,10 @@ var Sidebar = ({
|
|
|
15091
15142
|
$weight: theme.typography.text.fontWeight,
|
|
15092
15143
|
$color: theme.typography.text.color,
|
|
15093
15144
|
children: [
|
|
15094
|
-
formatCurrency(
|
|
15145
|
+
formatCurrency(
|
|
15146
|
+
addOn.planPrice,
|
|
15147
|
+
(planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
|
|
15148
|
+
),
|
|
15095
15149
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("sub", { children: [
|
|
15096
15150
|
"/",
|
|
15097
15151
|
shortenPeriod(addOn.planPeriod)
|
|
@@ -15178,7 +15232,10 @@ var Sidebar = ({
|
|
|
15178
15232
|
$size: theme.typography.text.fontSize,
|
|
15179
15233
|
$weight: theme.typography.text.fontWeight,
|
|
15180
15234
|
$color: theme.typography.text.color,
|
|
15181
|
-
children: formatCurrency(
|
|
15235
|
+
children: formatCurrency(
|
|
15236
|
+
proration,
|
|
15237
|
+
(planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
|
|
15238
|
+
)
|
|
15182
15239
|
}
|
|
15183
15240
|
) })
|
|
15184
15241
|
]
|
|
@@ -15282,7 +15339,10 @@ var Sidebar = ({
|
|
|
15282
15339
|
$size: theme.typography.text.fontSize,
|
|
15283
15340
|
$weight: theme.typography.text.fontWeight,
|
|
15284
15341
|
$color: theme.typography.text.color,
|
|
15285
|
-
children: formatCurrency(
|
|
15342
|
+
children: formatCurrency(
|
|
15343
|
+
newCharges / 100 * percentOff,
|
|
15344
|
+
(planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
|
|
15345
|
+
)
|
|
15286
15346
|
}
|
|
15287
15347
|
) })
|
|
15288
15348
|
]
|
|
@@ -15303,7 +15363,10 @@ var Sidebar = ({
|
|
|
15303
15363
|
$weight: theme.typography.text.fontWeight,
|
|
15304
15364
|
$color: theme.typography.text.color,
|
|
15305
15365
|
children: t2("X off", {
|
|
15306
|
-
amount: formatCurrency(
|
|
15366
|
+
amount: formatCurrency(
|
|
15367
|
+
Math.abs(amountOff),
|
|
15368
|
+
(planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
|
|
15369
|
+
)
|
|
15307
15370
|
})
|
|
15308
15371
|
}
|
|
15309
15372
|
) }),
|
|
@@ -15316,7 +15379,10 @@ var Sidebar = ({
|
|
|
15316
15379
|
$color: theme.typography.text.color,
|
|
15317
15380
|
children: [
|
|
15318
15381
|
"-",
|
|
15319
|
-
formatCurrency(
|
|
15382
|
+
formatCurrency(
|
|
15383
|
+
Math.abs(amountOff),
|
|
15384
|
+
(planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
|
|
15385
|
+
)
|
|
15320
15386
|
]
|
|
15321
15387
|
}
|
|
15322
15388
|
) })
|
|
@@ -15389,7 +15455,10 @@ var Sidebar = ({
|
|
|
15389
15455
|
$size: theme.typography.text.fontSize,
|
|
15390
15456
|
$weight: theme.typography.text.fontWeight,
|
|
15391
15457
|
$color: theme.typography.text.color,
|
|
15392
|
-
children: formatCurrency(
|
|
15458
|
+
children: formatCurrency(
|
|
15459
|
+
Math.max(0, dueNow),
|
|
15460
|
+
(planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
|
|
15461
|
+
)
|
|
15393
15462
|
}
|
|
15394
15463
|
) })
|
|
15395
15464
|
]
|
|
@@ -15416,7 +15485,10 @@ var Sidebar = ({
|
|
|
15416
15485
|
$size: theme.typography.text.fontSize,
|
|
15417
15486
|
$weight: theme.typography.text.fontWeight,
|
|
15418
15487
|
$color: theme.typography.text.color,
|
|
15419
|
-
children: formatCurrency(
|
|
15488
|
+
children: formatCurrency(
|
|
15489
|
+
Math.abs(dueNow),
|
|
15490
|
+
(planPeriod === "month" ? selectedPlan?.monthlyPrice : selectedPlan?.yearlyPrice)?.currency
|
|
15491
|
+
)
|
|
15420
15492
|
}
|
|
15421
15493
|
) })
|
|
15422
15494
|
] }),
|
|
@@ -15470,6 +15542,16 @@ var Sidebar = ({
|
|
|
15470
15542
|
// src/components/shared/checkout-dialog/Plan.tsx
|
|
15471
15543
|
var import_react22 = require("react");
|
|
15472
15544
|
var import_pluralize2 = __toESM(require_pluralize());
|
|
15545
|
+
|
|
15546
|
+
// src/components/elements/pricing-table/styles.ts
|
|
15547
|
+
var ButtonLink = dt.a`
|
|
15548
|
+
display: flex;
|
|
15549
|
+
justify-content: center;
|
|
15550
|
+
align-items: center;
|
|
15551
|
+
flex-grow: 1;
|
|
15552
|
+
`;
|
|
15553
|
+
|
|
15554
|
+
// src/components/shared/checkout-dialog/Plan.tsx
|
|
15473
15555
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
15474
15556
|
var Plan = ({
|
|
15475
15557
|
isLoading,
|
|
@@ -15576,12 +15658,13 @@ var Plan = ({
|
|
|
15576
15658
|
$size: theme.typography.heading2.fontSize,
|
|
15577
15659
|
$weight: theme.typography.heading2.fontWeight,
|
|
15578
15660
|
$color: theme.typography.heading2.color,
|
|
15579
|
-
children: formatCurrency(
|
|
15580
|
-
(period === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.price ?? 0
|
|
15661
|
+
children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig?.priceText : t2("Custom Plan Price") : formatCurrency(
|
|
15662
|
+
(period === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.price ?? 0,
|
|
15663
|
+
(period === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.currency
|
|
15581
15664
|
)
|
|
15582
15665
|
}
|
|
15583
15666
|
),
|
|
15584
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
15667
|
+
!plan.custom && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
15585
15668
|
Text,
|
|
15586
15669
|
{
|
|
15587
15670
|
$font: theme.typography.heading2.fontFamily,
|
|
@@ -15642,6 +15725,7 @@ var Plan = ({
|
|
|
15642
15725
|
}[entitlement.metricPeriod];
|
|
15643
15726
|
}
|
|
15644
15727
|
const price = (period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price;
|
|
15728
|
+
const currency = (period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency;
|
|
15645
15729
|
if (entitlement.priceBehavior && typeof price !== "number") {
|
|
15646
15730
|
return acc;
|
|
15647
15731
|
}
|
|
@@ -15673,7 +15757,7 @@ var Plan = ({
|
|
|
15673
15757
|
$weight: theme.typography.text.fontWeight,
|
|
15674
15758
|
$color: theme.typography.text.color,
|
|
15675
15759
|
children: typeof price !== "undefined" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
15676
|
-
formatCurrency(price),
|
|
15760
|
+
formatCurrency(price, currency),
|
|
15677
15761
|
" ",
|
|
15678
15762
|
t2("per"),
|
|
15679
15763
|
" ",
|
|
@@ -15776,13 +15860,25 @@ var Plan = ({
|
|
|
15776
15860
|
EmbedButton,
|
|
15777
15861
|
{
|
|
15778
15862
|
disabled: isLoading || !plan.valid,
|
|
15779
|
-
|
|
15780
|
-
|
|
15863
|
+
...{
|
|
15864
|
+
onClick: () => {
|
|
15865
|
+
if (plan.custom) {
|
|
15866
|
+
return;
|
|
15867
|
+
}
|
|
15868
|
+
selectPlan({ plan });
|
|
15869
|
+
}
|
|
15781
15870
|
},
|
|
15782
15871
|
$size: "sm",
|
|
15783
15872
|
$color: "primary",
|
|
15784
15873
|
$variant: plan.current ? "outline" : "filled",
|
|
15785
|
-
children:
|
|
15874
|
+
children: plan.custom ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
15875
|
+
ButtonLink,
|
|
15876
|
+
{
|
|
15877
|
+
href: plan.customPlanConfig?.ctaWebSite ?? "#",
|
|
15878
|
+
target: "_blank",
|
|
15879
|
+
children: plan.customPlanConfig?.ctaText ?? t2("Custom Plan CTA")
|
|
15880
|
+
}
|
|
15881
|
+
) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
15786
15882
|
Tooltip,
|
|
15787
15883
|
{
|
|
15788
15884
|
trigger: t2("Over usage limit"),
|
|
@@ -15863,7 +15959,8 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
|
|
|
15863
15959
|
$weight: theme.typography.heading2.fontWeight,
|
|
15864
15960
|
$color: theme.typography.heading2.color,
|
|
15865
15961
|
children: formatCurrency(
|
|
15866
|
-
(period === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.price ?? 0
|
|
15962
|
+
(period === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.price ?? 0,
|
|
15963
|
+
(period === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.currency
|
|
15867
15964
|
)
|
|
15868
15965
|
}
|
|
15869
15966
|
),
|
|
@@ -16064,7 +16161,8 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
|
|
|
16064
16161
|
$color: theme.typography.text.color,
|
|
16065
16162
|
children: [
|
|
16066
16163
|
formatCurrency(
|
|
16067
|
-
((period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * quantity
|
|
16164
|
+
((period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0) * quantity,
|
|
16165
|
+
(period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
|
|
16068
16166
|
),
|
|
16069
16167
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("sub", { children: [
|
|
16070
16168
|
"/",
|
|
@@ -16082,7 +16180,8 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
|
|
|
16082
16180
|
$color: unitPriceColor,
|
|
16083
16181
|
children: [
|
|
16084
16182
|
formatCurrency(
|
|
16085
|
-
(period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0
|
|
16183
|
+
(period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0,
|
|
16184
|
+
(period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
|
|
16086
16185
|
),
|
|
16087
16186
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("sub", { children: [
|
|
16088
16187
|
"/",
|
|
@@ -16115,14 +16214,19 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
|
|
|
16115
16214
|
var import_react23 = require("react");
|
|
16116
16215
|
|
|
16117
16216
|
// node_modules/@stripe/stripe-js/dist/index.mjs
|
|
16118
|
-
var
|
|
16217
|
+
var ORIGIN = "https://js.stripe.com";
|
|
16218
|
+
var STRIPE_JS_URL = "".concat(ORIGIN, "/v3");
|
|
16119
16219
|
var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
|
|
16220
|
+
var STRIPE_JS_URL_REGEX = /^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;
|
|
16120
16221
|
var EXISTING_SCRIPT_MESSAGE = "loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";
|
|
16222
|
+
var isStripeJSURL = function isStripeJSURL2(url) {
|
|
16223
|
+
return V3_URL_REGEX.test(url) || STRIPE_JS_URL_REGEX.test(url);
|
|
16224
|
+
};
|
|
16121
16225
|
var findScript = function findScript2() {
|
|
16122
|
-
var scripts = document.querySelectorAll('script[src^="'.concat(
|
|
16226
|
+
var scripts = document.querySelectorAll('script[src^="'.concat(ORIGIN, '"]'));
|
|
16123
16227
|
for (var i2 = 0; i2 < scripts.length; i2++) {
|
|
16124
16228
|
var script = scripts[i2];
|
|
16125
|
-
if (!
|
|
16229
|
+
if (!isStripeJSURL(script.src)) {
|
|
16126
16230
|
continue;
|
|
16127
16231
|
}
|
|
16128
16232
|
return script;
|
|
@@ -16132,7 +16236,7 @@ var findScript = function findScript2() {
|
|
|
16132
16236
|
var injectScript = function injectScript2(params) {
|
|
16133
16237
|
var queryString = params && !params.advancedFraudSignals ? "?advancedFraudSignals=false" : "";
|
|
16134
16238
|
var script = document.createElement("script");
|
|
16135
|
-
script.src = "".concat(
|
|
16239
|
+
script.src = "".concat(STRIPE_JS_URL).concat(queryString);
|
|
16136
16240
|
var headOrBody = document.head || document.body;
|
|
16137
16241
|
if (!headOrBody) {
|
|
16138
16242
|
throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");
|
|
@@ -16146,7 +16250,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
|
16146
16250
|
}
|
|
16147
16251
|
stripe._registerWrapper({
|
|
16148
16252
|
name: "stripe-js",
|
|
16149
|
-
version: "5.
|
|
16253
|
+
version: "5.7.0",
|
|
16150
16254
|
startTime
|
|
16151
16255
|
});
|
|
16152
16256
|
};
|
|
@@ -16428,12 +16532,6 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16428
16532
|
const modalRef = (0, import_react24.useRef)(null);
|
|
16429
16533
|
const contentRef = (0, import_react24.useRef)(null);
|
|
16430
16534
|
const checkoutRef = (0, import_react24.useRef)(null);
|
|
16431
|
-
const [checkoutStage, setCheckoutStage] = (0, import_react24.useState)(
|
|
16432
|
-
() => selected.addOnId ? "addons" : selected.usage ? "usage" : "plan"
|
|
16433
|
-
);
|
|
16434
|
-
const [planPeriod, setPlanPeriod] = (0, import_react24.useState)(
|
|
16435
|
-
selected.period || data.company?.plan?.planPeriod || "month"
|
|
16436
|
-
);
|
|
16437
16535
|
const [charges, setCharges] = (0, import_react24.useState)();
|
|
16438
16536
|
const [paymentMethodId, setPaymentMethodId] = (0, import_react24.useState)();
|
|
16439
16537
|
const [isLoading, setIsLoading] = (0, import_react24.useState)(false);
|
|
@@ -16442,13 +16540,18 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16442
16540
|
!data.subscription?.paymentMethod
|
|
16443
16541
|
);
|
|
16444
16542
|
const [promoCode, setPromoCode] = (0, import_react24.useState)();
|
|
16543
|
+
const [planPeriod, setPlanPeriod] = (0, import_react24.useState)(
|
|
16544
|
+
selected.period || data.company?.plan?.planPeriod || "month"
|
|
16545
|
+
);
|
|
16445
16546
|
const {
|
|
16446
16547
|
plans: availablePlans,
|
|
16447
16548
|
addOns: availableAddOns,
|
|
16448
16549
|
periods: availablePeriods
|
|
16449
16550
|
} = useAvailablePlans(planPeriod);
|
|
16450
16551
|
const [selectedPlan, setSelectedPlan] = (0, import_react24.useState)(
|
|
16451
|
-
() => availablePlans.find(
|
|
16552
|
+
() => availablePlans.find(
|
|
16553
|
+
(plan) => selected.planId ? plan.id === selected.planId : plan.current
|
|
16554
|
+
)
|
|
16452
16555
|
);
|
|
16453
16556
|
const currentAddOns = data.company?.addOns || [];
|
|
16454
16557
|
const [addOns, setAddOns] = (0, import_react24.useState)(
|
|
@@ -16554,51 +16657,25 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16554
16657
|
selectedPlan?.companyCanTrial,
|
|
16555
16658
|
requiresPayment
|
|
16556
16659
|
]);
|
|
16660
|
+
const [checkoutStage, setCheckoutStage] = (0, import_react24.useState)(() => {
|
|
16661
|
+
if (selected.addOnId) {
|
|
16662
|
+
return "addons";
|
|
16663
|
+
}
|
|
16664
|
+
if (selected.usage) {
|
|
16665
|
+
return "usage";
|
|
16666
|
+
}
|
|
16667
|
+
if (selected.planId !== currentPlan?.id) {
|
|
16668
|
+
return checkoutStages.some((stage) => stage.id === "usage") ? "usage" : checkoutStages.some((stage) => stage.id === "addons") ? "addons" : "plan";
|
|
16669
|
+
}
|
|
16670
|
+
return "plan";
|
|
16671
|
+
});
|
|
16557
16672
|
const isLightBackground = useIsLightBackground();
|
|
16558
|
-
const
|
|
16559
|
-
(
|
|
16560
|
-
const
|
|
16561
|
-
|
|
16562
|
-
|
|
16563
|
-
)
|
|
16564
|
-
setSelectedPlan(updatedPlan);
|
|
16565
|
-
setUsageBasedEntitlements(entitlements);
|
|
16566
|
-
},
|
|
16567
|
-
[createActiveUsageBasedEntitlementsReducer]
|
|
16568
|
-
);
|
|
16569
|
-
const toggleAddOn = (id) => {
|
|
16570
|
-
setAddOns(
|
|
16571
|
-
(prev2) => prev2.map((addOn) => ({
|
|
16572
|
-
...addOn,
|
|
16573
|
-
...addOn.id === id && { isSelected: !addOn.isSelected }
|
|
16574
|
-
}))
|
|
16575
|
-
);
|
|
16576
|
-
};
|
|
16577
|
-
const changePlanPeriod = (0, import_react24.useCallback)(
|
|
16578
|
-
(period) => {
|
|
16579
|
-
if (selectedPlan) {
|
|
16580
|
-
selectPlan(selectedPlan, period);
|
|
16581
|
-
}
|
|
16582
|
-
setPlanPeriod(period);
|
|
16583
|
-
},
|
|
16584
|
-
[selectedPlan, selectPlan, setPlanPeriod]
|
|
16585
|
-
);
|
|
16586
|
-
const updateUsageBasedEntitlementQuantity = (id, updatedQuantity) => {
|
|
16587
|
-
setUsageBasedEntitlements(
|
|
16588
|
-
(prev2) => prev2.map(
|
|
16589
|
-
({ entitlement, allocation, quantity, usage }) => entitlement.id === id ? {
|
|
16590
|
-
entitlement,
|
|
16591
|
-
allocation,
|
|
16592
|
-
quantity: updatedQuantity,
|
|
16593
|
-
usage
|
|
16594
|
-
} : { entitlement, allocation, quantity, usage }
|
|
16595
|
-
)
|
|
16596
|
-
);
|
|
16597
|
-
};
|
|
16598
|
-
(0, import_react24.useEffect)(() => {
|
|
16599
|
-
async function previewCheckout() {
|
|
16600
|
-
const planPriceId = planPeriod === "month" ? selectedPlan?.monthlyPrice?.id : selectedPlan?.yearlyPrice?.id;
|
|
16601
|
-
if (!api || !selectedPlan || !planPriceId) {
|
|
16673
|
+
const previewCheckout = (0, import_react24.useCallback)(
|
|
16674
|
+
async (updates) => {
|
|
16675
|
+
const period = updates.period || planPeriod;
|
|
16676
|
+
const plan = updates.plan || selectedPlan;
|
|
16677
|
+
const planPriceId = period === "month" ? plan?.monthlyPrice?.id : plan?.yearlyPrice?.id;
|
|
16678
|
+
if (!api || !plan || !planPriceId) {
|
|
16602
16679
|
return;
|
|
16603
16680
|
}
|
|
16604
16681
|
setError(void 0);
|
|
@@ -16607,23 +16684,26 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16607
16684
|
try {
|
|
16608
16685
|
const { data: data2 } = await api.previewCheckout({
|
|
16609
16686
|
changeSubscriptionRequestBody: {
|
|
16610
|
-
newPlanId:
|
|
16687
|
+
newPlanId: plan.id,
|
|
16611
16688
|
newPriceId: planPriceId,
|
|
16612
|
-
addOnIds: addOns.reduce(
|
|
16613
|
-
|
|
16614
|
-
|
|
16615
|
-
|
|
16616
|
-
|
|
16617
|
-
|
|
16618
|
-
|
|
16619
|
-
|
|
16689
|
+
addOnIds: (updates.addOns || addOns).reduce(
|
|
16690
|
+
(acc, addOn) => {
|
|
16691
|
+
if (addOn.isSelected) {
|
|
16692
|
+
const addOnPriceId = (period === "month" ? addOn?.monthlyPrice : addOn?.yearlyPrice)?.id;
|
|
16693
|
+
if (addOnPriceId) {
|
|
16694
|
+
acc.push({
|
|
16695
|
+
addOnId: addOn.id,
|
|
16696
|
+
priceId: addOnPriceId
|
|
16697
|
+
});
|
|
16698
|
+
}
|
|
16620
16699
|
}
|
|
16621
|
-
|
|
16622
|
-
|
|
16623
|
-
|
|
16624
|
-
|
|
16700
|
+
return acc;
|
|
16701
|
+
},
|
|
16702
|
+
[]
|
|
16703
|
+
),
|
|
16704
|
+
payInAdvance: (updates.payInAdvanceEntitlements || payInAdvanceEntitlements).reduce(
|
|
16625
16705
|
(acc, { entitlement, quantity }) => {
|
|
16626
|
-
const priceId = (
|
|
16706
|
+
const priceId = (period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.priceId;
|
|
16627
16707
|
if (priceId) {
|
|
16628
16708
|
acc.push({
|
|
16629
16709
|
priceId,
|
|
@@ -16634,7 +16714,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16634
16714
|
},
|
|
16635
16715
|
[]
|
|
16636
16716
|
),
|
|
16637
|
-
promoCode
|
|
16717
|
+
promoCode: updates.promoCode || promoCode
|
|
16638
16718
|
}
|
|
16639
16719
|
});
|
|
16640
16720
|
setCharges(data2);
|
|
@@ -16653,19 +16733,88 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
16653
16733
|
} finally {
|
|
16654
16734
|
setIsLoading(false);
|
|
16655
16735
|
}
|
|
16656
|
-
}
|
|
16657
|
-
|
|
16658
|
-
|
|
16659
|
-
|
|
16660
|
-
|
|
16661
|
-
|
|
16662
|
-
|
|
16663
|
-
|
|
16664
|
-
|
|
16665
|
-
|
|
16666
|
-
|
|
16736
|
+
},
|
|
16737
|
+
[
|
|
16738
|
+
t2,
|
|
16739
|
+
api,
|
|
16740
|
+
planPeriod,
|
|
16741
|
+
selectedPlan,
|
|
16742
|
+
addOns,
|
|
16743
|
+
payInAdvanceEntitlements,
|
|
16744
|
+
promoCode
|
|
16745
|
+
]
|
|
16746
|
+
);
|
|
16747
|
+
const selectPlan = (0, import_react24.useCallback)(
|
|
16748
|
+
(updates) => {
|
|
16749
|
+
const plan = updates.plan || selectedPlan;
|
|
16750
|
+
if (!plan) {
|
|
16751
|
+
return;
|
|
16752
|
+
}
|
|
16753
|
+
const period = updates.period || planPeriod;
|
|
16754
|
+
const entitlements = plan.entitlements.reduce(
|
|
16755
|
+
createActiveUsageBasedEntitlementsReducer(period),
|
|
16756
|
+
[]
|
|
16757
|
+
);
|
|
16758
|
+
if (updates.plan) {
|
|
16759
|
+
setSelectedPlan(plan);
|
|
16760
|
+
setUsageBasedEntitlements(entitlements);
|
|
16761
|
+
}
|
|
16762
|
+
previewCheckout({
|
|
16763
|
+
period,
|
|
16764
|
+
plan: updates.plan,
|
|
16765
|
+
payInAdvanceEntitlements: entitlements.filter(
|
|
16766
|
+
({ entitlement }) => entitlement.priceBehavior === "pay_in_advance"
|
|
16767
|
+
)
|
|
16768
|
+
});
|
|
16769
|
+
},
|
|
16770
|
+
[
|
|
16771
|
+
planPeriod,
|
|
16772
|
+
selectedPlan,
|
|
16773
|
+
createActiveUsageBasedEntitlementsReducer,
|
|
16774
|
+
previewCheckout
|
|
16775
|
+
]
|
|
16776
|
+
);
|
|
16777
|
+
const changePlanPeriod = (0, import_react24.useCallback)(
|
|
16778
|
+
(period) => {
|
|
16779
|
+
setPlanPeriod(period);
|
|
16780
|
+
previewCheckout({ period });
|
|
16781
|
+
},
|
|
16782
|
+
[setPlanPeriod, previewCheckout]
|
|
16783
|
+
);
|
|
16784
|
+
const toggleAddOn = (id) => {
|
|
16785
|
+
setAddOns((prev2) => {
|
|
16786
|
+
const updated = prev2.map((addOn) => ({
|
|
16787
|
+
...addOn,
|
|
16788
|
+
...addOn.id === id && { isSelected: !addOn.isSelected }
|
|
16789
|
+
}));
|
|
16790
|
+
previewCheckout({ addOns: updated });
|
|
16791
|
+
return updated;
|
|
16792
|
+
});
|
|
16793
|
+
};
|
|
16794
|
+
const updateUsageBasedEntitlementQuantity = (0, import_react24.useCallback)(
|
|
16795
|
+
(id, updatedQuantity) => {
|
|
16796
|
+
setUsageBasedEntitlements((prev2) => {
|
|
16797
|
+
const updated = prev2.map(
|
|
16798
|
+
({ entitlement, allocation, quantity, usage }) => entitlement.id === id ? {
|
|
16799
|
+
entitlement,
|
|
16800
|
+
allocation,
|
|
16801
|
+
quantity: updatedQuantity,
|
|
16802
|
+
usage
|
|
16803
|
+
} : { entitlement, allocation, quantity, usage }
|
|
16804
|
+
);
|
|
16805
|
+
previewCheckout({
|
|
16806
|
+
payInAdvanceEntitlements: updated.filter(
|
|
16807
|
+
({ entitlement }) => entitlement.priceBehavior === "pay_in_advance"
|
|
16808
|
+
)
|
|
16809
|
+
});
|
|
16810
|
+
return updated;
|
|
16811
|
+
});
|
|
16812
|
+
},
|
|
16813
|
+
[previewCheckout]
|
|
16814
|
+
);
|
|
16667
16815
|
const updatePromoCode = (code) => {
|
|
16668
16816
|
setPromoCode(code);
|
|
16817
|
+
previewCheckout({ promoCode: code });
|
|
16669
16818
|
};
|
|
16670
16819
|
(0, import_react24.useEffect)(() => {
|
|
16671
16820
|
if (charges) {
|
|
@@ -17431,6 +17580,18 @@ var Details = ({
|
|
|
17431
17580
|
const { t: t2 } = useTranslation();
|
|
17432
17581
|
const theme = nt();
|
|
17433
17582
|
const { data } = useEmbed();
|
|
17583
|
+
const currency = (0, import_react31.useMemo)(() => {
|
|
17584
|
+
if (data.company?.plan?.planPeriod === "month") {
|
|
17585
|
+
return monthlyUsageBasedPrice?.currency;
|
|
17586
|
+
}
|
|
17587
|
+
if (data.company?.plan?.planPeriod === "year") {
|
|
17588
|
+
return yearlyUsageBasedPrice?.currency;
|
|
17589
|
+
}
|
|
17590
|
+
}, [
|
|
17591
|
+
data.company?.plan?.planPeriod,
|
|
17592
|
+
monthlyUsageBasedPrice,
|
|
17593
|
+
yearlyUsageBasedPrice
|
|
17594
|
+
]);
|
|
17434
17595
|
const price = (0, import_react31.useMemo)(() => {
|
|
17435
17596
|
if (data.company?.plan?.planPeriod === "month") {
|
|
17436
17597
|
return monthlyUsageBasedPrice?.price;
|
|
@@ -17451,7 +17612,7 @@ var Details = ({
|
|
|
17451
17612
|
return `${formatNumber(allocation)} ${(0, import_pluralize4.default)(feature.name, allocation)}`;
|
|
17452
17613
|
}
|
|
17453
17614
|
if (priceBehavior === "pay_as_you_go" && typeof price === "number") {
|
|
17454
|
-
return `${formatCurrency(price)} ${t2("per")} ${(0, import_pluralize4.default)(feature.name.toLowerCase(), 1)}`;
|
|
17615
|
+
return `${formatCurrency(price, currency)} ${t2("per")} ${(0, import_pluralize4.default)(feature.name.toLowerCase(), 1)}`;
|
|
17455
17616
|
}
|
|
17456
17617
|
if (!priceBehavior && typeof allocation === "number") {
|
|
17457
17618
|
return `${formatNumber(allocation)} ${(0, import_pluralize4.default)(feature.name, allocation)}`;
|
|
@@ -17459,7 +17620,7 @@ var Details = ({
|
|
|
17459
17620
|
if (!priceBehavior) {
|
|
17460
17621
|
return t2("Unlimited", { item: (0, import_pluralize4.default)(feature.name) });
|
|
17461
17622
|
}
|
|
17462
|
-
}, [allocation, feature?.name, price, priceBehavior, t2]);
|
|
17623
|
+
}, [allocation, feature?.name, price, priceBehavior, t2, currency]);
|
|
17463
17624
|
const usageText = (0, import_react31.useMemo)(() => {
|
|
17464
17625
|
if (!feature?.name) {
|
|
17465
17626
|
return;
|
|
@@ -17467,15 +17628,15 @@ var Details = ({
|
|
|
17467
17628
|
if (usageData) {
|
|
17468
17629
|
let acc;
|
|
17469
17630
|
if (priceBehavior === "pay_in_advance" && typeof data.company?.plan?.planPeriod === "string" && typeof price === "number") {
|
|
17470
|
-
acc = `${formatCurrency(price)}/${(0, import_pluralize4.default)(feature.name.toLowerCase(), 1)}/${shortenPeriod(data.company.plan.planPeriod)}`;
|
|
17631
|
+
acc = `${formatCurrency(price, currency)}/${(0, import_pluralize4.default)(feature.name.toLowerCase(), 1)}/${shortenPeriod(data.company.plan.planPeriod)}`;
|
|
17471
17632
|
} else if (priceBehavior === "pay_as_you_go" && typeof usage === "number") {
|
|
17472
17633
|
acc = `${usage} ${(0, import_pluralize4.default)(feature.name.toLowerCase(), usage)} ${t2("used")}`;
|
|
17473
17634
|
}
|
|
17474
17635
|
if (acc) {
|
|
17475
17636
|
if (usageData?.priceBehavior === "pay_in_advance" && typeof price === "number" && typeof allocation === "number") {
|
|
17476
|
-
acc += ` \u2022 ${formatCurrency(price * allocation)}`;
|
|
17637
|
+
acc += ` \u2022 ${formatCurrency(price * allocation, currency)}`;
|
|
17477
17638
|
} else if (usageData?.priceBehavior === "pay_as_you_go" && typeof price === "number" && typeof usage === "number") {
|
|
17478
|
-
acc += ` \u2022 ${formatCurrency(price * usage)}`;
|
|
17639
|
+
acc += ` \u2022 ${formatCurrency(price * usage, currency)}`;
|
|
17479
17640
|
}
|
|
17480
17641
|
return acc;
|
|
17481
17642
|
}
|
|
@@ -17496,7 +17657,8 @@ var Details = ({
|
|
|
17496
17657
|
priceBehavior,
|
|
17497
17658
|
t2,
|
|
17498
17659
|
usage,
|
|
17499
|
-
usageData
|
|
17660
|
+
usageData,
|
|
17661
|
+
currency
|
|
17500
17662
|
]);
|
|
17501
17663
|
if (!text) {
|
|
17502
17664
|
return null;
|
|
@@ -17777,9 +17939,9 @@ function resolveDesignProps2(props) {
|
|
|
17777
17939
|
function formatInvoices(invoices) {
|
|
17778
17940
|
return (invoices || []).filter(
|
|
17779
17941
|
({ url, amountDue, amountPaid }) => url && (amountDue === 0 || amountPaid > 0)
|
|
17780
|
-
).sort((a2, b2) => a2.dueDate && b2.dueDate ? +b2.dueDate - +a2.dueDate : 1).map(({ amountDue, dueDate, url }) => ({
|
|
17942
|
+
).sort((a2, b2) => a2.dueDate && b2.dueDate ? +b2.dueDate - +a2.dueDate : 1).map(({ amountDue, dueDate, url, currency }) => ({
|
|
17781
17943
|
...dueDate && { date: toPrettyDate(dueDate) },
|
|
17782
|
-
amount: formatCurrency(amountDue),
|
|
17944
|
+
amount: formatCurrency(amountDue, currency),
|
|
17783
17945
|
url
|
|
17784
17946
|
}));
|
|
17785
17947
|
}
|
|
@@ -17962,10 +18124,13 @@ var MeteredFeatures = (0, import_react34.forwardRef)(({ className, ...rest }, re
|
|
|
17962
18124
|
yearlyUsageBasedPrice
|
|
17963
18125
|
}, index) => {
|
|
17964
18126
|
let price;
|
|
18127
|
+
let currency;
|
|
17965
18128
|
if (planPeriod === "month") {
|
|
17966
18129
|
price = monthlyUsageBasedPrice?.price;
|
|
18130
|
+
currency = monthlyUsageBasedPrice?.currency;
|
|
17967
18131
|
} else if (planPeriod === "year") {
|
|
17968
18132
|
price = yearlyUsageBasedPrice?.price;
|
|
18133
|
+
currency = yearlyUsageBasedPrice?.currency;
|
|
17969
18134
|
}
|
|
17970
18135
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Element, { as: Flex, $gap: "1.5rem", children: [
|
|
17971
18136
|
props.icon.isVisible && feature?.icon && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
@@ -18039,7 +18204,7 @@ var MeteredFeatures = (0, import_react34.forwardRef)(({ className, ...rest }, re
|
|
|
18039
18204
|
formatNumber(allocation),
|
|
18040
18205
|
" ",
|
|
18041
18206
|
(0, import_pluralize5.default)(feature.name, allocation)
|
|
18042
|
-
] }) : priceBehavior === "pay_as_you_go" ? typeof price === "number" && typeof usage === "number" && formatCurrency(usage * price) : typeof usage === "number" && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
|
|
18207
|
+
] }) : priceBehavior === "pay_as_you_go" ? typeof price === "number" && typeof usage === "number" && formatCurrency(usage * price, currency) : typeof usage === "number" && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
|
|
18043
18208
|
formatNumber(usage),
|
|
18044
18209
|
" ",
|
|
18045
18210
|
(0, import_pluralize5.default)(feature.name, usage)
|
|
@@ -18524,19 +18689,23 @@ var PlanManager = (0, import_react36.forwardRef)(({ children, className, portal,
|
|
|
18524
18689
|
(acc, usage) => {
|
|
18525
18690
|
const quantity = usage?.allocation ?? 0;
|
|
18526
18691
|
let price;
|
|
18692
|
+
let currencyCode;
|
|
18527
18693
|
if (currentPlan?.planPeriod === "month") {
|
|
18528
18694
|
price = usage.monthlyUsageBasedPrice?.price;
|
|
18695
|
+
currencyCode = usage.monthlyUsageBasedPrice?.currency;
|
|
18529
18696
|
} else if (currentPlan?.planPeriod === "year") {
|
|
18530
18697
|
price = usage.yearlyUsageBasedPrice?.price;
|
|
18698
|
+
currencyCode = usage.yearlyUsageBasedPrice?.currency;
|
|
18531
18699
|
}
|
|
18532
18700
|
if (usage.priceBehavior && typeof price === "number" && quantity > 0) {
|
|
18533
|
-
acc.push({ ...usage, price, quantity });
|
|
18701
|
+
acc.push({ ...usage, price, quantity, currencyCode });
|
|
18534
18702
|
}
|
|
18535
18703
|
return acc;
|
|
18536
18704
|
},
|
|
18537
18705
|
[]
|
|
18538
18706
|
);
|
|
18539
18707
|
const billingSubscription = data.company?.billingSubscription;
|
|
18708
|
+
const subscriptionCurrency = billingSubscription?.currency ?? "USD";
|
|
18540
18709
|
const showTrialBox = billingSubscription && billingSubscription.status == "trialing";
|
|
18541
18710
|
const trialEndDate = billingSubscription?.trialEnd ? new Date(billingSubscription.trialEnd * 1e3) : /* @__PURE__ */ new Date();
|
|
18542
18711
|
const todayDate = /* @__PURE__ */ new Date();
|
|
@@ -18630,7 +18799,10 @@ var PlanManager = (0, import_react36.forwardRef)(({ children, className, portal,
|
|
|
18630
18799
|
$size: theme.typography[props.header.price.fontStyle].fontSize,
|
|
18631
18800
|
$weight: theme.typography[props.header.price.fontStyle].fontWeight,
|
|
18632
18801
|
$color: theme.typography[props.header.price.fontStyle].color,
|
|
18633
|
-
children: formatCurrency(
|
|
18802
|
+
children: formatCurrency(
|
|
18803
|
+
currentPlan.planPrice,
|
|
18804
|
+
subscriptionCurrency
|
|
18805
|
+
)
|
|
18634
18806
|
}
|
|
18635
18807
|
),
|
|
18636
18808
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
@@ -18688,7 +18860,7 @@ var PlanManager = (0, import_react36.forwardRef)(({ children, className, portal,
|
|
|
18688
18860
|
$weight: theme.typography.text.fontWeight,
|
|
18689
18861
|
$color: theme.typography.text.color,
|
|
18690
18862
|
children: [
|
|
18691
|
-
formatCurrency(addOn.planPrice),
|
|
18863
|
+
formatCurrency(addOn.planPrice, subscriptionCurrency),
|
|
18692
18864
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("sub", { children: [
|
|
18693
18865
|
"/",
|
|
18694
18866
|
shortenPeriod(addOn.planPeriod)
|
|
@@ -18751,7 +18923,10 @@ var PlanManager = (0, import_react36.forwardRef)(({ children, className, portal,
|
|
|
18751
18923
|
$weight: theme.typography.text.fontWeight,
|
|
18752
18924
|
$color: hexToHSL(theme.typography.text.color).l > 50 ? darken(theme.typography.text.color, 0.46) : lighten(theme.typography.text.color, 0.46),
|
|
18753
18925
|
children: [
|
|
18754
|
-
formatCurrency(
|
|
18926
|
+
formatCurrency(
|
|
18927
|
+
entitlement.price,
|
|
18928
|
+
entitlement.currencyCode
|
|
18929
|
+
),
|
|
18755
18930
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("sub", { children: [
|
|
18756
18931
|
"/",
|
|
18757
18932
|
(0, import_pluralize6.default)(
|
|
@@ -18773,7 +18948,8 @@ var PlanManager = (0, import_react36.forwardRef)(({ children, className, portal,
|
|
|
18773
18948
|
$color: theme.typography.text.color,
|
|
18774
18949
|
children: [
|
|
18775
18950
|
formatCurrency(
|
|
18776
|
-
entitlement.price * (entitlement.priceBehavior === "pay_in_advance" ? entitlement.quantity : 1)
|
|
18951
|
+
entitlement.price * (entitlement.priceBehavior === "pay_in_advance" ? entitlement.quantity : 1),
|
|
18952
|
+
entitlement.currencyCode
|
|
18777
18953
|
),
|
|
18778
18954
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("sub", { children: [
|
|
18779
18955
|
"/",
|
|
@@ -18953,7 +19129,7 @@ var PricingTable = (0, import_react37.forwardRef)(({ children, className, ...res
|
|
|
18953
19129
|
$display: "grid",
|
|
18954
19130
|
$gridTemplateColumns: "repeat(auto-fill, minmax(320px, 1fr))",
|
|
18955
19131
|
$gap: "1rem",
|
|
18956
|
-
children: plans.map((plan, index
|
|
19132
|
+
children: plans.map((plan, index) => {
|
|
18957
19133
|
const isActivePlan = plan.current && data.company?.plan?.planPeriod === selectedPeriod;
|
|
18958
19134
|
const count = entitlementCounts[plan.id];
|
|
18959
19135
|
let isExpanded = false;
|
|
@@ -19012,12 +19188,13 @@ var PricingTable = (0, import_react37.forwardRef)(({ children, className, ...res
|
|
|
19012
19188
|
$size: theme.typography[props.plans.name.fontStyle].fontSize,
|
|
19013
19189
|
$weight: theme.typography[props.plans.name.fontStyle].fontWeight,
|
|
19014
19190
|
$color: theme.typography[props.plans.name.fontStyle].color,
|
|
19015
|
-
children: formatCurrency(
|
|
19016
|
-
(selectedPeriod === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.price ?? 0
|
|
19191
|
+
children: plan.custom ? plan.customPlanConfig?.priceText ? plan.customPlanConfig?.priceText : t2("Custom Plan Price") : formatCurrency(
|
|
19192
|
+
(selectedPeriod === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.price ?? 0,
|
|
19193
|
+
(selectedPeriod === "month" ? plan.monthlyPrice : plan.yearlyPrice)?.currency
|
|
19017
19194
|
)
|
|
19018
19195
|
}
|
|
19019
19196
|
),
|
|
19020
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
19197
|
+
!plan.custom && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
19021
19198
|
Text,
|
|
19022
19199
|
{
|
|
19023
19200
|
$font: theme.typography[props.plans.name.fontStyle].fontFamily,
|
|
@@ -19058,18 +19235,6 @@ var PricingTable = (0, import_react37.forwardRef)(({ children, className, ...res
|
|
|
19058
19235
|
$padding: `${0.75 * cardPadding}rem ${cardPadding}rem 0`,
|
|
19059
19236
|
children: [
|
|
19060
19237
|
props.plans.showEntitlements && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(Flex, { $flexDirection: "column", $gap: "1rem", $flexGrow: "1", children: [
|
|
19061
|
-
props.plans.showInclusionText && index > 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Box, { $marginBottom: "1.5rem", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
19062
|
-
Text,
|
|
19063
|
-
{
|
|
19064
|
-
$font: theme.typography.text.fontFamily,
|
|
19065
|
-
$size: theme.typography.text.fontSize,
|
|
19066
|
-
$weight: theme.typography.text.fontWeight,
|
|
19067
|
-
$color: theme.typography.text.color,
|
|
19068
|
-
children: t2("Everything in", {
|
|
19069
|
-
plan: self2[index - 1].name
|
|
19070
|
-
})
|
|
19071
|
-
}
|
|
19072
|
-
) }),
|
|
19073
19238
|
plan.entitlements.slice().sort((a2, b2) => {
|
|
19074
19239
|
if (a2.feature?.name && b2.feature?.name && a2.feature?.name > b2.feature?.name) {
|
|
19075
19240
|
return 1;
|
|
@@ -19080,10 +19245,13 @@ var PricingTable = (0, import_react37.forwardRef)(({ children, className, ...res
|
|
|
19080
19245
|
return 0;
|
|
19081
19246
|
}).reduce((acc, entitlement) => {
|
|
19082
19247
|
let price;
|
|
19248
|
+
let currency;
|
|
19083
19249
|
if (selectedPeriod === "month") {
|
|
19084
19250
|
price = entitlement.meteredMonthlyPrice?.price;
|
|
19251
|
+
currency = entitlement.meteredMonthlyPrice?.currency;
|
|
19085
19252
|
} else if (selectedPeriod === "year") {
|
|
19086
19253
|
price = entitlement.meteredYearlyPrice?.price;
|
|
19254
|
+
currency = entitlement.meteredYearlyPrice?.currency;
|
|
19087
19255
|
}
|
|
19088
19256
|
if (entitlement.priceBehavior && typeof price !== "number") {
|
|
19089
19257
|
return acc;
|
|
@@ -19110,7 +19278,7 @@ var PricingTable = (0, import_react37.forwardRef)(({ children, className, ...res
|
|
|
19110
19278
|
$color: theme.typography.text.color,
|
|
19111
19279
|
$leading: 1.35,
|
|
19112
19280
|
children: typeof price !== "undefined" ? /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
|
|
19113
|
-
formatCurrency(price),
|
|
19281
|
+
formatCurrency(price, currency),
|
|
19114
19282
|
" ",
|
|
19115
19283
|
t2("per"),
|
|
19116
19284
|
" ",
|
|
@@ -19218,13 +19386,15 @@ var PricingTable = (0, import_react37.forwardRef)(({ children, className, ...res
|
|
|
19218
19386
|
EmbedButton,
|
|
19219
19387
|
{
|
|
19220
19388
|
disabled: !plan.valid || !canCheckout,
|
|
19221
|
-
|
|
19222
|
-
|
|
19223
|
-
|
|
19224
|
-
|
|
19225
|
-
|
|
19226
|
-
|
|
19227
|
-
|
|
19389
|
+
...!plan.custom && {
|
|
19390
|
+
onClick: () => {
|
|
19391
|
+
setSelected({
|
|
19392
|
+
period: selectedPeriod,
|
|
19393
|
+
planId: isActivePlan ? null : plan.id,
|
|
19394
|
+
usage: false
|
|
19395
|
+
});
|
|
19396
|
+
setLayout("checkout");
|
|
19397
|
+
}
|
|
19228
19398
|
},
|
|
19229
19399
|
...index > currentPlanIndex ? {
|
|
19230
19400
|
$size: props.upgrade.buttonSize,
|
|
@@ -19235,7 +19405,14 @@ var PricingTable = (0, import_react37.forwardRef)(({ children, className, ...res
|
|
|
19235
19405
|
$color: props.downgrade.buttonStyle,
|
|
19236
19406
|
$variant: "outline"
|
|
19237
19407
|
},
|
|
19238
|
-
children:
|
|
19408
|
+
children: plan.custom ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
19409
|
+
ButtonLink,
|
|
19410
|
+
{
|
|
19411
|
+
href: plan.customPlanConfig?.ctaWebSite ?? "#",
|
|
19412
|
+
target: "_blank",
|
|
19413
|
+
children: plan.customPlanConfig?.ctaText ?? t2("Custom Plan CTA")
|
|
19414
|
+
}
|
|
19415
|
+
) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
19239
19416
|
Tooltip,
|
|
19240
19417
|
{
|
|
19241
19418
|
trigger: t2("Over usage limit"),
|
|
@@ -19328,7 +19505,8 @@ var PricingTable = (0, import_react37.forwardRef)(({ children, className, ...res
|
|
|
19328
19505
|
$weight: theme.typography[props.plans.name.fontStyle].fontWeight,
|
|
19329
19506
|
$color: theme.typography[props.plans.name.fontStyle].color,
|
|
19330
19507
|
children: formatCurrency(
|
|
19331
|
-
(selectedPeriod === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.price ?? 0
|
|
19508
|
+
(selectedPeriod === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.price ?? 0,
|
|
19509
|
+
(selectedPeriod === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.currency
|
|
19332
19510
|
)
|
|
19333
19511
|
}
|
|
19334
19512
|
),
|
|
@@ -19511,7 +19689,8 @@ var UpcomingBill = (0, import_react38.forwardRef)(({ className, ...rest }, ref)
|
|
|
19511
19689
|
},
|
|
19512
19690
|
...data.upcomingInvoice?.dueDate && {
|
|
19513
19691
|
dueDate: toPrettyDate(new Date(data.upcomingInvoice.dueDate))
|
|
19514
|
-
}
|
|
19692
|
+
},
|
|
19693
|
+
currency: data.upcomingInvoice?.currency
|
|
19515
19694
|
}
|
|
19516
19695
|
};
|
|
19517
19696
|
}, [data.subscription, data.upcomingInvoice]);
|
|
@@ -19550,7 +19729,10 @@ var UpcomingBill = (0, import_react38.forwardRef)(({ className, ...rest }, ref)
|
|
|
19550
19729
|
$weight: theme.typography[props.price.fontStyle].fontWeight,
|
|
19551
19730
|
$color: theme.typography[props.price.fontStyle].color,
|
|
19552
19731
|
$leading: 1,
|
|
19553
|
-
children: formatCurrency(
|
|
19732
|
+
children: formatCurrency(
|
|
19733
|
+
upcomingInvoice.amountDue,
|
|
19734
|
+
upcomingInvoice.currency
|
|
19735
|
+
)
|
|
19554
19736
|
}
|
|
19555
19737
|
) }),
|
|
19556
19738
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Box, { $lineHeight: 1.15, $maxWidth: "10rem", $textAlign: "right", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
@@ -19565,7 +19747,7 @@ var UpcomingBill = (0, import_react38.forwardRef)(({ className, ...rest }, ref)
|
|
|
19565
19747
|
}
|
|
19566
19748
|
) })
|
|
19567
19749
|
] }),
|
|
19568
|
-
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
|
|
19750
|
+
discounts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(Flex, { $justifyContent: "space-between", $alignItems: "center", children: [
|
|
19569
19751
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
19570
19752
|
Text,
|
|
19571
19753
|
{
|
|
@@ -19720,7 +19902,7 @@ var Error2 = ({ message }) => {
|
|
|
19720
19902
|
);
|
|
19721
19903
|
};
|
|
19722
19904
|
var ComponentTree = () => {
|
|
19723
|
-
const { error, nodes } = useEmbed();
|
|
19905
|
+
const { error, nodes, isPending } = useEmbed();
|
|
19724
19906
|
const [children, setChildren] = (0, import_react40.useState)(/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Loading, {}));
|
|
19725
19907
|
(0, import_react40.useEffect)(() => {
|
|
19726
19908
|
const renderer = createRenderer();
|
|
@@ -19730,7 +19912,7 @@ var ComponentTree = () => {
|
|
|
19730
19912
|
console.error(error);
|
|
19731
19913
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Error2, { message: error.message });
|
|
19732
19914
|
}
|
|
19733
|
-
if (
|
|
19915
|
+
if (isPending) {
|
|
19734
19916
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Loading, {});
|
|
19735
19917
|
}
|
|
19736
19918
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children });
|