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

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.
Files changed (50) hide show
  1. package/dist/Chronicles-D7E1yVzl.mjs +721 -0
  2. package/dist/Chronicles-hsVYwlUI.js +198 -0
  3. package/dist/ChroniclesComponent-9M_JIJlG.js +1 -0
  4. package/dist/{PretextComponent-BiS9XbZr.mjs → ChroniclesComponent-DrFDru99.mjs} +857 -425
  5. package/dist/{ClickGallerie-CYQMgrIr.js → ClickGallerie-41L7IKhN.js} +1 -1
  6. package/dist/{ClickGallerie-o2U6oyOF.mjs → ClickGallerie-CBquEuXQ.mjs} +1 -1
  7. package/dist/Components/Chronicles/Chronicles.d.ts +120 -0
  8. package/dist/Components/Chronicles/ChroniclesComponent.d.ts +313 -0
  9. package/dist/Components/utils/LinkWrapper.d.ts +1 -0
  10. package/dist/{ControlSlider-Kkec-i14.js → ControlSlider-D91b53un.js} +1 -1
  11. package/dist/{ControlSlider-LcZmviGX.mjs → ControlSlider-mp-LvrTR.mjs} +1 -1
  12. package/dist/{FAQ-BxhMo7T8.js → FAQ-8goVE-aB.js} +1 -1
  13. package/dist/{FAQ-CdwSft5p.mjs → FAQ-KL9X1-xe.mjs} +1 -1
  14. package/dist/{Grid-CFHTP3mb.js → Grid-Dec4bMvK.js} +1 -1
  15. package/dist/{Grid-e-gLfsji.mjs → Grid-wxlTwFLb.mjs} +1 -1
  16. package/dist/{ImageRevealSlider-BuukTGAK.js → ImageRevealSlider-Bv092gwv.js} +1 -1
  17. package/dist/{ImageRevealSlider-Df9sygk9.mjs → ImageRevealSlider-K_nNoquq.mjs} +1 -1
  18. package/dist/{Lightbox-DaunVrkp.js → Lightbox-C2r7Wt_8.js} +1 -1
  19. package/dist/{Lightbox-C_fXsfdz.mjs → Lightbox-Cyvva2uu.mjs} +1 -1
  20. package/dist/LinkWrapper-CFEH047t.mjs +14 -0
  21. package/dist/LinkWrapper-CzFwFtgU.js +1 -0
  22. package/dist/{Marquee-DfIP-tIN.js → Marquee-BacOdRJ9.js} +1 -1
  23. package/dist/{Marquee-DByooiWP.mjs → Marquee-DGbeihUh.mjs} +1 -1
  24. package/dist/{MarqueeText-DsUiV6Zv.js → MarqueeText-BuEx2FCt.js} +1 -1
  25. package/dist/{MarqueeText-D6FNCe6P.mjs → MarqueeText-DTlCevPX.mjs} +1 -1
  26. package/dist/{RichTextRenderer-K90Dd7pt.js → RichTextRenderer-CUEc4FaL.js} +1 -1
  27. package/dist/{RichTextRenderer-BptwNpbJ.mjs → RichTextRenderer-DizfCZEz.mjs} +1 -1
  28. package/dist/{Slider20-fMVeRfgx.js → Slider20-BdeHmG8C.js} +1 -1
  29. package/dist/{Slider20-CCzixTiN.mjs → Slider20-DS-FTzQC.mjs} +1 -1
  30. package/dist/{TestimonialGrid-CiCagfBU.js → TestimonialGrid-B0JHzqhv.js} +1 -1
  31. package/dist/{TestimonialGrid-CbsVxSn9.mjs → TestimonialGrid-BOqSqVin.mjs} +1 -1
  32. package/dist/{TestimonialSingle-BVm3Amrl.mjs → TestimonialSingle-7-PMnQ7u.mjs} +1 -1
  33. package/dist/{TestimonialSingle-BWXynGjv.js → TestimonialSingle-Bx_V-cYE.js} +1 -1
  34. package/dist/components-BDWmQ4M_.js +1 -0
  35. package/dist/{components-ljYgHKal.mjs → components-D6aHWqNw.mjs} +18 -17
  36. package/dist/elements.js +1 -1
  37. package/dist/elements.mjs +16 -15
  38. package/dist/elements.node.js +1 -1
  39. package/dist/elements.node.mjs +1 -1
  40. package/dist/index.js +1 -1
  41. package/dist/index.mjs +2 -2
  42. package/dist/sources.js +1031 -22
  43. package/dist/sources.mjs +1055 -45
  44. package/dist/utils.js +1 -1
  45. package/dist/utils.mjs +1 -1
  46. package/package.json +1 -1
  47. package/dist/LinkWrapper-Ca84iPtg.js +0 -1
  48. package/dist/LinkWrapper-DZs9hlOn.mjs +0 -13
  49. package/dist/PretextComponent-DWOy-dqD.js +0 -1
  50. package/dist/components-CJlisugq.js +0 -1
package/dist/sources.mjs CHANGED
@@ -1,5 +1,5 @@
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 } from "./PretextComponent-BiS9XbZr.mjs";
2
- const y = `import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent, type PointerEvent, type ReactNode } from 'react';
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, j as b, B as y } from "./ChroniclesComponent-DrFDru99.mjs";
2
+ const S = `import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent, type PointerEvent, type ReactNode } from 'react';
3
3
  import { CommonComponentProps } from '../props';
4
4
  import { buildColorVars, scalingValue, useScopedStyles } from '../utils';
5
5
  import { useLightboxScrollLock } from '../utils/useLightboxScrollLock';
@@ -2684,7 +2684,1016 @@ export function Burger({
2684
2684
  </div>
2685
2685
  );
2686
2686
  }
