Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-stick

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-stick - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

31

lib/Stick.js

@@ -36,2 +36,6 @@ "use strict";

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
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; }
function Stick(_ref) {

@@ -50,3 +54,4 @@ var inline = _ref.inline,

autoFlipVertically = _ref.autoFlipVertically,
onClickOutside = _ref.onClickOutside;
onClickOutside = _ref.onClickOutside,
rest = _objectWithoutPropertiesLoose(_ref, ["inline", "node", "style", "sameWidth", "children", "updateOnAnimationFrame", "position", "align", "component", "transportTo", "autoFlipHorizontally", "autoFlipVertically", "onClickOutside"]);

@@ -126,5 +131,13 @@ var _useState = (0, _react.useState)(0),

}));
var handleReposition = (0, _react.useCallback)(function () {
if (nodeRef.current && anchorRef.current) {
checkAlignment(nodeRef.current, anchorRef.current);
}
}, [checkAlignment]);
if (!node) {
return children;
var Component = component || 'div';
return _react.default.createElement(_StickContext.StickContext.Provider, {
value: nestingKey
}, _react.default.createElement(Component, rest, children));
}

@@ -135,3 +148,3 @@

value: nestingKey
}, _react.default.createElement(_StickInline.default, {
}, _react.default.createElement(_StickInline.default, _extends({}, rest, {
position: resolvedPosition,

@@ -152,3 +165,3 @@ align: resolvedAlign,

component: component
}, children));
}), children));
}

@@ -158,3 +171,3 @@

value: nestingKey
}, _react.default.createElement(_StickPortal.default, {
}, _react.default.createElement(_StickPortal.default, _extends({}, rest, {
updateOnAnimationFrame: !!updateOnAnimationFrame,

@@ -178,8 +191,4 @@ transportTo: transportTo,

containerRef: _containerRef,
onReposition: function onReposition() {
if (nodeRef.current && anchorRef.current) {
checkAlignment(nodeRef.current, anchorRef.current);
}
}
}, children));
onReposition: handleReposition
}), children));
}

@@ -186,0 +195,0 @@

@@ -16,2 +16,4 @@ "use strict";

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; }
function StickInline(_ref) {

@@ -23,5 +25,7 @@ var node = _ref.node,

containerRef = _ref.containerRef,
nestingKey = _ref.nestingKey;
nestingKey = _ref.nestingKey,
rest = _objectWithoutPropertiesLoose(_ref, ["node", "children", "style", "component", "containerRef", "nestingKey"]);
var Component = component || 'div';
return _react.default.createElement(Component, _extends({}, style, {
return _react.default.createElement(Component, _extends({}, style, rest, {
ref: containerRef,

@@ -28,0 +32,0 @@ "data-sticknestingkey": nestingKey

@@ -80,3 +80,3 @@ "use strict";

var Component = component || 'div';
return _react.default.createElement(Component, _extends({}, style, {
return _react.default.createElement(Component, _extends({}, style, rest, {
ref: function ref(node) {

@@ -83,0 +83,0 @@ if (typeof _ref2 === 'function') {

{
"name": "react-stick",
"version": "3.0.0",
"version": "3.0.1",
"description": "React component to stick a portaled node to an anchor node",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -45,2 +45,3 @@ // @flow

onClickOutside,
...rest
}: PropsT) {

@@ -129,4 +130,16 @@ const [width, setWidth] = useState(0)

const handleReposition = useCallback(() => {
if (nodeRef.current && anchorRef.current) {
checkAlignment(nodeRef.current, anchorRef.current)
}
}, [checkAlignment])
if (!node) {
return children
const Component = component || 'div'
return (
<StickContext.Provider value={nestingKey}>
<Component {...rest}>{children}</Component>
</StickContext.Provider>
)
}

@@ -138,2 +151,3 @@

<StickInline
{...rest}
position={resolvedPosition}

@@ -168,2 +182,3 @@ align={resolvedAlign}

<StickPortal
{...rest}
updateOnAnimationFrame={!!updateOnAnimationFrame}

@@ -195,7 +210,3 @@ transportTo={transportTo}

containerRef={containerRef}
onReposition={() => {
if (nodeRef.current && anchorRef.current) {
checkAlignment(nodeRef.current, anchorRef.current)
}
}}
onReposition={handleReposition}
>

@@ -202,0 +213,0 @@ {children}

@@ -22,6 +22,12 @@ // @flow

nestingKey,
...rest
}: PropsT) {
const Component = component || 'div'
return (
<Component {...style} ref={containerRef} data-sticknestingkey={nestingKey}>
<Component
{...style}
{...rest}
ref={containerRef}
data-sticknestingkey={nestingKey}
>
{children}

@@ -28,0 +34,0 @@ {node && <div {...style('node')}>{node}</div>}

@@ -80,2 +80,3 @@ // @flow

{...style}
{...rest}
ref={node => {

@@ -82,0 +83,0 @@ if (typeof ref === 'function') {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc