New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.4 to 3.0.5

6

babel.config.js

@@ -19,12 +19,6 @@ const { NODE_ENV } = process.env

'@babel/transform-runtime',
'@babel/plugin-transform-flow-strip-types',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-optional-chaining',
'lodash',
'syntax-dynamic-import',
...(NODE_ENV === 'test' ? ['dynamic-import-node'] : []),
],
}

6

lib/hooks/index.js
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;

@@ -12,4 +14,2 @@ exports.useWatcher = exports.useAutoFlip = void 0;

exports.useWatcher = _useWatcher.default;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.useWatcher = _useWatcher.default;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;

@@ -14,4 +16,2 @@ exports.default = void 0;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var useAutoFlip = function useAutoFlip(enableAutoHorizontalFlip, enableAutoVerticalFlip, initialPosition, initialAlign) {

@@ -18,0 +18,0 @@ var _useState = (0, _react.useState)(initialPosition),

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;

@@ -9,5 +11,2 @@ exports.default = void 0;

exports.default = _Stick.default;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
module.exports = exports.default;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _some2 = _interopRequireDefault(require("lodash/some"));

@@ -30,12 +38,4 @@

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
var _jsxFileName = "/home/circleci/repo/src/Stick.js";
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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) {

@@ -55,3 +55,3 @@ var inline = _ref.inline,

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

@@ -138,9 +138,15 @@ var _useState = (0, _react.useState)(0),

if (inline) {
return _react.default.createElement(_StickContext.StickContext.Provider, {
value: nestingKey
}, _react.default.createElement(_StickInline.default, _extends({}, rest, {
return /*#__PURE__*/_react.default.createElement(_StickContext.StickContext.Provider, {
value: nestingKey,
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 137,
columnNumber: 7
}
}, /*#__PURE__*/_react.default.createElement(_StickInline.default, (0, _extends2.default)({}, rest, {
position: resolvedPosition,
align: resolvedAlign,
style: resolvedStyle,
node: node && _react.default.createElement(_StickNode.default, {
node: node && /*#__PURE__*/_react.default.createElement(_StickNode.default, {
width: width,

@@ -150,3 +156,9 @@ position: resolvedPosition,

sameWidth: !!sameWidth,
nodeRef: nodeRef
nodeRef: nodeRef,
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 145,
columnNumber: 15
}
}, node),

@@ -158,9 +170,21 @@ nestingKey: nestingKey,

},
component: component
component: component,
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 138,
columnNumber: 9
}
}), children));
}
return _react.default.createElement(_StickContext.StickContext.Provider, {
value: nestingKey
}, _react.default.createElement(_StickPortal.default, _extends({}, rest, {
return /*#__PURE__*/_react.default.createElement(_StickContext.StickContext.Provider, {
value: nestingKey,
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 170,
columnNumber: 5
}
}, /*#__PURE__*/_react.default.createElement(_StickPortal.default, (0, _extends2.default)({}, rest, {
updateOnAnimationFrame: !!updateOnAnimationFrame,

@@ -174,3 +198,3 @@ transportTo: transportTo,

position: resolvedPosition,
node: node && _react.default.createElement(_StickNode.default, {
node: node && /*#__PURE__*/_react.default.createElement(_StickNode.default, {
width: width,

@@ -180,3 +204,9 @@ position: resolvedPosition,

sameWidth: !!sameWidth,
nodeRef: nodeRef
nodeRef: nodeRef,
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 187,
columnNumber: 13
}
}, node),

@@ -186,3 +216,9 @@ style: resolvedStyle,

containerRef: _containerRef,
onReposition: handleReposition
onReposition: handleReposition,
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 171,
columnNumber: 7
}
}), children));

@@ -189,0 +225,0 @@ }

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _react = _interopRequireDefault(require("react"));

@@ -12,8 +18,4 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _jsxFileName = "/home/circleci/repo/src/StickInline.js";
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 StickInline(_ref) {

@@ -28,9 +30,21 @@ var node = _ref.node,

position = _ref.position,
rest = _objectWithoutPropertiesLoose(_ref, ["node", "children", "style", "component", "containerRef", "nestingKey", "align", "position"]);
rest = (0, _objectWithoutPropertiesLoose2.default)(_ref, ["node", "children", "style", "component", "containerRef", "nestingKey", "align", "position"]);
var Component = component || 'div';
return _react.default.createElement(Component, _extends({}, style, rest, {
return /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, style, rest, {
ref: containerRef,
"data-sticknestingkey": nestingKey
}), children, node && _react.default.createElement("div", style('node'), node));
"data-sticknestingkey": nestingKey,
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 22,
columnNumber: 5
}
}), children, node && /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, style('node'), {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 29,
columnNumber: 16
}
}), node));
}

