@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
|
@@ -1,127 +1,150 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { defineComponent } from "../../core/dist/define-component.js";
|
|
3
|
+
import { defineContentType } from "../../core/dist/define-content-type.js";
|
|
3
4
|
import "../../core/dist/index.js";
|
|
5
|
+
import { useMessageFormatter } from "../../sdk/i18n/use-message-formatter.js";
|
|
4
6
|
import { AccessCodeField } from "../../particles/access-code-field/access-code-field.js";
|
|
5
|
-
import {
|
|
7
|
+
import { isValidEmail } from "../../particles/email-field/email-field.js";
|
|
6
8
|
import { useActionsOverride } from "../../sdk/actions/actions-override-context.js";
|
|
7
|
-
import {
|
|
8
|
-
import { resolveAuthoredCopy } from "../../utils/resolve-authored-copy.js";
|
|
9
|
+
import { formatErrorCode } from "../../sdk/i18n/format-error-code.js";
|
|
9
10
|
import { useSession } from "../session/session.js";
|
|
10
|
-
import {
|
|
11
|
+
import { useSignIn } from "../sign-in/sign-in.js";
|
|
12
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
11
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
//#region src/matter/access-code-sign-in/access-code-sign-in.tsx
|
|
13
|
-
const fragment = `
|
|
14
|
-
fragment AccessCodeSignInData on Query {
|
|
15
|
-
clientProfile {
|
|
16
|
-
__typename
|
|
17
|
-
id
|
|
18
|
-
email
|
|
19
|
-
}
|
|
20
|
-
sessionAuthProviders {
|
|
21
|
-
accessKeyAuthentication
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
`;
|
|
25
14
|
const ACCESS_CODE_SIGN_IN_CONTEXT_UNSET = Symbol("AccessCodeSignInContextUnset");
|
|
26
15
|
const AccessCodeSignInContext = createContext(ACCESS_CODE_SIGN_IN_CONTEXT_UNSET);
|
|
27
16
|
/**
|
|
28
|
-
* Read the stepper state (
|
|
29
|
-
* Throws when called outside that subtree — a misplaced control is a
|
|
30
|
-
* surface immediately, mirroring `useShippingSimulator()`/`useSession()`.
|
|
17
|
+
* Read the stepper state (step, authenticationToken, requestedEmail) from the nearest
|
|
18
|
+
* `AccessCodeSignInRoot`. Throws when called outside that subtree — a misplaced control is a
|
|
19
|
+
* composition bug that should surface immediately, mirroring `useShippingSimulator()`/`useSession()`.
|
|
20
|
+
* A part outside any `SignInRoot` reports that missing ancestor first, since it is the one to add first.
|
|
31
21
|
*/
|
|
32
22
|
function useAccessCodeSignIn() {
|
|
23
|
+
useSignIn();
|
|
33
24
|
const ctx = useContext(AccessCodeSignInContext);
|
|
34
25
|
if (ctx === ACCESS_CODE_SIGN_IN_CONTEXT_UNSET) throw new Error("AccessCodeSignIn components must be used inside AccessCodeSignInRoot.");
|
|
35
26
|
return ctx;
|
|
36
27
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
const AccessCodeRequestControlContent = defineContentType({
|
|
29
|
+
id: "access-code-request-control",
|
|
30
|
+
title: "Access Code Request Control",
|
|
31
|
+
description: "The inline messages shown when sending the access code fails.",
|
|
32
|
+
schema: {
|
|
33
|
+
type: "object",
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
properties: {
|
|
36
|
+
sendLimitMessage: {
|
|
37
|
+
type: "string",
|
|
38
|
+
title: "Send-limit message",
|
|
39
|
+
description: "Shown when too many codes were requested for the address.",
|
|
40
|
+
format: "icu-message",
|
|
41
|
+
messageSource: "Too many codes requested. Try again later."
|
|
42
|
+
},
|
|
43
|
+
blockedMessage: {
|
|
44
|
+
type: "string",
|
|
45
|
+
title: "Blocked message",
|
|
46
|
+
description: "Shown when the account is blocked. Names no duration: the account service returns none.",
|
|
47
|
+
format: "icu-message",
|
|
48
|
+
messageSource: "This account is blocked. Contact support."
|
|
49
|
+
},
|
|
50
|
+
networkErrorMessage: {
|
|
51
|
+
type: "string",
|
|
52
|
+
title: "Generic error message",
|
|
53
|
+
description: "Shown for a network failure and for any refusal the shopper cannot act on.",
|
|
54
|
+
format: "icu-message",
|
|
55
|
+
messageSource: "Something went wrong. Please try again."
|
|
56
|
+
}
|
|
57
|
+
}
|
|
43
58
|
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
});
|
|
60
|
+
const AccessCodeValidateControlContent = defineContentType({
|
|
61
|
+
id: "access-code-validate-control",
|
|
62
|
+
title: "Access Code Validate Control",
|
|
63
|
+
description: "The inline messages shown when the access code is refused.",
|
|
64
|
+
schema: {
|
|
65
|
+
type: "object",
|
|
66
|
+
additionalProperties: false,
|
|
67
|
+
properties: {
|
|
68
|
+
invalidCodeMessage: {
|
|
69
|
+
type: "string",
|
|
70
|
+
title: "Invalid code message",
|
|
71
|
+
description: "Shown when the code is wrong or expired.",
|
|
72
|
+
format: "icu-message",
|
|
73
|
+
messageSource: "That code is incorrect or expired."
|
|
74
|
+
},
|
|
75
|
+
blockedMessage: {
|
|
76
|
+
type: "string",
|
|
77
|
+
title: "Blocked message",
|
|
78
|
+
description: "Shown when the account is blocked. Names no duration: the account service returns none.",
|
|
79
|
+
format: "icu-message",
|
|
80
|
+
messageSource: "This account is blocked. Contact support."
|
|
81
|
+
},
|
|
82
|
+
missingAuthContextMessage: {
|
|
83
|
+
type: "string",
|
|
84
|
+
title: "Missing sign-in context message",
|
|
85
|
+
description: "Shown when the request lost the context the code was issued for. Should not occur on a correct flow.",
|
|
86
|
+
format: "icu-message",
|
|
87
|
+
messageSource: "Something went wrong. Please try again."
|
|
88
|
+
},
|
|
89
|
+
networkErrorMessage: {
|
|
90
|
+
type: "string",
|
|
91
|
+
title: "Generic error message",
|
|
92
|
+
description: "Shown for a network failure and for any refusal the shopper cannot act on.",
|
|
93
|
+
format: "icu-message",
|
|
94
|
+
messageSource: "Something went wrong. Please try again."
|
|
95
|
+
}
|
|
96
|
+
}
|
|
52
97
|
}
|
|
53
|
-
}
|
|
98
|
+
});
|
|
99
|
+
const ACCESS_CODE_REQUEST_ERROR_FIELDS = {
|
|
100
|
+
ACCESS_CODE_SEND_LIMIT: "sendLimitMessage",
|
|
101
|
+
BLOCKED: "blockedMessage",
|
|
102
|
+
NETWORK_ERROR: "networkErrorMessage",
|
|
103
|
+
MISSING_AUTH_CONTEXT: "networkErrorMessage",
|
|
104
|
+
INVALID_CREDENTIALS: "networkErrorMessage",
|
|
105
|
+
INVALID_ACCESS_CODE: "networkErrorMessage"
|
|
106
|
+
};
|
|
107
|
+
const ACCESS_CODE_VALIDATE_ERROR_FIELDS = {
|
|
108
|
+
INVALID_ACCESS_CODE: "invalidCodeMessage",
|
|
109
|
+
BLOCKED: "blockedMessage",
|
|
110
|
+
MISSING_AUTH_CONTEXT: "missingAuthContextMessage",
|
|
111
|
+
NETWORK_ERROR: "networkErrorMessage",
|
|
112
|
+
INVALID_CREDENTIALS: "networkErrorMessage",
|
|
113
|
+
ACCESS_CODE_SEND_LIMIT: "networkErrorMessage"
|
|
114
|
+
};
|
|
54
115
|
const AccessCodeSignInRootDefinition = defineComponent({
|
|
55
116
|
name: "AccessCodeSignInRoot",
|
|
56
117
|
importPath: "@vtex/faststore/components",
|
|
57
118
|
component: AccessCodeSignInRoot,
|
|
58
|
-
|
|
59
|
-
fetchStrategy: "reactive",
|
|
60
|
-
requiresContext: "session",
|
|
119
|
+
requiresContext: "sign-in",
|
|
61
120
|
editor: {
|
|
62
121
|
label: "Access Code Sign-In",
|
|
63
122
|
category: "identity"
|
|
64
123
|
},
|
|
65
124
|
schema: {},
|
|
66
|
-
guideline: "
|
|
67
|
-
});
|
|
68
|
-
const AccessCodeEmailControlDefinition = defineComponent({
|
|
69
|
-
name: "AccessCodeEmailControl",
|
|
70
|
-
importPath: "@vtex/faststore/components",
|
|
71
|
-
component: AccessCodeEmailControl,
|
|
72
|
-
editor: {
|
|
73
|
-
label: "Access Code Email",
|
|
74
|
-
category: "identity"
|
|
75
|
-
},
|
|
76
|
-
schema: {
|
|
77
|
-
label: {
|
|
78
|
-
type: "string",
|
|
79
|
-
label: "Label"
|
|
80
|
-
},
|
|
81
|
-
placeholder: {
|
|
82
|
-
type: "string",
|
|
83
|
-
label: "Placeholder"
|
|
84
|
-
},
|
|
85
|
-
invalidEmailMessage: {
|
|
86
|
-
type: "string",
|
|
87
|
-
label: "Invalid email message"
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
guideline: "The draft email input for the access-code flow: visible only at the request step, pre-fills from clientProfile.email when known but never persists an edit anywhere — it is purely the argument requestAccessCode/validateAccessCode dispatch with. Must be inside AccessCodeSignInRoot. See access-code-sign-in.md."
|
|
125
|
+
guideline: "Root of the access-code method of the sign-in surface: renders nothing until the account configuration has arrived, when the account disables the access code, while another method is the active one, and once loggedIn. Owns the request/validate stepper, the authenticationToken and the address the code was requested for; the email field is SignInEmailControl's. Must be inside SignInRoot. See access-code-sign-in.md."
|
|
91
126
|
});
|
|
92
127
|
const AccessCodeRequestControlDefinition = defineComponent({
|
|
93
128
|
name: "AccessCodeRequestControl",
|
|
94
129
|
importPath: "@vtex/faststore/components",
|
|
95
130
|
component: AccessCodeRequestControl,
|
|
131
|
+
content: AccessCodeRequestControlContent,
|
|
96
132
|
actions: { session: ["requestAccessCode"] },
|
|
97
133
|
editor: {
|
|
98
134
|
label: "Access Code Request",
|
|
99
135
|
category: "identity"
|
|
100
136
|
},
|
|
101
|
-
schema: {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
sendLimitMessage: {
|
|
107
|
-
type: "string",
|
|
108
|
-
label: "Send-limit message"
|
|
109
|
-
},
|
|
110
|
-
blockedMessage: {
|
|
111
|
-
type: "string",
|
|
112
|
-
label: "Blocked message"
|
|
113
|
-
},
|
|
114
|
-
networkErrorMessage: {
|
|
115
|
-
type: "string",
|
|
116
|
-
label: "Network error message"
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
guideline: "Send-code step: disabled until the Root-owned draft email is a valid, non-empty address; dispatches $actions.session.requestAccessCode with it and advances the stepper on success. Failures render inline, never as a blocking error. Must be inside AccessCodeSignInRoot. See access-code-sign-in.md."
|
|
137
|
+
schema: { label: {
|
|
138
|
+
type: "string",
|
|
139
|
+
label: "Label"
|
|
140
|
+
} },
|
|
141
|
+
guideline: "Send-code step: disabled until the shared SignInRoot email draft is a valid, non-empty address; dispatches $actions.session.requestAccessCode with it and advances the stepper on success. Failures render inline, never as a blocking error. Must be inside AccessCodeSignInRoot. See access-code-sign-in.md."
|
|
120
142
|
});
|
|
121
143
|
const AccessCodeValidateControlDefinition = defineComponent({
|
|
122
144
|
name: "AccessCodeValidateControl",
|
|
123
145
|
importPath: "@vtex/faststore/components",
|
|
124
146
|
component: AccessCodeValidateControl,
|
|
147
|
+
content: AccessCodeValidateControlContent,
|
|
125
148
|
actions: { session: ["validateAccessCode"] },
|
|
126
149
|
editor: {
|
|
127
150
|
label: "Access Code Validate",
|
|
@@ -144,73 +167,205 @@ const AccessCodeValidateControlDefinition = defineComponent({
|
|
|
144
167
|
type: "number",
|
|
145
168
|
default: 6,
|
|
146
169
|
label: "Code length"
|
|
147
|
-
}
|
|
148
|
-
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
guideline: "Code-entry step: composes AccessCodeField and dispatches $actions.session.validateAccessCode with the address the code was requested for and the authenticationToken, never the live email draft; a successful validate flips the session reactively and hides the Root. Must be inside AccessCodeSignInRoot. See access-code-sign-in.md."
|
|
173
|
+
});
|
|
174
|
+
const AccessCodeSentNoticeContent = defineContentType({
|
|
175
|
+
id: "access-code-sent-notice",
|
|
176
|
+
title: "Access Code Sent Notice",
|
|
177
|
+
description: "Confirmation that names the address the access code was sent to.",
|
|
178
|
+
schema: {
|
|
179
|
+
type: "object",
|
|
180
|
+
additionalProperties: false,
|
|
181
|
+
properties: { template: {
|
|
149
182
|
type: "string",
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
183
|
+
title: "Template",
|
|
184
|
+
format: "icu-message",
|
|
185
|
+
messageSource: "We sent an access code to {email}.",
|
|
186
|
+
messageArguments: {
|
|
187
|
+
type: "object",
|
|
188
|
+
properties: { email: { type: "string" } }
|
|
189
|
+
},
|
|
190
|
+
messageExample: { email: "shopper@example.com" }
|
|
191
|
+
} }
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
const AccessCodeSentNoticeDefinition = defineComponent({
|
|
195
|
+
name: "AccessCodeSentNotice",
|
|
196
|
+
importPath: "@vtex/faststore/components",
|
|
197
|
+
component: AccessCodeSentNotice,
|
|
198
|
+
content: AccessCodeSentNoticeContent,
|
|
199
|
+
editor: {
|
|
200
|
+
label: "Access Code Sent Notice",
|
|
201
|
+
category: "identity"
|
|
202
|
+
},
|
|
203
|
+
schema: {},
|
|
204
|
+
guideline: "Confirmation shown at the validate step only: names the address the code was sent to, read from the Root's pinned address and never from the live email draft. The sentence is the $content field template, an ICU message whose {email} argument is the address. Announced once as a status. Must be inside AccessCodeSignInRoot. See access-code-sign-in.md."
|
|
205
|
+
});
|
|
206
|
+
const AccessCodeResendContent = defineContentType({
|
|
207
|
+
id: "access-code-resend",
|
|
208
|
+
title: "Access Code Resend",
|
|
209
|
+
description: "Label of the resend button while the resend pace has not elapsed, and the inline messages shown when resending fails.",
|
|
210
|
+
schema: {
|
|
211
|
+
type: "object",
|
|
212
|
+
additionalProperties: false,
|
|
213
|
+
properties: {
|
|
214
|
+
sendLimitMessage: {
|
|
215
|
+
type: "string",
|
|
216
|
+
title: "Send-limit message",
|
|
217
|
+
description: "Shown when too many codes were requested for the address.",
|
|
218
|
+
format: "icu-message",
|
|
219
|
+
messageSource: "Too many codes requested. Try again later."
|
|
220
|
+
},
|
|
221
|
+
blockedMessage: {
|
|
222
|
+
type: "string",
|
|
223
|
+
title: "Blocked message",
|
|
224
|
+
description: "Shown when the account is blocked. Names no duration: the account service returns none.",
|
|
225
|
+
format: "icu-message",
|
|
226
|
+
messageSource: "This account is blocked. Contact support."
|
|
227
|
+
},
|
|
228
|
+
networkErrorMessage: {
|
|
229
|
+
type: "string",
|
|
230
|
+
title: "Generic error message",
|
|
231
|
+
description: "Shown for a network failure and for any refusal the shopper cannot act on.",
|
|
232
|
+
format: "icu-message",
|
|
233
|
+
messageSource: "Something went wrong. Please try again."
|
|
234
|
+
},
|
|
235
|
+
countdownTemplate: {
|
|
236
|
+
type: "string",
|
|
237
|
+
title: "Countdown template",
|
|
238
|
+
format: "icu-message",
|
|
239
|
+
messageSource: "Resend code in {seconds}s",
|
|
240
|
+
messageArguments: {
|
|
241
|
+
type: "object",
|
|
242
|
+
properties: { seconds: { type: "integer" } }
|
|
243
|
+
},
|
|
244
|
+
messageExample: { seconds: 42 }
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
const ACCESS_CODE_RESEND_ERROR_FIELDS = { ...ACCESS_CODE_REQUEST_ERROR_FIELDS };
|
|
250
|
+
const AccessCodeResendControlDefinition = defineComponent({
|
|
251
|
+
name: "AccessCodeResendControl",
|
|
252
|
+
importPath: "@vtex/faststore/components",
|
|
253
|
+
component: AccessCodeResendControl,
|
|
254
|
+
content: AccessCodeResendContent,
|
|
255
|
+
actions: { session: ["requestAccessCode"] },
|
|
256
|
+
editor: {
|
|
257
|
+
label: "Access Code Resend",
|
|
258
|
+
category: "identity"
|
|
259
|
+
},
|
|
260
|
+
schema: {
|
|
261
|
+
label: {
|
|
153
262
|
type: "string",
|
|
154
|
-
label: "
|
|
263
|
+
label: "Label"
|
|
155
264
|
},
|
|
156
|
-
|
|
265
|
+
pendingLabel: {
|
|
157
266
|
type: "string",
|
|
158
|
-
label: "
|
|
267
|
+
label: "Pending label"
|
|
159
268
|
}
|
|
160
269
|
},
|
|
161
|
-
guideline: "
|
|
270
|
+
guideline: "Validate-step only: dispatches $actions.session.requestAccessCode again with the address the first code was sent to, never the live email draft, and replaces the token. Inert for a fixed interval after each code is sent, counting the seconds down in its own label through the $content field countdownTemplate (an ICU message with a {seconds} argument). The interval is not authorable. Failures render inline. Must be inside AccessCodeSignInRoot. See access-code-sign-in.md."
|
|
162
271
|
});
|
|
272
|
+
const AccessCodeCorrectEmailControlDefinition = defineComponent({
|
|
273
|
+
name: "AccessCodeCorrectEmailControl",
|
|
274
|
+
importPath: "@vtex/faststore/components",
|
|
275
|
+
component: AccessCodeCorrectEmailControl,
|
|
276
|
+
editor: {
|
|
277
|
+
label: "Access Code Correct E-mail",
|
|
278
|
+
category: "identity"
|
|
279
|
+
},
|
|
280
|
+
schema: { label: {
|
|
281
|
+
type: "string",
|
|
282
|
+
label: "Label"
|
|
283
|
+
} },
|
|
284
|
+
guideline: "Validate-step only: returns the shopper to the send step and discards the earlier request whole (token, pinned address and resend pace), so a corrected address starts a genuinely new request. Never held by the resend pace. Must be inside AccessCodeSignInRoot. See access-code-sign-in.md."
|
|
285
|
+
});
|
|
286
|
+
/** The in-flight label: an authored `pendingLabel` with content, else `label`, so the button never blanks. */
|
|
287
|
+
function pendingLabelOr(pendingLabel, label) {
|
|
288
|
+
return pendingLabel?.trim() ? pendingLabel : label ?? "";
|
|
289
|
+
}
|
|
290
|
+
const INITIAL_STEPPER = {
|
|
291
|
+
step: "request",
|
|
292
|
+
authenticationToken: null,
|
|
293
|
+
requestedEmail: null,
|
|
294
|
+
resendAvailableAt: null
|
|
295
|
+
};
|
|
163
296
|
/**
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* than
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
297
|
+
* Root of the access-code method of the sign-in surface. It declares no fragment and reads no data of
|
|
298
|
+
* its own: the gate is the three `sign-in` context reads (`resolved`, `accessCodeEnabled` and
|
|
299
|
+
* `method === 'accessCode'`) plus the session read (`state !== 'loggedIn'`), so a store enabling both
|
|
300
|
+
* methods shows the code step only while the access code is the method showing. It returns `null`
|
|
301
|
+
* rather than unmounting, so its `useState` — the stepper, the token and the pinned address — survives
|
|
302
|
+
* a method switch and a gate close.
|
|
303
|
+
*
|
|
304
|
+
* Owns the `step`/`authenticationToken` stepper, the address the token was issued for and the resend
|
|
305
|
+
* deadline, broadcasting them through context. The shared email draft is `SignInRoot`'s, never this
|
|
306
|
+
* family's; the validate dispatch reads the pinned `requestedEmail` instead, because the server rejects a
|
|
307
|
+
* `validateAccessCode` whose email differs from the `requestAccessCode` that issued the token. The
|
|
308
|
+
* deadline lives here, not on the resend control, because this Root returns `null` on a method switch and
|
|
309
|
+
* unmounts every child with it. Everything clears together — `resetToRequest()` — on any change of
|
|
310
|
+
* `useSession().state` other than the session resolving, so a stale token, address and countdown never greet
|
|
311
|
+
* the next shopper. This Root never unmounts, so that reaction is the only thing that clears it: no manual call
|
|
312
|
+
* anywhere in this family.
|
|
175
313
|
*/
|
|
176
|
-
function AccessCodeSignInRoot({
|
|
177
|
-
const
|
|
178
|
-
const {
|
|
179
|
-
const
|
|
180
|
-
const [
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
314
|
+
function AccessCodeSignInRoot({ className, children, ...props }) {
|
|
315
|
+
const { state, loading } = useSession();
|
|
316
|
+
const { resolved, accessCodeEnabled, method } = useSignIn();
|
|
317
|
+
const wasLoading = useRef(loading);
|
|
318
|
+
const [stepper, setStepper] = useState(INITIAL_STEPPER);
|
|
319
|
+
const [, tick] = useReducer((count) => count + 1, 0);
|
|
320
|
+
const startValidation = useCallback((token, requestedEmail) => {
|
|
321
|
+
setStepper({
|
|
322
|
+
step: "validate",
|
|
323
|
+
authenticationToken: token,
|
|
324
|
+
requestedEmail,
|
|
325
|
+
resendAvailableAt: Date.now() + 6e4
|
|
326
|
+
});
|
|
184
327
|
}, []);
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
const [touched, setTouched] = useState(false);
|
|
188
|
-
useEffect(() => {
|
|
189
|
-
if (step === "request" && !touched) setEmailState(savedEmail);
|
|
190
|
-
}, [
|
|
191
|
-
savedEmail,
|
|
192
|
-
touched,
|
|
193
|
-
step
|
|
194
|
-
]);
|
|
195
|
-
const setEmail = useCallback((next) => {
|
|
196
|
-
setTouched(true);
|
|
197
|
-
setEmailState(next);
|
|
328
|
+
const resetToRequest = useCallback(() => {
|
|
329
|
+
setStepper(INITIAL_STEPPER);
|
|
198
330
|
}, []);
|
|
199
|
-
|
|
331
|
+
useEffect(() => {
|
|
332
|
+
if (!wasLoading.current) resetToRequest();
|
|
333
|
+
}, [state, resetToRequest]);
|
|
334
|
+
useEffect(() => {
|
|
335
|
+
wasLoading.current = loading;
|
|
336
|
+
}, [loading]);
|
|
337
|
+
const { step, authenticationToken, requestedEmail, resendAvailableAt } = stepper;
|
|
338
|
+
useEffect(() => {
|
|
339
|
+
if (resendAvailableAt == null) return;
|
|
340
|
+
const interval = setInterval(() => {
|
|
341
|
+
if (Date.now() < resendAvailableAt) {
|
|
342
|
+
tick();
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
setStepper((current) => current.resendAvailableAt === resendAvailableAt ? {
|
|
346
|
+
...current,
|
|
347
|
+
resendAvailableAt: null
|
|
348
|
+
} : current);
|
|
349
|
+
}, 1e3);
|
|
350
|
+
return () => clearInterval(interval);
|
|
351
|
+
}, [resendAvailableAt]);
|
|
352
|
+
const resendAvailableInSeconds = resendAvailableAt == null ? 0 : Math.max(0, Math.ceil((resendAvailableAt - Date.now()) / 1e3));
|
|
200
353
|
const contextValue = useMemo(() => ({
|
|
201
|
-
email,
|
|
202
|
-
setEmail,
|
|
203
354
|
step,
|
|
204
355
|
authenticationToken,
|
|
205
|
-
|
|
356
|
+
requestedEmail,
|
|
357
|
+
startValidation,
|
|
358
|
+
resendAvailableInSeconds,
|
|
359
|
+
resetToRequest
|
|
206
360
|
}), [
|
|
207
|
-
email,
|
|
208
|
-
setEmail,
|
|
209
361
|
step,
|
|
210
362
|
authenticationToken,
|
|
211
|
-
|
|
363
|
+
requestedEmail,
|
|
364
|
+
startValidation,
|
|
365
|
+
resendAvailableInSeconds,
|
|
366
|
+
resetToRequest
|
|
212
367
|
]);
|
|
213
|
-
if (!(state !== "loggedIn" &&
|
|
368
|
+
if (!(state !== "loggedIn" && resolved && accessCodeEnabled && method === "accessCode")) return null;
|
|
214
369
|
return /* @__PURE__ */ jsx(AccessCodeSignInContext, {
|
|
215
370
|
value: contextValue,
|
|
216
371
|
children: /* @__PURE__ */ jsx("div", {
|
|
@@ -222,54 +377,50 @@ function AccessCodeSignInRoot({ $data: $dataProp, className, children, ...props
|
|
|
222
377
|
});
|
|
223
378
|
}
|
|
224
379
|
/**
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
* never touches the cart. Format validation is `EmailField`'s own blur-triggered check (never
|
|
228
|
-
* per-keystroke); `invalidEmailMessage` is only its fallback text, mirroring how
|
|
229
|
-
* `EmailIdentificationControl` defers to the same particle for the same reason.
|
|
230
|
-
*/
|
|
231
|
-
function AccessCodeEmailControl({ label, placeholder, invalidEmailMessage, className, ...props }) {
|
|
232
|
-
const { step, email, setEmail } = useAccessCodeSignIn();
|
|
233
|
-
if (step !== "request") return null;
|
|
234
|
-
return /* @__PURE__ */ jsx("div", {
|
|
235
|
-
...props,
|
|
236
|
-
className,
|
|
237
|
-
"data-fs-access-code-email-control": "",
|
|
238
|
-
children: /* @__PURE__ */ jsx(EmailField, {
|
|
239
|
-
label,
|
|
240
|
-
placeholder,
|
|
241
|
-
value: email,
|
|
242
|
-
onValueChange: setEmail,
|
|
243
|
-
errorMessage: invalidEmailMessage
|
|
244
|
-
})
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Renders only while the Root's stepper is at `step === 'request'`. Reads the draft email from
|
|
249
|
-
* context and dispatches `$actions.session.requestAccessCode({ email })` once it is a valid,
|
|
380
|
+
* Renders only while the Root's stepper is at `step === 'request'`. Reads the shared draft email from
|
|
381
|
+
* `useSignIn()` and dispatches `$actions.session.requestAccessCode({ email })` once it is a valid,
|
|
250
382
|
* non-empty address (no account-existence pre-check beyond that format gate). On a result with a
|
|
251
|
-
* non-null token and no `userErrors`, advances the Root's stepper
|
|
252
|
-
*
|
|
383
|
+
* non-null token and no `userErrors`, advances the Root's stepper and hands it the exact address that
|
|
384
|
+
* was dispatched, so the validate step is bound to it. Every `userErrors` entry renders
|
|
385
|
+
* inline, worded by the `$content` field for its code; the step never changes on error, so the shopper can
|
|
253
386
|
* retry or abandon the method and continue as a guest.
|
|
387
|
+
*
|
|
388
|
+
* A result that arrives after the session changed under it is dropped rather than written: the Root
|
|
389
|
+
* cleared the stepper for that change, and writing the result would bind the next shopper to the
|
|
390
|
+
* address and the live token of the one who pressed send.
|
|
254
391
|
*/
|
|
255
|
-
function AccessCodeRequestControl({ label, pendingLabel,
|
|
392
|
+
function AccessCodeRequestControl({ label, pendingLabel, onRequested, $content, $locale, $actions: $actionsProp, className, ...props }) {
|
|
256
393
|
const $actions = useActionsOverride($actionsProp);
|
|
257
|
-
const { step,
|
|
394
|
+
const { step, startValidation } = useAccessCodeSignIn();
|
|
395
|
+
const { format } = useMessageFormatter(AccessCodeRequestControlContent, $content);
|
|
396
|
+
const { email } = useSignIn();
|
|
397
|
+
const { state, loading } = useSession();
|
|
258
398
|
const [pending, setPending] = useState(false);
|
|
259
399
|
const [error, setError] = useState(null);
|
|
400
|
+
const liveSession = useRef({});
|
|
401
|
+
const wasLoading = useRef(loading);
|
|
402
|
+
useEffect(() => {
|
|
403
|
+
if (!wasLoading.current) liveSession.current = { state };
|
|
404
|
+
}, [state]);
|
|
405
|
+
useEffect(() => {
|
|
406
|
+
wasLoading.current = loading;
|
|
407
|
+
}, [loading]);
|
|
260
408
|
if (step !== "request") return null;
|
|
261
409
|
const canSubmit = !pending && isValidEmail(email);
|
|
262
410
|
async function handleClick() {
|
|
263
411
|
if (!canSubmit) return;
|
|
412
|
+
const requestedEmail = email.trim();
|
|
413
|
+
const sessionAtPress = liveSession.current;
|
|
264
414
|
setPending(true);
|
|
265
415
|
setError(null);
|
|
266
416
|
try {
|
|
267
|
-
const result = await $actions?.session?.requestAccessCode?.({ email }) ?? {
|
|
417
|
+
const result = await $actions?.session?.requestAccessCode?.({ email: requestedEmail }) ?? {
|
|
268
418
|
authenticationToken: null,
|
|
269
419
|
userErrors: []
|
|
270
420
|
};
|
|
421
|
+
if (liveSession.current !== sessionAtPress) return;
|
|
271
422
|
if (result.authenticationToken && result.userErrors.length === 0) {
|
|
272
|
-
startValidation(result.authenticationToken);
|
|
423
|
+
startValidation(result.authenticationToken, requestedEmail);
|
|
273
424
|
onRequested?.(result.authenticationToken);
|
|
274
425
|
return;
|
|
275
426
|
}
|
|
@@ -279,11 +430,7 @@ function AccessCodeRequestControl({ label, pendingLabel, sendLimitMessage, block
|
|
|
279
430
|
setPending(false);
|
|
280
431
|
}
|
|
281
432
|
}
|
|
282
|
-
const message = error ?
|
|
283
|
-
sendLimitMessage,
|
|
284
|
-
blockedMessage,
|
|
285
|
-
networkErrorMessage
|
|
286
|
-
}) : null;
|
|
433
|
+
const message = error ? formatErrorCode(AccessCodeRequestControlContent, ACCESS_CODE_REQUEST_ERROR_FIELDS, error, format, "networkErrorMessage") : null;
|
|
287
434
|
return /* @__PURE__ */ jsxs("div", {
|
|
288
435
|
...props,
|
|
289
436
|
className,
|
|
@@ -296,8 +443,8 @@ function AccessCodeRequestControl({ label, pendingLabel, sendLimitMessage, block
|
|
|
296
443
|
"aria-busy": pending || void 0,
|
|
297
444
|
"data-fs-access-code-request-submit": "",
|
|
298
445
|
"data-fs-button": "",
|
|
299
|
-
children: pending ?
|
|
300
|
-
}),
|
|
446
|
+
children: pending ? pendingLabelOr(pendingLabel, label) : label
|
|
447
|
+
}), error ? /* @__PURE__ */ jsx("div", {
|
|
301
448
|
role: "alert",
|
|
302
449
|
"data-fs-access-code-request-error": "",
|
|
303
450
|
children: message
|
|
@@ -307,29 +454,34 @@ function AccessCodeRequestControl({ label, pendingLabel, sendLimitMessage, block
|
|
|
307
454
|
/**
|
|
308
455
|
* Renders only while the Root's stepper is at `step === 'validate'`. Composes `AccessCodeField` for
|
|
309
456
|
* the code value and a submit control, disabled below `codeLength` (a UX courtesy, never a
|
|
310
|
-
* validity claim). Dispatches `$actions.session.validateAccessCode` with the
|
|
311
|
-
* `authenticationToken` read from context
|
|
312
|
-
* `invalid`/`errorMessage` from
|
|
313
|
-
* shopper can retry without re-requesting. On success it calls the optional `onValidated` and renders
|
|
457
|
+
* validity claim). Dispatches `$actions.session.validateAccessCode` with the pinned `requestedEmail`
|
|
458
|
+
* and `authenticationToken` read from context — never the live `sign-in` draft. On a non-empty
|
|
459
|
+
* `userErrors` result, sets the field's `invalid`/`errorMessage` from the `$content` field for its code
|
|
460
|
+
* and retains the code/token so the shopper can retry without re-requesting. On success it calls the optional `onValidated` and renders
|
|
314
461
|
* no local "success" UI — `useSession()` flipping to `loggedIn` is what makes the whole Root
|
|
315
462
|
* disappear.
|
|
316
463
|
*/
|
|
317
|
-
function AccessCodeValidateControl({ label, placeholder, submitLabel, codeLength = 6,
|
|
464
|
+
function AccessCodeValidateControl({ label, placeholder, submitLabel, codeLength = 6, onValidated, $content, $locale, $actions: $actionsProp, className, ...props }) {
|
|
318
465
|
const $actions = useActionsOverride($actionsProp);
|
|
319
|
-
const {
|
|
466
|
+
const { format } = useMessageFormatter(AccessCodeValidateControlContent, $content);
|
|
467
|
+
const { step, requestedEmail, authenticationToken } = useAccessCodeSignIn();
|
|
320
468
|
const [code, setCode] = useState("");
|
|
321
469
|
const [pending, setPending] = useState(false);
|
|
322
470
|
const [error, setError] = useState(null);
|
|
323
|
-
if (step !== "validate")
|
|
324
|
-
|
|
471
|
+
if (step !== "validate") {
|
|
472
|
+
if (code) setCode("");
|
|
473
|
+
if (error) setError(null);
|
|
474
|
+
return null;
|
|
475
|
+
}
|
|
476
|
+
const canSubmit = !pending && code.length >= codeLength && authenticationToken != null && requestedEmail != null;
|
|
325
477
|
async function handleSubmit(event) {
|
|
326
478
|
event.preventDefault();
|
|
327
|
-
if (!canSubmit || authenticationToken == null) return;
|
|
479
|
+
if (!canSubmit || authenticationToken == null || requestedEmail == null) return;
|
|
328
480
|
setPending(true);
|
|
329
481
|
setError(null);
|
|
330
482
|
try {
|
|
331
483
|
const [firstError] = await $actions?.session?.validateAccessCode?.({
|
|
332
|
-
email,
|
|
484
|
+
email: requestedEmail,
|
|
333
485
|
accessCode: code,
|
|
334
486
|
authenticationToken
|
|
335
487
|
}) ?? [];
|
|
@@ -346,12 +498,7 @@ function AccessCodeValidateControl({ label, placeholder, submitLabel, codeLength
|
|
|
346
498
|
setCode(next);
|
|
347
499
|
if (error) setError(null);
|
|
348
500
|
}
|
|
349
|
-
const errorMessage = error ?
|
|
350
|
-
invalidCodeMessage,
|
|
351
|
-
blockedMessage,
|
|
352
|
-
missingAuthContextMessage,
|
|
353
|
-
networkErrorMessage
|
|
354
|
-
}) : void 0;
|
|
501
|
+
const errorMessage = error ? formatErrorCode(AccessCodeValidateControlContent, ACCESS_CODE_VALIDATE_ERROR_FIELDS, error, format, "networkErrorMessage") : void 0;
|
|
355
502
|
return /* @__PURE__ */ jsx("div", {
|
|
356
503
|
...props,
|
|
357
504
|
className,
|
|
@@ -379,13 +526,137 @@ function AccessCodeValidateControl({ label, placeholder, submitLabel, codeLength
|
|
|
379
526
|
})
|
|
380
527
|
});
|
|
381
528
|
}
|
|
529
|
+
/**
|
|
530
|
+
* Renders only at the validate step. Names the address the code was dispatched to — the Root's pinned
|
|
531
|
+
* `requestedEmail`, never the live `sign-in` draft, which a shopper edit or a profile re-seed can move
|
|
532
|
+
* after the request. The `template` message's `email` argument is the address. The wrapper is an
|
|
533
|
+
* `output`, whose implicit `status` role announces the confirmation once, when it appears.
|
|
534
|
+
*/
|
|
535
|
+
function AccessCodeSentNotice({ $content, $locale, className, ...props }) {
|
|
536
|
+
const { step, requestedEmail } = useAccessCodeSignIn();
|
|
537
|
+
const { format } = useMessageFormatter(AccessCodeSentNoticeContent, $content);
|
|
538
|
+
if (step !== "validate" || requestedEmail == null) return null;
|
|
539
|
+
return /* @__PURE__ */ jsx("output", {
|
|
540
|
+
...props,
|
|
541
|
+
className,
|
|
542
|
+
"data-fs-access-code-sent-notice": "",
|
|
543
|
+
children: format("template", { email: requestedEmail })
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Renders only at the validate step. Dispatches `$actions.session.requestAccessCode` with the Root's
|
|
548
|
+
* pinned `requestedEmail` — never the live draft, so a second code goes to the address the shopper was
|
|
549
|
+
* told about — and replaces the token with the one it returns through the same `startValidation` that
|
|
550
|
+
* the request control uses, which re-pins the same address and re-arms the pace. Inert until the pace
|
|
551
|
+
* has elapsed, with the whole seconds left in its own label. A failure renders inline and leaves the
|
|
552
|
+
* step, the token and the pace untouched: no code was sent, so none is paced.
|
|
553
|
+
*
|
|
554
|
+
* A result that arrives after the request it answered has been discarded (the shopper went back, the
|
|
555
|
+
* session changed, the Root closed) is dropped rather than written, so a token is never re-paired with
|
|
556
|
+
* the address that was left.
|
|
557
|
+
*/
|
|
558
|
+
function AccessCodeResendControl({ label, pendingLabel, onResent, $content, $locale, $actions: $actionsProp, className, ...props }) {
|
|
559
|
+
const $actions = useActionsOverride($actionsProp);
|
|
560
|
+
const { step, authenticationToken, requestedEmail, resendAvailableInSeconds, startValidation } = useAccessCodeSignIn();
|
|
561
|
+
const { format } = useMessageFormatter(AccessCodeResendContent, $content);
|
|
562
|
+
const [pending, setPending] = useState(false);
|
|
563
|
+
const [error, setError] = useState(null);
|
|
564
|
+
const liveToken = useRef(authenticationToken);
|
|
565
|
+
useEffect(() => {
|
|
566
|
+
liveToken.current = authenticationToken;
|
|
567
|
+
return () => {
|
|
568
|
+
liveToken.current = null;
|
|
569
|
+
};
|
|
570
|
+
}, [authenticationToken]);
|
|
571
|
+
if (step !== "validate" || requestedEmail == null) {
|
|
572
|
+
if (error) setError(null);
|
|
573
|
+
return null;
|
|
574
|
+
}
|
|
575
|
+
const paced = resendAvailableInSeconds > 0;
|
|
576
|
+
const canSubmit = !pending && !paced;
|
|
577
|
+
async function handleClick() {
|
|
578
|
+
if (!canSubmit || requestedEmail == null) return;
|
|
579
|
+
const pinnedEmail = requestedEmail;
|
|
580
|
+
const tokenAtPress = authenticationToken;
|
|
581
|
+
setPending(true);
|
|
582
|
+
setError(null);
|
|
583
|
+
try {
|
|
584
|
+
const result = await $actions?.session?.requestAccessCode?.({ email: pinnedEmail }) ?? {
|
|
585
|
+
authenticationToken: null,
|
|
586
|
+
userErrors: []
|
|
587
|
+
};
|
|
588
|
+
if (liveToken.current !== tokenAtPress) return;
|
|
589
|
+
if (result.authenticationToken && result.userErrors.length === 0) {
|
|
590
|
+
startValidation(result.authenticationToken, pinnedEmail);
|
|
591
|
+
onResent?.(result.authenticationToken);
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
const [firstError] = result.userErrors;
|
|
595
|
+
if (firstError) setError(firstError);
|
|
596
|
+
} finally {
|
|
597
|
+
setPending(false);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
const message = error ? formatErrorCode(AccessCodeResendContent, ACCESS_CODE_RESEND_ERROR_FIELDS, error, format, "networkErrorMessage") : null;
|
|
601
|
+
const pacedLabel = paced ? format("countdownTemplate", { seconds: resendAvailableInSeconds }) : label;
|
|
602
|
+
const buttonLabel = pending ? pendingLabelOr(pendingLabel, label) : pacedLabel;
|
|
603
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
604
|
+
...props,
|
|
605
|
+
className,
|
|
606
|
+
"data-fs-access-code-resend-control": "",
|
|
607
|
+
...paced ? { "data-fs-access-code-resend-waiting": "" } : {},
|
|
608
|
+
...pending ? { "data-fs-access-code-resend-pending": "" } : {},
|
|
609
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
610
|
+
type: "button",
|
|
611
|
+
onClick: handleClick,
|
|
612
|
+
disabled: !canSubmit,
|
|
613
|
+
"aria-busy": pending || void 0,
|
|
614
|
+
"data-fs-access-code-resend-submit": "",
|
|
615
|
+
"data-fs-button": "",
|
|
616
|
+
children: buttonLabel
|
|
617
|
+
}), error ? /* @__PURE__ */ jsx("div", {
|
|
618
|
+
role: "alert",
|
|
619
|
+
"data-fs-access-code-resend-error": "",
|
|
620
|
+
children: message
|
|
621
|
+
}) : null]
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Renders only at the validate step. Calls the Root's `resetToRequest()`, which discards the step, the
|
|
626
|
+
* token, the pinned address and the resend pace in one transition. The shopper lands on the request step
|
|
627
|
+
* with the shared draft still in the field to edit; the next request pins whatever address they send and
|
|
628
|
+
* the token the server issues for it, and the earlier token is unreachable. Never held by the pace: the
|
|
629
|
+
* pace counts codes sent, and a shopper who mistyped is not made to wait for the address they meant.
|
|
630
|
+
*/
|
|
631
|
+
function AccessCodeCorrectEmailControl({ label, onCorrected, className, ...props }) {
|
|
632
|
+
const { step, resetToRequest } = useAccessCodeSignIn();
|
|
633
|
+
if (step !== "validate") return null;
|
|
634
|
+
function handleClick() {
|
|
635
|
+
resetToRequest();
|
|
636
|
+
onCorrected?.();
|
|
637
|
+
}
|
|
638
|
+
return /* @__PURE__ */ jsx("div", {
|
|
639
|
+
...props,
|
|
640
|
+
className,
|
|
641
|
+
"data-fs-access-code-correct-email-control": "",
|
|
642
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
643
|
+
type: "button",
|
|
644
|
+
onClick: handleClick,
|
|
645
|
+
"data-fs-access-code-correct-email-button": "",
|
|
646
|
+
"data-fs-button": "",
|
|
647
|
+
children: label
|
|
648
|
+
})
|
|
649
|
+
});
|
|
650
|
+
}
|
|
382
651
|
const AccessCodeSignIn = {
|
|
383
652
|
Root: AccessCodeSignInRoot,
|
|
384
|
-
Email: AccessCodeEmailControl,
|
|
385
653
|
Request: AccessCodeRequestControl,
|
|
386
|
-
|
|
654
|
+
SentNotice: AccessCodeSentNotice,
|
|
655
|
+
Validate: AccessCodeValidateControl,
|
|
656
|
+
Resend: AccessCodeResendControl,
|
|
657
|
+
CorrectEmail: AccessCodeCorrectEmailControl
|
|
387
658
|
};
|
|
388
659
|
//#endregion
|
|
389
|
-
export {
|
|
660
|
+
export { ACCESS_CODE_REQUEST_ERROR_FIELDS, ACCESS_CODE_RESEND_ERROR_FIELDS, ACCESS_CODE_VALIDATE_ERROR_FIELDS, AccessCodeCorrectEmailControl, AccessCodeCorrectEmailControlDefinition, AccessCodeRequestControl, AccessCodeRequestControlContent, AccessCodeRequestControlDefinition, AccessCodeResendContent, AccessCodeResendControl, AccessCodeResendControlDefinition, AccessCodeSentNotice, AccessCodeSentNoticeContent, AccessCodeSentNoticeDefinition, AccessCodeSignIn, AccessCodeSignInRoot, AccessCodeSignInRootDefinition, AccessCodeValidateControl, AccessCodeValidateControlContent, AccessCodeValidateControlDefinition, useAccessCodeSignIn };
|
|
390
661
|
|
|
391
662
|
//# sourceMappingURL=access-code-sign-in.js.map
|