2687
- `, S = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2687
+ `, C = `import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type MouseEvent } from 'react';
2688
+ import { createPortal } from 'react-dom';
2689
+ import cn from 'classnames';
2690
+ import { CommonComponentProps } from '../props';
2691
+ import { buildColorVars, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
2692
+ import { buildValidUrl } from '../utils/LinkWrapper';
2693
+ import { omitTextColors, TextStyles, textStylesToCss } from '../utils/textStylesToCss';
2694
+ import { useLightboxScrollLock } from '../utils/useLightboxScrollLock';
2695
+
2696
+ export const CHRONICLES_EXTRA_TITLE_KEYS = ['title2', 'title3', 'title4'] as const;
2697
+ export const CHRONICLES_COLUMN_WIDTH_KEYS = ['column1Width', 'column2Width', 'column3Width', 'column4Width'] as const;
2698
+ export const CHRONICLES_COLUMN_STYLE_PREFIXES = ['column1', 'column2', 'column3', 'column4', 'column5'] as const;
2699
+
2700
+ const TITLE_KEYS = ['title', ...CHRONICLES_EXTRA_TITLE_KEYS] as const;
2701
+
2702
+ const PANEL_POSITION_OFFSETS = {
2703
+ center: { x: '50%', y: '50%' },
2704
+ 'left-top': { x: '0%', y: '0%' },
2705
+ 'top-center': { x: '50%', y: '0%' },
2706
+ 'top-right': { x: '100%', y: '0%' },
2707
+ 'left-center': { x: '0%', y: '50%' },
2708
+ 'right-center': { x: '100%', y: '50%' },
2709
+ 'left-bottom': { x: '0%', y: '100%' },
2710
+ 'bottom-center': { x: '50%', y: '100%' },
2711
+ 'right-bottom': { x: '100%', y: '100%' },
2712
+ } as const;
2713
+
2714
+ type ChroniclesPanelPosition = keyof typeof PANEL_POSITION_OFFSETS;
2715
+
2716
+ export const CHRONICLES_PANEL_POSITIONS = Object.keys(PANEL_POSITION_OFFSETS) as ChroniclesPanelPosition[];
2717
+
2718
+ const OVERLAY_ANIM_MS = 300;
2719
+ const IMAGE_FADE_MS = 300;
2720
+ const MIN_HANDLE_SIZE = 0.004;
2721
+ const MIN_COLUMN_WIDTH_PX = 20;
2722
+ const VIDEO_EXTENSION_RE = /\\.(mp4|webm|ogg|mov)(\\?|$)/i;
2723
+
2724
+ const LIGHTBOX_CSS_VARS = [
2725
+ '--cntrl-article-width',
2726
+ '--cntrl-article-top',
2727
+ '--cntrl-article-left',
2728
+ '--cntrl-viewport-height',
2729
+ ] as const;
2730
+
2731
+ const COLOR_VAR_MAP = {
2732
+ triggerColor: 'trigger-color',
2733
+ triggerHoverColor: 'trigger-hover-color',
2734
+ closeColor: 'close-color',
2735
+ closeHoverColor: 'close-hover-color',
2736
+ panelColor: 'panel-color',
2737
+ textColor: 'text-color',
2738
+ textHoverColor: 'text-hover-color',
2739
+ overlayColor: 'overlay-color',
2740
+ } as const;
2741
+
2742
+ const PADDING_CONTROLS = [
2743
+ { side: 'top', axis: 'y', variant: 'row-padding' },
2744
+ { side: 'bottom', axis: 'y', variant: 'row-padding', reverse: true },
2745
+ { side: 'left', axis: 'x', variant: 'column-padding', opposite: 'right' },
2746
+ { side: 'right', axis: 'x', variant: 'column-padding', opposite: 'left', reverse: true },
2747
+ ] as const;
2748
+
2749
+ type Padding = { top: number; right: number; bottom: number; left: number };
2750
+
2751
+ type ColumnWidthKey = typeof CHRONICLES_COLUMN_WIDTH_KEYS[number];
2752
+
2753
+ type TextStylePrefix = 'trigger' | typeof CHRONICLES_COLUMN_STYLE_PREFIXES[number];
2754
+
2755
+ type ChroniclesMedia = {
2756
+ assetId: string;
2757
+ name?: string;
2758
+ type?: 'image' | 'video';
2759
+ objectFit?: 'cover' | 'contain';
2760
+ };
2761
+
2762
+ type ChroniclesItem = {
2763
+ group?: string;
2764
+ title?: string;
2765
+ title2?: string;
2766
+ title3?: string;
2767
+ title4?: string;
2768
+ image?: ChroniclesMedia[];
2769
+ link?: ContentLink;
2770
+ };
2771
+
2772
+ type ChroniclesGroup = {
2773
+ label: string;
2774
+ rows: { item: ChroniclesItem; index: number }[];
2775
+ };
2776
+
2777
+ type TextStyleFields = {
2778
+ FontFamily: string;
2779
+ FontSettings: { fontWeight: number; fontStyle: string };
2780
+ FontSize: number;
2781
+ LineHeight: number;
2782
+ LetterSpacing: number;
2783
+ WordSpacing: number;
2784
+ TextAlign?: TextStyles['textAlign'];
2785
+ TextAppearance: TextStyles['textAppearance'];
2786
+ };
2787
+
2788
+ type PrefixedTextStyle<Prefix extends string> = {
2789
+ [Key in keyof TextStyleFields as \`\${Prefix}\${Key}\`]: TextStyleFields[Key];
2790
+ };
2791
+
2792
+ type ChroniclesSettings = PrefixedTextStyle<TextStylePrefix> & Partial<Record<ColumnWidthKey, number>> & {
2793
+ type: 'a' | 'b';
2794
+ triggerLabel: string;
2795
+ closeLabel: string;
2796
+ columns: number;
2797
+ columnGap: number;
2798
+ hoverInterval: number;
2799
+ panelPosition: ChroniclesPanelPosition;
2800
+ panelWidth: number;
2801
+ panelPadding: Padding;
2802
+ panelRadius: number;
2803
+ groupGap: number;
2804
+ triggerColor: string;
2805
+ triggerHoverColor: string;
2806
+ closeColor: string;
2807
+ closeHoverColor: string;
2808
+ panelColor: string;
2809
+ textColor: string;
2810
+ textHoverColor: string;
2811
+ overlayColor: string;
2812
+ };
2813
+
2814
+ type ColumnLayoutSettings = Pick<ChroniclesSettings, 'columns' | 'columnGap' | 'panelWidth' | 'panelPadding' | ColumnWidthKey>;
2815
+
2816
+ type ChroniclesProps = {
2817
+ settings: ChroniclesSettings;
2818
+ content?: ChroniclesItem[];
2819
+ isEditor?: boolean;
2820
+ isEditMode?: boolean;
2821
+ isPreviewMode?: boolean;
2822
+ activeEvent?: string;
2823
+ portalId?: string;
2824
+ } & CommonComponentProps;
2825
+
2826
+ function getColumnsSpace({ columns, columnGap, panelWidth, panelPadding }: ColumnLayoutSettings): number {
2827
+ return Math.max(0, panelWidth - panelPadding.left - panelPadding.right - (columns - 1) * columnGap);
2828
+ }
2829
+
2830
+ export function getChroniclesEqualColumnWidths(settings: ColumnLayoutSettings): Partial<Record<ColumnWidthKey, number>> {
2831
+ const width = getColumnsSpace(settings) / settings.columns;
2832
+ return Object.fromEntries(CHRONICLES_COLUMN_WIDTH_KEYS.slice(0, settings.columns - 1).map((key) => [key, width]));
2833
+ }
2834
+
2835
+ export function applyChroniclesColumnCountChange(
2836
+ nextSettings: Record<string, any>,
2837
+ prevSettings: Record<string, any>,
2838
+ ): Record<string, any> {
2839
+ if (typeof nextSettings.columns !== 'number' || nextSettings.columns === prevSettings.columns) {
2840
+ return nextSettings;
2841
+ }
2842
+ return { ...nextSettings, ...getChroniclesEqualColumnWidths({ ...prevSettings, ...nextSettings } as ColumnLayoutSettings) };
2843
+ }
2844
+
2845
+ // The last column takes the remaining space; sized columns shrink together when they no longer fit.
2846
+ function resolveColumnWidths(settings: ColumnLayoutSettings): number[] {
2847
+ const space = getColumnsSpace(settings);
2848
+ const sized = CHRONICLES_COLUMN_WIDTH_KEYS.slice(0, settings.columns - 1).map((key) => {
2849
+ const width = settings[key];
2850
+ return typeof width === 'number' ? Math.max(0, width) : space / settings.columns;
2851
+ });
2852
+ const sizedTotal = sized.reduce((sum, width) => sum + width, 0);
2853
+ const scale = sizedTotal > space ? space / sizedTotal : 1;
2854
+ return [...sized.map((width) => width * scale), Math.max(0, space - sizedTotal * scale)];
2855
+ }
2856
+
2857
+ function getGridTemplateColumns(widths: number[]): string {
2858
+ const total = widths.reduce((sum, width) => sum + width, 0);
2859
+ return widths.map((width) => \`minmax(0, \${total > 0 ? (width / total) * 100 : 1}fr)\`).join(' ');
2860
+ }
2861
+
2862
+ // A row with an empty group continues the group above it.
2863
+ function groupRows(items: ChroniclesItem[]): ChroniclesGroup[] {
2864
+ const groups: ChroniclesGroup[] = [];
2865
+ items.forEach((item, index) => {
2866
+ const label = item.group?.trim() ?? '';
2867
+ const current = groups[groups.length - 1];
2868
+ if (!current || (label !== '' && label !== current.label)) {
2869
+ groups.push({ label, rows: [{ item, index }] });
2870
+ return;
2871
+ }
2872
+ current.rows.push({ item, index });
2873
+ });
2874
+ return groups;
2875
+ }
2876
+
2877
+ function getRowMedia(item: ChroniclesItem | undefined): ChroniclesMedia[] {
2878
+ return (item?.image ?? []).filter((media) => Boolean(media?.assetId));
2879
+ }
2880
+
2881
+ function getMediaKey(rowIndex: number, mediaIndex: number, assetId: string): string {
2882
+ return \`\${rowIndex}-\${mediaIndex}-\${assetId}\`;
2883
+ }
2884
+
2885
+ function isVideoMedia({ type, name, assetId }: ChroniclesMedia): boolean {
2886
+ if (type) return type === 'video';
2887
+ return VIDEO_EXTENSION_RE.test(name ?? '') || VIDEO_EXTENSION_RE.test(assetId);
2888
+ }
2889
+
2890
+ function findLayoutContainer(element: HTMLElement | null): HTMLElement | null {
2891
+ for (let el = element; el; el = el.parentElement) {
2892
+ if (getComputedStyle(el).getPropertyValue('--cntrl-article-width').trim()) return el;
2893
+ }
2894
+ return element;
2895
+ }
2896
+
2897
+ function getLayoutStyle(container: HTMLElement | null): CSSProperties {
2898
+ const layoutContainer = findLayoutContainer(container);
2899
+ if (!layoutContainer) return {};
2900
+ const computed = getComputedStyle(layoutContainer);
2901
+ return Object.fromEntries(
2902
+ LIGHTBOX_CSS_VARS
2903
+ .map((name) => [name, computed.getPropertyValue(name).trim()])
2904
+ .filter(([, value]) => value),
2905
+ );
2906
+ }
2907
+
2908
+ function resolveTextStyle(settings: ChroniclesSettings, prefix: TextStylePrefix): TextStyles {
2909
+ const read = <Key extends keyof TextStyleFields>(key: Key) => (
2910
+ (settings as Record<string, unknown>)[\`\${prefix}\${key}\`] as TextStyleFields[Key]
2911
+ );
2912
+ return {
2913
+ fontSettings: { fontFamily: read('FontFamily'), ...read('FontSettings') },
2914
+ fontSize: read('FontSize'),
2915
+ lineHeight: read('LineHeight'),
2916
+ letterSpacing: read('LetterSpacing'),
2917
+ wordSpacing: read('WordSpacing'),
2918
+ textAlign: read('TextAlign'),
2919
+ textAppearance: read('TextAppearance'),
2920
+ color: '#000000',
2921
+ };
2922
+ }
2923
+
2924
+ function getCSS(P: string): string {
2925
+ return \`
2926
+ .\${P}-trigger,
2927
+ .\${P}-close {
2928
+ display: inline-block;
2929
+ margin: 0;
2930
+ padding: 0;
2931
+ border: 0;
2932
+ background: none;
2933
+ cursor: pointer;
2934
+ white-space: nowrap;
2935
+ transition: color 150ms ease;
2936
+ -webkit-appearance: none;
2937
+ appearance: none;
2938
+ -webkit-tap-highlight-color: transparent;
2939
+ }
2940
+ .\${P}-trigger {
2941
+ color: var(--\${P}-trigger-color);
2942
+ transition: color 150ms ease, opacity \${OVERLAY_ANIM_MS}ms ease;
2943
+ }
2944
+ .\${P}-trigger-hidden {
2945
+ opacity: 0;
2946
+ }
2947
+ .\${P}-close {
2948
+ position: absolute;
2949
+ z-index: 2;
2950
+ color: var(--\${P}-close-color);
2951
+ }
2952
+ .\${P}-trigger:focus,
2953
+ .\${P}-close:focus {
2954
+ outline: none;
2955
+ }
2956
+ .\${P}-trigger:focus-visible,
2957
+ .\${P}-close:focus-visible {
2958
+ outline: 1px solid currentColor;
2959
+ outline-offset: 2px;
2960
+ }
2961
+ .\${P}-interactive .\${P}-trigger:hover,
2962
+ .\${P}-state-hover .\${P}-trigger {
2963
+ color: var(--\${P}-trigger-hover-color, var(--\${P}-trigger-color));
2964
+ }
2965
+ .\${P}-close:hover {
2966
+ color: var(--\${P}-close-hover-color, var(--\${P}-close-color));
2967
+ }
2968
+ .\${P}-editor .\${P}-trigger {
2969
+ cursor: default;
2970
+ }
2971
+ .\${P}-overlay {
2972
+ position: fixed;
2973
+ inset: 0;
2974
+ z-index: 9997;
2975
+ overflow: hidden;
2976
+ overscroll-behavior: none;
2977
+ opacity: 0;
2978
+ pointer-events: none;
2979
+ transition: opacity \${OVERLAY_ANIM_MS}ms ease;
2980
+ }
2981
+ .\${P}-inline-layer {
2982
+ position: fixed;
2983
+ inset: 0;
2984
+ z-index: 9997;
2985
+ overflow: hidden;
2986
+ pointer-events: none;
2987
+ }
2988
+ .\${P}-overlay-editor {
2989
+ inset: auto;
2990
+ top: var(--cntrl-article-top, 0);
2991
+ left: var(--cntrl-article-left, 0);
2992
+ width: var(--cntrl-article-width, 100vw) !important;
2993
+ height: var(--cntrl-viewport-height, 100vh) !important;
2994
+ }
2995
+ .\${P}-overlay-edit-mode {
2996
+ z-index: 1;
2997
+ }
2998
+ .\${P}-overlay-active {
2999
+ opacity: 1;
3000
+ pointer-events: auto;
3001
+ }
3002
+ .\${P}-backdrop {
3003
+ position: absolute;
3004
+ inset: 0;
3005
+ background-color: var(--\${P}-overlay-color);
3006
+ }
3007
+ .\${P}-media-layer {
3008
+ position: absolute;
3009
+ inset: 0;
3010
+ pointer-events: none;
3011
+ }
3012
+ .\${P}-media {
3013
+ position: absolute;
3014
+ inset: 0;
3015
+ width: 100%;
3016
+ height: 100%;
3017
+ object-fit: cover;
3018
+ opacity: 0;
3019
+ }
3020
+ .\${P}-media-contain {
3021
+ object-fit: contain;
3022
+ }
3023
+ .\${P}-media-visible,
3024
+ .\${P}-media-fading {
3025
+ transition: opacity \${IMAGE_FADE_MS}ms cubic-bezier(0, 0, 0.58, 1);
3026
+ }
3027
+ .\${P}-media-visible {
3028
+ z-index: 1;
3029
+ opacity: 1;
3030
+ }
3031
+ .\${P}-media-covered {
3032
+ opacity: 1;
3033
+ }
3034
+ .\${P}-media-fading {
3035
+ opacity: 0;
3036
+ }
3037
+ .\${P}-media-layer-instant .\${P}-media {
3038
+ transition: none;
3039
+ }
3040
+ .\${P}-panel {
3041
+ position: absolute;
3042
+ top: var(--\${P}-panel-y);
3043
+ left: var(--\${P}-panel-x);
3044
+ z-index: 1;
3045
+ box-sizing: border-box;
3046
+ max-width: 100%;
3047
+ max-height: 100%;
3048
+ overflow-y: auto;
3049
+ transform: translate(calc(-1 * var(--\${P}-panel-x)), calc(-1 * var(--\${P}-panel-y) + 12px));
3050
+ background-color: var(--\${P}-panel-color);
3051
+ color: var(--\${P}-text-color);
3052
+ overscroll-behavior: contain;
3053
+ transition: transform \${OVERLAY_ANIM_MS}ms cubic-bezier(0, 0, 0.58, 1);
3054
+ }
3055
+ .\${P}-overlay-active .\${P}-panel {
3056
+ transform: translate(calc(-1 * var(--\${P}-panel-x)), calc(-1 * var(--\${P}-panel-y)));
3057
+ }
3058
+ .\${P}-panel-settled {
3059
+ transition: none;
3060
+ }
3061
+ .\${P}-panel-inline {
3062
+ position: relative;
3063
+ top: auto;
3064
+ left: auto;
3065
+ max-height: none;
3066
+ transform: none;
3067
+ transition: none;
3068
+ }
3069
+ .\${P}-panel-copy {
3070
+ position: absolute;
3071
+ pointer-events: none;
3072
+ }
3073
+ @media (prefers-reduced-motion: reduce) {
3074
+ .\${P}-panel {
3075
+ transition: none;
3076
+ }
3077
+ }
3078
+ .\${P}-group {
3079
+ display: grid;
3080
+ grid-template-columns: var(--\${P}-grid-columns);
3081
+ column-gap: var(--\${P}-column-gap);
3082
+ }
3083
+ .\${P}-group ~ .\${P}-group {
3084
+ margin-top: var(--\${P}-group-gap);
3085
+ }
3086
+ .\${P}-group-label {
3087
+ grid-column: 1;
3088
+ align-self: start;
3089
+ min-width: 0;
3090
+ overflow-wrap: anywhere;
3091
+ }
3092
+ .\${P}-row {
3093
+ grid-column: 2 / -1;
3094
+ display: grid;
3095
+ grid-template-columns: subgrid;
3096
+ align-items: baseline;
3097
+ }
3098
+ a.\${P}-row {
3099
+ color: inherit;
3100
+ text-decoration: none;
3101
+ }
3102
+ .\${P}-group-unlabeled .\${P}-row {
3103
+ grid-column: 1 / -1;
3104
+ }
3105
+ .\${P}-title {
3106
+ min-width: 0;
3107
+ overflow-wrap: anywhere;
3108
+ white-space: pre-line;
3109
+ transition: color 150ms cubic-bezier(0, 0, 0.58, 1);
3110
+ }
3111
+ .\${P}-interactive .\${P}-row:hover .\${P}-title,
3112
+ .\${P}-row:focus-visible .\${P}-title,
3113
+ .\${P}-panel-copy .\${P}-row-active .\${P}-title,
3114
+ .\${P}-state-hover .\${P}-row:first-of-type .\${P}-title {
3115
+ color: var(--\${P}-text-hover-color, var(--\${P}-text-color));
3116
+ }
3117
+ .\${P}-control-anchor {
3118
+ position: absolute;
3119
+ pointer-events: none;
3120
+ z-index: 2;
3121
+ }
3122
+ \`;
3123
+ }
3124
+
3125
+ type ChroniclesMediaItemProps = {
3126
+ P: string;
3127
+ media: ChroniclesMedia;
3128
+ isVisible: boolean;
3129
+ isLoaded: boolean;
3130
+ isCovered: boolean;
3131
+ isFading: boolean;
3132
+ onLoad: () => void;
3133
+ };
3134
+
3135
+ function ChroniclesMediaItem({ P, media, isVisible, isLoaded, isCovered, isFading, onLoad }: ChroniclesMediaItemProps) {
3136
+ const videoRef = useRef<HTMLVideoElement>(null);
3137
+ const isVideo = isVideoMedia(media);
3138
+ const className = cn(
3139
+ \`\${P}-media\`,
3140
+ media.objectFit === 'contain' && \`\${P}-media-contain\`,
3141
+ isVisible && isLoaded && \`\${P}-media-visible\`,
3142
+ isCovered && \`\${P}-media-covered\`,
3143
+ isFading && \`\${P}-media-fading\`,
3144
+ );
3145
+
3146
+ useEffect(() => {
3147
+ const video = videoRef.current;
3148
+ if (!video) return;
3149
+ if (isVisible) {
3150
+ video.play()?.catch(() => {});
3151
+ } else {
3152
+ video.pause();
3153
+ }
3154
+ }, [isVisible]);
3155
+
3156
+ if (isVideo) {
3157
+ return (
3158
+ <video
3159
+ ref={videoRef}
3160
+ className={className}
3161
+ src={media.assetId}
3162
+ muted
3163
+ loop
3164
+ playsInline
3165
+ preload="auto"
3166
+ onLoadedData={onLoad}
3167
+ />
3168
+ );
3169
+ }
3170
+
3171
+ return <img className={className} src={media.assetId} alt="" decoding="async" onLoad={onLoad} />;
3172
+ }
3173
+
3174
+ function renderColumnWidthControls(
3175
+ P: string,
3176
+ widths: number[],
3177
+ paddingLeft: number,
3178
+ columnGap: number,
3179
+ scaled: (value: number) => string,
3180
+ ) {
3181
+ const lastWidth = widths[widths.length - 1];
3182
+ let columnLeft = paddingLeft;
3183
+ return widths.slice(0, -1).map((width, index) => {
3184
+ const gapCenter = columnLeft + width + columnGap / 2;
3185
+ columnLeft += width + columnGap;
3186
+ return (
3187
+ <div
3188
+ key={CHRONICLES_COLUMN_WIDTH_KEYS[index]}
3189
+ data-controls={CHRONICLES_COLUMN_WIDTH_KEYS[index]}
3190
+ data-controls-axis="x"
3191
+ data-controls-variant="column-width"
3192
+ data-controls-min={String(MIN_COLUMN_WIDTH_PX)}
3193
+ data-controls-max-fraction={String(width + lastWidth)}
3194
+ className={\`\${P}-control-anchor\`}
3195
+ style={{ top: 0, left: scaled(gapCenter - MIN_HANDLE_SIZE / 2), width: scaled(MIN_HANDLE_SIZE), height: '100%' }}
3196
+ />
3197
+ );
3198
+ });
3199
+ }
3200
+
3201
+ function renderPanelPaddingControls(
3202
+ P: string,
3203
+ panelWidth: number,
3204
+ padding: Padding,
3205
+ scaled: (value: number) => string,
3206
+ ) {
3207
+ return PADDING_CONTROLS.map((control) => {
3208
+ const size = scaled(Math.max(padding[control.side], MIN_HANDLE_SIZE));
3209
+ const isHorizontal = control.axis === 'x';
3210
+ return (
3211
+ <div
3212
+ key={control.side}
3213
+ data-controls={\`panelPadding.\${control.side}\`}
3214
+ data-controls-axis={control.axis}
3215
+ data-controls-variant={control.variant}
3216
+ data-controls-reverse={'reverse' in control ? '' : undefined}
3217
+ data-controls-min="0"
3218
+ data-controls-max-fraction={'opposite' in control ? String(Math.max(0, panelWidth - padding[control.opposite])) : undefined}
3219
+ className={\`\${P}-control-anchor\`}
3220
+ style={{
3221
+ [control.side]: 0,
3222
+ ...(isHorizontal ? { top: 0, width: size, height: '100%' } : { left: 0, width: '100%', height: size }),
3223
+ }}
3224
+ />
3225
+ );
3226
+ });
3227
+ }
3228
+
3229
+ export function Chronicles({
3230
+ settings,
3231
+ content,
3232
+ isEditor,
3233
+ isEditMode,
3234
+ isPreviewMode,
3235
+ activeEvent,
3236
+ portalId,
3237
+ currentState,
3238
+ unavailableStates,
3239
+ }: ChroniclesProps) {
3240
+ const { prefix: P } = useScopedStyles();
3241
+ const {
3242
+ type,
3243
+ triggerLabel,
3244
+ closeLabel,
3245
+ columns,
3246
+ columnGap,
3247
+ hoverInterval,
3248
+ panelPosition,
3249
+ panelWidth,
3250
+ panelPadding,
3251
+ panelRadius,
3252
+ groupGap,
3253
+ triggerColor,
3254
+ triggerHoverColor,
3255
+ closeColor,
3256
+ closeHoverColor,
3257
+ panelColor,
3258
+ textColor,
3259
+ textHoverColor,
3260
+ overlayColor,
3261
+ } = settings;
3262
+ const items = useMemo(() => content ?? [], [content]);
3263
+ const wrapperRef = useRef<HTMLDivElement>(null);
3264
+ const triggerRef = useRef<HTMLButtonElement>(null);
3265
+ const overlayRef = useRef<HTMLDivElement>(null);
3266
+ const closeRef = useRef<HTMLButtonElement>(null);
3267
+ const panelRef = useRef<HTMLDivElement>(null);
3268
+ const inlineLayerRef = useRef<HTMLDivElement>(null);
3269
+ const shownMediaRef = useRef<string | null>(null);
3270
+ const [isUserOpen, setIsUserOpen] = useState(false);
3271
+ const [isOverlayMounted, setIsOverlayMounted] = useState(false);
3272
+ const [isOverlayActive, setIsOverlayActive] = useState(false);
3273
+ const [isOverlaySettled, setIsOverlaySettled] = useState(false);
3274
+ const [activeIndex, setActiveIndex] = useState<number | null>(null);
3275
+ const [activeMediaIndex, setActiveMediaIndex] = useState(0);
3276
+ const [mountedRows, setMountedRows] = useState<Set<number>>(() => new Set());
3277
+ const [loadedMedia, setLoadedMedia] = useState<Set<string>>(() => new Set());
3278
+ const [coveredMedia, setCoveredMedia] = useState<string | null>(null);
3279
+ const [lastShownMedia, setLastShownMedia] = useState<string | null>(null);
3280
+ const [closePosition, setClosePosition] = useState<{ top: number; left: number } | null>(null);
3281
+ const [layoutStyle, setLayoutStyle] = useState<CSSProperties>({});
3282
+ const [copyRect, setCopyRect] = useState<{ top: number; left: number; width: number } | null>(null);
3283
+ const [isMediaCut, setIsMediaCut] = useState(false);
3284
+
3285
+ const isEditorCanvas = Boolean(isEditor && !isPreviewMode);
3286
+ const isInteractive = !isEditorCanvas;
3287
+ const isInline = type === 'a';
3288
+ const isOpenPinned = isEditorCanvas && currentState === 'open' && !unavailableStates?.includes('open');
3289
+ const isOpen = !isInline && (isOpenPinned || ((isInteractive || Boolean(isEditMode)) && isUserOpen));
3290
+ const isListShown = isInteractive && (isInline || isOpen);
3291
+ const scaled = (value: number) => scalingValue(value, isEditor ?? false);
3292
+ const scopedCss = useMemo(() => getCSS(P), [P]);
3293
+ const panelOffset = PANEL_POSITION_OFFSETS[panelPosition];
3294
+ const columnWidths = resolveColumnWidths(settings);
3295
+ const titleKeys = TITLE_KEYS.slice(0, columns - 1);
3296
+ const hasGroupColumn = columns > 1;
3297
+ const groups = useMemo<ChroniclesGroup[]>(() => (
3298
+ hasGroupColumn ? groupRows(items) : [{ label: '', rows: items.map((item, index) => ({ item, index })) }]
3299
+ ), [items, hasGroupColumn]);
3300
+
3301
+ const activeMedia = activeIndex === null ? [] : getRowMedia(items[activeIndex]);
3302
+ const shownAsset = activeMedia[activeMediaIndex];
3303
+ const shownMedia = activeIndex !== null && shownAsset ? getMediaKey(activeIndex, activeMediaIndex, shownAsset.assetId) : null;
3304
+ const isShownMediaLoaded = shownMedia !== null && loadedMedia.has(shownMedia);
3305
+
3306
+ useLightboxScrollLock(isOpen && !isEditorCanvas);
3307
+
3308
+ useEffect(() => {
3309
+ if (isEditorCanvas && !isEditMode) setIsUserOpen(false);
3310
+ }, [isEditorCanvas, isEditMode]);
3311
+
3312
+ useEffect(() => {
3313
+ if (isOpen) {
3314
+ setLayoutStyle(getLayoutStyle(wrapperRef.current));
3315
+ setIsOverlayMounted(true);
3316
+ return;
3317
+ }
3318
+ setIsOverlayActive(false);
3319
+ setActiveIndex(null);
3320
+ const timer = window.setTimeout(() => setIsOverlayMounted(false), OVERLAY_ANIM_MS);
3321
+ return () => window.clearTimeout(timer);
3322
+ }, [isOpen]);
3323
+
3324
+ // Activate a frame after mount so the appear transition has a start state.
3325
+ useEffect(() => {
3326
+ if (!isOpen || !isOverlayMounted) return;
3327
+ overlayRef.current?.getBoundingClientRect();
3328
+ const frame = requestAnimationFrame(() => setIsOverlayActive(true));
3329
+ return () => cancelAnimationFrame(frame);
3330
+ }, [isOpen, isOverlayMounted]);
3331
+
3332
+ useEffect(() => {
3333
+ if (!isOverlayActive) {
3334
+ setIsOverlaySettled(false);
3335
+ return;
3336
+ }
3337
+ const timer = window.setTimeout(() => setIsOverlaySettled(true), OVERLAY_ANIM_MS);
3338
+ return () => window.clearTimeout(timer);
3339
+ }, [isOverlayActive]);
3340
+
3341
+ const updateClosePosition = useCallback(() => {
3342
+ const trigger = triggerRef.current;
3343
+ const overlay = overlayRef.current;
3344
+ if (!trigger || !overlay) return;
3345
+ const triggerRect = trigger.getBoundingClientRect();
3346
+ const overlayRect = overlay.getBoundingClientRect();
3347
+ setClosePosition({ top: triggerRect.top - overlayRect.top, left: triggerRect.left - overlayRect.left });
3348
+ }, []);
3349
+
3350
+ // The editor switches layouts by changing the article vars, so the copied vars must follow them.
3351
+ const isLayerMounted = isOverlayMounted || (isInline && mountedRows.size > 0);
3352
+ useEffect(() => {
3353
+ const wrapper = wrapperRef.current;
3354
+ if (!isLayerMounted || !wrapper || typeof ResizeObserver === 'undefined') return;
3355
+ const update = () => setLayoutStyle((prev) => {
3356
+ const next = getLayoutStyle(wrapper);
3357
+ const isSame = LIGHTBOX_CSS_VARS.every((name) => (prev as Record<string, unknown>)[name] === (next as Record<string, unknown>)[name]);
3358
+ return isSame ? prev : next;
3359
+ });
3360
+ const observer = new ResizeObserver(update);
3361
+ observer.observe(wrapper);
3362
+ const layoutContainer = findLayoutContainer(wrapper);
3363
+ if (layoutContainer && layoutContainer !== wrapper) observer.observe(layoutContainer);
3364
+ return () => observer.disconnect();
3365
+ }, [isLayerMounted]);
3366
+
3367
+ useLayoutEffect(() => {
3368
+ if (!isOverlayMounted) return;
3369
+ updateClosePosition();
3370
+ window.addEventListener('resize', updateClosePosition);
3371
+ return () => window.removeEventListener('resize', updateClosePosition);
3372
+ }, [isOverlayMounted, layoutStyle, updateClosePosition]);
3373
+
3374
+ useEffect(() => {
3375
+ if (!isOpen || !isInteractive) return;
3376
+ closeRef.current?.focus({ preventScroll: true });
3377
+ const onKeyDown = (event: KeyboardEvent) => {
3378
+ if (event.key === 'Escape') setIsUserOpen(false);
3379
+ };
3380
+ document.addEventListener('keydown', onKeyDown);
3381
+ return () => document.removeEventListener('keydown', onKeyDown);
3382
+ }, [isOpen, isInteractive]);
3383
+
3384
+ // Inline media covers the page, so a copy of the panel is laid over the real one.
3385
+ useLayoutEffect(() => {
3386
+ if (!isInline || activeIndex === null) return;
3387
+ const panelEl = panelRef.current;
3388
+ const layer = inlineLayerRef.current;
3389
+ if (!panelEl || !layer) return;
3390
+ const panelRect = panelEl.getBoundingClientRect();
3391
+ const layerRect = layer.getBoundingClientRect();
3392
+ setCopyRect({ top: panelRect.top - layerRect.top, left: panelRect.left - layerRect.left, width: panelRect.width });
3393
+ }, [isInline, activeIndex]);
3394
+
3395
+ useEffect(() => {
3396
+ if (activeIndex !== null) return;
3397
+ const timer = window.setTimeout(() => setCopyRect(null), IMAGE_FADE_MS);
3398
+ return () => window.clearTimeout(timer);
3399
+ }, [activeIndex]);
3400
+
3401
+ const isCopyShown = copyRect !== null;
3402
+ useEffect(() => {
3403
+ if (!isInline || !isCopyShown) return;
3404
+ const cut = () => {
3405
+ setIsMediaCut(true);
3406
+ setActiveIndex(null);
3407
+ setCopyRect(null);
3408
+ };
3409
+ document.addEventListener('scroll', cut, { capture: true, passive: true });
3410
+ window.addEventListener('resize', cut);
3411
+ return () => {
3412
+ document.removeEventListener('scroll', cut, { capture: true });
3413
+ window.removeEventListener('resize', cut);
3414
+ };
3415
+ }, [isInline, isCopyShown]);
3416
+
3417
+ useEffect(() => {
3418
+ if (!isListShown) return;
3419
+ items.forEach((item) => getRowMedia(item).forEach((media) => {
3420
+ if (!isVideoMedia(media)) new Image().src = media.assetId;
3421
+ }));
3422
+ }, [isListShown, items]);
3423
+
3424
+ useEffect(() => {
3425
+ if (activeMedia.length < 2) return;
3426
+ const timer = window.setInterval(() => {
3427
+ setActiveMediaIndex((current) => (current + 1) % activeMedia.length);
3428
+ }, hoverInterval);
3429
+ return () => window.clearInterval(timer);
3430
+ }, [activeIndex, activeMedia.length, hoverInterval]);
3431
+
3432
+ // Keep the replaced media under the next one until it has faded in; runs before paint to avoid a gap frame.
3433
+ useLayoutEffect(() => {
3434
+ const previous = shownMediaRef.current;
3435
+ shownMediaRef.current = shownMedia;
3436
+ if (shownMedia === null) return;
3437
+ setLastShownMedia(shownMedia);
3438
+ setCoveredMedia(previous);
3439
+ }, [shownMedia]);
3440
+
3441
+ useEffect(() => {
3442
+ if (!isShownMediaLoaded || coveredMedia === null) return;
3443
+ const timer = window.setTimeout(() => setCoveredMedia(null), IMAGE_FADE_MS);
3444
+ return () => window.clearTimeout(timer);
3445
+ }, [isShownMediaLoaded, coveredMedia]);
3446
+
3447
+ const close = () => {
3448
+ if (!isInteractive) return;
3449
+ setIsUserOpen(false);
3450
+ triggerRef.current?.focus({ preventScroll: true });
3451
+ };
3452
+
3453
+ const showRowMedia = (index: number) => {
3454
+ if (!isInteractive || getRowMedia(items[index]).length === 0) {
3455
+ setActiveIndex(null);
3456
+ return;
3457
+ }
3458
+ setMountedRows((prev) => (prev.has(index) ? prev : new Set(prev).add(index)));
3459
+ if (isInline && activeIndex === null) setLayoutStyle(getLayoutStyle(wrapperRef.current));
3460
+ if (activeIndex !== index) setActiveMediaIndex(0);
3461
+ setIsMediaCut(false);
3462
+ setActiveIndex(index);
3463
+ };
3464
+
3465
+ const hideRowMedia = (index: number) => {
3466
+ setActiveIndex((current) => (current === index ? null : current));
3467
+ };
3468
+
3469
+ const onPanelClickCapture = (event: MouseEvent<HTMLDivElement>) => {
3470
+ if (!isInteractive && (event.target as HTMLElement).closest('a')) {
3471
+ event.preventDefault();
3472
+ }
3473
+ };
3474
+
3475
+ const triggerTypographyCss = omitTextColors(textStylesToCss(resolveTextStyle(settings, 'trigger'), isEditor));
3476
+ const columnTypographyCss = CHRONICLES_COLUMN_STYLE_PREFIXES.slice(0, columns).map((prefix) => (
3477
+ omitTextColors(textStylesToCss(resolveTextStyle(settings, prefix), isEditor))
3478
+ ));
3479
+ const labelLineHeight = columnTypographyCss[0].lineHeight;
3480
+ const titleLineHeight = columnTypographyCss[1]?.lineHeight;
3481
+ const groupLabelOffset = labelLineHeight !== undefined && titleLineHeight !== undefined
3482
+ ? \`calc((\${titleLineHeight} - \${labelLineHeight}) / 2)\`
3483
+ : undefined;
3484
+
3485
+ const colorVars = buildColorVars(P, {
3486
+ triggerColor,
3487
+ triggerHoverColor,
3488
+ closeColor,
3489
+ closeHoverColor,
3490
+ panelColor,
3491
+ textColor,
3492
+ textHoverColor,
3493
+ overlayColor,
3494
+ }, COLOR_VAR_MAP, []);
3495
+ const stateClass = activeEvent && activeEvent !== 'default' ? \`\${P}-state-\${activeEvent}\` : '';
3496
+ const interactiveClass = isInteractive ? \`\${P}-interactive\` : '';
3497
+ const showPanelControls = Boolean(isEditMode) && (isInline || isOverlaySettled);
3498
+
3499
+ const mediaLayer = (
3500
+ <div className={cn(\`\${P}-media-layer\`, isMediaCut && \`\${P}-media-layer-instant\`)} aria-hidden="true">
3501
+ {[...mountedRows].flatMap((index) => getRowMedia(items[index]).map((media, mediaIndex) => {
3502
+ const mediaKey = getMediaKey(index, mediaIndex, media.assetId);
3503
+ return (
3504
+ <ChroniclesMediaItem
3505
+ key={mediaKey}
3506
+ P={P}
3507
+ media={media}
3508
+ isVisible={mediaKey === shownMedia}
3509
+ isLoaded={loadedMedia.has(mediaKey)}
3510
+ isCovered={mediaKey === coveredMedia}
3511
+ isFading={shownMedia === null && (mediaKey === lastShownMedia || mediaKey === coveredMedia)}
3512
+ onLoad={() => setLoadedMedia((prev) => (prev.has(mediaKey) ? prev : new Set(prev).add(mediaKey)))}
3513
+ />
3514
+ );
3515
+ }))}
3516
+ </div>
3517
+ );
3518
+
3519
+ const renderPanel = (isCopy: boolean) => {
3520
+ const showControls = !isCopy && showPanelControls;
3521
+ return (
3522
+ <div
3523
+ ref={isCopy ? undefined : panelRef}
3524
+ className={cn(
3525
+ \`\${P}-panel\`,
3526
+ isOverlayActive && isOverlaySettled && \`\${P}-panel-settled\`,
3527
+ isInline && \`\${P}-panel-inline\`,
3528
+ isCopy && \`\${P}-panel-copy\`,
3529
+ )}
3530
+ style={{
3531
+ width: scaled(panelWidth),
3532
+ paddingTop: scaled(panelPadding.top),
3533
+ paddingRight: scaled(panelPadding.right),
3534
+ paddingBottom: scaled(panelPadding.bottom),
3535
+ paddingLeft: scaled(panelPadding.left),
3536
+ borderRadius: scaled(panelRadius),
3537
+ [\`--\${P}-group-gap\`]: scaled(groupGap),
3538
+ [\`--\${P}-panel-x\`]: panelOffset.x,
3539
+ [\`--\${P}-panel-y\`]: panelOffset.y,
3540
+ [\`--\${P}-grid-columns\`]: getGridTemplateColumns(columnWidths),
3541
+ [\`--\${P}-column-gap\`]: scaled(columnGap),
3542
+ ...(isCopy && copyRect),
3543
+ } as CSSProperties}
3544
+ data-lightbox-scrollable={isInline ? undefined : ''}
3545
+ aria-hidden={isCopy || undefined}
3546
+ onMouseLeave={isCopy ? undefined : () => setActiveIndex(null)}
3547
+ onClickCapture={isCopy ? undefined : onPanelClickCapture}
3548
+ >
3549
+ {showControls && renderPanelPaddingControls(P, panelWidth, panelPadding, scaled)}
3550
+ {showControls && renderColumnWidthControls(P, columnWidths, panelPadding.left, columnGap, scaled)}
3551
+ {groups.map((group, groupIndex) => (
3552
+ <Fragment key={groupIndex}>
3553
+ {showControls && groupIndex > 0 && (
3554
+ <div
3555
+ data-controls="groupGap"
3556
+ data-controls-paired=""
3557
+ data-controls-axis="y"
3558
+ data-controls-reverse=""
3559
+ data-controls-min="0"
3560
+ className={\`\${P}-control-anchor\`}
3561
+ style={{ left: 0, width: '100%', height: scaled(Math.max(groupGap, MIN_HANDLE_SIZE)) }}
3562
+ />
3563
+ )}
3564
+ <div
3565
+ className={cn(\`\${P}-group\`, !hasGroupColumn && \`\${P}-group-unlabeled\`)}
3566
+ style={{ gridTemplateRows: \`repeat(\${group.rows.length}, auto) 1fr\` }}
3567
+ >
3568
+ {hasGroupColumn && (
3569
+ <span
3570
+ className={\`\${P}-group-label\`}
3571
+ style={{ ...columnTypographyCss[0], gridRow: \`1 / span \${group.rows.length + 1}\`, marginTop: groupLabelOffset }}
3572
+ >
3573
+ {group.label}
3574
+ </span>
3575
+ )}
3576
+ {group.rows.map(({ item, index }) => {
3577
+ const rowLink = !isCopy && item.link?.value ? item.link : undefined;
3578
+ const RowElement = rowLink ? 'a' : 'div';
3579
+ const linkProps = rowLink ? {
3580
+ href: buildValidUrl(rowLink.value),
3581
+ ...(rowLink.target === 'blank' && { target: '_blank', rel: 'noreferrer' }),
3582
+ } : {};
3583
+ const hoverProps = isCopy ? {} : {
3584
+ onMouseEnter: () => showRowMedia(index),
3585
+ onMouseLeave: () => hideRowMedia(index),
3586
+ onFocus: () => showRowMedia(index),
3587
+ onBlur: () => hideRowMedia(index),
3588
+ };
3589
+ return (
3590
+ <RowElement
3591
+ key={index}
3592
+ className={cn(\`\${P}-row\`, isCopy && index === activeIndex && \`\${P}-row-active\`)}
3593
+ {...linkProps}
3594
+ {...hoverProps}
3595
+ >
3596
+ {!hasGroupColumn && (
3597
+ <div className={\`\${P}-title\`} style={columnTypographyCss[0]}>{item.group}</div>
3598
+ )}
3599
+ {titleKeys.map((key, titleIndex) => (
3600
+ <div key={key} className={\`\${P}-title\`} style={columnTypographyCss[titleIndex + 1]}>{item[key]}</div>
3601
+ ))}
3602
+ </RowElement>
3603
+ );
3604
+ })}
3605
+ </div>
3606
+ </Fragment>
3607
+ ))}
3608
+ </div>
3609
+ );
3610
+ };
3611
+
3612
+ // The overlay and the inline list both render the panel with panelRef; keeping a closing overlay
3613
+ // around after switching to type A would detach the ref from the inline panel when it unmounts.
3614
+ const overlay = isOverlayMounted && !isInline ? (
3615
+ <div
3616
+ ref={overlayRef}
3617
+ className={cn(
3618
+ \`\${P}-overlay\`,
3619
+ isEditor && \`\${P}-overlay-editor\`,
3620
+ isEditMode && \`\${P}-overlay-edit-mode\`,
3621
+ isOverlayActive && \`\${P}-overlay-active\`,
3622
+ interactiveClass,
3623
+ stateClass,
3624
+ )}
3625
+ style={{ ...colorVars, ...layoutStyle }}
3626
+ role="dialog"
3627
+ aria-modal="true"
3628
+ aria-label={triggerLabel}
3629
+ data-selection="none"
3630
+ >
3631
+ <div className={\`\${P}-backdrop\`} aria-hidden="true" onClick={close} />
3632
+ {mediaLayer}
3633
+ <button
3634
+ ref={closeRef}
3635
+ type="button"
3636
+ className={\`\${P}-close\`}
3637
+ style={{
3638
+ ...triggerTypographyCss,
3639
+ top: closePosition?.top ?? 0,
3640
+ left: closePosition?.left ?? 0,
3641
+ visibility: closePosition ? 'visible' : 'hidden',
3642
+ }}
3643
+ onClick={close}
3644
+ >
3645
+ {closeLabel}
3646
+ </button>
3647
+ {renderPanel(false)}
3648
+ </div>
3649
+ ) : null;
3650
+
3651
+ const inlineLayer = isInline && mountedRows.size > 0 ? (
3652
+ <div
3653
+ ref={inlineLayerRef}
3654
+ className={cn(\`\${P}-inline-layer\`, isEditor && \`\${P}-overlay-editor\`, interactiveClass, stateClass)}
3655
+ style={{ ...colorVars, ...layoutStyle }}
3656
+ aria-hidden="true"
3657
+ data-selection="none"
3658
+ >
3659
+ {mediaLayer}
3660
+ {copyRect && renderPanel(true)}
3661
+ </div>
3662
+ ) : null;
3663
+ const portalContent = overlay ?? inlineLayer;
3664
+
3665
+ return (
3666
+ <>
3667
+ <style dangerouslySetInnerHTML={{ __html: scopedCss }} />
3668
+ <div
3669
+ ref={wrapperRef}
3670
+ className={cn(isEditorCanvas && \`\${P}-editor\`, interactiveClass, stateClass)}
3671
+ style={colorVars}
3672
+ >
3673
+ {isInline ? renderPanel(false) : (
3674
+ <button
3675
+ ref={triggerRef}
3676
+ type="button"
3677
+ className={cn(\`\${P}-trigger\`, isOverlayActive && \`\${P}-trigger-hidden\`)}
3678
+ style={triggerTypographyCss}
3679
+ aria-haspopup="dialog"
3680
+ aria-expanded={isOpen}
3681
+ onClick={() => {
3682
+ if (isInteractive) setIsUserOpen(true);
3683
+ }}
3684
+ >
3685
+ {triggerLabel}
3686
+ </button>
3687
+ )}
3688
+ </div>
3689
+ {portalContent && typeof document !== 'undefined' && createPortal(
3690
+ portalContent,
3691
+ (portalId ? document.getElementById(portalId) : null) ?? document.body,
3692
+ )}
3693
+ </>
3694
+ );
3695
+ }
3696
+ `, w = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2688
3697
  import { CommonComponentProps } from '../props';
