@cntrl-site/components 1.0.105 → 1.0.106

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 (88) hide show
  1. package/dist/ClickGallerie-CYQMgrIr.js +36 -0
  2. package/dist/ClickGallerie-o2U6oyOF.mjs +272 -0
  3. package/dist/Components/ClickGallerie/ClickGallerie.d.ts +2 -1
  4. package/dist/Components/Helix/Helix.d.ts +4 -1
  5. package/dist/Components/Hive/Hive.d.ts +4 -1
  6. package/dist/Components/ImageRevealSlider/ImageRevealSlider.d.ts +2 -1
  7. package/dist/Components/List/List.d.ts +6 -2
  8. package/dist/Components/Marquee/Marquee.d.ts +6 -2
  9. package/dist/Components/MarqueeText/MarqueeText.d.ts +2 -1
  10. package/dist/Components/Mercury/Mercury.d.ts +4 -1
  11. package/dist/Components/Waterfall/WaterfallLightbox.d.ts +4 -1
  12. package/dist/Components/utils/EmbedMediaFrame.d.ts +27 -0
  13. package/dist/Components/utils/LinkWrapper.d.ts +16 -0
  14. package/dist/Components/utils/embedMedia.d.ts +40 -0
  15. package/dist/Components/utils/index.d.ts +6 -0
  16. package/dist/{ControlSlider-SiOt22l_.js → ControlSlider-Kkec-i14.js} +1 -1
  17. package/dist/{ControlSlider-pZv7H6BU.mjs → ControlSlider-LcZmviGX.mjs} +1 -1
  18. package/dist/EmbedMediaFrame-DsOTKE4i.js +1 -0
  19. package/dist/EmbedMediaFrame-DwHeOAy5.mjs +164 -0
  20. package/dist/{FAQ-C7823fyi.js → FAQ-BxhMo7T8.js} +1 -1
  21. package/dist/{FAQ-CZ39u4m8.mjs → FAQ-CdwSft5p.mjs} +1 -1
  22. package/dist/Grid-CFHTP3mb.js +378 -0
  23. package/dist/Grid-e-gLfsji.mjs +1590 -0
  24. package/dist/Helix-BpLo9FD3.js +43 -0
  25. package/dist/Helix-CidI3ucE.mjs +324 -0
  26. package/dist/{Hive-D6-R6TwM.mjs → Hive-BsmFHk2i.mjs} +505 -475
  27. package/dist/Hive-D1j6wZpV.js +321 -0
  28. package/dist/ImageRevealSlider-BuukTGAK.js +1 -0
  29. package/dist/{ImageRevealSlider-BdFGyVEP.mjs → ImageRevealSlider-Df9sygk9.mjs} +63 -70
  30. package/dist/{Lightbox-eP9qAZzL.mjs → Lightbox-C_fXsfdz.mjs} +1 -1
  31. package/dist/{Lightbox-CIss_nOG.js → Lightbox-DaunVrkp.js} +1 -1
  32. package/dist/LinkWrapper-Ca84iPtg.js +1 -0
  33. package/dist/LinkWrapper-DZs9hlOn.mjs +13 -0
  34. package/dist/{List-DW7fyJbf.mjs → List-Bh_-l9vD.mjs} +532 -520
  35. package/dist/List-DVvpQ24J.js +377 -0
  36. package/dist/Marquee-DByooiWP.mjs +578 -0
  37. package/dist/Marquee-DfIP-tIN.js +133 -0
  38. package/dist/{MarqueeText-Rzt2fJYt.mjs → MarqueeText-D6FNCe6P.mjs} +115 -114
  39. package/dist/MarqueeText-DsUiV6Zv.js +132 -0
  40. package/dist/Mercury-B-s2Kvuq.js +267 -0
  41. package/dist/Mercury-CCW0Es-s.mjs +1700 -0
  42. package/dist/PretextComponent-Dnbenstn.js +1 -0
  43. package/dist/{PretextComponent-j-OsRZTx.mjs → PretextComponent-OygSO3fr.mjs} +312 -269
  44. package/dist/{RichTextRenderer-B6WtTYlR.mjs → RichTextRenderer-BptwNpbJ.mjs} +10 -9
  45. package/dist/RichTextRenderer-K90Dd7pt.js +1 -0
  46. package/dist/{Slider20-Dm8BeCli.mjs → Slider20-CCzixTiN.mjs} +1 -1
  47. package/dist/{Slider20-C9o2REDl.js → Slider20-fMVeRfgx.js} +1 -1
  48. package/dist/{TestimonialGrid-CPu4qQ6B.mjs → TestimonialGrid-CbsVxSn9.mjs} +1 -1
  49. package/dist/{TestimonialGrid-D4ieiz9e.js → TestimonialGrid-CiCagfBU.js} +1 -1
  50. package/dist/{TestimonialSingle-DLdnAVF7.mjs → TestimonialSingle-BVm3Amrl.mjs} +1 -1
  51. package/dist/{TestimonialSingle-CVu15ZtV.js → TestimonialSingle-BWXynGjv.js} +1 -1
  52. package/dist/Waterfall-3kKioKh2.mjs +1432 -0
  53. package/dist/Waterfall-DII4-WV5.js +288 -0
  54. package/dist/{components-D2LyuDm-.mjs → components-BRmbflgg.mjs} +15 -15
  55. package/dist/components-nvbH4l0S.js +1 -0
  56. package/dist/content/postFieldBindings.d.ts +29 -0
  57. package/dist/elements.js +1 -1
  58. package/dist/elements.mjs +16 -16
  59. package/dist/elements.node.js +1 -1
  60. package/dist/elements.node.mjs +1 -1
  61. package/dist/index.d.ts +3 -1
  62. package/dist/index.js +1 -1
  63. package/dist/index.mjs +52 -15
  64. package/dist/sources.js +312 -212
  65. package/dist/sources.mjs +312 -212
  66. package/dist/types/SchemaV1.d.ts +53 -1
  67. package/dist/utils.js +1 -1
  68. package/dist/utils.mjs +30 -20
  69. package/package.json +1 -1
  70. package/dist/ClickGallerie-D7g093HX.js +0 -36
  71. package/dist/ClickGallerie-QSOQjSdv.mjs +0 -271
  72. package/dist/Grid-BBpdl60K.js +0 -374
  73. package/dist/Grid-DS53S_gA.mjs +0 -1576
  74. package/dist/Helix-BPn9V1sg.mjs +0 -315
  75. package/dist/Helix-DcgsCc4D.js +0 -43
  76. package/dist/Hive-n8Fz-j3o.js +0 -321
  77. package/dist/ImageRevealSlider-BBWtFjUF.js +0 -1
  78. package/dist/List-C32WImI3.js +0 -377
  79. package/dist/Marquee-DOIRRCu4.js +0 -133
  80. package/dist/Marquee-O_PDwlIb.mjs +0 -564
  81. package/dist/MarqueeText-DkaO2lQ5.js +0 -132
  82. package/dist/Mercury-C9D10TTT.mjs +0 -1702
  83. package/dist/Mercury-DynO-NxY.js +0 -267
  84. package/dist/PretextComponent-BnsS2zJ6.js +0 -1
  85. package/dist/RichTextRenderer-CIy6yI8U.js +0 -1
  86. package/dist/Waterfall-DC2WQ3GT.js +0 -287
  87. package/dist/Waterfall-Yud2VR62.mjs +0 -1404
  88. package/dist/components-B9Vdjf0w.js +0 -1
