@vtex/faststore 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +55 -0
- package/README.md +0 -1
- package/dist/_virtual/_rolldown/runtime.js +4 -0
- package/dist/actions.json +6 -1
- package/dist/catalog.json +789 -1701
- package/dist/cli/index.d.ts +66 -28
- package/dist/cli/index.js +7371 -512
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/server-runtime.js +41 -60
- package/dist/cli/server-runtime.js.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js +2 -2
- package/dist/components.d.ts +63 -57
- package/dist/components.js +60 -54
- package/dist/content-types.json +5785 -754
- package/dist/core/dist/define-component.d.ts +1 -1
- package/dist/core/dist/define-content-type.d.ts +50 -2
- package/dist/core/dist/define-content-type.js +107 -3
- package/dist/core/dist/define-content-type.js.map +1 -1
- package/dist/core/dist/index.d.ts +2 -2
- package/dist/docs/access-code-field.md +1 -1
- package/dist/docs/access-code-sign-in.md +126 -77
- package/dist/docs/account-address-book.md +210 -95
- package/dist/docs/account-menu.md +14 -15
- package/dist/docs/account-saved-cards.md +44 -39
- package/dist/docs/alert-dialog.md +3 -1
- package/dist/docs/avatar.md +4 -2
- package/dist/docs/billing-address.md +99 -30
- package/dist/docs/binding-switcher.md +5 -2
- package/dist/docs/buy-button.md +7 -8
- package/dist/docs/card-entry.md +39 -26
- package/dist/docs/card-summary.md +18 -8
- package/dist/docs/cardholder-document.md +5 -3
- package/dist/docs/carousel.md +5 -4
- package/dist/docs/cart-destination.md +39 -26
- package/dist/docs/cart-item.md +29 -14
- package/dist/docs/cart-totalizer.md +7 -5
- package/dist/docs/cart.md +135 -41
- package/dist/docs/challenge-return.md +135 -0
- package/dist/docs/client-preferences-fieldset.md +10 -5
- package/dist/docs/client-preferences.md +31 -8
- package/dist/docs/client-profile-fieldset.md +20 -6
- package/dist/docs/client-profile.md +12 -3
- package/dist/docs/copy-text.md +9 -7
- package/dist/docs/document-field.md +1 -1
- package/dist/docs/email-field.md +2 -1
- package/dist/docs/email-identification.md +12 -2
- package/dist/docs/footer-copyright.md +4 -2
- package/dist/docs/form.md +54 -18
- package/dist/docs/free-shipping-progress.md +6 -5
- package/dist/docs/identity-edit.md +8 -2
- package/dist/docs/identity-summary.md +18 -5
- package/dist/docs/installments.md +46 -32
- package/dist/docs/my-account-profile.md +16 -11
- package/dist/docs/navigation-link.md +5 -3
- package/dist/docs/order-cancel.md +3 -1
- package/dist/docs/order-delivery-address.md +7 -5
- package/dist/docs/order-delivery-group.md +1 -3
- package/dist/docs/order-details-back.md +1 -1
- package/dist/docs/order-details-header.md +1 -4
- package/dist/docs/order-invoice-download.md +60 -0
- package/dist/docs/order-list-row.md +1 -1
- package/dist/docs/order-list-search.md +13 -20
- package/dist/docs/order-list-views.md +11 -17
- package/dist/docs/order-list.md +12 -5
- package/dist/docs/order-payment.md +9 -7
- package/dist/docs/order-placed-date.md +1 -1
- package/dist/docs/order-placed-payment-summary.md +28 -15
- package/dist/docs/order-placed.md +49 -14
- package/dist/docs/order-progress.md +1 -1
- package/dist/docs/order-status-badge.md +20 -9
- package/dist/docs/order-summary.md +2 -2
- package/dist/docs/order-tracking-link.md +58 -0
- package/dist/docs/payment-method-badges.md +30 -4
- package/dist/docs/payment-methods.md +1 -1
- package/dist/docs/payment.md +36 -17
- package/dist/docs/phone-field.md +4 -4
- package/dist/docs/place-order.md +84 -36
- package/dist/docs/postal-code-field.md +3 -1
- package/dist/docs/pricing.md +21 -23
- package/dist/docs/product-gallery.md +19 -20
- package/dist/docs/product-information.md +13 -9
- package/dist/docs/product-list.md +7 -6
- package/dist/docs/product-shelf.md +0 -1
- package/dist/docs/promotion.md +4 -2
- package/dist/docs/region.md +23 -15
- package/dist/docs/save-card.md +7 -6
- package/dist/docs/saved-cards.md +65 -36
- package/dist/docs/shipping-address.md +57 -21
- package/dist/docs/shipping-simulator.md +53 -15
- package/dist/docs/sign-in-disclosure.md +176 -0
- package/dist/docs/sign-in-form.md +78 -47
- package/dist/docs/sign-in-redirect.md +4 -2
- package/dist/docs/sign-in.md +173 -0
- package/dist/docs/toast.md +15 -4
- package/dist/docs/variant-selector.md +15 -11
- package/dist/domain-logic/dist/checkout/rules.js +33 -0
- package/dist/domain-logic/dist/checkout/rules.js.map +1 -0
- package/dist/graphql/types.d.ts +4 -14
- package/dist/index.d.ts +2 -2
- package/dist/internal/client.d.ts +1 -3
- package/dist/internal/client.js +1 -1
- package/dist/internal/server.d.ts +7 -4
- package/dist/internal/server.js +7 -4
- package/dist/matter/access-code-sign-in/access-code-sign-in.d.ts +250 -66
- package/dist/matter/access-code-sign-in/access-code-sign-in.js +459 -188
- package/dist/matter/access-code-sign-in/access-code-sign-in.js.map +1 -1
- package/dist/matter/account-address-book/account-address-book-delete.d.ts +78 -40
- package/dist/matter/account-address-book/account-address-book-delete.js +86 -50
- package/dist/matter/account-address-book/account-address-book-delete.js.map +1 -1
- package/dist/matter/account-address-book/account-address-book-deliverability.d.ts +21 -4
- package/dist/matter/account-address-book/account-address-book-deliverability.js +45 -17
- package/dist/matter/account-address-book/account-address-book-deliverability.js.map +1 -1
- package/dist/matter/account-address-book/account-address-book-form-parts.d.ts +74 -19
- package/dist/matter/account-address-book/account-address-book-form-parts.js +77 -26
- package/dist/matter/account-address-book/account-address-book-form-parts.js.map +1 -1
- package/dist/matter/account-address-book/account-address-book-profile-notice.d.ts +27 -6
- package/dist/matter/account-address-book/account-address-book-profile-notice.js +55 -28
- package/dist/matter/account-address-book/account-address-book-profile-notice.js.map +1 -1
- package/dist/matter/account-address-book/account-address-book.d.ts +67 -14
- package/dist/matter/account-address-book/account-address-book.js +74 -33
- package/dist/matter/account-address-book/account-address-book.js.map +1 -1
- package/dist/matter/account-address-book/account-address-country-switch.js +3 -3
- package/dist/matter/account-address-book/account-address-country-switch.js.map +1 -1
- package/dist/matter/account-address-book/account-address-country.d.ts +66 -20
- package/dist/matter/account-address-book/account-address-country.js +83 -49
- package/dist/matter/account-address-book/account-address-country.js.map +1 -1
- package/dist/matter/account-address-book/account-address-form-context.d.ts +8 -4
- package/dist/matter/account-address-book/account-address-form-context.js.map +1 -1
- package/dist/matter/account-address-book/account-address-form.d.ts +468 -45
- package/dist/matter/account-address-book/account-address-form.js +518 -155
- package/dist/matter/account-address-book/account-address-form.js.map +1 -1
- package/dist/matter/account-address-book/account-address-record.d.ts +27 -6
- package/dist/matter/account-address-book/account-address-record.js +32 -17
- package/dist/matter/account-address-book/account-address-record.js.map +1 -1
- package/dist/matter/account-menu/account-menu.d.ts +34 -17
- package/dist/matter/account-menu/account-menu.js +46 -54
- package/dist/matter/account-menu/account-menu.js.map +1 -1
- package/dist/matter/account-menu-identity/account-menu-identity.js +1 -1
- package/dist/matter/account-saved-cards/account-saved-cards.d.ts +108 -28
- package/dist/matter/account-saved-cards/account-saved-cards.js +177 -122
- package/dist/matter/account-saved-cards/account-saved-cards.js.map +1 -1
- package/dist/matter/billing-address/billing-address.d.ts +156 -74
- package/dist/matter/billing-address/billing-address.js +227 -156
- package/dist/matter/billing-address/billing-address.js.map +1 -1
- package/dist/matter/breadcrumb/breadcrumb.d.ts +21 -3
- package/dist/matter/breadcrumb/breadcrumb.js +24 -9
- package/dist/matter/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/matter/buy-button/buy-button.d.ts +8 -11
- package/dist/matter/buy-button/buy-button.js +10 -19
- package/dist/matter/buy-button/buy-button.js.map +1 -1
- package/dist/matter/card-entry/card-capture.js +12 -4
- package/dist/matter/card-entry/card-capture.js.map +1 -1
- package/dist/matter/card-entry/card-entry.d.ts +123 -32
- package/dist/matter/card-entry/card-entry.js +348 -221
- package/dist/matter/card-entry/card-entry.js.map +1 -1
- package/dist/matter/cart/cart-namespace.d.ts +7 -1
- package/dist/matter/cart/cart-namespace.js +7 -1
- package/dist/matter/cart/cart-namespace.js.map +1 -1
- package/dist/matter/cart/cart.d.ts +402 -61
- package/dist/matter/cart/cart.js +624 -153
- package/dist/matter/cart/cart.js.map +1 -1
- package/dist/matter/cart-destination/cart-destination.d.ts +30 -19
- package/dist/matter/cart-destination/cart-destination.js +160 -70
- package/dist/matter/cart-destination/cart-destination.js.map +1 -1
- package/dist/matter/cart-item/cart-item.d.ts +144 -17
- package/dist/matter/cart-item/cart-item.js +166 -49
- package/dist/matter/cart-item/cart-item.js.map +1 -1
- package/dist/matter/cart-item-compositions/cart-item-compositions.js +1 -1
- package/dist/matter/cart-item-compositions/cart-item-compositions.js.map +1 -1
- package/dist/matter/cart-item-customizations/cart-item-customizations.js +1 -1
- package/dist/matter/cart-item-customizations/cart-item-customizations.js.map +1 -1
- package/dist/matter/cart-item-discounts/cart-item-discounts.js +1 -1
- package/dist/matter/cart-item-discounts/cart-item-discounts.js.map +1 -1
- package/dist/matter/cart-item-seller-info/cart-item-seller-info.js +1 -1
- package/dist/matter/cart-item-seller-info/cart-item-seller-info.js.map +1 -1
- package/dist/matter/cart-item-variations/cart-item-variations.js +1 -1
- package/dist/matter/cart-item-variations/cart-item-variations.js.map +1 -1
- package/dist/matter/cart-totalizer/cart-totalizer.d.ts +43 -9
- package/dist/matter/cart-totalizer/cart-totalizer.js +46 -17
- package/dist/matter/cart-totalizer/cart-totalizer.js.map +1 -1
- package/dist/matter/challenge-return/challenge-return.d.ts +62 -0
- package/dist/matter/challenge-return/challenge-return.js +241 -0
- package/dist/matter/challenge-return/challenge-return.js.map +1 -0
- package/dist/matter/client-preferences/client-preferences-fieldset.d.ts +86 -17
- package/dist/matter/client-preferences/client-preferences-fieldset.js +126 -54
- package/dist/matter/client-preferences/client-preferences-fieldset.js.map +1 -1
- package/dist/matter/client-preferences/client-preferences.d.ts +50 -7
- package/dist/matter/client-preferences/client-preferences.js +84 -15
- package/dist/matter/client-preferences/client-preferences.js.map +1 -1
- package/dist/matter/client-profile/client-profile.d.ts +44 -9
- package/dist/matter/client-profile/client-profile.js +64 -24
- package/dist/matter/client-profile/client-profile.js.map +1 -1
- package/dist/matter/client-profile-form/client-profile-fieldset.d.ts +119 -22
- package/dist/matter/client-profile-form/client-profile-fieldset.js +161 -73
- package/dist/matter/client-profile-form/client-profile-fieldset.js.map +1 -1
- package/dist/matter/delivery-options/delivery-options-accordion.d.ts +49 -4
- package/dist/matter/delivery-options/delivery-options-accordion.js +67 -14
- package/dist/matter/delivery-options/delivery-options-accordion.js.map +1 -1
- package/dist/matter/delivery-options/delivery-options-controller.d.ts +69 -9
- package/dist/matter/delivery-options/delivery-options-controller.js +80 -14
- package/dist/matter/delivery-options/delivery-options-controller.js.map +1 -1
- package/dist/matter/delivery-options/delivery-options.d.ts +37 -2
- package/dist/matter/delivery-options/delivery-options.js +75 -12
- package/dist/matter/delivery-options/delivery-options.js.map +1 -1
- package/dist/matter/delivery-options/use-delivery-option-selection.d.ts +1 -0
- package/dist/matter/delivery-options/use-delivery-option-selection.js +1 -1
- package/dist/matter/delivery-options/use-delivery-option-selection.js.map +1 -1
- package/dist/matter/email-identification/email-identification.d.ts +25 -3
- package/dist/matter/email-identification/email-identification.js +49 -12
- package/dist/matter/email-identification/email-identification.js.map +1 -1
- package/dist/matter/free-shipping-progress/free-shipping-progress.d.ts +79 -7
- package/dist/matter/free-shipping-progress/free-shipping-progress.js +77 -20
- package/dist/matter/free-shipping-progress/free-shipping-progress.js.map +1 -1
- package/dist/matter/identity-edit/identity-edit.d.ts +52 -10
- package/dist/matter/identity-edit/identity-edit.js +47 -19
- package/dist/matter/identity-edit/identity-edit.js.map +1 -1
- package/dist/matter/identity-summary/identity-summary.d.ts +76 -22
- package/dist/matter/identity-summary/identity-summary.js +95 -45
- package/dist/matter/identity-summary/identity-summary.js.map +1 -1
- package/dist/matter/installments/installments-select.d.ts +98 -16
- package/dist/matter/installments/installments-select.js +156 -48
- package/dist/matter/installments/installments-select.js.map +1 -1
- package/dist/matter/installments/installments.d.ts +96 -16
- package/dist/matter/installments/installments.js +115 -40
- package/dist/matter/installments/installments.js.map +1 -1
- package/dist/matter/installments/use-installments-selection.d.ts +1 -0
- package/dist/matter/installments/use-installments-selection.js +8 -3
- package/dist/matter/installments/use-installments-selection.js.map +1 -1
- package/dist/matter/my-account-profile/my-account-profile.d.ts +358 -103
- package/dist/matter/my-account-profile/my-account-profile.js +370 -174
- package/dist/matter/my-account-profile/my-account-profile.js.map +1 -1
- package/dist/matter/order-cancel/order-cancel.d.ts +65 -19
- package/dist/matter/order-cancel/order-cancel.js +118 -51
- package/dist/matter/order-cancel/order-cancel.js.map +1 -1
- package/dist/matter/order-delivery-address/order-delivery-address.d.ts +8 -18
- package/dist/matter/order-delivery-address/order-delivery-address.js +14 -23
- package/dist/matter/order-delivery-address/order-delivery-address.js.map +1 -1
- package/dist/matter/order-delivery-group/order-delivery-group.d.ts +40 -24
- package/dist/matter/order-delivery-group/order-delivery-group.js +64 -74
- package/dist/matter/order-delivery-group/order-delivery-group.js.map +1 -1
- package/dist/matter/order-details-header/order-details-header.d.ts +32 -15
- package/dist/matter/order-details-header/order-details-header.js +66 -58
- package/dist/matter/order-details-header/order-details-header.js.map +1 -1
- package/dist/matter/order-invoice-download/order-invoice-download.d.ts +78 -0
- package/dist/matter/order-invoice-download/order-invoice-download.js +173 -0
- package/dist/matter/order-invoice-download/order-invoice-download.js.map +1 -0
- package/dist/matter/order-list/order-list.d.ts +164 -19
- package/dist/matter/order-list/order-list.js +229 -87
- package/dist/matter/order-list/order-list.js.map +1 -1
- package/dist/matter/order-list-row/order-list-row.d.ts +6 -1
- package/dist/matter/order-list-row/order-list-row.js +3 -2
- package/dist/matter/order-list-row/order-list-row.js.map +1 -1
- package/dist/matter/order-list-search/order-list-search.d.ts +18 -26
- package/dist/matter/order-list-search/order-list-search.js +30 -69
- package/dist/matter/order-list-search/order-list-search.js.map +1 -1
- package/dist/matter/order-list-views/order-list-views.d.ts +15 -22
- package/dist/matter/order-list-views/order-list-views.js +22 -68
- package/dist/matter/order-list-views/order-list-views.js.map +1 -1
- package/dist/matter/order-payment/order-payment.d.ts +33 -10
- package/dist/matter/order-payment/order-payment.js +44 -39
- package/dist/matter/order-payment/order-payment.js.map +1 -1
- package/dist/matter/order-placed/order-placed-deliveries.d.ts +144 -12
- package/dist/matter/order-placed/order-placed-deliveries.js +115 -40
- package/dist/matter/order-placed/order-placed-deliveries.js.map +1 -1
- package/dist/matter/order-placed/order-placed.d.ts +198 -31
- package/dist/matter/order-placed/order-placed.js +230 -139
- package/dist/matter/order-placed/order-placed.js.map +1 -1
- package/dist/matter/order-placed-date/order-placed-date.d.ts +5 -8
- package/dist/matter/order-placed-date/order-placed-date.js +7 -8
- package/dist/matter/order-placed-date/order-placed-date.js.map +1 -1
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.d.ts +90 -17
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js +93 -117
- package/dist/matter/order-placed-payment-summary/order-placed-payment-summary.js.map +1 -1
- package/dist/matter/order-progress/order-progress.d.ts +19 -8
- package/dist/matter/order-progress/order-progress.js +37 -45
- package/dist/matter/order-progress/order-progress.js.map +1 -1
- package/dist/matter/order-summary/order-summary.d.ts +19 -9
- package/dist/matter/order-summary/order-summary.js +38 -44
- package/dist/matter/order-summary/order-summary.js.map +1 -1
- package/dist/matter/order-tracking-link/order-tracking-link.d.ts +43 -0
- package/dist/matter/order-tracking-link/order-tracking-link.js +107 -0
- package/dist/matter/order-tracking-link/order-tracking-link.js.map +1 -0
- package/dist/matter/payment/payment-card-capture.js +17 -10
- package/dist/matter/payment/payment-card-capture.js.map +1 -1
- package/dist/matter/payment/payment-controller.d.ts +4 -2
- package/dist/matter/payment/payment-controller.js +30 -9
- package/dist/matter/payment/payment-controller.js.map +1 -1
- package/dist/matter/payment/payment-method-badges.js +1 -1
- package/dist/matter/payment/payment.d.ts +69 -19
- package/dist/matter/payment/payment.js +101 -35
- package/dist/matter/payment/payment.js.map +1 -1
- package/dist/matter/payment/use-payment-method-selection.d.ts +25 -4
- package/dist/matter/payment/use-payment-method-selection.js +94 -32
- package/dist/matter/payment/use-payment-method-selection.js.map +1 -1
- package/dist/matter/payment/use-payment-submit-gate.d.ts +14 -3
- package/dist/matter/payment/use-payment-submit-gate.js +47 -8
- package/dist/matter/payment/use-payment-submit-gate.js.map +1 -1
- package/dist/matter/place-order/place-order.d.ts +171 -57
- package/dist/matter/place-order/place-order.js +376 -185
- package/dist/matter/place-order/place-order.js.map +1 -1
- package/dist/matter/pricing/pricing.d.ts +152 -13
- package/dist/matter/pricing/pricing.js +153 -52
- package/dist/matter/pricing/pricing.js.map +1 -1
- package/dist/matter/product-information/product-information.d.ts +27 -4
- package/dist/matter/product-information/product-information.js +32 -15
- package/dist/matter/product-information/product-information.js.map +1 -1
- package/dist/matter/product-list/product-list.d.ts +24 -6
- package/dist/matter/product-list/product-list.js +32 -26
- package/dist/matter/product-list/product-list.js.map +1 -1
- package/dist/matter/product-shelf/product-shelf.d.ts +1 -3
- package/dist/matter/product-shelf/product-shelf.js +2 -15
- package/dist/matter/product-shelf/product-shelf.js.map +1 -1
- package/dist/matter/region/region.d.ts +33 -16
- package/dist/matter/region/region.js +59 -52
- package/dist/matter/region/region.js.map +1 -1
- package/dist/matter/save-card/save-card.d.ts +43 -8
- package/dist/matter/save-card/save-card.js +61 -23
- package/dist/matter/save-card/save-card.js.map +1 -1
- package/dist/matter/saved-cards/saved-cards.d.ts +113 -21
- package/dist/matter/saved-cards/saved-cards.js +349 -77
- package/dist/matter/saved-cards/saved-cards.js.map +1 -1
- package/dist/matter/shipping-address/address-payload.js +25 -0
- package/dist/matter/shipping-address/address-payload.js.map +1 -0
- package/dist/matter/shipping-address/country-descriptors.js +71 -71
- package/dist/matter/shipping-address/country-descriptors.js.map +1 -1
- package/dist/matter/shipping-address/library-country-descriptors.js +136 -0
- package/dist/matter/shipping-address/library-country-descriptors.js.map +1 -0
- package/dist/matter/shipping-address/shipping-address.d.ts +312 -45
- package/dist/matter/shipping-address/shipping-address.js +443 -188
- package/dist/matter/shipping-address/shipping-address.js.map +1 -1
- package/dist/matter/shipping-simulator/shipping-simulator.d.ts +250 -24
- package/dist/matter/shipping-simulator/shipping-simulator.js +257 -51
- package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -1
- package/dist/matter/sign-in/sign-in.d.ts +108 -0
- package/dist/matter/sign-in/sign-in.js +285 -0
- package/dist/matter/sign-in/sign-in.js.map +1 -0
- package/dist/matter/sign-in-disclosure/sign-in-disclosure.d.ts +81 -0
- package/dist/matter/sign-in-disclosure/sign-in-disclosure.js +232 -0
- package/dist/matter/sign-in-disclosure/sign-in-disclosure.js.map +1 -0
- package/dist/matter/sign-in-form/sign-in-form.d.ts +93 -62
- package/dist/matter/sign-in-form/sign-in-form.js +134 -144
- package/dist/matter/sign-in-form/sign-in-form.js.map +1 -1
- package/dist/particles/binding-switcher/binding-switcher.d.ts +29 -8
- package/dist/particles/binding-switcher/binding-switcher.js +37 -26
- package/dist/particles/binding-switcher/binding-switcher.js.map +1 -1
- package/dist/particles/card-summary/card-summary.d.ts +38 -8
- package/dist/particles/card-summary/card-summary.js +55 -22
- package/dist/particles/card-summary/card-summary.js.map +1 -1
- package/dist/particles/carousel/carousel.d.ts +99 -11
- package/dist/particles/carousel/carousel.js +103 -35
- package/dist/particles/carousel/carousel.js.map +1 -1
- package/dist/particles/copy-text/copy-text.js +5 -15
- package/dist/particles/copy-text/copy-text.js.map +1 -1
- package/dist/particles/dialog/dialog.d.ts +14 -6
- package/dist/particles/dialog/dialog.js +6 -3
- package/dist/particles/dialog/dialog.js.map +1 -1
- package/dist/particles/drawer/drawer.js +1 -1
- package/dist/particles/drawer/drawer.js.map +1 -1
- package/dist/particles/email-field/email-field.d.ts +2 -1
- package/dist/particles/email-field/email-field.js +2 -1
- package/dist/particles/email-field/email-field.js.map +1 -1
- package/dist/particles/footer-link-group/footer-link-group.js +1 -0
- package/dist/particles/footer-link-group/footer-link-group.js.map +1 -1
- package/dist/particles/form/form.d.ts +85 -13
- package/dist/particles/form/form.js +91 -42
- package/dist/particles/form/form.js.map +1 -1
- package/dist/particles/gallery/gallery.d.ts +129 -12
- package/dist/particles/gallery/gallery.js +121 -34
- package/dist/particles/gallery/gallery.js.map +1 -1
- package/dist/particles/order-details-back/order-details-back.d.ts +5 -3
- package/dist/particles/order-details-back/order-details-back.js +8 -10
- package/dist/particles/order-details-back/order-details-back.js.map +1 -1
- package/dist/particles/order-status-badge/order-status-badge.d.ts +3 -3
- package/dist/particles/order-status-badge/order-status-badge.js +4 -20
- package/dist/particles/order-status-badge/order-status-badge.js.map +1 -1
- package/dist/particles/password-field/password-field.d.ts +1 -1
- package/dist/particles/password-field/password-field.js +2 -4
- package/dist/particles/password-field/password-field.js.map +1 -1
- package/dist/particles/phone-field/phone-field.d.ts +4 -4
- package/dist/particles/phone-field/phone-field.js +8 -11
- package/dist/particles/phone-field/phone-field.js.map +1 -1
- package/dist/particles/spinner/spinner.d.ts +24 -4
- package/dist/particles/spinner/spinner.js +25 -9
- package/dist/particles/spinner/spinner.js.map +1 -1
- package/dist/particles/switch/switch.d.ts +4 -1
- package/dist/particles/switch/switch.js +3 -1
- package/dist/particles/switch/switch.js.map +1 -1
- package/dist/particles/toast/toast.d.ts +29 -3
- package/dist/particles/toast/toast.js +34 -10
- package/dist/particles/toast/toast.js.map +1 -1
- package/dist/schema.graphql +164 -56
- package/dist/sdk/address/address-fields.js +4 -4
- package/dist/sdk/address/address-fields.js.map +1 -1
- package/dist/sdk/address/constants.js +1 -6
- package/dist/sdk/address/constants.js.map +1 -1
- package/dist/sdk/address/messages.js +44 -44
- package/dist/sdk/address/messages.js.map +1 -1
- package/dist/sdk/address/postal-code.js +15 -2
- package/dist/sdk/address/postal-code.js.map +1 -1
- package/dist/sdk/address/types.d.ts +5 -3
- package/dist/sdk/address/validate-address.js +3 -3
- package/dist/sdk/address/validate-address.js.map +1 -1
- package/dist/sdk/analytics/use-analytics-actions.d.ts +1 -1
- package/dist/sdk/analytics/use-analytics-actions.js.map +1 -1
- package/dist/sdk/cart/use-cart-actions.js.map +1 -1
- package/dist/sdk/data/index.js +2 -2
- package/dist/sdk/data/reactive-list-item-data-provider.js +2 -2
- package/dist/sdk/generated/gql.js +1 -1
- package/dist/sdk/generated/gql.js.map +1 -1
- package/dist/sdk/generated/graphql.d.ts +20 -5
- package/dist/sdk/generated/graphql.js +6 -0
- package/dist/sdk/generated/graphql.js.map +1 -1
- package/dist/sdk/i18n/format-error-code.js +23 -0
- package/dist/sdk/i18n/format-error-code.js.map +1 -0
- package/dist/sdk/i18n/message-formatter.d.ts +22 -0
- package/dist/sdk/i18n/message-formatter.js +140 -0
- package/dist/sdk/i18n/message-formatter.js.map +1 -0
- package/dist/sdk/i18n/use-message-formatter.d.ts +8 -0
- package/dist/sdk/i18n/use-message-formatter.js +18 -0
- package/dist/sdk/i18n/use-message-formatter.js.map +1 -0
- package/dist/sdk/identity/use-identity-actions.js.map +1 -1
- package/dist/sdk/navigation/redirect.d.ts +2 -0
- package/dist/sdk/navigation/redirect.js +19 -1
- package/dist/sdk/navigation/redirect.js.map +1 -1
- package/dist/sdk/navigation/types.d.ts +13 -0
- package/dist/sdk/payment/bin-format.js +21 -0
- package/dist/sdk/payment/bin-format.js.map +1 -0
- package/dist/sdk/payment/challenge-return.js +37 -0
- package/dist/sdk/payment/challenge-return.js.map +1 -0
- package/dist/sdk/payment/confirmation-last-four.js +39 -0
- package/dist/sdk/payment/confirmation-last-four.js.map +1 -0
- package/dist/sdk/payment/gateway.d.ts +1 -1
- package/dist/sdk/payment/gateway.js +8 -2
- package/dist/sdk/payment/gateway.js.map +1 -1
- package/dist/sdk/payment/operations.d.ts +1 -0
- package/dist/sdk/payment/operations.js +28 -6
- package/dist/sdk/payment/operations.js.map +1 -1
- package/dist/sdk/payment/resumed-purchase.d.ts +1 -0
- package/dist/sdk/payment/resumed-purchase.js +119 -0
- package/dist/sdk/payment/resumed-purchase.js.map +1 -0
- package/dist/sdk/payment/security-code-mask.js +16 -23
- package/dist/sdk/payment/security-code-mask.js.map +1 -1
- package/dist/sdk/payment/submission-registry.js +6 -2
- package/dist/sdk/payment/submission-registry.js.map +1 -1
- package/dist/sdk/payment/use-payment-actions.d.ts +18 -3
- package/dist/sdk/payment/use-payment-actions.js +23 -4
- package/dist/sdk/payment/use-payment-actions.js.map +1 -1
- package/dist/sdk/payment/use-place-order.d.ts +10 -2
- package/dist/sdk/payment/use-place-order.js +138 -76
- package/dist/sdk/payment/use-place-order.js.map +1 -1
- package/dist/sdk/provider/storefront-provider.d.ts +1 -7
- package/dist/sdk/provider/storefront-provider.js +4 -11
- package/dist/sdk/provider/storefront-provider.js.map +1 -1
- package/dist/sdk/seo/entity-landing.d.ts +24 -0
- package/dist/sdk/seo/entity-landing.js +30 -0
- package/dist/sdk/seo/entity-landing.js.map +1 -0
- package/dist/sdk/seo/page-alternates.d.ts +3 -2
- package/dist/sdk/seo/page-alternates.js +4 -2
- package/dist/sdk/seo/page-alternates.js.map +1 -1
- package/dist/sdk/seo/search-landing.d.ts +42 -0
- package/dist/sdk/seo/search-landing.js +85 -0
- package/dist/sdk/seo/search-landing.js.map +1 -0
- package/dist/sdk/session/mock-session.d.ts +9 -0
- package/dist/sdk/session/mock-session.js +31 -0
- package/dist/sdk/session/mock-session.js.map +1 -0
- package/dist/sdk/session/read-server-session.d.ts +3 -0
- package/dist/sdk/session/read-server-session.js +5 -0
- package/dist/sdk/session/read-server-session.js.map +1 -1
- package/dist/sdk/session/return-path-segment.d.ts +10 -0
- package/dist/sdk/session/return-path-segment.js +15 -0
- package/dist/sdk/session/return-path-segment.js.map +1 -0
- package/dist/sdk/session/use-session-actions.js.map +1 -1
- package/dist/sdk/shipping/use-cart-shipping-simulation.js.map +1 -1
- package/dist/sdk/shipping/use-shipping-actions.js.map +1 -1
- package/dist/sdk/shipping/use-shipping-simulation.js.map +1 -1
- package/dist/utils/safe-href.d.ts +2 -0
- package/package.json +4 -3
- package/skills/storefront-asset/SKILL.md +2 -2
- package/skills/storefront-asset/references/api-side.md +27 -14
- package/skills/storefront-asset/references/findings.md +5 -2
- package/src/styles/tailwind.css +8 -0
- package/dist/matter/shipping-address/country-descriptors.d.ts +0 -1
- package/dist/message-locales.json +0 -7
- package/dist/sdk/i18n/client.d.ts +0 -4
- package/dist/sdk/i18n/client.js +0 -4
- package/dist/sdk/i18n/locales.d.ts +0 -8
- package/dist/sdk/i18n/locales.js +0 -57
- package/dist/sdk/i18n/locales.js.map +0 -1
- package/dist/sdk/i18n/messages/en-US.js +0 -183
- package/dist/sdk/i18n/messages/en-US.js.map +0 -1
- package/dist/sdk/i18n/messages/en-US.json +0 -178
- package/dist/sdk/i18n/messages/en-US.json.d.ts +0 -182
- package/dist/sdk/i18n/messages/es-ES.js +0 -183
- package/dist/sdk/i18n/messages/es-ES.js.map +0 -1
- package/dist/sdk/i18n/messages/es-ES.json +0 -178
- package/dist/sdk/i18n/messages/pt-BR.js +0 -183
- package/dist/sdk/i18n/messages/pt-BR.js.map +0 -1
- package/dist/sdk/i18n/messages/pt-BR.json +0 -178
- package/dist/sdk/i18n/provider.d.ts +0 -1
- package/dist/sdk/i18n/provider.js +0 -30
- package/dist/sdk/i18n/provider.js.map +0 -1
- package/dist/sdk/i18n/server.d.ts +0 -28
- package/dist/sdk/i18n/server.js +0 -59
- package/dist/sdk/i18n/server.js.map +0 -1
- package/dist/utils/resolve-authored-copy.js +0 -18
- package/dist/utils/resolve-authored-copy.js.map +0 -1
- package/dist/utils/substitute-template.js +0 -33
- package/dist/utils/substitute-template.js.map +0 -1
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { defineComponent } from "../../core/dist/define-component.js";
|
|
3
|
+
import { defineContentType } from "../../core/dist/define-content-type.js";
|
|
3
4
|
import "../../core/dist/index.js";
|
|
5
|
+
import { useStorefrontFormatters } from "../../sdk/format/client.js";
|
|
6
|
+
import { useMessageFormatter } from "../../sdk/i18n/use-message-formatter.js";
|
|
4
7
|
import { Field, FieldBinding, FieldsetFieldContext, readBaseline, useFieldsetField, useFieldsetFieldNames, useNoAncestorFieldset } from "../../particles/field/field.js";
|
|
5
8
|
import { useActionsOverride } from "../../sdk/actions/actions-override-context.js";
|
|
9
|
+
import { formatErrorCode } from "../../sdk/i18n/format-error-code.js";
|
|
6
10
|
import { useDataOverride } from "../../sdk/data/data-override-context.js";
|
|
7
|
-
import { resolveAuthoredCopy } from "../../utils/resolve-authored-copy.js";
|
|
8
|
-
import { useFormRegistry } from "../../particles/form/form.js";
|
|
9
11
|
import { useEntityDataResolved } from "../../sdk/data/entity-resolution-context.js";
|
|
10
12
|
import { useReactiveDataSettled } from "../../sdk/data/use-reactive-data-settled.js";
|
|
13
|
+
import { countryDisplayName } from "../../sdk/address/country-display.js";
|
|
14
|
+
import { useFormRegistry } from "../../particles/form/form.js";
|
|
11
15
|
import { Fieldset } from "../../particles/fieldset/fieldset.js";
|
|
16
|
+
import { normalizeAddressField, pickActiveTextFields } from "./address-payload.js";
|
|
17
|
+
import { LIBRARY_COUNTRIES, useLibraryCountryDescriptors } from "./library-country-descriptors.js";
|
|
12
18
|
import { getAvailableCountries, getCountryDescriptor } from "./country-descriptors.js";
|
|
13
19
|
import { FieldSelect } from "../../particles/select/field-select.js";
|
|
14
|
-
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
20
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
15
21
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
16
22
|
import { useFormContext, useWatch } from "react-hook-form";
|
|
17
23
|
//#region src/matter/shipping-address/shipping-address.tsx
|
|
@@ -94,15 +100,23 @@ const FIELD_AUTOCOMPLETE = {
|
|
|
94
100
|
state: "address-level1"
|
|
95
101
|
};
|
|
96
102
|
/**
|
|
97
|
-
*
|
|
98
|
-
* declaration of the baseline. The blank check it used to hand-write alongside lives
|
|
99
|
-
* `resolveRequiredness` now, installed for every bound control rather than only for this one.
|
|
103
|
+
* Words the descriptor's structural `rule` with the form's messages, under a generated `required`, which is
|
|
104
|
+
* this fieldset's whole declaration of the baseline. The blank check it used to hand-write alongside lives
|
|
105
|
+
* in `resolveRequiredness` now, installed for every bound control rather than only for this one.
|
|
100
106
|
*/
|
|
101
|
-
function
|
|
102
|
-
|
|
107
|
+
function textOf(value) {
|
|
108
|
+
return typeof value === "string" ? value : "";
|
|
109
|
+
}
|
|
110
|
+
function buildRule(field, requiredMessage, invalidMessage) {
|
|
111
|
+
const pattern = field.rule?.pattern;
|
|
112
|
+
const validate = field.rule?.validate;
|
|
103
113
|
return {
|
|
104
|
-
|
|
105
|
-
|
|
114
|
+
pattern: pattern ? {
|
|
115
|
+
value: pattern,
|
|
116
|
+
message: invalidMessage
|
|
117
|
+
} : void 0,
|
|
118
|
+
validate: validate ? (value) => validate(textOf(value)) || invalidMessage || false : void 0,
|
|
119
|
+
required: field.required ? requiredMessage : void 0
|
|
106
120
|
};
|
|
107
121
|
}
|
|
108
122
|
/** Keeps only the AddressDraft keys `values` actually defines — a field no control composed is absent, not `undefined`. */
|
|
@@ -114,6 +128,285 @@ function pickDefinedAddressFields(values) {
|
|
|
114
128
|
}
|
|
115
129
|
return result;
|
|
116
130
|
}
|
|
131
|
+
const ShippingAddressFieldsetContent = defineContentType({
|
|
132
|
+
id: "shipping-address-fieldset",
|
|
133
|
+
title: "Shipping Address Fieldset",
|
|
134
|
+
description: "Announcements and accessible name of the delivery address group, and its required-field message.",
|
|
135
|
+
schema: {
|
|
136
|
+
type: "object",
|
|
137
|
+
additionalProperties: false,
|
|
138
|
+
properties: {
|
|
139
|
+
loadingLabel: {
|
|
140
|
+
type: "string",
|
|
141
|
+
title: "Loading announcement",
|
|
142
|
+
description: "Announced politely while the address resolves.",
|
|
143
|
+
format: "icu-message",
|
|
144
|
+
messageSource: "Loading your delivery address"
|
|
145
|
+
},
|
|
146
|
+
loadedLabel: {
|
|
147
|
+
type: "string",
|
|
148
|
+
title: "Loaded announcement",
|
|
149
|
+
description: "Announced politely once the fields mount.",
|
|
150
|
+
format: "icu-message",
|
|
151
|
+
messageSource: "Your delivery address is ready"
|
|
152
|
+
},
|
|
153
|
+
groupLabel: {
|
|
154
|
+
type: "string",
|
|
155
|
+
title: "Accessible group name",
|
|
156
|
+
description: "A composed FieldsetLegend wins over it.",
|
|
157
|
+
format: "icu-message",
|
|
158
|
+
messageSource: "Your delivery address",
|
|
159
|
+
messageOptional: true
|
|
160
|
+
},
|
|
161
|
+
requiredMessage: {
|
|
162
|
+
type: "string",
|
|
163
|
+
title: "Required field message",
|
|
164
|
+
description: "Shown under a required field left blank; label is that field's label.",
|
|
165
|
+
format: "icu-message",
|
|
166
|
+
messageSource: "{label} is required",
|
|
167
|
+
messageArguments: {
|
|
168
|
+
type: "object",
|
|
169
|
+
properties: { label: { type: "string" } }
|
|
170
|
+
},
|
|
171
|
+
messageExample: { label: "recipient name" }
|
|
172
|
+
},
|
|
173
|
+
missingRecipientNameMessage: {
|
|
174
|
+
type: "string",
|
|
175
|
+
title: "Missing recipient name message",
|
|
176
|
+
description: "Shown by FormError when the server refuses a blank recipient name.",
|
|
177
|
+
format: "icu-message",
|
|
178
|
+
messageSource: "Enter the recipient's name."
|
|
179
|
+
},
|
|
180
|
+
invalidPostalCodeMessage: {
|
|
181
|
+
type: "string",
|
|
182
|
+
title: "Invalid postal code message",
|
|
183
|
+
description: "Shown by FormError when the server refuses the postal code.",
|
|
184
|
+
format: "icu-message",
|
|
185
|
+
messageSource: "Enter a valid postal code."
|
|
186
|
+
},
|
|
187
|
+
invalidAddressMessage: {
|
|
188
|
+
type: "string",
|
|
189
|
+
title: "Invalid address message",
|
|
190
|
+
description: "Shown by FormError when the server refuses the address.",
|
|
191
|
+
format: "icu-message",
|
|
192
|
+
messageSource: "Check the address and try again."
|
|
193
|
+
},
|
|
194
|
+
genericErrorMessage: {
|
|
195
|
+
type: "string",
|
|
196
|
+
title: "Generic error message",
|
|
197
|
+
description: "Shown by FormError for a network failure or a refusal the shopper cannot fix.",
|
|
198
|
+
format: "icu-message",
|
|
199
|
+
messageSource: "Unable to save your delivery address. Please try again."
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
/**
|
|
205
|
+
* The message for each refusal of the address write: every `ShippingAddressUpdateErrorCode` plus the
|
|
206
|
+
* client-minted transport failure. `dispatch` hands `FormError` this copy, never the server's English
|
|
207
|
+
* `message`: a code this map does not know shows genericErrorMessage.
|
|
208
|
+
*/
|
|
209
|
+
const SHIPPING_ADDRESS_FIELDSET_ERROR_FIELDS = {
|
|
210
|
+
MISSING_RECIPIENT_NAME: "missingRecipientNameMessage",
|
|
211
|
+
INVALID_POSTAL_CODE: "invalidPostalCodeMessage",
|
|
212
|
+
INVALID_ADDRESS: "invalidAddressMessage",
|
|
213
|
+
MISSING_CART_CONTEXT: "genericErrorMessage",
|
|
214
|
+
CART_NOT_FOUND: "genericErrorMessage",
|
|
215
|
+
INVALID_SAVED_ADDRESS_ID: "genericErrorMessage",
|
|
216
|
+
INVALID_COUNTRY_CODE: "genericErrorMessage",
|
|
217
|
+
NETWORK_ERROR: "genericErrorMessage"
|
|
218
|
+
};
|
|
219
|
+
function wordShippingAddressError(error, { format }) {
|
|
220
|
+
return {
|
|
221
|
+
code: error.code,
|
|
222
|
+
message: formatErrorCode(ShippingAddressFieldsetContent, SHIPPING_ADDRESS_FIELDSET_ERROR_FIELDS, error, format, "genericErrorMessage")
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
const ShippingAddressRecipientNameContent = defineContentType({
|
|
226
|
+
id: "shipping-address-recipient-name",
|
|
227
|
+
title: "Shipping Address Recipient Name",
|
|
228
|
+
description: "Label of the recipient name field of the delivery address.",
|
|
229
|
+
schema: {
|
|
230
|
+
type: "object",
|
|
231
|
+
additionalProperties: false,
|
|
232
|
+
properties: { label: {
|
|
233
|
+
type: "string",
|
|
234
|
+
title: "Field label",
|
|
235
|
+
format: "icu-message",
|
|
236
|
+
messageSource: "recipient name"
|
|
237
|
+
} }
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
const ShippingAddressStreetContent = defineContentType({
|
|
241
|
+
id: "shipping-address-street",
|
|
242
|
+
title: "Shipping Address Street",
|
|
243
|
+
description: "Label of the street field of the delivery address.",
|
|
244
|
+
schema: {
|
|
245
|
+
type: "object",
|
|
246
|
+
additionalProperties: false,
|
|
247
|
+
properties: { label: {
|
|
248
|
+
type: "string",
|
|
249
|
+
title: "Field label",
|
|
250
|
+
format: "icu-message",
|
|
251
|
+
messageSource: "street"
|
|
252
|
+
} }
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
const ShippingAddressNumberContent = defineContentType({
|
|
256
|
+
id: "shipping-address-number",
|
|
257
|
+
title: "Shipping Address Number",
|
|
258
|
+
description: "Label of the number field of the delivery address.",
|
|
259
|
+
schema: {
|
|
260
|
+
type: "object",
|
|
261
|
+
additionalProperties: false,
|
|
262
|
+
properties: { label: {
|
|
263
|
+
type: "string",
|
|
264
|
+
title: "Field label",
|
|
265
|
+
format: "icu-message",
|
|
266
|
+
messageSource: "number"
|
|
267
|
+
} }
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
const ShippingAddressComplementContent = defineContentType({
|
|
271
|
+
id: "shipping-address-complement",
|
|
272
|
+
title: "Shipping Address Complement",
|
|
273
|
+
description: "Label of the complement field of the delivery address.",
|
|
274
|
+
schema: {
|
|
275
|
+
type: "object",
|
|
276
|
+
additionalProperties: false,
|
|
277
|
+
properties: { label: {
|
|
278
|
+
type: "string",
|
|
279
|
+
title: "Field label",
|
|
280
|
+
format: "icu-message",
|
|
281
|
+
messageSource: "apartment, suite, etc. (optional)"
|
|
282
|
+
} }
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
const ShippingAddressNeighborhoodContent = defineContentType({
|
|
286
|
+
id: "shipping-address-neighborhood",
|
|
287
|
+
title: "Shipping Address Neighborhood",
|
|
288
|
+
description: "Label of the neighborhood field of the delivery address.",
|
|
289
|
+
schema: {
|
|
290
|
+
type: "object",
|
|
291
|
+
additionalProperties: false,
|
|
292
|
+
properties: { label: {
|
|
293
|
+
type: "string",
|
|
294
|
+
title: "Field label",
|
|
295
|
+
format: "icu-message",
|
|
296
|
+
messageSource: "neighborhood"
|
|
297
|
+
} }
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
const ShippingAddressCityContent = defineContentType({
|
|
301
|
+
id: "shipping-address-city",
|
|
302
|
+
title: "Shipping Address City",
|
|
303
|
+
description: "Label of the city field of the delivery address.",
|
|
304
|
+
schema: {
|
|
305
|
+
type: "object",
|
|
306
|
+
additionalProperties: false,
|
|
307
|
+
properties: { label: {
|
|
308
|
+
type: "string",
|
|
309
|
+
title: "Field label",
|
|
310
|
+
format: "icu-message",
|
|
311
|
+
messageSource: "city"
|
|
312
|
+
} }
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
const ShippingAddressStateContent = defineContentType({
|
|
316
|
+
id: "shipping-address-state",
|
|
317
|
+
title: "Shipping Address State",
|
|
318
|
+
description: "Label of the state field of the delivery address, worded per country.",
|
|
319
|
+
schema: {
|
|
320
|
+
type: "object",
|
|
321
|
+
additionalProperties: false,
|
|
322
|
+
properties: { label: {
|
|
323
|
+
type: "string",
|
|
324
|
+
title: "Field label",
|
|
325
|
+
description: "country is the active country (ISO 3166-1 alpha-3).",
|
|
326
|
+
format: "icu-message",
|
|
327
|
+
messageSource: "{country, select, CAN {province} other {state}}",
|
|
328
|
+
messageArguments: {
|
|
329
|
+
type: "object",
|
|
330
|
+
properties: { country: {
|
|
331
|
+
type: "string",
|
|
332
|
+
enum: [
|
|
333
|
+
"BRA",
|
|
334
|
+
"USA",
|
|
335
|
+
"CAN",
|
|
336
|
+
"MEX"
|
|
337
|
+
]
|
|
338
|
+
} }
|
|
339
|
+
},
|
|
340
|
+
messageExample: { country: "CAN" }
|
|
341
|
+
} }
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
const ShippingAddressPostalCodeContent = defineContentType({
|
|
345
|
+
id: "shipping-address-postal-code",
|
|
346
|
+
title: "Shipping Address Postal Code",
|
|
347
|
+
description: "Label of the postal code field of the delivery address and its format message, worded per country.",
|
|
348
|
+
schema: {
|
|
349
|
+
type: "object",
|
|
350
|
+
additionalProperties: false,
|
|
351
|
+
properties: {
|
|
352
|
+
label: {
|
|
353
|
+
type: "string",
|
|
354
|
+
title: "Field label",
|
|
355
|
+
description: "country is the active country (ISO 3166-1 alpha-3).",
|
|
356
|
+
format: "icu-message",
|
|
357
|
+
messageSource: "{country, select, USA {zip code} other {postal code}}",
|
|
358
|
+
messageArguments: {
|
|
359
|
+
type: "object",
|
|
360
|
+
properties: { country: {
|
|
361
|
+
type: "string",
|
|
362
|
+
enum: [
|
|
363
|
+
"BRA",
|
|
364
|
+
"USA",
|
|
365
|
+
"CAN",
|
|
366
|
+
"MEX"
|
|
367
|
+
]
|
|
368
|
+
} }
|
|
369
|
+
},
|
|
370
|
+
messageExample: { country: "USA" }
|
|
371
|
+
},
|
|
372
|
+
invalidMessage: {
|
|
373
|
+
type: "string",
|
|
374
|
+
title: "Invalid postal code message",
|
|
375
|
+
description: "Shown under a postal code not in the active country's format. Never contains the typed value.",
|
|
376
|
+
format: "icu-message",
|
|
377
|
+
messageSource: "{country, select, USA {invalid zip code} other {invalid postal code}}",
|
|
378
|
+
messageArguments: {
|
|
379
|
+
type: "object",
|
|
380
|
+
properties: { country: {
|
|
381
|
+
type: "string",
|
|
382
|
+
enum: [
|
|
383
|
+
"BRA",
|
|
384
|
+
"USA",
|
|
385
|
+
"CAN",
|
|
386
|
+
"MEX"
|
|
387
|
+
]
|
|
388
|
+
} }
|
|
389
|
+
},
|
|
390
|
+
messageExample: { country: "USA" }
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
const ShippingAddressCountryContent = defineContentType({
|
|
396
|
+
id: "shipping-address-country",
|
|
397
|
+
title: "Shipping Address Country",
|
|
398
|
+
description: "Label of the country selector of the delivery address.",
|
|
399
|
+
schema: {
|
|
400
|
+
type: "object",
|
|
401
|
+
additionalProperties: false,
|
|
402
|
+
properties: { label: {
|
|
403
|
+
type: "string",
|
|
404
|
+
title: "Field label",
|
|
405
|
+
format: "icu-message",
|
|
406
|
+
messageSource: "country"
|
|
407
|
+
} }
|
|
408
|
+
}
|
|
409
|
+
});
|
|
117
410
|
const ShippingAddressFieldsetDefinition = defineComponent({
|
|
118
411
|
name: "ShippingAddressFieldset",
|
|
119
412
|
importPath: "@vtex/faststore/components",
|
|
@@ -124,6 +417,7 @@ const ShippingAddressFieldsetDefinition = defineComponent({
|
|
|
124
417
|
actions: { shipping: ["setAddress"] },
|
|
125
418
|
requiresContext: "form",
|
|
126
419
|
providesContext: "shipping-address",
|
|
420
|
+
content: ShippingAddressFieldsetContent,
|
|
127
421
|
editor: {
|
|
128
422
|
label: "Shipping Address Fieldset",
|
|
129
423
|
category: "commerce"
|
|
@@ -138,217 +432,160 @@ const ShippingAddressFieldsetDefinition = defineComponent({
|
|
|
138
432
|
type: "number",
|
|
139
433
|
default: 9,
|
|
140
434
|
label: "Skeleton rows"
|
|
141
|
-
},
|
|
142
|
-
loadingLabel: {
|
|
143
|
-
type: "string",
|
|
144
|
-
default: "Loading your delivery address",
|
|
145
|
-
label: "Loading announcement"
|
|
146
|
-
},
|
|
147
|
-
loadedLabel: {
|
|
148
|
-
type: "string",
|
|
149
|
-
default: "Your delivery address is ready",
|
|
150
|
-
label: "Loaded announcement"
|
|
151
|
-
},
|
|
152
|
-
groupLabel: {
|
|
153
|
-
type: "string",
|
|
154
|
-
default: "Your delivery address",
|
|
155
|
-
label: "Accessible group name"
|
|
156
435
|
}
|
|
157
436
|
},
|
|
158
|
-
guideline: "Composable delivery-address entity: registers under \"shippingAddress\" with the enclosing FormRoot and dispatches shipping.setAddress only when the shopper changed something. Compose the nine ShippingAddress*Control parts inside it; place FormSubmit/FormEnterSubmit/FormError as siblings of the fieldset, not inside it — this fieldset renders no submit or error part of its own. The Controls mount only once the address has resolved, with skeletonCount placeholder rows in their place until then — set it to the number of Controls composed, or the form jumps by the difference. Style the announcement sr-only. groupLabel names the group as its accessible name; blank emits no aria-label, and a composed FieldsetLegend wins over it. See shipping-address.md."
|
|
437
|
+
guideline: "Composable delivery-address entity: registers under \"shippingAddress\" with the enclosing FormRoot and dispatches shipping.setAddress only when the shopper changed something. Compose the nine ShippingAddress*Control parts inside it; place FormSubmit/FormEnterSubmit/FormError as siblings of the fieldset, not inside it — this fieldset renders no submit or error part of its own. The Controls mount only once the address has resolved, with skeletonCount placeholder rows in their place until then — set it to the number of Controls composed, or the form jumps by the difference. Style the announcement sr-only; its two messages are the $content fields loadingLabel and loadedLabel. The $content field groupLabel names the group as its accessible name; blank emits no aria-label, and a composed FieldsetLegend wins over it. A required field left blank shows the $content field requiredMessage, whose label argument is the label of that field. See shipping-address.md."
|
|
159
438
|
});
|
|
160
|
-
const ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX = "Must be a descendant of ShippingAddressFieldset, which provides the shipping-address context this control requires. Recomposable: compose Field.Label, Field.Control and Field.Error as children, in any order, to reorder or extend the anatomy; a childless composition keeps the default label-control-error order.";
|
|
439
|
+
const ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX = "Its label is the $content field label. Must be a descendant of ShippingAddressFieldset, which provides the shipping-address context this control requires. Recomposable: compose Field.Label, Field.Control and Field.Error as children, in any order, to reorder or extend the anatomy; a childless composition keeps the default label-control-error order.";
|
|
161
440
|
const ShippingAddressRecipientNameControlDefinition = defineComponent({
|
|
162
441
|
name: "ShippingAddressRecipientNameControl",
|
|
163
442
|
importPath: "@vtex/faststore/components",
|
|
164
443
|
component: ShippingAddressRecipientNameControl,
|
|
444
|
+
content: ShippingAddressRecipientNameContent,
|
|
165
445
|
requiresContext: "shipping-address",
|
|
166
446
|
providesContext: "field",
|
|
167
447
|
editor: {
|
|
168
448
|
label: "Recipient Name Control",
|
|
169
449
|
category: "action"
|
|
170
450
|
},
|
|
171
|
-
schema: {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
},
|
|
176
|
-
placeholder: {
|
|
177
|
-
type: "string",
|
|
178
|
-
label: "Placeholder"
|
|
179
|
-
}
|
|
180
|
-
},
|
|
451
|
+
schema: { placeholder: {
|
|
452
|
+
type: "string",
|
|
453
|
+
label: "Placeholder"
|
|
454
|
+
} },
|
|
181
455
|
guideline: `Recipient-name input field; required for submit. ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`
|
|
182
456
|
});
|
|
183
457
|
const ShippingAddressStreetControlDefinition = defineComponent({
|
|
184
458
|
name: "ShippingAddressStreetControl",
|
|
185
459
|
importPath: "@vtex/faststore/components",
|
|
186
460
|
component: ShippingAddressStreetControl,
|
|
461
|
+
content: ShippingAddressStreetContent,
|
|
187
462
|
requiresContext: "shipping-address",
|
|
188
463
|
providesContext: "field",
|
|
189
464
|
editor: {
|
|
190
465
|
label: "Street Control",
|
|
191
466
|
category: "action"
|
|
192
467
|
},
|
|
193
|
-
schema: {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
},
|
|
198
|
-
placeholder: {
|
|
199
|
-
type: "string",
|
|
200
|
-
label: "Placeholder"
|
|
201
|
-
}
|
|
202
|
-
},
|
|
468
|
+
schema: { placeholder: {
|
|
469
|
+
type: "string",
|
|
470
|
+
label: "Placeholder"
|
|
471
|
+
} },
|
|
203
472
|
guideline: `Street name input field. ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`
|
|
204
473
|
});
|
|
205
474
|
const ShippingAddressNumberControlDefinition = defineComponent({
|
|
206
475
|
name: "ShippingAddressNumberControl",
|
|
207
476
|
importPath: "@vtex/faststore/components",
|
|
208
477
|
component: ShippingAddressNumberControl,
|
|
478
|
+
content: ShippingAddressNumberContent,
|
|
209
479
|
requiresContext: "shipping-address",
|
|
210
480
|
providesContext: "field",
|
|
211
481
|
editor: {
|
|
212
482
|
label: "Number Control",
|
|
213
483
|
category: "action"
|
|
214
484
|
},
|
|
215
|
-
schema: {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
},
|
|
220
|
-
placeholder: {
|
|
221
|
-
type: "string",
|
|
222
|
-
label: "Placeholder"
|
|
223
|
-
}
|
|
224
|
-
},
|
|
485
|
+
schema: { placeholder: {
|
|
486
|
+
type: "string",
|
|
487
|
+
label: "Placeholder"
|
|
488
|
+
} },
|
|
225
489
|
guideline: `Street number input field. ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`
|
|
226
490
|
});
|
|
227
491
|
const ShippingAddressCityControlDefinition = defineComponent({
|
|
228
492
|
name: "ShippingAddressCityControl",
|
|
229
493
|
importPath: "@vtex/faststore/components",
|
|
230
494
|
component: ShippingAddressCityControl,
|
|
495
|
+
content: ShippingAddressCityContent,
|
|
231
496
|
requiresContext: "shipping-address",
|
|
232
497
|
providesContext: "field",
|
|
233
498
|
editor: {
|
|
234
499
|
label: "City Control",
|
|
235
500
|
category: "action"
|
|
236
501
|
},
|
|
237
|
-
schema: {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
},
|
|
242
|
-
placeholder: {
|
|
243
|
-
type: "string",
|
|
244
|
-
label: "Placeholder"
|
|
245
|
-
}
|
|
246
|
-
},
|
|
502
|
+
schema: { placeholder: {
|
|
503
|
+
type: "string",
|
|
504
|
+
label: "Placeholder"
|
|
505
|
+
} },
|
|
247
506
|
guideline: `City name input field. ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`
|
|
248
507
|
});
|
|
249
508
|
const ShippingAddressStateControlDefinition = defineComponent({
|
|
250
509
|
name: "ShippingAddressStateControl",
|
|
251
510
|
importPath: "@vtex/faststore/components",
|
|
252
511
|
component: ShippingAddressStateControl,
|
|
512
|
+
content: ShippingAddressStateContent,
|
|
253
513
|
requiresContext: "shipping-address",
|
|
254
514
|
providesContext: "field",
|
|
255
515
|
editor: {
|
|
256
516
|
label: "State Control",
|
|
257
517
|
category: "action"
|
|
258
518
|
},
|
|
259
|
-
schema: {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
placeholder: {
|
|
265
|
-
type: "string",
|
|
266
|
-
label: "Placeholder"
|
|
267
|
-
}
|
|
268
|
-
},
|
|
269
|
-
guideline: `State/province input field. ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`
|
|
519
|
+
schema: { placeholder: {
|
|
520
|
+
type: "string",
|
|
521
|
+
label: "Placeholder"
|
|
522
|
+
} },
|
|
523
|
+
guideline: `State/province input field; its label takes the active country as the country select argument. ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`
|
|
270
524
|
});
|
|
271
525
|
const ShippingAddressPostalCodeControlDefinition = defineComponent({
|
|
272
526
|
name: "ShippingAddressPostalCodeControl",
|
|
273
527
|
importPath: "@vtex/faststore/components",
|
|
274
528
|
component: ShippingAddressPostalCodeControl,
|
|
529
|
+
content: ShippingAddressPostalCodeContent,
|
|
275
530
|
requiresContext: "shipping-address",
|
|
276
531
|
providesContext: "field",
|
|
277
532
|
editor: {
|
|
278
533
|
label: "Postal Code Control",
|
|
279
534
|
category: "action"
|
|
280
535
|
},
|
|
281
|
-
schema: {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
placeholder: {
|
|
287
|
-
type: "string",
|
|
288
|
-
label: "Placeholder"
|
|
289
|
-
}
|
|
290
|
-
},
|
|
291
|
-
guideline: `Postal code input field. ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`
|
|
536
|
+
schema: { placeholder: {
|
|
537
|
+
type: "string",
|
|
538
|
+
label: "Placeholder"
|
|
539
|
+
} },
|
|
540
|
+
guideline: `Postal code input field; its label and invalidMessage take the active country as the country select argument. ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`
|
|
292
541
|
});
|
|
293
542
|
const ShippingAddressComplementControlDefinition = defineComponent({
|
|
294
543
|
name: "ShippingAddressComplementControl",
|
|
295
544
|
importPath: "@vtex/faststore/components",
|
|
296
545
|
component: ShippingAddressComplementControl,
|
|
546
|
+
content: ShippingAddressComplementContent,
|
|
297
547
|
requiresContext: "shipping-address",
|
|
298
548
|
providesContext: "field",
|
|
299
549
|
editor: {
|
|
300
550
|
label: "Complement Control",
|
|
301
551
|
category: "action"
|
|
302
552
|
},
|
|
303
|
-
schema: {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
},
|
|
308
|
-
placeholder: {
|
|
309
|
-
type: "string",
|
|
310
|
-
label: "Placeholder"
|
|
311
|
-
}
|
|
312
|
-
},
|
|
553
|
+
schema: { placeholder: {
|
|
554
|
+
type: "string",
|
|
555
|
+
label: "Placeholder"
|
|
556
|
+
} },
|
|
313
557
|
guideline: `Complement (apartment, suite, etc.) input field. ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`
|
|
314
558
|
});
|
|
315
559
|
const ShippingAddressNeighborhoodControlDefinition = defineComponent({
|
|
316
560
|
name: "ShippingAddressNeighborhoodControl",
|
|
317
561
|
importPath: "@vtex/faststore/components",
|
|
318
562
|
component: ShippingAddressNeighborhoodControl,
|
|
563
|
+
content: ShippingAddressNeighborhoodContent,
|
|
319
564
|
requiresContext: "shipping-address",
|
|
320
565
|
providesContext: "field",
|
|
321
566
|
editor: {
|
|
322
567
|
label: "Neighborhood Control",
|
|
323
568
|
category: "action"
|
|
324
569
|
},
|
|
325
|
-
schema: {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
},
|
|
330
|
-
placeholder: {
|
|
331
|
-
type: "string",
|
|
332
|
-
label: "Placeholder"
|
|
333
|
-
}
|
|
334
|
-
},
|
|
570
|
+
schema: { placeholder: {
|
|
571
|
+
type: "string",
|
|
572
|
+
label: "Placeholder"
|
|
573
|
+
} },
|
|
335
574
|
guideline: `Neighborhood (bairro) input field; shown only for countries that have this field (BR in v1). ${ADDRESS_TEXT_CONTROL_GUIDELINE_SUFFIX}`
|
|
336
575
|
});
|
|
337
576
|
const ShippingAddressCountryControlDefinition = defineComponent({
|
|
338
577
|
name: "ShippingAddressCountryControl",
|
|
339
578
|
importPath: "@vtex/faststore/components",
|
|
340
579
|
component: ShippingAddressCountryControl,
|
|
580
|
+
content: ShippingAddressCountryContent,
|
|
341
581
|
requiresContext: "shipping-address",
|
|
342
582
|
providesContext: "field",
|
|
343
583
|
editor: {
|
|
344
584
|
label: "Country Control",
|
|
345
585
|
category: "action"
|
|
346
586
|
},
|
|
347
|
-
schema: {
|
|
348
|
-
|
|
349
|
-
label: "Field label"
|
|
350
|
-
} },
|
|
351
|
-
guideline: "Country selector; lists only countries with an implemented descriptor. Must be a descendant of ShippingAddressFieldset, which provides the shipping-address context this control requires. Recomposable: compose Field.Label, FieldSelect.Root and Field.Error as children, in any order; a childless composition keeps the default label-select-error order."
|
|
587
|
+
schema: {},
|
|
588
|
+
guideline: "Country selector; lists only countries with an implemented descriptor, each named in the store locale. Its label is the $content field label. Must be a descendant of ShippingAddressFieldset, which provides the shipping-address context this control requires. Recomposable: compose Field.Label, FieldSelect.Root and Field.Error as children, in any order; a childless composition keeps the default label-select-error order."
|
|
352
589
|
});
|
|
353
590
|
/** The message a constrained rule member carries; a bare value (or a bare `RegExp`) carries none. */
|
|
354
591
|
function messageOf(constraint) {
|
|
@@ -384,10 +621,12 @@ function messagesOf(rule) {
|
|
|
384
621
|
function useRewordErroredField(name, rule) {
|
|
385
622
|
const { getFieldState, trigger } = useFormContext();
|
|
386
623
|
const copy = messagesOf(rule).join("\n");
|
|
624
|
+
const validate = rule?.validate;
|
|
387
625
|
useEffect(() => {
|
|
388
626
|
if (getFieldState(name).error) trigger(name);
|
|
389
627
|
}, [
|
|
390
628
|
copy,
|
|
629
|
+
validate,
|
|
391
630
|
name,
|
|
392
631
|
getFieldState,
|
|
393
632
|
trigger
|
|
@@ -420,14 +659,21 @@ function useRewordErroredField(name, rule) {
|
|
|
420
659
|
* polite live region that announces `loadingLabel` and then `loadedLabel`. Style the region
|
|
421
660
|
* `sr-only` — it is text meant for a screen reader, not for the page.
|
|
422
661
|
*/
|
|
423
|
-
function ShippingAddressFieldset({ defaultCountry = "BRA", skeletonCount = SHIPPING_ADDRESS_SKELETON_ROWS,
|
|
662
|
+
function ShippingAddressFieldset({ defaultCountry = "BRA", skeletonCount = SHIPPING_ADDRESS_SKELETON_ROWS, className, children, $data: $dataProp, $actions: $actionsProp, $content }) {
|
|
424
663
|
const { registerFieldset } = useFormRegistry();
|
|
425
664
|
useNoAncestorFieldset("ShippingAddressFieldset");
|
|
426
665
|
const $data = useDataOverride($dataProp);
|
|
427
666
|
const $actions = useActionsOverride($actionsProp);
|
|
667
|
+
const messages = useMessageFormatter(ShippingAddressFieldsetContent, $content);
|
|
668
|
+
const { format } = messages;
|
|
669
|
+
const messagesRef = useRef(messages);
|
|
670
|
+
useEffect(() => {
|
|
671
|
+
messagesRef.current = messages;
|
|
672
|
+
}, [messages]);
|
|
673
|
+
const { displayName } = useStorefrontFormatters();
|
|
428
674
|
const settled = useReactiveDataSettled();
|
|
429
675
|
const sliceResolved = useEntityDataResolved();
|
|
430
|
-
const
|
|
676
|
+
const { loaded: loadedLibraryCountries, settled: libraryCountriesSettled } = useLibraryCountryDescriptors();
|
|
431
677
|
const currentAddress = $data?.shipping?.address;
|
|
432
678
|
const clientProfile = $data?.clientProfile;
|
|
433
679
|
const joinedProfileName = [clientProfile?.firstName, clientProfile?.lastName].filter(Boolean).join(" ");
|
|
@@ -451,27 +697,40 @@ function ShippingAddressFieldset({ defaultCountry = "BRA", skeletonCount = SHIPP
|
|
|
451
697
|
defaultValue: seed.country
|
|
452
698
|
});
|
|
453
699
|
const activeCountry = typeof watchedCountry === "string" && watchedCountry || seed.country;
|
|
454
|
-
const descriptor = getCountryDescriptor(activeCountry);
|
|
455
|
-
const
|
|
700
|
+
const descriptor = LIBRARY_COUNTRIES.includes(activeCountry) && !loadedLibraryCountries.includes(activeCountry) ? void 0 : getCountryDescriptor(activeCountry);
|
|
701
|
+
const resolved = settled && sliceResolved && $data !== void 0 && (descriptor !== void 0 || libraryCountriesSettled);
|
|
456
702
|
const fieldFor = useCallback((key) => descriptor?.fields.find((f) => f.name === key), [descriptor]);
|
|
457
703
|
const seedFor = useCallback((key) => seed[key], [seed]);
|
|
458
|
-
const ruleFor = useCallback((key, label) => {
|
|
704
|
+
const ruleFor = useCallback((key, label, invalidMessage) => {
|
|
459
705
|
const field = fieldFor(key);
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
706
|
+
if (!field) return void 0;
|
|
707
|
+
return buildRule(field, field.required ? format("requiredMessage", { label }) : "", invalidMessage);
|
|
708
|
+
}, [fieldFor, format]);
|
|
709
|
+
const countryOptions = useMemo(() => {
|
|
710
|
+
const libraryCountries = new Set(LIBRARY_COUNTRIES);
|
|
711
|
+
const loaded = new Set(loadedLibraryCountries);
|
|
712
|
+
const options = [];
|
|
713
|
+
for (const iso of getAvailableCountries()) {
|
|
714
|
+
if (libraryCountries.has(iso) && !loaded.has(iso)) continue;
|
|
715
|
+
options.push({
|
|
716
|
+
value: iso,
|
|
717
|
+
label: countryDisplayName(iso, displayName) ?? iso
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
return options;
|
|
721
|
+
}, [loadedLibraryCountries, displayName]);
|
|
722
|
+
const country = activeCountry;
|
|
466
723
|
const fieldsetContextValue = useMemo(() => ({
|
|
467
724
|
namespace: SHIPPING_ADDRESS_NAMESPACE,
|
|
468
725
|
descriptor,
|
|
726
|
+
country,
|
|
469
727
|
fieldFor,
|
|
470
728
|
seedFor,
|
|
471
729
|
ruleFor,
|
|
472
730
|
countryOptions
|
|
473
731
|
}), [
|
|
474
732
|
descriptor,
|
|
733
|
+
country,
|
|
475
734
|
fieldFor,
|
|
476
735
|
seedFor,
|
|
477
736
|
ruleFor,
|
|
@@ -489,18 +748,13 @@ function ShippingAddressFieldset({ defaultCountry = "BRA", skeletonCount = SHIPP
|
|
|
489
748
|
return {
|
|
490
749
|
country,
|
|
491
750
|
...isActive("recipientName") ? { recipientName: String(merged.recipientName ?? "").trim() } : {},
|
|
492
|
-
...isActive("postalCode") ? { postalCode: merged.postalCode } : {},
|
|
493
|
-
...
|
|
494
|
-
...isActive("number") ? { number: merged.number } : {},
|
|
495
|
-
...isActive("complement") ? { complement: merged.complement } : {},
|
|
496
|
-
...isActive("neighborhood") ? { neighborhood: merged.neighborhood } : {},
|
|
497
|
-
...isActive("city") ? { city: merged.city } : {},
|
|
498
|
-
...isActive("state") ? { state: merged.state } : {}
|
|
751
|
+
...isActive("postalCode") ? { postalCode: normalizeAddressField(active?.fields ?? [], "postalCode", merged.postalCode) } : {},
|
|
752
|
+
...pickActiveTextFields(active?.fields ?? [], merged)
|
|
499
753
|
};
|
|
500
754
|
}, [seed]);
|
|
501
755
|
const dispatch = useCallback(async (payload) => {
|
|
502
756
|
if (!$actions?.shipping?.setAddress) throw new Error("ShippingAddressFieldset requires $actions.shipping.setAddress.");
|
|
503
|
-
return $actions.shipping.setAddress(payload);
|
|
757
|
+
return (await $actions.shipping.setAddress(payload)).map((error) => wordShippingAddressError(error, messagesRef.current));
|
|
504
758
|
}, [$actions]);
|
|
505
759
|
const registration = useMemo(() => ({
|
|
506
760
|
namespace: SHIPPING_ADDRESS_NAMESPACE,
|
|
@@ -515,14 +769,15 @@ function ShippingAddressFieldset({ defaultCountry = "BRA", skeletonCount = SHIPP
|
|
|
515
769
|
]);
|
|
516
770
|
useEffect(() => registerFieldset(registration), [registerFieldset, registration]);
|
|
517
771
|
const [announcement, setAnnouncement] = useState("");
|
|
518
|
-
const announced = resolved ? loadedLabel : loadingLabel;
|
|
772
|
+
const announced = format(resolved ? "loadedLabel" : "loadingLabel");
|
|
773
|
+
const groupLabel = format("groupLabel");
|
|
519
774
|
useEffect(() => {
|
|
520
775
|
setAnnouncement(announced);
|
|
521
776
|
}, [announced]);
|
|
522
777
|
return /* @__PURE__ */ jsxs(Fieldset.Root, {
|
|
523
778
|
className,
|
|
524
779
|
"aria-busy": resolved ? void 0 : true,
|
|
525
|
-
...groupLabel
|
|
780
|
+
...groupLabel.trim() ? { "aria-label": groupLabel } : {},
|
|
526
781
|
"data-fs-shipping-address-fieldset": "",
|
|
527
782
|
...resolved ? {} : { "data-fs-shipping-address-fieldset-pending": "" },
|
|
528
783
|
children: [/* @__PURE__ */ jsx(ShippingAddressFieldsetContext.Provider, {
|
|
@@ -553,14 +808,19 @@ function ShippingAddressFieldsetSkeleton({ count = SHIPPING_ADDRESS_SKELETON_ROW
|
|
|
553
808
|
});
|
|
554
809
|
}
|
|
555
810
|
ShippingAddressFieldset.Skeleton = ShippingAddressFieldsetSkeleton;
|
|
556
|
-
function BoundAddressTextField({ fieldKey, slug, className, label, placeholder, children, fieldsetCtx
|
|
811
|
+
function BoundAddressTextField({ fieldKey, slug, className, label, invalidMessage = "", placeholder, children, fieldsetCtx }) {
|
|
557
812
|
const name = useFieldsetField(SHIPPING_ADDRESS_NAMESPACE, fieldKey);
|
|
558
|
-
const
|
|
559
|
-
const rule =
|
|
813
|
+
const { ruleFor } = fieldsetCtx;
|
|
814
|
+
const rule = useMemo(() => ruleFor(fieldKey, label, invalidMessage), [
|
|
815
|
+
ruleFor,
|
|
816
|
+
fieldKey,
|
|
817
|
+
label,
|
|
818
|
+
invalidMessage
|
|
819
|
+
]);
|
|
560
820
|
useRewordErroredField(name, rule);
|
|
561
821
|
return /* @__PURE__ */ jsx(FieldBinding, {
|
|
562
822
|
name,
|
|
563
|
-
label
|
|
823
|
+
label,
|
|
564
824
|
placeholder,
|
|
565
825
|
defaultValue: fieldsetCtx.seedFor(fieldKey),
|
|
566
826
|
rule,
|
|
@@ -581,130 +841,124 @@ function BoundAddressTextField({ fieldKey, slug, className, label, placeholder,
|
|
|
581
841
|
* too, against the active country's format.
|
|
582
842
|
* Pre-filled from clientProfile, editable, required.
|
|
583
843
|
*/
|
|
584
|
-
function ShippingAddressRecipientNameControl({ className,
|
|
844
|
+
function ShippingAddressRecipientNameControl({ className, placeholder, children, $content }) {
|
|
585
845
|
const fieldsetCtx = useShippingAddressFieldsetContext();
|
|
586
|
-
const
|
|
587
|
-
if (!
|
|
846
|
+
const { format } = useMessageFormatter(ShippingAddressRecipientNameContent, $content);
|
|
847
|
+
if (!fieldsetCtx.fieldFor("recipientName")) return null;
|
|
588
848
|
return /* @__PURE__ */ jsx(BoundAddressTextField, {
|
|
589
849
|
fieldKey: "recipientName",
|
|
590
850
|
slug: "recipient-name",
|
|
591
851
|
className,
|
|
592
|
-
label,
|
|
852
|
+
label: format("label"),
|
|
593
853
|
placeholder,
|
|
594
854
|
fieldsetCtx,
|
|
595
|
-
fieldDescriptor,
|
|
596
855
|
children
|
|
597
856
|
});
|
|
598
857
|
}
|
|
599
858
|
/** StreetControl */
|
|
600
|
-
function ShippingAddressStreetControl({ className,
|
|
859
|
+
function ShippingAddressStreetControl({ className, placeholder, children, $content }) {
|
|
601
860
|
const fieldsetCtx = useShippingAddressFieldsetContext();
|
|
602
|
-
const
|
|
603
|
-
if (!
|
|
861
|
+
const { format } = useMessageFormatter(ShippingAddressStreetContent, $content);
|
|
862
|
+
if (!fieldsetCtx.fieldFor("street")) return null;
|
|
604
863
|
return /* @__PURE__ */ jsx(BoundAddressTextField, {
|
|
605
864
|
fieldKey: "street",
|
|
606
865
|
slug: "street",
|
|
607
866
|
className,
|
|
608
|
-
label,
|
|
867
|
+
label: format("label"),
|
|
609
868
|
placeholder,
|
|
610
869
|
fieldsetCtx,
|
|
611
|
-
fieldDescriptor,
|
|
612
870
|
children
|
|
613
871
|
});
|
|
614
872
|
}
|
|
615
873
|
/** NumberControl */
|
|
616
|
-
function ShippingAddressNumberControl({ className,
|
|
874
|
+
function ShippingAddressNumberControl({ className, placeholder, children, $content }) {
|
|
617
875
|
const fieldsetCtx = useShippingAddressFieldsetContext();
|
|
618
|
-
const
|
|
619
|
-
if (!
|
|
876
|
+
const { format } = useMessageFormatter(ShippingAddressNumberContent, $content);
|
|
877
|
+
if (!fieldsetCtx.fieldFor("number")) return null;
|
|
620
878
|
return /* @__PURE__ */ jsx(BoundAddressTextField, {
|
|
621
879
|
fieldKey: "number",
|
|
622
880
|
slug: "number",
|
|
623
881
|
className,
|
|
624
|
-
label,
|
|
882
|
+
label: format("label"),
|
|
625
883
|
placeholder,
|
|
626
884
|
fieldsetCtx,
|
|
627
|
-
fieldDescriptor,
|
|
628
885
|
children
|
|
629
886
|
});
|
|
630
887
|
}
|
|
631
888
|
/** CityControl */
|
|
632
|
-
function ShippingAddressCityControl({ className,
|
|
889
|
+
function ShippingAddressCityControl({ className, placeholder, children, $content }) {
|
|
633
890
|
const fieldsetCtx = useShippingAddressFieldsetContext();
|
|
634
|
-
const
|
|
635
|
-
if (!
|
|
891
|
+
const { format } = useMessageFormatter(ShippingAddressCityContent, $content);
|
|
892
|
+
if (!fieldsetCtx.fieldFor("city")) return null;
|
|
636
893
|
return /* @__PURE__ */ jsx(BoundAddressTextField, {
|
|
637
894
|
fieldKey: "city",
|
|
638
895
|
slug: "city",
|
|
639
896
|
className,
|
|
640
|
-
label,
|
|
897
|
+
label: format("label"),
|
|
641
898
|
placeholder,
|
|
642
899
|
fieldsetCtx,
|
|
643
|
-
fieldDescriptor,
|
|
644
900
|
children
|
|
645
901
|
});
|
|
646
902
|
}
|
|
647
|
-
/** StateControl */
|
|
648
|
-
function ShippingAddressStateControl({ className,
|
|
903
|
+
/** StateControl — its label is worded per country (`state`, `province`). */
|
|
904
|
+
function ShippingAddressStateControl({ className, placeholder, children, $content }) {
|
|
649
905
|
const fieldsetCtx = useShippingAddressFieldsetContext();
|
|
650
|
-
const
|
|
651
|
-
if (!
|
|
906
|
+
const { format } = useMessageFormatter(ShippingAddressStateContent, $content);
|
|
907
|
+
if (!fieldsetCtx.fieldFor("state")) return null;
|
|
652
908
|
return /* @__PURE__ */ jsx(BoundAddressTextField, {
|
|
653
909
|
fieldKey: "state",
|
|
654
910
|
slug: "state",
|
|
655
911
|
className,
|
|
656
|
-
label,
|
|
912
|
+
label: format("label", { country: fieldsetCtx.country }),
|
|
657
913
|
placeholder,
|
|
658
914
|
fieldsetCtx,
|
|
659
|
-
fieldDescriptor,
|
|
660
915
|
children
|
|
661
916
|
});
|
|
662
917
|
}
|
|
663
|
-
/** PostalCodeControl */
|
|
664
|
-
function ShippingAddressPostalCodeControl({ className,
|
|
918
|
+
/** PostalCodeControl — its label and format message are worded per country. */
|
|
919
|
+
function ShippingAddressPostalCodeControl({ className, placeholder, children, $content }) {
|
|
665
920
|
const fieldsetCtx = useShippingAddressFieldsetContext();
|
|
666
|
-
const
|
|
667
|
-
if (!
|
|
921
|
+
const { format } = useMessageFormatter(ShippingAddressPostalCodeContent, $content);
|
|
922
|
+
if (!fieldsetCtx.fieldFor("postalCode")) return null;
|
|
923
|
+
const country = fieldsetCtx.country;
|
|
668
924
|
return /* @__PURE__ */ jsx(BoundAddressTextField, {
|
|
669
925
|
fieldKey: "postalCode",
|
|
670
926
|
slug: "postal-code",
|
|
671
927
|
className,
|
|
672
|
-
label,
|
|
928
|
+
label: format("label", { country }),
|
|
929
|
+
invalidMessage: format("invalidMessage", { country }),
|
|
673
930
|
placeholder,
|
|
674
931
|
fieldsetCtx,
|
|
675
|
-
fieldDescriptor,
|
|
676
932
|
children
|
|
677
933
|
});
|
|
678
934
|
}
|
|
679
935
|
/** ComplementControl */
|
|
680
|
-
function ShippingAddressComplementControl({ className,
|
|
936
|
+
function ShippingAddressComplementControl({ className, placeholder, children, $content }) {
|
|
681
937
|
const fieldsetCtx = useShippingAddressFieldsetContext();
|
|
682
|
-
const
|
|
683
|
-
if (!
|
|
938
|
+
const { format } = useMessageFormatter(ShippingAddressComplementContent, $content);
|
|
939
|
+
if (!fieldsetCtx.fieldFor("complement")) return null;
|
|
684
940
|
return /* @__PURE__ */ jsx(BoundAddressTextField, {
|
|
685
941
|
fieldKey: "complement",
|
|
686
942
|
slug: "complement",
|
|
687
943
|
className,
|
|
688
|
-
label,
|
|
944
|
+
label: format("label"),
|
|
689
945
|
placeholder,
|
|
690
946
|
fieldsetCtx,
|
|
691
|
-
fieldDescriptor,
|
|
692
947
|
children
|
|
693
948
|
});
|
|
694
949
|
}
|
|
695
950
|
/** NeighborhoodControl (BR-specific in v1) */
|
|
696
|
-
function ShippingAddressNeighborhoodControl({ className,
|
|
951
|
+
function ShippingAddressNeighborhoodControl({ className, placeholder, children, $content }) {
|
|
697
952
|
const fieldsetCtx = useShippingAddressFieldsetContext();
|
|
698
|
-
const
|
|
699
|
-
if (!
|
|
953
|
+
const { format } = useMessageFormatter(ShippingAddressNeighborhoodContent, $content);
|
|
954
|
+
if (!fieldsetCtx.fieldFor("neighborhood")) return null;
|
|
700
955
|
return /* @__PURE__ */ jsx(BoundAddressTextField, {
|
|
701
956
|
fieldKey: "neighborhood",
|
|
702
957
|
slug: "neighborhood",
|
|
703
958
|
className,
|
|
704
|
-
label,
|
|
959
|
+
label: format("label"),
|
|
705
960
|
placeholder,
|
|
706
961
|
fieldsetCtx,
|
|
707
|
-
fieldDescriptor,
|
|
708
962
|
children
|
|
709
963
|
});
|
|
710
964
|
}
|
|
@@ -714,24 +968,25 @@ function ShippingAddressNeighborhoodControl({ className, label, placeholder, chi
|
|
|
714
968
|
* none): a country with no descriptor renders no controls at all (Decision 3/4's "no entry, no
|
|
715
969
|
* control" applied to the field that selects the entry itself).
|
|
716
970
|
*/
|
|
717
|
-
function ShippingAddressCountryControl({ className,
|
|
971
|
+
function ShippingAddressCountryControl({ className, placeholder, children, $content }) {
|
|
718
972
|
const fieldsetCtx = useShippingAddressFieldsetContext();
|
|
973
|
+
const { format } = useMessageFormatter(ShippingAddressCountryContent, $content);
|
|
719
974
|
if (!fieldsetCtx.descriptor) return null;
|
|
720
975
|
return /* @__PURE__ */ jsx(BoundShippingAddressCountryControl, {
|
|
721
976
|
className,
|
|
722
|
-
label,
|
|
723
|
-
defaultLabel: fieldsetCtx.descriptor.countryLabel,
|
|
977
|
+
label: format("label"),
|
|
724
978
|
placeholder,
|
|
725
979
|
fieldsetCtx,
|
|
726
980
|
children
|
|
727
981
|
});
|
|
728
982
|
}
|
|
729
|
-
function BoundShippingAddressCountryControl({ className, label,
|
|
983
|
+
function BoundShippingAddressCountryControl({ className, label, placeholder, children, fieldsetCtx }) {
|
|
730
984
|
const name = useFieldsetField(SHIPPING_ADDRESS_NAMESPACE, "country");
|
|
985
|
+
const { displayName } = useStorefrontFormatters();
|
|
731
986
|
return /* @__PURE__ */ jsx(FieldBinding, {
|
|
732
987
|
name,
|
|
733
|
-
label
|
|
734
|
-
placeholder: placeholder ?? fieldsetCtx.descriptor?.
|
|
988
|
+
label,
|
|
989
|
+
placeholder: placeholder ?? countryDisplayName(fieldsetCtx.descriptor?.iso, displayName) ?? void 0,
|
|
735
990
|
defaultValue: fieldsetCtx.seedFor("country"),
|
|
736
991
|
options: fieldsetCtx.countryOptions,
|
|
737
992
|
autoComplete: FIELD_AUTOCOMPLETE.country,
|
|
@@ -770,6 +1025,6 @@ const ShippingAddress = {
|
|
|
770
1025
|
CountryControlDefinition: ShippingAddressCountryControlDefinition
|
|
771
1026
|
};
|
|
772
1027
|
//#endregion
|
|
773
|
-
export { ShippingAddress, ShippingAddressCityControl, ShippingAddressCityControlDefinition, ShippingAddressComplementControl, ShippingAddressComplementControlDefinition, ShippingAddressCountryControl, ShippingAddressCountryControlDefinition, ShippingAddressFieldset, ShippingAddressFieldsetDefinition, ShippingAddressFieldsetSkeleton, ShippingAddressNeighborhoodControl, ShippingAddressNeighborhoodControlDefinition, ShippingAddressNumberControl, ShippingAddressNumberControlDefinition, ShippingAddressPostalCodeControl, ShippingAddressPostalCodeControlDefinition, ShippingAddressRecipientNameControl, ShippingAddressRecipientNameControlDefinition, ShippingAddressStateControl, ShippingAddressStateControlDefinition, ShippingAddressStreetControl, ShippingAddressStreetControlDefinition };
|
|
1028
|
+
export { SHIPPING_ADDRESS_FIELDSET_ERROR_FIELDS, ShippingAddress, ShippingAddressCityContent, ShippingAddressCityControl, ShippingAddressCityControlDefinition, ShippingAddressComplementContent, ShippingAddressComplementControl, ShippingAddressComplementControlDefinition, ShippingAddressCountryContent, ShippingAddressCountryControl, ShippingAddressCountryControlDefinition, ShippingAddressFieldset, ShippingAddressFieldsetContent, ShippingAddressFieldsetDefinition, ShippingAddressFieldsetSkeleton, ShippingAddressNeighborhoodContent, ShippingAddressNeighborhoodControl, ShippingAddressNeighborhoodControlDefinition, ShippingAddressNumberContent, ShippingAddressNumberControl, ShippingAddressNumberControlDefinition, ShippingAddressPostalCodeContent, ShippingAddressPostalCodeControl, ShippingAddressPostalCodeControlDefinition, ShippingAddressRecipientNameContent, ShippingAddressRecipientNameControl, ShippingAddressRecipientNameControlDefinition, ShippingAddressStateContent, ShippingAddressStateControl, ShippingAddressStateControlDefinition, ShippingAddressStreetContent, ShippingAddressStreetControl, ShippingAddressStreetControlDefinition };
|
|
774
1029
|
|
|
775
1030
|
//# sourceMappingURL=shipping-address.js.map
|