2689
3698
  import { LinkWrapper, useScopedStyles, type ContentLink } from '../utils/index';
2690
3699
 
@@ -3213,7 +4222,7 @@ export function ClickGallerie({ settings, content = [], isEditor }: ClickGalleri
3213
4222
  </>
3214
4223
  );
3215
4224
  }
3216
- `, w = `import { useCallback, useEffect, useMemo, useState } from 'react';
4225
+ `, $ = `import { useCallback, useEffect, useMemo, useState } from 'react';
3217
4226
  import cn from 'classnames';
3218
4227
  import { CommonComponentProps } from '../props';
3219
4228
  import { buildColorVars, scalingValue, useScopedStyles } from '../utils/index';
@@ -3961,7 +4970,7 @@ export function FAQ({ settings, content, isEditor, isPreviewMode, isEditMode, ac
3961
4970
  </>
3962
4971
  );
3963
4972
  }
3964
- `, C = `import React, { useMemo, useState } from 'react';
4973
+ `, I = `import React, { useMemo, useState } from 'react';
3965
4974
  import { CommonComponentProps } from '../props';
3966
4975
  import { buildColorVars, getFormFieldValidationError, scalingValue, useScopedStyles } from '../utils/index';
3967
4976
  import { omitTextColors, textStylesToCss, type TextStyles } from '../utils/textStylesToCss';
