@elliemae/ds-popperjs 2.0.0-alpha.3 → 2.0.0-alpha.7

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.
@@ -13,7 +13,7 @@ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
13
13
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
14
14
 
15
15
  var _svg;
16
- const StyledArrow = /*#__PURE__*/styled__default['default'].div.withConfig({
16
+ const StyledArrow = /*#__PURE__*/styled__default["default"].div.withConfig({
17
17
  componentId: "sc-olcdf1-0"
18
18
  })(["position:absolute;width:18px;height:18px;pointer-events:none;background-color:transparent;& .stroke{fill:", ";fill-opacity:0.4;}& .fill{fill:", ";}&[data-placement^='top']{svg{transform:rotateZ(180deg);}bottom:-18px;}&[data-placement^='right']{svg{transform:rotateZ(-90deg);}left:-18px;}&[data-placement^='bottom']{top:-18px;}&[data-placement^='left']{svg{transform:rotateZ(90deg);}right:-18px;}"], ({
19
19
  theme
@@ -29,12 +29,12 @@ const PopoverArrow = ({
29
29
  style: style,
30
30
  ref: arrowElementRef,
31
31
  "data-testid": "ds-tooltip-arrow",
32
- children: _svg || (_svg = /*#__PURE__*/_jsx__default['default']("svg", {
32
+ children: _svg || (_svg = /*#__PURE__*/_jsx__default["default"]("svg", {
33
33
  viewBox: "0 0 30 30"
34
- }, void 0, /*#__PURE__*/_jsx__default['default']("path", {
34
+ }, void 0, /*#__PURE__*/_jsx__default["default"]("path", {
35
35
  className: "stroke",
36
36
  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"
37
- }), /*#__PURE__*/_jsx__default['default']("path", {
37
+ }), /*#__PURE__*/_jsx__default["default"]("path", {
38
38
  className: "fill",
39
39
  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"
40
40
  })))
@@ -17,10 +17,10 @@ var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
17
17
 
18
18
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
19
19
 
20
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
21
- const StyledPopoverContentWrapper = /*#__PURE__*/styled__default['default'].div.withConfig({
20
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
21
+ const StyledPopoverContentWrapper = /*#__PURE__*/styled__default["default"].div.withConfig({
22
22
  componentId: "sc-1gxm7np-0"
23
- })(["background:white;max-width:400px;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);padding:10px;z-index:", ";"], ({
23
+ })(["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);z-index:", ";"], ({
24
24
  zIndex
25
25
  }) => zIndex);
26
26
  const PopoverContent = ({
@@ -38,7 +38,7 @@ const PopoverContent = ({
38
38
  style: popperStyles
39
39
  }, popperAttributes), {}, {
40
40
  children: [children, withoutArrow === false ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
41
- children: [/*#__PURE__*/_jsx__default['default'](PopoverArrow.PopoverArrow, {
41
+ children: [/*#__PURE__*/_jsx__default["default"](PopoverArrow.PopoverArrow, {
42
42
  arrowElementRef: setArrowElement,
43
43
  style: arrowStyle,
44
44
  placement: popperAttributes ? popperAttributes['data-popper-placement'] : 'bottom'
@@ -17,16 +17,18 @@ const useConfigDSPopperjs = appProps => {
17
17
  const {
18
18
  referenceElement,
19
19
  closeContextMenu,
20
- modifiers
20
+ modifiers,
21
+ startPlacementPreference
21
22
  } = props;
22
23
  const popperExtraOpts = react.useMemo(() => ({
24
+ placement: startPlacementPreference,
23
25
  modifiers
24
- }), [modifiers]);
26
+ }), [modifiers, startPlacementPreference]);
25
27
  const popoverHelper = reactPopper.usePopper(referenceElement, popperElement, popperExtraOpts);
26
28
  useOnClickOutside.useOnClickOutside(popperElement, e => {
27
- var _referenceElement$cur, _referenceElement$cur2;
29
+ var _referenceElement$con;
28
30
 
29
- if (!(referenceElement !== null && referenceElement !== void 0 && (_referenceElement$cur = referenceElement.current) !== null && _referenceElement$cur !== void 0 && (_referenceElement$cur2 = _referenceElement$cur.contains) !== null && _referenceElement$cur2 !== void 0 && _referenceElement$cur2.call(_referenceElement$cur, e === null || e === void 0 ? void 0 : e.target))) closeContextMenu();
31
+ 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))) closeContextMenu();
30
32
  });
31
33
  return react.useMemo(() => ({
32
34
  props,
@@ -44,7 +44,8 @@ const useConfiguredDefaultModifiers = ({
44
44
  if (!explicitAppWithoutArrow) mod.push({
45
45
  name: 'arrow',
46
46
  options: {
47
- element: arrowElement
47
+ element: arrowElement,
48
+ padding: 18
48
49
  }
49
50
  }); // the app can define an explicit element to act as a boundary instead of popperjs default one
50
51
 
@@ -12,24 +12,26 @@ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_definePropert
12
12
 
13
13
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
14
14
 
15
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
15
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
16
16
 
17
17
  const noop = () => {};
18
18
 
19
- const staticDefaultProps = {
20
- referenceElement: null,
21
- showPopover: false,
22
- closeContextMenu: noop,
23
- withoutPortal: false,
24
- withoutArrow: false,
25
- portalDOMContainer: document.body,
26
- placementOrderPreference: ['top', 'bottom', 'left', 'right'],
27
- zIndex: 1
28
- };
29
19
  const useConfiguredDefaultProps = ({
30
20
  props,
31
21
  arrowElement
32
22
  }) => {
23
+ // don't move this out of the hook or `document.body` will explode
24
+ const staticDefaultProps = react.useMemo(() => ({
25
+ referenceElement: null,
26
+ showPopover: false,
27
+ closeContextMenu: noop,
28
+ withoutPortal: false,
29
+ withoutArrow: false,
30
+ portalDOMContainer: document.body,
31
+ startPlacementPreference: 'top',
32
+ placementOrderPreference: ['top', 'bottom', 'left', 'right'],
33
+ zIndex: 1
34
+ }), []);
33
35
  const {
34
36
  modifiers: configuredModifiers
35
37
  } = useConfiguredDefaultModifiers.useConfiguredDefaultModifiers({
@@ -38,7 +40,7 @@ const useConfiguredDefaultProps = ({
38
40
  });
39
41
  const defaultProps = react.useMemo(() => _objectSpread(_objectSpread({}, staticDefaultProps), {}, {
40
42
  modifiers: configuredModifiers
41
- }), [configuredModifiers]);
43
+ }), [configuredModifiers, staticDefaultProps]);
42
44
  return defaultProps;
43
45
  };
44
46
 
package/cjs/index.js CHANGED
@@ -5,6 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var _jsx = require('@babel/runtime/helpers/jsx');
6
6
  var react = require('react');
7
7
  var reactDom = require('react-dom');
8
+ var reactDesc = require('react-desc');
9
+ var propTypes = require('./propTypes.js');
8
10
  var PopoverContent = require('./PopoverContent.js');
9
11
  var useConfigDSPopperjs = require('./config/useConfigDSPopperjs.js');
10
12
  var jsxRuntime = require('react/jsx-runtime');
@@ -33,7 +35,7 @@ const DSPopperJS = props => {
33
35
  styles,
34
36
  attributes
35
37
  } = popoverHelper;
36
- const contentJSX = react.useMemo(() => /*#__PURE__*/_jsx__default['default'](PopoverContent.PopoverContent, {
38
+ const contentJSX = react.useMemo(() => /*#__PURE__*/_jsx__default["default"](PopoverContent.PopoverContent, {
37
39
  setPopperElement: setPopperElement,
38
40
  popperStyles: styles.popper,
39
41
  popperAttributes: attributes.popper,
@@ -55,4 +57,9 @@ const DSPopperJS = props => {
55
57
  return null;
56
58
  };
57
59
 
60
+ const DSPopperJSWithSchema = reactDesc.describe(DSPopperJS).description('A dimsum custom styling wrapper on top of popperjs');
61
+ DSPopperJSWithSchema.propTypes = propTypes.dspopperjsPropTypes;
62
+
58
63
  exports.DSPopperJS = DSPopperJS;
64
+ exports.DSPopperJSWithSchema = DSPopperJSWithSchema;
65
+ exports["default"] = DSPopperJS;
@@ -0,0 +1,72 @@
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
+ * Bounding element to calculate upon, defaults to it is "clippingParents",
36
+ * which are the scrolling containers that may cause the element to be partially or fully cut off.
37
+ */
38
+ 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),
39
+
40
+ /**
41
+ * When using portal, the container in which to append the DOM content, defaults to document body
42
+ */
43
+ portalDOMContainer: reactDesc.PropTypes.element.description('When using portal, the container in which to append the DOM content, defaults to document body').defaultValue(undefined),
44
+
45
+ /**
46
+ * start placement preferences, as per popperjs placement option
47
+ */
48
+ 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'"),
49
+
50
+ /**
51
+ * Array of placement preferences, as per popperjs "flip" placement option
52
+ */
53
+ 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']"),
54
+
55
+ /**
56
+ * popperjs content z-index
57
+ */
58
+ zIndex: reactDesc.PropTypes.number.description('popperjs content z-index').defaultValue(1),
59
+
60
+ /**
61
+ * placement offset array
62
+ */
63
+ customOffset: reactDesc.PropTypes.arrayOf(reactDesc.PropTypes.number).description('placement offset array').defaultValue(1),
64
+
65
+ /**
66
+ * modifiers array for full-custom popper-js override
67
+ * https://popper.js.org/docs/v2/modifiers/
68
+ */
69
+ modifiers: reactDesc.PropTypes.array.description('modifiers array for full-custom popper-js override, https://popper.js.org/docs/v2/modifiers/').defaultValue(1)
70
+ };
71
+
72
+ exports.dspopperjsPropTypes = dspopperjsPropTypes;
@@ -10,7 +10,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
10
10
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
11
11
  const StyledPopoverContentWrapper = /*#__PURE__*/styled.div.withConfig({
12
12
  componentId: "sc-1gxm7np-0"
13
- })(["background:white;max-width:400px;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);padding:10px;z-index:", ";"], ({
13
+ })(["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);z-index:", ";"], ({
14
14
  zIndex
15
15
  }) => zIndex);
16
16
  const PopoverContent = ({
@@ -13,16 +13,18 @@ const useConfigDSPopperjs = appProps => {
13
13
  const {
14
14
  referenceElement,
15
15
  closeContextMenu,
16
- modifiers
16
+ modifiers,
17
+ startPlacementPreference
17
18
  } = props;
18
19
  const popperExtraOpts = useMemo(() => ({
20
+ placement: startPlacementPreference,
19
21
  modifiers
20
- }), [modifiers]);
22
+ }), [modifiers, startPlacementPreference]);
21
23
  const popoverHelper = usePopper(referenceElement, popperElement, popperExtraOpts);
22
24
  useOnClickOutside(popperElement, e => {
23
- var _referenceElement$cur, _referenceElement$cur2;
25
+ var _referenceElement$con;
24
26
 
25
- if (!(referenceElement !== null && referenceElement !== void 0 && (_referenceElement$cur = referenceElement.current) !== null && _referenceElement$cur !== void 0 && (_referenceElement$cur2 = _referenceElement$cur.contains) !== null && _referenceElement$cur2 !== void 0 && _referenceElement$cur2.call(_referenceElement$cur, e === null || e === void 0 ? void 0 : e.target))) closeContextMenu();
27
+ 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))) closeContextMenu();
26
28
  });
27
29
  return useMemo(() => ({
28
30
  props,
@@ -40,7 +40,8 @@ const useConfiguredDefaultModifiers = ({
40
40
  if (!explicitAppWithoutArrow) mod.push({
41
41
  name: 'arrow',
42
42
  options: {
43
- element: arrowElement
43
+ element: arrowElement,
44
+ padding: 18
44
45
  }
45
46
  }); // the app can define an explicit element to act as a boundary instead of popperjs default one
46
47
 
@@ -8,20 +8,22 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
8
8
 
9
9
  const noop = () => {};
10
10
 
11
- const staticDefaultProps = {
12
- referenceElement: null,
13
- showPopover: false,
14
- closeContextMenu: noop,
15
- withoutPortal: false,
16
- withoutArrow: false,
17
- portalDOMContainer: document.body,
18
- placementOrderPreference: ['top', 'bottom', 'left', 'right'],
19
- zIndex: 1
20
- };
21
11
  const useConfiguredDefaultProps = ({
22
12
  props,
23
13
  arrowElement
24
14
  }) => {
15
+ // don't move this out of the hook or `document.body` will explode
16
+ const staticDefaultProps = useMemo(() => ({
17
+ referenceElement: null,
18
+ showPopover: false,
19
+ closeContextMenu: noop,
20
+ withoutPortal: false,
21
+ withoutArrow: false,
22
+ portalDOMContainer: document.body,
23
+ startPlacementPreference: 'top',
24
+ placementOrderPreference: ['top', 'bottom', 'left', 'right'],
25
+ zIndex: 1
26
+ }), []);
25
27
  const {
26
28
  modifiers: configuredModifiers
27
29
  } = useConfiguredDefaultModifiers({
@@ -30,7 +32,7 @@ const useConfiguredDefaultProps = ({
30
32
  });
31
33
  const defaultProps = useMemo(() => _objectSpread(_objectSpread({}, staticDefaultProps), {}, {
32
34
  modifiers: configuredModifiers
33
- }), [configuredModifiers]);
35
+ }), [configuredModifiers, staticDefaultProps]);
34
36
  return defaultProps;
35
37
  };
36
38
 
package/esm/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import _jsx from '@babel/runtime/helpers/esm/jsx';
2
2
  import { useMemo } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
+ import { describe } from 'react-desc';
5
+ import { dspopperjsPropTypes } from './propTypes.js';
4
6
  import { PopoverContent } from './PopoverContent.js';
5
7
  import { useConfigDSPopperjs } from './config/useConfigDSPopperjs.js';
6
8
  import { jsx, Fragment } from 'react/jsx-runtime';
@@ -47,4 +49,7 @@ const DSPopperJS = props => {
47
49
  return null;
48
50
  };
49
51
 
50
- export { DSPopperJS };
52
+ const DSPopperJSWithSchema = describe(DSPopperJS).description('A dimsum custom styling wrapper on top of popperjs');
53
+ DSPopperJSWithSchema.propTypes = dspopperjsPropTypes;
54
+
55
+ export { DSPopperJS, DSPopperJSWithSchema, DSPopperJS as default };
@@ -0,0 +1,68 @@
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
+ * Bounding element to calculate upon, defaults to it is "clippingParents",
32
+ * which are the scrolling containers that may cause the element to be partially or fully cut off.
33
+ */
34
+ 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),
35
+
36
+ /**
37
+ * When using portal, the container in which to append the DOM content, defaults to document body
38
+ */
39
+ portalDOMContainer: PropTypes.element.description('When using portal, the container in which to append the DOM content, defaults to document body').defaultValue(undefined),
40
+
41
+ /**
42
+ * start placement preferences, as per popperjs placement option
43
+ */
44
+ 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'"),
45
+
46
+ /**
47
+ * Array of placement preferences, as per popperjs "flip" placement option
48
+ */
49
+ 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']"),
50
+
51
+ /**
52
+ * popperjs content z-index
53
+ */
54
+ zIndex: PropTypes.number.description('popperjs content z-index').defaultValue(1),
55
+
56
+ /**
57
+ * placement offset array
58
+ */
59
+ customOffset: PropTypes.arrayOf(PropTypes.number).description('placement offset array').defaultValue(1),
60
+
61
+ /**
62
+ * modifiers array for full-custom popper-js override
63
+ * https://popper.js.org/docs/v2/modifiers/
64
+ */
65
+ modifiers: PropTypes.array.description('modifiers array for full-custom popper-js override, https://popper.js.org/docs/v2/modifiers/').defaultValue(1)
66
+ };
67
+
68
+ export { dspopperjsPropTypes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-popperjs",
3
- "version": "2.0.0-alpha.3",
3
+ "version": "2.0.0-alpha.7",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Popper JS Wrapper",
6
6
  "module": "./esm/index.js",
@@ -15,6 +15,10 @@
15
15
  "import": "./esm/utils/hooks/useOnClickOutside.js",
16
16
  "require": "./cjs/utils/hooks/useOnClickOutside.js"
17
17
  },
18
+ "./propTypes": {
19
+ "import": "./esm/propTypes.js",
20
+ "require": "./cjs/propTypes.js"
21
+ },
18
22
  "./PopoverContent": {
19
23
  "import": "./esm/PopoverContent.js",
20
24
  "require": "./cjs/PopoverContent.js"
@@ -60,7 +64,7 @@
60
64
  "build": "node ../../scripts/build/build.js"
61
65
  },
62
66
  "dependencies": {
63
- "@elliemae/ds-props-helpers": "2.0.0-alpha.3",
67
+ "@elliemae/ds-props-helpers": "2.0.0-alpha.7",
64
68
  "react-desc": "~4.1.3"
65
69
  },
66
70
  "devDependencies": {
@@ -9,6 +9,7 @@ export declare const useConfiguredDefaultProps: ({ props, arrowElement }: {
9
9
  withoutPortal: boolean;
10
10
  withoutArrow: boolean;
11
11
  portalDOMContainer: HTMLElement;
12
+ startPlacementPreference: string;
12
13
  placementOrderPreference: string[];
13
14
  zIndex: number;
14
15
  };
@@ -9,6 +9,7 @@ export declare const useConfiguredMergedProps: ({ props, arrowElement }: {
9
9
  withoutPortal: boolean;
10
10
  withoutArrow: boolean;
11
11
  portalDOMContainer: HTMLElement;
12
+ startPlacementPreference: string;
12
13
  placementOrderPreference: string[];
13
14
  zIndex: number;
14
15
  }>;
package/types/index.d.ts CHANGED
@@ -1,3 +1,22 @@
1
1
  /// <reference types="react" />
2
2
  import type { DSDSPopperjsPropsT } from './index.d';
3
- export declare const DSPopperJS: (props: DSDSPopperjsPropsT) => JSX.Element;
3
+ declare const DSPopperJS: {
4
+ (props: DSDSPopperjsPropsT): JSX.Element;
5
+ propTypes: {
6
+ referenceElement: any;
7
+ showPopover: any;
8
+ closeContextMenu: any;
9
+ withoutPortal: any;
10
+ withoutArrow: any;
11
+ boundaryElement: any;
12
+ portalDOMContainer: any;
13
+ startPlacementPreference: any;
14
+ placementOrderPreference: any;
15
+ zIndex: any;
16
+ customOffset: any;
17
+ modifiers: any;
18
+ };
19
+ };
20
+ declare const DSPopperJSWithSchema: any;
21
+ export { DSPopperJS, DSPopperJSWithSchema };
22
+ export default DSPopperJS;
@@ -0,0 +1,53 @@
1
+ export declare const dspopperjsPropTypes: {
2
+ /**
3
+ * React ref to popperjs referenceElement
4
+ */
5
+ referenceElement: any;
6
+ /**
7
+ * Wheter or not to show the popper content
8
+ */
9
+ showPopover: any;
10
+ /**
11
+ * Callback to close the context menu, used for "on click outside",
12
+ * if not provided click outside will not trigger anything
13
+ */
14
+ closeContextMenu: any;
15
+ /**
16
+ * Wheter or not the popper content should appear in a DOM portal or not
17
+ */
18
+ withoutPortal: any;
19
+ /**
20
+ * Wheter or not the popper context menu should print the arrow
21
+ */
22
+ withoutArrow: any;
23
+ /**
24
+ * Bounding element to calculate upon, defaults to it is "clippingParents",
25
+ * which are the scrolling containers that may cause the element to be partially or fully cut off.
26
+ */
27
+ boundaryElement: any;
28
+ /**
29
+ * When using portal, the container in which to append the DOM content, defaults to document body
30
+ */
31
+ portalDOMContainer: any;
32
+ /**
33
+ * start placement preferences, as per popperjs placement option
34
+ */
35
+ startPlacementPreference: any;
36
+ /**
37
+ * Array of placement preferences, as per popperjs "flip" placement option
38
+ */
39
+ placementOrderPreference: any;
40
+ /**
41
+ * popperjs content z-index
42
+ */
43
+ zIndex: any;
44
+ /**
45
+ * placement offset array
46
+ */
47
+ customOffset: any;
48
+ /**
49
+ * modifiers array for full-custom popper-js override
50
+ * https://popper.js.org/docs/v2/modifiers/
51
+ */
52
+ modifiers: any;
53
+ };