@schematichq/schematic-components 2.33.0 → 2.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/schematic-components-elements.cjs.js +1682 -210
- package/dist/schematic-components-elements.d.ts +431 -1
- package/dist/schematic-components-elements.esm.js +1677 -195
- package/dist/schematic-components.browser.cjs.js +713 -187
- package/dist/schematic-components.browser.esm.js +713 -187
- package/dist/schematic-components.cjs.js +713 -187
- package/dist/schematic-components.d.ts +155 -4
- package/dist/schematic-components.esm.js +713 -187
- package/package.json +8 -8
|
@@ -53,7 +53,6 @@ var init_tokens = __esm({
|
|
|
53
53
|
SCHEMATIC_TOKENS = {
|
|
54
54
|
"--schematic-accent": ld("#194bfb", "#6f92ff"),
|
|
55
55
|
"--schematic-accent-contrast": ld("#ffffff", "#0a0a0a"),
|
|
56
|
-
// Tints the dialog's backdrop, which also blurs the page behind it.
|
|
57
56
|
"--schematic-backdrop": ld(
|
|
58
57
|
"hsla(0, 0%, 87.5%, 0.9)",
|
|
59
58
|
"hsla(0, 0%, 12.5%, 0.9)"
|
|
@@ -67,16 +66,11 @@ var init_tokens = __esm({
|
|
|
67
66
|
"hsla(0, 0%, 0%, 0.175)",
|
|
68
67
|
"hsla(0, 0%, 100%, 0.2)"
|
|
69
68
|
),
|
|
70
|
-
// 45px from a 750px viewport up; narrower screens give the content the
|
|
71
|
-
// room instead (about 22px on a 375px phone).
|
|
72
69
|
"--schematic-card-padding": "min(2.8125rem, 6vw)",
|
|
73
70
|
"--schematic-danger": ld("#d75a5c", "#ff6b6e"),
|
|
74
71
|
"--schematic-font-body": '"Public Sans", system-ui, sans-serif',
|
|
75
72
|
"--schematic-font-heading": '"Manrope", system-ui, sans-serif',
|
|
76
|
-
// Link buttons' face: Edit, Set default, Try again, and the rest.
|
|
77
73
|
"--schematic-font-link": '"Inter", system-ui, sans-serif',
|
|
78
|
-
// A lighter tint than the surface, for panels set into a card: a credit's
|
|
79
|
-
// grants, a plan's auto top-up.
|
|
80
74
|
"--schematic-inset": ld("hsla(0, 0%, 0%, 0.04)", "hsla(0, 0%, 100%, 0.06)"),
|
|
81
75
|
"--schematic-line-height": "1.375",
|
|
82
76
|
"--schematic-line-height-heading": "1.2",
|
|
@@ -85,10 +79,8 @@ var init_tokens = __esm({
|
|
|
85
79
|
"--schematic-primary": ld("#000000", "#ffffff"),
|
|
86
80
|
"--schematic-primary-contrast": ld("#ffffff", "#000000"),
|
|
87
81
|
"--schematic-radius": "0.625rem",
|
|
88
|
-
// `light-dark()` takes colours only, so it is applied per shadow layer.
|
|
89
82
|
"--schematic-shadow": `0px 1px 20px 0px ${ld("#1018280f", "#00000099")}, 0px 1px 3px 0px ${ld("#1018281a", "#0000007a")}`,
|
|
90
83
|
"--schematic-space": "1rem",
|
|
91
|
-
// A tint over the background: the payment method pill.
|
|
92
84
|
"--schematic-surface": ld(
|
|
93
85
|
"hsla(0, 0%, 0%, 0.0625)",
|
|
94
86
|
"hsla(0, 0%, 100%, 0.125)"
|
|
@@ -479,18 +471,20 @@ var init_PaymentMethodForm = __esm({
|
|
|
479
471
|
// src/elements/index.ts
|
|
480
472
|
var index_exports = {};
|
|
481
473
|
__export(index_exports, {
|
|
482
|
-
BillingDataProvider: () =>
|
|
474
|
+
BillingDataProvider: () => import_schematic_react11.BillingDataProvider,
|
|
483
475
|
CreditUsage: () => CreditUsage,
|
|
484
476
|
DEFAULT_STRINGS: () => DEFAULT_STRINGS,
|
|
485
|
-
FEATURE_USER_USAGE_LIMIT: () =>
|
|
477
|
+
FEATURE_USER_USAGE_LIMIT: () => import_schematic_react11.FEATURE_USER_USAGE_LIMIT,
|
|
486
478
|
IncludedFeatures: () => IncludedFeatures,
|
|
487
479
|
Invoices: () => Invoices,
|
|
488
480
|
MeteredFeatures: () => MeteredFeatures,
|
|
489
481
|
PaymentMethods: () => PaymentMethods,
|
|
482
|
+
PlanManager: () => PlanManager,
|
|
490
483
|
SCHEMATIC_TOKENS: () => SCHEMATIC_TOKENS,
|
|
491
|
-
SchematicI18nProvider: () =>
|
|
484
|
+
SchematicI18nProvider: () => import_schematic_react11.SchematicI18nProvider,
|
|
492
485
|
SchematicStyles: () => SchematicStyles,
|
|
493
486
|
Tooltip: () => Tooltip,
|
|
487
|
+
UnsubscribeButton: () => UnsubscribeButton,
|
|
494
488
|
UpcomingBill: () => UpcomingBill,
|
|
495
489
|
billingResources: () => billingResources,
|
|
496
490
|
currentTier: () => currentTier,
|
|
@@ -499,6 +493,8 @@ __export(index_exports, {
|
|
|
499
493
|
deriveInvoiceList: () => deriveInvoiceList,
|
|
500
494
|
deriveMeteredFeatures: () => deriveMeteredFeatures,
|
|
501
495
|
derivePaymentMethods: () => derivePaymentMethods,
|
|
496
|
+
derivePlanManager: () => derivePlanManager,
|
|
497
|
+
deriveUnsubscribe: () => deriveUnsubscribe,
|
|
502
498
|
deriveUpcomingInvoice: () => deriveUpcomingInvoice,
|
|
503
499
|
featureName: () => featureName,
|
|
504
500
|
formatConsumptionRate: () => formatConsumptionRate,
|
|
@@ -521,25 +517,27 @@ __export(index_exports, {
|
|
|
521
517
|
tierRanges: () => tierRanges,
|
|
522
518
|
unitPrice: () => unitPrice,
|
|
523
519
|
usageLimit: () => usageLimit,
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
520
|
+
useCompany: () => import_schematic_react11.useCompany,
|
|
521
|
+
useCreditBalances: () => import_schematic_react11.useCreditBalances,
|
|
522
|
+
useCreditUserUsage: () => import_schematic_react11.useCreditUserUsage,
|
|
523
|
+
useFeatureUsage: () => import_schematic_react11.useFeatureUsage,
|
|
524
|
+
useFeatureUserUsage: () => import_schematic_react11.useFeatureUserUsage,
|
|
525
|
+
useInvalidateBillingData: () => import_schematic_react11.useInvalidateBillingData,
|
|
526
|
+
useInvoices: () => import_schematic_react11.useInvoices,
|
|
527
|
+
usePaymentMethods: () => import_schematic_react11.usePaymentMethods,
|
|
531
528
|
useResolvedLocale: () => useResolvedLocale,
|
|
532
|
-
useSchematicI18n: () =>
|
|
533
|
-
useSchematicLocale: () =>
|
|
534
|
-
useSchematicStrings: () =>
|
|
535
|
-
useSchematicTranslate: () =>
|
|
536
|
-
useSetupIntent: () =>
|
|
529
|
+
useSchematicI18n: () => import_schematic_react11.useSchematicI18n,
|
|
530
|
+
useSchematicLocale: () => import_schematic_react11.useSchematicLocale,
|
|
531
|
+
useSchematicStrings: () => import_schematic_react11.useSchematicStrings,
|
|
532
|
+
useSchematicTranslate: () => import_schematic_react11.useSchematicTranslate,
|
|
533
|
+
useSetupIntent: () => import_schematic_react11.useSetupIntent,
|
|
537
534
|
useTranslator: () => useTranslator,
|
|
538
|
-
|
|
535
|
+
useUnsubscribe: () => import_schematic_react11.useUnsubscribe,
|
|
536
|
+
useUpcomingInvoice: () => import_schematic_react11.useUpcomingInvoice,
|
|
539
537
|
viewerLocale: () => viewerLocale
|
|
540
538
|
});
|
|
541
539
|
module.exports = __toCommonJS(index_exports);
|
|
542
|
-
var
|
|
540
|
+
var import_schematic_react11 = require("@schematichq/schematic-react");
|
|
543
541
|
|
|
544
542
|
// src/elements/model/errors.ts
|
|
545
543
|
function httpStatus(error) {
|
|
@@ -1848,6 +1846,416 @@ function isEnglish2(locale) {
|
|
|
1848
1846
|
}
|
|
1849
1847
|
}
|
|
1850
1848
|
|
|
1849
|
+
// src/elements/model/planManager.ts
|
|
1850
|
+
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
1851
|
+
var HOUR_MS = 60 * 60 * 1e3;
|
|
1852
|
+
var MINUTE_MS = 60 * 1e3;
|
|
1853
|
+
function derivePlanManager(data, options) {
|
|
1854
|
+
const { company, creditBalances, featureUsage } = data;
|
|
1855
|
+
const { locale } = options;
|
|
1856
|
+
const subscription = company.subscription ?? null;
|
|
1857
|
+
const currency = subscription?.currency ?? "usd";
|
|
1858
|
+
const planPeriod = subscription?.period ?? company.plan?.period ?? null;
|
|
1859
|
+
const usageBasedSources = featureUsage.filter(
|
|
1860
|
+
(row) => typeof row.priceBehavior === "string"
|
|
1861
|
+
);
|
|
1862
|
+
return {
|
|
1863
|
+
notice: notice(company, options),
|
|
1864
|
+
plan: company.plan === void 0 || company.plan === null ? null : {
|
|
1865
|
+
name: company.plan.name,
|
|
1866
|
+
description: orNull3(company.plan.description),
|
|
1867
|
+
price: planPrice(
|
|
1868
|
+
company.plan.price,
|
|
1869
|
+
planPeriod,
|
|
1870
|
+
currency,
|
|
1871
|
+
usageBasedSources.length > 0,
|
|
1872
|
+
options
|
|
1873
|
+
)
|
|
1874
|
+
},
|
|
1875
|
+
addOns: company.addOns.map((addOn) => {
|
|
1876
|
+
const period = addOn.period === "one-time" ? "one-time" : planPeriod ?? addOn.period ?? null;
|
|
1877
|
+
return {
|
|
1878
|
+
id: addOn.id,
|
|
1879
|
+
name: addOn.name,
|
|
1880
|
+
price: typeof addOn.price === "number" && period !== null ? {
|
|
1881
|
+
amount: formatCurrency(addOn.price, currency, locale),
|
|
1882
|
+
period
|
|
1883
|
+
} : null
|
|
1884
|
+
};
|
|
1885
|
+
}),
|
|
1886
|
+
usageBased: usageBasedSources.flatMap((row) => {
|
|
1887
|
+
const derived = usageBasedRow(row, planPeriod ?? "month", options);
|
|
1888
|
+
return derived === null ? [] : [derived];
|
|
1889
|
+
}),
|
|
1890
|
+
planCredits: planCredits(company, creditBalances, locale),
|
|
1891
|
+
autoTopup: autoTopupBox(company, creditBalances, locale),
|
|
1892
|
+
...creditGroups(creditBalances, locale),
|
|
1893
|
+
canChangePlan: company.customPlanBilling?.activationStrategy !== "on_payment"
|
|
1894
|
+
};
|
|
1895
|
+
}
|
|
1896
|
+
function notice(company, options) {
|
|
1897
|
+
const { locale } = options;
|
|
1898
|
+
const subscription = company.subscription ?? null;
|
|
1899
|
+
const cancelAt = usableDate(subscription?.cancelAt);
|
|
1900
|
+
const willCancel = cancelAt !== void 0 && subscription?.cancelAtPeriodEnd === true;
|
|
1901
|
+
if (subscription?.status === "trialing" && !willCancel) {
|
|
1902
|
+
const trialEnd = usableDate(subscription.trialEnd);
|
|
1903
|
+
return {
|
|
1904
|
+
kind: "trial",
|
|
1905
|
+
endsIn: trialEnd === void 0 ? null : countdown(
|
|
1906
|
+
trialEnd.getTime() - (options.now ?? /* @__PURE__ */ new Date()).getTime()
|
|
1907
|
+
)
|
|
1908
|
+
};
|
|
1909
|
+
}
|
|
1910
|
+
if (willCancel) {
|
|
1911
|
+
return {
|
|
1912
|
+
kind: "canceled",
|
|
1913
|
+
planName: orNull3(company.plan?.name),
|
|
1914
|
+
date: formatDate(cancelAt, locale)
|
|
1915
|
+
};
|
|
1916
|
+
}
|
|
1917
|
+
const billing = company.customPlanBilling;
|
|
1918
|
+
if (billing !== void 0 && billing !== null) {
|
|
1919
|
+
return {
|
|
1920
|
+
kind: "customPlanBilling",
|
|
1921
|
+
awaitingActivation: billing.activationStrategy === "on_payment",
|
|
1922
|
+
planName: orNull3(billing.planName),
|
|
1923
|
+
date: formatDate(billing.dueAt, locale),
|
|
1924
|
+
invoiceUrl: orNull3(billing.invoiceUrl)
|
|
1925
|
+
};
|
|
1926
|
+
}
|
|
1927
|
+
const downgrade = company.scheduledDowngrade;
|
|
1928
|
+
if (downgrade !== void 0 && downgrade !== null && downgrade.toPlanName !== "") {
|
|
1929
|
+
const periodEnd = usableDate(subscription?.periodEnd);
|
|
1930
|
+
return {
|
|
1931
|
+
kind: "scheduledDowngrade",
|
|
1932
|
+
fromPlanName: downgrade.fromPlanName,
|
|
1933
|
+
toPlanName: downgrade.toPlanName,
|
|
1934
|
+
date: periodEnd === void 0 ? null : formatDate(periodEnd, locale)
|
|
1935
|
+
};
|
|
1936
|
+
}
|
|
1937
|
+
return null;
|
|
1938
|
+
}
|
|
1939
|
+
function countdown(ms) {
|
|
1940
|
+
if (ms >= DAY_MS) {
|
|
1941
|
+
return { amount: Math.floor(ms / DAY_MS), unit: "day" };
|
|
1942
|
+
}
|
|
1943
|
+
if (ms >= HOUR_MS) {
|
|
1944
|
+
return { amount: Math.floor(ms / HOUR_MS), unit: "hour" };
|
|
1945
|
+
}
|
|
1946
|
+
if (ms >= MINUTE_MS) {
|
|
1947
|
+
return { amount: Math.floor(ms / MINUTE_MS), unit: "minute" };
|
|
1948
|
+
}
|
|
1949
|
+
return ms > 0 ? "soon" : "ended";
|
|
1950
|
+
}
|
|
1951
|
+
function planPrice(price, period, currency, hasUsageBased, options) {
|
|
1952
|
+
if (typeof price !== "number") {
|
|
1953
|
+
return null;
|
|
1954
|
+
}
|
|
1955
|
+
const isFree = price === 0;
|
|
1956
|
+
if (isFree && hasUsageBased) {
|
|
1957
|
+
return { kind: "usageBased" };
|
|
1958
|
+
}
|
|
1959
|
+
if (isFree && options.showZeroPriceAsFree === true) {
|
|
1960
|
+
return { kind: "free" };
|
|
1961
|
+
}
|
|
1962
|
+
return {
|
|
1963
|
+
kind: "amount",
|
|
1964
|
+
amount: formatCurrency(price, currency, options.locale),
|
|
1965
|
+
period: isFree ? null : period
|
|
1966
|
+
};
|
|
1967
|
+
}
|
|
1968
|
+
function usageBasedRow(row, period, options) {
|
|
1969
|
+
const { locale } = options;
|
|
1970
|
+
const behavior = row.priceBehavior ?? null;
|
|
1971
|
+
const showCredits = options.showCredits ?? true;
|
|
1972
|
+
if (behavior === "credit_burndown" && !showCredits || row.featureName === "") {
|
|
1973
|
+
return null;
|
|
1974
|
+
}
|
|
1975
|
+
const unit = {
|
|
1976
|
+
name: row.featureName,
|
|
1977
|
+
singularName: row.featureSingularName ?? void 0,
|
|
1978
|
+
pluralName: row.featurePluralName ?? void 0
|
|
1979
|
+
};
|
|
1980
|
+
const isTrait = row.featureType === "trait";
|
|
1981
|
+
const price = row.price ?? void 0;
|
|
1982
|
+
const priceCurrency = price?.currency ?? "usd";
|
|
1983
|
+
const limit = behavior === "credit_burndown" ? null : usageLimit(row, options);
|
|
1984
|
+
let unitPriceText = null;
|
|
1985
|
+
if ((behavior === "pay_as_you_go" || behavior === "overage") && price !== void 0) {
|
|
1986
|
+
const packageSize = price.packageSize ?? 1;
|
|
1987
|
+
const ranges = behavior === "overage" ? tierRanges(price) : [];
|
|
1988
|
+
const lastTier = ranges[ranges.length - 1];
|
|
1989
|
+
const amount = lastTier === void 0 ? unitPrice(price) : lastTier.perUnitPrice ?? price.price;
|
|
1990
|
+
unitPriceText = {
|
|
1991
|
+
cost: formatCurrency(amount, priceCurrency, locale),
|
|
1992
|
+
packageSize: packageSize > 1 ? formatNumber(packageSize, locale) : null,
|
|
1993
|
+
units: featureName(unit, packageSize, locale),
|
|
1994
|
+
period: isTrait ? period : null
|
|
1995
|
+
};
|
|
1996
|
+
}
|
|
1997
|
+
let perUse = null;
|
|
1998
|
+
if (behavior === "credit_burndown" && typeof row.consumptionRate === "number" && row.consumptionRate !== 0 && typeof row.creditName === "string") {
|
|
1999
|
+
perUse = {
|
|
2000
|
+
amount: formatConsumptionRate(row.consumptionRate, locale),
|
|
2001
|
+
units: featureName(
|
|
2002
|
+
{
|
|
2003
|
+
name: row.creditName,
|
|
2004
|
+
singularName: row.creditSingularName,
|
|
2005
|
+
pluralName: row.creditPluralName
|
|
2006
|
+
},
|
|
2007
|
+
row.consumptionRate,
|
|
2008
|
+
locale
|
|
2009
|
+
)
|
|
2010
|
+
};
|
|
2011
|
+
}
|
|
2012
|
+
return {
|
|
2013
|
+
featureId: row.featureId,
|
|
2014
|
+
name: row.featureName,
|
|
2015
|
+
// The bare name, inflected, as the embed counts a limit.
|
|
2016
|
+
quantity: limit === null ? null : {
|
|
2017
|
+
amount: formatNumber(limit, locale),
|
|
2018
|
+
units: featureName({ name: row.featureName }, limit, locale)
|
|
2019
|
+
},
|
|
2020
|
+
additional: behavior === "overage",
|
|
2021
|
+
tierBased: behavior === "tier",
|
|
2022
|
+
unitPrice: unitPriceText,
|
|
2023
|
+
perUse,
|
|
2024
|
+
cost: behavior === "pay_in_advance" ? {
|
|
2025
|
+
amount: formatCurrency(row.currentCost ?? 0, priceCurrency, locale),
|
|
2026
|
+
period: isTrait ? period : null
|
|
2027
|
+
} : null,
|
|
2028
|
+
tiers: behavior === "tier" && isTieredPrice(price) ? {
|
|
2029
|
+
currency: priceCurrency,
|
|
2030
|
+
mode: price?.tiersMode ?? null,
|
|
2031
|
+
period,
|
|
2032
|
+
ranges: tierRanges(price),
|
|
2033
|
+
unit: row.featureSingularName ?? row.featureName
|
|
2034
|
+
} : null,
|
|
2035
|
+
hardLimit: behavior !== null && behavior !== "credit_burndown" && row.valueType === "numeric" && typeof row.allocation === "number" ? {
|
|
2036
|
+
amount: formatNumber(row.allocation, locale),
|
|
2037
|
+
units: featureName(unit, row.allocation, locale)
|
|
2038
|
+
} : null,
|
|
2039
|
+
source: row
|
|
2040
|
+
};
|
|
2041
|
+
}
|
|
2042
|
+
function planCredits(company, balances, locale) {
|
|
2043
|
+
const order = company.plan?.includedCreditIds ?? [];
|
|
2044
|
+
const rank = (creditId) => {
|
|
2045
|
+
const index = order.indexOf(creditId);
|
|
2046
|
+
return index === -1 ? order.length : index;
|
|
2047
|
+
};
|
|
2048
|
+
const subscriptionPeriod = company.subscription?.period ?? null;
|
|
2049
|
+
return balances.flatMap((balance) => {
|
|
2050
|
+
const grants = balance.grants.filter(
|
|
2051
|
+
(grant) => grant.grantReason === "plan"
|
|
2052
|
+
);
|
|
2053
|
+
if (grants.length === 0) {
|
|
2054
|
+
return [];
|
|
2055
|
+
}
|
|
2056
|
+
const unit = creditUnit(balance);
|
|
2057
|
+
const value = sum(grants, (grant) => grant.quantity);
|
|
2058
|
+
const used = sum(grants, (grant) => grant.quantityUsed);
|
|
2059
|
+
const composition = balance.composition ?? null;
|
|
2060
|
+
const autoTopup = balance.autoTopup ?? null;
|
|
2061
|
+
const row = {
|
|
2062
|
+
creditId: balance.creditId,
|
|
2063
|
+
text: composition === null ? {
|
|
2064
|
+
kind: "total",
|
|
2065
|
+
amount: formatCredits(value, locale),
|
|
2066
|
+
creditName: featureName(unit, value, locale),
|
|
2067
|
+
period: subscriptionPeriod
|
|
2068
|
+
} : {
|
|
2069
|
+
kind: "perLicense",
|
|
2070
|
+
amount: formatCredits(composition.perLicenseAmount, locale),
|
|
2071
|
+
creditName: featureName(
|
|
2072
|
+
unit,
|
|
2073
|
+
composition.perLicenseAmount,
|
|
2074
|
+
locale
|
|
2075
|
+
),
|
|
2076
|
+
licenseName: featureName(licenseUnit(composition), 1, locale),
|
|
2077
|
+
plus: composition.fixedQuantity > 0 ? {
|
|
2078
|
+
amount: formatCredits(
|
|
2079
|
+
composition.fixedQuantity,
|
|
2080
|
+
locale
|
|
2081
|
+
),
|
|
2082
|
+
creditName: featureName(
|
|
2083
|
+
unit,
|
|
2084
|
+
composition.fixedQuantity,
|
|
2085
|
+
locale
|
|
2086
|
+
),
|
|
2087
|
+
period: composition.period
|
|
2088
|
+
} : null
|
|
2089
|
+
},
|
|
2090
|
+
used: spent(used, locale),
|
|
2091
|
+
autoTopup: autoTopup !== null && autoTopup.enabled && typeof autoTopup.thresholdCredits === "number" && typeof autoTopup.amount === "number" ? {
|
|
2092
|
+
amount: formatCredits(autoTopup.amount, locale),
|
|
2093
|
+
threshold: formatCredits(autoTopup.thresholdCredits, locale)
|
|
2094
|
+
} : null,
|
|
2095
|
+
composition: composition === null ? null : {
|
|
2096
|
+
quantity: formatNumber(composition.licenseQuantity, locale),
|
|
2097
|
+
licenseName: featureName(
|
|
2098
|
+
licenseUnit(composition),
|
|
2099
|
+
composition.licenseQuantity,
|
|
2100
|
+
locale
|
|
2101
|
+
),
|
|
2102
|
+
perUnit: formatCredits(composition.perLicenseAmount, locale),
|
|
2103
|
+
fixed: composition.fixedQuantity > 0 ? formatCredits(composition.fixedQuantity, locale) : null,
|
|
2104
|
+
total: formatCredits(composition.total, locale),
|
|
2105
|
+
creditName: featureName(unit, composition.total, locale),
|
|
2106
|
+
period: composition.period
|
|
2107
|
+
}
|
|
2108
|
+
};
|
|
2109
|
+
return [row];
|
|
2110
|
+
}).map((row, index) => ({ row, index })).sort(
|
|
2111
|
+
(a, b) => rank(a.row.creditId) - rank(b.row.creditId) || a.index - b.index
|
|
2112
|
+
).map(({ row }) => row);
|
|
2113
|
+
}
|
|
2114
|
+
function autoTopupBox(company, balances, locale) {
|
|
2115
|
+
const order = company.plan?.includedCreditIds ?? [];
|
|
2116
|
+
const selfService = order.flatMap((creditId) => {
|
|
2117
|
+
const balance = balances.find((b) => b.creditId === creditId);
|
|
2118
|
+
const autoTopup = balance?.autoTopup ?? null;
|
|
2119
|
+
return balance === void 0 || autoTopup === null || !autoTopup.selfService ? [] : [{ balance, autoTopup }];
|
|
2120
|
+
});
|
|
2121
|
+
if (selfService.length === 0) {
|
|
2122
|
+
return null;
|
|
2123
|
+
}
|
|
2124
|
+
return {
|
|
2125
|
+
lines: selfService.flatMap(({ balance, autoTopup }) => {
|
|
2126
|
+
const unit = creditUnit(balance);
|
|
2127
|
+
if (!autoTopup.enabled) {
|
|
2128
|
+
return [
|
|
2129
|
+
{
|
|
2130
|
+
kind: "disabled",
|
|
2131
|
+
creditId: balance.creditId,
|
|
2132
|
+
unit: featureName(unit, 1, locale)
|
|
2133
|
+
}
|
|
2134
|
+
];
|
|
2135
|
+
}
|
|
2136
|
+
if (typeof autoTopup.thresholdCredits !== "number" || typeof autoTopup.amount !== "number") {
|
|
2137
|
+
return [];
|
|
2138
|
+
}
|
|
2139
|
+
return [
|
|
2140
|
+
{
|
|
2141
|
+
kind: "adds",
|
|
2142
|
+
creditId: balance.creditId,
|
|
2143
|
+
amount: formatCredits(autoTopup.amount, locale),
|
|
2144
|
+
unit: featureName(unit, autoTopup.amount, locale),
|
|
2145
|
+
threshold: formatCredits(autoTopup.thresholdCredits, locale)
|
|
2146
|
+
}
|
|
2147
|
+
];
|
|
2148
|
+
})
|
|
2149
|
+
};
|
|
2150
|
+
}
|
|
2151
|
+
function creditGroups(balances, locale) {
|
|
2152
|
+
const groups = /* @__PURE__ */ new Map();
|
|
2153
|
+
for (const balance of balances) {
|
|
2154
|
+
for (const grant of balance.grants) {
|
|
2155
|
+
if (grant.grantReason === "plan") {
|
|
2156
|
+
continue;
|
|
2157
|
+
}
|
|
2158
|
+
const key = `${grant.grantReason}:${grant.bundleId ?? grant.id}`;
|
|
2159
|
+
const group = groups.get(key);
|
|
2160
|
+
if (group === void 0) {
|
|
2161
|
+
groups.set(key, { balance, grants: [grant] });
|
|
2162
|
+
} else {
|
|
2163
|
+
group.grants.push(grant);
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
const rows = Array.from(groups.entries()).map(([key, { balance, grants }]) => {
|
|
2168
|
+
const sorted = [...grants].sort(byRecency);
|
|
2169
|
+
const latest = sorted[0];
|
|
2170
|
+
return {
|
|
2171
|
+
reason: latest.grantReason,
|
|
2172
|
+
createdAt: latest.createdAt,
|
|
2173
|
+
row: {
|
|
2174
|
+
key,
|
|
2175
|
+
count: sorted.length,
|
|
2176
|
+
bundleName: orNull3(latest.bundleName),
|
|
2177
|
+
quantity: formatCredits(latest.quantity, locale),
|
|
2178
|
+
creditName: featureName(creditUnit(balance), latest.quantity, locale),
|
|
2179
|
+
used: spent(
|
|
2180
|
+
sum(sorted, (grant) => grant.quantityUsed),
|
|
2181
|
+
locale
|
|
2182
|
+
)
|
|
2183
|
+
}
|
|
2184
|
+
};
|
|
2185
|
+
}).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
2186
|
+
const pick = (reason) => rows.filter((entry) => entry.reason === reason).map((entry) => entry.row);
|
|
2187
|
+
return {
|
|
2188
|
+
bundles: pick("purchased"),
|
|
2189
|
+
promotional: pick("free"),
|
|
2190
|
+
topUps: pick("billing_credit_auto_topup")
|
|
2191
|
+
};
|
|
2192
|
+
}
|
|
2193
|
+
function byRecency(a, b) {
|
|
2194
|
+
return b.createdAt.getTime() - a.createdAt.getTime();
|
|
2195
|
+
}
|
|
2196
|
+
function creditUnit(balance) {
|
|
2197
|
+
return {
|
|
2198
|
+
name: balance.creditName,
|
|
2199
|
+
singularName: balance.creditSingularName ?? void 0,
|
|
2200
|
+
pluralName: balance.creditPluralName ?? void 0
|
|
2201
|
+
};
|
|
2202
|
+
}
|
|
2203
|
+
function licenseUnit(composition) {
|
|
2204
|
+
return {
|
|
2205
|
+
name: composition.licenseName,
|
|
2206
|
+
singularName: composition.licenseSingularName,
|
|
2207
|
+
pluralName: composition.licensePluralName
|
|
2208
|
+
};
|
|
2209
|
+
}
|
|
2210
|
+
function spent(used, locale) {
|
|
2211
|
+
return used > 0 ? formatCredits(used, locale) : null;
|
|
2212
|
+
}
|
|
2213
|
+
function sum(items, value) {
|
|
2214
|
+
return items.reduce((total, item) => total + value(item), 0);
|
|
2215
|
+
}
|
|
2216
|
+
function orNull3(value) {
|
|
2217
|
+
return value === void 0 || value === null || value === "" ? null : value;
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
// src/elements/model/unsubscribe.ts
|
|
2221
|
+
function deriveUnsubscribe(company, featureUsage, options) {
|
|
2222
|
+
const { locale } = options;
|
|
2223
|
+
const subscription = company.subscription ?? null;
|
|
2224
|
+
const currency = subscription?.currency ?? "usd";
|
|
2225
|
+
const cancelAt = usableDate(subscription?.cancelAt);
|
|
2226
|
+
const endsOn = cancelAt ?? usableDate(subscription?.nextBillAt) ?? options.now ?? /* @__PURE__ */ new Date();
|
|
2227
|
+
const money = (amount) => formatCurrency(amount, currency, locale);
|
|
2228
|
+
const addOns = company.addOns.flatMap(
|
|
2229
|
+
(addOn) => typeof addOn.price === "number" ? [
|
|
2230
|
+
{
|
|
2231
|
+
id: addOn.id,
|
|
2232
|
+
name: addOn.name,
|
|
2233
|
+
price: money(addOn.price),
|
|
2234
|
+
oneTime: addOn.period === "one-time"
|
|
2235
|
+
}
|
|
2236
|
+
] : []
|
|
2237
|
+
);
|
|
2238
|
+
const planPrice2 = company.plan?.price;
|
|
2239
|
+
const total = (typeof planPrice2 === "number" ? planPrice2 : 0) + company.addOns.reduce(
|
|
2240
|
+
(sum2, addOn) => addOn.period !== "one-time" && typeof addOn.price === "number" ? sum2 + addOn.price : sum2,
|
|
2241
|
+
0
|
|
2242
|
+
) + featureUsage.reduce(
|
|
2243
|
+
(sum2, row) => row.priceBehavior === "pay_in_advance" ? sum2 + (row.currentCost ?? 0) : sum2,
|
|
2244
|
+
0
|
|
2245
|
+
);
|
|
2246
|
+
return {
|
|
2247
|
+
canUnsubscribe: subscription !== null && cancelAt === void 0,
|
|
2248
|
+
accessEndsOn: formatDate(endsOn, locale),
|
|
2249
|
+
period: subscription?.period ?? company.plan?.period ?? "month",
|
|
2250
|
+
plan: company.plan === void 0 || company.plan === null ? null : {
|
|
2251
|
+
name: company.plan.name,
|
|
2252
|
+
price: typeof planPrice2 === "number" ? money(planPrice2) : null
|
|
2253
|
+
},
|
|
2254
|
+
addOns,
|
|
2255
|
+
total: money(total)
|
|
2256
|
+
};
|
|
2257
|
+
}
|
|
2258
|
+
|
|
1851
2259
|
// src/elements/strings.ts
|
|
1852
2260
|
var DEFAULT_STRINGS_LOCALE = "en";
|
|
1853
2261
|
var DEFAULT_STRINGS = {
|
|
@@ -1956,6 +2364,73 @@ var DEFAULT_STRINGS = {
|
|
|
1956
2364
|
creditUsagePerLicense: "{{quantity}} {{licenseName}} \xD7 {{perUnit}}",
|
|
1957
2365
|
creditUsageCompanyGrant: "{{amount}} company grant",
|
|
1958
2366
|
creditUsageRenewsOn: "Renews on the {{day}}.",
|
|
2367
|
+
planManagerLoading: "Loading your plan",
|
|
2368
|
+
planManagerError: "There was a problem retrieving your plan.",
|
|
2369
|
+
planManagerUnavailable: "Your plan is not available for this account.",
|
|
2370
|
+
planManagerTrialEndsIn: "Trial ends in {{amount}} {{units}}",
|
|
2371
|
+
planManagerTrialEndsSoon: "Trial ends in less than a minute",
|
|
2372
|
+
planManagerTrialEnded: "Your trial has ended",
|
|
2373
|
+
// The trial countdown's units, looked up by the bare key with `{ count }`.
|
|
2374
|
+
planManagerDays: "days",
|
|
2375
|
+
planManagerDays_one: "day",
|
|
2376
|
+
planManagerDays_other: "days",
|
|
2377
|
+
planManagerHours: "hours",
|
|
2378
|
+
planManagerHours_one: "hour",
|
|
2379
|
+
planManagerHours_other: "hours",
|
|
2380
|
+
planManagerMinutes: "minutes",
|
|
2381
|
+
planManagerMinutes_one: "minute",
|
|
2382
|
+
planManagerMinutes_other: "minutes",
|
|
2383
|
+
planManagerCanceled: "Subscription canceled",
|
|
2384
|
+
planManagerAccessEnds: "Access to {{plan}} will end on {{date}}.",
|
|
2385
|
+
planManagerPlanFallback: "plan",
|
|
2386
|
+
planManagerCustomAwaiting: "Pay to activate {{plan}}",
|
|
2387
|
+
planManagerCustomAwaitingDescription: "Pay the invoice to activate your custom plan. Due by {{date}}.",
|
|
2388
|
+
planManagerCustomDue: "Pay by {{date}} to keep {{plan}}",
|
|
2389
|
+
planManagerCustomDueDescription: "Access to {{plan}} will end on {{date}} unless the invoice is paid.",
|
|
2390
|
+
planManagerYourPlan: "your plan",
|
|
2391
|
+
planManagerPayNow: "Pay now",
|
|
2392
|
+
planManagerDowngradeScheduled: "Downgrade to {{plan}} scheduled",
|
|
2393
|
+
planManagerUsageBased: "Usage-based",
|
|
2394
|
+
planManagerFree: "Free",
|
|
2395
|
+
planManagerAddOns: "Add-ons",
|
|
2396
|
+
planManagerAdditional: "Additional",
|
|
2397
|
+
planManagerTierBased: "Tier-based",
|
|
2398
|
+
planManagerCreditsInPlan: "Credits in plan",
|
|
2399
|
+
planManagerCreditsError: "There was a problem retrieving your credits.",
|
|
2400
|
+
planManagerCreditsLoading: "Loading your credits",
|
|
2401
|
+
planManagerTopUps: "Top-ups",
|
|
2402
|
+
planManagerCreditBundles: "Credit bundles",
|
|
2403
|
+
planManagerPromotionalCredits: "Promotional credits",
|
|
2404
|
+
planManagerChangePlan: "Change plan",
|
|
2405
|
+
planManagerCredits: "{{amount}} {{creditName}}",
|
|
2406
|
+
planManagerCreditsPerPeriod: "{{amount}} {{creditName}} per {{period}}",
|
|
2407
|
+
planManagerCreditsPerLicense: "{{amount}} {{creditName}} per {{licenseName}}",
|
|
2408
|
+
planManagerCreditsPlusPerPeriod: "+ {{amount}} {{creditName}} per {{period}}",
|
|
2409
|
+
planManagerLicensesTimesCredits: "{{quantity}} {{licenseName}} \xD7 {{perUnit}} = {{total}} {{creditName}}/{{period}}",
|
|
2410
|
+
planManagerLicensesTimesCreditsPlusCompany: "{{quantity}} {{licenseName}} \xD7 {{perUnit}} + {{fixed}} = {{total}} {{creditName}}/{{period}}",
|
|
2411
|
+
planManagerUsed: "{{amount}} used",
|
|
2412
|
+
planManagerAutoTopup: "Auto top-up",
|
|
2413
|
+
planManagerAutoTopupDisabled: "Auto top-up disabled for {{unit}}",
|
|
2414
|
+
planManagerAutoTopupAdds: "Adds {{amount}} {{unit}} when {{threshold}} remaining in balance",
|
|
2415
|
+
planManagerAutoTopupTip: "When credit balance reaches {{threshold}} remaining, an auto top-up of {{amount}} credits will be processed.",
|
|
2416
|
+
planManagerEdit: "Edit",
|
|
2417
|
+
planManagerSeeAll: "See all ({{total}})",
|
|
2418
|
+
planManagerHideAll: "Hide all",
|
|
2419
|
+
unsubscribeButton: "Unsubscribe",
|
|
2420
|
+
unsubscribeTitle: "Cancel subscription",
|
|
2421
|
+
unsubscribeAccessUntil: "You will retain access to your plan until the end of the billing period, on {{date}}",
|
|
2422
|
+
unsubscribeNotReady: "Not ready to cancel?",
|
|
2423
|
+
unsubscribeManagePlan: "Manage plan",
|
|
2424
|
+
unsubscribePlan: "Plan",
|
|
2425
|
+
unsubscribeAddOns: "Add-ons",
|
|
2426
|
+
unsubscribeMonthlyTotal: "Monthly total:",
|
|
2427
|
+
unsubscribeQuarterlyTotal: "Quarterly total:",
|
|
2428
|
+
unsubscribeYearlyTotal: "Yearly total:",
|
|
2429
|
+
unsubscribeConfirm: "Cancel subscription",
|
|
2430
|
+
unsubscribeFailed: "Unsubscribe failed",
|
|
2431
|
+
unsubscribeClose: "Close",
|
|
2432
|
+
unsubscribeError: "There was a problem retrieving your subscription.",
|
|
2433
|
+
unsubscribeUnavailable: "Your subscription is not available for this account.",
|
|
1959
2434
|
usageByUserHeader: "Usage by user",
|
|
1960
2435
|
usageByUserTotal: "{{amount}} used by your team this period",
|
|
1961
2436
|
usageByUserError: "There was a problem retrieving usage by user.",
|
|
@@ -1991,7 +2466,12 @@ var DEFAULT_STRINGS = {
|
|
|
1991
2466
|
usageTiersGraduated: "Tiers apply progressively as quantity increases.",
|
|
1992
2467
|
periodMonthShort: "mo",
|
|
1993
2468
|
periodQuarterShort: "qtr",
|
|
1994
|
-
periodYearShort: "yr"
|
|
2469
|
+
periodYearShort: "yr",
|
|
2470
|
+
periodDay: "day",
|
|
2471
|
+
periodWeek: "week",
|
|
2472
|
+
periodMonth: "month",
|
|
2473
|
+
periodQuarter: "quarter",
|
|
2474
|
+
periodYear: "year"
|
|
1995
2475
|
};
|
|
1996
2476
|
var MISSING_STRING = "\0schematic:missing";
|
|
1997
2477
|
function interpolate(template, vars) {
|
|
@@ -2022,6 +2502,45 @@ function defaultString(key, vars) {
|
|
|
2022
2502
|
return lookup(DEFAULT_STRINGS, key, vars) ?? DEFAULT_STRINGS[key] ?? key;
|
|
2023
2503
|
}
|
|
2024
2504
|
|
|
2505
|
+
// src/elements/styles/card-group.ts
|
|
2506
|
+
var cardGroupCss = `
|
|
2507
|
+
.schematic-card-group {
|
|
2508
|
+
background: var(--schematic-background);
|
|
2509
|
+
border-radius: var(--schematic-radius);
|
|
2510
|
+
box-shadow: var(--schematic-shadow);
|
|
2511
|
+
color: var(--schematic-text);
|
|
2512
|
+
display: flex;
|
|
2513
|
+
flex-direction: column;
|
|
2514
|
+
overflow: clip;
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
.schematic-card-group .schematic-card,
|
|
2518
|
+
.schematic-card-group .schematic-element[data-state="pending"],
|
|
2519
|
+
.schematic-card-group .schematic-element[data-state="error"],
|
|
2520
|
+
.schematic-card-group .schematic-plan-manager {
|
|
2521
|
+
background: none;
|
|
2522
|
+
border-radius: 0;
|
|
2523
|
+
box-shadow: none;
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
.schematic-card-group .schematic-metered-features__list,
|
|
2527
|
+
.schematic-card-group .schematic-credit-usage__credits,
|
|
2528
|
+
.schematic-card-group .schematic-plan-manager {
|
|
2529
|
+
gap: 0;
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
.schematic-card-group > .schematic-element + .schematic-element,
|
|
2533
|
+
.schematic-card-group .schematic-card + .schematic-card {
|
|
2534
|
+
border-top: 1px solid var(--schematic-card-divider);
|
|
2535
|
+
}
|
|
2536
|
+
|
|
2537
|
+
.schematic-card-group .schematic-element:not(.schematic-card) > .schematic-header {
|
|
2538
|
+
margin: 0;
|
|
2539
|
+
padding: calc(var(--schematic-card-padding) * 0.75)
|
|
2540
|
+
var(--schematic-card-padding) 0;
|
|
2541
|
+
}
|
|
2542
|
+
`;
|
|
2543
|
+
|
|
2025
2544
|
// src/elements/styles/credit-usage.ts
|
|
2026
2545
|
var creditUsageCss = `
|
|
2027
2546
|
.schematic-credit-usage__credits {
|
|
@@ -2030,8 +2549,6 @@ var creditUsageCss = `
|
|
|
2030
2549
|
gap: var(--schematic-space);
|
|
2031
2550
|
}
|
|
2032
2551
|
|
|
2033
|
-
/* Each credit draws its own card, so the root draws one only while pending
|
|
2034
|
-
or failed. */
|
|
2035
2552
|
.schematic-credit-usage[data-state="pending"],
|
|
2036
2553
|
.schematic-credit-usage[data-state="error"] {
|
|
2037
2554
|
background: var(--schematic-background);
|
|
@@ -2052,7 +2569,6 @@ var creditUsageCss = `
|
|
|
2052
2569
|
gap: calc(var(--schematic-space) * 1.5);
|
|
2053
2570
|
}
|
|
2054
2571
|
|
|
2055
|
-
/* Held even without a glyph, as the embed does, so names line up. */
|
|
2056
2572
|
.schematic-credit-usage__icon {
|
|
2057
2573
|
align-items: center;
|
|
2058
2574
|
background: var(--schematic-surface);
|
|
@@ -2069,8 +2585,6 @@ var creditUsageCss = `
|
|
|
2069
2585
|
color: var(--schematic-accent);
|
|
2070
2586
|
}
|
|
2071
2587
|
|
|
2072
|
-
/* The embed's spacing: the balance well clear of the name, the composition
|
|
2073
|
-
tucked close under the balance. */
|
|
2074
2588
|
.schematic-credit-usage__body {
|
|
2075
2589
|
display: flex;
|
|
2076
2590
|
flex-direction: column;
|
|
@@ -2126,7 +2640,6 @@ var creditUsageCss = `
|
|
|
2126
2640
|
margin-inline-start: -0.333rem;
|
|
2127
2641
|
}
|
|
2128
2642
|
|
|
2129
|
-
/* Opens above its toggle, as in the embed. */
|
|
2130
2643
|
.schematic-credit-usage__grants {
|
|
2131
2644
|
background: var(--schematic-inset);
|
|
2132
2645
|
border-radius: calc(var(--schematic-radius) * 0.8);
|
|
@@ -2146,8 +2659,6 @@ var creditUsageCss = `
|
|
|
2146
2659
|
padding: 0;
|
|
2147
2660
|
}
|
|
2148
2661
|
|
|
2149
|
-
/* Where the grant and its date do not fit on one line, the date wraps
|
|
2150
|
-
rather than overflowing the panel. */
|
|
2151
2662
|
.schematic-credit-usage__grant {
|
|
2152
2663
|
display: flex;
|
|
2153
2664
|
flex-wrap: wrap;
|
|
@@ -2178,7 +2689,6 @@ var creditUsageCss = `
|
|
|
2178
2689
|
|
|
2179
2690
|
// src/elements/styles/dialog.ts
|
|
2180
2691
|
var dialogCss = `
|
|
2181
|
-
/* Up to 768px wide, with a tighter radius than a card. */
|
|
2182
2692
|
.schematic-dialog {
|
|
2183
2693
|
background: var(--schematic-background);
|
|
2184
2694
|
border: 0;
|
|
@@ -2189,16 +2699,10 @@ var dialogCss = `
|
|
|
2189
2699
|
margin: auto;
|
|
2190
2700
|
max-height: calc(100vh - 2 * var(--schematic-space));
|
|
2191
2701
|
max-width: none;
|
|
2192
|
-
/* No padding of its own: a click on the backdrop lands on the dialog
|
|
2193
|
-
itself, and one inside lands on the header or body. */
|
|
2194
2702
|
padding: 0;
|
|
2195
|
-
/* Never wider than the screen, whatever it holds. */
|
|
2196
2703
|
width: min(48rem, calc(100vw - 2 * var(--schematic-space)));
|
|
2197
2704
|
}
|
|
2198
2705
|
|
|
2199
|
-
/* Centred by vw on a phone: a host page wider than the screen widens the
|
|
2200
|
-
layout viewport, and auto margins would centre the dialog half off the
|
|
2201
|
-
screen. Desktop keeps auto margins, as vw counts the scrollbar there. */
|
|
2202
2706
|
@media (max-width: 52rem) {
|
|
2203
2707
|
.schematic-dialog {
|
|
2204
2708
|
inset-inline: 0 auto;
|
|
@@ -2215,8 +2719,6 @@ var dialogCss = `
|
|
|
2215
2719
|
background: var(--schematic-backdrop);
|
|
2216
2720
|
}
|
|
2217
2721
|
|
|
2218
|
-
/* Narrow on the right, where the close control's own hit area makes up the
|
|
2219
|
-
rest. */
|
|
2220
2722
|
.schematic-dialog__header {
|
|
2221
2723
|
align-items: center;
|
|
2222
2724
|
border-bottom: 1px solid
|
|
@@ -2233,7 +2735,6 @@ var dialogCss = `
|
|
|
2233
2735
|
}
|
|
2234
2736
|
}
|
|
2235
2737
|
|
|
2236
|
-
/* Body text at 18px, not a heading face. */
|
|
2237
2738
|
.schematic-dialog__title {
|
|
2238
2739
|
font-family: var(--schematic-font-body);
|
|
2239
2740
|
font-size: 1.125rem;
|
|
@@ -2698,15 +3199,12 @@ var includedFeaturesCss = `
|
|
|
2698
3199
|
padding: 0;
|
|
2699
3200
|
}
|
|
2700
3201
|
|
|
2701
|
-
/* Icon, name and details; the usage drops beneath on a narrow card. */
|
|
2702
3202
|
.schematic-included-features__row {
|
|
2703
3203
|
column-gap: 0.5rem;
|
|
2704
3204
|
display: grid;
|
|
2705
3205
|
grid-template-columns: min-content 1fr;
|
|
2706
3206
|
}
|
|
2707
3207
|
|
|
2708
|
-
/* Two classes: the icon font's own rule comes later in the sheet and sets
|
|
2709
|
-
display, which would leave the glyph in the circle's corner. */
|
|
2710
3208
|
.schematic-included-features .schematic-included-features__icon {
|
|
2711
3209
|
align-items: center;
|
|
2712
3210
|
background: var(--schematic-surface);
|
|
@@ -2728,7 +3226,6 @@ var includedFeaturesCss = `
|
|
|
2728
3226
|
grid-column: 2;
|
|
2729
3227
|
}
|
|
2730
3228
|
|
|
2731
|
-
/* An item name, as add-ons and plan lines elsewhere. */
|
|
2732
3229
|
.schematic-included-features__name {
|
|
2733
3230
|
font-family: var(--schematic-font-heading);
|
|
2734
3231
|
font-size: 1.125rem;
|
|
@@ -2751,10 +3248,8 @@ var includedFeaturesCss = `
|
|
|
2751
3248
|
}
|
|
2752
3249
|
|
|
2753
3250
|
@container (min-width: 23.4375rem) {
|
|
2754
|
-
/* The usage takes the room it needs and wraps only when the name leaves
|
|
2755
|
-
it none. */
|
|
2756
3251
|
.schematic-included-features__row {
|
|
2757
|
-
grid-template-columns: min-content 1fr
|
|
3252
|
+
grid-template-columns: min-content 1fr 1fr;
|
|
2758
3253
|
}
|
|
2759
3254
|
|
|
2760
3255
|
.schematic-included-features__usage {
|
|
@@ -2826,7 +3321,6 @@ var invoicesCss = `
|
|
|
2826
3321
|
.schematic-invoices__amount {
|
|
2827
3322
|
cursor: help;
|
|
2828
3323
|
font-variant-numeric: tabular-nums;
|
|
2829
|
-
/* Keeps a lone amount at the end when the date is hidden. */
|
|
2830
3324
|
margin-inline-start: auto;
|
|
2831
3325
|
text-align: end;
|
|
2832
3326
|
}
|
|
@@ -2844,7 +3338,6 @@ var invoicesCss = `
|
|
|
2844
3338
|
gap: calc(var(--schematic-space) / 2);
|
|
2845
3339
|
}
|
|
2846
3340
|
|
|
2847
|
-
/* Cancels the glyph's side bearing, so the chevron sits flush. */
|
|
2848
3341
|
.schematic-invoices__chevron {
|
|
2849
3342
|
margin-inline-start: -0.333rem;
|
|
2850
3343
|
}
|
|
@@ -2873,7 +3366,6 @@ var meteredFeaturesCss = `
|
|
|
2873
3366
|
padding: 0;
|
|
2874
3367
|
}
|
|
2875
3368
|
|
|
2876
|
-
/* Each feature is a card; while pending or failed, the root is the card. */
|
|
2877
3369
|
.schematic-metered-features[data-state="pending"],
|
|
2878
3370
|
.schematic-metered-features[data-state="error"] {
|
|
2879
3371
|
background: var(--schematic-background);
|
|
@@ -2896,7 +3388,6 @@ var meteredFeaturesCss = `
|
|
|
2896
3388
|
gap: calc(var(--schematic-space) * 1.5);
|
|
2897
3389
|
}
|
|
2898
3390
|
|
|
2899
|
-
/* Kept without a glyph, as in the embed, so names line up. */
|
|
2900
3391
|
.schematic-metered-features__icon {
|
|
2901
3392
|
align-items: center;
|
|
2902
3393
|
background: var(--schematic-surface);
|
|
@@ -2910,8 +3401,6 @@ var meteredFeaturesCss = `
|
|
|
2910
3401
|
width: 2.75rem;
|
|
2911
3402
|
}
|
|
2912
3403
|
|
|
2913
|
-
/* The glyph takes the base text colour rather than inheriting, so the accent
|
|
2914
|
-
is set on it too. */
|
|
2915
3404
|
.schematic-metered-features__icon .schematic-icon {
|
|
2916
3405
|
color: var(--schematic-accent);
|
|
2917
3406
|
}
|
|
@@ -2945,8 +3434,6 @@ var meteredFeaturesCss = `
|
|
|
2945
3434
|
margin: 0;
|
|
2946
3435
|
}
|
|
2947
3436
|
|
|
2948
|
-
/* Beside the title when both fit, otherwise beneath it as in the embed,
|
|
2949
|
-
rather than wrapping in a narrow column. */
|
|
2950
3437
|
.schematic-metered-features__figures {
|
|
2951
3438
|
display: flex;
|
|
2952
3439
|
flex: 0 0 auto;
|
|
@@ -2969,7 +3456,6 @@ var meteredFeaturesCss = `
|
|
|
2969
3456
|
text-align: start;
|
|
2970
3457
|
}
|
|
2971
3458
|
|
|
2972
|
-
/* Too narrow to keep "1,300 GB of storage used" on one line. */
|
|
2973
3459
|
.schematic-metered-features__headline {
|
|
2974
3460
|
white-space: normal;
|
|
2975
3461
|
}
|
|
@@ -2984,7 +3470,6 @@ var meteredFeaturesCss = `
|
|
|
2984
3470
|
white-space: nowrap;
|
|
2985
3471
|
}
|
|
2986
3472
|
|
|
2987
|
-
/* Negative margins undo the card's padding so the footer bleeds to its edges. */
|
|
2988
3473
|
.schematic-metered-features__price-details {
|
|
2989
3474
|
align-items: center;
|
|
2990
3475
|
background: var(--schematic-surface);
|
|
@@ -2997,6 +3482,10 @@ var meteredFeaturesCss = `
|
|
|
2997
3482
|
var(--schematic-card-padding);
|
|
2998
3483
|
}
|
|
2999
3484
|
|
|
3485
|
+
.schematic-metered-features__price-cost {
|
|
3486
|
+
text-align: end;
|
|
3487
|
+
}
|
|
3488
|
+
|
|
3000
3489
|
.schematic-metered-features .schematic-skeleton__cell[data-column="name"] {
|
|
3001
3490
|
width: 10rem;
|
|
3002
3491
|
}
|
|
@@ -3020,7 +3509,6 @@ var meteredFeaturesCss = `
|
|
|
3020
3509
|
background: color-mix(in srgb, var(--schematic-accent) 50%, transparent);
|
|
3021
3510
|
}
|
|
3022
3511
|
|
|
3023
|
-
/* Past the soft limit, the fill is the included share over a warning track. */
|
|
3024
3512
|
.schematic-meter--overage {
|
|
3025
3513
|
background: var(--schematic-warning);
|
|
3026
3514
|
}
|
|
@@ -3112,7 +3600,6 @@ var paymentMethodsCss = `
|
|
|
3112
3600
|
white-space: nowrap;
|
|
3113
3601
|
}
|
|
3114
3602
|
|
|
3115
|
-
/* The pill: the default method on the left, Edit or Add on the right. */
|
|
3116
3603
|
.schematic-payment-methods__current {
|
|
3117
3604
|
align-items: center;
|
|
3118
3605
|
background: var(--schematic-surface);
|
|
@@ -3123,8 +3610,6 @@ var paymentMethodsCss = `
|
|
|
3123
3610
|
padding: calc(var(--schematic-space) / 2.25) var(--schematic-space);
|
|
3124
3611
|
}
|
|
3125
3612
|
|
|
3126
|
-
/* One line: a label too long for the space truncates rather than wrapping
|
|
3127
|
-
"Card ending in" away from its digits or widening the dialog. */
|
|
3128
3613
|
.schematic-payment-methods__method {
|
|
3129
3614
|
align-items: center;
|
|
3130
3615
|
display: inline-flex;
|
|
@@ -3140,7 +3625,6 @@ var paymentMethodsCss = `
|
|
|
3140
3625
|
white-space: nowrap;
|
|
3141
3626
|
}
|
|
3142
3627
|
|
|
3143
|
-
/* The brand's mark before the label, in the label's colour. */
|
|
3144
3628
|
.schematic-payment-methods__icon {
|
|
3145
3629
|
color: currentColor;
|
|
3146
3630
|
flex-shrink: 0;
|
|
@@ -3163,15 +3647,10 @@ var paymentMethodsCss = `
|
|
|
3163
3647
|
white-space: nowrap;
|
|
3164
3648
|
}
|
|
3165
3649
|
|
|
3166
|
-
/* The toggle that reveals the other methods. Its chevron is a glyph per
|
|
3167
|
-
state, down while folded and up while unfolded, and the hover underline
|
|
3168
|
-
goes on the label alone, as on every toggle. */
|
|
3169
3650
|
.schematic-payment-methods__choose {
|
|
3170
3651
|
align-items: center;
|
|
3171
3652
|
align-self: flex-start;
|
|
3172
3653
|
display: inline-flex;
|
|
3173
|
-
/* A button centres its text; a label that wraps on a phone keeps to the
|
|
3174
|
-
start. */
|
|
3175
3654
|
text-align: start;
|
|
3176
3655
|
gap: calc(var(--schematic-space) / 2);
|
|
3177
3656
|
}
|
|
@@ -3184,9 +3663,6 @@ var paymentMethodsCss = `
|
|
|
3184
3663
|
text-decoration: underline;
|
|
3185
3664
|
}
|
|
3186
3665
|
|
|
3187
|
-
|
|
3188
|
-
/* A faintly tinted panel, roomier than the shared dialog body, with its
|
|
3189
|
-
parts spaced further apart. */
|
|
3190
3666
|
.schematic-payment-methods__dialog .schematic-dialog__body {
|
|
3191
3667
|
background: color-mix(in srgb, var(--schematic-text) 2.5%, transparent);
|
|
3192
3668
|
gap: calc(var(--schematic-space) * 2);
|
|
@@ -3199,9 +3675,6 @@ var paymentMethodsCss = `
|
|
|
3199
3675
|
}
|
|
3200
3676
|
}
|
|
3201
3677
|
|
|
3202
|
-
/* The list tucks up under its toggle, the heading sits a card's gap above
|
|
3203
|
-
the pill, and a failed write sits close under what it failed
|
|
3204
|
-
on. */
|
|
3205
3678
|
.schematic-payment-methods__dialog .schematic-payment-methods__list,
|
|
3206
3679
|
.schematic-payment-methods__dialog .schematic-payment-methods__current,
|
|
3207
3680
|
.schematic-payment-methods__dialog .schematic-payment-methods__error {
|
|
@@ -3216,8 +3689,6 @@ var paymentMethodsCss = `
|
|
|
3216
3689
|
padding: 0;
|
|
3217
3690
|
}
|
|
3218
3691
|
|
|
3219
|
-
/* The name on the left, the expiry and actions on the right; a narrow
|
|
3220
|
-
dialog wraps the actions under the name. */
|
|
3221
3692
|
.schematic-payment-methods__row {
|
|
3222
3693
|
align-items: center;
|
|
3223
3694
|
border-bottom: 1px solid var(--schematic-card-divider);
|
|
@@ -3227,8 +3698,6 @@ var paymentMethodsCss = `
|
|
|
3227
3698
|
padding: calc(var(--schematic-space) / 2) 0;
|
|
3228
3699
|
}
|
|
3229
3700
|
|
|
3230
|
-
/* The name takes the line's room first; the actions wrap under it before
|
|
3231
|
-
the name is cut short. */
|
|
3232
3701
|
.schematic-payment-methods__row .schematic-payment-methods__method {
|
|
3233
3702
|
flex: 1 1 10rem;
|
|
3234
3703
|
}
|
|
@@ -3281,7 +3750,6 @@ var paymentMethodsCss = `
|
|
|
3281
3750
|
width: 100%;
|
|
3282
3751
|
}
|
|
3283
3752
|
|
|
3284
|
-
/* Larger than the shared CTA: taller, with bigger type and radius. */
|
|
3285
3753
|
.schematic-payment-methods__add-new {
|
|
3286
3754
|
border-radius: 0.625rem;
|
|
3287
3755
|
font-size: 1.1875rem;
|
|
@@ -3293,7 +3761,6 @@ var paymentMethodsCss = `
|
|
|
3293
3761
|
align-self: flex-start;
|
|
3294
3762
|
}
|
|
3295
3763
|
|
|
3296
|
-
/* The failed write and its retry sit on one line at the foot of the dialog. */
|
|
3297
3764
|
.schematic-payment-methods__error {
|
|
3298
3765
|
align-items: center;
|
|
3299
3766
|
display: flex;
|
|
@@ -3306,8 +3773,6 @@ var paymentMethodsCss = `
|
|
|
3306
3773
|
white-space: nowrap;
|
|
3307
3774
|
}
|
|
3308
3775
|
|
|
3309
|
-
/* Spaced as the embed's form: 24px between parts, and a wider break before
|
|
3310
|
-
Save under the address. */
|
|
3311
3776
|
.schematic-payment-methods__form {
|
|
3312
3777
|
display: flex;
|
|
3313
3778
|
flex-direction: column;
|
|
@@ -3318,8 +3783,6 @@ var paymentMethodsCss = `
|
|
|
3318
3783
|
margin-bottom: calc(var(--schematic-space) * 2);
|
|
3319
3784
|
}
|
|
3320
3785
|
|
|
3321
|
-
/* The fields the checkout settings add beside Stripe's own, labelled as
|
|
3322
|
-
Stripe's are. */
|
|
3323
3786
|
.schematic-payment-methods__field {
|
|
3324
3787
|
display: flex;
|
|
3325
3788
|
flex-direction: column;
|
|
@@ -3329,7 +3792,6 @@ var paymentMethodsCss = `
|
|
|
3329
3792
|
.schematic-payment-methods__input {
|
|
3330
3793
|
background: var(--schematic-background);
|
|
3331
3794
|
border: 1px solid var(--schematic-border);
|
|
3332
|
-
/* The embed's 8px at the default radius; Stripe's fields take the same. */
|
|
3333
3795
|
border-radius: calc(var(--schematic-radius) * 0.8);
|
|
3334
3796
|
box-sizing: border-box;
|
|
3335
3797
|
color: var(--schematic-text);
|
|
@@ -3358,109 +3820,364 @@ var paymentMethodsCss = `
|
|
|
3358
3820
|
}
|
|
3359
3821
|
`;
|
|
3360
3822
|
|
|
3361
|
-
// src/elements/styles/
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
display: inline-block;
|
|
3368
|
-
margin-inline-start: 0.25rem;
|
|
3369
|
-
position: relative;
|
|
3370
|
-
vertical-align: middle;
|
|
3371
|
-
}
|
|
3372
|
-
|
|
3373
|
-
.schematic-tooltip__trigger {
|
|
3374
|
-
background: none;
|
|
3375
|
-
border: 0;
|
|
3376
|
-
color: var(--schematic-muted);
|
|
3377
|
-
cursor: help;
|
|
3378
|
-
/* A button keeps the browser's control font; the glyph is the embed's
|
|
3379
|
-
24px. */
|
|
3380
|
-
font-size: 1.5rem;
|
|
3381
|
-
line-height: 0;
|
|
3382
|
-
padding: 0;
|
|
3823
|
+
// src/elements/styles/plan-manager.ts
|
|
3824
|
+
var planManagerCss = `
|
|
3825
|
+
.schematic-plan-manager {
|
|
3826
|
+
display: flex;
|
|
3827
|
+
flex-direction: column;
|
|
3828
|
+
gap: var(--schematic-space);
|
|
3383
3829
|
}
|
|
3384
3830
|
|
|
3385
|
-
.schematic-
|
|
3386
|
-
|
|
3387
|
-
|
|
3831
|
+
.schematic-plan-manager[data-state="pending"],
|
|
3832
|
+
.schematic-plan-manager[data-state="error"] {
|
|
3833
|
+
background: var(--schematic-background);
|
|
3834
|
+
border-radius: var(--schematic-radius);
|
|
3835
|
+
box-shadow: var(--schematic-shadow);
|
|
3836
|
+
padding: calc(var(--schematic-card-padding) * 0.75)
|
|
3837
|
+
var(--schematic-card-padding);
|
|
3388
3838
|
}
|
|
3389
3839
|
|
|
3390
|
-
.schematic-
|
|
3840
|
+
.schematic-plan-manager:has(.schematic-plan-manager__notice) {
|
|
3391
3841
|
background: var(--schematic-background);
|
|
3392
|
-
border:
|
|
3393
|
-
border-radius: calc(var(--schematic-radius) / 2);
|
|
3394
|
-
bottom: calc(100% + 0.5rem);
|
|
3842
|
+
border-radius: var(--schematic-radius);
|
|
3395
3843
|
box-shadow: var(--schematic-shadow);
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
inset-inline-end: 0;
|
|
3399
|
-
padding: 0.5rem 0.75rem;
|
|
3400
|
-
pointer-events: none;
|
|
3401
|
-
position: absolute;
|
|
3402
|
-
text-align: start;
|
|
3403
|
-
visibility: hidden;
|
|
3404
|
-
white-space: nowrap;
|
|
3405
|
-
z-index: 1;
|
|
3844
|
+
gap: 0;
|
|
3845
|
+
overflow: hidden;
|
|
3406
3846
|
}
|
|
3407
3847
|
|
|
3408
|
-
.schematic-
|
|
3409
|
-
.schematic-
|
|
3410
|
-
|
|
3848
|
+
.schematic-plan-manager:has(.schematic-plan-manager__notice)
|
|
3849
|
+
.schematic-plan-manager__card {
|
|
3850
|
+
border-radius: 0;
|
|
3851
|
+
box-shadow: none;
|
|
3411
3852
|
}
|
|
3412
3853
|
|
|
3413
|
-
.schematic-
|
|
3854
|
+
.schematic-plan-manager__notice {
|
|
3855
|
+
align-items: center;
|
|
3856
|
+
background: var(--schematic-inset);
|
|
3414
3857
|
display: flex;
|
|
3415
3858
|
flex-direction: column;
|
|
3416
3859
|
gap: 0.5rem;
|
|
3860
|
+
padding: calc(var(--schematic-space) * 1.5);
|
|
3861
|
+
text-align: center;
|
|
3417
3862
|
}
|
|
3418
3863
|
|
|
3419
|
-
.schematic-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
display: flex;
|
|
3425
|
-
gap: var(--schematic-space);
|
|
3426
|
-
justify-content: space-between;
|
|
3427
|
-
padding: 0.25rem 0;
|
|
3428
|
-
}
|
|
3429
|
-
|
|
3430
|
-
.schematic-tiers__price {
|
|
3864
|
+
.schematic-plan-manager__notice-title {
|
|
3865
|
+
font-family: var(--schematic-font-heading);
|
|
3866
|
+
font-size: 1.25rem;
|
|
3867
|
+
font-weight: 600;
|
|
3868
|
+
line-height: var(--schematic-line-height-heading);
|
|
3431
3869
|
margin: 0;
|
|
3432
3870
|
}
|
|
3433
3871
|
|
|
3434
|
-
.schematic-
|
|
3435
|
-
|
|
3436
|
-
padding-top: 0.5rem;
|
|
3437
|
-
white-space: normal;
|
|
3872
|
+
.schematic-plan-manager__notice-body {
|
|
3873
|
+
font-size: 0.8125rem;
|
|
3438
3874
|
}
|
|
3439
|
-
`;
|
|
3440
3875
|
|
|
3441
|
-
|
|
3442
|
-
var upcomingBillCss = `
|
|
3443
|
-
.schematic-upcoming-bill {
|
|
3876
|
+
.schematic-plan-manager__card {
|
|
3444
3877
|
display: flex;
|
|
3445
3878
|
flex-direction: column;
|
|
3446
|
-
gap: var(--schematic-space);
|
|
3879
|
+
gap: calc(var(--schematic-space) * 2);
|
|
3447
3880
|
}
|
|
3448
3881
|
|
|
3449
|
-
.schematic-
|
|
3450
|
-
|
|
3882
|
+
.schematic-plan-manager__plan {
|
|
3883
|
+
align-items: center;
|
|
3884
|
+
display: flex;
|
|
3885
|
+
gap: var(--schematic-space);
|
|
3886
|
+
justify-content: space-between;
|
|
3451
3887
|
}
|
|
3452
3888
|
|
|
3453
|
-
.schematic-
|
|
3454
|
-
align-items: flex-start;
|
|
3889
|
+
.schematic-plan-manager__title {
|
|
3455
3890
|
display: flex;
|
|
3891
|
+
flex-direction: column;
|
|
3456
3892
|
gap: var(--schematic-space);
|
|
3457
|
-
justify-content: space-between;
|
|
3458
3893
|
}
|
|
3459
3894
|
|
|
3460
|
-
.schematic-
|
|
3895
|
+
.schematic-plan-manager__name {
|
|
3461
3896
|
font-family: var(--schematic-font-heading);
|
|
3462
3897
|
font-size: 2.3125rem;
|
|
3463
|
-
font-
|
|
3898
|
+
font-weight: 800;
|
|
3899
|
+
line-height: 1;
|
|
3900
|
+
margin: 0;
|
|
3901
|
+
}
|
|
3902
|
+
|
|
3903
|
+
.schematic-plan-manager__price {
|
|
3904
|
+
font-family: var(--schematic-font-heading);
|
|
3905
|
+
font-size: 1.25rem;
|
|
3906
|
+
font-weight: 600;
|
|
3907
|
+
white-space: nowrap;
|
|
3908
|
+
}
|
|
3909
|
+
|
|
3910
|
+
.schematic-plan-manager__section {
|
|
3911
|
+
display: flex;
|
|
3912
|
+
flex-direction: column;
|
|
3913
|
+
gap: 0.5rem;
|
|
3914
|
+
}
|
|
3915
|
+
|
|
3916
|
+
.schematic-plan-manager__label {
|
|
3917
|
+
line-height: 1;
|
|
3918
|
+
}
|
|
3919
|
+
|
|
3920
|
+
.schematic-plan-manager__rows {
|
|
3921
|
+
display: flex;
|
|
3922
|
+
flex-direction: column;
|
|
3923
|
+
gap: var(--schematic-space);
|
|
3924
|
+
list-style: none;
|
|
3925
|
+
margin: 0;
|
|
3926
|
+
padding: 0;
|
|
3927
|
+
}
|
|
3928
|
+
|
|
3929
|
+
.schematic-plan-manager__row,
|
|
3930
|
+
.schematic-plan-manager__row-main {
|
|
3931
|
+
align-items: center;
|
|
3932
|
+
display: flex;
|
|
3933
|
+
flex-wrap: wrap;
|
|
3934
|
+
gap: var(--schematic-space);
|
|
3935
|
+
justify-content: space-between;
|
|
3936
|
+
}
|
|
3937
|
+
|
|
3938
|
+
.schematic-plan-manager__row-main {
|
|
3939
|
+
align-items: baseline;
|
|
3940
|
+
gap: 0.5rem;
|
|
3941
|
+
}
|
|
3942
|
+
|
|
3943
|
+
.schematic-plan-manager__row--stacked {
|
|
3944
|
+
align-items: stretch;
|
|
3945
|
+
flex-direction: column;
|
|
3946
|
+
gap: 0.25rem;
|
|
3947
|
+
}
|
|
3948
|
+
|
|
3949
|
+
.schematic-plan-manager__item {
|
|
3950
|
+
font-family: var(--schematic-font-heading);
|
|
3951
|
+
font-size: 1.125rem;
|
|
3952
|
+
font-weight: 800;
|
|
3953
|
+
}
|
|
3954
|
+
|
|
3955
|
+
.schematic-plan-manager__detail,
|
|
3956
|
+
.schematic-plan-manager__used {
|
|
3957
|
+
align-items: center;
|
|
3958
|
+
display: inline-flex;
|
|
3959
|
+
gap: 0.25rem;
|
|
3960
|
+
}
|
|
3961
|
+
|
|
3962
|
+
.schematic-plan-manager__see-all {
|
|
3963
|
+
align-items: center;
|
|
3964
|
+
align-self: flex-start;
|
|
3965
|
+
display: inline-flex;
|
|
3966
|
+
gap: 0.25rem;
|
|
3967
|
+
margin-top: 0.5rem;
|
|
3968
|
+
}
|
|
3969
|
+
|
|
3970
|
+
.schematic-plan-manager__see-all .schematic-chevron {
|
|
3971
|
+
margin-inline-start: -0.333rem;
|
|
3972
|
+
}
|
|
3973
|
+
|
|
3974
|
+
.schematic-plan-manager__auto-topup {
|
|
3975
|
+
align-items: center;
|
|
3976
|
+
background: var(--schematic-inset);
|
|
3977
|
+
border-radius: calc(var(--schematic-radius) * 0.8);
|
|
3978
|
+
display: flex;
|
|
3979
|
+
gap: 0.5rem;
|
|
3980
|
+
justify-content: space-between;
|
|
3981
|
+
padding: calc(var(--schematic-space) * 1.5);
|
|
3982
|
+
}
|
|
3983
|
+
|
|
3984
|
+
.schematic-plan-manager__auto-topup-lines {
|
|
3985
|
+
display: flex;
|
|
3986
|
+
flex-direction: column;
|
|
3987
|
+
gap: 0.5rem;
|
|
3988
|
+
line-height: 1.25;
|
|
3989
|
+
}
|
|
3990
|
+
|
|
3991
|
+
.schematic-plan-manager__change-plan {
|
|
3992
|
+
width: 100%;
|
|
3993
|
+
}
|
|
3994
|
+
|
|
3995
|
+
.schematic-plan-manager .schematic-skeleton__cell[data-column="name"] {
|
|
3996
|
+
width: 10rem;
|
|
3997
|
+
}
|
|
3998
|
+
|
|
3999
|
+
.schematic-plan-manager .schematic-skeleton__cell[data-column="price"] {
|
|
4000
|
+
width: 6rem;
|
|
4001
|
+
}
|
|
4002
|
+
`;
|
|
4003
|
+
|
|
4004
|
+
// src/elements/styles/index.tsx
|
|
4005
|
+
init_tokens();
|
|
4006
|
+
|
|
4007
|
+
// src/elements/styles/tooltip.ts
|
|
4008
|
+
var tooltipCss = `
|
|
4009
|
+
.schematic-tooltip {
|
|
4010
|
+
display: inline-block;
|
|
4011
|
+
margin-inline-start: 0.25rem;
|
|
4012
|
+
position: relative;
|
|
4013
|
+
vertical-align: middle;
|
|
4014
|
+
}
|
|
4015
|
+
|
|
4016
|
+
.schematic-tooltip__trigger {
|
|
4017
|
+
background: none;
|
|
4018
|
+
border: 0;
|
|
4019
|
+
color: var(--schematic-muted);
|
|
4020
|
+
cursor: help;
|
|
4021
|
+
font-size: 1.5rem;
|
|
4022
|
+
line-height: 0;
|
|
4023
|
+
padding: 0;
|
|
4024
|
+
}
|
|
4025
|
+
|
|
4026
|
+
.schematic-tooltip__trigger:focus-visible {
|
|
4027
|
+
outline: 2px solid var(--schematic-accent);
|
|
4028
|
+
outline-offset: 2px;
|
|
4029
|
+
}
|
|
4030
|
+
|
|
4031
|
+
.schematic-tooltip__content {
|
|
4032
|
+
background: var(--schematic-background);
|
|
4033
|
+
border: 1px solid var(--schematic-border);
|
|
4034
|
+
border-radius: calc(var(--schematic-radius) / 2);
|
|
4035
|
+
bottom: calc(100% + 0.5rem);
|
|
4036
|
+
box-shadow: var(--schematic-shadow);
|
|
4037
|
+
color: var(--schematic-text);
|
|
4038
|
+
font-size: 0.875rem;
|
|
4039
|
+
inset-inline-end: 0;
|
|
4040
|
+
padding: 0.5rem 0.75rem;
|
|
4041
|
+
pointer-events: none;
|
|
4042
|
+
position: absolute;
|
|
4043
|
+
text-align: start;
|
|
4044
|
+
visibility: hidden;
|
|
4045
|
+
white-space: nowrap;
|
|
4046
|
+
z-index: 1;
|
|
4047
|
+
}
|
|
4048
|
+
|
|
4049
|
+
.schematic-tooltip:hover .schematic-tooltip__content,
|
|
4050
|
+
.schematic-tooltip:focus-within .schematic-tooltip__content {
|
|
4051
|
+
visibility: visible;
|
|
4052
|
+
}
|
|
4053
|
+
|
|
4054
|
+
.schematic-tiers {
|
|
4055
|
+
display: flex;
|
|
4056
|
+
flex-direction: column;
|
|
4057
|
+
gap: 0.5rem;
|
|
4058
|
+
}
|
|
4059
|
+
|
|
4060
|
+
.schematic-tiers__list {
|
|
4061
|
+
margin: 0;
|
|
4062
|
+
}
|
|
4063
|
+
|
|
4064
|
+
.schematic-tiers__tier {
|
|
4065
|
+
display: flex;
|
|
4066
|
+
gap: var(--schematic-space);
|
|
4067
|
+
justify-content: space-between;
|
|
4068
|
+
padding: 0.25rem 0;
|
|
4069
|
+
}
|
|
4070
|
+
|
|
4071
|
+
.schematic-tiers__price {
|
|
4072
|
+
margin: 0;
|
|
4073
|
+
}
|
|
4074
|
+
|
|
4075
|
+
.schematic-tiers__mode {
|
|
4076
|
+
border-top: 1px solid var(--schematic-border);
|
|
4077
|
+
padding-top: 0.5rem;
|
|
4078
|
+
white-space: normal;
|
|
4079
|
+
}
|
|
4080
|
+
`;
|
|
4081
|
+
|
|
4082
|
+
// src/elements/styles/unsubscribe.ts
|
|
4083
|
+
var unsubscribeCss = `
|
|
4084
|
+
.schematic-unsubscribe {
|
|
4085
|
+
display: flex;
|
|
4086
|
+
justify-content: center;
|
|
4087
|
+
}
|
|
4088
|
+
|
|
4089
|
+
.schematic-unsubscribe__open {
|
|
4090
|
+
width: 100%;
|
|
4091
|
+
}
|
|
4092
|
+
|
|
4093
|
+
.schematic-unsubscribe__columns {
|
|
4094
|
+
display: flex;
|
|
4095
|
+
flex-wrap: wrap;
|
|
4096
|
+
gap: calc(var(--schematic-space) * 2);
|
|
4097
|
+
}
|
|
4098
|
+
|
|
4099
|
+
.schematic-unsubscribe__summary {
|
|
4100
|
+
display: flex;
|
|
4101
|
+
flex: 1 1 18rem;
|
|
4102
|
+
flex-direction: column;
|
|
4103
|
+
gap: calc(var(--schematic-space) * 2);
|
|
4104
|
+
}
|
|
4105
|
+
|
|
4106
|
+
.schematic-unsubscribe__manage {
|
|
4107
|
+
display: flex;
|
|
4108
|
+
flex-direction: column;
|
|
4109
|
+
gap: 0.5rem;
|
|
4110
|
+
}
|
|
4111
|
+
|
|
4112
|
+
.schematic-unsubscribe__manage-plan {
|
|
4113
|
+
align-self: flex-start;
|
|
4114
|
+
color: var(--schematic-accent);
|
|
4115
|
+
}
|
|
4116
|
+
|
|
4117
|
+
.schematic-unsubscribe__sidebar {
|
|
4118
|
+
background: var(--schematic-inset);
|
|
4119
|
+
border-radius: calc(var(--schematic-radius) * 0.8);
|
|
4120
|
+
display: flex;
|
|
4121
|
+
flex: 1 1 16rem;
|
|
4122
|
+
flex-direction: column;
|
|
4123
|
+
gap: calc(var(--schematic-space) * 1.5);
|
|
4124
|
+
padding: calc(var(--schematic-space) * 1.5);
|
|
4125
|
+
}
|
|
4126
|
+
|
|
4127
|
+
.schematic-unsubscribe__group {
|
|
4128
|
+
display: flex;
|
|
4129
|
+
flex-direction: column;
|
|
4130
|
+
gap: 0.125rem;
|
|
4131
|
+
}
|
|
4132
|
+
|
|
4133
|
+
.schematic-unsubscribe__line {
|
|
4134
|
+
align-items: baseline;
|
|
4135
|
+
display: flex;
|
|
4136
|
+
gap: var(--schematic-space);
|
|
4137
|
+
justify-content: space-between;
|
|
4138
|
+
white-space: nowrap;
|
|
4139
|
+
}
|
|
4140
|
+
|
|
4141
|
+
.schematic-unsubscribe__name {
|
|
4142
|
+
font-family: var(--schematic-font-heading);
|
|
4143
|
+
font-size: 1.125rem;
|
|
4144
|
+
font-weight: 800;
|
|
4145
|
+
white-space: normal;
|
|
4146
|
+
}
|
|
4147
|
+
|
|
4148
|
+
.schematic-unsubscribe__total {
|
|
4149
|
+
border-top: 1px solid var(--schematic-card-divider);
|
|
4150
|
+
padding-top: calc(var(--schematic-space) * 1.5);
|
|
4151
|
+
}
|
|
4152
|
+
|
|
4153
|
+
.schematic-unsubscribe__confirm {
|
|
4154
|
+
width: 100%;
|
|
4155
|
+
}
|
|
4156
|
+
`;
|
|
4157
|
+
|
|
4158
|
+
// src/elements/styles/upcoming-bill.ts
|
|
4159
|
+
var upcomingBillCss = `
|
|
4160
|
+
.schematic-upcoming-bill {
|
|
4161
|
+
display: flex;
|
|
4162
|
+
flex-direction: column;
|
|
4163
|
+
gap: var(--schematic-space);
|
|
4164
|
+
}
|
|
4165
|
+
|
|
4166
|
+
.schematic-upcoming-bill .schematic-header {
|
|
4167
|
+
margin-bottom: 0;
|
|
4168
|
+
}
|
|
4169
|
+
|
|
4170
|
+
.schematic-upcoming-bill__amount {
|
|
4171
|
+
align-items: flex-start;
|
|
4172
|
+
display: flex;
|
|
4173
|
+
gap: var(--schematic-space);
|
|
4174
|
+
justify-content: space-between;
|
|
4175
|
+
}
|
|
4176
|
+
|
|
4177
|
+
.schematic-upcoming-bill__total {
|
|
4178
|
+
font-family: var(--schematic-font-heading);
|
|
4179
|
+
font-size: 2.3125rem;
|
|
4180
|
+
font-variant-numeric: tabular-nums;
|
|
3464
4181
|
font-weight: 800;
|
|
3465
4182
|
line-height: 1;
|
|
3466
4183
|
}
|
|
@@ -3492,7 +4209,7 @@ var upcomingBillCss = `
|
|
|
3492
4209
|
}
|
|
3493
4210
|
|
|
3494
4211
|
.schematic-upcoming-bill__discount {
|
|
3495
|
-
align-items:
|
|
4212
|
+
align-items: start;
|
|
3496
4213
|
display: inline-flex;
|
|
3497
4214
|
gap: calc(var(--schematic-space) / 2);
|
|
3498
4215
|
}
|
|
@@ -3520,6 +4237,7 @@ var rulesCss = `
|
|
|
3520
4237
|
color: var(--schematic-text);
|
|
3521
4238
|
font-family: var(--schematic-font-body);
|
|
3522
4239
|
line-height: var(--schematic-line-height);
|
|
4240
|
+
text-wrap: balance;
|
|
3523
4241
|
}
|
|
3524
4242
|
|
|
3525
4243
|
:where([class^="schematic-"]) *,
|
|
@@ -3532,7 +4250,6 @@ var rulesCss = `
|
|
|
3532
4250
|
margin: 0;
|
|
3533
4251
|
}
|
|
3534
4252
|
|
|
3535
|
-
/* Unit suffixes ("/mo", "/seat") sit on the baseline, as in the embed. */
|
|
3536
4253
|
:where([class^="schematic-"]) sub,
|
|
3537
4254
|
:where([class^="schematic-"]) sup {
|
|
3538
4255
|
line-height: 1;
|
|
@@ -3570,13 +4287,11 @@ var rulesCss = `
|
|
|
3570
4287
|
gap: var(--schematic-space);
|
|
3571
4288
|
}
|
|
3572
4289
|
|
|
3573
|
-
/* The message may run long; the action beside it stays one line. */
|
|
3574
4290
|
.schematic-status__retry {
|
|
3575
4291
|
flex-shrink: 0;
|
|
3576
4292
|
white-space: nowrap;
|
|
3577
4293
|
}
|
|
3578
4294
|
|
|
3579
|
-
/* Visually hidden, still read by assistive technology. */
|
|
3580
4295
|
.schematic-hidden {
|
|
3581
4296
|
border: 0;
|
|
3582
4297
|
clip-path: inset(50%);
|
|
@@ -3705,7 +4420,6 @@ var rulesCss = `
|
|
|
3705
4420
|
border-color: var(--schematic-primary);
|
|
3706
4421
|
}
|
|
3707
4422
|
|
|
3708
|
-
/* The embed's small button: 15px type, 40px tall. */
|
|
3709
4423
|
.schematic-cta--small {
|
|
3710
4424
|
border-radius: 0.375rem;
|
|
3711
4425
|
font-size: 0.9375rem;
|
|
@@ -3713,7 +4427,6 @@ var rulesCss = `
|
|
|
3713
4427
|
padding: 0.4375rem 1.25rem;
|
|
3714
4428
|
}
|
|
3715
4429
|
|
|
3716
|
-
/* The embed's ghost button, for secondary actions such as Try again. */
|
|
3717
4430
|
.schematic-cta--ghost {
|
|
3718
4431
|
background: transparent;
|
|
3719
4432
|
border-color: color-mix(in srgb, var(--schematic-text) 20%, transparent);
|
|
@@ -3741,19 +4454,15 @@ var rulesCss = `
|
|
|
3741
4454
|
text-decoration: underline;
|
|
3742
4455
|
}
|
|
3743
4456
|
|
|
3744
|
-
/* Every toggle's chevron: the 24px glyph, muted. */
|
|
3745
4457
|
.schematic-chevron {
|
|
3746
4458
|
color: var(--schematic-muted);
|
|
3747
4459
|
font-size: 1.5rem;
|
|
3748
4460
|
}
|
|
3749
4461
|
|
|
3750
|
-
/* A toggle underlines its label alone: a flex container hands its underline
|
|
3751
|
-
to every item, the chevron included, and an item cannot take it off. */
|
|
3752
4462
|
.schematic-link-button:has(.schematic-link-button__label):hover {
|
|
3753
4463
|
text-decoration: none;
|
|
3754
4464
|
}
|
|
3755
4465
|
|
|
3756
|
-
/* The reset colours every schematic- element; the label keeps the link's. */
|
|
3757
4466
|
.schematic-link-button__label {
|
|
3758
4467
|
color: inherit;
|
|
3759
4468
|
}
|
|
@@ -3854,7 +4563,6 @@ var rulesCss = `
|
|
|
3854
4563
|
margin: 0;
|
|
3855
4564
|
}
|
|
3856
4565
|
|
|
3857
|
-
/* A label on the left, its value on the right. */
|
|
3858
4566
|
.schematic-row {
|
|
3859
4567
|
align-items: flex-start;
|
|
3860
4568
|
display: flex;
|
|
@@ -4063,6 +4771,9 @@ ${tooltipCss}
|
|
|
4063
4771
|
${includedFeaturesCss}
|
|
4064
4772
|
${meteredFeaturesCss}
|
|
4065
4773
|
${creditUsageCss}
|
|
4774
|
+
${planManagerCss}
|
|
4775
|
+
${unsubscribeCss}
|
|
4776
|
+
${cardGroupCss}
|
|
4066
4777
|
`;
|
|
4067
4778
|
var schematicStylesCss = withTokenDefaults(rulesCss) + iconsCss;
|
|
4068
4779
|
var SchematicStyles = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { "data-schematic-styles": "", children: schematicStylesCss });
|
|
@@ -4167,8 +4878,9 @@ var StatusFrame = ({
|
|
|
4167
4878
|
skeleton = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "schematic-skeleton" })
|
|
4168
4879
|
}) => {
|
|
4169
4880
|
useReportHiddenError(error, errorMessage);
|
|
4881
|
+
const root = cx("schematic-element", className);
|
|
4170
4882
|
if (error !== void 0 && !hasData) {
|
|
4171
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className, "data-state": "error", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "schematic-status", role: "alert", children: [
|
|
4883
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: root, "data-state": "error", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "schematic-status", role: "alert", children: [
|
|
4172
4884
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "schematic-error schematic-status__message", children: errorMessage ?? error.message }),
|
|
4173
4885
|
onRetry !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
4174
4886
|
"button",
|
|
@@ -4182,12 +4894,12 @@ var StatusFrame = ({
|
|
|
4182
4894
|
] }) });
|
|
4183
4895
|
}
|
|
4184
4896
|
if (isPending && !hasData) {
|
|
4185
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "aria-busy": "true", className, "data-state": "pending", children: [
|
|
4897
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { "aria-busy": "true", className: root, "data-state": "pending", children: [
|
|
4186
4898
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "schematic-hidden", children: loadingLabel }),
|
|
4187
4899
|
skeleton
|
|
4188
4900
|
] });
|
|
4189
4901
|
}
|
|
4190
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className, "data-state": "ready", children: [
|
|
4902
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: root, "data-state": "ready", children: [
|
|
4191
4903
|
children,
|
|
4192
4904
|
error !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "schematic-status-note schematic-error", role: "alert", children: errorMessage ?? error.message })
|
|
4193
4905
|
] });
|
|
@@ -5368,7 +6080,7 @@ function PriceDetails({
|
|
|
5368
6080
|
const period = details.period === null ? void 0 : shortPeriod(details.period, t);
|
|
5369
6081
|
if (details.kind === "overage") {
|
|
5370
6082
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "schematic-metered-features__price-details", children: [
|
|
5371
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
|
|
6083
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "schematic-metered-features__price-label", children: [
|
|
5372
6084
|
t("meteredFeaturesAdditional"),
|
|
5373
6085
|
": ",
|
|
5374
6086
|
details.unitPrice,
|
|
@@ -5379,7 +6091,7 @@ function PriceDetails({
|
|
|
5379
6091
|
period !== void 0 && `/${period}`
|
|
5380
6092
|
] })
|
|
5381
6093
|
] }),
|
|
5382
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
|
|
6094
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "schematic-metered-features__price-cost", children: [
|
|
5383
6095
|
details.overage.amount,
|
|
5384
6096
|
" ",
|
|
5385
6097
|
details.overage.units,
|
|
@@ -5393,7 +6105,7 @@ function PriceDetails({
|
|
|
5393
6105
|
] });
|
|
5394
6106
|
}
|
|
5395
6107
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "schematic-metered-features__price-details", children: [
|
|
5396
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
|
|
6108
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "schematic-metered-features__price-label", children: [
|
|
5397
6109
|
t("meteredFeaturesTier"),
|
|
5398
6110
|
": ",
|
|
5399
6111
|
details.from,
|
|
@@ -5411,7 +6123,7 @@ function PriceDetails({
|
|
|
5411
6123
|
}
|
|
5412
6124
|
) })
|
|
5413
6125
|
] }),
|
|
5414
|
-
details.cost !== null && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
|
|
6126
|
+
details.cost !== null && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "schematic-metered-features__price-cost", children: [
|
|
5415
6127
|
details.cost,
|
|
5416
6128
|
period !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("sub", { children: [
|
|
5417
6129
|
"/",
|
|
@@ -5855,33 +6567,793 @@ function FormSkeleton({ label }) {
|
|
|
5855
6567
|
}
|
|
5856
6568
|
PaymentMethods.resources = ["paymentMethods"];
|
|
5857
6569
|
|
|
5858
|
-
// src/elements/
|
|
6570
|
+
// src/elements/PlanManager.tsx
|
|
5859
6571
|
var import_schematic_react8 = require("@schematichq/schematic-react");
|
|
5860
6572
|
var import_react9 = require("react");
|
|
5861
6573
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
5862
|
-
|
|
6574
|
+
var VISIBLE_CREDIT_COUNT = 3;
|
|
6575
|
+
var UNIT_KEY = {
|
|
6576
|
+
day: "planManagerDays",
|
|
6577
|
+
hour: "planManagerHours",
|
|
6578
|
+
minute: "planManagerMinutes"
|
|
6579
|
+
};
|
|
6580
|
+
var PERIOD_KEY = {
|
|
6581
|
+
day: "periodDay",
|
|
6582
|
+
month: "periodMonth",
|
|
6583
|
+
quarter: "periodQuarter",
|
|
6584
|
+
week: "periodWeek",
|
|
6585
|
+
year: "periodYear"
|
|
6586
|
+
};
|
|
6587
|
+
function PlanManager({
|
|
6588
|
+
changePlanTarget,
|
|
6589
|
+
changePlanUrl,
|
|
5863
6590
|
className,
|
|
6591
|
+
editAutoTopupTarget,
|
|
6592
|
+
editAutoTopupUrl,
|
|
5864
6593
|
headingLevel = 2,
|
|
5865
6594
|
locale: localeProp,
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
6595
|
+
onChangePlan,
|
|
6596
|
+
onEditAutoTopup,
|
|
6597
|
+
showAddOns = true,
|
|
6598
|
+
showCredits = true,
|
|
6599
|
+
showDescription = true,
|
|
6600
|
+
showHardLimit = false,
|
|
5869
6601
|
showHeader = true,
|
|
6602
|
+
showLabels = true,
|
|
6603
|
+
showNotice = true,
|
|
6604
|
+
showPrice = true,
|
|
6605
|
+
showUsageBased = true,
|
|
6606
|
+
showWarningThresholdAsLimit = false,
|
|
6607
|
+
showZeroPriceAsFree = false,
|
|
5870
6608
|
strings
|
|
5871
6609
|
}) {
|
|
5872
|
-
const
|
|
6610
|
+
const company = (0, import_schematic_react8.useCompany)();
|
|
6611
|
+
const usage = (0, import_schematic_react8.useFeatureUsage)();
|
|
6612
|
+
const credits = (0, import_schematic_react8.useCreditBalances)();
|
|
5873
6613
|
const locale = useResolvedLocale(localeProp);
|
|
5874
6614
|
const t = useTranslator(strings, localeProp);
|
|
5875
|
-
const
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
6615
|
+
const creditsFailed = credits.data === void 0 && credits.error !== void 0;
|
|
6616
|
+
const [creditsHaveFailed, setCreditsHaveFailed] = (0, import_react9.useState)(false);
|
|
6617
|
+
if (creditsFailed && !creditsHaveFailed) {
|
|
6618
|
+
setCreditsHaveFailed(true);
|
|
6619
|
+
} else if (!creditsFailed && creditsHaveFailed && (credits.data !== void 0 || company.data === void 0 || usage.data === void 0)) {
|
|
6620
|
+
setCreditsHaveFailed(false);
|
|
6621
|
+
}
|
|
6622
|
+
const creditsSettled = !showCredits || credits.data !== void 0 || creditsHaveFailed;
|
|
6623
|
+
const view = (0, import_react9.useMemo)(
|
|
6624
|
+
() => company.data === void 0 || usage.data === void 0 || !creditsSettled ? void 0 : derivePlanManager(
|
|
6625
|
+
{
|
|
6626
|
+
company: company.data,
|
|
6627
|
+
creditBalances: credits.data ?? [],
|
|
6628
|
+
featureUsage: usage.data
|
|
6629
|
+
},
|
|
6630
|
+
{
|
|
6631
|
+
locale,
|
|
6632
|
+
showCredits,
|
|
6633
|
+
showWarningThresholdAsLimit,
|
|
6634
|
+
showZeroPriceAsFree
|
|
6635
|
+
}
|
|
6636
|
+
),
|
|
6637
|
+
[
|
|
6638
|
+
company.data,
|
|
6639
|
+
credits.data,
|
|
6640
|
+
creditsSettled,
|
|
6641
|
+
locale,
|
|
6642
|
+
showCredits,
|
|
6643
|
+
showWarningThresholdAsLimit,
|
|
6644
|
+
showZeroPriceAsFree,
|
|
6645
|
+
usage.data
|
|
6646
|
+
]
|
|
6647
|
+
);
|
|
6648
|
+
const creditsRefetchError = showCredits && credits.data !== void 0 ? credits.error : void 0;
|
|
6649
|
+
const cardError = company.error ?? usage.error;
|
|
6650
|
+
const error = cardError ?? creditsRefetchError;
|
|
6651
|
+
const unavailable = view === void 0 && httpStatus(error) === 404;
|
|
6652
|
+
const errorMessage = error === void 0 ? void 0 : unavailable ? t("planManagerUnavailable") : cardError === void 0 ? t("planManagerCreditsError") : t("planManagerError");
|
|
6653
|
+
const retry = () => {
|
|
6654
|
+
for (const handle of showCredits ? [company, usage, credits] : [company, usage]) {
|
|
6655
|
+
if (handle.error !== void 0) {
|
|
6656
|
+
handle.refetch();
|
|
6657
|
+
}
|
|
6658
|
+
}
|
|
6659
|
+
};
|
|
6660
|
+
const Heading = `h${headingLevel}`;
|
|
6661
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6662
|
+
StatusFrame,
|
|
6663
|
+
{
|
|
6664
|
+
className: cx("schematic-plan-manager", className),
|
|
6665
|
+
error,
|
|
6666
|
+
errorMessage,
|
|
6667
|
+
hasData: view !== void 0,
|
|
6668
|
+
isPending: company.isPending || usage.isPending || credits.isPending,
|
|
6669
|
+
loadingLabel: t("planManagerLoading"),
|
|
6670
|
+
onRetry: retry,
|
|
6671
|
+
retryText: t("retry"),
|
|
6672
|
+
skeleton: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PlanManagerSkeleton, {}),
|
|
6673
|
+
children: view !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
6674
|
+
showNotice && view.notice !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Notice, { locale, notice: view.notice, t }),
|
|
6675
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "schematic-card schematic-plan-manager__card", children: [
|
|
6676
|
+
showHeader && view.plan !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "schematic-plan-manager__plan", children: [
|
|
6677
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "schematic-plan-manager__title", children: [
|
|
6678
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Heading, { className: "schematic-plan-manager__name", children: view.plan.name }),
|
|
6679
|
+
showDescription && view.plan.description !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "schematic-plan-manager__description", children: view.plan.description })
|
|
6680
|
+
] }),
|
|
6681
|
+
showPrice && view.plan.price !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Price, { price: view.plan.price, t })
|
|
6682
|
+
] }),
|
|
6683
|
+
showAddOns && view.addOns.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Section, { label: t("planManagerAddOns"), showLabel: showLabels, children: view.addOns.map((addOn) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("li", { className: "schematic-plan-manager__row", children: [
|
|
6684
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-plan-manager__item", children: addOn.name }),
|
|
6685
|
+
addOn.price !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: "schematic-plan-manager__price-value", children: [
|
|
6686
|
+
addOn.price.amount,
|
|
6687
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PeriodSuffix, { period: addOn.price.period, t })
|
|
6688
|
+
] })
|
|
6689
|
+
] }, addOn.id)) }),
|
|
6690
|
+
showUsageBased && view.usageBased.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6691
|
+
Section,
|
|
6692
|
+
{
|
|
6693
|
+
label: t("planManagerUsageBased"),
|
|
6694
|
+
showLabel: showLabels,
|
|
6695
|
+
children: view.usageBased.map((row) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6696
|
+
UsageBasedItem,
|
|
6697
|
+
{
|
|
6698
|
+
locale,
|
|
6699
|
+
row,
|
|
6700
|
+
showHardLimit,
|
|
6701
|
+
t
|
|
6702
|
+
},
|
|
6703
|
+
row.featureId
|
|
6704
|
+
))
|
|
6705
|
+
}
|
|
6706
|
+
),
|
|
6707
|
+
showCredits && credits.data === void 0 && creditsHaveFailed && (credits.error !== void 0 || credits.isPending) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6708
|
+
StatusFrame,
|
|
6709
|
+
{
|
|
6710
|
+
className: "schematic-plan-manager__section",
|
|
6711
|
+
error: credits.error,
|
|
6712
|
+
errorMessage: t("planManagerCreditsError"),
|
|
6713
|
+
hasData: false,
|
|
6714
|
+
isPending: credits.isPending,
|
|
6715
|
+
loadingLabel: t("planManagerCreditsLoading"),
|
|
6716
|
+
onRetry: credits.refetch,
|
|
6717
|
+
retryText: t("retry"),
|
|
6718
|
+
children: null
|
|
6719
|
+
}
|
|
6720
|
+
),
|
|
6721
|
+
showCredits && view.planCredits.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6722
|
+
Truncated,
|
|
6723
|
+
{
|
|
6724
|
+
locale,
|
|
6725
|
+
after: view.autoTopup !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6726
|
+
AutoTopupBox,
|
|
6727
|
+
{
|
|
6728
|
+
lines: view.autoTopup.lines,
|
|
6729
|
+
onEdit: onEditAutoTopup,
|
|
6730
|
+
t,
|
|
6731
|
+
target: editAutoTopupTarget,
|
|
6732
|
+
url: editAutoTopupUrl
|
|
6733
|
+
}
|
|
6734
|
+
),
|
|
6735
|
+
label: t("planManagerCreditsInPlan"),
|
|
6736
|
+
rows: view.planCredits,
|
|
6737
|
+
showLabel: showLabels,
|
|
6738
|
+
t,
|
|
6739
|
+
children: (row) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PlanCreditItem, { row, t }, row.creditId)
|
|
6740
|
+
}
|
|
6741
|
+
),
|
|
6742
|
+
showCredits && view.topUps.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6743
|
+
Truncated,
|
|
6744
|
+
{
|
|
6745
|
+
locale,
|
|
6746
|
+
label: t("planManagerTopUps"),
|
|
6747
|
+
rows: view.topUps,
|
|
6748
|
+
showLabel: showLabels,
|
|
6749
|
+
t,
|
|
6750
|
+
children: (row) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CreditGroupItem, { countAlways: true, row, t }, row.key)
|
|
6751
|
+
}
|
|
6752
|
+
),
|
|
6753
|
+
showCredits && view.bundles.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6754
|
+
Truncated,
|
|
6755
|
+
{
|
|
6756
|
+
locale,
|
|
6757
|
+
label: t("planManagerCreditBundles"),
|
|
6758
|
+
rows: view.bundles,
|
|
6759
|
+
showLabel: showLabels,
|
|
6760
|
+
t,
|
|
6761
|
+
children: (row) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CreditGroupItem, { row, t }, row.key)
|
|
6762
|
+
}
|
|
6763
|
+
),
|
|
6764
|
+
showCredits && view.promotional.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6765
|
+
Truncated,
|
|
6766
|
+
{
|
|
6767
|
+
locale,
|
|
6768
|
+
label: t("planManagerPromotionalCredits"),
|
|
6769
|
+
rows: view.promotional,
|
|
6770
|
+
showLabel: showLabels,
|
|
6771
|
+
t,
|
|
6772
|
+
children: (row) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CreditGroupItem, { plain: true, row, t }, row.key)
|
|
6773
|
+
}
|
|
6774
|
+
),
|
|
6775
|
+
view.canChangePlan && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6776
|
+
Cta,
|
|
6777
|
+
{
|
|
6778
|
+
className: "schematic-cta schematic-plan-manager__change-plan",
|
|
6779
|
+
label: t("planManagerChangePlan"),
|
|
6780
|
+
onClick: onChangePlan,
|
|
6781
|
+
target: changePlanTarget,
|
|
6782
|
+
url: changePlanUrl
|
|
6783
|
+
}
|
|
6784
|
+
)
|
|
6785
|
+
] })
|
|
6786
|
+
] })
|
|
6787
|
+
}
|
|
6788
|
+
);
|
|
6789
|
+
}
|
|
6790
|
+
function Notice({
|
|
6791
|
+
locale,
|
|
6792
|
+
notice: notice2,
|
|
6793
|
+
t
|
|
6794
|
+
}) {
|
|
6795
|
+
let title = null;
|
|
6796
|
+
let body = null;
|
|
6797
|
+
let payUrl = null;
|
|
6798
|
+
switch (notice2.kind) {
|
|
6799
|
+
case "trial":
|
|
6800
|
+
title = notice2.endsIn === null ? null : notice2.endsIn === "soon" ? t("planManagerTrialEndsSoon") : notice2.endsIn === "ended" ? t("planManagerTrialEnded") : t("planManagerTrialEndsIn", {
|
|
6801
|
+
amount: formatNumber(notice2.endsIn.amount, locale),
|
|
6802
|
+
units: t(UNIT_KEY[notice2.endsIn.unit], {
|
|
6803
|
+
count: notice2.endsIn.amount
|
|
6804
|
+
})
|
|
6805
|
+
});
|
|
6806
|
+
break;
|
|
6807
|
+
case "canceled":
|
|
6808
|
+
title = t("planManagerCanceled");
|
|
6809
|
+
body = notice2.date === null ? null : t("planManagerAccessEnds", {
|
|
6810
|
+
date: notice2.date,
|
|
6811
|
+
plan: notice2.planName ?? t("planManagerPlanFallback")
|
|
6812
|
+
});
|
|
6813
|
+
break;
|
|
6814
|
+
case "customPlanBilling": {
|
|
6815
|
+
const plan = notice2.planName ?? t("planManagerYourPlan");
|
|
6816
|
+
title = notice2.awaitingActivation ? t("planManagerCustomAwaiting", { plan }) : t("planManagerCustomDue", { date: notice2.date, plan });
|
|
6817
|
+
body = notice2.awaitingActivation ? t("planManagerCustomAwaitingDescription", { date: notice2.date }) : t("planManagerCustomDueDescription", { date: notice2.date, plan });
|
|
6818
|
+
payUrl = notice2.invoiceUrl;
|
|
6819
|
+
break;
|
|
6820
|
+
}
|
|
6821
|
+
case "scheduledDowngrade":
|
|
6822
|
+
title = t("planManagerDowngradeScheduled", { plan: notice2.toPlanName });
|
|
6823
|
+
body = notice2.date === null ? null : t("planManagerAccessEnds", {
|
|
6824
|
+
date: notice2.date,
|
|
6825
|
+
plan: notice2.fromPlanName
|
|
6826
|
+
});
|
|
6827
|
+
break;
|
|
6828
|
+
}
|
|
6829
|
+
if (title === null && body === null) {
|
|
6830
|
+
return null;
|
|
6831
|
+
}
|
|
6832
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
6833
|
+
"div",
|
|
6834
|
+
{
|
|
6835
|
+
className: "schematic-plan-manager__notice",
|
|
6836
|
+
"data-kind": notice2.kind,
|
|
6837
|
+
role: "status",
|
|
6838
|
+
children: [
|
|
6839
|
+
title !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "schematic-plan-manager__notice-title", children: title }),
|
|
6840
|
+
body !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "schematic-small schematic-plan-manager__notice-body", children: body }),
|
|
6841
|
+
payUrl !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6842
|
+
"a",
|
|
6843
|
+
{
|
|
6844
|
+
className: "schematic-cta schematic-plan-manager__pay-now",
|
|
6845
|
+
href: payUrl,
|
|
6846
|
+
rel: "noreferrer",
|
|
6847
|
+
target: "_blank",
|
|
6848
|
+
children: t("planManagerPayNow")
|
|
6849
|
+
}
|
|
6850
|
+
)
|
|
6851
|
+
]
|
|
6852
|
+
}
|
|
6853
|
+
);
|
|
6854
|
+
}
|
|
6855
|
+
function Price({ price, t }) {
|
|
6856
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "schematic-plan-manager__price", children: [
|
|
6857
|
+
price.kind === "usageBased" ? t("planManagerUsageBased") : price.kind === "free" ? t("planManagerFree") : price.amount,
|
|
6858
|
+
price.kind === "amount" && price.period !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PeriodSuffix, { period: price.period, t })
|
|
6859
|
+
] });
|
|
6860
|
+
}
|
|
6861
|
+
function PeriodSuffix({ period, t }) {
|
|
6862
|
+
const short = shortPeriod(period, t);
|
|
6863
|
+
return short === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("sub", { children: [
|
|
6864
|
+
"/",
|
|
6865
|
+
short
|
|
6866
|
+
] });
|
|
6867
|
+
}
|
|
6868
|
+
function Section({
|
|
6869
|
+
children,
|
|
6870
|
+
label,
|
|
6871
|
+
showLabel
|
|
6872
|
+
}) {
|
|
6873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { "aria-label": label, className: "schematic-plan-manager__section", children: [
|
|
6874
|
+
showLabel && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-muted schematic-plan-manager__label", children: label }),
|
|
6875
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { className: "schematic-plan-manager__rows", children })
|
|
6876
|
+
] });
|
|
6877
|
+
}
|
|
6878
|
+
function Truncated({
|
|
6879
|
+
after,
|
|
6880
|
+
children,
|
|
6881
|
+
label,
|
|
6882
|
+
locale,
|
|
6883
|
+
rows,
|
|
6884
|
+
showLabel,
|
|
6885
|
+
t
|
|
6886
|
+
}) {
|
|
6887
|
+
const [expanded, setExpanded] = (0, import_react9.useState)(false);
|
|
6888
|
+
const shown = expanded ? rows : rows.slice(0, VISIBLE_CREDIT_COUNT);
|
|
6889
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { "aria-label": label, className: "schematic-plan-manager__section", children: [
|
|
6890
|
+
showLabel && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-muted schematic-plan-manager__label", children: label }),
|
|
6891
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { className: "schematic-plan-manager__rows", children: shown.map(children) }),
|
|
6892
|
+
rows.length > VISIBLE_CREDIT_COUNT && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
6893
|
+
"button",
|
|
6894
|
+
{
|
|
6895
|
+
"aria-expanded": expanded,
|
|
6896
|
+
className: "schematic-link-button schematic-plan-manager__see-all",
|
|
6897
|
+
type: "button",
|
|
6898
|
+
onClick: () => setExpanded((value) => !value),
|
|
6899
|
+
children: [
|
|
6900
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6901
|
+
"i",
|
|
6902
|
+
{
|
|
6903
|
+
"aria-hidden": "true",
|
|
6904
|
+
className: `schematic-icon schematic-icon--${expanded ? "chevron-up" : "chevron-down"} schematic-chevron`
|
|
6905
|
+
}
|
|
6906
|
+
),
|
|
6907
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-link-button__label", children: expanded ? t("planManagerHideAll") : t("planManagerSeeAll", {
|
|
6908
|
+
total: formatNumber(rows.length, locale)
|
|
6909
|
+
}) })
|
|
6910
|
+
]
|
|
6911
|
+
}
|
|
6912
|
+
),
|
|
6913
|
+
after
|
|
6914
|
+
] });
|
|
6915
|
+
}
|
|
6916
|
+
function UsageBasedItem({
|
|
6917
|
+
locale,
|
|
6918
|
+
row,
|
|
6919
|
+
showHardLimit,
|
|
6920
|
+
t
|
|
6921
|
+
}) {
|
|
6922
|
+
const details = [];
|
|
6923
|
+
if (row.additional) {
|
|
6924
|
+
details.push(`${t("planManagerAdditional")}: `);
|
|
6925
|
+
}
|
|
6926
|
+
if (row.tierBased) {
|
|
6927
|
+
details.push(t("planManagerTierBased"));
|
|
6928
|
+
}
|
|
6929
|
+
if (row.unitPrice !== null) {
|
|
6930
|
+
const short = row.unitPrice.period === null ? void 0 : shortPeriod(row.unitPrice.period, t);
|
|
6931
|
+
details.push(
|
|
6932
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { children: [
|
|
6933
|
+
row.unitPrice.cost,
|
|
6934
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("sub", { children: [
|
|
6935
|
+
"/",
|
|
6936
|
+
row.unitPrice.packageSize !== null && `${row.unitPrice.packageSize} `,
|
|
6937
|
+
row.unitPrice.units,
|
|
6938
|
+
short !== void 0 && `/${short}`
|
|
6939
|
+
] })
|
|
6940
|
+
] }, "price")
|
|
6941
|
+
);
|
|
6942
|
+
}
|
|
6943
|
+
if (row.perUse !== null) {
|
|
6944
|
+
details.push(
|
|
6945
|
+
t("usagePerUse", { amount: row.perUse.amount, units: row.perUse.units })
|
|
6946
|
+
);
|
|
6947
|
+
}
|
|
6948
|
+
const costPeriod = row.cost?.period === null || row.cost === null ? void 0 : shortPeriod(row.cost.period, t);
|
|
6949
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
6950
|
+
"li",
|
|
6951
|
+
{
|
|
6952
|
+
className: "schematic-plan-manager__row",
|
|
6953
|
+
"data-testid": "schematic-usage-based",
|
|
6954
|
+
children: [
|
|
6955
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-plan-manager__item", children: row.quantity === null ? row.name : `${row.quantity.amount} ${row.quantity.units}` }),
|
|
6956
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: "schematic-plan-manager__detail", children: [
|
|
6957
|
+
details.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-muted schematic-small", children: details }),
|
|
6958
|
+
row.cost !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { children: [
|
|
6959
|
+
row.cost.amount,
|
|
6960
|
+
costPeriod !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("sub", { children: [
|
|
6961
|
+
"/",
|
|
6962
|
+
costPeriod
|
|
6963
|
+
] })
|
|
6964
|
+
] }),
|
|
6965
|
+
row.tiers !== null && row.tiers.ranges.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Tooltip, { label: t("usageTieredPricingLabel"), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
6966
|
+
PriceTiers,
|
|
6967
|
+
{
|
|
6968
|
+
currency: row.tiers.currency,
|
|
6969
|
+
locale,
|
|
6970
|
+
mode: row.tiers.mode,
|
|
6971
|
+
period: row.tiers.period,
|
|
6972
|
+
ranges: row.tiers.ranges,
|
|
6973
|
+
t,
|
|
6974
|
+
unit: row.tiers.unit
|
|
6975
|
+
}
|
|
6976
|
+
) }),
|
|
6977
|
+
showHardLimit && row.hardLimit !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Tooltip, { label: t("usageHardLimitLabel"), children: t("usageHardLimit", {
|
|
6978
|
+
amount: row.hardLimit.amount,
|
|
6979
|
+
units: row.hardLimit.units
|
|
6980
|
+
}) })
|
|
6981
|
+
] })
|
|
6982
|
+
]
|
|
6983
|
+
}
|
|
6984
|
+
);
|
|
6985
|
+
}
|
|
6986
|
+
function PlanCreditItem({ row, t }) {
|
|
6987
|
+
const text = row.text;
|
|
6988
|
+
const composition = row.composition;
|
|
6989
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
6990
|
+
"li",
|
|
6991
|
+
{
|
|
6992
|
+
className: "schematic-plan-manager__row schematic-plan-manager__row--stacked",
|
|
6993
|
+
"data-testid": "schematic-plan-credit",
|
|
6994
|
+
children: [
|
|
6995
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "schematic-plan-manager__row-main", children: [
|
|
6996
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-plan-manager__item", children: text.kind === "perLicense" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
6997
|
+
t("planManagerCreditsPerLicense", {
|
|
6998
|
+
amount: text.amount,
|
|
6999
|
+
creditName: text.creditName,
|
|
7000
|
+
licenseName: text.licenseName
|
|
7001
|
+
}),
|
|
7002
|
+
text.plus !== null && ` ${t("planManagerCreditsPlusPerPeriod", {
|
|
7003
|
+
amount: text.plus.amount,
|
|
7004
|
+
creditName: text.plus.creditName,
|
|
7005
|
+
period: periodWord(text.plus.period, t)
|
|
7006
|
+
})}`
|
|
7007
|
+
] }) : text.period === null ? t("planManagerCredits", {
|
|
7008
|
+
amount: text.amount,
|
|
7009
|
+
creditName: text.creditName
|
|
7010
|
+
}) : t("planManagerCreditsPerPeriod", {
|
|
7011
|
+
amount: text.amount,
|
|
7012
|
+
creditName: text.creditName,
|
|
7013
|
+
period: periodWord(text.period, t)
|
|
7014
|
+
}) }),
|
|
7015
|
+
row.used !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: "schematic-muted schematic-small schematic-plan-manager__used", children: [
|
|
7016
|
+
t("planManagerUsed", { amount: row.used }),
|
|
7017
|
+
row.autoTopup !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Tooltip, { label: t("planManagerAutoTopup"), children: t("planManagerAutoTopupTip", {
|
|
7018
|
+
amount: row.autoTopup.amount,
|
|
7019
|
+
threshold: row.autoTopup.threshold
|
|
7020
|
+
}) })
|
|
7021
|
+
] })
|
|
7022
|
+
] }),
|
|
7023
|
+
composition !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-muted schematic-small", children: t(
|
|
7024
|
+
composition.fixed === null ? "planManagerLicensesTimesCredits" : "planManagerLicensesTimesCreditsPlusCompany",
|
|
7025
|
+
{
|
|
7026
|
+
creditName: composition.creditName,
|
|
7027
|
+
fixed: composition.fixed ?? void 0,
|
|
7028
|
+
licenseName: composition.licenseName,
|
|
7029
|
+
period: shortPeriod(composition.period, t) ?? periodWord(composition.period, t),
|
|
7030
|
+
perUnit: composition.perUnit,
|
|
7031
|
+
quantity: composition.quantity,
|
|
7032
|
+
total: composition.total
|
|
7033
|
+
}
|
|
7034
|
+
) })
|
|
7035
|
+
]
|
|
7036
|
+
}
|
|
7037
|
+
);
|
|
7038
|
+
}
|
|
7039
|
+
function CreditGroupItem({
|
|
7040
|
+
countAlways = false,
|
|
7041
|
+
plain = false,
|
|
7042
|
+
row,
|
|
7043
|
+
t
|
|
7044
|
+
}) {
|
|
7045
|
+
const named = !plain && row.bundleName !== null;
|
|
7046
|
+
const showCount = !plain && row.count > 1 && (named || countAlways);
|
|
7047
|
+
const amount = `${row.quantity} ${row.creditName}`;
|
|
7048
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
7049
|
+
"li",
|
|
7050
|
+
{
|
|
7051
|
+
className: "schematic-plan-manager__row",
|
|
7052
|
+
"data-testid": "schematic-credit-group",
|
|
7053
|
+
children: [
|
|
7054
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: "schematic-plan-manager__item", children: [
|
|
7055
|
+
showCount && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: "schematic-muted", children: [
|
|
7056
|
+
"(",
|
|
7057
|
+
row.count,
|
|
7058
|
+
") "
|
|
7059
|
+
] }),
|
|
7060
|
+
named ? `${row.bundleName} (${amount})` : amount
|
|
7061
|
+
] }),
|
|
7062
|
+
row.used !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-muted schematic-small schematic-plan-manager__used", children: t("planManagerUsed", { amount: row.used }) })
|
|
7063
|
+
]
|
|
7064
|
+
}
|
|
7065
|
+
);
|
|
7066
|
+
}
|
|
7067
|
+
function AutoTopupBox({
|
|
7068
|
+
lines,
|
|
7069
|
+
onEdit,
|
|
7070
|
+
t,
|
|
7071
|
+
target,
|
|
7072
|
+
url
|
|
7073
|
+
}) {
|
|
7074
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "schematic-plan-manager__auto-topup", children: [
|
|
7075
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "schematic-plan-manager__auto-topup-lines", children: [
|
|
7076
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-plan-manager__item", children: t("planManagerAutoTopup") }),
|
|
7077
|
+
lines.map((line) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: line.kind === "disabled" ? t("planManagerAutoTopupDisabled", { unit: line.unit }) : t("planManagerAutoTopupAdds", {
|
|
7078
|
+
amount: line.amount,
|
|
7079
|
+
threshold: line.threshold,
|
|
7080
|
+
unit: line.unit
|
|
7081
|
+
}) }, line.creditId))
|
|
7082
|
+
] }),
|
|
7083
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
7084
|
+
Cta,
|
|
7085
|
+
{
|
|
7086
|
+
className: "schematic-cta schematic-cta--small schematic-cta--ghost schematic-plan-manager__edit",
|
|
7087
|
+
label: t("planManagerEdit"),
|
|
7088
|
+
onClick: onEdit,
|
|
7089
|
+
target,
|
|
7090
|
+
url
|
|
7091
|
+
}
|
|
7092
|
+
)
|
|
7093
|
+
] });
|
|
7094
|
+
}
|
|
7095
|
+
function Cta({
|
|
7096
|
+
className,
|
|
7097
|
+
label,
|
|
7098
|
+
onClick,
|
|
7099
|
+
target,
|
|
7100
|
+
url
|
|
7101
|
+
}) {
|
|
7102
|
+
if (onClick !== void 0) {
|
|
7103
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { className, type: "button", onClick, children: label });
|
|
7104
|
+
}
|
|
7105
|
+
if (url !== void 0) {
|
|
7106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("a", { className, href: url, target, children: label });
|
|
7107
|
+
}
|
|
7108
|
+
return null;
|
|
7109
|
+
}
|
|
7110
|
+
function periodWord(period, t) {
|
|
7111
|
+
const key = PERIOD_KEY[period];
|
|
7112
|
+
return key === void 0 ? period : t(key);
|
|
7113
|
+
}
|
|
7114
|
+
function PlanManagerSkeleton() {
|
|
7115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "schematic-skeleton", children: [
|
|
7116
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "schematic-skeleton__heading" }),
|
|
7117
|
+
[0, 1].map((index) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "schematic-skeleton__row", children: [
|
|
7118
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "name" }),
|
|
7119
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "price" })
|
|
7120
|
+
] }, index))
|
|
7121
|
+
] });
|
|
7122
|
+
}
|
|
7123
|
+
PlanManager.resources = ["company", "featureUsage", "creditBalances"];
|
|
7124
|
+
|
|
7125
|
+
// src/elements/UnsubscribeButton.tsx
|
|
7126
|
+
var import_schematic_react9 = require("@schematichq/schematic-react");
|
|
7127
|
+
var import_react10 = require("react");
|
|
7128
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
7129
|
+
var TOTAL_KEY = {
|
|
7130
|
+
quarter: "unsubscribeQuarterlyTotal",
|
|
7131
|
+
year: "unsubscribeYearlyTotal"
|
|
7132
|
+
};
|
|
7133
|
+
function UnsubscribeButton({
|
|
7134
|
+
className,
|
|
7135
|
+
locale: localeProp,
|
|
7136
|
+
managePlanTarget,
|
|
7137
|
+
managePlanUrl,
|
|
7138
|
+
onManagePlan,
|
|
7139
|
+
onUnsubscribed,
|
|
7140
|
+
strings
|
|
7141
|
+
}) {
|
|
7142
|
+
const company = (0, import_schematic_react9.useCompany)();
|
|
7143
|
+
const usage = (0, import_schematic_react9.useFeatureUsage)();
|
|
7144
|
+
const { isMutating, unsubscribe } = (0, import_schematic_react9.useUnsubscribe)();
|
|
7145
|
+
const locale = useResolvedLocale(localeProp);
|
|
7146
|
+
const t = useTranslator(strings, localeProp);
|
|
7147
|
+
const [open, setOpen] = (0, import_react10.useState)(false);
|
|
7148
|
+
const [failed, setFailed] = (0, import_react10.useState)(false);
|
|
7149
|
+
const view = (0, import_react10.useMemo)(
|
|
7150
|
+
() => company.data === void 0 || usage.data === void 0 ? void 0 : deriveUnsubscribe(company.data, usage.data, { locale }),
|
|
7151
|
+
[company.data, locale, usage.data]
|
|
7152
|
+
);
|
|
7153
|
+
if (view === void 0) {
|
|
7154
|
+
const error = company.error ?? usage.error;
|
|
7155
|
+
if (error === void 0) {
|
|
7156
|
+
return null;
|
|
7157
|
+
}
|
|
7158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
7159
|
+
StatusFrame,
|
|
7160
|
+
{
|
|
7161
|
+
className: cx("schematic-card", "schematic-unsubscribe", className),
|
|
7162
|
+
error,
|
|
7163
|
+
errorMessage: httpStatus(error) === 404 ? t("unsubscribeUnavailable") : t("unsubscribeError"),
|
|
7164
|
+
hasData: false,
|
|
7165
|
+
isPending: false,
|
|
7166
|
+
loadingLabel: "",
|
|
7167
|
+
onRetry: () => {
|
|
7168
|
+
for (const handle of [company, usage]) {
|
|
7169
|
+
if (handle.error !== void 0) {
|
|
7170
|
+
handle.refetch();
|
|
7171
|
+
}
|
|
7172
|
+
}
|
|
7173
|
+
},
|
|
7174
|
+
retryText: t("retry"),
|
|
7175
|
+
children: null
|
|
7176
|
+
}
|
|
7177
|
+
);
|
|
7178
|
+
}
|
|
7179
|
+
if (!view.canUnsubscribe && !open) {
|
|
7180
|
+
return null;
|
|
7181
|
+
}
|
|
7182
|
+
const close = () => {
|
|
7183
|
+
setOpen(false);
|
|
7184
|
+
setFailed(false);
|
|
7185
|
+
};
|
|
7186
|
+
const confirm = async () => {
|
|
7187
|
+
setFailed(false);
|
|
7188
|
+
try {
|
|
7189
|
+
await unsubscribe();
|
|
7190
|
+
} catch {
|
|
7191
|
+
setFailed(true);
|
|
7192
|
+
return;
|
|
7193
|
+
}
|
|
7194
|
+
setOpen(false);
|
|
7195
|
+
onUnsubscribed?.();
|
|
7196
|
+
};
|
|
7197
|
+
const per = shortPeriod(view.period, t);
|
|
7198
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
7199
|
+
"div",
|
|
7200
|
+
{
|
|
7201
|
+
className: cx(
|
|
7202
|
+
"schematic-element",
|
|
7203
|
+
"schematic-card",
|
|
7204
|
+
"schematic-unsubscribe",
|
|
7205
|
+
className
|
|
7206
|
+
),
|
|
7207
|
+
children: [
|
|
7208
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
7209
|
+
"button",
|
|
7210
|
+
{
|
|
7211
|
+
className: "schematic-cta schematic-unsubscribe__open",
|
|
7212
|
+
type: "button",
|
|
7213
|
+
onClick: () => {
|
|
7214
|
+
setFailed(false);
|
|
7215
|
+
setOpen(true);
|
|
7216
|
+
},
|
|
7217
|
+
children: t("unsubscribeButton")
|
|
7218
|
+
}
|
|
7219
|
+
),
|
|
7220
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
7221
|
+
Dialog,
|
|
7222
|
+
{
|
|
7223
|
+
className: "schematic-unsubscribe__dialog",
|
|
7224
|
+
closeLabel: t("unsubscribeClose"),
|
|
7225
|
+
open,
|
|
7226
|
+
title: t("unsubscribeTitle"),
|
|
7227
|
+
onClose: close,
|
|
7228
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "schematic-unsubscribe__columns", children: [
|
|
7229
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "schematic-unsubscribe__summary", children: [
|
|
7230
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: t("unsubscribeAccessUntil", { date: view.accessEndsOn }) }),
|
|
7231
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
7232
|
+
ManagePlan,
|
|
7233
|
+
{
|
|
7234
|
+
onClick: onManagePlan,
|
|
7235
|
+
t,
|
|
7236
|
+
target: managePlanTarget,
|
|
7237
|
+
url: managePlanUrl
|
|
7238
|
+
}
|
|
7239
|
+
)
|
|
7240
|
+
] }),
|
|
7241
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "schematic-unsubscribe__sidebar", children: [
|
|
7242
|
+
view.plan !== null && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "schematic-unsubscribe__group", children: [
|
|
7243
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "schematic-muted schematic-small", children: t("unsubscribePlan") }),
|
|
7244
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "schematic-unsubscribe__line", children: [
|
|
7245
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "schematic-unsubscribe__name", children: view.plan.name }),
|
|
7246
|
+
view.plan.price !== null && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { children: [
|
|
7247
|
+
view.plan.price,
|
|
7248
|
+
per !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("sub", { children: [
|
|
7249
|
+
"/",
|
|
7250
|
+
per
|
|
7251
|
+
] })
|
|
7252
|
+
] })
|
|
7253
|
+
] })
|
|
7254
|
+
] }),
|
|
7255
|
+
view.addOns.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "schematic-unsubscribe__group", children: [
|
|
7256
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "schematic-muted schematic-small", children: t("unsubscribeAddOns") }),
|
|
7257
|
+
view.addOns.map((addOn) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "schematic-unsubscribe__line", children: [
|
|
7258
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "schematic-unsubscribe__name", children: addOn.name }),
|
|
7259
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { children: [
|
|
7260
|
+
addOn.price,
|
|
7261
|
+
!addOn.oneTime && per !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("sub", { children: [
|
|
7262
|
+
"/",
|
|
7263
|
+
per
|
|
7264
|
+
] })
|
|
7265
|
+
] })
|
|
7266
|
+
] }, addOn.id))
|
|
7267
|
+
] }),
|
|
7268
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "schematic-unsubscribe__line schematic-unsubscribe__total", children: [
|
|
7269
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "schematic-muted", children: t(TOTAL_KEY[view.period] ?? "unsubscribeMonthlyTotal") }),
|
|
7270
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { children: [
|
|
7271
|
+
view.total,
|
|
7272
|
+
per !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("sub", { children: [
|
|
7273
|
+
"/",
|
|
7274
|
+
per
|
|
7275
|
+
] })
|
|
7276
|
+
] })
|
|
7277
|
+
] }),
|
|
7278
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
7279
|
+
"button",
|
|
7280
|
+
{
|
|
7281
|
+
className: "schematic-cta schematic-unsubscribe__confirm",
|
|
7282
|
+
disabled: isMutating,
|
|
7283
|
+
type: "button",
|
|
7284
|
+
onClick: () => void confirm(),
|
|
7285
|
+
children: t("unsubscribeConfirm")
|
|
7286
|
+
}
|
|
7287
|
+
),
|
|
7288
|
+
failed && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "schematic-error", role: "alert", children: t("unsubscribeFailed") })
|
|
7289
|
+
] })
|
|
7290
|
+
] })
|
|
7291
|
+
}
|
|
7292
|
+
)
|
|
7293
|
+
]
|
|
7294
|
+
}
|
|
7295
|
+
);
|
|
7296
|
+
}
|
|
7297
|
+
function ManagePlan({
|
|
7298
|
+
onClick,
|
|
7299
|
+
t,
|
|
7300
|
+
target,
|
|
7301
|
+
url
|
|
7302
|
+
}) {
|
|
7303
|
+
if (onClick === void 0 && url === void 0) {
|
|
7304
|
+
return null;
|
|
7305
|
+
}
|
|
7306
|
+
const label = t("unsubscribeManagePlan");
|
|
7307
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "schematic-unsubscribe__manage", children: [
|
|
7308
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: t("unsubscribeNotReady") }),
|
|
7309
|
+
onClick !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
7310
|
+
"button",
|
|
7311
|
+
{
|
|
7312
|
+
className: "schematic-cta schematic-cta--small schematic-cta--ghost schematic-unsubscribe__manage-plan",
|
|
7313
|
+
type: "button",
|
|
7314
|
+
onClick,
|
|
7315
|
+
children: label
|
|
7316
|
+
}
|
|
7317
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
7318
|
+
"a",
|
|
7319
|
+
{
|
|
7320
|
+
className: "schematic-cta schematic-cta--small schematic-cta--ghost schematic-unsubscribe__manage-plan",
|
|
7321
|
+
href: url,
|
|
7322
|
+
target,
|
|
7323
|
+
children: label
|
|
7324
|
+
}
|
|
7325
|
+
)
|
|
7326
|
+
] });
|
|
7327
|
+
}
|
|
7328
|
+
UnsubscribeButton.resources = ["company", "featureUsage"];
|
|
7329
|
+
|
|
7330
|
+
// src/elements/UpcomingBill.tsx
|
|
7331
|
+
var import_schematic_react10 = require("@schematichq/schematic-react");
|
|
7332
|
+
var import_react11 = require("react");
|
|
7333
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
7334
|
+
function UpcomingBill({
|
|
7335
|
+
className,
|
|
7336
|
+
headingLevel = 2,
|
|
7337
|
+
locale: localeProp,
|
|
7338
|
+
showAmount = true,
|
|
7339
|
+
showBalance = true,
|
|
7340
|
+
showDiscounts = true,
|
|
7341
|
+
showHeader = true,
|
|
7342
|
+
strings
|
|
7343
|
+
}) {
|
|
7344
|
+
const { data: invoice, error, isPending, refetch } = (0, import_schematic_react10.useUpcomingInvoice)();
|
|
7345
|
+
const locale = useResolvedLocale(localeProp);
|
|
7346
|
+
const t = useTranslator(strings, localeProp);
|
|
7347
|
+
const bill = (0, import_react11.useMemo)(
|
|
7348
|
+
() => invoice === void 0 || invoice === null ? null : deriveUpcomingInvoice(invoice, { locale }),
|
|
7349
|
+
[invoice, locale]
|
|
7350
|
+
);
|
|
5879
7351
|
const Heading = `h${headingLevel}`;
|
|
5880
7352
|
const balanceRows = showBalance && bill !== null && (bill.balanceApplied !== null || bill.balanceRemaining !== null);
|
|
5881
7353
|
const discountRow = showDiscounts && bill !== null && bill.discounts.length > 0;
|
|
5882
7354
|
const unavailable = invoice === void 0 && httpStatus(error) === 404;
|
|
5883
7355
|
const errorMessage = error === void 0 ? void 0 : unavailable ? t("upcomingBillUnavailable") : t("upcomingBillError");
|
|
5884
|
-
return /* @__PURE__ */ (0,
|
|
7356
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
5885
7357
|
StatusFrame,
|
|
5886
7358
|
{
|
|
5887
7359
|
className: cx("schematic-card", "schematic-upcoming-bill", className),
|
|
@@ -5892,11 +7364,11 @@ function UpcomingBill({
|
|
|
5892
7364
|
loadingLabel: t("upcomingBillLoading"),
|
|
5893
7365
|
onRetry: refetch,
|
|
5894
7366
|
retryText: t("retry"),
|
|
5895
|
-
skeleton: /* @__PURE__ */ (0,
|
|
5896
|
-
children: bill === null ? invoice !== void 0 && /* @__PURE__ */ (0,
|
|
5897
|
-
showHeader && bill.dueAt !== null && /* @__PURE__ */ (0,
|
|
5898
|
-
showAmount && /* @__PURE__ */ (0,
|
|
5899
|
-
/* @__PURE__ */ (0,
|
|
7367
|
+
skeleton: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(UpcomingBillSkeleton, { showHeader }),
|
|
7368
|
+
children: bill === null ? invoice !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "schematic-muted schematic-upcoming-bill__empty", children: t("upcomingBillEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
7369
|
+
showHeader && bill.dueAt !== null && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "schematic-header", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Heading, { className: "schematic-header__title", children: t("upcomingBillHeader", { date: bill.dueAt.text }) }) }),
|
|
7370
|
+
showAmount && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "schematic-upcoming-bill__amount", children: [
|
|
7371
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
5900
7372
|
"span",
|
|
5901
7373
|
{
|
|
5902
7374
|
className: "schematic-upcoming-bill__total",
|
|
@@ -5904,46 +7376,46 @@ function UpcomingBill({
|
|
|
5904
7376
|
children: bill.amountDueText
|
|
5905
7377
|
}
|
|
5906
7378
|
),
|
|
5907
|
-
/* @__PURE__ */ (0,
|
|
7379
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "schematic-small schematic-upcoming-bill__estimate", children: t("upcomingBillEstimate") })
|
|
5908
7380
|
] }),
|
|
5909
|
-
(balanceRows || discountRow) && /* @__PURE__ */ (0,
|
|
5910
|
-
balanceRows && bill.balanceApplied !== null && /* @__PURE__ */ (0,
|
|
7381
|
+
(balanceRows || discountRow) && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "schematic-upcoming-bill__rows", children: [
|
|
7382
|
+
balanceRows && bill.balanceApplied !== null && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
5911
7383
|
"div",
|
|
5912
7384
|
{
|
|
5913
7385
|
className: "schematic-row schematic-upcoming-bill__balance-applied",
|
|
5914
7386
|
"data-testid": "schematic-balance-applied",
|
|
5915
7387
|
children: [
|
|
5916
|
-
/* @__PURE__ */ (0,
|
|
5917
|
-
/* @__PURE__ */ (0,
|
|
7388
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "schematic-row__label", children: t("upcomingBillBalanceApplied") }),
|
|
7389
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "schematic-row__value", children: bill.balanceApplied.amountText })
|
|
5918
7390
|
]
|
|
5919
7391
|
}
|
|
5920
7392
|
),
|
|
5921
|
-
balanceRows && bill.balanceRemaining !== null && /* @__PURE__ */ (0,
|
|
7393
|
+
balanceRows && bill.balanceRemaining !== null && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
5922
7394
|
"div",
|
|
5923
7395
|
{
|
|
5924
7396
|
className: "schematic-row schematic-upcoming-bill__balance-remaining",
|
|
5925
7397
|
"data-testid": "schematic-balance-remaining",
|
|
5926
7398
|
children: [
|
|
5927
|
-
/* @__PURE__ */ (0,
|
|
5928
|
-
/* @__PURE__ */ (0,
|
|
7399
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "schematic-row__label", children: t("upcomingBillBalanceRemaining") }),
|
|
7400
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "schematic-row__value", children: bill.balanceRemaining.amountText })
|
|
5929
7401
|
]
|
|
5930
7402
|
}
|
|
5931
7403
|
),
|
|
5932
|
-
discountRow && /* @__PURE__ */ (0,
|
|
7404
|
+
discountRow && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
5933
7405
|
"div",
|
|
5934
7406
|
{
|
|
5935
7407
|
className: "schematic-row schematic-upcoming-bill__discount-row",
|
|
5936
7408
|
"data-testid": "schematic-discounts",
|
|
5937
7409
|
children: [
|
|
5938
|
-
/* @__PURE__ */ (0,
|
|
5939
|
-
/* @__PURE__ */ (0,
|
|
7410
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "schematic-row__label", children: t("upcomingBillDiscount") }),
|
|
7411
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("ul", { className: "schematic-row__value schematic-upcoming-bill__discounts", children: bill.discounts.map((discount, index) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
5940
7412
|
"li",
|
|
5941
7413
|
{
|
|
5942
7414
|
className: "schematic-upcoming-bill__discount",
|
|
5943
7415
|
"data-testid": "schematic-discount",
|
|
5944
7416
|
children: [
|
|
5945
|
-
discount.code !== null && /* @__PURE__ */ (0,
|
|
5946
|
-
/* @__PURE__ */ (0,
|
|
7417
|
+
discount.code !== null && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "schematic-chip schematic-upcoming-bill__code", children: discount.code }),
|
|
7418
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "schematic-upcoming-bill__discount-value", children: discountText(discount, t) })
|
|
5947
7419
|
]
|
|
5948
7420
|
},
|
|
5949
7421
|
`${discount.couponName}-${index}`
|
|
@@ -5957,10 +7429,10 @@ function UpcomingBill({
|
|
|
5957
7429
|
);
|
|
5958
7430
|
}
|
|
5959
7431
|
function UpcomingBillSkeleton({ showHeader }) {
|
|
5960
|
-
return /* @__PURE__ */ (0,
|
|
5961
|
-
showHeader && /* @__PURE__ */ (0,
|
|
5962
|
-
/* @__PURE__ */ (0,
|
|
5963
|
-
/* @__PURE__ */ (0,
|
|
7432
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "schematic-skeleton", children: [
|
|
7433
|
+
showHeader && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "schematic-skeleton__heading" }),
|
|
7434
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "amount" }) }),
|
|
7435
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "row" }) })
|
|
5964
7436
|
] });
|
|
5965
7437
|
}
|
|
5966
7438
|
function discountText(discount, t) {
|