@@ -4599,7 +5608,7 @@ const COLOR_VAR_MAP: Record<ColorKeys, string> = {
4599
5608
  };
4600
5609
 
4601
5610
  const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
4602
- `, $ = `import { Splide, SplideSlide } from '@splidejs/react-splide';
5611
+ `, T = `import { Splide, SplideSlide } from '@splidejs/react-splide';
4603
5612
  import '@splidejs/react-splide/css/core';
4604
5613
  import { CommonComponentProps } from '../props';
4605
5614
  import { EmbedMediaFrame, getEmbedAspect, getEmbedPlayback, isEmbedMedia } from '../utils/index';
@@ -6914,7 +7923,7 @@ const COLOR_VAR_MAP: Record<ColorKeys, string> = {
6914
7923
  };
6915
7924
 
6916
7925
  const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
6917
- `, I = `import { useEffect, useMemo, useRef, type CSSProperties } from 'react';
7926
+ `, E = `import { useEffect, useMemo, useRef, type CSSProperties } from 'react';
6918
7927
  import { CommonComponentProps } from '../props';
6919
7928
  import { scalingValue } from '../utils/scalingValue';
6920
7929
  import { useScopedStyles } from '../utils/useScopedStyles';
@@ -7487,7 +8496,7 @@ export function Helix({
7487
8496
  </>
7488
8497
  );
7489
8498
  }