@@ -37,0 +51,0 @@

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireDefault(require("react"));

@@ -12,6 +16,4 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _jsxFileName = "/home/circleci/repo/src/StickNode.js";
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 StickNode(_ref) {

@@ -21,4 +23,17 @@ var style = _ref.style,

nodeRef = _ref.nodeRef;
return _react.default.createElement("div", style, _react.default.createElement("div", _extends({}, style('content'), {
ref: nodeRef
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, style, {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 29,
columnNumber: 5
}
}), /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, style('content'), {
ref: nodeRef,
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 30,
columnNumber: 7
}
}), children));

@@ -25,0 +40,0 @@ }

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
require("requestidlecallback");

@@ -18,18 +28,8 @@

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
var _jsxFileName = "/home/circleci/repo/src/StickPortal.js";
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
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 StickPortal(_ref, _ref2) {

@@ -46,4 +46,3 @@ var children = _ref.children,

onReposition = _ref.onReposition,
rest = _objectWithoutPropertiesLoose(_ref, ["children", "component", "style", "transportTo", "nestingKey", "node", "position", "containerRef", "updateOnAnimationFrame", "onReposition"]);
rest = (0, _objectWithoutPropertiesLoose2.default)(_ref, ["children", "component", "style", "transportTo", "nestingKey", "node", "position", "containerRef", "updateOnAnimationFrame", "onReposition"]);
var nodeRef = (0, _react.useRef)();

@@ -59,2 +58,6 @@

var _useState3 = (0, _react.useState)(!!node),
visible = _useState3[0],
setVisible = _useState3[1];
var _useHost = useHost(transportTo),

@@ -69,4 +72,7 @@ host = _useHost[0],

}, [onReposition, top, left]);
(0, _react.useEffect)(function () {
setVisible(!!node);
}, [node]);
(0, _react.useLayoutEffect)(function () {
if (node) {
if (visible) {
hostParent.appendChild(host);

@@ -77,3 +83,3 @@ return function () {

}
}, [host, hostParent, node]);
}, [host, hostParent, visible]);
var measure = (0, _react.useCallback)(function () {

@@ -102,6 +108,6 @@ if (!nodeRef.current) {

nodeStyle = _style.style,
otherNodeStyleProps = _objectWithoutPropertiesLoose(_style, ["style"]);
otherNodeStyleProps = (0, _objectWithoutPropertiesLoose2.default)(_style, ["style"]);
var Component = component || 'div';
return _react.default.createElement(Component, _extends({}, style, rest, {
return /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, style, rest, {
ref: function ref(node) {

@@ -115,6 +121,18 @@ if (typeof _ref2 === 'function') {

nodeRef.current = node;
},
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 94,
columnNumber: 5
}
}), children, _react.default.createElement(PortalContext.Provider, {
value: host.parentNode
}, (0, _reactDom.createPortal)(_react.default.createElement("div", _extends({}, otherNodeStyleProps, {
}), children, /*#__PURE__*/_react.default.createElement(PortalContext.Provider, {
value: host.parentNode,
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 109,
columnNumber: 7
}
}, (0, _reactDom.createPortal)( /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, otherNodeStyleProps, {
ref: containerRef,

@@ -127,3 +145,9 @@ "data-sticknestingkey": nestingKey,

left: left
})
}),
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 111,
columnNumber: 11
}
}), node), host)));

@@ -139,6 +163,6 @@ }

