@vtex/faststore 0.0.10 → 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 +42 -0
- package/README.md +0 -1
- 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/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 +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/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,7 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { defineComponent } from "../../core/dist/define-component.js";
|
|
3
|
+
import { defineContentType } from "../../core/dist/define-content-type.js";
|
|
3
4
|
import "../../core/dist/index.js";
|
|
5
|
+
import { useMessageFormatter } from "../../sdk/i18n/use-message-formatter.js";
|
|
4
6
|
import { useActionsOverride } from "../../sdk/actions/actions-override-context.js";
|
|
7
|
+
import { formatErrorCode } from "../../sdk/i18n/format-error-code.js";
|
|
5
8
|
import { useDataOverride } from "../../sdk/data/data-override-context.js";
|
|
6
9
|
import { useSession } from "../session/session.js";
|
|
7
10
|
import { PhoneField, toE164, validatePhoneNumber } from "../../particles/phone-field/phone-field.js";
|
|
@@ -74,10 +77,57 @@ function ClientProfileRoot({ $data: $dataProp, className, children }) {
|
|
|
74
77
|
})
|
|
75
78
|
});
|
|
76
79
|
}
|
|
80
|
+
const ClientProfilePhoneControlContent = defineContentType({
|
|
81
|
+
id: "client-profile-phone-control",
|
|
82
|
+
title: "Client Profile Phone Control",
|
|
83
|
+
description: "The phone field's label, its validation messages and the message for a refused save.",
|
|
84
|
+
schema: {
|
|
85
|
+
type: "object",
|
|
86
|
+
additionalProperties: false,
|
|
87
|
+
properties: {
|
|
88
|
+
label: {
|
|
89
|
+
type: "string",
|
|
90
|
+
title: "Label",
|
|
91
|
+
format: "icu-message",
|
|
92
|
+
messageSource: "Phone"
|
|
93
|
+
},
|
|
94
|
+
errorInvalid: {
|
|
95
|
+
type: "string",
|
|
96
|
+
title: "Invalid error message",
|
|
97
|
+
format: "icu-message",
|
|
98
|
+
messageSource: "Invalid phone number"
|
|
99
|
+
},
|
|
100
|
+
errorRequired: {
|
|
101
|
+
type: "string",
|
|
102
|
+
title: "Required error message",
|
|
103
|
+
format: "icu-message",
|
|
104
|
+
messageSource: "Phone number is required"
|
|
105
|
+
},
|
|
106
|
+
genericErrorMessage: {
|
|
107
|
+
type: "string",
|
|
108
|
+
title: "Save failure message",
|
|
109
|
+
description: "Shown for a network failure and for any refusal the shopper cannot act on.",
|
|
110
|
+
format: "icu-message",
|
|
111
|
+
messageSource: "Unable to save your details. Please try again."
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
/**
|
|
117
|
+
* `ClientProfileUpdateErrorCode` of API Core's schema plus the client-minted transport failure. None is
|
|
118
|
+
* something the shopper can fix by editing the phone, so all share the generic message.
|
|
119
|
+
*/
|
|
120
|
+
const CLIENT_PROFILE_PHONE_ERROR_FIELDS = {
|
|
121
|
+
MISSING_CART_CONTEXT: "genericErrorMessage",
|
|
122
|
+
CART_NOT_FOUND: "genericErrorMessage",
|
|
123
|
+
NO_PROFILE_FIELD_PROVIDED: "genericErrorMessage",
|
|
124
|
+
NETWORK_ERROR: "genericErrorMessage"
|
|
125
|
+
};
|
|
77
126
|
const ClientProfilePhoneControlDefinition = defineComponent({
|
|
78
127
|
name: "ClientProfilePhoneControl",
|
|
79
128
|
importPath: "@vtex/faststore/components",
|
|
80
129
|
component: ClientProfilePhoneControl,
|
|
130
|
+
content: ClientProfilePhoneControlContent,
|
|
81
131
|
requiresContext: "client-profile",
|
|
82
132
|
actions: { identity: ["clientProfileUpdate"] },
|
|
83
133
|
editor: {
|
|
@@ -85,11 +135,6 @@ const ClientProfilePhoneControlDefinition = defineComponent({
|
|
|
85
135
|
category: "identity"
|
|
86
136
|
},
|
|
87
137
|
schema: {
|
|
88
|
-
label: {
|
|
89
|
-
type: "string",
|
|
90
|
-
default: "Phone",
|
|
91
|
-
label: "Label"
|
|
92
|
-
},
|
|
93
138
|
country: {
|
|
94
139
|
type: "string",
|
|
95
140
|
default: "US",
|
|
@@ -99,19 +144,9 @@ const ClientProfilePhoneControlDefinition = defineComponent({
|
|
|
99
144
|
type: ["mandatory", "optional"],
|
|
100
145
|
default: "mandatory",
|
|
101
146
|
label: "Requirement"
|
|
102
|
-
},
|
|
103
|
-
errorInvalid: {
|
|
104
|
-
type: "string",
|
|
105
|
-
default: "Invalid phone number",
|
|
106
|
-
label: "Invalid error message"
|
|
107
|
-
},
|
|
108
|
-
errorRequired: {
|
|
109
|
-
type: "string",
|
|
110
|
-
default: "Phone number is required",
|
|
111
|
-
label: "Required error message"
|
|
112
147
|
}
|
|
113
148
|
},
|
|
114
|
-
guideline: "The bound phone field; must be a descendant of ClientProfileRoot. Reads the saved phone from the ClientProfile entity and persists it on blur via $actions.identity.clientProfileUpdate({ phone }). Composes the reusable PhoneField particle."
|
|
149
|
+
guideline: "The bound phone field; must be a descendant of ClientProfileRoot. Reads the saved phone from the ClientProfile entity and persists it on blur via $actions.identity.clientProfileUpdate({ phone }). Composes the reusable PhoneField particle, passing it the $content fields label, errorInvalid and errorRequired; a refused save shows genericErrorMessage."
|
|
115
150
|
});
|
|
116
151
|
/**
|
|
117
152
|
* Renders the bound phone field by composing the reusable `PhoneField` particle. Reads the saved
|
|
@@ -120,10 +155,12 @@ const ClientProfilePhoneControlDefinition = defineComponent({
|
|
|
120
155
|
* mirroring `EmailIdentificationControl`). While the write is in flight the field is disabled and
|
|
121
156
|
* `data-fs-client-profile-phone-pending` is present so a checkout-CTA guard can block. When the
|
|
122
157
|
* session reports `canEditData: false` the field renders disabled with
|
|
123
|
-
* `data-fs-client-profile-phone-readonly`. Server `userErrors` are surfaced inline
|
|
158
|
+
* `data-fs-client-profile-phone-readonly`. Server `userErrors` are surfaced inline, worded by the
|
|
159
|
+
* `$content` field for their code (genericErrorMessage for a code it does not know).
|
|
124
160
|
*/
|
|
125
|
-
function ClientProfilePhoneControl({
|
|
161
|
+
function ClientProfilePhoneControl({ country = "US", requirement = "mandatory", $content, $locale, className, $actions: $actionsProp }) {
|
|
126
162
|
const $actions = useActionsOverride($actionsProp);
|
|
163
|
+
const { format } = useMessageFormatter(ClientProfilePhoneControlContent, $content);
|
|
127
164
|
const { phone: savedPhone } = useClientProfileContext();
|
|
128
165
|
const { canEditData } = useSession();
|
|
129
166
|
const readOnly = !canEditData;
|
|
@@ -136,6 +173,9 @@ function ClientProfilePhoneControl({ label = "Phone", country = "US", requiremen
|
|
|
136
173
|
setPrevSaved(savedPhone);
|
|
137
174
|
if (!dirtyRef.current) setDraft(savedPhone);
|
|
138
175
|
}
|
|
176
|
+
function serverErrorMessage(error) {
|
|
177
|
+
return formatErrorCode(ClientProfilePhoneControlContent, CLIENT_PROFILE_PHONE_ERROR_FIELDS, error, format, "genericErrorMessage");
|
|
178
|
+
}
|
|
139
179
|
function handleValueChange(next) {
|
|
140
180
|
setDraft(next);
|
|
141
181
|
dirtyRef.current = true;
|
|
@@ -154,7 +194,7 @@ function ClientProfilePhoneControl({ label = "Phone", country = "US", requiremen
|
|
|
154
194
|
setServerError(null);
|
|
155
195
|
try {
|
|
156
196
|
const errors = await clientProfileUpdate({ phone }) ?? [];
|
|
157
|
-
if (errors.length > 0) setServerError(errors[0]
|
|
197
|
+
if (errors.length > 0) setServerError(errors[0] ?? null);
|
|
158
198
|
else dirtyRef.current = false;
|
|
159
199
|
} finally {
|
|
160
200
|
setPending(false);
|
|
@@ -166,17 +206,17 @@ function ClientProfilePhoneControl({ label = "Phone", country = "US", requiremen
|
|
|
166
206
|
...pending ? { "data-fs-client-profile-phone-pending": "" } : {},
|
|
167
207
|
...readOnly ? { "data-fs-client-profile-phone-readonly": "" } : {},
|
|
168
208
|
children: /* @__PURE__ */ jsx(PhoneField, {
|
|
169
|
-
label,
|
|
209
|
+
label: format("label"),
|
|
170
210
|
country,
|
|
171
211
|
requirement,
|
|
172
|
-
errorInvalid,
|
|
173
|
-
errorRequired,
|
|
212
|
+
errorInvalid: format("errorInvalid"),
|
|
213
|
+
errorRequired: format("errorRequired"),
|
|
174
214
|
value: draft,
|
|
175
215
|
onValueChange: handleValueChange,
|
|
176
216
|
onBlur: handleBlur,
|
|
177
217
|
isDisabled: pending || readOnly,
|
|
178
218
|
invalid: serverError != null || void 0,
|
|
179
|
-
error: serverError
|
|
219
|
+
error: serverError ? serverErrorMessage(serverError) : void 0
|
|
180
220
|
})
|
|
181
221
|
});
|
|
182
222
|
}
|
|
@@ -185,6 +225,6 @@ const ClientProfile = {
|
|
|
185
225
|
PhoneControl: ClientProfilePhoneControl
|
|
186
226
|
};
|
|
187
227
|
//#endregion
|
|
188
|
-
export { ClientProfile, ClientProfilePhoneControl, ClientProfilePhoneControlDefinition, ClientProfileRoot, ClientProfileRootDefinition };
|
|
228
|
+
export { CLIENT_PROFILE_PHONE_ERROR_FIELDS, ClientProfile, ClientProfilePhoneControl, ClientProfilePhoneControlContent, ClientProfilePhoneControlDefinition, ClientProfileRoot, ClientProfileRootDefinition };
|
|
189
229
|
|
|
190
230
|
//# sourceMappingURL=client-profile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-profile.js","names":[],"sources":["../../../src/matter/client-profile/client-profile.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport { createContext, type ReactNode, useContext, useMemo, useRef, useState } from 'react';\nimport type { PhoneCountry } from '../../particles/phone-field/phone-field.js';\nimport { PhoneField, toE164, validatePhoneNumber } from '../../particles/phone-field/phone-field.js';\nimport { useActionsOverride } from '../../sdk/actions/actions-override-context.js';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { useSession } from '../session/session.js';\n\n/**\n * The `client-profile` section matter (per ADR-0011: a matter is decomposed by DATA OWNERSHIP, not\n * per field). The shopper-profile fields recorded on the cart's `clientProfileData` live on the User\n * Identity `ClientProfile` entity — a SIBLING of `Cart`, not nested under it. They are read through\n * `Query.clientProfile` and written through the shared `$actions.identity.clientProfileUpdate`\n * action, which performs a partial write that leaves the fields it is not given untouched.\n *\n * This matter wires only `phone`: a `ClientProfilePhoneControl` that composes the reusable,\n * business-agnostic `PhoneField` particle (reused later in MyAccount / extensions; the binding here\n * owns the data source and persistence). Room is kept for future profile Controls on the same Root.\n * Reads follow the colocated-fragment Root pattern (ADR-0006, fetchStrategy 'reactive'), mirroring\n * `EmailIdentificationControl`; writes flow through `$actions.identity` (ADR-0010). The write is\n * pessimistic (awaits the mutation) and is dispatched on blur — form-bound saving via the profile-form\n * CTA is a follow-up, not implemented here.\n */\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment — colocated on the ClientProfile sibling entity (ADR-0011)\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment ClientProfilePhoneData on Query {\n clientProfile {\n __typename\n id\n phone\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Raw data shape of the section fragment\n// ---------------------------------------------------------------------------\n\n/** The `$data` slice forwarded by the reactive runtime — the `ClientProfile` sibling entity, unwrapped. */\nexport type ClientProfileData = {\n phone?: string | null;\n} | null;\n\n// ---------------------------------------------------------------------------\n// Context — the Root publishes the seeded profile values to its Controls\n// ---------------------------------------------------------------------------\n\nexport type ClientProfileContextValue = Readonly<{\n /** Current value of each profile field, seeded from the ClientProfile entity (null → empty). */\n phone: string;\n}>;\n\nconst CLIENT_PROFILE_UNSET = Symbol('ClientProfileContextUnset');\n\nconst ClientProfileContext = createContext<ClientProfileContextValue | typeof CLIENT_PROFILE_UNSET>(\n CLIENT_PROFILE_UNSET,\n);\n\nfunction useClientProfileContext(): ClientProfileContextValue {\n const ctx = useContext(ClientProfileContext);\n if (ctx === CLIENT_PROFILE_UNSET) {\n throw new Error('A client-profile Control must be used inside a ClientProfileRoot.');\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Root\n// ---------------------------------------------------------------------------\n\nexport type ClientProfileRootProps = {\n /** ClientProfile entity slice forwarded by the reactive runtime (value of the section fragment). */\n $data?: ClientProfileData;\n className?: string;\n children?: ReactNode;\n};\n\nexport const ClientProfileRootDefinition = defineComponent<ClientProfileRootProps>({\n name: 'ClientProfileRoot',\n importPath: '@vtex/faststore/components',\n component: ClientProfileRoot,\n fragment,\n fetchStrategy: 'reactive',\n providesContext: 'client-profile',\n requiresContext: 'session',\n editor: { label: 'Client Profile Root', category: 'identity' },\n schema: {},\n guideline:\n 'Binding provider for the shopper-profile section; reads the profile fields (today: phone) from the ClientProfile entity (Query.clientProfile) and exposes them to its Controls. Writes flow through $actions.identity.clientProfileUpdate. Must be inside SessionRoot. Wrap a ClientProfilePhoneControl.',\n});\n\n/**\n * Renders the client-profile section Root: reads `$data` (the `ClientProfile` sibling entity), seeds\n * the profile values from the colocated fragment, and publishes a section context. It also reads\n * `useSession()` — which enforces the `SessionRoot` ancestor. Writes are owned by the Control's\n * `$actions.identity` (ADR-0010); the Root only supplies the pre-fill.\n */\nexport function ClientProfileRoot({ $data: $dataProp, className, children }: ClientProfileRootProps) {\n const $data = useDataOverride($dataProp);\n // Reads identification state and, as a side effect, throws when rendered outside <SessionRoot>.\n useSession();\n\n const phone = $data?.phone ?? '';\n\n const contextValue = useMemo<ClientProfileContextValue>(() => ({ phone }), [phone]);\n\n return (\n <ClientProfileContext value={contextValue}>\n <div className={className} data-fs-client-profile-root=\"\">\n {children}\n </div>\n </ClientProfileContext>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Phone Control\n// ---------------------------------------------------------------------------\n\ntype PhoneFieldRequirement = 'mandatory' | 'optional';\n\nexport type ClientProfilePhoneControlProps = {\n /** Visible field label. */\n label?: string;\n /** Selects the phone mask and validation rule. */\n country?: PhoneCountry;\n /** Controls required validation. */\n requirement?: PhoneFieldRequirement;\n /** Error string shown when the input format is invalid. */\n errorInvalid?: string;\n /** Error string shown when the mandatory field is left empty. */\n errorRequired?: string;\n className?: string;\n /** Injected by the compiler from `actions: { identity: ['clientProfileUpdate'] }`; the write surface. */\n $actions?: ComponentActions;\n};\n\nexport const ClientProfilePhoneControlDefinition = defineComponent<ClientProfilePhoneControlProps>({\n name: 'ClientProfilePhoneControl',\n importPath: '@vtex/faststore/components',\n component: ClientProfilePhoneControl,\n requiresContext: 'client-profile',\n actions: { identity: ['clientProfileUpdate'] },\n editor: { label: 'Client Profile Phone Control', category: 'identity' },\n schema: {\n label: { type: 'string', default: 'Phone', label: 'Label' },\n country: { type: 'string', default: 'US', label: 'Country (US or BR)' },\n requirement: { type: ['mandatory', 'optional'] as const, default: 'mandatory', label: 'Requirement' },\n errorInvalid: { type: 'string', default: 'Invalid phone number', label: 'Invalid error message' },\n errorRequired: { type: 'string', default: 'Phone number is required', label: 'Required error message' },\n },\n guideline:\n 'The bound phone field; must be a descendant of ClientProfileRoot. Reads the saved phone from the ClientProfile entity and persists it on blur via $actions.identity.clientProfileUpdate({ phone }). Composes the reusable PhoneField particle.',\n});\n\n/**\n * Renders the bound phone field by composing the reusable `PhoneField` particle. Reads the saved\n * phone from the section context, and on a **changed** value persists only `phone` — normalized to\n * E.164 — through `$actions.identity.clientProfileUpdate({ phone })` on blur (pessimistic,\n * mirroring `EmailIdentificationControl`). While the write is in flight the field is disabled and\n * `data-fs-client-profile-phone-pending` is present so a checkout-CTA guard can block. When the\n * session reports `canEditData: false` the field renders disabled with\n * `data-fs-client-profile-phone-readonly`. Server `userErrors` are surfaced inline.\n */\nexport function ClientProfilePhoneControl({\n label = 'Phone',\n country = 'US',\n requirement = 'mandatory',\n errorInvalid = 'Invalid phone number',\n errorRequired = 'Phone number is required',\n className,\n $actions: $actionsProp,\n}: Readonly<ClientProfilePhoneControlProps>) {\n const $actions = useActionsOverride($actionsProp);\n const { phone: savedPhone } = useClientProfileContext();\n // VTEX refuses profile edits for an identified-but-unauthenticated claimed profile; render the\n // field read-only instead of accepting a write that is doomed server-side (mirrors\n // EmailIdentificationControl).\n const { canEditData } = useSession();\n const readOnly = !canEditData;\n const [draft, setDraft] = useState(savedPhone);\n // A plain ref, not state: set only from handlers (never during render), and read only inside the\n // render-body re-seed comparison below — nothing here needs its own re-render, since every call\n // site that sets it already triggers one via a sibling state setter in the same tick.\n const dirtyRef = useRef(false);\n const [pending, setPending] = useState(false);\n const [serverError, setServerError] = useState<string | null>(null);\n\n // Re-seed the local draft when the saved value changes (e.g. cache update after a write, or a\n // logged-in shopper's profile resolving) — but never while an edit is in progress. A render-phase\n // compare-and-set, not a ref: the comparison baseline lives in state, and the compare-and-set runs\n // during render, so a render React abandons without committing — a suspended transition, a\n // Suspense retry — never leaves a stale baseline behind the way a ref write would, and a reactive\n // fetch landing mid-keystroke still can't silently replace what the shopper just typed.\n const [prevSaved, setPrevSaved] = useState(savedPhone);\n if (prevSaved !== savedPhone) {\n setPrevSaved(savedPhone);\n if (!dirtyRef.current) setDraft(savedPhone);\n }\n\n function handleValueChange(next: string) {\n setDraft(next);\n dirtyRef.current = true;\n if (serverError) setServerError(null);\n }\n\n async function handleBlur() {\n const clientProfileUpdate = $actions?.identity?.clientProfileUpdate;\n if (!clientProfileUpdate) return;\n // Untouched → nothing to persist.\n if (draft === savedPhone) return;\n // Client-side invalid → skip the write and let the PhoneField's inline error stand; don't\n // rely on server userErrors for a value the mask/validator already rejects. Mirrors the\n // validity the PhoneField particle computes on blur (mandatory-empty or bad format).\n const isEmpty = !draft.trim();\n if (requirement === 'mandatory' && isEmpty) return;\n if (!isEmpty && !validatePhoneNumber(draft, country)) return;\n const phone = isEmpty ? '' : toE164(draft, country);\n // Unchanged after normalization (e.g. the saved \"+12015551234\" re-typed as \"2015551234\") →\n // nothing to persist either.\n if (phone === savedPhone) return;\n\n setPending(true);\n setServerError(null);\n try {\n const errors = (await clientProfileUpdate({ phone })) ?? [];\n if (errors.length > 0) {\n setServerError(errors[0]?.message ?? null);\n } else {\n // The edit is now committed — clear the guard so a later external change (another tab,\n // a cache refresh) can re-seed the draft again.\n dirtyRef.current = false;\n }\n } finally {\n setPending(false);\n }\n }\n\n return (\n <div\n className={className}\n data-fs-client-profile-phone-control=\"\"\n {...(pending ? { 'data-fs-client-profile-phone-pending': '' } : {})}\n {...(readOnly ? { 'data-fs-client-profile-phone-readonly': '' } : {})}\n >\n <PhoneField\n label={label}\n country={country}\n requirement={requirement}\n errorInvalid={errorInvalid}\n errorRequired={errorRequired}\n value={draft}\n onValueChange={handleValueChange}\n onBlur={handleBlur}\n isDisabled={pending || readOnly}\n invalid={serverError != null || undefined}\n error={serverError ?? undefined}\n />\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace export\n// ---------------------------------------------------------------------------\n\nexport const ClientProfile = {\n Root: ClientProfileRoot,\n PhoneControl: ClientProfilePhoneControl,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,WAAyB;;;;;;;;;AA4B/B,MAAM,uBAAuB,OAAO,2BAA2B;AAE/D,MAAM,uBAAuB,cAC3B,oBACF;AAEA,SAAS,0BAAqD;CAC5D,MAAM,MAAM,WAAW,oBAAoB;CAC3C,IAAI,QAAQ,sBACV,MAAM,IAAI,MAAM,mEAAmE;CAErF,OAAO;AACT;AAaA,MAAa,8BAA8B,gBAAwC;CACj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O,eAAe,KAAA;EACvB,CAAA;CACE,CAAA;AAET;AAMA,MAAa,gBAAgB;CAC3B,MAAM;CACN,cAAc;AAChB"}
|
|
1
|
+
{"version":3,"file":"client-profile.js","names":[],"sources":["../../../src/matter/client-profile/client-profile.tsx"],"sourcesContent":["'use client';\n\nimport {\n type ContentValue,\n defineComponent,\n defineContentType,\n type MessageFieldName,\n type MessageLocaleProp,\n} from '@vtex/fs-core';\nimport { createContext, type ReactNode, useContext, useMemo, useRef, useState } from 'react';\nimport type { PhoneCountry } from '../../particles/phone-field/phone-field.js';\nimport { PhoneField, toE164, validatePhoneNumber } from '../../particles/phone-field/phone-field.js';\nimport { useActionsOverride } from '../../sdk/actions/actions-override-context.js';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport { formatErrorCode } from '../../sdk/i18n/format-error-code.js';\nimport { useMessageFormatter } from '../../sdk/i18n/use-message-formatter.js';\nimport type { ClientProfileUserError } from '../../sdk/identity/operations.js';\nimport { useSession } from '../session/session.js';\n\n/**\n * The `client-profile` section matter (per ADR-0011: a matter is decomposed by DATA OWNERSHIP, not\n * per field). The shopper-profile fields recorded on the cart's `clientProfileData` live on the User\n * Identity `ClientProfile` entity — a SIBLING of `Cart`, not nested under it. They are read through\n * `Query.clientProfile` and written through the shared `$actions.identity.clientProfileUpdate`\n * action, which performs a partial write that leaves the fields it is not given untouched.\n *\n * This matter wires only `phone`: a `ClientProfilePhoneControl` that composes the reusable,\n * business-agnostic `PhoneField` particle (reused later in MyAccount / extensions; the binding here\n * owns the data source and persistence). Room is kept for future profile Controls on the same Root.\n * Reads follow the colocated-fragment Root pattern (ADR-0006, fetchStrategy 'reactive'), mirroring\n * `EmailIdentificationControl`; writes flow through `$actions.identity` (ADR-0010). The write is\n * pessimistic (awaits the mutation) and is dispatched on blur — form-bound saving via the profile-form\n * CTA is a follow-up, not implemented here.\n */\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment — colocated on the ClientProfile sibling entity (ADR-0011)\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment ClientProfilePhoneData on Query {\n clientProfile {\n __typename\n id\n phone\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Raw data shape of the section fragment\n// ---------------------------------------------------------------------------\n\n/** The `$data` slice forwarded by the reactive runtime — the `ClientProfile` sibling entity, unwrapped. */\nexport type ClientProfileData = {\n phone?: string | null;\n} | null;\n\n// ---------------------------------------------------------------------------\n// Context — the Root publishes the seeded profile values to its Controls\n// ---------------------------------------------------------------------------\n\nexport type ClientProfileContextValue = Readonly<{\n /** Current value of each profile field, seeded from the ClientProfile entity (null → empty). */\n phone: string;\n}>;\n\nconst CLIENT_PROFILE_UNSET = Symbol('ClientProfileContextUnset');\n\nconst ClientProfileContext = createContext<ClientProfileContextValue | typeof CLIENT_PROFILE_UNSET>(\n CLIENT_PROFILE_UNSET,\n);\n\nfunction useClientProfileContext(): ClientProfileContextValue {\n const ctx = useContext(ClientProfileContext);\n if (ctx === CLIENT_PROFILE_UNSET) {\n throw new Error('A client-profile Control must be used inside a ClientProfileRoot.');\n }\n return ctx;\n}\n\n// ---------------------------------------------------------------------------\n// Root\n// ---------------------------------------------------------------------------\n\nexport type ClientProfileRootProps = {\n /** ClientProfile entity slice forwarded by the reactive runtime (value of the section fragment). */\n $data?: ClientProfileData;\n className?: string;\n children?: ReactNode;\n};\n\nexport const ClientProfileRootDefinition = defineComponent<ClientProfileRootProps>({\n name: 'ClientProfileRoot',\n importPath: '@vtex/faststore/components',\n component: ClientProfileRoot,\n fragment,\n fetchStrategy: 'reactive',\n providesContext: 'client-profile',\n requiresContext: 'session',\n editor: { label: 'Client Profile Root', category: 'identity' },\n schema: {},\n guideline:\n 'Binding provider for the shopper-profile section; reads the profile fields (today: phone) from the ClientProfile entity (Query.clientProfile) and exposes them to its Controls. Writes flow through $actions.identity.clientProfileUpdate. Must be inside SessionRoot. Wrap a ClientProfilePhoneControl.',\n});\n\n/**\n * Renders the client-profile section Root: reads `$data` (the `ClientProfile` sibling entity), seeds\n * the profile values from the colocated fragment, and publishes a section context. It also reads\n * `useSession()` — which enforces the `SessionRoot` ancestor. Writes are owned by the Control's\n * `$actions.identity` (ADR-0010); the Root only supplies the pre-fill.\n */\nexport function ClientProfileRoot({ $data: $dataProp, className, children }: ClientProfileRootProps) {\n const $data = useDataOverride($dataProp);\n // Reads identification state and, as a side effect, throws when rendered outside <SessionRoot>.\n useSession();\n\n const phone = $data?.phone ?? '';\n\n const contextValue = useMemo<ClientProfileContextValue>(() => ({ phone }), [phone]);\n\n return (\n <ClientProfileContext value={contextValue}>\n <div className={className} data-fs-client-profile-root=\"\">\n {children}\n </div>\n </ClientProfileContext>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Phone Control\n// ---------------------------------------------------------------------------\n\ntype PhoneFieldRequirement = 'mandatory' | 'optional';\n\nexport const ClientProfilePhoneControlContent = defineContentType({\n id: 'client-profile-phone-control',\n title: 'Client Profile Phone Control',\n description: \"The phone field's label, its validation messages and the message for a refused save.\",\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n label: { type: 'string', title: 'Label', format: 'icu-message', messageSource: 'Phone' },\n errorInvalid: {\n type: 'string',\n title: 'Invalid error message',\n format: 'icu-message',\n messageSource: 'Invalid phone number',\n },\n errorRequired: {\n type: 'string',\n title: 'Required error message',\n format: 'icu-message',\n messageSource: 'Phone number is required',\n },\n genericErrorMessage: {\n type: 'string',\n title: 'Save failure message',\n description: 'Shown for a network failure and for any refusal the shopper cannot act on.',\n format: 'icu-message',\n messageSource: 'Unable to save your details. Please try again.',\n },\n },\n },\n});\n\n/**\n * `ClientProfileUpdateErrorCode` of API Core's schema plus the client-minted transport failure. None is\n * something the shopper can fix by editing the phone, so all share the generic message.\n */\nexport const CLIENT_PROFILE_PHONE_ERROR_FIELDS = {\n MISSING_CART_CONTEXT: 'genericErrorMessage',\n CART_NOT_FOUND: 'genericErrorMessage',\n NO_PROFILE_FIELD_PROVIDED: 'genericErrorMessage',\n NETWORK_ERROR: 'genericErrorMessage',\n} as const satisfies Record<string, MessageFieldName<typeof ClientProfilePhoneControlContent>>;\n\nexport type ClientProfilePhoneControlProps = MessageLocaleProp & {\n /** Selects the phone mask and validation rule. */\n country?: PhoneCountry;\n /** Controls required validation. */\n requirement?: PhoneFieldRequirement;\n /** The visible label, the messages for an invalid format and a mandatory field left empty, and the\n * message for a refused save. */\n $content?: ContentValue<typeof ClientProfilePhoneControlContent>;\n className?: string;\n /** Injected by the compiler from `actions: { identity: ['clientProfileUpdate'] }`; the write surface. */\n $actions?: ComponentActions;\n};\n\nexport const ClientProfilePhoneControlDefinition = defineComponent<ClientProfilePhoneControlProps>({\n name: 'ClientProfilePhoneControl',\n importPath: '@vtex/faststore/components',\n component: ClientProfilePhoneControl,\n content: ClientProfilePhoneControlContent,\n requiresContext: 'client-profile',\n actions: { identity: ['clientProfileUpdate'] },\n editor: { label: 'Client Profile Phone Control', category: 'identity' },\n schema: {\n country: { type: 'string', default: 'US', label: 'Country (US or BR)' },\n requirement: { type: ['mandatory', 'optional'] as const, default: 'mandatory', label: 'Requirement' },\n },\n guideline:\n 'The bound phone field; must be a descendant of ClientProfileRoot. Reads the saved phone from the ClientProfile entity and persists it on blur via $actions.identity.clientProfileUpdate({ phone }). Composes the reusable PhoneField particle, passing it the $content fields label, errorInvalid and errorRequired; a refused save shows genericErrorMessage.',\n});\n\n/**\n * Renders the bound phone field by composing the reusable `PhoneField` particle. Reads the saved\n * phone from the section context, and on a **changed** value persists only `phone` — normalized to\n * E.164 — through `$actions.identity.clientProfileUpdate({ phone })` on blur (pessimistic,\n * mirroring `EmailIdentificationControl`). While the write is in flight the field is disabled and\n * `data-fs-client-profile-phone-pending` is present so a checkout-CTA guard can block. When the\n * session reports `canEditData: false` the field renders disabled with\n * `data-fs-client-profile-phone-readonly`. Server `userErrors` are surfaced inline, worded by the\n * `$content` field for their code (genericErrorMessage for a code it does not know).\n */\nexport function ClientProfilePhoneControl({\n country = 'US',\n requirement = 'mandatory',\n $content,\n $locale,\n className,\n $actions: $actionsProp,\n}: Readonly<ClientProfilePhoneControlProps>) {\n const $actions = useActionsOverride($actionsProp);\n const { format } = useMessageFormatter(ClientProfilePhoneControlContent, $content);\n const { phone: savedPhone } = useClientProfileContext();\n // VTEX refuses profile edits for an identified-but-unauthenticated claimed profile; render the\n // field read-only instead of accepting a write that is doomed server-side (mirrors\n // EmailIdentificationControl).\n const { canEditData } = useSession();\n const readOnly = !canEditData;\n const [draft, setDraft] = useState(savedPhone);\n // A plain ref, not state: set only from handlers (never during render), and read only inside the\n // render-body re-seed comparison below — nothing here needs its own re-render, since every call\n // site that sets it already triggers one via a sibling state setter in the same tick.\n const dirtyRef = useRef(false);\n const [pending, setPending] = useState(false);\n const [serverError, setServerError] = useState<ClientProfileUserError | null>(null);\n\n // Re-seed the local draft when the saved value changes (e.g. cache update after a write, or a\n // logged-in shopper's profile resolving) — but never while an edit is in progress. A render-phase\n // compare-and-set, not a ref: the comparison baseline lives in state, and the compare-and-set runs\n // during render, so a render React abandons without committing — a suspended transition, a\n // Suspense retry — never leaves a stale baseline behind the way a ref write would, and a reactive\n // fetch landing mid-keystroke still can't silently replace what the shopper just typed.\n const [prevSaved, setPrevSaved] = useState(savedPhone);\n if (prevSaved !== savedPhone) {\n setPrevSaved(savedPhone);\n if (!dirtyRef.current) setDraft(savedPhone);\n }\n\n function serverErrorMessage(error: ClientProfileUserError): string {\n return formatErrorCode(\n ClientProfilePhoneControlContent,\n CLIENT_PROFILE_PHONE_ERROR_FIELDS,\n error,\n format,\n 'genericErrorMessage',\n );\n }\n\n function handleValueChange(next: string) {\n setDraft(next);\n dirtyRef.current = true;\n if (serverError) setServerError(null);\n }\n\n async function handleBlur() {\n const clientProfileUpdate = $actions?.identity?.clientProfileUpdate;\n if (!clientProfileUpdate) return;\n // Untouched → nothing to persist.\n if (draft === savedPhone) return;\n // Client-side invalid → skip the write and let the PhoneField's inline error stand; don't\n // rely on server userErrors for a value the mask/validator already rejects. Mirrors the\n // validity the PhoneField particle computes on blur (mandatory-empty or bad format).\n const isEmpty = !draft.trim();\n if (requirement === 'mandatory' && isEmpty) return;\n if (!isEmpty && !validatePhoneNumber(draft, country)) return;\n const phone = isEmpty ? '' : toE164(draft, country);\n // Unchanged after normalization (e.g. the saved \"+12015551234\" re-typed as \"2015551234\") →\n // nothing to persist either.\n if (phone === savedPhone) return;\n\n setPending(true);\n setServerError(null);\n try {\n const errors = (await clientProfileUpdate({ phone })) ?? [];\n if (errors.length > 0) {\n setServerError(errors[0] ?? null);\n } else {\n // The edit is now committed — clear the guard so a later external change (another tab,\n // a cache refresh) can re-seed the draft again.\n dirtyRef.current = false;\n }\n } finally {\n setPending(false);\n }\n }\n\n return (\n <div\n className={className}\n data-fs-client-profile-phone-control=\"\"\n {...(pending ? { 'data-fs-client-profile-phone-pending': '' } : {})}\n {...(readOnly ? { 'data-fs-client-profile-phone-readonly': '' } : {})}\n >\n <PhoneField\n label={format('label')}\n country={country}\n requirement={requirement}\n errorInvalid={format('errorInvalid')}\n errorRequired={format('errorRequired')}\n value={draft}\n onValueChange={handleValueChange}\n onBlur={handleBlur}\n isDisabled={pending || readOnly}\n invalid={serverError != null || undefined}\n error={serverError ? serverErrorMessage(serverError) : undefined}\n />\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace export\n// ---------------------------------------------------------------------------\n\nexport const ClientProfile = {\n Root: ClientProfileRoot,\n PhoneControl: ClientProfilePhoneControl,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,WAAyB;;;;;;;;;AA4B/B,MAAM,uBAAuB,OAAO,2BAA2B;AAE/D,MAAM,uBAAuB,cAC3B,oBACF;AAEA,SAAS,0BAAqD;CAC5D,MAAM,MAAM,WAAW,oBAAoB;CAC3C,IAAI,QAAQ,sBACV,MAAM,IAAI,MAAM,mEAAmE;CAErF,OAAO;AACT;AAaA,MAAa,8BAA8B,gBA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AAM,CAAC,KAAM,CAAC;GAC1D,IAAI,OAAO,SAAS,GAClB,eAAe,OAAO,MAAM,IAAI;QAIhC,SAAS,UAAU;EAEvB,UAAU;GACR,WAAW,KAAK;EAClB;CACF;CAEA,OACE,oBAAC,OAAD;EACa;EACX,wCAAqC;EACrC,GAAK,UAAU,EAAE,wCAAwC,GAAG,IAAI,CAAC;EACjE,GAAK,WAAW,EAAE,yCAAyC,GAAG,IAAI,CAAC;EAEnE,UAAA,oBAAC,YAAD;GACE,OAAO,OAAO,OAAO;GACZ;GACI;GACb,cAAc,OAAO,cAAc;GACnC,eAAe,OAAO,eAAe;GACrC,OAAO;GACP,eAAe;GACf,QAAQ;GACR,YAAY,WAAW;GACvB,SAAS,eAAe,QAAQ,KAAA;GAChC,OAAO,cAAc,mBAAmB,WAAW,IAAI,KAAA;EACxD,CAAA;CACE,CAAA;AAET;AAMA,MAAa,gBAAgB;CAC3B,MAAM;CACN,cAAc;AAChB"}
|
|
@@ -1,9 +1,110 @@
|
|
|
1
|
+
import { ContentTypeDefinition, ContentValue, MessageLocaleProp } from "../../core/dist/define-content-type.js";
|
|
1
2
|
import { ComponentDefinition } from "../../core/dist/define-component.js";
|
|
2
3
|
import "../../core/dist/index.js";
|
|
3
4
|
import { ComponentActions } from "../../sdk/actions/types.js";
|
|
4
5
|
import { PhoneCountry } from "../../particles/phone-field/phone-field.js";
|
|
5
6
|
import { ComponentPropsWithRef, ReactNode } from "react";
|
|
6
7
|
//#region src/matter/client-profile-form/client-profile-fieldset.d.ts
|
|
8
|
+
export declare const ClientProfileFieldsetContent: {
|
|
9
|
+
readonly id: "client-profile-fieldset";
|
|
10
|
+
readonly title: "Client Profile Fieldset";
|
|
11
|
+
readonly description: "The profile fieldset's loading and loaded announcements and its accessible group name.";
|
|
12
|
+
readonly schema: {
|
|
13
|
+
readonly type: "object";
|
|
14
|
+
readonly additionalProperties: false;
|
|
15
|
+
readonly properties: {
|
|
16
|
+
readonly loadingLabel: {
|
|
17
|
+
readonly type: "string";
|
|
18
|
+
readonly title: "Loading announcement";
|
|
19
|
+
readonly format: "icu-message";
|
|
20
|
+
readonly messageSource: "Loading your details";
|
|
21
|
+
};
|
|
22
|
+
readonly loadedLabel: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly title: "Loaded announcement";
|
|
25
|
+
readonly format: "icu-message";
|
|
26
|
+
readonly messageSource: "Your details are ready";
|
|
27
|
+
};
|
|
28
|
+
readonly groupLabel: {
|
|
29
|
+
readonly type: "string";
|
|
30
|
+
readonly title: "Accessible group name";
|
|
31
|
+
readonly format: "icu-message";
|
|
32
|
+
readonly messageSource: "Your details";
|
|
33
|
+
readonly messageOptional: true;
|
|
34
|
+
};
|
|
35
|
+
readonly genericErrorMessage: {
|
|
36
|
+
readonly type: "string";
|
|
37
|
+
readonly title: "Generic error message";
|
|
38
|
+
readonly description: "Shown by FormError when the details could not be saved.";
|
|
39
|
+
readonly format: "icu-message";
|
|
40
|
+
readonly messageSource: "Unable to save your details. Please try again.";
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export declare const ClientProfileFieldsetPhoneControlContent: {
|
|
46
|
+
readonly id: "client-profile-fieldset-phone";
|
|
47
|
+
readonly title: "Client Profile Fieldset Phone Control";
|
|
48
|
+
readonly description: "The phone control's label and its validation messages.";
|
|
49
|
+
readonly schema: {
|
|
50
|
+
readonly type: "object";
|
|
51
|
+
readonly additionalProperties: false;
|
|
52
|
+
readonly properties: {
|
|
53
|
+
readonly label: {
|
|
54
|
+
readonly type: "string";
|
|
55
|
+
readonly title: "Label";
|
|
56
|
+
readonly format: "icu-message";
|
|
57
|
+
readonly messageSource: "Phone";
|
|
58
|
+
};
|
|
59
|
+
readonly errorInvalid: {
|
|
60
|
+
readonly type: "string";
|
|
61
|
+
readonly title: "Invalid error message";
|
|
62
|
+
readonly format: "icu-message";
|
|
63
|
+
readonly messageSource: "Invalid phone number";
|
|
64
|
+
};
|
|
65
|
+
readonly errorRequired: {
|
|
66
|
+
readonly type: "string";
|
|
67
|
+
readonly title: "Required error message";
|
|
68
|
+
readonly format: "icu-message";
|
|
69
|
+
readonly messageSource: "Phone number is required";
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export declare const ClientProfileFirstNameControlContent: {
|
|
75
|
+
readonly id: "client-profile-first-name";
|
|
76
|
+
readonly title: "Client Profile First Name Control";
|
|
77
|
+
readonly description: "The first-name control's label.";
|
|
78
|
+
readonly schema: {
|
|
79
|
+
readonly type: "object";
|
|
80
|
+
readonly additionalProperties: false;
|
|
81
|
+
readonly properties: {
|
|
82
|
+
readonly label: {
|
|
83
|
+
readonly type: "string";
|
|
84
|
+
readonly title: "Label";
|
|
85
|
+
readonly format: "icu-message";
|
|
86
|
+
readonly messageSource: "First name";
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export declare const ClientProfileLastNameControlContent: {
|
|
92
|
+
readonly id: "client-profile-last-name";
|
|
93
|
+
readonly title: "Client Profile Last Name Control";
|
|
94
|
+
readonly description: "The last-name control's label.";
|
|
95
|
+
readonly schema: {
|
|
96
|
+
readonly type: "object";
|
|
97
|
+
readonly additionalProperties: false;
|
|
98
|
+
readonly properties: {
|
|
99
|
+
readonly label: {
|
|
100
|
+
readonly type: "string";
|
|
101
|
+
readonly title: "Label";
|
|
102
|
+
readonly format: "icu-message";
|
|
103
|
+
readonly messageSource: "Last name";
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
};
|
|
7
108
|
/** The `$data` slice forwarded by the reactive runtime — the ClientProfile sibling entity, unwrapped. */
|
|
8
109
|
export type ClientProfileFieldsetData = {
|
|
9
110
|
firstName?: string | null;
|
|
@@ -11,19 +112,15 @@ export type ClientProfileFieldsetData = {
|
|
|
11
112
|
phone?: string | null;
|
|
12
113
|
document?: string | null;
|
|
13
114
|
} | null;
|
|
14
|
-
export type ClientProfileFieldsetProps = {
|
|
115
|
+
export type ClientProfileFieldsetProps = MessageLocaleProp & {
|
|
15
116
|
/** Phone mask/validation country, provided to the phone control via context. */
|
|
16
117
|
country?: PhoneCountry;
|
|
17
118
|
/** Locale document type; the document control renders only when supported. */
|
|
18
119
|
documentType?: string;
|
|
19
120
|
/** Placeholder rows the loading skeleton draws. Set it to the number of controls composed here. */
|
|
20
121
|
skeletonCount?: number;
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
/** Announced politely once the controls mount. Blank means no announcement. */
|
|
24
|
-
loadedLabel?: string;
|
|
25
|
-
/** Accessible name of the `<fieldset>` group. Blank means no name is exposed. */
|
|
26
|
-
groupLabel?: string;
|
|
122
|
+
/** The loading and loaded announcements and the accessible group name. */
|
|
123
|
+
$content?: ContentValue<typeof ClientProfileFieldsetContent>;
|
|
27
124
|
className?: string;
|
|
28
125
|
children?: ReactNode;
|
|
29
126
|
/** `ClientProfileFieldsetData` slice forwarded by the reactive runtime. */
|
|
@@ -31,16 +128,16 @@ export type ClientProfileFieldsetProps = {
|
|
|
31
128
|
/** Compiler-injected; carries `identity.clientProfileUpdate`. */
|
|
32
129
|
$actions?: ComponentActions;
|
|
33
130
|
};
|
|
34
|
-
type ProfileTextControlProps = {
|
|
35
|
-
label?: string;
|
|
131
|
+
type ProfileTextControlProps<T extends ContentTypeDefinition> = MessageLocaleProp & {
|
|
36
132
|
placeholder?: string;
|
|
133
|
+
/** The control's label. */
|
|
134
|
+
$content?: ContentValue<T>;
|
|
37
135
|
className?: string;
|
|
38
136
|
children?: ReactNode;
|
|
39
137
|
};
|
|
40
|
-
export type ClientProfileFirstNameControlProps = ProfileTextControlProps
|
|
41
|
-
export type ClientProfileLastNameControlProps = ProfileTextControlProps
|
|
42
|
-
export type ClientProfileFieldsetPhoneControlProps = {
|
|
43
|
-
label?: string;
|
|
138
|
+
export type ClientProfileFirstNameControlProps = ProfileTextControlProps<typeof ClientProfileFirstNameControlContent>;
|
|
139
|
+
export type ClientProfileLastNameControlProps = ProfileTextControlProps<typeof ClientProfileLastNameControlContent>;
|
|
140
|
+
export type ClientProfileFieldsetPhoneControlProps = MessageLocaleProp & {
|
|
44
141
|
placeholder?: string;
|
|
45
142
|
/**
|
|
46
143
|
* Raises the field to required. The composite owns it; the contract carries no rule (Decision 6),
|
|
@@ -48,8 +145,8 @@ export type ClientProfileFieldsetPhoneControlProps = {
|
|
|
48
145
|
* optional.
|
|
49
146
|
*/
|
|
50
147
|
requirement?: 'mandatory' | 'optional';
|
|
51
|
-
|
|
52
|
-
|
|
148
|
+
/** The label and the invalid and required messages. */
|
|
149
|
+
$content?: ContentValue<typeof ClientProfileFieldsetPhoneControlContent>;
|
|
53
150
|
className?: string;
|
|
54
151
|
/** Given, replaces PhoneField's default Field.Label + PhoneFieldInput + Field.Error anatomy. */
|
|
55
152
|
children?: ReactNode;
|
|
@@ -63,8 +160,8 @@ export type ClientProfileDocumentControlProps = {
|
|
|
63
160
|
children?: ReactNode;
|
|
64
161
|
};
|
|
65
162
|
export declare const ClientProfileFieldsetDefinition: ComponentDefinition<ClientProfileFieldsetProps>;
|
|
66
|
-
export declare const ClientProfileFirstNameControlDefinition: ComponentDefinition<
|
|
67
|
-
export declare const ClientProfileLastNameControlDefinition: ComponentDefinition<
|
|
163
|
+
export declare const ClientProfileFirstNameControlDefinition: ComponentDefinition<ClientProfileFirstNameControlProps>;
|
|
164
|
+
export declare const ClientProfileLastNameControlDefinition: ComponentDefinition<ClientProfileLastNameControlProps>;
|
|
68
165
|
export declare const ClientProfileFieldsetPhoneControlDefinition: ComponentDefinition<ClientProfileFieldsetPhoneControlProps>;
|
|
69
166
|
export declare const ClientProfileDocumentControlDefinition: ComponentDefinition<ClientProfileDocumentControlProps>;
|
|
70
167
|
/**
|
|
@@ -89,10 +186,10 @@ export declare const ClientProfileDocumentControlDefinition: ComponentDefinition
|
|
|
89
186
|
* carries trees with no reactive root above them, where the slice arrives as a plain prop.
|
|
90
187
|
*
|
|
91
188
|
* Both ends of that wait are spoken: the fieldset carries `aria-busy` while it lasts and holds a polite
|
|
92
|
-
* live region that announces `loadingLabel` and then `loadedLabel
|
|
189
|
+
* live region that announces the `loadingLabel` and then the `loadedLabel` message. Style the region `sr-only` — it is
|
|
93
190
|
* text meant for a screen reader, not for the page.
|
|
94
191
|
*/
|
|
95
|
-
export declare function ClientProfileFieldset({ country, documentType, skeletonCount,
|
|
192
|
+
export declare function ClientProfileFieldset({ country, documentType, skeletonCount, $content, $locale, className, children, $data: $dataProp, $actions: $actionsProp }: ClientProfileFieldsetProps): import("react/jsx-runtime").JSX.Element;
|
|
96
193
|
export declare namespace ClientProfileFieldset {
|
|
97
194
|
var Skeleton: typeof ClientProfileFieldsetSkeleton;
|
|
98
195
|
}
|
|
@@ -104,8 +201,8 @@ export declare namespace ClientProfileFieldset {
|
|
|
104
201
|
export declare function ClientProfileFieldsetSkeleton({ count, className, ...props }: ComponentPropsWithRef<'div'> & {
|
|
105
202
|
count?: number;
|
|
106
203
|
}): import("react/jsx-runtime").JSX.Element;
|
|
107
|
-
export declare function ClientProfileFirstNameControl({
|
|
108
|
-
export declare function ClientProfileLastNameControl({
|
|
204
|
+
export declare function ClientProfileFirstNameControl({ placeholder, $content, $locale, className, children }: ClientProfileFirstNameControlProps): import("react/jsx-runtime").JSX.Element;
|
|
205
|
+
export declare function ClientProfileLastNameControl({ placeholder, $content, $locale, className, children }: ClientProfileLastNameControlProps): import("react/jsx-runtime").JSX.Element;
|
|
109
206
|
/**
|
|
110
207
|
* Composes `PhoneField` inside a `FieldBinding`, wrapped in a `data-fs-client-profile-fieldset-field="phone"`
|
|
111
208
|
* node — the same styling hook attribute the text controls carry on their own `Field.Root`.
|
|
@@ -113,7 +210,7 @@ export declare function ClientProfileLastNameControl({ label, placeholder, class
|
|
|
113
210
|
* state for this control to second-guess; `requirement` only ever raises the field to required,
|
|
114
211
|
* and left unset it raises nothing.
|
|
115
212
|
*/
|
|
116
|
-
export declare function ClientProfileFieldsetPhoneControl({
|
|
213
|
+
export declare function ClientProfileFieldsetPhoneControl({ placeholder, requirement, $content, $locale, className, children }: ClientProfileFieldsetPhoneControlProps): import("react/jsx-runtime").JSX.Element;
|
|
117
214
|
export declare function ClientProfileDocumentControl({ label, placeholder, errorMessage, className, children }: ClientProfileDocumentControlProps): import("react/jsx-runtime").JSX.Element | null;
|
|
118
215
|
//#endregion
|
|
119
216
|
//# sourceMappingURL=client-profile-fieldset.d.ts.map
|