@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.js CHANGED
@@ -26,6 +26,7 @@ import Autoplay from 'embla-carousel-autoplay';
26
26
  import * as ProgressPrimitive from '@radix-ui/react-progress';
27
27
  import * as AvatarPrimitive from '@radix-ui/react-avatar';
28
28
  import AutoScroll3 from 'embla-carousel-auto-scroll';
29
+ import { ImmersiveFeedProvider, ImmersiveViewer, useImmersiveFeed, ThumbnailCard } from '@page-speed/media-immersive';
29
30
  import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
30
31
  import * as LabelPrimitive from '@radix-ui/react-label';
31
32
  import { SocialShare } from '@page-speed/social-share';
@@ -35231,23 +35232,276 @@ function InteriorCarousel({
35231
35232
  }
35232
35233
  );
35233
35234
  }
35234
- function EngagementBadge({
35235
+ var IG_TILE_WIDTH = 320;
35236
+ var IG_TILE_STYLE = { width: "100%" };
35237
+ var TITLE_MAX = 90;
35238
+ function truncate(text, max = TITLE_MAX) {
35239
+ const trimmed = text.trim();
35240
+ if (trimmed.length <= max) return trimmed;
35241
+ const slice = trimmed.slice(0, max);
35242
+ const lastSpace = slice.lastIndexOf(" ");
35243
+ const head = lastSpace > max * 0.6 ? slice.slice(0, lastSpace) : slice;
35244
+ return `${head.trimEnd()}\u2026`;
35245
+ }
35246
+ function captionToString(caption) {
35247
+ return typeof caption === "string" ? caption : "";
35248
+ }
35249
+ function toMediaItem(item) {
35250
+ const isVideo = Boolean(item.isVideo && item.videoUrl);
35251
+ const fullCaption = captionToString(item.caption);
35252
+ const title = truncate(fullCaption) || item.imageAlt || "Instagram post";
35253
+ const meta = {
35254
+ href: item.href,
35255
+ likeCount: item.likeCount,
35256
+ commentCount: item.commentCount,
35257
+ viewCount: item.viewCount,
35258
+ date: item.date
35259
+ };
35260
+ return {
35261
+ id: item.id,
35262
+ type: isVideo ? "video" : "image",
35263
+ poster: item.image,
35264
+ // Video source only when the post is a real video (image posts ignore it).
35265
+ src: isVideo ? item.videoUrl : void 0,
35266
+ title,
35267
+ caption: fullCaption || void 0,
35268
+ kind: "Instagram",
35269
+ meta
35270
+ };
35271
+ }
35272
+ function openPermalink(item) {
35273
+ if (typeof window === "undefined") return;
35274
+ const href = item.meta?.href;
35275
+ if (!href) return;
35276
+ window.open(href, "_blank", "noopener,noreferrer");
35277
+ }
35278
+ function likeBadge(likeCount) {
35279
+ return /* @__PURE__ */ jsxs(
35280
+ "span",
35281
+ {
35282
+ "aria-label": `${likeCount.toLocaleString()} likes`,
35283
+ style: {
35284
+ display: "inline-flex",
35285
+ alignItems: "center",
35286
+ gap: 4,
35287
+ padding: "3px 8px",
35288
+ borderRadius: 999,
35289
+ background: "rgba(8,12,24,0.65)",
35290
+ backdropFilter: "blur(6px)",
35291
+ WebkitBackdropFilter: "blur(6px)",
35292
+ color: "#fff",
35293
+ fontSize: 11,
35294
+ fontWeight: 700,
35295
+ lineHeight: 1
35296
+ },
35297
+ children: [
35298
+ /* @__PURE__ */ jsx(DynamicIcon, { name: "lucide/heart", size: 13, "aria-hidden": "true" }),
35299
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: likeCount.toLocaleString() })
35300
+ ]
35301
+ }
35302
+ );
35303
+ }
35304
+ var VIEWER_ACTIONS = [
35305
+ {
35306
+ id: "open-in-instagram",
35307
+ icon: /* @__PURE__ */ jsx(DynamicIcon, { name: "lucide/external-link", size: 22, "aria-hidden": "true" }),
35308
+ label: "Instagram",
35309
+ ariaLabel: "Open in Instagram",
35310
+ onPress: (item) => openPermalink(item)
35311
+ }
35312
+ ];
35313
+ function RailStat({
35235
35314
  iconName,
35236
35315
  count,
35237
- label
35316
+ label,
35317
+ onPress
35238
35318
  }) {
35239
35319
  return /* @__PURE__ */ jsxs(
35240
- "span",
35320
+ "button",
35241
35321
  {
35242
- className: "inline-flex items-center gap-1",
35322
+ type: "button",
35243
35323
  "aria-label": `${count.toLocaleString()} ${label}`,
35324
+ onClick: (e) => {
35325
+ e.stopPropagation();
35326
+ onPress();
35327
+ },
35328
+ style: {
35329
+ display: "flex",
35330
+ flexDirection: "column",
35331
+ alignItems: "center",
35332
+ gap: 5,
35333
+ padding: 0,
35334
+ border: "none",
35335
+ background: "transparent",
35336
+ color: "inherit",
35337
+ cursor: "pointer",
35338
+ font: "inherit"
35339
+ },
35244
35340
  children: [
35245
- /* @__PURE__ */ jsx(DynamicIcon, { name: iconName, size: 16, "aria-hidden": "true" }),
35246
- /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: count.toLocaleString() })
35341
+ /* @__PURE__ */ jsx(
35342
+ "span",
35343
+ {
35344
+ style: {
35345
+ width: 46,
35346
+ height: 46,
35347
+ borderRadius: "50%",
35348
+ background: "var(--psmi-chrome-bg, rgba(255,255,255,0.14))",
35349
+ backdropFilter: "blur(6px)",
35350
+ WebkitBackdropFilter: "blur(6px)",
35351
+ display: "flex",
35352
+ alignItems: "center",
35353
+ justifyContent: "center"
35354
+ },
35355
+ children: /* @__PURE__ */ jsx(DynamicIcon, { name: iconName, size: 22, "aria-hidden": "true" })
35356
+ }
35357
+ ),
35358
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", style: { fontSize: 11, fontWeight: 600 }, children: count.toLocaleString() })
35247
35359
  ]
35248
35360
  }