7490
- `, T = `import { CommonComponentProps } from '../props';
8499
+ `, R = `import { CommonComponentProps } from '../props';
7491
8500
  import { EmbedMediaFrame, getEmbedAspect, isEmbedMedia, scalingValue, useLazyVideos, useScopedStyles } from '../utils/index';
7492
8501
  import { LazyVideo } from '../helpers/LazyVideo/LazyVideo';
7493
8502
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
@@ -9939,7 +10948,7 @@ export function Hive({
9939
10948
  </>
9940
10949
  );
9941
10950
  }
9942
- `, E = `import { useCallback, useEffect, useMemo, useRef, useState, type MouseEvent } from 'react';
10951
+ `, M = `import { useCallback, useEffect, useMemo, useRef, useState, type MouseEvent } from 'react';
9943
10952
  import { createPortal } from 'react-dom';
9944
10953
  import { CommonComponentProps } from '../props';
9945
10954
  import { useScopedStyles } from '../utils/useScopedStyles';
@@ -10704,7 +11713,7 @@ export type LightboxJournalSettings = {
10704
11713
  closeIconColor: string;
10705
11714
  closeIconHoverColor: string;
10706
11715
  };
10707
- `, R = `import { useEffect, useRef, useState, type MouseEvent } from 'react';
11716
+ `, L = `import { useEffect, useRef, useState, type MouseEvent } from 'react';
10708
11717
  import { createPortal } from 'react-dom';