@@ -62,6 +62,58 @@ export type SchemaDisplayRule = {
62
62
  value: unknown;
63
63
  };
64
64
  };
65
+ /** The post header fields a content field can be filled from when a collection is connected, and the post page's link. */
66
+ export type ContentKey = 'title' | 'subtitle' | 'date' | 'gallery' | 'link';
67
+ /**
68
+ * A link as a `link-input` content field holds it. In the editor `value` is a url, a page id or a
69
+ * section id; a published site gets it with `value` already the url to follow.
70
+ */
71
+ export type ContentLink = {
72
+ type: 'url' | 'anchor' | 'page';
73
+ value: string;
74
+ target: 'blank' | 'self';
75
+ anchor?: string;
76
+ };
77
+ export type ComponentContentSettings = {
78
+ allowsVideo?: boolean;
79
+ addItemWithoutImage?: boolean;
80
+ addItemFromFileExplorer?: boolean;
81
+ deleteImageDeletesEntry?: boolean;
82
+ stripFieldsOnAdd?: string[];
83
+ /** A collection's posts may be connected as this component's rows. */
84
+ allowsCollection?: boolean;
85
+ };
86
+ export type ComponentContentProperty = {
87
+ type?: 'string' | 'number' | 'boolean' | 'object' | 'array';
88
+ label?: string;
89
+ placeholder?: string;
90
+ /** The post field this one is filled from when a collection is connected; none leaves it to the user. */
91
+ contentKey?: ContentKey;
92
+ display?: SchemaDisplay;
93
+ properties?: Record<string, ComponentContentProperty>;
94
+ items?: ComponentContentProperty;
95
+ required?: string[];
96
+ enum?: Array<string | number>;
97
+ min?: number;
98
+ max?: number;
99
+ default?: unknown;
100
+ };
101
+ export type ComponentContentSchema = {
102
+ type: 'array';
103
+ max?: number;
104
+ settings?: ComponentContentSettings;
105
+ display?: {
106
+ type: string;
107
+ ref?: Record<string, string>;
108
+ rules?: SchemaDisplayRule[];
109
+ };
110
+ items: {
111
+ type: 'object';
112
+ properties: Record<string, ComponentContentProperty>;
113
+ required?: string[];
114
+ };
115
+ default: unknown[];
116
+ };
65
117
  export type SchemaSection = {
66
118
  sizing?: string;
67
119
  hasLinkParameter?: boolean;
@@ -96,7 +148,7 @@ export type ComponentSchemaV1 = {
96
148
  settings: SchemaSection;
97
149
  panels?: SchemaPanel[];
98
150
  paletteBookmark?: SchemaPaletteBookmark;
99
- content?: any;
151
+ content?: ComponentContentSchema;
100
152
  fontRelations?: Record<string, string>;
101
153
  allowedPlugins?: string[];
102
154
  states?: string[];
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./scalingValue-CSHYgTZl.js"),i=require("./buildColorVars-CE2D5cQV.js"),r=require("./getColorAlpha-CoSseoCn.js"),e=require("./formFieldValidation-DZl2KVaF.js"),t=require("./useScopedStyles-Bf6yohVQ.js"),o=require("./useLazyVideos-CdCbc2j0.js"),s=require("./readTestimonialTextMeasure-CEPaB4Sy.js"),a=require("./panelAvailability-DnOe0rQ4.js");exports.scalingValue=l.scalingValue;exports.buildColorVars=i.buildColorVars;exports.getColorAlpha=r.getColorAlpha;exports.getFormFieldValidationError=e.getFormFieldValidationError;exports.isValidEmailFormat=e.isValidEmailFormat;exports.isValidPhoneFormat=e.isValidPhoneFormat;exports.useScopedStyles=t.useScopedStyles;exports.useLazyVideos=o.useLazyVideos;exports.readTestimonialTextMeasure=s.readTestimonialTextMeasure;exports.getAvailableStatePanels=a.getAvailableStatePanels;exports.getUnavailableStates=a.getUnavailableStates;exports.isPanelAvailable=a.isPanelAvailable;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./scalingValue-CSHYgTZl.js"),l=require("./buildColorVars-CE2D5cQV.js"),t=require("./getColorAlpha-CoSseoCn.js"),a=require("./formFieldValidation-DZl2KVaF.js"),o=require("./useScopedStyles-Bf6yohVQ.js"),s=require("./useLazyVideos-CdCbc2j0.js"),d=require("./readTestimonialTextMeasure-CEPaB4Sy.js"),i=require("./panelAvailability-DnOe0rQ4.js"),m=require("./LinkWrapper-Ca84iPtg.js"),e=require("./EmbedMediaFrame-DsOTKE4i.js");exports.scalingValue=r.scalingValue;exports.buildColorVars=l.buildColorVars;exports.getColorAlpha=t.getColorAlpha;exports.getFormFieldValidationError=a.getFormFieldValidationError;exports.isValidEmailFormat=a.isValidEmailFormat;exports.isValidPhoneFormat=a.isValidPhoneFormat;exports.useScopedStyles=o.useScopedStyles;exports.useLazyVideos=s.useLazyVideos;exports.readTestimonialTextMeasure=d.readTestimonialTextMeasure;exports.getAvailableStatePanels=i.getAvailableStatePanels;exports.getUnavailableStates=i.getUnavailableStates;exports.isPanelAvailable=i.isPanelAvailable;exports.LinkWrapper=m.LinkWrapper;exports.EmbedMediaFrame=e.EmbedMediaFrame;exports.getEmbedAspect=e.getEmbedAspect;exports.getEmbedPlayback=e.getEmbedPlayback;exports.getEmbedPlayerSrc=e.getEmbedPlayerSrc;exports.getEmbedProvider=e.getEmbedProvider;exports.isEmbedMedia=e.isEmbedMedia;exports.postEmbedCommand=e.postEmbedCommand;
package/dist/utils.mjs CHANGED
@@ -1,22 +1,32 @@
1
- import { s as o } from "./scalingValue-C9JH5L6O.mjs";
2
- import { b as s } from "./buildColorVars-CLyWQm5K.mjs";
3
- import { g as l } from "./getColorAlpha-BVBY0N5x.mjs";
4
- import { g as m, i as p, a as x } from "./formFieldValidation-DvihFrq5.mjs";
5
- import { u as f } from "./useScopedStyles-DhBG3557.mjs";
6
- import { u as n } from "./useLazyVideos-CxXyEjRQ.mjs";
7
- import { r as V } from "./readTestimonialTextMeasure-BIXpGFEt.mjs";
8
- import { g as F, a as S, i as v } from "./panelAvailability-D179wwJx.mjs";
1
+ import { s as r } from "./scalingValue-C9JH5L6O.mjs";
2
+ import { b as o } from "./buildColorVars-CLyWQm5K.mjs";
3
+ import { g as i } from "./getColorAlpha-BVBY0N5x.mjs";
4
+ import { g as l, i as d, a as p } from "./formFieldValidation-DvihFrq5.mjs";
5
+ import { u as g } from "./useScopedStyles-DhBG3557.mjs";
6
+ import { u as f } from "./useLazyVideos-CxXyEjRQ.mjs";
7
+ import { r as n } from "./readTestimonialTextMeasure-BIXpGFEt.mjs";
8
+ import { g as c, a as P, i as V } from "./panelAvailability-D179wwJx.mjs";
9
+ import { L as S } from "./LinkWrapper-DZs9hlOn.mjs";
10
+ import { E as y, g as A, a as C, b as L, c as M, i as h, p as k } from "./EmbedMediaFrame-DwHeOAy5.mjs";
9
11
  export {
10
- s as buildColorVars,
11
- F as getAvailableStatePanels,
12
- l as getColorAlpha,
13
- m as getFormFieldValidationError,
14
- S as getUnavailableStates,
15
- v as isPanelAvailable,
16
- p as isValidEmailFormat,
17
- x as isValidPhoneFormat,
18
- V as readTestimonialTextMeasure,
19
- o as scalingValue,
20
- n as useLazyVideos,
21
- f as useScopedStyles
12
+ y as EmbedMediaFrame,
13
+ S as LinkWrapper,
14
+ o as buildColorVars,
15
+ c as getAvailableStatePanels,
16
+ i as getColorAlpha,
17
+ A as getEmbedAspect,
18
+ C as getEmbedPlayback,
19
+ L as getEmbedPlayerSrc,
20
+ M as getEmbedProvider,
21
+ l as getFormFieldValidationError,
22
+ P as getUnavailableStates,
23
+ h as isEmbedMedia,
24
+ V as isPanelAvailable,
25
+ d as isValidEmailFormat,
26
+ p as isValidPhoneFormat,
27
+ k as postEmbedCommand,
28
+ n as readTestimonialTextMeasure,
29
+ r as scalingValue,
30
+ f as useLazyVideos,
31
+ g as useScopedStyles
22
32
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/components",
3
- "version": "1.0.105",
3
+ "version": "1.0.106",
4
4
  "description": "Custom components for control editor and public websites.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1,36 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),l=require("react"),te=require("./useScopedStyles-Bf6yohVQ.js"),ne={sizeType:"custom",value:700,min:400,max:700};function z(o,a){return{widthPx:o,heightPx:o*a}}function q(o,a,i,s,t,h){return{x:Math.min(Math.max(o,t/2),i-t/2),y:Math.min(Math.max(a,h/2),s-h/2)}}function A(o,a,i,s){const{heightPx:t}=z(i,s);return q(o/2,a/2,o,a,i,t)}function Z(o,a,i){for(const s of i){const{heightPx:t}=z(s.widthPx,s.aspectRatio),h=s.widthPx/2,f=t/2;if(o>=s.x-h&&o<=s.x+h&&a>=s.y-f&&a<=s.y+f)return!0}return!1}function se(o,a,i,s,t,h,f,p){if(t==="system")return"none";const P=s.getBoundingClientRect(),R=document.elementFromPoint(P.left+o,P.top+a);return R&&R.closest("a")?"none":Z(o,a,i)||h==="area"?f??"none":p??"none"}function H(o,a,i){var p;const{sizeType:s,value:t,min:h,max:f}=a;return s==="custom"?t:s==="as is"?((p=i.get(o))==null?void 0:p.naturalWidth)??t:Math.round(Math.random()*(f-h)+h)}function re(o){return`
2
- .${o}-root {
3
- position: absolute;
4
- top: 0;
5
- left: 0;
6
- width: 100%;
7
- height: 100%;
8
- overflow: hidden;
9
- }
10
- .${o}-wrapper {
11
- position: absolute;
12
- transform: translate(-50%, -50%);
13
- height: auto;
14
- }
15
- .${o}-image {
16
- display: block;
17
- width: 100%;
18
- height: auto;
19
- object-fit: cover;
20
- position: relative;
21
- user-select: none;
22
- pointer-events: none;
23
- }
24
- .${o}-link {
25
- width: 100%;
26
- display: block;
27
- }
28
- .${o}-cursor {
29
- position: absolute;
30
- top: 0;
31
- left: 0;
32
- pointer-events: none;
33
- width: 32px;
34
- height: 32px;
35
- }
36
- `}function oe(o){return new Promise(a=>{const i=new Image;i.onload=()=>{a({aspectRatio:i.naturalHeight/i.naturalWidth,naturalWidth:i.naturalWidth})},i.onerror=()=>{a({aspectRatio:1,naturalWidth:700})},i.src=o})}async function ae(o){const a=[...new Set(o.filter(Boolean))],i=await Promise.all(a.map(async s=>[s,await oe(s)]));return new Map(i)}function ie({settings:o,content:a=[],isEditor:i}){const{prefix:s}=te.useScopedStyles(),[t,h]=l.useState(null),[f,p]=l.useState([]),[P,R]=l.useState(0),J=l.useRef(0),[F,K]=l.useState({x:0,y:0}),[X,Y]=l.useState("none"),M=l.useRef({x:0,y:0}),[w,G]=l.useState(!1),[N,T]=l.useState(!1),S=l.useRef(new Map),{imageSize:k=ne,cursor:O="system",target:$="area",origin:Q,position:V,visible:W="all",defaultCursor:b=null,hoverCursor:j=null}=o,I=Q??V??"random",y=a.filter(e=>{var n;return!!((n=e==null?void 0:e.image)!=null&&n.assetId)}),D=l.useMemo(()=>re(s),[s]),v=l.useCallback((e,n,r=f)=>{if(!t)return;const d=t.getBoundingClientRect(),c=e-d.left,u=n-d.top;K({x:c,y:u}),Y(se(c,u,r,t,O,$,j,b))},[t,f,O,$,j,b]);l.useEffect(()=>{const e=[...y.map(r=>r.image.assetId),b,j].filter(r=>!!r);if(e.length===0){S.current=new Map,T(!0);return}let n=!1;return T(!1),ae(e).then(r=>{n||(S.current=r,T(!0))}),()=>{n=!0}},[a,b,j]),l.useEffect(()=>{if(!t)return;const e=r=>{r.stopPropagation(),M.current={x:r.clientX,y:r.clientY},v(r.clientX,r.clientY)},n=()=>{w&&v(M.current.x,M.current.y)};return t.addEventListener("mousemove",e),window.addEventListener("scroll",n,!0),()=>{t.removeEventListener("mousemove",e),window.removeEventListener("scroll",n,!0)}},[t,w,v]),l.useEffect(()=>{!t||!w||v(M.current.x,M.current.y)},[f,t,w,v]),l.useEffect(()=>{w||Y("none")},[w]);const U=(e,n,r,d={})=>{var C,L;if(!((C=e==null?void 0:e.image)!=null&&C.assetId))return null;const c=((L=S.current.get(e.image.assetId))==null?void 0:L.aspectRatio)??1,u=H(e.image.assetId,k,S.current),{heightPx:E}=z(u,c);let m=0,g=0;return I==="same"?{x:m,y:g}=A(n,r,u,c):(m=d.x??Math.random()*n,g=d.y??Math.random()*r,{x:m,y:g}=q(m,g,n,r,u,E)),{id:J.current++,assetId:e.image.assetId,link:e.link,name:e.image.name,x:m,y:g,xRatio:m/n,yRatio:g/r,aspectRatio:c,widthPx:u}},B=()=>{if(!t)return;const e=t.getBoundingClientRect(),n=e.width,r=e.height;n===0||r===0||p(d=>d.length===0?d:d.map(c=>{const u=k.sizeType==="random"?c.widthPx:H(c.assetId,k,S.current),{heightPx:E}=z(u,c.aspectRatio);if(I==="same"){const{x:C,y:L}=A(n,r,u,c.aspectRatio);return{...c,x:C,y:L,widthPx:u}}const{x:m,y:g}=q(c.xRatio*n,c.yRatio*r,n,r,u,E);return{...c,x:m,y:g,widthPx:u}}))};l.useEffect(()=>{if(!t||y.length===0||!N)return;const e=t.getBoundingClientRect(),n=e.width,r=e.height,d=U(y[0],n,r);d&&(p([d]),R(y.length>1?1:0))},[k,I,t,a,N]),l.useEffect(()=>{if(!t)return;B();const e=new ResizeObserver(B);return e.observe(t),window.addEventListener("resize",B),()=>{e.disconnect(),window.removeEventListener("resize",B)}},[t,I,k,f.length]),l.useEffect(()=>{W==="last One"&&p(e=>e.length>0?[e[e.length-1]]:[])},[W]);const ee=e=>{if(!t||y.length===0||!N)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left,d=e.clientY-n.top;if($==="image"&&!Z(r,d,f))return;let c=0,u=0;I==="on Click"?(c=r,u=d):I==="same"?(c=n.width/2,u=n.height/2):(c=Math.random()*n.width,u=Math.random()*n.height);const E=y[P%y.length],m=U(E,n.width,n.height,{x:c,y:u});if(!m)return;const g=W==="all"?[...f,m]:[m];p(g),R(C=>(C+1)%y.length),v(e.clientX,e.clientY,g)},_=O==="custom"&&X!=="none";return x.jsxs(x.Fragment,{children:[x.jsx("style",{dangerouslySetInnerHTML:{__html:D}}),x.jsxs("div",{ref:h,onClick:ee,onMouseEnter:()=>G(!0),onMouseLeave:()=>G(!1),className:`${s}-root`,style:{cursor:_?"none":"default"},children:[f.map(e=>x.jsx("div",{className:`${s}-wrapper`,style:{top:`${e.y}px`,left:`${e.x}px`,width:`${e.widthPx}px`,cursor:_?"none":"default"},children:$==="area"&&e.link?x.jsx("a",{href:e.link,target:"_blank",rel:"noreferrer",className:`${s}-link`,children:x.jsx("img",{src:e.assetId,alt:e.name,className:`${s}-image`})}):x.jsx("img",{src:e.assetId,alt:e.name,className:`${s}-image`})},e.id)),w&&_&&x.jsx("div",{className:`${s}-cursor`,style:{left:`${F.x}px`,top:`${F.y}px`,transform:"translate(-50%, -50%)",backgroundImage:`url('${X}')`,backgroundSize:"cover",backgroundPosition:"center"}})]})]})}exports.ClickGallerie=ie;
@@ -1,271 +0,0 @@
1
- import { jsxs as Z, Fragment as oe, jsx as M } from "react/jsx-runtime";
2
- import { useState as y, useRef as Y, useMemo as se, useCallback as ie, useEffect as w } from "react";
3
- import { u as ae } from "./useScopedStyles-DhBG3557.mjs";
4
- const ce = {
5
- sizeType: "custom",
6
- value: 700,
7
- min: 400,
8
- max: 700
9
- };
10
- function T(s, i) {
11
- return {
12
- widthPx: s,
13
- heightPx: s * i
14
- };
15
- }
16
- function j(s, i, a, r, t, f) {
17
- return {
18
- x: Math.min(Math.max(s, t / 2), a - t / 2),
19
- y: Math.min(Math.max(i, f / 2), r - f / 2)
20
- };
21
- }
22
- function J(s, i, a, r) {
23
- const { heightPx: t } = T(a, r);
24
- return j(
25
- s / 2,
26
- i / 2,
27
- s,
28
- i,
29
- a,
30
- t
31
- );
32
- }
33
- function Q(s, i, a) {
34
- for (const r of a) {
35
- const { heightPx: t } = T(r.widthPx, r.aspectRatio), f = r.widthPx / 2, d = t / 2;
36
- if (s >= r.x - f && s <= r.x + f && i >= r.y - d && i <= r.y + d)
37
- return !0;
38
- }
39
- return !1;
40
- }
41
- function le(s, i, a, r, t, f, d, g) {
42
- if (t === "system")
43
- return "none";
44
- const S = r.getBoundingClientRect(), R = document.elementFromPoint(S.left + s, S.top + i);
45
- return R && R.closest("a") ? "none" : Q(s, i, a) || f === "area" ? d ?? "none" : g ?? "none";
46
- }
47
- function K(s, i, a) {
48
- var g;
49
- const { sizeType: r, value: t, min: f, max: d } = i;
50
- return r === "custom" ? t : r === "as is" ? ((g = a.get(s)) == null ? void 0 : g.naturalWidth) ?? t : Math.round(Math.random() * (d - f) + f);
51
- }
52
- function ue(s) {
53
- return `
54
- .${s}-root {
55
- position: absolute;
56
- top: 0;
57
- left: 0;
58
- width: 100%;
59
- height: 100%;
60
- overflow: hidden;
61
- }
62
- .${s}-wrapper {
63
- position: absolute;
64
- transform: translate(-50%, -50%);
65
- height: auto;
66
- }
67
- .${s}-image {
68
- display: block;
69
- width: 100%;
70
- height: auto;
71
- object-fit: cover;
72
- position: relative;
73
- user-select: none;
74
- pointer-events: none;
75
- }
76
- .${s}-link {
77
- width: 100%;
78
- display: block;
79
- }
80
- .${s}-cursor {
81
- position: absolute;
82
- top: 0;
83
- left: 0;
84
- pointer-events: none;
85
- width: 32px;
86
- height: 32px;
87
- }
88
- `;
89
- }
90
- function de(s) {
91
- return new Promise((i) => {
92
- const a = new Image();
93
- a.onload = () => {
94
- i({
95
- aspectRatio: a.naturalHeight / a.naturalWidth,
96
- naturalWidth: a.naturalWidth
97
- });
98
- }, a.onerror = () => {
99
- i({ aspectRatio: 1, naturalWidth: 700 });
100
- }, a.src = s;
101
- });
102
- }
103
- async function fe(s) {
104
- const i = [...new Set(s.filter(Boolean))], a = await Promise.all(
105
- i.map(async (r) => [r, await de(r)])
106
- );
107
- return new Map(a);
108
- }
109
- function pe({ settings: s, content: i = [], isEditor: a }) {
110
- const { prefix: r } = ae(), [t, f] = y(null), [d, g] = y([]), [S, R] = y(0), V = Y(0), [U, D] = y({ x: 0, y: 0 }), [A, G] = y("none"), k = Y({ x: 0, y: 0 }), [x, q] = y(!1), [W, _] = y(!1), $ = Y(/* @__PURE__ */ new Map()), {
111
- imageSize: P = ce,
112
- cursor: F = "system",
113
- target: E = "area",
114
- origin: ee,
115
- position: te,
116
- visible: O = "all",
117
- defaultCursor: B = null,
118
- hoverCursor: L = null
119
- } = s, I = ee ?? te ?? "random", p = i.filter(
120
- (e) => {
121
- var n;
122
- return !!((n = e == null ? void 0 : e.image) != null && n.assetId);
123
- }
124
- ), ne = se(() => ue(r), [r]), v = ie((e, n, o = d) => {
125
- if (!t) return;
126
- const u = t.getBoundingClientRect(), c = e - u.left, l = n - u.top;
127
- D({ x: c, y: l }), G(
128
- le(c, l, o, t, F, E, L, B)
129
- );
130
- }, [t, d, F, E, L, B]);
131
- w(() => {
132
- const e = [
133
- ...p.map((o) => o.image.assetId),
134
- B,
135
- L
136
- ].filter((o) => !!o);
137
- if (e.length === 0) {
138
- $.current = /* @__PURE__ */ new Map(), _(!0);
139
- return;
140
- }
141
- let n = !1;
142
- return _(!1), fe(e).then((o) => {
143
- n || ($.current = o, _(!0));
144
- }), () => {
145
- n = !0;
146
- };
147
- }, [i, B, L]), w(() => {
148
- if (!t) return;
149
- const e = (o) => {
150
- o.stopPropagation(), k.current = { x: o.clientX, y: o.clientY }, v(o.clientX, o.clientY);
151
- }, n = () => {
152
- x && v(k.current.x, k.current.y);
153
- };
154
- return t.addEventListener("mousemove", e), window.addEventListener("scroll", n, !0), () => {
155
- t.removeEventListener("mousemove", e), window.removeEventListener("scroll", n, !0);
156
- };
157
- }, [t, x, v]), w(() => {
158
- !t || !x || v(k.current.x, k.current.y);
159
- }, [d, t, x, v]), w(() => {
160
- x || G("none");
161
- }, [x]);
162
- const H = (e, n, o, u = {}) => {
163
- var C, N;
164
- if (!((C = e == null ? void 0 : e.image) != null && C.assetId)) return null;
165
- const c = ((N = $.current.get(e.image.assetId)) == null ? void 0 : N.aspectRatio) ?? 1, l = K(e.image.assetId, P, $.current), { heightPx: b } = T(l, c);
166
- let m = 0, h = 0;
167
- return I === "same" ? { x: m, y: h } = J(n, o, l, c) : (m = u.x ?? Math.random() * n, h = u.y ?? Math.random() * o, { x: m, y: h } = j(m, h, n, o, l, b)), {
168
- id: V.current++,
169
- assetId: e.image.assetId,
170
- link: e.link,
171
- name: e.image.name,
172
- x: m,
173
- y: h,
174
- xRatio: m / n,
175
- yRatio: h / o,
176
- aspectRatio: c,
177
- widthPx: l
178
- };
179
- }, z = () => {
180
- if (!t) return;
181
- const e = t.getBoundingClientRect(), n = e.width, o = e.height;
182
- n === 0 || o === 0 || g((u) => u.length === 0 ? u : u.map((c) => {
183
- const l = P.sizeType === "random" ? c.widthPx : K(c.assetId, P, $.current), { heightPx: b } = T(l, c.aspectRatio);
184
- if (I === "same") {
185
- const { x: C, y: N } = J(n, o, l, c.aspectRatio);
186
- return { ...c, x: C, y: N, widthPx: l };
187
- }
188
- const { x: m, y: h } = j(
189
- c.xRatio * n,
190
- c.yRatio * o,
191
- n,
192
- o,
193
- l,
194
- b
195
- );
196
- return { ...c, x: m, y: h, widthPx: l };
197
- }));
198
- };
199
- w(() => {
200
- if (!t || p.length === 0 || !W) return;
201
- const e = t.getBoundingClientRect(), n = e.width, o = e.height, u = H(p[0], n, o);
202
- u && (g([u]), R(p.length > 1 ? 1 : 0));
203
- }, [P, I, t, i, W]), w(() => {
204
- if (!t) return;
205
- z();
206
- const e = new ResizeObserver(z);
207
- return e.observe(t), window.addEventListener("resize", z), () => {
208
- e.disconnect(), window.removeEventListener("resize", z);
209
- };
210
- }, [t, I, P, d.length]), w(() => {
211
- O === "last One" && g((e) => e.length > 0 ? [e[e.length - 1]] : []);
212
- }, [O]);
213
- const re = (e) => {
214
- if (!t || p.length === 0 || !W) return;
215
- const n = t.getBoundingClientRect(), o = e.clientX - n.left, u = e.clientY - n.top;
216
- if (E === "image" && !Q(o, u, d)) return;
217
- let c = 0, l = 0;
218
- I === "on Click" ? (c = o, l = u) : I === "same" ? (c = n.width / 2, l = n.height / 2) : (c = Math.random() * n.width, l = Math.random() * n.height);
219
- const b = p[S % p.length], m = H(b, n.width, n.height, { x: c, y: l });
220
- if (!m) return;
221
- const h = O === "all" ? [...d, m] : [m];
222
- g(h), R((C) => (C + 1) % p.length), v(e.clientX, e.clientY, h);
223
- }, X = F === "custom" && A !== "none";
224
- return /* @__PURE__ */ Z(oe, { children: [
225
- /* @__PURE__ */ M("style", { dangerouslySetInnerHTML: { __html: ne } }),
226
- /* @__PURE__ */ Z(
227
- "div",
228
- {
229
- ref: f,
230
- onClick: re,
231
- onMouseEnter: () => q(!0),
232
- onMouseLeave: () => q(!1),
233
- className: `${r}-root`,
234
- style: { cursor: X ? "none" : "default" },
235
- children: [
236
- d.map((e) => /* @__PURE__ */ M(
237
- "div",
238
- {
239
- className: `${r}-wrapper`,
240
- style: {
241
- top: `${e.y}px`,
242
- left: `${e.x}px`,
243
- width: `${e.widthPx}px`,
244
- cursor: X ? "none" : "default"
245
- },
246
- children: E === "area" && e.link ? /* @__PURE__ */ M("a", { href: e.link, target: "_blank", rel: "noreferrer", className: `${r}-link`, children: /* @__PURE__ */ M("img", { src: e.assetId, alt: e.name, className: `${r}-image` }) }) : /* @__PURE__ */ M("img", { src: e.assetId, alt: e.name, className: `${r}-image` })
247
- },
248
- e.id
249
- )),
250
- x && X && /* @__PURE__ */ M(
251
- "div",
252
- {
253
- className: `${r}-cursor`,
254
- style: {
255
- left: `${U.x}px`,
256
- top: `${U.y}px`,
257
- transform: "translate(-50%, -50%)",
258
- backgroundImage: `url('${A}')`,
259
- backgroundSize: "cover",
260
- backgroundPosition: "center"
261
- }
262
- }
263
- )
264
- ]
265
- }
266
- )
267
- ] });
268
- }
269
- export {
270
- pe as ClickGallerie
271
- };