@fayz-ai/storefront 0.19.1 → 0.21.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.
@@ -1 +1 @@
1
- {"version":3,"file":"createStorefrontApp.d.ts","sourceRoot":"","sources":["../../src/app/createStorefrontApp.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAM1D,OAAO,KAAK,EAAE,gBAAgB,EAA4B,MAAM,oBAAoB,CAAA;AACpF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAU3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AA0JlD;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAIzE;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,gBAAgB,GAAG,YAAY,CAEhF;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CA8CpE;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;gFACgF;AAChF,wBAAgB,eAAe,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,GAAE,oBAAyB,qBAcxF;AAgDD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,KAAK,CAAC,aAAa,CAiBjF;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,gBAAgB,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,UAAU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AAM,EAAE,gBAAgB,GAAG,KAAK,CAAC,aAAa,CAiBjF;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,gBAAgB,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,UAAU,CAAC,EAAE,oBAAoB,CAAA;IACjC,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IACnC,KAAK,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IAClC,QAAQ,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAA;CACxC;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,KAAK,CAAC,aAAa,CAgBtF"}
@@ -0,0 +1,26 @@
1
+ import type { useStorefrontConfig } from '../document/config';
2
+ type Config = ReturnType<typeof useStorefrontConfig>;
3
+ /**
4
+ * Onde "voltar" volta.
5
+ *
6
+ * O checkout mandava sempre para `catalogPath`, e no modo delivery isso é uma
7
+ * página que a pessoa nunca viu: ela veio do cardápio, clicou em voltar, e
8
+ * caiu numa grade de produtos com facetas. Não é um erro de rótulo — é perder
9
+ * o lugar de alguém no meio de uma compra.
10
+ *
11
+ * Guardado por sessão e não derivado do modo: no delivery as DUAS telas
12
+ * existem (`/delivery` e `/catalog`), então o modo sozinho não sabe de qual
13
+ * delas a pessoa saiu. A sessão sabe.
14
+ */
15
+ export declare function rememberReturnPath(path: string): void;
16
+ /**
17
+ * A superfície de compra para onde voltar.
18
+ *
19
+ * Sem nada guardado — primeira carga direto no /checkout, SSR, storage
20
+ * bloqueado — cai para o cardápio quando a loja está em modo delivery e para o
21
+ * catálogo quando não está: o padrão certo para cada loja, em vez de um só para
22
+ * as duas.
23
+ */
24
+ export declare function returnPath(config: Config): string;
25
+ export {};
26
+ //# sourceMappingURL=return-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"return-path.d.ts","sourceRoot":"","sources":["../../src/app/return-path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE7D,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAIpD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAOrD;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAUjD"}
@@ -7696,6 +7696,26 @@ function useMyOrders() {
7696
7696
  }, [customerId, email, tick]);
7697
7697
  return { orders, loading, refresh };
7698
7698
  }
7699
+
7700
+ // src/app/return-path.ts
7701
+ var KEY2 = "fayz:sf:return-path";
7702
+ function rememberReturnPath(path) {
7703
+ try {
7704
+ if (typeof sessionStorage === "undefined") return;
7705
+ sessionStorage.setItem(KEY2, path);
7706
+ } catch {
7707
+ }
7708
+ }
7709
+ function returnPath(config) {
7710
+ try {
7711
+ if (typeof sessionStorage !== "undefined") {
7712
+ const remembered = sessionStorage.getItem(KEY2);
7713
+ if (remembered) return remembered;
7714
+ }
7715
+ } catch {
7716
+ }
7717
+ return config.delivery?.menuPath ?? config.catalogPath;
7718
+ }
7699
7719
  function SignInModal({ defaultEmail = "", onClose, onSignedIn }) {
7700
7720
  const [email, setEmail] = useState(defaultEmail);
7701
7721
  const [password, setPassword] = useState("");
@@ -8854,6 +8874,28 @@ function CheckoutPage() {
8854
8874
  cancelled = true;
8855
8875
  };
8856
8876
  }, [session.customerId]);
