@elliemae/ds-popper 2.2.0-alpha.3 → 2.2.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/DSPopper.js +97 -117
- package/cjs/PopperContent.js +114 -106
- package/cjs/PopperImpl.js +167 -104
- package/cjs/getArrowStylesBySize.js +45 -59
- package/cjs/index.js +19 -37
- package/cjs/interaction.js +9 -37
- package/cjs/positions.js +23 -67
- package/cjs/props.js +61 -62
- package/esm/DSPopper.js +80 -85
- package/esm/PopperContent.js +102 -74
- package/esm/PopperImpl.js +148 -69
- package/esm/getArrowStylesBySize.js +36 -30
- package/esm/index.js +4 -8
- package/esm/interaction.js +4 -8
- package/esm/positions.js +18 -38
- package/esm/props.js +54 -31
- package/package.json +3 -3
- package/cjs/DSPopper.js.map +0 -7
- package/cjs/PopperContent.js.map +0 -7
- package/cjs/PopperImpl.js.map +0 -7
- package/cjs/getArrowStylesBySize.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/interaction.js.map +0 -7
- package/cjs/positions.js.map +0 -7
- package/cjs/props.js.map +0 -7
- package/esm/DSPopper.js.map +0 -7
- package/esm/PopperContent.js.map +0 -7
- package/esm/PopperImpl.js.map +0 -7
- package/esm/getArrowStylesBySize.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/interaction.js.map +0 -7
- package/esm/positions.js.map +0 -7
- package/esm/props.js.map +0 -7
package/cjs/DSPopper.js
CHANGED
|
@@ -1,117 +1,97 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
openAnimationConfig,
|
|
99
|
-
placement,
|
|
100
|
-
preventOverflow,
|
|
101
|
-
referenceNode,
|
|
102
|
-
renderReference,
|
|
103
|
-
showArrow,
|
|
104
|
-
triggerComponent,
|
|
105
|
-
triggerRef,
|
|
106
|
-
usePortal,
|
|
107
|
-
wrapExtraComponent,
|
|
108
|
-
zIndex,
|
|
109
|
-
hideIfNotVisible
|
|
110
|
-
}, customPopper);
|
|
111
|
-
DSPopper.propTypes = import_props.popperProps;
|
|
112
|
-
DSPopper.defaultProps = import_props.defaultProps;
|
|
113
|
-
const DSPopperWithSchema = (0, import_react_desc.describe)(DSPopper);
|
|
114
|
-
DSPopperWithSchema.propTypes = import_props.popperProps;
|
|
115
|
-
var DSPopper_default = DSPopper;
|
|
116
|
-
module.exports = __toCommonJS(DSPopper_exports);
|
|
117
|
-
//# sourceMappingURL=DSPopper.js.map
|
|
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 reactDesc = require('react-desc');
|
|
8
|
+
var PopperImpl = require('./PopperImpl.js');
|
|
9
|
+
var positions = require('./positions.js');
|
|
10
|
+
var interaction = require('./interaction.js');
|
|
11
|
+
var props = require('./props.js');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
16
|
+
|
|
17
|
+
const DSPopper = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
containerProps,
|
|
20
|
+
arrowGap,
|
|
21
|
+
arrowSize,
|
|
22
|
+
blockName,
|
|
23
|
+
contentOffset,
|
|
24
|
+
contentStyle,
|
|
25
|
+
contentComponent,
|
|
26
|
+
delayClose,
|
|
27
|
+
delayOpen,
|
|
28
|
+
interactionType,
|
|
29
|
+
isOpen,
|
|
30
|
+
// if this is set DSPopper would be a controlled component if not, an uncontrolled one
|
|
31
|
+
onOpen,
|
|
32
|
+
onClose,
|
|
33
|
+
onPlacementChange,
|
|
34
|
+
placement,
|
|
35
|
+
preventOverflow,
|
|
36
|
+
showArrow,
|
|
37
|
+
closeAnimationConfig,
|
|
38
|
+
openAnimationConfig,
|
|
39
|
+
usePortal,
|
|
40
|
+
triggerComponent,
|
|
41
|
+
wrapExtraComponent,
|
|
42
|
+
getTargetFromChildren,
|
|
43
|
+
getContentFromChildren,
|
|
44
|
+
modifiers,
|
|
45
|
+
triggerRef,
|
|
46
|
+
children: customPopper,
|
|
47
|
+
renderReference,
|
|
48
|
+
referenceNode,
|
|
49
|
+
zIndex,
|
|
50
|
+
hideIfNotVisible
|
|
51
|
+
} = _ref;
|
|
52
|
+
return /*#__PURE__*/_jsx__default["default"](PopperImpl["default"], {
|
|
53
|
+
arrowGap: arrowGap,
|
|
54
|
+
arrowSize: arrowSize,
|
|
55
|
+
blockName: blockName,
|
|
56
|
+
closeAnimationConfig: closeAnimationConfig,
|
|
57
|
+
containerProps: containerProps,
|
|
58
|
+
contentComponent: contentComponent,
|
|
59
|
+
contentOffset: contentOffset,
|
|
60
|
+
contentStyle: contentStyle,
|
|
61
|
+
delayClose: delayClose,
|
|
62
|
+
delayOpen: delayOpen,
|
|
63
|
+
getContentFromChildren: getContentFromChildren,
|
|
64
|
+
getTargetFromChildren: getTargetFromChildren,
|
|
65
|
+
interactionType: interactionType,
|
|
66
|
+
isOpen: isOpen,
|
|
67
|
+
modifiers: modifiers,
|
|
68
|
+
onOpen: onOpen,
|
|
69
|
+
onClose: onClose,
|
|
70
|
+
onPlacementChange: onPlacementChange,
|
|
71
|
+
openAnimationConfig: openAnimationConfig,
|
|
72
|
+
placement: placement,
|
|
73
|
+
preventOverflow: preventOverflow,
|
|
74
|
+
referenceNode: referenceNode,
|
|
75
|
+
renderReference: renderReference,
|
|
76
|
+
showArrow: showArrow,
|
|
77
|
+
triggerComponent: triggerComponent,
|
|
78
|
+
triggerRef: triggerRef,
|
|
79
|
+
usePortal: usePortal,
|
|
80
|
+
wrapExtraComponent: wrapExtraComponent,
|
|
81
|
+
zIndex: zIndex,
|
|
82
|
+
hideIfNotVisible: hideIfNotVisible
|
|
83
|
+
}, void 0, customPopper);
|
|
84
|
+
}; // @deprecated: There's the NEW (not finished) popover that uses its own popper implementation.
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
DSPopper.defaultProps = props.defaultProps;
|
|
88
|
+
const DSPopperWithSchema = reactDesc.describe(DSPopper);
|
|
89
|
+
DSPopperWithSchema.propTypes = props.popperProps;
|
|
90
|
+
|
|
91
|
+
exports.PopperPositions = positions.Position;
|
|
92
|
+
exports.positions = positions.positions;
|
|
93
|
+
exports.PopperInteractions = interaction.Interaction;
|
|
94
|
+
exports.interactions = interaction.interactions;
|
|
95
|
+
exports.DSPopper = DSPopper;
|
|
96
|
+
exports.DSPopperWithSchema = DSPopperWithSchema;
|
|
97
|
+
exports["default"] = DSPopper;
|
package/cjs/PopperContent.js
CHANGED
|
@@ -1,86 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var import_react = __toESM(require("react"));
|
|
34
|
-
var import_react_popper = __toESM(require("react-popper"));
|
|
35
|
-
var import_renderprops = __toESM(require("react-spring/renderprops"));
|
|
36
|
-
var import_getComponentFromProps = __toESM(require("@elliemae/ds-utilities/getComponentFromProps"));
|
|
37
|
-
var import_ds_overlay = __toESM(require("@elliemae/ds-overlay"));
|
|
38
|
-
var import_getArrowStylesBySize = __toESM(require("./getArrowStylesBySize"));
|
|
39
|
-
const Content = import_renderprops.Keyframes.Spring({});
|
|
40
|
-
class PopperContent extends import_react.PureComponent {
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
4
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
5
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
8
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
9
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
10
|
+
var react = require('react');
|
|
11
|
+
var reactPopper = require('react-popper');
|
|
12
|
+
var renderprops = require('react-spring/renderprops');
|
|
13
|
+
var getComponentFromProps = require('@elliemae/ds-utilities/getComponentFromProps');
|
|
14
|
+
var DSOverlay = require('@elliemae/ds-overlay');
|
|
15
|
+
var getArrowStylesBySize = require('./getArrowStylesBySize.js');
|
|
16
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
17
|
+
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
+
|
|
20
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
21
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
22
|
+
var getComponentFromProps__default = /*#__PURE__*/_interopDefaultLegacy(getComponentFromProps);
|
|
23
|
+
var DSOverlay__default = /*#__PURE__*/_interopDefaultLegacy(DSOverlay);
|
|
24
|
+
|
|
25
|
+
var _svg;
|
|
26
|
+
|
|
27
|
+
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; }
|
|
28
|
+
|
|
29
|
+
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; }
|
|
30
|
+
const Content = renderprops.Keyframes.Spring({});
|
|
31
|
+
class PopperContent extends react.PureComponent {
|
|
32
|
+
// eslint-disable-next-line react/static-property-placement
|
|
41
33
|
constructor(props) {
|
|
42
34
|
super(props);
|
|
43
35
|
this.renderContent = this.renderContent.bind(this);
|
|
44
36
|
this.renderArrow = this.renderArrow.bind(this);
|
|
45
37
|
this.handleRestAnimation = this.handleRestAnimation.bind(this);
|
|
38
|
+
this.handleRestAnimation = this.handleRestAnimation.bind(this);
|
|
46
39
|
}
|
|
40
|
+
|
|
47
41
|
handleRestAnimation() {
|
|
48
|
-
const {
|
|
42
|
+
const {
|
|
43
|
+
isOpen,
|
|
44
|
+
onContentDestroyed
|
|
45
|
+
} = this.props;
|
|
46
|
+
|
|
49
47
|
if (!isOpen) {
|
|
50
48
|
onContentDestroyed();
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return null;
|
|
57
|
-
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
58
|
-
key: "popper-arrow",
|
|
51
|
+
|
|
52
|
+
renderArrow(_ref, placement) {
|
|
53
|
+
let {
|
|
59
54
|
ref,
|
|
60
|
-
|
|
55
|
+
style
|
|
56
|
+
} = _ref;
|
|
57
|
+
const {
|
|
58
|
+
blockName,
|
|
59
|
+
showArrow
|
|
60
|
+
} = this.props;
|
|
61
|
+
if (!showArrow) return null;
|
|
62
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
63
|
+
ref: ref,
|
|
64
|
+
className: "".concat(blockName || 'popper', "__arrow"),
|
|
61
65
|
"data-placement": placement,
|
|
62
|
-
style: {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
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"
|
|
74
|
-
})));
|
|
66
|
+
style: _objectSpread(_objectSpread({}, style), getArrowStylesBySize.getArrowStylesBySize(placement, 25)),
|
|
67
|
+
children: _svg || (_svg = /*#__PURE__*/_jsx__default["default"]("svg", {
|
|
68
|
+
viewBox: "0 0 30 30"
|
|
69
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"]("path", {
|
|
70
|
+
className: "stroke",
|
|
71
|
+
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"
|
|
72
|
+
}), /*#__PURE__*/_jsx__default["default"]("path", {
|
|
73
|
+
className: "fill",
|
|
74
|
+
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"
|
|
75
|
+
})))
|
|
76
|
+
}, "popper-arrow");
|
|
75
77
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
|
|
79
|
+
renderContent(_ref2) {
|
|
80
|
+
let {
|
|
81
|
+
ref,
|
|
82
|
+
style,
|
|
83
|
+
placement,
|
|
84
|
+
arrowProps,
|
|
85
|
+
scheduleUpdate,
|
|
86
|
+
outOfBoundaries
|
|
87
|
+
} = _ref2;
|
|
84
88
|
const {
|
|
85
89
|
contentComponent,
|
|
86
90
|
contentStyle,
|
|
@@ -93,56 +97,60 @@ class PopperContent extends import_react.PureComponent {
|
|
|
93
97
|
zIndex,
|
|
94
98
|
hideIfNotVisible
|
|
95
99
|
} = this.props;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
...contentStyle,
|
|
100
|
+
|
|
101
|
+
const computedStyle = _objectSpread(_objectSpread(_objectSpread({}, style), contentStyle), {}, {
|
|
99
102
|
zIndex
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
103
106
|
"data-placement": placement,
|
|
104
|
-
onMouseEnter,
|
|
105
|
-
onMouseLeave,
|
|
107
|
+
onMouseEnter: onMouseEnter,
|
|
108
|
+
onMouseLeave: onMouseLeave,
|
|
106
109
|
style: computedStyle,
|
|
107
|
-
"data-testid": "popper-container"
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
110
|
+
"data-testid": "popper-container",
|
|
111
|
+
children: /*#__PURE__*/_jsx__default["default"](Content, {
|
|
112
|
+
native: true,
|
|
113
|
+
onRest: this.handleRestAnimation,
|
|
114
|
+
state: isOpen && (!outOfBoundaries || !hideIfNotVisible) ? 'open' : 'close',
|
|
115
|
+
states: {
|
|
116
|
+
open: _objectSpread(_objectSpread({}, openAnimationConfig), {}, {
|
|
117
|
+
from: closeAnimationConfig.to
|
|
118
|
+
}),
|
|
119
|
+
close: closeAnimationConfig
|
|
120
|
+
}
|
|
121
|
+
}, void 0, animationStyle => /*#__PURE__*/jsxRuntime.jsx(renderprops.animated.div, {
|
|
122
|
+
ref: ref,
|
|
123
|
+
style: animationStyle,
|
|
124
|
+
children: getComponentFromProps__default["default"](contentComponent, {
|
|
125
|
+
scheduleUpdate
|
|
126
|
+
}, [this.renderArrow(arrowProps, placement)])
|
|
127
|
+
}))
|
|
128
|
+
}));
|
|
125
129
|
}
|
|
130
|
+
|
|
126
131
|
render() {
|
|
127
132
|
const {
|
|
128
133
|
destroyed = false,
|
|
129
134
|
onClickOutside = () => null,
|
|
130
|
-
placement =
|
|
135
|
+
placement = 'bottom-start',
|
|
131
136
|
modifiers = {},
|
|
132
137
|
referenceNode,
|
|
133
138
|
usePortal = true
|
|
134
139
|
} = this.props;
|
|
135
|
-
return
|
|
140
|
+
return /*#__PURE__*/_jsx__default["default"](DSOverlay__default["default"], {
|
|
136
141
|
isOpen: !destroyed,
|
|
137
|
-
onClickOutside,
|
|
138
|
-
usePortal
|
|
139
|
-
},
|
|
140
|
-
modifiers,
|
|
141
|
-
placement,
|
|
142
|
+
onClickOutside: onClickOutside,
|
|
143
|
+
usePortal: usePortal
|
|
144
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](reactPopper.Popper, {
|
|
145
|
+
modifiers: modifiers,
|
|
146
|
+
placement: placement,
|
|
142
147
|
referenceElement: referenceNode
|
|
143
|
-
}, this.renderContent));
|
|
148
|
+
}, void 0, this.renderContent));
|
|
144
149
|
}
|
|
150
|
+
|
|
145
151
|
}
|
|
146
|
-
PopperContent.defaultProps = {
|
|
147
|
-
|
|
148
|
-
|
|
152
|
+
PopperContent.defaultProps = {
|
|
153
|
+
onContentDestroyed: () => null
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
module.exports = PopperContent;
|