@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,125 @@
|
|
|
1
|
+
import { ComponentDefinition } from "../../core/dist/define-component.js";
|
|
2
|
+
import "../../core/dist/index.js";
|
|
3
|
+
import { ProductListItem } from "../product-list/product-list.js";
|
|
4
|
+
import { ComponentPropsWithRef } from "react";
|
|
5
|
+
//#region src/matter/product-shelf/product-shelf.d.ts
|
|
6
|
+
type RawMoney = {
|
|
7
|
+
amount: number;
|
|
8
|
+
currencyCode: string;
|
|
9
|
+
};
|
|
10
|
+
type RawOffer = {
|
|
11
|
+
price: RawMoney;
|
|
12
|
+
listPrice: RawMoney;
|
|
13
|
+
spotPrice: RawMoney;
|
|
14
|
+
tax: RawMoney;
|
|
15
|
+
taxPercentage: number | null;
|
|
16
|
+
availableQuantity: number;
|
|
17
|
+
};
|
|
18
|
+
type RawVariantNode = {
|
|
19
|
+
availableForSale: boolean;
|
|
20
|
+
quantityAvailable: number | null;
|
|
21
|
+
price: RawMoney;
|
|
22
|
+
compareAtPrice: RawMoney | null;
|
|
23
|
+
sellers: Array<{
|
|
24
|
+
isDefault: boolean;
|
|
25
|
+
offer: RawOffer | null;
|
|
26
|
+
}>;
|
|
27
|
+
};
|
|
28
|
+
type RawProductNode = {
|
|
29
|
+
id: string;
|
|
30
|
+
title: string;
|
|
31
|
+
slug: string;
|
|
32
|
+
images: {
|
|
33
|
+
edges: Array<{
|
|
34
|
+
node: {
|
|
35
|
+
url: string;
|
|
36
|
+
altText: string | null;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
39
|
+
};
|
|
40
|
+
variants: {
|
|
41
|
+
edges: Array<{
|
|
42
|
+
node: RawVariantNode;
|
|
43
|
+
}>;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export type ProductShelfData = {
|
|
47
|
+
edges: Array<{
|
|
48
|
+
node: RawProductNode;
|
|
49
|
+
}>;
|
|
50
|
+
totalCount: number;
|
|
51
|
+
};
|
|
52
|
+
export type ProductShelfItem = ProductListItem;
|
|
53
|
+
export type ProductShelfSort = 'relevance' | 'price_asc' | 'price_desc' | 'name_asc' | 'name_desc' | 'release' | 'orders' | 'discount';
|
|
54
|
+
export type ProductSortField = 'TITLE' | 'PRICE' | 'RELEASE_DATE' | 'RELEVANCE' | 'BEST_SELLING';
|
|
55
|
+
export type SortDirection = 'ASC' | 'DESC';
|
|
56
|
+
export type ProductsFilterInput = {
|
|
57
|
+
searchTerm?: string;
|
|
58
|
+
categoryIds?: string[];
|
|
59
|
+
brandIds?: string[];
|
|
60
|
+
collectionId?: string;
|
|
61
|
+
specifications?: Array<{
|
|
62
|
+
name: string;
|
|
63
|
+
values: string[];
|
|
64
|
+
}>;
|
|
65
|
+
availableOnly?: boolean;
|
|
66
|
+
};
|
|
67
|
+
export type ProductShelfVariables = {
|
|
68
|
+
first: number;
|
|
69
|
+
orderBy?: {
|
|
70
|
+
field: ProductSortField;
|
|
71
|
+
direction: SortDirection;
|
|
72
|
+
};
|
|
73
|
+
filter: ProductsFilterInput;
|
|
74
|
+
};
|
|
75
|
+
export type ProductShelfConfig = {
|
|
76
|
+
first?: number;
|
|
77
|
+
itemsPerPage?: number;
|
|
78
|
+
sort?: ProductShelfSort;
|
|
79
|
+
searchTerm?: string;
|
|
80
|
+
categoryId?: string;
|
|
81
|
+
brandId?: string;
|
|
82
|
+
collectionId?: string;
|
|
83
|
+
specifications?: Array<{
|
|
84
|
+
name: string;
|
|
85
|
+
values: string[];
|
|
86
|
+
}>;
|
|
87
|
+
availableOnly?: boolean;
|
|
88
|
+
};
|
|
89
|
+
export type ProductShelfContextValue = {
|
|
90
|
+
itemsPerPage: number;
|
|
91
|
+
variables: ProductShelfVariables;
|
|
92
|
+
count: number;
|
|
93
|
+
};
|
|
94
|
+
export type ProductShelfRootProps = ComponentPropsWithRef<'section'> & ProductShelfConfig & {
|
|
95
|
+
/** When true, card prices render tax-inclusive (from each item's tax data). Default false. */
|
|
96
|
+
usePriceWithTaxes?: boolean;
|
|
97
|
+
/** Text for the tax label part when tax display is on. Default `'Tax included'`. */
|
|
98
|
+
taxesLabel?: string;
|
|
99
|
+
products?: ProductShelfItem[];
|
|
100
|
+
$data?: ProductShelfData | null;
|
|
101
|
+
};
|
|
102
|
+
export type ProductShelfItemsProps = ComponentPropsWithRef<'div'>;
|
|
103
|
+
export type ProductShelfHeadingProps = ComponentPropsWithRef<'h2'>;
|
|
104
|
+
export declare function useProductShelf(): ProductShelfContextValue;
|
|
105
|
+
export declare function useProductShelfItem(): ProductShelfItem;
|
|
106
|
+
export declare function buildProductShelfVariables(config: ProductShelfConfig): ProductShelfVariables;
|
|
107
|
+
export declare function transformProducts(data: ProductShelfData): ProductShelfItem[];
|
|
108
|
+
export declare const ProductShelfRootDefinition: ComponentDefinition<ProductShelfRootProps>;
|
|
109
|
+
export declare const ProductShelfItemsDefinition: ComponentDefinition<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
|
|
110
|
+
export declare const ProductShelfHeadingDefinition: ComponentDefinition<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>>;
|
|
111
|
+
export declare function ProductShelfRoot({ first, itemsPerPage, sort, searchTerm, categoryId, brandId, collectionId, specifications, availableOnly, usePriceWithTaxes, taxesLabel, products, $data: $dataProp, className, children, ...props }: ProductShelfRootProps): import("react/jsx-runtime").JSX.Element | null;
|
|
112
|
+
export declare namespace ProductShelfRoot {
|
|
113
|
+
var Skeleton: typeof ProductShelfSkeleton;
|
|
114
|
+
}
|
|
115
|
+
export declare function ProductShelfHeading({ className, children, ...props }: ProductShelfHeadingProps): import("react/jsx-runtime").JSX.Element | null;
|
|
116
|
+
export declare function ProductShelfItems({ children, ...props }: ProductShelfItemsProps): import("react/jsx-runtime").JSX.Element;
|
|
117
|
+
export declare function ProductShelfSkeleton({ className, ...props }: ComponentPropsWithRef<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
118
|
+
export declare const ProductShelf: {
|
|
119
|
+
Root: typeof ProductShelfRoot;
|
|
120
|
+
Heading: typeof ProductShelfHeading;
|
|
121
|
+
Items: typeof ProductShelfItems;
|
|
122
|
+
Skeleton: typeof ProductShelfSkeleton;
|
|
123
|
+
};
|
|
124
|
+
//#endregion
|
|
125
|
+
//# sourceMappingURL=product-shelf.d.ts.map
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { defineComponent } from "../../core/dist/define-component.js";
|
|
3
|
+
import "../../core/dist/index.js";
|
|
4
|
+
import { useDataOverride } from "../../sdk/data/data-override-context.js";
|
|
5
|
+
import { Text } from "../../particles/text/text.js";
|
|
6
|
+
import { ProductListConfigContext, ProductListItemContext } from "../product-list/product-list.js";
|
|
7
|
+
import { CarouselTrack } from "../../particles/carousel/carousel.js";
|
|
8
|
+
import { createContext, useCallback, useContext, useEffect, useId, useMemo, useState } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
//#region src/matter/product-shelf/product-shelf.tsx
|
|
11
|
+
const fragment = `
|
|
12
|
+
fragment ProductShelfData on Query {
|
|
13
|
+
products(first: 12, orderBy: { field: RELEVANCE, direction: DESC }) {
|
|
14
|
+
edges {
|
|
15
|
+
node {
|
|
16
|
+
id
|
|
17
|
+
title
|
|
18
|
+
slug
|
|
19
|
+
images(first: 1) {
|
|
20
|
+
edges {
|
|
21
|
+
node {
|
|
22
|
+
url
|
|
23
|
+
altText
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
variants(first: 1) {
|
|
28
|
+
edges {
|
|
29
|
+
node {
|
|
30
|
+
availableForSale
|
|
31
|
+
quantityAvailable
|
|
32
|
+
price {
|
|
33
|
+
amount
|
|
34
|
+
currencyCode
|
|
35
|
+
}
|
|
36
|
+
compareAtPrice {
|
|
37
|
+
amount
|
|
38
|
+
currencyCode
|
|
39
|
+
}
|
|
40
|
+
sellers {
|
|
41
|
+
isDefault
|
|
42
|
+
offer {
|
|
43
|
+
price {
|
|
44
|
+
amount
|
|
45
|
+
currencyCode
|
|
46
|
+
}
|
|
47
|
+
listPrice {
|
|
48
|
+
amount
|
|
49
|
+
currencyCode
|
|
50
|
+
}
|
|
51
|
+
spotPrice {
|
|
52
|
+
amount
|
|
53
|
+
currencyCode
|
|
54
|
+
}
|
|
55
|
+
tax {
|
|
56
|
+
amount
|
|
57
|
+
currencyCode
|
|
58
|
+
}
|
|
59
|
+
taxPercentage
|
|
60
|
+
availableQuantity
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
totalCount
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
const ProductShelfProductsContext = createContext([]);
|
|
73
|
+
const ProductShelfContext = createContext(null);
|
|
74
|
+
const ProductShelfHeadingContext = createContext(null);
|
|
75
|
+
function useProductShelf() {
|
|
76
|
+
const ctx = useContext(ProductShelfContext);
|
|
77
|
+
if (!ctx) throw new Error("useProductShelf must be used inside ProductShelfRoot.");
|
|
78
|
+
return ctx;
|
|
79
|
+
}
|
|
80
|
+
function useProductShelfHeading() {
|
|
81
|
+
const ctx = useContext(ProductShelfHeadingContext);
|
|
82
|
+
if (!ctx) throw new Error("ProductShelfHeading must be used inside ProductShelfRoot.");
|
|
83
|
+
return ctx;
|
|
84
|
+
}
|
|
85
|
+
function useProductShelfItem() {
|
|
86
|
+
const item = useContext(ProductListItemContext);
|
|
87
|
+
if (!item) throw new Error("Product card components must be used inside ProductShelfItems.");
|
|
88
|
+
return item;
|
|
89
|
+
}
|
|
90
|
+
const SORT_MAP = {
|
|
91
|
+
relevance: {
|
|
92
|
+
field: "RELEVANCE",
|
|
93
|
+
direction: "DESC"
|
|
94
|
+
},
|
|
95
|
+
price_asc: {
|
|
96
|
+
field: "PRICE",
|
|
97
|
+
direction: "ASC"
|
|
98
|
+
},
|
|
99
|
+
price_desc: {
|
|
100
|
+
field: "PRICE",
|
|
101
|
+
direction: "DESC"
|
|
102
|
+
},
|
|
103
|
+
name_asc: {
|
|
104
|
+
field: "TITLE",
|
|
105
|
+
direction: "ASC"
|
|
106
|
+
},
|
|
107
|
+
name_desc: {
|
|
108
|
+
field: "TITLE",
|
|
109
|
+
direction: "DESC"
|
|
110
|
+
},
|
|
111
|
+
release: {
|
|
112
|
+
field: "RELEASE_DATE",
|
|
113
|
+
direction: "DESC"
|
|
114
|
+
},
|
|
115
|
+
orders: {
|
|
116
|
+
field: "BEST_SELLING",
|
|
117
|
+
direction: "DESC"
|
|
118
|
+
},
|
|
119
|
+
discount: {
|
|
120
|
+
field: "RELEVANCE",
|
|
121
|
+
direction: "DESC"
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
function buildProductShelfVariables(config) {
|
|
125
|
+
const { first = 5, sort = "relevance", searchTerm, categoryId, brandId, collectionId, specifications, availableOnly } = config;
|
|
126
|
+
const filter = {};
|
|
127
|
+
if (searchTerm) filter.searchTerm = searchTerm;
|
|
128
|
+
if (categoryId) filter.categoryIds = [categoryId];
|
|
129
|
+
if (brandId) filter.brandIds = [brandId];
|
|
130
|
+
if (collectionId) filter.collectionId = collectionId;
|
|
131
|
+
if (specifications && specifications.length > 0) filter.specifications = specifications;
|
|
132
|
+
if (availableOnly) filter.availableOnly = true;
|
|
133
|
+
return {
|
|
134
|
+
first,
|
|
135
|
+
orderBy: SORT_MAP[sort],
|
|
136
|
+
filter
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function transformProducts(data) {
|
|
140
|
+
return data.edges.map(({ node }) => {
|
|
141
|
+
const image = node.images.edges[0]?.node;
|
|
142
|
+
const variant = node.variants.edges[0]?.node;
|
|
143
|
+
const offer = (variant?.sellers.find((s) => s.isDefault) ?? variant?.sellers[0])?.offer ?? null;
|
|
144
|
+
const price = offer?.price.amount ?? variant?.price.amount ?? 0;
|
|
145
|
+
const listPrice = offer?.listPrice.amount ?? variant?.compareAtPrice?.amount;
|
|
146
|
+
const spotPrice = offer?.spotPrice.amount;
|
|
147
|
+
const currency = offer?.price.currencyCode ?? variant?.price.currencyCode;
|
|
148
|
+
return {
|
|
149
|
+
id: node.id,
|
|
150
|
+
name: node.title,
|
|
151
|
+
slug: node.slug,
|
|
152
|
+
image: {
|
|
153
|
+
src: image?.url ?? "",
|
|
154
|
+
alt: image?.altText ?? node.title
|
|
155
|
+
},
|
|
156
|
+
price,
|
|
157
|
+
...listPrice !== void 0 ? { listPrice } : {},
|
|
158
|
+
...spotPrice !== void 0 ? { spotPrice } : {},
|
|
159
|
+
...offer ? {
|
|
160
|
+
tax: offer.tax.amount,
|
|
161
|
+
taxPercentage: offer.taxPercentage
|
|
162
|
+
} : {},
|
|
163
|
+
...variant ? { availableForSale: variant.availableForSale } : {},
|
|
164
|
+
...variant?.quantityAvailable != null ? { availableQuantity: variant.quantityAvailable } : {},
|
|
165
|
+
...currency ? { currency } : {}
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
const ProductShelfRootDefinition = defineComponent({
|
|
170
|
+
name: "ProductShelfRoot",
|
|
171
|
+
importPath: "@vtex/faststore/components",
|
|
172
|
+
component: ProductShelfRoot,
|
|
173
|
+
fragment,
|
|
174
|
+
fetchStrategy: "lazy",
|
|
175
|
+
skeleton: ProductShelfSkeleton,
|
|
176
|
+
editor: {
|
|
177
|
+
label: "Product Shelf Root",
|
|
178
|
+
category: "commerce"
|
|
179
|
+
},
|
|
180
|
+
providesContext: "product-shelf",
|
|
181
|
+
schema: {
|
|
182
|
+
first: {
|
|
183
|
+
type: "number",
|
|
184
|
+
default: 5,
|
|
185
|
+
label: "Number of Products"
|
|
186
|
+
},
|
|
187
|
+
itemsPerPage: {
|
|
188
|
+
type: "number",
|
|
189
|
+
default: 5,
|
|
190
|
+
label: "Items Per Page"
|
|
191
|
+
},
|
|
192
|
+
sort: {
|
|
193
|
+
type: [
|
|
194
|
+
"relevance",
|
|
195
|
+
"price_asc",
|
|
196
|
+
"price_desc",
|
|
197
|
+
"name_asc",
|
|
198
|
+
"name_desc",
|
|
199
|
+
"release",
|
|
200
|
+
"orders",
|
|
201
|
+
"discount"
|
|
202
|
+
],
|
|
203
|
+
default: "relevance",
|
|
204
|
+
label: "Sort"
|
|
205
|
+
},
|
|
206
|
+
searchTerm: {
|
|
207
|
+
type: "string",
|
|
208
|
+
label: "Search Term"
|
|
209
|
+
},
|
|
210
|
+
categoryId: {
|
|
211
|
+
type: "string",
|
|
212
|
+
label: "Category ID"
|
|
213
|
+
},
|
|
214
|
+
brandId: {
|
|
215
|
+
type: "string",
|
|
216
|
+
label: "Brand ID"
|
|
217
|
+
},
|
|
218
|
+
collectionId: {
|
|
219
|
+
type: "string",
|
|
220
|
+
label: "Collection ID"
|
|
221
|
+
},
|
|
222
|
+
specifications: {
|
|
223
|
+
type: "array",
|
|
224
|
+
label: "Specification Filters"
|
|
225
|
+
},
|
|
226
|
+
availableOnly: {
|
|
227
|
+
type: "boolean",
|
|
228
|
+
default: false,
|
|
229
|
+
label: "Available Only"
|
|
230
|
+
},
|
|
231
|
+
usePriceWithTaxes: {
|
|
232
|
+
type: "boolean",
|
|
233
|
+
default: false,
|
|
234
|
+
label: "Use Price With Taxes"
|
|
235
|
+
},
|
|
236
|
+
taxesLabel: {
|
|
237
|
+
type: "string",
|
|
238
|
+
default: "Tax included",
|
|
239
|
+
label: "Taxes Label"
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
guideline: "Data-owning root of a facet-sourced product shelf. Owns a products(filter:) fragment and receives $data lazily. Compose as: ProductShelfRoot > (ProductShelfHeading + CarouselRoot > (ProductShelfItems + CarouselPrevious + CarouselNext + CarouselBullets)). Compose ProductShelfHeading with the title as its children to render a heading; set the source with categoryId / brandId / collectionId / searchTerm / specifications and tune first, sort, availableOnly. Renders a skeleton while loading and nothing when the result is empty. Bind itemsPerPage to the CarouselRoot so paging matches the shelf config. See product-shelf.md."
|
|
243
|
+
});
|
|
244
|
+
const ProductShelfItemsDefinition = defineComponent({
|
|
245
|
+
name: "ProductShelfItems",
|
|
246
|
+
importPath: "@vtex/faststore/components",
|
|
247
|
+
component: ProductShelfItems,
|
|
248
|
+
editor: {
|
|
249
|
+
label: "Product Shelf Items",
|
|
250
|
+
category: "commerce"
|
|
251
|
+
},
|
|
252
|
+
requiresContext: "product-shelf",
|
|
253
|
+
schema: {},
|
|
254
|
+
guideline: "Repeats the shelf products into the carousel track, publishing one product per slide through the per-item context the ProductCard* parts read. Place directly inside CarouselRoot (it renders the CarouselTrack). Put the card template (ProductCardImage, ProductCardName, ProductCardPrice, …) as its children."
|
|
255
|
+
});
|
|
256
|
+
const ProductShelfHeadingDefinition = defineComponent({
|
|
257
|
+
name: "ProductShelfHeading",
|
|
258
|
+
importPath: "@vtex/faststore/components",
|
|
259
|
+
component: ProductShelfHeading,
|
|
260
|
+
editor: {
|
|
261
|
+
label: "Product Shelf Heading",
|
|
262
|
+
category: "commerce"
|
|
263
|
+
},
|
|
264
|
+
requiresContext: "product-shelf",
|
|
265
|
+
schema: {},
|
|
266
|
+
guideline: "Renders its children as the shelf title (an <h2>) and provides the section's accessible label. Author the title text as its children (props.children). Place it inside ProductShelfRoot where the title should sit — usually above CarouselRoot. Renders nothing when it has no children."
|
|
267
|
+
});
|
|
268
|
+
function ProductShelfRoot({ first = 5, itemsPerPage = 5, sort = "relevance", searchTerm, categoryId, brandId, collectionId, specifications, availableOnly = false, usePriceWithTaxes = false, taxesLabel = "Tax included", products, $data: $dataProp, className, children, ...props }) {
|
|
269
|
+
const $data = useDataOverride($dataProp);
|
|
270
|
+
const headingId = useId();
|
|
271
|
+
const [headingCount, setHeadingCount] = useState(0);
|
|
272
|
+
const registerHeading = useCallback(() => {
|
|
273
|
+
setHeadingCount((count) => count + 1);
|
|
274
|
+
return () => setHeadingCount((count) => count - 1);
|
|
275
|
+
}, []);
|
|
276
|
+
const headingContext = useMemo(() => ({
|
|
277
|
+
headingId,
|
|
278
|
+
registerHeading
|
|
279
|
+
}), [headingId, registerHeading]);
|
|
280
|
+
const config = useMemo(() => ({
|
|
281
|
+
usePriceWithTaxes,
|
|
282
|
+
taxesLabel
|
|
283
|
+
}), [usePriceWithTaxes, taxesLabel]);
|
|
284
|
+
const hasHeading = headingCount > 0;
|
|
285
|
+
let items;
|
|
286
|
+
if (products !== void 0) items = products;
|
|
287
|
+
else if ($data === void 0) return /* @__PURE__ */ jsx(ProductShelfSkeleton, { className });
|
|
288
|
+
else items = $data ? transformProducts($data) : [];
|
|
289
|
+
items = items.slice(0, first);
|
|
290
|
+
if (items.length === 0) return null;
|
|
291
|
+
const shelf = {
|
|
292
|
+
itemsPerPage,
|
|
293
|
+
variables: buildProductShelfVariables({
|
|
294
|
+
first,
|
|
295
|
+
sort,
|
|
296
|
+
searchTerm,
|
|
297
|
+
categoryId,
|
|
298
|
+
brandId,
|
|
299
|
+
collectionId,
|
|
300
|
+
specifications,
|
|
301
|
+
availableOnly
|
|
302
|
+
}),
|
|
303
|
+
count: items.length
|
|
304
|
+
};
|
|
305
|
+
return /* @__PURE__ */ jsx(ProductListConfigContext, {
|
|
306
|
+
value: config,
|
|
307
|
+
children: /* @__PURE__ */ jsx(ProductShelfProductsContext, {
|
|
308
|
+
value: items,
|
|
309
|
+
children: /* @__PURE__ */ jsx(ProductShelfContext, {
|
|
310
|
+
value: shelf,
|
|
311
|
+
children: /* @__PURE__ */ jsx(ProductShelfHeadingContext, {
|
|
312
|
+
value: headingContext,
|
|
313
|
+
children: /* @__PURE__ */ jsx("section", {
|
|
314
|
+
...props,
|
|
315
|
+
className,
|
|
316
|
+
"data-fs-product-shelf": "",
|
|
317
|
+
"aria-labelledby": hasHeading ? headingId : void 0,
|
|
318
|
+
children
|
|
319
|
+
})
|
|
320
|
+
})
|
|
321
|
+
})
|
|
322
|
+
})
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
function ProductShelfHeading({ className, children, ...props }) {
|
|
326
|
+
const { headingId, registerHeading } = useProductShelfHeading();
|
|
327
|
+
const hasContent = children != null && children !== "";
|
|
328
|
+
useEffect(() => {
|
|
329
|
+
if (!hasContent) return;
|
|
330
|
+
return registerHeading();
|
|
331
|
+
}, [hasContent, registerHeading]);
|
|
332
|
+
if (!hasContent) return null;
|
|
333
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
334
|
+
...props,
|
|
335
|
+
as: "h2",
|
|
336
|
+
id: headingId,
|
|
337
|
+
className,
|
|
338
|
+
"data-fs-product-shelf-heading": "",
|
|
339
|
+
children
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
function ProductShelfItems({ children, ...props }) {
|
|
343
|
+
const items = useContext(ProductShelfProductsContext);
|
|
344
|
+
return /* @__PURE__ */ jsx(CarouselTrack, {
|
|
345
|
+
...props,
|
|
346
|
+
"data-fs-product-shelf-items": "",
|
|
347
|
+
children: items.map((item) => /* @__PURE__ */ jsx(ProductListItemContext, {
|
|
348
|
+
value: item,
|
|
349
|
+
children
|
|
350
|
+
}, item.id))
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
function ProductShelfSkeleton({ className, ...props }) {
|
|
354
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
355
|
+
...props,
|
|
356
|
+
className,
|
|
357
|
+
"data-fs-product-shelf-skeleton": "",
|
|
358
|
+
"aria-hidden": "true",
|
|
359
|
+
children: [
|
|
360
|
+
/* @__PURE__ */ jsx("span", { "data-fs-product-shelf-skeleton-item": "" }),
|
|
361
|
+
/* @__PURE__ */ jsx("span", { "data-fs-product-shelf-skeleton-item": "" }),
|
|
362
|
+
/* @__PURE__ */ jsx("span", { "data-fs-product-shelf-skeleton-item": "" })
|
|
363
|
+
]
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
ProductShelfRoot.Skeleton = ProductShelfSkeleton;
|
|
367
|
+
const ProductShelf = {
|
|
368
|
+
Root: ProductShelfRoot,
|
|
369
|
+
Heading: ProductShelfHeading,
|
|
370
|
+
Items: ProductShelfItems,
|
|
371
|
+
Skeleton: ProductShelfSkeleton
|
|
372
|
+
};
|
|
373
|
+
//#endregion
|
|
374
|
+
export { ProductShelf, ProductShelfHeading, ProductShelfHeadingDefinition, ProductShelfItems, ProductShelfItemsDefinition, ProductShelfRoot, ProductShelfRootDefinition, ProductShelfSkeleton, buildProductShelfVariables, transformProducts, useProductShelf, useProductShelfItem };
|
|
375
|
+
|
|
376
|
+
//# sourceMappingURL=product-shelf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-shelf.js","names":[],"sources":["../../../src/matter/product-shelf/product-shelf.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport {\n type ComponentPropsWithRef,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useState,\n} from 'react';\nimport { CarouselTrack } from '../../particles/carousel/carousel.js';\nimport { Text } from '../../particles/text/text.js';\nimport { useDataOverride } from '../../sdk/data/data-override-context.js';\nimport {\n ProductListConfigContext,\n type ProductListItem,\n ProductListItemContext,\n} from '../product-list/product-list.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment — product connection from the catalog module. The query\n// arguments are fixed literals rather than variables: the compiler resolves\n// fragment variables only from route params, search params, or reactive vars\n// (there is no per-element config-variable source), so a config-sourced\n// $first/$orderBy/$filter cannot be hoisted. Until that binding exists\n// (Decision 4), the shelf fetches a fixed top-relevance slice; the config\n// props still drive the client-side context (itemsPerPage, locale, currency).\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment ProductShelfData on Query {\n products(first: 12, orderBy: { field: RELEVANCE, direction: DESC }) {\n edges {\n node {\n id\n title\n slug\n images(first: 1) {\n edges {\n node {\n url\n altText\n }\n }\n }\n variants(first: 1) {\n edges {\n node {\n availableForSale\n quantityAvailable\n price {\n amount\n currencyCode\n }\n compareAtPrice {\n amount\n currencyCode\n }\n sellers {\n isDefault\n offer {\n price {\n amount\n currencyCode\n }\n listPrice {\n amount\n currencyCode\n }\n spotPrice {\n amount\n currencyCode\n }\n tax {\n amount\n currencyCode\n }\n taxPercentage\n availableQuantity\n }\n }\n }\n }\n }\n }\n }\n totalCount\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Raw data types (shape of the fragment result)\n// ---------------------------------------------------------------------------\n\ntype RawMoney = { amount: number; currencyCode: string };\n\ntype RawOffer = {\n price: RawMoney;\n listPrice: RawMoney;\n spotPrice: RawMoney;\n tax: RawMoney;\n taxPercentage: number | null;\n availableQuantity: number;\n};\n\ntype RawVariantNode = {\n availableForSale: boolean;\n quantityAvailable: number | null;\n price: RawMoney;\n compareAtPrice: RawMoney | null;\n sellers: Array<{ isDefault: boolean; offer: RawOffer | null }>;\n};\n\ntype RawProductNode = {\n id: string;\n title: string;\n slug: string;\n images: { edges: Array<{ node: { url: string; altText: string | null } }> };\n variants: { edges: Array<{ node: RawVariantNode }> };\n};\n\n// The `$data` the shelf receives is the unwrapped top-level fragment field:\n// HotDataProvider forwards `data['products']` (the connection value), not the\n// `{ products: ... }` wrapper — same contract as PricingRoot's productBySlug.\nexport type ProductShelfData = {\n edges: Array<{ node: RawProductNode }>;\n totalCount: number;\n};\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n// The per-item value object the card parts (T3–T7) read. It is the widened\n// ProductListItem, so the existing ProductList.Card* leaves render unchanged.\nexport type ProductShelfItem = ProductListItem;\n\nexport type ProductShelfSort =\n | 'relevance'\n | 'price_asc'\n | 'price_desc'\n | 'name_asc'\n | 'name_desc'\n | 'release'\n | 'orders'\n | 'discount';\n\nexport type ProductSortField = 'TITLE' | 'PRICE' | 'RELEASE_DATE' | 'RELEVANCE' | 'BEST_SELLING';\n\nexport type SortDirection = 'ASC' | 'DESC';\n\nexport type ProductsFilterInput = {\n searchTerm?: string;\n categoryIds?: string[];\n brandIds?: string[];\n collectionId?: string;\n specifications?: Array<{ name: string; values: string[] }>;\n availableOnly?: boolean;\n};\n\nexport type ProductShelfVariables = {\n first: number;\n orderBy?: { field: ProductSortField; direction: SortDirection };\n filter: ProductsFilterInput;\n};\n\nexport type ProductShelfConfig = {\n first?: number;\n itemsPerPage?: number;\n sort?: ProductShelfSort;\n searchTerm?: string;\n categoryId?: string;\n brandId?: string;\n collectionId?: string;\n specifications?: Array<{ name: string; values: string[] }>;\n availableOnly?: boolean;\n};\n\nexport type ProductShelfContextValue = {\n itemsPerPage: number;\n variables: ProductShelfVariables;\n count: number;\n};\n\nexport type ProductShelfRootProps = ComponentPropsWithRef<'section'> &\n ProductShelfConfig & {\n /** When true, card prices render tax-inclusive (from each item's tax data). Default false. */\n usePriceWithTaxes?: boolean;\n /** Text for the tax label part when tax display is on. Default `'Tax included'`. */\n taxesLabel?: string;\n products?: ProductShelfItem[];\n $data?: ProductShelfData | null;\n };\n\nexport type ProductShelfItemsProps = ComponentPropsWithRef<'div'>;\n\nexport type ProductShelfHeadingProps = ComponentPropsWithRef<'h2'>;\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\nconst ProductShelfProductsContext = createContext<ProductShelfItem[]>([]);\n\nconst ProductShelfContext = createContext<ProductShelfContextValue | null>(null);\n\n// Wires the section ⇄ heading `aria-labelledby` link without the root having to\n// know its descendants: `headingId` is the shared id, and a composed\n// ProductShelfHeading registers its presence so the section points at it only\n// when it exists (never a dangling idref). `registerHeading` is ref-counted and\n// returns its unregister, so the heading can be placed anywhere.\ntype ProductShelfHeadingContextValue = { headingId: string; registerHeading: () => () => void };\n\nconst ProductShelfHeadingContext = createContext<ProductShelfHeadingContextValue | null>(null);\n\nexport function useProductShelf(): ProductShelfContextValue {\n const ctx = useContext(ProductShelfContext);\n if (!ctx) {\n throw new Error('useProductShelf must be used inside ProductShelfRoot.');\n }\n return ctx;\n}\n\nfunction useProductShelfHeading(): ProductShelfHeadingContextValue {\n const ctx = useContext(ProductShelfHeadingContext);\n if (!ctx) {\n throw new Error('ProductShelfHeading must be used inside ProductShelfRoot.');\n }\n return ctx;\n}\n\nexport function useProductShelfItem(): ProductShelfItem {\n const item = useContext(ProductListItemContext);\n if (!item) {\n throw new Error('Product card components must be used inside ProductShelfItems.');\n }\n return item;\n}\n\n// ---------------------------------------------------------------------------\n// Config → GraphQL variables (the read-side of the shelf's serializable props)\n// ---------------------------------------------------------------------------\n\nconst SORT_MAP: Record<ProductShelfSort, { field: ProductSortField; direction: SortDirection }> = {\n relevance: { field: 'RELEVANCE', direction: 'DESC' },\n price_asc: { field: 'PRICE', direction: 'ASC' },\n price_desc: { field: 'PRICE', direction: 'DESC' },\n name_asc: { field: 'TITLE', direction: 'ASC' },\n name_desc: { field: 'TITLE', direction: 'DESC' },\n release: { field: 'RELEASE_DATE', direction: 'DESC' },\n orders: { field: 'BEST_SELLING', direction: 'DESC' },\n // No direct ProductSortField for legacy \"discount\"; fall back to relevance.\n discount: { field: 'RELEVANCE', direction: 'DESC' },\n};\n\nexport function buildProductShelfVariables(config: ProductShelfConfig): ProductShelfVariables {\n const {\n first = 5,\n sort = 'relevance',\n searchTerm,\n categoryId,\n brandId,\n collectionId,\n specifications,\n availableOnly,\n } = config;\n\n const filter: ProductsFilterInput = {};\n if (searchTerm) filter.searchTerm = searchTerm;\n if (categoryId) filter.categoryIds = [categoryId];\n if (brandId) filter.brandIds = [brandId];\n if (collectionId) filter.collectionId = collectionId;\n if (specifications && specifications.length > 0) filter.specifications = specifications;\n if (availableOnly) filter.availableOnly = true;\n\n return { first, orderBy: SORT_MAP[sort], filter };\n}\n\n// ---------------------------------------------------------------------------\n// Transform — raw fragment slice → per-item value objects\n// ---------------------------------------------------------------------------\n\nexport function transformProducts(data: ProductShelfData): ProductShelfItem[] {\n return data.edges.map(({ node }): ProductShelfItem => {\n const image = node.images.edges[0]?.node;\n const variant = node.variants.edges[0]?.node;\n const seller = variant?.sellers.find((s) => s.isDefault) ?? variant?.sellers[0];\n const offer = seller?.offer ?? null;\n\n const price = offer?.price.amount ?? variant?.price.amount ?? 0;\n const listPrice = offer?.listPrice.amount ?? variant?.compareAtPrice?.amount;\n const spotPrice = offer?.spotPrice.amount;\n const currency = offer?.price.currencyCode ?? variant?.price.currencyCode;\n\n return {\n id: node.id,\n name: node.title,\n slug: node.slug,\n image: { src: image?.url ?? '', alt: image?.altText ?? node.title },\n price,\n ...(listPrice !== undefined ? { listPrice } : {}),\n ...(spotPrice !== undefined ? { spotPrice } : {}),\n ...(offer ? { tax: offer.tax.amount, taxPercentage: offer.taxPercentage } : {}),\n ...(variant ? { availableForSale: variant.availableForSale } : {}),\n ...(variant?.quantityAvailable != null ? { availableQuantity: variant.quantityAvailable } : {}),\n ...(currency ? { currency } : {}),\n };\n });\n}\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const ProductShelfRootDefinition = defineComponent<ProductShelfRootProps>({\n name: 'ProductShelfRoot',\n importPath: '@vtex/faststore/components',\n component: ProductShelfRoot,\n fragment,\n fetchStrategy: 'lazy',\n skeleton: ProductShelfSkeleton,\n editor: { label: 'Product Shelf Root', category: 'commerce' },\n providesContext: 'product-shelf',\n schema: {\n first: { type: 'number', default: 5, label: 'Number of Products' },\n itemsPerPage: { type: 'number', default: 5, label: 'Items Per Page' },\n sort: {\n type: ['relevance', 'price_asc', 'price_desc', 'name_asc', 'name_desc', 'release', 'orders', 'discount'] as const,\n default: 'relevance',\n label: 'Sort',\n },\n searchTerm: { type: 'string', label: 'Search Term' },\n categoryId: { type: 'string', label: 'Category ID' },\n brandId: { type: 'string', label: 'Brand ID' },\n collectionId: { type: 'string', label: 'Collection ID' },\n specifications: { type: 'array', label: 'Specification Filters' },\n availableOnly: { type: 'boolean', default: false, label: 'Available Only' },\n usePriceWithTaxes: { type: 'boolean', default: false, label: 'Use Price With Taxes' },\n taxesLabel: { type: 'string', default: 'Tax included', label: 'Taxes Label' },\n },\n guideline:\n 'Data-owning root of a facet-sourced product shelf. Owns a products(filter:) fragment and receives $data lazily. Compose as: ProductShelfRoot > (ProductShelfHeading + CarouselRoot > (ProductShelfItems + CarouselPrevious + CarouselNext + CarouselBullets)). Compose ProductShelfHeading with the title as its children to render a heading; set the source with categoryId / brandId / collectionId / searchTerm / specifications and tune first, sort, availableOnly. Renders a skeleton while loading and nothing when the result is empty. Bind itemsPerPage to the CarouselRoot so paging matches the shelf config. See product-shelf.md.',\n});\n\nexport const ProductShelfItemsDefinition = defineComponent<ProductShelfItemsProps>({\n name: 'ProductShelfItems',\n importPath: '@vtex/faststore/components',\n component: ProductShelfItems,\n editor: { label: 'Product Shelf Items', category: 'commerce' },\n requiresContext: 'product-shelf',\n schema: {},\n guideline:\n 'Repeats the shelf products into the carousel track, publishing one product per slide through the per-item context the ProductCard* parts read. Place directly inside CarouselRoot (it renders the CarouselTrack). Put the card template (ProductCardImage, ProductCardName, ProductCardPrice, …) as its children.',\n});\n\nexport const ProductShelfHeadingDefinition = defineComponent<ProductShelfHeadingProps>({\n name: 'ProductShelfHeading',\n importPath: '@vtex/faststore/components',\n component: ProductShelfHeading,\n editor: { label: 'Product Shelf Heading', category: 'commerce' },\n requiresContext: 'product-shelf',\n schema: {},\n guideline:\n \"Renders its children as the shelf title (an <h2>) and provides the section's accessible label. Author the title text as its children (props.children). Place it inside ProductShelfRoot where the title should sit — usually above CarouselRoot. Renders nothing when it has no children.\",\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\nexport function ProductShelfRoot({\n first = 5,\n itemsPerPage = 5,\n sort = 'relevance',\n searchTerm,\n categoryId,\n brandId,\n collectionId,\n specifications,\n availableOnly = false,\n usePriceWithTaxes = false,\n taxesLabel = 'Tax included',\n products,\n $data: $dataProp,\n className,\n children,\n ...props\n}: ProductShelfRootProps) {\n const $data = useDataOverride<ProductShelfData | null | undefined>($dataProp);\n const headingId = useId();\n // Ref-counted so a composed ProductShelfHeading flips `hasHeading` wherever it is placed; the\n // section then labels itself only while a heading is mounted, never via a dangling idref.\n const [headingCount, setHeadingCount] = useState(0);\n const registerHeading = useCallback(() => {\n setHeadingCount((count) => count + 1);\n return () => setHeadingCount((count) => count - 1);\n }, []);\n const headingContext = useMemo(() => ({ headingId, registerHeading }), [headingId, registerHeading]);\n const config = useMemo(() => ({ usePriceWithTaxes, taxesLabel }), [usePriceWithTaxes, taxesLabel]);\n const hasHeading = headingCount > 0;\n\n let items: ProductShelfItem[];\n if (products !== undefined) {\n items = products;\n } else if ($data === undefined) {\n // Lazy source not resolved yet — show the skeleton (the runtime also renders it).\n return <ProductShelfSkeleton className={className} />;\n } else {\n items = $data ? transformProducts($data) : [];\n }\n\n items = items.slice(0, first);\n\n // Empty result renders nothing (legacy parity) rather than an empty carousel.\n if (items.length === 0) {\n return null;\n }\n\n const variables = buildProductShelfVariables({\n first,\n sort,\n searchTerm,\n categoryId,\n brandId,\n collectionId,\n specifications,\n availableOnly,\n });\n\n const shelf: ProductShelfContextValue = { itemsPerPage, variables, count: items.length };\n\n return (\n <ProductListConfigContext value={config}>\n <ProductShelfProductsContext value={items}>\n <ProductShelfContext value={shelf}>\n <ProductShelfHeadingContext value={headingContext}>\n <section\n {...props}\n className={className}\n data-fs-product-shelf=\"\"\n aria-labelledby={hasHeading ? headingId : undefined}\n >\n {children}\n </section>\n </ProductShelfHeadingContext>\n </ProductShelfContext>\n </ProductShelfProductsContext>\n </ProductListConfigContext>\n );\n}\n\nexport function ProductShelfHeading({ className, children, ...props }: ProductShelfHeadingProps) {\n const { headingId, registerHeading } = useProductShelfHeading();\n const hasContent = children != null && children !== '';\n\n // Announce presence to the root so its section wires `aria-labelledby` to this heading; the\n // registration (and its unregister) is scoped to when the heading actually renders content.\n useEffect(() => {\n if (!hasContent) {\n return;\n }\n return registerHeading();\n }, [hasContent, registerHeading]);\n\n if (!hasContent) {\n return null;\n }\n\n return (\n <Text {...props} as=\"h2\" id={headingId} className={className} data-fs-product-shelf-heading=\"\">\n {children}\n </Text>\n );\n}\n\nexport function ProductShelfItems({ children, ...props }: ProductShelfItemsProps) {\n const items = useContext(ProductShelfProductsContext);\n\n return (\n <CarouselTrack {...props} data-fs-product-shelf-items=\"\">\n {items.map((item) => (\n <ProductListItemContext key={item.id} value={item}>\n {children}\n </ProductListItemContext>\n ))}\n </CarouselTrack>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Skeleton\n// ---------------------------------------------------------------------------\n\nexport function ProductShelfSkeleton({ className, ...props }: ComponentPropsWithRef<'div'>) {\n return (\n <div {...props} className={className} data-fs-product-shelf-skeleton=\"\" aria-hidden=\"true\">\n <span data-fs-product-shelf-skeleton-item=\"\" />\n <span data-fs-product-shelf-skeleton-item=\"\" />\n <span data-fs-product-shelf-skeleton-item=\"\" />\n </div>\n );\n}\n\nProductShelfRoot.Skeleton = ProductShelfSkeleton;\n\n// ---------------------------------------------------------------------------\n// Namespace export\n// ---------------------------------------------------------------------------\n\nexport const ProductShelf = {\n Root: ProductShelfRoot,\n Heading: ProductShelfHeading,\n Items: ProductShelfItems,\n Skeleton: ProductShelfSkeleton,\n};\n"],"mappings":";;;;;;;;;;AAgCA,MAAM,WAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8K/B,MAAM,8BAA8B,cAAkC,CAAC,CAAC;AAExE,MAAM,sBAAsB,cAA+C,IAAI;AAS/E,MAAM,6BAA6B,cAAsD,IAAI;AAE7F,SAAgB,kBAA4C;CAC1D,MAAM,MAAM,WAAW,mBAAmB;CAC1C,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,uDAAuD;CAEzE,OAAO;AACT;AAEA,SAAS,yBAA0D;CACjE,MAAM,MAAM,WAAW,0BAA0B;CACjD,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,2DAA2D;CAE7E,OAAO;AACT;AAEA,SAAgB,sBAAwC;CACtD,MAAM,OAAO,WAAW,sBAAsB;CAC9C,IAAI,CAAC,MACH,MAAM,IAAI,MAAM,gEAAgE;CAElF,OAAO;AACT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