@elliemae/ds-popperjs 2.3.1 → 3.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/PopoverArrow.js +91 -0
- package/dist/cjs/PopoverArrow.js.map +7 -0
- package/dist/cjs/PopoverContent.js +89 -0
- package/dist/cjs/PopoverContent.js.map +7 -0
- package/dist/cjs/config/useConfigDSPopperjs.js +69 -0
- package/dist/cjs/config/useConfigDSPopperjs.js.map +7 -0
- package/dist/cjs/config/useConfiguredDefaultModifiers.js +89 -0
- package/dist/cjs/config/useConfiguredDefaultModifiers.js.map +7 -0
- package/dist/cjs/config/useConfiguredDefaultProps.js +79 -0
- package/dist/cjs/config/useConfiguredDefaultProps.js.map +7 -0
- package/dist/cjs/config/useConfiguredMergedProps.js +40 -0
- package/dist/cjs/config/useConfiguredMergedProps.js.map +7 -0
- package/dist/cjs/index.d.js +27 -0
- package/dist/cjs/index.d.js.map +7 -0
- package/dist/cjs/index.js +115 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/propTypes.js +80 -0
- package/dist/cjs/propTypes.js.map +7 -0
- package/dist/cjs/styled.js +71 -0
- package/dist/cjs/styled.js.map +7 -0
- package/dist/cjs/utils/hooks/useOnClickOutside.js +51 -0
- package/dist/cjs/utils/hooks/useOnClickOutside.js.map +7 -0
- package/dist/esm/PopoverArrow.js +62 -0
- package/dist/esm/PopoverArrow.js.map +7 -0
- package/dist/esm/PopoverContent.js +62 -0
- package/dist/esm/PopoverContent.js.map +7 -0
- package/dist/esm/config/useConfigDSPopperjs.js +40 -0
- package/dist/esm/config/useConfigDSPopperjs.js.map +7 -0
- package/dist/esm/config/useConfiguredDefaultModifiers.js +60 -0
- package/dist/esm/config/useConfiguredDefaultModifiers.js.map +7 -0
- package/dist/esm/config/useConfiguredDefaultProps.js +52 -0
- package/dist/esm/config/useConfiguredDefaultProps.js.map +7 -0
- package/dist/esm/config/useConfiguredMergedProps.js +11 -0
- package/dist/esm/config/useConfiguredMergedProps.js.map +7 -0
- package/dist/esm/index.d.js +2 -0
- package/dist/esm/index.d.js.map +7 -0
- package/dist/esm/index.js +88 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/propTypes.js +51 -0
- package/dist/esm/propTypes.js.map +7 -0
- package/dist/esm/styled.js +42 -0
- package/dist/esm/styled.js.map +7 -0
- package/dist/esm/utils/hooks/useOnClickOutside.js +22 -0
- package/dist/esm/utils/hooks/useOnClickOutside.js.map +7 -0
- package/package.json +44 -35
- package/cjs/PopoverArrow.js +0 -54
- package/cjs/PopoverContent.js +0 -71
- package/cjs/config/useConfigDSPopperjs.js +0 -60
- package/cjs/config/useConfiguredDefaultModifiers.js +0 -70
- package/cjs/config/useConfiguredDefaultProps.js +0 -58
- package/cjs/config/useConfiguredMergedProps.js +0 -20
- package/cjs/index.d.js +0 -2
- package/cjs/index.js +0 -85
- package/cjs/propTypes.js +0 -85
- package/cjs/styled.js +0 -37
- package/cjs/utils/hooks/useOnClickOutside.js +0 -29
- package/esm/PopoverArrow.js +0 -45
- package/esm/PopoverContent.js +0 -62
- package/esm/config/useConfigDSPopperjs.js +0 -56
- package/esm/config/useConfiguredDefaultModifiers.js +0 -66
- package/esm/config/useConfiguredDefaultProps.js +0 -50
- package/esm/config/useConfiguredMergedProps.js +0 -16
- package/esm/index.d.js +0 -1
- package/esm/index.js +0 -74
- package/esm/propTypes.js +0 -81
- package/esm/styled.js +0 -27
- package/esm/utils/hooks/useOnClickOutside.js +0 -25
- package/types/PopoverArrow.d.ts +0 -8
- package/types/PopoverContent.d.ts +0 -3
- package/types/config/useConfigDSPopperjs.d.ts +0 -2
- package/types/config/useConfiguredDefaultModifiers.d.ts +0 -6
- package/types/config/useConfiguredDefaultProps.d.ts +0 -19
- package/types/config/useConfiguredMergedProps.d.ts +0 -19
- package/types/index.d.ts +0 -58
- package/types/propTypes.d.ts +0 -95
- package/types/styled.d.ts +0 -11
- package/types/utils/hooks/useOnClickOutside.d.ts +0 -4
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
22
|
+
var __export = (target, all) => {
|
|
23
|
+
for (var name in all)
|
|
24
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
+
};
|
|
26
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
27
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
28
|
+
for (let key of __getOwnPropNames(module2))
|
|
29
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
30
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
31
|
+
}
|
|
32
|
+
return target;
|
|
33
|
+
};
|
|
34
|
+
var __toESM = (module2, isNodeMode) => {
|
|
35
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
36
|
+
};
|
|
37
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
38
|
+
return (module2, temp) => {
|
|
39
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
40
|
+
};
|
|
41
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
42
|
+
var src_exports = {};
|
|
43
|
+
__export(src_exports, {
|
|
44
|
+
DSPopperJS: () => DSPopperJS,
|
|
45
|
+
DSPopperJSWithSchema: () => DSPopperJSWithSchema,
|
|
46
|
+
default: () => src_default
|
|
47
|
+
});
|
|
48
|
+
var React = __toESM(require("react"));
|
|
49
|
+
var import_react = __toESM(require("react"));
|
|
50
|
+
var import_react_dom = require("react-dom");
|
|
51
|
+
var import_react_desc = require("react-desc");
|
|
52
|
+
var import_propTypes = require("./propTypes");
|
|
53
|
+
var import_PopoverContent = require("./PopoverContent");
|
|
54
|
+
var import_useConfigDSPopperjs = require("./config/useConfigDSPopperjs");
|
|
55
|
+
const DSPopperJS = (props) => {
|
|
56
|
+
const {
|
|
57
|
+
props: {
|
|
58
|
+
showPopover,
|
|
59
|
+
withoutAnimation,
|
|
60
|
+
animationDuration,
|
|
61
|
+
withoutPortal,
|
|
62
|
+
withoutArrow,
|
|
63
|
+
portalDOMContainer,
|
|
64
|
+
zIndex,
|
|
65
|
+
extraPopperStyles
|
|
66
|
+
},
|
|
67
|
+
setPopperElement,
|
|
68
|
+
setArrowElement,
|
|
69
|
+
setIsAnimating,
|
|
70
|
+
popoverHelper,
|
|
71
|
+
isAnimating
|
|
72
|
+
} = (0, import_useConfigDSPopperjs.useConfigDSPopperjs)(props);
|
|
73
|
+
const { children } = props;
|
|
74
|
+
const { styles, attributes } = popoverHelper;
|
|
75
|
+
const contentJSX = (0, import_react.useMemo)(() => /* @__PURE__ */ import_react.default.createElement(import_PopoverContent.PopoverContent, {
|
|
76
|
+
setPopperElement,
|
|
77
|
+
popperStyles: __spreadValues(__spreadValues({}, styles.popper), extraPopperStyles),
|
|
78
|
+
popperAttributes: attributes.popper,
|
|
79
|
+
setArrowElement,
|
|
80
|
+
arrowStyle: styles.arrow,
|
|
81
|
+
withoutArrow,
|
|
82
|
+
withoutAnimation,
|
|
83
|
+
animationDuration,
|
|
84
|
+
zIndex,
|
|
85
|
+
showPopover,
|
|
86
|
+
setIsAnimating
|
|
87
|
+
}, children), [
|
|
88
|
+
attributes.popper,
|
|
89
|
+
children,
|
|
90
|
+
setIsAnimating,
|
|
91
|
+
showPopover,
|
|
92
|
+
extraPopperStyles,
|
|
93
|
+
setArrowElement,
|
|
94
|
+
setPopperElement,
|
|
95
|
+
styles.arrow,
|
|
96
|
+
styles.popper,
|
|
97
|
+
withoutArrow,
|
|
98
|
+
withoutAnimation,
|
|
99
|
+
animationDuration,
|
|
100
|
+
zIndex
|
|
101
|
+
]);
|
|
102
|
+
if (showPopover || isAnimating) {
|
|
103
|
+
if (withoutPortal === true)
|
|
104
|
+
return contentJSX;
|
|
105
|
+
if (withoutPortal === false)
|
|
106
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, (0, import_react_dom.createPortal)(/* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, contentJSX), portalDOMContainer));
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
};
|
|
110
|
+
DSPopperJS.propTypes = import_propTypes.dspopperjsPropTypes;
|
|
111
|
+
const DSPopperJSWithSchema = (0, import_react_desc.describe)(DSPopperJS).description("A dimsum custom styling wrapper on top of popperjs");
|
|
112
|
+
DSPopperJSWithSchema.propTypes = import_propTypes.dspopperjsPropTypes;
|
|
113
|
+
var src_default = DSPopperJS;
|
|
114
|
+
module.exports = __toCommonJS(src_exports);
|
|
115
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"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: {\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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA+B;AAC/B,uBAA6B;AAC7B,wBAAyB;AACzB,uBAAoC;AACpC,4BAA+B;AAC/B,iCAAoC;AAGpC,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,oDAAoB;AACxB,QAAM,EAAE,aAAa;AACrB,QAAM,EAAE,QAAQ,eAAe;AAC/B,QAAM,aAAa,0BACjB,MACE,mDAAC,sCAAD;AAAA,IACE;AAAA,IACA,cAAc,kCAAK,OAAO,SAAW;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,wFAAG,mCAAa,wFAAG,aAAgB;AAAA;AAEzE,SAAO;AAAA;AAGT,WAAW,YAAY;AAEvB,MAAM,uBAAuB,gCAAS,YAAY,YAAY;AAC9D,qBAAqB,YAAY;AAGjC,IAAO,cAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var propTypes_exports = {};
|
|
29
|
+
__export(propTypes_exports, {
|
|
30
|
+
dspopperjsPropTypes: () => dspopperjsPropTypes
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_react_desc = require("react-desc");
|
|
34
|
+
const dspopperjsPropTypes = {
|
|
35
|
+
referenceElement: import_react_desc.PropTypes.element.description("popperjs DOM referenceElement").isRequired,
|
|
36
|
+
showPopover: import_react_desc.PropTypes.bool.description("whether or not to show the popper content").isRequired,
|
|
37
|
+
closeContextMenu: import_react_desc.PropTypes.func.description('Callback to close the context menu, used for "on click outside", if not provided click outside will not trigger anything').defaultValue("() => {}"),
|
|
38
|
+
withoutPortal: import_react_desc.PropTypes.bool.description("Whether or not the popper content should appear in a DOM portal or not").defaultValue(true),
|
|
39
|
+
withoutArrow: import_react_desc.PropTypes.bool.description("Whether or not the popper context menu should print the arrow").defaultValue(false),
|
|
40
|
+
withoutAnimation: import_react_desc.PropTypes.bool.description("Whether or not the popper context menu should be animated").defaultValue(false),
|
|
41
|
+
animationDuration: import_react_desc.PropTypes.number.description("Popper context menus Animation duration in ms").defaultValue(100),
|
|
42
|
+
boundaryElement: import_react_desc.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),
|
|
43
|
+
portalDOMContainer: import_react_desc.PropTypes.element.description("When using portal, the container in which to append the DOM content, defaults to document body").defaultValue(void 0),
|
|
44
|
+
startPlacementPreference: import_react_desc.PropTypes.oneOf([
|
|
45
|
+
"top-start",
|
|
46
|
+
"top",
|
|
47
|
+
"top-end",
|
|
48
|
+
"right-start",
|
|
49
|
+
"right",
|
|
50
|
+
"right-end",
|
|
51
|
+
"bottom-end",
|
|
52
|
+
"bottom",
|
|
53
|
+
"bottom-start",
|
|
54
|
+
"left-end",
|
|
55
|
+
"left",
|
|
56
|
+
"left-start"
|
|
57
|
+
]).description("start placement preferences, as per popperjs placement option").defaultValue("'top'"),
|
|
58
|
+
placementOrderPreference: import_react_desc.PropTypes.arrayOf(import_react_desc.PropTypes.oneOf([
|
|
59
|
+
"top-start",
|
|
60
|
+
"top",
|
|
61
|
+
"top-end",
|
|
62
|
+
"right-start",
|
|
63
|
+
"right",
|
|
64
|
+
"right-end",
|
|
65
|
+
"bottom-end",
|
|
66
|
+
"bottom",
|
|
67
|
+
"bottom-start",
|
|
68
|
+
"left-end",
|
|
69
|
+
"left",
|
|
70
|
+
"left-start"
|
|
71
|
+
])).description('Array of placement preferences, as per popperjs "flip" placement option').defaultValue("['top', 'bottom', 'left', 'right']"),
|
|
72
|
+
zIndex: import_react_desc.PropTypes.number.description("popperjs content z-index").defaultValue(1),
|
|
73
|
+
customOffset: import_react_desc.PropTypes.arrayOf(import_react_desc.PropTypes.number).description("placement offset array").defaultValue(1),
|
|
74
|
+
modifiers: import_react_desc.PropTypes.array.description("modifiers array for full-custom popper-js override, https://popper.js.org/docs/v2/modifiers/").defaultValue(1),
|
|
75
|
+
extraPopperStyles: import_react_desc.PropTypes.object.description("Extra object styles to attach to the popper element").defaultValue({}),
|
|
76
|
+
onClickOutside: import_react_desc.PropTypes.func.description("Callback triggered when clicking outside the popper").defaultValue(() => null),
|
|
77
|
+
children: import_react_desc.PropTypes.node.description("The content of the popper").defaultValue(void 0)
|
|
78
|
+
};
|
|
79
|
+
module.exports = __toCommonJS(propTypes_exports);
|
|
80
|
+
//# sourceMappingURL=propTypes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/propTypes.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"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 * 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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAA0B;AAEnB,MAAM,sBAAsB;AAAA,EAIjC,kBAAkB,4BAAU,QAAQ,YAAY,iCAAiC;AAAA,EAIjF,aAAa,4BAAU,KAAK,YAAY,6CAA6C;AAAA,EAKrF,kBAAkB,4BAAU,KACzB,YACC,4HAGD,aAAa;AAAA,EAIhB,eAAe,4BAAU,KACtB,YAAY,0EACZ,aAAa;AAAA,EAIhB,cAAc,4BAAU,KACrB,YAAY,iEACZ,aAAa;AAAA,EAIhB,kBAAkB,4BAAU,KACzB,YAAY,6DACZ,aAAa;AAAA,EAIhB,mBAAmB,4BAAU,OAAO,YAAY,iDAAiD,aAAa;AAAA,EAK9G,iBAAiB,4BAAU,QACxB,YACC,gKAGD,aAAa;AAAA,EAIhB,oBAAoB,4BAAU,QAC3B,YAAY,kGACZ,aAAa;AAAA,EAIhB,0BAA0B,4BAAU,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,4BAAU,QAClC,4BAAU,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,4BAAU,OAAO,YAAY,4BAA4B,aAAa;AAAA,EAI9E,cAAc,4BAAU,QAAQ,4BAAU,QAAQ,YAAY,0BAA0B,aAAa;AAAA,EAKrG,WAAW,4BAAU,MAClB,YAAY,gGACZ,aAAa;AAAA,EAChB,mBAAmB,4BAAU,OAC1B,YAAY,uDACZ,aAAa;AAAA,EAChB,gBAAgB,4BAAU,KACvB,YAAY,uDACZ,aAAa,MAAM;AAAA,EACtB,UAAU,4BAAU,KAAK,YAAY,6BAA6B,aAAa;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var styled_exports = {};
|
|
29
|
+
__export(styled_exports, {
|
|
30
|
+
StyledAnimatedPopper: () => StyledAnimatedPopper,
|
|
31
|
+
StyledPopoverContentWrapper: () => StyledPopoverContentWrapper
|
|
32
|
+
});
|
|
33
|
+
var React = __toESM(require("react"));
|
|
34
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
35
|
+
var import_ds_system = require("@elliemae/ds-system");
|
|
36
|
+
const showAnimation = import_ds_system.kfrm`
|
|
37
|
+
from {
|
|
38
|
+
opacity: 0;
|
|
39
|
+
transform: scale(0.8);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
to {
|
|
43
|
+
opacity: 1;
|
|
44
|
+
transform: scale(1);
|
|
45
|
+
visibility: visible;
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
const hideAnimation = import_ds_system.kfrm`
|
|
49
|
+
from {
|
|
50
|
+
opacity: 1;
|
|
51
|
+
transform: scale(1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
to {
|
|
55
|
+
opacity: 0;
|
|
56
|
+
transform: scale(0.8);
|
|
57
|
+
visibility: hidden;
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
const StyledPopoverContentWrapper = import_styled_components.default.div`
|
|
61
|
+
z-index: ${({ zIndex }) => zIndex};
|
|
62
|
+
`;
|
|
63
|
+
const StyledAnimatedPopper = import_styled_components.default.div`
|
|
64
|
+
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);
|
|
65
|
+
|
|
66
|
+
${({ showPopover, animationDuration, withoutAnimation }) => !withoutAnimation && import_ds_system.css`
|
|
67
|
+
animation: ${showPopover ? showAnimation : hideAnimation} ${animationDuration}ms ease-in;
|
|
68
|
+
`}
|
|
69
|
+
`;
|
|
70
|
+
module.exports = __toCommonJS(styled_exports);
|
|
71
|
+
//# sourceMappingURL=styled.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/styled.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,+BAAmB;AACnB,uBAA0B;AAY1B,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,iCAAO;AAAA,aACrC,CAAC,EAAE,aAAa;AAAA;AAGtB,MAAM,uBAAuB,iCAAO;AAAA;AAAA;AAAA,IAGvC,CAAC,EAAE,aAAa,mBAAmB,uBACnC,CAAC,oBACD;AAAA,mBACe,cAAc,gBAAgB,iBAAiB;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var useOnClickOutside_exports = {};
|
|
29
|
+
__export(useOnClickOutside_exports, {
|
|
30
|
+
useOnClickOutside: () => useOnClickOutside
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_react = require("react");
|
|
34
|
+
function useOnClickOutside(ref, cb) {
|
|
35
|
+
(0, import_react.useEffect)(() => {
|
|
36
|
+
const listener = (event) => {
|
|
37
|
+
if (!ref || ref?.contains?.(event.target)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
cb(event);
|
|
41
|
+
};
|
|
42
|
+
document.addEventListener("mousedown", listener);
|
|
43
|
+
document.addEventListener("touchstart", listener);
|
|
44
|
+
return () => {
|
|
45
|
+
document.removeEventListener("mousedown", listener);
|
|
46
|
+
document.removeEventListener("touchstart", listener);
|
|
47
|
+
};
|
|
48
|
+
}, [ref, cb]);
|
|
49
|
+
}
|
|
50
|
+
module.exports = __toCommonJS(useOnClickOutside_exports);
|
|
51
|
+
//# sourceMappingURL=useOnClickOutside.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/utils/hooks/useOnClickOutside.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAiC;AAG1B,2BAAmE,KAAQ,IAAe;AAC/F,8BAAU,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
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
const arrowWidth = 18;
|
|
5
|
+
const arrowHeight = 18;
|
|
6
|
+
const StyledArrow = styled.div`
|
|
7
|
+
position: absolute;
|
|
8
|
+
width: ${arrowWidth}px;
|
|
9
|
+
height: ${arrowHeight}px;
|
|
10
|
+
pointer-events: none;
|
|
11
|
+
background-color: transparent;
|
|
12
|
+
& .stroke {
|
|
13
|
+
fill: ${({ theme }) => theme.colors.neutral["500"]};
|
|
14
|
+
fill-opacity: 0.4;
|
|
15
|
+
}
|
|
16
|
+
& .fill {
|
|
17
|
+
fill: ${({ theme }) => theme.colors.neutral["000"]};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&[data-placement^='top'] {
|
|
21
|
+
svg {
|
|
22
|
+
transform: rotateZ(180deg);
|
|
23
|
+
}
|
|
24
|
+
bottom: -${arrowHeight}px;
|
|
25
|
+
}
|
|
26
|
+
&[data-placement^='right'] {
|
|
27
|
+
svg {
|
|
28
|
+
transform: rotateZ(-90deg);
|
|
29
|
+
}
|
|
30
|
+
left: -${arrowWidth}px;
|
|
31
|
+
}
|
|
32
|
+
&[data-placement^='bottom'] {
|
|
33
|
+
top: -${arrowHeight}px;
|
|
34
|
+
}
|
|
35
|
+
&[data-placement^='left'] {
|
|
36
|
+
svg {
|
|
37
|
+
transform: rotateZ(90deg);
|
|
38
|
+
}
|
|
39
|
+
right: -${arrowWidth}px;
|
|
40
|
+
}
|
|
41
|
+
margin-left: ${(props) => props["data-placement"].startsWith("top") || props["data-placement"].startsWith("bottom") ? `-${arrowWidth / 2}px;` : "0;"};
|
|
42
|
+
margin-top: ${(props) => props["data-placement"].startsWith("left") || props["data-placement"].startsWith("right") ? `-${arrowHeight / 2}px;` : "0;"};
|
|
43
|
+
`;
|
|
44
|
+
const PopoverArrow = ({ placement, style, arrowElementRef }) => /* @__PURE__ */ React2.createElement(StyledArrow, {
|
|
45
|
+
key: "popper-arrow",
|
|
46
|
+
"data-placement": placement,
|
|
47
|
+
style,
|
|
48
|
+
ref: arrowElementRef,
|
|
49
|
+
"data-testid": "ds-tooltip-arrow"
|
|
50
|
+
}, /* @__PURE__ */ React2.createElement("svg", {
|
|
51
|
+
viewBox: "0 0 30 30"
|
|
52
|
+
}, /* @__PURE__ */ React2.createElement("path", {
|
|
53
|
+
className: "stroke",
|
|
54
|
+
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\n C26.7,29,24.6,28.1,23.7,27.1z"
|
|
55
|
+
}), /* @__PURE__ */ React2.createElement("path", {
|
|
56
|
+
className: "fill",
|
|
57
|
+
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"
|
|
58
|
+
})));
|
|
59
|
+
export {
|
|
60
|
+
PopoverArrow
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=PopoverArrow.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/PopoverArrow.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport styled from 'styled-components';\ninterface PopoverArrowT {\n placement: string;\n style: React.CSSProperties;\n arrowElementRef: React.Dispatch<React.SetStateAction<HTMLDivElement>>;\n}\nconst arrowWidth = 18;\nconst arrowHeight = 18;\n\nconst StyledArrow = styled.div`\n position: absolute;\n width: ${arrowWidth}px;\n height: ${arrowHeight}px;\n pointer-events: none;\n background-color: transparent;\n & .stroke {\n fill: ${({ theme }) => theme.colors.neutral['500']};\n fill-opacity: 0.4;\n }\n & .fill {\n fill: ${({ theme }) => theme.colors.neutral['000']};\n }\n\n &[data-placement^='top'] {\n svg {\n transform: rotateZ(180deg);\n }\n bottom: -${arrowHeight}px;\n }\n &[data-placement^='right'] {\n svg {\n transform: rotateZ(-90deg);\n }\n left: -${arrowWidth}px;\n }\n &[data-placement^='bottom'] {\n top: -${arrowHeight}px;\n }\n &[data-placement^='left'] {\n svg {\n transform: rotateZ(90deg);\n }\n right: -${arrowWidth}px;\n }\n margin-left: ${(props) =>\n props['data-placement'].startsWith('top') || props['data-placement'].startsWith('bottom')\n ? `-${arrowWidth / 2}px;`\n : '0;'};\n margin-top: ${(props) =>\n props['data-placement'].startsWith('left') || props['data-placement'].startsWith('right')\n ? `-${arrowHeight / 2}px;`\n : '0;'};\n`;\n\nexport const PopoverArrow = ({ placement, style, arrowElementRef }: PopoverArrowT): React.ReactElement => (\n <StyledArrow\n key=\"popper-arrow\"\n data-placement={placement}\n style={style}\n ref={arrowElementRef}\n data-testid=\"ds-tooltip-arrow\"\n >\n <svg viewBox=\"0 0 30 30\">\n <path\n className=\"stroke\"\n 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\n C26.7,29,24.6,28.1,23.7,27.1z\"\n />\n <path\n className=\"fill\"\n 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\"\n />\n </svg>\n </StyledArrow>\n);\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AAMA,MAAM,aAAa;AACnB,MAAM,cAAc;AAEpB,MAAM,cAAc,OAAO;AAAA;AAAA,WAEhB;AAAA,YACC;AAAA;AAAA;AAAA;AAAA,YAIA,CAAC,EAAE,YAAY,MAAM,OAAO,QAAQ;AAAA;AAAA;AAAA;AAAA,YAIpC,CAAC,EAAE,YAAY,MAAM,OAAO,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAOjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAMF;AAAA;AAAA;AAAA,YAGD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAME;AAAA;AAAA,iBAEG,CAAC,UACd,MAAM,kBAAkB,WAAW,UAAU,MAAM,kBAAkB,WAAW,YAC5E,IAAI,aAAa,SACjB;AAAA,gBACQ,CAAC,UACb,MAAM,kBAAkB,WAAW,WAAW,MAAM,kBAAkB,WAAW,WAC7E,IAAI,cAAc,SAClB;AAAA;AAGD,MAAM,eAAe,CAAC,EAAE,WAAW,OAAO,sBAC/C,qCAAC,aAAD;AAAA,EACE,KAAI;AAAA,EACJ,kBAAgB;AAAA,EAChB;AAAA,EACA,KAAK;AAAA,EACL,eAAY;AAAA,GAEZ,qCAAC,OAAD;AAAA,EAAK,SAAQ;AAAA,GACX,qCAAC,QAAD;AAAA,EACE,WAAU;AAAA,EACV,GAAE;AAAA,IAGJ,qCAAC,QAAD;AAAA,EACE,WAAU;AAAA,EACV,GAAE;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import React2, { useCallback, useMemo } from "react";
|
|
19
|
+
import { PopoverArrow } from "./PopoverArrow";
|
|
20
|
+
import { StyledPopoverContentWrapper, StyledAnimatedPopper } from "./styled";
|
|
21
|
+
const PopoverContent = ({
|
|
22
|
+
setPopperElement,
|
|
23
|
+
popperStyles,
|
|
24
|
+
popperAttributes,
|
|
25
|
+
children,
|
|
26
|
+
showPopover,
|
|
27
|
+
setArrowElement,
|
|
28
|
+
setIsAnimating,
|
|
29
|
+
arrowStyle,
|
|
30
|
+
withoutArrow,
|
|
31
|
+
withoutAnimation,
|
|
32
|
+
animationDuration,
|
|
33
|
+
zIndex
|
|
34
|
+
}) => {
|
|
35
|
+
const checkAnimationStatus = useCallback(() => {
|
|
36
|
+
if (!showPopover && !withoutAnimation) {
|
|
37
|
+
setIsAnimating(false);
|
|
38
|
+
}
|
|
39
|
+
}, [showPopover, withoutAnimation, setIsAnimating]);
|
|
40
|
+
const popperContent = useMemo(() => /* @__PURE__ */ React2.createElement(React2.Fragment, null, children, withoutArrow === false ? /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(PopoverArrow, {
|
|
41
|
+
arrowElementRef: setArrowElement,
|
|
42
|
+
style: arrowStyle,
|
|
43
|
+
placement: popperAttributes ? popperAttributes["data-popper-placement"] : "bottom"
|
|
44
|
+
}), /* @__PURE__ */ React2.createElement("div", {
|
|
45
|
+
ref: setArrowElement,
|
|
46
|
+
style: arrowStyle
|
|
47
|
+
})) : null), [children, withoutArrow, arrowStyle, popperAttributes, setArrowElement]);
|
|
48
|
+
return /* @__PURE__ */ React2.createElement(StyledPopoverContentWrapper, __spreadValues({
|
|
49
|
+
zIndex,
|
|
50
|
+
ref: setPopperElement,
|
|
51
|
+
style: popperStyles
|
|
52
|
+
}, popperAttributes), /* @__PURE__ */ React2.createElement(StyledAnimatedPopper, {
|
|
53
|
+
showPopover,
|
|
54
|
+
animationDuration,
|
|
55
|
+
withoutAnimation,
|
|
56
|
+
onAnimationEnd: checkAnimationStatus
|
|
57
|
+
}, popperContent));
|
|
58
|
+
};
|
|
59
|
+
export {
|
|
60
|
+
PopoverContent
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=PopoverContent.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/PopoverContent.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback, useMemo } from 'react';\nimport { PopoverArrow } from './PopoverArrow';\nimport type { PopoverContentPropsT } from './index.d';\nimport { StyledPopoverContentWrapper, StyledAnimatedPopper } from './styled';\n\nexport const PopoverContent = ({\n setPopperElement,\n popperStyles,\n popperAttributes,\n children,\n showPopover,\n setArrowElement,\n setIsAnimating,\n arrowStyle,\n withoutArrow,\n withoutAnimation,\n animationDuration,\n zIndex,\n}: PopoverContentPropsT): JSX.Element => {\n const checkAnimationStatus = useCallback(() => {\n if (!showPopover && !withoutAnimation) {\n setIsAnimating(false);\n }\n }, [showPopover, withoutAnimation, setIsAnimating]);\n\n const popperContent = useMemo(\n () => (\n <>\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 </>\n ),\n [children, withoutArrow, arrowStyle, popperAttributes, setArrowElement],\n );\n return (\n <StyledPopoverContentWrapper zIndex={zIndex} ref={setPopperElement} style={popperStyles} {...popperAttributes}>\n <StyledAnimatedPopper\n showPopover={showPopover}\n animationDuration={animationDuration}\n withoutAnimation={withoutAnimation}\n onAnimationEnd={checkAnimationStatus}\n >\n {popperContent}\n </StyledAnimatedPopper>\n </StyledPopoverContentWrapper>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AAEA;AAEO,MAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACuC;AACvC,QAAM,uBAAuB,YAAY,MAAM;AAC7C,QAAI,CAAC,eAAe,CAAC,kBAAkB;AACrC,qBAAe;AAAA;AAAA,KAEhB,CAAC,aAAa,kBAAkB;AAEnC,QAAM,gBAAgB,QACpB,MACE,4DACG,UACA,iBAAiB,QAChB,4DACE,qCAAC,cAAD;AAAA,IACE,iBAAiB;AAAA,IACjB,OAAO;AAAA,IACP,WAAW,mBAAmB,iBAAiB,2BAA2B;AAAA,MAE5E,qCAAC,OAAD;AAAA,IAAK,KAAK;AAAA,IAAiB,OAAO;AAAA,QAElC,OAGR,CAAC,UAAU,cAAc,YAAY,kBAAkB;AAEzD,SACE,qCAAC,6BAAD;AAAA,IAA6B;AAAA,IAAgB,KAAK;AAAA,IAAkB,OAAO;AAAA,KAAkB,mBAC3F,qCAAC,sBAAD;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,KAEf;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useMemo, useState, useEffect } from "react";
|
|
3
|
+
import { usePopper } from "react-popper";
|
|
4
|
+
import { useConfiguredMergedProps } from "./useConfiguredMergedProps";
|
|
5
|
+
import { useOnClickOutside } from "../utils/hooks/useOnClickOutside";
|
|
6
|
+
const useConfigDSPopperjs = (appProps) => {
|
|
7
|
+
const [popperElement, setPopperElement] = useState(null);
|
|
8
|
+
const [arrowElement, setArrowElement] = useState(null);
|
|
9
|
+
const [isAnimating, setIsAnimating] = useState(false);
|
|
10
|
+
const props = useConfiguredMergedProps({ props: appProps, arrowElement });
|
|
11
|
+
const { referenceElement, closeContextMenu, onClickOutside, modifiers, startPlacementPreference } = props;
|
|
12
|
+
const popperExtraOpts = useMemo(() => ({ placement: startPlacementPreference, modifiers }), [modifiers, startPlacementPreference]);
|
|
13
|
+
const popoverHelper = usePopper(referenceElement, popperElement, popperExtraOpts);
|
|
14
|
+
const { showPopover, withoutAnimation } = props;
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (showPopover && !withoutAnimation) {
|
|
17
|
+
setIsAnimating(true);
|
|
18
|
+
}
|
|
19
|
+
}, [showPopover, withoutAnimation]);
|
|
20
|
+
useOnClickOutside(popperElement, (e) => {
|
|
21
|
+
if (!referenceElement?.contains?.(e?.target)) {
|
|
22
|
+
onClickOutside(e);
|
|
23
|
+
closeContextMenu();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return useMemo(() => ({
|
|
27
|
+
props,
|
|
28
|
+
popperElement,
|
|
29
|
+
setPopperElement,
|
|
30
|
+
arrowElement,
|
|
31
|
+
setArrowElement,
|
|
32
|
+
popoverHelper,
|
|
33
|
+
isAnimating,
|
|
34
|
+
setIsAnimating
|
|
35
|
+
}), [arrowElement, popoverHelper, popperElement, isAnimating, props]);
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
useConfigDSPopperjs
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=useConfigDSPopperjs.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useConfigDSPopperjs.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useMemo, useState, useEffect } 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 const [isAnimating, setIsAnimating] = useState<boolean>(false);\n\n const props = useConfiguredMergedProps({ props: appProps, arrowElement });\n const { referenceElement, closeContextMenu, onClickOutside, 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 const { showPopover, withoutAnimation } = props;\n\n useEffect(() => {\n if (showPopover && !withoutAnimation) {\n setIsAnimating(true);\n }\n }, [showPopover, withoutAnimation]);\n\n useOnClickOutside(popperElement, (e) => {\n if (!referenceElement?.contains?.(e?.target)) {\n onClickOutside(e);\n closeContextMenu();\n }\n });\n\n return useMemo(\n () => ({\n props,\n popperElement,\n setPopperElement,\n arrowElement,\n setArrowElement,\n popoverHelper,\n isAnimating,\n setIsAnimating,\n }),\n [arrowElement, popoverHelper, popperElement, isAnimating, props],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AAGA;AAEO,MAAM,sBAAsB,CAAC,aAAsD;AACxF,QAAM,CAAC,eAAe,oBAAoB,SAAS;AACnD,QAAM,CAAC,cAAc,mBAAmB,SAAS;AACjD,QAAM,CAAC,aAAa,kBAAkB,SAAkB;AAExD,QAAM,QAAQ,yBAAyB,EAAE,OAAO,UAAU;AAC1D,QAAM,EAAE,kBAAkB,kBAAkB,gBAAgB,WAAW,6BAA6B;AACpG,QAAM,kBAAkB,QACtB,MAAO,GAAE,WAAW,0BAA0B,cAC9C,CAAC,WAAW;AAGd,QAAM,gBAAgB,UAAU,kBAAkB,eAAe;AAEjE,QAAM,EAAE,aAAa,qBAAqB;AAE1C,YAAU,MAAM;AACd,QAAI,eAAe,CAAC,kBAAkB;AACpC,qBAAe;AAAA;AAAA,KAEhB,CAAC,aAAa;AAEjB,oBAAkB,eAAe,CAAC,MAAM;AACtC,QAAI,CAAC,kBAAkB,WAAW,GAAG,SAAS;AAC5C,qBAAe;AACf;AAAA;AAAA;AAIJ,SAAO,QACL,MAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MAEF,CAAC,cAAc,eAAe,eAAe,aAAa;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
const useConfiguredDefaultModifiers = ({ props, arrowElement }) => {
|
|
4
|
+
const {
|
|
5
|
+
boundaryElement: explicitAppBoundaryElement,
|
|
6
|
+
withoutArrow: explicitAppWithoutArrow = false,
|
|
7
|
+
placementOrderPreference: explicitPlacementOrderPreference = ["top", "bottom", "left", "right"],
|
|
8
|
+
customOffset: explictAppOffset = void 0
|
|
9
|
+
} = props;
|
|
10
|
+
const defaultModifiers = useMemo(() => {
|
|
11
|
+
const mod = [];
|
|
12
|
+
mod.push({ name: "hide", enabled: true });
|
|
13
|
+
mod.push({
|
|
14
|
+
name: "flip",
|
|
15
|
+
options: {
|
|
16
|
+
fallbackPlacements: explicitPlacementOrderPreference
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
if (!explicitAppWithoutArrow || explictAppOffset) {
|
|
20
|
+
const defaultOffset = explictAppOffset || [0, 14];
|
|
21
|
+
mod.push({
|
|
22
|
+
name: "offset",
|
|
23
|
+
enabled: true,
|
|
24
|
+
options: {
|
|
25
|
+
offset: defaultOffset
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (!explicitAppWithoutArrow)
|
|
30
|
+
mod.push({
|
|
31
|
+
name: "arrow",
|
|
32
|
+
options: {
|
|
33
|
+
element: arrowElement,
|
|
34
|
+
padding: 18
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
if (explicitAppBoundaryElement)
|
|
38
|
+
mod.push({
|
|
39
|
+
name: "preventOverflow",
|
|
40
|
+
options: {
|
|
41
|
+
boundary: explicitAppBoundaryElement
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return mod;
|
|
45
|
+
}, [
|
|
46
|
+
arrowElement,
|
|
47
|
+
explicitAppBoundaryElement,
|
|
48
|
+
explicitAppWithoutArrow,
|
|
49
|
+
explicitPlacementOrderPreference,
|
|
50
|
+
explictAppOffset
|
|
51
|
+
]);
|
|
52
|
+
const { modifiers: explicitAppModifiers = defaultModifiers } = props;
|
|
53
|
+
return useMemo(() => ({
|
|
54
|
+
modifiers: explicitAppModifiers
|
|
55
|
+
}), [explicitAppModifiers]);
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
useConfiguredDefaultModifiers
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=useConfiguredDefaultModifiers.js.map
|