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

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,60 @@
1
+ import { useId as f } from "react";
2
+ function h(e, t = !1) {
3
+ return t ? `calc(var(--cntrl-article-width) * ${e})` : `${e * 100}vw`;
4
+ }
5
+ const p = (e, t, n, a, r) => {
6
+ const i = {};
7
+ for (const [o, s] of Object.entries(n))
8
+ i[`--${e}-${s}`] = t[o];
9
+ if (r)
10
+ for (const o of a) {
11
+ const s = r[o];
12
+ if (s)
13
+ for (const [l, u] of Object.entries(n)) {
14
+ const c = s[l];
15
+ c !== void 0 && (i[`--${e}-${o}-${u}`] = c);
16
+ }
17
+ }
18
+ return i;
19
+ }, d = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, m = (e) => d.test(e.trim()), g = (e) => {
20
+ const t = e.replace(/\D/g, "");
21
+ return t.length >= 7 && t.length <= 15;
22
+ }, $ = (e, t) => {
23
+ var n;
24
+ for (const a of e) {
25
+ const r = ((n = t[a.name]) == null ? void 0 : n.trim()) ?? "";
26
+ if (r) {
27
+ if (a.type === "email" && !m(r))
28
+ return "Please enter a valid email address.";
29
+ if (a.type === "phone" && !g(r))
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: (n) => `${t}-${n}`
40
+ };
41
+ }
42
+ const v = (e, t) => {
43
+ const n = Array.from(e.querySelectorAll('[data-testimonial-measure="text"]')).reduce(
44
+ (r, i) => Math.max(r, i.getBoundingClientRect().height),
45
+ 0
46
+ ), a = Array.from(e.querySelectorAll('[data-testimonial-measure="caption"]')).reduce(
47
+ (r, i) => Math.max(r, i.getBoundingClientRect().height),
48
+ 0
49
+ );
50
+ t({ maxTextPx: n, maxCaptionPx: a });
51
+ };
52
+ export {
53
+ g as a,
54
+ p as b,
55
+ $ as g,
56
+ m as i,
57
+ v as r,
58
+ h as s,
59
+ y as u
60
+ };
@@ -0,0 +1 @@
1
+ "use strict";const m=require("react");function g(e,t=!1){return t?`calc(var(--cntrl-article-width) * ${e})`:`${e*100}vw`}const h=(e,t,i,n,r)=>{const a={};for(const[o,s]of Object.entries(i))a[`--${e}-${s}`]=t[o];if(r)for(const o of n){const s=r[o];if(s)for(const[d,f]of Object.entries(i)){const l=s[d];l!==void 0&&(a[`--${e}-${o}-${f}`]=l)}}return a},x=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,c=e=>x.test(e.trim()),u=e=>{const t=e.replace(/\D/g,"");return t.length>=7&&t.length<=15},$=(e,t)=>{var i;for(const n of e){const r=((i=t[n.name])==null?void 0:i.trim())??"";if(r){if(n.type==="email"&&!c(r))return"Please enter a valid email address.";if(n.type==="phone"&&!u(r))return"Please enter a valid phone number."}}return null};function p(){const t=`cf-${m.useId().replace(/:/g,"")}`;return{prefix:t,cls:i=>`${t}-${i}`}}const y=(e,t)=>{const i=Array.from(e.querySelectorAll('[data-testimonial-measure="text"]')).reduce((r,a)=>Math.max(r,a.getBoundingClientRect().height),0),n=Array.from(e.querySelectorAll('[data-testimonial-measure="caption"]')).reduce((r,a)=>Math.max(r,a.getBoundingClientRect().height),0);t({maxTextPx:i,maxCaptionPx:n})};exports.buildColorVars=h;exports.getFormFieldValidationError=$;exports.isValidEmailFormat=c;exports.isValidPhoneFormat=u;exports.readTestimonialTextMeasure=y;exports.scalingValue=g;exports.useScopedStyles=p;
package/dist/utils.js CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./readTestimonialTextMeasure-CB_Uq-fO.js");exports.buildColorVars=e.buildColorVars;exports.getFormFieldValidationError=e.getFormFieldValidationError;exports.isValidEmailFormat=e.isValidEmailFormat;exports.isValidPhoneFormat=e.isValidPhoneFormat;exports.readTestimonialTextMeasure=e.readTestimonialTextMeasure;exports.scalingValue=e.scalingValue;exports.useScopedStyles=e.useScopedStyles;
package/dist/utils.mjs CHANGED
@@ -1,10 +1,10 @@
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";
1
+ import { b as e, g as i, i as r, a as o, r as l, s as t, u as d } from "./readTestimonialTextMeasure-B1FI-93F.mjs";
2
2
  export {
3
3
  e as buildColorVars,
4
4
  i as getFormFieldValidationError,
5
- o as isValidEmailFormat,
6
- l as isValidPhoneFormat,
7
- r as scalingValue,
8
- t as useScopedStyles,
9
- d as useTestimonialTextMeasure
5
+ r as isValidEmailFormat,
6
+ o as isValidPhoneFormat,
7
+ l as readTestimonialTextMeasure,
8
+ t as scalingValue,
9
+ d as useScopedStyles
10
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/components",
3
- "version": "1.0.7-alpha.11",
3
+ "version": "1.0.7-alpha.13",
4
4
  "description": "Custom components for control editor and public websites.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1,13 +0,0 @@
1
- import { DependencyList, RefObject } from 'react';
2
- export type TestimonialMeasureExtents = {
3
- maxTextPx: number;
4
- maxCaptionPx: number;
5
- };
6
- type UseTestimonialMeasureExtentsOpts = {
7
- enabled: boolean;
8
- rootRef: RefObject<HTMLElement | null>;
9
- onExtents: (extents: TestimonialMeasureExtents) => void;
10
- deps?: DependencyList;
11
- };
12
- export declare const useTestimonialTextMeasure: ({ enabled, rootRef, onExtents, deps, }: UseTestimonialMeasureExtentsOpts) => void;
13
- export {};
@@ -1 +0,0 @@
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=$;
@@ -1,80 +0,0 @@
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
- };