@stratakit/structures
Version:
Medium-sized component structures for the Strata design system
42 lines (41 loc) • 1.01 kB
JavaScript
import { c as _c } from "react-compiler-runtime";
import * as React from "react";
const INTERACTIVE_CONTENT_SELECTOR = ["button", ":any-link", "[tabindex='0']"].join(",");
function useWarnOnInteractiveDescendants(ref, message) {
const $ = _c(4);
const hasWarnedRef = React.useRef(false);
let t0;
let t1;
if ($[0] !== message || $[1] !== ref) {
t0 = () => {
const container = ref.current;
if (hasWarnedRef.current) {
return;
}
if (!container) {
return;
}
const interactiveDescendant = container.querySelector(INTERACTIVE_CONTENT_SELECTOR);
if (!interactiveDescendant) {
return;
}
hasWarnedRef.current = true;
console.warn(message, {
container,
interactiveDescendant
});
};
t1 = [message, ref];
$[0] = message;
$[1] = ref;
$[2] = t0;
$[3] = t1;
} else {
t0 = $[2];
t1 = $[3];
}
React.useEffect(t0, t1);
}
export {
useWarnOnInteractiveDescendants
};