@fayz-ai/storefront 0.9.0 → 0.11.0
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/README.md +3 -3
- package/dist/app/createStorefrontApp.d.ts +65 -0
- package/dist/app/createStorefrontApp.d.ts.map +1 -0
- package/dist/{define.d.ts → app/define.d.ts} +3 -3
- package/dist/app/define.d.ts.map +1 -0
- package/dist/app/hydration.d.ts +37 -0
- package/dist/app/hydration.d.ts.map +1 -0
- package/dist/app/prerender.d.ts +57 -0
- package/dist/app/prerender.d.ts.map +1 -0
- package/dist/{router.d.ts → app/router.d.ts} +140 -113
- package/dist/app/router.d.ts.map +1 -0
- package/dist/{scaffold.d.ts → app/scaffold.d.ts} +2 -2
- package/dist/app/scaffold.d.ts.map +1 -0
- package/dist/app/serving.d.ts +70 -0
- package/dist/app/serving.d.ts.map +1 -0
- package/dist/app/static-render.d.ts +46 -0
- package/dist/app/static-render.d.ts.map +1 -0
- package/dist/blocks/block-at-path.d.ts +59 -0
- package/dist/blocks/block-at-path.d.ts.map +1 -0
- package/dist/blocks/page-blocks.d.ts +163 -0
- package/dist/blocks/page-blocks.d.ts.map +1 -0
- package/dist/blocks/page-data.d.ts +105 -0
- package/dist/blocks/page-data.d.ts.map +1 -0
- package/dist/{blocks.d.ts → blocks/registry.d.ts} +1 -1
- package/dist/blocks/registry.d.ts.map +1 -0
- package/dist/{sections.d.ts → blocks/sections.d.ts} +40 -2
- package/dist/blocks/sections.d.ts.map +1 -0
- package/dist/chunk-6IXTENLB.js +162 -0
- package/dist/chunk-6IXTENLB.js.map +1 -0
- package/dist/chunk-SX3J3QIT.js +11046 -0
- package/dist/chunk-SX3J3QIT.js.map +1 -0
- package/dist/components/PaymentTerms.d.ts +34 -0
- package/dist/components/PaymentTerms.d.ts.map +1 -0
- package/dist/components/Skeleton.d.ts +17 -0
- package/dist/components/Skeleton.d.ts.map +1 -0
- package/dist/components/SmoothImage.d.ts +1 -1
- package/dist/components/SmoothImage.d.ts.map +1 -1
- package/dist/components/account/CustomerAccountShell.d.ts +17 -0
- package/dist/components/account/CustomerAccountShell.d.ts.map +1 -0
- package/dist/components/account/SignInModal.d.ts.map +1 -0
- package/dist/components/account/section.d.ts +15 -0
- package/dist/components/account/section.d.ts.map +1 -0
- package/dist/components/cart/CartDrawer.d.ts.map +1 -0
- package/dist/components/cart/QuantityInput.d.ts.map +1 -0
- package/dist/components/checkout/CheckoutPayment.d.ts +17 -0
- package/dist/components/checkout/CheckoutPayment.d.ts.map +1 -0
- package/dist/components/checkout/CheckoutSteps.d.ts +9 -0
- package/dist/components/checkout/CheckoutSteps.d.ts.map +1 -0
- package/dist/components/checkout/DeliveryEstimator.d.ts.map +1 -0
- package/dist/components/collection/CategoryShowcase.d.ts +44 -0
- package/dist/components/collection/CategoryShowcase.d.ts.map +1 -0
- package/dist/components/collection/FiltersPanel.d.ts +19 -0
- package/dist/components/collection/FiltersPanel.d.ts.map +1 -0
- package/dist/components/collection/ProductGrid.d.ts.map +1 -0
- package/dist/components/layout/PageBodyBlocks.d.ts +40 -0
- package/dist/components/layout/PageBodyBlocks.d.ts.map +1 -0
- package/dist/components/layout/SearchOverlay.d.ts +13 -0
- package/dist/components/layout/SearchOverlay.d.ts.map +1 -0
- package/dist/components/layout/StorefrontErrorBoundary.d.ts.map +1 -0
- package/dist/components/layout/StorefrontFooter.d.ts.map +1 -0
- package/dist/components/layout/StorefrontHeader.d.ts.map +1 -0
- package/dist/components/layout/Toaster.d.ts.map +1 -0
- package/dist/components/marketing/CollectionSections.d.ts +463 -0
- package/dist/components/marketing/CollectionSections.d.ts.map +1 -0
- package/dist/components/marketing/ConversionSections.d.ts +221 -0
- package/dist/components/marketing/ConversionSections.d.ts.map +1 -0
- package/dist/components/marketing/EditorialSections.d.ts +248 -0
- package/dist/components/marketing/EditorialSections.d.ts.map +1 -0
- package/dist/components/marketing/EntityList.d.ts +97 -0
- package/dist/components/marketing/EntityList.d.ts.map +1 -0
- package/dist/components/marketing/FormBlock.d.ts +167 -0
- package/dist/components/marketing/FormBlock.d.ts.map +1 -0
- package/dist/components/marketing/HeroSection.d.ts +125 -0
- package/dist/components/marketing/HeroSection.d.ts.map +1 -0
- package/dist/components/marketing/MediaCarousel.d.ts +135 -0
- package/dist/components/marketing/MediaCarousel.d.ts.map +1 -0
- package/dist/components/marketing/MiscSections.d.ts +252 -0
- package/dist/components/marketing/MiscSections.d.ts.map +1 -0
- package/dist/components/order/OrderTrackingTimeline.d.ts.map +1 -0
- package/dist/components/order/SuccessMark.d.ts +10 -0
- package/dist/components/order/SuccessMark.d.ts.map +1 -0
- package/dist/components/product/ProductCard.d.ts +14 -0
- package/dist/components/product/ProductCard.d.ts.map +1 -0
- package/dist/components/product/ProductEnquiryForm.d.ts.map +1 -0
- package/dist/components/product/ProductGallery.d.ts +36 -0
- package/dist/components/product/ProductGallery.d.ts.map +1 -0
- package/dist/components/{ProductOptionSelector.d.ts → product/ProductOptionSelector.d.ts} +1 -1
- package/dist/components/product/ProductOptionSelector.d.ts.map +1 -0
- package/dist/components/product/ProductRail.d.ts +93 -0
- package/dist/components/product/ProductRail.d.ts.map +1 -0
- package/dist/components/product/ProductReviews.d.ts +39 -0
- package/dist/components/product/ProductReviews.d.ts.map +1 -0
- package/dist/components/product/ProductSlider.d.ts +169 -0
- package/dist/components/product/ProductSlider.d.ts.map +1 -0
- package/dist/components/product/ProductSpecs.d.ts.map +1 -0
- package/dist/components/product/RelatedProducts.d.ts.map +1 -0
- package/dist/{auth.d.ts → data/auth.d.ts} +9 -0
- package/dist/data/auth.d.ts.map +1 -0
- package/dist/data/facets.d.ts +39 -0
- package/dist/data/facets.d.ts.map +1 -0
- package/dist/data/loaders.d.ts +52 -0
- package/dist/data/loaders.d.ts.map +1 -0
- package/dist/data/local-orders.d.ts +5 -0
- package/dist/data/local-orders.d.ts.map +1 -0
- package/dist/data/order-status.d.ts.map +1 -0
- package/dist/data/product-options.d.ts +36 -0
- package/dist/data/product-options.d.ts.map +1 -0
- package/dist/data/shipping-items.d.ts +20 -0
- package/dist/data/shipping-items.d.ts.map +1 -0
- package/dist/diagnostics/seo-audit.d.ts +54 -0
- package/dist/diagnostics/seo-audit.d.ts.map +1 -0
- package/dist/diagnostics/seo-audit.js +3 -0
- package/dist/diagnostics/seo-audit.js.map +1 -0
- package/dist/document/change.d.ts +100 -0
- package/dist/document/change.d.ts.map +1 -0
- package/dist/document/config.d.ts +311 -0
- package/dist/document/config.d.ts.map +1 -0
- package/dist/document/describe.d.ts +135 -0
- package/dist/document/describe.d.ts.map +1 -0
- package/dist/document/overlay.d.ts +58 -0
- package/dist/document/overlay.d.ts.map +1 -0
- package/dist/{presets.d.ts → document/presets.d.ts} +2 -2
- package/dist/document/presets.d.ts.map +1 -0
- package/dist/document/render.d.ts +171 -0
- package/dist/document/render.d.ts.map +1 -0
- package/dist/document/round-trip.d.ts +46 -0
- package/dist/document/round-trip.d.ts.map +1 -0
- package/dist/document/sections.d.ts +194 -0
- package/dist/document/sections.d.ts.map +1 -0
- package/dist/document/store-policy.d.ts +29 -0
- package/dist/document/store-policy.d.ts.map +1 -0
- package/dist/document/upgrade.d.ts +112 -0
- package/dist/document/upgrade.d.ts.map +1 -0
- package/dist/document/validate.d.ts +24 -0
- package/dist/document/validate.d.ts.map +1 -0
- package/dist/{component-contracts.d.ts → extend/component-contracts.d.ts} +74 -22
- package/dist/extend/component-contracts.d.ts.map +1 -0
- package/dist/extend/component-override.d.ts +38 -0
- package/dist/extend/component-override.d.ts.map +1 -0
- package/dist/extend/component-selectors.d.ts.map +1 -0
- package/dist/extend/editor-bridge.d.ts +59 -0
- package/dist/extend/editor-bridge.d.ts.map +1 -0
- package/dist/extend/extension-points.d.ts +103 -0
- package/dist/extend/extension-points.d.ts.map +1 -0
- package/dist/extend/slots.d.ts +216 -0
- package/dist/extend/slots.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +25 -6
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/use-address.d.ts +26 -0
- package/dist/hooks/use-address.d.ts.map +1 -0
- package/dist/hooks/use-cart.d.ts +3 -0
- package/dist/hooks/use-cart.d.ts.map +1 -0
- package/dist/hooks/use-catalog.d.ts +24 -0
- package/dist/hooks/use-catalog.d.ts.map +1 -0
- package/dist/hooks/use-categories.d.ts +19 -0
- package/dist/hooks/use-categories.d.ts.map +1 -0
- package/dist/hooks/use-checkout.d.ts +41 -0
- package/dist/hooks/use-checkout.d.ts.map +1 -0
- package/dist/hooks/use-discount-validator.d.ts +20 -0
- package/dist/hooks/use-discount-validator.d.ts.map +1 -0
- package/dist/hooks/use-enquiry.d.ts +7 -0
- package/dist/hooks/use-enquiry.d.ts.map +1 -0
- package/dist/hooks/{useMyOrders.d.ts → use-my-orders.d.ts} +1 -1
- package/dist/hooks/use-my-orders.d.ts.map +1 -0
- package/dist/hooks/use-order.d.ts +17 -0
- package/dist/hooks/use-order.d.ts.map +1 -0
- package/dist/hooks/use-payment-methods.d.ts +19 -0
- package/dist/hooks/use-payment-methods.d.ts.map +1 -0
- package/dist/hooks/use-policies.d.ts +25 -0
- package/dist/hooks/use-policies.d.ts.map +1 -0
- package/dist/hooks/use-product.d.ts +15 -0
- package/dist/hooks/use-product.d.ts.map +1 -0
- package/dist/hooks/{useProducts.d.ts → use-products.d.ts} +1 -1
- package/dist/hooks/use-products.d.ts.map +1 -0
- package/dist/hooks/use-region.d.ts +15 -0
- package/dist/hooks/use-region.d.ts.map +1 -0
- package/dist/hooks/use-shipping.d.ts +32 -0
- package/dist/hooks/use-shipping.d.ts.map +1 -0
- package/dist/hooks/use-storefront-actions.d.ts +12 -0
- package/dist/hooks/use-storefront-actions.d.ts.map +1 -0
- package/dist/hooks/use-storefront-head.d.ts +19 -0
- package/dist/hooks/use-storefront-head.d.ts.map +1 -0
- package/dist/hooks/use-storefront.d.ts +3 -0
- package/dist/hooks/use-storefront.d.ts.map +1 -0
- package/dist/index.d.ts +124 -54
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1310 -5010
- package/dist/index.js.map +1 -1
- package/dist/lib/errors.d.ts +9 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/format.d.ts.map +1 -0
- package/dist/lib/motion.d.ts.map +1 -0
- package/dist/lib/seo.d.ts +26 -0
- package/dist/lib/seo.d.ts.map +1 -0
- package/dist/{testids.d.ts → lib/testids.d.ts} +33 -0
- package/dist/lib/testids.d.ts.map +1 -0
- package/dist/{theme.d.ts → lib/theme.d.ts} +41 -3
- package/dist/lib/theme.d.ts.map +1 -0
- package/dist/render.d.ts +5 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +359 -0
- package/dist/render.js.map +1 -0
- package/dist/stores/cart.store.d.ts +34 -2
- package/dist/stores/cart.store.d.ts.map +1 -1
- package/dist/stores/catalog.store.d.ts +11 -0
- package/dist/stores/catalog.store.d.ts.map +1 -1
- package/dist/stores/delivery.store.d.ts +9 -0
- package/dist/stores/delivery.store.d.ts.map +1 -1
- package/dist/views/CatalogPage.d.ts.map +1 -0
- package/dist/views/CheckoutPage.d.ts.map +1 -0
- package/dist/views/ContentPage.d.ts +11 -0
- package/dist/views/ContentPage.d.ts.map +1 -0
- package/dist/views/HomePage.d.ts +9 -0
- package/dist/views/HomePage.d.ts.map +1 -0
- package/dist/views/MyPurchasesPage.d.ts.map +1 -0
- package/dist/views/NotFoundPage.d.ts.map +1 -0
- package/dist/views/OrderConfirmationPage.d.ts.map +1 -0
- package/dist/{pages → views}/PolicyPage.d.ts.map +1 -1
- package/dist/views/ProductDetailPage.d.ts.map +1 -0
- package/dist/views/StorefrontPage.d.ts +35 -0
- package/dist/views/StorefrontPage.d.ts.map +1 -0
- package/dist/workflows/checkout.d.ts +1 -1
- package/dist/workflows/checkout.d.ts.map +1 -1
- package/package.json +21 -14
- package/dist/auth.d.ts.map +0 -1
- package/dist/blocks.d.ts.map +0 -1
- package/dist/component-contracts.d.ts.map +0 -1
- package/dist/component-selectors.d.ts.map +0 -1
- package/dist/components/CartDrawer.d.ts.map +0 -1
- package/dist/components/CustomerAccountShell.d.ts +0 -13
- package/dist/components/CustomerAccountShell.d.ts.map +0 -1
- package/dist/components/DeliveryEstimator.d.ts.map +0 -1
- package/dist/components/FiltersPanel.d.ts +0 -3
- package/dist/components/FiltersPanel.d.ts.map +0 -1
- package/dist/components/OrderTrackingTimeline.d.ts.map +0 -1
- package/dist/components/ProductCard.d.ts +0 -4
- package/dist/components/ProductCard.d.ts.map +0 -1
- package/dist/components/ProductEnquiryForm.d.ts.map +0 -1
- package/dist/components/ProductGallery.d.ts +0 -22
- package/dist/components/ProductGallery.d.ts.map +0 -1
- package/dist/components/ProductGrid.d.ts.map +0 -1
- package/dist/components/ProductOptionSelector.d.ts.map +0 -1
- package/dist/components/ProductSpecs.d.ts.map +0 -1
- package/dist/components/QuantityInput.d.ts.map +0 -1
- package/dist/components/RelatedProducts.d.ts.map +0 -1
- package/dist/components/SignInModal.d.ts.map +0 -1
- package/dist/components/StorefrontErrorBoundary.d.ts.map +0 -1
- package/dist/components/StorefrontFooter.d.ts.map +0 -1
- package/dist/components/StorefrontHeader.d.ts.map +0 -1
- package/dist/components/Toaster.d.ts.map +0 -1
- package/dist/components/sections/CategoryShowcase.d.ts +0 -6
- package/dist/components/sections/CategoryShowcase.d.ts.map +0 -1
- package/dist/components/sections/HeroSection.d.ts +0 -9
- package/dist/components/sections/HeroSection.d.ts.map +0 -1
- package/dist/components/sections/MediaCarousel.d.ts +0 -11
- package/dist/components/sections/MediaCarousel.d.ts.map +0 -1
- package/dist/components/sections/MiscSections.d.ts +0 -33
- package/dist/components/sections/MiscSections.d.ts.map +0 -1
- package/dist/components/sections/ProductRail.d.ts +0 -9
- package/dist/components/sections/ProductRail.d.ts.map +0 -1
- package/dist/components/sections/ProductSlider.d.ts +0 -15
- package/dist/components/sections/ProductSlider.d.ts.map +0 -1
- package/dist/config.d.ts +0 -174
- package/dist/config.d.ts.map +0 -1
- package/dist/createStorefrontApp.d.ts +0 -28
- package/dist/createStorefrontApp.d.ts.map +0 -1
- package/dist/define.d.ts.map +0 -1
- package/dist/format.d.ts.map +0 -1
- package/dist/hooks/useCategories.d.ts +0 -6
- package/dist/hooks/useCategories.d.ts.map +0 -1
- package/dist/hooks/useDiscountValidator.d.ts +0 -14
- package/dist/hooks/useDiscountValidator.d.ts.map +0 -1
- package/dist/hooks/useMyOrders.d.ts.map +0 -1
- package/dist/hooks/useProduct.d.ts +0 -7
- package/dist/hooks/useProduct.d.ts.map +0 -1
- package/dist/hooks/useProducts.d.ts.map +0 -1
- package/dist/hooks/useStorefront.d.ts +0 -35
- package/dist/hooks/useStorefront.d.ts.map +0 -1
- package/dist/hooks/useStorefrontHead.d.ts +0 -11
- package/dist/hooks/useStorefrontHead.d.ts.map +0 -1
- package/dist/motion.d.ts.map +0 -1
- package/dist/order-status.d.ts.map +0 -1
- package/dist/pages/CatalogPage.d.ts.map +0 -1
- package/dist/pages/CheckoutPage.d.ts.map +0 -1
- package/dist/pages/HomePage.d.ts +0 -9
- package/dist/pages/HomePage.d.ts.map +0 -1
- package/dist/pages/MyPurchasesPage.d.ts.map +0 -1
- package/dist/pages/NotFoundPage.d.ts.map +0 -1
- package/dist/pages/OrderConfirmationPage.d.ts.map +0 -1
- package/dist/pages/ProductDetailPage.d.ts.map +0 -1
- package/dist/presets.d.ts.map +0 -1
- package/dist/product-options.d.ts +0 -12
- package/dist/product-options.d.ts.map +0 -1
- package/dist/router.d.ts.map +0 -1
- package/dist/scaffold.d.ts.map +0 -1
- package/dist/sections.d.ts.map +0 -1
- package/dist/testids.d.ts.map +0 -1
- package/dist/theme.d.ts.map +0 -1
- package/src/auth.ts +0 -227
- package/src/blocks.tsx +0 -51
- package/src/catalog.ts +0 -3
- package/src/component-contracts.ts +0 -154
- package/src/component-selectors.ts +0 -31
- package/src/components/CartDrawer.tsx +0 -279
- package/src/components/CustomerAccountShell.tsx +0 -102
- package/src/components/DeliveryEstimator.tsx +0 -157
- package/src/components/FiltersPanel.tsx +0 -109
- package/src/components/OrderTrackingTimeline.tsx +0 -135
- package/src/components/Price.tsx +0 -32
- package/src/components/ProductCard.tsx +0 -120
- package/src/components/ProductEnquiryForm.tsx +0 -175
- package/src/components/ProductGallery.tsx +0 -174
- package/src/components/ProductGrid.tsx +0 -43
- package/src/components/ProductOptionSelector.tsx +0 -50
- package/src/components/ProductSpecs.tsx +0 -75
- package/src/components/QuantityInput.tsx +0 -52
- package/src/components/RelatedProducts.tsx +0 -40
- package/src/components/SignInModal.tsx +0 -120
- package/src/components/SmoothImage.tsx +0 -59
- package/src/components/StorefrontErrorBoundary.tsx +0 -51
- package/src/components/StorefrontFooter.tsx +0 -110
- package/src/components/StorefrontHeader.tsx +0 -477
- package/src/components/Toaster.tsx +0 -60
- package/src/components/sections/CategoryShowcase.tsx +0 -80
- package/src/components/sections/HeroSection.tsx +0 -193
- package/src/components/sections/MediaCarousel.tsx +0 -141
- package/src/components/sections/MiscSections.tsx +0 -158
- package/src/components/sections/ProductRail.tsx +0 -81
- package/src/components/sections/ProductSlider.tsx +0 -119
- package/src/config.ts +0 -229
- package/src/createStorefrontApp.tsx +0 -247
- package/src/define.ts +0 -34
- package/src/format.ts +0 -7
- package/src/hooks/index.ts +0 -6
- package/src/hooks/useCategories.ts +0 -26
- package/src/hooks/useDiscountValidator.ts +0 -43
- package/src/hooks/useMyOrders.ts +0 -41
- package/src/hooks/useProduct.ts +0 -36
- package/src/hooks/useProducts.ts +0 -39
- package/src/hooks/useStorefront.ts +0 -58
- package/src/hooks/useStorefrontHead.ts +0 -25
- package/src/index.ts +0 -202
- package/src/motion.tsx +0 -94
- package/src/order-status.ts +0 -33
- package/src/pages/CatalogPage.tsx +0 -118
- package/src/pages/CheckoutPage.tsx +0 -689
- package/src/pages/HomePage.tsx +0 -16
- package/src/pages/MyPurchasesPage.tsx +0 -311
- package/src/pages/NotFoundPage.tsx +0 -25
- package/src/pages/OrderConfirmationPage.tsx +0 -190
- package/src/pages/PolicyPage.tsx +0 -47
- package/src/pages/ProductDetailPage.tsx +0 -264
- package/src/presets.ts +0 -324
- package/src/product-options.ts +0 -63
- package/src/router.ts +0 -49
- package/src/scaffold.tsx +0 -115
- package/src/sections.ts +0 -116
- package/src/shop.ts +0 -4
- package/src/stores/cart.store.ts +0 -185
- package/src/stores/catalog.store.ts +0 -39
- package/src/stores/delivery.store.ts +0 -152
- package/src/stores/session.store.ts +0 -28
- package/src/stores/toast.store.ts +0 -43
- package/src/testids.ts +0 -136
- package/src/theme.ts +0 -194
- package/src/ui.ts +0 -5
- package/src/workflows/checkout.ts +0 -119
- /package/dist/components/{SignInModal.d.ts → account/SignInModal.d.ts} +0 -0
- /package/dist/components/{CartDrawer.d.ts → cart/CartDrawer.d.ts} +0 -0
- /package/dist/components/{QuantityInput.d.ts → cart/QuantityInput.d.ts} +0 -0
- /package/dist/components/{DeliveryEstimator.d.ts → checkout/DeliveryEstimator.d.ts} +0 -0
- /package/dist/components/{ProductGrid.d.ts → collection/ProductGrid.d.ts} +0 -0
- /package/dist/components/{StorefrontErrorBoundary.d.ts → layout/StorefrontErrorBoundary.d.ts} +0 -0
- /package/dist/components/{StorefrontFooter.d.ts → layout/StorefrontFooter.d.ts} +0 -0
- /package/dist/components/{StorefrontHeader.d.ts → layout/StorefrontHeader.d.ts} +0 -0
- /package/dist/components/{Toaster.d.ts → layout/Toaster.d.ts} +0 -0
- /package/dist/components/{OrderTrackingTimeline.d.ts → order/OrderTrackingTimeline.d.ts} +0 -0
- /package/dist/components/{ProductEnquiryForm.d.ts → product/ProductEnquiryForm.d.ts} +0 -0
- /package/dist/components/{ProductSpecs.d.ts → product/ProductSpecs.d.ts} +0 -0
- /package/dist/components/{RelatedProducts.d.ts → product/RelatedProducts.d.ts} +0 -0
- /package/dist/{order-status.d.ts → data/order-status.d.ts} +0 -0
- /package/dist/{component-selectors.d.ts → extend/component-selectors.d.ts} +0 -0
- /package/dist/{format.d.ts → lib/format.d.ts} +0 -0
- /package/dist/{motion.d.ts → lib/motion.d.ts} +0 -0
- /package/dist/{pages → views}/CatalogPage.d.ts +0 -0
- /package/dist/{pages → views}/CheckoutPage.d.ts +0 -0
- /package/dist/{pages → views}/MyPurchasesPage.d.ts +0 -0
- /package/dist/{pages → views}/NotFoundPage.d.ts +0 -0
- /package/dist/{pages → views}/OrderConfirmationPage.d.ts +0 -0
- /package/dist/{pages → views}/PolicyPage.d.ts +0 -0
- /package/dist/{pages → views}/ProductDetailPage.d.ts +0 -0
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import React, { useMemo, useRef } from 'react'
|
|
2
|
-
import { ChevronLeft, ChevronRight } from 'lucide-react'
|
|
3
|
-
import { getStorefrontComponents, useStorefrontConfig } from '../../config'
|
|
4
|
-
import { useProducts } from '../../hooks/useProducts'
|
|
5
|
-
import { useStorefrontActions } from '../../hooks/useStorefront'
|
|
6
|
-
import { ProductCard } from '../ProductCard'
|
|
7
|
-
import { Link } from '../../router'
|
|
8
|
-
import { TID } from '../../testids'
|
|
9
|
-
|
|
10
|
-
export interface ProductSliderProps {
|
|
11
|
-
title: string
|
|
12
|
-
subtitle?: string
|
|
13
|
-
eyebrow?: string
|
|
14
|
-
filter?: 'sale' | 'new' | 'all'
|
|
15
|
-
categoryName?: string
|
|
16
|
-
collection?: string
|
|
17
|
-
limit?: number
|
|
18
|
-
cta?: string
|
|
19
|
-
href?: string
|
|
20
|
-
className?: string
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function ProductSlider({
|
|
24
|
-
title,
|
|
25
|
-
subtitle,
|
|
26
|
-
eyebrow,
|
|
27
|
-
filter = 'all',
|
|
28
|
-
categoryName,
|
|
29
|
-
collection,
|
|
30
|
-
limit = 10,
|
|
31
|
-
cta = 'View all',
|
|
32
|
-
href,
|
|
33
|
-
className = '',
|
|
34
|
-
}: ProductSliderProps) {
|
|
35
|
-
const config = useStorefrontConfig()
|
|
36
|
-
const actions = useStorefrontActions()
|
|
37
|
-
const viewportRef = useRef<HTMLDivElement>(null)
|
|
38
|
-
const components = getStorefrontComponents(config)
|
|
39
|
-
const ProductCardComponent = components.ProductCard ?? ProductCard
|
|
40
|
-
const { products, loading } = useProducts(
|
|
41
|
-
filter === 'new'
|
|
42
|
-
? { status: 'active', orderBy: 'created_at', order: 'desc' }
|
|
43
|
-
: { status: 'active' },
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
const visible = useMemo(() => {
|
|
47
|
-
let list = products
|
|
48
|
-
if (filter === 'sale') list = list.filter((p) => p.compareAtPrice != null && p.compareAtPrice > p.price)
|
|
49
|
-
if (categoryName) list = list.filter((p) => p.categoryName === categoryName)
|
|
50
|
-
if (collection) list = list.filter((p) => p.metadata?.collection === collection)
|
|
51
|
-
return list.slice(0, limit)
|
|
52
|
-
}, [categoryName, collection, filter, limit, products])
|
|
53
|
-
|
|
54
|
-
const scroll = (direction: -1 | 1) => {
|
|
55
|
-
viewportRef.current?.scrollBy({ left: direction * Math.max(320, viewportRef.current.clientWidth * 0.75), behavior: 'smooth' })
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (!loading && visible.length === 0) return null
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<section data-testid={TID.productSlider} className={`mx-auto max-w-7xl px-4 py-14 sm:px-6 ${className}`}>
|
|
62
|
-
<div className="mb-8 flex flex-col gap-5 sm:flex-row sm:items-end sm:justify-between">
|
|
63
|
-
<div className="max-w-2xl">
|
|
64
|
-
{eyebrow && <p className="mb-2 text-xs font-semibold uppercase tracking-[0.2em] text-primary">{eyebrow}</p>}
|
|
65
|
-
<h2 className="sf-heading text-3xl font-normal leading-tight tracking-normal sm:text-5xl">{title}</h2>
|
|
66
|
-
{subtitle && <p className="mt-3 leading-7 text-muted-foreground">{subtitle}</p>}
|
|
67
|
-
</div>
|
|
68
|
-
<div className="flex items-center gap-2">
|
|
69
|
-
<button
|
|
70
|
-
type="button"
|
|
71
|
-
aria-label="Previous products"
|
|
72
|
-
data-testid={TID.productSliderPrev}
|
|
73
|
-
onClick={() => scroll(-1)}
|
|
74
|
-
className="inline-flex h-10 w-10 items-center justify-center border border-border bg-background transition hover:bg-foreground hover:text-background"
|
|
75
|
-
>
|
|
76
|
-
<ChevronLeft className="h-5 w-5" />
|
|
77
|
-
</button>
|
|
78
|
-
<button
|
|
79
|
-
type="button"
|
|
80
|
-
aria-label="Next products"
|
|
81
|
-
data-testid={TID.productSliderNext}
|
|
82
|
-
onClick={() => scroll(1)}
|
|
83
|
-
className="inline-flex h-10 w-10 items-center justify-center border border-border bg-background transition hover:bg-foreground hover:text-background"
|
|
84
|
-
>
|
|
85
|
-
<ChevronRight className="h-5 w-5" />
|
|
86
|
-
</button>
|
|
87
|
-
</div>
|
|
88
|
-
</div>
|
|
89
|
-
<div
|
|
90
|
-
ref={viewportRef}
|
|
91
|
-
data-testid={TID.productSliderViewport}
|
|
92
|
-
className="flex snap-x gap-5 overflow-x-auto pb-5 [scrollbar-width:thin]"
|
|
93
|
-
>
|
|
94
|
-
{loading
|
|
95
|
-
? Array.from({ length: Math.min(limit, 6) }, (_, i) => (
|
|
96
|
-
<div key={i} className="h-[360px] min-w-[260px] snap-start animate-pulse bg-muted" />
|
|
97
|
-
))
|
|
98
|
-
: visible.map((product) => (
|
|
99
|
-
<div key={product.id} className="min-w-[260px] max-w-[300px] flex-[0_0_72vw] snap-start sm:flex-[0_0_300px]">
|
|
100
|
-
<ProductCardComponent
|
|
101
|
-
product={product}
|
|
102
|
-
config={config}
|
|
103
|
-
commerceMode={config.commerceMode}
|
|
104
|
-
actions={actions}
|
|
105
|
-
/>
|
|
106
|
-
</div>
|
|
107
|
-
))}
|
|
108
|
-
</div>
|
|
109
|
-
{cta && (
|
|
110
|
-
<Link
|
|
111
|
-
to={href ?? config.catalogPath}
|
|
112
|
-
className="mt-4 inline-flex border border-foreground/30 px-6 py-3 text-xs font-semibold uppercase tracking-[0.16em] transition hover:bg-foreground hover:text-background"
|
|
113
|
-
>
|
|
114
|
-
{cta}
|
|
115
|
-
</Link>
|
|
116
|
-
)}
|
|
117
|
-
</section>
|
|
118
|
-
)
|
|
119
|
-
}
|
package/src/config.ts
DELETED
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useContext } from 'react'
|
|
2
|
-
import type { ShopProvider } from '@fayz-ai/shop/provider'
|
|
3
|
-
import type { MockShopSeed } from '@fayz-ai/shop/mock'
|
|
4
|
-
import type { PaymentMethodKind } from '@fayz-ai/shop/types'
|
|
5
|
-
import type { StorefrontTheme } from './theme'
|
|
6
|
-
import type { HomeConfig, NavLink, FooterConfig } from './sections'
|
|
7
|
-
import type { StorefrontAuthConfig } from './auth'
|
|
8
|
-
import type { StorefrontComponents } from './component-contracts'
|
|
9
|
-
|
|
10
|
-
export type StorefrontRouteKind =
|
|
11
|
-
| 'home'
|
|
12
|
-
| 'catalog'
|
|
13
|
-
| 'product'
|
|
14
|
-
| 'checkout'
|
|
15
|
-
| 'account'
|
|
16
|
-
| 'order'
|
|
17
|
-
| 'custom'
|
|
18
|
-
|
|
19
|
-
export type StorefrontRouteParams = Record<string, string>
|
|
20
|
-
|
|
21
|
-
export interface StorefrontRouteComponentProps {
|
|
22
|
-
path: string
|
|
23
|
-
params: StorefrontRouteParams
|
|
24
|
-
config: ResolvedStorefrontConfig
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export type StorefrontRouteChrome = 'default' | 'focused'
|
|
28
|
-
export type StorefrontCommerceMode = 'checkout' | 'catalog' | 'enquiry'
|
|
29
|
-
export type StorefrontImageLoadingMode = 'fade' | 'none'
|
|
30
|
-
|
|
31
|
-
export interface StorefrontImageLoadingConfig {
|
|
32
|
-
mode?: StorefrontImageLoadingMode
|
|
33
|
-
durationMs?: number
|
|
34
|
-
easing?: string
|
|
35
|
-
blur?: boolean
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface StorefrontRouteDefinition {
|
|
39
|
-
/**
|
|
40
|
-
* Stable identifier for generated-code diffs, QA reports, and route ownership.
|
|
41
|
-
*/
|
|
42
|
-
id: string
|
|
43
|
-
/**
|
|
44
|
-
* Hash route pattern. Supports the same params as matchPath, e.g. '/checkout'
|
|
45
|
-
* or '/collections/:slug'. Custom routes are matched before SDK defaults.
|
|
46
|
-
*/
|
|
47
|
-
path: string
|
|
48
|
-
/**
|
|
49
|
-
* Intent label for agents and manifests. It does not change matching behavior.
|
|
50
|
-
*/
|
|
51
|
-
kind?: StorefrontRouteKind
|
|
52
|
-
/**
|
|
53
|
-
* Shell chrome for the route. `focused` hides storefront nav/footer/cart
|
|
54
|
-
* around high-intent flows such as checkout.
|
|
55
|
-
*/
|
|
56
|
-
chrome?: StorefrontRouteChrome
|
|
57
|
-
/**
|
|
58
|
-
* App-owned screen/workflow that can still use storefront/shop primitives.
|
|
59
|
-
*/
|
|
60
|
-
component: React.ComponentType<StorefrontRouteComponentProps>
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface StorefrontDiscountConfig {
|
|
64
|
-
code: string
|
|
65
|
-
percent: number
|
|
66
|
-
title?: string
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface StorefrontEnquiryConfig {
|
|
70
|
-
label?: string
|
|
71
|
-
successMessage?: string
|
|
72
|
-
subjectPrefix?: string
|
|
73
|
-
email?: string
|
|
74
|
-
whatsappUrl?: string
|
|
75
|
-
requirePhone?: boolean
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface StorefrontConfig {
|
|
79
|
-
/** Store display name (header, page title) */
|
|
80
|
-
name: string
|
|
81
|
-
/** Optional logo node; defaults to the store name */
|
|
82
|
-
logo?: React.ReactNode
|
|
83
|
-
/** ISO 4217 — default 'BRL' */
|
|
84
|
-
currency?: string
|
|
85
|
-
/** Intl locale for money/date formatting — default 'pt-BR' */
|
|
86
|
-
locale?: string
|
|
87
|
-
/** Visual identity: colors, fonts, radius, header/card personality */
|
|
88
|
-
theme?: StorefrontTheme
|
|
89
|
-
/** Checkout-first default, catalog-only browsing, or product enquiry flow. */
|
|
90
|
-
commerceMode?: StorefrontCommerceMode
|
|
91
|
-
/** Promo message above the header (e.g. 'FRETE GRÁTIS ACIMA DE R$ 300') */
|
|
92
|
-
announcement?: string
|
|
93
|
-
/** Home page blueprint. When set, `/` renders it and the catalog moves to /catalog. */
|
|
94
|
-
home?: HomeConfig
|
|
95
|
-
/** Header nav links — defaults derived from home/catalog routing */
|
|
96
|
-
nav?: NavLink[]
|
|
97
|
-
/** Footer content (about text, contact, social) */
|
|
98
|
-
footer?: FooterConfig
|
|
99
|
-
/** Preferred backend descriptor for manifest/scaffold metadata. */
|
|
100
|
-
backend?: { provider?: 'mock' | 'fayz-api' | 'fayz-shop' | 'custom'; url?: string }
|
|
101
|
-
/** @deprecated Use backend/provider adapters. Storefront no longer creates Supabase clients. */
|
|
102
|
-
supabaseUrl?: string
|
|
103
|
-
/** @deprecated Use backend/provider adapters. Storefront no longer creates Supabase clients. */
|
|
104
|
-
supabaseAnonKey?: string
|
|
105
|
-
/** Explicit provider override (tests, custom backends) */
|
|
106
|
-
provider?: ShopProvider
|
|
107
|
-
/** Per-store mock catalog (products/categories/discounts) for mock mode */
|
|
108
|
-
catalog?: MockShopSeed
|
|
109
|
-
/** Store-level discount codes available regardless of provider backend. */
|
|
110
|
-
discounts?: StorefrontDiscountConfig[]
|
|
111
|
-
/**
|
|
112
|
-
* Institutional/legal page content (privacy, terms, returns). Plain text —
|
|
113
|
-
* blank lines separate paragraphs. Unset pages render a placeholder so the
|
|
114
|
-
* routes (and footer links) exist even before the store writes its policy.
|
|
115
|
-
*/
|
|
116
|
-
legal?: { privacy?: string; terms?: string; returns?: string }
|
|
117
|
-
/** Customer auth — same AuthAdapter contract as createSaasApp. Default: mock. */
|
|
118
|
-
auth?: StorefrontAuthConfig
|
|
119
|
-
/** Shipping pricing — default { flatRate: 0 } */
|
|
120
|
-
shipping?: { flatRate?: number; freeAbove?: number }
|
|
121
|
-
/**
|
|
122
|
-
* Payment behavior. v1 default 'mock' instantly marks orders paid with NO
|
|
123
|
-
* real charge (demo). M4 sets 'pix-mercadopago' so orders stay pending until
|
|
124
|
-
* a real payment webhook confirms settlement.
|
|
125
|
-
*/
|
|
126
|
-
payments?: {
|
|
127
|
-
mode?: 'mock' | 'pix-mercadopago'
|
|
128
|
-
/**
|
|
129
|
-
* Which methods the checkout offers. Declaring them is what lets the order
|
|
130
|
-
* record how the buyer intends to pay instead of assuming 'credit_card',
|
|
131
|
-
* which is what it did while the card form was a simulation.
|
|
132
|
-
*/
|
|
133
|
-
methods?: readonly PaymentMethodKind[]
|
|
134
|
-
}
|
|
135
|
-
/** Product enquiry behavior for catalog/enquiry stores. */
|
|
136
|
-
enquiry?: StorefrontEnquiryConfig
|
|
137
|
-
/** Feature toggles — defaults depend on commerceMode. */
|
|
138
|
-
features?: { discounts?: boolean; accounts?: boolean; cart?: boolean; checkout?: boolean }
|
|
139
|
-
/** Global storefront image reveal behavior. Default is a soft fade. */
|
|
140
|
-
imageLoading?: StorefrontImageLoadingConfig
|
|
141
|
-
/** Code-level component replacements. Kept out of serialized manifests. */
|
|
142
|
-
components?: StorefrontComponents
|
|
143
|
-
/** Code-level route overrides/custom routes. Kept out of serialized manifests. */
|
|
144
|
-
routes?: readonly StorefrontRouteDefinition[]
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export interface ResolvedStorefrontConfig extends StorefrontConfig {
|
|
148
|
-
currency: string
|
|
149
|
-
locale: string
|
|
150
|
-
shipping: { flatRate: number; freeAbove?: number }
|
|
151
|
-
payments: { mode: 'mock' | 'pix-mercadopago'; methods: readonly PaymentMethodKind[] }
|
|
152
|
-
commerceMode: StorefrontCommerceMode
|
|
153
|
-
enquiry: Required<Pick<StorefrontEnquiryConfig, 'label' | 'successMessage' | 'subjectPrefix'>> &
|
|
154
|
-
Omit<StorefrontEnquiryConfig, 'label' | 'successMessage' | 'subjectPrefix'>
|
|
155
|
-
features: { discounts: boolean; accounts: boolean; cart: boolean; checkout: boolean }
|
|
156
|
-
imageLoading: Required<StorefrontImageLoadingConfig>
|
|
157
|
-
/** Where the full product list lives ('/' without a home page, '/catalog' with one) */
|
|
158
|
-
catalogPath: string
|
|
159
|
-
nav: NavLink[]
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export function resolveConfig(config: StorefrontConfig): ResolvedStorefrontConfig {
|
|
163
|
-
const catalogPath = config.home ? '/catalog' : '/'
|
|
164
|
-
const commerceMode = config.commerceMode ?? 'checkout'
|
|
165
|
-
const checkoutEnabled = commerceMode === 'checkout'
|
|
166
|
-
return {
|
|
167
|
-
...config,
|
|
168
|
-
currency: config.currency ?? 'BRL',
|
|
169
|
-
locale: config.locale ?? 'pt-BR',
|
|
170
|
-
shipping: { flatRate: config.shipping?.flatRate ?? 0, freeAbove: config.shipping?.freeAbove },
|
|
171
|
-
payments: {
|
|
172
|
-
mode: config.payments?.mode ?? 'mock',
|
|
173
|
-
methods: config.payments?.methods?.length ? config.payments.methods : ['pix', 'credit_card', 'cash'],
|
|
174
|
-
},
|
|
175
|
-
commerceMode,
|
|
176
|
-
enquiry: {
|
|
177
|
-
label: config.enquiry?.label ?? 'Contact me',
|
|
178
|
-
successMessage: config.enquiry?.successMessage ?? 'Thanks. We received your enquiry.',
|
|
179
|
-
subjectPrefix: config.enquiry?.subjectPrefix ?? 'Product enquiry',
|
|
180
|
-
email: config.enquiry?.email,
|
|
181
|
-
whatsappUrl: config.enquiry?.whatsappUrl,
|
|
182
|
-
requirePhone: config.enquiry?.requirePhone,
|
|
183
|
-
},
|
|
184
|
-
features: {
|
|
185
|
-
// Auto-enable the coupon UI when the store actually ships discount codes
|
|
186
|
-
// (via config.discounts or a seeded catalog), unless explicitly overridden —
|
|
187
|
-
// otherwise a store can advertise a coupon with no field to enter it.
|
|
188
|
-
discounts:
|
|
189
|
-
config.features?.discounts ??
|
|
190
|
-
Boolean(config.discounts?.length || config.catalog?.discounts?.length),
|
|
191
|
-
accounts: config.features?.accounts ?? checkoutEnabled,
|
|
192
|
-
cart: config.features?.cart ?? checkoutEnabled,
|
|
193
|
-
checkout: config.features?.checkout ?? checkoutEnabled,
|
|
194
|
-
},
|
|
195
|
-
imageLoading: {
|
|
196
|
-
mode: config.imageLoading?.mode ?? 'fade',
|
|
197
|
-
durationMs: config.imageLoading?.durationMs ?? 420,
|
|
198
|
-
easing: config.imageLoading?.easing ?? 'cubic-bezier(0.22, 1, 0.36, 1)',
|
|
199
|
-
blur: config.imageLoading?.blur ?? true,
|
|
200
|
-
},
|
|
201
|
-
catalogPath,
|
|
202
|
-
nav:
|
|
203
|
-
config.nav ??
|
|
204
|
-
(config.home
|
|
205
|
-
? [
|
|
206
|
-
{ label: 'Início', to: '/' },
|
|
207
|
-
{ label: 'Loja', to: '/catalog' },
|
|
208
|
-
]
|
|
209
|
-
: [{ label: 'Loja', to: '/' }]),
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const StorefrontConfigContext = createContext<ResolvedStorefrontConfig | null>(null)
|
|
214
|
-
|
|
215
|
-
export const StorefrontConfigProvider = StorefrontConfigContext.Provider
|
|
216
|
-
|
|
217
|
-
export function useStorefrontConfig(): ResolvedStorefrontConfig {
|
|
218
|
-
const ctx = useContext(StorefrontConfigContext)
|
|
219
|
-
if (!ctx) throw new Error('useStorefrontConfig must be used inside createStorefrontApp')
|
|
220
|
-
return ctx
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export function useStorefrontConfigOptional(): ResolvedStorefrontConfig | null {
|
|
224
|
-
return useContext(StorefrontConfigContext)
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export function getStorefrontComponents(config: ResolvedStorefrontConfig): StorefrontComponents {
|
|
228
|
-
return config.components ?? {}
|
|
229
|
-
}
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { setShopProvider, getShopProvider } from '@fayz-ai/shop/runtime'
|
|
3
|
-
import { createMockShopProvider } from '@fayz-ai/shop/mock'
|
|
4
|
-
import type { MockShopSeed } from '@fayz-ai/shop/mock'
|
|
5
|
-
import type { Discount } from '@fayz-ai/shop/types'
|
|
6
|
-
import type { ShopProvider } from '@fayz-ai/shop/provider'
|
|
7
|
-
import { initCustomerAuth, resolveAuthAdapter } from './auth'
|
|
8
|
-
import { registerStorefrontBlocks } from './blocks'
|
|
9
|
-
import { getStorefrontComponents, StorefrontConfigProvider, resolveConfig, useStorefrontConfig } from './config'
|
|
10
|
-
import type { StorefrontConfig, StorefrontDiscountConfig } from './config'
|
|
11
|
-
import type { StorefrontComponents } from './component-contracts'
|
|
12
|
-
import type { StorefrontSection } from './sections'
|
|
13
|
-
import { useHashPath, matchPath } from './router'
|
|
14
|
-
import { useCartStore } from './stores/cart.store'
|
|
15
|
-
import { StorefrontThemeStyle } from './theme'
|
|
16
|
-
import { StorefrontHeader } from './components/StorefrontHeader'
|
|
17
|
-
import { StorefrontFooter } from './components/StorefrontFooter'
|
|
18
|
-
import { CartDrawer } from './components/CartDrawer'
|
|
19
|
-
import { CatalogPage } from './pages/CatalogPage'
|
|
20
|
-
import { HomePage } from './pages/HomePage'
|
|
21
|
-
import { ProductDetailPage } from './pages/ProductDetailPage'
|
|
22
|
-
import { CheckoutPage } from './pages/CheckoutPage'
|
|
23
|
-
import { OrderConfirmationPage } from './pages/OrderConfirmationPage'
|
|
24
|
-
import { MyPurchasesPage } from './pages/MyPurchasesPage'
|
|
25
|
-
import { NotFoundPage } from './pages/NotFoundPage'
|
|
26
|
-
import { PolicyPage } from './pages/PolicyPage'
|
|
27
|
-
import { StorefrontErrorBoundary } from './components/StorefrontErrorBoundary'
|
|
28
|
-
import { Toaster } from './components/Toaster'
|
|
29
|
-
|
|
30
|
-
function getCustomRouteMatch(config: ReturnType<typeof useStorefrontConfig>, path: string) {
|
|
31
|
-
for (const route of config.routes ?? []) {
|
|
32
|
-
const params = matchPath(route.path, path)
|
|
33
|
-
if (params) return { route, params }
|
|
34
|
-
}
|
|
35
|
-
return null
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function isFocusedRoute(config: ReturnType<typeof useStorefrontConfig>, path: string): boolean {
|
|
39
|
-
const custom = getCustomRouteMatch(config, path)
|
|
40
|
-
if (custom) return custom.route.chrome === 'focused' || custom.route.kind === 'checkout'
|
|
41
|
-
return Boolean(matchPath('/checkout', path))
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function RouteSwitch({ path }: { path: string }) {
|
|
45
|
-
const config = useStorefrontConfig()
|
|
46
|
-
|
|
47
|
-
const custom = getCustomRouteMatch(config, path)
|
|
48
|
-
if (custom) {
|
|
49
|
-
const CustomRoute = custom.route.component
|
|
50
|
-
return <CustomRoute path={path} params={custom.params} config={config} />
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const product = matchPath('/product/:slug', path)
|
|
54
|
-
if (product?.slug) return <ProductDetailPage slug={product.slug} />
|
|
55
|
-
|
|
56
|
-
const order = matchPath('/order/:id', path)
|
|
57
|
-
if (order?.id) return <OrderConfirmationPage orderId={order.id} />
|
|
58
|
-
|
|
59
|
-
if (matchPath('/checkout', path) && config.features.checkout) return <CheckoutPage />
|
|
60
|
-
if (matchPath('/account', path) && config.features.accounts) return <MyPurchasesPage />
|
|
61
|
-
if (matchPath('/catalog', path)) return <CatalogPage />
|
|
62
|
-
if (matchPath('/privacy', path)) return <PolicyPage kind="privacy" />
|
|
63
|
-
if (matchPath('/terms', path)) return <PolicyPage kind="terms" />
|
|
64
|
-
if (matchPath('/refunds', path)) return <PolicyPage kind="returns" />
|
|
65
|
-
|
|
66
|
-
// Root renders home (or catalog when there's no home). Any other unmatched
|
|
67
|
-
// path is a genuine 404 — don't silently fall back to the storefront.
|
|
68
|
-
if (path === '/' || path === '') {
|
|
69
|
-
return config.home ? <HomePage sections={config.home.sections} /> : <CatalogPage />
|
|
70
|
-
}
|
|
71
|
-
return <NotFoundPage />
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Side-effect runtime init shared by the factory and the manifest scaffold:
|
|
76
|
-
* wires customer auth and the shop provider. Idempotent and safe to call once
|
|
77
|
-
* before first render. Provider resolution: explicit > catalog mock > empty mock.
|
|
78
|
-
*/
|
|
79
|
-
/**
|
|
80
|
-
* config.discounts are simple {code, percent} entries the UI validator trusts
|
|
81
|
-
* (useDiscountValidator). They must ALSO be seeded into the provider, or
|
|
82
|
-
* placeOrder won't find the code server-side and will charge full price — the
|
|
83
|
-
* shopper sees a discounted total but is billed the undiscounted one.
|
|
84
|
-
*/
|
|
85
|
-
function storefrontDiscountToSeed(discount: StorefrontDiscountConfig): Discount {
|
|
86
|
-
const ts = new Date().toISOString()
|
|
87
|
-
return {
|
|
88
|
-
id: `cfg-discount-${discount.code.trim().toLowerCase()}`,
|
|
89
|
-
tenantId: 'mock',
|
|
90
|
-
title: discount.title ?? `${discount.percent}% off`,
|
|
91
|
-
code: discount.code.trim().toUpperCase(),
|
|
92
|
-
type: 'percentage',
|
|
93
|
-
method: 'code',
|
|
94
|
-
value: discount.percent,
|
|
95
|
-
usageLimit: null,
|
|
96
|
-
oncePerCustomer: false,
|
|
97
|
-
minSubtotal: null,
|
|
98
|
-
appliesTo: 'all',
|
|
99
|
-
productIds: [],
|
|
100
|
-
categoryIds: [],
|
|
101
|
-
startsAt: ts,
|
|
102
|
-
endsAt: null,
|
|
103
|
-
status: 'active',
|
|
104
|
-
timesUsed: 0,
|
|
105
|
-
createdAt: ts,
|
|
106
|
-
updatedAt: ts,
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function buildMockSeed(config: StorefrontConfig): MockShopSeed | undefined {
|
|
111
|
-
const configDiscounts = (config.discounts ?? []).map(storefrontDiscountToSeed)
|
|
112
|
-
if (!config.catalog && configDiscounts.length === 0) return undefined
|
|
113
|
-
// Config-level codes win over catalog seeds sharing the same code.
|
|
114
|
-
const catalogDiscounts = (config.catalog?.discounts ?? []).filter(
|
|
115
|
-
(cd) => !configDiscounts.some((cfg) => (cd.code ?? '').toUpperCase() === cfg.code),
|
|
116
|
-
)
|
|
117
|
-
return {
|
|
118
|
-
...config.catalog,
|
|
119
|
-
discounts: [...catalogDiscounts, ...configDiscounts],
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export function initStorefrontRuntime(config: StorefrontConfig): void {
|
|
124
|
-
registerStorefrontBlocks()
|
|
125
|
-
if (resolveConfig(config).features.accounts) {
|
|
126
|
-
initCustomerAuth(resolveAuthAdapter(config.auth, {
|
|
127
|
-
supabaseUrl: config.supabaseUrl,
|
|
128
|
-
supabaseAnonKey: config.supabaseAnonKey,
|
|
129
|
-
}))
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (config.provider) {
|
|
133
|
-
setShopProvider(config.provider)
|
|
134
|
-
} else {
|
|
135
|
-
setShopProvider(createMockShopProvider(buildMockSeed(config)))
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Drop any persisted cart line the active backend can't resolve (e.g. a cart
|
|
139
|
-
// built in an earlier mock-mode session, whose ids don't exist live) so stale
|
|
140
|
-
// ids never reach checkout and 400 the order. Keeps a line on any error so a
|
|
141
|
-
// transient failure never discards a valid item. Runs AFTER the persisted cart
|
|
142
|
-
// has hydrated — zustand/persist rehydrates asynchronously, so reconciling at
|
|
143
|
-
// init would see an empty cart and no-op.
|
|
144
|
-
const reconcileCart = () => {
|
|
145
|
-
const provider = getShopProvider()
|
|
146
|
-
void useCartStore.getState().reconcile(async (line) => {
|
|
147
|
-
const product = await provider.getProduct(line.productId)
|
|
148
|
-
return product != null
|
|
149
|
-
})
|
|
150
|
-
}
|
|
151
|
-
if (useCartStore.persist.hasHydrated()) reconcileCart()
|
|
152
|
-
else useCartStore.persist.onFinishHydration(reconcileCart)
|
|
153
|
-
|
|
154
|
-
if (config.supabaseUrl || config.supabaseAnonKey) {
|
|
155
|
-
console.warn(
|
|
156
|
-
'@fayz-ai/shop: supabaseUrl/supabaseAnonKey are legacy fields. Pass an explicit provider/adapter or use the Fayz SDK broker path.',
|
|
157
|
-
)
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/** The inner storefront UI. Reads everything from the config context, so it is
|
|
162
|
-
* shared by createStorefrontApp and the manifest-driven StorefrontScaffold. */
|
|
163
|
-
export function StorefrontShell() {
|
|
164
|
-
const config = useStorefrontConfig()
|
|
165
|
-
const path = useHashPath()
|
|
166
|
-
const focused = isFocusedRoute(config, path)
|
|
167
|
-
const components = getStorefrontComponents(config)
|
|
168
|
-
const chromeProps = { config, commerceMode: config.commerceMode }
|
|
169
|
-
const body = (
|
|
170
|
-
<>
|
|
171
|
-
{config.theme && <StorefrontThemeStyle theme={config.theme} />}
|
|
172
|
-
{!focused &&
|
|
173
|
-
(components.Header ? <components.Header {...chromeProps} /> : <StorefrontHeader />)}
|
|
174
|
-
<StorefrontErrorBoundary key={path}>
|
|
175
|
-
<RouteSwitch path={path} />
|
|
176
|
-
</StorefrontErrorBoundary>
|
|
177
|
-
{!focused && config.features.cart && <CartDrawer />}
|
|
178
|
-
{!focused &&
|
|
179
|
-
(components.Footer ? <components.Footer {...chromeProps} /> : <StorefrontFooter />)}
|
|
180
|
-
<Toaster />
|
|
181
|
-
</>
|
|
182
|
-
)
|
|
183
|
-
|
|
184
|
-
if (components.Shell) {
|
|
185
|
-
return (
|
|
186
|
-
<components.Shell {...chromeProps}>
|
|
187
|
-
{body}
|
|
188
|
-
</components.Shell>
|
|
189
|
-
)
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return (
|
|
193
|
-
<div className="min-h-screen bg-background text-foreground">
|
|
194
|
-
{body}
|
|
195
|
-
</div>
|
|
196
|
-
)
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Declarative storefront factory — the customer-facing counterpart of
|
|
201
|
-
* createSaasApp. Sugar over the manifest path: it is equivalent to
|
|
202
|
-
* renderApp(defineStorefront(config)), sharing initStorefrontRuntime +
|
|
203
|
-
* StorefrontShell with the scaffold.
|
|
204
|
-
*
|
|
205
|
-
* const App = createStorefrontApp({ name: 'Aurora Goods', currency: 'BRL' })
|
|
206
|
-
*/
|
|
207
|
-
export function createStorefrontApp(config: StorefrontConfig): React.ComponentType {
|
|
208
|
-
const resolved = resolveConfig(config)
|
|
209
|
-
initStorefrontRuntime(config)
|
|
210
|
-
|
|
211
|
-
function StorefrontApp() {
|
|
212
|
-
return (
|
|
213
|
-
<StorefrontConfigProvider value={resolved}>
|
|
214
|
-
<StorefrontShell />
|
|
215
|
-
</StorefrontConfigProvider>
|
|
216
|
-
)
|
|
217
|
-
}
|
|
218
|
-
StorefrontApp.displayName = 'StorefrontApp'
|
|
219
|
-
return StorefrontApp
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export interface CreateStorefrontOptions {
|
|
223
|
-
config: StorefrontConfig
|
|
224
|
-
provider?: ShopProvider
|
|
225
|
-
components?: StorefrontComponents
|
|
226
|
-
routes?: StorefrontConfig['routes']
|
|
227
|
-
pages?: StorefrontConfig['routes']
|
|
228
|
-
sections?: readonly StorefrontSection[]
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
export function createStorefront(options: CreateStorefrontOptions): React.ComponentType {
|
|
232
|
-
const routes = [...(options.pages ?? []), ...(options.routes ?? [])]
|
|
233
|
-
const config: StorefrontConfig = {
|
|
234
|
-
...options.config,
|
|
235
|
-
provider: options.provider ?? options.config.provider,
|
|
236
|
-
components: {
|
|
237
|
-
...options.config.components,
|
|
238
|
-
...options.components,
|
|
239
|
-
},
|
|
240
|
-
routes: routes.length > 0 ? routes : options.config.routes,
|
|
241
|
-
home: options.sections
|
|
242
|
-
? { ...(options.config.home ?? { sections: [] }), sections: options.sections }
|
|
243
|
-
: options.config.home,
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return createStorefrontApp(config)
|
|
247
|
-
}
|
package/src/define.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
StorefrontConfig,
|
|
3
|
-
StorefrontRouteDefinition,
|
|
4
|
-
} from './config'
|
|
5
|
-
import type { StorefrontComponents } from './component-contracts'
|
|
6
|
-
import type { StorefrontSection } from './sections'
|
|
7
|
-
import type { CreateStorefrontOptions } from './createStorefrontApp'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Identity helpers for generated/custom storefronts.
|
|
11
|
-
*
|
|
12
|
-
* They do not add runtime behavior; they make the intended client-app shape
|
|
13
|
-
* explicit and keep TypeScript inference tight across config, components, routes,
|
|
14
|
-
* sections and app creation options.
|
|
15
|
-
*/
|
|
16
|
-
export function defineStorefrontConfig<const T extends StorefrontConfig>(config: T): T {
|
|
17
|
-
return config
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function defineStorefrontComponents<const T extends StorefrontComponents>(components: T): T {
|
|
21
|
-
return components
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function defineStorefrontRoutes<const T extends readonly StorefrontRouteDefinition[]>(routes: T): T {
|
|
25
|
-
return routes
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function defineStorefrontSections<const T extends readonly StorefrontSection[]>(sections: T): T {
|
|
29
|
-
return sections
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function defineStorefrontApp<const T extends CreateStorefrontOptions>(options: T): T {
|
|
33
|
-
return options
|
|
34
|
-
}
|
package/src/format.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export function formatMoney(value: number, currency = 'BRL', locale = 'pt-BR'): string {
|
|
2
|
-
return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(value)
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export function roundCents(value: number): number {
|
|
6
|
-
return Math.round(value * 100) / 100
|
|
7
|
-
}
|
package/src/hooks/index.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { useProducts } from './useProducts'
|
|
2
|
-
export { useProduct } from './useProduct'
|
|
3
|
-
export { useCategories } from './useCategories'
|
|
4
|
-
export { useStorefront, useCatalog, useCart, useEnquiry, useStorefrontActions } from './useStorefront'
|
|
5
|
-
export { useMyOrders } from './useMyOrders'
|
|
6
|
-
export { useDiscountValidator } from './useDiscountValidator'
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react'
|
|
2
|
-
import { getShopProvider } from '@fayz-ai/shop/runtime'
|
|
3
|
-
import type { Category } from '@fayz-ai/shop/types'
|
|
4
|
-
|
|
5
|
-
export function useCategories(): { categories: Category[]; loading: boolean } {
|
|
6
|
-
const [categories, setCategories] = useState<Category[]>([])
|
|
7
|
-
const [loading, setLoading] = useState(true)
|
|
8
|
-
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
let cancelled = false
|
|
11
|
-
getShopProvider()
|
|
12
|
-
.listCategories()
|
|
13
|
-
.then((data) => {
|
|
14
|
-
if (!cancelled) setCategories(data)
|
|
15
|
-
})
|
|
16
|
-
.catch(() => {})
|
|
17
|
-
.finally(() => {
|
|
18
|
-
if (!cancelled) setLoading(false)
|
|
19
|
-
})
|
|
20
|
-
return () => {
|
|
21
|
-
cancelled = true
|
|
22
|
-
}
|
|
23
|
-
}, [])
|
|
24
|
-
|
|
25
|
-
return { categories, loading }
|
|
26
|
-
}
|