10709
11718
  import { CommonComponentProps } from '../props';
10710
11719
  import { useScopedStyles } from '../utils/useScopedStyles';
@@ -11250,7 +12259,7 @@ export const LightboxStrip = ({ settings, content, isEditor, isEditMode, isPrevi
11250
12259
  </>
11251
12260
  );
11252
12261
  };
11253
- `, M = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
12262
+ `, k = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
11254
12263
  import { createPortal } from 'react-dom';
11255
12264
  import { CommonComponentProps } from '../props';
11256
12265
  import { buildColorVars, EmbedMediaFrame, isEmbedMedia, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
@@ -14355,7 +15364,7 @@ export function List({ settings, content, isEditor, isPreviewMode, isEditMode, a
14355
15364
  </>
14356
15365
  );
14357
15366
  }
14358
- `, L = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
15367
+ `, A = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
14359
15368
  import cn from 'classnames';
14360
15369
  import { CommonComponentProps } from '../props';
14361
15370
  import { EmbedMediaFrame, getEmbedAspect, isEmbedMedia, LinkWrapper, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
@@ -15213,7 +16222,7 @@ type MarqueeProps = {
15213
16222
  isPreviewMode?: boolean;
15214
16223
  isEditMode?: boolean;
15215
16224
  } & CommonComponentProps;
15216
- `, k = `import { useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent } from 'react';
16225
+ `, N = `import { useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent } from 'react';
15217
16226
  import cn from 'classnames';
15218
16227
  import { CommonComponentProps } from '../props';
15219
16228
  import { LinkWrapper, scalingValue, useScopedStyles, type ContentLink } from '../utils/index';
@@ -16156,7 +17165,7 @@ type MarqueeTextProps = {
16156
17165
  isPreviewMode?: boolean;
16157
17166
  isEditMode?: boolean;
16158
17167
  } & CommonComponentProps;
16159
- `, A = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
17168
+ `, H = `import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
16160
17169
  import { createPortal } from 'react-dom';
16161
17170
  import type React from 'react';
16162
17171
  import { CommonComponentProps } from '../props';
@@ -18638,7 +19647,7 @@ export function Mercury({
18638
19647
  </>
18639
19648
  );
18640
19649
  }
18641
- `, N = `import React, { useMemo, useState } from 'react';
19650
+ `, O = `import React, { useMemo, useState } from 'react';
18642
19651
  import { CommonComponentProps } from '../props';
18643
19652
  import { buildColorVars, getFormFieldValidationError, scalingValue, useScopedStyles } from '../utils/index';
18644
19653
  import { omitTextColors, textStylesToCss, type TextStyles } from '../utils/textStylesToCss';
@@ -19217,7 +20226,7 @@ const COLOR_VAR_MAP: Record<OnelinerColorKeys, string> = {
19217
20226
  };
19218
20227
 
19219
20228
  const STATE_KEYS = ['hover', 'focus', 'filled', 'success', 'error'] as const;
19220
- `, H = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
20229
+ `, _ = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
19221
20230
  import type React from 'react';
19222
20231
  import { CommonComponentProps } from '../props';
19223
20232
  import { scalingValue, useScopedStyles } from '../utils/index';
@@ -20056,7 +21065,7 @@ export function Pretext({ settings, content, isEditor, isPreviewMode, isEditMode
20056
21065
  </>
20057
21066
  );
20058
21067
  }
20059
- `, O = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
21068
+ `, F = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
20060
21069
  import cn from 'classnames';
20061
21070
  import { CommonComponentProps } from '../props';
20062
21071
  import { useScopedStyles } from '../utils/useScopedStyles';
@@ -20684,7 +21693,7 @@ export function Scale({ settings, content, isEditor, isPreviewMode }: ScaleProps
20684
21693
  </>
20685
21694
  );
20686
21695
  }
20687
- `, F = `import { useMemo, type CSSProperties, type MouseEvent, type ReactNode } from 'react';
21696
+ `, W = `import { useMemo, type CSSProperties, type MouseEvent, type ReactNode } from 'react';
20688
21697
  import { SvgImage } from '../helpers/SvgImage/SvgImage';
20689
21698
  import { CommonComponentProps } from '../props';
20690
21699
  import { buildColorVars, scalingValue, useScopedStyles } from '../utils';
@@ -21316,7 +22325,7 @@ export function SimpleButton({ settings, isEditor, isPreviewMode, activeEvent, h
21316
22325
  </>
21317
22326
  );
21318
22327
  }
21319
- `, _ = `import React, { useCallback, useEffect, useRef, useState } from 'react';
22328
+ `, D = `import React, { useCallback, useEffect, useRef, useState } from 'react';
21320
22329
  import cn from 'classnames';
21321
22330
  import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
21322
22331
  import { scalingValue } from '../utils/scalingValue';
@@ -22498,7 +23507,7 @@ function ArrowIcon({ color, className }: { color: string, className: string }) {
22498
23507
  </svg>
22499
23508
  );
22500
23509
  }
22501
- `, W = `import { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
23510
+ `, B = `import { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
22502
23511
  import cn from 'classnames';
22503
23512
  import { CommonComponentProps } from '../props';
22504
23513
  import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
@@ -23129,7 +24138,7 @@ type TestimonialsSettings = {
23129
24138
  logoHeight: number;
23130
24139
  captionMarginTop: number;
23131
24140
  };
23132
- `, D = `import cn from 'classnames';
24141
+ `, z = `import cn from 'classnames';
23133
24142
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
23134
24143
  import { CommonComponentProps } from '../props';
23135
24144
  import { RichTextRenderer } from '../helpers/RichTextRenderer/RichTextRenderer';
@@ -23625,7 +24634,7 @@ type TestimonialsSettings = {
23625
24634
  icon?: string | null;
23626
24635
  };
23627
24636
  };
23628
- `, B = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
24637
+ `, V = `import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
23629
24638
  import type React from 'react';
23630
24639
  import { createPortal } from 'react-dom';
23631
24640
  import { CommonComponentProps } from '../props';
@@ -24158,29 +25167,30 @@ export function Waterfall({
24158
25167
  </>
24159
25168
  );
24160
25169
  }
24161
- `, V = {
24162
- [b.id]: y,
24163
- [x.id]: S,
24164
- [P.id]: w,
24165
- [v.id]: C,
24166
- [f.id]: $,
24167
- [h.id]: I,
24168
- [p.id]: T,
24169
- [m.id]: E,
24170
- [g.id]: R,
24171
- [u.id]: M,
24172
- [d.id]: L,
24173
- [c.id]: k,
24174
- [l.id]: A,
24175
- [s.id]: N,
24176
- [a.id]: H,
24177
- [r.id]: O,
24178
- [o.id]: F,
24179
- [i.id]: _,
24180
- [t.id]: W,
24181
- [e.id]: D,
24182
- [n.id]: B
25170
+ `, U = {
25171
+ [y.id]: S,
25172
+ [b.id]: C,
25173
+ [x.id]: w,
25174
+ [P.id]: $,
25175
+ [v.id]: I,
25176
+ [f.id]: T,
25177
+ [h.id]: E,
25178
+ [p.id]: R,
25179
+ [m.id]: M,
25180
+ [g.id]: L,
25181
+ [u.id]: k,
25182
+ [d.id]: A,
25183
+ [c.id]: N,
25184
+ [l.id]: H,
25185
+ [s.id]: O,
25186
+ [a.id]: _,
25187
+ [r.id]: F,
25188
+ [o.id]: W,
25189
+ [i.id]: D,
25190
+ [t.id]: B,
25191
+ [e.id]: z,
25192
+ [n.id]: V
24183
25193
  };
24184
25194
  export {
24185
- V as componentSources
25195
+ U as componentSources
24186
25196
  };