35249
35361
  );
35250
35362
  }
35363
+ function InstagramViewerRail({ item }) {
35364
+ const meta = item.meta ?? {};
35365
+ const open = () => openPermalink(item);
35366
+ return /* @__PURE__ */ jsxs(
35367
+ "div",
35368
+ {
35369
+ style: {
35370
+ position: "absolute",
35371
+ right: 11,
35372
+ bottom: 135,
35373
+ display: "flex",
35374
+ flexDirection: "column",
35375
+ alignItems: "center",
35376
+ gap: 18,
35377
+ color: "var(--psmi-chrome-fg, #fff)",
35378
+ zIndex: 3
35379
+ },
35380
+ children: [
35381
+ typeof meta.likeCount === "number" ? /* @__PURE__ */ jsx(
35382
+ RailStat,
35383
+ {
35384
+ iconName: "lucide/heart",
35385
+ count: meta.likeCount,
35386
+ label: "likes",
35387
+ onPress: open
35388
+ }
35389
+ ) : null,
35390
+ typeof meta.commentCount === "number" ? /* @__PURE__ */ jsx(
35391
+ RailStat,
35392
+ {
35393
+ iconName: "lucide/message-circle",
35394
+ count: meta.commentCount,
35395
+ label: "comments",
35396
+ onPress: open
35397
+ }
35398
+ ) : null,
35399
+ typeof meta.viewCount === "number" ? /* @__PURE__ */ jsx(
35400
+ RailStat,
35401
+ {
35402
+ iconName: "lucide/eye",
35403
+ count: meta.viewCount,
35404
+ label: "views",
35405
+ onPress: open
35406
+ }
35407
+ ) : null,
35408
+ meta.href ? /* @__PURE__ */ jsxs(
35409
+ "a",
35410
+ {
35411
+ href: meta.href,
35412
+ target: "_blank",
35413
+ rel: "noopener noreferrer",
35414
+ "aria-label": "Open in Instagram",
35415
+ onClick: (e) => e.stopPropagation(),
35416
+ style: {
35417
+ display: "flex",
35418
+ flexDirection: "column",
35419
+ alignItems: "center",
35420
+ gap: 5,
35421
+ padding: 0,
35422
+ border: "none",
35423
+ background: "transparent",
35424
+ color: "inherit",
35425
+ cursor: "pointer",
35426
+ font: "inherit",
35427
+ textDecoration: "none"
35428
+ },
35429
+ children: [
35430
+ /* @__PURE__ */ jsx(
35431
+ "span",
35432
+ {
35433
+ style: {
35434
+ width: 46,
35435
+ height: 46,
35436
+ borderRadius: "50%",
35437
+ background: "var(--psmi-chrome-bg, rgba(255,255,255,0.14))",
35438
+ backdropFilter: "blur(6px)",
35439
+ WebkitBackdropFilter: "blur(6px)",
35440
+ display: "flex",
35441
+ alignItems: "center",
35442
+ justifyContent: "center"
35443
+ },
35444
+ children: /* @__PURE__ */ jsx(
35445
+ DynamicIcon,
35446
+ {
35447
+ name: "lucide/external-link",
35448
+ size: 22,
35449
+ "aria-hidden": "true"
35450
+ }
35451
+ )
35452
+ }
35453
+ ),
35454
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", style: { fontSize: 11, fontWeight: 600 }, children: "Instagram" })
35455
+ ]
35456
+ }
35457
+ ) : null
35458
+ ]
35459
+ }
35460
+ );
35461
+ }
35462
+ function InstagramFeedGrid({
35463
+ mediaItems,
35464
+ gridClassName,
35465
+ itemClassName,
35466
+ imageClassName,
35467
+ optixFlowConfig
35468
+ }) {
35469
+ const { open } = useImmersiveFeed();
35470
+ const posterImgProps = useMemo(() => {
35471
+ const next = {};
35472
+ if (imageClassName) next.className = imageClassName;
35473
+ if (optixFlowConfig) next.optixFlowConfig = optixFlowConfig;
35474
+ return Object.keys(next).length > 0 ? next : void 0;
35475
+ }, [imageClassName, optixFlowConfig]);
35476
+ return /* @__PURE__ */ jsx(
35477
+ "div",
35478
+ {
35479
+ className: cn(
35480
+ "grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",
35481
+ gridClassName
35482
+ ),
35483
+ children: mediaItems.map((mediaItem) => {
35484
+ const likeCount = mediaItem.meta?.likeCount;
35485
+ return /* @__PURE__ */ jsx(
35486
+ ThumbnailCard,
35487
+ {
35488
+ item: mediaItem,
35489
+ onOpen: open,
35490
+ size: IG_TILE_WIDTH,
35491
+ style: IG_TILE_STYLE,
35492
+ className: itemClassName,
35493
+ elevated: false,
35494
+ showDuration: false,
35495
+ glyphMode: "hover",
35496
+ posterImgProps,
35497
+ badgeSlot: typeof likeCount === "number" ? likeBadge(likeCount) : void 0
35498
+ },
35499
+ mediaItem.id
35500
+ );
35501
+ })
35502
+ }
35503
+ );
35504
+ }
35251
35505
  function InstagramPostGrid({
35252
35506
  sectionId = "instagram-post-grid",
35253
35507
  heading,
@@ -35262,111 +35516,17 @@ function InstagramPostGrid({
35262
35516
  gridClassName,
35263
35517
  itemClassName,
35264
35518
  imageClassName,
35519
+ optixFlowConfig,
35265
35520
  background,
35266
35521
  spacing,
35267
35522
  pattern,
35268
35523
  patternOpacity,
35269
- patternClassName,
35270
- optixFlowConfig
35524
+ patternClassName
35271
35525
  }) {
35272
- const tiles = useMemo(() => {
35273
- if (itemsSlot) return itemsSlot;
35274
- if (!items || items.length === 0) return null;
35275
- const visibleItems = items.filter((item) => Boolean(item.image));
35276
- return visibleItems.map((item) => {
35277
- const altText = item.imageAlt || (typeof item.caption === "string" ? item.caption : "") || "Instagram post";
35278
- const showVideo = Boolean(item.isVideo && item.videoUrl);
35279
- return /* @__PURE__ */ jsxs(
35280
- Pressable,
35281
- {
35282
- href: item.href,
35283
- "aria-label": typeof item.caption === "string" && item.caption.length > 0 ? item.caption : "View Instagram post",
35284
- className: cn(
35285
- "group relative block aspect-square overflow-hidden rounded-md bg-muted",
35286
- item.className,
35287
- itemClassName
35288
- ),
35289
- children: [
35290
- /* @__PURE__ */ jsx(
35291
- Img,
35292
- {
35293
- src: item.image,
35294
- alt: altText,
35295
- loading: "lazy",
35296
- className: cn(
35297
- "h-full w-full object-cover object-center transition-transform duration-300 group-hover:scale-105 motion-reduce:transform-none motion-reduce:transition-none",
35298
- imageClassName
35299
- ),
35300
- optixFlowConfig
35301
- }
35302
- ),
35303
- showVideo && /* @__PURE__ */ jsx(
35304
- Video,
35305
- {
35306
- src: item.videoUrl,
35307
- poster: item.image,
35308
- controls: false,
35309
- muted: true,
35310
- loop: true,
35311
- playsInline: true,
35312
- preload: "metadata",
35313
- onMouseEnter: (e) => {
35314
- void e.currentTarget.play().catch(() => void 0);
35315
- },
35316
- onMouseLeave: (e) => {
35317
- e.currentTarget.pause();
35318
- e.currentTarget.currentTime = 0;
35319
- },
35320
- className: cn(
35321
- "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",
35322
- imageClassName
35323
- )
35324
- }
35325
- ),
35326
- item.isVideo && /* @__PURE__ */ jsx(
35327
- "span",
35328
- {
35329
- className: "absolute right-2 top-2 text-white drop-shadow-md",
35330
- "aria-hidden": "true",
35331
- children: /* @__PURE__ */ jsx(DynamicIcon, { name: "lucide/play", size: 18 })
35332
- }
35333
- ),
35334
- (item.caption || item.date || typeof item.likeCount === "number" || typeof item.commentCount === "number" || typeof item.viewCount === "number") && /* @__PURE__ */ 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: [
35335
- item.caption && (typeof item.caption === "string" ? /* @__PURE__ */ jsx("p", { className: "line-clamp-2 text-xs leading-snug wrap-break-word", children: item.caption }) : /* @__PURE__ */ jsx("div", { className: "line-clamp-2 text-xs leading-snug", children: item.caption })),
35336
- (typeof item.likeCount === "number" || typeof item.commentCount === "number" || typeof item.viewCount === "number" || item.date) && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 text-xs font-medium", children: [
35337
- typeof item.likeCount === "number" && /* @__PURE__ */ jsx(
35338
- EngagementBadge,
35339
- {
35340
- iconName: "lucide/heart",
35341
- count: item.likeCount,
35342
- label: "likes"
35343
- }
35344
- ),
35345
- typeof item.commentCount === "number" && /* @__PURE__ */ jsx(
35346
- EngagementBadge,
35347
- {
35348
- iconName: "lucide/message-circle",
35349
- count: item.commentCount,
35350
- label: "comments"
35351
- }
35352
- ),
35353
- typeof item.viewCount === "number" && /* @__PURE__ */ jsx(
35354
- EngagementBadge,
35355
- {
35356
- iconName: "lucide/eye",
35357
- count: item.viewCount,
35358
- label: "views"
35359
- }
35360
- ),
35361
- item.date && /* @__PURE__ */ jsx("span", { className: "ml-auto opacity-80", children: item.date })
35362
- ] })
35363
- ] })
35364
- ]
35365
- },
35366
- item.id
35367
- );
35368
- });
35369
- }, [itemsSlot, items, itemClassName, imageClassName, optixFlowConfig]);
35526
+ const mediaItems = useMemo(() => {
35527
+ if (itemsSlot || !items) return [];
35528
+ return items.filter((item) => Boolean(item.image)).map(toMediaItem);
35529
+ }, [items, itemsSlot]);
35370
35530
  if (!itemsSlot && (!items || items.length === 0)) {
35371
35531
  return null;
35372
35532
  }
