made-refine 0.2.21 → 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/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +998 -715
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +998 -715
- package/dist/index.mjs.map +1 -1
- package/dist/preload/preload.js +3 -1
- package/dist/preload.js +3 -1
- package/dist/preload.js.map +1 -1
- package/dist/preload.mjs +3 -1
- package/dist/preload.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/{utils-Byovnuwg.d.mts → utils-ovHeRo0g.d.mts} +16 -15
- package/dist/{utils-Byovnuwg.d.ts → utils-ovHeRo0g.d.ts} +16 -15
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +256 -192
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +256 -192
- package/dist/utils.mjs.map +1 -1
- package/package.json +12 -1
package/dist/utils.js
CHANGED
|
@@ -510,14 +510,7 @@ function getReactComponentInfo(element) {
|
|
|
510
510
|
}
|
|
511
511
|
return { ...getRenderStack(fiber), elementSourceFile };
|
|
512
512
|
}
|
|
513
|
-
var EXCLUDED_PROP_KEYS = /* @__PURE__ */ new Set([
|
|
514
|
-
"className",
|
|
515
|
-
"style",
|
|
516
|
-
"children",
|
|
517
|
-
"ref",
|
|
518
|
-
"key",
|
|
519
|
-
"render"
|
|
520
|
-
]);
|
|
513
|
+
var EXCLUDED_PROP_KEYS = /* @__PURE__ */ new Set(["className", "style", "children", "ref", "key", "render"]);
|
|
521
514
|
function serializePropValue(value) {
|
|
522
515
|
if (typeof value === "function") return "[function]";
|
|
523
516
|
if (typeof value === "symbol") return void 0;
|
|
@@ -628,19 +621,7 @@ function classifyComponentFiber(fiber, frames, elementSourceFile) {
|
|
|
628
621
|
return { isComponentPrimitive: false };
|
|
629
622
|
}
|
|
630
623
|
|
|
631
|
-
// src/utils.ts
|
|
632
|
-
function clamp(value, min, max) {
|
|
633
|
-
if (!Number.isFinite(value)) return min;
|
|
634
|
-
if (max < min) return min;
|
|
635
|
-
return Math.max(min, Math.min(max, value));
|
|
636
|
-
}
|
|
637
|
-
function isInputFocused() {
|
|
638
|
-
let active = document.activeElement;
|
|
639
|
-
while (active?.shadowRoot?.activeElement) {
|
|
640
|
-
active = active.shadowRoot.activeElement;
|
|
641
|
-
}
|
|
642
|
-
return active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement || active instanceof HTMLElement && active.isContentEditable;
|
|
643
|
-
}
|
|
624
|
+
// src/utils/computed-styles.ts
|
|
644
625
|
function getComputedStyles(element) {
|
|
645
626
|
const computed = window.getComputedStyle(element);
|
|
646
627
|
return {
|
|
@@ -749,6 +730,255 @@ function getOriginalInlineStyles(element) {
|
|
|
749
730
|
}
|
|
750
731
|
return styles;
|
|
751
732
|
}
|
|
733
|
+
function getComputedTypography(element) {
|
|
734
|
+
const computed = window.getComputedStyle(element);
|
|
735
|
+
let textVerticalAlign = "flex-start";
|
|
736
|
+
if (computed.display === "flex" || computed.display === "inline-flex") {
|
|
737
|
+
const alignItems = computed.alignItems;
|
|
738
|
+
if (alignItems === "center") textVerticalAlign = "center";
|
|
739
|
+
else if (alignItems === "flex-end" || alignItems === "end") textVerticalAlign = "flex-end";
|
|
740
|
+
}
|
|
741
|
+
const lineHeight = computed.lineHeight === "normal" ? {
|
|
742
|
+
numericValue: parseFloat(computed.fontSize) * 1.2,
|
|
743
|
+
unit: "px",
|
|
744
|
+
raw: `${Math.round(parseFloat(computed.fontSize) * 1.2)}px`
|
|
745
|
+
} : parsePropertyValue(computed.lineHeight);
|
|
746
|
+
const fontSize = parseFloat(computed.fontSize);
|
|
747
|
+
let letterSpacing;
|
|
748
|
+
if (computed.letterSpacing === "normal") {
|
|
749
|
+
letterSpacing = { numericValue: 0, unit: "em", raw: "0em" };
|
|
750
|
+
} else {
|
|
751
|
+
const parsed = parsePropertyValue(computed.letterSpacing);
|
|
752
|
+
if (parsed.unit === "px" && fontSize > 0) {
|
|
753
|
+
const emValue = Math.round(parsed.numericValue / fontSize * 100) / 100;
|
|
754
|
+
letterSpacing = { numericValue: emValue, unit: "em", raw: `${emValue}em` };
|
|
755
|
+
} else {
|
|
756
|
+
letterSpacing = parsed;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
return {
|
|
760
|
+
fontFamily: computed.fontFamily,
|
|
761
|
+
fontWeight: computed.fontWeight,
|
|
762
|
+
fontSize: parsePropertyValue(computed.fontSize),
|
|
763
|
+
lineHeight,
|
|
764
|
+
letterSpacing,
|
|
765
|
+
textAlign: computed.textAlign,
|
|
766
|
+
textVerticalAlign
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
function getComputedSizing(element) {
|
|
770
|
+
return {
|
|
771
|
+
width: getSizingValue(element, "width"),
|
|
772
|
+
height: getSizingValue(element, "height")
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
var TEXT_ELEMENT_TAGS = /* @__PURE__ */ new Set([
|
|
776
|
+
"p",
|
|
777
|
+
"h1",
|
|
778
|
+
"h2",
|
|
779
|
+
"h3",
|
|
780
|
+
"h4",
|
|
781
|
+
"h5",
|
|
782
|
+
"h6",
|
|
783
|
+
"span",
|
|
784
|
+
"label",
|
|
785
|
+
"a",
|
|
786
|
+
"strong",
|
|
787
|
+
"em",
|
|
788
|
+
"small",
|
|
789
|
+
"blockquote",
|
|
790
|
+
"li",
|
|
791
|
+
"td",
|
|
792
|
+
"th",
|
|
793
|
+
"caption",
|
|
794
|
+
"figcaption",
|
|
795
|
+
"legend",
|
|
796
|
+
"dt",
|
|
797
|
+
"dd",
|
|
798
|
+
"abbr",
|
|
799
|
+
"cite",
|
|
800
|
+
"code",
|
|
801
|
+
"pre"
|
|
802
|
+
]);
|
|
803
|
+
function hasDirectNonWhitespaceText(element) {
|
|
804
|
+
return Array.from(element.childNodes).some(
|
|
805
|
+
(node) => node.nodeType === Node.TEXT_NODE && Boolean(node.textContent?.trim())
|
|
806
|
+
);
|
|
807
|
+
}
|
|
808
|
+
var TRANSPARENT_COLOR = { hex: "000000", alpha: 0, raw: "transparent" };
|
|
809
|
+
function isVisibleBorderSide(side) {
|
|
810
|
+
return side.style !== "none" && side.style !== "hidden" && parseFloat(side.width) > 0;
|
|
811
|
+
}
|
|
812
|
+
function hasVisibleOutline(computed) {
|
|
813
|
+
return computed.outlineStyle !== "none" && parseFloat(computed.outlineWidth) > 0;
|
|
814
|
+
}
|
|
815
|
+
function parseVisibleColor(value, fallbackCurrentColor) {
|
|
816
|
+
const raw = value.trim();
|
|
817
|
+
const lowered = raw.toLowerCase();
|
|
818
|
+
if (!raw || lowered === "none" || lowered === "transparent") {
|
|
819
|
+
return null;
|
|
820
|
+
}
|
|
821
|
+
const resolved = /^currentcolor$/i.test(raw) ? fallbackCurrentColor ?? raw : raw;
|
|
822
|
+
const parsed = parseColorValue(resolved);
|
|
823
|
+
if (parsed.alpha <= 0) {
|
|
824
|
+
return null;
|
|
825
|
+
}
|
|
826
|
+
return parsed;
|
|
827
|
+
}
|
|
828
|
+
function addUniqueColor(colors, color) {
|
|
829
|
+
if (!color) return;
|
|
830
|
+
colors.set(`${color.hex}:${color.alpha}`, color);
|
|
831
|
+
}
|
|
832
|
+
function isTextRenderingFormControl(element) {
|
|
833
|
+
if (element instanceof HTMLTextAreaElement) return true;
|
|
834
|
+
if (element instanceof HTMLSelectElement) return true;
|
|
835
|
+
if (element instanceof HTMLButtonElement) return true;
|
|
836
|
+
if (element instanceof HTMLInputElement) {
|
|
837
|
+
const textlessInputTypes = /* @__PURE__ */ new Set([
|
|
838
|
+
"hidden",
|
|
839
|
+
"checkbox",
|
|
840
|
+
"radio",
|
|
841
|
+
"range",
|
|
842
|
+
"color",
|
|
843
|
+
"file",
|
|
844
|
+
"image"
|
|
845
|
+
]);
|
|
846
|
+
return !textlessInputTypes.has(element.type.toLowerCase());
|
|
847
|
+
}
|
|
848
|
+
return false;
|
|
849
|
+
}
|
|
850
|
+
function hasRenderableTextNode(element) {
|
|
851
|
+
if (element.isContentEditable) return true;
|
|
852
|
+
if (isTextRenderingFormControl(element)) return true;
|
|
853
|
+
if (!element.textContent?.trim()) return false;
|
|
854
|
+
if (hasDirectNonWhitespaceText(element)) return true;
|
|
855
|
+
const tagName = element.tagName.toLowerCase();
|
|
856
|
+
return TEXT_ELEMENT_TAGS.has(tagName) || element.children.length === 0;
|
|
857
|
+
}
|
|
858
|
+
function getComputedBoxShadow(element) {
|
|
859
|
+
const computed = window.getComputedStyle(element);
|
|
860
|
+
const value = computed.boxShadow.trim();
|
|
861
|
+
return value || "none";
|
|
862
|
+
}
|
|
863
|
+
function getComputedColorStyles(element) {
|
|
864
|
+
const computed = window.getComputedStyle(element);
|
|
865
|
+
const borderSides = [
|
|
866
|
+
{
|
|
867
|
+
style: computed.borderTopStyle,
|
|
868
|
+
width: computed.borderTopWidth,
|
|
869
|
+
color: computed.borderTopColor
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
style: computed.borderRightStyle,
|
|
873
|
+
width: computed.borderRightWidth,
|
|
874
|
+
color: computed.borderRightColor
|
|
875
|
+
},
|
|
876
|
+
{
|
|
877
|
+
style: computed.borderBottomStyle,
|
|
878
|
+
width: computed.borderBottomWidth,
|
|
879
|
+
color: computed.borderBottomColor
|
|
880
|
+
},
|
|
881
|
+
{
|
|
882
|
+
style: computed.borderLeftStyle,
|
|
883
|
+
width: computed.borderLeftWidth,
|
|
884
|
+
color: computed.borderLeftColor
|
|
885
|
+
}
|
|
886
|
+
];
|
|
887
|
+
const visibleBorderSide = borderSides.find((side) => isVisibleBorderSide(side));
|
|
888
|
+
const hasBorder = Boolean(visibleBorderSide);
|
|
889
|
+
const hasOutline = hasVisibleOutline(computed);
|
|
890
|
+
return {
|
|
891
|
+
backgroundColor: parseColorValue(computed.backgroundColor),
|
|
892
|
+
color: parseColorValue(computed.color),
|
|
893
|
+
borderColor: hasBorder && visibleBorderSide ? parseColorValue(visibleBorderSide.color) : TRANSPARENT_COLOR,
|
|
894
|
+
outlineColor: hasOutline ? parseColorValue(computed.outlineColor) : TRANSPARENT_COLOR
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
function getSelectionColors(element) {
|
|
898
|
+
const uniqueColors = /* @__PURE__ */ new Map();
|
|
899
|
+
const queue = [element];
|
|
900
|
+
for (let index = 0; index < queue.length; index++) {
|
|
901
|
+
const node = queue[index];
|
|
902
|
+
const computed = window.getComputedStyle(node);
|
|
903
|
+
if (computed.display === "none") {
|
|
904
|
+
continue;
|
|
905
|
+
}
|
|
906
|
+
const isVisibilityHidden = computed.visibility === "hidden" || computed.visibility === "collapse";
|
|
907
|
+
const currentTextColor = computed.color;
|
|
908
|
+
if (!isVisibilityHidden) {
|
|
909
|
+
addUniqueColor(uniqueColors, parseVisibleColor(computed.backgroundColor));
|
|
910
|
+
if (node instanceof HTMLElement && hasRenderableTextNode(node)) {
|
|
911
|
+
addUniqueColor(uniqueColors, parseVisibleColor(currentTextColor));
|
|
912
|
+
}
|
|
913
|
+
const borderSides = [
|
|
914
|
+
{
|
|
915
|
+
style: computed.borderTopStyle,
|
|
916
|
+
width: computed.borderTopWidth,
|
|
917
|
+
color: computed.borderTopColor
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
style: computed.borderRightStyle,
|
|
921
|
+
width: computed.borderRightWidth,
|
|
922
|
+
color: computed.borderRightColor
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
style: computed.borderBottomStyle,
|
|
926
|
+
width: computed.borderBottomWidth,
|
|
927
|
+
color: computed.borderBottomColor
|
|
928
|
+
},
|
|
929
|
+
{
|
|
930
|
+
style: computed.borderLeftStyle,
|
|
931
|
+
width: computed.borderLeftWidth,
|
|
932
|
+
color: computed.borderLeftColor
|
|
933
|
+
}
|
|
934
|
+
];
|
|
935
|
+
for (const side of borderSides) {
|
|
936
|
+
if (!isVisibleBorderSide(side)) continue;
|
|
937
|
+
addUniqueColor(uniqueColors, parseVisibleColor(side.color, currentTextColor));
|
|
938
|
+
}
|
|
939
|
+
if (hasVisibleOutline(computed)) {
|
|
940
|
+
addUniqueColor(uniqueColors, parseVisibleColor(computed.outlineColor, currentTextColor));
|
|
941
|
+
}
|
|
942
|
+
if (node instanceof SVGElement) {
|
|
943
|
+
const fillColor = parseVisibleColor(computed.getPropertyValue("fill"), currentTextColor) ?? parseVisibleColor(node.getAttribute("fill") ?? "", currentTextColor);
|
|
944
|
+
const strokeColor = parseVisibleColor(computed.getPropertyValue("stroke"), currentTextColor) ?? parseVisibleColor(node.getAttribute("stroke") ?? "", currentTextColor);
|
|
945
|
+
addUniqueColor(uniqueColors, fillColor);
|
|
946
|
+
addUniqueColor(uniqueColors, strokeColor);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
for (const child of node.children) {
|
|
950
|
+
queue.push(child);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
return Array.from(uniqueColors.values());
|
|
954
|
+
}
|
|
955
|
+
function getAllComputedStyles(element) {
|
|
956
|
+
const { spacing, borderRadius, flex } = getComputedStyles(element);
|
|
957
|
+
return {
|
|
958
|
+
spacing,
|
|
959
|
+
borderRadius,
|
|
960
|
+
border: getComputedBorderStyles(element),
|
|
961
|
+
flex,
|
|
962
|
+
sizing: getComputedSizing(element),
|
|
963
|
+
color: getComputedColorStyles(element),
|
|
964
|
+
boxShadow: getComputedBoxShadow(element),
|
|
965
|
+
typography: getComputedTypography(element)
|
|
966
|
+
};
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
// src/utils.ts
|
|
970
|
+
function clamp(value, min, max) {
|
|
971
|
+
if (!Number.isFinite(value)) return min;
|
|
972
|
+
if (max < min) return min;
|
|
973
|
+
return Math.max(min, Math.min(max, value));
|
|
974
|
+
}
|
|
975
|
+
function isInputFocused() {
|
|
976
|
+
let active = document.activeElement;
|
|
977
|
+
while (active?.shadowRoot?.activeElement) {
|
|
978
|
+
active = active.shadowRoot.activeElement;
|
|
979
|
+
}
|
|
980
|
+
return active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement || active instanceof HTMLElement && active.isContentEditable;
|
|
981
|
+
}
|
|
752
982
|
var spacingScale = { 0: "0", 1: "px", 2: "0.5", 4: "1", 8: "2", 12: "3", 16: "4", 20: "5", 24: "6", 32: "8" };
|
|
753
983
|
var tailwindClassMap = {
|
|
754
984
|
padding: { prefix: "p", scale: spacingScale },
|
|
@@ -1075,7 +1305,7 @@ var typographyPropertyToCSSMap = {
|
|
|
1075
1305
|
textAlign: "text-align",
|
|
1076
1306
|
textVerticalAlign: "align-items"
|
|
1077
1307
|
};
|
|
1078
|
-
var
|
|
1308
|
+
var TEXT_ELEMENT_TAGS2 = /* @__PURE__ */ new Set([
|
|
1079
1309
|
"p",
|
|
1080
1310
|
"h1",
|
|
1081
1311
|
"h2",
|
|
@@ -1103,17 +1333,17 @@ var TEXT_ELEMENT_TAGS = /* @__PURE__ */ new Set([
|
|
|
1103
1333
|
"code",
|
|
1104
1334
|
"pre"
|
|
1105
1335
|
]);
|
|
1106
|
-
function
|
|
1336
|
+
function hasDirectNonWhitespaceText2(element) {
|
|
1107
1337
|
return Array.from(element.childNodes).some(
|
|
1108
1338
|
(node) => node.nodeType === Node.TEXT_NODE && Boolean(node.textContent?.trim())
|
|
1109
1339
|
);
|
|
1110
1340
|
}
|
|
1111
1341
|
function isTextElement2(element) {
|
|
1112
1342
|
const tagName = element.tagName.toLowerCase();
|
|
1113
|
-
if (
|
|
1343
|
+
if (TEXT_ELEMENT_TAGS2.has(tagName)) {
|
|
1114
1344
|
return true;
|
|
1115
1345
|
}
|
|
1116
|
-
if (
|
|
1346
|
+
if (hasDirectNonWhitespaceText2(element)) {
|
|
1117
1347
|
return true;
|
|
1118
1348
|
}
|
|
1119
1349
|
if (element.children.length === 0 && element.textContent?.trim()) {
|
|
@@ -1121,38 +1351,6 @@ function isTextElement2(element) {
|
|
|
1121
1351
|
}
|
|
1122
1352
|
return false;
|
|
1123
1353
|
}
|
|
1124
|
-
function getComputedTypography(element) {
|
|
1125
|
-
const computed = window.getComputedStyle(element);
|
|
1126
|
-
let textVerticalAlign = "flex-start";
|
|
1127
|
-
if (computed.display === "flex" || computed.display === "inline-flex") {
|
|
1128
|
-
const alignItems = computed.alignItems;
|
|
1129
|
-
if (alignItems === "center") textVerticalAlign = "center";
|
|
1130
|
-
else if (alignItems === "flex-end" || alignItems === "end") textVerticalAlign = "flex-end";
|
|
1131
|
-
}
|
|
1132
|
-
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);
|
|
1133
|
-
const fontSize = parseFloat(computed.fontSize);
|
|
1134
|
-
let letterSpacing;
|
|
1135
|
-
if (computed.letterSpacing === "normal") {
|
|
1136
|
-
letterSpacing = { numericValue: 0, unit: "em", raw: "0em" };
|
|
1137
|
-
} else {
|
|
1138
|
-
const parsed = parsePropertyValue(computed.letterSpacing);
|
|
1139
|
-
if (parsed.unit === "px" && fontSize > 0) {
|
|
1140
|
-
const emValue = Math.round(parsed.numericValue / fontSize * 100) / 100;
|
|
1141
|
-
letterSpacing = { numericValue: emValue, unit: "em", raw: `${emValue}em` };
|
|
1142
|
-
} else {
|
|
1143
|
-
letterSpacing = parsed;
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
return {
|
|
1147
|
-
fontFamily: computed.fontFamily,
|
|
1148
|
-
fontWeight: computed.fontWeight,
|
|
1149
|
-
fontSize: parsePropertyValue(computed.fontSize),
|
|
1150
|
-
lineHeight,
|
|
1151
|
-
letterSpacing,
|
|
1152
|
-
textAlign: computed.textAlign,
|
|
1153
|
-
textVerticalAlign
|
|
1154
|
-
};
|
|
1155
|
-
}
|
|
1156
1354
|
function detectSizingMode(element, dimension) {
|
|
1157
1355
|
const computed = window.getComputedStyle(element);
|
|
1158
1356
|
const inlineValue = element.style[dimension];
|
|
@@ -1200,12 +1398,6 @@ function getSizingValue(element, dimension) {
|
|
|
1200
1398
|
}
|
|
1201
1399
|
};
|
|
1202
1400
|
}
|
|
1203
|
-
function getComputedSizing(element) {
|
|
1204
|
-
return {
|
|
1205
|
-
width: getSizingValue(element, "width"),
|
|
1206
|
-
height: getSizingValue(element, "height")
|
|
1207
|
-
};
|
|
1208
|
-
}
|
|
1209
1401
|
function sizingValueToCSS(sizing) {
|
|
1210
1402
|
switch (sizing.mode) {
|
|
1211
1403
|
case "fill":
|
|
@@ -1325,134 +1517,6 @@ function parseColorValue(cssValue) {
|
|
|
1325
1517
|
}
|
|
1326
1518
|
return parseNamedColor(raw);
|
|
1327
1519
|
}
|
|
1328
|
-
var TRANSPARENT_COLOR = { hex: "000000", alpha: 0, raw: "transparent" };
|
|
1329
|
-
function isVisibleBorderSide(side) {
|
|
1330
|
-
return side.style !== "none" && side.style !== "hidden" && parseFloat(side.width) > 0;
|
|
1331
|
-
}
|
|
1332
|
-
function hasVisibleOutline(computed) {
|
|
1333
|
-
return computed.outlineStyle !== "none" && parseFloat(computed.outlineWidth) > 0;
|
|
1334
|
-
}
|
|
1335
|
-
function parseVisibleColor(value, fallbackCurrentColor) {
|
|
1336
|
-
const raw = value.trim();
|
|
1337
|
-
const lowered = raw.toLowerCase();
|
|
1338
|
-
if (!raw || lowered === "none" || lowered === "transparent") {
|
|
1339
|
-
return null;
|
|
1340
|
-
}
|
|
1341
|
-
const resolved = /^currentcolor$/i.test(raw) ? fallbackCurrentColor ?? raw : raw;
|
|
1342
|
-
const parsed = parseColorValue(resolved);
|
|
1343
|
-
if (parsed.alpha <= 0) {
|
|
1344
|
-
return null;
|
|
1345
|
-
}
|
|
1346
|
-
return parsed;
|
|
1347
|
-
}
|
|
1348
|
-
function addUniqueColor(colors, color) {
|
|
1349
|
-
if (!color) return;
|
|
1350
|
-
colors.set(`${color.hex}:${color.alpha}`, color);
|
|
1351
|
-
}
|
|
1352
|
-
function isTextRenderingFormControl(element) {
|
|
1353
|
-
if (element instanceof HTMLTextAreaElement) return true;
|
|
1354
|
-
if (element instanceof HTMLSelectElement) return true;
|
|
1355
|
-
if (element instanceof HTMLButtonElement) return true;
|
|
1356
|
-
if (element instanceof HTMLInputElement) {
|
|
1357
|
-
const textlessInputTypes = /* @__PURE__ */ new Set([
|
|
1358
|
-
"hidden",
|
|
1359
|
-
"checkbox",
|
|
1360
|
-
"radio",
|
|
1361
|
-
"range",
|
|
1362
|
-
"color",
|
|
1363
|
-
"file",
|
|
1364
|
-
"image"
|
|
1365
|
-
]);
|
|
1366
|
-
return !textlessInputTypes.has(element.type.toLowerCase());
|
|
1367
|
-
}
|
|
1368
|
-
return false;
|
|
1369
|
-
}
|
|
1370
|
-
function hasRenderableTextNode(element) {
|
|
1371
|
-
if (element.isContentEditable) return true;
|
|
1372
|
-
if (isTextRenderingFormControl(element)) return true;
|
|
1373
|
-
if (!element.textContent?.trim()) return false;
|
|
1374
|
-
if (hasDirectNonWhitespaceText(element)) return true;
|
|
1375
|
-
const tagName = element.tagName.toLowerCase();
|
|
1376
|
-
return TEXT_ELEMENT_TAGS.has(tagName) || element.children.length === 0;
|
|
1377
|
-
}
|
|
1378
|
-
function getComputedBoxShadow(element) {
|
|
1379
|
-
const computed = window.getComputedStyle(element);
|
|
1380
|
-
const value = computed.boxShadow.trim();
|
|
1381
|
-
return value || "none";
|
|
1382
|
-
}
|
|
1383
|
-
function getComputedColorStyles(element) {
|
|
1384
|
-
const computed = window.getComputedStyle(element);
|
|
1385
|
-
const borderSides = [
|
|
1386
|
-
{ style: computed.borderTopStyle, width: computed.borderTopWidth, color: computed.borderTopColor },
|
|
1387
|
-
{ style: computed.borderRightStyle, width: computed.borderRightWidth, color: computed.borderRightColor },
|
|
1388
|
-
{ style: computed.borderBottomStyle, width: computed.borderBottomWidth, color: computed.borderBottomColor },
|
|
1389
|
-
{ style: computed.borderLeftStyle, width: computed.borderLeftWidth, color: computed.borderLeftColor }
|
|
1390
|
-
];
|
|
1391
|
-
const visibleBorderSide = borderSides.find((side) => isVisibleBorderSide(side));
|
|
1392
|
-
const hasBorder = Boolean(visibleBorderSide);
|
|
1393
|
-
const hasOutline = hasVisibleOutline(computed);
|
|
1394
|
-
return {
|
|
1395
|
-
backgroundColor: parseColorValue(computed.backgroundColor),
|
|
1396
|
-
color: parseColorValue(computed.color),
|
|
1397
|
-
borderColor: hasBorder && visibleBorderSide ? parseColorValue(visibleBorderSide.color) : TRANSPARENT_COLOR,
|
|
1398
|
-
outlineColor: hasOutline ? parseColorValue(computed.outlineColor) : TRANSPARENT_COLOR
|
|
1399
|
-
};
|
|
1400
|
-
}
|
|
1401
|
-
function getSelectionColors(element) {
|
|
1402
|
-
const uniqueColors = /* @__PURE__ */ new Map();
|
|
1403
|
-
const queue = [element];
|
|
1404
|
-
for (let index = 0; index < queue.length; index++) {
|
|
1405
|
-
const node = queue[index];
|
|
1406
|
-
const computed = window.getComputedStyle(node);
|
|
1407
|
-
if (computed.display === "none") {
|
|
1408
|
-
continue;
|
|
1409
|
-
}
|
|
1410
|
-
const isVisibilityHidden = computed.visibility === "hidden" || computed.visibility === "collapse";
|
|
1411
|
-
const currentTextColor = computed.color;
|
|
1412
|
-
if (!isVisibilityHidden) {
|
|
1413
|
-
addUniqueColor(uniqueColors, parseVisibleColor(computed.backgroundColor));
|
|
1414
|
-
if (node instanceof HTMLElement && hasRenderableTextNode(node)) {
|
|
1415
|
-
addUniqueColor(uniqueColors, parseVisibleColor(currentTextColor));
|
|
1416
|
-
}
|
|
1417
|
-
const borderSides = [
|
|
1418
|
-
{ style: computed.borderTopStyle, width: computed.borderTopWidth, color: computed.borderTopColor },
|
|
1419
|
-
{ style: computed.borderRightStyle, width: computed.borderRightWidth, color: computed.borderRightColor },
|
|
1420
|
-
{ style: computed.borderBottomStyle, width: computed.borderBottomWidth, color: computed.borderBottomColor },
|
|
1421
|
-
{ style: computed.borderLeftStyle, width: computed.borderLeftWidth, color: computed.borderLeftColor }
|
|
1422
|
-
];
|
|
1423
|
-
for (const side of borderSides) {
|
|
1424
|
-
if (!isVisibleBorderSide(side)) continue;
|
|
1425
|
-
addUniqueColor(uniqueColors, parseVisibleColor(side.color, currentTextColor));
|
|
1426
|
-
}
|
|
1427
|
-
if (hasVisibleOutline(computed)) {
|
|
1428
|
-
addUniqueColor(uniqueColors, parseVisibleColor(computed.outlineColor, currentTextColor));
|
|
1429
|
-
}
|
|
1430
|
-
if (node instanceof SVGElement) {
|
|
1431
|
-
const fillColor = parseVisibleColor(computed.getPropertyValue("fill"), currentTextColor) ?? parseVisibleColor(node.getAttribute("fill") ?? "", currentTextColor);
|
|
1432
|
-
const strokeColor = parseVisibleColor(computed.getPropertyValue("stroke"), currentTextColor) ?? parseVisibleColor(node.getAttribute("stroke") ?? "", currentTextColor);
|
|
1433
|
-
addUniqueColor(uniqueColors, fillColor);
|
|
1434
|
-
addUniqueColor(uniqueColors, strokeColor);
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
for (const child of node.children) {
|
|
1438
|
-
queue.push(child);
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
return Array.from(uniqueColors.values());
|
|
1442
|
-
}
|
|
1443
|
-
function getAllComputedStyles(element) {
|
|
1444
|
-
const { spacing, borderRadius, flex } = getComputedStyles(element);
|
|
1445
|
-
return {
|
|
1446
|
-
spacing,
|
|
1447
|
-
borderRadius,
|
|
1448
|
-
border: getComputedBorderStyles(element),
|
|
1449
|
-
flex,
|
|
1450
|
-
sizing: getComputedSizing(element),
|
|
1451
|
-
color: getComputedColorStyles(element),
|
|
1452
|
-
boxShadow: getComputedBoxShadow(element),
|
|
1453
|
-
typography: getComputedTypography(element)
|
|
1454
|
-
};
|
|
1455
|
-
}
|
|
1456
1520
|
var colorPropertyToCSSMap = {
|
|
1457
1521
|
backgroundColor: "background-color",
|
|
1458
1522
|
color: "color",
|
|
@@ -1965,7 +2029,7 @@ function findChildAtPoint(parent, clientX, clientY) {
|
|
|
1965
2029
|
return clientX >= r.left && clientX <= r.right && clientY >= r.top && clientY <= r.bottom;
|
|
1966
2030
|
});
|
|
1967
2031
|
if (hit) return hit;
|
|
1968
|
-
if (children.length === 1 && !
|
|
2032
|
+
if (children.length === 1 && !hasDirectNonWhitespaceText2(parent)) return children[0];
|
|
1969
2033
|
return null;
|
|
1970
2034
|
}
|
|
1971
2035
|
function elementFromPointWithoutOverlays(x, y) {
|