function useHost(transportTo) {
var _useState3 = (0, _react.useState)(function () {
var _useState4 = (0, _react.useState)(function () {
return document.createElement('div');
}),
host = _useState3[0];
host = _useState4[0];

@@ -145,0 +169,0 @@ var portalHost = (0, _react.useContext)(PortalContext);

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;

@@ -10,4 +12,2 @@ exports.default = void 0;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var getModifiers = function getModifiers(_ref) {

@@ -14,0 +14,0 @@ var _ref2;

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;

@@ -37,4 +39,2 @@ var _exportNames = {

exports.uniqueId = _uniqueId.default;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.uniqueId = _uniqueId.default;
{
"name": "react-stick",
"version": "3.0.4",
"version": "3.0.5",
"description": "React component to stick a portaled node to an anchor node",

@@ -36,3 +36,7 @@ "main": "lib/index.js",

"@babel/core": "7.8.7",
"@babel/plugin-proposal-object-rest-spread": "^7.9.5",
"@babel/plugin-transform-runtime": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"@babel/preset-flow": "7.8.3",
"@babel/preset-react": "^7.9.4",
"babel-eslint": "10.1.0",

@@ -57,3 +61,3 @@ "babel-loader": "^8.1.0",

"inferno": "7.4.2",
"nwb": "0.24.3",
"nwb": "0.24.5",
"prettier": "1.19.1",

@@ -60,0 +64,0 @@ "react": "^16.13.1",

@@ -13,3 +13,3 @@ // @flow

useRef,
useState
useState,
} from 'react'

@@ -41,2 +41,3 @@ import { createPortal } from 'react-dom'

const [left, setLeft] = useState(0)
const [visible, setVisible] = useState(!!node)

@@ -51,4 +52,8 @@ const [host, hostParent] = useHost(transportTo)

useEffect(() => {
setVisible(!!node)
}, [node])
useLayoutEffect(() => {
if (node) {
if (visible) {
hostParent.appendChild(host)

@@ -60,3 +65,3 @@

}
}, [host, hostParent, node])
}, [host, hostParent, visible])

@@ -96,3 +101,3 @@ const measure = useCallback(() => {

{...rest}
ref={node => {
ref={(node) => {
if (typeof ref === 'function') {

@@ -121,3 +126,3 @@ ref(node)

top,
left
left,
}}

@@ -124,0 +129,0 @@ >

import expect from 'expect'
import React, { cloneElement } from 'react'
import { render as renderBase, unmountComponentAtNode } from 'react-dom'
import { act } from 'react-dom/test-utils'
import Stick from 'src/'

@@ -15,14 +16,17 @@

let called = false
renderBase(
<div style={{ width: 10, height: 10 }}>
{cloneElement(stick, {
node:
stick.props.node &&
cloneElement(stick.props.node, {
ref: el => !!el && !called && window.setTimeout(callback, 1),
}),
})}
</div>,
host
)
act(() => {
renderBase(
<div style={{ width: 10, height: 10 }}>
{cloneElement(stick, {
node:
stick.props.node &&
cloneElement(stick.props.node, {
ref: (el) => !!el && !called && window.setTimeout(callback, 1),
}),
})}
</div>,
host
)
})
}

@@ -40,3 +44,3 @@

it('should work if the node is only provided after the initial mount', done => {
it('should work if the node is only provided after the initial mount', (done) => {
render(<Stick position="middle right">{anchor}</Stick>, host)

@@ -58,3 +62,3 @@ render(

it('should unmount node container if no node is passed anymore', done => {
it('should unmount node container if no node is passed anymore', (done) => {
render(<Stick node={node}>{anchor}</Stick>, host, () => {

@@ -73,3 +77,3 @@ const bodyChildrenCountWithStick = document.body.childElementCount

it('should correctly apply `sameWidth` if set after initial mount', done => {
it('should correctly apply `sameWidth` if set after initial mount', (done) => {
render(<Stick node={node}>{anchor}</Stick>, host, () => {

@@ -93,3 +97,3 @@ render(

it('should correctly handle clearing of `sameWidth` after initial mount', done => {
it('should correctly handle clearing of `sameWidth` after initial mount', (done) => {
render(

@@ -111,3 +115,3 @@ <Stick sameWidth node={node}>

it('should handle switching to `updateOnAnimationFrame` correctly', done => {
it('should handle switching to `updateOnAnimationFrame` correctly', (done) => {
render(

@@ -136,3 +140,3 @@ <Stick node={node} position="middle right">

it('should handle switching back from `updateOnAnimationFrame` correctly', done => {
it('should handle switching back from `updateOnAnimationFrame` correctly', (done) => {
render(

@@ -139,0 +143,0 @@ <Stick node={node} position="middle right" updateOnAnimationFrame>

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