@opensite/ui 3.10.0 → 3.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/dist/registry.cjs CHANGED
@@ -27,6 +27,7 @@ var Autoplay = require('embla-carousel-autoplay');
27
27
  var ProgressPrimitive = require('@radix-ui/react-progress');
28
28
  var AvatarPrimitive = require('@radix-ui/react-avatar');
29
29
  var AutoScroll3 = require('embla-carousel-auto-scroll');
30
+ var mediaImmersive = require('@page-speed/media-immersive');
30
31
  var CheckboxPrimitive = require('@radix-ui/react-checkbox');
31
32
  var LabelPrimitive = require('@radix-ui/react-label');
32
33
  var socialShare = require('@page-speed/social-share');
@@ -35271,23 +35272,276 @@ function InteriorCarousel({
35271
35272
  }
35272
35273
  );
35273
35274
  }
35274
- function EngagementBadge({
35275
+ var IG_TILE_WIDTH = 320;
35276
+ var IG_TILE_STYLE = { width: "100%" };
35277
+ var TITLE_MAX = 90;
35278
+ function truncate(text, max = TITLE_MAX) {
35279
+ const trimmed = text.trim();
35280
+ if (trimmed.length <= max) return trimmed;
35281
+ const slice = trimmed.slice(0, max);
35282
+ const lastSpace = slice.lastIndexOf(" ");
35283
+ const head = lastSpace > max * 0.6 ? slice.slice(0, lastSpace) : slice;
35284
+ return `${head.trimEnd()}\u2026`;
35285
+ }
35286
+ function captionToString(caption) {
35287
+ return typeof caption === "string" ? caption : "";
35288
+ }
35289
+ function toMediaItem(item) {
35290
+ const isVideo = Boolean(item.isVideo && item.videoUrl);
35291
+ const fullCaption = captionToString(item.caption);
35292
+ const title = truncate(fullCaption) || item.imageAlt || "Instagram post";
35293
+ const meta = {
35294
+ href: item.href,
35295
+ likeCount: item.likeCount,
35296
+ commentCount: item.commentCount,
35297
+ viewCount: item.viewCount,
35298
+ date: item.date
35299
+ };
35300
+ return {
35301
+ id: item.id,
35302
+ type: isVideo ? "video" : "image",
35303
+ poster: item.image,
35304
+ // Video source only when the post is a real video (image posts ignore it).
35305
+ src: isVideo ? item.videoUrl : void 0,
35306
+ title,
35307
+ caption: fullCaption || void 0,
35308
+ kind: "Instagram",
35309
+ meta
35310
+ };
35311
+ }
35312
+ function openPermalink(item) {
35313
+ if (typeof window === "undefined") return;
35314
+ const href = item.meta?.href;
35315
+ if (!href) return;
35316
+ window.open(href, "_blank", "noopener,noreferrer");
35317
+ }
35318
+ function likeBadge(likeCount) {
35319
+ return /* @__PURE__ */ jsxRuntime.jsxs(
35320
+ "span",
35321
+ {
35322
+ "aria-label": `${likeCount.toLocaleString()} likes`,
35323
+ style: {
35324
+ display: "inline-flex",
35325
+ alignItems: "center",
35326
+ gap: 4,
35327
+ padding: "3px 8px",
35328
+ borderRadius: 999,
35329
+ background: "rgba(8,12,24,0.65)",
35330
+ backdropFilter: "blur(6px)",
35331
+ WebkitBackdropFilter: "blur(6px)",
35332
+ color: "#fff",
35333
+ fontSize: 11,
35334
+ fontWeight: 700,
35335
+ lineHeight: 1
35336
+ },
35337
+ children: [
35338
+ /* @__PURE__ */ jsxRuntime.jsx(DynamicIcon, { name: "lucide/heart", size: 13, "aria-hidden": "true" }),
35339
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: likeCount.toLocaleString() })
35340
+ ]
35341
+ }
35342
+ );
35343
+ }
35344
+ var VIEWER_ACTIONS = [
35345
+ {
35346
+ id: "open-in-instagram",
35347
+ icon: /* @__PURE__ */ jsxRuntime.jsx(DynamicIcon, { name: "lucide/external-link", size: 22, "aria-hidden": "true" }),
35348
+ label: "Instagram",
35349
+ ariaLabel: "Open in Instagram",
35350
+ onPress: (item) => openPermalink(item)
35351
+ }
35352
+ ];
35353
+ function RailStat({
35275
35354
  iconName,
35276
35355
  count,
35277
- label
35356
+ label,
35357
+ onPress
35278
35358
  }) {
35279
35359
  return /* @__PURE__ */ jsxRuntime.jsxs(
35280
- "span",
35360
+ "button",
35281
35361
  {
35282
- className: "inline-flex items-center gap-1",
35362
+ type: "button",
35283
35363
  "aria-label": `${count.toLocaleString()} ${label}`,
35364
+ onClick: (e) => {
35365
+ e.stopPropagation();
35366
+ onPress();
35367
+ },
35368
+ style: {
35369
+ display: "flex",
35370
+ flexDirection: "column",
35371
+ alignItems: "center",
35372
+ gap: 5,
35373
+ padding: 0,
35374
+ border: "none",
35375
+ background: "transparent",
35376
+ color: "inherit",
35377
+ cursor: "pointer",
35378
+ font: "inherit"
35379
+ },
35284
35380
  children: [
35285
- /* @__PURE__ */ jsxRuntime.jsx(DynamicIcon, { name: iconName, size: 16, "aria-hidden": "true" }),
35286
- /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: count.toLocaleString() })
35381
+ /* @__PURE__ */ jsxRuntime.jsx(
35382
+ "span",
35383
+ {
35384
+ style: {
35385
+ width: 46,
35386
+ height: 46,
35387
+ borderRadius: "50%",
35388
+ background: "var(--psmi-chrome-bg, rgba(255,255,255,0.14))",
35389
+ backdropFilter: "blur(6px)",
35390
+ WebkitBackdropFilter: "blur(6px)",
35391
+ display: "flex",
35392
+ alignItems: "center",
35393
+ justifyContent: "center"
35394
+ },
35395
+ children: /* @__PURE__ */ jsxRuntime.jsx(DynamicIcon, { name: iconName, size: 22, "aria-hidden": "true" })
35396
+ }
35397
+ ),
35398
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", style: { fontSize: 11, fontWeight: 600 }, children: count.toLocaleString() })
35287
35399
  ]
35288
35400
  }
