@fayz-ai/storefront 0.8.3 → 0.8.4

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":"StorefrontHeader.d.ts","sourceRoot":"","sources":["../../src/components/StorefrontHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AA0SvC,wBAAgB,gBAAgB,sBA2E/B"}
1
+ {"version":3,"file":"StorefrontHeader.d.ts","sourceRoot":"","sources":["../../src/components/StorefrontHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AA0YvC,wBAAgB,gBAAgB,sBAkF/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"createStorefrontApp.d.ts","sourceRoot":"","sources":["../src/createStorefrontApp.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAG1D,OAAO,KAAK,EAAE,gBAAgB,EAA4B,MAAM,UAAU,CAAA;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AA2GnD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAmCpE;AAED;gFACgF;AAChF,wBAAgB,eAAe,sBAkC9B;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,KAAK,CAAC,aAAa,CAajF;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"}
1
+ {"version":3,"file":"createStorefrontApp.d.ts","sourceRoot":"","sources":["../src/createStorefrontApp.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAG1D,OAAO,KAAK,EAAE,gBAAgB,EAA4B,MAAM,UAAU,CAAA;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AA+GnD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAmCpE;AAED;gFACgF;AAChF,wBAAgB,eAAe,sBAkC9B;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,KAAK,CAAC,aAAa,CAajF;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"}
package/dist/index.cjs CHANGED
@@ -932,7 +932,7 @@ function SearchInput({ className, iconOnly = false }) {
932
932
  )
933
933
  ] });
934
934
  }
935
- function HeaderActions() {
935
+ function HeaderActions({ onMenuClick }) {
936
936
  const config = useStorefrontConfig();
937
937
  const count = useCartStore(selectCount);
938
938
  const openDrawer = useCartStore((s) => s.openDrawer);
@@ -1030,6 +1030,16 @@ function HeaderActions() {
1030
1030
  )
1031
1031
  ]
1032
1032
  }
1033
+ ),
1034
+ onMenuClick && /* @__PURE__ */ jsxRuntime.jsx(
1035
+ "button",
1036
+ {
1037
+ type: "button",
1038
+ "aria-label": "Abrir menu",
1039
+ onClick: onMenuClick,
1040
+ className: "relative rounded-full p-2.5 transition-opacity hover:opacity-70 md:hidden",
1041
+ children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.Menu, { className: "h-5 w-5" })
1042
+ }
1033
1043
  )
1034
1044
  ] });
1035
1045
  }
@@ -1070,12 +1080,94 @@ function NavLinks({ className }) {
1070
1080
  ))
1071
1081
  ] });
1072
1082
  }
1083
+ function MobileMenuDrawer({ open, onClose }) {
1084
+ const config = useStorefrontConfig();
1085
+ const { categories } = useCategories();
1086
+ const setCategoryId = useCatalogStore((s) => s.setCategoryId);
1087
+ const showCategories = config.theme?.header?.showCategories !== false;
1088
+ const goCategory = (categoryId) => {
1089
+ useCatalogStore.getState().reset();
1090
+ setCategoryId(categoryId);
1091
+ navigateTo(config.catalogPath);
1092
+ onClose();
1093
+ };
1094
+ React7__default.default.useEffect(() => {
1095
+ if (!open) return;
1096
+ const onKey = (e) => {
1097
+ if (e.key === "Escape") onClose();
1098
+ };
1099
+ document.addEventListener("keydown", onKey);
1100
+ return () => document.removeEventListener("keydown", onKey);
1101
+ }, [open, onClose]);
1102
+ if (!open) return null;
1103
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fixed inset-0 z-50 md:hidden", children: [
1104
+ /* @__PURE__ */ jsxRuntime.jsx(
1105
+ "div",
1106
+ {
1107
+ className: "absolute inset-0 animate-fade-in bg-black/40",
1108
+ "aria-hidden": true,
1109
+ onClick: onClose
1110
+ }
1111
+ ),
1112
+ /* @__PURE__ */ jsxRuntime.jsxs(
1113
+ "div",
1114
+ {
1115
+ "data-testid": "mobile-menu-drawer",
1116
+ role: "dialog",
1117
+ "aria-label": "Menu Principal",
1118
+ className: "absolute right-0 top-0 flex h-full w-full max-w-[280px] animate-slide-in-from-right flex-col bg-background shadow-2xl",
1119
+ children: [
1120
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between border-b px-5 py-4", children: [
1121
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-semibold", children: "Menu" }),
1122
+ /* @__PURE__ */ jsxRuntime.jsx(
1123
+ "button",
1124
+ {
1125
+ type: "button",
1126
+ "aria-label": "Fechar menu",
1127
+ onClick: onClose,
1128
+ className: "rounded-full p-1.5 hover:bg-muted",
1129
+ children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.X, { className: "h-5 w-5" })
1130
+ }
1131
+ )
1132
+ ] }),
1133
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-y-auto p-5", children: /* @__PURE__ */ jsxRuntime.jsxs("nav", { className: "flex flex-col gap-4", children: [
1134
+ config.nav.map((link) => /* @__PURE__ */ jsxRuntime.jsx(
1135
+ Link,
1136
+ {
1137
+ to: link.to,
1138
+ onClick: onClose,
1139
+ className: "text-base font-semibold transition-opacity hover:opacity-70",
1140
+ children: link.label
1141
+ },
1142
+ link.to
1143
+ )),
1144
+ showCategories && categories.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1145
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-2 border-t" }),
1146
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-2 text-xs font-bold uppercase tracking-wider text-muted-foreground", children: "Categorias" }),
1147
+ categories.map((c) => /* @__PURE__ */ jsxRuntime.jsx(
1148
+ "button",
1149
+ {
1150
+ type: "button",
1151
+ onClick: () => goCategory(c.id),
1152
+ className: "text-left text-sm font-medium transition-opacity hover:opacity-80",
1153
+ children: c.name
1154
+ },
1155
+ c.id
1156
+ ))
1157
+ ] })
1158
+ ] }) })
1159
+ ]
1160
+ }
1161
+ )
1162
+ ] });
1163
+ }
1073
1164
  function StorefrontHeader() {
1074
1165
  const config = useStorefrontConfig();
1075
1166
  const variant = config.theme?.header?.variant ?? "classic";
1076
1167
  const scrolled = useScrolled();
1077
1168
  const showSearch = config.theme?.header?.showSearch !== false;
1078
1169
  const iconSearch = config.theme?.header?.searchStyle === "icon";
1170
+ const [mobileMenuOpen, setMobileMenuOpen] = React7.useState(false);
1079
1171
  const logo = /* @__PURE__ */ jsxRuntime.jsx(Link, { to: "/", className: "sf-heading shrink-0 text-xl font-bold tracking-tight", children: config.logo ?? config.name });
1080
1172
  return /* @__PURE__ */ jsxRuntime.jsxs(
1081
1173
  "header",
@@ -1116,14 +1208,20 @@ function StorefrontHeader() {
1116
1208
  ] })
