@elliemae/ds-popperjs 2.2.0-alpha.4 → 3.0.0-next.2
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 +51 -88
- package/cjs/PopoverContent.js +65 -70
- package/cjs/config/useConfigDSPopperjs.js +42 -51
- package/cjs/config/useConfiguredDefaultModifiers.js +50 -69
- package/cjs/config/useConfiguredDefaultProps.js +40 -44
- package/cjs/config/useConfiguredMergedProps.js +19 -39
- package/cjs/index.d.js +2 -27
- package/cjs/index.js +63 -79
- package/cjs/propTypes.js +83 -78
- package/cjs/styled.js +34 -68
- package/cjs/utils/hooks/useOnClickOutside.js +20 -42
- package/esm/PopoverArrow.js +42 -59
- package/esm/PopoverContent.js +55 -40
- package/esm/config/useConfigDSPopperjs.js +32 -16
- package/esm/config/useConfiguredDefaultModifiers.js +44 -38
- package/esm/config/useConfiguredDefaultProps.js +31 -14
- package/esm/config/useConfiguredMergedProps.js +14 -9
- package/esm/index.d.js +1 -2
- package/esm/index.js +50 -48
- package/esm/propTypes.js +79 -49
- package/esm/styled.js +25 -40
- package/esm/utils/hooks/useOnClickOutside.js +15 -12
- package/package.json +3 -3
- package/cjs/PopoverArrow.js.map +0 -7
- package/cjs/PopoverContent.js.map +0 -7
- package/cjs/config/useConfigDSPopperjs.js.map +0 -7
- package/cjs/config/useConfiguredDefaultModifiers.js.map +0 -7
- package/cjs/config/useConfiguredDefaultProps.js.map +0 -7
- package/cjs/config/useConfiguredMergedProps.js.map +0 -7
- package/cjs/index.d.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/propTypes.js.map +0 -7
- package/cjs/styled.js.map +0 -7
- package/cjs/utils/hooks/useOnClickOutside.js.map +0 -7
- package/esm/PopoverArrow.js.map +0 -7
- package/esm/PopoverContent.js.map +0 -7
- package/esm/config/useConfigDSPopperjs.js.map +0 -7
- package/esm/config/useConfiguredDefaultModifiers.js.map +0 -7
- package/esm/config/useConfiguredDefaultProps.js.map +0 -7
- package/esm/config/useConfiguredMergedProps.js.map +0 -7
- package/esm/index.d.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/propTypes.js.map +0 -7
- package/esm/styled.js.map +0 -7
- package/esm/utils/hooks/useOnClickOutside.js.map +0 -7
package/esm/PopoverArrow.js
CHANGED
|
@@ -1,62 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import styled from
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var _svg;
|
|
4
7
|
const arrowWidth = 18;
|
|
5
8
|
const arrowHeight = 18;
|
|
6
|
-
const StyledArrow = styled.div
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
}
|
|
41
|
-
margin-left: ${(props) => props["data-placement"].startsWith("top") || props["data-placement"].startsWith("bottom") ? `-${arrowWidth / 2}px;` : "0;"};
|
|
42
|
-
margin-top: ${(props) => props["data-placement"].startsWith("left") || props["data-placement"].startsWith("right") ? `-${arrowHeight / 2}px;` : "0;"};
|
|
43
|
-
`;
|
|
44
|
-
const PopoverArrow = ({ placement, style, arrowElementRef }) => /* @__PURE__ */ React2.createElement(StyledArrow, {
|
|
45
|
-
key: "popper-arrow",
|
|
46
|
-
"data-placement": placement,
|
|
47
|
-
style,
|
|
48
|
-
ref: arrowElementRef,
|
|
49
|
-
"data-testid": "ds-tooltip-arrow"
|
|
50
|
-
}, /* @__PURE__ */ React2.createElement("svg", {
|
|
51
|
-
viewBox: "0 0 30 30"
|
|
52
|
-
}, /* @__PURE__ */ React2.createElement("path", {
|
|
53
|
-
className: "stroke",
|
|
54
|
-
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\n C26.7,29,24.6,28.1,23.7,27.1z"
|
|
55
|
-
}), /* @__PURE__ */ React2.createElement("path", {
|
|
56
|
-
className: "fill",
|
|
57
|
-
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"
|
|
58
|
-
})));
|
|
59
|
-
export {
|
|
60
|
-
PopoverArrow
|
|
9
|
+
const StyledArrow = /*#__PURE__*/styled.div.withConfig({
|
|
10
|
+
componentId: "sc-olcdf1-0"
|
|
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");
|
|
61
43
|
};
|
|
62
|
-
|
|
44
|
+
|
|
45
|
+
export { PopoverArrow };
|
package/esm/PopoverContent.js
CHANGED
|
@@ -1,47 +1,62 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
|
+
import { useCallback, useMemo } from 'react';
|
|
9
|
+
import { PopoverArrow } from './PopoverArrow.js';
|
|
10
|
+
import { StyledPopoverContentWrapper, StyledAnimatedPopper } from './styled.js';
|
|
11
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
12
|
+
|
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
+
|
|
15
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
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;
|
|
19
31
|
const checkAnimationStatus = useCallback(() => {
|
|
20
32
|
if (!showPopover && !withoutAnimation) {
|
|
21
33
|
setIsAnimating(false);
|
|
22
34
|
}
|
|
23
35
|
}, [showPopover, withoutAnimation, setIsAnimating]);
|
|
24
|
-
const popperContent = useMemo(() =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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,
|
|
34
50
|
ref: setPopperElement,
|
|
35
|
-
style: popperStyles
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
export {
|
|
45
|
-
PopoverContent
|
|
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
|
+
}));
|
|
46
60
|
};
|
|
47
|
-
|
|
61
|
+
|
|
62
|
+
export { PopoverContent };
|
|
@@ -1,24 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { usePopper } from
|
|
4
|
-
import { useConfiguredMergedProps } from
|
|
5
|
-
import { useOnClickOutside } from
|
|
6
|
-
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
+
import { useState, useMemo, useEffect } from 'react';
|
|
3
|
+
import { usePopper } from 'react-popper';
|
|
4
|
+
import { useConfiguredMergedProps } from './useConfiguredMergedProps.js';
|
|
5
|
+
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);
|
|
9
10
|
const [isAnimating, setIsAnimating] = useState(false);
|
|
10
|
-
const props = useConfiguredMergedProps({
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const props = useConfiguredMergedProps({
|
|
12
|
+
props: appProps,
|
|
13
|
+
arrowElement
|
|
14
|
+
});
|
|
15
|
+
const {
|
|
16
|
+
referenceElement,
|
|
17
|
+
closeContextMenu,
|
|
18
|
+
onClickOutside,
|
|
19
|
+
modifiers,
|
|
20
|
+
startPlacementPreference
|
|
21
|
+
} = props;
|
|
22
|
+
const popperExtraOpts = useMemo(() => ({
|
|
23
|
+
placement: startPlacementPreference,
|
|
24
|
+
modifiers
|
|
25
|
+
}), [modifiers, startPlacementPreference]);
|
|
13
26
|
const popoverHelper = usePopper(referenceElement, popperElement, popperExtraOpts);
|
|
14
|
-
const {
|
|
27
|
+
const {
|
|
28
|
+
showPopover,
|
|
29
|
+
withoutAnimation
|
|
30
|
+
} = props;
|
|
15
31
|
useEffect(() => {
|
|
16
32
|
if (showPopover && !withoutAnimation) {
|
|
17
33
|
setIsAnimating(true);
|
|
18
34
|
}
|
|
19
35
|
}, [showPopover, withoutAnimation]);
|
|
20
|
-
useOnClickOutside(popperElement,
|
|
21
|
-
|
|
36
|
+
useOnClickOutside(popperElement, e => {
|
|
37
|
+
var _referenceElement$con;
|
|
38
|
+
|
|
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))) {
|
|
22
40
|
onClickOutside(e);
|
|
23
41
|
closeContextMenu();
|
|
24
42
|
}
|
|
@@ -34,7 +52,5 @@ const useConfigDSPopperjs = (appProps) => {
|
|
|
34
52
|
setIsAnimating
|
|
35
53
|
}), [arrowElement, popoverHelper, popperElement, isAnimating, props]);
|
|
36
54
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=useConfigDSPopperjs.js.map
|
|
55
|
+
|
|
56
|
+
export { useConfigDSPopperjs };
|
|
@@ -1,60 +1,66 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const useConfiguredDefaultModifiers =
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
const useConfiguredDefaultModifiers = _ref => {
|
|
4
|
+
let {
|
|
5
|
+
props,
|
|
6
|
+
arrowElement
|
|
7
|
+
} = _ref;
|
|
8
|
+
// we destructure explicit app definitions before merge
|
|
4
9
|
const {
|
|
5
10
|
boundaryElement: explicitAppBoundaryElement,
|
|
6
11
|
withoutArrow: explicitAppWithoutArrow = false,
|
|
7
|
-
placementOrderPreference: explicitPlacementOrderPreference = [
|
|
8
|
-
customOffset: explictAppOffset =
|
|
9
|
-
} = props;
|
|
12
|
+
placementOrderPreference: explicitPlacementOrderPreference = ['top', 'bottom', 'left', 'right'],
|
|
13
|
+
customOffset: explictAppOffset = undefined
|
|
14
|
+
} = props; // to build default modifiers on top of it
|
|
15
|
+
|
|
10
16
|
const defaultModifiers = useMemo(() => {
|
|
11
17
|
const mod = [];
|
|
12
|
-
mod.push({ name: "hide", enabled: true });
|
|
13
18
|
mod.push({
|
|
14
|
-
name:
|
|
19
|
+
name: 'hide',
|
|
20
|
+
enabled: true
|
|
21
|
+
});
|
|
22
|
+
mod.push({
|
|
23
|
+
name: 'flip',
|
|
15
24
|
options: {
|
|
16
25
|
fallbackPlacements: explicitPlacementOrderPreference
|
|
17
26
|
}
|
|
18
|
-
});
|
|
27
|
+
}); // we apply an offset if the app defines one or if the app wants the arrow
|
|
28
|
+
|
|
19
29
|
if (!explicitAppWithoutArrow || explictAppOffset) {
|
|
20
30
|
const defaultOffset = explictAppOffset || [0, 14];
|
|
21
31
|
mod.push({
|
|
22
|
-
name:
|
|
32
|
+
name: 'offset',
|
|
23
33
|
enabled: true,
|
|
24
34
|
options: {
|
|
25
35
|
offset: defaultOffset
|
|
26
36
|
}
|
|
27
37
|
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
38
|
+
} // the app can opt for a "no arrow" implementation (we do so in datatable/calendar etc...)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
if (!explicitAppWithoutArrow) mod.push({
|
|
42
|
+
name: 'arrow',
|
|
43
|
+
options: {
|
|
44
|
+
element: arrowElement,
|
|
45
|
+
padding: 18
|
|
46
|
+
}
|
|
47
|
+
}); // the app can define an explicit element to act as a boundary instead of popperjs default one
|
|
48
|
+
|
|
49
|
+
if (explicitAppBoundaryElement) mod.push({
|
|
50
|
+
name: 'preventOverflow',
|
|
51
|
+
options: {
|
|
52
|
+
boundary: explicitAppBoundaryElement
|
|
53
|
+
}
|
|
54
|
+
});
|
|
44
55
|
return mod;
|
|
45
|
-
}, [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
explictAppOffset
|
|
51
|
-
]);
|
|
52
|
-
const { modifiers: explicitAppModifiers = defaultModifiers } = props;
|
|
56
|
+
}, [arrowElement, explicitAppBoundaryElement, explicitAppWithoutArrow, explicitPlacementOrderPreference, explictAppOffset]); // if the app pass custom modifier, we don't use "default modifiers"
|
|
57
|
+
|
|
58
|
+
const {
|
|
59
|
+
modifiers: explicitAppModifiers = defaultModifiers
|
|
60
|
+
} = props;
|
|
53
61
|
return useMemo(() => ({
|
|
54
62
|
modifiers: explicitAppModifiers
|
|
55
63
|
}), [explicitAppModifiers]);
|
|
56
64
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
60
|
-
//# sourceMappingURL=useConfiguredDefaultModifiers.js.map
|
|
65
|
+
|
|
66
|
+
export { useConfiguredDefaultModifiers };
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
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';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import { useMemo } from 'react';
|
|
8
|
+
import { useConfiguredDefaultModifiers } from './useConfiguredDefaultModifiers.js';
|
|
9
|
+
|
|
10
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
|
+
|
|
12
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
|
+
|
|
14
|
+
const noop = () => {};
|
|
15
|
+
|
|
6
16
|
const emptyObj = {};
|
|
7
|
-
const useConfiguredDefaultProps =
|
|
17
|
+
const useConfiguredDefaultProps = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
props,
|
|
20
|
+
arrowElement
|
|
21
|
+
} = _ref;
|
|
22
|
+
// don't move this out of the hook or `document.body` will explode
|
|
8
23
|
const staticDefaultProps = useMemo(() => ({
|
|
9
24
|
referenceElement: null,
|
|
10
25
|
showPopover: false,
|
|
@@ -15,19 +30,21 @@ const useConfiguredDefaultProps = ({ props, arrowElement }) => {
|
|
|
15
30
|
withoutAnimation: false,
|
|
16
31
|
animationDuration: 100,
|
|
17
32
|
portalDOMContainer: document.body,
|
|
18
|
-
startPlacementPreference:
|
|
19
|
-
placementOrderPreference: [
|
|
33
|
+
startPlacementPreference: 'top',
|
|
34
|
+
placementOrderPreference: ['top', 'bottom', 'left', 'right'],
|
|
20
35
|
zIndex: 1,
|
|
21
36
|
extraPopperStyles: emptyObj
|
|
22
37
|
}), []);
|
|
23
|
-
const {
|
|
38
|
+
const {
|
|
39
|
+
modifiers: configuredModifiers
|
|
40
|
+
} = useConfiguredDefaultModifiers({
|
|
24
41
|
props,
|
|
25
42
|
arrowElement
|
|
26
43
|
});
|
|
27
|
-
const defaultProps = useMemo(() => ({
|
|
44
|
+
const defaultProps = useMemo(() => _objectSpread(_objectSpread({}, staticDefaultProps), {}, {
|
|
45
|
+
modifiers: configuredModifiers
|
|
46
|
+
}), [configuredModifiers, staticDefaultProps]);
|
|
28
47
|
return defaultProps;
|
|
29
48
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=useConfiguredDefaultProps.js.map
|
|
49
|
+
|
|
50
|
+
export { useConfiguredDefaultProps };
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const useConfiguredMergedProps =
|
|
5
|
-
|
|
1
|
+
import { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';
|
|
2
|
+
import { useConfiguredDefaultProps } from './useConfiguredDefaultProps.js';
|
|
3
|
+
|
|
4
|
+
const useConfiguredMergedProps = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
props,
|
|
7
|
+
arrowElement
|
|
8
|
+
} = _ref;
|
|
9
|
+
const defaultProps = useConfiguredDefaultProps({
|
|
10
|
+
props,
|
|
11
|
+
arrowElement
|
|
12
|
+
});
|
|
6
13
|
return useMemoMergePropsWithDefault(props, defaultProps);
|
|
7
14
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=useConfiguredMergedProps.js.map
|
|
15
|
+
|
|
16
|
+
export { useConfiguredMergedProps };
|
package/esm/index.d.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=index.d.js.map
|
|
1
|
+
|
package/esm/index.js
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
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';
|
|
6
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
7
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
8
|
+
import { useMemo } from 'react';
|
|
9
|
+
import { createPortal } from 'react-dom';
|
|
10
|
+
import { describe } from 'react-desc';
|
|
11
|
+
import { dspopperjsPropTypes } from './propTypes.js';
|
|
12
|
+
import { PopoverContent } from './PopoverContent.js';
|
|
13
|
+
import { useConfigDSPopperjs } from './config/useConfigDSPopperjs.js';
|
|
14
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
15
|
+
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
+
|
|
20
|
+
const DSPopperJS = props => {
|
|
9
21
|
const {
|
|
10
22
|
props: {
|
|
11
23
|
showPopover,
|
|
@@ -23,50 +35,40 @@ const DSPopperJS = (props) => {
|
|
|
23
35
|
popoverHelper,
|
|
24
36
|
isAnimating
|
|
25
37
|
} = useConfigDSPopperjs(props);
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
const {
|
|
39
|
+
children
|
|
40
|
+
} = props;
|
|
41
|
+
const {
|
|
42
|
+
styles,
|
|
43
|
+
attributes
|
|
44
|
+
} = popoverHelper;
|
|
45
|
+
const contentJSX = useMemo(() => /*#__PURE__*/_jsx(PopoverContent, {
|
|
46
|
+
setPopperElement: setPopperElement,
|
|
47
|
+
popperStyles: _objectSpread(_objectSpread({}, styles.popper), extraPopperStyles),
|
|
31
48
|
popperAttributes: attributes.popper,
|
|
32
|
-
setArrowElement,
|
|
49
|
+
setArrowElement: setArrowElement,
|
|
33
50
|
arrowStyle: styles.arrow,
|
|
34
|
-
withoutArrow,
|
|
35
|
-
withoutAnimation,
|
|
36
|
-
animationDuration,
|
|
37
|
-
zIndex,
|
|
38
|
-
showPopover,
|
|
39
|
-
setIsAnimating
|
|
40
|
-
}, children), [
|
|
41
|
-
|
|
42
|
-
children,
|
|
43
|
-
setIsAnimating,
|
|
44
|
-
showPopover,
|
|
45
|
-
extraPopperStyles,
|
|
46
|
-
setArrowElement,
|
|
47
|
-
setPopperElement,
|
|
48
|
-
styles.arrow,
|
|
49
|
-
styles.popper,
|
|
50
|
-
withoutArrow,
|
|
51
|
-
withoutAnimation,
|
|
52
|
-
animationDuration,
|
|
53
|
-
zIndex
|
|
54
|
-
]);
|
|
51
|
+
withoutArrow: withoutArrow,
|
|
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]);
|
|
58
|
+
|
|
55
59
|
if (showPopover || isAnimating) {
|
|
56
|
-
if (withoutPortal === true)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
if (withoutPortal === true) return contentJSX;
|
|
61
|
+
if (withoutPortal === false) return /*#__PURE__*/jsx(Fragment, {
|
|
62
|
+
children: /*#__PURE__*/createPortal( /*#__PURE__*/jsx(Fragment, {
|
|
63
|
+
children: contentJSX
|
|
64
|
+
}), portalDOMContainer)
|
|
65
|
+
});
|
|
60
66
|
}
|
|
67
|
+
|
|
61
68
|
return null;
|
|
62
69
|
};
|
|
63
|
-
|
|
64
|
-
const DSPopperJSWithSchema = describe(DSPopperJS).description(
|
|
70
|
+
|
|
71
|
+
const DSPopperJSWithSchema = describe(DSPopperJS).description('A dimsum custom styling wrapper on top of popperjs');
|
|
65
72
|
DSPopperJSWithSchema.propTypes = dspopperjsPropTypes;
|
|
66
|
-
|
|
67
|
-
export {
|
|
68
|
-
DSPopperJS,
|
|
69
|
-
DSPopperJSWithSchema,
|
|
70
|
-
src_default as default
|
|
71
|
-
};
|
|
72
|
-
//# sourceMappingURL=index.js.map
|
|
73
|
+
|
|
74
|
+
export { DSPopperJS, DSPopperJSWithSchema, DSPopperJS as default };
|