@cntrl-site/components 1.0.97-7 → 1.0.97-8

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/utils.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./EmbedMediaFrame-C5O6lDaq.js");exports.EmbedMediaFrame=e.EmbedMediaFrame;exports.LinkWrapper=e.LinkWrapper;exports.buildColorVars=e.buildColorVars;exports.getAvailableStatePanels=e.getAvailableStatePanels;exports.getColorAlpha=e.getColorAlpha;exports.getEmbedAspect=e.getEmbedAspect;exports.getEmbedPlayerSrc=e.getEmbedPlayerSrc;exports.getEmbedProvider=e.getEmbedProvider;exports.getFormFieldValidationError=e.getFormFieldValidationError;exports.getUnavailableStates=e.getUnavailableStates;exports.isEmbedMedia=e.isEmbedMedia;exports.isPanelAvailable=e.isPanelAvailable;exports.isValidEmailFormat=e.isValidEmailFormat;exports.isValidPhoneFormat=e.isValidPhoneFormat;exports.readTestimonialTextMeasure=e.readTestimonialTextMeasure;exports.scalingValue=e.scalingValue;exports.useScopedStyles=e.useScopedStyles;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./EmbedMediaFrame-C__c1jQ6.js");exports.EmbedMediaFrame=e.EmbedMediaFrame;exports.LinkWrapper=e.LinkWrapper;exports.buildColorVars=e.buildColorVars;exports.getAvailableStatePanels=e.getAvailableStatePanels;exports.getColorAlpha=e.getColorAlpha;exports.getEmbedAspect=e.getEmbedAspect;exports.getEmbedPlayback=e.getEmbedPlayback;exports.getEmbedPlayerSrc=e.getEmbedPlayerSrc;exports.getEmbedProvider=e.getEmbedProvider;exports.getFormFieldValidationError=e.getFormFieldValidationError;exports.getUnavailableStates=e.getUnavailableStates;exports.isEmbedMedia=e.isEmbedMedia;exports.isPanelAvailable=e.isPanelAvailable;exports.isValidEmailFormat=e.isValidEmailFormat;exports.isValidPhoneFormat=e.isValidPhoneFormat;exports.postEmbedCommand=e.postEmbedCommand;exports.readTestimonialTextMeasure=e.readTestimonialTextMeasure;exports.scalingValue=e.scalingValue;exports.useScopedStyles=e.useScopedStyles;
package/dist/utils.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { E as s, L as l, b as i, d as r, g as t, h as d, j as o, k as m, a as b, e as g, l as n, f as E, i as p, c, r as u, s as F, u as P } from "./EmbedMediaFrame-BqqoaiHc.mjs";
1
+ import { E as s, L as l, b as i, d as r, g as t, h as d, j as m, k as o, l as b, a as g, e as E, m as n, f as p, i as c, c as P, p as u, r as F, s as S, u as V } from "./EmbedMediaFrame-Mkas2vMk.mjs";
2
2
  export {
3
3
  s as EmbedMediaFrame,
4
4
  l as LinkWrapper,
@@ -6,15 +6,17 @@ export {
6
6
  r as getAvailableStatePanels,
7
7
  t as getColorAlpha,
8
8
  d as getEmbedAspect,
9
+ m as getEmbedPlayback,
9
10
  o as getEmbedPlayerSrc,
10
- m as getEmbedProvider,
11
- b as getFormFieldValidationError,
12
- g as getUnavailableStates,
11
+ b as getEmbedProvider,
12
+ g as getFormFieldValidationError,
13
+ E as getUnavailableStates,
13
14
  n as isEmbedMedia,
14
- E as isPanelAvailable,
15
- p as isValidEmailFormat,
16
- c as isValidPhoneFormat,
17
- u as readTestimonialTextMeasure,
18
- F as scalingValue,
19
- P as useScopedStyles
15
+ p as isPanelAvailable,
16
+ c as isValidEmailFormat,
17
+ P as isValidPhoneFormat,
18
+ u as postEmbedCommand,
19
+ F as readTestimonialTextMeasure,
20
+ S as scalingValue,
21
+ V as useScopedStyles
20
22
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/components",
3
- "version": "1.0.97-7",
3
+ "version": "1.0.97-8",
4
4
  "description": "Custom components for control editor and public websites.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1,236 +0,0 @@
1
- import { useId as P, useRef as R, useState as x, useEffect as E } from "react";
2
- import { jsx as g, Fragment as j, jsxs as L } from "react/jsx-runtime";
3
- function Y(t, e = !1) {
4
- return e ? `calc(var(--cntrl-article-width) * ${t})` : `${t * 100}vw`;
5
- }
6
- const z = (t, e, r, s, n) => {
7
- const o = {};
8
- for (const [a, l] of Object.entries(r))
9
- o[`--${t}-${l}`] = e[a];
10
- const i = new Set(s);
11
- if (n)
12
- for (const a of Object.keys(n))
13
- i.add(a);
14
- for (const a of i) {
15
- const l = n == null ? void 0 : n[a];
16
- if (l)
17
- for (const [b, m] of Object.entries(r)) {
18
- const c = l[b];
19
- c !== void 0 && (o[`--${t}-${a}-${m}`] = c);
20
- }
21
- }
22
- return o;
23
- };
24
- function M(t) {
25
- const e = t.trim();
26
- if (!e || e === "none") return 1;
27
- if (e.endsWith("%")) {
28
- const s = parseFloat(e);
29
- return Number.isFinite(s) ? s / 100 : 1;
30
- }
31
- const r = parseFloat(e);
32
- return Number.isFinite(r) ? r : 1;
33
- }
34
- function k(t) {
35
- const e = t.lastIndexOf("/");
36
- if (e !== -1)
37
- return M(t.slice(e + 1));
38
- }
39
- function G(t) {
40
- const e = t.trim().toLowerCase();
41
- if (!e || e === "transparent") return 0;
42
- const r = e.match(/^(?:oklch|oklab|rgba?|hsla?|hwb|lab|lch|color)\((.+)\)$/);
43
- if (r) {
44
- const n = r[1], o = k(n);
45
- if (o !== void 0) return o;
46
- if (/^(?:rgba|hsla)$/.test(e.slice(0, 4))) {
47
- const i = n.split(",").map((a) => parseFloat(a.trim()));
48
- if (i.length === 4 && Number.isFinite(i[3]))
49
- return i[3];
50
- }
51
- return 1;
52
- }
53
- const s = e.match(/^#([0-9a-f]{4}|[0-9a-f]{8})$/);
54
- if (s) {
55
- const n = s[1], o = n.length === 4 ? n[3] + n[3] : n.slice(6, 8);
56
- return parseInt(o, 16) / 255;
57
- }
58
- return 1;
59
- }
60
- const C = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, W = (t) => C.test(t.trim()), _ = (t) => {
61
- const e = t.replace(/\D/g, "");
62
- return e.length >= 7 && e.length <= 15;
63
- }, J = (t, e) => {
64
- var r;
65
- for (const s of t) {
66
- const n = ((r = e[s.name]) == null ? void 0 : r.trim()) ?? "";
67
- if (n) {
68
- if (s.type === "email" && !W(n))
69
- return "Please enter a valid email address.";
70
- if (s.type === "phone" && !_(n))
71
- return "Please enter a valid phone number.";
72
- }
73
- }
74
- return null;
75
- };
76
- function K() {
77
- const e = `cf-${P().replace(/:/g, "")}`;
78
- return {
79
- prefix: e,
80
- cls: (r) => `${e}-${r}`
81
- };
82
- }
83
- const Q = (t, e) => {
84
- const r = Array.from(t.querySelectorAll('[data-testimonial-measure="text"]')).reduce(
85
- (n, o) => Math.max(n, o.getBoundingClientRect().height),
86
- 0
87
- ), s = Array.from(t.querySelectorAll('[data-testimonial-measure="caption"]')).reduce(
88
- (n, o) => Math.max(n, o.getBoundingClientRect().height),
89
- 0
90
- );
91
- e({ maxTextPx: r, maxCaptionPx: s });
92
- };
93
- function B(t, e) {
94
- const r = t == null ? void 0 : t.availableWhen;
95
- return r ? Object.entries(r).every(([s, n]) => {
96
- if (!(n != null && n.length)) return !0;
97
- const o = e[s];
98
- return o === void 0 ? !0 : n.includes(o);
99
- }) : !0;
100
- }
101
- function N(t, e) {
102
- const r = t == null ? void 0 : t.statePanels;
103
- return r != null && r.length ? r.filter((s) => {
104
- var o;
105
- const n = (o = t == null ? void 0 : t.panels) == null ? void 0 : o.find((i) => i.id === s);
106
- return B(n, e);
107
- }) : null;
108
- }
109
- function Z(t, e) {
110
- const r = t == null ? void 0 : t.statePanels;
111
- if (!(r != null && r.length)) return [];
112
- const s = new Set(N(t, e) ?? []);
113
- return r.filter((n) => !s.has(n));
114
- }
115
- const T = ["http://", "https://", "/", "mailto:", "tel:", "file:", "ftp:", "javascript", "#"];
116
- function U(t) {
117
- return T.some((e) => t.startsWith(e)) ? t : `//${t}`;
118
- }
119
- const tt = ({ link: t, className: e, style: r, children: s }) => {
120
- if (!(t != null && t.value)) return /* @__PURE__ */ g(j, { children: s });
121
- const n = t.target === "blank" || t.target === "_blank" ? { target: "_blank", rel: "noreferrer" } : {};
122
- return /* @__PURE__ */ g("a", { href: U(t.value), className: e, style: r, ...n, children: s });
123
- }, V = {
124
- vimeo: /^player\.vimeo\.com$/i,
125
- youtube: /^(?:www\.)?youtube(?:-nocookie)?\.com$/i
126
- };
127
- function $(t) {
128
- if (!(t != null && t.assetId) || t.type !== "vimeo" && t.type !== "youtube") return null;
129
- try {
130
- const e = new URL(t.assetId);
131
- return !V[t.type].test(e.hostname) || t.type === "youtube" && !e.pathname.startsWith("/embed/") ? null : t.type;
132
- } catch {
133
- return null;
134
- }
135
- }
136
- function et(t) {
137
- return $(t) !== null;
138
- }
139
- function O(t) {
140
- const { width: e, height: r } = t;
141
- return e && r && e > 0 && r > 0 ? e / r : 16 / 9;
142
- }
143
- function q(t, e) {
144
- const r = $(t);
145
- if (!r || !t.assetId) return t.assetId ?? "";
146
- const s = new URL(t.assetId), n = s.searchParams;
147
- return r === "vimeo" ? (n.set("autoplay", "1"), e === "background" && (n.set("background", "1"), n.set("muted", "1"), n.set("loop", "1"))) : (n.set("autoplay", "1"), n.set("playsinline", "1"), n.set("rel", "0"), e === "background" && (n.set("mute", "1"), n.set("loop", "1"), n.set("playlist", s.pathname.slice(7)), n.set("controls", "0"), n.set("modestbranding", "1"))), s.toString();
148
- }
149
- function H(t, e, r) {
150
- const s = t.width / t.height, n = r === "cover" ? e <= s : e >= s, o = n ? t.width : t.height * e, i = n ? t.width / e : t.height;
151
- return { width: o, height: i, left: (t.width - o) / 2, top: (t.height - i) / 2 };
152
- }
153
- const nt = ({
154
- media: t,
155
- mode: e,
156
- fit: r,
157
- interactive: s = e === "player",
158
- lazy: n = !0,
159
- style: o,
160
- ...i
161
- }) => {
162
- const a = R(null), [l, b] = x(null), [m, c] = x(!n), y = O(t);
163
- E(() => {
164
- const u = a.current;
165
- if (!u || typeof ResizeObserver > "u") return;
166
- const h = () => {
167
- const { width: w, height: S } = u.getBoundingClientRect();
168
- b((p) => p && p.width === w && p.height === S ? p : { width: w, height: S });
169
- };
170
- h();
171
- const d = new ResizeObserver(h);
172
- return d.observe(u), () => d.disconnect();
173
- }, []), E(() => {
174
- const u = a.current;
175
- if (!n || !u || typeof IntersectionObserver > "u") {
176
- c(!0);
177
- return;
178
- }
179
- const h = new IntersectionObserver(([d]) => c(d.isIntersecting), { rootMargin: "200px" });
180
- return h.observe(u), () => h.disconnect();
181
- }, [n]);
182
- const f = l && l.width > 0 && l.height > 0 ? H(l, y, r) : null, { width: v, ...I } = o ?? {}, F = {
183
- position: "relative",
184
- overflow: "hidden",
185
- aspectRatio: `${y}`,
186
- width: v === void 0 || v === "auto" ? "100%" : v,
187
- ...I
188
- }, A = {
189
- position: "absolute",
190
- inset: 0,
191
- width: "100%",
192
- height: "100%",
193
- objectFit: r,
194
- pointerEvents: "none"
195
- };
196
- return /* @__PURE__ */ L("div", { ref: a, "data-embed-frame": "", style: F, ...i, children: [
197
- t.thumbnail && /* @__PURE__ */ g("img", { src: t.thumbnail, alt: t.name ?? "", draggable: !1, style: A }),
198
- m && f && /* @__PURE__ */ g(
199
- "iframe",
200
- {
201
- src: q(t, e),
202
- title: t.name || "Embedded video",
203
- allow: "autoplay; fullscreen; picture-in-picture",
204
- allowFullScreen: !0,
205
- style: {
206
- position: "absolute",
207
- left: f.left,
208
- top: f.top,
209
- width: f.width,
210
- height: f.height,
211
- border: 0,
212
- pointerEvents: s ? "auto" : "none"
213
- }
214
- }
215
- )
216
- ] });
217
- };
218
- export {
219
- nt as E,
220
- tt as L,
221
- J as a,
222
- z as b,
223
- _ as c,
224
- N as d,
225
- Z as e,
226
- B as f,
227
- G as g,
228
- O as h,
229
- W as i,
230
- q as j,
231
- $ as k,
232
- et as l,
233
- Q as r,
234
- Y as s,
235
- K as u
236
- };
@@ -1 +0,0 @@
1
- "use strict";const c=require("react"),f=require("react/jsx-runtime");function C(t,e=!1){return e?`calc(var(--cntrl-article-width) * ${t})`:`${t*100}vw`}const L=(t,e,r,s,n)=>{const i={};for(const[a,l]of Object.entries(r))i[`--${t}-${l}`]=e[a];const o=new Set(s);if(n)for(const a of Object.keys(n))o.add(a);for(const a of o){const l=n==null?void 0:n[a];if(l)for(const[m,v]of Object.entries(r)){const h=l[m];h!==void 0&&(i[`--${t}-${a}-${v}`]=h)}}return i};function k(t){const e=t.trim();if(!e||e==="none")return 1;if(e.endsWith("%")){const s=parseFloat(e);return Number.isFinite(s)?s/100:1}const r=parseFloat(e);return Number.isFinite(r)?r:1}function T(t){const e=t.lastIndexOf("/");if(e!==-1)return k(t.slice(e+1))}function W(t){const e=t.trim().toLowerCase();if(!e||e==="transparent")return 0;const r=e.match(/^(?:oklch|oklab|rgba?|hsla?|hwb|lab|lch|color)\((.+)\)$/);if(r){const n=r[1],i=T(n);if(i!==void 0)return i;if(/^(?:rgba|hsla)$/.test(e.slice(0,4))){const o=n.split(",").map(a=>parseFloat(a.trim()));if(o.length===4&&Number.isFinite(o[3]))return o[3]}return 1}const s=e.match(/^#([0-9a-f]{4}|[0-9a-f]{8})$/);if(s){const n=s[1],i=n.length===4?n[3]+n[3]:n.slice(6,8);return parseInt(i,16)/255}return 1}const U=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,F=t=>U.test(t.trim()),P=t=>{const e=t.replace(/\D/g,"");return e.length>=7&&e.length<=15},_=(t,e)=>{var r;for(const s of t){const n=((r=e[s.name])==null?void 0:r.trim())??"";if(n){if(s.type==="email"&&!F(n))return"Please enter a valid email address.";if(s.type==="phone"&&!P(n))return"Please enter a valid phone number."}}return null};function B(){const e=`cf-${c.useId().replace(/:/g,"")}`;return{prefix:e,cls:r=>`${e}-${r}`}}const N=(t,e)=>{const r=Array.from(t.querySelectorAll('[data-testimonial-measure="text"]')).reduce((n,i)=>Math.max(n,i.getBoundingClientRect().height),0),s=Array.from(t.querySelectorAll('[data-testimonial-measure="caption"]')).reduce((n,i)=>Math.max(n,i.getBoundingClientRect().height),0);e({maxTextPx:r,maxCaptionPx:s})};function A(t,e){const r=t==null?void 0:t.availableWhen;return r?Object.entries(r).every(([s,n])=>{if(!(n!=null&&n.length))return!0;const i=e[s];return i===void 0?!0:n.includes(i)}):!0}function $(t,e){const r=t==null?void 0:t.statePanels;return r!=null&&r.length?r.filter(s=>{var i;const n=(i=t==null?void 0:t.panels)==null?void 0:i.find(o=>o.id===s);return A(n,e)}):null}function q(t,e){const r=t==null?void 0:t.statePanels;if(!(r!=null&&r.length))return[];const s=new Set($(t,e)??[]);return r.filter(n=>!s.has(n))}const O=["http://","https://","/","mailto:","tel:","file:","ftp:","javascript","#"];function H(t){return O.some(e=>t.startsWith(e))?t:`//${t}`}const D=({link:t,className:e,style:r,children:s})=>{if(!(t!=null&&t.value))return f.jsx(f.Fragment,{children:s});const n=t.target==="blank"||t.target==="_blank"?{target:"_blank",rel:"noreferrer"}:{};return f.jsx("a",{href:H(t.value),className:e,style:r,...n,children:s})},X={vimeo:/^player\.vimeo\.com$/i,youtube:/^(?:www\.)?youtube(?:-nocookie)?\.com$/i};function w(t){if(!(t!=null&&t.assetId)||t.type!=="vimeo"&&t.type!=="youtube")return null;try{const e=new URL(t.assetId);return!X[t.type].test(e.hostname)||t.type==="youtube"&&!e.pathname.startsWith("/embed/")?null:t.type}catch{return null}}function Y(t){return w(t)!==null}function I(t){const{width:e,height:r}=t;return e&&r&&e>0&&r>0?e/r:16/9}function R(t,e){const r=w(t);if(!r||!t.assetId)return t.assetId??"";const s=new URL(t.assetId),n=s.searchParams;return r==="vimeo"?(n.set("autoplay","1"),e==="background"&&(n.set("background","1"),n.set("muted","1"),n.set("loop","1"))):(n.set("autoplay","1"),n.set("playsinline","1"),n.set("rel","0"),e==="background"&&(n.set("mute","1"),n.set("loop","1"),n.set("playlist",s.pathname.slice(7)),n.set("controls","0"),n.set("modestbranding","1"))),s.toString()}function z(t,e,r){const s=t.width/t.height,n=r==="cover"?e<=s:e>=s,i=n?t.width:t.height*e,o=n?t.width/e:t.height;return{width:i,height:o,left:(t.width-i)/2,top:(t.height-o)/2}}const G=({media:t,mode:e,fit:r,interactive:s=e==="player",lazy:n=!0,style:i,...o})=>{const a=c.useRef(null),[l,m]=c.useState(null),[v,h]=c.useState(!n),S=I(t);c.useEffect(()=>{const u=a.current;if(!u||typeof ResizeObserver>"u")return;const g=()=>{const{width:E,height:x}=u.getBoundingClientRect();m(b=>b&&b.width===E&&b.height===x?b:{width:E,height:x})};g();const p=new ResizeObserver(g);return p.observe(u),()=>p.disconnect()},[]),c.useEffect(()=>{const u=a.current;if(!n||!u||typeof IntersectionObserver>"u"){h(!0);return}const g=new IntersectionObserver(([p])=>h(p.isIntersecting),{rootMargin:"200px"});return g.observe(u),()=>g.disconnect()},[n]);const d=l&&l.width>0&&l.height>0?z(l,S,r):null,{width:y,...j}=i??{},M={position:"relative",overflow:"hidden",aspectRatio:`${S}`,width:y===void 0||y==="auto"?"100%":y,...j},V={position:"absolute",inset:0,width:"100%",height:"100%",objectFit:r,pointerEvents:"none"};return f.jsxs("div",{ref:a,"data-embed-frame":"",style:M,...o,children:[t.thumbnail&&f.jsx("img",{src:t.thumbnail,alt:t.name??"",draggable:!1,style:V}),v&&d&&f.jsx("iframe",{src:R(t,e),title:t.name||"Embedded video",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,style:{position:"absolute",left:d.left,top:d.top,width:d.width,height:d.height,border:0,pointerEvents:s?"auto":"none"}})]})};exports.EmbedMediaFrame=G;exports.LinkWrapper=D;exports.buildColorVars=L;exports.getAvailableStatePanels=$;exports.getColorAlpha=W;exports.getEmbedAspect=I;exports.getEmbedPlayerSrc=R;exports.getEmbedProvider=w;exports.getFormFieldValidationError=_;exports.getUnavailableStates=q;exports.isEmbedMedia=Y;exports.isPanelAvailable=A;exports.isValidEmailFormat=F;exports.isValidPhoneFormat=P;exports.readTestimonialTextMeasure=N;exports.scalingValue=C;exports.useScopedStyles=B;