@theorem/react
Advanced tools
Comparing version 6.3.1 to 7.0.0
@@ -31,3 +31,5 @@ import type { AnchorHTMLAttributes, CSSProperties, ReactNode } from "react"; | ||
*/ | ||
renderLink?: (props: AnchorHTMLAttributes<HTMLAnchorElement>) => ReactNode; | ||
renderLink?: (props: AnchorHTMLAttributes<HTMLAnchorElement> & { | ||
href: string; | ||
}) => ReactNode; | ||
title?: string; | ||
@@ -34,0 +36,0 @@ style?: CSSProperties; |
@@ -14,6 +14,8 @@ var __assign = (this && this.__assign) || function () { | ||
import test from "ava"; | ||
import { render } from "../lib-test"; | ||
import { render, silenceConsole } from "../lib-test"; | ||
import { ActionArea } from "./ActionArea"; | ||
test("ActionArea unexpected action", function (t) { | ||
t.throws(function () { return render(_jsx(ActionArea, __assign({ action: false }, { children: "Show" }), void 0)); }); | ||
t.throws(silenceConsole(function () { | ||
return render(_jsx(ActionArea, __assign({ action: false }, { children: "Show" }), void 0)); | ||
})); | ||
}); |
export * from "./render"; | ||
export declare function silenceConsole<Result>(f: () => Result): () => Result; |
export * from "./render"; | ||
export function silenceConsole(f) { | ||
return function () { | ||
var orig = console.error; | ||
console.error = function () { }; | ||
try { | ||
return f(); | ||
} | ||
finally { | ||
console.error = orig; | ||
} | ||
}; | ||
} |
@@ -26,18 +26,20 @@ var counter = 0; | ||
} | ||
function prependTo(parent, child) { | ||
parent.insertBefore(child, parent.firstChild); | ||
} | ||
export function globalCss(window, css) { | ||
var doc = window.document; | ||
var s = doc.createElement("style"); | ||
s.innerHTML = css; | ||
doc.head.appendChild(s); | ||
s.innerText = css; | ||
prependTo(doc.head, s); | ||
} | ||
export function scopedStyles(prefix, styles, win) { | ||
counter += 1; | ||
var name = prefix + "-" + counter; | ||
var name = prefix + "-" + counter + "uVdOIRB"; | ||
var w = win || (typeof window === "undefined" ? undefined : window); | ||
if (typeof w !== "undefined") { | ||
var style = w.document.createElement("style"); | ||
style.innerText = objectToString("." + name, styles); | ||
w.document.head.appendChild(style); | ||
// :where for 0 specificity | ||
globalCss(w, objectToString(":where(." + name + ")", styles)); | ||
} | ||
return name; | ||
} |
@@ -10,2 +10,14 @@ import { scopedStyles } from "."; | ||
}, | ||
get firstChild() { | ||
return appendedChildren[0] || null; | ||
}, | ||
insertBefore: function (newChild, targetChild) { | ||
var index = targetChild === null | ||
? appendedChildren.length | ||
: appendedChildren.findIndex(function (c) { return c === targetChild; }); | ||
if (index === -1) | ||
throw new Error("The node before which the new node is to be inserted is not a child of this node"); | ||
appendedChildren.splice(index, 0, newChild); | ||
return newChild; | ||
}, | ||
}; | ||
@@ -12,0 +24,0 @@ var document = { |
@@ -60,3 +60,3 @@ { | ||
"types": "dist/index.js", | ||
"version": "6.3.1" | ||
"version": "7.0.0" | ||
} |
@@ -60,3 +60,3 @@ { | ||
"types": "dist/index.js", | ||
"version": "6.3.1" | ||
"version": "7.0.0" | ||
} |
@@ -13,2 +13,6 @@ # React tools | ||
## Browser support | ||
For the most part the library is not using any newer APIs. That said, if you support browsers with less than 2% of the market (Internet Explorer, Safari before 14, Chrome before 88), take a second look whether everything works well. | ||
## About Theorem | ||
@@ -15,0 +19,0 @@ |
70914
1641
32