@elliemae/ds-popperjs 2.2.0-alpha.1 → 2.2.0-alpha.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 (45) hide show
  1. package/cjs/PopoverArrow.js +88 -51
  2. package/cjs/PopoverArrow.js.map +7 -0
  3. package/cjs/PopoverContent.js +70 -65
  4. package/cjs/PopoverContent.js.map +7 -0
  5. package/cjs/config/useConfigDSPopperjs.js +51 -42
  6. package/cjs/config/useConfigDSPopperjs.js.map +7 -0
  7. package/cjs/config/useConfiguredDefaultModifiers.js +69 -50
  8. package/cjs/config/useConfiguredDefaultModifiers.js.map +7 -0
  9. package/cjs/config/useConfiguredDefaultProps.js +44 -40
  10. package/cjs/config/useConfiguredDefaultProps.js.map +7 -0
  11. package/cjs/config/useConfiguredMergedProps.js +39 -19
  12. package/cjs/config/useConfiguredMergedProps.js.map +7 -0
  13. package/cjs/index.d.js +27 -2
  14. package/cjs/index.d.js.map +7 -0
  15. package/cjs/index.js +79 -63
  16. package/cjs/index.js.map +7 -0
  17. package/cjs/propTypes.js +78 -83
  18. package/cjs/propTypes.js.map +7 -0
  19. package/cjs/styled.js +68 -34
  20. package/cjs/styled.js.map +7 -0
  21. package/cjs/utils/hooks/useOnClickOutside.js +42 -20
  22. package/cjs/utils/hooks/useOnClickOutside.js.map +7 -0
  23. package/esm/PopoverArrow.js +59 -42
  24. package/esm/PopoverArrow.js.map +7 -0
  25. package/esm/PopoverContent.js +40 -55
  26. package/esm/PopoverContent.js.map +7 -0
  27. package/esm/config/useConfigDSPopperjs.js +16 -32
  28. package/esm/config/useConfigDSPopperjs.js.map +7 -0
  29. package/esm/config/useConfiguredDefaultModifiers.js +38 -44
  30. package/esm/config/useConfiguredDefaultModifiers.js.map +7 -0
  31. package/esm/config/useConfiguredDefaultProps.js +14 -31
  32. package/esm/config/useConfiguredDefaultProps.js.map +7 -0
  33. package/esm/config/useConfiguredMergedProps.js +9 -14
  34. package/esm/config/useConfiguredMergedProps.js.map +7 -0
  35. package/esm/index.d.js +2 -1
  36. package/esm/index.d.js.map +7 -0
  37. package/esm/index.js +48 -50
  38. package/esm/index.js.map +7 -0
  39. package/esm/propTypes.js +49 -79
  40. package/esm/propTypes.js.map +7 -0
  41. package/esm/styled.js +40 -25
  42. package/esm/styled.js.map +7 -0
  43. package/esm/utils/hooks/useOnClickOutside.js +12 -15
  44. package/esm/utils/hooks/useOnClickOutside.js.map +7 -0
  45. package/package.json +3 -3
@@ -1,25 +1,10 @@
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
-
1
+ import * as React from "react";
2
+ import { useMemo } from "react";
3
+ import { useConfiguredDefaultModifiers } from "./useConfiguredDefaultModifiers";
4
+ const noop = () => {
5
+ };
16
6
  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
