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

dibs-react-tooltip

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dibs-react-tooltip - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

.idea/copyright/profiles_settings.xml

859

dist/Tooltip.js

@@ -1,12 +0,3 @@

(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"), require("classnames"));
else if(typeof define === 'function' && define.amd)
define(["react", "classnames"], factory);
else {
var a = typeof exports === 'object' ? factory(require("react"), require("classnames")) : factory(root["react"], root["classnames"]);
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_2__) {
return /******/ (function(modules) { // webpackBootstrap
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache

@@ -74,3 +65,3 @@ /******/ var installedModules = {};

var lodashDebounce = __webpack_require__(3);
var styles = __webpack_require__(5);
var styles = __webpack_require__(4);

@@ -101,2 +92,3 @@ var oppositeDirections = {

}
return 0;
};

@@ -111,3 +103,3 @@ }

var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Tooltip).call(this, props));
var _this = _possibleConstructorReturn(this, (Tooltip.__proto__ || Object.getPrototypeOf(Tooltip)).call(this, props));

@@ -148,5 +140,5 @@ _this.state = {

value: function componentDidUpdate() {
var _state = this.state;
var isVisible = _state.isVisible;
var moved = _state.moved;
var _state = this.state,
isVisible = _state.isVisible,
moved = _state.moved;
var debounce = this.props.debounce;

@@ -172,5 +164,5 @@

value: function _getInitialTooltipPosition(elementRect, tooltipDirection, rootRect) {
var _props = this.props;
var hasTriangle = _props.hasTriangle;
var triangleSize = _props.triangleSize;
var _props = this.props,
hasTriangle = _props.hasTriangle,
triangleSize = _props.triangleSize;

@@ -242,10 +234,10 @@ var triangleSpacing = hasTriangle ? triangleSize : triangleSize / 2;

var _getElementsPositions2 = this._getElementsPositions();
var _getElementsPositions2 = this._getElementsPositions(),
elementRect = _getElementsPositions2.elementRect,
rootRect = _getElementsPositions2.rootRect;
var elementRect = _getElementsPositions2.elementRect;
var rootRect = _getElementsPositions2.rootRect;
var tooltipDirection = this.state.tooltipDirection;
var _props2 = this.props;
var thresholds = _props2.positionThresholds;
var triangleSize = _props2.triangleSize;
var _props2 = this.props,
thresholds = _props2.positionThresholds,
triangleSize = _props2.triangleSize;

@@ -385,9 +377,9 @@ var position = this._getInitialTooltipPosition(elementRect, tooltipDirection, rootRect);

value: function _renderContents(containerStyle) {
var _props3 = this.props;
var className = _props3.className;
var children = _props3.children;
var hasTriangle = _props3.hasTriangle;
var hasClose = _props3.hasClose;
var containerClass = _props3.containerClass;
var onClick = _props3.onClick;
var _props3 = this.props,
className = _props3.className,
children = _props3.children,
hasTriangle = _props3.hasTriangle,
hasClose = _props3.hasClose,
containerClass = _props3.containerClass,
onClick = _props3.onClick;
var tooltipDirection = this.state.tooltipDirection;

@@ -418,8 +410,8 @@

value: function _renderTriangle(direction) {
var _props4 = this.props;
var triangleSize = _props4.triangleSize;
var triangleClass = _props4.triangleClass;
var _state2 = this.state;
var left = _state2.triangleLeft;
var top = _state2.triangleTop;
var _props4 = this.props,
triangleSize = _props4.triangleSize,
triangleClass = _props4.triangleClass;
var _state2 = this.state,
left = _state2.triangleLeft,
top = _state2.triangleTop;

@@ -463,5 +455,5 @@ var triangleClassName = classNames(styles.triangle, triangleClass);

value: function _renderClose() {
var _props5 = this.props;
var closeClass = _props5.closeClass;
var onCloseClick = _props5.onCloseClick;
var _props5 = this.props,
closeClass = _props5.closeClass,
onCloseClick = _props5.onCloseClick;

@@ -485,5 +477,5 @@ var closeClassName = classNames(styles.close, closeClass);

var _state3 = this.state;
var top = _state3.top;
var left = _state3.left;
var _state3 = this.state,
top = _state3.top,
left = _state3.left;

@@ -560,758 +552,73 @@ var containerStyle = { top: top, left: left };

module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
module.exports = require("react");
/***/ },
/* 2 */
/***/ function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_2__;
/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {
/**
* lodash 3.1.1 (Custom Build) <https://lodash.com/>
* Build: `lodash modern modularize exports="npm" -o ./`
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <https://lodash.com/license>
*/
var getNative = __webpack_require__(4);
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
Copyright (c) 2016 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
/* global define */
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
(function () {
'use strict';
/* Native method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max,
nativeNow = getNative(Date, 'now');
var hasOwn = {}.hasOwnProperty;
/**
* Gets the number of milliseconds that have elapsed since the Unix epoch
* (1 January 1970 00:00:00 UTC).
*
* @static
* @memberOf _
* @category Date
* @example
*
* _.defer(function(stamp) {
* console.log(_.now() - stamp);
* }, _.now());
* // => logs the number of milliseconds it took for the deferred function to be invoked
*/
var now = nativeNow || function() {
return new Date().getTime();
};
function classNames () {
var classes = [];
/**
* Creates a debounced function that delays invoking `func` until after `wait`
* milliseconds have elapsed since the last time the debounced function was
* invoked. The debounced function comes with a `cancel` method to cancel
* delayed invocations. Provide an options object to indicate that `func`
* should be invoked on the leading and/or trailing edge of the `wait` timeout.
* Subsequent calls to the debounced function return the result of the last
* `func` invocation.
*
* **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
* on the trailing edge of the timeout only if the the debounced function is
* invoked more than once during the `wait` timeout.
*
* See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
* for details over the differences between `_.debounce` and `_.throttle`.
*
* @static
* @memberOf _
* @category Function
* @param {Function} func The function to debounce.
* @param {number} [wait=0] The number of milliseconds to delay.
* @param {Object} [options] The options object.
* @param {boolean} [options.leading=false] Specify invoking on the leading
* edge of the timeout.
* @param {number} [options.maxWait] The maximum time `func` is allowed to be
* delayed before it is invoked.
* @param {boolean} [options.trailing=true] Specify invoking on the trailing
* edge of the timeout.
* @returns {Function} Returns the new debounced function.
* @example
*
* // avoid costly calculations while the window size is in flux
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
*
* // invoke `sendMail` when the click event is fired, debouncing subsequent calls
* jQuery('#postbox').on('click', _.debounce(sendMail, 300, {
* 'leading': true,
* 'trailing': false
* }));
*
* // ensure `batchLog` is invoked once after 1 second of debounced calls
* var source = new EventSource('/stream');
* jQuery(source).on('message', _.debounce(batchLog, 250, {
* 'maxWait': 1000
* }));
*
* // cancel a debounced call
* var todoChanges = _.debounce(batchLog, 1000);
* Object.observe(models.todo, todoChanges);
*
* Object.observe(models, function(changes) {
* if (_.find(changes, { 'user': 'todo', 'type': 'delete'})) {
* todoChanges.cancel();
* }
* }, ['delete']);
*
* // ...at some point `models.todo` is changed
* models.todo.completed = true;
*
* // ...before 1 second has passed `models.todo` is deleted
* // which cancels the debounced `todoChanges` call
* delete models.todo;
*/
function debounce(func, wait, options) {
var args,
maxTimeoutId,
result,
stamp,
thisArg,
timeoutId,
trailingCall,
lastCalled = 0,
maxWait = false,
trailing = true;
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if (!arg) continue;
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
wait = wait < 0 ? 0 : (+wait || 0);
if (options === true) {
var leading = true;
trailing = false;
} else if (isObject(options)) {
leading = !!options.leading;
maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait);
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
var argType = typeof arg;
function cancel() {
if (timeoutId) {
clearTimeout(timeoutId);
}
if (maxTimeoutId) {
clearTimeout(maxTimeoutId);
}
lastCalled = 0;
maxTimeoutId = timeoutId = trailingCall = undefined;
}
if (argType === 'string' || argType === 'number') {
classes.push(arg);
} else if (Array.isArray(arg)) {
classes.push(classNames.apply(null, arg));
} else if (argType === 'object') {
for (var key in arg) {
if (hasOwn.call(arg, key) && arg[key]) {
classes.push(key);
}
}
}
}
function complete(isCalled, id) {
if (id) {
clearTimeout(id);
}
maxTimeoutId = timeoutId = trailingCall = undefined;
if (isCalled) {
lastCalled = now();
result = func.apply(thisArg, args);
if (!timeoutId && !maxTimeoutId) {
args = thisArg = undefined;
}
}
}
return classes.join(' ');
}
function delayed() {
var remaining = wait - (now() - stamp);
if (remaining <= 0 || remaining > wait) {
complete(trailingCall, maxTimeoutId);
} else {
timeoutId = setTimeout(delayed, remaining);
}
}
function maxDelayed() {
complete(trailing, timeoutId);
}
function debounced() {
args = arguments;
stamp = now();
thisArg = this;
trailingCall = trailing && (timeoutId || !leading);
if (maxWait === false) {
var leadingCall = leading && !timeoutId;
} else {
if (!maxTimeoutId && !leading) {
lastCalled = stamp;
}
var remaining = maxWait - (stamp - lastCalled),
isCalled = remaining <= 0 || remaining > maxWait;
if (isCalled) {
if (maxTimeoutId) {
maxTimeoutId = clearTimeout(maxTimeoutId);
}
lastCalled = stamp;
result = func.apply(thisArg, args);
}
else if (!maxTimeoutId) {
maxTimeoutId = setTimeout(maxDelayed, remaining);
}
}
if (isCalled && timeoutId) {
timeoutId = clearTimeout(timeoutId);
}
else if (!timeoutId && wait !== maxWait) {
timeoutId = setTimeout(delayed, wait);
}
if (leadingCall) {
isCalled = true;
result = func.apply(thisArg, args);
}
if (isCalled && !timeoutId && !maxTimeoutId) {
args = thisArg = undefined;
}
return result;
}
debounced.cancel = cancel;
return debounced;
}
/**
* Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(1);
* // => false
*/
function isObject(value) {
// Avoid a V8 JIT bug in Chrome 19-20.
// See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
var type = typeof value;
return !!value && (type == 'object' || type == 'function');
}
module.exports = debounce;
if (typeof module !== 'undefined' && module.exports) {
module.exports = classNames;
} else if (true) {
// register as 'classnames', consistent with npm package name
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function () {
return classNames;
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {
window.classNames = classNames;
}
}());
/***/ },
/* 4 */
/* 3 */
/***/ function(module, exports) {
/**
* lodash 3.9.1 (Custom Build) <https://lodash.com/>
* Build: `lodash modern modularize exports="npm" -o ./`
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <https://lodash.com/license>
*/
/** `Object#toString` result references. */
var funcTag = '[object Function]';
/** Used to detect host constructors (Safari > 5). */
var reIsHostCtor = /^\[object .+?Constructor\]$/;
/**
* Checks if `value` is object-like.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
*/
function isObjectLike(value) {
return !!value && typeof value == 'object';
}
/** Used for native method references. */
var objectProto = Object.prototype;
/** Used to resolve the decompiled source of functions. */
var fnToString = Function.prototype.toString;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
* of values.
*/
var objToString = objectProto.toString;
/** Used to detect if a method is native. */
var reIsNative = RegExp('^' +
fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
);
/**
* Gets the native function at `key` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the method to get.
* @returns {*} Returns the function if it's native, else `undefined`.
*/
function getNative(object, key) {
var value = object == null ? undefined : object[key];
return isNative(value) ? value : undefined;
}
/**
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
* _.isFunction(/abc/);
* // => false
*/
function isFunction(value) {
// The use of `Object#toString` avoids issues with the `typeof` operator
// in older versions of Chrome and Safari which return 'function' for regexes
// and Safari 8 equivalents which return 'object' for typed array constructors.
return isObject(value) && objToString.call(value) == funcTag;
}
/**
* Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(1);
* // => false
*/
function isObject(value) {
// Avoid a V8 JIT bug in Chrome 19-20.
// See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
var type = typeof value;
return !!value && (type == 'object' || type == 'function');
}
/**
* Checks if `value` is a native function.
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function, else `false`.
* @example
*
* _.isNative(Array.prototype.push);
* // => true
*
* _.isNative(_);
* // => false
*/
function isNative(value) {
if (value == null) {
return false;
}
if (isFunction(value)) {
return reIsNative.test(fnToString.call(value));
}
return isObjectLike(value) && reIsHostCtor.test(value);
}
module.exports = getNative;
module.exports = require("lodash.debounce");
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {
// style-loader: Adds some css to the DOM by adding a <style> tag
// load the styles
var content = __webpack_require__(6);
if(typeof content === 'string') content = [[module.id, content, '']];
// add the styles to the DOM
var update = __webpack_require__(8)(content, {});
if(content.locals) module.exports = content.locals;
// Hot Module Replacement
if(false) {
// When the styles change, update the <style> tags
if(!content.locals) {
module.hot.accept("!!./../node_modules/css-loader/index.js?localIdentName=[name]__[local]___[hash:base64:5]!./../node_modules/postcss-loader/index.js!./Tooltip.css", function() {
var newContent = require("!!./../node_modules/css-loader/index.js?localIdentName=[name]__[local]___[hash:base64:5]!./../node_modules/postcss-loader/index.js!./Tooltip.css");
if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
update(newContent);
});
}
// When the module is disposed, remove the <style> tags
module.hot.dispose(function() { update(); });
}
/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {
exports = module.exports = __webpack_require__(7)();
// imports
// module
exports.push([module.id, "/* styles for tooltip*/\n\n.Tooltip__defaultStyle___2PHGC {\n width: 250px;\n padding: 15px;\n font-size: 13px;\n line-height: 1.4;\n text-align: left;\n background: #fff;\n}\n\n.Tooltip__defaultClose___3C4eQ {\n fill: #000;\n}\n\n.Tooltip__defaultTriangle___2yE9C {\n fill: #fff;\n}\n\n.Tooltip__container___1iGSw {\n box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);\n display: block;\n position: absolute;\n z-index: 1000;\n cursor: default;\n}\n\n.Tooltip__inner___34nOg {\n position: relative;\n}\n\n.Tooltip__svg___1D5qj {\n max-height: 100%;\n max-width: 100%;\n}\n\n.Tooltip__close___39mNB {\n position: absolute;\n right: 8px;\n top: 8px;\n width: 10px;\n height: 10px;\n cursor: pointer;\n}\n\n.Tooltip__close___39mNB:hover {\n opacity: 0.9;\n}\n\n.Tooltip__triangle___XBkZH {\n position: absolute;\n}\n\n.Tooltip__triangleStroke___1qO6p {\n stroke: rgba(0, 0, 0, 0.1);\n}\n\n.Tooltip__top___3PYiq .Tooltip__triangle___XBkZH {\n -webkit-transform: rotate(180deg) translateZ(0);\n transform: rotate(180deg) translateZ(0);\n}\n\n.Tooltip__left___2ocL0 .Tooltip__triangle___XBkZH {\n -webkit-transform: rotate(90deg) translateZ(0);\n transform: rotate(90deg) translateZ(0);\n}\n\n.Tooltip__right___1Jius .Tooltip__triangle___XBkZH {\n -webkit-transform: rotate(-90deg) translateZ(0);\n transform: rotate(-90deg) translateZ(0);\n}\n", ""]);
// exports
exports.locals = {
"defaultStyle": "Tooltip__defaultStyle___2PHGC",
"defaultClose": "Tooltip__defaultClose___3C4eQ",
"defaultTriangle": "Tooltip__defaultTriangle___2yE9C",
"container": "Tooltip__container___1iGSw",
"inner": "Tooltip__inner___34nOg",
"svg": "Tooltip__svg___1D5qj",
"close": "Tooltip__close___39mNB Tooltip__svg___1D5qj",
"triangle": "Tooltip__triangle___XBkZH Tooltip__svg___1D5qj",
"triangleStroke": "Tooltip__triangleStroke___1qO6p",
"top": "Tooltip__top___3PYiq",
"left": "Tooltip__left___2ocL0",
"right": "Tooltip__right___1Jius"
};
/***/ },
/* 7 */
/* 4 */
/***/ function(module, exports) {
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
// css base code, injected by the css-loader
module.exports = function() {
var list = [];
// return the list of modules as css string
list.toString = function toString() {
var result = [];
for(var i = 0; i < this.length; i++) {
var item = this[i];
if(item[2]) {
result.push("@media " + item[2] + "{" + item[1] + "}");
} else {
result.push(item[1]);
}
}
return result.join("");
};
// import a list of modules into the list
list.i = function(modules, mediaQuery) {
if(typeof modules === "string")
modules = [[null, modules, ""]];
var alreadyImportedModules = {};
for(var i = 0; i < this.length; i++) {
var id = this[i][0];
if(typeof id === "number")
alreadyImportedModules[id] = true;
}
for(i = 0; i < modules.length; i++) {
var item = modules[i];
// skip already imported module
// this implementation is not 100% perfect for weird media query combinations
// when a module is imported multiple times with different media queries.
// I hope this will never occur (Hey this way we have smaller bundles)
if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
if(mediaQuery && !item[2]) {
item[2] = mediaQuery;
} else if(mediaQuery) {
item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
}
list.push(item);
}
}
};
return list;
};
// removed by extract-text-webpack-plugin
module.exports = {"defaultStyle":"Tooltip__defaultStyle___2PHGC","defaultClose":"Tooltip__defaultClose___3C4eQ","defaultTriangle":"Tooltip__defaultTriangle___2yE9C","container":"Tooltip__container___1iGSw","inner":"Tooltip__inner___34nOg","svg":"Tooltip__svg___1D5qj","close":"Tooltip__close___39mNB Tooltip__svg___1D5qj","triangle":"Tooltip__triangle___XBkZH Tooltip__svg___1D5qj","triangleStroke":"Tooltip__triangleStroke___1qO6p","top":"Tooltip__top___3PYiq","left":"Tooltip__left___2ocL0","right":"Tooltip__right___1Jius"};
/***/ },
/* 8 */
/***/ function(module, exports, __webpack_require__) {
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var stylesInDom = {},
memoize = function(fn) {
var memo;
return function () {
if (typeof memo === "undefined") memo = fn.apply(this, arguments);
return memo;
};
},
isOldIE = memoize(function() {
return /msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase());
}),
getHeadElement = memoize(function () {
return document.head || document.getElementsByTagName("head")[0];
}),
singletonElement = null,
singletonCounter = 0,
styleElementsInsertedAtTop = [];
module.exports = function(list, options) {
if(false) {
if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
}
options = options || {};
// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
// tags it will allow on a page
if (typeof options.singleton === "undefined") options.singleton = isOldIE();
// By default, add <style> tags to the bottom of <head>.
if (typeof options.insertAt === "undefined") options.insertAt = "bottom";
var styles = listToStyles(list);
addStylesToDom(styles, options);
return function update(newList) {
var mayRemove = [];
for(var i = 0; i < styles.length; i++) {
var item = styles[i];
var domStyle = stylesInDom[item.id];
domStyle.refs--;
mayRemove.push(domStyle);
}
if(newList) {
var newStyles = listToStyles(newList);
addStylesToDom(newStyles, options);
}
for(var i = 0; i < mayRemove.length; i++) {
var domStyle = mayRemove[i];
if(domStyle.refs === 0) {
for(var j = 0; j < domStyle.parts.length; j++)
domStyle.parts[j]();
delete stylesInDom[domStyle.id];
}
}
};
}
function addStylesToDom(styles, options) {
for(var i = 0; i < styles.length; i++) {
var item = styles[i];
var domStyle = stylesInDom[item.id];
if(domStyle) {
domStyle.refs++;
for(var j = 0; j < domStyle.parts.length; j++) {
domStyle.parts[j](item.parts[j]);
}
for(; j < item.parts.length; j++) {
domStyle.parts.push(addStyle(item.parts[j], options));
}
} else {
var parts = [];
for(var j = 0; j < item.parts.length; j++) {
parts.push(addStyle(item.parts[j], options));
}
stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
}
}
}
function listToStyles(list) {
var styles = [];
var newStyles = {};
for(var i = 0; i < list.length; i++) {
var item = list[i];
var id = item[0];
var css = item[1];
var media = item[2];
var sourceMap = item[3];
var part = {css: css, media: media, sourceMap: sourceMap};
if(!newStyles[id])
styles.push(newStyles[id] = {id: id, parts: [part]});
else
newStyles[id].parts.push(part);
}
return styles;
}
function insertStyleElement(options, styleElement) {
var head = getHeadElement();
var lastStyleElementInsertedAtTop = styleElementsInsertedAtTop[styleElementsInsertedAtTop.length - 1];
if (options.insertAt === "top") {
if(!lastStyleElementInsertedAtTop) {
head.insertBefore(styleElement, head.firstChild);
} else if(lastStyleElementInsertedAtTop.nextSibling) {
head.insertBefore(styleElement, lastStyleElementInsertedAtTop.nextSibling);
} else {
head.appendChild(styleElement);
}
styleElementsInsertedAtTop.push(styleElement);
} else if (options.insertAt === "bottom") {
head.appendChild(styleElement);
} else {
throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");
}
}
function removeStyleElement(styleElement) {
styleElement.parentNode.removeChild(styleElement);
var idx = styleElementsInsertedAtTop.indexOf(styleElement);
if(idx >= 0) {
styleElementsInsertedAtTop.splice(idx, 1);
}
}
function createStyleElement(options) {
var styleElement = document.createElement("style");
styleElement.type = "text/css";
insertStyleElement(options, styleElement);
return styleElement;
}
function createLinkElement(options) {
var linkElement = document.createElement("link");
linkElement.rel = "stylesheet";
insertStyleElement(options, linkElement);
return linkElement;
}
function addStyle(obj, options) {
var styleElement, update, remove;
if (options.singleton) {
var styleIndex = singletonCounter++;
styleElement = singletonElement || (singletonElement = createStyleElement(options));
update = applyToSingletonTag.bind(null, styleElement, styleIndex, false);
remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true);
} else if(obj.sourceMap &&
typeof URL === "function" &&
typeof URL.createObjectURL === "function" &&
typeof URL.revokeObjectURL === "function" &&
typeof Blob === "function" &&
typeof btoa === "function") {
styleElement = createLinkElement(options);
update = updateLink.bind(null, styleElement);
remove = function() {
removeStyleElement(styleElement);
if(styleElement.href)
URL.revokeObjectURL(styleElement.href);
};
} else {
styleElement = createStyleElement(options);
update = applyToTag.bind(null, styleElement);
remove = function() {
removeStyleElement(styleElement);
};
}
update(obj);
return function updateStyle(newObj) {
if(newObj) {
if(newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap)
return;
update(obj = newObj);
} else {
remove();
}
};
}
var replaceText = (function () {
var textStore = [];
return function (index, replacement) {
textStore[index] = replacement;
return textStore.filter(Boolean).join('\n');
};
})();
function applyToSingletonTag(styleElement, index, remove, obj) {
var css = remove ? "" : obj.css;
if (styleElement.styleSheet) {
styleElement.styleSheet.cssText = replaceText(index, css);
} else {
var cssNode = document.createTextNode(css);
var childNodes = styleElement.childNodes;
if (childNodes[index]) styleElement.removeChild(childNodes[index]);
if (childNodes.length) {
styleElement.insertBefore(cssNode, childNodes[index]);
} else {
styleElement.appendChild(cssNode);
}
}
}
function applyToTag(styleElement, obj) {
var css = obj.css;
var media = obj.media;
if(media) {
styleElement.setAttribute("media", media)
}
if(styleElement.styleSheet) {
styleElement.styleSheet.cssText = css;
} else {
while(styleElement.firstChild) {
styleElement.removeChild(styleElement.firstChild);
}
styleElement.appendChild(document.createTextNode(css));
}
}
function updateLink(linkElement, obj) {
var css = obj.css;
var sourceMap = obj.sourceMap;
if(sourceMap) {
// http://stackoverflow.com/a/26603875
css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
}
var blob = new Blob([css], { type: "text/css" });
var oldSrc = linkElement.href;
linkElement.href = URL.createObjectURL(blob);
if(oldSrc)
URL.revokeObjectURL(oldSrc);
}
/***/ }
/******/ ])
});
;
/******/ ]);
//# sourceMappingURL=Tooltip.js.map
{
"name": "dibs-react-tooltip",
"version": "0.2.1",
"version": "0.3.0",
"description": "1stdibs React tooltip component",
"main": "index.js",
"scripts": {
"build": "./node_modules/webpack/bin/webpack.js",
"test": "./node_modules/mocha/bin/mocha ./test/Tooltip_spec.js --compilers js:babel-core/register,css:./test/style-null-compiler"
"build": "webpack",
"prepublish": "yarn test && yarn run build",
"test": "mocha --compilers js:babel-core/register,css:./test/style-null-compiler"
},

@@ -33,16 +34,20 @@ "repository": {

"css-loader": "^0.23.0",
"lodash.debounce": "~3.1.1",
"extract-text-webpack-plugin": "^1.0.1",
"jasmine": "^2.3.2",
"karma": "^0.13.15",
"lodash.debounce": "^4.0.8",
"mocha": "^2.3.4",
"postcss-loader": "^0.8.0",
"react-addons-test-utils": "^0.14.3",
"react": "^15.0.0",
"react-addons-test-utils": "^15.3.2",
"sinon": "^1.17.2",
"style-loader": "^0.13.0",
"webpack": "^1.12.9"
},
"peerDependencies": {
"lodash.debounce": "^4.0.8",
"react": "^15.0.0"
},
"dependencies": {
"classnames": "^2.2.0",
"react": "^0.14.3 || ^15.0.0"
"classnames": "^2.2.5"
}
}
Usage:
```
const Tooltip = require('dibs-react-tooltip');
require('dibs-react-tooltip/dist/main.css'); // to include default styles
render() {

@@ -7,0 +7,0 @@ return (

@@ -34,2 +34,3 @@ /* eslint react/no-did-update-set-state: 0 */

}
return 0;
};

@@ -36,0 +37,0 @@ }

@@ -5,2 +5,3 @@ 'use strict';

var autoprefixer = require('autoprefixer');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

@@ -10,14 +11,14 @@ module.exports = {

output: {
libraryTarget: 'umd',
libraryTarget: 'commonjs2',
path: path.resolve(__dirname, './dist'),
filename: 'Tooltip.js'
},
externals: [
'react',
'classnames'
],
externals: {
'react': 'react',
'lodash.debounce': 'lodash.debounce'
},
module: {
loaders: [
{test: /\.jsx$/, loader: 'babel-loader', query: {plugins: ['transform-object-assign']}},
{test: /\.css$/, loader: 'style!css?localIdentName=[name]__[local]___[hash:base64:5]!postcss'}
{test: /\.css$/, loader: ExtractTextPlugin.extract('css?localIdentName=[name]__[local]___[hash:base64:5]!postcss')}
]

@@ -28,3 +29,6 @@ },

],
devtool: 'source-map'
devtool: 'source-map',
plugins: [
new ExtractTextPlugin('[name].css')
]
};

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