@cntrl-site/components 1.0.7-alpha.10 → 1.0.7-alpha.11

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.
@@ -0,0 +1 @@
1
+ "use strict";const d=require("react");function x(e,t=!1){return t?`calc(var(--cntrl-article-width) * ${e})`:`${e*100}vw`}const g=(e,t,r,n,i)=>{const s={};for(const[o,a]of Object.entries(r))s[`--${e}-${a}`]=t[o];if(i)for(const o of n){const a=i[o];if(a)for(const[u,l]of Object.entries(r)){const c=a[u];c!==void 0&&(s[`--${e}-${o}-${l}`]=c)}}return s},h=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,f=e=>h.test(e.trim()),m=e=>{const t=e.replace(/\D/g,"");return t.length>=7&&t.length<=15},p=(e,t)=>{var r;for(const n of e){const i=((r=t[n.name])==null?void 0:r.trim())??"";if(i){if(n.type==="email"&&!f(i))return"Please enter a valid email address.";if(n.type==="phone"&&!m(i))return"Please enter a valid phone number."}}return null};function y(){const t=`cf-${d.useId().replace(/:/g,"")}`;return{prefix:t,cls:r=>`${t}-${r}`}}const $=({enabled:e,rootRef:t,onExtents:r,deps:n=[]})=>{d.useLayoutEffect(()=>{if(!e){r({maxTextPx:0,maxCaptionPx:0});return}const i=t.current;if(!i)return;const s=()=>{const a=Array.from(i.querySelectorAll('[data-testimonial-measure="text"]')).reduce((l,c)=>Math.max(l,c.getBoundingClientRect().height),0),u=Array.from(i.querySelectorAll('[data-testimonial-measure="caption"]')).reduce((l,c)=>Math.max(l,c.getBoundingClientRect().height),0);r({maxTextPx:a,maxCaptionPx:u})};s();const o=new ResizeObserver(s);return o.observe(i),()=>{o.disconnect()}},[e,t,r,...n])};exports.buildColorVars=g;exports.getFormFieldValidationError=p;exports.isValidEmailFormat=f;exports.isValidPhoneFormat=m;exports.scalingValue=x;exports.useScopedStyles=y;exports.useTestimonialTextMeasure=$;
@@ -0,0 +1,80 @@
1
+ import { useId as f, useLayoutEffect as m } from "react";
2
+ function p(e, t = !1) {
3
+ return t ? `calc(var(--cntrl-article-width) * ${e})` : `${e * 100}vw`;
4
+ }
5
+ const $ = (e, t, r, o, n) => {
6
+ const a = {};
7
+ for (const [s, i] of Object.entries(r))
8
+ a[`--${e}-${i}`] = t[s];
9
+ if (n)
10
+ for (const s of o) {
11
+ const i = n[s];
12
+ if (i)
13
+ for (const [u, l] of Object.entries(r)) {
14
+ const c = i[u];
15
+ c !== void 0 && (a[`--${e}-${s}-${l}`] = c);
16
+ }
17
+ }
18
+ return a;
19
+ }, d = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, x = (e) => d.test(e.trim()), g = (e) => {
20
+ const t = e.replace(/\D/g, "");
21
+ return t.length >= 7 && t.length <= 15;
22
+ }, v = (e, t) => {
23
+ var r;
24
+ for (const o of e) {
25
+ const n = ((r = t[o.name]) == null ? void 0 : r.trim()) ?? "";
26
+ if (n) {
27
+ if (o.type === "email" && !x(n))
28
+ return "Please enter a valid email address.";
29
+ if (o.type === "phone" && !g(n))
30
+ return "Please enter a valid phone number.";
31
+ }
32
+ }
33
+ return null;
34
+ };
35
+ function y() {
36
+ const t = `cf-${f().replace(/:/g, "")}`;
37
+ return {
38
+ prefix: t,
39
+ cls: (r) => `${t}-${r}`
40
+ };
41
+ }
42
+ const P = ({
43
+ enabled: e,
44
+ rootRef: t,
45
+ onExtents: r,
46
+ deps: o = []
47
+ }) => {
48
+ m(() => {
49
+ if (!e) {
50
+ r({ maxTextPx: 0, maxCaptionPx: 0 });
51
+ return;
52
+ }
53
+ const n = t.current;
54
+ if (!n) return;
55
+ const a = () => {
56
+ const i = Array.from(n.querySelectorAll('[data-testimonial-measure="text"]')).reduce(
57
+ (l, c) => Math.max(l, c.getBoundingClientRect().height),
58
+ 0
59
+ ), u = Array.from(n.querySelectorAll('[data-testimonial-measure="caption"]')).reduce(
60
+ (l, c) => Math.max(l, c.getBoundingClientRect().height),
61
+ 0
62
+ );
63
+ r({ maxTextPx: i, maxCaptionPx: u });
64
+ };
65
+ a();
66
+ const s = new ResizeObserver(a);
67
+ return s.observe(n), () => {
68
+ s.disconnect();
69
+ };
70
+ }, [e, t, r, ...o]);
71
+ };
72
+ export {
73
+ g as a,
74
+ $ as b,
75
+ P as c,
76
+ v as g,
77
+ x as i,
78
+ p as s,
79
+ y as u
80
+ };
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useScopedStyles-DpVdqfXj.js");exports.buildColorVars=e.buildColorVars;exports.getFormFieldValidationError=e.getFormFieldValidationError;exports.isValidEmailFormat=e.isValidEmailFormat;exports.isValidPhoneFormat=e.isValidPhoneFormat;exports.scalingValue=e.scalingValue;exports.useScopedStyles=e.useScopedStyles;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useTestimonialTextMeasure-CNYd-juE.js");exports.buildColorVars=e.buildColorVars;exports.getFormFieldValidationError=e.getFormFieldValidationError;exports.isValidEmailFormat=e.isValidEmailFormat;exports.isValidPhoneFormat=e.isValidPhoneFormat;exports.scalingValue=e.scalingValue;exports.useScopedStyles=e.useScopedStyles;exports.useTestimonialTextMeasure=e.useTestimonialTextMeasure;
package/dist/utils.mjs CHANGED
@@ -1,9 +1,10 @@
1
- import { b as i, g as o, i as l, a as r, s as e, u as d } from "./useScopedStyles-BSwFAT27.mjs";
1
+ import { b as e, g as i, i as o, a as l, s as r, u as t, c as d } from "./useTestimonialTextMeasure-D9FrESIm.mjs";
2
2
  export {
3
- i as buildColorVars,
4
- o as getFormFieldValidationError,
5
- l as isValidEmailFormat,
6
- r as isValidPhoneFormat,
7
- e as scalingValue,
8
- d as useScopedStyles
3
+ e as buildColorVars,
4
+ i as getFormFieldValidationError,
5
+ o as isValidEmailFormat,
6
+ l as isValidPhoneFormat,
7
+ r as scalingValue,
8
+ t as useScopedStyles,
9
+ d as useTestimonialTextMeasure
9
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/components",
3
- "version": "1.0.7-alpha.10",
3
+ "version": "1.0.7-alpha.11",
4
4
  "description": "Custom components for control editor and public websites.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1,49 +0,0 @@
1
- import { useId as u } from "react";
2
- function g(e, t = !1) {
3
- return t ? `calc(var(--cntrl-article-width) * ${e})` : `${e * 100}vw`;
4
- }
5
- const v = (e, t, n, s, r) => {
6
- const a = {};
7
- for (const [o, i] of Object.entries(n))
8
- a[`--${e}-${i}`] = t[o];
9
- if (r)
10
- for (const o of s) {
11
- const i = r[o];
12
- if (i)
13
- for (const [l, f] of Object.entries(n)) {
14
- const c = i[l];
15
- c !== void 0 && (a[`--${e}-${o}-${f}`] = c);
16
- }
17
- }
18
- return a;
19
- }, d = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, m = (e) => d.test(e.trim()), $ = (e) => {
20
- const t = e.replace(/\D/g, "");
21
- return t.length >= 7 && t.length <= 15;
22
- }, h = (e, t) => {
23
- var n;
24
- for (const s of e) {
25
- const r = ((n = t[s.name]) == null ? void 0 : n.trim()) ?? "";
26
- if (r) {
27
- if (s.type === "email" && !m(r))
28
- return "Please enter a valid email address.";
29
- if (s.type === "phone" && !$(r))
30
- return "Please enter a valid phone number.";
31
- }
32
- }
33
- return null;
34
- };
35
- function b() {
36
- const t = `cf-${u().replace(/:/g, "")}`;
37
- return {
38
- prefix: t,
39
- cls: (n) => `${t}-${n}`
40
- };
41
- }
42
- export {
43
- $ as a,
44
- v as b,
45
- h as g,
46
- m as i,
47
- g as s,
48
- b as u
49
- };
@@ -1 +0,0 @@
1
- "use strict";const m=require("react");function $(e,t=!1){return t?`calc(var(--cntrl-article-width) * ${e})`:`${e*100}vw`}const g=(e,t,r,n,i)=>{const a={};for(const[o,s]of Object.entries(r))a[`--${e}-${s}`]=t[o];if(i)for(const o of n){const s=i[o];if(s)for(const[d,u]of Object.entries(r)){const l=s[d];l!==void 0&&(a[`--${e}-${o}-${u}`]=l)}}return a},V=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,c=e=>V.test(e.trim()),f=e=>{const t=e.replace(/\D/g,"");return t.length>=7&&t.length<=15},p=(e,t)=>{var r;for(const n of e){const i=((r=t[n.name])==null?void 0:r.trim())??"";if(i){if(n.type==="email"&&!c(i))return"Please enter a valid email address.";if(n.type==="phone"&&!f(i))return"Please enter a valid phone number."}}return null};function v(){const t=`cf-${m.useId().replace(/:/g,"")}`;return{prefix:t,cls:r=>`${t}-${r}`}}exports.buildColorVars=g;exports.getFormFieldValidationError=p;exports.isValidEmailFormat=c;exports.isValidPhoneFormat=f;exports.scalingValue=$;exports.useScopedStyles=v;