7
+ const useConfiguredDefaultProps = ({ props, arrowElement }) => {
23
8
  const staticDefaultProps = useMemo(() => ({
24
9
  referenceElement: null,
25
10
  showPopover: false,
@@ -30,21 +15,19 @@ const useConfiguredDefaultProps = _ref => {
30
15
  withoutAnimation: false,
31
16
  animationDuration: 100,
32
17
  portalDOMContainer: document.body,
33
- startPlacementPreference: 'top',
34
- placementOrderPreference: ['top', 'bottom', 'left', 'right'],
18
+ startPlacementPreference: "top",
19
+ placementOrderPreference: ["top", "bottom", "left", "right"],
35
20
  zIndex: 1,
36
21
  extraPopperStyles: emptyObj
37
22
  }), []);
38
- const {
39
- modifiers: configuredModifiers
40
- } = useConfiguredDefaultModifiers({
23
+ const { modifiers: configuredModifiers } = useConfiguredDefaultModifiers({
41
24
  props,
42
25
  arrowElement
43
26
  });
44
- const defaultProps = useMemo(() => _objectSpread(_objectSpread({}, staticDefaultProps), {}, {
45
- modifiers: configuredModifiers
46
- }), [configuredModifiers, staticDefaultProps]);
27
+ const defaultProps = useMemo(() => ({ ...staticDefaultProps, modifiers: configuredModifiers }), [configuredModifiers, staticDefaultProps]);
47
28
  return defaultProps;
48
29
  };
49
-
50
- export { useConfiguredDefaultProps };
30
+ export {
31
+ useConfiguredDefaultProps
32
+ };
33
+ //# sourceMappingURL=useConfiguredDefaultProps.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useConfiguredDefaultProps.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useMemo } from 'react';\nimport { useConfiguredDefaultModifiers } from './useConfiguredDefaultModifiers';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = () => {};\n\nconst emptyObj = {};\n\nexport const useConfiguredDefaultProps = ({ props, arrowElement }) => {\n // don't move this out of the hook or `document.body` will explode\n const staticDefaultProps = useMemo(\n () => ({\n referenceElement: null,\n showPopover: false,\n closeContextMenu: noop,\n onClickOutside: noop,\n withoutPortal: false,\n withoutArrow: false,\n withoutAnimation: false,\n animationDuration: 100,\n portalDOMContainer: document.body,\n startPlacementPreference: 'top',\n placementOrderPreference: ['top', 'bottom', 'left', 'right'],\n zIndex: 1,\n extraPopperStyles: emptyObj,\n }),\n [],\n );\n const { modifiers: configuredModifiers } = useConfiguredDefaultModifiers({\n props,\n arrowElement,\n });\n\n const defaultProps = useMemo(\n () => ({ ...staticDefaultProps, modifiers: configuredModifiers }),\n [configuredModifiers, staticDefaultProps],\n );\n\n return defaultProps;\n};\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AAGA,MAAM,OAAO,MAAM;AAAA;AAEnB,MAAM,WAAW;AAEV,MAAM,4BAA4B,CAAC,EAAE,OAAO,mBAAmB;AAEpE,QAAM,qBAAqB,QACzB,MAAO;AAAA,IACL,kBAAkB;AAAA,IAClB,aAAa;AAAA,IACb,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,cAAc;AAAA,IACd,kBAAkB;AAAA,IAClB,mBAAmB;AAAA,IACnB,oBAAoB,SAAS;AAAA,IAC7B,0BAA0B;AAAA,IAC1B,0BAA0B,CAAC,OAAO,UAAU,QAAQ;AAAA,IACpD,QAAQ;AAAA,IACR,mBAAmB;AAAA,MAErB;AAEF,QAAM,EAAE,WAAW,wBAAwB,8BAA8B;AAAA,IACvE;AAAA,IACA;AAAA;AAGF,QAAM,eAAe,QACnB,MAAO,MAAK,oBAAoB,WAAW,wBAC3C,CAAC,qBAAqB;AAGxB,SAAO;AAAA;",
6
+ "names": []
7
+ }
@@ -1,16 +1,11 @@
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
- });
1
+ import * as React from "react";
2
+ import { useMemoMergePropsWithDefault } from "@elliemae/ds-props-helpers";
3
+ import { useConfiguredDefaultProps } from "./useConfiguredDefaultProps";
4
+ const useConfiguredMergedProps = ({ props, arrowElement }) => {
5
+ const defaultProps = useConfiguredDefaultProps({ props, arrowElement });
13
6
  return useMemoMergePropsWithDefault(props, defaultProps);
14
7
  };
