@elliemae/ds-popperjs 2.3.0-alpha.8 → 2.3.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.
Files changed (77) hide show
  1. package/cjs/PopoverArrow.js +54 -0
  2. package/cjs/PopoverContent.js +71 -0
  3. package/cjs/config/useConfigDSPopperjs.js +60 -0
  4. package/cjs/config/useConfiguredDefaultModifiers.js +70 -0
  5. package/cjs/config/useConfiguredDefaultProps.js +58 -0
  6. package/cjs/config/useConfiguredMergedProps.js +20 -0
  7. package/cjs/index.d.js +2 -0
  8. package/cjs/index.js +85 -0
  9. package/cjs/propTypes.js +85 -0
  10. package/cjs/styled.js +37 -0
  11. package/cjs/utils/hooks/useOnClickOutside.js +29 -0
  12. package/esm/PopoverArrow.js +45 -0
  13. package/esm/PopoverContent.js +62 -0
  14. package/esm/config/useConfigDSPopperjs.js +56 -0
  15. package/esm/config/useConfiguredDefaultModifiers.js +66 -0
  16. package/esm/config/useConfiguredDefaultProps.js +50 -0
  17. package/esm/config/useConfiguredMergedProps.js +16 -0
  18. package/esm/index.d.js +1 -0
  19. package/esm/index.js +74 -0
  20. package/esm/propTypes.js +81 -0
  21. package/esm/styled.js +27 -0
  22. package/esm/utils/hooks/useOnClickOutside.js +25 -0
  23. package/package.json +36 -38
  24. package/types/PopoverArrow.d.ts +8 -0
  25. package/types/PopoverContent.d.ts +3 -0
  26. package/types/config/useConfigDSPopperjs.d.ts +2 -0
  27. package/types/config/useConfiguredDefaultModifiers.d.ts +6 -0
  28. package/types/config/useConfiguredDefaultProps.d.ts +19 -0
  29. package/types/config/useConfiguredMergedProps.d.ts +19 -0
  30. package/types/index.d.ts +58 -0
  31. package/types/propTypes.d.ts +95 -0
  32. package/types/styled.d.ts +11 -0
  33. package/types/utils/hooks/useOnClickOutside.d.ts +4 -0
  34. package/dist/cjs/PopoverArrow.js +0 -91
  35. package/dist/cjs/PopoverArrow.js.map +0 -7
  36. package/dist/cjs/PopoverContent.js +0 -76
  37. package/dist/cjs/PopoverContent.js.map +0 -7
  38. package/dist/cjs/config/useConfigDSPopperjs.js +0 -69
  39. package/dist/cjs/config/useConfigDSPopperjs.js.map +0 -7
  40. package/dist/cjs/config/useConfiguredDefaultModifiers.js +0 -89
  41. package/dist/cjs/config/useConfiguredDefaultModifiers.js.map +0 -7
  42. package/dist/cjs/config/useConfiguredDefaultProps.js +0 -62
  43. package/dist/cjs/config/useConfiguredDefaultProps.js.map +0 -7
  44. package/dist/cjs/config/useConfiguredMergedProps.js +0 -40
  45. package/dist/cjs/config/useConfiguredMergedProps.js.map +0 -7
  46. package/dist/cjs/index.d.js +0 -27
  47. package/dist/cjs/index.d.js.map +0 -7
  48. package/dist/cjs/index.js +0 -101
  49. package/dist/cjs/index.js.map +0 -7
  50. package/dist/cjs/propTypes.js +0 -80
  51. package/dist/cjs/propTypes.js.map +0 -7
  52. package/dist/cjs/styled.js +0 -71
  53. package/dist/cjs/styled.js.map +0 -7
  54. package/dist/cjs/utils/hooks/useOnClickOutside.js +0 -51
  55. package/dist/cjs/utils/hooks/useOnClickOutside.js.map +0 -7
  56. package/dist/esm/PopoverArrow.js +0 -62
  57. package/dist/esm/PopoverArrow.js.map +0 -7
  58. package/dist/esm/PopoverContent.js +0 -47
  59. package/dist/esm/PopoverContent.js.map +0 -7
  60. package/dist/esm/config/useConfigDSPopperjs.js +0 -40
  61. package/dist/esm/config/useConfigDSPopperjs.js.map +0 -7
  62. package/dist/esm/config/useConfiguredDefaultModifiers.js +0 -60
  63. package/dist/esm/config/useConfiguredDefaultModifiers.js.map +0 -7
  64. package/dist/esm/config/useConfiguredDefaultProps.js +0 -33
  65. package/dist/esm/config/useConfiguredDefaultProps.js.map +0 -7
  66. package/dist/esm/config/useConfiguredMergedProps.js +0 -11
  67. package/dist/esm/config/useConfiguredMergedProps.js.map +0 -7
  68. package/dist/esm/index.d.js +0 -2
  69. package/dist/esm/index.d.js.map +0 -7
  70. package/dist/esm/index.js +0 -72
  71. package/dist/esm/index.js.map +0 -7
  72. package/dist/esm/propTypes.js +0 -51
  73. package/dist/esm/propTypes.js.map +0 -7
  74. package/dist/esm/styled.js +0 -42
  75. package/dist/esm/styled.js.map +0 -7
  76. package/dist/esm/utils/hooks/useOnClickOutside.js +0 -22
  77. package/dist/esm/utils/hooks/useOnClickOutside.js.map +0 -7
