dynim-core 1.0.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/README.md +290 -0
- package/dist/builder/ai-prompt-popover.d.ts +26 -0
- package/dist/builder/ai-prompt-popover.d.ts.map +1 -0
- package/dist/builder/ai-prompt-popover.js +180 -0
- package/dist/builder/builder-client.d.ts +48 -0
- package/dist/builder/builder-client.d.ts.map +1 -0
- package/dist/builder/builder-client.js +157 -0
- package/dist/builder/builder.d.ts +41 -0
- package/dist/builder/builder.d.ts.map +1 -0
- package/dist/builder/builder.js +537 -0
- package/dist/builder/bundle-manager.d.ts +60 -0
- package/dist/builder/bundle-manager.d.ts.map +1 -0
- package/dist/builder/bundle-manager.js +357 -0
- package/dist/builder/classifier/classname-analyzer.d.ts +6 -0
- package/dist/builder/classifier/classname-analyzer.d.ts.map +1 -0
- package/dist/builder/classifier/classname-analyzer.js +107 -0
- package/dist/builder/classifier/index.d.ts +20 -0
- package/dist/builder/classifier/index.d.ts.map +1 -0
- package/dist/builder/classifier/index.js +181 -0
- package/dist/builder/classifier/semantic-analyzer.d.ts +24 -0
- package/dist/builder/classifier/semantic-analyzer.d.ts.map +1 -0
- package/dist/builder/classifier/semantic-analyzer.js +94 -0
- package/dist/builder/classifier/size-analyzer.d.ts +7 -0
- package/dist/builder/classifier/size-analyzer.d.ts.map +1 -0
- package/dist/builder/classifier/size-analyzer.js +120 -0
- package/dist/builder/classifier/visual-analyzer.d.ts +6 -0
- package/dist/builder/classifier/visual-analyzer.d.ts.map +1 -0
- package/dist/builder/classifier/visual-analyzer.js +158 -0
- package/dist/builder/client.d.ts +22 -0
- package/dist/builder/client.d.ts.map +1 -0
- package/dist/builder/client.js +54 -0
- package/dist/builder/code-client.d.ts +101 -0
- package/dist/builder/code-client.d.ts.map +1 -0
- package/dist/builder/code-client.js +418 -0
- package/dist/builder/diff-state.d.ts +24 -0
- package/dist/builder/diff-state.d.ts.map +1 -0
- package/dist/builder/diff-state.js +134 -0
- package/dist/builder/dom-scanner.d.ts +20 -0
- package/dist/builder/dom-scanner.d.ts.map +1 -0
- package/dist/builder/dom-scanner.js +102 -0
- package/dist/builder/drag-engine.d.ts +41 -0
- package/dist/builder/drag-engine.d.ts.map +1 -0
- package/dist/builder/drag-engine.js +686 -0
- package/dist/builder/editor-overlays.d.ts +31 -0
- package/dist/builder/editor-overlays.d.ts.map +1 -0
- package/dist/builder/editor-overlays.js +202 -0
- package/dist/builder/editor-state.d.ts +50 -0
- package/dist/builder/editor-state.d.ts.map +1 -0
- package/dist/builder/editor-state.js +132 -0
- package/dist/builder/element-utils.d.ts +43 -0
- package/dist/builder/element-utils.d.ts.map +1 -0
- package/dist/builder/element-utils.js +227 -0
- package/dist/builder/fiber-capture.d.ts +28 -0
- package/dist/builder/fiber-capture.d.ts.map +1 -0
- package/dist/builder/fiber-capture.js +264 -0
- package/dist/builder/freeze-overlay.d.ts +26 -0
- package/dist/builder/freeze-overlay.d.ts.map +1 -0
- package/dist/builder/freeze-overlay.js +213 -0
- package/dist/builder/history-state.d.ts +41 -0
- package/dist/builder/history-state.d.ts.map +1 -0
- package/dist/builder/history-state.js +76 -0
- package/dist/builder/index.d.ts +62 -0
- package/dist/builder/index.d.ts.map +1 -0
- package/dist/builder/index.js +92 -0
- package/dist/builder/state.d.ts +27 -0
- package/dist/builder/state.d.ts.map +1 -0
- package/dist/builder/state.js +50 -0
- package/dist/builder/style-applier.d.ts +61 -0
- package/dist/builder/style-applier.d.ts.map +1 -0
- package/dist/builder/style-applier.js +311 -0
- package/dist/builder/tree-state.d.ts +71 -0
- package/dist/builder/tree-state.d.ts.map +1 -0
- package/dist/builder/tree-state.js +168 -0
- package/dist/builder/widget.d.ts +29 -0
- package/dist/builder/widget.d.ts.map +1 -0
- package/dist/builder/widget.js +181 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/package.json +25 -0
- package/src/styles/base.css +378 -0
- package/src/styles/builder.css +422 -0
- package/src/styles/editor.css +131 -0
- package/src/styles/themes/dark.css +24 -0
- package/src/styles/themes/light.css +21 -0
- package/src/styles/variables.css +63 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visual overlays for the editor
|
|
3
|
+
* Hover highlight, selection box, drag ghost, drop indicator
|
|
4
|
+
* Uses CSS classes with !important to prevent Dark Reader interference
|
|
5
|
+
*/
|
|
6
|
+
export interface OverlaysConfig {
|
|
7
|
+
zIndex?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface Overlays {
|
|
10
|
+
container: HTMLDivElement;
|
|
11
|
+
mount: () => void;
|
|
12
|
+
unmount: () => void;
|
|
13
|
+
showHover: (rect: DOMRect | null) => void;
|
|
14
|
+
hideHover: () => void;
|
|
15
|
+
showSelection: (rect: DOMRect | null) => void;
|
|
16
|
+
hideSelection: () => void;
|
|
17
|
+
showDragGhost: (sourceRect: DOMRect | null, cursorPos: {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
} | null, grabOffsetX?: number | null, grabOffsetY?: number | null) => void;
|
|
21
|
+
hideDragGhost: () => void;
|
|
22
|
+
showDropIndicator: (targetRect: DOMRect | null, position: string | null, parentRect?: DOMRect | null) => void;
|
|
23
|
+
hideDropIndicator: () => void;
|
|
24
|
+
showNoDropIndicator: (rect: DOMRect | null) => void;
|
|
25
|
+
hideNoDropIndicator: () => void;
|
|
26
|
+
showTooltip: (text: string | null, rect: DOMRect | null) => void;
|
|
27
|
+
hideTooltip: () => void;
|
|
28
|
+
hideAll: () => void;
|
|
29
|
+
}
|
|
30
|
+
export declare function createOverlays(config?: OverlaysConfig): Overlays;
|
|
31
|
+
//# sourceMappingURL=editor-overlays.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-overlays.d.ts","sourceRoot":"","sources":["../../src/builder/editor-overlays.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WA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AAG,QAAQ,CA4NpE"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visual overlays for the editor
|
|
3
|
+
* Hover highlight, selection box, drag ghost, drop indicator
|
|
4
|
+
* Uses CSS classes with !important to prevent Dark Reader interference
|
|
5
|
+
*/
|
|
6
|
+
function createOverlayElement(className) {
|
|
7
|
+
const el = document.createElement('div');
|
|
8
|
+
el.className = className;
|
|
9
|
+
el.style.display = 'none';
|
|
10
|
+
return el;
|
|
11
|
+
}
|
|
12
|
+
export function createOverlays(config = {}) {
|
|
13
|
+
const { zIndex = 10000 } = config;
|
|
14
|
+
const container = document.createElement('div');
|
|
15
|
+
container.id = '__editor-overlays__';
|
|
16
|
+
container.style.cssText = `
|
|
17
|
+
position: fixed;
|
|
18
|
+
inset: 0;
|
|
19
|
+
pointer-events: none;
|
|
20
|
+
z-index: ${zIndex};
|
|
21
|
+
`;
|
|
22
|
+
const hoverOverlay = createOverlayElement('editor-hover-overlay');
|
|
23
|
+
const selectionOverlay = createOverlayElement('editor-selection-overlay');
|
|
24
|
+
const dragGhost = createOverlayElement('editor-drag-ghost');
|
|
25
|
+
const dropLine = createOverlayElement('editor-drop-line');
|
|
26
|
+
const dropTarget = createOverlayElement('editor-drop-target');
|
|
27
|
+
const parentHighlight = createOverlayElement('editor-parent-highlight');
|
|
28
|
+
const tooltip = createOverlayElement('editor-tooltip');
|
|
29
|
+
const noDropIndicator = createOverlayElement('editor-no-drop-indicator');
|
|
30
|
+
container.appendChild(hoverOverlay);
|
|
31
|
+
container.appendChild(selectionOverlay);
|
|
32
|
+
container.appendChild(dragGhost);
|
|
33
|
+
container.appendChild(dropTarget);
|
|
34
|
+
container.appendChild(parentHighlight);
|
|
35
|
+
container.appendChild(dropLine);
|
|
36
|
+
container.appendChild(tooltip);
|
|
37
|
+
container.appendChild(noDropIndicator);
|
|
38
|
+
function mount() {
|
|
39
|
+
document.body.appendChild(container);
|
|
40
|
+
}
|
|
41
|
+
function unmount() {
|
|
42
|
+
container.remove();
|
|
43
|
+
}
|
|
44
|
+
function showHover(rect) {
|
|
45
|
+
if (!rect) {
|
|
46
|
+
hideHover();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
hoverOverlay.style.left = `${rect.x}px`;
|
|
50
|
+
hoverOverlay.style.top = `${rect.y}px`;
|
|
51
|
+
hoverOverlay.style.width = `${rect.width}px`;
|
|
52
|
+
hoverOverlay.style.height = `${rect.height}px`;
|
|
53
|
+
hoverOverlay.style.display = 'block';
|
|
54
|
+
hoverOverlay.classList.add('active');
|
|
55
|
+
}
|
|
56
|
+
function hideHover() {
|
|
57
|
+
hoverOverlay.classList.remove('active');
|
|
58
|
+
hoverOverlay.style.display = 'none';
|
|
59
|
+
}
|
|
60
|
+
function showSelection(rect) {
|
|
61
|
+
if (!rect) {
|
|
62
|
+
hideSelection();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
selectionOverlay.style.left = `${rect.x}px`;
|
|
66
|
+
selectionOverlay.style.top = `${rect.y}px`;
|
|
67
|
+
selectionOverlay.style.width = `${rect.width}px`;
|
|
68
|
+
selectionOverlay.style.height = `${rect.height}px`;
|
|
69
|
+
selectionOverlay.style.display = 'block';
|
|
70
|
+
selectionOverlay.classList.add('active');
|
|
71
|
+
}
|
|
72
|
+
function hideSelection() {
|
|
73
|
+
selectionOverlay.classList.remove('active');
|
|
74
|
+
selectionOverlay.style.display = 'none';
|
|
75
|
+
}
|
|
76
|
+
function showDragGhost(sourceRect, cursorPos, grabOffsetX = null, grabOffsetY = null) {
|
|
77
|
+
if (!sourceRect || !cursorPos) {
|
|
78
|
+
hideDragGhost();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const ghostX = grabOffsetX !== null ? cursorPos.x - grabOffsetX : cursorPos.x - sourceRect.width / 2;
|
|
82
|
+
const ghostY = grabOffsetY !== null ? cursorPos.y - grabOffsetY : cursorPos.y - sourceRect.height / 2;
|
|
83
|
+
dragGhost.style.left = `${ghostX}px`;
|
|
84
|
+
dragGhost.style.top = `${ghostY}px`;
|
|
85
|
+
dragGhost.style.width = `${sourceRect.width}px`;
|
|
86
|
+
dragGhost.style.height = `${sourceRect.height}px`;
|
|
87
|
+
dragGhost.style.display = 'block';
|
|
88
|
+
dragGhost.classList.add('active');
|
|
89
|
+
}
|
|
90
|
+
function hideDragGhost() {
|
|
91
|
+
dragGhost.classList.remove('active');
|
|
92
|
+
dragGhost.style.display = 'none';
|
|
93
|
+
}
|
|
94
|
+
function showDropIndicator(targetRect, position, _parentRect) {
|
|
95
|
+
if (!targetRect || !position) {
|
|
96
|
+
hideDropIndicator();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
dropTarget.style.left = `${targetRect.x}px`;
|
|
100
|
+
dropTarget.style.top = `${targetRect.y}px`;
|
|
101
|
+
dropTarget.style.width = `${targetRect.width}px`;
|
|
102
|
+
dropTarget.style.height = `${targetRect.height}px`;
|
|
103
|
+
dropTarget.style.display = 'block';
|
|
104
|
+
dropTarget.classList.add('active');
|
|
105
|
+
parentHighlight.classList.remove('active');
|
|
106
|
+
parentHighlight.style.display = 'none';
|
|
107
|
+
const lineThickness = 4;
|
|
108
|
+
if (position === 'top') {
|
|
109
|
+
dropLine.style.left = `${targetRect.x}px`;
|
|
110
|
+
dropLine.style.top = `${targetRect.y - lineThickness / 2}px`;
|
|
111
|
+
dropLine.style.width = `${targetRect.width}px`;
|
|
112
|
+
dropLine.style.height = `${lineThickness}px`;
|
|
113
|
+
}
|
|
114
|
+
else if (position === 'bottom') {
|
|
115
|
+
dropLine.style.left = `${targetRect.x}px`;
|
|
116
|
+
dropLine.style.top = `${targetRect.y + targetRect.height - lineThickness / 2}px`;
|
|
117
|
+
dropLine.style.width = `${targetRect.width}px`;
|
|
118
|
+
dropLine.style.height = `${lineThickness}px`;
|
|
119
|
+
}
|
|
120
|
+
else if (position === 'left') {
|
|
121
|
+
dropLine.style.left = `${targetRect.x - lineThickness / 2}px`;
|
|
122
|
+
dropLine.style.top = `${targetRect.y}px`;
|
|
123
|
+
dropLine.style.width = `${lineThickness}px`;
|
|
124
|
+
dropLine.style.height = `${targetRect.height}px`;
|
|
125
|
+
}
|
|
126
|
+
else if (position === 'right') {
|
|
127
|
+
dropLine.style.left = `${targetRect.x + targetRect.width - lineThickness / 2}px`;
|
|
128
|
+
dropLine.style.top = `${targetRect.y}px`;
|
|
129
|
+
dropLine.style.width = `${lineThickness}px`;
|
|
130
|
+
dropLine.style.height = `${targetRect.height}px`;
|
|
131
|
+
}
|
|
132
|
+
dropLine.style.display = 'block';
|
|
133
|
+
dropLine.classList.add('active');
|
|
134
|
+
}
|
|
135
|
+
function hideDropIndicator() {
|
|
136
|
+
dropTarget.classList.remove('active');
|
|
137
|
+
dropTarget.style.display = 'none';
|
|
138
|
+
dropLine.classList.remove('active');
|
|
139
|
+
dropLine.style.display = 'none';
|
|
140
|
+
parentHighlight.classList.remove('active');
|
|
141
|
+
parentHighlight.style.display = 'none';
|
|
142
|
+
}
|
|
143
|
+
function showNoDropIndicator(rect) {
|
|
144
|
+
if (!rect) {
|
|
145
|
+
hideNoDropIndicator();
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
noDropIndicator.style.left = `${rect.x}px`;
|
|
149
|
+
noDropIndicator.style.top = `${rect.y}px`;
|
|
150
|
+
noDropIndicator.style.width = `${rect.width}px`;
|
|
151
|
+
noDropIndicator.style.height = `${rect.height}px`;
|
|
152
|
+
noDropIndicator.style.display = 'block';
|
|
153
|
+
noDropIndicator.classList.add('active');
|
|
154
|
+
}
|
|
155
|
+
function hideNoDropIndicator() {
|
|
156
|
+
noDropIndicator.classList.remove('active');
|
|
157
|
+
noDropIndicator.style.display = 'none';
|
|
158
|
+
}
|
|
159
|
+
function showTooltip(text, rect) {
|
|
160
|
+
if (!text || !rect) {
|
|
161
|
+
hideTooltip();
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const tooltipX = rect.x;
|
|
165
|
+
const tooltipY = rect.y - 28;
|
|
166
|
+
tooltip.textContent = text;
|
|
167
|
+
tooltip.style.left = `${tooltipX}px`;
|
|
168
|
+
tooltip.style.top = `${Math.max(4, tooltipY)}px`;
|
|
169
|
+
tooltip.style.display = 'block';
|
|
170
|
+
tooltip.classList.add('active');
|
|
171
|
+
}
|
|
172
|
+
function hideTooltip() {
|
|
173
|
+
tooltip.classList.remove('active');
|
|
174
|
+
tooltip.style.display = 'none';
|
|
175
|
+
}
|
|
176
|
+
function hideAll() {
|
|
177
|
+
hideHover();
|
|
178
|
+
hideSelection();
|
|
179
|
+
hideDragGhost();
|
|
180
|
+
hideDropIndicator();
|
|
181
|
+
hideNoDropIndicator();
|
|
182
|
+
hideTooltip();
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
container,
|
|
186
|
+
mount,
|
|
187
|
+
unmount,
|
|
188
|
+
showHover,
|
|
189
|
+
hideHover,
|
|
190
|
+
showSelection,
|
|
191
|
+
hideSelection,
|
|
192
|
+
showDragGhost,
|
|
193
|
+
hideDragGhost,
|
|
194
|
+
showDropIndicator,
|
|
195
|
+
hideDropIndicator,
|
|
196
|
+
showNoDropIndicator,
|
|
197
|
+
hideNoDropIndicator,
|
|
198
|
+
showTooltip,
|
|
199
|
+
hideTooltip,
|
|
200
|
+
hideAll
|
|
201
|
+
};
|
|
202
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor state management - Selection, hover, and drag state
|
|
3
|
+
* Uses event emitters for framework-agnostic reactivity (matching state.js pattern)
|
|
4
|
+
*/
|
|
5
|
+
export interface DropIndicator {
|
|
6
|
+
rect: DOMRect;
|
|
7
|
+
position: string;
|
|
8
|
+
parentRect?: DOMRect | null;
|
|
9
|
+
}
|
|
10
|
+
export interface EditorStateData {
|
|
11
|
+
selectedIds: string[];
|
|
12
|
+
primarySelectedId: string | null;
|
|
13
|
+
selectionRect: DOMRect | null;
|
|
14
|
+
selectedElement: HTMLElement | null;
|
|
15
|
+
hoveredId: string | null;
|
|
16
|
+
hoverRect: DOMRect | null;
|
|
17
|
+
hoveredElement: HTMLElement | null;
|
|
18
|
+
drillDepth: number;
|
|
19
|
+
isMultiSelectActive: boolean;
|
|
20
|
+
isDragging: boolean;
|
|
21
|
+
dragSourceElement: HTMLElement | null;
|
|
22
|
+
dragSourceRect: DOMRect | null;
|
|
23
|
+
dragGhostPos: {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
} | null;
|
|
27
|
+
dropIndicator: DropIndicator | null;
|
|
28
|
+
}
|
|
29
|
+
export type EditorStateListener = (state: EditorStateData, prevState?: EditorStateData) => void;
|
|
30
|
+
export interface EditorState {
|
|
31
|
+
getState: () => EditorStateData;
|
|
32
|
+
setState: (updates: Partial<EditorStateData>) => void;
|
|
33
|
+
subscribe: (listener: EditorStateListener) => () => void;
|
|
34
|
+
setSelectedIds: (ids: string[]) => void;
|
|
35
|
+
addToSelection: (id: string) => void;
|
|
36
|
+
clearSelection: () => void;
|
|
37
|
+
setSelection: (element: HTMLElement | null, rect: DOMRect | null) => void;
|
|
38
|
+
setHover: (id: string | null, element: HTMLElement | null, rect: DOMRect | null) => void;
|
|
39
|
+
clearHover: () => void;
|
|
40
|
+
incrementDrillDepth: () => void;
|
|
41
|
+
resetDrillDepth: () => void;
|
|
42
|
+
startDrag: (element: HTMLElement, rect: DOMRect) => void;
|
|
43
|
+
updateDrag: (ghostPos: {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
} | null, dropIndicator: DropIndicator | null) => void;
|
|
47
|
+
endDrag: () => void;
|
|
48
|
+
}
|
|
49
|
+
export declare function createEditorState(initialState?: Partial<EditorStateData>): EditorState;
|
|
50
|
+
//# sourceMappingURL=editor-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-state.d.ts","sourceRoot":"","sources":["../../src/builder/editor-state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH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rC,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,YAAY,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1E,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;IACzF,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,SAAS,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACzD,UAAU,EAAE,CAAC,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,EAAE,aAAa,EAAE,aAAa,GAAG,IAAI,KAAK,IAAI,CAAC;IACrG,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wBAAgB,iBAAiB,CAAC,YAAY,GAAE,OAAO,CAAC,eAAe,CAAM,GAAG,WAAW,CA+I1F"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor state management - Selection, hover, and drag state
|
|
3
|
+
* Uses event emitters for framework-agnostic reactivity (matching state.js pattern)
|
|
4
|
+
*/
|
|
5
|
+
export function createEditorState(initialState = {}) {
|
|
6
|
+
let state = {
|
|
7
|
+
selectedIds: [],
|
|
8
|
+
primarySelectedId: null,
|
|
9
|
+
selectionRect: null,
|
|
10
|
+
selectedElement: null,
|
|
11
|
+
hoveredId: null,
|
|
12
|
+
hoverRect: null,
|
|
13
|
+
hoveredElement: null,
|
|
14
|
+
drillDepth: 0,
|
|
15
|
+
isMultiSelectActive: false,
|
|
16
|
+
isDragging: false,
|
|
17
|
+
dragSourceElement: null,
|
|
18
|
+
dragSourceRect: null,
|
|
19
|
+
dragGhostPos: null,
|
|
20
|
+
dropIndicator: null,
|
|
21
|
+
...initialState
|
|
22
|
+
};
|
|
23
|
+
const listeners = new Set();
|
|
24
|
+
function getState() {
|
|
25
|
+
return { ...state };
|
|
26
|
+
}
|
|
27
|
+
function setState(updates) {
|
|
28
|
+
const prevState = state;
|
|
29
|
+
state = { ...state, ...updates };
|
|
30
|
+
listeners.forEach(listener => listener(state, prevState));
|
|
31
|
+
}
|
|
32
|
+
function subscribe(listener) {
|
|
33
|
+
listeners.add(listener);
|
|
34
|
+
return () => listeners.delete(listener);
|
|
35
|
+
}
|
|
36
|
+
function setSelectedIds(ids) {
|
|
37
|
+
setState({
|
|
38
|
+
selectedIds: ids,
|
|
39
|
+
primarySelectedId: ids[0] ?? null,
|
|
40
|
+
drillDepth: 0,
|
|
41
|
+
isMultiSelectActive: ids.length > 1
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function addToSelection(id) {
|
|
45
|
+
if (state.selectedIds.includes(id)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
setState({
|
|
49
|
+
selectedIds: [...state.selectedIds, id],
|
|
50
|
+
isMultiSelectActive: true
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function clearSelection() {
|
|
54
|
+
setState({
|
|
55
|
+
selectedIds: [],
|
|
56
|
+
primarySelectedId: null,
|
|
57
|
+
selectionRect: null,
|
|
58
|
+
selectedElement: null,
|
|
59
|
+
isMultiSelectActive: false
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function setSelection(element, rect) {
|
|
63
|
+
setState({
|
|
64
|
+
selectedElement: element,
|
|
65
|
+
selectionRect: rect
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function setHover(id, element, rect) {
|
|
69
|
+
setState({
|
|
70
|
+
hoveredId: id,
|
|
71
|
+
hoveredElement: element,
|
|
72
|
+
hoverRect: rect
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function clearHover() {
|
|
76
|
+
setState({
|
|
77
|
+
hoveredId: null,
|
|
78
|
+
hoveredElement: null,
|
|
79
|
+
hoverRect: null
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function incrementDrillDepth() {
|
|
83
|
+
setState({
|
|
84
|
+
drillDepth: state.drillDepth + 1
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function resetDrillDepth() {
|
|
88
|
+
setState({
|
|
89
|
+
drillDepth: 0
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function startDrag(element, rect) {
|
|
93
|
+
setState({
|
|
94
|
+
isDragging: true,
|
|
95
|
+
dragSourceElement: element,
|
|
96
|
+
dragSourceRect: rect,
|
|
97
|
+
selectedElement: null,
|
|
98
|
+
selectionRect: null
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function updateDrag(ghostPos, dropIndicator) {
|
|
102
|
+
setState({
|
|
103
|
+
dragGhostPos: ghostPos,
|
|
104
|
+
dropIndicator: dropIndicator
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function endDrag() {
|
|
108
|
+
setState({
|
|
109
|
+
isDragging: false,
|
|
110
|
+
dragSourceElement: null,
|
|
111
|
+
dragSourceRect: null,
|
|
112
|
+
dragGhostPos: null,
|
|
113
|
+
dropIndicator: null
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
getState,
|
|
118
|
+
setState,
|
|
119
|
+
subscribe,
|
|
120
|
+
setSelectedIds,
|
|
121
|
+
addToSelection,
|
|
122
|
+
clearSelection,
|
|
123
|
+
setSelection,
|
|
124
|
+
setHover,
|
|
125
|
+
clearHover,
|
|
126
|
+
incrementDrillDepth,
|
|
127
|
+
resetDrillDepth,
|
|
128
|
+
startDrag,
|
|
129
|
+
updateDrag,
|
|
130
|
+
endDrag
|
|
131
|
+
};
|
|
132
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Element utilities - Stable IDs and element identification
|
|
3
|
+
*/
|
|
4
|
+
export declare const STABLE_ID_ATTR = "data-sdesign-id";
|
|
5
|
+
export declare const VISIBILITY_ATTR = "vis";
|
|
6
|
+
export interface ElementIdentifier {
|
|
7
|
+
tagName: string;
|
|
8
|
+
classes: string[];
|
|
9
|
+
nthOfType: number;
|
|
10
|
+
attributeHints: Record<string, string>;
|
|
11
|
+
id?: string;
|
|
12
|
+
textContentPreview?: string;
|
|
13
|
+
parentIdentifier?: ElementIdentifier;
|
|
14
|
+
}
|
|
15
|
+
export interface PlacementTarget {
|
|
16
|
+
parent: ElementIdentifier;
|
|
17
|
+
parentStableId: string;
|
|
18
|
+
position: 'prepend' | 'append' | 'after';
|
|
19
|
+
referenceElement?: ElementIdentifier;
|
|
20
|
+
referenceStableId?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface SerializedRect {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
top: number;
|
|
28
|
+
right: number;
|
|
29
|
+
bottom: number;
|
|
30
|
+
left: number;
|
|
31
|
+
}
|
|
32
|
+
export declare function getVisibilityBoundary(element: HTMLElement): HTMLElement | null;
|
|
33
|
+
export declare function canDropInZone(sourceElement: HTMLElement, targetElement: HTMLElement): boolean;
|
|
34
|
+
export declare function getStableId(element: HTMLElement): string;
|
|
35
|
+
export declare function findByStableId(id: string, root?: HTMLElement): HTMLElement | null;
|
|
36
|
+
export declare function getDomPath(element: HTMLElement, root: HTMLElement): number[];
|
|
37
|
+
export declare function getElementAtPath(path: number[], root: HTMLElement): HTMLElement | null;
|
|
38
|
+
export declare function getRelevantStyles(el: HTMLElement): Record<string, string>;
|
|
39
|
+
export declare function serializeRect(rect: DOMRect): SerializedRect;
|
|
40
|
+
export declare function buildElementIdentifier(element: HTMLElement, maxDepth?: number): ElementIdentifier;
|
|
41
|
+
export declare function buildPlacementTarget(element: HTMLElement): PlacementTarget | null;
|
|
42
|
+
export declare function getVisibleContent(): string[];
|
|
43
|
+
//# sourceMappingURL=element-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-utils.d.ts","sourceRoot":"","sources":["../../src/builder/element-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAChD,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;CACtC;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;IACzC,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IACrC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC7B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,IAAI,CAa9E;AAED,wBAAgB,aAAa,CAAC,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,G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