@schematichq/schematic-components 2.26.0 → 2.28.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.
@@ -2,6 +2,8 @@ import { BillingData } from '@schematichq/schematic-react';
2
2
  import { BillingDataProvider } from '@schematichq/schematic-react';
3
3
  import { BillingDataProviderProps } from '@schematichq/schematic-react';
4
4
  import { BillingDataStatus } from '@schematichq/schematic-react';
5
+ import { BillingResourceName } from '@schematichq/schematic-react';
6
+ import { Discount } from '@schematichq/schematic-react';
5
7
  import { Invoice } from '@schematichq/schematic-react';
6
8
  import { InvoicePage } from '@schematichq/schematic-react';
7
9
  import { InvoiceQuery } from '@schematichq/schematic-react';
@@ -14,12 +16,14 @@ import { SchematicI18nConfig } from '@schematichq/schematic-react';
14
16
  import { SchematicI18nProvider } from '@schematichq/schematic-react';
15
17
  import { SchematicI18nProviderProps } from '@schematichq/schematic-react';
16
18
  import type { Translate } from '@schematichq/schematic-react';
19
+ import { UpcomingInvoice } from '@schematichq/schematic-react';
17
20
  import { useInvalidateBillingData } from '@schematichq/schematic-react';
18
21
  import { useInvoices } from '@schematichq/schematic-react';
19
22
  import { useSchematicI18n } from '@schematichq/schematic-react';
20
23
  import { useSchematicLocale } from '@schematichq/schematic-react';
21
24
  import { useSchematicStrings } from '@schematichq/schematic-react';
22
25
  import { useSchematicTranslate } from '@schematichq/schematic-react';
26
+ import { useUpcomingInvoice } from '@schematichq/schematic-react';
23
27
 
24
28
  export { BillingData }
25
29
 
@@ -29,6 +33,22 @@ export { BillingDataProviderProps }
29
33
 
30
34
  export { BillingDataStatus }
31
35
 
36
+ /**
37
+ * The resource names to prefetch for the elements a page renders, each once:
38
+ *
39
+ * ```ts
40
+ * fetchBillingData(client, { names: billingResources(UpcomingBill, Invoices) });
41
+ * ```
42
+ */
43
+ export declare function billingResources(...elements: ReadsBillingResources[]): BillingResourceName[];
44
+
45
+ /** An amount on the bill, with the text for it. */
46
+ export declare interface BillLine {
47
+ /** Minor units, signed as it affects the bill. */
48
+ amountMinor: number;
49
+ amountText: string;
50
+ }
51
+
32
52
  /**
33
53
  * The English copy, and the fallback for anything a host does not answer.
34
54
  * It is a plain resource bundle, so it can be registered as one:
@@ -52,6 +72,44 @@ export declare interface DeriveInvoiceListOptions {
52
72
  format?: InvoiceFormatters;
53
73
  }
54
74
 
75
+ export declare function deriveUpcomingInvoice(invoice: UpcomingInvoice, options: DeriveUpcomingInvoiceOptions): UpcomingBillSummary;
76
+
77
+ export declare interface DeriveUpcomingInvoiceOptions {
78
+ locale: string;
79
+ format?: UpcomingInvoiceFormatters;
80
+ }
81
+
82
+ export { Discount }
83
+
84
+ /**
85
+ * `deriveUpcomingInvoice`: the company's next bill as display parts — the
86
+ * estimated amount, the balance it consumes, and the discounts shaping it.
87
+ *
88
+ * The arithmetic is not here. The server sends what the balance applies and
89
+ * what survives, because those depend on provider conventions (a negative
90
+ * balance is held credit; a previewed invoice reports no ending balance)
91
+ * that no consumer should have to know.
92
+ */
93
+ /** One discount on the subscription, as the bill shows it. */
94
+ export declare interface DiscountLine {
95
+ /** The coupon's name, for a host that wants to show it. */
96
+ couponName: string;
97
+ /** The promo code, for the chip beside the amount; `null` when none. */
98
+ code: string | null;
99
+ /** Whether the discount takes a percentage off or a fixed amount. */
100
+ kind: "percent" | "amount";
101
+ /** "20%" or "$5.00" — what comes off. */
102
+ valueText: string;
103
+ /** The percentage as written (20 for 20% off); `null` for an amount. */
104
+ percentOff: number | null;
105
+ /** Minor units off; `null` for a percentage. */
106
+ amountOffMinor: number | null;
107
+ /** Months the discount repeats for; `null` when it does not repeat. */
108
+ months: number | null;
109
+ /** Provider vocabulary: `once`, `repeating`, or `forever`. */
110
+ duration: string;
111
+ }
112
+
55
113
  /** Props every element accepts on its root. */
