@base44-preview/vite-plugin 0.2.21-pr.35.60ab963 → 0.2.22-pr.36.69a0b76

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.
Files changed (37) hide show
  1. package/dist/injections/layer-dropdown/consts.d.ts +15 -0
  2. package/dist/injections/layer-dropdown/consts.d.ts.map +1 -0
  3. package/dist/injections/layer-dropdown/consts.js +36 -0
  4. package/dist/injections/layer-dropdown/consts.js.map +1 -0
  5. package/dist/injections/layer-dropdown/controller.d.ts +4 -0
  6. package/dist/injections/layer-dropdown/controller.d.ts.map +1 -0
  7. package/dist/injections/layer-dropdown/controller.js +85 -0
  8. package/dist/injections/layer-dropdown/controller.js.map +1 -0
  9. package/dist/injections/layer-dropdown/dropdown-ui.d.ts +13 -0
  10. package/dist/injections/layer-dropdown/dropdown-ui.d.ts.map +1 -0
  11. package/dist/injections/layer-dropdown/dropdown-ui.js +158 -0
  12. package/dist/injections/layer-dropdown/dropdown-ui.js.map +1 -0
  13. package/dist/injections/layer-dropdown/types.d.ts +21 -0
  14. package/dist/injections/layer-dropdown/types.d.ts.map +1 -0
  15. package/dist/injections/layer-dropdown/types.js +3 -0
  16. package/dist/injections/layer-dropdown/types.js.map +1 -0
  17. package/dist/injections/layer-dropdown/utils.d.ts +23 -0
  18. package/dist/injections/layer-dropdown/utils.d.ts.map +1 -0
  19. package/dist/injections/layer-dropdown/utils.js +113 -0
  20. package/dist/injections/layer-dropdown/utils.js.map +1 -0
  21. package/dist/injections/utils.d.ts +6 -0
  22. package/dist/injections/utils.d.ts.map +1 -1
  23. package/dist/injections/utils.js +25 -0
  24. package/dist/injections/utils.js.map +1 -1
  25. package/dist/injections/visual-edit-agent.d.ts.map +1 -1
  26. package/dist/injections/visual-edit-agent.js +79 -64
  27. package/dist/injections/visual-edit-agent.js.map +1 -1
  28. package/dist/statics/index.mjs +1 -1
  29. package/dist/statics/index.mjs.map +1 -1
  30. package/package.json +1 -1
  31. package/src/injections/layer-dropdown/consts.ts +44 -0
  32. package/src/injections/layer-dropdown/controller.ts +105 -0
  33. package/src/injections/layer-dropdown/dropdown-ui.ts +221 -0
  34. package/src/injections/layer-dropdown/types.ts +24 -0
  35. package/src/injections/layer-dropdown/utils.ts +138 -0
  36. package/src/injections/utils.ts +34 -0
  37. package/src/injections/visual-edit-agent.ts +88 -74
