@schematichq/schematic-components 2.31.1 → 2.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/schematic-components-elements.cjs.js +1717 -244
- package/dist/schematic-components-elements.d.ts +382 -6
- package/dist/schematic-components-elements.esm.js +1668 -187
- package/dist/schematic-components.browser.cjs.js +247 -32
- package/dist/schematic-components.browser.esm.js +247 -32
- package/dist/schematic-components.cjs.js +247 -32
- package/dist/schematic-components.d.ts +127 -0
- package/dist/schematic-components.esm.js +247 -32
- package/package.json +7 -7
|
@@ -75,6 +75,9 @@ var init_tokens = __esm({
|
|
|
75
75
|
"--schematic-font-heading": '"Manrope", system-ui, sans-serif',
|
|
76
76
|
// Link buttons' face: Edit, Set default, Try again, and the rest.
|
|
77
77
|
"--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
|
+
"--schematic-inset": ld("hsla(0, 0%, 0%, 0.04)", "hsla(0, 0%, 100%, 0.06)"),
|
|
78
81
|
"--schematic-line-height": "1.375",
|
|
79
82
|
"--schematic-line-height-heading": "1.2",
|
|
80
83
|
"--schematic-meter-track": ld("#f2f4f7", "#26282d"),
|
|
@@ -159,10 +162,10 @@ function PaymentMethodForm({
|
|
|
159
162
|
onSelectExisting,
|
|
160
163
|
t
|
|
161
164
|
}) {
|
|
162
|
-
const { create } = (0,
|
|
163
|
-
const [state, setState] = (0,
|
|
164
|
-
const hostRef = (0,
|
|
165
|
-
(0,
|
|
165
|
+
const { create } = (0, import_schematic_react6.useSetupIntent)();
|
|
166
|
+
const [state, setState] = (0, import_react7.useState)({ status: "loading" });
|
|
167
|
+
const hostRef = (0, import_react7.useRef)(null);
|
|
168
|
+
(0, import_react7.useEffect)(() => {
|
|
166
169
|
let cancelled = false;
|
|
167
170
|
let setupFailed = false;
|
|
168
171
|
Promise.all([
|
|
@@ -208,7 +211,7 @@ function PaymentMethodForm({
|
|
|
208
211
|
};
|
|
209
212
|
}, [create, locale]);
|
|
210
213
|
if (state.status === "loading") {
|
|
211
|
-
return /* @__PURE__ */ (0,
|
|
214
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
212
215
|
"div",
|
|
213
216
|
{
|
|
214
217
|
"aria-busy": "true",
|
|
@@ -216,15 +219,15 @@ function PaymentMethodForm({
|
|
|
216
219
|
"data-state": "pending",
|
|
217
220
|
ref: hostRef,
|
|
218
221
|
children: [
|
|
219
|
-
/* @__PURE__ */ (0,
|
|
220
|
-
/* @__PURE__ */ (0,
|
|
222
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "schematic-hidden", children: t("paymentMethodsFormLoading") }),
|
|
223
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "schematic-skeleton", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "field" }) }) })
|
|
221
224
|
]
|
|
222
225
|
}
|
|
223
226
|
);
|
|
224
227
|
}
|
|
225
228
|
if (state.status === "failed") {
|
|
226
|
-
return /* @__PURE__ */ (0,
|
|
227
|
-
/* @__PURE__ */ (0,
|
|
229
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "schematic-payment-methods__form", "data-state": "error", children: [
|
|
230
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
228
231
|
"p",
|
|
229
232
|
{
|
|
230
233
|
className: "schematic-error schematic-small schematic-payment-methods__form-error",
|
|
@@ -232,11 +235,11 @@ function PaymentMethodForm({
|
|
|
232
235
|
children: t(state.errorKey)
|
|
233
236
|
}
|
|
234
237
|
),
|
|
235
|
-
onSelectExisting !== void 0 && /* @__PURE__ */ (0,
|
|
238
|
+
onSelectExisting !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SelectExisting, { t, onSelectExisting })
|
|
236
239
|
] });
|
|
237
240
|
}
|
|
238
241
|
const { Elements } = state.ui;
|
|
239
|
-
return /* @__PURE__ */ (0,
|
|
242
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
240
243
|
Elements,
|
|
241
244
|
{
|
|
242
245
|
stripe: state.stripe,
|
|
@@ -244,7 +247,7 @@ function PaymentMethodForm({
|
|
|
244
247
|
appearance: state.appearance,
|
|
245
248
|
clientSecret: state.clientSecret
|
|
246
249
|
},
|
|
247
|
-
children: /* @__PURE__ */ (0,
|
|
250
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
248
251
|
Fields,
|
|
249
252
|
{
|
|
250
253
|
checkoutPrefill,
|
|
@@ -273,19 +276,19 @@ function Fields({
|
|
|
273
276
|
const showAddress = collectAddress || collectPhone;
|
|
274
277
|
const prefill = checkoutPrefill?.billingDetails;
|
|
275
278
|
const prefillName = orUndefined(prefill?.name);
|
|
276
|
-
const emailId = (0,
|
|
279
|
+
const emailId = (0, import_react7.useId)();
|
|
277
280
|
const stripe = useStripe();
|
|
278
281
|
const elements = useElements();
|
|
279
|
-
const [saving, setSaving] = (0,
|
|
280
|
-
const [message, setMessage] = (0,
|
|
281
|
-
const [complete, setComplete] = (0,
|
|
282
|
-
const [ready, setReady] = (0,
|
|
283
|
-
const [loadFailed, setLoadFailed] = (0,
|
|
284
|
-
const [addressComplete, setAddressComplete] = (0,
|
|
285
|
-
const [typedEmail, setTypedEmail] = (0,
|
|
282
|
+
const [saving, setSaving] = (0, import_react7.useState)(false);
|
|
283
|
+
const [message, setMessage] = (0, import_react7.useState)(null);
|
|
284
|
+
const [complete, setComplete] = (0, import_react7.useState)(false);
|
|
285
|
+
const [ready, setReady] = (0, import_react7.useState)(false);
|
|
286
|
+
const [loadFailed, setLoadFailed] = (0, import_react7.useState)(false);
|
|
287
|
+
const [addressComplete, setAddressComplete] = (0, import_react7.useState)(!collectAddress);
|
|
288
|
+
const [typedEmail, setTypedEmail] = (0, import_react7.useState)(null);
|
|
286
289
|
const email = typedEmail ?? orUndefined(prefill?.email) ?? "";
|
|
287
290
|
const emailValid = !collectEmail || VALID_EMAIL.test(email);
|
|
288
|
-
(0,
|
|
291
|
+
(0, import_react7.useEffect)(() => {
|
|
289
292
|
if (ready) {
|
|
290
293
|
return;
|
|
291
294
|
}
|
|
@@ -337,14 +340,14 @@ function Fields({
|
|
|
337
340
|
setSaving(false);
|
|
338
341
|
}
|
|
339
342
|
};
|
|
340
|
-
return /* @__PURE__ */ (0,
|
|
343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
341
344
|
"form",
|
|
342
345
|
{
|
|
343
346
|
className: "schematic-payment-methods__form",
|
|
344
347
|
"data-state": "ready",
|
|
345
348
|
onSubmit: (event) => void submit(event),
|
|
346
349
|
children: [
|
|
347
|
-
/* @__PURE__ */ (0,
|
|
350
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "schematic-payment-methods__fields", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
348
351
|
PaymentElement,
|
|
349
352
|
{
|
|
350
353
|
onChange: (event) => setComplete(event.complete),
|
|
@@ -355,8 +358,8 @@ function Fields({
|
|
|
355
358
|
}
|
|
356
359
|
}
|
|
357
360
|
) }),
|
|
358
|
-
collectEmail && /* @__PURE__ */ (0,
|
|
359
|
-
/* @__PURE__ */ (0,
|
|
361
|
+
collectEmail && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "schematic-payment-methods__field", children: [
|
|
362
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
360
363
|
"label",
|
|
361
364
|
{
|
|
362
365
|
className: "schematic-payment-methods__field-label",
|
|
@@ -364,7 +367,7 @@ function Fields({
|
|
|
364
367
|
children: t("paymentMethodsEmail")
|
|
365
368
|
}
|
|
366
369
|
),
|
|
367
|
-
/* @__PURE__ */ (0,
|
|
370
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
368
371
|
"input",
|
|
369
372
|
{
|
|
370
373
|
autoComplete: "email",
|
|
@@ -378,7 +381,7 @@ function Fields({
|
|
|
378
381
|
}
|
|
379
382
|
)
|
|
380
383
|
] }),
|
|
381
|
-
showAddress && /* @__PURE__ */ (0,
|
|
384
|
+
showAddress && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "schematic-payment-methods__address", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
382
385
|
AddressElement,
|
|
383
386
|
{
|
|
384
387
|
options: {
|
|
@@ -392,7 +395,7 @@ function Fields({
|
|
|
392
395
|
},
|
|
393
396
|
prefillName ?? ""
|
|
394
397
|
) }),
|
|
395
|
-
loadFailed && /* @__PURE__ */ (0,
|
|
398
|
+
loadFailed && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
396
399
|
"p",
|
|
397
400
|
{
|
|
398
401
|
className: "schematic-error schematic-small schematic-payment-methods__form-error",
|
|
@@ -400,7 +403,7 @@ function Fields({
|
|
|
400
403
|
children: t("paymentMethodsFormError")
|
|
401
404
|
}
|
|
402
405
|
),
|
|
403
|
-
message !== null && /* @__PURE__ */ (0,
|
|
406
|
+
message !== null && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
404
407
|
"p",
|
|
405
408
|
{
|
|
406
409
|
className: "schematic-error schematic-small schematic-payment-methods__form-error",
|
|
@@ -408,7 +411,7 @@ function Fields({
|
|
|
408
411
|
children: message
|
|
409
412
|
}
|
|
410
413
|
),
|
|
411
|
-
/* @__PURE__ */ (0,
|
|
414
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
412
415
|
"button",
|
|
413
416
|
{
|
|
414
417
|
className: "schematic-cta schematic-payment-methods__save",
|
|
@@ -417,7 +420,7 @@ function Fields({
|
|
|
417
420
|
children: saving ? t("paymentMethodsSaving") : t("paymentMethodsSave")
|
|
418
421
|
}
|
|
419
422
|
),
|
|
420
|
-
onSelectExisting !== void 0 && /* @__PURE__ */ (0,
|
|
423
|
+
onSelectExisting !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
421
424
|
SelectExisting,
|
|
422
425
|
{
|
|
423
426
|
disabled: saving,
|
|
@@ -434,7 +437,7 @@ function SelectExisting({
|
|
|
434
437
|
onSelectExisting,
|
|
435
438
|
t
|
|
436
439
|
}) {
|
|
437
|
-
return /* @__PURE__ */ (0,
|
|
440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
438
441
|
"button",
|
|
439
442
|
{
|
|
440
443
|
className: "schematic-link-button schematic-payment-methods__select-existing",
|
|
@@ -445,14 +448,14 @@ function SelectExisting({
|
|
|
445
448
|
}
|
|
446
449
|
);
|
|
447
450
|
}
|
|
448
|
-
var
|
|
451
|
+
var import_schematic_react6, import_react7, import_jsx_runtime8, NO_CLIENT_SECRET, STRIPE_NOT_LOADED, PROBE_CSS, READY_TIMEOUT_MS, VALID_EMAIL, PaymentMethodForm_default;
|
|
449
452
|
var init_PaymentMethodForm = __esm({
|
|
450
453
|
"src/elements/PaymentMethodForm.tsx"() {
|
|
451
454
|
"use strict";
|
|
452
|
-
|
|
453
|
-
|
|
455
|
+
import_schematic_react6 = require("@schematichq/schematic-react");
|
|
456
|
+
import_react7 = require("react");
|
|
454
457
|
init_tokens();
|
|
455
|
-
|
|
458
|
+
import_jsx_runtime8 = require("react/jsx-runtime");
|
|
456
459
|
NO_CLIENT_SECRET = "The setup intent carries no client secret.";
|
|
457
460
|
STRIPE_NOT_LOADED = "Stripe.js did not load.";
|
|
458
461
|
PROBE_CSS = withTokenDefaults(
|
|
@@ -476,21 +479,25 @@ var init_PaymentMethodForm = __esm({
|
|
|
476
479
|
// src/elements/index.ts
|
|
477
480
|
var index_exports = {};
|
|
478
481
|
__export(index_exports, {
|
|
479
|
-
BillingDataProvider: () =>
|
|
482
|
+
BillingDataProvider: () => import_schematic_react9.BillingDataProvider,
|
|
483
|
+
CreditUsage: () => CreditUsage,
|
|
480
484
|
DEFAULT_STRINGS: () => DEFAULT_STRINGS,
|
|
481
|
-
FEATURE_USER_USAGE_LIMIT: () =>
|
|
485
|
+
FEATURE_USER_USAGE_LIMIT: () => import_schematic_react9.FEATURE_USER_USAGE_LIMIT,
|
|
482
486
|
IncludedFeatures: () => IncludedFeatures,
|
|
483
487
|
Invoices: () => Invoices,
|
|
488
|
+
MeteredFeatures: () => MeteredFeatures,
|
|
484
489
|
PaymentMethods: () => PaymentMethods,
|
|
485
490
|
SCHEMATIC_TOKENS: () => SCHEMATIC_TOKENS,
|
|
486
|
-
SchematicI18nProvider: () =>
|
|
491
|
+
SchematicI18nProvider: () => import_schematic_react9.SchematicI18nProvider,
|
|
487
492
|
SchematicStyles: () => SchematicStyles,
|
|
488
493
|
Tooltip: () => Tooltip,
|
|
489
494
|
UpcomingBill: () => UpcomingBill,
|
|
490
495
|
billingResources: () => billingResources,
|
|
491
496
|
currentTier: () => currentTier,
|
|
497
|
+
deriveCreditUsage: () => deriveCreditUsage,
|
|
492
498
|
deriveIncludedFeatures: () => deriveIncludedFeatures,
|
|
493
499
|
deriveInvoiceList: () => deriveInvoiceList,
|
|
500
|
+
deriveMeteredFeatures: () => deriveMeteredFeatures,
|
|
494
501
|
derivePaymentMethods: () => derivePaymentMethods,
|
|
495
502
|
deriveUpcomingInvoice: () => deriveUpcomingInvoice,
|
|
496
503
|
featureName: () => featureName,
|
|
@@ -514,23 +521,25 @@ __export(index_exports, {
|
|
|
514
521
|
tierRanges: () => tierRanges,
|
|
515
522
|
unitPrice: () => unitPrice,
|
|
516
523
|
usageLimit: () => usageLimit,
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
524
|
+
useCreditBalances: () => import_schematic_react9.useCreditBalances,
|
|
525
|
+
useCreditUserUsage: () => import_schematic_react9.useCreditUserUsage,
|
|
526
|
+
useFeatureUsage: () => import_schematic_react9.useFeatureUsage,
|
|
527
|
+
useFeatureUserUsage: () => import_schematic_react9.useFeatureUserUsage,
|
|
528
|
+
useInvalidateBillingData: () => import_schematic_react9.useInvalidateBillingData,
|
|
529
|
+
useInvoices: () => import_schematic_react9.useInvoices,
|
|
530
|
+
usePaymentMethods: () => import_schematic_react9.usePaymentMethods,
|
|
522
531
|
useResolvedLocale: () => useResolvedLocale,
|
|
523
|
-
useSchematicI18n: () =>
|
|
524
|
-
useSchematicLocale: () =>
|
|
525
|
-
useSchematicStrings: () =>
|
|
526
|
-
useSchematicTranslate: () =>
|
|
527
|
-
useSetupIntent: () =>
|
|
532
|
+
useSchematicI18n: () => import_schematic_react9.useSchematicI18n,
|
|
533
|
+
useSchematicLocale: () => import_schematic_react9.useSchematicLocale,
|
|
534
|
+
useSchematicStrings: () => import_schematic_react9.useSchematicStrings,
|
|
535
|
+
useSchematicTranslate: () => import_schematic_react9.useSchematicTranslate,
|
|
536
|
+
useSetupIntent: () => import_schematic_react9.useSetupIntent,
|
|
528
537
|
useTranslator: () => useTranslator,
|
|
529
|
-
useUpcomingInvoice: () =>
|
|
538
|
+
useUpcomingInvoice: () => import_schematic_react9.useUpcomingInvoice,
|
|
530
539
|
viewerLocale: () => viewerLocale
|
|
531
540
|
});
|
|
532
541
|
module.exports = __toCommonJS(index_exports);
|
|
533
|
-
var
|
|
542
|
+
var import_schematic_react9 = require("@schematichq/schematic-react");
|
|
534
543
|
|
|
535
544
|
// src/elements/model/errors.ts
|
|
536
545
|
function httpStatus(error) {
|
|
@@ -985,6 +994,9 @@ function formatCurrency(amountMinor, currency, locale, options = {}) {
|
|
|
985
994
|
function formatNumber(value, locale, options) {
|
|
986
995
|
return new Intl.NumberFormat(usableLocale(locale), options).format(value);
|
|
987
996
|
}
|
|
997
|
+
function formatCredits(value, locale) {
|
|
998
|
+
return formatNumber(value, locale, { maximumFractionDigits: 10 });
|
|
999
|
+
}
|
|
988
1000
|
function formatConsumptionRate(rate, locale) {
|
|
989
1001
|
return formatNumber(rate, locale, {
|
|
990
1002
|
maximumFractionDigits: MAXIMUM_FRACTION_DIGITS
|
|
@@ -1381,7 +1393,10 @@ function includedFeatureRow(row, options) {
|
|
|
1381
1393
|
description: nonEmpty(row.featureDescription),
|
|
1382
1394
|
icon: nonEmpty(row.featureIcon),
|
|
1383
1395
|
perLicenseCredits: row.perLicenseCreditGrants.filter((grant) => grant.scaling === "per_license").map((grant) => ({
|
|
1384
|
-
|
|
1396
|
+
// Credits come in fractions as small as 1e-10.
|
|
1397
|
+
amount: formatNumber(grant.creditAmount, locale, {
|
|
1398
|
+
maximumFractionDigits: 10
|
|
1399
|
+
}),
|
|
1385
1400
|
creditName: featureName(
|
|
1386
1401
|
{
|
|
1387
1402
|
name: grant.creditName,
|
|
@@ -1401,7 +1416,7 @@ function includedFeatureRow(row, options) {
|
|
|
1401
1416
|
usage: usageSegments(row, locale, tiered, period),
|
|
1402
1417
|
usageSummary: usageSummary(row, options),
|
|
1403
1418
|
hardLimit: row.priceBehavior !== void 0 && row.priceBehavior !== null && row.priceBehavior !== "credit_burndown" && row.valueType === "numeric" && typeof row.allocation === "number" ? {
|
|
1404
|
-
amount: row.allocation,
|
|
1419
|
+
amount: formatNumber(row.allocation, locale),
|
|
1405
1420
|
units: featureName(feature, row.allocation, locale)
|
|
1406
1421
|
} : null,
|
|
1407
1422
|
tiers: (row.priceBehavior === "tier" || tiered) && row.price !== void 0 ? {
|
|
@@ -1446,7 +1461,7 @@ function entitlementText(row, options) {
|
|
|
1446
1461
|
return size > 1 ? {
|
|
1447
1462
|
kind: "perPackage",
|
|
1448
1463
|
cost,
|
|
1449
|
-
size,
|
|
1464
|
+
size: formatNumber(size, locale),
|
|
1450
1465
|
units: featureName(feature, size, locale)
|
|
1451
1466
|
} : { kind: "perUnit", cost, unit: featureName(feature, 1, locale) };
|
|
1452
1467
|
}
|
|
@@ -1507,14 +1522,14 @@ function usageSegments(row, locale, tiered, period) {
|
|
|
1507
1522
|
segments.push({
|
|
1508
1523
|
kind: "unitPricePerPeriod",
|
|
1509
1524
|
cost: formatCurrency(unitPrice(row.price), row.price.currency, locale),
|
|
1510
|
-
size,
|
|
1525
|
+
size: size > 1 ? formatNumber(size, locale) : null,
|
|
1511
1526
|
units: featureName(feature, size, locale),
|
|
1512
1527
|
period
|
|
1513
1528
|
});
|
|
1514
1529
|
} else if ((row.priceBehavior === "pay_as_you_go" || row.priceBehavior === "overage" || row.priceBehavior === "tier" || row.priceBehavior === "credit_burndown" || tiered) && typeof row.usage === "number") {
|
|
1515
1530
|
segments.push({
|
|
1516
1531
|
kind: "used",
|
|
1517
|
-
amount:
|
|
1532
|
+
amount: formatNumber(row.usage, locale),
|
|
1518
1533
|
units: featureName(feature, row.usage, locale)
|
|
1519
1534
|
});
|
|
1520
1535
|
}
|
|
@@ -1555,6 +1570,284 @@ function nonEmpty(value) {
|
|
|
1555
1570
|
return value === void 0 || value === null || value === "" ? null : value;
|
|
1556
1571
|
}
|
|
1557
1572
|
|
|
1573
|
+
// src/elements/model/meteredFeatures.ts
|
|
1574
|
+
var TONES = [
|
|
1575
|
+
"ok",
|
|
1576
|
+
"ok",
|
|
1577
|
+
"ok",
|
|
1578
|
+
"warning",
|
|
1579
|
+
"critical",
|
|
1580
|
+
"critical"
|
|
1581
|
+
];
|
|
1582
|
+
function deriveMeteredFeatures(features, options) {
|
|
1583
|
+
const ordered = options.visibleFeatures === void 0 ? features : options.visibleFeatures.flatMap((id) => {
|
|
1584
|
+
const row = features.find((f) => f.featureId === id);
|
|
1585
|
+
return row === void 0 ? [] : [row];
|
|
1586
|
+
});
|
|
1587
|
+
return ordered.filter((row) => row.featureType === "event" || row.featureType === "trait").map((row) => meteredFeatureRow(row, options));
|
|
1588
|
+
}
|
|
1589
|
+
function meteredFeatureRow(row, options) {
|
|
1590
|
+
const { locale } = options;
|
|
1591
|
+
const unit = {
|
|
1592
|
+
name: row.featureName,
|
|
1593
|
+
singularName: row.featureSingularName ?? void 0,
|
|
1594
|
+
pluralName: row.featurePluralName ?? void 0
|
|
1595
|
+
};
|
|
1596
|
+
const limit = usageLimit(row, options);
|
|
1597
|
+
const resetsAt = usableDate(row.resetsAt);
|
|
1598
|
+
return {
|
|
1599
|
+
featureId: row.featureId,
|
|
1600
|
+
name: row.featureName,
|
|
1601
|
+
description: row.featureDescription === "" ? null : row.featureDescription ?? null,
|
|
1602
|
+
icon: row.featureIcon === "" ? null : row.featureIcon ?? null,
|
|
1603
|
+
headline: headline(row, limit, unit, locale),
|
|
1604
|
+
limit: limitLine(row, limit, unit, options),
|
|
1605
|
+
resetsAt: resetsAt === void 0 ? null : formatDate(resetsAt, locale, { month: "short", year: void 0 }),
|
|
1606
|
+
hardLimit: row.priceBehavior !== void 0 && row.priceBehavior !== null && row.priceBehavior !== "credit_burndown" && row.valueType === "numeric" && typeof row.allocation === "number" ? {
|
|
1607
|
+
amount: formatNumber(row.allocation, locale),
|
|
1608
|
+
units: featureName(unit, row.allocation, locale)
|
|
1609
|
+
} : null,
|
|
1610
|
+
meter: meter(row, options),
|
|
1611
|
+
priceDetails: priceDetails(row, unit, locale),
|
|
1612
|
+
canAddMore: row.priceBehavior === "pay_in_advance",
|
|
1613
|
+
hasUsageByUser: row.featureType === "event",
|
|
1614
|
+
unit,
|
|
1615
|
+
source: row
|
|
1616
|
+
};
|
|
1617
|
+
}
|
|
1618
|
+
function headline(row, limit, unit, locale) {
|
|
1619
|
+
if (row.priceBehavior === "pay_in_advance") {
|
|
1620
|
+
return {
|
|
1621
|
+
kind: "quantity",
|
|
1622
|
+
amount: limit === null ? null : formatNumber(limit, locale),
|
|
1623
|
+
units: featureName(unit, limit ?? 0, locale)
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1626
|
+
if (typeof row.usage !== "number") {
|
|
1627
|
+
return null;
|
|
1628
|
+
}
|
|
1629
|
+
return {
|
|
1630
|
+
kind: "used",
|
|
1631
|
+
amount: formatNumber(row.usage, locale),
|
|
1632
|
+
units: featureName(unit, row.usage, locale)
|
|
1633
|
+
};
|
|
1634
|
+
}
|
|
1635
|
+
function limitLine(row, limit, unit, options) {
|
|
1636
|
+
const { locale } = options;
|
|
1637
|
+
switch (row.priceBehavior) {
|
|
1638
|
+
case "tier": {
|
|
1639
|
+
const tier = currentTier(row);
|
|
1640
|
+
if (tier !== null) {
|
|
1641
|
+
return tier.to === null ? { kind: "tierUnlimited", feature: featureName(unit, 0, locale) } : {
|
|
1642
|
+
kind: "tierUpTo",
|
|
1643
|
+
amount: formatNumber(tier.to, locale),
|
|
1644
|
+
feature: featureName(unit, tier.to, locale)
|
|
1645
|
+
};
|
|
1646
|
+
}
|
|
1647
|
+
break;
|
|
1648
|
+
}
|
|
1649
|
+
case "overage":
|
|
1650
|
+
if (limit !== null) {
|
|
1651
|
+
return { kind: "included", amount: formatNumber(limit, locale) };
|
|
1652
|
+
}
|
|
1653
|
+
break;
|
|
1654
|
+
case "pay_in_advance":
|
|
1655
|
+
if (typeof row.usage === "number") {
|
|
1656
|
+
return { kind: "used", amount: formatNumber(row.usage, locale) };
|
|
1657
|
+
}
|
|
1658
|
+
break;
|
|
1659
|
+
case "pay_as_you_go":
|
|
1660
|
+
if (typeof row.currentCost === "number" && row.price !== void 0) {
|
|
1661
|
+
return {
|
|
1662
|
+
kind: "cost",
|
|
1663
|
+
cost: formatCurrency(row.currentCost, row.price.currency, locale)
|
|
1664
|
+
};
|
|
1665
|
+
}
|
|
1666
|
+
break;
|
|
1667
|
+
case "credit_burndown":
|
|
1668
|
+
if (options.showCredits === false || typeof row.consumptionRate !== "number" || row.creditName === void 0 || row.creditName === null) {
|
|
1669
|
+
return null;
|
|
1670
|
+
}
|
|
1671
|
+
return {
|
|
1672
|
+
kind: "perUse",
|
|
1673
|
+
amount: formatConsumptionRate(row.consumptionRate, locale),
|
|
1674
|
+
units: featureName(
|
|
1675
|
+
{
|
|
1676
|
+
name: row.creditName,
|
|
1677
|
+
singularName: row.creditSingularName,
|
|
1678
|
+
pluralName: row.creditPluralName
|
|
1679
|
+
},
|
|
1680
|
+
row.consumptionRate,
|
|
1681
|
+
locale
|
|
1682
|
+
)
|
|
1683
|
+
};
|
|
1684
|
+
default:
|
|
1685
|
+
break;
|
|
1686
|
+
}
|
|
1687
|
+
return limit === null ? { kind: "noLimit" } : { kind: "limitOf", amount: formatNumber(limit, locale) };
|
|
1688
|
+
}
|
|
1689
|
+
function meter(row, options) {
|
|
1690
|
+
if (row.priceBehavior === "pay_as_you_go" || row.priceBehavior === "credit_burndown" || typeof row.usage !== "number") {
|
|
1691
|
+
return null;
|
|
1692
|
+
}
|
|
1693
|
+
const total = options.showWarningThresholdAsLimit === true && typeof row.warningThreshold === "number" ? row.warningThreshold : row.softLimit ?? row.allocation ?? null;
|
|
1694
|
+
if (typeof total !== "number") {
|
|
1695
|
+
return null;
|
|
1696
|
+
}
|
|
1697
|
+
const usage = row.usage;
|
|
1698
|
+
const past = row.priceBehavior === "overage" && usage > total;
|
|
1699
|
+
const ratio = past ? Math.min(usage, total) / Math.max(usage, total) : total === 0 ? 1 : usage / total;
|
|
1700
|
+
const digits = { maximumFractionDigits: 10 };
|
|
1701
|
+
return {
|
|
1702
|
+
value: usage,
|
|
1703
|
+
total,
|
|
1704
|
+
percent: Math.min(ratio * 100, 100),
|
|
1705
|
+
tone: row.priceBehavior === "tier" ? "tier" : past ? "overage" : TONES[Math.floor(
|
|
1706
|
+
(total === 0 ? 1 : Math.min(usage, total) / total) * (TONES.length - 1)
|
|
1707
|
+
)],
|
|
1708
|
+
valueText: formatNumber(usage, options.locale, digits),
|
|
1709
|
+
totalText: formatNumber(total, options.locale, digits)
|
|
1710
|
+
};
|
|
1711
|
+
}
|
|
1712
|
+
function priceDetails(row, unit, locale) {
|
|
1713
|
+
const price = row.price;
|
|
1714
|
+
if (price === void 0) {
|
|
1715
|
+
return null;
|
|
1716
|
+
}
|
|
1717
|
+
const tier = currentTier(row);
|
|
1718
|
+
const period = row.featureType === "trait" ? pricePeriod(price) : null;
|
|
1719
|
+
const money = (amount) => formatCurrency(amount, price.currency, locale);
|
|
1720
|
+
if (row.priceBehavior === "overage") {
|
|
1721
|
+
if (tier === null || tier.perUnitPrice === null) {
|
|
1722
|
+
return null;
|
|
1723
|
+
}
|
|
1724
|
+
const size = price.packageSize;
|
|
1725
|
+
const over = typeof row.usage === "number" && typeof row.softLimit === "number" ? Math.max(0, row.usage - row.softLimit) : 0;
|
|
1726
|
+
return {
|
|
1727
|
+
kind: "overage",
|
|
1728
|
+
unitPrice: money(tier.perUnitPrice),
|
|
1729
|
+
packageSize: size > 1 ? formatNumber(size, locale) : null,
|
|
1730
|
+
units: featureName(unit, size, locale),
|
|
1731
|
+
period,
|
|
1732
|
+
overage: {
|
|
1733
|
+
amount: formatNumber(over, locale),
|
|
1734
|
+
units: featureName(unit, over, locale),
|
|
1735
|
+
cost: money(tier.perUnitPrice * over)
|
|
1736
|
+
}
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
if (row.priceBehavior === "tier") {
|
|
1740
|
+
if (tier === null || tier.perUnitPrice === null) {
|
|
1741
|
+
return null;
|
|
1742
|
+
}
|
|
1743
|
+
return {
|
|
1744
|
+
kind: "tier",
|
|
1745
|
+
from: formatNumber(tier.from === 0 ? 1 : tier.from, locale),
|
|
1746
|
+
to: tier.to === null ? null : formatNumber(tier.to, locale),
|
|
1747
|
+
cost: typeof row.currentCost === "number" ? money(row.currentCost) : null,
|
|
1748
|
+
period,
|
|
1749
|
+
tiers: {
|
|
1750
|
+
ranges: tierRanges(price),
|
|
1751
|
+
currency: price.currency,
|
|
1752
|
+
mode: price.tiersMode ?? null
|
|
1753
|
+
}
|
|
1754
|
+
};
|
|
1755
|
+
}
|
|
1756
|
+
return null;
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
// src/elements/model/creditUsage.ts
|
|
1760
|
+
function deriveCreditUsage(balances, options) {
|
|
1761
|
+
const ordered = options.visibleCredits === void 0 ? balances : options.visibleCredits.flatMap((id) => {
|
|
1762
|
+
const balance = balances.find((b) => b.creditId === id);
|
|
1763
|
+
return balance === void 0 ? [] : [balance];
|
|
1764
|
+
});
|
|
1765
|
+
return ordered.map((balance) => creditUsageRow(balance, options.locale));
|
|
1766
|
+
}
|
|
1767
|
+
function creditUsageRow(balance, locale) {
|
|
1768
|
+
const unit = {
|
|
1769
|
+
name: balance.creditName,
|
|
1770
|
+
singularName: balance.creditSingularName ?? void 0,
|
|
1771
|
+
pluralName: balance.creditPluralName ?? void 0
|
|
1772
|
+
};
|
|
1773
|
+
const composition = balance.composition;
|
|
1774
|
+
return {
|
|
1775
|
+
creditId: balance.creditId,
|
|
1776
|
+
name: balance.creditName,
|
|
1777
|
+
description: balance.creditDescription === "" ? null : balance.creditDescription,
|
|
1778
|
+
icon: balance.creditIcon === void 0 || balance.creditIcon === null || balance.creditIcon === "" ? null : balance.creditIcon,
|
|
1779
|
+
remaining: {
|
|
1780
|
+
amount: formatCredits(balance.remaining, locale),
|
|
1781
|
+
units: featureName(unit, balance.remaining, locale)
|
|
1782
|
+
},
|
|
1783
|
+
purchasable: balance.purchasable,
|
|
1784
|
+
ledger: balance.grants.map((grant) => ledgerRow(grant, unit, locale)),
|
|
1785
|
+
composition: composition === void 0 || composition === null ? null : {
|
|
1786
|
+
total: formatCredits(composition.total, locale),
|
|
1787
|
+
creditName: featureName(unit, composition.total, locale),
|
|
1788
|
+
period: composition.period,
|
|
1789
|
+
perLicense: {
|
|
1790
|
+
quantity: formatNumber(composition.licenseQuantity, locale),
|
|
1791
|
+
licenseName: featureName(
|
|
1792
|
+
{
|
|
1793
|
+
name: composition.licenseName,
|
|
1794
|
+
singularName: composition.licenseSingularName,
|
|
1795
|
+
pluralName: composition.licensePluralName
|
|
1796
|
+
},
|
|
1797
|
+
composition.licenseQuantity,
|
|
1798
|
+
locale
|
|
1799
|
+
),
|
|
1800
|
+
perUnit: formatCredits(composition.perLicenseAmount, locale)
|
|
1801
|
+
},
|
|
1802
|
+
companyGrant: composition.fixedQuantity > 0 ? formatCredits(composition.fixedQuantity, locale) : null,
|
|
1803
|
+
renewsOn: renewsOn(composition.renewsAt, locale)
|
|
1804
|
+
},
|
|
1805
|
+
unit,
|
|
1806
|
+
source: balance
|
|
1807
|
+
};
|
|
1808
|
+
}
|
|
1809
|
+
function ledgerRow(grant, unit, locale) {
|
|
1810
|
+
const kind = grant.grantReason === "plan" ? "plan" : grant.grantReason === "purchased" ? "bundle" : grant.grantReason === "billing_credit_auto_topup" ? "autoTopup" : "promotional";
|
|
1811
|
+
const short = (date) => formatDate(date, locale, { month: "short" });
|
|
1812
|
+
const resetsAt = usableDate(grant.resetsAt);
|
|
1813
|
+
const expiresAt = usableDate(grant.expiresAt);
|
|
1814
|
+
return {
|
|
1815
|
+
id: grant.id,
|
|
1816
|
+
kind,
|
|
1817
|
+
amount: formatCredits(grant.quantity, locale),
|
|
1818
|
+
item: featureName(unit, kind === "bundle" ? 1 : grant.quantity, locale),
|
|
1819
|
+
createdAt: short(grant.createdAt),
|
|
1820
|
+
date: resetsAt !== void 0 ? { kind: "resets", text: short(resetsAt) } : expiresAt !== void 0 ? { kind: "expires", text: short(expiresAt) } : null,
|
|
1821
|
+
source: grant
|
|
1822
|
+
};
|
|
1823
|
+
}
|
|
1824
|
+
function renewsOn(date, locale) {
|
|
1825
|
+
const due = usableDate(date);
|
|
1826
|
+
if (due === void 0) {
|
|
1827
|
+
return null;
|
|
1828
|
+
}
|
|
1829
|
+
const day = due.getDate();
|
|
1830
|
+
if (!isEnglish2(locale)) {
|
|
1831
|
+
return formatNumber(day, locale);
|
|
1832
|
+
}
|
|
1833
|
+
const suffix = {
|
|
1834
|
+
few: "rd",
|
|
1835
|
+
many: "th",
|
|
1836
|
+
one: "st",
|
|
1837
|
+
other: "th",
|
|
1838
|
+
two: "nd",
|
|
1839
|
+
zero: "th"
|
|
1840
|
+
};
|
|
1841
|
+
return `${day}${suffix[new Intl.PluralRules("en", { type: "ordinal" }).select(day)]}`;
|
|
1842
|
+
}
|
|
1843
|
+
function isEnglish2(locale) {
|
|
1844
|
+
try {
|
|
1845
|
+
return new Intl.Locale(locale).language === "en";
|
|
1846
|
+
} catch {
|
|
1847
|
+
return false;
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1558
1851
|
// src/elements/strings.ts
|
|
1559
1852
|
var DEFAULT_STRINGS_LOCALE = "en";
|
|
1560
1853
|
var DEFAULT_STRINGS = {
|
|
@@ -1630,6 +1923,53 @@ var DEFAULT_STRINGS = {
|
|
|
1630
1923
|
includedFeaturesHideAll: "Hide all",
|
|
1631
1924
|
includedFeaturesExpires: "Expires {{date}}",
|
|
1632
1925
|
includedFeaturesPerLicense: "Includes {{amount}} {{creditName}} per {{licenseName}}",
|
|
1926
|
+
meteredFeaturesLoading: "Loading usage",
|
|
1927
|
+
meteredFeaturesHeader: "Usage",
|
|
1928
|
+
meteredFeaturesError: "There was a problem retrieving your usage.",
|
|
1929
|
+
meteredFeaturesUnavailable: "Usage is not available for this account.",
|
|
1930
|
+
meteredFeaturesUsed: "{{amount}} {{units}} used",
|
|
1931
|
+
meteredFeaturesIncluded: "{{amount}} included",
|
|
1932
|
+
meteredFeaturesInUse: "{{amount}} used",
|
|
1933
|
+
meteredFeaturesLimitOf: "Limit of {{amount}}",
|
|
1934
|
+
meteredFeaturesNoLimit: "No limit",
|
|
1935
|
+
meteredFeaturesAddMore: "Add More",
|
|
1936
|
+
meteredFeaturesAdditional: "Additional",
|
|
1937
|
+
meteredFeaturesTier: "Tier",
|
|
1938
|
+
creditUsageLoading: "Loading credits",
|
|
1939
|
+
creditUsageHeader: "Credits",
|
|
1940
|
+
creditUsageError: "There was a problem retrieving your credits.",
|
|
1941
|
+
creditUsageUnavailable: "Credits are not available for this account.",
|
|
1942
|
+
creditUsageRemaining: "{{amount}} {{units}} remaining",
|
|
1943
|
+
creditUsageBuyMore: "Buy More",
|
|
1944
|
+
creditUsageSeeDetails: "See balance details",
|
|
1945
|
+
creditUsageHideDetails: "Hide balance details",
|
|
1946
|
+
creditUsageSeeAll: "See all ({{total}})",
|
|
1947
|
+
creditUsageHideAll: "Hide all",
|
|
1948
|
+
creditUsageGrantPlan: "{{amount}} {{item}} included in plan",
|
|
1949
|
+
creditUsageGrantBundle: "{{amount}} {{item}} bundle purchased {{createdAt}}",
|
|
1950
|
+
creditUsageGrantAutoTopup: "{{amount}} {{item}} auto-topup purchased {{createdAt}}",
|
|
1951
|
+
creditUsageGrantPromotional: "{{amount}} promotional {{item}} granted {{createdAt}}",
|
|
1952
|
+
creditUsageResets: "Resets {{date}}",
|
|
1953
|
+
creditUsageExpires: "Expires {{date}}",
|
|
1954
|
+
creditUsageComposition: "Your plan includes {{total}} {{creditName}}/{{period}} \u2014 {{perLicense}}.",
|
|
1955
|
+
creditUsageCompositionWithGrant: "Your plan includes {{total}} {{creditName}}/{{period}} \u2014 {{perLicense}} + {{companyGrant}}.",
|
|
1956
|
+
creditUsagePerLicense: "{{quantity}} {{licenseName}} \xD7 {{perUnit}}",
|
|
1957
|
+
creditUsageCompanyGrant: "{{amount}} company grant",
|
|
1958
|
+
creditUsageRenewsOn: "Renews on the {{day}}.",
|
|
1959
|
+
usageByUserHeader: "Usage by user",
|
|
1960
|
+
usageByUserTotal: "{{amount}} used by your team this period",
|
|
1961
|
+
usageByUserError: "There was a problem retrieving usage by user.",
|
|
1962
|
+
usageByUserUnattributed: "Unattributed",
|
|
1963
|
+
// Looked up by the bare key with `{ count }`; `shown` is the count formatted.
|
|
1964
|
+
usageByUserMore: "plus {{shown}} more",
|
|
1965
|
+
usageByUserShowTop: "Show top {{shown}} users",
|
|
1966
|
+
usageByUserShowTop_one: "Show top {{shown}} user",
|
|
1967
|
+
usageByUserShowTop_other: "Show top {{shown}} users",
|
|
1968
|
+
usageByUserShowAllCount: "Show all {{shown}} users",
|
|
1969
|
+
usageByUserShowAllCount_one: "Show all {{shown}} user",
|
|
1970
|
+
usageByUserShowAllCount_other: "Show all {{shown}} users",
|
|
1971
|
+
usageByUserShowAll: "Show all",
|
|
1972
|
+
usageByUserShowFewer: "Show fewer",
|
|
1633
1973
|
// Shared by the usage elements.
|
|
1634
1974
|
usageUnits: "{{amount}} {{units}}",
|
|
1635
1975
|
usagePerUnit: "{{cost}} per {{unit}}",
|
|
@@ -1682,6 +2022,160 @@ function defaultString(key, vars) {
|
|
|
1682
2022
|
return lookup(DEFAULT_STRINGS, key, vars) ?? DEFAULT_STRINGS[key] ?? key;
|
|
1683
2023
|
}
|
|
1684
2024
|
|
|
2025
|
+
// src/elements/styles/credit-usage.ts
|
|
2026
|
+
var creditUsageCss = `
|
|
2027
|
+
.schematic-credit-usage__credits {
|
|
2028
|
+
display: flex;
|
|
2029
|
+
flex-direction: column;
|
|
2030
|
+
gap: var(--schematic-space);
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
/* Each credit draws its own card, so the root draws one only while pending
|
|
2034
|
+
or failed. */
|
|
2035
|
+
.schematic-credit-usage[data-state="pending"],
|
|
2036
|
+
.schematic-credit-usage[data-state="error"] {
|
|
2037
|
+
background: var(--schematic-background);
|
|
2038
|
+
border-radius: var(--schematic-radius);
|
|
2039
|
+
box-shadow: var(--schematic-shadow);
|
|
2040
|
+
padding: calc(var(--schematic-card-padding) * 0.75)
|
|
2041
|
+
var(--schematic-card-padding);
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
.schematic-credit-usage__credit {
|
|
2045
|
+
display: flex;
|
|
2046
|
+
flex-direction: column;
|
|
2047
|
+
gap: var(--schematic-space);
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
.schematic-credit-usage__main {
|
|
2051
|
+
display: flex;
|
|
2052
|
+
gap: calc(var(--schematic-space) * 1.5);
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
/* Held even without a glyph, as the embed does, so names line up. */
|
|
2056
|
+
.schematic-credit-usage__icon {
|
|
2057
|
+
align-items: center;
|
|
2058
|
+
background: var(--schematic-surface);
|
|
2059
|
+
border-radius: 9999px;
|
|
2060
|
+
display: inline-flex;
|
|
2061
|
+
flex-shrink: 0;
|
|
2062
|
+
font-size: 1.5rem;
|
|
2063
|
+
height: 2.75rem;
|
|
2064
|
+
justify-content: center;
|
|
2065
|
+
width: 2.75rem;
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
.schematic-credit-usage__icon .schematic-icon {
|
|
2069
|
+
color: var(--schematic-accent);
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
/* The embed's spacing: the balance well clear of the name, the composition
|
|
2073
|
+
tucked close under the balance. */
|
|
2074
|
+
.schematic-credit-usage__body {
|
|
2075
|
+
display: flex;
|
|
2076
|
+
flex-direction: column;
|
|
2077
|
+
flex-grow: 1;
|
|
2078
|
+
gap: calc(var(--schematic-space) * 2);
|
|
2079
|
+
min-width: 0;
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
.schematic-credit-usage__composition {
|
|
2083
|
+
margin-top: calc(var(--schematic-space) * -1.5);
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
.schematic-credit-usage__title {
|
|
2087
|
+
display: flex;
|
|
2088
|
+
flex-direction: column;
|
|
2089
|
+
gap: 0.5rem;
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
.schematic-credit-usage__name {
|
|
2093
|
+
font-family: var(--schematic-font-heading);
|
|
2094
|
+
font-size: 1.8125rem;
|
|
2095
|
+
font-weight: 800;
|
|
2096
|
+
line-height: var(--schematic-line-height-heading);
|
|
2097
|
+
margin: 0;
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
.schematic-credit-usage__balance {
|
|
2101
|
+
align-items: center;
|
|
2102
|
+
display: flex;
|
|
2103
|
+
gap: var(--schematic-space);
|
|
2104
|
+
justify-content: space-between;
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
.schematic-credit-usage__remaining {
|
|
2108
|
+
font-size: 1.0625rem;
|
|
2109
|
+
font-variant-numeric: tabular-nums;
|
|
2110
|
+
font-weight: 500;
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
.schematic-credit-usage__buy-more {
|
|
2114
|
+
white-space: nowrap;
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
.schematic-credit-usage__details,
|
|
2118
|
+
.schematic-credit-usage__see-all {
|
|
2119
|
+
align-items: center;
|
|
2120
|
+
display: inline-flex;
|
|
2121
|
+
gap: 0.25rem;
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
.schematic-credit-usage__details .schematic-chevron,
|
|
2125
|
+
.schematic-credit-usage__see-all .schematic-chevron {
|
|
2126
|
+
margin-inline-start: -0.333rem;
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
/* Opens above its toggle, as in the embed. */
|
|
2130
|
+
.schematic-credit-usage__grants {
|
|
2131
|
+
background: var(--schematic-inset);
|
|
2132
|
+
border-radius: calc(var(--schematic-radius) * 0.8);
|
|
2133
|
+
display: flex;
|
|
2134
|
+
flex-direction: column;
|
|
2135
|
+
gap: 0.5rem;
|
|
2136
|
+
margin-bottom: 0.5rem;
|
|
2137
|
+
padding: calc(var(--schematic-space) * 1.5);
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
.schematic-credit-usage__grant-list {
|
|
2141
|
+
display: flex;
|
|
2142
|
+
flex-direction: column;
|
|
2143
|
+
gap: 0.75rem;
|
|
2144
|
+
list-style: none;
|
|
2145
|
+
margin: 0;
|
|
2146
|
+
padding: 0;
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
/* Where the grant and its date do not fit on one line, the date wraps
|
|
2150
|
+
rather than overflowing the panel. */
|
|
2151
|
+
.schematic-credit-usage__grant {
|
|
2152
|
+
display: flex;
|
|
2153
|
+
flex-wrap: wrap;
|
|
2154
|
+
gap: 0.25rem var(--schematic-space);
|
|
2155
|
+
justify-content: space-between;
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
.schematic-credit-usage__grant-text {
|
|
2159
|
+
flex: 1 1 12rem;
|
|
2160
|
+
min-width: 0;
|
|
2161
|
+
overflow-wrap: anywhere;
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
.schematic-credit-usage__grant-date {
|
|
2165
|
+
margin-inline-start: auto;
|
|
2166
|
+
text-align: end;
|
|
2167
|
+
white-space: nowrap;
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
.schematic-credit-usage .schematic-skeleton__cell[data-column="name"] {
|
|
2171
|
+
width: 10rem;
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
.schematic-credit-usage .schematic-skeleton__cell[data-column="remaining"] {
|
|
2175
|
+
width: 6rem;
|
|
2176
|
+
}
|
|
2177
|
+
`;
|
|
2178
|
+
|
|
1685
2179
|
// src/elements/styles/dialog.ts
|
|
1686
2180
|
var dialogCss = `
|
|
1687
2181
|
/* Up to 768px wide, with a tighter radius than a card. */
|
|
@@ -2368,26 +2862,258 @@ var invoicesCss = `
|
|
|
2368
2862
|
}
|
|
2369
2863
|
`;
|
|
2370
2864
|
|
|
2371
|
-
// src/elements/styles/
|
|
2372
|
-
var
|
|
2373
|
-
.schematic-
|
|
2865
|
+
// src/elements/styles/metered-features.ts
|
|
2866
|
+
var meteredFeaturesCss = `
|
|
2867
|
+
.schematic-metered-features__list {
|
|
2374
2868
|
display: flex;
|
|
2375
2869
|
flex-direction: column;
|
|
2376
2870
|
gap: var(--schematic-space);
|
|
2871
|
+
list-style: none;
|
|
2872
|
+
margin: 0;
|
|
2873
|
+
padding: 0;
|
|
2377
2874
|
}
|
|
2378
2875
|
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2876
|
+
/* Each feature is a card; while pending or failed, the root is the card. */
|
|
2877
|
+
.schematic-metered-features[data-state="pending"],
|
|
2878
|
+
.schematic-metered-features[data-state="error"] {
|
|
2879
|
+
background: var(--schematic-background);
|
|
2880
|
+
border-radius: var(--schematic-radius);
|
|
2881
|
+
box-shadow: var(--schematic-shadow);
|
|
2882
|
+
padding: calc(var(--schematic-card-padding) * 0.75)
|
|
2883
|
+
var(--schematic-card-padding);
|
|
2387
2884
|
}
|
|
2388
2885
|
|
|
2389
|
-
|
|
2390
|
-
|
|
2886
|
+
.schematic-metered-features__feature {
|
|
2887
|
+
container-type: inline-size;
|
|
2888
|
+
display: flex;
|
|
2889
|
+
flex-direction: column;
|
|
2890
|
+
gap: calc(var(--schematic-space) * 1.5);
|
|
2891
|
+
overflow: hidden;
|
|
2892
|
+
}
|
|
2893
|
+
|
|
2894
|
+
.schematic-metered-features__main {
|
|
2895
|
+
display: flex;
|
|
2896
|
+
gap: calc(var(--schematic-space) * 1.5);
|
|
2897
|
+
}
|
|
2898
|
+
|
|
2899
|
+
/* Kept without a glyph, as in the embed, so names line up. */
|
|
2900
|
+
.schematic-metered-features__icon {
|
|
2901
|
+
align-items: center;
|
|
2902
|
+
background: var(--schematic-surface);
|
|
2903
|
+
border-radius: 9999px;
|
|
2904
|
+
color: var(--schematic-accent);
|
|
2905
|
+
display: inline-flex;
|
|
2906
|
+
flex-shrink: 0;
|
|
2907
|
+
font-size: 1.5rem;
|
|
2908
|
+
height: 2.75rem;
|
|
2909
|
+
justify-content: center;
|
|
2910
|
+
width: 2.75rem;
|
|
2911
|
+
}
|
|
2912
|
+
|
|
2913
|
+
/* The glyph takes the base text colour rather than inheriting, so the accent
|
|
2914
|
+
is set on it too. */
|
|
2915
|
+
.schematic-metered-features__icon .schematic-icon {
|
|
2916
|
+
color: var(--schematic-accent);
|
|
2917
|
+
}
|
|
2918
|
+
|
|
2919
|
+
.schematic-metered-features__body {
|
|
2920
|
+
display: flex;
|
|
2921
|
+
flex-direction: column;
|
|
2922
|
+
flex-grow: 1;
|
|
2923
|
+
gap: calc(var(--schematic-space) * 2);
|
|
2924
|
+
min-width: 0;
|
|
2925
|
+
}
|
|
2926
|
+
|
|
2927
|
+
.schematic-metered-features__top {
|
|
2928
|
+
display: flex;
|
|
2929
|
+
flex-wrap: wrap;
|
|
2930
|
+
gap: var(--schematic-space);
|
|
2931
|
+
}
|
|
2932
|
+
|
|
2933
|
+
.schematic-metered-features__title {
|
|
2934
|
+
display: flex;
|
|
2935
|
+
flex: 1 1 min-content;
|
|
2936
|
+
flex-direction: column;
|
|
2937
|
+
gap: 0.5rem;
|
|
2938
|
+
}
|
|
2939
|
+
|
|
2940
|
+
.schematic-metered-features__name {
|
|
2941
|
+
font-family: var(--schematic-font-heading);
|
|
2942
|
+
font-size: 1.8125rem;
|
|
2943
|
+
font-weight: 800;
|
|
2944
|
+
line-height: var(--schematic-line-height-heading);
|
|
2945
|
+
margin: 0;
|
|
2946
|
+
}
|
|
2947
|
+
|
|
2948
|
+
/* Beside the title when both fit, otherwise beneath it as in the embed,
|
|
2949
|
+
rather than wrapping in a narrow column. */
|
|
2950
|
+
.schematic-metered-features__figures {
|
|
2951
|
+
display: flex;
|
|
2952
|
+
flex: 0 0 auto;
|
|
2953
|
+
flex-direction: column;
|
|
2954
|
+
gap: 0.25rem;
|
|
2955
|
+
max-width: 100%;
|
|
2956
|
+
text-align: end;
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
.schematic-metered-features__headline {
|
|
2960
|
+
font-size: 1.0625rem;
|
|
2961
|
+
font-variant-numeric: tabular-nums;
|
|
2962
|
+
font-weight: 500;
|
|
2963
|
+
white-space: nowrap;
|
|
2964
|
+
}
|
|
2965
|
+
|
|
2966
|
+
@container (max-width: 30rem) {
|
|
2967
|
+
.schematic-metered-features__figures {
|
|
2968
|
+
min-width: 0;
|
|
2969
|
+
text-align: start;
|
|
2970
|
+
}
|
|
2971
|
+
|
|
2972
|
+
/* Too narrow to keep "1,300 GB of storage used" on one line. */
|
|
2973
|
+
.schematic-metered-features__headline {
|
|
2974
|
+
white-space: normal;
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
|
|
2978
|
+
.schematic-metered-features__limit {
|
|
2979
|
+
font-variant-numeric: tabular-nums;
|
|
2980
|
+
}
|
|
2981
|
+
|
|
2982
|
+
.schematic-metered-features__add-more {
|
|
2983
|
+
align-self: flex-start;
|
|
2984
|
+
white-space: nowrap;
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
/* Negative margins undo the card's padding so the footer bleeds to its edges. */
|
|
2988
|
+
.schematic-metered-features__price-details {
|
|
2989
|
+
align-items: center;
|
|
2990
|
+
background: var(--schematic-surface);
|
|
2991
|
+
display: flex;
|
|
2992
|
+
gap: var(--schematic-space);
|
|
2993
|
+
justify-content: space-between;
|
|
2994
|
+
margin: 0 calc(var(--schematic-card-padding) * -1)
|
|
2995
|
+
calc(var(--schematic-card-padding) * -0.75);
|
|
2996
|
+
padding: calc(var(--schematic-card-padding) * 0.4375)
|
|
2997
|
+
var(--schematic-card-padding);
|
|
2998
|
+
}
|
|
2999
|
+
|
|
3000
|
+
.schematic-metered-features .schematic-skeleton__cell[data-column="name"] {
|
|
3001
|
+
width: 10rem;
|
|
3002
|
+
}
|
|
3003
|
+
|
|
3004
|
+
.schematic-metered-features .schematic-skeleton__cell[data-column="usage"] {
|
|
3005
|
+
width: 6rem;
|
|
3006
|
+
}
|
|
3007
|
+
|
|
3008
|
+
.schematic-metered-features__meter {
|
|
3009
|
+
align-items: center;
|
|
3010
|
+
display: flex;
|
|
3011
|
+
gap: var(--schematic-space);
|
|
3012
|
+
}
|
|
3013
|
+
|
|
3014
|
+
.schematic-metered-features__meter .schematic-meter {
|
|
3015
|
+
flex-grow: 1;
|
|
3016
|
+
min-width: 6rem;
|
|
3017
|
+
}
|
|
3018
|
+
|
|
3019
|
+
.schematic-meter--tier {
|
|
3020
|
+
background: color-mix(in srgb, var(--schematic-accent) 50%, transparent);
|
|
3021
|
+
}
|
|
3022
|
+
|
|
3023
|
+
/* Past the soft limit, the fill is the included share over a warning track. */
|
|
3024
|
+
.schematic-meter--overage {
|
|
3025
|
+
background: var(--schematic-warning);
|
|
3026
|
+
}
|
|
3027
|
+
|
|
3028
|
+
.schematic-metered-features__meter-label {
|
|
3029
|
+
font-size: 0.875rem;
|
|
3030
|
+
font-variant-numeric: tabular-nums;
|
|
3031
|
+
font-weight: 500;
|
|
3032
|
+
white-space: nowrap;
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
.schematic-usage-by-user {
|
|
3036
|
+
align-items: flex-start;
|
|
3037
|
+
display: flex;
|
|
3038
|
+
flex-direction: column;
|
|
3039
|
+
gap: 0.25rem;
|
|
3040
|
+
}
|
|
3041
|
+
|
|
3042
|
+
.schematic-usage-by-user__title {
|
|
3043
|
+
font-family: var(--schematic-font-heading);
|
|
3044
|
+
font-size: 1.125rem;
|
|
3045
|
+
font-weight: 800;
|
|
3046
|
+
}
|
|
3047
|
+
|
|
3048
|
+
.schematic-usage-by-user__list {
|
|
3049
|
+
align-self: stretch;
|
|
3050
|
+
list-style: none;
|
|
3051
|
+
margin: 0.5rem 0 0;
|
|
3052
|
+
padding: 0;
|
|
3053
|
+
}
|
|
3054
|
+
|
|
3055
|
+
.schematic-usage-by-user__user {
|
|
3056
|
+
align-items: center;
|
|
3057
|
+
display: flex;
|
|
3058
|
+
gap: 0.75rem;
|
|
3059
|
+
padding: 0.5rem 0;
|
|
3060
|
+
}
|
|
3061
|
+
|
|
3062
|
+
.schematic-usage-by-user__avatar {
|
|
3063
|
+
align-items: center;
|
|
3064
|
+
background: var(--schematic-surface);
|
|
3065
|
+
border-radius: 9999px;
|
|
3066
|
+
display: inline-flex;
|
|
3067
|
+
flex-shrink: 0;
|
|
3068
|
+
font-size: 0.6875rem;
|
|
3069
|
+
font-weight: 500;
|
|
3070
|
+
height: 1.75rem;
|
|
3071
|
+
justify-content: center;
|
|
3072
|
+
width: 1.75rem;
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
.schematic-usage-by-user__name {
|
|
3076
|
+
flex-grow: 1;
|
|
3077
|
+
overflow: hidden;
|
|
3078
|
+
text-overflow: ellipsis;
|
|
3079
|
+
white-space: nowrap;
|
|
3080
|
+
}
|
|
3081
|
+
|
|
3082
|
+
.schematic-usage-by-user__amount {
|
|
3083
|
+
text-align: end;
|
|
3084
|
+
}
|
|
3085
|
+
|
|
3086
|
+
.schematic-usage-by-user__toggle {
|
|
3087
|
+
align-items: center;
|
|
3088
|
+
display: inline-flex;
|
|
3089
|
+
gap: 0.25rem;
|
|
3090
|
+
}
|
|
3091
|
+
|
|
3092
|
+
.schematic-usage-by-user__toggle .schematic-chevron {
|
|
3093
|
+
margin-inline-start: -0.333rem;
|
|
3094
|
+
}
|
|
3095
|
+
`;
|
|
3096
|
+
|
|
3097
|
+
// src/elements/styles/payment-methods.ts
|
|
3098
|
+
var paymentMethodsCss = `
|
|
3099
|
+
.schematic-payment-methods {
|
|
3100
|
+
display: flex;
|
|
3101
|
+
flex-direction: column;
|
|
3102
|
+
gap: var(--schematic-space);
|
|
3103
|
+
}
|
|
3104
|
+
|
|
3105
|
+
.schematic-payment-methods .schematic-header {
|
|
3106
|
+
align-items: center;
|
|
3107
|
+
margin-bottom: 0;
|
|
3108
|
+
}
|
|
3109
|
+
|
|
3110
|
+
.schematic-payment-methods__expiry-warning {
|
|
3111
|
+
color: var(--schematic-danger);
|
|
3112
|
+
white-space: nowrap;
|
|
3113
|
+
}
|
|
3114
|
+
|
|
3115
|
+
/* The pill: the default method on the left, Edit or Add on the right. */
|
|
3116
|
+
.schematic-payment-methods__current {
|
|
2391
3117
|
align-items: center;
|
|
2392
3118
|
background: var(--schematic-surface);
|
|
2393
3119
|
border-radius: 9999px;
|
|
@@ -3335,13 +4061,15 @@ ${upcomingBillCss}
|
|
|
3335
4061
|
${paymentMethodsCss}
|
|
3336
4062
|
${tooltipCss}
|
|
3337
4063
|
${includedFeaturesCss}
|
|
4064
|
+
${meteredFeaturesCss}
|
|
4065
|
+
${creditUsageCss}
|
|
3338
4066
|
`;
|
|
3339
4067
|
var schematicStylesCss = withTokenDefaults(rulesCss) + iconsCss;
|
|
3340
4068
|
var SchematicStyles = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { "data-schematic-styles": "", children: schematicStylesCss });
|
|
3341
4069
|
|
|
3342
|
-
// src/elements/
|
|
4070
|
+
// src/elements/CreditUsage.tsx
|
|
3343
4071
|
var import_schematic_react2 = require("@schematichq/schematic-react");
|
|
3344
|
-
var
|
|
4072
|
+
var import_react3 = require("react");
|
|
3345
4073
|
|
|
3346
4074
|
// src/elements/common.tsx
|
|
3347
4075
|
var import_schematic_react = require("@schematichq/schematic-react");
|
|
@@ -3376,6 +4104,9 @@ function useTranslator(overrides, locale) {
|
|
|
3376
4104
|
const { onMissingString, strings, translate } = (0, import_schematic_react.useSchematicI18n)();
|
|
3377
4105
|
return (0, import_react.useCallback)(
|
|
3378
4106
|
(key, vars) => {
|
|
4107
|
+
if (isDevelopment) {
|
|
4108
|
+
warnRawNumbers(key, vars);
|
|
4109
|
+
}
|
|
3379
4110
|
const override = lookup(overrides, key, vars, resolved2) ?? lookup(strings, key, vars, resolved2);
|
|
3380
4111
|
if (override !== void 0) {
|
|
3381
4112
|
return override;
|
|
@@ -3397,6 +4128,18 @@ function useTranslator(overrides, locale) {
|
|
|
3397
4128
|
[onMissingString, overrides, resolved2, strings, translate]
|
|
3398
4129
|
);
|
|
3399
4130
|
}
|
|
4131
|
+
var rawNumberWarnings = /* @__PURE__ */ new Set();
|
|
4132
|
+
function warnRawNumbers(key, vars) {
|
|
4133
|
+
for (const [name, value] of Object.entries(vars ?? {})) {
|
|
4134
|
+
const id = `${key}.${name}`;
|
|
4135
|
+
if (name !== "count" && typeof value === "number" && !rawNumberWarnings.has(id)) {
|
|
4136
|
+
rawNumberWarnings.add(id);
|
|
4137
|
+
console.warn(
|
|
4138
|
+
`Schematic: "${key}" got a raw number for "${name}"; format it before it reaches the translator.`
|
|
4139
|
+
);
|
|
4140
|
+
}
|
|
4141
|
+
}
|
|
4142
|
+
}
|
|
3400
4143
|
var isDevelopment = (() => {
|
|
3401
4144
|
try {
|
|
3402
4145
|
return process.env.NODE_ENV !== "production";
|
|
@@ -3523,7 +4266,10 @@ var Dialog = ({ children, className, closeLabel, onClose, open, title, titleId }
|
|
|
3523
4266
|
};
|
|
3524
4267
|
|
|
3525
4268
|
// src/elements/usage.tsx
|
|
4269
|
+
var import_react2 = require("react");
|
|
3526
4270
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
4271
|
+
var COLLAPSED_USER_COUNT = 3;
|
|
4272
|
+
var EXPANDED_USER_COUNT = 20;
|
|
3527
4273
|
function shortPeriod(period, t) {
|
|
3528
4274
|
switch (period) {
|
|
3529
4275
|
case "month":
|
|
@@ -3577,89 +4323,468 @@ function PriceTiers({
|
|
|
3577
4323
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "schematic-tiers", children: [
|
|
3578
4324
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dl", { className: "schematic-tiers__list", children: ranges.map((tier) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "schematic-tiers__tier", children: [
|
|
3579
4325
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("dt", { className: "schematic-tiers__range", children: [
|
|
3580
|
-
tier.from,
|
|
3581
|
-
tier.to === null ? "+" : tier.to !== tier.from ? `\u2013${tier.to}` : ""
|
|
4326
|
+
formatNumber(tier.from, locale),
|
|
4327
|
+
tier.to === null ? "+" : tier.to !== tier.from ? `\u2013${formatNumber(tier.to, locale)}` : ""
|
|
3582
4328
|
] }),
|
|
3583
4329
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dd", { className: "schematic-tiers__price", children: tierPrice(tier.flatPrice ?? 0, tier.perUnitPrice ?? 0) })
|
|
3584
4330
|
] }, tier.from)) }),
|
|
3585
4331
|
mode !== null && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-tiers__mode", children: mode === "volume" ? t("usageTiersVolume") : t("usageTiersGraduated") })
|
|
3586
4332
|
] });
|
|
3587
4333
|
}
|
|
4334
|
+
function UserBreakdown({
|
|
4335
|
+
breakdown,
|
|
4336
|
+
error,
|
|
4337
|
+
formatAmount,
|
|
4338
|
+
locale,
|
|
4339
|
+
onRetry,
|
|
4340
|
+
t,
|
|
4341
|
+
unit
|
|
4342
|
+
}) {
|
|
4343
|
+
const [expanded, setExpanded] = (0, import_react2.useState)(false);
|
|
4344
|
+
const users = (0, import_react2.useMemo)(
|
|
4345
|
+
() => [...breakdown?.users ?? []].sort((a, b) => b.amount - a.amount),
|
|
4346
|
+
[breakdown?.users]
|
|
4347
|
+
);
|
|
4348
|
+
const amount = (value) => `${formatAmount?.(value) ?? formatNumber(value, locale)} ${featureName(unit, value, locale)}`;
|
|
4349
|
+
if (breakdown === void 0 && error !== void 0) {
|
|
4350
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "schematic-usage-by-user", role: "alert", children: [
|
|
4351
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-usage-by-user__title", children: t("usageByUserHeader") }),
|
|
4352
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-error", children: t("usageByUserError") }),
|
|
4353
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
4354
|
+
"button",
|
|
4355
|
+
{
|
|
4356
|
+
className: "schematic-cta schematic-cta--small schematic-cta--ghost schematic-status__retry",
|
|
4357
|
+
type: "button",
|
|
4358
|
+
onClick: onRetry,
|
|
4359
|
+
children: t("retry")
|
|
4360
|
+
}
|
|
4361
|
+
)
|
|
4362
|
+
] });
|
|
4363
|
+
}
|
|
4364
|
+
const unattributed = breakdown?.unattributed ?? null;
|
|
4365
|
+
if (breakdown === void 0 || users.length === 0 && unattributed === null) {
|
|
4366
|
+
return null;
|
|
4367
|
+
}
|
|
4368
|
+
const visible = users.slice(
|
|
4369
|
+
0,
|
|
4370
|
+
expanded ? EXPANDED_USER_COUNT : COLLAPSED_USER_COUNT
|
|
4371
|
+
);
|
|
4372
|
+
const remaining = Math.max(breakdown.count - visible.length, 0);
|
|
4373
|
+
const hidden = Math.max(
|
|
4374
|
+
Math.min(breakdown.count, EXPANDED_USER_COUNT) - Math.min(users.length, COLLAPSED_USER_COUNT),
|
|
4375
|
+
0
|
|
4376
|
+
);
|
|
4377
|
+
const expandLabel = breakdown.count > EXPANDED_USER_COUNT ? t("usageByUserShowTop", {
|
|
4378
|
+
count: EXPANDED_USER_COUNT,
|
|
4379
|
+
shown: formatNumber(EXPANDED_USER_COUNT, locale)
|
|
4380
|
+
}) : hidden > 0 ? t("usageByUserShowAllCount", {
|
|
4381
|
+
count: breakdown.count,
|
|
4382
|
+
shown: formatNumber(breakdown.count, locale)
|
|
4383
|
+
}) : t("usageByUserShowAll");
|
|
4384
|
+
const user = (key, label, value, muted = false) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("li", { className: "schematic-usage-by-user__user", children: [
|
|
4385
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "aria-hidden": "true", className: "schematic-usage-by-user__avatar", children: muted ? "?" : (label.trim()[0] ?? "?").toUpperCase() }),
|
|
4386
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
4387
|
+
"span",
|
|
4388
|
+
{
|
|
4389
|
+
className: cx(
|
|
4390
|
+
"schematic-usage-by-user__name",
|
|
4391
|
+
muted && "schematic-muted"
|
|
4392
|
+
),
|
|
4393
|
+
children: label
|
|
4394
|
+
}
|
|
4395
|
+
),
|
|
4396
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-muted schematic-usage-by-user__amount", children: amount(value) })
|
|
4397
|
+
] }, key);
|
|
4398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "schematic-usage-by-user", children: [
|
|
4399
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-usage-by-user__title", children: t("usageByUserHeader") }),
|
|
4400
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-muted", children: t("usageByUserTotal", { amount: amount(breakdown.total) }) }),
|
|
4401
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("ul", { className: "schematic-usage-by-user__list", children: [
|
|
4402
|
+
visible.map((entry) => user(entry.id, entry.label, entry.amount)),
|
|
4403
|
+
expanded && unattributed !== null && user(
|
|
4404
|
+
"unattributed",
|
|
4405
|
+
t("usageByUserUnattributed"),
|
|
4406
|
+
unattributed,
|
|
4407
|
+
true
|
|
4408
|
+
)
|
|
4409
|
+
] }),
|
|
4410
|
+
expanded && remaining > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-muted", children: t("usageByUserMore", {
|
|
4411
|
+
count: remaining,
|
|
4412
|
+
shown: formatNumber(remaining, locale)
|
|
4413
|
+
}) }),
|
|
4414
|
+
(hidden > 0 || unattributed !== null) && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
4415
|
+
"button",
|
|
4416
|
+
{
|
|
4417
|
+
"aria-expanded": expanded,
|
|
4418
|
+
className: "schematic-link-button schematic-usage-by-user__toggle",
|
|
4419
|
+
type: "button",
|
|
4420
|
+
onClick: () => setExpanded((value) => !value),
|
|
4421
|
+
children: [
|
|
4422
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
4423
|
+
"i",
|
|
4424
|
+
{
|
|
4425
|
+
"aria-hidden": "true",
|
|
4426
|
+
className: `schematic-icon schematic-icon--${expanded ? "chevron-up" : "chevron-down"} schematic-chevron`
|
|
4427
|
+
}
|
|
4428
|
+
),
|
|
4429
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "schematic-link-button__label", children: expanded ? t("usageByUserShowFewer") : expandLabel })
|
|
4430
|
+
]
|
|
4431
|
+
}
|
|
4432
|
+
)
|
|
4433
|
+
] });
|
|
4434
|
+
}
|
|
3588
4435
|
|
|
3589
|
-
// src/elements/
|
|
4436
|
+
// src/elements/CreditUsage.tsx
|
|
3590
4437
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
3591
|
-
var
|
|
3592
|
-
|
|
4438
|
+
var VISIBLE_GRANT_COUNT = 3;
|
|
4439
|
+
var GRANT_KEY = {
|
|
4440
|
+
autoTopup: "creditUsageGrantAutoTopup",
|
|
4441
|
+
bundle: "creditUsageGrantBundle",
|
|
4442
|
+
plan: "creditUsageGrantPlan",
|
|
4443
|
+
promotional: "creditUsageGrantPromotional"
|
|
4444
|
+
};
|
|
4445
|
+
function CreditUsage({
|
|
4446
|
+
buyMoreTarget,
|
|
4447
|
+
buyMoreUrl,
|
|
3593
4448
|
className,
|
|
3594
4449
|
headingLevel = 2,
|
|
3595
4450
|
locale: localeProp,
|
|
3596
|
-
|
|
4451
|
+
onBuyMore,
|
|
3597
4452
|
showDescription = true,
|
|
3598
|
-
showEntitlement = true,
|
|
3599
4453
|
showExpiration = true,
|
|
3600
|
-
|
|
3601
|
-
showHeader = true,
|
|
4454
|
+
showHeader = false,
|
|
3602
4455
|
showIcon = true,
|
|
3603
4456
|
showUsage = true,
|
|
3604
|
-
|
|
4457
|
+
showUsageByUser = true,
|
|
3605
4458
|
strings,
|
|
3606
|
-
|
|
4459
|
+
visibleCredits
|
|
3607
4460
|
}) {
|
|
3608
|
-
const { data:
|
|
4461
|
+
const { data: balances, error, isPending, refetch } = (0, import_schematic_react2.useCreditBalances)();
|
|
3609
4462
|
const locale = useResolvedLocale(localeProp);
|
|
3610
4463
|
const t = useTranslator(strings, localeProp);
|
|
3611
|
-
const
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
locale,
|
|
3615
|
-
showCredits,
|
|
3616
|
-
showWarningThresholdAsLimit,
|
|
3617
|
-
visibleFeatures
|
|
3618
|
-
}),
|
|
3619
|
-
[
|
|
3620
|
-
features,
|
|
3621
|
-
locale,
|
|
3622
|
-
showCredits,
|
|
3623
|
-
showWarningThresholdAsLimit,
|
|
3624
|
-
visibleFeatures
|
|
3625
|
-
]
|
|
4464
|
+
const credits = (0, import_react3.useMemo)(
|
|
4465
|
+
() => balances === void 0 ? [] : deriveCreditUsage(balances, { locale, visibleCredits }),
|
|
4466
|
+
[balances, locale, visibleCredits]
|
|
3626
4467
|
);
|
|
4468
|
+
const unavailable = balances === void 0 && httpStatus(error) === 404;
|
|
4469
|
+
const errorMessage = error === void 0 ? void 0 : unavailable ? t("creditUsageUnavailable") : t("creditUsageError");
|
|
4470
|
+
if (balances !== void 0 && error === void 0 && credits.length === 0) {
|
|
4471
|
+
return null;
|
|
4472
|
+
}
|
|
3627
4473
|
const Heading = `h${headingLevel}`;
|
|
3628
|
-
const
|
|
3629
|
-
const shown = canExpand && !expanded ? rows.slice(0, VISIBLE_FEATURE_COUNT) : rows;
|
|
3630
|
-
const unavailable = features === void 0 && httpStatus(error) === 404;
|
|
3631
|
-
const errorMessage = error === void 0 ? void 0 : unavailable ? t("includedFeaturesUnavailable") : t("includedFeaturesError");
|
|
4474
|
+
const CreditHeading = showHeader ? `h${Math.min(6, headingLevel + 1)}` : Heading;
|
|
3632
4475
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
3633
4476
|
StatusFrame,
|
|
3634
4477
|
{
|
|
3635
|
-
className: cx("schematic-
|
|
4478
|
+
className: cx("schematic-credit-usage", className),
|
|
3636
4479
|
error,
|
|
3637
4480
|
errorMessage,
|
|
3638
|
-
hasData:
|
|
4481
|
+
hasData: balances !== void 0,
|
|
3639
4482
|
isPending,
|
|
3640
|
-
loadingLabel: t("
|
|
4483
|
+
loadingLabel: t("creditUsageLoading"),
|
|
3641
4484
|
onRetry: refetch,
|
|
3642
4485
|
retryText: t("retry"),
|
|
3643
|
-
skeleton: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4486
|
+
skeleton: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CreditUsageSkeleton, { showHeader }),
|
|
3644
4487
|
children: [
|
|
3645
|
-
showHeader && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-header", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Heading, { className: "schematic-header__title", children: t("
|
|
3646
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("
|
|
4488
|
+
showHeader && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-header", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Heading, { className: "schematic-header__title", children: t("creditUsageHeader") }) }),
|
|
4489
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-credit-usage__credits", children: credits.map((credit) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
4490
|
+
"section",
|
|
4491
|
+
{
|
|
4492
|
+
"aria-label": credit.name,
|
|
4493
|
+
className: "schematic-card schematic-credit-usage__credit",
|
|
4494
|
+
"data-testid": "schematic-credit",
|
|
4495
|
+
children: [
|
|
4496
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-credit-usage__main", children: [
|
|
4497
|
+
showIcon && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "schematic-credit-usage__icon", children: credit.icon !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4498
|
+
"i",
|
|
4499
|
+
{
|
|
4500
|
+
"aria-hidden": "true",
|
|
4501
|
+
className: `schematic-icon schematic-icon--${credit.icon}`
|
|
4502
|
+
}
|
|
4503
|
+
) }),
|
|
4504
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-credit-usage__body", children: [
|
|
4505
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-credit-usage__title", children: [
|
|
4506
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CreditHeading, { className: "schematic-credit-usage__name", children: credit.name }),
|
|
4507
|
+
showDescription && credit.description !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "schematic-muted", children: credit.description })
|
|
4508
|
+
] }),
|
|
4509
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-credit-usage__balance", children: [
|
|
4510
|
+
showUsage && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4511
|
+
"span",
|
|
4512
|
+
{
|
|
4513
|
+
className: "schematic-credit-usage__remaining",
|
|
4514
|
+
"data-testid": "schematic-credit-remaining",
|
|
4515
|
+
children: t("creditUsageRemaining", credit.remaining)
|
|
4516
|
+
}
|
|
4517
|
+
),
|
|
4518
|
+
credit.purchasable && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4519
|
+
BuyMore,
|
|
4520
|
+
{
|
|
4521
|
+
credit,
|
|
4522
|
+
label: t("creditUsageBuyMore"),
|
|
4523
|
+
onBuyMore,
|
|
4524
|
+
target: buyMoreTarget,
|
|
4525
|
+
url: buyMoreUrl
|
|
4526
|
+
}
|
|
4527
|
+
)
|
|
4528
|
+
] }),
|
|
4529
|
+
credit.composition !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "schematic-muted schematic-small schematic-credit-usage__composition", children: compositionText(credit, t) })
|
|
4530
|
+
] })
|
|
4531
|
+
] }),
|
|
4532
|
+
credit.ledger.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4533
|
+
Ledger,
|
|
4534
|
+
{
|
|
4535
|
+
credit,
|
|
4536
|
+
locale,
|
|
4537
|
+
showExpiration,
|
|
4538
|
+
t
|
|
4539
|
+
}
|
|
4540
|
+
),
|
|
4541
|
+
showUsageByUser && credit.ledger.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CreditUserBreakdown, { credit, locale, t })
|
|
4542
|
+
]
|
|
4543
|
+
},
|
|
4544
|
+
credit.creditId
|
|
4545
|
+
)) })
|
|
4546
|
+
]
|
|
4547
|
+
}
|
|
4548
|
+
);
|
|
4549
|
+
}
|
|
4550
|
+
function compositionText(credit, t) {
|
|
4551
|
+
const composition = credit.composition;
|
|
4552
|
+
if (composition === null) {
|
|
4553
|
+
return "";
|
|
4554
|
+
}
|
|
4555
|
+
const vars = {
|
|
4556
|
+
creditName: composition.creditName,
|
|
4557
|
+
perLicense: t("creditUsagePerLicense", composition.perLicense),
|
|
4558
|
+
period: shortPeriod(composition.period, t) ?? composition.period,
|
|
4559
|
+
total: composition.total
|
|
4560
|
+
};
|
|
4561
|
+
const sentence = composition.companyGrant === null ? t("creditUsageComposition", vars) : t("creditUsageCompositionWithGrant", {
|
|
4562
|
+
...vars,
|
|
4563
|
+
companyGrant: t("creditUsageCompanyGrant", {
|
|
4564
|
+
amount: composition.companyGrant
|
|
4565
|
+
})
|
|
4566
|
+
});
|
|
4567
|
+
return composition.renewsOn === null ? sentence : `${sentence} ${t("creditUsageRenewsOn", { day: composition.renewsOn })}`;
|
|
4568
|
+
}
|
|
4569
|
+
function Ledger({
|
|
4570
|
+
credit,
|
|
4571
|
+
locale,
|
|
4572
|
+
showExpiration,
|
|
4573
|
+
t
|
|
4574
|
+
}) {
|
|
4575
|
+
const [open, setOpen] = (0, import_react3.useState)(false);
|
|
4576
|
+
const [all, setAll] = (0, import_react3.useState)(false);
|
|
4577
|
+
const rows = all ? credit.ledger : credit.ledger.slice(0, VISIBLE_GRANT_COUNT);
|
|
4578
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-credit-usage__ledger", children: [
|
|
4579
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-credit-usage__grants", children: [
|
|
4580
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: "schematic-credit-usage__grant-list", children: rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
4581
|
+
"li",
|
|
4582
|
+
{
|
|
4583
|
+
className: "schematic-credit-usage__grant",
|
|
4584
|
+
"data-testid": "schematic-credit-grant",
|
|
4585
|
+
children: [
|
|
4586
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "schematic-credit-usage__grant-text", children: t(GRANT_KEY[row.kind], {
|
|
4587
|
+
amount: row.amount,
|
|
4588
|
+
createdAt: row.createdAt,
|
|
4589
|
+
item: row.item
|
|
4590
|
+
}) }),
|
|
4591
|
+
showExpiration && row.date !== null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "schematic-credit-usage__grant-date", children: row.date.kind === "resets" ? t("creditUsageResets", { date: row.date.text }) : t("creditUsageExpires", { date: row.date.text }) })
|
|
4592
|
+
]
|
|
4593
|
+
},
|
|
4594
|
+
row.id
|
|
4595
|
+
)) }),
|
|
4596
|
+
credit.ledger.length > VISIBLE_GRANT_COUNT && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
4597
|
+
"button",
|
|
4598
|
+
{
|
|
4599
|
+
"aria-expanded": all,
|
|
4600
|
+
className: "schematic-link-button schematic-credit-usage__see-all",
|
|
4601
|
+
type: "button",
|
|
4602
|
+
onClick: () => setAll((value) => !value),
|
|
4603
|
+
children: [
|
|
4604
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4605
|
+
"i",
|
|
4606
|
+
{
|
|
4607
|
+
"aria-hidden": "true",
|
|
4608
|
+
className: `schematic-icon schematic-icon--${all ? "chevron-up" : "chevron-down"} schematic-chevron`
|
|
4609
|
+
}
|
|
4610
|
+
),
|
|
4611
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "schematic-link-button__label", children: all ? t("creditUsageHideAll") : t("creditUsageSeeAll", {
|
|
4612
|
+
total: formatNumber(credit.ledger.length, locale)
|
|
4613
|
+
}) })
|
|
4614
|
+
]
|
|
4615
|
+
}
|
|
4616
|
+
)
|
|
4617
|
+
] }),
|
|
4618
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
4619
|
+
"button",
|
|
4620
|
+
{
|
|
4621
|
+
"aria-expanded": open,
|
|
4622
|
+
className: "schematic-link-button schematic-credit-usage__details",
|
|
4623
|
+
type: "button",
|
|
4624
|
+
onClick: () => {
|
|
4625
|
+
setOpen((value) => !value);
|
|
4626
|
+
setAll(false);
|
|
4627
|
+
},
|
|
4628
|
+
children: [
|
|
4629
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4630
|
+
"i",
|
|
4631
|
+
{
|
|
4632
|
+
"aria-hidden": "true",
|
|
4633
|
+
className: `schematic-icon schematic-icon--${open ? "chevron-up" : "chevron-down"} schematic-chevron`
|
|
4634
|
+
}
|
|
4635
|
+
),
|
|
4636
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "schematic-link-button__label", children: open ? t("creditUsageHideDetails") : t("creditUsageSeeDetails") })
|
|
4637
|
+
]
|
|
4638
|
+
}
|
|
4639
|
+
)
|
|
4640
|
+
] });
|
|
4641
|
+
}
|
|
4642
|
+
function BuyMore({
|
|
4643
|
+
credit,
|
|
4644
|
+
label,
|
|
4645
|
+
onBuyMore,
|
|
4646
|
+
target,
|
|
4647
|
+
url
|
|
4648
|
+
}) {
|
|
4649
|
+
if (onBuyMore !== void 0) {
|
|
4650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4651
|
+
"button",
|
|
4652
|
+
{
|
|
4653
|
+
className: "schematic-cta schematic-cta--small schematic-credit-usage__buy-more",
|
|
4654
|
+
type: "button",
|
|
4655
|
+
onClick: () => onBuyMore(credit.source),
|
|
4656
|
+
children: label
|
|
4657
|
+
}
|
|
4658
|
+
);
|
|
4659
|
+
}
|
|
4660
|
+
if (url !== void 0) {
|
|
4661
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4662
|
+
"a",
|
|
4663
|
+
{
|
|
4664
|
+
className: "schematic-cta schematic-cta--small schematic-credit-usage__buy-more",
|
|
4665
|
+
href: url,
|
|
4666
|
+
target,
|
|
4667
|
+
children: label
|
|
4668
|
+
}
|
|
4669
|
+
);
|
|
4670
|
+
}
|
|
4671
|
+
return null;
|
|
4672
|
+
}
|
|
4673
|
+
function CreditUserBreakdown({
|
|
4674
|
+
credit,
|
|
4675
|
+
locale,
|
|
4676
|
+
t
|
|
4677
|
+
}) {
|
|
4678
|
+
const { data, error, refetch } = (0, import_schematic_react2.useCreditUserUsage)(credit.creditId);
|
|
4679
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4680
|
+
UserBreakdown,
|
|
4681
|
+
{
|
|
4682
|
+
breakdown: data === void 0 ? void 0 : {
|
|
4683
|
+
count: data.count,
|
|
4684
|
+
total: data.total,
|
|
4685
|
+
unattributed: data.unattributed ?? null,
|
|
4686
|
+
users: data.users.map((user) => ({
|
|
4687
|
+
amount: user.used,
|
|
4688
|
+
id: user.userId,
|
|
4689
|
+
label: user.name ?? user.userId
|
|
4690
|
+
}))
|
|
4691
|
+
},
|
|
4692
|
+
error,
|
|
4693
|
+
formatAmount: (value) => formatCredits(value, locale),
|
|
4694
|
+
locale,
|
|
4695
|
+
onRetry: refetch,
|
|
4696
|
+
t,
|
|
4697
|
+
unit: credit.unit
|
|
4698
|
+
}
|
|
4699
|
+
);
|
|
4700
|
+
}
|
|
4701
|
+
function CreditUsageSkeleton({ showHeader }) {
|
|
4702
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-skeleton", children: [
|
|
4703
|
+
showHeader && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-skeleton__heading" }),
|
|
4704
|
+
[0, 1].map((index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "schematic-skeleton__row", children: [
|
|
4705
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "name" }),
|
|
4706
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "remaining" })
|
|
4707
|
+
] }, index))
|
|
4708
|
+
] });
|
|
4709
|
+
}
|
|
4710
|
+
CreditUsage.resources = ["creditBalances"];
|
|
4711
|
+
|
|
4712
|
+
// src/elements/IncludedFeatures.tsx
|
|
4713
|
+
var import_schematic_react3 = require("@schematichq/schematic-react");
|
|
4714
|
+
var import_react4 = require("react");
|
|
4715
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
4716
|
+
var VISIBLE_FEATURE_COUNT = 4;
|
|
4717
|
+
function IncludedFeatures({
|
|
4718
|
+
className,
|
|
4719
|
+
headingLevel = 2,
|
|
4720
|
+
locale: localeProp,
|
|
4721
|
+
showCredits = true,
|
|
4722
|
+
showDescription = true,
|
|
4723
|
+
showEntitlement = true,
|
|
4724
|
+
showExpiration = true,
|
|
4725
|
+
showHardLimit = false,
|
|
4726
|
+
showHeader = true,
|
|
4727
|
+
showIcon = true,
|
|
4728
|
+
showUsage = true,
|
|
4729
|
+
showWarningThresholdAsLimit = false,
|
|
4730
|
+
strings,
|
|
4731
|
+
visibleFeatures
|
|
4732
|
+
}) {
|
|
4733
|
+
const { data: features, error, isPending, refetch } = (0, import_schematic_react3.useFeatureUsage)();
|
|
4734
|
+
const locale = useResolvedLocale(localeProp);
|
|
4735
|
+
const t = useTranslator(strings, localeProp);
|
|
4736
|
+
const [expanded, setExpanded] = (0, import_react4.useState)(false);
|
|
4737
|
+
const rows = (0, import_react4.useMemo)(
|
|
4738
|
+
() => features === void 0 ? [] : deriveIncludedFeatures(features, {
|
|
4739
|
+
locale,
|
|
4740
|
+
showCredits,
|
|
4741
|
+
showWarningThresholdAsLimit,
|
|
4742
|
+
visibleFeatures
|
|
4743
|
+
}),
|
|
4744
|
+
[
|
|
4745
|
+
features,
|
|
4746
|
+
locale,
|
|
4747
|
+
showCredits,
|
|
4748
|
+
showWarningThresholdAsLimit,
|
|
4749
|
+
visibleFeatures
|
|
4750
|
+
]
|
|
4751
|
+
);
|
|
4752
|
+
const Heading = `h${headingLevel}`;
|
|
4753
|
+
const canExpand = rows.length > VISIBLE_FEATURE_COUNT;
|
|
4754
|
+
const shown = canExpand && !expanded ? rows.slice(0, VISIBLE_FEATURE_COUNT) : rows;
|
|
4755
|
+
const unavailable = features === void 0 && httpStatus(error) === 404;
|
|
4756
|
+
const errorMessage = error === void 0 ? void 0 : unavailable ? t("includedFeaturesUnavailable") : t("includedFeaturesError");
|
|
4757
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4758
|
+
StatusFrame,
|
|
4759
|
+
{
|
|
4760
|
+
className: cx("schematic-card", "schematic-included-features", className),
|
|
4761
|
+
error,
|
|
4762
|
+
errorMessage,
|
|
4763
|
+
hasData: features !== void 0,
|
|
4764
|
+
isPending,
|
|
4765
|
+
loadingLabel: t("includedFeaturesLoading"),
|
|
4766
|
+
onRetry: refetch,
|
|
4767
|
+
retryText: t("retry"),
|
|
4768
|
+
skeleton: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(IncludedFeaturesSkeleton, { showHeader }),
|
|
4769
|
+
children: [
|
|
4770
|
+
showHeader && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "schematic-header", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Heading, { className: "schematic-header__title", children: t("includedFeaturesHeader") }) }),
|
|
4771
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { className: "schematic-included-features__list", children: shown.map((row) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3647
4772
|
"li",
|
|
3648
4773
|
{
|
|
3649
4774
|
className: "schematic-included-features__row",
|
|
3650
4775
|
"data-testid": "schematic-included-feature",
|
|
3651
4776
|
children: [
|
|
3652
|
-
showIcon && row.icon !== null && /* @__PURE__ */ (0,
|
|
4777
|
+
showIcon && row.icon !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3653
4778
|
"i",
|
|
3654
4779
|
{
|
|
3655
4780
|
"aria-hidden": "true",
|
|
3656
4781
|
className: `schematic-icon schematic-icon--${row.icon} schematic-included-features__icon`
|
|
3657
4782
|
}
|
|
3658
4783
|
),
|
|
3659
|
-
/* @__PURE__ */ (0,
|
|
3660
|
-
/* @__PURE__ */ (0,
|
|
3661
|
-
showDescription && row.description !== null && /* @__PURE__ */ (0,
|
|
3662
|
-
row.perLicenseCredits.map((credits, index) => /* @__PURE__ */ (0,
|
|
4784
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "schematic-included-features__details", children: [
|
|
4785
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "schematic-included-features__name", children: row.name }),
|
|
4786
|
+
showDescription && row.description !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "schematic-muted schematic-small", children: row.description }),
|
|
4787
|
+
row.perLicenseCredits.map((credits, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3663
4788
|
"span",
|
|
3664
4789
|
{
|
|
3665
4790
|
className: "schematic-muted schematic-small",
|
|
@@ -3671,9 +4796,9 @@ function IncludedFeatures({
|
|
|
3671
4796
|
},
|
|
3672
4797
|
`${credits.creditName}-${index}`
|
|
3673
4798
|
)),
|
|
3674
|
-
showExpiration && row.expiresAt !== null && /* @__PURE__ */ (0,
|
|
4799
|
+
showExpiration && row.expiresAt !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("em", { className: "schematic-muted schematic-small", children: t("includedFeaturesExpires", { date: row.expiresAt.text }) })
|
|
3675
4800
|
] }),
|
|
3676
|
-
/* @__PURE__ */ (0,
|
|
4801
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3677
4802
|
UsageDetails,
|
|
3678
4803
|
{
|
|
3679
4804
|
row,
|
|
@@ -3688,7 +4813,7 @@ function IncludedFeatures({
|
|
|
3688
4813
|
},
|
|
3689
4814
|
row.featureId
|
|
3690
4815
|
)) }),
|
|
3691
|
-
canExpand && /* @__PURE__ */ (0,
|
|
4816
|
+
canExpand && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3692
4817
|
"button",
|
|
3693
4818
|
{
|
|
3694
4819
|
"aria-expanded": expanded,
|
|
@@ -3696,14 +4821,14 @@ function IncludedFeatures({
|
|
|
3696
4821
|
type: "button",
|
|
3697
4822
|
onClick: () => setExpanded((value) => !value),
|
|
3698
4823
|
children: [
|
|
3699
|
-
/* @__PURE__ */ (0,
|
|
4824
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3700
4825
|
"i",
|
|
3701
4826
|
{
|
|
3702
4827
|
"aria-hidden": "true",
|
|
3703
4828
|
className: `schematic-icon schematic-icon--${expanded ? "chevron-up" : "chevron-down"} schematic-chevron`
|
|
3704
4829
|
}
|
|
3705
4830
|
),
|
|
3706
|
-
/* @__PURE__ */ (0,
|
|
4831
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "schematic-link-button__label", children: expanded ? t("includedFeaturesHideAll") : t("includedFeaturesSeeAll") })
|
|
3707
4832
|
]
|
|
3708
4833
|
}
|
|
3709
4834
|
)
|
|
@@ -3723,17 +4848,17 @@ function UsageDetails({
|
|
|
3723
4848
|
if (row.entitlement === null && usage === null) {
|
|
3724
4849
|
return null;
|
|
3725
4850
|
}
|
|
3726
|
-
return /* @__PURE__ */ (0,
|
|
3727
|
-
showEntitlement && row.entitlement !== null && /* @__PURE__ */ (0,
|
|
4851
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "schematic-included-features__usage", children: [
|
|
4852
|
+
showEntitlement && row.entitlement !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "schematic-included-features__entitlement", children: [
|
|
3728
4853
|
entitlementText2(row.entitlement, t),
|
|
3729
|
-
showHardLimit && row.hardLimit !== null && /* @__PURE__ */ (0,
|
|
4854
|
+
showHardLimit && row.hardLimit !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Tooltip, { label: t("usageHardLimitLabel"), children: t("usageHardLimit", {
|
|
3730
4855
|
amount: row.hardLimit.amount,
|
|
3731
4856
|
units: row.hardLimit.units
|
|
3732
4857
|
}) })
|
|
3733
4858
|
] }),
|
|
3734
|
-
showUsage && usage !== null && /* @__PURE__ */ (0,
|
|
4859
|
+
showUsage && usage !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "schematic-muted schematic-small schematic-included-features__used", children: [
|
|
3735
4860
|
usage,
|
|
3736
|
-
row.tiers !== null && row.tiers.ranges.length > 0 && /* @__PURE__ */ (0,
|
|
4861
|
+
row.tiers !== null && row.tiers.ranges.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Tooltip, { label: t("usageTieredPricingLabel"), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3737
4862
|
PriceTiers,
|
|
3738
4863
|
{
|
|
3739
4864
|
currency: row.tiers.currency,
|
|
@@ -3786,7 +4911,7 @@ function segmentText(segment, t) {
|
|
|
3786
4911
|
switch (segment.kind) {
|
|
3787
4912
|
case "unitPricePerPeriod": {
|
|
3788
4913
|
const period = shortPeriod(segment.period, t) ?? segment.period;
|
|
3789
|
-
return segment.size
|
|
4914
|
+
return segment.size !== null ? t("usagePackagePricePerPeriod", {
|
|
3790
4915
|
cost: segment.cost,
|
|
3791
4916
|
size: segment.size,
|
|
3792
4917
|
units: segment.units,
|
|
@@ -3808,20 +4933,20 @@ function segmentText(segment, t) {
|
|
|
3808
4933
|
}
|
|
3809
4934
|
}
|
|
3810
4935
|
function IncludedFeaturesSkeleton({ showHeader }) {
|
|
3811
|
-
return /* @__PURE__ */ (0,
|
|
3812
|
-
showHeader && /* @__PURE__ */ (0,
|
|
3813
|
-
[0, 1, 2].map((index) => /* @__PURE__ */ (0,
|
|
3814
|
-
/* @__PURE__ */ (0,
|
|
3815
|
-
/* @__PURE__ */ (0,
|
|
4936
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "schematic-skeleton", children: [
|
|
4937
|
+
showHeader && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "schematic-skeleton__heading" }),
|
|
4938
|
+
[0, 1, 2].map((index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "schematic-skeleton__row", children: [
|
|
4939
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "name" }),
|
|
4940
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "usage" })
|
|
3816
4941
|
] }, index))
|
|
3817
4942
|
] });
|
|
3818
4943
|
}
|
|
3819
4944
|
IncludedFeatures.resources = ["featureUsage"];
|
|
3820
4945
|
|
|
3821
4946
|
// src/elements/Invoices.tsx
|
|
3822
|
-
var
|
|
3823
|
-
var
|
|
3824
|
-
var
|
|
4947
|
+
var import_schematic_react4 = require("@schematichq/schematic-react");
|
|
4948
|
+
var import_react5 = require("react");
|
|
4949
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
3825
4950
|
var SKELETON_ROWS = 4;
|
|
3826
4951
|
function Invoices({
|
|
3827
4952
|
className,
|
|
@@ -3841,15 +4966,15 @@ function Invoices({
|
|
|
3841
4966
|
isPending,
|
|
3842
4967
|
loadMore,
|
|
3843
4968
|
refetch
|
|
3844
|
-
} = (0,
|
|
4969
|
+
} = (0, import_schematic_react4.useInvoices)(query);
|
|
3845
4970
|
const locale = useResolvedLocale(localeProp);
|
|
3846
4971
|
const t = useTranslator(strings, localeProp);
|
|
3847
|
-
const [expanded, setExpanded] = (0,
|
|
3848
|
-
const list = (0,
|
|
4972
|
+
const [expanded, setExpanded] = (0, import_react5.useState)(false);
|
|
4973
|
+
const list = (0, import_react5.useMemo)(
|
|
3849
4974
|
() => page === void 0 ? void 0 : deriveInvoiceList(page, { locale }),
|
|
3850
4975
|
[locale, page]
|
|
3851
4976
|
);
|
|
3852
|
-
const headingId = (0,
|
|
4977
|
+
const headingId = (0, import_react5.useId)();
|
|
3853
4978
|
const rows = list?.rows ?? [];
|
|
3854
4979
|
const canCollapse = collapsible && rows.length > limit;
|
|
3855
4980
|
const showingAll = !canCollapse || expanded;
|
|
@@ -3861,7 +4986,7 @@ function Invoices({
|
|
|
3861
4986
|
);
|
|
3862
4987
|
const unavailable = list === void 0 && httpStatus(error) === 404;
|
|
3863
4988
|
const errorMessage = error === void 0 ? void 0 : unavailable ? t("invoicesUnavailable") : t("invoicesError");
|
|
3864
|
-
return /* @__PURE__ */ (0,
|
|
4989
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3865
4990
|
StatusFrame,
|
|
3866
4991
|
{
|
|
3867
4992
|
className: cx("schematic-card", "schematic-invoices", className),
|
|
@@ -3872,7 +4997,7 @@ function Invoices({
|
|
|
3872
4997
|
loadingLabel: t("invoicesLoading"),
|
|
3873
4998
|
onRetry: refetch,
|
|
3874
4999
|
retryText: t("retry"),
|
|
3875
|
-
skeleton: /* @__PURE__ */ (0,
|
|
5000
|
+
skeleton: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3876
5001
|
InvoicesSkeleton,
|
|
3877
5002
|
{
|
|
3878
5003
|
columns,
|
|
@@ -3880,22 +5005,22 @@ function Invoices({
|
|
|
3880
5005
|
showHeader
|
|
3881
5006
|
}
|
|
3882
5007
|
),
|
|
3883
|
-
children: list !== void 0 && /* @__PURE__ */ (0,
|
|
3884
|
-
showHeader && /* @__PURE__ */ (0,
|
|
3885
|
-
rows.length === 0 ? /* @__PURE__ */ (0,
|
|
5008
|
+
children: list !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
5009
|
+
showHeader && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "schematic-header", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Heading, { className: "schematic-header__title", id: headingId, children: t("invoicesHeader") }) }),
|
|
5010
|
+
rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "schematic-muted schematic-invoices__empty", children: t("invoicesEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3886
5011
|
"ul",
|
|
3887
5012
|
{
|
|
3888
5013
|
className: "schematic-invoices__list",
|
|
3889
5014
|
"aria-label": showHeader ? void 0 : t("invoicesHeader"),
|
|
3890
5015
|
"aria-labelledby": showHeader ? headingId : void 0,
|
|
3891
|
-
children: visible.map((row) => /* @__PURE__ */ (0,
|
|
5016
|
+
children: visible.map((row) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
3892
5017
|
"li",
|
|
3893
5018
|
{
|
|
3894
5019
|
className: "schematic-invoices__row",
|
|
3895
5020
|
"data-testid": "schematic-invoice",
|
|
3896
5021
|
children: [
|
|
3897
|
-
showDate && /* @__PURE__ */ (0,
|
|
3898
|
-
showAmount && /* @__PURE__ */ (0,
|
|
5022
|
+
showDate && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "schematic-invoices__date", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(InvoiceDate, { row, t }) }),
|
|
5023
|
+
showAmount && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3899
5024
|
"span",
|
|
3900
5025
|
{
|
|
3901
5026
|
className: cx(
|
|
@@ -3912,8 +5037,8 @@ function Invoices({
|
|
|
3912
5037
|
))
|
|
3913
5038
|
}
|
|
3914
5039
|
),
|
|
3915
|
-
(canCollapse || showingAll && list.hasMore) && /* @__PURE__ */ (0,
|
|
3916
|
-
canCollapse && /* @__PURE__ */ (0,
|
|
5040
|
+
(canCollapse || showingAll && list.hasMore) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "schematic-invoices__actions", children: [
|
|
5041
|
+
canCollapse && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
3917
5042
|
"button",
|
|
3918
5043
|
{
|
|
3919
5044
|
"aria-expanded": expanded,
|
|
@@ -3921,7 +5046,7 @@ function Invoices({
|
|
|
3921
5046
|
type: "button",
|
|
3922
5047
|
onClick: () => setExpanded((value) => !value),
|
|
3923
5048
|
children: [
|
|
3924
|
-
/* @__PURE__ */ (0,
|
|
5049
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3925
5050
|
"i",
|
|
3926
5051
|
{
|
|
3927
5052
|
"aria-hidden": "true",
|
|
@@ -3933,11 +5058,11 @@ function Invoices({
|
|
|
3933
5058
|
)
|
|
3934
5059
|
}
|
|
3935
5060
|
),
|
|
3936
|
-
/* @__PURE__ */ (0,
|
|
5061
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "schematic-link-button__label", children: expanded ? t("invoicesSeeLess") : t("invoicesSeeMore") })
|
|
3937
5062
|
]
|
|
3938
5063
|
}
|
|
3939
5064
|
),
|
|
3940
|
-
showingAll && list.hasMore && /* @__PURE__ */ (0,
|
|
5065
|
+
showingAll && list.hasMore && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3941
5066
|
"button",
|
|
3942
5067
|
{
|
|
3943
5068
|
className: "schematic-link-button schematic-invoices__load-more",
|
|
@@ -3960,9 +5085,9 @@ function InvoicesSkeleton({
|
|
|
3960
5085
|
rows,
|
|
3961
5086
|
showHeader
|
|
3962
5087
|
}) {
|
|
3963
|
-
return /* @__PURE__ */ (0,
|
|
3964
|
-
showHeader && /* @__PURE__ */ (0,
|
|
3965
|
-
Array.from({ length: rows }, (_, row) => /* @__PURE__ */ (0,
|
|
5088
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "schematic-skeleton", children: [
|
|
5089
|
+
showHeader && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "schematic-skeleton__heading" }),
|
|
5090
|
+
Array.from({ length: rows }, (_, row) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "schematic-skeleton__row", children: columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3966
5091
|
"div",
|
|
3967
5092
|
{
|
|
3968
5093
|
className: "schematic-skeleton__cell",
|
|
@@ -3974,10 +5099,10 @@ function InvoicesSkeleton({
|
|
|
3974
5099
|
}
|
|
3975
5100
|
function InvoiceDate({ row, t }) {
|
|
3976
5101
|
if (row.url === null) {
|
|
3977
|
-
return /* @__PURE__ */ (0,
|
|
5102
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "schematic-invoices__date-text", children: row.dateText });
|
|
3978
5103
|
}
|
|
3979
5104
|
const label = row.dateText === "" ? t("invoicesUndated") : row.dateText;
|
|
3980
|
-
return /* @__PURE__ */ (0,
|
|
5105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3981
5106
|
"a",
|
|
3982
5107
|
{
|
|
3983
5108
|
className: "schematic-invoices__link",
|
|
@@ -3990,11 +5115,354 @@ function InvoiceDate({ row, t }) {
|
|
|
3990
5115
|
}
|
|
3991
5116
|
Invoices.resources = ["invoices"];
|
|
3992
5117
|
|
|
3993
|
-
// src/elements/
|
|
5118
|
+
// src/elements/MeteredFeatures.tsx
|
|
3994
5119
|
var import_schematic_react5 = require("@schematichq/schematic-react");
|
|
3995
|
-
var
|
|
5120
|
+
var import_react6 = require("react");
|
|
3996
5121
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3997
|
-
|
|
5122
|
+
function MeteredFeatures({
|
|
5123
|
+
addMoreTarget,
|
|
5124
|
+
addMoreUrl,
|
|
5125
|
+
className,
|
|
5126
|
+
headingLevel = 2,
|
|
5127
|
+
locale: localeProp,
|
|
5128
|
+
onAddMore,
|
|
5129
|
+
showAllocation = true,
|
|
5130
|
+
showCredits = true,
|
|
5131
|
+
showDescription = true,
|
|
5132
|
+
showHardLimit = false,
|
|
5133
|
+
showHeader = false,
|
|
5134
|
+
showIcon = true,
|
|
5135
|
+
showMeter = true,
|
|
5136
|
+
showUsage = true,
|
|
5137
|
+
showUsageByUser = true,
|
|
5138
|
+
showWarningThresholdAsLimit = false,
|
|
5139
|
+
strings,
|
|
5140
|
+
visibleFeatures
|
|
5141
|
+
}) {
|
|
5142
|
+
const { data: features, error, isPending, refetch } = (0, import_schematic_react5.useFeatureUsage)();
|
|
5143
|
+
const locale = useResolvedLocale(localeProp);
|
|
5144
|
+
const t = useTranslator(strings, localeProp);
|
|
5145
|
+
const rows = (0, import_react6.useMemo)(
|
|
5146
|
+
() => features === void 0 ? [] : deriveMeteredFeatures(features, {
|
|
5147
|
+
locale,
|
|
5148
|
+
showCredits,
|
|
5149
|
+
showWarningThresholdAsLimit,
|
|
5150
|
+
visibleFeatures
|
|
5151
|
+
}),
|
|
5152
|
+
[
|
|
5153
|
+
features,
|
|
5154
|
+
locale,
|
|
5155
|
+
showCredits,
|
|
5156
|
+
showWarningThresholdAsLimit,
|
|
5157
|
+
visibleFeatures
|
|
5158
|
+
]
|
|
5159
|
+
);
|
|
5160
|
+
const unavailable = features === void 0 && httpStatus(error) === 404;
|
|
5161
|
+
const errorMessage = error === void 0 ? void 0 : unavailable ? t("meteredFeaturesUnavailable") : t("meteredFeaturesError");
|
|
5162
|
+
if (features !== void 0 && error === void 0 && rows.length === 0) {
|
|
5163
|
+
return null;
|
|
5164
|
+
}
|
|
5165
|
+
const Heading = `h${headingLevel}`;
|
|
5166
|
+
const NameHeading = showHeader ? `h${Math.min(6, headingLevel + 1)}` : Heading;
|
|
5167
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
5168
|
+
StatusFrame,
|
|
5169
|
+
{
|
|
5170
|
+
className: cx("schematic-metered-features", className),
|
|
5171
|
+
error,
|
|
5172
|
+
errorMessage,
|
|
5173
|
+
hasData: features !== void 0,
|
|
5174
|
+
isPending,
|
|
5175
|
+
loadingLabel: t("meteredFeaturesLoading"),
|
|
5176
|
+
onRetry: refetch,
|
|
5177
|
+
retryText: t("retry"),
|
|
5178
|
+
skeleton: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MeteredFeaturesSkeleton, { showHeader }),
|
|
5179
|
+
children: [
|
|
5180
|
+
showHeader && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "schematic-header", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Heading, { className: "schematic-header__title", children: t("meteredFeaturesHeader") }) }),
|
|
5181
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { className: "schematic-metered-features__list", children: rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
5182
|
+
"li",
|
|
5183
|
+
{
|
|
5184
|
+
className: "schematic-card schematic-metered-features__feature",
|
|
5185
|
+
"data-testid": "schematic-metered-feature",
|
|
5186
|
+
children: [
|
|
5187
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "schematic-metered-features__main", children: [
|
|
5188
|
+
showIcon && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "schematic-metered-features__icon", children: row.icon !== null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
5189
|
+
"i",
|
|
5190
|
+
{
|
|
5191
|
+
"aria-hidden": "true",
|
|
5192
|
+
className: `schematic-icon schematic-icon--${row.icon}`
|
|
5193
|
+
}
|
|
5194
|
+
) }),
|
|
5195
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "schematic-metered-features__body", children: [
|
|
5196
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "schematic-metered-features__top", children: [
|
|
5197
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "schematic-metered-features__title", children: [
|
|
5198
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(NameHeading, { className: "schematic-metered-features__name", children: row.name }),
|
|
5199
|
+
showDescription && row.description !== null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "schematic-muted", children: row.description })
|
|
5200
|
+
] }),
|
|
5201
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "schematic-metered-features__figures", children: [
|
|
5202
|
+
showUsage && row.headline !== null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "schematic-metered-features__headline", children: headlineText(row.headline, t) }),
|
|
5203
|
+
showAllocation && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
5204
|
+
LimitLine,
|
|
5205
|
+
{
|
|
5206
|
+
row,
|
|
5207
|
+
showHardLimit,
|
|
5208
|
+
t
|
|
5209
|
+
}
|
|
5210
|
+
)
|
|
5211
|
+
] })
|
|
5212
|
+
] }),
|
|
5213
|
+
showMeter && row.meter !== null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Meter, { meter: row.meter }),
|
|
5214
|
+
row.canAddMore && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
5215
|
+
AddMore,
|
|
5216
|
+
{
|
|
5217
|
+
label: t("meteredFeaturesAddMore"),
|
|
5218
|
+
onAddMore: onAddMore === void 0 ? void 0 : () => onAddMore(row.source),
|
|
5219
|
+
target: addMoreTarget,
|
|
5220
|
+
url: addMoreUrl
|
|
5221
|
+
}
|
|
5222
|
+
)
|
|
5223
|
+
] })
|
|
5224
|
+
] }),
|
|
5225
|
+
showUsageByUser && row.hasUsageByUser && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(UsageByUser, { locale, row, t }),
|
|
5226
|
+
row.priceDetails !== null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
5227
|
+
PriceDetails,
|
|
5228
|
+
{
|
|
5229
|
+
details: row.priceDetails,
|
|
5230
|
+
locale,
|
|
5231
|
+
row,
|
|
5232
|
+
t
|
|
5233
|
+
}
|
|
5234
|
+
)
|
|
5235
|
+
]
|
|
5236
|
+
},
|
|
5237
|
+
row.featureId
|
|
5238
|
+
)) })
|
|
5239
|
+
]
|
|
5240
|
+
}
|
|
5241
|
+
);
|
|
5242
|
+
}
|
|
5243
|
+
function headlineText(headline2, t) {
|
|
5244
|
+
if (headline2.kind === "used") {
|
|
5245
|
+
return t("meteredFeaturesUsed", {
|
|
5246
|
+
amount: headline2.amount,
|
|
5247
|
+
units: headline2.units
|
|
5248
|
+
});
|
|
5249
|
+
}
|
|
5250
|
+
return headline2.amount === null ? headline2.units : t("usageUnits", { amount: headline2.amount, units: headline2.units });
|
|
5251
|
+
}
|
|
5252
|
+
function limitText(limit, t) {
|
|
5253
|
+
switch (limit.kind) {
|
|
5254
|
+
case "tierUpTo":
|
|
5255
|
+
return t("usageTierUpTo", {
|
|
5256
|
+
amount: limit.amount,
|
|
5257
|
+
feature: limit.feature
|
|
5258
|
+
});
|
|
5259
|
+
case "tierUnlimited":
|
|
5260
|
+
return t("usageTierUnlimited", { feature: limit.feature });
|
|
5261
|
+
case "included":
|
|
5262
|
+
return t("meteredFeaturesIncluded", { amount: limit.amount });
|
|
5263
|
+
case "used":
|
|
5264
|
+
return t("meteredFeaturesInUse", { amount: limit.amount });
|
|
5265
|
+
case "cost":
|
|
5266
|
+
return limit.cost;
|
|
5267
|
+
case "perUse":
|
|
5268
|
+
return t("usagePerUse", { amount: limit.amount, units: limit.units });
|
|
5269
|
+
case "limitOf":
|
|
5270
|
+
return t("meteredFeaturesLimitOf", { amount: limit.amount });
|
|
5271
|
+
case "noLimit":
|
|
5272
|
+
return t("meteredFeaturesNoLimit");
|
|
5273
|
+
}
|
|
5274
|
+
}
|
|
5275
|
+
function LimitLine({
|
|
5276
|
+
row,
|
|
5277
|
+
showHardLimit,
|
|
5278
|
+
t
|
|
5279
|
+
}) {
|
|
5280
|
+
const parts = [];
|
|
5281
|
+
if (row.limit !== null) {
|
|
5282
|
+
parts.push(limitText(row.limit, t));
|
|
5283
|
+
}
|
|
5284
|
+
if (row.resetsAt !== null) {
|
|
5285
|
+
parts.push(t("usageResets", { date: row.resetsAt }));
|
|
5286
|
+
}
|
|
5287
|
+
if (parts.length === 0) {
|
|
5288
|
+
return null;
|
|
5289
|
+
}
|
|
5290
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "schematic-muted schematic-metered-features__limit", children: [
|
|
5291
|
+
parts.join(" \u2022 "),
|
|
5292
|
+
showHardLimit && row.hardLimit !== null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Tooltip, { label: t("usageHardLimitLabel"), children: t("usageHardLimit", {
|
|
5293
|
+
amount: row.hardLimit.amount,
|
|
5294
|
+
units: row.hardLimit.units
|
|
5295
|
+
}) })
|
|
5296
|
+
] });
|
|
5297
|
+
}
|
|
5298
|
+
var METER_TONE_CLASS = {
|
|
5299
|
+
ok: void 0,
|
|
5300
|
+
warning: "schematic-meter--warning",
|
|
5301
|
+
critical: "schematic-meter--over",
|
|
5302
|
+
tier: "schematic-meter--tier",
|
|
5303
|
+
overage: "schematic-meter--overage"
|
|
5304
|
+
};
|
|
5305
|
+
function Meter({ meter: meter2 }) {
|
|
5306
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "schematic-metered-features__meter", children: [
|
|
5307
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
5308
|
+
"div",
|
|
5309
|
+
{
|
|
5310
|
+
"aria-valuemax": meter2.total,
|
|
5311
|
+
"aria-valuemin": 0,
|
|
5312
|
+
"aria-valuenow": meter2.value,
|
|
5313
|
+
className: cx("schematic-meter", METER_TONE_CLASS[meter2.tone]),
|
|
5314
|
+
"data-tone": meter2.tone,
|
|
5315
|
+
role: "meter",
|
|
5316
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
5317
|
+
"div",
|
|
5318
|
+
{
|
|
5319
|
+
className: "schematic-meter__fill",
|
|
5320
|
+
style: { width: `${meter2.percent}%` }
|
|
5321
|
+
}
|
|
5322
|
+
)
|
|
5323
|
+
}
|
|
5324
|
+
),
|
|
5325
|
+
meter2.total > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "schematic-metered-features__meter-label", children: [
|
|
5326
|
+
meter2.valueText,
|
|
5327
|
+
"/",
|
|
5328
|
+
meter2.totalText
|
|
5329
|
+
] })
|
|
5330
|
+
] });
|
|
5331
|
+
}
|
|
5332
|
+
function AddMore({
|
|
5333
|
+
label,
|
|
5334
|
+
onAddMore,
|
|
5335
|
+
target,
|
|
5336
|
+
url
|
|
5337
|
+
}) {
|
|
5338
|
+
if (onAddMore !== void 0) {
|
|
5339
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
5340
|
+
"button",
|
|
5341
|
+
{
|
|
5342
|
+
className: "schematic-cta schematic-metered-features__add-more",
|
|
5343
|
+
type: "button",
|
|
5344
|
+
onClick: onAddMore,
|
|
5345
|
+
children: label
|
|
5346
|
+
}
|
|
5347
|
+
);
|
|
5348
|
+
}
|
|
5349
|
+
if (url !== void 0) {
|
|
5350
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
5351
|
+
"a",
|
|
5352
|
+
{
|
|
5353
|
+
className: "schematic-cta schematic-metered-features__add-more",
|
|
5354
|
+
href: url,
|
|
5355
|
+
target,
|
|
5356
|
+
children: label
|
|
5357
|
+
}
|
|
5358
|
+
);
|
|
5359
|
+
}
|
|
5360
|
+
return null;
|
|
5361
|
+
}
|
|
5362
|
+
function PriceDetails({
|
|
5363
|
+
details,
|
|
5364
|
+
locale,
|
|
5365
|
+
row,
|
|
5366
|
+
t
|
|
5367
|
+
}) {
|
|
5368
|
+
const period = details.period === null ? void 0 : shortPeriod(details.period, t);
|
|
5369
|
+
if (details.kind === "overage") {
|
|
5370
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "schematic-metered-features__price-details", children: [
|
|
5371
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
|
|
5372
|
+
t("meteredFeaturesAdditional"),
|
|
5373
|
+
": ",
|
|
5374
|
+
details.unitPrice,
|
|
5375
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("sub", { children: [
|
|
5376
|
+
"/",
|
|
5377
|
+
details.packageSize !== null && `${details.packageSize} `,
|
|
5378
|
+
details.units,
|
|
5379
|
+
period !== void 0 && `/${period}`
|
|
5380
|
+
] })
|
|
5381
|
+
] }),
|
|
5382
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
|
|
5383
|
+
details.overage.amount,
|
|
5384
|
+
" ",
|
|
5385
|
+
details.overage.units,
|
|
5386
|
+
" \xB7 ",
|
|
5387
|
+
details.overage.cost,
|
|
5388
|
+
period !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("sub", { children: [
|
|
5389
|
+
"/",
|
|
5390
|
+
period
|
|
5391
|
+
] })
|
|
5392
|
+
] })
|
|
5393
|
+
] });
|
|
5394
|
+
}
|
|
5395
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "schematic-metered-features__price-details", children: [
|
|
5396
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
|
|
5397
|
+
t("meteredFeaturesTier"),
|
|
5398
|
+
": ",
|
|
5399
|
+
details.from,
|
|
5400
|
+
details.to === null ? "+" : details.to !== details.from ? `\u2013${details.to}` : "",
|
|
5401
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Tooltip, { label: t("usageTieredPricingLabel"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
5402
|
+
PriceTiers,
|
|
5403
|
+
{
|
|
5404
|
+
currency: details.tiers.currency,
|
|
5405
|
+
locale,
|
|
5406
|
+
mode: details.tiers.mode,
|
|
5407
|
+
period: details.period,
|
|
5408
|
+
ranges: details.tiers.ranges,
|
|
5409
|
+
t,
|
|
5410
|
+
unit: featureName(row.unit, 1, locale)
|
|
5411
|
+
}
|
|
5412
|
+
) })
|
|
5413
|
+
] }),
|
|
5414
|
+
details.cost !== null && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
|
|
5415
|
+
details.cost,
|
|
5416
|
+
period !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("sub", { children: [
|
|
5417
|
+
"/",
|
|
5418
|
+
period
|
|
5419
|
+
] })
|
|
5420
|
+
] })
|
|
5421
|
+
] });
|
|
5422
|
+
}
|
|
5423
|
+
function UsageByUser({
|
|
5424
|
+
locale,
|
|
5425
|
+
row,
|
|
5426
|
+
t
|
|
5427
|
+
}) {
|
|
5428
|
+
const { data, error, refetch } = (0, import_schematic_react5.useFeatureUserUsage)(row.featureId);
|
|
5429
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
5430
|
+
UserBreakdown,
|
|
5431
|
+
{
|
|
5432
|
+
breakdown: data === void 0 ? void 0 : {
|
|
5433
|
+
count: data.count,
|
|
5434
|
+
total: data.total,
|
|
5435
|
+
unattributed: data.unattributed ?? null,
|
|
5436
|
+
users: data.users.map((user) => ({
|
|
5437
|
+
amount: user.usage,
|
|
5438
|
+
id: user.userId,
|
|
5439
|
+
label: user.name ?? user.userId
|
|
5440
|
+
}))
|
|
5441
|
+
},
|
|
5442
|
+
error,
|
|
5443
|
+
locale,
|
|
5444
|
+
onRetry: refetch,
|
|
5445
|
+
t,
|
|
5446
|
+
unit: row.unit
|
|
5447
|
+
}
|
|
5448
|
+
);
|
|
5449
|
+
}
|
|
5450
|
+
function MeteredFeaturesSkeleton({ showHeader }) {
|
|
5451
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "schematic-skeleton", children: [
|
|
5452
|
+
showHeader && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "schematic-skeleton__heading" }),
|
|
5453
|
+
[0, 1].map((index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "schematic-skeleton__row", children: [
|
|
5454
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "name" }),
|
|
5455
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "usage" })
|
|
5456
|
+
] }, index))
|
|
5457
|
+
] });
|
|
5458
|
+
}
|
|
5459
|
+
MeteredFeatures.resources = ["featureUsage"];
|
|
5460
|
+
|
|
5461
|
+
// src/elements/PaymentMethods.tsx
|
|
5462
|
+
var import_schematic_react7 = require("@schematichq/schematic-react");
|
|
5463
|
+
var import_react8 = require("react");
|
|
5464
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
5465
|
+
var PaymentMethodForm2 = (0, import_react8.lazy)(() => Promise.resolve().then(() => (init_PaymentMethodForm(), PaymentMethodForm_exports)));
|
|
3998
5466
|
function PaymentMethods({
|
|
3999
5467
|
allowEdit = true,
|
|
4000
5468
|
checkoutPrefill,
|
|
@@ -4015,24 +5483,24 @@ function PaymentMethods({
|
|
|
4015
5483
|
refetch,
|
|
4016
5484
|
remove,
|
|
4017
5485
|
setDefault
|
|
4018
|
-
} = (0,
|
|
5486
|
+
} = (0, import_schematic_react7.usePaymentMethods)();
|
|
4019
5487
|
const locale = useResolvedLocale(localeProp);
|
|
4020
5488
|
const t = useTranslator(strings, localeProp);
|
|
4021
|
-
const [dialog, setDialog] = (0,
|
|
4022
|
-
const [choosing, setChoosing] = (0,
|
|
4023
|
-
const [lastWrite, setLastWrite] = (0,
|
|
4024
|
-
const derived = (0,
|
|
5489
|
+
const [dialog, setDialog] = (0, import_react8.useState)(null);
|
|
5490
|
+
const [choosing, setChoosing] = (0, import_react8.useState)(false);
|
|
5491
|
+
const [lastWrite, setLastWrite] = (0, import_react8.useState)(null);
|
|
5492
|
+
const derived = (0, import_react8.useMemo)(
|
|
4025
5493
|
() => methods === void 0 ? void 0 : derivePaymentMethods(methods, { locale }),
|
|
4026
5494
|
[locale, methods]
|
|
4027
5495
|
);
|
|
4028
|
-
const write = (0,
|
|
5496
|
+
const write = (0, import_react8.useCallback)(async (next) => {
|
|
4029
5497
|
setLastWrite(next);
|
|
4030
5498
|
try {
|
|
4031
5499
|
await next.action();
|
|
4032
5500
|
} catch {
|
|
4033
5501
|
}
|
|
4034
5502
|
}, []);
|
|
4035
|
-
const saved = (0,
|
|
5503
|
+
const saved = (0, import_react8.useCallback)(
|
|
4036
5504
|
async (paymentMethodId) => {
|
|
4037
5505
|
await write({
|
|
4038
5506
|
action: () => setDefault(paymentMethodId),
|
|
@@ -4043,16 +5511,16 @@ function PaymentMethods({
|
|
|
4043
5511
|
},
|
|
4044
5512
|
[setDefault, write]
|
|
4045
5513
|
);
|
|
4046
|
-
const open = (0,
|
|
5514
|
+
const open = (0, import_react8.useCallback)(() => {
|
|
4047
5515
|
setLastWrite(null);
|
|
4048
5516
|
setChoosing(false);
|
|
4049
5517
|
setDialog("current");
|
|
4050
5518
|
}, []);
|
|
4051
|
-
const close = (0,
|
|
5519
|
+
const close = (0, import_react8.useCallback)(() => setDialog(null), []);
|
|
4052
5520
|
const Heading = `h${headingLevel}`;
|
|
4053
5521
|
const unavailable = derived === void 0 && httpStatus(error) === 404;
|
|
4054
5522
|
const errorMessage = error === void 0 ? void 0 : unavailable ? t("paymentMethodsUnavailable") : t("paymentMethodsError");
|
|
4055
|
-
return /* @__PURE__ */ (0,
|
|
5523
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4056
5524
|
StatusFrame,
|
|
4057
5525
|
{
|
|
4058
5526
|
className: cx("schematic-card", "schematic-payment-methods", className),
|
|
@@ -4063,18 +5531,19 @@ function PaymentMethods({
|
|
|
4063
5531
|
loadingLabel: t("paymentMethodsLoading"),
|
|
4064
5532
|
onRetry: refetch,
|
|
4065
5533
|
retryText: t("retry"),
|
|
4066
|
-
skeleton: /* @__PURE__ */ (0,
|
|
4067
|
-
children: derived !== void 0 && /* @__PURE__ */ (0,
|
|
4068
|
-
showHeader && /* @__PURE__ */ (0,
|
|
5534
|
+
skeleton: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PaymentMethodsSkeleton, { showHeader }),
|
|
5535
|
+
children: derived !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
5536
|
+
showHeader && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4069
5537
|
PaymentMethodsHeader,
|
|
4070
5538
|
{
|
|
4071
5539
|
derived,
|
|
4072
5540
|
heading: Heading,
|
|
5541
|
+
locale,
|
|
4073
5542
|
showExpiration,
|
|
4074
5543
|
t
|
|
4075
5544
|
}
|
|
4076
5545
|
),
|
|
4077
|
-
/* @__PURE__ */ (0,
|
|
5546
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MethodPill, { row: derived.current, t, children: allowEdit && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4078
5547
|
"button",
|
|
4079
5548
|
{
|
|
4080
5549
|
className: "schematic-link-button schematic-payment-methods__edit",
|
|
@@ -4083,7 +5552,7 @@ function PaymentMethods({
|
|
|
4083
5552
|
children: derived.current === null ? t("paymentMethodsAdd") : t("paymentMethodsEdit")
|
|
4084
5553
|
}
|
|
4085
5554
|
) }),
|
|
4086
|
-
dialog !== null && /* @__PURE__ */ (0,
|
|
5555
|
+
dialog !== null && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4087
5556
|
PaymentMethodsDialog,
|
|
4088
5557
|
{
|
|
4089
5558
|
checkoutPrefill,
|
|
@@ -4135,7 +5604,7 @@ function PaymentMethodsDialog({
|
|
|
4135
5604
|
const { current, others, rows } = derived;
|
|
4136
5605
|
const hasMethods = rows.length > 0;
|
|
4137
5606
|
const showForm = view === "add" || !hasMethods;
|
|
4138
|
-
return /* @__PURE__ */ (0,
|
|
5607
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
4139
5608
|
Dialog,
|
|
4140
5609
|
{
|
|
4141
5610
|
className: "schematic-payment-methods__dialog",
|
|
@@ -4144,11 +5613,11 @@ function PaymentMethodsDialog({
|
|
|
4144
5613
|
title: t("paymentMethodsDialogTitle"),
|
|
4145
5614
|
onClose,
|
|
4146
5615
|
children: [
|
|
4147
|
-
showForm ? /* @__PURE__ */ (0,
|
|
4148
|
-
|
|
5616
|
+
showForm ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
5617
|
+
import_react8.Suspense,
|
|
4149
5618
|
{
|
|
4150
|
-
fallback: /* @__PURE__ */ (0,
|
|
4151
|
-
children: /* @__PURE__ */ (0,
|
|
5619
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FormSkeleton, { label: t("paymentMethodsFormLoading") }),
|
|
5620
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4152
5621
|
PaymentMethodForm2,
|
|
4153
5622
|
{
|
|
4154
5623
|
checkoutPrefill,
|
|
@@ -4160,17 +5629,18 @@ function PaymentMethodsDialog({
|
|
|
4160
5629
|
}
|
|
4161
5630
|
)
|
|
4162
5631
|
}
|
|
4163
|
-
) : /* @__PURE__ */ (0,
|
|
4164
|
-
/* @__PURE__ */ (0,
|
|
5632
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
5633
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4165
5634
|
PaymentMethodsHeader,
|
|
4166
5635
|
{
|
|
4167
5636
|
derived,
|
|
4168
5637
|
heading: "h3",
|
|
5638
|
+
locale,
|
|
4169
5639
|
showExpiration: true,
|
|
4170
5640
|
t
|
|
4171
5641
|
}
|
|
4172
5642
|
),
|
|
4173
|
-
/* @__PURE__ */ (0,
|
|
5643
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MethodPill, { row: current, t, children: current?.canRemove === true && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4174
5644
|
"button",
|
|
4175
5645
|
{
|
|
4176
5646
|
className: "schematic-link-button schematic-payment-methods__remove-current",
|
|
@@ -4180,7 +5650,7 @@ function PaymentMethodsDialog({
|
|
|
4180
5650
|
children: t("paymentMethodsRemove")
|
|
4181
5651
|
}
|
|
4182
5652
|
) }),
|
|
4183
|
-
/* @__PURE__ */ (0,
|
|
5653
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
4184
5654
|
"button",
|
|
4185
5655
|
{
|
|
4186
5656
|
"aria-expanded": choosing,
|
|
@@ -4188,8 +5658,8 @@ function PaymentMethodsDialog({
|
|
|
4188
5658
|
type: "button",
|
|
4189
5659
|
onClick: onChoose,
|
|
4190
5660
|
children: [
|
|
4191
|
-
/* @__PURE__ */ (0,
|
|
4192
|
-
/* @__PURE__ */ (0,
|
|
5661
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "schematic-payment-methods__choose-label", children: t("paymentMethodsChooseDifferent") }),
|
|
5662
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4193
5663
|
"i",
|
|
4194
5664
|
{
|
|
4195
5665
|
"aria-hidden": "true",
|
|
@@ -4204,13 +5674,13 @@ function PaymentMethodsDialog({
|
|
|
4204
5674
|
]
|
|
4205
5675
|
}
|
|
4206
5676
|
),
|
|
4207
|
-
choosing && /* @__PURE__ */ (0,
|
|
4208
|
-
others.length > 0 && /* @__PURE__ */ (0,
|
|
5677
|
+
choosing && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
5678
|
+
others.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4209
5679
|
"ul",
|
|
4210
5680
|
{
|
|
4211
5681
|
"aria-label": t("paymentMethodsChooseDifferent"),
|
|
4212
5682
|
className: "schematic-payment-methods__list",
|
|
4213
|
-
children: others.map((row) => /* @__PURE__ */ (0,
|
|
5683
|
+
children: others.map((row) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
4214
5684
|
"li",
|
|
4215
5685
|
{
|
|
4216
5686
|
className: "schematic-payment-methods__row",
|
|
@@ -4218,11 +5688,11 @@ function PaymentMethodsDialog({
|
|
|
4218
5688
|
"data-kind": row.kind,
|
|
4219
5689
|
"data-testid": "schematic-payment-method",
|
|
4220
5690
|
children: [
|
|
4221
|
-
/* @__PURE__ */ (0,
|
|
4222
|
-
row.expiresShort !== null && /* @__PURE__ */ (0,
|
|
5691
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Method, { row, t }),
|
|
5692
|
+
row.expiresShort !== null && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "schematic-payment-methods__expires", children: t("paymentMethodsExpires", {
|
|
4223
5693
|
date: row.expiresShort
|
|
4224
5694
|
}) }),
|
|
4225
|
-
/* @__PURE__ */ (0,
|
|
5695
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4226
5696
|
"button",
|
|
4227
5697
|
{
|
|
4228
5698
|
className: "schematic-link-button schematic-payment-methods__set-default",
|
|
@@ -4232,7 +5702,7 @@ function PaymentMethodsDialog({
|
|
|
4232
5702
|
children: t("paymentMethodsSetDefault")
|
|
4233
5703
|
}
|
|
4234
5704
|
),
|
|
4235
|
-
row.canRemove && /* @__PURE__ */ (0,
|
|
5705
|
+
row.canRemove && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4236
5706
|
"button",
|
|
4237
5707
|
{
|
|
4238
5708
|
"aria-label": t("paymentMethodsRemove"),
|
|
@@ -4240,7 +5710,7 @@ function PaymentMethodsDialog({
|
|
|
4240
5710
|
disabled: isMutating,
|
|
4241
5711
|
type: "button",
|
|
4242
5712
|
onClick: () => onRemove(row),
|
|
4243
|
-
children: /* @__PURE__ */ (0,
|
|
5713
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4244
5714
|
"i",
|
|
4245
5715
|
{
|
|
4246
5716
|
"aria-hidden": "true",
|
|
@@ -4255,7 +5725,7 @@ function PaymentMethodsDialog({
|
|
|
4255
5725
|
))
|
|
4256
5726
|
}
|
|
4257
5727
|
),
|
|
4258
|
-
/* @__PURE__ */ (0,
|
|
5728
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4259
5729
|
"button",
|
|
4260
5730
|
{
|
|
4261
5731
|
className: "schematic-cta schematic-payment-methods__add-new",
|
|
@@ -4267,14 +5737,14 @@ function PaymentMethodsDialog({
|
|
|
4267
5737
|
)
|
|
4268
5738
|
] })
|
|
4269
5739
|
] }),
|
|
4270
|
-
mutationError !== void 0 && /* @__PURE__ */ (0,
|
|
5740
|
+
mutationError !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
4271
5741
|
"p",
|
|
4272
5742
|
{
|
|
4273
5743
|
className: "schematic-status-note schematic-error schematic-payment-methods__error",
|
|
4274
5744
|
role: "alert",
|
|
4275
5745
|
children: [
|
|
4276
|
-
/* @__PURE__ */ (0,
|
|
4277
|
-
onRetry !== void 0 && /* @__PURE__ */ (0,
|
|
5746
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "schematic-payment-methods__error-message", children: mutationError }),
|
|
5747
|
+
onRetry !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4278
5748
|
"button",
|
|
4279
5749
|
{
|
|
4280
5750
|
className: "schematic-cta schematic-cta--small schematic-cta--ghost schematic-payment-methods__error-retry",
|
|
@@ -4294,17 +5764,18 @@ function PaymentMethodsDialog({
|
|
|
4294
5764
|
function PaymentMethodsHeader({
|
|
4295
5765
|
derived,
|
|
4296
5766
|
heading: Heading,
|
|
5767
|
+
locale,
|
|
4297
5768
|
showExpiration,
|
|
4298
5769
|
t
|
|
4299
5770
|
}) {
|
|
4300
|
-
return /* @__PURE__ */ (0,
|
|
4301
|
-
/* @__PURE__ */ (0,
|
|
4302
|
-
showExpiration && derived.expiryWarning !== "none" && /* @__PURE__ */ (0,
|
|
5771
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "schematic-header", children: [
|
|
5772
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Heading, { className: "schematic-header__title", children: t("paymentMethodsHeader") }),
|
|
5773
|
+
showExpiration && derived.expiryWarning !== "none" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4303
5774
|
"span",
|
|
4304
5775
|
{
|
|
4305
5776
|
className: "schematic-small schematic-payment-methods__expiry-warning",
|
|
4306
5777
|
"data-expiry": derived.expiryWarning,
|
|
4307
|
-
children: expiryWarningText(derived, t)
|
|
5778
|
+
children: expiryWarningText(derived, locale, t)
|
|
4308
5779
|
}
|
|
4309
5780
|
)
|
|
4310
5781
|
] });
|
|
@@ -4314,37 +5785,37 @@ function MethodPill({
|
|
|
4314
5785
|
row,
|
|
4315
5786
|
t
|
|
4316
5787
|
}) {
|
|
4317
|
-
return /* @__PURE__ */ (0,
|
|
5788
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
4318
5789
|
"div",
|
|
4319
5790
|
{
|
|
4320
5791
|
className: "schematic-payment-methods__current",
|
|
4321
5792
|
"data-testid": "schematic-payment-method-current",
|
|
4322
5793
|
children: [
|
|
4323
|
-
row === null ? /* @__PURE__ */ (0,
|
|
5794
|
+
row === null ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "schematic-payment-methods__empty", children: t("paymentMethodsEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Method, { row, t }),
|
|
4324
5795
|
children
|
|
4325
5796
|
]
|
|
4326
5797
|
}
|
|
4327
5798
|
);
|
|
4328
5799
|
}
|
|
4329
5800
|
function Method({ row, t }) {
|
|
4330
|
-
return /* @__PURE__ */ (0,
|
|
5801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
4331
5802
|
"span",
|
|
4332
5803
|
{
|
|
4333
5804
|
className: "schematic-payment-methods__method",
|
|
4334
5805
|
"data-brand": row.brand,
|
|
4335
5806
|
"data-kind": row.kind,
|
|
4336
5807
|
children: [
|
|
4337
|
-
/* @__PURE__ */ (0,
|
|
5808
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
4338
5809
|
"i",
|
|
4339
5810
|
{
|
|
4340
5811
|
"aria-hidden": "true",
|
|
4341
5812
|
className: `schematic-icon schematic-icon--${row.icon} schematic-payment-methods__icon`
|
|
4342
5813
|
}
|
|
4343
5814
|
),
|
|
4344
|
-
/* @__PURE__ */ (0,
|
|
4345
|
-
row.last4 !== null && /* @__PURE__ */ (0,
|
|
5815
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "schematic-payment-methods__label", children: labelText(row.label, t) }),
|
|
5816
|
+
row.last4 !== null && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
4346
5817
|
" ",
|
|
4347
|
-
/* @__PURE__ */ (0,
|
|
5818
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "schematic-payment-methods__last4", children: row.last4 })
|
|
4348
5819
|
] })
|
|
4349
5820
|
]
|
|
4350
5821
|
}
|
|
@@ -4353,29 +5824,31 @@ function Method({ row, t }) {
|
|
|
4353
5824
|
function labelText(label, t) {
|
|
4354
5825
|
return label.key === void 0 ? label.text : t(label.key);
|
|
4355
5826
|
}
|
|
4356
|
-
function expiryWarningText(derived, t) {
|
|
5827
|
+
function expiryWarningText(derived, locale, t) {
|
|
4357
5828
|
const months = derived.monthsToExpiration ?? 0;
|
|
4358
|
-
return derived.expiryWarning === "expired" ? t("paymentMethodsExpired") : t("paymentMethodsExpiresInMonths", {
|
|
5829
|
+
return derived.expiryWarning === "expired" ? t("paymentMethodsExpired") : t("paymentMethodsExpiresInMonths", {
|
|
5830
|
+
months: formatNumber(months, locale)
|
|
5831
|
+
});
|
|
4359
5832
|
}
|
|
4360
5833
|
function PaymentMethodsSkeleton({ showHeader }) {
|
|
4361
|
-
return /* @__PURE__ */ (0,
|
|
4362
|
-
showHeader && /* @__PURE__ */ (0,
|
|
4363
|
-
/* @__PURE__ */ (0,
|
|
4364
|
-
/* @__PURE__ */ (0,
|
|
4365
|
-
/* @__PURE__ */ (0,
|
|
5834
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "schematic-skeleton", children: [
|
|
5835
|
+
showHeader && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "schematic-skeleton__heading" }),
|
|
5836
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "schematic-skeleton__row", children: [
|
|
5837
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "method" }),
|
|
5838
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "action" })
|
|
4366
5839
|
] })
|
|
4367
5840
|
] });
|
|
4368
5841
|
}
|
|
4369
5842
|
function FormSkeleton({ label }) {
|
|
4370
|
-
return /* @__PURE__ */ (0,
|
|
5843
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
4371
5844
|
"div",
|
|
4372
5845
|
{
|
|
4373
5846
|
"aria-busy": "true",
|
|
4374
5847
|
className: "schematic-payment-methods__form",
|
|
4375
5848
|
"data-state": "pending",
|
|
4376
5849
|
children: [
|
|
4377
|
-
/* @__PURE__ */ (0,
|
|
4378
|
-
/* @__PURE__ */ (0,
|
|
5850
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "schematic-hidden", children: label }),
|
|
5851
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "schematic-skeleton", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "field" }) }) })
|
|
4379
5852
|
]
|
|
4380
5853
|
}
|
|
4381
5854
|
);
|
|
@@ -4383,9 +5856,9 @@ function FormSkeleton({ label }) {
|
|
|
4383
5856
|
PaymentMethods.resources = ["paymentMethods"];
|
|
4384
5857
|
|
|
4385
5858
|
// src/elements/UpcomingBill.tsx
|
|
4386
|
-
var
|
|
4387
|
-
var
|
|
4388
|
-
var
|
|
5859
|
+
var import_schematic_react8 = require("@schematichq/schematic-react");
|
|
5860
|
+
var import_react9 = require("react");
|
|
5861
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
4389
5862
|
function UpcomingBill({
|
|
4390
5863
|
className,
|
|
4391
5864
|
headingLevel = 2,
|
|
@@ -4396,10 +5869,10 @@ function UpcomingBill({
|
|
|
4396
5869
|
showHeader = true,
|
|
4397
5870
|
strings
|
|
4398
5871
|
}) {
|
|
4399
|
-
const { data: invoice, error, isPending, refetch } = (0,
|
|
5872
|
+
const { data: invoice, error, isPending, refetch } = (0, import_schematic_react8.useUpcomingInvoice)();
|
|
4400
5873
|
const locale = useResolvedLocale(localeProp);
|
|
4401
5874
|
const t = useTranslator(strings, localeProp);
|
|
4402
|
-
const bill = (0,
|
|
5875
|
+
const bill = (0, import_react9.useMemo)(
|
|
4403
5876
|
() => invoice === void 0 || invoice === null ? null : deriveUpcomingInvoice(invoice, { locale }),
|
|
4404
5877
|
[invoice, locale]
|
|
4405
5878
|
);
|
|
@@ -4408,7 +5881,7 @@ function UpcomingBill({
|
|
|
4408
5881
|
const discountRow = showDiscounts && bill !== null && bill.discounts.length > 0;
|
|
4409
5882
|
const unavailable = invoice === void 0 && httpStatus(error) === 404;
|
|
4410
5883
|
const errorMessage = error === void 0 ? void 0 : unavailable ? t("upcomingBillUnavailable") : t("upcomingBillError");
|
|
4411
|
-
return /* @__PURE__ */ (0,
|
|
5884
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4412
5885
|
StatusFrame,
|
|
4413
5886
|
{
|
|
4414
5887
|
className: cx("schematic-card", "schematic-upcoming-bill", className),
|
|
@@ -4419,11 +5892,11 @@ function UpcomingBill({
|
|
|
4419
5892
|
loadingLabel: t("upcomingBillLoading"),
|
|
4420
5893
|
onRetry: refetch,
|
|
4421
5894
|
retryText: t("retry"),
|
|
4422
|
-
skeleton: /* @__PURE__ */ (0,
|
|
4423
|
-
children: bill === null ? invoice !== void 0 && /* @__PURE__ */ (0,
|
|
4424
|
-
showHeader && bill.dueAt !== null && /* @__PURE__ */ (0,
|
|
4425
|
-
showAmount && /* @__PURE__ */ (0,
|
|
4426
|
-
/* @__PURE__ */ (0,
|
|
5895
|
+
skeleton: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(UpcomingBillSkeleton, { showHeader }),
|
|
5896
|
+
children: bill === null ? invoice !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "schematic-muted schematic-upcoming-bill__empty", children: t("upcomingBillEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
5897
|
+
showHeader && bill.dueAt !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "schematic-header", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Heading, { className: "schematic-header__title", children: t("upcomingBillHeader", { date: bill.dueAt.text }) }) }),
|
|
5898
|
+
showAmount && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "schematic-upcoming-bill__amount", children: [
|
|
5899
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4427
5900
|
"span",
|
|
4428
5901
|
{
|
|
4429
5902
|
className: "schematic-upcoming-bill__total",
|
|
@@ -4431,46 +5904,46 @@ function UpcomingBill({
|
|
|
4431
5904
|
children: bill.amountDueText
|
|
4432
5905
|
}
|
|
4433
5906
|
),
|
|
4434
|
-
/* @__PURE__ */ (0,
|
|
5907
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-small schematic-upcoming-bill__estimate", children: t("upcomingBillEstimate") })
|
|
4435
5908
|
] }),
|
|
4436
|
-
(balanceRows || discountRow) && /* @__PURE__ */ (0,
|
|
4437
|
-
balanceRows && bill.balanceApplied !== null && /* @__PURE__ */ (0,
|
|
5909
|
+
(balanceRows || discountRow) && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "schematic-upcoming-bill__rows", children: [
|
|
5910
|
+
balanceRows && bill.balanceApplied !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
4438
5911
|
"div",
|
|
4439
5912
|
{
|
|
4440
5913
|
className: "schematic-row schematic-upcoming-bill__balance-applied",
|
|
4441
5914
|
"data-testid": "schematic-balance-applied",
|
|
4442
5915
|
children: [
|
|
4443
|
-
/* @__PURE__ */ (0,
|
|
4444
|
-
/* @__PURE__ */ (0,
|
|
5916
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-row__label", children: t("upcomingBillBalanceApplied") }),
|
|
5917
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-row__value", children: bill.balanceApplied.amountText })
|
|
4445
5918
|
]
|
|
4446
5919
|
}
|
|
4447
5920
|
),
|
|
4448
|
-
balanceRows && bill.balanceRemaining !== null && /* @__PURE__ */ (0,
|
|
5921
|
+
balanceRows && bill.balanceRemaining !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
4449
5922
|
"div",
|
|
4450
5923
|
{
|
|
4451
5924
|
className: "schematic-row schematic-upcoming-bill__balance-remaining",
|
|
4452
5925
|
"data-testid": "schematic-balance-remaining",
|
|
4453
5926
|
children: [
|
|
4454
|
-
/* @__PURE__ */ (0,
|
|
4455
|
-
/* @__PURE__ */ (0,
|
|
5927
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-row__label", children: t("upcomingBillBalanceRemaining") }),
|
|
5928
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-row__value", children: bill.balanceRemaining.amountText })
|
|
4456
5929
|
]
|
|
4457
5930
|
}
|
|
4458
5931
|
),
|
|
4459
|
-
discountRow && /* @__PURE__ */ (0,
|
|
5932
|
+
discountRow && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
4460
5933
|
"div",
|
|
4461
5934
|
{
|
|
4462
5935
|
className: "schematic-row schematic-upcoming-bill__discount-row",
|
|
4463
5936
|
"data-testid": "schematic-discounts",
|
|
4464
5937
|
children: [
|
|
4465
|
-
/* @__PURE__ */ (0,
|
|
4466
|
-
/* @__PURE__ */ (0,
|
|
5938
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-row__label", children: t("upcomingBillDiscount") }),
|
|
5939
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { className: "schematic-row__value schematic-upcoming-bill__discounts", children: bill.discounts.map((discount, index) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
4467
5940
|
"li",
|
|
4468
5941
|
{
|
|
4469
5942
|
className: "schematic-upcoming-bill__discount",
|
|
4470
5943
|
"data-testid": "schematic-discount",
|
|
4471
5944
|
children: [
|
|
4472
|
-
discount.code !== null && /* @__PURE__ */ (0,
|
|
4473
|
-
/* @__PURE__ */ (0,
|
|
5945
|
+
discount.code !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-chip schematic-upcoming-bill__code", children: discount.code }),
|
|
5946
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "schematic-upcoming-bill__discount-value", children: discountText(discount, t) })
|
|
4474
5947
|
]
|
|
4475
5948
|
},
|
|
4476
5949
|
`${discount.couponName}-${index}`
|
|
@@ -4484,10 +5957,10 @@ function UpcomingBill({
|
|
|
4484
5957
|
);
|
|
4485
5958
|
}
|
|
4486
5959
|
function UpcomingBillSkeleton({ showHeader }) {
|
|
4487
|
-
return /* @__PURE__ */ (0,
|
|
4488
|
-
showHeader && /* @__PURE__ */ (0,
|
|
4489
|
-
/* @__PURE__ */ (0,
|
|
4490
|
-
/* @__PURE__ */ (0,
|
|
5960
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "schematic-skeleton", children: [
|
|
5961
|
+
showHeader && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "schematic-skeleton__heading" }),
|
|
5962
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "amount" }) }),
|
|
5963
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "schematic-skeleton__cell", "data-column": "row" }) })
|
|
4491
5964
|
] });
|
|
4492
5965
|
}
|
|
4493
5966
|
function discountText(discount, t) {
|