@aglyn/plugins-commerce 1.0.0-beta.230 → 1.0.0-beta.232
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/package.json +13 -13
- package/src/index.d.ts +0 -1
- package/src/index.js +0 -1
- package/src/index.js.map +1 -1
- package/src/lib/barcode/barcode-decode.d.ts +71 -0
- package/src/lib/barcode/barcode-decode.js +498 -0
- package/src/lib/barcode/barcode-decode.js.map +1 -0
- package/src/lib/barcode/barcode-encode.d.ts +44 -0
- package/src/lib/barcode/barcode-encode.js +138 -0
- package/src/lib/barcode/barcode-encode.js.map +1 -0
- package/src/lib/barcode/barcode-scanner.component.d.ts +23 -0
- package/src/lib/barcode/barcode-scanner.component.js +260 -0
- package/src/lib/barcode/barcode-scanner.component.js.map +1 -0
- package/src/lib/barcode/scan-button.component.d.ts +10 -0
- package/src/lib/barcode/scan-button.component.js +62 -0
- package/src/lib/barcode/scan-button.component.js.map +1 -0
- package/src/lib/barcode/scanner-wedge.d.ts +35 -0
- package/src/lib/barcode/scanner-wedge.js +108 -0
- package/src/lib/barcode/scanner-wedge.js.map +1 -0
- package/src/lib/components/account.js +10 -1
- package/src/lib/components/account.js.map +1 -1
- package/src/lib/components/cart-extras.d.ts +45 -0
- package/src/lib/components/cart-extras.js +127 -0
- package/src/lib/components/cart-extras.js.map +1 -0
- package/src/lib/components/cart.js +82 -15
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/checkout-return-notice.d.ts +26 -0
- package/src/lib/components/checkout-return-notice.js +48 -0
- package/src/lib/components/checkout-return-notice.js.map +1 -0
- package/src/lib/components/commerce-console-page.js +124 -0
- package/src/lib/components/commerce-console-page.js.map +1 -1
- package/src/lib/components/commerce-console-sections.d.ts +1 -1
- package/src/lib/components/commerce-console-sections.js +4 -0
- package/src/lib/components/commerce-console-sections.js.map +1 -1
- package/src/lib/components/console/bulk-fulfill.d.ts +44 -0
- package/src/lib/components/console/bulk-fulfill.js +84 -0
- package/src/lib/components/console/bulk-fulfill.js.map +1 -0
- package/src/lib/components/console/catalog-organization-card.component.js +1 -0
- package/src/lib/components/console/catalog-organization-card.component.js.map +1 -1
- package/src/lib/components/console/customer-notifications-card.component.d.ts +19 -0
- package/src/lib/components/console/customer-notifications-card.component.js +149 -0
- package/src/lib/components/console/customer-notifications-card.component.js.map +1 -0
- package/src/lib/components/console/host-orders-card.component.js +88 -6
- package/src/lib/components/console/host-orders-card.component.js.map +1 -1
- package/src/lib/components/console/locations-card.component.js +164 -57
- package/src/lib/components/console/locations-card.component.js.map +1 -1
- package/src/lib/components/console/order-detail-dialog.component.js +209 -61
- package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
- package/src/lib/components/console/order-fulfillment-panel.component.d.ts +48 -0
- package/src/lib/components/console/order-fulfillment-panel.component.js +542 -0
- package/src/lib/components/console/order-fulfillment-panel.component.js.map +1 -0
- package/src/lib/components/console/order-invoice.component.d.ts +33 -0
- package/src/lib/components/console/order-invoice.component.js +81 -0
- package/src/lib/components/console/order-invoice.component.js.map +1 -0
- package/src/lib/components/console/order-receipt-resend.component.d.ts +21 -0
- package/src/lib/components/console/order-receipt-resend.component.js +203 -0
- package/src/lib/components/console/order-receipt-resend.component.js.map +1 -0
- package/src/lib/components/console/order-returns.component.d.ts +36 -0
- package/src/lib/components/console/order-returns.component.js +142 -0
- package/src/lib/components/console/order-returns.component.js.map +1 -0
- package/src/lib/components/console/order-shipping-actions.component.d.ts +54 -0
- package/src/lib/components/console/order-shipping-actions.component.js +149 -0
- package/src/lib/components/console/order-shipping-actions.component.js.map +1 -0
- package/src/lib/components/console/order-webhooks-card.component.d.ts +50 -0
- package/src/lib/components/console/order-webhooks-card.component.js +623 -0
- package/src/lib/components/console/order-webhooks-card.component.js.map +1 -0
- package/src/lib/components/console/order-zones.d.ts +155 -0
- package/src/lib/components/console/order-zones.js +40 -0
- package/src/lib/components/console/order-zones.js.map +1 -0
- package/src/lib/components/console/payment-methods-card.component.d.ts +67 -0
- package/src/lib/components/console/payment-methods-card.component.js +395 -0
- package/src/lib/components/console/payment-methods-card.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-api.d.ts +124 -0
- package/src/lib/components/console/pos/pos-api.js +101 -0
- package/src/lib/components/console/pos/pos-api.js.map +1 -0
- package/src/lib/components/console/pos/pos-cart-panel.component.d.ts +36 -0
- package/src/lib/components/console/pos/pos-cart-panel.component.js +160 -0
- package/src/lib/components/console/pos/pos-cart-panel.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-item-dialog.component.d.ts +39 -0
- package/src/lib/components/console/pos/pos-item-dialog.component.js +352 -0
- package/src/lib/components/console/pos/pos-item-dialog.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-product-grid.component.d.ts +47 -0
- package/src/lib/components/console/pos/pos-product-grid.component.js +272 -0
- package/src/lib/components/console/pos/pos-product-grid.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-receipt-panel.component.d.ts +27 -0
- package/src/lib/components/console/pos/pos-receipt-panel.component.js +282 -0
- package/src/lib/components/console/pos/pos-receipt-panel.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.d.ts +53 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js +445 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js.map +1 -0
- package/src/lib/components/console/pos/pos-tender-panel.component.d.ts +31 -0
- package/src/lib/components/console/pos/pos-tender-panel.component.js +640 -0
- package/src/lib/components/console/pos/pos-tender-panel.component.js.map +1 -0
- package/src/lib/components/console/pos/use-pos-display.d.ts +43 -0
- package/src/lib/components/console/pos/use-pos-display.js +161 -0
- package/src/lib/components/console/pos/use-pos-display.js.map +1 -0
- package/src/lib/components/console/pos-devices-card.component.d.ts +14 -0
- package/src/lib/components/console/pos-devices-card.component.js +546 -0
- package/src/lib/components/console/pos-devices-card.component.js.map +1 -0
- package/src/lib/components/console/pos-display/brand-screen.d.ts +33 -0
- package/src/lib/components/console/pos-display/brand-screen.js +85 -0
- package/src/lib/components/console/pos-display/brand-screen.js.map +1 -0
- package/src/lib/components/console/pos-display/cart-screen.d.ts +29 -0
- package/src/lib/components/console/pos-display/cart-screen.js +166 -0
- package/src/lib/components/console/pos-display/cart-screen.js.map +1 -0
- package/src/lib/components/console/pos-display/pairing-screen.d.ts +24 -0
- package/src/lib/components/console/pos-display/pairing-screen.js +127 -0
- package/src/lib/components/console/pos-display/pairing-screen.js.map +1 -0
- package/src/lib/components/console/pos-display/pos-display-api.d.ts +90 -0
- package/src/lib/components/console/pos-display/pos-display-api.js +140 -0
- package/src/lib/components/console/pos-display/pos-display-api.js.map +1 -0
- package/src/lib/components/console/pos-display/receipt-screen.d.ts +35 -0
- package/src/lib/components/console/pos-display/receipt-screen.js +200 -0
- package/src/lib/components/console/pos-display/receipt-screen.js.map +1 -0
- package/src/lib/components/console/pos-display/tip-screen.d.ts +36 -0
- package/src/lib/components/console/pos-display/tip-screen.js +211 -0
- package/src/lib/components/console/pos-display/tip-screen.js.map +1 -0
- package/src/lib/components/console/pos-display-page.component.d.ts +16 -0
- package/src/lib/components/console/pos-display-page.component.js +407 -0
- package/src/lib/components/console/pos-display-page.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-customer-lookup.component.d.ts +40 -0
- package/src/lib/components/console/pos-ops/pos-customer-lookup.component.js +289 -0
- package/src/lib/components/console/pos-ops/pos-customer-lookup.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-last-receipt.component.d.ts +34 -0
- package/src/lib/components/console/pos-ops/pos-last-receipt.component.js +61 -0
- package/src/lib/components/console/pos-ops/pos-last-receipt.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.d.ts +38 -0
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.js +129 -0
- package/src/lib/components/console/pos-ops/pos-operations-bar.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-ops-api.d.ts +37 -0
- package/src/lib/components/console/pos-ops/pos-ops-api.js +60 -0
- package/src/lib/components/console/pos-ops/pos-ops-api.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-pin-pad.component.d.ts +48 -0
- package/src/lib/components/console/pos-ops/pos-pin-pad.component.js +220 -0
- package/src/lib/components/console/pos-ops/pos-pin-pad.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-receipt-actions.component.d.ts +63 -0
- package/src/lib/components/console/pos-ops/pos-receipt-actions.component.js +186 -0
- package/src/lib/components/console/pos-ops/pos-receipt-actions.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-receipt.d.ts +39 -0
- package/src/lib/components/console/pos-ops/pos-receipt.js +182 -0
- package/src/lib/components/console/pos-ops/pos-receipt.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-return-dialog.component.d.ts +40 -0
- package/src/lib/components/console/pos-ops/pos-return-dialog.component.js +465 -0
- package/src/lib/components/console/pos-ops/pos-return-dialog.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-shift-history-card.component.d.ts +29 -0
- package/src/lib/components/console/pos-ops/pos-shift-history-card.component.js +253 -0
- package/src/lib/components/console/pos-ops/pos-shift-history-card.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.d.ts +34 -0
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.js +494 -0
- package/src/lib/components/console/pos-ops/pos-shift-panel.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-shift-report.component.d.ts +37 -0
- package/src/lib/components/console/pos-ops/pos-shift-report.component.js +102 -0
- package/src/lib/components/console/pos-ops/pos-shift-report.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.d.ts +30 -0
- package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.js +277 -0
- package/src/lib/components/console/pos-ops/pos-staff-pins-card.component.js.map +1 -0
- package/src/lib/components/console/pos-ops/register-ops.d.ts +28 -0
- package/src/lib/components/console/pos-ops/register-ops.js +28 -0
- package/src/lib/components/console/pos-ops/register-ops.js.map +1 -0
- package/src/lib/components/console/pos-ops/use-pos-cashier.d.ts +46 -0
- package/src/lib/components/console/pos-ops/use-pos-cashier.js +128 -0
- package/src/lib/components/console/pos-ops/use-pos-cashier.js.map +1 -0
- package/src/lib/components/console/pos-ops/use-pos-sale-receipt.d.ts +36 -0
- package/src/lib/components/console/pos-ops/use-pos-sale-receipt.js +64 -0
- package/src/lib/components/console/pos-ops/use-pos-sale-receipt.js.map +1 -0
- package/src/lib/components/console/pos-page.component.d.ts +13 -5
- package/src/lib/components/console/pos-page.component.js +756 -654
- package/src/lib/components/console/pos-page.component.js.map +1 -1
- package/src/lib/components/console/pos-zones.d.ts +23 -0
- package/src/lib/components/console/pos-zones.js +31 -0
- package/src/lib/components/console/pos-zones.js.map +1 -0
- package/src/lib/components/console/product-editor-dialog.component.js +61 -71
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/product-labels-dialog.component.d.ts +13 -0
- package/src/lib/components/console/product-labels-dialog.component.js +197 -0
- package/src/lib/components/console/product-labels-dialog.component.js.map +1 -0
- package/src/lib/components/console/product-register-fields.component.d.ts +19 -0
- package/src/lib/components/console/product-register-fields.component.js +241 -0
- package/src/lib/components/console/product-register-fields.component.js.map +1 -0
- package/src/lib/components/console/product-zones.d.ts +44 -0
- package/src/lib/components/console/product-zones.js.map +1 -1
- package/src/lib/components/console/products-hub-card.component.js +23 -20
- package/src/lib/components/console/products-hub-card.component.js.map +1 -1
- package/src/lib/components/console/register-hardware-card.component.d.ts +33 -0
- package/src/lib/components/console/register-hardware-card.component.js +826 -0
- package/src/lib/components/console/register-hardware-card.component.js.map +1 -0
- package/src/lib/components/console/registers-card.component.js +24 -5
- package/src/lib/components/console/registers-card.component.js.map +1 -1
- package/src/lib/components/console/return-actions.d.ts +38 -0
- package/src/lib/components/console/return-actions.js +76 -0
- package/src/lib/components/console/return-actions.js.map +1 -0
- package/src/lib/components/console/return-detail-dialog.component.d.ts +34 -0
- package/src/lib/components/console/return-detail-dialog.component.js +718 -0
- package/src/lib/components/console/return-detail-dialog.component.js.map +1 -0
- package/src/lib/components/console/return-settings-card.component.d.ts +34 -0
- package/src/lib/components/console/return-settings-card.component.js +195 -0
- package/src/lib/components/console/return-settings-card.component.js.map +1 -0
- package/src/lib/components/console/return-zones.d.ts +87 -0
- package/src/lib/components/console/return-zones.js +31 -0
- package/src/lib/components/console/return-zones.js.map +1 -0
- package/src/lib/components/console/returns-card.component.d.ts +45 -0
- package/src/lib/components/console/returns-card.component.js +159 -0
- package/src/lib/components/console/returns-card.component.js.map +1 -0
- package/src/lib/components/console/shipping-settings-card.component.js +161 -5
- package/src/lib/components/console/shipping-settings-card.component.js.map +1 -1
- package/src/lib/components/console/shippingeasy-card.component.d.ts +59 -0
- package/src/lib/components/console/shippingeasy-card.component.js +378 -0
- package/src/lib/components/console/shippingeasy-card.component.js.map +1 -0
- package/src/lib/components/console/shipstation-card.component.d.ts +35 -0
- package/src/lib/components/console/shipstation-card.component.js +345 -0
- package/src/lib/components/console/shipstation-card.component.js.map +1 -0
- package/src/lib/components/console/start-return-dialog.component.d.ts +40 -0
- package/src/lib/components/console/start-return-dialog.component.js +243 -0
- package/src/lib/components/console/start-return-dialog.component.js.map +1 -0
- package/src/lib/components/console/stock-movements-card.component.js +2 -1
- package/src/lib/components/console/stock-movements-card.component.js.map +1 -1
- package/src/lib/components/console/store-settings-card.component.js +2 -66
- package/src/lib/components/console/store-settings-card.component.js.map +1 -1
- package/src/lib/components/console/store-zones.d.ts +42 -0
- package/src/lib/components/console/store-zones.js +39 -0
- package/src/lib/components/console/store-zones.js.map +1 -0
- package/src/lib/components/console/storefront-tax-summary-card.component.js +1 -0
- package/src/lib/components/console/storefront-tax-summary-card.component.js.map +1 -1
- package/src/lib/components/order-status.d.ts +36 -0
- package/src/lib/components/order-status.js +502 -0
- package/src/lib/components/order-status.js.map +1 -0
- package/src/lib/components/product-detail.js +41 -2
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/return-request.d.ts +32 -0
- package/src/lib/components/return-request.js +576 -0
- package/src/lib/components/return-request.js.map +1 -0
- package/src/lib/components/storefront-payment-appearance.d.ts +32 -0
- package/src/lib/components/storefront-payment-appearance.js +114 -0
- package/src/lib/components/storefront-payment-appearance.js.map +1 -0
- package/src/lib/components/storefront-payment-element.d.ts +57 -1
- package/src/lib/components/storefront-payment-element.js +332 -33
- package/src/lib/components/storefront-payment-element.js.map +1 -1
- package/src/lib/constants/order-status.d.ts +22 -0
- package/src/lib/constants/order-status.js +22 -0
- package/src/lib/constants/order-status.js.map +1 -0
- package/src/lib/constants/return-request.d.ts +27 -0
- package/src/lib/constants/return-request.js +32 -0
- package/src/lib/constants/return-request.js.map +1 -0
- package/src/lib/constants/stock-movement-query.js +2 -1
- package/src/lib/constants/stock-movement-query.js.map +1 -1
- package/src/lib/declarations.console-server.js +9 -0
- package/src/lib/declarations.console-server.js.map +1 -1
- package/src/lib/declarations.server.d.ts +2 -1
- package/src/lib/declarations.server.js +68 -1
- package/src/lib/declarations.server.js.map +1 -1
- package/src/lib/model/buyer-notifications.d.ts +59 -0
- package/src/lib/model/buyer-notifications.js +97 -0
- package/src/lib/model/buyer-notifications.js.map +1 -0
- package/src/lib/model/commerce-orders.d.ts +171 -2
- package/src/lib/model/commerce-orders.js +26 -16
- package/src/lib/model/commerce-orders.js.map +1 -1
- package/src/lib/model/commerce-payment-methods.d.ts +146 -0
- package/src/lib/model/commerce-payment-methods.js +247 -0
- package/src/lib/model/commerce-payment-methods.js.map +1 -0
- package/src/lib/model/commerce-pos-ops.d.ts +437 -0
- package/src/lib/model/commerce-pos-ops.js +721 -0
- package/src/lib/model/commerce-pos-ops.js.map +1 -0
- package/src/lib/model/commerce-pos.d.ts +263 -0
- package/src/lib/model/commerce-pos.js +375 -0
- package/src/lib/model/commerce-pos.js.map +1 -0
- package/src/lib/model/commerce-printers.d.ts +211 -0
- package/src/lib/model/commerce-printers.js +181 -0
- package/src/lib/model/commerce-printers.js.map +1 -0
- package/src/lib/model/commerce-receipt.d.ts +97 -0
- package/src/lib/model/commerce-receipt.js +180 -0
- package/src/lib/model/commerce-receipt.js.map +1 -0
- package/src/lib/model/commerce-returns.d.ts +207 -0
- package/src/lib/model/commerce-returns.js +300 -0
- package/src/lib/model/commerce-returns.js.map +1 -0
- package/src/lib/model/commerce-shipping.d.ts +44 -1
- package/src/lib/model/commerce-shipping.js +53 -9
- package/src/lib/model/commerce-shipping.js.map +1 -1
- package/src/lib/model/commerce-tax-engine.d.ts +90 -0
- package/src/lib/model/commerce-tax-engine.js +129 -0
- package/src/lib/model/commerce-tax-engine.js.map +1 -0
- package/src/lib/model/commerce.d.ts +91 -2
- package/src/lib/model/commerce.js +89 -1
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/index.d.ts +16 -0
- package/src/lib/model/index.js +16 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/order-events.d.ts +154 -0
- package/src/lib/model/order-events.js +153 -0
- package/src/lib/model/order-events.js.map +1 -0
- package/src/lib/model/order-fulfillment.d.ts +117 -0
- package/src/lib/model/order-fulfillment.js +217 -0
- package/src/lib/model/order-fulfillment.js.map +1 -0
- package/src/lib/model/order-history.d.ts +58 -0
- package/src/lib/model/order-history.js +22 -0
- package/src/lib/model/order-history.js.map +1 -0
- package/src/lib/model/order-list-fields.d.ts +9 -1
- package/src/lib/model/order-list-fields.js +7 -1
- package/src/lib/model/order-list-fields.js.map +1 -1
- package/src/lib/model/order-shipping-export.d.ts +91 -0
- package/src/lib/model/order-shipping-export.js +192 -0
- package/src/lib/model/order-shipping-export.js.map +1 -0
- package/src/lib/model/order-status-view.d.ts +103 -0
- package/src/lib/model/order-status-view.js +156 -0
- package/src/lib/model/order-status-view.js.map +1 -0
- package/src/lib/model/order-webhooks.d.ts +142 -0
- package/src/lib/model/order-webhooks.js +91 -0
- package/src/lib/model/order-webhooks.js.map +1 -0
- package/src/lib/model/product-channel.d.ts +56 -0
- package/src/lib/model/product-channel.js +86 -0
- package/src/lib/model/product-channel.js.map +1 -0
- package/src/lib/model/product-modifiers.d.ts +80 -0
- package/src/lib/model/product-modifiers.js +140 -0
- package/src/lib/model/product-modifiers.js.map +1 -0
- package/src/lib/model/product-write.d.ts +186 -0
- package/src/lib/model/product-write.js +116 -0
- package/src/lib/model/product-write.js.map +1 -0
- package/src/lib/model/shippingeasy.d.ts +94 -0
- package/src/lib/model/shippingeasy.js +267 -0
- package/src/lib/model/shippingeasy.js.map +1 -0
- package/src/lib/model/shipstation.d.ts +125 -0
- package/src/lib/model/shipstation.js +399 -0
- package/src/lib/model/shipstation.js.map +1 -0
- package/src/lib/model/smart-collection-reads.d.ts +32 -0
- package/src/lib/model/smart-collection-reads.js +63 -0
- package/src/lib/model/smart-collection-reads.js.map +1 -0
- package/src/lib/model/tracking-url.d.ts +74 -0
- package/src/lib/model/tracking-url.js +159 -0
- package/src/lib/model/tracking-url.js.map +1 -0
- package/src/lib/plugin-config.d.ts +13 -0
- package/src/lib/plugin-config.js +77 -5
- package/src/lib/plugin-config.js.map +1 -1
- package/src/lib/plugin.js +26 -0
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/pos-ops-config.d.ts +39 -0
- package/src/lib/pos-ops-config.js +88 -0
- package/src/lib/pos-ops-config.js.map +1 -0
- package/src/lib/printing/print-document.d.ts +106 -0
- package/src/lib/printing/print-document.js +464 -0
- package/src/lib/printing/print-document.js.map +1 -0
- package/src/lib/printing/product-labels.d.ts +58 -0
- package/src/lib/printing/product-labels.js +116 -0
- package/src/lib/printing/product-labels.js.map +1 -0
- package/src/lib/printing/render-epson.d.ts +57 -0
- package/src/lib/printing/render-epson.js +135 -0
- package/src/lib/printing/render-epson.js.map +1 -0
- package/src/lib/printing/render-star.d.ts +45 -0
- package/src/lib/printing/render-star.js +100 -0
- package/src/lib/printing/render-star.js.map +1 -0
- package/src/lib/printing/render-text.d.ts +25 -0
- package/src/lib/printing/render-text.js +53 -0
- package/src/lib/printing/render-text.js.map +1 -0
- package/src/lib/server/api-v1/openapi.js +27 -4
- package/src/lib/server/api-v1/openapi.js.map +1 -1
- package/src/lib/server/api-v1/order-view.d.ts +67 -0
- package/src/lib/server/api-v1/order-view.js +120 -0
- package/src/lib/server/api-v1/order-view.js.map +1 -0
- package/src/lib/server/api-v1/orders-and-products.js +58 -65
- package/src/lib/server/api-v1/orders-and-products.js.map +1 -1
- package/src/lib/server/billing-webhook.js +135 -28
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/cancel-order.js +29 -0
- package/src/lib/server/cancel-order.js.map +1 -1
- package/src/lib/server/carrier-rates-availability.d.ts +26 -0
- package/src/lib/server/carrier-rates-availability.js +76 -0
- package/src/lib/server/carrier-rates-availability.js.map +1 -0
- package/src/lib/server/carrier-shipping.d.ts +84 -0
- package/src/lib/server/carrier-shipping.js +135 -0
- package/src/lib/server/carrier-shipping.js.map +1 -0
- package/src/lib/server/cart-checkout.d.ts +2 -0
- package/src/lib/server/cart-checkout.js +226 -22
- package/src/lib/server/cart-checkout.js.map +1 -1
- package/src/lib/server/channel-order-updates.d.ts +50 -0
- package/src/lib/server/channel-order-updates.js +290 -0
- package/src/lib/server/channel-order-updates.js.map +1 -0
- package/src/lib/server/channel-orders.d.ts +85 -0
- package/src/lib/server/channel-orders.js +543 -0
- package/src/lib/server/channel-orders.js.map +1 -0
- package/src/lib/server/checkout-extras.d.ts +64 -0
- package/src/lib/server/checkout-extras.js +157 -0
- package/src/lib/server/checkout-extras.js.map +1 -0
- package/src/lib/server/{feed.d.ts → checkout-status.d.ts} +2 -7
- package/src/lib/server/checkout-status.js +111 -0
- package/src/lib/server/checkout-status.js.map +1 -0
- package/src/lib/server/checkout.js +86 -9
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/draft-order.js +34 -5
- package/src/lib/server/draft-order.js.map +1 -1
- package/src/lib/server/fulfill-order.d.ts +127 -10
- package/src/lib/server/fulfill-order.js +451 -49
- package/src/lib/server/fulfill-order.js.map +1 -1
- package/src/lib/server/legacy-feed.d.ts +28 -0
- package/src/lib/server/legacy-feed.js +52 -0
- package/src/lib/server/legacy-feed.js.map +1 -0
- package/src/lib/server/native-checkout.d.ts +34 -15
- package/src/lib/server/native-checkout.js +32 -17
- package/src/lib/server/native-checkout.js.map +1 -1
- package/src/lib/server/order-event-host-emit.d.ts +23 -0
- package/src/lib/server/order-event-host-emit.js +30 -0
- package/src/lib/server/order-event-host-emit.js.map +1 -0
- package/src/lib/server/order-event-triggers.d.ts +37 -0
- package/src/lib/server/order-event-triggers.js +119 -0
- package/src/lib/server/order-event-triggers.js.map +1 -0
- package/src/lib/server/order-events.d.ts +62 -0
- package/src/lib/server/order-events.js +109 -0
- package/src/lib/server/order-events.js.map +1 -0
- package/src/lib/server/order-history.d.ts +23 -0
- package/src/lib/server/order-history.js +65 -0
- package/src/lib/server/order-history.js.map +1 -0
- package/src/lib/server/order-notifications.d.ts +185 -0
- package/src/lib/server/order-notifications.js +567 -0
- package/src/lib/server/order-notifications.js.map +1 -0
- package/src/lib/server/order-receipt-send.d.ts +39 -0
- package/src/lib/server/order-receipt-send.js +151 -0
- package/src/lib/server/order-receipt-send.js.map +1 -0
- package/src/lib/server/order-status-token.d.ts +31 -0
- package/src/lib/server/order-status-token.js +75 -0
- package/src/lib/server/order-status-token.js.map +1 -0
- package/src/lib/server/order-status.d.ts +58 -0
- package/src/lib/server/order-status.js +141 -0
- package/src/lib/server/order-status.js.map +1 -0
- package/src/lib/server/order-webhooks.d.ts +108 -0
- package/src/lib/server/order-webhooks.js +622 -0
- package/src/lib/server/order-webhooks.js.map +1 -0
- package/src/lib/server/orders-shipping-prepare.d.ts +26 -0
- package/src/lib/server/orders-shipping-prepare.js +121 -0
- package/src/lib/server/orders-shipping-prepare.js.map +1 -0
- package/src/lib/server/payment-method-domains.d.ts +209 -0
- package/src/lib/server/payment-method-domains.js +444 -0
- package/src/lib/server/payment-method-domains.js.map +1 -0
- package/src/lib/server/payment-methods.d.ts +77 -0
- package/src/lib/server/payment-methods.js +284 -0
- package/src/lib/server/payment-methods.js.map +1 -0
- package/src/lib/server/pos-auth.d.ts +50 -0
- package/src/lib/server/pos-auth.js +121 -0
- package/src/lib/server/pos-auth.js.map +1 -0
- package/src/lib/server/pos-customer.d.ts +49 -0
- package/src/lib/server/pos-customer.js +257 -0
- package/src/lib/server/pos-customer.js.map +1 -0
- package/src/lib/server/pos-display.d.ts +57 -0
- package/src/lib/server/pos-display.js +419 -0
- package/src/lib/server/pos-display.js.map +1 -0
- package/src/lib/server/pos-fee-month.d.ts +34 -0
- package/src/lib/server/pos-fee-month.js +36 -0
- package/src/lib/server/pos-fee-month.js.map +1 -0
- package/src/lib/server/pos-ops-gate.d.ts +161 -0
- package/src/lib/server/pos-ops-gate.js +295 -0
- package/src/lib/server/pos-ops-gate.js.map +1 -0
- package/src/lib/server/pos-ops-routes.d.ts +22 -0
- package/src/lib/server/pos-ops-routes.js +36 -0
- package/src/lib/server/pos-ops-routes.js.map +1 -0
- package/src/lib/server/pos-order.d.ts +1 -18
- package/src/lib/server/pos-order.js +222 -42
- package/src/lib/server/pos-order.js.map +1 -1
- package/src/lib/server/pos-payment.d.ts +39 -0
- package/src/lib/server/pos-payment.js +922 -0
- package/src/lib/server/pos-payment.js.map +1 -0
- package/src/lib/server/pos-print.d.ts +82 -0
- package/src/lib/server/pos-print.js +193 -0
- package/src/lib/server/pos-print.js.map +1 -0
- package/src/lib/server/pos-readers.d.ts +27 -0
- package/src/lib/server/pos-readers.js +276 -0
- package/src/lib/server/pos-readers.js.map +1 -0
- package/src/lib/server/pos-refund-authority.d.ts +60 -0
- package/src/lib/server/pos-refund-authority.js +72 -0
- package/src/lib/server/pos-refund-authority.js.map +1 -0
- package/src/lib/server/pos-return.d.ts +58 -0
- package/src/lib/server/pos-return.js +891 -0
- package/src/lib/server/pos-return.js.map +1 -0
- package/src/lib/server/pos-sale-stamp.d.ts +66 -0
- package/src/lib/server/pos-sale-stamp.js +84 -0
- package/src/lib/server/pos-sale-stamp.js.map +1 -0
- package/src/lib/server/pos-sale.d.ts +170 -0
- package/src/lib/server/pos-sale.js +461 -0
- package/src/lib/server/pos-sale.js.map +1 -0
- package/src/lib/server/pos-shift.d.ts +45 -0
- package/src/lib/server/pos-shift.js +484 -0
- package/src/lib/server/pos-shift.js.map +1 -0
- package/src/lib/server/pos-staff-pin.d.ts +26 -0
- package/src/lib/server/pos-staff-pin.js +339 -0
- package/src/lib/server/pos-staff-pin.js.map +1 -0
- package/src/lib/server/pos-stripe.d.ts +91 -0
- package/src/lib/server/pos-stripe.js +129 -0
- package/src/lib/server/pos-stripe.js.map +1 -0
- package/src/lib/server/pos-terminal-connection-token.d.ts +48 -0
- package/src/lib/server/pos-terminal-connection-token.js +166 -0
- package/src/lib/server/pos-terminal-connection-token.js.map +1 -0
- package/src/lib/server/pos-terminal.d.ts +218 -0
- package/src/lib/server/pos-terminal.js +1014 -0
- package/src/lib/server/pos-terminal.js.map +1 -0
- package/src/lib/server/print-queue.d.ts +124 -0
- package/src/lib/server/print-queue.js +301 -0
- package/src/lib/server/print-queue.js.map +1 -0
- package/src/lib/server/printer-poll.d.ts +75 -0
- package/src/lib/server/printer-poll.js +325 -0
- package/src/lib/server/printer-poll.js.map +1 -0
- package/src/lib/server/printer-secret.d.ts +39 -0
- package/src/lib/server/printer-secret.js +56 -0
- package/src/lib/server/printer-secret.js.map +1 -0
- package/src/lib/server/printers.d.ts +114 -0
- package/src/lib/server/printers.js +546 -0
- package/src/lib/server/printers.js.map +1 -0
- package/src/lib/server/product-catalog.d.ts +42 -0
- package/src/lib/server/product-catalog.js +309 -0
- package/src/lib/server/product-catalog.js.map +1 -0
- package/src/lib/server/product-drafts.d.ts +5 -1
- package/src/lib/server/product-drafts.js +3 -3
- package/src/lib/server/product-drafts.js.map +1 -1
- package/src/lib/server/product-writer.d.ts +19 -0
- package/src/lib/server/product-writer.js +261 -0
- package/src/lib/server/product-writer.js.map +1 -0
- package/src/lib/server/products-write.d.ts +61 -0
- package/src/lib/server/products-write.js +375 -0
- package/src/lib/server/products-write.js.map +1 -0
- package/src/lib/server/refund.js +110 -45
- package/src/lib/server/refund.js.map +1 -1
- package/src/lib/server/reserve.js +2 -0
- package/src/lib/server/reserve.js.map +1 -1
- package/src/lib/server/return-status-action.d.ts +37 -0
- package/src/lib/server/return-status-action.js +57 -0
- package/src/lib/server/return-status-action.js.map +1 -0
- package/src/lib/server/returns.d.ts +119 -0
- package/src/lib/server/returns.js +938 -0
- package/src/lib/server/returns.js.map +1 -0
- package/src/lib/server/shipment-records.d.ts +36 -0
- package/src/lib/server/shipment-records.js +289 -0
- package/src/lib/server/shipment-records.js.map +1 -0
- package/src/lib/server/shipping-connector-gates.d.ts +40 -0
- package/src/lib/server/shipping-connector-gates.js +97 -0
- package/src/lib/server/shipping-connector-gates.js.map +1 -0
- package/src/lib/server/shipping-connectors.d.ts +29 -0
- package/src/lib/server/shipping-connectors.js +236 -0
- package/src/lib/server/shipping-connectors.js.map +1 -0
- package/src/lib/server/shippingeasy.d.ts +238 -0
- package/src/lib/server/shippingeasy.js +787 -0
- package/src/lib/server/shippingeasy.js.map +1 -0
- package/src/lib/server/shipstation.d.ts +129 -0
- package/src/lib/server/shipstation.js +483 -0
- package/src/lib/server/shipstation.js.map +1 -0
- package/src/lib/server/site-page-resolver.d.ts +5 -0
- package/src/lib/server/site-page-resolver.js +156 -1
- package/src/lib/server/site-page-resolver.js.map +1 -1
- package/src/lib/server/stock-levels.d.ts +21 -0
- package/src/lib/server/stock-levels.js +263 -0
- package/src/lib/server/stock-levels.js.map +1 -0
- package/src/lib/server/stripe-refund.d.ts +47 -0
- package/src/lib/server/stripe-refund.js +87 -0
- package/src/lib/server/stripe-refund.js.map +1 -0
- package/src/lib/server/supplier-update.js +46 -5
- package/src/lib/server/supplier-update.js.map +1 -1
- package/src/lib/server/tax-engine-quote.d.ts +47 -0
- package/src/lib/server/tax-engine-quote.js +105 -0
- package/src/lib/server/tax-engine-quote.js.map +1 -0
- package/src/lib/server.js +143 -2
- package/src/lib/server.js.map +1 -1
- package/src/lib/site.js +12 -0
- package/src/lib/site.js.map +1 -1
- package/src/lib/subprocessors.d.ts +26 -0
- package/src/lib/subprocessors.js +50 -0
- package/src/lib/subprocessors.js.map +1 -0
- package/src/lib/tenant-emails.js +461 -3
- package/src/lib/tenant-emails.js.map +1 -1
- package/src/lib/testing/fake-firestore.d.ts +45 -0
- package/src/lib/testing/fake-firestore.js +189 -0
- package/src/lib/testing/fake-firestore.js.map +1 -0
- package/src/lib/testing/memory-firestore.d.ts +136 -0
- package/src/lib/testing/memory-firestore.js +282 -0
- package/src/lib/testing/memory-firestore.js.map +1 -0
- package/src/lib/testing/pos-ops-harness.d.ts +50 -0
- package/src/lib/testing/pos-ops-harness.js +184 -0
- package/src/lib/testing/pos-ops-harness.js.map +1 -0
- package/src/lib/testing/pos-ops-memory-firestore.d.ts +55 -0
- package/src/lib/testing/pos-ops-memory-firestore.js +376 -0
- package/src/lib/testing/pos-ops-memory-firestore.js.map +1 -0
- package/src/lib/transfer/products.server.d.ts +5 -0
- package/src/lib/transfer/products.server.js +2 -2
- package/src/lib/transfer/products.server.js.map +1 -1
- package/src/lib/transfer/records-transfer.d.ts +11 -1
- package/src/lib/transfer/records-transfer.js +127 -5
- package/src/lib/transfer/records-transfer.js.map +1 -1
- package/src/lib/transfer/records.server.d.ts +9 -2
- package/src/lib/transfer/records.server.js +58 -7
- package/src/lib/transfer/records.server.js.map +1 -1
- package/src/lib/transfer/register-transfer-resources.js +40 -1
- package/src/lib/transfer/register-transfer-resources.js.map +1 -1
- package/src/lib/transfer/register-transfer-ui.js +4 -1
- package/src/lib/transfer/register-transfer-ui.js.map +1 -1
- package/src/lib/transfer/shipping-presets.d.ts +23 -0
- package/src/lib/transfer/shipping-presets.js +156 -0
- package/src/lib/transfer/shipping-presets.js.map +1 -0
- package/src/lib/transfer/tracking-transfer.d.ts +101 -0
- package/src/lib/transfer/tracking-transfer.js +546 -0
- package/src/lib/transfer/tracking-transfer.js.map +1 -0
- package/src/lib/transfer/tracking.server.d.ts +37 -0
- package/src/lib/transfer/tracking.server.js +393 -0
- package/src/lib/transfer/tracking.server.js.map +1 -0
- package/src/lib/transfer/transfer-keys.d.ts +2 -1
- package/src/lib/transfer/transfer-keys.js +6 -2
- package/src/lib/transfer/transfer-keys.js.map +1 -1
- package/src/lib/utils/code128.d.ts +37 -0
- package/src/lib/utils/code128.js +199 -0
- package/src/lib/utils/code128.js.map +1 -0
- package/src/lib/utils/order-invoice.d.ts +55 -0
- package/src/lib/utils/order-invoice.js +127 -0
- package/src/lib/utils/order-invoice.js.map +1 -0
- package/src/lib/utils/use-checkout-return-notice.d.ts +34 -0
- package/src/lib/utils/use-checkout-return-notice.js +78 -0
- package/src/lib/utils/use-checkout-return-notice.js.map +1 -0
- package/src/lib/server/feed.js +0 -69
- package/src/lib/server/feed.js.map +0 -1
|
@@ -37,6 +37,8 @@ import TextField from "@mui/material/TextField";
|
|
|
37
37
|
import Typography from "@mui/material/Typography";
|
|
38
38
|
import { Suspense, forwardRef, lazy, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
39
39
|
import { StorefrontPaymentElementFallback } from "./storefront-payment-element-fallback.js";
|
|
40
|
+
import { CheckoutReturnNotice } from "./checkout-return-notice.js";
|
|
41
|
+
import { CartExtras, useCartExtras } from "./cart-extras.js";
|
|
40
42
|
/**
|
|
41
43
|
* The Payment Element (AGL-1944), lazily. Stripe.js and its React wrapper are
|
|
42
44
|
* a large dependency and the flag is OFF, so a static import would ship the
|
|
@@ -85,6 +87,10 @@ function CartLines(props) {
|
|
|
85
87
|
// itself the server's answer rather than a guess made here.
|
|
86
88
|
const [shipTo, setShipTo] = useState('');
|
|
87
89
|
const [shipCountries, setShipCountries] = useState(null);
|
|
90
|
+
// Live carrier rates price by postal code (AGL-3612): asked only when the
|
|
91
|
+
// store prices that way and the server says so.
|
|
92
|
+
const [shipPostal, setShipPostal] = useState('');
|
|
93
|
+
const [askPostal, setAskPostal] = useState(false);
|
|
88
94
|
// `paused` is its own state, not an `error` with gentler words (AGL-1511):
|
|
89
95
|
// the two need different severities, and a shopper told in red that
|
|
90
96
|
// checkout failed does not read the sentence explaining it did not. `ask` is
|
|
@@ -177,6 +183,9 @@ function CartLines(props) {
|
|
|
177
183
|
}, [
|
|
178
184
|
cart
|
|
179
185
|
]);
|
|
186
|
+
// Optional lines another plugin offers (AGL-3635), asked while the cart is shown.
|
|
187
|
+
const extras = useCartExtras(hostId, cartSignature);
|
|
188
|
+
const extrasSignature = extras.chosenIds.join(',');
|
|
180
189
|
useEffect(()=>{
|
|
181
190
|
attemptKey.current = '';
|
|
182
191
|
}, [
|
|
@@ -184,7 +193,9 @@ function CartLines(props) {
|
|
|
184
193
|
email,
|
|
185
194
|
coupon,
|
|
186
195
|
giftCard,
|
|
187
|
-
shipTo
|
|
196
|
+
shipTo,
|
|
197
|
+
shipPostal,
|
|
198
|
+
extrasSignature
|
|
188
199
|
]);
|
|
189
200
|
const handleCheckout = useCallback(async ()=>{
|
|
190
201
|
if (status === 'sending') return;
|
|
@@ -217,6 +228,10 @@ function CartLines(props) {
|
|
|
217
228
|
giftCardCode: giftCard.trim()
|
|
218
229
|
} : {}, shipTo ? {
|
|
219
230
|
shippingCountry: shipTo
|
|
231
|
+
} : {}, shipPostal.trim() ? {
|
|
232
|
+
shippingPostalCode: shipPostal.trim()
|
|
233
|
+
} : {}, extras.chosenIds.length ? {
|
|
234
|
+
extras: extras.chosenIds
|
|
220
235
|
} : {}))
|
|
221
236
|
});
|
|
222
237
|
const payload = await response.json().catch(()=>({}));
|
|
@@ -236,7 +251,8 @@ function CartLines(props) {
|
|
|
236
251
|
}));
|
|
237
252
|
setNativeCheckout({
|
|
238
253
|
clientSecret: String(payload.clientSecret),
|
|
239
|
-
publishableKey: String(payload.publishableKey)
|
|
254
|
+
publishableKey: String(payload.publishableKey),
|
|
255
|
+
wallets: CommerceModel.readStorefrontCheckoutWallets(payload.wallets)
|
|
240
256
|
});
|
|
241
257
|
setStatus('idle');
|
|
242
258
|
return;
|
|
@@ -288,6 +304,15 @@ function CartLines(props) {
|
|
|
288
304
|
// this is a visitor-facing surface, the 501 bodies differ between the
|
|
289
305
|
// cart and buy-now doors, and one of them could grow a variable name
|
|
290
306
|
// without anyone thinking about who reads it.
|
|
307
|
+
// An offer the shopper ticked changed or went away (AGL-3635): show
|
|
308
|
+
// what is offered now and let them decide again.
|
|
309
|
+
if (payload == null ? void 0 : payload.extrasChanged) {
|
|
310
|
+
var _ref4;
|
|
311
|
+
extras.reload();
|
|
312
|
+
setMessage(String((_ref4 = payload == null ? void 0 : payload.error) != null ? _ref4 : ''));
|
|
313
|
+
setStatus('error');
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
291
316
|
if (isPaymentsNotConfigured(response.status)) {
|
|
292
317
|
setMessage(storefrontPaymentsNotConfiguredText());
|
|
293
318
|
setStatus('unconfigured');
|
|
@@ -297,12 +322,13 @@ function CartLines(props) {
|
|
|
297
322
|
// price this cart until it knows one (AGL-1721). Reveal the field and
|
|
298
323
|
// let the shopper answer; a store that never sends this never shows it.
|
|
299
324
|
if (payload == null ? void 0 : payload.needsShippingCountry) {
|
|
300
|
-
var
|
|
325
|
+
var _ref5;
|
|
301
326
|
var _payload_shippingCountries;
|
|
327
|
+
if (payload == null ? void 0 : payload.needsShippingPostalCode) setAskPostal(true);
|
|
302
328
|
setShipCountries(((_payload_shippingCountries = payload.shippingCountries) == null ? void 0 : _payload_shippingCountries.length) ? payload.shippingCountries : [
|
|
303
329
|
...CommerceModel.CHECKOUT_SHIPPING_COUNTRIES
|
|
304
330
|
]);
|
|
305
|
-
setMessage(String((
|
|
331
|
+
setMessage(String((_ref5 = payload == null ? void 0 : payload.error) != null ? _ref5 : ''));
|
|
306
332
|
// An unserved destination is a real refusal and reads as one; being
|
|
307
333
|
// asked the first time is not.
|
|
308
334
|
setStatus(shipTo ? 'error' : 'ask');
|
|
@@ -327,8 +353,11 @@ function CartLines(props) {
|
|
|
327
353
|
optIn,
|
|
328
354
|
giftCard,
|
|
329
355
|
shipTo,
|
|
356
|
+
shipPostal,
|
|
330
357
|
status,
|
|
331
|
-
siteFetch
|
|
358
|
+
siteFetch,
|
|
359
|
+
extras.chosenIds,
|
|
360
|
+
extras.reload
|
|
332
361
|
]);
|
|
333
362
|
if (!cart || cart.lines.length === 0) {
|
|
334
363
|
return /*#__PURE__*/ _jsx(Typography, {
|
|
@@ -452,6 +481,12 @@ function CartLines(props) {
|
|
|
452
481
|
})
|
|
453
482
|
]
|
|
454
483
|
}),
|
|
484
|
+
/*#__PURE__*/ _jsx(CartExtras, {
|
|
485
|
+
offers: extras.offers,
|
|
486
|
+
chosen: extras.chosen,
|
|
487
|
+
onToggle: extras.toggle,
|
|
488
|
+
formatCents: usd
|
|
489
|
+
}),
|
|
455
490
|
/*#__PURE__*/ _jsx(Typography, {
|
|
456
491
|
variant: "caption",
|
|
457
492
|
color: "text.secondary",
|
|
@@ -508,6 +543,19 @@ function CartLines(props) {
|
|
|
508
543
|
}, code);
|
|
509
544
|
})
|
|
510
545
|
}) : null,
|
|
546
|
+
askPostal ? /*#__PURE__*/ _jsx(TextField, {
|
|
547
|
+
label: "Postal code",
|
|
548
|
+
value: shipPostal,
|
|
549
|
+
onChange: (event)=>setShipPostal(event.target.value),
|
|
550
|
+
size: "small",
|
|
551
|
+
helperText: "Carrier rates depend on the postal code",
|
|
552
|
+
slotProps: {
|
|
553
|
+
htmlInput: {
|
|
554
|
+
autoComplete: 'shipping postal-code',
|
|
555
|
+
maxLength: 12
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}) : null,
|
|
511
559
|
status === 'paused' || status === 'ask' || status === 'unconfigured' ? /*#__PURE__*/ _jsx(Alert, {
|
|
512
560
|
severity: "info",
|
|
513
561
|
children: message
|
|
@@ -523,7 +571,7 @@ function CartLines(props) {
|
|
|
523
571
|
// 501, so the control latches off rather than inviting a retry that
|
|
524
572
|
// cannot succeed (AGL-2019).
|
|
525
573
|
status === 'unconfigured' || // Asked but unanswered: the server would only refuse again.
|
|
526
|
-
shipCountries !== null && !shipTo,
|
|
574
|
+
shipCountries !== null && !shipTo || askPostal && !shipPostal.trim(),
|
|
527
575
|
onClick: handleCheckout,
|
|
528
576
|
children: status === 'sending' ? // place (AGL-1944).
|
|
529
577
|
nativeCheckout ? 'Opening…' : 'Redirecting…' : checkoutLabel || 'Checkout'
|
|
@@ -533,7 +581,16 @@ function CartLines(props) {
|
|
|
533
581
|
children: /*#__PURE__*/ _jsx(StorefrontPaymentElement, {
|
|
534
582
|
clientSecret: nativeCheckout.clientSecret,
|
|
535
583
|
publishableKey: nativeCheckout.publishableKey,
|
|
584
|
+
wallets: nativeCheckout.wallets,
|
|
536
585
|
payLabel: checkoutLabel || 'Pay now',
|
|
586
|
+
defaultEmail: email,
|
|
587
|
+
// An expired or unloadable session is replaced, never replayed:
|
|
588
|
+
// the old attempt key would hand back the dead session.
|
|
589
|
+
onRestart: ()=>{
|
|
590
|
+
attemptKey.current = '';
|
|
591
|
+
setNativeCheckout(null);
|
|
592
|
+
void handleCheckout();
|
|
593
|
+
},
|
|
537
594
|
// The session is left open on cancel, deliberately: it is what the
|
|
538
595
|
// AGL-323 abandoned-cart recovery emails are built on, and expiring
|
|
539
596
|
// it would be a write against the merchant's Stripe account made
|
|
@@ -668,17 +725,23 @@ function CartLines(props) {
|
|
|
668
725
|
}));
|
|
669
726
|
}
|
|
670
727
|
if (variant === 'inline') {
|
|
671
|
-
return /*#__PURE__*/
|
|
728
|
+
return /*#__PURE__*/ _jsxs(Box, _extends({
|
|
672
729
|
ref: ref
|
|
673
730
|
}, rest, {
|
|
674
|
-
children:
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
731
|
+
children: [
|
|
732
|
+
/*#__PURE__*/ _jsx(CheckoutReturnNotice, {
|
|
733
|
+
hostId: hostId,
|
|
734
|
+
siteFetch: siteFetch
|
|
735
|
+
}),
|
|
736
|
+
/*#__PURE__*/ _jsx(CartLines, {
|
|
737
|
+
hostId: hostId,
|
|
738
|
+
cart: cart,
|
|
739
|
+
showCoupon: showCoupon,
|
|
740
|
+
checkoutLabel: checkoutLabel,
|
|
741
|
+
emptyText: emptyText,
|
|
742
|
+
onMutate: mutate
|
|
743
|
+
})
|
|
744
|
+
]
|
|
682
745
|
}));
|
|
683
746
|
}
|
|
684
747
|
return /*#__PURE__*/ _jsxs(Box, _extends({
|
|
@@ -691,6 +754,10 @@ function CartLines(props) {
|
|
|
691
754
|
...nodeSx
|
|
692
755
|
],
|
|
693
756
|
children: [
|
|
757
|
+
/*#__PURE__*/ _jsx(CheckoutReturnNotice, {
|
|
758
|
+
hostId: hostId,
|
|
759
|
+
siteFetch: siteFetch
|
|
760
|
+
}),
|
|
694
761
|
/*#__PURE__*/ _jsx(IconButton, {
|
|
695
762
|
"aria-label": "Cart",
|
|
696
763
|
onClick: ()=>setOpen(true),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/cart.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport {\n buildBeginCheckoutParams,\n buildViewCartParams,\n trackEvent,\n trackEventBeforeNavigation,\n type AnalyticsItem,\n} from '@aglyn/aglyn/app-utils/analytics-events'\nimport { isPaymentsNotConfigured } from '@aglyn/aglyn/app-utils/payments-configured'\nimport { storefrontPaymentsNotConfiguredText } from '../constants/storefront-payments'\nimport * as CommerceModel from '../model'\nimport { mdiCartOutline } from '@aglyn/shared-data-mdi'\nimport Alert from '@mui/material/Alert'\nimport Badge from '@mui/material/Badge'\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Checkbox from '@mui/material/Checkbox'\nimport Drawer from '@mui/material/Drawer'\nimport FormControlLabel from '@mui/material/FormControlLabel'\nimport IconButton from '@mui/material/IconButton'\nimport MenuItem from '@mui/material/MenuItem'\nimport SvgIcon from '@mui/material/SvgIcon'\nimport TextField from '@mui/material/TextField'\nimport Typography from '@mui/material/Typography'\nimport {\n Suspense,\n forwardRef,\n lazy,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport { StorefrontPaymentElementFallback } from './storefront-payment-element-fallback'\n\n/**\n * The Payment Element (AGL-1944), lazily. Stripe.js and its React wrapper are\n * a large dependency and the flag is OFF, so a static import would ship the\n * whole SDK in the bundle of every page carrying a cart — which is most pages\n * on a storefront — to serve a path no shopper currently reaches.\n */\nconst StorefrontPaymentElement = lazy(() =>\n import('./storefront-payment-element').then((module) => ({\n default: module.StorefrontPaymentElement,\n })),\n)\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { generatePresetId } from '../utils/generate-preset-id'\nimport { useStorefrontPurchaseEvent } from '../utils/use-storefront-purchase-event'\n\n// Component ids are persisted in screen documents; never rename.\nexport const ID: Aglyn.ComponentId = 'cart'\n\n/** Blocks dispatch this after mutating the cart so badges refresh. */\nexport const CART_UPDATED_EVENT = 'aglyn:cart-updated'\n\nexport interface CartProps {\n /** 'button' = app-bar icon + drawer; 'inline' = full cart in place. */\n variant?: 'button' | 'inline'\n checkoutLabel?: string\n /** Show the coupon-code field above checkout. */\n showCoupon?: boolean\n emptyText?: string\n}\n\ninterface CartLineView {\n productId: string\n variantId?: string\n quantity: number\n name: string\n variantLabel?: string\n unitAmountCents: number\n imageUrl?: string\n unavailable?: boolean\n}\n\ninterface CartView {\n lines: CartLineView[]\n count: number\n subtotalCents: number\n}\n\nconst usd = (cents: number) => `$${(cents / 100).toFixed(2)}`\n\n/**\n * The cart's lines as GA4 `items`.\n *\n * One mapping for every event this file sends — `view_cart` and both\n * `begin_checkout` branches — because the `item_id` is what joins them into a\n * single per-product funnel with the `view_item` and `add_to_cart` the product\n * blocks send. Three hand-written copies of the same map are three chances for\n * one step to start reporting a variant id, or a name, or a different price\n * basis, and a funnel whose steps disagree about the product silently reports\n * a drop that never happened.\n */\nfunction cartAnalyticsItems(cart: CartView | null): AnalyticsItem[] {\n return (cart?.lines ?? []).map((line) => ({\n item_id: line.productId,\n item_name: line.name,\n price: line.unitAmountCents / 100,\n quantity: line.quantity,\n }))\n}\n\nfunction CartLines(props: {\n hostId: string\n cart: CartView | null\n showCoupon?: boolean\n checkoutLabel?: string\n emptyText?: string\n onMutate: (body: Record<string, unknown>) => Promise<void>\n}) {\n const { hostId, cart, showCoupon, checkoutLabel, emptyText, onMutate } =\n props\n const siteFetch = Aglyn.useSiteFetch()\n const [coupon, setCoupon] = useState('')\n const [email, setEmail] = useState('')\n const [optIn, setOptIn] = useState(false)\n const [giftCard, setGiftCard] = useState('')\n // Where the parcel is going (AGL-1721). Asked ONLY when the server says it\n // cannot price shipping without it — a merchant with one zone, one\n // rest-of-world zone, or no shipping at all never sees this field, which is\n // the common configuration. `null` is \"not asked\", so the field appearing is\n // itself the server's answer rather than a guess made here.\n const [shipTo, setShipTo] = useState('')\n const [shipCountries, setShipCountries] = useState<string[] | null>(null)\n // `paused` is its own state, not an `error` with gentler words (AGL-1511):\n // the two need different severities, and a shopper told in red that\n // checkout failed does not read the sentence explaining it did not. `ask` is\n // the same argument again: being asked for a destination is not a failure.\n // `unconfigured` is the third instance (AGL-2019): a store with no Stripe key\n // answers 501, and before this that fell through to the error tail below and\n // rendered RED. It is also the only one of the five that is TERMINAL — the\n // others can succeed on a retry, this one cannot until the operator acts, so\n // it latches the buy control off instead of inviting another click.\n const [status, setStatus] = useState<\n 'idle' | 'sending' | 'error' | 'paused' | 'ask' | 'unconfigured'\n >('idle')\n const [message, setMessage] = useState('')\n /**\n * The in-page checkout session (AGL-1944). Null unless the server chose\n * native mode, which needs both the release flag and a publishable key.\n */\n const [nativeCheckout, setNativeCheckout] = useState<{\n clientSecret: string\n publishableKey: string\n } | null>(null)\n /**\n * In-progress quantity edits, keyed by line, as the raw field text\n * (AGL-1772). The field used to POST /api/commerce/cart on every\n * keystroke — typing \"100\" was three Firestore writes, and clearing the\n * field to retype passed through `\"\"` → 0, which is the REMOVE path, so a\n * select-all-and-retype could delete the line mid-edit (and the response\n * replacing `cart` state then fought the input).\n *\n * The repo convention for quantity inputs is local state committed on an\n * explicit settle — the PDP's Qty field (product-detail.tsx) holds\n * `useState` and sends nothing until the buy click, and besigner\n * attributes commit on blur. So: keystrokes only edit the draft; blur or\n * Enter commits ONE write; an empty or unparsable draft is a pending\n * state that reverts to the server's quantity, never a 0-as-remove. A\n * genuine remove still works both ways — the ✕ button, and typing an\n * actual 0 then leaving the field.\n */\n const [quantityDrafts, setQuantityDrafts] = useState<Record<string, string>>(\n {},\n )\n const lineKey = (line: CartLineView) =>\n `${line.productId}:${line.variantId ?? ''}`\n const commitQuantity = (line: CartLineView) => {\n const key = lineKey(line)\n const draft = quantityDrafts[key]\n if (draft === undefined) return\n // Drops the draft, but only if it is still THIS one — a keystroke that\n // lands while the write is in flight starts a new edit, and clearing it\n // here would erase what the shopper is typing.\n const settle = () =>\n setQuantityDrafts((drafts) => {\n if (drafts[key] !== draft) return drafts\n const { [key]: _settled, ...rest } = drafts\n return rest\n })\n // `Number('')` is 0 — exactly the misreading that turned a cleared\n // field into a remove. Empty means \"no answer\": show the server's\n // quantity again and write nothing. NaN (letters) reverts the same way.\n if (draft.trim() === '') return settle()\n const parsed = Math.round(Number(draft))\n if (!Number.isFinite(parsed)) return settle()\n const quantity = Math.max(0, parsed)\n // A settled value equal to the server's is not an edit.\n if (quantity === line.quantity) return settle()\n // The draft keeps rendering until the response lands, so the field does\n // not flash the superseded quantity during the round-trip; the server's\n // answer (via the replaced `cart`) takes over when it arrives.\n void onMutate({\n action: 'set',\n productId: line.productId,\n variantId: line.variantId,\n quantity,\n }).finally(settle)\n }\n\n /**\n * Idempotency key for ONE checkout attempt (AGL-1697).\n *\n * Minted lazily on the first checkout click, retired whenever the attempt\n * changes shape — different lines, codes, email or destination are a\n * different checkout. Keyed off a CONTENT signature of the lines rather\n * than the `cart` object, whose identity changes on every refetch: retiring\n * on identity would hand a genuine retry a fresh key, which is exactly the\n * double-session this exists to prevent.\n */\n const attemptKey = useRef('')\n const cartSignature = useMemo(\n () =>\n JSON.stringify(\n (cart?.lines ?? []).map((line) => [\n line.productId,\n line.variantId ?? '',\n line.quantity,\n ]),\n ),\n [cart],\n )\n useEffect(() => {\n attemptKey.current = ''\n }, [cartSignature, email, coupon, giftCard, shipTo])\n\n const handleCheckout = useCallback(async () => {\n if (status === 'sending') return\n setStatus('sending')\n setMessage('')\n if (!attemptKey.current) {\n attemptKey.current =\n globalThis.crypto?.randomUUID?.() ??\n `${Date.now()}-${Math.random().toString(36).slice(2)}`\n }\n try {\n const response = await siteFetch('/api/commerce/cart-checkout', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n // Stable across a retry of THIS attempt (AGL-1697), so a\n // double-click cannot spawn a second session from one cart.\n 'Idempotency-Key': attemptKey.current,\n },\n body: JSON.stringify({\n hostId,\n ...(email.trim() ? { email: email.trim() } : {}),\n ...(optIn ? { marketingOptIn: true } : {}),\n ...(coupon.trim() ? { couponCode: coupon.trim() } : {}),\n ...(giftCard.trim() ? { giftCardCode: giftCard.trim() } : {}),\n // A request, never an instruction: the server resolves the rates\n // for this country AND restricts the session's collectable\n // addresses to it, so declaring one cannot buy a cheaper zone's\n // rate than the address the shopper then enters (AGL-1721).\n ...(shipTo ? { shippingCountry: shipTo } : {}),\n }),\n })\n const payload = await response.json().catch(() => ({}))\n // In-page payment (AGL-1944). Checked BEFORE the redirect branch: a\n // native session carries a client secret and no url, and if a server ever\n // sent both, navigating away would silently discard the form.\n //\n // `begin_checkout` is reported on BOTH paths, and from the same place, so\n // the GA4 funnel does not develop a hole the day the flag flips — a\n // storefront whose `begin_checkout` count halved would look like a\n // conversion collapse rather than a checkout that stopped redirecting.\n if (response.ok && payload?.clientSecret && payload?.publishableKey) {\n trackEvent(\n 'begin_checkout',\n buildBeginCheckoutParams({\n value: (cart?.subtotalCents ?? 0) / 100,\n items: cartAnalyticsItems(cart),\n }),\n )\n setNativeCheckout({\n clientSecret: String(payload.clientSecret),\n publishableKey: String(payload.publishableKey),\n })\n setStatus('idle')\n return\n }\n if (response.ok && payload?.url) {\n // GA4 checkout funnel (AGL-1561, converted by AGL-1591). This used to\n // call `window.gtag` raw with `value`/`currency` only, so the same\n // event name arrived from this surface and from the console's plan\n // checkout in two different shapes — and this half carried no `items`,\n // which is the field GA4's ecommerce funnel is actually built on.\n //\n // The item ids are the PRODUCT ids `view_item` and `add_to_cart`\n // already send, so the three now join into one per-product funnel.\n // `value` is stated rather than derived because the cart subtotal is\n // authoritative after a coupon or gift card, which the line prices\n // below are not. No `billing_interval`: a storefront cart is not a\n // subscription.\n //\n // AWAITED before the redirect (AGL-1580). This surface registers no\n // transport, so delivery is a synchronous `window.gtag` call and the\n // await resolves immediately — a storefront checkout is not slowed by\n // one microtask. It is written this way anyway because the property\n // that makes it safe is invisible from here: the day this bundle grows\n // an async transport, or a host registers one for it, the bare call\n // would start losing the event on exactly the branch that navigates,\n // and nothing at this call site would look different.\n await trackEventBeforeNavigation(\n 'begin_checkout',\n buildBeginCheckoutParams({\n value: (cart?.subtotalCents ?? 0) / 100,\n items: cartAnalyticsItems(cart),\n }),\n )\n window.location.assign(payload.url)\n return\n }\n // A read-only lockdown answers 423 with the visitor pause copy\n // (AGL-1511). Rendering `payload.error` here would print the wire\n // token \"locked\" at a shopper, and the `severity=\"error\"` styling\n // would tell them their payment failed — the one thing this copy\n // exists to never say. So the refusal is parsed and shown as a calm\n // notice instead.\n const paused = Aglyn.parseLockdownRefusal(response.status, payload)\n if (paused) {\n setMessage(Aglyn.lockdownRefusalText(paused))\n setStatus('paused')\n return\n }\n // A store that never had payments configured (AGL-2019). The server's\n // own words are NOT rendered here even though they are safe today:\n // this is a visitor-facing surface, the 501 bodies differ between the\n // cart and buy-now doors, and one of them could grow a variable name\n // without anyone thinking about who reads it.\n if (isPaymentsNotConfigured(response.status)) {\n setMessage(storefrontPaymentsNotConfiguredText())\n setStatus('unconfigured')\n return\n }\n // The merchant's rates differ by destination, so the server will not\n // price this cart until it knows one (AGL-1721). Reveal the field and\n // let the shopper answer; a store that never sends this never shows it.\n if (payload?.needsShippingCountry) {\n setShipCountries(\n (payload.shippingCountries as string[] | undefined)?.length\n ? (payload.shippingCountries as string[])\n : [...CommerceModel.CHECKOUT_SHIPPING_COUNTRIES],\n )\n setMessage(String(payload?.error ?? ''))\n // An unserved destination is a real refusal and reads as one; being\n // asked the first time is not.\n setStatus(shipTo ? 'error' : 'ask')\n return\n }\n setMessage(String(payload?.error ?? ''))\n setStatus('error')\n } catch {\n setStatus('error')\n }\n // `cart` is a dependency because the payload above reads it: without it\n // the handler closes over whichever cart was current when it was created,\n // and a checkout started after a quantity change would report the OLD\n // subtotal and the OLD lines. The pre-AGL-1591 raw call had the same bug\n // in the `value` alone, where a wrong number is indistinguishable from a\n // right one.\n }, [hostId, cart, coupon, email, optIn, giftCard, shipTo, status, siteFetch])\n\n if (!cart || cart.lines.length === 0) {\n return (\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ p: 2 }}>\n {emptyText || 'Your cart is empty.'}\n </Typography>\n )\n }\n return (\n <Box sx={{ display: 'flex', flexDirection: 'column', gap: 1.5, p: 2 }}>\n {cart.lines.map((line) => {\n // AGL-1726: resolve BEFORE the guard, never inside the `src`. A\n // stored value can be truthy and still resolve to nothing (a\n // malformed `media:` reference), and testing the raw string would\n // turn \"no image\" into an `<img>` with no `src` — a broken-image\n // icon where the placeholder belongs.\n const imageUrl = Aglyn.siteRelativeMediaSrc(line.imageUrl, { hostId })\n return (\n <Box\n key={`${line.productId}:${line.variantId ?? ''}`}\n sx={{ display: 'flex', gap: 1.5, alignItems: 'center' }}\n >\n {imageUrl ? (\n <Box\n component=\"img\"\n src={imageUrl}\n alt=\"\"\n sx={{\n width: 48,\n height: 48,\n objectFit: 'cover',\n borderRadius: 1,\n }}\n // Deferred (AGL-2486). A 48px cart-line thumbnail is the\n // clearest case of the set: it can never be the LCP, and a\n // cart is usually below the fold or inside a panel.\n {...Aglyn.DEFERRED_IMAGE_ATTRIBUTES}\n />\n ) : (\n <Box\n sx={{\n width: 48,\n height: 48,\n bgcolor: 'action.hover',\n borderRadius: 1,\n }}\n />\n )}\n <Box sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {line.name}\n {line.variantLabel ? ` — ${line.variantLabel}` : ''}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {line.unavailable\n ? 'No longer available'\n : usd(line.unitAmountCents)}\n </Typography>\n </Box>\n <TextField\n value={quantityDrafts[lineKey(line)] ?? line.quantity}\n onChange={(event) =>\n setQuantityDrafts((drafts) => ({\n ...drafts,\n [lineKey(line)]: event.target.value,\n }))\n }\n onBlur={() => commitQuantity(line)}\n onKeyDown={(event) => {\n if (event.key === 'Enter') commitQuantity(line)\n }}\n size=\"small\"\n sx={{ width: 60 }}\n slotProps={{ htmlInput: { inputMode: 'numeric' } }}\n />\n <Button\n size=\"small\"\n color=\"error\"\n onClick={() =>\n void onMutate({\n action: 'remove',\n productId: line.productId,\n variantId: line.variantId,\n })\n }\n >\n {'✕'}\n </Button>\n </Box>\n )\n })}\n <Box sx={{ display: 'flex', justifyContent: 'space-between' }}>\n <Typography variant=\"subtitle2\">{'Subtotal'}</Typography>\n <Typography variant=\"subtitle2\">{usd(cart.subtotalCents)}</Typography>\n </Box>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Shipping and taxes are calculated at checkout.'}\n </Typography>\n <TextField\n label=\"Email\"\n type=\"email\"\n value={email}\n onChange={(event) => setEmail(event.target.value)}\n size=\"small\"\n helperText=\"For your receipt and order updates\"\n />\n <FormControlLabel\n control={\n <Checkbox\n size=\"small\"\n checked={optIn}\n onChange={(event) => setOptIn(event.target.checked)}\n />\n }\n label={\n <Typography variant=\"caption\">\n {'Email me news and offers'}\n </Typography>\n }\n />\n {showCoupon ? (\n <>\n <TextField\n label=\"Coupon code\"\n value={coupon}\n onChange={(event) => setCoupon(event.target.value)}\n size=\"small\"\n />\n <TextField\n label=\"Gift card\"\n value={giftCard}\n onChange={(event) => setGiftCard(event.target.value)}\n size=\"small\"\n placeholder=\"GC-…\"\n />\n </>\n ) : null}\n {shipCountries ? (\n <TextField\n select\n label=\"Ship to\"\n value={shipTo}\n onChange={(event) => setShipTo(event.target.value)}\n size=\"small\"\n helperText=\"Shipping rates depend on where this is going\"\n >\n {shipCountries.map((code) => (\n <MenuItem key={code} value={code}>\n {CommerceModel.CHECKOUT_SHIPPING_COUNTRY_NAMES[code] ?? code}\n </MenuItem>\n ))}\n </TextField>\n ) : null}\n {status === 'paused' || status === 'ask' || status === 'unconfigured' ? (\n <Alert severity=\"info\">{message}</Alert>\n ) : null}\n {status === 'error' ? (\n <Alert severity=\"error\">\n {message || 'Checkout is unavailable right now.'}\n </Alert>\n ) : null}\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={\n status === 'sending' ||\n cart.lines.every((line) => line.unavailable) ||\n // No payments on this deployment: every further click gets the same\n // 501, so the control latches off rather than inviting a retry that\n // cannot succeed (AGL-2019).\n status === 'unconfigured' ||\n // Asked but unanswered: the server would only refuse again.\n (shipCountries !== null && !shipTo)\n }\n onClick={handleCheckout}\n >\n {status === 'sending'\n ? // \"Redirecting\" stops being true the moment the form opens in\n // place (AGL-1944).\n nativeCheckout\n ? 'Opening…'\n : 'Redirecting…'\n : checkoutLabel || 'Checkout'}\n </Button>\n {nativeCheckout ? (\n <Suspense fallback={<StorefrontPaymentElementFallback />}>\n <StorefrontPaymentElement\n clientSecret={nativeCheckout.clientSecret}\n publishableKey={nativeCheckout.publishableKey}\n payLabel={checkoutLabel || 'Pay now'}\n // The session is left open on cancel, deliberately: it is what the\n // AGL-323 abandoned-cart recovery emails are built on, and expiring\n // it would be a write against the merchant's Stripe account made\n // from a browser.\n onCancel={() => setNativeCheckout(null)}\n />\n </Suspense>\n ) : null}\n </Box>\n )\n}\n\n/**\n * Cart block (AGL-293): 'button' renders a badge icon + slide-out\n * drawer for app bars; 'inline' renders the full cart for a cart page.\n * Lines live server-side (cookie cart); every mutation re-resolves\n * prices. Other blocks broadcast CART_UPDATED_EVENT to refresh badges.\n */\nconst Cart = forwardRef<HTMLDivElement, CartProps>((props, ref) => {\n const { variant, checkoutLabel, showCoupon, emptyText, ...rest } = props\n // Node styles ride the renderer-merged sx; recompose (stack.ts pattern).\n const nodeSx = Array.isArray(props['sx']) ? props['sx'] : [props['sx']]\n const { hostId } = Aglyn.useSite()\n const siteFetch = Aglyn.useSiteFetch()\n const [cart, setCart] = useState<CartView | null>(null)\n const [open, setOpen] = useState(false)\n\n // Closes the merchant's ecommerce funnel (AGL-1641). Stripe returns a cart\n // checkout to the page it started on — this one — so the `purchase` that\n // `begin_checkout` above has never had a counterpart to is reported here.\n // No-ops on every ordinary render: the hook returns immediately unless the\n // URL carries `?order=success&session_id=…`.\n useStorefrontPurchaseEvent(hostId, siteFetch)\n\n const refresh = useCallback(async () => {\n if (!hostId) return\n try {\n const response = await fetch(\n `/api/commerce/cart?hostId=${encodeURIComponent(hostId)}`,\n )\n if (response.ok) setCart(await response.json())\n } catch {\n // Badge silently stays stale offline.\n }\n }, [hostId])\n\n useEffect(() => {\n void refresh()\n const handler = () => void refresh()\n window.addEventListener(CART_UPDATED_EVENT, handler)\n return () => window.removeEventListener(CART_UPDATED_EVENT, handler)\n }, [refresh])\n\n /**\n * Has THIS opening of the cart already been reported? A drawer that is\n * closed and reopened is a second view; a re-render, a badge refresh or a\n * quantity edit inside an already-open drawer is not.\n */\n const viewReported = useRef(false)\n\n /**\n * `view_cart` — the funnel step between `add_to_cart` and `begin_checkout`.\n *\n * Fired on the cart being SEEN, which is why it hangs off `open` rather off\n * mount: the button variant renders a badge on every page of a storefront,\n * and reporting a view there would have made \"opened the cart\" a synonym for\n * \"loaded a page\" and the checkout rate a fraction of pageviews.\n *\n * Deferred until the lines have actually arrived. The cart is fetched, so a\n * drawer opened while that request is in flight has nothing to describe yet\n * — reporting then would send an empty `items` and a zero `value` for a cart\n * that in fact had both. An empty cart never reports at all: there is no\n * view of nothing, and counting it would put every idle badge click into the\n * denominator of the checkout rate.\n */\n useEffect(() => {\n const onScreen = variant === 'inline' || open\n if (!onScreen) {\n viewReported.current = false\n return\n }\n if (viewReported.current || !cart || cart.lines.length === 0) return\n viewReported.current = true\n trackEvent(\n 'view_cart',\n buildViewCartParams({\n // The server's subtotal, so this and the `begin_checkout` the same\n // cart sends describe one cart at one size.\n value: cart.subtotalCents / 100,\n items: cartAnalyticsItems(cart),\n }),\n )\n }, [variant, open, cart])\n\n const mutate = useCallback(\n async (body: Record<string, unknown>) => {\n if (!hostId) return\n const response = await siteFetch('/api/commerce/cart', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, ...body }),\n })\n if (response.ok) {\n setCart(await response.json())\n window.dispatchEvent(new Event(CART_UPDATED_EVENT))\n }\n },\n [hostId, siteFetch],\n )\n\n if (!hostId) {\n return (\n <Box\n ref={ref}\n {...rest}\n sx={[\n {\n p: variant === 'inline' ? 3 : 1,\n border: '1px dashed',\n borderColor: 'divider',\n borderRadius: 1,\n color: 'text.secondary',\n fontSize: 13,\n fontFamily: 'system-ui, sans-serif',\n display: 'inline-block',\n },\n ...nodeSx,\n ]}\n >\n {variant === 'inline' ? 'Cart — lines render here' : '🛒 Cart'}\n </Box>\n )\n }\n\n if (variant === 'inline') {\n return (\n <Box ref={ref} {...rest}>\n <CartLines\n hostId={hostId}\n cart={cart}\n showCoupon={showCoupon}\n checkoutLabel={checkoutLabel}\n emptyText={emptyText}\n onMutate={mutate}\n />\n </Box>\n )\n }\n\n return (\n <Box ref={ref} {...rest} sx={[{ display: 'inline-flex' }, ...nodeSx]}>\n <IconButton aria-label=\"Cart\" onClick={() => setOpen(true)}>\n <Badge badgeContent={cart?.count ?? 0} color=\"primary\">\n <SvgIcon>\n <path d={mdiCartOutline.path} />\n </SvgIcon>\n </Badge>\n </IconButton>\n <Drawer anchor=\"right\" open={open} onClose={() => setOpen(false)}>\n <Box sx={{ width: { xs: '85vw', sm: 380 } }}>\n <Typography variant=\"h6\" sx={{ p: 2, pb: 0 }}>\n {'Your cart'}\n </Typography>\n <CartLines\n hostId={hostId}\n cart={cart}\n showCoupon={showCoupon}\n checkoutLabel={checkoutLabel}\n emptyText={emptyText}\n onMutate={mutate}\n />\n </Box>\n </Drawer>\n </Box>\n )\n})\nCart.displayName = 'AglynCart'\n\nexport const schema: Aglyn.ComponentSchema<CartProps> = {\n $id: ID,\n pluginId: BUNDLE_ID,\n displayName: 'Cart',\n description:\n 'The shopping cart — a badge icon with a slide-out drawer, or the full cart page.',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiCartOutline.path, sx: { color: '#2e7d32' } },\n flags: { selfClosing: Aglyn.FEATURE_FLAG.ENABLED },\n attributes: [\n {\n name: 'variant',\n label: 'Style',\n description: 'Icon-with-drawer for app bars, or the full inline cart.',\n component: Aglyn.FieldComponentType.SELECT,\n options: [\n { value: 'button', label: 'Icon + drawer' },\n { value: 'inline', label: 'Inline (cart page)' },\n ],\n },\n {\n name: 'checkoutLabel',\n label: 'Checkout label',\n description: 'Defaults to \"Checkout\".',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n {\n // The PROP KEY stays `showCoupon` — it is persisted in every saved page\n // that uses this component, and renaming it would blank the control on\n // all of them. Only what the merchant reads changes.\n name: 'showCoupon',\n // ONE CONTROL, TWO FEATURES, AND IT ONLY NAMED ONE. This checkbox gates\n // the gift-card field as well as the coupon field, so a merchant who\n // wanted gift cards had no reason to look here — gift cards are only\n // redeemable in the cart, and this is the switch that shows the box.\n // A control named for one feature that also gates another is how a\n // shipped feature stays invisible.\n label: 'Show coupon and gift card fields',\n description:\n 'One checkbox for both. Coupon codes and gift cards are managed on ' +\n 'the Products page.',\n component: Aglyn.FieldComponentType.CHECKBOX,\n },\n {\n name: 'emptyText',\n label: 'Empty text',\n description: 'Copy when the cart is empty.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n ],\n}\n\nexport const presets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(ID, 'button'),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Cart button',\n pluginId: BUNDLE_ID,\n description: 'Badge icon with a slide-out cart drawer',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiCartOutline.path, sx: { color: '#2e7d32' } },\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: { variant: 'button' },\n },\n },\n {\n $id: generatePresetId(ID, 'inline'),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Cart page',\n pluginId: BUNDLE_ID,\n description:\n 'Full cart with quantities, coupon, gift card, and checkout',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiCartOutline.path, sx: { color: '#2e7d32' } },\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: { variant: 'inline', showCoupon: true },\n },\n },\n]\n\nexport default Cart\n"],"names":["Aglyn","buildBeginCheckoutParams","buildViewCartParams","trackEvent","trackEventBeforeNavigation","isPaymentsNotConfigured","storefrontPaymentsNotConfiguredText","CommerceModel","mdiCartOutline","Alert","Badge","Box","Button","Checkbox","Drawer","FormControlLabel","IconButton","MenuItem","SvgIcon","TextField","Typography","Suspense","forwardRef","lazy","useCallback","useEffect","useMemo","useRef","useState","StorefrontPaymentElementFallback","StorefrontPaymentElement","then","module","default","BUNDLE_ID","generatePresetId","useStorefrontPurchaseEvent","ID","CART_UPDATED_EVENT","usd","cents","toFixed","cartAnalyticsItems","cart","lines","map","line","item_id","productId","item_name","name","price","unitAmountCents","quantity","CartLines","props","hostId","showCoupon","checkoutLabel","emptyText","onMutate","siteFetch","useSiteFetch","coupon","setCoupon","email","setEmail","optIn","setOptIn","giftCard","setGiftCard","shipTo","setShipTo","shipCountries","setShipCountries","status","setStatus","message","setMessage","nativeCheckout","setNativeCheckout","quantityDrafts","setQuantityDrafts","lineKey","variantId","commitQuantity","key","draft","undefined","settle","drafts","_settled","rest","trim","parsed","Math","round","Number","isFinite","max","action","finally","attemptKey","cartSignature","JSON","stringify","current","handleCheckout","globalThis","crypto","randomUUID","Date","now","random","toString","slice","response","method","headers","body","marketingOptIn","couponCode","giftCardCode","shippingCountry","payload","json","catch","ok","clientSecret","publishableKey","value","subtotalCents","items","String","url","window","location","assign","paused","parseLockdownRefusal","lockdownRefusalText","needsShippingCountry","shippingCountries","length","CHECKOUT_SHIPPING_COUNTRIES","error","variant","color","sx","p","display","flexDirection","gap","imageUrl","siteRelativeMediaSrc","alignItems","component","src","alt","width","height","objectFit","borderRadius","DEFERRED_IMAGE_ATTRIBUTES","bgcolor","flex","minWidth","noWrap","variantLabel","unavailable","onChange","event","target","onBlur","onKeyDown","size","slotProps","htmlInput","inputMode","onClick","justifyContent","label","type","helperText","control","checked","placeholder","select","code","CHECKOUT_SHIPPING_COUNTRY_NAMES","severity","disabled","every","fallback","payLabel","onCancel","Cart","ref","nodeSx","Array","isArray","useSite","setCart","open","setOpen","refresh","fetch","encodeURIComponent","handler","addEventListener","removeEventListener","viewReported","onScreen","mutate","dispatchEvent","Event","border","borderColor","fontSize","fontFamily","aria-label","badgeContent","count","path","d","anchor","onClose","xs","sm","pb","displayName","schema","$id","pluginId","description","category","ComponentCategory","COMMERCE","icon","flags","selfClosing","FEATURE_FLAG","ENABLED","attributes","FieldComponentType","SELECT","options","TEXT_FIELD","CHECKBOX","presets","NodeType","PRESET","data","componentId"],"mappings":";;;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SACEC,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,CAACC,MAAM;QAC3BrB,aAAa;QACbG,UAAUvM;QACVwM,aAAa;QACbC,UAAU3O,MAAM4O,iBAAiB,CAACC,QAAQ;QAC1CC,MAAM;YAAEf,MAAMvN,eAAeuN,IAAI;YAAE3E,IAAI;gBAAED,OAAO;YAAU;QAAE;QAC5DyG,MAAM;YACJpB,KAAK;YACLqB,aAAaxN;YACboM,UAAUvM;YACVqB,OAAO;gBAAE2F,SAAS;YAAS;QAC7B;IACF;IACA;QACEsF,KAAKrM,iBAAiBE,IAAI;QAC1BiJ,MAAMtL,MAAM0P,QAAQ,CAACC,MAAM;QAC3BrB,aAAa;QACbG,UAAUvM;QACVwM,aACE;QACFC,UAAU3O,MAAM4O,iBAAiB,CAACC,QAAQ;QAC1CC,MAAM;YAAEf,MAAMvN,eAAeuN,IAAI;YAAE3E,IAAI;gBAAED,OAAO;YAAU;QAAE;QAC5DyG,MAAM;YACJpB,KAAK;YACLqB,aAAaxN;YACboM,UAAUvM;YACVqB,OAAO;gBAAE2F,SAAS;gBAAUzF,YAAY;YAAK;QAC/C;IACF;CACD,CAAA;AAED,eAAe2I,KAAI"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/cart.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport {\n buildBeginCheckoutParams,\n buildViewCartParams,\n trackEvent,\n trackEventBeforeNavigation,\n type AnalyticsItem,\n} from '@aglyn/aglyn/app-utils/analytics-events'\nimport { isPaymentsNotConfigured } from '@aglyn/aglyn/app-utils/payments-configured'\nimport { storefrontPaymentsNotConfiguredText } from '../constants/storefront-payments'\nimport * as CommerceModel from '../model'\nimport { mdiCartOutline } from '@aglyn/shared-data-mdi'\nimport Alert from '@mui/material/Alert'\nimport Badge from '@mui/material/Badge'\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Checkbox from '@mui/material/Checkbox'\nimport Drawer from '@mui/material/Drawer'\nimport FormControlLabel from '@mui/material/FormControlLabel'\nimport IconButton from '@mui/material/IconButton'\nimport MenuItem from '@mui/material/MenuItem'\nimport SvgIcon from '@mui/material/SvgIcon'\nimport TextField from '@mui/material/TextField'\nimport Typography from '@mui/material/Typography'\nimport {\n Suspense,\n forwardRef,\n lazy,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\nimport { StorefrontPaymentElementFallback } from './storefront-payment-element-fallback'\nimport { CheckoutReturnNotice } from './checkout-return-notice'\nimport { CartExtras, useCartExtras } from './cart-extras'\n\n/**\n * The Payment Element (AGL-1944), lazily. Stripe.js and its React wrapper are\n * a large dependency and the flag is OFF, so a static import would ship the\n * whole SDK in the bundle of every page carrying a cart — which is most pages\n * on a storefront — to serve a path no shopper currently reaches.\n */\nconst StorefrontPaymentElement = lazy(() =>\n import('./storefront-payment-element').then((module) => ({\n default: module.StorefrontPaymentElement,\n })),\n)\nimport { BUNDLE_ID } from '../constants/bundle-common'\nimport { generatePresetId } from '../utils/generate-preset-id'\nimport { useStorefrontPurchaseEvent } from '../utils/use-storefront-purchase-event'\n\n// Component ids are persisted in screen documents; never rename.\nexport const ID: Aglyn.ComponentId = 'cart'\n\n/** Blocks dispatch this after mutating the cart so badges refresh. */\nexport const CART_UPDATED_EVENT = 'aglyn:cart-updated'\n\nexport interface CartProps {\n /** 'button' = app-bar icon + drawer; 'inline' = full cart in place. */\n variant?: 'button' | 'inline'\n checkoutLabel?: string\n /** Show the coupon-code field above checkout. */\n showCoupon?: boolean\n emptyText?: string\n}\n\ninterface CartLineView {\n productId: string\n variantId?: string\n quantity: number\n name: string\n variantLabel?: string\n unitAmountCents: number\n imageUrl?: string\n unavailable?: boolean\n}\n\ninterface CartView {\n lines: CartLineView[]\n count: number\n subtotalCents: number\n}\n\nconst usd = (cents: number) => `$${(cents / 100).toFixed(2)}`\n\n/**\n * The cart's lines as GA4 `items`.\n *\n * One mapping for every event this file sends — `view_cart` and both\n * `begin_checkout` branches — because the `item_id` is what joins them into a\n * single per-product funnel with the `view_item` and `add_to_cart` the product\n * blocks send. Three hand-written copies of the same map are three chances for\n * one step to start reporting a variant id, or a name, or a different price\n * basis, and a funnel whose steps disagree about the product silently reports\n * a drop that never happened.\n */\nfunction cartAnalyticsItems(cart: CartView | null): AnalyticsItem[] {\n return (cart?.lines ?? []).map((line) => ({\n item_id: line.productId,\n item_name: line.name,\n price: line.unitAmountCents / 100,\n quantity: line.quantity,\n }))\n}\n\nfunction CartLines(props: {\n hostId: string\n cart: CartView | null\n showCoupon?: boolean\n checkoutLabel?: string\n emptyText?: string\n onMutate: (body: Record<string, unknown>) => Promise<void>\n}) {\n const { hostId, cart, showCoupon, checkoutLabel, emptyText, onMutate } =\n props\n const siteFetch = Aglyn.useSiteFetch()\n const [coupon, setCoupon] = useState('')\n const [email, setEmail] = useState('')\n const [optIn, setOptIn] = useState(false)\n const [giftCard, setGiftCard] = useState('')\n // Where the parcel is going (AGL-1721). Asked ONLY when the server says it\n // cannot price shipping without it — a merchant with one zone, one\n // rest-of-world zone, or no shipping at all never sees this field, which is\n // the common configuration. `null` is \"not asked\", so the field appearing is\n // itself the server's answer rather than a guess made here.\n const [shipTo, setShipTo] = useState('')\n const [shipCountries, setShipCountries] = useState<string[] | null>(null)\n // Live carrier rates price by postal code (AGL-3612): asked only when the\n // store prices that way and the server says so.\n const [shipPostal, setShipPostal] = useState('')\n const [askPostal, setAskPostal] = useState(false)\n // `paused` is its own state, not an `error` with gentler words (AGL-1511):\n // the two need different severities, and a shopper told in red that\n // checkout failed does not read the sentence explaining it did not. `ask` is\n // the same argument again: being asked for a destination is not a failure.\n // `unconfigured` is the third instance (AGL-2019): a store with no Stripe key\n // answers 501, and before this that fell through to the error tail below and\n // rendered RED. It is also the only one of the five that is TERMINAL — the\n // others can succeed on a retry, this one cannot until the operator acts, so\n // it latches the buy control off instead of inviting another click.\n const [status, setStatus] = useState<\n 'idle' | 'sending' | 'error' | 'paused' | 'ask' | 'unconfigured'\n >('idle')\n const [message, setMessage] = useState('')\n /**\n * The in-page checkout session (AGL-1944). Null unless the server chose\n * native mode, which needs both the release flag and a publishable key.\n */\n const [nativeCheckout, setNativeCheckout] = useState<{\n clientSecret: string\n publishableKey: string\n /** The wallets the merchant hid (AGL-3629). */\n wallets?: CommerceModel.StorefrontCheckoutWallets\n } | null>(null)\n /**\n * In-progress quantity edits, keyed by line, as the raw field text\n * (AGL-1772). The field used to POST /api/commerce/cart on every\n * keystroke — typing \"100\" was three Firestore writes, and clearing the\n * field to retype passed through `\"\"` → 0, which is the REMOVE path, so a\n * select-all-and-retype could delete the line mid-edit (and the response\n * replacing `cart` state then fought the input).\n *\n * The repo convention for quantity inputs is local state committed on an\n * explicit settle — the PDP's Qty field (product-detail.tsx) holds\n * `useState` and sends nothing until the buy click, and besigner\n * attributes commit on blur. So: keystrokes only edit the draft; blur or\n * Enter commits ONE write; an empty or unparsable draft is a pending\n * state that reverts to the server's quantity, never a 0-as-remove. A\n * genuine remove still works both ways — the ✕ button, and typing an\n * actual 0 then leaving the field.\n */\n const [quantityDrafts, setQuantityDrafts] = useState<Record<string, string>>(\n {},\n )\n const lineKey = (line: CartLineView) =>\n `${line.productId}:${line.variantId ?? ''}`\n const commitQuantity = (line: CartLineView) => {\n const key = lineKey(line)\n const draft = quantityDrafts[key]\n if (draft === undefined) return\n // Drops the draft, but only if it is still THIS one — a keystroke that\n // lands while the write is in flight starts a new edit, and clearing it\n // here would erase what the shopper is typing.\n const settle = () =>\n setQuantityDrafts((drafts) => {\n if (drafts[key] !== draft) return drafts\n const { [key]: _settled, ...rest } = drafts\n return rest\n })\n // `Number('')` is 0 — exactly the misreading that turned a cleared\n // field into a remove. Empty means \"no answer\": show the server's\n // quantity again and write nothing. NaN (letters) reverts the same way.\n if (draft.trim() === '') return settle()\n const parsed = Math.round(Number(draft))\n if (!Number.isFinite(parsed)) return settle()\n const quantity = Math.max(0, parsed)\n // A settled value equal to the server's is not an edit.\n if (quantity === line.quantity) return settle()\n // The draft keeps rendering until the response lands, so the field does\n // not flash the superseded quantity during the round-trip; the server's\n // answer (via the replaced `cart`) takes over when it arrives.\n void onMutate({\n action: 'set',\n productId: line.productId,\n variantId: line.variantId,\n quantity,\n }).finally(settle)\n }\n\n /**\n * Idempotency key for ONE checkout attempt (AGL-1697).\n *\n * Minted lazily on the first checkout click, retired whenever the attempt\n * changes shape — different lines, codes, email or destination are a\n * different checkout. Keyed off a CONTENT signature of the lines rather\n * than the `cart` object, whose identity changes on every refetch: retiring\n * on identity would hand a genuine retry a fresh key, which is exactly the\n * double-session this exists to prevent.\n */\n const attemptKey = useRef('')\n const cartSignature = useMemo(\n () =>\n JSON.stringify(\n (cart?.lines ?? []).map((line) => [\n line.productId,\n line.variantId ?? '',\n line.quantity,\n ]),\n ),\n [cart],\n )\n // Optional lines another plugin offers (AGL-3635), asked while the cart is shown.\n const extras = useCartExtras(hostId, cartSignature)\n const extrasSignature = extras.chosenIds.join(',')\n useEffect(() => {\n attemptKey.current = ''\n }, [cartSignature, email, coupon, giftCard, shipTo, shipPostal, extrasSignature])\n\n const handleCheckout = useCallback(async () => {\n if (status === 'sending') return\n setStatus('sending')\n setMessage('')\n if (!attemptKey.current) {\n attemptKey.current =\n globalThis.crypto?.randomUUID?.() ??\n `${Date.now()}-${Math.random().toString(36).slice(2)}`\n }\n try {\n const response = await siteFetch('/api/commerce/cart-checkout', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n // Stable across a retry of THIS attempt (AGL-1697), so a\n // double-click cannot spawn a second session from one cart.\n 'Idempotency-Key': attemptKey.current,\n },\n body: JSON.stringify({\n hostId,\n ...(email.trim() ? { email: email.trim() } : {}),\n ...(optIn ? { marketingOptIn: true } : {}),\n ...(coupon.trim() ? { couponCode: coupon.trim() } : {}),\n ...(giftCard.trim() ? { giftCardCode: giftCard.trim() } : {}),\n // A request, never an instruction: the server resolves the rates\n // for this country AND restricts the session's collectable\n // addresses to it, so declaring one cannot buy a cheaper zone's\n // rate than the address the shopper then enters (AGL-1721).\n ...(shipTo ? { shippingCountry: shipTo } : {}),\n ...(shipPostal.trim() ? { shippingPostalCode: shipPostal.trim() } : {}),\n // Which offers, never their price: the server asks the provider again.\n ...(extras.chosenIds.length ? { extras: extras.chosenIds } : {}),\n }),\n })\n const payload = await response.json().catch(() => ({}))\n // In-page payment (AGL-1944). Checked BEFORE the redirect branch: a\n // native session carries a client secret and no url, and if a server ever\n // sent both, navigating away would silently discard the form.\n //\n // `begin_checkout` is reported on BOTH paths, and from the same place, so\n // the GA4 funnel does not develop a hole the day the flag flips — a\n // storefront whose `begin_checkout` count halved would look like a\n // conversion collapse rather than a checkout that stopped redirecting.\n if (response.ok && payload?.clientSecret && payload?.publishableKey) {\n trackEvent(\n 'begin_checkout',\n buildBeginCheckoutParams({\n value: (cart?.subtotalCents ?? 0) / 100,\n items: cartAnalyticsItems(cart),\n }),\n )\n setNativeCheckout({\n clientSecret: String(payload.clientSecret),\n publishableKey: String(payload.publishableKey),\n wallets: CommerceModel.readStorefrontCheckoutWallets(payload.wallets),\n })\n setStatus('idle')\n return\n }\n if (response.ok && payload?.url) {\n // GA4 checkout funnel (AGL-1561, converted by AGL-1591). This used to\n // call `window.gtag` raw with `value`/`currency` only, so the same\n // event name arrived from this surface and from the console's plan\n // checkout in two different shapes — and this half carried no `items`,\n // which is the field GA4's ecommerce funnel is actually built on.\n //\n // The item ids are the PRODUCT ids `view_item` and `add_to_cart`\n // already send, so the three now join into one per-product funnel.\n // `value` is stated rather than derived because the cart subtotal is\n // authoritative after a coupon or gift card, which the line prices\n // below are not. No `billing_interval`: a storefront cart is not a\n // subscription.\n //\n // AWAITED before the redirect (AGL-1580). This surface registers no\n // transport, so delivery is a synchronous `window.gtag` call and the\n // await resolves immediately — a storefront checkout is not slowed by\n // one microtask. It is written this way anyway because the property\n // that makes it safe is invisible from here: the day this bundle grows\n // an async transport, or a host registers one for it, the bare call\n // would start losing the event on exactly the branch that navigates,\n // and nothing at this call site would look different.\n await trackEventBeforeNavigation(\n 'begin_checkout',\n buildBeginCheckoutParams({\n value: (cart?.subtotalCents ?? 0) / 100,\n items: cartAnalyticsItems(cart),\n }),\n )\n window.location.assign(payload.url)\n return\n }\n // A read-only lockdown answers 423 with the visitor pause copy\n // (AGL-1511). Rendering `payload.error` here would print the wire\n // token \"locked\" at a shopper, and the `severity=\"error\"` styling\n // would tell them their payment failed — the one thing this copy\n // exists to never say. So the refusal is parsed and shown as a calm\n // notice instead.\n const paused = Aglyn.parseLockdownRefusal(response.status, payload)\n if (paused) {\n setMessage(Aglyn.lockdownRefusalText(paused))\n setStatus('paused')\n return\n }\n // A store that never had payments configured (AGL-2019). The server's\n // own words are NOT rendered here even though they are safe today:\n // this is a visitor-facing surface, the 501 bodies differ between the\n // cart and buy-now doors, and one of them could grow a variable name\n // without anyone thinking about who reads it.\n // An offer the shopper ticked changed or went away (AGL-3635): show\n // what is offered now and let them decide again.\n if (payload?.extrasChanged) {\n extras.reload()\n setMessage(String(payload?.error ?? ''))\n setStatus('error')\n return\n }\n if (isPaymentsNotConfigured(response.status)) {\n setMessage(storefrontPaymentsNotConfiguredText())\n setStatus('unconfigured')\n return\n }\n // The merchant's rates differ by destination, so the server will not\n // price this cart until it knows one (AGL-1721). Reveal the field and\n // let the shopper answer; a store that never sends this never shows it.\n if (payload?.needsShippingCountry) {\n if (payload?.needsShippingPostalCode) setAskPostal(true)\n setShipCountries(\n (payload.shippingCountries as string[] | undefined)?.length\n ? (payload.shippingCountries as string[])\n : [...CommerceModel.CHECKOUT_SHIPPING_COUNTRIES],\n )\n setMessage(String(payload?.error ?? ''))\n // An unserved destination is a real refusal and reads as one; being\n // asked the first time is not.\n setStatus(shipTo ? 'error' : 'ask')\n return\n }\n setMessage(String(payload?.error ?? ''))\n setStatus('error')\n } catch {\n setStatus('error')\n }\n // `cart` is a dependency because the payload above reads it: without it\n // the handler closes over whichever cart was current when it was created,\n // and a checkout started after a quantity change would report the OLD\n // subtotal and the OLD lines. The pre-AGL-1591 raw call had the same bug\n // in the `value` alone, where a wrong number is indistinguishable from a\n // right one.\n }, [hostId, cart, coupon, email, optIn, giftCard, shipTo, shipPostal, status, siteFetch, extras.chosenIds, extras.reload])\n\n if (!cart || cart.lines.length === 0) {\n return (\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ p: 2 }}>\n {emptyText || 'Your cart is empty.'}\n </Typography>\n )\n }\n return (\n <Box sx={{ display: 'flex', flexDirection: 'column', gap: 1.5, p: 2 }}>\n {cart.lines.map((line) => {\n // AGL-1726: resolve BEFORE the guard, never inside the `src`. A\n // stored value can be truthy and still resolve to nothing (a\n // malformed `media:` reference), and testing the raw string would\n // turn \"no image\" into an `<img>` with no `src` — a broken-image\n // icon where the placeholder belongs.\n const imageUrl = Aglyn.siteRelativeMediaSrc(line.imageUrl, { hostId })\n return (\n <Box\n key={`${line.productId}:${line.variantId ?? ''}`}\n sx={{ display: 'flex', gap: 1.5, alignItems: 'center' }}\n >\n {imageUrl ? (\n <Box\n component=\"img\"\n src={imageUrl}\n alt=\"\"\n sx={{\n width: 48,\n height: 48,\n objectFit: 'cover',\n borderRadius: 1,\n }}\n // Deferred (AGL-2486). A 48px cart-line thumbnail is the\n // clearest case of the set: it can never be the LCP, and a\n // cart is usually below the fold or inside a panel.\n {...Aglyn.DEFERRED_IMAGE_ATTRIBUTES}\n />\n ) : (\n <Box\n sx={{\n width: 48,\n height: 48,\n bgcolor: 'action.hover',\n borderRadius: 1,\n }}\n />\n )}\n <Box sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {line.name}\n {line.variantLabel ? ` — ${line.variantLabel}` : ''}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {line.unavailable\n ? 'No longer available'\n : usd(line.unitAmountCents)}\n </Typography>\n </Box>\n <TextField\n value={quantityDrafts[lineKey(line)] ?? line.quantity}\n onChange={(event) =>\n setQuantityDrafts((drafts) => ({\n ...drafts,\n [lineKey(line)]: event.target.value,\n }))\n }\n onBlur={() => commitQuantity(line)}\n onKeyDown={(event) => {\n if (event.key === 'Enter') commitQuantity(line)\n }}\n size=\"small\"\n sx={{ width: 60 }}\n slotProps={{ htmlInput: { inputMode: 'numeric' } }}\n />\n <Button\n size=\"small\"\n color=\"error\"\n onClick={() =>\n void onMutate({\n action: 'remove',\n productId: line.productId,\n variantId: line.variantId,\n })\n }\n >\n {'✕'}\n </Button>\n </Box>\n )\n })}\n <Box sx={{ display: 'flex', justifyContent: 'space-between' }}>\n <Typography variant=\"subtitle2\">{'Subtotal'}</Typography>\n <Typography variant=\"subtitle2\">{usd(cart.subtotalCents)}</Typography>\n </Box>\n <CartExtras\n offers={extras.offers}\n chosen={extras.chosen}\n onToggle={extras.toggle}\n formatCents={usd}\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Shipping and taxes are calculated at checkout.'}\n </Typography>\n <TextField\n label=\"Email\"\n type=\"email\"\n value={email}\n onChange={(event) => setEmail(event.target.value)}\n size=\"small\"\n helperText=\"For your receipt and order updates\"\n />\n <FormControlLabel\n control={\n <Checkbox\n size=\"small\"\n checked={optIn}\n onChange={(event) => setOptIn(event.target.checked)}\n />\n }\n label={\n <Typography variant=\"caption\">\n {'Email me news and offers'}\n </Typography>\n }\n />\n {showCoupon ? (\n <>\n <TextField\n label=\"Coupon code\"\n value={coupon}\n onChange={(event) => setCoupon(event.target.value)}\n size=\"small\"\n />\n <TextField\n label=\"Gift card\"\n value={giftCard}\n onChange={(event) => setGiftCard(event.target.value)}\n size=\"small\"\n placeholder=\"GC-…\"\n />\n </>\n ) : null}\n {shipCountries ? (\n <TextField\n select\n label=\"Ship to\"\n value={shipTo}\n onChange={(event) => setShipTo(event.target.value)}\n size=\"small\"\n helperText=\"Shipping rates depend on where this is going\"\n >\n {shipCountries.map((code) => (\n <MenuItem key={code} value={code}>\n {CommerceModel.CHECKOUT_SHIPPING_COUNTRY_NAMES[code] ?? code}\n </MenuItem>\n ))}\n </TextField>\n ) : null}\n {askPostal ? (\n <TextField\n label=\"Postal code\"\n value={shipPostal}\n onChange={(event) => setShipPostal(event.target.value)}\n size=\"small\"\n helperText=\"Carrier rates depend on the postal code\"\n slotProps={{ htmlInput: { autoComplete: 'shipping postal-code', maxLength: 12 } }}\n />\n ) : null}\n {status === 'paused' || status === 'ask' || status === 'unconfigured' ? (\n <Alert severity=\"info\">{message}</Alert>\n ) : null}\n {status === 'error' ? (\n <Alert severity=\"error\">\n {message || 'Checkout is unavailable right now.'}\n </Alert>\n ) : null}\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={\n status === 'sending' ||\n cart.lines.every((line) => line.unavailable) ||\n // No payments on this deployment: every further click gets the same\n // 501, so the control latches off rather than inviting a retry that\n // cannot succeed (AGL-2019).\n status === 'unconfigured' ||\n // Asked but unanswered: the server would only refuse again.\n (shipCountries !== null && !shipTo) ||\n (askPostal && !shipPostal.trim())\n }\n onClick={handleCheckout}\n >\n {status === 'sending'\n ? // \"Redirecting\" stops being true the moment the form opens in\n // place (AGL-1944).\n nativeCheckout\n ? 'Opening…'\n : 'Redirecting…'\n : checkoutLabel || 'Checkout'}\n </Button>\n {nativeCheckout ? (\n <Suspense fallback={<StorefrontPaymentElementFallback />}>\n <StorefrontPaymentElement\n clientSecret={nativeCheckout.clientSecret}\n publishableKey={nativeCheckout.publishableKey}\n wallets={nativeCheckout.wallets}\n payLabel={checkoutLabel || 'Pay now'}\n defaultEmail={email}\n // An expired or unloadable session is replaced, never replayed:\n // the old attempt key would hand back the dead session.\n onRestart={() => {\n attemptKey.current = ''\n setNativeCheckout(null)\n void handleCheckout()\n }}\n // The session is left open on cancel, deliberately: it is what the\n // AGL-323 abandoned-cart recovery emails are built on, and expiring\n // it would be a write against the merchant's Stripe account made\n // from a browser.\n onCancel={() => setNativeCheckout(null)}\n />\n </Suspense>\n ) : null}\n </Box>\n )\n}\n\n/**\n * Cart block (AGL-293): 'button' renders a badge icon + slide-out\n * drawer for app bars; 'inline' renders the full cart for a cart page.\n * Lines live server-side (cookie cart); every mutation re-resolves\n * prices. Other blocks broadcast CART_UPDATED_EVENT to refresh badges.\n */\nconst Cart = forwardRef<HTMLDivElement, CartProps>((props, ref) => {\n const { variant, checkoutLabel, showCoupon, emptyText, ...rest } = props\n // Node styles ride the renderer-merged sx; recompose (stack.ts pattern).\n const nodeSx = Array.isArray(props['sx']) ? props['sx'] : [props['sx']]\n const { hostId } = Aglyn.useSite()\n const siteFetch = Aglyn.useSiteFetch()\n const [cart, setCart] = useState<CartView | null>(null)\n const [open, setOpen] = useState(false)\n\n // Closes the merchant's ecommerce funnel (AGL-1641). Stripe returns a cart\n // checkout to the page it started on — this one — so the `purchase` that\n // `begin_checkout` above has never had a counterpart to is reported here.\n // No-ops on every ordinary render: the hook returns immediately unless the\n // URL carries `?order=success&session_id=…`.\n useStorefrontPurchaseEvent(hostId, siteFetch)\n\n const refresh = useCallback(async () => {\n if (!hostId) return\n try {\n const response = await fetch(\n `/api/commerce/cart?hostId=${encodeURIComponent(hostId)}`,\n )\n if (response.ok) setCart(await response.json())\n } catch {\n // Badge silently stays stale offline.\n }\n }, [hostId])\n\n useEffect(() => {\n void refresh()\n const handler = () => void refresh()\n window.addEventListener(CART_UPDATED_EVENT, handler)\n return () => window.removeEventListener(CART_UPDATED_EVENT, handler)\n }, [refresh])\n\n /**\n * Has THIS opening of the cart already been reported? A drawer that is\n * closed and reopened is a second view; a re-render, a badge refresh or a\n * quantity edit inside an already-open drawer is not.\n */\n const viewReported = useRef(false)\n\n /**\n * `view_cart` — the funnel step between `add_to_cart` and `begin_checkout`.\n *\n * Fired on the cart being SEEN, which is why it hangs off `open` rather off\n * mount: the button variant renders a badge on every page of a storefront,\n * and reporting a view there would have made \"opened the cart\" a synonym for\n * \"loaded a page\" and the checkout rate a fraction of pageviews.\n *\n * Deferred until the lines have actually arrived. The cart is fetched, so a\n * drawer opened while that request is in flight has nothing to describe yet\n * — reporting then would send an empty `items` and a zero `value` for a cart\n * that in fact had both. An empty cart never reports at all: there is no\n * view of nothing, and counting it would put every idle badge click into the\n * denominator of the checkout rate.\n */\n useEffect(() => {\n const onScreen = variant === 'inline' || open\n if (!onScreen) {\n viewReported.current = false\n return\n }\n if (viewReported.current || !cart || cart.lines.length === 0) return\n viewReported.current = true\n trackEvent(\n 'view_cart',\n buildViewCartParams({\n // The server's subtotal, so this and the `begin_checkout` the same\n // cart sends describe one cart at one size.\n value: cart.subtotalCents / 100,\n items: cartAnalyticsItems(cart),\n }),\n )\n }, [variant, open, cart])\n\n const mutate = useCallback(\n async (body: Record<string, unknown>) => {\n if (!hostId) return\n const response = await siteFetch('/api/commerce/cart', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, ...body }),\n })\n if (response.ok) {\n setCart(await response.json())\n window.dispatchEvent(new Event(CART_UPDATED_EVENT))\n }\n },\n [hostId, siteFetch],\n )\n\n if (!hostId) {\n return (\n <Box\n ref={ref}\n {...rest}\n sx={[\n {\n p: variant === 'inline' ? 3 : 1,\n border: '1px dashed',\n borderColor: 'divider',\n borderRadius: 1,\n color: 'text.secondary',\n fontSize: 13,\n fontFamily: 'system-ui, sans-serif',\n display: 'inline-block',\n },\n ...nodeSx,\n ]}\n >\n {variant === 'inline' ? 'Cart — lines render here' : '🛒 Cart'}\n </Box>\n )\n }\n\n if (variant === 'inline') {\n return (\n <Box ref={ref} {...rest}>\n <CheckoutReturnNotice hostId={hostId} siteFetch={siteFetch} />\n <CartLines\n hostId={hostId}\n cart={cart}\n showCoupon={showCoupon}\n checkoutLabel={checkoutLabel}\n emptyText={emptyText}\n onMutate={mutate}\n />\n </Box>\n )\n }\n\n return (\n <Box ref={ref} {...rest} sx={[{ display: 'inline-flex' }, ...nodeSx]}>\n <CheckoutReturnNotice hostId={hostId} siteFetch={siteFetch} />\n <IconButton aria-label=\"Cart\" onClick={() => setOpen(true)}>\n <Badge badgeContent={cart?.count ?? 0} color=\"primary\">\n <SvgIcon>\n <path d={mdiCartOutline.path} />\n </SvgIcon>\n </Badge>\n </IconButton>\n <Drawer anchor=\"right\" open={open} onClose={() => setOpen(false)}>\n <Box sx={{ width: { xs: '85vw', sm: 380 } }}>\n <Typography variant=\"h6\" sx={{ p: 2, pb: 0 }}>\n {'Your cart'}\n </Typography>\n <CartLines\n hostId={hostId}\n cart={cart}\n showCoupon={showCoupon}\n checkoutLabel={checkoutLabel}\n emptyText={emptyText}\n onMutate={mutate}\n />\n </Box>\n </Drawer>\n </Box>\n )\n})\nCart.displayName = 'AglynCart'\n\nexport const schema: Aglyn.ComponentSchema<CartProps> = {\n $id: ID,\n pluginId: BUNDLE_ID,\n displayName: 'Cart',\n description:\n 'The shopping cart — a badge icon with a slide-out drawer, or the full cart page.',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiCartOutline.path, sx: { color: '#2e7d32' } },\n flags: { selfClosing: Aglyn.FEATURE_FLAG.ENABLED },\n attributes: [\n {\n name: 'variant',\n label: 'Style',\n description: 'Icon-with-drawer for app bars, or the full inline cart.',\n component: Aglyn.FieldComponentType.SELECT,\n options: [\n { value: 'button', label: 'Icon + drawer' },\n { value: 'inline', label: 'Inline (cart page)' },\n ],\n },\n {\n name: 'checkoutLabel',\n label: 'Checkout label',\n description: 'Defaults to \"Checkout\".',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n {\n // The PROP KEY stays `showCoupon` — it is persisted in every saved page\n // that uses this component, and renaming it would blank the control on\n // all of them. Only what the merchant reads changes.\n name: 'showCoupon',\n // ONE CONTROL, TWO FEATURES, AND IT ONLY NAMED ONE. This checkbox gates\n // the gift-card field as well as the coupon field, so a merchant who\n // wanted gift cards had no reason to look here — gift cards are only\n // redeemable in the cart, and this is the switch that shows the box.\n // A control named for one feature that also gates another is how a\n // shipped feature stays invisible.\n label: 'Show coupon and gift card fields',\n description:\n 'One checkbox for both. Coupon codes and gift cards are managed on ' +\n 'the Products page.',\n component: Aglyn.FieldComponentType.CHECKBOX,\n },\n {\n name: 'emptyText',\n label: 'Empty text',\n description: 'Copy when the cart is empty.',\n component: Aglyn.FieldComponentType.TEXT_FIELD,\n },\n ],\n}\n\nexport const presets: Aglyn.PresetSchema[] = [\n {\n $id: generatePresetId(ID, 'button'),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Cart button',\n pluginId: BUNDLE_ID,\n description: 'Badge icon with a slide-out cart drawer',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiCartOutline.path, sx: { color: '#2e7d32' } },\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: { variant: 'button' },\n },\n },\n {\n $id: generatePresetId(ID, 'inline'),\n type: Aglyn.NodeType.PRESET,\n displayName: 'Cart page',\n pluginId: BUNDLE_ID,\n description:\n 'Full cart with quantities, coupon, gift card, and checkout',\n category: Aglyn.ComponentCategory.COMMERCE,\n icon: { path: mdiCartOutline.path, sx: { color: '#2e7d32' } },\n data: {\n $id: null,\n componentId: ID,\n pluginId: BUNDLE_ID,\n props: { variant: 'inline', showCoupon: true },\n },\n },\n]\n\nexport default Cart\n"],"names":["Aglyn","buildBeginCheckoutParams","buildViewCartParams","trackEvent","trackEventBeforeNavigation","isPaymentsNotConfigured","storefrontPaymentsNotConfiguredText","CommerceModel","mdiCartOutline","Alert","Badge","Box","Button","Checkbox","Drawer","FormControlLabel","IconButton","MenuItem","SvgIcon","TextField","Typography","Suspense","forwardRef","lazy","useCallback","useEffect","useMemo","useRef","useState","StorefrontPaymentElementFallback","CheckoutReturnNotice","CartExtras","useCartExtras","StorefrontPaymentElement","then","module","default","BUNDLE_ID","generatePresetId","useStorefrontPurchaseEvent","ID","CART_UPDATED_EVENT","usd","cents","toFixed","cartAnalyticsItems","cart","lines","map","line","item_id","productId","item_name","name","price","unitAmountCents","quantity","CartLines","props","hostId","showCoupon","checkoutLabel","emptyText","onMutate","siteFetch","useSiteFetch","coupon","setCoupon","email","setEmail","optIn","setOptIn","giftCard","setGiftCard","shipTo","setShipTo","shipCountries","setShipCountries","shipPostal","setShipPostal","askPostal","setAskPostal","status","setStatus","message","setMessage","nativeCheckout","setNativeCheckout","quantityDrafts","setQuantityDrafts","lineKey","variantId","commitQuantity","key","draft","undefined","settle","drafts","_settled","rest","trim","parsed","Math","round","Number","isFinite","max","action","finally","attemptKey","cartSignature","JSON","stringify","extras","extrasSignature","chosenIds","join","current","handleCheckout","globalThis","crypto","randomUUID","Date","now","random","toString","slice","response","method","headers","body","marketingOptIn","couponCode","giftCardCode","shippingCountry","shippingPostalCode","length","payload","json","catch","ok","clientSecret","publishableKey","value","subtotalCents","items","String","wallets","readStorefrontCheckoutWallets","url","window","location","assign","paused","parseLockdownRefusal","lockdownRefusalText","extrasChanged","reload","error","needsShippingCountry","needsShippingPostalCode","shippingCountries","CHECKOUT_SHIPPING_COUNTRIES","variant","color","sx","p","display","flexDirection","gap","imageUrl","siteRelativeMediaSrc","alignItems","component","src","alt","width","height","objectFit","borderRadius","DEFERRED_IMAGE_ATTRIBUTES","bgcolor","flex","minWidth","noWrap","variantLabel","unavailable","onChange","event","target","onBlur","onKeyDown","size","slotProps","htmlInput","inputMode","onClick","justifyContent","offers","chosen","onToggle","toggle","formatCents","label","type","helperText","control","checked","placeholder","select","code","CHECKOUT_SHIPPING_COUNTRY_NAMES","autoComplete","maxLength","severity","disabled","every","fallback","payLabel","defaultEmail","onRestart","onCancel","Cart","ref","nodeSx","Array","isArray","useSite","setCart","open","setOpen","refresh","fetch","encodeURIComponent","handler","addEventListener","removeEventListener","viewReported","onScreen","mutate","dispatchEvent","Event","border","borderColor","fontSize","fontFamily","aria-label","badgeContent","count","path","d","anchor","onClose","xs","sm","pb","displayName","schema","$id","pluginId","description","category","ComponentCategory","COMMERCE","icon","flags","selfClosing","FEATURE_FLAG","ENABLED","attributes","FieldComponentType","SELECT","options","TEXT_FIELD","CHECKBOX","presets","NodeType","PRESET","data","componentId"],"mappings":";;;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SACEC,wBAAwB,EACxBC,mBAAmB,EACnBC,UAAU,EACVC,0BAA0B,QAErB,0CAAyC;AAChD,SAASC,uBAAuB,QAAQ,6CAA4C;AACpF,SAASC,mCAAmC,QAAQ,sCAAkC;AACtF,YAAYC,mBAAmB,oBAAU;AACzC,SAASC,cAAc,QAAQ,yBAAwB;AACvD,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,SAAS,oBAAmB;AACnC,OAAOC,YAAY,uBAAsB;AACzC,OAAOC,cAAc,yBAAwB;AAC7C,OAAOC,YAAY,uBAAsB;AACzC,OAAOC,sBAAsB,iCAAgC;AAC7D,OAAOC,gBAAgB,2BAA0B;AACjD,OAAOC,cAAc,yBAAwB;AAC7C,OAAOC,aAAa,wBAAuB;AAC3C,OAAOC,eAAe,0BAAyB;AAC/C,OAAOC,gBAAgB,2BAA0B;AACjD,SACEC,QAAQ,EACRC,UAAU,EACVC,IAAI,EACJC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,QAAO;AACd,SAASC,gCAAgC,QAAQ,2CAAuC;AACxF,SAASC,oBAAoB,QAAQ,8BAA0B;AAC/D,SAASC,UAAU,EAAEC,aAAa,QAAQ,mBAAe;AAEzD;;;;;CAKC,GACD,MAAMC,yCAA2BV,KAAK,IACpC,MAAM,CAAC,mCAAgCW,IAAI,CAAC,CAACC,SAAY,CAAA;YACvDC,SAASD,OAAOF,wBAAwB;QAC1C,CAAA;AAEF,SAASI,SAAS,QAAQ,gCAA4B;AACtD,SAASC,gBAAgB,QAAQ,i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
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Tells a shopper returned from checkout that their payment did not go
|
|
19
|
+
* through (AGL-3606). A snackbar rather than an inline alert because the
|
|
20
|
+
* cart that mounts it may be a closed drawer behind a badge, and the message
|
|
21
|
+
* is about the whole page's purchase, not about the block it sits in.
|
|
22
|
+
*/
|
|
23
|
+
export declare function CheckoutReturnNotice({ hostId, siteFetch, }: {
|
|
24
|
+
hostId: string;
|
|
25
|
+
siteFetch?: typeof fetch;
|
|
26
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ 'use client';
|
|
17
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
+
import Alert from "@mui/material/Alert";
|
|
19
|
+
import Snackbar from "@mui/material/Snackbar";
|
|
20
|
+
import { useCheckoutReturnNotice } from "../utils/use-checkout-return-notice.js";
|
|
21
|
+
/**
|
|
22
|
+
* Tells a shopper returned from checkout that their payment did not go
|
|
23
|
+
* through (AGL-3606). A snackbar rather than an inline alert because the
|
|
24
|
+
* cart that mounts it may be a closed drawer behind a badge, and the message
|
|
25
|
+
* is about the whole page's purchase, not about the block it sits in.
|
|
26
|
+
*/ export function CheckoutReturnNotice({ hostId, siteFetch }) {
|
|
27
|
+
var _ref, _ref1;
|
|
28
|
+
const [notice, dismiss] = useCheckoutReturnNotice(hostId, siteFetch);
|
|
29
|
+
return /*#__PURE__*/ _jsx(Snackbar, {
|
|
30
|
+
open: Boolean(notice),
|
|
31
|
+
onClose: (_event, reason)=>{
|
|
32
|
+
// A click elsewhere on the page is not the shopper reading this.
|
|
33
|
+
if (reason !== 'clickaway') dismiss();
|
|
34
|
+
},
|
|
35
|
+
anchorOrigin: {
|
|
36
|
+
vertical: 'bottom',
|
|
37
|
+
horizontal: 'center'
|
|
38
|
+
},
|
|
39
|
+
children: /*#__PURE__*/ _jsx(Alert, {
|
|
40
|
+
severity: (_ref = notice == null ? void 0 : notice.severity) != null ? _ref : 'info',
|
|
41
|
+
onClose: dismiss,
|
|
42
|
+
role: "alert",
|
|
43
|
+
children: (_ref1 = notice == null ? void 0 : notice.message) != null ? _ref1 : ''
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=checkout-return-notice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/checkout-return-notice.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n'use client'\n\nimport Alert from '@mui/material/Alert'\nimport Snackbar from '@mui/material/Snackbar'\nimport { useCheckoutReturnNotice } from '../utils/use-checkout-return-notice'\n\n/**\n * Tells a shopper returned from checkout that their payment did not go\n * through (AGL-3606). A snackbar rather than an inline alert because the\n * cart that mounts it may be a closed drawer behind a badge, and the message\n * is about the whole page's purchase, not about the block it sits in.\n */\nexport function CheckoutReturnNotice({\n hostId,\n siteFetch,\n}: {\n hostId: string\n siteFetch?: typeof fetch\n}) {\n const [notice, dismiss] = useCheckoutReturnNotice(hostId, siteFetch)\n return (\n <Snackbar\n open={Boolean(notice)}\n onClose={(_event, reason) => {\n // A click elsewhere on the page is not the shopper reading this.\n if (reason !== 'clickaway') dismiss()\n }}\n anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}\n >\n {/* Always an element: the exit transition still renders the child. */}\n <Alert severity={notice?.severity ?? 'info'} onClose={dismiss} role=\"alert\">\n {notice?.message ?? ''}\n </Alert>\n </Snackbar>\n )\n}\n"],"names":["Alert","Snackbar","useCheckoutReturnNotice","CheckoutReturnNotice","hostId","siteFetch","notice","dismiss","open","Boolean","onClose","_event","reason","anchorOrigin","vertical","horizontal","severity","role","message"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;AAEA,OAAOA,WAAW,sBAAqB;AACvC,OAAOC,cAAc,yBAAwB;AAC7C,SAASC,uBAAuB,QAAQ,yCAAqC;AAE7E;;;;;CAKC,GACD,OAAO,SAASC,qBAAqB,EACnCC,MAAM,EACNC,SAAS,EAIV;;IACC,MAAM,CAACC,QAAQC,QAAQ,GAAGL,wBAAwBE,QAAQC;IAC1D,qBACE,KAACJ;QACCO,MAAMC,QAAQH;QACdI,SAAS,CAACC,QAAQC;YAChB,iEAAiE;YACjE,IAAIA,WAAW,aAAaL;QAC9B;QACAM,cAAc;YAAEC,UAAU;YAAUC,YAAY;QAAS;kBAGzD,cAAA,KAACf;YAAMgB,QAAQ,UAAEV,0BAAAA,OAAQU,QAAQ,mBAAI;YAAQN,SAASH;YAASU,MAAK;+BACjEX,0BAAAA,OAAQY,OAAO,oBAAI;;;AAI5B"}
|