1117
1209
  ] })
1118
1210
  ) : (
1119
- // classic: logo left, nav, then a right-aligned search + actions cluster
1120
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mx-auto flex h-16 max-w-7xl items-center gap-6 px-4 sm:px-6", children: [
1121
- logo,
1122
- /* @__PURE__ */ jsxRuntime.jsx(NavLinks, { className: "hidden md:flex" }),
1123
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-auto flex items-center gap-2 sm:gap-3", children: [
1124
- showSearch && /* @__PURE__ */ jsxRuntime.jsx(SearchInput, { iconOnly: iconSearch, className: iconSearch ? "" : "hidden w-full max-w-sm sm:block" }),
1125
- /* @__PURE__ */ jsxRuntime.jsx(HeaderActions, {})
1126
- ] })
1211
+ // classic: logo left, nav, then a right-aligned search + actions cluster.
1212
+ // NavLinks is hidden below md in the primary row (no room for it there)
1213
+ // below md a hamburger opens MobileMenuDrawer instead, otherwise mobile
1214
+ // has no way to reach nav/category links at all.
1215
+ /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1216
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mx-auto flex h-16 max-w-7xl items-center gap-6 px-4 sm:px-6", children: [
1217
+ logo,
1218
+ /* @__PURE__ */ jsxRuntime.jsx(NavLinks, { className: "hidden md:flex" }),
1219
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-auto flex items-center gap-2 sm:gap-3", children: [
1220
+ showSearch && /* @__PURE__ */ jsxRuntime.jsx(SearchInput, { iconOnly: iconSearch, className: iconSearch ? "" : "hidden w-full max-w-sm sm:block" }),
1221
+ /* @__PURE__ */ jsxRuntime.jsx(HeaderActions, { onMenuClick: () => setMobileMenuOpen(true) })
1222
+ ] })
1223
+ ] }),
1224
+ /* @__PURE__ */ jsxRuntime.jsx(MobileMenuDrawer, { open: mobileMenuOpen, onClose: () => setMobileMenuOpen(false) })
1127
1225
  ] })
1128
1226
  )
1129
1227
  ]
@@ -3727,7 +3825,7 @@ function CheckoutPage() {
3727
3825
  ];
3728
3826
  const minDuration = sleep(stepMs * 2);
3729
3827
  try {
3730
- const { order } = await placeStorefrontOrder({
3828
+ const { order, customerId } = await placeStorefrontOrder({
3731
3829
  config,
3732
3830
  cart,
3733
3831
  session,
@@ -3750,6 +3848,7 @@ function CheckoutPage() {
3750
3848
  // declare it settled. The order is now born `pending` and only the
3751
3849
  // merchant (or a PSP webhook) can confirm the money arrived.
3752
3850
  });
3851
+ if (customerId) session.setSession({ customerId, email: form.email, name: form.name });
3753
3852
  await minDuration;
3754
3853
  cart.clear();
3755
3854
  navigateTo(`/order/${order.id}`);
@@ -4853,6 +4952,10 @@ function storefrontDiscountToSeed(discount) {
4853
4952
  value: discount.percent,
4854
4953
  usageLimit: null,
4855
4954
  oncePerCustomer: false,
4955
+ minSubtotal: null,
4956
+ appliesTo: "all",
4957
+ productIds: [],
4958
+ categoryIds: [],
4856
4959
  startsAt: ts,
4857
4960
  endsAt: null,
4858
4961
  status: "active",