8877
+ useEffect(() => {
8878
+ const customerId = session.customerId;
8879
+ if (!customerId) return;
8880
+ const provider = getShopProvider();
8881
+ const getCustomer = provider.getCustomer?.bind(provider);
8882
+ if (!getCustomer) return;
8883
+ let cancelled = false;
8884
+ void getCustomer(customerId).then((customer) => {
8885
+ if (cancelled || !customer) return;
8886
+ setForm((current) => ({
8887
+ ...current,
8888
+ phone: current.phone || customer.phone || "",
8889
+ document: current.document || customer.document || "",
8890
+ email: current.email || customer.email || "",
8891
+ name: current.name || [customer.firstName, customer.lastName].filter(Boolean).join(" ").trim()
8892
+ }));
8893
+ }).catch(() => {
8894
+ });
8895
+ return () => {
8896
+ cancelled = true;
8897
+ };
8898
+ }, [session.customerId]);
8857
8899
  useEffect(() => {
8858
8900
  if (addressMode !== "new") return;
8859
8901
  const kept = delivery.savedAddresses.find((a) => a.id === delivery.selectedAddressId);
@@ -9089,7 +9131,7 @@ function CheckoutPage() {
9089
9131
  }
9090
9132
  ),
9091
9133
  /* @__PURE__ */ jsx("header", { className: "border-b bg-background", children: /* @__PURE__ */ jsxs("div", { className: "mx-auto flex max-w-6xl items-center justify-between gap-4 px-4 py-6 sm:px-6", children: [
9092
- /* @__PURE__ */ jsx(Link, { to: config.catalogPath, className: "text-sm text-muted-foreground hover:text-foreground", children: "Voltar \xE0 loja" }),
9134
+ /* @__PURE__ */ jsx(Link, { to: returnPath(config), className: "text-sm text-muted-foreground hover:text-foreground", children: "Voltar \xE0 loja" }),
9093
9135
  /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
9094
9136
  /* @__PURE__ */ jsx("div", { className: "sf-heading text-2xl font-bold tracking-tight", children: config.logo ?? config.name }),
9095
9137
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex items-center justify-center gap-2 text-xs text-muted-foreground", children: [
@@ -9396,7 +9438,7 @@ function CheckoutPage() {
9396
9438
  children: "Voltar aos dados"
9397
9439
  }
9398
9440
  ),
9399
- /* @__PURE__ */ jsx(Link, { to: config.catalogPath, className: "text-center text-sm text-muted-foreground hover:text-foreground", children: "Voltar ao carrinho" })
9441
+ /* @__PURE__ */ jsx(Link, { to: returnPath(config), className: "text-center text-sm text-muted-foreground hover:text-foreground", children: "Voltar ao carrinho" })
9400
9442
  ] })
9401
9443
  ]
9402
9444
  }
@@ -11751,6 +11793,10 @@ function routeChrome(config, path) {
11751
11793
  function RouteSwitch({ path }) {
11752
11794
  const config = useStorefrontConfig();
11753
11795
  const match = resolveStorefrontRoute(config, path);
11796
+ const isShopping = match.kind !== "checkout" && match.kind !== "order";
11797
+ useEffect(() => {
11798
+ if (isShopping) rememberReturnPath(path);
11799
+ }, [isShopping, path]);
11754
11800
  switch (match.kind) {
11755
11801
  case "custom": {
11756
11802
  const CustomRoute = match.route.component;
@@ -13249,5 +13295,5 @@ ${formatErrors(report.errors)}`;
13249
13295
  }
13250
13296
 
13251
13297
  export { AddressSheet, AddressStrip, BEFORE_PLACE_ORDER_VALVE, BLOCK_STRUCTURAL_KEYS, BenefitsRow, BlockDataError, CART_LINE_ANNOTATION_POINT, CATALOG_BODY_BLOCK, CHECKOUT_FIELD_POINT, CartDrawer, CatalogPage, CategoryShowcase, CheckoutPage, ClosedStoreDialog, CollectionCta, CollectionHero, ContentPage, CountdownBand, EmailConfirmationRequiredError, EntityListBlock, FaqSection, FiltersPanel, FormBlock, HeroSection, ImageTiles, ItemSheet, Link, 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, 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, matchContentPage, matchPath, matchesFacets, mergeCollectionFacet, mergePageTheme, navigateTo, nextMilestone, 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, useBlockData, useCartStore, useCatalogStore, useCategories, useDeliveryStore, useDiscountValidator, useEnquiry, useHashPath, useInView, useLoader, useMyOrders, useNavigate, usePopOnChange, useProduct, useProducts, useRoutePath, useRouterAdapter, useScrollToTopOnNavigate, useScrolled, useServiceStore, useSessionStore, useSlotContext, useStorefrontActions, useStorefrontConfig, useStorefrontConfigOptional, useStorefrontHead, useStorefrontPage, useStorefrontPageOptional, usedSlots, validateStore, withFacet, withStaticRenderPass };
13252
- //# sourceMappingURL=chunk-77V5ZAF5.js.map
13253
- //# sourceMappingURL=chunk-77V5ZAF5.js.map
13298
+ //# sourceMappingURL=chunk-KHVM7LEC.js.map
13299
+ //# sourceMappingURL=chunk-KHVM7LEC.js.map