@@ -35404,16 +35564,34 @@ function InstagramPostGrid({
35404
35564
  }
35405
35565
  ) : /* @__PURE__ */ jsx("div", { className: subheadingClassName, children: subheading }))
35406
35566
  ] }),
35407
- /* @__PURE__ */ jsx(
35567
+ itemsSlot ? /* @__PURE__ */ jsx(
35408
35568
  "div",
35409
35569
  {
35410
35570
  className: cn(
35411
35571
  "grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",
35412
35572
  gridClassName
35413
35573
  ),
35414
- children: tiles
35574
+ children: itemsSlot
35415
35575
  }
35416
- )
35576
+ ) : /* @__PURE__ */ jsxs(ImmersiveFeedProvider, { items: mediaItems, actions: VIEWER_ACTIONS, children: [
35577
+ /* @__PURE__ */ jsx(
35578
+ InstagramFeedGrid,
35579
+ {
35580
+ mediaItems,
35581
+ gridClassName,
35582
+ itemClassName,
35583
+ imageClassName,
35584
+ optixFlowConfig
35585
+ }
35586
+ ),
35587
+ /* @__PURE__ */ jsx(
35588
+ ImmersiveViewer,
35589
+ {
35590
+ ariaLabel: "Instagram post viewer",
35591
+ renderActions: ({ item }) => /* @__PURE__ */ jsx(InstagramViewerRail, { item })
35592
+ }
35593
+ )
35594
+ ] })
35417
35595
  ]
