react-grab 0.0.44 → 0.0.46
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/index.cjs +347 -80
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.global.js +33 -25
- package/dist/index.js +350 -83
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -100,6 +100,8 @@ var SELECTION_LERP_FACTOR = 0.95;
|
|
|
100
100
|
var SUCCESS_LABEL_DURATION_MS = 1700;
|
|
101
101
|
var PROGRESS_INDICATOR_DELAY_MS = 150;
|
|
102
102
|
var DRAG_THRESHOLD_PX = 2;
|
|
103
|
+
var AUTO_SCROLL_EDGE_THRESHOLD_PX = 25;
|
|
104
|
+
var AUTO_SCROLL_SPEED_PX = 10;
|
|
103
105
|
var Z_INDEX_LABEL = 2147483647;
|
|
104
106
|
|
|
105
107
|
// src/utils/lerp.ts
|
|
@@ -582,6 +584,87 @@ var Crosshair = (props) => {
|
|
|
582
584
|
}
|
|
583
585
|
});
|
|
584
586
|
};
|
|
587
|
+
var _tmpl$10 = /* @__PURE__ */ web.template(`<div data-react-grab-input style="position:fixed;background-color:#fde7f7;color:#b21c8e;border:1px solid #f7c5ec;border-radius:4px;font-size:11px;font-weight:500;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;max-width:calc(100vw - (16px + env(safe-area-inset-left) + env(safe-area-inset-right)));overflow:hidden"><div style="position:relative;padding:2px 3px;display:flex;flex-direction:column;gap:2px"><textarea placeholder="e.g., Make this button larger"rows=1 style="width:240px;padding:2px 4px;background-color:#ffffff;color:#b21c8e;border:1px solid #f7c5ec;border-radius:3px;font-size:11px;line-height:1.2;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;outline:none;resize:vertical;min-height:18px"></textarea><div style=font-size:9px;opacity:0.6;text-align:center>Enter \u23CE to submit, Escape to cancel`);
|
|
588
|
+
var InputOverlay = (props) => {
|
|
589
|
+
let containerRef;
|
|
590
|
+
let inputRef;
|
|
591
|
+
const position = useAnimatedPosition({
|
|
592
|
+
x: () => props.x,
|
|
593
|
+
y: () => props.y,
|
|
594
|
+
lerpFactor: 0.3
|
|
595
|
+
});
|
|
596
|
+
const containerBoundingRect = () => containerRef?.getBoundingClientRect();
|
|
597
|
+
const computedPosition = () => {
|
|
598
|
+
const boundingRect = containerBoundingRect();
|
|
599
|
+
if (!boundingRect) return {
|
|
600
|
+
left: position.x(),
|
|
601
|
+
top: position.y()
|
|
602
|
+
};
|
|
603
|
+
const viewportWidth = window.innerWidth;
|
|
604
|
+
const viewportHeight = window.innerHeight;
|
|
605
|
+
const quadrants = getCursorQuadrants(position.x(), position.y(), boundingRect.width, boundingRect.height, CURSOR_OFFSET_PX);
|
|
606
|
+
for (const position2 of quadrants) {
|
|
607
|
+
const fitsHorizontally = position2.left >= VIEWPORT_MARGIN_PX && position2.left + boundingRect.width <= viewportWidth - VIEWPORT_MARGIN_PX;
|
|
608
|
+
const fitsVertically = position2.top >= VIEWPORT_MARGIN_PX && position2.top + boundingRect.height <= viewportHeight - VIEWPORT_MARGIN_PX;
|
|
609
|
+
if (fitsHorizontally && fitsVertically) {
|
|
610
|
+
return position2;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
const fallback = getClampedElementPosition(quadrants[0].left, quadrants[0].top, boundingRect.width, boundingRect.height);
|
|
614
|
+
fallback.left += INDICATOR_CLAMP_PADDING_PX;
|
|
615
|
+
fallback.top += INDICATOR_CLAMP_PADDING_PX;
|
|
616
|
+
return fallback;
|
|
617
|
+
};
|
|
618
|
+
const handleKeyDown = (event) => {
|
|
619
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
620
|
+
event.preventDefault();
|
|
621
|
+
event.stopPropagation();
|
|
622
|
+
props.onSubmit();
|
|
623
|
+
} else if (event.key === "Escape") {
|
|
624
|
+
event.preventDefault();
|
|
625
|
+
event.stopPropagation();
|
|
626
|
+
props.onCancel();
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
const handleInput = (event) => {
|
|
630
|
+
const target = event.target;
|
|
631
|
+
props.onInput(target.value);
|
|
632
|
+
};
|
|
633
|
+
solidJs.createEffect(() => {
|
|
634
|
+
if (props.visible && inputRef) {
|
|
635
|
+
inputRef.focus();
|
|
636
|
+
} else if (!props.visible && inputRef) {
|
|
637
|
+
inputRef.blur();
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
return (() => {
|
|
641
|
+
var _el$ = _tmpl$10(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild; _el$3.nextSibling;
|
|
642
|
+
var _ref$ = containerRef;
|
|
643
|
+
typeof _ref$ === "function" ? web.use(_ref$, _el$) : containerRef = _el$;
|
|
644
|
+
_el$3.$$keydown = handleKeyDown;
|
|
645
|
+
_el$3.$$input = handleInput;
|
|
646
|
+
var _ref$2 = inputRef;
|
|
647
|
+
typeof _ref$2 === "function" ? web.use(_ref$2, _el$3) : inputRef = _el$3;
|
|
648
|
+
web.effect((_p$) => {
|
|
649
|
+
var _v$ = props.visible ? "block" : "none", _v$2 = `${computedPosition().top}px`, _v$3 = `${computedPosition().left}px`, _v$4 = props.zIndex?.toString() ?? "2147483647", _v$5 = props.visible ? "auto" : "none";
|
|
650
|
+
_v$ !== _p$.e && web.setStyleProperty(_el$, "display", _p$.e = _v$);
|
|
651
|
+
_v$2 !== _p$.t && web.setStyleProperty(_el$, "top", _p$.t = _v$2);
|
|
652
|
+
_v$3 !== _p$.a && web.setStyleProperty(_el$, "left", _p$.a = _v$3);
|
|
653
|
+
_v$4 !== _p$.o && web.setStyleProperty(_el$, "z-index", _p$.o = _v$4);
|
|
654
|
+
_v$5 !== _p$.i && web.setStyleProperty(_el$, "pointer-events", _p$.i = _v$5);
|
|
655
|
+
return _p$;
|
|
656
|
+
}, {
|
|
657
|
+
e: void 0,
|
|
658
|
+
t: void 0,
|
|
659
|
+
a: void 0,
|
|
660
|
+
o: void 0,
|
|
661
|
+
i: void 0
|
|
662
|
+
});
|
|
663
|
+
web.effect(() => _el$3.value = props.value);
|
|
664
|
+
return _el$;
|
|
665
|
+
})();
|
|
666
|
+
};
|
|
667
|
+
web.delegateEvents(["input", "keydown"]);
|
|
585
668
|
|
|
586
669
|
// src/components/renderer.tsx
|
|
587
670
|
var ReactGrabRenderer = (props) => {
|
|
@@ -698,6 +781,31 @@ var ReactGrabRenderer = (props) => {
|
|
|
698
781
|
}
|
|
699
782
|
});
|
|
700
783
|
}
|
|
784
|
+
}), web.createComponent(InputOverlay, {
|
|
785
|
+
get x() {
|
|
786
|
+
return props.inputX ?? 0;
|
|
787
|
+
},
|
|
788
|
+
get y() {
|
|
789
|
+
return props.inputY ?? 0;
|
|
790
|
+
},
|
|
791
|
+
get zIndex() {
|
|
792
|
+
return props.labelZIndex;
|
|
793
|
+
},
|
|
794
|
+
get value() {
|
|
795
|
+
return props.inputValue ?? "";
|
|
796
|
+
},
|
|
797
|
+
get visible() {
|
|
798
|
+
return props.inputVisible ?? false;
|
|
799
|
+
},
|
|
800
|
+
get onInput() {
|
|
801
|
+
return props.onInputChange;
|
|
802
|
+
},
|
|
803
|
+
get onSubmit() {
|
|
804
|
+
return props.onInputSubmit;
|
|
805
|
+
},
|
|
806
|
+
get onCancel() {
|
|
807
|
+
return props.onInputCancel;
|
|
808
|
+
}
|
|
701
809
|
})];
|
|
702
810
|
};
|
|
703
811
|
|
|
@@ -751,50 +859,60 @@ var checkIsSourceComponentName = (name) => {
|
|
|
751
859
|
return true;
|
|
752
860
|
};
|
|
753
861
|
var getNearestComponentName = (element) => {
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
(
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
if (
|
|
763
|
-
|
|
764
|
-
|
|
862
|
+
if (!bippy.isInstrumentationActive()) return null;
|
|
863
|
+
try {
|
|
864
|
+
const fiber = bippy.getFiberFromHostInstance(element);
|
|
865
|
+
if (!fiber) return null;
|
|
866
|
+
let foundComponentName = null;
|
|
867
|
+
bippy.traverseFiber(
|
|
868
|
+
fiber,
|
|
869
|
+
(currentFiber) => {
|
|
870
|
+
if (bippy.isCompositeFiber(currentFiber)) {
|
|
871
|
+
const displayName = bippy.getDisplayName(currentFiber);
|
|
872
|
+
if (displayName && checkIsSourceComponentName(displayName)) {
|
|
873
|
+
foundComponentName = displayName;
|
|
874
|
+
return true;
|
|
875
|
+
}
|
|
765
876
|
}
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
877
|
+
return false;
|
|
878
|
+
},
|
|
879
|
+
true
|
|
880
|
+
);
|
|
881
|
+
return foundComponentName;
|
|
882
|
+
} catch {
|
|
883
|
+
return null;
|
|
884
|
+
}
|
|
772
885
|
};
|
|
773
886
|
var getStack = async (element) => {
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
(
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
887
|
+
if (!bippy.isInstrumentationActive()) return [];
|
|
888
|
+
try {
|
|
889
|
+
const maybeFiber = bippy.getFiberFromHostInstance(element);
|
|
890
|
+
if (!maybeFiber || !bippy.isFiber(maybeFiber)) return [];
|
|
891
|
+
const fiber = bippy.getLatestFiber(maybeFiber);
|
|
892
|
+
const unresolvedStack = [];
|
|
893
|
+
bippy.traverseFiber(
|
|
894
|
+
fiber,
|
|
895
|
+
(currentFiber) => {
|
|
896
|
+
const displayName = bippy.isHostFiber(currentFiber) ? typeof currentFiber.type === "string" ? currentFiber.type : null : bippy.getDisplayName(currentFiber);
|
|
897
|
+
if (displayName && !checkIsInternalComponentName(displayName)) {
|
|
898
|
+
unresolvedStack.push({
|
|
899
|
+
name: displayName,
|
|
900
|
+
sourcePromise: source.getSource(currentFiber)
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
},
|
|
904
|
+
true
|
|
905
|
+
);
|
|
906
|
+
const resolvedStack = await Promise.all(
|
|
907
|
+
unresolvedStack.map(async (frame) => ({
|
|
908
|
+
name: frame.name,
|
|
909
|
+
source: await frame.sourcePromise
|
|
910
|
+
}))
|
|
911
|
+
);
|
|
912
|
+
return resolvedStack.filter((frame) => frame.source !== null);
|
|
913
|
+
} catch {
|
|
914
|
+
return [];
|
|
915
|
+
}
|
|
798
916
|
};
|
|
799
917
|
var formatStack = (stack) => {
|
|
800
918
|
const isNextProject = checkIsNextProject();
|
|
@@ -837,7 +955,7 @@ var getHTMLPreview = (element) => {
|
|
|
837
955
|
if (node.textContent && node.textContent.trim().length > 0) {
|
|
838
956
|
foundFirstText = true;
|
|
839
957
|
}
|
|
840
|
-
} else if (node
|
|
958
|
+
} else if (node instanceof Element) {
|
|
841
959
|
if (!foundFirstText) {
|
|
842
960
|
topElements.push(node);
|
|
843
961
|
} else {
|
|
@@ -1067,7 +1185,7 @@ var createElementBounds = (element) => {
|
|
|
1067
1185
|
};
|
|
1068
1186
|
|
|
1069
1187
|
// src/core.tsx
|
|
1070
|
-
var
|
|
1188
|
+
var hasInited = false;
|
|
1071
1189
|
var init = (rawOptions) => {
|
|
1072
1190
|
const options = {
|
|
1073
1191
|
enabled: true,
|
|
@@ -1076,7 +1194,7 @@ var init = (rawOptions) => {
|
|
|
1076
1194
|
playCopySound: false,
|
|
1077
1195
|
...rawOptions
|
|
1078
1196
|
};
|
|
1079
|
-
if (options.enabled === false) {
|
|
1197
|
+
if (options.enabled === false || hasInited) {
|
|
1080
1198
|
return {
|
|
1081
1199
|
activate: () => {
|
|
1082
1200
|
},
|
|
@@ -1089,16 +1207,15 @@ var init = (rawOptions) => {
|
|
|
1089
1207
|
}
|
|
1090
1208
|
};
|
|
1091
1209
|
}
|
|
1210
|
+
hasInited = true;
|
|
1092
1211
|
const logIntro = () => {
|
|
1093
|
-
if (hasLoggedIntro) return;
|
|
1094
|
-
hasLoggedIntro = true;
|
|
1095
1212
|
try {
|
|
1096
|
-
const version = "0.0.
|
|
1213
|
+
const version = "0.0.46";
|
|
1097
1214
|
const logoSvg = `<svg width="294" height="294" viewBox="0 0 294 294" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_0_3)"><mask id="mask0_0_3" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="0" y="0" width="294" height="294"><path d="M294 0H0V294H294V0Z" fill="white"/></mask><g mask="url(#mask0_0_3)"><path d="M144.599 47.4924C169.712 27.3959 194.548 20.0265 212.132 30.1797C227.847 39.2555 234.881 60.3243 231.926 89.516C231.677 92.0069 231.328 94.5423 230.94 97.1058L228.526 110.14C228.517 110.136 228.505 110.132 228.495 110.127C228.486 110.165 228.479 110.203 228.468 110.24L216.255 105.741C216.256 105.736 216.248 105.728 216.248 105.723C207.915 103.125 199.421 101.075 190.82 99.5888L190.696 99.5588L173.526 97.2648L173.511 97.2631C173.492 97.236 173.467 97.2176 173.447 97.1905C163.862 96.2064 154.233 95.7166 144.599 95.7223C134.943 95.7162 125.295 96.219 115.693 97.2286C110.075 105.033 104.859 113.118 100.063 121.453C95.2426 129.798 90.8624 138.391 86.939 147.193C90.8624 155.996 95.2426 164.588 100.063 172.933C104.866 181.302 110.099 189.417 115.741 197.245C115.749 197.245 115.758 197.246 115.766 197.247L115.752 197.27L115.745 197.283L115.754 197.296L126.501 211.013L126.574 211.089C132.136 217.767 138.126 224.075 144.507 229.974L144.609 230.082L154.572 238.287C154.539 238.319 154.506 238.35 154.472 238.38C154.485 238.392 154.499 238.402 154.513 238.412L143.846 247.482L143.827 247.497C126.56 261.128 109.472 268.745 94.8019 268.745C88.5916 268.837 82.4687 267.272 77.0657 264.208C61.3496 255.132 54.3164 234.062 57.2707 204.871C57.528 202.307 57.8806 199.694 58.2904 197.054C28.3363 185.327 9.52301 167.51 9.52301 147.193C9.52301 129.042 24.2476 112.396 50.9901 100.375C53.3443 99.3163 55.7938 98.3058 58.2904 97.3526C57.8806 94.7023 57.528 92.0803 57.2707 89.516C54.3164 60.3243 61.3496 39.2555 77.0657 30.1797C94.6494 20.0265 119.486 27.3959 144.599 47.4924ZM70.6423 201.315C70.423 202.955 70.2229 204.566 70.0704 206.168C67.6686 229.567 72.5478 246.628 83.3615 252.988L83.5176 253.062C95.0399 259.717 114.015 254.426 134.782 238.38C125.298 229.45 116.594 219.725 108.764 209.314C95.8516 207.742 83.0977 205.066 70.6423 201.315ZM80.3534 163.438C77.34 171.677 74.8666 180.104 72.9484 188.664C81.1787 191.224 89.5657 193.247 98.0572 194.724L98.4618 194.813C95.2115 189.865 92.0191 184.66 88.9311 179.378C85.8433 174.097 83.003 168.768 80.3534 163.438ZM60.759 110.203C59.234 110.839 57.7378 111.475 56.27 112.11C34.7788 121.806 22.3891 134.591 22.3891 147.193C22.3891 160.493 36.4657 174.297 60.7494 184.26C63.7439 171.581 67.8124 159.182 72.9104 147.193C67.822 135.23 63.7566 122.855 60.759 110.203ZM98.4137 99.6404C89.8078 101.145 81.3075 103.206 72.9676 105.809C74.854 114.203 77.2741 122.468 80.2132 130.554L80.3059 130.939C82.9938 125.6 85.8049 120.338 88.8834 115.008C91.9618 109.679 95.1544 104.569 98.4137 99.6404ZM94.9258 38.5215C90.9331 38.4284 86.9866 39.3955 83.4891 41.3243C72.6291 47.6015 67.6975 64.5954 70.0424 87.9446L70.0416 88.2194C70.194 89.8208 70.3941 91.4325 70.6134 93.0624C83.0737 89.3364 95.8263 86.6703 108.736 85.0924C116.57 74.6779 125.28 64.9532 134.773 56.0249C119.877 44.5087 105.895 38.5215 94.9258 38.5215ZM205.737 41.3148C202.268 39.398 198.355 38.4308 194.394 38.5099L194.29 38.512C183.321 38.512 169.34 44.4991 154.444 56.0153C163.93 64.9374 172.634 74.6557 180.462 85.064C193.375 86.6345 206.128 89.3102 218.584 93.0624C218.812 91.4325 219.003 89.8118 219.165 88.2098C221.548 64.7099 216.65 47.6164 205.737 41.3148ZM144.552 64.3097C138.104 70.2614 132.054 76.6306 126.443 83.3765C132.39 82.995 138.426 82.8046 144.552 82.8046C150.727 82.8046 156.778 83.0143 162.707 83.3765C157.08 76.6293 151.015 70.2596 144.552 64.3097Z" fill="white"/><path d="M144.598 47.4924C169.712 27.3959 194.547 20.0265 212.131 30.1797C227.847 39.2555 234.88 60.3243 231.926 89.516C231.677 92.0069 231.327 94.5423 230.941 97.1058L228.526 110.14L228.496 110.127C228.487 110.165 228.478 110.203 228.469 110.24L216.255 105.741L216.249 105.723C207.916 103.125 199.42 101.075 190.82 99.5888L190.696 99.5588L173.525 97.2648L173.511 97.263C173.492 97.236 173.468 97.2176 173.447 97.1905C163.863 96.2064 154.234 95.7166 144.598 95.7223C134.943 95.7162 125.295 96.219 115.693 97.2286C110.075 105.033 104.859 113.118 100.063 121.453C95.2426 129.798 90.8622 138.391 86.939 147.193C90.8622 155.996 95.2426 164.588 100.063 172.933C104.866 181.302 110.099 189.417 115.741 197.245L115.766 197.247L115.752 197.27L115.745 197.283L115.754 197.296L126.501 211.013L126.574 211.089C132.136 217.767 138.126 224.075 144.506 229.974L144.61 230.082L154.572 238.287C154.539 238.319 154.506 238.35 154.473 238.38L154.512 238.412L143.847 247.482L143.827 247.497C126.56 261.13 109.472 268.745 94.8018 268.745C88.5915 268.837 82.4687 267.272 77.0657 264.208C61.3496 255.132 54.3162 234.062 57.2707 204.871C57.528 202.307 57.8806 199.694 58.2904 197.054C28.3362 185.327 9.52298 167.51 9.52298 147.193C9.52298 129.042 24.2476 112.396 50.9901 100.375C53.3443 99.3163 55.7938 98.3058 58.2904 97.3526C57.8806 94.7023 57.528 92.0803 57.2707 89.516C54.3162 60.3243 61.3496 39.2555 77.0657 30.1797C94.6493 20.0265 119.486 27.3959 144.598 47.4924ZM70.6422 201.315C70.423 202.955 70.2229 204.566 70.0704 206.168C67.6686 229.567 72.5478 246.628 83.3615 252.988L83.5175 253.062C95.0399 259.717 114.015 254.426 134.782 238.38C125.298 229.45 116.594 219.725 108.764 209.314C95.8515 207.742 83.0977 205.066 70.6422 201.315ZM80.3534 163.438C77.34 171.677 74.8666 180.104 72.9484 188.664C81.1786 191.224 89.5657 193.247 98.0572 194.724L98.4618 194.813C95.2115 189.865 92.0191 184.66 88.931 179.378C85.8433 174.097 83.003 168.768 80.3534 163.438ZM60.7589 110.203C59.234 110.839 57.7378 111.475 56.2699 112.11C34.7788 121.806 22.3891 134.591 22.3891 147.193C22.3891 160.493 36.4657 174.297 60.7494 184.26C63.7439 171.581 67.8124 159.182 72.9103 147.193C67.822 135.23 63.7566 122.855 60.7589 110.203ZM98.4137 99.6404C89.8078 101.145 81.3075 103.206 72.9676 105.809C74.8539 114.203 77.2741 122.468 80.2132 130.554L80.3059 130.939C82.9938 125.6 85.8049 120.338 88.8834 115.008C91.9618 109.679 95.1544 104.569 98.4137 99.6404ZM94.9258 38.5215C90.9331 38.4284 86.9866 39.3955 83.4891 41.3243C72.629 47.6015 67.6975 64.5954 70.0424 87.9446L70.0415 88.2194C70.194 89.8208 70.3941 91.4325 70.6134 93.0624C83.0737 89.3364 95.8262 86.6703 108.736 85.0924C116.57 74.6779 125.28 64.9532 134.772 56.0249C119.877 44.5087 105.895 38.5215 94.9258 38.5215ZM205.737 41.3148C202.268 39.398 198.355 38.4308 194.394 38.5099L194.291 38.512C183.321 38.512 169.34 44.4991 154.443 56.0153C163.929 64.9374 172.634 74.6557 180.462 85.064C193.374 86.6345 206.129 89.3102 218.584 93.0624C218.813 91.4325 219.003 89.8118 219.166 88.2098C221.548 64.7099 216.65 47.6164 205.737 41.3148ZM144.551 64.3097C138.103 70.2614 132.055 76.6306 126.443 83.3765C132.389 82.995 138.427 82.8046 144.551 82.8046C150.727 82.8046 156.779 83.0143 162.707 83.3765C157.079 76.6293 151.015 70.2596 144.551 64.3097Z" fill="#FF40E0"/></g><mask id="mask1_0_3" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="102" y="84" width="161" height="162"><path d="M235.282 84.827L102.261 112.259L129.693 245.28L262.714 217.848L235.282 84.827Z" fill="white"/></mask><g mask="url(#mask1_0_3)"><path d="M136.863 129.916L213.258 141.224C220.669 142.322 222.495 152.179 215.967 155.856L187.592 171.843L184.135 204.227C183.339 211.678 173.564 213.901 169.624 207.526L129.021 141.831C125.503 136.14 130.245 128.936 136.863 129.916Z" fill="#FF40E0" stroke="#FF40E0" stroke-width="0.817337" stroke-linecap="round" stroke-linejoin="round"/></g></g><defs><clipPath id="clip0_0_3"><rect width="294" height="294" fill="white"/></clipPath></defs></svg>`;
|
|
1098
1215
|
const logoDataUri = `data:image/svg+xml;base64,${btoa(logoSvg)}`;
|
|
1099
1216
|
console.log(`%cReact Grab${version ? ` v${version}` : ""}%c
|
|
1100
1217
|
https://react-grab.com`, `background: #330039; color: #ffffff; border: 1px solid #d75fcb; padding: 4px 4px 4px 24px; border-radius: 4px; background-image: url("${logoDataUri}"); background-size: 16px 16px; background-repeat: no-repeat; background-position: 4px center; display: inline-block; margin-bottom: 4px;`, "");
|
|
1101
|
-
fetch("https://react-grab.com/api/version").then((res) => res.text()).catch(() => null);
|
|
1218
|
+
fetch("https://www.react-grab.com/api/version").then((res) => res.text()).catch(() => null);
|
|
1102
1219
|
} catch {
|
|
1103
1220
|
}
|
|
1104
1221
|
};
|
|
@@ -1123,21 +1240,34 @@ https://react-grab.com`, `background: #330039; color: #ffffff; border: 1px solid
|
|
|
1123
1240
|
const [copyStartX, setCopyStartX] = solidJs.createSignal(OFFSCREEN_POSITION);
|
|
1124
1241
|
const [copyStartY, setCopyStartY] = solidJs.createSignal(OFFSCREEN_POSITION);
|
|
1125
1242
|
const [mouseHasSettled, setMouseHasSettled] = solidJs.createSignal(false);
|
|
1243
|
+
const [viewportVersion, setViewportVersion] = solidJs.createSignal(0);
|
|
1244
|
+
const [isInputMode, setIsInputMode] = solidJs.createSignal(false);
|
|
1245
|
+
const [inputText, setInputText] = solidJs.createSignal("");
|
|
1126
1246
|
let holdTimerId = null;
|
|
1127
1247
|
let progressAnimationId = null;
|
|
1128
1248
|
let progressDelayTimerId = null;
|
|
1129
1249
|
let keydownSpamTimerId = null;
|
|
1130
1250
|
let mouseSettleTimerId = null;
|
|
1251
|
+
let autoScrollAnimationId = null;
|
|
1131
1252
|
const isRendererActive = solidJs.createMemo(() => isActivated() && !isCopying());
|
|
1132
1253
|
const hasValidMousePosition = solidJs.createMemo(() => mouseX() > OFFSCREEN_POSITION && mouseY() > OFFSCREEN_POSITION);
|
|
1133
1254
|
const isTargetKeyCombination = (event) => (event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "c";
|
|
1134
|
-
const
|
|
1255
|
+
const getAutoScrollDirection = (clientX, clientY) => {
|
|
1256
|
+
return {
|
|
1257
|
+
top: clientY < AUTO_SCROLL_EDGE_THRESHOLD_PX,
|
|
1258
|
+
bottom: clientY > window.innerHeight - AUTO_SCROLL_EDGE_THRESHOLD_PX,
|
|
1259
|
+
left: clientX < AUTO_SCROLL_EDGE_THRESHOLD_PX,
|
|
1260
|
+
right: clientX > window.innerWidth - AUTO_SCROLL_EDGE_THRESHOLD_PX
|
|
1261
|
+
};
|
|
1262
|
+
};
|
|
1263
|
+
const showTemporaryGrabbedBox = (bounds, element) => {
|
|
1135
1264
|
const boxId = `grabbed-${Date.now()}-${Math.random()}`;
|
|
1136
1265
|
const createdAt = Date.now();
|
|
1137
1266
|
const newBox = {
|
|
1138
1267
|
id: boxId,
|
|
1139
1268
|
bounds,
|
|
1140
|
-
createdAt
|
|
1269
|
+
createdAt,
|
|
1270
|
+
element
|
|
1141
1271
|
};
|
|
1142
1272
|
const currentBoxes = grabbedBoxes();
|
|
1143
1273
|
setGrabbedBoxes([...currentBoxes, newBox]);
|
|
@@ -1192,11 +1322,7 @@ ${context}
|
|
|
1192
1322
|
setIsCopying(false);
|
|
1193
1323
|
stopProgressAnimation();
|
|
1194
1324
|
if (isToggleMode()) {
|
|
1195
|
-
|
|
1196
|
-
deactivateRenderer();
|
|
1197
|
-
} else {
|
|
1198
|
-
setIsToggleMode(false);
|
|
1199
|
-
}
|
|
1325
|
+
deactivateRenderer();
|
|
1200
1326
|
}
|
|
1201
1327
|
});
|
|
1202
1328
|
};
|
|
@@ -1208,37 +1334,60 @@ ${context}
|
|
|
1208
1334
|
return element.textContent ?? "";
|
|
1209
1335
|
};
|
|
1210
1336
|
const createCombinedTextContent = (elements) => elements.map((element) => extractElementTextContent(element).trim()).filter((textContent) => textContent.length > 0).join("\n\n");
|
|
1211
|
-
const tryCopyWithFallback = async (elements) => {
|
|
1337
|
+
const tryCopyWithFallback = async (elements, extraPrompt) => {
|
|
1212
1338
|
let didCopy = false;
|
|
1339
|
+
const isReactProject = bippy.isInstrumentationActive();
|
|
1213
1340
|
try {
|
|
1214
|
-
const elementSnippetResults = await Promise.allSettled(elements.map(async (element) =>
|
|
1215
|
-
|
|
1341
|
+
const elementSnippetResults = await Promise.allSettled(elements.map(async (element) => {
|
|
1342
|
+
const htmlPreview = getHTMLPreview(element);
|
|
1343
|
+
if (!isReactProject) {
|
|
1344
|
+
return `## HTML Frame:
|
|
1345
|
+
${htmlPreview}`;
|
|
1346
|
+
}
|
|
1347
|
+
const stack = await getStack(element);
|
|
1348
|
+
const formattedStack = formatStack(stack);
|
|
1349
|
+
if (formattedStack) {
|
|
1350
|
+
return `## HTML Frame:
|
|
1351
|
+
${htmlPreview}
|
|
1216
1352
|
|
|
1217
1353
|
## Code Location:
|
|
1218
|
-
${
|
|
1354
|
+
${formattedStack}`;
|
|
1355
|
+
}
|
|
1356
|
+
return `## HTML Frame:
|
|
1357
|
+
${htmlPreview}`;
|
|
1358
|
+
}));
|
|
1219
1359
|
const elementSnippets = elementSnippetResults.map((result) => result.status === "fulfilled" ? result.value : "").filter((snippet) => snippet.trim());
|
|
1220
1360
|
if (elementSnippets.length > 0) {
|
|
1221
|
-
const
|
|
1361
|
+
const wrappedSnippets = elementSnippets.map((snippet) => wrapInSelectedElementTags(snippet)).join("\n\n");
|
|
1362
|
+
const plainTextContent = extraPrompt ? `${extraPrompt}
|
|
1363
|
+
|
|
1364
|
+
${wrappedSnippets}` : wrappedSnippets;
|
|
1222
1365
|
didCopy = await copyContent(plainTextContent, options.playCopySound ? playCopySound : void 0);
|
|
1223
1366
|
}
|
|
1224
1367
|
if (!didCopy) {
|
|
1225
1368
|
const plainTextContentOnly = createCombinedTextContent(elements);
|
|
1226
1369
|
if (plainTextContentOnly.length > 0) {
|
|
1227
|
-
|
|
1370
|
+
const contentWithPrompt = extraPrompt ? `${extraPrompt}
|
|
1371
|
+
|
|
1372
|
+
${plainTextContentOnly}` : plainTextContentOnly;
|
|
1373
|
+
didCopy = await copyContent(contentWithPrompt, options.playCopySound ? playCopySound : void 0);
|
|
1228
1374
|
}
|
|
1229
1375
|
}
|
|
1230
1376
|
} catch {
|
|
1231
1377
|
const plainTextContentOnly = createCombinedTextContent(elements);
|
|
1232
1378
|
if (plainTextContentOnly.length > 0) {
|
|
1233
|
-
|
|
1379
|
+
const contentWithPrompt = extraPrompt ? `${extraPrompt}
|
|
1380
|
+
|
|
1381
|
+
${plainTextContentOnly}` : plainTextContentOnly;
|
|
1382
|
+
didCopy = await copyContent(contentWithPrompt, options.playCopySound ? playCopySound : void 0);
|
|
1234
1383
|
}
|
|
1235
1384
|
}
|
|
1236
1385
|
return didCopy;
|
|
1237
1386
|
};
|
|
1238
|
-
const copySingleElementToClipboard = async (targetElement2) => {
|
|
1239
|
-
showTemporaryGrabbedBox(createElementBounds(targetElement2));
|
|
1387
|
+
const copySingleElementToClipboard = async (targetElement2, extraPrompt) => {
|
|
1388
|
+
showTemporaryGrabbedBox(createElementBounds(targetElement2), targetElement2);
|
|
1240
1389
|
await new Promise((resolve) => requestAnimationFrame(resolve));
|
|
1241
|
-
const didCopy = await tryCopyWithFallback([targetElement2]);
|
|
1390
|
+
const didCopy = await tryCopyWithFallback([targetElement2], extraPrompt);
|
|
1242
1391
|
if (didCopy) {
|
|
1243
1392
|
showTemporarySuccessLabel(extractElementLabelText(targetElement2));
|
|
1244
1393
|
}
|
|
@@ -1247,7 +1396,7 @@ ${formatStack(await getStack(element))}`));
|
|
|
1247
1396
|
const copyMultipleElementsToClipboard = async (targetElements) => {
|
|
1248
1397
|
if (targetElements.length === 0) return;
|
|
1249
1398
|
for (const element of targetElements) {
|
|
1250
|
-
showTemporaryGrabbedBox(createElementBounds(element));
|
|
1399
|
+
showTemporaryGrabbedBox(createElementBounds(element), element);
|
|
1251
1400
|
}
|
|
1252
1401
|
await new Promise((resolve) => requestAnimationFrame(resolve));
|
|
1253
1402
|
const didCopy = await tryCopyWithFallback(targetElements);
|
|
@@ -1261,6 +1410,7 @@ ${formatStack(await getStack(element))}`));
|
|
|
1261
1410
|
return getElementAtPosition(mouseX(), mouseY());
|
|
1262
1411
|
});
|
|
1263
1412
|
const selectionBounds = solidJs.createMemo(() => {
|
|
1413
|
+
viewportVersion();
|
|
1264
1414
|
const element = targetElement();
|
|
1265
1415
|
if (!element) return void 0;
|
|
1266
1416
|
const elementBounds = element.getBoundingClientRect();
|
|
@@ -1274,23 +1424,29 @@ ${formatStack(await getStack(element))}`));
|
|
|
1274
1424
|
y: elementBounds.top
|
|
1275
1425
|
};
|
|
1276
1426
|
});
|
|
1277
|
-
const calculateDragDistance = (endX, endY) =>
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1427
|
+
const calculateDragDistance = (endX, endY) => {
|
|
1428
|
+
const endPageX = endX + window.scrollX;
|
|
1429
|
+
const endPageY = endY + window.scrollY;
|
|
1430
|
+
return {
|
|
1431
|
+
x: Math.abs(endPageX - dragStartX()),
|
|
1432
|
+
y: Math.abs(endPageY - dragStartY())
|
|
1433
|
+
};
|
|
1434
|
+
};
|
|
1281
1435
|
const isDraggingBeyondThreshold = solidJs.createMemo(() => {
|
|
1282
1436
|
if (!isDragging()) return false;
|
|
1283
1437
|
const dragDistance = calculateDragDistance(mouseX(), mouseY());
|
|
1284
1438
|
return dragDistance.x > DRAG_THRESHOLD_PX || dragDistance.y > DRAG_THRESHOLD_PX;
|
|
1285
1439
|
});
|
|
1286
1440
|
const calculateDragRectangle = (endX, endY) => {
|
|
1287
|
-
const
|
|
1288
|
-
const
|
|
1289
|
-
const
|
|
1290
|
-
const
|
|
1441
|
+
const endPageX = endX + window.scrollX;
|
|
1442
|
+
const endPageY = endY + window.scrollY;
|
|
1443
|
+
const dragPageX = Math.min(dragStartX(), endPageX);
|
|
1444
|
+
const dragPageY = Math.min(dragStartY(), endPageY);
|
|
1445
|
+
const dragWidth = Math.abs(endPageX - dragStartX());
|
|
1446
|
+
const dragHeight = Math.abs(endPageY - dragStartY());
|
|
1291
1447
|
return {
|
|
1292
|
-
x:
|
|
1293
|
-
y:
|
|
1448
|
+
x: dragPageX - window.scrollX,
|
|
1449
|
+
y: dragPageY - window.scrollY,
|
|
1294
1450
|
width: dragWidth,
|
|
1295
1451
|
height: dragHeight
|
|
1296
1452
|
};
|
|
@@ -1330,6 +1486,15 @@ ${formatStack(await getStack(element))}`));
|
|
|
1330
1486
|
setLastGrabbedElement(null);
|
|
1331
1487
|
}
|
|
1332
1488
|
}));
|
|
1489
|
+
solidJs.createEffect(solidJs.on(() => viewportVersion(), () => {
|
|
1490
|
+
const currentBoxes = grabbedBoxes();
|
|
1491
|
+
if (currentBoxes.length === 0) return;
|
|
1492
|
+
const updatedBoxes = currentBoxes.map((box) => ({
|
|
1493
|
+
...box,
|
|
1494
|
+
bounds: createElementBounds(box.element)
|
|
1495
|
+
}));
|
|
1496
|
+
setGrabbedBoxes(updatedBoxes);
|
|
1497
|
+
}));
|
|
1333
1498
|
const startProgressAnimation = () => {
|
|
1334
1499
|
const startTime = Date.now();
|
|
1335
1500
|
setProgressStartTime(startTime);
|
|
@@ -1366,6 +1531,31 @@ ${formatStack(await getStack(element))}`));
|
|
|
1366
1531
|
setProgress(1);
|
|
1367
1532
|
setShowProgressIndicator(false);
|
|
1368
1533
|
};
|
|
1534
|
+
const startAutoScroll = () => {
|
|
1535
|
+
const scroll = () => {
|
|
1536
|
+
if (!isDragging()) {
|
|
1537
|
+
stopAutoScroll();
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1540
|
+
const direction = getAutoScrollDirection(mouseX(), mouseY());
|
|
1541
|
+
if (direction.top) window.scrollBy(0, -AUTO_SCROLL_SPEED_PX);
|
|
1542
|
+
if (direction.bottom) window.scrollBy(0, AUTO_SCROLL_SPEED_PX);
|
|
1543
|
+
if (direction.left) window.scrollBy(-AUTO_SCROLL_SPEED_PX, 0);
|
|
1544
|
+
if (direction.right) window.scrollBy(AUTO_SCROLL_SPEED_PX, 0);
|
|
1545
|
+
if (direction.top || direction.bottom || direction.left || direction.right) {
|
|
1546
|
+
autoScrollAnimationId = requestAnimationFrame(scroll);
|
|
1547
|
+
} else {
|
|
1548
|
+
autoScrollAnimationId = null;
|
|
1549
|
+
}
|
|
1550
|
+
};
|
|
1551
|
+
scroll();
|
|
1552
|
+
};
|
|
1553
|
+
const stopAutoScroll = () => {
|
|
1554
|
+
if (autoScrollAnimationId !== null) {
|
|
1555
|
+
cancelAnimationFrame(autoScrollAnimationId);
|
|
1556
|
+
autoScrollAnimationId = null;
|
|
1557
|
+
}
|
|
1558
|
+
};
|
|
1369
1559
|
const activateRenderer = () => {
|
|
1370
1560
|
stopProgressAnimation();
|
|
1371
1561
|
setIsActivated(true);
|
|
@@ -1376,6 +1566,8 @@ ${formatStack(await getStack(element))}`));
|
|
|
1376
1566
|
setIsToggleMode(false);
|
|
1377
1567
|
setIsHoldingKeys(false);
|
|
1378
1568
|
setIsActivated(false);
|
|
1569
|
+
setIsInputMode(false);
|
|
1570
|
+
setInputText("");
|
|
1379
1571
|
document.body.style.cursor = "";
|
|
1380
1572
|
if (isDragging()) {
|
|
1381
1573
|
setIsDragging(false);
|
|
@@ -1388,17 +1580,44 @@ ${formatStack(await getStack(element))}`));
|
|
|
1388
1580
|
mouseSettleTimerId = null;
|
|
1389
1581
|
}
|
|
1390
1582
|
setMouseHasSettled(false);
|
|
1583
|
+
stopAutoScroll();
|
|
1391
1584
|
stopProgressAnimation();
|
|
1392
1585
|
options.onDeactivate?.();
|
|
1393
1586
|
};
|
|
1587
|
+
const handleInputChange = (value) => {
|
|
1588
|
+
setInputText(value);
|
|
1589
|
+
};
|
|
1590
|
+
const handleInputSubmit = () => {
|
|
1591
|
+
if (!isInputMode()) return;
|
|
1592
|
+
const element = targetElement();
|
|
1593
|
+
const prompt = inputText().trim();
|
|
1594
|
+
const currentX = mouseX();
|
|
1595
|
+
const currentY = mouseY();
|
|
1596
|
+
setIsInputMode(false);
|
|
1597
|
+
setInputText("");
|
|
1598
|
+
if (element) {
|
|
1599
|
+
void executeCopyOperation(currentX, currentY, () => copySingleElementToClipboard(element, prompt || void 0)).then(() => {
|
|
1600
|
+
deactivateRenderer();
|
|
1601
|
+
});
|
|
1602
|
+
} else {
|
|
1603
|
+
deactivateRenderer();
|
|
1604
|
+
}
|
|
1605
|
+
};
|
|
1606
|
+
const handleInputCancel = () => {
|
|
1607
|
+
if (!isInputMode()) return;
|
|
1608
|
+
deactivateRenderer();
|
|
1609
|
+
};
|
|
1394
1610
|
const abortController = new AbortController();
|
|
1395
1611
|
const eventListenerSignal = abortController.signal;
|
|
1396
1612
|
window.addEventListener("keydown", (event) => {
|
|
1397
1613
|
if (event.key === "Escape" && isHoldingKeys()) {
|
|
1614
|
+
if (isInputMode()) {
|
|
1615
|
+
return;
|
|
1616
|
+
}
|
|
1398
1617
|
deactivateRenderer();
|
|
1399
1618
|
return;
|
|
1400
1619
|
}
|
|
1401
|
-
if (event.key === "Enter" && isHoldingKeys()) {
|
|
1620
|
+
if (event.key === "Enter" && isHoldingKeys() && !isInputMode()) {
|
|
1402
1621
|
setIsToggleMode(true);
|
|
1403
1622
|
if (keydownSpamTimerId !== null) {
|
|
1404
1623
|
window.clearTimeout(keydownSpamTimerId);
|
|
@@ -1408,6 +1627,7 @@ ${formatStack(await getStack(element))}`));
|
|
|
1408
1627
|
if (holdTimerId) window.clearTimeout(holdTimerId);
|
|
1409
1628
|
activateRenderer();
|
|
1410
1629
|
}
|
|
1630
|
+
setIsInputMode(true);
|
|
1411
1631
|
return;
|
|
1412
1632
|
}
|
|
1413
1633
|
if (!options.allowActivationInsideInput && isKeyboardEventTriggeredByInput(event)) {
|
|
@@ -1461,15 +1681,32 @@ ${formatStack(await getStack(element))}`));
|
|
|
1461
1681
|
setMouseHasSettled(true);
|
|
1462
1682
|
mouseSettleTimerId = null;
|
|
1463
1683
|
}, 300);
|
|
1684
|
+
if (isDragging()) {
|
|
1685
|
+
const direction = getAutoScrollDirection(event.clientX, event.clientY);
|
|
1686
|
+
const isNearEdge = direction.top || direction.bottom || direction.left || direction.right;
|
|
1687
|
+
if (isNearEdge && autoScrollAnimationId === null) {
|
|
1688
|
+
startAutoScroll();
|
|
1689
|
+
} else if (!isNearEdge && autoScrollAnimationId !== null) {
|
|
1690
|
+
stopAutoScroll();
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1464
1693
|
}, {
|
|
1465
1694
|
signal: eventListenerSignal
|
|
1466
1695
|
});
|
|
1467
1696
|
window.addEventListener("mousedown", (event) => {
|
|
1697
|
+
if (isInputMode()) {
|
|
1698
|
+
const target = event.target;
|
|
1699
|
+
const isClickingInput = target.closest("[data-react-grab-input]");
|
|
1700
|
+
if (!isClickingInput) {
|
|
1701
|
+
handleInputCancel();
|
|
1702
|
+
}
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1468
1705
|
if (!isRendererActive() || isCopying()) return;
|
|
1469
1706
|
event.preventDefault();
|
|
1470
1707
|
setIsDragging(true);
|
|
1471
|
-
setDragStartX(event.clientX);
|
|
1472
|
-
setDragStartY(event.clientY);
|
|
1708
|
+
setDragStartX(event.clientX + window.scrollX);
|
|
1709
|
+
setDragStartY(event.clientY + window.scrollY);
|
|
1473
1710
|
document.body.style.userSelect = "none";
|
|
1474
1711
|
}, {
|
|
1475
1712
|
signal: eventListenerSignal
|
|
@@ -1479,6 +1716,7 @@ ${formatStack(await getStack(element))}`));
|
|
|
1479
1716
|
const dragDistance = calculateDragDistance(event.clientX, event.clientY);
|
|
1480
1717
|
const wasDragGesture = dragDistance.x > DRAG_THRESHOLD_PX || dragDistance.y > DRAG_THRESHOLD_PX;
|
|
1481
1718
|
setIsDragging(false);
|
|
1719
|
+
stopAutoScroll();
|
|
1482
1720
|
document.body.style.userSelect = "";
|
|
1483
1721
|
if (wasDragGesture) {
|
|
1484
1722
|
setDidJustDrag(true);
|
|
@@ -1528,11 +1766,23 @@ ${formatStack(await getStack(element))}`));
|
|
|
1528
1766
|
}, {
|
|
1529
1767
|
signal: eventListenerSignal
|
|
1530
1768
|
});
|
|
1769
|
+
window.addEventListener("scroll", () => {
|
|
1770
|
+
setViewportVersion((version) => version + 1);
|
|
1771
|
+
}, {
|
|
1772
|
+
signal: eventListenerSignal,
|
|
1773
|
+
capture: true
|
|
1774
|
+
});
|
|
1775
|
+
window.addEventListener("resize", () => {
|
|
1776
|
+
setViewportVersion((version) => version + 1);
|
|
1777
|
+
}, {
|
|
1778
|
+
signal: eventListenerSignal
|
|
1779
|
+
});
|
|
1531
1780
|
solidJs.onCleanup(() => {
|
|
1532
1781
|
abortController.abort();
|
|
1533
1782
|
if (holdTimerId) window.clearTimeout(holdTimerId);
|
|
1534
1783
|
if (keydownSpamTimerId) window.clearTimeout(keydownSpamTimerId);
|
|
1535
1784
|
if (mouseSettleTimerId) window.clearTimeout(mouseSettleTimerId);
|
|
1785
|
+
stopAutoScroll();
|
|
1536
1786
|
stopProgressAnimation();
|
|
1537
1787
|
document.body.style.userSelect = "";
|
|
1538
1788
|
document.body.style.cursor = "";
|
|
@@ -1542,12 +1792,14 @@ ${formatStack(await getStack(element))}`));
|
|
|
1542
1792
|
const dragVisible = solidJs.createMemo(() => isRendererActive() && isDraggingBeyondThreshold());
|
|
1543
1793
|
const labelVariant = solidJs.createMemo(() => isCopying() ? "processing" : "hover");
|
|
1544
1794
|
const labelVisible = solidJs.createMemo(() => {
|
|
1795
|
+
if (isInputMode()) return false;
|
|
1545
1796
|
if (isCopying()) return true;
|
|
1546
1797
|
if (successLabels().length > 0) return false;
|
|
1547
1798
|
return isRendererActive() && !isDragging() && Boolean(targetElement());
|
|
1548
1799
|
});
|
|
1549
1800
|
const progressVisible = solidJs.createMemo(() => isCopying() && showProgressIndicator() && hasValidMousePosition());
|
|
1550
1801
|
const crosshairVisible = solidJs.createMemo(() => isRendererActive() && !isDragging());
|
|
1802
|
+
const inputVisible = solidJs.createMemo(() => isInputMode());
|
|
1551
1803
|
web.render(() => web.createComponent(ReactGrabRenderer, {
|
|
1552
1804
|
get selectionVisible() {
|
|
1553
1805
|
return selectionVisible();
|
|
@@ -1600,7 +1852,22 @@ ${formatStack(await getStack(element))}`));
|
|
|
1600
1852
|
},
|
|
1601
1853
|
get crosshairVisible() {
|
|
1602
1854
|
return crosshairVisible();
|
|
1603
|
-
}
|
|
1855
|
+
},
|
|
1856
|
+
get inputVisible() {
|
|
1857
|
+
return inputVisible();
|
|
1858
|
+
},
|
|
1859
|
+
get inputX() {
|
|
1860
|
+
return mouseX();
|
|
1861
|
+
},
|
|
1862
|
+
get inputY() {
|
|
1863
|
+
return mouseY();
|
|
1864
|
+
},
|
|
1865
|
+
get inputValue() {
|
|
1866
|
+
return inputText();
|
|
1867
|
+
},
|
|
1868
|
+
onInputChange: handleInputChange,
|
|
1869
|
+
onInputSubmit: handleInputSubmit,
|
|
1870
|
+
onInputCancel: handleInputCancel
|
|
1604
1871
|
}), rendererRoot);
|
|
1605
1872
|
return {
|
|
1606
1873
|
activate: () => {
|