@cntrl-site/components 1.0.107-alpha.1 → 1.0.107-alpha.3

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/sources.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./ArchivePopupComponent-BTniPIfi.js"),e=`import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent } from 'react';
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./ArchivePopupComponent-CJz4GmEb.js"),e=`import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent } from 'react';
2
2
  import { createPortal } from 'react-dom';
3
3
  import cn from 'classnames';
4
4
  import { CommonComponentProps } from '../props';
@@ -25,7 +25,7 @@ export const ARCHIVE_POPUP_COLUMN_WIDTH_KEYS = ['column1Width', 'column2Width',
25
25
  type ArchivePopupColumnWidthKey = typeof ARCHIVE_POPUP_COLUMN_WIDTH_KEYS[number];
26
26
 
27
27
  /**
28
- * Where A's panel sits on the screen, as \`left\`/\`top\` of the screen and of the panel alike, so 0% is flush with
28
+ * Where B's panel sits on the screen, as \`left\`/\`top\` of the screen and of the panel alike, so 0% is flush with
29
29
  * one edge and 100% with the other. Named like Mercury's title position; center comes first because the editor
30
30
  * puts the first value into a popup saved before there was a position, and those were centred.
31
31
  */
@@ -59,7 +59,8 @@ export type ArchivePopupContentItem = {
59
59
  title2?: ArchivePopupTitle;
60
60
  title3?: ArchivePopupTitle;
61
61
  title4?: ArchivePopupTitle;
62
- image?: ArchivePopupMedia;
62
+ /** The row's hover images, shown in turn while it is hovered; a row saved before there could be several holds just one. */
63
+ image?: ArchivePopupMedia | ArchivePopupMedia[];
63
64
  };
64
65
 
65
66
  type FontSettings = { fontWeight: number; fontStyle: string };
@@ -87,7 +88,7 @@ type ArchivePopupSettings = PrefixedTextStyle<'trigger'>
87
88
  // One style every column shared before each had its own; a column with no style of its own still shows it.
88
89
  & PrefixedTextStyle<'list'>
89
90
  & {
90
- /** \`a\` opens from a label; \`b\` is always open, in place on the page. */
91
+ /** \`a\` is always open, in place on the page; \`b\` opens from a label. */
91
92
  type?: 'a' | 'b';
92
93
  triggerLabel?: string;
93
94
  closeLabel?: string;
@@ -98,7 +99,9 @@ type ArchivePopupSettings = PrefixedTextStyle<'trigger'>
98
99
  column2Width?: number;
99
100
  column3Width?: number;
100
101
  column4Width?: number;
101
- /** A only: B's panel stays where it is placed on the page. */
102
+ /** How long each of a hovered row's images shows before the next, in ms. */
103
+ hoverInterval?: number;
104
+ /** B only: A's panel stays where it is placed on the page. */
102
105
  panelPosition?: string;
103
106
  panelWidth?: number;
104
107
  panelPadding?: Padding;
@@ -166,7 +169,8 @@ const MIN_COLUMN_WIDTH_PX = 20;
166
169
  const DEFAULT_COLUMN_GAP = 0.0139;
167
170
  const DEFAULT_PANEL_WIDTH = 0.3194;
168
171
  const DEFAULT_PANEL_PADDING: Padding = { top: 0.00972, right: 0.00972, bottom: 0.00972, left: 0.00972 };
169
- const IMAGE_FADE_MS = 800;
172
+ const IMAGE_FADE_MS = 300;
173
+ const DEFAULT_HOVER_INTERVAL_MS = 1000;
170
174
 
171
175
  const LIGHTBOX_CSS_VARS = [
172
176
  '--cntrl-article-width',
@@ -244,6 +248,11 @@ export function groupArchiveRows(items: ArchivePopupContentItem[]): ArchivePopup
244
248
  return groups;
245
249
  }
246
250
 
251
+ export function getArchivePopupRowMedia(item: ArchivePopupContentItem | undefined): ArchivePopupMedia[] {
252
+ const { image } = item ?? {};
253
+ return (Array.isArray(image) ? image : image ? [image] : []).filter((media) => Boolean(media?.assetId));
254
+ }
255
+
247
256
  function isVideoMedia(media: ArchivePopupMedia): boolean {
248
257
  if (media.type === 'video') return true;
249
258
  if (media.type === 'image') return false;
@@ -315,6 +324,10 @@ function getCSS(P: string): string {
315
324
  }
316
325
  .\${P}-trigger {
317
326
  color: var(--\${P}-trigger-color);
327
+ transition: color 150ms ease, opacity \${OVERLAY_ANIM_MS}ms ease;
328
+ }
329
+ .\${P}-trigger-hidden {
330
+ opacity: 0;
318
331
  }
319
332
  .\${P}-close {
320
333
  color: var(--\${P}-close-color);
@@ -445,13 +458,20 @@ function getCSS(P: string): string {
445
458
  .\${P}-group ~ .\${P}-group {
446
459
  margin-top: var(--\${P}-group-gap);
447
460
  }
448
- .\${P}-row {
461
+ .\${P}-group {
449
462
  display: grid;
450
463
  grid-template-columns: var(--\${P}-grid-columns);
451
464
  column-gap: var(--\${P}-column-gap);
465
+ }
466
+ .\${P}-row {
467
+ grid-column: 2 / -1;
468
+ display: grid;
469
+ grid-template-columns: subgrid;
452
470
  align-items: baseline;
453
471
  }
454
472
  .\${P}-group-label {
473
+ grid-column: 1;
474
+ align-self: start;
455
475
  min-width: 0;
456
476
  overflow-wrap: anywhere;
457
477
  }
@@ -470,7 +490,7 @@ function getCSS(P: string): string {
470
490
  }
471
491
  .\${P}-interactive .\${P}-row:hover .\${P}-title,
472
492
  .\${P}-row:focus-within .\${P}-title,
473
- .\${P}-state-hover .\${P}-row:first-child .\${P}-title {
493
+ .\${P}-state-hover .\${P}-group-label + .\${P}-row .\${P}-title {
474
494
  color: var(--\${P}-text-hover-color, var(--\${P}-text-color));
475
495
  }
476
496
  \`;
@@ -621,11 +641,12 @@ export function ArchivePopup({
621
641
  }: ArchivePopupProps) {
622
642
  const { prefix: P } = useScopedStyles();
623
643
  const {
624
- type = 'a',
644
+ type = 'b',
625
645
  triggerLabel = 'Archive',
626
646
  closeLabel = 'Close',
627
647
  columns = ARCHIVE_POPUP_MIN_COLUMNS,
628
648
  columnGap = DEFAULT_COLUMN_GAP,
649
+ hoverInterval = DEFAULT_HOVER_INTERVAL_MS,
629
650
  panelPosition,
630
651
  panelWidth = DEFAULT_PANEL_WIDTH,
631
652
  panelPadding = DEFAULT_PANEL_PADDING,
@@ -652,6 +673,8 @@ export function ArchivePopup({
652
673
  const [isOverlayActive, setIsOverlayActive] = useState(false);
653
674
  const [isOverlaySettled, setIsOverlaySettled] = useState(false);
654
675
  const [activeIndex, setActiveIndex] = useState<number | null>(null);
676
+ // Which of the hovered row's images shows, counted afresh on every hover.
677
+ const [activeMediaIndex, setActiveMediaIndex] = useState(0);
655
678
  const [mountedMedia, setMountedMedia] = useState<Set<number>>(() => new Set());
656
679
  const [closePosition, setClosePosition] = useState<{ top: number; left: number } | null>(null);
657
680
  const [layoutStyle, setLayoutStyle] = useState<CSSProperties>({});
@@ -660,8 +683,8 @@ export function ArchivePopup({
660
683
 
661
684
  const isEditorCanvas = Boolean(isEditor && !isPreviewMode);
662
685
  const isInteractive = !isEditor || Boolean(isPreviewMode);
663
- // B has no popup to open: its panel is always shown in place of the label.
664
- const isInline = type === 'b';
686
+ // A has no popup to open: its panel is always shown in place of the label.
687
+ const isInline = type === 'a';
665
688
  const isOpenPinned = isEditorCanvas && currentState === 'open' && !unavailableStates?.includes('open');
666
689
  // Escape from preview lands in edit mode: a popup opened there stays open, with its controls.
667
690
  const isOpen = !isInline && (isOpenPinned || ((isInteractive || Boolean(isEditMode)) && isOpenUser));
@@ -737,7 +760,7 @@ export function ArchivePopup({
737
760
  return () => document.removeEventListener('keydown', onKeyDown);
738
761
  }, [isOpen, isInteractive]);
739
762
 
740
- // B's media fills the screen above the page, so a copy of the panel is laid exactly over the real one to stay readable.
763
+ // A's media fills the screen above the page, so a copy of the panel is laid exactly over the real one to stay readable.
741
764
  useLayoutEffect(() => {
742
765
  if (!isInline || activeIndex === null) return;
743
766
  const panelEl = panelRef.current;
@@ -779,13 +802,35 @@ export function ArchivePopup({
779
802
  triggerRef.current?.focus({ preventScroll: true });
780
803
  };
781
804
 
805
+ // Every row's images are fetched once the list can be hovered, so a row's first hover shows its image at once
806
+ // rather than after it loads; videos are left to load on hover.
807
+ const isListShown = isInteractive && (isInline || isOpen);
808
+ useEffect(() => {
809
+ if (!isListShown) return;
810
+ (content ?? []).forEach((item) => getArchivePopupRowMedia(item).forEach((media) => {
811
+ if (!isVideoMedia(media)) new Image().src = media.assetId;
812
+ }));
813
+ }, [isListShown, content]);
814
+
815
+ // A hovered row with several images shows them in turn, round and round, for as long as it stays hovered.
816
+ const activeRowMediaCount = activeIndex === null ? 0 : getArchivePopupRowMedia(items[activeIndex]).length;
817
+ useEffect(() => {
818
+ if (activeRowMediaCount < 2) return;
819
+ const timer = window.setInterval(() => {
820
+ setActiveMediaIndex((current) => (current + 1) % activeRowMediaCount);
821
+ }, Math.max(100, hoverInterval));
822
+ return () => window.clearInterval(timer);
823
+ }, [activeIndex, activeRowMediaCount, hoverInterval]);
824
+
782
825
  const showRowMedia = (index: number) => {
783
- if (!isInteractive || !items[index]?.image?.assetId) {
826
+ if (!isInteractive || getArchivePopupRowMedia(items[index]).length === 0) {
784
827
  setActiveIndex(null);
785
828
  return;
786
829
  }
830
+ // A row's images all load on its first hover, so the next is ready by the time it shows.
787
831
  setMountedMedia((prev) => (prev.has(index) ? prev : new Set(prev).add(index)));
788
832
  if (isInline && activeIndex === null) setLayoutStyle(getLightboxLayoutStyle(wrapperRef.current));
833
+ if (activeIndex !== index) setActiveMediaIndex(0);
789
834
  setIsMediaCut(false);
790
835
  setActiveIndex(index);
791
836
  };
@@ -805,6 +850,13 @@ export function ArchivePopup({
805
850
  const columnTypographyCss = ARCHIVE_POPUP_COLUMN_STYLE_PREFIXES.slice(0, columnCount).map((prefix) => (
806
851
  omitTextColors(textStylesToCss(resolveTextStyle(settings, prefix, 'list'), isEditor))
807
852
  ));
853
+ // Half the difference of the two line heights sets the label's first line on the first title's, exactly
854
+ // while both columns share a font size.
855
+ const labelLineHeight = columnTypographyCss[0].lineHeight;
856
+ const titleLineHeight = columnTypographyCss[1]?.lineHeight;
857
+ const groupLabelOffset = labelLineHeight !== undefined && titleLineHeight !== undefined
858
+ ? \`calc((\${titleLineHeight} - \${labelLineHeight}) / 2)\`
859
+ : undefined;
808
860
 
809
861
  const colorVars = buildColorVars(P, {
810
862
  triggerColor,
@@ -821,18 +873,14 @@ export function ArchivePopup({
821
873
 
822
874
  const mediaLayer = (
823
875
  <div className={cn(\`\${P}-media-layer\`, isMediaCut && \`\${P}-media-layer-instant\`)} aria-hidden="true">
824
- {[...mountedMedia].map((index) => {
825
- const media = items[index]?.image;
826
- if (!media?.assetId) return null;
827
- return (
828
- <ArchivePopupMediaItem
829
- key={\`\${index}-\${media.assetId}\`}
830
- P={P}
831
- media={media}
832
- isVisible={activeIndex === index}
833
- />
834
- );
835
- })}
876
+ {[...mountedMedia].flatMap((index) => getArchivePopupRowMedia(items[index]).map((media, mediaIndex) => (
877
+ <ArchivePopupMediaItem
878
+ key={\`\${index}-\${mediaIndex}-\${media.assetId}\`}
879
+ P={P}
880
+ media={media}
881
+ isVisible={activeIndex === index && activeMediaIndex === mediaIndex}
882
+ />
883
+ )))}
836
884
  </div>
837
885
  );
838
886
  // Inline there is no slide-in to wait for, so the canvas controls can measure straight away.
@@ -883,8 +931,16 @@ export function ArchivePopup({
883
931
  style={{ left: 0, width: '100%', height: scaled(Math.max(groupGap, PADDING_HANDLE_SIZE)) }}
884
932
  />
885
933
  )}
886
- <div className={\`\${P}-group\`}>
887
- {group.rows.map(({ item, index }, rowIndex) => (
934
+ {/* The label spans its group's rows, so its line height spaces only its own lines, never the rows beside it;
935
+ a label longer than its rows grows the last track, below them. */}
936
+ <div className={\`\${P}-group\`} style={{ gridTemplateRows: \`repeat(\${group.rows.length}, auto) 1fr\` }}>
937
+ <span
938
+ className={\`\${P}-group-label\`}
939
+ style={{ ...columnTypographyCss[0], gridRow: \`1 / span \${group.rows.length + 1}\`, marginTop: groupLabelOffset }}
940
+ >
941
+ {group.label}
942
+ </span>
943
+ {group.rows.map(({ item, index }) => (
888
944
  <div
889
945
  key={index}
890
946
  className={cn(\`\${P}-row\`, isCopy && index === activeIndex && \`\${P}-row-active\`)}
@@ -895,9 +951,6 @@ export function ArchivePopup({
895
951
  onBlur: () => hideRowMedia(index),
896
952
  })}
897
953
  >
898
- <span className={\`\${P}-group-label\`} style={columnTypographyCss[0]}>
899
- {rowIndex === 0 ? group.label : ''}
900
- </span>
901
954
  {titleKeys.map((key, titleIndex) => {
902
955
  const title = item[key];
903
956
  return (
@@ -974,10 +1027,12 @@ export function ArchivePopup({
974
1027
  style={colorVars}
975
1028
  >
976
1029
  {isInline ? renderPanel(false) : (
1030
+ // The overlay lets the page show through, so the label fades out with it rather than sit under the close.
1031
+ // Only faded, it keeps the component's size and can still take focus back on close.
977
1032
  <button
978
1033
  ref={triggerRef}
979
1034
  type="button"
980
- className={\`\${P}-trigger\`}
1035
+ className={cn(\`\${P}-trigger\`, isOverlayActive && \`\${P}-trigger-hidden\`)}
981
1036
  style={triggerTypographyCss}
982
1037
  aria-haspopup="dialog"
983
1038
  aria-expanded={isOpen}
@@ -25048,4 +25103,4 @@ export function Waterfall({
25048
25103
  </>
25049
25104
  );
25050
25105
  }
25051
- `,C={[n.ArchivePopupComponent.id]:e,[n.BurgerComponent.id]:t,[n.ClickGallerieComponent.id]:i,[n.FAQComponent.id]:o,[n.FormComponent.id]:r,[n.GridComponent.id]:a,[n.HelixComponent.id]:s,[n.HiveComponent.id]:l,[n.LightboxJournalComponent.id]:c,[n.LightboxStripComponent.id]:d,[n.ListComponent.id]:u,[n.MarqueeComponent.id]:g,[n.MarqueeTextComponent.id]:m,[n.MercuryComponent.id]:p,[n.OnelinerFormComponent.id]:h,[n.PretextComponent.id]:f,[n.ScaleComponent.id]:v,[n.SimpleButtonComponent.id]:P,[n.Slider20Component.id]:x,[n.TestimonialGridComponent.id]:b,[n.TestimonialSingleComponent.id]:y,[n.WaterfallComponent.id]:S};exports.componentSources=C;
25106
+ `,w={[n.ArchivePopupComponent.id]:e,[n.BurgerComponent.id]:t,[n.ClickGallerieComponent.id]:i,[n.FAQComponent.id]:o,[n.FormComponent.id]:r,[n.GridComponent.id]:a,[n.HelixComponent.id]:s,[n.HiveComponent.id]:l,[n.LightboxJournalComponent.id]:c,[n.LightboxStripComponent.id]:d,[n.ListComponent.id]:u,[n.MarqueeComponent.id]:g,[n.MarqueeTextComponent.id]:m,[n.MercuryComponent.id]:p,[n.OnelinerFormComponent.id]:h,[n.PretextComponent.id]:f,[n.ScaleComponent.id]:v,[n.SimpleButtonComponent.id]:P,[n.Slider20Component.id]:x,[n.TestimonialGridComponent.id]:b,[n.TestimonialSingleComponent.id]:y,[n.WaterfallComponent.id]:S};exports.componentSources=w;
package/dist/sources.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { W as n, b as e, T as t, g as i, f as o, S as r, P as a, O as s, h as l, a as c, M as d, L as u, d as g, e as m, H as p, i as h, G as f, F as v, c as P, C as x, B as b, A as y } from "./ArchivePopupComponent-GgAT2Avz.mjs";
1
+ import { W as n, b as e, T as t, g as i, f as o, S as r, P as a, O as s, h as l, a as c, M as d, L as u, d as g, e as m, H as p, i as h, G as f, F as v, c as P, C as x, B as b, A as y } from "./ArchivePopupComponent-Dwh1vyqt.mjs";
2
2
  const S = `import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
  import cn from 'classnames';
@@ -26,7 +26,7 @@ export const ARCHIVE_POPUP_COLUMN_WIDTH_KEYS = ['column1Width', 'column2Width',
26
26
  type ArchivePopupColumnWidthKey = typeof ARCHIVE_POPUP_COLUMN_WIDTH_KEYS[number];
27
27
 
28
28
  /**
29
- * Where A's panel sits on the screen, as \`left\`/\`top\` of the screen and of the panel alike, so 0% is flush with
29
+ * Where B's panel sits on the screen, as \`left\`/\`top\` of the screen and of the panel alike, so 0% is flush with
30
30
  * one edge and 100% with the other. Named like Mercury's title position; center comes first because the editor
31
31
  * puts the first value into a popup saved before there was a position, and those were centred.
32
32
  */
@@ -60,7 +60,8 @@ export type ArchivePopupContentItem = {
60
60
  title2?: ArchivePopupTitle;
61
61
  title3?: ArchivePopupTitle;
62
62
  title4?: ArchivePopupTitle;
63
- image?: ArchivePopupMedia;
63
+ /** The row's hover images, shown in turn while it is hovered; a row saved before there could be several holds just one. */
64
+ image?: ArchivePopupMedia | ArchivePopupMedia[];
64
65
  };
65
66
 
66
67
  type FontSettings = { fontWeight: number; fontStyle: string };
@@ -88,7 +89,7 @@ type ArchivePopupSettings = PrefixedTextStyle<'trigger'>
88
89
  // One style every column shared before each had its own; a column with no style of its own still shows it.
89
90
  & PrefixedTextStyle<'list'>
90
91
  & {
91
- /** \`a\` opens from a label; \`b\` is always open, in place on the page. */
92
+ /** \`a\` is always open, in place on the page; \`b\` opens from a label. */
92
93
  type?: 'a' | 'b';
93
94
  triggerLabel?: string;
94
95
  closeLabel?: string;
@@ -99,7 +100,9 @@ type ArchivePopupSettings = PrefixedTextStyle<'trigger'>
99
100
  column2Width?: number;
100
101
  column3Width?: number;
101
102
  column4Width?: number;
102
- /** A only: B's panel stays where it is placed on the page. */
103
+ /** How long each of a hovered row's images shows before the next, in ms. */
104
+ hoverInterval?: number;
105
+ /** B only: A's panel stays where it is placed on the page. */
103
106
  panelPosition?: string;
104
107
  panelWidth?: number;
105
108
  panelPadding?: Padding;
@@ -167,7 +170,8 @@ const MIN_COLUMN_WIDTH_PX = 20;
167
170
  const DEFAULT_COLUMN_GAP = 0.0139;
168
171
  const DEFAULT_PANEL_WIDTH = 0.3194;
169
172
  const DEFAULT_PANEL_PADDING: Padding = { top: 0.00972, right: 0.00972, bottom: 0.00972, left: 0.00972 };
170
- const IMAGE_FADE_MS = 800;
173
+ const IMAGE_FADE_MS = 300;
174
+ const DEFAULT_HOVER_INTERVAL_MS = 1000;
171
175
 
172
176
  const LIGHTBOX_CSS_VARS = [
173
177
  '--cntrl-article-width',
@@ -245,6 +249,11 @@ export function groupArchiveRows(items: ArchivePopupContentItem[]): ArchivePopup
245
249
  return groups;
246
250
  }
247
251
 
252
+ export function getArchivePopupRowMedia(item: ArchivePopupContentItem | undefined): ArchivePopupMedia[] {
253
+ const { image } = item ?? {};
254
+ return (Array.isArray(image) ? image : image ? [image] : []).filter((media) => Boolean(media?.assetId));
255
+ }
256
+
248
257
  function isVideoMedia(media: ArchivePopupMedia): boolean {
249
258
  if (media.type === 'video') return true;
250
259
  if (media.type === 'image') return false;
@@ -316,6 +325,10 @@ function getCSS(P: string): string {
316
325
  }
317
326
  .\${P}-trigger {
318
327
  color: var(--\${P}-trigger-color);
328
+ transition: color 150ms ease, opacity \${OVERLAY_ANIM_MS}ms ease;
329
+ }
330
+ .\${P}-trigger-hidden {
331
+ opacity: 0;
319
332
  }
320
333
  .\${P}-close {
321
334
  color: var(--\${P}-close-color);
@@ -446,13 +459,20 @@ function getCSS(P: string): string {
446
459
  .\${P}-group ~ .\${P}-group {
447
460
  margin-top: var(--\${P}-group-gap);
448
461
  }
449
- .\${P}-row {
462
+ .\${P}-group {
450
463
  display: grid;
451
464
  grid-template-columns: var(--\${P}-grid-columns);
452
465
  column-gap: var(--\${P}-column-gap);
466
+ }
467
+ .\${P}-row {
468
+ grid-column: 2 / -1;
469
+ display: grid;
470
+ grid-template-columns: subgrid;
453
471
  align-items: baseline;
454
472
  }
455
473
  .\${P}-group-label {
474
+ grid-column: 1;
475
+ align-self: start;
456
476
  min-width: 0;
457
477
  overflow-wrap: anywhere;
458
478
  }
@@ -471,7 +491,7 @@ function getCSS(P: string): string {
471
491
  }
472
492
  .\${P}-interactive .\${P}-row:hover .\${P}-title,
473
493
  .\${P}-row:focus-within .\${P}-title,
474
- .\${P}-state-hover .\${P}-row:first-child .\${P}-title {
494
+ .\${P}-state-hover .\${P}-group-label + .\${P}-row .\${P}-title {
475
495
  color: var(--\${P}-text-hover-color, var(--\${P}-text-color));
476
496
  }
477
497
  \`;
@@ -622,11 +642,12 @@ export function ArchivePopup({
622
642
  }: ArchivePopupProps) {
623
643
  const { prefix: P } = useScopedStyles();
624
644
  const {
625
- type = 'a',
645
+ type = 'b',
626
646
  triggerLabel = 'Archive',
627
647
  closeLabel = 'Close',
628
648
  columns = ARCHIVE_POPUP_MIN_COLUMNS,
629
649
  columnGap = DEFAULT_COLUMN_GAP,
650
+ hoverInterval = DEFAULT_HOVER_INTERVAL_MS,
630
651
  panelPosition,
631
652
  panelWidth = DEFAULT_PANEL_WIDTH,
632
653
  panelPadding = DEFAULT_PANEL_PADDING,
@@ -653,6 +674,8 @@ export function ArchivePopup({
653
674
  const [isOverlayActive, setIsOverlayActive] = useState(false);
654
675
  const [isOverlaySettled, setIsOverlaySettled] = useState(false);
655
676
  const [activeIndex, setActiveIndex] = useState<number | null>(null);
677
+ // Which of the hovered row's images shows, counted afresh on every hover.
678
+ const [activeMediaIndex, setActiveMediaIndex] = useState(0);
656
679
  const [mountedMedia, setMountedMedia] = useState<Set<number>>(() => new Set());
657
680
  const [closePosition, setClosePosition] = useState<{ top: number; left: number } | null>(null);
658
681
  const [layoutStyle, setLayoutStyle] = useState<CSSProperties>({});
@@ -661,8 +684,8 @@ export function ArchivePopup({
661
684
 
662
685
  const isEditorCanvas = Boolean(isEditor && !isPreviewMode);
663
686
  const isInteractive = !isEditor || Boolean(isPreviewMode);
664
- // B has no popup to open: its panel is always shown in place of the label.
665
- const isInline = type === 'b';
687
+ // A has no popup to open: its panel is always shown in place of the label.
688
+ const isInline = type === 'a';
666
689
  const isOpenPinned = isEditorCanvas && currentState === 'open' && !unavailableStates?.includes('open');
667
690
  // Escape from preview lands in edit mode: a popup opened there stays open, with its controls.
668
691
  const isOpen = !isInline && (isOpenPinned || ((isInteractive || Boolean(isEditMode)) && isOpenUser));
@@ -738,7 +761,7 @@ export function ArchivePopup({
738
761
  return () => document.removeEventListener('keydown', onKeyDown);
739
762
  }, [isOpen, isInteractive]);
740
763
 
741
- // B's media fills the screen above the page, so a copy of the panel is laid exactly over the real one to stay readable.
764
+ // A's media fills the screen above the page, so a copy of the panel is laid exactly over the real one to stay readable.
742
765
  useLayoutEffect(() => {
743
766
  if (!isInline || activeIndex === null) return;
744
767
  const panelEl = panelRef.current;
@@ -780,13 +803,35 @@ export function ArchivePopup({
780
803
  triggerRef.current?.focus({ preventScroll: true });
781
804
  };
782
805
 
806
+ // Every row's images are fetched once the list can be hovered, so a row's first hover shows its image at once
807
+ // rather than after it loads; videos are left to load on hover.
808
+ const isListShown = isInteractive && (isInline || isOpen);
809
+ useEffect(() => {
810
+ if (!isListShown) return;
811
+ (content ?? []).forEach((item) => getArchivePopupRowMedia(item).forEach((media) => {
812
+ if (!isVideoMedia(media)) new Image().src = media.assetId;
813
+ }));
814
+ }, [isListShown, content]);
815
+
816
+ // A hovered row with several images shows them in turn, round and round, for as long as it stays hovered.
817
+ const activeRowMediaCount = activeIndex === null ? 0 : getArchivePopupRowMedia(items[activeIndex]).length;
818
+ useEffect(() => {
819
+ if (activeRowMediaCount < 2) return;
820
+ const timer = window.setInterval(() => {
821
+ setActiveMediaIndex((current) => (current + 1) % activeRowMediaCount);
822
+ }, Math.max(100, hoverInterval));
823
+ return () => window.clearInterval(timer);
824
+ }, [activeIndex, activeRowMediaCount, hoverInterval]);
825
+
783
826
  const showRowMedia = (index: number) => {
784
- if (!isInteractive || !items[index]?.image?.assetId) {
827
+ if (!isInteractive || getArchivePopupRowMedia(items[index]).length === 0) {
785
828
  setActiveIndex(null);
786
829
  return;
787
830
  }
831
+ // A row's images all load on its first hover, so the next is ready by the time it shows.
788
832
  setMountedMedia((prev) => (prev.has(index) ? prev : new Set(prev).add(index)));
789
833
  if (isInline && activeIndex === null) setLayoutStyle(getLightboxLayoutStyle(wrapperRef.current));
834
+ if (activeIndex !== index) setActiveMediaIndex(0);
790
835
  setIsMediaCut(false);
791
836
  setActiveIndex(index);
792
837
  };
@@ -806,6 +851,13 @@ export function ArchivePopup({
806
851
  const columnTypographyCss = ARCHIVE_POPUP_COLUMN_STYLE_PREFIXES.slice(0, columnCount).map((prefix) => (
807
852
  omitTextColors(textStylesToCss(resolveTextStyle(settings, prefix, 'list'), isEditor))
808
853
  ));
854
+ // Half the difference of the two line heights sets the label's first line on the first title's, exactly
855
+ // while both columns share a font size.
856
+ const labelLineHeight = columnTypographyCss[0].lineHeight;
857
+ const titleLineHeight = columnTypographyCss[1]?.lineHeight;
858
+ const groupLabelOffset = labelLineHeight !== undefined && titleLineHeight !== undefined
859
+ ? \`calc((\${titleLineHeight} - \${labelLineHeight}) / 2)\`
860
+ : undefined;
809
861
 
810
862
  const colorVars = buildColorVars(P, {
811
863
  triggerColor,
@@ -822,18 +874,14 @@ export function ArchivePopup({
822
874
 
823
875
  const mediaLayer = (
824
876
  <div className={cn(\`\${P}-media-layer\`, isMediaCut && \`\${P}-media-layer-instant\`)} aria-hidden="true">
825
- {[...mountedMedia].map((index) => {
826
- const media = items[index]?.image;
827
- if (!media?.assetId) return null;
828
- return (
829
- <ArchivePopupMediaItem
830
- key={\`\${index}-\${media.assetId}\`}
831
- P={P}
832
- media={media}
833
- isVisible={activeIndex === index}
834
- />
835
- );
836
- })}
877
+ {[...mountedMedia].flatMap((index) => getArchivePopupRowMedia(items[index]).map((media, mediaIndex) => (
878
+ <ArchivePopupMediaItem
879
+ key={\`\${index}-\${mediaIndex}-\${media.assetId}\`}
880
+ P={P}
881
+ media={media}
882
+ isVisible={activeIndex === index && activeMediaIndex === mediaIndex}
883
+ />
884
+ )))}
837
885
  </div>
838
886
  );
839
887
  // Inline there is no slide-in to wait for, so the canvas controls can measure straight away.
@@ -884,8 +932,16 @@ export function ArchivePopup({
884
932
  style={{ left: 0, width: '100%', height: scaled(Math.max(groupGap, PADDING_HANDLE_SIZE)) }}
885
933
  />
886
934
  )}
887
- <div className={\`\${P}-group\`}>
888
- {group.rows.map(({ item, index }, rowIndex) => (
935
+ {/* The label spans its group's rows, so its line height spaces only its own lines, never the rows beside it;
936
+ a label longer than its rows grows the last track, below them. */}
937
+ <div className={\`\${P}-group\`} style={{ gridTemplateRows: \`repeat(\${group.rows.length}, auto) 1fr\` }}>
938
+ <span
939
+ className={\`\${P}-group-label\`}
940
+ style={{ ...columnTypographyCss[0], gridRow: \`1 / span \${group.rows.length + 1}\`, marginTop: groupLabelOffset }}
941
+ >
942
+ {group.label}
943
+ </span>
944
+ {group.rows.map(({ item, index }) => (
889
945
  <div
890
946
  key={index}
891
947
  className={cn(\`\${P}-row\`, isCopy && index === activeIndex && \`\${P}-row-active\`)}
@@ -896,9 +952,6 @@ export function ArchivePopup({
896
952
  onBlur: () => hideRowMedia(index),
897
953
  })}
898
954
  >
899
- <span className={\`\${P}-group-label\`} style={columnTypographyCss[0]}>
900
- {rowIndex === 0 ? group.label : ''}
901
- </span>
902
955
  {titleKeys.map((key, titleIndex) => {
903
956
  const title = item[key];
904
957
  return (
@@ -975,10 +1028,12 @@ export function ArchivePopup({
975
1028
  style={colorVars}
976
1029
  >
977
1030
  {isInline ? renderPanel(false) : (
1031
+ // The overlay lets the page show through, so the label fades out with it rather than sit under the close.
1032
+ // Only faded, it keeps the component's size and can still take focus back on close.
978
1033
  <button
979
1034
  ref={triggerRef}
980
1035
  type="button"
981
- className={\`\${P}-trigger\`}
1036
+ className={cn(\`\${P}-trigger\`, isOverlayActive && \`\${P}-trigger-hidden\`)}
982
1037
  style={triggerTypographyCss}
983
1038
  aria-haspopup="dialog"
984
1039
  aria-expanded={isOpen}
@@ -997,7 +1052,7 @@ export function ArchivePopup({
997
1052
  </>
998
1053
  );
999
1054
  }
1000
- `, C = `import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent, type PointerEvent, type ReactNode } from 'react';
1055
+ `, w = `import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent, type PointerEvent, type ReactNode } from 'react';
1001
1056
  import { CommonComponentProps } from '../props';
1002
1057
  import { buildColorVars, scalingValue, useScopedStyles } from '../utils';
1003
1058
  import { useLightboxScrollLock } from '../utils/useLightboxScrollLock';
@@ -3638,7 +3693,7 @@ export function Burger({
3638
3693
  </div>
3639
3694
  );
3640
3695
  }
3641
- `, w = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3696
+ `, C = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3642
3697
  import { CommonComponentProps } from '../props';
3643
3698
  import { LinkWrapper, useScopedStyles, type ContentLink } from '../utils/index';
3644
3699
 
@@ -25051,8 +25106,8 @@ export function Waterfall({
25051
25106
  }
25052
25107
  `, U = {
25053
25108
  [y.id]: S,
25054
- [b.id]: C,
25055
- [x.id]: w,
25109
+ [b.id]: w,
25110
+ [x.id]: C,
25056
25111
  [P.id]: $,
25057
25112
  [v.id]: I,
25058
25113
  [f.id]: T,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/components",
3
- "version": "1.0.107-alpha.1",
3
+ "version": "1.0.107-alpha.3",
4
4
  "description": "Custom components for control editor and public websites.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",