@asteby/storefront-react 0.26.0 → 0.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.
Files changed (38) hide show
  1. package/README.md +7 -2
  2. package/dist/account-server.cjs +533 -83
  3. package/dist/account-server.cjs.map +1 -1
  4. package/dist/account-server.d.cts +13 -2
  5. package/dist/account-server.d.ts +13 -2
  6. package/dist/account-server.js +23 -6
  7. package/dist/account-server.js.map +1 -1
  8. package/dist/account.cjs +572 -96
  9. package/dist/account.cjs.map +1 -1
  10. package/dist/account.d.cts +82 -45
  11. package/dist/account.d.ts +82 -45
  12. package/dist/account.js +53 -14
  13. package/dist/account.js.map +1 -1
  14. package/dist/checkout.cjs +114 -38
  15. package/dist/checkout.cjs.map +1 -1
  16. package/dist/checkout.d.cts +24 -1
  17. package/dist/checkout.d.ts +24 -1
  18. package/dist/checkout.js +114 -38
  19. package/dist/checkout.js.map +1 -1
  20. package/dist/chunk-BXKV2KWZ.js +291 -0
  21. package/dist/chunk-BXKV2KWZ.js.map +1 -0
  22. package/dist/chunk-LIUEQENV.js +156 -0
  23. package/dist/chunk-LIUEQENV.js.map +1 -0
  24. package/dist/fiscal-server.cjs +27 -2
  25. package/dist/fiscal-server.cjs.map +1 -1
  26. package/dist/fiscal-server.d.cts +10 -1
  27. package/dist/fiscal-server.d.ts +10 -1
  28. package/dist/fiscal-server.js +26 -3
  29. package/dist/fiscal-server.js.map +1 -1
  30. package/dist/voucher-document-FWH4DQ5N.js +72 -0
  31. package/dist/voucher-document-FWH4DQ5N.js.map +1 -0
  32. package/dist/voucher-pdf-LQC333AB.js +213 -0
  33. package/dist/voucher-pdf-LQC333AB.js.map +1 -0
  34. package/package.json +1 -1
  35. package/dist/chunk-TXEYBDFG.js +0 -182
  36. package/dist/chunk-TXEYBDFG.js.map +0 -1
  37. package/dist/voucher-document-SFWJCLTN.js +0 -124
  38. package/dist/voucher-document-SFWJCLTN.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ComponentType, ReactNode, MouseEvent } from 'react';
3
- import { CustomerCapabilities, Order, NextAction, OrderProgress as OrderProgress$1, OrderLine, Shipment, ShipmentMap, InvoiceDoc, InvoiceSummary, InvoiceFileKind, PendingPayment, PaymentInfo, Refund, StorefrontClient, Connection, Money, CustomerSessionInfo, CustomerPreferences } from '@asteby/storefront';
3
+ import { CustomerCapabilities, Order, NextAction, OrderProgress as OrderProgress$1, OrderLine, Shipment, ShipmentMap, InvoiceDoc, InvoiceSummary, InvoiceFileKind, Money, PendingPayment, PaymentInfo, Refund, StorefrontClient, Connection, CustomerSessionInfo, CustomerPreferences } from '@asteby/storefront';
4
4
  import { a as CheckoutFieldClassNames } from './fields-vnMUi2HB.cjs';
5
5
  import { a as AuthActionData, d as AuthStep, b as AuthErrorCode, A as AccountSettingsActionData } from './settings-types-jxFQFFqP.cjs';
6
6
  export { c as AuthIntent, S as SettingsErrorCode, e as SettingsIntent } from './settings-types-jxFQFFqP.cjs';
