@chayns-components/core 5.0.0-beta.363 → 5.0.0-beta.366

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.
@@ -21,6 +21,10 @@ export type PopupProps = {
21
21
  * Whether the popup should be opened on hover. If not, the popup will be opened on click.
22
22
  */
23
23
  shouldShowOnHover?: boolean;
24
+ /**
25
+ * The Y offset of the popup to the children.
26
+ */
27
+ yOffset?: number;
24
28
  };
25
29
  declare const Popup: React.ForwardRefExoticComponent<PopupProps & React.RefAttributes<PopupRef>>;
26
30
  export default Popup;
@@ -21,7 +21,8 @@ const Popup = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
21
21
  onShow,
22
22
  onHide,
23
23
  children,
24
- shouldShowOnHover = false
24
+ shouldShowOnHover = false,
25
+ yOffset = 0
25
26
  } = _ref;
26
27
  const [coordinates, setCoordinates] = (0, _react.useState)({
27
28
  x: 0,
@@ -58,7 +59,7 @@ const Popup = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
58
59
  }
59
60
  setCoordinates({
60
61
  x: childrenLeft + childrenWidth / 2,
61
- y: childrenTop + childrenHeight + 4
62
+ y: childrenTop + childrenHeight + 4 - yOffset
62
63
  });
63
64
  } else {
64
65
  if (pseudoWidth > childrenLeft + childrenWidth / 2 - 25) {
@@ -68,12 +69,12 @@ const Popup = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
68
69
  }
69
70
  setCoordinates({
70
71
  x: childrenLeft + childrenWidth / 2,
71
- y: childrenTop - 4
72
+ y: childrenTop - 4 + yOffset
72
73
  });
73
74
  }
74
75
  setIsOpen(true);
75
76
  }