35289
35401
  );
35290
35402
  }
35403
+ function InstagramViewerRail({ item }) {
35404
+ const meta = item.meta ?? {};
35405
+ const open = () => openPermalink(item);
35406
+ return /* @__PURE__ */ jsxRuntime.jsxs(
35407
+ "div",
35408
+ {
35409
+ style: {
35410
+ position: "absolute",
35411
+ right: 11,
35412
+ bottom: 135,
35413
+ display: "flex",
35414
+ flexDirection: "column",
35415
+ alignItems: "center",
35416
+ gap: 18,
35417
+ color: "var(--psmi-chrome-fg, #fff)",
35418
+ zIndex: 3
35419
+ },
35420
+ children: [
35421
+ typeof meta.likeCount === "number" ? /* @__PURE__ */ jsxRuntime.jsx(
35422
+ RailStat,
35423
+ {
35424
+ iconName: "lucide/heart",
35425
+ count: meta.likeCount,
35426
+ label: "likes",
35427
+ onPress: open
35428
+ }
35429
+ ) : null,
35430
+ typeof meta.commentCount === "number" ? /* @__PURE__ */ jsxRuntime.jsx(
35431
+ RailStat,
35432
+ {
35433
+ iconName: "lucide/message-circle",
35434
+ count: meta.commentCount,
35435
+ label: "comments",
35436
+ onPress: open
35437
+ }
35438
+ ) : null,
35439
+ typeof meta.viewCount === "number" ? /* @__PURE__ */ jsxRuntime.jsx(
35440
+ RailStat,
35441
+ {
35442
+ iconName: "lucide/eye",
35443
+ count: meta.viewCount,
35444
+ label: "views",
35445
+ onPress: open
35446
+ }
35447
+ ) : null,
35448
+ meta.href ? /* @__PURE__ */ jsxRuntime.jsxs(
35449
+ "a",
35450
+ {
35451
+ href: meta.href,
35452
+ target: "_blank",
35453
+ rel: "noopener noreferrer",
35454
+ "aria-label": "Open in Instagram",
35455
+ onClick: (e) => e.stopPropagation(),
35456
+ style: {
35457
+ display: "flex",
35458
+ flexDirection: "column",
35459
+ alignItems: "center",
35460
+ gap: 5,
35461
+ padding: 0,
35462
+ border: "none",
35463
+ background: "transparent",
35464
+ color: "inherit",
35465
+ cursor: "pointer",
35466
+ font: "inherit",
35467
+ textDecoration: "none"
35468
+ },
35469
+ children: [
35470
+ /* @__PURE__ */ jsxRuntime.jsx(
35471
+ "span",
35472
+ {
35473
+ style: {
35474
+ width: 46,
35475
+ height: 46,
35476
+ borderRadius: "50%",
35477
+ background: "var(--psmi-chrome-bg, rgba(255,255,255,0.14))",
35478
+ backdropFilter: "blur(6px)",
35479
+ WebkitBackdropFilter: "blur(6px)",
35480
+ display: "flex",
35481
+ alignItems: "center",
35482
+ justifyContent: "center"
35483
+ },
35484
+ children: /* @__PURE__ */ jsxRuntime.jsx(
35485
+ DynamicIcon,
35486
+ {
35487
+ name: "lucide/external-link",
35488
+ size: 22,
35489
+ "aria-hidden": "true"
35490
+ }
35491
+ )
35492
+ }
35493
+ ),
35494
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", style: { fontSize: 11, fontWeight: 600 }, children: "Instagram" })
35495
+ ]
35496
+ }
35497
+ ) : null
35498
+ ]
35499
+ }
35500
+ );
35501
+ }
35502
+ function InstagramFeedGrid({
35503
+ mediaItems,
35504
+ gridClassName,
35505
+ itemClassName,
35506
+ imageClassName,
35507
+ optixFlowConfig
35508
+ }) {
35509
+ const { open } = mediaImmersive.useImmersiveFeed();
35510
+ const posterImgProps = React30.useMemo(() => {
35511
+ const next = {};
35512
+ if (imageClassName) next.className = imageClassName;
35513
+ if (optixFlowConfig) next.optixFlowConfig = optixFlowConfig;
35514
+ return Object.keys(next).length > 0 ? next : void 0;
35515
+ }, [imageClassName, optixFlowConfig]);
35516
+ return /* @__PURE__ */ jsxRuntime.jsx(
35517
+ "div",
35518
+ {
35519
+ className: cn(
35520
+ "grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",
35521
+ gridClassName
35522
+ ),
35523
+ children: mediaItems.map((mediaItem) => {
35524
+ const likeCount = mediaItem.meta?.likeCount;
35525
+ return /* @__PURE__ */ jsxRuntime.jsx(
35526
+ mediaImmersive.ThumbnailCard,
35527
+ {
35528
+ item: mediaItem,
35529
+ onOpen: open,
35530
+ size: IG_TILE_WIDTH,
35531
+ style: IG_TILE_STYLE,
35532
+ className: itemClassName,
35533
+ elevated: false,
35534
+ showDuration: false,
35535
+ glyphMode: "hover",
35536
+ posterImgProps,
35537
+ badgeSlot: typeof likeCount === "number" ? likeBadge(likeCount) : void 0
35538
+ },
35539
+ mediaItem.id
35540
+ );
35541
+ })
35542
+ }
35543
+ );
35544
+ }
35291
35545
  function InstagramPostGrid({
35292
35546
  sectionId = "instagram-post-grid",
35293
35547
  heading,
@@ -35302,111 +35556,17 @@ function InstagramPostGrid({
35302
35556
  gridClassName,
35303
35557
  itemClassName,
35304
35558
  imageClassName,
35559
+ optixFlowConfig,
35305
35560
  background,
35306
35561
  spacing,
35307
35562
  pattern,
35308
35563
  patternOpacity,
35309
- patternClassName,
35310
- optixFlowConfig
35564
+ patternClassName
35311
35565
  }) {
35312
- const tiles = React30.useMemo(() => {
35313
- if (itemsSlot) return itemsSlot;
35314
- if (!items || items.length === 0) return null;
35315
- const visibleItems = items.filter((item) => Boolean(item.image));
35316
- return visibleItems.map((item) => {
35317
- const altText = item.imageAlt || (typeof item.caption === "string" ? item.caption : "") || "Instagram post";
35318
- const showVideo = Boolean(item.isVideo && item.videoUrl);
35319
- return /* @__PURE__ */ jsxRuntime.jsxs(
35320
- pressable.Pressable,
35321
- {
35322
- href: item.href,
35323
- "aria-label": typeof item.caption === "string" && item.caption.length > 0 ? item.caption : "View Instagram post",
35324
- className: cn(
35325
- "group relative block aspect-square overflow-hidden rounded-md bg-muted",
35326
- item.className,
35327
- itemClassName
35328
- ),
35329
- children: [
35330
- /* @__PURE__ */ jsxRuntime.jsx(
35331
- img$1.Img,
35332
- {
35333
- src: item.image,
35334
- alt: altText,
35335
- loading: "lazy",
35336
- className: cn(
35337
- "h-full w-full object-cover object-center transition-transform duration-300 group-hover:scale-105 motion-reduce:transform-none motion-reduce:transition-none",
35338
- imageClassName
35339
- ),
35340
- optixFlowConfig
35341
- }
35342
- ),
35343
- showVideo && /* @__PURE__ */ jsxRuntime.jsx(
35344
- video.Video,
35345
- {
35346
- src: item.videoUrl,
35347
- poster: item.image,
35348
- controls: false,
35349
- muted: true,
35350
- loop: true,
35351
- playsInline: true,
35352
- preload: "metadata",
35353
- onMouseEnter: (e) => {
35354
- void e.currentTarget.play().catch(() => void 0);
35355
- },
35356
- onMouseLeave: (e) => {
35357
- e.currentTarget.pause();
35358
- e.currentTarget.currentTime = 0;
35359
- },
35360
- className: cn(
35361
- "absolute inset-0 h-full w-full object-cover object-center opacity-0 transition-opacity duration-300 group-hover:opacity-100 motion-reduce:transition-none",
35362
- imageClassName
35363
- )
35364
- }
35365
- ),
35366
- item.isVideo && /* @__PURE__ */ jsxRuntime.jsx(
35367
- "span",
35368
- {
35369
- className: "absolute right-2 top-2 text-white drop-shadow-md",
35370
- "aria-hidden": "true",
35371
- children: /* @__PURE__ */ jsxRuntime.jsx(DynamicIcon, { name: "lucide/play", size: 18 })
35372
- }
35373
- ),
35374
- (item.caption || item.date || typeof item.likeCount === "number" || typeof item.commentCount === "number" || typeof item.viewCount === "number") && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 flex flex-col gap-1 bg-linear-to-t from-black/70 to-transparent p-3 text-left text-white opacity-0 transition-opacity duration-300 group-hover:opacity-100 motion-reduce:transition-none", children: [
35375
- item.caption && (typeof item.caption === "string" ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "line-clamp-2 text-xs leading-snug wrap-break-word", children: item.caption }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "line-clamp-2 text-xs leading-snug", children: item.caption })),
35376
- (typeof item.likeCount === "number" || typeof item.commentCount === "number" || typeof item.viewCount === "number" || item.date) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 text-xs font-medium", children: [
35377
- typeof item.likeCount === "number" && /* @__PURE__ */ jsxRuntime.jsx(
35378
- EngagementBadge,
35379
- {
35380
- iconName: "lucide/heart",
35381
- count: item.likeCount,
35382
- label: "likes"
35383
- }
35384
- ),
35385
- typeof item.commentCount === "number" && /* @__PURE__ */ jsxRuntime.jsx(
35386
- EngagementBadge,
35387
- {
35388
- iconName: "lucide/message-circle",
35389
- count: item.commentCount,
35390
- label: "comments"
35391
- }
35392
- ),
35393
- typeof item.viewCount === "number" && /* @__PURE__ */ jsxRuntime.jsx(
35394
- EngagementBadge,
35395
- {
35396
- iconName: "lucide/eye",
35397
- count: item.viewCount,
35398
- label: "views"
35399
- }
35400
- ),
35401
- item.date && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-auto opacity-80", children: item.date })
35402
- ] })
35403
- ] })
35404
- ]
35405
- },
35406
- item.id
35407
- );
35408
- });
35409
- }, [itemsSlot, items, itemClassName, imageClassName, optixFlowConfig]);
35566
+ const mediaItems = React30.useMemo(() => {
35567
+ if (itemsSlot || !items) return [];
35568
+ return items.filter((item) => Boolean(item.image)).map(toMediaItem);
35569
+ }, [items, itemsSlot]);
35410
35570
  if (!itemsSlot && (!items || items.length === 0)) {
35411
35571
  return null;
35412
35572
  }
