@schematichq/schematic-components 0.7.12 → 0.7.14
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 +337 -220
- package/dist/schematic-components.d.ts +16 -60
- package/dist/schematic-components.esm.js +367 -250
- package/package.json +15 -15
|
@@ -6745,9 +6745,9 @@ var unitlessKeys = {
|
|
|
6745
6745
|
var f = "undefined" != typeof process && void 0 !== process.env && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR) || "data-styled";
|
|
6746
6746
|
var m = "active";
|
|
6747
6747
|
var y = "data-styled-version";
|
|
6748
|
-
var v = "6.1.
|
|
6748
|
+
var v = "6.1.18";
|
|
6749
6749
|
var g = "/*!sc*/\n";
|
|
6750
|
-
var S = "undefined" != typeof window && "
|
|
6750
|
+
var S = "undefined" != typeof window && "undefined" != typeof document;
|
|
6751
6751
|
var w = Boolean("boolean" == typeof SC_DISABLE_SPEEDY ? SC_DISABLE_SPEEDY : "undefined" != typeof process && void 0 !== process.env && void 0 !== process.env.REACT_APP_SC_DISABLE_SPEEDY && "" !== process.env.REACT_APP_SC_DISABLE_SPEEDY ? "false" !== process.env.REACT_APP_SC_DISABLE_SPEEDY && process.env.REACT_APP_SC_DISABLE_SPEEDY : "undefined" != typeof process && void 0 !== process.env && void 0 !== process.env.SC_DISABLE_SPEEDY && "" !== process.env.SC_DISABLE_SPEEDY ? "false" !== process.env.SC_DISABLE_SPEEDY && process.env.SC_DISABLE_SPEEDY : true);
|
|
6752
6752
|
var b = {};
|
|
6753
6753
|
var E = /invalid hook call/i;
|
|
@@ -8166,13 +8166,14 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
8166
8166
|
if (lng) this.language = lng;
|
|
8167
8167
|
}
|
|
8168
8168
|
exists(key) {
|
|
8169
|
-
let
|
|
8169
|
+
let o2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
8170
8170
|
interpolation: {}
|
|
8171
8171
|
};
|
|
8172
|
-
|
|
8173
|
-
|
|
8174
|
-
}
|
|
8175
|
-
|
|
8172
|
+
const opt = {
|
|
8173
|
+
...o2
|
|
8174
|
+
};
|
|
8175
|
+
if (key == null) return false;
|
|
8176
|
+
const resolved = this.resolve(key, opt);
|
|
8176
8177
|
return resolved?.res !== void 0;
|
|
8177
8178
|
}
|
|
8178
8179
|
extractFromKey(key, opt) {
|
|
@@ -8199,7 +8200,10 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
8199
8200
|
namespaces: isString(namespaces) ? [namespaces] : namespaces
|
|
8200
8201
|
};
|
|
8201
8202
|
}
|
|
8202
|
-
translate(keys,
|
|
8203
|
+
translate(keys, o2, lastKey) {
|
|
8204
|
+
let opt = typeof o2 === "object" ? {
|
|
8205
|
+
...o2
|
|
8206
|
+
} : o2;
|
|
8203
8207
|
if (typeof opt !== "object" && this.options.overloadTranslationOptionHandler) {
|
|
8204
8208
|
opt = this.options.overloadTranslationOptionHandler(arguments);
|
|
8205
8209
|
}
|
|
@@ -8377,7 +8381,7 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
8377
8381
|
res = this.extendTranslation(res, keys, opt, resolved, lastKey);
|
|
8378
8382
|
if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
|
|
8379
8383
|
if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
|
|
8380
|
-
res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : void 0);
|
|
8384
|
+
res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : void 0, opt);
|
|
8381
8385
|
}
|
|
8382
8386
|
}
|
|
8383
8387
|
if (returnDetails) {
|
|
@@ -9658,7 +9662,7 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
9658
9662
|
}
|
|
9659
9663
|
if (!this.resolvedLanguage && this.languages.indexOf(l2) < 0 && this.store.hasLanguageSomeTranslations(l2)) {
|
|
9660
9664
|
this.resolvedLanguage = l2;
|
|
9661
|
-
|
|
9665
|
+
this.languages.unshift(l2);
|
|
9662
9666
|
}
|
|
9663
9667
|
}
|
|
9664
9668
|
changeLanguage(lng, callback) {
|
|
@@ -9872,12 +9876,13 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
9872
9876
|
prev2[l2] = {
|
|
9873
9877
|
...this.store.data[l2]
|
|
9874
9878
|
};
|
|
9875
|
-
|
|
9879
|
+
prev2[l2] = Object.keys(prev2[l2]).reduce((acc, n) => {
|
|
9876
9880
|
acc[n] = {
|
|
9877
9881
|
...prev2[l2][n]
|
|
9878
9882
|
};
|
|
9879
9883
|
return acc;
|
|
9880
|
-
},
|
|
9884
|
+
}, prev2[l2]);
|
|
9885
|
+
return prev2;
|
|
9881
9886
|
}, {});
|
|
9882
9887
|
clone.store = new ResourceStore(clonedData, mergedOptions);
|
|
9883
9888
|
clone.services.resourceStore = clone.store;
|
|
@@ -14734,6 +14739,8 @@ function BillingPriceViewFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
14734
14739
|
id: json["id"],
|
|
14735
14740
|
interval: json["interval"],
|
|
14736
14741
|
isActive: json["is_active"],
|
|
14742
|
+
meterEventName: json["meter_event_name"] == null ? void 0 : json["meter_event_name"],
|
|
14743
|
+
meterEventPayloadKey: json["meter_event_payload_key"] == null ? void 0 : json["meter_event_payload_key"],
|
|
14737
14744
|
meterId: json["meter_id"] == null ? void 0 : json["meter_id"],
|
|
14738
14745
|
packageSize: json["package_size"],
|
|
14739
14746
|
price: json["price"],
|
|
@@ -15274,12 +15281,12 @@ function EventSummaryResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
15274
15281
|
return json;
|
|
15275
15282
|
}
|
|
15276
15283
|
return {
|
|
15277
|
-
companyCount: json["company_count"],
|
|
15284
|
+
companyCount: json["company_count"] == null ? void 0 : json["company_count"],
|
|
15278
15285
|
environmentId: json["environment_id"],
|
|
15279
15286
|
eventCount: json["event_count"],
|
|
15280
15287
|
eventSubtype: json["event_subtype"],
|
|
15281
15288
|
lastSeenAt: json["last_seen_at"] == null ? void 0 : new Date(json["last_seen_at"]),
|
|
15282
|
-
userCount: json["user_count"]
|
|
15289
|
+
userCount: json["user_count"] == null ? void 0 : json["user_count"]
|
|
15283
15290
|
};
|
|
15284
15291
|
}
|
|
15285
15292
|
|
|
@@ -16416,7 +16423,7 @@ var en_default = {
|
|
|
16416
16423
|
Monthly: "Monthly",
|
|
16417
16424
|
Next: "Next",
|
|
16418
16425
|
"No limit": "No limit",
|
|
16419
|
-
"No payment method
|
|
16426
|
+
"No payment method added yet": "No payment method added yet",
|
|
16420
16427
|
"Not ready to cancel?": "Not ready to cancel?",
|
|
16421
16428
|
"On demand": "On demand",
|
|
16422
16429
|
"One time ": "One time",
|
|
@@ -16426,6 +16433,7 @@ var en_default = {
|
|
|
16426
16433
|
"Pay now": "Pay now",
|
|
16427
16434
|
"Payment Method": "Payment Method",
|
|
16428
16435
|
"Percent off": "{{percent}}% off",
|
|
16436
|
+
"Plan selected": "Plan selected",
|
|
16429
16437
|
Plan: "Plan",
|
|
16430
16438
|
Plans: "Plans",
|
|
16431
16439
|
"Please provide an access token.": "Please provide an access token.",
|
|
@@ -16439,6 +16447,7 @@ var en_default = {
|
|
|
16439
16447
|
"See less": "See less",
|
|
16440
16448
|
"See more": "See more",
|
|
16441
16449
|
"Select add-ons": "Select add-ons",
|
|
16450
|
+
"Select existing payment method": "Select existing payment method",
|
|
16442
16451
|
"Select payment method": "Select payment method",
|
|
16443
16452
|
"Select plan": "Select plan",
|
|
16444
16453
|
"Select quantity": "Select quantity",
|
|
@@ -16446,13 +16455,15 @@ var en_default = {
|
|
|
16446
16455
|
"Session expired. Please refresh and try again.": "Session expired. Please refresh and try again.",
|
|
16447
16456
|
"Show details": "Show details",
|
|
16448
16457
|
"Start trial": "Start trial",
|
|
16458
|
+
"Start X day trial": "Start {{days}} day trial",
|
|
16449
16459
|
"Subscribe and close": "Subscribe and close",
|
|
16450
16460
|
"Subscription canceled": "Subscription canceled",
|
|
16451
16461
|
Subscription: "Subscription",
|
|
16452
16462
|
"Talk to support": "Talk to support",
|
|
16453
16463
|
Total: "Total",
|
|
16454
16464
|
"Trial ends in": "Trial ends in {{days}} days",
|
|
16455
|
-
"Trial
|
|
16465
|
+
"Trial in progress": "Trial in progress",
|
|
16466
|
+
"Trial selected": "Trial selected",
|
|
16456
16467
|
Trial: "Trial",
|
|
16457
16468
|
Unlimited: "Unlimited {{item}}",
|
|
16458
16469
|
"Unsubscribe failed": "Unsubscribe failed",
|
|
@@ -17147,7 +17158,7 @@ var EmbedProvider = ({
|
|
|
17147
17158
|
(0, import_react11.useEffect)(() => {
|
|
17148
17159
|
if (accessToken) {
|
|
17149
17160
|
const { headers = {} } = apiConfig ?? {};
|
|
17150
|
-
headers["X-Schematic-Components-Version"] = "0.7.
|
|
17161
|
+
headers["X-Schematic-Components-Version"] = "0.7.14";
|
|
17151
17162
|
headers["X-Schematic-Session-ID"] = sessionIdRef.current;
|
|
17152
17163
|
const config = new Configuration({
|
|
17153
17164
|
...apiConfig,
|
|
@@ -17591,29 +17602,23 @@ var Button = dt.button(
|
|
|
17591
17602
|
case "sm":
|
|
17592
17603
|
return lt`
|
|
17593
17604
|
font-size: ${15 / TEXT_BASE_SIZE}rem;
|
|
17594
|
-
${
|
|
17595
|
-
|
|
17596
|
-
|
|
17597
|
-
border-radius: ${6 / TEXT_BASE_SIZE}rem;
|
|
17598
|
-
`}
|
|
17605
|
+
height: ${40 / TEXT_BASE_SIZE}rem;
|
|
17606
|
+
padding: ${7 / TEXT_BASE_SIZE}rem ${20 / TEXT_BASE_SIZE}rem;
|
|
17607
|
+
border-radius: ${6 / TEXT_BASE_SIZE}rem;
|
|
17599
17608
|
`;
|
|
17600
17609
|
case "md":
|
|
17601
17610
|
return lt`
|
|
17602
17611
|
font-size: ${17 / TEXT_BASE_SIZE}rem;
|
|
17603
|
-
${
|
|
17604
|
-
|
|
17605
|
-
|
|
17606
|
-
border-radius: ${8 / TEXT_BASE_SIZE}rem;
|
|
17607
|
-
`}
|
|
17612
|
+
height: ${52 / TEXT_BASE_SIZE}rem;
|
|
17613
|
+
padding: ${8 / TEXT_BASE_SIZE}rem ${24 / TEXT_BASE_SIZE}rem;
|
|
17614
|
+
border-radius: ${8 / TEXT_BASE_SIZE}rem;
|
|
17608
17615
|
`;
|
|
17609
17616
|
case "lg":
|
|
17610
17617
|
return lt`
|
|
17611
17618
|
font-size: ${19 / TEXT_BASE_SIZE}rem;
|
|
17612
|
-
${
|
|
17613
|
-
|
|
17614
|
-
|
|
17615
|
-
border-radius: ${10 / TEXT_BASE_SIZE}rem;
|
|
17616
|
-
`}
|
|
17619
|
+
height: ${64 / TEXT_BASE_SIZE}rem;
|
|
17620
|
+
padding: ${9 / TEXT_BASE_SIZE}rem ${28 / TEXT_BASE_SIZE}rem;
|
|
17621
|
+
border-radius: ${10 / TEXT_BASE_SIZE}rem;
|
|
17617
17622
|
`;
|
|
17618
17623
|
}
|
|
17619
17624
|
}}
|
|
@@ -18631,7 +18636,8 @@ var StageButton = ({
|
|
|
18631
18636
|
isLoading,
|
|
18632
18637
|
requiresPayment,
|
|
18633
18638
|
setCheckoutStage,
|
|
18634
|
-
trialPaymentMethodRequired
|
|
18639
|
+
trialPaymentMethodRequired,
|
|
18640
|
+
willTrial
|
|
18635
18641
|
}) => {
|
|
18636
18642
|
const { t: t2 } = useTranslation();
|
|
18637
18643
|
const NoPaymentRequired = () => {
|
|
@@ -18647,42 +18653,14 @@ var StageButton = ({
|
|
|
18647
18653
|
);
|
|
18648
18654
|
};
|
|
18649
18655
|
if (checkoutStage === "plan") {
|
|
18650
|
-
if (canTrial) {
|
|
18651
|
-
if (trialPaymentMethodRequired) {
|
|
18652
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
18653
|
-
Button,
|
|
18654
|
-
{
|
|
18655
|
-
type: "button",
|
|
18656
|
-
disabled: !hasAddOns && !canUpdateSubscription,
|
|
18657
|
-
onClick: async () => {
|
|
18658
|
-
setCheckoutStage?.("checkout");
|
|
18659
|
-
},
|
|
18660
|
-
$isLoading: isLoading,
|
|
18661
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
18662
|
-
Flex,
|
|
18663
|
-
{
|
|
18664
|
-
$gap: "0.5rem",
|
|
18665
|
-
$justifyContent: "center",
|
|
18666
|
-
$alignItems: "center",
|
|
18667
|
-
$padding: "0 1rem",
|
|
18668
|
-
children: [
|
|
18669
|
-
t2("Next"),
|
|
18670
|
-
": ",
|
|
18671
|
-
t2("Checkout"),
|
|
18672
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon2, { name: "arrow-right" })
|
|
18673
|
-
]
|
|
18674
|
-
}
|
|
18675
|
-
)
|
|
18676
|
-
}
|
|
18677
|
-
);
|
|
18678
|
-
}
|
|
18656
|
+
if (canTrial && trialPaymentMethodRequired) {
|
|
18679
18657
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
18680
18658
|
Button,
|
|
18681
18659
|
{
|
|
18682
18660
|
type: "button",
|
|
18683
|
-
disabled: !
|
|
18661
|
+
disabled: !hasAddOns && !canUpdateSubscription,
|
|
18684
18662
|
onClick: async () => {
|
|
18685
|
-
checkout
|
|
18663
|
+
setCheckoutStage?.("checkout");
|
|
18686
18664
|
},
|
|
18687
18665
|
$isLoading: isLoading,
|
|
18688
18666
|
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
@@ -18693,7 +18671,9 @@ var StageButton = ({
|
|
|
18693
18671
|
$alignItems: "center",
|
|
18694
18672
|
$padding: "0 1rem",
|
|
18695
18673
|
children: [
|
|
18696
|
-
t2("
|
|
18674
|
+
t2("Next"),
|
|
18675
|
+
": ",
|
|
18676
|
+
t2("Checkout"),
|
|
18697
18677
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon2, { name: "arrow-right" })
|
|
18698
18678
|
]
|
|
18699
18679
|
}
|
|
@@ -18702,7 +18682,7 @@ var StageButton = ({
|
|
|
18702
18682
|
);
|
|
18703
18683
|
}
|
|
18704
18684
|
if (!requiresPayment && !checkoutStages?.some(
|
|
18705
|
-
(stage) => stage.id === "
|
|
18685
|
+
(stage) => stage.id === "usage" || stage.id === "addons"
|
|
18706
18686
|
)) {
|
|
18707
18687
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(NoPaymentRequired, {});
|
|
18708
18688
|
}
|
|
@@ -18728,7 +18708,7 @@ var StageButton = ({
|
|
|
18728
18708
|
);
|
|
18729
18709
|
}
|
|
18730
18710
|
if (checkoutStage === "usage") {
|
|
18731
|
-
if (!requiresPayment) {
|
|
18711
|
+
if (!requiresPayment && !checkoutStages?.some((stage) => stage.id === "addons")) {
|
|
18732
18712
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(NoPaymentRequired, {});
|
|
18733
18713
|
}
|
|
18734
18714
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
@@ -18800,7 +18780,7 @@ var StageButton = ({
|
|
|
18800
18780
|
disabled: isLoading || !hasUnstagedChanges || !canCheckout,
|
|
18801
18781
|
onClick: checkout,
|
|
18802
18782
|
$isLoading: isLoading,
|
|
18803
|
-
children:
|
|
18783
|
+
children: willTrial ? t2("Start trial") : t2("Pay now")
|
|
18804
18784
|
}
|
|
18805
18785
|
);
|
|
18806
18786
|
}
|
|
@@ -18826,7 +18806,8 @@ var Sidebar = ({
|
|
|
18826
18806
|
setError,
|
|
18827
18807
|
setIsLoading,
|
|
18828
18808
|
updatePromoCode,
|
|
18829
|
-
showHeader = true
|
|
18809
|
+
showHeader = true,
|
|
18810
|
+
willTrial = false
|
|
18830
18811
|
}) => {
|
|
18831
18812
|
const { t: t2 } = useTranslation();
|
|
18832
18813
|
const theme = nt();
|
|
@@ -18956,10 +18937,10 @@ var Sidebar = ({
|
|
|
18956
18937
|
...promoCode && { promoCode }
|
|
18957
18938
|
}
|
|
18958
18939
|
});
|
|
18959
|
-
dispatchPlanChangedEvent(response.data);
|
|
18960
18940
|
setIsLoading(false);
|
|
18961
18941
|
setLayout("portal");
|
|
18962
|
-
hydrate();
|
|
18942
|
+
await hydrate();
|
|
18943
|
+
dispatchPlanChangedEvent(response.data);
|
|
18963
18944
|
} catch {
|
|
18964
18945
|
setLayout("checkout");
|
|
18965
18946
|
setError(
|
|
@@ -19057,6 +19038,7 @@ var Sidebar = ({
|
|
|
19057
19038
|
currentUsageBasedEntitlements,
|
|
19058
19039
|
usageBasedEntitlements
|
|
19059
19040
|
]);
|
|
19041
|
+
const willPeriodChange = planPeriod !== data.company?.plan?.planPeriod;
|
|
19060
19042
|
const willPlanChange = typeof selectedPlan !== "undefined" && !selectedPlan.current;
|
|
19061
19043
|
const removedAddOns = currentAddOns.filter(
|
|
19062
19044
|
(current) => !selectedAddOns.some((selected) => current.id === selected.id) && current.planPeriod !== "one-time"
|
|
@@ -19066,10 +19048,10 @@ var Sidebar = ({
|
|
|
19066
19048
|
);
|
|
19067
19049
|
const willAddOnsChange = removedAddOns.length > 0 || addedAddOns.length > 0;
|
|
19068
19050
|
const willPayInAdvanceEntitlementsChange = payInAdvanceEntitlements.length > 0 && payInAdvanceEntitlements.some(({ quantity, usage }) => quantity !== usage);
|
|
19069
|
-
const hasUnstagedChanges = willPlanChange || willAddOnsChange || willPayInAdvanceEntitlementsChange;
|
|
19051
|
+
const hasUnstagedChanges = willPeriodChange || willPlanChange || willAddOnsChange || willPayInAdvanceEntitlementsChange;
|
|
19070
19052
|
const canUpdateSubscription = mode === "edit" || api !== null && !isLoading;
|
|
19071
19053
|
const canCheckout = canUpdateSubscription && (!!data.subscription?.paymentMethod || typeof paymentMethodId === "string");
|
|
19072
|
-
const isTrialable = selectedPlan?.companyCanTrial;
|
|
19054
|
+
const isTrialable = selectedPlan?.companyCanTrial === true;
|
|
19073
19055
|
const today = /* @__PURE__ */ new Date();
|
|
19074
19056
|
const trialEndsOn = new Date(today);
|
|
19075
19057
|
if (isTrialable && selectedPlan.trialDays) {
|
|
@@ -19145,7 +19127,7 @@ var Sidebar = ({
|
|
|
19145
19127
|
}
|
|
19146
19128
|
) }),
|
|
19147
19129
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Flex, { $flexDirection: "column", $gap: "0.5rem", $marginBottom: "1.5rem", children: [
|
|
19148
|
-
|
|
19130
|
+
currentPlan && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
19149
19131
|
Flex,
|
|
19150
19132
|
{
|
|
19151
19133
|
$justifyContent: "space-between",
|
|
@@ -19164,10 +19146,10 @@ var Sidebar = ({
|
|
|
19164
19146
|
$size: theme.typography.heading4.fontSize,
|
|
19165
19147
|
$weight: theme.typography.heading4.fontWeight,
|
|
19166
19148
|
$color: theme.typography.heading4.color,
|
|
19167
|
-
children:
|
|
19149
|
+
children: currentPlan.name
|
|
19168
19150
|
}
|
|
19169
19151
|
) }),
|
|
19170
|
-
typeof
|
|
19152
|
+
typeof currentPlan.planPrice === "number" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
19171
19153
|
Text,
|
|
19172
19154
|
{
|
|
19173
19155
|
$font: theme.typography.text.fontFamily,
|
|
@@ -19176,14 +19158,12 @@ var Sidebar = ({
|
|
|
19176
19158
|
$color: theme.typography.text.color,
|
|
19177
19159
|
children: [
|
|
19178
19160
|
formatCurrency(
|
|
19179
|
-
|
|
19180
|
-
data.company
|
|
19161
|
+
currentPlan.planPrice,
|
|
19162
|
+
data.company?.billingSubscription?.currency
|
|
19181
19163
|
),
|
|
19182
19164
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("sub", { children: [
|
|
19183
19165
|
"/",
|
|
19184
|
-
shortenPeriod(
|
|
19185
|
-
data.company.plan.planPeriod || planPeriod
|
|
19186
|
-
)
|
|
19166
|
+
shortenPeriod(currentPlan.planPeriod || planPeriod)
|
|
19187
19167
|
] })
|
|
19188
19168
|
]
|
|
19189
19169
|
}
|
|
@@ -19949,7 +19929,7 @@ var Sidebar = ({
|
|
|
19949
19929
|
layout === "checkout" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
19950
19930
|
StageButton,
|
|
19951
19931
|
{
|
|
19952
|
-
canTrial:
|
|
19932
|
+
canTrial: isTrialable,
|
|
19953
19933
|
canCheckout,
|
|
19954
19934
|
canUpdateSubscription,
|
|
19955
19935
|
checkout,
|
|
@@ -19961,7 +19941,8 @@ var Sidebar = ({
|
|
|
19961
19941
|
isLoading,
|
|
19962
19942
|
requiresPayment,
|
|
19963
19943
|
setCheckoutStage,
|
|
19964
|
-
trialPaymentMethodRequired: data.trialPaymentMethodRequired === true
|
|
19944
|
+
trialPaymentMethodRequired: data.trialPaymentMethodRequired === true,
|
|
19945
|
+
willTrial
|
|
19965
19946
|
}
|
|
19966
19947
|
),
|
|
19967
19948
|
layout === "unsubscribe" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { onClick: unsubscribe, $isLoading: isLoading, children: t2("Cancel subscription") }),
|
|
@@ -20271,13 +20252,11 @@ var Navigation = ({
|
|
|
20271
20252
|
}
|
|
20272
20253
|
),
|
|
20273
20254
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
20274
|
-
|
|
20255
|
+
Text,
|
|
20275
20256
|
{
|
|
20257
|
+
as: Box,
|
|
20276
20258
|
tabIndex: 0,
|
|
20277
|
-
$
|
|
20278
|
-
$fontFamily: theme.typography.text.fontFamily,
|
|
20279
|
-
$fontWeight: index === activeIndex ? 600 : 400,
|
|
20280
|
-
$color: theme.typography.text.color,
|
|
20259
|
+
$weight: index === activeIndex ? 600 : 400,
|
|
20281
20260
|
...!showFullContent && {
|
|
20282
20261
|
$overflow: "hidden",
|
|
20283
20262
|
$whiteSpace: "nowrap",
|
|
@@ -20330,15 +20309,162 @@ var ButtonLink = dt.a`
|
|
|
20330
20309
|
|
|
20331
20310
|
// src/components/shared/checkout-dialog/Plan.tsx
|
|
20332
20311
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
20312
|
+
var Selected = ({ isCurrent = false, isTrial = false }) => {
|
|
20313
|
+
const { t: t2 } = useTranslation();
|
|
20314
|
+
const theme = nt();
|
|
20315
|
+
const text = (0, import_react25.useMemo)(() => {
|
|
20316
|
+
if (isCurrent) {
|
|
20317
|
+
return isTrial ? t2("Trial in progress") : t2("Current plan");
|
|
20318
|
+
}
|
|
20319
|
+
return isTrial ? t2("Trial selected") : t2("Plan selected");
|
|
20320
|
+
}, [t2, isCurrent, isTrial]);
|
|
20321
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
20322
|
+
Flex,
|
|
20323
|
+
{
|
|
20324
|
+
$justifyContent: "center",
|
|
20325
|
+
$alignItems: "center",
|
|
20326
|
+
$gap: "0.25rem",
|
|
20327
|
+
$padding: "0.625rem 0",
|
|
20328
|
+
children: [
|
|
20329
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20330
|
+
Icon2,
|
|
20331
|
+
{
|
|
20332
|
+
name: "check-rounded",
|
|
20333
|
+
style: {
|
|
20334
|
+
fontSize: 20,
|
|
20335
|
+
lineHeight: 1,
|
|
20336
|
+
color: theme.primary
|
|
20337
|
+
}
|
|
20338
|
+
}
|
|
20339
|
+
),
|
|
20340
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20341
|
+
Text,
|
|
20342
|
+
{
|
|
20343
|
+
$font: theme.typography.text.fontFamily,
|
|
20344
|
+
$size: 15 / 16 * theme.typography.text.fontSize,
|
|
20345
|
+
$weight: theme.typography.text.fontWeight,
|
|
20346
|
+
$color: theme.typography.text.color,
|
|
20347
|
+
$leading: 1,
|
|
20348
|
+
children: text
|
|
20349
|
+
}
|
|
20350
|
+
)
|
|
20351
|
+
]
|
|
20352
|
+
}
|
|
20353
|
+
);
|
|
20354
|
+
};
|
|
20355
|
+
var PlanButtonGroup = ({
|
|
20356
|
+
plan,
|
|
20357
|
+
isLoading,
|
|
20358
|
+
isSelected,
|
|
20359
|
+
onSelect,
|
|
20360
|
+
willTrial
|
|
20361
|
+
}) => {
|
|
20362
|
+
const { t: t2 } = useTranslation();
|
|
20363
|
+
const { data } = useEmbed();
|
|
20364
|
+
const isCurrent = plan.id === data.company?.plan?.id;
|
|
20365
|
+
if (plan.companyCanTrial) {
|
|
20366
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Flex, { $flexDirection: "column", $gap: "1.5rem", children: [
|
|
20367
|
+
data.subscription?.status !== "trialing" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: isSelected && willTrial ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20368
|
+
Selected,
|
|
20369
|
+
{
|
|
20370
|
+
isCurrent,
|
|
20371
|
+
isTrial: plan.companyCanTrial && willTrial
|
|
20372
|
+
}
|
|
20373
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20374
|
+
Button,
|
|
20375
|
+
{
|
|
20376
|
+
type: "button",
|
|
20377
|
+
disabled: (isLoading || !plan.valid) && !plan.custom,
|
|
20378
|
+
...!plan.custom && {
|
|
20379
|
+
onClick: () => {
|
|
20380
|
+
onSelect({
|
|
20381
|
+
plan,
|
|
20382
|
+
shouldTrial: true
|
|
20383
|
+
});
|
|
20384
|
+
}
|
|
20385
|
+
},
|
|
20386
|
+
$size: "sm",
|
|
20387
|
+
$color: "primary",
|
|
20388
|
+
$variant: "filled",
|
|
20389
|
+
children: plan.custom ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20390
|
+
ButtonLink,
|
|
20391
|
+
{
|
|
20392
|
+
href: plan.customPlanConfig?.ctaWebSite ?? "#",
|
|
20393
|
+
target: "_blank",
|
|
20394
|
+
children: plan.customPlanConfig?.ctaText ?? t2("Talk to support")
|
|
20395
|
+
}
|
|
20396
|
+
) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20397
|
+
Tooltip,
|
|
20398
|
+
{
|
|
20399
|
+
trigger: t2("Over usage limit"),
|
|
20400
|
+
content: t2("Current usage exceeds the limit of this plan.")
|
|
20401
|
+
}
|
|
20402
|
+
) : t2("Start X day trial", { days: plan.trialDays })
|
|
20403
|
+
}
|
|
20404
|
+
) }),
|
|
20405
|
+
!plan.custom && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: isSelected && (!willTrial || data.subscription?.status === "trialing") ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Selected, { isCurrent }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20406
|
+
Button,
|
|
20407
|
+
{
|
|
20408
|
+
type: "button",
|
|
20409
|
+
disabled: isLoading || !plan.valid,
|
|
20410
|
+
onClick: () => {
|
|
20411
|
+
onSelect({ plan, shouldTrial: false });
|
|
20412
|
+
},
|
|
20413
|
+
$size: "sm",
|
|
20414
|
+
$color: "primary",
|
|
20415
|
+
$variant: data.subscription?.status === "trialing" ? "filled" : "text",
|
|
20416
|
+
children: !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20417
|
+
Tooltip,
|
|
20418
|
+
{
|
|
20419
|
+
trigger: t2("Over usage limit"),
|
|
20420
|
+
content: t2("Current usage exceeds the limit of this plan.")
|
|
20421
|
+
}
|
|
20422
|
+
) : t2("Choose plan")
|
|
20423
|
+
}
|
|
20424
|
+
) })
|
|
20425
|
+
] });
|
|
20426
|
+
}
|
|
20427
|
+
return isSelected ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Selected, { isCurrent }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20428
|
+
Button,
|
|
20429
|
+
{
|
|
20430
|
+
type: "button",
|
|
20431
|
+
disabled: (isLoading || !plan.valid) && !plan.custom,
|
|
20432
|
+
...!plan.custom && {
|
|
20433
|
+
onClick: () => {
|
|
20434
|
+
onSelect({ plan });
|
|
20435
|
+
}
|
|
20436
|
+
},
|
|
20437
|
+
$size: "sm",
|
|
20438
|
+
$color: "primary",
|
|
20439
|
+
$variant: "filled",
|
|
20440
|
+
children: plan.custom ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20441
|
+
ButtonLink,
|
|
20442
|
+
{
|
|
20443
|
+
href: plan.customPlanConfig?.ctaWebSite ?? "#",
|
|
20444
|
+
target: "_blank",
|
|
20445
|
+
children: plan.customPlanConfig?.ctaText ?? t2("Talk to support")
|
|
20446
|
+
}
|
|
20447
|
+
) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20448
|
+
Tooltip,
|
|
20449
|
+
{
|
|
20450
|
+
trigger: t2("Over usage limit"),
|
|
20451
|
+
content: t2("Current usage exceeds the limit of this plan.")
|
|
20452
|
+
}
|
|
20453
|
+
) : t2("Choose plan")
|
|
20454
|
+
}
|
|
20455
|
+
);
|
|
20456
|
+
};
|
|
20333
20457
|
var Plan = ({
|
|
20334
20458
|
isLoading,
|
|
20335
20459
|
plans,
|
|
20336
20460
|
selectedPlan,
|
|
20337
20461
|
period,
|
|
20338
|
-
selectPlan
|
|
20462
|
+
selectPlan,
|
|
20463
|
+
willTrial
|
|
20339
20464
|
}) => {
|
|
20340
20465
|
const { t: t2 } = useTranslation();
|
|
20341
20466
|
const theme = nt();
|
|
20467
|
+
const { data } = useEmbed();
|
|
20342
20468
|
const isLightBackground = useIsLightBackground();
|
|
20343
20469
|
const [entitlementCounts, setEntitlementCounts] = (0, import_react25.useState)(
|
|
20344
20470
|
() => plans.reduce(
|
|
@@ -20352,7 +20478,6 @@ var Plan = ({
|
|
|
20352
20478
|
{}
|
|
20353
20479
|
)
|
|
20354
20480
|
);
|
|
20355
|
-
const cardPadding = theme.card.padding / TEXT_BASE_SIZE;
|
|
20356
20481
|
const handleToggleShowAll = (id) => {
|
|
20357
20482
|
setEntitlementCounts((prev2) => {
|
|
20358
20483
|
const count = { ...prev2[id] };
|
|
@@ -20365,6 +20490,7 @@ var Plan = ({
|
|
|
20365
20490
|
};
|
|
20366
20491
|
});
|
|
20367
20492
|
};
|
|
20493
|
+
const cardPadding = theme.card.padding / TEXT_BASE_SIZE;
|
|
20368
20494
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20369
20495
|
Box,
|
|
20370
20496
|
{
|
|
@@ -20473,7 +20599,7 @@ var Plan = ({
|
|
|
20473
20599
|
$size: 0.75 * theme.typography.text.fontSize,
|
|
20474
20600
|
$weight: theme.typography.text.fontWeight,
|
|
20475
20601
|
$color: hexToHSL(theme.primary).l > 50 ? "#000000" : "#FFFFFF",
|
|
20476
|
-
children: t2("Active")
|
|
20602
|
+
children: data.subscription?.status === "trialing" ? t2("Trialing") : t2("Active")
|
|
20477
20603
|
}
|
|
20478
20604
|
)
|
|
20479
20605
|
}
|
|
@@ -20688,70 +20814,14 @@ var Plan = ({
|
|
|
20688
20814
|
}
|
|
20689
20815
|
)
|
|
20690
20816
|
] }),
|
|
20691
|
-
|
|
20692
|
-
|
|
20693
|
-
{
|
|
20694
|
-
$justifyContent: "center",
|
|
20695
|
-
$alignItems: "center",
|
|
20696
|
-
$gap: "0.25rem",
|
|
20697
|
-
$padding: "0.625rem 0",
|
|
20698
|
-
children: [
|
|
20699
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20700
|
-
Icon2,
|
|
20701
|
-
{
|
|
20702
|
-
name: "check-rounded",
|
|
20703
|
-
style: {
|
|
20704
|
-
fontSize: 20,
|
|
20705
|
-
lineHeight: 1,
|
|
20706
|
-
color: theme.primary
|
|
20707
|
-
}
|
|
20708
|
-
}
|
|
20709
|
-
),
|
|
20710
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20711
|
-
Text,
|
|
20712
|
-
{
|
|
20713
|
-
$font: theme.typography.text.fontFamily,
|
|
20714
|
-
$size: 15 / 16 * theme.typography.text.fontSize,
|
|
20715
|
-
$weight: theme.typography.text.fontWeight,
|
|
20716
|
-
$color: theme.typography.text.color,
|
|
20717
|
-
$leading: 1,
|
|
20718
|
-
children: plan.current ? t2("Current plan") : t2("Selected")
|
|
20719
|
-
}
|
|
20720
|
-
)
|
|
20721
|
-
]
|
|
20722
|
-
}
|
|
20723
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20724
|
-
Button,
|
|
20817
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20818
|
+
PlanButtonGroup,
|
|
20725
20819
|
{
|
|
20726
|
-
|
|
20727
|
-
|
|
20728
|
-
|
|
20729
|
-
|
|
20730
|
-
|
|
20731
|
-
return;
|
|
20732
|
-
}
|
|
20733
|
-
selectPlan({ plan });
|
|
20734
|
-
}
|
|
20735
|
-
},
|
|
20736
|
-
$size: "sm",
|
|
20737
|
-
$color: "primary",
|
|
20738
|
-
$variant: plan.current ? "outline" : "filled",
|
|
20739
|
-
children: plan.custom ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20740
|
-
ButtonLink,
|
|
20741
|
-
{
|
|
20742
|
-
href: plan.customPlanConfig?.ctaWebSite ?? "#",
|
|
20743
|
-
target: "_blank",
|
|
20744
|
-
children: plan.customPlanConfig?.ctaText ?? t2("Talk to support")
|
|
20745
|
-
}
|
|
20746
|
-
) : !plan.valid ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
20747
|
-
Tooltip,
|
|
20748
|
-
{
|
|
20749
|
-
trigger: t2("Over usage limit"),
|
|
20750
|
-
content: t2(
|
|
20751
|
-
"Current usage exceeds the limit of this plan."
|
|
20752
|
-
)
|
|
20753
|
-
}
|
|
20754
|
-
) : plan.companyCanTrial ? t2("Trial plan", { days: plan.trialDays }) : t2("Choose plan")
|
|
20820
|
+
plan,
|
|
20821
|
+
isLoading,
|
|
20822
|
+
isSelected: plan.id === selectedPlan?.id,
|
|
20823
|
+
onSelect: selectPlan,
|
|
20824
|
+
willTrial
|
|
20755
20825
|
}
|
|
20756
20826
|
)
|
|
20757
20827
|
]
|
|
@@ -20961,10 +21031,11 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
20961
21031
|
const contentRef = (0, import_react26.useRef)(null);
|
|
20962
21032
|
const checkoutRef = (0, import_react26.useRef)(null);
|
|
20963
21033
|
const [charges, setCharges] = (0, import_react26.useState)();
|
|
20964
|
-
const [paymentMethodId, setPaymentMethodId] = (0, import_react26.useState)(
|
|
21034
|
+
const [paymentMethodId, setPaymentMethodId] = (0, import_react26.useState)(
|
|
21035
|
+
(data.subscription?.paymentMethod || data.company?.defaultPaymentMethod)?.externalId
|
|
21036
|
+
);
|
|
20965
21037
|
const [isLoading, setIsLoading] = (0, import_react26.useState)(false);
|
|
20966
21038
|
const [error, setError] = (0, import_react26.useState)();
|
|
20967
|
-
const [promoCode, setPromoCode] = (0, import_react26.useState)();
|
|
20968
21039
|
const [planPeriod, setPlanPeriod] = (0, import_react26.useState)(
|
|
20969
21040
|
selected.period || data.company?.plan?.planPeriod || "month"
|
|
20970
21041
|
);
|
|
@@ -20978,6 +21049,9 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
20978
21049
|
(plan) => selected.planId ? plan.id === selected.planId : plan.current
|
|
20979
21050
|
)
|
|
20980
21051
|
);
|
|
21052
|
+
const [willTrial, setWillTrial] = (0, import_react26.useState)(
|
|
21053
|
+
data.subscription?.status !== "trialing" && !data.trialPaymentMethodRequired
|
|
21054
|
+
);
|
|
20981
21055
|
const [addOns, setAddOns] = (0, import_react26.useState)(
|
|
20982
21056
|
() => availableAddOns.map((addOn) => ({
|
|
20983
21057
|
...addOn,
|
|
@@ -20986,6 +21060,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
20986
21060
|
)
|
|
20987
21061
|
}))
|
|
20988
21062
|
);
|
|
21063
|
+
const hasActiveAddOns = addOns.some((addOn) => addOn.isSelected);
|
|
20989
21064
|
const currentEntitlements = (0, import_react26.useMemo)(() => {
|
|
20990
21065
|
return data.featureUsage?.features || [];
|
|
20991
21066
|
}, [data.featureUsage?.features]);
|
|
@@ -21004,11 +21079,14 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
21004
21079
|
),
|
|
21005
21080
|
[usageBasedEntitlements]
|
|
21006
21081
|
);
|
|
21007
|
-
const hasActiveAddOns = addOns.some((addOn) => addOn.isSelected);
|
|
21008
21082
|
const hasActivePayInAdvanceEntitlements = payInAdvanceEntitlements.some(
|
|
21009
21083
|
({ quantity }) => quantity > 0
|
|
21010
21084
|
);
|
|
21011
|
-
const
|
|
21085
|
+
const [promoCode, setPromoCode] = (0, import_react26.useState)();
|
|
21086
|
+
const isTrialable = selectedPlan?.isTrialable === true && selectedPlan?.companyCanTrial === true;
|
|
21087
|
+
const isTrialableAndFree = isTrialable && data.trialPaymentMethodRequired !== true;
|
|
21088
|
+
const planRequiresPayment = !isTrialableAndFree || !isTrialable && selectedPlan?.isFree !== true;
|
|
21089
|
+
const requiresPayment = planRequiresPayment || hasActiveAddOns || hasActivePayInAdvanceEntitlements;
|
|
21012
21090
|
const checkoutStages = (0, import_react26.useMemo)(() => {
|
|
21013
21091
|
const stages = [
|
|
21014
21092
|
{
|
|
@@ -21018,13 +21096,16 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
21018
21096
|
description: t2("Choose your base plan")
|
|
21019
21097
|
}
|
|
21020
21098
|
];
|
|
21021
|
-
if (
|
|
21099
|
+
if (willTrial) {
|
|
21100
|
+
return stages;
|
|
21101
|
+
}
|
|
21102
|
+
if (payInAdvanceEntitlements.length > 0) {
|
|
21022
21103
|
stages.push({
|
|
21023
21104
|
id: "usage",
|
|
21024
21105
|
name: t2("Quantity")
|
|
21025
21106
|
});
|
|
21026
21107
|
}
|
|
21027
|
-
if (availableAddOns.length
|
|
21108
|
+
if (availableAddOns.length > 0) {
|
|
21028
21109
|
stages.push({
|
|
21029
21110
|
id: "addons",
|
|
21030
21111
|
name: t2("Add-ons"),
|
|
@@ -21042,9 +21123,9 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
21042
21123
|
return stages;
|
|
21043
21124
|
}, [
|
|
21044
21125
|
t2,
|
|
21126
|
+
willTrial,
|
|
21045
21127
|
payInAdvanceEntitlements,
|
|
21046
21128
|
availableAddOns,
|
|
21047
|
-
selectedPlan?.companyCanTrial,
|
|
21048
21129
|
requiresPayment
|
|
21049
21130
|
]);
|
|
21050
21131
|
const [checkoutStage, setCheckoutStage] = (0, import_react26.useState)(() => {
|
|
@@ -21149,6 +21230,8 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
21149
21230
|
setSelectedPlan(plan);
|
|
21150
21231
|
setUsageBasedEntitlements(entitlements);
|
|
21151
21232
|
}
|
|
21233
|
+
const shouldTrial = updates.shouldTrial ?? false;
|
|
21234
|
+
setWillTrial(shouldTrial && !data.trialPaymentMethodRequired);
|
|
21152
21235
|
previewCheckout({
|
|
21153
21236
|
period,
|
|
21154
21237
|
plan: updates.plan,
|
|
@@ -21157,7 +21240,13 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
21157
21240
|
)
|
|
21158
21241
|
});
|
|
21159
21242
|
},
|
|
21160
|
-
[
|
|
21243
|
+
[
|
|
21244
|
+
data.trialPaymentMethodRequired,
|
|
21245
|
+
planPeriod,
|
|
21246
|
+
selectedPlan,
|
|
21247
|
+
currentEntitlements,
|
|
21248
|
+
previewCheckout
|
|
21249
|
+
]
|
|
21161
21250
|
);
|
|
21162
21251
|
const changePlanPeriod = (0, import_react26.useCallback)(
|
|
21163
21252
|
(period) => {
|
|
@@ -21354,7 +21443,8 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
21354
21443
|
period: planPeriod,
|
|
21355
21444
|
plans: availablePlans,
|
|
21356
21445
|
selectedPlan,
|
|
21357
|
-
selectPlan
|
|
21446
|
+
selectPlan,
|
|
21447
|
+
willTrial
|
|
21358
21448
|
}
|
|
21359
21449
|
),
|
|
21360
21450
|
checkoutStage === "usage" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
@@ -21406,7 +21496,8 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
21406
21496
|
setCheckoutStage: (stage) => setCheckoutStage(stage),
|
|
21407
21497
|
setError: (msg) => setError(msg),
|
|
21408
21498
|
setIsLoading,
|
|
21409
|
-
updatePromoCode: (code) => updatePromoCode(code)
|
|
21499
|
+
updatePromoCode: (code) => updatePromoCode(code),
|
|
21500
|
+
willTrial
|
|
21410
21501
|
}
|
|
21411
21502
|
)
|
|
21412
21503
|
]
|
|
@@ -21451,6 +21542,7 @@ var PaymentForm = ({ onConfirm }) => {
|
|
|
21451
21542
|
const [message, setMessage] = (0, import_react27.useState)(null);
|
|
21452
21543
|
const [isLoading, setIsLoading] = (0, import_react27.useState)(false);
|
|
21453
21544
|
const [isConfirmed, setIsConfirmed] = (0, import_react27.useState)(false);
|
|
21545
|
+
const [isComplete, setIsComplete] = (0, import_react27.useState)(false);
|
|
21454
21546
|
const handleSubmit = async (event) => {
|
|
21455
21547
|
event.preventDefault();
|
|
21456
21548
|
if (!api || !stripe || !elements) {
|
|
@@ -21493,12 +21585,20 @@ var PaymentForm = ({ onConfirm }) => {
|
|
|
21493
21585
|
overflowY: "auto"
|
|
21494
21586
|
},
|
|
21495
21587
|
children: [
|
|
21496
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Box, { $marginBottom: "1.5rem", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
21588
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Box, { $marginBottom: "1.5rem", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
21589
|
+
import_react_stripe_js.PaymentElement,
|
|
21590
|
+
{
|
|
21591
|
+
id: "payment-element",
|
|
21592
|
+
onChange: (event) => {
|
|
21593
|
+
setIsComplete(event.complete);
|
|
21594
|
+
}
|
|
21595
|
+
}
|
|
21596
|
+
) }),
|
|
21497
21597
|
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
21498
21598
|
Button,
|
|
21499
21599
|
{
|
|
21500
21600
|
id: "submit",
|
|
21501
|
-
disabled: isLoading || !stripe || !elements || isConfirmed,
|
|
21601
|
+
disabled: isLoading || !stripe || !elements || isConfirmed || !isComplete,
|
|
21502
21602
|
style: { flexShrink: 0 },
|
|
21503
21603
|
$color: "primary",
|
|
21504
21604
|
$isLoading: isLoading,
|
|
@@ -23041,7 +23141,7 @@ var PaymentElement2 = ({
|
|
|
23041
23141
|
};
|
|
23042
23142
|
var EmptyPaymentElement = () => {
|
|
23043
23143
|
const theme = nt();
|
|
23044
|
-
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Text, { $font: theme.typography.text.fontFamily, $size: 16, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Flex, { $flexDirection: "row", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Flex, { $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Box, { $lineHeight: "1", $marginRight: "4px", children: t("No payment method
|
|
23144
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Text, { $font: theme.typography.text.fontFamily, $size: 16, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Flex, { $flexDirection: "row", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Flex, { $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Box, { $lineHeight: "1", $marginRight: "4px", children: t("No payment method added yet") }) }) }) });
|
|
23045
23145
|
};
|
|
23046
23146
|
var getPaymentMethodData = ({
|
|
23047
23147
|
accountLast4,
|
|
@@ -23383,7 +23483,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
|
23383
23483
|
}
|
|
23384
23484
|
stripe._registerWrapper({
|
|
23385
23485
|
name: "stripe-js",
|
|
23386
|
-
version: "7.
|
|
23486
|
+
version: "7.3.0",
|
|
23387
23487
|
startTime
|
|
23388
23488
|
});
|
|
23389
23489
|
};
|
|
@@ -23458,7 +23558,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
|
|
|
23458
23558
|
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
23459
23559
|
var expectedVersion = RELEASE_TRAIN;
|
|
23460
23560
|
if (isTestKey && version !== expectedVersion) {
|
|
23461
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.
|
|
23561
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.3.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
23462
23562
|
}
|
|
23463
23563
|
var stripe = maybeStripe.apply(void 0, args);
|
|
23464
23564
|
registerWrapper(stripe, startTime);
|
|
@@ -23523,12 +23623,7 @@ var PaymentMethodDetails = ({
|
|
|
23523
23623
|
const [stripe, setStripe] = (0, import_react38.useState)(null);
|
|
23524
23624
|
const [setupIntent, setSetupIntent] = (0, import_react38.useState)();
|
|
23525
23625
|
const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = (0, import_react38.useState)(false);
|
|
23526
|
-
const [paymentMethod, setPaymentMethod] = (0, import_react38.useState)(
|
|
23527
|
-
(0, import_react38.useEffect)(() => {
|
|
23528
|
-
setPaymentMethod(
|
|
23529
|
-
data.subscription?.paymentMethod || data.company?.defaultPaymentMethod
|
|
23530
|
-
);
|
|
23531
|
-
}, [data.company?.defaultPaymentMethod, data.subscription?.paymentMethod]);
|
|
23626
|
+
const [paymentMethod, setPaymentMethod] = (0, import_react38.useState)(data.subscription?.paymentMethod || data.company?.defaultPaymentMethod);
|
|
23532
23627
|
const monthsToExpiration = (0, import_react38.useMemo)(() => {
|
|
23533
23628
|
let expiration;
|
|
23534
23629
|
if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
|
|
@@ -23542,33 +23637,25 @@ var PaymentMethodDetails = ({
|
|
|
23542
23637
|
}
|
|
23543
23638
|
return expiration;
|
|
23544
23639
|
}, [paymentMethod?.cardExpYear, paymentMethod?.cardExpMonth]);
|
|
23545
|
-
(0, import_react38.useEffect)(() => {
|
|
23546
|
-
if (!stripe && setupIntent?.publishableKey) {
|
|
23547
|
-
setStripe(loadStripe(setupIntent.publishableKey));
|
|
23548
|
-
}
|
|
23549
|
-
}, [stripe, setupIntent?.publishableKey]);
|
|
23550
23640
|
const createSetupIntent = (0, import_react38.useCallback)(async () => {
|
|
23551
23641
|
if (!api || !data.component?.id) {
|
|
23552
23642
|
return;
|
|
23553
23643
|
}
|
|
23554
23644
|
try {
|
|
23555
23645
|
setIsLoading(true);
|
|
23556
|
-
const
|
|
23646
|
+
const response = await api.getSetupIntent({
|
|
23557
23647
|
componentId: data.component.id
|
|
23558
23648
|
});
|
|
23559
|
-
setSetupIntent(
|
|
23560
|
-
setShowPaymentForm(true);
|
|
23649
|
+
setSetupIntent(response.data);
|
|
23561
23650
|
} catch {
|
|
23562
23651
|
setError(
|
|
23563
23652
|
t2("Error initializing payment method change. Please try again.")
|
|
23564
23653
|
);
|
|
23565
23654
|
} finally {
|
|
23655
|
+
setShowPaymentForm(true);
|
|
23566
23656
|
setIsLoading(false);
|
|
23567
23657
|
}
|
|
23568
23658
|
}, [t2, api, data.component?.id]);
|
|
23569
|
-
const dropDownDifferentPaymentMethods = (0, import_react38.useCallback)(() => {
|
|
23570
|
-
setShowDifferentPaymentMethods((state) => !state);
|
|
23571
|
-
}, []);
|
|
23572
23659
|
const updatePaymentMethod = (0, import_react38.useCallback)(
|
|
23573
23660
|
async (externalId) => {
|
|
23574
23661
|
if (!api || !externalId) {
|
|
@@ -23645,33 +23732,43 @@ var PaymentMethodDetails = ({
|
|
|
23645
23732
|
},
|
|
23646
23733
|
[api, data, setData, t2]
|
|
23647
23734
|
);
|
|
23735
|
+
(0, import_react38.useEffect)(() => {
|
|
23736
|
+
if (!stripe && setupIntent?.publishableKey) {
|
|
23737
|
+
setStripe(loadStripe(setupIntent.publishableKey));
|
|
23738
|
+
}
|
|
23739
|
+
}, [stripe, setupIntent?.publishableKey]);
|
|
23740
|
+
(0, import_react38.useEffect)(() => {
|
|
23741
|
+
if (!setupIntent && (!paymentMethod || showPaymentForm)) {
|
|
23742
|
+
createSetupIntent();
|
|
23743
|
+
}
|
|
23744
|
+
}, [setupIntent, paymentMethod, showPaymentForm, createSetupIntent]);
|
|
23648
23745
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Flex, { $position: "relative", children: [
|
|
23649
|
-
|
|
23746
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
23650
23747
|
Flex,
|
|
23651
23748
|
{
|
|
23652
23749
|
$position: "absolute",
|
|
23653
|
-
$
|
|
23654
|
-
$height: "100%",
|
|
23750
|
+
$zIndex: isLoading ? 1 : 0,
|
|
23655
23751
|
$justifyContent: "center",
|
|
23656
23752
|
$alignItems: "center",
|
|
23657
|
-
$
|
|
23658
|
-
$
|
|
23659
|
-
$
|
|
23660
|
-
$opacity: 0.5,
|
|
23661
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Loader, { $color: theme.primary, $size: "2xl" })
|
|
23753
|
+
$width: "100%",
|
|
23754
|
+
$height: "100%",
|
|
23755
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Loader, { $color: theme.primary, $size: "2xl", $isLoading: isLoading })
|
|
23662
23756
|
}
|
|
23663
23757
|
),
|
|
23664
23758
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
23665
23759
|
Flex,
|
|
23666
23760
|
{
|
|
23761
|
+
$position: "relative",
|
|
23762
|
+
$zIndex: isLoading ? 0 : 1,
|
|
23667
23763
|
$flexDirection: "column",
|
|
23668
|
-
$flexGrow:
|
|
23764
|
+
$flexGrow: 1,
|
|
23669
23765
|
$gap: "1rem",
|
|
23766
|
+
$overflow: "auto",
|
|
23670
23767
|
$padding: "2rem 2.5rem 2rem 2.5rem",
|
|
23768
|
+
$visibility: isLoading ? "hidden" : "visible",
|
|
23671
23769
|
$backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.025)" : "hsla(0, 0%, 100%, 0.025)",
|
|
23672
|
-
$overflow: "auto",
|
|
23673
23770
|
children: [
|
|
23674
|
-
showPaymentForm ? /* @__PURE__ */ (0, import_jsx_runtime34.
|
|
23771
|
+
setupIntent && showPaymentForm ? /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
23675
23772
|
import_react_stripe_js2.Elements,
|
|
23676
23773
|
{
|
|
23677
23774
|
stripe,
|
|
@@ -23700,16 +23797,32 @@ var PaymentMethodDetails = ({
|
|
|
23700
23797
|
},
|
|
23701
23798
|
clientSecret: setupIntent?.setupIntentClientSecret
|
|
23702
23799
|
},
|
|
23703
|
-
children:
|
|
23704
|
-
|
|
23705
|
-
|
|
23706
|
-
|
|
23707
|
-
|
|
23708
|
-
|
|
23709
|
-
|
|
23800
|
+
children: [
|
|
23801
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
23802
|
+
PaymentForm,
|
|
23803
|
+
{
|
|
23804
|
+
onConfirm: async (paymentMethodId) => {
|
|
23805
|
+
await updatePaymentMethod(paymentMethodId);
|
|
23806
|
+
setShowPaymentForm(false);
|
|
23807
|
+
setShowDifferentPaymentMethods(false);
|
|
23808
|
+
}
|
|
23710
23809
|
}
|
|
23711
|
-
|
|
23712
|
-
|
|
23810
|
+
),
|
|
23811
|
+
paymentMethod && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
23812
|
+
Text,
|
|
23813
|
+
{
|
|
23814
|
+
onClick: () => {
|
|
23815
|
+
setShowPaymentForm(false);
|
|
23816
|
+
setShowDifferentPaymentMethods(false);
|
|
23817
|
+
},
|
|
23818
|
+
$font: theme.typography.link.fontFamily,
|
|
23819
|
+
$size: theme.typography.link.fontSize,
|
|
23820
|
+
$weight: theme.typography.link.fontWeight,
|
|
23821
|
+
$color: theme.typography.link.color,
|
|
23822
|
+
children: t2("Select existing payment method")
|
|
23823
|
+
}
|
|
23824
|
+
) })
|
|
23825
|
+
]
|
|
23713
23826
|
}
|
|
23714
23827
|
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Flex, { $flexDirection: "column", $gap: "2rem", children: [
|
|
23715
23828
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
@@ -23724,7 +23837,9 @@ var PaymentMethodDetails = ({
|
|
|
23724
23837
|
(data.company?.paymentMethods || []).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
23725
23838
|
Text,
|
|
23726
23839
|
{
|
|
23727
|
-
onClick:
|
|
23840
|
+
onClick: () => {
|
|
23841
|
+
setShowDifferentPaymentMethods((prev2) => !prev2);
|
|
23842
|
+
},
|
|
23728
23843
|
$font: theme.typography.link.fontFamily,
|
|
23729
23844
|
$size: theme.typography.link.fontSize,
|
|
23730
23845
|
$weight: theme.typography.link.fontWeight,
|
|
@@ -23747,18 +23862,20 @@ var PaymentMethodDetails = ({
|
|
|
23747
23862
|
]
|
|
23748
23863
|
}
|
|
23749
23864
|
) }),
|
|
23750
|
-
showDifferentPaymentMethods && /* @__PURE__ */ (0, import_jsx_runtime34.
|
|
23751
|
-
(
|
|
23752
|
-
|
|
23753
|
-
|
|
23754
|
-
|
|
23755
|
-
|
|
23756
|
-
|
|
23757
|
-
|
|
23758
|
-
|
|
23759
|
-
|
|
23760
|
-
|
|
23761
|
-
|
|
23865
|
+
showDifferentPaymentMethods && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Flex, { $flexDirection: "column", $overflowY: "hidden", children: [
|
|
23866
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Flex, { $flexDirection: "column", $overflowY: "scroll", children: (data.company?.paymentMethods.filter(
|
|
23867
|
+
(pm) => pm.id !== paymentMethod?.id
|
|
23868
|
+
) || []).map((paymentMethod2) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
23869
|
+
PaymentListElement,
|
|
23870
|
+
{
|
|
23871
|
+
paymentMethod: paymentMethod2,
|
|
23872
|
+
setDefault: updatePaymentMethod,
|
|
23873
|
+
handleDelete: deletePaymentMethod
|
|
23874
|
+
},
|
|
23875
|
+
paymentMethod2.id
|
|
23876
|
+
)) }),
|
|
23877
|
+
(!setupIntent || !paymentMethod || showDifferentPaymentMethods) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Button, { onClick: createSetupIntent, $size: "lg", children: t2("Add new payment method") })
|
|
23878
|
+
] })
|
|
23762
23879
|
] }),
|
|
23763
23880
|
!isLoading && error && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
23764
23881
|
Text,
|
|
@@ -24637,7 +24754,7 @@ var PricingTable = (0, import_react40.forwardRef)(({ children, className, ...res
|
|
|
24637
24754
|
"Current usage exceeds the limit of this plan."
|
|
24638
24755
|
)
|
|
24639
24756
|
}
|
|
24640
|
-
) : plan.companyCanTrial ? t2("
|
|
24757
|
+
) : plan.companyCanTrial ? t2("Start X day trial", { days: plan.trialDays }) : t2("Choose plan")
|
|
24641
24758
|
}
|
|
24642
24759
|
)
|
|
24643
24760
|
]
|