@@ -0,0 +1,15 @@
1
+ /** Style constants for the layer dropdown UI */
2
+ export declare const DROPDOWN_CONTAINER_STYLES: Record<string, string>;
3
+ export declare const DROPDOWN_ITEM_BASE_STYLES: Record<string, string>;
4
+ export declare const DROPDOWN_ITEM_ACTIVE_COLOR = "#526cff";
5
+ export declare const DROPDOWN_ITEM_ACTIVE_BG = "#DBEAFE";
6
+ export declare const DROPDOWN_ITEM_ACTIVE_FONT_WEIGHT = "600";
7
+ export declare const DROPDOWN_ITEM_HOVER_BG = "#f1f5f9";
8
+ export declare const DEPTH_INDENT_PX = 10;
9
+ export declare const LABEL_CHEVRON = " \u25BE";
10
+ export declare const LAYER_DROPDOWN_ATTR = "data-layer-dropdown";
11
+ /** Max instrumented ancestors to show above the selected element */
12
+ export declare const MAX_PARENT_DEPTH = 2;
13
+ /** Max instrumented depth levels to show below the selected element */
14
+ export declare const MAX_CHILD_DEPTH = 2;
15
+ //# sourceMappingURL=consts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/injections/layer-dropdown/consts.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAEhD,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAa5D,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAQ5D,CAAC;AAEF,eAAO,MAAM,0BAA0B,YAAY,CAAC;AACpD,eAAO,MAAM,uBAAuB,YAAY,CAAC;AACjD,eAAO,MAAM,gCAAgC,QAAQ,CAAC;AAEtD,eAAO,MAAM,sBAAsB,YAAY,CAAC;AAEhD,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC,eAAO,MAAM,aAAa,YAAY,CAAC;AAEvC,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD,oEAAoE;AACpE,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,uEAAuE;AACvE,eAAO,MAAM,eAAe,IAAI,CAAC"}
@@ -0,0 +1,36 @@
1
+ /** Style constants for the layer dropdown UI */
2
+ export const DROPDOWN_CONTAINER_STYLES = {
3
+ position: "absolute",
4
+ backgroundColor: "#ffffff",
5
+ border: "1px solid #e2e8f0",
6
+ borderRadius: "6px",
7
+ boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
8
+ fontSize: "12px",
9
+ minWidth: "120px",
10
+ maxHeight: "200px",
11
+ overflowY: "auto",
12
+ zIndex: "10001",
13
+ padding: "4px 0",
14
+ pointerEvents: "auto",
15
+ };
16
+ export const DROPDOWN_ITEM_BASE_STYLES = {
17
+ padding: "4px 12px",
18
+ cursor: "pointer",
19
+ color: "#334155",
20
+ backgroundColor: "transparent",
21
+ whiteSpace: "nowrap",
22
+ lineHeight: "1.5",
23
+ fontWeight: "400",
24
+ };
25
+ export const DROPDOWN_ITEM_ACTIVE_COLOR = "#526cff";
26
+ export const DROPDOWN_ITEM_ACTIVE_BG = "#DBEAFE";
27
+ export const DROPDOWN_ITEM_ACTIVE_FONT_WEIGHT = "600";
28
+ export const DROPDOWN_ITEM_HOVER_BG = "#f1f5f9";
29
+ export const DEPTH_INDENT_PX = 10;
30
+ export const LABEL_CHEVRON = " \u25BE";
31
+ export const LAYER_DROPDOWN_ATTR = "data-layer-dropdown";
32
+ /** Max instrumented ancestors to show above the selected element */
33
+ export const MAX_PARENT_DEPTH = 2;
34
+ /** Max instrumented depth levels to show below the selected element */
35
+ export const MAX_CHILD_DEPTH = 2;
36
+ //# sourceMappingURL=consts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../../../src/injections/layer-dropdown/consts.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAEhD,MAAM,CAAC,MAAM,yBAAyB,GAA2B;IAC/D,QAAQ,EAAE,UAAU;IACpB,eAAe,EAAE,SAAS;IAC1B,MAAM,EAAE,mBAAmB;IAC3B,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE,gCAAgC;IAC3C,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,OAAO;IACjB,SAAS,EAAE,OAAO;IAClB,SAAS,EAAE,MAAM;IACjB,MAAM,EAAE,OAAO;IACf,OAAO,EAAE,OAAO;IAChB,aAAa,EAAE,MAAM;CACtB,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAA2B;IAC/D,OAAO,EAAE,UAAU;IACnB,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,SAAS;IAChB,eAAe,EAAE,aAAa;IAC9B,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,KAAK;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,SAAS,CAAC;AACpD,MAAM,CAAC,MAAM,uBAAuB,GAAG,SAAS,CAAC;AACjD,MAAM,CAAC,MAAM,gCAAgC,GAAG,KAAK,CAAC;AAEtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAEhD,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAElC,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AAEvC,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAEzD,oEAAoE;AACpE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,uEAAuE;AACvE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ /** Controller that encapsulates layer-dropdown integration logic */
2
+ import type { LayerControllerDeps, LayerController } from "./types.js";
3
+ export declare function createLayerController(deps: LayerControllerDeps): LayerController;
4
+ //# sourceMappingURL=controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/injections/layer-dropdown/controller.ts"],"names":[],"mappings":"AAAA,oEAAoE;AAUpE,OAAO,KAAK,EAAa,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElF,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,mBAAmB,GAAG,eAAe,CA4FhF"}
@@ -0,0 +1,85 @@
1
+ /** Controller that encapsulates layer-dropdown integration logic */
2
+ import { getElementSelectorId } from "../utils.js";
3
+ import { buildLayerChain } from "./utils.js";
4
+ import { enhanceLabelWithChevron, showDropdown, closeDropdown, isDropdownOpen, } from "./dropdown-ui.js";
5
+ export function createLayerController(deps) {
6
+ let layerPreviewOverlay = null;
7
+ let escapeHandler = null;
8
+ let dropdownSourceElement = null;
9
+ const clearLayerPreview = () => {
10
+ if (layerPreviewOverlay && layerPreviewOverlay.parentNode) {
11
+ layerPreviewOverlay.remove();
12
+ }
13
+ layerPreviewOverlay = null;
14
+ };
15
+ const showLayerPreview = (layer) => {
16
+ clearLayerPreview();
17
+ if (getElementSelectorId(layer.element) === deps.getSelectedElementId())
18
+ return;
19
+ layerPreviewOverlay = deps.createPreviewOverlay(layer.element);
20
+ };
21
+ const selectElementFromLayer = (layer) => {
22
+ clearLayerPreview();
23
+ closeDropdown();
24
+ if (escapeHandler) {
25
+ document.removeEventListener("keydown", escapeHandler, true);
26
+ escapeHandler = null;
27
+ }
28
+ dropdownSourceElement = null;
29
+ const firstOverlay = deps.selectElement(layer.element);
30
+ attachToOverlay(firstOverlay, layer.element);
31
+ };
32
+ const reselectDropdownSource = () => {
33
+ if (escapeHandler) {
34
+ document.removeEventListener("keydown", escapeHandler, true);
35
+ escapeHandler = null;
36
+ }
37
+ if (dropdownSourceElement) {
38
+ selectElementFromLayer({
39
+ element: dropdownSourceElement,
40
+ tagName: dropdownSourceElement.tagName.toLowerCase(),
41
+ selectorId: getElementSelectorId(dropdownSourceElement),
42
+ });
43
+ dropdownSourceElement = null;
44
+ }
45
+ };
46
+ const attachToOverlay = (overlay, element) => {
47
+ if (!overlay)
48
+ return;
49
+ const label = overlay.querySelector("div");
50
+ if (!label)
51
+ return;
52
+ const layers = buildLayerChain(element);
53
+ if (layers.length <= 1)
54
+ return;
55
+ const currentId = getElementSelectorId(element);
56
+ enhanceLabelWithChevron(label);
57
+ label.addEventListener("click", (e) => {
58
+ e.stopPropagation();
59
+ e.preventDefault();
60
+ if (isDropdownOpen()) {
61
+ closeDropdown();
62
+ reselectDropdownSource();
63
+ }
64
+ else {
65
+ dropdownSourceElement = element;
66
+ deps.onDeselect();
67
+ escapeHandler = (ev) => {
68
+ if (ev.key === "Escape") {
69
+ ev.stopPropagation();
70
+ closeDropdown();
71
+ reselectDropdownSource();
72
+ }
73
+ };
74
+ document.addEventListener("keydown", escapeHandler, true);
75
+ showDropdown(label, layers, currentId, selectElementFromLayer, showLayerPreview, clearLayerPreview);
76
+ }
77
+ });
78
+ };
79
+ const cleanup = () => {
80
+ clearLayerPreview();
81
+ closeDropdown();
82
+ };
83
+ return { attachToOverlay, cleanup };
84
+ }
85
+ //# sourceMappingURL=controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/injections/layer-dropdown/controller.ts"],"names":[],"mappings":"AAAA,oEAAoE;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EACL,uBAAuB,EACvB,YAAY,EACZ,aAAa,EACb,cAAc,GACf,MAAM,kBAAkB,CAAC;AAG1B,MAAM,UAAU,qBAAqB,CAAC,IAAyB;IAC7D,IAAI,mBAAmB,GAA0B,IAAI,CAAC;IACtD,IAAI,aAAa,GAAwC,IAAI,CAAC;IAC9D,IAAI,qBAAqB,GAAmB,IAAI,CA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sBAAsB,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;YACtG,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,iBAAiB,EAAE,CAAC;QACpB,aAAa,EAAE,CAAC;IAClB,CAAC,CAAC;IAEF,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC;AACtC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /** Dropdown UI component for layer navigation */
2
+ import type { LayerInfo, OnLayerSelect, OnLayerHover, OnLayerHoverEnd } from "./types.js";
3
+ /** Create the dropdown DOM element with layer items */
4
+ export declare function createDropdownElement(layers: LayerInfo[], currentSelectorId: string | null, onSelect: OnLayerSelect, onHover?: OnLayerHover, onHoverEnd?: OnLayerHoverEnd): HTMLDivElement;
5
+ /** Add chevron indicator and pointer-events to the label */
6
+ export declare function enhanceLabelWithChevron(label: HTMLDivElement): void;
7
+ /** Show the dropdown below the label element */
8
+ export declare function showDropdown(label: HTMLDivElement, layers: LayerInfo[], currentSelectorId: string | null, onSelect: OnLayerSelect, onHover?: OnLayerHover, onHoverEnd?: OnLayerHoverEnd): void;
9
+ /** Close the active dropdown and clean up listeners */
10
+ export declare function closeDropdown(): void;
11
+ /** Check if a dropdown is currently visible */
12
+ export declare function isDropdownOpen(): boolean;
13
+ //# sourceMappingURL=dropdown-ui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropdown-ui.d.ts","sourceRoot":"","sources":["../../../src/injections/layer-dropdown/dropdown-ui.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAcjD,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAgD1F,uDAAuD;AACvD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EAAE,EACnB,iBAAiB,EAAE,MAAM,GAAG,IAAI,EAChC,QAAQ,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,YAAY,EACtB,UAAU,CAAC,EAAE,eAAe,GAC3B,cAAc,CAWhB;AAED,4DAA4D;AAC5D,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAQnE;AAkED,gDAAgD;AAChD,wBAAgB,YAAY,CAC1B,KAAK,EAAE,cAAc,EACrB,MAAM,EAAE,SAAS,EAAE,EACnB,iBAAiB,EAAE,MAAM,GAAG,IAAI,EAChC,QAAQ,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,YAAY,EACtB,UAAU,CAAC,EAAE,eAAe,GAC3B,IAAI,CA2BN;AAED,uDAAuD;AACvD,wBAAgB,aAAa,IAAI,IAAI,CAoBpC;AAED,+CAA+C;AAC/C,wBAAgB,cAAc,IAAI,OAAO,CAExC"}
@@ -0,0 +1,158 @@
1
+ /** Dropdown UI component for layer navigation */
2
+ import { DROPDOWN_CONTAINER_STYLES, DROPDOWN_ITEM_BASE_STYLES, DROPDOWN_ITEM_ACTIVE_COLOR, DROPDOWN_ITEM_ACTIVE_BG, DROPDOWN_ITEM_ACTIVE_FONT_WEIGHT, DROPDOWN_ITEM_HOVER_BG, DEPTH_INDENT_PX, LABEL_CHEVRON, LAYER_DROPDOWN_ATTR, } from "./consts.js";
3
+ import { applyStyles, getLayerDisplayName } from "./utils.js";
4
+ let activeDropdown = null;
5
+ let outsideMousedownHandler = null;
6
+ let activeOnHoverEnd = null;
7
+ let activeKeydownHandler = null;
8
+ function createDropdownItem(layer, isActive, onSelect, onHover, onHoverEnd) {
9
+ const item = document.createElement("div");
10
+ item.textContent = getLayerDisplayName(layer);
11
+ applyStyles(item, DROPDOWN_ITEM_BASE_STYLES);
12
+ const depth = layer.depth ?? 0;
13
+ if (depth > 0) {
14
+ item.style.paddingLeft = `${12 + depth * DEPTH_INDENT_PX}px`;
15
+ }
16
+ if (isActive) {
17
+ item.style.color = DROPDOWN_ITEM_ACTIVE_COLOR;
18
+ item.style.backgroundColor = DROPDOWN_ITEM_ACTIVE_BG;
19
+ item.style.fontWeight = DROPDOWN_ITEM_ACTIVE_FONT_WEIGHT;
20
+ }
21
+ item.addEventListener("mouseenter", () => {
22
+ if (!isActive)
23
+ item.style.backgroundColor = DROPDOWN_ITEM_HOVER_BG;
24
+ if (onHover)
25
+ onHover(layer);
26
+ });
27
+ item.addEventListener("mouseleave", () => {
28
+ if (!isActive)
29
+ item.style.backgroundColor = "transparent";
30
+ if (onHoverEnd)
31
+ onHoverEnd();
32
+ });
33
+ item.addEventListener("click", (e) => {
34
+ e.stopPropagation();
35
+ e.preventDefault();
36
+ onSelect(layer);
37
+ });
38
+ return item;
39
+ }
40
+ /** Create the dropdown DOM element with layer items */
41
+ export function createDropdownElement(layers, currentSelectorId, onSelect, onHover, onHoverEnd) {
42
+ const container = document.createElement("div");
43
+ container.setAttribute(LAYER_DROPDOWN_ATTR, "true");
44
+ applyStyles(container, DROPDOWN_CONTAINER_STYLES);
45
+ layers.forEach((layer) => {
46
+ const isActive = layer.selectorId === currentSelectorId;
47
+ container.appendChild(createDropdownItem(layer, isActive, onSelect, onHover, onHoverEnd));
48
+ });
49
+ return container;
50
+ }
51
+ /** Add chevron indicator and pointer-events to the label */
52
+ export function enhanceLabelWithChevron(label) {
53
+ if (label.textContent?.includes(LABEL_CHEVRON))
54
+ return;
55
+ label.textContent = label.textContent + LABEL_CHEVRON;
56
+ label.style.cursor = "pointer";
57
+ label.style.userSelect = "none";
58
+ label.style.pointerEvents = "auto";
59
+ label.setAttribute(LAYER_DROPDOWN_ATTR, "true");
60
+ }
61
+ function setupKeyboardNavigation(dropdown, layers, currentSelectorId, onSelect, onHover, onHoverEnd) {
62
+ const items = Array.from(dropdown.children);
63
+ let focusedIndex = layers.findIndex((l) => l.selectorId === currentSelectorId);
64
+ const setFocusedItem = (index) => {
65
+ if (focusedIndex >= 0 && focusedIndex < items.length) {
66
+ const prev = items[focusedIndex];
67
+ if (prev.style.color !== DROPDOWN_ITEM_ACTIVE_COLOR) {
68
+ prev.style.backgroundColor = "transparent";
69
+ }
70
+ }
71
+ focusedIndex = index;
72
+ if (focusedIndex >= 0 && focusedIndex < items.length) {
73
+ const cur = items[focusedIndex];
74
+ if (cur.style.color !== DROPDOWN_ITEM_ACTIVE_COLOR) {
75
+ cur.style.backgroundColor = DROPDOWN_ITEM_HOVER_BG;
76
+ }
77
+ cur.scrollIntoView({ block: "nearest" });
78
+ if (onHover)
79
+ onHover(layers[focusedIndex]);
80
+ }
81
+ };
82
+ activeKeydownHandler = (e) => {
83
+ if (e.key === "ArrowDown") {
84
+ e.preventDefault();
85
+ e.stopPropagation();
86
+ setFocusedItem(focusedIndex < items.length - 1 ? focusedIndex + 1 : 0);
87
+ }
88
+ else if (e.key === "ArrowUp") {
89
+ e.preventDefault();
90
+ e.stopPropagation();
91
+ setFocusedItem(focusedIndex > 0 ? focusedIndex - 1 : items.length - 1);
92
+ }
93
+ else if (e.key === "Enter" && focusedIndex >= 0) {
94
+ e.preventDefault();
95
+ e.stopPropagation();
96
+ if (onHoverEnd)
97
+ onHoverEnd();
98
+ onSelect(layers[focusedIndex]);
99
+ closeDropdown();
100
+ }
101
+ };
102
+ document.addEventListener("keydown", activeKeydownHandler, true);
103
+ }
104
+ function setupOutsideClickHandler(dropdown, label) {
105
+ setTimeout(() => {
106
+ outsideMousedownHandler = (e) => {
107
+ const target = e.target;
108
+ if (!dropdown.contains(target) && target !== label) {
109
+ closeDropdown();
110
+ }
111
+ };
112
+ document.addEventListener("mousedown", outsideMousedownHandler, true);
113
+ }, 0);
114
+ }
115
+ /** Show the dropdown below the label element */
116
+ export function showDropdown(label, layers, currentSelectorId, onSelect, onHover, onHoverEnd) {
117
+ closeDropdown();
118
+ const dropdown = createDropdownElement(layers, currentSelectorId, (layer) => {
119
+ if (onHoverEnd)
120
+ onHoverEnd();
121
+ onSelect(layer);
122
+ closeDropdown();
123
+ }, onHover, onHoverEnd);
124
+ const overlay = label.parentElement;
125
+ if (!overlay)
126
+ return;
127
+ dropdown.style.top = `${label.offsetTop + label.offsetHeight + 2}px`;
128
+ dropdown.style.left = `${label.offsetLeft}px`;
129
+ overlay.appendChild(dropdown);
130
+ activeDropdown = dropdown;
131
+ activeOnHoverEnd = onHoverEnd ?? null;
132
+ setupKeyboardNavigation(dropdown, layers, currentSelectorId, onSelect, onHover, onHoverEnd);
133
+ setupOutsideClickHandler(dropdown, label);
134
+ }
135
+ /** Close the active dropdown and clean up listeners */
136
+ export function closeDropdown() {
137
+ if (activeOnHoverEnd) {
138
+ activeOnHoverEnd();
139
+ activeOnHoverEnd = null;
140
+ }
141
+ if (activeDropdown && activeDropdown.parentNode) {
142
+ activeDropdown.remove();
143
+ }
144
+ activeDropdown = null;
145
+ if (outsideMousedownHandler) {
146
+ document.removeEventListener("mousedown", outsideMousedownHandler, true);
147
+ outsideMousedownHandler = null;
148
+ }
149
+ if (activeKeydownHandler) {
150
+ document.removeEventListener("keydown", activeKeydownHandler, true);
151
+ activeKeydownHandler = null;
152
+ }
153
+ }
154
+ /** Check if a dropdown is currently visible */
155
+ export function isDropdownOpen() {
156
+ return activeDropdown !== null;
157
+ }
158
+ //# sourceMappingURL=dropdown-ui.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropdown-ui.js","sourceRoot":"","sources":["../../../src/injections/layer-dropdown/dropdown-ui.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,0BAA0B,EAC1B,uBAAuB,EACvB,gCAAgC,EAChC,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAG9D,IAAI,cAAc,GAA0B,IAAI,CAAC;AACjD,IAAI,uBAAuB,GAAqC,IAAI,CAAC;AACrE,IAAI,gBAAgB,GAA2B,IAAI,CAAC;AACpD,IAAI,oBAAoB,GAAwC,IAAI,CAAC;AAErE,SAAS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AC;QAC5B,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,uBAAuB,EAAE,IAAI,CAAC,CAAC;QACzE,uBAAuB,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,IAAI,oBAAoB,EAAE,CAAC;QACzB,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,oBAAoB,EAAE,IAAI,CAAC,CAAC;QACpE,oBAAoB,GAAG,IAAI,CAAC;IAC9B,CAAC;AACH,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,cAAc;IAC5B,OAAO,cAAc,KAAK,IAAI,CAAC;AACjC,CAAC"}
@@ -0,0 +1,21 @@
1
+ /** Shared types for the layer-dropdown module */
2
+ export interface LayerInfo {
3
+ element: Element;
4
+ tagName: string;
5
+ selectorId: string | null;
6
+ depth?: number;
7
+ }
8
+ export type OnLayerSelect = (layer: LayerInfo) => void;
9
+ export type OnLayerHover = (layer: LayerInfo) => void;
10
+ export type OnLayerHoverEnd = () => void;
11
+ export interface LayerControllerDeps {
12
+ createPreviewOverlay: (element: Element) => HTMLDivElement;
13
+ getSelectedElementId: () => string | null;
14
+ selectElement: (element: Element) => HTMLDivElement | undefined;
15
+ onDeselect: () => void;
16
+ }
17
+ export interface LayerController {
18
+ attachToOverlay: (overlay: HTMLDivElement | undefined, element: Element) => void;
19
+ cleanup: () => void;
20
+ }
21
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/injections/layer-dropdown/types.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;AACvD,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;AACtD,MAAM,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC;AAEzC,MAAM,WAAW,mBAAmB;IAClC,oBAAoB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,cAAc,CAAC;IAC3D,oBAAoB,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAC1C,aAAa,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,cAAc,GAAG,SAAS,CAAC;IAChE,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACjF,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB"}
@@ -0,0 +1,3 @@
1
+ /** Shared types for the layer-dropdown module */
2
+ export {};
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/injections/layer-dropdown/types.ts"],"names":[],"mappings":"AAAA,iDAAiD"}
@@ -0,0 +1,23 @@
1
+ /** DOM utilities for the layer-dropdown module */
2
+ import type { LayerInfo } from "./types.js";
3
+ /** Apply a style map to an element */
4
+ export declare function applyStyles(element: HTMLElement, styles: Record<string, string>): void;
5
+ /** Display name for a layer — just the real tag name */
6
+ export declare function getLayerDisplayName(layer: LayerInfo): string;
7
+ /**
8
+ * Collect instrumented descendants up to `maxDepth` instrumented nesting levels.
9
+ * Non-instrumented wrappers are walked through without counting toward depth.
10
+ * Results are in DOM order.
11
+ */
12
+ export declare function getInstrumentedDescendants(parent: Element, maxDepth: number): LayerInfo[];
13
+ /**
14
+ * Build the layer chain for the dropdown:
15
+ *
16
+ * Parents – up to MAX_PARENT_DEPTH instrumented ancestors, outer → inner.
17
+ * Current – the selected element.
18
+ * Children – instrumented descendants within MAX_CHILD_DEPTH levels, DOM order.
19
+ *
20
+ * Each item carries a `depth` for visual indentation.
21
+ */
22
+ export declare function buildLayerChain(selectedElement: Element): LayerInfo[];
23
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/injections/layer-dropdown/utils.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAKlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,sCAAsC;AACtC,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAEtF;AAED,wDAAwD;AACxD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,MAAM,GACf,SAAS,EAAE,CAsBb;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,eAAe,EAAE,OAAO,GAAG,SAAS,EAAE,CAkDrE"}
@@ -0,0 +1,113 @@
1
+ /** DOM utilities for the layer-dropdown module */
2
+ import { isInstrumentedElement, getElementSelectorId } from "../utils.js";
3
+ import { MAX_PARENT_DEPTH, MAX_CHILD_DEPTH } from "./consts.js";
4
+ /** Apply a style map to an element */
5
+ export function applyStyles(element, styles) {
6
+ Object.assign(element.style, styles);
7
+ }
8
+ /** Display name for a layer — just the real tag name */
9
+ export function getLayerDisplayName(layer) {
10
+ return layer.tagName;
11
+ }
12
+ /**
13
+ * Collect instrumented descendants up to `maxDepth` instrumented nesting levels.
14
+ * Non-instrumented wrappers are walked through without counting toward depth.
15
+ * Results are in DOM order.
16
+ */
17
+ export function getInstrumentedDescendants(parent, maxDepth) {
18
+ const result = [];
19
+ function walk(el, instrDepth) {
20
+ if (instrDepth > maxDepth)
21
+ return;
22
+ for (let i = 0; i < el.children.length; i++) {
23
+ const child = el.children[i];
24
+ if (isInstrumentedElement(child)) {
25
+ result.push({
26
+ element: child,
27
+ tagName: child.tagName.toLowerCase(),
28
+ selectorId: getElementSelectorId(child),
29
+ });
30
+ walk(child, instrDepth + 1);
31
+ }
32
+ else {
33
+ walk(child, instrDepth);
34
+ }
35
+ }
36
+ }
37
+ walk(parent, 1);
38
+ return result;
39
+ }
40
+ /**
41
+ * Build the layer chain for the dropdown:
42
+ *
43
+ * Parents – up to MAX_PARENT_DEPTH instrumented ancestors, outer → inner.
44
+ * Current – the selected element.
45
+ * Children – instrumented descendants within MAX_CHILD_DEPTH levels, DOM order.
46
+ *
47
+ * Each item carries a `depth` for visual indentation.
48
+ */
49
+ export function buildLayerChain(selectedElement) {
50
+ // --- Parents (walk up, collect at most MAX_PARENT_DEPTH) ---
51
+ const parents = [];
52
+ let current = selectedElement.parentElement;
53
+ while (current &&
54
+ current !== document.documentElement &&
55
+ current !== document.body &&
56
+ parents.length < MAX_PARENT_DEPTH) {
57
+ if (isInstrumentedElement(current)) {
58
+ parents.push({
59
+ element: current,
60
+ tagName: current.tagName.toLowerCase(),
61
+ selectorId: getElementSelectorId(current),
62
+ });
63
+ }
64
+ current = current.parentElement;
65
+ }
66
+ // Reverse so outermost parent comes first
67
+ parents.reverse();
68
+ // --- Build the chain with depth ---
69
+ const chain = [];
70
+ const baseDepth = 0;
71
+ // Parents: depth 0, 1, …
72
+ parents.forEach((p, i) => {
73
+ chain.push({ ...p, depth: baseDepth + i });
74
+ });
75
+ // Self
76
+ const selfDepth = parents.length;
77
+ chain.push({
78
+ element: selectedElement,
79
+ tagName: selectedElement.tagName.toLowerCase(),
80
+ selectorId: getElementSelectorId(selectedElement),
81
+ depth: selfDepth,
82
+ });
83
+ // Children: up to MAX_CHILD_DEPTH instrumented levels below selected
84
+ const descendants = getInstrumentedDescendants(selectedElement, MAX_CHILD_DEPTH);
85
+ // Assign visual depth: we need to track the instrumented nesting to set depth correctly
86
+ assignDescendantDepths(selectedElement, descendants, selfDepth + 1);
87
+ chain.push(...descendants);
88
+ return chain;
89
+ }
90
+ /**
91
+ * Walk the DOM tree again to assign correct visual depth to each descendant.
92
+ * This avoids storing depth during collection and keeps the API simple.
93
+ */
94
+ function assignDescendantDepths(root, descendants, startDepth) {
95
+ // Build a set for O(1) lookup
96
+ const descSet = new Set(descendants.map((d) => d.element));
97
+ // Map element → LayerInfo for mutation
98
+ const descMap = new Map(descendants.map((d) => [d.element, d]));
99
+ function walk(el, instrDepth) {
100
+ for (let i = 0; i < el.children.length; i++) {
101
+ const child = el.children[i];
102
+ if (descSet.has(child)) {
103
+ descMap.get(child).depth = startDepth + instrDepth - 1;
104
+ walk(child, instrDepth + 1);
105
+ }
106
+ else {
107
+ walk(child, instrDepth);
108
+ }
109
+ }
110
+ }
111
+ walk(root, 1);
112
+ }
113
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/injections/layer-dropdown/utils.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAElD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAIhE,sCAAsC;AACtC,MAAM,UAAU,WAAW,CAAC,OAAoB,EAAE,MAA8B;IAC9E,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACvC,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,mBAAmB,CAAC,KAAgB;IAClD,OAAO,KAAK,CAAC,OAAO,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,MAAe,EACf,QAAgB;IAEhB,MAAM,MAAM,GAAgB,EAAE,CAAC;IAE/B,SAAS,IAAI,CAAC,EAAW,EAAE,UAAkB;QAC3C,IAAI,UAAU,GAAG,QAAQ;YAAE,OAAO;QAClC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EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhE,SAAS,IAAI,CAAC,EAAW,EAAE,UAAkB;QAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5C,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAE,CAAC;YAC9B,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,CAAC,CAAC;gBACxD,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC;YAC9B,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAChB,CAAC"}
@@ -1,3 +1,9 @@
1
+ /** Check if an element has instrumentation attributes */
2
+ export declare function isInstrumentedElement(element: Element): boolean;
3
+ /** Get the selector ID from an element's data attributes (prefers source-location) */
4
+ export declare function getElementSelectorId(element: Element): string | null;
5
+ /** Find the nearest instrumented ancestor (not the element itself) */
6
+ export declare function getImmediateInstrumentedParent(element: Element): Element | null;
1
7
  /** Find elements by ID - first try data-source-location, fallback to data-visual-selector-id */
