@vtex/faststore 0.0.8 → 0.0.11
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 +101 -0
- package/README.md +0 -1
- package/dist/actions.json +48 -1
- package/dist/catalog.json +1397 -1594
- 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 +67 -56
- package/dist/components.js +64 -53
- package/dist/content-types.json +5886 -555
- package/dist/core/dist/define-component.d.ts +7 -2
- 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-entry-point.md +4 -4
- package/dist/docs/account-menu.md +16 -17
- package/dist/docs/account-saved-cards.md +306 -0
- 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 +157 -0
- package/dist/docs/buy-button.md +7 -8
- package/dist/docs/card-entry.md +42 -29
- package/dist/docs/card-summary.md +185 -0
- package/dist/docs/cardholder-document.md +5 -3
- package/dist/docs/carousel.md +5 -4
- package/dist/docs/cart-destination.md +251 -0
- package/dist/docs/cart-item.md +48 -15
- package/dist/docs/cart-totalizer.md +8 -6
- package/dist/docs/cart.md +240 -39
- 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/footer-social.md +1 -1
- package/dist/docs/form.md +54 -18
- package/dist/docs/free-shipping-progress.md +18 -13
- package/dist/docs/identity-edit.md +8 -2
- package/dist/docs/identity-summary.md +18 -5
- package/dist/docs/incentives.md +2 -2
- package/dist/docs/installments.md +46 -32
- package/dist/docs/logo.md +1 -1
- 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 +32 -6
- package/dist/docs/payment-methods.md +2 -2
- 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 +14 -10
- package/dist/docs/product-list.md +7 -6
- package/dist/docs/product-shelf.md +7 -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/select.md +3 -4
- 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 +5 -3
- package/dist/docs/sign-in.md +173 -0
- package/dist/docs/toast.md +45 -16
- package/dist/docs/variant-selector.md +15 -11
- package/dist/graphql/types.d.ts +4 -14
- package/dist/index.d.ts +3 -2
- package/dist/internal/client.d.ts +4 -3
- package/dist/internal/client.js +5 -2
- package/dist/internal/server.d.ts +10 -5
- package/dist/internal/server.js +9 -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 +463 -0
- package/dist/matter/account-saved-cards/account-saved-cards.js +1011 -0
- package/dist/matter/account-saved-cards/account-saved-cards.js.map +1 -0
- 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 +11 -1
- package/dist/matter/cart/cart-namespace.js +11 -1
- package/dist/matter/cart/cart-namespace.js.map +1 -1
- package/dist/matter/cart/cart.d.ts +416 -45
- package/dist/matter/cart/cart.js +782 -101
- package/dist/matter/cart/cart.js.map +1 -1
- package/dist/matter/cart-destination/cart-destination.d.ts +233 -0
- package/dist/matter/cart-destination/cart-destination.js +703 -0
- package/dist/matter/cart-destination/cart-destination.js.map +1 -0
- package/dist/matter/cart-item/cart-item.d.ts +145 -16
- package/dist/matter/cart-item/cart-item.js +230 -54
- 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 +49 -19
- 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 +85 -10
- package/dist/matter/free-shipping-progress/free-shipping-progress.js +153 -53
- 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 +8 -3
- package/dist/matter/product-shelf/product-shelf.js +111 -10
- 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 +251 -25
- package/dist/matter/shipping-simulator/shipping-simulator.js +261 -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 +59 -0
- package/dist/particles/binding-switcher/binding-switcher.js +194 -0
- package/dist/particles/binding-switcher/binding-switcher.js.map +1 -0
- package/dist/particles/card-summary/card-network.d.ts +17 -0
- package/dist/particles/card-summary/card-network.js +25 -0
- package/dist/particles/card-summary/card-network.js.map +1 -0
- package/dist/particles/card-summary/card-summary.d.ts +113 -0
- package/dist/particles/card-summary/card-summary.js +221 -0
- package/dist/particles/card-summary/card-summary.js.map +1 -0
- 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/footer-social/footer-social.d.ts +1 -1
- package/dist/particles/footer-social/footer-social.js +1 -1
- package/dist/particles/footer-social/footer-social.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/incentives/incentives.d.ts +1 -1
- package/dist/particles/incentives/incentives.js +1 -1
- package/dist/particles/incentives/incentives.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/payment-methods/payment-methods.d.ts +1 -1
- package/dist/particles/payment-methods/payment-methods.js +1 -1
- package/dist/particles/payment-methods/payment-methods.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 +49 -9
- package/dist/particles/toast/toast.js +81 -15
- package/dist/particles/toast/toast.js.map +1 -1
- package/dist/schema.graphql +461 -89
- package/dist/sdk/actions/index.d.ts +3 -1
- package/dist/sdk/actions/index.js +3 -1
- package/dist/sdk/actions/locale-action-provider.d.ts +16 -0
- package/dist/sdk/actions/locale-action-provider.js +20 -0
- package/dist/sdk/actions/locale-action-provider.js.map +1 -0
- package/dist/sdk/actions/saved-card-action-provider.d.ts +12 -0
- package/dist/sdk/actions/saved-card-action-provider.js +16 -0
- package/dist/sdk/actions/saved-card-action-provider.js.map +1 -0
- package/dist/sdk/actions/types.d.ts +6 -2
- 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/cache/storefront-cache.js +2 -1
- package/dist/sdk/cache/storefront-cache.js.map +1 -1
- package/dist/sdk/cart/operations.d.ts +2 -1
- package/dist/sdk/cart/operations.js +55 -1
- package/dist/sdk/cart/operations.js.map +1 -1
- package/dist/sdk/cart/optimistic.d.ts +30 -7
- package/dist/sdk/cart/optimistic.js +78 -41
- package/dist/sdk/cart/optimistic.js.map +1 -1
- package/dist/sdk/cart/use-cart-actions.d.ts +7 -0
- package/dist/sdk/cart/use-cart-actions.js +61 -15
- package/dist/sdk/cart/use-cart-actions.js.map +1 -1
- package/dist/sdk/cart/use-cart-sync-sales-channel.js +70 -0
- package/dist/sdk/cart/use-cart-sync-sales-channel.js.map +1 -0
- 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 +16 -12
- package/dist/sdk/generated/gql.js.map +1 -1
- package/dist/sdk/generated/graphql.d.ts +197 -51
- package/dist/sdk/generated/graphql.js +2318 -91
- 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/locale/binding-switch-provider.d.ts +13 -0
- package/dist/sdk/locale/binding-switch-provider.js +20 -0
- package/dist/sdk/locale/binding-switch-provider.js.map +1 -0
- package/dist/sdk/locale/use-locale-actions.d.ts +16 -0
- package/dist/sdk/locale/use-locale-actions.js +70 -0
- package/dist/sdk/locale/use-locale-actions.js.map +1 -0
- package/dist/sdk/navigation/binding-switch.d.ts +39 -0
- package/dist/sdk/navigation/binding-switch.js +129 -0
- package/dist/sdk/navigation/binding-switch.js.map +1 -0
- package/dist/sdk/navigation/decode-route-params.d.ts +11 -0
- package/dist/sdk/navigation/decode-route-params.js +32 -0
- package/dist/sdk/navigation/decode-route-params.js.map +1 -0
- 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 +20 -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 -3
- 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/saved-cards/operations.d.ts +16 -0
- package/dist/sdk/saved-cards/operations.js +41 -0
- package/dist/sdk/saved-cards/operations.js.map +1 -0
- package/dist/sdk/saved-cards/use-saved-card-actions.d.ts +26 -0
- package/dist/sdk/saved-cards/use-saved-card-actions.js +86 -0
- package/dist/sdk/saved-cards/use-saved-card-actions.js.map +1 -0
- 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 +8 -5
- package/dist/sdk/seo/page-alternates.js +11 -14
- 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/shipping-operations.d.ts +1 -1
- package/dist/sdk/shipping/shipping-operations.js +13 -0
- package/dist/sdk/shipping/shipping-operations.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/sdk/state/cart.d.ts +9 -2
- package/dist/sdk/state/cart.js +9 -2
- package/dist/sdk/state/cart.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 +9 -2
- 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 -164
- package/dist/sdk/i18n/messages/en-US.js.map +0 -1
- package/dist/sdk/i18n/messages/en-US.json +0 -159
- package/dist/sdk/i18n/messages/en-US.json.d.ts +0 -163
- package/dist/sdk/i18n/messages/es-ES.js +0 -164
- package/dist/sdk/i18n/messages/es-ES.js.map +0 -1
- package/dist/sdk/i18n/messages/es-ES.json +0 -159
- package/dist/sdk/i18n/messages/pt-BR.js +0 -164
- package/dist/sdk/i18n/messages/pt-BR.js.map +0 -1
- package/dist/sdk/i18n/messages/pt-BR.json +0 -159
- 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
|
@@ -0,0 +1,703 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { defineComponent } from "../../core/dist/define-component.js";
|
|
3
|
+
import { defineContentType } from "../../core/dist/define-content-type.js";
|
|
4
|
+
import "../../core/dist/index.js";
|
|
5
|
+
import { useMessageFormatter } from "../../sdk/i18n/use-message-formatter.js";
|
|
6
|
+
import { Field } from "../../particles/field/field.js";
|
|
7
|
+
import { useActionsOverride } from "../../sdk/actions/actions-override-context.js";
|
|
8
|
+
import { formatErrorCode } from "../../sdk/i18n/format-error-code.js";
|
|
9
|
+
import { useDataOverride } from "../../sdk/data/data-override-context.js";
|
|
10
|
+
import { loggableErrorName } from "../../utils/loggable-error-name.js";
|
|
11
|
+
import { ReactiveRootContext } from "../../sdk/data/page-reactive-data-root.js";
|
|
12
|
+
import { addressFields } from "../../sdk/address/address-fields.js";
|
|
13
|
+
import { loadCountryRules } from "../../sdk/address/country-rules.js";
|
|
14
|
+
import { validateAddress } from "../../sdk/address/validate-address.js";
|
|
15
|
+
import { normalizePostalCode } from "../../sdk/address/postal-code.js";
|
|
16
|
+
import { awaitCartWrites } from "../../sdk/cart/write-gate.js";
|
|
17
|
+
import { Input } from "../../particles/input/input.js";
|
|
18
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
19
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
+
//#region src/matter/cart-destination/cart-destination.tsx
|
|
21
|
+
const fragment = `
|
|
22
|
+
fragment CartDestinationData on Query {
|
|
23
|
+
shipping {
|
|
24
|
+
__typename
|
|
25
|
+
id
|
|
26
|
+
address {
|
|
27
|
+
__typename
|
|
28
|
+
id
|
|
29
|
+
postalCode
|
|
30
|
+
country
|
|
31
|
+
city
|
|
32
|
+
state
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
const CartDestinationValueContent = defineContentType({
|
|
38
|
+
id: "cart-destination-value",
|
|
39
|
+
title: "Cart Destination Value",
|
|
40
|
+
description: "Copy that precedes the destination in read mode.",
|
|
41
|
+
schema: {
|
|
42
|
+
type: "object",
|
|
43
|
+
additionalProperties: false,
|
|
44
|
+
properties: { prefix: {
|
|
45
|
+
type: "string",
|
|
46
|
+
title: "Prefix"
|
|
47
|
+
} }
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const CartDestinationChangeContent = defineContentType({
|
|
51
|
+
id: "cart-destination-change",
|
|
52
|
+
title: "Cart Destination Change",
|
|
53
|
+
description: "Copy for the control that opens edit mode.",
|
|
54
|
+
schema: {
|
|
55
|
+
type: "object",
|
|
56
|
+
additionalProperties: false,
|
|
57
|
+
properties: { label: {
|
|
58
|
+
type: "string",
|
|
59
|
+
title: "Button label"
|
|
60
|
+
} }
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
const CartDestinationSubmitContent = defineContentType({
|
|
64
|
+
id: "cart-destination-submit",
|
|
65
|
+
title: "Cart Destination Submit",
|
|
66
|
+
description: "Copy for the control that writes the destination.",
|
|
67
|
+
schema: {
|
|
68
|
+
type: "object",
|
|
69
|
+
additionalProperties: false,
|
|
70
|
+
properties: {
|
|
71
|
+
label: {
|
|
72
|
+
type: "string",
|
|
73
|
+
title: "Button label"
|
|
74
|
+
},
|
|
75
|
+
pendingLabel: {
|
|
76
|
+
type: "string",
|
|
77
|
+
title: "Pending label"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const CartDestinationCancelContent = defineContentType({
|
|
83
|
+
id: "cart-destination-cancel",
|
|
84
|
+
title: "Cart Destination Cancel",
|
|
85
|
+
description: "Copy for the control that closes edit mode without writing.",
|
|
86
|
+
schema: {
|
|
87
|
+
type: "object",
|
|
88
|
+
additionalProperties: false,
|
|
89
|
+
properties: { label: {
|
|
90
|
+
type: "string",
|
|
91
|
+
title: "Button label"
|
|
92
|
+
} }
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
const CartDestinationErrorContent = defineContentType({
|
|
96
|
+
id: "cart-destination-error",
|
|
97
|
+
title: "Cart Destination Error",
|
|
98
|
+
description: "Messages shown when the destination write is refused, one per error code the shopper can act on.",
|
|
99
|
+
schema: {
|
|
100
|
+
type: "object",
|
|
101
|
+
additionalProperties: false,
|
|
102
|
+
properties: {
|
|
103
|
+
genericMessage: {
|
|
104
|
+
type: "string",
|
|
105
|
+
title: "Failure message",
|
|
106
|
+
description: "Shown for a network failure and for every refusal the shopper cannot act on.",
|
|
107
|
+
format: "icu-message",
|
|
108
|
+
messageSource: "Unable to update the delivery location. Please try again."
|
|
109
|
+
},
|
|
110
|
+
invalidPostalCodeMessage: {
|
|
111
|
+
type: "string",
|
|
112
|
+
title: "Invalid postal code message",
|
|
113
|
+
description: "Shown when the server rejects the postal code.",
|
|
114
|
+
format: "icu-message",
|
|
115
|
+
messageSource: "Enter a valid postal code."
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
const CART_DESTINATION_CONTEXT_UNSET = Symbol("CartDestinationContextUnset");
|
|
121
|
+
const CartDestinationContextInternal = createContext(CART_DESTINATION_CONTEXT_UNSET);
|
|
122
|
+
/**
|
|
123
|
+
* Read the destination and the edit-mode state from the nearest `CartDestinationRoot`. Throws outside
|
|
124
|
+
* one: a misplaced part is a composition bug the author should see at once.
|
|
125
|
+
*/
|
|
126
|
+
function useCartDestination() {
|
|
127
|
+
const ctx = useContext(CartDestinationContextInternal);
|
|
128
|
+
if (ctx === CART_DESTINATION_CONTEXT_UNSET) throw new Error("CartDestination components must be used inside a <CartDestinationRoot> subtree.");
|
|
129
|
+
return ctx;
|
|
130
|
+
}
|
|
131
|
+
/** Whether a `CartDestinationForm` encloses the subtree, so `CartDestinationSubmit` knows its form owner. */
|
|
132
|
+
const CartDestinationFormContext = createContext(false);
|
|
133
|
+
const DEFAULT_COUNTRY = "BRA";
|
|
134
|
+
/** Whether the country's rules refuse the value. A country the library does not cover refuses nothing. */
|
|
135
|
+
function isPostalCodeRefused(value, rules) {
|
|
136
|
+
if (!rules?.covered) return false;
|
|
137
|
+
return validateAddress({ postalCode: value.trim() }, rules).postalCode !== void 0;
|
|
138
|
+
}
|
|
139
|
+
/** The form the write sends and the comparison uses: the country's own, else the trimmed text. */
|
|
140
|
+
function toStoredPostalCode(value, rules) {
|
|
141
|
+
return rules ? normalizePostalCode(value, rules) : value.trim();
|
|
142
|
+
}
|
|
143
|
+
function isDraftSubmittable(draft, current, rules) {
|
|
144
|
+
if (draft.trim() === "" || isPostalCodeRefused(draft, rules)) return false;
|
|
145
|
+
return toStoredPostalCode(draft, rules) !== toStoredPostalCode(current ?? "", rules);
|
|
146
|
+
}
|
|
147
|
+
const CartDestinationRootDefinition = defineComponent({
|
|
148
|
+
name: "CartDestinationRoot",
|
|
149
|
+
importPath: "@vtex/faststore/components",
|
|
150
|
+
component: CartDestinationRoot,
|
|
151
|
+
fragment,
|
|
152
|
+
fetchStrategy: "reactive",
|
|
153
|
+
providesContext: "cartDestination",
|
|
154
|
+
actions: { shipping: ["setAddress"] },
|
|
155
|
+
editor: {
|
|
156
|
+
label: "Cart Destination Root",
|
|
157
|
+
category: "content"
|
|
158
|
+
},
|
|
159
|
+
schema: { defaultCountry: {
|
|
160
|
+
type: "string",
|
|
161
|
+
default: "BRA",
|
|
162
|
+
label: "Default country (ISO alpha-3)"
|
|
163
|
+
} },
|
|
164
|
+
guideline: "Where the cart is delivered, with a postal-code-only form that writes the cart destination so the free-shipping bar follows. Compose CartDestinationRead (CartDestinationValue, CartDestinationUnset, CartDestinationChange) for read mode and CartDestinationForm (PostalCodeControl, Submit, Cancel, Error) for edit mode. Starts in read mode; the store cannot open edit mode from outside. See cart-destination.md."
|
|
165
|
+
});
|
|
166
|
+
const CartDestinationReadDefinition = defineComponent({
|
|
167
|
+
name: "CartDestinationRead",
|
|
168
|
+
importPath: "@vtex/faststore/components",
|
|
169
|
+
component: CartDestinationRead,
|
|
170
|
+
requiresContext: "cartDestination",
|
|
171
|
+
editor: {
|
|
172
|
+
label: "Cart Destination Read",
|
|
173
|
+
category: "layout"
|
|
174
|
+
},
|
|
175
|
+
schema: {},
|
|
176
|
+
guideline: "Wraps what read mode shows: the value, the invitation when no destination is set, and the change control. Renders nothing while edit mode is open. Must be inside CartDestinationRoot."
|
|
177
|
+
});
|
|
178
|
+
const CartDestinationValueDefinition = defineComponent({
|
|
179
|
+
name: "CartDestinationValue",
|
|
180
|
+
importPath: "@vtex/faststore/components",
|
|
181
|
+
component: CartDestinationValue,
|
|
182
|
+
content: CartDestinationValueContent,
|
|
183
|
+
requiresContext: "cartDestination",
|
|
184
|
+
editor: {
|
|
185
|
+
label: "Cart Destination Value",
|
|
186
|
+
category: "content"
|
|
187
|
+
},
|
|
188
|
+
schema: { prefix: {
|
|
189
|
+
type: "string",
|
|
190
|
+
label: "Prefix"
|
|
191
|
+
} },
|
|
192
|
+
guideline: "The cart destination as postal code, city and state, each in its own element. Renders nothing while loading or when no destination is set. Must be inside CartDestinationRoot."
|
|
193
|
+
});
|
|
194
|
+
const CartDestinationUnsetDefinition = defineComponent({
|
|
195
|
+
name: "CartDestinationUnset",
|
|
196
|
+
importPath: "@vtex/faststore/components",
|
|
197
|
+
component: CartDestinationUnset,
|
|
198
|
+
requiresContext: "cartDestination",
|
|
199
|
+
editor: {
|
|
200
|
+
label: "Cart Destination Unset",
|
|
201
|
+
category: "content"
|
|
202
|
+
},
|
|
203
|
+
schema: {},
|
|
204
|
+
guideline: "A button that opens edit mode when pressed, like CartDestinationChange, with aria-expanded tied to the mode. Renders only once the destination resolved and none is set. Its children are the store-authored invitation (for example an Icon and a Text reading \"Informe seu CEP\"). Never place a CartDestinationChange, a link or another button inside it: a button cannot hold another. The regular CartDestinationChange repeats it, so the store usually hides that one while this shows. Place it within CartDestinationRead. Must be inside CartDestinationRoot."
|
|
205
|
+
});
|
|
206
|
+
const CartDestinationChangeDefinition = defineComponent({
|
|
207
|
+
name: "CartDestinationChange",
|
|
208
|
+
importPath: "@vtex/faststore/components",
|
|
209
|
+
component: CartDestinationChange,
|
|
210
|
+
content: CartDestinationChangeContent,
|
|
211
|
+
requiresContext: "cartDestination",
|
|
212
|
+
editor: {
|
|
213
|
+
label: "Cart Destination Change",
|
|
214
|
+
category: "action"
|
|
215
|
+
},
|
|
216
|
+
schema: { label: {
|
|
217
|
+
type: "string",
|
|
218
|
+
label: "Button label"
|
|
219
|
+
} },
|
|
220
|
+
guideline: "Button that opens edit mode, styled as a link by the store. Place it inside CartDestinationRead. Must be inside CartDestinationRoot."
|
|
221
|
+
});
|
|
222
|
+
const CartDestinationFormDefinition = defineComponent({
|
|
223
|
+
name: "CartDestinationForm",
|
|
224
|
+
importPath: "@vtex/faststore/components",
|
|
225
|
+
component: CartDestinationForm,
|
|
226
|
+
requiresContext: "cartDestination",
|
|
227
|
+
editor: {
|
|
228
|
+
label: "Cart Destination Form",
|
|
229
|
+
category: "action"
|
|
230
|
+
},
|
|
231
|
+
schema: {},
|
|
232
|
+
guideline: "Edit mode: renders only while editing and routes Enter to the submit. Holds the postal code control, Submit, Cancel and Error, and any help text the store places. Must be inside CartDestinationRoot."
|
|
233
|
+
});
|
|
234
|
+
const CartDestinationPostalCodeControlDefinition = defineComponent({
|
|
235
|
+
name: "CartDestinationPostalCodeControl",
|
|
236
|
+
importPath: "@vtex/faststore/components",
|
|
237
|
+
component: CartDestinationPostalCodeControl,
|
|
238
|
+
requiresContext: "cartDestination",
|
|
239
|
+
editor: {
|
|
240
|
+
label: "Cart Destination Postal Code Control",
|
|
241
|
+
category: "content"
|
|
242
|
+
},
|
|
243
|
+
schema: {
|
|
244
|
+
label: {
|
|
245
|
+
type: "string",
|
|
246
|
+
label: "Label"
|
|
247
|
+
},
|
|
248
|
+
placeholder: {
|
|
249
|
+
type: "string",
|
|
250
|
+
label: "Placeholder"
|
|
251
|
+
},
|
|
252
|
+
invalidMessage: {
|
|
253
|
+
type: "string",
|
|
254
|
+
label: "Invalid-value message"
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
guideline: "The postal code input of edit mode, empty each time edit mode opens and focused once enabled. A plain text field whose limits and example come from the cart country's postal code rules; it stays disabled while they load, and a country the rules do not cover takes free text. Must be inside CartDestinationForm."
|
|
258
|
+
});
|
|
259
|
+
const CartDestinationSubmitDefinition = defineComponent({
|
|
260
|
+
name: "CartDestinationSubmit",
|
|
261
|
+
importPath: "@vtex/faststore/components",
|
|
262
|
+
component: CartDestinationSubmit,
|
|
263
|
+
content: CartDestinationSubmitContent,
|
|
264
|
+
requiresContext: "cartDestination",
|
|
265
|
+
editor: {
|
|
266
|
+
label: "Cart Destination Submit",
|
|
267
|
+
category: "action"
|
|
268
|
+
},
|
|
269
|
+
schema: {
|
|
270
|
+
label: {
|
|
271
|
+
type: "string",
|
|
272
|
+
label: "Button label"
|
|
273
|
+
},
|
|
274
|
+
pendingLabel: {
|
|
275
|
+
type: "string",
|
|
276
|
+
label: "Pending label"
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
guideline: "Writes the typed postal code. Disabled until the country's rules have loaded, the typed code is valid for the country (any text for a country the rules do not cover) and different from the current one, and while a write is pending (aria-busy). Must be inside CartDestinationForm."
|
|
280
|
+
});
|
|
281
|
+
const CartDestinationCancelDefinition = defineComponent({
|
|
282
|
+
name: "CartDestinationCancel",
|
|
283
|
+
importPath: "@vtex/faststore/components",
|
|
284
|
+
component: CartDestinationCancel,
|
|
285
|
+
content: CartDestinationCancelContent,
|
|
286
|
+
requiresContext: "cartDestination",
|
|
287
|
+
editor: {
|
|
288
|
+
label: "Cart Destination Cancel",
|
|
289
|
+
category: "action"
|
|
290
|
+
},
|
|
291
|
+
schema: { label: {
|
|
292
|
+
type: "string",
|
|
293
|
+
label: "Button label"
|
|
294
|
+
} },
|
|
295
|
+
guideline: "Closes edit mode, discards what was typed and writes nothing. Disabled while a write is pending. Must be inside CartDestinationForm."
|
|
296
|
+
});
|
|
297
|
+
const CartDestinationErrorDefinition = defineComponent({
|
|
298
|
+
name: "CartDestinationError",
|
|
299
|
+
importPath: "@vtex/faststore/components",
|
|
300
|
+
component: CartDestinationError,
|
|
301
|
+
content: CartDestinationErrorContent,
|
|
302
|
+
requiresContext: "cartDestination",
|
|
303
|
+
editor: {
|
|
304
|
+
label: "Cart Destination Error",
|
|
305
|
+
category: "content"
|
|
306
|
+
},
|
|
307
|
+
schema: {},
|
|
308
|
+
guideline: "Announces why the destination write failed, as an alert, and renders nothing otherwise. Words each error code from its $content: invalidPostalCodeMessage for a postal code the server rejects, genericMessage for a network failure and every refusal the shopper cannot act on. A postal code the platform refuses upstream also reaches the client as a network failure, so write genericMessage to cover it. An unknown code also shows genericMessage. Must be inside CartDestinationForm."
|
|
309
|
+
});
|
|
310
|
+
/**
|
|
311
|
+
* Reads the cart destination reactively and publishes it, the edit-mode flag, the draft and the write
|
|
312
|
+
* state as `cartDestination` context.
|
|
313
|
+
*
|
|
314
|
+
* The destination is never copied into state: the Value renders only what `$data` resolves, and a
|
|
315
|
+
* successful write updates it solely by the mutation payload normalizing into the Apollo cache. A
|
|
316
|
+
* rejected write therefore needs no rollback.
|
|
317
|
+
*/
|
|
318
|
+
function CartDestinationRoot({ defaultCountry = DEFAULT_COUNTRY, $data: $dataProp, $actions: $actionsProp, className, children, ...props }) {
|
|
319
|
+
const $data = useDataOverride($dataProp);
|
|
320
|
+
const $actions = useActionsOverride($actionsProp);
|
|
321
|
+
const address = $data?.address ?? null;
|
|
322
|
+
const { loading: rootLoading } = useContext(ReactiveRootContext);
|
|
323
|
+
const postalCode = address?.postalCode ?? null;
|
|
324
|
+
const loading = rootLoading && postalCode == null;
|
|
325
|
+
const country = address?.country ?? defaultCountry;
|
|
326
|
+
const [editing, setEditing] = useState(false);
|
|
327
|
+
const [draft, setDraft] = useState("");
|
|
328
|
+
const [pending, setPending] = useState(false);
|
|
329
|
+
const [errors, setErrors] = useState([]);
|
|
330
|
+
const [invalid, setInvalid] = useState(false);
|
|
331
|
+
const inFlightRef = useRef(false);
|
|
332
|
+
const rootRef = useRef(null);
|
|
333
|
+
const wasEditingRef = useRef(false);
|
|
334
|
+
/**
|
|
335
|
+
* Leaving edit mode moves focus back to the control that opens it, which only mounts once read mode
|
|
336
|
+
* renders again, hence an effect on the flag rather than a call at the event. With no destination that
|
|
337
|
+
* is the invitation; the change control is hidden then, so the invitation wins when both exist.
|
|
338
|
+
* Opening it focuses the field, which `CartDestinationPostalCodeControl` does once the rules have loaded and enabled it.
|
|
339
|
+
*/
|
|
340
|
+
useEffect(() => {
|
|
341
|
+
if (wasEditingRef.current === editing) return;
|
|
342
|
+
wasEditingRef.current = editing;
|
|
343
|
+
if (editing) return;
|
|
344
|
+
(rootRef.current?.querySelector("[data-fs-cart-destination-unset]") ?? rootRef.current?.querySelector("[data-fs-cart-destination-change]"))?.focus();
|
|
345
|
+
}, [editing]);
|
|
346
|
+
const [loaded, setLoaded] = useState(null);
|
|
347
|
+
useEffect(() => {
|
|
348
|
+
if (!editing) {
|
|
349
|
+
setLoaded((current) => current?.rules ? current : null);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
let active = true;
|
|
353
|
+
loadCountryRules(country).then((rules) => {
|
|
354
|
+
if (active) setLoaded({
|
|
355
|
+
country,
|
|
356
|
+
rules
|
|
357
|
+
});
|
|
358
|
+
}, (error) => {
|
|
359
|
+
if (!active) return;
|
|
360
|
+
console.warn("[CartDestinationRoot] country rules failed to load", {
|
|
361
|
+
country,
|
|
362
|
+
error: loggableErrorName(error)
|
|
363
|
+
});
|
|
364
|
+
setLoaded({
|
|
365
|
+
country,
|
|
366
|
+
rules: null
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
return () => {
|
|
370
|
+
active = false;
|
|
371
|
+
};
|
|
372
|
+
}, [editing, country]);
|
|
373
|
+
const rulesLoading = editing && loaded?.country !== country;
|
|
374
|
+
const rules = loaded?.country === country ? loaded.rules : null;
|
|
375
|
+
const canSubmit = !pending && !rulesLoading && isDraftSubmittable(draft, postalCode, rules);
|
|
376
|
+
const startEditing = useCallback(() => setEditing(true), []);
|
|
377
|
+
const cancel = useCallback(() => {
|
|
378
|
+
setEditing(false);
|
|
379
|
+
setDraft("");
|
|
380
|
+
setErrors([]);
|
|
381
|
+
setInvalid(false);
|
|
382
|
+
}, []);
|
|
383
|
+
/** Typing is the shopper's answer to a refusal, so the message and the invalid flag go with it. */
|
|
384
|
+
const updateDraft = useCallback((value) => {
|
|
385
|
+
setDraft(value);
|
|
386
|
+
setErrors((current) => current.length === 0 ? current : []);
|
|
387
|
+
setInvalid(false);
|
|
388
|
+
}, []);
|
|
389
|
+
const submit = useCallback(() => {
|
|
390
|
+
if (inFlightRef.current) return;
|
|
391
|
+
const setAddress = $actions?.shipping?.setAddress;
|
|
392
|
+
if (!setAddress) return;
|
|
393
|
+
if (!canSubmit) {
|
|
394
|
+
setInvalid(true);
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
inFlightRef.current = true;
|
|
398
|
+
setPending(true);
|
|
399
|
+
setErrors([]);
|
|
400
|
+
setInvalid(false);
|
|
401
|
+
awaitCartWrites().then(() => setAddress({
|
|
402
|
+
postalCode: toStoredPostalCode(draft, rules),
|
|
403
|
+
country
|
|
404
|
+
})).then((writeErrors) => {
|
|
405
|
+
if (writeErrors.length > 0) {
|
|
406
|
+
setErrors(writeErrors);
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
setEditing(false);
|
|
410
|
+
setDraft("");
|
|
411
|
+
}).finally(() => {
|
|
412
|
+
inFlightRef.current = false;
|
|
413
|
+
setPending(false);
|
|
414
|
+
});
|
|
415
|
+
}, [
|
|
416
|
+
$actions,
|
|
417
|
+
canSubmit,
|
|
418
|
+
draft,
|
|
419
|
+
country,
|
|
420
|
+
rules
|
|
421
|
+
]);
|
|
422
|
+
const value = useMemo(() => ({
|
|
423
|
+
postalCode,
|
|
424
|
+
city: address?.city ?? null,
|
|
425
|
+
state: address?.state ?? null,
|
|
426
|
+
country,
|
|
427
|
+
loading,
|
|
428
|
+
editing,
|
|
429
|
+
startEditing,
|
|
430
|
+
cancel,
|
|
431
|
+
draft,
|
|
432
|
+
setDraft: updateDraft,
|
|
433
|
+
rules,
|
|
434
|
+
rulesLoading,
|
|
435
|
+
canSubmit,
|
|
436
|
+
pending,
|
|
437
|
+
errors,
|
|
438
|
+
invalid,
|
|
439
|
+
submit
|
|
440
|
+
}), [
|
|
441
|
+
postalCode,
|
|
442
|
+
address?.city,
|
|
443
|
+
address?.state,
|
|
444
|
+
country,
|
|
445
|
+
loading,
|
|
446
|
+
editing,
|
|
447
|
+
startEditing,
|
|
448
|
+
cancel,
|
|
449
|
+
draft,
|
|
450
|
+
updateDraft,
|
|
451
|
+
rules,
|
|
452
|
+
rulesLoading,
|
|
453
|
+
canSubmit,
|
|
454
|
+
pending,
|
|
455
|
+
errors,
|
|
456
|
+
invalid,
|
|
457
|
+
submit
|
|
458
|
+
]);
|
|
459
|
+
return /* @__PURE__ */ jsx(CartDestinationContextInternal, {
|
|
460
|
+
value,
|
|
461
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
462
|
+
...props,
|
|
463
|
+
ref: rootRef,
|
|
464
|
+
className,
|
|
465
|
+
"data-fs-cart-destination": "",
|
|
466
|
+
...pending ? { "data-fs-cart-destination-pending": "" } : {},
|
|
467
|
+
...editing ? { "data-fs-cart-destination-editing": "" } : {},
|
|
468
|
+
children
|
|
469
|
+
})
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
function CartDestinationRead({ className, children, ...props }) {
|
|
473
|
+
const { editing } = useCartDestination();
|
|
474
|
+
if (editing) return null;
|
|
475
|
+
return /* @__PURE__ */ jsx("div", {
|
|
476
|
+
...props,
|
|
477
|
+
className,
|
|
478
|
+
"data-fs-cart-destination-read": "",
|
|
479
|
+
children
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
function pickAuthored(content, prop) {
|
|
483
|
+
if (content?.trim()) return content;
|
|
484
|
+
if (prop?.trim()) return prop;
|
|
485
|
+
return null;
|
|
486
|
+
}
|
|
487
|
+
function CartDestinationValue({ prefix, $content, className, ...props }) {
|
|
488
|
+
const { postalCode, city, state, loading } = useCartDestination();
|
|
489
|
+
if (loading || postalCode == null) return null;
|
|
490
|
+
const resolvedPrefix = pickAuthored($content?.prefix, prefix);
|
|
491
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
492
|
+
...props,
|
|
493
|
+
className,
|
|
494
|
+
"data-fs-cart-destination-value": "",
|
|
495
|
+
children: [
|
|
496
|
+
resolvedPrefix ? /* @__PURE__ */ jsx("span", {
|
|
497
|
+
"data-fs-cart-destination-value-prefix": "",
|
|
498
|
+
children: resolvedPrefix
|
|
499
|
+
}) : null,
|
|
500
|
+
resolvedPrefix ? " " : null,
|
|
501
|
+
/* @__PURE__ */ jsx("span", {
|
|
502
|
+
"data-fs-cart-destination-value-postal-code": "",
|
|
503
|
+
children: postalCode
|
|
504
|
+
}),
|
|
505
|
+
city || state ? " · " : null,
|
|
506
|
+
city ? /* @__PURE__ */ jsx("span", {
|
|
507
|
+
"data-fs-cart-destination-value-city": "",
|
|
508
|
+
children: city
|
|
509
|
+
}) : null,
|
|
510
|
+
city && state ? ", " : null,
|
|
511
|
+
state ? /* @__PURE__ */ jsx("span", {
|
|
512
|
+
"data-fs-cart-destination-value-state": "",
|
|
513
|
+
children: state
|
|
514
|
+
}) : null
|
|
515
|
+
]
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
function CartDestinationUnset({ className, children, onClick, ...props }) {
|
|
519
|
+
const { postalCode, loading, editing, startEditing } = useCartDestination();
|
|
520
|
+
if (loading || postalCode != null) return null;
|
|
521
|
+
return /* @__PURE__ */ jsx("button", {
|
|
522
|
+
...props,
|
|
523
|
+
type: "button",
|
|
524
|
+
onClick: (event) => {
|
|
525
|
+
onClick?.(event);
|
|
526
|
+
startEditing();
|
|
527
|
+
},
|
|
528
|
+
"aria-expanded": editing,
|
|
529
|
+
className,
|
|
530
|
+
"data-fs-cart-destination-unset": "",
|
|
531
|
+
children
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
function CartDestinationChange({ label, $content, className, children, ...props }) {
|
|
535
|
+
const { editing, startEditing } = useCartDestination();
|
|
536
|
+
const resolvedLabel = pickAuthored($content?.label, label);
|
|
537
|
+
return /* @__PURE__ */ jsx("button", {
|
|
538
|
+
...props,
|
|
539
|
+
type: "button",
|
|
540
|
+
onClick: startEditing,
|
|
541
|
+
"aria-expanded": editing,
|
|
542
|
+
className,
|
|
543
|
+
"data-fs-cart-destination-change": "",
|
|
544
|
+
children: children ?? resolvedLabel
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
function CartDestinationForm({ className, children, ...props }) {
|
|
548
|
+
const { editing, submit } = useCartDestination();
|
|
549
|
+
if (!editing) return null;
|
|
550
|
+
return /* @__PURE__ */ jsx(CartDestinationFormContext, {
|
|
551
|
+
value: true,
|
|
552
|
+
children: /* @__PURE__ */ jsx("form", {
|
|
553
|
+
...props,
|
|
554
|
+
className,
|
|
555
|
+
"data-fs-cart-destination-form": "",
|
|
556
|
+
onKeyDown: (event) => {
|
|
557
|
+
if (event.key !== "Enter" || !(event.target instanceof HTMLInputElement)) return;
|
|
558
|
+
event.preventDefault();
|
|
559
|
+
submit();
|
|
560
|
+
},
|
|
561
|
+
onSubmit: (event) => {
|
|
562
|
+
event.preventDefault();
|
|
563
|
+
submit();
|
|
564
|
+
},
|
|
565
|
+
children
|
|
566
|
+
})
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
function CartDestinationPostalCodeControl({ className, label, placeholder, invalidMessage }) {
|
|
570
|
+
const { draft, setDraft, errors, invalid, pending, rules, rulesLoading } = useCartDestination();
|
|
571
|
+
const rootRef = useRef(null);
|
|
572
|
+
const focusedOnOpenRef = useRef(false);
|
|
573
|
+
const [blurInvalid, setBlurInvalid] = useState(false);
|
|
574
|
+
const refused = errors.length > 0;
|
|
575
|
+
const descriptor = useMemo(() => rules ? addressFields(rules, {}).find(({ name }) => name === "postalCode") : void 0, [rules]);
|
|
576
|
+
/** The country's example postal code: address data, not a message. */
|
|
577
|
+
const example = descriptor?.placeholder?.values.example;
|
|
578
|
+
/** A disabled input cannot take focus, so opening edit mode focuses the field once the rules enable it. */
|
|
579
|
+
useEffect(() => {
|
|
580
|
+
if (rulesLoading || focusedOnOpenRef.current) return;
|
|
581
|
+
focusedOnOpenRef.current = true;
|
|
582
|
+
rootRef.current?.querySelector("[data-fs-postal-code-field-input]")?.focus();
|
|
583
|
+
}, [rulesLoading]);
|
|
584
|
+
/**
|
|
585
|
+
* Disabling the input while the write is in flight drops focus to the body, so a refusal otherwise
|
|
586
|
+
* lands with nothing focused. Waits for `pending` to clear: focusing a disabled input is a no-op.
|
|
587
|
+
*/
|
|
588
|
+
useEffect(() => {
|
|
589
|
+
if (!refused || pending) return;
|
|
590
|
+
rootRef.current?.querySelector("[data-fs-postal-code-field-input]")?.focus();
|
|
591
|
+
}, [refused, pending]);
|
|
592
|
+
function handleChange(event) {
|
|
593
|
+
setBlurInvalid(false);
|
|
594
|
+
setDraft(event.target.value);
|
|
595
|
+
}
|
|
596
|
+
const showInvalid = invalid || refused || blurInvalid;
|
|
597
|
+
return /* @__PURE__ */ jsxs(Field.Root, {
|
|
598
|
+
ref: rootRef,
|
|
599
|
+
className,
|
|
600
|
+
name: "postalCode",
|
|
601
|
+
invalid: showInvalid,
|
|
602
|
+
disabled: pending || rulesLoading,
|
|
603
|
+
"data-fs-postal-code-field": "",
|
|
604
|
+
"data-fs-cart-destination-postal-code-control": "",
|
|
605
|
+
children: [
|
|
606
|
+
label ? /* @__PURE__ */ jsx(Field.Label, {
|
|
607
|
+
"data-fs-postal-code-field-label": "",
|
|
608
|
+
children: label
|
|
609
|
+
}) : null,
|
|
610
|
+
/* @__PURE__ */ jsx(Input, {
|
|
611
|
+
"data-fs-postal-code-field-input": "",
|
|
612
|
+
type: "text",
|
|
613
|
+
name: "postalCode",
|
|
614
|
+
autoComplete: "postal-code",
|
|
615
|
+
value: draft,
|
|
616
|
+
maxLength: descriptor?.maxLength,
|
|
617
|
+
inputMode: descriptor?.inputMode,
|
|
618
|
+
placeholder: placeholder ?? example,
|
|
619
|
+
onChange: handleChange,
|
|
620
|
+
onBlur: () => setBlurInvalid(draft.trim() !== "" && isPostalCodeRefused(draft, rules))
|
|
621
|
+
}),
|
|
622
|
+
showInvalid && !refused && invalidMessage ? /* @__PURE__ */ jsx(Field.Error, {
|
|
623
|
+
match: true,
|
|
624
|
+
"data-fs-postal-code-field-error": "",
|
|
625
|
+
children: invalidMessage
|
|
626
|
+
}) : null
|
|
627
|
+
]
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
function CartDestinationSubmit({ label, pendingLabel, $content, className, children, ...props }) {
|
|
631
|
+
const { canSubmit, pending, submit } = useCartDestination();
|
|
632
|
+
const inForm = useContext(CartDestinationFormContext);
|
|
633
|
+
const resolvedLabel = pickAuthored($content?.label, label);
|
|
634
|
+
const resolvedPendingLabel = pickAuthored($content?.pendingLabel, pendingLabel);
|
|
635
|
+
return /* @__PURE__ */ jsx("button", {
|
|
636
|
+
...props,
|
|
637
|
+
type: inForm ? "submit" : "button",
|
|
638
|
+
onClick: inForm ? props.onClick : submit,
|
|
639
|
+
disabled: !canSubmit || props.disabled,
|
|
640
|
+
"aria-busy": pending || void 0,
|
|
641
|
+
className,
|
|
642
|
+
"data-fs-cart-destination-submit": "",
|
|
643
|
+
...pending ? { "data-fs-cart-destination-submit-pending": "" } : {},
|
|
644
|
+
children: children ?? (pending ? resolvedPendingLabel ?? resolvedLabel : resolvedLabel)
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
function CartDestinationCancel({ label, $content, className, children, ...props }) {
|
|
648
|
+
const { cancel, pending } = useCartDestination();
|
|
649
|
+
const resolvedLabel = pickAuthored($content?.label, label);
|
|
650
|
+
return /* @__PURE__ */ jsx("button", {
|
|
651
|
+
...props,
|
|
652
|
+
type: "button",
|
|
653
|
+
onClick: cancel,
|
|
654
|
+
disabled: pending || props.disabled,
|
|
655
|
+
className,
|
|
656
|
+
"data-fs-cart-destination-cancel": "",
|
|
657
|
+
children: children ?? resolvedLabel
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* The message for each code `shippingAddressUpdate` can return, plus the client-minted transport failure.
|
|
662
|
+
* This form writes only the postal code and the country, so every other refusal is one the shopper
|
|
663
|
+
* cannot act on here.
|
|
664
|
+
*/
|
|
665
|
+
const CART_DESTINATION_ERROR_FIELDS = {
|
|
666
|
+
INVALID_POSTAL_CODE: "invalidPostalCodeMessage",
|
|
667
|
+
INVALID_ADDRESS: "genericMessage",
|
|
668
|
+
INVALID_COUNTRY_CODE: "genericMessage",
|
|
669
|
+
MISSING_RECIPIENT_NAME: "genericMessage",
|
|
670
|
+
INVALID_SAVED_ADDRESS_ID: "genericMessage",
|
|
671
|
+
MISSING_CART_CONTEXT: "genericMessage",
|
|
672
|
+
CART_NOT_FOUND: "genericMessage",
|
|
673
|
+
NETWORK_ERROR: "genericMessage"
|
|
674
|
+
};
|
|
675
|
+
function CartDestinationError({ $content, $locale, className, ...props }) {
|
|
676
|
+
const { errors } = useCartDestination();
|
|
677
|
+
const { format } = useMessageFormatter(CartDestinationErrorContent, $content);
|
|
678
|
+
const [firstError] = errors;
|
|
679
|
+
if (!firstError) return null;
|
|
680
|
+
return /* @__PURE__ */ jsx("div", {
|
|
681
|
+
...props,
|
|
682
|
+
role: "alert",
|
|
683
|
+
className,
|
|
684
|
+
"data-fs-cart-destination-error": "",
|
|
685
|
+
children: formatErrorCode(CartDestinationErrorContent, CART_DESTINATION_ERROR_FIELDS, firstError, format, "genericMessage")
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
const CartDestination = {
|
|
689
|
+
Root: CartDestinationRoot,
|
|
690
|
+
Read: CartDestinationRead,
|
|
691
|
+
Value: CartDestinationValue,
|
|
692
|
+
Unset: CartDestinationUnset,
|
|
693
|
+
Change: CartDestinationChange,
|
|
694
|
+
Form: CartDestinationForm,
|
|
695
|
+
PostalCodeControl: CartDestinationPostalCodeControl,
|
|
696
|
+
Submit: CartDestinationSubmit,
|
|
697
|
+
Cancel: CartDestinationCancel,
|
|
698
|
+
Error: CartDestinationError
|
|
699
|
+
};
|
|
700
|
+
//#endregion
|
|
701
|
+
export { CART_DESTINATION_ERROR_FIELDS, CartDestination, CartDestinationCancel, CartDestinationCancelContent, CartDestinationCancelDefinition, CartDestinationChange, CartDestinationChangeContent, CartDestinationChangeDefinition, CartDestinationError, CartDestinationErrorContent, CartDestinationErrorDefinition, CartDestinationForm, CartDestinationFormDefinition, CartDestinationPostalCodeControl, CartDestinationPostalCodeControlDefinition, CartDestinationRead, CartDestinationReadDefinition, CartDestinationRoot, CartDestinationRootDefinition, CartDestinationSubmit, CartDestinationSubmitContent, CartDestinationSubmitDefinition, CartDestinationUnset, CartDestinationUnsetDefinition, CartDestinationValue, CartDestinationValueContent, CartDestinationValueDefinition, useCartDestination };
|
|
702
|
+
|
|
703
|
+
//# sourceMappingURL=cart-destination.js.map
|