@fayz-ai/storefront 0.68.0 → 0.70.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.
@@ -707,6 +707,16 @@ async function productBySlug(params, ctx) {
707
707
  }
708
708
  return product;
709
709
  }
710
+ async function productsFeatured(_params, ctx) {
711
+ const none = { listing: [], menu: [] };
712
+ if (!ctx.shop.listFeaturedProducts) return none;
713
+ try {
714
+ const got = await ctx.shop.listFeaturedProducts();
715
+ return { listing: got?.listing ?? [], menu: got?.menu ?? [] };
716
+ } catch {
717
+ return none;
718
+ }
719
+ }
710
720
  async function categoriesList(_params, ctx) {
711
721
  return ctx.shop.listCategories();
712
722
  }
@@ -821,6 +831,13 @@ function registerStorefrontLoaders() {
821
831
  }
822
832
  ]
823
833
  });
834
+ defineLoader("products.featured", productsFeatured, {
835
+ source: "sdk",
836
+ title: "Featured products",
837
+ description: "The store's own highlights: products featured (\xABDestaque no site\xBB) on the product's Loja tab and in the Card\xE1pio, each in the merchant's order. Only products the shopper can read.",
838
+ output: "{ listing: string[], menu: string[] } \u2014 product ids per source, each in order. Empty lists when the store curated nothing.",
839
+ settings: []
840
+ });
824
841
  defineLoader("categories.list", categoriesList, {
825
842
  source: "sdk",
826
843
  title: "Category list",
@@ -11795,6 +11812,34 @@ function AddressForm2({ onDone, initial: initial2, replaces }) {
11795
11812
  ] });
11796
11813
  }
11797
11814
 
11815
+ // src/lib/highlights.ts
11816
+ var HIGHLIGHT_LIMIT = 6;
11817
+ function pickHighlights(items, sources = {}) {
11818
+ const limit = sources.limit ?? HIGHLIGHT_LIMIT;
11819
+ const pick = (key, wanted) => {
11820
+ if (!wanted?.length) return [];
11821
+ const byKey = new Map(items.map((p) => [p[key], p]));
11822
+ const seen = /* @__PURE__ */ new Set();
11823
+ const out = [];
11824
+ for (const value of wanted) {
11825
+ const product = byKey.get(value);
11826
+ if (!product || seen.has(product.id)) continue;
11827
+ seen.add(product.id);
11828
+ out.push(product);
11829
+ if (out.length >= limit) break;
11830
+ }
11831
+ return out;
11832
+ };
11833
+ for (const chosen of [
11834
+ pick("id", sources.listingFeaturedIds),
11835
+ pick("id", sources.menuFeaturedIds),
11836
+ pick("slug", sources.highlightSlugs)
11837
+ ]) {
11838
+ if (chosen.length) return chosen;
11839
+ }
11840
+ return items.filter((p) => p.compareAtPrice != null && p.compareAtPrice > p.price && p.inventoryCount > 0).slice(0, limit);
11841
+ }
11842
+
11798
11843
  // src/components/account/section.ts
11799
11844
  var ACCOUNT_SECTIONS = [
11800
11845
  "profile",
@@ -11905,7 +11950,6 @@ function AccountDrawer({ onClose, onSignIn, onAddresses, onShowHours }) {
11905
11950
  ] })
11906
11951
  ] });
11907
11952
  }
11908
- var HIGHLIGHT_LIMIT = 6;
11909
11953
  function MenuPage() {
11910
11954
  const config = useStorefrontConfig();
11911
11955
  const addItem = useCartStore((s2) => s2.addItem);
@@ -11938,6 +11982,8 @@ function MenuPage() {
11938
11982
  }
11939
11983
  const products = useLoader("products.list", {});
11940
11984
  const categories = useLoader("categories.list", {});
11985
+ const featured = useLoader("products.featured", {});
11986
+ const featuredPending = featured.status === "loading" || featured.status === "idle";
11941
11987
  const loading = products.status === "loading" || products.status === "idle";
11942
11988
  const items = products.data ?? [];
11943
11989
  const cats = categories.data ?? [];
@@ -11969,14 +12015,14 @@ function MenuPage() {
11969
12015
  }
11970
12016
  return ordered;
11971
12017
  }, [items, cats]);
