@inkindcards/semantic-layer 2.2.0 → 2.2.2
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/components.cjs +87 -43
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +4 -2
- package/dist/components.d.ts +4 -2
- package/dist/components.js +87 -43
- package/dist/components.js.map +1 -1
- package/package.json +2 -2
package/dist/components.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var chunkT2C43AAL_cjs = require('./chunk-T2C43AAL.cjs');
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var reactDom = require('react-dom');
|
|
6
7
|
|
|
7
8
|
var containerStyle = {
|
|
8
9
|
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
@@ -836,6 +837,21 @@ function InspectableRegistry({ children }) {
|
|
|
836
837
|
};
|
|
837
838
|
return /* @__PURE__ */ jsxRuntime.jsx(InspectableRegistryContext.Provider, { value, children });
|
|
838
839
|
}
|
|
840
|
+
function getChildrenBounds(el) {
|
|
841
|
+
const children = el.children;
|
|
842
|
+
if (children.length === 0) return null;
|
|
843
|
+
let top = Infinity, left = Infinity, bottom = -Infinity, right = -Infinity;
|
|
844
|
+
for (let i = 0; i < children.length; i++) {
|
|
845
|
+
const r = children[i].getBoundingClientRect();
|
|
846
|
+
if (r.width === 0 && r.height === 0) continue;
|
|
847
|
+
top = Math.min(top, r.top);
|
|
848
|
+
left = Math.min(left, r.left);
|
|
849
|
+
bottom = Math.max(bottom, r.bottom);
|
|
850
|
+
right = Math.max(right, r.right);
|
|
851
|
+
}
|
|
852
|
+
if (top === Infinity) return null;
|
|
853
|
+
return new DOMRect(left, top, right - left, bottom - top);
|
|
854
|
+
}
|
|
839
855
|
function Inspectable({
|
|
840
856
|
label,
|
|
841
857
|
currentSource = "unknown",
|
|
@@ -845,7 +861,8 @@ function Inspectable({
|
|
|
845
861
|
}) {
|
|
846
862
|
const registry = react.useContext(InspectableRegistryContext);
|
|
847
863
|
const id = react.useId();
|
|
848
|
-
const
|
|
864
|
+
const wrapperRef = react.useRef(null);
|
|
865
|
+
const [rect, setRect] = react.useState(null);
|
|
849
866
|
const inferredColumns = columns ?? (data?.[0] ? Object.keys(data[0]) : []);
|
|
850
867
|
const sampleValues = data?.slice(0, 3) ?? [];
|
|
851
868
|
react.useEffect(() => {
|
|
@@ -856,59 +873,86 @@ function Inspectable({
|
|
|
856
873
|
currentSource,
|
|
857
874
|
columns: inferredColumns,
|
|
858
875
|
sampleValues,
|
|
859
|
-
element:
|
|
876
|
+
element: wrapperRef.current
|
|
860
877
|
});
|
|
861
878
|
return () => registry.unregister(id);
|
|
862
879
|
}, [id, label, currentSource, inferredColumns.join(","), registry]);
|
|
880
|
+
react.useEffect(() => {
|
|
881
|
+
if (!registry?.inspectActive || !wrapperRef.current) {
|
|
882
|
+
setRect(null);
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
const measure = () => {
|
|
886
|
+
if (wrapperRef.current) {
|
|
887
|
+
setRect(getChildrenBounds(wrapperRef.current));
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
measure();
|
|
891
|
+
window.addEventListener("scroll", measure, true);
|
|
892
|
+
window.addEventListener("resize", measure);
|
|
893
|
+
const interval = setInterval(measure, 300);
|
|
894
|
+
return () => {
|
|
895
|
+
window.removeEventListener("scroll", measure, true);
|
|
896
|
+
window.removeEventListener("resize", measure);
|
|
897
|
+
clearInterval(interval);
|
|
898
|
+
};
|
|
899
|
+
}, [registry?.inspectActive]);
|
|
863
900
|
if (!registry) {
|
|
864
901
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
865
902
|
}
|
|
866
903
|
const isSelected = registry.selectedId === id;
|
|
867
|
-
const showOutline = registry.inspectActive;
|
|
868
904
|
const handleClick = (e) => {
|
|
869
|
-
if (!registry.inspectActive) return;
|
|
870
905
|
e.stopPropagation();
|
|
906
|
+
e.preventDefault();
|
|
871
907
|
registry.setSelectedId(isSelected ? null : id);
|
|
872
908
|
};
|
|
873
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
909
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: wrapperRef, style: { display: "contents" }, children: [
|
|
910
|
+
children,
|
|
911
|
+
registry.inspectActive && rect && reactDom.createPortal(
|
|
912
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
913
|
+
"div",
|
|
914
|
+
{
|
|
915
|
+
onClick: handleClick,
|
|
916
|
+
style: {
|
|
917
|
+
position: "fixed",
|
|
918
|
+
top: rect.top,
|
|
919
|
+
left: rect.left,
|
|
920
|
+
width: rect.width,
|
|
921
|
+
height: rect.height,
|
|
922
|
+
zIndex: 9999,
|
|
923
|
+
cursor: "pointer",
|
|
924
|
+
outline: isSelected ? "2px solid #3b82f6" : "2px dashed #93c5fd",
|
|
925
|
+
outlineOffset: 2,
|
|
926
|
+
borderRadius: 4,
|
|
927
|
+
transition: "outline 0.15s ease",
|
|
928
|
+
background: isSelected ? "rgba(59,130,246,0.05)" : "transparent",
|
|
929
|
+
pointerEvents: "auto"
|
|
930
|
+
},
|
|
931
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
932
|
+
"div",
|
|
933
|
+
{
|
|
934
|
+
style: {
|
|
935
|
+
position: "absolute",
|
|
936
|
+
top: -10,
|
|
937
|
+
left: 4,
|
|
938
|
+
fontSize: 10,
|
|
939
|
+
fontWeight: 600,
|
|
940
|
+
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
941
|
+
color: "#fff",
|
|
942
|
+
backgroundColor: isSelected ? "#3b82f6" : "#93c5fd",
|
|
943
|
+
padding: "1px 6px",
|
|
944
|
+
borderRadius: 3,
|
|
945
|
+
pointerEvents: "none",
|
|
946
|
+
whiteSpace: "nowrap"
|
|
947
|
+
},
|
|
948
|
+
children: label
|
|
949
|
+
}
|
|
950
|
+
)
|
|
951
|
+
}
|
|
952
|
+
),
|
|
953
|
+
document.body
|
|
954
|
+
)
|
|
955
|
+
] });
|
|
912
956
|
}
|
|
913
957
|
|
|
914
958
|
// src/components/field-matcher.ts
|