@osimart/create-storefront 1.0.10 → 1.0.12

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.
@@ -63,7 +63,11 @@ export function useMenu() {
63
63
  */
64
64
  function normalizeItems(items = [], parentId = "m") {
65
65
  return items.map((item, index) => {
66
- const url = itemUrl(item);
66
+ // An External URL left empty links nowhere: "#", which every menu draws
67
+ // as a toggle for its sub-items (or a plain label), never a link.
68
+ // itemUrl() alone would fall through to "/".
69
+ const noLink = item.link_type === "URL" && !String(item.url ?? "").trim();
70
+ const url = noLink ? "#" : itemUrl(item);
67
71
  const id = item.id ?? `${parentId}.${index}`;
68
72
  return {
69
73
  id,
@@ -336,6 +336,27 @@ export default function useLogic({ props }) {
336
336
  ...(bottomThreeZone.value || bottomStacked.value ? {} : { justifyContent: bottomAlignment.value }),
337
337
  }));
338
338
 
339
+ /**
340
+ * Utilities drawn from the block tree (FooterUtilitiesSection's barTree):
341
+ * whether a part has anything to show. A Group shows while any part inside
342
+ * it does, so separators and empty groups never dangle.
343
+ */
344
+ function partShown(node) {
345
+ if (!node) return false;
346
+ switch (node.type) {
347
+ case "GROUP":
348
+ return (node.children ?? []).some(partShown);
349
+ case "UTILITY_COPYRIGHT":
350
+ return true;
351
+ case "UTILITY_POLICIES":
352
+ return policyLinks.value.length > 0;
353
+ case "UTILITY_SOCIAL":
354
+ return (unref(socials)?.length ?? 0) > 0;
355
+ default:
356
+ return false;
357
+ }
358
+ }
359
+
339
360
  const showPoweredBy = computed(() => settings.value.FOOTER_SHOW_POWERED_BY !== false);
340
361
  const poweredByText = computed(() => t(settings.value.FOOTER_POWERED_BY_TEXT));
341
362
  // Plain text between the copyright and the link — not part of the link.
@@ -472,5 +493,5 @@ export default function useLogic({ props }) {
472
493
  const headingTextStyle = computed(() => textStyleVars("FOOTER_HEADING", "UPPERCASE"));
473
494
  const linkTextStyle = computed(() => textStyleVars("FOOTER_LINK", "NONE"));
474
495
 
475
- return { isBar, utilityBlocks, settings, brand, pick, barScheme, scheme, appearance, store, storeLogo, mediaUrl, useMenuByHandle, t, menu1, menu2, menu3, columnWidthMode, columnFlexBasis, columns, logoSrc, logoPosition, logoAlignment, logoWidthVars, showBrandDescription, DESCRIPTION_ALIGNMENTS, brandDescriptionStyle, footerText, copyright, socials, socialsEnabled, socialPosition, paymentIcons, languages, countries, currentLanguage, currentCountry, showSocial, socialAlignment, showNewsletter, newsletterOnStart, newsletterStacked, newsletterAlignment, showConsent, newsletterSubmitted, handleNewsletterSubmit, newsletterSuccessMessage, showPaymentIcons, showLanguageSelector, showCountrySelector, containerStyle, footerStyle, columnsAlignment, columnsVerticalAlignment, columnTextAlignment, JUSTIFY, ALIGN, TEXT, bottomAlignment, showBottomBarDivider, bottomThreeZone, bottomStacked, px, barVars, policyClasses, policyStyle, copyrightStyle, orderStyle, barStyle, showPoweredBy, poweredByText, poweredByPrefix, copyrightGap, poweredByUrl, POLICY_SLOTS, policyLinks, socialsInBar, socialsInColumns, socialsUnderNewsletter, hasFooterContent, mobileAccordion, openColumns, toggleColumn, isColumnOpen, FONT_WEIGHTS, FONT_FAMILIES, TEXT_TRANSFORMS, textStyleVars, headingTextStyle, linkTextStyle };
476
- }
496
+ return { isBar, utilityBlocks, settings, brand, pick, barScheme, scheme, appearance, store, storeLogo, mediaUrl, useMenuByHandle, t, menu1, menu2, menu3, columnWidthMode, columnFlexBasis, columns, logoSrc, logoPosition, logoAlignment, logoWidthVars, showBrandDescription, DESCRIPTION_ALIGNMENTS, brandDescriptionStyle, footerText, copyright, socials, socialsEnabled, socialPosition, paymentIcons, languages, countries, currentLanguage, currentCountry, showSocial, socialAlignment, showNewsletter, newsletterOnStart, newsletterStacked, newsletterAlignment, showConsent, newsletterSubmitted, handleNewsletterSubmit, newsletterSuccessMessage, showPaymentIcons, showLanguageSelector, showCountrySelector, containerStyle, footerStyle, columnsAlignment, columnsVerticalAlignment, columnTextAlignment, JUSTIFY, ALIGN, TEXT, bottomAlignment, showBottomBarDivider, bottomThreeZone, bottomStacked, px, barVars, policyClasses, policyStyle, copyrightStyle, orderStyle, barStyle, showPoweredBy, poweredByText, poweredByPrefix, copyrightGap, poweredByUrl, POLICY_SLOTS, policyLinks, socialsInBar, socialsInColumns, socialsUnderNewsletter, hasFooterContent, partShown, mobileAccordion, openColumns, toggleColumn, isColumnOpen, FONT_WEIGHTS, FONT_FAMILIES, TEXT_TRANSFORMS, textStyleVars, headingTextStyle, linkTextStyle };
497
+ }
@@ -1,9 +1,67 @@
1
1
  import { NuxtLink } from "#components";
2
2
  import { Autoplay, Pagination } from "swiper/modules";
3
3
 
4
+ /**
5
+ * GALLERY, Shopify-style:
6
+ *
7
+ * section the frame — width, padding, colours, CONTENT_GAP
8
+ * header blocks ordinary blocks (a Group of Text / Button…), drawn by
9
+ * ContentNode wherever they sit
10
+ * Images block GALLERY_CONTENT: the layout (grid / masonry /
11
+ * carousel / marquee + every image setting) and, inside
12
+ * it, the Image (MEDIA) blocks. Where it sits among the
13
+ * blocks is where the images go; hiding it hides them.
14
+ *
15
+ * An older section (no Images block: heading and layout on the section,
16
+ * images at the top level) renders exactly as before.
17
+ */
4
18
  export default function useLogic({ props }) {
5
- const { s, t, shellStyle, innerStyle, align, customClass, heading } = useSectionShell(() => props.section);
19
+ const { s: sectionSettings, t, shellStyle, innerStyle, align, customClass, heading: legacyHeadingText } =
20
+ useSectionShell(() => props.section);
6
21
  const { mediaUrl } = useMediaUrl();
22
+
23
+ const blocks = computed(() => props.section.blocks ?? []);
24
+ const contentBlock = computed(() => blocks.value.find((b) => b.type === "GALLERY_CONTENT") ?? null);
25
+ const legacy = computed(() => !contentBlock.value);
26
+
27
+ /** The gallery's own settings: the Images block's, or (older) the section's. */
28
+ const s = computed(() => (legacy.value ? sectionSettings.value : contentBlock.value.settings ?? {}));
29
+
30
+ /** The image blocks, in order. */
31
+ const mediaBlocks = computed(() => {
32
+ if (legacy.value) return blocks.value.filter((b) => b.type === "MEDIA" && !b.parent_key);
33
+ const key = contentBlock.value.key;
34
+ return blocks.value.filter((b) => b.type === "MEDIA" && b.parent_key === key);
35
+ });
36
+
37
+ // The header and anything else around the images: ordinary blocks. The
38
+ // Images block stays a plain node (raw) — this section draws it.
39
+ const { tree } = useContentTree(() => props.section, {
40
+ raw: ["GALLERY_CONTENT"],
41
+ rootDefaults: { DIRECTION: "VERTICAL", GAP: 24 },
42
+ index: () => props.index,
43
+ });
44
+
45
+ /** The page, in block order; the images go where the Images block is. */
46
+ const parts = computed(() => {
47
+ if (legacy.value) return [{ kind: "gallery", key: "gallery" }];
48
+ return tree.value.children.map((node) =>
49
+ node.type === "GALLERY_CONTENT"
50
+ ? { kind: "gallery", key: node.key }
51
+ : { kind: "block", key: node.key, node }
52
+ );
53
+ });
54
+
55
+ /** data-osi-block for the images area (the editor outlines / selects it). */
56
+ const contentKey = computed(() => contentBlock.value?.key || undefined);
57
+
58
+ const stackGap = computed(() => {
59
+ const n = Number(sectionSettings.value.CONTENT_GAP);
60
+ return `${Number.isFinite(n) && sectionSettings.value.CONTENT_GAP !== "" ? n : 24}px`;
61
+ });
62
+
63
+ // Older sections: their HEADING / SUBHEADING, until they're converted.
64
+ const heading = computed(() => (legacy.value ? legacyHeadingText.value : ""));
7
65
  const placeholders = usePlaceholders();
8
66
  const NuxtLinkComponent = NuxtLink;
9
67
 
@@ -16,13 +74,15 @@ export default function useLogic({ props }) {
16
74
  const TILE_SIZES = ["NORMAL", "TALL", "WIDE", "LARGE"];
17
75
 
18
76
  const items = computed(() => {
19
- const rows = (props.section.blocks ?? [])
77
+ const rows = mediaBlocks.value
20
78
  .filter((block) => !block.disabled)
21
79
  .map((block) => {
22
80
  const bs = block.settings ?? {};
23
81
  const media = bs.MEDIA ?? block.media ?? block.relations?.media ?? bs.IMAGE ?? null;
24
82
  return {
25
83
  key: block.id ?? block.key,
84
+ // The block's key, for the editor overlay (data-osi-block).
85
+ blockKey: block.key || undefined,
26
86
  src: mediaUrl(media),
27
87
  caption: t(bs.CAPTION) || "",
28
88
  url: bs.URL || bs.LINK_URL || null,
@@ -115,7 +175,7 @@ export default function useLogic({ props }) {
115
175
  () => layout.value === "GRID" && !isNatural.value && items.value.some((i) => i.size !== "NORMAL")
116
176
  );
117
177
 
118
- const subheading = computed(() => t(s.value.SUBHEADING));
178
+ const subheading = computed(() => (legacy.value ? t(sectionSettings.value.SUBHEADING) : ""));
119
179
  const showCaptions = computed(() => !!s.value.SHOW_CAPTIONS);
120
180
  const captionOverlay = computed(() => String(s.value.CAPTION_POSITION || "BELOW").toUpperCase() === "OVERLAY");
121
181
 
@@ -228,5 +288,5 @@ export default function useLogic({ props }) {
228
288
 
229
289
  const current = computed(() => (openIndex.value === null ? null : realItems.value[openIndex.value]));
230
290
 
231
- return { s, t, shellStyle, innerStyle, align, customClass, heading, mediaUrl, placeholders, NuxtLinkComponent, has, num, px, TILE_SIZES, items, layout, marqueeTrack, marqueeVars, MQ_ALIGN, marqueeMode, marqueeSizeBy, marqueeWidths, marqueeReverse, marqueePause, RATIOS, RATIO_PARTS, TILE_SPANS, isNatural, bento, subheading, showCaptions, captionOverlay, vars, rootClasses, perView, overflows, loop, slides, onSwiper, onSlideChange, goPrev, goNext, isBeginning, isEnd, breakpoints, autoplay, showArrows, showDots, lightboxEnabled, realItems, openIndex, isOpen, tagFor, open, close, step, onKeydown, current, Autoplay, Pagination };
232
- }
291
+ return { legacy, contentBlock, contentKey, parts, stackGap, s, t, shellStyle, innerStyle, align, customClass, heading, mediaUrl, placeholders, NuxtLinkComponent, has, num, px, TILE_SIZES, items, layout, marqueeTrack, marqueeVars, MQ_ALIGN, marqueeMode, marqueeSizeBy, marqueeWidths, marqueeReverse, marqueePause, RATIOS, RATIO_PARTS, TILE_SPANS, isNatural, bento, subheading, showCaptions, captionOverlay, vars, rootClasses, perView, overflows, loop, slides, onSwiper, onSlideChange, goPrev, goNext, isBeginning, isEnd, breakpoints, autoplay, showArrows, showDots, lightboxEnabled, realItems, openIndex, isOpen, tagFor, open, close, step, onKeydown, current, Autoplay, Pagination };
292
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimart/create-storefront",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Osimart storefront platform — logic, platform pages and CLI; extended by every theme repo",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",