@reach/popover
Advanced tools
Comparing version 0.4.0-beta.0 to 0.4.0
@@ -27,9 +27,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
var targetRect = useRect(targetRef); | ||
var ref = useForkedRef(popoverRef, forwardedRef); | ||
useSimulateTabNavigationForReactTree(targetRef, popoverRef); | ||
return React.createElement("div", _extends({ | ||
"data-reach-popover": "", | ||
ref: function ref(node) { | ||
assignRef(popoverRef, node); | ||
assignRef(forwardedRef, node); | ||
}, | ||
ref: ref, | ||
style: _extends({}, style, { | ||
@@ -247,2 +245,23 @@ position: "absolute" | ||
} | ||
} // TODO: Remove and import from @reach/utils once it's been added to the package | ||
function useForkedRef() { | ||
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) { | ||
refs[_key] = arguments[_key]; | ||
} | ||
return React.useMemo(function () { | ||
if (refs.every(function (ref) { | ||
return ref == null; | ||
})) { | ||
return null; | ||
} | ||
return function (node) { | ||
refs.forEach(function (ref) { | ||
assignRef(ref, node); | ||
}); | ||
}; // eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, refs); | ||
} |
27
index.js
@@ -47,9 +47,7 @@ "use strict"; | ||
var targetRect = (0, _rect.useRect)(targetRef); | ||
var ref = useForkedRef(popoverRef, forwardedRef); | ||
useSimulateTabNavigationForReactTree(targetRef, popoverRef); | ||
return _react["default"].createElement("div", _extends({ | ||
"data-reach-popover": "", | ||
ref: function ref(node) { | ||
(0, _utils.assignRef)(popoverRef, node); | ||
(0, _utils.assignRef)(forwardedRef, node); | ||
}, | ||
ref: ref, | ||
style: _extends({}, style, { | ||
@@ -269,2 +267,23 @@ position: "absolute" | ||
} | ||
} // TODO: Remove and import from @reach/utils once it's been added to the package | ||
function useForkedRef() { | ||
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) { | ||
refs[_key] = arguments[_key]; | ||
} | ||
return _react["default"].useMemo(function () { | ||
if (refs.every(function (ref) { | ||
return ref == null; | ||
})) { | ||
return null; | ||
} | ||
return function (node) { | ||
refs.forEach(function (ref) { | ||
(0, _utils.assignRef)(ref, node); | ||
}); | ||
}; // eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, refs); | ||
} |
{ | ||
"name": "@reach/popover", | ||
"version": "0.4.0-beta.0", | ||
"version": "0.4.0", | ||
"description": "Render a portal positioned relative to another element.", | ||
@@ -8,9 +8,8 @@ "main": "index.js", | ||
"scripts": { | ||
"build": "node ../../shared/build-package", | ||
"lint": "eslint . --max-warnings=0" | ||
"build": "node ../../shared/build-package" | ||
}, | ||
"dependencies": { | ||
"@reach/portal": "^0.4.0-beta.0", | ||
"@reach/rect": "^0.4.0-beta.0", | ||
"@reach/utils": "^0.4.0-beta.0", | ||
"@reach/portal": "^0.4.0", | ||
"@reach/rect": "^0.4.0", | ||
"@reach/utils": "^0.4.0", | ||
"tabbable": "^4.0.0" | ||
@@ -22,3 +21,3 @@ }, | ||
}, | ||
"author": "Ryan Florence <@ryanflorence>", | ||
"author": "React Training <hello@reacttraining.com>", | ||
"license": "MIT", | ||
@@ -30,4 +29,6 @@ "files": [ | ||
"index.js", | ||
"index.d.ts", | ||
"styles.css" | ||
] | ||
], | ||
"gitHead": "0f3d2c7e530cd80e1d1bd338182ac89a3ba23999" | ||
} |
@@ -24,2 +24,3 @@ import React, { useRef, forwardRef, useEffect } from "react"; | ||
const targetRect = useRect(targetRef); | ||
const ref = useForkedRef(popoverRef, forwardedRef); | ||
@@ -31,6 +32,3 @@ useSimulateTabNavigationForReactTree(targetRef, popoverRef); | ||
data-reach-popover="" | ||
ref={node => { | ||
assignRef(popoverRef, node); | ||
assignRef(forwardedRef, node); | ||
}} | ||
ref={ref} | ||
style={{ | ||
@@ -243,1 +241,16 @@ ...style, | ||
} | ||
// TODO: Remove and import from @reach/utils once it's been added to the package | ||
function useForkedRef(...refs) { | ||
return React.useMemo(() => { | ||
if (refs.every(ref => ref == null)) { | ||
return null; | ||
} | ||
return node => { | ||
refs.forEach(ref => { | ||
assignRef(ref, node); | ||
}); | ||
}; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, refs); | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30283
6
712
Updated@reach/portal@^0.4.0
Updated@reach/rect@^0.4.0
Updated@reach/utils@^0.4.0