@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/cjs/PopoverArrow.js
CHANGED
|
@@ -1,91 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var PopoverArrow_exports = {};
|
|
29
|
-
__export(PopoverArrow_exports, {
|
|
30
|
-
PopoverArrow: () => PopoverArrow
|
|
31
|
-
});
|
|
32
|
-
var React = __toESM(require("react"));
|
|
33
|
-
var import_react = __toESM(require("react"));
|
|
34
|
-
var import_styled_components = __toESM(require("styled-components"));
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
6
|
+
require('react');
|
|
7
|
+
var styled = require('styled-components');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
13
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
14
|
+
|
|
15
|
+
var _svg;
|
|
35
16
|
const arrowWidth = 18;
|
|
36
17
|
const arrowHeight = 18;
|
|
37
|
-
const StyledArrow =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
18
|
+
const StyledArrow = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
19
|
+
componentId: "sc-olcdf1-0"
|
|
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
|
+
};
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
svg {
|
|
53
|
-
transform: rotateZ(180deg);
|
|
54
|
-
}
|
|
55
|
-
bottom: -${arrowHeight}px;
|
|
56
|
-
}
|
|
57
|
-
&[data-placement^='right'] {
|
|
58
|
-
svg {
|
|
59
|
-
transform: rotateZ(-90deg);
|
|
60
|
-
}
|
|
61
|
-
left: -${arrowWidth}px;
|
|
62
|
-
}
|
|
63
|
-
&[data-placement^='bottom'] {
|
|
64
|
-
top: -${arrowHeight}px;
|
|
65
|
-
}
|
|
66
|
-
&[data-placement^='left'] {
|
|
67
|
-
svg {
|
|
68
|
-
transform: rotateZ(90deg);
|
|
69
|
-
}
|
|
70
|
-
right: -${arrowWidth}px;
|
|
71
|
-
}
|
|
72
|
-
margin-left: ${(props) => props["data-placement"].startsWith("top") || props["data-placement"].startsWith("bottom") ? `-${arrowWidth / 2}px;` : "0;"};
|
|
73
|
-
margin-top: ${(props) => props["data-placement"].startsWith("left") || props["data-placement"].startsWith("right") ? `-${arrowHeight / 2}px;` : "0;"};
|
|
74
|
-
`;
|
|
75
|
-
const PopoverArrow = ({ placement, style, arrowElementRef }) => /* @__PURE__ */ import_react.default.createElement(StyledArrow, {
|
|
76
|
-
key: "popper-arrow",
|
|
77
|
-
"data-placement": placement,
|
|
78
|
-
style,
|
|
79
|
-
ref: arrowElementRef,
|
|
80
|
-
"data-testid": "ds-tooltip-arrow"
|
|
81
|
-
}, /* @__PURE__ */ import_react.default.createElement("svg", {
|
|
82
|
-
viewBox: "0 0 30 30"
|
|
83
|
-
}, /* @__PURE__ */ import_react.default.createElement("path", {
|
|
84
|
-
className: "stroke",
|
|
85
|
-
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"
|
|
86
|
-
}), /* @__PURE__ */ import_react.default.createElement("path", {
|
|
87
|
-
className: "fill",
|
|
88
|
-
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"
|
|
89
|
-
})));
|
|
90
|
-
module.exports = __toCommonJS(PopoverArrow_exports);
|
|
91
|
-
//# sourceMappingURL=PopoverArrow.js.map
|
|
54
|
+
exports.PopoverArrow = PopoverArrow;
|
package/cjs/PopoverContent.js
CHANGED
|
@@ -1,76 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
showPopover,
|
|
42
|
-
setArrowElement,
|
|
43
|
-
setIsAnimating,
|
|
44
|
-
arrowStyle,
|
|
45
|
-
withoutArrow,
|
|
46
|
-
withoutAnimation,
|
|
47
|
-
animationDuration,
|
|
48
|
-
zIndex
|
|
49
|
-
}) => {
|
|
50
|
-
const checkAnimationStatus = (0, import_react.useCallback)(() => {
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
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');
|
|
10
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
11
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
12
|
+
var react = require('react');
|
|
13
|
+
var PopoverArrow = require('./PopoverArrow.js');
|
|
14
|
+
var styled = require('./styled.js');
|
|
15
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
16
|
+
|
|
17
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
|
+
|
|
19
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
20
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
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__default["default"](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; }
|
|
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(() => {
|
|
51
41
|
if (!showPopover && !withoutAnimation) {
|
|
52
42
|
setIsAnimating(false);
|
|
53
43
|
}
|
|
54
44
|
}, [showPopover, withoutAnimation, setIsAnimating]);
|
|
55
|
-
const popperContent =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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,
|
|
65
59
|
ref: setPopperElement,
|
|
66
|
-
style: popperStyles
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
+
}));
|
|
74
69
|
};
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
|
|
71
|
+
exports.PopoverContent = PopoverContent;
|
|
@@ -1,60 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
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
|
-
var import_useOnClickOutside = require("../utils/hooks/useOnClickOutside");
|
|
37
|
-
const useConfigDSPopperjs = (appProps) => {
|
|
38
|
-
const [popperElement, setPopperElement] = (0, import_react.useState)(null);
|
|
39
|
-
const [arrowElement, setArrowElement] = (0, import_react.useState)(null);
|
|
40
|
-
const [isAnimating, setIsAnimating] = (0, import_react.useState)(false);
|
|
41
|
-
const props = (0, import_useConfiguredMergedProps.useConfiguredMergedProps)({ props: appProps, arrowElement });
|
|
42
|
-
const { referenceElement, closeContextMenu, onClickOutside, modifiers, startPlacementPreference } = props;
|
|
43
|
-
const popperExtraOpts = (0, import_react.useMemo)(() => ({ placement: startPlacementPreference, modifiers }), [modifiers, startPlacementPreference]);
|
|
44
|
-
const popoverHelper = (0, import_react_popper.usePopper)(referenceElement, popperElement, popperExtraOpts);
|
|
45
|
-
const { showPopover, withoutAnimation } = props;
|
|
46
|
-
(0, import_react.useEffect)(() => {
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var reactPopper = require('react-popper');
|
|
8
|
+
var useConfiguredMergedProps = require('./useConfiguredMergedProps.js');
|
|
9
|
+
var useOnClickOutside = require('../utils/hooks/useOnClickOutside.js');
|
|
10
|
+
|
|
11
|
+
const useConfigDSPopperjs = appProps => {
|
|
12
|
+
const [popperElement, setPopperElement] = react.useState(null);
|
|
13
|
+
const [arrowElement, setArrowElement] = react.useState(null);
|
|
14
|
+
const [isAnimating, setIsAnimating] = react.useState(false);
|
|
15
|
+
const props = useConfiguredMergedProps.useConfiguredMergedProps({
|
|
16
|
+
props: appProps,
|
|
17
|
+
arrowElement
|
|
18
|
+
});
|
|
19
|
+
const {
|
|
20
|
+
referenceElement,
|
|
21
|
+
closeContextMenu,
|
|
22
|
+
onClickOutside,
|
|
23
|
+
modifiers,
|
|
24
|
+
startPlacementPreference
|
|
25
|
+
} = props;
|
|
26
|
+
const popperExtraOpts = react.useMemo(() => ({
|
|
27
|
+
placement: startPlacementPreference,
|
|
28
|
+
modifiers
|
|
29
|
+
}), [modifiers, startPlacementPreference]);
|
|
30
|
+
const popoverHelper = reactPopper.usePopper(referenceElement, popperElement, popperExtraOpts);
|
|
31
|
+
const {
|
|
32
|
+
showPopover,
|
|
33
|
+
withoutAnimation
|
|
34
|
+
} = props;
|
|
35
|
+
react.useEffect(() => {
|
|
47
36
|
if (showPopover && !withoutAnimation) {
|
|
48
37
|
setIsAnimating(true);
|
|
49
38
|
}
|
|
50
39
|
}, [showPopover, withoutAnimation]);
|
|
51
|
-
|
|
52
|
-
|
|
40
|
+
useOnClickOutside.useOnClickOutside(popperElement, e => {
|
|
41
|
+
var _referenceElement$con;
|
|
42
|
+
|
|
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))) {
|
|
53
44
|
onClickOutside(e);
|
|
54
45
|
closeContextMenu();
|
|
55
46
|
}
|
|
56
47
|
});
|
|
57
|
-
return
|
|
48
|
+
return react.useMemo(() => ({
|
|
58
49
|
props,
|
|
59
50
|
popperElement,
|
|
60
51
|
setPopperElement,
|
|
@@ -65,5 +56,5 @@ const useConfigDSPopperjs = (appProps) => {
|
|
|
65
56
|
setIsAnimating
|
|
66
57
|
}), [arrowElement, popoverHelper, popperElement, isAnimating, props]);
|
|
67
58
|
};
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
|
|
60
|
+
exports.useConfigDSPopperjs = useConfigDSPopperjs;
|
|
@@ -1,89 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var useConfiguredDefaultModifiers_exports = {};
|
|
29
|
-
__export(useConfiguredDefaultModifiers_exports, {
|
|
30
|
-
useConfiguredDefaultModifiers: () => useConfiguredDefaultModifiers
|
|
31
|
-
});
|
|
32
|
-
var React = __toESM(require("react"));
|
|
33
|
-
var import_react = require("react");
|
|
34
|
-
const useConfiguredDefaultModifiers = ({ props, arrowElement }) => {
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var react = require('react');
|
|
6
|
+
|
|
7
|
+
const useConfiguredDefaultModifiers = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
props,
|
|
10
|
+
arrowElement
|
|
11
|
+
} = _ref;
|
|
12
|
+
// we destructure explicit app definitions before merge
|
|
35
13
|
const {
|
|
36
14
|
boundaryElement: explicitAppBoundaryElement,
|
|
37
15
|
withoutArrow: explicitAppWithoutArrow = false,
|
|
38
|
-
placementOrderPreference: explicitPlacementOrderPreference = [
|
|
39
|
-
customOffset: explictAppOffset =
|
|
40
|
-
} = props;
|
|
41
|
-
|
|
16
|
+
placementOrderPreference: explicitPlacementOrderPreference = ['top', 'bottom', 'left', 'right'],
|
|
17
|
+
customOffset: explictAppOffset = undefined
|
|
18
|
+
} = props; // to build default modifiers on top of it
|
|
19
|
+
|
|
20
|
+
const defaultModifiers = react.useMemo(() => {
|
|
42
21
|
const mod = [];
|
|
43
|
-
mod.push({ name: "hide", enabled: true });
|
|
44
22
|
mod.push({
|
|
45
|
-
name:
|
|
23
|
+
name: 'hide',
|
|
24
|
+
enabled: true
|
|
25
|
+
});
|
|
26
|
+
mod.push({
|
|
27
|
+
name: 'flip',
|
|
46
28
|
options: {
|
|
47
29
|
fallbackPlacements: explicitPlacementOrderPreference
|
|
48
30
|
}
|
|
49
|
-
});
|
|
31
|
+
}); // we apply an offset if the app defines one or if the app wants the arrow
|
|
32
|
+
|
|
50
33
|
if (!explicitAppWithoutArrow || explictAppOffset) {
|
|
51
34
|
const defaultOffset = explictAppOffset || [0, 14];
|
|
52
35
|
mod.push({
|
|
53
|
-
name:
|
|
36
|
+
name: 'offset',
|
|
54
37
|
enabled: true,
|
|
55
38
|
options: {
|
|
56
39
|
offset: defaultOffset
|
|
57
40
|
}
|
|
58
41
|
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
42
|
+
} // the app can opt for a "no arrow" implementation (we do so in datatable/calendar etc...)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if (!explicitAppWithoutArrow) mod.push({
|
|
46
|
+
name: 'arrow',
|
|
47
|
+
options: {
|
|
48
|
+
element: arrowElement,
|
|
49
|
+
padding: 18
|
|
50
|
+
}
|
|
51
|
+
}); // the app can define an explicit element to act as a boundary instead of popperjs default one
|
|
52
|
+
|
|
53
|
+
if (explicitAppBoundaryElement) mod.push({
|
|
54
|
+
name: 'preventOverflow',
|
|
55
|
+
options: {
|
|
56
|
+
boundary: explicitAppBoundaryElement
|
|
57
|
+
}
|
|
58
|
+
});
|
|
75
59
|
return mod;
|
|
76
|
-
}, [
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
]);
|
|
83
|
-
const { modifiers: explicitAppModifiers = defaultModifiers } = props;
|
|
84
|
-
return (0, import_react.useMemo)(() => ({
|
|
60
|
+
}, [arrowElement, explicitAppBoundaryElement, explicitAppWithoutArrow, explicitPlacementOrderPreference, explictAppOffset]); // if the app pass custom modifier, we don't use "default modifiers"
|
|
61
|
+
|
|
62
|
+
const {
|
|
63
|
+
modifiers: explicitAppModifiers = defaultModifiers
|
|
64
|
+
} = props;
|
|
65
|
+
return react.useMemo(() => ({
|
|
85
66
|
modifiers: explicitAppModifiers
|
|
86
67
|
}), [explicitAppModifiers]);
|
|
87
68
|
};
|
|
88
|
-
|
|
89
|
-
|
|
69
|
+
|
|
70
|
+
exports.useConfiguredDefaultModifiers = useConfiguredDefaultModifiers;
|
|
@@ -1,42 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var useConfiguredDefaultProps_exports = {};
|
|
29
|
-
__export(useConfiguredDefaultProps_exports, {
|
|
30
|
-
useConfiguredDefaultProps: () => useConfiguredDefaultProps
|
|
31
|
-
});
|
|
32
|
-
var React = __toESM(require("react"));
|
|
33
|
-
var import_react = require("react");
|
|
34
|
-
var import_useConfiguredDefaultModifiers = require("./useConfiguredDefaultModifiers");
|
|
35
|
-
const noop = () => {
|
|
36
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
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');
|
|
10
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
11
|
+
var react = require('react');
|
|
12
|
+
var useConfiguredDefaultModifiers = require('./useConfiguredDefaultModifiers.js');
|
|
13
|
+
|
|
14
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
+
|
|
16
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
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__default["default"](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; }
|
|
21
|
+
|
|
22
|
+
const noop = () => {};
|
|
23
|
+
|
|
37
24
|
const emptyObj = {};
|
|
38
|
-
const useConfiguredDefaultProps =
|
|
39
|
-
|
|
25
|
+
const useConfiguredDefaultProps = _ref => {
|
|
26
|
+
let {
|
|
27
|
+
props,
|
|
28
|
+
arrowElement
|
|
29
|
+
} = _ref;
|
|
30
|
+
// don't move this out of the hook or `document.body` will explode
|
|
31
|
+
const staticDefaultProps = react.useMemo(() => ({
|
|
40
32
|
referenceElement: null,
|
|
41
33
|
showPopover: false,
|
|
42
34
|
closeContextMenu: noop,
|
|
@@ -46,17 +38,21 @@ const useConfiguredDefaultProps = ({ props, arrowElement }) => {
|
|
|
46
38
|
withoutAnimation: false,
|
|
47
39
|
animationDuration: 100,
|
|
48
40
|
portalDOMContainer: document.body,
|
|
49
|
-
startPlacementPreference:
|
|
50
|
-
placementOrderPreference: [
|
|
41
|
+
startPlacementPreference: 'top',
|
|
42
|
+
placementOrderPreference: ['top', 'bottom', 'left', 'right'],
|
|
51
43
|
zIndex: 1,
|
|
52
44
|
extraPopperStyles: emptyObj
|
|
53
45
|
}), []);
|
|
54
|
-
const {
|
|
46
|
+
const {
|
|
47
|
+
modifiers: configuredModifiers
|
|
48
|
+
} = useConfiguredDefaultModifiers.useConfiguredDefaultModifiers({
|
|
55
49
|
props,
|
|
56
50
|
arrowElement
|
|
57
51
|
});
|
|
58
|
-
const defaultProps =
|
|
52
|
+
const defaultProps = react.useMemo(() => _objectSpread(_objectSpread({}, staticDefaultProps), {}, {
|
|
53
|
+
modifiers: configuredModifiers
|
|
54
|
+
}), [configuredModifiers, staticDefaultProps]);
|
|
59
55
|
return defaultProps;
|
|
60
56
|
};
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
|
|
58
|
+
exports.useConfiguredDefaultProps = useConfiguredDefaultProps;
|