15
-
16
- export { useConfiguredMergedProps };
8
+ export {
9
+ useConfiguredMergedProps
10
+ };
11
+ //# sourceMappingURL=useConfiguredMergedProps.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useConfiguredMergedProps.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport { useConfiguredDefaultProps } from './useConfiguredDefaultProps';\n\nexport const useConfiguredMergedProps = ({ props, arrowElement }) => {\n const defaultProps = useConfiguredDefaultProps({ props, arrowElement });\n\n return useMemoMergePropsWithDefault(props, defaultProps);\n};\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AAEO,MAAM,2BAA2B,CAAC,EAAE,OAAO,mBAAmB;AACnE,QAAM,eAAe,0BAA0B,EAAE,OAAO;AAExD,SAAO,6BAA6B,OAAO;AAAA;",
6
+ "names": []
7
+ }
package/esm/index.d.js CHANGED
@@ -1 +1,2 @@
1
-
1
+ import * as React from "react";
2
+ //# sourceMappingURL=index.d.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": "AAAA;",
6
+ "names": []
7
+ }
package/esm/index.js CHANGED
@@ -1,23 +1,11 @@
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 => {
1
+ import * as React from "react";
2
+ import React2, { useMemo } from "react";
3
+ import { createPortal } from "react-dom";
4
+ import { describe } from "react-desc";
5
+ import { dspopperjsPropTypes } from "./propTypes";
6
+ import { PopoverContent } from "./PopoverContent";
7
+ import { useConfigDSPopperjs } from "./config/useConfigDSPopperjs";
8
+ const DSPopperJS = (props) => {
21
9
  const {
22
10
  props: {
23
11
  showPopover,
@@ -35,40 +23,50 @@ const DSPopperJS = props => {
35
23
  popoverHelper,
36
24
  isAnimating
37
25
  } = 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),
26
+ const { children } = props;
27
+ const { styles, attributes } = popoverHelper;
28
+ const contentJSX = useMemo(() => /* @__PURE__ */ React2.createElement(PopoverContent, {
29
+ setPopperElement,
30
+ popperStyles: { ...styles.popper, ...extraPopperStyles },
48
31
  popperAttributes: attributes.popper,
49
- setArrowElement: setArrowElement,
32
+ setArrowElement,
50
33
  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
-
34
+ withoutArrow,
35
+ withoutAnimation,
36
+ animationDuration,
37
+ zIndex,
38
+ showPopover,
39
+ setIsAnimating
40
+ }, children), [
41
+ attributes.popper,
42
+ children,
43
+ setIsAnimating,
44
+ showPopover,
45
+ extraPopperStyles,
46
+ setArrowElement,
47
+ setPopperElement,
48
+ styles.arrow,
49
+ styles.popper,
50
+ withoutArrow,
51
+ withoutAnimation,
52
+ animationDuration,
53
+ zIndex
54
+ ]);
59
55
  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
- });
56
+ if (withoutPortal === true)
57
+ return contentJSX;
58
+ if (withoutPortal === false)
59
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, createPortal(/* @__PURE__ */ React2.createElement(React2.Fragment, null, contentJSX), portalDOMContainer));
66
60
  }
67
-
68
61
  return null;
69
62
  };
70
-
71
- const DSPopperJSWithSchema = describe(DSPopperJS).description('A dimsum custom styling wrapper on top of popperjs');
63
+ DSPopperJS.propTypes = dspopperjsPropTypes;
64
+ const DSPopperJSWithSchema = describe(DSPopperJS).description("A dimsum custom styling wrapper on top of popperjs");
72
65
  DSPopperJSWithSchema.propTypes = dspopperjsPropTypes;