56
114
  export declare interface ElementProps {
57
115
  className?: string;
@@ -82,6 +140,17 @@ export declare type ElementStrings = {
82
140
  invoicesChargeTooltip: string;
83
141
  invoicesCreditTooltip: string;
84
142
  invoicesUndated: string;
143
+ upcomingBillLoading: string;
144
+ upcomingBillHeader: string;
145
+ upcomingBillError: string;
146
+ upcomingBillUnavailable: string;
147
+ upcomingBillEmpty: string;
148
+ upcomingBillEstimate: string;
149
+ upcomingBillBalanceApplied: string;
150
+ upcomingBillBalanceRemaining: string;
151
+ upcomingBillDiscount: string;
152
+ upcomingBillDiscountValue: string;
153
+ upcomingBillDiscountRepeating: string;
85
154
  };
86
155
 
87
156
  /**
@@ -122,6 +191,18 @@ export declare function formatDate(date: Date, locale: string, options?: Intl.Da
122
191
 
123
192
  export declare function formatNumber(value: number, locale: string, options?: Intl.NumberFormatOptions): string;
124
193
 
194
+ /**
195
+ * A malformed timestamp decodes to an Invalid Date, and `Intl` throws a
196
+ * RangeError on formatting one. Thrown inside a render, that takes down the
197
+ * host's tree.
198
+ */
199
+ /**
200
+ * "50%", or "12.5%" for a coupon written with a fraction. Two places is
201
+ * what a provider allows a percentage, and Intl drops trailing zeros, so
202
+ * a whole number stays whole.
203
+ */
204
+ export declare function formatPercent(fraction: number, locale: string): string;
205
+
125
206
  /** "8/21". Empty for an Invalid Date. */
126
207
  export declare function formatShortDate(date: Date, locale: string): string;
127
208
 
@@ -191,6 +272,10 @@ export declare interface InvoiceRow {
191
272
  */
192
273
  export declare function Invoices({ className, collapsible, headingLevel, limit, locale: localeProp, query, showAmount, showDate, showHeader, strings, }: InvoicesProps): JSX.Element;
193
274
 
275
+ export declare namespace Invoices {
276
+ var resources: readonly ["invoices"];
277
+ }
278
+
194
279
  export declare interface InvoicesProps extends ElementProps {
195
280
  /** Rows shown before "See more". Default 10. */
196
281
  limit?: number;
@@ -231,6 +316,16 @@ export declare function plural(locale: string, count: number, forms: Partial<Rec
231
316
  /** The i18next plural suffixes a key can carry. */
232
317
  declare type PluralSuffix = "zero" | "one" | "two" | "few" | "many" | "other";
233
318
 
319
+ /**
320
+ * What an element reads from the billing store, declared on the element so
321
+ * a page can prefetch exactly that. `fetchBillingData` has no default set:
322
+ * each resource is a request on the server, and the set grows with every
323
+ * element, so the page names what it renders.
324
+ */
325
+ export declare interface ReadsBillingResources {
326
+ readonly resources: readonly BillingResourceName[];
327
+ }
328
+
234
329
  /**
235
330
  * The given tag, or the default when it is absent or `Intl` rejects it.
236
331
  * Deliberately ignores `navigator`; `viewerLocale` does that reading.
@@ -291,6 +386,78 @@ export { Translate }
291
386
 
292
387
  export declare type Translator = (key: StringKey, vars?: StringVars) => string;
293
388
 
389
+ /**
390
+ * The company's next bill: what it will be charged and when, and the
391
+ * account balance and discounts that shaped the figure.
392
+ *
393
+ * A company with nothing to bill — no subscription — gets the empty state
394
+ * rather than a fabricated zero. That is a loaded answer from the server (a
395
+ * 204), not a missing one, so it renders as content rather than as a
396
+ * permanent skeleton. A 404 is something else: the account is not enabled
397
+ * for company reads, and the card says so rather than showing a customer
398
+ * with a subscription "no upcoming invoice".
399
+ */
400
+ export declare function UpcomingBill({ className, headingLevel, locale: localeProp, showAmount, showBalance, showDiscounts, showHeader, strings, }: UpcomingBillProps): JSX.Element;
401
+
402
+ export declare namespace UpcomingBill {
403
+ var resources: readonly ["upcomingInvoice"];
404
+ }
405
+
406
+ export declare interface UpcomingBillProps extends ElementProps {
407
+ /** The "Next bill due …" heading. Default true. */
408
+ showHeader?: boolean;
409
+ /** Heading level, so the card fits the host's outline. Default 2. */
410
+ headingLevel?: HeadingLevel;
411
+ /** The estimated amount. Default true. */
412
+ showAmount?: boolean;
413
+ /** The applied and remaining account-balance rows. Default true. */
414
+ showBalance?: boolean;
415
+ /** The discount row. Default true. */
416
+ showDiscounts?: boolean;
417
+ }
418
+
419
+ export declare interface UpcomingBillSummary {
420
+ /** What the company will be charged, after discounts and balance. */
421
+ amountDueMinor: number;
422
+ amountDueText: string;
423
+ /** Before discounts and tax. */
424
+ subtotalMinor: number;
425
+ subtotalText: string;
426
+ /** ISO 4217 code, upper-cased. */
427
+ currency: string;
428
+ /** When it will be charged; `null` when the provider names no date. */
429
+ dueAt: {
430
+ date: Date;
431
+ text: string;
432
+ } | null;
433
+ /**
434
+ * The stored balance this invoice consumes, as a deduction — the amount is
435
+ * negative and its text carries the locale's sign. `null` when none of the
436
+ * balance is applied.
437
+ */
438
+ balanceApplied: BillLine | null;
439
+ /**
440
+ * What is left of the balance afterwards, as a positive amount. `null`
441
+ * when there was no balance to begin with — a company that has one, and
442
+ * spends all of it, still gets a zero here to say so.
443
+ */
444
+ balanceRemaining: BillLine | null;
445
+ /** Active discounts, already filtered server-side to the ones that bite. */
446
+ discounts: DiscountLine[];
447
+ }
448
+
449
+ export { UpcomingInvoice }
450
+
451
+ /**
452
+ * Per-field formatting, for a host that wants the derivation's parts but not
453
+ * its wording. Each receives the raw value and the resolved locale; amounts
454
+ * arrive signed.
455
+ */
456
+ export declare interface UpcomingInvoiceFormatters {
457
+ date?: (date: Date, locale: string) => string;
458
+ amount?: (amountMinor: number, currency: string, locale: string) => string;
459
+ }
460
+
294
461
  export { useInvalidateBillingData }
295
462
 
296
463
  export { useInvoices }
@@ -324,6 +491,8 @@ export { useSchematicTranslate }
324
491
  */
325
492
  export declare function useTranslator(overrides?: StringOverrides, locale?: string): Translator;
326
493
 
494
+ export { useUpcomingInvoice }
495
+
327
496
  /** Not for a server render or its hydration; `useResolvedLocale` reads it
328
497
  * through `useSyncExternalStore`, which keeps it out of both. */
329
498
  export declare function viewerLocale(): string | undefined;
@@ -7,7 +7,8 @@ import {
7
7
  useSchematicI18n as useSchematicI18n2,
8
8
  useSchematicLocale as useSchematicLocale2,
9
9
  useSchematicStrings,
10
- useSchematicTranslate
10
+ useSchematicTranslate,
11
+ useUpcomingInvoice as useUpcomingInvoice2
11
12
  } from "@schematichq/schematic-react";
12
13
 
13
14
  // src/elements/model/errors.ts
@@ -468,6 +469,12 @@ function formatConsumptionRate(rate, locale) {
468
469
  maximumFractionDigits: MAXIMUM_FRACTION_DIGITS
469
470
  });
470
471
  }
472
+ function formatPercent(fraction, locale) {
473
+ return new Intl.NumberFormat(usableLocale(locale), {
474
+ style: "percent",
475
+ maximumFractionDigits: 2
476
+ }).format(fraction);
477
+ }
471
478
  function usableDate(date) {
472
479
  if (date === null || date === void 0) {
473
480
  return void 0;
@@ -557,6 +564,64 @@ function deriveInvoiceList(page, options) {
557
564
  };
558
565
  }
559
566
 
567
+ // src/elements/model/upcomingBill.ts
568
+ function deriveUpcomingInvoice(invoice, options) {
569
+ const { format, locale } = options;
570
+ const currency = invoice.currency.toUpperCase();
571
+ const money = (amountMinor) => format?.amount?.(amountMinor, currency, locale) ?? formatCurrency(amountMinor, currency, locale, {
572
+ preserveSubUnitPrecision: false
573
+ });
574
+ const line = (amountMinor) => ({
575
+ amountMinor,
576
+ amountText: money(amountMinor)
577
+ });
578
+ const applied = invoice.customerBalanceApplied;
579
+ const remaining = invoice.customerBalanceRemaining;
580
+ const dueDate = usableDate(invoice.dueDate) ?? null;
581
+ return {
582
+ amountDueMinor: invoice.amountDue,
583
+ amountDueText: money(invoice.amountDue),
584
+ subtotalMinor: invoice.subtotal,
585
+ subtotalText: money(invoice.subtotal),
586
+ currency,
587
+ dueAt: dueDate === null ? null : {
588
+ date: dueDate,
589
+ text: format?.date?.(dueDate, locale) ?? formatDate(dueDate, locale)
590
+ },
591
+ // A deduction: the sign is the locale's, so a host never assembles one.
592
+ balanceApplied: applied > 0 ? line(-applied) : null,
593
+ // Zero remaining is worth saying when a balance was spent; no balance at
594
+ // all is not.
595
+ balanceRemaining: applied > 0 || remaining > 0 ? line(remaining) : null,
596
+ discounts: invoice.discounts.flatMap(
597
+ (discount) => discountLine(discount, currency, locale, money)
598
+ )
599
+ };
600
+ }
601
+ function discountLine(discount, invoiceCurrency, locale, money) {
602
+ const percentOff = discount.percentOff ?? null;
603
+ const amountOff = discount.amountOff ?? null;
604
+ const isPercent = percentOff !== null && percentOff > 0;
605
+ if (!isPercent && (amountOff === null || amountOff <= 0)) {
606
+ return [];
607
+ }
608
+ const currency = discount.currency?.toUpperCase() ?? invoiceCurrency;
609
+ return [
610
+ {
611
+ couponName: discount.couponName,
612
+ code: discount.customerFacingCode ?? null,
613
+ kind: isPercent ? "percent" : "amount",
614
+ valueText: isPercent ? formatPercent(percentOff / 100, locale) : currency === invoiceCurrency ? money(amountOff ?? 0) : formatCurrency(amountOff ?? 0, currency, locale, {
615
+ preserveSubUnitPrecision: false
616
+ }),
617
+ percentOff: isPercent ? percentOff : null,
618
+ amountOffMinor: isPercent ? null : amountOff,
619
+ months: discount.duration === "repeating" ? discount.durationInMonths ?? null : null,
620
+ duration: discount.duration
621
+ }
622
+ ];
623
+ }
624
+
560
625
  // src/elements/strings.ts
561
626
  var DEFAULT_STRINGS_LOCALE = "en";
562
627
  var DEFAULT_STRINGS = {
@@ -571,7 +636,21 @@ var DEFAULT_STRINGS = {
571
636
  invoicesLoadMore: "Load more",
572
637
  invoicesChargeTooltip: "Charge \u2014 you were billed this amount",
573
638
  invoicesCreditTooltip: "Credit \u2014 this amount was returned to your account, typically due to a plan change or proration",
574
- invoicesUndated: "View invoice"
639
+ invoicesUndated: "View invoice",
640
+ upcomingBillLoading: "Loading your next bill",
641
+ upcomingBillHeader: "Next bill due {{date}}",
642
+ upcomingBillError: "There was a problem retrieving your upcoming invoice.",
643
+ upcomingBillUnavailable: "Your upcoming invoice is not available for this account.",
644
+ upcomingBillEmpty: "No upcoming invoice",
645
+ upcomingBillEstimate: "Estimated bill",
646
+ upcomingBillBalanceApplied: "Applied balance towards next invoice",
647
+ upcomingBillBalanceRemaining: "Remaining balance after next invoice",
648
+ upcomingBillDiscount: "Discount",
649
+ upcomingBillDiscountValue: "{{value}} off",
650
+ // Looked up by the bare key with `{ count }`; English has two forms.
651
+ upcomingBillDiscountRepeating: "{{value}} off for next {{count}} months",
652
+ upcomingBillDiscountRepeating_one: "{{value}} off for next month",
653
+ upcomingBillDiscountRepeating_other: "{{value}} off for next {{count}} months"
575
654
  };
576
655
  var MISSING_STRING = "\0schematic:missing";
577
656
  function interpolate(template, vars) {
@@ -738,6 +817,83 @@ ${Object.entries(SCHEMATIC_TOKENS).map(([name, value]) => ` ${name}: ${value};`
738
817
  }
739
818
  `;
740
819
 
820
+ // src/elements/styles/upcoming-bill.ts
821
+ var upcomingBillCss = `
822
+ .schematic-upcoming-bill {
823
+ display: flex;
824
+ flex-direction: column;
825
+ gap: var(--schematic-space);
826
+ }
827
+
828
+ .schematic-upcoming-bill .schematic-header {
829
+ margin-bottom: 0;
830
+ }
831
+
832
+ .schematic-upcoming-bill .schematic-header__title {
833
+ margin-bottom: 0;
834
+ }
835
+
836
+ .schematic-upcoming-bill__amount {
837
+ align-items: flex-start;
838
+ display: flex;
839
+ gap: var(--schematic-space);
840
+ justify-content: space-between;
841
+ }
842
+
843
+ .schematic-upcoming-bill__total {
844
+ font-family: var(--schematic-font-heading);
845
+ font-size: 1.8125rem;
846
+ font-variant-numeric: tabular-nums;
847
+ font-weight: 800;
848
+ line-height: 1;
849
+ }
850
+
851
+ .schematic-upcoming-bill__estimate {
852
+ font-weight: 600;
853
+ max-width: 10rem;
854
+ text-align: end;
855
+ }
856
+
857
+ .schematic-upcoming-bill__rows {
858
+ display: flex;
859
+ flex-direction: column;
860
+ gap: var(--schematic-space);
861
+ }
862
+
863
+ .schematic-upcoming-bill .schematic-row__value {
864
+ font-variant-numeric: tabular-nums;
865
+ }
866
+
867
+ .schematic-upcoming-bill__discounts {
868
+ align-items: flex-end;
869
+ display: flex;
870
+ flex-direction: column;
871
+ gap: calc(var(--schematic-space) / 2);
872
+ list-style: none;
873
+ margin: 0;
874
+ padding: 0;
875
+ }
876
+
877
+ .schematic-upcoming-bill__discount {
878
+ align-items: center;
879
+ display: inline-flex;
880
+ gap: calc(var(--schematic-space) / 2);
881
+ }
882
+
883
+ .schematic-upcoming-bill__empty {
884
+ padding: calc(var(--schematic-space) / 2) 0;
885
+ }
886
+
887
+ .schematic-upcoming-bill .schematic-skeleton__cell[data-column="amount"] {
888
+ height: 1.8125rem;
889
+ width: 7rem;
890
+ }
891
+
892
+ .schematic-upcoming-bill .schematic-skeleton__cell[data-column="row"] {
893
+ width: 12rem;
894
+ }
895
+ `;
896
+
741
897
  // src/elements/styles/index.tsx
742
898
  import { jsx } from "react/jsx-runtime";
743
899
  var rulesCss = `
@@ -781,6 +937,12 @@ var rulesCss = `
781
937
  gap: var(--schematic-space);
782
938
  }
783
939
 
940
+ /* The message may run long; the action beside it stays one line. */
941
+ .schematic-status__retry {
942
+ flex-shrink: 0;
943
+ white-space: nowrap;
944
+ }
945
+
784
946
  /* Visually hidden, still read by assistive technology. */
785
947
  .schematic-hidden {
786
948
  border: 0;
@@ -1047,6 +1209,22 @@ var rulesCss = `
1047
1209
  margin: 0 0 calc(var(--schematic-space) / 2);
1048
1210
  }
1049
1211
 
1212
+ /* A label on the left, its value on the right. */
1213
+ .schematic-row {
1214
+ align-items: flex-start;
1215
+ display: flex;
1216
+ gap: var(--schematic-space);
1217
+ justify-content: space-between;
1218
+ }
1219
+
1220
+ .schematic-row__label {
1221
+ font-weight: 600;
1222
+ }
1223
+
1224
+ .schematic-row__value {
1225
+ text-align: end;
1226
+ }
1227
+
1050
1228
  .schematic-feature-list {
1051
1229
  display: flex;
1052
1230
  flex-direction: column;
@@ -1233,6 +1411,7 @@ var rulesCss = `
1233
1411
  }
1234
1412
 
1235
1413
  ${invoicesCss}
1414
+ ${upcomingBillCss}
1236
1415
  `;
1237
1416
  var schematicStylesCss = withTokenDefaults(rulesCss);
1238
1417
  var SchematicStyles = () => /* @__PURE__ */ jsx("style", { "data-schematic-styles": "", children: schematicStylesCss });
@@ -1249,6 +1428,17 @@ import {
1249
1428
  import { useCallback, useEffect, useSyncExternalStore } from "react";
1250
1429
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
1251
1430
  var cx = (...names) => names.filter((name) => typeof name === "string" && name !== "").join(" ");
1431
+ function billingResources(...elements) {
1432
+ const names = [];
1433
+ for (const element of elements) {
1434
+ for (const name of element.resources) {
1435
+ if (!names.includes(name)) {
1436
+ names.push(name);
1437
+ }
1438
+ }
1439
+ }
1440
+ return names;
1441
+ }
1252
1442
  function useResolvedLocale(locale) {
1253
1443
  const configured = useSchematicLocale();
1254
1444
  const viewer = useSyncExternalStore(
@@ -1503,6 +1693,126 @@ function InvoiceDate({ row, t }) {
1503
1693
  }
1504
1694
  );
1505
1695
  }
1696
+ Invoices.resources = ["invoices"];
1697
+
1698
+ // src/elements/UpcomingBill.tsx
1699
+ import { useUpcomingInvoice } from "@schematichq/schematic-react";
1700
+ import { useMemo as useMemo2 } from "react";
1701
+ import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
1702
+ function UpcomingBill({
1703
+ className,
1704
+ headingLevel = 2,
1705
+ locale: localeProp,
1706
+ showAmount = true,
1707
+ showBalance = true,
1708
+ showDiscounts = true,
1709
+ showHeader = true,
1710
+ strings
1711
+ }) {
1712
+ const { data: invoice, error, isPending, refetch } = useUpcomingInvoice();
1713
+ const locale = useResolvedLocale(localeProp);
1714
+ const t = useTranslator(strings, localeProp);
1715
+ const bill = useMemo2(
1716
+ () => invoice === void 0 || invoice === null ? null : deriveUpcomingInvoice(invoice, { locale }),
1717
+ [invoice, locale]
1718
+ );
1719
+ const Heading = `h${headingLevel}`;
1720
+ const balanceRows = showBalance && bill !== null && (bill.balanceApplied !== null || bill.balanceRemaining !== null);
1721
+ const discountRow = showDiscounts && bill !== null && bill.discounts.length > 0;
1722
+ const unavailable = invoice === void 0 && httpStatus(error) === 404;
1723
+ const errorMessage = error === void 0 ? void 0 : unavailable ? t("upcomingBillUnavailable") : t("upcomingBillError");
1724
+ return /* @__PURE__ */ jsx4(
1725
+ StatusFrame,
1726
+ {
1727
+ className: cx("schematic-card", "schematic-upcoming-bill", className),
1728
+ error,
1729
+ errorMessage,
1730
+ hasData: invoice !== void 0,
1731
+ isPending,
1732
+ loadingLabel: t("upcomingBillLoading"),
1733
+ onRetry: refetch,
1734
+ retryText: t("retry"),
1735
+ skeleton: /* @__PURE__ */ jsx4(UpcomingBillSkeleton, { showHeader }),
1736
+ children: bill === null ? invoice !== void 0 && /* @__PURE__ */ jsx4("p", { className: "schematic-muted schematic-upcoming-bill__empty", children: t("upcomingBillEmpty") }) : /* @__PURE__ */ jsxs3(Fragment2, { children: [
1737
+ showHeader && bill.dueAt !== null && /* @__PURE__ */ jsx4("div", { className: "schematic-header", children: /* @__PURE__ */ jsx4(Heading, { className: "schematic-header__title", children: t("upcomingBillHeader", { date: bill.dueAt.text }) }) }),
1738
+ showAmount && /* @__PURE__ */ jsxs3("div", { className: "schematic-upcoming-bill__amount", children: [
1739
+ /* @__PURE__ */ jsx4(
1740
+ "span",
1741
+ {
1742
+ className: "schematic-upcoming-bill__total",
1743
+ "data-testid": "schematic-upcoming-total",
1744
+ children: bill.amountDueText
1745
+ }
1746
+ ),
1747
+ /* @__PURE__ */ jsx4("span", { className: "schematic-small schematic-upcoming-bill__estimate", children: t("upcomingBillEstimate") })
1748
+ ] }),
1749
+ (balanceRows || discountRow) && /* @__PURE__ */ jsxs3("div", { className: "schematic-upcoming-bill__rows", children: [
1750
+ balanceRows && bill.balanceApplied !== null && /* @__PURE__ */ jsxs3(
1751
+ "div",
1752
+ {
1753
+ className: "schematic-row schematic-upcoming-bill__balance-applied",
1754
+ "data-testid": "schematic-balance-applied",
1755
+ children: [
1756
+ /* @__PURE__ */ jsx4("span", { className: "schematic-row__label", children: t("upcomingBillBalanceApplied") }),
1757
+ /* @__PURE__ */ jsx4("span", { className: "schematic-row__value", children: bill.balanceApplied.amountText })
1758
+ ]
1759
+ }
1760
+ ),
1761
+ balanceRows && bill.balanceRemaining !== null && /* @__PURE__ */ jsxs3(
1762
+ "div",
1763
+ {
1764
+ className: "schematic-row schematic-upcoming-bill__balance-remaining",
1765
+ "data-testid": "schematic-balance-remaining",
1766
+ children: [
1767
+ /* @__PURE__ */ jsx4("span", { className: "schematic-row__label", children: t("upcomingBillBalanceRemaining") }),
1768
+ /* @__PURE__ */ jsx4("span", { className: "schematic-row__value", children: bill.balanceRemaining.amountText })
1769
+ ]
1770
+ }
1771
+ ),
1772
+ discountRow && /* @__PURE__ */ jsxs3(
1773
+ "div",
1774
+ {
1775
+ className: "schematic-row schematic-upcoming-bill__discount-row",
1776
+ "data-testid": "schematic-discounts",
1777
+ children: [
1778
+ /* @__PURE__ */ jsx4("span", { className: "schematic-row__label", children: t("upcomingBillDiscount") }),
1779
+ /* @__PURE__ */ jsx4("ul", { className: "schematic-row__value schematic-upcoming-bill__discounts", children: bill.discounts.map((discount, index) => /* @__PURE__ */ jsxs3(
1780
+ "li",
1781
+ {
1782
+ className: "schematic-upcoming-bill__discount",
1783
+ "data-testid": "schematic-discount",
1784
+ children: [
1785
+ discount.code !== null && /* @__PURE__ */ jsx4("span", { className: "schematic-chip schematic-upcoming-bill__code", children: discount.code }),
1786
+ /* @__PURE__ */ jsx4("span", { className: "schematic-upcoming-bill__discount-value", children: discountText(discount, t) })
1787
+ ]
1788
+ },
1789
+ `${discount.couponName}-${index}`
1790
+ )) })
1791
+ ]
1792
+ }
1793
+ )
1794
+ ] })
1795
+ ] })
1796
+ }
1797
+ );
1798
+ }
1799
+ function UpcomingBillSkeleton({ showHeader }) {
1800
+ return /* @__PURE__ */ jsxs3("div", { className: "schematic-skeleton", children: [
1801
+ showHeader && /* @__PURE__ */ jsx4("div", { className: "schematic-skeleton__heading" }),
1802
+ /* @__PURE__ */ jsx4("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ jsx4("div", { className: "schematic-skeleton__cell", "data-column": "amount" }) }),
1803
+ /* @__PURE__ */ jsx4("div", { className: "schematic-skeleton__row", children: /* @__PURE__ */ jsx4("div", { className: "schematic-skeleton__cell", "data-column": "row" }) })
1804
+ ] });
1805
+ }
1806
+ function discountText(discount, t) {
1807
+ if (discount.months === null) {
1808
+ return t("upcomingBillDiscountValue", { value: discount.valueText });
1809
+ }
1810
+ return t("upcomingBillDiscountRepeating", {
1811
+ count: discount.months,
1812
+ value: discount.valueText
1813
+ });
1814
+ }
1815
+ UpcomingBill.resources = ["upcomingInvoice"];
1506
1816
  export {
1507
1817
  BillingDataProvider,
1508
1818
  DEFAULT_STRINGS,
@@ -1510,12 +1820,16 @@ export {
1510
1820
  SCHEMATIC_TOKENS,
1511
1821
  SchematicI18nProvider,
1512
1822
  SchematicStyles,
1823
+ UpcomingBill,
1824
+ billingResources,
1513
1825
  deriveInvoiceList,
1826
+ deriveUpcomingInvoice,
1514
1827
  featureName,
1515
1828
  formatConsumptionRate,
1516
1829
  formatCurrency,
1517
1830
  formatDate,
1518
1831
  formatNumber,
1832
+ formatPercent,
1519
1833
  formatShortDate,
1520
1834
  httpStatus,
1521
1835
  interpolate,
@@ -1532,5 +1846,6 @@ export {
1532
1846
  useSchematicStrings,
1533
1847
  useSchematicTranslate,
1534
1848
  useTranslator,
1849
+ useUpcomingInvoice2 as useUpcomingInvoice,
1535
1850
  viewerLocale
1536
1851
  };