@@ -0,0 +1,62 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
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 };
@@ -0,0 +1,56 @@
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 };
@@ -0,0 +1,66 @@
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
9
+ const {
10
+ boundaryElement: explicitAppBoundaryElement,
11
+ withoutArrow: explicitAppWithoutArrow = false,
12
+ placementOrderPreference: explicitPlacementOrderPreference = ['top', 'bottom', 'left', 'right'],
13
+ customOffset: explictAppOffset = undefined
14
+ } = props; // to build default modifiers on top of it
15
+
16
+ const defaultModifiers = useMemo(() => {
17
+ const mod = [];
18
+ mod.push({
19
+ name: 'hide',
20
+ enabled: true
21
+ });
22
+ mod.push({
23
+ name: 'flip',
24
+ options: {
25
+ fallbackPlacements: explicitPlacementOrderPreference
26
+ }
27
+ }); // we apply an offset if the app defines one or if the app wants the arrow
28
+
29
+ if (!explicitAppWithoutArrow || explictAppOffset) {
30
+ const defaultOffset = explictAppOffset || [0, 14];
31
+ mod.push({
32
+ name: 'offset',
33
+ enabled: true,
34
+ options: {
35
+ offset: defaultOffset
36
+ }
37
+ });
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
+ });
55
+ return mod;
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;
61
+ return useMemo(() => ({
62
+ modifiers: explicitAppModifiers
63
+ }), [explicitAppModifiers]);
64
+ };
65
+
66
+ export { useConfiguredDefaultModifiers };
@@ -0,0 +1,50 @@
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
+
16
+ const emptyObj = {};
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
23
+ const staticDefaultProps = useMemo(() => ({
24
+ referenceElement: null,
25
+ showPopover: false,
26
+ closeContextMenu: noop,
27
+ onClickOutside: noop,
28
+ withoutPortal: false,
29
+ withoutArrow: false,
30
+ withoutAnimation: false,
31
+ animationDuration: 100,
32
+ portalDOMContainer: document.body,
33
+ startPlacementPreference: 'top',
34
+ placementOrderPreference: ['top', 'bottom', 'left', 'right'],
35
+ zIndex: 1,
36
+ extraPopperStyles: emptyObj
37
+ }), []);
38
+ const {
39
+ modifiers: configuredModifiers
40
+ } = useConfiguredDefaultModifiers({
41
+ props,
42
+ arrowElement
43
+ });
44
+ const defaultProps = useMemo(() => _objectSpread(_objectSpread({}, staticDefaultProps), {}, {
45
+ modifiers: configuredModifiers
46
+ }), [configuredModifiers, staticDefaultProps]);
47
+ return defaultProps;
48
+ };
49
+
50
+ export { useConfiguredDefaultProps };
@@ -0,0 +1,16 @@
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
+ });
13
+ return useMemoMergePropsWithDefault(props, defaultProps);
14
+ };
15
+
16
+ export { useConfiguredMergedProps };
package/esm/index.d.js ADDED
@@ -0,0 +1 @@
1
+
package/esm/index.js ADDED
@@ -0,0 +1,74 @@
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 => {
21
+ const {
22
+ props: {
23
+ showPopover,
24
+ withoutAnimation,
25
+ animationDuration,
26
+ withoutPortal,
27
+ withoutArrow,
28
+ portalDOMContainer,
29
+ zIndex,
30
+ extraPopperStyles
31
+ },
32
+ setPopperElement,
33
+ setArrowElement,
34
+ setIsAnimating,
35
+ popoverHelper,
36
+ isAnimating
37
+ } = useConfigDSPopperjs(props);
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),
48
+ popperAttributes: attributes.popper,
49
+ setArrowElement: setArrowElement,
50
+ arrowStyle: styles.arrow,
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
+
59
+ if (showPopover || isAnimating) {
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
+ });
66
+ }
67
+
68
+ return null;
69
+ };
70
+
71
+ const DSPopperJSWithSchema = describe(DSPopperJS).description('A dimsum custom styling wrapper on top of popperjs');
72
+ DSPopperJSWithSchema.propTypes = dspopperjsPropTypes;
73
+
74
+ export { DSPopperJS, DSPopperJSWithSchema, DSPopperJS as default };
@@ -0,0 +1,81 @@
1
+ import { PropTypes } from 'react-desc';
2
+
3
+ const dspopperjsPropTypes = {
4
+ /**
5
+ * React ref to popperjs referenceElement
6
+ */
7
+ referenceElement: PropTypes.element.description('popperjs DOM referenceElement').isRequired,
8
+
9
+ /**
10
+ * Wheter or not to show the popper content
11
+ */
12
+ showPopover: PropTypes.bool.description('whether or not to show the popper content').isRequired,
13
+
14
+ /**
15
+ * Callback to close the context menu, used for "on click outside",
16
+ * if not provided click outside will not trigger anything
17
+ */
18
+ closeContextMenu: PropTypes.func.description('Callback to close the context menu, used for "on click outside",' + ' if not provided click outside will not trigger anything').defaultValue('() => {}'),
19
+
20
+ /**
21
+ * Wheter or not the popper content should appear in a DOM portal or not
22
+ */
23
+ withoutPortal: PropTypes.bool.description('Whether or not the popper content should appear in a DOM portal or not').defaultValue(true),
24
+
25
+ /**
26
+ * Wheter or not the popper context menu should print the arrow
27
+ */
28
+ withoutArrow: PropTypes.bool.description('Whether or not the popper context menu should print the arrow').defaultValue(false),
29
+
30
+ /**
31
+ * Whether or not the popper context menu should be animated
32
+ */
33
+ withoutAnimation: PropTypes.bool.description('Whether or not the popper context menu should be animated').defaultValue(false),
34
+
35
+ /**
36
+ * Popper context menus Animation duration in ms
37
+ */
38
+ animationDuration: PropTypes.number.description('Popper context menus Animation duration in ms').defaultValue(100),
39
+
40
+ /**
41
+ * Bounding element to calculate upon, defaults to it is "clippingParents",
42
+ * which are the scrolling containers that may cause the element to be partially or fully cut off.
43
+ */
44
+ boundaryElement: 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),
45
+
46
+ /**
47
+ * When using portal, the container in which to append the DOM content, defaults to document body
48
+ */
49
+ portalDOMContainer: PropTypes.element.description('When using portal, the container in which to append the DOM content, defaults to document body').defaultValue(undefined),
50
+
51
+ /**
52
+ * start placement preferences, as per popperjs placement option
53
+ */
54
+ startPlacementPreference: 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'"),
55
+
56
+ /**
57
+ * Array of placement preferences, as per popperjs "flip" placement option
58
+ */
59
+ placementOrderPreference: PropTypes.arrayOf(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']"),
60
+
61
+ /**
62
+ * popperjs content z-index
63
+ */
64
+ zIndex: PropTypes.number.description('popperjs content z-index').defaultValue(1),
65
+
66
+ /**
67
+ * placement offset array
68
+ */
69
+ customOffset: PropTypes.arrayOf(PropTypes.number).description('placement offset array').defaultValue(1),
70
+
71
+ /**
72
+ * modifiers array for full-custom popper-js override
73
+ * https://popper.js.org/docs/v2/modifiers/
74
+ */
75
+ modifiers: PropTypes.array.description('modifiers array for full-custom popper-js override, https://popper.js.org/docs/v2/modifiers/').defaultValue(1),
76
+ extraPopperStyles: PropTypes.object.description('Extra object styles to attach to the popper element').defaultValue({}),
77
+ onClickOutside: PropTypes.func.description('Callback triggered when clicking outside the popper').defaultValue(() => null),
78
+ children: PropTypes.node.description('The content of the popper').defaultValue(undefined)
79
+ };
80
+
81
+ export { dspopperjsPropTypes };
package/esm/styled.js ADDED
@@ -0,0 +1,27 @@
1
+ import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
2
+ import styled from 'styled-components';
3
+ import { kfrm, css } from '@elliemae/ds-system';
4
+
5
+ var _templateObject, _templateObject2, _templateObject3;
6
+ const showAnimation = kfrm(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n from {\n opacity: 0;\n transform: scale(0.8);\n }\n\n to {\n opacity: 1;\n transform: scale(1);\n visibility: visible;\n }\n"])));
7
+ const hideAnimation = kfrm(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n from {\n opacity: 1;\n transform: scale(1);\n }\n\n to {\n opacity: 0;\n transform: scale(0.8);\n visibility: hidden;\n }\n"])));
8
+ const StyledPopoverContentWrapper = /*#__PURE__*/styled.div.withConfig({
9
+ componentId: "sc-1giz5kx-0"
10
+ })(["z-index:", ";"], _ref => {
11
+ let {
12
+ zIndex
13
+ } = _ref;
14
+ return zIndex;
15
+ });
16
+ const StyledAnimatedPopper = /*#__PURE__*/styled.div.withConfig({
17
+ componentId: "sc-1giz5kx-1"
18
+ })(["box-shadow:0 0 0 1px rgba(16,22,26,0.1),0 2px 4px rgba(16,22,26,0.2),0 8px 24px rgba(16,22,26,0.2);", ""], _ref2 => {
19
+ let {
20
+ showPopover,
21
+ animationDuration,
22
+ withoutAnimation
23
+ } = _ref2;
24
+ return !withoutAnimation && css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n animation: ", " ", "ms ease-in;\n "])), showPopover ? showAnimation : hideAnimation, animationDuration);
25
+ });
26
+
27
+ export { StyledAnimatedPopper, StyledPopoverContentWrapper };
@@ -0,0 +1,25 @@
1
+ import { useEffect } from 'react';
2
+
3
+ function useOnClickOutside(ref, cb) {
4
+ useEffect(() => {
5
+ const listener = event => {
6
+ var _ref$contains;
7
+
8
+ // Do nothing if clicking ref's element or descendent elements
9
+ if (!ref || ref !== null && ref !== void 0 && (_ref$contains = ref.contains) !== null && _ref$contains !== void 0 && _ref$contains.call(ref, event.target)) {
10
+ return;
11
+ }
12
+
13
+ cb(event);
14
+ };
15
+
16
+ document.addEventListener('mousedown', listener);
17
+ document.addEventListener('touchstart', listener);
18
+ return () => {
19
+ document.removeEventListener('mousedown', listener);
20
+ document.removeEventListener('touchstart', listener);
21
+ };
22
+ }, [ref, cb]);
23
+ }
24
+
25
+ export { useOnClickOutside };
package/package.json CHANGED
@@ -1,54 +1,51 @@
1
1
  {
2
2
  "name": "@elliemae/ds-popperjs",
3
- "version": "2.3.0-alpha.8",
3
+ "version": "2.3.0-next.2",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Popper JS Wrapper",
6
- "files": [
7
- "dist"
8
- ],
9
- "module": "./dist/esm/index.js",
10
- "main": "./dist/cjs/index.js",
11
- "types": "./dist/types/index.d.ts",
6
+ "module": "./esm/index.js",
7
+ "main": "./cjs/index.js",
8
+ "types": "./types/index.d.ts",
12
9
  "exports": {
13
10
  ".": {
14
- "import": "./dist/esm/index.js",
15
- "require": "./dist/cjs/index.js"
11
+ "import": "./esm/index.js",
12
+ "require": "./cjs/index.js"
16
13
  },
17
14
  "./utils/hooks/useOnClickOutside": {
18
- "import": "./dist/esm/utils/hooks/useOnClickOutside.js",
19
- "require": "./dist/cjs/utils/hooks/useOnClickOutside.js"
15
+ "import": "./esm/utils/hooks/useOnClickOutside.js",
16
+ "require": "./cjs/utils/hooks/useOnClickOutside.js"
20
17
  },
21
18
  "./styled": {
22
- "import": "./dist/esm/styled.js",
23
- "require": "./dist/cjs/styled.js"
19
+ "import": "./esm/styled.js",
20
+ "require": "./cjs/styled.js"
24
21
  },
25
22
  "./propTypes": {
26
- "import": "./dist/esm/propTypes.js",
27
- "require": "./dist/cjs/propTypes.js"
23
+ "import": "./esm/propTypes.js",
24
+ "require": "./cjs/propTypes.js"
28
25
  },
29
26
  "./PopoverContent": {
30
- "import": "./dist/esm/PopoverContent.js",
31
- "require": "./dist/cjs/PopoverContent.js"
27
+ "import": "./esm/PopoverContent.js",
28
+ "require": "./cjs/PopoverContent.js"
32
29
  },
33
30
  "./PopoverArrow": {
34
- "import": "./dist/esm/PopoverArrow.js",
35
- "require": "./dist/cjs/PopoverArrow.js"
31
+ "import": "./esm/PopoverArrow.js",
32
+ "require": "./cjs/PopoverArrow.js"
36
33
  },
37
34
  "./config/useConfiguredMergedProps": {
38
- "import": "./dist/esm/config/useConfiguredMergedProps.js",
39
- "require": "./dist/cjs/config/useConfiguredMergedProps.js"
35
+ "import": "./esm/config/useConfiguredMergedProps.js",
36
+ "require": "./cjs/config/useConfiguredMergedProps.js"
40
37
  },
41
38
  "./config/useConfiguredDefaultProps": {
42
- "import": "./dist/esm/config/useConfiguredDefaultProps.js",
43
- "require": "./dist/cjs/config/useConfiguredDefaultProps.js"
39
+ "import": "./esm/config/useConfiguredDefaultProps.js",
40
+ "require": "./cjs/config/useConfiguredDefaultProps.js"
44
41
  },
45
42
  "./config/useConfiguredDefaultModifiers": {
46
- "import": "./dist/esm/config/useConfiguredDefaultModifiers.js",
47
- "require": "./dist/cjs/config/useConfiguredDefaultModifiers.js"
43
+ "import": "./esm/config/useConfiguredDefaultModifiers.js",
44
+ "require": "./cjs/config/useConfiguredDefaultModifiers.js"
48
45
  },
49
46
  "./config/useConfigDSPopperjs": {
50
- "import": "./dist/esm/config/useConfigDSPopperjs.js",
51
- "require": "./dist/cjs/config/useConfigDSPopperjs.js"
47
+ "import": "./esm/config/useConfigDSPopperjs.js",
48
+ "require": "./cjs/config/useConfigDSPopperjs.js"
52
49
  }
53
50
  },
54
51
  "sideEffects": [
@@ -60,13 +57,19 @@
60
57
  "url": "https://git.elliemae.io/platform-ui/dimsum.git"
61
58
  },
62
59
  "engines": {
63
- "pnpm": ">=6",
64
- "node": ">=16"
60
+ "npm": ">=7",
61
+ "node": ">=14"
65
62
  },
66
63
  "author": "ICE MT",
64
+ "scripts": {
65
+ "dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
66
+ "prebuild": "exit 0",
67
+ "predev": "exit 0",
68
+ "build": "node ../../scripts/build/build.js"
69
+ },
67
70
  "dependencies": {
68
- "@elliemae/ds-props-helpers": "2.3.0-alpha.8",
69
- "@elliemae/ds-system": "2.3.0-alpha.8",
71
+ "@elliemae/ds-props-helpers": "2.3.0-next.2",
72
+ "@elliemae/ds-system": "2.3.0-next.1",
70
73
  "react-desc": "~4.1.3",
71
74
  "react-popper": "~2.2.5"
72
75
  },
@@ -80,12 +83,7 @@
80
83
  },
81
84
  "publishConfig": {
82
85
  "access": "public",
83
- "typeSafety": false
84
- },
85
- "scripts": {
86
- "dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
87
- "prebuild": "exit 0",
88
- "predev": "exit 0",
89
- "build": "node ../../scripts/build/build.js"
86
+ "directory": "dist",
87
+ "generateSubmodules": true
90
88
  }
91
89
  }
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ interface PopoverArrowT {
3
+ placement: string;
4
+ style: React.CSSProperties;
5
+ arrowElementRef: React.Dispatch<React.SetStateAction<HTMLDivElement>>;
6
+ }
7
+ export declare const PopoverArrow: ({ placement, style, arrowElementRef }: PopoverArrowT) => React.ReactElement;
8
+ export {};
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { PopoverContentPropsT } from './index.d';
3
+ export declare const PopoverContent: ({ setPopperElement, popperStyles, popperAttributes, children, showPopover, setArrowElement, setIsAnimating, arrowStyle, withoutArrow, withoutAnimation, animationDuration, zIndex, }: PopoverContentPropsT) => JSX.Element;
@@ -0,0 +1,2 @@
1
+ import type { useDSPopperjsPropsArgT, useDSPopperjsRT } from '../index.d';
2
+ export declare const useConfigDSPopperjs: (appProps: useDSPopperjsPropsArgT) => useDSPopperjsRT;
@@ -0,0 +1,6 @@
1
+ export declare const useConfiguredDefaultModifiers: ({ props, arrowElement }: {
2
+ props: any;
3
+ arrowElement: any;
4
+ }) => {
5
+ modifiers: any;
6
+ };
@@ -0,0 +1,19 @@
1
+ export declare const useConfiguredDefaultProps: ({ props, arrowElement }: {
2
+ props: any;
3
+ arrowElement: any;
4
+ }) => {
5
+ modifiers: any;
6
+ referenceElement: null;
7
+ showPopover: boolean;
8
+ closeContextMenu: () => void;
9
+ onClickOutside: () => void;
10
+ withoutPortal: boolean;
11
+ withoutArrow: boolean;
12
+ withoutAnimation: boolean;
13
+ animationDuration: number;
14
+ portalDOMContainer: HTMLElement;
15
+ startPlacementPreference: string;
16
+ placementOrderPreference: string[];
17
+ zIndex: number;
18
+ extraPopperStyles: {};
19
+ };
@@ -0,0 +1,19 @@
1
+ export declare const useConfiguredMergedProps: ({ props, arrowElement }: {
2
+ props: any;
3
+ arrowElement: any;
4
+ }) => {
5
+ modifiers: any;
6
+ referenceElement: null;
7
+ showPopover: boolean;
8
+ closeContextMenu: () => void;
9
+ onClickOutside: () => void;
10
+ withoutPortal: boolean;
11
+ withoutArrow: boolean;
12
+ withoutAnimation: boolean;
13
+ animationDuration: number;
14
+ portalDOMContainer: HTMLElement;
15
+ startPlacementPreference: string;
16
+ placementOrderPreference: string[];
17
+ zIndex: number;
18
+ extraPopperStyles: {};
19
+ };