@@ -258,6 +258,8 @@ declare const ES$1: {
258
258
  readonly 'pending.expired': "Vencida";
259
259
  readonly 'pending.reference': "Referencia";
260
260
  readonly 'pending.clabe': "CLABE";
261
+ readonly 'pending.beneficiary': "Beneficiario";
262
+ readonly 'pending.bank': "Banco";
261
263
  readonly 'pending.expires': "Vence el {date}";
262
264
  readonly 'pending.expiredOn': "Venció el {date}";
263
265
  readonly 'pending.total': "Total";
@@ -266,9 +268,11 @@ declare const ES$1: {
266
268
  readonly 'pending.copied': "Copiada";
267
269
  readonly 'pending.copyFailed': "No pudimos copiar; selecciona el texto.";
268
270
  readonly 'pending.print': "Ver e imprimir ficha";
269
- readonly 'pending.download': "Descargar ficha";
271
+ readonly 'pending.download': "Descargar PDF";
270
272
  readonly 'pending.expiredNote': "Esta ficha ya no es válida. Haz tu pedido de nuevo.";
271
273
  readonly 'pending.barcode': "Código de barras {code}";
274
+ readonly 'pending.code': "Código";
275
+ readonly 'pending.ticket': "Ver comprobante del proveedor";
272
276
  readonly 'pending.method.oxxo': "OXXO";
273
277
  readonly 'pending.method.spei': "Transferencia SPEI";
274
278
  readonly 'pending.method.bank_transfer': "Transferencia bancaria";
@@ -483,20 +487,92 @@ type InvoiceListProps = AccountTextProps & {
483
487
  };
484
488
  declare function InvoiceList({ invoices, summary, renderSummary, fileHref, onDownload, degraded, onRetry, testMode, headingLevel, children, classNames: cx, ...text }: InvoiceListProps): react.JSX.Element;
485
489
 
490
+ /**
491
+ * Pure pieces of the cash voucher (OXXO, SPEI, deposit): the normalized `VoucherView` of a `PendingPayment` and the
492
+ * Code 128 barcode (the one cashiers' readers scan). No React, no DOM: the same code draws the barcode in the page
493
+ * (`<Barcode>`) and in the printable document (`voucher-document.ts`, loaded only when the buyer prints).
494
+ */
495
+
496
+ type VoucherView = {
497
+ /** `oxxo`, `spei`, ... as the gateway publishes it. */
498
+ method: string | null;
499
+ reference: string | null;
500
+ /** Value the barcode encodes, exactly as the server sent it. `null` when the server sent none or it cannot be drawn. */
501
+ barcode: string | null;
502
+ /** Symbology of `barcode`; `null` when there is no barcode or its format is not one we can draw. */
503
+ barcode_format: BarcodeFormat | null;
504
+ /**
505
+ * Code the server sent but that is NOT drawn (`barcode_data` is null or names a symbology we cannot draw): shown as
506
+ * plain text. `null` when there is nothing to show (also when it is the same as `reference`).
507
+ */
508
+ barcode_text: string | null;
509
+ clabe: string | null;
510
+ /** SPEI / transfer: who receives the money and in which bank. */
511
+ beneficiary: string | null;
512
+ bank: string | null;
513
+ /** What kind of document to print: cash at a store, bank transfer, or unknown (generic, no brand named). */
514
+ kind: VoucherKind;
515
+ /** Server-chosen key of the instructions (`oxxo`, `spei`...); unknown keys fall back to the kind. */
516
+ instructions_key: string | null;
517
+ /** `https` link to the provider's own receipt: `ticket_url`, else the older `voucher_url`. */
518
+ ticket_url: string | null;
519
+ expires_at: string | null;
520
+ amount: Money | null;
521
+ instructions: string | null;
522
+ };
523
+ type BarcodeFormat = 'code128' | 'code39' | 'itf' | 'ean13';
524
+ type VoucherKind = 'cash' | 'transfer' | 'generic';
525
+ /** The voucher of a pending payment; `null` when it has neither reference, barcode nor CLABE (nothing to pay with). */
526
+ declare function voucherOf(p: Pick<PendingPayment, 'payment' | 'total' | 'expires_at'> | null | undefined): VoucherView | null;
527
+ /**
528
+ * The value the barcode encodes: only what the server sent. A reference is NOT a barcode (an OXXO reference and its
529
+ * scannable code differ), so without `barcode` nothing is drawn and the reference is shown as text.
530
+ */
531
+ declare function barcodeValue(v: Pick<VoucherView, 'barcode'>): string | null;
532
+ /**
533
+ * Modules (`1` bar, `0` space) of the Code 128 of `value`: set C (digit pairs) when it is all digits of even length,
534
+ * set B (printable ASCII) otherwise. `null` when it cannot be encoded.
535
+ */
536
+ declare function code128Modules(value: string): string | null;
537
+ /** Modules of the Code 39 of `value` (`*` start/stop added). `null` for lower case, `*` or anything outside its set. */
538
+ declare function code39Modules(value: string): string | null;
539
+ /** Modules of `value` in the given symbology. */
540
+ declare function barcodeModules(value: string, format?: BarcodeFormat): string | null;
541
+ type BarcodeGeometry = {
542
+ width: number;
543
+ height: number;
544
+ rects: {
545
+ x: number;
546
+ w: number;
547
+ }[];
548
+ };
549
+ /** Bars of the barcode as rectangles (quiet zone of 10 modules each side included in `width`). `null` if not encodable. */
550
+ declare function barcodeGeometry(value: string, opts?: {
551
+ module?: number;
552
+ height?: number;
553
+ format?: BarcodeFormat;
554
+ }): BarcodeGeometry | null;
555
+
486
556
  type BarcodeProps = {
487
557
  value: string;
488
558
  label: string;
489
559
  height?: number;
490
- className?: string;
560
+ className?: string; /** Symbology (default Code 128). */
561
+ format?: BarcodeFormat;
491
562
  };
492
563
  /** Code 128 as an inline `<svg role="img">` (no HTML injection). `null` when the value cannot be encoded. */
493
- declare function Barcode({ value, label, height, className }: BarcodeProps): react.JSX.Element | null;
564
+ declare function Barcode({ value, label, height, className, format }: BarcodeProps): react.JSX.Element | null;
494
565
  type PendingPaymentCardClassNames = Partial<Record<'root' | 'header' | 'method' | 'badge' | 'field' | 'label' | 'value' | 'barcode' | 'expiry' | 'total' | 'note' | 'actions' | 'primary' | 'secondary', string>>;
495
566
  type PendingPaymentCardProps = AccountTextProps & {
496
567
  payment: PendingPayment;
497
- /** Server route that serves the printable voucher: `(payment, { download })`. Without it the browser builds it. */
568
+ /**
569
+ * Server route that serves the voucher: `(payment, { download, format })`. The "view and print" link asks for
570
+ * `{ download: false, format: 'html' }`, the download link for `{ download: true, format: 'pdf' }` (a store whose
571
+ * route predates `format` keeps serving the HTML attachment). Without it the browser builds the documents.
572
+ */
498
573
  voucherHref?: (payment: PendingPayment, opts: {
499
574
  download: boolean;
575
+ format: 'html' | 'pdf';
500
576
  }) => string;
501
577
  /** Store name printed on the document built in the browser. */
502
578
  shopName?: string;
@@ -618,45 +694,6 @@ type UseCustomerOrderResult = {
618
694
  /** One order with its detail (shipments, invoices, payments, refunds, `degraded`). */
619
695
  declare function useCustomerOrder(id: string | null | undefined, { client, initial, poll }?: UseCustomerOrderOptions): UseCustomerOrderResult;
620
696
 
621
- /**
622
- * Pure pieces of the cash voucher (OXXO, SPEI, deposit): the normalized `VoucherView` of a `PendingPayment` and the
623
- * Code 128 barcode (the one cashiers' readers scan). No React, no DOM: the same code draws the barcode in the page
624
- * (`<Barcode>`) and in the printable document (`voucher-document.ts`, loaded only when the buyer prints).
625
- */
626
-
627
- type VoucherView = {
628
- /** `oxxo`, `spei`, ... as the gateway publishes it. */
629
- method: string | null;
630
- reference: string | null;
631
- barcode: string | null;
632
- clabe: string | null;
633
- expires_at: string | null;
634
- amount: Money | null;
635
- instructions: string | null;
636
- };
637
- /** The voucher of a pending payment; `null` when it has neither reference, barcode nor CLABE (nothing to pay with). */
638
- declare function voucherOf(p: Pick<PendingPayment, 'payment' | 'total' | 'expires_at'> | null | undefined): VoucherView | null;
639
- /** The value the barcode encodes: the gateway's `barcode`, else the reference of an OXXO voucher. */
640
- declare function barcodeValue(v: Pick<VoucherView, 'barcode' | 'method' | 'reference'>): string | null;
641
- /**
642
- * Modules (`1` bar, `0` space) of the Code 128 of `value`: set C (digit pairs) when it is all digits of even length,
643
- * set B (printable ASCII) otherwise. `null` when it cannot be encoded.
644
- */
645
- declare function code128Modules(value: string): string | null;
646
- type BarcodeGeometry = {
647
- width: number;
648
- height: number;
649
- rects: {
650
- x: number;
651
- w: number;
652
- }[];
653
- };
654
- /** Bars of the barcode as rectangles (quiet zone of 10 modules each side included in `width`). `null` if not encodable. */
655
- declare function barcodeGeometry(value: string, opts?: {
656
- module?: number;
657
- height?: number;
658
- }): BarcodeGeometry | null;
659
-
660
697
  /**
661
698
  * Texts of the account settings screens (`SessionsList`, and the other sections). Spanish (es-MX) by default,
662
699
  * English with `en*`, anything with `messages`. Server errors are codes (`SettingsErrorCode`); the words are here.
@@ -781,4 +818,4 @@ type NotificationPreferencesProps = SectionProps & {
781
818
  };
782
819
  declare function NotificationPreferences({ channels, preferences, events, data, pending, form: FormTag, action, headingLevel, classNames: cx, children, ...text }: NotificationPreferencesProps): react.JSX.Element | null;
783
820
 
784
- export { AccountAuth, type AccountAuthClassNames, type AccountAuthMessages, type AccountAuthProps, type AccountAuthView, type AccountFormProps, type AccountMessageKey, type AccountMessages, AccountSettingsActionData, type AccountStatus, type AccountTextProps, AuthActionData, AuthErrorCode, AuthStep, Barcode, type BarcodeGeometry, type BarcodeProps, InvoiceList, type InvoiceListClassNames, type InvoiceListProps, LanguagePreference, type LanguagePreferenceClassNames, type LanguagePreferenceProps, NOTIFICATION_EVENTS, NextActionBar, type NextActionBarClassNames, type NextActionBarProps, NotificationPreferences, type NotificationPreferencesClassNames, type NotificationPreferencesProps, OrderCard, type OrderCardClassNames, type OrderCardProps, OrderLines, type OrderLinesClassNames, type OrderLinesProps, OrderList, type OrderListClassNames, type OrderListProps, OrderProductsStack, OrderProgress, type OrderProgressClassNames, type OrderProgressProps, OrderStatusBadge, type OrderStatusBadgeProps, type OrderTone, type PaymentLabelOptions, type PaymentMethodKey, PaymentSummary, type PaymentSummaryProps, PendingPaymentCard, type PendingPaymentCardClassNames, type PendingPaymentCardProps, PendingPaymentList, type PendingPaymentListProps, PostPurchaseAccountPrompt, type PostPurchaseAccountPromptClassNames, type PostPurchaseAccountPromptMessages, type PostPurchaseAccountPromptProps, RefundList, type RefundListClassNames, type RefundListProps, SessionsList, type SessionsListClassNames, type SessionsListProps, type SettingsMessageKey, type SettingsMessages, type SettingsTextProps, ShipmentCard, type ShipmentCardClassNames, type ShipmentCardProps, type ShipmentMapSlotProps, type UseConnectionResult, type UseCustomerOrderOptions, type UseCustomerOrderResult, type UseCustomerOrdersOptions, type UsePendingPaymentsOptions, type VoucherView, accountAuthMessages, accountMessages, barcodeGeometry, barcodeValue, code128Modules, enumText, lineImage, paymentLabel, paymentMethodKey, postPurchaseAccountPromptMessages, settingsEnumText, settingsMessages, stageTone, useCustomerOrder, useCustomerOrders, usePendingPayments, voucherOf };
821
+ export { AccountAuth, type AccountAuthClassNames, type AccountAuthMessages, type AccountAuthProps, type AccountAuthView, type AccountFormProps, type AccountMessageKey, type AccountMessages, AccountSettingsActionData, type AccountStatus, type AccountTextProps, AuthActionData, AuthErrorCode, AuthStep, Barcode, type BarcodeFormat, type BarcodeGeometry, type BarcodeProps, InvoiceList, type InvoiceListClassNames, type InvoiceListProps, LanguagePreference, type LanguagePreferenceClassNames, type LanguagePreferenceProps, NOTIFICATION_EVENTS, NextActionBar, type NextActionBarClassNames, type NextActionBarProps, NotificationPreferences, type NotificationPreferencesClassNames, type NotificationPreferencesProps, OrderCard, type OrderCardClassNames, type OrderCardProps, OrderLines, type OrderLinesClassNames, type OrderLinesProps, OrderList, type OrderListClassNames, type OrderListProps, OrderProductsStack, OrderProgress, type OrderProgressClassNames, type OrderProgressProps, OrderStatusBadge, type OrderStatusBadgeProps, type OrderTone, type PaymentLabelOptions, type PaymentMethodKey, PaymentSummary, type PaymentSummaryProps, PendingPaymentCard, type PendingPaymentCardClassNames, type PendingPaymentCardProps, PendingPaymentList, type PendingPaymentListProps, PostPurchaseAccountPrompt, type PostPurchaseAccountPromptClassNames, type PostPurchaseAccountPromptMessages, type PostPurchaseAccountPromptProps, RefundList, type RefundListClassNames, type RefundListProps, SessionsList, type SessionsListClassNames, type SessionsListProps, type SettingsMessageKey, type SettingsMessages, type SettingsTextProps, ShipmentCard, type ShipmentCardClassNames, type ShipmentCardProps, type ShipmentMapSlotProps, type UseConnectionResult, type UseCustomerOrderOptions, type UseCustomerOrderResult, type UseCustomerOrdersOptions, type UsePendingPaymentsOptions, type VoucherKind, type VoucherView, accountAuthMessages, accountMessages, barcodeGeometry, barcodeModules, barcodeValue, code128Modules, code39Modules, enumText, lineImage, paymentLabel, paymentMethodKey, postPurchaseAccountPromptMessages, settingsEnumText, settingsMessages, stageTone, useCustomerOrder, useCustomerOrders, usePendingPayments, voucherOf };
package/dist/account.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ComponentType, ReactNode, MouseEvent } from 'react';
3
- import { CustomerCapabilities, Order, NextAction, OrderProgress as OrderProgress$1, OrderLine, Shipment, ShipmentMap, InvoiceDoc, InvoiceSummary, InvoiceFileKind, PendingPayment, PaymentInfo, Refund, StorefrontClient, Connection, Money, CustomerSessionInfo, CustomerPreferences } from '@asteby/storefront';
3
+ import { CustomerCapabilities, Order, NextAction, OrderProgress as OrderProgress$1, OrderLine, Shipment, ShipmentMap, InvoiceDoc, InvoiceSummary, InvoiceFileKind, Money, PendingPayment, PaymentInfo, Refund, StorefrontClient, Connection, CustomerSessionInfo, CustomerPreferences } from '@asteby/storefront';
4
4
  import { a as CheckoutFieldClassNames } from './fields-vnMUi2HB.js';
5
5
  import { a as AuthActionData, d as AuthStep, b as AuthErrorCode, A as AccountSettingsActionData } from './settings-types-jxFQFFqP.js';
6
6
  export { c as AuthIntent, S as SettingsErrorCode, e as SettingsIntent } from './settings-types-jxFQFFqP.js';
@@ -258,6 +258,8 @@ declare const ES$1: {
258
258
  readonly 'pending.expired': "Vencida";
259
259
  readonly 'pending.reference': "Referencia";
260
260
  readonly 'pending.clabe': "CLABE";
261
+ readonly 'pending.beneficiary': "Beneficiario";
262
+ readonly 'pending.bank': "Banco";
261
263
  readonly 'pending.expires': "Vence el {date}";
262
264
  readonly 'pending.expiredOn': "Venció el {date}";
263
265
  readonly 'pending.total': "Total";
@@ -266,9 +268,11 @@ declare const ES$1: {
266
268
  readonly 'pending.copied': "Copiada";
267
269
  readonly 'pending.copyFailed': "No pudimos copiar; selecciona el texto.";
268
270
  readonly 'pending.print': "Ver e imprimir ficha";
269
- readonly 'pending.download': "Descargar ficha";
271
+ readonly 'pending.download': "Descargar PDF";
270
272
  readonly 'pending.expiredNote': "Esta ficha ya no es válida. Haz tu pedido de nuevo.";
271
273
  readonly 'pending.barcode': "Código de barras {code}";
274
+ readonly 'pending.code': "Código";
275
+ readonly 'pending.ticket': "Ver comprobante del proveedor";
272
276
  readonly 'pending.method.oxxo': "OXXO";
273
277
  readonly 'pending.method.spei': "Transferencia SPEI";
274
278
  readonly 'pending.method.bank_transfer': "Transferencia bancaria";
@@ -483,20 +487,92 @@ type InvoiceListProps = AccountTextProps & {
483
487
  };
484
488
  declare function InvoiceList({ invoices, summary, renderSummary, fileHref, onDownload, degraded, onRetry, testMode, headingLevel, children, classNames: cx, ...text }: InvoiceListProps): react.JSX.Element;
485
489
 
490
+ /**
491
+ * Pure pieces of the cash voucher (OXXO, SPEI, deposit): the normalized `VoucherView` of a `PendingPayment` and the
492
+ * Code 128 barcode (the one cashiers' readers scan). No React, no DOM: the same code draws the barcode in the page
493
+ * (`<Barcode>`) and in the printable document (`voucher-document.ts`, loaded only when the buyer prints).
494
+ */
495
+
496
+ type VoucherView = {
497
+ /** `oxxo`, `spei`, ... as the gateway publishes it. */
498
+ method: string | null;
499
+ reference: string | null;
500
+ /** Value the barcode encodes, exactly as the server sent it. `null` when the server sent none or it cannot be drawn. */
501
+ barcode: string | null;
502
+ /** Symbology of `barcode`; `null` when there is no barcode or its format is not one we can draw. */
503
+ barcode_format: BarcodeFormat | null;
504
+ /**
505
+ * Code the server sent but that is NOT drawn (`barcode_data` is null or names a symbology we cannot draw): shown as
506
+ * plain text. `null` when there is nothing to show (also when it is the same as `reference`).
507
+ */
508
+ barcode_text: string | null;
509
+ clabe: string | null;
510
+ /** SPEI / transfer: who receives the money and in which bank. */
511
+ beneficiary: string | null;
512
+ bank: string | null;
513
+ /** What kind of document to print: cash at a store, bank transfer, or unknown (generic, no brand named). */
514
+ kind: VoucherKind;
515
+ /** Server-chosen key of the instructions (`oxxo`, `spei`...); unknown keys fall back to the kind. */
516
+ instructions_key: string | null;
517
+ /** `https` link to the provider's own receipt: `ticket_url`, else the older `voucher_url`. */
518
+ ticket_url: string | null;
519
+ expires_at: string | null;
520
+ amount: Money | null;
521
+ instructions: string | null;
522
+ };
523
+ type BarcodeFormat = 'code128' | 'code39' | 'itf' | 'ean13';
524
+ type VoucherKind = 'cash' | 'transfer' | 'generic';
525
+ /** The voucher of a pending payment; `null` when it has neither reference, barcode nor CLABE (nothing to pay with). */
526
+ declare function voucherOf(p: Pick<PendingPayment, 'payment' | 'total' | 'expires_at'> | null | undefined): VoucherView | null;
527
+ /**
528
+ * The value the barcode encodes: only what the server sent. A reference is NOT a barcode (an OXXO reference and its
529
+ * scannable code differ), so without `barcode` nothing is drawn and the reference is shown as text.
530
+ */
531
+ declare function barcodeValue(v: Pick<VoucherView, 'barcode'>): string | null;
532
+ /**
533
+ * Modules (`1` bar, `0` space) of the Code 128 of `value`: set C (digit pairs) when it is all digits of even length,
534
+ * set B (printable ASCII) otherwise. `null` when it cannot be encoded.
535
+ */
536
+ declare function code128Modules(value: string): string | null;
537
+ /** Modules of the Code 39 of `value` (`*` start/stop added). `null` for lower case, `*` or anything outside its set. */
538
+ declare function code39Modules(value: string): string | null;
539
+ /** Modules of `value` in the given symbology. */
540
+ declare function barcodeModules(value: string, format?: BarcodeFormat): string | null;
541
+ type BarcodeGeometry = {
542
+ width: number;
543
+ height: number;
544
+ rects: {
545
+ x: number;
546
+ w: number;
547
+ }[];
548
+ };
549
+ /** Bars of the barcode as rectangles (quiet zone of 10 modules each side included in `width`). `null` if not encodable. */
550
+ declare function barcodeGeometry(value: string, opts?: {
551
+ module?: number;
552
+ height?: number;
553
+ format?: BarcodeFormat;
554
+ }): BarcodeGeometry | null;
555
+
486
556
  type BarcodeProps = {
487
557
  value: string;
488
558
  label: string;
489
559
  height?: number;
490
- className?: string;
560
+ className?: string; /** Symbology (default Code 128). */
561
+ format?: BarcodeFormat;
491
562
  };
492
563
  /** Code 128 as an inline `<svg role="img">` (no HTML injection). `null` when the value cannot be encoded. */
493
- declare function Barcode({ value, label, height, className }: BarcodeProps): react.JSX.Element | null;
564
+ declare function Barcode({ value, label, height, className, format }: BarcodeProps): react.JSX.Element | null;
494
565
  type PendingPaymentCardClassNames = Partial<Record<'root' | 'header' | 'method' | 'badge' | 'field' | 'label' | 'value' | 'barcode' | 'expiry' | 'total' | 'note' | 'actions' | 'primary' | 'secondary', string>>;
495
566
  type PendingPaymentCardProps = AccountTextProps & {
496
567
  payment: PendingPayment;
497
- /** Server route that serves the printable voucher: `(payment, { download })`. Without it the browser builds it. */
568
+ /**
569
+ * Server route that serves the voucher: `(payment, { download, format })`. The "view and print" link asks for
570
+ * `{ download: false, format: 'html' }`, the download link for `{ download: true, format: 'pdf' }` (a store whose
571
+ * route predates `format` keeps serving the HTML attachment). Without it the browser builds the documents.
572
+ */
498
573
  voucherHref?: (payment: PendingPayment, opts: {
499
574
  download: boolean;
575
+ format: 'html' | 'pdf';
500
576
  }) => string;
501
577
  /** Store name printed on the document built in the browser. */
502
578
  shopName?: string;
@@ -618,45 +694,6 @@ type UseCustomerOrderResult = {
618
694
  /** One order with its detail (shipments, invoices, payments, refunds, `degraded`). */
619
695
  declare function useCustomerOrder(id: string | null | undefined, { client, initial, poll }?: UseCustomerOrderOptions): UseCustomerOrderResult;
620
696
 
621
- /**
622
- * Pure pieces of the cash voucher (OXXO, SPEI, deposit): the normalized `VoucherView` of a `PendingPayment` and the
623
- * Code 128 barcode (the one cashiers' readers scan). No React, no DOM: the same code draws the barcode in the page
624
- * (`<Barcode>`) and in the printable document (`voucher-document.ts`, loaded only when the buyer prints).
625
- */
626
-
627
- type VoucherView = {
628
- /** `oxxo`, `spei`, ... as the gateway publishes it. */
629
- method: string | null;
630
- reference: string | null;
631
- barcode: string | null;
632
- clabe: string | null;
633
- expires_at: string | null;
634
- amount: Money | null;
635
- instructions: string | null;
636
- };
637
- /** The voucher of a pending payment; `null` when it has neither reference, barcode nor CLABE (nothing to pay with). */
638
- declare function voucherOf(p: Pick<PendingPayment, 'payment' | 'total' | 'expires_at'> | null | undefined): VoucherView | null;
639
- /** The value the barcode encodes: the gateway's `barcode`, else the reference of an OXXO voucher. */
640
- declare function barcodeValue(v: Pick<VoucherView, 'barcode' | 'method' | 'reference'>): string | null;
641
- /**
642
- * Modules (`1` bar, `0` space) of the Code 128 of `value`: set C (digit pairs) when it is all digits of even length,
643
- * set B (printable ASCII) otherwise. `null` when it cannot be encoded.
644
- */
645
- declare function code128Modules(value: string): string | null;
646
- type BarcodeGeometry = {
647
- width: number;
648
- height: number;
649
- rects: {
650
- x: number;
651
- w: number;
652
- }[];
653
- };
654
- /** Bars of the barcode as rectangles (quiet zone of 10 modules each side included in `width`). `null` if not encodable. */
655
- declare function barcodeGeometry(value: string, opts?: {
656
- module?: number;
657
- height?: number;
658
- }): BarcodeGeometry | null;
659
-
660
697
  /**
661
698
  * Texts of the account settings screens (`SessionsList`, and the other sections). Spanish (es-MX) by default,
662
699
  * English with `en*`, anything with `messages`. Server errors are codes (`SettingsErrorCode`); the words are here.
@@ -781,4 +818,4 @@ type NotificationPreferencesProps = SectionProps & {
781
818
  };
782
819
  declare function NotificationPreferences({ channels, preferences, events, data, pending, form: FormTag, action, headingLevel, classNames: cx, children, ...text }: NotificationPreferencesProps): react.JSX.Element | null;
783
820
 
784
- export { AccountAuth, type AccountAuthClassNames, type AccountAuthMessages, type AccountAuthProps, type AccountAuthView, type AccountFormProps, type AccountMessageKey, type AccountMessages, AccountSettingsActionData, type AccountStatus, type AccountTextProps, AuthActionData, AuthErrorCode, AuthStep, Barcode, type BarcodeGeometry, type BarcodeProps, InvoiceList, type InvoiceListClassNames, type InvoiceListProps, LanguagePreference, type LanguagePreferenceClassNames, type LanguagePreferenceProps, NOTIFICATION_EVENTS, NextActionBar, type NextActionBarClassNames, type NextActionBarProps, NotificationPreferences, type NotificationPreferencesClassNames, type NotificationPreferencesProps, OrderCard, type OrderCardClassNames, type OrderCardProps, OrderLines, type OrderLinesClassNames, type OrderLinesProps, OrderList, type OrderListClassNames, type OrderListProps, OrderProductsStack, OrderProgress, type OrderProgressClassNames, type OrderProgressProps, OrderStatusBadge, type OrderStatusBadgeProps, type OrderTone, type PaymentLabelOptions, type PaymentMethodKey, PaymentSummary, type PaymentSummaryProps, PendingPaymentCard, type PendingPaymentCardClassNames, type PendingPaymentCardProps, PendingPaymentList, type PendingPaymentListProps, PostPurchaseAccountPrompt, type PostPurchaseAccountPromptClassNames, type PostPurchaseAccountPromptMessages, type PostPurchaseAccountPromptProps, RefundList, type RefundListClassNames, type RefundListProps, SessionsList, type SessionsListClassNames, type SessionsListProps, type SettingsMessageKey, type SettingsMessages, type SettingsTextProps, ShipmentCard, type ShipmentCardClassNames, type ShipmentCardProps, type ShipmentMapSlotProps, type UseConnectionResult, type UseCustomerOrderOptions, type UseCustomerOrderResult, type UseCustomerOrdersOptions, type UsePendingPaymentsOptions, type VoucherView, accountAuthMessages, accountMessages, barcodeGeometry, barcodeValue, code128Modules, enumText, lineImage, paymentLabel, paymentMethodKey, postPurchaseAccountPromptMessages, settingsEnumText, settingsMessages, stageTone, useCustomerOrder, useCustomerOrders, usePendingPayments, voucherOf };
821
+ export { AccountAuth, type AccountAuthClassNames, type AccountAuthMessages, type AccountAuthProps, type AccountAuthView, type AccountFormProps, type AccountMessageKey, type AccountMessages, AccountSettingsActionData, type AccountStatus, type AccountTextProps, AuthActionData, AuthErrorCode, AuthStep, Barcode, type BarcodeFormat, type BarcodeGeometry, type BarcodeProps, InvoiceList, type InvoiceListClassNames, type InvoiceListProps, LanguagePreference, type LanguagePreferenceClassNames, type LanguagePreferenceProps, NOTIFICATION_EVENTS, NextActionBar, type NextActionBarClassNames, type NextActionBarProps, NotificationPreferences, type NotificationPreferencesClassNames, type NotificationPreferencesProps, OrderCard, type OrderCardClassNames, type OrderCardProps, OrderLines, type OrderLinesClassNames, type OrderLinesProps, OrderList, type OrderListClassNames, type OrderListProps, OrderProductsStack, OrderProgress, type OrderProgressClassNames, type OrderProgressProps, OrderStatusBadge, type OrderStatusBadgeProps, type OrderTone, type PaymentLabelOptions, type PaymentMethodKey, PaymentSummary, type PaymentSummaryProps, PendingPaymentCard, type PendingPaymentCardClassNames, type PendingPaymentCardProps, PendingPaymentList, type PendingPaymentListProps, PostPurchaseAccountPrompt, type PostPurchaseAccountPromptClassNames, type PostPurchaseAccountPromptMessages, type PostPurchaseAccountPromptProps, RefundList, type RefundListClassNames, type RefundListProps, SessionsList, type SessionsListClassNames, type SessionsListProps, type SettingsMessageKey, type SettingsMessages, type SettingsTextProps, ShipmentCard, type ShipmentCardClassNames, type ShipmentCardProps, type ShipmentMapSlotProps, type UseConnectionResult, type UseCustomerOrderOptions, type UseCustomerOrderResult, type UseCustomerOrdersOptions, type UsePendingPaymentsOptions, type VoucherKind, type VoucherView, accountAuthMessages, accountMessages, barcodeGeometry, barcodeModules, barcodeValue, code128Modules, code39Modules, enumText, lineImage, paymentLabel, paymentMethodKey, postPurchaseAccountPromptMessages, settingsEnumText, settingsMessages, stageTone, useCustomerOrder, useCustomerOrders, usePendingPayments, voucherOf };
package/dist/account.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { fill } from './chunk-5XYQLOE3.js';
2
- import { barcodeGeometry, voucherOf, barcodeValue } from './chunk-TXEYBDFG.js';
3
- export { barcodeGeometry, barcodeValue, code128Modules, voucherOf } from './chunk-TXEYBDFG.js';
2
+ import { barcodeGeometry, voucherOf } from './chunk-BXKV2KWZ.js';
3
+ export { barcodeGeometry, barcodeModules, barcodeValue, code128Modules, code39Modules, voucherOf } from './chunk-BXKV2KWZ.js';
4
4
  import { useFieldErrors, CheckoutField, ErrorSummary } from './chunk-DFGLCIEG.js';
5
5
  import { ProductPreview, ProductThumbStack } from './chunk-VHEY5AU3.js';
6
6
  export { ProductPreview, ProductThumb, ProductThumbStack, productInitials } from './chunk-VHEY5AU3.js';
@@ -458,6 +458,8 @@ var ES3 = {
458
458
  "pending.expired": "Vencida",
459
459
  "pending.reference": "Referencia",
460
460
  "pending.clabe": "CLABE",
461
+ "pending.beneficiary": "Beneficiario",
462
+ "pending.bank": "Banco",
461
463
  "pending.expires": "Vence el {date}",
462
464
  "pending.expiredOn": "Venci\xF3 el {date}",
463
465
  "pending.total": "Total",
@@ -466,9 +468,11 @@ var ES3 = {
466
468
  "pending.copied": "Copiada",
467
469
  "pending.copyFailed": "No pudimos copiar; selecciona el texto.",
468
470
  "pending.print": "Ver e imprimir ficha",
469
- "pending.download": "Descargar ficha",
471
+ "pending.download": "Descargar PDF",
470
472
  "pending.expiredNote": "Esta ficha ya no es v\xE1lida. Haz tu pedido de nuevo.",
471
473
  "pending.barcode": "C\xF3digo de barras {code}",
474
+ "pending.code": "C\xF3digo",
475
+ "pending.ticket": "Ver comprobante del proveedor",
472
476
  "pending.method.oxxo": "OXXO",
473
477
  "pending.method.spei": "Transferencia SPEI",
474
478
  "pending.method.bank_transfer": "Transferencia bancaria",
@@ -631,6 +635,8 @@ var EN3 = {
631
635
  "pending.expired": "Expired",
632
636
  "pending.reference": "Reference",
633
637
  "pending.clabe": "CLABE",
638
+ "pending.beneficiary": "Beneficiary",
639
+ "pending.bank": "Bank",
634
640
  "pending.expires": "Expires on {date}",
635
641
  "pending.expiredOn": "Expired on {date}",
636
642
  "pending.total": "Total",
@@ -639,9 +645,11 @@ var EN3 = {
639
645
  "pending.copied": "Copied",
640
646
  "pending.copyFailed": "We could not copy; select the text.",
641
647
  "pending.print": "View and print voucher",
642
- "pending.download": "Download voucher",
648
+ "pending.download": "Download PDF",
643
649
  "pending.expiredNote": "This voucher is no longer valid. Place your order again.",
644
650
  "pending.barcode": "Barcode {code}",
651
+ "pending.code": "Code",
652
+ "pending.ticket": "View provider receipt",
645
653
  "pending.method.oxxo": "OXXO",
646
654
  "pending.method.spei": "SPEI transfer",
647
655
  "pending.method.bank_transfer": "Bank transfer",
@@ -1162,15 +1170,27 @@ function InvoiceList({ invoices, summary, renderSummary, fileHref, onDownload, d
1162
1170
  children
1163
1171
  ] });
1164
1172
  }
1165
- function Barcode({ value, label, height = 56, className }) {
1166
- const g = useMemo(() => barcodeGeometry(value, { height }), [value, height]);
1173
+ function Barcode({ value, label, height = 56, className, format }) {
1174
+ const g = useMemo(() => barcodeGeometry(value, { height, ...format ? { format } : {} }), [value, height, format]);
1167
1175
  if (!g) return null;
1168
1176
  return /* @__PURE__ */ jsx("svg", { className, viewBox: `0 0 ${g.width} ${g.height}`, width: g.width, height: g.height, role: "img", "aria-label": label, shapeRendering: "crispEdges", fill: "#000", "data-sf-voucher-barcode-svg": true, children: g.rects.map((r) => /* @__PURE__ */ jsx("rect", { x: r.x, y: 0, width: r.w, height: g.height }, r.x)) });
1169
1177
  }
1178
+ async function downloadPdf(payment, opts) {
1179
+ const v = voucherOf(payment);
1180
+ if (!v) return;
1181
+ const { renderVoucherPdf } = await import('./voucher-pdf-LQC333AB.js');
1182
+ const bytes = renderVoucherPdf(v, { locale: opts.locale, ...opts.shopName ? { shopName: opts.shopName } : {}, ...opts.timeZone ? { timeZone: opts.timeZone } : {} });
1183
+ const url = URL.createObjectURL(new Blob([bytes], { type: "application/pdf" }));
1184
+ const a = document.createElement("a");
1185
+ a.href = url;
1186
+ a.download = "ficha-de-pago.pdf";
1187
+ a.click();
1188
+ setTimeout(() => URL.revokeObjectURL(url), 6e4);
1189
+ }
1170
1190
  async function openDocument(payment, mode, opts) {
1171
1191
  const v = voucherOf(payment);
1172
1192
  if (!v) return;
1173
- const { renderVoucherDocument } = await import('./voucher-document-SFWJCLTN.js');
1193
+ const { renderVoucherDocument } = await import('./voucher-document-FWH4DQ5N.js');
1174
1194
  const html = renderVoucherDocument(v, { locale: opts.locale, ...opts.shopName ? { shopName: opts.shopName } : {}, ...opts.timeZone ? { timeZone: opts.timeZone } : {}, printButton: mode === "print", autoPrint: mode === "print" });
1175
1195
  const url = URL.createObjectURL(new Blob([html], { type: "text/html;charset=utf-8" }));
1176
1196
  const download = () => {
@@ -1179,11 +1199,11 @@ async function openDocument(payment, mode, opts) {
1179
1199
  a.download = "ficha-de-pago.html";
1180
1200
  a.click();
1181
1201
  };
1182
- if (mode === "print") {
1202
+ {
1183
1203
  const w = window.open(url, "_blank");
1184
1204
  if (w) w.opener = null;
1185
1205
  else download();
1186
- } else download();
1206
+ }
1187
1207
  setTimeout(() => URL.revokeObjectURL(url), 6e4);
1188
1208
  }
1189
1209
  function PendingPaymentCard({ payment, voucherHref, shopName, headingLevel = 3, classNames: cx = {}, children, ...text }) {
@@ -1193,7 +1213,7 @@ function PendingPaymentCard({ payment, voucherHref, shopName, headingLevel = 3,
1193
1213
  if (!v) return null;
1194
1214
  const expired = payment.status === "expired";
1195
1215
  const Heading = `h${headingLevel}`;
1196
- const code = barcodeValue(v);
1216
+ const code = v.barcode;
1197
1217
  const methodLabel = enumText(m, "pending.method", v.method?.toLowerCase());
1198
1218
  const total = moneyText(payment.total, locale) ?? moneyText(v.amount, locale);
1199
1219
  const copyValue = v.reference ?? v.clabe;
@@ -1207,11 +1227,23 @@ function PendingPaymentCard({ payment, voucherHref, shopName, headingLevel = 3,
1207
1227
  /* @__PURE__ */ jsx("p", { className: cx.label, children: m["pending.reference"] }),
1208
1228
  /* @__PURE__ */ jsx("p", { className: cx.value, "data-sf-voucher-value": true, children: v.reference })
1209
1229
  ] }) : null,
1230
+ v.beneficiary ? /* @__PURE__ */ jsxs("div", { className: cx.field, "data-sf-voucher-beneficiary": true, children: [
1231
+ /* @__PURE__ */ jsx("p", { className: cx.label, children: m["pending.beneficiary"] }),
1232
+ /* @__PURE__ */ jsx("p", { className: cx.value, "data-sf-voucher-value": true, children: v.beneficiary })
1233
+ ] }) : null,
1234
+ v.bank ? /* @__PURE__ */ jsxs("div", { className: cx.field, "data-sf-voucher-bank": true, children: [
1235
+ /* @__PURE__ */ jsx("p", { className: cx.label, children: m["pending.bank"] }),
1236
+ /* @__PURE__ */ jsx("p", { className: cx.value, "data-sf-voucher-value": true, children: v.bank })
1237
+ ] }) : null,
1210
1238
  v.clabe ? /* @__PURE__ */ jsxs("div", { className: cx.field, "data-sf-voucher-clabe": true, children: [
1211
1239
  /* @__PURE__ */ jsx("p", { className: cx.label, children: m["pending.clabe"] }),
1212
1240
  /* @__PURE__ */ jsx("p", { className: cx.value, "data-sf-voucher-value": true, children: v.clabe })
1213
1241
  ] }) : null,
1214
- code && !expired ? /* @__PURE__ */ jsx("div", { className: cx.barcode, "data-sf-voucher-barcode": true, children: /* @__PURE__ */ jsx(Barcode, { value: code, label: fill(m["pending.barcode"], { code }) }) }) : null,
1242
+ v.barcode_text && !expired ? /* @__PURE__ */ jsxs("div", { className: cx.field, "data-sf-voucher-code": true, children: [
1243
+ /* @__PURE__ */ jsx("p", { className: cx.label, children: m["pending.code"] }),
1244
+ /* @__PURE__ */ jsx("p", { className: cx.value, "data-sf-voucher-value": true, children: v.barcode_text })
1245
+ ] }) : null,
1246
+ code && !expired ? /* @__PURE__ */ jsx("div", { className: cx.barcode, "data-sf-voucher-barcode": true, children: /* @__PURE__ */ jsx(Barcode, { value: code, format: v.barcode_format ?? "code128", label: fill(m["pending.barcode"], { code }) }) }) : null,
1215
1247
  expires ? /* @__PURE__ */ jsx("p", { className: cx.expiry, "data-sf-voucher-expiry": true, children: /* @__PURE__ */ jsx(Time, { value: v.expires_at ?? payment.expires_at, text: fill(m[expired ? "pending.expiredOn" : "pending.expires"], { date: expires }) }) }) : null,
1216
1248
  total ? /* @__PURE__ */ jsxs("p", { className: cx.total, "data-sf-voucher-total": true, children: [
1217
1249
  /* @__PURE__ */ jsxs("span", { children: [
@@ -1222,18 +1254,25 @@ function PendingPaymentCard({ payment, voucherHref, shopName, headingLevel = 3,
1222
1254
  ] }) : null,
1223
1255
  expired ? /* @__PURE__ */ jsx("p", { className: cx.note, "data-sf-voucher-expired-note": true, children: m["pending.expiredNote"] }) : /* @__PURE__ */ jsxs("div", { className: cx.actions, "data-sf-voucher-actions": true, children: [
1224
1256
  voucherHref ? /* @__PURE__ */ jsxs(Fragment, { children: [
1225
- /* @__PURE__ */ jsxs("a", { href: voucherHref(payment, { download: false }), target: "_blank", rel: "noopener", className: cx.primary, "data-sf-voucher-print": true, children: [
1257
+ /* @__PURE__ */ jsxs("a", { href: voucherHref(payment, { download: false, format: "html" }), target: "_blank", rel: "noopener", className: cx.primary, "data-sf-voucher-print": true, children: [
1226
1258
  m["pending.print"],
1227
1259
  /* @__PURE__ */ jsxs(Hidden, { children: [
1228
1260
  " ",
1229
1261
  m["action.newTab"]
1230
1262
  ] })
1231
1263
  ] }),
1232
- /* @__PURE__ */ jsx("a", { href: voucherHref(payment, { download: true }), download: true, className: cx.secondary, "data-sf-voucher-download": true, children: m["pending.download"] })
1264
+ /* @__PURE__ */ jsx("a", { href: voucherHref(payment, { download: true, format: "pdf" }), download: true, className: cx.secondary, "data-sf-voucher-download": true, children: m["pending.download"] })
1233
1265
  ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1234
1266
  /* @__PURE__ */ jsx("button", { type: "button", className: cx.primary, onClick: () => void openDocument(payment, "print", { locale, shopName, timeZone }), "data-sf-voucher-print": true, children: m["pending.print"] }),
1235
- /* @__PURE__ */ jsx("button", { type: "button", className: cx.secondary, onClick: () => void openDocument(payment, "download", { locale, shopName, timeZone }), "data-sf-voucher-download": true, children: m["pending.download"] })
1267
+ /* @__PURE__ */ jsx("button", { type: "button", className: cx.secondary, onClick: () => void downloadPdf(payment, { locale, shopName, timeZone }), "data-sf-voucher-download": true, children: m["pending.download"] })
1236
1268
  ] }),
1269
+ v.ticket_url ? /* @__PURE__ */ jsxs("a", { href: v.ticket_url, target: "_blank", rel: "noopener noreferrer", className: cx.secondary, "data-sf-voucher-ticket": true, children: [
1270
+ m["pending.ticket"],
1271
+ /* @__PURE__ */ jsxs(Hidden, { children: [
1272
+ " ",
1273
+ m["action.newTab"]
1274
+ ] })
1275
+ ] }) : null,
1237
1276
  copyValue ? /* @__PURE__ */ jsx(CopyButton, { value: copyValue, label: v.reference ? m["pending.copyReference"] : m["pending.copyClabe"], copiedLabel: m["pending.copied"], failedLabel: m["pending.copyFailed"], className: cx.secondary, "data-sf-copy": "voucher" }) : null
1238
1277
  ] }),
1239
1278
  children