@vtex/faststore 0.0.6 → 0.0.8
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/CHANGELOG.md +99 -0
- package/dist/actions.json +152 -1
- package/dist/catalog.json +2541 -1278
- package/dist/cli/UnreachableCaseError-Crd168Vu.js +10 -0
- package/dist/cli/UnreachableCaseError-Crd168Vu.js.map +1 -0
- package/dist/cli/cacheControl-CEojH_TM.js +158 -0
- package/dist/cli/cacheControl-CEojH_TM.js.map +1 -0
- package/dist/cli/cachePolicy-m2vASMRW.js +26 -0
- package/dist/cli/cachePolicy-m2vASMRW.js.map +1 -0
- package/dist/cli/computeCoreSchemaHash-DPJZj-qJ.js +10 -0
- package/dist/cli/computeCoreSchemaHash-DPJZj-qJ.js.map +1 -0
- package/dist/cli/default-BCQHcwbL.js +253 -0
- package/dist/cli/default-BCQHcwbL.js.map +1 -0
- package/dist/cli/disableSuggestions-yO9UqiWn.js +21 -0
- package/dist/cli/disableSuggestions-yO9UqiWn.js.map +1 -0
- package/dist/cli/dist-C1JhdHfo.js +2001 -0
- package/dist/cli/dist-C1JhdHfo.js.map +1 -0
- package/dist/cli/graphql-DG9thCDG.js +14589 -0
- package/dist/cli/graphql-DG9thCDG.js.map +1 -0
- package/dist/cli/index.d.ts +799 -0
- package/dist/cli/index.js +36459 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/index.min-BsIHDfFK.js +613 -0
- package/dist/cli/index.min-BsIHDfFK.js.map +1 -0
- package/dist/cli/inlineTrace-uLgOJ3TH.js +52 -0
- package/dist/cli/inlineTrace-uLgOJ3TH.js.map +1 -0
- package/dist/cli/internalPlugin-DnuwN4_4.js +11 -0
- package/dist/cli/internalPlugin-DnuwN4_4.js.map +1 -0
- package/dist/cli/packageVersion-DQAnIEil.js +6 -0
- package/dist/cli/packageVersion-DQAnIEil.js.map +1 -0
- package/dist/cli/rolldown-runtime-BMI-E3GI.js +44 -0
- package/dist/cli/schemaIsSubgraph-DoGh3OYj.js +17 -0
- package/dist/cli/schemaIsSubgraph-DoGh3OYj.js.map +1 -0
- package/dist/cli/schemaReporting-K-me-3-v.js +199 -0
- package/dist/cli/schemaReporting-K-me-3-v.js.map +1 -0
- package/dist/cli/server-runtime.js +49879 -0
- package/dist/cli/server-runtime.js.map +1 -0
- package/dist/cli/traceTreeBuilder-BIcV2U7b.js +9118 -0
- package/dist/cli/traceTreeBuilder-BIcV2U7b.js.map +1 -0
- package/dist/cli/usageReporting-Bpl8vSZX.js +10201 -0
- package/dist/cli/usageReporting-Bpl8vSZX.js.map +1 -0
- package/dist/cli/v4-CBhFvC49.js +42 -0
- package/dist/cli/v4-CBhFvC49.js.map +1 -0
- package/dist/client.d.ts +5 -1
- package/dist/client.js +5 -1
- package/dist/components.d.ts +38 -9
- package/dist/components.js +42 -13
- package/dist/content-types.json +616 -0
- package/dist/core/dist/define-component.d.ts +43 -1
- package/dist/core/dist/index.d.ts +2 -2
- package/dist/docs/account-access-gate.md +4 -4
- package/dist/docs/account-address-book.md +519 -0
- package/dist/docs/account-entry-point.md +1 -1
- package/dist/docs/account-menu-identity.md +160 -0
- package/dist/docs/account-menu.md +107 -24
- package/dist/docs/alert-dialog.md +2 -2
- package/dist/docs/avatar.md +103 -0
- package/dist/docs/billing-address.md +17 -9
- package/dist/docs/card-entry.md +37 -6
- package/dist/docs/cardholder-document.md +16 -14
- package/dist/docs/cart-item.md +1 -1
- package/dist/docs/cart.md +8 -8
- package/dist/docs/client-profile-fieldset.md +7 -5
- package/dist/docs/copy-text.md +84 -0
- package/dist/docs/document-field.md +8 -8
- package/dist/docs/footer-link-group.md +2 -2
- package/dist/docs/header-root.md +1 -1
- package/dist/docs/incentives.md +2 -2
- package/dist/docs/logo.md +5 -5
- package/dist/docs/my-account-profile.md +5 -5
- package/dist/docs/navigation-link-list.md +2 -2
- package/dist/docs/navigation-link.md +3 -3
- package/dist/docs/order-cancel.md +52 -0
- package/dist/docs/order-delivery-address.md +63 -0
- package/dist/docs/order-delivery-group.md +83 -0
- package/dist/docs/order-details-back.md +41 -0
- package/dist/docs/order-details-header.md +48 -0
- package/dist/docs/order-list-row.md +46 -0
- package/dist/docs/order-list-search.md +101 -0
- package/dist/docs/order-list-views.md +97 -0
- package/dist/docs/order-list.md +94 -0
- package/dist/docs/order-payment.md +94 -0
- package/dist/docs/order-placed-date.md +49 -0
- package/dist/docs/order-placed-payment-summary.md +13 -15
- package/dist/docs/order-placed.md +225 -0
- package/dist/docs/order-progress.md +88 -0
- package/dist/docs/order-status-badge.md +91 -0
- package/dist/docs/order-summary.md +53 -0
- package/dist/docs/payment-method-badges.md +14 -3
- package/dist/docs/place-order.md +13 -9
- package/dist/docs/product-shelf.md +20 -13
- package/dist/docs/saved-cards.md +2 -2
- package/dist/docs/select.md +19 -6
- package/dist/docs/session.md +1 -1
- package/dist/docs/shipping-address.md +1 -1
- package/dist/docs/sign-in-redirect.md +6 -6
- package/dist/docs/toast.md +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +2 -1
- package/dist/internal/client.d.ts +6 -1
- package/dist/internal/client.js +8 -3
- package/dist/internal/content.d.ts +2 -2
- package/dist/internal/server.d.ts +8 -1
- package/dist/internal/server.js +8 -1
- package/dist/matter/account-access-gate/account-access-gate.d.ts +2 -1
- package/dist/matter/account-access-gate/account-access-gate.js +19 -16
- package/dist/matter/account-access-gate/account-access-gate.js.map +1 -1
- package/dist/matter/account-address-book/account-address-book-delete.d.ts +60 -0
- package/dist/matter/account-address-book/account-address-book-delete.js +184 -0
- package/dist/matter/account-address-book/account-address-book-delete.js.map +1 -0
- package/dist/matter/account-address-book/account-address-book-deliverability.d.ts +19 -0
- package/dist/matter/account-address-book/account-address-book-deliverability.js +50 -0
- package/dist/matter/account-address-book/account-address-book-deliverability.js.map +1 -0
- package/dist/matter/account-address-book/account-address-book-form-parts.d.ts +42 -0
- package/dist/matter/account-address-book/account-address-book-form-parts.js +146 -0
- package/dist/matter/account-address-book/account-address-book-form-parts.js.map +1 -0
- package/dist/matter/account-address-book/account-address-book-profile-notice.d.ts +25 -0
- package/dist/matter/account-address-book/account-address-book-profile-notice.js +72 -0
- package/dist/matter/account-address-book/account-address-book-profile-notice.js.map +1 -0
- package/dist/matter/account-address-book/account-address-book.d.ts +120 -0
- package/dist/matter/account-address-book/account-address-book.js +469 -0
- package/dist/matter/account-address-book/account-address-book.js.map +1 -0
- package/dist/matter/account-address-book/account-address-country-switch.js +59 -0
- package/dist/matter/account-address-book/account-address-country-switch.js.map +1 -0
- package/dist/matter/account-address-book/account-address-country.d.ts +36 -0
- package/dist/matter/account-address-book/account-address-country.js +151 -0
- package/dist/matter/account-address-book/account-address-country.js.map +1 -0
- package/dist/matter/account-address-book/account-address-first-line.js +11 -0
- package/dist/matter/account-address-book/account-address-first-line.js.map +1 -0
- package/dist/matter/account-address-book/account-address-form-context.d.ts +55 -0
- package/dist/matter/account-address-book/account-address-form-context.js +14 -0
- package/dist/matter/account-address-book/account-address-form-context.js.map +1 -0
- package/dist/matter/account-address-book/account-address-form.d.ts +85 -0
- package/dist/matter/account-address-book/account-address-form.js +946 -0
- package/dist/matter/account-address-book/account-address-form.js.map +1 -0
- package/dist/matter/account-address-book/account-address-postal-autofill.js +189 -0
- package/dist/matter/account-address-book/account-address-postal-autofill.js.map +1 -0
- package/dist/matter/account-address-book/account-address-record.d.ts +26 -0
- package/dist/matter/account-address-book/account-address-record.js +138 -0
- package/dist/matter/account-address-book/account-address-record.js.map +1 -0
- package/dist/matter/account-entry-point/account-entry-point.js +11 -11
- package/dist/matter/account-entry-point/account-entry-point.js.map +1 -1
- package/dist/matter/account-menu/account-menu.d.ts +77 -3
- package/dist/matter/account-menu/account-menu.js +252 -19
- package/dist/matter/account-menu/account-menu.js.map +1 -1
- package/dist/matter/account-menu/sign-out-failure.js +50 -0
- package/dist/matter/account-menu/sign-out-failure.js.map +1 -0
- package/dist/matter/account-menu-identity/account-menu-identity.d.ts +21 -0
- package/dist/matter/account-menu-identity/account-menu-identity.js +88 -0
- package/dist/matter/account-menu-identity/account-menu-identity.js.map +1 -0
- package/dist/matter/billing-address/billing-address.d.ts +30 -17
- package/dist/matter/billing-address/billing-address.js +128 -33
- package/dist/matter/billing-address/billing-address.js.map +1 -1
- package/dist/matter/breadcrumb/breadcrumb.js +2 -2
- package/dist/matter/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/matter/card-entry/card-capture.js +4 -3
- package/dist/matter/card-entry/card-capture.js.map +1 -1
- package/dist/matter/card-entry/card-entry.d.ts +5 -3
- package/dist/matter/card-entry/card-entry.js +78 -27
- package/dist/matter/card-entry/card-entry.js.map +1 -1
- package/dist/matter/cardholder-document/cardholder-document.d.ts +10 -9
- package/dist/matter/cardholder-document/cardholder-document.js +36 -16
- package/dist/matter/cardholder-document/cardholder-document.js.map +1 -1
- package/dist/matter/cart/cart.d.ts +7 -2
- package/dist/matter/cart/cart.js +29 -26
- package/dist/matter/cart/cart.js.map +1 -1
- package/dist/matter/cart-item/cart-item.js +2 -2
- package/dist/matter/cart-item/cart-item.js.map +1 -1
- package/dist/matter/client-preferences/client-preferences-fieldset.js +2 -2
- package/dist/matter/client-profile-form/client-profile-fieldset.js +9 -6
- package/dist/matter/client-profile-form/client-profile-fieldset.js.map +1 -1
- package/dist/matter/identity-edit/identity-edit.js +3 -3
- package/dist/matter/identity-edit/identity-edit.js.map +1 -1
- package/dist/matter/identity-summary/identity-summary.js +4 -3
- package/dist/matter/identity-summary/identity-summary.js.map +1 -1
- package/dist/matter/my-account-profile/my-account-profile.d.ts +6 -3
- package/dist/matter/my-account-profile/my-account-profile.js +6 -5
- package/dist/matter/my-account-profile/my-account-profile.js.map +1 -1
- package/dist/matter/order-cancel/order-cancel.d.ts +110 -0
- package/dist/matter/order-cancel/order-cancel.js +344 -0
- package/dist/matter/order-cancel/order-cancel.js.map +1 -0
- package/dist/matter/order-delivery-address/order-delivery-address.d.ts +73 -0
- package/dist/matter/order-delivery-address/order-delivery-address.js +172 -0
- package/dist/matter/order-delivery-address/order-delivery-address.js.map +1 -0
- package/dist/matter/order-delivery-group/order-delivery-group.d.ts +128 -0
- package/dist/matter/order-delivery-group/order-delivery-group.js +408 -0
- package/dist/matter/order-delivery-group/order-delivery-group.js.map +1 -0
- package/dist/matter/order-details-header/order-details-header.d.ts +104 -0
- package/dist/matter/order-details-header/order-details-header.js +190 -0
- package/dist/matter/order-details-header/order-details-header.js.map +1 -0
- package/dist/matter/order-list/customer-orders-filter.d.ts +12 -0
- package/dist/matter/order-list/customer-orders-filter.js +30 -0
- package/dist/matter/order-list/customer-orders-filter.js.map +1 -0
- package/dist/matter/order-list/order-list.d.ts +121 -0
- package/dist/matter/order-list/order-list.js +395 -0
- package/dist/matter/order-list/order-list.js.map +1 -0
- package/dist/matter/order-list-row/order-list-row.d.ts +44 -0
- package/dist/matter/order-list-row/order-list-row.js +127 -0
- package/dist/matter/order-list-row/order-list-row.js.map +1 -0
- package/dist/matter/order-list-search/order-list-search.d.ts +72 -0
- package/dist/matter/order-list-search/order-list-search.js +296 -0
- package/dist/matter/order-list-search/order-list-search.js.map +1 -0
- package/dist/matter/order-list-views/order-list-views.d.ts +65 -0
- package/dist/matter/order-list-views/order-list-views.js +154 -0
- package/dist/matter/order-list-views/order-list-views.js.map +1 -0
- package/dist/matter/order-payment/order-payment.d.ts +83 -0
- package/dist/matter/order-payment/order-payment.js +258 -0
- package/dist/matter/order-payment/order-payment.js.map +1 -0
- package/dist/matter/order-placed/order-placed-deliveries.d.ts +145 -0
- package/dist/matter/order-placed/order-placed-deliveries.js +380 -0
- package/dist/matter/order-placed/order-placed-deliveries.js.map +1 -0
- package/dist/matter/order-placed/order-placed.d.ts +122 -0
- package/dist/matter/order-placed/order-placed.js +452 -0
- package/dist/matter/order-placed/order-placed.js.map +1 -0
- package/dist/matter/order-placed-date/order-placed-date.d.ts +45 -0
- package/dist/matter/order-placed-date/order-placed-date.js +92 -0
- package/dist/matter/order-placed-date/order-placed-date.js.map +1 -0
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.d.ts +5 -8
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js +29 -81
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js.map +1 -1
- package/dist/matter/order-progress/order-progress.d.ts +85 -0
- package/dist/matter/order-progress/order-progress.js +203 -0
- package/dist/matter/order-progress/order-progress.js.map +1 -0
- package/dist/matter/order-summary/order-summary.d.ts +81 -0
- package/dist/matter/order-summary/order-summary.js +192 -0
- package/dist/matter/order-summary/order-summary.js.map +1 -0
- package/dist/matter/payment/cardholder-document-rule.d.ts +35 -0
- package/dist/matter/payment/cardholder-document-rule.js +35 -0
- package/dist/matter/payment/cardholder-document-rule.js.map +1 -0
- package/dist/matter/payment/payment-card-capture.js +38 -23
- package/dist/matter/payment/payment-card-capture.js.map +1 -1
- package/dist/matter/payment/payment-controller.js +12 -0
- package/dist/matter/payment/payment-controller.js.map +1 -1
- package/dist/matter/payment/payment-method-badges.js +4 -2
- package/dist/matter/payment/payment-method-badges.js.map +1 -1
- package/dist/matter/payment/payment.js +12 -0
- package/dist/matter/payment/payment.js.map +1 -1
- package/dist/matter/payment/use-payment-method-selection.d.ts +39 -0
- package/dist/matter/payment/use-payment-method-selection.js +30 -2
- package/dist/matter/payment/use-payment-method-selection.js.map +1 -1
- package/dist/matter/payment/use-payment-submit-gate.d.ts +16 -2
- package/dist/matter/payment/use-payment-submit-gate.js +42 -14
- package/dist/matter/payment/use-payment-submit-gate.js.map +1 -1
- package/dist/matter/place-order/place-order.d.ts +12 -7
- package/dist/matter/place-order/place-order.js +126 -103
- package/dist/matter/place-order/place-order.js.map +1 -1
- package/dist/matter/pricing/pricing.js +5 -5
- package/dist/matter/pricing/pricing.js.map +1 -1
- package/dist/matter/product-shelf/product-shelf.d.ts +61 -31
- package/dist/matter/product-shelf/product-shelf.js +157 -57
- package/dist/matter/product-shelf/product-shelf.js.map +1 -1
- package/dist/matter/region/region.js +1 -1
- package/dist/matter/saved-cards/saved-cards.js +27 -15
- package/dist/matter/saved-cards/saved-cards.js.map +1 -1
- package/dist/matter/session/session.js +2 -2
- package/dist/matter/session/session.js.map +1 -1
- package/dist/matter/shipping-address/country-descriptors.d.ts +1 -0
- package/dist/matter/shipping-address/country-descriptors.js +23 -1
- package/dist/matter/shipping-address/country-descriptors.js.map +1 -1
- package/dist/matter/shipping-address/shipping-address.js +63 -15
- package/dist/matter/shipping-address/shipping-address.js.map +1 -1
- package/dist/matter/shipping-simulator/shipping-simulator.d.ts +1 -1
- package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -1
- package/dist/matter/sign-in-redirect/sign-in-redirect.js +48 -10
- package/dist/matter/sign-in-redirect/sign-in-redirect.js.map +1 -1
- package/dist/matter/variant-selector/variant-selector.js +2 -2
- package/dist/matter/variant-selector/variant-selector.js.map +1 -1
- package/dist/particles/address-summary/address-summary.js +2 -2
- package/dist/particles/address-summary/address-summary.js.map +1 -1
- package/dist/particles/alert-dialog/alert-dialog.d.ts +5 -1
- package/dist/particles/alert-dialog/alert-dialog.js +5 -2
- package/dist/particles/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/particles/avatar/avatar.d.ts +17 -0
- package/dist/particles/avatar/avatar.js +65 -0
- package/dist/particles/avatar/avatar.js.map +1 -0
- package/dist/particles/copy-text/copy-text.d.ts +28 -0
- package/dist/particles/copy-text/copy-text.js +140 -0
- package/dist/particles/copy-text/copy-text.js.map +1 -0
- package/dist/particles/document-field/document-field.d.ts +34 -5
- package/dist/particles/document-field/document-field.js +115 -19
- package/dist/particles/document-field/document-field.js.map +1 -1
- package/dist/particles/field/field.js +1 -1
- package/dist/particles/field/field.js.map +1 -1
- package/dist/particles/footer-link-group/footer-link-group.d.ts +6 -2
- package/dist/particles/footer-link-group/footer-link-group.js +18 -7
- package/dist/particles/footer-link-group/footer-link-group.js.map +1 -1
- package/dist/particles/incentives/incentives.d.ts +6 -2
- package/dist/particles/incentives/incentives.js +7 -2
- package/dist/particles/incentives/incentives.js.map +1 -1
- package/dist/particles/logo/logo.d.ts +3 -2
- package/dist/particles/logo/logo.js +20 -8
- package/dist/particles/logo/logo.js.map +1 -1
- package/dist/particles/navigation-link/navigation-link.d.ts +2 -3
- package/dist/particles/navigation-link/navigation-link.js +4 -4
- package/dist/particles/navigation-link/navigation-link.js.map +1 -1
- package/dist/particles/navigation-link-list/navigation-link-list.d.ts +6 -2
- package/dist/particles/navigation-link-list/navigation-link-list.js +18 -7
- package/dist/particles/navigation-link-list/navigation-link-list.js.map +1 -1
- package/dist/particles/order-details-back/order-details-back.d.ts +28 -0
- package/dist/particles/order-details-back/order-details-back.js +52 -0
- package/dist/particles/order-details-back/order-details-back.js.map +1 -0
- package/dist/particles/order-status-badge/order-status-badge.d.ts +19 -0
- package/dist/particles/order-status-badge/order-status-badge.js +50 -0
- package/dist/particles/order-status-badge/order-status-badge.js.map +1 -0
- package/dist/particles/phone-field/phone-field.js +2 -2
- package/dist/particles/phone-field/phone-field.js.map +1 -1
- package/dist/particles/select/select.js +6 -6
- package/dist/particles/select/select.js.map +1 -1
- package/dist/particles/toast/toast.d.ts +1 -1
- package/dist/particles/toast/toast.js +32 -6
- package/dist/particles/toast/toast.js.map +1 -1
- package/dist/schema.graphql +1079 -54
- package/dist/sdk/actions/address-action-provider.d.ts +16 -0
- package/dist/sdk/actions/address-action-provider.js +20 -0
- package/dist/sdk/actions/address-action-provider.js.map +1 -0
- package/dist/sdk/actions/analytics-action-provider.js +1 -1
- package/dist/sdk/actions/index.d.ts +3 -1
- package/dist/sdk/actions/index.js +3 -1
- package/dist/sdk/actions/order-action-provider.d.ts +12 -0
- package/dist/sdk/actions/order-action-provider.js +16 -0
- package/dist/sdk/actions/order-action-provider.js.map +1 -0
- package/dist/sdk/actions/types.d.ts +6 -2
- package/dist/sdk/address/address-fields.js +38 -0
- package/dist/sdk/address/address-fields.js.map +1 -0
- package/dist/sdk/address/checkout-readiness.js +17 -0
- package/dist/sdk/address/checkout-readiness.js.map +1 -0
- package/dist/sdk/address/constants.js +60 -0
- package/dist/sdk/address/constants.js.map +1 -0
- package/dist/sdk/address/country-display.js +19 -0
- package/dist/sdk/address/country-display.js.map +1 -0
- package/dist/sdk/address/country-rules.js +30 -0
- package/dist/sdk/address/country-rules.js.map +1 -0
- package/dist/sdk/address/format-address.js +18 -0
- package/dist/sdk/address/format-address.js.map +1 -0
- package/dist/sdk/address/iso-countries.js +262 -0
- package/dist/sdk/address/iso-countries.js.map +1 -0
- package/dist/sdk/address/layouts.js +56 -0
- package/dist/sdk/address/layouts.js.map +1 -0
- package/dist/sdk/address/messages.js +97 -0
- package/dist/sdk/address/messages.js.map +1 -0
- package/dist/sdk/address/operations.d.ts +54 -0
- package/dist/sdk/address/operations.js +83 -0
- package/dist/sdk/address/operations.js.map +1 -0
- package/dist/sdk/address/postal-code-lookup-operations.js +23 -0
- package/dist/sdk/address/postal-code-lookup-operations.js.map +1 -0
- package/dist/sdk/address/postal-code.js +11 -0
- package/dist/sdk/address/postal-code.js.map +1 -0
- package/dist/sdk/address/schema.js +14 -0
- package/dist/sdk/address/schema.js.map +1 -0
- package/dist/sdk/address/server-fields.js +25 -0
- package/dist/sdk/address/server-fields.js.map +1 -0
- package/dist/sdk/address/switch-country.js +57 -0
- package/dist/sdk/address/switch-country.js.map +1 -0
- package/dist/sdk/address/types.d.ts +26 -0
- package/dist/sdk/address/use-address-actions.d.ts +29 -0
- package/dist/sdk/address/use-address-actions.js +247 -0
- package/dist/sdk/address/use-address-actions.js.map +1 -0
- package/dist/sdk/address/use-address-by-postal-code.js +57 -0
- package/dist/sdk/address/use-address-by-postal-code.js.map +1 -0
- package/dist/sdk/address/validate-address.js +62 -0
- package/dist/sdk/address/validate-address.js.map +1 -0
- package/dist/sdk/analytics/use-analytics-actions.js +2 -1
- package/dist/sdk/analytics/use-analytics-actions.js.map +1 -1
- package/dist/sdk/cache/storefront-cache.js +29 -4
- package/dist/sdk/cache/storefront-cache.js.map +1 -1
- package/dist/sdk/cart/use-cart-actions.js +9 -8
- package/dist/sdk/cart/use-cart-actions.js.map +1 -1
- package/dist/sdk/cart/use-cart-validate-on-open.js +2 -1
- package/dist/sdk/cart/use-cart-validate-on-open.js.map +1 -1
- package/dist/sdk/client/fetch-page-data.d.ts +11 -0
- package/dist/sdk/client/fetch-page-data.js +12 -1
- package/dist/sdk/client/fetch-page-data.js.map +1 -1
- package/dist/sdk/content/create-content-runtime.d.ts +22 -1
- package/dist/sdk/content/create-content-runtime.js +90 -9
- package/dist/sdk/content/create-content-runtime.js.map +1 -1
- package/dist/sdk/data/empty-content-value.js +16 -0
- package/dist/sdk/data/empty-content-value.js.map +1 -0
- package/dist/sdk/data/failed-fields.js +23 -0
- package/dist/sdk/data/failed-fields.js.map +1 -0
- package/dist/sdk/data/hot-data-provider.js +2 -1
- package/dist/sdk/data/hot-data-provider.js.map +1 -1
- package/dist/sdk/data/index.js +1 -1
- package/dist/sdk/data/page-reactive-data-root.d.ts +45 -7
- package/dist/sdk/data/page-reactive-data-root.js +88 -12
- package/dist/sdk/data/page-reactive-data-root.js.map +1 -1
- package/dist/sdk/data/variables-from-content.d.ts +43 -0
- package/dist/sdk/data/variables-from-content.js +57 -0
- package/dist/sdk/data/variables-from-content.js.map +1 -0
- package/dist/sdk/generated/fragment-types.js +2 -0
- package/dist/sdk/generated/fragment-types.js.map +1 -1
- package/dist/sdk/generated/gql.js +4 -1
- package/dist/sdk/generated/gql.js.map +1 -1
- package/dist/sdk/generated/graphql.d.ts +8 -0
- package/dist/sdk/generated/graphql.js +296 -1
- package/dist/sdk/generated/graphql.js.map +1 -1
- package/dist/sdk/i18n/messages/en-US.js +138 -1
- package/dist/sdk/i18n/messages/en-US.json +138 -1
- package/dist/sdk/i18n/messages/en-US.json.d.ts +137 -0
- package/dist/sdk/i18n/messages/es-ES.js +138 -1
- package/dist/sdk/i18n/messages/es-ES.json +138 -1
- package/dist/sdk/i18n/messages/pt-BR.js +138 -1
- package/dist/sdk/i18n/messages/pt-BR.json +138 -1
- package/dist/sdk/identity/use-identity-actions.js +5 -4
- package/dist/sdk/identity/use-identity-actions.js.map +1 -1
- package/dist/sdk/navigation/current-page.js +30 -0
- package/dist/sdk/navigation/current-page.js.map +1 -0
- package/dist/sdk/navigation/not-found-log.d.ts +28 -0
- package/dist/sdk/navigation/not-found-log.js +133 -0
- package/dist/sdk/navigation/not-found-log.js.map +1 -0
- package/dist/sdk/navigation/path.js +25 -0
- package/dist/sdk/navigation/path.js.map +1 -0
- package/dist/sdk/navigation/redirect.d.ts +11 -0
- package/dist/sdk/navigation/redirect.js +22 -0
- package/dist/sdk/navigation/redirect.js.map +1 -0
- package/dist/sdk/navigation/report.js +70 -0
- package/dist/sdk/navigation/report.js.map +1 -0
- package/dist/sdk/navigation/resolve-storefront-href.d.ts +12 -0
- package/dist/sdk/navigation/resolve-storefront-href.js +214 -0
- package/dist/sdk/navigation/resolve-storefront-href.js.map +1 -0
- package/dist/sdk/navigation/route-identity-provider.d.ts +11 -0
- package/dist/sdk/navigation/route-identity-provider.js +20 -0
- package/dist/sdk/navigation/route-identity-provider.js.map +1 -0
- package/dist/sdk/navigation/route-map-provider.d.ts +19 -0
- package/dist/sdk/navigation/route-map-provider.js +29 -0
- package/dist/sdk/navigation/route-map-provider.js.map +1 -0
- package/dist/sdk/navigation/storefront-link.d.ts +16 -0
- package/dist/sdk/navigation/storefront-link.js +66 -0
- package/dist/sdk/navigation/storefront-link.js.map +1 -0
- package/dist/sdk/navigation/types.d.ts +45 -0
- package/dist/sdk/navigation/use-storefront-navigation.d.ts +26 -0
- package/dist/sdk/navigation/use-storefront-navigation.js +73 -0
- package/dist/sdk/navigation/use-storefront-navigation.js.map +1 -0
- package/dist/sdk/navigation/use-storefront-route.d.ts +26 -0
- package/dist/sdk/navigation/use-storefront-route.js +87 -0
- package/dist/sdk/navigation/use-storefront-route.js.map +1 -0
- package/dist/sdk/navigation/use-storefront-search-params.d.ts +11 -0
- package/dist/sdk/navigation/use-storefront-search-params.js +16 -0
- package/dist/sdk/navigation/use-storefront-search-params.js.map +1 -0
- package/dist/sdk/orders/completion-badge.d.ts +8 -0
- package/dist/sdk/orders/completion-badge.js +47 -0
- package/dist/sdk/orders/completion-badge.js.map +1 -0
- package/dist/sdk/orders/order-operations.d.ts +19 -0
- package/dist/sdk/orders/order-operations.js +21 -0
- package/dist/sdk/orders/order-operations.js.map +1 -0
- package/dist/sdk/orders/use-order-actions.d.ts +23 -0
- package/dist/sdk/orders/use-order-actions.js +62 -0
- package/dist/sdk/orders/use-order-actions.js.map +1 -0
- package/dist/sdk/payment/gateway-origin.js +26 -13
- package/dist/sdk/payment/gateway-origin.js.map +1 -1
- package/dist/sdk/payment/gateway.d.ts +14 -2
- package/dist/sdk/payment/gateway.js +32 -14
- package/dist/sdk/payment/gateway.js.map +1 -1
- package/dist/sdk/payment/operations.js +11 -0
- package/dist/sdk/payment/operations.js.map +1 -1
- package/dist/sdk/payment/submission-registry.d.ts +2 -1
- package/dist/sdk/payment/submission-registry.js +12 -8
- package/dist/sdk/payment/submission-registry.js.map +1 -1
- package/dist/sdk/payment/use-payment-actions.d.ts +5 -3
- package/dist/sdk/payment/use-payment-actions.js +6 -3
- package/dist/sdk/payment/use-payment-actions.js.map +1 -1
- package/dist/sdk/payment/use-place-order.d.ts +6 -3
- package/dist/sdk/payment/use-place-order.js +334 -144
- package/dist/sdk/payment/use-place-order.js.map +1 -1
- package/dist/sdk/region/use-region-actions.js +2 -1
- package/dist/sdk/region/use-region-actions.js.map +1 -1
- package/dist/sdk/seo/page-alternates.d.ts +55 -0
- package/dist/sdk/seo/page-alternates.js +132 -0
- package/dist/sdk/seo/page-alternates.js.map +1 -0
- package/dist/sdk/session/read-server-session.d.ts +21 -0
- package/dist/sdk/session/read-server-session.js +61 -0
- package/dist/sdk/session/read-server-session.js.map +1 -0
- package/dist/sdk/session/use-session-actions.js +5 -4
- package/dist/sdk/session/use-session-actions.js.map +1 -1
- package/dist/sdk/session/use-session-revalidation.js +2 -1
- package/dist/sdk/session/use-session-revalidation.js.map +1 -1
- package/dist/sdk/shipping/use-shipping-actions.js +3 -2
- package/dist/sdk/shipping/use-shipping-actions.js.map +1 -1
- package/dist/utils/own-value.js +19 -0
- package/dist/utils/own-value.js.map +1 -0
- package/dist/utils/safe-href.d.ts +11 -0
- package/dist/utils/safe-href.js +31 -22
- package/dist/utils/safe-href.js.map +1 -1
- package/package.json +17 -2
- package/skills/storefront-asset/SKILL.md +111 -0
- package/skills/storefront-asset/references/api-side.md +153 -0
- package/skills/storefront-asset/references/findings.md +40 -0
- package/skills/storefront-asset/references/ui-side.md +94 -0
- package/src/styles/tailwind.css +27 -0
|
@@ -24,7 +24,6 @@ export type OrderPlacedInstallment = {
|
|
|
24
24
|
export type OrderPlacedPaymentSummaryData = {
|
|
25
25
|
network?: string | null;
|
|
26
26
|
lastFourDigits?: string | null;
|
|
27
|
-
label?: string | null;
|
|
28
27
|
installment?: OrderPlacedInstallment;
|
|
29
28
|
} | null;
|
|
30
29
|
export type OrderPlacedPaymentSummaryProps = {
|
|
@@ -35,8 +34,6 @@ export type OrderPlacedPaymentSummaryProps = {
|
|
|
35
34
|
noPaymentRecordLabel?: string;
|
|
36
35
|
/** Shown when the order group does not resolve to a settled order. */
|
|
37
36
|
unresolvedOrderLabel?: string;
|
|
38
|
-
/** Shown for a split order; `{count}` placeholder, omitted when the count is unknown. */
|
|
39
|
-
multiSellerNotice?: string;
|
|
40
37
|
/**
|
|
41
38
|
* Rendered only when `installment` resolves; `{count}`/`{total}` placeholders. When the source
|
|
42
39
|
* carries the count but not enough to build a total from (US-2 — never a fabricated per-installment
|
|
@@ -52,12 +49,12 @@ export type OrderPlacedPaymentSummaryProps = {
|
|
|
52
49
|
export declare const OrderPlacedPaymentSummaryDefinition: ComponentDefinition<OrderPlacedPaymentSummaryProps>;
|
|
53
50
|
/**
|
|
54
51
|
* Renders the settled order's payment recap on a confirmation surface. Resolves through
|
|
55
|
-
* `resolveOrderPlacedPayment`'s fixed precedence and renders exactly one state: the
|
|
56
|
-
*
|
|
52
|
+
* `resolveOrderPlacedPayment`'s fixed precedence and renders exactly one state: the unresolved
|
|
53
|
+
* notice as an inline `role="alert"` element (FR-6); the no-record line as plain
|
|
57
54
|
* informational text; the in-flight state as nothing at all (Decision 6); the recap as network plus
|
|
58
|
-
* last four (whenever present) plus the
|
|
59
|
-
*
|
|
55
|
+
* last four (whenever present) plus the installment line (whenever the settled record reports one,
|
|
56
|
+
* T33). Requires no context — composable standalone.
|
|
60
57
|
*/
|
|
61
|
-
export declare function OrderPlacedPaymentSummary({ className, lastFourTemplate, noPaymentRecordLabel, unresolvedOrderLabel,
|
|
58
|
+
export declare function OrderPlacedPaymentSummary({ className, lastFourTemplate, noPaymentRecordLabel, unresolvedOrderLabel, installmentTemplate, $data: $dataProp }: OrderPlacedPaymentSummaryProps): import("react/jsx-runtime").JSX.Element | null;
|
|
62
59
|
//#endregion
|
|
63
60
|
//# sourceMappingURL=order-placed-payment-summary.d.ts.map
|
|
@@ -6,7 +6,6 @@ import { ReactiveRootContext } from "../../sdk/data/page-reactive-data-root.js";
|
|
|
6
6
|
import { substituteTemplate } from "../../utils/substitute-template.js";
|
|
7
7
|
import { useContext } from "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
import { CombinedGraphQLErrors } from "@apollo/client/errors";
|
|
10
9
|
//#region src/matter/order-placed-payment-summary/order-placed-payment-summary.tsx
|
|
11
10
|
/**
|
|
12
11
|
* OrderPlacedPaymentSummary matter (epic `credit-card`, T17 — recap the payment on the order
|
|
@@ -21,7 +20,7 @@ import { CombinedGraphQLErrors } from "@apollo/client/errors";
|
|
|
21
20
|
* point this component at `Query.payment`.
|
|
22
21
|
*
|
|
23
22
|
* Read-only recap — no write affordance, no internal state; every transition is driven purely by
|
|
24
|
-
* `$data
|
|
23
|
+
* `$data` and `loading`.
|
|
25
24
|
*/
|
|
26
25
|
const fragment = `
|
|
27
26
|
fragment OrderPlacedPaymentSummaryData on Query {
|
|
@@ -30,7 +29,6 @@ const fragment = `
|
|
|
30
29
|
id
|
|
31
30
|
network
|
|
32
31
|
lastFourDigits
|
|
33
|
-
label
|
|
34
32
|
installment {
|
|
35
33
|
count
|
|
36
34
|
total {
|
|
@@ -41,63 +39,32 @@ const fragment = `
|
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
`;
|
|
44
|
-
const MULTI_SELLER_ERROR_CODE = "UNSUPPORTED_MULTI_SELLER_ORDER";
|
|
45
42
|
const TOTAL_TOKEN = "{total}";
|
|
46
43
|
const COUNT_TOKEN = "{count}";
|
|
47
44
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* `unresolved` state instead, matching FR-5's precedence.
|
|
55
|
-
*/
|
|
56
|
-
function resolveMultiSellerSignal(error) {
|
|
57
|
-
if (!error || !CombinedGraphQLErrors.is(error)) return null;
|
|
58
|
-
const multiSellerError = error.errors.find((graphQLError) => graphQLError.extensions?.code === MULTI_SELLER_ERROR_CODE);
|
|
59
|
-
if (!multiSellerError) return null;
|
|
60
|
-
const sellerCount = multiSellerError.extensions?.sellerCount;
|
|
61
|
-
return { sellerCount: typeof sellerCount === "number" ? sellerCount : null };
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Resolves `$data` plus the reactive root's `loading`/`error` into exactly one of five states, in
|
|
65
|
-
* FR-5's total, ordered precedence: multi-seller wins over everything else — including a resolved
|
|
66
|
-
* `$data` — because in that state the one seller's card that *is* present would otherwise be shown as
|
|
67
|
-
* if it were the whole payment (Decision 4). `loading && data == null` (Decision 6) separates a
|
|
68
|
-
* transient in-flight window from a genuinely unresolved order group, so the unresolved alert never
|
|
69
|
-
* flashes on first paint of a successful confirmation. `no-record` fires only when every recap field
|
|
70
|
-
* is null — a record carrying just one of the three still renders as `recap` (Open Question 5).
|
|
45
|
+
* Resolves `$data` plus the reactive root's `loading` into exactly one of four states, in a total,
|
|
46
|
+
* ordered precedence. A split purchase is read whole (docs/features/order-placed/rfc.md, 3.1), so no
|
|
47
|
+
* error carries a state of its own: any failed read leaves `$data` null and resolves to `unresolved`.
|
|
48
|
+
* `loading && data == null` separates a transient in-flight window from a genuinely unresolved order
|
|
49
|
+
* group, so the unresolved alert never flashes on first paint of a successful confirmation. `no-record` fires only when network and
|
|
50
|
+
* lastFourDigits are both null — a record carrying either still renders as `recap` (Open Question 5).
|
|
71
51
|
*
|
|
72
|
-
* `no-record`'s gate
|
|
73
|
-
*
|
|
74
|
-
*
|
|
52
|
+
* `no-record`'s gate never reads installment (FR-6, INV-6): an order carrying an installment but
|
|
53
|
+
* neither network nor lastFourDigits still renders `no-record`, not a recap with only an installment
|
|
54
|
+
* line. The order system sends no card label, so the recap reads none
|
|
55
|
+
* (docs/features/order-placed/rfc.md, 4.5).
|
|
75
56
|
*/
|
|
76
|
-
function resolveOrderPlacedPayment(data, loading
|
|
77
|
-
const multiSeller = resolveMultiSellerSignal(error);
|
|
78
|
-
if (multiSeller) return {
|
|
79
|
-
kind: "multi-seller",
|
|
80
|
-
sellerCount: multiSeller.sellerCount
|
|
81
|
-
};
|
|
57
|
+
function resolveOrderPlacedPayment(data, loading) {
|
|
82
58
|
if (loading && data == null) return { kind: "loading" };
|
|
83
59
|
if (data == null) return { kind: "unresolved" };
|
|
84
|
-
if (data.network == null && data.lastFourDigits == null
|
|
60
|
+
if (data.network == null && data.lastFourDigits == null) return { kind: "no-record" };
|
|
85
61
|
return {
|
|
86
62
|
kind: "recap",
|
|
87
63
|
network: data.network ?? "",
|
|
88
64
|
lastFourDigits: data.lastFourDigits ?? null,
|
|
89
|
-
label: data.label ?? null,
|
|
90
65
|
installment: data.installment ?? null
|
|
91
66
|
};
|
|
92
67
|
}
|
|
93
|
-
/**
|
|
94
|
-
* Substitutes `{count}` when the seller count is known; otherwise drops the token and collapses the
|
|
95
|
-
* resulting run of spaces, so an unknown count never prints the literal string "undefined" or "NaN".
|
|
96
|
-
*/
|
|
97
|
-
function formatMultiSellerNotice(template, sellerCount) {
|
|
98
|
-
if (sellerCount == null) return substituteTemplate(template, { count: "" }).replace(/ {2,}/g, " ").trim();
|
|
99
|
-
return substituteTemplate(template, { count: String(sellerCount) });
|
|
100
|
-
}
|
|
101
68
|
/** Locale-formats a settled Money value (e.g. "R$ 600,00"). Fixed to pt-BR — not because it matches
|
|
102
69
|
* every other default in this component (T31 moved every copy default here to en-US, which falsifies
|
|
103
70
|
* that reasoning) but because this component has no `locale` prop of its own to read instead: adding
|
|
@@ -231,39 +198,27 @@ const OrderPlacedPaymentSummaryDefinition = defineComponent({
|
|
|
231
198
|
default: "Could not load the payment details",
|
|
232
199
|
label: "Unresolved order label"
|
|
233
200
|
},
|
|
234
|
-
multiSellerNotice: {
|
|
235
|
-
type: "string",
|
|
236
|
-
default: "This order was split across {count} sellers; the payment summary does not cover split orders",
|
|
237
|
-
label: "Multi-seller notice"
|
|
238
|
-
},
|
|
239
201
|
installmentTemplate: {
|
|
240
202
|
type: "string",
|
|
241
203
|
default: "{count}x of {total}",
|
|
242
204
|
label: "Installment template"
|
|
243
205
|
}
|
|
244
206
|
},
|
|
245
|
-
guideline: "Read-only recap, on a post-purchase confirmation surface, of the card the shopper paid with — sourced from the settled order (Query.order), never the live order form. Owns its own fragment; requires no ancestor context, so it composes standalone. Renders exactly one of
|
|
207
|
+
guideline: "Read-only recap, on a post-purchase confirmation surface, of the card the shopper paid with — sourced from the settled order (Query.order), never the live order form. Owns its own fragment; requires no ancestor context, so it composes standalone. Renders exactly one of four states, in strict precedence: nothing while the query is in flight; a role=\"alert\" notice when the order group does not resolve; an informational line when the order resolves with no payment record; or the recap itself (network, plus last four whenever the projection carries one, plus an installment line — count and settled total only, never a per-installment amount or interest rate — whenever the settled record reports one). Never compose it in checkout — the order group it reads does not exist until the order is placed, and no component renders a payment recap there. Never renders a full card number or CVV. See order-placed-payment-summary.md."
|
|
246
208
|
});
|
|
247
209
|
/**
|
|
248
210
|
* Renders the settled order's payment recap on a confirmation surface. Resolves through
|
|
249
|
-
* `resolveOrderPlacedPayment`'s fixed precedence and renders exactly one state: the
|
|
250
|
-
*
|
|
211
|
+
* `resolveOrderPlacedPayment`'s fixed precedence and renders exactly one state: the unresolved
|
|
212
|
+
* notice as an inline `role="alert"` element (FR-6); the no-record line as plain
|
|
251
213
|
* informational text; the in-flight state as nothing at all (Decision 6); the recap as network plus
|
|
252
|
-
* last four (whenever present) plus the
|
|
253
|
-
*
|
|
214
|
+
* last four (whenever present) plus the installment line (whenever the settled record reports one,
|
|
215
|
+
* T33). Requires no context — composable standalone.
|
|
254
216
|
*/
|
|
255
|
-
function OrderPlacedPaymentSummary({ className, lastFourTemplate = "•••• {lastFour}", noPaymentRecordLabel = "Payment method not available", unresolvedOrderLabel = "Could not load the payment details",
|
|
217
|
+
function OrderPlacedPaymentSummary({ className, lastFourTemplate = "•••• {lastFour}", noPaymentRecordLabel = "Payment method not available", unresolvedOrderLabel = "Could not load the payment details", installmentTemplate = "{count}x of {total}", $data: $dataProp }) {
|
|
256
218
|
const $data = useDataOverride($dataProp);
|
|
257
|
-
const { loading
|
|
258
|
-
const resolved = resolveOrderPlacedPayment($data ?? null, loading
|
|
219
|
+
const { loading } = useContext(ReactiveRootContext);
|
|
220
|
+
const resolved = resolveOrderPlacedPayment($data ?? null, loading);
|
|
259
221
|
if (resolved.kind === "loading") return null;
|
|
260
|
-
if (resolved.kind === "multi-seller") return /* @__PURE__ */ jsx("div", {
|
|
261
|
-
className,
|
|
262
|
-
role: "alert",
|
|
263
|
-
"data-fs-order-placed-payment-summary": "",
|
|
264
|
-
"data-fs-order-placed-payment-summary-multi-seller": "",
|
|
265
|
-
children: formatMultiSellerNotice(multiSellerNotice, resolved.sellerCount)
|
|
266
|
-
});
|
|
267
222
|
if (resolved.kind === "unresolved") return /* @__PURE__ */ jsx("div", {
|
|
268
223
|
className,
|
|
269
224
|
role: "alert",
|
|
@@ -277,26 +232,19 @@ function OrderPlacedPaymentSummary({ className, lastFourTemplate = "••••
|
|
|
277
232
|
"data-fs-order-placed-payment-summary-no-record": "",
|
|
278
233
|
children: noPaymentRecordLabel
|
|
279
234
|
});
|
|
280
|
-
const { network, lastFourDigits,
|
|
235
|
+
const { network, lastFourDigits, installment } = resolved;
|
|
281
236
|
const methodText = [network, lastFourDigits ? substituteTemplate(lastFourTemplate, { lastFour: lastFourDigits }) : null].filter(Boolean).join(" ");
|
|
282
237
|
const installmentText = installment ? formatInstallmentLine(installmentTemplate, installment) : null;
|
|
283
238
|
return /* @__PURE__ */ jsxs("div", {
|
|
284
239
|
className,
|
|
285
240
|
"data-fs-order-placed-payment-summary": "",
|
|
286
|
-
children: [
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
children: label
|
|
294
|
-
}) : null,
|
|
295
|
-
installmentText ? /* @__PURE__ */ jsx("p", {
|
|
296
|
-
"data-fs-order-placed-payment-summary-installment": "",
|
|
297
|
-
children: installmentText
|
|
298
|
-
}) : null
|
|
299
|
-
]
|
|
241
|
+
children: [methodText ? /* @__PURE__ */ jsx("p", {
|
|
242
|
+
"data-fs-order-placed-payment-summary-method": "",
|
|
243
|
+
children: methodText
|
|
244
|
+
}) : null, installmentText ? /* @__PURE__ */ jsx("p", {
|
|
245
|
+
"data-fs-order-placed-payment-summary-installment": "",
|
|
246
|
+
children: installmentText
|
|
247
|
+
}) : null]
|
|
300
248
|
});
|
|
301
249
|
}
|
|
302
250
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-placed-payment-summary.js","names":[],"sources":["../../../src/matter/order-placed-payment-summary/order-placed-payment-summary.tsx"],"sourcesContent":["'use client';\n\nimport type { ErrorLike } from '@apollo/client';\nimport { CombinedGraphQLErrors } from '@apollo/client/errors';\nimport { defineComponent } from '@vtex/fs-core';\nimport { useContext } from 'react';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { ReactiveRootContext } from '../../sdk/data/page-reactive-data-root.js';\nimport { substituteTemplate } from '../../utils/substitute-template.js';\n\n/**\n * OrderPlacedPaymentSummary matter (epic `credit-card`, T17 — recap the payment on the order\n * confirmation). Single-file matter per ADR-0001: owns its own `Query.order(orderGroup: $orderGroup)`\n * fragment and sets no `requiresContext`, so it composes independently on a confirmation surface — no\n * ancestor context needed.\n *\n * This component is sourced from the settled order, never the live order form\n * (specs/order-placed-payment-summary.md, Decision 1): `Query.payment` projects the live order form\n * and stops resolving once the order is placed, so a post-purchase recap needs the settled-order\n * projection (`Query.order`, T16) instead — never compose it in checkout, and never\n * point this component at `Query.payment`.\n *\n * Read-only recap — no write affordance, no internal state; every transition is driven purely by\n * `$data`, `loading`, and the reactive root's query error (the multi-seller signal — Decision 4).\n */\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment OrderPlacedPaymentSummaryData on Query {\n order(orderGroup: $orderGroup) {\n __typename\n id\n network\n lastFourDigits\n label\n installment {\n count\n total {\n amount\n currencyCode\n }\n }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * The installment plan the order was charged in (T33, specs/settle-and-project-the-placed-\n * order.md). Null when the settled record reports none — never fabricated, never defaulted to\n * `{ count: 1 }`. `total` is null when the source carries the count but not enough to build a\n * Money from (Decision 2: the settled-order source never carries a per-installment amount or an\n * interest rate at all, see US-2).\n */\nexport type OrderPlacedInstallment = {\n count: number;\n total?: { amount: string; currencyCode: string } | null;\n} | null;\n\n/**\n * The `$data` slice forwarded by the reactive runtime. `OrderPlacedPaymentSummaryData` selects\n * exactly one top-level field (`order`), so per ADR-0015 the compiler derives a single entity\n * fragment and `$data` is the unwrapped value of that field — never a `{ order: … }` wrapper. `null`\n * when the order group does not resolve to a settled order.\n */\nexport type OrderPlacedPaymentSummaryData = {\n network?: string | null;\n lastFourDigits?: string | null;\n label?: string | null;\n installment?: OrderPlacedInstallment;\n} | null;\n\n/** The five states FR-5 resolves to, in strict, total precedence order. */\ntype ResolvedOrderPlacedPayment =\n | { kind: 'multi-seller'; sellerCount: number | null }\n | { kind: 'loading' }\n | { kind: 'unresolved' }\n | { kind: 'no-record' }\n | {\n kind: 'recap';\n network: string;\n lastFourDigits: string | null;\n label: string | null;\n installment: OrderPlacedInstallment;\n };\n\nexport type OrderPlacedPaymentSummaryProps = {\n className?: string;\n /** Rendered only when `lastFourDigits` resolves; `{lastFour}` placeholder. */\n lastFourTemplate?: string;\n /** Shown when the order resolves but carries no projectable payment record. */\n noPaymentRecordLabel?: string;\n /** Shown when the order group does not resolve to a settled order. */\n unresolvedOrderLabel?: string;\n /** Shown for a split order; `{count}` placeholder, omitted when the count is unknown. */\n multiSellerNotice?: string;\n /**\n * Rendered only when `installment` resolves; `{count}`/`{total}` placeholders. When the source\n * carries the count but not enough to build a total from (US-2 — never a fabricated per-installment\n * amount), `{total}` is dropped together with everything between `{count}`'s own glued suffix (if\n * any) and `{total}` — but a run glued directly to `{count}`, with no whitespace, is a suffix of the\n * count, not a connector, and is kept. A null total therefore degrades `'{count}x of {total}'` to\n * \"6x\" — never \"6x of\" or a bare \"6\" (see `stripTotalToken`).\n */\n installmentTemplate?: string;\n /** Unwrapped `Order` slice forwarded by the reactive runtime — never a `{ order: … }` wrapper. */\n $data?: OrderPlacedPaymentSummaryData;\n};\n\n// ---------------------------------------------------------------------------\n// Resolution\n// ---------------------------------------------------------------------------\n\nconst MULTI_SELLER_ERROR_CODE = 'UNSUPPORTED_MULTI_SELLER_ORDER';\nconst TOTAL_TOKEN = '{total}';\nconst COUNT_TOKEN = '{count}';\n\n/**\n * Extracts the multi-seller signal from the reactive root's query error (Decision 4): `Query.order`\n * throws a `GraphQLError` with `extensions.code === 'UNSUPPORTED_MULTI_SELLER_ORDER'` and\n * `extensions.sellerCount` set to the seller count, rather than returning a data field — the count\n * exists only inside the combined GraphQL error's own `errors[].extensions`, never on `$data`.\n * Returns `null` when `error` is absent, is not a `CombinedGraphQLErrors`, or carries no matching\n * entry — a differently-coded failure (e.g. a generic upstream error) falls through to the\n * `unresolved` state instead, matching FR-5's precedence.\n */\nfunction resolveMultiSellerSignal(error: ErrorLike | undefined): { sellerCount: number | null } | null {\n if (!error || !CombinedGraphQLErrors.is(error)) return null;\n const multiSellerError = error.errors.find(\n (graphQLError) => graphQLError.extensions?.code === MULTI_SELLER_ERROR_CODE,\n );\n if (!multiSellerError) return null;\n const sellerCount = multiSellerError.extensions?.sellerCount;\n return { sellerCount: typeof sellerCount === 'number' ? sellerCount : null };\n}\n\n/**\n * Resolves `$data` plus the reactive root's `loading`/`error` into exactly one of five states, in\n * FR-5's total, ordered precedence: multi-seller wins over everything else — including a resolved\n * `$data` — because in that state the one seller's card that *is* present would otherwise be shown as\n * if it were the whole payment (Decision 4). `loading && data == null` (Decision 6) separates a\n * transient in-flight window from a genuinely unresolved order group, so the unresolved alert never\n * flashes on first paint of a successful confirmation. `no-record` fires only when every recap field\n * is null — a record carrying just one of the three still renders as `recap` (Open Question 5).\n *\n * `no-record`'s gate is unchanged by T33 (FR-6, INV-6): it still checks only network/lastFourDigits/\n * label, never installment — an order carrying an installment but none of the original three fields\n * still renders `no-record`, not a recap with only an installment line.\n */\nfunction resolveOrderPlacedPayment(\n data: OrderPlacedPaymentSummaryData,\n loading: boolean,\n error: ErrorLike | undefined,\n): ResolvedOrderPlacedPayment {\n const multiSeller = resolveMultiSellerSignal(error);\n if (multiSeller) return { kind: 'multi-seller', sellerCount: multiSeller.sellerCount };\n if (loading && data == null) return { kind: 'loading' };\n if (data == null) return { kind: 'unresolved' };\n if (data.network == null && data.lastFourDigits == null && data.label == null) return { kind: 'no-record' };\n return {\n kind: 'recap',\n network: data.network ?? '',\n lastFourDigits: data.lastFourDigits ?? null,\n label: data.label ?? null,\n installment: data.installment ?? null,\n };\n}\n\n/**\n * Substitutes `{count}` when the seller count is known; otherwise drops the token and collapses the\n * resulting run of spaces, so an unknown count never prints the literal string \"undefined\" or \"NaN\".\n */\nfunction formatMultiSellerNotice(template: string, sellerCount: number | null): string {\n if (sellerCount == null) return substituteTemplate(template, { count: '' }).replace(/ {2,}/g, ' ').trim();\n return substituteTemplate(template, { count: String(sellerCount) });\n}\n\n/** Locale-formats a settled Money value (e.g. \"R$ 600,00\"). Fixed to pt-BR — not because it matches\n * every other default in this component (T31 moved every copy default here to en-US, which falsifies\n * that reasoning) but because this component has no `locale` prop of its own to read instead: adding\n * one is a formatting change, not a copy change, and is out of this task's scope (see OQ-3 in\n * specs/make-the-payment-components-authored-copy.md).\n *\n * `currencyCode` reaches this function already validated: `Money.currencyCode` is `CurrencyCode!`,\n * a GraphQL enum (`base/schema.graphql:186,206`), so a value outside the declared members fails\n * GraphQL's own enum serialization server-side and nulls `total` before it ever reaches a query\n * result — verified against this app's exact `buildSubgraphSchema` wiring (T33 fix pass: an empty\n * string / \"XX\" / \"BRLL\" each produced a `total: null` field error, never a value reaching here).\n * The try/catch below is defense in depth only, for a caller that bypasses that enum entirely (a\n * Storybook fixture, a `$data` override, a future schema change) — never expected to fire against a\n * real query response. */\nfunction formatMoney(money: { amount: string; currencyCode: string }): string {\n try {\n return new Intl.NumberFormat('pt-BR', { style: 'currency', currency: money.currencyCode }).format(\n Number(money.amount),\n );\n } catch {\n return money.amount;\n }\n}\n\n/**\n * Drops the `{total}` placeholder from the RAW template — before `{count}` is substituted — together\n * with the WHOLE run of text between `{count}`'s own glued suffix (if any) and `{total}`, not merely\n * one connector word (Decision 8, T31 — specs/make-the-payment-components-authored-copy.md; this\n * hardens FR-12/T97's original single-run rule, which dropped only one word and left a multi-word\n * connector dangling, e.g. `'{count}x no valor total de {total}'` degrading to \"6x no valor total\").\n *\n * When `{count}` appears before `{total}`, this scans FORWARD from the end of `{count}` to the first\n * whitespace character: that run (possibly zero-length) is the count's own glued suffix — a unit\n * symbol like \"x\"/\"×\"/\"回\", never a connector — and is kept verbatim; everything from there through\n * `{total}` itself is dropped. When no whitespace separates `{count}` from `{total}` at all, the whole\n * run between them is glued and kept, and only the `{total}` token is dropped. A null total therefore\n * degrades `'{count}x of {total}'` to \"6x\" (the whitespace-separated run \"of\" is dropped in full),\n * `'{count}x {total}'` to \"6x\" (the \"x\" is glued to `{count}`, so it survives even though `{total}`\n * does not), `'{count}x{total}'` to \"6x\" too (no whitespace at all between them — the glued run,\n * `{total}` aside, is kept), and `'{count} parcelas de {total}'` — a self-contained unit noun with no\n * glued suffix — to a bare \"6\": no algorithm can tell \"parcelas\" apart from a dangling preposition, so\n * the same deterministic rule that kills every dangling phrase also takes a legitimate unit noun with\n * it (OQ-2). This applies wherever `{count}` sits in the template, not only at its start (`'Paid\n * {count}x {total}'` → \"Paid 6x\").\n *\n * The forward scan is bounded so it can never cross into `{total}`: `{total}` is a fixed literal\n * marker with a known position, unlike the count's own digits once substituted, which could otherwise\n * be mistaken for a connector by shape alone. Running this on the raw template — and only substituting\n * `{count}` afterward — is what keeps the count itself from ever being the thing removed (FR-4: the\n * element must always render when `count` resolves, for any template that contains `{count}`).\n *\n * Two edge cases are deliberate limits of this rule, not bugs to chase. `'{count} x {total}'` still\n * degrades to \"6\": a whitespace-separated single-character \"x\" is by construction indistinguishable\n * from a connector word, so it is dropped along with it — that IS the rule's principle, not an\n * exception to it. `'{count}-{total}'` degrades to \"6-\": the glued \"-\" is kept verbatim as the\n * author's own template text, whatever character it is. Both outcomes are stable and predictable,\n * which is the point.\n *\n * When `{count}` does not appear before `{total}` at all (a template that never shows the count, e.g.\n * `'Total: {total}'`), there is no boundary to scan forward from, and this path is unchanged from\n * before Decision 8: walk backward from `{total}`, drop one connector run and its surrounding\n * whitespace, and fall back to cutting the bare `{total}` token only when that would leave nothing but\n * whitespace (`installmentTemplate = '{total}'` collapses to `''`). FR-4's \"always renders when count\n * resolves\" guarantee is therefore scoped to templates that contain `{count}`; a total-only template\n * never had a count to render, and asked for the total alone.\n */\nfunction stripTotalToken(template: string): string {\n const totalIndex = template.indexOf(TOTAL_TOKEN);\n if (totalIndex === -1) return template;\n\n const countIndex = template.indexOf(COUNT_TOKEN);\n const countEnd = countIndex + COUNT_TOKEN.length;\n const hasCountBoundary = countIndex !== -1 && countEnd <= totalIndex;\n\n const isWhitespaceAt = (index: number) => /\\s/.test(template[index] ?? '');\n\n if (hasCountBoundary) {\n // Forward scan (Decision 8): the count's own glued suffix runs from countEnd up to the first\n // whitespace, or up to {total} itself when there is no whitespace between them at all.\n let gluedEnd = countEnd;\n while (gluedEnd < totalIndex && !isWhitespaceAt(gluedEnd)) gluedEnd++;\n return template.slice(0, gluedEnd) + template.slice(totalIndex + TOTAL_TOKEN.length);\n }\n\n // No {count} precedes {total} (e.g. \"Total: {total}\") — there is no boundary to stop a\n // connector-removal scan at, so this walks backward from {total} exactly as it did before Decision\n // 8: drop the whitespace immediately before {total}, then the one connector run before that, falling\n // back to dropping only the bare {total} token when removing the connector would leave nothing but\n // whitespace. Unchanged by Decision 8.\n let cursor = totalIndex;\n while (cursor > 0 && isWhitespaceAt(cursor - 1)) cursor--; // whitespace right before {total}\n while (cursor > 0 && !isWhitespaceAt(cursor - 1)) cursor--; // the candidate connector run\n while (cursor > 0 && isWhitespaceAt(cursor - 1)) cursor--; // whitespace right before the connector\n\n const withConnectorDropped = template.slice(0, cursor) + template.slice(totalIndex + TOTAL_TOKEN.length);\n if (withConnectorDropped.trim() !== '') return withConnectorDropped;\n\n return template.slice(0, totalIndex) + template.slice(totalIndex + TOTAL_TOKEN.length);\n}\n\n/**\n * Substitutes `{count}` and `{total}` with replacer FUNCTIONS, not replacement strings (FR-5, the\n * same S1 fix `lastFourText` below applies to `lastFourTemplate`): `total.amount`/`total.currencyCode`\n * are server-sourced and unconstrained, so a replacement STRING could let a hostile value rewrite the\n * surrounding template text via `$&`/`` $` ``/`$'`/`$$`.\n *\n * When total is null, `{total}` and its connector word are dropped by `stripTotalToken` — on the raw\n * template, before `{count}` is substituted; see that function's doc comment for the exact rule. A\n * prior version ran an unanchored regex over the ALREADY-substituted string and, for any template\n * where the connector sits right next to `{count}` with only whitespace further out (e.g.\n * `'{count}x {total}'`), matched from the very start of the string and deleted the count along with\n * the connector, silently un-rendering the whole line (T33 fix-round-2 regression).\n */\nfunction formatInstallmentLine(\n template: string,\n installment: { count: number; total?: { amount: string; currencyCode: string } | null },\n): string {\n const { total } = installment;\n if (!total) {\n return substituteTemplate(stripTotalToken(template), { count: String(installment.count) }).trim();\n }\n return substituteTemplate(template, { count: String(installment.count), total: formatMoney(total) }).trim();\n}\n\n// ---------------------------------------------------------------------------\n// Definition\n// ---------------------------------------------------------------------------\n\nexport const OrderPlacedPaymentSummaryDefinition = defineComponent<OrderPlacedPaymentSummaryProps>({\n name: 'OrderPlacedPaymentSummary',\n importPath: '@vtex/faststore/components',\n component: OrderPlacedPaymentSummary,\n fragment,\n fetchStrategy: 'reactive',\n editor: { label: 'Order Placed Payment Summary', category: 'commerce' },\n schema: {\n lastFourTemplate: { type: 'string', default: '•••• {lastFour}', label: 'Last-four template' },\n noPaymentRecordLabel: {\n type: 'string',\n default: 'Payment method not available',\n label: 'No payment record label',\n },\n unresolvedOrderLabel: {\n type: 'string',\n default: 'Could not load the payment details',\n label: 'Unresolved order label',\n },\n multiSellerNotice: {\n type: 'string',\n default: 'This order was split across {count} sellers; the payment summary does not cover split orders',\n label: 'Multi-seller notice',\n },\n installmentTemplate: {\n type: 'string',\n default: '{count}x of {total}',\n label: 'Installment template',\n },\n },\n guideline:\n 'Read-only recap, on a post-purchase confirmation surface, of the card the shopper paid with — sourced from the settled order (Query.order), never the live order form. Owns its own fragment; requires no ancestor context, so it composes standalone. Renders exactly one of five states, in strict precedence: a role=\"alert\" notice for a split (multi-seller) order — the projection never covers one; nothing while the query is in flight; a role=\"alert\" notice when the order group does not resolve; an informational line when the order resolves with no payment record; or the recap itself (network, plus last four whenever the projection carries one, plus the saved-card label when set, plus an installment line — count and settled total only, never a per-installment amount or interest rate — whenever the settled record reports one). Never compose it in checkout — the order group it reads does not exist until the order is placed, and no component renders a payment recap there. Never renders a full card number or CVV. See order-placed-payment-summary.md.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\n/**\n * Renders the settled order's payment recap on a confirmation surface. Resolves through\n * `resolveOrderPlacedPayment`'s fixed precedence and renders exactly one state: the multi-seller and\n * unresolved notices as inline `role=\"alert\"` elements (FR-6); the no-record line as plain\n * informational text; the in-flight state as nothing at all (Decision 6); the recap as network plus\n * last four (whenever present) plus the saved-card label (whenever set) plus the installment line\n * (whenever the settled record reports one, T33). Requires no context — composable standalone.\n */\nexport function OrderPlacedPaymentSummary({\n className,\n lastFourTemplate = '•••• {lastFour}',\n noPaymentRecordLabel = 'Payment method not available',\n unresolvedOrderLabel = 'Could not load the payment details',\n multiSellerNotice = 'This order was split across {count} sellers; the payment summary does not cover split orders',\n installmentTemplate = '{count}x of {total}',\n $data: $dataProp,\n}: OrderPlacedPaymentSummaryProps) {\n const $data = useDataOverride($dataProp);\n const { loading, error } = useContext(ReactiveRootContext);\n const resolved = resolveOrderPlacedPayment($data ?? null, loading, error);\n\n if (resolved.kind === 'loading') return null;\n\n if (resolved.kind === 'multi-seller') {\n return (\n <div\n className={className}\n role=\"alert\"\n data-fs-order-placed-payment-summary=\"\"\n data-fs-order-placed-payment-summary-multi-seller=\"\"\n >\n {formatMultiSellerNotice(multiSellerNotice, resolved.sellerCount)}\n </div>\n );\n }\n\n if (resolved.kind === 'unresolved') {\n return (\n <div\n className={className}\n role=\"alert\"\n data-fs-order-placed-payment-summary=\"\"\n data-fs-order-placed-payment-summary-unresolved=\"\"\n >\n {unresolvedOrderLabel}\n </div>\n );\n }\n\n if (resolved.kind === 'no-record') {\n return (\n <div\n className={className}\n data-fs-order-placed-payment-summary=\"\"\n data-fs-order-placed-payment-summary-no-record=\"\"\n >\n {noPaymentRecordLabel}\n </div>\n );\n }\n\n const { network, lastFourDigits, label, installment } = resolved;\n // `substituteTemplate` inserts every value literally (Decision 7): lastFourDigits is server-sourced\n // and unconstrained (a plain `String` in the schema, mapped straight from VTEX's payment.lastDigits\n // with no length/charset check — schema.graphql:2508, mappers.ts:650), so a hostile or buggy\n // upstream value can never rewrite the surrounding template text (S1).\n const lastFourText = lastFourDigits ? substituteTemplate(lastFourTemplate, { lastFour: lastFourDigits }) : null;\n // network/lastFourDigits/label are each independently nullable (schema.graphql:2496-2516,\n // mappers.ts:649-651) — the no-record gate above fires only when ALL THREE are null (FR-5), so a\n // record carrying just one or two of them still reaches this branch. Joining only the present parts\n // avoids a leading space (network null, lastFourDigits set) and avoids rendering an empty <p> above\n // the label line (network and lastFourDigits both null, label set) — the exact blank US-2 forbids\n // (R2).\n const methodText = [network, lastFourText].filter(Boolean).join(' ');\n // FR-4/FR-6: rendered whenever installment resolves, regardless of the count's value (Open\n // Question 3 — whether to suppress at count <= 1 — is left to a future product decision; this\n // component has no such special case today), and only inside this recap branch.\n const installmentText = installment ? formatInstallmentLine(installmentTemplate, installment) : null;\n\n return (\n <div className={className} data-fs-order-placed-payment-summary=\"\">\n {methodText ? <p data-fs-order-placed-payment-summary-method=\"\">{methodText}</p> : null}\n {label ? <p data-fs-order-placed-payment-summary-label=\"\">{label}</p> : null}\n {installmentText ? <p data-fs-order-placed-payment-summary-installment=\"\">{installmentText}</p> : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,WAAyB;;;;;;;;;;;;;;;;;;AAyF/B,MAAM,0BAA0B;AAChC,MAAM,cAAc;AACpB,MAAM,cAAc;;;;;;;;;;AAWpB,SAAS,yBAAyB,OAAqE;CACrG,IAAI,CAAC,SAAS,CAAC,sBAAsB,GAAG,KAAK,GAAG,OAAO;CACvD,MAAM,mBAAmB,MAAM,OAAO,MACnC,iBAAiB,aAAa,YAAY,SAAS,uBACtD;CACA,IAAI,CAAC,kBAAkB,OAAO;CAC9B,MAAM,cAAc,iBAAiB,YAAY;CACjD,OAAO,EAAE,aAAa,OAAO,gBAAgB,WAAW,cAAc,KAAK;AAC7E;;;;;;;;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
{"version":3,"file":"order-placed-payment-summary.js","names":[],"sources":["../../../src/matter/order-placed-payment-summary/order-placed-payment-summary.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport { useContext } from 'react';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { ReactiveRootContext } from '../../sdk/data/page-reactive-data-root.js';\nimport { substituteTemplate } from '../../utils/substitute-template.js';\n\n/**\n * OrderPlacedPaymentSummary matter (epic `credit-card`, T17 — recap the payment on the order\n * confirmation). Single-file matter per ADR-0001: owns its own `Query.order(orderGroup: $orderGroup)`\n * fragment and sets no `requiresContext`, so it composes independently on a confirmation surface — no\n * ancestor context needed.\n *\n * This component is sourced from the settled order, never the live order form\n * (specs/order-placed-payment-summary.md, Decision 1): `Query.payment` projects the live order form\n * and stops resolving once the order is placed, so a post-purchase recap needs the settled-order\n * projection (`Query.order`, T16) instead — never compose it in checkout, and never\n * point this component at `Query.payment`.\n *\n * Read-only recap — no write affordance, no internal state; every transition is driven purely by\n * `$data` and `loading`.\n */\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment OrderPlacedPaymentSummaryData on Query {\n order(orderGroup: $orderGroup) {\n __typename\n id\n network\n lastFourDigits\n installment {\n count\n total {\n amount\n currencyCode\n }\n }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * The installment plan the order was charged in (T33, specs/settle-and-project-the-placed-\n * order.md). Null when the settled record reports none — never fabricated, never defaulted to\n * `{ count: 1 }`. `total` is null when the source carries the count but not enough to build a\n * Money from (Decision 2: the settled-order source never carries a per-installment amount or an\n * interest rate at all, see US-2).\n */\nexport type OrderPlacedInstallment = {\n count: number;\n total?: { amount: string; currencyCode: string } | null;\n} | null;\n\n/**\n * The `$data` slice forwarded by the reactive runtime. `OrderPlacedPaymentSummaryData` selects\n * exactly one top-level field (`order`), so per ADR-0015 the compiler derives a single entity\n * fragment and `$data` is the unwrapped value of that field — never a `{ order: … }` wrapper. `null`\n * when the order group does not resolve to a settled order.\n */\nexport type OrderPlacedPaymentSummaryData = {\n network?: string | null;\n lastFourDigits?: string | null;\n installment?: OrderPlacedInstallment;\n} | null;\n\n/** The four states the recap resolves to, in strict, total precedence order. */\ntype ResolvedOrderPlacedPayment =\n | { kind: 'loading' }\n | { kind: 'unresolved' }\n | { kind: 'no-record' }\n | {\n kind: 'recap';\n network: string;\n lastFourDigits: string | null;\n installment: OrderPlacedInstallment;\n };\n\nexport type OrderPlacedPaymentSummaryProps = {\n className?: string;\n /** Rendered only when `lastFourDigits` resolves; `{lastFour}` placeholder. */\n lastFourTemplate?: string;\n /** Shown when the order resolves but carries no projectable payment record. */\n noPaymentRecordLabel?: string;\n /** Shown when the order group does not resolve to a settled order. */\n unresolvedOrderLabel?: string;\n /**\n * Rendered only when `installment` resolves; `{count}`/`{total}` placeholders. When the source\n * carries the count but not enough to build a total from (US-2 — never a fabricated per-installment\n * amount), `{total}` is dropped together with everything between `{count}`'s own glued suffix (if\n * any) and `{total}` — but a run glued directly to `{count}`, with no whitespace, is a suffix of the\n * count, not a connector, and is kept. A null total therefore degrades `'{count}x of {total}'` to\n * \"6x\" — never \"6x of\" or a bare \"6\" (see `stripTotalToken`).\n */\n installmentTemplate?: string;\n /** Unwrapped `Order` slice forwarded by the reactive runtime — never a `{ order: … }` wrapper. */\n $data?: OrderPlacedPaymentSummaryData;\n};\n\n// ---------------------------------------------------------------------------\n// Resolution\n// ---------------------------------------------------------------------------\n\nconst TOTAL_TOKEN = '{total}';\nconst COUNT_TOKEN = '{count}';\n\n/**\n * Resolves `$data` plus the reactive root's `loading` into exactly one of four states, in a total,\n * ordered precedence. A split purchase is read whole (docs/features/order-placed/rfc.md, 3.1), so no\n * error carries a state of its own: any failed read leaves `$data` null and resolves to `unresolved`.\n * `loading && data == null` separates a transient in-flight window from a genuinely unresolved order\n * group, so the unresolved alert never flashes on first paint of a successful confirmation. `no-record` fires only when network and\n * lastFourDigits are both null — a record carrying either still renders as `recap` (Open Question 5).\n *\n * `no-record`'s gate never reads installment (FR-6, INV-6): an order carrying an installment but\n * neither network nor lastFourDigits still renders `no-record`, not a recap with only an installment\n * line. The order system sends no card label, so the recap reads none\n * (docs/features/order-placed/rfc.md, 4.5).\n */\nfunction resolveOrderPlacedPayment(data: OrderPlacedPaymentSummaryData, loading: boolean): ResolvedOrderPlacedPayment {\n if (loading && data == null) return { kind: 'loading' };\n if (data == null) return { kind: 'unresolved' };\n if (data.network == null && data.lastFourDigits == null) return { kind: 'no-record' };\n return {\n kind: 'recap',\n network: data.network ?? '',\n lastFourDigits: data.lastFourDigits ?? null,\n installment: data.installment ?? null,\n };\n}\n\n/** Locale-formats a settled Money value (e.g. \"R$ 600,00\"). Fixed to pt-BR — not because it matches\n * every other default in this component (T31 moved every copy default here to en-US, which falsifies\n * that reasoning) but because this component has no `locale` prop of its own to read instead: adding\n * one is a formatting change, not a copy change, and is out of this task's scope (see OQ-3 in\n * specs/make-the-payment-components-authored-copy.md).\n *\n * `currencyCode` reaches this function already validated: `Money.currencyCode` is `CurrencyCode!`,\n * a GraphQL enum (`base/schema.graphql:186,206`), so a value outside the declared members fails\n * GraphQL's own enum serialization server-side and nulls `total` before it ever reaches a query\n * result — verified against this app's exact `buildSubgraphSchema` wiring (T33 fix pass: an empty\n * string / \"XX\" / \"BRLL\" each produced a `total: null` field error, never a value reaching here).\n * The try/catch below is defense in depth only, for a caller that bypasses that enum entirely (a\n * Storybook fixture, a `$data` override, a future schema change) — never expected to fire against a\n * real query response. */\nfunction formatMoney(money: { amount: string; currencyCode: string }): string {\n try {\n return new Intl.NumberFormat('pt-BR', { style: 'currency', currency: money.currencyCode }).format(\n Number(money.amount),\n );\n } catch {\n return money.amount;\n }\n}\n\n/**\n * Drops the `{total}` placeholder from the RAW template — before `{count}` is substituted — together\n * with the WHOLE run of text between `{count}`'s own glued suffix (if any) and `{total}`, not merely\n * one connector word (Decision 8, T31 — specs/make-the-payment-components-authored-copy.md; this\n * hardens FR-12/T97's original single-run rule, which dropped only one word and left a multi-word\n * connector dangling, e.g. `'{count}x no valor total de {total}'` degrading to \"6x no valor total\").\n *\n * When `{count}` appears before `{total}`, this scans FORWARD from the end of `{count}` to the first\n * whitespace character: that run (possibly zero-length) is the count's own glued suffix — a unit\n * symbol like \"x\"/\"×\"/\"回\", never a connector — and is kept verbatim; everything from there through\n * `{total}` itself is dropped. When no whitespace separates `{count}` from `{total}` at all, the whole\n * run between them is glued and kept, and only the `{total}` token is dropped. A null total therefore\n * degrades `'{count}x of {total}'` to \"6x\" (the whitespace-separated run \"of\" is dropped in full),\n * `'{count}x {total}'` to \"6x\" (the \"x\" is glued to `{count}`, so it survives even though `{total}`\n * does not), `'{count}x{total}'` to \"6x\" too (no whitespace at all between them — the glued run,\n * `{total}` aside, is kept), and `'{count} parcelas de {total}'` — a self-contained unit noun with no\n * glued suffix — to a bare \"6\": no algorithm can tell \"parcelas\" apart from a dangling preposition, so\n * the same deterministic rule that kills every dangling phrase also takes a legitimate unit noun with\n * it (OQ-2). This applies wherever `{count}` sits in the template, not only at its start (`'Paid\n * {count}x {total}'` → \"Paid 6x\").\n *\n * The forward scan is bounded so it can never cross into `{total}`: `{total}` is a fixed literal\n * marker with a known position, unlike the count's own digits once substituted, which could otherwise\n * be mistaken for a connector by shape alone. Running this on the raw template — and only substituting\n * `{count}` afterward — is what keeps the count itself from ever being the thing removed (FR-4: the\n * element must always render when `count` resolves, for any template that contains `{count}`).\n *\n * Two edge cases are deliberate limits of this rule, not bugs to chase. `'{count} x {total}'` still\n * degrades to \"6\": a whitespace-separated single-character \"x\" is by construction indistinguishable\n * from a connector word, so it is dropped along with it — that IS the rule's principle, not an\n * exception to it. `'{count}-{total}'` degrades to \"6-\": the glued \"-\" is kept verbatim as the\n * author's own template text, whatever character it is. Both outcomes are stable and predictable,\n * which is the point.\n *\n * When `{count}` does not appear before `{total}` at all (a template that never shows the count, e.g.\n * `'Total: {total}'`), there is no boundary to scan forward from, and this path is unchanged from\n * before Decision 8: walk backward from `{total}`, drop one connector run and its surrounding\n * whitespace, and fall back to cutting the bare `{total}` token only when that would leave nothing but\n * whitespace (`installmentTemplate = '{total}'` collapses to `''`). FR-4's \"always renders when count\n * resolves\" guarantee is therefore scoped to templates that contain `{count}`; a total-only template\n * never had a count to render, and asked for the total alone.\n */\nfunction stripTotalToken(template: string): string {\n const totalIndex = template.indexOf(TOTAL_TOKEN);\n if (totalIndex === -1) return template;\n\n const countIndex = template.indexOf(COUNT_TOKEN);\n const countEnd = countIndex + COUNT_TOKEN.length;\n const hasCountBoundary = countIndex !== -1 && countEnd <= totalIndex;\n\n const isWhitespaceAt = (index: number) => /\\s/.test(template[index] ?? '');\n\n if (hasCountBoundary) {\n // Forward scan (Decision 8): the count's own glued suffix runs from countEnd up to the first\n // whitespace, or up to {total} itself when there is no whitespace between them at all.\n let gluedEnd = countEnd;\n while (gluedEnd < totalIndex && !isWhitespaceAt(gluedEnd)) gluedEnd++;\n return template.slice(0, gluedEnd) + template.slice(totalIndex + TOTAL_TOKEN.length);\n }\n\n // No {count} precedes {total} (e.g. \"Total: {total}\") — there is no boundary to stop a\n // connector-removal scan at, so this walks backward from {total} exactly as it did before Decision\n // 8: drop the whitespace immediately before {total}, then the one connector run before that, falling\n // back to dropping only the bare {total} token when removing the connector would leave nothing but\n // whitespace. Unchanged by Decision 8.\n let cursor = totalIndex;\n while (cursor > 0 && isWhitespaceAt(cursor - 1)) cursor--; // whitespace right before {total}\n while (cursor > 0 && !isWhitespaceAt(cursor - 1)) cursor--; // the candidate connector run\n while (cursor > 0 && isWhitespaceAt(cursor - 1)) cursor--; // whitespace right before the connector\n\n const withConnectorDropped = template.slice(0, cursor) + template.slice(totalIndex + TOTAL_TOKEN.length);\n if (withConnectorDropped.trim() !== '') return withConnectorDropped;\n\n return template.slice(0, totalIndex) + template.slice(totalIndex + TOTAL_TOKEN.length);\n}\n\n/**\n * Substitutes `{count}` and `{total}` with replacer FUNCTIONS, not replacement strings (FR-5, the\n * same S1 fix `lastFourText` below applies to `lastFourTemplate`): `total.amount`/`total.currencyCode`\n * are server-sourced and unconstrained, so a replacement STRING could let a hostile value rewrite the\n * surrounding template text via `$&`/`` $` ``/`$'`/`$$`.\n *\n * When total is null, `{total}` and its connector word are dropped by `stripTotalToken` — on the raw\n * template, before `{count}` is substituted; see that function's doc comment for the exact rule. A\n * prior version ran an unanchored regex over the ALREADY-substituted string and, for any template\n * where the connector sits right next to `{count}` with only whitespace further out (e.g.\n * `'{count}x {total}'`), matched from the very start of the string and deleted the count along with\n * the connector, silently un-rendering the whole line (T33 fix-round-2 regression).\n */\nfunction formatInstallmentLine(\n template: string,\n installment: { count: number; total?: { amount: string; currencyCode: string } | null },\n): string {\n const { total } = installment;\n if (!total) {\n return substituteTemplate(stripTotalToken(template), { count: String(installment.count) }).trim();\n }\n return substituteTemplate(template, { count: String(installment.count), total: formatMoney(total) }).trim();\n}\n\n// ---------------------------------------------------------------------------\n// Definition\n// ---------------------------------------------------------------------------\n\nexport const OrderPlacedPaymentSummaryDefinition = defineComponent<OrderPlacedPaymentSummaryProps>({\n name: 'OrderPlacedPaymentSummary',\n importPath: '@vtex/faststore/components',\n component: OrderPlacedPaymentSummary,\n fragment,\n fetchStrategy: 'reactive',\n editor: { label: 'Order Placed Payment Summary', category: 'commerce' },\n schema: {\n lastFourTemplate: { type: 'string', default: '•••• {lastFour}', label: 'Last-four template' },\n noPaymentRecordLabel: {\n type: 'string',\n default: 'Payment method not available',\n label: 'No payment record label',\n },\n unresolvedOrderLabel: {\n type: 'string',\n default: 'Could not load the payment details',\n label: 'Unresolved order label',\n },\n installmentTemplate: {\n type: 'string',\n default: '{count}x of {total}',\n label: 'Installment template',\n },\n },\n guideline:\n 'Read-only recap, on a post-purchase confirmation surface, of the card the shopper paid with — sourced from the settled order (Query.order), never the live order form. Owns its own fragment; requires no ancestor context, so it composes standalone. Renders exactly one of four states, in strict precedence: nothing while the query is in flight; a role=\"alert\" notice when the order group does not resolve; an informational line when the order resolves with no payment record; or the recap itself (network, plus last four whenever the projection carries one, plus an installment line — count and settled total only, never a per-installment amount or interest rate — whenever the settled record reports one). Never compose it in checkout — the order group it reads does not exist until the order is placed, and no component renders a payment recap there. Never renders a full card number or CVV. See order-placed-payment-summary.md.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\n/**\n * Renders the settled order's payment recap on a confirmation surface. Resolves through\n * `resolveOrderPlacedPayment`'s fixed precedence and renders exactly one state: the unresolved\n * notice as an inline `role=\"alert\"` element (FR-6); the no-record line as plain\n * informational text; the in-flight state as nothing at all (Decision 6); the recap as network plus\n * last four (whenever present) plus the installment line (whenever the settled record reports one,\n * T33). Requires no context — composable standalone.\n */\nexport function OrderPlacedPaymentSummary({\n className,\n lastFourTemplate = '•••• {lastFour}',\n noPaymentRecordLabel = 'Payment method not available',\n unresolvedOrderLabel = 'Could not load the payment details',\n installmentTemplate = '{count}x of {total}',\n $data: $dataProp,\n}: OrderPlacedPaymentSummaryProps) {\n const $data = useDataOverride($dataProp);\n const { loading } = useContext(ReactiveRootContext);\n const resolved = resolveOrderPlacedPayment($data ?? null, loading);\n\n if (resolved.kind === 'loading') return null;\n\n if (resolved.kind === 'unresolved') {\n return (\n <div\n className={className}\n role=\"alert\"\n data-fs-order-placed-payment-summary=\"\"\n data-fs-order-placed-payment-summary-unresolved=\"\"\n >\n {unresolvedOrderLabel}\n </div>\n );\n }\n\n if (resolved.kind === 'no-record') {\n return (\n <div\n className={className}\n data-fs-order-placed-payment-summary=\"\"\n data-fs-order-placed-payment-summary-no-record=\"\"\n >\n {noPaymentRecordLabel}\n </div>\n );\n }\n\n const { network, lastFourDigits, installment } = resolved;\n // `substituteTemplate` inserts every value literally (Decision 7): lastFourDigits is server-sourced\n // and unconstrained (a plain `String` in the schema, mapped straight from VTEX's payment.lastDigits\n // with no length/charset check — schema.graphql:2508, mappers.ts:650), so a hostile or buggy\n // upstream value can never rewrite the surrounding template text (S1).\n const lastFourText = lastFourDigits ? substituteTemplate(lastFourTemplate, { lastFour: lastFourDigits }) : null;\n // network and lastFourDigits are each independently nullable (schema.graphql:2496-2516,\n // mappers.ts:649-651) — the no-record gate above fires only when BOTH are null (FR-5), so a record\n // carrying just one of them still reaches this branch. Joining only the present parts avoids a\n // leading space (network null, lastFourDigits set) (R2).\n const methodText = [network, lastFourText].filter(Boolean).join(' ');\n // FR-4/FR-6: rendered whenever installment resolves, regardless of the count's value (Open\n // Question 3 — whether to suppress at count <= 1 — is left to a future product decision; this\n // component has no such special case today), and only inside this recap branch.\n const installmentText = installment ? formatInstallmentLine(installmentTemplate, installment) : null;\n\n return (\n <div className={className} data-fs-order-placed-payment-summary=\"\">\n {methodText ? <p data-fs-order-placed-payment-summary-method=\"\">{methodText}</p> : null}\n {installmentText ? <p data-fs-order-placed-payment-summary-installment=\"\">{installmentText}</p> : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,WAAyB;;;;;;;;;;;;;;;;;AAmF/B,MAAM,cAAc;AACpB,MAAM,cAAc;;;;;;;;;;;;;;AAepB,SAAS,0BAA0B,MAAqC,SAA8C;CACpH,IAAI,WAAW,QAAQ,MAAM,OAAO,EAAE,MAAM,UAAU;CACtD,IAAI,QAAQ,MAAM,OAAO,EAAE,MAAM,aAAa;CAC9C,IAAI,KAAK,WAAW,QAAQ,KAAK,kBAAkB,MAAM,OAAO,EAAE,MAAM,YAAY;CACpF,OAAO;EACL,MAAM;EACN,SAAS,KAAK,WAAW;EACzB,gBAAgB,KAAK,kBAAkB;EACvC,aAAa,KAAK,eAAe;CACnC;AACF;;;;;;;;;;;;;;;AAgBA,SAAS,YAAY,OAAyD;CAC5E,IAAI;EACF,OAAO,IAAI,KAAK,aAAa,SAAS;GAAE,OAAO;GAAY,UAAU,MAAM;EAAa,CAAC,CAAC,CAAC,OACzF,OAAO,MAAM,MAAM,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;GAAI,UAAA;EAAmB,CAAA,IAAI,IAC/F;;AAET"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { ContentValue } from "../../core/dist/define-content-type.js";
|
|
2
|
+
import { ComponentDefinition } from "../../core/dist/define-component.js";
|
|
3
|
+
import "../../core/dist/index.js";
|
|
4
|
+
import { ComponentPropsWithRef, Ref } from "react";
|
|
5
|
+
//#region src/matter/order-progress/order-progress.d.ts
|
|
6
|
+
export declare const OrderProgressContent: {
|
|
7
|
+
readonly id: "order-progress";
|
|
8
|
+
readonly title: "Order Progress";
|
|
9
|
+
readonly description: "The stage names, the state sentences, and the accessible name of the progress list.";
|
|
10
|
+
readonly schema: {
|
|
11
|
+
readonly type: "object";
|
|
12
|
+
readonly additionalProperties: false;
|
|
13
|
+
readonly properties: {
|
|
14
|
+
readonly label: {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
readonly title: "Accessible name";
|
|
17
|
+
};
|
|
18
|
+
readonly placed: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
readonly title: "Order placed";
|
|
21
|
+
};
|
|
22
|
+
readonly payment: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly title: "Payment";
|
|
25
|
+
};
|
|
26
|
+
readonly processing: {
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
readonly title: "Processing";
|
|
29
|
+
};
|
|
30
|
+
readonly shipping: {
|
|
31
|
+
readonly type: "string";
|
|
32
|
+
readonly title: "Shipping";
|
|
33
|
+
};
|
|
34
|
+
readonly stateDone: {
|
|
35
|
+
readonly type: "string";
|
|
36
|
+
readonly title: "Completed";
|
|
37
|
+
};
|
|
38
|
+
readonly stateCurrent: {
|
|
39
|
+
readonly type: "string";
|
|
40
|
+
readonly title: "In progress";
|
|
41
|
+
};
|
|
42
|
+
readonly statePending: {
|
|
43
|
+
readonly type: "string";
|
|
44
|
+
readonly title: "Not started";
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export type OrderProgressContentValue = ContentValue<typeof OrderProgressContent>;
|
|
50
|
+
export type OrderProgressStage = 'placed' | 'payment' | 'processing' | 'shipping';
|
|
51
|
+
export type OrderProgressStageState = 'done' | 'current' | 'failed' | 'not-applicable' | 'pending';
|
|
52
|
+
export type OrderProgressLineState = 'done' | 'pending' | 'not-applicable';
|
|
53
|
+
export type OrderProgressOrder = {
|
|
54
|
+
id: string;
|
|
55
|
+
completion: {
|
|
56
|
+
view: string;
|
|
57
|
+
label: string;
|
|
58
|
+
};
|
|
59
|
+
progress: {
|
|
60
|
+
stage: string;
|
|
61
|
+
paymentFailed: boolean;
|
|
62
|
+
cancelled: boolean;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* The `customerOrder` root the generator passes as `$data`. A single-root fragment is bound to
|
|
67
|
+
* that field's value, so this is the order itself, or null when the read resolves nothing.
|
|
68
|
+
*/
|
|
69
|
+
export type OrderProgressData = OrderProgressOrder | null;
|
|
70
|
+
export type OrderProgressProps = Readonly<{
|
|
71
|
+
$data?: OrderProgressData | null;
|
|
72
|
+
$content?: OrderProgressContentValue;
|
|
73
|
+
className?: string;
|
|
74
|
+
ref?: Ref<HTMLOListElement>;
|
|
75
|
+
}>;
|
|
76
|
+
export declare const OrderProgressDefinition: ComponentDefinition<Readonly<{
|
|
77
|
+
$data?: OrderProgressData | null;
|
|
78
|
+
$content?: OrderProgressContentValue;
|
|
79
|
+
className?: string;
|
|
80
|
+
ref?: Ref<HTMLOListElement>;
|
|
81
|
+
}>>;
|
|
82
|
+
export declare function OrderProgressSkeleton({ className, ...props }: ComponentPropsWithRef<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
83
|
+
export declare function OrderProgress({ $data, $content, className, ref }: OrderProgressProps): import("react/jsx-runtime").JSX.Element | null;
|
|
84
|
+
//#endregion
|
|
85
|
+
//# sourceMappingURL=order-progress.d.ts.map
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { defineComponent } from "../../core/dist/define-component.js";
|
|
3
|
+
import { defineContentType } from "../../core/dist/define-content-type.js";
|
|
4
|
+
import "../../core/dist/index.js";
|
|
5
|
+
import { useIntl } from "../../sdk/i18n/client.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/matter/order-progress/order-progress.tsx
|
|
8
|
+
const fragment = `
|
|
9
|
+
fragment OrderProgressData on Query {
|
|
10
|
+
customerOrder(id: $orderId) {
|
|
11
|
+
id
|
|
12
|
+
completion {
|
|
13
|
+
view
|
|
14
|
+
label
|
|
15
|
+
}
|
|
16
|
+
progress {
|
|
17
|
+
stage
|
|
18
|
+
paymentFailed
|
|
19
|
+
cancelled
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
const OrderProgressContent = defineContentType({
|
|
25
|
+
id: "order-progress",
|
|
26
|
+
title: "Order Progress",
|
|
27
|
+
description: "The stage names, the state sentences, and the accessible name of the progress list.",
|
|
28
|
+
schema: {
|
|
29
|
+
type: "object",
|
|
30
|
+
additionalProperties: false,
|
|
31
|
+
properties: {
|
|
32
|
+
label: {
|
|
33
|
+
type: "string",
|
|
34
|
+
title: "Accessible name"
|
|
35
|
+
},
|
|
36
|
+
placed: {
|
|
37
|
+
type: "string",
|
|
38
|
+
title: "Order placed"
|
|
39
|
+
},
|
|
40
|
+
payment: {
|
|
41
|
+
type: "string",
|
|
42
|
+
title: "Payment"
|
|
43
|
+
},
|
|
44
|
+
processing: {
|
|
45
|
+
type: "string",
|
|
46
|
+
title: "Processing"
|
|
47
|
+
},
|
|
48
|
+
shipping: {
|
|
49
|
+
type: "string",
|
|
50
|
+
title: "Shipping"
|
|
51
|
+
},
|
|
52
|
+
stateDone: {
|
|
53
|
+
type: "string",
|
|
54
|
+
title: "Completed"
|
|
55
|
+
},
|
|
56
|
+
stateCurrent: {
|
|
57
|
+
type: "string",
|
|
58
|
+
title: "In progress"
|
|
59
|
+
},
|
|
60
|
+
statePending: {
|
|
61
|
+
type: "string",
|
|
62
|
+
title: "Not started"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const STAGES = [
|
|
68
|
+
"placed",
|
|
69
|
+
"payment",
|
|
70
|
+
"processing",
|
|
71
|
+
"shipping"
|
|
72
|
+
];
|
|
73
|
+
const STAGE_LABELS = {
|
|
74
|
+
placed: "fs/order.stage.placed",
|
|
75
|
+
payment: "fs/order.stage.payment",
|
|
76
|
+
processing: "fs/order.stage.processing",
|
|
77
|
+
shipping: "fs/order.stage.shipping"
|
|
78
|
+
};
|
|
79
|
+
const STATE_LABELS = {
|
|
80
|
+
done: "fs/order.stage-state.done",
|
|
81
|
+
current: "fs/order.stage-state.current",
|
|
82
|
+
pending: "fs/order.stage-state.pending"
|
|
83
|
+
};
|
|
84
|
+
const OrderProgressDefinition = defineComponent({
|
|
85
|
+
name: "OrderProgress",
|
|
86
|
+
importPath: "@vtex/faststore/components",
|
|
87
|
+
component: OrderProgress,
|
|
88
|
+
content: OrderProgressContent,
|
|
89
|
+
fragment,
|
|
90
|
+
fetchStrategy: "static",
|
|
91
|
+
skeleton: OrderProgressSkeleton,
|
|
92
|
+
editor: {
|
|
93
|
+
label: "Order Progress",
|
|
94
|
+
category: "content"
|
|
95
|
+
},
|
|
96
|
+
schema: {},
|
|
97
|
+
guideline: "Four stages of one order on the order page: placed, payment, processing, shipping, with a line up to the current one. Stage names and state sentences are content; a blank field keeps the catalogue. Reads the stage the API resolved; style each stage through its state hook."
|
|
98
|
+
});
|
|
99
|
+
function authored(value, fallback) {
|
|
100
|
+
return value?.trim() || fallback;
|
|
101
|
+
}
|
|
102
|
+
function currentStage(value) {
|
|
103
|
+
switch (value) {
|
|
104
|
+
case "PAYMENT": return "payment";
|
|
105
|
+
case "PROCESSING": return "processing";
|
|
106
|
+
case "SHIPPING": return "shipping";
|
|
107
|
+
default: return "placed";
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function stageState(index, current, order) {
|
|
111
|
+
if (order.progress.cancelled) return STAGES[index] === "payment" ? "failed" : "not-applicable";
|
|
112
|
+
if (index < current) return "done";
|
|
113
|
+
if (index > current) return "pending";
|
|
114
|
+
if (order.progress.paymentFailed) return "failed";
|
|
115
|
+
return order.completion.view === "COMPLETED" ? "done" : "current";
|
|
116
|
+
}
|
|
117
|
+
function lineState(state, cancelled) {
|
|
118
|
+
if (cancelled) return "not-applicable";
|
|
119
|
+
return state === "pending" ? "pending" : "done";
|
|
120
|
+
}
|
|
121
|
+
function stageModels(order) {
|
|
122
|
+
const current = STAGES.indexOf(currentStage(order.progress.stage));
|
|
123
|
+
return STAGES.map((stage, index) => {
|
|
124
|
+
const state = stageState(index, current, order);
|
|
125
|
+
return {
|
|
126
|
+
stage,
|
|
127
|
+
state,
|
|
128
|
+
line: index === 0 ? null : lineState(state, order.progress.cancelled)
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function OrderProgressSkeleton({ className, ...props }) {
|
|
133
|
+
return /* @__PURE__ */ jsx("div", {
|
|
134
|
+
...props,
|
|
135
|
+
className,
|
|
136
|
+
"data-fs-order-progress-skeleton": "",
|
|
137
|
+
"aria-hidden": "true",
|
|
138
|
+
children: STAGES.map((stage) => /* @__PURE__ */ jsx("span", { "data-fs-order-progress-skeleton-stage": "" }, stage))
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function stageSentence(stage, content) {
|
|
142
|
+
switch (stage) {
|
|
143
|
+
case "placed": return content?.placed;
|
|
144
|
+
case "payment": return content?.payment;
|
|
145
|
+
case "processing": return content?.processing;
|
|
146
|
+
case "shipping": return content?.shipping;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function stateSentence(state, content) {
|
|
150
|
+
switch (state) {
|
|
151
|
+
case "done": return content?.stateDone;
|
|
152
|
+
case "current": return content?.stateCurrent;
|
|
153
|
+
case "pending": return content?.statePending;
|
|
154
|
+
default: return;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function OrderProgress({ $data, $content, className, ref }) {
|
|
158
|
+
const intl = useIntl();
|
|
159
|
+
const order = $data;
|
|
160
|
+
if (!order) return null;
|
|
161
|
+
const stages = stageModels(order);
|
|
162
|
+
return /* @__PURE__ */ jsx("ol", {
|
|
163
|
+
ref,
|
|
164
|
+
"aria-label": authored($content?.label, intl.formatMessage({ id: "fs/order.progress.label" })),
|
|
165
|
+
className,
|
|
166
|
+
"data-fs-order-progress": "",
|
|
167
|
+
"data-fs-order-progress-current": currentStage(order.progress.stage),
|
|
168
|
+
"data-fs-order-progress-cancelled": order.progress.cancelled ? "" : void 0,
|
|
169
|
+
children: stages.map(({ stage, state, line }) => {
|
|
170
|
+
const statusLabel = STATE_LABELS[state];
|
|
171
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
172
|
+
"data-fs-order-progress-stage": stage,
|
|
173
|
+
"data-fs-order-progress-stage-state": state,
|
|
174
|
+
"aria-current": state === "current" ? "step" : void 0,
|
|
175
|
+
children: [
|
|
176
|
+
/* @__PURE__ */ jsxs("span", {
|
|
177
|
+
"data-fs-order-progress-track": "",
|
|
178
|
+
children: [line ? /* @__PURE__ */ jsx("span", {
|
|
179
|
+
"data-fs-order-progress-line": "",
|
|
180
|
+
"data-fs-order-progress-line-state": line,
|
|
181
|
+
"aria-hidden": "true"
|
|
182
|
+
}) : null, /* @__PURE__ */ jsx("span", {
|
|
183
|
+
"data-fs-order-progress-marker": "",
|
|
184
|
+
"aria-hidden": "true"
|
|
185
|
+
})]
|
|
186
|
+
}),
|
|
187
|
+
/* @__PURE__ */ jsx("span", {
|
|
188
|
+
"data-fs-order-progress-label": "",
|
|
189
|
+
children: authored(stageSentence(stage, $content), intl.formatMessage({ id: STAGE_LABELS[stage] }))
|
|
190
|
+
}),
|
|
191
|
+
statusLabel ? /* @__PURE__ */ jsx("span", {
|
|
192
|
+
"data-fs-order-progress-status": "",
|
|
193
|
+
children: authored(stateSentence(state, $content), intl.formatMessage({ id: statusLabel }))
|
|
194
|
+
}) : null
|
|
195
|
+
]
|
|
196
|
+
}, stage);
|
|
197
|
+
})
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
//#endregion
|
|
201
|
+
export { OrderProgress, OrderProgressContent, OrderProgressDefinition, OrderProgressSkeleton };
|
|
202
|
+
|
|
203
|
+
//# sourceMappingURL=order-progress.js.map
|