@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
|
@@ -3,9 +3,10 @@ import { defineComponent } from "../../core/dist/define-component.js";
|
|
|
3
3
|
import { defineContentType } from "../../core/dist/define-content-type.js";
|
|
4
4
|
import "../../core/dist/index.js";
|
|
5
5
|
import { resolveSafeHref } from "../../utils/safe-href.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useMessageFormatter } from "../../sdk/i18n/use-message-formatter.js";
|
|
7
7
|
import { graphql } from "../../sdk/generated/gql.js";
|
|
8
8
|
import { useActionsOverride } from "../../sdk/actions/actions-override-context.js";
|
|
9
|
+
import { formatErrorCode } from "../../sdk/i18n/format-error-code.js";
|
|
9
10
|
import { useDataOverride } from "../../sdk/data/data-override-context.js";
|
|
10
11
|
import { ReactiveRootContext } from "../../sdk/data/page-reactive-data-root.js";
|
|
11
12
|
import { PostalCodeField } from "../../particles/postal-code-field/postal-code-field.js";
|
|
@@ -29,7 +30,9 @@ const RegionTriggerContent = defineContentType({
|
|
|
29
30
|
properties: {
|
|
30
31
|
unsetLabel: {
|
|
31
32
|
type: "string",
|
|
32
|
-
title: "Label when no region is set"
|
|
33
|
+
title: "Label when no region is set",
|
|
34
|
+
format: "icu-message",
|
|
35
|
+
messageSource: "Enter your postal code"
|
|
33
36
|
},
|
|
34
37
|
ariaLabel: {
|
|
35
38
|
type: "string",
|
|
@@ -48,11 +51,15 @@ const RegionSubmitContent = defineContentType({
|
|
|
48
51
|
properties: {
|
|
49
52
|
label: {
|
|
50
53
|
type: "string",
|
|
51
|
-
title: "Button label"
|
|
54
|
+
title: "Button label",
|
|
55
|
+
format: "icu-message",
|
|
56
|
+
messageSource: "Apply"
|
|
52
57
|
},
|
|
53
58
|
pendingLabel: {
|
|
54
59
|
type: "string",
|
|
55
|
-
title: "Pending label"
|
|
60
|
+
title: "Pending label",
|
|
61
|
+
format: "icu-message",
|
|
62
|
+
messageSource: "Applying..."
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
65
|
}
|
|
@@ -82,14 +89,32 @@ const RegionUnknownLinkContent = defineContentType({
|
|
|
82
89
|
const RegionErrorContent = defineContentType({
|
|
83
90
|
id: "region-error",
|
|
84
91
|
title: "Region Error",
|
|
85
|
-
description: "
|
|
92
|
+
description: "Messages shown when a write fails: a network failure, an invalid postal code, an unserved one.",
|
|
86
93
|
schema: {
|
|
87
94
|
type: "object",
|
|
88
95
|
additionalProperties: false,
|
|
89
|
-
properties: {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
96
|
+
properties: {
|
|
97
|
+
genericMessage: {
|
|
98
|
+
type: "string",
|
|
99
|
+
title: "Generic failure message",
|
|
100
|
+
format: "icu-message",
|
|
101
|
+
messageSource: "Unable to set your region. Please try again."
|
|
102
|
+
},
|
|
103
|
+
invalidPostalCode: {
|
|
104
|
+
type: "string",
|
|
105
|
+
title: "Invalid postal code",
|
|
106
|
+
description: "Shown when the server rejects the postal code as invalid.",
|
|
107
|
+
format: "icu-message",
|
|
108
|
+
messageSource: "Enter a valid postal code."
|
|
109
|
+
},
|
|
110
|
+
unservedPostalCode: {
|
|
111
|
+
type: "string",
|
|
112
|
+
title: "Unserved postal code",
|
|
113
|
+
description: "Shown when the server serves no region for the postal code.",
|
|
114
|
+
format: "icu-message",
|
|
115
|
+
messageSource: "We do not deliver to this postal code yet."
|
|
116
|
+
}
|
|
117
|
+
}
|
|
93
118
|
}
|
|
94
119
|
});
|
|
95
120
|
const REGION_CONTEXT_UNSET = Symbol("RegionContextUnset");
|
|
@@ -138,12 +163,8 @@ const RegionTriggerDefinition = defineComponent({
|
|
|
138
163
|
label: "Region Trigger",
|
|
139
164
|
category: "action"
|
|
140
165
|
},
|
|
141
|
-
schema: {
|
|
142
|
-
|
|
143
|
-
default: "Informe seu CEP",
|
|
144
|
-
label: "Label when no region is set"
|
|
145
|
-
} },
|
|
146
|
-
guideline: "Opens the region modal. Shows its unset label while no region is set; compose RegionValue as its child so the active region reads inside the control once one is. Its accessible name carries the active region, so a screen reader announces where the shopper is shopping. Must be inside RegionRoot."
|
|
166
|
+
schema: {},
|
|
167
|
+
guideline: "Opens the region modal. Shows its unset label ($content field unsetLabel) while no region is set; compose RegionValue as its child so the active region reads inside the control once one is. Its accessible name carries the active region, so a screen reader announces where the shopper is shopping. Must be inside RegionRoot."
|
|
147
168
|
});
|
|
148
169
|
const RegionValueDefinition = defineComponent({
|
|
149
170
|
name: "RegionValue",
|
|
@@ -233,19 +254,8 @@ const RegionSubmitDefinition = defineComponent({
|
|
|
233
254
|
label: "Region Submit",
|
|
234
255
|
category: "action"
|
|
235
256
|
},
|
|
236
|
-
schema: {
|
|
237
|
-
|
|
238
|
-
type: "string",
|
|
239
|
-
default: "Aplicar",
|
|
240
|
-
label: "Button label"
|
|
241
|
-
},
|
|
242
|
-
pendingLabel: {
|
|
243
|
-
type: "string",
|
|
244
|
-
default: "Aplicando...",
|
|
245
|
-
label: "Pending label"
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
guideline: "Submits the region draft. Inside a RegionForm it is the form's submit button, which is what makes Enter in the field work; on its own it dispatches directly. Inert while empty and while a write is in flight, so a double activation dispatches one mutation; the pending state is exposed as aria-busy with no built-in spinner. On success the modal closes; on a rejection it stays open and RegionError explains why. Must be inside a RegionModalController dialog."
|
|
257
|
+
schema: {},
|
|
258
|
+
guideline: "Submits the region draft. Its label comes from the $content fields label and pendingLabel; authored children replace both. Inside a RegionForm it is the form's submit button, which is what makes Enter in the field work; on its own it dispatches directly. Inert while empty and while a write is in flight, so a double activation dispatches one mutation; the pending state is exposed as aria-busy with no built-in spinner. On success the modal closes; on a rejection it stays open and RegionError explains why. Must be inside a RegionModalController dialog."
|
|
249
259
|
});
|
|
250
260
|
const RegionErrorDefinition = defineComponent({
|
|
251
261
|
name: "RegionError",
|
|
@@ -258,7 +268,7 @@ const RegionErrorDefinition = defineComponent({
|
|
|
258
268
|
category: "content"
|
|
259
269
|
},
|
|
260
270
|
schema: {},
|
|
261
|
-
guideline: "Shows why the latest region write was refused, announced as an alert when it appears. Renders nothing when there is no error, so it needs no visibility prop.
|
|
271
|
+
guideline: "Shows why the latest region write was refused, announced as an alert when it appears. Renders nothing when there is no error, so it needs no visibility prop. Words each known code from its message (genericMessage for a transport failure and an unknown code). Must be inside a RegionModalController dialog."
|
|
262
272
|
});
|
|
263
273
|
const RegionUnknownLinkDefinition = defineComponent({
|
|
264
274
|
name: "RegionUnknownLink",
|
|
@@ -376,10 +386,10 @@ function RegionRoot({ $data: $dataProp, $actions: $actionsProp, className, child
|
|
|
376
386
|
})
|
|
377
387
|
});
|
|
378
388
|
}
|
|
379
|
-
function RegionTrigger({
|
|
389
|
+
function RegionTrigger({ $content, $locale, className, children, ...props }) {
|
|
380
390
|
const { postalCode, city, loading, setOpen } = useRegion();
|
|
391
|
+
const { format } = useMessageFormatter(RegionTriggerContent, $content);
|
|
381
392
|
const isUnset = postalCode == null;
|
|
382
|
-
const resolvedUnsetLabel = $content?.unsetLabel?.trim() ? $content.unsetLabel : unsetLabel;
|
|
383
393
|
const authoredAriaLabel = $content?.ariaLabel?.trim() ? $content.ariaLabel : props["aria-label"];
|
|
384
394
|
/**
|
|
385
395
|
* WCAG 2.5.3 wants the accessible name to contain the visible label, so an authored label prefixes
|
|
@@ -390,8 +400,9 @@ function RegionTrigger({ unsetLabel = "Informe seu CEP", $content, className, ch
|
|
|
390
400
|
* the text itself, which already satisfies the rule.
|
|
391
401
|
*/
|
|
392
402
|
let visibleLabel = "";
|
|
393
|
-
if (!loading) visibleLabel = isUnset ?
|
|
394
|
-
|
|
403
|
+
if (!loading) visibleLabel = isUnset ? format("unsetLabel") : [city, postalCode].filter(Boolean).join(" ");
|
|
404
|
+
let ariaLabel = authoredAriaLabel && visibleLabel ? `${authoredAriaLabel}: ${visibleLabel}` : authoredAriaLabel;
|
|
405
|
+
if (loading && !ariaLabel) ariaLabel = format("unsetLabel");
|
|
395
406
|
return /* @__PURE__ */ jsxs("button", {
|
|
396
407
|
...props,
|
|
397
408
|
type: "button",
|
|
@@ -401,7 +412,7 @@ function RegionTrigger({ unsetLabel = "Informe seu CEP", $content, className, ch
|
|
|
401
412
|
className,
|
|
402
413
|
"data-fs-region-trigger": "",
|
|
403
414
|
...isUnset ? { "data-fs-region-trigger-unset": "" } : {},
|
|
404
|
-
children: [isUnset && !loading ?
|
|
415
|
+
children: [isUnset && !loading ? visibleLabel : null, children]
|
|
405
416
|
});
|
|
406
417
|
}
|
|
407
418
|
function RegionValue({ className, ...props }) {
|
|
@@ -496,11 +507,10 @@ function RegionPostalCodeControl({ className, mask, label, placeholder, errorMes
|
|
|
496
507
|
disabled: pending
|
|
497
508
|
});
|
|
498
509
|
}
|
|
499
|
-
function RegionSubmit({
|
|
510
|
+
function RegionSubmit({ $content, $locale, className, children, ...props }) {
|
|
500
511
|
const { draft, pending, submit } = useRegion();
|
|
501
512
|
const inForm = useContext(RegionFormContext);
|
|
502
|
-
const
|
|
503
|
-
const resolvedPendingLabel = $content?.pendingLabel?.trim() ? $content.pendingLabel : pendingLabel;
|
|
513
|
+
const { format } = useMessageFormatter(RegionSubmitContent, $content);
|
|
504
514
|
return /* @__PURE__ */ jsx("button", {
|
|
505
515
|
...props,
|
|
506
516
|
type: inForm ? "submit" : "button",
|
|
@@ -510,28 +520,25 @@ function RegionSubmit({ label = "Aplicar", pendingLabel = "Aplicando...", $conte
|
|
|
510
520
|
className,
|
|
511
521
|
"data-fs-region-submit": "",
|
|
512
522
|
...pending ? { "data-fs-region-submit-pending": "" } : {},
|
|
513
|
-
children: children ?? (pending ?
|
|
523
|
+
children: children ?? format(pending ? "pendingLabel" : "label")
|
|
514
524
|
});
|
|
515
525
|
}
|
|
516
526
|
/**
|
|
517
|
-
* The
|
|
518
|
-
*
|
|
519
|
-
*
|
|
527
|
+
* The message for each rejection the client can name: the server's `RegionErrorCode` values plus the
|
|
528
|
+
* client-minted transport failure. A code this map does not know (a newer server than this package)
|
|
529
|
+
* shows genericMessage.
|
|
520
530
|
*/
|
|
521
|
-
const
|
|
522
|
-
INVALID_POSTAL_CODE: "
|
|
523
|
-
UNSERVED_POSTAL_CODE: "
|
|
524
|
-
NETWORK_ERROR: "
|
|
531
|
+
const REGION_ERROR_FIELDS = {
|
|
532
|
+
INVALID_POSTAL_CODE: "invalidPostalCode",
|
|
533
|
+
UNSERVED_POSTAL_CODE: "unservedPostalCode",
|
|
534
|
+
NETWORK_ERROR: "genericMessage"
|
|
525
535
|
};
|
|
526
|
-
function RegionError({ $content, className, ...props }) {
|
|
536
|
+
function RegionError({ $content, $locale, className, ...props }) {
|
|
527
537
|
const { errors } = useRegion();
|
|
528
|
-
const
|
|
538
|
+
const { format } = useMessageFormatter(RegionErrorContent, $content);
|
|
529
539
|
if (errors.length === 0) return null;
|
|
530
|
-
const genericMessage = $content?.genericMessage?.trim() ? $content.genericMessage : null;
|
|
531
540
|
function copyFor(error) {
|
|
532
|
-
|
|
533
|
-
const id = error.code ? REGION_ERROR_MESSAGE_IDS[error.code] : void 0;
|
|
534
|
-
return id ? intl.formatMessage({ id }) : error.message;
|
|
541
|
+
return formatErrorCode(RegionErrorContent, REGION_ERROR_FIELDS, error, format, "genericMessage");
|
|
535
542
|
}
|
|
536
543
|
return /* @__PURE__ */ jsx("div", {
|
|
537
544
|
...props,
|
|
@@ -577,6 +584,6 @@ const Region = {
|
|
|
577
584
|
UnknownLink: RegionUnknownLink
|
|
578
585
|
};
|
|
579
586
|
//#endregion
|
|
580
|
-
export { Region, RegionContext, RegionError, RegionErrorContent, RegionErrorDefinition, RegionForm, RegionFormDefinition, RegionLoading, RegionLoadingDefinition, RegionModalController, RegionModalControllerDefinition, RegionPostalCodeControl, RegionPostalCodeControlDefinition, RegionRoot, RegionRootDefinition, RegionSubmit, RegionSubmitContent, RegionSubmitDefinition, RegionTrigger, RegionTriggerContent, RegionTriggerDefinition, RegionUnknownLink, RegionUnknownLinkContent, RegionUnknownLinkDefinition, RegionValue, RegionValueDefinition, useRegion };
|
|
587
|
+
export { REGION_ERROR_FIELDS, Region, RegionContext, RegionError, RegionErrorContent, RegionErrorDefinition, RegionForm, RegionFormDefinition, RegionLoading, RegionLoadingDefinition, RegionModalController, RegionModalControllerDefinition, RegionPostalCodeControl, RegionPostalCodeControlDefinition, RegionRoot, RegionRootDefinition, RegionSubmit, RegionSubmitContent, RegionSubmitDefinition, RegionTrigger, RegionTriggerContent, RegionTriggerDefinition, RegionUnknownLink, RegionUnknownLinkContent, RegionUnknownLinkDefinition, RegionValue, RegionValueDefinition, useRegion };
|
|
581
588
|
|
|
582
589
|
//# sourceMappingURL=region.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"region.js","names":[],"sources":["../../../src/matter/region/region.tsx"],"sourcesContent":["'use client';\n\nimport { type ContentValue, defineComponent, defineContentType } from '@vtex/fs-core';\nimport {\n type ComponentPropsWithRef,\n cloneElement,\n createContext,\n isValidElement,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { DialogRootProps } from '../../particles/dialog/dialog.js';\nimport { PostalCodeField } from '../../particles/postal-code-field/postal-code-field.js';\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 { ReactiveRootContext } from '../../sdk/data/page-reactive-data-root.js';\nimport { graphql } from '../../sdk/generated/gql.js';\nimport { type MessageId, useIntl } from '../../sdk/i18n/client.js';\nimport type { RegionEntity } from '../../sdk/region/operations.js';\nimport type { RegionUserError } from '../../sdk/region/region-operations.js';\nimport { resolveSafeHref } from '../../utils/safe-href.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment — typed via @graphql-codegen client-preset\n// ---------------------------------------------------------------------------\n\nconst fragment = graphql(`\n fragment RegionData on Query {\n region {\n ...RegionFragment\n }\n }\n`);\n\n// ---------------------------------------------------------------------------\n// Content models — one per copy-bearing part (Decision 7)\n// ---------------------------------------------------------------------------\n\nexport const RegionTriggerContent = defineContentType({\n id: 'region-trigger',\n title: 'Region Trigger',\n description: 'Copy for the control that opens the region modal.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n unsetLabel: { type: 'string', title: 'Label when no region is set' },\n ariaLabel: { type: 'string', title: 'Accessible label' },\n },\n },\n});\n\nexport const RegionSubmitContent = defineContentType({\n id: 'region-submit',\n title: 'Region Submit',\n description: 'Copy for the region submit control.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n label: { type: 'string', title: 'Button label' },\n pendingLabel: { type: 'string', title: 'Pending label' },\n },\n },\n});\n\nexport const RegionUnknownLinkContent = defineContentType({\n id: 'region-unknown-link',\n title: 'Region \"I don\\'t know my postal code\" Link',\n description: 'Copy and destination for the postal-code lookup link. Absent href omits the link.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n text: { type: 'string', minLength: 1, title: 'Link text' },\n href: {\n type: 'string',\n title: 'Destination',\n format: 'uri-reference',\n // The set `resolveSafeHref` admits, so the Admin form cannot reject a destination the render\n // gate would have kept. Author-time only and lookahead-free, as in the link-bearing particles.\n pattern: '^(?:https?://.*|mailto:.+|tel:.+|/(?:[^/].*)?)$',\n },\n },\n },\n});\n\nexport const RegionErrorContent = defineContentType({\n id: 'region-error',\n title: 'Region Error',\n description: 'Fallback message shown when a write fails without a server message.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n genericMessage: { type: 'string', title: 'Generic failure message' },\n },\n },\n});\n\n// ---------------------------------------------------------------------------\n// Region context\n// ---------------------------------------------------------------------------\n\nexport type RegionContextValue = Readonly<{\n /** Persisted postal code, formatted; null until a region is set. */\n postalCode: string | null;\n /** Persisted city; null when the contract does not resolve one. */\n city: string | null;\n /** The reactive read has not resolved and no cached value is available. */\n loading: boolean;\n /** The modal's draft value, masked as the shopper typed it. */\n draft: string;\n setDraft: (value: string) => void;\n /** A write is in flight. */\n pending: boolean;\n /** Errors from the latest write; empty when there are none. */\n errors: readonly RegionUserError[];\n open: boolean;\n setOpen: (open: boolean) => void;\n /** Dispatches setPostalCode with the current draft. No-op while pending. */\n submit: () => void;\n}>;\n\nconst REGION_CONTEXT_UNSET = Symbol('RegionContextUnset');\n\nconst RegionContextInternal = createContext<RegionContextValue | typeof REGION_CONTEXT_UNSET>(REGION_CONTEXT_UNSET);\n\nexport const RegionContext = RegionContextInternal as React.Context<RegionContextValue>;\n\n/**\n * Read the active region and the modal's write state from the nearest `RegionRoot`. Throws when\n * called outside a `RegionRoot` subtree, mirroring `useSession()` and `useCart()`: a misplaced part\n * is a composition bug the author should see immediately, not a silent degrade to \"no region\". The\n * compiler catches the same mistake earlier through `requiresContext: 'region'` (ADR-0009).\n */\nexport function useRegion(): RegionContextValue {\n const ctx = useContext(RegionContextInternal);\n if (ctx === REGION_CONTEXT_UNSET) {\n throw new Error('Region components must be used inside a <RegionRoot> subtree.');\n }\n return ctx;\n}\n\n/**\n * Whether a `RegionForm` encloses the subtree. `RegionSubmit` is independently placeable, so it\n * cannot assume a form owner: with one it is a real submit button, which is what makes Enter in the\n * field submit; without one a `type=\"submit\"` button would have nothing to submit and its click\n * would do nothing. Reading this keeps the form composable rather than load-bearing.\n */\nconst RegionFormContext = createContext(false);\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type RegionRootProps = ComponentPropsWithRef<'div'> & {\n /**\n * Region entity slice forwarded by the reactive runtime (`ReactiveDataProvider`) — the value of the\n * `region` top-level field on `RegionData on Query`, not the wrapping `{ region: … }` shape.\n * Receives `null` while the entity has not resolved and when no region is set.\n */\n $data?: RegionEntity | null;\n /** Injected by the compiler from `actions: { region: ['setPostalCode'] }`; the region write surface. */\n $actions?: ComponentActions;\n children?: ReactNode;\n};\n\nexport type RegionTriggerProps = ComponentPropsWithRef<'button'> & {\n /** Shown when no region is set. */\n unsetLabel?: string;\n /** Merchant-authored copy; wins over the props when present. */\n $content?: ContentValue<typeof RegionTriggerContent>;\n};\n\n/** Children are omitted: what this renders is the resolved region, never authored content. */\nexport type RegionValueProps = Omit<ComponentPropsWithRef<'span'>, 'children'>;\n\nexport type RegionLoadingProps = ComponentPropsWithRef<'div'>;\n\nexport type RegionModalControllerProps = {\n children?: ReactNode;\n};\n\nexport type RegionFormProps = ComponentPropsWithRef<'form'>;\n\nexport type RegionPostalCodeControlProps = {\n className?: string;\n /** Mask template forwarded to `PostalCodeField`; defaults to that particle's BR CEP mask. */\n mask?: string;\n label?: string;\n placeholder?: string;\n /** The field's own incomplete-value message. Server rejections surface through `RegionError`. */\n errorMessage?: string;\n};\n\nexport type RegionSubmitProps = ComponentPropsWithRef<'button'> & {\n label?: string;\n pendingLabel?: string;\n /** Merchant-authored copy; wins over the props when present. */\n $content?: ContentValue<typeof RegionSubmitContent>;\n};\n\n/** Children are omitted: what this renders is the write's own error, never authored content. */\nexport type RegionErrorProps = Omit<ComponentPropsWithRef<'div'>, 'children'> & {\n /** Merchant-authored fallback copy; wins over the prop when present. */\n $content?: ContentValue<typeof RegionErrorContent>;\n};\n\nexport type RegionUnknownLinkProps = ComponentPropsWithRef<'a'> & {\n /** Merchant-authored text and destination; each wins over its prop when present. */\n $content?: ContentValue<typeof RegionUnknownLinkContent>;\n};\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const RegionRootDefinition = defineComponent<RegionRootProps>({\n name: 'RegionRoot',\n importPath: '@vtex/faststore/components',\n component: RegionRoot,\n fragment,\n fetchStrategy: 'reactive',\n providesContext: 'region',\n actions: { region: ['setPostalCode'] },\n editor: { label: 'Region Root', category: 'content' },\n schema: {},\n guideline:\n 'Provides region context and reads the active postal code and city reactively. Place it in the shared header layout and compose RegionTrigger, RegionValue, RegionLoading, and a RegionModalController inside it. Every Region* component must be a descendant. See region.md.',\n});\n\nexport const RegionTriggerDefinition = defineComponent<RegionTriggerProps>({\n name: 'RegionTrigger',\n importPath: '@vtex/faststore/components',\n component: RegionTrigger,\n content: RegionTriggerContent,\n requiresContext: 'region',\n editor: { label: 'Region Trigger', category: 'action' },\n schema: {\n unsetLabel: { type: 'string', default: 'Informe seu CEP', label: 'Label when no region is set' },\n },\n guideline:\n 'Opens the region modal. Shows its unset label while no region is set; compose RegionValue as its child so the active region reads inside the control once one is. Its accessible name carries the active region, so a screen reader announces where the shopper is shopping. Must be inside RegionRoot.',\n});\n\nexport const RegionValueDefinition = defineComponent<RegionValueProps>({\n name: 'RegionValue',\n importPath: '@vtex/faststore/components',\n component: RegionValue,\n requiresContext: 'region',\n editor: { label: 'Region Value', category: 'content' },\n schema: {},\n guideline:\n 'The active region, as city plus postal code. Renders nothing while the region is unresolved or unset, so it needs no visibility prop — place it inside RegionTrigger, or anywhere in the header that should echo the region. The city is wrapped in its own element (data-fs-region-value-city) so a store can style or hide it; when the contract resolves no city, the postal code renders alone with no separator. A plain space separates the two in the text, so the accessible name reads \"São Paulo 01310-100\"; a flex container strips it, so a gap swatch still sets the visible spacing. Must be inside RegionRoot.',\n});\n\nexport const RegionLoadingDefinition = defineComponent<RegionLoadingProps>({\n name: 'RegionLoading',\n importPath: '@vtex/faststore/components',\n component: RegionLoading,\n requiresContext: 'region',\n editor: { label: 'Region Loading', category: 'content' },\n schema: {},\n guideline:\n 'Renders its children only while the region read has not resolved. Supply a skeleton placeholder as its child, sized like the resolved display so the header does not reflow when the region arrives. RegionValue renders nothing while this branch is showing, so the two never double up. Must be inside RegionRoot.',\n});\n\nexport const RegionModalControllerDefinition = defineComponent<RegionModalControllerProps>({\n name: 'RegionModalController',\n importPath: '@vtex/faststore/components',\n component: RegionModalController,\n requiresContext: 'region',\n editor: { label: 'Region Modal Controller', category: 'action' },\n schema: {},\n guideline:\n 'Wraps a single DialogRoot child (the region modal) and makes it controlled by the region state: RegionTrigger opens it, Escape and the backdrop close it, and a successful write closes it. Do not set raw open/onOpenChange on the wrapped DialogRoot. Compose DialogPortal, DialogBackdrop, DialogViewport and DialogPopup inside it, with DialogTitle and DialogDescription naming the dialog, and place a RegionForm holding RegionPostalCodeControl and RegionSubmit in the popup, alongside RegionError and RegionUnknownLink. Same pattern as CartOpenOnAdd wrapping the mini-cart DrawerRoot. Must be inside RegionRoot.',\n});\n\nexport const RegionFormDefinition = defineComponent<RegionFormProps>({\n name: 'RegionForm',\n importPath: '@vtex/faststore/components',\n component: RegionForm,\n requiresContext: 'region',\n editor: { label: 'Region Form', category: 'action' },\n schema: {},\n guideline:\n 'Form wrapper holding RegionPostalCodeControl and RegionSubmit inside the region modal, so pressing Enter in the field submits. Same role as ShippingSimulatorForm. Compose it whenever both parts sit together; without it the shopper must reach the button, which still works but is not what a one-field form leads them to expect. Must be inside a RegionModalController dialog.',\n});\n\nexport const RegionPostalCodeControlDefinition = defineComponent<RegionPostalCodeControlProps>({\n name: 'RegionPostalCodeControl',\n importPath: '@vtex/faststore/components',\n component: RegionPostalCodeControl,\n requiresContext: 'region',\n editor: { label: 'Region Postal Code Control', category: 'content' },\n schema: {\n mask: { type: 'string', default: '99999-999', label: 'Mask pattern' },\n label: { type: 'string', label: 'Label' },\n placeholder: { type: 'string', label: 'Placeholder' },\n errorMessage: { type: 'string', label: 'Incomplete-value message' },\n },\n guideline:\n 'The postal-code input inside the region modal: a PostalCodeField bound to the region draft, seeded from the persisted value every time the modal opens. Set mask to the country format at build time (default 99999-999, BR CEP). Server rejections mark the field invalid and take focus back to it; their message is shown by RegionError, not repeated here, and the first keystroke after one clears it. Must be inside a RegionModalController dialog.',\n});\n\nexport const RegionSubmitDefinition = defineComponent<RegionSubmitProps>({\n name: 'RegionSubmit',\n importPath: '@vtex/faststore/components',\n component: RegionSubmit,\n content: RegionSubmitContent,\n requiresContext: 'region',\n editor: { label: 'Region Submit', category: 'action' },\n schema: {\n label: { type: 'string', default: 'Aplicar', label: 'Button label' },\n pendingLabel: { type: 'string', default: 'Aplicando...', label: 'Pending label' },\n },\n guideline:\n \"Submits the region draft. Inside a RegionForm it is the form's submit button, which is what makes Enter in the field work; on its own it dispatches directly. Inert while empty and while a write is in flight, so a double activation dispatches one mutation; the pending state is exposed as aria-busy with no built-in spinner. On success the modal closes; on a rejection it stays open and RegionError explains why. Must be inside a RegionModalController dialog.\",\n});\n\nexport const RegionErrorDefinition = defineComponent<RegionErrorProps>({\n name: 'RegionError',\n importPath: '@vtex/faststore/components',\n component: RegionError,\n content: RegionErrorContent,\n requiresContext: 'region',\n editor: { label: 'Region Error', category: 'content' },\n schema: {},\n guideline:\n \"Shows why the latest region write was refused, announced as an alert when it appears. Renders nothing when there is no error, so it needs no visibility prop. The server's own message is shown verbatim; the authored generic message covers a transport failure, where there is no server message to show. Must be inside a RegionModalController dialog.\",\n});\n\nexport const RegionUnknownLinkDefinition = defineComponent<RegionUnknownLinkProps>({\n name: 'RegionUnknownLink',\n importPath: '@vtex/faststore/components',\n component: RegionUnknownLink,\n content: RegionUnknownLinkContent,\n requiresContext: 'region',\n editor: { label: 'Region Unknown Postal Code Link', category: 'navigation' },\n schema: {\n href: { type: 'string', label: 'Lookup service URL' },\n target: { type: ['_self', '_blank'] as const, default: '_self', label: 'Open in' },\n },\n guideline:\n 'The \"I don\\'t know my postal code\" escape hatch, pointing at a postal-code lookup service. Renders nothing until a destination is set, so a store without a lookup service composes it and simply gets no link rather than a dead one. Its text comes from authored content or its children. Must be inside a RegionModalController dialog.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\n/**\n * Reads the active region reactively and publishes it, the modal's draft, and the write state as\n * `region` context.\n *\n * The resolved value is never copied into state: `RegionValue` renders only what the fragment\n * resolves, and a successful write updates the display solely by the mutation payload normalizing\n * into the Apollo cache (Decision 5). That is why a rejected write needs no rollback and cannot\n * leave the header showing a postal code the server refused.\n */\nexport function RegionRoot({\n $data: $dataProp,\n $actions: $actionsProp,\n className,\n children,\n ...props\n}: RegionRootProps) {\n const $data = useDataOverride($dataProp);\n const $actions = useActionsOverride($actionsProp);\n const region = $data ?? null;\n const { loading: rootLoading } = useContext(ReactiveRootContext);\n // A null region is ambiguous on its own — an unresolved read and a shopper who never set one look\n // the same — so the root query's in-flight flag is what separates \"loading\" from \"unset\". Without\n // it a first-time shopper would sit under a skeleton forever instead of seeing the unset prompt.\n const loading = rootLoading && region == null;\n\n const postalCode = region?.postalCode ?? null;\n\n const [open, setOpenState] = useState(false);\n const [draft, setDraftState] = useState('');\n const [pending, setPending] = useState(false);\n const [errors, setErrors] = useState<readonly RegionUserError[]>([]);\n // State is batched, so two activations in one tick would both pass a `pending` check. The ref is\n // what makes \"exactly one mutation per activation\" hold.\n const inFlightRef = useRef(false);\n\n /**\n * Seeds the draft from the persisted value on open and clears it on close (Decision 6), so a\n * reopened modal always shows the truth rather than an abandoned edit.\n */\n const setOpen = useCallback(\n (next: boolean) => {\n setOpenState(next);\n setDraftState(next ? (postalCode ?? '') : '');\n setErrors([]);\n },\n [postalCode],\n );\n\n /**\n * Editing is the shopper's answer to a rejection, so the message and the invalid flag go with the\n * first keystroke. Left standing, they describe a value that is no longer in the field — and\n * `RegionPostalCodeControl`, which withholds its own incomplete-value copy while a rejection\n * stands, would stay silent for the whole edit. Returns the same array when there is nothing to\n * clear, so ordinary typing does not re-render the error subtree.\n */\n const setDraft = useCallback((value: string) => {\n setDraftState(value);\n setErrors((current) => (current.length === 0 ? current : []));\n }, []);\n\n const submit = useCallback(() => {\n if (inFlightRef.current) return;\n const setPostalCode = $actions?.region?.setPostalCode;\n if (!setPostalCode) return;\n\n inFlightRef.current = true;\n setPending(true);\n setErrors([]);\n\n void setPostalCode(draft)\n .then((writeErrors) => {\n if (writeErrors.length > 0) {\n // A rejection keeps the modal open so the message has somewhere to show (US-3).\n setErrors(writeErrors);\n return;\n }\n setOpenState(false);\n setDraftState('');\n })\n .finally(() => {\n inFlightRef.current = false;\n setPending(false);\n });\n }, [$actions, draft]);\n\n const value: RegionContextValue = useMemo(\n () => ({\n postalCode,\n city: region?.city ?? null,\n loading,\n draft,\n setDraft,\n pending,\n errors,\n open,\n setOpen,\n submit,\n }),\n [postalCode, region?.city, loading, draft, setDraft, pending, errors, open, setOpen, submit],\n );\n\n return (\n <RegionContextInternal value={value}>\n <div {...props} className={className} data-fs-region-root=\"\">\n {children}\n </div>\n </RegionContextInternal>\n );\n}\n\nexport function RegionTrigger({\n unsetLabel = 'Informe seu CEP',\n $content,\n className,\n children,\n ...props\n}: RegionTriggerProps) {\n const { postalCode, city, loading, setOpen } = useRegion();\n const isUnset = postalCode == null;\n\n const resolvedUnsetLabel = $content?.unsetLabel?.trim() ? $content.unsetLabel : unsetLabel;\n const authoredAriaLabel = $content?.ariaLabel?.trim() ? $content.ariaLabel : props['aria-label'];\n\n /**\n * WCAG 2.5.3 wants the accessible name to contain the visible label, so an authored label prefixes\n * the text on screen rather than replacing it: a name of \"Alterar região\" over text reading\n * \"Informe seu CEP\" leaves a voice-control user nothing to say. The region is spaced the way\n * `RegionValue` spaces it, since the name has to carry that text verbatim. Empty while the region\n * is unresolved, when the button reads nothing, and with no authored label the name falls back to\n * the text itself, which already satisfies the rule.\n */\n let visibleLabel = '';\n if (!loading) {\n visibleLabel = isUnset ? resolvedUnsetLabel : [city, postalCode].filter(Boolean).join(' ');\n }\n\n const ariaLabel = authoredAriaLabel && visibleLabel ? `${authoredAriaLabel}: ${visibleLabel}` : authoredAriaLabel;\n\n return (\n <button\n {...props}\n type=\"button\"\n onClick={() => setOpen(true)}\n // Not yet interactive while the region is unresolved: activating it would seed the draft from a\n // value that has not arrived.\n disabled={loading || props.disabled}\n aria-label={ariaLabel}\n className={className}\n data-fs-region-trigger=\"\"\n {...(isUnset ? { 'data-fs-region-trigger-unset': '' } : {})}\n >\n {isUnset && !loading ? resolvedUnsetLabel : null}\n {children}\n </button>\n );\n}\n\nexport function RegionValue({ className, ...props }: RegionValueProps) {\n const { postalCode, city, loading } = useRegion();\n if (loading || postalCode == null) return null;\n\n return (\n <span {...props} className={className} data-fs-region-value=\"\">\n {city ? <span data-fs-region-value-city=\"\">{city}</span> : null}\n {/* A real text node, not a styling concern: it is what separates the two values in the\n accessible name — this is the trigger's name whenever no aria-label is authored — and in any\n non-flex placement. It must stay a plain space: a flex container strips it as leading\n whitespace, so a store's `gap` still governs the visible spacing, where an would\n survive and widen the row. Absent with no city, so the postal code never renders padded. */}\n {city ? ' ' : null}\n {postalCode}\n </span>\n );\n}\n\nexport function RegionLoading({ className, children, ...props }: RegionLoadingProps) {\n const { loading } = useRegion();\n if (!loading) return null;\n\n return (\n <div {...props} className={className} data-fs-region-loading=\"\">\n {children}\n </div>\n );\n}\n\n/**\n * Makes the wrapped `DialogRoot` controlled by the region state. Mirrors\n * `ShippingAddressSavedAddressDrawerController`'s `cloneElement` mechanism; expects a single\n * `DialogRoot` child. Dismissal is never blocked — the Phase 1 modal is always dismissible.\n */\nexport function RegionModalController({ children }: RegionModalControllerProps) {\n const { open, setOpen } = useRegion();\n\n if (!isValidElement<Pick<DialogRootProps, 'open' | 'onOpenChange'>>(children)) {\n return children;\n }\n\n return cloneElement(children, {\n open,\n onOpenChange: (next: boolean) => setOpen(next),\n });\n}\n\n/**\n * Gives the field and the submit a form owner, so Enter in the postal code submits the way it does\n * in every other short form in the repo. Mirrors `ShippingSimulatorForm`: the form's only job is to\n * route native submission to the context's `submit()`.\n */\nexport function RegionForm({ className, children, ...props }: RegionFormProps) {\n const { submit } = useRegion();\n\n return (\n <RegionFormContext value={true}>\n <form\n {...props}\n className={className}\n data-fs-region-form=\"\"\n onSubmit={(event) => {\n event.preventDefault();\n submit();\n }}\n >\n {children}\n </form>\n </RegionFormContext>\n );\n}\n\nexport function RegionPostalCodeControl({\n className,\n mask,\n label,\n placeholder,\n errorMessage,\n}: RegionPostalCodeControlProps) {\n const { draft, setDraft, errors, pending } = useRegion();\n const rootRef = useRef<HTMLDivElement>(null);\n const refused = errors.length > 0;\n\n /**\n * A refusal has to leave the shopper on the value they need to correct. Disabling the input while\n * the write is in flight blurs it and the browser drops focus to the document body, so a rejection\n * otherwise lands with nothing focused inside an open dialog — Enter does nothing and Tab restarts\n * from the top. Waits for `pending` to clear, because focusing a still-disabled input is a no-op:\n * the errors and the pending flag settle in separate microtasks, so there is a render in between\n * where the rejection is known and the field is not yet editable. The field is reached through the\n * root via a scoped querySelector, not a ref threaded down through props.\n */\n useEffect(() => {\n if (!refused || pending) return;\n rootRef.current?.querySelector<HTMLInputElement>('[data-fs-postal-code-field-input]')?.focus();\n }, [refused, pending]);\n\n return (\n <PostalCodeField\n ref={rootRef}\n className={className}\n data-fs-region-postal-code-control=\"\"\n mask={mask}\n label={label}\n placeholder={placeholder}\n // The field renders this whenever it is invalid, from either source, so it is withheld while a\n // server rejection stands: that message is RegionError's, and the field's own copy describes an\n // incomplete value — wrong for a complete code the server refused, and contradictory stacked\n // under the real reason.\n errorMessage={errors.length > 0 ? undefined : errorMessage}\n value={draft}\n onValueChange={setDraft}\n // Still flagged invalid, so the refused value carries aria-invalid and the invalid styling.\n invalid={errors.length > 0}\n disabled={pending}\n />\n );\n}\n\nexport function RegionSubmit({\n label = 'Aplicar',\n pendingLabel = 'Aplicando...',\n $content,\n className,\n children,\n ...props\n}: RegionSubmitProps) {\n const { draft, pending, submit } = useRegion();\n const inForm = useContext(RegionFormContext);\n\n const resolvedLabel = $content?.label?.trim() ? $content.label : label;\n const resolvedPendingLabel = $content?.pendingLabel?.trim() ? $content.pendingLabel : pendingLabel;\n\n return (\n <button\n {...props}\n // The form routes native submission to the same submit(); alone there is no form to submit.\n type={inForm ? 'submit' : 'button'}\n onClick={inForm ? props.onClick : submit}\n disabled={pending || draft.trim() === '' || props.disabled}\n aria-busy={pending || undefined}\n className={className}\n data-fs-region-submit=\"\"\n {...(pending ? { 'data-fs-region-submit-pending': '' } : {})}\n >\n {children ?? (pending ? resolvedPendingLabel : resolvedLabel)}\n </button>\n );\n}\n\n/**\n * The catalog copy for each rejection the client can name: the server's `RegionErrorCode` values plus\n * the client-minted transport failure. The server's own `message` is English, so it is shown only for\n * a code this map does not know — a newer server than this package.\n */\nconst REGION_ERROR_MESSAGE_IDS: Readonly<Record<string, MessageId>> = {\n INVALID_POSTAL_CODE: 'fs/region.error.invalid-postal-code',\n UNSERVED_POSTAL_CODE: 'fs/region.error.unserved-postal-code',\n NETWORK_ERROR: 'fs/region.error.network',\n};\n\nexport function RegionError({ $content, className, ...props }: RegionErrorProps) {\n const { errors } = useRegion();\n const intl = useIntl();\n if (errors.length === 0) return null;\n\n const genericMessage = $content?.genericMessage?.trim() ? $content.genericMessage : null;\n\n function copyFor(error: RegionUserError): string {\n // A transport failure carries no server message worth showing a shopper, so the authored\n // generic copy wins there and only there. Every other code the catalog knows renders in the\n // store's language; a code it does not know falls back to the server's own message.\n if (error.code === 'NETWORK_ERROR' && genericMessage) return genericMessage;\n const id = error.code ? REGION_ERROR_MESSAGE_IDS[error.code] : undefined;\n return id ? intl.formatMessage({ id }) : error.message;\n }\n\n return (\n <div {...props} role=\"alert\" className={className} data-fs-region-error=\"\">\n {errors.map((error) => (\n <div key={`${error.code ?? ''}${error.message}`}>{copyFor(error)}</div>\n ))}\n </div>\n );\n}\n\nexport function RegionUnknownLink({ $content, className, children, href, rel, ...props }: RegionUnknownLinkProps) {\n // Called for its guard alone: a part placed outside a RegionRoot must fail here the way its\n // siblings do, even though this one reads nothing from the context.\n useRegion();\n\n const authoredHref = $content?.href?.trim() ? $content.href : href?.trim();\n // Absent is \"no link\", the ordinary shape for a store with no lookup service, so it never reaches\n // the allowlist or the log.\n if (!authoredHref) return null;\n\n // No read-time validator enforces the model's `format` or `pattern`, so this is the only gate on\n // the CMS value.\n const destination = resolveSafeHref(authoredHref);\n if (!destination.safe) {\n // A bounded reason and no authored value, the convention the content runtime's own log follows.\n console.warn('[RegionUnknownLink] link destination rejected', { reason: destination.reason });\n return null;\n }\n\n const text = $content?.text?.trim() ? $content.text : children;\n if (!text) return null;\n\n // A lookup service is a natural new-tab destination, so a store may pass target. The tab-nabbing\n // defense is then this component's responsibility, not the composer's — the same contract\n // NavigationLink states. Target keywords and link types are both ASCII case-insensitive per HTML,\n // so _BLANK opens a new tab and a caller-passed NOOPENER already counts.\n const relTokens = rel?.split(/\\s+/).filter(Boolean) ?? [];\n const present = new Set(relTokens.map((token) => token.toLowerCase()));\n const safeRel =\n props.target?.toLowerCase() === '_blank'\n ? [...relTokens, ...['noopener', 'noreferrer'].filter((token) => !present.has(token))].join(' ')\n : rel;\n\n return (\n <a {...props} href={destination.href} rel={safeRel} className={className} data-fs-region-unknown-link=\"\">\n {text}\n </a>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace export\n// ---------------------------------------------------------------------------\n\nexport const Region = {\n Root: RegionRoot,\n Trigger: RegionTrigger,\n Value: RegionValue,\n Loading: RegionLoading,\n ModalController: RegionModalController,\n Form: RegionForm,\n PostalCodeControl: RegionPostalCodeControl,\n Submit: RegionSubmit,\n Error: RegionError,\n UnknownLink: RegionUnknownLink,\n};\n"],"mappings":";;;;;;;;;;;;;;AAgCA,MAAM,WAAW,QAAQ;;;;;;CAMxB;AAMD,MAAa,uBAAuB,kBAAkB;CACpD,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,YAAY;GACV,YAAY;IAAE,MAAM;IAAU,OAAO;GAA8B;GACnE,WAAW;IAAE,MAAM;IAAU,OAAO;GAAmB;EACzD;CACF;AACF,CAAC;AAED,MAAa,sBAAsB,kBAAkB;CACnD,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,YAAY;GACV,OAAO;IA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AAC,KAAK,GAAG,IAC7F;CAEN,OACE,oBAAC,KAAD;EAAG,GAAI;EAAO,MAAM,YAAY;EAAM,KAAK;EAAoB;EAAW,+BAA4B;EACnG,UAAA;CACA,CAAA;AAEP;AAMA,MAAa,SAAS;CACpB,MAAM;CACN,SAAS;CACT,OAAO;CACP,SAAS;CACT,iBAAiB;CACjB,MAAM;CACN,mBAAmB;CACnB,QAAQ;CACR,OAAO;CACP,aAAa;AACf"}
|
|
1
|
+
{"version":3,"file":"region.js","names":[],"sources":["../../../src/matter/region/region.tsx"],"sourcesContent":["'use client';\n\nimport {\n type ContentValue,\n defineComponent,\n defineContentType,\n type MessageFieldName,\n type MessageLocaleProp,\n} from '@vtex/fs-core';\nimport {\n type ComponentPropsWithRef,\n cloneElement,\n createContext,\n isValidElement,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { DialogRootProps } from '../../particles/dialog/dialog.js';\nimport { PostalCodeField } from '../../particles/postal-code-field/postal-code-field.js';\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 { ReactiveRootContext } from '../../sdk/data/page-reactive-data-root.js';\nimport { graphql } from '../../sdk/generated/gql.js';\nimport { formatErrorCode } from '../../sdk/i18n/format-error-code.js';\nimport { useMessageFormatter } from '../../sdk/i18n/use-message-formatter.js';\nimport type { RegionEntity } from '../../sdk/region/operations.js';\nimport type { RegionUserError } from '../../sdk/region/region-operations.js';\nimport { resolveSafeHref } from '../../utils/safe-href.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment — typed via @graphql-codegen client-preset\n// ---------------------------------------------------------------------------\n\nconst fragment = graphql(`\n fragment RegionData on Query {\n region {\n ...RegionFragment\n }\n }\n`);\n\n// ---------------------------------------------------------------------------\n// Content models — one per copy-bearing part (Decision 7)\n// ---------------------------------------------------------------------------\n\nexport const RegionTriggerContent = defineContentType({\n id: 'region-trigger',\n title: 'Region Trigger',\n description: 'Copy for the control that opens the region modal.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n unsetLabel: {\n type: 'string',\n title: 'Label when no region is set',\n format: 'icu-message',\n messageSource: 'Enter your postal code',\n },\n ariaLabel: { type: 'string', title: 'Accessible label' },\n },\n },\n});\n\nexport const RegionSubmitContent = defineContentType({\n id: 'region-submit',\n title: 'Region Submit',\n description: 'Copy for the region submit control.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n label: { type: 'string', title: 'Button label', format: 'icu-message', messageSource: 'Apply' },\n pendingLabel: { type: 'string', title: 'Pending label', format: 'icu-message', messageSource: 'Applying...' },\n },\n },\n});\n\nexport const RegionUnknownLinkContent = defineContentType({\n id: 'region-unknown-link',\n title: 'Region \"I don\\'t know my postal code\" Link',\n description: 'Copy and destination for the postal-code lookup link. Absent href omits the link.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n text: { type: 'string', minLength: 1, title: 'Link text' },\n href: {\n type: 'string',\n title: 'Destination',\n format: 'uri-reference',\n // The set `resolveSafeHref` admits, so the Admin form cannot reject a destination the render\n // gate would have kept. Author-time only and lookahead-free, as in the link-bearing particles.\n pattern: '^(?:https?://.*|mailto:.+|tel:.+|/(?:[^/].*)?)$',\n },\n },\n },\n});\n\nexport const RegionErrorContent = defineContentType({\n id: 'region-error',\n title: 'Region Error',\n description: 'Messages shown when a write fails: a network failure, an invalid postal code, an unserved one.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n genericMessage: {\n type: 'string',\n title: 'Generic failure message',\n format: 'icu-message',\n messageSource: 'Unable to set your region. Please try again.',\n },\n invalidPostalCode: {\n type: 'string',\n title: 'Invalid postal code',\n description: 'Shown when the server rejects the postal code as invalid.',\n format: 'icu-message',\n messageSource: 'Enter a valid postal code.',\n },\n unservedPostalCode: {\n type: 'string',\n title: 'Unserved postal code',\n description: 'Shown when the server serves no region for the postal code.',\n format: 'icu-message',\n messageSource: 'We do not deliver to this postal code yet.',\n },\n },\n },\n});\n\n// ---------------------------------------------------------------------------\n// Region context\n// ---------------------------------------------------------------------------\n\nexport type RegionContextValue = Readonly<{\n /** Persisted postal code, formatted; null until a region is set. */\n postalCode: string | null;\n /** Persisted city; null when the contract does not resolve one. */\n city: string | null;\n /** The reactive read has not resolved and no cached value is available. */\n loading: boolean;\n /** The modal's draft value, masked as the shopper typed it. */\n draft: string;\n setDraft: (value: string) => void;\n /** A write is in flight. */\n pending: boolean;\n /** Errors from the latest write; empty when there are none. */\n errors: readonly RegionUserError[];\n open: boolean;\n setOpen: (open: boolean) => void;\n /** Dispatches setPostalCode with the current draft. No-op while pending. */\n submit: () => void;\n}>;\n\nconst REGION_CONTEXT_UNSET = Symbol('RegionContextUnset');\n\nconst RegionContextInternal = createContext<RegionContextValue | typeof REGION_CONTEXT_UNSET>(REGION_CONTEXT_UNSET);\n\nexport const RegionContext = RegionContextInternal as React.Context<RegionContextValue>;\n\n/**\n * Read the active region and the modal's write state from the nearest `RegionRoot`. Throws when\n * called outside a `RegionRoot` subtree, mirroring `useSession()` and `useCart()`: a misplaced part\n * is a composition bug the author should see immediately, not a silent degrade to \"no region\". The\n * compiler catches the same mistake earlier through `requiresContext: 'region'` (ADR-0009).\n */\nexport function useRegion(): RegionContextValue {\n const ctx = useContext(RegionContextInternal);\n if (ctx === REGION_CONTEXT_UNSET) {\n throw new Error('Region components must be used inside a <RegionRoot> subtree.');\n }\n return ctx;\n}\n\n/**\n * Whether a `RegionForm` encloses the subtree. `RegionSubmit` is independently placeable, so it\n * cannot assume a form owner: with one it is a real submit button, which is what makes Enter in the\n * field submit; without one a `type=\"submit\"` button would have nothing to submit and its click\n * would do nothing. Reading this keeps the form composable rather than load-bearing.\n */\nconst RegionFormContext = createContext(false);\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type RegionRootProps = ComponentPropsWithRef<'div'> & {\n /**\n * Region entity slice forwarded by the reactive runtime (`ReactiveDataProvider`) — the value of the\n * `region` top-level field on `RegionData on Query`, not the wrapping `{ region: … }` shape.\n * Receives `null` while the entity has not resolved and when no region is set.\n */\n $data?: RegionEntity | null;\n /** Injected by the compiler from `actions: { region: ['setPostalCode'] }`; the region write surface. */\n $actions?: ComponentActions;\n children?: ReactNode;\n};\n\nexport type RegionTriggerProps = ComponentPropsWithRef<'button'> &\n MessageLocaleProp & {\n /** Merchant-authored copy: the unset label and the accessible label. */\n $content?: ContentValue<typeof RegionTriggerContent>;\n };\n\n/** Children are omitted: what this renders is the resolved region, never authored content. */\nexport type RegionValueProps = Omit<ComponentPropsWithRef<'span'>, 'children'>;\n\nexport type RegionLoadingProps = ComponentPropsWithRef<'div'>;\n\nexport type RegionModalControllerProps = {\n children?: ReactNode;\n};\n\nexport type RegionFormProps = ComponentPropsWithRef<'form'>;\n\nexport type RegionPostalCodeControlProps = {\n className?: string;\n /** Mask template forwarded to `PostalCodeField`; defaults to that particle's BR CEP mask. */\n mask?: string;\n label?: string;\n placeholder?: string;\n /** The field's own incomplete-value message. Server rejections surface through `RegionError`. */\n errorMessage?: string;\n};\n\nexport type RegionSubmitProps = ComponentPropsWithRef<'button'> &\n MessageLocaleProp & {\n /** The idle and pending labels; authored `children` replace both. */\n $content?: ContentValue<typeof RegionSubmitContent>;\n };\n\n/** Children are omitted: what this renders is the write's own error, worded by `$content`. */\nexport type RegionErrorProps = Omit<ComponentPropsWithRef<'div'>, 'children'> &\n MessageLocaleProp & {\n $content?: ContentValue<typeof RegionErrorContent>;\n };\n\nexport type RegionUnknownLinkProps = ComponentPropsWithRef<'a'> & {\n /** Merchant-authored text and destination; each wins over its prop when present. */\n $content?: ContentValue<typeof RegionUnknownLinkContent>;\n};\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const RegionRootDefinition = defineComponent<RegionRootProps>({\n name: 'RegionRoot',\n importPath: '@vtex/faststore/components',\n component: RegionRoot,\n fragment,\n fetchStrategy: 'reactive',\n providesContext: 'region',\n actions: { region: ['setPostalCode'] },\n editor: { label: 'Region Root', category: 'content' },\n schema: {},\n guideline:\n 'Provides region context and reads the active postal code and city reactively. Place it in the shared header layout and compose RegionTrigger, RegionValue, RegionLoading, and a RegionModalController inside it. Every Region* component must be a descendant. See region.md.',\n});\n\nexport const RegionTriggerDefinition = defineComponent<RegionTriggerProps>({\n name: 'RegionTrigger',\n importPath: '@vtex/faststore/components',\n component: RegionTrigger,\n content: RegionTriggerContent,\n requiresContext: 'region',\n editor: { label: 'Region Trigger', category: 'action' },\n schema: {},\n guideline:\n 'Opens the region modal. Shows its unset label ($content field unsetLabel) while no region is set; compose RegionValue as its child so the active region reads inside the control once one is. Its accessible name carries the active region, so a screen reader announces where the shopper is shopping. Must be inside RegionRoot.',\n});\n\nexport const RegionValueDefinition = defineComponent<RegionValueProps>({\n name: 'RegionValue',\n importPath: '@vtex/faststore/components',\n component: RegionValue,\n requiresContext: 'region',\n editor: { label: 'Region Value', category: 'content' },\n schema: {},\n guideline:\n 'The active region, as city plus postal code. Renders nothing while the region is unresolved or unset, so it needs no visibility prop — place it inside RegionTrigger, or anywhere in the header that should echo the region. The city is wrapped in its own element (data-fs-region-value-city) so a store can style or hide it; when the contract resolves no city, the postal code renders alone with no separator. A plain space separates the two in the text, so the accessible name reads \"São Paulo 01310-100\"; a flex container strips it, so a gap swatch still sets the visible spacing. Must be inside RegionRoot.',\n});\n\nexport const RegionLoadingDefinition = defineComponent<RegionLoadingProps>({\n name: 'RegionLoading',\n importPath: '@vtex/faststore/components',\n component: RegionLoading,\n requiresContext: 'region',\n editor: { label: 'Region Loading', category: 'content' },\n schema: {},\n guideline:\n 'Renders its children only while the region read has not resolved. Supply a skeleton placeholder as its child, sized like the resolved display so the header does not reflow when the region arrives. RegionValue renders nothing while this branch is showing, so the two never double up. Must be inside RegionRoot.',\n});\n\nexport const RegionModalControllerDefinition = defineComponent<RegionModalControllerProps>({\n name: 'RegionModalController',\n importPath: '@vtex/faststore/components',\n component: RegionModalController,\n requiresContext: 'region',\n editor: { label: 'Region Modal Controller', category: 'action' },\n schema: {},\n guideline:\n 'Wraps a single DialogRoot child (the region modal) and makes it controlled by the region state: RegionTrigger opens it, Escape and the backdrop close it, and a successful write closes it. Do not set raw open/onOpenChange on the wrapped DialogRoot. Compose DialogPortal, DialogBackdrop, DialogViewport and DialogPopup inside it, with DialogTitle and DialogDescription naming the dialog, and place a RegionForm holding RegionPostalCodeControl and RegionSubmit in the popup, alongside RegionError and RegionUnknownLink. Same pattern as CartOpenOnAdd wrapping the mini-cart DrawerRoot. Must be inside RegionRoot.',\n});\n\nexport const RegionFormDefinition = defineComponent<RegionFormProps>({\n name: 'RegionForm',\n importPath: '@vtex/faststore/components',\n component: RegionForm,\n requiresContext: 'region',\n editor: { label: 'Region Form', category: 'action' },\n schema: {},\n guideline:\n 'Form wrapper holding RegionPostalCodeControl and RegionSubmit inside the region modal, so pressing Enter in the field submits. Same role as ShippingSimulatorForm. Compose it whenever both parts sit together; without it the shopper must reach the button, which still works but is not what a one-field form leads them to expect. Must be inside a RegionModalController dialog.',\n});\n\nexport const RegionPostalCodeControlDefinition = defineComponent<RegionPostalCodeControlProps>({\n name: 'RegionPostalCodeControl',\n importPath: '@vtex/faststore/components',\n component: RegionPostalCodeControl,\n requiresContext: 'region',\n editor: { label: 'Region Postal Code Control', category: 'content' },\n schema: {\n mask: { type: 'string', default: '99999-999', label: 'Mask pattern' },\n label: { type: 'string', label: 'Label' },\n placeholder: { type: 'string', label: 'Placeholder' },\n errorMessage: { type: 'string', label: 'Incomplete-value message' },\n },\n guideline:\n 'The postal-code input inside the region modal: a PostalCodeField bound to the region draft, seeded from the persisted value every time the modal opens. Set mask to the country format at build time (default 99999-999, BR CEP). Server rejections mark the field invalid and take focus back to it; their message is shown by RegionError, not repeated here, and the first keystroke after one clears it. Must be inside a RegionModalController dialog.',\n});\n\nexport const RegionSubmitDefinition = defineComponent<RegionSubmitProps>({\n name: 'RegionSubmit',\n importPath: '@vtex/faststore/components',\n component: RegionSubmit,\n content: RegionSubmitContent,\n requiresContext: 'region',\n editor: { label: 'Region Submit', category: 'action' },\n schema: {},\n guideline:\n \"Submits the region draft. Its label comes from the $content fields label and pendingLabel; authored children replace both. Inside a RegionForm it is the form's submit button, which is what makes Enter in the field work; on its own it dispatches directly. Inert while empty and while a write is in flight, so a double activation dispatches one mutation; the pending state is exposed as aria-busy with no built-in spinner. On success the modal closes; on a rejection it stays open and RegionError explains why. Must be inside a RegionModalController dialog.\",\n});\n\nexport const RegionErrorDefinition = defineComponent<RegionErrorProps>({\n name: 'RegionError',\n importPath: '@vtex/faststore/components',\n component: RegionError,\n content: RegionErrorContent,\n requiresContext: 'region',\n editor: { label: 'Region Error', category: 'content' },\n schema: {},\n guideline:\n 'Shows why the latest region write was refused, announced as an alert when it appears. Renders nothing when there is no error, so it needs no visibility prop. Words each known code from its message (genericMessage for a transport failure and an unknown code). Must be inside a RegionModalController dialog.',\n});\n\nexport const RegionUnknownLinkDefinition = defineComponent<RegionUnknownLinkProps>({\n name: 'RegionUnknownLink',\n importPath: '@vtex/faststore/components',\n component: RegionUnknownLink,\n content: RegionUnknownLinkContent,\n requiresContext: 'region',\n editor: { label: 'Region Unknown Postal Code Link', category: 'navigation' },\n schema: {\n href: { type: 'string', label: 'Lookup service URL' },\n target: { type: ['_self', '_blank'] as const, default: '_self', label: 'Open in' },\n },\n guideline:\n 'The \"I don\\'t know my postal code\" escape hatch, pointing at a postal-code lookup service. Renders nothing until a destination is set, so a store without a lookup service composes it and simply gets no link rather than a dead one. Its text comes from authored content or its children. Must be inside a RegionModalController dialog.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\n/**\n * Reads the active region reactively and publishes it, the modal's draft, and the write state as\n * `region` context.\n *\n * The resolved value is never copied into state: `RegionValue` renders only what the fragment\n * resolves, and a successful write updates the display solely by the mutation payload normalizing\n * into the Apollo cache (Decision 5). That is why a rejected write needs no rollback and cannot\n * leave the header showing a postal code the server refused.\n */\nexport function RegionRoot({\n $data: $dataProp,\n $actions: $actionsProp,\n className,\n children,\n ...props\n}: RegionRootProps) {\n const $data = useDataOverride($dataProp);\n const $actions = useActionsOverride($actionsProp);\n const region = $data ?? null;\n const { loading: rootLoading } = useContext(ReactiveRootContext);\n // A null region is ambiguous on its own — an unresolved read and a shopper who never set one look\n // the same — so the root query's in-flight flag is what separates \"loading\" from \"unset\". Without\n // it a first-time shopper would sit under a skeleton forever instead of seeing the unset prompt.\n const loading = rootLoading && region == null;\n\n const postalCode = region?.postalCode ?? null;\n\n const [open, setOpenState] = useState(false);\n const [draft, setDraftState] = useState('');\n const [pending, setPending] = useState(false);\n const [errors, setErrors] = useState<readonly RegionUserError[]>([]);\n // State is batched, so two activations in one tick would both pass a `pending` check. The ref is\n // what makes \"exactly one mutation per activation\" hold.\n const inFlightRef = useRef(false);\n\n /**\n * Seeds the draft from the persisted value on open and clears it on close (Decision 6), so a\n * reopened modal always shows the truth rather than an abandoned edit.\n */\n const setOpen = useCallback(\n (next: boolean) => {\n setOpenState(next);\n setDraftState(next ? (postalCode ?? '') : '');\n setErrors([]);\n },\n [postalCode],\n );\n\n /**\n * Editing is the shopper's answer to a rejection, so the message and the invalid flag go with the\n * first keystroke. Left standing, they describe a value that is no longer in the field — and\n * `RegionPostalCodeControl`, which withholds its own incomplete-value copy while a rejection\n * stands, would stay silent for the whole edit. Returns the same array when there is nothing to\n * clear, so ordinary typing does not re-render the error subtree.\n */\n const setDraft = useCallback((value: string) => {\n setDraftState(value);\n setErrors((current) => (current.length === 0 ? current : []));\n }, []);\n\n const submit = useCallback(() => {\n if (inFlightRef.current) return;\n const setPostalCode = $actions?.region?.setPostalCode;\n if (!setPostalCode) return;\n\n inFlightRef.current = true;\n setPending(true);\n setErrors([]);\n\n void setPostalCode(draft)\n .then((writeErrors) => {\n if (writeErrors.length > 0) {\n // A rejection keeps the modal open so the message has somewhere to show (US-3).\n setErrors(writeErrors);\n return;\n }\n setOpenState(false);\n setDraftState('');\n })\n .finally(() => {\n inFlightRef.current = false;\n setPending(false);\n });\n }, [$actions, draft]);\n\n const value: RegionContextValue = useMemo(\n () => ({\n postalCode,\n city: region?.city ?? null,\n loading,\n draft,\n setDraft,\n pending,\n errors,\n open,\n setOpen,\n submit,\n }),\n [postalCode, region?.city, loading, draft, setDraft, pending, errors, open, setOpen, submit],\n );\n\n return (\n <RegionContextInternal value={value}>\n <div {...props} className={className} data-fs-region-root=\"\">\n {children}\n </div>\n </RegionContextInternal>\n );\n}\n\nexport function RegionTrigger({ $content, $locale, className, children, ...props }: RegionTriggerProps) {\n const { postalCode, city, loading, setOpen } = useRegion();\n const { format } = useMessageFormatter(RegionTriggerContent, $content);\n const isUnset = postalCode == null;\n\n const authoredAriaLabel = $content?.ariaLabel?.trim() ? $content.ariaLabel : props['aria-label'];\n\n /**\n * WCAG 2.5.3 wants the accessible name to contain the visible label, so an authored label prefixes\n * the text on screen rather than replacing it: a name of \"Alterar região\" over text reading\n * \"Informe seu CEP\" leaves a voice-control user nothing to say. The region is spaced the way\n * `RegionValue` spaces it, since the name has to carry that text verbatim. Empty while the region\n * is unresolved, when the button reads nothing, and with no authored label the name falls back to\n * the text itself, which already satisfies the rule.\n */\n let visibleLabel = '';\n if (!loading) {\n visibleLabel = isUnset ? format('unsetLabel') : [city, postalCode].filter(Boolean).join(' ');\n }\n\n let ariaLabel = authoredAriaLabel && visibleLabel ? `${authoredAriaLabel}: ${visibleLabel}` : authoredAriaLabel;\n // The button shows nothing while the region is unresolved, so with no authored label it would have no\n // name at all. Name it as it will read once resolved and unset.\n if (loading && !ariaLabel) ariaLabel = format('unsetLabel');\n\n return (\n <button\n {...props}\n type=\"button\"\n onClick={() => setOpen(true)}\n // Not yet interactive while the region is unresolved: activating it would seed the draft from a\n // value that has not arrived.\n disabled={loading || props.disabled}\n aria-label={ariaLabel}\n className={className}\n data-fs-region-trigger=\"\"\n {...(isUnset ? { 'data-fs-region-trigger-unset': '' } : {})}\n >\n {isUnset && !loading ? visibleLabel : null}\n {children}\n </button>\n );\n}\n\nexport function RegionValue({ className, ...props }: RegionValueProps) {\n const { postalCode, city, loading } = useRegion();\n if (loading || postalCode == null) return null;\n\n return (\n <span {...props} className={className} data-fs-region-value=\"\">\n {city ? <span data-fs-region-value-city=\"\">{city}</span> : null}\n {/* A real text node, not a styling concern: it is what separates the two values in the\n accessible name — this is the trigger's name whenever no aria-label is authored — and in any\n non-flex placement. It must stay a plain space: a flex container strips it as leading\n whitespace, so a store's `gap` still governs the visible spacing, where an would\n survive and widen the row. Absent with no city, so the postal code never renders padded. */}\n {city ? ' ' : null}\n {postalCode}\n </span>\n );\n}\n\nexport function RegionLoading({ className, children, ...props }: RegionLoadingProps) {\n const { loading } = useRegion();\n if (!loading) return null;\n\n return (\n <div {...props} className={className} data-fs-region-loading=\"\">\n {children}\n </div>\n );\n}\n\n/**\n * Makes the wrapped `DialogRoot` controlled by the region state. Mirrors\n * `ShippingAddressSavedAddressDrawerController`'s `cloneElement` mechanism; expects a single\n * `DialogRoot` child. Dismissal is never blocked — the Phase 1 modal is always dismissible.\n */\nexport function RegionModalController({ children }: RegionModalControllerProps) {\n const { open, setOpen } = useRegion();\n\n if (!isValidElement<Pick<DialogRootProps, 'open' | 'onOpenChange'>>(children)) {\n return children;\n }\n\n return cloneElement(children, {\n open,\n onOpenChange: (next: boolean) => setOpen(next),\n });\n}\n\n/**\n * Gives the field and the submit a form owner, so Enter in the postal code submits the way it does\n * in every other short form in the repo. Mirrors `ShippingSimulatorForm`: the form's only job is to\n * route native submission to the context's `submit()`.\n */\nexport function RegionForm({ className, children, ...props }: RegionFormProps) {\n const { submit } = useRegion();\n\n return (\n <RegionFormContext value={true}>\n <form\n {...props}\n className={className}\n data-fs-region-form=\"\"\n onSubmit={(event) => {\n event.preventDefault();\n submit();\n }}\n >\n {children}\n </form>\n </RegionFormContext>\n );\n}\n\nexport function RegionPostalCodeControl({\n className,\n mask,\n label,\n placeholder,\n errorMessage,\n}: RegionPostalCodeControlProps) {\n const { draft, setDraft, errors, pending } = useRegion();\n const rootRef = useRef<HTMLDivElement>(null);\n const refused = errors.length > 0;\n\n /**\n * A refusal has to leave the shopper on the value they need to correct. Disabling the input while\n * the write is in flight blurs it and the browser drops focus to the document body, so a rejection\n * otherwise lands with nothing focused inside an open dialog — Enter does nothing and Tab restarts\n * from the top. Waits for `pending` to clear, because focusing a still-disabled input is a no-op:\n * the errors and the pending flag settle in separate microtasks, so there is a render in between\n * where the rejection is known and the field is not yet editable. The field is reached through the\n * root via a scoped querySelector, not a ref threaded down through props.\n */\n useEffect(() => {\n if (!refused || pending) return;\n rootRef.current?.querySelector<HTMLInputElement>('[data-fs-postal-code-field-input]')?.focus();\n }, [refused, pending]);\n\n return (\n <PostalCodeField\n ref={rootRef}\n className={className}\n data-fs-region-postal-code-control=\"\"\n mask={mask}\n label={label}\n placeholder={placeholder}\n // The field renders this whenever it is invalid, from either source, so it is withheld while a\n // server rejection stands: that message is RegionError's, and the field's own copy describes an\n // incomplete value — wrong for a complete code the server refused, and contradictory stacked\n // under the real reason.\n errorMessage={errors.length > 0 ? undefined : errorMessage}\n value={draft}\n onValueChange={setDraft}\n // Still flagged invalid, so the refused value carries aria-invalid and the invalid styling.\n invalid={errors.length > 0}\n disabled={pending}\n />\n );\n}\n\nexport function RegionSubmit({ $content, $locale, className, children, ...props }: RegionSubmitProps) {\n const { draft, pending, submit } = useRegion();\n const inForm = useContext(RegionFormContext);\n const { format } = useMessageFormatter(RegionSubmitContent, $content);\n\n return (\n <button\n {...props}\n // The form routes native submission to the same submit(); alone there is no form to submit.\n type={inForm ? 'submit' : 'button'}\n onClick={inForm ? props.onClick : submit}\n disabled={pending || draft.trim() === '' || props.disabled}\n aria-busy={pending || undefined}\n className={className}\n data-fs-region-submit=\"\"\n {...(pending ? { 'data-fs-region-submit-pending': '' } : {})}\n >\n {children ?? format(pending ? 'pendingLabel' : 'label')}\n </button>\n );\n}\n\n/**\n * The message for each rejection the client can name: the server's `RegionErrorCode` values plus the\n * client-minted transport failure. A code this map does not know (a newer server than this package)\n * shows genericMessage.\n */\nexport const REGION_ERROR_FIELDS = {\n INVALID_POSTAL_CODE: 'invalidPostalCode',\n UNSERVED_POSTAL_CODE: 'unservedPostalCode',\n NETWORK_ERROR: 'genericMessage',\n} as const satisfies Record<string, MessageFieldName<typeof RegionErrorContent>>;\n\nexport function RegionError({ $content, $locale, className, ...props }: RegionErrorProps) {\n const { errors } = useRegion();\n const { format } = useMessageFormatter(RegionErrorContent, $content);\n if (errors.length === 0) return null;\n\n function copyFor(error: RegionUserError): string {\n return formatErrorCode(RegionErrorContent, REGION_ERROR_FIELDS, error, format, 'genericMessage');\n }\n\n return (\n <div {...props} role=\"alert\" className={className} data-fs-region-error=\"\">\n {errors.map((error) => (\n <div key={`${error.code ?? ''}${error.message}`}>{copyFor(error)}</div>\n ))}\n </div>\n );\n}\n\nexport function RegionUnknownLink({ $content, className, children, href, rel, ...props }: RegionUnknownLinkProps) {\n // Called for its guard alone: a part placed outside a RegionRoot must fail here the way its\n // siblings do, even though this one reads nothing from the context.\n useRegion();\n\n const authoredHref = $content?.href?.trim() ? $content.href : href?.trim();\n // Absent is \"no link\", the ordinary shape for a store with no lookup service, so it never reaches\n // the allowlist or the log.\n if (!authoredHref) return null;\n\n // No read-time validator enforces the model's `format` or `pattern`, so this is the only gate on\n // the CMS value.\n const destination = resolveSafeHref(authoredHref);\n if (!destination.safe) {\n // A bounded reason and no authored value, the convention the content runtime's own log follows.\n console.warn('[RegionUnknownLink] link destination rejected', { reason: destination.reason });\n return null;\n }\n\n const text = $content?.text?.trim() ? $content.text : children;\n if (!text) return null;\n\n // A lookup service is a natural new-tab destination, so a store may pass target. The tab-nabbing\n // defense is then this component's responsibility, not the composer's — the same contract\n // NavigationLink states. Target keywords and link types are both ASCII case-insensitive per HTML,\n // so _BLANK opens a new tab and a caller-passed NOOPENER already counts.\n const relTokens = rel?.split(/\\s+/).filter(Boolean) ?? [];\n const present = new Set(relTokens.map((token) => token.toLowerCase()));\n const safeRel =\n props.target?.toLowerCase() === '_blank'\n ? [...relTokens, ...['noopener', 'noreferrer'].filter((token) => !present.has(token))].join(' ')\n : rel;\n\n return (\n <a {...props} href={destination.href} rel={safeRel} className={className} data-fs-region-unknown-link=\"\">\n {text}\n </a>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace export\n// ---------------------------------------------------------------------------\n\nexport const Region = {\n Root: RegionRoot,\n Trigger: RegionTrigger,\n Value: RegionValue,\n Loading: RegionLoading,\n ModalController: RegionModalController,\n Form: RegionForm,\n PostalCodeControl: RegionPostalCodeControl,\n Submit: RegionSubmit,\n Error: RegionError,\n UnknownLink: RegionUnknownLink,\n};\n"],"mappings":";;;;;;;;;;;;;;;AAuCA,MAAM,WAAW,QAAQ;;;;;;CAMxB;AAMD,MAAa,uBAAuB,kBAAkB;CACpD,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,YAAY;GACV,YAAY;IACV,MAAM;IACN,OAAO;IACP,QAAQ;IACR,eAAe;GACjB;GACA,WAAW;IAAE,MAAM;IAAU,OAAO;GAAmB;EACzD;CACF;AACF,CAAC;AAED,MAAa,sBAAsB,kBAAkB;CACnD,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,YAAY;GACV,OAAO;IAAE,MAAM;IAAU,OAAO;IAAgB,QAAQ;IAAe,eAAe;GAAQ;GAC9F,cAAc;IAAE,MAAM;IAAU,OAAO;IAAiB,QAAQ;IAAe,eAAe;GAAc;EAC9G;CACF;AACF,CAAC;AAED,MAAa,2BAA2B,kBAAkB;CACxD,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,YAAY;GACV,MAAM;IAAE,MAAM;IAAU,WAAW;IAAG,OAAO;GAAY;GACzD,MAAM;IACJ,MAAM;IACN,OA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AA5D,GAAG,MAAM,QAAQ,KAAK,MAAM,SAAgC,CACvE;CACE,CAAA;AAET;AAEA,SAAgB,kBAAkB,EAAE,UAAU,WAAW,UAAU,MAAM,KAAK,GAAG,SAAiC;CAGhH,UAAU;CAEV,MAAM,eAAe,UAAU,MAAM,KAAK,IAAI,SAAS,OAAO,MAAM,KAAK;CAGzE,IAAI,CAAC,cAAc,OAAO;CAI1B,MAAM,cAAc,gBAAgB,YAAY;CAChD,IAAI,CAAC,YAAY,MAAM;EAErB,QAAQ,KAAK,iDAAiD,EAAE,QAAQ,YAAY,OAAO,CAAC;EAC5F,OAAO;CACT;CAEA,MAAM,OAAO,UAAU,MAAM,KAAK,IAAI,SAAS,OAAO;CACtD,IAAI,CAAC,MAAM,OAAO;CAMlB,MAAM,YAAY,KAAK,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO,KAAK,CAAC;CACxD,MAAM,UAAU,IAAI,IAAI,UAAU,KAAK,UAAU,MAAM,YAAY,CAAC,CAAC;CACrE,MAAM,UACJ,MAAM,QAAQ,YAAY,MAAM,WAC5B,CAAC,GAAG,WAAW,GAAG,CAAC,YAAY,YAAY,CAAC,CAAC,QAAQ,UAAU,CAAC,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAC7F;CAEN,OACE,oBAAC,KAAD;EAAG,GAAI;EAAO,MAAM,YAAY;EAAM,KAAK;EAAoB;EAAW,+BAA4B;EACnG,UAAA;CACA,CAAA;AAEP;AAMA,MAAa,SAAS;CACpB,MAAM;CACN,SAAS;CACT,OAAO;CACP,SAAS;CACT,iBAAiB;CACjB,MAAM;CACN,mBAAmB;CACnB,QAAQ;CACR,OAAO;CACP,aAAa;AACf"}
|
|
@@ -1,3 +1,4 @@
|
|
|
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";
|
|
@@ -11,16 +12,50 @@ import { ComponentPropsWithRef } from "react";
|
|
|
11
12
|
export type SaveCardData = {
|
|
12
13
|
savePersonalData?: boolean | null;
|
|
13
14
|
} | null;
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
export declare const SaveCardContent: {
|
|
16
|
+
readonly id: "save-card";
|
|
17
|
+
readonly title: "Save Card";
|
|
18
|
+
readonly description: "Copy for the save-card toggle, its consent notice, the nickname field and a refused consent write.";
|
|
19
|
+
readonly schema: {
|
|
20
|
+
readonly type: "object";
|
|
21
|
+
readonly additionalProperties: false;
|
|
22
|
+
readonly properties: {
|
|
23
|
+
readonly label: {
|
|
24
|
+
readonly type: "string";
|
|
25
|
+
readonly title: "Toggle label";
|
|
26
|
+
readonly format: "icu-message";
|
|
27
|
+
readonly messageSource: "Save this card for next time";
|
|
28
|
+
};
|
|
29
|
+
readonly nicknameLabel: {
|
|
30
|
+
readonly type: "string";
|
|
31
|
+
readonly title: "Nickname field label";
|
|
32
|
+
readonly description: "Rendered only while the toggle is checked.";
|
|
33
|
+
readonly format: "icu-message";
|
|
34
|
+
readonly messageSource: "Card nickname";
|
|
35
|
+
};
|
|
36
|
+
readonly consentNoticeLabel: {
|
|
37
|
+
readonly type: "string";
|
|
38
|
+
readonly title: "Consent notice";
|
|
39
|
+
readonly description: "Shown beside the toggle until the shopper has granted the save-personal-data consent.";
|
|
40
|
+
readonly format: "icu-message";
|
|
41
|
+
readonly messageSource: "Checking this also lets us store your personal data for future purchases.";
|
|
42
|
+
};
|
|
43
|
+
readonly genericErrorMessage: {
|
|
44
|
+
readonly type: "string";
|
|
45
|
+
readonly title: "Consent write failure message";
|
|
46
|
+
readonly description: "Shown when the consent write fails: a network failure or a fault the shopper cannot fix.";
|
|
47
|
+
readonly format: "icu-message";
|
|
48
|
+
readonly messageSource: "Unable to save your card preference. Please try again.";
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export type SaveCardProps = Omit<ComponentPropsWithRef<'div'>, 'children'> & MessageLocaleProp & {
|
|
19
54
|
nicknamePlaceholder?: string;
|
|
20
|
-
/** Shown beside the toggle while `savePersonalData !== true` (covers both `false` and `null`). */
|
|
21
|
-
consentNoticeLabel?: string;
|
|
22
55
|
/** Disables both the toggle and the nickname field. */
|
|
23
56
|
disabled?: boolean;
|
|
57
|
+
/** Merchant-authored copy: the toggle label, the nickname field label, the consent notice and the write error. */
|
|
58
|
+
$content?: ContentValue<typeof SaveCardContent>;
|
|
24
59
|
/** This component's own `clientPreferences` slice (arity-1 fragment, ADR-0015). */
|
|
25
60
|
$data?: SaveCardData;
|
|
26
61
|
/** Compiler-injected action surface; carries `payment.saveCard`. */
|
|
@@ -44,6 +79,6 @@ export declare function isSaveCardVisible({ loading, state }: Pick<SessionContex
|
|
|
44
79
|
*/
|
|
45
80
|
export declare function isConsentNoticeVisible(savePersonalData: boolean | null | undefined): boolean;
|
|
46
81
|
export declare const SaveCardDefinition: ComponentDefinition<SaveCardProps>;
|
|
47
|
-
export declare function SaveCard({
|
|
82
|
+
export declare function SaveCard({ nicknamePlaceholder, disabled, className, $content, $locale, $data: $dataProp, $actions: $actionsProp, ...props }: SaveCardProps): import("react/jsx-runtime").JSX.Element | null;
|
|
48
83
|
//#endregion
|
|
49
84
|
//# sourceMappingURL=save-card.d.ts.map
|