made-refine 0.2.20 → 0.3.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 +1 -1
- package/dist/babel.cjs +5 -1
- package/dist/index.d.mts +22 -4
- package/dist/index.d.ts +22 -4
- package/dist/index.js +1525 -793
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1526 -794
- package/dist/index.mjs.map +1 -1
- package/dist/preload/preload.js +26 -3
- package/dist/preload.js +25 -3
- package/dist/preload.js.map +1 -1
- package/dist/preload.mjs +10 -3
- package/dist/preload.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/{utils-CpmjloNg.d.mts → utils-ovHeRo0g.d.mts} +20 -16
- package/dist/{utils-CpmjloNg.d.ts → utils-ovHeRo0g.d.ts} +20 -16
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +292 -198
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +292 -198
- package/dist/utils.mjs.map +1 -1
- package/package.json +14 -3
package/dist/utils.mjs
CHANGED
|
@@ -320,10 +320,30 @@ function getSourceFromFiber(fiber) {
|
|
|
320
320
|
if (fromDebugStack?.fileName) return fromDebugStack;
|
|
321
321
|
return null;
|
|
322
322
|
}
|
|
323
|
+
var REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref");
|
|
324
|
+
var REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo");
|
|
325
|
+
function resolveComponentName(type) {
|
|
326
|
+
let current = type;
|
|
327
|
+
for (let depth = 0; depth < 4 && current != null; depth++) {
|
|
328
|
+
const name = current.displayName || (typeof current === "function" ? current.name : void 0);
|
|
329
|
+
if (name) return name;
|
|
330
|
+
if (typeof current !== "object") return null;
|
|
331
|
+
if (current.$$typeof === REACT_MEMO_TYPE) {
|
|
332
|
+
current = current.type;
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
if (current.$$typeof === REACT_FORWARD_REF_TYPE) {
|
|
336
|
+
current = current.render;
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
323
343
|
function buildFrame(fiber) {
|
|
324
344
|
const type = fiber?.type;
|
|
325
345
|
if (typeof type !== "function" && typeof type !== "object") return null;
|
|
326
|
-
const name = type
|
|
346
|
+
const name = resolveComponentName(type);
|
|
327
347
|
if (!name || name === "Fragment") return null;
|
|
328
348
|
const frame = { name };
|
|
329
349
|
const source = getSourceFromFiber(fiber);
|
|
@@ -395,14 +415,7 @@ function getReactComponentInfo(element) {
|
|
|
395
415
|
}
|
|
396
416
|
return { ...getRenderStack(fiber), elementSourceFile };
|
|
397
417
|
}
|
|
398
|
-
var EXCLUDED_PROP_KEYS = /* @__PURE__ */ new Set([
|
|
399
|
-
"className",
|
|
400
|
-
"style",
|
|
401
|
-
"children",
|
|
402
|
-
"ref",
|
|
403
|
-
"key",
|
|
404
|
-
"render"
|
|
405
|
-
]);
|
|
418
|
+
var EXCLUDED_PROP_KEYS = /* @__PURE__ */ new Set(["className", "style", "children", "ref", "key", "render"]);
|
|
406
419
|
function serializePropValue(value) {
|
|
407
420
|
if (typeof value === "function") return "[function]";
|
|
408
421
|
if (typeof value === "symbol") return void 0;
|
|
@@ -513,19 +526,7 @@ function classifyComponentFiber(fiber, frames, elementSourceFile) {
|
|
|
513
526
|
return { isComponentPrimitive: false };
|
|
514
527
|
}
|
|
515
528
|
|
|
516
|
-
// src/utils.ts
|
|
517
|
-
function clamp(value, min, max) {
|
|
518
|
-
if (!Number.isFinite(value)) return min;
|
|
519
|
-
if (max < min) return min;
|
|
520
|
-
return Math.max(min, Math.min(max, value));
|
|
521
|
-
}
|
|
522
|
-
function isInputFocused() {
|
|
523
|
-
let active = document.activeElement;
|
|
524
|
-
while (active?.shadowRoot?.activeElement) {
|
|
525
|
-
active = active.shadowRoot.activeElement;
|
|
526
|
-
}
|
|
527
|
-
return active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement || active instanceof HTMLElement && active.isContentEditable;
|
|
528
|
-
}
|
|
529
|
+
// src/utils/computed-styles.ts
|
|
529
530
|
function getComputedStyles(element) {
|
|
530
531
|
const computed = window.getComputedStyle(element);
|
|
531
532
|
return {
|
|
@@ -634,6 +635,255 @@ function getOriginalInlineStyles(element) {
|
|
|
634
635
|
}
|
|
635
636
|
return styles;
|
|
636
637
|
}
|
|
638
|
+
function getComputedTypography(element) {
|
|
639
|
+
const computed = window.getComputedStyle(element);
|
|
640
|
+
let textVerticalAlign = "flex-start";
|
|
641
|
+
if (computed.display === "flex" || computed.display === "inline-flex") {
|
|
642
|
+
const alignItems = computed.alignItems;
|
|
643
|
+
if (alignItems === "center") textVerticalAlign = "center";
|
|
644
|
+
else if (alignItems === "flex-end" || alignItems === "end") textVerticalAlign = "flex-end";
|
|
645
|
+
}
|
|
646
|
+
const lineHeight = computed.lineHeight === "normal" ? {
|
|
647
|
+
numericValue: parseFloat(computed.fontSize) * 1.2,
|
|
648
|
+
unit: "px",
|
|
649
|
+
raw: `${Math.round(parseFloat(computed.fontSize) * 1.2)}px`
|
|
650
|
+
} : parsePropertyValue(computed.lineHeight);
|
|
651
|
+
const fontSize = parseFloat(computed.fontSize);
|
|
652
|
+
let letterSpacing;
|
|
653
|
+
if (computed.letterSpacing === "normal") {
|
|
654
|
+
letterSpacing = { numericValue: 0, unit: "em", raw: "0em" };
|
|
655
|
+
} else {
|
|
656
|
+
const parsed = parsePropertyValue(computed.letterSpacing);
|
|
657
|
+
if (parsed.unit === "px" && fontSize > 0) {
|
|
658
|
+
const emValue = Math.round(parsed.numericValue / fontSize * 100) / 100;
|
|
659
|
+
letterSpacing = { numericValue: emValue, unit: "em", raw: `${emValue}em` };
|
|
660
|
+
} else {
|
|
661
|
+
letterSpacing = parsed;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
return {
|
|
665
|
+
fontFamily: computed.fontFamily,
|
|
666
|
+
fontWeight: computed.fontWeight,
|
|
667
|
+
fontSize: parsePropertyValue(computed.fontSize),
|
|
668
|
+
lineHeight,
|
|
669
|
+
letterSpacing,
|
|
670
|
+
textAlign: computed.textAlign,
|
|
671
|
+
textVerticalAlign
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
function getComputedSizing(element) {
|
|
675
|
+
return {
|
|
676
|
+
width: getSizingValue(element, "width"),
|
|
677
|
+
height: getSizingValue(element, "height")
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
var TEXT_ELEMENT_TAGS = /* @__PURE__ */ new Set([
|
|
681
|
+
"p",
|
|
682
|
+
"h1",
|
|
683
|
+
"h2",
|
|
684
|
+
"h3",
|
|
685
|
+
"h4",
|
|
686
|
+
"h5",
|
|
687
|
+
"h6",
|
|
688
|
+
"span",
|
|
689
|
+
"label",
|
|
690
|
+
"a",
|
|
691
|
+
"strong",
|
|
692
|
+
"em",
|
|
693
|
+
"small",
|
|
694
|
+
"blockquote",
|
|
695
|
+
"li",
|
|
696
|
+
"td",
|
|
697
|
+
"th",
|
|
698
|
+
"caption",
|
|
699
|
+
"figcaption",
|
|
700
|
+
"legend",
|
|
701
|
+
"dt",
|
|
702
|
+
"dd",
|
|
703
|
+
"abbr",
|
|
704
|
+
"cite",
|
|
705
|
+
"code",
|
|
706
|
+
"pre"
|
|
707
|
+
]);
|
|
708
|
+
function hasDirectNonWhitespaceText(element) {
|
|
709
|
+
return Array.from(element.childNodes).some(
|
|
710
|
+
(node) => node.nodeType === Node.TEXT_NODE && Boolean(node.textContent?.trim())
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
var TRANSPARENT_COLOR = { hex: "000000", alpha: 0, raw: "transparent" };
|
|
714
|
+
function isVisibleBorderSide(side) {
|
|
715
|
+
return side.style !== "none" && side.style !== "hidden" && parseFloat(side.width) > 0;
|
|
716
|
+
}
|
|
717
|
+
function hasVisibleOutline(computed) {
|
|
718
|
+
return computed.outlineStyle !== "none" && parseFloat(computed.outlineWidth) > 0;
|
|
719
|
+
}
|
|
720
|
+
function parseVisibleColor(value, fallbackCurrentColor) {
|
|
721
|
+
const raw = value.trim();
|
|
722
|
+
const lowered = raw.toLowerCase();
|
|
723
|
+
if (!raw || lowered === "none" || lowered === "transparent") {
|
|
724
|
+
return null;
|
|
725
|
+
}
|
|
726
|
+
const resolved = /^currentcolor$/i.test(raw) ? fallbackCurrentColor ?? raw : raw;
|
|
727
|
+
const parsed = parseColorValue(resolved);
|
|
728
|
+
if (parsed.alpha <= 0) {
|
|
729
|
+
return null;
|
|
730
|
+
}
|
|
731
|
+
return parsed;
|
|
732
|
+
}
|
|
733
|
+
function addUniqueColor(colors, color) {
|
|
734
|
+
if (!color) return;
|
|
735
|
+
colors.set(`${color.hex}:${color.alpha}`, color);
|
|
736
|
+
}
|
|
737
|
+
function isTextRenderingFormControl(element) {
|
|
738
|
+
if (element instanceof HTMLTextAreaElement) return true;
|
|
739
|
+
if (element instanceof HTMLSelectElement) return true;
|
|
740
|
+
if (element instanceof HTMLButtonElement) return true;
|
|
741
|
+
if (element instanceof HTMLInputElement) {
|
|
742
|
+
const textlessInputTypes = /* @__PURE__ */ new Set([
|
|
743
|
+
"hidden",
|
|
744
|
+
"checkbox",
|
|
745
|
+
"radio",
|
|
746
|
+
"range",
|
|
747
|
+
"color",
|
|
748
|
+
"file",
|
|
749
|
+
"image"
|
|
750
|
+
]);
|
|
751
|
+
return !textlessInputTypes.has(element.type.toLowerCase());
|
|
752
|
+
}
|
|
753
|
+
return false;
|
|
754
|
+
}
|
|
755
|
+
function hasRenderableTextNode(element) {
|
|
756
|
+
if (element.isContentEditable) return true;
|
|
757
|
+
if (isTextRenderingFormControl(element)) return true;
|
|
758
|
+
if (!element.textContent?.trim()) return false;
|
|
759
|
+
if (hasDirectNonWhitespaceText(element)) return true;
|
|
760
|
+
const tagName = element.tagName.toLowerCase();
|
|
761
|
+
return TEXT_ELEMENT_TAGS.has(tagName) || element.children.length === 0;
|
|
762
|
+
}
|
|
763
|
+
function getComputedBoxShadow(element) {
|
|
764
|
+
const computed = window.getComputedStyle(element);
|
|
765
|
+
const value = computed.boxShadow.trim();
|
|
766
|
+
return value || "none";
|
|
767
|
+
}
|
|
768
|
+
function getComputedColorStyles(element) {
|
|
769
|
+
const computed = window.getComputedStyle(element);
|
|
770
|
+
const borderSides = [
|
|
771
|
+
{
|
|
772
|
+
style: computed.borderTopStyle,
|
|
773
|
+
width: computed.borderTopWidth,
|
|
774
|
+
color: computed.borderTopColor
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
style: computed.borderRightStyle,
|
|
778
|
+
width: computed.borderRightWidth,
|
|
779
|
+
color: computed.borderRightColor
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
style: computed.borderBottomStyle,
|
|
783
|
+
width: computed.borderBottomWidth,
|
|
784
|
+
color: computed.borderBottomColor
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
style: computed.borderLeftStyle,
|
|
788
|
+
width: computed.borderLeftWidth,
|
|
789
|
+
color: computed.borderLeftColor
|
|
790
|
+
}
|
|
791
|
+
];
|
|
792
|
+
const visibleBorderSide = borderSides.find((side) => isVisibleBorderSide(side));
|
|
793
|
+
const hasBorder = Boolean(visibleBorderSide);
|
|
794
|
+
const hasOutline = hasVisibleOutline(computed);
|
|
795
|
+
return {
|
|
796
|
+
backgroundColor: parseColorValue(computed.backgroundColor),
|
|
797
|
+
color: parseColorValue(computed.color),
|
|
798
|
+
borderColor: hasBorder && visibleBorderSide ? parseColorValue(visibleBorderSide.color) : TRANSPARENT_COLOR,
|
|
799
|
+
outlineColor: hasOutline ? parseColorValue(computed.outlineColor) : TRANSPARENT_COLOR
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
function getSelectionColors(element) {
|
|
803
|
+
const uniqueColors = /* @__PURE__ */ new Map();
|
|
804
|
+
const queue = [element];
|
|
805
|
+
for (let index = 0; index < queue.length; index++) {
|
|
806
|
+
const node = queue[index];
|
|
807
|
+
const computed = window.getComputedStyle(node);
|
|
808
|
+
if (computed.display === "none") {
|
|
809
|
+
continue;
|
|
810
|
+
}
|
|
811
|
+
const isVisibilityHidden = computed.visibility === "hidden" || computed.visibility === "collapse";
|
|
812
|
+
const currentTextColor = computed.color;
|
|
813
|
+
if (!isVisibilityHidden) {
|
|
814
|
+
addUniqueColor(uniqueColors, parseVisibleColor(computed.backgroundColor));
|
|
815
|
+
if (node instanceof HTMLElement && hasRenderableTextNode(node)) {
|
|
816
|
+
addUniqueColor(uniqueColors, parseVisibleColor(currentTextColor));
|
|
817
|
+
}
|
|
818
|
+
const borderSides = [
|
|
819
|
+
{
|
|
820
|
+
style: computed.borderTopStyle,
|
|
821
|
+
width: computed.borderTopWidth,
|
|
822
|
+
color: computed.borderTopColor
|
|
823
|
+
},
|
|
824
|
+
{
|
|
825
|
+
style: computed.borderRightStyle,
|
|
826
|
+
width: computed.borderRightWidth,
|
|
827
|
+
color: computed.borderRightColor
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
style: computed.borderBottomStyle,
|
|
831
|
+
width: computed.borderBottomWidth,
|
|
832
|
+
color: computed.borderBottomColor
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
style: computed.borderLeftStyle,
|
|
836
|
+
width: computed.borderLeftWidth,
|
|
837
|
+
color: computed.borderLeftColor
|
|
838
|
+
}
|
|
839
|
+
];
|
|
840
|
+
for (const side of borderSides) {
|
|
841
|
+
if (!isVisibleBorderSide(side)) continue;
|
|
842
|
+
addUniqueColor(uniqueColors, parseVisibleColor(side.color, currentTextColor));
|
|
843
|
+
}
|
|
844
|
+
if (hasVisibleOutline(computed)) {
|
|
845
|
+
addUniqueColor(uniqueColors, parseVisibleColor(computed.outlineColor, currentTextColor));
|
|
846
|
+
}
|
|
847
|
+
if (node instanceof SVGElement) {
|
|
848
|
+
const fillColor = parseVisibleColor(computed.getPropertyValue("fill"), currentTextColor) ?? parseVisibleColor(node.getAttribute("fill") ?? "", currentTextColor);
|
|
849
|
+
const strokeColor = parseVisibleColor(computed.getPropertyValue("stroke"), currentTextColor) ?? parseVisibleColor(node.getAttribute("stroke") ?? "", currentTextColor);
|
|
850
|
+
addUniqueColor(uniqueColors, fillColor);
|
|
851
|
+
addUniqueColor(uniqueColors, strokeColor);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
for (const child of node.children) {
|
|
855
|
+
queue.push(child);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
return Array.from(uniqueColors.values());
|
|
859
|
+
}
|
|
860
|
+
function getAllComputedStyles(element) {
|
|
861
|
+
const { spacing, borderRadius, flex } = getComputedStyles(element);
|
|
862
|
+
return {
|
|
863
|
+
spacing,
|
|
864
|
+
borderRadius,
|
|
865
|
+
border: getComputedBorderStyles(element),
|
|
866
|
+
flex,
|
|
867
|
+
sizing: getComputedSizing(element),
|
|
868
|
+
color: getComputedColorStyles(element),
|
|
869
|
+
boxShadow: getComputedBoxShadow(element),
|
|
870
|
+
typography: getComputedTypography(element)
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
// src/utils.ts
|
|
875
|
+
function clamp(value, min, max) {
|
|
876
|
+
if (!Number.isFinite(value)) return min;
|
|
877
|
+
if (max < min) return min;
|
|
878
|
+
return Math.max(min, Math.min(max, value));
|
|
879
|
+
}
|
|
880
|
+
function isInputFocused() {
|
|
881
|
+
let active = document.activeElement;
|
|
882
|
+
while (active?.shadowRoot?.activeElement) {
|
|
883
|
+
active = active.shadowRoot.activeElement;
|
|
884
|
+
}
|
|
885
|
+
return active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement || active instanceof HTMLElement && active.isContentEditable;
|
|
886
|
+
}
|
|
637
887
|
var spacingScale = { 0: "0", 1: "px", 2: "0.5", 4: "1", 8: "2", 12: "3", 16: "4", 20: "5", 24: "6", 32: "8" };
|
|
638
888
|
var tailwindClassMap = {
|
|
639
889
|
padding: { prefix: "p", scale: spacingScale },
|
|
@@ -960,7 +1210,7 @@ var typographyPropertyToCSSMap = {
|
|
|
960
1210
|
textAlign: "text-align",
|
|
961
1211
|
textVerticalAlign: "align-items"
|
|
962
1212
|
};
|
|
963
|
-
var
|
|
1213
|
+
var TEXT_ELEMENT_TAGS2 = /* @__PURE__ */ new Set([
|
|
964
1214
|
"p",
|
|
965
1215
|
"h1",
|
|
966
1216
|
"h2",
|
|
@@ -988,17 +1238,17 @@ var TEXT_ELEMENT_TAGS = /* @__PURE__ */ new Set([
|
|
|
988
1238
|
"code",
|
|
989
1239
|
"pre"
|
|
990
1240
|
]);
|
|
991
|
-
function
|
|
1241
|
+
function hasDirectNonWhitespaceText2(element) {
|
|
992
1242
|
return Array.from(element.childNodes).some(
|
|
993
1243
|
(node) => node.nodeType === Node.TEXT_NODE && Boolean(node.textContent?.trim())
|
|
994
1244
|
);
|
|
995
1245
|
}
|
|
996
1246
|
function isTextElement2(element) {
|
|
997
1247
|
const tagName = element.tagName.toLowerCase();
|
|
998
|
-
if (
|
|
1248
|
+
if (TEXT_ELEMENT_TAGS2.has(tagName)) {
|
|
999
1249
|
return true;
|
|
1000
1250
|
}
|
|
1001
|
-
if (
|
|
1251
|
+
if (hasDirectNonWhitespaceText2(element)) {
|
|
1002
1252
|
return true;
|
|
1003
1253
|
}
|
|
1004
1254
|
if (element.children.length === 0 && element.textContent?.trim()) {
|
|
@@ -1006,38 +1256,6 @@ function isTextElement2(element) {
|
|
|
1006
1256
|
}
|
|
1007
1257
|
return false;
|
|
1008
1258
|
}
|
|
1009
|
-
function getComputedTypography(element) {
|
|
1010
|
-
const computed = window.getComputedStyle(element);
|
|
1011
|
-
let textVerticalAlign = "flex-start";
|
|
1012
|
-
if (computed.display === "flex" || computed.display === "inline-flex") {
|
|
1013
|
-
const alignItems = computed.alignItems;
|
|
1014
|
-
if (alignItems === "center") textVerticalAlign = "center";
|
|
1015
|
-
else if (alignItems === "flex-end" || alignItems === "end") textVerticalAlign = "flex-end";
|
|
1016
|
-
}
|
|
1017
|
-
const lineHeight = computed.lineHeight === "normal" ? { numericValue: parseFloat(computed.fontSize) * 1.2, unit: "px", raw: `${Math.round(parseFloat(computed.fontSize) * 1.2)}px` } : parsePropertyValue(computed.lineHeight);
|
|
1018
|
-
const fontSize = parseFloat(computed.fontSize);
|
|
1019
|
-
let letterSpacing;
|
|
1020
|
-
if (computed.letterSpacing === "normal") {
|
|
1021
|
-
letterSpacing = { numericValue: 0, unit: "em", raw: "0em" };
|
|
1022
|
-
} else {
|
|
1023
|
-
const parsed = parsePropertyValue(computed.letterSpacing);
|
|
1024
|
-
if (parsed.unit === "px" && fontSize > 0) {
|
|
1025
|
-
const emValue = Math.round(parsed.numericValue / fontSize * 100) / 100;
|
|
1026
|
-
letterSpacing = { numericValue: emValue, unit: "em", raw: `${emValue}em` };
|
|
1027
|
-
} else {
|
|
1028
|
-
letterSpacing = parsed;
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
return {
|
|
1032
|
-
fontFamily: computed.fontFamily,
|
|
1033
|
-
fontWeight: computed.fontWeight,
|
|
1034
|
-
fontSize: parsePropertyValue(computed.fontSize),
|
|
1035
|
-
lineHeight,
|
|
1036
|
-
letterSpacing,
|
|
1037
|
-
textAlign: computed.textAlign,
|
|
1038
|
-
textVerticalAlign
|
|
1039
|
-
};
|
|
1040
|
-
}
|
|
1041
1259
|
function detectSizingMode(element, dimension) {
|
|
1042
1260
|
const computed = window.getComputedStyle(element);
|
|
1043
1261
|
const inlineValue = element.style[dimension];
|
|
@@ -1085,12 +1303,6 @@ function getSizingValue(element, dimension) {
|
|
|
1085
1303
|
}
|
|
1086
1304
|
};
|
|
1087
1305
|
}
|
|
1088
|
-
function getComputedSizing(element) {
|
|
1089
|
-
return {
|
|
1090
|
-
width: getSizingValue(element, "width"),
|
|
1091
|
-
height: getSizingValue(element, "height")
|
|
1092
|
-
};
|
|
1093
|
-
}
|
|
1094
1306
|
function sizingValueToCSS(sizing) {
|
|
1095
1307
|
switch (sizing.mode) {
|
|
1096
1308
|
case "fill":
|
|
@@ -1210,134 +1422,6 @@ function parseColorValue(cssValue) {
|
|
|
1210
1422
|
}
|
|
1211
1423
|
return parseNamedColor(raw);
|
|
1212
1424
|
}
|
|
1213
|
-
var TRANSPARENT_COLOR = { hex: "000000", alpha: 0, raw: "transparent" };
|
|
1214
|
-
function isVisibleBorderSide(side) {
|
|
1215
|
-
return side.style !== "none" && side.style !== "hidden" && parseFloat(side.width) > 0;
|
|
1216
|
-
}
|
|
1217
|
-
function hasVisibleOutline(computed) {
|
|
1218
|
-
return computed.outlineStyle !== "none" && parseFloat(computed.outlineWidth) > 0;
|
|
1219
|
-
}
|
|
1220
|
-
function parseVisibleColor(value, fallbackCurrentColor) {
|
|
1221
|
-
const raw = value.trim();
|
|
1222
|
-
const lowered = raw.toLowerCase();
|
|
1223
|
-
if (!raw || lowered === "none" || lowered === "transparent") {
|
|
1224
|
-
return null;
|
|
1225
|
-
}
|
|
1226
|
-
const resolved = /^currentcolor$/i.test(raw) ? fallbackCurrentColor ?? raw : raw;
|
|
1227
|
-
const parsed = parseColorValue(resolved);
|
|
1228
|
-
if (parsed.alpha <= 0) {
|
|
1229
|
-
return null;
|
|
1230
|
-
}
|
|
1231
|
-
return parsed;
|
|
1232
|
-
}
|
|
1233
|
-
function addUniqueColor(colors, color) {
|
|
1234
|
-
if (!color) return;
|
|
1235
|
-
colors.set(`${color.hex}:${color.alpha}`, color);
|
|
1236
|
-
}
|
|
1237
|
-
function isTextRenderingFormControl(element) {
|
|
1238
|
-
if (element instanceof HTMLTextAreaElement) return true;
|
|
1239
|
-
if (element instanceof HTMLSelectElement) return true;
|
|
1240
|
-
if (element instanceof HTMLButtonElement) return true;
|
|
1241
|
-
if (element instanceof HTMLInputElement) {
|
|
1242
|
-
const textlessInputTypes = /* @__PURE__ */ new Set([
|
|
1243
|
-
"hidden",
|
|
1244
|
-
"checkbox",
|
|
1245
|
-
"radio",
|
|
1246
|
-
"range",
|
|
1247
|
-
"color",
|
|
1248
|
-
"file",
|
|
1249
|
-
"image"
|
|
1250
|
-
]);
|
|
1251
|
-
return !textlessInputTypes.has(element.type.toLowerCase());
|
|
1252
|
-
}
|
|
1253
|
-
return false;
|
|
1254
|
-
}
|
|
1255
|
-
function hasRenderableTextNode(element) {
|
|
1256
|
-
if (element.isContentEditable) return true;
|
|
1257
|
-
if (isTextRenderingFormControl(element)) return true;
|
|
1258
|
-
if (!element.textContent?.trim()) return false;
|
|
1259
|
-
if (hasDirectNonWhitespaceText(element)) return true;
|
|
1260
|
-
const tagName = element.tagName.toLowerCase();
|
|
1261
|
-
return TEXT_ELEMENT_TAGS.has(tagName) || element.children.length === 0;
|
|
1262
|
-
}
|
|
1263
|
-
function getComputedBoxShadow(element) {
|
|
1264
|
-
const computed = window.getComputedStyle(element);
|
|
1265
|
-
const value = computed.boxShadow.trim();
|
|
1266
|
-
return value || "none";
|
|
1267
|
-
}
|
|
1268
|
-
function getComputedColorStyles(element) {
|
|
1269
|
-
const computed = window.getComputedStyle(element);
|
|
1270
|
-
const borderSides = [
|
|
1271
|
-
{ style: computed.borderTopStyle, width: computed.borderTopWidth, color: computed.borderTopColor },
|
|
1272
|
-
{ style: computed.borderRightStyle, width: computed.borderRightWidth, color: computed.borderRightColor },
|
|
1273
|
-
{ style: computed.borderBottomStyle, width: computed.borderBottomWidth, color: computed.borderBottomColor },
|
|
1274
|
-
{ style: computed.borderLeftStyle, width: computed.borderLeftWidth, color: computed.borderLeftColor }
|
|
1275
|
-
];
|
|
1276
|
-
const visibleBorderSide = borderSides.find((side) => isVisibleBorderSide(side));
|
|
1277
|
-
const hasBorder = Boolean(visibleBorderSide);
|
|
1278
|
-
const hasOutline = hasVisibleOutline(computed);
|
|
1279
|
-
return {
|
|
1280
|
-
backgroundColor: parseColorValue(computed.backgroundColor),
|
|
1281
|
-
color: parseColorValue(computed.color),
|
|
1282
|
-
borderColor: hasBorder && visibleBorderSide ? parseColorValue(visibleBorderSide.color) : TRANSPARENT_COLOR,
|
|
1283
|
-
outlineColor: hasOutline ? parseColorValue(computed.outlineColor) : TRANSPARENT_COLOR
|
|
1284
|
-
};
|
|
1285
|
-
}
|
|
1286
|
-
function getSelectionColors(element) {
|
|
1287
|
-
const uniqueColors = /* @__PURE__ */ new Map();
|
|
1288
|
-
const queue = [element];
|
|
1289
|
-
for (let index = 0; index < queue.length; index++) {
|
|
1290
|
-
const node = queue[index];
|
|
1291
|
-
const computed = window.getComputedStyle(node);
|
|
1292
|
-
if (computed.display === "none") {
|
|
1293
|
-
continue;
|
|
1294
|
-
}
|
|
1295
|
-
const isVisibilityHidden = computed.visibility === "hidden" || computed.visibility === "collapse";
|
|
1296
|
-
const currentTextColor = computed.color;
|
|
1297
|
-
if (!isVisibilityHidden) {
|
|
1298
|
-
addUniqueColor(uniqueColors, parseVisibleColor(computed.backgroundColor));
|
|
1299
|
-
if (node instanceof HTMLElement && hasRenderableTextNode(node)) {
|
|
1300
|
-
addUniqueColor(uniqueColors, parseVisibleColor(currentTextColor));
|
|
1301
|
-
}
|
|
1302
|
-
const borderSides = [
|
|
1303
|
-
{ style: computed.borderTopStyle, width: computed.borderTopWidth, color: computed.borderTopColor },
|
|
1304
|
-
{ style: computed.borderRightStyle, width: computed.borderRightWidth, color: computed.borderRightColor },
|
|
1305
|
-
{ style: computed.borderBottomStyle, width: computed.borderBottomWidth, color: computed.borderBottomColor },
|
|
1306
|
-
{ style: computed.borderLeftStyle, width: computed.borderLeftWidth, color: computed.borderLeftColor }
|
|
1307
|
-
];
|
|
1308
|
-
for (const side of borderSides) {
|
|
1309
|
-
if (!isVisibleBorderSide(side)) continue;
|
|
1310
|
-
addUniqueColor(uniqueColors, parseVisibleColor(side.color, currentTextColor));
|
|
1311
|
-
}
|
|
1312
|
-
if (hasVisibleOutline(computed)) {
|
|
1313
|
-
addUniqueColor(uniqueColors, parseVisibleColor(computed.outlineColor, currentTextColor));
|
|
1314
|
-
}
|
|
1315
|
-
if (node instanceof SVGElement) {
|
|
1316
|
-
const fillColor = parseVisibleColor(computed.getPropertyValue("fill"), currentTextColor) ?? parseVisibleColor(node.getAttribute("fill") ?? "", currentTextColor);
|
|
1317
|
-
const strokeColor = parseVisibleColor(computed.getPropertyValue("stroke"), currentTextColor) ?? parseVisibleColor(node.getAttribute("stroke") ?? "", currentTextColor);
|
|
1318
|
-
addUniqueColor(uniqueColors, fillColor);
|
|
1319
|
-
addUniqueColor(uniqueColors, strokeColor);
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
for (const child of node.children) {
|
|
1323
|
-
queue.push(child);
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
return Array.from(uniqueColors.values());
|
|
1327
|
-
}
|
|
1328
|
-
function getAllComputedStyles(element) {
|
|
1329
|
-
const { spacing, borderRadius, flex } = getComputedStyles(element);
|
|
1330
|
-
return {
|
|
1331
|
-
spacing,
|
|
1332
|
-
borderRadius,
|
|
1333
|
-
border: getComputedBorderStyles(element),
|
|
1334
|
-
flex,
|
|
1335
|
-
sizing: getComputedSizing(element),
|
|
1336
|
-
color: getComputedColorStyles(element),
|
|
1337
|
-
boxShadow: getComputedBoxShadow(element),
|
|
1338
|
-
typography: getComputedTypography(element)
|
|
1339
|
-
};
|
|
1340
|
-
}
|
|
1341
1425
|
var colorPropertyToCSSMap = {
|
|
1342
1426
|
backgroundColor: "background-color",
|
|
1343
1427
|
color: "color",
|
|
@@ -1850,7 +1934,7 @@ function findChildAtPoint(parent, clientX, clientY) {
|
|
|
1850
1934
|
return clientX >= r.left && clientX <= r.right && clientY >= r.top && clientY <= r.bottom;
|
|
1851
1935
|
});
|
|
1852
1936
|
if (hit) return hit;
|
|
1853
|
-
if (children.length === 1 && !
|
|
1937
|
+
if (children.length === 1 && !hasDirectNonWhitespaceText2(parent)) return children[0];
|
|
1854
1938
|
return null;
|
|
1855
1939
|
}
|
|
1856
1940
|
function elementFromPointWithoutOverlays(x, y) {
|
|
@@ -2411,7 +2495,7 @@ function buildElementContext(locator) {
|
|
|
2411
2495
|
return buildLocatorContextLines(locator).join("\n");
|
|
2412
2496
|
}
|
|
2413
2497
|
function hasSessionEditChanges(edit) {
|
|
2414
|
-
return Object.keys(edit.pendingStyles).length > 0 || Boolean(edit.textEdit) || Boolean(edit.move);
|
|
2498
|
+
return Object.keys(edit.pendingStyles).length > 0 || Boolean(edit.textEdit) || Boolean(edit.move) || Boolean(edit.deleted);
|
|
2415
2499
|
}
|
|
2416
2500
|
function partitionMultiSelectedEdits(elements, sessionEditsRef) {
|
|
2417
2501
|
const editsWithChanges = [];
|
|
@@ -2933,7 +3017,7 @@ function buildMoveEntries(edits) {
|
|
|
2933
3017
|
let noopMoveCount = 0;
|
|
2934
3018
|
for (const edit of edits) {
|
|
2935
3019
|
const move = edit.move;
|
|
2936
|
-
if (!move) continue;
|
|
3020
|
+
if (!move || edit.deleted) continue;
|
|
2937
3021
|
const subject = buildAnchorRef(
|
|
2938
3022
|
getElementDisplayName(edit.element) || edit.locator.tagName,
|
|
2939
3023
|
edit.locator.domSelector,
|
|
@@ -3101,19 +3185,22 @@ function getExportContentProfile(edits, comments, movePlanOrContext) {
|
|
|
3101
3185
|
hasCssEdits: edits.some((e) => Object.keys(e.pendingStyles).length > 0),
|
|
3102
3186
|
hasTextEdits: edits.some((e) => e.textEdit != null),
|
|
3103
3187
|
hasMoves: moveOpCount > 0,
|
|
3104
|
-
hasComments: comments.length > 0
|
|
3188
|
+
hasComments: comments.length > 0,
|
|
3189
|
+
hasDeletes: edits.some((e) => e.deleted)
|
|
3105
3190
|
};
|
|
3106
3191
|
}
|
|
3107
3192
|
function buildExportInstruction(profile) {
|
|
3108
3193
|
const { hasCssEdits, hasTextEdits, hasMoves, hasComments } = profile;
|
|
3109
|
-
|
|
3110
|
-
if (!hasCssEdits && !hasTextEdits && !hasMoves)
|
|
3194
|
+
const hasDeletes = Boolean(profile.hasDeletes);
|
|
3195
|
+
if (!hasCssEdits && !hasTextEdits && !hasMoves && !hasComments && !hasDeletes) return "";
|
|
3196
|
+
if (!hasCssEdits && !hasTextEdits && !hasMoves && !hasDeletes) {
|
|
3111
3197
|
return hasComments ? "Address this feedback on the UI. Use the provided source location and selector to find each element in the codebase." : "";
|
|
3112
3198
|
}
|
|
3113
3199
|
const parts = [];
|
|
3114
3200
|
if (hasCssEdits) parts.push("Apply the CSS changes to the targeted elements using the project's existing styling approach (Tailwind, CSS modules, etc.). Map values to existing CSS variables, design tokens, or utility classes already used in the project whenever possible.");
|
|
3115
3201
|
if (hasTextEdits) parts.push("Update the text content as specified.");
|
|
3116
3202
|
if (hasMoves) parts.push("Implement the move plan below directly in source code. For `structural_move`, reorder/reparent elements using the target anchors. For `layout_refactor`, apply the listed flex/grid refactor steps. Do NOT simulate movement with absolute positioning, left/top offsets, transform, or margin hacks.");
|
|
3203
|
+
if (hasDeletes) parts.push("Delete the elements marked for deletion from the source code \u2014 remove their markup/JSX (and any now-dead props, handlers, or imports they solely used).");
|
|
3117
3204
|
if (hasComments) parts.push("Address the comments on the relevant elements.");
|
|
3118
3205
|
return `${parts.join(" ")} Use the provided source locations, selectors, and context HTML to locate each element in the codebase.`;
|
|
3119
3206
|
}
|
|
@@ -3148,6 +3235,13 @@ function buildSessionExport(edits, comments = [], options) {
|
|
|
3148
3235
|
blocks.push(planLines.join("\n"));
|
|
3149
3236
|
}
|
|
3150
3237
|
for (const edit of edits) {
|
|
3238
|
+
if (edit.deleted) {
|
|
3239
|
+
const lines = buildLocatorContextLines(edit.locator);
|
|
3240
|
+
lines.push("");
|
|
3241
|
+
lines.push("action: delete this element \u2014 remove it from the source");
|
|
3242
|
+
blocks.push(lines.join("\n"));
|
|
3243
|
+
continue;
|
|
3244
|
+
}
|
|
3151
3245
|
const moveIntent = getMoveIntentForEdit(edit, planContext);
|
|
3152
3246
|
const hasMove = Boolean(moveIntent);
|
|
3153
3247
|
const hasStyleOrText = Object.keys(edit.pendingStyles).length > 0 || edit.textEdit != null;
|