@cntrl-site/components 1.0.63 → 1.0.64-alpha.0
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/Components/Pretext/Pretext.d.ts +132 -0
- package/dist/Components/Pretext/PretextComponent.d.ts +43 -0
- package/dist/index.js +2779 -85
- package/dist/index.mjs +12365 -8046
- package/package.json +1 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { CommonComponentProps } from '../props';
|
|
2
|
+
import { TextStyles } from '../utils/textStylesToCss';
|
|
3
|
+
export declare const SHAPE_IDS: readonly ["rectangle", "ellipse", "circle", "triangle-up", "triangle-down", "diamond", "hourglass", "teardrop", "leaf", "wave", "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
|
+
path?: string;
|
|
31
|
+
};
|
|
32
|
+
type PretextSettings = {
|
|
33
|
+
shape?: ShapeId;
|
|
34
|
+
customPath?: string;
|
|
35
|
+
pathFit?: PathFit;
|
|
36
|
+
pathViewBox?: string;
|
|
37
|
+
pathSnap?: number;
|
|
38
|
+
shapeMode?: 'contain' | 'avoid';
|
|
39
|
+
overflowMode?: 'clip' | 'visible';
|
|
40
|
+
fitText?: 'on' | 'off';
|
|
41
|
+
dropCap?: 'on' | 'off';
|
|
42
|
+
dropCapLines?: number;
|
|
43
|
+
backgroundColor?: string;
|
|
44
|
+
textColor?: string;
|
|
45
|
+
linkColor?: string;
|
|
46
|
+
textFontFamily?: string;
|
|
47
|
+
textFontSettings?: {
|
|
48
|
+
fontWeight: number;
|
|
49
|
+
fontStyle: string;
|
|
50
|
+
};
|
|
51
|
+
textFontSize?: number;
|
|
52
|
+
textLineHeight?: number;
|
|
53
|
+
textLetterSpacing?: number;
|
|
54
|
+
textWordSpacing?: number;
|
|
55
|
+
textAlign?: Align;
|
|
56
|
+
textTextAppearance?: TextStyles['textAppearance'];
|
|
57
|
+
};
|
|
58
|
+
type PretextProps = {
|
|
59
|
+
settings?: PretextSettings;
|
|
60
|
+
content?: PretextContentItem[];
|
|
61
|
+
isEditor?: boolean;
|
|
62
|
+
isPreviewMode?: boolean;
|
|
63
|
+
isEditMode?: boolean;
|
|
64
|
+
isSelected?: boolean;
|
|
65
|
+
onUpdateSettings?: (settings: PretextSettings) => void;
|
|
66
|
+
} & CommonComponentProps;
|
|
67
|
+
type Pt = {
|
|
68
|
+
x: number;
|
|
69
|
+
y: number;
|
|
70
|
+
};
|
|
71
|
+
type Ring = Pt[];
|
|
72
|
+
/** One anchor plus the two cubic handles meeting on it. `null` handle = straight. */
|
|
73
|
+
export type VecNode = {
|
|
74
|
+
p: Pt;
|
|
75
|
+
in?: Pt | null;
|
|
76
|
+
out?: Pt | null;
|
|
77
|
+
};
|
|
78
|
+
export type VecContour = {
|
|
79
|
+
nodes: VecNode[];
|
|
80
|
+
closed: boolean;
|
|
81
|
+
};
|
|
82
|
+
/** Vector editing always happens in this coordinate space, so a drag is 1:1. */
|
|
83
|
+
export declare const EDIT_VIEW_BOX = "0 0 100 100";
|
|
84
|
+
export declare function mapContours(contours: VecContour[], transform: (point: Pt) => Pt): VecContour[];
|
|
85
|
+
/** Uniform (or axis-independent) scale about `origin` — keeps proportions when sx === sy. */
|
|
86
|
+
export declare function scaleContours(contours: VecContour[], origin: Pt, scaleX: number, scaleY?: number): VecContour[];
|
|
87
|
+
/**
|
|
88
|
+
* SVG path string → editable contours. Every command is normalized to cubic
|
|
89
|
+
* nodes, so what comes back can be dragged around and written out again.
|
|
90
|
+
*/
|
|
91
|
+
export declare function parsePathNodes(d: string): VecContour[];
|
|
92
|
+
/** Contours → an SVG path string, which is what the setting stores. */
|
|
93
|
+
export declare function serializeContours(contours: VecContour[]): string;
|
|
94
|
+
/** Contours → polygon rings, the form the text layout reads. */
|
|
95
|
+
export declare function flattenContours(contours: VecContour[]): Ring[];
|
|
96
|
+
/**
|
|
97
|
+
* Sampled rings → contours, so any preset can be picked up and dragged.
|
|
98
|
+
* Few points means a polygon: its corners are kept. Many points means a curve:
|
|
99
|
+
* it is thinned out and smoothed back, which lands within a hair of the original.
|
|
100
|
+
*/
|
|
101
|
+
export declare function ringsToContours(rings: Ring[]): VecContour[];
|
|
102
|
+
/** Turns a preset into the editable viewBox path the editor persists after a shape pick. */
|
|
103
|
+
export declare function settingsForEditablePreset(shape: ShapeId, aspect?: number, previous?: {
|
|
104
|
+
customPath?: string;
|
|
105
|
+
pathFit?: string;
|
|
106
|
+
pathViewBox?: string;
|
|
107
|
+
}): {
|
|
108
|
+
shape: 'custom';
|
|
109
|
+
customPath: string;
|
|
110
|
+
pathFit: 'viewbox';
|
|
111
|
+
pathViewBox: string;
|
|
112
|
+
};
|
|
113
|
+
export declare function moveNodeTo(contours: VecContour[], contourIndex: number, nodeIndex: number, point: Pt): VecContour[];
|
|
114
|
+
export declare function setNodeHandle(contours: VecContour[], contourIndex: number, nodeIndex: number, which: 'in' | 'out', point: Pt, mirror: boolean): VecContour[];
|
|
115
|
+
/** Pulls a handle back into its anchor, straightening that side of the node. */
|
|
116
|
+
export declare function clearNodeHandle(contours: VecContour[], contourIndex: number, nodeIndex: number, which: 'in' | 'out'): VecContour[];
|
|
117
|
+
/** Splits a segment at `t` (de Casteljau), so the new node sits on the curve. */
|
|
118
|
+
export declare function insertNodeOnSegment(contours: VecContour[], contourIndex: number, segmentIndex: number, t: number): {
|
|
119
|
+
contours: VecContour[];
|
|
120
|
+
nodeIndex: number;
|
|
121
|
+
};
|
|
122
|
+
export declare function removeContourNode(contours: VecContour[], contourIndex: number, nodeIndex: number): VecContour[];
|
|
123
|
+
/** Corner ⇄ smooth: drops both handles, or grows them from the neighbours. */
|
|
124
|
+
export declare function toggleNodeSmooth(contours: VecContour[], contourIndex: number, nodeIndex: number): VecContour[];
|
|
125
|
+
export declare function nearestSegmentHit(contours: VecContour[], point: Pt): {
|
|
126
|
+
contour: number;
|
|
127
|
+
segment: number;
|
|
128
|
+
t: number;
|
|
129
|
+
distance: number;
|
|
130
|
+
} | null;
|
|
131
|
+
export declare function Pretext({ settings, content, isEditor, isPreviewMode, isEditMode, isSelected, onUpdateSettings }: PretextProps): import("react/jsx-runtime").JSX.Element;
|
|
132
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
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: never[];
|
|
33
|
+
};
|
|
34
|
+
fontSettingsPaths: {
|
|
35
|
+
content: never[];
|
|
36
|
+
parameters: {
|
|
37
|
+
path: string;
|
|
38
|
+
}[];
|
|
39
|
+
};
|
|
40
|
+
fontRelations: {
|
|
41
|
+
textFontSettings: string;
|
|
42
|
+
};
|
|
43
|
+
};
|