73
-
74
- export { DSPopperJS, DSPopperJSWithSchema, DSPopperJS as default };
66
+ var src_default = DSPopperJS;
67
+ export {
68
+ DSPopperJS,
69
+ DSPopperJSWithSchema,
70
+ src_default as default
71
+ };
72
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useMemo } from 'react';\nimport { createPortal } from 'react-dom';\nimport { describe } from 'react-desc';\nimport { dspopperjsPropTypes } from './propTypes';\nimport { PopoverContent } from './PopoverContent';\nimport { useConfigDSPopperjs } from './config/useConfigDSPopperjs';\nimport type { DSDSPopperjsPropsT } from './index.d';\n\nconst DSPopperJS = (props: DSDSPopperjsPropsT): JSX.Element => {\n const {\n props: {\n showPopover,\n withoutAnimation,\n animationDuration,\n withoutPortal,\n withoutArrow,\n portalDOMContainer,\n zIndex,\n extraPopperStyles,\n },\n setPopperElement,\n setArrowElement,\n setIsAnimating,\n popoverHelper,\n isAnimating,\n } = useConfigDSPopperjs(props);\n const { children } = props;\n const { styles, attributes } = popoverHelper;\n const contentJSX = useMemo(\n () => (\n <PopoverContent\n setPopperElement={setPopperElement}\n popperStyles={{ ...styles.popper, ...extraPopperStyles }}\n popperAttributes={attributes.popper}\n setArrowElement={setArrowElement}\n arrowStyle={styles.arrow}\n withoutArrow={withoutArrow}\n withoutAnimation={withoutAnimation}\n animationDuration={animationDuration}\n zIndex={zIndex}\n showPopover={showPopover}\n setIsAnimating={setIsAnimating}\n >\n {children}\n </PopoverContent>\n ),\n [\n attributes.popper,\n children,\n setIsAnimating,\n showPopover,\n extraPopperStyles,\n setArrowElement,\n setPopperElement,\n styles.arrow,\n styles.popper,\n withoutArrow,\n withoutAnimation,\n animationDuration,\n zIndex,\n ],\n );\n if (showPopover || isAnimating) {\n if (withoutPortal === true) return contentJSX;\n if (withoutPortal === false) return <>{createPortal(<>{contentJSX}</>, portalDOMContainer)}</>;\n }\n return null;\n};\n\nDSPopperJS.propTypes = dspopperjsPropTypes;\n\nconst DSPopperJSWithSchema = describe(DSPopperJS).description('A dimsum custom styling wrapper on top of popperjs');\nDSPopperJSWithSchema.propTypes = dspopperjsPropTypes;\n\nexport { DSPopperJS, DSPopperJSWithSchema };\nexport default DSPopperJS;\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AAGA,MAAM,aAAa,CAAC,UAA2C;AAC7D,QAAM;AAAA,IACJ,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,IAEF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,oBAAoB;AACxB,QAAM,EAAE,aAAa;AACrB,QAAM,EAAE,QAAQ,eAAe;AAC/B,QAAM,aAAa,QACjB,MACE,qCAAC,gBAAD;AAAA,IACE;AAAA,IACA,cAAc,KAAK,OAAO,WAAW;AAAA,IACrC,kBAAkB,WAAW;AAAA,IAC7B;AAAA,IACA,YAAY,OAAO;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KAEC,WAGL;AAAA,IACE,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGJ,MAAI,eAAe,aAAa;AAC9B,QAAI,kBAAkB;AAAM,aAAO;AACnC,QAAI,kBAAkB;AAAO,aAAO,4DAAG,aAAa,4DAAG,aAAgB;AAAA;AAEzE,SAAO;AAAA;AAGT,WAAW,YAAY;AAEvB,MAAM,uBAAuB,SAAS,YAAY,YAAY;AAC9D,qBAAqB,YAAY;AAGjC,IAAO,cAAQ;",
6
+ "names": []
7
+ }
package/esm/propTypes.js CHANGED
@@ -1,81 +1,51 @@
1
- import { PropTypes } from 'react-desc';
2
-
1
+ import * as React from "react";
2
+ import { PropTypes } from "react-desc";
3
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)
4
+ referenceElement: PropTypes.element.description("popperjs DOM referenceElement").isRequired,
5
+ showPopover: PropTypes.bool.description("whether or not to show the popper content").isRequired,
6
+ 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("() => {}"),
7
+ withoutPortal: PropTypes.bool.description("Whether or not the popper content should appear in a DOM portal or not").defaultValue(true),
8
+ withoutArrow: PropTypes.bool.description("Whether or not the popper context menu should print the arrow").defaultValue(false),
9
+ withoutAnimation: PropTypes.bool.description("Whether or not the popper context menu should be animated").defaultValue(false),
10
+ animationDuration: PropTypes.number.description("Popper context menus Animation duration in ms").defaultValue(100),
11
+ 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(void 0),
12
+ portalDOMContainer: PropTypes.element.description("When using portal, the container in which to append the DOM content, defaults to document body").defaultValue(void 0),
13
+ startPlacementPreference: PropTypes.oneOf([
14
+ "top-start",
15
+ "top",
16
+ "top-end",
17
+ "right-start",
18
+ "right",
19
+ "right-end",
20
+ "bottom-end",
21
+ "bottom",
22
+ "bottom-start",
23
+ "left-end",
24
+ "left",
25
+ "left-start"
26
+ ]).description("start placement preferences, as per popperjs placement option").defaultValue("'top'"),
27
+ placementOrderPreference: PropTypes.arrayOf(PropTypes.oneOf([
28
+ "top-start",
29
+ "top",
30
+ "top-end",
31
+ "right-start",
32
+ "right",
33
+ "right-end",
34
+ "bottom-end",
35
+ "bottom",
36
+ "bottom-start",
37
+ "left-end",
38
+ "left",
39
+ "left-start"
40
+ ])).description('Array of placement preferences, as per popperjs "flip" placement option').defaultValue("['top', 'bottom', 'left', 'right']"),
41
+ zIndex: PropTypes.number.description("popperjs content z-index").defaultValue(1),
42
+ customOffset: PropTypes.arrayOf(PropTypes.number).description("placement offset array").defaultValue(1),
43
+ modifiers: PropTypes.array.description("modifiers array for full-custom popper-js override, https://popper.js.org/docs/v2/modifiers/").defaultValue(1),
44
+ extraPopperStyles: PropTypes.object.description("Extra object styles to attach to the popper element").defaultValue({}),
45
+ onClickOutside: PropTypes.func.description("Callback triggered when clicking outside the popper").defaultValue(() => null),
46
+ children: PropTypes.node.description("The content of the popper").defaultValue(void 0)
79
47
  };