11972
- const highlights = React38.useMemo(() => {
11973
- const slugs = config.delivery?.highlightSlugs;
11974
- if (slugs?.length) {
11975
- const bySlug = new Map(items.map((p) => [p.slug, p]));
11976
- return slugs.map((slug) => bySlug.get(slug)).filter((p) => Boolean(p)).slice(0, HIGHLIGHT_LIMIT);
11977
- }
11978
- return items.filter((p) => p.compareAtPrice != null && p.compareAtPrice > p.price && p.inventoryCount > 0).slice(0, HIGHLIGHT_LIMIT);
11979
- }, [items, config.delivery?.highlightSlugs]);
12018
+ const highlights = React38.useMemo(
12019
+ () => pickHighlights(items, {
12020
+ listingFeaturedIds: featured.data?.listing,
12021
+ menuFeaturedIds: featured.data?.menu,
12022
+ highlightSlugs: config.delivery?.highlightSlugs
12023
+ }),
12024
+ [items, featured.data, config.delivery?.highlightSlugs]
12025
+ );
11980
12026
  const normalized = query.trim().toLowerCase();
11981
12027
  const sections = React38.useMemo(() => {
11982
12028
  if (!normalized) return allSections;
@@ -12049,7 +12095,7 @@ function MenuPage() {
12049
12095
  " ",
12050
12096
  matches === 1 ? "item encontrado" : "itens encontrados"
12051
12097
  ] }),
