@vtex/faststore 0.0.10 → 0.0.12
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 +55 -0
- package/README.md +0 -1
- package/dist/_virtual/_rolldown/runtime.js +4 -0
- package/dist/actions.json +6 -1
- package/dist/catalog.json +789 -1701
- package/dist/cli/index.d.ts +66 -28
- package/dist/cli/index.js +7371 -512
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/server-runtime.js +41 -60
- package/dist/cli/server-runtime.js.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js +2 -2
- package/dist/components.d.ts +63 -57
- package/dist/components.js +60 -54
- package/dist/content-types.json +5785 -754
- package/dist/core/dist/define-component.d.ts +1 -1
- package/dist/core/dist/define-content-type.d.ts +50 -2
- package/dist/core/dist/define-content-type.js +107 -3
- package/dist/core/dist/define-content-type.js.map +1 -1
- package/dist/core/dist/index.d.ts +2 -2
- package/dist/docs/access-code-field.md +1 -1
- package/dist/docs/access-code-sign-in.md +126 -77
- package/dist/docs/account-address-book.md +210 -95
- package/dist/docs/account-menu.md +14 -15
- package/dist/docs/account-saved-cards.md +44 -39
- package/dist/docs/alert-dialog.md +3 -1
- package/dist/docs/avatar.md +4 -2
- package/dist/docs/billing-address.md +99 -30
- package/dist/docs/binding-switcher.md +5 -2
- package/dist/docs/buy-button.md +7 -8
- package/dist/docs/card-entry.md +39 -26
- package/dist/docs/card-summary.md +18 -8
- package/dist/docs/cardholder-document.md +5 -3
- package/dist/docs/carousel.md +5 -4
- package/dist/docs/cart-destination.md +39 -26
- package/dist/docs/cart-item.md +29 -14
- package/dist/docs/cart-totalizer.md +7 -5
- package/dist/docs/cart.md +135 -41
- package/dist/docs/challenge-return.md +135 -0
- package/dist/docs/client-preferences-fieldset.md +10 -5
- package/dist/docs/client-preferences.md +31 -8
- package/dist/docs/client-profile-fieldset.md +20 -6
- package/dist/docs/client-profile.md +12 -3
- package/dist/docs/copy-text.md +9 -7
- package/dist/docs/document-field.md +1 -1
- package/dist/docs/email-field.md +2 -1
- package/dist/docs/email-identification.md +12 -2
- package/dist/docs/footer-copyright.md +4 -2
- package/dist/docs/form.md +54 -18
- package/dist/docs/free-shipping-progress.md +6 -5
- package/dist/docs/identity-edit.md +8 -2
- package/dist/docs/identity-summary.md +18 -5
- package/dist/docs/installments.md +46 -32
- package/dist/docs/my-account-profile.md +16 -11
- package/dist/docs/navigation-link.md +5 -3
- package/dist/docs/order-cancel.md +3 -1
- package/dist/docs/order-delivery-address.md +7 -5
- package/dist/docs/order-delivery-group.md +1 -3
- package/dist/docs/order-details-back.md +1 -1
- package/dist/docs/order-details-header.md +1 -4
- package/dist/docs/order-invoice-download.md +60 -0
- package/dist/docs/order-list-row.md +1 -1
- package/dist/docs/order-list-search.md +13 -20
- package/dist/docs/order-list-views.md +11 -17
- package/dist/docs/order-list.md +12 -5
- package/dist/docs/order-payment.md +9 -7
- package/dist/docs/order-placed-date.md +1 -1
- package/dist/docs/order-placed-payment-summary.md +28 -15
- package/dist/docs/order-placed.md +49 -14
- package/dist/docs/order-progress.md +1 -1
- package/dist/docs/order-status-badge.md +20 -9
- package/dist/docs/order-summary.md +2 -2
- package/dist/docs/order-tracking-link.md +58 -0
- package/dist/docs/payment-method-badges.md +30 -4
- package/dist/docs/payment-methods.md +1 -1
- package/dist/docs/payment.md +36 -17
- package/dist/docs/phone-field.md +4 -4
- package/dist/docs/place-order.md +84 -36
- package/dist/docs/postal-code-field.md +3 -1
- package/dist/docs/pricing.md +21 -23
- package/dist/docs/product-gallery.md +19 -20
- package/dist/docs/product-information.md +13 -9
- package/dist/docs/product-list.md +7 -6
- package/dist/docs/product-shelf.md +0 -1
- package/dist/docs/promotion.md +4 -2
- package/dist/docs/region.md +23 -15
- package/dist/docs/save-card.md +7 -6
- package/dist/docs/saved-cards.md +65 -36
- package/dist/docs/shipping-address.md +57 -21
- package/dist/docs/shipping-simulator.md +53 -15
- package/dist/docs/sign-in-disclosure.md +176 -0
- package/dist/docs/sign-in-form.md +78 -47
- package/dist/docs/sign-in-redirect.md +4 -2
- package/dist/docs/sign-in.md +173 -0
- package/dist/docs/toast.md +15 -4
- package/dist/docs/variant-selector.md +15 -11
- package/dist/domain-logic/dist/checkout/rules.js +33 -0
- package/dist/domain-logic/dist/checkout/rules.js.map +1 -0
- package/dist/graphql/types.d.ts +4 -14
- package/dist/index.d.ts +2 -2
- package/dist/internal/client.d.ts +1 -3
- package/dist/internal/client.js +1 -1
- package/dist/internal/server.d.ts +7 -4
- package/dist/internal/server.js +7 -4
- package/dist/matter/access-code-sign-in/access-code-sign-in.d.ts +250 -66
- package/dist/matter/access-code-sign-in/access-code-sign-in.js +459 -188
- package/dist/matter/access-code-sign-in/access-code-sign-in.js.map +1 -1
- package/dist/matter/account-address-book/account-address-book-delete.d.ts +78 -40
- package/dist/matter/account-address-book/account-address-book-delete.js +86 -50
- package/dist/matter/account-address-book/account-address-book-delete.js.map +1 -1
- package/dist/matter/account-address-book/account-address-book-deliverability.d.ts +21 -4
- package/dist/matter/account-address-book/account-address-book-deliverability.js +45 -17
- package/dist/matter/account-address-book/account-address-book-deliverability.js.map +1 -1
- package/dist/matter/account-address-book/account-address-book-form-parts.d.ts +74 -19
- package/dist/matter/account-address-book/account-address-book-form-parts.js +77 -26
- package/dist/matter/account-address-book/account-address-book-form-parts.js.map +1 -1
- package/dist/matter/account-address-book/account-address-book-profile-notice.d.ts +27 -6
- package/dist/matter/account-address-book/account-address-book-profile-notice.js +55 -28
- package/dist/matter/account-address-book/account-address-book-profile-notice.js.map +1 -1
- package/dist/matter/account-address-book/account-address-book.d.ts +67 -14
- package/dist/matter/account-address-book/account-address-book.js +74 -33
- package/dist/matter/account-address-book/account-address-book.js.map +1 -1
- package/dist/matter/account-address-book/account-address-country-switch.js +3 -3
- package/dist/matter/account-address-book/account-address-country-switch.js.map +1 -1
- package/dist/matter/account-address-book/account-address-country.d.ts +66 -20
- package/dist/matter/account-address-book/account-address-country.js +83 -49
- package/dist/matter/account-address-book/account-address-country.js.map +1 -1
- package/dist/matter/account-address-book/account-address-form-context.d.ts +8 -4
- package/dist/matter/account-address-book/account-address-form-context.js.map +1 -1
- package/dist/matter/account-address-book/account-address-form.d.ts +468 -45
- package/dist/matter/account-address-book/account-address-form.js +518 -155
- package/dist/matter/account-address-book/account-address-form.js.map +1 -1
- package/dist/matter/account-address-book/account-address-record.d.ts +27 -6
- package/dist/matter/account-address-book/account-address-record.js +32 -17
- package/dist/matter/account-address-book/account-address-record.js.map +1 -1
- package/dist/matter/account-menu/account-menu.d.ts +34 -17
- package/dist/matter/account-menu/account-menu.js +46 -54
- package/dist/matter/account-menu/account-menu.js.map +1 -1
- package/dist/matter/account-menu-identity/account-menu-identity.js +1 -1
- package/dist/matter/account-saved-cards/account-saved-cards.d.ts +108 -28
- package/dist/matter/account-saved-cards/account-saved-cards.js +177 -122
- package/dist/matter/account-saved-cards/account-saved-cards.js.map +1 -1
- package/dist/matter/billing-address/billing-address.d.ts +156 -74
- package/dist/matter/billing-address/billing-address.js +227 -156
- package/dist/matter/billing-address/billing-address.js.map +1 -1
- package/dist/matter/breadcrumb/breadcrumb.d.ts +21 -3
- package/dist/matter/breadcrumb/breadcrumb.js +24 -9
- package/dist/matter/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/matter/buy-button/buy-button.d.ts +8 -11
- package/dist/matter/buy-button/buy-button.js +10 -19
- package/dist/matter/buy-button/buy-button.js.map +1 -1
- package/dist/matter/card-entry/card-capture.js +12 -4
- package/dist/matter/card-entry/card-capture.js.map +1 -1
- package/dist/matter/card-entry/card-entry.d.ts +123 -32
- package/dist/matter/card-entry/card-entry.js +348 -221
- package/dist/matter/card-entry/card-entry.js.map +1 -1
- package/dist/matter/cart/cart-namespace.d.ts +7 -1
- package/dist/matter/cart/cart-namespace.js +7 -1
- package/dist/matter/cart/cart-namespace.js.map +1 -1
- package/dist/matter/cart/cart.d.ts +402 -61
- package/dist/matter/cart/cart.js +624 -153
- package/dist/matter/cart/cart.js.map +1 -1
- package/dist/matter/cart-destination/cart-destination.d.ts +30 -19
- package/dist/matter/cart-destination/cart-destination.js +160 -70
- package/dist/matter/cart-destination/cart-destination.js.map +1 -1
- package/dist/matter/cart-item/cart-item.d.ts +144 -17
- package/dist/matter/cart-item/cart-item.js +166 -49
- package/dist/matter/cart-item/cart-item.js.map +1 -1
- package/dist/matter/cart-item-compositions/cart-item-compositions.js +1 -1
- package/dist/matter/cart-item-compositions/cart-item-compositions.js.map +1 -1
- package/dist/matter/cart-item-customizations/cart-item-customizations.js +1 -1
- package/dist/matter/cart-item-customizations/cart-item-customizations.js.map +1 -1
- package/dist/matter/cart-item-discounts/cart-item-discounts.js +1 -1
- package/dist/matter/cart-item-discounts/cart-item-discounts.js.map +1 -1
- package/dist/matter/cart-item-seller-info/cart-item-seller-info.js +1 -1
- package/dist/matter/cart-item-seller-info/cart-item-seller-info.js.map +1 -1
- package/dist/matter/cart-item-variations/cart-item-variations.js +1 -1
- package/dist/matter/cart-item-variations/cart-item-variations.js.map +1 -1
- package/dist/matter/cart-totalizer/cart-totalizer.d.ts +43 -9
- package/dist/matter/cart-totalizer/cart-totalizer.js +46 -17
- package/dist/matter/cart-totalizer/cart-totalizer.js.map +1 -1
- package/dist/matter/challenge-return/challenge-return.d.ts +62 -0
- package/dist/matter/challenge-return/challenge-return.js +241 -0
- package/dist/matter/challenge-return/challenge-return.js.map +1 -0
- package/dist/matter/client-preferences/client-preferences-fieldset.d.ts +86 -17
- package/dist/matter/client-preferences/client-preferences-fieldset.js +126 -54
- package/dist/matter/client-preferences/client-preferences-fieldset.js.map +1 -1
- package/dist/matter/client-preferences/client-preferences.d.ts +50 -7
- package/dist/matter/client-preferences/client-preferences.js +84 -15
- package/dist/matter/client-preferences/client-preferences.js.map +1 -1
- package/dist/matter/client-profile/client-profile.d.ts +44 -9
- package/dist/matter/client-profile/client-profile.js +64 -24
- package/dist/matter/client-profile/client-profile.js.map +1 -1
- package/dist/matter/client-profile-form/client-profile-fieldset.d.ts +119 -22
- package/dist/matter/client-profile-form/client-profile-fieldset.js +161 -73
- package/dist/matter/client-profile-form/client-profile-fieldset.js.map +1 -1
- package/dist/matter/delivery-options/delivery-options-accordion.d.ts +49 -4
- package/dist/matter/delivery-options/delivery-options-accordion.js +67 -14
- package/dist/matter/delivery-options/delivery-options-accordion.js.map +1 -1
- package/dist/matter/delivery-options/delivery-options-controller.d.ts +69 -9
- package/dist/matter/delivery-options/delivery-options-controller.js +80 -14
- package/dist/matter/delivery-options/delivery-options-controller.js.map +1 -1
- package/dist/matter/delivery-options/delivery-options.d.ts +37 -2
- package/dist/matter/delivery-options/delivery-options.js +75 -12
- package/dist/matter/delivery-options/delivery-options.js.map +1 -1
- package/dist/matter/delivery-options/use-delivery-option-selection.d.ts +1 -0
- package/dist/matter/delivery-options/use-delivery-option-selection.js +1 -1
- package/dist/matter/delivery-options/use-delivery-option-selection.js.map +1 -1
- package/dist/matter/email-identification/email-identification.d.ts +25 -3
- package/dist/matter/email-identification/email-identification.js +49 -12
- package/dist/matter/email-identification/email-identification.js.map +1 -1
- package/dist/matter/free-shipping-progress/free-shipping-progress.d.ts +79 -7
- package/dist/matter/free-shipping-progress/free-shipping-progress.js +77 -20
- package/dist/matter/free-shipping-progress/free-shipping-progress.js.map +1 -1
- package/dist/matter/identity-edit/identity-edit.d.ts +52 -10
- package/dist/matter/identity-edit/identity-edit.js +47 -19
- package/dist/matter/identity-edit/identity-edit.js.map +1 -1
- package/dist/matter/identity-summary/identity-summary.d.ts +76 -22
- package/dist/matter/identity-summary/identity-summary.js +95 -45
- package/dist/matter/identity-summary/identity-summary.js.map +1 -1
- package/dist/matter/installments/installments-select.d.ts +98 -16
- package/dist/matter/installments/installments-select.js +156 -48
- package/dist/matter/installments/installments-select.js.map +1 -1
- package/dist/matter/installments/installments.d.ts +96 -16
- package/dist/matter/installments/installments.js +115 -40
- package/dist/matter/installments/installments.js.map +1 -1
- package/dist/matter/installments/use-installments-selection.d.ts +1 -0
- package/dist/matter/installments/use-installments-selection.js +8 -3
- package/dist/matter/installments/use-installments-selection.js.map +1 -1
- package/dist/matter/my-account-profile/my-account-profile.d.ts +358 -103
- package/dist/matter/my-account-profile/my-account-profile.js +370 -174
- package/dist/matter/my-account-profile/my-account-profile.js.map +1 -1
- package/dist/matter/order-cancel/order-cancel.d.ts +65 -19
- package/dist/matter/order-cancel/order-cancel.js +118 -51
- package/dist/matter/order-cancel/order-cancel.js.map +1 -1
- package/dist/matter/order-delivery-address/order-delivery-address.d.ts +8 -18
- package/dist/matter/order-delivery-address/order-delivery-address.js +14 -23
- package/dist/matter/order-delivery-address/order-delivery-address.js.map +1 -1
- package/dist/matter/order-delivery-group/order-delivery-group.d.ts +40 -24
- package/dist/matter/order-delivery-group/order-delivery-group.js +64 -74
- package/dist/matter/order-delivery-group/order-delivery-group.js.map +1 -1
- package/dist/matter/order-details-header/order-details-header.d.ts +32 -15
- package/dist/matter/order-details-header/order-details-header.js +66 -58
- package/dist/matter/order-details-header/order-details-header.js.map +1 -1
- package/dist/matter/order-invoice-download/order-invoice-download.d.ts +78 -0
- package/dist/matter/order-invoice-download/order-invoice-download.js +173 -0
- package/dist/matter/order-invoice-download/order-invoice-download.js.map +1 -0
- package/dist/matter/order-list/order-list.d.ts +164 -19
- package/dist/matter/order-list/order-list.js +229 -87
- package/dist/matter/order-list/order-list.js.map +1 -1
- package/dist/matter/order-list-row/order-list-row.d.ts +6 -1
- package/dist/matter/order-list-row/order-list-row.js +3 -2
- package/dist/matter/order-list-row/order-list-row.js.map +1 -1
- package/dist/matter/order-list-search/order-list-search.d.ts +18 -26
- package/dist/matter/order-list-search/order-list-search.js +30 -69
- package/dist/matter/order-list-search/order-list-search.js.map +1 -1
- package/dist/matter/order-list-views/order-list-views.d.ts +15 -22
- package/dist/matter/order-list-views/order-list-views.js +22 -68
- package/dist/matter/order-list-views/order-list-views.js.map +1 -1
- package/dist/matter/order-payment/order-payment.d.ts +33 -10
- package/dist/matter/order-payment/order-payment.js +44 -39
- package/dist/matter/order-payment/order-payment.js.map +1 -1
- package/dist/matter/order-placed/order-placed-deliveries.d.ts +144 -12
- package/dist/matter/order-placed/order-placed-deliveries.js +115 -40
- package/dist/matter/order-placed/order-placed-deliveries.js.map +1 -1
- package/dist/matter/order-placed/order-placed.d.ts +198 -31
- package/dist/matter/order-placed/order-placed.js +230 -139
- package/dist/matter/order-placed/order-placed.js.map +1 -1
- package/dist/matter/order-placed-date/order-placed-date.d.ts +5 -8
- package/dist/matter/order-placed-date/order-placed-date.js +7 -8
- package/dist/matter/order-placed-date/order-placed-date.js.map +1 -1
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.d.ts +90 -17
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js +93 -117
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js.map +1 -1
- package/dist/matter/order-progress/order-progress.d.ts +19 -8
- package/dist/matter/order-progress/order-progress.js +37 -45
- package/dist/matter/order-progress/order-progress.js.map +1 -1
- package/dist/matter/order-summary/order-summary.d.ts +19 -9
- package/dist/matter/order-summary/order-summary.js +38 -44
- package/dist/matter/order-summary/order-summary.js.map +1 -1
- package/dist/matter/order-tracking-link/order-tracking-link.d.ts +43 -0
- package/dist/matter/order-tracking-link/order-tracking-link.js +107 -0
- package/dist/matter/order-tracking-link/order-tracking-link.js.map +1 -0
- package/dist/matter/payment/payment-card-capture.js +17 -10
- package/dist/matter/payment/payment-card-capture.js.map +1 -1
- package/dist/matter/payment/payment-controller.d.ts +4 -2
- package/dist/matter/payment/payment-controller.js +30 -9
- package/dist/matter/payment/payment-controller.js.map +1 -1
- package/dist/matter/payment/payment-method-badges.js +1 -1
- package/dist/matter/payment/payment.d.ts +69 -19
- package/dist/matter/payment/payment.js +101 -35
- package/dist/matter/payment/payment.js.map +1 -1
- package/dist/matter/payment/use-payment-method-selection.d.ts +25 -4
- package/dist/matter/payment/use-payment-method-selection.js +94 -32
- package/dist/matter/payment/use-payment-method-selection.js.map +1 -1
- package/dist/matter/payment/use-payment-submit-gate.d.ts +14 -3
- package/dist/matter/payment/use-payment-submit-gate.js +47 -8
- package/dist/matter/payment/use-payment-submit-gate.js.map +1 -1
- package/dist/matter/place-order/place-order.d.ts +171 -57
- package/dist/matter/place-order/place-order.js +376 -185
- package/dist/matter/place-order/place-order.js.map +1 -1
- package/dist/matter/pricing/pricing.d.ts +152 -13
- package/dist/matter/pricing/pricing.js +153 -52
- package/dist/matter/pricing/pricing.js.map +1 -1
- package/dist/matter/product-information/product-information.d.ts +27 -4
- package/dist/matter/product-information/product-information.js +32 -15
- package/dist/matter/product-information/product-information.js.map +1 -1
- package/dist/matter/product-list/product-list.d.ts +24 -6
- package/dist/matter/product-list/product-list.js +32 -26
- package/dist/matter/product-list/product-list.js.map +1 -1
- package/dist/matter/product-shelf/product-shelf.d.ts +1 -3
- package/dist/matter/product-shelf/product-shelf.js +2 -15
- package/dist/matter/product-shelf/product-shelf.js.map +1 -1
- package/dist/matter/region/region.d.ts +33 -16
- package/dist/matter/region/region.js +59 -52
- package/dist/matter/region/region.js.map +1 -1
- package/dist/matter/save-card/save-card.d.ts +43 -8
- package/dist/matter/save-card/save-card.js +61 -23
- package/dist/matter/save-card/save-card.js.map +1 -1
- package/dist/matter/saved-cards/saved-cards.d.ts +113 -21
- package/dist/matter/saved-cards/saved-cards.js +349 -77
- package/dist/matter/saved-cards/saved-cards.js.map +1 -1
- package/dist/matter/shipping-address/address-payload.js +25 -0
- package/dist/matter/shipping-address/address-payload.js.map +1 -0
- package/dist/matter/shipping-address/country-descriptors.js +71 -71
- package/dist/matter/shipping-address/country-descriptors.js.map +1 -1
- package/dist/matter/shipping-address/library-country-descriptors.js +136 -0
- package/dist/matter/shipping-address/library-country-descriptors.js.map +1 -0
- package/dist/matter/shipping-address/shipping-address.d.ts +312 -45
- package/dist/matter/shipping-address/shipping-address.js +443 -188
- package/dist/matter/shipping-address/shipping-address.js.map +1 -1
- package/dist/matter/shipping-simulator/shipping-simulator.d.ts +250 -24
- package/dist/matter/shipping-simulator/shipping-simulator.js +257 -51
- package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -1
- package/dist/matter/sign-in/sign-in.d.ts +108 -0
- package/dist/matter/sign-in/sign-in.js +285 -0
- package/dist/matter/sign-in/sign-in.js.map +1 -0
- package/dist/matter/sign-in-disclosure/sign-in-disclosure.d.ts +81 -0
- package/dist/matter/sign-in-disclosure/sign-in-disclosure.js +232 -0
- package/dist/matter/sign-in-disclosure/sign-in-disclosure.js.map +1 -0
- package/dist/matter/sign-in-form/sign-in-form.d.ts +93 -62
- package/dist/matter/sign-in-form/sign-in-form.js +134 -144
- package/dist/matter/sign-in-form/sign-in-form.js.map +1 -1
- package/dist/particles/binding-switcher/binding-switcher.d.ts +29 -8
- package/dist/particles/binding-switcher/binding-switcher.js +37 -26
- package/dist/particles/binding-switcher/binding-switcher.js.map +1 -1
- package/dist/particles/card-summary/card-summary.d.ts +38 -8
- package/dist/particles/card-summary/card-summary.js +55 -22
- package/dist/particles/card-summary/card-summary.js.map +1 -1
- package/dist/particles/carousel/carousel.d.ts +99 -11
- package/dist/particles/carousel/carousel.js +103 -35
- package/dist/particles/carousel/carousel.js.map +1 -1
- package/dist/particles/copy-text/copy-text.js +5 -15
- package/dist/particles/copy-text/copy-text.js.map +1 -1
- package/dist/particles/dialog/dialog.d.ts +14 -6
- package/dist/particles/dialog/dialog.js +6 -3
- package/dist/particles/dialog/dialog.js.map +1 -1
- package/dist/particles/drawer/drawer.js +1 -1
- package/dist/particles/drawer/drawer.js.map +1 -1
- package/dist/particles/email-field/email-field.d.ts +2 -1
- package/dist/particles/email-field/email-field.js +2 -1
- package/dist/particles/email-field/email-field.js.map +1 -1
- package/dist/particles/footer-link-group/footer-link-group.js +1 -0
- package/dist/particles/footer-link-group/footer-link-group.js.map +1 -1
- package/dist/particles/form/form.d.ts +85 -13
- package/dist/particles/form/form.js +91 -42
- package/dist/particles/form/form.js.map +1 -1
- package/dist/particles/gallery/gallery.d.ts +129 -12
- package/dist/particles/gallery/gallery.js +121 -34
- package/dist/particles/gallery/gallery.js.map +1 -1
- package/dist/particles/order-details-back/order-details-back.d.ts +5 -3
- package/dist/particles/order-details-back/order-details-back.js +8 -10
- package/dist/particles/order-details-back/order-details-back.js.map +1 -1
- package/dist/particles/order-status-badge/order-status-badge.d.ts +3 -3
- package/dist/particles/order-status-badge/order-status-badge.js +4 -20
- package/dist/particles/order-status-badge/order-status-badge.js.map +1 -1
- package/dist/particles/password-field/password-field.d.ts +1 -1
- package/dist/particles/password-field/password-field.js +2 -4
- package/dist/particles/password-field/password-field.js.map +1 -1
- package/dist/particles/phone-field/phone-field.d.ts +4 -4
- package/dist/particles/phone-field/phone-field.js +8 -11
- package/dist/particles/phone-field/phone-field.js.map +1 -1
- package/dist/particles/spinner/spinner.d.ts +24 -4
- package/dist/particles/spinner/spinner.js +25 -9
- package/dist/particles/spinner/spinner.js.map +1 -1
- package/dist/particles/switch/switch.d.ts +4 -1
- package/dist/particles/switch/switch.js +3 -1
- package/dist/particles/switch/switch.js.map +1 -1
- package/dist/particles/toast/toast.d.ts +29 -3
- package/dist/particles/toast/toast.js +34 -10
- package/dist/particles/toast/toast.js.map +1 -1
- package/dist/schema.graphql +164 -56
- package/dist/sdk/address/address-fields.js +4 -4
- package/dist/sdk/address/address-fields.js.map +1 -1
- package/dist/sdk/address/constants.js +1 -6
- package/dist/sdk/address/constants.js.map +1 -1
- package/dist/sdk/address/messages.js +44 -44
- package/dist/sdk/address/messages.js.map +1 -1
- package/dist/sdk/address/postal-code.js +15 -2
- package/dist/sdk/address/postal-code.js.map +1 -1
- package/dist/sdk/address/types.d.ts +5 -3
- package/dist/sdk/address/validate-address.js +3 -3
- package/dist/sdk/address/validate-address.js.map +1 -1
- package/dist/sdk/analytics/use-analytics-actions.d.ts +1 -1
- package/dist/sdk/analytics/use-analytics-actions.js.map +1 -1
- package/dist/sdk/cart/use-cart-actions.js.map +1 -1
- package/dist/sdk/data/index.js +2 -2
- package/dist/sdk/data/reactive-list-item-data-provider.js +2 -2
- package/dist/sdk/generated/gql.js +1 -1
- package/dist/sdk/generated/gql.js.map +1 -1
- package/dist/sdk/generated/graphql.d.ts +20 -5
- package/dist/sdk/generated/graphql.js +6 -0
- package/dist/sdk/generated/graphql.js.map +1 -1
- package/dist/sdk/i18n/format-error-code.js +23 -0
- package/dist/sdk/i18n/format-error-code.js.map +1 -0
- package/dist/sdk/i18n/message-formatter.d.ts +22 -0
- package/dist/sdk/i18n/message-formatter.js +140 -0
- package/dist/sdk/i18n/message-formatter.js.map +1 -0
- package/dist/sdk/i18n/use-message-formatter.d.ts +8 -0
- package/dist/sdk/i18n/use-message-formatter.js +18 -0
- package/dist/sdk/i18n/use-message-formatter.js.map +1 -0
- package/dist/sdk/identity/use-identity-actions.js.map +1 -1
- package/dist/sdk/navigation/redirect.d.ts +2 -0
- package/dist/sdk/navigation/redirect.js +19 -1
- package/dist/sdk/navigation/redirect.js.map +1 -1
- package/dist/sdk/navigation/types.d.ts +13 -0
- package/dist/sdk/payment/bin-format.js +21 -0
- package/dist/sdk/payment/bin-format.js.map +1 -0
- package/dist/sdk/payment/challenge-return.js +37 -0
- package/dist/sdk/payment/challenge-return.js.map +1 -0
- package/dist/sdk/payment/confirmation-last-four.js +39 -0
- package/dist/sdk/payment/confirmation-last-four.js.map +1 -0
- package/dist/sdk/payment/gateway.d.ts +1 -1
- package/dist/sdk/payment/gateway.js +8 -2
- package/dist/sdk/payment/gateway.js.map +1 -1
- package/dist/sdk/payment/operations.d.ts +1 -0
- package/dist/sdk/payment/operations.js +28 -6
- package/dist/sdk/payment/operations.js.map +1 -1
- package/dist/sdk/payment/resumed-purchase.d.ts +1 -0
- package/dist/sdk/payment/resumed-purchase.js +119 -0
- package/dist/sdk/payment/resumed-purchase.js.map +1 -0
- package/dist/sdk/payment/security-code-mask.js +16 -23
- package/dist/sdk/payment/security-code-mask.js.map +1 -1
- package/dist/sdk/payment/submission-registry.js +6 -2
- package/dist/sdk/payment/submission-registry.js.map +1 -1
- package/dist/sdk/payment/use-payment-actions.d.ts +18 -3
- package/dist/sdk/payment/use-payment-actions.js +23 -4
- package/dist/sdk/payment/use-payment-actions.js.map +1 -1
- package/dist/sdk/payment/use-place-order.d.ts +10 -2
- package/dist/sdk/payment/use-place-order.js +138 -76
- package/dist/sdk/payment/use-place-order.js.map +1 -1
- package/dist/sdk/provider/storefront-provider.d.ts +1 -7
- package/dist/sdk/provider/storefront-provider.js +4 -11
- package/dist/sdk/provider/storefront-provider.js.map +1 -1
- package/dist/sdk/seo/entity-landing.d.ts +24 -0
- package/dist/sdk/seo/entity-landing.js +30 -0
- package/dist/sdk/seo/entity-landing.js.map +1 -0
- package/dist/sdk/seo/page-alternates.d.ts +3 -2
- package/dist/sdk/seo/page-alternates.js +4 -2
- package/dist/sdk/seo/page-alternates.js.map +1 -1
- package/dist/sdk/seo/search-landing.d.ts +42 -0
- package/dist/sdk/seo/search-landing.js +85 -0
- package/dist/sdk/seo/search-landing.js.map +1 -0
- package/dist/sdk/session/mock-session.d.ts +9 -0
- package/dist/sdk/session/mock-session.js +31 -0
- package/dist/sdk/session/mock-session.js.map +1 -0
- package/dist/sdk/session/read-server-session.d.ts +3 -0
- package/dist/sdk/session/read-server-session.js +5 -0
- package/dist/sdk/session/read-server-session.js.map +1 -1
- package/dist/sdk/session/return-path-segment.d.ts +10 -0
- package/dist/sdk/session/return-path-segment.js +15 -0
- package/dist/sdk/session/return-path-segment.js.map +1 -0
- package/dist/sdk/session/use-session-actions.js.map +1 -1
- package/dist/sdk/shipping/use-cart-shipping-simulation.js.map +1 -1
- package/dist/sdk/shipping/use-shipping-actions.js.map +1 -1
- package/dist/sdk/shipping/use-shipping-simulation.js.map +1 -1
- package/dist/utils/safe-href.d.ts +2 -0
- package/package.json +4 -3
- package/skills/storefront-asset/SKILL.md +2 -2
- package/skills/storefront-asset/references/api-side.md +27 -14
- package/skills/storefront-asset/references/findings.md +5 -2
- package/src/styles/tailwind.css +8 -0
- package/dist/matter/shipping-address/country-descriptors.d.ts +0 -1
- package/dist/message-locales.json +0 -7
- package/dist/sdk/i18n/client.d.ts +0 -4
- package/dist/sdk/i18n/client.js +0 -4
- package/dist/sdk/i18n/locales.d.ts +0 -8
- package/dist/sdk/i18n/locales.js +0 -57
- package/dist/sdk/i18n/locales.js.map +0 -1
- package/dist/sdk/i18n/messages/en-US.js +0 -183
- package/dist/sdk/i18n/messages/en-US.js.map +0 -1
- package/dist/sdk/i18n/messages/en-US.json +0 -178
- package/dist/sdk/i18n/messages/en-US.json.d.ts +0 -182
- package/dist/sdk/i18n/messages/es-ES.js +0 -183
- package/dist/sdk/i18n/messages/es-ES.js.map +0 -1
- package/dist/sdk/i18n/messages/es-ES.json +0 -178
- package/dist/sdk/i18n/messages/pt-BR.js +0 -183
- package/dist/sdk/i18n/messages/pt-BR.js.map +0 -1
- package/dist/sdk/i18n/messages/pt-BR.json +0 -178
- package/dist/sdk/i18n/provider.d.ts +0 -1
- package/dist/sdk/i18n/provider.js +0 -30
- package/dist/sdk/i18n/provider.js.map +0 -1
- package/dist/sdk/i18n/server.d.ts +0 -28
- package/dist/sdk/i18n/server.js +0 -59
- package/dist/sdk/i18n/server.js.map +0 -1
- package/dist/utils/resolve-authored-copy.js +0 -18
- package/dist/utils/resolve-authored-copy.js.map +0 -1
- package/dist/utils/substitute-template.js +0 -33
- package/dist/utils/substitute-template.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment-card-capture.js","names":[],"sources":["../../../src/matter/payment/payment-card-capture.tsx"],"sourcesContent":["'use client';\n\nimport { type ReactNode, useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport type { PaymentGatewayTransaction } from '../../sdk/payment/gateway.js';\nimport { PAYMENT_NETWORK_ERROR_CODE, type PaymentUserError } from '../../sdk/payment/operations.js';\nimport { type PaymentSubmission, usePaymentSubmission } from '../../sdk/payment/submission-registry.js';\nimport {\n type CapturedCard,\n type CardCapture,\n CardCaptureContext,\n type CardCaptureContextValue,\n type CardCaptureMissingMethodExplainer,\n type CardCapturePreflight,\n type CardCaptureResult,\n} from '../card-entry/card-capture.js';\nimport { resolveCardholderDocument } from './cardholder-document-rule.js';\nimport { isCardMethod, type PaymentMethodSelection } from './use-payment-method-selection.js';\n\n/**\n * The checkout's `card-capture` provider (specs/sfs-3457-card-entry-card-capture-context.md),\n * rendered by both payment roots inside their `PaymentSubmissionProvider`. It hands `CardEntry` the\n * scoped methods and the selection facts, registers its capture as the `new-card` submission, folds\n * the draft's non-sensitive values into the card, and sends it through `sendPayments`. It also owns\n * `add_payment_info`, which needs the cart total `CardEntry` no longer reads.\n */\n\nexport type PaymentCartData = {\n total?: { amount: number; currencyCode: string } | null;\n} | null;\n\n/** The `add_payment_info` payment type for a card group; `undefined` for any other group (T140). */\nfunction paymentTypeOf(groupName: string | undefined): 'Credit Card' | 'Debit Card' | undefined {\n if (groupName === 'creditCardPaymentGroup') return 'Credit Card';\n if (groupName === 'debitCardPaymentGroup') return 'Debit Card';\n return undefined;\n}\n\n/** Mirrors `usePaymentActions`' own infrastructure-failure code for the same underlying meaning. */\nconst MISSING_GATEWAY_ACTION_ERROR: PaymentUserError = {\n code: PAYMENT_NETWORK_ERROR_CODE,\n message: 'Unable to complete the request. Please try again.',\n};\n\ntype LatestCaptureFacts = Readonly<{ selection: PaymentMethodSelection; $actions: ComponentActions | undefined }>;\n\n/**\n * Folds the draft's non-sensitive values into the captured card and sends it through `sendPayments`.\n * `facts` is `latest.current` read at submission time, never a value a closure captured earlier.\n */\nasync function sendNewCard(\n { selection, $actions }: LatestCaptureFacts,\n transaction: PaymentGatewayTransaction,\n card: CapturedCard,\n): Promise<CardCaptureResult> {\n const sendPayments = $actions?.payment?.sendPayments;\n if (!sendPayments) {\n console.error('[CardEntry] the payment action namespace is not injected');\n // Nothing was sent: no action to send it with (T112).\n return { reachedGateway: false, userErrors: [MISSING_GATEWAY_ACTION_ERROR] };\n }\n const { draft, allMethods, persistedMethodId, countryDocumentType } = selection;\n // T42 (Decision 4): the draft document is posted only while the rule applies — the same unscoped\n // persisted method the submit gate reads, under the store's country — never a stale value.\n const documentRule = resolveCardholderDocument({\n method: allMethods.find((method) => method.id === persistedMethodId) ?? null,\n countryDocumentType,\n });\n return sendPayments({\n transaction,\n card: {\n kind: 'new',\n ...card,\n document: documentRule ? (draft.document ?? undefined) : undefined,\n cardLabel: draft.cardLabel ?? undefined,\n saveCard: draft.saveCard ?? undefined,\n },\n });\n}\n\ntype PaymentCardCaptureProviderProps = Readonly<{\n selection: PaymentMethodSelection;\n cart: PaymentCartData | undefined;\n $actions: ComponentActions | undefined;\n children: ReactNode;\n}>;\n\nexport function PaymentCardCaptureProvider({ selection, cart, $actions, children }: PaymentCardCaptureProviderProps) {\n const { register } = usePaymentSubmission();\n // Read at submission and analytics time, never captured by a closure: the place-order sequence must\n // fold the draft as it stands then, and a keystroke must not re-render the section.\n const latest = useRef({ selection, $actions });\n useLayoutEffect(() => {\n latest.current = { selection, $actions };\n });\n\n const total = cart?.total ?? null;\n const totalRef = useRef(total);\n const activeCaptures = useRef(0);\n const analyticsDispatched = useRef(false);\n\n // `add_payment_info` (T2), once per root, when a card capture is mounted and the cart total has\n // resolved. T140, Decision 5: `paymentType` comes from whatever is selected when it fires, and the key\n // is absent otherwise; a later selection never re-fires it.\n const dispatchAddPaymentInfo = useCallback(() => {\n const currentTotal = totalRef.current;\n if (analyticsDispatched.current || activeCaptures.current === 0 || !currentTotal) return;\n const track = latest.current.$actions?.analytics?.track;\n if (!track) return;\n const { methods, selectedMethodId } = latest.current.selection;\n const paymentType = paymentTypeOf(methods.find((method) => method.id === selectedMethodId)?.groupName);\n track({\n name: 'add_payment_info',\n value: { amount: currentTotal.amount, currencyCode: currentTotal.currencyCode },\n // The key itself must be absent when nothing resolves to a known card kind — never a present\n // key holding `undefined` (toEcommercePayload's own doc comment carries the rest of this rule).\n ...(paymentType ? { paymentType } : {}),\n });\n analyticsDispatched.current = true;\n }, []);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: `$actions` re-runs the dispatch when the analytics namespace arrives after the total; the dispatch reads it through `latest`.\n useEffect(() => {\n totalRef.current = total;\n dispatchAddPaymentInfo();\n }, [total, $actions, dispatchAddPaymentInfo]);\n\n const registerCapture = useCallback(\n (\n capture: CardCapture,\n preflight: CardCapturePreflight,\n explainMissingMethod?: CardCaptureMissingMethodExplainer,\n ) => {\n const submit: PaymentSubmission = (transaction) =>\n capture((card) => sendNewCard(latest.current, transaction, card));\n const unregister = register('new-card', submit, preflight, explainMissingMethod);\n activeCaptures.current += 1;\n dispatchAddPaymentInfo();\n return () => {\n activeCaptures.current -= 1;\n unregister();\n };\n },\n [register, dispatchAddPaymentInfo],\n );\n\n const {\n methods,\n placing,\n attempt,\n selectMethod,\n selectNewCard,\n setDraftBin,\n draft,\n cardPaymentCollapsed,\n cardModeActive,\n selectedMethodId,\n selectionOutOfScope,\n selectedMethod,\n } = selection;\n // T202: `sent` and `unresolved` are the two phases in which `placeOrder` only resumes (the callback leg), so\n // a card typed there would never be submitted and never cleared. The form takes no input until the attempt\n // is freed. Read from the attempt on every render; nothing here writes it.\n const locked = attempt?.phase === 'sent' || attempt?.phase === 'unresolved';\n // T191 (FR-13, Decision 8): classified with the engine's own `isCardMethod`, so the card form's\n // refusal and the collapse can never disagree about a method.\n const selectionNonCard = selectedMethod !== null && !isCardMethod(selectedMethod);\n\n const value = useMemo<CardCaptureContextValue>(\n () => ({\n networks: methods,\n busy: placing || locked,\n // T202: the card POST has settled by any route once `send` returns, so nothing the form holds is needed\n // again (a refusal raised before `send` never reaches the clear).\n clearOn: 'any-outcome',\n registerCapture,\n selection: {\n selectMethod,\n selectNewCard,\n setDraftBin,\n path: draft.path,\n bin: draft.bin,\n collapsed: cardPaymentCollapsed,\n cardModeActive,\n selectedMethodId,\n selectionOutOfScope,\n selectionNonCard,\n },\n }),\n [\n methods,\n placing,\n locked,\n registerCapture,\n selectMethod,\n selectNewCard,\n setDraftBin,\n draft.path,\n draft.bin,\n cardPaymentCollapsed,\n cardModeActive,\n selectedMethodId,\n selectionOutOfScope,\n selectionNonCard,\n ],\n );\n\n return <CardCaptureContext value={value}>{children}</CardCaptureContext>;\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"payment-card-capture.js","names":[],"sources":["../../../src/matter/payment/payment-card-capture.tsx"],"sourcesContent":["'use client';\n\nimport { type ReactNode, useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport type { PaymentType } from '../../sdk/generated/graphql.js';\nimport { lastFourOf, rememberConfirmationLastFour } from '../../sdk/payment/confirmation-last-four.js';\nimport type { PaymentGatewayTransaction } from '../../sdk/payment/gateway.js';\nimport { PAYMENT_NETWORK_ERROR_CODE, type PaymentUserError } from '../../sdk/payment/operations.js';\nimport { type PaymentSubmission, usePaymentSubmission } from '../../sdk/payment/submission-registry.js';\nimport {\n type CapturedCard,\n type CardCapture,\n CardCaptureContext,\n type CardCaptureContextValue,\n type CardCaptureMissingMethodExplainer,\n type CardCapturePreflight,\n type CardCaptureResult,\n} from '../card-entry/card-capture.js';\nimport { resolveCardholderDocument } from './cardholder-document-rule.js';\nimport { isCardMethod, type PaymentMethodSelection } from './use-payment-method-selection.js';\n\n/**\n * The checkout's `card-capture` provider (specs/sfs-3457-card-entry-card-capture-context.md),\n * rendered by both payment roots inside their `PaymentSubmissionProvider`. It hands `CardEntry` the\n * scoped methods and the selection facts, registers its capture as the `new-card` submission, folds\n * the draft's non-sensitive values into the card, and sends it through `sendPayments`. It also owns\n * `add_payment_info`, which needs the cart total `CardEntry` no longer reads.\n */\n\nexport type PaymentCartData = {\n total?: { amount: number; currencyCode: string } | null;\n} | null;\n\n/** The `add_payment_info` payment type for a card kind; `undefined` for any other kind (T140; read off `type` since T230). */\nfunction paymentTypeOf(type: PaymentType | undefined): 'Credit Card' | 'Debit Card' | undefined {\n if (type === 'CREDIT_CARD') return 'Credit Card';\n if (type === 'DEBIT_CARD') return 'Debit Card';\n return undefined;\n}\n\n/** Mirrors `usePaymentActions`' own infrastructure-failure code. Its `message` is diagnostic; `PlaceOrder` words the code. */\nconst MISSING_GATEWAY_ACTION_ERROR: PaymentUserError = {\n code: PAYMENT_NETWORK_ERROR_CODE,\n message: 'Unable to complete the request. Please try again.',\n};\n\ntype LatestCaptureFacts = Readonly<{ selection: PaymentMethodSelection; $actions: ComponentActions | undefined }>;\n\n/**\n * Folds the draft's non-sensitive values into the captured card and sends it through `sendPayments`.\n * `facts` is `latest.current` read at submission time, never a value a closure captured earlier.\n */\nasync function sendNewCard(\n { selection, $actions }: LatestCaptureFacts,\n transaction: PaymentGatewayTransaction,\n card: CapturedCard,\n): Promise<CardCaptureResult> {\n const sendPayments = $actions?.payment?.sendPayments;\n if (!sendPayments) {\n console.error('[CardEntry] the payment action namespace is not injected');\n // Nothing was sent: no action to send it with (T112).\n return { reachedGateway: false, userErrors: [MISSING_GATEWAY_ACTION_ERROR] };\n }\n const { draft, allMethods, persistedMethodId, countryDocumentType } = selection;\n // T42 (Decision 4): the draft document is posted only while the rule applies — the same unscoped\n // persisted method the submit gate reads, under the store's country — never a stale value.\n const documentRule = resolveCardholderDocument({\n method: allMethods.find((method) => method.id === persistedMethodId) ?? null,\n countryDocumentType,\n });\n const lastFour = lastFourOf(card.number);\n const result = await sendPayments({\n transaction,\n card: {\n kind: 'new',\n ...card,\n document: documentRule ? (draft.document ?? undefined) : undefined,\n cardLabel: draft.cardLabel ?? undefined,\n saveCard: draft.saveCard ?? undefined,\n },\n });\n if (lastFour && result.userErrors.length === 0) rememberConfirmationLastFour(transaction.orderGroup, lastFour);\n return result;\n}\n\ntype PaymentCardCaptureProviderProps = Readonly<{\n selection: PaymentMethodSelection;\n cart: PaymentCartData | undefined;\n $actions: ComponentActions | undefined;\n children: ReactNode;\n}>;\n\nexport function PaymentCardCaptureProvider({ selection, cart, $actions, children }: PaymentCardCaptureProviderProps) {\n const { register } = usePaymentSubmission();\n // Read at submission and analytics time, never captured by a closure: the place-order sequence must\n // fold the draft as it stands then, and a keystroke must not re-render the section.\n const latest = useRef({ selection, $actions });\n useLayoutEffect(() => {\n latest.current = { selection, $actions };\n });\n\n const total = cart?.total ?? null;\n const totalRef = useRef(total);\n const activeCaptures = useRef(0);\n const analyticsDispatched = useRef(false);\n\n // `add_payment_info` (T2), once per root, when a card capture is mounted and the cart total has\n // resolved. T140, Decision 5: `paymentType` comes from whatever is selected when it fires, and the key\n // is absent otherwise; a later selection never re-fires it.\n const dispatchAddPaymentInfo = useCallback(() => {\n const currentTotal = totalRef.current;\n if (analyticsDispatched.current || activeCaptures.current === 0 || !currentTotal) return;\n const track = latest.current.$actions?.analytics?.track;\n if (!track) return;\n const { methods, selectedMethodId } = latest.current.selection;\n const paymentType = paymentTypeOf(methods.find((method) => method.id === selectedMethodId)?.type);\n track({\n name: 'add_payment_info',\n value: { amount: currentTotal.amount, currencyCode: currentTotal.currencyCode },\n // The key itself must be absent when nothing resolves to a known card kind — never a present\n // key holding `undefined` (toEcommercePayload's own doc comment carries the rest of this rule).\n ...(paymentType ? { paymentType } : {}),\n });\n analyticsDispatched.current = true;\n }, []);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: `$actions` re-runs the dispatch when the analytics namespace arrives after the total; the dispatch reads it through `latest`.\n useEffect(() => {\n totalRef.current = total;\n dispatchAddPaymentInfo();\n }, [total, $actions, dispatchAddPaymentInfo]);\n\n const registerCapture = useCallback(\n (\n capture: CardCapture,\n preflight: CardCapturePreflight,\n explainMissingMethod?: CardCaptureMissingMethodExplainer,\n ) => {\n const submit: PaymentSubmission = (transaction) =>\n capture((card) => sendNewCard(latest.current, transaction, card));\n const unregister = register('new-card', submit, preflight, explainMissingMethod);\n activeCaptures.current += 1;\n return () => {\n activeCaptures.current -= 1;\n unregister();\n };\n },\n [register],\n );\n\n const {\n methods,\n placing,\n attempt,\n selectMethod,\n selectNewCard,\n setDraftBin,\n setDraftEntryValid,\n draft,\n cardPaymentCollapsed,\n cardModeActive,\n selectedMethodId,\n selectionOutOfScope,\n selectedMethod,\n } = selection;\n // T202: `sent` and `unresolved` are the two phases in which `placeOrder` only resumes (the callback leg), so\n // a card typed there would never be submitted and never cleared. The form takes no input until the attempt\n // is freed. Read from the attempt on every render; nothing here writes it.\n const locked = attempt?.phase === 'sent' || attempt?.phase === 'unresolved';\n // T191 (FR-13, Decision 8): classified with the engine's own `isCardMethod`, so the card form's\n // refusal and the collapse can never disagree about a method.\n const selectionNonCard = selectedMethod !== null && !isCardMethod(selectedMethod);\n\n const value = useMemo<CardCaptureContextValue>(\n () => ({\n networks: methods,\n busy: placing || locked,\n // T202: the card POST has settled by any route once `send` returns, so nothing the form holds is needed\n // again (a refusal raised before `send` never reaches the clear).\n clearOn: 'any-outcome',\n registerCapture,\n onCaptureMounted: dispatchAddPaymentInfo,\n selection: {\n selectMethod,\n selectNewCard,\n setDraftBin,\n setDraftEntryValid,\n path: draft.path,\n bin: draft.bin,\n collapsed: cardPaymentCollapsed,\n cardModeActive,\n selectedMethodId,\n selectionOutOfScope,\n selectionNonCard,\n },\n }),\n [\n methods,\n placing,\n locked,\n registerCapture,\n dispatchAddPaymentInfo,\n selectMethod,\n selectNewCard,\n setDraftBin,\n setDraftEntryValid,\n draft.path,\n draft.bin,\n cardPaymentCollapsed,\n cardModeActive,\n selectedMethodId,\n selectionOutOfScope,\n selectionNonCard,\n ],\n );\n\n return <CardCaptureContext value={value}>{children}</CardCaptureContext>;\n}\n"],"mappings":"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"}
|
|
@@ -11,7 +11,9 @@ export type PaymentSectionControllerProps = {
|
|
|
11
11
|
* scopes to exactly that one group. An empty string scopes nothing.
|
|
12
12
|
*/
|
|
13
13
|
group?: string | readonly string[];
|
|
14
|
-
/**
|
|
14
|
+
/** The order of the method list by `PaymentMethod.groupName`; only orders, never hides. See `PaymentSectionRootProps`. */
|
|
15
|
+
groupOrder?: string | readonly string[];
|
|
16
|
+
/** Keyed `{ payment, cart, clientProfile }` forwarded by the reactive runtime (arity-3 fragment, ADR-0015). */
|
|
15
17
|
$data?: PaymentSectionRootData;
|
|
16
18
|
/** Compiler-injected action surface; carries `payment.setMethod`, `payment.sendPayments`, and `analytics.track`. */
|
|
17
19
|
$actions?: ComponentActions;
|
|
@@ -19,6 +21,6 @@ export type PaymentSectionControllerProps = {
|
|
|
19
21
|
children?: ReactNode;
|
|
20
22
|
};
|
|
21
23
|
export declare const PaymentSectionControllerDefinition: ComponentDefinition<PaymentSectionControllerProps>;
|
|
22
|
-
export declare function PaymentSectionController({ group, $data: $dataProp, $actions: $actionsProp, children }: Readonly<PaymentSectionControllerProps>): string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
|
|
24
|
+
export declare function PaymentSectionController({ group, groupOrder, $data: $dataProp, $actions: $actionsProp, children }: Readonly<PaymentSectionControllerProps>): string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
|
|
23
25
|
//#endregion
|
|
24
26
|
//# sourceMappingURL=payment-controller.d.ts.map
|
|
@@ -22,6 +22,7 @@ const PaymentSectionControllerDefinition = defineComponent({
|
|
|
22
22
|
__typename
|
|
23
23
|
id
|
|
24
24
|
name
|
|
25
|
+
type
|
|
25
26
|
groupName
|
|
26
27
|
validator {
|
|
27
28
|
__typename
|
|
@@ -61,6 +62,13 @@ const PaymentSectionControllerDefinition = defineComponent({
|
|
|
61
62
|
currencyCode
|
|
62
63
|
}
|
|
63
64
|
}
|
|
65
|
+
clientProfile {
|
|
66
|
+
__typename
|
|
67
|
+
id
|
|
68
|
+
firstName
|
|
69
|
+
lastName
|
|
70
|
+
phone
|
|
71
|
+
}
|
|
64
72
|
}
|
|
65
73
|
`,
|
|
66
74
|
fetchStrategy: "reactive",
|
|
@@ -74,28 +82,41 @@ const PaymentSectionControllerDefinition = defineComponent({
|
|
|
74
82
|
label: "Payment Section Controller",
|
|
75
83
|
category: "commerce"
|
|
76
84
|
},
|
|
77
|
-
schema: {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
schema: {
|
|
86
|
+
group: {
|
|
87
|
+
type: "array",
|
|
88
|
+
default: ["creditCardPaymentGroup", "debitCardPaymentGroup"],
|
|
89
|
+
label: "Payment method group"
|
|
90
|
+
},
|
|
91
|
+
groupOrder: {
|
|
92
|
+
type: "array",
|
|
93
|
+
label: "Payment method group order"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
guideline: "State-only controller for a collapsed payment section: wrap a single DialogRoot (centered modal) or DrawerRoot (slide-in) child and it becomes controlled. Renders no markup and bakes no styling — compose the overlay particles (DialogTrigger/DialogPortal/DialogBackdrop/DialogPopup or the Drawer equivalents) directly as page nodes, put a static label (Text) inside the trigger — no component echoes the current choice there, and put PaymentMethodList plus the payment leaves (CardEntry, Installments, SavedCards, PlaceOrder, …) inside the popup. Provides the same 'payment' and 'card-capture' contexts as PaymentSectionRoot, so every leaf composes under either with no change. groupOrder only orders the popup's PaymentMethodList — a list of the store's payment group names, copied from its own data, that puts each option at its group's position; it never hides or adds an option, and a group it leaves out still shows after the named ones. Unlike the delivery-options controller it does NOT close on a successful selection — picking a method is mid-flow — so close it from a DrawerClose/DialogClose particle or from the leaf that finishes the flow. See payment.md.",
|
|
83
97
|
docPath: "./payment.md"
|
|
84
98
|
});
|
|
85
|
-
function PaymentSectionController({ group = DEFAULT_METHOD_GROUP, $data: $dataProp, $actions: $actionsProp, children }) {
|
|
99
|
+
function PaymentSectionController({ group = DEFAULT_METHOD_GROUP, groupOrder, $data: $dataProp, $actions: $actionsProp, children }) {
|
|
86
100
|
const $data = useDataOverride($dataProp);
|
|
87
101
|
const $actions = useActionsOverride($actionsProp);
|
|
88
102
|
const selection = usePaymentMethodSelection({
|
|
89
103
|
group,
|
|
104
|
+
groupOrder,
|
|
90
105
|
$data: $data?.payment ?? null,
|
|
91
106
|
$actions
|
|
92
107
|
});
|
|
93
108
|
const [open, setOpen] = useState(false);
|
|
109
|
+
const clientProfile = $data?.clientProfile;
|
|
94
110
|
const payment = useMemo(() => ({
|
|
95
111
|
...selection,
|
|
96
112
|
open,
|
|
97
|
-
setOpen
|
|
98
|
-
|
|
113
|
+
setOpen,
|
|
114
|
+
clientProfile
|
|
115
|
+
}), [
|
|
116
|
+
selection,
|
|
117
|
+
open,
|
|
118
|
+
clientProfile
|
|
119
|
+
]);
|
|
99
120
|
if (!isValidElement(children)) return children;
|
|
100
121
|
return /* @__PURE__ */ jsx(PaymentContext, {
|
|
101
122
|
value: payment,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment-controller.js","names":[],"sources":["../../../src/matter/payment/payment-controller.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport { cloneElement, isValidElement, type ReactNode, useMemo, useState } from 'react';\nimport { useActionsOverride } from '../../sdk/actions/actions-override-context.js';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { PaymentSubmissionProvider } from '../../sdk/payment/submission-registry.js';\nimport {\n DEFAULT_METHOD_GROUP,\n PaymentContext,\n type PaymentContextValue,\n type PaymentSectionRootData,\n} from './payment.js';\nimport { PaymentCardCaptureProvider } from './payment-card-capture.js';\nimport { usePaymentMethodSelection } from './use-payment-method-selection.js';\n\n/**\n * The collapsed payment section (centered modal / slide-in panel) as a state-only controller\n * (specs/payment-section-root.md, T5; docs/features/credit-card/rfc.md § D1). The page composes a raw\n * `DialogRoot` or `DrawerRoot` and each of its particles (`DialogTrigger` / `DialogBackdrop` /\n * `DialogPopup` …) directly as `page.json` nodes, so every part — including the portaled backdrop and\n * popup a descendant selector could not reach — is a swatch-addressable node with zero Tailwind baked\n * into the package, exactly as `DeliveryOptionsController` established.\n *\n * `PaymentSectionController` renders no markup: it runs the shared `usePaymentMethodSelection` engine,\n * holds the open state, provides the same `payment` context `PaymentSectionRoot` does (ADR-0009 matches\n * by contract identifier, so every leaf composes under either with no edit), then injects\n * `open` / `onOpenChange` into its single overlay-`Root` child via `cloneElement` — the same mechanism\n * as `CartOpenOnAdd` and `ShippingAddressSavedAddressDrawerController`.\n *\n * It diverges from `DeliveryOptionsController` in one deliberate way: a successful method selection\n * does **not** close the surface. Picking a delivery option completes that interaction; picking a\n * payment method is the first step of several — the shopper still types a card, picks an installment,\n * and places the order. Closing is therefore the composition's call, through the context's `setOpen`\n * (T14 on a placed order) or a `DrawerClose` / `DialogClose` particle.\n *\n * The trigger holds a static label (`Text`): no component echoes the current choice there, and none is\n * shipped here — `payment.md` documents the same composition.\n */\n\n// Repeats `PaymentSectionData`'s selection set verbatim under its own name. Two definitions cannot\n// share one fragment name in a page query, and the native catalog builder resolves\n// `defineComponent({ fragment })` statically — a value imported from another module is silently\n// dropped from the built catalog. `delivery-options` duplicates for the same reason;\n// `payment.test.tsx` asserts the two sets stay field-for-field identical.\nconst fragment = /* GraphQL */ `\n fragment PaymentSectionControllerData on Query {\n payment {\n __typename\n id\n methods {\n __typename\n id\n name\n groupName\n validator {\n __typename\n numberMask\n numberRegex\n cvvMask\n cvvRegex\n cvvRequired\n expirationRequired\n holderNameRequired\n billingAddressRequired\n documentDisplayable\n documentRequired\n }\n }\n selectedMethodId\n selectedAccountId\n selectedBin\n storeCountryCode\n countries {\n __typename\n countryCode\n documents {\n __typename\n type\n displayable\n required\n }\n }\n }\n cart {\n __typename\n id\n total {\n __typename\n amount\n currencyCode\n }\n }\n }\n`;\n\n// The minimal open-state shape the controller injects into its overlay-Root child; both `DialogRoot`\n// and `DrawerRoot` accept it.\ntype OverlayOpenProps = {\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n};\n\n// ---------------------------------------------------------------------------\n// Props\n// ---------------------------------------------------------------------------\n\nexport type PaymentSectionControllerProps = {\n /**\n * Scopes the method list to a **set** of `PaymentMethod.groupName` values — a method is in scope\n * when its `groupName` is a member (T140, FR-1, Decision 1). A single string is still accepted and\n * scopes to exactly that one group. An empty string scopes nothing.\n */\n group?: string | readonly string[];\n /** Keyed `{ payment, cart }` forwarded by the reactive runtime (arity-2 fragment, ADR-0015). */\n $data?: PaymentSectionRootData;\n /** Compiler-injected action surface; carries `payment.setMethod`, `payment.sendPayments`, and `analytics.track`. */\n $actions?: ComponentActions;\n /** The single overlay `Root` to control — a `DialogRoot` (modal) or `DrawerRoot` (slide-in). */\n children?: ReactNode;\n};\n\n// ---------------------------------------------------------------------------\n// Definition\n// ---------------------------------------------------------------------------\n\nexport const PaymentSectionControllerDefinition = defineComponent<PaymentSectionControllerProps>({\n name: 'PaymentSectionController',\n importPath: '@vtex/faststore/components',\n component: PaymentSectionController,\n fragment,\n fetchStrategy: 'reactive',\n actions: { payment: ['setMethod', 'sendPayments'], analytics: ['track'] },\n providesContext: ['payment', 'card-capture'],\n hardened: true,\n editor: { label: 'Payment Section Controller', category: 'commerce' },\n schema: {\n // Literal, not `DEFAULT_METHOD_GROUP` — see the same note on `PaymentSectionRootDefinition`.\n // T140, Decision 2/OQ-6: same widened shape as `PaymentSectionRootDefinition` — see its own note.\n group: {\n type: 'array',\n default: ['creditCardPaymentGroup', 'debitCardPaymentGroup'],\n label: 'Payment method group',\n },\n },\n guideline:\n \"State-only controller for a collapsed payment section: wrap a single DialogRoot (centered modal) or DrawerRoot (slide-in) child and it becomes controlled. Renders no markup and bakes no styling — compose the overlay particles (DialogTrigger/DialogPortal/DialogBackdrop/DialogPopup or the Drawer equivalents) directly as page nodes, put a static label (Text) inside the trigger — no component echoes the current choice there, and put PaymentMethodList plus the payment leaves (CardEntry, Installments, SavedCards, PlaceOrder, …) inside the popup. Provides the same 'payment' and 'card-capture' contexts as PaymentSectionRoot, so every leaf composes under either with no change. Unlike the delivery-options controller it does NOT close on a successful selection — picking a method is mid-flow — so close it from a DrawerClose/DialogClose particle or from the leaf that finishes the flow. See payment.md.\",\n // The convention-based `<file-stem>.md` (`payment-controller.md`) does not exist — this component's\n // doc is `payment.md`, shared with PaymentSectionRoot/PaymentMethodList (T25/FR-8).\n docPath: './payment.md',\n});\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\nexport function PaymentSectionController({\n group = DEFAULT_METHOD_GROUP,\n $data: $dataProp,\n $actions: $actionsProp,\n children,\n}: Readonly<PaymentSectionControllerProps>) {\n const $data = useDataOverride($dataProp);\n const $actions = useActionsOverride($actionsProp);\n const selection = usePaymentMethodSelection({ group, $data: $data?.payment ?? null, $actions });\n const [open, setOpen] = useState(false);\n const payment = useMemo<PaymentContextValue>(() => ({ ...selection, open, setOpen }), [selection, open]);\n\n if (!isValidElement<OverlayOpenProps>(children)) {\n return children;\n }\n\n return (\n <PaymentContext value={payment}>\n <PaymentSubmissionProvider path={selection.draft.path}>\n <PaymentCardCaptureProvider selection={selection} cart={$data?.cart} $actions={$actions}>\n {cloneElement(children, { open, onOpenChange: setOpen })}\n </PaymentCardCaptureProvider>\n </PaymentSubmissionProvider>\n </PaymentContext>\n );\n}\n"],"mappings":";;;;;;;;;;;AA+HA,MAAa,qCAAqC,gBAA+C;CAC/F,MAAM;CACN,YAAY;CACZ,WAAW;CACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACA,eAAe;CACf,SAAS;EAAE,SAAS,CAAC,aAAa,cAAc;EAAG,WAAW,CAAC,OAAO;CAAE;CACxE,iBAAiB,CAAC,WAAW,cAAc;CAC3C,UAAU;CACV,QAAQ;EAAE,OAAO;EAA8B,UAAU;CAAW;CACpE,QAAQ,EAGN,OAAO;EACL,MAAM;EACN,SAAS,CAAC,0BAA0B,uBAAuB;EAC3D,OAAO;CACT,EACF;CACA,WACE;CAGF,SAAS;AACX,CAAC;AAMD,SAAgB,yBAAyB,EACvC,QAAQ,sBACR,OAAO,WACP,UAAU,cACV,YAC0C;CAC1C,MAAM,QAAQ,gBAAgB,SAAS;CACvC,MAAM,WAAW,mBAAmB,YAAY;CAChD,MAAM,YAAY,0BAA0B;EAAE;EAAO,OAAO,OAAO,WAAW;EAAM;CAAS,CAAC;CAC9F,MAAM,CAAC,MAAM,WAAW,SAAS,KAAK;CACtC,MAAM,UAAU,eAAoC;EAAE,GAAG;EAAW;EAAM;CAAQ,IAAI,CAAC,WAAW,IAAI,CAAC;CAEvG,IAAI,CAAC,eAAiC,QAAQ,GAC5C,OAAO;CAGT,OACE,oBAAC,gBAAD;EAAgB,OAAO;EACrB,UAAA,oBAAC,2BAAD;GAA2B,MAAM,UAAU,MAAM;GAC/C,UAAA,oBAAC,4BAAD;IAAuC;IAAW,MAAM,OAAO;IAAgB;IAC5E,UAAA,aAAa,UAAU;KAAE;KAAM,cAAc;IAAQ,CAAC;GAC7B,CAAA;EACH,CAAA;CACb,CAAA;AAEpB"}
|
|
1
|
+
{"version":3,"file":"payment-controller.js","names":[],"sources":["../../../src/matter/payment/payment-controller.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport { cloneElement, isValidElement, type ReactNode, useMemo, useState } from 'react';\nimport { useActionsOverride } from '../../sdk/actions/actions-override-context.js';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { PaymentSubmissionProvider } from '../../sdk/payment/submission-registry.js';\nimport {\n DEFAULT_METHOD_GROUP,\n PaymentContext,\n type PaymentContextValue,\n type PaymentSectionRootData,\n} from './payment.js';\nimport { PaymentCardCaptureProvider } from './payment-card-capture.js';\nimport { usePaymentMethodSelection } from './use-payment-method-selection.js';\n\n/**\n * The collapsed payment section (centered modal / slide-in panel) as a state-only controller\n * (specs/payment-section-root.md, T5; docs/features/credit-card/rfc.md § D1). The page composes a raw\n * `DialogRoot` or `DrawerRoot` and each of its particles (`DialogTrigger` / `DialogBackdrop` /\n * `DialogPopup` …) directly as `page.json` nodes, so every part — including the portaled backdrop and\n * popup a descendant selector could not reach — is a swatch-addressable node with zero Tailwind baked\n * into the package, exactly as `DeliveryOptionsController` established.\n *\n * `PaymentSectionController` renders no markup: it runs the shared `usePaymentMethodSelection` engine,\n * holds the open state, provides the same `payment` context `PaymentSectionRoot` does (ADR-0009 matches\n * by contract identifier, so every leaf composes under either with no edit), then injects\n * `open` / `onOpenChange` into its single overlay-`Root` child via `cloneElement` — the same mechanism\n * as `CartOpenOnAdd` and `ShippingAddressSavedAddressDrawerController`.\n *\n * It diverges from `DeliveryOptionsController` in one deliberate way: a successful method selection\n * does **not** close the surface. Picking a delivery option completes that interaction; picking a\n * payment method is the first step of several — the shopper still types a card, picks an installment,\n * and places the order. Closing is therefore the composition's call, through the context's `setOpen`\n * (T14 on a placed order) or a `DrawerClose` / `DialogClose` particle.\n *\n * The trigger holds a static label (`Text`): no component echoes the current choice there, and none is\n * shipped here — `payment.md` documents the same composition.\n */\n\n// Repeats `PaymentSectionData`'s selection set verbatim under its own name. Two definitions cannot\n// share one fragment name in a page query, and the native catalog builder resolves\n// `defineComponent({ fragment })` statically — a value imported from another module is silently\n// dropped from the built catalog. `delivery-options` duplicates for the same reason;\n// `payment.test.tsx` asserts the two sets stay field-for-field identical.\nconst fragment = /* GraphQL */ `\n fragment PaymentSectionControllerData on Query {\n payment {\n __typename\n id\n methods {\n __typename\n id\n name\n type\n groupName\n validator {\n __typename\n numberMask\n numberRegex\n cvvMask\n cvvRegex\n cvvRequired\n expirationRequired\n holderNameRequired\n billingAddressRequired\n documentDisplayable\n documentRequired\n }\n }\n selectedMethodId\n selectedAccountId\n selectedBin\n storeCountryCode\n countries {\n __typename\n countryCode\n documents {\n __typename\n type\n displayable\n required\n }\n }\n }\n cart {\n __typename\n id\n total {\n __typename\n amount\n currencyCode\n }\n }\n clientProfile {\n __typename\n id\n firstName\n lastName\n phone\n }\n }\n`;\n\n// The minimal open-state shape the controller injects into its overlay-Root child; both `DialogRoot`\n// and `DrawerRoot` accept it.\ntype OverlayOpenProps = {\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n};\n\n// ---------------------------------------------------------------------------\n// Props\n// ---------------------------------------------------------------------------\n\nexport type PaymentSectionControllerProps = {\n /**\n * Scopes the method list to a **set** of `PaymentMethod.groupName` values — a method is in scope\n * when its `groupName` is a member (T140, FR-1, Decision 1). A single string is still accepted and\n * scopes to exactly that one group. An empty string scopes nothing.\n */\n group?: string | readonly string[];\n /** The order of the method list by `PaymentMethod.groupName`; only orders, never hides. See `PaymentSectionRootProps`. */\n groupOrder?: string | readonly string[];\n /** Keyed `{ payment, cart, clientProfile }` forwarded by the reactive runtime (arity-3 fragment, ADR-0015). */\n $data?: PaymentSectionRootData;\n /** Compiler-injected action surface; carries `payment.setMethod`, `payment.sendPayments`, and `analytics.track`. */\n $actions?: ComponentActions;\n /** The single overlay `Root` to control — a `DialogRoot` (modal) or `DrawerRoot` (slide-in). */\n children?: ReactNode;\n};\n\n// ---------------------------------------------------------------------------\n// Definition\n// ---------------------------------------------------------------------------\n\nexport const PaymentSectionControllerDefinition = defineComponent<PaymentSectionControllerProps>({\n name: 'PaymentSectionController',\n importPath: '@vtex/faststore/components',\n component: PaymentSectionController,\n fragment,\n fetchStrategy: 'reactive',\n actions: { payment: ['setMethod', 'sendPayments'], analytics: ['track'] },\n providesContext: ['payment', 'card-capture'],\n hardened: true,\n editor: { label: 'Payment Section Controller', category: 'commerce' },\n schema: {\n // Literal, not `DEFAULT_METHOD_GROUP` — see the same note on `PaymentSectionRootDefinition`.\n // T140, Decision 2/OQ-6: same widened shape as `PaymentSectionRootDefinition` — see its own note.\n group: {\n type: 'array',\n default: ['creditCardPaymentGroup', 'debitCardPaymentGroup'],\n label: 'Payment method group',\n },\n // T199, Decision 2: no `default` — see the same note on `PaymentSectionRootDefinition`.\n groupOrder: {\n type: 'array',\n label: 'Payment method group order',\n },\n },\n guideline:\n \"State-only controller for a collapsed payment section: wrap a single DialogRoot (centered modal) or DrawerRoot (slide-in) child and it becomes controlled. Renders no markup and bakes no styling — compose the overlay particles (DialogTrigger/DialogPortal/DialogBackdrop/DialogPopup or the Drawer equivalents) directly as page nodes, put a static label (Text) inside the trigger — no component echoes the current choice there, and put PaymentMethodList plus the payment leaves (CardEntry, Installments, SavedCards, PlaceOrder, …) inside the popup. Provides the same 'payment' and 'card-capture' contexts as PaymentSectionRoot, so every leaf composes under either with no change. groupOrder only orders the popup's PaymentMethodList — a list of the store's payment group names, copied from its own data, that puts each option at its group's position; it never hides or adds an option, and a group it leaves out still shows after the named ones. Unlike the delivery-options controller it does NOT close on a successful selection — picking a method is mid-flow — so close it from a DrawerClose/DialogClose particle or from the leaf that finishes the flow. See payment.md.\",\n // The convention-based `<file-stem>.md` (`payment-controller.md`) does not exist — this component's\n // doc is `payment.md`, shared with PaymentSectionRoot/PaymentMethodList (T25/FR-8).\n docPath: './payment.md',\n});\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\nexport function PaymentSectionController({\n group = DEFAULT_METHOD_GROUP,\n groupOrder,\n $data: $dataProp,\n $actions: $actionsProp,\n children,\n}: Readonly<PaymentSectionControllerProps>) {\n const $data = useDataOverride($dataProp);\n const $actions = useActionsOverride($actionsProp);\n const selection = usePaymentMethodSelection({ group, groupOrder, $data: $data?.payment ?? null, $actions });\n const [open, setOpen] = useState(false);\n const clientProfile = $data?.clientProfile;\n const payment = useMemo<PaymentContextValue>(\n () => ({ ...selection, open, setOpen, clientProfile }),\n [selection, open, clientProfile],\n );\n\n if (!isValidElement<OverlayOpenProps>(children)) {\n return children;\n }\n\n return (\n <PaymentContext value={payment}>\n <PaymentSubmissionProvider path={selection.draft.path}>\n <PaymentCardCaptureProvider selection={selection} cart={$data?.cart} $actions={$actions}>\n {cloneElement(children, { open, onOpenChange: setOpen })}\n </PaymentCardCaptureProvider>\n </PaymentSubmissionProvider>\n </PaymentContext>\n );\n}\n"],"mappings":";;;;;;;;;;;AAyIA,MAAa,qCAAqC,gBAA+C;CAC/F,MAAM;CACN,YAAY;CACZ,WAAW;CACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACA,eAAe;CACf,SAAS;EAAE,SAAS,CAAC,aAAa,cAAc;EAAG,WAAW,CAAC,OAAO;CAAE;CACxE,iBAAiB,CAAC,WAAW,cAAc;CAC3C,UAAU;CACV,QAAQ;EAAE,OAAO;EAA8B,UAAU;CAAW;CACpE,QAAQ;EAGN,OAAO;GACL,MAAM;GACN,SAAS,CAAC,0BAA0B,uBAAuB;GAC3D,OAAO;EACT;EAEA,YAAY;GACV,MAAM;GACN,OAAO;EACT;CACF;CACA,WACE;CAGF,SAAS;AACX,CAAC;AAMD,SAAgB,yBAAyB,EACvC,QAAQ,sBACR,YACA,OAAO,WACP,UAAU,cACV,YAC0C;CAC1C,MAAM,QAAQ,gBAAgB,SAAS;CACvC,MAAM,WAAW,mBAAmB,YAAY;CAChD,MAAM,YAAY,0BAA0B;EAAE;EAAO;EAAY,OAAO,OAAO,WAAW;EAAM;CAAS,CAAC;CAC1G,MAAM,CAAC,MAAM,WAAW,SAAS,KAAK;CACtC,MAAM,gBAAgB,OAAO;CAC7B,MAAM,UAAU,eACP;EAAE,GAAG;EAAW;EAAM;EAAS;CAAc,IACpD;EAAC;EAAW;EAAM;CAAa,CACjC;CAEA,IAAI,CAAC,eAAiC,QAAQ,GAC5C,OAAO;CAGT,OACE,oBAAC,gBAAD;EAAgB,OAAO;EACrB,UAAA,oBAAC,2BAAD;GAA2B,MAAM,UAAU,MAAM;GAC/C,UAAA,oBAAC,4BAAD;IAAuC;IAAW,MAAM,OAAO;IAAgB;IAC5E,UAAA,aAAa,UAAU;KAAE;KAAM,cAAc;IAAQ,CAAC;GAC7B,CAAA;EACH,CAAA;CACb,CAAA;AAEpB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { defineComponent } from "../../core/dist/define-component.js";
|
|
3
3
|
import "../../core/dist/index.js";
|
|
4
|
+
import { ownValue } from "../../utils/own-value.js";
|
|
4
5
|
import { useDataOverride } from "../../sdk/data/data-override-context.js";
|
|
5
6
|
import { Icon } from "../../particles/icon/icon.js";
|
|
6
7
|
import { usePayment } from "./payment.js";
|
|
7
|
-
import { ownValue } from "../../utils/own-value.js";
|
|
8
8
|
import { NETWORK_ICON_BY_KEY } from "../card-entry/card-entry.js";
|
|
9
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
//#region src/matter/payment/payment-method-badges.tsx
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { ContentValue, MessageLocaleProp } from "../../core/dist/define-content-type.js";
|
|
1
2
|
import { ComponentDefinition } from "../../core/dist/define-component.js";
|
|
2
3
|
import "../../core/dist/index.js";
|
|
3
4
|
import { ComponentActions } from "../../sdk/actions/types.js";
|
|
4
|
-
import { PaymentMethodSelection, PaymentSectionData } from "./use-payment-method-selection.js";
|
|
5
5
|
import { PaymentCartData } from "./payment-card-capture.js";
|
|
6
|
+
import { PaymentMethodSelection, PaymentSectionData } from "./use-payment-method-selection.js";
|
|
6
7
|
import { ComponentPropsWithRef } from "react";
|
|
7
8
|
//#region src/matter/payment/payment.d.ts
|
|
8
9
|
/**
|
|
@@ -12,12 +13,23 @@ import { ComponentPropsWithRef } from "react";
|
|
|
12
13
|
* a set (Decision 1) — a public API break for any consumer importing it directly (Interfaces).
|
|
13
14
|
*/
|
|
14
15
|
/**
|
|
15
|
-
* The
|
|
16
|
-
*
|
|
16
|
+
* The cart's contact profile as the submit gate reads it. Only the three fields VTEX refuses an order
|
|
17
|
+
* for; the profile's `document` is never selected, so no cardholder-document value reaches this contract.
|
|
18
|
+
*/
|
|
19
|
+
export type PaymentClientProfile = Readonly<{
|
|
20
|
+
firstName?: string | null;
|
|
21
|
+
lastName?: string | null;
|
|
22
|
+
phone?: string | null;
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* The roots' keyed `$data` (ADR-0015, arity 3): the `Payment` slice the selection engine reads, the
|
|
26
|
+
* cart total `add_payment_info` needs (moved here from `CardEntry`, which reads no cart), and the cart's
|
|
27
|
+
* profile, which the submit gate checks before a transaction opens.
|
|
17
28
|
*/
|
|
18
29
|
export type PaymentSectionRootData = {
|
|
19
30
|
payment?: PaymentSectionData;
|
|
20
31
|
cart?: PaymentCartData;
|
|
32
|
+
clientProfile?: PaymentClientProfile | null;
|
|
21
33
|
} | null;
|
|
22
34
|
export declare const DEFAULT_METHOD_GROUP: readonly string[];
|
|
23
35
|
/**
|
|
@@ -38,6 +50,12 @@ export type PaymentContextValue = Readonly<PaymentMethodSelection & {
|
|
|
38
50
|
* shopper still has a card to type — so closing is the composition's call (Decision 5).
|
|
39
51
|
*/
|
|
40
52
|
setOpen: (open: boolean) => void;
|
|
53
|
+
/**
|
|
54
|
+
* The cart's profile when the roots' `$data` carried one. `undefined` or `null` means it was not
|
|
55
|
+
* read (still resolving, or a `$data` that omits it), which the submit gate never refuses on; a
|
|
56
|
+
* present object counts as read even when every field is `null`.
|
|
57
|
+
*/
|
|
58
|
+
clientProfile?: PaymentClientProfile | null;
|
|
41
59
|
}>;
|
|
42
60
|
/** The provider both section roots render. Exported for `PaymentSectionController`. */
|
|
43
61
|
export declare const PaymentContext: React.Context<PaymentContextValue>;
|
|
@@ -59,31 +77,63 @@ export type PaymentSectionRootProps = ComponentPropsWithRef<'div'> & {
|
|
|
59
77
|
* fragment data. An empty string scopes nothing.
|
|
60
78
|
*/
|
|
61
79
|
group?: string | readonly string[];
|
|
62
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* The order of the method list, as a list of `PaymentMethod.groupName` values (T199): a method row
|
|
82
|
+
* sits at its group's position, and the single card control at the first of its groups the list
|
|
83
|
+
* names. It only orders — a group the list leaves out still shows, after the named ones in the order
|
|
84
|
+
* form's order, and a name no method holds is ignored. Names match exactly. Unset or empty keeps the
|
|
85
|
+
* order form's order, the card control first.
|
|
86
|
+
*/
|
|
87
|
+
groupOrder?: string | readonly string[];
|
|
88
|
+
/** Keyed `{ payment, cart, clientProfile }` forwarded by the reactive runtime (arity-3 fragment, ADR-0015). */
|
|
63
89
|
$data?: PaymentSectionRootData;
|
|
64
90
|
/** Compiler-injected action surface; carries `payment.setMethod`, `payment.sendPayments`, and `analytics.track`. */
|
|
65
91
|
$actions?: ComponentActions;
|
|
66
92
|
};
|
|
93
|
+
export declare const PaymentMethodListContent: {
|
|
94
|
+
readonly id: "payment-method-list";
|
|
95
|
+
readonly title: "Payment Method List";
|
|
96
|
+
readonly description: "Copy for the payment method group legend, the single card option and a refused selection.";
|
|
97
|
+
readonly schema: {
|
|
98
|
+
readonly type: "object";
|
|
99
|
+
readonly additionalProperties: false;
|
|
100
|
+
readonly properties: {
|
|
101
|
+
readonly legend: {
|
|
102
|
+
readonly type: "string";
|
|
103
|
+
readonly title: "Legend";
|
|
104
|
+
readonly description: "The radio group's visible accessible name.";
|
|
105
|
+
readonly format: "icu-message";
|
|
106
|
+
readonly messageSource: "Payment method";
|
|
107
|
+
};
|
|
108
|
+
readonly cardLabel: {
|
|
109
|
+
readonly type: "string";
|
|
110
|
+
readonly title: "Card option label";
|
|
111
|
+
readonly description: "Names the one option that stands for every in-scope credit and debit method.";
|
|
112
|
+
readonly format: "icu-message";
|
|
113
|
+
readonly messageSource: "Pay with Credit / Debit Card";
|
|
114
|
+
};
|
|
115
|
+
readonly genericErrorMessage: {
|
|
116
|
+
readonly type: "string";
|
|
117
|
+
readonly title: "Selection failure message";
|
|
118
|
+
readonly description: "Shown when a method selection fails: a network failure or a fault the shopper cannot fix.";
|
|
119
|
+
readonly format: "icu-message";
|
|
120
|
+
readonly messageSource: "Unable to select the payment method. Please try again.";
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
};
|
|
67
125
|
/** Renders its own controls from the context's method list — `children` would have nothing to template. */
|
|
68
|
-
export type PaymentMethodListProps = Omit<ComponentPropsWithRef<'div'>, 'children'> & {
|
|
69
|
-
/**
|
|
70
|
-
* The radio group's accessible name, rendered as a visible `Fieldset.Legend` (T38, Decision 1).
|
|
71
|
-
* Resolved through `resolveAuthoredCopy`: an authored empty or whitespace-only string falls back to
|
|
72
|
-
* the default rather than rendering a nameless group.
|
|
73
|
-
*/
|
|
74
|
-
legend?: string;
|
|
126
|
+
export type PaymentMethodListProps = Omit<ComponentPropsWithRef<'div'>, 'children'> & MessageLocaleProp & {
|
|
75
127
|
/**
|
|
76
|
-
*
|
|
77
|
-
* credit/debit method at once, so it cannot take its name from one
|
|
78
|
-
*
|
|
79
|
-
* Resolved through `resolveAuthoredCopy` exactly as `legend` is, so an authored empty or
|
|
80
|
-
* whitespace-only string falls back rather than rendering a nameless control.
|
|
128
|
+
* Merchant-authored copy: the group legend (T38) and the single card control's name (T171). The card
|
|
129
|
+
* control stands for every in-scope credit/debit method at once, so it cannot take its name from one
|
|
130
|
+
* of their `method.name` values.
|
|
81
131
|
*/
|
|
82
|
-
|
|
132
|
+
$content?: ContentValue<typeof PaymentMethodListContent>;
|
|
83
133
|
};
|
|
84
134
|
export declare const PaymentSectionRootDefinition: ComponentDefinition<PaymentSectionRootProps>;
|
|
85
135
|
export declare const PaymentMethodListDefinition: ComponentDefinition<PaymentMethodListProps>;
|
|
86
|
-
export declare function PaymentSectionRoot({ group, $data: $dataProp, $actions: $actionsProp, className, children, ...props }: PaymentSectionRootProps): import("react/jsx-runtime").JSX.Element;
|
|
87
|
-
export declare function PaymentMethodList({
|
|
136
|
+
export declare function PaymentSectionRoot({ group, groupOrder, $data: $dataProp, $actions: $actionsProp, className, children, ...props }: PaymentSectionRootProps): import("react/jsx-runtime").JSX.Element;
|
|
137
|
+
export declare function PaymentMethodList({ $content, $locale, className, ...props }: PaymentMethodListProps): import("react/jsx-runtime").JSX.Element;
|
|
88
138
|
//#endregion
|
|
89
139
|
//# sourceMappingURL=payment.d.ts.map
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { defineComponent } from "../../core/dist/define-component.js";
|
|
3
|
+
import { defineContentType } from "../../core/dist/define-content-type.js";
|
|
3
4
|
import "../../core/dist/index.js";
|
|
5
|
+
import { useMessageFormatter } from "../../sdk/i18n/use-message-formatter.js";
|
|
4
6
|
import { useActionsOverride } from "../../sdk/actions/actions-override-context.js";
|
|
7
|
+
import { formatErrorCode } from "../../sdk/i18n/format-error-code.js";
|
|
5
8
|
import { useDataOverride } from "../../sdk/data/data-override-context.js";
|
|
6
|
-
import { resolveAuthoredCopy } from "../../utils/resolve-authored-copy.js";
|
|
7
9
|
import { Fieldset } from "../../particles/fieldset/fieldset.js";
|
|
8
10
|
import { RadioGroup, RadioIndicator, RadioRoot } from "../../particles/radio/radio.js";
|
|
9
11
|
import { PaymentSubmissionProvider } from "../../sdk/payment/submission-registry.js";
|
|
10
|
-
import { resolveCanRevealCardPayment, resolvePreselectionCandidateId, splitCardMethods, usePaymentMethodSelection } from "./use-payment-method-selection.js";
|
|
12
|
+
import { orderMethodListRows, resolveCanRevealCardPayment, resolvePreselectionCandidateId, splitCardMethods, usePaymentMethodSelection } from "./use-payment-method-selection.js";
|
|
11
13
|
import { PaymentCardCaptureProvider } from "./payment-card-capture.js";
|
|
12
14
|
import { createContext, useContext, useId, useLayoutEffect, useMemo } from "react";
|
|
13
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -41,6 +43,7 @@ const fragment = `
|
|
|
41
43
|
__typename
|
|
42
44
|
id
|
|
43
45
|
name
|
|
46
|
+
type
|
|
44
47
|
groupName
|
|
45
48
|
validator {
|
|
46
49
|
__typename
|
|
@@ -80,6 +83,13 @@ const fragment = `
|
|
|
80
83
|
currencyCode
|
|
81
84
|
}
|
|
82
85
|
}
|
|
86
|
+
clientProfile {
|
|
87
|
+
__typename
|
|
88
|
+
id
|
|
89
|
+
firstName
|
|
90
|
+
lastName
|
|
91
|
+
phone
|
|
92
|
+
}
|
|
83
93
|
}
|
|
84
94
|
`;
|
|
85
95
|
const DEFAULT_METHOD_GROUP = ["creditCardPaymentGroup", "debitCardPaymentGroup"];
|
|
@@ -101,6 +111,53 @@ function usePayment() {
|
|
|
101
111
|
return ctx;
|
|
102
112
|
}
|
|
103
113
|
const NO_DISCLOSURE = () => {};
|
|
114
|
+
const PaymentMethodListContent = defineContentType({
|
|
115
|
+
id: "payment-method-list",
|
|
116
|
+
title: "Payment Method List",
|
|
117
|
+
description: "Copy for the payment method group legend, the single card option and a refused selection.",
|
|
118
|
+
schema: {
|
|
119
|
+
type: "object",
|
|
120
|
+
additionalProperties: false,
|
|
121
|
+
properties: {
|
|
122
|
+
legend: {
|
|
123
|
+
type: "string",
|
|
124
|
+
title: "Legend",
|
|
125
|
+
description: "The radio group's visible accessible name.",
|
|
126
|
+
format: "icu-message",
|
|
127
|
+
messageSource: "Payment method"
|
|
128
|
+
},
|
|
129
|
+
cardLabel: {
|
|
130
|
+
type: "string",
|
|
131
|
+
title: "Card option label",
|
|
132
|
+
description: "Names the one option that stands for every in-scope credit and debit method.",
|
|
133
|
+
format: "icu-message",
|
|
134
|
+
messageSource: "Pay with Credit / Debit Card"
|
|
135
|
+
},
|
|
136
|
+
genericErrorMessage: {
|
|
137
|
+
type: "string",
|
|
138
|
+
title: "Selection failure message",
|
|
139
|
+
description: "Shown when a method selection fails: a network failure or a fault the shopper cannot fix.",
|
|
140
|
+
format: "icu-message",
|
|
141
|
+
messageSource: "Unable to select the payment method. Please try again."
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
/**
|
|
147
|
+
* The message for each code a method selection can return. The list is not where a saved card is picked,
|
|
148
|
+
* so no code is one its shopper can act on here; every code, and one this map does not know, shows
|
|
149
|
+
* genericErrorMessage.
|
|
150
|
+
*/
|
|
151
|
+
const PAYMENT_METHOD_LIST_ERROR_FIELDS = {
|
|
152
|
+
MISSING_CART_CONTEXT: "genericErrorMessage",
|
|
153
|
+
CART_NOT_FOUND: "genericErrorMessage",
|
|
154
|
+
INVALID_METHOD_ID: "genericErrorMessage",
|
|
155
|
+
INVALID_SAVED_CARD_ACCOUNT_ID: "genericErrorMessage",
|
|
156
|
+
MISMATCHED_BIN_FOR_SAVED_CARD: "genericErrorMessage",
|
|
157
|
+
INVALID_BIN_FORMAT: "genericErrorMessage",
|
|
158
|
+
CONFLICTING_BIN_AND_ACCOUNT_ID: "genericErrorMessage",
|
|
159
|
+
NETWORK_ERROR: "genericErrorMessage"
|
|
160
|
+
};
|
|
104
161
|
const PaymentSectionRootDefinition = defineComponent({
|
|
105
162
|
name: "PaymentSectionRoot",
|
|
106
163
|
importPath: "@vtex/faststore/components",
|
|
@@ -117,49 +174,48 @@ const PaymentSectionRootDefinition = defineComponent({
|
|
|
117
174
|
label: "Payment Section",
|
|
118
175
|
category: "commerce"
|
|
119
176
|
},
|
|
120
|
-
schema: {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
177
|
+
schema: {
|
|
178
|
+
group: {
|
|
179
|
+
type: "array",
|
|
180
|
+
default: ["creditCardPaymentGroup", "debitCardPaymentGroup"],
|
|
181
|
+
label: "Payment method group"
|
|
182
|
+
},
|
|
183
|
+
groupOrder: {
|
|
184
|
+
type: "array",
|
|
185
|
+
label: "Payment method group order"
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
guideline: "Root of the checkout payment section: reads the payment methods and the current selection from the order form and provides the 'payment' context every payment leaf needs and the 'card-capture' context CardEntry needs, so place CardEntry, CardholderDocument, Installments, SaveCard, BillingAddress, SavedCards, PlaceOrder, and PaymentMethodList as its children — none of them render without a payment root ancestor. Renders one container div and no chrome or copy of its own; headings and layout belong to the composition. Selecting a payment option dispatches $actions.payment.setMethod and every subscriber re-renders from the cache with no refetch — and for a card it is the number the shopper types that decides the network, not an option they pick, so PaymentMethodList shows every in-scope credit and debit method as ONE card option. Which methods exist is always real data — never author them as props; group only scopes the list by the store's payment group(s) — defaults to credit and debit together, accepts one group name or a set of them, and set it to \"\" to show every method, one option each, with no card option. groupOrder only orders the list — a list of the store's payment group names, copied from its own data, that puts each option at its group's position and the card option at the first of its groups the list names; it never hides, adds or renames an option, a group it leaves out still shows after the named ones, and a name no method holds is ignored. Use PaymentSectionController instead when the section should live in a drawer or modal. See payment.md."
|
|
126
189
|
});
|
|
127
190
|
const PaymentMethodListDefinition = defineComponent({
|
|
128
191
|
name: "PaymentMethodList",
|
|
129
192
|
importPath: "@vtex/faststore/components",
|
|
130
193
|
component: PaymentMethodList,
|
|
131
194
|
requiresContext: "payment",
|
|
195
|
+
content: PaymentMethodListContent,
|
|
132
196
|
editor: {
|
|
133
197
|
label: "Payment Method List",
|
|
134
198
|
category: "commerce"
|
|
135
199
|
},
|
|
136
|
-
schema: {
|
|
137
|
-
|
|
138
|
-
type: "string",
|
|
139
|
-
default: "Payment method",
|
|
140
|
-
label: "Legend"
|
|
141
|
-
},
|
|
142
|
-
cardLabel: {
|
|
143
|
-
type: "string",
|
|
144
|
-
default: "Pay with Credit / Debit Card",
|
|
145
|
-
label: "Card option label"
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
guideline: "The payment-method picker: a radio group of the payment options the order form offers, plus the inline selection error (role=\"alert\"). Every in-scope credit and debit method is ONE option — the network comes from the card number the shopper types, never from a row they pick — and any other in-scope method (e.g. Pix) keeps a row of its own; set group to \"\" on the root to switch that off and get one row per method. Selecting an option dispatches the method selection. Selecting a non-card option hides the card form, and the card option brings it back. Place it inside a PaymentSectionRoot, or inside the DialogPopup/DrawerPopup of a PaymentSectionController. It renders its own options from real data, so it takes no children and no method props; author the card option's wording with cardLabel. Keep it composed: it is the only element that surfaces a rejected selection, and the only control that can recover a selection this section does not serve — omit it and a shopper whose persisted method sits outside group has no reachable way back. Must be inside a payment root."
|
|
200
|
+
schema: {},
|
|
201
|
+
guideline: "The payment-method picker: a radio group of the payment options the order form offers, plus the inline selection error (role=\"alert\"). Every in-scope credit and debit method is ONE option — the network comes from the card number the shopper types, never from a row they pick — and any other in-scope method (e.g. Pix) keeps a row of its own; set group to \"\" on the root to switch that off and get one row per method. Selecting an option dispatches the method selection. Selecting a non-card option hides the card form, and the card option brings it back. Place it inside a PaymentSectionRoot, or inside the DialogPopup/DrawerPopup of a PaymentSectionController. It renders its own options from real data, so it takes no children and no method props; its legend and the card option's wording come from the $content fields legend and cardLabel, and a refused selection shows genericErrorMessage. Keep it composed: it is the only element that surfaces a rejected selection, and the only control that can recover a selection this section does not serve — omit it and a shopper whose persisted method sits outside group has no reachable way back. Must be inside a payment root."
|
|
149
202
|
});
|
|
150
|
-
function PaymentSectionRoot({ group = DEFAULT_METHOD_GROUP, $data: $dataProp, $actions: $actionsProp, className, children, ...props }) {
|
|
203
|
+
function PaymentSectionRoot({ group = DEFAULT_METHOD_GROUP, groupOrder, $data: $dataProp, $actions: $actionsProp, className, children, ...props }) {
|
|
151
204
|
const $data = useDataOverride($dataProp);
|
|
152
205
|
const $actions = useActionsOverride($actionsProp);
|
|
153
206
|
const selection = usePaymentMethodSelection({
|
|
154
207
|
group,
|
|
208
|
+
groupOrder,
|
|
155
209
|
$data: $data?.payment ?? null,
|
|
156
210
|
$actions
|
|
157
211
|
});
|
|
212
|
+
const clientProfile = $data?.clientProfile;
|
|
158
213
|
const payment = useMemo(() => ({
|
|
159
214
|
...selection,
|
|
160
215
|
open: true,
|
|
161
|
-
setOpen: NO_DISCLOSURE
|
|
162
|
-
|
|
216
|
+
setOpen: NO_DISCLOSURE,
|
|
217
|
+
clientProfile
|
|
218
|
+
}), [selection, clientProfile]);
|
|
163
219
|
return /* @__PURE__ */ jsx(PaymentContextInternal, {
|
|
164
220
|
value: payment,
|
|
165
221
|
children: /* @__PURE__ */ jsx(PaymentSubmissionProvider, {
|
|
@@ -203,12 +259,22 @@ function methodListState({ loading, count }) {
|
|
|
203
259
|
* `PaymentMethod.id` a standalone row is bound to.
|
|
204
260
|
*/
|
|
205
261
|
const CARD_CONTROL_VALUE = "__fs-card-control";
|
|
206
|
-
function PaymentMethodList({
|
|
207
|
-
const {
|
|
262
|
+
function PaymentMethodList({ $content, $locale, className, ...props }) {
|
|
263
|
+
const { format } = useMessageFormatter(PaymentMethodListContent, $content);
|
|
264
|
+
const { methods, allMethods, groupOrder, persistedMethodId, selectedMethodId, selectionError, selectMethod, selectNewCard, cardModeActive, loading, placing, setMethodListMounted } = usePayment();
|
|
208
265
|
const { collapsedCardMethods, standaloneMethods } = useMemo(() => splitCardMethods({
|
|
209
266
|
methods,
|
|
210
267
|
allMethods
|
|
211
268
|
}), [methods, allMethods]);
|
|
269
|
+
const rows = useMemo(() => orderMethodListRows({
|
|
270
|
+
collapsedCardMethods,
|
|
271
|
+
standaloneMethods,
|
|
272
|
+
groupOrder
|
|
273
|
+
}), [
|
|
274
|
+
collapsedCardMethods,
|
|
275
|
+
standaloneMethods,
|
|
276
|
+
groupOrder
|
|
277
|
+
]);
|
|
212
278
|
const cardCandidateId = useMemo(() => resolvePreselectionCandidateId(methods), [methods]);
|
|
213
279
|
const canRevealCardPayment = resolveCanRevealCardPayment({
|
|
214
280
|
collapsedCardMethods,
|
|
@@ -246,30 +312,30 @@ function PaymentMethodList({ legend, cardLabel, className, ...props }) {
|
|
|
246
312
|
children: [selectionError ? /* @__PURE__ */ jsx("div", {
|
|
247
313
|
role: "alert",
|
|
248
314
|
"data-fs-payment-method-list-error": "",
|
|
249
|
-
children: selectionError
|
|
315
|
+
children: formatErrorCode(PaymentMethodListContent, PAYMENT_METHOD_LIST_ERROR_FIELDS, selectionError, format, "genericErrorMessage")
|
|
250
316
|
}) : null, methods.length > 0 ? /* @__PURE__ */ jsxs(Fieldset.Root, {
|
|
251
317
|
"data-fs-payment-method-list-fieldset": "",
|
|
252
|
-
children: [/* @__PURE__ */ jsx(Fieldset.Legend, { children:
|
|
318
|
+
children: [/* @__PURE__ */ jsx(Fieldset.Legend, { children: format("legend") }), /* @__PURE__ */ jsx(RadioGroup, {
|
|
253
319
|
value: cardControlChecked ? CARD_CONTROL_VALUE : selectedMethodId ?? "",
|
|
254
320
|
onValueChange: handleValueChange,
|
|
255
|
-
children:
|
|
321
|
+
children: rows.map((row) => row.kind === "card" ? /* @__PURE__ */ jsxs(RadioRoot, {
|
|
256
322
|
value: CARD_CONTROL_VALUE,
|
|
257
323
|
children: [/* @__PURE__ */ jsx(RadioIndicator, { "data-fs-payment-method-indicator": "" }), /* @__PURE__ */ jsx("span", {
|
|
258
324
|
"data-fs-payment-method-name": "",
|
|
259
|
-
children:
|
|
325
|
+
children: format("cardLabel")
|
|
260
326
|
})]
|
|
261
|
-
}
|
|
262
|
-
value: method.id,
|
|
327
|
+
}, CARD_CONTROL_VALUE) : /* @__PURE__ */ jsxs(RadioRoot, {
|
|
328
|
+
value: row.method.id,
|
|
263
329
|
children: [/* @__PURE__ */ jsx(RadioIndicator, { "data-fs-payment-method-indicator": "" }), /* @__PURE__ */ jsx("span", {
|
|
264
330
|
"data-fs-payment-method-name": "",
|
|
265
|
-
children: method.name
|
|
331
|
+
children: row.method.name
|
|
266
332
|
})]
|
|
267
|
-
}, method.id))
|
|
333
|
+
}, row.method.id))
|
|
268
334
|
})]
|
|
269
335
|
}) : null]
|
|
270
336
|
});
|
|
271
337
|
}
|
|
272
338
|
//#endregion
|
|
273
|
-
export { DEFAULT_METHOD_GROUP, PaymentContext, PaymentMethodList, PaymentMethodListDefinition, PaymentSectionRoot, PaymentSectionRootDefinition, usePayment };
|
|
339
|
+
export { DEFAULT_METHOD_GROUP, PAYMENT_METHOD_LIST_ERROR_FIELDS, PaymentContext, PaymentMethodList, PaymentMethodListContent, PaymentMethodListDefinition, PaymentSectionRoot, PaymentSectionRootDefinition, usePayment };
|
|
274
340
|
|
|
275
341
|
//# sourceMappingURL=payment.js.map
|