35418
35596
  }
35419
35597
  );
@@ -111294,8 +111472,8 @@ var interiorCarousel = {
111294
111472
  }
111295
111473
  };
111296
111474
  var instagramPostGrid = {
111297
- 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').",
111298
- 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).`,
111475
+ 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').",
111476
+ 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).`,
111299
111477
  usageRequirements: {
111300
111478
  requiredProps: ["items"],
111301
111479
  requiresSiteCapabilities: galleryCapabilities(
@@ -124777,7 +124955,7 @@ var BLOCK_REGISTRY = {
124777
124955
  "instagram-post-grid": {
124778
124956
  id: "instagram-post-grid",
124779
124957
  name: "Instagram Post Grid",
124780
- 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.",
124958
+ 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.",
124781
124959
  semanticTags: [
124782
124960
  "gallery",
124783
124961
  "instagram",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opensite/ui",
3
- "version": "3.10.0",
3
+ "version": "3.11.0",
4
4
  "description": "Foundational UI component library for OpenSite Semantic Site Builder with tree-shakable exports and abstract styling",
5
5
  "keywords": [
6
6
  "react",
@@ -3437,6 +3437,7 @@
3437
3437
  "@page-speed/lightbox": "^0.2.1",
3438
3438
  "@page-speed/maps": "0.2.4",
3439
3439
  "@page-speed/markdown-to-jsx": "^0.0.7",
3440
+ "@page-speed/media-immersive": "0.5.0",
3440
3441
  "@page-speed/pdf-viewer": ">=0.1.9",
3441
3442
  "@page-speed/skins": "0.1.2",
3442
3443
  "@page-speed/social-share": "0.1.7",