@theorem/react
Advanced tools
Comparing version 5.0.0 to 6.0.0
@@ -0,1 +1,7 @@ | ||
# 6.0.0 | ||
- ActionArea: improve rels and referrer | ||
- ActionArea: nicer error message when action is missing | ||
- permanence: renders children on the screen even without parent | ||
# 5.0.0 | ||
@@ -2,0 +8,0 @@ |
@@ -39,4 +39,6 @@ var __assign = (this && this.__assign) || function () { | ||
export function ActionArea(props) { | ||
var action = props.action, children = props.children, title = props.title, style = props.style; | ||
var children = props.children, title = props.title, style = props.style; | ||
var className = props.className || ""; | ||
// Make sure we handle a common error well | ||
var action = props.action; | ||
var button = function (opts) { | ||
@@ -57,8 +59,3 @@ var onClick = opts.onClick, onMouseDown = opts.onMouseDown, type = opts.type; | ||
return span("current"); | ||
var external = url.startsWith("http://") || url.startsWith("https://"); | ||
var rels = [ | ||
newWindow ? "noopener" : "", | ||
external ? "noreferrer" : "", | ||
].filter(function (s) { return s; }); | ||
return (_jsx("a", __assign({ className: baseStyles + " " + className, download: download, href: url, rel: rels.join(" "), target: newWindow ? "_blank" : undefined, title: title, style: style }, { children: children }), void 0)); | ||
return (_jsx("a", __assign({ className: baseStyles + " " + className, download: download, href: url, rel: newWindow ? "noopener" : undefined, referrerPolicy: "strict-origin-when-cross-origin", target: newWindow ? "_blank" : undefined, title: title, style: style }, { children: children }), void 0)); | ||
}; | ||
@@ -73,9 +70,12 @@ if (action === "disabled") | ||
return link(action); | ||
if ("download" in action) | ||
return link(action.url, { download: action.download }); | ||
if ("mousedown" in action) | ||
return button({ onMouseDown: action.mousedown }); | ||
if ("newWindow" in action) | ||
return link(action.newWindow, { newWindow: true }); | ||
throw new Error("Unexpected action"); | ||
if (action) { | ||
if ("download" in action) | ||
return link(action.url, { download: action.download }); | ||
if ("mousedown" in action) | ||
return button({ onMouseDown: action.mousedown }); | ||
if ("newWindow" in action) | ||
return link(action.newWindow, { newWindow: true }); | ||
} | ||
console.error("Props for the last ActionArea:", props); | ||
throw new Error("ActionArea received an invalid action: " + action); | ||
} |
@@ -21,22 +21,20 @@ { | ||
"dependencies": { | ||
"@types/color-convert": "^2.0.0", | ||
"@types/findup-sync": "^2.0.2", | ||
"color-convert": "^2.0.1", | ||
"commander": "^2.20.3", | ||
"commander": "^7.0.0", | ||
"findup-sync": "^4.0.0", | ||
"license-checker-webpack-plugin": "=0.2.0", | ||
"license-checker-webpack-plugin": "=0.2.1", | ||
"parse-css-color": "^0.1.2", | ||
"use-memo-one": "^1.1.1" | ||
"use-memo-one": "^1.1.2" | ||
}, | ||
"devDependencies": { | ||
"@theorem/eslint-plugin": "^6.2.1", | ||
"@types/license-checker-webpack-plugin": "^0.0.2", | ||
"@types/license-checker-webpack-plugin": "^0.0.3", | ||
"@types/react": "^17.0.0", | ||
"@types/react-test-renderer": "^17.0.0", | ||
"ava": "^3.13.0", | ||
"eslint": "^7.15.0", | ||
"ava": "^3.15.0", | ||
"eslint": "^7.18.0", | ||
"prettier": "^2.2.1", | ||
"react": "^17.0.1", | ||
"react-test-renderer": "^17.0.1", | ||
"ts-node": "^9.1.0", | ||
"ts-node": "^9.1.1", | ||
"typescript": "^4.1.3" | ||
@@ -62,3 +60,3 @@ }, | ||
"types": "dist/index.js", | ||
"version": "5.0.0" | ||
"version": "6.0.0" | ||
} |
@@ -9,2 +9,2 @@ import { ReactNode } from "react"; | ||
children: ReactNode; | ||
}) => null]; | ||
}) => {} | null | undefined]; |
@@ -18,3 +18,3 @@ var __assign = (this && this.__assign) || function () { | ||
export function makePermanence() { | ||
var context = createContext(function () { }); | ||
var context = createContext("no-parent"); | ||
return [ | ||
@@ -30,5 +30,9 @@ function Parent(props) { | ||
useLayoutEffect(function () { | ||
if (setDeepChildren === "no-parent") | ||
return; | ||
setDeepChildren(children); | ||
return function () { return setDeepChildren(null); }; | ||
}); | ||
if (setDeepChildren === "no-parent") | ||
return children; | ||
return null; | ||
@@ -35,0 +39,0 @@ }, |
@@ -21,22 +21,20 @@ { | ||
"dependencies": { | ||
"@types/color-convert": "^2.0.0", | ||
"@types/findup-sync": "^2.0.2", | ||
"color-convert": "^2.0.1", | ||
"commander": "^2.20.3", | ||
"commander": "^7.0.0", | ||
"findup-sync": "^4.0.0", | ||
"license-checker-webpack-plugin": "=0.2.0", | ||
"license-checker-webpack-plugin": "=0.2.1", | ||
"parse-css-color": "^0.1.2", | ||
"use-memo-one": "^1.1.1" | ||
"use-memo-one": "^1.1.2" | ||
}, | ||
"devDependencies": { | ||
"@theorem/eslint-plugin": "^6.2.1", | ||
"@types/license-checker-webpack-plugin": "^0.0.2", | ||
"@types/license-checker-webpack-plugin": "^0.0.3", | ||
"@types/react": "^17.0.0", | ||
"@types/react-test-renderer": "^17.0.0", | ||
"ava": "^3.13.0", | ||
"eslint": "^7.15.0", | ||
"ava": "^3.15.0", | ||
"eslint": "^7.18.0", | ||
"prettier": "^2.2.1", | ||
"react": "^17.0.1", | ||
"react-test-renderer": "^17.0.1", | ||
"ts-node": "^9.1.0", | ||
"ts-node": "^9.1.1", | ||
"typescript": "^4.1.3" | ||
@@ -62,3 +60,3 @@ }, | ||
"types": "dist/index.js", | ||
"version": "5.0.0" | ||
"version": "6.0.0" | ||
} |
63903
7
1408
+ Addedcommander@7.2.0(transitive)
- Removed@types/color-convert@^2.0.0
- Removedcolor-convert@^2.0.1
- Removed@types/color-convert@2.0.4(transitive)
- Removed@types/color-name@1.1.5(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcommander@2.20.3(transitive)
Updatedcommander@^7.0.0
Updateduse-memo-one@^1.1.2