@chayns-components/core 5.0.28 → 5.0.30

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.
@@ -27,7 +27,8 @@ const Popup = /*#__PURE__*/(0, _react2.forwardRef)(({
27
27
  shouldUseChildrenWidth = true,
28
28
  shouldScrollWithContent = true,
29
29
  shouldUseFullWidth = false,
30
- yOffset = 0
30
+ yOffset = 0,
31
+ shouldBeOpen = false
31
32
  }, ref) => {
32
33
  const [coordinates, setCoordinates] = (0, _react2.useState)({
33
34
  x: 0,
@@ -35,7 +36,7 @@ const Popup = /*#__PURE__*/(0, _react2.forwardRef)(({
35
36
  });
36
37
  const [internalAlignment, setInternalAlignment] = (0, _react2.useState)(_popup.PopupAlignment.TopLeft);
37
38
  const [offset, setOffset] = (0, _react2.useState)(0);
38
- const [isOpen, setIsOpen] = (0, _react2.useState)(false);
39
+ const [isOpen, setIsOpen] = (0, _react2.useState)(shouldBeOpen);
39
40
  const [portal, setPortal] = (0, _react2.useState)();
40
41
  const [pseudoSize, setPseudoSize] = (0, _react2.useState)();
41
42
  const [newContainer, setNewContainer] = (0, _react2.useState)(container ?? null);
@@ -146,6 +147,11 @@ const Popup = /*#__PURE__*/(0, _react2.forwardRef)(({
146
147
  setIsOpen(true);
147
148
  }
148
149
  }, [alignment, newContainer, pseudoSize, shouldScrollWithContent, yOffset]);
150
+ (0, _react2.useEffect)(() => {
151
+ if (shouldBeOpen) {
152
+ handleShow();
153
+ }
154
+ }, [handleShow, shouldBeOpen]);
149
155
  (0, _react2.useEffect)(() => {
150
156
  if (!newContainer || !popupRef.current) return;
151
157
  const viewHeight = newContainer.clientHeight;
@@ -191,7 +197,7 @@ const Popup = /*#__PURE__*/(0, _react2.forwardRef)(({
191
197
  show: handleShow
192
198
  }), [handleHide, handleShow]);
193
199
  (0, _react2.useEffect)(() => {
194
- if (isOpen) {
200
+ if (isOpen && !shouldBeOpen) {
195
201
  document.addEventListener('click', handleDocumentClick, true);
196
202
  window.addEventListener('blur', handleHide);
197
203
  if (typeof onShow === 'function') {
@@ -204,7 +210,7 @@ const Popup = /*#__PURE__*/(0, _react2.forwardRef)(({
204
210
  document.removeEventListener('click', handleDocumentClick, true);
205
211
  window.removeEventListener('blur', handleHide);
206
212
  };
207
- }, [handleDocumentClick, handleHide, isOpen, onHide, onShow]);
213
+ }, [handleDocumentClick, handleHide, isOpen, onHide, onShow, shouldBeOpen]);
208
214
  (0, _react2.useEffect)(() => {
209
215
  if (!newContainer) {
210
216
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"Popup.js","names":["_react","require","_react2","_interopRequireWildcard","_reactDom","_uuid","_popup","_AreaContextProvider","_interopRequireDefault","_PopupContentWrapper","_Popup","_element","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Popup","forwardRef","alignment","content","onShow","container","onHide","children","shouldHideOnChildrenLeave","shouldShowOnHover","shouldUseChildrenWidth","shouldScrollWithContent","shouldUseFullWidth","yOffset","ref","coordinates","setCoordinates","useState","x","y","internalAlignment","setInternalAlignment","PopupAlignment","TopLeft","offset","setOffset","isOpen","setIsOpen","portal","setPortal","pseudoSize","setPseudoSize","newContainer","setNewContainer","contentMaxHeight","setContentMaxHeight","undefined","timeout","useRef","uuid","useUuid","height","width","measuredElement","useMeasuredClone","shouldPreventTextWrapping","popupContentRef","popupRef","useEffect","current","el","element","closest","Element","handleShow","useCallback","pseudoHeight","pseudoWidth","childrenHeight","left","childrenLeft","top","childrenTop","childrenWidth","getBoundingClientRect","document","body","containerHeight","containerWidth","zoomX","offsetWidth","zoomY","offsetHeight","BottomLeft","BottomRight","isRight","scrollLeft","scrollTop","newOffset","window","innerWidth","right","newX","TopRight","viewHeight","clientHeight","TopCenter","includes","handleChildrenClick","handleHide","handleMouseEnter","clearTimeout","handleMouseLeave","setTimeout","handleDocumentClick","event","_popupContentRef$curr","contains","target","useImperativeHandle","hide","show","addEventListener","removeEventListener","createPortal","createElement","AnimatePresence","initial","key","maxHeight","onMouseLeave","onMouseEnter","shouldChangeColor","Fragment","StyledPopup","className","onClick","$shouldUseChildrenWidth","$shouldUseFullWidth","displayName","_default","exports"],"sources":["../../../../src/components/popup/Popup.tsx"],"sourcesContent":["import { AnimatePresence } from 'motion/react';\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 '../../types/popup';\nimport AreaContextProvider from '../area-provider/AreaContextProvider';\nimport PopupContentWrapper from './popup-content-wrapper/PopupContentWrapper';\nimport { StyledPopup } from './Popup.styles';\nimport { useMeasuredClone } from '../../hooks/element';\n\nexport type PopupProps = {\n /**\n * The alignment of the popup. By default, the popup will calculate the best alignment.\n */\n alignment?: PopupAlignment;\n /**\n * The element over which the content of the `ContextMenu` should be displayed.\n */\n children?: ReactNode;\n /**\n * The element where the content of the `Popup` should be rendered via React Portal.\n */\n container?: Element;\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 tooltip should be hidden after the children is not hovered.\n */\n shouldHideOnChildrenLeave?: boolean;\n /**\n * Whether the popup should scroll with the content.\n */\n shouldScrollWithContent?: boolean;\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 * Whether the width of the children should be used.\n */\n shouldUseChildrenWidth?: boolean;\n /**\n * Whether the popup children should use the full width.\n */\n shouldUseFullWidth?: boolean;\n /**\n * The Y offset of the popup to the children.\n */\n yOffset?: number;\n};\n\nconst Popup = forwardRef<PopupRef, PopupProps>(\n (\n {\n alignment,\n content,\n onShow,\n container,\n onHide,\n children,\n shouldHideOnChildrenLeave,\n shouldShowOnHover = false,\n shouldUseChildrenWidth = true,\n shouldScrollWithContent = true,\n shouldUseFullWidth = false,\n yOffset = 0,\n },\n ref,\n ) => {\n const [coordinates, setCoordinates] = useState<PopupCoordinates>({\n x: 0,\n y: 0,\n });\n\n const [internalAlignment, setInternalAlignment] = useState<PopupAlignment>(\n PopupAlignment.TopLeft,\n );\n const [offset, setOffset] = useState<number>(0);\n const [isOpen, setIsOpen] = useState(false);\n const [portal, setPortal] = useState<ReactPortal>();\n const [pseudoSize, setPseudoSize] = useState<{ height: number; width: number }>();\n const [newContainer, setNewContainer] = useState<Element | null>(container ?? null);\n const [contentMaxHeight, setContentMaxHeight] = useState<number | undefined>(undefined);\n\n const timeout = useRef<number>();\n\n const uuid = useUuid();\n\n const { height, width, measuredElement } = useMeasuredClone({\n content,\n shouldPreventTextWrapping: !shouldUseChildrenWidth,\n });\n\n const popupContentRef = useRef<HTMLDivElement>(null);\n const popupRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (popupRef.current && !container) {\n const el = popupRef.current as HTMLElement;\n\n const element = el.closest('.dialog-inner, .page-provider, .tapp, body');\n\n setNewContainer(element);\n }\n }, [container]);\n\n useEffect(() => {\n if (container instanceof Element) {\n setNewContainer(container);\n }\n }, [container]);\n\n useEffect(() => {\n setPseudoSize({ height, width });\n }, [height, width]);\n\n const handleShow = useCallback(() => {\n if (popupRef.current && pseudoSize) {\n if (!newContainer) {\n return;\n }\n\n const { height: pseudoHeight, width: pseudoWidth } = pseudoSize;\n\n const {\n height: childrenHeight,\n left: childrenLeft,\n top: childrenTop,\n width: childrenWidth,\n } = popupRef.current.getBoundingClientRect();\n\n const element = shouldScrollWithContent ? newContainer : document.body;\n\n const {\n height: containerHeight,\n width: containerWidth,\n top,\n left,\n } = element.getBoundingClientRect();\n\n const zoomX = containerWidth / (element as HTMLElement).offsetWidth;\n const zoomY = containerHeight / (element as HTMLElement).offsetHeight;\n\n if (\n pseudoHeight > childrenTop - 25 ||\n alignment === PopupAlignment.BottomLeft ||\n alignment === PopupAlignment.BottomRight\n ) {\n let isRight = false;\n\n if (\n pseudoWidth > childrenLeft + childrenWidth / 2 - 25 ||\n alignment === PopupAlignment.BottomRight\n ) {\n setInternalAlignment(PopupAlignment.BottomRight);\n\n isRight = true;\n } else {\n setInternalAlignment(PopupAlignment.BottomLeft);\n }\n\n const x =\n (childrenLeft + childrenWidth / 2 - left) / zoomX + element.scrollLeft;\n const y =\n (childrenTop + childrenHeight / 2 - top) / zoomY +\n element.scrollTop -\n yOffset;\n\n let newOffset;\n\n if (isRight) {\n newOffset =\n x + pseudoWidth >= window.innerWidth\n ? x + pseudoWidth - window.innerWidth\n : 0;\n } else {\n newOffset = 0;\n\n const right = window.innerWidth - (childrenLeft + childrenWidth / 2);\n\n newOffset =\n right + pseudoWidth >= window.innerWidth\n ? right + pseudoWidth - window.innerWidth\n : 0;\n }\n\n setOffset(newOffset);\n\n const newX = x - newOffset;\n\n setCoordinates({\n x: newX < 23 ? 23 : newX,\n y,\n });\n } else {\n let isRight = false;\n\n if (\n pseudoWidth > childrenLeft + childrenWidth / 2 - 25 ||\n alignment === PopupAlignment.TopRight\n ) {\n setInternalAlignment(PopupAlignment.TopRight);\n\n isRight = true;\n } else {\n setInternalAlignment(PopupAlignment.TopLeft);\n }\n\n const x =\n (childrenLeft + childrenWidth / 2 - left) / zoomX + element.scrollLeft;\n const y =\n (childrenTop + childrenHeight / 2 - top) / zoomY +\n element.scrollTop -\n yOffset;\n\n let newOffset;\n\n if (isRight) {\n newOffset =\n x + pseudoWidth >= window.innerWidth\n ? x + pseudoWidth - window.innerWidth\n : 0;\n } else {\n newOffset = 0;\n\n const right = window.innerWidth - (childrenLeft + childrenWidth / 2);\n\n newOffset =\n right + pseudoWidth >= window.innerWidth\n ? right + pseudoWidth - window.innerWidth\n : 0;\n }\n\n setOffset(newOffset);\n\n const newX = x - newOffset;\n\n setCoordinates({\n x: newX < 23 ? 23 : newX,\n y,\n });\n }\n\n setIsOpen(true);\n }\n }, [alignment, newContainer, pseudoSize, shouldScrollWithContent, yOffset]);\n\n useEffect(() => {\n if (!newContainer || !popupRef.current) return;\n\n const viewHeight = newContainer.clientHeight;\n const childrenHeight = popupRef.current.getBoundingClientRect().height;\n\n if (\n [\n PopupAlignment.TopLeft,\n PopupAlignment.TopRight,\n PopupAlignment.TopCenter,\n ].includes(internalAlignment)\n ) {\n setContentMaxHeight(coordinates.y - 20);\n } else {\n setContentMaxHeight(viewHeight - childrenHeight - coordinates.y - 20);\n }\n }, [coordinates.y, internalAlignment, newContainer]);\n\n const handleChildrenClick = () => {\n handleShow();\n };\n\n const handleHide = useCallback(() => {\n setIsOpen(false);\n }, []);\n\n const handleMouseEnter = useCallback(() => {\n if (shouldShowOnHover) {\n window.clearTimeout(timeout.current);\n handleShow();\n }\n }, [handleShow, shouldShowOnHover]);\n\n const handleMouseLeave = useCallback(() => {\n if (!shouldShowOnHover) {\n return;\n }\n\n if (shouldHideOnChildrenLeave) {\n handleHide();\n\n return;\n }\n\n timeout.current = window.setTimeout(() => {\n handleHide();\n }, 500);\n }, [handleHide, shouldHideOnChildrenLeave, shouldShowOnHover]);\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (!popupContentRef.current?.contains(event.target as Node)) {\n handleHide();\n }\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 if (!newContainer) {\n return;\n }\n\n setPortal(() =>\n createPortal(\n <AnimatePresence initial={false}>\n {isOpen && (\n <PopupContentWrapper\n width={pseudoSize?.width ?? 0}\n offset={offset}\n shouldScrollWithContent={shouldScrollWithContent}\n coordinates={coordinates}\n key={`tooltip_${uuid}`}\n maxHeight={contentMaxHeight}\n alignment={internalAlignment}\n ref={popupContentRef}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n >\n <AreaContextProvider shouldChangeColor>\n {content}\n </AreaContextProvider>\n </PopupContentWrapper>\n )}\n </AnimatePresence>,\n newContainer,\n ),\n );\n }, [\n contentMaxHeight,\n internalAlignment,\n newContainer,\n content,\n coordinates,\n handleMouseEnter,\n handleMouseLeave,\n isOpen,\n offset,\n pseudoSize?.width,\n uuid,\n shouldScrollWithContent,\n ]);\n\n return (\n <>\n {measuredElement}\n <StyledPopup\n className=\"beta-chayns-popup\"\n ref={popupRef}\n onClick={handleChildrenClick}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n $shouldUseChildrenWidth={shouldUseChildrenWidth}\n $shouldUseFullWidth={shouldUseFullWidth}\n >\n {children}\n </StyledPopup>\n {portal}\n </>\n );\n },\n);\n\nPopup.displayName = 'Popup';\n\nexport default Popup;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AAUA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,oBAAA,GAAAD,sBAAA,CAAAP,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AAAuD,SAAAO,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAA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,EACNF,MAAM,EACNM,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEY,KAAK,EACjBH,IAAI,EACJ5B,uBAAuB,CAC1B,CAAC;EAEF,oBACIxC,OAAA,CAAAY,OAAA,CAAA0H,aAAA,CAAAtI,OAAA,CAAAY,OAAA,CAAAkI,QAAA,QACKtE,eAAe,eAChBxE,OAAA,CAAAY,OAAA,CAAA0H,aAAA,CAAC9H,MAAA,CAAAuI,WAAW;IACRC,SAAS,EAAC,mBAAmB;IAC7BrG,GAAG,EAAEiC,QAAS;IACdqE,OAAO,EAAE5B,mBAAoB;IAC7BsB,YAAY,EAAElB,gBAAiB;IAC/BmB,YAAY,EAAErB,gBAAiB;IAC/B2B,uBAAuB,EAAE3G,sBAAuB;IAChD4G,mBAAmB,EAAE1G;EAAmB,GAEvCL,QACQ,CAAC,EACbqB,MACH,CAAC;AAEX,CACJ,CAAC;AAED5B,KAAK,CAACuH,WAAW,GAAG,OAAO;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA1I,OAAA,GAEbiB,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"Popup.js","names":["_react","require","_react2","_interopRequireWildcard","_reactDom","_uuid","_popup","_AreaContextProvider","_interopRequireDefault","_PopupContentWrapper","_Popup","_element","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Popup","forwardRef","alignment","content","onShow","container","onHide","children","shouldHideOnChildrenLeave","shouldShowOnHover","shouldUseChildrenWidth","shouldScrollWithContent","shouldUseFullWidth","yOffset","shouldBeOpen","ref","coordinates","setCoordinates","useState","x","y","internalAlignment","setInternalAlignment","PopupAlignment","TopLeft","offset","setOffset","isOpen","setIsOpen","portal","setPortal","pseudoSize","setPseudoSize","newContainer","setNewContainer","contentMaxHeight","setContentMaxHeight","undefined","timeout","useRef","uuid","useUuid","height","width","measuredElement","useMeasuredClone","shouldPreventTextWrapping","popupContentRef","popupRef","useEffect","current","el","element","closest","Element","handleShow","useCallback","pseudoHeight","pseudoWidth","childrenHeight","left","childrenLeft","top","childrenTop","childrenWidth","getBoundingClientRect","document","body","containerHeight","containerWidth","zoomX","offsetWidth","zoomY","offsetHeight","BottomLeft","BottomRight","isRight","scrollLeft","scrollTop","newOffset","window","innerWidth","right","newX","TopRight","viewHeight","clientHeight","TopCenter","includes","handleChildrenClick","handleHide","handleMouseEnter","clearTimeout","handleMouseLeave","setTimeout","handleDocumentClick","event","_popupContentRef$curr","contains","target","useImperativeHandle","hide","show","addEventListener","removeEventListener","createPortal","createElement","AnimatePresence","initial","key","maxHeight","onMouseLeave","onMouseEnter","shouldChangeColor","Fragment","StyledPopup","className","onClick","$shouldUseChildrenWidth","$shouldUseFullWidth","displayName","_default","exports"],"sources":["../../../../src/components/popup/Popup.tsx"],"sourcesContent":["import { AnimatePresence } from 'motion/react';\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 '../../types/popup';\nimport AreaContextProvider from '../area-provider/AreaContextProvider';\nimport PopupContentWrapper from './popup-content-wrapper/PopupContentWrapper';\nimport { StyledPopup } from './Popup.styles';\nimport { useMeasuredClone } from '../../hooks/element';\n\nexport type PopupProps = {\n /**\n * The alignment of the popup. By default, the popup will calculate the best alignment.\n */\n alignment?: PopupAlignment;\n /**\n * The element over which the content of the `ContextMenu` should be displayed.\n */\n children?: ReactNode;\n /**\n * The element where the content of the `Popup` should be rendered via React Portal.\n */\n container?: Element;\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 tooltip should be hidden after the children is not hovered.\n */\n shouldHideOnChildrenLeave?: boolean;\n /**\n * Whether the popup should scroll with the content.\n */\n shouldScrollWithContent?: boolean;\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 * Whether the width of the children should be used.\n */\n shouldUseChildrenWidth?: boolean;\n /**\n * Whether the popup children should use the full width.\n */\n shouldUseFullWidth?: boolean;\n /**\n * The Y offset of the popup to the children.\n */\n yOffset?: number;\n /**\n * Whether the popup should be open. This can be used to control the popup from outside.\n */\n shouldBeOpen?: boolean;\n};\n\nconst Popup = forwardRef<PopupRef, PopupProps>(\n (\n {\n alignment,\n content,\n onShow,\n container,\n onHide,\n children,\n shouldHideOnChildrenLeave,\n shouldShowOnHover = false,\n shouldUseChildrenWidth = true,\n shouldScrollWithContent = true,\n shouldUseFullWidth = false,\n yOffset = 0,\n shouldBeOpen = false,\n },\n ref,\n ) => {\n const [coordinates, setCoordinates] = useState<PopupCoordinates>({\n x: 0,\n y: 0,\n });\n\n const [internalAlignment, setInternalAlignment] = useState<PopupAlignment>(\n PopupAlignment.TopLeft,\n );\n const [offset, setOffset] = useState<number>(0);\n const [isOpen, setIsOpen] = useState(shouldBeOpen);\n const [portal, setPortal] = useState<ReactPortal>();\n const [pseudoSize, setPseudoSize] = useState<{ height: number; width: number }>();\n const [newContainer, setNewContainer] = useState<Element | null>(container ?? null);\n const [contentMaxHeight, setContentMaxHeight] = useState<number | undefined>(undefined);\n\n const timeout = useRef<number>();\n\n const uuid = useUuid();\n\n const { height, width, measuredElement } = useMeasuredClone({\n content,\n shouldPreventTextWrapping: !shouldUseChildrenWidth,\n });\n\n const popupContentRef = useRef<HTMLDivElement>(null);\n const popupRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (popupRef.current && !container) {\n const el = popupRef.current as HTMLElement;\n\n const element = el.closest('.dialog-inner, .page-provider, .tapp, body');\n\n setNewContainer(element);\n }\n }, [container]);\n\n useEffect(() => {\n if (container instanceof Element) {\n setNewContainer(container);\n }\n }, [container]);\n\n useEffect(() => {\n setPseudoSize({ height, width });\n }, [height, width]);\n\n const handleShow = useCallback(() => {\n if (popupRef.current && pseudoSize) {\n if (!newContainer) {\n return;\n }\n\n const { height: pseudoHeight, width: pseudoWidth } = pseudoSize;\n\n const {\n height: childrenHeight,\n left: childrenLeft,\n top: childrenTop,\n width: childrenWidth,\n } = popupRef.current.getBoundingClientRect();\n\n const element = shouldScrollWithContent ? newContainer : document.body;\n\n const {\n height: containerHeight,\n width: containerWidth,\n top,\n left,\n } = element.getBoundingClientRect();\n\n const zoomX = containerWidth / (element as HTMLElement).offsetWidth;\n const zoomY = containerHeight / (element as HTMLElement).offsetHeight;\n\n if (\n pseudoHeight > childrenTop - 25 ||\n alignment === PopupAlignment.BottomLeft ||\n alignment === PopupAlignment.BottomRight\n ) {\n let isRight = false;\n\n if (\n pseudoWidth > childrenLeft + childrenWidth / 2 - 25 ||\n alignment === PopupAlignment.BottomRight\n ) {\n setInternalAlignment(PopupAlignment.BottomRight);\n\n isRight = true;\n } else {\n setInternalAlignment(PopupAlignment.BottomLeft);\n }\n\n const x =\n (childrenLeft + childrenWidth / 2 - left) / zoomX + element.scrollLeft;\n const y =\n (childrenTop + childrenHeight / 2 - top) / zoomY +\n element.scrollTop -\n yOffset;\n\n let newOffset;\n\n if (isRight) {\n newOffset =\n x + pseudoWidth >= window.innerWidth\n ? x + pseudoWidth - window.innerWidth\n : 0;\n } else {\n newOffset = 0;\n\n const right = window.innerWidth - (childrenLeft + childrenWidth / 2);\n\n newOffset =\n right + pseudoWidth >= window.innerWidth\n ? right + pseudoWidth - window.innerWidth\n : 0;\n }\n\n setOffset(newOffset);\n\n const newX = x - newOffset;\n\n setCoordinates({\n x: newX < 23 ? 23 : newX,\n y,\n });\n } else {\n let isRight = false;\n\n if (\n pseudoWidth > childrenLeft + childrenWidth / 2 - 25 ||\n alignment === PopupAlignment.TopRight\n ) {\n setInternalAlignment(PopupAlignment.TopRight);\n\n isRight = true;\n } else {\n setInternalAlignment(PopupAlignment.TopLeft);\n }\n\n const x =\n (childrenLeft + childrenWidth / 2 - left) / zoomX + element.scrollLeft;\n const y =\n (childrenTop + childrenHeight / 2 - top) / zoomY +\n element.scrollTop -\n yOffset;\n\n let newOffset;\n\n if (isRight) {\n newOffset =\n x + pseudoWidth >= window.innerWidth\n ? x + pseudoWidth - window.innerWidth\n : 0;\n } else {\n newOffset = 0;\n\n const right = window.innerWidth - (childrenLeft + childrenWidth / 2);\n\n newOffset =\n right + pseudoWidth >= window.innerWidth\n ? right + pseudoWidth - window.innerWidth\n : 0;\n }\n\n setOffset(newOffset);\n\n const newX = x - newOffset;\n\n setCoordinates({\n x: newX < 23 ? 23 : newX,\n y,\n });\n }\n\n setIsOpen(true);\n }\n }, [alignment, newContainer, pseudoSize, shouldScrollWithContent, yOffset]);\n\n useEffect(() => {\n if (shouldBeOpen) {\n handleShow();\n }\n }, [handleShow, shouldBeOpen]);\n\n useEffect(() => {\n if (!newContainer || !popupRef.current) return;\n\n const viewHeight = newContainer.clientHeight;\n const childrenHeight = popupRef.current.getBoundingClientRect().height;\n\n if (\n [\n PopupAlignment.TopLeft,\n PopupAlignment.TopRight,\n PopupAlignment.TopCenter,\n ].includes(internalAlignment)\n ) {\n setContentMaxHeight(coordinates.y - 20);\n } else {\n setContentMaxHeight(viewHeight - childrenHeight - coordinates.y - 20);\n }\n }, [coordinates.y, internalAlignment, newContainer]);\n\n const handleChildrenClick = () => {\n handleShow();\n };\n\n const handleHide = useCallback(() => {\n setIsOpen(false);\n }, []);\n\n const handleMouseEnter = useCallback(() => {\n if (shouldShowOnHover) {\n window.clearTimeout(timeout.current);\n handleShow();\n }\n }, [handleShow, shouldShowOnHover]);\n\n const handleMouseLeave = useCallback(() => {\n if (!shouldShowOnHover) {\n return;\n }\n\n if (shouldHideOnChildrenLeave) {\n handleHide();\n\n return;\n }\n\n timeout.current = window.setTimeout(() => {\n handleHide();\n }, 500);\n }, [handleHide, shouldHideOnChildrenLeave, shouldShowOnHover]);\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (!popupContentRef.current?.contains(event.target as Node)) {\n handleHide();\n }\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 && !shouldBeOpen) {\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, shouldBeOpen]);\n\n useEffect(() => {\n if (!newContainer) {\n return;\n }\n\n setPortal(() =>\n createPortal(\n <AnimatePresence initial={false}>\n {isOpen && (\n <PopupContentWrapper\n width={pseudoSize?.width ?? 0}\n offset={offset}\n shouldScrollWithContent={shouldScrollWithContent}\n coordinates={coordinates}\n key={`tooltip_${uuid}`}\n maxHeight={contentMaxHeight}\n alignment={internalAlignment}\n ref={popupContentRef}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n >\n <AreaContextProvider shouldChangeColor>\n {content}\n </AreaContextProvider>\n </PopupContentWrapper>\n )}\n </AnimatePresence>,\n newContainer,\n ),\n );\n }, [\n contentMaxHeight,\n internalAlignment,\n newContainer,\n content,\n coordinates,\n handleMouseEnter,\n handleMouseLeave,\n isOpen,\n offset,\n pseudoSize?.width,\n uuid,\n shouldScrollWithContent,\n ]);\n\n return (\n <>\n {measuredElement}\n <StyledPopup\n className=\"beta-chayns-popup\"\n ref={popupRef}\n onClick={handleChildrenClick}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n $shouldUseChildrenWidth={shouldUseChildrenWidth}\n $shouldUseFullWidth={shouldUseFullWidth}\n >\n {children}\n </StyledPopup>\n {portal}\n </>\n );\n },\n);\n\nPopup.displayName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C,EACbsB,MACH,CAAC;AAEX,CACJ,CAAC;AAED7B,KAAK,CAACwH,WAAW,GAAG,OAAO;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA3I,OAAA,GAEbiB,KAAK","ignoreList":[]}
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _reactCompilerRuntime = require("react-compiler-runtime");
7
8
  var _react = _interopRequireWildcard(require("react"));
8
9
  var _uuid = require("../../hooks/uuid");
9
10
  var _ProgressBar = require("./ProgressBar.styles");
@@ -12,140 +13,252 @@ var _styledComponents = require("styled-components");
12
13
  var _Popup = _interopRequireDefault(require("../popup/Popup"));
13
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
15
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
15
- const ProgressBar = ({
16
- percentage,
17
- label,
18
- shouldHideProgress = false,
19
- shouldShowLabelInline = false,
20
- steps,
21
- colors,
22
- thumbLabel,
23
- showShine = false,
24
- height
25
- }) => {
26
- 'use memo';
16
+ const ProgressBar = t0 => {
17
+ "use memo";
27
18
 
19
+ const $ = (0, _reactCompilerRuntime.c)(39);
20
+ const {
21
+ percentage,
22
+ label,
23
+ shouldHideProgress: t1,
24
+ shouldShowLabelInline: t2,
25
+ steps,
26
+ colors,
27
+ thumbLabel,
28
+ showShine: t3,
29
+ height
30
+ } = t0;
31
+ const shouldHideProgress = t1 === undefined ? false : t1;
32
+ const shouldShowLabelInline = t2 === undefined ? false : t2;
33
+ const showShine = t3 === undefined ? false : t3;
28
34
  const uuid = (0, _uuid.useUuid)();
29
35
  const [coordinates, setCoordinates] = (0, _react.useState)();
30
36
  const popupRef = (0, _react.useRef)(null);
31
- const hostContainerRef = (0, _react.useRef)(null);
37
+ const [hostContainer, setHostContainer] = (0, _react.useState)(null);
32
38
  const theme = (0, _react.useContext)(_styledComponents.ThemeContext);
33
- const shineEffect = (0, _react.useMemo)(() => {
34
- if (!showShine || percentage === undefined) return null;
35
- const MIN_ANIMATION_LENGTH = 1;
36
- const MAX_ANIMATION_LENGTH = 5;
37
- const MAX_SHINE_COUNT = 6;
39
+ let t4;
40
+ bb0: {
41
+ if (!showShine || percentage === undefined) {
42
+ t4 = null;
43
+ break bb0;
44
+ }
38
45
  const t = percentage / 100;
39
- const shineCount = Math.ceil(MAX_SHINE_COUNT * t);
40
- const speed = MIN_ANIMATION_LENGTH + (MAX_ANIMATION_LENGTH - MIN_ANIMATION_LENGTH) * t;
41
- return Array.from({
42
- length: shineCount
43
- }).map((_, index) => /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarShine
44
- /* eslint-disable-next-line react/no-array-index-key */, {
45
- key: `progress-bar-shine__${shineCount}__${index}`,
46
- $speed: speed,
47
- $delay: -(speed / shineCount) * index
48
- }));
49
- }, [percentage, showShine]);
50
- (0, _react.useEffect)(() => {
51
- var _hostContainerRef$cur;
52
- if (thumbLabel) setCoordinates((_hostContainerRef$cur = hostContainerRef.current) === null || _hostContainerRef$cur === void 0 ? void 0 : _hostContainerRef$cur.getBoundingClientRect());
53
- }, [thumbLabel]);
54
- (0, _react.useEffect)(() => {
55
- var _popupRef$current;
56
- if (coordinates) (_popupRef$current = popupRef.current) === null || _popupRef$current === void 0 || _popupRef$current.show();
57
- }, [coordinates]);
58
- const progressBar = (0, _react.useMemo)(() => {
59
- if (shouldHideProgress) {
60
- return null;
46
+ const shineCount = Math.ceil(6 * t);
47
+ const speed = 1 + 4 * t;
48
+ let t5;
49
+ if ($[0] !== shineCount) {
50
+ t5 = Array.from({
51
+ length: shineCount
52
+ });
53
+ $[0] = shineCount;
54
+ $[1] = t5;
55
+ } else {
56
+ t5 = $[1];
57
+ }
58
+ let t6;
59
+ if ($[2] !== shineCount || $[3] !== speed || $[4] !== t5) {
60
+ t6 = t5.map((_, index) => /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarShine, {
61
+ key: `progress-bar-shine__${shineCount}__${index}`,
62
+ $speed: speed,
63
+ $delay: -(speed / shineCount) * index
64
+ }));
65
+ $[2] = shineCount;
66
+ $[3] = speed;
67
+ $[4] = t5;
68
+ $[5] = t6;
69
+ } else {
70
+ t6 = $[5];
61
71
  }
62
- if (percentage === undefined) {
63
- return /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarProgressWrapper, null, /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledMotionProgressBarProgress, {
64
- key: `progress-bar-loop__${uuid}`,
72
+ t4 = t6;
73
+ }
74
+ const shineEffect = t4;
75
+ let t5;
76
+ let t6;
77
+ if ($[6] !== hostContainer || $[7] !== thumbLabel) {
78
+ t5 = () => {
79
+ if (thumbLabel) {
80
+ setCoordinates(hostContainer === null || hostContainer === void 0 ? void 0 : hostContainer.getBoundingClientRect());
81
+ }
82
+ };
83
+ t6 = [hostContainer, thumbLabel];
84
+ $[6] = hostContainer;
85
+ $[7] = thumbLabel;
86
+ $[8] = t5;
87
+ $[9] = t6;
88
+ } else {
89
+ t5 = $[8];
90
+ t6 = $[9];
91
+ }
92
+ (0, _react.useEffect)(t5, t6);
93
+ let t7;
94
+ let t8;
95
+ if ($[10] !== coordinates) {
96
+ t7 = () => {
97
+ if (coordinates) {
98
+ var _popupRef$current;
99
+ (_popupRef$current = popupRef.current) === null || _popupRef$current === void 0 || _popupRef$current.show();
100
+ }
101
+ };
102
+ t8 = [coordinates];
103
+ $[10] = coordinates;
104
+ $[11] = t7;
105
+ $[12] = t8;
106
+ } else {
107
+ t7 = $[11];
108
+ t8 = $[12];
109
+ }
110
+ (0, _react.useEffect)(t7, t8);
111
+ let t9;
112
+ if ($[13] !== (colors === null || colors === void 0 ? void 0 : colors.backgroundColor) || $[14] !== (colors === null || colors === void 0 ? void 0 : colors.primaryTextColor) || $[15] !== (colors === null || colors === void 0 ? void 0 : colors.progressColor) || $[16] !== (colors === null || colors === void 0 ? void 0 : colors.secondaryTextColor) || $[17] !== (colors === null || colors === void 0 ? void 0 : colors.stepColor) || $[18] !== (colors === null || colors === void 0 ? void 0 : colors.thumbLabelColor) || $[19] !== height || $[20] !== hostContainer || $[21] !== label || $[22] !== percentage || $[23] !== shineEffect || $[24] !== shouldHideProgress || $[25] !== shouldShowLabelInline || $[26] !== showShine || $[27] !== steps || $[28] !== theme || $[29] !== thumbLabel || $[30] !== uuid) {
113
+ colors === null || colors === void 0 || colors.backgroundColor;
114
+ colors === null || colors === void 0 || colors.primaryTextColor;
115
+ colors === null || colors === void 0 || colors.progressColor;
116
+ colors === null || colors === void 0 || colors.secondaryTextColor;
117
+ colors === null || colors === void 0 || colors.stepColor;
118
+ colors === null || colors === void 0 || colors.thumbLabelColor;
119
+ t9 = (() => {
120
+ if (shouldHideProgress) {
121
+ return null;
122
+ }
123
+ if (percentage === undefined) {
124
+ return /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarProgressWrapper, null, /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledMotionProgressBarProgress, {
125
+ key: `progress-bar-loop__${uuid}`,
126
+ $color: colors === null || colors === void 0 ? void 0 : colors.progressColor,
127
+ initial: {
128
+ width: "200px",
129
+ left: "-200px"
130
+ },
131
+ animate: {
132
+ width: "200px",
133
+ left: "100%"
134
+ },
135
+ exit: {
136
+ width: "200px",
137
+ left: "100%"
138
+ },
139
+ transition: {
140
+ type: "tween",
141
+ repeat: Infinity,
142
+ repeatDelay: 0,
143
+ duration: 1
144
+ }
145
+ }), /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarBackground, {
146
+ $color: colors === null || colors === void 0 ? void 0 : colors.backgroundColor
147
+ }));
148
+ }
149
+ return /*#__PURE__*/_react.default.createElement("div", {
150
+ ref: instance => setHostContainer(instance),
151
+ style: {
152
+ border: 0
153
+ }
154
+ }, /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarProgressWrapper, {
155
+ $isBig: shouldShowLabelInline,
156
+ $height: height
157
+ }, !!(steps !== null && steps !== void 0 && steps.length) && /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarStepWrapper, null, steps.map(step => /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarStep, {
158
+ $position: step,
159
+ key: `progress-step-${step}`,
160
+ $color: colors === null || colors === void 0 ? void 0 : colors.stepColor
161
+ }))), /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledMotionProgressBarProgress, {
162
+ $height: height,
65
163
  $color: colors === null || colors === void 0 ? void 0 : colors.progressColor,
164
+ key: `progress-bar__${uuid}`,
66
165
  initial: {
67
- width: '200px',
68
- left: '-200px'
166
+ width: "0%"
69
167
  },
70
168
  animate: {
71
- width: '200px',
72
- left: '100%'
169
+ width: `${percentage}%`
73
170
  },
74
171
  exit: {
75
- width: '200px',
76
- left: '100%'
172
+ width: "0%"
77
173
  },
78
174
  transition: {
79
- type: 'tween',
80
- repeat: Infinity,
81
- repeatDelay: 0,
82
- duration: 1
175
+ type: "tween"
176
+ },
177
+ onUpdate: () => {
178
+ var _popupRef$current2;
179
+ return (_popupRef$current2 = popupRef.current) === null || _popupRef$current2 === void 0 ? void 0 : _popupRef$current2.show();
180
+ },
181
+ onAnimationComplete: () => {
182
+ var _popupRef$current3;
183
+ return (_popupRef$current3 = popupRef.current) === null || _popupRef$current3 === void 0 ? void 0 : _popupRef$current3.show();
83
184
  }
84
- }), /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarBackground, {
185
+ }, showShine && shineEffect, thumbLabel && /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarThumbLabel, {
186
+ onClick: _temp
187
+ }, /*#__PURE__*/_react.default.createElement(_styledComponents.ThemeProvider, {
188
+ theme: {
189
+ "000": (colors === null || colors === void 0 ? void 0 : colors.thumbLabelColor) ?? (theme === null || theme === void 0 ? void 0 : theme["104"]),
190
+ text: (colors === null || colors === void 0 ? void 0 : colors.secondaryTextColor) ?? (theme === null || theme === void 0 ? void 0 : theme["300"])
191
+ }
192
+ }, /*#__PURE__*/_react.default.createElement(_Popup.default, {
193
+ ref: popupRef,
194
+ content: thumbLabel,
195
+ alignment: _popup.PopupAlignment.TopCenter,
196
+ onHide: () => {
197
+ var _popupRef$current4;
198
+ return (_popupRef$current4 = popupRef.current) === null || _popupRef$current4 === void 0 ? void 0 : _popupRef$current4.show();
199
+ },
200
+ container: hostContainer ?? undefined,
201
+ shouldUseChildrenWidth: true,
202
+ shouldBeOpen: true
203
+ })))), shouldShowLabelInline && label && /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarLabel, {
204
+ $shouldShowLabelInline: shouldShowLabelInline,
205
+ $primaryColor: colors === null || colors === void 0 ? void 0 : colors.primaryTextColor,
206
+ $secondaryColor: colors === null || colors === void 0 ? void 0 : colors.secondaryTextColor,
207
+ $colorSplitPosition: percentage
208
+ }, label), /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarBackground, {
85
209
  $color: colors === null || colors === void 0 ? void 0 : colors.backgroundColor
86
- }));
87
- }
88
- return /*#__PURE__*/_react.default.createElement("div", {
89
- ref: hostContainerRef
90
- }, /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarProgressWrapper, {
91
- $isBig: shouldShowLabelInline,
92
- $height: height
93
- }, !!(steps !== null && steps !== void 0 && steps.length) && /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarStepWrapper, null, steps.map(step => /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarStep, {
94
- $position: step,
95
- key: `progress-step-${step}`,
96
- $color: colors === null || colors === void 0 ? void 0 : colors.stepColor
97
- }))), /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledMotionProgressBarProgress, {
98
- $color: colors === null || colors === void 0 ? void 0 : colors.progressColor,
99
- key: `progress-bar__${uuid}`,
100
- initial: {
101
- width: '0%'
102
- },
103
- animate: {
104
- width: `${percentage}%`
105
- },
106
- exit: {
107
- width: '0%'
108
- },
109
- transition: {
110
- type: 'tween'
111
- },
112
- onUpdate: () => {
113
- var _popupRef$current2;
114
- return (_popupRef$current2 = popupRef.current) === null || _popupRef$current2 === void 0 ? void 0 : _popupRef$current2.show();
115
- },
116
- onAnimationComplete: () => {
117
- var _popupRef$current3;
118
- return (_popupRef$current3 = popupRef.current) === null || _popupRef$current3 === void 0 ? void 0 : _popupRef$current3.show();
119
- }
120
- }, showShine && shineEffect, thumbLabel && /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarThumbLabel, {
121
- onClick: event => event.stopPropagation()
122
- }, /*#__PURE__*/_react.default.createElement(_styledComponents.ThemeProvider, {
123
- theme: {
124
- '000': (colors === null || colors === void 0 ? void 0 : colors.backgroundColor) ?? (theme === null || theme === void 0 ? void 0 : theme['104']),
125
- text: (colors === null || colors === void 0 ? void 0 : colors.secondaryTextColor) ?? (theme === null || theme === void 0 ? void 0 : theme['300'])
126
- }
127
- }, /*#__PURE__*/_react.default.createElement(_Popup.default, {
128
- ref: popupRef,
129
- content: thumbLabel,
130
- alignment: _popup.PopupAlignment.TopCenter,
131
- onHide: () => {
132
- var _popupRef$current4;
133
- return (_popupRef$current4 = popupRef.current) === null || _popupRef$current4 === void 0 ? void 0 : _popupRef$current4.show();
134
- },
135
- container: hostContainerRef.current ?? undefined
136
- })))), shouldShowLabelInline && label && /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarLabel, {
137
- $shouldShowLabelInline: shouldShowLabelInline,
138
- $primaryColor: colors === null || colors === void 0 ? void 0 : colors.primaryTextColor,
139
- $secondaryColor: colors === null || colors === void 0 ? void 0 : colors.secondaryTextColor,
140
- $colorSplitPosition: percentage
141
- }, label), /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarBackground, {
142
- $color: colors === null || colors === void 0 ? void 0 : colors.backgroundColor
143
- })));
144
- }, [colors === null || colors === void 0 ? void 0 : colors.backgroundColor, colors === null || colors === void 0 ? void 0 : colors.primaryTextColor, colors === null || colors === void 0 ? void 0 : colors.progressColor, colors === null || colors === void 0 ? void 0 : colors.secondaryTextColor, colors === null || colors === void 0 ? void 0 : colors.stepColor, height, label, percentage, shineEffect, shouldHideProgress, shouldShowLabelInline, showShine, steps, theme, thumbLabel, uuid]);
145
- return (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBar, null, progressBar, label && !shouldShowLabelInline && /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarLabel, {
146
- $primaryColor: colors === null || colors === void 0 ? void 0 : colors.primaryTextColor
147
- }, label)), [colors === null || colors === void 0 ? void 0 : colors.primaryTextColor, label, progressBar, shouldShowLabelInline]);
210
+ })));
211
+ })();
212
+ $[13] = colors === null || colors === void 0 ? void 0 : colors.backgroundColor;
213
+ $[14] = colors === null || colors === void 0 ? void 0 : colors.primaryTextColor;
214
+ $[15] = colors === null || colors === void 0 ? void 0 : colors.progressColor;
215
+ $[16] = colors === null || colors === void 0 ? void 0 : colors.secondaryTextColor;
216
+ $[17] = colors === null || colors === void 0 ? void 0 : colors.stepColor;
217
+ $[18] = colors === null || colors === void 0 ? void 0 : colors.thumbLabelColor;
218
+ $[19] = height;
219
+ $[20] = hostContainer;
220
+ $[21] = label;
221
+ $[22] = percentage;
222
+ $[23] = shineEffect;
223
+ $[24] = shouldHideProgress;
224
+ $[25] = shouldShowLabelInline;
225
+ $[26] = showShine;
226
+ $[27] = steps;
227
+ $[28] = theme;
228
+ $[29] = thumbLabel;
229
+ $[30] = uuid;
230
+ $[31] = t9;
231
+ } else {
232
+ t9 = $[31];
233
+ }
234
+ const progressBar = t9;
235
+ colors === null || colors === void 0 || colors.primaryTextColor;
236
+ let t10;
237
+ if ($[32] !== (colors === null || colors === void 0 ? void 0 : colors.primaryTextColor) || $[33] !== label || $[34] !== shouldShowLabelInline) {
238
+ t10 = label && !shouldShowLabelInline && /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBarLabel, {
239
+ $primaryColor: colors === null || colors === void 0 ? void 0 : colors.primaryTextColor
240
+ }, label);
241
+ $[32] = colors === null || colors === void 0 ? void 0 : colors.primaryTextColor;
242
+ $[33] = label;
243
+ $[34] = shouldShowLabelInline;
244
+ $[35] = t10;
245
+ } else {
246
+ t10 = $[35];
247
+ }
248
+ let t11;
249
+ if ($[36] !== progressBar || $[37] !== t10) {
250
+ t11 = /*#__PURE__*/_react.default.createElement(_ProgressBar.StyledProgressBar, null, progressBar, t10);
251
+ $[36] = progressBar;
252
+ $[37] = t10;
253
+ $[38] = t11;
254
+ } else {
255
+ t11 = $[38];
256
+ }
257
+ return t11;
148
258
  };
149
259
  ProgressBar.displayName = 'ProgressBar';
150
260
  var _default = exports.default = ProgressBar;
261
+ function _temp(event) {
262
+ return event.stopPropagation();
263
+ }
151
264
  //# sourceMappingURL=ProgressBar.js.map