2
8
  export declare function findElementsById(id: string | null): Element[];
3
9
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/injections/utils.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,EAAE,CAW7D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAI/E"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/injections/utils.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAK/D;AAED,sFAAsF;AACtF,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAOpE;AAED,sEAAsE;AACtE,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAa/E;AAED,gGAAgG;AAChG,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,EAAE,CAW7D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAI/E"}
@@ -1,3 +1,28 @@
1
+ /** Check if an element has instrumentation attributes */
2
+ export function isInstrumentedElement(element) {
3
+ const htmlEl = element;
4
+ return !!(htmlEl.dataset?.sourceLocation || htmlEl.dataset?.visualSelectorId);
5
+ }
6
+ /** Get the selector ID from an element's data attributes (prefers source-location) */
7
+ export function getElementSelectorId(element) {
8
+ const htmlEl = element;
9
+ return (htmlEl.dataset?.sourceLocation ||
10
+ htmlEl.dataset?.visualSelectorId ||
11
+ null);
12
+ }
13
+ /** Find the nearest instrumented ancestor (not the element itself) */
14
+ export function getImmediateInstrumentedParent(element) {
15
+ let current = element.parentElement;
16
+ while (current &&
17
+ current !== document.documentElement &&
18
+ current !== document.body) {
19
+ if (isInstrumentedElement(current)) {
20
+ return current;
21
+ }
22
+ current = current.parentElement;
23
+ }
24
+ return null;
25
+ }
1
26
  /** Find elements by ID - first try data-source-location, fallback to data-visual-selector-id */
