@sanmid/flux 0.1.5 → 0.1.9

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,240 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ type DesignEditorProps = {
4
+ /**
5
+ * When true, the editor mounts in production builds.
6
+ * Default is **development only** (`process.env.NODE_ENV === "development"`).
7
+ */
8
+ force?: boolean;
9
+ /**
10
+ * Classic margin / border / padding overlay bands on the selected node.
11
+ * Default **false** — only the mint selection ring is shown unless you opt in.
12
+ */
13
+ showBoxModel?: boolean;
14
+ /**
15
+ * When the overlay is active, block default actions on interactive page nodes (buttons, links, inputs, …)
16
+ * via capture-phase listeners. Opt-in for host apps (e.g. playgrounds); default **false**.
17
+ */
18
+ blockPageInteractions?: boolean;
19
+ };
20
+ /**
21
+ * Visual design editor overlay. **Does not render in production** unless `force` is set.
22
+ */
23
+ declare function DesignEditor({ force, showBoxModel, blockPageInteractions, }: DesignEditorProps): react_jsx_runtime.JSX.Element | null;
24
+
25
+ /** Persisted for copy prompt after a successful DOM reorder. */
26
+ type FluxStructuralReorder = {
27
+ type: "reorder";
28
+ containerSelector: string;
29
+ containerComponents: string[];
30
+ originalOrder: string[];
31
+ newOrder: string[];
32
+ childrenType: "array" | "static";
33
+ containerSourceFile: {
34
+ fileName: string;
35
+ lineNumber: number;
36
+ columnNumber?: number;
37
+ } | null;
38
+ childSources?: {
39
+ label: string;
40
+ sourceFile: {
41
+ fileName: string;
42
+ lineNumber: number;
43
+ columnNumber?: number;
44
+ };
45
+ }[];
46
+ timestamp: number;
47
+ };
48
+
49
+ /**
50
+ * Live preview engine using Constructable Stylesheets when supported,
51
+ * otherwise a single <style> tag in document.head.
52
+ *
53
+ * Applies CSS changes without mutating the host element's inline styles.
54
+ */
55
+ interface AppliedRule {
56
+ selector: string;
57
+ property: string;
58
+ value: string;
59
+ }
60
+ declare class PreviewEngine {
61
+ private sheet;
62
+ private fallbackStyle;
63
+ private rules;
64
+ private attached;
65
+ constructor();
66
+ attach(): void;
67
+ detach(): void;
68
+ applyChange(selector: string, property: string, value: string): void;
69
+ removeChange(selector: string, property: string): void;
70
+ removeAllChanges(selector: string): void;
71
+ clearAll(): void;
72
+ getChanges(): readonly AppliedRule[];
73
+ /** Last preview value applied for this selector + property (e.g. `100%` when Fill), or undefined. */
74
+ getPreviewValue(selector: string, property: string): string | undefined;
75
+ destroy(): void;
76
+ private flush;
77
+ }
78
+ /**
79
+ * Generate a unique CSS selector for an element using @medv/finder.
80
+ * Falls back to a manual path if finder throws (e.g., SVG elements).
81
+ */
82
+ declare function getUniqueSelector(el: Element): string;
83
+ /**
84
+ * `parent > :nth-child(n)` so preview rules (e.g. `order`) target the exact direct child.
85
+ * Finder-only selectors often collide for sibling elements; this stays stable for flex/grid children.
86
+ */
87
+ declare function getDirectChildSelector(parent: Element, child: Element): string;
88
+ /**
89
+ * Selector used for {@link PreviewEngine} rules. Verifies each candidate with
90
+ * `querySelectorAll(sel).length === 1` and that node is `el`, so injected rules
91
+ * cannot hit multiple elements (e.g. all `button`s). Last resort: a temporary
92
+ * `data-flux-preview-target` id — call {@link removePreviewTargetAttribute} when deselecting.
93
+ */
94
+ declare function getReliableSelectorForPreview(el: Element): {
95
+ selector: string;
96
+ usedAttrFallback: boolean;
97
+ };
98
+ declare function removePreviewTargetAttribute(el: Element | null | undefined): void;
99
+
100
+ interface StyleSnapshot {
101
+ fontFamily: string;
102
+ fontSize: string;
103
+ fontWeight: string;
104
+ lineHeight: string;
105
+ letterSpacing: string;
106
+ color: string;
107
+ textAlign: string;
108
+ width: string;
109
+ height: string;
110
+ padding: string;
111
+ margin: string;
112
+ paddingTop: string;
113
+ paddingRight: string;
114
+ paddingBottom: string;
115
+ paddingLeft: string;
116
+ marginTop: string;
117
+ marginRight: string;
118
+ marginBottom: string;
119
+ marginLeft: string;
120
+ /** CSS `position` (static, relative, absolute, fixed, sticky). */
121
+ position: string;
122
+ /** Inset offsets for positioned layout (`top` / `right` / `bottom` / `left`). */
123
+ top: string;
124
+ right: string;
125
+ bottom: string;
126
+ left: string;
127
+ /** CSS `align-self` — item alignment in flex/grid. */
128
+ alignSelf: string;
129
+ /** CSS `justify-self` — grid item alignment on row axis. */
130
+ justifySelf: string;
131
+ overflow: string;
132
+ display: string;
133
+ flexDirection: string;
134
+ justifyContent: string;
135
+ alignItems: string;
136
+ gap: string;
137
+ rowGap: string;
138
+ columnGap: string;
139
+ gridTemplateColumns: string;
140
+ gridTemplateRows: string;
141
+ backgroundColor: string;
142
+ /** Computed `background-image` (gradients count as fill for `hasFill`-style checks). */
143
+ backgroundImage: string;
144
+ borderTopWidth: string;
145
+ borderRightWidth: string;
146
+ borderBottomWidth: string;
147
+ borderLeftWidth: string;
148
+ borderTopLeftRadius: string;
149
+ borderTopRightRadius: string;
150
+ borderBottomRightRadius: string;
151
+ borderBottomLeftRadius: string;
152
+ borderTopColor: string;
153
+ borderRightColor: string;
154
+ borderBottomColor: string;
155
+ borderLeftColor: string;
156
+ borderTopStyle: string;
157
+ borderRightStyle: string;
158
+ borderBottomStyle: string;
159
+ borderLeftStyle: string;
160
+ borderColor: string;
161
+ borderRadius: string;
162
+ borderStyle: string;
163
+ boxShadow: string;
164
+ opacity: string;
165
+ }
166
+ type DesignEditorElement = Element & {
167
+ style: CSSStyleDeclaration;
168
+ };
169
+ declare function isStyleableElement(target: EventTarget | null): target is DesignEditorElement;
170
+ declare function getComputedSnapshot(el: Element): StyleSnapshot;
171
+ declare function getElementPath(el: Element): string;
172
+ declare function getElementSelector(el: Element): string;
173
+
174
+ /**
175
+ * Border-box dimensions in viewport CSS pixels, rounded for the overlay label.
176
+ */
177
+ declare function formatSelectionDimensions(width: number, height: number): string;
178
+
179
+ /**
180
+ * React fiber traversal for extracting component hierarchy and source file locations.
181
+ * Works with React 18+ dev builds that attach `__reactFiber$` to DOM nodes.
182
+ */
183
+ interface ReactComponentInfo {
184
+ components: string[];
185
+ sourceFile: {
186
+ fileName: string;
187
+ lineNumber: number;
188
+ columnNumber?: number;
189
+ } | null;
190
+ }
191
+ declare function getExactSourceLocation(el: Element): string | null;
192
+ declare function getReactComponentStack(el: Element): string | null;
193
+ declare function getReactComponentInfo(el: Element): ReactComponentInfo;
194
+
195
+ /**
196
+ * Lazy token scanner — walks document.styleSheets to discover CSS custom properties
197
+ * and utility class tokens. Scans on-demand per category, cached until stylesheet count changes.
198
+ */
199
+ type TokenCategory = "colors" | "spacing" | "typography" | "borders" | "effects" | "layout";
200
+ type CssFramework = "tailwind" | "css-modules" | "custom" | "unknown";
201
+ interface DesignToken {
202
+ className: string;
203
+ property: string;
204
+ value: string;
205
+ category: TokenCategory;
206
+ }
207
+ interface CssVariable {
208
+ name: string;
209
+ value: string;
210
+ category: TokenCategory;
211
+ }
212
+ interface TokenScanResult {
213
+ tokens: DesignToken[];
214
+ variables: CssVariable[];
215
+ framework: CssFramework;
216
+ }
217
+ declare function scanTokens(): TokenScanResult;
218
+ /** One-line summary for AI prompts (design-token preamble). */
219
+ declare function summarizeTokenSystem(): string | null;
220
+ declare function detectFramework(): CssFramework;
221
+ declare function getTokensForProperty(cssProperty: string): DesignToken[];
222
+ declare function getVariablesForProperty(cssProperty: string): CssVariable[];
223
+ /**
224
+ * Variables that appear in real CSS rules for this property first, then category fallback.
225
+ */
226
+ declare function getVariablesForPropertySmart(cssPropertyKebab: string): CssVariable[];
227
+
228
+ /**
229
+ * Maps CSS property names (kebab-case) to custom property names that appear
230
+ * in stylesheet values via var(--name), so pickers can prefer vars actually
231
+ * used for that property in the host app.
232
+ */
233
+ declare function invalidateVariableUsageCache(): void;
234
+ /** Custom property names (--foo) that appear in rules for this CSS property. */
235
+ declare function getVariablesUsedForCssProperty(kebabProperty: string): string[];
236
+
237
+ /** Collect `font-family` values from parsed stylesheets (best-effort; skips cross-origin). */
238
+ declare function scanStylesheetFontFamilies(): string[];
239
+
240
+ export { type CssFramework, type CssVariable, DesignEditor, type DesignEditorElement, type DesignEditorProps, type DesignToken, type FluxStructuralReorder, PreviewEngine, type ReactComponentInfo, type StyleSnapshot, type TokenCategory, type TokenScanResult, detectFramework, formatSelectionDimensions, getComputedSnapshot, getDirectChildSelector, getElementPath, getElementSelector, getExactSourceLocation, getReactComponentInfo, getReactComponentStack, getReliableSelectorForPreview, getTokensForProperty, getUniqueSelector, getVariablesForProperty, getVariablesForPropertySmart, getVariablesUsedForCssProperty, invalidateVariableUsageCache, isStyleableElement, removePreviewTargetAttribute, scanStylesheetFontFamilies, scanTokens, summarizeTokenSystem };