@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,342 @@
|
|
|
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 { Button } from "../../particles/button/button.js";
|
|
6
|
+
import { Image } from "../../particles/image/image.js";
|
|
7
|
+
import { Badge } from "../../particles/badge/badge.js";
|
|
8
|
+
import { Container } from "../../particles/container/container.js";
|
|
9
|
+
import { Text } from "../../particles/text/text.js";
|
|
10
|
+
import { createContext, useContext, useMemo } from "react";
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
//#region src/matter/product-list/product-list.tsx
|
|
13
|
+
const ProductListConfigContext = createContext({
|
|
14
|
+
usePriceWithTaxes: false,
|
|
15
|
+
taxesLabel: "Tax included"
|
|
16
|
+
});
|
|
17
|
+
function useProductListConfig() {
|
|
18
|
+
return useContext(ProductListConfigContext);
|
|
19
|
+
}
|
|
20
|
+
function formatPrice(value, locale, currency) {
|
|
21
|
+
return new Intl.NumberFormat(locale, {
|
|
22
|
+
style: "currency",
|
|
23
|
+
currency
|
|
24
|
+
}).format(value);
|
|
25
|
+
}
|
|
26
|
+
function taxRate(item) {
|
|
27
|
+
if (item.taxPercentage != null) return item.taxPercentage;
|
|
28
|
+
if (item.tax != null && item.price > 0) return item.tax / item.price;
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
function priceWithTaxes(base, item) {
|
|
32
|
+
return base * (1 + taxRate(item));
|
|
33
|
+
}
|
|
34
|
+
const ProductListProductsContext = createContext([]);
|
|
35
|
+
const ProductListItemContext = createContext(null);
|
|
36
|
+
function useProductListItem() {
|
|
37
|
+
const item = useContext(ProductListItemContext);
|
|
38
|
+
if (!item) throw new Error("ProductCard components must be used inside ProductListGrid.");
|
|
39
|
+
return item;
|
|
40
|
+
}
|
|
41
|
+
const ProductListRootDefinition = defineComponent({
|
|
42
|
+
name: "ProductListRoot",
|
|
43
|
+
importPath: "@vtex/faststore/components",
|
|
44
|
+
component: ProductListRoot,
|
|
45
|
+
editor: {
|
|
46
|
+
label: "Product List Root",
|
|
47
|
+
category: "commerce"
|
|
48
|
+
},
|
|
49
|
+
schema: {
|
|
50
|
+
usePriceWithTaxes: {
|
|
51
|
+
type: "boolean",
|
|
52
|
+
default: false,
|
|
53
|
+
label: "Use Price With Taxes"
|
|
54
|
+
},
|
|
55
|
+
taxesLabel: {
|
|
56
|
+
type: "string",
|
|
57
|
+
default: "Tax included",
|
|
58
|
+
label: "Taxes Label"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
guideline: "Top-level wrapper for the product list; compose as ProductListRoot > ProductListGrid > ProductCard* children. Set usePriceWithTaxes to render tax-inclusive card prices and compose ProductCardTaxLabel to show the taxesLabel."
|
|
62
|
+
});
|
|
63
|
+
const ProductListGridDefinition = defineComponent({
|
|
64
|
+
name: "ProductListGrid",
|
|
65
|
+
importPath: "@vtex/faststore/components",
|
|
66
|
+
component: ProductListGrid,
|
|
67
|
+
editor: {
|
|
68
|
+
label: "Product List Grid",
|
|
69
|
+
category: "commerce"
|
|
70
|
+
},
|
|
71
|
+
schema: {},
|
|
72
|
+
guideline: "Repeating grid that renders the ProductCard* template for each product; must be a direct child of ProductListRoot."
|
|
73
|
+
});
|
|
74
|
+
const ProductCardDefinition = defineComponent({
|
|
75
|
+
name: "ProductCard",
|
|
76
|
+
importPath: "@vtex/faststore/components",
|
|
77
|
+
component: ProductCard,
|
|
78
|
+
editor: {
|
|
79
|
+
label: "Product Card",
|
|
80
|
+
category: "commerce"
|
|
81
|
+
},
|
|
82
|
+
schema: { bordered: {
|
|
83
|
+
type: "boolean",
|
|
84
|
+
default: true,
|
|
85
|
+
label: "Bordered"
|
|
86
|
+
} },
|
|
87
|
+
guideline: "Optional card wrapper for the ProductCard* parts; always emits data-fs-product-card and data-fs-product-card-bordered (true/false, from the bordered toggle), and adds data-fs-product-card-out-of-stock when the product is unavailable (derived from availability, no prop). The border look is a swatch keyed off data-fs-product-card-bordered. Renders all children unchanged. Must be inside ProductListGrid / ProductShelfItems."
|
|
88
|
+
});
|
|
89
|
+
const ProductCardImageDefinition = defineComponent({
|
|
90
|
+
name: "ProductCardImage",
|
|
91
|
+
importPath: "@vtex/faststore/components",
|
|
92
|
+
component: ProductCardImage,
|
|
93
|
+
editor: {
|
|
94
|
+
label: "Product Card Image",
|
|
95
|
+
category: "commerce"
|
|
96
|
+
},
|
|
97
|
+
schema: {
|
|
98
|
+
objectFit: {
|
|
99
|
+
type: [
|
|
100
|
+
"contain",
|
|
101
|
+
"cover",
|
|
102
|
+
"fill",
|
|
103
|
+
"none"
|
|
104
|
+
],
|
|
105
|
+
default: "cover",
|
|
106
|
+
label: "Object Fit"
|
|
107
|
+
},
|
|
108
|
+
aspectRatio: {
|
|
109
|
+
type: "string",
|
|
110
|
+
label: "Aspect Ratio"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
guideline: "Renders the product image with a configurable aspectRatio (e.g. 1/1, 3/4, 16/9) and objectFit. Alt text comes from the catalog. Must be inside ProductListGrid."
|
|
114
|
+
});
|
|
115
|
+
const ProductCardNameDefinition = defineComponent({
|
|
116
|
+
name: "ProductCardName",
|
|
117
|
+
importPath: "@vtex/faststore/components",
|
|
118
|
+
component: ProductCardName,
|
|
119
|
+
editor: {
|
|
120
|
+
label: "Product Card Name",
|
|
121
|
+
category: "commerce"
|
|
122
|
+
},
|
|
123
|
+
schema: {},
|
|
124
|
+
guideline: "Renders the product name. Must be inside ProductListGrid."
|
|
125
|
+
});
|
|
126
|
+
const ProductCardPriceDefinition = defineComponent({
|
|
127
|
+
name: "ProductCardPrice",
|
|
128
|
+
importPath: "@vtex/faststore/components",
|
|
129
|
+
component: ProductCardPrice,
|
|
130
|
+
editor: {
|
|
131
|
+
label: "Product Card Price",
|
|
132
|
+
category: "commerce"
|
|
133
|
+
},
|
|
134
|
+
schema: {},
|
|
135
|
+
guideline: "Displays the selling price formatted from the active storefront context; renders tax-inclusive when usePriceWithTaxes is enabled. Must be inside ProductListGrid."
|
|
136
|
+
});
|
|
137
|
+
const ProductCardListPriceDefinition = defineComponent({
|
|
138
|
+
name: "ProductCardListPrice",
|
|
139
|
+
importPath: "@vtex/faststore/components",
|
|
140
|
+
component: ProductCardListPrice,
|
|
141
|
+
editor: {
|
|
142
|
+
label: "Product Card List Price",
|
|
143
|
+
category: "commerce"
|
|
144
|
+
},
|
|
145
|
+
schema: {},
|
|
146
|
+
guideline: "Displays the original (strikethrough) list price when it exceeds the selling price; renders tax-inclusive when usePriceWithTaxes is enabled. Must be inside ProductListGrid."
|
|
147
|
+
});
|
|
148
|
+
const ProductCardTaxLabelDefinition = defineComponent({
|
|
149
|
+
name: "ProductCardTaxLabel",
|
|
150
|
+
importPath: "@vtex/faststore/components",
|
|
151
|
+
component: ProductCardTaxLabel,
|
|
152
|
+
editor: {
|
|
153
|
+
label: "Product Card Tax Label",
|
|
154
|
+
category: "commerce"
|
|
155
|
+
},
|
|
156
|
+
schema: {},
|
|
157
|
+
guideline: "Tax label (e.g. \"Tax included\") shown beside the price. Renders only when the ProductListRoot/ProductShelfRoot config usePriceWithTaxes is enabled (state-driven, no toggle); the text comes from the taxesLabel config. Compose it to place the label, omit it to hide it. Must be inside ProductListGrid / ProductShelfItems."
|
|
158
|
+
});
|
|
159
|
+
const ProductCardDiscountDefinition = defineComponent({
|
|
160
|
+
name: "ProductCardDiscount",
|
|
161
|
+
importPath: "@vtex/faststore/components",
|
|
162
|
+
component: ProductCardDiscount,
|
|
163
|
+
editor: {
|
|
164
|
+
label: "Product Card Discount",
|
|
165
|
+
category: "commerce"
|
|
166
|
+
},
|
|
167
|
+
schema: { format: {
|
|
168
|
+
type: ["percentage", "absolute"],
|
|
169
|
+
default: "percentage",
|
|
170
|
+
label: "Discount Format"
|
|
171
|
+
} },
|
|
172
|
+
guideline: "Discount badge for the current product; auto-computes the markdown from listPrice vs price and renders only when a discount exists. Compose it to show the badge, omit it to hide it (no toggle). Must be inside ProductListGrid / ProductShelfItems."
|
|
173
|
+
});
|
|
174
|
+
const ProductCardAddToCartDefinition = defineComponent({
|
|
175
|
+
name: "ProductCardAddToCart",
|
|
176
|
+
importPath: "@vtex/faststore/components",
|
|
177
|
+
component: ProductCardAddToCart,
|
|
178
|
+
editor: {
|
|
179
|
+
label: "Product Card Add to Cart",
|
|
180
|
+
category: "commerce"
|
|
181
|
+
},
|
|
182
|
+
schema: {},
|
|
183
|
+
actions: { cart: ["addItem"] },
|
|
184
|
+
guideline: "Add-to-cart button for the current product card; must be inside ProductListGrid."
|
|
185
|
+
});
|
|
186
|
+
function ProductListRoot({ usePriceWithTaxes = false, taxesLabel = "Tax included", products = [], className, children, ...props }) {
|
|
187
|
+
const config = useMemo(() => ({
|
|
188
|
+
usePriceWithTaxes,
|
|
189
|
+
taxesLabel
|
|
190
|
+
}), [usePriceWithTaxes, taxesLabel]);
|
|
191
|
+
return /* @__PURE__ */ jsx(ProductListConfigContext, {
|
|
192
|
+
value: config,
|
|
193
|
+
children: /* @__PURE__ */ jsx(ProductListProductsContext, {
|
|
194
|
+
value: products,
|
|
195
|
+
children: /* @__PURE__ */ jsx(Container, {
|
|
196
|
+
...props,
|
|
197
|
+
className,
|
|
198
|
+
"data-fs-product-list-root": "",
|
|
199
|
+
children
|
|
200
|
+
})
|
|
201
|
+
})
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function ProductListGrid({ className, children, ...props }) {
|
|
205
|
+
const products = useContext(ProductListProductsContext);
|
|
206
|
+
return /* @__PURE__ */ jsx(Container, {
|
|
207
|
+
...props,
|
|
208
|
+
className,
|
|
209
|
+
"data-fs-product-list-grid": "",
|
|
210
|
+
children: products.map((product) => /* @__PURE__ */ jsx(ProductListItemContext, {
|
|
211
|
+
value: product,
|
|
212
|
+
children
|
|
213
|
+
}, product.id))
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function ProductCard({ className, children, bordered = true, ...props }) {
|
|
217
|
+
const item = useProductListItem();
|
|
218
|
+
const outOfStock = item.availableForSale === false || item.availableQuantity === 0;
|
|
219
|
+
return /* @__PURE__ */ jsx(Container, {
|
|
220
|
+
...props,
|
|
221
|
+
className,
|
|
222
|
+
"data-fs-product-card": "",
|
|
223
|
+
"data-fs-product-card-bordered": String(bordered),
|
|
224
|
+
"data-fs-product-card-out-of-stock": outOfStock ? "" : void 0,
|
|
225
|
+
children
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
function ProductCardImage({ className, objectFit = "cover", aspectRatio, ...props }) {
|
|
229
|
+
const item = useProductListItem();
|
|
230
|
+
return /* @__PURE__ */ jsx(Image, {
|
|
231
|
+
...props,
|
|
232
|
+
src: item.image.src,
|
|
233
|
+
alt: item.image.alt,
|
|
234
|
+
aspectRatio,
|
|
235
|
+
className,
|
|
236
|
+
style: {
|
|
237
|
+
objectFit,
|
|
238
|
+
...props.style
|
|
239
|
+
},
|
|
240
|
+
"data-fs-product-card-image": ""
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
function ProductCardName({ className, children, ...props }) {
|
|
244
|
+
const item = useProductListItem();
|
|
245
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
246
|
+
...props,
|
|
247
|
+
as: "span",
|
|
248
|
+
className,
|
|
249
|
+
"data-fs-product-card-name": "",
|
|
250
|
+
children: children ?? item.name
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
function ProductCardPrice({ className, children, ...props }) {
|
|
254
|
+
const item = useProductListItem();
|
|
255
|
+
const { usePriceWithTaxes } = useProductListConfig();
|
|
256
|
+
const { locale, currency } = useStorefrontContext();
|
|
257
|
+
const value = usePriceWithTaxes ? priceWithTaxes(item.price, item) : item.price;
|
|
258
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
259
|
+
...props,
|
|
260
|
+
as: "span",
|
|
261
|
+
className,
|
|
262
|
+
"data-fs-product-card-price": "",
|
|
263
|
+
children: children ?? formatPrice(value, locale, item.currency ?? currency)
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
function ProductCardListPrice({ className, children, ...props }) {
|
|
267
|
+
const item = useProductListItem();
|
|
268
|
+
const { usePriceWithTaxes } = useProductListConfig();
|
|
269
|
+
const { locale, currency } = useStorefrontContext();
|
|
270
|
+
if (!item.listPrice || item.listPrice <= item.price) return null;
|
|
271
|
+
const value = usePriceWithTaxes ? priceWithTaxes(item.listPrice, item) : item.listPrice;
|
|
272
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
273
|
+
...props,
|
|
274
|
+
as: "span",
|
|
275
|
+
className,
|
|
276
|
+
"data-fs-product-card-list-price": "",
|
|
277
|
+
children: children ?? formatPrice(value, locale, item.currency ?? currency)
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
function ProductCardTaxLabel({ className, children, ...props }) {
|
|
281
|
+
const { usePriceWithTaxes, taxesLabel } = useProductListConfig();
|
|
282
|
+
if (!usePriceWithTaxes) return null;
|
|
283
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
284
|
+
...props,
|
|
285
|
+
as: "span",
|
|
286
|
+
className,
|
|
287
|
+
"data-fs-product-card-tax-label": "",
|
|
288
|
+
children: children ?? taxesLabel
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
function ProductCardDiscount({ className, children, format = "percentage", ...props }) {
|
|
292
|
+
const item = useProductListItem();
|
|
293
|
+
const { usePriceWithTaxes } = useProductListConfig();
|
|
294
|
+
const { locale, currency } = useStorefrontContext();
|
|
295
|
+
const { listPrice, price } = item;
|
|
296
|
+
if (!listPrice || listPrice <= price) return null;
|
|
297
|
+
const amountOff = listPrice - price;
|
|
298
|
+
const percentOff = Math.round(amountOff / listPrice * 100);
|
|
299
|
+
const tier = percentOff >= 30 ? "high" : percentOff >= 15 ? "medium" : "low";
|
|
300
|
+
const displayedAmountOff = usePriceWithTaxes ? priceWithTaxes(amountOff, item) : amountOff;
|
|
301
|
+
const label = format === "absolute" ? `-${formatPrice(displayedAmountOff, locale, item.currency ?? currency)}` : `-${percentOff}%`;
|
|
302
|
+
return /* @__PURE__ */ jsx(Badge, {
|
|
303
|
+
...props,
|
|
304
|
+
className,
|
|
305
|
+
"data-fs-product-card-discount": "",
|
|
306
|
+
"data-fs-product-card-discount-tier": tier,
|
|
307
|
+
children: children ?? label
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
function ProductCardAddToCart({ className, children, onClick, $actions, ...props }) {
|
|
311
|
+
const item = useProductListItem();
|
|
312
|
+
function handleClick(e) {
|
|
313
|
+
$actions?.cart?.addItem?.({
|
|
314
|
+
variantId: item.id,
|
|
315
|
+
seller: "1"
|
|
316
|
+
});
|
|
317
|
+
onClick?.(e);
|
|
318
|
+
}
|
|
319
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
320
|
+
...props,
|
|
321
|
+
className,
|
|
322
|
+
onClick: handleClick,
|
|
323
|
+
"data-fs-product-card-add-to-cart": "",
|
|
324
|
+
children
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
const ProductList = {
|
|
328
|
+
Root: ProductListRoot,
|
|
329
|
+
Grid: ProductListGrid,
|
|
330
|
+
Card: ProductCard,
|
|
331
|
+
CardImage: ProductCardImage,
|
|
332
|
+
CardName: ProductCardName,
|
|
333
|
+
CardPrice: ProductCardPrice,
|
|
334
|
+
CardListPrice: ProductCardListPrice,
|
|
335
|
+
CardTaxLabel: ProductCardTaxLabel,
|
|
336
|
+
CardDiscount: ProductCardDiscount,
|
|
337
|
+
CardAddToCart: ProductCardAddToCart
|
|
338
|
+
};
|
|
339
|
+
//#endregion
|
|
340
|
+
export { ProductCard, ProductCardAddToCart, ProductCardAddToCartDefinition, ProductCardDefinition, ProductCardDiscount, ProductCardDiscountDefinition, ProductCardImage, ProductCardImageDefinition, ProductCardListPrice, ProductCardListPriceDefinition, ProductCardName, ProductCardNameDefinition, ProductCardPrice, ProductCardPriceDefinition, ProductCardTaxLabel, ProductCardTaxLabelDefinition, ProductList, ProductListConfigContext, ProductListGrid, ProductListGridDefinition, ProductListItemContext, ProductListRoot, ProductListRootDefinition };
|
|
341
|
+
|
|
342
|
+
//# sourceMappingURL=product-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-list.js","names":[],"sources":["../../../src/matter/product-list/product-list.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport { type ComponentPropsWithRef, createContext, useContext, useMemo } from 'react';\nimport { Badge } from '../../particles/badge/badge.js';\nimport { Button } from '../../particles/button/button.js';\nimport { Container } from '../../particles/container/container.js';\nimport { Image } from '../../particles/image/image.js';\nimport { Text } from '../../particles/text/text.js';\nimport type { ComponentActions } from '../../sdk/actions/types.js';\nimport { useStorefrontContext } from '../../sdk/context/storefront-context.js';\n\n// ---------------------------------------------------------------------------\n// Product list config context (tax display)\n// ---------------------------------------------------------------------------\n\ntype ProductListConfig = {\n usePriceWithTaxes: boolean;\n taxesLabel: string;\n};\n\nexport const ProductListConfigContext = createContext<ProductListConfig>({\n usePriceWithTaxes: false,\n taxesLabel: 'Tax included',\n});\n\nfunction useProductListConfig(): ProductListConfig {\n return useContext(ProductListConfigContext);\n}\n\nfunction formatPrice(value: number, locale: string, currency: string): string {\n return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(value);\n}\n\n// Tax rate for the item: the explicit `taxPercentage` (e.g. 0.18) wins; otherwise it is derived\n// from the absolute tax amount over the price. Missing/zero-price data yields 0 (no change).\nfunction taxRate(item: ProductListItem): number {\n if (item.taxPercentage != null) {\n return item.taxPercentage;\n }\n if (item.tax != null && item.price > 0) {\n return item.tax / item.price;\n }\n return 0;\n}\n\nfunction priceWithTaxes(base: number, item: ProductListItem): number {\n return base * (1 + taxRate(item));\n}\n\n// ---------------------------------------------------------------------------\n// Product list item types\n// ---------------------------------------------------------------------------\n\nexport type ProductListItemImage = {\n src: string;\n alt: string;\n};\n\nexport type ProductListItem = {\n id: string;\n name: string;\n image: ProductListItemImage;\n price: number;\n listPrice?: number;\n variant?: string;\n slug?: string;\n // Widened for the Product Shelf (T2): fields the card parts T3–T7 read straight off the\n // per-item context. Optional so the plain-`products` ProductListRoot (PLP) stays valid.\n spotPrice?: number;\n tax?: number;\n taxPercentage?: number | null;\n availableForSale?: boolean;\n availableQuantity?: number;\n currency?: string;\n};\n\n// ---------------------------------------------------------------------------\n// Products context (provided by Root, consumed by Grid)\n// ---------------------------------------------------------------------------\n\nconst ProductListProductsContext = createContext<ProductListItem[]>([]);\n\n// ---------------------------------------------------------------------------\n// Item context (provided by Grid per product)\n// ---------------------------------------------------------------------------\n\nexport const ProductListItemContext = createContext<ProductListItem | null>(null);\n\nfunction useProductListItem(): ProductListItem {\n const item = useContext(ProductListItemContext);\n if (!item) {\n throw new Error('ProductCard components must be used inside ProductListGrid.');\n }\n return item;\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type ProductListRootProps = ComponentPropsWithRef<'div'> & {\n products?: ProductListItem[];\n /** When true, card prices render tax-inclusive (from the 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};\n\nexport type ProductListGridProps = ComponentPropsWithRef<'div'>;\n\nexport type ProductCardProps = ComponentPropsWithRef<'div'> & {\n /** Toggles the card border. Reflects onto data-fs-product-card-bordered; a swatch draws the border. Default true. */\n bordered?: boolean;\n};\n\nexport type ProductCardImageProps = ComponentPropsWithRef<'img'> & {\n objectFit?: 'contain' | 'cover' | 'fill' | 'none';\n /** CSS `aspect-ratio` (e.g. `'1/1'`, `'3/4'`, `'16/9'`); lays out the image box, orthogonal to `objectFit`. */\n aspectRatio?: string;\n};\n\nexport type ProductCardNameProps = ComponentPropsWithRef<'span'>;\n\nexport type ProductCardPriceProps = ComponentPropsWithRef<'span'>;\n\nexport type ProductCardListPriceProps = ComponentPropsWithRef<'span'>;\n\nexport type ProductCardTaxLabelProps = ComponentPropsWithRef<'span'>;\n\nexport type ProductCardDiscountProps = ComponentPropsWithRef<'span'> & {\n format?: 'percentage' | 'absolute';\n};\n\nexport type ProductCardAddToCartProps = ComponentPropsWithRef<'button'> & {\n /** Injected by the compiler from `actions: { cart: ['addItem'] }`; the cart write surface. */\n $actions?: ComponentActions;\n};\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const ProductListRootDefinition = defineComponent<ProductListRootProps>({\n name: 'ProductListRoot',\n importPath: '@vtex/faststore/components',\n component: ProductListRoot,\n editor: { label: 'Product List Root', category: 'commerce' },\n schema: {\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 'Top-level wrapper for the product list; compose as ProductListRoot > ProductListGrid > ProductCard* children. Set usePriceWithTaxes to render tax-inclusive card prices and compose ProductCardTaxLabel to show the taxesLabel.',\n});\n\nexport const ProductListGridDefinition = defineComponent<ProductListGridProps>({\n name: 'ProductListGrid',\n importPath: '@vtex/faststore/components',\n component: ProductListGrid,\n editor: { label: 'Product List Grid', category: 'commerce' },\n schema: {},\n guideline:\n 'Repeating grid that renders the ProductCard* template for each product; must be a direct child of ProductListRoot.',\n});\n\nexport const ProductCardDefinition = defineComponent<ProductCardProps>({\n name: 'ProductCard',\n importPath: '@vtex/faststore/components',\n component: ProductCard,\n editor: { label: 'Product Card', category: 'commerce' },\n schema: {\n bordered: { type: 'boolean', default: true, label: 'Bordered' },\n },\n guideline:\n 'Optional card wrapper for the ProductCard* parts; always emits data-fs-product-card and data-fs-product-card-bordered (true/false, from the bordered toggle), and adds data-fs-product-card-out-of-stock when the product is unavailable (derived from availability, no prop). The border look is a swatch keyed off data-fs-product-card-bordered. Renders all children unchanged. Must be inside ProductListGrid / ProductShelfItems.',\n});\n\nexport const ProductCardImageDefinition = defineComponent<ProductCardImageProps>({\n name: 'ProductCardImage',\n importPath: '@vtex/faststore/components',\n component: ProductCardImage,\n editor: { label: 'Product Card Image', category: 'commerce' },\n schema: {\n objectFit: { type: ['contain', 'cover', 'fill', 'none'] as const, default: 'cover', label: 'Object Fit' },\n aspectRatio: { type: 'string', label: 'Aspect Ratio' },\n },\n guideline:\n 'Renders the product image with a configurable aspectRatio (e.g. 1/1, 3/4, 16/9) and objectFit. Alt text comes from the catalog. Must be inside ProductListGrid.',\n});\n\nexport const ProductCardNameDefinition = defineComponent<ProductCardNameProps>({\n name: 'ProductCardName',\n importPath: '@vtex/faststore/components',\n component: ProductCardName,\n editor: { label: 'Product Card Name', category: 'commerce' },\n schema: {},\n guideline: 'Renders the product name. Must be inside ProductListGrid.',\n});\n\nexport const ProductCardPriceDefinition = defineComponent<ProductCardPriceProps>({\n name: 'ProductCardPrice',\n importPath: '@vtex/faststore/components',\n component: ProductCardPrice,\n editor: { label: 'Product Card Price', category: 'commerce' },\n schema: {},\n guideline:\n 'Displays the selling price formatted from the active storefront context; renders tax-inclusive when usePriceWithTaxes is enabled. Must be inside ProductListGrid.',\n});\n\nexport const ProductCardListPriceDefinition = defineComponent<ProductCardListPriceProps>({\n name: 'ProductCardListPrice',\n importPath: '@vtex/faststore/components',\n component: ProductCardListPrice,\n editor: { label: 'Product Card List Price', category: 'commerce' },\n schema: {},\n guideline:\n 'Displays the original (strikethrough) list price when it exceeds the selling price; renders tax-inclusive when usePriceWithTaxes is enabled. Must be inside ProductListGrid.',\n});\n\nexport const ProductCardTaxLabelDefinition = defineComponent<ProductCardTaxLabelProps>({\n name: 'ProductCardTaxLabel',\n importPath: '@vtex/faststore/components',\n component: ProductCardTaxLabel,\n editor: { label: 'Product Card Tax Label', category: 'commerce' },\n schema: {},\n guideline:\n 'Tax label (e.g. \"Tax included\") shown beside the price. Renders only when the ProductListRoot/ProductShelfRoot config usePriceWithTaxes is enabled (state-driven, no toggle); the text comes from the taxesLabel config. Compose it to place the label, omit it to hide it. Must be inside ProductListGrid / ProductShelfItems.',\n});\n\nexport const ProductCardDiscountDefinition = defineComponent<ProductCardDiscountProps>({\n name: 'ProductCardDiscount',\n importPath: '@vtex/faststore/components',\n component: ProductCardDiscount,\n editor: { label: 'Product Card Discount', category: 'commerce' },\n schema: {\n format: { type: ['percentage', 'absolute'] as const, default: 'percentage', label: 'Discount Format' },\n },\n guideline:\n 'Discount badge for the current product; auto-computes the markdown from listPrice vs price and renders only when a discount exists. Compose it to show the badge, omit it to hide it (no toggle). Must be inside ProductListGrid / ProductShelfItems.',\n});\n\nexport const ProductCardAddToCartDefinition = defineComponent<ProductCardAddToCartProps>({\n name: 'ProductCardAddToCart',\n importPath: '@vtex/faststore/components',\n component: ProductCardAddToCart,\n editor: { label: 'Product Card Add to Cart', category: 'commerce' },\n schema: {},\n actions: { cart: ['addItem'] },\n guideline: 'Add-to-cart button for the current product card; must be inside ProductListGrid.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\nexport function ProductListRoot({\n usePriceWithTaxes = false,\n taxesLabel = 'Tax included',\n products = [],\n className,\n children,\n ...props\n}: ProductListRootProps) {\n const config = useMemo(() => ({ usePriceWithTaxes, taxesLabel }), [usePriceWithTaxes, taxesLabel]);\n\n return (\n <ProductListConfigContext value={config}>\n <ProductListProductsContext value={products}>\n <Container {...props} className={className} data-fs-product-list-root=\"\">\n {children}\n </Container>\n </ProductListProductsContext>\n </ProductListConfigContext>\n );\n}\n\nexport function ProductListGrid({ className, children, ...props }: ProductListGridProps) {\n const products = useContext(ProductListProductsContext);\n\n return (\n <Container {...props} className={className} data-fs-product-list-grid=\"\">\n {products.map((product) => (\n <ProductListItemContext key={product.id} value={product}>\n {children}\n </ProductListItemContext>\n ))}\n </Container>\n );\n}\n\nexport function ProductCard({ className, children, bordered = true, ...props }: ProductCardProps) {\n const item = useProductListItem();\n const outOfStock = item.availableForSale === false || item.availableQuantity === 0;\n\n return (\n <Container\n {...props}\n className={className}\n data-fs-product-card=\"\"\n data-fs-product-card-bordered={String(bordered)}\n data-fs-product-card-out-of-stock={outOfStock ? '' : undefined}\n >\n {children}\n </Container>\n );\n}\n\nexport function ProductCardImage({ className, objectFit = 'cover', aspectRatio, ...props }: ProductCardImageProps) {\n const item = useProductListItem();\n\n return (\n <Image\n {...props}\n src={item.image.src}\n alt={item.image.alt}\n aspectRatio={aspectRatio}\n className={className}\n style={{ objectFit, ...props.style }}\n data-fs-product-card-image=\"\"\n />\n );\n}\n\nexport function ProductCardName({ className, children, ...props }: ProductCardNameProps) {\n const item = useProductListItem();\n\n return (\n <Text {...props} as=\"span\" className={className} data-fs-product-card-name=\"\">\n {children ?? item.name}\n </Text>\n );\n}\n\nexport function ProductCardPrice({ className, children, ...props }: ProductCardPriceProps) {\n const item = useProductListItem();\n const { usePriceWithTaxes } = useProductListConfig();\n const { locale, currency } = useStorefrontContext();\n const value = usePriceWithTaxes ? priceWithTaxes(item.price, item) : item.price;\n\n return (\n <Text {...props} as=\"span\" className={className} data-fs-product-card-price=\"\">\n {children ?? formatPrice(value, locale, item.currency ?? currency)}\n </Text>\n );\n}\n\nexport function ProductCardListPrice({ className, children, ...props }: ProductCardListPriceProps) {\n const item = useProductListItem();\n const { usePriceWithTaxes } = useProductListConfig();\n const { locale, currency } = useStorefrontContext();\n\n if (!item.listPrice || item.listPrice <= item.price) {\n return null;\n }\n\n const value = usePriceWithTaxes ? priceWithTaxes(item.listPrice, item) : item.listPrice;\n\n return (\n <Text {...props} as=\"span\" className={className} data-fs-product-card-list-price=\"\">\n {children ?? formatPrice(value, locale, item.currency ?? currency)}\n </Text>\n );\n}\n\nexport function ProductCardTaxLabel({ className, children, ...props }: ProductCardTaxLabelProps) {\n const { usePriceWithTaxes, taxesLabel } = useProductListConfig();\n\n if (!usePriceWithTaxes) {\n return null;\n }\n\n return (\n <Text {...props} as=\"span\" className={className} data-fs-product-card-tax-label=\"\">\n {children ?? taxesLabel}\n </Text>\n );\n}\n\nexport function ProductCardDiscount({\n className,\n children,\n format = 'percentage',\n ...props\n}: ProductCardDiscountProps) {\n const item = useProductListItem();\n const { usePriceWithTaxes } = useProductListConfig();\n const { locale, currency } = useStorefrontContext();\n\n const { listPrice, price } = item;\n if (!listPrice || listPrice <= price) {\n return null;\n }\n\n const amountOff = listPrice - price;\n const percentOff = Math.round((amountOff / listPrice) * 100);\n const tier = percentOff >= 30 ? 'high' : percentOff >= 15 ? 'medium' : 'low';\n // The percentage is tax-invariant (both prices scale by the same factor), but the absolute amount\n // must match the displayed prices, which are tax-inclusive when usePriceWithTaxes is enabled.\n const displayedAmountOff = usePriceWithTaxes ? priceWithTaxes(amountOff, item) : amountOff;\n const label =\n format === 'absolute'\n ? `-${formatPrice(displayedAmountOff, locale, item.currency ?? currency)}`\n : `-${percentOff}%`;\n\n return (\n <Badge {...props} className={className} data-fs-product-card-discount=\"\" data-fs-product-card-discount-tier={tier}>\n {children ?? label}\n </Badge>\n );\n}\n\nexport function ProductCardAddToCart({ className, children, onClick, $actions, ...props }: ProductCardAddToCartProps) {\n const item = useProductListItem();\n\n function handleClick(e: React.MouseEvent<HTMLButtonElement>) {\n void $actions?.cart?.addItem?.({ variantId: item.id, seller: '1' });\n onClick?.(e);\n }\n\n return (\n <Button {...props} className={className} onClick={handleClick} data-fs-product-card-add-to-cart=\"\">\n {children}\n </Button>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace export\n// ---------------------------------------------------------------------------\n\nexport const ProductList = {\n Root: ProductListRoot,\n Grid: ProductListGrid,\n Card: ProductCard,\n CardImage: ProductCardImage,\n CardName: ProductCardName,\n CardPrice: ProductCardPrice,\n CardListPrice: ProductCardListPrice,\n CardTaxLabel: ProductCardTaxLabel,\n CardDiscount: ProductCardDiscount,\n CardAddToCart: ProductCardAddToCart,\n};\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAa,2BAA2B,cAAiC;CACvE,mBAAmB;CACnB,YAAY;AACd,CAAC;AAED,SAAS,uBAA0C;CACjD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ACwB;CAC3B,MAAM,OAAO,mBAAmB;CAChC,MAAM,EAAE,sBAAsB,qBAAqB;CACnD,MAAM,EAAE,QAAQ,aAAa,qBAAqB;CAElD,MAAM,EAAE,WAAW,UAAU;CAC7B,IAAI,CAAC,aAAa,aAAa,OAC7B,OAAO;CAGT,MAAM,YAAY,YAAY;CAC9B,MAAM,aAAa,KAAK,MAAO,YAAY,YAAa,GAAG;CAC3D,MAAM,OAAO,cAAc,KAAK,SAAS,cAAc,KAAK,WAAW;CAGvE,MAAM,qBAAqB,oBAAoB,eAAe,WAAW,IAAI,IAAI;CACjF,MAAM,QACJ,WAAW,aACP,IAAI,YAAY,oBAAoB,QAAQ,KAAK,YAAY,QAAQ,MACrE,IAAI,WAAW;CAErB,OACE,oBAAC,OAAD;EAAO,GAAI;EAAkB;EAAW,iCAA8B;EAAG,sCAAoC;EAC1G,UAAA,YAAY;CACR,CAAA;AAEX;AAEA,SAAgB,qBAAqB,EAAE,WAAW,UAAU,SAAS,UAAU,GAAG,SAAoC;CACpH,MAAM,OAAO,mBAAmB;CAEhC,SAAS,YAAY,GAAwC;EAC3D,UAAe,MAAM,UAAU;GAAE,WAAW,KAAK;GAAI,QAAQ;EAAI,CAAC;EAClE,UAAU,CAAC;CACb;CAEA,OACE,oBAAC,QAAD;EAAQ,GAAI;EAAkB;EAAW,SAAS;EAAa,oCAAiC;EAC7F;CACK,CAAA;AAEZ;AAMA,MAAa,cAAc;CACzB,MAAM;CACN,MAAM;CACN,MAAM;CACN,WAAW;CACX,UAAU;CACV,WAAW;CACX,eAAe;CACf,cAAc;CACd,cAAc;CACd,eAAe;AACjB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ComponentDefinition } from "../../core/dist/define-component.js";
|
|
2
|
+
import "../../core/dist/index.js";
|
|
3
|
+
import { QuantitySelectorMessage, QuantitySelectorRootProps } from "../../particles/quantity-selector/quantity-selector.js";
|
|
4
|
+
import { ReactNode } from "react";
|
|
5
|
+
//#region src/matter/product-quantity/product-quantity.d.ts
|
|
6
|
+
type RawProductQuantityData = {
|
|
7
|
+
id: string;
|
|
8
|
+
variants: {
|
|
9
|
+
edges: Array<{
|
|
10
|
+
node: {
|
|
11
|
+
id: string;
|
|
12
|
+
sellers: Array<{
|
|
13
|
+
id: string;
|
|
14
|
+
isDefault: boolean;
|
|
15
|
+
offer: {
|
|
16
|
+
availableQuantity: number;
|
|
17
|
+
} | null;
|
|
18
|
+
}>;
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
type ProductQuantityContextValue = {
|
|
24
|
+
quantity: number;
|
|
25
|
+
setQuantity: (quantity: number | null) => void;
|
|
26
|
+
/** Available stock of the selected seller, or null when unknown. Drives the selector `max`. */
|
|
27
|
+
max: number | null;
|
|
28
|
+
};
|
|
29
|
+
export type ProductQuantityRootProps = Readonly<{
|
|
30
|
+
$data?: RawProductQuantityData | null;
|
|
31
|
+
defaultValue?: number;
|
|
32
|
+
children?: ReactNode;
|
|
33
|
+
}>;
|
|
34
|
+
export type ProductQuantitySelectorProps = Readonly<Omit<QuantitySelectorRootProps, 'value' | 'defaultValue' | 'onQuantityChange' | 'min' | 'max'>>;
|
|
35
|
+
export declare function useProductQuantity(): ProductQuantityContextValue;
|
|
36
|
+
export declare const ProductQuantityRootDefinition: ComponentDefinition<Readonly<{
|
|
37
|
+
$data?: RawProductQuantityData | null;
|
|
38
|
+
defaultValue?: number;
|
|
39
|
+
children?: ReactNode;
|
|
40
|
+
}>>;
|
|
41
|
+
export declare const ProductQuantitySelectorDefinition: ComponentDefinition<Readonly<Omit<QuantitySelectorRootProps, "defaultValue" | "value" | "max" | "min" | "onQuantityChange">>>;
|
|
42
|
+
export declare function ProductQuantityRoot({ $data, defaultValue, children }: ProductQuantityRootProps): import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
export declare function ProductQuantitySelector({ children, ...props }: ProductQuantitySelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export declare const ProductQuantity: {
|
|
45
|
+
Root: typeof ProductQuantityRoot;
|
|
46
|
+
Selector: typeof ProductQuantitySelector;
|
|
47
|
+
Message: typeof QuantitySelectorMessage;
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
//# sourceMappingURL=product-quantity.d.ts.map
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { defineComponent } from "../../core/dist/define-component.js";
|
|
3
|
+
import "../../core/dist/index.js";
|
|
4
|
+
import { QuantitySelectorMessage, QuantitySelectorRoot } from "../../particles/quantity-selector/quantity-selector.js";
|
|
5
|
+
import { createContext, useCallback, useContext, useMemo, useState } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
//#region src/matter/product-quantity/product-quantity.tsx
|
|
8
|
+
const fragment = `
|
|
9
|
+
fragment ProductQuantityData on Query {
|
|
10
|
+
productBySlug(slug: $slug) {
|
|
11
|
+
id
|
|
12
|
+
variants(first: 1) {
|
|
13
|
+
edges {
|
|
14
|
+
node {
|
|
15
|
+
id
|
|
16
|
+
sellers {
|
|
17
|
+
id
|
|
18
|
+
isDefault
|
|
19
|
+
offer {
|
|
20
|
+
availableQuantity
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
const DEFAULT_QUANTITY = 1;
|
|
30
|
+
const ProductQuantityContext = createContext({
|
|
31
|
+
quantity: DEFAULT_QUANTITY,
|
|
32
|
+
setQuantity: () => {},
|
|
33
|
+
max: null
|
|
34
|
+
});
|
|
35
|
+
function useProductQuantity() {
|
|
36
|
+
return useContext(ProductQuantityContext);
|
|
37
|
+
}
|
|
38
|
+
function transformProductQuantityMax(data) {
|
|
39
|
+
const variant = data.variants.edges[0]?.node;
|
|
40
|
+
if (!variant) return null;
|
|
41
|
+
return (variant.sellers.find((s) => s.isDefault) ?? variant.sellers[0])?.offer?.availableQuantity ?? null;
|
|
42
|
+
}
|
|
43
|
+
const ProductQuantityRootDefinition = defineComponent({
|
|
44
|
+
name: "ProductQuantityRoot",
|
|
45
|
+
importPath: "@vtex/faststore/components",
|
|
46
|
+
component: ProductQuantityRoot,
|
|
47
|
+
fragment,
|
|
48
|
+
editor: {
|
|
49
|
+
label: "Product Quantity",
|
|
50
|
+
category: "commerce"
|
|
51
|
+
},
|
|
52
|
+
schema: { defaultValue: {
|
|
53
|
+
type: "number",
|
|
54
|
+
default: 1,
|
|
55
|
+
label: "Default Quantity"
|
|
56
|
+
} },
|
|
57
|
+
providesContext: "product-quantity",
|
|
58
|
+
guideline: "Headless purchase-quantity boundary for a PDP: holds the selected quantity and exposes the selected seller stock as `max`. Renders no DOM, so place it as high as a single product scope allows (e.g. the PDP page root); BuyButton and ProductQuantitySelector may live in different layout blocks anywhere in its subtree. One provider per product. See product-quantity.md."
|
|
59
|
+
});
|
|
60
|
+
const ProductQuantitySelectorDefinition = defineComponent({
|
|
61
|
+
name: "ProductQuantitySelector",
|
|
62
|
+
importPath: "@vtex/faststore/components",
|
|
63
|
+
component: ProductQuantitySelector,
|
|
64
|
+
editor: {
|
|
65
|
+
label: "Product Quantity Selector",
|
|
66
|
+
category: "commerce"
|
|
67
|
+
},
|
|
68
|
+
schema: {},
|
|
69
|
+
requiresContext: "product-quantity",
|
|
70
|
+
guideline: "Quantity selector bound to ProductQuantityRoot context. Renders the generic QuantitySelectorRoot wired to the shared quantity state and seller stock (max). Compose as: ProductQuantitySelector > NumberFieldGroup > NumberFieldDecrement + NumberFieldInput + NumberFieldIncrement."
|
|
71
|
+
});
|
|
72
|
+
function ProductQuantityRoot({ $data, defaultValue = DEFAULT_QUANTITY, children }) {
|
|
73
|
+
const max = $data ? transformProductQuantityMax($data) : null;
|
|
74
|
+
const [quantity, setQuantity] = useState(defaultValue);
|
|
75
|
+
const updateQuantity = useCallback((next) => {
|
|
76
|
+
if (next != null) setQuantity(next);
|
|
77
|
+
}, []);
|
|
78
|
+
const value = useMemo(() => ({
|
|
79
|
+
quantity,
|
|
80
|
+
setQuantity: updateQuantity,
|
|
81
|
+
max
|
|
82
|
+
}), [
|
|
83
|
+
quantity,
|
|
84
|
+
updateQuantity,
|
|
85
|
+
max
|
|
86
|
+
]);
|
|
87
|
+
return /* @__PURE__ */ jsx(ProductQuantityContext, {
|
|
88
|
+
value,
|
|
89
|
+
children
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function ProductQuantitySelector({ children, ...props }) {
|
|
93
|
+
const { quantity, setQuantity, max } = useProductQuantity();
|
|
94
|
+
return /* @__PURE__ */ jsx(QuantitySelectorRoot, {
|
|
95
|
+
...props,
|
|
96
|
+
value: quantity,
|
|
97
|
+
onQuantityChange: setQuantity,
|
|
98
|
+
min: 1,
|
|
99
|
+
max: max ?? void 0,
|
|
100
|
+
children
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
const ProductQuantity = {
|
|
104
|
+
Root: ProductQuantityRoot,
|
|
105
|
+
Selector: ProductQuantitySelector,
|
|
106
|
+
Message: QuantitySelectorMessage
|
|
107
|
+
};
|
|
108
|
+
//#endregion
|
|
109
|
+
export { ProductQuantity, ProductQuantityRoot, ProductQuantityRootDefinition, ProductQuantitySelector, ProductQuantitySelectorDefinition, useProductQuantity };
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=product-quantity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-quantity.js","names":[],"sources":["../../../src/matter/product-quantity/product-quantity.tsx"],"sourcesContent":["'use client';\n\nimport { defineComponent } from '@vtex/fs-core';\nimport type { ReactNode } from 'react';\nimport { createContext, useCallback, useContext, useMemo, useState } from 'react';\nimport {\n QuantitySelectorMessage,\n QuantitySelectorRoot,\n type QuantitySelectorRootProps,\n} from '../../particles/quantity-selector/quantity-selector.js';\n\n// ---------------------------------------------------------------------------\n// GraphQL Fragment\n// ---------------------------------------------------------------------------\n\nconst fragment = /* GraphQL */ `\n fragment ProductQuantityData on Query {\n productBySlug(slug: $slug) {\n id\n variants(first: 1) {\n edges {\n node {\n id\n sellers {\n id\n isDefault\n offer {\n availableQuantity\n }\n }\n }\n }\n }\n }\n }\n`;\n\n// ---------------------------------------------------------------------------\n// Raw data types (shape of the fragment result)\n// ---------------------------------------------------------------------------\n\ntype RawProductQuantityData = {\n id: string;\n variants: {\n edges: Array<{\n node: {\n id: string;\n sellers: Array<{\n id: string;\n isDefault: boolean;\n offer: {\n availableQuantity: number;\n } | null;\n }>;\n };\n }>;\n };\n};\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ntype ProductQuantityContextValue = {\n quantity: number;\n setQuantity: (quantity: number | null) => void;\n /** Available stock of the selected seller, or null when unknown. Drives the selector `max`. */\n max: number | null;\n};\n\nconst DEFAULT_QUANTITY = 1;\n\nexport type ProductQuantityRootProps = Readonly<{\n $data?: RawProductQuantityData | null;\n defaultValue?: number;\n children?: ReactNode;\n}>;\n\nexport type ProductQuantitySelectorProps = Readonly<\n Omit<QuantitySelectorRootProps, 'value' | 'defaultValue' | 'onQuantityChange' | 'min' | 'max'>\n>;\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\n// Seeded with a safe default so the context never throws: a BuyButton rendered without a\n// ProductQuantityRoot ancestor (e.g. reused standalone) still works and adds quantity 1.\nconst ProductQuantityContext = createContext<ProductQuantityContextValue>({\n quantity: DEFAULT_QUANTITY,\n setQuantity: () => {},\n max: null,\n});\n\nexport function useProductQuantity(): ProductQuantityContextValue {\n return useContext(ProductQuantityContext);\n}\n\n// ---------------------------------------------------------------------------\n// Transform\n// ---------------------------------------------------------------------------\n\n// Mirrors BuyButton's seller-selection rule so `max` reflects the stock of the seller the\n// BuyButton actually adds to (default seller, else first).\nfunction transformProductQuantityMax(data: RawProductQuantityData): number | null {\n const variant = data.variants.edges[0]?.node;\n if (!variant) return null;\n\n const seller = variant.sellers.find((s) => s.isDefault) ?? variant.sellers[0];\n return seller?.offer?.availableQuantity ?? null;\n}\n\n// ---------------------------------------------------------------------------\n// Definitions\n// ---------------------------------------------------------------------------\n\nexport const ProductQuantityRootDefinition = defineComponent<ProductQuantityRootProps>({\n name: 'ProductQuantityRoot',\n importPath: '@vtex/faststore/components',\n component: ProductQuantityRoot,\n fragment,\n editor: { label: 'Product Quantity', category: 'commerce' },\n schema: {\n defaultValue: { type: 'number', default: 1, label: 'Default Quantity' },\n },\n providesContext: 'product-quantity',\n guideline:\n 'Headless purchase-quantity boundary for a PDP: holds the selected quantity and exposes the selected seller stock as `max`. Renders no DOM, so place it as high as a single product scope allows (e.g. the PDP page root); BuyButton and ProductQuantitySelector may live in different layout blocks anywhere in its subtree. One provider per product. See product-quantity.md.',\n});\n\nexport const ProductQuantitySelectorDefinition = defineComponent<ProductQuantitySelectorProps>({\n name: 'ProductQuantitySelector',\n importPath: '@vtex/faststore/components',\n component: ProductQuantitySelector,\n editor: { label: 'Product Quantity Selector', category: 'commerce' },\n schema: {},\n requiresContext: 'product-quantity',\n guideline:\n 'Quantity selector bound to ProductQuantityRoot context. Renders the generic QuantitySelectorRoot wired to the shared quantity state and seller stock (max). Compose as: ProductQuantitySelector > NumberFieldGroup > NumberFieldDecrement + NumberFieldInput + NumberFieldIncrement.',\n});\n\n// ---------------------------------------------------------------------------\n// Implementations\n// ---------------------------------------------------------------------------\n\nexport function ProductQuantityRoot({ $data, defaultValue = DEFAULT_QUANTITY, children }: ProductQuantityRootProps) {\n const max = $data ? transformProductQuantityMax($data) : null;\n const [quantity, setQuantity] = useState<number>(defaultValue);\n\n // The Base UI NumberField emits null while the input is empty; keep the last valid value so the\n // quantity sent to the cart is always a positive integer (clamped to [1, max] by the field).\n const updateQuantity = useCallback((next: number | null) => {\n if (next != null) setQuantity(next);\n }, []);\n\n const value = useMemo<ProductQuantityContextValue>(\n () => ({ quantity, setQuantity: updateQuantity, max }),\n [quantity, updateQuantity, max],\n );\n\n return <ProductQuantityContext value={value}>{children}</ProductQuantityContext>;\n}\n\nexport function ProductQuantitySelector({ children, ...props }: ProductQuantitySelectorProps) {\n const { quantity, setQuantity, max } = useProductQuantity();\n\n return (\n <QuantitySelectorRoot {...props} value={quantity} onQuantityChange={setQuantity} min={1} max={max ?? undefined}>\n {children}\n </QuantitySelectorRoot>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Namespace export\n// ---------------------------------------------------------------------------\n\nexport const ProductQuantity = {\n Root: ProductQuantityRoot,\n Selector: ProductQuantitySelector,\n // Thin alias of the particle part: reads the QuantitySelectorRoot context the Selector renders.\n Message: QuantitySelectorMessage,\n};\n"],"mappings":";;;;;;;AAeA,MAAM,WAAyB;;;;;;;;;;;;;;;;;;;;;AAuD/B,MAAM,mBAAmB;AAkBzB,MAAM,yBAAyB,cAA2C;CACxE,UAAU;CACV,mBAAmB,CAAC;CACpB,KAAK;AACP,CAAC;AAED,SAAgB,qBAAkD;CAChE,OAAO,WAAW,sBAAsB;AAC1C;AAQA,SAAS,4BAA4B,MAA6C;CAChF,MAAM,UAAU,KAAK,SAAS,MAAM,EAAE,EAAE;CACxC,IAAI,CAAC,SAAS,OAAO;CAGrB,QADe,QAAQ,QAAQ,MAAM,MAAM,EAAE,SAAS,KAAK,QAAQ,QAAQ,GAAA,EAC5D,OAAO,qBAAqB;AAC7C;AAMA,MAAa,gCAAgC,gBAA0C;CACrF,MAAM;CACN,YAAY;CACZ,WAAW;CACX;CACA,QAAQ;EAAE,OAAO;EAAoB,UAAU;CAAW;CAC1D,QAAQ,EACN,cAAc;EAAE,MAAM;EAAU,SAAS;EAAG,OAAO;CAAmB,EACxE;CACA,iBAAiB;CACjB,WACE;AACJ,CAAC;AAED,MAAa,oCAAoC,gBAA8C;CAC7F,MAAM;CACN,YAAY;CACZ,WAAW;CACX,QAAQ;EAAE,OAAO;EAA6B,UAAU;CAAW;CACnE,QAAQ,CAAC;CACT,iBAAiB;CACjB,WACE;AACJ,CAAC;AAMD,SAA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