MCPcopy Create free account
hub / github.com/altic-dev/Pilot / ReactComponentPicker

Class ReactComponentPicker

public/picker/react-component-picker.js:11–446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9 'use strict';
10
11 class ReactComponentPicker {
12 constructor() {
13 this.isActive = false;
14 this.overlay = null;
15 this.tooltip = null;
16 this.currentElement = null;
17 this.boundMouseOver = this.handleMouseOver.bind(this);
18 this.boundClick = this.handleClick.bind(this);
19 this.boundKeyDown = this.handleKeyDown.bind(this);
20 }
21
22 /**
23 * Activate selection mode
24 */
25 activate() {
26 if (this.isActive) return;
27
28 this.isActive = true;
29 this.createOverlay();
30 this.createTooltip();
31
32 document.addEventListener('mouseover', this.boundMouseOver, true);
33 document.addEventListener('click', this.boundClick, true);
34 document.addEventListener('keydown', this.boundKeyDown, true);
35
36 document.body.style.cursor = 'crosshair';
37
38 console.log('[Pilot Picker] Selection mode activated');
39 }
40
41 /**
42 * Deactivate selection mode
43 */
44 deactivate() {
45 if (!this.isActive) return;
46
47 this.isActive = false;
48
49 if (this.overlay) {
50 this.overlay.remove();
51 this.overlay = null;
52 }
53
54 if (this.tooltip) {
55 this.tooltip.remove();
56 this.tooltip = null;
57 }
58
59 document.removeEventListener('mouseover', this.boundMouseOver, true);
60 document.removeEventListener('click', this.boundClick, true);
61 document.removeEventListener('keydown', this.boundKeyDown, true);
62
63 document.body.style.cursor = '';
64
65 console.log('[Pilot Picker] Selection mode deactivated');
66 }
67
68 /**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected