@vtex/faststore 0.0.1
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 +18 -0
- package/LICENSE +21 -0
- package/README.md +95 -0
- package/dist/actions.json +334 -0
- package/dist/catalog.json +6615 -0
- package/dist/client.d.ts +17 -0
- package/dist/client.js +8 -0
- package/dist/components.d.ts +87 -0
- package/dist/components.js +87 -0
- package/dist/content-types.json +684 -0
- package/dist/core/dist/actions/mock-action.d.ts +24 -0
- package/dist/core/dist/actions/mock-action.js +28 -0
- package/dist/core/dist/actions/mock-action.js.map +1 -0
- package/dist/core/dist/actions/registry.d.ts +24 -0
- package/dist/core/dist/actions/registry.js +28 -0
- package/dist/core/dist/actions/registry.js.map +1 -0
- package/dist/core/dist/define-component.d.ts +100 -0
- package/dist/core/dist/define-component.js +8 -0
- package/dist/core/dist/define-component.js.map +1 -0
- package/dist/core/dist/define-content-type.d.ts +95 -0
- package/dist/core/dist/define-content-type.js +283 -0
- package/dist/core/dist/define-content-type.js.map +1 -0
- package/dist/core/dist/index.d.ts +7 -0
- package/dist/core/dist/index.js +5 -0
- package/dist/core/dist/schema/generated/schema.d.ts +28 -0
- package/dist/core/dist/types.d.ts +1 -0
- package/dist/docs/access-code-field.md +100 -0
- package/dist/docs/access-code-sign-in.md +174 -0
- package/dist/docs/account-entry-point.md +155 -0
- package/dist/docs/address-summary.md +50 -0
- package/dist/docs/buy-button.md +162 -0
- package/dist/docs/carousel.md +105 -0
- package/dist/docs/cart-item.md +162 -0
- package/dist/docs/cart-totalizer.md +197 -0
- package/dist/docs/cart.md +495 -0
- package/dist/docs/client-preferences.md +184 -0
- package/dist/docs/client-profile-form.md +192 -0
- package/dist/docs/client-profile.md +117 -0
- package/dist/docs/container.md +97 -0
- package/dist/docs/document-field.md +97 -0
- package/dist/docs/email-field.md +93 -0
- package/dist/docs/email-identification.md +102 -0
- package/dist/docs/footer-copyright.md +112 -0
- package/dist/docs/footer-link-group.md +162 -0
- package/dist/docs/footer-root.md +145 -0
- package/dist/docs/footer-social.md +151 -0
- package/dist/docs/free-shipping-progress.md +87 -0
- package/dist/docs/gallery.md +84 -0
- package/dist/docs/header-root.md +150 -0
- package/dist/docs/identity-edit.md +88 -0
- package/dist/docs/identity-summary.md +106 -0
- package/dist/docs/incentives.md +151 -0
- package/dist/docs/logo.md +135 -0
- package/dist/docs/meter.md +67 -0
- package/dist/docs/navigation-link-list.md +171 -0
- package/dist/docs/navigation-link.md +163 -0
- package/dist/docs/navigation-menu.md +264 -0
- package/dist/docs/payment-methods.md +139 -0
- package/dist/docs/phone-field.md +106 -0
- package/dist/docs/postal-code-field.md +126 -0
- package/dist/docs/pricing.md +499 -0
- package/dist/docs/product-gallery.md +409 -0
- package/dist/docs/product-information.md +295 -0
- package/dist/docs/product-list.md +170 -0
- package/dist/docs/product-quantity.md +88 -0
- package/dist/docs/product-shelf.md +141 -0
- package/dist/docs/promotion.md +109 -0
- package/dist/docs/region.md +225 -0
- package/dist/docs/session.md +123 -0
- package/dist/docs/shipping-address.md +390 -0
- package/dist/docs/shipping-simulator.md +147 -0
- package/dist/docs/sign-in-form.md +117 -0
- package/dist/docs/tabs.md +176 -0
- package/dist/docs/toast.md +124 -0
- package/dist/docs/variant-selector.md +450 -0
- package/dist/graphql/define-subgraph.d.ts +12 -0
- package/dist/graphql/define-subgraph.js +15 -0
- package/dist/graphql/define-subgraph.js.map +1 -0
- package/dist/graphql/gql.d.ts +10 -0
- package/dist/graphql/gql.js +16 -0
- package/dist/graphql/gql.js.map +1 -0
- package/dist/graphql/types.d.ts +88 -0
- package/dist/graphql.d.ts +4 -0
- package/dist/graphql.js +3 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +5 -0
- package/dist/internal/client.d.ts +24 -0
- package/dist/internal/client.js +23 -0
- package/dist/internal/content.d.ts +2 -0
- package/dist/internal/content.js +2 -0
- package/dist/internal/server.d.ts +7 -0
- package/dist/internal/server.js +6 -0
- package/dist/matter/access-code-sign-in/access-code-sign-in.d.ts +111 -0
- package/dist/matter/access-code-sign-in/access-code-sign-in.js +387 -0
- package/dist/matter/access-code-sign-in/access-code-sign-in.js.map +1 -0
- package/dist/matter/account-entry-point/account-entry-point.d.ts +64 -0
- package/dist/matter/account-entry-point/account-entry-point.js +151 -0
- package/dist/matter/account-entry-point/account-entry-point.js.map +1 -0
- package/dist/matter/breadcrumb/breadcrumb.d.ts +40 -0
- package/dist/matter/breadcrumb/breadcrumb.js +155 -0
- package/dist/matter/breadcrumb/breadcrumb.js.map +1 -0
- package/dist/matter/buy-button/buy-button.d.ts +95 -0
- package/dist/matter/buy-button/buy-button.js +259 -0
- package/dist/matter/buy-button/buy-button.js.map +1 -0
- package/dist/matter/cart/cart-namespace.d.ts +48 -0
- package/dist/matter/cart/cart-namespace.js +50 -0
- package/dist/matter/cart/cart-namespace.js.map +1 -0
- package/dist/matter/cart/cart.d.ts +312 -0
- package/dist/matter/cart/cart.js +1034 -0
- package/dist/matter/cart/cart.js.map +1 -0
- package/dist/matter/cart-item/cart-item.d.ts +103 -0
- package/dist/matter/cart-item/cart-item.js +672 -0
- package/dist/matter/cart-item/cart-item.js.map +1 -0
- package/dist/matter/cart-item-compositions/cart-item-compositions.d.ts +49 -0
- package/dist/matter/cart-item-compositions/cart-item-compositions.js +165 -0
- package/dist/matter/cart-item-compositions/cart-item-compositions.js.map +1 -0
- package/dist/matter/cart-item-customizations/cart-item-customizations.d.ts +28 -0
- package/dist/matter/cart-item-customizations/cart-item-customizations.js +73 -0
- package/dist/matter/cart-item-customizations/cart-item-customizations.js.map +1 -0
- package/dist/matter/cart-item-discounts/cart-item-discounts.d.ts +33 -0
- package/dist/matter/cart-item-discounts/cart-item-discounts.js +70 -0
- package/dist/matter/cart-item-discounts/cart-item-discounts.js.map +1 -0
- package/dist/matter/cart-item-seller-info/cart-item-seller-info.d.ts +24 -0
- package/dist/matter/cart-item-seller-info/cart-item-seller-info.js +54 -0
- package/dist/matter/cart-item-seller-info/cart-item-seller-info.js.map +1 -0
- package/dist/matter/cart-item-variations/cart-item-variations.d.ts +27 -0
- package/dist/matter/cart-item-variations/cart-item-variations.js +69 -0
- package/dist/matter/cart-item-variations/cart-item-variations.js.map +1 -0
- package/dist/matter/cart-totalizer/cart-totalizer.d.ts +78 -0
- package/dist/matter/cart-totalizer/cart-totalizer.js +220 -0
- package/dist/matter/cart-totalizer/cart-totalizer.js.map +1 -0
- package/dist/matter/client-preferences/client-preferences.d.ts +50 -0
- package/dist/matter/client-preferences/client-preferences.js +206 -0
- package/dist/matter/client-preferences/client-preferences.js.map +1 -0
- package/dist/matter/client-profile/client-profile.d.ts +59 -0
- package/dist/matter/client-profile/client-profile.js +185 -0
- package/dist/matter/client-profile/client-profile.js.map +1 -0
- package/dist/matter/client-profile-form/client-profile-form.d.ts +126 -0
- package/dist/matter/client-profile-form/client-profile-form.js +660 -0
- package/dist/matter/client-profile-form/client-profile-form.js.map +1 -0
- package/dist/matter/delivery-options/delivery-options-accordion.d.ts +30 -0
- package/dist/matter/delivery-options/delivery-options-accordion.js +189 -0
- package/dist/matter/delivery-options/delivery-options-accordion.js.map +1 -0
- package/dist/matter/delivery-options/delivery-options-controller.d.ts +49 -0
- package/dist/matter/delivery-options/delivery-options-controller.js +203 -0
- package/dist/matter/delivery-options/delivery-options-controller.js.map +1 -0
- package/dist/matter/delivery-options/delivery-options.d.ts +31 -0
- package/dist/matter/delivery-options/delivery-options.js +103 -0
- package/dist/matter/delivery-options/delivery-options.js.map +1 -0
- package/dist/matter/delivery-options/use-delivery-option-selection.d.ts +9 -0
- package/dist/matter/delivery-options/use-delivery-option-selection.js +76 -0
- package/dist/matter/delivery-options/use-delivery-option-selection.js.map +1 -0
- package/dist/matter/email-identification/email-identification.d.ts +37 -0
- package/dist/matter/email-identification/email-identification.js +111 -0
- package/dist/matter/email-identification/email-identification.js.map +1 -0
- package/dist/matter/free-shipping-progress/free-shipping-progress.d.ts +44 -0
- package/dist/matter/free-shipping-progress/free-shipping-progress.js +170 -0
- package/dist/matter/free-shipping-progress/free-shipping-progress.js.map +1 -0
- package/dist/matter/identity-edit/identity-edit.d.ts +52 -0
- package/dist/matter/identity-edit/identity-edit.js +148 -0
- package/dist/matter/identity-edit/identity-edit.js.map +1 -0
- package/dist/matter/identity-summary/identity-summary.d.ts +128 -0
- package/dist/matter/identity-summary/identity-summary.js +344 -0
- package/dist/matter/identity-summary/identity-summary.js.map +1 -0
- package/dist/matter/pricing/pricing.d.ts +162 -0
- package/dist/matter/pricing/pricing.js +793 -0
- package/dist/matter/pricing/pricing.js.map +1 -0
- package/dist/matter/product-gallery/product-gallery.d.ts +23 -0
- package/dist/matter/product-gallery/product-gallery.js +188 -0
- package/dist/matter/product-gallery/product-gallery.js.map +1 -0
- package/dist/matter/product-information/product-information.d.ts +61 -0
- package/dist/matter/product-information/product-information.js +355 -0
- package/dist/matter/product-information/product-information.js.map +1 -0
- package/dist/matter/product-list/product-list.d.ts +86 -0
- package/dist/matter/product-list/product-list.js +342 -0
- package/dist/matter/product-list/product-list.js.map +1 -0
- package/dist/matter/product-quantity/product-quantity.d.ts +50 -0
- package/dist/matter/product-quantity/product-quantity.js +111 -0
- package/dist/matter/product-quantity/product-quantity.js.map +1 -0
- package/dist/matter/product-shelf/product-shelf.d.ts +125 -0
- package/dist/matter/product-shelf/product-shelf.js +376 -0
- package/dist/matter/product-shelf/product-shelf.js.map +1 -0
- package/dist/matter/region/region.d.ts +211 -0
- package/dist/matter/region/region.js +579 -0
- package/dist/matter/region/region.js.map +1 -0
- package/dist/matter/session/session.d.ts +58 -0
- package/dist/matter/session/session.js +112 -0
- package/dist/matter/session/session.js.map +1 -0
- package/dist/matter/shipping-address/country-descriptors.js +101 -0
- package/dist/matter/shipping-address/country-descriptors.js.map +1 -0
- package/dist/matter/shipping-address/shipping-address.d.ts +284 -0
- package/dist/matter/shipping-address/shipping-address.js +1036 -0
- package/dist/matter/shipping-address/shipping-address.js.map +1 -0
- package/dist/matter/shipping-simulator/shipping-simulator.d.ts +143 -0
- package/dist/matter/shipping-simulator/shipping-simulator.js +644 -0
- package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -0
- package/dist/matter/sign-in-form/sign-in-form.d.ts +79 -0
- package/dist/matter/sign-in-form/sign-in-form.js +226 -0
- package/dist/matter/sign-in-form/sign-in-form.js.map +1 -0
- package/dist/matter/variant-selector/variant-selector.d.ts +183 -0
- package/dist/matter/variant-selector/variant-selector.js +840 -0
- package/dist/matter/variant-selector/variant-selector.js.map +1 -0
- package/dist/message-locales.json +7 -0
- package/dist/particles/access-code-field/access-code-field.d.ts +33 -0
- package/dist/particles/access-code-field/access-code-field.js +95 -0
- package/dist/particles/access-code-field/access-code-field.js.map +1 -0
- package/dist/particles/accordion/accordion.d.ts +45 -0
- package/dist/particles/accordion/accordion.js +156 -0
- package/dist/particles/accordion/accordion.js.map +1 -0
- package/dist/particles/address-summary/address-summary.d.ts +50 -0
- package/dist/particles/address-summary/address-summary.js +129 -0
- package/dist/particles/address-summary/address-summary.js.map +1 -0
- package/dist/particles/badge/badge.d.ts +10 -0
- package/dist/particles/badge/badge.js +27 -0
- package/dist/particles/badge/badge.js.map +1 -0
- package/dist/particles/button/button.d.ts +18 -0
- package/dist/particles/button/button.js +37 -0
- package/dist/particles/button/button.js.map +1 -0
- package/dist/particles/carousel/carousel.d.ts +60 -0
- package/dist/particles/carousel/carousel.js +335 -0
- package/dist/particles/carousel/carousel.js.map +1 -0
- package/dist/particles/checkbox/checkbox.d.ts +40 -0
- package/dist/particles/checkbox/checkbox.js +82 -0
- package/dist/particles/checkbox/checkbox.js.map +1 -0
- package/dist/particles/container/container.d.ts +20 -0
- package/dist/particles/container/container.js +36 -0
- package/dist/particles/container/container.js.map +1 -0
- package/dist/particles/dialog/dialog.d.ts +54 -0
- package/dist/particles/dialog/dialog.js +192 -0
- package/dist/particles/dialog/dialog.js.map +1 -0
- package/dist/particles/document-field/document-field.d.ts +61 -0
- package/dist/particles/document-field/document-field.js +146 -0
- package/dist/particles/document-field/document-field.js.map +1 -0
- package/dist/particles/drawer/drawer.d.ts +52 -0
- package/dist/particles/drawer/drawer.js +183 -0
- package/dist/particles/drawer/drawer.js.map +1 -0
- package/dist/particles/email-field/email-field.d.ts +37 -0
- package/dist/particles/email-field/email-field.js +106 -0
- package/dist/particles/email-field/email-field.js.map +1 -0
- package/dist/particles/field/field.d.ts +50 -0
- package/dist/particles/field/field.js +133 -0
- package/dist/particles/field/field.js.map +1 -0
- package/dist/particles/fieldset/fieldset.d.ts +16 -0
- package/dist/particles/fieldset/fieldset.js +52 -0
- package/dist/particles/fieldset/fieldset.js.map +1 -0
- package/dist/particles/footer-copyright/footer-copyright.d.ts +32 -0
- package/dist/particles/footer-copyright/footer-copyright.js +50 -0
- package/dist/particles/footer-copyright/footer-copyright.js.map +1 -0
- package/dist/particles/footer-link-group/footer-link-group.d.ts +66 -0
- package/dist/particles/footer-link-group/footer-link-group.js +154 -0
- package/dist/particles/footer-link-group/footer-link-group.js.map +1 -0
- package/dist/particles/footer-root/footer-root.d.ts +21 -0
- package/dist/particles/footer-root/footer-root.js +38 -0
- package/dist/particles/footer-root/footer-root.js.map +1 -0
- package/dist/particles/footer-social/footer-social.d.ts +79 -0
- package/dist/particles/footer-social/footer-social.js +176 -0
- package/dist/particles/footer-social/footer-social.js.map +1 -0
- package/dist/particles/gallery/gallery.d.ts +181 -0
- package/dist/particles/gallery/gallery.js +920 -0
- package/dist/particles/gallery/gallery.js.map +1 -0
- package/dist/particles/header-root/header-root.d.ts +21 -0
- package/dist/particles/header-root/header-root.js +38 -0
- package/dist/particles/header-root/header-root.js.map +1 -0
- package/dist/particles/icon/icon.d.ts +22 -0
- package/dist/particles/icon/icon.js +48 -0
- package/dist/particles/icon/icon.js.map +1 -0
- package/dist/particles/image/image.d.ts +13 -0
- package/dist/particles/image/image.js +59 -0
- package/dist/particles/image/image.js.map +1 -0
- package/dist/particles/incentives/incentives.d.ts +85 -0
- package/dist/particles/incentives/incentives.js +200 -0
- package/dist/particles/incentives/incentives.js.map +1 -0
- package/dist/particles/input/input.d.ts +9 -0
- package/dist/particles/input/input.js +28 -0
- package/dist/particles/input/input.js.map +1 -0
- package/dist/particles/logo/logo.d.ts +55 -0
- package/dist/particles/logo/logo.js +96 -0
- package/dist/particles/logo/logo.js.map +1 -0
- package/dist/particles/menu/menu.d.ts +103 -0
- package/dist/particles/menu/menu.js +409 -0
- package/dist/particles/menu/menu.js.map +1 -0
- package/dist/particles/menubar/menubar.d.ts +18 -0
- package/dist/particles/menubar/menubar.js +42 -0
- package/dist/particles/menubar/menubar.js.map +1 -0
- package/dist/particles/meter/meter.d.ts +36 -0
- package/dist/particles/meter/meter.js +132 -0
- package/dist/particles/meter/meter.js.map +1 -0
- package/dist/particles/navigation-link/navigation-link.d.ts +43 -0
- package/dist/particles/navigation-link/navigation-link.js +82 -0
- package/dist/particles/navigation-link/navigation-link.js.map +1 -0
- package/dist/particles/navigation-link-list/navigation-link-list.d.ts +59 -0
- package/dist/particles/navigation-link-list/navigation-link-list.js +103 -0
- package/dist/particles/navigation-link-list/navigation-link-list.js.map +1 -0
- package/dist/particles/navigation-menu/navigation-menu.d.ts +78 -0
- package/dist/particles/navigation-menu/navigation-menu.js +295 -0
- package/dist/particles/navigation-menu/navigation-menu.js.map +1 -0
- package/dist/particles/number-field/number-field.d.ts +46 -0
- package/dist/particles/number-field/number-field.js +169 -0
- package/dist/particles/number-field/number-field.js.map +1 -0
- package/dist/particles/password-field/password-field.d.ts +31 -0
- package/dist/particles/password-field/password-field.js +109 -0
- package/dist/particles/password-field/password-field.js.map +1 -0
- package/dist/particles/payment-methods/payment-methods.d.ts +72 -0
- package/dist/particles/payment-methods/payment-methods.js +151 -0
- package/dist/particles/payment-methods/payment-methods.js.map +1 -0
- package/dist/particles/phone-field/phone-field.d.ts +67 -0
- package/dist/particles/phone-field/phone-field.js +250 -0
- package/dist/particles/phone-field/phone-field.js.map +1 -0
- package/dist/particles/popover/popover.d.ts +68 -0
- package/dist/particles/popover/popover.js +284 -0
- package/dist/particles/popover/popover.js.map +1 -0
- package/dist/particles/postal-code-field/postal-code-field.d.ts +75 -0
- package/dist/particles/postal-code-field/postal-code-field.js +169 -0
- package/dist/particles/postal-code-field/postal-code-field.js.map +1 -0
- package/dist/particles/promotion/promotion.d.ts +46 -0
- package/dist/particles/promotion/promotion.js +78 -0
- package/dist/particles/promotion/promotion.js.map +1 -0
- package/dist/particles/quantity-selector/quantity-selector.d.ts +30 -0
- package/dist/particles/quantity-selector/quantity-selector.js +116 -0
- package/dist/particles/quantity-selector/quantity-selector.js.map +1 -0
- package/dist/particles/radio/radio.d.ts +36 -0
- package/dist/particles/radio/radio.js +76 -0
- package/dist/particles/radio/radio.js.map +1 -0
- package/dist/particles/scroll-area/scroll-area.d.ts +36 -0
- package/dist/particles/scroll-area/scroll-area.js +145 -0
- package/dist/particles/scroll-area/scroll-area.js.map +1 -0
- package/dist/particles/select/select.d.ts +125 -0
- package/dist/particles/select/select.js +478 -0
- package/dist/particles/select/select.js.map +1 -0
- package/dist/particles/separator/separator.d.ts +12 -0
- package/dist/particles/separator/separator.js +33 -0
- package/dist/particles/separator/separator.js.map +1 -0
- package/dist/particles/shared/input-mask.d.ts +5 -0
- package/dist/particles/shared/input-mask.js +58 -0
- package/dist/particles/shared/input-mask.js.map +1 -0
- package/dist/particles/spinner/spinner.d.ts +13 -0
- package/dist/particles/spinner/spinner.js +31 -0
- package/dist/particles/spinner/spinner.js.map +1 -0
- package/dist/particles/switch/switch.d.ts +27 -0
- package/dist/particles/switch/switch.js +59 -0
- package/dist/particles/switch/switch.js.map +1 -0
- package/dist/particles/tabs/tabs.d.ts +45 -0
- package/dist/particles/tabs/tabs.js +164 -0
- package/dist/particles/tabs/tabs.js.map +1 -0
- package/dist/particles/text/text.d.ts +24 -0
- package/dist/particles/text/text.js +40 -0
- package/dist/particles/text/text.js.map +1 -0
- package/dist/particles/toast/toast.d.ts +83 -0
- package/dist/particles/toast/toast.js +194 -0
- package/dist/particles/toast/toast.js.map +1 -0
- package/dist/particles/toggle/toggle.d.ts +26 -0
- package/dist/particles/toggle/toggle.js +61 -0
- package/dist/particles/toggle/toggle.js.map +1 -0
- package/dist/particles/tooltip/tooltip.d.ts +61 -0
- package/dist/particles/tooltip/tooltip.js +240 -0
- package/dist/particles/tooltip/tooltip.js.map +1 -0
- package/dist/schema.graphql +2953 -0
- package/dist/sdk/actions/cart-action-provider.d.ts +19 -0
- package/dist/sdk/actions/cart-action-provider.js +23 -0
- package/dist/sdk/actions/cart-action-provider.js.map +1 -0
- package/dist/sdk/actions/identity-action-provider.d.ts +15 -0
- package/dist/sdk/actions/identity-action-provider.js +19 -0
- package/dist/sdk/actions/identity-action-provider.js.map +1 -0
- package/dist/sdk/actions/index.d.ts +7 -0
- package/dist/sdk/actions/index.js +6 -0
- package/dist/sdk/actions/inject-actions.d.ts +14 -0
- package/dist/sdk/actions/inject-actions.js +36 -0
- package/dist/sdk/actions/inject-actions.js.map +1 -0
- package/dist/sdk/actions/region-action-provider.d.ts +15 -0
- package/dist/sdk/actions/region-action-provider.js +19 -0
- package/dist/sdk/actions/region-action-provider.js.map +1 -0
- package/dist/sdk/actions/session-action-provider.d.ts +15 -0
- package/dist/sdk/actions/session-action-provider.js +19 -0
- package/dist/sdk/actions/session-action-provider.js.map +1 -0
- package/dist/sdk/actions/shipping-action-provider.d.ts +15 -0
- package/dist/sdk/actions/shipping-action-provider.js +19 -0
- package/dist/sdk/actions/shipping-action-provider.js.map +1 -0
- package/dist/sdk/actions/types.d.ts +21 -0
- package/dist/sdk/cache/storefront-cache.js +35 -0
- package/dist/sdk/cache/storefront-cache.js.map +1 -0
- package/dist/sdk/cart/operations.d.ts +31 -0
- package/dist/sdk/cart/operations.js +215 -0
- package/dist/sdk/cart/operations.js.map +1 -0
- package/dist/sdk/cart/optimistic.d.ts +24 -0
- package/dist/sdk/cart/optimistic.js +164 -0
- package/dist/sdk/cart/optimistic.js.map +1 -0
- package/dist/sdk/cart/use-cart-actions.d.ts +56 -0
- package/dist/sdk/cart/use-cart-actions.js +348 -0
- package/dist/sdk/cart/use-cart-actions.js.map +1 -0
- package/dist/sdk/cart/use-cart-validate-on-open.js +50 -0
- package/dist/sdk/cart/use-cart-validate-on-open.js.map +1 -0
- package/dist/sdk/cart/write-gate.js +54 -0
- package/dist/sdk/cart/write-gate.js.map +1 -0
- package/dist/sdk/client/assert-api-url.js +20 -0
- package/dist/sdk/client/assert-api-url.js.map +1 -0
- package/dist/sdk/client/create-client.d.ts +23 -0
- package/dist/sdk/client/create-client.js +46 -0
- package/dist/sdk/client/create-client.js.map +1 -0
- package/dist/sdk/client/fetch-page-data.d.ts +39 -0
- package/dist/sdk/client/fetch-page-data.js +33 -0
- package/dist/sdk/client/fetch-page-data.js.map +1 -0
- package/dist/sdk/client/register-preload-query.d.ts +24 -0
- package/dist/sdk/client/register-preload-query.js +33 -0
- package/dist/sdk/client/register-preload-query.js.map +1 -0
- package/dist/sdk/content/create-content-runtime.d.ts +68 -0
- package/dist/sdk/content/create-content-runtime.js +503 -0
- package/dist/sdk/content/create-content-runtime.js.map +1 -0
- package/dist/sdk/context/headers.d.ts +15 -0
- package/dist/sdk/context/headers.js +21 -0
- package/dist/sdk/context/headers.js.map +1 -0
- package/dist/sdk/context/storefront-context.d.ts +11 -0
- package/dist/sdk/context/storefront-context.js +29 -0
- package/dist/sdk/context/storefront-context.js.map +1 -0
- package/dist/sdk/data/data-override-context.d.ts +12 -0
- package/dist/sdk/data/data-override-context.js +19 -0
- package/dist/sdk/data/data-override-context.js.map +1 -0
- package/dist/sdk/data/entity-subscriber.js +28 -0
- package/dist/sdk/data/entity-subscriber.js.map +1 -0
- package/dist/sdk/data/hot-data-provider.d.ts +19 -0
- package/dist/sdk/data/hot-data-provider.js +33 -0
- package/dist/sdk/data/hot-data-provider.js.map +1 -0
- package/dist/sdk/data/index.d.ts +8 -0
- package/dist/sdk/data/index.js +8 -0
- package/dist/sdk/data/list-item-ref-context.d.ts +20 -0
- package/dist/sdk/data/list-item-ref-context.js +11 -0
- package/dist/sdk/data/list-item-ref-context.js.map +1 -0
- package/dist/sdk/data/multiple-reactive-data-provider.d.ts +32 -0
- package/dist/sdk/data/multiple-reactive-data-provider.js +20 -0
- package/dist/sdk/data/multiple-reactive-data-provider.js.map +1 -0
- package/dist/sdk/data/page-reactive-data-root.d.ts +53 -0
- package/dist/sdk/data/page-reactive-data-root.js +153 -0
- package/dist/sdk/data/page-reactive-data-root.js.map +1 -0
- package/dist/sdk/data/reactive-data-provider.d.ts +25 -0
- package/dist/sdk/data/reactive-data-provider.js +24 -0
- package/dist/sdk/data/reactive-data-provider.js.map +1 -0
- package/dist/sdk/data/reactive-list-item-data-provider.d.ts +26 -0
- package/dist/sdk/data/reactive-list-item-data-provider.js +42 -0
- package/dist/sdk/data/reactive-list-item-data-provider.js.map +1 -0
- package/dist/sdk/data/use-reactive-entity.js +40 -0
- package/dist/sdk/data/use-reactive-entity.js.map +1 -0
- package/dist/sdk/format/client.d.ts +12 -0
- package/dist/sdk/format/client.js +20 -0
- package/dist/sdk/format/client.js.map +1 -0
- package/dist/sdk/format/formatters.d.ts +32 -0
- package/dist/sdk/format/formatters.js +45 -0
- package/dist/sdk/format/formatters.js.map +1 -0
- package/dist/sdk/generated/fragment-types.js +23 -0
- package/dist/sdk/generated/fragment-types.js.map +1 -0
- package/dist/sdk/generated/gql.js +51 -0
- package/dist/sdk/generated/gql.js.map +1 -0
- package/dist/sdk/generated/graphql.d.ts +622 -0
- package/dist/sdk/generated/graphql.js +11917 -0
- package/dist/sdk/generated/graphql.js.map +1 -0
- package/dist/sdk/graphql-tag.d.ts +10 -0
- package/dist/sdk/graphql-tag.js +21 -0
- package/dist/sdk/graphql-tag.js.map +1 -0
- package/dist/sdk/i18n/client.d.ts +4 -0
- package/dist/sdk/i18n/client.js +4 -0
- package/dist/sdk/i18n/locales.d.ts +8 -0
- package/dist/sdk/i18n/locales.js +57 -0
- package/dist/sdk/i18n/locales.js.map +1 -0
- package/dist/sdk/i18n/messages/en-US.js +24 -0
- package/dist/sdk/i18n/messages/en-US.js.map +1 -0
- package/dist/sdk/i18n/messages/en-US.json +19 -0
- package/dist/sdk/i18n/messages/en-US.json.d.ts +23 -0
- package/dist/sdk/i18n/messages/es-ES.js +24 -0
- package/dist/sdk/i18n/messages/es-ES.js.map +1 -0
- package/dist/sdk/i18n/messages/es-ES.json +19 -0
- package/dist/sdk/i18n/messages/pt-BR.js +24 -0
- package/dist/sdk/i18n/messages/pt-BR.js.map +1 -0
- package/dist/sdk/i18n/messages/pt-BR.json +19 -0
- package/dist/sdk/i18n/provider.d.ts +1 -0
- package/dist/sdk/i18n/provider.js +30 -0
- package/dist/sdk/i18n/provider.js.map +1 -0
- package/dist/sdk/i18n/server.d.ts +28 -0
- package/dist/sdk/i18n/server.js +59 -0
- package/dist/sdk/i18n/server.js.map +1 -0
- package/dist/sdk/identity/operations.d.ts +34 -0
- package/dist/sdk/identity/operations.js +78 -0
- package/dist/sdk/identity/operations.js.map +1 -0
- package/dist/sdk/identity/use-identity-actions.d.ts +62 -0
- package/dist/sdk/identity/use-identity-actions.js +180 -0
- package/dist/sdk/identity/use-identity-actions.js.map +1 -0
- package/dist/sdk/provider/index.d.ts +2 -0
- package/dist/sdk/provider/index.js +2 -0
- package/dist/sdk/provider/storefront-provider.d.ts +32 -0
- package/dist/sdk/provider/storefront-provider.js +111 -0
- package/dist/sdk/provider/storefront-provider.js.map +1 -0
- package/dist/sdk/region/operations.d.ts +6 -0
- package/dist/sdk/region/region-operations.d.ts +30 -0
- package/dist/sdk/region/region-operations.js +23 -0
- package/dist/sdk/region/region-operations.js.map +1 -0
- package/dist/sdk/region/use-region-actions.d.ts +23 -0
- package/dist/sdk/region/use-region-actions.js +66 -0
- package/dist/sdk/region/use-region-actions.js.map +1 -0
- package/dist/sdk/seller.js +11 -0
- package/dist/sdk/seller.js.map +1 -0
- package/dist/sdk/session/auth-operations.d.ts +47 -0
- package/dist/sdk/session/auth-operations.js +79 -0
- package/dist/sdk/session/auth-operations.js.map +1 -0
- package/dist/sdk/session/operations.d.ts +6 -0
- package/dist/sdk/session/use-session-actions.d.ts +27 -0
- package/dist/sdk/session/use-session-actions.js +126 -0
- package/dist/sdk/session/use-session-actions.js.map +1 -0
- package/dist/sdk/shipping/cart-operations.d.ts +3 -0
- package/dist/sdk/shipping/cart-operations.js +33 -0
- package/dist/sdk/shipping/cart-operations.js.map +1 -0
- package/dist/sdk/shipping/operations.d.ts +3 -0
- package/dist/sdk/shipping/operations.js +33 -0
- package/dist/sdk/shipping/operations.js.map +1 -0
- package/dist/sdk/shipping/option-select-operations.d.ts +24 -0
- package/dist/sdk/shipping/option-select-operations.js +45 -0
- package/dist/sdk/shipping/option-select-operations.js.map +1 -0
- package/dist/sdk/shipping/request-timeout.js +41 -0
- package/dist/sdk/shipping/request-timeout.js.map +1 -0
- package/dist/sdk/shipping/shipping-operations.d.ts +38 -0
- package/dist/sdk/shipping/shipping-operations.js +77 -0
- package/dist/sdk/shipping/shipping-operations.js.map +1 -0
- package/dist/sdk/shipping/use-cart-shipping-simulation.d.ts +7 -0
- package/dist/sdk/shipping/use-cart-shipping-simulation.js +72 -0
- package/dist/sdk/shipping/use-cart-shipping-simulation.js.map +1 -0
- package/dist/sdk/shipping/use-shipping-actions.d.ts +27 -0
- package/dist/sdk/shipping/use-shipping-actions.js +113 -0
- package/dist/sdk/shipping/use-shipping-actions.js.map +1 -0
- package/dist/sdk/shipping/use-shipping-simulation.d.ts +7 -0
- package/dist/sdk/shipping/use-shipping-simulation.js +72 -0
- package/dist/sdk/shipping/use-shipping-simulation.js.map +1 -0
- package/dist/sdk/state/cart.d.ts +42 -0
- package/dist/sdk/state/cart.js +64 -0
- package/dist/sdk/state/cart.js.map +1 -0
- package/dist/sdk/state/index.js +3 -0
- package/dist/sdk/state/variant-selector.d.ts +17 -0
- package/dist/sdk/state/variant-selector.js +14 -0
- package/dist/sdk/state/variant-selector.js.map +1 -0
- package/dist/utils/safe-href.js +63 -0
- package/dist/utils/safe-href.js.map +1 -0
- package/package.json +84 -0
- package/src/styles/tailwind.css +32 -0
|
@@ -0,0 +1,644 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { defineComponent } from "../../core/dist/define-component.js";
|
|
3
|
+
import "../../core/dist/index.js";
|
|
4
|
+
import { useStorefrontContext } from "../../sdk/context/storefront-context.js";
|
|
5
|
+
import { FormattedMessage, useIntl } from "../../sdk/i18n/client.js";
|
|
6
|
+
import { useCartShippingSimulation } from "../../sdk/shipping/use-cart-shipping-simulation.js";
|
|
7
|
+
import { useShippingSimulation } from "../../sdk/shipping/use-shipping-simulation.js";
|
|
8
|
+
import { useDataOverride } from "../../sdk/data/data-override-context.js";
|
|
9
|
+
import { createContext, useCallback, useContext, useMemo, useRef, useState } from "react";
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
//#region src/matter/shipping-simulator/shipping-simulator.tsx
|
|
12
|
+
const fragment = `
|
|
13
|
+
fragment ShippingSimulatorData on Query {
|
|
14
|
+
productBySlug(slug: $slug) {
|
|
15
|
+
variants(first: 1) {
|
|
16
|
+
edges {
|
|
17
|
+
node {
|
|
18
|
+
id
|
|
19
|
+
sellers {
|
|
20
|
+
id
|
|
21
|
+
isDefault
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
const SHIPPING_SIMULATOR_CONTEXT_UNSET = Symbol("ShippingSimulatorContextUnset");
|
|
30
|
+
const ShippingSimulatorContext = createContext(SHIPPING_SIMULATOR_CONTEXT_UNSET);
|
|
31
|
+
const OptionItemContext = createContext(null);
|
|
32
|
+
function useShippingSimulator() {
|
|
33
|
+
const ctx = useContext(ShippingSimulatorContext);
|
|
34
|
+
if (ctx === SHIPPING_SIMULATOR_CONTEXT_UNSET) throw new Error("ShippingSimulator components must be used inside ShippingSimulatorRoot.");
|
|
35
|
+
return ctx;
|
|
36
|
+
}
|
|
37
|
+
function useOptionItem() {
|
|
38
|
+
const ctx = useContext(OptionItemContext);
|
|
39
|
+
if (!ctx) throw new Error("ShippingSimulatorOption components must be used inside ShippingSimulatorOptions.");
|
|
40
|
+
return ctx;
|
|
41
|
+
}
|
|
42
|
+
function formatPrice(value, locale, currency) {
|
|
43
|
+
return new Intl.NumberFormat(locale, {
|
|
44
|
+
style: "currency",
|
|
45
|
+
currency
|
|
46
|
+
}).format(value);
|
|
47
|
+
}
|
|
48
|
+
const ESTIMATE_MESSAGE = {
|
|
49
|
+
BUSINESS_DAYS: {
|
|
50
|
+
id: "fs/shipping.estimate.in-business-days",
|
|
51
|
+
variable: "days"
|
|
52
|
+
},
|
|
53
|
+
DAYS: {
|
|
54
|
+
id: "fs/shipping.estimate.in-days",
|
|
55
|
+
variable: "days"
|
|
56
|
+
},
|
|
57
|
+
HOURS: {
|
|
58
|
+
id: "fs/shipping.estimate.in-hours",
|
|
59
|
+
variable: "hours"
|
|
60
|
+
},
|
|
61
|
+
MINUTES: {
|
|
62
|
+
id: "fs/shipping.estimate.in-minutes",
|
|
63
|
+
variable: "minutes"
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const ESTIMATE_UNIT_MINUTES = {
|
|
67
|
+
MINUTES: 1,
|
|
68
|
+
HOURS: 60,
|
|
69
|
+
DAYS: 1440,
|
|
70
|
+
BUSINESS_DAYS: 1440
|
|
71
|
+
};
|
|
72
|
+
function sortShippingOptions(options, sortBy) {
|
|
73
|
+
const rank = sortBy === "price" ? (option) => Number(option.price.amount) : (option) => option.shippingEstimate.value * ESTIMATE_UNIT_MINUTES[option.shippingEstimate.unit];
|
|
74
|
+
return [...options].sort((a, b) => rank(a) - rank(b));
|
|
75
|
+
}
|
|
76
|
+
function normalizePostalCode(value) {
|
|
77
|
+
return value.replace(/\D/g, "").slice(0, 8);
|
|
78
|
+
}
|
|
79
|
+
function formatPostalCode(value) {
|
|
80
|
+
const digits = normalizePostalCode(value);
|
|
81
|
+
return digits.length > 5 ? `${digits.slice(0, 5)}-${digits.slice(5)}` : digits;
|
|
82
|
+
}
|
|
83
|
+
function extractProductFromData(data) {
|
|
84
|
+
if (!data) return {
|
|
85
|
+
variantId: null,
|
|
86
|
+
seller: null
|
|
87
|
+
};
|
|
88
|
+
const edge = data.variants?.edges?.[0];
|
|
89
|
+
if (!edge) return {
|
|
90
|
+
variantId: null,
|
|
91
|
+
seller: null
|
|
92
|
+
};
|
|
93
|
+
const { id, sellers } = edge.node;
|
|
94
|
+
const defaultSeller = sellers?.find((s) => s.isDefault) ?? sellers?.[0];
|
|
95
|
+
return {
|
|
96
|
+
variantId: id ?? null,
|
|
97
|
+
seller: defaultSeller?.id ?? null
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const ShippingSimulatorRootDefinition = defineComponent({
|
|
101
|
+
name: "ShippingSimulatorRoot",
|
|
102
|
+
importPath: "@vtex/faststore/components",
|
|
103
|
+
component: ShippingSimulatorRoot,
|
|
104
|
+
fragment,
|
|
105
|
+
fetchStrategy: "reactive",
|
|
106
|
+
editor: {
|
|
107
|
+
label: "Shipping Simulator",
|
|
108
|
+
category: "commerce"
|
|
109
|
+
},
|
|
110
|
+
schema: {
|
|
111
|
+
country: {
|
|
112
|
+
type: "string",
|
|
113
|
+
default: "BRA",
|
|
114
|
+
label: "Country (ISO-3)"
|
|
115
|
+
},
|
|
116
|
+
quantity: {
|
|
117
|
+
type: "number",
|
|
118
|
+
default: 1,
|
|
119
|
+
label: "Quantity"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
providesContext: "shipping-simulator",
|
|
123
|
+
guideline: "Root container for the PDP shipping simulator: a shopper types a postal code and sees a shipping preview for ONE product on a product detail page. Backed by shippingSimulation and a product fragment (productBySlug(slug: $slug)), so it must live on a page with a $slug variable. Use CartShippingSimulatorRoot instead for a whole-cart calculator in the cart/mini-cart. All other ShippingSimulator components must be descendants of this one."
|
|
124
|
+
});
|
|
125
|
+
const CartShippingSimulatorRootDefinition = defineComponent({
|
|
126
|
+
name: "CartShippingSimulatorRoot",
|
|
127
|
+
importPath: "@vtex/faststore/components",
|
|
128
|
+
component: CartShippingSimulatorRoot,
|
|
129
|
+
editor: {
|
|
130
|
+
label: "Cart Shipping Simulator",
|
|
131
|
+
category: "commerce"
|
|
132
|
+
},
|
|
133
|
+
schema: { country: {
|
|
134
|
+
type: "string",
|
|
135
|
+
default: "BRA",
|
|
136
|
+
label: "Country (ISO-3)"
|
|
137
|
+
} },
|
|
138
|
+
providesContext: "shipping-simulator",
|
|
139
|
+
guideline: "Root container for the cart/mini-cart shipping calculator: the shopper types a postal code and sees the shipping options for the WHOLE cart. Backed by cartShippingSimulation (cart sourced server-side via x-order-form-id); needs no CartRoot ancestor and no product fragment. Use ShippingSimulatorRoot instead for a single-product shipping preview on a PDP. All other CartShippingSimulator components must be descendants of this one."
|
|
140
|
+
});
|
|
141
|
+
const ShippingSimulatorFormDefinition = defineComponent({
|
|
142
|
+
name: "ShippingSimulatorForm",
|
|
143
|
+
importPath: "@vtex/faststore/components",
|
|
144
|
+
component: ShippingSimulatorForm,
|
|
145
|
+
editor: {
|
|
146
|
+
label: "Shipping Simulator Form",
|
|
147
|
+
category: "commerce"
|
|
148
|
+
},
|
|
149
|
+
schema: {},
|
|
150
|
+
requiresContext: "shipping-simulator",
|
|
151
|
+
guideline: "Form wrapper that holds ShippingSimulatorInput and ShippingSimulatorSubmit; must be a descendant of ShippingSimulatorRoot."
|
|
152
|
+
});
|
|
153
|
+
const ShippingSimulatorInputDefinition = defineComponent({
|
|
154
|
+
name: "ShippingSimulatorInput",
|
|
155
|
+
importPath: "@vtex/faststore/components",
|
|
156
|
+
component: ShippingSimulatorInput,
|
|
157
|
+
editor: {
|
|
158
|
+
label: "Shipping Simulator Input",
|
|
159
|
+
category: "action"
|
|
160
|
+
},
|
|
161
|
+
schema: { format: {
|
|
162
|
+
type: "boolean",
|
|
163
|
+
default: false,
|
|
164
|
+
label: "Auto-format CEP (00000-000)"
|
|
165
|
+
} },
|
|
166
|
+
requiresContext: "shipping-simulator",
|
|
167
|
+
guideline: "Postal-code text input; enable `format` to auto-hyphenate the CEP as the user types (e.g. 01310-100). The placeholder comes from the message catalog. Must be a descendant of ShippingSimulatorForm."
|
|
168
|
+
});
|
|
169
|
+
const ShippingSimulatorSubmitDefinition = defineComponent({
|
|
170
|
+
name: "ShippingSimulatorSubmit",
|
|
171
|
+
importPath: "@vtex/faststore/components",
|
|
172
|
+
component: ShippingSimulatorSubmit,
|
|
173
|
+
editor: {
|
|
174
|
+
label: "Shipping Simulator Submit",
|
|
175
|
+
category: "action"
|
|
176
|
+
},
|
|
177
|
+
schema: {},
|
|
178
|
+
requiresContext: "shipping-simulator",
|
|
179
|
+
guideline: "Submit button for the postal-code form; must be a descendant of ShippingSimulatorForm."
|
|
180
|
+
});
|
|
181
|
+
const ShippingSimulatorLoadingDefinition = defineComponent({
|
|
182
|
+
name: "ShippingSimulatorLoading",
|
|
183
|
+
importPath: "@vtex/faststore/components",
|
|
184
|
+
component: ShippingSimulatorLoading,
|
|
185
|
+
editor: {
|
|
186
|
+
label: "Shipping Simulator Loading",
|
|
187
|
+
category: "commerce"
|
|
188
|
+
},
|
|
189
|
+
schema: {},
|
|
190
|
+
requiresContext: "shipping-simulator",
|
|
191
|
+
guideline: "Loading indicator shown while a simulation is in progress; must be a descendant of ShippingSimulatorRoot."
|
|
192
|
+
});
|
|
193
|
+
const ShippingSimulatorErrorDefinition = defineComponent({
|
|
194
|
+
name: "ShippingSimulatorError",
|
|
195
|
+
importPath: "@vtex/faststore/components",
|
|
196
|
+
component: ShippingSimulatorError,
|
|
197
|
+
editor: {
|
|
198
|
+
label: "Shipping Simulator Error",
|
|
199
|
+
category: "commerce"
|
|
200
|
+
},
|
|
201
|
+
schema: {},
|
|
202
|
+
requiresContext: "shipping-simulator",
|
|
203
|
+
guideline: "Error banner shown when the simulation returns validation errors; must be a descendant of ShippingSimulatorRoot."
|
|
204
|
+
});
|
|
205
|
+
const ShippingSimulatorOptionsDefinition = defineComponent({
|
|
206
|
+
name: "ShippingSimulatorOptions",
|
|
207
|
+
importPath: "@vtex/faststore/components",
|
|
208
|
+
component: ShippingSimulatorOptions,
|
|
209
|
+
editor: {
|
|
210
|
+
label: "Shipping Simulator Options",
|
|
211
|
+
category: "commerce"
|
|
212
|
+
},
|
|
213
|
+
schema: {
|
|
214
|
+
sortBy: {
|
|
215
|
+
type: ["price", "estimate"],
|
|
216
|
+
label: "Sort by"
|
|
217
|
+
},
|
|
218
|
+
maxOptions: {
|
|
219
|
+
type: "number",
|
|
220
|
+
label: "Max options"
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
requiresContext: "shipping-simulator",
|
|
224
|
+
providesContext: "shipping-simulator-option",
|
|
225
|
+
guideline: "List that renders one ShippingSimulatorOption per available shipping option; must be a descendant of a shipping-simulator Root (PDP or cart). Renders every option in API order by default; set sortBy (\"price\" = cheapest first, \"estimate\" = fastest first) and maxOptions to cap the list — sortBy=\"price\" with maxOptions=1 shows only the cheapest option. See shipping-simulator.md."
|
|
226
|
+
});
|
|
227
|
+
const ShippingSimulatorOptionDefinition = defineComponent({
|
|
228
|
+
name: "ShippingSimulatorOption",
|
|
229
|
+
importPath: "@vtex/faststore/components",
|
|
230
|
+
component: ShippingSimulatorOption,
|
|
231
|
+
editor: {
|
|
232
|
+
label: "Shipping Simulator Option",
|
|
233
|
+
category: "commerce"
|
|
234
|
+
},
|
|
235
|
+
schema: {},
|
|
236
|
+
requiresContext: "shipping-simulator-option",
|
|
237
|
+
guideline: "Container for a single shipping option row; holds ShippingSimulatorOptionName, ShippingSimulatorOptionEstimate, and ShippingSimulatorOptionPrice. Must be a descendant of ShippingSimulatorOptions."
|
|
238
|
+
});
|
|
239
|
+
const ShippingSimulatorOptionNameDefinition = defineComponent({
|
|
240
|
+
name: "ShippingSimulatorOptionName",
|
|
241
|
+
importPath: "@vtex/faststore/components",
|
|
242
|
+
component: ShippingSimulatorOptionName,
|
|
243
|
+
editor: {
|
|
244
|
+
label: "Option Name",
|
|
245
|
+
category: "commerce"
|
|
246
|
+
},
|
|
247
|
+
schema: {},
|
|
248
|
+
requiresContext: "shipping-simulator-option",
|
|
249
|
+
guideline: "Displays the shipping option name (e.g. \"Entrega Normal\"); must be a descendant of ShippingSimulatorOption."
|
|
250
|
+
});
|
|
251
|
+
const ShippingSimulatorOptionEstimateDefinition = defineComponent({
|
|
252
|
+
name: "ShippingSimulatorOptionEstimate",
|
|
253
|
+
importPath: "@vtex/faststore/components",
|
|
254
|
+
component: ShippingSimulatorOptionEstimate,
|
|
255
|
+
editor: {
|
|
256
|
+
label: "Option Estimate",
|
|
257
|
+
category: "commerce"
|
|
258
|
+
},
|
|
259
|
+
schema: {},
|
|
260
|
+
requiresContext: "shipping-simulator-option",
|
|
261
|
+
guideline: "Displays the delivery estimate in the active locale, one whole sentence per unit from the message catalog; a zero-value estimate (any unit) reads as an arrival-today message instead, since \"chega em 0 dias úteis\" reads wrong. Must be a descendant of ShippingSimulatorOption."
|
|
262
|
+
});
|
|
263
|
+
const ShippingSimulatorOptionPriceDefinition = defineComponent({
|
|
264
|
+
name: "ShippingSimulatorOptionPrice",
|
|
265
|
+
importPath: "@vtex/faststore/components",
|
|
266
|
+
component: ShippingSimulatorOptionPrice,
|
|
267
|
+
editor: {
|
|
268
|
+
label: "Option Price",
|
|
269
|
+
category: "commerce"
|
|
270
|
+
},
|
|
271
|
+
schema: {},
|
|
272
|
+
requiresContext: "shipping-simulator-option",
|
|
273
|
+
guideline: "Displays the shipping price, showing the free-shipping label from the message catalog when the amount is zero; must be a descendant of ShippingSimulatorOption."
|
|
274
|
+
});
|
|
275
|
+
const ShippingSimulatorOptionFreeBadgeDefinition = defineComponent({
|
|
276
|
+
name: "ShippingSimulatorOptionFreeBadge",
|
|
277
|
+
importPath: "@vtex/faststore/components",
|
|
278
|
+
component: ShippingSimulatorOptionFreeBadge,
|
|
279
|
+
editor: {
|
|
280
|
+
label: "Option Free Badge",
|
|
281
|
+
category: "commerce"
|
|
282
|
+
},
|
|
283
|
+
schema: {},
|
|
284
|
+
requiresContext: "shipping-simulator-option",
|
|
285
|
+
guideline: "Badge shown only when the current option price is zero (free shipping); renders nothing otherwise. Must be a descendant of ShippingSimulatorOption. Orthogonal to the free-price replacement text owned by ShippingSimulatorOptionPrice."
|
|
286
|
+
});
|
|
287
|
+
const ShippingSimulatorEmptyDefinition = defineComponent({
|
|
288
|
+
name: "ShippingSimulatorEmpty",
|
|
289
|
+
importPath: "@vtex/faststore/components",
|
|
290
|
+
component: ShippingSimulatorEmpty,
|
|
291
|
+
editor: {
|
|
292
|
+
label: "Shipping Simulator Empty",
|
|
293
|
+
category: "commerce"
|
|
294
|
+
},
|
|
295
|
+
schema: {},
|
|
296
|
+
requiresContext: "shipping-simulator",
|
|
297
|
+
guideline: "Message shown when a simulation ran and returned no shipping options (e.g. no carrier common to the whole cart). Renders nothing before the first submit and nothing when options or an error are present. The copy comes from the message catalog; pass children to override. Must be a descendant of a shipping-simulator Root."
|
|
298
|
+
});
|
|
299
|
+
function ShippingSimulatorRoot({ country = "BRA", quantity = 1, variantId: variantIdProp, seller: sellerProp, $data: $dataProp, shippingOptions: shippingOptionsProp, userErrors: userErrorsProp, onSimulate: onSimulateProp, onResult, className, children, ...props }) {
|
|
300
|
+
const defaultSimulate = useShippingSimulation();
|
|
301
|
+
const onSimulate = onSimulateProp ?? defaultSimulate;
|
|
302
|
+
const intl = useIntl();
|
|
303
|
+
const extracted = extractProductFromData(useDataOverride($dataProp));
|
|
304
|
+
const variantId = variantIdProp ?? extracted.variantId;
|
|
305
|
+
const seller = sellerProp ?? extracted.seller;
|
|
306
|
+
const [postalCode, setPostalCode] = useState("");
|
|
307
|
+
const [status, setStatus] = useState(() => {
|
|
308
|
+
if (userErrorsProp?.length) return "error";
|
|
309
|
+
if (shippingOptionsProp) return "success";
|
|
310
|
+
return "idle";
|
|
311
|
+
});
|
|
312
|
+
const [shippingOptions, setShippingOptions] = useState(shippingOptionsProp ?? null);
|
|
313
|
+
const [userErrors, setUserErrors] = useState(userErrorsProp ?? []);
|
|
314
|
+
const submissionToken = useRef(0);
|
|
315
|
+
const submit = useCallback(() => {
|
|
316
|
+
if (!onSimulate || !variantId || !seller) return;
|
|
317
|
+
const normalizedCep = normalizePostalCode(postalCode);
|
|
318
|
+
if (normalizedCep.length !== 8) return;
|
|
319
|
+
const token = ++submissionToken.current;
|
|
320
|
+
setStatus("loading");
|
|
321
|
+
setShippingOptions(null);
|
|
322
|
+
setUserErrors([]);
|
|
323
|
+
onSimulate({
|
|
324
|
+
postalCode: normalizedCep,
|
|
325
|
+
country,
|
|
326
|
+
variantId,
|
|
327
|
+
quantity,
|
|
328
|
+
seller
|
|
329
|
+
}).then((result) => {
|
|
330
|
+
if (submissionToken.current !== token) return;
|
|
331
|
+
setShippingOptions(result.shippingOptions);
|
|
332
|
+
setUserErrors(result.userErrors);
|
|
333
|
+
setStatus(result.userErrors.length > 0 ? "error" : "success");
|
|
334
|
+
onResult?.(result);
|
|
335
|
+
}).catch(() => {
|
|
336
|
+
if (submissionToken.current !== token) return;
|
|
337
|
+
const fallback = {
|
|
338
|
+
code: "UNKNOWN",
|
|
339
|
+
message: intl.formatMessage({ id: "fs/shipping.calculation-failed" })
|
|
340
|
+
};
|
|
341
|
+
setShippingOptions(null);
|
|
342
|
+
setUserErrors([fallback]);
|
|
343
|
+
setStatus("error");
|
|
344
|
+
onResult?.({
|
|
345
|
+
shippingOptions: null,
|
|
346
|
+
userErrors: [fallback]
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
}, [
|
|
350
|
+
country,
|
|
351
|
+
intl,
|
|
352
|
+
onResult,
|
|
353
|
+
onSimulate,
|
|
354
|
+
postalCode,
|
|
355
|
+
quantity,
|
|
356
|
+
seller,
|
|
357
|
+
variantId
|
|
358
|
+
]);
|
|
359
|
+
const contextValue = useMemo(() => ({
|
|
360
|
+
postalCode,
|
|
361
|
+
setPostalCode,
|
|
362
|
+
status,
|
|
363
|
+
shippingOptions,
|
|
364
|
+
userErrors,
|
|
365
|
+
submit
|
|
366
|
+
}), [
|
|
367
|
+
postalCode,
|
|
368
|
+
status,
|
|
369
|
+
shippingOptions,
|
|
370
|
+
userErrors,
|
|
371
|
+
submit
|
|
372
|
+
]);
|
|
373
|
+
return /* @__PURE__ */ jsx(ShippingSimulatorContext, {
|
|
374
|
+
value: contextValue,
|
|
375
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
376
|
+
...props,
|
|
377
|
+
className,
|
|
378
|
+
"data-fs-shipping-simulator": "",
|
|
379
|
+
children
|
|
380
|
+
})
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
function CartShippingSimulatorRoot({ country = "BRA", shippingOptions: shippingOptionsProp, userErrors: userErrorsProp, onSimulate: onSimulateProp, onResult, className, children, ...props }) {
|
|
384
|
+
const defaultSimulate = useCartShippingSimulation();
|
|
385
|
+
const onSimulate = onSimulateProp ?? defaultSimulate;
|
|
386
|
+
const intl = useIntl();
|
|
387
|
+
const [postalCode, setPostalCode] = useState("");
|
|
388
|
+
const [status, setStatus] = useState(() => {
|
|
389
|
+
if (userErrorsProp?.length) return "error";
|
|
390
|
+
if (shippingOptionsProp) return "success";
|
|
391
|
+
return "idle";
|
|
392
|
+
});
|
|
393
|
+
const [shippingOptions, setShippingOptions] = useState(shippingOptionsProp ?? null);
|
|
394
|
+
const [userErrors, setUserErrors] = useState(userErrorsProp ?? []);
|
|
395
|
+
const submissionToken = useRef(0);
|
|
396
|
+
const submit = useCallback(() => {
|
|
397
|
+
const normalizedCep = normalizePostalCode(postalCode);
|
|
398
|
+
if (normalizedCep.length !== 8) return;
|
|
399
|
+
const token = ++submissionToken.current;
|
|
400
|
+
setStatus("loading");
|
|
401
|
+
setShippingOptions(null);
|
|
402
|
+
setUserErrors([]);
|
|
403
|
+
onSimulate({
|
|
404
|
+
postalCode: normalizedCep,
|
|
405
|
+
country
|
|
406
|
+
}).then((result) => {
|
|
407
|
+
if (submissionToken.current !== token) return;
|
|
408
|
+
setShippingOptions(result.shippingOptions);
|
|
409
|
+
setUserErrors(result.userErrors);
|
|
410
|
+
setStatus(result.userErrors.length > 0 ? "error" : "success");
|
|
411
|
+
onResult?.(result);
|
|
412
|
+
}).catch(() => {
|
|
413
|
+
if (submissionToken.current !== token) return;
|
|
414
|
+
const fallback = {
|
|
415
|
+
code: "UNKNOWN",
|
|
416
|
+
message: intl.formatMessage({ id: "fs/shipping.calculation-failed" })
|
|
417
|
+
};
|
|
418
|
+
setShippingOptions(null);
|
|
419
|
+
setUserErrors([fallback]);
|
|
420
|
+
setStatus("error");
|
|
421
|
+
onResult?.({
|
|
422
|
+
shippingOptions: null,
|
|
423
|
+
userErrors: [fallback]
|
|
424
|
+
});
|
|
425
|
+
});
|
|
426
|
+
}, [
|
|
427
|
+
country,
|
|
428
|
+
intl,
|
|
429
|
+
onResult,
|
|
430
|
+
onSimulate,
|
|
431
|
+
postalCode
|
|
432
|
+
]);
|
|
433
|
+
const contextValue = useMemo(() => ({
|
|
434
|
+
postalCode,
|
|
435
|
+
setPostalCode,
|
|
436
|
+
status,
|
|
437
|
+
shippingOptions,
|
|
438
|
+
userErrors,
|
|
439
|
+
submit
|
|
440
|
+
}), [
|
|
441
|
+
postalCode,
|
|
442
|
+
status,
|
|
443
|
+
shippingOptions,
|
|
444
|
+
userErrors,
|
|
445
|
+
submit
|
|
446
|
+
]);
|
|
447
|
+
return /* @__PURE__ */ jsx(ShippingSimulatorContext, {
|
|
448
|
+
value: contextValue,
|
|
449
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
450
|
+
...props,
|
|
451
|
+
className,
|
|
452
|
+
"data-fs-shipping-simulator": "",
|
|
453
|
+
children
|
|
454
|
+
})
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
function ShippingSimulatorForm({ className, children, ...props }) {
|
|
458
|
+
const { submit } = useShippingSimulator();
|
|
459
|
+
return /* @__PURE__ */ jsx("form", {
|
|
460
|
+
...props,
|
|
461
|
+
className,
|
|
462
|
+
"data-fs-shipping-simulator-form": "",
|
|
463
|
+
onSubmit: (event) => {
|
|
464
|
+
event.preventDefault();
|
|
465
|
+
submit();
|
|
466
|
+
},
|
|
467
|
+
children
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
function ShippingSimulatorInput({ className, placeholder, "aria-label": ariaLabel, format = false, ...props }) {
|
|
471
|
+
const { postalCode, setPostalCode } = useShippingSimulator();
|
|
472
|
+
const intl = useIntl();
|
|
473
|
+
const displayValue = format ? formatPostalCode(postalCode) : postalCode;
|
|
474
|
+
return /* @__PURE__ */ jsx("input", {
|
|
475
|
+
...props,
|
|
476
|
+
"aria-label": ariaLabel ?? intl.formatMessage({ id: "fs/shipping.postal-code.aria-label" }),
|
|
477
|
+
className,
|
|
478
|
+
"data-fs-shipping-simulator-input": "",
|
|
479
|
+
type: "text",
|
|
480
|
+
value: displayValue,
|
|
481
|
+
onChange: (event) => setPostalCode(normalizePostalCode(event.target.value)),
|
|
482
|
+
placeholder: placeholder ?? intl.formatMessage({ id: "fs/shipping.postal-code.placeholder" }),
|
|
483
|
+
pattern: "\\d{5}-?\\d{3}",
|
|
484
|
+
maxLength: 9,
|
|
485
|
+
inputMode: "numeric",
|
|
486
|
+
required: true
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
function ShippingSimulatorSubmit({ className, children, disabled, ...props }) {
|
|
490
|
+
const { status } = useShippingSimulator();
|
|
491
|
+
const isLoading = status === "loading";
|
|
492
|
+
return /* @__PURE__ */ jsx("button", {
|
|
493
|
+
...props,
|
|
494
|
+
type: "submit",
|
|
495
|
+
className,
|
|
496
|
+
"data-fs-shipping-simulator-submit": "",
|
|
497
|
+
disabled: disabled || isLoading,
|
|
498
|
+
"aria-busy": isLoading,
|
|
499
|
+
children
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
function ShippingSimulatorLoading({ className, children, ...props }) {
|
|
503
|
+
const { status } = useShippingSimulator();
|
|
504
|
+
if (status !== "loading") return null;
|
|
505
|
+
return /* @__PURE__ */ jsx("output", {
|
|
506
|
+
...props,
|
|
507
|
+
"aria-live": "polite",
|
|
508
|
+
className,
|
|
509
|
+
"data-fs-shipping-simulator-loading": "",
|
|
510
|
+
children: children ?? /* @__PURE__ */ jsx(FormattedMessage, { id: "fs/shipping.calculating" })
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
function ShippingSimulatorError({ className, children, ...props }) {
|
|
514
|
+
const { userErrors } = useShippingSimulator();
|
|
515
|
+
const [firstError] = userErrors;
|
|
516
|
+
if (!firstError) return null;
|
|
517
|
+
return /* @__PURE__ */ jsx("div", {
|
|
518
|
+
...props,
|
|
519
|
+
role: "alert",
|
|
520
|
+
className,
|
|
521
|
+
"data-fs-shipping-simulator-error": "",
|
|
522
|
+
children: children ?? firstError.message
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
function ShippingSimulatorOptions({ sortBy, maxOptions, className, children, ...props }) {
|
|
526
|
+
const { shippingOptions } = useShippingSimulator();
|
|
527
|
+
const visibleOptions = useMemo(() => {
|
|
528
|
+
if (!shippingOptions) return null;
|
|
529
|
+
const sorted = sortBy ? sortShippingOptions(shippingOptions, sortBy) : shippingOptions;
|
|
530
|
+
return maxOptions && maxOptions > 0 ? sorted.slice(0, maxOptions) : sorted;
|
|
531
|
+
}, [
|
|
532
|
+
shippingOptions,
|
|
533
|
+
sortBy,
|
|
534
|
+
maxOptions
|
|
535
|
+
]);
|
|
536
|
+
if (!visibleOptions || visibleOptions.length === 0) return null;
|
|
537
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
538
|
+
...props,
|
|
539
|
+
className,
|
|
540
|
+
"data-fs-shipping-simulator-options": "",
|
|
541
|
+
children: visibleOptions.map((option) => /* @__PURE__ */ jsx(OptionItemContext, {
|
|
542
|
+
value: option,
|
|
543
|
+
children
|
|
544
|
+
}, option.id))
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
function ShippingSimulatorOption({ className, children, ...props }) {
|
|
548
|
+
const option = useOptionItem();
|
|
549
|
+
return /* @__PURE__ */ jsx("li", {
|
|
550
|
+
...props,
|
|
551
|
+
className,
|
|
552
|
+
"data-fs-shipping-simulator-option": "",
|
|
553
|
+
"data-fs-shipping-simulator-option-channel": option.channel,
|
|
554
|
+
children
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
function ShippingSimulatorOptionName({ className, children, ...props }) {
|
|
558
|
+
const option = useOptionItem();
|
|
559
|
+
return /* @__PURE__ */ jsx("span", {
|
|
560
|
+
...props,
|
|
561
|
+
className,
|
|
562
|
+
"data-fs-shipping-simulator-option-name": "",
|
|
563
|
+
children: children ?? option.name
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
function ShippingSimulatorOptionEstimate({ className, children, ...props }) {
|
|
567
|
+
const option = useOptionItem();
|
|
568
|
+
const intl = useIntl();
|
|
569
|
+
const { value, unit } = option.shippingEstimate;
|
|
570
|
+
const { id, variable } = ESTIMATE_MESSAGE[unit];
|
|
571
|
+
const text = value === 0 ? intl.formatMessage({ id: "fs/shipping.estimate.today" }) : intl.formatMessage({ id }, { [variable]: value });
|
|
572
|
+
return /* @__PURE__ */ jsx("span", {
|
|
573
|
+
...props,
|
|
574
|
+
className,
|
|
575
|
+
"data-fs-shipping-simulator-option-estimate": "",
|
|
576
|
+
children: children ?? text
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
function ShippingSimulatorOptionPrice({ className, children, ...props }) {
|
|
580
|
+
const option = useOptionItem();
|
|
581
|
+
const intl = useIntl();
|
|
582
|
+
const { locale, currency } = useStorefrontContext();
|
|
583
|
+
const text = option.price.amount === 0 ? intl.formatMessage({ id: "fs/shipping.free-price" }) : formatPrice(option.price.amount, locale, currency);
|
|
584
|
+
return /* @__PURE__ */ jsx("span", {
|
|
585
|
+
...props,
|
|
586
|
+
className,
|
|
587
|
+
"data-fs-shipping-simulator-option-price": "",
|
|
588
|
+
children: children ?? text
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
function ShippingSimulatorOptionFreeBadge({ className, children, ...props }) {
|
|
592
|
+
if (useOptionItem().price.amount !== 0) return null;
|
|
593
|
+
return /* @__PURE__ */ jsx("span", {
|
|
594
|
+
...props,
|
|
595
|
+
className,
|
|
596
|
+
"data-fs-shipping-simulator-option-free-badge": "",
|
|
597
|
+
children: children ?? /* @__PURE__ */ jsx(FormattedMessage, { id: "fs/shipping.free-badge" })
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
function ShippingSimulatorEmpty({ className, children, ...props }) {
|
|
601
|
+
const { shippingOptions, userErrors } = useShippingSimulator();
|
|
602
|
+
if (!(Array.isArray(shippingOptions) && shippingOptions.length === 0 && userErrors.length === 0)) return null;
|
|
603
|
+
return /* @__PURE__ */ jsx("output", {
|
|
604
|
+
...props,
|
|
605
|
+
"aria-live": "polite",
|
|
606
|
+
className,
|
|
607
|
+
"data-fs-shipping-simulator-empty": "",
|
|
608
|
+
children: children ?? /* @__PURE__ */ jsx(FormattedMessage, { id: "fs/shipping.no-options" })
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
const ShippingSimulator = {
|
|
612
|
+
Root: ShippingSimulatorRoot,
|
|
613
|
+
Form: ShippingSimulatorForm,
|
|
614
|
+
Input: ShippingSimulatorInput,
|
|
615
|
+
Submit: ShippingSimulatorSubmit,
|
|
616
|
+
Loading: ShippingSimulatorLoading,
|
|
617
|
+
Error: ShippingSimulatorError,
|
|
618
|
+
Options: ShippingSimulatorOptions,
|
|
619
|
+
Option: ShippingSimulatorOption,
|
|
620
|
+
OptionName: ShippingSimulatorOptionName,
|
|
621
|
+
OptionEstimate: ShippingSimulatorOptionEstimate,
|
|
622
|
+
OptionPrice: ShippingSimulatorOptionPrice,
|
|
623
|
+
OptionFreeBadge: ShippingSimulatorOptionFreeBadge,
|
|
624
|
+
Empty: ShippingSimulatorEmpty
|
|
625
|
+
};
|
|
626
|
+
const CartShippingSimulator = {
|
|
627
|
+
Root: CartShippingSimulatorRoot,
|
|
628
|
+
Form: ShippingSimulatorForm,
|
|
629
|
+
Input: ShippingSimulatorInput,
|
|
630
|
+
Submit: ShippingSimulatorSubmit,
|
|
631
|
+
Loading: ShippingSimulatorLoading,
|
|
632
|
+
Error: ShippingSimulatorError,
|
|
633
|
+
Options: ShippingSimulatorOptions,
|
|
634
|
+
Option: ShippingSimulatorOption,
|
|
635
|
+
OptionName: ShippingSimulatorOptionName,
|
|
636
|
+
OptionEstimate: ShippingSimulatorOptionEstimate,
|
|
637
|
+
OptionPrice: ShippingSimulatorOptionPrice,
|
|
638
|
+
OptionFreeBadge: ShippingSimulatorOptionFreeBadge,
|
|
639
|
+
Empty: ShippingSimulatorEmpty
|
|
640
|
+
};
|
|
641
|
+
//#endregion
|
|
642
|
+
export { CartShippingSimulator, CartShippingSimulatorRoot, CartShippingSimulatorRootDefinition, ESTIMATE_MESSAGE, OptionItemContext, ShippingSimulator, ShippingSimulatorContext, ShippingSimulatorEmpty, ShippingSimulatorEmptyDefinition, ShippingSimulatorError, ShippingSimulatorErrorDefinition, ShippingSimulatorForm, ShippingSimulatorFormDefinition, ShippingSimulatorInput, ShippingSimulatorInputDefinition, ShippingSimulatorLoading, ShippingSimulatorLoadingDefinition, ShippingSimulatorOption, ShippingSimulatorOptionDefinition, ShippingSimulatorOptionEstimate, ShippingSimulatorOptionEstimateDefinition, ShippingSimulatorOptionFreeBadge, ShippingSimulatorOptionFreeBadgeDefinition, ShippingSimulatorOptionName, ShippingSimulatorOptionNameDefinition, ShippingSimulatorOptionPrice, ShippingSimulatorOptionPriceDefinition, ShippingSimulatorOptions, ShippingSimulatorOptionsDefinition, ShippingSimulatorRoot, ShippingSimulatorRootDefinition, ShippingSimulatorSubmit, ShippingSimulatorSubmitDefinition };
|
|
643
|
+
|
|
644
|
+
//# sourceMappingURL=shipping-simulator.js.map
|