80
-
81
- export { dspopperjsPropTypes };
48
+ export {
49
+ dspopperjsPropTypes
50
+ };
51
+ //# sourceMappingURL=propTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/propTypes.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { PropTypes } from 'react-desc';\n\nexport const dspopperjsPropTypes = {\n /**\n * React ref to popperjs referenceElement\n */\n referenceElement: PropTypes.element.description('popperjs DOM referenceElement').isRequired,\n /**\n * Wheter or not to show the popper content\n */\n showPopover: PropTypes.bool.description('whether or not to show the popper content').isRequired,\n /**\n * Callback to close the context menu, used for \"on click outside\",\n * if not provided click outside will not trigger anything\n */\n closeContextMenu: PropTypes.func\n .description(\n 'Callback to close the context menu, used for \"on click outside\",' +\n ' if not provided click outside will not trigger anything',\n )\n .defaultValue('() => {}'),\n /**\n * Wheter or not the popper content should appear in a DOM portal or not\n */\n withoutPortal: PropTypes.bool\n .description('Whether or not the popper content should appear in a DOM portal or not')\n .defaultValue(true),\n /**\n * Wheter or not the popper context menu should print the arrow\n */\n withoutArrow: PropTypes.bool\n .description('Whether or not the popper context menu should print the arrow')\n .defaultValue(false),\n /**\n * Whether or not the popper context menu should be animated\n */\n withoutAnimation: PropTypes.bool\n .description('Whether or not the popper context menu should be animated')\n .defaultValue(false),\n /**\n * Popper context menus Animation duration in ms\n */\n animationDuration: PropTypes.number.description('Popper context menus Animation duration in ms').defaultValue(100),\n /**\n * Bounding element to calculate upon, defaults to it is \"clippingParents\",\n * which are the scrolling containers that may cause the element to be partially or fully cut off.\n */\n boundaryElement: PropTypes.element\n .description(\n 'Bounding element to calculate upon, defaults to \"clippingParents\",' +\n 'which are the scrolling containers that may cause element to be partially or fully cut off',\n )\n .defaultValue(undefined),\n /**\n * When using portal, the container in which to append the DOM content, defaults to document body\n */\n portalDOMContainer: PropTypes.element\n .description('When using portal, the container in which to append the DOM content, defaults to document body')\n .defaultValue(undefined),\n /**\n * start placement preferences, as per popperjs placement option\n */\n startPlacementPreference: PropTypes.oneOf([\n 'top-start',\n 'top',\n 'top-end',\n 'right-start',\n 'right',\n 'right-end',\n 'bottom-end',\n 'bottom',\n 'bottom-start',\n 'left-end',\n 'left',\n 'left-start',\n ])\n .description('start placement preferences, as per popperjs placement option')\n .defaultValue(\"'top'\"),\n /**\n * Array of placement preferences, as per popperjs \"flip\" placement option\n */\n placementOrderPreference: PropTypes.arrayOf(\n PropTypes.oneOf([\n 'top-start',\n 'top',\n 'top-end',\n 'right-start',\n 'right',\n 'right-end',\n 'bottom-end',\n 'bottom',\n 'bottom-start',\n 'left-end',\n 'left',\n 'left-start',\n ]),\n )\n .description('Array of placement preferences, as per popperjs \"flip\" placement option')\n .defaultValue(\"['top', 'bottom', 'left', 'right']\"),\n /**\n * popperjs content z-index\n */\n zIndex: PropTypes.number.description('popperjs content z-index').defaultValue(1),\n /**\n * placement offset array\n */\n customOffset: PropTypes.arrayOf(PropTypes.number).description('placement offset array').defaultValue(1),\n /**\n * modifiers array for full-custom popper-js override\n * https://popper.js.org/docs/v2/modifiers/\n */\n modifiers: PropTypes.array\n .description('modifiers array for full-custom popper-js override, https://popper.js.org/docs/v2/modifiers/')\n .defaultValue(1),\n extraPopperStyles: PropTypes.object\n .description('Extra object styles to attach to the popper element')\n .defaultValue({}),\n onClickOutside: PropTypes.func\n .description('Callback triggered when clicking outside the popper')\n .defaultValue(() => null),\n children: PropTypes.node.description('The content of the popper').defaultValue(undefined),\n};\n"],
5
+ "mappings": "AAAA;ACAA;AAEO,MAAM,sBAAsB;AAAA,EAIjC,kBAAkB,UAAU,QAAQ,YAAY,iCAAiC;AAAA,EAIjF,aAAa,UAAU,KAAK,YAAY,6CAA6C;AAAA,EAKrF,kBAAkB,UAAU,KACzB,YACC,4HAGD,aAAa;AAAA,EAIhB,eAAe,UAAU,KACtB,YAAY,0EACZ,aAAa;AAAA,EAIhB,cAAc,UAAU,KACrB,YAAY,iEACZ,aAAa;AAAA,EAIhB,kBAAkB,UAAU,KACzB,YAAY,6DACZ,aAAa;AAAA,EAIhB,mBAAmB,UAAU,OAAO,YAAY,iDAAiD,aAAa;AAAA,EAK9G,iBAAiB,UAAU,QACxB,YACC,gKAGD,aAAa;AAAA,EAIhB,oBAAoB,UAAU,QAC3B,YAAY,kGACZ,aAAa;AAAA,EAIhB,0BAA0B,UAAU,MAAM;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KAEC,YAAY,iEACZ,aAAa;AAAA,EAIhB,0BAA0B,UAAU,QAClC,UAAU,MAAM;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MAGD,YAAY,2EACZ,aAAa;AAAA,EAIhB,QAAQ,UAAU,OAAO,YAAY,4BAA4B,aAAa;AAAA,EAI9E,cAAc,UAAU,QAAQ,UAAU,QAAQ,YAAY,0BAA0B,aAAa;AAAA,EAKrG,WAAW,UAAU,MAClB,YAAY,gGACZ,aAAa;AAAA,EAChB,mBAAmB,UAAU,OAC1B,YAAY,uDACZ,aAAa;AAAA,EAChB,gBAAgB,UAAU,KACvB,YAAY,uDACZ,aAAa,MAAM;AAAA,EACtB,UAAU,UAAU,KAAK,YAAY,6BAA6B,aAAa;AAAA;",
6
+ "names": []
7
+ }
package/esm/styled.js CHANGED
@@ -1,27 +1,42 @@
1
- import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
2
- import styled from 'styled-components';
3
- import { kfrm, css } from '@elliemae/ds-system';
1
+ import * as React from "react";
2
+ import styled from "styled-components";
3
+ import { kfrm, css } from "@elliemae/ds-system";
4
+ const showAnimation = kfrm`
5
+ from {
6
+ opacity: 0;
7
+ transform: scale(0.8);
8
+ }
4
9
 
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
- });
10
+ to {
11
+ opacity: 1;
12
+ transform: scale(1);
13
+ visibility: visible;
14
+ }
15
+ `;
16
+ const hideAnimation = kfrm`
17
+ from {
18
+ opacity: 1;
19
+ transform: scale(1);
20
+ }
26
21
 
27
- export { StyledAnimatedPopper, StyledPopoverContentWrapper };
22
+ to {
23
+ opacity: 0;
24
+ transform: scale(0.8);
25
+ visibility: hidden;
26
+ }
27
+ `;
28
+ const StyledPopoverContentWrapper = styled.div`
29
+ z-index: ${({ zIndex }) => zIndex};
30
+ `;
31
+ const StyledAnimatedPopper = styled.div`
32
+ 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);
33
+
34
+ ${({ showPopover, animationDuration, withoutAnimation }) => !withoutAnimation && css`
35
+ animation: ${showPopover ? showAnimation : hideAnimation} ${animationDuration}ms ease-in;
36
+ `}
37
+ `;
38
+ export {
39
+ StyledAnimatedPopper,
40
+ StyledPopoverContentWrapper
41
+ };
42
+ //# sourceMappingURL=styled.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/styled.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import styled from 'styled-components';\nimport { kfrm, css } from '@elliemae/ds-system';\n\ninterface StyledContentWrapperPropsT {\n zIndex: number;\n}\n\ninterface StyledAnimatedPopperPropsT {\n showPopover: boolean;\n animationDuration: number;\n withoutAnimation: boolean;\n}\n\nconst showAnimation = kfrm`\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`;\n\nconst hideAnimation = kfrm`\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`;\n\nexport const StyledPopoverContentWrapper = styled.div<StyledContentWrapperPropsT>`\n z-index: ${({ zIndex }) => zIndex};\n`;\n\nexport const StyledAnimatedPopper = styled.div<StyledAnimatedPopperPropsT>`\n 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);\n\n ${({ showPopover, animationDuration, withoutAnimation }) =>\n !withoutAnimation &&\n css`\n animation: ${showPopover ? showAnimation : hideAnimation} ${animationDuration}ms ease-in;\n `}\n`;\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AAYA,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAatB,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaf,MAAM,8BAA8B,OAAO;AAAA,aACrC,CAAC,EAAE,aAAa;AAAA;AAGtB,MAAM,uBAAuB,OAAO;AAAA;AAAA;AAAA,IAGvC,CAAC,EAAE,aAAa,mBAAmB,uBACnC,CAAC,oBACD;AAAA,mBACe,cAAc,gBAAgB,iBAAiB;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -1,25 +1,22 @@
1
- import { useEffect } from 'react';
2
-
1
+ import * as React from "react";
2
+ import { useEffect } from "react";
3
3
  function useOnClickOutside(ref, cb) {
4
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)) {
5
+ const listener = (event) => {
6
+ if (!ref || ref?.contains?.(event.target)) {
10
7
  return;
11
8
  }
12
-
13
9
  cb(event);
14
10
  };
15
-
16
- document.addEventListener('mousedown', listener);
17
- document.addEventListener('touchstart', listener);
11
+ document.addEventListener("mousedown", listener);
12
+ document.addEventListener("touchstart", listener);
18
13
  return () => {
19
- document.removeEventListener('mousedown', listener);
20
- document.removeEventListener('touchstart', listener);
14
+ document.removeEventListener("mousedown", listener);
15
+ document.removeEventListener("touchstart", listener);
21
16
  };
22
17
  }, [ref, cb]);
