@elliemae/ds-popperjs 1.54.0-rc.1 → 1.55.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/PopoverContent.js +1 -1
- package/cjs/PopoverContent.js.map +1 -1
- package/cjs/config/useConfigDSPopperjs.js +6 -4
- package/cjs/config/useConfigDSPopperjs.js.map +1 -1
- package/cjs/config/useConfiguredDefaultModifiers.js +2 -1
- package/cjs/config/useConfiguredDefaultModifiers.js.map +1 -1
- package/cjs/config/useConfiguredDefaultProps.js +17 -13
- package/cjs/config/useConfiguredDefaultProps.js.map +1 -1
- package/cjs/index.js +8 -0
- package/cjs/index.js.map +1 -1
- package/cjs/propTypes.js +73 -0
- package/cjs/propTypes.js.map +1 -0
- package/esm/PopoverContent.js +1 -1
- package/esm/PopoverContent.js.map +1 -1
- package/esm/config/useConfigDSPopperjs.js +6 -4
- package/esm/config/useConfigDSPopperjs.js.map +1 -1
- package/esm/config/useConfiguredDefaultModifiers.js +2 -1
- package/esm/config/useConfiguredDefaultModifiers.js.map +1 -1
- package/esm/config/useConfiguredDefaultProps.js +15 -11
- package/esm/config/useConfiguredDefaultProps.js.map +1 -1
- package/esm/index.js +7 -1
- package/esm/index.js.map +1 -1
- package/esm/propTypes.js +69 -0
- package/esm/propTypes.js.map +1 -0
- package/package.json +2 -2
- package/propTypes/package.json +10 -0
package/cjs/PopoverContent.js
CHANGED
|
@@ -15,7 +15,7 @@ var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
|
15
15
|
|
|
16
16
|
var StyledPopoverContentWrapper = /*#__PURE__*/styled__default['default'].div.withConfig({
|
|
17
17
|
componentId: "sc-1gxm7np-0"
|
|
18
|
-
})(["
|
|
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);z-index:", ";"], function (_ref) {
|
|
19
19
|
var zIndex = _ref.zIndex;
|
|
20
20
|
return zIndex;
|
|
21
21
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverContent.js","sources":["../../src/PopoverContent.tsx"],"sourcesContent":["import React from 'react';\nimport styled from 'styled-components';\nimport { PopoverArrow } from './PopoverArrow';\nimport type { PopoverContentPropsT } from './index.d';\n\ninterface StyledContentWrapperPropsT {\n zIndex: number;\n}\nconst StyledPopoverContentWrapper = styled.div<StyledContentWrapperPropsT>`\n
|
|
1
|
+
{"version":3,"file":"PopoverContent.js","sources":["../../src/PopoverContent.tsx"],"sourcesContent":["import React from 'react';\nimport styled from 'styled-components';\nimport { PopoverArrow } from './PopoverArrow';\nimport type { PopoverContentPropsT } from './index.d';\n\ninterface StyledContentWrapperPropsT {\n zIndex: number;\n}\nconst StyledPopoverContentWrapper = styled.div<StyledContentWrapperPropsT>`\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 z-index: ${({ zIndex }) => zIndex};\n`;\n\nexport const PopoverContent = ({\n setPopperElement,\n popperStyles,\n popperAttributes,\n children,\n setArrowElement,\n arrowStyle,\n withoutArrow,\n zIndex,\n}: PopoverContentPropsT): JSX.Element => (\n <StyledPopoverContentWrapper zIndex={zIndex} ref={setPopperElement} style={popperStyles} {...popperAttributes}>\n {children}\n {withoutArrow === false ? (\n <>\n <PopoverArrow\n arrowElementRef={setArrowElement}\n style={arrowStyle}\n placement={popperAttributes ? popperAttributes['data-popper-placement'] : 'bottom'}\n />\n <div ref={setArrowElement} style={arrowStyle} />\n </>\n ) : null}\n </StyledPopoverContentWrapper>\n);\n"],"names":["StyledPopoverContentWrapper","styled","div","zIndex","PopoverContent","setPopperElement","popperStyles","popperAttributes","children","setArrowElement","arrowStyle","withoutArrow","React","PopoverArrow"],"mappings":";;;;;;;;;;;;;;;AAQA,IAAMA,2BAA2B,gBAAGC,0BAAM,CAACC,GAAV;AAAA;AAAA,yHAEpB;AAAA,MAAGC,MAAH,QAAGA,MAAH;AAAA,SAAgBA,MAAhB;AAAA,CAFoB,CAAjC;IAKaC,cAAc,GAAG,SAAjBA,cAAiB;AAAA,MAC5BC,gBAD4B,SAC5BA,gBAD4B;AAAA,MAE5BC,YAF4B,SAE5BA,YAF4B;AAAA,MAG5BC,gBAH4B,SAG5BA,gBAH4B;AAAA,MAI5BC,QAJ4B,SAI5BA,QAJ4B;AAAA,MAK5BC,eAL4B,SAK5BA,eAL4B;AAAA,MAM5BC,UAN4B,SAM5BA,UAN4B;AAAA,MAO5BC,YAP4B,SAO5BA,YAP4B;AAAA,MAQ5BR,MAR4B,SAQ5BA,MAR4B;AAAA,sBAU5BS,wCAAC,2BAAD;AAA6B,IAAA,MAAM,EAAET,MAArC;AAA6C,IAAA,GAAG,EAAEE,gBAAlD;AAAoE,IAAA,KAAK,EAAEC;AAA3E,KAA6FC,gBAA7F,GACGC,QADH,EAEGG,YAAY,KAAK,KAAjB,gBACCC,+FACEA,wCAACC,yBAAD;AACE,IAAA,eAAe,EAAEJ,eADnB;AAEE,IAAA,KAAK,EAAEC,UAFT;AAGE,IAAA,SAAS,EAAEH,gBAAgB,GAAGA,gBAAgB,CAAC,uBAAD,CAAnB,GAA+C;AAH5E,IADF,eAMEK;AAAK,IAAA,GAAG,EAAEH,eAAV;AAA2B,IAAA,KAAK,EAAEC;AAAlC,IANF,CADD,GASG,IAXN,CAV4B;AAAA;;;;"}
|
|
@@ -33,17 +33,19 @@ var useConfigDSPopperjs = function useConfigDSPopperjs(appProps) {
|
|
|
33
33
|
});
|
|
34
34
|
var referenceElement = props.referenceElement,
|
|
35
35
|
closeContextMenu = props.closeContextMenu,
|
|
36
|
-
modifiers = props.modifiers
|
|
36
|
+
modifiers = props.modifiers,
|
|
37
|
+
startPlacementPreference = props.startPlacementPreference;
|
|
37
38
|
var popperExtraOpts = React.useMemo(function () {
|
|
38
39
|
return {
|
|
40
|
+
placement: startPlacementPreference,
|
|
39
41
|
modifiers: modifiers
|
|
40
42
|
};
|
|
41
|
-
}, [modifiers]);
|
|
43
|
+
}, [modifiers, startPlacementPreference]);
|
|
42
44
|
var popoverHelper = reactPopper.usePopper(referenceElement, popperElement, popperExtraOpts);
|
|
43
45
|
utils_hooks_useOnClickOutside.useOnClickOutside(popperElement, function (e) {
|
|
44
|
-
var _referenceElement$
|
|
46
|
+
var _referenceElement$con;
|
|
45
47
|
|
|
46
|
-
if (!(referenceElement !== null && referenceElement !== void 0 && (_referenceElement$
|
|
48
|
+
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();
|
|
47
49
|
});
|
|
48
50
|
return React.useMemo(function () {
|
|
49
51
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConfigDSPopperjs.js","sources":["../../../src/config/useConfigDSPopperjs.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { usePopper } from 'react-popper';\nimport { useConfiguredMergedProps } from './useConfiguredMergedProps';\nimport type { useDSPopperjsPropsArgT, useDSPopperjsRT } from '../index.d';\n\nimport { useOnClickOutside } from '../utils/hooks/useOnClickOutside';\n\nexport const useConfigDSPopperjs = (appProps: useDSPopperjsPropsArgT): useDSPopperjsRT => {\n const [popperElement, setPopperElement] = useState(null);\n const [arrowElement, setArrowElement] = useState(null);\n\n const props = useConfiguredMergedProps({ props: appProps, arrowElement });\n const { referenceElement, closeContextMenu, modifiers } = props;\n const popperExtraOpts = useMemo(() => ({ modifiers }),
|
|
1
|
+
{"version":3,"file":"useConfigDSPopperjs.js","sources":["../../../src/config/useConfigDSPopperjs.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { usePopper } from 'react-popper';\nimport { useConfiguredMergedProps } from './useConfiguredMergedProps';\nimport type { useDSPopperjsPropsArgT, useDSPopperjsRT } from '../index.d';\n\nimport { useOnClickOutside } from '../utils/hooks/useOnClickOutside';\n\nexport const useConfigDSPopperjs = (appProps: useDSPopperjsPropsArgT): useDSPopperjsRT => {\n const [popperElement, setPopperElement] = useState(null);\n const [arrowElement, setArrowElement] = useState(null);\n\n const props = useConfiguredMergedProps({ props: appProps, arrowElement });\n const { referenceElement, closeContextMenu, modifiers, startPlacementPreference } = props;\n const popperExtraOpts = useMemo(\n () => ({ placement: startPlacementPreference, modifiers }),\n [modifiers, startPlacementPreference],\n );\n\n const popoverHelper = usePopper(referenceElement, popperElement, popperExtraOpts);\n\n useOnClickOutside(popperElement, (e) => {\n if (!referenceElement?.contains?.(e?.target)) closeContextMenu();\n });\n\n return useMemo(\n () => ({\n props,\n popperElement,\n setPopperElement,\n arrowElement,\n setArrowElement,\n popoverHelper,\n }),\n [arrowElement, popoverHelper, popperElement, props],\n );\n};\n"],"names":["useConfigDSPopperjs","appProps","useState","popperElement","setPopperElement","arrowElement","setArrowElement","props","useConfiguredMergedProps","referenceElement","closeContextMenu","modifiers","startPlacementPreference","popperExtraOpts","useMemo","placement","popoverHelper","usePopper","useOnClickOutside","e","contains","target"],"mappings":";;;;;;;;;;;;;;;;;;IAOaA,mBAAmB,GAAG,SAAtBA,mBAAsB,CAACC,QAAD,EAAuD;AACxF,kBAA0CC,cAAQ,CAAC,IAAD,CAAlD;AAAA;AAAA,MAAOC,aAAP;AAAA,MAAsBC,gBAAtB;;AACA,mBAAwCF,cAAQ,CAAC,IAAD,CAAhD;AAAA;AAAA,MAAOG,YAAP;AAAA,MAAqBC,eAArB;;AAEA,MAAMC,KAAK,GAAGC,wDAAwB,CAAC;AAAED,IAAAA,KAAK,EAAEN,QAAT;AAAmBI,IAAAA,YAAY,EAAZA;AAAnB,GAAD,CAAtC;AACA,MAAQI,gBAAR,GAAoFF,KAApF,CAAQE,gBAAR;AAAA,MAA0BC,gBAA1B,GAAoFH,KAApF,CAA0BG,gBAA1B;AAAA,MAA4CC,SAA5C,GAAoFJ,KAApF,CAA4CI,SAA5C;AAAA,MAAuDC,wBAAvD,GAAoFL,KAApF,CAAuDK,wBAAvD;AACA,MAAMC,eAAe,GAAGC,aAAO,CAC7B;AAAA,WAAO;AAAEC,MAAAA,SAAS,EAAEH,wBAAb;AAAuCD,MAAAA,SAAS,EAATA;AAAvC,KAAP;AAAA,GAD6B,EAE7B,CAACA,SAAD,EAAYC,wBAAZ,CAF6B,CAA/B;AAKA,MAAMI,aAAa,GAAGC,qBAAS,CAACR,gBAAD,EAAmBN,aAAnB,EAAkCU,eAAlC,CAA/B;AAEAK,EAAAA,+CAAiB,CAACf,aAAD,EAAgB,UAACgB,CAAD,EAAO;AAAA;;AACtC,QAAI,EAACV,gBAAD,aAACA,gBAAD,wCAACA,gBAAgB,CAAEW,QAAnB,kDAAC,2BAAAX,gBAAgB,EAAaU,CAAb,aAAaA,CAAb,uBAAaA,CAAC,CAAEE,MAAhB,CAAjB,CAAJ,EAA8CX,gBAAgB;AAC/D,GAFgB,CAAjB;AAIA,SAAOI,aAAO,CACZ;AAAA,WAAO;AACLP,MAAAA,KAAK,EAALA,KADK;AAELJ,MAAAA,aAAa,EAAbA,aAFK;AAGLC,MAAAA,gBAAgB,EAAhBA,gBAHK;AAILC,MAAAA,YAAY,EAAZA,YAJK;AAKLC,MAAAA,eAAe,EAAfA,eALK;AAMLU,MAAAA,aAAa,EAAbA;AANK,KAAP;AAAA,GADY,EASZ,CAACX,YAAD,EAAeW,aAAf,EAA8Bb,aAA9B,EAA6CI,KAA7C,CATY,CAAd;AAWD;;;;"}
|
|
@@ -44,7 +44,8 @@ var useConfiguredDefaultModifiers = function useConfiguredDefaultModifiers(_ref)
|
|
|
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
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConfiguredDefaultModifiers.js","sources":["../../../src/config/useConfiguredDefaultModifiers.tsx"],"sourcesContent":["import { useMemo } from 'react';\n\nexport const useConfiguredDefaultModifiers = ({ props, arrowElement }) => {\n // we destructure explicit app definitions before merge\n const {\n boundaryElement: explicitAppBoundaryElement,\n withoutArrow: explicitAppWithoutArrow = false,\n placementOrderPreference: explicitPlacementOrderPreference = ['top', 'bottom', 'left', 'right'],\n customOffset: explictAppOffset = undefined,\n } = props;\n // to build default modifiers on top of it\n const defaultModifiers = useMemo(() => {\n const mod = [];\n mod.push({ name: 'hide', enabled: true });\n mod.push({\n name: 'flip',\n options: {\n fallbackPlacements: explicitPlacementOrderPreference,\n },\n });\n // we apply an offset if the app defines one or if the app wants the arrow\n if (!explicitAppWithoutArrow || explictAppOffset) {\n const defaultOffset = explictAppOffset || [0, 14];\n mod.push({\n name: 'offset',\n enabled: true,\n options: {\n offset: defaultOffset,\n },\n });\n }\n // the app can opt for a \"no arrow\" implementation (we do so in datatable/calendar etc...)\n if (!explicitAppWithoutArrow)
|
|
1
|
+
{"version":3,"file":"useConfiguredDefaultModifiers.js","sources":["../../../src/config/useConfiguredDefaultModifiers.tsx"],"sourcesContent":["import { useMemo } from 'react';\n\nexport const useConfiguredDefaultModifiers = ({ props, arrowElement }) => {\n // we destructure explicit app definitions before merge\n const {\n boundaryElement: explicitAppBoundaryElement,\n withoutArrow: explicitAppWithoutArrow = false,\n placementOrderPreference: explicitPlacementOrderPreference = ['top', 'bottom', 'left', 'right'],\n customOffset: explictAppOffset = undefined,\n } = props;\n // to build default modifiers on top of it\n const defaultModifiers = useMemo(() => {\n const mod = [];\n mod.push({ name: 'hide', enabled: true });\n mod.push({\n name: 'flip',\n options: {\n fallbackPlacements: explicitPlacementOrderPreference,\n },\n });\n // we apply an offset if the app defines one or if the app wants the arrow\n if (!explicitAppWithoutArrow || explictAppOffset) {\n const defaultOffset = explictAppOffset || [0, 14];\n mod.push({\n name: 'offset',\n enabled: true,\n options: {\n offset: defaultOffset,\n },\n });\n }\n // the app can opt for a \"no arrow\" implementation (we do so in datatable/calendar etc...)\n if (!explicitAppWithoutArrow)\n mod.push({\n name: 'arrow',\n options: {\n element: arrowElement,\n padding: 18,\n },\n });\n\n // the app can define an explicit element to act as a boundary instead of popperjs default one\n if (explicitAppBoundaryElement)\n mod.push({\n name: 'preventOverflow',\n options: {\n boundary: explicitAppBoundaryElement,\n },\n });\n return mod;\n }, [\n arrowElement,\n explicitAppBoundaryElement,\n explicitAppWithoutArrow,\n explicitPlacementOrderPreference,\n explictAppOffset,\n ]);\n // if the app pass custom modifier, we don't use \"default modifiers\"\n const { modifiers: explicitAppModifiers = defaultModifiers } = props;\n\n return useMemo(\n () => ({\n modifiers: explicitAppModifiers,\n }),\n [explicitAppModifiers],\n );\n};\n"],"names":["useConfiguredDefaultModifiers","props","arrowElement","explicitAppBoundaryElement","boundaryElement","withoutArrow","explicitAppWithoutArrow","placementOrderPreference","explicitPlacementOrderPreference","customOffset","explictAppOffset","undefined","defaultModifiers","useMemo","mod","push","name","enabled","options","fallbackPlacements","defaultOffset","offset","element","padding","boundary","modifiers","explicitAppModifiers"],"mappings":";;;;;;IAEaA,6BAA6B,GAAG,SAAhCA,6BAAgC,OAA6B;AAAA,MAA1BC,KAA0B,QAA1BA,KAA0B;AAAA,MAAnBC,YAAmB,QAAnBA,YAAmB;AACxE;AACA,MACmBC,0BADnB,GAKIF,KALJ,CACEG,eADF;AAAA,4BAKIH,KALJ,CAEEI,YAFF;AAAA,MAEgBC,uBAFhB,oCAE0C,KAF1C;AAAA,8BAKIL,KALJ,CAGEM,wBAHF;AAAA,MAG4BC,gCAH5B,sCAG+D,CAAC,KAAD,EAAQ,QAAR,EAAkB,MAAlB,EAA0B,OAA1B,CAH/D;AAAA,4BAKIP,KALJ,CAIEQ,YAJF;AAAA,MAIgBC,gBAJhB,oCAImCC,SAJnC,uBAFwE;;AASxE,M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C,aAAO,CACZ;AAAA,WAAO;AACLY,MAAAA,SAAS,EAAEC;AADN,KAAP;AAAA,GADY,EAIZ,CAACA,oBAAD,CAJY,CAAd;AAMD;;;;"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
-
var React = require('react');
|
|
6
|
+
var React$1 = require('react');
|
|
7
7
|
var config_useConfiguredDefaultModifiers = require('./useConfiguredDefaultModifiers.js');
|
|
8
8
|
|
|
9
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -16,19 +16,23 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
16
16
|
|
|
17
17
|
var noop = function noop() {};
|
|
18
18
|
|
|
19
|
-
var 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
|
var useConfiguredDefaultProps = function useConfiguredDefaultProps(_ref) {
|
|
30
20
|
var props = _ref.props,
|
|
31
21
|
arrowElement = _ref.arrowElement;
|
|
22
|
+
// don't move this out of the hook or `document.body` will explode
|
|
23
|
+
var staticDefaultProps = React.useMemo(function () {
|
|
24
|
+
return {
|
|
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
|
+
};
|
|
35
|
+
}, []);
|
|
32
36
|
|
|
33
37
|
var _useConfiguredDefault = config_useConfiguredDefaultModifiers.useConfiguredDefaultModifiers({
|
|
34
38
|
props: props,
|
|
@@ -36,11 +40,11 @@ var useConfiguredDefaultProps = function useConfiguredDefaultProps(_ref) {
|
|
|
36
40
|
}),
|
|
37
41
|
configuredModifiers = _useConfiguredDefault.modifiers;
|
|
38
42
|
|
|
39
|
-
var defaultProps = React.useMemo(function () {
|
|
43
|
+
var defaultProps = React$1.useMemo(function () {
|
|
40
44
|
return _objectSpread(_objectSpread({}, staticDefaultProps), {}, {
|
|
41
45
|
modifiers: configuredModifiers
|
|
42
46
|
});
|
|
43
|
-
}, [configuredModifiers]);
|
|
47
|
+
}, [configuredModifiers, staticDefaultProps]);
|
|
44
48
|
return defaultProps;
|
|
45
49
|
};
|
|
46
50
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConfiguredDefaultProps.js","sources":["../../../src/config/useConfiguredDefaultProps.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { useConfiguredDefaultModifiers } from './useConfiguredDefaultModifiers';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = () => {};\n\
|
|
1
|
+
{"version":3,"file":"useConfiguredDefaultProps.js","sources":["../../../src/config/useConfiguredDefaultProps.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { useConfiguredDefaultModifiers } from './useConfiguredDefaultModifiers';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = () => {};\n\nexport const useConfiguredDefaultProps = ({ props, arrowElement }) => {\n // don't move this out of the hook or `document.body` will explode\n const staticDefaultProps = React.useMemo(\n () => ({\n referenceElement: null,\n showPopover: false,\n closeContextMenu: noop,\n withoutPortal: false,\n withoutArrow: false,\n portalDOMContainer: document.body,\n startPlacementPreference: 'top',\n placementOrderPreference: ['top', 'bottom', 'left', 'right'],\n zIndex: 1,\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"],"names":["noop","useConfiguredDefaultProps","props","arrowElement","staticDefaultProps","React","useMemo","referenceElement","showPopover","closeContextMenu","withoutPortal","withoutArrow","portalDOMContainer","document","body","startPlacementPreference","placementOrderPreference","zIndex","useConfiguredDefaultModifiers","configuredModifiers","modifiers","defaultProps"],"mappings":";;;;;;;;;;;;;;;;AAIA,IAAMA,IAAI,GAAG,SAAPA,IAAO,GAAM,EAAnB;;IAEaC,yBAAyB,GAAG,SAA5BA,yBAA4B,OAA6B;AAAA,MAA1BC,KAA0B,QAA1BA,KAA0B;AAAA,MAAnBC,YAAmB,QAAnBA,YAAmB;AACpE;AACA,MAAMC,kBAAkB,GAAGC,KAAK,CAACC,OAAN,CACzB;AAAA,WAAO;AACLC,MAAAA,gBAAgB,EAAE,IADb;AAELC,MAAAA,WAAW,EAAE,KAFR;AAGLC,MAAAA,gBAAgB,EAAET,IAHb;AAILU,MAAAA,aAAa,EAAE,KAJV;AAKLC,MAAAA,YAAY,EAAE,KALT;AAMLC,MAAAA,kBAAkB,EAAEC,QAAQ,CAACC,IANxB;AAOLC,MAAAA,wBAAwB,EAAE,KAPrB;AAQLC,MAAAA,wBAAwB,EAAE,CAAC,KAAD,EAAQ,QAAR,EAAkB,MAAlB,EAA0B,OAA1B,CARrB;AASLC,MAAAA,MAAM,EAAE;AATH,KAAP;AAAA,GADyB,EAYzB,EAZyB,CAA3B;;AAcA,8BAA2CC,kEAA6B,CAAC;AACvEhB,IAAAA,KAAK,EAALA,KADuE;AAEvEC,IAAAA,YAAY,EAAZA;AAFuE,GAAD,CAAxE;AAAA,MAAmBgB,mBAAnB,yBAAQC,SAAR;;AAKA,MAAMC,YAAY,GAAGf,eAAO,CAC1B;AAAA,2CAAYF,kBAAZ;AAAgCgB,MAAAA,SAAS,EAAED;AAA3C;AAAA,GAD0B,EAE1B,CAACA,mBAAD,EAAsBf,kBAAtB,CAF0B,CAA5B;AAKA,SAAOiB,YAAP;AACD;;;;"}
|
package/cjs/index.js
CHANGED
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var reactDom = require('react-dom');
|
|
7
|
+
var reactDesc = require('react-desc');
|
|
8
|
+
var propTypes = require('./propTypes.js');
|
|
7
9
|
var PopoverContent = require('./PopoverContent.js');
|
|
8
10
|
var config_useConfigDSPopperjs = require('./config/useConfigDSPopperjs.js');
|
|
9
11
|
require('@babel/runtime/helpers/extends');
|
|
@@ -57,5 +59,11 @@ var DSPopperJS = function DSPopperJS(props) {
|
|
|
57
59
|
return null;
|
|
58
60
|
};
|
|
59
61
|
|
|
62
|
+
DSPopperJS.propTypes = propTypes.dspopperjsPropTypes;
|
|
63
|
+
var DSPopperJSWithSchema = reactDesc.describe(DSPopperJS).description('A dimsum custom styling wrapper on top of popperjs');
|
|
64
|
+
DSPopperJSWithSchema.propTypes = propTypes.dspopperjsPropTypes;
|
|
65
|
+
|
|
60
66
|
exports.DSPopperJS = DSPopperJS;
|
|
67
|
+
exports.DSPopperJSWithSchema = DSPopperJSWithSchema;
|
|
68
|
+
exports['default'] = DSPopperJS;
|
|
61
69
|
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { createPortal } from 'react-dom';\nimport { PopoverContent } from './PopoverContent';\nimport { useConfigDSPopperjs } from './config/useConfigDSPopperjs';\nimport type { DSDSPopperjsPropsT } from './index.d';\n\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["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: { showPopover, withoutPortal, withoutArrow, portalDOMContainer, zIndex },\n setPopperElement,\n setArrowElement,\n popoverHelper,\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}\n popperAttributes={attributes.popper}\n setArrowElement={setArrowElement}\n arrowStyle={styles.arrow}\n withoutArrow={withoutArrow}\n zIndex={zIndex}\n >\n {children}\n </PopoverContent>\n ),\n [attributes.popper, children, setArrowElement, setPopperElement, styles.arrow, styles.popper, withoutArrow, zIndex],\n );\n if (showPopover) {\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"],"names":["DSPopperJS","props","useConfigDSPopperjs","showPopover","withoutPortal","withoutArrow","portalDOMContainer","zIndex","setPopperElement","setArrowElement","popoverHelper","children","styles","attributes","contentJSX","useMemo","React","PopoverContent","popper","arrow","createPortal","propTypes","dspopperjsPropTypes","DSPopperJSWithSchema","describe","description"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;IAQMA,UAAU,GAAG,SAAbA,UAAa,CAACC,KAAD,EAA4C;AAC7D,6BAKIC,8CAAmB,CAACD,KAAD,CALvB;AAAA,mDACEA,KADF;AAA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,oBAAoB,GAAGC,kBAAQ,CAACxB,UAAD,CAAR,CAAqByB,WAArB,CAAiC,oDAAjC;AAC7BF,oBAAoB,CAACF,SAArB,GAAiCC,6BAAjC;;;;;;"}
|
package/cjs/propTypes.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var reactDesc = require('react-desc');
|
|
6
|
+
|
|
7
|
+
var 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;
|
|
73
|
+
//# sourceMappingURL=propTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propTypes.js","sources":["../../src/propTypes.tsx"],"sourcesContent":["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 * 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};\n"],"names":["dspopperjsPropTypes","referenceElement","PropTypes","element","description","isRequired","showPopover","bool","closeContextMenu","func","defaultValue","withoutPortal","withoutArrow","boundaryElement","undefined","portalDOMContainer","startPlacementPreference","oneOf","placementOrderPreference","arrayOf","zIndex","number","customOffset","modifiers","array"],"mappings":";;;;;;IAEaA,mBAAmB,GAAG;AACjC;AACF;AACA;AACEC,EAAAA,gBAAgB,EAAEC,mBAAS,CAACC,OAAV,CAAkBC,WAAlB,CAA8B,+BAA9B,EAA+DC,UAJhD;;AAKjC;AACF;AACA;AACEC,EAAAA,WAAW,EAAEJ,mBAAS,CAACK,IAAV,CAAeH,WAAf,CAA2B,2CAA3B,EAAwEC,UARpD;;AASjC;AACF;AACA;AACA;AACEG,EAAAA,gBAAgB,EAAEN,mBAAS,CAACO,IAAV,CACfL,WADe,CAEd,qEACE,0DAHY,EAKfM,YALe,CAKF,UALE,CAbe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B,EAAyDM,YAAzD,CAAsE,CAAtE,CA1FyB;;AA2FjC;AACF;AACA;AACEY,EAAAA,YAAY,EAAEpB,mBAAS,CAACiB,OAAV,CAAkBjB,mBAAS,CAACmB,MAA5B,EAAoCjB,WAApC,CAAgD,wBAAhD,EAA0EM,YAA1E,CAAuF,CAAvF,CA9FmB;;AA+FjC;AACF;AACA;AACA;AACEa,EAAAA,SAAS,EAAErB,mBAAS,CAACsB,KAAV,CACRpB,WADQ,CACI,8FADJ,EAERM,YAFQ,CAEK,CAFL;AAnGsB;;;;"}
|
package/esm/PopoverContent.js
CHANGED
|
@@ -5,7 +5,7 @@ import { PopoverArrow } from './PopoverArrow.js';
|
|
|
5
5
|
|
|
6
6
|
var StyledPopoverContentWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
7
7
|
componentId: "sc-1gxm7np-0"
|
|
8
|
-
})(["
|
|
8
|
+
})(["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:", ";"], function (_ref) {
|
|
9
9
|
var zIndex = _ref.zIndex;
|
|
10
10
|
return zIndex;
|
|
11
11
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverContent.js","sources":["../../src/PopoverContent.tsx"],"sourcesContent":["import React from 'react';\nimport styled from 'styled-components';\nimport { PopoverArrow } from './PopoverArrow';\nimport type { PopoverContentPropsT } from './index.d';\n\ninterface StyledContentWrapperPropsT {\n zIndex: number;\n}\nconst StyledPopoverContentWrapper = styled.div<StyledContentWrapperPropsT>`\n
|
|
1
|
+
{"version":3,"file":"PopoverContent.js","sources":["../../src/PopoverContent.tsx"],"sourcesContent":["import React from 'react';\nimport styled from 'styled-components';\nimport { PopoverArrow } from './PopoverArrow';\nimport type { PopoverContentPropsT } from './index.d';\n\ninterface StyledContentWrapperPropsT {\n zIndex: number;\n}\nconst StyledPopoverContentWrapper = styled.div<StyledContentWrapperPropsT>`\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 z-index: ${({ zIndex }) => zIndex};\n`;\n\nexport const PopoverContent = ({\n setPopperElement,\n popperStyles,\n popperAttributes,\n children,\n setArrowElement,\n arrowStyle,\n withoutArrow,\n zIndex,\n}: PopoverContentPropsT): JSX.Element => (\n <StyledPopoverContentWrapper zIndex={zIndex} ref={setPopperElement} style={popperStyles} {...popperAttributes}>\n {children}\n {withoutArrow === false ? (\n <>\n <PopoverArrow\n arrowElementRef={setArrowElement}\n style={arrowStyle}\n placement={popperAttributes ? popperAttributes['data-popper-placement'] : 'bottom'}\n />\n <div ref={setArrowElement} style={arrowStyle} />\n </>\n ) : null}\n </StyledPopoverContentWrapper>\n);\n"],"names":["StyledPopoverContentWrapper","styled","div","zIndex","PopoverContent","setPopperElement","popperStyles","popperAttributes","children","setArrowElement","arrowStyle","withoutArrow"],"mappings":";;;;;AAQA,IAAMA,2BAA2B,gBAAGC,MAAM,CAACC,GAAV;AAAA;AAAA,yHAEpB;AAAA,MAAGC,MAAH,QAAGA,MAAH;AAAA,SAAgBA,MAAhB;AAAA,CAFoB,CAAjC;IAKaC,cAAc,GAAG,SAAjBA,cAAiB;AAAA,MAC5BC,gBAD4B,SAC5BA,gBAD4B;AAAA,MAE5BC,YAF4B,SAE5BA,YAF4B;AAAA,MAG5BC,gBAH4B,SAG5BA,gBAH4B;AAAA,MAI5BC,QAJ4B,SAI5BA,QAJ4B;AAAA,MAK5BC,eAL4B,SAK5BA,eAL4B;AAAA,MAM5BC,UAN4B,SAM5BA,UAN4B;AAAA,MAO5BC,YAP4B,SAO5BA,YAP4B;AAAA,MAQ5BR,MAR4B,SAQ5BA,MAR4B;AAAA,sBAU5B,oBAAC,2BAAD;AAA6B,IAAA,MAAM,EAAEA,MAArC;AAA6C,IAAA,GAAG,EAAEE,gBAAlD;AAAoE,IAAA,KAAK,EAAEC;AAA3E,KAA6FC,gBAA7F,GACGC,QADH,EAEGG,YAAY,KAAK,KAAjB,gBACC,uDACE,oBAAC,YAAD;AACE,IAAA,eAAe,EAAEF,eADnB;AAEE,IAAA,KAAK,EAAEC,UAFT;AAGE,IAAA,SAAS,EAAEH,gBAAgB,GAAGA,gBAAgB,CAAC,uBAAD,CAAnB,GAA+C;AAH5E,IADF,eAME;AAAK,IAAA,GAAG,EAAEE,eAAV;AAA2B,IAAA,KAAK,EAAEC;AAAlC,IANF,CADD,GASG,IAXN,CAV4B;AAAA;;;;"}
|
|
@@ -25,17 +25,19 @@ var useConfigDSPopperjs = function useConfigDSPopperjs(appProps) {
|
|
|
25
25
|
});
|
|
26
26
|
var referenceElement = props.referenceElement,
|
|
27
27
|
closeContextMenu = props.closeContextMenu,
|
|
28
|
-
modifiers = props.modifiers
|
|
28
|
+
modifiers = props.modifiers,
|
|
29
|
+
startPlacementPreference = props.startPlacementPreference;
|
|
29
30
|
var popperExtraOpts = useMemo(function () {
|
|
30
31
|
return {
|
|
32
|
+
placement: startPlacementPreference,
|
|
31
33
|
modifiers: modifiers
|
|
32
34
|
};
|
|
33
|
-
}, [modifiers]);
|
|
35
|
+
}, [modifiers, startPlacementPreference]);
|
|
34
36
|
var popoverHelper = usePopper(referenceElement, popperElement, popperExtraOpts);
|
|
35
37
|
useOnClickOutside(popperElement, function (e) {
|
|
36
|
-
var _referenceElement$
|
|
38
|
+
var _referenceElement$con;
|
|
37
39
|
|
|
38
|
-
if (!(referenceElement !== null && referenceElement !== void 0 && (_referenceElement$
|
|
40
|
+
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();
|
|
39
41
|
});
|
|
40
42
|
return useMemo(function () {
|
|
41
43
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConfigDSPopperjs.js","sources":["../../../src/config/useConfigDSPopperjs.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { usePopper } from 'react-popper';\nimport { useConfiguredMergedProps } from './useConfiguredMergedProps';\nimport type { useDSPopperjsPropsArgT, useDSPopperjsRT } from '../index.d';\n\nimport { useOnClickOutside } from '../utils/hooks/useOnClickOutside';\n\nexport const useConfigDSPopperjs = (appProps: useDSPopperjsPropsArgT): useDSPopperjsRT => {\n const [popperElement, setPopperElement] = useState(null);\n const [arrowElement, setArrowElement] = useState(null);\n\n const props = useConfiguredMergedProps({ props: appProps, arrowElement });\n const { referenceElement, closeContextMenu, modifiers } = props;\n const popperExtraOpts = useMemo(() => ({ modifiers }),
|
|
1
|
+
{"version":3,"file":"useConfigDSPopperjs.js","sources":["../../../src/config/useConfigDSPopperjs.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { usePopper } from 'react-popper';\nimport { useConfiguredMergedProps } from './useConfiguredMergedProps';\nimport type { useDSPopperjsPropsArgT, useDSPopperjsRT } from '../index.d';\n\nimport { useOnClickOutside } from '../utils/hooks/useOnClickOutside';\n\nexport const useConfigDSPopperjs = (appProps: useDSPopperjsPropsArgT): useDSPopperjsRT => {\n const [popperElement, setPopperElement] = useState(null);\n const [arrowElement, setArrowElement] = useState(null);\n\n const props = useConfiguredMergedProps({ props: appProps, arrowElement });\n const { referenceElement, closeContextMenu, modifiers, startPlacementPreference } = props;\n const popperExtraOpts = useMemo(\n () => ({ placement: startPlacementPreference, modifiers }),\n [modifiers, startPlacementPreference],\n );\n\n const popoverHelper = usePopper(referenceElement, popperElement, popperExtraOpts);\n\n useOnClickOutside(popperElement, (e) => {\n if (!referenceElement?.contains?.(e?.target)) closeContextMenu();\n });\n\n return useMemo(\n () => ({\n props,\n popperElement,\n setPopperElement,\n arrowElement,\n setArrowElement,\n popoverHelper,\n }),\n [arrowElement, popoverHelper, popperElement, props],\n );\n};\n"],"names":["useConfigDSPopperjs","appProps","useState","popperElement","setPopperElement","arrowElement","setArrowElement","props","useConfiguredMergedProps","referenceElement","closeContextMenu","modifiers","startPlacementPreference","popperExtraOpts","useMemo","placement","popoverHelper","usePopper","useOnClickOutside","e","contains","target"],"mappings":";;;;;;;;;;IAOaA,mBAAmB,GAAG,SAAtBA,mBAAsB,CAACC,QAAD,EAAuD;AACxF,kBAA0CC,QAAQ,CAAC,IAAD,CAAlD;AAAA;AAAA,MAAOC,aAAP;AAAA,MAAsBC,gBAAtB;;AACA,mBAAwCF,QAAQ,CAAC,IAAD,CAAhD;AAAA;AAAA,MAAOG,YAAP;AAAA,MAAqBC,eAArB;;AAEA,MAAMC,KAAK,GAAGC,wBAAwB,CAAC;AAAED,IAAAA,KAAK,EAAEN,QAAT;AAAmBI,IAAAA,YAAY,EAAZA;AAAnB,GAAD,CAAtC;AACA,MAAQI,gBAAR,GAAoFF,KAApF,CAAQE,gBAAR;AAAA,MAA0BC,gBAA1B,GAAoFH,KAApF,CAA0BG,gBAA1B;AAAA,MAA4CC,SAA5C,GAAoFJ,KAApF,CAA4CI,SAA5C;AAAA,MAAuDC,wBAAvD,GAAoFL,KAApF,CAAuDK,wBAAvD;AACA,MAAMC,eAAe,GAAGC,OAAO,CAC7B;AAAA,WAAO;AAAEC,MAAAA,SAAS,EAAEH,wBAAb;AAAuCD,MAAAA,SAAS,EAATA;AAAvC,KAAP;AAAA,GAD6B,EAE7B,CAACA,SAAD,EAAYC,wBAAZ,CAF6B,CAA/B;AAKA,MAAMI,aAAa,GAAGC,SAAS,CAACR,gBAAD,EAAmBN,aAAnB,EAAkCU,eAAlC,CAA/B;AAEAK,EAAAA,iBAAiB,CAACf,aAAD,EAAgB,UAACgB,CAAD,EAAO;AAAA;;AACtC,QAAI,EAACV,gBAAD,aAACA,gBAAD,wCAACA,gBAAgB,CAAEW,QAAnB,kDAAC,2BAAAX,gBAAgB,EAAaU,CAAb,aAAaA,CAAb,uBAAaA,CAAC,CAAEE,MAAhB,CAAjB,CAAJ,EAA8CX,gBAAgB;AAC/D,GAFgB,CAAjB;AAIA,SAAOI,OAAO,CACZ;AAAA,WAAO;AACLP,MAAAA,KAAK,EAALA,KADK;AAELJ,MAAAA,aAAa,EAAbA,aAFK;AAGLC,MAAAA,gBAAgB,EAAhBA,gBAHK;AAILC,MAAAA,YAAY,EAAZA,YAJK;AAKLC,MAAAA,eAAe,EAAfA,eALK;AAMLU,MAAAA,aAAa,EAAbA;AANK,KAAP;AAAA,GADY,EASZ,CAACX,YAAD,EAAeW,aAAf,EAA8Bb,aAA9B,EAA6CI,KAA7C,CATY,CAAd;AAWD;;;;"}
|
|
@@ -40,7 +40,8 @@ var useConfiguredDefaultModifiers = function useConfiguredDefaultModifiers(_ref)
|
|
|
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
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConfiguredDefaultModifiers.js","sources":["../../../src/config/useConfiguredDefaultModifiers.tsx"],"sourcesContent":["import { useMemo } from 'react';\n\nexport const useConfiguredDefaultModifiers = ({ props, arrowElement }) => {\n // we destructure explicit app definitions before merge\n const {\n boundaryElement: explicitAppBoundaryElement,\n withoutArrow: explicitAppWithoutArrow = false,\n placementOrderPreference: explicitPlacementOrderPreference = ['top', 'bottom', 'left', 'right'],\n customOffset: explictAppOffset = undefined,\n } = props;\n // to build default modifiers on top of it\n const defaultModifiers = useMemo(() => {\n const mod = [];\n mod.push({ name: 'hide', enabled: true });\n mod.push({\n name: 'flip',\n options: {\n fallbackPlacements: explicitPlacementOrderPreference,\n },\n });\n // we apply an offset if the app defines one or if the app wants the arrow\n if (!explicitAppWithoutArrow || explictAppOffset) {\n const defaultOffset = explictAppOffset || [0, 14];\n mod.push({\n name: 'offset',\n enabled: true,\n options: {\n offset: defaultOffset,\n },\n });\n }\n // the app can opt for a \"no arrow\" implementation (we do so in datatable/calendar etc...)\n if (!explicitAppWithoutArrow)
|
|
1
|
+
{"version":3,"file":"useConfiguredDefaultModifiers.js","sources":["../../../src/config/useConfiguredDefaultModifiers.tsx"],"sourcesContent":["import { useMemo } from 'react';\n\nexport const useConfiguredDefaultModifiers = ({ props, arrowElement }) => {\n // we destructure explicit app definitions before merge\n const {\n boundaryElement: explicitAppBoundaryElement,\n withoutArrow: explicitAppWithoutArrow = false,\n placementOrderPreference: explicitPlacementOrderPreference = ['top', 'bottom', 'left', 'right'],\n customOffset: explictAppOffset = undefined,\n } = props;\n // to build default modifiers on top of it\n const defaultModifiers = useMemo(() => {\n const mod = [];\n mod.push({ name: 'hide', enabled: true });\n mod.push({\n name: 'flip',\n options: {\n fallbackPlacements: explicitPlacementOrderPreference,\n },\n });\n // we apply an offset if the app defines one or if the app wants the arrow\n if (!explicitAppWithoutArrow || explictAppOffset) {\n const defaultOffset = explictAppOffset || [0, 14];\n mod.push({\n name: 'offset',\n enabled: true,\n options: {\n offset: defaultOffset,\n },\n });\n }\n // the app can opt for a \"no arrow\" implementation (we do so in datatable/calendar etc...)\n if (!explicitAppWithoutArrow)\n mod.push({\n name: 'arrow',\n options: {\n element: arrowElement,\n padding: 18,\n },\n });\n\n // the app can define an explicit element to act as a boundary instead of popperjs default one\n if (explicitAppBoundaryElement)\n mod.push({\n name: 'preventOverflow',\n options: {\n boundary: explicitAppBoundaryElement,\n },\n });\n return mod;\n }, [\n arrowElement,\n explicitAppBoundaryElement,\n explicitAppWithoutArrow,\n explicitPlacementOrderPreference,\n explictAppOffset,\n ]);\n // if the app pass custom modifier, we don't use \"default modifiers\"\n const { modifiers: explicitAppModifiers = defaultModifiers } = props;\n\n return useMemo(\n () => ({\n modifiers: explicitAppModifiers,\n }),\n [explicitAppModifiers],\n );\n};\n"],"names":["useConfiguredDefaultModifiers","props","arrowElement","explicitAppBoundaryElement","boundaryElement","withoutArrow","explicitAppWithoutArrow","placementOrderPreference","explicitPlacementOrderPreference","customOffset","explictAppOffset","undefined","defaultModifiers","useMemo","mod","push","name","enabled","options","fallbackPlacements","defaultOffset","offset","element","padding","boundary","modifiers","explicitAppModifiers"],"mappings":";;IAEaA,6BAA6B,GAAG,SAAhCA,6BAAgC,OAA6B;AAAA,MAA1BC,KAA0B,QAA1BA,KAA0B;AAAA,MAAnBC,YAAmB,QAAnBA,YAAmB;AACxE;AACA,MACmBC,0BADnB,GAKIF,KALJ,CACEG,eADF;AAAA,4BAKIH,KALJ,CAEEI,YAFF;AAAA,MAEgBC,uBAFhB,oCAE0C,KAF1C;AAAA,8BAKIL,KALJ,CAGEM,wBAHF;AAAA,MAG4BC,gCAH5B,sCAG+D,CAAC,KAAD,EAAQ,QAAR,EAAkB,MAAlB,EAA0B,OAA1B,CAH/D;AAAA,4BAKIP,KALJ,CAIEQ,YAJF;AAAA,MAIgBC,gBAJhB,oCAImCC,SAJnC,uBAFwE;;AASxE,MAAMC,gBAAgB,GAAGC,OAAO,CAAC,YAAM;AACrC,QAAMC,GAAG,GAAG,EAAZ;AACAA,IAAAA,GAAG,CAACC,IAAJ,CAAS;AAAEC,MAAAA,IAAI,EAAE,MAAR;AAAgBC,MAAAA,OAAO,EAAE;AAAzB,KAAT;AACAH,IAAAA,GAAG,CAACC,IAAJ,CAAS;AACPC,MAAAA,IAAI,EAAE,MADC;AAEPE,MAAAA,OAAO,EAAE;AACPC,QAAAA,kBAAkB,EAAEX;AADb;AAFF,KAAT,EAHqC;;AAUrC,QAAI,CAACF,uBAAD,IAA4BI,gBAAhC,EAAkD;AAChD,UAAMU,aAAa,GAAGV,gBAAgB,IAAI,CAAC,CAAD,EAAI,EAAJ,CAA1C;AACAI,MAAAA,GAAG,CAACC,IAAJ,CAAS;AACPC,QAAAA,IAAI,EAAE,QADC;AAEPC,QAAAA,OAAO,EAAE,IAFF;AAGPC,QAAAA,OAAO,EAAE;AACPG,UAAAA,MAAM,EAAED;AADD;AAHF,OAAT;AAOD,KAnBoC;;;AAqBrC,QAAI,CAACd,uBAAL,EACEQ,GAAG,CAACC,IAAJ,CAAS;AACPC,MAAAA,IAAI,EAAE,OADC;AAEPE,MAAAA,OAAO,EAAE;AACPI,QAAAA,OAAO,EAAEpB,YADF;AAEPqB,QAAAA,OAAO,EAAE;AAFF;AAFF,KAAT,EAtBmC;;AA+BrC,QAAIpB,0BAAJ,EACEW,GAAG,CAACC,IAAJ,CAAS;AACPC,MAAAA,IAAI,EAAE,iBADC;AAEPE,MAAAA,OAAO,EAAE;AACPM,QAAAA,QAAQ,EAAErB;AADH;AAFF,KAAT;AAMF,WAAOW,GAAP;AACD,GAvC+B,EAuC7B,CACDZ,YADC,EAEDC,0BAFC,EAGDG,uBAHC,EAIDE,gCAJC,EAKDE,gBALC,CAvC6B,CAAhC,CATwE;;AAwDxE,yBAA+DT,KAA/D,CAAQwB,SAAR;AAAA,MAAmBC,oBAAnB,iCAA0Cd,gBAA1C;AAEA,SAAOC,OAAO,CACZ;AAAA,WAAO;AACLY,MAAAA,SAAS,EAAEC;AADN,KAAP;AAAA,GADY,EAIZ,CAACA,oBAAD,CAJY,CAAd;AAMD;;;;"}
|
|
@@ -8,19 +8,23 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
8
8
|
|
|
9
9
|
var noop = function noop() {};
|
|
10
10
|
|
|
11
|
-
var 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
|
var useConfiguredDefaultProps = function useConfiguredDefaultProps(_ref) {
|
|
22
12
|
var props = _ref.props,
|
|
23
13
|
arrowElement = _ref.arrowElement;
|
|
14
|
+
// don't move this out of the hook or `document.body` will explode
|
|
15
|
+
var staticDefaultProps = React.useMemo(function () {
|
|
16
|
+
return {
|
|
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
|
+
};
|
|
27
|
+
}, []);
|
|
24
28
|
|
|
25
29
|
var _useConfiguredDefault = useConfiguredDefaultModifiers({
|
|
26
30
|
props: props,
|
|
@@ -32,7 +36,7 @@ var useConfiguredDefaultProps = function useConfiguredDefaultProps(_ref) {
|
|
|
32
36
|
return _objectSpread(_objectSpread({}, staticDefaultProps), {}, {
|
|
33
37
|
modifiers: configuredModifiers
|
|
34
38
|
});
|
|
35
|
-
}, [configuredModifiers]);
|
|
39
|
+
}, [configuredModifiers, staticDefaultProps]);
|
|
36
40
|
return defaultProps;
|
|
37
41
|
};
|
|
38
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConfiguredDefaultProps.js","sources":["../../../src/config/useConfiguredDefaultProps.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { useConfiguredDefaultModifiers } from './useConfiguredDefaultModifiers';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = () => {};\n\
|
|
1
|
+
{"version":3,"file":"useConfiguredDefaultProps.js","sources":["../../../src/config/useConfiguredDefaultProps.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { useConfiguredDefaultModifiers } from './useConfiguredDefaultModifiers';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = () => {};\n\nexport const useConfiguredDefaultProps = ({ props, arrowElement }) => {\n // don't move this out of the hook or `document.body` will explode\n const staticDefaultProps = React.useMemo(\n () => ({\n referenceElement: null,\n showPopover: false,\n closeContextMenu: noop,\n withoutPortal: false,\n withoutArrow: false,\n portalDOMContainer: document.body,\n startPlacementPreference: 'top',\n placementOrderPreference: ['top', 'bottom', 'left', 'right'],\n zIndex: 1,\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"],"names":["noop","useConfiguredDefaultProps","props","arrowElement","staticDefaultProps","React","useMemo","referenceElement","showPopover","closeContextMenu","withoutPortal","withoutArrow","portalDOMContainer","document","body","startPlacementPreference","placementOrderPreference","zIndex","useConfiguredDefaultModifiers","configuredModifiers","modifiers","defaultProps"],"mappings":";;;;;;;;AAIA,IAAMA,IAAI,GAAG,SAAPA,IAAO,GAAM,EAAnB;;IAEaC,yBAAyB,GAAG,SAA5BA,yBAA4B,OAA6B;AAAA,MAA1BC,KAA0B,QAA1BA,KAA0B;AAAA,MAAnBC,YAAmB,QAAnBA,YAAmB;AACpE;AACA,MAAMC,kBAAkB,GAAGC,KAAK,CAACC,OAAN,CACzB;AAAA,WAAO;AACLC,MAAAA,gBAAgB,EAAE,IADb;AAELC,MAAAA,WAAW,EAAE,KAFR;AAGLC,MAAAA,gBAAgB,EAAET,IAHb;AAILU,MAAAA,aAAa,EAAE,KAJV;AAKLC,MAAAA,YAAY,EAAE,KALT;AAMLC,MAAAA,kBAAkB,EAAEC,QAAQ,CAACC,IANxB;AAOLC,MAAAA,wBAAwB,EAAE,KAPrB;AAQLC,MAAAA,wBAAwB,EAAE,CAAC,KAAD,EAAQ,QAAR,EAAkB,MAAlB,EAA0B,OAA1B,CARrB;AASLC,MAAAA,MAAM,EAAE;AATH,KAAP;AAAA,GADyB,EAYzB,EAZyB,CAA3B;;AAcA,8BAA2CC,6BAA6B,CAAC;AACvEhB,IAAAA,KAAK,EAALA,KADuE;AAEvEC,IAAAA,YAAY,EAAZA;AAFuE,GAAD,CAAxE;AAAA,MAAmBgB,mBAAnB,yBAAQC,SAAR;;AAKA,MAAMC,YAAY,GAAGf,OAAO,CAC1B;AAAA,2CAAYF,kBAAZ;AAAgCgB,MAAAA,SAAS,EAAED;AAA3C;AAAA,GAD0B,EAE1B,CAACA,mBAAD,EAAsBf,kBAAtB,CAF0B,CAA5B;AAKA,SAAOiB,YAAP;AACD;;;;"}
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
|
+
import { describe } from 'react-desc';
|
|
4
|
+
import { dspopperjsPropTypes } from './propTypes.js';
|
|
3
5
|
import { PopoverContent } from './PopoverContent.js';
|
|
4
6
|
import { useConfigDSPopperjs } from './config/useConfigDSPopperjs.js';
|
|
5
7
|
import '@babel/runtime/helpers/esm/extends';
|
|
@@ -49,5 +51,9 @@ var DSPopperJS = function DSPopperJS(props) {
|
|
|
49
51
|
return null;
|
|
50
52
|
};
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
DSPopperJS.propTypes = dspopperjsPropTypes;
|
|
55
|
+
var DSPopperJSWithSchema = describe(DSPopperJS).description('A dimsum custom styling wrapper on top of popperjs');
|
|
56
|
+
DSPopperJSWithSchema.propTypes = dspopperjsPropTypes;
|
|
57
|
+
|
|
58
|
+
export { DSPopperJS, DSPopperJSWithSchema, DSPopperJS as default };
|
|
53
59
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { createPortal } from 'react-dom';\nimport { PopoverContent } from './PopoverContent';\nimport { useConfigDSPopperjs } from './config/useConfigDSPopperjs';\nimport type { DSDSPopperjsPropsT } from './index.d';\n\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["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: { showPopover, withoutPortal, withoutArrow, portalDOMContainer, zIndex },\n setPopperElement,\n setArrowElement,\n popoverHelper,\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}\n popperAttributes={attributes.popper}\n setArrowElement={setArrowElement}\n arrowStyle={styles.arrow}\n withoutArrow={withoutArrow}\n zIndex={zIndex}\n >\n {children}\n </PopoverContent>\n ),\n [attributes.popper, children, setArrowElement, setPopperElement, styles.arrow, styles.popper, withoutArrow, zIndex],\n );\n if (showPopover) {\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"],"names":["DSPopperJS","props","useConfigDSPopperjs","showPopover","withoutPortal","withoutArrow","portalDOMContainer","zIndex","setPopperElement","setArrowElement","popoverHelper","children","styles","attributes","contentJSX","useMemo","popper","arrow","createPortal","propTypes","dspopperjsPropTypes","DSPopperJSWithSchema","describe","description"],"mappings":";;;;;;;;;;;;;;;;;;IAQMA,UAAU,GAAG,SAAbA,UAAa,CAACC,KAAD,EAA4C;AAC7D,6BAKIC,mBAAmB,CAACD,KAAD,CALvB;AAAA,m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AAvB;IAEMC,oBAAoB,GAAGC,QAAQ,CAACtB,UAAD,CAAR,CAAqBuB,WAArB,CAAiC,oDAAjC;AAC7BF,oBAAoB,CAACF,SAArB,GAAiCC,mBAAjC;;;;"}
|
package/esm/propTypes.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { PropTypes } from 'react-desc';
|
|
2
|
+
|
|
3
|
+
var 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 };
|
|
69
|
+
//# sourceMappingURL=propTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propTypes.js","sources":["../../src/propTypes.tsx"],"sourcesContent":["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 * 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};\n"],"names":["dspopperjsPropTypes","referenceElement","PropTypes","element","description","isRequired","showPopover","bool","closeContextMenu","func","defaultValue","withoutPortal","withoutArrow","boundaryElement","undefined","portalDOMContainer","startPlacementPreference","oneOf","placementOrderPreference","arrayOf","zIndex","number","customOffset","modifiers","array"],"mappings":";;IAEaA,mBAAmB,GAAG;AACjC;AACF;AACA;AACEC,EAAAA,gBAAgB,EAAEC,SAAS,CAACC,OAAV,CAAkBC,WAAlB,CAA8B,+BAA9B,EAA+DC,UAJhD;;AAKjC;AACF;AACA;AACEC,EAAAA,WAAW,EAAEJ,SAAS,CAACK,IAAV,CAAeH,WAAf,CAA2B,2CAA3B,EAAwEC,UARpD;;AASjC;AACF;AACA;AACA;AACEG,EAAAA,gBAAgB,EAAEN,SAAS,CAACO,IAAV,CACfL,WADe,CAEd,qEACE,0DAHY,EAKfM,YALe,CAKF,UALE,CAbe;;AAmBjC;AACF;AACA;AACEC,EAAAA,aAAa,EAAET,SAAS,CAACK,IAAV,CACZH,WADY,CACA,wEADA,EAEZM,YAFY,CAEC,IAFD,CAtBkB;;AAyBjC;AACF;AACA;AACEE,EAAAA,YAAY,EAAEV,SAAS,CAACK,IAAV,CACXH,WADW,CACC,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AA+FjC;AACF;AACA;AACA;AACEa,EAAAA,SAAS,EAAErB,SAAS,CAACsB,KAAV,CACRpB,WADQ,CACI,8FADJ,EAERM,YAFQ,CAEK,CAFL;AAnGsB;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-popperjs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.55.0-next.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Ellie Mae - Dim Sum - Popper JS wrapper",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"build": "node ../../scripts/build/build.js"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@elliemae/ds-props-helpers": "1.
|
|
19
|
+
"@elliemae/ds-props-helpers": "1.55.0-next.2",
|
|
20
20
|
"react-desc": "^4.1.2"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|