@schematichq/schematic-components 0.7.5 → 0.7.7
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 +351 -414
- package/dist/schematic-components.d.ts +16 -5
- package/dist/schematic-components.esm.js +361 -424
- package/package.json +1 -1
|
@@ -10712,6 +10712,7 @@ function BillingPriceViewFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
10712
10712
|
interval: json["interval"],
|
|
10713
10713
|
isActive: json["is_active"],
|
|
10714
10714
|
meterId: json["meter_id"] == null ? void 0 : json["meter_id"],
|
|
10715
|
+
packageSize: json["package_size"],
|
|
10715
10716
|
price: json["price"],
|
|
10716
10717
|
priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
|
|
10717
10718
|
priceExternalId: json["price_external_id"],
|
|
@@ -10773,6 +10774,7 @@ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDisc
|
|
|
10773
10774
|
interval: json["interval"],
|
|
10774
10775
|
meterId: json["meter_id"] == null ? void 0 : json["meter_id"],
|
|
10775
10776
|
name: json["name"],
|
|
10777
|
+
packageSize: json["package_size"],
|
|
10776
10778
|
price: json["price"],
|
|
10777
10779
|
priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
|
|
10778
10780
|
priceExternalId: json["price_external_id"],
|
|
@@ -13140,7 +13142,7 @@ var EmbedProvider = ({
|
|
|
13140
13142
|
useEffect2(() => {
|
|
13141
13143
|
if (accessToken) {
|
|
13142
13144
|
const { headers = {} } = apiConfig ?? {};
|
|
13143
|
-
headers["X-Schematic-Components-Version"] = "0.7.
|
|
13145
|
+
headers["X-Schematic-Components-Version"] = "0.7.7";
|
|
13144
13146
|
headers["X-Schematic-Session-ID"] = sessionIdRef.current;
|
|
13145
13147
|
const config = new Configuration({
|
|
13146
13148
|
...apiConfig,
|
|
@@ -14397,43 +14399,61 @@ var ProgressBar = ({
|
|
|
14397
14399
|
|
|
14398
14400
|
// src/components/ui/text/styles.ts
|
|
14399
14401
|
var TextPropNames = /* @__PURE__ */ ((TextPropNames2) => {
|
|
14400
|
-
TextPropNames2["Align"] = "$align";
|
|
14401
14402
|
TextPropNames2["Font"] = "$font";
|
|
14402
14403
|
TextPropNames2["Size"] = "$size";
|
|
14403
14404
|
TextPropNames2["Weight"] = "$weight";
|
|
14404
14405
|
TextPropNames2["Color"] = "$color";
|
|
14405
14406
|
TextPropNames2["Leading"] = "$leading";
|
|
14407
|
+
TextPropNames2["Align"] = "$align";
|
|
14406
14408
|
return TextPropNames2;
|
|
14407
14409
|
})(TextPropNames || {});
|
|
14408
|
-
var Text = dt.span.
|
|
14410
|
+
var Text = dt.span.withConfig({
|
|
14411
|
+
shouldForwardProp: (prop) => prop !== "display"
|
|
14412
|
+
}).attrs(({ onClick }) => ({
|
|
14409
14413
|
...onClick && { tabIndex: 0 }
|
|
14410
|
-
}))
|
|
14411
|
-
|
|
14412
|
-
|
|
14413
|
-
|
|
14414
|
-
|
|
14415
|
-
|
|
14416
|
-
|
|
14417
|
-
|
|
14418
|
-
|
|
14419
|
-
|
|
14420
|
-
|
|
14421
|
-
|
|
14422
|
-
|
|
14423
|
-
|
|
14424
|
-
|
|
14425
|
-
|
|
14426
|
-
|
|
14427
|
-
|
|
14428
|
-
|
|
14429
|
-
|
|
14430
|
-
|
|
14431
|
-
|
|
14432
|
-
|
|
14433
|
-
|
|
14414
|
+
}))(
|
|
14415
|
+
({
|
|
14416
|
+
display = "text",
|
|
14417
|
+
theme,
|
|
14418
|
+
onClick,
|
|
14419
|
+
$font,
|
|
14420
|
+
$size,
|
|
14421
|
+
$weight,
|
|
14422
|
+
$color,
|
|
14423
|
+
$leading = 1.35,
|
|
14424
|
+
$align
|
|
14425
|
+
}) => {
|
|
14426
|
+
const settings = theme.typography[display];
|
|
14427
|
+
const fontFamily = $font || settings.fontFamily;
|
|
14428
|
+
const fontSize = $size || settings.fontSize;
|
|
14429
|
+
const fontWeight = $weight || settings.fontWeight;
|
|
14430
|
+
const color = $color || settings.color;
|
|
14431
|
+
return lt`
|
|
14432
|
+
font-family: ${fontFamily}, sans-serif;
|
|
14433
|
+
font-size: ${typeof fontSize === "number" ? `${fontSize / TEXT_BASE_SIZE}rem` : fontSize};
|
|
14434
|
+
font-weight: ${fontWeight};
|
|
14435
|
+
font-variation-settings: "wght" ${fontWeight};
|
|
14436
|
+
line-height: ${$leading};
|
|
14437
|
+
color: ${color};
|
|
14438
|
+
|
|
14439
|
+
${$align && lt`
|
|
14440
|
+
text-align: ${$align};
|
|
14441
|
+
`};
|
|
14442
|
+
|
|
14443
|
+
${onClick && lt`
|
|
14444
|
+
&:hover {
|
|
14445
|
+
cursor: pointer;
|
|
14446
|
+
text-decoration: underline;
|
|
14447
|
+
}
|
|
14448
|
+
`}
|
|
14449
|
+
|
|
14450
|
+
&:focus-visible {
|
|
14451
|
+
outline: 2px solid ${({ theme: theme2 }) => theme2.primary};
|
|
14452
|
+
outline-offset: 2px;
|
|
14434
14453
|
}
|
|
14435
|
-
|
|
14436
|
-
|
|
14454
|
+
`;
|
|
14455
|
+
}
|
|
14456
|
+
);
|
|
14437
14457
|
|
|
14438
14458
|
// src/components/ui/tooltip/Tooltip.tsx
|
|
14439
14459
|
var import_debounce = __toESM(require_debounce());
|
|
@@ -14720,7 +14740,7 @@ var Container2 = dt.div`
|
|
|
14720
14740
|
all: initial;
|
|
14721
14741
|
box-sizing: border-box;
|
|
14722
14742
|
display: block;
|
|
14723
|
-
font-size:
|
|
14743
|
+
font-size: 1rem;
|
|
14724
14744
|
line-height: 1.35;
|
|
14725
14745
|
width: 100%;
|
|
14726
14746
|
height: 100%;
|
|
@@ -14763,7 +14783,7 @@ import { createPortal as createPortal2 } from "react-dom";
|
|
|
14763
14783
|
// src/components/shared/checkout-dialog/CheckoutDialog.tsx
|
|
14764
14784
|
import {
|
|
14765
14785
|
useCallback as useCallback8,
|
|
14766
|
-
useEffect as
|
|
14786
|
+
useEffect as useEffect4,
|
|
14767
14787
|
useLayoutEffect as useLayoutEffect4,
|
|
14768
14788
|
useMemo as useMemo5,
|
|
14769
14789
|
useRef as useRef5,
|
|
@@ -14787,6 +14807,7 @@ var StageButton = ({
|
|
|
14787
14807
|
checkoutStages,
|
|
14788
14808
|
hasAddOns,
|
|
14789
14809
|
hasPayInAdvanceEntitlements,
|
|
14810
|
+
hasUnstagedChanges,
|
|
14790
14811
|
isLoading,
|
|
14791
14812
|
requiresPayment,
|
|
14792
14813
|
setCheckoutStage,
|
|
@@ -14798,7 +14819,7 @@ var StageButton = ({
|
|
|
14798
14819
|
EmbedButton,
|
|
14799
14820
|
{
|
|
14800
14821
|
type: "button",
|
|
14801
|
-
disabled: isLoading || !canUpdateSubscription,
|
|
14822
|
+
disabled: isLoading || !hasUnstagedChanges || !canUpdateSubscription,
|
|
14802
14823
|
onClick: checkout,
|
|
14803
14824
|
isLoading,
|
|
14804
14825
|
children: t2("Subscribe and close")
|
|
@@ -14839,7 +14860,7 @@ var StageButton = ({
|
|
|
14839
14860
|
EmbedButton,
|
|
14840
14861
|
{
|
|
14841
14862
|
type: "button",
|
|
14842
|
-
disabled: !canUpdateSubscription,
|
|
14863
|
+
disabled: !hasUnstagedChanges || !canUpdateSubscription,
|
|
14843
14864
|
onClick: async () => {
|
|
14844
14865
|
checkout();
|
|
14845
14866
|
},
|
|
@@ -14965,7 +14986,7 @@ var StageButton = ({
|
|
|
14965
14986
|
EmbedButton,
|
|
14966
14987
|
{
|
|
14967
14988
|
type: "button",
|
|
14968
|
-
disabled: isLoading || !canCheckout,
|
|
14989
|
+
disabled: isLoading || !hasUnstagedChanges || !canCheckout,
|
|
14969
14990
|
onClick: checkout,
|
|
14970
14991
|
isLoading,
|
|
14971
14992
|
children: canTrial ? t2("Start trial") : t2("Pay now")
|
|
@@ -15169,14 +15190,6 @@ var Sidebar = ({
|
|
|
15169
15190
|
}
|
|
15170
15191
|
}, [t2, api, hydrate, setError, setIsLoading, setLayout]);
|
|
15171
15192
|
const selectedAddOns = addOns.filter((addOn) => addOn.isSelected);
|
|
15172
|
-
const willPlanChange = typeof selectedPlan !== "undefined" && !selectedPlan.current;
|
|
15173
|
-
const canUpdateSubscription = mode === "edit" || api !== null && (willPlanChange || // TODO: test add-on comparison for finding "changes"
|
|
15174
|
-
selectedAddOns.length !== currentAddOns.length || !selectedAddOns.every(
|
|
15175
|
-
(addOn) => currentAddOns.some((currentAddOn) => addOn.id === currentAddOn.id)
|
|
15176
|
-
) || payInAdvanceEntitlements.every(
|
|
15177
|
-
({ quantity, usage }) => quantity >= usage
|
|
15178
|
-
)) && !isLoading;
|
|
15179
|
-
const canCheckout = canUpdateSubscription && (!!data.subscription?.paymentMethod || typeof paymentMethodId === "string");
|
|
15180
15193
|
const {
|
|
15181
15194
|
changedUsageBasedEntitlements,
|
|
15182
15195
|
addedUsageBasedEntitlements,
|
|
@@ -15233,6 +15246,7 @@ var Sidebar = ({
|
|
|
15233
15246
|
currentUsageBasedEntitlements,
|
|
15234
15247
|
usageBasedEntitlements
|
|
15235
15248
|
]);
|
|
15249
|
+
const willPlanChange = typeof selectedPlan !== "undefined" && !selectedPlan.current;
|
|
15236
15250
|
const removedAddOns = currentAddOns.filter(
|
|
15237
15251
|
(current) => !selectedAddOns.some((selected) => current.id === selected.id)
|
|
15238
15252
|
);
|
|
@@ -15240,6 +15254,10 @@ var Sidebar = ({
|
|
|
15240
15254
|
(selected) => !currentAddOns.some((current) => selected.id === current.id)
|
|
15241
15255
|
);
|
|
15242
15256
|
const willAddOnsChange = removedAddOns.length > 0 || addedAddOns.length > 0;
|
|
15257
|
+
const willPayInAdvanceEntitlementsChange = payInAdvanceEntitlements.length > 0 && payInAdvanceEntitlements.some(({ quantity, usage }) => quantity !== usage);
|
|
15258
|
+
const hasUnstagedChanges = willPlanChange || willAddOnsChange || willPayInAdvanceEntitlementsChange;
|
|
15259
|
+
const canUpdateSubscription = mode === "edit" || api !== null && !isLoading;
|
|
15260
|
+
const canCheckout = canUpdateSubscription && (!!data.subscription?.paymentMethod || typeof paymentMethodId === "string");
|
|
15243
15261
|
const isTrialable = selectedPlan?.companyCanTrial;
|
|
15244
15262
|
const today = /* @__PURE__ */ new Date();
|
|
15245
15263
|
const trialEndsOn = new Date(today);
|
|
@@ -16151,6 +16169,7 @@ var Sidebar = ({
|
|
|
16151
16169
|
checkoutStages,
|
|
16152
16170
|
hasAddOns: addOns.length > 0,
|
|
16153
16171
|
hasPayInAdvanceEntitlements: payInAdvanceEntitlements.length > 0,
|
|
16172
|
+
hasUnstagedChanges,
|
|
16154
16173
|
isLoading,
|
|
16155
16174
|
requiresPayment,
|
|
16156
16175
|
setCheckoutStage,
|
|
@@ -16331,160 +16350,8 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
|
|
|
16331
16350
|
) });
|
|
16332
16351
|
};
|
|
16333
16352
|
|
|
16334
|
-
// node_modules/@stripe/stripe-js/dist/index.mjs
|
|
16335
|
-
var RELEASE_TRAIN = "basil";
|
|
16336
|
-
var runtimeVersionToUrlVersion = function runtimeVersionToUrlVersion2(version) {
|
|
16337
|
-
return version === 3 ? "v3" : version;
|
|
16338
|
-
};
|
|
16339
|
-
var ORIGIN = "https://js.stripe.com";
|
|
16340
|
-
var STRIPE_JS_URL = "".concat(ORIGIN, "/").concat(RELEASE_TRAIN, "/stripe.js");
|
|
16341
|
-
var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
|
|
16342
|
-
var STRIPE_JS_URL_REGEX = /^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;
|
|
16343
|
-
var EXISTING_SCRIPT_MESSAGE = "loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";
|
|
16344
|
-
var isStripeJSURL = function isStripeJSURL2(url) {
|
|
16345
|
-
return V3_URL_REGEX.test(url) || STRIPE_JS_URL_REGEX.test(url);
|
|
16346
|
-
};
|
|
16347
|
-
var findScript = function findScript2() {
|
|
16348
|
-
var scripts = document.querySelectorAll('script[src^="'.concat(ORIGIN, '"]'));
|
|
16349
|
-
for (var i2 = 0; i2 < scripts.length; i2++) {
|
|
16350
|
-
var script = scripts[i2];
|
|
16351
|
-
if (!isStripeJSURL(script.src)) {
|
|
16352
|
-
continue;
|
|
16353
|
-
}
|
|
16354
|
-
return script;
|
|
16355
|
-
}
|
|
16356
|
-
return null;
|
|
16357
|
-
};
|
|
16358
|
-
var injectScript = function injectScript2(params) {
|
|
16359
|
-
var queryString = params && !params.advancedFraudSignals ? "?advancedFraudSignals=false" : "";
|
|
16360
|
-
var script = document.createElement("script");
|
|
16361
|
-
script.src = "".concat(STRIPE_JS_URL).concat(queryString);
|
|
16362
|
-
var headOrBody = document.head || document.body;
|
|
16363
|
-
if (!headOrBody) {
|
|
16364
|
-
throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");
|
|
16365
|
-
}
|
|
16366
|
-
headOrBody.appendChild(script);
|
|
16367
|
-
return script;
|
|
16368
|
-
};
|
|
16369
|
-
var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
16370
|
-
if (!stripe || !stripe._registerWrapper) {
|
|
16371
|
-
return;
|
|
16372
|
-
}
|
|
16373
|
-
stripe._registerWrapper({
|
|
16374
|
-
name: "stripe-js",
|
|
16375
|
-
version: "7.0.0",
|
|
16376
|
-
startTime
|
|
16377
|
-
});
|
|
16378
|
-
};
|
|
16379
|
-
var stripePromise$1 = null;
|
|
16380
|
-
var onErrorListener = null;
|
|
16381
|
-
var onLoadListener = null;
|
|
16382
|
-
var onError = function onError2(reject) {
|
|
16383
|
-
return function(cause) {
|
|
16384
|
-
reject(new Error("Failed to load Stripe.js", {
|
|
16385
|
-
cause
|
|
16386
|
-
}));
|
|
16387
|
-
};
|
|
16388
|
-
};
|
|
16389
|
-
var onLoad = function onLoad2(resolve, reject) {
|
|
16390
|
-
return function() {
|
|
16391
|
-
if (window.Stripe) {
|
|
16392
|
-
resolve(window.Stripe);
|
|
16393
|
-
} else {
|
|
16394
|
-
reject(new Error("Stripe.js not available"));
|
|
16395
|
-
}
|
|
16396
|
-
};
|
|
16397
|
-
};
|
|
16398
|
-
var loadScript = function loadScript2(params) {
|
|
16399
|
-
if (stripePromise$1 !== null) {
|
|
16400
|
-
return stripePromise$1;
|
|
16401
|
-
}
|
|
16402
|
-
stripePromise$1 = new Promise(function(resolve, reject) {
|
|
16403
|
-
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
16404
|
-
resolve(null);
|
|
16405
|
-
return;
|
|
16406
|
-
}
|
|
16407
|
-
if (window.Stripe && params) {
|
|
16408
|
-
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
16409
|
-
}
|
|
16410
|
-
if (window.Stripe) {
|
|
16411
|
-
resolve(window.Stripe);
|
|
16412
|
-
return;
|
|
16413
|
-
}
|
|
16414
|
-
try {
|
|
16415
|
-
var script = findScript();
|
|
16416
|
-
if (script && params) {
|
|
16417
|
-
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
16418
|
-
} else if (!script) {
|
|
16419
|
-
script = injectScript(params);
|
|
16420
|
-
} else if (script && onLoadListener !== null && onErrorListener !== null) {
|
|
16421
|
-
var _script$parentNode;
|
|
16422
|
-
script.removeEventListener("load", onLoadListener);
|
|
16423
|
-
script.removeEventListener("error", onErrorListener);
|
|
16424
|
-
(_script$parentNode = script.parentNode) === null || _script$parentNode === void 0 ? void 0 : _script$parentNode.removeChild(script);
|
|
16425
|
-
script = injectScript(params);
|
|
16426
|
-
}
|
|
16427
|
-
onLoadListener = onLoad(resolve, reject);
|
|
16428
|
-
onErrorListener = onError(reject);
|
|
16429
|
-
script.addEventListener("load", onLoadListener);
|
|
16430
|
-
script.addEventListener("error", onErrorListener);
|
|
16431
|
-
} catch (error) {
|
|
16432
|
-
reject(error);
|
|
16433
|
-
return;
|
|
16434
|
-
}
|
|
16435
|
-
});
|
|
16436
|
-
return stripePromise$1["catch"](function(error) {
|
|
16437
|
-
stripePromise$1 = null;
|
|
16438
|
-
return Promise.reject(error);
|
|
16439
|
-
});
|
|
16440
|
-
};
|
|
16441
|
-
var initStripe = function initStripe2(maybeStripe, args, startTime) {
|
|
16442
|
-
if (maybeStripe === null) {
|
|
16443
|
-
return null;
|
|
16444
|
-
}
|
|
16445
|
-
var pk = args[0];
|
|
16446
|
-
var isTestKey = pk.match(/^pk_test/);
|
|
16447
|
-
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
16448
|
-
var expectedVersion = RELEASE_TRAIN;
|
|
16449
|
-
if (isTestKey && version !== expectedVersion) {
|
|
16450
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.0.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
16451
|
-
}
|
|
16452
|
-
var stripe = maybeStripe.apply(void 0, args);
|
|
16453
|
-
registerWrapper(stripe, startTime);
|
|
16454
|
-
return stripe;
|
|
16455
|
-
};
|
|
16456
|
-
var stripePromise;
|
|
16457
|
-
var loadCalled = false;
|
|
16458
|
-
var getStripePromise = function getStripePromise2() {
|
|
16459
|
-
if (stripePromise) {
|
|
16460
|
-
return stripePromise;
|
|
16461
|
-
}
|
|
16462
|
-
stripePromise = loadScript(null)["catch"](function(error) {
|
|
16463
|
-
stripePromise = null;
|
|
16464
|
-
return Promise.reject(error);
|
|
16465
|
-
});
|
|
16466
|
-
return stripePromise;
|
|
16467
|
-
};
|
|
16468
|
-
Promise.resolve().then(function() {
|
|
16469
|
-
return getStripePromise();
|
|
16470
|
-
})["catch"](function(error) {
|
|
16471
|
-
if (!loadCalled) {
|
|
16472
|
-
console.warn(error);
|
|
16473
|
-
}
|
|
16474
|
-
});
|
|
16475
|
-
var loadStripe = function loadStripe2() {
|
|
16476
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
16477
|
-
args[_key] = arguments[_key];
|
|
16478
|
-
}
|
|
16479
|
-
loadCalled = true;
|
|
16480
|
-
var startTime = Date.now();
|
|
16481
|
-
return getStripePromise().then(function(maybeStripe) {
|
|
16482
|
-
return initStripe(maybeStripe, args, startTime);
|
|
16483
|
-
});
|
|
16484
|
-
};
|
|
16485
|
-
|
|
16486
16353
|
// src/components/shared/checkout-dialog/Checkout.tsx
|
|
16487
|
-
import {
|
|
16354
|
+
import { useState as useState5 } from "react";
|
|
16488
16355
|
import { Fragment as Fragment5, jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
16489
16356
|
var Checkout = ({
|
|
16490
16357
|
requiresPayment,
|
|
@@ -16493,36 +16360,11 @@ var Checkout = ({
|
|
|
16493
16360
|
}) => {
|
|
16494
16361
|
const { t: t2 } = useTranslation();
|
|
16495
16362
|
const theme = nt();
|
|
16496
|
-
const { api, data } = useEmbed();
|
|
16497
16363
|
const isLightBackground = useIsLightBackground();
|
|
16498
|
-
const [stripe, setStripe] = useState5(null);
|
|
16499
|
-
const [setupIntent, setSetupIntent] = useState5();
|
|
16500
16364
|
const [discount, setDiscount] = useState5("");
|
|
16501
|
-
useEffect4(() => {
|
|
16502
|
-
if (api && data.component?.id) {
|
|
16503
|
-
api.getSetupIntent({ componentId: data.component.id }).then((res) => setSetupIntent(res.data));
|
|
16504
|
-
}
|
|
16505
|
-
}, [api, data.component?.id]);
|
|
16506
|
-
useEffect4(() => {
|
|
16507
|
-
if (setupIntent?.publishableKey) {
|
|
16508
|
-
setStripe(loadStripe(setupIntent.publishableKey));
|
|
16509
|
-
}
|
|
16510
|
-
}, [setupIntent?.publishableKey]);
|
|
16511
16365
|
if (!requiresPayment) {
|
|
16512
16366
|
return null;
|
|
16513
16367
|
}
|
|
16514
|
-
if (!stripe) {
|
|
16515
|
-
return /* @__PURE__ */ jsx15(
|
|
16516
|
-
Flex,
|
|
16517
|
-
{
|
|
16518
|
-
$justifyContent: "center",
|
|
16519
|
-
$alignItems: "center",
|
|
16520
|
-
$flexGrow: 1,
|
|
16521
|
-
$marginTop: "-3.5rem",
|
|
16522
|
-
children: /* @__PURE__ */ jsx15(Loader, { $color: theme.primary, $size: "3xl" })
|
|
16523
|
-
}
|
|
16524
|
-
);
|
|
16525
|
-
}
|
|
16526
16368
|
return /* @__PURE__ */ jsxs10(Fragment5, { children: [
|
|
16527
16369
|
/* @__PURE__ */ jsx15(PaymentMethodDetails, { setPaymentMethodId }),
|
|
16528
16370
|
/* @__PURE__ */ jsxs10(Flex, { $flexDirection: "column", $gap: "1rem", children: [
|
|
@@ -16876,12 +16718,19 @@ var Plan = ({
|
|
|
16876
16718
|
}[entitlement.metricPeriod];
|
|
16877
16719
|
}
|
|
16878
16720
|
const limit = entitlement.softLimit ?? entitlement.valueNumeric;
|
|
16879
|
-
const
|
|
16880
|
-
price: entitlementPrice,
|
|
16881
|
-
currency: entitlementCurrency
|
|
16882
|
-
} = getBillingPrice(
|
|
16721
|
+
const entitlementPriceObject = getBillingPrice(
|
|
16883
16722
|
period === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice
|
|
16884
|
-
) ||
|
|
16723
|
+
) || null;
|
|
16724
|
+
let entitlementPrice = entitlementPriceObject?.price;
|
|
16725
|
+
const entitlementCurrency = entitlementPriceObject?.currency;
|
|
16726
|
+
if (entitlement.priceBehavior === "overage" && entitlementPriceObject) {
|
|
16727
|
+
const { priceTier } = entitlementPriceObject;
|
|
16728
|
+
if (priceTier.length) {
|
|
16729
|
+
const lastTier = priceTier[priceTier.length - 1];
|
|
16730
|
+
const { perUnitPrice, perUnitPriceDecimal } = lastTier;
|
|
16731
|
+
entitlementPrice = perUnitPriceDecimal ? Number(perUnitPriceDecimal) : perUnitPrice ?? 0;
|
|
16732
|
+
}
|
|
16733
|
+
}
|
|
16885
16734
|
if (entitlement.priceBehavior && typeof entitlementPrice !== "number") {
|
|
16886
16735
|
return acc;
|
|
16887
16736
|
}
|
|
@@ -17541,7 +17390,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
17541
17390
|
setPromoCode(code);
|
|
17542
17391
|
previewCheckout({ promoCode: code });
|
|
17543
17392
|
};
|
|
17544
|
-
|
|
17393
|
+
useEffect4(() => {
|
|
17545
17394
|
if (charges) {
|
|
17546
17395
|
checkoutRef.current?.scrollIntoView({
|
|
17547
17396
|
behavior: "smooth",
|
|
@@ -18338,6 +18187,10 @@ var StyledViewport = dt.div.withConfig({
|
|
|
18338
18187
|
@media (min-width: 768px) {
|
|
18339
18188
|
grid-template-columns: ${({ theme }) => lt`repeat(${theme.numberOfColumns}, minmax(300px, 1fr))`};
|
|
18340
18189
|
}
|
|
18190
|
+
|
|
18191
|
+
@container (max-width: 768px) {
|
|
18192
|
+
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
|
18193
|
+
}
|
|
18341
18194
|
`;
|
|
18342
18195
|
|
|
18343
18196
|
// src/components/layout/viewport/Viewport.tsx
|
|
@@ -18766,7 +18619,7 @@ var IncludedFeatures = forwardRef8(({ className, ...rest }, ref) => {
|
|
|
18766
18619
|
IncludedFeatures.displayName = "IncludedFeatures";
|
|
18767
18620
|
|
|
18768
18621
|
// src/components/elements/invoices/Invoices.tsx
|
|
18769
|
-
import { forwardRef as forwardRef9, useEffect as
|
|
18622
|
+
import { forwardRef as forwardRef9, useEffect as useEffect5, useState as useState13 } from "react";
|
|
18770
18623
|
import { jsx as jsx30, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
18771
18624
|
function resolveDesignProps3(props) {
|
|
18772
18625
|
return {
|
|
@@ -18830,11 +18683,14 @@ var Invoices = forwardRef9(({ className, data, ...rest }, ref) => {
|
|
|
18830
18683
|
(prev2) => prev2 !== props.limit.number ? props.limit.number : MAX_VISIBLE_INVOICE_COUNT
|
|
18831
18684
|
);
|
|
18832
18685
|
};
|
|
18833
|
-
|
|
18834
|
-
api?.listInvoices().then((
|
|
18835
|
-
setInvoices(formatInvoices(
|
|
18686
|
+
useEffect5(() => {
|
|
18687
|
+
api?.listInvoices().then((response) => {
|
|
18688
|
+
setInvoices(formatInvoices(response.data));
|
|
18836
18689
|
});
|
|
18837
18690
|
}, [api]);
|
|
18691
|
+
useEffect5(() => {
|
|
18692
|
+
setInvoices(formatInvoices(data));
|
|
18693
|
+
}, [data]);
|
|
18838
18694
|
if (invoices.length === 0) {
|
|
18839
18695
|
return null;
|
|
18840
18696
|
}
|
|
@@ -19008,9 +18864,32 @@ var MeteredFeatures = forwardRef10(({ className, ...rest }, ref) => {
|
|
|
19008
18864
|
}, index) => {
|
|
19009
18865
|
const limit = softLimit ?? allocation ?? 0;
|
|
19010
18866
|
const isOverage = priceBehavior === "overage" && typeof softLimit === "number" && typeof usage === "number" && usage > softLimit;
|
|
19011
|
-
|
|
18867
|
+
let { price, currency } = getBillingPrice(
|
|
19012
18868
|
planPeriod === "year" ? yearlyUsageBasedPrice : monthlyUsageBasedPrice
|
|
19013
18869
|
) || {};
|
|
18870
|
+
if (priceBehavior === "overage") {
|
|
18871
|
+
const productId = (yearlyUsageBasedPrice ?? monthlyUsageBasedPrice)?.productId;
|
|
18872
|
+
if (productId) {
|
|
18873
|
+
const products = data?.subscription?.products ?? [];
|
|
18874
|
+
const product = products.find((p2) => p2.id === productId);
|
|
18875
|
+
if (product && product.priceTier?.length > 1) {
|
|
18876
|
+
const overagePrice = product.priceTier[product.priceTier.length - 1];
|
|
18877
|
+
price = overagePrice.perUnitPriceDecimal ? Number(overagePrice.perUnitPriceDecimal) : overagePrice.perUnitPrice ?? 0;
|
|
18878
|
+
currency = product.currency;
|
|
18879
|
+
}
|
|
18880
|
+
}
|
|
18881
|
+
}
|
|
18882
|
+
if (isOverage) {
|
|
18883
|
+
const productId = (yearlyUsageBasedPrice ?? monthlyUsageBasedPrice).productId;
|
|
18884
|
+
if (productId) {
|
|
18885
|
+
const products = data?.subscription?.products ?? [];
|
|
18886
|
+
const product = products.find((p2) => p2.id === productId);
|
|
18887
|
+
if (product) {
|
|
18888
|
+
price = product.price;
|
|
18889
|
+
currency = product.currency;
|
|
18890
|
+
}
|
|
18891
|
+
}
|
|
18892
|
+
}
|
|
19014
18893
|
const progressBar = props.isVisible && typeof usage === "number" && limit > 0 && priceBehavior !== "pay_as_you_go" && /* @__PURE__ */ jsx31(
|
|
19015
18894
|
ProgressBar,
|
|
19016
18895
|
{
|
|
@@ -19561,7 +19440,161 @@ PaymentMethod.displayName = "PaymentMethod";
|
|
|
19561
19440
|
|
|
19562
19441
|
// src/components/elements/payment-method/PaymentMethodDetails.tsx
|
|
19563
19442
|
import { Elements } from "@stripe/react-stripe-js";
|
|
19564
|
-
|
|
19443
|
+
|
|
19444
|
+
// node_modules/@stripe/stripe-js/dist/index.mjs
|
|
19445
|
+
var RELEASE_TRAIN = "basil";
|
|
19446
|
+
var runtimeVersionToUrlVersion = function runtimeVersionToUrlVersion2(version) {
|
|
19447
|
+
return version === 3 ? "v3" : version;
|
|
19448
|
+
};
|
|
19449
|
+
var ORIGIN = "https://js.stripe.com";
|
|
19450
|
+
var STRIPE_JS_URL = "".concat(ORIGIN, "/").concat(RELEASE_TRAIN, "/stripe.js");
|
|
19451
|
+
var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
|
|
19452
|
+
var STRIPE_JS_URL_REGEX = /^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;
|
|
19453
|
+
var EXISTING_SCRIPT_MESSAGE = "loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";
|
|
19454
|
+
var isStripeJSURL = function isStripeJSURL2(url) {
|
|
19455
|
+
return V3_URL_REGEX.test(url) || STRIPE_JS_URL_REGEX.test(url);
|
|
19456
|
+
};
|
|
19457
|
+
var findScript = function findScript2() {
|
|
19458
|
+
var scripts = document.querySelectorAll('script[src^="'.concat(ORIGIN, '"]'));
|
|
19459
|
+
for (var i2 = 0; i2 < scripts.length; i2++) {
|
|
19460
|
+
var script = scripts[i2];
|
|
19461
|
+
if (!isStripeJSURL(script.src)) {
|
|
19462
|
+
continue;
|
|
19463
|
+
}
|
|
19464
|
+
return script;
|
|
19465
|
+
}
|
|
19466
|
+
return null;
|
|
19467
|
+
};
|
|
19468
|
+
var injectScript = function injectScript2(params) {
|
|
19469
|
+
var queryString = params && !params.advancedFraudSignals ? "?advancedFraudSignals=false" : "";
|
|
19470
|
+
var script = document.createElement("script");
|
|
19471
|
+
script.src = "".concat(STRIPE_JS_URL).concat(queryString);
|
|
19472
|
+
var headOrBody = document.head || document.body;
|
|
19473
|
+
if (!headOrBody) {
|
|
19474
|
+
throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");
|
|
19475
|
+
}
|
|
19476
|
+
headOrBody.appendChild(script);
|
|
19477
|
+
return script;
|
|
19478
|
+
};
|
|
19479
|
+
var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
19480
|
+
if (!stripe || !stripe._registerWrapper) {
|
|
19481
|
+
return;
|
|
19482
|
+
}
|
|
19483
|
+
stripe._registerWrapper({
|
|
19484
|
+
name: "stripe-js",
|
|
19485
|
+
version: "7.0.0",
|
|
19486
|
+
startTime
|
|
19487
|
+
});
|
|
19488
|
+
};
|
|
19489
|
+
var stripePromise$1 = null;
|
|
19490
|
+
var onErrorListener = null;
|
|
19491
|
+
var onLoadListener = null;
|
|
19492
|
+
var onError = function onError2(reject) {
|
|
19493
|
+
return function(cause) {
|
|
19494
|
+
reject(new Error("Failed to load Stripe.js", {
|
|
19495
|
+
cause
|
|
19496
|
+
}));
|
|
19497
|
+
};
|
|
19498
|
+
};
|
|
19499
|
+
var onLoad = function onLoad2(resolve, reject) {
|
|
19500
|
+
return function() {
|
|
19501
|
+
if (window.Stripe) {
|
|
19502
|
+
resolve(window.Stripe);
|
|
19503
|
+
} else {
|
|
19504
|
+
reject(new Error("Stripe.js not available"));
|
|
19505
|
+
}
|
|
19506
|
+
};
|
|
19507
|
+
};
|
|
19508
|
+
var loadScript = function loadScript2(params) {
|
|
19509
|
+
if (stripePromise$1 !== null) {
|
|
19510
|
+
return stripePromise$1;
|
|
19511
|
+
}
|
|
19512
|
+
stripePromise$1 = new Promise(function(resolve, reject) {
|
|
19513
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
19514
|
+
resolve(null);
|
|
19515
|
+
return;
|
|
19516
|
+
}
|
|
19517
|
+
if (window.Stripe && params) {
|
|
19518
|
+
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
19519
|
+
}
|
|
19520
|
+
if (window.Stripe) {
|
|
19521
|
+
resolve(window.Stripe);
|
|
19522
|
+
return;
|
|
19523
|
+
}
|
|
19524
|
+
try {
|
|
19525
|
+
var script = findScript();
|
|
19526
|
+
if (script && params) {
|
|
19527
|
+
console.warn(EXISTING_SCRIPT_MESSAGE);
|
|
19528
|
+
} else if (!script) {
|
|
19529
|
+
script = injectScript(params);
|
|
19530
|
+
} else if (script && onLoadListener !== null && onErrorListener !== null) {
|
|
19531
|
+
var _script$parentNode;
|
|
19532
|
+
script.removeEventListener("load", onLoadListener);
|
|
19533
|
+
script.removeEventListener("error", onErrorListener);
|
|
19534
|
+
(_script$parentNode = script.parentNode) === null || _script$parentNode === void 0 ? void 0 : _script$parentNode.removeChild(script);
|
|
19535
|
+
script = injectScript(params);
|
|
19536
|
+
}
|
|
19537
|
+
onLoadListener = onLoad(resolve, reject);
|
|
19538
|
+
onErrorListener = onError(reject);
|
|
19539
|
+
script.addEventListener("load", onLoadListener);
|
|
19540
|
+
script.addEventListener("error", onErrorListener);
|
|
19541
|
+
} catch (error) {
|
|
19542
|
+
reject(error);
|
|
19543
|
+
return;
|
|
19544
|
+
}
|
|
19545
|
+
});
|
|
19546
|
+
return stripePromise$1["catch"](function(error) {
|
|
19547
|
+
stripePromise$1 = null;
|
|
19548
|
+
return Promise.reject(error);
|
|
19549
|
+
});
|
|
19550
|
+
};
|
|
19551
|
+
var initStripe = function initStripe2(maybeStripe, args, startTime) {
|
|
19552
|
+
if (maybeStripe === null) {
|
|
19553
|
+
return null;
|
|
19554
|
+
}
|
|
19555
|
+
var pk = args[0];
|
|
19556
|
+
var isTestKey = pk.match(/^pk_test/);
|
|
19557
|
+
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
19558
|
+
var expectedVersion = RELEASE_TRAIN;
|
|
19559
|
+
if (isTestKey && version !== expectedVersion) {
|
|
19560
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.0.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
19561
|
+
}
|
|
19562
|
+
var stripe = maybeStripe.apply(void 0, args);
|
|
19563
|
+
registerWrapper(stripe, startTime);
|
|
19564
|
+
return stripe;
|
|
19565
|
+
};
|
|
19566
|
+
var stripePromise;
|
|
19567
|
+
var loadCalled = false;
|
|
19568
|
+
var getStripePromise = function getStripePromise2() {
|
|
19569
|
+
if (stripePromise) {
|
|
19570
|
+
return stripePromise;
|
|
19571
|
+
}
|
|
19572
|
+
stripePromise = loadScript(null)["catch"](function(error) {
|
|
19573
|
+
stripePromise = null;
|
|
19574
|
+
return Promise.reject(error);
|
|
19575
|
+
});
|
|
19576
|
+
return stripePromise;
|
|
19577
|
+
};
|
|
19578
|
+
Promise.resolve().then(function() {
|
|
19579
|
+
return getStripePromise();
|
|
19580
|
+
})["catch"](function(error) {
|
|
19581
|
+
if (!loadCalled) {
|
|
19582
|
+
console.warn(error);
|
|
19583
|
+
}
|
|
19584
|
+
});
|
|
19585
|
+
var loadStripe = function loadStripe2() {
|
|
19586
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
19587
|
+
args[_key] = arguments[_key];
|
|
19588
|
+
}
|
|
19589
|
+
loadCalled = true;
|
|
19590
|
+
var startTime = Date.now();
|
|
19591
|
+
return getStripePromise().then(function(maybeStripe) {
|
|
19592
|
+
return initStripe(maybeStripe, args, startTime);
|
|
19593
|
+
});
|
|
19594
|
+
};
|
|
19595
|
+
|
|
19596
|
+
// src/components/elements/payment-method/PaymentMethodDetails.tsx
|
|
19597
|
+
import { useCallback as useCallback10, useEffect as useEffect6, useMemo as useMemo13, useState as useState14 } from "react";
|
|
19565
19598
|
import { jsx as jsx34, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
19566
19599
|
var resolveDesignProps6 = () => {
|
|
19567
19600
|
return {
|
|
@@ -19590,7 +19623,7 @@ var PaymentMethodDetails = ({
|
|
|
19590
19623
|
const [setupIntent, setSetupIntent] = useState14();
|
|
19591
19624
|
const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = useState14(false);
|
|
19592
19625
|
const [paymentMethod, setPaymentMethod] = useState14(void 0);
|
|
19593
|
-
|
|
19626
|
+
useEffect6(() => {
|
|
19594
19627
|
setPaymentMethod(
|
|
19595
19628
|
data.subscription?.paymentMethod || data.company?.defaultPaymentMethod
|
|
19596
19629
|
);
|
|
@@ -19608,7 +19641,7 @@ var PaymentMethodDetails = ({
|
|
|
19608
19641
|
}
|
|
19609
19642
|
return expiration;
|
|
19610
19643
|
}, [paymentMethod?.cardExpYear, paymentMethod?.cardExpMonth]);
|
|
19611
|
-
|
|
19644
|
+
useEffect6(() => {
|
|
19612
19645
|
if (!stripe && setupIntent?.publishableKey) {
|
|
19613
19646
|
setStripe(loadStripe(setupIntent.publishableKey));
|
|
19614
19647
|
}
|
|
@@ -19911,7 +19944,7 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
|
|
|
19911
19944
|
const isTrialSubscription = billingSubscription?.status === "trialing";
|
|
19912
19945
|
const willSubscriptionCancel = billingSubscription?.cancelAtPeriodEnd;
|
|
19913
19946
|
const isUsageBasedPlan = currentPlan?.planPrice === 0 && usageBasedEntitlements.length > 0;
|
|
19914
|
-
const headerPriceFontStyle = isUsageBasedPlan ?
|
|
19947
|
+
const headerPriceFontStyle = isUsageBasedPlan ? "heading3" : props.header.price.fontStyle;
|
|
19915
19948
|
return /* @__PURE__ */ jsxs27(Fragment11, { children: [
|
|
19916
19949
|
isTrialSubscription && !willSubscriptionCancel ? /* @__PURE__ */ jsxs27(
|
|
19917
19950
|
Notice,
|
|
@@ -19923,32 +19956,12 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
|
|
|
19923
19956
|
$textAlign: "center",
|
|
19924
19957
|
$backgroundColor: isLightBackground ? darken(theme.card.background, 0.04) : lighten(theme.card.background, 0.04),
|
|
19925
19958
|
children: [
|
|
19926
|
-
/* @__PURE__ */ jsx35(
|
|
19927
|
-
|
|
19928
|
-
|
|
19929
|
-
|
|
19930
|
-
|
|
19931
|
-
|
|
19932
|
-
$weight: theme.typography.heading3.fontWeight,
|
|
19933
|
-
$color: theme.typography.heading3.color,
|
|
19934
|
-
children: t2("Trial ends in", { days: trialEndDays.toString() })
|
|
19935
|
-
}
|
|
19936
|
-
),
|
|
19937
|
-
/* @__PURE__ */ jsx35(
|
|
19938
|
-
Text,
|
|
19939
|
-
{
|
|
19940
|
-
as: "p",
|
|
19941
|
-
$font: theme.typography.text.fontFamily,
|
|
19942
|
-
$size: 0.8125 * theme.typography.text.fontSize,
|
|
19943
|
-
$weight: theme.typography.text.fontWeight,
|
|
19944
|
-
$color: theme.typography.text.color,
|
|
19945
|
-
children: data.trialPaymentMethodRequired ? t2("After the trial, subscribe") : defaultPlan ? t2("After the trial, cancel", {
|
|
19946
|
-
defaultPlanName: defaultPlan?.name
|
|
19947
|
-
}) : t2("After the trial, cancel no default", {
|
|
19948
|
-
planName: currentPlan?.name
|
|
19949
|
-
})
|
|
19950
|
-
}
|
|
19951
|
-
)
|
|
19959
|
+
/* @__PURE__ */ jsx35(Text, { as: "h3", display: "heading3", children: t2("Trial ends in", { days: trialEndDays.toString() }) }),
|
|
19960
|
+
/* @__PURE__ */ jsx35(Text, { as: "p", $size: 0.8125 * theme.typography.text.fontSize, children: data.trialPaymentMethodRequired ? t2("After the trial, subscribe") : defaultPlan ? t2("After the trial, cancel", {
|
|
19961
|
+
defaultPlanName: defaultPlan?.name
|
|
19962
|
+
}) : t2("After the trial, cancel no default", {
|
|
19963
|
+
planName: currentPlan?.name
|
|
19964
|
+
}) })
|
|
19952
19965
|
]
|
|
19953
19966
|
}
|
|
19954
19967
|
) : willSubscriptionCancel && /* @__PURE__ */ jsxs27(
|
|
@@ -19961,35 +19974,15 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
|
|
|
19961
19974
|
$textAlign: "center",
|
|
19962
19975
|
$backgroundColor: isLightBackground ? darken(theme.card.background, 0.04) : lighten(theme.card.background, 0.04),
|
|
19963
19976
|
children: [
|
|
19964
|
-
/* @__PURE__ */ jsx35(
|
|
19965
|
-
|
|
19966
|
-
|
|
19967
|
-
|
|
19968
|
-
|
|
19969
|
-
|
|
19970
|
-
|
|
19971
|
-
|
|
19972
|
-
|
|
19973
|
-
}
|
|
19974
|
-
),
|
|
19975
|
-
billingSubscription?.cancelAt && /* @__PURE__ */ jsx35(
|
|
19976
|
-
Text,
|
|
19977
|
-
{
|
|
19978
|
-
as: "p",
|
|
19979
|
-
$font: theme.typography.text.fontFamily,
|
|
19980
|
-
$size: 0.8125 * theme.typography.text.fontSize,
|
|
19981
|
-
$weight: theme.typography.text.fontWeight,
|
|
19982
|
-
$color: theme.typography.text.color,
|
|
19983
|
-
children: t2("Access to plan will end on", {
|
|
19984
|
-
date: toPrettyDate(
|
|
19985
|
-
new Date(billingSubscription.cancelAt * 1e3),
|
|
19986
|
-
{
|
|
19987
|
-
month: "numeric"
|
|
19988
|
-
}
|
|
19989
|
-
)
|
|
19990
|
-
})
|
|
19991
|
-
}
|
|
19992
|
-
)
|
|
19977
|
+
/* @__PURE__ */ jsx35(Text, { as: "h3", display: "heading3", children: t2("Subscription canceled") }),
|
|
19978
|
+
billingSubscription?.cancelAt && /* @__PURE__ */ jsx35(Text, { as: "p", $size: 0.8125 * theme.typography.text.fontSize, children: t2("Access to plan will end on", {
|
|
19979
|
+
date: toPrettyDate(
|
|
19980
|
+
new Date(billingSubscription.cancelAt * 1e3),
|
|
19981
|
+
{
|
|
19982
|
+
month: "numeric"
|
|
19983
|
+
}
|
|
19984
|
+
)
|
|
19985
|
+
}) })
|
|
19993
19986
|
]
|
|
19994
19987
|
}
|
|
19995
19988
|
),
|
|
@@ -20011,57 +20004,18 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
|
|
|
20011
20004
|
$gap: "1rem",
|
|
20012
20005
|
children: [
|
|
20013
20006
|
/* @__PURE__ */ jsxs27(Flex, { $flexDirection: "column", $gap: "1rem", children: [
|
|
20014
|
-
/* @__PURE__ */ jsx35(
|
|
20015
|
-
|
|
20016
|
-
{
|
|
20017
|
-
as: Box,
|
|
20018
|
-
$font: theme.typography[props.header.title.fontStyle].fontFamily,
|
|
20019
|
-
$size: theme.typography[props.header.title.fontStyle].fontSize,
|
|
20020
|
-
$weight: theme.typography[props.header.title.fontStyle].fontWeight,
|
|
20021
|
-
$color: theme.typography[props.header.title.fontStyle].color,
|
|
20022
|
-
$leading: 1,
|
|
20023
|
-
children: currentPlan.name
|
|
20024
|
-
}
|
|
20025
|
-
),
|
|
20026
|
-
props.header.description.isVisible && currentPlan.description && /* @__PURE__ */ jsx35(
|
|
20027
|
-
Text,
|
|
20028
|
-
{
|
|
20029
|
-
as: Box,
|
|
20030
|
-
$font: theme.typography[props.header.description.fontStyle].fontFamily,
|
|
20031
|
-
$size: theme.typography[props.header.description.fontStyle].fontSize,
|
|
20032
|
-
$weight: theme.typography[props.header.description.fontStyle].fontWeight,
|
|
20033
|
-
$color: theme.typography[props.header.description.fontStyle].color,
|
|
20034
|
-
children: currentPlan.description
|
|
20035
|
-
}
|
|
20036
|
-
)
|
|
20007
|
+
/* @__PURE__ */ jsx35(Text, { display: props.header.title.fontStyle, $leading: 1, children: currentPlan.name }),
|
|
20008
|
+
props.header.description.isVisible && currentPlan.description && /* @__PURE__ */ jsx35(Text, { display: props.header.description.fontStyle, children: currentPlan.description })
|
|
20037
20009
|
] }),
|
|
20038
20010
|
props.header.price.isVisible && typeof currentPlan.planPrice === "number" && currentPlan.planPeriod && /* @__PURE__ */ jsxs27(Box, { children: [
|
|
20039
|
-
/* @__PURE__ */ jsx35(
|
|
20040
|
-
|
|
20041
|
-
|
|
20042
|
-
|
|
20043
|
-
|
|
20044
|
-
|
|
20045
|
-
|
|
20046
|
-
|
|
20047
|
-
currentPlan.planPrice,
|
|
20048
|
-
subscriptionCurrency
|
|
20049
|
-
)
|
|
20050
|
-
}
|
|
20051
|
-
),
|
|
20052
|
-
!isUsageBasedPlan && /* @__PURE__ */ jsx35(
|
|
20053
|
-
Text,
|
|
20054
|
-
{
|
|
20055
|
-
$font: theme.typography[props.header.price.fontStyle].fontFamily,
|
|
20056
|
-
$size: theme.typography[props.header.price.fontStyle].fontSize,
|
|
20057
|
-
$weight: theme.typography[props.header.price.fontStyle].fontWeight,
|
|
20058
|
-
$color: theme.typography[props.header.price.fontStyle].color,
|
|
20059
|
-
children: /* @__PURE__ */ jsxs27("sub", { children: [
|
|
20060
|
-
"/",
|
|
20061
|
-
shortenPeriod(currentPlan.planPeriod)
|
|
20062
|
-
] })
|
|
20063
|
-
}
|
|
20064
|
-
)
|
|
20011
|
+
/* @__PURE__ */ jsx35(Text, { display: headerPriceFontStyle, children: isUsageBasedPlan ? t2("Usage-based") : formatCurrency(
|
|
20012
|
+
currentPlan.planPrice,
|
|
20013
|
+
subscriptionCurrency
|
|
20014
|
+
) }),
|
|
20015
|
+
!isUsageBasedPlan && /* @__PURE__ */ jsx35(Text, { display: props.header.price.fontStyle, children: /* @__PURE__ */ jsxs27("sub", { children: [
|
|
20016
|
+
"/",
|
|
20017
|
+
shortenPeriod(currentPlan.planPeriod)
|
|
20018
|
+
] }) })
|
|
20065
20019
|
] })
|
|
20066
20020
|
]
|
|
20067
20021
|
}
|
|
@@ -20070,9 +20024,6 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
|
|
|
20070
20024
|
props.addOns.showLabel && /* @__PURE__ */ jsx35(
|
|
20071
20025
|
Text,
|
|
20072
20026
|
{
|
|
20073
|
-
$font: theme.typography.text.fontFamily,
|
|
20074
|
-
$size: theme.typography.text.fontSize,
|
|
20075
|
-
$weight: theme.typography.text.fontWeight,
|
|
20076
20027
|
$color: isLightBackground ? darken(theme.card.background, 0.46) : lighten(theme.card.background, 0.46),
|
|
20077
20028
|
$leading: 1,
|
|
20078
20029
|
children: t2("Add-ons")
|
|
@@ -20086,32 +20037,14 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
|
|
|
20086
20037
|
$flexWrap: "wrap",
|
|
20087
20038
|
$gap: "1rem",
|
|
20088
20039
|
children: [
|
|
20089
|
-
/* @__PURE__ */ jsx35(
|
|
20090
|
-
|
|
20091
|
-
|
|
20092
|
-
|
|
20093
|
-
|
|
20094
|
-
|
|
20095
|
-
|
|
20096
|
-
|
|
20097
|
-
}
|
|
20098
|
-
),
|
|
20099
|
-
addOn.planPrice && addOn.planPeriod && /* @__PURE__ */ jsxs27(
|
|
20100
|
-
Text,
|
|
20101
|
-
{
|
|
20102
|
-
$font: theme.typography.text.fontFamily,
|
|
20103
|
-
$size: theme.typography.text.fontSize,
|
|
20104
|
-
$weight: theme.typography.text.fontWeight,
|
|
20105
|
-
$color: theme.typography.text.color,
|
|
20106
|
-
children: [
|
|
20107
|
-
formatCurrency(addOn.planPrice, subscriptionCurrency),
|
|
20108
|
-
/* @__PURE__ */ jsxs27("sub", { children: [
|
|
20109
|
-
"/",
|
|
20110
|
-
shortenPeriod(addOn.planPeriod)
|
|
20111
|
-
] })
|
|
20112
|
-
]
|
|
20113
|
-
}
|
|
20114
|
-
)
|
|
20040
|
+
/* @__PURE__ */ jsx35(Text, { display: props.addOns.fontStyle, children: addOn.name }),
|
|
20041
|
+
addOn.planPrice && addOn.planPeriod && /* @__PURE__ */ jsxs27(Text, { children: [
|
|
20042
|
+
formatCurrency(addOn.planPrice, subscriptionCurrency),
|
|
20043
|
+
/* @__PURE__ */ jsxs27("sub", { children: [
|
|
20044
|
+
"/",
|
|
20045
|
+
shortenPeriod(addOn.planPeriod)
|
|
20046
|
+
] })
|
|
20047
|
+
] })
|
|
20115
20048
|
]
|
|
20116
20049
|
},
|
|
20117
20050
|
addOnIndex
|
|
@@ -20121,9 +20054,6 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
|
|
|
20121
20054
|
/* @__PURE__ */ jsx35(
|
|
20122
20055
|
Text,
|
|
20123
20056
|
{
|
|
20124
|
-
$font: theme.typography.text.fontFamily,
|
|
20125
|
-
$size: theme.typography.text.fontSize,
|
|
20126
|
-
$weight: theme.typography.text.fontWeight,
|
|
20127
20057
|
$color: isLightBackground ? darken(theme.card.background, 0.46) : lighten(theme.card.background, 0.46),
|
|
20128
20058
|
$leading: 1,
|
|
20129
20059
|
children: t2("Usage-based")
|
|
@@ -20132,8 +20062,24 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
|
|
|
20132
20062
|
usageBasedEntitlements.reduce(
|
|
20133
20063
|
(acc, entitlement, entitlementIndex) => {
|
|
20134
20064
|
const limit = entitlement.softLimit ?? entitlement.allocation ?? 0;
|
|
20135
|
-
|
|
20065
|
+
let overageAmount = entitlement.priceBehavior === "overage" && (entitlement?.usage ?? 0) - (entitlement?.softLimit ?? 0);
|
|
20136
20066
|
const amount = overageAmount || entitlement.allocation || 0;
|
|
20067
|
+
if (entitlement.priceBehavior === "overage" && data.subscription) {
|
|
20068
|
+
const subscription = data.subscription;
|
|
20069
|
+
const entitlementPrice = entitlement.monthlyUsageBasedPrice ?? entitlement.yearlyUsageBasedPrice;
|
|
20070
|
+
if (entitlementPrice) {
|
|
20071
|
+
const entitlementProduct = subscription.products.find(
|
|
20072
|
+
(product) => product.id === entitlementPrice.productId
|
|
20073
|
+
);
|
|
20074
|
+
if (entitlementProduct?.priceTier.length) {
|
|
20075
|
+
const entitlementProductLastTierPrice = entitlementProduct?.priceTier[entitlementProduct?.priceTier?.length - 1];
|
|
20076
|
+
overageAmount = (entitlement?.usage ?? 0) - (entitlementProduct?.priceTier[0].upTo ?? 0);
|
|
20077
|
+
entitlement.price = entitlementProductLastTierPrice?.perUnitPriceDecimal ? Number(
|
|
20078
|
+
entitlementProductLastTierPrice?.perUnitPriceDecimal
|
|
20079
|
+
) : entitlementProductLastTierPrice.perUnitPrice ?? entitlement.price;
|
|
20080
|
+
}
|
|
20081
|
+
}
|
|
20082
|
+
}
|
|
20137
20083
|
if (entitlement.feature?.name) {
|
|
20138
20084
|
acc.push(
|
|
20139
20085
|
/* @__PURE__ */ jsxs27(
|
|
@@ -20144,38 +20090,27 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
|
|
|
20144
20090
|
$flexWrap: "wrap",
|
|
20145
20091
|
$gap: "1rem",
|
|
20146
20092
|
children: [
|
|
20147
|
-
/* @__PURE__ */ jsxs27(
|
|
20148
|
-
|
|
20149
|
-
|
|
20150
|
-
|
|
20151
|
-
|
|
20152
|
-
|
|
20153
|
-
|
|
20154
|
-
|
|
20155
|
-
|
|
20156
|
-
|
|
20157
|
-
|
|
20158
|
-
getFeatureName(entitlement.feature, limit)
|
|
20159
|
-
] }) : entitlement.feature.name,
|
|
20160
|
-
entitlement.priceBehavior === "overage" && entitlement.feature.featureType === "event" && currentPlan?.planPeriod && /* @__PURE__ */ jsxs27(Fragment11, { children: [
|
|
20161
|
-
"/",
|
|
20162
|
-
shortenPeriod(currentPlan.planPeriod)
|
|
20163
|
-
] })
|
|
20164
|
-
]
|
|
20165
|
-
}
|
|
20166
|
-
),
|
|
20093
|
+
/* @__PURE__ */ jsxs27(Text, { display: props.addOns.fontStyle, children: [
|
|
20094
|
+
entitlement.priceBehavior === "pay_in_advance" || entitlement.priceBehavior === "overage" && limit > 0 ? /* @__PURE__ */ jsxs27(Fragment11, { children: [
|
|
20095
|
+
limit,
|
|
20096
|
+
" ",
|
|
20097
|
+
getFeatureName(entitlement.feature, limit)
|
|
20098
|
+
] }) : entitlement.feature.name,
|
|
20099
|
+
entitlement.priceBehavior === "overage" && entitlement.feature.featureType === "event" && currentPlan?.planPeriod && /* @__PURE__ */ jsxs27(Fragment11, { children: [
|
|
20100
|
+
"/",
|
|
20101
|
+
shortenPeriod(currentPlan.planPeriod)
|
|
20102
|
+
] })
|
|
20103
|
+
] }),
|
|
20167
20104
|
/* @__PURE__ */ jsxs27(Flex, { $alignItems: "center", $gap: "1rem", children: [
|
|
20168
20105
|
entitlement.priceBehavior === "overage" && currentPlan?.planPeriod ? /* @__PURE__ */ jsx35(
|
|
20169
20106
|
Text,
|
|
20170
20107
|
{
|
|
20171
|
-
$font: theme.typography.text.fontFamily,
|
|
20172
20108
|
$size: 0.875 * theme.typography.text.fontSize,
|
|
20173
|
-
$weight: theme.typography.text.fontWeight,
|
|
20174
20109
|
$color: hexToHSL(theme.typography.text.color).l > 50 ? darken(theme.typography.text.color, 0.46) : lighten(theme.typography.text.color, 0.46),
|
|
20175
20110
|
children: typeof overageAmount === "number" && overageAmount > 0 ? t2("X over the limit", {
|
|
20176
20111
|
amount: overageAmount
|
|
20177
20112
|
}) : /* @__PURE__ */ jsxs27(Fragment11, { children: [
|
|
20178
|
-
t2("
|
|
20113
|
+
t2("overage fee"),
|
|
20179
20114
|
":",
|
|
20180
20115
|
" ",
|
|
20181
20116
|
formatCurrency(
|
|
@@ -20195,9 +20130,7 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
|
|
|
20195
20130
|
) : entitlement.priceBehavior === "pay_in_advance" && currentPlan?.planPeriod && /* @__PURE__ */ jsxs27(
|
|
20196
20131
|
Text,
|
|
20197
20132
|
{
|
|
20198
|
-
$font: theme.typography.text.fontFamily,
|
|
20199
20133
|
$size: 0.875 * theme.typography.text.fontSize,
|
|
20200
|
-
$weight: theme.typography.text.fontWeight,
|
|
20201
20134
|
$color: hexToHSL(theme.typography.text.color).l > 50 ? darken(theme.typography.text.color, 0.46) : lighten(theme.typography.text.color, 0.46),
|
|
20202
20135
|
children: [
|
|
20203
20136
|
formatCurrency(
|
|
@@ -20213,25 +20146,16 @@ var PlanManager = forwardRef12(({ children, className, portal, ...rest }, ref) =
|
|
|
20213
20146
|
]
|
|
20214
20147
|
}
|
|
20215
20148
|
),
|
|
20216
|
-
amount > 0 && /* @__PURE__ */ jsxs27(
|
|
20217
|
-
|
|
20218
|
-
|
|
20219
|
-
|
|
20220
|
-
|
|
20221
|
-
|
|
20222
|
-
|
|
20223
|
-
|
|
20224
|
-
|
|
20225
|
-
|
|
20226
|
-
entitlement.currency
|
|
20227
|
-
),
|
|
20228
|
-
(entitlement.priceBehavior === "pay_in_advance" || entitlement.priceBehavior !== "overage") && /* @__PURE__ */ jsxs27("sub", { children: [
|
|
20229
|
-
"/",
|
|
20230
|
-
currentPlan?.planPeriod && entitlement.priceBehavior === "pay_in_advance" ? shortenPeriod(currentPlan.planPeriod) : getFeatureName(entitlement.feature, 1)
|
|
20231
|
-
] })
|
|
20232
|
-
]
|
|
20233
|
-
}
|
|
20234
|
-
)
|
|
20149
|
+
amount > 0 && /* @__PURE__ */ jsxs27(Text, { children: [
|
|
20150
|
+
formatCurrency(
|
|
20151
|
+
(entitlement.price ?? 0) * amount,
|
|
20152
|
+
entitlement.currency
|
|
20153
|
+
),
|
|
20154
|
+
(entitlement.priceBehavior === "pay_in_advance" || entitlement.priceBehavior !== "overage") && /* @__PURE__ */ jsxs27("sub", { children: [
|
|
20155
|
+
"/",
|
|
20156
|
+
currentPlan?.planPeriod && entitlement.priceBehavior === "pay_in_advance" ? shortenPeriod(currentPlan.planPeriod) : getFeatureName(entitlement.feature, 1)
|
|
20157
|
+
] })
|
|
20158
|
+
] })
|
|
20235
20159
|
] })
|
|
20236
20160
|
]
|
|
20237
20161
|
},
|
|
@@ -20530,12 +20454,25 @@ var PricingTable = forwardRef13(({ children, className, ...rest }, ref) => {
|
|
|
20530
20454
|
plan.entitlements.reduce(
|
|
20531
20455
|
(acc, entitlement, entitlementIndex) => {
|
|
20532
20456
|
const limit = entitlement.softLimit ?? entitlement.valueNumeric;
|
|
20533
|
-
|
|
20534
|
-
|
|
20535
|
-
|
|
20536
|
-
}
|
|
20537
|
-
|
|
20538
|
-
|
|
20457
|
+
let entitlementPriceObject;
|
|
20458
|
+
if (selectedPeriod === "month") {
|
|
20459
|
+
entitlementPriceObject = entitlement.meteredMonthlyPrice;
|
|
20460
|
+
} else if (selectedPeriod === "year") {
|
|
20461
|
+
entitlementPriceObject = entitlement.meteredYearlyPrice;
|
|
20462
|
+
}
|
|
20463
|
+
let entitlementPrice;
|
|
20464
|
+
let entitlementCurrency;
|
|
20465
|
+
if (entitlementPriceObject) {
|
|
20466
|
+
entitlementPrice = entitlementPriceObject?.price;
|
|
20467
|
+
entitlementCurrency = entitlementPriceObject?.currency;
|
|
20468
|
+
}
|
|
20469
|
+
if (entitlementPriceObject && entitlement.priceBehavior === "overage") {
|
|
20470
|
+
if (entitlementPriceObject.priceTier?.length > 1) {
|
|
20471
|
+
const overagePrice = entitlementPriceObject.priceTier[entitlementPriceObject.priceTier.length - 1];
|
|
20472
|
+
entitlementPrice = overagePrice.perUnitPrice ?? Number(overagePrice.perUnitPriceDecimal);
|
|
20473
|
+
entitlementCurrency = entitlementPriceObject.currency;
|
|
20474
|
+
}
|
|
20475
|
+
}
|
|
20539
20476
|
if (entitlement.priceBehavior && typeof entitlementPrice !== "number") {
|
|
20540
20477
|
return acc;
|
|
20541
20478
|
}
|
|
@@ -21256,7 +21193,7 @@ var UpcomingBill = forwardRef16(({ className, ...rest }, ref) => {
|
|
|
21256
21193
|
UpcomingBill.displayName = "UpcomingBill";
|
|
21257
21194
|
|
|
21258
21195
|
// src/components/embed/ComponentTree.tsx
|
|
21259
|
-
import { useEffect as
|
|
21196
|
+
import { useEffect as useEffect7, useState as useState16 } from "react";
|
|
21260
21197
|
|
|
21261
21198
|
// src/components/embed/renderer.ts
|
|
21262
21199
|
import { createElement as createElement5 } from "react";
|
|
@@ -21363,7 +21300,7 @@ var Error2 = ({ message }) => {
|
|
|
21363
21300
|
var ComponentTree = () => {
|
|
21364
21301
|
const { error, nodes, isPending } = useEmbed();
|
|
21365
21302
|
const [children, setChildren] = useState16(/* @__PURE__ */ jsx40(Loading, {}));
|
|
21366
|
-
|
|
21303
|
+
useEffect7(() => {
|
|
21367
21304
|
const renderer = createRenderer();
|
|
21368
21305
|
setChildren(nodes.map(renderer));
|
|
21369
21306
|
}, [nodes]);
|