2
27
  export function findElementsById(id) {
3
28
  if (!id)
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/injections/ut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OAAO,CAAC,aAAa,CAAC;IACpC,OACE,OAAO;QACP,OAAO,KAAK,QAAQ,CAAC,eAAe;QACpC,OAAO,KAAK,QAAQ,CAAC,IAAI,EACzB,CAAC;QACD,IAAI,qBAAqB,CAAC,OAAO,CAAC,EAAE,CAAC;YACnC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;IAClC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,gBAAgB,CAAC,EAAiB;IAChD,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,CAAC;IACnB,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAC/B,QAAQ,CAAC,gBAAgB,CAAC,0BAA0B,EAAE,IAAI,CAAC,CAC5D,CAAC;IACF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CACf,QAAQ,CAAC,gBAAgB,CAAC,6BAA6B,EAAE,IAAI,CAAC,CAC/D,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAmB,EAAE,OAAe;IACvE,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"visual-edit-agent.d.ts","sourceRoot":"","sources":["../../src/injections/visual-edit-agent.ts"],"names":[],"mappings":"AAEA,wBAAgB,oBAAoB,SA8iBnC"}
1
+ {"version":3,"file":"visual-edit-agent.d.ts","sourceRoot":"","sources":["../../src/injections/visual-edit-agent.ts"],"names":[],"mappings":"AAIA,wBAAgB,oBAAoB,SA0jBnC"}