12052
- !normalized && highlights.length > 0 && /* @__PURE__ */ jsxs("section", { "data-testid": TID.menuHighlights, className: "mb-10 pt-6", children: [
12098
+ !normalized && !featuredPending && highlights.length > 0 && /* @__PURE__ */ jsxs("section", { "data-testid": TID.menuHighlights, className: "mb-10 pt-6", children: [
12053
12099
  /* @__PURE__ */ jsx("h2", { className: "text-lg font-bold uppercase tracking-wide", children: "Destaques" }),
12054
12100
  /* @__PURE__ */ jsx("ul", { className: "mt-2", children: highlights.map((product) => /* @__PURE__ */ jsx(
12055
12101
  MenuItemRow,
@@ -14747,5 +14793,5 @@ ${formatErrors(report.errors)}`;
14747
14793
  }
14748
14794
 
14749
14795
  export { AddressForm, AddressSheet, AddressStrip, BEFORE_PLACE_ORDER_VALVE, BLOCK_STRUCTURAL_KEYS, BUYER_COUNTRY_COOKIE, BenefitsRow, BlockDataError, CART_LINE_ANNOTATION_POINT, CATALOG_BODY_BLOCK, CHECKOUT_FIELD_POINT, CartDrawer, CatalogPage, CategoryShowcase, CheckoutPage, ClosedStoreDialog, CollectionCta, CollectionHero, ContentPage, CountdownBand, CountrySelect, DeliverToPicker, EmailConfirmationRequiredError, EntityListBlock, FaqSection, FiltersPanel, FormBlock, HeroSection, ImageTiles, ItemSheet, Link, MESSAGES, ManifestoBlock, MediaCarousel, MenuItemRow, MenuPage, MenuToolbar, MotifStrip, MyPurchasesPage, NewsletterBand, ORDER_METADATA_POINT, OrderConfirmationPage, OrderTrackingTimeline, PAGE_DATA_SCRIPT_ID, PLACEHOLDER_ASPECTS, PRODUCT_BODY_BLOCK, PRODUCT_CARD_BADGE_POINT, PageDataScope, PaymentTerms, Price, ProductCard, ProductDetailPage, ProductEnquiryForm, ProductGallery, ProductGrid, ProductOptionSelector, ProductRail, ProductReviews, ProductSlider, ProductSpecs, ProductSpotlight, PromoBanner, QuantityInput, Reveal, STOREFRONT_COMPONENT_KEYS, STOREFRONT_PAGE_KINDS, STOREFRONT_SLOTS, STORE_BACKEND_PROVIDERS, STORE_COMMERCE_MODES, STORE_DOCUMENT_KIND, STORE_PAYMENT_METHOD_KINDS, STORE_PAYMENT_MODES, STORE_ROUTE_CHROMES, STORE_ROUTE_KINDS, STORE_SECTIONS, STORE_SECTION_NAMES, ScheduleSheet, SealsBand, SearchOverlay, ServiceHoursModal, Slot, SmoothImage, StepsSection, StoreCover, StorefrontConfigHost, StorefrontConfigProvider, StorefrontFooter, StorefrontHeader, StorefrontPage, StorefrontRouterProvider, StorefrontShell, StorefrontThemeStyle, StoryQuote, THEME_SCALE_FIELDS, THEME_SCALE_VAR_PREFIX, TID, Testimonials, TierCards, applyDeliveryPolicy, applyStoreSettings, bannerPlaceholder, blockInstanceId, buildEnquiryFromForm, checkPageBlocks, collectDataNeeds, collectOrderMetadata, contentPagePath, createStorefront, createStorefrontApp, currentStaticRenderPass, defaultPageBlocks, entityListBlockMeta, establishCustomerSession, exportStore, formatMoney, formatProductOptionSelection, getCartLineAnnotations, getCheckoutFieldContributions, getCustomerAuthAdapter, getProductCardBadges, getProductOptionGroups, hydrateStoreDocument, hydratedEntriesFor, initStorefrontRuntime, isJsonValue, isKnownPath, isNestedBlockRef, isPublicPath, isRecord, listSlots, marketForCountry, marketUnitPrice, matchContentPage, matchPath, matchesFacets, mergeCollectionFacet, mergePageTheme, navigateTo, nextMilestone, normalizeLanguage, normalizeProductOptionSelection, orderGalleryImages, overrideComponent, overrideProps, pageSeo, pageThemeSelector, pickProductCardImage, placeStorefrontOrder, prefersReducedMotion, primaryImageUrl, productCardComponentContract, productJsonLd, productOptionSelectionKey, productPlaceholder, productSeo, readHydratedPageData, registerStorefrontBlocks, registerStorefrontEntities, registerStorefrontExtensionPoints, registerStorefrontLoaders, resetPageDiagnostics, resetProductOptionsDeprecationWarnings, resetStorefrontExtensionPoints, resolveAuthAdapter, resolveConfig, resolveDataParams, resolveOverride, resolvePageData, resolvePageDataNeed, resolvePaymentTerms, resolveStorefrontProvider, resolveStorefrontRoute, resolveVariantForSelection, roundCents, routePathParams, runBeforePlaceOrderValve, sectionToJsonSchema, sectionsToBlocks, selectCount, selectDiscountTotal, selectIsOpen, selectRequiresShipping, selectShipping, selectShowsHours, selectSubtotal, selectTotal, selectionPrice, serializePageData, shellRouterAdapter, signInByEmail, signOutCustomer, signUpCustomer, slugifyStoreName, storefrontComponentContracts, storefrontPaths, themeToCss, toBlockNodes, toFacetMap, translate, useBlockData, useBuyerCountry, useBuyerStore, useCartStore, useCatalogStore, useCategories, useDeliveryStore, useDiscountValidator, useEnquiry, useHashPath, useInView, useLoader, useMarketProduct, useMarketStore, useMyOrders, useNavigate, usePopOnChange, useProduct, useProducts, useRoutePath, useRouterAdapter, useScrollToTopOnNavigate, useScrolled, useServiceStore, useSessionStore, useSlotContext, useStorefrontActions, useStorefrontConfig, useStorefrontConfigOptional, useStorefrontHead, useStorefrontPage, useStorefrontPageOptional, useT, usedSlots, validateStore, withFacet, withMarketPrice, withStaticRenderPass };
14750
- //# sourceMappingURL=chunk-OK5U3JNM.js.map
14751
- //# sourceMappingURL=chunk-OK5U3JNM.js.map
14796
+ //# sourceMappingURL=chunk-AUARAE26.js.map
14797
+ //# sourceMappingURL=chunk-AUARAE26.js.map