@@ -35444,16 +35604,34 @@ function InstagramPostGrid({
35444
35604
  }
35445
35605
  ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: subheadingClassName, children: subheading }))
35446
35606
  ] }),
35447
- /* @__PURE__ */ jsxRuntime.jsx(
35607
+ itemsSlot ? /* @__PURE__ */ jsxRuntime.jsx(
35448
35608
  "div",
35449
35609
  {
35450
35610
  className: cn(
35451
35611
  "grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",
35452
35612
  gridClassName
35453
35613
  ),
35454
- children: tiles
35614
+ children: itemsSlot
35455
35615
  }
35456
- )
35616
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(mediaImmersive.ImmersiveFeedProvider, { items: mediaItems, actions: VIEWER_ACTIONS, children: [
35617
+ /* @__PURE__ */ jsxRuntime.jsx(
35618
+ InstagramFeedGrid,
35619
+ {
35620
+ mediaItems,
35621
+ gridClassName,
35622
+ itemClassName,
35623
+ imageClassName,
35624
+ optixFlowConfig
35625
+ }
35626
+ ),
35627
+ /* @__PURE__ */ jsxRuntime.jsx(
35628
+ mediaImmersive.ImmersiveViewer,
35629
+ {
35630
+ ariaLabel: "Instagram post viewer",
35631
+ renderActions: ({ item }) => /* @__PURE__ */ jsxRuntime.jsx(InstagramViewerRail, { item })
35632
+ }
35633
+ )
35634
+ ] })
35457
35635
  ]
