@cntrl-site/components 1.0.69-alpha.3 → 1.0.69-alpha.5

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,126 @@
1
+ import { useId as d } from "react";
2
+ function S(t, e = !1) {
3
+ return e ? `calc(var(--cntrl-article-width) * ${t})` : `${t * 100}vw`;
4
+ }
5
+ const y = (t, e, r, i, n) => {
6
+ const a = {};
7
+ for (const [s, l] of Object.entries(r))
8
+ a[`--${t}-${l}`] = e[s];
9
+ const o = new Set(i);
10
+ if (n)
11
+ for (const s of Object.keys(n))
12
+ o.add(s);
13
+ for (const s of o) {
14
+ const l = n == null ? void 0 : n[s];
15
+ if (l)
16
+ for (const [c, f] of Object.entries(r)) {
17
+ const u = l[c];
18
+ u !== void 0 && (a[`--${t}-${s}-${f}`] = u);
19
+ }
20
+ }
21
+ return a;
22
+ };
23
+ function h(t) {
24
+ const e = t.trim();
25
+ if (!e || e === "none") return 1;
26
+ if (e.endsWith("%")) {
27
+ const i = parseFloat(e);
28
+ return Number.isFinite(i) ? i / 100 : 1;
29
+ }
30
+ const r = parseFloat(e);
31
+ return Number.isFinite(r) ? r : 1;
32
+ }
33
+ function g(t) {
34
+ const e = t.lastIndexOf("/");
35
+ if (e !== -1)
36
+ return h(t.slice(e + 1));
37
+ }
38
+ function A(t) {
39
+ const e = t.trim().toLowerCase();
40
+ if (!e || e === "transparent") return 0;
41
+ const r = e.match(/^(?:oklch|oklab|rgba?|hsla?|hwb|lab|lch|color)\((.+)\)$/);
42
+ if (r) {
43
+ const n = r[1], a = g(n);
44
+ if (a !== void 0) return a;
45
+ if (/^(?:rgba|hsla)$/.test(e.slice(0, 4))) {
46
+ const o = n.split(",").map((s) => parseFloat(s.trim()));
47
+ if (o.length === 4 && Number.isFinite(o[3]))
48
+ return o[3];
49
+ }
50
+ return 1;
51
+ }
52
+ const i = e.match(/^#([0-9a-f]{4}|[0-9a-f]{8})$/);
53
+ if (i) {
54
+ const n = i[1], a = n.length === 4 ? n[3] + n[3] : n.slice(6, 8);
55
+ return parseInt(a, 16) / 255;
56
+ }
57
+ return 1;
58
+ }
59
+ const p = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, b = (t) => p.test(t.trim()), m = (t) => {
60
+ const e = t.replace(/\D/g, "");
61
+ return e.length >= 7 && e.length <= 15;
62
+ }, F = (t, e) => {
63
+ var r;
64
+ for (const i of t) {
65
+ const n = ((r = e[i.name]) == null ? void 0 : r.trim()) ?? "";
66
+ if (n) {
67
+ if (i.type === "email" && !b(n))
68
+ return "Please enter a valid email address.";
69
+ if (i.type === "phone" && !m(n))
70
+ return "Please enter a valid phone number.";
71
+ }
72
+ }
73
+ return null;
74
+ };
75
+ function P() {
76
+ const e = `cf-${d().replace(/:/g, "")}`;
77
+ return {
78
+ prefix: e,
79
+ cls: (r) => `${e}-${r}`
80
+ };
81
+ }
82
+ const k = (t, e) => {
83
+ const r = Array.from(t.querySelectorAll('[data-testimonial-measure="text"]')).reduce(
84
+ (n, a) => Math.max(n, a.getBoundingClientRect().height),
85
+ 0
86
+ ), i = Array.from(t.querySelectorAll('[data-testimonial-measure="caption"]')).reduce(
87
+ (n, a) => Math.max(n, a.getBoundingClientRect().height),
88
+ 0
89
+ );
90
+ e({ maxTextPx: r, maxCaptionPx: i });
91
+ };
92
+ function x(t, e) {
93
+ const r = t == null ? void 0 : t.availableWhen;
94
+ return r ? Object.entries(r).every(([i, n]) => {
95
+ if (!(n != null && n.length)) return !0;
96
+ const a = e[i];
97
+ return a === void 0 ? !0 : n.includes(a);
98
+ }) : !0;
99
+ }
100
+ function v(t, e) {
101
+ const r = t == null ? void 0 : t.statePanels;
102
+ return r != null && r.length ? r.filter((i) => {
103
+ var a;
104
+ const n = (a = t == null ? void 0 : t.panels) == null ? void 0 : a.find((o) => o.id === i);
105
+ return x(n, e);
106
+ }) : null;
107
+ }
108
+ function C(t, e) {
109
+ const r = t == null ? void 0 : t.statePanels;
110
+ if (!(r != null && r.length)) return [];
111
+ const i = new Set(v(t, e) ?? []);
112
+ return r.filter((n) => !i.has(n));
113
+ }
114
+ export {
115
+ F as a,
116
+ y as b,
117
+ m as c,
118
+ v as d,
119
+ C as e,
120
+ x as f,
121
+ A as g,
122
+ b as i,
123
+ k as r,
124
+ S as s,
125
+ P as u
126
+ };
@@ -0,0 +1 @@
1
+ "use strict";const m=require("react");function p(t,e=!1){return e?`calc(var(--cntrl-article-width) * ${t})`:`${t*100}vw`}const v=(t,e,r,i,n)=>{const a={};for(const[l,s]of Object.entries(r))a[`--${t}-${s}`]=e[l];const o=new Set(i);if(n)for(const l of Object.keys(n))o.add(l);for(const l of o){const s=n==null?void 0:n[l];if(s)for(const[h,b]of Object.entries(r)){const u=s[h];u!==void 0&&(a[`--${t}-${l}-${b}`]=u)}}return a};function x(t){const e=t.trim();if(!e||e==="none")return 1;if(e.endsWith("%")){const i=parseFloat(e);return Number.isFinite(i)?i/100:1}const r=parseFloat(e);return Number.isFinite(r)?r:1}function S(t){const e=t.lastIndexOf("/");if(e!==-1)return x(t.slice(e+1))}function A(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],a=S(n);if(a!==void 0)return a;if(/^(?:rgba|hsla)$/.test(e.slice(0,4))){const o=n.split(",").map(l=>parseFloat(l.trim()));if(o.length===4&&Number.isFinite(o[3]))return o[3]}return 1}const i=e.match(/^#([0-9a-f]{4}|[0-9a-f]{8})$/);if(i){const n=i[1],a=n.length===4?n[3]+n[3]:n.slice(6,8);return parseInt(a,16)/255}return 1}const F=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,c=t=>F.test(t.trim()),f=t=>{const e=t.replace(/\D/g,"");return e.length>=7&&e.length<=15},$=(t,e)=>{var r;for(const i of t){const n=((r=e[i.name])==null?void 0:r.trim())??"";if(n){if(i.type==="email"&&!c(n))return"Please enter a valid email address.";if(i.type==="phone"&&!f(n))return"Please enter a valid phone number."}}return null};function y(){const e=`cf-${m.useId().replace(/:/g,"")}`;return{prefix:e,cls:r=>`${e}-${r}`}}const P=(t,e)=>{const r=Array.from(t.querySelectorAll('[data-testimonial-measure="text"]')).reduce((n,a)=>Math.max(n,a.getBoundingClientRect().height),0),i=Array.from(t.querySelectorAll('[data-testimonial-measure="caption"]')).reduce((n,a)=>Math.max(n,a.getBoundingClientRect().height),0);e({maxTextPx:r,maxCaptionPx:i})};function d(t,e){const r=t==null?void 0:t.availableWhen;return r?Object.entries(r).every(([i,n])=>{if(!(n!=null&&n.length))return!0;const a=e[i];return a===void 0?!0:n.includes(a)}):!0}function g(t,e){const r=t==null?void 0:t.statePanels;return r!=null&&r.length?r.filter(i=>{var a;const n=(a=t==null?void 0:t.panels)==null?void 0:a.find(o=>o.id===i);return d(n,e)}):null}function V(t,e){const r=t==null?void 0:t.statePanels;if(!(r!=null&&r.length))return[];const i=new Set(g(t,e)??[]);return r.filter(n=>!i.has(n))}exports.buildColorVars=v;exports.getAvailableStatePanels=g;exports.getColorAlpha=A;exports.getFormFieldValidationError=$;exports.getUnavailableStates=V;exports.isPanelAvailable=d;exports.isValidEmailFormat=c;exports.isValidPhoneFormat=f;exports.readTestimonialTextMeasure=P;exports.scalingValue=p;exports.useScopedStyles=y;
@@ -12,7 +12,7 @@ export type Component = {
12
12
  name: string;
13
13
  category?: string;
14
14
  version?: number;
15
- layoutMode?: 'freeform' | 'structured';
15
+ layoutMode?: 'freeform' | 'structured' | 'navigation';
16
16
  defaultSize?: ComponentDefaultSize;
17
17
  schema: any;
18
18
  preview?: {
@@ -71,12 +71,19 @@ export type SchemaSection = {
71
71
  layoutDefaults?: Record<string, Record<string, unknown>>;
72
72
  displayRules?: SchemaDisplayRule[];
73
73
  };
74
+ export type SchemaPanelAvailability = Record<string, string[]>;
74
75
  export type SchemaPanel = {
75
76
  id: string;
76
77
  icon: string;
77
78
  title: string;
78
79
  tooltip?: string;
79
80
  layout: LayoutItem[];
81
+ /**
82
+ * When set, the panel is available only if every listed context key
83
+ * is either missing or matches one of the allowed values.
84
+ * Example: `{ navigationPosition: ['default', 'switch'] }`.
85
+ */
86
+ availableWhen?: SchemaPanelAvailability;
80
87
  };
81
88
  export type SchemaPaletteBookmark = {
82
89
  items: string[];
@@ -93,4 +100,10 @@ export type ComponentSchemaV1 = {
93
100
  fontRelations?: Record<string, string>;
94
101
  allowedPlugins?: string[];
95
102
  states?: string[];
103
+ /**
104
+ * Panel ids that represent a visual component state.
105
+ * `null` or omitted means the component has no state panels.
106
+ * Opening one of these panels sets `currentState` to that panel id.
107
+ */
108
+ statePanels?: string[] | null;
96
109
  };
package/dist/utils.js CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./panelAvailability-D8c7cdbu.js");exports.buildColorVars=a.buildColorVars;exports.getAvailableStatePanels=a.getAvailableStatePanels;exports.getColorAlpha=a.getColorAlpha;exports.getFormFieldValidationError=a.getFormFieldValidationError;exports.getUnavailableStates=a.getUnavailableStates;exports.isPanelAvailable=a.isPanelAvailable;exports.isValidEmailFormat=a.isValidEmailFormat;exports.isValidPhoneFormat=a.isValidPhoneFormat;exports.readTestimonialTextMeasure=a.readTestimonialTextMeasure;exports.scalingValue=a.scalingValue;exports.useScopedStyles=a.useScopedStyles;
package/dist/utils.mjs CHANGED
@@ -1,10 +1,14 @@
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";
1
+ import { b as s, d as l, g as i, a as t, e as o, f as r, i as d, c as n, r as g, s as m, u as b } from "./panelAvailability-CgSic84c.mjs";
2
2
  export {
3
- e as buildColorVars,
4
- i as getFormFieldValidationError,
5
- r as isValidEmailFormat,
6
- o as isValidPhoneFormat,
7
- l as readTestimonialTextMeasure,
8
- t as scalingValue,
9
- d as useScopedStyles
3
+ s as buildColorVars,
4
+ l as getAvailableStatePanels,
5
+ i as getColorAlpha,
6
+ t as getFormFieldValidationError,
7
+ o as getUnavailableStates,
8
+ r as isPanelAvailable,
9
+ d as isValidEmailFormat,
10
+ n as isValidPhoneFormat,
11
+ g as readTestimonialTextMeasure,
12
+ m as scalingValue,
13
+ b as useScopedStyles
10
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/components",
3
- "version": "1.0.69-alpha.3",
3
+ "version": "1.0.69-alpha.5",
4
4
  "description": "Custom components for control editor and public websites.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1,121 +0,0 @@
1
- import { CommonComponentProps } from '../props';
2
- import { TextStyles } from '../utils/textStylesToCss';
3
- export declare const SHAPE_IDS: readonly ["diamond", "parallelogram", "vase", "circle", "shield", "bobbin", "custom"];
4
- export type ShapeId = typeof SHAPE_IDS[number];
5
- type Align = 'left' | 'center' | 'right' | 'justify';
6
- type PathFit = 'stretch' | 'viewbox';
7
- type RichLeaf = {
8
- text?: string;
9
- fontFamily?: string;
10
- fontWeight?: number;
11
- fontStyle?: string;
12
- textDecoration?: string;
13
- textTransform?: string;
14
- fontVariant?: string;
15
- verticalAlign?: string;
16
- };
17
- type RichLink = {
18
- type: 'link';
19
- value?: string;
20
- target?: string;
21
- children?: RichNode[];
22
- };
23
- type RichNode = RichLeaf | RichLink;
24
- type RichBlock = {
25
- type?: string;
26
- children?: RichNode[];
27
- };
28
- type PretextContentItem = {
29
- text?: RichBlock[];
30
- };
31
- type PretextSettings = {
32
- shape?: ShapeId;
33
- customPath?: string;
34
- pathFit?: PathFit;
35
- pathViewBox?: string;
36
- pathSnap?: number;
37
- shapeMode?: 'A' | 'B';
38
- overflowMode?: 'clip' | 'visible';
39
- fitText?: 'on' | 'off';
40
- dropCapLines?: number;
41
- dropCapSize?: number;
42
- image?: string | null;
43
- imageFocalX?: number;
44
- imageFocalY?: number;
45
- imageScale?: number;
46
- backgroundColor?: string;
47
- textColor?: string;
48
- linkColor?: string;
49
- textFontFamily?: string;
50
- textFontSettings?: {
51
- fontWeight: number;
52
- fontStyle: string;
53
- };
54
- textFontSize?: number;
55
- textLineHeight?: number;
56
- textLetterSpacing?: number;
57
- textWordSpacing?: number;
58
- textAlign?: Align;
59
- textTextAppearance?: TextStyles['textAppearance'];
60
- };
61
- type PretextProps = {
62
- settings?: PretextSettings;
63
- content?: PretextContentItem[];
64
- isEditor?: boolean;
65
- isPreviewMode?: boolean;
66
- isEditMode?: boolean;
67
- isSelected?: boolean;
68
- onUpdateSettings?: (settings: PretextSettings) => void;
69
- } & CommonComponentProps;
70
- type Pt = {
71
- x: number;
72
- y: number;
73
- };
74
- type Ring = Pt[];
75
- export type VecNode = {
76
- p: Pt;
77
- in?: Pt | null;
78
- out?: Pt | null;
79
- };
80
- export type VecContour = {
81
- nodes: VecNode[];
82
- closed: boolean;
83
- };
84
- export declare const EDIT_VIEW_BOX = "0 0 100 100";
85
- export declare function mapContours(contours: VecContour[], transform: (point: Pt) => Pt): VecContour[];
86
- export declare function scaleContours(contours: VecContour[], origin: Pt, scaleX: number, scaleY?: number): VecContour[];
87
- export declare function parsePathNodes(d: string): VecContour[];
88
- export declare function serializeContours(contours: VecContour[]): string;
89
- export declare function flattenContours(contours: VecContour[]): Ring[];
90
- export declare function ringsToContours(rings: Ring[]): VecContour[];
91
- export declare function settingsForEditablePreset(shape: ShapeId): {
92
- shape: ShapeId;
93
- customPath: string;
94
- pathFit: 'viewbox';
95
- pathViewBox: string;
96
- };
97
- export declare function moveNodeTo(contours: VecContour[], contourIndex: number, nodeIndex: number, point: Pt): VecContour[];
98
- export declare function moveSelectedNodesBy(contours: VecContour[], selection: {
99
- contour: number;
100
- node: number;
101
- }[], dx: number, dy: number): VecContour[];
102
- export declare function removeContourNodes(contours: VecContour[], selection: {
103
- contour: number;
104
- node: number;
105
- }[]): VecContour[];
106
- export declare function setNodeHandle(contours: VecContour[], contourIndex: number, nodeIndex: number, which: 'in' | 'out', point: Pt, mirror: boolean): VecContour[];
107
- export declare function clearNodeHandle(contours: VecContour[], contourIndex: number, nodeIndex: number, which: 'in' | 'out'): VecContour[];
108
- export declare function insertNodeOnSegment(contours: VecContour[], contourIndex: number, segmentIndex: number, t: number): {
109
- contours: VecContour[];
110
- nodeIndex: number;
111
- };
112
- export declare function removeContourNode(contours: VecContour[], contourIndex: number, nodeIndex: number): VecContour[];
113
- export declare function toggleNodeSmooth(contours: VecContour[], contourIndex: number, nodeIndex: number): VecContour[];
114
- export declare function nearestSegmentHit(contours: VecContour[], point: Pt): {
115
- contour: number;
116
- segment: number;
117
- t: number;
118
- distance: number;
119
- } | null;
120
- export declare function Pretext({ settings, content, isEditor, isPreviewMode, isEditMode, isSelected, onUpdateSettings }: PretextProps): import("react/jsx-runtime").JSX.Element;
121
- export {};
@@ -1,46 +0,0 @@
1
- import { Pretext } from './Pretext';
2
- import { ComponentSchemaV1 } from '../../types/SchemaV1';
3
- export declare const PretextComponent: {
4
- element: typeof Pretext;
5
- id: string;
6
- name: string;
7
- category: string;
8
- version: number;
9
- normalizeLayoutSettingsUpdate: (nextSettings: Record<string, any>, prevSettings: Record<string, any>) => Record<string, any>;
10
- defaultSize: {
11
- d: {
12
- width: number;
13
- height: number;
14
- };
15
- t: {
16
- width: number;
17
- height: number;
18
- };
19
- m: {
20
- width: number;
21
- height: number;
22
- };
23
- };
24
- preview: {
25
- type: "image";
26
- url: string;
27
- };
28
- schema: ComponentSchemaV1;
29
- sourceCode: string;
30
- assetsPaths: {
31
- content: never[];
32
- parameters: {
33
- path: string;
34
- placeholderEnabled: boolean;
35
- }[];
36
- };
37
- fontSettingsPaths: {
38
- content: never[];
39
- parameters: {
40
- path: string;
41
- }[];
42
- };
43
- fontRelations: {
44
- textFontSettings: string;
45
- };
46
- };
@@ -1,60 +0,0 @@
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
- };
@@ -1 +0,0 @@
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;