@chayns-components/core 5.0.0-beta.176 → 5.0.0-beta.177
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/lib/components/popup/Popup.d.ts +8 -0
- package/lib/components/popup/Popup.js +22 -5
- package/lib/components/popup/Popup.js.map +1 -1
- package/lib/components/tooltip/Tooltip.d.ts +10 -0
- package/lib/components/tooltip/Tooltip.js +32 -0
- package/lib/components/tooltip/Tooltip.js.map +1 -0
- package/lib/components/tooltip/Tooltip.styles.d.ts +1 -0
- package/lib/components/tooltip/Tooltip.styles.js +11 -0
- package/lib/components/tooltip/Tooltip.styles.js.map +1 -0
- package/lib/components/tooltip/interface.d.ts +4 -0
- package/lib/components/tooltip/interface.js +6 -0
- package/lib/components/tooltip/interface.js.map +1 -0
- package/lib/components/tooltip/tooltip-item/TooltipItem.d.ts +7 -0
- package/lib/components/tooltip/tooltip-item/TooltipItem.js +21 -0
- package/lib/components/tooltip/tooltip-item/TooltipItem.js.map +1 -0
- package/lib/components/tooltip/tooltip-item/TooltipItem.styles.d.ts +7 -0
- package/lib/components/tooltip/tooltip-item/TooltipItem.styles.js +32 -0
- package/lib/components/tooltip/tooltip-item/TooltipItem.styles.js.map +1 -0
- package/package.json +2 -2
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { PopupRef } from './interface';
|
|
3
3
|
export type PopupProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The element over which the content of the `ContextMenu` should be displayed.
|
|
6
|
+
*/
|
|
7
|
+
children?: ReactNode;
|
|
4
8
|
/**
|
|
5
9
|
* The content that should be displayed inside the popup.
|
|
6
10
|
*/
|
|
@@ -13,6 +17,10 @@ export type PopupProps = {
|
|
|
13
17
|
* Function to be executed when the content of the Context menu has been shown.
|
|
14
18
|
*/
|
|
15
19
|
onShow?: VoidFunction;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the popup should be opened on hover. If not, the popup will be opened on click.
|
|
22
|
+
*/
|
|
23
|
+
shouldShowOnHover?: boolean;
|
|
16
24
|
};
|
|
17
25
|
declare const Popup: React.ForwardRefExoticComponent<PopupProps & React.RefAttributes<PopupRef>>;
|
|
18
26
|
export default Popup;
|
|
@@ -19,7 +19,8 @@ const Popup = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
19
19
|
content,
|
|
20
20
|
onShow,
|
|
21
21
|
onHide,
|
|
22
|
-
children
|
|
22
|
+
children,
|
|
23
|
+
shouldShowOnHover = false
|
|
23
24
|
} = _ref;
|
|
24
25
|
const [coordinates, setCoordinates] = (0, _react.useState)({
|
|
25
26
|
x: 0,
|
|
@@ -74,19 +75,33 @@ const Popup = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
74
75
|
}
|
|
75
76
|
}, []);
|
|
76
77
|
const handleChildrenClick = () => {
|
|
77
|
-
|
|
78
|
+
if (!shouldShowOnHover) {
|
|
79
|
+
handleShow();
|
|
80
|
+
}
|
|
78
81
|
};
|
|
79
82
|
const handleHide = (0, _react.useCallback)(() => {
|
|
80
83
|
setIsOpen(false);
|
|
81
84
|
}, []);
|
|
85
|
+
const handleMouseEnter = () => {
|
|
86
|
+
if (shouldShowOnHover) {
|
|
87
|
+
handleShow();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const handleMouseLeave = () => {
|
|
91
|
+
if (shouldShowOnHover) {
|
|
92
|
+
handleHide();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
82
95
|
const handleDocumentClick = (0, _react.useCallback)(event => {
|
|
83
96
|
var _popupContentRef$curr;
|
|
84
97
|
if (!((_popupContentRef$curr = popupContentRef.current) !== null && _popupContentRef$curr !== void 0 && _popupContentRef$curr.contains(event.target))) {
|
|
85
98
|
event.preventDefault();
|
|
86
99
|
event.stopPropagation();
|
|
87
100
|
}
|
|
88
|
-
|
|
89
|
-
|
|
101
|
+
if (!shouldShowOnHover) {
|
|
102
|
+
handleHide();
|
|
103
|
+
}
|
|
104
|
+
}, [handleHide, shouldShowOnHover]);
|
|
90
105
|
(0, _react.useImperativeHandle)(ref, () => ({
|
|
91
106
|
hide: handleHide,
|
|
92
107
|
show: handleShow
|
|
@@ -121,7 +136,9 @@ const Popup = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
121
136
|
ref: popupPseudoContentRef
|
|
122
137
|
}, content), /*#__PURE__*/_react.default.createElement(_Popup.StyledPopup, {
|
|
123
138
|
ref: popupRef,
|
|
124
|
-
onClick: handleChildrenClick
|
|
139
|
+
onClick: handleChildrenClick,
|
|
140
|
+
onMouseLeave: handleMouseLeave,
|
|
141
|
+
onMouseEnter: handleMouseEnter
|
|
125
142
|
}, children), portal);
|
|
126
143
|
});
|
|
127
144
|
Popup.displayName = 'Popup';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popup.js","names":["_framerMotion","require","_react","_interopRequireWildcard","_reactDom","_uuid","_interface","_PopupContent","_interopRequireDefault","_Popup","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","Popup","forwardRef","_ref","ref","content","onShow","onHide","children","coordinates","setCoordinates","useState","x","y","container","document","body","alignment","setAlignment","PopupAlignment","TopLeft","isOpen","setIsOpen","portal","setPortal","uuid","useUuid","popupContentRef","useRef","popupPseudoContentRef","popupRef","handleShow","useCallback","current","height","pseudoHeight","width","pseudoWidth","getBoundingClientRect","childrenX","childrenY","childrenHeight","childrenWidth","BottomRight","BottomLeft","TopRight","handleChildrenClick","handleHide","handleDocumentClick","event","_popupContentRef$curr","contains","target","preventDefault","stopPropagation","useImperativeHandle","hide","show","useEffect","addEventListener","window","removeEventListener","createPortal","createElement","AnimatePresence","initial","Fragment","StyledPopupPseudo","StyledPopup","onClick","displayName","_default","exports"],"sources":["../../../src/components/popup/Popup.tsx"],"sourcesContent":["import { AnimatePresence } from 'framer-motion';\nimport React, {\n forwardRef,\n ReactNode,\n ReactPortal,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useUuid } from '../../hooks/uuid';\nimport { PopupAlignment, PopupCoordinates, PopupRef } from './interface';\nimport PopupContent from './popup-content/PopupContent';\nimport { StyledPopup, StyledPopupPseudo } from './Popup.styles';\n\nexport type PopupProps = {\n /**\n * The content that should be displayed inside the popup.\n */\n content: ReactNode;\n /**\n * Function to be executed when the content of the Context menu has been hidden.\n */\n onHide?: VoidFunction;\n /**\n * Function to be executed when the content of the Context menu has been shown.\n */\n onShow?: VoidFunction;\n};\n\nconst Popup = forwardRef<PopupRef, PopupProps>(({ content, onShow, onHide, children }, ref) => {\n const [coordinates, setCoordinates] = useState<PopupCoordinates>({\n x: 0,\n y: 0,\n });\n const container = document.body;\n\n const [alignment, setAlignment] = useState<PopupAlignment>(PopupAlignment.TopLeft);\n const [isOpen, setIsOpen] = useState(false);\n const [portal, setPortal] = useState<ReactPortal>();\n\n const uuid = useUuid();\n\n // ToDo: Replace with hook if new chayns api is ready\n const popupContentRef = useRef<HTMLDivElement>(null);\n const popupPseudoContentRef = useRef<HTMLDivElement>(null);\n const popupRef = useRef<HTMLDivElement>(null);\n\n const handleShow = useCallback(() => {\n if (popupRef.current && popupPseudoContentRef.current) {\n const { height: pseudoHeight, width: pseudoWidth } =\n popupPseudoContentRef.current.getBoundingClientRect();\n\n const {\n x: childrenX,\n y: childrenY,\n height: childrenHeight,\n width: childrenWidth,\n } = popupRef.current.getBoundingClientRect();\n\n if (pseudoHeight > childrenY - 25) {\n if (pseudoWidth > childrenX + childrenWidth / 2 - 25) {\n setAlignment(PopupAlignment.BottomRight);\n } else {\n setAlignment(PopupAlignment.BottomLeft);\n }\n\n setCoordinates({\n x: childrenX + childrenWidth / 2,\n y: childrenY + childrenHeight - 15,\n });\n } else if (pseudoWidth > childrenX + childrenWidth / 2 - 25) {\n setAlignment(PopupAlignment.TopRight);\n setCoordinates({\n x: childrenX + childrenWidth / 2,\n y: childrenY,\n });\n } else {\n setAlignment(PopupAlignment.TopLeft);\n setCoordinates({\n x: childrenX + childrenWidth / 2,\n y: childrenY + 15,\n });\n }\n\n setIsOpen(true);\n }\n }, []);\n\n const handleChildrenClick = () => {\n handleShow();\n };\n\n const handleHide = useCallback(() => {\n setIsOpen(false);\n }, []);\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (!popupContentRef.current?.contains(event.target as Node)) {\n event.preventDefault();\n event.stopPropagation();\n }\n\n handleHide();\n },\n [handleHide]\n );\n\n useImperativeHandle(\n ref,\n () => ({\n hide: handleHide,\n show: handleShow,\n }),\n [handleHide, handleShow]\n );\n\n useEffect(() => {\n if (isOpen) {\n document.addEventListener('click', handleDocumentClick, true);\n window.addEventListener('blur', handleHide);\n\n if (typeof onShow === 'function') {\n onShow();\n }\n } else if (typeof onHide === 'function') {\n onHide();\n }\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n window.removeEventListener('blur', handleHide);\n };\n }, [handleDocumentClick, handleHide, isOpen, onHide, onShow]);\n\n useEffect(() => {\n setPortal(() =>\n createPortal(\n <AnimatePresence initial={false}>\n {isOpen && (\n <PopupContent\n coordinates={coordinates}\n content={content}\n key={`tooltip_${uuid}`}\n alignment={alignment}\n ref={popupContentRef}\n />\n )}\n </AnimatePresence>,\n container\n )\n );\n }, [alignment, container, content, coordinates, isOpen, uuid]);\n\n return (\n <>\n <StyledPopupPseudo ref={popupPseudoContentRef}>{content}</StyledPopupPseudo>\n <StyledPopup ref={popupRef} onClick={handleChildrenClick}>\n {children}\n </StyledPopup>\n {portal}\n </>\n );\n});\n\nPopup.displayName = 'Popup';\n\nexport default Popup;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAUA,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AAC,mBACN,IAAAsC,sBAAY,gBACR3F,MAAA,CAAAU,OAAA,CAAAkF,aAAA,CAAC9F,aAAA,CAAA+F,eAAe;MAACC,OAAO,EAAE;IAAM,GAC3B5C,MAAM,iBACHlD,MAAA,CAAAU,OAAA,CAAAkF,aAAA,CAACvF,aAAA,CAAAK,OAAY;MACT4B,WAAW,EAAEA,WAAY;MACzBJ,OAAO,EAAEA,OAAQ;MACjBV,GAAG,EAAG,WAAU8B,IAAK,EAAE;MACvBR,SAAS,EAAEA,SAAU;MACrBb,GAAG,EAAEuB;IAAgB,CACxB,CAEQ,CAAC,EAClBb,SACJ,CACJ,CAAC;EACL,CAAC,EAAE,CAACG,SAAS,EAAEH,SAAS,EAAET,OAAO,EAAEI,WAAW,EAAEY,MAAM,EAAEI,IAAI,CAAC,CAAC;EAE9D,oBACItD,MAAA,CAAAU,OAAA,CAAAkF,aAAA,CAAA5F,MAAA,CAAAU,OAAA,CAAAqF,QAAA,qBACI/F,MAAA,CAAAU,OAAA,CAAAkF,aAAA,CAACrF,MAAA,CAAAyF,iBAAiB;IAAC/D,GAAG,EAAEyB;EAAsB,GAAExB,OAA2B,CAAC,eAC5ElC,MAAA,CAAAU,OAAA,CAAAkF,aAAA,CAACrF,MAAA,CAAA0F,WAAW;IAAChE,GAAG,EAAE0B,QAAS;IAACuC,OAAO,EAAEvB;EAAoB,GACpDtC,QACQ,CAAC,EACbe,MACH,CAAC;AAEX,CAAC,CAAC;AAEFtB,KAAK,CAACqE,WAAW,GAAG,OAAO;AAAC,IAAAC,QAAA,GAEbtE,KAAK;AAAAuE,OAAA,CAAA3F,OAAA,GAAA0F,QAAA"}
|
|
1
|
+
{"version":3,"file":"Popup.js","names":["_framerMotion","require","_react","_interopRequireWildcard","_reactDom","_uuid","_interface","_PopupContent","_interopRequireDefault","_Popup","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","Popup","forwardRef","_ref","ref","content","onShow","onHide","children","shouldShowOnHover","coordinates","setCoordinates","useState","x","y","container","document","body","alignment","setAlignment","PopupAlignment","TopLeft","isOpen","setIsOpen","portal","setPortal","uuid","useUuid","popupContentRef","useRef","popupPseudoContentRef","popupRef","handleShow","useCallback","current","height","pseudoHeight","width","pseudoWidth","getBoundingClientRect","childrenX","childrenY","childrenHeight","childrenWidth","BottomRight","BottomLeft","TopRight","handleChildrenClick","handleHide","handleMouseEnter","handleMouseLeave","handleDocumentClick","event","_popupContentRef$curr","contains","target","preventDefault","stopPropagation","useImperativeHandle","hide","show","useEffect","addEventListener","window","removeEventListener","createPortal","createElement","AnimatePresence","initial","Fragment","StyledPopupPseudo","StyledPopup","onClick","onMouseLeave","onMouseEnter","displayName","_default","exports"],"sources":["../../../src/components/popup/Popup.tsx"],"sourcesContent":["import { AnimatePresence } from 'framer-motion';\nimport React, {\n forwardRef,\n ReactNode,\n ReactPortal,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useUuid } from '../../hooks/uuid';\nimport { PopupAlignment, PopupCoordinates, PopupRef } from './interface';\nimport PopupContent from './popup-content/PopupContent';\nimport { StyledPopup, StyledPopupPseudo } from './Popup.styles';\n\nexport type PopupProps = {\n /**\n * The element over which the content of the `ContextMenu` should be displayed.\n */\n children?: ReactNode;\n /**\n * The content that should be displayed inside the popup.\n */\n content: ReactNode;\n /**\n * Function to be executed when the content of the Context menu has been hidden.\n */\n onHide?: VoidFunction;\n /**\n * Function to be executed when the content of the Context menu has been shown.\n */\n onShow?: VoidFunction;\n /**\n * Whether the popup should be opened on hover. If not, the popup will be opened on click.\n */\n shouldShowOnHover?: boolean;\n};\n\nconst Popup = forwardRef<PopupRef, PopupProps>(\n ({ content, onShow, onHide, children, shouldShowOnHover = false }, ref) => {\n const [coordinates, setCoordinates] = useState<PopupCoordinates>({\n x: 0,\n y: 0,\n });\n const container = document.body;\n\n const [alignment, setAlignment] = useState<PopupAlignment>(PopupAlignment.TopLeft);\n const [isOpen, setIsOpen] = useState(false);\n const [portal, setPortal] = useState<ReactPortal>();\n\n const uuid = useUuid();\n\n // ToDo: Replace with hook if new chayns api is ready\n const popupContentRef = useRef<HTMLDivElement>(null);\n const popupPseudoContentRef = useRef<HTMLDivElement>(null);\n const popupRef = useRef<HTMLDivElement>(null);\n\n const handleShow = useCallback(() => {\n if (popupRef.current && popupPseudoContentRef.current) {\n const { height: pseudoHeight, width: pseudoWidth } =\n popupPseudoContentRef.current.getBoundingClientRect();\n\n const {\n x: childrenX,\n y: childrenY,\n height: childrenHeight,\n width: childrenWidth,\n } = popupRef.current.getBoundingClientRect();\n\n if (pseudoHeight > childrenY - 25) {\n if (pseudoWidth > childrenX + childrenWidth / 2 - 25) {\n setAlignment(PopupAlignment.BottomRight);\n } else {\n setAlignment(PopupAlignment.BottomLeft);\n }\n\n setCoordinates({\n x: childrenX + childrenWidth / 2,\n y: childrenY + childrenHeight - 15,\n });\n } else if (pseudoWidth > childrenX + childrenWidth / 2 - 25) {\n setAlignment(PopupAlignment.TopRight);\n setCoordinates({\n x: childrenX + childrenWidth / 2,\n y: childrenY,\n });\n } else {\n setAlignment(PopupAlignment.TopLeft);\n setCoordinates({\n x: childrenX + childrenWidth / 2,\n y: childrenY + 15,\n });\n }\n\n setIsOpen(true);\n }\n }, []);\n\n const handleChildrenClick = () => {\n if (!shouldShowOnHover) {\n handleShow();\n }\n };\n\n const handleHide = useCallback(() => {\n setIsOpen(false);\n }, []);\n\n const handleMouseEnter = () => {\n if (shouldShowOnHover) {\n handleShow();\n }\n };\n\n const handleMouseLeave = () => {\n if (shouldShowOnHover) {\n handleHide();\n }\n };\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (!popupContentRef.current?.contains(event.target as Node)) {\n event.preventDefault();\n event.stopPropagation();\n }\n\n if (!shouldShowOnHover) {\n handleHide();\n }\n },\n [handleHide, shouldShowOnHover]\n );\n\n useImperativeHandle(\n ref,\n () => ({\n hide: handleHide,\n show: handleShow,\n }),\n [handleHide, handleShow]\n );\n\n useEffect(() => {\n if (isOpen) {\n document.addEventListener('click', handleDocumentClick, true);\n window.addEventListener('blur', handleHide);\n\n if (typeof onShow === 'function') {\n onShow();\n }\n } else if (typeof onHide === 'function') {\n onHide();\n }\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n window.removeEventListener('blur', handleHide);\n };\n }, [handleDocumentClick, handleHide, isOpen, onHide, onShow]);\n\n useEffect(() => {\n setPortal(() =>\n createPortal(\n <AnimatePresence initial={false}>\n {isOpen && (\n <PopupContent\n coordinates={coordinates}\n content={content}\n key={`tooltip_${uuid}`}\n alignment={alignment}\n ref={popupContentRef}\n />\n )}\n </AnimatePresence>,\n container\n )\n );\n }, [alignment, container, content, coordinates, isOpen, uuid]);\n\n return (\n <>\n <StyledPopupPseudo ref={popupPseudoContentRef}>{content}</StyledPopupPseudo>\n <StyledPopup\n ref={popupRef}\n onClick={handleChildrenClick}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n >\n {children}\n </StyledPopup>\n {portal}\n </>\n );\n }\n);\n\nPopup.displayName = 'Popup';\n\nexport default Popup;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAUA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AAAgE,SAAAO,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iB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|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _Popup = _interopRequireDefault(require("../popup/Popup"));
|
|
9
|
+
var _TooltipItem = _interopRequireDefault(require("./tooltip-item/TooltipItem"));
|
|
10
|
+
var _Tooltip = require("./Tooltip.styles");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
+
const Tooltip = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
item,
|
|
17
|
+
children
|
|
18
|
+
} = _ref;
|
|
19
|
+
const tooltipRef = (0, _react.useRef)(null);
|
|
20
|
+
return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_Tooltip.StyledTooltip, null, /*#__PURE__*/_react.default.createElement(_Popup.default, {
|
|
21
|
+
shouldShowOnHover: true,
|
|
22
|
+
content: /*#__PURE__*/_react.default.createElement(_TooltipItem.default, {
|
|
23
|
+
text: item.text,
|
|
24
|
+
headline: item.headline
|
|
25
|
+
}),
|
|
26
|
+
ref: tooltipRef
|
|
27
|
+
}, children)), [item, children]);
|
|
28
|
+
};
|
|
29
|
+
Tooltip.displayName = 'Tooltip';
|
|
30
|
+
var _default = Tooltip;
|
|
31
|
+
exports.default = _default;
|
|
32
|
+
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.js","names":["_react","_interopRequireWildcard","require","_Popup","_interopRequireDefault","_TooltipItem","_Tooltip","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","Tooltip","_ref","item","children","tooltipRef","useRef","useMemo","createElement","StyledTooltip","shouldShowOnHover","content","text","headline","ref","displayName","_default","exports"],"sources":["../../../src/components/tooltip/Tooltip.tsx"],"sourcesContent":["import React, { FC, useMemo, useRef } from 'react';\nimport type { PopupRef } from '../popup/interface';\nimport Popup from '../popup/Popup';\nimport type { ITooltipItem } from './interface';\nimport TooltipItem from './tooltip-item/TooltipItem';\nimport { StyledTooltip } from './Tooltip.styles';\n\nexport type TooltipProps = {\n /**\n * The content that should be displayed.\n */\n item: ITooltipItem;\n};\n\nconst Tooltip: FC<TooltipProps> = ({ item, children }) => {\n const tooltipRef = useRef<PopupRef>(null);\n\n return useMemo(\n () => (\n <StyledTooltip>\n <Popup\n shouldShowOnHover\n content={<TooltipItem text={item.text} headline={item.headline} />}\n ref={tooltipRef}\n >\n {children}\n </Popup>\n </StyledTooltip>\n ),\n [item, children]\n );\n};\n\nTooltip.displayName = 'Tooltip';\n\nexport default Tooltip;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,YAAA,GAA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GAAA,EAAAW,MAAA,YAAAA,MAAA;AASjD,MAAMW,OAAyB,GAAGC,IAAA,IAAwB;EAAA,IAAvB;IAAEC,IAAI;IAAEC;EAAS,CAAC,GAAAF,IAAA;EACjD,MAAMG,UAAU,GAAG,IAAAC,aAAM,EAAW,IAAI,CAAC;EAEzC,OAAO,IAAAC,cAAO,EACV,mBACInC,MAAA,CAAAS,OAAA,CAAA2B,aAAA,CAAC9B,QAAA,CAAA+B,aAAa,qBACVrC,MAAA,CAAAS,OAAA,CAAA2B,aAAA,CAACjC,MAAA,CAAAM,OAAK;IACF6B,iBAAiB;IACjBC,OAAO,eAAEvC,MAAA,CAAAS,OAAA,CAAA2B,aAAA,CAAC/B,YAAA,CAAAI,OAAW;MAAC+B,IAAI,EAAET,IAAI,CAACS,IAAK;MAACC,QAAQ,EAAEV,IAAI,CAACU;IAAS,CAAE,CAAE;IACnEC,GAAG,EAAET;EAAW,GAEfD,QACE,CACI,CAClB,EACD,CAACD,IAAI,EAAEC,QAAQ,CACnB,CAAC;AACL,CAAC;AAEDH,OAAO,CAACc,WAAW,GAAG,SAAS;AAAC,IAAAC,QAAA,GAEjBf,OAAO;AAAAgB,OAAA,CAAApC,OAAA,GAAAmC,QAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const StyledTooltip: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StyledTooltip = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
const StyledTooltip = _styledComponents.default.div``;
|
|
10
|
+
exports.StyledTooltip = StyledTooltip;
|
|
11
|
+
//# sourceMappingURL=Tooltip.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.styles.js","names":["_styledComponents","_interopRequireDefault","require","obj","__esModule","default","StyledTooltip","styled","div","exports"],"sources":["../../../src/components/tooltip/Tooltip.styles.ts"],"sourcesContent":["import styled from 'styled-components';\n\nexport const StyledTooltip = styled.div``;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEhC,MAAMG,aAAa,GAAGC,yBAAM,CAACC,GAAI,EAAC;AAACC,OAAA,CAAAH,aAAA,GAAAA,aAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.js","names":[],"sources":["../../../src/components/tooltip/interface.ts"],"sourcesContent":["export interface ITooltipItem {\n headline?: string;\n text: string;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _TooltipItem = require("./TooltipItem.styles");
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
+
const TooltipItem = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
headline,
|
|
14
|
+
text
|
|
15
|
+
} = _ref;
|
|
16
|
+
return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_TooltipItem.StyledTooltipItem, null, /*#__PURE__*/_react.default.createElement(_TooltipItem.StyledTooltipItemHeadline, null, headline), /*#__PURE__*/_react.default.createElement(_TooltipItem.StyledTooltipItemText, null, text)), [headline, text]);
|
|
17
|
+
};
|
|
18
|
+
TooltipItem.displayName = 'TooltipItem';
|
|
19
|
+
var _default = TooltipItem;
|
|
20
|
+
exports.default = _default;
|
|
21
|
+
//# sourceMappingURL=TooltipItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TooltipItem.js","names":["_react","_interopRequireWildcard","require","_TooltipItem","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TooltipItem","_ref","headline","text","useMemo","createElement","StyledTooltipItem","StyledTooltipItemHeadline","StyledTooltipItemText","displayName","_default","exports"],"sources":["../../../../src/components/tooltip/tooltip-item/TooltipItem.tsx"],"sourcesContent":["import React, { FC, useMemo } from 'react';\nimport {\n StyledTooltipItem,\n StyledTooltipItemHeadline,\n StyledTooltipItemText,\n} from './TooltipItem.styles';\n\nexport type TooltipProps = {\n headline?: string;\n text: string;\n};\n\nconst TooltipItem: FC<TooltipProps> = ({ headline, text }) =>\n useMemo(\n () => (\n <StyledTooltipItem>\n <StyledTooltipItemHeadline>{headline}</StyledTooltipItemHeadline>\n <StyledTooltipItemText>{text}</StyledTooltipItemText>\n </StyledTooltipItem>\n ),\n [headline, text]\n );\n\nTooltipItem.displayName = 'TooltipItem';\n\nexport default TooltipItem;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAI8B,SAAAE,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAJ,wBAAAQ,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA;AAO9B,MAAMW,WAA6B,GAAGC,IAAA;EAAA,IAAC;IAAEC,QAAQ;IAAEC;EAAK,CAAC,GAAAF,IAAA;EAAA,OACrD,IAAAG,cAAO,EACH,mBACI9B,MAAA,CAAAW,OAAA,CAAAoB,aAAA,CAAC5B,YAAA,CAAA6B,iBAAiB,qBACdhC,MAAA,CAAAW,OAAA,CAAAoB,aAAA,CAAC5B,YAAA,CAAA8B,yBAAyB,QAAEL,QAAoC,CAAC,eACjE5B,MAAA,CAAAW,OAAA,CAAAoB,aAAA,CAAC5B,YAAA,CAAA+B,qBAAqB,QAAEL,IAA4B,CACrC,CACtB,EACD,CAACD,QAAQ,EAAEC,IAAI,CACnB,CAAC;AAAA;AAELH,WAAW,CAACS,WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAEzBV,WAAW;AAAAW,OAAA,CAAA1B,OAAA,GAAAyB,QAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const StyledTooltipItem: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const StyledTooltipItemHeadline: import("styled-components").StyledComponent<"h5", any, {
|
|
3
|
+
theme: import("../../color-scheme-provider/ColorSchemeProvider").Theme;
|
|
4
|
+
}, never>;
|
|
5
|
+
export declare const StyledTooltipItemText: import("styled-components").StyledComponent<"p", any, {
|
|
6
|
+
theme: import("../../color-scheme-provider/ColorSchemeProvider").Theme;
|
|
7
|
+
}, never>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StyledTooltipItemText = exports.StyledTooltipItemHeadline = exports.StyledTooltipItem = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
const StyledTooltipItem = _styledComponents.default.div`
|
|
10
|
+
padding: 5px;
|
|
11
|
+
`;
|
|
12
|
+
exports.StyledTooltipItem = StyledTooltipItem;
|
|
13
|
+
const StyledTooltipItemHeadline = _styledComponents.default.h5`
|
|
14
|
+
color: ${_ref => {
|
|
15
|
+
let {
|
|
16
|
+
theme
|
|
17
|
+
} = _ref;
|
|
18
|
+
return theme.headline;
|
|
19
|
+
}};
|
|
20
|
+
margin: 0;
|
|
21
|
+
`;
|
|
22
|
+
exports.StyledTooltipItemHeadline = StyledTooltipItemHeadline;
|
|
23
|
+
const StyledTooltipItemText = _styledComponents.default.p`
|
|
24
|
+
color: ${_ref2 => {
|
|
25
|
+
let {
|
|
26
|
+
theme
|
|
27
|
+
} = _ref2;
|
|
28
|
+
return theme.text;
|
|
29
|
+
}};
|
|
30
|
+
`;
|
|
31
|
+
exports.StyledTooltipItemText = StyledTooltipItemText;
|
|
32
|
+
//# sourceMappingURL=TooltipItem.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TooltipItem.styles.js","names":["_styledComponents","_interopRequireDefault","require","obj","__esModule","default","StyledTooltipItem","styled","div","exports","StyledTooltipItemHeadline","h5","_ref","theme","headline","StyledTooltipItemText","p","_ref2","text"],"sources":["../../../../src/components/tooltip/tooltip-item/TooltipItem.styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\n\nexport const StyledTooltipItem = styled.div`\n padding: 5px;\n`;\n\ntype StyledTooltipItemHeadlineProps = WithTheme<unknown>;\n\nexport const StyledTooltipItemHeadline = styled.h5<StyledTooltipItemHeadlineProps>`\n color: ${({ theme }: StyledTooltipItemHeadlineProps) => theme.headline};\n margin: 0;\n`;\n\ntype StyledTooltipItemTextProps = WithTheme<unknown>;\n\nexport const StyledTooltipItemText = styled.p<StyledTooltipItemTextProps>`\n color: ${({ theme }: StyledTooltipItemTextProps) => theme.text};\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAGhC,MAAMG,iBAAiB,GAAGC,yBAAM,CAACC,GAAI;AAC5C;AACA,CAAC;AAACC,OAAA,CAAAH,iBAAA,GAAAA,iBAAA;AAIK,MAAMI,yBAAyB,GAAGH,yBAAM,CAACI,EAAmC;AACnF,aAAaC,IAAA;EAAA,IAAC;IAAEC;EAAsC,CAAC,GAAAD,IAAA;EAAA,OAAKC,KAAK,CAACC,QAAQ;AAAA,CAAC;AAC3E;AACA,CAAC;AAACL,OAAA,CAAAC,yBAAA,GAAAA,yBAAA;AAIK,MAAMK,qBAAqB,GAAGR,yBAAM,CAACS,CAA8B;AAC1E,aAAaC,KAAA;EAAA,IAAC;IAAEJ;EAAkC,CAAC,GAAAI,KAAA;EAAA,OAAKJ,KAAK,CAACK,IAAI;AAAA,CAAC;AACnE,CAAC;AAACT,OAAA,CAAAM,qBAAA,GAAAA,qBAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.177",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chayns",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "ae1757d99f2fdfc84ee2c5d9967ffe8502cc6e4b"
|
|
67
67
|
}
|