76
- }, []);
77
+ }, [yOffset]);
77
78
  const handleChildrenClick = () => {
78
79
  if (!shouldShowOnHover) {
79
80
  handleShow();
@@ -1 +1 @@
1
- {"version":3,"file":"Popup.js","names":["_chaynsApi","require","_framerMotion","_react","_interopRequireWildcard","_reactDom","_uuid","_PopupContent","_interopRequireDefault","_Popup","_types","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Popup","forwardRef","_ref","ref","content","onShow","onHide","children","shouldShowOnHover","coordinates","setCoordinates","useState","x","y","container","document","querySelector","body","alignment","setAlignment","PopupAlignment","TopLeft","isOpen","setIsOpen","portal","setPortal","menuHeight","setMenuHeight","uuid","useUuid","popupContentRef","useRef","popupPseudoContentRef","popupRef","handleShow","useCallback","current","height","pseudoHeight","width","pseudoWidth","getBoundingClientRect","childrenHeight","left","childrenLeft","top","childrenTop","childrenWidth","BottomRight","BottomLeft","TopRight","handleChildrenClick","handleHide","handleMouseEnter","handleMouseLeave","handleDocumentClick","event","contains","target","preventDefault","stopPropagation","useImperativeHandle","hide","show","useEffect","getWindowMetrics","then","result","topBarHeight","addEventListener","window","removeEventListener","createPortal","createElement","AnimatePresence","initial","key","Fragment","StyledPopupPseudo","StyledPopup","onClick","onMouseLeave","onMouseEnter","displayName","_default","exports"],"sources":["../../../src/components/popup/Popup.tsx"],"sourcesContent":["import { getWindowMetrics } from 'chayns-api';\nimport { 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 PopupContent from './popup-content/PopupContent';\nimport { StyledPopup, StyledPopupPseudo } from './Popup.styles';\nimport { PopupAlignment, PopupCoordinates, PopupRef } from './types';\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.querySelector('.tapp') || document.body;\n\n const [alignment, setAlignment] = useState<PopupAlignment>(PopupAlignment.TopLeft);\n const [isOpen, setIsOpen] = useState(false);\n const [portal, setPortal] = useState<ReactPortal>();\n const [menuHeight, setMenuHeight] = useState(0);\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 height: childrenHeight,\n left: childrenLeft,\n top: childrenTop,\n width: childrenWidth,\n } = popupRef.current.getBoundingClientRect();\n\n if (pseudoHeight > childrenTop - 25) {\n if (pseudoWidth > childrenLeft + childrenWidth / 2 - 25) {\n setAlignment(PopupAlignment.BottomRight);\n } else {\n setAlignment(PopupAlignment.BottomLeft);\n }\n\n setCoordinates({\n x: childrenLeft + childrenWidth / 2,\n y: childrenTop + childrenHeight + 4,\n });\n } else {\n if (pseudoWidth > childrenLeft + childrenWidth / 2 - 25) {\n setAlignment(PopupAlignment.TopRight);\n } else {\n setAlignment(PopupAlignment.TopLeft);\n }\n\n setCoordinates({\n x: childrenLeft + childrenWidth / 2,\n y: childrenTop - 4,\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 if (!shouldShowOnHover) {\n handleHide();\n }\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 void getWindowMetrics().then((result) => {\n if (result.topBarHeight) {\n setMenuHeight(result.topBarHeight);\n }\n });\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} menuHeight={menuHeight}>\n {content}\n </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,UAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AAUA,IAAAI,SAAA,GAAAJ,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qBAAsB;IAACN,UAAU,EAAEA;EAAW,GACjEtB,OACc,CAAC,eACpBlC,MAAA,CAAAU,OAAA,CAAA6F,aAAA,CAACjG,MAAA,CAAAuG,WAAW;IACR5E,GAAG,EAAE8B,QAAS;IACd+C,OAAO,EAAE7B,mBAAoB;IAC7B8B,YAAY,EAAE3B,gBAAiB;IAC/B4B,YAAY,EAAE7B;EAAiB,GAE9B9C,QACQ,CAAC,EACbiB,MACH,CAAC;AAEX,CACJ,CAAC;AAEDxB,KAAK,CAACmF,WAAW,GAAG,OAAO;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAzG,OAAA,GAEboB,KAAK"}
1
+ {"version":3,"file":"Popup.js","names":["_chaynsApi","require","_framerMotion","_react","_interopRequireWildcard","_reactDom","_uuid","_PopupContent","_interopRequireDefault","_Popup","_types","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Popup","forwardRef","_ref","ref","content","onShow","onHide","children","shouldShowOnHover","yOffset","coordinates","setCoordinates","useState","x","y","container","document","querySelector","body","alignment","setAlignment","PopupAlignment","TopLeft","isOpen","setIsOpen","portal","setPortal","menuHeight","setMenuHeight","uuid","useUuid","popupContentRef","useRef","popupPseudoContentRef","popupRef","handleShow","useCallback","current","height","pseudoHeight","width","pseudoWidth","getBoundingClientRect","childrenHeight","left","childrenLeft","top","childrenTop","childrenWidth","BottomRight","BottomLeft","TopRight","handleChildrenClick","handleHide","handleMouseEnter","handleMouseLeave","handleDocumentClick","event","contains","target","preventDefault","stopPropagation","useImperativeHandle","hide","show","useEffect","getWindowMetrics","then","result","topBarHeight","addEventListener","window","removeEventListener","createPortal","createElement","AnimatePresence","initial","key","Fragment","StyledPopupPseudo","StyledPopup","onClick","onMouseLeave","onMouseEnter","displayName","_default","exports"],"sources":["../../../src/components/popup/Popup.tsx"],"sourcesContent":["import { getWindowMetrics } from 'chayns-api';\nimport { 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 PopupContent from './popup-content/PopupContent';\nimport { StyledPopup, StyledPopupPseudo } from './Popup.styles';\nimport { PopupAlignment, PopupCoordinates, PopupRef } from './types';\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 * The Y offset of the popup to the children.\n */\n yOffset?: number;\n};\n\nconst Popup = forwardRef<PopupRef, PopupProps>(\n ({ content, onShow, onHide, children, shouldShowOnHover = false, yOffset = 0 }, ref) => {\n const [coordinates, setCoordinates] = useState<PopupCoordinates>({\n x: 0,\n y: 0,\n });\n const container = document.querySelector('.tapp') || document.body;\n\n const [alignment, setAlignment] = useState<PopupAlignment>(PopupAlignment.TopLeft);\n const [isOpen, setIsOpen] = useState(false);\n const [portal, setPortal] = useState<ReactPortal>();\n const [menuHeight, setMenuHeight] = useState(0);\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 height: childrenHeight,\n left: childrenLeft,\n top: childrenTop,\n width: childrenWidth,\n } = popupRef.current.getBoundingClientRect();\n\n if (pseudoHeight > childrenTop - 25) {\n if (pseudoWidth > childrenLeft + childrenWidth / 2 - 25) {\n setAlignment(PopupAlignment.BottomRight);\n } else {\n setAlignment(PopupAlignment.BottomLeft);\n }\n\n setCoordinates({\n x: childrenLeft + childrenWidth / 2,\n y: childrenTop + childrenHeight + 4 - yOffset,\n });\n } else {\n if (pseudoWidth > childrenLeft + childrenWidth / 2 - 25) {\n setAlignment(PopupAlignment.TopRight);\n } else {\n setAlignment(PopupAlignment.TopLeft);\n }\n\n setCoordinates({\n x: childrenLeft + childrenWidth / 2,\n y: childrenTop - 4 + yOffset,\n });\n }\n\n setIsOpen(true);\n }\n }, [yOffset]);\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 if (!shouldShowOnHover) {\n handleHide();\n }\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 void getWindowMetrics().then((result) => {\n if (result.topBarHeight) {\n setMenuHeight(result.topBarHeight);\n }\n });\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} menuHeight={menuHeight}>\n {content}\n </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,UAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AAUA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AAAqE,SAAAO,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAX,wBAAAW,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAF,OAAA,EAAAE,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAA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AAAU,OAAA,CAAA8F,aAAA,CAACzG,aAAA,CAAA0G,eAAe;MAACC,OAAO,EAAE;IAAM,GAC3BrD,MAAM,iBACHrD,MAAA,CAAAU,OAAA,CAAA8F,aAAA,CAACpG,aAAA,CAAAM,OAAY;MACT8B,WAAW,EAAEA,WAAY;MACzBN,OAAO,EAAEA,OAAQ;MACjByE,GAAG,EAAG,WAAUhD,IAAK,EAAE;MACvBV,SAAS,EAAEA,SAAU;MACrBhB,GAAG,EAAE4B;IAAgB,CACxB,CAEQ,CAAC,EAClBhB,SACJ,CACJ,CAAC;EACL,CAAC,EAAE,CAACI,SAAS,EAAEJ,SAAS,EAAEX,OAAO,EAAEM,WAAW,EAAEa,MAAM,EAAEM,IAAI,CAAC,CAAC;EAE9D,oBACI3D,MAAA,CAAAU,OAAA,CAAA8F,aAAA,CAAAxG,MAAA,CAAAU,OAAA,CAAAkG,QAAA,qBACI5G,MAAA,CAAAU,OAAA,CAAA8F,aAAA,CAAClG,MAAA,CAAAuG,iBAAiB;IAAC5E,GAAG,EAAE8B,qBAAsB;IAACN,UAAU,EAAEA;EAAW,GACjEvB,OACc,CAAC,eACpBlC,MAAA,CAAAU,OAAA,CAAA8F,aAAA,CAAClG,MAAA,CAAAwG,WAAW;IACR7E,GAAG,EAAE+B,QAAS;IACd+C,OAAO,EAAE7B,mBAAoB;IAC7B8B,YAAY,EAAE3B,gBAAiB;IAC/B4B,YAAY,EAAE7B;EAAiB,GAE9B/C,QACQ,CAAC,EACbkB,MACH,CAAC;AAEX,CACJ,CAAC;AAEDzB,KAAK,CAACoF,WAAW,GAAG,OAAO;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA1G,OAAA,GAEboB,KAAK"}
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _chaynsApi = require("chayns-api");
8
7
  var _react = _interopRequireDefault(require("react"));
8
+ var _colorMode = require("../../../hooks/colorMode");
9
9
  var _types = require("../types");
10
10
  var _PopupContent = require("./PopupContent.styles");
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -15,9 +15,7 @@ const PopupContent = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
15
15
  coordinates,
16
16
  content
17
17
  } = _ref;
18
- const {
19
- colorMode
20
- } = (0, _chaynsApi.getSite)();
18
+ const colorMode = (0, _colorMode.useColorMode)();
21
19
  const isBottomLeftAlignment = alignment === _types.PopupAlignment.BottomLeft;
22
20
  const isTopLeftAlignment = alignment === _types.PopupAlignment.TopLeft;
23
21
  const isTopRightAlignment = alignment === _types.PopupAlignment.TopRight;
@@ -1 +1 @@
1
- {"version":3,"file":"PopupContent.js","names":["_chaynsApi","require","_react","_interopRequireDefault","_types","_PopupContent","obj","__esModule","default","PopupContent","React","forwardRef","_ref","ref","alignment","coordinates","content","colorMode","getSite","isBottomLeftAlignment","PopupAlignment","BottomLeft","isTopLeftAlignment","TopLeft","isTopRightAlignment","TopRight","percentageOffsetX","percentageOffsetY","anchorOffsetX","anchorOffsetY","exitAndInitialY","createElement","StyledMotionPopupContent","animate","opacity","y","exit","initial","position","style","left","x","top","transition","type","transformTemplate","_ref2","StyledPopupContentInner","displayName","_default","exports"],"sources":["../../../../src/components/popup/popup-content/PopupContent.tsx"],"sourcesContent":["import { getSite } from 'chayns-api';\nimport React, { ReactNode } from 'react';\nimport { PopupAlignment, PopupCoordinates } from '../types';\nimport { StyledMotionPopupContent, StyledPopupContentInner } from './PopupContent.styles';\n\ntype PopupContentProps = {\n alignment: PopupAlignment;\n coordinates: PopupCoordinates;\n content: ReactNode;\n};\n\nconst PopupContent = React.forwardRef<HTMLDivElement, PopupContentProps>(\n ({ alignment, coordinates, content }, ref) => {\n const { colorMode } = getSite();\n\n const isBottomLeftAlignment = alignment === PopupAlignment.BottomLeft;\n const isTopLeftAlignment = alignment === PopupAlignment.TopLeft;\n const isTopRightAlignment = alignment === PopupAlignment.TopRight;\n\n const percentageOffsetX = isBottomLeftAlignment || isTopLeftAlignment ? -100 : 0;\n const percentageOffsetY = isTopRightAlignment || isTopLeftAlignment ? -100 : 0;\n\n const anchorOffsetX = isBottomLeftAlignment || isTopLeftAlignment ? 21 : -21;\n const anchorOffsetY = isTopRightAlignment || isTopLeftAlignment ? -21 : 21;\n\n const exitAndInitialY = isTopLeftAlignment || isTopRightAlignment ? -16 : 16;\n\n return (\n <StyledMotionPopupContent\n animate={{ opacity: 1, y: 0 }}\n colorMode={colorMode}\n exit={{ opacity: 0, y: exitAndInitialY }}\n initial={{ opacity: 0, y: exitAndInitialY }}\n position={alignment}\n ref={ref}\n style={{ left: coordinates.x, top: coordinates.y }}\n transition={{ type: 'tween' }}\n transformTemplate={({ y = '0px' }) => `\n translateX(${percentageOffsetX}%)\n translateY(${percentageOffsetY}%)\n translateX(${anchorOffsetX}px)\n translateY(${anchorOffsetY}px)\n translateY(${y})\n `}\n >\n <StyledPopupContentInner>{content}</StyledPopupContentInner>\n </StyledMotionPopupContent>\n );\n },\n);\n\nPopupContent.displayName = 'PopupContent';\n\nexport default PopupContent;\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAA0F,SAAAE,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAQ1F,MAAMG,YAAY,gBAAGC,cAAK,CAACC,UAAU,CACjC,CAAAC,IAAA,EAAsCC,GAAG,KAAK;EAAA,IAA7C;IAAEC,SAAS;IAAEC,WAAW;IAAEC;EAAQ,CAAC,GAAAJ,IAAA;EAChC,MAAM;IAAEK;EAAU,CAAC,GAAG,IAAAC,kBAAO,EAAC,CAAC;EAE/B,MAAMC,qBAAqB,GAAGL,SAAS,KAAKM,qBAAc,CAAC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ACnD,iCAAiCC,iBAAkB;AACnD,iCAAiCC,aAAc;AAC/C,iCAAiCC,aAAc;AAC/C,iCAAiCM,CAAE;AACnC,iBAAiB;IAAA;EAAC,gBAEFjC,MAAA,CAAAM,OAAA,CAAAuB,aAAA,CAAC1B,aAAA,CAAA0C,uBAAuB,QAAE/B,OAAiC,CACrC,CAAC;AAEnC,CACJ,CAAC;AAEDP,YAAY,CAACuC,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA1C,OAAA,GAE3BC,YAAY"}
1
+ {"version":3,"file":"PopupContent.js","names":["_react","_interopRequireDefault","require","_colorMode","_types","_PopupContent","obj","__esModule","default","PopupContent","React","forwardRef","_ref","ref","alignment","coordinates","content","colorMode","useColorMode","isBottomLeftAlignment","PopupAlignment","BottomLeft","isTopLeftAlignment","TopLeft","isTopRightAlignment","TopRight","percentageOffsetX","percentageOffsetY","anchorOffsetX","anchorOffsetY","exitAndInitialY","createElement","StyledMotionPopupContent","animate","opacity","y","exit","initial","position","style","left","x","top","transition","type","transformTemplate","_ref2","StyledPopupContentInner","displayName","_default","exports"],"sources":["../../../../src/components/popup/popup-content/PopupContent.tsx"],"sourcesContent":["import React, { ReactNode } from 'react';\nimport { useColorMode } from '../../../hooks/colorMode';\nimport { PopupAlignment, PopupCoordinates } from '../types';\nimport { StyledMotionPopupContent, StyledPopupContentInner } from './PopupContent.styles';\n\ntype PopupContentProps = {\n alignment: PopupAlignment;\n coordinates: PopupCoordinates;\n content: ReactNode;\n};\n\nconst PopupContent = React.forwardRef<HTMLDivElement, PopupContentProps>(\n ({ alignment, coordinates, content }, ref) => {\n const colorMode = useColorMode();\n\n const isBottomLeftAlignment = alignment === PopupAlignment.BottomLeft;\n const isTopLeftAlignment = alignment === PopupAlignment.TopLeft;\n const isTopRightAlignment = alignment === PopupAlignment.TopRight;\n\n const percentageOffsetX = isBottomLeftAlignment || isTopLeftAlignment ? -100 : 0;\n const percentageOffsetY = isTopRightAlignment || isTopLeftAlignment ? -100 : 0;\n\n const anchorOffsetX = isBottomLeftAlignment || isTopLeftAlignment ? 21 : -21;\n const anchorOffsetY = isTopRightAlignment || isTopLeftAlignment ? -21 : 21;\n\n const exitAndInitialY = isTopLeftAlignment || isTopRightAlignment ? -16 : 16;\n\n return (\n <StyledMotionPopupContent\n animate={{ opacity: 1, y: 0 }}\n colorMode={colorMode}\n exit={{ opacity: 0, y: exitAndInitialY }}\n initial={{ opacity: 0, y: exitAndInitialY }}\n position={alignment}\n ref={ref}\n style={{ left: coordinates.x, top: coordinates.y }}\n transition={{ type: 'tween' }}\n transformTemplate={({ y = '0px' }) => `\n translateX(${percentageOffsetX}%)\n translateY(${percentageOffsetY}%)\n translateX(${anchorOffsetX}px)\n translateY(${anchorOffsetY}px)\n translateY(${y})\n `}\n >\n <StyledPopupContentInner>{content}</StyledPopupContentInner>\n </StyledMotionPopupContent>\n );\n },\n);\n\nPopupContent.displayName = 'PopupContent';\n\nexport default PopupContent;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAA0F,SAAAD,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAQ1F,MAAMG,YAAY,gBAAGC,cAAK,CAACC,UAAU,CACjC,CAAAC,IAAA,EAAsCC,GAAG,KAAK;EAAA,IAA7C;IAAEC,SAAS;IAAEC,WAAW;IAAEC;EAAQ,CAAC,GAAAJ,IAAA;EAChC,MAAMK,SAAS,GAAG,IAAAC,uBAAY,EAAC,CAAC;EAEhC,MAAMC,qBAAqB,GAAGL,SAAS,KAAKM,qBAAc,CAACC,UAAU;EACrE,MAAMC,kBAAkB,GAAGR,SAAS,KAAKM,qBAAc,CAACG,OAAO;EAC/D,MAAMC,mBAAmB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;AACnC,iBAAiB;IAAA;EAAC,gBAEFnC,MAAA,CAAAQ,OAAA,CAAAuB,aAAA,CAAC1B,aAAA,CAAA0C,uBAAuB,QAAE/B,OAAiC,CACrC,CAAC;AAEnC,CACJ,CAAC;AAEDP,YAAY,CAACuC,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA1C,OAAA,GAE3BC,YAAY"}
@@ -36,11 +36,7 @@ const Truncation = _ref => {
36
36
  });
37
37
  }, [onChange]);
38
38
  const handleAnimationEnd = (0, _react.useCallback)(() => {
39
- if (!isOpen) {
40
- setShouldShowCollapsedElement(true);
41
- } else {
42
- setShouldShowCollapsedElement(false);
43
- }
39
+ setShouldShowCollapsedElement(!isOpen);
44
40
  }, [isOpen]);
45
41
  (0, _react.useEffect)(() => {
46
42
  if (!pseudoChildrenRef.current) {
@@ -59,19 +55,11 @@ const Truncation = _ref => {
59
55
  }, [collapsedHeight, newCollapsedHeight, originalHeight]);
60
56
  (0, _react.useEffect)(() => {
61
57
  if (childrenRef.current && pseudoChildrenRef.current && originalChildrenRef.current) {
62
- if (shouldShowCollapsedElement && !isOpen) {
63
- while (childrenRef.current.firstChild) {
64
- childrenRef.current.removeChild(childrenRef.current.firstChild);
65
- }
66
- childrenRef.current.appendChild(pseudoChildrenRef.current);
67
- childrenRef.current.children[0].style.visibility = 'visible';
68
- } else {
69
- while (childrenRef.current.firstChild) {
70
- childrenRef.current.removeChild(childrenRef.current.firstChild);
71
- }
72
- childrenRef.current.appendChild(originalChildrenRef.current);
73
- childrenRef.current.children[0].style.visibility = 'visible';
58
+ while (childrenRef.current.firstChild) {
59
+ childrenRef.current.removeChild(childrenRef.current.firstChild);
74
60
  }
61
+ childrenRef.current.appendChild(shouldShowCollapsedElement && !isOpen ? pseudoChildrenRef.current : originalChildrenRef.current);
62
+ childrenRef.current.children[0].style.visibility = 'visible';
75
63
  }
76
64
  }, [children, isOpen, shouldShowCollapsedElement]);
77
65
  return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_Truncation.StyledTruncation, {
@@ -1 +1 @@
1
- {"version":3,"file":"Truncation.js","names":["_react","_interopRequireWildcard","require","_truncation","_Truncation","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Truncation","_ref","collapsedHeight","moreLabel","lessLabel","onChange","children","isOpen","setIsOpen","useState","showClamp","setShowClamp","newCollapsedHeight","setNewCollapsedHeight","originalHeight","setOriginalHeight","shouldShowCollapsedElement","setShouldShowCollapsedElement","pseudoChildrenRef","useRef","childrenRef","originalChildrenRef","handleClampClick","useCallback","event","current","handleAnimationEnd","useEffect","offsetHeight","truncateElement","firstChild","removeChild","appendChild","style","visibility","useMemo","createElement","StyledTruncation","className","StyledTruncationPseudoContent","ref","StyledMotionTruncationContent","animate","height","initial","transition","type","onAnimationComplete","StyledTruncationClamp","onClick","_default","exports"],"sources":["../../../src/components/truncation/Truncation.tsx"],"sourcesContent":["import React, {\n FC,\n MouseEvent,\n MouseEventHandler,\n ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { truncateElement } from '../../utils/truncation';\nimport {\n StyledMotionTruncationContent,\n StyledTruncation,\n StyledTruncationClamp,\n StyledTruncationPseudoContent,\n} from './Truncation.styles';\n\nexport type TruncationProps = {\n /**\n * The elements that should be expanding or collapsing.\n */\n children: ReactElement;\n /**\n * The height of the children Element in it`s collapsed state.\n */\n collapsedHeight?: number;\n /**\n * A text that should be displayed if the content is expanded.\n */\n lessLabel?: string;\n /**\n * A text that should be displayed if the content is collapsed.\n */\n moreLabel?: string;\n /**\n * Function to be executed when the component is expanding or collapsing.\n */\n onChange?: (event: MouseEvent<HTMLAnchorElement>, isOpen: boolean) => void;\n};\n\nconst Truncation: FC<TruncationProps> = ({\n collapsedHeight = 150,\n moreLabel = 'Mehr',\n lessLabel = 'Weniger',\n onChange,\n children,\n}) => {\n const [isOpen, setIsOpen] = useState(false);\n const [showClamp, setShowClamp] = useState(true);\n const [newCollapsedHeight, setNewCollapsedHeight] = useState(collapsedHeight);\n const [originalHeight, setOriginalHeight] = useState(0);\n const [shouldShowCollapsedElement, setShouldShowCollapsedElement] = useState(true);\n\n const pseudoChildrenRef = useRef<HTMLDivElement>(null);\n const childrenRef = useRef<HTMLDivElement>(null);\n const originalChildrenRef = useRef<HTMLDivElement>(null);\n\n // Changes the state of the truncation\n const handleClampClick = useCallback<MouseEventHandler<HTMLAnchorElement>>(\n (event) => {\n setIsOpen((current) => {\n if (typeof onChange === 'function') {\n onChange(event, !current);\n }\n\n return !current;\n });\n },\n [onChange],\n );\n\n const handleAnimationEnd = useCallback(() => {\n if (!isOpen) {\n setShouldShowCollapsedElement(true);\n } else {\n setShouldShowCollapsedElement(false);\n }\n }, [isOpen]);\n\n useEffect(() => {\n if (!pseudoChildrenRef.current) {\n return;\n }\n\n setOriginalHeight(pseudoChildrenRef.current.offsetHeight);\n\n truncateElement(pseudoChildrenRef.current, collapsedHeight);\n\n setNewCollapsedHeight(pseudoChildrenRef.current.offsetHeight);\n }, [collapsedHeight, pseudoChildrenRef]);\n\n // Checks if the clamp should be shown\n useEffect(() => {\n if (pseudoChildrenRef.current) {\n setShowClamp(originalHeight > newCollapsedHeight);\n }\n }, [collapsedHeight, newCollapsedHeight, originalHeight]);\n\n useEffect(() => {\n if (childrenRef.current && pseudoChildrenRef.current && originalChildrenRef.current) {\n if (shouldShowCollapsedElement && !isOpen) {\n while (childrenRef.current.firstChild) {\n childrenRef.current.removeChild(childrenRef.current.firstChild);\n }\n\n childrenRef.current.appendChild(pseudoChildrenRef.current);\n\n (childrenRef.current.children[0] as HTMLDivElement).style.visibility = 'visible';\n } else {\n while (childrenRef.current.firstChild) {\n childrenRef.current.removeChild(childrenRef.current.firstChild);\n }\n\n childrenRef.current.appendChild(originalChildrenRef.current);\n\n (childrenRef.current.children[0] as HTMLDivElement).style.visibility = 'visible';\n }\n }\n }, [children, isOpen, shouldShowCollapsedElement]);\n\n return useMemo(\n () => (\n <StyledTruncation className=\"beta-chayns-truncation\">\n <StyledTruncationPseudoContent ref={pseudoChildrenRef}>\n {children}\n </StyledTruncationPseudoContent>\n <StyledTruncationPseudoContent ref={originalChildrenRef}>\n {children}\n </StyledTruncationPseudoContent>\n <StyledMotionTruncationContent\n animate={{ height: isOpen ? originalHeight : newCollapsedHeight }}\n initial={false}\n transition={{ type: 'tween' }}\n onAnimationComplete={handleAnimationEnd}\n ref={childrenRef}\n />\n {showClamp && (\n <StyledTruncationClamp onClick={handleClampClick}>\n {isOpen ? lessLabel : moreLabel}\n </StyledTruncationClamp>\n )}\n </StyledTruncation>\n ),\n [\n children,\n handleAnimationEnd,\n handleClampClick,\n isOpen,\n lessLabel,\n moreLabel,\n newCollapsedHeight,\n originalHeight,\n showClamp,\n ],\n );\n};\n\nexport default Truncation;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAWA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAK6B,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,G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AC1D,WAAA,CAAA+D,6BAA6B;IAC1BC,OAAO,EAAE;MAAEC,MAAM,EAAEpC,MAAM,GAAGO,cAAc,GAAGF;IAAmB,CAAE;IAClEgC,OAAO,EAAE,KAAM;IACfC,UAAU,EAAE;MAAEC,IAAI,EAAE;IAAQ,CAAE;IAC9BC,mBAAmB,EAAErB,kBAAmB;IACxCc,GAAG,EAAEpB;EAAY,CACpB,CAAC,EACDV,SAAS,iBACNpC,MAAA,CAAAW,OAAA,CAAAmD,aAAA,CAAC1D,WAAA,CAAAsE,qBAAqB;IAACC,OAAO,EAAE3B;EAAiB,GAC5Cf,MAAM,GAAGH,SAAS,GAAGD,SACH,CAEb,CACrB,EACD,CACIG,QAAQ,EACRoB,kBAAkB,EAClBJ,gBAAgB,EAChBf,MAAM,EACNH,SAAS,EACTD,SAAS,EACTS,kBAAkB,EAClBE,cAAc,EACdJ,SAAS,CAEjB,CAAC;AACL,CAAC;AAAC,IAAAwC,QAAA,GAAAC,OAAA,CAAAlE,OAAA,GAEae,UAAU"}
1
+ {"version":3,"file":"Truncation.js","names":["_react","_interopRequireWildcard","require","_truncation","_Truncation","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Truncation","_ref","collapsedHeight","moreLabel","lessLabel","onChange","children","isOpen","setIsOpen","useState","showClamp","setShowClamp","newCollapsedHeight","setNewCollapsedHeight","originalHeight","setOriginalHeight","shouldShowCollapsedElement","setShouldShowCollapsedElement","pseudoChildrenRef","useRef","childrenRef","originalChildrenRef","handleClampClick","useCallback","event","current","handleAnimationEnd","useEffect","offsetHeight","truncateElement","firstChild","removeChild","appendChild","style","visibility","useMemo","createElement","StyledTruncation","className","StyledTruncationPseudoContent","ref","StyledMotionTruncationContent","animate","height","initial","transition","type","onAnimationComplete","StyledTruncationClamp","onClick","_default","exports"],"sources":["../../../src/components/truncation/Truncation.tsx"],"sourcesContent":["import React, {\n FC,\n MouseEvent,\n MouseEventHandler,\n ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { truncateElement } from '../../utils/truncation';\nimport {\n StyledMotionTruncationContent,\n StyledTruncation,\n StyledTruncationClamp,\n StyledTruncationPseudoContent,\n} from './Truncation.styles';\n\nexport type TruncationProps = {\n /**\n * The elements that should be expanding or collapsing.\n */\n children: ReactElement;\n /**\n * The height of the children Element in it`s collapsed state.\n */\n collapsedHeight?: number;\n /**\n * A text that should be displayed if the content is expanded.\n */\n lessLabel?: string;\n /**\n * A text that should be displayed if the content is collapsed.\n */\n moreLabel?: string;\n /**\n * Function to be executed when the component is expanding or collapsing.\n */\n onChange?: (event: MouseEvent<HTMLAnchorElement>, isOpen: boolean) => void;\n};\n\nconst Truncation: FC<TruncationProps> = ({\n collapsedHeight = 150,\n moreLabel = 'Mehr',\n lessLabel = 'Weniger',\n onChange,\n children,\n}) => {\n const [isOpen, setIsOpen] = useState(false);\n const [showClamp, setShowClamp] = useState(true);\n const [newCollapsedHeight, setNewCollapsedHeight] = useState(collapsedHeight);\n const [originalHeight, setOriginalHeight] = useState(0);\n const [shouldShowCollapsedElement, setShouldShowCollapsedElement] = useState(true);\n\n const pseudoChildrenRef = useRef<HTMLDivElement>(null);\n const childrenRef = useRef<HTMLDivElement>(null);\n const originalChildrenRef = useRef<HTMLDivElement>(null);\n\n // Changes the state of the truncation\n const handleClampClick = useCallback<MouseEventHandler<HTMLAnchorElement>>(\n (event) => {\n setIsOpen((current) => {\n if (typeof onChange === 'function') {\n onChange(event, !current);\n }\n\n return !current;\n });\n },\n [onChange],\n );\n\n const handleAnimationEnd = useCallback(() => {\n setShouldShowCollapsedElement(!isOpen);\n }, [isOpen]);\n\n useEffect(() => {\n if (!pseudoChildrenRef.current) {\n return;\n }\n\n setOriginalHeight(pseudoChildrenRef.current.offsetHeight);\n\n truncateElement(pseudoChildrenRef.current, collapsedHeight);\n\n setNewCollapsedHeight(pseudoChildrenRef.current.offsetHeight);\n }, [collapsedHeight, pseudoChildrenRef]);\n\n // Checks if the clamp should be shown\n useEffect(() => {\n if (pseudoChildrenRef.current) {\n setShowClamp(originalHeight > newCollapsedHeight);\n }\n }, [collapsedHeight, newCollapsedHeight, originalHeight]);\n\n useEffect(() => {\n if (childrenRef.current && pseudoChildrenRef.current && originalChildrenRef.current) {\n while (childrenRef.current.firstChild) {\n childrenRef.current.removeChild(childrenRef.current.firstChild);\n }\n\n childrenRef.current.appendChild(\n shouldShowCollapsedElement && !isOpen\n ? pseudoChildrenRef.current\n : originalChildrenRef.current,\n );\n\n (childrenRef.current.children[0] as HTMLDivElement).style.visibility = 'visible';\n }\n }, [children, isOpen, shouldShowCollapsedElement]);\n\n return useMemo(\n () => (\n <StyledTruncation className=\"beta-chayns-truncation\">\n <StyledTruncationPseudoContent ref={pseudoChildrenRef}>\n {children}\n </StyledTruncationPseudoContent>\n <StyledTruncationPseudoContent ref={originalChildrenRef}>\n {children}\n </StyledTruncationPseudoContent>\n <StyledMotionTruncationContent\n animate={{ height: isOpen ? originalHeight : newCollapsedHeight }}\n initial={false}\n transition={{ type: 'tween' }}\n onAnimationComplete={handleAnimationEnd}\n ref={childrenRef}\n />\n {showClamp && (\n <StyledTruncationClamp onClick={handleClampClick}>\n {isOpen ? lessLabel : moreLabel}\n </StyledTruncationClamp>\n )}\n </StyledTruncation>\n ),\n [\n children,\n handleAnimationEnd,\n handleClampClick,\n isOpen,\n lessLabel,\n moreLabel,\n newCollapsedHeight,\n originalHeight,\n showClamp,\n ],\n );\n};\n\nexport default Truncation;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAWA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAK6B,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAA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A,CAAAW,OAAA,CAAAmD,aAAA,CAAC1D,WAAA,CAAA+D,6BAA6B;IAC1BC,OAAO,EAAE;MAAEC,MAAM,EAAEpC,MAAM,GAAGO,cAAc,GAAGF;IAAmB,CAAE;IAClEgC,OAAO,EAAE,KAAM;IACfC,UAAU,EAAE;MAAEC,IAAI,EAAE;IAAQ,CAAE;IAC9BC,mBAAmB,EAAErB,kBAAmB;IACxCc,GAAG,EAAEpB;EAAY,CACpB,CAAC,EACDV,SAAS,iBACNpC,MAAA,CAAAW,OAAA,CAAAmD,aAAA,CAAC1D,WAAA,CAAAsE,qBAAqB;IAACC,OAAO,EAAE3B;EAAiB,GAC5Cf,MAAM,GAAGH,SAAS,GAAGD,SACH,CAEb,CACrB,EACD,CACIG,QAAQ,EACRoB,kBAAkB,EAClBJ,gBAAgB,EAChBf,MAAM,EACNH,SAAS,EACTD,SAAS,EACTS,kBAAkB,EAClBE,cAAc,EACdJ,SAAS,CAEjB,CAAC;AACL,CAAC;AAAC,IAAAwC,QAAA,GAAAC,OAAA,CAAAlE,OAAA,GAEae,UAAU"}
@@ -0,0 +1,2 @@
1
+ import type { ColorMode } from 'chayns-api';
2
+ export declare const useColorMode: () => ColorMode;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useColorMode = void 0;
7
+ var _react = require("react");
8
+ const useColorMode = () => {
9
+ const [colorMode, setColorMode] = (0, _react.useState)(chayns.env.site.colorMode);
10
+ (0, _react.useEffect)(() => {
11
+ const listener = () => {
12
+ setColorMode(chayns.env.site.colorMode);
13
+ };
14
+ void chayns.addDesignSettingsChangeListener(listener);
15
+ return () => {
16
+ void chayns.removeDesignSettingsChangeListener(listener);
17
+ };
18
+ }, []);
19
+ return colorMode;
20
+ };
21
+ exports.useColorMode = useColorMode;
22
+ //# sourceMappingURL=colorMode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorMode.js","names":["_react","require","useColorMode","colorMode","setColorMode","useState","chayns","env","site","useEffect","listener","addDesignSettingsChangeListener","removeDesignSettingsChangeListener","exports"],"sources":["../../src/hooks/colorMode.ts"],"sourcesContent":["import type { ColorMode } from 'chayns-api';\nimport { useEffect, useState } from 'react';\n\nexport const useColorMode = (): ColorMode => {\n const [colorMode, setColorMode] = useState<ColorMode>(chayns.env.site.colorMode);\n\n useEffect(() => {\n const listener = () => {\n setColorMode(chayns.env.site.colorMode);\n };\n\n void chayns.addDesignSettingsChangeListener(listener);\n\n return () => {\n void chayns.removeDesignSettingsChangeListener(listener);\n };\n }, []);\n\n return colorMode;\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEO,MAAMC,YAAY,GAAGA,CAAA,KAAiB;EACzC,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAG,IAAAC,eAAQ,EAAYC,MAAM,CAACC,GAAG,CAACC,IAAI,CAACL,SAAS,CAAC;EAEhF,IAAAM,gBAAS,EAAC,MAAM;IACZ,MAAMC,QAAQ,GAAGA,CAAA,KAAM;MACnBN,YAAY,CAACE,MAAM,CAACC,GAAG,CAACC,IAAI,CAACL,SAAS,CAAC;IAC3C,CAAC;IAED,KAAKG,MAAM,CAACK,+BAA+B,CAACD,QAAQ,CAAC;IAErD,OAAO,MAAM;MACT,KAAKJ,MAAM,CAACM,kCAAkC,CAACF,QAAQ,CAAC;IAC5D,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOP,SAAS;AACpB,CAAC;AAACU,OAAA,CAAAX,YAAA,GAAAA,YAAA"}
@@ -8,6 +8,8 @@ export interface Chayns {
8
8
  openVideo(url: string): Promise<void>;
9
9
  register(config: object): any;
10
10
  getWindowMetrics(): Promise<WindowMetrics>;
11
+ addDesignSettingsChangeListener(callback: () => any): Promise<any>;
12
+ removeDesignSettingsChangeListener(callback: () => any): Promise<any>;
11
13
  }
12
14
  export interface WindowMetrics {
13
15
  bottomBarHeight: number;
@@ -99,6 +101,7 @@ export interface User {
99
101
  }
100
102
  export interface Site {
101
103
  id: string;
104
+ colorMode: 0 | 1 | 2;
102
105
  }
103
106
  export interface Env {
104
107
  site: Site;
@@ -1 +1 @@
1
- {"version":3,"file":"chayns.js","names":["ButtonType","exports"],"sources":["../../src/types/chayns.ts"],"sourcesContent":["declare global {\n let chayns: Chayns;\n}\n\nexport interface Chayns {\n dialog: Dialog;\n env: Env;\n openImage(urls: string | string[], start?: number): Promise<undefined>;\n openVideo(url: string): Promise<void>;\n register(config: object): any;\n getWindowMetrics(): Promise<WindowMetrics>;\n}\n\nexport interface WindowMetrics {\n bottomBarHeight: number;\n coverHeight: 0;\n frameX: number;\n frameY: number;\n height: number;\n menuHeight: number;\n offsetTop: number;\n pageYOffset: number;\n scrollTop: number;\n windowHeight: number;\n windowWidth: number;\n}\n\nexport interface Dialog {\n select(config: {\n title?: string;\n message?: string;\n list: Array<SelectDialogItem>;\n multiselect?: boolean;\n type?: SelectType;\n preventCloseOnClick?: boolean;\n buttons?: DialogButton[];\n selectAllButton?: string;\n }): Promise<SelectDialogResult>;\n alert(headline: string, text: string): Promise<ButtonType>;\n iFrame(config: {\n url: string;\n input?: object;\n title?: string;\n message?: string;\n buttons?: DialogButton[];\n seamless?: boolean;\n transparent?: boolean;\n waitCursor?: boolean;\n maxHeight?: string;\n width?: number;\n customTransitionTimeout?: number;\n }): Promise<any>;\n}\n\ndeclare enum ButtonText {\n Cancel = 'Abbrechen',\n No = 'Nein',\n Ok = 'OK',\n Yes = 'Ja',\n}\n\nexport enum ButtonType {\n Cancel = -1,\n Negative = 0,\n Positive = 1,\n}\n\nexport interface DialogButton {\n text: ButtonText | string;\n buttonType: ButtonType | number;\n collapseTime?: number;\n textColor?: string;\n backgroundColor?: string;\n}\n\nexport interface SelectDialogItem {\n name: string;\n value: string | number;\n isSelected?: boolean;\n}\n\nexport interface SelectDialogResult {\n buttonType: ButtonType | number;\n selection: Array<SelectDialogItem>;\n}\n\ndeclare enum SelectType {\n Default = 0,\n Icon = 1,\n IconAndText,\n}\n\nexport interface Group {\n id: number;\n isActive: boolean;\n}\n\nexport interface User {\n name: string;\n firstName: string;\n gender: number;\n lastName: string;\n id: number;\n personId: string;\n tobitAccessToken: string;\n groups: Group[];\n isAuthenticated: boolean;\n adminMode: boolean;\n isAdmin: boolean;\n}\n\nexport interface Site {\n id: string;\n}\n\nexport interface Env {\n site: Site;\n user: User;\n language: any;\n parameters: any;\n isApp: boolean;\n isMobile: boolean;\n isTablet: boolean;\n}\n"],"mappings":";;;;;;IA6DYA,UAAU,GAAAC,OAAA,CAAAD,UAAA,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA"}
1
+ {"version":3,"file":"chayns.js","names":["ButtonType","exports"],"sources":["../../src/types/chayns.ts"],"sourcesContent":["declare global {\n let chayns: Chayns;\n}\n\nexport interface Chayns {\n dialog: Dialog;\n env: Env;\n openImage(urls: string | string[], start?: number): Promise<undefined>;\n openVideo(url: string): Promise<void>;\n register(config: object): any;\n getWindowMetrics(): Promise<WindowMetrics>;\n addDesignSettingsChangeListener(callback: () => any): Promise<any>;\n removeDesignSettingsChangeListener(callback: () => any): Promise<any>;\n}\n\nexport interface WindowMetrics {\n bottomBarHeight: number;\n coverHeight: 0;\n frameX: number;\n frameY: number;\n height: number;\n menuHeight: number;\n offsetTop: number;\n pageYOffset: number;\n scrollTop: number;\n windowHeight: number;\n windowWidth: number;\n}\n\nexport interface Dialog {\n select(config: {\n title?: string;\n message?: string;\n list: Array<SelectDialogItem>;\n multiselect?: boolean;\n type?: SelectType;\n preventCloseOnClick?: boolean;\n buttons?: DialogButton[];\n selectAllButton?: string;\n }): Promise<SelectDialogResult>;\n alert(headline: string, text: string): Promise<ButtonType>;\n iFrame(config: {\n url: string;\n input?: object;\n title?: string;\n message?: string;\n buttons?: DialogButton[];\n seamless?: boolean;\n transparent?: boolean;\n waitCursor?: boolean;\n maxHeight?: string;\n width?: number;\n customTransitionTimeout?: number;\n }): Promise<any>;\n}\n\ndeclare enum ButtonText {\n Cancel = 'Abbrechen',\n No = 'Nein',\n Ok = 'OK',\n Yes = 'Ja',\n}\n\nexport enum ButtonType {\n Cancel = -1,\n Negative = 0,\n Positive = 1,\n}\n\nexport interface DialogButton {\n text: ButtonText | string;\n buttonType: ButtonType | number;\n collapseTime?: number;\n textColor?: string;\n backgroundColor?: string;\n}\n\nexport interface SelectDialogItem {\n name: string;\n value: string | number;\n isSelected?: boolean;\n}\n\nexport interface SelectDialogResult {\n buttonType: ButtonType | number;\n selection: Array<SelectDialogItem>;\n}\n\ndeclare enum SelectType {\n Default = 0,\n Icon = 1,\n IconAndText,\n}\n\nexport interface Group {\n id: number;\n isActive: boolean;\n}\n\nexport interface User {\n name: string;\n firstName: string;\n gender: number;\n lastName: string;\n id: number;\n personId: string;\n tobitAccessToken: string;\n groups: Group[];\n isAuthenticated: boolean;\n adminMode: boolean;\n isAdmin: boolean;\n}\n\nexport interface Site {\n id: string;\n colorMode: 0 | 1 | 2;\n}\n\nexport interface Env {\n site: Site;\n user: User;\n language: any;\n parameters: any;\n isApp: boolean;\n isMobile: boolean;\n isTablet: boolean;\n}\n"],"mappings":";;;;;;IA+DYA,UAAU,GAAAC,OAAA,CAAAD,UAAA,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chayns-components/core",
3
- "version": "5.0.0-beta.363",
3
+ "version": "5.0.0-beta.366",
4
4
  "description": "A set of beautiful React components for developing your own applications with chayns.",
5
5
  "keywords": [
6
6
  "chayns",
@@ -70,5 +70,5 @@
70
70
  "publishConfig": {
71
71
  "access": "public"
72
72
  },
73
- "gitHead": "c50d2de2bcafd9742450849f4dc09e5e26ab0925"
73
+ "gitHead": "33cf86c4452074aa7bad0a2e7fac4a550a62e560"
74
74
  }