@elliemae/ds-popperjs 2.0.0-alpha.10 → 2.0.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/PopoverArrow.js +35 -24
- package/cjs/PopoverContent.js +52 -33
- package/cjs/config/useConfigDSPopperjs.js +20 -3
- package/cjs/config/useConfiguredDefaultModifiers.js +5 -4
- package/cjs/config/useConfiguredDefaultProps.js +13 -4
- package/cjs/config/useConfiguredMergedProps.js +5 -4
- package/cjs/index.js +17 -4
- package/cjs/propTypes.js +13 -1
- package/cjs/styled.js +37 -0
- package/esm/PopoverArrow.js +35 -24
- package/esm/PopoverContent.js +52 -32
- package/esm/config/useConfigDSPopperjs.js +21 -4
- package/esm/config/useConfiguredDefaultModifiers.js +5 -4
- package/esm/config/useConfiguredDefaultProps.js +13 -4
- package/esm/config/useConfiguredMergedProps.js +5 -4
- package/esm/index.js +17 -4
- package/esm/propTypes.js +13 -1
- package/esm/styled.js +27 -0
- package/package.json +11 -5
- package/types/PopoverContent.d.ts +1 -1
- package/types/config/useConfiguredDefaultProps.d.ts +3 -0
- package/types/config/useConfiguredMergedProps.d.ts +5 -2
- package/types/index.d.ts +48 -13
- package/types/propTypes.d.ts +54 -13
- package/types/styled.d.ts +11 -0
- package/cjs/package.json +0 -7
- package/esm/package.json +0 -7
package/cjs/PopoverArrow.js
CHANGED
|
@@ -13,31 +13,42 @@ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
|
13
13
|
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
14
14
|
|
|
15
15
|
var _svg;
|
|
16
|
+
const arrowWidth = 18;
|
|
17
|
+
const arrowHeight = 18;
|
|
16
18
|
const StyledArrow = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
17
19
|
componentId: "sc-olcdf1-0"
|
|
18
|
-
})(["position:absolute;width:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
20
|
+
})(["position:absolute;width:", "px;height:", "px;pointer-events:none;background-color:transparent;& .stroke{fill:", ";fill-opacity:0.4;}& .fill{fill:", ";}&[data-placement^='top']{svg{transform:rotateZ(180deg);}bottom:-", "px;}&[data-placement^='right']{svg{transform:rotateZ(-90deg);}left:-", "px;}&[data-placement^='bottom']{top:-", "px;}&[data-placement^='left']{svg{transform:rotateZ(90deg);}right:-", "px;}margin-left:", ";margin-top:", ";"], arrowWidth, arrowHeight, _ref => {
|
|
21
|
+
let {
|
|
22
|
+
theme
|
|
23
|
+
} = _ref;
|
|
24
|
+
return theme.colors.neutral['500'];
|
|
25
|
+
}, _ref2 => {
|
|
26
|
+
let {
|
|
27
|
+
theme
|
|
28
|
+
} = _ref2;
|
|
29
|
+
return theme.colors.neutral['000'];
|
|
30
|
+
}, arrowHeight, arrowWidth, arrowHeight, arrowWidth, props => props['data-placement'].startsWith('top') || props['data-placement'].startsWith('bottom') ? "-".concat(arrowWidth / 2, "px;") : '0;', props => props['data-placement'].startsWith('left') || props['data-placement'].startsWith('right') ? "-".concat(arrowHeight / 2, "px;") : '0;');
|
|
31
|
+
const PopoverArrow = _ref3 => {
|
|
32
|
+
let {
|
|
33
|
+
placement,
|
|
34
|
+
style,
|
|
35
|
+
arrowElementRef
|
|
36
|
+
} = _ref3;
|
|
37
|
+
return /*#__PURE__*/jsxRuntime.jsx(StyledArrow, {
|
|
38
|
+
"data-placement": placement,
|
|
39
|
+
style: style,
|
|
40
|
+
ref: arrowElementRef,
|
|
41
|
+
"data-testid": "ds-tooltip-arrow",
|
|
42
|
+
children: _svg || (_svg = /*#__PURE__*/_jsx__default["default"]("svg", {
|
|
43
|
+
viewBox: "0 0 30 30"
|
|
44
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"]("path", {
|
|
45
|
+
className: "stroke",
|
|
46
|
+
d: "M23.7,27.1L17,19.9C16.5,19.3,15.8,19,15,19s-1.6,0.3-2.1,0.9l-6.6,7.2C5.3,28.1,3.4,29,2,29h26 C26.7,29,24.6,28.1,23.7,27.1z"
|
|
47
|
+
}), /*#__PURE__*/_jsx__default["default"]("path", {
|
|
48
|
+
className: "fill",
|
|
49
|
+
d: "M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z"
|
|
50
|
+
})))
|
|
51
|
+
}, "popper-arrow");
|
|
52
|
+
};
|
|
42
53
|
|
|
43
54
|
exports.PopoverArrow = PopoverArrow;
|
package/cjs/PopoverContent.js
CHANGED
|
@@ -2,51 +2,70 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
5
10
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
11
|
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
7
|
-
require('react');
|
|
8
|
-
var styled = require('styled-components');
|
|
12
|
+
var react = require('react');
|
|
9
13
|
var PopoverArrow = require('./PopoverArrow.js');
|
|
14
|
+
var styled = require('./styled.js');
|
|
10
15
|
var jsxRuntime = require('react/jsx-runtime');
|
|
11
16
|
|
|
12
17
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
18
|
|
|
14
19
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
15
20
|
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
16
|
-
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
17
21
|
|
|
18
22
|
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; }
|
|
19
23
|
|
|
20
24
|
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__default["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; }
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
})
|
|
25
|
+
const PopoverContent = _ref => {
|
|
26
|
+
let {
|
|
27
|
+
setPopperElement,
|
|
28
|
+
popperStyles,
|
|
29
|
+
popperAttributes,
|
|
30
|
+
children,
|
|
31
|
+
showPopover,
|
|
32
|
+
setArrowElement,
|
|
33
|
+
setIsAnimating,
|
|
34
|
+
arrowStyle,
|
|
35
|
+
withoutArrow,
|
|
36
|
+
withoutAnimation,
|
|
37
|
+
animationDuration,
|
|
38
|
+
zIndex
|
|
39
|
+
} = _ref;
|
|
40
|
+
const checkAnimationStatus = react.useCallback(() => {
|
|
41
|
+
if (!showPopover && !withoutAnimation) {
|
|
42
|
+
setIsAnimating(false);
|
|
43
|
+
}
|
|
44
|
+
}, [showPopover, withoutAnimation, setIsAnimating]);
|
|
45
|
+
const popperContent = react.useMemo(() => /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
46
|
+
children: [children, withoutArrow === false ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
47
|
+
children: [/*#__PURE__*/_jsx__default["default"](PopoverArrow.PopoverArrow, {
|
|
48
|
+
arrowElementRef: setArrowElement,
|
|
49
|
+
style: arrowStyle,
|
|
50
|
+
placement: popperAttributes ? popperAttributes['data-popper-placement'] : 'bottom'
|
|
51
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
52
|
+
ref: setArrowElement,
|
|
53
|
+
style: arrowStyle
|
|
54
|
+
})]
|
|
55
|
+
}) : null]
|
|
56
|
+
}), [children, withoutArrow, arrowStyle, popperAttributes, setArrowElement]);
|
|
57
|
+
return /*#__PURE__*/jsxRuntime.jsx(styled.StyledPopoverContentWrapper, _objectSpread(_objectSpread({
|
|
58
|
+
zIndex: zIndex,
|
|
59
|
+
ref: setPopperElement,
|
|
60
|
+
style: popperStyles
|
|
61
|
+
}, popperAttributes), {}, {
|
|
62
|
+
children: /*#__PURE__*/_jsx__default["default"](styled.StyledAnimatedPopper, {
|
|
63
|
+
showPopover: showPopover,
|
|
64
|
+
animationDuration: animationDuration,
|
|
65
|
+
withoutAnimation: withoutAnimation,
|
|
66
|
+
onAnimationEnd: checkAnimationStatus
|
|
67
|
+
}, void 0, popperContent)
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
51
70
|
|
|
52
71
|
exports.PopoverContent = PopoverContent;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
5
6
|
var react = require('react');
|
|
6
7
|
var reactPopper = require('react-popper');
|
|
7
8
|
var useConfiguredMergedProps = require('./useConfiguredMergedProps.js');
|
|
@@ -10,6 +11,7 @@ var useOnClickOutside = require('../utils/hooks/useOnClickOutside.js');
|
|
|
10
11
|
const useConfigDSPopperjs = appProps => {
|
|
11
12
|
const [popperElement, setPopperElement] = react.useState(null);
|
|
12
13
|
const [arrowElement, setArrowElement] = react.useState(null);
|
|
14
|
+
const [isAnimating, setIsAnimating] = react.useState(false);
|
|
13
15
|
const props = useConfiguredMergedProps.useConfiguredMergedProps({
|
|
14
16
|
props: appProps,
|
|
15
17
|
arrowElement
|
|
@@ -17,6 +19,7 @@ const useConfigDSPopperjs = appProps => {
|
|
|
17
19
|
const {
|
|
18
20
|
referenceElement,
|
|
19
21
|
closeContextMenu,
|
|
22
|
+
onClickOutside,
|
|
20
23
|
modifiers,
|
|
21
24
|
startPlacementPreference
|
|
22
25
|
} = props;
|
|
@@ -25,10 +28,22 @@ const useConfigDSPopperjs = appProps => {
|
|
|
25
28
|
modifiers
|
|
26
29
|
}), [modifiers, startPlacementPreference]);
|
|
27
30
|
const popoverHelper = reactPopper.usePopper(referenceElement, popperElement, popperExtraOpts);
|
|
31
|
+
const {
|
|
32
|
+
showPopover,
|
|
33
|
+
withoutAnimation
|
|
34
|
+
} = props;
|
|
35
|
+
react.useEffect(() => {
|
|
36
|
+
if (showPopover && !withoutAnimation) {
|
|
37
|
+
setIsAnimating(true);
|
|
38
|
+
}
|
|
39
|
+
}, [showPopover, withoutAnimation]);
|
|
28
40
|
useOnClickOutside.useOnClickOutside(popperElement, e => {
|
|
29
41
|
var _referenceElement$con;
|
|
30
42
|
|
|
31
|
-
if (!(referenceElement !== null && referenceElement !== void 0 && (_referenceElement$con = referenceElement.contains) !== null && _referenceElement$con !== void 0 && _referenceElement$con.call(referenceElement, e === null || e === void 0 ? void 0 : e.target)))
|
|
43
|
+
if (!(referenceElement !== null && referenceElement !== void 0 && (_referenceElement$con = referenceElement.contains) !== null && _referenceElement$con !== void 0 && _referenceElement$con.call(referenceElement, e === null || e === void 0 ? void 0 : e.target))) {
|
|
44
|
+
onClickOutside(e);
|
|
45
|
+
closeContextMenu();
|
|
46
|
+
}
|
|
32
47
|
});
|
|
33
48
|
return react.useMemo(() => ({
|
|
34
49
|
props,
|
|
@@ -36,8 +51,10 @@ const useConfigDSPopperjs = appProps => {
|
|
|
36
51
|
setPopperElement,
|
|
37
52
|
arrowElement,
|
|
38
53
|
setArrowElement,
|
|
39
|
-
popoverHelper
|
|
40
|
-
|
|
54
|
+
popoverHelper,
|
|
55
|
+
isAnimating,
|
|
56
|
+
setIsAnimating
|
|
57
|
+
}), [arrowElement, popoverHelper, popperElement, isAnimating, props]);
|
|
41
58
|
};
|
|
42
59
|
|
|
43
60
|
exports.useConfigDSPopperjs = useConfigDSPopperjs;
|
|
@@ -4,10 +4,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var react = require('react');
|
|
6
6
|
|
|
7
|
-
const useConfiguredDefaultModifiers =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const useConfiguredDefaultModifiers = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
props,
|
|
10
|
+
arrowElement
|
|
11
|
+
} = _ref;
|
|
11
12
|
// we destructure explicit app definitions before merge
|
|
12
13
|
const {
|
|
13
14
|
boundaryElement: explicitAppBoundaryElement,
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
5
10
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
11
|
var react = require('react');
|
|
7
12
|
var useConfiguredDefaultModifiers = require('./useConfiguredDefaultModifiers.js');
|
|
@@ -17,17 +22,21 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
17
22
|
const noop = () => {};
|
|
18
23
|
|
|
19
24
|
const emptyObj = {};
|
|
20
|
-
const useConfiguredDefaultProps =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
const useConfiguredDefaultProps = _ref => {
|
|
26
|
+
let {
|
|
27
|
+
props,
|
|
28
|
+
arrowElement
|
|
29
|
+
} = _ref;
|
|
24
30
|
// don't move this out of the hook or `document.body` will explode
|
|
25
31
|
const staticDefaultProps = react.useMemo(() => ({
|
|
26
32
|
referenceElement: null,
|
|
27
33
|
showPopover: false,
|
|
28
34
|
closeContextMenu: noop,
|
|
35
|
+
onClickOutside: noop,
|
|
29
36
|
withoutPortal: false,
|
|
30
37
|
withoutArrow: false,
|
|
38
|
+
withoutAnimation: false,
|
|
39
|
+
animationDuration: 100,
|
|
31
40
|
portalDOMContainer: document.body,
|
|
32
41
|
startPlacementPreference: 'top',
|
|
33
42
|
placementOrderPreference: ['top', 'bottom', 'left', 'right'],
|
|
@@ -5,10 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var dsPropsHelpers = require('@elliemae/ds-props-helpers');
|
|
6
6
|
var useConfiguredDefaultProps = require('./useConfiguredDefaultProps.js');
|
|
7
7
|
|
|
8
|
-
const useConfiguredMergedProps =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const useConfiguredMergedProps = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
props,
|
|
11
|
+
arrowElement
|
|
12
|
+
} = _ref;
|
|
12
13
|
const defaultProps = useConfiguredDefaultProps.useConfiguredDefaultProps({
|
|
13
14
|
props,
|
|
14
15
|
arrowElement
|
package/cjs/index.js
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
5
10
|
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
11
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
7
12
|
var react = require('react');
|
|
@@ -25,6 +30,8 @@ const DSPopperJS = props => {
|
|
|
25
30
|
const {
|
|
26
31
|
props: {
|
|
27
32
|
showPopover,
|
|
33
|
+
withoutAnimation,
|
|
34
|
+
animationDuration,
|
|
28
35
|
withoutPortal,
|
|
29
36
|
withoutArrow,
|
|
30
37
|
portalDOMContainer,
|
|
@@ -33,7 +40,9 @@ const DSPopperJS = props => {
|
|
|
33
40
|
},
|
|
34
41
|
setPopperElement,
|
|
35
42
|
setArrowElement,
|
|
36
|
-
|
|
43
|
+
setIsAnimating,
|
|
44
|
+
popoverHelper,
|
|
45
|
+
isAnimating
|
|
37
46
|
} = useConfigDSPopperjs.useConfigDSPopperjs(props);
|
|
38
47
|
const {
|
|
39
48
|
children
|
|
@@ -49,10 +58,14 @@ const DSPopperJS = props => {
|
|
|
49
58
|
setArrowElement: setArrowElement,
|
|
50
59
|
arrowStyle: styles.arrow,
|
|
51
60
|
withoutArrow: withoutArrow,
|
|
52
|
-
|
|
53
|
-
|
|
61
|
+
withoutAnimation: withoutAnimation,
|
|
62
|
+
animationDuration: animationDuration,
|
|
63
|
+
zIndex: zIndex,
|
|
64
|
+
showPopover: showPopover,
|
|
65
|
+
setIsAnimating: setIsAnimating
|
|
66
|
+
}, void 0, children), [attributes.popper, children, setIsAnimating, showPopover, extraPopperStyles, setArrowElement, setPopperElement, styles.arrow, styles.popper, withoutArrow, withoutAnimation, animationDuration, zIndex]);
|
|
54
67
|
|
|
55
|
-
if (showPopover) {
|
|
68
|
+
if (showPopover || isAnimating) {
|
|
56
69
|
if (withoutPortal === true) return contentJSX;
|
|
57
70
|
if (withoutPortal === false) return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
58
71
|
children: /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
package/cjs/propTypes.js
CHANGED
|
@@ -31,6 +31,16 @@ const dspopperjsPropTypes = {
|
|
|
31
31
|
*/
|
|
32
32
|
withoutArrow: reactDesc.PropTypes.bool.description('Whether or not the popper context menu should print the arrow').defaultValue(false),
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Whether or not the popper context menu should be animated
|
|
36
|
+
*/
|
|
37
|
+
withoutAnimation: reactDesc.PropTypes.bool.description('Whether or not the popper context menu should be animated').defaultValue(false),
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Popper context menus Animation duration in ms
|
|
41
|
+
*/
|
|
42
|
+
animationDuration: reactDesc.PropTypes.number.description('Popper context menus Animation duration in ms').defaultValue(100),
|
|
43
|
+
|
|
34
44
|
/**
|
|
35
45
|
* Bounding element to calculate upon, defaults to it is "clippingParents",
|
|
36
46
|
* which are the scrolling containers that may cause the element to be partially or fully cut off.
|
|
@@ -67,7 +77,9 @@ const dspopperjsPropTypes = {
|
|
|
67
77
|
* https://popper.js.org/docs/v2/modifiers/
|
|
68
78
|
*/
|
|
69
79
|
modifiers: reactDesc.PropTypes.array.description('modifiers array for full-custom popper-js override, https://popper.js.org/docs/v2/modifiers/').defaultValue(1),
|
|
70
|
-
extraPopperStyles: reactDesc.PropTypes.object.description('Extra object styles to attach to the popper element').defaultValue({})
|
|
80
|
+
extraPopperStyles: reactDesc.PropTypes.object.description('Extra object styles to attach to the popper element').defaultValue({}),
|
|
81
|
+
onClickOutside: reactDesc.PropTypes.func.description('Callback triggered when clicking outside the popper').defaultValue(() => null),
|
|
82
|
+
children: reactDesc.PropTypes.node.description('The content of the popper').defaultValue(undefined)
|
|
71
83
|
};
|
|
72
84
|
|
|
73
85
|
exports.dspopperjsPropTypes = dspopperjsPropTypes;
|
package/cjs/styled.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
|
|
6
|
+
var styled = require('styled-components');
|
|
7
|
+
var dsSystem = require('@elliemae/ds-system');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteral);
|
|
12
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
13
|
+
|
|
14
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
15
|
+
const showAnimation = dsSystem.kfrm(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n from {\n opacity: 0;\n transform: scale(0.8);\n }\n\n to {\n opacity: 1;\n transform: scale(1);\n visibility: visible;\n }\n"])));
|
|
16
|
+
const hideAnimation = dsSystem.kfrm(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral__default["default"](["\n from {\n opacity: 1;\n transform: scale(1);\n }\n\n to {\n opacity: 0;\n transform: scale(0.8);\n visibility: hidden;\n }\n"])));
|
|
17
|
+
const StyledPopoverContentWrapper = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
18
|
+
componentId: "sc-1giz5kx-0"
|
|
19
|
+
})(["z-index:", ";"], _ref => {
|
|
20
|
+
let {
|
|
21
|
+
zIndex
|
|
22
|
+
} = _ref;
|
|
23
|
+
return zIndex;
|
|
24
|
+
});
|
|
25
|
+
const StyledAnimatedPopper = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
26
|
+
componentId: "sc-1giz5kx-1"
|
|
27
|
+
})(["box-shadow:0 0 0 1px rgba(16,22,26,0.1),0 2px 4px rgba(16,22,26,0.2),0 8px 24px rgba(16,22,26,0.2);", ""], _ref2 => {
|
|
28
|
+
let {
|
|
29
|
+
showPopover,
|
|
30
|
+
animationDuration,
|
|
31
|
+
withoutAnimation
|
|
32
|
+
} = _ref2;
|
|
33
|
+
return !withoutAnimation && dsSystem.css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral__default["default"](["\n animation: ", " ", "ms ease-in;\n "])), showPopover ? showAnimation : hideAnimation, animationDuration);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
exports.StyledAnimatedPopper = StyledAnimatedPopper;
|
|
37
|
+
exports.StyledPopoverContentWrapper = StyledPopoverContentWrapper;
|
package/esm/PopoverArrow.js
CHANGED
|
@@ -4,31 +4,42 @@ import styled from 'styled-components';
|
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
var _svg;
|
|
7
|
+
const arrowWidth = 18;
|
|
8
|
+
const arrowHeight = 18;
|
|
7
9
|
const StyledArrow = /*#__PURE__*/styled.div.withConfig({
|
|
8
10
|
componentId: "sc-olcdf1-0"
|
|
9
|
-
})(["position:absolute;width:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
11
|
+
})(["position:absolute;width:", "px;height:", "px;pointer-events:none;background-color:transparent;& .stroke{fill:", ";fill-opacity:0.4;}& .fill{fill:", ";}&[data-placement^='top']{svg{transform:rotateZ(180deg);}bottom:-", "px;}&[data-placement^='right']{svg{transform:rotateZ(-90deg);}left:-", "px;}&[data-placement^='bottom']{top:-", "px;}&[data-placement^='left']{svg{transform:rotateZ(90deg);}right:-", "px;}margin-left:", ";margin-top:", ";"], arrowWidth, arrowHeight, _ref => {
|
|
12
|
+
let {
|
|
13
|
+
theme
|
|
14
|
+
} = _ref;
|
|
15
|
+
return theme.colors.neutral['500'];
|
|
16
|
+
}, _ref2 => {
|
|
17
|
+
let {
|
|
18
|
+
theme
|
|
19
|
+
} = _ref2;
|
|
20
|
+
return theme.colors.neutral['000'];
|
|
21
|
+
}, arrowHeight, arrowWidth, arrowHeight, arrowWidth, props => props['data-placement'].startsWith('top') || props['data-placement'].startsWith('bottom') ? "-".concat(arrowWidth / 2, "px;") : '0;', props => props['data-placement'].startsWith('left') || props['data-placement'].startsWith('right') ? "-".concat(arrowHeight / 2, "px;") : '0;');
|
|
22
|
+
const PopoverArrow = _ref3 => {
|
|
23
|
+
let {
|
|
24
|
+
placement,
|
|
25
|
+
style,
|
|
26
|
+
arrowElementRef
|
|
27
|
+
} = _ref3;
|
|
28
|
+
return /*#__PURE__*/jsx(StyledArrow, {
|
|
29
|
+
"data-placement": placement,
|
|
30
|
+
style: style,
|
|
31
|
+
ref: arrowElementRef,
|
|
32
|
+
"data-testid": "ds-tooltip-arrow",
|
|
33
|
+
children: _svg || (_svg = /*#__PURE__*/_jsx("svg", {
|
|
34
|
+
viewBox: "0 0 30 30"
|
|
35
|
+
}, void 0, /*#__PURE__*/_jsx("path", {
|
|
36
|
+
className: "stroke",
|
|
37
|
+
d: "M23.7,27.1L17,19.9C16.5,19.3,15.8,19,15,19s-1.6,0.3-2.1,0.9l-6.6,7.2C5.3,28.1,3.4,29,2,29h26 C26.7,29,24.6,28.1,23.7,27.1z"
|
|
38
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
39
|
+
className: "fill",
|
|
40
|
+
d: "M23,27.8c1.1,1.2,3.4,2.2,5,2.2h2H0h2c1.7,0,3.9-1,5-2.2l6.6-7.2c0.7-0.8,2-0.8,2.7,0L23,27.8L23,27.8z"
|
|
41
|
+
})))
|
|
42
|
+
}, "popper-arrow");
|
|
43
|
+
};
|
|
33
44
|
|
|
34
45
|
export { PopoverArrow };
|
package/esm/PopoverContent.js
CHANGED
|
@@ -1,42 +1,62 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
7
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
3
|
-
import 'react';
|
|
4
|
-
import styled from 'styled-components';
|
|
8
|
+
import { useCallback, useMemo } from 'react';
|
|
5
9
|
import { PopoverArrow } from './PopoverArrow.js';
|
|
10
|
+
import { StyledPopoverContentWrapper, StyledAnimatedPopper } from './styled.js';
|
|
6
11
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
7
12
|
|
|
8
13
|
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; }
|
|
9
14
|
|
|
10
15
|
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; }
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})
|
|
16
|
+
const PopoverContent = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
setPopperElement,
|
|
19
|
+
popperStyles,
|
|
20
|
+
popperAttributes,
|
|
21
|
+
children,
|
|
22
|
+
showPopover,
|
|
23
|
+
setArrowElement,
|
|
24
|
+
setIsAnimating,
|
|
25
|
+
arrowStyle,
|
|
26
|
+
withoutArrow,
|
|
27
|
+
withoutAnimation,
|
|
28
|
+
animationDuration,
|
|
29
|
+
zIndex
|
|
30
|
+
} = _ref;
|
|
31
|
+
const checkAnimationStatus = useCallback(() => {
|
|
32
|
+
if (!showPopover && !withoutAnimation) {
|
|
33
|
+
setIsAnimating(false);
|
|
34
|
+
}
|
|
35
|
+
}, [showPopover, withoutAnimation, setIsAnimating]);
|
|
36
|
+
const popperContent = useMemo(() => /*#__PURE__*/jsxs(Fragment, {
|
|
37
|
+
children: [children, withoutArrow === false ? /*#__PURE__*/jsxs(Fragment, {
|
|
38
|
+
children: [/*#__PURE__*/_jsx(PopoverArrow, {
|
|
39
|
+
arrowElementRef: setArrowElement,
|
|
40
|
+
style: arrowStyle,
|
|
41
|
+
placement: popperAttributes ? popperAttributes['data-popper-placement'] : 'bottom'
|
|
42
|
+
}), /*#__PURE__*/jsx("div", {
|
|
43
|
+
ref: setArrowElement,
|
|
44
|
+
style: arrowStyle
|
|
45
|
+
})]
|
|
46
|
+
}) : null]
|
|
47
|
+
}), [children, withoutArrow, arrowStyle, popperAttributes, setArrowElement]);
|
|
48
|
+
return /*#__PURE__*/jsx(StyledPopoverContentWrapper, _objectSpread(_objectSpread({
|
|
49
|
+
zIndex: zIndex,
|
|
50
|
+
ref: setPopperElement,
|
|
51
|
+
style: popperStyles
|
|
52
|
+
}, popperAttributes), {}, {
|
|
53
|
+
children: /*#__PURE__*/_jsx(StyledAnimatedPopper, {
|
|
54
|
+
showPopover: showPopover,
|
|
55
|
+
animationDuration: animationDuration,
|
|
56
|
+
withoutAnimation: withoutAnimation,
|
|
57
|
+
onAnimationEnd: checkAnimationStatus
|
|
58
|
+
}, void 0, popperContent)
|
|
59
|
+
}));
|
|
60
|
+
};
|
|
41
61
|
|
|
42
62
|
export { PopoverContent };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
+
import { useState, useMemo, useEffect } from 'react';
|
|
2
3
|
import { usePopper } from 'react-popper';
|
|
3
4
|
import { useConfiguredMergedProps } from './useConfiguredMergedProps.js';
|
|
4
5
|
import { useOnClickOutside } from '../utils/hooks/useOnClickOutside.js';
|
|
@@ -6,6 +7,7 @@ import { useOnClickOutside } from '../utils/hooks/useOnClickOutside.js';
|
|
|
6
7
|
const useConfigDSPopperjs = appProps => {
|
|
7
8
|
const [popperElement, setPopperElement] = useState(null);
|
|
8
9
|
const [arrowElement, setArrowElement] = useState(null);
|
|
10
|
+
const [isAnimating, setIsAnimating] = useState(false);
|
|
9
11
|
const props = useConfiguredMergedProps({
|
|
10
12
|
props: appProps,
|
|
11
13
|
arrowElement
|
|
@@ -13,6 +15,7 @@ const useConfigDSPopperjs = appProps => {
|
|
|
13
15
|
const {
|
|
14
16
|
referenceElement,
|
|
15
17
|
closeContextMenu,
|
|
18
|
+
onClickOutside,
|
|
16
19
|
modifiers,
|
|
17
20
|
startPlacementPreference
|
|
18
21
|
} = props;
|
|
@@ -21,10 +24,22 @@ const useConfigDSPopperjs = appProps => {
|
|
|
21
24
|
modifiers
|
|
22
25
|
}), [modifiers, startPlacementPreference]);
|
|
23
26
|
const popoverHelper = usePopper(referenceElement, popperElement, popperExtraOpts);
|
|
27
|
+
const {
|
|
28
|
+
showPopover,
|
|
29
|
+
withoutAnimation
|
|
30
|
+
} = props;
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (showPopover && !withoutAnimation) {
|
|
33
|
+
setIsAnimating(true);
|
|
34
|
+
}
|
|
35
|
+
}, [showPopover, withoutAnimation]);
|
|
24
36
|
useOnClickOutside(popperElement, e => {
|
|
25
37
|
var _referenceElement$con;
|
|
26
38
|
|
|
27
|
-
if (!(referenceElement !== null && referenceElement !== void 0 && (_referenceElement$con = referenceElement.contains) !== null && _referenceElement$con !== void 0 && _referenceElement$con.call(referenceElement, e === null || e === void 0 ? void 0 : e.target)))
|
|
39
|
+
if (!(referenceElement !== null && referenceElement !== void 0 && (_referenceElement$con = referenceElement.contains) !== null && _referenceElement$con !== void 0 && _referenceElement$con.call(referenceElement, e === null || e === void 0 ? void 0 : e.target))) {
|
|
40
|
+
onClickOutside(e);
|
|
41
|
+
closeContextMenu();
|
|
42
|
+
}
|
|
28
43
|
});
|
|
29
44
|
return useMemo(() => ({
|
|
30
45
|
props,
|
|
@@ -32,8 +47,10 @@ const useConfigDSPopperjs = appProps => {
|
|
|
32
47
|
setPopperElement,
|
|
33
48
|
arrowElement,
|
|
34
49
|
setArrowElement,
|
|
35
|
-
popoverHelper
|
|
36
|
-
|
|
50
|
+
popoverHelper,
|
|
51
|
+
isAnimating,
|
|
52
|
+
setIsAnimating
|
|
53
|
+
}), [arrowElement, popoverHelper, popperElement, isAnimating, props]);
|
|
37
54
|
};
|
|
38
55
|
|
|
39
56
|
export { useConfigDSPopperjs };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
|
|
3
|
-
const useConfiguredDefaultModifiers =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const useConfiguredDefaultModifiers = _ref => {
|
|
4
|
+
let {
|
|
5
|
+
props,
|
|
6
|
+
arrowElement
|
|
7
|
+
} = _ref;
|
|
7
8
|
// we destructure explicit app definitions before merge
|
|
8
9
|
const {
|
|
9
10
|
boundaryElement: explicitAppBoundaryElement,
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
7
|
import { useMemo } from 'react';
|
|
3
8
|
import { useConfiguredDefaultModifiers } from './useConfiguredDefaultModifiers.js';
|
|
@@ -9,17 +14,21 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
9
14
|
const noop = () => {};
|
|
10
15
|
|
|
11
16
|
const emptyObj = {};
|
|
12
|
-
const useConfiguredDefaultProps =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
const useConfiguredDefaultProps = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
props,
|
|
20
|
+
arrowElement
|
|
21
|
+
} = _ref;
|
|
16
22
|
// don't move this out of the hook or `document.body` will explode
|
|
17
23
|
const staticDefaultProps = useMemo(() => ({
|
|
18
24
|
referenceElement: null,
|
|
19
25
|
showPopover: false,
|
|
20
26
|
closeContextMenu: noop,
|
|
27
|
+
onClickOutside: noop,
|
|
21
28
|
withoutPortal: false,
|
|
22
29
|
withoutArrow: false,
|
|
30
|
+
withoutAnimation: false,
|
|
31
|
+
animationDuration: 100,
|
|
23
32
|
portalDOMContainer: document.body,
|
|
24
33
|
startPlacementPreference: 'top',
|
|
25
34
|
placementOrderPreference: ['top', 'bottom', 'left', 'right'],
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';
|
|
2
2
|
import { useConfiguredDefaultProps } from './useConfiguredDefaultProps.js';
|
|
3
3
|
|
|
4
|
-
const useConfiguredMergedProps =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const useConfiguredMergedProps = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
props,
|
|
7
|
+
arrowElement
|
|
8
|
+
} = _ref;
|
|
8
9
|
const defaultProps = useConfiguredDefaultProps({
|
|
9
10
|
props,
|
|
10
11
|
arrowElement
|
package/esm/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
6
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
7
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
8
|
import { useMemo } from 'react';
|
|
@@ -16,6 +21,8 @@ const DSPopperJS = props => {
|
|
|
16
21
|
const {
|
|
17
22
|
props: {
|
|
18
23
|
showPopover,
|
|
24
|
+
withoutAnimation,
|
|
25
|
+
animationDuration,
|
|
19
26
|
withoutPortal,
|
|
20
27
|
withoutArrow,
|
|
21
28
|
portalDOMContainer,
|
|
@@ -24,7 +31,9 @@ const DSPopperJS = props => {
|
|
|
24
31
|
},
|
|
25
32
|
setPopperElement,
|
|
26
33
|
setArrowElement,
|
|
27
|
-
|
|
34
|
+
setIsAnimating,
|
|
35
|
+
popoverHelper,
|
|
36
|
+
isAnimating
|
|
28
37
|
} = useConfigDSPopperjs(props);
|
|
29
38
|
const {
|
|
30
39
|
children
|
|
@@ -40,10 +49,14 @@ const DSPopperJS = props => {
|
|
|
40
49
|
setArrowElement: setArrowElement,
|
|
41
50
|
arrowStyle: styles.arrow,
|
|
42
51
|
withoutArrow: withoutArrow,
|
|
43
|
-
|
|
44
|
-
|
|
52
|
+
withoutAnimation: withoutAnimation,
|
|
53
|
+
animationDuration: animationDuration,
|
|
54
|
+
zIndex: zIndex,
|
|
55
|
+
showPopover: showPopover,
|
|
56
|
+
setIsAnimating: setIsAnimating
|
|
57
|
+
}, void 0, children), [attributes.popper, children, setIsAnimating, showPopover, extraPopperStyles, setArrowElement, setPopperElement, styles.arrow, styles.popper, withoutArrow, withoutAnimation, animationDuration, zIndex]);
|
|
45
58
|
|
|
46
|
-
if (showPopover) {
|
|
59
|
+
if (showPopover || isAnimating) {
|
|
47
60
|
if (withoutPortal === true) return contentJSX;
|
|
48
61
|
if (withoutPortal === false) return /*#__PURE__*/jsx(Fragment, {
|
|
49
62
|
children: /*#__PURE__*/createPortal( /*#__PURE__*/jsx(Fragment, {
|
package/esm/propTypes.js
CHANGED
|
@@ -27,6 +27,16 @@ const dspopperjsPropTypes = {
|
|
|
27
27
|
*/
|
|
28
28
|
withoutArrow: PropTypes.bool.description('Whether or not the popper context menu should print the arrow').defaultValue(false),
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Whether or not the popper context menu should be animated
|
|
32
|
+
*/
|
|
33
|
+
withoutAnimation: PropTypes.bool.description('Whether or not the popper context menu should be animated').defaultValue(false),
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Popper context menus Animation duration in ms
|
|
37
|
+
*/
|
|
38
|
+
animationDuration: PropTypes.number.description('Popper context menus Animation duration in ms').defaultValue(100),
|
|
39
|
+
|
|
30
40
|
/**
|
|
31
41
|
* Bounding element to calculate upon, defaults to it is "clippingParents",
|
|
32
42
|
* which are the scrolling containers that may cause the element to be partially or fully cut off.
|
|
@@ -63,7 +73,9 @@ const dspopperjsPropTypes = {
|
|
|
63
73
|
* https://popper.js.org/docs/v2/modifiers/
|
|
64
74
|
*/
|
|
65
75
|
modifiers: PropTypes.array.description('modifiers array for full-custom popper-js override, https://popper.js.org/docs/v2/modifiers/').defaultValue(1),
|
|
66
|
-
extraPopperStyles: PropTypes.object.description('Extra object styles to attach to the popper element').defaultValue({})
|
|
76
|
+
extraPopperStyles: PropTypes.object.description('Extra object styles to attach to the popper element').defaultValue({}),
|
|
77
|
+
onClickOutside: PropTypes.func.description('Callback triggered when clicking outside the popper').defaultValue(() => null),
|
|
78
|
+
children: PropTypes.node.description('The content of the popper').defaultValue(undefined)
|
|
67
79
|
};
|
|
68
80
|
|
|
69
81
|
export { dspopperjsPropTypes };
|
package/esm/styled.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { kfrm, css } from '@elliemae/ds-system';
|
|
4
|
+
|
|
5
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
6
|
+
const showAnimation = kfrm(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n from {\n opacity: 0;\n transform: scale(0.8);\n }\n\n to {\n opacity: 1;\n transform: scale(1);\n visibility: visible;\n }\n"])));
|
|
7
|
+
const hideAnimation = kfrm(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n from {\n opacity: 1;\n transform: scale(1);\n }\n\n to {\n opacity: 0;\n transform: scale(0.8);\n visibility: hidden;\n }\n"])));
|
|
8
|
+
const StyledPopoverContentWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
9
|
+
componentId: "sc-1giz5kx-0"
|
|
10
|
+
})(["z-index:", ";"], _ref => {
|
|
11
|
+
let {
|
|
12
|
+
zIndex
|
|
13
|
+
} = _ref;
|
|
14
|
+
return zIndex;
|
|
15
|
+
});
|
|
16
|
+
const StyledAnimatedPopper = /*#__PURE__*/styled.div.withConfig({
|
|
17
|
+
componentId: "sc-1giz5kx-1"
|
|
18
|
+
})(["box-shadow:0 0 0 1px rgba(16,22,26,0.1),0 2px 4px rgba(16,22,26,0.2),0 8px 24px rgba(16,22,26,0.2);", ""], _ref2 => {
|
|
19
|
+
let {
|
|
20
|
+
showPopover,
|
|
21
|
+
animationDuration,
|
|
22
|
+
withoutAnimation
|
|
23
|
+
} = _ref2;
|
|
24
|
+
return !withoutAnimation && css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n animation: ", " ", "ms ease-in;\n "])), showPopover ? showAnimation : hideAnimation, animationDuration);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export { StyledAnimatedPopper, StyledPopoverContentWrapper };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-popperjs",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Popper JS Wrapper",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
"import": "./esm/utils/hooks/useOnClickOutside.js",
|
|
16
16
|
"require": "./cjs/utils/hooks/useOnClickOutside.js"
|
|
17
17
|
},
|
|
18
|
+
"./styled": {
|
|
19
|
+
"import": "./esm/styled.js",
|
|
20
|
+
"require": "./cjs/styled.js"
|
|
21
|
+
},
|
|
18
22
|
"./propTypes": {
|
|
19
23
|
"import": "./esm/propTypes.js",
|
|
20
24
|
"require": "./cjs/propTypes.js"
|
|
@@ -64,16 +68,18 @@
|
|
|
64
68
|
"build": "node ../../scripts/build/build.js"
|
|
65
69
|
},
|
|
66
70
|
"dependencies": {
|
|
67
|
-
"@elliemae/ds-props-helpers": "2.0.0-alpha.
|
|
68
|
-
"
|
|
71
|
+
"@elliemae/ds-props-helpers": "2.0.0-alpha.14",
|
|
72
|
+
"@elliemae/ds-system": "2.0.0-alpha.14",
|
|
73
|
+
"react-desc": "~4.1.3",
|
|
74
|
+
"react-popper": "~2.2.5"
|
|
69
75
|
},
|
|
70
76
|
"devDependencies": {
|
|
71
|
-
"styled-components": "~5.3.
|
|
77
|
+
"styled-components": "~5.3.3"
|
|
72
78
|
},
|
|
73
79
|
"peerDependencies": {
|
|
74
80
|
"react": "^17.0.2",
|
|
75
81
|
"react-dom": "^17.0.2",
|
|
76
|
-
"styled-components": "^5.3.
|
|
82
|
+
"styled-components": "^5.3.3"
|
|
77
83
|
},
|
|
78
84
|
"publishConfig": {
|
|
79
85
|
"access": "public",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { PopoverContentPropsT } from './index.d';
|
|
3
|
-
export declare const PopoverContent: ({ setPopperElement, popperStyles, popperAttributes, children, setArrowElement, arrowStyle, withoutArrow, zIndex, }: PopoverContentPropsT) => JSX.Element;
|
|
3
|
+
export declare const PopoverContent: ({ setPopperElement, popperStyles, popperAttributes, children, showPopover, setArrowElement, setIsAnimating, arrowStyle, withoutArrow, withoutAnimation, animationDuration, zIndex, }: PopoverContentPropsT) => JSX.Element;
|
|
@@ -6,8 +6,11 @@ export declare const useConfiguredDefaultProps: ({ props, arrowElement }: {
|
|
|
6
6
|
referenceElement: null;
|
|
7
7
|
showPopover: boolean;
|
|
8
8
|
closeContextMenu: () => void;
|
|
9
|
+
onClickOutside: () => void;
|
|
9
10
|
withoutPortal: boolean;
|
|
10
11
|
withoutArrow: boolean;
|
|
12
|
+
withoutAnimation: boolean;
|
|
13
|
+
animationDuration: number;
|
|
11
14
|
portalDOMContainer: HTMLElement;
|
|
12
15
|
startPlacementPreference: string;
|
|
13
16
|
placementOrderPreference: string[];
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
export declare const useConfiguredMergedProps: ({ props, arrowElement }: {
|
|
2
2
|
props: any;
|
|
3
3
|
arrowElement: any;
|
|
4
|
-
}) =>
|
|
4
|
+
}) => {
|
|
5
5
|
modifiers: any;
|
|
6
6
|
referenceElement: null;
|
|
7
7
|
showPopover: boolean;
|
|
8
8
|
closeContextMenu: () => void;
|
|
9
|
+
onClickOutside: () => void;
|
|
9
10
|
withoutPortal: boolean;
|
|
10
11
|
withoutArrow: boolean;
|
|
12
|
+
withoutAnimation: boolean;
|
|
13
|
+
animationDuration: number;
|
|
11
14
|
portalDOMContainer: HTMLElement;
|
|
12
15
|
startPlacementPreference: string;
|
|
13
16
|
placementOrderPreference: string[];
|
|
14
17
|
zIndex: number;
|
|
15
18
|
extraPopperStyles: {};
|
|
16
|
-
}
|
|
19
|
+
};
|
package/types/index.d.ts
CHANGED
|
@@ -1,21 +1,56 @@
|
|
|
1
|
+
/// <reference path="../../../../shared/typings/react-desc.d.ts" />
|
|
1
2
|
/// <reference types="react" />
|
|
2
3
|
import type { DSDSPopperjsPropsT } from './index.d';
|
|
3
4
|
declare const DSPopperJS: {
|
|
4
5
|
(props: DSDSPopperjsPropsT): JSX.Element;
|
|
5
6
|
propTypes: {
|
|
6
|
-
referenceElement:
|
|
7
|
-
showPopover:
|
|
8
|
-
closeContextMenu:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
referenceElement: import("react-desc").PropTypesDescValidator;
|
|
8
|
+
showPopover: import("react-desc").PropTypesDescValidator;
|
|
9
|
+
closeContextMenu: {
|
|
10
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
11
|
+
};
|
|
12
|
+
withoutPortal: {
|
|
13
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
14
|
+
};
|
|
15
|
+
withoutArrow: {
|
|
16
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
17
|
+
};
|
|
18
|
+
withoutAnimation: {
|
|
19
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
20
|
+
};
|
|
21
|
+
animationDuration: {
|
|
22
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
23
|
+
};
|
|
24
|
+
boundaryElement: {
|
|
25
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
26
|
+
};
|
|
27
|
+
portalDOMContainer: {
|
|
28
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
29
|
+
};
|
|
30
|
+
startPlacementPreference: {
|
|
31
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
32
|
+
};
|
|
33
|
+
placementOrderPreference: {
|
|
34
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
35
|
+
};
|
|
36
|
+
zIndex: {
|
|
37
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
38
|
+
};
|
|
39
|
+
customOffset: {
|
|
40
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
41
|
+
};
|
|
42
|
+
modifiers: {
|
|
43
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
44
|
+
};
|
|
45
|
+
extraPopperStyles: {
|
|
46
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
47
|
+
};
|
|
48
|
+
onClickOutside: {
|
|
49
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
50
|
+
};
|
|
51
|
+
children: {
|
|
52
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
53
|
+
};
|
|
19
54
|
};
|
|
20
55
|
};
|
|
21
56
|
declare const DSPopperJSWithSchema: any;
|
package/types/propTypes.d.ts
CHANGED
|
@@ -1,54 +1,95 @@
|
|
|
1
|
+
/// <reference path="../../../../shared/typings/react-desc.d.ts" />
|
|
1
2
|
export declare const dspopperjsPropTypes: {
|
|
2
3
|
/**
|
|
3
4
|
* React ref to popperjs referenceElement
|
|
4
5
|
*/
|
|
5
|
-
referenceElement:
|
|
6
|
+
referenceElement: import("react-desc").PropTypesDescValidator;
|
|
6
7
|
/**
|
|
7
8
|
* Wheter or not to show the popper content
|
|
8
9
|
*/
|
|
9
|
-
showPopover:
|
|
10
|
+
showPopover: import("react-desc").PropTypesDescValidator;
|
|
10
11
|
/**
|
|
11
12
|
* Callback to close the context menu, used for "on click outside",
|
|
12
13
|
* if not provided click outside will not trigger anything
|
|
13
14
|
*/
|
|
14
|
-
closeContextMenu:
|
|
15
|
+
closeContextMenu: {
|
|
16
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
17
|
+
};
|
|
15
18
|
/**
|
|
16
19
|
* Wheter or not the popper content should appear in a DOM portal or not
|
|
17
20
|
*/
|
|
18
|
-
withoutPortal:
|
|
21
|
+
withoutPortal: {
|
|
22
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
23
|
+
};
|
|
19
24
|
/**
|
|
20
25
|
* Wheter or not the popper context menu should print the arrow
|
|
21
26
|
*/
|
|
22
|
-
withoutArrow:
|
|
27
|
+
withoutArrow: {
|
|
28
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Whether or not the popper context menu should be animated
|
|
32
|
+
*/
|
|
33
|
+
withoutAnimation: {
|
|
34
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Popper context menus Animation duration in ms
|
|
38
|
+
*/
|
|
39
|
+
animationDuration: {
|
|
40
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
41
|
+
};
|
|
23
42
|
/**
|
|
24
43
|
* Bounding element to calculate upon, defaults to it is "clippingParents",
|
|
25
44
|
* which are the scrolling containers that may cause the element to be partially or fully cut off.
|
|
26
45
|
*/
|
|
27
|
-
boundaryElement:
|
|
46
|
+
boundaryElement: {
|
|
47
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
48
|
+
};
|
|
28
49
|
/**
|
|
29
50
|
* When using portal, the container in which to append the DOM content, defaults to document body
|
|
30
51
|
*/
|
|
31
|
-
portalDOMContainer:
|
|
52
|
+
portalDOMContainer: {
|
|
53
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
54
|
+
};
|
|
32
55
|
/**
|
|
33
56
|
* start placement preferences, as per popperjs placement option
|
|
34
57
|
*/
|
|
35
|
-
startPlacementPreference:
|
|
58
|
+
startPlacementPreference: {
|
|
59
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
60
|
+
};
|
|
36
61
|
/**
|
|
37
62
|
* Array of placement preferences, as per popperjs "flip" placement option
|
|
38
63
|
*/
|
|
39
|
-
placementOrderPreference:
|
|
64
|
+
placementOrderPreference: {
|
|
65
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
66
|
+
};
|
|
40
67
|
/**
|
|
41
68
|
* popperjs content z-index
|
|
42
69
|
*/
|
|
43
|
-
zIndex:
|
|
70
|
+
zIndex: {
|
|
71
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
72
|
+
};
|
|
44
73
|
/**
|
|
45
74
|
* placement offset array
|
|
46
75
|
*/
|
|
47
|
-
customOffset:
|
|
76
|
+
customOffset: {
|
|
77
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
78
|
+
};
|
|
48
79
|
/**
|
|
49
80
|
* modifiers array for full-custom popper-js override
|
|
50
81
|
* https://popper.js.org/docs/v2/modifiers/
|
|
51
82
|
*/
|
|
52
|
-
modifiers:
|
|
53
|
-
|
|
83
|
+
modifiers: {
|
|
84
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
85
|
+
};
|
|
86
|
+
extraPopperStyles: {
|
|
87
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
88
|
+
};
|
|
89
|
+
onClickOutside: {
|
|
90
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
91
|
+
};
|
|
92
|
+
children: {
|
|
93
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
94
|
+
};
|
|
54
95
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface StyledContentWrapperPropsT {
|
|
2
|
+
zIndex: number;
|
|
3
|
+
}
|
|
4
|
+
interface StyledAnimatedPopperPropsT {
|
|
5
|
+
showPopover: boolean;
|
|
6
|
+
animationDuration: number;
|
|
7
|
+
withoutAnimation: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const StyledPopoverContentWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, StyledContentWrapperPropsT, never>;
|
|
10
|
+
export declare const StyledAnimatedPopper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, StyledAnimatedPopperPropsT, never>;
|
|
11
|
+
export {};
|
package/cjs/package.json
DELETED