@schematichq/schematic-components 1.1.2 → 1.1.4
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 +401 -302
- package/dist/schematic-components.d.ts +179 -0
- package/dist/schematic-components.esm.js +408 -303
- package/package.json +4 -4
|
@@ -5253,7 +5253,7 @@ var Interpolator = class {
|
|
|
5253
5253
|
};
|
|
5254
5254
|
this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
|
|
5255
5255
|
this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
|
|
5256
|
-
this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}(
|
|
5256
|
+
this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
|
|
5257
5257
|
}
|
|
5258
5258
|
interpolate(str, data, lng, options2) {
|
|
5259
5259
|
let match2;
|
|
@@ -7262,17 +7262,24 @@ function BillingCreditBundleViewFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
7262
7262
|
return json;
|
|
7263
7263
|
}
|
|
7264
7264
|
return {
|
|
7265
|
+
billingInvoiceId: json["billing_invoice_id"] == null ? void 0 : json["billing_invoice_id"],
|
|
7265
7266
|
bundleType: json["bundle_type"],
|
|
7266
7267
|
createdAt: new Date(json["created_at"]),
|
|
7268
|
+
creditDescription: json["credit_description"] == null ? void 0 : json["credit_description"],
|
|
7269
|
+
creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
|
|
7267
7270
|
creditId: json["credit_id"],
|
|
7271
|
+
creditName: json["credit_name"],
|
|
7268
7272
|
expiryType: json["expiry_type"],
|
|
7269
7273
|
expiryUnit: json["expiry_unit"],
|
|
7270
7274
|
expiryUnitCount: json["expiry_unit_count"] == null ? void 0 : json["expiry_unit_count"],
|
|
7271
7275
|
id: json["id"],
|
|
7272
7276
|
name: json["name"],
|
|
7277
|
+
pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
|
|
7273
7278
|
price: json["price"] == null ? void 0 : BillingProductPriceResponseDataFromJSON(json["price"]),
|
|
7274
7279
|
quantity: json["quantity"] == null ? void 0 : json["quantity"],
|
|
7280
|
+
singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
|
|
7275
7281
|
status: json["status"],
|
|
7282
|
+
unitPrice: json["unit_price"] == null ? void 0 : BillingProductPriceResponseDataFromJSON(json["unit_price"]),
|
|
7276
7283
|
updatedAt: new Date(json["updated_at"])
|
|
7277
7284
|
};
|
|
7278
7285
|
}
|
|
@@ -8133,6 +8140,32 @@ function FeatureDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8133
8140
|
};
|
|
8134
8141
|
}
|
|
8135
8142
|
|
|
8143
|
+
// src/api/checkoutexternal/models/PlanCreditGrantView.ts
|
|
8144
|
+
function PlanCreditGrantViewFromJSON(json) {
|
|
8145
|
+
return PlanCreditGrantViewFromJSONTyped(json, false);
|
|
8146
|
+
}
|
|
8147
|
+
function PlanCreditGrantViewFromJSONTyped(json, ignoreDiscriminator) {
|
|
8148
|
+
if (json == null) {
|
|
8149
|
+
return json;
|
|
8150
|
+
}
|
|
8151
|
+
return {
|
|
8152
|
+
createdAt: new Date(json["created_at"]),
|
|
8153
|
+
creditAmount: json["credit_amount"],
|
|
8154
|
+
creditDescription: json["credit_description"],
|
|
8155
|
+
creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
|
|
8156
|
+
creditId: json["credit_id"],
|
|
8157
|
+
creditName: json["credit_name"],
|
|
8158
|
+
id: json["id"],
|
|
8159
|
+
planId: json["plan_id"],
|
|
8160
|
+
planName: json["plan_name"],
|
|
8161
|
+
pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
|
|
8162
|
+
resetCadence: json["reset_cadence"],
|
|
8163
|
+
resetStart: json["reset_start"],
|
|
8164
|
+
singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
|
|
8165
|
+
updatedAt: new Date(json["updated_at"])
|
|
8166
|
+
};
|
|
8167
|
+
}
|
|
8168
|
+
|
|
8136
8169
|
// src/api/checkoutexternal/models/PlanResponseData.ts
|
|
8137
8170
|
function PlanResponseDataFromJSON(json) {
|
|
8138
8171
|
return PlanResponseDataFromJSONTyped(json, false);
|
|
@@ -8233,6 +8266,9 @@ function CompanyPlanDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8233
8266
|
),
|
|
8234
8267
|
icon: json["icon"],
|
|
8235
8268
|
id: json["id"],
|
|
8269
|
+
includedCreditGrants: json["included_credit_grants"].map(
|
|
8270
|
+
PlanCreditGrantViewFromJSON
|
|
8271
|
+
),
|
|
8236
8272
|
isCustom: json["is_custom"],
|
|
8237
8273
|
isDefault: json["is_default"],
|
|
8238
8274
|
isFree: json["is_free"],
|
|
@@ -8370,16 +8406,20 @@ function CreditCompanyGrantViewFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8370
8406
|
companyId: json["company_id"],
|
|
8371
8407
|
companyName: json["company_name"],
|
|
8372
8408
|
createdAt: new Date(json["created_at"]),
|
|
8409
|
+
creditDescription: json["credit_description"],
|
|
8410
|
+
creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
|
|
8373
8411
|
creditName: json["credit_name"],
|
|
8374
8412
|
expiresAt: json["expires_at"] == null ? void 0 : new Date(json["expires_at"]),
|
|
8375
8413
|
grantReason: json["grant_reason"],
|
|
8376
8414
|
id: json["id"],
|
|
8377
8415
|
planId: json["plan_id"] == null ? void 0 : json["plan_id"],
|
|
8378
8416
|
planName: json["plan_name"] == null ? void 0 : json["plan_name"],
|
|
8417
|
+
pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
|
|
8379
8418
|
price: json["price"] == null ? void 0 : BillingProductPriceResponseDataFromJSON(json["price"]),
|
|
8380
8419
|
quantity: json["quantity"],
|
|
8381
8420
|
quantityRemaining: json["quantity_remaining"],
|
|
8382
8421
|
quantityUsed: json["quantity_used"],
|
|
8422
|
+
singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
|
|
8383
8423
|
sourceLabel: json["source_label"],
|
|
8384
8424
|
updatedAt: new Date(json["updated_at"]),
|
|
8385
8425
|
validFrom: json["valid_from"] == null ? void 0 : new Date(json["valid_from"]),
|
|
@@ -10131,7 +10171,7 @@ var EmbedProvider = ({
|
|
|
10131
10171
|
});
|
|
10132
10172
|
const customHeaders = useMemo3(
|
|
10133
10173
|
() => ({
|
|
10134
|
-
"X-Schematic-Components-Version": "1.1.
|
|
10174
|
+
"X-Schematic-Components-Version": "1.1.4",
|
|
10135
10175
|
"X-Schematic-Session-ID": sessionIdRef.current
|
|
10136
10176
|
}),
|
|
10137
10177
|
[]
|
|
@@ -10535,8 +10575,8 @@ function useTrialEnd() {
|
|
|
10535
10575
|
const end = typeof billingSubscription?.trialEnd === "number" ? new Date(billingSubscription.trialEnd * 1e3) : void 0;
|
|
10536
10576
|
let formatted2;
|
|
10537
10577
|
if (end) {
|
|
10538
|
-
const
|
|
10539
|
-
const difference = end.getTime() -
|
|
10578
|
+
const now = /* @__PURE__ */ new Date();
|
|
10579
|
+
const difference = end.getTime() - now.getTime();
|
|
10540
10580
|
let amount;
|
|
10541
10581
|
let unit;
|
|
10542
10582
|
if (difference >= DAYS_IN_MS) {
|
|
@@ -12288,8 +12328,8 @@ var Sidebar = ({
|
|
|
12288
12328
|
const inEditMode = settings.mode === "edit";
|
|
12289
12329
|
const hasPaymentMethod = typeof paymentMethod !== "undefined" || typeof paymentMethodId === "string";
|
|
12290
12330
|
const isSelectedPlanTrialable = isHydratedPlan(selectedPlan) && selectedPlan?.companyCanTrial === true && selectedPlan?.isTrialable === true;
|
|
12291
|
-
const
|
|
12292
|
-
const trialEndsOn = new Date(
|
|
12331
|
+
const now = /* @__PURE__ */ new Date();
|
|
12332
|
+
const trialEndsOn = new Date(now);
|
|
12293
12333
|
if (isSelectedPlanTrialable && selectedPlan.trialDays) {
|
|
12294
12334
|
trialEndsOn.setDate(trialEndsOn.getDate() + selectedPlan.trialDays);
|
|
12295
12335
|
}
|
|
@@ -13091,7 +13131,7 @@ var PlanButtonGroup = ({
|
|
|
13091
13131
|
children: plan.custom ? plan.customPlanConfig?.ctaText ?? t2("Talk to support") : !isValidPlan ? /* @__PURE__ */ jsx17(
|
|
13092
13132
|
Tooltip,
|
|
13093
13133
|
{
|
|
13094
|
-
trigger: /* @__PURE__ */ jsx17(Text, { children: t2("Over usage limit") }),
|
|
13134
|
+
trigger: /* @__PURE__ */ jsx17(Text, { as: Box, $align: "center", children: t2("Over usage limit") }),
|
|
13095
13135
|
content: /* @__PURE__ */ jsx17(Text, { children: t2("Current usage exceeds the limit of this plan.") })
|
|
13096
13136
|
}
|
|
13097
13137
|
) : t2("Start X day trial", { days: plan.trialDays })
|
|
@@ -13112,7 +13152,7 @@ var PlanButtonGroup = ({
|
|
|
13112
13152
|
children: !isValidPlan ? /* @__PURE__ */ jsx17(
|
|
13113
13153
|
Tooltip,
|
|
13114
13154
|
{
|
|
13115
|
-
trigger: /* @__PURE__ */ jsx17(Text, { children: t2("Over usage limit") }),
|
|
13155
|
+
trigger: /* @__PURE__ */ jsx17(Text, { as: Box, $align: "center", children: t2("Over usage limit") }),
|
|
13116
13156
|
content: /* @__PURE__ */ jsx17(Text, { children: t2("Current usage exceeds the limit of this plan.") })
|
|
13117
13157
|
}
|
|
13118
13158
|
) : t2("Choose plan")
|
|
@@ -13142,7 +13182,7 @@ var PlanButtonGroup = ({
|
|
|
13142
13182
|
children: plan.custom ? plan.customPlanConfig?.ctaText ?? t2("Talk to support") : !isValidPlan ? /* @__PURE__ */ jsx17(
|
|
13143
13183
|
Tooltip,
|
|
13144
13184
|
{
|
|
13145
|
-
trigger: /* @__PURE__ */ jsx17(Text, { children: t2("Over usage limit") }),
|
|
13185
|
+
trigger: /* @__PURE__ */ jsx17(Text, { as: Box, $align: "center", children: t2("Over usage limit") }),
|
|
13146
13186
|
content: /* @__PURE__ */ jsx17(Text, { children: t2("Current usage exceeds the limit of this plan.") })
|
|
13147
13187
|
}
|
|
13148
13188
|
) : t2("Choose plan")
|
|
@@ -14572,7 +14612,7 @@ var TieredPricingDetails = ({
|
|
|
14572
14612
|
Y: formatCurrency(perUnitPrice, currency),
|
|
14573
14613
|
unit: getFeatureName(entitlement.feature, 1),
|
|
14574
14614
|
Z: formatCurrency(flatAmount, currency),
|
|
14575
|
-
period
|
|
14615
|
+
period
|
|
14576
14616
|
});
|
|
14577
14617
|
}
|
|
14578
14618
|
};
|
|
@@ -14973,7 +15013,8 @@ var UsageDetails = ({
|
|
|
14973
15013
|
feature,
|
|
14974
15014
|
priceBehavior,
|
|
14975
15015
|
usage,
|
|
14976
|
-
softLimit
|
|
15016
|
+
softLimit,
|
|
15017
|
+
metricResetAt
|
|
14977
15018
|
} = entitlement;
|
|
14978
15019
|
const { t: t2 } = useTranslation();
|
|
14979
15020
|
const { data } = useEmbed();
|
|
@@ -15078,23 +15119,38 @@ var UsageDetails = ({
|
|
|
15078
15119
|
);
|
|
15079
15120
|
index += 1;
|
|
15080
15121
|
}
|
|
15081
|
-
if (
|
|
15082
|
-
|
|
15083
|
-
|
|
15084
|
-
/* @__PURE__ */
|
|
15085
|
-
|
|
15086
|
-
|
|
15087
|
-
|
|
15088
|
-
|
|
15122
|
+
if (typeof cost === "number" && cost > 0) {
|
|
15123
|
+
acc.push(
|
|
15124
|
+
/* @__PURE__ */ jsxs24(Fragment13, { children: [
|
|
15125
|
+
acc.length > 0 && /* @__PURE__ */ jsx30(Fragment14, { children: " \u2022 " }),
|
|
15126
|
+
formatCurrency(cost, currency)
|
|
15127
|
+
] }, index)
|
|
15128
|
+
);
|
|
15129
|
+
index += 1;
|
|
15130
|
+
if (feature.featureType === "trait" /* Trait */ && typeof period === "string") {
|
|
15131
|
+
acc.push(/* @__PURE__ */ jsxs24(Fragment13, { children: [
|
|
15132
|
+
"/",
|
|
15133
|
+
shortenPeriod(period)
|
|
15134
|
+
] }, index));
|
|
15089
15135
|
index += 1;
|
|
15090
|
-
if (feature.featureType === "trait" /* Trait */ && typeof period === "string") {
|
|
15091
|
-
acc.push(/* @__PURE__ */ jsxs24(Fragment13, { children: [
|
|
15092
|
-
"/",
|
|
15093
|
-
shortenPeriod(period)
|
|
15094
|
-
] }, index));
|
|
15095
|
-
index += 1;
|
|
15096
|
-
}
|
|
15097
15136
|
}
|
|
15137
|
+
}
|
|
15138
|
+
if (metricResetAt) {
|
|
15139
|
+
acc.push(
|
|
15140
|
+
/* @__PURE__ */ jsxs24(Fragment13, { children: [
|
|
15141
|
+
acc.length > 0 && /* @__PURE__ */ jsx30(Fragment14, { children: " \u2022 " }),
|
|
15142
|
+
t2("Resets", {
|
|
15143
|
+
date: toPrettyDate(metricResetAt, {
|
|
15144
|
+
month: "numeric",
|
|
15145
|
+
day: "numeric",
|
|
15146
|
+
year: void 0
|
|
15147
|
+
})
|
|
15148
|
+
})
|
|
15149
|
+
] }, index)
|
|
15150
|
+
);
|
|
15151
|
+
index += 1;
|
|
15152
|
+
}
|
|
15153
|
+
if (acc.length > 0) {
|
|
15098
15154
|
return acc;
|
|
15099
15155
|
}
|
|
15100
15156
|
if (typeof usage === "number") {
|
|
@@ -15112,6 +15168,7 @@ var UsageDetails = ({
|
|
|
15112
15168
|
priceBehavior,
|
|
15113
15169
|
allocation,
|
|
15114
15170
|
usage,
|
|
15171
|
+
metricResetAt,
|
|
15115
15172
|
billingPrice,
|
|
15116
15173
|
cost
|
|
15117
15174
|
]);
|
|
@@ -15343,8 +15400,10 @@ function resolveDesignProps3(props) {
|
|
|
15343
15400
|
}
|
|
15344
15401
|
};
|
|
15345
15402
|
}
|
|
15346
|
-
function formatInvoices(invoices) {
|
|
15347
|
-
|
|
15403
|
+
function formatInvoices(invoices, options2) {
|
|
15404
|
+
const { hideUpcoming = true } = options2 || {};
|
|
15405
|
+
const now = /* @__PURE__ */ new Date();
|
|
15406
|
+
return (invoices || []).filter(({ dueDate }) => !hideUpcoming || dueDate && +dueDate <= +now).sort((a2, b2) => a2.dueDate && b2.dueDate ? +b2.dueDate - +a2.dueDate : 1).map(({ amountDue, dueDate, url, currency }) => ({
|
|
15348
15407
|
amount: formatCurrency(amountDue, currency),
|
|
15349
15408
|
date: dueDate ? toPrettyDate(dueDate) : void 0,
|
|
15350
15409
|
url: url || void 0
|
|
@@ -15605,7 +15664,7 @@ var Container2 = dt.div`
|
|
|
15605
15664
|
import { Fragment as Fragment17, jsx as jsx35, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
15606
15665
|
var Limit = ({ entitlement, usageDetails, fontStyle }) => {
|
|
15607
15666
|
const { t: t2 } = useTranslation();
|
|
15608
|
-
const { feature, priceBehavior, usage, metricResetAt } = entitlement;
|
|
15667
|
+
const { feature, priceBehavior, allocation, usage, metricResetAt } = entitlement;
|
|
15609
15668
|
const { billingPrice, limit, cost, currentTier } = usageDetails;
|
|
15610
15669
|
const acc = [];
|
|
15611
15670
|
acc.push(
|
|
@@ -15616,15 +15675,15 @@ var Limit = ({ entitlement, usageDetails, fontStyle }) => {
|
|
|
15616
15675
|
feature: getFeatureName(feature)
|
|
15617
15676
|
}) : priceBehavior === "overage" /* Overage */ && typeof limit === "number" ? t2("X included", {
|
|
15618
15677
|
amount: formatNumber(limit)
|
|
15619
|
-
}) : priceBehavior === "pay_in_advance" /* PayInAdvance */ && typeof usage === "number" ? `${formatNumber(usage)} ${t2("used")}` : priceBehavior === "pay_as_you_go" /* PayAsYouGo */ && typeof cost === "number" ? formatCurrency(cost, billingPrice?.currency) : typeof
|
|
15620
|
-
amount: formatNumber(
|
|
15678
|
+
}) : priceBehavior === "pay_in_advance" /* PayInAdvance */ && typeof usage === "number" ? `${formatNumber(usage)} ${t2("used")}` : priceBehavior === "pay_as_you_go" /* PayAsYouGo */ && typeof cost === "number" ? formatCurrency(cost, billingPrice?.currency) : typeof allocation === "number" ? t2("Limit of", {
|
|
15679
|
+
amount: formatNumber(allocation)
|
|
15621
15680
|
}) : t2("No limit")
|
|
15622
15681
|
);
|
|
15623
15682
|
if (metricResetAt) {
|
|
15624
15683
|
acc.push(
|
|
15625
15684
|
t2("Resets", {
|
|
15626
15685
|
date: toPrettyDate(metricResetAt, {
|
|
15627
|
-
month: "
|
|
15686
|
+
month: "numeric",
|
|
15628
15687
|
day: "numeric",
|
|
15629
15688
|
year: void 0
|
|
15630
15689
|
})
|
|
@@ -16017,9 +16076,9 @@ var PaymentMethod = forwardRef10(({ children, className, portal, allowEdit = tru
|
|
|
16017
16076
|
const paymentMethod2 = data.subscription?.paymentMethod || data.company?.defaultPaymentMethod;
|
|
16018
16077
|
let monthsToExpiration2;
|
|
16019
16078
|
if (typeof paymentMethod2?.cardExpYear === "number" && typeof paymentMethod2?.cardExpMonth === "number") {
|
|
16020
|
-
const
|
|
16021
|
-
const currentYear =
|
|
16022
|
-
const currentMonth =
|
|
16079
|
+
const now = /* @__PURE__ */ new Date();
|
|
16080
|
+
const currentYear = now.getFullYear();
|
|
16081
|
+
const currentMonth = now.getMonth();
|
|
16023
16082
|
const timeToExpiration = Math.round(
|
|
16024
16083
|
+new Date(paymentMethod2.cardExpYear, paymentMethod2.cardExpMonth - 1) - +new Date(currentYear, currentMonth)
|
|
16025
16084
|
);
|
|
@@ -16093,7 +16152,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
|
16093
16152
|
}
|
|
16094
16153
|
stripe._registerWrapper({
|
|
16095
16154
|
name: "stripe-js",
|
|
16096
|
-
version: "7.
|
|
16155
|
+
version: "7.8.0",
|
|
16097
16156
|
startTime
|
|
16098
16157
|
});
|
|
16099
16158
|
};
|
|
@@ -16168,7 +16227,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
|
|
|
16168
16227
|
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
16169
16228
|
var expectedVersion = RELEASE_TRAIN;
|
|
16170
16229
|
if (isTestKey && version !== expectedVersion) {
|
|
16171
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.
|
|
16230
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.8.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
16172
16231
|
}
|
|
16173
16232
|
var stripe = maybeStripe.apply(void 0, args);
|
|
16174
16233
|
registerWrapper(stripe, startTime);
|
|
@@ -16256,9 +16315,9 @@ var PaymentMethodDetails = ({
|
|
|
16256
16315
|
const monthsToExpiration = useMemo21(() => {
|
|
16257
16316
|
let expiration;
|
|
16258
16317
|
if (typeof currentPaymentMethod?.cardExpYear === "number" && typeof currentPaymentMethod?.cardExpMonth === "number") {
|
|
16259
|
-
const
|
|
16260
|
-
const currentYear =
|
|
16261
|
-
const currentMonth =
|
|
16318
|
+
const now = /* @__PURE__ */ new Date();
|
|
16319
|
+
const currentYear = now.getFullYear();
|
|
16320
|
+
const currentMonth = now.getMonth();
|
|
16262
16321
|
const timeToExpiration = Math.round(
|
|
16263
16322
|
+new Date(
|
|
16264
16323
|
currentPaymentMethod.cardExpYear,
|
|
@@ -16326,9 +16385,10 @@ var PaymentMethodDetails = ({
|
|
|
16326
16385
|
);
|
|
16327
16386
|
useEffect7(() => {
|
|
16328
16387
|
if (!stripe && setupIntent) {
|
|
16329
|
-
|
|
16388
|
+
let publishableKey = setupIntent.publishableKey || setupIntent.schematicPublishableKey;
|
|
16330
16389
|
const stripeOptions = {};
|
|
16331
16390
|
if (setupIntent.accountId) {
|
|
16391
|
+
publishableKey = setupIntent.schematicPublishableKey;
|
|
16332
16392
|
stripeOptions.stripeAccount = setupIntent.accountId;
|
|
16333
16393
|
}
|
|
16334
16394
|
setStripe(loadStripe(publishableKey, stripeOptions));
|
|
@@ -16855,7 +16915,13 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
|
|
|
16855
16915
|
PlanManager.displayName = "PlanManager";
|
|
16856
16916
|
|
|
16857
16917
|
// src/components/elements/pricing-table/PricingTable.tsx
|
|
16858
|
-
import {
|
|
16918
|
+
import {
|
|
16919
|
+
Fragment as Fragment23,
|
|
16920
|
+
forwardRef as forwardRef12,
|
|
16921
|
+
useEffect as useEffect8,
|
|
16922
|
+
useMemo as useMemo26,
|
|
16923
|
+
useState as useState16
|
|
16924
|
+
} from "react";
|
|
16859
16925
|
|
|
16860
16926
|
// src/components/elements/pricing-table/AddOn.tsx
|
|
16861
16927
|
import { useMemo as useMemo24 } from "react";
|
|
@@ -16965,24 +17031,34 @@ var AddOn2 = ({ addOn, sharedProps, selectedPeriod }) => {
|
|
|
16965
17031
|
rounded: true
|
|
16966
17032
|
}
|
|
16967
17033
|
),
|
|
16968
|
-
|
|
16969
|
-
entitlement.valueType === "unlimited" /* Unlimited */ ?
|
|
16970
|
-
|
|
16971
|
-
|
|
16972
|
-
|
|
16973
|
-
|
|
16974
|
-
|
|
16975
|
-
|
|
16976
|
-
|
|
16977
|
-
|
|
16978
|
-
|
|
16979
|
-
|
|
16980
|
-
|
|
16981
|
-
|
|
16982
|
-
|
|
16983
|
-
|
|
16984
|
-
|
|
16985
|
-
|
|
17034
|
+
/* @__PURE__ */ jsxs34(Flex, { $flexDirection: "column", $gap: "0.5rem", children: [
|
|
17035
|
+
entitlement.feature?.name && /* @__PURE__ */ jsx42(Flex, { $alignItems: "center", $flexGrow: 1, children: /* @__PURE__ */ jsx42(Text, { children: entitlement.valueType === "numeric" /* Numeric */ || entitlement.valueType === "unlimited" /* Unlimited */ || entitlement.valueType === "trait" /* Trait */ ? /* @__PURE__ */ jsxs34(Fragment21, { children: [
|
|
17036
|
+
entitlement.valueType === "unlimited" /* Unlimited */ ? t2("Unlimited", {
|
|
17037
|
+
item: getFeatureName(entitlement.feature)
|
|
17038
|
+
}) : typeof entitlement.valueNumeric === "number" && /* @__PURE__ */ jsxs34(Fragment21, { children: [
|
|
17039
|
+
formatNumber(entitlement.valueNumeric),
|
|
17040
|
+
" ",
|
|
17041
|
+
getFeatureName(
|
|
17042
|
+
entitlement.feature,
|
|
17043
|
+
entitlement.valueNumeric
|
|
17044
|
+
)
|
|
17045
|
+
] }),
|
|
17046
|
+
metricPeriodName && /* @__PURE__ */ jsxs34(Fragment21, { children: [
|
|
17047
|
+
" ",
|
|
17048
|
+
t2("per"),
|
|
17049
|
+
" ",
|
|
17050
|
+
t2(metricPeriodName)
|
|
17051
|
+
] })
|
|
17052
|
+
] }) : entitlement.feature.name }) }),
|
|
17053
|
+
layout.plans.showFeatureDescriptions && entitlement.feature?.description && /* @__PURE__ */ jsx42(
|
|
17054
|
+
Text,
|
|
17055
|
+
{
|
|
17056
|
+
$size: 0.875 * settings.theme.typography.text.fontSize,
|
|
17057
|
+
$color: `color-mix(in oklch, ${settings.theme.typography.text.color}, ${settings.theme.card.background})`,
|
|
17058
|
+
children: entitlement.feature.description
|
|
17059
|
+
}
|
|
17060
|
+
)
|
|
17061
|
+
] })
|
|
16986
17062
|
] })
|
|
16987
17063
|
},
|
|
16988
17064
|
entitlementIndex
|
|
@@ -17062,85 +17138,95 @@ var Entitlement = ({
|
|
|
17062
17138
|
rounded: true
|
|
17063
17139
|
}
|
|
17064
17140
|
),
|
|
17065
|
-
entitlement.feature?.name && /* @__PURE__ */ jsxs35(Flex, { $flexDirection: "column", $
|
|
17066
|
-
/* @__PURE__ */
|
|
17067
|
-
|
|
17068
|
-
|
|
17069
|
-
t2("per"),
|
|
17070
|
-
" ",
|
|
17071
|
-
entitlementPackageSize > 1 && /* @__PURE__ */ jsxs35(Fragment22, { children: [
|
|
17072
|
-
entitlementPackageSize,
|
|
17073
|
-
" "
|
|
17074
|
-
] }),
|
|
17075
|
-
getFeatureName(entitlement.feature, entitlementPackageSize),
|
|
17076
|
-
entitlement.priceBehavior === "pay_in_advance" /* PayInAdvance */ && /* @__PURE__ */ jsxs35(Fragment22, { children: [
|
|
17141
|
+
entitlement.feature?.name && /* @__PURE__ */ jsxs35(Flex, { $flexDirection: "column", $gap: "0.5rem", children: [
|
|
17142
|
+
/* @__PURE__ */ jsxs35(Flex, { $flexDirection: "column", $justifyContent: "center", $flexGrow: 1, children: [
|
|
17143
|
+
/* @__PURE__ */ jsx43(Text, { children: typeof entitlementPrice === "number" && (entitlement.priceBehavior === "pay_in_advance" /* PayInAdvance */ || entitlement.priceBehavior === "pay_as_you_go" /* PayAsYouGo */) ? /* @__PURE__ */ jsxs35(Fragment22, { children: [
|
|
17144
|
+
formatCurrency(entitlementPrice, entitlementCurrency),
|
|
17077
17145
|
" ",
|
|
17078
17146
|
t2("per"),
|
|
17079
17147
|
" ",
|
|
17080
|
-
|
|
17081
|
-
|
|
17082
|
-
|
|
17083
|
-
|
|
17084
|
-
|
|
17085
|
-
entitlement,
|
|
17086
|
-
period: selectedPeriod
|
|
17087
|
-
}
|
|
17088
|
-
) : entitlement.valueType === "numeric" /* Numeric */ || entitlement.valueType === "unlimited" /* Unlimited */ || entitlement.valueType === "trait" /* Trait */ ? /* @__PURE__ */ jsxs35(Fragment22, { children: [
|
|
17089
|
-
entitlement.valueType === "unlimited" /* Unlimited */ && !entitlement.priceBehavior ? t2("Unlimited", {
|
|
17090
|
-
item: getFeatureName(entitlement.feature)
|
|
17091
|
-
}) : typeof limit === "number" && /* @__PURE__ */ jsxs35(Fragment22, { children: [
|
|
17092
|
-
formatNumber(limit),
|
|
17093
|
-
" ",
|
|
17094
|
-
getFeatureName(entitlement.feature, limit)
|
|
17095
|
-
] }),
|
|
17096
|
-
metricPeriodName && /* @__PURE__ */ jsxs35(Fragment22, { children: [
|
|
17097
|
-
" ",
|
|
17098
|
-
t2("per"),
|
|
17099
|
-
" ",
|
|
17100
|
-
t2(metricPeriodName)
|
|
17101
|
-
] })
|
|
17102
|
-
] }) : entitlement.feature.name }),
|
|
17103
|
-
entitlement.priceBehavior === "overage" /* Overage */ && typeof entitlementPrice === "number" ? /* @__PURE__ */ jsxs35(
|
|
17104
|
-
Text,
|
|
17105
|
-
{
|
|
17106
|
-
$size: 0.875 * settings.theme.typography.text.fontSize,
|
|
17107
|
-
$color: `color-mix(in oklch, ${settings.theme.typography.text.color}, ${settings.theme.card.background})`,
|
|
17108
|
-
children: [
|
|
17109
|
-
t2("then"),
|
|
17148
|
+
entitlementPackageSize > 1 && /* @__PURE__ */ jsxs35(Fragment22, { children: [
|
|
17149
|
+
entitlementPackageSize,
|
|
17150
|
+
" "
|
|
17151
|
+
] }),
|
|
17152
|
+
getFeatureName(entitlement.feature, entitlementPackageSize),
|
|
17153
|
+
entitlement.priceBehavior === "pay_in_advance" /* PayInAdvance */ && /* @__PURE__ */ jsxs35(Fragment22, { children: [
|
|
17110
17154
|
" ",
|
|
17111
|
-
|
|
17112
|
-
"
|
|
17113
|
-
|
|
17114
|
-
|
|
17115
|
-
|
|
17116
|
-
|
|
17117
|
-
getFeatureName(entitlement.feature, entitlementPackageSize),
|
|
17118
|
-
entitlement.feature.featureType === "trait" /* Trait */ && /* @__PURE__ */ jsxs35(Fragment22, { children: [
|
|
17119
|
-
"/",
|
|
17120
|
-
shortenPeriod(selectedPeriod)
|
|
17121
|
-
] })
|
|
17122
|
-
]
|
|
17123
|
-
}
|
|
17124
|
-
) : entitlement.priceBehavior === "tier" /* Tiered */ && /* @__PURE__ */ jsxs35(Flex, { $alignItems: "center", children: [
|
|
17125
|
-
/* @__PURE__ */ jsx43(
|
|
17126
|
-
PricingTiersTooltip,
|
|
17155
|
+
t2("per"),
|
|
17156
|
+
" ",
|
|
17157
|
+
selectedPeriod
|
|
17158
|
+
] })
|
|
17159
|
+
] }) : entitlement.priceBehavior === "tier" /* Tiered */ ? /* @__PURE__ */ jsx43(
|
|
17160
|
+
TieredPricingDetails,
|
|
17127
17161
|
{
|
|
17128
|
-
|
|
17129
|
-
period: selectedPeriod
|
|
17130
|
-
currency: entitlementCurrency,
|
|
17131
|
-
priceTiers: entitlementPriceTiers
|
|
17162
|
+
entitlement,
|
|
17163
|
+
period: selectedPeriod
|
|
17132
17164
|
}
|
|
17133
|
-
),
|
|
17134
|
-
|
|
17165
|
+
) : entitlement.valueType === "numeric" /* Numeric */ || entitlement.valueType === "unlimited" /* Unlimited */ || entitlement.valueType === "trait" /* Trait */ ? /* @__PURE__ */ jsxs35(Fragment22, { children: [
|
|
17166
|
+
entitlement.valueType === "unlimited" /* Unlimited */ && !entitlement.priceBehavior ? t2("Unlimited", {
|
|
17167
|
+
item: getFeatureName(entitlement.feature)
|
|
17168
|
+
}) : typeof limit === "number" && /* @__PURE__ */ jsxs35(Fragment22, { children: [
|
|
17169
|
+
formatNumber(limit),
|
|
17170
|
+
" ",
|
|
17171
|
+
getFeatureName(entitlement.feature, limit)
|
|
17172
|
+
] }),
|
|
17173
|
+
metricPeriodName && /* @__PURE__ */ jsxs35(Fragment22, { children: [
|
|
17174
|
+
" ",
|
|
17175
|
+
t2("per"),
|
|
17176
|
+
" ",
|
|
17177
|
+
t2(metricPeriodName)
|
|
17178
|
+
] })
|
|
17179
|
+
] }) : entitlement.feature.name }),
|
|
17180
|
+
entitlement.priceBehavior === "overage" /* Overage */ && typeof entitlementPrice === "number" ? /* @__PURE__ */ jsxs35(
|
|
17135
17181
|
Text,
|
|
17136
17182
|
{
|
|
17137
|
-
style: { opacity: 0.54 },
|
|
17138
17183
|
$size: 0.875 * settings.theme.typography.text.fontSize,
|
|
17139
|
-
$color: settings.theme.typography.text.color,
|
|
17140
|
-
children:
|
|
17184
|
+
$color: `color-mix(in oklch, ${settings.theme.typography.text.color}, ${settings.theme.card.background})`,
|
|
17185
|
+
children: [
|
|
17186
|
+
t2("then"),
|
|
17187
|
+
" ",
|
|
17188
|
+
formatCurrency(entitlementPrice, entitlementCurrency),
|
|
17189
|
+
"/",
|
|
17190
|
+
entitlementPackageSize > 1 && /* @__PURE__ */ jsxs35(Fragment22, { children: [
|
|
17191
|
+
entitlementPackageSize,
|
|
17192
|
+
" "
|
|
17193
|
+
] }),
|
|
17194
|
+
getFeatureName(entitlement.feature, entitlementPackageSize),
|
|
17195
|
+
entitlement.feature.featureType === "trait" /* Trait */ && /* @__PURE__ */ jsxs35(Fragment22, { children: [
|
|
17196
|
+
"/",
|
|
17197
|
+
shortenPeriod(selectedPeriod)
|
|
17198
|
+
] })
|
|
17199
|
+
]
|
|
17141
17200
|
}
|
|
17142
|
-
)
|
|
17143
|
-
|
|
17201
|
+
) : entitlement.priceBehavior === "tier" /* Tiered */ && /* @__PURE__ */ jsxs35(Flex, { $alignItems: "center", children: [
|
|
17202
|
+
/* @__PURE__ */ jsx43(
|
|
17203
|
+
PricingTiersTooltip,
|
|
17204
|
+
{
|
|
17205
|
+
feature: entitlement.feature,
|
|
17206
|
+
period: selectedPeriod,
|
|
17207
|
+
currency: entitlementCurrency,
|
|
17208
|
+
priceTiers: entitlementPriceTiers
|
|
17209
|
+
}
|
|
17210
|
+
),
|
|
17211
|
+
/* @__PURE__ */ jsx43(
|
|
17212
|
+
Text,
|
|
17213
|
+
{
|
|
17214
|
+
style: { opacity: 0.54 },
|
|
17215
|
+
$size: 0.875 * settings.theme.typography.text.fontSize,
|
|
17216
|
+
$color: settings.theme.typography.text.color,
|
|
17217
|
+
children: t2("Tier-based")
|
|
17218
|
+
}
|
|
17219
|
+
)
|
|
17220
|
+
] })
|
|
17221
|
+
] }),
|
|
17222
|
+
layout.plans.showFeatureDescriptions && entitlement.feature?.description && /* @__PURE__ */ jsx43(
|
|
17223
|
+
Text,
|
|
17224
|
+
{
|
|
17225
|
+
$size: 0.875 * settings.theme.typography.text.fontSize,
|
|
17226
|
+
$color: `color-mix(in oklch, ${settings.theme.typography.text.color}, ${settings.theme.card.background})`,
|
|
17227
|
+
children: entitlement.feature.description
|
|
17228
|
+
}
|
|
17229
|
+
)
|
|
17144
17230
|
] })
|
|
17145
17231
|
] });
|
|
17146
17232
|
};
|
|
@@ -17156,7 +17242,7 @@ var Plan2 = ({
|
|
|
17156
17242
|
entitlementCounts,
|
|
17157
17243
|
handleToggleShowAll
|
|
17158
17244
|
}) => {
|
|
17159
|
-
const { layout
|
|
17245
|
+
const { layout } = sharedProps;
|
|
17160
17246
|
const { t: t2 } = useTranslation();
|
|
17161
17247
|
const { data, settings, setCheckoutState } = useEmbed();
|
|
17162
17248
|
const isLightBackground = useIsLightBackground();
|
|
@@ -17188,9 +17274,24 @@ var Plan2 = ({
|
|
|
17188
17274
|
isTrialSubscription: false,
|
|
17189
17275
|
willSubscriptionCancel: false,
|
|
17190
17276
|
isStandalone: true,
|
|
17191
|
-
showCallToAction: typeof callToActionUrl === "string"
|
|
17277
|
+
showCallToAction: typeof sharedProps.callToActionUrl === "string" || typeof sharedProps.onCallToAction === "function"
|
|
17192
17278
|
};
|
|
17193
|
-
}, [data, callToActionUrl]);
|
|
17279
|
+
}, [data, sharedProps.callToActionUrl, sharedProps.onCallToAction]);
|
|
17280
|
+
const callToActionTarget = useMemo25(() => {
|
|
17281
|
+
if (sharedProps.callToActionTarget) {
|
|
17282
|
+
return sharedProps.callToActionTarget;
|
|
17283
|
+
}
|
|
17284
|
+
if (sharedProps.callToActionUrl) {
|
|
17285
|
+
try {
|
|
17286
|
+
const ctaUrlOrigin = new URL(sharedProps.callToActionUrl).origin;
|
|
17287
|
+
if (ctaUrlOrigin === window.location.hostname) {
|
|
17288
|
+
return "_self";
|
|
17289
|
+
}
|
|
17290
|
+
} catch {
|
|
17291
|
+
}
|
|
17292
|
+
}
|
|
17293
|
+
return "_blank";
|
|
17294
|
+
}, [sharedProps.callToActionUrl, sharedProps.callToActionTarget]);
|
|
17194
17295
|
const cardPadding = settings.theme.card.padding / TEXT_BASE_SIZE;
|
|
17195
17296
|
const currentPlanIndex = plans.findIndex(
|
|
17196
17297
|
(plan2) => isHydratedPlan(plan2) && plan2.current
|
|
@@ -17289,7 +17390,7 @@ var Plan2 = ({
|
|
|
17289
17390
|
Entitlement,
|
|
17290
17391
|
{
|
|
17291
17392
|
entitlement,
|
|
17292
|
-
sharedProps: { layout
|
|
17393
|
+
sharedProps: { layout },
|
|
17293
17394
|
selectedPeriod
|
|
17294
17395
|
},
|
|
17295
17396
|
idx
|
|
@@ -17367,14 +17468,14 @@ var Plan2 = ({
|
|
|
17367
17468
|
href: plan.customPlanConfig?.ctaWebSite ?? "#",
|
|
17368
17469
|
target: "_blank",
|
|
17369
17470
|
rel: "noreferrer"
|
|
17370
|
-
} : callToActionUrl ? {
|
|
17471
|
+
} : sharedProps.callToActionUrl ? {
|
|
17371
17472
|
as: "a",
|
|
17372
|
-
href: callToActionUrl,
|
|
17373
|
-
target:
|
|
17473
|
+
href: sharedProps.callToActionUrl,
|
|
17474
|
+
target: callToActionTarget,
|
|
17374
17475
|
rel: "noreferrer"
|
|
17375
17476
|
} : {
|
|
17376
17477
|
onClick: () => {
|
|
17377
|
-
onCallToAction?.(plan);
|
|
17478
|
+
sharedProps.onCallToAction?.(plan);
|
|
17378
17479
|
if (!isStandalone && isHydratedPlan(plan) && !plan.custom) {
|
|
17379
17480
|
setCheckoutState({
|
|
17380
17481
|
period: selectedPeriod,
|
|
@@ -17388,7 +17489,7 @@ var Plan2 = ({
|
|
|
17388
17489
|
children: plan.custom ? plan.customPlanConfig?.ctaText ?? t2("Talk to support") : isHydratedPlan(plan) && !plan.valid ? /* @__PURE__ */ jsx44(
|
|
17389
17490
|
Tooltip,
|
|
17390
17491
|
{
|
|
17391
|
-
trigger: /* @__PURE__ */ jsx44(Text, { children: t2("Over usage limit") }),
|
|
17492
|
+
trigger: /* @__PURE__ */ jsx44(Text, { as: Box, $align: "center", children: t2("Over usage limit") }),
|
|
17392
17493
|
content: /* @__PURE__ */ jsx44(Text, { children: t2("Current usage exceeds the limit of this plan.") })
|
|
17393
17494
|
}
|
|
17394
17495
|
) : isHydratedPlan(plan) && plan.companyCanTrial && plan.isTrialable ? t2("Start X day trial", { days: plan.trialDays }) : t2("Choose plan")
|
|
@@ -17423,12 +17524,14 @@ var resolveDesignProps8 = (props) => {
|
|
|
17423
17524
|
},
|
|
17424
17525
|
showInclusionText: props.plans?.showInclusionText ?? true,
|
|
17425
17526
|
showFeatureIcons: props.plans?.showFeatureIcons ?? true,
|
|
17527
|
+
showFeatureDescriptions: props.plans?.showFeatureDescriptions ?? true,
|
|
17426
17528
|
showEntitlements: props.plans?.showEntitlements ?? true
|
|
17427
17529
|
},
|
|
17428
17530
|
addOns: {
|
|
17429
17531
|
isVisible: props.addOns?.isVisible ?? true,
|
|
17430
17532
|
showDescription: props.addOns?.showDescription ?? true,
|
|
17431
17533
|
showFeatureIcons: props.addOns?.showFeatureIcons ?? true,
|
|
17534
|
+
showFeatureDescriptions: props.plans?.showFeatureDescriptions ?? true,
|
|
17432
17535
|
showEntitlements: props.addOns?.showEntitlements ?? true
|
|
17433
17536
|
},
|
|
17434
17537
|
upgrade: {
|
|
@@ -17443,181 +17546,183 @@ var resolveDesignProps8 = (props) => {
|
|
|
17443
17546
|
}
|
|
17444
17547
|
};
|
|
17445
17548
|
};
|
|
17446
|
-
var PricingTable = forwardRef12(
|
|
17447
|
-
|
|
17448
|
-
|
|
17449
|
-
|
|
17450
|
-
|
|
17451
|
-
|
|
17452
|
-
|
|
17453
|
-
|
|
17454
|
-
|
|
17455
|
-
|
|
17456
|
-
currentPeriod: data.company?.plan?.planPeriod || "month",
|
|
17457
|
-
currentAddOns: data.company?.addOns || [],
|
|
17458
|
-
canCheckout: data.capabilities?.checkout ?? true,
|
|
17459
|
-
isTrialSubscription,
|
|
17460
|
-
willSubscriptionCancel,
|
|
17461
|
-
isStandalone: false,
|
|
17462
|
-
showCallToAction: true
|
|
17463
|
-
};
|
|
17464
|
-
}
|
|
17465
|
-
return {
|
|
17466
|
-
currentPeriod: "month",
|
|
17467
|
-
currentAddOns: [],
|
|
17468
|
-
canCheckout: true,
|
|
17469
|
-
isTrialSubscription: false,
|
|
17470
|
-
willSubscriptionCancel: false,
|
|
17471
|
-
isStandalone: true,
|
|
17472
|
-
showCallToAction: typeof callToActionUrl === "string"
|
|
17473
|
-
};
|
|
17474
|
-
}, [data, callToActionUrl]);
|
|
17475
|
-
const [selectedPeriod, setSelectedPeriod] = useState16(currentPeriod);
|
|
17476
|
-
const { plans, addOns, periods } = useAvailablePlans(selectedPeriod);
|
|
17477
|
-
const [entitlementCounts, setEntitlementCounts] = useState16(
|
|
17478
|
-
() => plans.reduce(entitlementCountsReducer, {})
|
|
17479
|
-
);
|
|
17480
|
-
const handleToggleShowAll = (id) => {
|
|
17481
|
-
setEntitlementCounts((prev2) => {
|
|
17482
|
-
const count = prev2[id] ? { ...prev2[id] } : void 0;
|
|
17483
|
-
if (count) {
|
|
17549
|
+
var PricingTable = forwardRef12(
|
|
17550
|
+
({ className, callToActionUrl, callToActionTarget, onCallToAction, ...rest }, ref) => {
|
|
17551
|
+
const props = resolveDesignProps8(rest);
|
|
17552
|
+
const { t: t2 } = useTranslation();
|
|
17553
|
+
const { data, settings, hydratePublic } = useEmbed();
|
|
17554
|
+
const { currentPeriod, isStandalone } = useMemo26(() => {
|
|
17555
|
+
if (isCheckoutData(data)) {
|
|
17556
|
+
const billingSubscription = data.company?.billingSubscription;
|
|
17557
|
+
const isTrialSubscription = billingSubscription?.status === "trialing";
|
|
17558
|
+
const willSubscriptionCancel = billingSubscription?.cancelAt;
|
|
17484
17559
|
return {
|
|
17485
|
-
|
|
17486
|
-
[
|
|
17487
|
-
|
|
17488
|
-
|
|
17489
|
-
|
|
17560
|
+
currentPeriod: data.company?.plan?.planPeriod || "month",
|
|
17561
|
+
currentAddOns: data.company?.addOns || [],
|
|
17562
|
+
canCheckout: data.capabilities?.checkout ?? true,
|
|
17563
|
+
isTrialSubscription,
|
|
17564
|
+
willSubscriptionCancel,
|
|
17565
|
+
isStandalone: false
|
|
17490
17566
|
};
|
|
17491
17567
|
}
|
|
17492
|
-
return
|
|
17493
|
-
|
|
17494
|
-
|
|
17495
|
-
|
|
17496
|
-
|
|
17497
|
-
|
|
17498
|
-
|
|
17499
|
-
|
|
17500
|
-
|
|
17501
|
-
|
|
17502
|
-
|
|
17503
|
-
|
|
17504
|
-
|
|
17505
|
-
|
|
17506
|
-
{
|
|
17507
|
-
|
|
17508
|
-
|
|
17509
|
-
|
|
17510
|
-
|
|
17511
|
-
|
|
17512
|
-
|
|
17513
|
-
|
|
17514
|
-
|
|
17515
|
-
|
|
17516
|
-
|
|
17517
|
-
|
|
17518
|
-
|
|
17519
|
-
|
|
17520
|
-
|
|
17521
|
-
|
|
17522
|
-
|
|
17523
|
-
|
|
17524
|
-
|
|
17525
|
-
|
|
17526
|
-
|
|
17527
|
-
|
|
17528
|
-
|
|
17529
|
-
|
|
17568
|
+
return {
|
|
17569
|
+
currentPeriod: "month",
|
|
17570
|
+
currentAddOns: [],
|
|
17571
|
+
canCheckout: true,
|
|
17572
|
+
isTrialSubscription: false,
|
|
17573
|
+
willSubscriptionCancel: false,
|
|
17574
|
+
isStandalone: true
|
|
17575
|
+
};
|
|
17576
|
+
}, [data]);
|
|
17577
|
+
const [selectedPeriod, setSelectedPeriod] = useState16(currentPeriod);
|
|
17578
|
+
const { plans, addOns, periods } = useAvailablePlans(selectedPeriod);
|
|
17579
|
+
const [entitlementCounts, setEntitlementCounts] = useState16(
|
|
17580
|
+
() => plans.reduce(entitlementCountsReducer, {})
|
|
17581
|
+
);
|
|
17582
|
+
const handleToggleShowAll = (id) => {
|
|
17583
|
+
setEntitlementCounts((prev2) => {
|
|
17584
|
+
const count = prev2[id] ? { ...prev2[id] } : void 0;
|
|
17585
|
+
if (count) {
|
|
17586
|
+
return {
|
|
17587
|
+
...prev2,
|
|
17588
|
+
[id]: {
|
|
17589
|
+
size: count.size,
|
|
17590
|
+
limit: count.limit > VISIBLE_ENTITLEMENT_COUNT ? VISIBLE_ENTITLEMENT_COUNT : count.size
|
|
17591
|
+
}
|
|
17592
|
+
};
|
|
17593
|
+
}
|
|
17594
|
+
return prev2;
|
|
17595
|
+
});
|
|
17596
|
+
};
|
|
17597
|
+
useEffect8(() => {
|
|
17598
|
+
if (isStandalone) {
|
|
17599
|
+
hydratePublic();
|
|
17600
|
+
}
|
|
17601
|
+
}, [isStandalone, hydratePublic]);
|
|
17602
|
+
useEffect8(() => {
|
|
17603
|
+
setEntitlementCounts(plans.reduce(entitlementCountsReducer, {}));
|
|
17604
|
+
}, [plans]);
|
|
17605
|
+
const Wrapper = isStandalone ? Container : Fragment23;
|
|
17606
|
+
return /* @__PURE__ */ jsx45(Wrapper, { children: /* @__PURE__ */ jsxs37(
|
|
17607
|
+
FussyChild,
|
|
17608
|
+
{
|
|
17609
|
+
ref,
|
|
17610
|
+
className: `sch-PricingTable ${className}`,
|
|
17611
|
+
as: Flex,
|
|
17612
|
+
$flexDirection: "column",
|
|
17613
|
+
$gap: "2rem",
|
|
17614
|
+
children: [
|
|
17615
|
+
/* @__PURE__ */ jsxs37(Box, { children: [
|
|
17616
|
+
/* @__PURE__ */ jsxs37(
|
|
17617
|
+
Flex,
|
|
17618
|
+
{
|
|
17619
|
+
$flexDirection: "column",
|
|
17620
|
+
$justifyContent: "center",
|
|
17621
|
+
$alignItems: "center",
|
|
17622
|
+
$gap: "1rem",
|
|
17623
|
+
$marginBottom: "1rem",
|
|
17624
|
+
$viewport: {
|
|
17625
|
+
md: {
|
|
17626
|
+
$flexDirection: "row",
|
|
17627
|
+
$justifyContent: "space-between"
|
|
17628
|
+
}
|
|
17629
|
+
},
|
|
17630
|
+
children: [
|
|
17631
|
+
/* @__PURE__ */ jsx45(
|
|
17632
|
+
Text,
|
|
17633
|
+
{
|
|
17634
|
+
display: props.header.fontStyle,
|
|
17635
|
+
$color: settings.theme.card.background,
|
|
17636
|
+
children: props.header.isVisible && props.plans.isVisible && plans.length > 0 && t2("Plans")
|
|
17637
|
+
}
|
|
17638
|
+
),
|
|
17639
|
+
props.showPeriodToggle && periods.length > 1 && /* @__PURE__ */ jsx45(
|
|
17640
|
+
PeriodToggle,
|
|
17641
|
+
{
|
|
17642
|
+
options: periods,
|
|
17643
|
+
selectedOption: selectedPeriod,
|
|
17644
|
+
onSelect: (period) => {
|
|
17645
|
+
if (period !== selectedPeriod) {
|
|
17646
|
+
setSelectedPeriod(period);
|
|
17647
|
+
}
|
|
17648
|
+
}
|
|
17649
|
+
}
|
|
17650
|
+
)
|
|
17651
|
+
]
|
|
17652
|
+
}
|
|
17653
|
+
),
|
|
17654
|
+
props.plans.isVisible && plans.length > 0 && /* @__PURE__ */ jsx45(
|
|
17655
|
+
Box,
|
|
17656
|
+
{
|
|
17657
|
+
$display: "grid",
|
|
17658
|
+
$gridTemplateColumns: "repeat(auto-fill, minmax(320px, 1fr))",
|
|
17659
|
+
$gap: "1rem",
|
|
17660
|
+
children: plans.map((plan, index, self2) => /* @__PURE__ */ jsx45(
|
|
17661
|
+
Plan2,
|
|
17662
|
+
{
|
|
17663
|
+
plan,
|
|
17664
|
+
index,
|
|
17665
|
+
sharedProps: {
|
|
17666
|
+
layout: props,
|
|
17667
|
+
callToActionUrl,
|
|
17668
|
+
callToActionTarget,
|
|
17669
|
+
onCallToAction
|
|
17670
|
+
},
|
|
17671
|
+
plans: self2,
|
|
17672
|
+
selectedPeriod,
|
|
17673
|
+
entitlementCounts,
|
|
17674
|
+
handleToggleShowAll
|
|
17675
|
+
},
|
|
17676
|
+
index
|
|
17677
|
+
))
|
|
17678
|
+
}
|
|
17679
|
+
)
|
|
17680
|
+
] }),
|
|
17681
|
+
/* @__PURE__ */ jsx45(Box, { children: props.addOns.isVisible && addOns.length > 0 && /* @__PURE__ */ jsxs37(Fragment24, { children: [
|
|
17682
|
+
props.header.isVisible && /* @__PURE__ */ jsx45(
|
|
17683
|
+
Flex,
|
|
17684
|
+
{
|
|
17685
|
+
$justifyContent: "space-between",
|
|
17686
|
+
$alignItems: "center",
|
|
17687
|
+
$marginBottom: "1rem",
|
|
17688
|
+
children: /* @__PURE__ */ jsx45(
|
|
17530
17689
|
Text,
|
|
17531
17690
|
{
|
|
17532
17691
|
display: props.header.fontStyle,
|
|
17533
17692
|
$color: settings.theme.card.background,
|
|
17534
|
-
children:
|
|
17535
|
-
}
|
|
17536
|
-
),
|
|
17537
|
-
props.showPeriodToggle && periods.length > 1 && /* @__PURE__ */ jsx45(
|
|
17538
|
-
PeriodToggle,
|
|
17539
|
-
{
|
|
17540
|
-
options: periods,
|
|
17541
|
-
selectedOption: selectedPeriod,
|
|
17542
|
-
onSelect: (period) => {
|
|
17543
|
-
if (period !== selectedPeriod) {
|
|
17544
|
-
setSelectedPeriod(period);
|
|
17545
|
-
}
|
|
17546
|
-
}
|
|
17693
|
+
children: t2("Add-ons")
|
|
17547
17694
|
}
|
|
17548
17695
|
)
|
|
17549
|
-
|
|
17550
|
-
|
|
17551
|
-
|
|
17552
|
-
|
|
17553
|
-
|
|
17554
|
-
|
|
17555
|
-
|
|
17556
|
-
|
|
17557
|
-
|
|
17558
|
-
|
|
17559
|
-
|
|
17560
|
-
|
|
17561
|
-
|
|
17562
|
-
|
|
17563
|
-
|
|
17564
|
-
|
|
17565
|
-
|
|
17566
|
-
|
|
17567
|
-
|
|
17568
|
-
plans: self2,
|
|
17569
|
-
selectedPeriod,
|
|
17570
|
-
entitlementCounts,
|
|
17571
|
-
handleToggleShowAll
|
|
17572
|
-
},
|
|
17573
|
-
index
|
|
17574
|
-
))
|
|
17575
|
-
}
|
|
17576
|
-
)
|
|
17577
|
-
] }),
|
|
17578
|
-
/* @__PURE__ */ jsx45(Box, { children: props.addOns.isVisible && addOns.length > 0 && /* @__PURE__ */ jsxs37(Fragment24, { children: [
|
|
17579
|
-
props.header.isVisible && /* @__PURE__ */ jsx45(
|
|
17580
|
-
Flex,
|
|
17581
|
-
{
|
|
17582
|
-
$justifyContent: "space-between",
|
|
17583
|
-
$alignItems: "center",
|
|
17584
|
-
$marginBottom: "1rem",
|
|
17585
|
-
children: /* @__PURE__ */ jsx45(
|
|
17586
|
-
Text,
|
|
17587
|
-
{
|
|
17588
|
-
display: props.header.fontStyle,
|
|
17589
|
-
$color: settings.theme.card.background,
|
|
17590
|
-
children: t2("Add-ons")
|
|
17591
|
-
}
|
|
17592
|
-
)
|
|
17593
|
-
}
|
|
17594
|
-
),
|
|
17595
|
-
/* @__PURE__ */ jsx45(
|
|
17596
|
-
Box,
|
|
17597
|
-
{
|
|
17598
|
-
$display: "grid",
|
|
17599
|
-
$gridTemplateColumns: "repeat(auto-fill, minmax(320px, 1fr))",
|
|
17600
|
-
$gap: "1rem",
|
|
17601
|
-
children: addOns.map((addOn, index) => /* @__PURE__ */ jsx45(
|
|
17602
|
-
AddOn2,
|
|
17603
|
-
{
|
|
17604
|
-
addOn,
|
|
17605
|
-
sharedProps: {
|
|
17606
|
-
layout: props,
|
|
17607
|
-
callToActionUrl,
|
|
17608
|
-
onCallToAction
|
|
17696
|
+
}
|
|
17697
|
+
),
|
|
17698
|
+
/* @__PURE__ */ jsx45(
|
|
17699
|
+
Box,
|
|
17700
|
+
{
|
|
17701
|
+
$display: "grid",
|
|
17702
|
+
$gridTemplateColumns: "repeat(auto-fill, minmax(320px, 1fr))",
|
|
17703
|
+
$gap: "1rem",
|
|
17704
|
+
children: addOns.map((addOn, index) => /* @__PURE__ */ jsx45(
|
|
17705
|
+
AddOn2,
|
|
17706
|
+
{
|
|
17707
|
+
addOn,
|
|
17708
|
+
sharedProps: {
|
|
17709
|
+
layout: props,
|
|
17710
|
+
callToActionUrl,
|
|
17711
|
+
callToActionTarget,
|
|
17712
|
+
onCallToAction
|
|
17713
|
+
},
|
|
17714
|
+
selectedPeriod
|
|
17609
17715
|
},
|
|
17610
|
-
|
|
17611
|
-
|
|
17612
|
-
|
|
17613
|
-
|
|
17614
|
-
|
|
17615
|
-
|
|
17616
|
-
|
|
17617
|
-
|
|
17618
|
-
|
|
17619
|
-
|
|
17620
|
-
});
|
|
17716
|
+
index
|
|
17717
|
+
))
|
|
17718
|
+
}
|
|
17719
|
+
)
|
|
17720
|
+
] }) })
|
|
17721
|
+
]
|
|
17722
|
+
}
|
|
17723
|
+
) });
|
|
17724
|
+
}
|
|
17725
|
+
);
|
|
17621
17726
|
PricingTable.displayName = "PricingTable";
|
|
17622
17727
|
|
|
17623
17728
|
// src/components/elements/text/Text.tsx
|