@elliemae/ds-popperjs 2.3.1 → 3.0.0-alpha.3
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/dist/cjs/PopoverArrow.js +91 -0
- package/dist/cjs/PopoverArrow.js.map +7 -0
- package/dist/cjs/PopoverContent.js +89 -0
- package/dist/cjs/PopoverContent.js.map +7 -0
- package/dist/cjs/config/useConfigDSPopperjs.js +69 -0
- package/dist/cjs/config/useConfigDSPopperjs.js.map +7 -0
- package/dist/cjs/config/useConfiguredDefaultModifiers.js +89 -0
- package/dist/cjs/config/useConfiguredDefaultModifiers.js.map +7 -0
- package/dist/cjs/config/useConfiguredDefaultProps.js +79 -0
- package/dist/cjs/config/useConfiguredDefaultProps.js.map +7 -0
- package/dist/cjs/config/useConfiguredMergedProps.js +40 -0
- package/dist/cjs/config/useConfiguredMergedProps.js.map +7 -0
- package/dist/cjs/index.d.js +27 -0
- package/dist/cjs/index.d.js.map +7 -0
- package/dist/cjs/index.js +115 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/propTypes.js +80 -0
- package/dist/cjs/propTypes.js.map +7 -0
- package/dist/cjs/styled.js +71 -0
- package/dist/cjs/styled.js.map +7 -0
- package/dist/cjs/utils/hooks/useOnClickOutside.js +51 -0
- package/dist/cjs/utils/hooks/useOnClickOutside.js.map +7 -0
- package/dist/esm/PopoverArrow.js +62 -0
- package/dist/esm/PopoverArrow.js.map +7 -0
- package/dist/esm/PopoverContent.js +62 -0
- package/dist/esm/PopoverContent.js.map +7 -0
- package/dist/esm/config/useConfigDSPopperjs.js +40 -0
- package/dist/esm/config/useConfigDSPopperjs.js.map +7 -0
- package/dist/esm/config/useConfiguredDefaultModifiers.js +60 -0
- package/dist/esm/config/useConfiguredDefaultModifiers.js.map +7 -0
- package/dist/esm/config/useConfiguredDefaultProps.js +52 -0
- package/dist/esm/config/useConfiguredDefaultProps.js.map +7 -0
- package/dist/esm/config/useConfiguredMergedProps.js +11 -0
- package/dist/esm/config/useConfiguredMergedProps.js.map +7 -0
- package/dist/esm/index.d.js +2 -0
- package/dist/esm/index.d.js.map +7 -0
- package/dist/esm/index.js +88 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/propTypes.js +51 -0
- package/dist/esm/propTypes.js.map +7 -0
- package/dist/esm/styled.js +42 -0
- package/dist/esm/styled.js.map +7 -0
- package/dist/esm/utils/hooks/useOnClickOutside.js +22 -0
- package/dist/esm/utils/hooks/useOnClickOutside.js.map +7 -0
- package/package.json +44 -35
- package/cjs/PopoverArrow.js +0 -54
- package/cjs/PopoverContent.js +0 -71
- package/cjs/config/useConfigDSPopperjs.js +0 -60
- package/cjs/config/useConfiguredDefaultModifiers.js +0 -70
- package/cjs/config/useConfiguredDefaultProps.js +0 -58
- package/cjs/config/useConfiguredMergedProps.js +0 -20
- package/cjs/index.d.js +0 -2
- package/cjs/index.js +0 -85
- package/cjs/propTypes.js +0 -85
- package/cjs/styled.js +0 -37
- package/cjs/utils/hooks/useOnClickOutside.js +0 -29
- package/esm/PopoverArrow.js +0 -45
- package/esm/PopoverContent.js +0 -62
- package/esm/config/useConfigDSPopperjs.js +0 -56
- package/esm/config/useConfiguredDefaultModifiers.js +0 -66
- package/esm/config/useConfiguredDefaultProps.js +0 -50
- package/esm/config/useConfiguredMergedProps.js +0 -16
- package/esm/index.d.js +0 -1
- package/esm/index.js +0 -74
- package/esm/propTypes.js +0 -81
- package/esm/styled.js +0 -27
- package/esm/utils/hooks/useOnClickOutside.js +0 -25
- package/types/PopoverArrow.d.ts +0 -8
- package/types/PopoverContent.d.ts +0 -3
- package/types/config/useConfigDSPopperjs.d.ts +0 -2
- package/types/config/useConfiguredDefaultModifiers.d.ts +0 -6
- package/types/config/useConfiguredDefaultProps.d.ts +0 -19
- package/types/config/useConfiguredMergedProps.d.ts +0 -19
- package/types/index.d.ts +0 -58
- package/types/propTypes.d.ts +0 -95
- package/types/styled.d.ts +0 -11
- package/types/utils/hooks/useOnClickOutside.d.ts +0 -4
|
@@ -1,60 +0,0 @@
|
|
|
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(() => {
|
|
36
|
-
if (showPopover && !withoutAnimation) {
|
|
37
|
-
setIsAnimating(true);
|
|
38
|
-
}
|
|
39
|
-
}, [showPopover, withoutAnimation]);
|
|
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))) {
|
|
44
|
-
onClickOutside(e);
|
|
45
|
-
closeContextMenu();
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
return react.useMemo(() => ({
|
|
49
|
-
props,
|
|
50
|
-
popperElement,
|
|
51
|
-
setPopperElement,
|
|
52
|
-
arrowElement,
|
|
53
|
-
setArrowElement,
|
|
54
|
-
popoverHelper,
|
|
55
|
-
isAnimating,
|
|
56
|
-
setIsAnimating
|
|
57
|
-
}), [arrowElement, popoverHelper, popperElement, isAnimating, props]);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
exports.useConfigDSPopperjs = useConfigDSPopperjs;
|
|
@@ -1,70 +0,0 @@
|
|
|
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
|
|
13
|
-
const {
|
|
14
|
-
boundaryElement: explicitAppBoundaryElement,
|
|
15
|
-
withoutArrow: explicitAppWithoutArrow = false,
|
|
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(() => {
|
|
21
|
-
const mod = [];
|
|
22
|
-
mod.push({
|
|
23
|
-
name: 'hide',
|
|
24
|
-
enabled: true
|
|
25
|
-
});
|
|
26
|
-
mod.push({
|
|
27
|
-
name: 'flip',
|
|
28
|
-
options: {
|
|
29
|
-
fallbackPlacements: explicitPlacementOrderPreference
|
|
30
|
-
}
|
|
31
|
-
}); // we apply an offset if the app defines one or if the app wants the arrow
|
|
32
|
-
|
|
33
|
-
if (!explicitAppWithoutArrow || explictAppOffset) {
|
|
34
|
-
const defaultOffset = explictAppOffset || [0, 14];
|
|
35
|
-
mod.push({
|
|
36
|
-
name: 'offset',
|
|
37
|
-
enabled: true,
|
|
38
|
-
options: {
|
|
39
|
-
offset: defaultOffset
|
|
40
|
-
}
|
|
41
|
-
});
|
|
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
|
-
});
|
|
59
|
-
return mod;
|
|
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(() => ({
|
|
66
|
-
modifiers: explicitAppModifiers
|
|
67
|
-
}), [explicitAppModifiers]);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
exports.useConfiguredDefaultModifiers = useConfiguredDefaultModifiers;
|
|
@@ -1,58 +0,0 @@
|
|
|
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
|
-
|
|
24
|
-
const emptyObj = {};
|
|
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(() => ({
|
|
32
|
-
referenceElement: null,
|
|
33
|
-
showPopover: false,
|
|
34
|
-
closeContextMenu: noop,
|
|
35
|
-
onClickOutside: noop,
|
|
36
|
-
withoutPortal: false,
|
|
37
|
-
withoutArrow: false,
|
|
38
|
-
withoutAnimation: false,
|
|
39
|
-
animationDuration: 100,
|
|
40
|
-
portalDOMContainer: document.body,
|
|
41
|
-
startPlacementPreference: 'top',
|
|
42
|
-
placementOrderPreference: ['top', 'bottom', 'left', 'right'],
|
|
43
|
-
zIndex: 1,
|
|
44
|
-
extraPopperStyles: emptyObj
|
|
45
|
-
}), []);
|
|
46
|
-
const {
|
|
47
|
-
modifiers: configuredModifiers
|
|
48
|
-
} = useConfiguredDefaultModifiers.useConfiguredDefaultModifiers({
|
|
49
|
-
props,
|
|
50
|
-
arrowElement
|
|
51
|
-
});
|
|
52
|
-
const defaultProps = react.useMemo(() => _objectSpread(_objectSpread({}, staticDefaultProps), {}, {
|
|
53
|
-
modifiers: configuredModifiers
|
|
54
|
-
}), [configuredModifiers, staticDefaultProps]);
|
|
55
|
-
return defaultProps;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
exports.useConfiguredDefaultProps = useConfiguredDefaultProps;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var dsPropsHelpers = require('@elliemae/ds-props-helpers');
|
|
6
|
-
var useConfiguredDefaultProps = require('./useConfiguredDefaultProps.js');
|
|
7
|
-
|
|
8
|
-
const useConfiguredMergedProps = _ref => {
|
|
9
|
-
let {
|
|
10
|
-
props,
|
|
11
|
-
arrowElement
|
|
12
|
-
} = _ref;
|
|
13
|
-
const defaultProps = useConfiguredDefaultProps.useConfiguredDefaultProps({
|
|
14
|
-
props,
|
|
15
|
-
arrowElement
|
|
16
|
-
});
|
|
17
|
-
return dsPropsHelpers.useMemoMergePropsWithDefault(props, defaultProps);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
exports.useConfiguredMergedProps = useConfiguredMergedProps;
|
package/cjs/index.d.js
DELETED
package/cjs/index.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
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 _jsx = require('@babel/runtime/helpers/jsx');
|
|
11
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
12
|
-
var react = require('react');
|
|
13
|
-
var reactDom = require('react-dom');
|
|
14
|
-
var reactDesc = require('react-desc');
|
|
15
|
-
var propTypes = require('./propTypes.js');
|
|
16
|
-
var PopoverContent = require('./PopoverContent.js');
|
|
17
|
-
var useConfigDSPopperjs = require('./config/useConfigDSPopperjs.js');
|
|
18
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
19
|
-
|
|
20
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
|
-
|
|
22
|
-
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
23
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
24
|
-
|
|
25
|
-
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; }
|
|
26
|
-
|
|
27
|
-
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; }
|
|
28
|
-
|
|
29
|
-
const DSPopperJS = props => {
|
|
30
|
-
const {
|
|
31
|
-
props: {
|
|
32
|
-
showPopover,
|
|
33
|
-
withoutAnimation,
|
|
34
|
-
animationDuration,
|
|
35
|
-
withoutPortal,
|
|
36
|
-
withoutArrow,
|
|
37
|
-
portalDOMContainer,
|
|
38
|
-
zIndex,
|
|
39
|
-
extraPopperStyles
|
|
40
|
-
},
|
|
41
|
-
setPopperElement,
|
|
42
|
-
setArrowElement,
|
|
43
|
-
setIsAnimating,
|
|
44
|
-
popoverHelper,
|
|
45
|
-
isAnimating
|
|
46
|
-
} = useConfigDSPopperjs.useConfigDSPopperjs(props);
|
|
47
|
-
const {
|
|
48
|
-
children
|
|
49
|
-
} = props;
|
|
50
|
-
const {
|
|
51
|
-
styles,
|
|
52
|
-
attributes
|
|
53
|
-
} = popoverHelper;
|
|
54
|
-
const contentJSX = react.useMemo(() => /*#__PURE__*/_jsx__default["default"](PopoverContent.PopoverContent, {
|
|
55
|
-
setPopperElement: setPopperElement,
|
|
56
|
-
popperStyles: _objectSpread(_objectSpread({}, styles.popper), extraPopperStyles),
|
|
57
|
-
popperAttributes: attributes.popper,
|
|
58
|
-
setArrowElement: setArrowElement,
|
|
59
|
-
arrowStyle: styles.arrow,
|
|
60
|
-
withoutArrow: withoutArrow,
|
|
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]);
|
|
67
|
-
|
|
68
|
-
if (showPopover || isAnimating) {
|
|
69
|
-
if (withoutPortal === true) return contentJSX;
|
|
70
|
-
if (withoutPortal === false) return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
71
|
-
children: /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
72
|
-
children: contentJSX
|
|
73
|
-
}), portalDOMContainer)
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return null;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const DSPopperJSWithSchema = reactDesc.describe(DSPopperJS).description('A dimsum custom styling wrapper on top of popperjs');
|
|
81
|
-
DSPopperJSWithSchema.propTypes = propTypes.dspopperjsPropTypes;
|
|
82
|
-
|
|
83
|
-
exports.DSPopperJS = DSPopperJS;
|
|
84
|
-
exports.DSPopperJSWithSchema = DSPopperJSWithSchema;
|
|
85
|
-
exports["default"] = DSPopperJS;
|
package/cjs/propTypes.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var reactDesc = require('react-desc');
|
|
6
|
-
|
|
7
|
-
const dspopperjsPropTypes = {
|
|
8
|
-
/**
|
|
9
|
-
* React ref to popperjs referenceElement
|
|
10
|
-
*/
|
|
11
|
-
referenceElement: reactDesc.PropTypes.element.description('popperjs DOM referenceElement').isRequired,
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Wheter or not to show the popper content
|
|
15
|
-
*/
|
|
16
|
-
showPopover: reactDesc.PropTypes.bool.description('whether or not to show the popper content').isRequired,
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Callback to close the context menu, used for "on click outside",
|
|
20
|
-
* if not provided click outside will not trigger anything
|
|
21
|
-
*/
|
|
22
|
-
closeContextMenu: reactDesc.PropTypes.func.description('Callback to close the context menu, used for "on click outside",' + ' if not provided click outside will not trigger anything').defaultValue('() => {}'),
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Wheter or not the popper content should appear in a DOM portal or not
|
|
26
|
-
*/
|
|
27
|
-
withoutPortal: reactDesc.PropTypes.bool.description('Whether or not the popper content should appear in a DOM portal or not').defaultValue(true),
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Wheter or not the popper context menu should print the arrow
|
|
31
|
-
*/
|
|
32
|
-
withoutArrow: reactDesc.PropTypes.bool.description('Whether or not the popper context menu should print the arrow').defaultValue(false),
|
|
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
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Bounding element to calculate upon, defaults to it is "clippingParents",
|
|
46
|
-
* which are the scrolling containers that may cause the element to be partially or fully cut off.
|
|
47
|
-
*/
|
|
48
|
-
boundaryElement: reactDesc.PropTypes.element.description('Bounding element to calculate upon, defaults to "clippingParents",' + 'which are the scrolling containers that may cause element to be partially or fully cut off').defaultValue(undefined),
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* When using portal, the container in which to append the DOM content, defaults to document body
|
|
52
|
-
*/
|
|
53
|
-
portalDOMContainer: reactDesc.PropTypes.element.description('When using portal, the container in which to append the DOM content, defaults to document body').defaultValue(undefined),
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* start placement preferences, as per popperjs placement option
|
|
57
|
-
*/
|
|
58
|
-
startPlacementPreference: reactDesc.PropTypes.oneOf(['top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start']).description('start placement preferences, as per popperjs placement option').defaultValue("'top'"),
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Array of placement preferences, as per popperjs "flip" placement option
|
|
62
|
-
*/
|
|
63
|
-
placementOrderPreference: reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.oneOf(['top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'])).description('Array of placement preferences, as per popperjs "flip" placement option').defaultValue("['top', 'bottom', 'left', 'right']"),
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* popperjs content z-index
|
|
67
|
-
*/
|
|
68
|
-
zIndex: reactDesc.PropTypes.number.description('popperjs content z-index').defaultValue(1),
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* placement offset array
|
|
72
|
-
*/
|
|
73
|
-
customOffset: reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.number).description('placement offset array').defaultValue(1),
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* modifiers array for full-custom popper-js override
|
|
77
|
-
* https://popper.js.org/docs/v2/modifiers/
|
|
78
|
-
*/
|
|
79
|
-
modifiers: reactDesc.PropTypes.array.description('modifiers array for full-custom popper-js override, https://popper.js.org/docs/v2/modifiers/').defaultValue(1),
|
|
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)
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
exports.dspopperjsPropTypes = dspopperjsPropTypes;
|
package/cjs/styled.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var react = require('react');
|
|
6
|
-
|
|
7
|
-
function useOnClickOutside(ref, cb) {
|
|
8
|
-
react.useEffect(() => {
|
|
9
|
-
const listener = event => {
|
|
10
|
-
var _ref$contains;
|
|
11
|
-
|
|
12
|
-
// Do nothing if clicking ref's element or descendent elements
|
|
13
|
-
if (!ref || ref !== null && ref !== void 0 && (_ref$contains = ref.contains) !== null && _ref$contains !== void 0 && _ref$contains.call(ref, event.target)) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
cb(event);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
document.addEventListener('mousedown', listener);
|
|
21
|
-
document.addEventListener('touchstart', listener);
|
|
22
|
-
return () => {
|
|
23
|
-
document.removeEventListener('mousedown', listener);
|
|
24
|
-
document.removeEventListener('touchstart', listener);
|
|
25
|
-
};
|
|
26
|
-
}, [ref, cb]);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
exports.useOnClickOutside = useOnClickOutside;
|
package/esm/PopoverArrow.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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;
|
|
7
|
-
const arrowWidth = 18;
|
|
8
|
-
const arrowHeight = 18;
|
|
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");
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export { PopoverArrow };
|
package/esm/PopoverContent.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
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;
|
|
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
|
-
};
|
|
61
|
-
|
|
62
|
-
export { PopoverContent };
|
|
@@ -1,56 +0,0 @@
|
|
|
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 => {
|
|
8
|
-
const [popperElement, setPopperElement] = useState(null);
|
|
9
|
-
const [arrowElement, setArrowElement] = useState(null);
|
|
10
|
-
const [isAnimating, setIsAnimating] = useState(false);
|
|
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]);
|
|
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]);
|
|
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))) {
|
|
40
|
-
onClickOutside(e);
|
|
41
|
-
closeContextMenu();
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return useMemo(() => ({
|
|
45
|
-
props,
|
|
46
|
-
popperElement,
|
|
47
|
-
setPopperElement,
|
|
48
|
-
arrowElement,
|
|
49
|
-
setArrowElement,
|
|
50
|
-
popoverHelper,
|
|
51
|
-
isAnimating,
|
|
52
|
-
setIsAnimating
|
|
53
|
-
}), [arrowElement, popoverHelper, popperElement, isAnimating, props]);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export { useConfigDSPopperjs };
|