react-floater
Advanced tools
Comparing version 0.8.0-0 to 0.8.0
@@ -11,6 +11,6 @@ import * as React from 'react'; | ||
if (placement.startsWith('top')) { | ||
points = "0,0 " + x / 2 + "," + y + " " + x + ",0"; | ||
points = "0,0 ".concat(x / 2, ",").concat(y, " ").concat(x, ",0"); | ||
} | ||
else if (placement.startsWith('bottom')) { | ||
points = x + "," + y + " " + x / 2 + ",0 0," + y; | ||
points = "".concat(x, ",").concat(y, " ").concat(x / 2, ",0 0,").concat(y); | ||
} | ||
@@ -20,3 +20,3 @@ else if (placement.startsWith('left')) { | ||
x = length; | ||
points = "0,0 " + x + "," + y / 2 + " 0," + y; | ||
points = "0,0 ".concat(x, ",").concat(y / 2, " 0,").concat(y); | ||
} | ||
@@ -26,3 +26,3 @@ else if (placement.startsWith('right')) { | ||
x = length; | ||
points = x + "," + y + " " + x + ",0 0," + y / 2; | ||
points = "".concat(x, ",").concat(y, " ").concat(x, ",0 0,").concat(y / 2); | ||
} | ||
@@ -29,0 +29,0 @@ return (React.createElement("span", { ref: arrowRef, className: "__floater__arrow", style: arrowStyles }, |
@@ -17,3 +17,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
return (React.createElement("button", { "aria-label": "close", onClick: onClick, style: style, type: "button" }, | ||
React.createElement("svg", { height: height + "px", preserveAspectRatio: "xMidYMid", version: "1.1", viewBox: "0 0 18 18", width: width + "px", xmlns: "http://www.w3.org/2000/svg" }, | ||
React.createElement("svg", { height: "".concat(height, "px"), preserveAspectRatio: "xMidYMid", version: "1.1", viewBox: "0 0 18 18", width: "".concat(width, "px"), xmlns: "http://www.w3.org/2000/svg" }, | ||
React.createElement("g", null, | ||
@@ -20,0 +20,0 @@ React.createElement("path", { d: "M8.13911129,9.00268191 L0.171521827,17.0258467 C-0.0498027049,17.248715 -0.0498027049,17.6098394 0.171521827,17.8327545 C0.28204354,17.9443526 0.427188206,17.9998706 0.572051765,17.9998706 C0.71714958,17.9998706 0.862013139,17.9443526 0.972581703,17.8327545 L9.0000937,9.74924618 L17.0276057,17.8327545 C17.1384085,17.9443526 17.2832721,17.9998706 17.4281356,17.9998706 C17.5729992,17.9998706 17.718097,17.9443526 17.8286656,17.8327545 C18.0499901,17.6098862 18.0499901,17.2487618 17.8286656,17.0258467 L9.86135722,9.00268191 L17.8340066,0.973848225 C18.0553311,0.750979934 18.0553311,0.389855532 17.8340066,0.16694039 C17.6126821,-0.0556467968 17.254037,-0.0556467968 17.0329467,0.16694039 L9.00042166,8.25611765 L0.967006424,0.167268345 C0.745681892,-0.0553188426 0.387317931,-0.0553188426 0.165993399,0.167268345 C-0.0553311331,0.390136635 -0.0553311331,0.751261038 0.165993399,0.974176179 L8.13920499,9.00268191 L8.13911129,9.00268191 Z", fill: color }))))); |
@@ -23,12 +23,12 @@ var __assign = (this && this.__assign) || function () { | ||
if (placement.startsWith('top')) { | ||
element.padding = "0 0 " + length + "px"; | ||
element.padding = "0 0 ".concat(length, "px"); | ||
} | ||
else if (placement.startsWith('bottom')) { | ||
element.padding = length + "px 0 0"; | ||
element.padding = "".concat(length, "px 0 0"); | ||
} | ||
else if (placement.startsWith('left')) { | ||
element.padding = "0 " + length + "px 0 0"; | ||
element.padding = "0 ".concat(length, "px 0 0"); | ||
} | ||
else if (placement.startsWith('right')) { | ||
element.padding = "0 0 0 " + length + "px"; | ||
element.padding = "0 0 0 ".concat(length, "px"); | ||
} | ||
@@ -35,0 +35,0 @@ } |
import * as React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
import is from 'is-lite'; | ||
import { canUseDOM, portalId, useSingleton } from '../utils'; | ||
import { canUseDOM, portalId } from '../modules/helpers'; | ||
import { useMount, useSingleton, useUnmount } from '../modules/hooks'; | ||
function ReactFloaterPortal(props) { | ||
@@ -25,3 +26,3 @@ var children = props.children, hasChildren = props.hasChildren, placement = props.placement, portalElement = props.portalElement, target = props.target, zIndex = props.zIndex; | ||
node.current.id = portalId; | ||
node.current.style.zIndex = "" + zIndex; | ||
node.current.style.zIndex = "".concat(zIndex); | ||
document.body.appendChild(node.current); | ||
@@ -32,3 +33,3 @@ } | ||
useSingleton(initialize); | ||
React.useEffect(function () { | ||
useMount(function () { | ||
if (!portalElement && !document.getElementById(portalId)) { | ||
@@ -42,20 +43,19 @@ if (node.current) { | ||
} | ||
return function () { | ||
if (!canUseDOM || !node) { | ||
return; | ||
} | ||
try { | ||
if (node.current && node.current.id === portalId && node.current.childElementCount === 0) { | ||
if (document.body.contains(node.current)) { | ||
document.body.removeChild(node.current); | ||
node.current = null; | ||
} | ||
}); | ||
useUnmount(function () { | ||
if (!canUseDOM || !node) { | ||
return; | ||
} | ||
try { | ||
if (node.current && node.current.id === portalId && node.current.childElementCount === 0) { | ||
if (document.body.contains(node.current)) { | ||
document.body.removeChild(node.current); | ||
node.current = null; | ||
} | ||
} | ||
catch (_a) { | ||
node.current = null; | ||
} | ||
}; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
} | ||
catch (_a) { | ||
node.current = null; | ||
} | ||
}); | ||
if (node.current) { | ||
@@ -62,0 +62,0 @@ if (!hasChildren && !target && placement !== 'center') { |
@@ -56,4 +56,5 @@ var __assign = (this && this.__assign) || function () { | ||
import { POSITIONING_PROPS, STATUS } from './literals'; | ||
import getStyles from './styles'; | ||
import { canUseDOM, enhanceProps, getFallbackPlacements, getModifiers, isFixed, isMobile, log, mergeModifier, once, randomId, useSetState, useSingleton, useUpdateEffect, } from './utils'; | ||
import { canUseDOM, enhanceProps, getFallbackPlacements, getModifiers, isFixed, isMobile, log, mergeModifier, once, randomId, } from './modules/helpers'; | ||
import { useMount, useSetState, useSingleton, useUnmount, useUpdateEffect } from './modules/hooks'; | ||
import getStyles from './modules/styles'; | ||
export default function ReactFloater(props) { | ||
@@ -244,3 +245,3 @@ var _a = enhanceProps(props), autoOpen = _a.autoOpen, callback = _a.callback, children = _a.children, component = _a.component, content = _a.content, debug = _a.debug, disableFlip = _a.disableFlip, disableHoverToClick = _a.disableHoverToClick, event = _a.event, eventDelay = _a.eventDelay, footer = _a.footer, getPopper = _a.getPopper, hideArrow = _a.hideArrow, id = _a.id, modifiers = _a.modifiers, offset = _a.offset, open = _a.open, placement = _a.placement, portalElement = _a.portalElement, showCloseButton = _a.showCloseButton, style = _a.style, styles = _a.styles, target = _a.target, title = _a.title, wrapperOptions = _a.wrapperOptions; | ||
} | ||
], __read((rest ? Object.values(rest) : [])), false), | ||
], __read(Object.values(rest)), false), | ||
onFirstUpdate: function (popperState) { | ||
@@ -384,6 +385,8 @@ updateState({ | ||
}, [currentDebug, currentEvent, event, eventDelay, open, positionWrapper, status, toggle]); | ||
// Handle mount/unmount | ||
React.useEffect(function () { | ||
var cleanUpFn = cleanUp.current; | ||
var handleLoadFn = handleLoad.current; | ||
useSingleton(function () { | ||
if (canUseDOM) { | ||
window.addEventListener('load', handleLoad.current); | ||
} | ||
}); | ||
useMount(function () { | ||
isMounted.current = true; | ||
@@ -403,12 +406,10 @@ log({ | ||
initPopper.current(); | ||
return function () { | ||
isMounted.current = false; | ||
cleanUpFn(); | ||
window.removeEventListener('load', handleLoadFn); | ||
}; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
}); | ||
useUnmount(function () { | ||
isMounted.current = false; | ||
cleanUp.current(); | ||
window.removeEventListener('load', handleLoad.current); | ||
}); | ||
// handle changes | ||
useUpdateEffect(function () { | ||
var _a; | ||
if (!canUseDOM) { | ||
@@ -436,3 +437,3 @@ return; | ||
if (popperRef.current) { | ||
(_a = popperRef.current) === null || _a === void 0 ? void 0 : _a.destroy(); | ||
popperRef.current.destroy(); | ||
} | ||
@@ -452,7 +453,2 @@ initPopper.current(); | ||
}); | ||
useSingleton(function () { | ||
if (canUseDOM) { | ||
window.addEventListener('load', handleLoad.current); | ||
} | ||
}); | ||
var wrapper = (React.createElement(Wrapper, { childRef: childRef, id: id || internalId.current, isControlled: is.boolean(open), onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, status: status, style: style, styles: currentStyles.wrapper, wrapperRef: wrapperRef }, children)); | ||
@@ -459,0 +455,0 @@ return (React.createElement(React.Fragment, null, |
@@ -13,6 +13,6 @@ "use strict"; | ||
if (placement.startsWith('top')) { | ||
points = "0,0 " + x / 2 + "," + y + " " + x + ",0"; | ||
points = "0,0 ".concat(x / 2, ",").concat(y, " ").concat(x, ",0"); | ||
} | ||
else if (placement.startsWith('bottom')) { | ||
points = x + "," + y + " " + x / 2 + ",0 0," + y; | ||
points = "".concat(x, ",").concat(y, " ").concat(x / 2, ",0 0,").concat(y); | ||
} | ||
@@ -22,3 +22,3 @@ else if (placement.startsWith('left')) { | ||
x = length; | ||
points = "0,0 " + x + "," + y / 2 + " 0," + y; | ||
points = "0,0 ".concat(x, ",").concat(y / 2, " 0,").concat(y); | ||
} | ||
@@ -28,3 +28,3 @@ else if (placement.startsWith('right')) { | ||
x = length; | ||
points = x + "," + y + " " + x + ",0 0," + y / 2; | ||
points = "".concat(x, ",").concat(y, " ").concat(x, ",0 0,").concat(y / 2); | ||
} | ||
@@ -31,0 +31,0 @@ return (React.createElement("span", { ref: arrowRef, className: "__floater__arrow", style: arrowStyles }, |
@@ -19,3 +19,3 @@ "use strict"; | ||
return (React.createElement("button", { "aria-label": "close", onClick: onClick, style: style, type: "button" }, | ||
React.createElement("svg", { height: height + "px", preserveAspectRatio: "xMidYMid", version: "1.1", viewBox: "0 0 18 18", width: width + "px", xmlns: "http://www.w3.org/2000/svg" }, | ||
React.createElement("svg", { height: "".concat(height, "px"), preserveAspectRatio: "xMidYMid", version: "1.1", viewBox: "0 0 18 18", width: "".concat(width, "px"), xmlns: "http://www.w3.org/2000/svg" }, | ||
React.createElement("g", null, | ||
@@ -22,0 +22,0 @@ React.createElement("path", { d: "M8.13911129,9.00268191 L0.171521827,17.0258467 C-0.0498027049,17.248715 -0.0498027049,17.6098394 0.171521827,17.8327545 C0.28204354,17.9443526 0.427188206,17.9998706 0.572051765,17.9998706 C0.71714958,17.9998706 0.862013139,17.9443526 0.972581703,17.8327545 L9.0000937,9.74924618 L17.0276057,17.8327545 C17.1384085,17.9443526 17.2832721,17.9998706 17.4281356,17.9998706 C17.5729992,17.9998706 17.718097,17.9443526 17.8286656,17.8327545 C18.0499901,17.6098862 18.0499901,17.2487618 17.8286656,17.0258467 L9.86135722,9.00268191 L17.8340066,0.973848225 C18.0553311,0.750979934 18.0553311,0.389855532 17.8340066,0.16694039 C17.6126821,-0.0556467968 17.254037,-0.0556467968 17.0329467,0.16694039 L9.00042166,8.25611765 L0.967006424,0.167268345 C0.745681892,-0.0553188426 0.387317931,-0.0553188426 0.165993399,0.167268345 C-0.0553311331,0.390136635 -0.0553311331,0.751261038 0.165993399,0.974176179 L8.13920499,9.00268191 L8.13911129,9.00268191 Z", fill: color }))))); |
@@ -25,12 +25,12 @@ "use strict"; | ||
if (placement.startsWith('top')) { | ||
element.padding = "0 0 " + length + "px"; | ||
element.padding = "0 0 ".concat(length, "px"); | ||
} | ||
else if (placement.startsWith('bottom')) { | ||
element.padding = length + "px 0 0"; | ||
element.padding = "".concat(length, "px 0 0"); | ||
} | ||
else if (placement.startsWith('left')) { | ||
element.padding = "0 " + length + "px 0 0"; | ||
element.padding = "0 ".concat(length, "px 0 0"); | ||
} | ||
else if (placement.startsWith('right')) { | ||
element.padding = "0 0 0 " + length + "px"; | ||
element.padding = "0 0 0 ".concat(length, "px"); | ||
} | ||
@@ -37,0 +37,0 @@ } |
@@ -6,3 +6,4 @@ "use strict"; | ||
var is_lite_1 = require("is-lite"); | ||
var utils_1 = require("../utils"); | ||
var helpers_1 = require("../modules/helpers"); | ||
var hooks_1 = require("../modules/hooks"); | ||
function ReactFloaterPortal(props) { | ||
@@ -12,3 +13,3 @@ var children = props.children, hasChildren = props.hasChildren, placement = props.placement, portalElement = props.portalElement, target = props.target, zIndex = props.zIndex; | ||
var initialize = React.useCallback(function () { | ||
if (!utils_1.canUseDOM) { | ||
if (!helpers_1.canUseDOM) { | ||
return; | ||
@@ -28,4 +29,4 @@ } | ||
node.current = document.createElement('div'); | ||
node.current.id = utils_1.portalId; | ||
node.current.style.zIndex = "" + zIndex; | ||
node.current.id = helpers_1.portalId; | ||
node.current.style.zIndex = "".concat(zIndex); | ||
document.body.appendChild(node.current); | ||
@@ -35,5 +36,5 @@ } | ||
}, [portalElement, zIndex]); | ||
(0, utils_1.useSingleton)(initialize); | ||
React.useEffect(function () { | ||
if (!portalElement && !document.getElementById(utils_1.portalId)) { | ||
(0, hooks_1.useSingleton)(initialize); | ||
(0, hooks_1.useMount)(function () { | ||
if (!portalElement && !document.getElementById(helpers_1.portalId)) { | ||
if (node.current) { | ||
@@ -46,20 +47,19 @@ document.body.appendChild(node.current); | ||
} | ||
return function () { | ||
if (!utils_1.canUseDOM || !node) { | ||
return; | ||
} | ||
try { | ||
if (node.current && node.current.id === utils_1.portalId && node.current.childElementCount === 0) { | ||
if (document.body.contains(node.current)) { | ||
document.body.removeChild(node.current); | ||
node.current = null; | ||
} | ||
}); | ||
(0, hooks_1.useUnmount)(function () { | ||
if (!helpers_1.canUseDOM || !node) { | ||
return; | ||
} | ||
try { | ||
if (node.current && node.current.id === helpers_1.portalId && node.current.childElementCount === 0) { | ||
if (document.body.contains(node.current)) { | ||
document.body.removeChild(node.current); | ||
node.current = null; | ||
} | ||
} | ||
catch (_a) { | ||
node.current = null; | ||
} | ||
}; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
} | ||
catch (_a) { | ||
node.current = null; | ||
} | ||
}); | ||
if (node.current) { | ||
@@ -66,0 +66,0 @@ if (!hasChildren && !target && placement !== 'center') { |
@@ -58,7 +58,8 @@ "use strict"; | ||
var literals_1 = require("./literals"); | ||
var styles_1 = require("./styles"); | ||
var utils_1 = require("./utils"); | ||
var helpers_1 = require("./modules/helpers"); | ||
var hooks_1 = require("./modules/hooks"); | ||
var styles_1 = require("./modules/styles"); | ||
function ReactFloater(props) { | ||
var _a = (0, utils_1.enhanceProps)(props), autoOpen = _a.autoOpen, callback = _a.callback, children = _a.children, component = _a.component, content = _a.content, debug = _a.debug, disableFlip = _a.disableFlip, disableHoverToClick = _a.disableHoverToClick, event = _a.event, eventDelay = _a.eventDelay, footer = _a.footer, getPopper = _a.getPopper, hideArrow = _a.hideArrow, id = _a.id, modifiers = _a.modifiers, offset = _a.offset, open = _a.open, placement = _a.placement, portalElement = _a.portalElement, showCloseButton = _a.showCloseButton, style = _a.style, styles = _a.styles, target = _a.target, title = _a.title, wrapperOptions = _a.wrapperOptions; | ||
var _b = __read((0, utils_1.useSetState)({ | ||
var _a = (0, helpers_1.enhanceProps)(props), autoOpen = _a.autoOpen, callback = _a.callback, children = _a.children, component = _a.component, content = _a.content, debug = _a.debug, disableFlip = _a.disableFlip, disableHoverToClick = _a.disableHoverToClick, event = _a.event, eventDelay = _a.eventDelay, footer = _a.footer, getPopper = _a.getPopper, hideArrow = _a.hideArrow, id = _a.id, modifiers = _a.modifiers, offset = _a.offset, open = _a.open, placement = _a.placement, portalElement = _a.portalElement, showCloseButton = _a.showCloseButton, style = _a.style, styles = _a.styles, target = _a.target, title = _a.title, wrapperOptions = _a.wrapperOptions; | ||
var _b = __read((0, hooks_1.useSetState)({ | ||
currentPlacement: placement || 'bottom', | ||
@@ -73,3 +74,3 @@ positionWrapper: !!(wrapperOptions === null || wrapperOptions === void 0 ? void 0 : wrapperOptions.position) && !!target, | ||
var floaterRef = React.useRef(null); | ||
var internalId = React.useRef((0, utils_1.randomId)()); | ||
var internalId = React.useRef((0, helpers_1.randomId)()); | ||
var isMounted = React.useRef(false); | ||
@@ -104,3 +105,3 @@ var popperRef = React.useRef(); | ||
var targetElement = React.useRef(function () { | ||
if (!utils_1.canUseDOM) { | ||
if (!helpers_1.canUseDOM) { | ||
return null; | ||
@@ -117,6 +118,6 @@ } | ||
var currentDebug = React.useMemo(function () { | ||
return debug || utils_1.canUseDOM ? !!window.ReactFloaterDebug : false; | ||
return debug || helpers_1.canUseDOM ? !!window.ReactFloaterDebug : false; | ||
}, [debug]); | ||
var currentEvent = React.useMemo(function () { | ||
if (event === 'hover' && (0, utils_1.isMobile)() && !disableHoverToClick) { | ||
if (event === 'hover' && (0, helpers_1.isMobile)() && !disableHoverToClick) { | ||
return 'click'; | ||
@@ -183,8 +184,8 @@ } | ||
if (floaterRef.current) { | ||
var _a = (0, utils_1.getModifiers)(modifiers), arrow = _a.arrow, flip = _a.flip, offsetModifier = _a.offset, rest = __rest(_a, ["arrow", "flip", "offset"]); | ||
var _a = (0, helpers_1.getModifiers)(modifiers), arrow = _a.arrow, flip = _a.flip, offsetModifier = _a.offset, rest = __rest(_a, ["arrow", "flip", "offset"]); | ||
popperRef.current = (0, core_1.createPopper)(element, floaterRef.current, { | ||
placement: placement, | ||
strategy: (0, utils_1.isFixed)(childRef.current) ? 'fixed' : 'absolute', | ||
strategy: (0, helpers_1.isFixed)(childRef.current) ? 'fixed' : 'absolute', | ||
modifiers: __spreadArray([ | ||
(0, utils_1.mergeModifier)({ | ||
(0, helpers_1.mergeModifier)({ | ||
name: 'arrow', | ||
@@ -197,3 +198,3 @@ enabled: !hideArrow, | ||
}, arrow), | ||
(0, utils_1.mergeModifier)({ | ||
(0, helpers_1.mergeModifier)({ | ||
name: 'flip', | ||
@@ -203,6 +204,6 @@ enabled: !disableFlip, | ||
altAxis: false, | ||
fallbackPlacements: (0, utils_1.getFallbackPlacements)(placement || 'bottom'), | ||
fallbackPlacements: (0, helpers_1.getFallbackPlacements)(placement || 'bottom'), | ||
}, | ||
}, flip), | ||
(0, utils_1.mergeModifier)({ | ||
(0, helpers_1.mergeModifier)({ | ||
name: 'offset', | ||
@@ -252,3 +253,3 @@ options: { | ||
} | ||
], __read((rest ? Object.values(rest) : [])), false), | ||
], __read(Object.values(rest)), false), | ||
onFirstUpdate: function (popperState) { | ||
@@ -333,3 +334,3 @@ updateState({ | ||
if (callback) { | ||
callback(stateRef.current.status === literals_1.STATUS.OPEN ? 'open' : 'close', (0, utils_1.enhanceProps)(props)); | ||
callback(stateRef.current.status === literals_1.STATUS.OPEN ? 'open' : 'close', (0, helpers_1.enhanceProps)(props)); | ||
} | ||
@@ -344,3 +345,3 @@ }); | ||
if (currentEvent === 'click' || (currentEvent === 'hover' && positionWrapper)) { | ||
(0, utils_1.log)({ | ||
(0, helpers_1.log)({ | ||
title: 'click', | ||
@@ -354,6 +355,6 @@ data: [{ event: event, status: status === literals_1.STATUS.OPEN ? 'closing' : 'opening' }], | ||
var handleMouseEnter = React.useCallback(function () { | ||
if (is_lite_1.default.boolean(open) || (0, utils_1.isMobile)() || currentEvent !== 'hover') { | ||
if (is_lite_1.default.boolean(open) || (0, helpers_1.isMobile)() || currentEvent !== 'hover') { | ||
return; | ||
} | ||
(0, utils_1.log)({ | ||
(0, helpers_1.log)({ | ||
title: 'mouseEnter', | ||
@@ -370,3 +371,3 @@ data: [{ key: 'originalEvent', value: event }], | ||
var handleMouseLeave = React.useCallback(function () { | ||
if (is_lite_1.default.boolean(open) || (0, utils_1.isMobile)()) { | ||
if (is_lite_1.default.boolean(open) || (0, helpers_1.isMobile)()) { | ||
return; | ||
@@ -376,3 +377,3 @@ } | ||
if (currentEvent === 'hover') { | ||
(0, utils_1.log)({ | ||
(0, helpers_1.log)({ | ||
title: 'mouseLeave', | ||
@@ -397,8 +398,10 @@ data: [{ key: 'originalEvent', value: event }], | ||
}, [currentDebug, currentEvent, event, eventDelay, open, positionWrapper, status, toggle]); | ||
// Handle mount/unmount | ||
React.useEffect(function () { | ||
var cleanUpFn = cleanUp.current; | ||
var handleLoadFn = handleLoad.current; | ||
(0, hooks_1.useSingleton)(function () { | ||
if (helpers_1.canUseDOM) { | ||
window.addEventListener('load', handleLoad.current); | ||
} | ||
}); | ||
(0, hooks_1.useMount)(function () { | ||
isMounted.current = true; | ||
(0, utils_1.log)({ | ||
(0, helpers_1.log)({ | ||
title: 'init', | ||
@@ -416,13 +419,11 @@ data: { | ||
initPopper.current(); | ||
return function () { | ||
isMounted.current = false; | ||
cleanUpFn(); | ||
window.removeEventListener('load', handleLoadFn); | ||
}; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
}); | ||
(0, hooks_1.useUnmount)(function () { | ||
isMounted.current = false; | ||
cleanUp.current(); | ||
window.removeEventListener('load', handleLoad.current); | ||
}); | ||
// handle changes | ||
(0, utils_1.useUpdateEffect)(function () { | ||
var _a; | ||
if (!utils_1.canUseDOM) { | ||
(0, hooks_1.useUpdateEffect)(function () { | ||
if (!helpers_1.canUseDOM) { | ||
return; | ||
@@ -449,3 +450,3 @@ } | ||
if (popperRef.current) { | ||
(_a = popperRef.current) === null || _a === void 0 ? void 0 : _a.destroy(); | ||
popperRef.current.destroy(); | ||
} | ||
@@ -455,3 +456,3 @@ initPopper.current(); | ||
if (floaterRef.current && changed('status', [literals_1.STATUS.RENDER, literals_1.STATUS.CLOSING])) { | ||
(0, utils_1.once)(floaterRef.current, 'transitionend', handleTransitionEnd.current); | ||
(0, helpers_1.once)(floaterRef.current, 'transitionend', handleTransitionEnd.current); | ||
} | ||
@@ -466,7 +467,2 @@ if (changed('status', literals_1.STATUS.IDLE, literals_1.STATUS.CLOSING) && popperRef.current) { | ||
}); | ||
(0, utils_1.useSingleton)(function () { | ||
if (utils_1.canUseDOM) { | ||
window.addEventListener('load', handleLoad.current); | ||
} | ||
}); | ||
var wrapper = (React.createElement(Wrapper_1.default, { childRef: childRef, id: id || internalId.current, isControlled: is_lite_1.default.boolean(open), onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, status: status, style: style, styles: currentStyles.wrapper, wrapperRef: wrapperRef }, children)); | ||
@@ -473,0 +469,0 @@ return (React.createElement(React.Fragment, null, |
{ | ||
"name": "react-floater", | ||
"version": "0.8.0-0", | ||
"version": "0.8.0", | ||
"description": "Floaters everywhere!", | ||
@@ -39,3 +39,3 @@ "author": "Gil Barbara <gilbarbara@gmail.com>", | ||
"dependencies": { | ||
"@popperjs/core": "^2.10.1", | ||
"@popperjs/core": "^2.11.0", | ||
"deepmerge": "^4.2.2", | ||
@@ -50,30 +50,30 @@ "exenv": "^1.2.2", | ||
"@gilbarbara/tsconfig": "^0.1.0", | ||
"@size-limit/preset-small-lib": "^5.0.3", | ||
"@testing-library/dom": "^8.5.0", | ||
"@testing-library/jest-dom": "^5.14.1", | ||
"@testing-library/react": "^12.1.0", | ||
"@size-limit/preset-small-lib": "^7.0.4", | ||
"@testing-library/dom": "^8.11.1", | ||
"@testing-library/jest-dom": "^5.16.1", | ||
"@testing-library/react": "^12.1.2", | ||
"@types/enzyme-adapter-react-16": "^1.0.6", | ||
"@types/exenv": "^1.2.0", | ||
"@types/jest": "^27.0.1", | ||
"@types/node": "^16.9.2", | ||
"@types/react": "^17.0.21", | ||
"@types/react-dom": "^17.0.9", | ||
"@types/styled-components": "^5.1.14", | ||
"@types/jest": "^27.0.3", | ||
"@types/node": "^17.0.0", | ||
"@types/react": "^17.0.37", | ||
"@types/react-dom": "^17.0.11", | ||
"@types/styled-components": "^5.1.18", | ||
"del-cli": "^4.0.1", | ||
"husky": "^4.3.8", | ||
"is-ci-cli": "^2.2.0", | ||
"jest": "^27.2.0", | ||
"jest-extended": "^0.11.5", | ||
"jest": "^27.4.5", | ||
"jest-extended": "^1.2.0", | ||
"jest-serializer-html": "^7.1.0", | ||
"jest-watch-typeahead": "^0.6.4", | ||
"lint-staged": "^11.1.2", | ||
"jest-watch-typeahead": "^1.0.0", | ||
"lint-staged": "^12.1.3", | ||
"react": "^16.14.0", | ||
"react-dom": "^16.14.0", | ||
"repo-tools": "^0.2.2", | ||
"size-limit": "^5.0.3", | ||
"styled-components": "^5.3.1", | ||
"ts-jest": "^27.0.5", | ||
"ts-node": "^10.2.1", | ||
"type-fest": "^2.3.3", | ||
"typescript": "^4.4.3" | ||
"size-limit": "^7.0.4", | ||
"styled-components": "^5.3.3", | ||
"ts-jest": "^27.1.2", | ||
"ts-node": "^10.4.0", | ||
"type-fest": "^2.8.0", | ||
"typescript": "^4.5.4" | ||
}, | ||
@@ -80,0 +80,0 @@ "scripts": { |
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
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
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
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
227164
87
3942
0
Updated@popperjs/core@^2.11.0