@schematichq/schematic-components 2.32.0 → 2.34.0
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-elements.cjs.js +2490 -409
- package/dist/schematic-components-elements.d.ts +605 -11
- package/dist/schematic-components-elements.esm.js +2466 -370
- package/dist/schematic-components.browser.cjs.js +859 -215
- package/dist/schematic-components.browser.esm.js +859 -215
- package/dist/schematic-components.cjs.js +859 -215
- package/dist/schematic-components.d.ts +127 -0
- package/dist/schematic-components.esm.js +859 -215
- package/package.json +10 -10
|
@@ -53,6 +53,9 @@ var init_tokens = __esm({
|
|
|
53
53
|
"--schematic-font-heading": '"Manrope", system-ui, sans-serif',
|
|
54
54
|
// Link buttons' face: Edit, Set default, Try again, and the rest.
|
|
55
55
|
"--schematic-font-link": '"Inter", system-ui, sans-serif',
|
|
56
|
+
// A lighter tint than the surface, for panels set into a card: a credit's
|
|
57
|
+
// grants, a plan's auto top-up.
|
|
58
|
+
"--schematic-inset": ld("hsla(0, 0%, 0%, 0.04)", "hsla(0, 0%, 100%, 0.06)"),
|
|
56
59
|
"--schematic-line-height": "1.375",
|
|
57
60
|
"--schematic-line-height-heading": "1.2",
|
|
58
61
|
"--schematic-meter-track": ld("#f2f4f7", "#26282d"),
|
|
@@ -87,8 +90,8 @@ __export(PaymentMethodForm_exports, {
|
|
|
87
90
|
resolveAppearance: () => resolveAppearance
|
|
88
91
|
});
|
|
89
92
|
import { useSetupIntent } from "@schematichq/schematic-react";
|
|
90
|
-
import { useEffect as useEffect2, useId as useId3, useRef as useRef2, useState as
|
|
91
|
-
import { jsx as
|
|
93
|
+
import { useEffect as useEffect2, useId as useId3, useRef as useRef2, useState as useState5 } from "react";
|
|
94
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
92
95
|
function orUndefined(value) {
|
|
93
96
|
return value === void 0 || value === "" ? void 0 : value;
|
|
94
97
|
}
|
|
@@ -141,7 +144,7 @@ function PaymentMethodForm({
|
|
|
141
144
|
t
|
|
142
145
|
}) {
|
|
143
146
|
const { create } = useSetupIntent();
|
|
144
|
-
const [state, setState] =
|
|
147
|
+
const [state, setState] = useState5({ status: "loading" });
|
|
145
148
|
const hostRef = useRef2(null);
|
|
146
149
|
useEffect2(() => {
|
|
147
150
|
let cancelled = false;
|
|
@@ -189,7 +192,7 @@ function PaymentMethodForm({
|
|
|
189
192
|
};
|
|
190
193
|
}, [create, locale]);
|
|
191
194
|
if (state.status === "loading") {
|
|
192
|
-
return /* @__PURE__ */
|
|
195
|
+
return /* @__PURE__ */ jsxs7(
|
|
193
196
|
"div",
|
|
194
197
|
{
|
|
195
198
|
"aria-busy": "true",
|
|
@@ -197,15 +200,15 @@ function PaymentMethodForm({
|
|
|
197
200
|
"data-state": "pending",
|
|
198
201
|
ref: hostRef,
|
|
199
202
|
children: [
|
|
200
|
-
/* @__PURE__ */
|
|
201
|
-
/* @__PURE__ */
|
|
203
|
+
/* @__PURE__ */ jsx8("span", { className: "schematic-hidden", children: t("paymentMethodsFormLoading") }),
|
|
204
|
+
/* @__PURE__ */ jsx8("div", { className: "schematic-skeleton", children: /* @__PURE__ */ jsx8("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ jsx8("div", { className: "schematic-skeleton__cell", "data-column": "field" }) }) })
|
|
202
205
|
]
|
|
203
206
|
}
|
|
204
207
|
);
|
|
205
208
|
}
|
|
206
209
|
if (state.status === "failed") {
|
|
207
|
-
return /* @__PURE__ */
|
|
208
|
-
/* @__PURE__ */
|
|
210
|
+
return /* @__PURE__ */ jsxs7("div", { className: "schematic-payment-methods__form", "data-state": "error", children: [
|
|
211
|
+
/* @__PURE__ */ jsx8(
|
|
209
212
|
"p",
|
|
210
213
|
{
|
|
211
214
|
className: "schematic-error schematic-small schematic-payment-methods__form-error",
|
|
@@ -213,11 +216,11 @@ function PaymentMethodForm({
|
|
|
213
216
|
children: t(state.errorKey)
|
|
214
217
|
}
|
|
215
218
|
),
|
|
216
|
-
onSelectExisting !== void 0 && /* @__PURE__ */
|
|
219
|
+
onSelectExisting !== void 0 && /* @__PURE__ */ jsx8(SelectExisting, { t, onSelectExisting })
|
|
217
220
|
] });
|
|
218
221
|
}
|
|
219
222
|
const { Elements } = state.ui;
|
|
220
|
-
return /* @__PURE__ */
|
|
223
|
+
return /* @__PURE__ */ jsx8(
|
|
221
224
|
Elements,
|
|
222
225
|
{
|
|
223
226
|
stripe: state.stripe,
|
|
@@ -225,7 +228,7 @@ function PaymentMethodForm({
|
|
|
225
228
|
appearance: state.appearance,
|
|
226
229
|
clientSecret: state.clientSecret
|
|
227
230
|
},
|
|
228
|
-
children: /* @__PURE__ */
|
|
231
|
+
children: /* @__PURE__ */ jsx8(
|
|
229
232
|
Fields,
|
|
230
233
|
{
|
|
231
234
|
checkoutPrefill,
|
|
@@ -257,13 +260,13 @@ function Fields({
|
|
|
257
260
|
const emailId = useId3();
|
|
258
261
|
const stripe = useStripe();
|
|
259
262
|
const elements = useElements();
|
|
260
|
-
const [saving, setSaving] =
|
|
261
|
-
const [message, setMessage] =
|
|
262
|
-
const [complete, setComplete] =
|
|
263
|
-
const [ready, setReady] =
|
|
264
|
-
const [loadFailed, setLoadFailed] =
|
|
265
|
-
const [addressComplete, setAddressComplete] =
|
|
266
|
-
const [typedEmail, setTypedEmail] =
|
|
263
|
+
const [saving, setSaving] = useState5(false);
|
|
264
|
+
const [message, setMessage] = useState5(null);
|
|
265
|
+
const [complete, setComplete] = useState5(false);
|
|
266
|
+
const [ready, setReady] = useState5(false);
|
|
267
|
+
const [loadFailed, setLoadFailed] = useState5(false);
|
|
268
|
+
const [addressComplete, setAddressComplete] = useState5(!collectAddress);
|
|
269
|
+
const [typedEmail, setTypedEmail] = useState5(null);
|
|
267
270
|
const email = typedEmail ?? orUndefined(prefill?.email) ?? "";
|
|
268
271
|
const emailValid = !collectEmail || VALID_EMAIL.test(email);
|
|
269
272
|
useEffect2(() => {
|
|
@@ -318,14 +321,14 @@ function Fields({
|
|
|
318
321
|
setSaving(false);
|
|
319
322
|
}
|
|
320
323
|
};
|
|
321
|
-
return /* @__PURE__ */
|
|
324
|
+
return /* @__PURE__ */ jsxs7(
|
|
322
325
|
"form",
|
|
323
326
|
{
|
|
324
327
|
className: "schematic-payment-methods__form",
|
|
325
328
|
"data-state": "ready",
|
|
326
329
|
onSubmit: (event) => void submit(event),
|
|
327
330
|
children: [
|
|
328
|
-
/* @__PURE__ */
|
|
331
|
+
/* @__PURE__ */ jsx8("div", { className: "schematic-payment-methods__fields", children: /* @__PURE__ */ jsx8(
|
|
329
332
|
PaymentElement,
|
|
330
333
|
{
|
|
331
334
|
onChange: (event) => setComplete(event.complete),
|
|
@@ -336,8 +339,8 @@ function Fields({
|
|
|
336
339
|
}
|
|
337
340
|
}
|
|
338
341
|
) }),
|
|
339
|
-
collectEmail && /* @__PURE__ */
|
|
340
|
-
/* @__PURE__ */
|
|
342
|
+
collectEmail && /* @__PURE__ */ jsxs7("div", { className: "schematic-payment-methods__field", children: [
|
|
343
|
+
/* @__PURE__ */ jsx8(
|
|
341
344
|
"label",
|
|
342
345
|
{
|
|
343
346
|
className: "schematic-payment-methods__field-label",
|
|
@@ -345,7 +348,7 @@ function Fields({
|
|
|
345
348
|
children: t("paymentMethodsEmail")
|
|
346
349
|
}
|
|
347
350
|
),
|
|
348
|
-
/* @__PURE__ */
|
|
351
|
+
/* @__PURE__ */ jsx8(
|
|
349
352
|
"input",
|
|
350
353
|
{
|
|
351
354
|
autoComplete: "email",
|
|
@@ -359,7 +362,7 @@ function Fields({
|
|
|
359
362
|
}
|
|
360
363
|
)
|
|
361
364
|
] }),
|
|
362
|
-
showAddress && /* @__PURE__ */
|
|
365
|
+
showAddress && /* @__PURE__ */ jsx8("div", { className: "schematic-payment-methods__address", children: /* @__PURE__ */ jsx8(
|
|
363
366
|
AddressElement,
|
|
364
367
|
{
|
|
365
368
|
options: {
|
|
@@ -373,7 +376,7 @@ function Fields({
|
|
|
373
376
|
},
|
|
374
377
|
prefillName ?? ""
|
|
375
378
|
) }),
|
|
376
|
-
loadFailed && /* @__PURE__ */
|
|
379
|
+
loadFailed && /* @__PURE__ */ jsx8(
|
|
377
380
|
"p",
|
|
378
381
|
{
|
|
379
382
|
className: "schematic-error schematic-small schematic-payment-methods__form-error",
|
|
@@ -381,7 +384,7 @@ function Fields({
|
|
|
381
384
|
children: t("paymentMethodsFormError")
|
|
382
385
|
}
|
|
383
386
|
),
|
|
384
|
-
message !== null && /* @__PURE__ */
|
|
387
|
+
message !== null && /* @__PURE__ */ jsx8(
|
|
385
388
|
"p",
|
|
386
389
|
{
|
|
387
390
|
className: "schematic-error schematic-small schematic-payment-methods__form-error",
|
|
@@ -389,7 +392,7 @@ function Fields({
|
|
|
389
392
|
children: message
|
|
390
393
|
}
|
|
391
394
|
),
|
|
392
|
-
/* @__PURE__ */
|
|
395
|
+
/* @__PURE__ */ jsx8(
|
|
393
396
|
"button",
|
|
394
397
|
{
|
|
395
398
|
className: "schematic-cta schematic-payment-methods__save",
|
|
@@ -398,7 +401,7 @@ function Fields({
|
|
|
398
401
|
children: saving ? t("paymentMethodsSaving") : t("paymentMethodsSave")
|
|
399
402
|
}
|
|
400
403
|
),
|
|
401
|
-
onSelectExisting !== void 0 && /* @__PURE__ */
|
|
404
|
+
onSelectExisting !== void 0 && /* @__PURE__ */ jsx8(
|
|
402
405
|
SelectExisting,
|
|
403
406
|
{
|
|
404
407
|
disabled: saving,
|
|
@@ -415,7 +418,7 @@ function SelectExisting({
|
|
|
415
418
|
onSelectExisting,
|
|
416
419
|
t
|
|
417
420
|
}) {
|
|
418
|
-
return /* @__PURE__ */
|
|
421
|
+
return /* @__PURE__ */ jsx8(
|
|
419
422
|
"button",
|
|
420
423
|
{
|
|
421
424
|
className: "schematic-link-button schematic-payment-methods__select-existing",
|
|
@@ -456,7 +459,10 @@ import {
|
|
|
456
459
|
BillingDataProvider,
|
|
457
460
|
FEATURE_USER_USAGE_LIMIT,
|
|
458
461
|
SchematicI18nProvider,
|
|
459
|
-
|
|
462
|
+
useCompany as useCompany3,
|
|
463
|
+
useCreditBalances as useCreditBalances3,
|
|
464
|
+
useCreditUserUsage as useCreditUserUsage2,
|
|
465
|
+
useFeatureUsage as useFeatureUsage5,
|
|
460
466
|
useFeatureUserUsage as useFeatureUserUsage2,
|
|
461
467
|
useInvalidateBillingData,
|
|
462
468
|
useInvoices as useInvoices2,
|
|
@@ -466,6 +472,7 @@ import {
|
|
|
466
472
|
useSchematicStrings,
|
|
467
473
|
useSchematicTranslate,
|
|
468
474
|
useSetupIntent as useSetupIntent2,
|
|
475
|
+
useUnsubscribe as useUnsubscribe2,
|
|
469
476
|
useUpcomingInvoice as useUpcomingInvoice2
|
|
470
477
|
} from "@schematichq/schematic-react";
|
|
471
478
|
|
|
@@ -922,6 +929,9 @@ function formatCurrency(amountMinor, currency, locale, options = {}) {
|
|
|
922
929
|
function formatNumber(value, locale, options) {
|
|
923
930
|
return new Intl.NumberFormat(usableLocale(locale), options).format(value);
|
|
924
931
|
}
|
|
932
|
+
function formatCredits(value, locale) {
|
|
933
|
+
return formatNumber(value, locale, { maximumFractionDigits: 10 });
|
|
934
|
+
}
|
|
925
935
|
function formatConsumptionRate(rate, locale) {
|
|
926
936
|
return formatNumber(rate, locale, {
|
|
927
937
|
maximumFractionDigits: MAXIMUM_FRACTION_DIGITS
|
|
@@ -1318,7 +1328,10 @@ function includedFeatureRow(row, options) {
|
|
|
1318
1328
|
description: nonEmpty(row.featureDescription),
|
|
1319
1329
|
icon: nonEmpty(row.featureIcon),
|
|
1320
1330
|
perLicenseCredits: row.perLicenseCreditGrants.filter((grant) => grant.scaling === "per_license").map((grant) => ({
|
|
1321
|
-
|
|
1331
|
+
// Credits come in fractions as small as 1e-10.
|
|
1332
|
+
amount: formatNumber(grant.creditAmount, locale, {
|
|
1333
|
+
maximumFractionDigits: 10
|
|
1334
|
+
}),
|
|
1322
1335
|
creditName: featureName(
|
|
1323
1336
|
{
|
|
1324
1337
|
name: grant.creditName,
|
|
@@ -1338,7 +1351,7 @@ function includedFeatureRow(row, options) {
|
|
|
1338
1351
|
usage: usageSegments(row, locale, tiered, period),
|
|
1339
1352
|
usageSummary: usageSummary(row, options),
|
|
1340
1353
|
hardLimit: row.priceBehavior !== void 0 && row.priceBehavior !== null && row.priceBehavior !== "credit_burndown" && row.valueType === "numeric" && typeof row.allocation === "number" ? {
|
|
1341
|
-
amount: row.allocation,
|
|
1354
|
+
amount: formatNumber(row.allocation, locale),
|
|
1342
1355
|
units: featureName(feature, row.allocation, locale)
|
|
1343
1356
|
} : null,
|
|
1344
1357
|
tiers: (row.priceBehavior === "tier" || tiered) && row.price !== void 0 ? {
|
|
@@ -1383,7 +1396,7 @@ function entitlementText(row, options) {
|
|
|
1383
1396
|
return size > 1 ? {
|
|
1384
1397
|
kind: "perPackage",
|
|
1385
1398
|
cost,
|
|
1386
|
-
size,
|
|
1399
|
+
size: formatNumber(size, locale),
|
|
1387
1400
|
units: featureName(feature, size, locale)
|
|
1388
1401
|
} : { kind: "perUnit", cost, unit: featureName(feature, 1, locale) };
|
|
1389
1402
|
}
|
|
@@ -1444,14 +1457,14 @@ function usageSegments(row, locale, tiered, period) {
|
|
|
1444
1457
|
segments.push({
|
|
1445
1458
|
kind: "unitPricePerPeriod",
|
|
1446
1459
|
cost: formatCurrency(unitPrice(row.price), row.price.currency, locale),
|
|
1447
|
-
size,
|
|
1460
|
+
size: size > 1 ? formatNumber(size, locale) : null,
|
|
1448
1461
|
units: featureName(feature, size, locale),
|
|
1449
1462
|
period
|
|
1450
1463
|
});
|
|
1451
1464
|
} else if ((row.priceBehavior === "pay_as_you_go" || row.priceBehavior === "overage" || row.priceBehavior === "tier" || row.priceBehavior === "credit_burndown" || tiered) && typeof row.usage === "number") {
|
|
1452
1465
|
segments.push({
|
|
1453
1466
|
kind: "used",
|
|
1454
|
-
amount:
|
|
1467
|
+
amount: formatNumber(row.usage, locale),
|
|
1455
1468
|
units: featureName(feature, row.usage, locale)
|
|
1456
1469
|
});
|
|
1457
1470
|
}
|
|
@@ -1526,7 +1539,7 @@ function meteredFeatureRow(row, options) {
|
|
|
1526
1539
|
limit: limitLine(row, limit, unit, options),
|
|
1527
1540
|
resetsAt: resetsAt === void 0 ? null : formatDate(resetsAt, locale, { month: "short", year: void 0 }),
|
|
1528
1541
|
hardLimit: row.priceBehavior !== void 0 && row.priceBehavior !== null && row.priceBehavior !== "credit_burndown" && row.valueType === "numeric" && typeof row.allocation === "number" ? {
|
|
1529
|
-
amount: row.allocation,
|
|
1542
|
+
amount: formatNumber(row.allocation, locale),
|
|
1530
1543
|
units: featureName(unit, row.allocation, locale)
|
|
1531
1544
|
} : null,
|
|
1532
1545
|
meter: meter(row, options),
|
|
@@ -1648,7 +1661,7 @@ function priceDetails(row, unit, locale) {
|
|
|
1648
1661
|
return {
|
|
1649
1662
|
kind: "overage",
|
|
1650
1663
|
unitPrice: money(tier.perUnitPrice),
|
|
1651
|
-
packageSize: size,
|
|
1664
|
+
packageSize: size > 1 ? formatNumber(size, locale) : null,
|
|
1652
1665
|
units: featureName(unit, size, locale),
|
|
1653
1666
|
period,
|
|
1654
1667
|
overage: {
|
|
@@ -1664,8 +1677,8 @@ function priceDetails(row, unit, locale) {
|
|
|
1664
1677
|
}
|
|
1665
1678
|
return {
|
|
1666
1679
|
kind: "tier",
|
|
1667
|
-
from: tier.from === 0 ? 1 : tier.from,
|
|
1668
|
-
to: tier.to,
|
|
1680
|
+
from: formatNumber(tier.from === 0 ? 1 : tier.from, locale),
|
|
1681
|
+
to: tier.to === null ? null : formatNumber(tier.to, locale),
|
|
1669
1682
|
cost: typeof row.currentCost === "number" ? money(row.currentCost) : null,
|
|
1670
1683
|
period,
|
|
1671
1684
|
tiers: {
|
|
@@ -1678,6 +1691,508 @@ function priceDetails(row, unit, locale) {
|
|
|
1678
1691
|
return null;
|
|
1679
1692
|
}
|
|
1680
1693
|
|
|
1694
|
+
// src/elements/model/creditUsage.ts
|
|
1695
|
+
function deriveCreditUsage(balances, options) {
|
|
1696
|
+
const ordered = options.visibleCredits === void 0 ? balances : options.visibleCredits.flatMap((id) => {
|
|
1697
|
+
const balance = balances.find((b) => b.creditId === id);
|
|
1698
|
+
return balance === void 0 ? [] : [balance];
|
|
1699
|
+
});
|
|
1700
|
+
return ordered.map((balance) => creditUsageRow(balance, options.locale));
|
|
1701
|
+
}
|
|
1702
|
+
function creditUsageRow(balance, locale) {
|
|
1703
|
+
const unit = {
|
|
1704
|
+
name: balance.creditName,
|
|
1705
|
+
singularName: balance.creditSingularName ?? void 0,
|
|
1706
|
+
pluralName: balance.creditPluralName ?? void 0
|
|
1707
|
+
};
|
|
1708
|
+
const composition = balance.composition;
|
|
1709
|
+
return {
|
|
1710
|
+
creditId: balance.creditId,
|
|
1711
|
+
name: balance.creditName,
|
|
1712
|
+
description: balance.creditDescription === "" ? null : balance.creditDescription,
|
|
1713
|
+
icon: balance.creditIcon === void 0 || balance.creditIcon === null || balance.creditIcon === "" ? null : balance.creditIcon,
|
|
1714
|
+
remaining: {
|
|
1715
|
+
amount: formatCredits(balance.remaining, locale),
|
|
1716
|
+
units: featureName(unit, balance.remaining, locale)
|
|
1717
|
+
},
|
|
1718
|
+
purchasable: balance.purchasable,
|
|
1719
|
+
ledger: balance.grants.map((grant) => ledgerRow(grant, unit, locale)),
|
|
1720
|
+
composition: composition === void 0 || composition === null ? null : {
|
|
1721
|
+
total: formatCredits(composition.total, locale),
|
|
1722
|
+
creditName: featureName(unit, composition.total, locale),
|
|
1723
|
+
period: composition.period,
|
|
1724
|
+
perLicense: {
|
|
1725
|
+
quantity: formatNumber(composition.licenseQuantity, locale),
|
|
1726
|
+
licenseName: featureName(
|
|
1727
|
+
{
|
|
1728
|
+
name: composition.licenseName,
|
|
1729
|
+
singularName: composition.licenseSingularName,
|
|
1730
|
+
pluralName: composition.licensePluralName
|
|
1731
|
+
},
|
|
1732
|
+
composition.licenseQuantity,
|
|
1733
|
+
locale
|
|
1734
|
+
),
|
|
1735
|
+
perUnit: formatCredits(composition.perLicenseAmount, locale)
|
|
1736
|
+
},
|
|
1737
|
+
companyGrant: composition.fixedQuantity > 0 ? formatCredits(composition.fixedQuantity, locale) : null,
|
|
1738
|
+
renewsOn: renewsOn(composition.renewsAt, locale)
|
|
1739
|
+
},
|
|
1740
|
+
unit,
|
|
1741
|
+
source: balance
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
function ledgerRow(grant, unit, locale) {
|
|
1745
|
+
const kind = grant.grantReason === "plan" ? "plan" : grant.grantReason === "purchased" ? "bundle" : grant.grantReason === "billing_credit_auto_topup" ? "autoTopup" : "promotional";
|
|
1746
|
+
const short = (date) => formatDate(date, locale, { month: "short" });
|
|
1747
|
+
const resetsAt = usableDate(grant.resetsAt);
|
|
1748
|
+
const expiresAt = usableDate(grant.expiresAt);
|
|
1749
|
+
return {
|
|
1750
|
+
id: grant.id,
|
|
1751
|
+
kind,
|
|
1752
|
+
amount: formatCredits(grant.quantity, locale),
|
|
1753
|
+
item: featureName(unit, kind === "bundle" ? 1 : grant.quantity, locale),
|
|
1754
|
+
createdAt: short(grant.createdAt),
|
|
1755
|
+
date: resetsAt !== void 0 ? { kind: "resets", text: short(resetsAt) } : expiresAt !== void 0 ? { kind: "expires", text: short(expiresAt) } : null,
|
|
1756
|
+
source: grant
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
function renewsOn(date, locale) {
|
|
1760
|
+
const due = usableDate(date);
|
|
1761
|
+
if (due === void 0) {
|
|
1762
|
+
return null;
|
|
1763
|
+
}
|
|
1764
|
+
const day = due.getDate();
|
|
1765
|
+
if (!isEnglish2(locale)) {
|
|
1766
|
+
return formatNumber(day, locale);
|
|
1767
|
+
}
|
|
1768
|
+
const suffix = {
|
|
1769
|
+
few: "rd",
|
|
1770
|
+
many: "th",
|
|
1771
|
+
one: "st",
|
|
1772
|
+
other: "th",
|
|
1773
|
+
two: "nd",
|
|
1774
|
+
zero: "th"
|
|
1775
|
+
};
|
|
1776
|
+
return `${day}${suffix[new Intl.PluralRules("en", { type: "ordinal" }).select(day)]}`;
|
|
1777
|
+
}
|
|
1778
|
+
function isEnglish2(locale) {
|
|
1779
|
+
try {
|
|
1780
|
+
return new Intl.Locale(locale).language === "en";
|
|
1781
|
+
} catch {
|
|
1782
|
+
return false;
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
// src/elements/model/planManager.ts
|
|
1787
|
+
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
1788
|
+
var HOUR_MS = 60 * 60 * 1e3;
|
|
1789
|
+
var MINUTE_MS = 60 * 1e3;
|
|
1790
|
+
function derivePlanManager(data, options) {
|
|
1791
|
+
const { company, creditBalances, featureUsage } = data;
|
|
1792
|
+
const { locale } = options;
|
|
1793
|
+
const subscription = company.subscription ?? null;
|
|
1794
|
+
const currency = subscription?.currency ?? "usd";
|
|
1795
|
+
const planPeriod = subscription?.period ?? company.plan?.period ?? null;
|
|
1796
|
+
const usageBasedSources = featureUsage.filter(
|
|
1797
|
+
(row) => typeof row.priceBehavior === "string"
|
|
1798
|
+
);
|
|
1799
|
+
return {
|
|
1800
|
+
notice: notice(company, options),
|
|
1801
|
+
plan: company.plan === void 0 || company.plan === null ? null : {
|
|
1802
|
+
name: company.plan.name,
|
|
1803
|
+
description: orNull3(company.plan.description),
|
|
1804
|
+
price: planPrice(
|
|
1805
|
+
company.plan.price,
|
|
1806
|
+
planPeriod,
|
|
1807
|
+
currency,
|
|
1808
|
+
usageBasedSources.length > 0,
|
|
1809
|
+
options
|
|
1810
|
+
)
|
|
1811
|
+
},
|
|
1812
|
+
addOns: company.addOns.map((addOn) => {
|
|
1813
|
+
const period = addOn.period === "one-time" ? "one-time" : planPeriod ?? addOn.period ?? null;
|
|
1814
|
+
return {
|
|
1815
|
+
id: addOn.id,
|
|
1816
|
+
name: addOn.name,
|
|
1817
|
+
price: typeof addOn.price === "number" && period !== null ? {
|
|
1818
|
+
amount: formatCurrency(addOn.price, currency, locale),
|
|
1819
|
+
period
|
|
1820
|
+
} : null
|
|
1821
|
+
};
|
|
1822
|
+
}),
|
|
1823
|
+
usageBased: usageBasedSources.flatMap((row) => {
|
|
1824
|
+
const derived = usageBasedRow(row, planPeriod ?? "month", options);
|
|
1825
|
+
return derived === null ? [] : [derived];
|
|
1826
|
+
}),
|
|
1827
|
+
planCredits: planCredits(company, creditBalances, locale),
|
|
1828
|
+
autoTopup: autoTopupBox(company, creditBalances, locale),
|
|
1829
|
+
...creditGroups(creditBalances, locale),
|
|
1830
|
+
canChangePlan: company.customPlanBilling?.activationStrategy !== "on_payment"
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
function notice(company, options) {
|
|
1834
|
+
const { locale } = options;
|
|
1835
|
+
const subscription = company.subscription ?? null;
|
|
1836
|
+
const cancelAt = usableDate(subscription?.cancelAt);
|
|
1837
|
+
const willCancel = cancelAt !== void 0 && subscription?.cancelAtPeriodEnd === true;
|
|
1838
|
+
if (subscription?.status === "trialing" && !willCancel) {
|
|
1839
|
+
const trialEnd = usableDate(subscription.trialEnd);
|
|
1840
|
+
return {
|
|
1841
|
+
kind: "trial",
|
|
1842
|
+
endsIn: trialEnd === void 0 ? null : countdown(
|
|
1843
|
+
trialEnd.getTime() - (options.now ?? /* @__PURE__ */ new Date()).getTime()
|
|
1844
|
+
)
|
|
1845
|
+
};
|
|
1846
|
+
}
|
|
1847
|
+
if (willCancel) {
|
|
1848
|
+
return {
|
|
1849
|
+
kind: "canceled",
|
|
1850
|
+
planName: orNull3(company.plan?.name),
|
|
1851
|
+
date: formatDate(cancelAt, locale)
|
|
1852
|
+
};
|
|
1853
|
+
}
|
|
1854
|
+
const billing = company.customPlanBilling;
|
|
1855
|
+
if (billing !== void 0 && billing !== null) {
|
|
1856
|
+
return {
|
|
1857
|
+
kind: "customPlanBilling",
|
|
1858
|
+
awaitingActivation: billing.activationStrategy === "on_payment",
|
|
1859
|
+
planName: orNull3(billing.planName),
|
|
1860
|
+
date: formatDate(billing.dueAt, locale),
|
|
1861
|
+
invoiceUrl: orNull3(billing.invoiceUrl)
|
|
1862
|
+
};
|
|
1863
|
+
}
|
|
1864
|
+
const downgrade = company.scheduledDowngrade;
|
|
1865
|
+
if (downgrade !== void 0 && downgrade !== null && downgrade.toPlanName !== "") {
|
|
1866
|
+
const periodEnd = usableDate(subscription?.periodEnd);
|
|
1867
|
+
return {
|
|
1868
|
+
kind: "scheduledDowngrade",
|
|
1869
|
+
fromPlanName: downgrade.fromPlanName,
|
|
1870
|
+
toPlanName: downgrade.toPlanName,
|
|
1871
|
+
date: periodEnd === void 0 ? null : formatDate(periodEnd, locale)
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1874
|
+
return null;
|
|
1875
|
+
}
|
|
1876
|
+
function countdown(ms) {
|
|
1877
|
+
if (ms >= DAY_MS) {
|
|
1878
|
+
return { amount: Math.floor(ms / DAY_MS), unit: "day" };
|
|
1879
|
+
}
|
|
1880
|
+
if (ms >= HOUR_MS) {
|
|
1881
|
+
return { amount: Math.floor(ms / HOUR_MS), unit: "hour" };
|
|
1882
|
+
}
|
|
1883
|
+
if (ms >= MINUTE_MS) {
|
|
1884
|
+
return { amount: Math.floor(ms / MINUTE_MS), unit: "minute" };
|
|
1885
|
+
}
|
|
1886
|
+
return ms > 0 ? "soon" : "ended";
|
|
1887
|
+
}
|
|
1888
|
+
function planPrice(price, period, currency, hasUsageBased, options) {
|
|
1889
|
+
if (typeof price !== "number") {
|
|
1890
|
+
return null;
|
|
1891
|
+
}
|
|
1892
|
+
const isFree = price === 0;
|
|
1893
|
+
if (isFree && hasUsageBased) {
|
|
1894
|
+
return { kind: "usageBased" };
|
|
1895
|
+
}
|
|
1896
|
+
if (isFree && options.showZeroPriceAsFree === true) {
|
|
1897
|
+
return { kind: "free" };
|
|
1898
|
+
}
|
|
1899
|
+
return {
|
|
1900
|
+
kind: "amount",
|
|
1901
|
+
amount: formatCurrency(price, currency, options.locale),
|
|
1902
|
+
period: isFree ? null : period
|
|
1903
|
+
};
|
|
1904
|
+
}
|
|
1905
|
+
function usageBasedRow(row, period, options) {
|
|
1906
|
+
const { locale } = options;
|
|
1907
|
+
const behavior = row.priceBehavior ?? null;
|
|
1908
|
+
const showCredits = options.showCredits ?? true;
|
|
1909
|
+
if (behavior === "credit_burndown" && !showCredits || row.featureName === "") {
|
|
1910
|
+
return null;
|
|
1911
|
+
}
|
|
1912
|
+
const unit = {
|
|
1913
|
+
name: row.featureName,
|
|
1914
|
+
singularName: row.featureSingularName ?? void 0,
|
|
1915
|
+
pluralName: row.featurePluralName ?? void 0
|
|
1916
|
+
};
|
|
1917
|
+
const isTrait = row.featureType === "trait";
|
|
1918
|
+
const price = row.price ?? void 0;
|
|
1919
|
+
const priceCurrency = price?.currency ?? "usd";
|
|
1920
|
+
const limit = behavior === "credit_burndown" ? null : usageLimit(row, options);
|
|
1921
|
+
let unitPriceText = null;
|
|
1922
|
+
if ((behavior === "pay_as_you_go" || behavior === "overage") && price !== void 0) {
|
|
1923
|
+
const packageSize = price.packageSize ?? 1;
|
|
1924
|
+
const ranges = behavior === "overage" ? tierRanges(price) : [];
|
|
1925
|
+
const lastTier = ranges[ranges.length - 1];
|
|
1926
|
+
const amount = lastTier === void 0 ? unitPrice(price) : lastTier.perUnitPrice ?? price.price;
|
|
1927
|
+
unitPriceText = {
|
|
1928
|
+
cost: formatCurrency(amount, priceCurrency, locale),
|
|
1929
|
+
packageSize: packageSize > 1 ? formatNumber(packageSize, locale) : null,
|
|
1930
|
+
units: featureName(unit, packageSize, locale),
|
|
1931
|
+
period: isTrait ? period : null
|
|
1932
|
+
};
|
|
1933
|
+
}
|
|
1934
|
+
let perUse = null;
|
|
1935
|
+
if (behavior === "credit_burndown" && typeof row.consumptionRate === "number" && row.consumptionRate !== 0 && typeof row.creditName === "string") {
|
|
1936
|
+
perUse = {
|
|
1937
|
+
amount: formatConsumptionRate(row.consumptionRate, locale),
|
|
1938
|
+
units: featureName(
|
|
1939
|
+
{
|
|
1940
|
+
name: row.creditName,
|
|
1941
|
+
singularName: row.creditSingularName,
|
|
1942
|
+
pluralName: row.creditPluralName
|
|
1943
|
+
},
|
|
1944
|
+
row.consumptionRate,
|
|
1945
|
+
locale
|
|
1946
|
+
)
|
|
1947
|
+
};
|
|
1948
|
+
}
|
|
1949
|
+
return {
|
|
1950
|
+
featureId: row.featureId,
|
|
1951
|
+
name: row.featureName,
|
|
1952
|
+
// The bare name, inflected, as the embed counts a limit.
|
|
1953
|
+
quantity: limit === null ? null : {
|
|
1954
|
+
amount: formatNumber(limit, locale),
|
|
1955
|
+
units: featureName({ name: row.featureName }, limit, locale)
|
|
1956
|
+
},
|
|
1957
|
+
additional: behavior === "overage",
|
|
1958
|
+
tierBased: behavior === "tier",
|
|
1959
|
+
unitPrice: unitPriceText,
|
|
1960
|
+
perUse,
|
|
1961
|
+
cost: behavior === "pay_in_advance" ? {
|
|
1962
|
+
amount: formatCurrency(row.currentCost ?? 0, priceCurrency, locale),
|
|
1963
|
+
period: isTrait ? period : null
|
|
1964
|
+
} : null,
|
|
1965
|
+
tiers: behavior === "tier" && isTieredPrice(price) ? {
|
|
1966
|
+
currency: priceCurrency,
|
|
1967
|
+
mode: price?.tiersMode ?? null,
|
|
1968
|
+
period,
|
|
1969
|
+
ranges: tierRanges(price),
|
|
1970
|
+
unit: row.featureSingularName ?? row.featureName
|
|
1971
|
+
} : null,
|
|
1972
|
+
hardLimit: behavior !== null && behavior !== "credit_burndown" && row.valueType === "numeric" && typeof row.allocation === "number" ? {
|
|
1973
|
+
amount: formatNumber(row.allocation, locale),
|
|
1974
|
+
units: featureName(unit, row.allocation, locale)
|
|
1975
|
+
} : null,
|
|
1976
|
+
source: row
|
|
1977
|
+
};
|
|
1978
|
+
}
|
|
1979
|
+
function planCredits(company, balances, locale) {
|
|
1980
|
+
const order = company.plan?.includedCreditIds ?? [];
|
|
1981
|
+
const rank = (creditId) => {
|
|
1982
|
+
const index = order.indexOf(creditId);
|
|
1983
|
+
return index === -1 ? order.length : index;
|
|
1984
|
+
};
|
|
1985
|
+
const subscriptionPeriod = company.subscription?.period ?? null;
|
|
1986
|
+
return balances.flatMap((balance) => {
|
|
1987
|
+
const grants = balance.grants.filter(
|
|
1988
|
+
(grant) => grant.grantReason === "plan"
|
|
1989
|
+
);
|
|
1990
|
+
if (grants.length === 0) {
|
|
1991
|
+
return [];
|
|
1992
|
+
}
|
|
1993
|
+
const unit = creditUnit(balance);
|
|
1994
|
+
const value = sum(grants, (grant) => grant.quantity);
|
|
1995
|
+
const used = sum(grants, (grant) => grant.quantityUsed);
|
|
1996
|
+
const composition = balance.composition ?? null;
|
|
1997
|
+
const autoTopup = balance.autoTopup ?? null;
|
|
1998
|
+
const row = {
|
|
1999
|
+
creditId: balance.creditId,
|
|
2000
|
+
text: composition === null ? {
|
|
2001
|
+
kind: "total",
|
|
2002
|
+
amount: formatCredits(value, locale),
|
|
2003
|
+
creditName: featureName(unit, value, locale),
|
|
2004
|
+
period: subscriptionPeriod
|
|
2005
|
+
} : {
|
|
2006
|
+
kind: "perLicense",
|
|
2007
|
+
amount: formatCredits(composition.perLicenseAmount, locale),
|
|
2008
|
+
creditName: featureName(
|
|
2009
|
+
unit,
|
|
2010
|
+
composition.perLicenseAmount,
|
|
2011
|
+
locale
|
|
2012
|
+
),
|
|
2013
|
+
licenseName: featureName(licenseUnit(composition), 1, locale),
|
|
2014
|
+
plus: composition.fixedQuantity > 0 ? {
|
|
2015
|
+
amount: formatCredits(
|
|
2016
|
+
composition.fixedQuantity,
|
|
2017
|
+
locale
|
|
2018
|
+
),
|
|
2019
|
+
creditName: featureName(
|
|
2020
|
+
unit,
|
|
2021
|
+
composition.fixedQuantity,
|
|
2022
|
+
locale
|
|
2023
|
+
),
|
|
2024
|
+
period: composition.period
|
|
2025
|
+
} : null
|
|
2026
|
+
},
|
|
2027
|
+
used: spent(used, locale),
|
|
2028
|
+
autoTopup: autoTopup !== null && autoTopup.enabled && typeof autoTopup.thresholdCredits === "number" && typeof autoTopup.amount === "number" ? {
|
|
2029
|
+
amount: formatCredits(autoTopup.amount, locale),
|
|
2030
|
+
threshold: formatCredits(autoTopup.thresholdCredits, locale)
|
|
2031
|
+
} : null,
|
|
2032
|
+
composition: composition === null ? null : {
|
|
2033
|
+
quantity: formatNumber(composition.licenseQuantity, locale),
|
|
2034
|
+
licenseName: featureName(
|
|
2035
|
+
licenseUnit(composition),
|
|
2036
|
+
composition.licenseQuantity,
|
|
2037
|
+
locale
|
|
2038
|
+
),
|
|
2039
|
+
perUnit: formatCredits(composition.perLicenseAmount, locale),
|
|
2040
|
+
fixed: composition.fixedQuantity > 0 ? formatCredits(composition.fixedQuantity, locale) : null,
|
|
2041
|
+
total: formatCredits(composition.total, locale),
|
|
2042
|
+
creditName: featureName(unit, composition.total, locale),
|
|
2043
|
+
period: composition.period
|
|
2044
|
+
}
|
|
2045
|
+
};
|
|
2046
|
+
return [row];
|
|
2047
|
+
}).map((row, index) => ({ row, index })).sort(
|
|
2048
|
+
(a, b) => rank(a.row.creditId) - rank(b.row.creditId) || a.index - b.index
|
|
2049
|
+
).map(({ row }) => row);
|
|
2050
|
+
}
|
|
2051
|
+
function autoTopupBox(company, balances, locale) {
|
|
2052
|
+
const order = company.plan?.includedCreditIds ?? [];
|
|
2053
|
+
const selfService = order.flatMap((creditId) => {
|
|
2054
|
+
const balance = balances.find((b) => b.creditId === creditId);
|
|
2055
|
+
const autoTopup = balance?.autoTopup ?? null;
|
|
2056
|
+
return balance === void 0 || autoTopup === null || !autoTopup.selfService ? [] : [{ balance, autoTopup }];
|
|
2057
|
+
});
|
|
2058
|
+
if (selfService.length === 0) {
|
|
2059
|
+
return null;
|
|
2060
|
+
}
|
|
2061
|
+
return {
|
|
2062
|
+
lines: selfService.flatMap(({ balance, autoTopup }) => {
|
|
2063
|
+
const unit = creditUnit(balance);
|
|
2064
|
+
if (!autoTopup.enabled) {
|
|
2065
|
+
return [
|
|
2066
|
+
{
|
|
2067
|
+
kind: "disabled",
|
|
2068
|
+
creditId: balance.creditId,
|
|
2069
|
+
unit: featureName(unit, 1, locale)
|
|
2070
|
+
}
|
|
2071
|
+
];
|
|
2072
|
+
}
|
|
2073
|
+
if (typeof autoTopup.thresholdCredits !== "number" || typeof autoTopup.amount !== "number") {
|
|
2074
|
+
return [];
|
|
2075
|
+
}
|
|
2076
|
+
return [
|
|
2077
|
+
{
|
|
2078
|
+
kind: "adds",
|
|
2079
|
+
creditId: balance.creditId,
|
|
2080
|
+
amount: formatCredits(autoTopup.amount, locale),
|
|
2081
|
+
unit: featureName(unit, autoTopup.amount, locale),
|
|
2082
|
+
threshold: formatCredits(autoTopup.thresholdCredits, locale)
|
|
2083
|
+
}
|
|
2084
|
+
];
|
|
2085
|
+
})
|
|
2086
|
+
};
|
|
2087
|
+
}
|
|
2088
|
+
function creditGroups(balances, locale) {
|
|
2089
|
+
const groups = /* @__PURE__ */ new Map();
|
|
2090
|
+
for (const balance of balances) {
|
|
2091
|
+
for (const grant of balance.grants) {
|
|
2092
|
+
if (grant.grantReason === "plan") {
|
|
2093
|
+
continue;
|
|
2094
|
+
}
|
|
2095
|
+
const key = `${grant.grantReason}:${grant.bundleId ?? grant.id}`;
|
|
2096
|
+
const group = groups.get(key);
|
|
2097
|
+
if (group === void 0) {
|
|
2098
|
+
groups.set(key, { balance, grants: [grant] });
|
|
2099
|
+
} else {
|
|
2100
|
+
group.grants.push(grant);
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
const rows = Array.from(groups.entries()).map(([key, { balance, grants }]) => {
|
|
2105
|
+
const sorted = [...grants].sort(byRecency);
|
|
2106
|
+
const latest = sorted[0];
|
|
2107
|
+
return {
|
|
2108
|
+
reason: latest.grantReason,
|
|
2109
|
+
createdAt: latest.createdAt,
|
|
2110
|
+
row: {
|
|
2111
|
+
key,
|
|
2112
|
+
count: sorted.length,
|
|
2113
|
+
bundleName: orNull3(latest.bundleName),
|
|
2114
|
+
quantity: formatCredits(latest.quantity, locale),
|
|
2115
|
+
creditName: featureName(creditUnit(balance), latest.quantity, locale),
|
|
2116
|
+
used: spent(
|
|
2117
|
+
sum(sorted, (grant) => grant.quantityUsed),
|
|
2118
|
+
locale
|
|
2119
|
+
)
|
|
2120
|
+
}
|
|
2121
|
+
};
|
|
2122
|
+
}).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
2123
|
+
const pick = (reason) => rows.filter((entry) => entry.reason === reason).map((entry) => entry.row);
|
|
2124
|
+
return {
|
|
2125
|
+
bundles: pick("purchased"),
|
|
2126
|
+
promotional: pick("free"),
|
|
2127
|
+
topUps: pick("billing_credit_auto_topup")
|
|
2128
|
+
};
|
|
2129
|
+
}
|
|
2130
|
+
function byRecency(a, b) {
|
|
2131
|
+
return b.createdAt.getTime() - a.createdAt.getTime();
|
|
2132
|
+
}
|
|
2133
|
+
function creditUnit(balance) {
|
|
2134
|
+
return {
|
|
2135
|
+
name: balance.creditName,
|
|
2136
|
+
singularName: balance.creditSingularName ?? void 0,
|
|
2137
|
+
pluralName: balance.creditPluralName ?? void 0
|
|
2138
|
+
};
|
|
2139
|
+
}
|
|
2140
|
+
function licenseUnit(composition) {
|
|
2141
|
+
return {
|
|
2142
|
+
name: composition.licenseName,
|
|
2143
|
+
singularName: composition.licenseSingularName,
|
|
2144
|
+
pluralName: composition.licensePluralName
|
|
2145
|
+
};
|
|
2146
|
+
}
|
|
2147
|
+
function spent(used, locale) {
|
|
2148
|
+
return used > 0 ? formatCredits(used, locale) : null;
|
|
2149
|
+
}
|
|
2150
|
+
function sum(items, value) {
|
|
2151
|
+
return items.reduce((total, item) => total + value(item), 0);
|
|
2152
|
+
}
|
|
2153
|
+
function orNull3(value) {
|
|
2154
|
+
return value === void 0 || value === null || value === "" ? null : value;
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
// src/elements/model/unsubscribe.ts
|
|
2158
|
+
function deriveUnsubscribe(company, featureUsage, options) {
|
|
2159
|
+
const { locale } = options;
|
|
2160
|
+
const subscription = company.subscription ?? null;
|
|
2161
|
+
const currency = subscription?.currency ?? "usd";
|
|
2162
|
+
const cancelAt = usableDate(subscription?.cancelAt);
|
|
2163
|
+
const endsOn = cancelAt ?? usableDate(subscription?.nextBillAt) ?? options.now ?? /* @__PURE__ */ new Date();
|
|
2164
|
+
const money = (amount) => formatCurrency(amount, currency, locale);
|
|
2165
|
+
const addOns = company.addOns.flatMap(
|
|
2166
|
+
(addOn) => typeof addOn.price === "number" ? [
|
|
2167
|
+
{
|
|
2168
|
+
id: addOn.id,
|
|
2169
|
+
name: addOn.name,
|
|
2170
|
+
price: money(addOn.price),
|
|
2171
|
+
oneTime: addOn.period === "one-time"
|
|
2172
|
+
}
|
|
2173
|
+
] : []
|
|
2174
|
+
);
|
|
2175
|
+
const planPrice2 = company.plan?.price;
|
|
2176
|
+
const total = (typeof planPrice2 === "number" ? planPrice2 : 0) + company.addOns.reduce(
|
|
2177
|
+
(sum2, addOn) => addOn.period !== "one-time" && typeof addOn.price === "number" ? sum2 + addOn.price : sum2,
|
|
2178
|
+
0
|
|
2179
|
+
) + featureUsage.reduce(
|
|
2180
|
+
(sum2, row) => row.priceBehavior === "pay_in_advance" ? sum2 + (row.currentCost ?? 0) : sum2,
|
|
2181
|
+
0
|
|
2182
|
+
);
|
|
2183
|
+
return {
|
|
2184
|
+
canUnsubscribe: subscription !== null && cancelAt === void 0,
|
|
2185
|
+
accessEndsOn: formatDate(endsOn, locale),
|
|
2186
|
+
period: subscription?.period ?? company.plan?.period ?? "month",
|
|
2187
|
+
plan: company.plan === void 0 || company.plan === null ? null : {
|
|
2188
|
+
name: company.plan.name,
|
|
2189
|
+
price: typeof planPrice2 === "number" ? money(planPrice2) : null
|
|
2190
|
+
},
|
|
2191
|
+
addOns,
|
|
2192
|
+
total: money(total)
|
|
2193
|
+
};
|
|
2194
|
+
}
|
|
2195
|
+
|
|
1681
2196
|
// src/elements/strings.ts
|
|
1682
2197
|
var DEFAULT_STRINGS_LOCALE = "en";
|
|
1683
2198
|
var DEFAULT_STRINGS = {
|
|
@@ -1765,6 +2280,94 @@ var DEFAULT_STRINGS = {
|
|
|
1765
2280
|
meteredFeaturesAddMore: "Add More",
|
|
1766
2281
|
meteredFeaturesAdditional: "Additional",
|
|
1767
2282
|
meteredFeaturesTier: "Tier",
|
|
2283
|
+
creditUsageLoading: "Loading credits",
|
|
2284
|
+
creditUsageHeader: "Credits",
|
|
2285
|
+
creditUsageError: "There was a problem retrieving your credits.",
|
|
2286
|
+
creditUsageUnavailable: "Credits are not available for this account.",
|
|
2287
|
+
creditUsageRemaining: "{{amount}} {{units}} remaining",
|
|
2288
|
+
creditUsageBuyMore: "Buy More",
|
|
2289
|
+
creditUsageSeeDetails: "See balance details",
|
|
2290
|
+
creditUsageHideDetails: "Hide balance details",
|
|
2291
|
+
creditUsageSeeAll: "See all ({{total}})",
|
|
2292
|
+
creditUsageHideAll: "Hide all",
|
|
2293
|
+
creditUsageGrantPlan: "{{amount}} {{item}} included in plan",
|
|
2294
|
+
creditUsageGrantBundle: "{{amount}} {{item}} bundle purchased {{createdAt}}",
|
|
2295
|
+
creditUsageGrantAutoTopup: "{{amount}} {{item}} auto-topup purchased {{createdAt}}",
|
|
2296
|
+
creditUsageGrantPromotional: "{{amount}} promotional {{item}} granted {{createdAt}}",
|
|
2297
|
+
creditUsageResets: "Resets {{date}}",
|
|
2298
|
+
creditUsageExpires: "Expires {{date}}",
|
|
2299
|
+
creditUsageComposition: "Your plan includes {{total}} {{creditName}}/{{period}} \u2014 {{perLicense}}.",
|
|
2300
|
+
creditUsageCompositionWithGrant: "Your plan includes {{total}} {{creditName}}/{{period}} \u2014 {{perLicense}} + {{companyGrant}}.",
|
|
2301
|
+
creditUsagePerLicense: "{{quantity}} {{licenseName}} \xD7 {{perUnit}}",
|
|
2302
|
+
creditUsageCompanyGrant: "{{amount}} company grant",
|
|
2303
|
+
creditUsageRenewsOn: "Renews on the {{day}}.",
|
|
2304
|
+
planManagerLoading: "Loading your plan",
|
|
2305
|
+
planManagerError: "There was a problem retrieving your plan.",
|
|
2306
|
+
planManagerUnavailable: "Your plan is not available for this account.",
|
|
2307
|
+
planManagerTrialEndsIn: "Trial ends in {{amount}} {{units}}",
|
|
2308
|
+
planManagerTrialEndsSoon: "Trial ends in less than a minute",
|
|
2309
|
+
planManagerTrialEnded: "Your trial has ended",
|
|
2310
|
+
// The trial countdown's units, looked up by the bare key with `{ count }`.
|
|
2311
|
+
planManagerDays: "days",
|
|
2312
|
+
planManagerDays_one: "day",
|
|
2313
|
+
planManagerDays_other: "days",
|
|
2314
|
+
planManagerHours: "hours",
|
|
2315
|
+
planManagerHours_one: "hour",
|
|
2316
|
+
planManagerHours_other: "hours",
|
|
2317
|
+
planManagerMinutes: "minutes",
|
|
2318
|
+
planManagerMinutes_one: "minute",
|
|
2319
|
+
planManagerMinutes_other: "minutes",
|
|
2320
|
+
planManagerCanceled: "Subscription canceled",
|
|
2321
|
+
planManagerAccessEnds: "Access to {{plan}} will end on {{date}}.",
|
|
2322
|
+
planManagerPlanFallback: "plan",
|
|
2323
|
+
planManagerCustomAwaiting: "Pay to activate {{plan}}",
|
|
2324
|
+
planManagerCustomAwaitingDescription: "Pay the invoice to activate your custom plan. Due by {{date}}.",
|
|
2325
|
+
planManagerCustomDue: "Pay by {{date}} to keep {{plan}}",
|
|
2326
|
+
planManagerCustomDueDescription: "Access to {{plan}} will end on {{date}} unless the invoice is paid.",
|
|
2327
|
+
planManagerYourPlan: "your plan",
|
|
2328
|
+
planManagerPayNow: "Pay now",
|
|
2329
|
+
planManagerDowngradeScheduled: "Downgrade to {{plan}} scheduled",
|
|
2330
|
+
planManagerUsageBased: "Usage-based",
|
|
2331
|
+
planManagerFree: "Free",
|
|
2332
|
+
planManagerAddOns: "Add-ons",
|
|
2333
|
+
planManagerAdditional: "Additional",
|
|
2334
|
+
planManagerTierBased: "Tier-based",
|
|
2335
|
+
planManagerCreditsInPlan: "Credits in plan",
|
|
2336
|
+
planManagerCreditsError: "There was a problem retrieving your credits.",
|
|
2337
|
+
planManagerCreditsLoading: "Loading your credits",
|
|
2338
|
+
planManagerTopUps: "Top-ups",
|
|
2339
|
+
planManagerCreditBundles: "Credit bundles",
|
|
2340
|
+
planManagerPromotionalCredits: "Promotional credits",
|
|
2341
|
+
planManagerChangePlan: "Change plan",
|
|
2342
|
+
planManagerCredits: "{{amount}} {{creditName}}",
|
|
2343
|
+
planManagerCreditsPerPeriod: "{{amount}} {{creditName}} per {{period}}",
|
|
2344
|
+
planManagerCreditsPerLicense: "{{amount}} {{creditName}} per {{licenseName}}",
|
|
2345
|
+
planManagerCreditsPlusPerPeriod: "+ {{amount}} {{creditName}} per {{period}}",
|
|
2346
|
+
planManagerLicensesTimesCredits: "{{quantity}} {{licenseName}} \xD7 {{perUnit}} = {{total}} {{creditName}}/{{period}}",
|
|
2347
|
+
planManagerLicensesTimesCreditsPlusCompany: "{{quantity}} {{licenseName}} \xD7 {{perUnit}} + {{fixed}} = {{total}} {{creditName}}/{{period}}",
|
|
2348
|
+
planManagerUsed: "{{amount}} used",
|
|
2349
|
+
planManagerAutoTopup: "Auto top-up",
|
|
2350
|
+
planManagerAutoTopupDisabled: "Auto top-up disabled for {{unit}}",
|
|
2351
|
+
planManagerAutoTopupAdds: "Adds {{amount}} {{unit}} when {{threshold}} remaining in balance",
|
|
2352
|
+
planManagerAutoTopupTip: "When credit balance reaches {{threshold}} remaining, an auto top-up of {{amount}} credits will be processed.",
|
|
2353
|
+
planManagerEdit: "Edit",
|
|
2354
|
+
planManagerSeeAll: "See all ({{total}})",
|
|
2355
|
+
planManagerHideAll: "Hide all",
|
|
2356
|
+
unsubscribeButton: "Unsubscribe",
|
|
2357
|
+
unsubscribeTitle: "Cancel subscription",
|
|
2358
|
+
unsubscribeAccessUntil: "You will retain access to your plan until the end of the billing period, on {{date}}",
|
|
2359
|
+
unsubscribeNotReady: "Not ready to cancel?",
|
|
2360
|
+
unsubscribeManagePlan: "Manage plan",
|
|
2361
|
+
unsubscribePlan: "Plan",
|
|
2362
|
+
unsubscribeAddOns: "Add-ons",
|
|
2363
|
+
unsubscribeMonthlyTotal: "Monthly total:",
|
|
2364
|
+
unsubscribeQuarterlyTotal: "Quarterly total:",
|
|
2365
|
+
unsubscribeYearlyTotal: "Yearly total:",
|
|
2366
|
+
unsubscribeConfirm: "Cancel subscription",
|
|
2367
|
+
unsubscribeFailed: "Unsubscribe failed",
|
|
2368
|
+
unsubscribeClose: "Close",
|
|
2369
|
+
unsubscribeError: "There was a problem retrieving your subscription.",
|
|
2370
|
+
unsubscribeUnavailable: "Your subscription is not available for this account.",
|
|
1768
2371
|
usageByUserHeader: "Usage by user",
|
|
1769
2372
|
usageByUserTotal: "{{amount}} used by your team this period",
|
|
1770
2373
|
usageByUserError: "There was a problem retrieving usage by user.",
|
|
@@ -1800,7 +2403,12 @@ var DEFAULT_STRINGS = {
|
|
|
1800
2403
|
usageTiersGraduated: "Tiers apply progressively as quantity increases.",
|
|
1801
2404
|
periodMonthShort: "mo",
|
|
1802
2405
|
periodQuarterShort: "qtr",
|
|
1803
|
-
periodYearShort: "yr"
|
|
2406
|
+
periodYearShort: "yr",
|
|
2407
|
+
periodDay: "day",
|
|
2408
|
+
periodWeek: "week",
|
|
2409
|
+
periodMonth: "month",
|
|
2410
|
+
periodQuarter: "quarter",
|
|
2411
|
+
periodYear: "year"
|
|
1804
2412
|
};
|
|
1805
2413
|
var MISSING_STRING = "\0schematic:missing";
|
|
1806
2414
|
function interpolate(template, vars) {
|
|
@@ -1831,97 +2439,251 @@ function defaultString(key, vars) {
|
|
|
1831
2439
|
return lookup(DEFAULT_STRINGS, key, vars) ?? DEFAULT_STRINGS[key] ?? key;
|
|
1832
2440
|
}
|
|
1833
2441
|
|
|
1834
|
-
// src/elements/styles/
|
|
1835
|
-
var
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
border-radius: 0.5rem;
|
|
1841
|
-
box-shadow: var(--schematic-shadow);
|
|
1842
|
-
box-sizing: border-box;
|
|
1843
|
-
color: var(--schematic-text);
|
|
1844
|
-
margin: auto;
|
|
1845
|
-
max-height: calc(100vh - 2 * var(--schematic-space));
|
|
1846
|
-
max-width: none;
|
|
1847
|
-
/* No padding of its own: a click on the backdrop lands on the dialog
|
|
1848
|
-
itself, and one inside lands on the header or body. */
|
|
1849
|
-
padding: 0;
|
|
1850
|
-
/* Never wider than the screen, whatever it holds. */
|
|
1851
|
-
width: min(48rem, calc(100vw - 2 * var(--schematic-space)));
|
|
1852
|
-
}
|
|
1853
|
-
|
|
1854
|
-
/* Centred by vw on a phone: a host page wider than the screen widens the
|
|
1855
|
-
layout viewport, and auto margins would centre the dialog half off the
|
|
1856
|
-
screen. Desktop keeps auto margins, as vw counts the scrollbar there. */
|
|
1857
|
-
@media (max-width: 52rem) {
|
|
1858
|
-
.schematic-dialog {
|
|
1859
|
-
inset-inline: 0 auto;
|
|
1860
|
-
margin-inline: calc(
|
|
1861
|
-
(100vw - min(48rem, calc(100vw - 2 * var(--schematic-space)))) / 2
|
|
1862
|
-
)
|
|
1863
|
-
0;
|
|
1864
|
-
}
|
|
2442
|
+
// src/elements/styles/credit-usage.ts
|
|
2443
|
+
var creditUsageCss = `
|
|
2444
|
+
.schematic-credit-usage__credits {
|
|
2445
|
+
display: flex;
|
|
2446
|
+
flex-direction: column;
|
|
2447
|
+
gap: var(--schematic-space);
|
|
1865
2448
|
}
|
|
1866
2449
|
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
2450
|
+
/* Each credit draws its own card, so the root draws one only while pending
|
|
2451
|
+
or failed. */
|
|
2452
|
+
.schematic-credit-usage[data-state="pending"],
|
|
2453
|
+
.schematic-credit-usage[data-state="error"] {
|
|
2454
|
+
background: var(--schematic-background);
|
|
2455
|
+
border-radius: var(--schematic-radius);
|
|
2456
|
+
box-shadow: var(--schematic-shadow);
|
|
2457
|
+
padding: calc(var(--schematic-card-padding) * 0.75)
|
|
2458
|
+
var(--schematic-card-padding);
|
|
1871
2459
|
}
|
|
1872
2460
|
|
|
1873
|
-
|
|
1874
|
-
rest. */
|
|
1875
|
-
.schematic-dialog__header {
|
|
1876
|
-
align-items: center;
|
|
1877
|
-
border-bottom: 1px solid
|
|
1878
|
-
color-mix(in srgb, var(--schematic-text) 15%, transparent);
|
|
2461
|
+
.schematic-credit-usage__credit {
|
|
1879
2462
|
display: flex;
|
|
2463
|
+
flex-direction: column;
|
|
1880
2464
|
gap: var(--schematic-space);
|
|
1881
|
-
justify-content: space-between;
|
|
1882
|
-
padding: 0.5rem 0.5rem 0.5rem 1.5rem;
|
|
1883
2465
|
}
|
|
1884
2466
|
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
}
|
|
1889
|
-
}
|
|
1890
|
-
|
|
1891
|
-
/* Body text at 18px, not a heading face. */
|
|
1892
|
-
.schematic-dialog__title {
|
|
1893
|
-
font-family: var(--schematic-font-body);
|
|
1894
|
-
font-size: 1.125rem;
|
|
1895
|
-
font-weight: 400;
|
|
1896
|
-
line-height: var(--schematic-line-height);
|
|
1897
|
-
margin: 0;
|
|
2467
|
+
.schematic-credit-usage__main {
|
|
2468
|
+
display: flex;
|
|
2469
|
+
gap: calc(var(--schematic-space) * 1.5);
|
|
1898
2470
|
}
|
|
1899
2471
|
|
|
1900
|
-
.
|
|
2472
|
+
/* Held even without a glyph, as the embed does, so names line up. */
|
|
2473
|
+
.schematic-credit-usage__icon {
|
|
1901
2474
|
align-items: center;
|
|
1902
|
-
background:
|
|
1903
|
-
border:
|
|
1904
|
-
color: color-mix(in srgb, var(--schematic-text) 27.5%, transparent);
|
|
1905
|
-
cursor: pointer;
|
|
2475
|
+
background: var(--schematic-surface);
|
|
2476
|
+
border-radius: 9999px;
|
|
1906
2477
|
display: inline-flex;
|
|
1907
2478
|
flex-shrink: 0;
|
|
1908
|
-
font-size:
|
|
2479
|
+
font-size: 1.5rem;
|
|
1909
2480
|
height: 2.75rem;
|
|
1910
2481
|
justify-content: center;
|
|
1911
|
-
line-height: 1;
|
|
1912
|
-
padding: 0;
|
|
1913
2482
|
width: 2.75rem;
|
|
1914
2483
|
}
|
|
1915
2484
|
|
|
1916
|
-
.schematic-
|
|
1917
|
-
|
|
1918
|
-
outline-offset: 2px;
|
|
2485
|
+
.schematic-credit-usage__icon .schematic-icon {
|
|
2486
|
+
color: var(--schematic-accent);
|
|
1919
2487
|
}
|
|
1920
2488
|
|
|
1921
|
-
|
|
2489
|
+
/* The embed's spacing: the balance well clear of the name, the composition
|
|
2490
|
+
tucked close under the balance. */
|
|
2491
|
+
.schematic-credit-usage__body {
|
|
1922
2492
|
display: flex;
|
|
1923
2493
|
flex-direction: column;
|
|
1924
|
-
|
|
2494
|
+
flex-grow: 1;
|
|
2495
|
+
gap: calc(var(--schematic-space) * 2);
|
|
2496
|
+
min-width: 0;
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
.schematic-credit-usage__composition {
|
|
2500
|
+
margin-top: calc(var(--schematic-space) * -1.5);
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
.schematic-credit-usage__title {
|
|
2504
|
+
display: flex;
|
|
2505
|
+
flex-direction: column;
|
|
2506
|
+
gap: 0.5rem;
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
.schematic-credit-usage__name {
|
|
2510
|
+
font-family: var(--schematic-font-heading);
|
|
2511
|
+
font-size: 1.8125rem;
|
|
2512
|
+
font-weight: 800;
|
|
2513
|
+
line-height: var(--schematic-line-height-heading);
|
|
2514
|
+
margin: 0;
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
.schematic-credit-usage__balance {
|
|
2518
|
+
align-items: center;
|
|
2519
|
+
display: flex;
|
|
2520
|
+
gap: var(--schematic-space);
|
|
2521
|
+
justify-content: space-between;
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
.schematic-credit-usage__remaining {
|
|
2525
|
+
font-size: 1.0625rem;
|
|
2526
|
+
font-variant-numeric: tabular-nums;
|
|
2527
|
+
font-weight: 500;
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
.schematic-credit-usage__buy-more {
|
|
2531
|
+
white-space: nowrap;
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
.schematic-credit-usage__details,
|
|
2535
|
+
.schematic-credit-usage__see-all {
|
|
2536
|
+
align-items: center;
|
|
2537
|
+
display: inline-flex;
|
|
2538
|
+
gap: 0.25rem;
|
|
2539
|
+
}
|
|
2540
|
+
|
|
2541
|
+
.schematic-credit-usage__details .schematic-chevron,
|
|
2542
|
+
.schematic-credit-usage__see-all .schematic-chevron {
|
|
2543
|
+
margin-inline-start: -0.333rem;
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
/* Opens above its toggle, as in the embed. */
|
|
2547
|
+
.schematic-credit-usage__grants {
|
|
2548
|
+
background: var(--schematic-inset);
|
|
2549
|
+
border-radius: calc(var(--schematic-radius) * 0.8);
|
|
2550
|
+
display: flex;
|
|
2551
|
+
flex-direction: column;
|
|
2552
|
+
gap: 0.5rem;
|
|
2553
|
+
margin-bottom: 0.5rem;
|
|
2554
|
+
padding: calc(var(--schematic-space) * 1.5);
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2557
|
+
.schematic-credit-usage__grant-list {
|
|
2558
|
+
display: flex;
|
|
2559
|
+
flex-direction: column;
|
|
2560
|
+
gap: 0.75rem;
|
|
2561
|
+
list-style: none;
|
|
2562
|
+
margin: 0;
|
|
2563
|
+
padding: 0;
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
/* Where the grant and its date do not fit on one line, the date wraps
|
|
2567
|
+
rather than overflowing the panel. */
|
|
2568
|
+
.schematic-credit-usage__grant {
|
|
2569
|
+
display: flex;
|
|
2570
|
+
flex-wrap: wrap;
|
|
2571
|
+
gap: 0.25rem var(--schematic-space);
|
|
2572
|
+
justify-content: space-between;
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2575
|
+
.schematic-credit-usage__grant-text {
|
|
2576
|
+
flex: 1 1 12rem;
|
|
2577
|
+
min-width: 0;
|
|
2578
|
+
overflow-wrap: anywhere;
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2581
|
+
.schematic-credit-usage__grant-date {
|
|
2582
|
+
margin-inline-start: auto;
|
|
2583
|
+
text-align: end;
|
|
2584
|
+
white-space: nowrap;
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
.schematic-credit-usage .schematic-skeleton__cell[data-column="name"] {
|
|
2588
|
+
width: 10rem;
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
.schematic-credit-usage .schematic-skeleton__cell[data-column="remaining"] {
|
|
2592
|
+
width: 6rem;
|
|
2593
|
+
}
|
|
2594
|
+
`;
|
|
2595
|
+
|
|
2596
|
+
// src/elements/styles/dialog.ts
|
|
2597
|
+
var dialogCss = `
|
|
2598
|
+
/* Up to 768px wide, with a tighter radius than a card. */
|
|
2599
|
+
.schematic-dialog {
|
|
2600
|
+
background: var(--schematic-background);
|
|
2601
|
+
border: 0;
|
|
2602
|
+
border-radius: 0.5rem;
|
|
2603
|
+
box-shadow: var(--schematic-shadow);
|
|
2604
|
+
box-sizing: border-box;
|
|
2605
|
+
color: var(--schematic-text);
|
|
2606
|
+
margin: auto;
|
|
2607
|
+
max-height: calc(100vh - 2 * var(--schematic-space));
|
|
2608
|
+
max-width: none;
|
|
2609
|
+
/* No padding of its own: a click on the backdrop lands on the dialog
|
|
2610
|
+
itself, and one inside lands on the header or body. */
|
|
2611
|
+
padding: 0;
|
|
2612
|
+
/* Never wider than the screen, whatever it holds. */
|
|
2613
|
+
width: min(48rem, calc(100vw - 2 * var(--schematic-space)));
|
|
2614
|
+
}
|
|
2615
|
+
|
|
2616
|
+
/* Centred by vw on a phone: a host page wider than the screen widens the
|
|
2617
|
+
layout viewport, and auto margins would centre the dialog half off the
|
|
2618
|
+
screen. Desktop keeps auto margins, as vw counts the scrollbar there. */
|
|
2619
|
+
@media (max-width: 52rem) {
|
|
2620
|
+
.schematic-dialog {
|
|
2621
|
+
inset-inline: 0 auto;
|
|
2622
|
+
margin-inline: calc(
|
|
2623
|
+
(100vw - min(48rem, calc(100vw - 2 * var(--schematic-space)))) / 2
|
|
2624
|
+
)
|
|
2625
|
+
0;
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
|
|
2629
|
+
.schematic-dialog::backdrop {
|
|
2630
|
+
-webkit-backdrop-filter: blur(8px);
|
|
2631
|
+
backdrop-filter: blur(8px);
|
|
2632
|
+
background: var(--schematic-backdrop);
|
|
2633
|
+
}
|
|
2634
|
+
|
|
2635
|
+
/* Narrow on the right, where the close control's own hit area makes up the
|
|
2636
|
+
rest. */
|
|
2637
|
+
.schematic-dialog__header {
|
|
2638
|
+
align-items: center;
|
|
2639
|
+
border-bottom: 1px solid
|
|
2640
|
+
color-mix(in srgb, var(--schematic-text) 15%, transparent);
|
|
2641
|
+
display: flex;
|
|
2642
|
+
gap: var(--schematic-space);
|
|
2643
|
+
justify-content: space-between;
|
|
2644
|
+
padding: 0.5rem 0.5rem 0.5rem 1.5rem;
|
|
2645
|
+
}
|
|
2646
|
+
|
|
2647
|
+
@media (min-width: 768px) {
|
|
2648
|
+
.schematic-dialog__header {
|
|
2649
|
+
padding: 1rem 0.75rem 1rem 3rem;
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
/* Body text at 18px, not a heading face. */
|
|
2654
|
+
.schematic-dialog__title {
|
|
2655
|
+
font-family: var(--schematic-font-body);
|
|
2656
|
+
font-size: 1.125rem;
|
|
2657
|
+
font-weight: 400;
|
|
2658
|
+
line-height: var(--schematic-line-height);
|
|
2659
|
+
margin: 0;
|
|
2660
|
+
}
|
|
2661
|
+
|
|
2662
|
+
.schematic-dialog__close {
|
|
2663
|
+
align-items: center;
|
|
2664
|
+
background: none;
|
|
2665
|
+
border: none;
|
|
2666
|
+
color: color-mix(in srgb, var(--schematic-text) 27.5%, transparent);
|
|
2667
|
+
cursor: pointer;
|
|
2668
|
+
display: inline-flex;
|
|
2669
|
+
flex-shrink: 0;
|
|
2670
|
+
font-size: 2.5rem;
|
|
2671
|
+
height: 2.75rem;
|
|
2672
|
+
justify-content: center;
|
|
2673
|
+
line-height: 1;
|
|
2674
|
+
padding: 0;
|
|
2675
|
+
width: 2.75rem;
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
.schematic-dialog__close:focus-visible {
|
|
2679
|
+
outline: 2px solid var(--schematic-accent);
|
|
2680
|
+
outline-offset: 2px;
|
|
2681
|
+
}
|
|
2682
|
+
|
|
2683
|
+
.schematic-dialog__body {
|
|
2684
|
+
display: flex;
|
|
2685
|
+
flex-direction: column;
|
|
2686
|
+
gap: var(--schematic-space);
|
|
1925
2687
|
min-width: 0;
|
|
1926
2688
|
overflow-wrap: anywhere;
|
|
1927
2689
|
padding: calc(var(--schematic-space) * 1.5);
|
|
@@ -3013,96 +3775,358 @@ var paymentMethodsCss = `
|
|
|
3013
3775
|
}
|
|
3014
3776
|
`;
|
|
3015
3777
|
|
|
3016
|
-
// src/elements/styles/
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
display: inline-block;
|
|
3023
|
-
margin-inline-start: 0.25rem;
|
|
3024
|
-
position: relative;
|
|
3025
|
-
vertical-align: middle;
|
|
3026
|
-
}
|
|
3027
|
-
|
|
3028
|
-
.schematic-tooltip__trigger {
|
|
3029
|
-
background: none;
|
|
3030
|
-
border: 0;
|
|
3031
|
-
color: var(--schematic-muted);
|
|
3032
|
-
cursor: help;
|
|
3033
|
-
/* A button keeps the browser's control font; the glyph is the embed's
|
|
3034
|
-
24px. */
|
|
3035
|
-
font-size: 1.5rem;
|
|
3036
|
-
line-height: 0;
|
|
3037
|
-
padding: 0;
|
|
3778
|
+
// src/elements/styles/plan-manager.ts
|
|
3779
|
+
var planManagerCss = `
|
|
3780
|
+
.schematic-plan-manager {
|
|
3781
|
+
display: flex;
|
|
3782
|
+
flex-direction: column;
|
|
3783
|
+
gap: var(--schematic-space);
|
|
3038
3784
|
}
|
|
3039
3785
|
|
|
3040
|
-
.
|
|
3041
|
-
|
|
3042
|
-
|
|
3786
|
+
/* While loading or failed there is no plan card, so the root draws one. */
|
|
3787
|
+
.schematic-plan-manager[data-state="pending"],
|
|
3788
|
+
.schematic-plan-manager[data-state="error"] {
|
|
3789
|
+
background: var(--schematic-background);
|
|
3790
|
+
border-radius: var(--schematic-radius);
|
|
3791
|
+
box-shadow: var(--schematic-shadow);
|
|
3792
|
+
padding: calc(var(--schematic-card-padding) * 0.75)
|
|
3793
|
+
var(--schematic-card-padding);
|
|
3043
3794
|
}
|
|
3044
3795
|
|
|
3045
|
-
|
|
3796
|
+
/* As in the embed, a notice is a band across the top of the card: the
|
|
3797
|
+
root draws the card and the plan's own card goes flat. */
|
|
3798
|
+
.schematic-plan-manager:has(.schematic-plan-manager__notice) {
|
|
3046
3799
|
background: var(--schematic-background);
|
|
3047
|
-
border:
|
|
3048
|
-
border-radius: calc(var(--schematic-radius) / 2);
|
|
3049
|
-
bottom: calc(100% + 0.5rem);
|
|
3800
|
+
border-radius: var(--schematic-radius);
|
|
3050
3801
|
box-shadow: var(--schematic-shadow);
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
inset-inline-end: 0;
|
|
3054
|
-
padding: 0.5rem 0.75rem;
|
|
3055
|
-
pointer-events: none;
|
|
3056
|
-
position: absolute;
|
|
3057
|
-
text-align: start;
|
|
3058
|
-
visibility: hidden;
|
|
3059
|
-
white-space: nowrap;
|
|
3060
|
-
z-index: 1;
|
|
3802
|
+
gap: 0;
|
|
3803
|
+
overflow: hidden;
|
|
3061
3804
|
}
|
|
3062
3805
|
|
|
3063
|
-
.schematic-
|
|
3064
|
-
.schematic-
|
|
3065
|
-
|
|
3806
|
+
.schematic-plan-manager:has(.schematic-plan-manager__notice)
|
|
3807
|
+
.schematic-plan-manager__card {
|
|
3808
|
+
border-radius: 0;
|
|
3809
|
+
box-shadow: none;
|
|
3066
3810
|
}
|
|
3067
3811
|
|
|
3068
|
-
.schematic-
|
|
3812
|
+
.schematic-plan-manager__notice {
|
|
3813
|
+
align-items: center;
|
|
3814
|
+
background: var(--schematic-inset);
|
|
3069
3815
|
display: flex;
|
|
3070
3816
|
flex-direction: column;
|
|
3071
3817
|
gap: 0.5rem;
|
|
3818
|
+
padding: calc(var(--schematic-space) * 1.5);
|
|
3819
|
+
text-align: center;
|
|
3072
3820
|
}
|
|
3073
3821
|
|
|
3074
|
-
.schematic-
|
|
3822
|
+
.schematic-plan-manager__notice-title {
|
|
3823
|
+
font-family: var(--schematic-font-heading);
|
|
3824
|
+
font-size: 1.25rem;
|
|
3825
|
+
font-weight: 600;
|
|
3826
|
+
line-height: var(--schematic-line-height-heading);
|
|
3075
3827
|
margin: 0;
|
|
3076
3828
|
}
|
|
3077
3829
|
|
|
3078
|
-
.schematic-
|
|
3079
|
-
|
|
3080
|
-
gap: var(--schematic-space);
|
|
3081
|
-
justify-content: space-between;
|
|
3082
|
-
padding: 0.25rem 0;
|
|
3830
|
+
.schematic-plan-manager__notice-body {
|
|
3831
|
+
font-size: 0.8125rem;
|
|
3083
3832
|
}
|
|
3084
3833
|
|
|
3085
|
-
.schematic-
|
|
3086
|
-
|
|
3834
|
+
.schematic-plan-manager__card {
|
|
3835
|
+
display: flex;
|
|
3836
|
+
flex-direction: column;
|
|
3837
|
+
gap: calc(var(--schematic-space) * 2);
|
|
3087
3838
|
}
|
|
3088
3839
|
|
|
3089
|
-
.schematic-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3840
|
+
.schematic-plan-manager__plan {
|
|
3841
|
+
align-items: center;
|
|
3842
|
+
display: flex;
|
|
3843
|
+
gap: var(--schematic-space);
|
|
3844
|
+
justify-content: space-between;
|
|
3093
3845
|
}
|
|
3094
|
-
`;
|
|
3095
3846
|
|
|
3096
|
-
|
|
3097
|
-
var upcomingBillCss = `
|
|
3098
|
-
.schematic-upcoming-bill {
|
|
3847
|
+
.schematic-plan-manager__title {
|
|
3099
3848
|
display: flex;
|
|
3100
3849
|
flex-direction: column;
|
|
3101
3850
|
gap: var(--schematic-space);
|
|
3102
3851
|
}
|
|
3103
3852
|
|
|
3104
|
-
.schematic-
|
|
3105
|
-
|
|
3853
|
+
.schematic-plan-manager__name {
|
|
3854
|
+
font-family: var(--schematic-font-heading);
|
|
3855
|
+
font-size: 2.3125rem;
|
|
3856
|
+
font-weight: 800;
|
|
3857
|
+
line-height: 1;
|
|
3858
|
+
margin: 0;
|
|
3859
|
+
}
|
|
3860
|
+
|
|
3861
|
+
.schematic-plan-manager__price {
|
|
3862
|
+
font-family: var(--schematic-font-heading);
|
|
3863
|
+
font-size: 1.25rem;
|
|
3864
|
+
font-weight: 600;
|
|
3865
|
+
white-space: nowrap;
|
|
3866
|
+
}
|
|
3867
|
+
|
|
3868
|
+
.schematic-plan-manager__section {
|
|
3869
|
+
display: flex;
|
|
3870
|
+
flex-direction: column;
|
|
3871
|
+
gap: 0.5rem;
|
|
3872
|
+
}
|
|
3873
|
+
|
|
3874
|
+
.schematic-plan-manager__label {
|
|
3875
|
+
line-height: 1;
|
|
3876
|
+
}
|
|
3877
|
+
|
|
3878
|
+
.schematic-plan-manager__rows {
|
|
3879
|
+
display: flex;
|
|
3880
|
+
flex-direction: column;
|
|
3881
|
+
gap: var(--schematic-space);
|
|
3882
|
+
list-style: none;
|
|
3883
|
+
margin: 0;
|
|
3884
|
+
padding: 0;
|
|
3885
|
+
}
|
|
3886
|
+
|
|
3887
|
+
/* Centred as in the embed; a plan credit's name and figure share a
|
|
3888
|
+
baseline above the line that explains them. */
|
|
3889
|
+
.schematic-plan-manager__row,
|
|
3890
|
+
.schematic-plan-manager__row-main {
|
|
3891
|
+
align-items: center;
|
|
3892
|
+
display: flex;
|
|
3893
|
+
flex-wrap: wrap;
|
|
3894
|
+
gap: var(--schematic-space);
|
|
3895
|
+
justify-content: space-between;
|
|
3896
|
+
}
|
|
3897
|
+
|
|
3898
|
+
.schematic-plan-manager__row-main {
|
|
3899
|
+
align-items: baseline;
|
|
3900
|
+
gap: 0.5rem;
|
|
3901
|
+
}
|
|
3902
|
+
|
|
3903
|
+
.schematic-plan-manager__row--stacked {
|
|
3904
|
+
align-items: stretch;
|
|
3905
|
+
flex-direction: column;
|
|
3906
|
+
gap: 0.25rem;
|
|
3907
|
+
}
|
|
3908
|
+
|
|
3909
|
+
.schematic-plan-manager__item {
|
|
3910
|
+
font-family: var(--schematic-font-heading);
|
|
3911
|
+
font-size: 1.125rem;
|
|
3912
|
+
font-weight: 800;
|
|
3913
|
+
}
|
|
3914
|
+
|
|
3915
|
+
.schematic-plan-manager__detail,
|
|
3916
|
+
.schematic-plan-manager__used {
|
|
3917
|
+
align-items: center;
|
|
3918
|
+
display: inline-flex;
|
|
3919
|
+
gap: 0.25rem;
|
|
3920
|
+
}
|
|
3921
|
+
|
|
3922
|
+
.schematic-plan-manager__see-all {
|
|
3923
|
+
align-items: center;
|
|
3924
|
+
align-self: flex-start;
|
|
3925
|
+
display: inline-flex;
|
|
3926
|
+
gap: 0.25rem;
|
|
3927
|
+
margin-top: 0.5rem;
|
|
3928
|
+
}
|
|
3929
|
+
|
|
3930
|
+
.schematic-plan-manager__see-all .schematic-chevron {
|
|
3931
|
+
margin-inline-start: -0.333rem;
|
|
3932
|
+
}
|
|
3933
|
+
|
|
3934
|
+
.schematic-plan-manager__auto-topup {
|
|
3935
|
+
align-items: center;
|
|
3936
|
+
background: var(--schematic-inset);
|
|
3937
|
+
border-radius: calc(var(--schematic-radius) * 0.8);
|
|
3938
|
+
display: flex;
|
|
3939
|
+
gap: 0.5rem;
|
|
3940
|
+
justify-content: space-between;
|
|
3941
|
+
padding: calc(var(--schematic-space) * 1.5);
|
|
3942
|
+
}
|
|
3943
|
+
|
|
3944
|
+
.schematic-plan-manager__auto-topup-lines {
|
|
3945
|
+
display: flex;
|
|
3946
|
+
flex-direction: column;
|
|
3947
|
+
gap: 0.5rem;
|
|
3948
|
+
line-height: 1.25;
|
|
3949
|
+
}
|
|
3950
|
+
|
|
3951
|
+
.schematic-plan-manager__change-plan {
|
|
3952
|
+
width: 100%;
|
|
3953
|
+
}
|
|
3954
|
+
|
|
3955
|
+
.schematic-plan-manager .schematic-skeleton__cell[data-column="name"] {
|
|
3956
|
+
width: 10rem;
|
|
3957
|
+
}
|
|
3958
|
+
|
|
3959
|
+
.schematic-plan-manager .schematic-skeleton__cell[data-column="price"] {
|
|
3960
|
+
width: 6rem;
|
|
3961
|
+
}
|
|
3962
|
+
`;
|
|
3963
|
+
|
|
3964
|
+
// src/elements/styles/index.tsx
|
|
3965
|
+
init_tokens();
|
|
3966
|
+
|
|
3967
|
+
// src/elements/styles/tooltip.ts
|
|
3968
|
+
var tooltipCss = `
|
|
3969
|
+
.schematic-tooltip {
|
|
3970
|
+
display: inline-block;
|
|
3971
|
+
margin-inline-start: 0.25rem;
|
|
3972
|
+
position: relative;
|
|
3973
|
+
vertical-align: middle;
|
|
3974
|
+
}
|
|
3975
|
+
|
|
3976
|
+
.schematic-tooltip__trigger {
|
|
3977
|
+
background: none;
|
|
3978
|
+
border: 0;
|
|
3979
|
+
color: var(--schematic-muted);
|
|
3980
|
+
cursor: help;
|
|
3981
|
+
/* A button keeps the browser's control font; the glyph is the embed's
|
|
3982
|
+
24px. */
|
|
3983
|
+
font-size: 1.5rem;
|
|
3984
|
+
line-height: 0;
|
|
3985
|
+
padding: 0;
|
|
3986
|
+
}
|
|
3987
|
+
|
|
3988
|
+
.schematic-tooltip__trigger:focus-visible {
|
|
3989
|
+
outline: 2px solid var(--schematic-accent);
|
|
3990
|
+
outline-offset: 2px;
|
|
3991
|
+
}
|
|
3992
|
+
|
|
3993
|
+
.schematic-tooltip__content {
|
|
3994
|
+
background: var(--schematic-background);
|
|
3995
|
+
border: 1px solid var(--schematic-border);
|
|
3996
|
+
border-radius: calc(var(--schematic-radius) / 2);
|
|
3997
|
+
bottom: calc(100% + 0.5rem);
|
|
3998
|
+
box-shadow: var(--schematic-shadow);
|
|
3999
|
+
color: var(--schematic-text);
|
|
4000
|
+
font-size: 0.875rem;
|
|
4001
|
+
inset-inline-end: 0;
|
|
4002
|
+
padding: 0.5rem 0.75rem;
|
|
4003
|
+
pointer-events: none;
|
|
4004
|
+
position: absolute;
|
|
4005
|
+
text-align: start;
|
|
4006
|
+
visibility: hidden;
|
|
4007
|
+
white-space: nowrap;
|
|
4008
|
+
z-index: 1;
|
|
4009
|
+
}
|
|
4010
|
+
|
|
4011
|
+
.schematic-tooltip:hover .schematic-tooltip__content,
|
|
4012
|
+
.schematic-tooltip:focus-within .schematic-tooltip__content {
|
|
4013
|
+
visibility: visible;
|
|
4014
|
+
}
|
|
4015
|
+
|
|
4016
|
+
.schematic-tiers {
|
|
4017
|
+
display: flex;
|
|
4018
|
+
flex-direction: column;
|
|
4019
|
+
gap: 0.5rem;
|
|
4020
|
+
}
|
|
4021
|
+
|
|
4022
|
+
.schematic-tiers__list {
|
|
4023
|
+
margin: 0;
|
|
4024
|
+
}
|
|
4025
|
+
|
|
4026
|
+
.schematic-tiers__tier {
|
|
4027
|
+
display: flex;
|
|
4028
|
+
gap: var(--schematic-space);
|
|
4029
|
+
justify-content: space-between;
|
|
4030
|
+
padding: 0.25rem 0;
|
|
4031
|
+
}
|
|
4032
|
+
|
|
4033
|
+
.schematic-tiers__price {
|
|
4034
|
+
margin: 0;
|
|
4035
|
+
}
|
|
4036
|
+
|
|
4037
|
+
.schematic-tiers__mode {
|
|
4038
|
+
border-top: 1px solid var(--schematic-border);
|
|
4039
|
+
padding-top: 0.5rem;
|
|
4040
|
+
white-space: normal;
|
|
4041
|
+
}
|
|
4042
|
+
`;
|
|
4043
|
+
|
|
4044
|
+
// src/elements/styles/unsubscribe.ts
|
|
4045
|
+
var unsubscribeCss = `
|
|
4046
|
+
.schematic-unsubscribe {
|
|
4047
|
+
display: flex;
|
|
4048
|
+
justify-content: center;
|
|
4049
|
+
}
|
|
4050
|
+
|
|
4051
|
+
.schematic-unsubscribe__open {
|
|
4052
|
+
width: 100%;
|
|
4053
|
+
}
|
|
4054
|
+
|
|
4055
|
+
.schematic-unsubscribe__columns {
|
|
4056
|
+
display: flex;
|
|
4057
|
+
flex-wrap: wrap;
|
|
4058
|
+
gap: calc(var(--schematic-space) * 2);
|
|
4059
|
+
}
|
|
4060
|
+
|
|
4061
|
+
.schematic-unsubscribe__summary {
|
|
4062
|
+
display: flex;
|
|
4063
|
+
flex: 1 1 18rem;
|
|
4064
|
+
flex-direction: column;
|
|
4065
|
+
gap: calc(var(--schematic-space) * 2);
|
|
4066
|
+
}
|
|
4067
|
+
|
|
4068
|
+
.schematic-unsubscribe__manage {
|
|
4069
|
+
display: flex;
|
|
4070
|
+
flex-direction: column;
|
|
4071
|
+
gap: 0.5rem;
|
|
4072
|
+
}
|
|
4073
|
+
|
|
4074
|
+
.schematic-unsubscribe__manage-plan {
|
|
4075
|
+
align-self: flex-start;
|
|
4076
|
+
color: var(--schematic-accent);
|
|
4077
|
+
}
|
|
4078
|
+
|
|
4079
|
+
.schematic-unsubscribe__sidebar {
|
|
4080
|
+
background: var(--schematic-inset);
|
|
4081
|
+
border-radius: calc(var(--schematic-radius) * 0.8);
|
|
4082
|
+
display: flex;
|
|
4083
|
+
flex: 1 1 16rem;
|
|
4084
|
+
flex-direction: column;
|
|
4085
|
+
gap: calc(var(--schematic-space) * 1.5);
|
|
4086
|
+
padding: calc(var(--schematic-space) * 1.5);
|
|
4087
|
+
}
|
|
4088
|
+
|
|
4089
|
+
.schematic-unsubscribe__group {
|
|
4090
|
+
display: flex;
|
|
4091
|
+
flex-direction: column;
|
|
4092
|
+
gap: 0.125rem;
|
|
4093
|
+
}
|
|
4094
|
+
|
|
4095
|
+
.schematic-unsubscribe__line {
|
|
4096
|
+
align-items: baseline;
|
|
4097
|
+
display: flex;
|
|
4098
|
+
gap: var(--schematic-space);
|
|
4099
|
+
justify-content: space-between;
|
|
4100
|
+
white-space: nowrap;
|
|
4101
|
+
}
|
|
4102
|
+
|
|
4103
|
+
.schematic-unsubscribe__name {
|
|
4104
|
+
font-family: var(--schematic-font-heading);
|
|
4105
|
+
font-size: 1.125rem;
|
|
4106
|
+
font-weight: 800;
|
|
4107
|
+
white-space: normal;
|
|
4108
|
+
}
|
|
4109
|
+
|
|
4110
|
+
.schematic-unsubscribe__total {
|
|
4111
|
+
border-top: 1px solid var(--schematic-card-divider);
|
|
4112
|
+
padding-top: calc(var(--schematic-space) * 1.5);
|
|
4113
|
+
}
|
|
4114
|
+
|
|
4115
|
+
.schematic-unsubscribe__confirm {
|
|
4116
|
+
width: 100%;
|
|
4117
|
+
}
|
|
4118
|
+
`;
|
|
4119
|
+
|
|
4120
|
+
// src/elements/styles/upcoming-bill.ts
|
|
4121
|
+
var upcomingBillCss = `
|
|
4122
|
+
.schematic-upcoming-bill {
|
|
4123
|
+
display: flex;
|
|
4124
|
+
flex-direction: column;
|
|
4125
|
+
gap: var(--schematic-space);
|
|
4126
|
+
}
|
|
4127
|
+
|
|
4128
|
+
.schematic-upcoming-bill .schematic-header {
|
|
4129
|
+
margin-bottom: 0;
|
|
3106
4130
|
}
|
|
3107
4131
|
|
|
3108
4132
|
.schematic-upcoming-bill__amount {
|
|
@@ -3717,12 +4741,18 @@ ${paymentMethodsCss}
|
|
|
3717
4741
|
${tooltipCss}
|
|
3718
4742
|
${includedFeaturesCss}
|
|
3719
4743
|
${meteredFeaturesCss}
|
|
4744
|
+
${creditUsageCss}
|
|
4745
|
+
${planManagerCss}
|
|
4746
|
+
${unsubscribeCss}
|
|
3720
4747
|
`;
|
|
3721
4748
|
var schematicStylesCss = withTokenDefaults(rulesCss) + iconsCss;
|
|
3722
4749
|
var SchematicStyles = () => /* @__PURE__ */ jsx("style", { "data-schematic-styles": "", children: schematicStylesCss });
|
|
3723
4750
|
|
|
3724
|
-
// src/elements/
|
|
3725
|
-
import {
|
|
4751
|
+
// src/elements/CreditUsage.tsx
|
|
4752
|
+
import {
|
|
4753
|
+
useCreditBalances,
|
|
4754
|
+
useCreditUserUsage
|
|
4755
|
+
} from "@schematichq/schematic-react";
|
|
3726
4756
|
import { useMemo as useMemo2, useState as useState2 } from "react";
|
|
3727
4757
|
|
|
3728
4758
|
// src/elements/common.tsx
|
|
@@ -3767,6 +4797,9 @@ function useTranslator(overrides, locale) {
|
|
|
3767
4797
|
const { onMissingString, strings, translate } = useSchematicI18n();
|
|
3768
4798
|
return useCallback(
|
|
3769
4799
|
(key, vars) => {
|
|
4800
|
+
if (isDevelopment) {
|
|
4801
|
+
warnRawNumbers(key, vars);
|
|
4802
|
+
}
|
|
3770
4803
|
const override = lookup(overrides, key, vars, resolved2) ?? lookup(strings, key, vars, resolved2);
|
|
3771
4804
|
if (override !== void 0) {
|
|
3772
4805
|
return override;
|
|
@@ -3788,6 +4821,18 @@ function useTranslator(overrides, locale) {
|
|
|
3788
4821
|
[onMissingString, overrides, resolved2, strings, translate]
|
|
3789
4822
|
);
|
|
3790
4823
|
}
|
|
4824
|
+
var rawNumberWarnings = /* @__PURE__ */ new Set();
|
|
4825
|
+
function warnRawNumbers(key, vars) {
|
|
4826
|
+
for (const [name, value] of Object.entries(vars ?? {})) {
|
|
4827
|
+
const id = `${key}.${name}`;
|
|
4828
|
+
if (name !== "count" && typeof value === "number" && !rawNumberWarnings.has(id)) {
|
|
4829
|
+
rawNumberWarnings.add(id);
|
|
4830
|
+
console.warn(
|
|
4831
|
+
`Schematic: "${key}" got a raw number for "${name}"; format it before it reaches the translator.`
|
|
4832
|
+
);
|
|
4833
|
+
}
|
|
4834
|
+
}
|
|
4835
|
+
}
|
|
3791
4836
|
var isDevelopment = (() => {
|
|
3792
4837
|
try {
|
|
3793
4838
|
return process.env.NODE_ENV !== "production";
|
|
@@ -3971,8 +5016,8 @@ function PriceTiers({
|
|
|
3971
5016
|
return /* @__PURE__ */ jsxs2("span", { className: "schematic-tiers", children: [
|
|
3972
5017
|
/* @__PURE__ */ jsx3("dl", { className: "schematic-tiers__list", children: ranges.map((tier) => /* @__PURE__ */ jsxs2("div", { className: "schematic-tiers__tier", children: [
|
|
3973
5018
|
/* @__PURE__ */ jsxs2("dt", { className: "schematic-tiers__range", children: [
|
|
3974
|
-
tier.from,
|
|
3975
|
-
tier.to === null ? "+" : tier.to !== tier.from ? `\u2013${tier.to}` : ""
|
|
5019
|
+
formatNumber(tier.from, locale),
|
|
5020
|
+
tier.to === null ? "+" : tier.to !== tier.from ? `\u2013${formatNumber(tier.to, locale)}` : ""
|
|
3976
5021
|
] }),
|
|
3977
5022
|
/* @__PURE__ */ jsx3("dd", { className: "schematic-tiers__price", children: tierPrice(tier.flatPrice ?? 0, tier.perUnitPrice ?? 0) })
|
|
3978
5023
|
] }, tier.from)) }),
|
|
@@ -3982,6 +5027,7 @@ function PriceTiers({
|
|
|
3982
5027
|
function UserBreakdown({
|
|
3983
5028
|
breakdown,
|
|
3984
5029
|
error,
|
|
5030
|
+
formatAmount,
|
|
3985
5031
|
locale,
|
|
3986
5032
|
onRetry,
|
|
3987
5033
|
t,
|
|
@@ -3992,7 +5038,7 @@ function UserBreakdown({
|
|
|
3992
5038
|
() => [...breakdown?.users ?? []].sort((a, b) => b.amount - a.amount),
|
|
3993
5039
|
[breakdown?.users]
|
|
3994
5040
|
);
|
|
3995
|
-
const amount = (value) => `${formatNumber(value, locale)} ${featureName(unit, value, locale)}`;
|
|
5041
|
+
const amount = (value) => `${formatAmount?.(value) ?? formatNumber(value, locale)} ${featureName(unit, value, locale)}`;
|
|
3996
5042
|
if (breakdown === void 0 && error !== void 0) {
|
|
3997
5043
|
return /* @__PURE__ */ jsxs2("div", { className: "schematic-usage-by-user", role: "alert", children: [
|
|
3998
5044
|
/* @__PURE__ */ jsx3("span", { className: "schematic-usage-by-user__title", children: t("usageByUserHeader") }),
|
|
@@ -4080,38 +5126,316 @@ function UserBreakdown({
|
|
|
4080
5126
|
] });
|
|
4081
5127
|
}
|
|
4082
5128
|
|
|
4083
|
-
// src/elements/
|
|
5129
|
+
// src/elements/CreditUsage.tsx
|
|
4084
5130
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
4085
|
-
var
|
|
4086
|
-
|
|
5131
|
+
var VISIBLE_GRANT_COUNT = 3;
|
|
5132
|
+
var GRANT_KEY = {
|
|
5133
|
+
autoTopup: "creditUsageGrantAutoTopup",
|
|
5134
|
+
bundle: "creditUsageGrantBundle",
|
|
5135
|
+
plan: "creditUsageGrantPlan",
|
|
5136
|
+
promotional: "creditUsageGrantPromotional"
|
|
5137
|
+
};
|
|
5138
|
+
function CreditUsage({
|
|
5139
|
+
buyMoreTarget,
|
|
5140
|
+
buyMoreUrl,
|
|
4087
5141
|
className,
|
|
4088
5142
|
headingLevel = 2,
|
|
4089
5143
|
locale: localeProp,
|
|
4090
|
-
|
|
5144
|
+
onBuyMore,
|
|
4091
5145
|
showDescription = true,
|
|
4092
|
-
showEntitlement = true,
|
|
4093
5146
|
showExpiration = true,
|
|
4094
|
-
|
|
4095
|
-
showHeader = true,
|
|
5147
|
+
showHeader = false,
|
|
4096
5148
|
showIcon = true,
|
|
4097
5149
|
showUsage = true,
|
|
4098
|
-
|
|
5150
|
+
showUsageByUser = true,
|
|
4099
5151
|
strings,
|
|
4100
|
-
|
|
5152
|
+
visibleCredits
|
|
4101
5153
|
}) {
|
|
4102
|
-
const { data:
|
|
5154
|
+
const { data: balances, error, isPending, refetch } = useCreditBalances();
|
|
4103
5155
|
const locale = useResolvedLocale(localeProp);
|
|
4104
5156
|
const t = useTranslator(strings, localeProp);
|
|
4105
|
-
const
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
5157
|
+
const credits = useMemo2(
|
|
5158
|
+
() => balances === void 0 ? [] : deriveCreditUsage(balances, { locale, visibleCredits }),
|
|
5159
|
+
[balances, locale, visibleCredits]
|
|
5160
|
+
);
|
|
5161
|
+
const unavailable = balances === void 0 && httpStatus(error) === 404;
|
|
5162
|
+
const errorMessage = error === void 0 ? void 0 : unavailable ? t("creditUsageUnavailable") : t("creditUsageError");
|
|
5163
|
+
if (balances !== void 0 && error === void 0 && credits.length === 0) {
|
|
5164
|
+
return null;
|
|
5165
|
+
}
|
|
5166
|
+
const Heading = `h${headingLevel}`;
|
|
5167
|
+
const CreditHeading = showHeader ? `h${Math.min(6, headingLevel + 1)}` : Heading;
|
|
5168
|
+
return /* @__PURE__ */ jsxs3(
|
|
5169
|
+
StatusFrame,
|
|
5170
|
+
{
|
|
5171
|
+
className: cx("schematic-credit-usage", className),
|
|
5172
|
+
error,
|
|
5173
|
+
errorMessage,
|
|
5174
|
+
hasData: balances !== void 0,
|
|
5175
|
+
isPending,
|
|
5176
|
+
loadingLabel: t("creditUsageLoading"),
|
|
5177
|
+
onRetry: refetch,
|
|
5178
|
+
retryText: t("retry"),
|
|
5179
|
+
skeleton: /* @__PURE__ */ jsx4(CreditUsageSkeleton, { showHeader }),
|
|
5180
|
+
children: [
|
|
5181
|
+
showHeader && /* @__PURE__ */ jsx4("div", { className: "schematic-header", children: /* @__PURE__ */ jsx4(Heading, { className: "schematic-header__title", children: t("creditUsageHeader") }) }),
|
|
5182
|
+
/* @__PURE__ */ jsx4("div", { className: "schematic-credit-usage__credits", children: credits.map((credit) => /* @__PURE__ */ jsxs3(
|
|
5183
|
+
"section",
|
|
5184
|
+
{
|
|
5185
|
+
"aria-label": credit.name,
|
|
5186
|
+
className: "schematic-card schematic-credit-usage__credit",
|
|
5187
|
+
"data-testid": "schematic-credit",
|
|
5188
|
+
children: [
|
|
5189
|
+
/* @__PURE__ */ jsxs3("div", { className: "schematic-credit-usage__main", children: [
|
|
5190
|
+
showIcon && /* @__PURE__ */ jsx4("span", { className: "schematic-credit-usage__icon", children: credit.icon !== null && /* @__PURE__ */ jsx4(
|
|
5191
|
+
"i",
|
|
5192
|
+
{
|
|
5193
|
+
"aria-hidden": "true",
|
|
5194
|
+
className: `schematic-icon schematic-icon--${credit.icon}`
|
|
5195
|
+
}
|
|
5196
|
+
) }),
|
|
5197
|
+
/* @__PURE__ */ jsxs3("div", { className: "schematic-credit-usage__body", children: [
|
|
5198
|
+
/* @__PURE__ */ jsxs3("div", { className: "schematic-credit-usage__title", children: [
|
|
5199
|
+
/* @__PURE__ */ jsx4(CreditHeading, { className: "schematic-credit-usage__name", children: credit.name }),
|
|
5200
|
+
showDescription && credit.description !== null && /* @__PURE__ */ jsx4("p", { className: "schematic-muted", children: credit.description })
|
|
5201
|
+
] }),
|
|
5202
|
+
/* @__PURE__ */ jsxs3("div", { className: "schematic-credit-usage__balance", children: [
|
|
5203
|
+
showUsage && /* @__PURE__ */ jsx4(
|
|
5204
|
+
"span",
|
|
5205
|
+
{
|
|
5206
|
+
className: "schematic-credit-usage__remaining",
|
|
5207
|
+
"data-testid": "schematic-credit-remaining",
|
|
5208
|
+
children: t("creditUsageRemaining", credit.remaining)
|
|
5209
|
+
}
|
|
5210
|
+
),
|
|
5211
|
+
credit.purchasable && /* @__PURE__ */ jsx4(
|
|
5212
|
+
BuyMore,
|
|
5213
|
+
{
|
|
5214
|
+
credit,
|
|
5215
|
+
label: t("creditUsageBuyMore"),
|
|
5216
|
+
onBuyMore,
|
|
5217
|
+
target: buyMoreTarget,
|
|
5218
|
+
url: buyMoreUrl
|
|
5219
|
+
}
|
|
5220
|
+
)
|
|
5221
|
+
] }),
|
|
5222
|
+
credit.composition !== null && /* @__PURE__ */ jsx4("p", { className: "schematic-muted schematic-small schematic-credit-usage__composition", children: compositionText(credit, t) })
|
|
5223
|
+
] })
|
|
5224
|
+
] }),
|
|
5225
|
+
credit.ledger.length > 0 && /* @__PURE__ */ jsx4(
|
|
5226
|
+
Ledger,
|
|
5227
|
+
{
|
|
5228
|
+
credit,
|
|
5229
|
+
locale,
|
|
5230
|
+
showExpiration,
|
|
5231
|
+
t
|
|
5232
|
+
}
|
|
5233
|
+
),
|
|
5234
|
+
showUsageByUser && credit.ledger.length > 0 && /* @__PURE__ */ jsx4(CreditUserBreakdown, { credit, locale, t })
|
|
5235
|
+
]
|
|
5236
|
+
},
|
|
5237
|
+
credit.creditId
|
|
5238
|
+
)) })
|
|
5239
|
+
]
|
|
5240
|
+
}
|
|
5241
|
+
);
|
|
5242
|
+
}
|
|
5243
|
+
function compositionText(credit, t) {
|
|
5244
|
+
const composition = credit.composition;
|
|
5245
|
+
if (composition === null) {
|
|
5246
|
+
return "";
|
|
5247
|
+
}
|
|
5248
|
+
const vars = {
|
|
5249
|
+
creditName: composition.creditName,
|
|
5250
|
+
perLicense: t("creditUsagePerLicense", composition.perLicense),
|
|
5251
|
+
period: shortPeriod(composition.period, t) ?? composition.period,
|
|
5252
|
+
total: composition.total
|
|
5253
|
+
};
|
|
5254
|
+
const sentence = composition.companyGrant === null ? t("creditUsageComposition", vars) : t("creditUsageCompositionWithGrant", {
|
|
5255
|
+
...vars,
|
|
5256
|
+
companyGrant: t("creditUsageCompanyGrant", {
|
|
5257
|
+
amount: composition.companyGrant
|
|
5258
|
+
})
|
|
5259
|
+
});
|
|
5260
|
+
return composition.renewsOn === null ? sentence : `${sentence} ${t("creditUsageRenewsOn", { day: composition.renewsOn })}`;
|
|
5261
|
+
}
|
|
5262
|
+
function Ledger({
|
|
5263
|
+
credit,
|
|
5264
|
+
locale,
|
|
5265
|
+
showExpiration,
|
|
5266
|
+
t
|
|
5267
|
+
}) {
|
|
5268
|
+
const [open, setOpen] = useState2(false);
|
|
5269
|
+
const [all, setAll] = useState2(false);
|
|
5270
|
+
const rows = all ? credit.ledger : credit.ledger.slice(0, VISIBLE_GRANT_COUNT);
|
|
5271
|
+
return /* @__PURE__ */ jsxs3("div", { className: "schematic-credit-usage__ledger", children: [
|
|
5272
|
+
open && /* @__PURE__ */ jsxs3("div", { className: "schematic-credit-usage__grants", children: [
|
|
5273
|
+
/* @__PURE__ */ jsx4("ul", { className: "schematic-credit-usage__grant-list", children: rows.map((row) => /* @__PURE__ */ jsxs3(
|
|
5274
|
+
"li",
|
|
5275
|
+
{
|
|
5276
|
+
className: "schematic-credit-usage__grant",
|
|
5277
|
+
"data-testid": "schematic-credit-grant",
|
|
5278
|
+
children: [
|
|
5279
|
+
/* @__PURE__ */ jsx4("span", { className: "schematic-credit-usage__grant-text", children: t(GRANT_KEY[row.kind], {
|
|
5280
|
+
amount: row.amount,
|
|
5281
|
+
createdAt: row.createdAt,
|
|
5282
|
+
item: row.item
|
|
5283
|
+
}) }),
|
|
5284
|
+
showExpiration && row.date !== null && /* @__PURE__ */ jsx4("span", { className: "schematic-credit-usage__grant-date", children: row.date.kind === "resets" ? t("creditUsageResets", { date: row.date.text }) : t("creditUsageExpires", { date: row.date.text }) })
|
|
5285
|
+
]
|
|
5286
|
+
},
|
|
5287
|
+
row.id
|
|
5288
|
+
)) }),
|
|
5289
|
+
credit.ledger.length > VISIBLE_GRANT_COUNT && /* @__PURE__ */ jsxs3(
|
|
5290
|
+
"button",
|
|
5291
|
+
{
|
|
5292
|
+
"aria-expanded": all,
|
|
5293
|
+
className: "schematic-link-button schematic-credit-usage__see-all",
|
|
5294
|
+
type: "button",
|
|
5295
|
+
onClick: () => setAll((value) => !value),
|
|
5296
|
+
children: [
|
|
5297
|
+
/* @__PURE__ */ jsx4(
|
|
5298
|
+
"i",
|
|
5299
|
+
{
|
|
5300
|
+
"aria-hidden": "true",
|
|
5301
|
+
className: `schematic-icon schematic-icon--${all ? "chevron-up" : "chevron-down"} schematic-chevron`
|
|
5302
|
+
}
|
|
5303
|
+
),
|
|
5304
|
+
/* @__PURE__ */ jsx4("span", { className: "schematic-link-button__label", children: all ? t("creditUsageHideAll") : t("creditUsageSeeAll", {
|
|
5305
|
+
total: formatNumber(credit.ledger.length, locale)
|
|
5306
|
+
}) })
|
|
5307
|
+
]
|
|
5308
|
+
}
|
|
5309
|
+
)
|
|
5310
|
+
] }),
|
|
5311
|
+
/* @__PURE__ */ jsxs3(
|
|
5312
|
+
"button",
|
|
5313
|
+
{
|
|
5314
|
+
"aria-expanded": open,
|
|
5315
|
+
className: "schematic-link-button schematic-credit-usage__details",
|
|
5316
|
+
type: "button",
|
|
5317
|
+
onClick: () => {
|
|
5318
|
+
setOpen((value) => !value);
|
|
5319
|
+
setAll(false);
|
|
5320
|
+
},
|
|
5321
|
+
children: [
|
|
5322
|
+
/* @__PURE__ */ jsx4(
|
|
5323
|
+
"i",
|
|
5324
|
+
{
|
|
5325
|
+
"aria-hidden": "true",
|
|
5326
|
+
className: `schematic-icon schematic-icon--${open ? "chevron-up" : "chevron-down"} schematic-chevron`
|
|
5327
|
+
}
|
|
5328
|
+
),
|
|
5329
|
+
/* @__PURE__ */ jsx4("span", { className: "schematic-link-button__label", children: open ? t("creditUsageHideDetails") : t("creditUsageSeeDetails") })
|
|
5330
|
+
]
|
|
5331
|
+
}
|
|
5332
|
+
)
|
|
5333
|
+
] });
|
|
5334
|
+
}
|
|
5335
|
+
function BuyMore({
|
|
5336
|
+
credit,
|
|
5337
|
+
label,
|
|
5338
|
+
onBuyMore,
|
|
5339
|
+
target,
|
|
5340
|
+
url
|
|
5341
|
+
}) {
|
|
5342
|
+
if (onBuyMore !== void 0) {
|
|
5343
|
+
return /* @__PURE__ */ jsx4(
|
|
5344
|
+
"button",
|
|
5345
|
+
{
|
|
5346
|
+
className: "schematic-cta schematic-cta--small schematic-credit-usage__buy-more",
|
|
5347
|
+
type: "button",
|
|
5348
|
+
onClick: () => onBuyMore(credit.source),
|
|
5349
|
+
children: label
|
|
5350
|
+
}
|
|
5351
|
+
);
|
|
5352
|
+
}
|
|
5353
|
+
if (url !== void 0) {
|
|
5354
|
+
return /* @__PURE__ */ jsx4(
|
|
5355
|
+
"a",
|
|
5356
|
+
{
|
|
5357
|
+
className: "schematic-cta schematic-cta--small schematic-credit-usage__buy-more",
|
|
5358
|
+
href: url,
|
|
5359
|
+
target,
|
|
5360
|
+
children: label
|
|
5361
|
+
}
|
|
5362
|
+
);
|
|
5363
|
+
}
|
|
5364
|
+
return null;
|
|
5365
|
+
}
|
|
5366
|
+
function CreditUserBreakdown({
|
|
5367
|
+
credit,
|
|
5368
|
+
locale,
|
|
5369
|
+
t
|
|
5370
|
+
}) {
|
|
5371
|
+
const { data, error, refetch } = useCreditUserUsage(credit.creditId);
|
|
5372
|
+
return /* @__PURE__ */ jsx4(
|
|
5373
|
+
UserBreakdown,
|
|
5374
|
+
{
|
|
5375
|
+
breakdown: data === void 0 ? void 0 : {
|
|
5376
|
+
count: data.count,
|
|
5377
|
+
total: data.total,
|
|
5378
|
+
unattributed: data.unattributed ?? null,
|
|
5379
|
+
users: data.users.map((user) => ({
|
|
5380
|
+
amount: user.used,
|
|
5381
|
+
id: user.userId,
|
|
5382
|
+
label: user.name ?? user.userId
|
|
5383
|
+
}))
|
|
5384
|
+
},
|
|
5385
|
+
error,
|
|
5386
|
+
formatAmount: (value) => formatCredits(value, locale),
|
|
5387
|
+
locale,
|
|
5388
|
+
onRetry: refetch,
|
|
5389
|
+
t,
|
|
5390
|
+
unit: credit.unit
|
|
5391
|
+
}
|
|
5392
|
+
);
|
|
5393
|
+
}
|
|
5394
|
+
function CreditUsageSkeleton({ showHeader }) {
|
|
5395
|
+
return /* @__PURE__ */ jsxs3("div", { className: "schematic-skeleton", children: [
|
|
5396
|
+
showHeader && /* @__PURE__ */ jsx4("div", { className: "schematic-skeleton__heading" }),
|
|
5397
|
+
[0, 1].map((index) => /* @__PURE__ */ jsxs3("div", { className: "schematic-skeleton__row", children: [
|
|
5398
|
+
/* @__PURE__ */ jsx4("div", { className: "schematic-skeleton__cell", "data-column": "name" }),
|
|
5399
|
+
/* @__PURE__ */ jsx4("div", { className: "schematic-skeleton__cell", "data-column": "remaining" })
|
|
5400
|
+
] }, index))
|
|
5401
|
+
] });
|
|
5402
|
+
}
|
|
5403
|
+
CreditUsage.resources = ["creditBalances"];
|
|
5404
|
+
|
|
5405
|
+
// src/elements/IncludedFeatures.tsx
|
|
5406
|
+
import { useFeatureUsage } from "@schematichq/schematic-react";
|
|
5407
|
+
import { useMemo as useMemo3, useState as useState3 } from "react";
|
|
5408
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
5409
|
+
var VISIBLE_FEATURE_COUNT = 4;
|
|
5410
|
+
function IncludedFeatures({
|
|
5411
|
+
className,
|
|
5412
|
+
headingLevel = 2,
|
|
5413
|
+
locale: localeProp,
|
|
5414
|
+
showCredits = true,
|
|
5415
|
+
showDescription = true,
|
|
5416
|
+
showEntitlement = true,
|
|
5417
|
+
showExpiration = true,
|
|
5418
|
+
showHardLimit = false,
|
|
5419
|
+
showHeader = true,
|
|
5420
|
+
showIcon = true,
|
|
5421
|
+
showUsage = true,
|
|
5422
|
+
showWarningThresholdAsLimit = false,
|
|
5423
|
+
strings,
|
|
5424
|
+
visibleFeatures
|
|
5425
|
+
}) {
|
|
5426
|
+
const { data: features, error, isPending, refetch } = useFeatureUsage();
|
|
5427
|
+
const locale = useResolvedLocale(localeProp);
|
|
5428
|
+
const t = useTranslator(strings, localeProp);
|
|
5429
|
+
const [expanded, setExpanded] = useState3(false);
|
|
5430
|
+
const rows = useMemo3(
|
|
5431
|
+
() => features === void 0 ? [] : deriveIncludedFeatures(features, {
|
|
5432
|
+
locale,
|
|
5433
|
+
showCredits,
|
|
5434
|
+
showWarningThresholdAsLimit,
|
|
5435
|
+
visibleFeatures
|
|
5436
|
+
}),
|
|
5437
|
+
[
|
|
5438
|
+
features,
|
|
4115
5439
|
locale,
|
|
4116
5440
|
showCredits,
|
|
4117
5441
|
showWarningThresholdAsLimit,
|
|
@@ -4123,7 +5447,7 @@ function IncludedFeatures({
|
|
|
4123
5447
|
const shown = canExpand && !expanded ? rows.slice(0, VISIBLE_FEATURE_COUNT) : rows;
|
|
4124
5448
|
const unavailable = features === void 0 && httpStatus(error) === 404;
|
|
4125
5449
|
const errorMessage = error === void 0 ? void 0 : unavailable ? t("includedFeaturesUnavailable") : t("includedFeaturesError");
|
|
4126
|
-
return /* @__PURE__ */
|
|
5450
|
+
return /* @__PURE__ */ jsxs4(
|
|
4127
5451
|
StatusFrame,
|
|
4128
5452
|
{
|
|
4129
5453
|
className: cx("schematic-card", "schematic-included-features", className),
|
|
@@ -4134,26 +5458,26 @@ function IncludedFeatures({
|
|
|
4134
5458
|
loadingLabel: t("includedFeaturesLoading"),
|
|
4135
5459
|
onRetry: refetch,
|
|
4136
5460
|
retryText: t("retry"),
|
|
4137
|
-
skeleton: /* @__PURE__ */
|
|
5461
|
+
skeleton: /* @__PURE__ */ jsx5(IncludedFeaturesSkeleton, { showHeader }),
|
|
4138
5462
|
children: [
|
|
4139
|
-
showHeader && /* @__PURE__ */
|
|
4140
|
-
/* @__PURE__ */
|
|
5463
|
+
showHeader && /* @__PURE__ */ jsx5("div", { className: "schematic-header", children: /* @__PURE__ */ jsx5(Heading, { className: "schematic-header__title", children: t("includedFeaturesHeader") }) }),
|
|
5464
|
+
/* @__PURE__ */ jsx5("ul", { className: "schematic-included-features__list", children: shown.map((row) => /* @__PURE__ */ jsxs4(
|
|
4141
5465
|
"li",
|
|
4142
5466
|
{
|
|
4143
5467
|
className: "schematic-included-features__row",
|
|
4144
5468
|
"data-testid": "schematic-included-feature",
|
|
4145
5469
|
children: [
|
|
4146
|
-
showIcon && row.icon !== null && /* @__PURE__ */
|
|
5470
|
+
showIcon && row.icon !== null && /* @__PURE__ */ jsx5(
|
|
4147
5471
|
"i",
|
|
4148
5472
|
{
|
|
4149
5473
|
"aria-hidden": "true",
|
|
4150
5474
|
className: `schematic-icon schematic-icon--${row.icon} schematic-included-features__icon`
|
|
4151
5475
|
}
|
|
4152
5476
|
),
|
|
4153
|
-
/* @__PURE__ */
|
|
4154
|
-
/* @__PURE__ */
|
|
4155
|
-
showDescription && row.description !== null && /* @__PURE__ */
|
|
4156
|
-
row.perLicenseCredits.map((credits, index) => /* @__PURE__ */
|
|
5477
|
+
/* @__PURE__ */ jsxs4("div", { className: "schematic-included-features__details", children: [
|
|
5478
|
+
/* @__PURE__ */ jsx5("span", { className: "schematic-included-features__name", children: row.name }),
|
|
5479
|
+
showDescription && row.description !== null && /* @__PURE__ */ jsx5("span", { className: "schematic-muted schematic-small", children: row.description }),
|
|
5480
|
+
row.perLicenseCredits.map((credits, index) => /* @__PURE__ */ jsx5(
|
|
4157
5481
|
"span",
|
|
4158
5482
|
{
|
|
4159
5483
|
className: "schematic-muted schematic-small",
|
|
@@ -4165,9 +5489,9 @@ function IncludedFeatures({
|
|
|
4165
5489
|
},
|
|
4166
5490
|
`${credits.creditName}-${index}`
|
|
4167
5491
|
)),
|
|
4168
|
-
showExpiration && row.expiresAt !== null && /* @__PURE__ */
|
|
5492
|
+
showExpiration && row.expiresAt !== null && /* @__PURE__ */ jsx5("em", { className: "schematic-muted schematic-small", children: t("includedFeaturesExpires", { date: row.expiresAt.text }) })
|
|
4169
5493
|
] }),
|
|
4170
|
-
/* @__PURE__ */
|
|
5494
|
+
/* @__PURE__ */ jsx5(
|
|
4171
5495
|
UsageDetails,
|
|
4172
5496
|
{
|
|
4173
5497
|
row,
|
|
@@ -4182,7 +5506,7 @@ function IncludedFeatures({
|
|
|
4182
5506
|
},
|
|
4183
5507
|
row.featureId
|
|
4184
5508
|
)) }),
|
|
4185
|
-
canExpand && /* @__PURE__ */
|
|
5509
|
+
canExpand && /* @__PURE__ */ jsxs4(
|
|
4186
5510
|
"button",
|
|
4187
5511
|
{
|
|
4188
5512
|
"aria-expanded": expanded,
|
|
@@ -4190,14 +5514,14 @@ function IncludedFeatures({
|
|
|
4190
5514
|
type: "button",
|
|
4191
5515
|
onClick: () => setExpanded((value) => !value),
|
|
4192
5516
|
children: [
|
|
4193
|
-
/* @__PURE__ */
|
|
5517
|
+
/* @__PURE__ */ jsx5(
|
|
4194
5518
|
"i",
|
|
4195
5519
|
{
|
|
4196
5520
|
"aria-hidden": "true",
|
|
4197
5521
|
className: `schematic-icon schematic-icon--${expanded ? "chevron-up" : "chevron-down"} schematic-chevron`
|
|
4198
5522
|
}
|
|
4199
5523
|
),
|
|
4200
|
-
/* @__PURE__ */
|
|
5524
|
+
/* @__PURE__ */ jsx5("span", { className: "schematic-link-button__label", children: expanded ? t("includedFeaturesHideAll") : t("includedFeaturesSeeAll") })
|
|
4201
5525
|
]
|
|
4202
5526
|
}
|
|
4203
5527
|
)
|
|
@@ -4217,17 +5541,17 @@ function UsageDetails({
|
|
|
4217
5541
|
if (row.entitlement === null && usage === null) {
|
|
4218
5542
|
return null;
|
|
4219
5543
|
}
|
|
4220
|
-
return /* @__PURE__ */
|
|
4221
|
-
showEntitlement && row.entitlement !== null && /* @__PURE__ */
|
|
5544
|
+
return /* @__PURE__ */ jsxs4("div", { className: "schematic-included-features__usage", children: [
|
|
5545
|
+
showEntitlement && row.entitlement !== null && /* @__PURE__ */ jsxs4("span", { className: "schematic-included-features__entitlement", children: [
|
|
4222
5546
|
entitlementText2(row.entitlement, t),
|
|
4223
|
-
showHardLimit && row.hardLimit !== null && /* @__PURE__ */
|
|
5547
|
+
showHardLimit && row.hardLimit !== null && /* @__PURE__ */ jsx5(Tooltip, { label: t("usageHardLimitLabel"), children: t("usageHardLimit", {
|
|
4224
5548
|
amount: row.hardLimit.amount,
|
|
4225
5549
|
units: row.hardLimit.units
|
|
4226
5550
|
}) })
|
|
4227
5551
|
] }),
|
|
4228
|
-
showUsage && usage !== null && /* @__PURE__ */
|
|
5552
|
+
showUsage && usage !== null && /* @__PURE__ */ jsxs4("span", { className: "schematic-muted schematic-small schematic-included-features__used", children: [
|
|
4229
5553
|
usage,
|
|
4230
|
-
row.tiers !== null && row.tiers.ranges.length > 0 && /* @__PURE__ */
|
|
5554
|
+
row.tiers !== null && row.tiers.ranges.length > 0 && /* @__PURE__ */ jsx5(Tooltip, { label: t("usageTieredPricingLabel"), children: /* @__PURE__ */ jsx5(
|
|
4231
5555
|
PriceTiers,
|
|
4232
5556
|
{
|
|
4233
5557
|
currency: row.tiers.currency,
|
|
@@ -4280,7 +5604,7 @@ function segmentText(segment, t) {
|
|
|
4280
5604
|
switch (segment.kind) {
|
|
4281
5605
|
case "unitPricePerPeriod": {
|
|
4282
5606
|
const period = shortPeriod(segment.period, t) ?? segment.period;
|
|
4283
|
-
return segment.size
|
|
5607
|
+
return segment.size !== null ? t("usagePackagePricePerPeriod", {
|
|
4284
5608
|
cost: segment.cost,
|
|
4285
5609
|
size: segment.size,
|
|
4286
5610
|
units: segment.units,
|
|
@@ -4302,11 +5626,11 @@ function segmentText(segment, t) {
|
|
|
4302
5626
|
}
|
|
4303
5627
|
}
|
|
4304
5628
|
function IncludedFeaturesSkeleton({ showHeader }) {
|
|
4305
|
-
return /* @__PURE__ */
|
|
4306
|
-
showHeader && /* @__PURE__ */
|
|
4307
|
-
[0, 1, 2].map((index) => /* @__PURE__ */
|
|
4308
|
-
/* @__PURE__ */
|
|
4309
|
-
/* @__PURE__ */
|
|
5629
|
+
return /* @__PURE__ */ jsxs4("div", { className: "schematic-skeleton", children: [
|
|
5630
|
+
showHeader && /* @__PURE__ */ jsx5("div", { className: "schematic-skeleton__heading" }),
|
|
5631
|
+
[0, 1, 2].map((index) => /* @__PURE__ */ jsxs4("div", { className: "schematic-skeleton__row", children: [
|
|
5632
|
+
/* @__PURE__ */ jsx5("div", { className: "schematic-skeleton__cell", "data-column": "name" }),
|
|
5633
|
+
/* @__PURE__ */ jsx5("div", { className: "schematic-skeleton__cell", "data-column": "usage" })
|
|
4310
5634
|
] }, index))
|
|
4311
5635
|
] });
|
|
4312
5636
|
}
|
|
@@ -4314,8 +5638,8 @@ IncludedFeatures.resources = ["featureUsage"];
|
|
|
4314
5638
|
|
|
4315
5639
|
// src/elements/Invoices.tsx
|
|
4316
5640
|
import { useInvoices } from "@schematichq/schematic-react";
|
|
4317
|
-
import { useId as useId2, useMemo as
|
|
4318
|
-
import { Fragment as Fragment2, jsx as
|
|
5641
|
+
import { useId as useId2, useMemo as useMemo4, useState as useState4 } from "react";
|
|
5642
|
+
import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
4319
5643
|
var SKELETON_ROWS = 4;
|
|
4320
5644
|
function Invoices({
|
|
4321
5645
|
className,
|
|
@@ -4338,8 +5662,8 @@ function Invoices({
|
|
|
4338
5662
|
} = useInvoices(query);
|
|
4339
5663
|
const locale = useResolvedLocale(localeProp);
|
|
4340
5664
|
const t = useTranslator(strings, localeProp);
|
|
4341
|
-
const [expanded, setExpanded] =
|
|
4342
|
-
const list =
|
|
5665
|
+
const [expanded, setExpanded] = useState4(false);
|
|
5666
|
+
const list = useMemo4(
|
|
4343
5667
|
() => page === void 0 ? void 0 : deriveInvoiceList(page, { locale }),
|
|
4344
5668
|
[locale, page]
|
|
4345
5669
|
);
|
|
@@ -4355,7 +5679,7 @@ function Invoices({
|
|
|
4355
5679
|
);
|
|
4356
5680
|
const unavailable = list === void 0 && httpStatus(error) === 404;
|
|
4357
5681
|
const errorMessage = error === void 0 ? void 0 : unavailable ? t("invoicesUnavailable") : t("invoicesError");
|
|
4358
|
-
return /* @__PURE__ */
|
|
5682
|
+
return /* @__PURE__ */ jsx6(
|
|
4359
5683
|
StatusFrame,
|
|
4360
5684
|
{
|
|
4361
5685
|
className: cx("schematic-card", "schematic-invoices", className),
|
|
@@ -4366,7 +5690,7 @@ function Invoices({
|
|
|
4366
5690
|
loadingLabel: t("invoicesLoading"),
|
|
4367
5691
|
onRetry: refetch,
|
|
4368
5692
|
retryText: t("retry"),
|
|
4369
|
-
skeleton: /* @__PURE__ */
|
|
5693
|
+
skeleton: /* @__PURE__ */ jsx6(
|
|
4370
5694
|
InvoicesSkeleton,
|
|
4371
5695
|
{
|
|
4372
5696
|
columns,
|
|
@@ -4374,22 +5698,22 @@ function Invoices({
|
|
|
4374
5698
|
showHeader
|
|
4375
5699
|
}
|
|
4376
5700
|
),
|
|
4377
|
-
children: list !== void 0 && /* @__PURE__ */
|
|
4378
|
-
showHeader && /* @__PURE__ */
|
|
4379
|
-
rows.length === 0 ? /* @__PURE__ */
|
|
5701
|
+
children: list !== void 0 && /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
5702
|
+
showHeader && /* @__PURE__ */ jsx6("div", { className: "schematic-header", children: /* @__PURE__ */ jsx6(Heading, { className: "schematic-header__title", id: headingId, children: t("invoicesHeader") }) }),
|
|
5703
|
+
rows.length === 0 ? /* @__PURE__ */ jsx6("p", { className: "schematic-muted schematic-invoices__empty", children: t("invoicesEmpty") }) : /* @__PURE__ */ jsx6(
|
|
4380
5704
|
"ul",
|
|
4381
5705
|
{
|
|
4382
5706
|
className: "schematic-invoices__list",
|
|
4383
5707
|
"aria-label": showHeader ? void 0 : t("invoicesHeader"),
|
|
4384
5708
|
"aria-labelledby": showHeader ? headingId : void 0,
|
|
4385
|
-
children: visible.map((row) => /* @__PURE__ */
|
|
5709
|
+
children: visible.map((row) => /* @__PURE__ */ jsxs5(
|
|
4386
5710
|
"li",
|
|
4387
5711
|
{
|
|
4388
5712
|
className: "schematic-invoices__row",
|
|
4389
5713
|
"data-testid": "schematic-invoice",
|
|
4390
5714
|
children: [
|
|
4391
|
-
showDate && /* @__PURE__ */
|
|
4392
|
-
showAmount && /* @__PURE__ */
|
|
5715
|
+
showDate && /* @__PURE__ */ jsx6("span", { className: "schematic-invoices__date", children: /* @__PURE__ */ jsx6(InvoiceDate, { row, t }) }),
|
|
5716
|
+
showAmount && /* @__PURE__ */ jsx6(
|
|
4393
5717
|
"span",
|
|
4394
5718
|
{
|
|
4395
5719
|
className: cx(
|
|
@@ -4406,8 +5730,8 @@ function Invoices({
|
|
|
4406
5730
|
))
|
|
4407
5731
|
}
|
|
4408
5732
|
),
|
|
4409
|
-
(canCollapse || showingAll && list.hasMore) && /* @__PURE__ */
|
|
4410
|
-
canCollapse && /* @__PURE__ */
|
|
5733
|
+
(canCollapse || showingAll && list.hasMore) && /* @__PURE__ */ jsxs5("div", { className: "schematic-invoices__actions", children: [
|
|
5734
|
+
canCollapse && /* @__PURE__ */ jsxs5(
|
|
4411
5735
|
"button",
|
|
4412
5736
|
{
|
|
4413
5737
|
"aria-expanded": expanded,
|
|
@@ -4415,7 +5739,7 @@ function Invoices({
|
|
|
4415
5739
|
type: "button",
|
|
4416
5740
|
onClick: () => setExpanded((value) => !value),
|
|
4417
5741
|
children: [
|
|
4418
|
-
/* @__PURE__ */
|
|
5742
|
+
/* @__PURE__ */ jsx6(
|
|
4419
5743
|
"i",
|
|
4420
5744
|
{
|
|
4421
5745
|
"aria-hidden": "true",
|
|
@@ -4427,11 +5751,11 @@ function Invoices({
|
|
|
4427
5751
|
)
|
|
4428
5752
|
}
|
|
4429
5753
|
),
|
|
4430
|
-
/* @__PURE__ */
|
|
5754
|
+
/* @__PURE__ */ jsx6("span", { className: "schematic-link-button__label", children: expanded ? t("invoicesSeeLess") : t("invoicesSeeMore") })
|
|
4431
5755
|
]
|
|
4432
5756
|
}
|
|
4433
5757
|
),
|
|
4434
|
-
showingAll && list.hasMore && /* @__PURE__ */
|
|
5758
|
+
showingAll && list.hasMore && /* @__PURE__ */ jsx6(
|
|
4435
5759
|
"button",
|
|
4436
5760
|
{
|
|
4437
5761
|
className: "schematic-link-button schematic-invoices__load-more",
|
|
@@ -4454,9 +5778,9 @@ function InvoicesSkeleton({
|
|
|
4454
5778
|
rows,
|
|
4455
5779
|
showHeader
|
|
4456
5780
|
}) {
|
|
4457
|
-
return /* @__PURE__ */
|
|
4458
|
-
showHeader && /* @__PURE__ */
|
|
4459
|
-
Array.from({ length: rows }, (_, row) => /* @__PURE__ */
|
|
5781
|
+
return /* @__PURE__ */ jsxs5("div", { className: "schematic-skeleton", children: [
|
|
5782
|
+
showHeader && /* @__PURE__ */ jsx6("div", { className: "schematic-skeleton__heading" }),
|
|
5783
|
+
Array.from({ length: rows }, (_, row) => /* @__PURE__ */ jsx6("div", { className: "schematic-skeleton__row", children: columns.map((column) => /* @__PURE__ */ jsx6(
|
|
4460
5784
|
"div",
|
|
4461
5785
|
{
|
|
4462
5786
|
className: "schematic-skeleton__cell",
|
|
@@ -4468,10 +5792,10 @@ function InvoicesSkeleton({
|
|
|
4468
5792
|
}
|
|
4469
5793
|
function InvoiceDate({ row, t }) {
|
|
4470
5794
|
if (row.url === null) {
|
|
4471
|
-
return /* @__PURE__ */
|
|
5795
|
+
return /* @__PURE__ */ jsx6("span", { className: "schematic-invoices__date-text", children: row.dateText });
|
|
4472
5796
|
}
|
|
4473
5797
|
const label = row.dateText === "" ? t("invoicesUndated") : row.dateText;
|
|
4474
|
-
return /* @__PURE__ */
|
|
5798
|
+
return /* @__PURE__ */ jsx6(
|
|
4475
5799
|
"a",
|
|
4476
5800
|
{
|
|
4477
5801
|
className: "schematic-invoices__link",
|
|
@@ -4489,8 +5813,8 @@ import {
|
|
|
4489
5813
|
useFeatureUsage as useFeatureUsage2,
|
|
4490
5814
|
useFeatureUserUsage
|
|
4491
5815
|
} from "@schematichq/schematic-react";
|
|
4492
|
-
import { useMemo as
|
|
4493
|
-
import { jsx as
|
|
5816
|
+
import { useMemo as useMemo5 } from "react";
|
|
5817
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
4494
5818
|
function MeteredFeatures({
|
|
4495
5819
|
addMoreTarget,
|
|
4496
5820
|
addMoreUrl,
|
|
@@ -4514,7 +5838,7 @@ function MeteredFeatures({
|
|
|
4514
5838
|
const { data: features, error, isPending, refetch } = useFeatureUsage2();
|
|
4515
5839
|
const locale = useResolvedLocale(localeProp);
|
|
4516
5840
|
const t = useTranslator(strings, localeProp);
|
|
4517
|
-
const rows =
|
|
5841
|
+
const rows = useMemo5(
|
|
4518
5842
|
() => features === void 0 ? [] : deriveMeteredFeatures(features, {
|
|
4519
5843
|
locale,
|
|
4520
5844
|
showCredits,
|
|
@@ -4536,7 +5860,7 @@ function MeteredFeatures({
|
|
|
4536
5860
|
}
|
|
4537
5861
|
const Heading = `h${headingLevel}`;
|
|
4538
5862
|
const NameHeading = showHeader ? `h${Math.min(6, headingLevel + 1)}` : Heading;
|
|
4539
|
-
return /* @__PURE__ */
|
|
5863
|
+
return /* @__PURE__ */ jsxs6(
|
|
4540
5864
|
StatusFrame,
|
|
4541
5865
|
{
|
|
4542
5866
|
className: cx("schematic-metered-features", className),
|
|
@@ -4547,32 +5871,32 @@ function MeteredFeatures({
|
|
|
4547
5871
|
loadingLabel: t("meteredFeaturesLoading"),
|
|
4548
5872
|
onRetry: refetch,
|
|
4549
5873
|
retryText: t("retry"),
|
|
4550
|
-
skeleton: /* @__PURE__ */
|
|
5874
|
+
skeleton: /* @__PURE__ */ jsx7(MeteredFeaturesSkeleton, { showHeader }),
|
|
4551
5875
|
children: [
|
|
4552
|
-
showHeader && /* @__PURE__ */
|
|
4553
|
-
/* @__PURE__ */
|
|
5876
|
+
showHeader && /* @__PURE__ */ jsx7("div", { className: "schematic-header", children: /* @__PURE__ */ jsx7(Heading, { className: "schematic-header__title", children: t("meteredFeaturesHeader") }) }),
|
|
5877
|
+
/* @__PURE__ */ jsx7("ul", { className: "schematic-metered-features__list", children: rows.map((row) => /* @__PURE__ */ jsxs6(
|
|
4554
5878
|
"li",
|
|
4555
5879
|
{
|
|
4556
5880
|
className: "schematic-card schematic-metered-features__feature",
|
|
4557
5881
|
"data-testid": "schematic-metered-feature",
|
|
4558
5882
|
children: [
|
|
4559
|
-
/* @__PURE__ */
|
|
4560
|
-
showIcon && /* @__PURE__ */
|
|
5883
|
+
/* @__PURE__ */ jsxs6("div", { className: "schematic-metered-features__main", children: [
|
|
5884
|
+
showIcon && /* @__PURE__ */ jsx7("span", { className: "schematic-metered-features__icon", children: row.icon !== null && /* @__PURE__ */ jsx7(
|
|
4561
5885
|
"i",
|
|
4562
5886
|
{
|
|
4563
5887
|
"aria-hidden": "true",
|
|
4564
5888
|
className: `schematic-icon schematic-icon--${row.icon}`
|
|
4565
5889
|
}
|
|
4566
5890
|
) }),
|
|
4567
|
-
/* @__PURE__ */
|
|
4568
|
-
/* @__PURE__ */
|
|
4569
|
-
/* @__PURE__ */
|
|
4570
|
-
/* @__PURE__ */
|
|
4571
|
-
showDescription && row.description !== null && /* @__PURE__ */
|
|
5891
|
+
/* @__PURE__ */ jsxs6("div", { className: "schematic-metered-features__body", children: [
|
|
5892
|
+
/* @__PURE__ */ jsxs6("div", { className: "schematic-metered-features__top", children: [
|
|
5893
|
+
/* @__PURE__ */ jsxs6("div", { className: "schematic-metered-features__title", children: [
|
|
5894
|
+
/* @__PURE__ */ jsx7(NameHeading, { className: "schematic-metered-features__name", children: row.name }),
|
|
5895
|
+
showDescription && row.description !== null && /* @__PURE__ */ jsx7("p", { className: "schematic-muted", children: row.description })
|
|
4572
5896
|
] }),
|
|
4573
|
-
/* @__PURE__ */
|
|
4574
|
-
showUsage && row.headline !== null && /* @__PURE__ */
|
|
4575
|
-
showAllocation && /* @__PURE__ */
|
|
5897
|
+
/* @__PURE__ */ jsxs6("div", { className: "schematic-metered-features__figures", children: [
|
|
5898
|
+
showUsage && row.headline !== null && /* @__PURE__ */ jsx7("span", { className: "schematic-metered-features__headline", children: headlineText(row.headline, t) }),
|
|
5899
|
+
showAllocation && /* @__PURE__ */ jsx7(
|
|
4576
5900
|
LimitLine,
|
|
4577
5901
|
{
|
|
4578
5902
|
row,
|
|
@@ -4582,8 +5906,8 @@ function MeteredFeatures({
|
|
|
4582
5906
|
)
|
|
4583
5907
|
] })
|
|
4584
5908
|
] }),
|
|
4585
|
-
showMeter && row.meter !== null && /* @__PURE__ */
|
|
4586
|
-
row.canAddMore && /* @__PURE__ */
|
|
5909
|
+
showMeter && row.meter !== null && /* @__PURE__ */ jsx7(Meter, { meter: row.meter }),
|
|
5910
|
+
row.canAddMore && /* @__PURE__ */ jsx7(
|
|
4587
5911
|
AddMore,
|
|
4588
5912
|
{
|
|
4589
5913
|
label: t("meteredFeaturesAddMore"),
|
|
@@ -4594,8 +5918,8 @@ function MeteredFeatures({
|
|
|
4594
5918
|
)
|
|
4595
5919
|
] })
|
|
4596
5920
|
] }),
|
|
4597
|
-
showUsageByUser && row.hasUsageByUser && /* @__PURE__ */
|
|
4598
|
-
row.priceDetails !== null && /* @__PURE__ */
|
|
5921
|
+
showUsageByUser && row.hasUsageByUser && /* @__PURE__ */ jsx7(UsageByUser, { locale, row, t }),
|
|
5922
|
+
row.priceDetails !== null && /* @__PURE__ */ jsx7(
|
|
4599
5923
|
PriceDetails,
|
|
4600
5924
|
{
|
|
4601
5925
|
details: row.priceDetails,
|
|
@@ -4659,9 +5983,9 @@ function LimitLine({
|
|
|
4659
5983
|
if (parts.length === 0) {
|
|
4660
5984
|
return null;
|
|
4661
5985
|
}
|
|
4662
|
-
return /* @__PURE__ */
|
|
5986
|
+
return /* @__PURE__ */ jsxs6("span", { className: "schematic-muted schematic-metered-features__limit", children: [
|
|
4663
5987
|
parts.join(" \u2022 "),
|
|
4664
|
-
showHardLimit && row.hardLimit !== null && /* @__PURE__ */
|
|
5988
|
+
showHardLimit && row.hardLimit !== null && /* @__PURE__ */ jsx7(Tooltip, { label: t("usageHardLimitLabel"), children: t("usageHardLimit", {
|
|
4665
5989
|
amount: row.hardLimit.amount,
|
|
4666
5990
|
units: row.hardLimit.units
|
|
4667
5991
|
}) })
|
|
@@ -4675,8 +5999,8 @@ var METER_TONE_CLASS = {
|
|
|
4675
5999
|
overage: "schematic-meter--overage"
|
|
4676
6000
|
};
|
|
4677
6001
|
function Meter({ meter: meter2 }) {
|
|
4678
|
-
return /* @__PURE__ */
|
|
4679
|
-
/* @__PURE__ */
|
|
6002
|
+
return /* @__PURE__ */ jsxs6("div", { className: "schematic-metered-features__meter", children: [
|
|
6003
|
+
/* @__PURE__ */ jsx7(
|
|
4680
6004
|
"div",
|
|
4681
6005
|
{
|
|
4682
6006
|
"aria-valuemax": meter2.total,
|
|
@@ -4685,7 +6009,7 @@ function Meter({ meter: meter2 }) {
|
|
|
4685
6009
|
className: cx("schematic-meter", METER_TONE_CLASS[meter2.tone]),
|
|
4686
6010
|
"data-tone": meter2.tone,
|
|
4687
6011
|
role: "meter",
|
|
4688
|
-
children: /* @__PURE__ */
|
|
6012
|
+
children: /* @__PURE__ */ jsx7(
|
|
4689
6013
|
"div",
|
|
4690
6014
|
{
|
|
4691
6015
|
className: "schematic-meter__fill",
|
|
@@ -4694,7 +6018,7 @@ function Meter({ meter: meter2 }) {
|
|
|
4694
6018
|
)
|
|
4695
6019
|
}
|
|
4696
6020
|
),
|
|
4697
|
-
meter2.total > 0 && /* @__PURE__ */
|
|
6021
|
+
meter2.total > 0 && /* @__PURE__ */ jsxs6("span", { className: "schematic-metered-features__meter-label", children: [
|
|
4698
6022
|
meter2.valueText,
|
|
4699
6023
|
"/",
|
|
4700
6024
|
meter2.totalText
|
|
@@ -4708,7 +6032,7 @@ function AddMore({
|
|
|
4708
6032
|
url
|
|
4709
6033
|
}) {
|
|
4710
6034
|
if (onAddMore !== void 0) {
|
|
4711
|
-
return /* @__PURE__ */
|
|
6035
|
+
return /* @__PURE__ */ jsx7(
|
|
4712
6036
|
"button",
|
|
4713
6037
|
{
|
|
4714
6038
|
className: "schematic-cta schematic-metered-features__add-more",
|
|
@@ -4719,7 +6043,7 @@ function AddMore({
|
|
|
4719
6043
|
);
|
|
4720
6044
|
}
|
|
4721
6045
|
if (url !== void 0) {
|
|
4722
|
-
return /* @__PURE__ */
|
|
6046
|
+
return /* @__PURE__ */ jsx7(
|
|
4723
6047
|
"a",
|
|
4724
6048
|
{
|
|
4725
6049
|
className: "schematic-cta schematic-metered-features__add-more",
|
|
@@ -4739,38 +6063,38 @@ function PriceDetails({
|
|
|
4739
6063
|
}) {
|
|
4740
6064
|
const period = details.period === null ? void 0 : shortPeriod(details.period, t);
|
|
4741
6065
|
if (details.kind === "overage") {
|
|
4742
|
-
return /* @__PURE__ */
|
|
4743
|
-
/* @__PURE__ */
|
|
6066
|
+
return /* @__PURE__ */ jsxs6("div", { className: "schematic-metered-features__price-details", children: [
|
|
6067
|
+
/* @__PURE__ */ jsxs6("span", { children: [
|
|
4744
6068
|
t("meteredFeaturesAdditional"),
|
|
4745
6069
|
": ",
|
|
4746
6070
|
details.unitPrice,
|
|
4747
|
-
/* @__PURE__ */
|
|
6071
|
+
/* @__PURE__ */ jsxs6("sub", { children: [
|
|
4748
6072
|
"/",
|
|
4749
|
-
details.packageSize
|
|
6073
|
+
details.packageSize !== null && `${details.packageSize} `,
|
|
4750
6074
|
details.units,
|
|
4751
6075
|
period !== void 0 && `/${period}`
|
|
4752
6076
|
] })
|
|
4753
6077
|
] }),
|
|
4754
|
-
/* @__PURE__ */
|
|
6078
|
+
/* @__PURE__ */ jsxs6("span", { children: [
|
|
4755
6079
|
details.overage.amount,
|
|
4756
6080
|
" ",
|
|
4757
6081
|
details.overage.units,
|
|
4758
6082
|
" \xB7 ",
|
|
4759
6083
|
details.overage.cost,
|
|
4760
|
-
period !== void 0 && /* @__PURE__ */
|
|
6084
|
+
period !== void 0 && /* @__PURE__ */ jsxs6("sub", { children: [
|
|
4761
6085
|
"/",
|
|
4762
6086
|
period
|
|
4763
6087
|
] })
|
|
4764
6088
|
] })
|
|
4765
6089
|
] });
|
|
4766
6090
|
}
|
|
4767
|
-
return /* @__PURE__ */
|
|
4768
|
-
/* @__PURE__ */
|
|
6091
|
+
return /* @__PURE__ */ jsxs6("div", { className: "schematic-metered-features__price-details", children: [
|
|
6092
|
+
/* @__PURE__ */ jsxs6("span", { children: [
|
|
4769
6093
|
t("meteredFeaturesTier"),
|
|
4770
6094
|
": ",
|
|
4771
6095
|
details.from,
|
|
4772
6096
|
details.to === null ? "+" : details.to !== details.from ? `\u2013${details.to}` : "",
|
|
4773
|
-
/* @__PURE__ */
|
|
6097
|
+
/* @__PURE__ */ jsx7(Tooltip, { label: t("usageTieredPricingLabel"), children: /* @__PURE__ */ jsx7(
|
|
4774
6098
|
PriceTiers,
|
|
4775
6099
|
{
|
|
4776
6100
|
currency: details.tiers.currency,
|
|
@@ -4783,9 +6107,9 @@ function PriceDetails({
|
|
|
4783
6107
|
}
|
|
4784
6108
|
) })
|
|
4785
6109
|
] }),
|
|
4786
|
-
details.cost !== null && /* @__PURE__ */
|
|
6110
|
+
details.cost !== null && /* @__PURE__ */ jsxs6("span", { children: [
|
|
4787
6111
|
details.cost,
|
|
4788
|
-
period !== void 0 && /* @__PURE__ */
|
|
6112
|
+
period !== void 0 && /* @__PURE__ */ jsxs6("sub", { children: [
|
|
4789
6113
|
"/",
|
|
4790
6114
|
period
|
|
4791
6115
|
] })
|
|
@@ -4798,7 +6122,7 @@ function UsageByUser({
|
|
|
4798
6122
|
t
|
|
4799
6123
|
}) {
|
|
4800
6124
|
const { data, error, refetch } = useFeatureUserUsage(row.featureId);
|
|
4801
|
-
return /* @__PURE__ */
|
|
6125
|
+
return /* @__PURE__ */ jsx7(
|
|
4802
6126
|
UserBreakdown,
|
|
4803
6127
|
{
|
|
4804
6128
|
breakdown: data === void 0 ? void 0 : {
|
|
@@ -4820,11 +6144,11 @@ function UsageByUser({
|
|
|
4820
6144
|
);
|
|
4821
6145
|
}
|
|
4822
6146
|
function MeteredFeaturesSkeleton({ showHeader }) {
|
|
4823
|
-
return /* @__PURE__ */
|
|
4824
|
-
showHeader && /* @__PURE__ */
|
|
4825
|
-
[0, 1].map((index) => /* @__PURE__ */
|
|
4826
|
-
/* @__PURE__ */
|
|
4827
|
-
/* @__PURE__ */
|
|
6147
|
+
return /* @__PURE__ */ jsxs6("div", { className: "schematic-skeleton", children: [
|
|
6148
|
+
showHeader && /* @__PURE__ */ jsx7("div", { className: "schematic-skeleton__heading" }),
|
|
6149
|
+
[0, 1].map((index) => /* @__PURE__ */ jsxs6("div", { className: "schematic-skeleton__row", children: [
|
|
6150
|
+
/* @__PURE__ */ jsx7("div", { className: "schematic-skeleton__cell", "data-column": "name" }),
|
|
6151
|
+
/* @__PURE__ */ jsx7("div", { className: "schematic-skeleton__cell", "data-column": "usage" })
|
|
4828
6152
|
] }, index))
|
|
4829
6153
|
] });
|
|
4830
6154
|
}
|
|
@@ -4832,8 +6156,8 @@ MeteredFeatures.resources = ["featureUsage"];
|
|
|
4832
6156
|
|
|
4833
6157
|
// src/elements/PaymentMethods.tsx
|
|
4834
6158
|
import { usePaymentMethods } from "@schematichq/schematic-react";
|
|
4835
|
-
import { Suspense, lazy, useCallback as useCallback2, useMemo as
|
|
4836
|
-
import { Fragment as Fragment3, jsx as
|
|
6159
|
+
import { Suspense, lazy, useCallback as useCallback2, useMemo as useMemo6, useState as useState6 } from "react";
|
|
6160
|
+
import { Fragment as Fragment3, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
4837
6161
|
var PaymentMethodForm2 = lazy(() => Promise.resolve().then(() => (init_PaymentMethodForm(), PaymentMethodForm_exports)));
|
|
4838
6162
|
function PaymentMethods({
|
|
4839
6163
|
allowEdit = true,
|
|
@@ -4858,10 +6182,10 @@ function PaymentMethods({
|
|
|
4858
6182
|
} = usePaymentMethods();
|
|
4859
6183
|
const locale = useResolvedLocale(localeProp);
|
|
4860
6184
|
const t = useTranslator(strings, localeProp);
|
|
4861
|
-
const [dialog, setDialog] =
|
|
4862
|
-
const [choosing, setChoosing] =
|
|
4863
|
-
const [lastWrite, setLastWrite] =
|
|
4864
|
-
const derived =
|
|
6185
|
+
const [dialog, setDialog] = useState6(null);
|
|
6186
|
+
const [choosing, setChoosing] = useState6(false);
|
|
6187
|
+
const [lastWrite, setLastWrite] = useState6(null);
|
|
6188
|
+
const derived = useMemo6(
|
|
4865
6189
|
() => methods === void 0 ? void 0 : derivePaymentMethods(methods, { locale }),
|
|
4866
6190
|
[locale, methods]
|
|
4867
6191
|
);
|
|
@@ -4892,7 +6216,7 @@ function PaymentMethods({
|
|
|
4892
6216
|
const Heading = `h${headingLevel}`;
|
|
4893
6217
|
const unavailable = derived === void 0 && httpStatus(error) === 404;
|
|
4894
6218
|
const errorMessage = error === void 0 ? void 0 : unavailable ? t("paymentMethodsUnavailable") : t("paymentMethodsError");
|
|
4895
|
-
return /* @__PURE__ */
|
|
6219
|
+
return /* @__PURE__ */ jsx9(
|
|
4896
6220
|
StatusFrame,
|
|
4897
6221
|
{
|
|
4898
6222
|
className: cx("schematic-card", "schematic-payment-methods", className),
|
|
@@ -4903,18 +6227,19 @@ function PaymentMethods({
|
|
|
4903
6227
|
loadingLabel: t("paymentMethodsLoading"),
|
|
4904
6228
|
onRetry: refetch,
|
|
4905
6229
|
retryText: t("retry"),
|
|
4906
|
-
skeleton: /* @__PURE__ */
|
|
4907
|
-
children: derived !== void 0 && /* @__PURE__ */
|
|
4908
|
-
showHeader && /* @__PURE__ */
|
|
6230
|
+
skeleton: /* @__PURE__ */ jsx9(PaymentMethodsSkeleton, { showHeader }),
|
|
6231
|
+
children: derived !== void 0 && /* @__PURE__ */ jsxs8(Fragment3, { children: [
|
|
6232
|
+
showHeader && /* @__PURE__ */ jsx9(
|
|
4909
6233
|
PaymentMethodsHeader,
|
|
4910
6234
|
{
|
|
4911
6235
|
derived,
|
|
4912
6236
|
heading: Heading,
|
|
6237
|
+
locale,
|
|
4913
6238
|
showExpiration,
|
|
4914
6239
|
t
|
|
4915
6240
|
}
|
|
4916
6241
|
),
|
|
4917
|
-
/* @__PURE__ */
|
|
6242
|
+
/* @__PURE__ */ jsx9(MethodPill, { row: derived.current, t, children: allowEdit && /* @__PURE__ */ jsx9(
|
|
4918
6243
|
"button",
|
|
4919
6244
|
{
|
|
4920
6245
|
className: "schematic-link-button schematic-payment-methods__edit",
|
|
@@ -4923,7 +6248,7 @@ function PaymentMethods({
|
|
|
4923
6248
|
children: derived.current === null ? t("paymentMethodsAdd") : t("paymentMethodsEdit")
|
|
4924
6249
|
}
|
|
4925
6250
|
) }),
|
|
4926
|
-
dialog !== null && /* @__PURE__ */
|
|
6251
|
+
dialog !== null && /* @__PURE__ */ jsx9(
|
|
4927
6252
|
PaymentMethodsDialog,
|
|
4928
6253
|
{
|
|
4929
6254
|
checkoutPrefill,
|
|
@@ -4975,7 +6300,7 @@ function PaymentMethodsDialog({
|
|
|
4975
6300
|
const { current, others, rows } = derived;
|
|
4976
6301
|
const hasMethods = rows.length > 0;
|
|
4977
6302
|
const showForm = view === "add" || !hasMethods;
|
|
4978
|
-
return /* @__PURE__ */
|
|
6303
|
+
return /* @__PURE__ */ jsxs8(
|
|
4979
6304
|
Dialog,
|
|
4980
6305
|
{
|
|
4981
6306
|
className: "schematic-payment-methods__dialog",
|
|
@@ -4984,11 +6309,11 @@ function PaymentMethodsDialog({
|
|
|
4984
6309
|
title: t("paymentMethodsDialogTitle"),
|
|
4985
6310
|
onClose,
|
|
4986
6311
|
children: [
|
|
4987
|
-
showForm ? /* @__PURE__ */
|
|
6312
|
+
showForm ? /* @__PURE__ */ jsx9(
|
|
4988
6313
|
Suspense,
|
|
4989
6314
|
{
|
|
4990
|
-
fallback: /* @__PURE__ */
|
|
4991
|
-
children: /* @__PURE__ */
|
|
6315
|
+
fallback: /* @__PURE__ */ jsx9(FormSkeleton, { label: t("paymentMethodsFormLoading") }),
|
|
6316
|
+
children: /* @__PURE__ */ jsx9(
|
|
4992
6317
|
PaymentMethodForm2,
|
|
4993
6318
|
{
|
|
4994
6319
|
checkoutPrefill,
|
|
@@ -5000,17 +6325,18 @@ function PaymentMethodsDialog({
|
|
|
5000
6325
|
}
|
|
5001
6326
|
)
|
|
5002
6327
|
}
|
|
5003
|
-
) : /* @__PURE__ */
|
|
5004
|
-
/* @__PURE__ */
|
|
6328
|
+
) : /* @__PURE__ */ jsxs8(Fragment3, { children: [
|
|
6329
|
+
/* @__PURE__ */ jsx9(
|
|
5005
6330
|
PaymentMethodsHeader,
|
|
5006
6331
|
{
|
|
5007
6332
|
derived,
|
|
5008
6333
|
heading: "h3",
|
|
6334
|
+
locale,
|
|
5009
6335
|
showExpiration: true,
|
|
5010
6336
|
t
|
|
5011
6337
|
}
|
|
5012
6338
|
),
|
|
5013
|
-
/* @__PURE__ */
|
|
6339
|
+
/* @__PURE__ */ jsx9(MethodPill, { row: current, t, children: current?.canRemove === true && /* @__PURE__ */ jsx9(
|
|
5014
6340
|
"button",
|
|
5015
6341
|
{
|
|
5016
6342
|
className: "schematic-link-button schematic-payment-methods__remove-current",
|
|
@@ -5020,7 +6346,7 @@ function PaymentMethodsDialog({
|
|
|
5020
6346
|
children: t("paymentMethodsRemove")
|
|
5021
6347
|
}
|
|
5022
6348
|
) }),
|
|
5023
|
-
/* @__PURE__ */
|
|
6349
|
+
/* @__PURE__ */ jsxs8(
|
|
5024
6350
|
"button",
|
|
5025
6351
|
{
|
|
5026
6352
|
"aria-expanded": choosing,
|
|
@@ -5028,8 +6354,8 @@ function PaymentMethodsDialog({
|
|
|
5028
6354
|
type: "button",
|
|
5029
6355
|
onClick: onChoose,
|
|
5030
6356
|
children: [
|
|
5031
|
-
/* @__PURE__ */
|
|
5032
|
-
/* @__PURE__ */
|
|
6357
|
+
/* @__PURE__ */ jsx9("span", { className: "schematic-payment-methods__choose-label", children: t("paymentMethodsChooseDifferent") }),
|
|
6358
|
+
/* @__PURE__ */ jsx9(
|
|
5033
6359
|
"i",
|
|
5034
6360
|
{
|
|
5035
6361
|
"aria-hidden": "true",
|
|
@@ -5044,13 +6370,13 @@ function PaymentMethodsDialog({
|
|
|
5044
6370
|
]
|
|
5045
6371
|
}
|
|
5046
6372
|
),
|
|
5047
|
-
choosing && /* @__PURE__ */
|
|
5048
|
-
others.length > 0 && /* @__PURE__ */
|
|
6373
|
+
choosing && /* @__PURE__ */ jsxs8(Fragment3, { children: [
|
|
6374
|
+
others.length > 0 && /* @__PURE__ */ jsx9(
|
|
5049
6375
|
"ul",
|
|
5050
6376
|
{
|
|
5051
6377
|
"aria-label": t("paymentMethodsChooseDifferent"),
|
|
5052
6378
|
className: "schematic-payment-methods__list",
|
|
5053
|
-
children: others.map((row) => /* @__PURE__ */
|
|
6379
|
+
children: others.map((row) => /* @__PURE__ */ jsxs8(
|
|
5054
6380
|
"li",
|
|
5055
6381
|
{
|
|
5056
6382
|
className: "schematic-payment-methods__row",
|
|
@@ -5058,11 +6384,11 @@ function PaymentMethodsDialog({
|
|
|
5058
6384
|
"data-kind": row.kind,
|
|
5059
6385
|
"data-testid": "schematic-payment-method",
|
|
5060
6386
|
children: [
|
|
5061
|
-
/* @__PURE__ */
|
|
5062
|
-
row.expiresShort !== null && /* @__PURE__ */
|
|
6387
|
+
/* @__PURE__ */ jsx9(Method, { row, t }),
|
|
6388
|
+
row.expiresShort !== null && /* @__PURE__ */ jsx9("span", { className: "schematic-payment-methods__expires", children: t("paymentMethodsExpires", {
|
|
5063
6389
|
date: row.expiresShort
|
|
5064
6390
|
}) }),
|
|
5065
|
-
/* @__PURE__ */
|
|
6391
|
+
/* @__PURE__ */ jsx9(
|
|
5066
6392
|
"button",
|
|
5067
6393
|
{
|
|
5068
6394
|
className: "schematic-link-button schematic-payment-methods__set-default",
|
|
@@ -5072,7 +6398,7 @@ function PaymentMethodsDialog({
|
|
|
5072
6398
|
children: t("paymentMethodsSetDefault")
|
|
5073
6399
|
}
|
|
5074
6400
|
),
|
|
5075
|
-
row.canRemove && /* @__PURE__ */
|
|
6401
|
+
row.canRemove && /* @__PURE__ */ jsx9(
|
|
5076
6402
|
"button",
|
|
5077
6403
|
{
|
|
5078
6404
|
"aria-label": t("paymentMethodsRemove"),
|
|
@@ -5080,7 +6406,7 @@ function PaymentMethodsDialog({
|
|
|
5080
6406
|
disabled: isMutating,
|
|
5081
6407
|
type: "button",
|
|
5082
6408
|
onClick: () => onRemove(row),
|
|
5083
|
-
children: /* @__PURE__ */
|
|
6409
|
+
children: /* @__PURE__ */ jsx9(
|
|
5084
6410
|
"i",
|
|
5085
6411
|
{
|
|
5086
6412
|
"aria-hidden": "true",
|
|
@@ -5095,7 +6421,7 @@ function PaymentMethodsDialog({
|
|
|
5095
6421
|
))
|
|
5096
6422
|
}
|
|
5097
6423
|
),
|
|
5098
|
-
/* @__PURE__ */
|
|
6424
|
+
/* @__PURE__ */ jsx9(
|
|
5099
6425
|
"button",
|
|
5100
6426
|
{
|
|
5101
6427
|
className: "schematic-cta schematic-payment-methods__add-new",
|
|
@@ -5107,14 +6433,14 @@ function PaymentMethodsDialog({
|
|
|
5107
6433
|
)
|
|
5108
6434
|
] })
|
|
5109
6435
|
] }),
|
|
5110
|
-
mutationError !== void 0 && /* @__PURE__ */
|
|
6436
|
+
mutationError !== void 0 && /* @__PURE__ */ jsxs8(
|
|
5111
6437
|
"p",
|
|
5112
6438
|
{
|
|
5113
6439
|
className: "schematic-status-note schematic-error schematic-payment-methods__error",
|
|
5114
6440
|
role: "alert",
|
|
5115
6441
|
children: [
|
|
5116
|
-
/* @__PURE__ */
|
|
5117
|
-
onRetry !== void 0 && /* @__PURE__ */
|
|
6442
|
+
/* @__PURE__ */ jsx9("span", { className: "schematic-payment-methods__error-message", children: mutationError }),
|
|
6443
|
+
onRetry !== void 0 && /* @__PURE__ */ jsx9(
|
|
5118
6444
|
"button",
|
|
5119
6445
|
{
|
|
5120
6446
|
className: "schematic-cta schematic-cta--small schematic-cta--ghost schematic-payment-methods__error-retry",
|
|
@@ -5134,17 +6460,18 @@ function PaymentMethodsDialog({
|
|
|
5134
6460
|
function PaymentMethodsHeader({
|
|
5135
6461
|
derived,
|
|
5136
6462
|
heading: Heading,
|
|
6463
|
+
locale,
|
|
5137
6464
|
showExpiration,
|
|
5138
6465
|
t
|
|
5139
6466
|
}) {
|
|
5140
|
-
return /* @__PURE__ */
|
|
5141
|
-
/* @__PURE__ */
|
|
5142
|
-
showExpiration && derived.expiryWarning !== "none" && /* @__PURE__ */
|
|
6467
|
+
return /* @__PURE__ */ jsxs8("div", { className: "schematic-header", children: [
|
|
6468
|
+
/* @__PURE__ */ jsx9(Heading, { className: "schematic-header__title", children: t("paymentMethodsHeader") }),
|
|
6469
|
+
showExpiration && derived.expiryWarning !== "none" && /* @__PURE__ */ jsx9(
|
|
5143
6470
|
"span",
|
|
5144
6471
|
{
|
|
5145
6472
|
className: "schematic-small schematic-payment-methods__expiry-warning",
|
|
5146
6473
|
"data-expiry": derived.expiryWarning,
|
|
5147
|
-
children: expiryWarningText(derived, t)
|
|
6474
|
+
children: expiryWarningText(derived, locale, t)
|
|
5148
6475
|
}
|
|
5149
6476
|
)
|
|
5150
6477
|
] });
|
|
@@ -5154,37 +6481,37 @@ function MethodPill({
|
|
|
5154
6481
|
row,
|
|
5155
6482
|
t
|
|
5156
6483
|
}) {
|
|
5157
|
-
return /* @__PURE__ */
|
|
6484
|
+
return /* @__PURE__ */ jsxs8(
|
|
5158
6485
|
"div",
|
|
5159
6486
|
{
|
|
5160
6487
|
className: "schematic-payment-methods__current",
|
|
5161
6488
|
"data-testid": "schematic-payment-method-current",
|
|
5162
6489
|
children: [
|
|
5163
|
-
row === null ? /* @__PURE__ */
|
|
6490
|
+
row === null ? /* @__PURE__ */ jsx9("span", { className: "schematic-payment-methods__empty", children: t("paymentMethodsEmpty") }) : /* @__PURE__ */ jsx9(Method, { row, t }),
|
|
5164
6491
|
children
|
|
5165
6492
|
]
|
|
5166
6493
|
}
|
|
5167
6494
|
);
|
|
5168
6495
|
}
|
|
5169
6496
|
function Method({ row, t }) {
|
|
5170
|
-
return /* @__PURE__ */
|
|
6497
|
+
return /* @__PURE__ */ jsxs8(
|
|
5171
6498
|
"span",
|
|
5172
6499
|
{
|
|
5173
6500
|
className: "schematic-payment-methods__method",
|
|
5174
6501
|
"data-brand": row.brand,
|
|
5175
6502
|
"data-kind": row.kind,
|
|
5176
6503
|
children: [
|
|
5177
|
-
/* @__PURE__ */
|
|
6504
|
+
/* @__PURE__ */ jsx9(
|
|
5178
6505
|
"i",
|
|
5179
6506
|
{
|
|
5180
6507
|
"aria-hidden": "true",
|
|
5181
6508
|
className: `schematic-icon schematic-icon--${row.icon} schematic-payment-methods__icon`
|
|
5182
6509
|
}
|
|
5183
6510
|
),
|
|
5184
|
-
/* @__PURE__ */
|
|
5185
|
-
row.last4 !== null && /* @__PURE__ */
|
|
6511
|
+
/* @__PURE__ */ jsx9("span", { className: "schematic-payment-methods__label", children: labelText(row.label, t) }),
|
|
6512
|
+
row.last4 !== null && /* @__PURE__ */ jsxs8(Fragment3, { children: [
|
|
5186
6513
|
" ",
|
|
5187
|
-
/* @__PURE__ */
|
|
6514
|
+
/* @__PURE__ */ jsx9("span", { className: "schematic-payment-methods__last4", children: row.last4 })
|
|
5188
6515
|
] })
|
|
5189
6516
|
]
|
|
5190
6517
|
}
|
|
@@ -5193,39 +6520,798 @@ function Method({ row, t }) {
|
|
|
5193
6520
|
function labelText(label, t) {
|
|
5194
6521
|
return label.key === void 0 ? label.text : t(label.key);
|
|
5195
6522
|
}
|
|
5196
|
-
function expiryWarningText(derived, t) {
|
|
6523
|
+
function expiryWarningText(derived, locale, t) {
|
|
5197
6524
|
const months = derived.monthsToExpiration ?? 0;
|
|
5198
|
-
return derived.expiryWarning === "expired" ? t("paymentMethodsExpired") : t("paymentMethodsExpiresInMonths", {
|
|
6525
|
+
return derived.expiryWarning === "expired" ? t("paymentMethodsExpired") : t("paymentMethodsExpiresInMonths", {
|
|
6526
|
+
months: formatNumber(months, locale)
|
|
6527
|
+
});
|
|
5199
6528
|
}
|
|
5200
6529
|
function PaymentMethodsSkeleton({ showHeader }) {
|
|
5201
|
-
return /* @__PURE__ */
|
|
5202
|
-
showHeader && /* @__PURE__ */
|
|
5203
|
-
/* @__PURE__ */
|
|
5204
|
-
/* @__PURE__ */
|
|
5205
|
-
/* @__PURE__ */
|
|
6530
|
+
return /* @__PURE__ */ jsxs8("div", { className: "schematic-skeleton", children: [
|
|
6531
|
+
showHeader && /* @__PURE__ */ jsx9("div", { className: "schematic-skeleton__heading" }),
|
|
6532
|
+
/* @__PURE__ */ jsxs8("div", { className: "schematic-skeleton__row", children: [
|
|
6533
|
+
/* @__PURE__ */ jsx9("div", { className: "schematic-skeleton__cell", "data-column": "method" }),
|
|
6534
|
+
/* @__PURE__ */ jsx9("div", { className: "schematic-skeleton__cell", "data-column": "action" })
|
|
5206
6535
|
] })
|
|
5207
6536
|
] });
|
|
5208
6537
|
}
|
|
5209
6538
|
function FormSkeleton({ label }) {
|
|
5210
|
-
return /* @__PURE__ */
|
|
6539
|
+
return /* @__PURE__ */ jsxs8(
|
|
5211
6540
|
"div",
|
|
5212
6541
|
{
|
|
5213
6542
|
"aria-busy": "true",
|
|
5214
6543
|
className: "schematic-payment-methods__form",
|
|
5215
6544
|
"data-state": "pending",
|
|
5216
6545
|
children: [
|
|
5217
|
-
/* @__PURE__ */
|
|
5218
|
-
/* @__PURE__ */
|
|
6546
|
+
/* @__PURE__ */ jsx9("span", { className: "schematic-hidden", children: label }),
|
|
6547
|
+
/* @__PURE__ */ jsx9("div", { className: "schematic-skeleton", children: /* @__PURE__ */ jsx9("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ jsx9("div", { className: "schematic-skeleton__cell", "data-column": "field" }) }) })
|
|
5219
6548
|
]
|
|
5220
6549
|
}
|
|
5221
6550
|
);
|
|
5222
6551
|
}
|
|
5223
6552
|
PaymentMethods.resources = ["paymentMethods"];
|
|
5224
6553
|
|
|
6554
|
+
// src/elements/PlanManager.tsx
|
|
6555
|
+
import {
|
|
6556
|
+
useCompany,
|
|
6557
|
+
useCreditBalances as useCreditBalances2,
|
|
6558
|
+
useFeatureUsage as useFeatureUsage3
|
|
6559
|
+
} from "@schematichq/schematic-react";
|
|
6560
|
+
import { useMemo as useMemo7, useState as useState7 } from "react";
|
|
6561
|
+
import { Fragment as Fragment4, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
6562
|
+
var VISIBLE_CREDIT_COUNT = 3;
|
|
6563
|
+
var UNIT_KEY = {
|
|
6564
|
+
day: "planManagerDays",
|
|
6565
|
+
hour: "planManagerHours",
|
|
6566
|
+
minute: "planManagerMinutes"
|
|
6567
|
+
};
|
|
6568
|
+
var PERIOD_KEY = {
|
|
6569
|
+
day: "periodDay",
|
|
6570
|
+
month: "periodMonth",
|
|
6571
|
+
quarter: "periodQuarter",
|
|
6572
|
+
week: "periodWeek",
|
|
6573
|
+
year: "periodYear"
|
|
6574
|
+
};
|
|
6575
|
+
function PlanManager({
|
|
6576
|
+
changePlanTarget,
|
|
6577
|
+
changePlanUrl,
|
|
6578
|
+
className,
|
|
6579
|
+
editAutoTopupTarget,
|
|
6580
|
+
editAutoTopupUrl,
|
|
6581
|
+
headingLevel = 2,
|
|
6582
|
+
locale: localeProp,
|
|
6583
|
+
onChangePlan,
|
|
6584
|
+
onEditAutoTopup,
|
|
6585
|
+
showAddOns = true,
|
|
6586
|
+
showCredits = true,
|
|
6587
|
+
showDescription = true,
|
|
6588
|
+
showHardLimit = false,
|
|
6589
|
+
showHeader = true,
|
|
6590
|
+
showLabels = true,
|
|
6591
|
+
showNotice = true,
|
|
6592
|
+
showPrice = true,
|
|
6593
|
+
showUsageBased = true,
|
|
6594
|
+
showWarningThresholdAsLimit = false,
|
|
6595
|
+
showZeroPriceAsFree = false,
|
|
6596
|
+
strings
|
|
6597
|
+
}) {
|
|
6598
|
+
const company = useCompany();
|
|
6599
|
+
const usage = useFeatureUsage3();
|
|
6600
|
+
const credits = useCreditBalances2();
|
|
6601
|
+
const locale = useResolvedLocale(localeProp);
|
|
6602
|
+
const t = useTranslator(strings, localeProp);
|
|
6603
|
+
const creditsFailed = credits.data === void 0 && credits.error !== void 0;
|
|
6604
|
+
const [creditsHaveFailed, setCreditsHaveFailed] = useState7(false);
|
|
6605
|
+
if (creditsFailed && !creditsHaveFailed) {
|
|
6606
|
+
setCreditsHaveFailed(true);
|
|
6607
|
+
} else if (!creditsFailed && creditsHaveFailed && (credits.data !== void 0 || company.data === void 0 || usage.data === void 0)) {
|
|
6608
|
+
setCreditsHaveFailed(false);
|
|
6609
|
+
}
|
|
6610
|
+
const creditsSettled = !showCredits || credits.data !== void 0 || creditsHaveFailed;
|
|
6611
|
+
const view = useMemo7(
|
|
6612
|
+
() => company.data === void 0 || usage.data === void 0 || !creditsSettled ? void 0 : derivePlanManager(
|
|
6613
|
+
{
|
|
6614
|
+
company: company.data,
|
|
6615
|
+
creditBalances: credits.data ?? [],
|
|
6616
|
+
featureUsage: usage.data
|
|
6617
|
+
},
|
|
6618
|
+
{
|
|
6619
|
+
locale,
|
|
6620
|
+
showCredits,
|
|
6621
|
+
showWarningThresholdAsLimit,
|
|
6622
|
+
showZeroPriceAsFree
|
|
6623
|
+
}
|
|
6624
|
+
),
|
|
6625
|
+
[
|
|
6626
|
+
company.data,
|
|
6627
|
+
credits.data,
|
|
6628
|
+
creditsSettled,
|
|
6629
|
+
locale,
|
|
6630
|
+
showCredits,
|
|
6631
|
+
showWarningThresholdAsLimit,
|
|
6632
|
+
showZeroPriceAsFree,
|
|
6633
|
+
usage.data
|
|
6634
|
+
]
|
|
6635
|
+
);
|
|
6636
|
+
const creditsRefetchError = showCredits && credits.data !== void 0 ? credits.error : void 0;
|
|
6637
|
+
const cardError = company.error ?? usage.error;
|
|
6638
|
+
const error = cardError ?? creditsRefetchError;
|
|
6639
|
+
const unavailable = view === void 0 && httpStatus(error) === 404;
|
|
6640
|
+
const errorMessage = error === void 0 ? void 0 : unavailable ? t("planManagerUnavailable") : cardError === void 0 ? t("planManagerCreditsError") : t("planManagerError");
|
|
6641
|
+
const retry = () => {
|
|
6642
|
+
for (const handle of showCredits ? [company, usage, credits] : [company, usage]) {
|
|
6643
|
+
if (handle.error !== void 0) {
|
|
6644
|
+
handle.refetch();
|
|
6645
|
+
}
|
|
6646
|
+
}
|
|
6647
|
+
};
|
|
6648
|
+
const Heading = `h${headingLevel}`;
|
|
6649
|
+
return /* @__PURE__ */ jsx10(
|
|
6650
|
+
StatusFrame,
|
|
6651
|
+
{
|
|
6652
|
+
className: cx("schematic-plan-manager", className),
|
|
6653
|
+
error,
|
|
6654
|
+
errorMessage,
|
|
6655
|
+
hasData: view !== void 0,
|
|
6656
|
+
isPending: company.isPending || usage.isPending || credits.isPending,
|
|
6657
|
+
loadingLabel: t("planManagerLoading"),
|
|
6658
|
+
onRetry: retry,
|
|
6659
|
+
retryText: t("retry"),
|
|
6660
|
+
skeleton: /* @__PURE__ */ jsx10(PlanManagerSkeleton, {}),
|
|
6661
|
+
children: view !== void 0 && /* @__PURE__ */ jsxs9(Fragment4, { children: [
|
|
6662
|
+
showNotice && view.notice !== null && /* @__PURE__ */ jsx10(Notice, { locale, notice: view.notice, t }),
|
|
6663
|
+
/* @__PURE__ */ jsxs9("div", { className: "schematic-card schematic-plan-manager__card", children: [
|
|
6664
|
+
showHeader && view.plan !== null && /* @__PURE__ */ jsxs9("div", { className: "schematic-plan-manager__plan", children: [
|
|
6665
|
+
/* @__PURE__ */ jsxs9("div", { className: "schematic-plan-manager__title", children: [
|
|
6666
|
+
/* @__PURE__ */ jsx10(Heading, { className: "schematic-plan-manager__name", children: view.plan.name }),
|
|
6667
|
+
showDescription && view.plan.description !== null && /* @__PURE__ */ jsx10("p", { className: "schematic-plan-manager__description", children: view.plan.description })
|
|
6668
|
+
] }),
|
|
6669
|
+
showPrice && view.plan.price !== null && /* @__PURE__ */ jsx10(Price, { price: view.plan.price, t })
|
|
6670
|
+
] }),
|
|
6671
|
+
showAddOns && view.addOns.length > 0 && /* @__PURE__ */ jsx10(Section, { label: t("planManagerAddOns"), showLabel: showLabels, children: view.addOns.map((addOn) => /* @__PURE__ */ jsxs9("li", { className: "schematic-plan-manager__row", children: [
|
|
6672
|
+
/* @__PURE__ */ jsx10("span", { className: "schematic-plan-manager__item", children: addOn.name }),
|
|
6673
|
+
addOn.price !== null && /* @__PURE__ */ jsxs9("span", { className: "schematic-plan-manager__price-value", children: [
|
|
6674
|
+
addOn.price.amount,
|
|
6675
|
+
/* @__PURE__ */ jsx10(PeriodSuffix, { period: addOn.price.period, t })
|
|
6676
|
+
] })
|
|
6677
|
+
] }, addOn.id)) }),
|
|
6678
|
+
showUsageBased && view.usageBased.length > 0 && /* @__PURE__ */ jsx10(
|
|
6679
|
+
Section,
|
|
6680
|
+
{
|
|
6681
|
+
label: t("planManagerUsageBased"),
|
|
6682
|
+
showLabel: showLabels,
|
|
6683
|
+
children: view.usageBased.map((row) => /* @__PURE__ */ jsx10(
|
|
6684
|
+
UsageBasedItem,
|
|
6685
|
+
{
|
|
6686
|
+
locale,
|
|
6687
|
+
row,
|
|
6688
|
+
showHardLimit,
|
|
6689
|
+
t
|
|
6690
|
+
},
|
|
6691
|
+
row.featureId
|
|
6692
|
+
))
|
|
6693
|
+
}
|
|
6694
|
+
),
|
|
6695
|
+
showCredits && credits.data === void 0 && creditsHaveFailed && (credits.error !== void 0 || credits.isPending) && /* @__PURE__ */ jsx10(
|
|
6696
|
+
StatusFrame,
|
|
6697
|
+
{
|
|
6698
|
+
className: "schematic-plan-manager__section",
|
|
6699
|
+
error: credits.error,
|
|
6700
|
+
errorMessage: t("planManagerCreditsError"),
|
|
6701
|
+
hasData: false,
|
|
6702
|
+
isPending: credits.isPending,
|
|
6703
|
+
loadingLabel: t("planManagerCreditsLoading"),
|
|
6704
|
+
onRetry: credits.refetch,
|
|
6705
|
+
retryText: t("retry"),
|
|
6706
|
+
children: null
|
|
6707
|
+
}
|
|
6708
|
+
),
|
|
6709
|
+
showCredits && view.planCredits.length > 0 && /* @__PURE__ */ jsx10(
|
|
6710
|
+
Truncated,
|
|
6711
|
+
{
|
|
6712
|
+
locale,
|
|
6713
|
+
after: view.autoTopup !== null && /* @__PURE__ */ jsx10(
|
|
6714
|
+
AutoTopupBox,
|
|
6715
|
+
{
|
|
6716
|
+
lines: view.autoTopup.lines,
|
|
6717
|
+
onEdit: onEditAutoTopup,
|
|
6718
|
+
t,
|
|
6719
|
+
target: editAutoTopupTarget,
|
|
6720
|
+
url: editAutoTopupUrl
|
|
6721
|
+
}
|
|
6722
|
+
),
|
|
6723
|
+
label: t("planManagerCreditsInPlan"),
|
|
6724
|
+
rows: view.planCredits,
|
|
6725
|
+
showLabel: showLabels,
|
|
6726
|
+
t,
|
|
6727
|
+
children: (row) => /* @__PURE__ */ jsx10(PlanCreditItem, { row, t }, row.creditId)
|
|
6728
|
+
}
|
|
6729
|
+
),
|
|
6730
|
+
showCredits && view.topUps.length > 0 && /* @__PURE__ */ jsx10(
|
|
6731
|
+
Truncated,
|
|
6732
|
+
{
|
|
6733
|
+
locale,
|
|
6734
|
+
label: t("planManagerTopUps"),
|
|
6735
|
+
rows: view.topUps,
|
|
6736
|
+
showLabel: showLabels,
|
|
6737
|
+
t,
|
|
6738
|
+
children: (row) => /* @__PURE__ */ jsx10(CreditGroupItem, { countAlways: true, row, t }, row.key)
|
|
6739
|
+
}
|
|
6740
|
+
),
|
|
6741
|
+
showCredits && view.bundles.length > 0 && /* @__PURE__ */ jsx10(
|
|
6742
|
+
Truncated,
|
|
6743
|
+
{
|
|
6744
|
+
locale,
|
|
6745
|
+
label: t("planManagerCreditBundles"),
|
|
6746
|
+
rows: view.bundles,
|
|
6747
|
+
showLabel: showLabels,
|
|
6748
|
+
t,
|
|
6749
|
+
children: (row) => /* @__PURE__ */ jsx10(CreditGroupItem, { row, t }, row.key)
|
|
6750
|
+
}
|
|
6751
|
+
),
|
|
6752
|
+
showCredits && view.promotional.length > 0 && /* @__PURE__ */ jsx10(
|
|
6753
|
+
Truncated,
|
|
6754
|
+
{
|
|
6755
|
+
locale,
|
|
6756
|
+
label: t("planManagerPromotionalCredits"),
|
|
6757
|
+
rows: view.promotional,
|
|
6758
|
+
showLabel: showLabels,
|
|
6759
|
+
t,
|
|
6760
|
+
children: (row) => /* @__PURE__ */ jsx10(CreditGroupItem, { plain: true, row, t }, row.key)
|
|
6761
|
+
}
|
|
6762
|
+
),
|
|
6763
|
+
view.canChangePlan && /* @__PURE__ */ jsx10(
|
|
6764
|
+
Cta,
|
|
6765
|
+
{
|
|
6766
|
+
className: "schematic-cta schematic-plan-manager__change-plan",
|
|
6767
|
+
label: t("planManagerChangePlan"),
|
|
6768
|
+
onClick: onChangePlan,
|
|
6769
|
+
target: changePlanTarget,
|
|
6770
|
+
url: changePlanUrl
|
|
6771
|
+
}
|
|
6772
|
+
)
|
|
6773
|
+
] })
|
|
6774
|
+
] })
|
|
6775
|
+
}
|
|
6776
|
+
);
|
|
6777
|
+
}
|
|
6778
|
+
function Notice({
|
|
6779
|
+
locale,
|
|
6780
|
+
notice: notice2,
|
|
6781
|
+
t
|
|
6782
|
+
}) {
|
|
6783
|
+
let title = null;
|
|
6784
|
+
let body = null;
|
|
6785
|
+
let payUrl = null;
|
|
6786
|
+
switch (notice2.kind) {
|
|
6787
|
+
case "trial":
|
|
6788
|
+
title = notice2.endsIn === null ? null : notice2.endsIn === "soon" ? t("planManagerTrialEndsSoon") : notice2.endsIn === "ended" ? t("planManagerTrialEnded") : t("planManagerTrialEndsIn", {
|
|
6789
|
+
amount: formatNumber(notice2.endsIn.amount, locale),
|
|
6790
|
+
units: t(UNIT_KEY[notice2.endsIn.unit], {
|
|
6791
|
+
count: notice2.endsIn.amount
|
|
6792
|
+
})
|
|
6793
|
+
});
|
|
6794
|
+
break;
|
|
6795
|
+
case "canceled":
|
|
6796
|
+
title = t("planManagerCanceled");
|
|
6797
|
+
body = notice2.date === null ? null : t("planManagerAccessEnds", {
|
|
6798
|
+
date: notice2.date,
|
|
6799
|
+
plan: notice2.planName ?? t("planManagerPlanFallback")
|
|
6800
|
+
});
|
|
6801
|
+
break;
|
|
6802
|
+
case "customPlanBilling": {
|
|
6803
|
+
const plan = notice2.planName ?? t("planManagerYourPlan");
|
|
6804
|
+
title = notice2.awaitingActivation ? t("planManagerCustomAwaiting", { plan }) : t("planManagerCustomDue", { date: notice2.date, plan });
|
|
6805
|
+
body = notice2.awaitingActivation ? t("planManagerCustomAwaitingDescription", { date: notice2.date }) : t("planManagerCustomDueDescription", { date: notice2.date, plan });
|
|
6806
|
+
payUrl = notice2.invoiceUrl;
|
|
6807
|
+
break;
|
|
6808
|
+
}
|
|
6809
|
+
case "scheduledDowngrade":
|
|
6810
|
+
title = t("planManagerDowngradeScheduled", { plan: notice2.toPlanName });
|
|
6811
|
+
body = notice2.date === null ? null : t("planManagerAccessEnds", {
|
|
6812
|
+
date: notice2.date,
|
|
6813
|
+
plan: notice2.fromPlanName
|
|
6814
|
+
});
|
|
6815
|
+
break;
|
|
6816
|
+
}
|
|
6817
|
+
if (title === null && body === null) {
|
|
6818
|
+
return null;
|
|
6819
|
+
}
|
|
6820
|
+
return /* @__PURE__ */ jsxs9(
|
|
6821
|
+
"div",
|
|
6822
|
+
{
|
|
6823
|
+
className: "schematic-plan-manager__notice",
|
|
6824
|
+
"data-kind": notice2.kind,
|
|
6825
|
+
role: "status",
|
|
6826
|
+
children: [
|
|
6827
|
+
title !== null && /* @__PURE__ */ jsx10("p", { className: "schematic-plan-manager__notice-title", children: title }),
|
|
6828
|
+
body !== null && /* @__PURE__ */ jsx10("p", { className: "schematic-small schematic-plan-manager__notice-body", children: body }),
|
|
6829
|
+
payUrl !== null && /* @__PURE__ */ jsx10(
|
|
6830
|
+
"a",
|
|
6831
|
+
{
|
|
6832
|
+
className: "schematic-cta schematic-plan-manager__pay-now",
|
|
6833
|
+
href: payUrl,
|
|
6834
|
+
rel: "noreferrer",
|
|
6835
|
+
target: "_blank",
|
|
6836
|
+
children: t("planManagerPayNow")
|
|
6837
|
+
}
|
|
6838
|
+
)
|
|
6839
|
+
]
|
|
6840
|
+
}
|
|
6841
|
+
);
|
|
6842
|
+
}
|
|
6843
|
+
function Price({ price, t }) {
|
|
6844
|
+
return /* @__PURE__ */ jsxs9("div", { className: "schematic-plan-manager__price", children: [
|
|
6845
|
+
price.kind === "usageBased" ? t("planManagerUsageBased") : price.kind === "free" ? t("planManagerFree") : price.amount,
|
|
6846
|
+
price.kind === "amount" && price.period !== null && /* @__PURE__ */ jsx10(PeriodSuffix, { period: price.period, t })
|
|
6847
|
+
] });
|
|
6848
|
+
}
|
|
6849
|
+
function PeriodSuffix({ period, t }) {
|
|
6850
|
+
const short = shortPeriod(period, t);
|
|
6851
|
+
return short === void 0 ? null : /* @__PURE__ */ jsxs9("sub", { children: [
|
|
6852
|
+
"/",
|
|
6853
|
+
short
|
|
6854
|
+
] });
|
|
6855
|
+
}
|
|
6856
|
+
function Section({
|
|
6857
|
+
children,
|
|
6858
|
+
label,
|
|
6859
|
+
showLabel
|
|
6860
|
+
}) {
|
|
6861
|
+
return /* @__PURE__ */ jsxs9("section", { "aria-label": label, className: "schematic-plan-manager__section", children: [
|
|
6862
|
+
showLabel && /* @__PURE__ */ jsx10("span", { className: "schematic-muted schematic-plan-manager__label", children: label }),
|
|
6863
|
+
/* @__PURE__ */ jsx10("ul", { className: "schematic-plan-manager__rows", children })
|
|
6864
|
+
] });
|
|
6865
|
+
}
|
|
6866
|
+
function Truncated({
|
|
6867
|
+
after,
|
|
6868
|
+
children,
|
|
6869
|
+
label,
|
|
6870
|
+
locale,
|
|
6871
|
+
rows,
|
|
6872
|
+
showLabel,
|
|
6873
|
+
t
|
|
6874
|
+
}) {
|
|
6875
|
+
const [expanded, setExpanded] = useState7(false);
|
|
6876
|
+
const shown = expanded ? rows : rows.slice(0, VISIBLE_CREDIT_COUNT);
|
|
6877
|
+
return /* @__PURE__ */ jsxs9("section", { "aria-label": label, className: "schematic-plan-manager__section", children: [
|
|
6878
|
+
showLabel && /* @__PURE__ */ jsx10("span", { className: "schematic-muted schematic-plan-manager__label", children: label }),
|
|
6879
|
+
/* @__PURE__ */ jsx10("ul", { className: "schematic-plan-manager__rows", children: shown.map(children) }),
|
|
6880
|
+
rows.length > VISIBLE_CREDIT_COUNT && /* @__PURE__ */ jsxs9(
|
|
6881
|
+
"button",
|
|
6882
|
+
{
|
|
6883
|
+
"aria-expanded": expanded,
|
|
6884
|
+
className: "schematic-link-button schematic-plan-manager__see-all",
|
|
6885
|
+
type: "button",
|
|
6886
|
+
onClick: () => setExpanded((value) => !value),
|
|
6887
|
+
children: [
|
|
6888
|
+
/* @__PURE__ */ jsx10(
|
|
6889
|
+
"i",
|
|
6890
|
+
{
|
|
6891
|
+
"aria-hidden": "true",
|
|
6892
|
+
className: `schematic-icon schematic-icon--${expanded ? "chevron-up" : "chevron-down"} schematic-chevron`
|
|
6893
|
+
}
|
|
6894
|
+
),
|
|
6895
|
+
/* @__PURE__ */ jsx10("span", { className: "schematic-link-button__label", children: expanded ? t("planManagerHideAll") : t("planManagerSeeAll", {
|
|
6896
|
+
total: formatNumber(rows.length, locale)
|
|
6897
|
+
}) })
|
|
6898
|
+
]
|
|
6899
|
+
}
|
|
6900
|
+
),
|
|
6901
|
+
after
|
|
6902
|
+
] });
|
|
6903
|
+
}
|
|
6904
|
+
function UsageBasedItem({
|
|
6905
|
+
locale,
|
|
6906
|
+
row,
|
|
6907
|
+
showHardLimit,
|
|
6908
|
+
t
|
|
6909
|
+
}) {
|
|
6910
|
+
const details = [];
|
|
6911
|
+
if (row.additional) {
|
|
6912
|
+
details.push(`${t("planManagerAdditional")}: `);
|
|
6913
|
+
}
|
|
6914
|
+
if (row.tierBased) {
|
|
6915
|
+
details.push(t("planManagerTierBased"));
|
|
6916
|
+
}
|
|
6917
|
+
if (row.unitPrice !== null) {
|
|
6918
|
+
const short = row.unitPrice.period === null ? void 0 : shortPeriod(row.unitPrice.period, t);
|
|
6919
|
+
details.push(
|
|
6920
|
+
/* @__PURE__ */ jsxs9("span", { children: [
|
|
6921
|
+
row.unitPrice.cost,
|
|
6922
|
+
/* @__PURE__ */ jsxs9("sub", { children: [
|
|
6923
|
+
"/",
|
|
6924
|
+
row.unitPrice.packageSize !== null && `${row.unitPrice.packageSize} `,
|
|
6925
|
+
row.unitPrice.units,
|
|
6926
|
+
short !== void 0 && `/${short}`
|
|
6927
|
+
] })
|
|
6928
|
+
] }, "price")
|
|
6929
|
+
);
|
|
6930
|
+
}
|
|
6931
|
+
if (row.perUse !== null) {
|
|
6932
|
+
details.push(
|
|
6933
|
+
t("usagePerUse", { amount: row.perUse.amount, units: row.perUse.units })
|
|
6934
|
+
);
|
|
6935
|
+
}
|
|
6936
|
+
const costPeriod = row.cost?.period === null || row.cost === null ? void 0 : shortPeriod(row.cost.period, t);
|
|
6937
|
+
return /* @__PURE__ */ jsxs9(
|
|
6938
|
+
"li",
|
|
6939
|
+
{
|
|
6940
|
+
className: "schematic-plan-manager__row",
|
|
6941
|
+
"data-testid": "schematic-usage-based",
|
|
6942
|
+
children: [
|
|
6943
|
+
/* @__PURE__ */ jsx10("span", { className: "schematic-plan-manager__item", children: row.quantity === null ? row.name : `${row.quantity.amount} ${row.quantity.units}` }),
|
|
6944
|
+
/* @__PURE__ */ jsxs9("span", { className: "schematic-plan-manager__detail", children: [
|
|
6945
|
+
details.length > 0 && /* @__PURE__ */ jsx10("span", { className: "schematic-muted schematic-small", children: details }),
|
|
6946
|
+
row.cost !== null && /* @__PURE__ */ jsxs9("span", { children: [
|
|
6947
|
+
row.cost.amount,
|
|
6948
|
+
costPeriod !== void 0 && /* @__PURE__ */ jsxs9("sub", { children: [
|
|
6949
|
+
"/",
|
|
6950
|
+
costPeriod
|
|
6951
|
+
] })
|
|
6952
|
+
] }),
|
|
6953
|
+
row.tiers !== null && row.tiers.ranges.length > 0 && /* @__PURE__ */ jsx10(Tooltip, { label: t("usageTieredPricingLabel"), children: /* @__PURE__ */ jsx10(
|
|
6954
|
+
PriceTiers,
|
|
6955
|
+
{
|
|
6956
|
+
currency: row.tiers.currency,
|
|
6957
|
+
locale,
|
|
6958
|
+
mode: row.tiers.mode,
|
|
6959
|
+
period: row.tiers.period,
|
|
6960
|
+
ranges: row.tiers.ranges,
|
|
6961
|
+
t,
|
|
6962
|
+
unit: row.tiers.unit
|
|
6963
|
+
}
|
|
6964
|
+
) }),
|
|
6965
|
+
showHardLimit && row.hardLimit !== null && /* @__PURE__ */ jsx10(Tooltip, { label: t("usageHardLimitLabel"), children: t("usageHardLimit", {
|
|
6966
|
+
amount: row.hardLimit.amount,
|
|
6967
|
+
units: row.hardLimit.units
|
|
6968
|
+
}) })
|
|
6969
|
+
] })
|
|
6970
|
+
]
|
|
6971
|
+
}
|
|
6972
|
+
);
|
|
6973
|
+
}
|
|
6974
|
+
function PlanCreditItem({ row, t }) {
|
|
6975
|
+
const text = row.text;
|
|
6976
|
+
const composition = row.composition;
|
|
6977
|
+
return /* @__PURE__ */ jsxs9(
|
|
6978
|
+
"li",
|
|
6979
|
+
{
|
|
6980
|
+
className: "schematic-plan-manager__row schematic-plan-manager__row--stacked",
|
|
6981
|
+
"data-testid": "schematic-plan-credit",
|
|
6982
|
+
children: [
|
|
6983
|
+
/* @__PURE__ */ jsxs9("div", { className: "schematic-plan-manager__row-main", children: [
|
|
6984
|
+
/* @__PURE__ */ jsx10("span", { className: "schematic-plan-manager__item", children: text.kind === "perLicense" ? /* @__PURE__ */ jsxs9(Fragment4, { children: [
|
|
6985
|
+
t("planManagerCreditsPerLicense", {
|
|
6986
|
+
amount: text.amount,
|
|
6987
|
+
creditName: text.creditName,
|
|
6988
|
+
licenseName: text.licenseName
|
|
6989
|
+
}),
|
|
6990
|
+
text.plus !== null && ` ${t("planManagerCreditsPlusPerPeriod", {
|
|
6991
|
+
amount: text.plus.amount,
|
|
6992
|
+
creditName: text.plus.creditName,
|
|
6993
|
+
period: periodWord(text.plus.period, t)
|
|
6994
|
+
})}`
|
|
6995
|
+
] }) : text.period === null ? t("planManagerCredits", {
|
|
6996
|
+
amount: text.amount,
|
|
6997
|
+
creditName: text.creditName
|
|
6998
|
+
}) : t("planManagerCreditsPerPeriod", {
|
|
6999
|
+
amount: text.amount,
|
|
7000
|
+
creditName: text.creditName,
|
|
7001
|
+
period: periodWord(text.period, t)
|
|
7002
|
+
}) }),
|
|
7003
|
+
row.used !== null && /* @__PURE__ */ jsxs9("span", { className: "schematic-muted schematic-small schematic-plan-manager__used", children: [
|
|
7004
|
+
t("planManagerUsed", { amount: row.used }),
|
|
7005
|
+
row.autoTopup !== null && /* @__PURE__ */ jsx10(Tooltip, { label: t("planManagerAutoTopup"), children: t("planManagerAutoTopupTip", {
|
|
7006
|
+
amount: row.autoTopup.amount,
|
|
7007
|
+
threshold: row.autoTopup.threshold
|
|
7008
|
+
}) })
|
|
7009
|
+
] })
|
|
7010
|
+
] }),
|
|
7011
|
+
composition !== null && /* @__PURE__ */ jsx10("span", { className: "schematic-muted schematic-small", children: t(
|
|
7012
|
+
composition.fixed === null ? "planManagerLicensesTimesCredits" : "planManagerLicensesTimesCreditsPlusCompany",
|
|
7013
|
+
{
|
|
7014
|
+
creditName: composition.creditName,
|
|
7015
|
+
fixed: composition.fixed ?? void 0,
|
|
7016
|
+
licenseName: composition.licenseName,
|
|
7017
|
+
period: shortPeriod(composition.period, t) ?? periodWord(composition.period, t),
|
|
7018
|
+
perUnit: composition.perUnit,
|
|
7019
|
+
quantity: composition.quantity,
|
|
7020
|
+
total: composition.total
|
|
7021
|
+
}
|
|
7022
|
+
) })
|
|
7023
|
+
]
|
|
7024
|
+
}
|
|
7025
|
+
);
|
|
7026
|
+
}
|
|
7027
|
+
function CreditGroupItem({
|
|
7028
|
+
countAlways = false,
|
|
7029
|
+
plain = false,
|
|
7030
|
+
row,
|
|
7031
|
+
t
|
|
7032
|
+
}) {
|
|
7033
|
+
const named = !plain && row.bundleName !== null;
|
|
7034
|
+
const showCount = !plain && row.count > 1 && (named || countAlways);
|
|
7035
|
+
const amount = `${row.quantity} ${row.creditName}`;
|
|
7036
|
+
return /* @__PURE__ */ jsxs9(
|
|
7037
|
+
"li",
|
|
7038
|
+
{
|
|
7039
|
+
className: "schematic-plan-manager__row",
|
|
7040
|
+
"data-testid": "schematic-credit-group",
|
|
7041
|
+
children: [
|
|
7042
|
+
/* @__PURE__ */ jsxs9("span", { className: "schematic-plan-manager__item", children: [
|
|
7043
|
+
showCount && /* @__PURE__ */ jsxs9("span", { className: "schematic-muted", children: [
|
|
7044
|
+
"(",
|
|
7045
|
+
row.count,
|
|
7046
|
+
") "
|
|
7047
|
+
] }),
|
|
7048
|
+
named ? `${row.bundleName} (${amount})` : amount
|
|
7049
|
+
] }),
|
|
7050
|
+
row.used !== null && /* @__PURE__ */ jsx10("span", { className: "schematic-muted schematic-small schematic-plan-manager__used", children: t("planManagerUsed", { amount: row.used }) })
|
|
7051
|
+
]
|
|
7052
|
+
}
|
|
7053
|
+
);
|
|
7054
|
+
}
|
|
7055
|
+
function AutoTopupBox({
|
|
7056
|
+
lines,
|
|
7057
|
+
onEdit,
|
|
7058
|
+
t,
|
|
7059
|
+
target,
|
|
7060
|
+
url
|
|
7061
|
+
}) {
|
|
7062
|
+
return /* @__PURE__ */ jsxs9("div", { className: "schematic-plan-manager__auto-topup", children: [
|
|
7063
|
+
/* @__PURE__ */ jsxs9("div", { className: "schematic-plan-manager__auto-topup-lines", children: [
|
|
7064
|
+
/* @__PURE__ */ jsx10("span", { className: "schematic-plan-manager__item", children: t("planManagerAutoTopup") }),
|
|
7065
|
+
lines.map((line) => /* @__PURE__ */ jsx10("span", { children: line.kind === "disabled" ? t("planManagerAutoTopupDisabled", { unit: line.unit }) : t("planManagerAutoTopupAdds", {
|
|
7066
|
+
amount: line.amount,
|
|
7067
|
+
threshold: line.threshold,
|
|
7068
|
+
unit: line.unit
|
|
7069
|
+
}) }, line.creditId))
|
|
7070
|
+
] }),
|
|
7071
|
+
/* @__PURE__ */ jsx10(
|
|
7072
|
+
Cta,
|
|
7073
|
+
{
|
|
7074
|
+
className: "schematic-cta schematic-cta--small schematic-cta--ghost schematic-plan-manager__edit",
|
|
7075
|
+
label: t("planManagerEdit"),
|
|
7076
|
+
onClick: onEdit,
|
|
7077
|
+
target,
|
|
7078
|
+
url
|
|
7079
|
+
}
|
|
7080
|
+
)
|
|
7081
|
+
] });
|
|
7082
|
+
}
|
|
7083
|
+
function Cta({
|
|
7084
|
+
className,
|
|
7085
|
+
label,
|
|
7086
|
+
onClick,
|
|
7087
|
+
target,
|
|
7088
|
+
url
|
|
7089
|
+
}) {
|
|
7090
|
+
if (onClick !== void 0) {
|
|
7091
|
+
return /* @__PURE__ */ jsx10("button", { className, type: "button", onClick, children: label });
|
|
7092
|
+
}
|
|
7093
|
+
if (url !== void 0) {
|
|
7094
|
+
return /* @__PURE__ */ jsx10("a", { className, href: url, target, children: label });
|
|
7095
|
+
}
|
|
7096
|
+
return null;
|
|
7097
|
+
}
|
|
7098
|
+
function periodWord(period, t) {
|
|
7099
|
+
const key = PERIOD_KEY[period];
|
|
7100
|
+
return key === void 0 ? period : t(key);
|
|
7101
|
+
}
|
|
7102
|
+
function PlanManagerSkeleton() {
|
|
7103
|
+
return /* @__PURE__ */ jsxs9("div", { className: "schematic-skeleton", children: [
|
|
7104
|
+
/* @__PURE__ */ jsx10("div", { className: "schematic-skeleton__heading" }),
|
|
7105
|
+
[0, 1].map((index) => /* @__PURE__ */ jsxs9("div", { className: "schematic-skeleton__row", children: [
|
|
7106
|
+
/* @__PURE__ */ jsx10("div", { className: "schematic-skeleton__cell", "data-column": "name" }),
|
|
7107
|
+
/* @__PURE__ */ jsx10("div", { className: "schematic-skeleton__cell", "data-column": "price" })
|
|
7108
|
+
] }, index))
|
|
7109
|
+
] });
|
|
7110
|
+
}
|
|
7111
|
+
PlanManager.resources = ["company", "featureUsage", "creditBalances"];
|
|
7112
|
+
|
|
7113
|
+
// src/elements/UnsubscribeButton.tsx
|
|
7114
|
+
import {
|
|
7115
|
+
useCompany as useCompany2,
|
|
7116
|
+
useFeatureUsage as useFeatureUsage4,
|
|
7117
|
+
useUnsubscribe
|
|
7118
|
+
} from "@schematichq/schematic-react";
|
|
7119
|
+
import { useMemo as useMemo8, useState as useState8 } from "react";
|
|
7120
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
7121
|
+
var TOTAL_KEY = {
|
|
7122
|
+
quarter: "unsubscribeQuarterlyTotal",
|
|
7123
|
+
year: "unsubscribeYearlyTotal"
|
|
7124
|
+
};
|
|
7125
|
+
function UnsubscribeButton({
|
|
7126
|
+
className,
|
|
7127
|
+
locale: localeProp,
|
|
7128
|
+
managePlanTarget,
|
|
7129
|
+
managePlanUrl,
|
|
7130
|
+
onManagePlan,
|
|
7131
|
+
onUnsubscribed,
|
|
7132
|
+
strings
|
|
7133
|
+
}) {
|
|
7134
|
+
const company = useCompany2();
|
|
7135
|
+
const usage = useFeatureUsage4();
|
|
7136
|
+
const { isMutating, unsubscribe } = useUnsubscribe();
|
|
7137
|
+
const locale = useResolvedLocale(localeProp);
|
|
7138
|
+
const t = useTranslator(strings, localeProp);
|
|
7139
|
+
const [open, setOpen] = useState8(false);
|
|
7140
|
+
const [failed, setFailed] = useState8(false);
|
|
7141
|
+
const view = useMemo8(
|
|
7142
|
+
() => company.data === void 0 || usage.data === void 0 ? void 0 : deriveUnsubscribe(company.data, usage.data, { locale }),
|
|
7143
|
+
[company.data, locale, usage.data]
|
|
7144
|
+
);
|
|
7145
|
+
if (view === void 0) {
|
|
7146
|
+
const error = company.error ?? usage.error;
|
|
7147
|
+
if (error === void 0) {
|
|
7148
|
+
return null;
|
|
7149
|
+
}
|
|
7150
|
+
return /* @__PURE__ */ jsx11(
|
|
7151
|
+
StatusFrame,
|
|
7152
|
+
{
|
|
7153
|
+
className: cx("schematic-card", "schematic-unsubscribe", className),
|
|
7154
|
+
error,
|
|
7155
|
+
errorMessage: httpStatus(error) === 404 ? t("unsubscribeUnavailable") : t("unsubscribeError"),
|
|
7156
|
+
hasData: false,
|
|
7157
|
+
isPending: false,
|
|
7158
|
+
loadingLabel: "",
|
|
7159
|
+
onRetry: () => {
|
|
7160
|
+
for (const handle of [company, usage]) {
|
|
7161
|
+
if (handle.error !== void 0) {
|
|
7162
|
+
handle.refetch();
|
|
7163
|
+
}
|
|
7164
|
+
}
|
|
7165
|
+
},
|
|
7166
|
+
retryText: t("retry"),
|
|
7167
|
+
children: null
|
|
7168
|
+
}
|
|
7169
|
+
);
|
|
7170
|
+
}
|
|
7171
|
+
if (!view.canUnsubscribe && !open) {
|
|
7172
|
+
return null;
|
|
7173
|
+
}
|
|
7174
|
+
const close = () => {
|
|
7175
|
+
setOpen(false);
|
|
7176
|
+
setFailed(false);
|
|
7177
|
+
};
|
|
7178
|
+
const confirm = async () => {
|
|
7179
|
+
setFailed(false);
|
|
7180
|
+
try {
|
|
7181
|
+
await unsubscribe();
|
|
7182
|
+
} catch {
|
|
7183
|
+
setFailed(true);
|
|
7184
|
+
return;
|
|
7185
|
+
}
|
|
7186
|
+
setOpen(false);
|
|
7187
|
+
onUnsubscribed?.();
|
|
7188
|
+
};
|
|
7189
|
+
const per = shortPeriod(view.period, t);
|
|
7190
|
+
return /* @__PURE__ */ jsxs10("div", { className: cx("schematic-card", "schematic-unsubscribe", className), children: [
|
|
7191
|
+
/* @__PURE__ */ jsx11(
|
|
7192
|
+
"button",
|
|
7193
|
+
{
|
|
7194
|
+
className: "schematic-cta schematic-unsubscribe__open",
|
|
7195
|
+
type: "button",
|
|
7196
|
+
onClick: () => {
|
|
7197
|
+
setFailed(false);
|
|
7198
|
+
setOpen(true);
|
|
7199
|
+
},
|
|
7200
|
+
children: t("unsubscribeButton")
|
|
7201
|
+
}
|
|
7202
|
+
),
|
|
7203
|
+
/* @__PURE__ */ jsx11(
|
|
7204
|
+
Dialog,
|
|
7205
|
+
{
|
|
7206
|
+
className: "schematic-unsubscribe__dialog",
|
|
7207
|
+
closeLabel: t("unsubscribeClose"),
|
|
7208
|
+
open,
|
|
7209
|
+
title: t("unsubscribeTitle"),
|
|
7210
|
+
onClose: close,
|
|
7211
|
+
children: /* @__PURE__ */ jsxs10("div", { className: "schematic-unsubscribe__columns", children: [
|
|
7212
|
+
/* @__PURE__ */ jsxs10("div", { className: "schematic-unsubscribe__summary", children: [
|
|
7213
|
+
/* @__PURE__ */ jsx11("p", { children: t("unsubscribeAccessUntil", { date: view.accessEndsOn }) }),
|
|
7214
|
+
/* @__PURE__ */ jsx11(
|
|
7215
|
+
ManagePlan,
|
|
7216
|
+
{
|
|
7217
|
+
onClick: onManagePlan,
|
|
7218
|
+
t,
|
|
7219
|
+
target: managePlanTarget,
|
|
7220
|
+
url: managePlanUrl
|
|
7221
|
+
}
|
|
7222
|
+
)
|
|
7223
|
+
] }),
|
|
7224
|
+
/* @__PURE__ */ jsxs10("div", { className: "schematic-unsubscribe__sidebar", children: [
|
|
7225
|
+
view.plan !== null && /* @__PURE__ */ jsxs10("div", { className: "schematic-unsubscribe__group", children: [
|
|
7226
|
+
/* @__PURE__ */ jsx11("span", { className: "schematic-muted schematic-small", children: t("unsubscribePlan") }),
|
|
7227
|
+
/* @__PURE__ */ jsxs10("div", { className: "schematic-unsubscribe__line", children: [
|
|
7228
|
+
/* @__PURE__ */ jsx11("span", { className: "schematic-unsubscribe__name", children: view.plan.name }),
|
|
7229
|
+
view.plan.price !== null && /* @__PURE__ */ jsxs10("span", { children: [
|
|
7230
|
+
view.plan.price,
|
|
7231
|
+
per !== void 0 && /* @__PURE__ */ jsxs10("sub", { children: [
|
|
7232
|
+
"/",
|
|
7233
|
+
per
|
|
7234
|
+
] })
|
|
7235
|
+
] })
|
|
7236
|
+
] })
|
|
7237
|
+
] }),
|
|
7238
|
+
view.addOns.length > 0 && /* @__PURE__ */ jsxs10("div", { className: "schematic-unsubscribe__group", children: [
|
|
7239
|
+
/* @__PURE__ */ jsx11("span", { className: "schematic-muted schematic-small", children: t("unsubscribeAddOns") }),
|
|
7240
|
+
view.addOns.map((addOn) => /* @__PURE__ */ jsxs10("div", { className: "schematic-unsubscribe__line", children: [
|
|
7241
|
+
/* @__PURE__ */ jsx11("span", { className: "schematic-unsubscribe__name", children: addOn.name }),
|
|
7242
|
+
/* @__PURE__ */ jsxs10("span", { children: [
|
|
7243
|
+
addOn.price,
|
|
7244
|
+
!addOn.oneTime && per !== void 0 && /* @__PURE__ */ jsxs10("sub", { children: [
|
|
7245
|
+
"/",
|
|
7246
|
+
per
|
|
7247
|
+
] })
|
|
7248
|
+
] })
|
|
7249
|
+
] }, addOn.id))
|
|
7250
|
+
] }),
|
|
7251
|
+
/* @__PURE__ */ jsxs10("div", { className: "schematic-unsubscribe__line schematic-unsubscribe__total", children: [
|
|
7252
|
+
/* @__PURE__ */ jsx11("span", { className: "schematic-muted", children: t(TOTAL_KEY[view.period] ?? "unsubscribeMonthlyTotal") }),
|
|
7253
|
+
/* @__PURE__ */ jsxs10("span", { children: [
|
|
7254
|
+
view.total,
|
|
7255
|
+
per !== void 0 && /* @__PURE__ */ jsxs10("sub", { children: [
|
|
7256
|
+
"/",
|
|
7257
|
+
per
|
|
7258
|
+
] })
|
|
7259
|
+
] })
|
|
7260
|
+
] }),
|
|
7261
|
+
/* @__PURE__ */ jsx11(
|
|
7262
|
+
"button",
|
|
7263
|
+
{
|
|
7264
|
+
className: "schematic-cta schematic-unsubscribe__confirm",
|
|
7265
|
+
disabled: isMutating,
|
|
7266
|
+
type: "button",
|
|
7267
|
+
onClick: () => void confirm(),
|
|
7268
|
+
children: t("unsubscribeConfirm")
|
|
7269
|
+
}
|
|
7270
|
+
),
|
|
7271
|
+
failed && /* @__PURE__ */ jsx11("p", { className: "schematic-error", role: "alert", children: t("unsubscribeFailed") })
|
|
7272
|
+
] })
|
|
7273
|
+
] })
|
|
7274
|
+
}
|
|
7275
|
+
)
|
|
7276
|
+
] });
|
|
7277
|
+
}
|
|
7278
|
+
function ManagePlan({
|
|
7279
|
+
onClick,
|
|
7280
|
+
t,
|
|
7281
|
+
target,
|
|
7282
|
+
url
|
|
7283
|
+
}) {
|
|
7284
|
+
if (onClick === void 0 && url === void 0) {
|
|
7285
|
+
return null;
|
|
7286
|
+
}
|
|
7287
|
+
const label = t("unsubscribeManagePlan");
|
|
7288
|
+
return /* @__PURE__ */ jsxs10("div", { className: "schematic-unsubscribe__manage", children: [
|
|
7289
|
+
/* @__PURE__ */ jsx11("p", { children: t("unsubscribeNotReady") }),
|
|
7290
|
+
onClick !== void 0 ? /* @__PURE__ */ jsx11(
|
|
7291
|
+
"button",
|
|
7292
|
+
{
|
|
7293
|
+
className: "schematic-cta schematic-cta--small schematic-cta--ghost schematic-unsubscribe__manage-plan",
|
|
7294
|
+
type: "button",
|
|
7295
|
+
onClick,
|
|
7296
|
+
children: label
|
|
7297
|
+
}
|
|
7298
|
+
) : /* @__PURE__ */ jsx11(
|
|
7299
|
+
"a",
|
|
7300
|
+
{
|
|
7301
|
+
className: "schematic-cta schematic-cta--small schematic-cta--ghost schematic-unsubscribe__manage-plan",
|
|
7302
|
+
href: url,
|
|
7303
|
+
target,
|
|
7304
|
+
children: label
|
|
7305
|
+
}
|
|
7306
|
+
)
|
|
7307
|
+
] });
|
|
7308
|
+
}
|
|
7309
|
+
UnsubscribeButton.resources = ["company", "featureUsage"];
|
|
7310
|
+
|
|
5225
7311
|
// src/elements/UpcomingBill.tsx
|
|
5226
7312
|
import { useUpcomingInvoice } from "@schematichq/schematic-react";
|
|
5227
|
-
import { useMemo as
|
|
5228
|
-
import { Fragment as
|
|
7313
|
+
import { useMemo as useMemo9 } from "react";
|
|
7314
|
+
import { Fragment as Fragment5, jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
5229
7315
|
function UpcomingBill({
|
|
5230
7316
|
className,
|
|
5231
7317
|
headingLevel = 2,
|
|
@@ -5239,7 +7325,7 @@ function UpcomingBill({
|
|
|
5239
7325
|
const { data: invoice, error, isPending, refetch } = useUpcomingInvoice();
|
|
5240
7326
|
const locale = useResolvedLocale(localeProp);
|
|
5241
7327
|
const t = useTranslator(strings, localeProp);
|
|
5242
|
-
const bill =
|
|
7328
|
+
const bill = useMemo9(
|
|
5243
7329
|
() => invoice === void 0 || invoice === null ? null : deriveUpcomingInvoice(invoice, { locale }),
|
|
5244
7330
|
[invoice, locale]
|
|
5245
7331
|
);
|
|
@@ -5248,7 +7334,7 @@ function UpcomingBill({
|
|
|
5248
7334
|
const discountRow = showDiscounts && bill !== null && bill.discounts.length > 0;
|
|
5249
7335
|
const unavailable = invoice === void 0 && httpStatus(error) === 404;
|
|
5250
7336
|
const errorMessage = error === void 0 ? void 0 : unavailable ? t("upcomingBillUnavailable") : t("upcomingBillError");
|
|
5251
|
-
return /* @__PURE__ */
|
|
7337
|
+
return /* @__PURE__ */ jsx12(
|
|
5252
7338
|
StatusFrame,
|
|
5253
7339
|
{
|
|
5254
7340
|
className: cx("schematic-card", "schematic-upcoming-bill", className),
|
|
@@ -5259,11 +7345,11 @@ function UpcomingBill({
|
|
|
5259
7345
|
loadingLabel: t("upcomingBillLoading"),
|
|
5260
7346
|
onRetry: refetch,
|
|
5261
7347
|
retryText: t("retry"),
|
|
5262
|
-
skeleton: /* @__PURE__ */
|
|
5263
|
-
children: bill === null ? invoice !== void 0 && /* @__PURE__ */
|
|
5264
|
-
showHeader && bill.dueAt !== null && /* @__PURE__ */
|
|
5265
|
-
showAmount && /* @__PURE__ */
|
|
5266
|
-
/* @__PURE__ */
|
|
7348
|
+
skeleton: /* @__PURE__ */ jsx12(UpcomingBillSkeleton, { showHeader }),
|
|
7349
|
+
children: bill === null ? invoice !== void 0 && /* @__PURE__ */ jsx12("p", { className: "schematic-muted schematic-upcoming-bill__empty", children: t("upcomingBillEmpty") }) : /* @__PURE__ */ jsxs11(Fragment5, { children: [
|
|
7350
|
+
showHeader && bill.dueAt !== null && /* @__PURE__ */ jsx12("div", { className: "schematic-header", children: /* @__PURE__ */ jsx12(Heading, { className: "schematic-header__title", children: t("upcomingBillHeader", { date: bill.dueAt.text }) }) }),
|
|
7351
|
+
showAmount && /* @__PURE__ */ jsxs11("div", { className: "schematic-upcoming-bill__amount", children: [
|
|
7352
|
+
/* @__PURE__ */ jsx12(
|
|
5267
7353
|
"span",
|
|
5268
7354
|
{
|
|
5269
7355
|
className: "schematic-upcoming-bill__total",
|
|
@@ -5271,46 +7357,46 @@ function UpcomingBill({
|
|
|
5271
7357
|
children: bill.amountDueText
|
|
5272
7358
|
}
|
|
5273
7359
|
),
|
|
5274
|
-
/* @__PURE__ */
|
|
7360
|
+
/* @__PURE__ */ jsx12("span", { className: "schematic-small schematic-upcoming-bill__estimate", children: t("upcomingBillEstimate") })
|
|
5275
7361
|
] }),
|
|
5276
|
-
(balanceRows || discountRow) && /* @__PURE__ */
|
|
5277
|
-
balanceRows && bill.balanceApplied !== null && /* @__PURE__ */
|
|
7362
|
+
(balanceRows || discountRow) && /* @__PURE__ */ jsxs11("div", { className: "schematic-upcoming-bill__rows", children: [
|
|
7363
|
+
balanceRows && bill.balanceApplied !== null && /* @__PURE__ */ jsxs11(
|
|
5278
7364
|
"div",
|
|
5279
7365
|
{
|
|
5280
7366
|
className: "schematic-row schematic-upcoming-bill__balance-applied",
|
|
5281
7367
|
"data-testid": "schematic-balance-applied",
|
|
5282
7368
|
children: [
|
|
5283
|
-
/* @__PURE__ */
|
|
5284
|
-
/* @__PURE__ */
|
|
7369
|
+
/* @__PURE__ */ jsx12("span", { className: "schematic-row__label", children: t("upcomingBillBalanceApplied") }),
|
|
7370
|
+
/* @__PURE__ */ jsx12("span", { className: "schematic-row__value", children: bill.balanceApplied.amountText })
|
|
5285
7371
|
]
|
|
5286
7372
|
}
|
|
5287
7373
|
),
|
|
5288
|
-
balanceRows && bill.balanceRemaining !== null && /* @__PURE__ */
|
|
7374
|
+
balanceRows && bill.balanceRemaining !== null && /* @__PURE__ */ jsxs11(
|
|
5289
7375
|
"div",
|
|
5290
7376
|
{
|
|
5291
7377
|
className: "schematic-row schematic-upcoming-bill__balance-remaining",
|
|
5292
7378
|
"data-testid": "schematic-balance-remaining",
|
|
5293
7379
|
children: [
|
|
5294
|
-
/* @__PURE__ */
|
|
5295
|
-
/* @__PURE__ */
|
|
7380
|
+
/* @__PURE__ */ jsx12("span", { className: "schematic-row__label", children: t("upcomingBillBalanceRemaining") }),
|
|
7381
|
+
/* @__PURE__ */ jsx12("span", { className: "schematic-row__value", children: bill.balanceRemaining.amountText })
|
|
5296
7382
|
]
|
|
5297
7383
|
}
|
|
5298
7384
|
),
|
|
5299
|
-
discountRow && /* @__PURE__ */
|
|
7385
|
+
discountRow && /* @__PURE__ */ jsxs11(
|
|
5300
7386
|
"div",
|
|
5301
7387
|
{
|
|
5302
7388
|
className: "schematic-row schematic-upcoming-bill__discount-row",
|
|
5303
7389
|
"data-testid": "schematic-discounts",
|
|
5304
7390
|
children: [
|
|
5305
|
-
/* @__PURE__ */
|
|
5306
|
-
/* @__PURE__ */
|
|
7391
|
+
/* @__PURE__ */ jsx12("span", { className: "schematic-row__label", children: t("upcomingBillDiscount") }),
|
|
7392
|
+
/* @__PURE__ */ jsx12("ul", { className: "schematic-row__value schematic-upcoming-bill__discounts", children: bill.discounts.map((discount, index) => /* @__PURE__ */ jsxs11(
|
|
5307
7393
|
"li",
|
|
5308
7394
|
{
|
|
5309
7395
|
className: "schematic-upcoming-bill__discount",
|
|
5310
7396
|
"data-testid": "schematic-discount",
|
|
5311
7397
|
children: [
|
|
5312
|
-
discount.code !== null && /* @__PURE__ */
|
|
5313
|
-
/* @__PURE__ */
|
|
7398
|
+
discount.code !== null && /* @__PURE__ */ jsx12("span", { className: "schematic-chip schematic-upcoming-bill__code", children: discount.code }),
|
|
7399
|
+
/* @__PURE__ */ jsx12("span", { className: "schematic-upcoming-bill__discount-value", children: discountText(discount, t) })
|
|
5314
7400
|
]
|
|
5315
7401
|
},
|
|
5316
7402
|
`${discount.couponName}-${index}`
|
|
@@ -5324,10 +7410,10 @@ function UpcomingBill({
|
|
|
5324
7410
|
);
|
|
5325
7411
|
}
|
|
5326
7412
|
function UpcomingBillSkeleton({ showHeader }) {
|
|
5327
|
-
return /* @__PURE__ */
|
|
5328
|
-
showHeader && /* @__PURE__ */
|
|
5329
|
-
/* @__PURE__ */
|
|
5330
|
-
/* @__PURE__ */
|
|
7413
|
+
return /* @__PURE__ */ jsxs11("div", { className: "schematic-skeleton", children: [
|
|
7414
|
+
showHeader && /* @__PURE__ */ jsx12("div", { className: "schematic-skeleton__heading" }),
|
|
7415
|
+
/* @__PURE__ */ jsx12("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ jsx12("div", { className: "schematic-skeleton__cell", "data-column": "amount" }) }),
|
|
7416
|
+
/* @__PURE__ */ jsx12("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ jsx12("div", { className: "schematic-skeleton__cell", "data-column": "row" }) })
|
|
5331
7417
|
] });
|
|
5332
7418
|
}
|
|
5333
7419
|
function discountText(discount, t) {
|
|
@@ -5342,23 +7428,29 @@ function discountText(discount, t) {
|
|
|
5342
7428
|
UpcomingBill.resources = ["upcomingInvoice"];
|
|
5343
7429
|
export {
|
|
5344
7430
|
BillingDataProvider,
|
|
7431
|
+
CreditUsage,
|
|
5345
7432
|
DEFAULT_STRINGS,
|
|
5346
7433
|
FEATURE_USER_USAGE_LIMIT,
|
|
5347
7434
|
IncludedFeatures,
|
|
5348
7435
|
Invoices,
|
|
5349
7436
|
MeteredFeatures,
|
|
5350
7437
|
PaymentMethods,
|
|
7438
|
+
PlanManager,
|
|
5351
7439
|
SCHEMATIC_TOKENS,
|
|
5352
7440
|
SchematicI18nProvider,
|
|
5353
7441
|
SchematicStyles,
|
|
5354
7442
|
Tooltip,
|
|
7443
|
+
UnsubscribeButton,
|
|
5355
7444
|
UpcomingBill,
|
|
5356
7445
|
billingResources,
|
|
5357
7446
|
currentTier,
|
|
7447
|
+
deriveCreditUsage,
|
|
5358
7448
|
deriveIncludedFeatures,
|
|
5359
7449
|
deriveInvoiceList,
|
|
5360
7450
|
deriveMeteredFeatures,
|
|
5361
7451
|
derivePaymentMethods,
|
|
7452
|
+
derivePlanManager,
|
|
7453
|
+
deriveUnsubscribe,
|
|
5362
7454
|
deriveUpcomingInvoice,
|
|
5363
7455
|
featureName,
|
|
5364
7456
|
formatConsumptionRate,
|
|
@@ -5381,7 +7473,10 @@ export {
|
|
|
5381
7473
|
tierRanges,
|
|
5382
7474
|
unitPrice,
|
|
5383
7475
|
usageLimit,
|
|
5384
|
-
|
|
7476
|
+
useCompany3 as useCompany,
|
|
7477
|
+
useCreditBalances3 as useCreditBalances,
|
|
7478
|
+
useCreditUserUsage2 as useCreditUserUsage,
|
|
7479
|
+
useFeatureUsage5 as useFeatureUsage,
|
|
5385
7480
|
useFeatureUserUsage2 as useFeatureUserUsage,
|
|
5386
7481
|
useInvalidateBillingData,
|
|
5387
7482
|
useInvoices2 as useInvoices,
|
|
@@ -5393,6 +7488,7 @@ export {
|
|
|
5393
7488
|
useSchematicTranslate,
|
|
5394
7489
|
useSetupIntent2 as useSetupIntent,
|
|
5395
7490
|
useTranslator,
|
|
7491
|
+
useUnsubscribe2 as useUnsubscribe,
|
|
5396
7492
|
useUpcomingInvoice2 as useUpcomingInvoice,
|
|
5397
7493
|
viewerLocale
|
|
5398
7494
|
};
|