35458
35636
  }
35459
35637
  );
@@ -111334,8 +111512,8 @@ var interiorCarousel = {
111334
111512
  }
111335
111513
  };
111336
111514
  var instagramPostGrid = {
111337
- exampleUsage: "Display a website's Instagram feed as a responsive grid of square tiles. Each tile links out to the post's instagram.com permalink in a new tab, shows the caption and post date on hover, and renders like/comment/view counts when available. Video posts play muted on hover. Data is hydrated from the toastability Instagram feed (dataSource type 'instagram_feed', bindTo 'items').",
111338
- importantUsageNotes: `${GALLERY_MEDIA_NOTE} This is a DYNAMIC feed block: its 'items' are hydrated at routing-build time from the connected Instagram profile \u2014 do NOT hand-author post content. 'items[].image' and 'items[].videoUrl' MUST be the re-hosted MediaRecord CDN URLs served by the feed; expiring Instagram CDN URLs must never be used. Engagement counts ('likeCount', 'commentCount', 'viewCount') render only when the value is present \u2014 never fabricate a zero for a missing metric. Each 'items[].href' is an external instagram.com permalink and opens in a new tab. Items without an 'image' are skipped; an empty or missing 'items' array renders nothing. Requires the site to have a connected, fully-imported Instagram profile ('instagram_media' capability).`,
111515
+ exampleUsage: "Display a website's Instagram feed as a responsive grid of vertical (9:16) tiles that open a fullscreen, swipeable immersive viewer (TikTok/Reels-style). Photos and reels are both first-class media \u2014 reels play a muted preview and open with playback; photos open as a full-bleed still. Each tile shows a like-count pill top-left (when available), no duration timestamp, and a center glyph on hover only (a play triangle for reels, an expand icon for photos). The fullscreen viewer carries the caption plus a read-only engagement rail (likes/comments/views) and an explicit 'Open in Instagram' link (a real anchor opening in a new tab). Data is hydrated from the toastability Instagram feed (dataSource type 'instagram_feed', bindTo 'items').",
111516
+ importantUsageNotes: `${GALLERY_MEDIA_NOTE} This is a DYNAMIC feed block: its 'items' are hydrated at routing-build time from the connected Instagram profile \u2014 do NOT hand-author post content. 'items[].image' and 'items[].videoUrl' MUST be the re-hosted MediaRecord CDN URLs served by the feed; expiring Instagram CDN URLs must never be used. Tiles are VERTICAL (9:16) and render both photos and reels; a post is treated as a reel only when 'isVideo' is true AND 'videoUrl' is present. Engagement counts ('likeCount', 'commentCount', 'viewCount') render only when the value is present \u2014 never fabricate a zero for a missing metric; 'likeCount' surfaces as the tile's top-left pill and, with comments/views, in the viewer rail. Tapping a tile OPENS THE FULLSCREEN VIEWER (the whole-tile link-out was replaced); the instagram.com permalink ('items[].href') opens from the viewer's 'Open in Instagram' egress, which is rendered as a REAL anchor (target=_blank, rel=noopener noreferrer) \u2014 a crawlable, affordance-correct link, not a scripted window.open button. 'items[].caption' should be a plain STRING when rendered immersively \u2014 it flows through as the tile/viewer title text; a rich ReactNode caption cannot be threaded through the immersive card/viewer and falls back to 'items[].imageAlt' (then a generic label). Consumer image styling is honored: 'imageClassName' and 'optixFlowConfig' are forwarded onto each tile's poster image. Items without an 'image' are skipped; an empty or missing 'items' array renders nothing. Requires the site to have a connected, fully-imported Instagram profile ('instagram_media' capability).`,
111339
111517
  usageRequirements: {
111340
111518
  requiredProps: ["items"],
111341
111519
  requiresSiteCapabilities: galleryCapabilities(
@@ -124817,7 +124995,7 @@ var BLOCK_REGISTRY = {
124817
124995
  "instagram-post-grid": {
124818
124996
  id: "instagram-post-grid",
124819
124997
  name: "Instagram Post Grid",
124820
- description: "A responsive grid of square tiles rendering a website's Instagram feed. Each tile links out to the post's instagram.com permalink in a new tab, reveals the caption, date, and like/comment/view counts on hover, and plays video posts muted on hover. Content is hydrated dynamically from the connected Instagram profile. Ideal for social proof sections, footers, and community pages that showcase a live Instagram presence.",
124998
+ description: "A responsive grid of vertical (9:16) tiles rendering a website's Instagram feed. Tapping a tile opens a fullscreen, swipeable immersive viewer (TikTok/Reels-style) with the caption, a read-only engagement rail (likes/comments/views), and an 'Open in Instagram' action. Photos and reels are both first-class media; each tile shows a like-count pill and a hover-only center glyph (play for reels, expand for photos). Content is hydrated dynamically from the connected Instagram profile. Ideal for social proof sections, footers, and community pages that showcase a live Instagram presence.",
124821
124999
  semanticTags: [
124822
125000
  "gallery",
124823
125001
  "instagram",