23
18
  }
24
-
25
- export { useOnClickOutside };
19
+ export {
20
+ useOnClickOutside
21
+ };
22
+ //# sourceMappingURL=useOnClickOutside.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/utils/hooks/useOnClickOutside.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useEffect } from 'react';\n\ntype defaultCbt = (e: React.MouseEvent) => void;\nexport function useOnClickOutside<T extends Node, cbT extends defaultCbt>(ref: T, cb: cbT): void {\n useEffect(() => {\n const listener = (event) => {\n // Do nothing if clicking ref's element or descendent elements\n if (!ref || ref?.contains?.(event.target)) {\n return;\n }\n cb(event);\n };\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n return () => {\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [ref, cb]);\n}\n"],
5
+ "mappings": "AAAA;ACAA;AAGO,2BAAmE,KAAQ,IAAe;AAC/F,YAAU,MAAM;AACd,UAAM,WAAW,CAAC,UAAU;AAE1B,UAAI,CAAC,OAAO,KAAK,WAAW,MAAM,SAAS;AACzC;AAAA;AAEF,SAAG;AAAA;AAEL,aAAS,iBAAiB,aAAa;AACvC,aAAS,iBAAiB,cAAc;AACxC,WAAO,MAAM;AACX,eAAS,oBAAoB,aAAa;AAC1C,eAAS,oBAAoB,cAAc;AAAA;AAAA,KAE5C,CAAC,KAAK;AAAA;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-popperjs",
3
- "version": "2.2.0-alpha.1",
3
+ "version": "2.2.0-alpha.2",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Popper JS Wrapper",
6
6
  "module": "./esm/index.js",
@@ -68,8 +68,8 @@
68
68
  "build": "node ../../scripts/build/build.js"
69
69
  },
70
70
  "dependencies": {
71
- "@elliemae/ds-props-helpers": "2.2.0-alpha.1",
72
- "@elliemae/ds-system": "2.2.0-alpha.1",
71
+ "@elliemae/ds-props-helpers": "2.2.0-alpha.2",
72
+ "@elliemae/ds-system": "2.2.0-alpha.2",
73
73
  "react-desc": "~4.1.3",
74
74
  "react-popper": "~2.2.5"
75
75
  },