@vibe/dialog 4.0.0-alpha.1 → 4.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Dialog/Dialog.d.ts +4 -4
- package/dist/Dialog/Dialog.js.map +1 -1
- package/dist/Dialog/Dialog.module.scss.js +1 -1
- package/dist/Dialog/Dialog.types.d.ts +214 -214
- package/dist/Dialog/DialogConstants.d.ts +8 -8
- package/dist/Dialog/components/DialogContent/DialogContent.d.ts +79 -79
- package/dist/Dialog/components/DialogContent/DialogContent.js.map +1 -1
- package/dist/Dialog/components/DialogContent/DialogContent.module.scss.js +1 -1
- package/dist/Dialog/components/Refable/Refable.d.ts +18 -18
- package/dist/Dialog/components/Refable/Refable.js.map +1 -1
- package/dist/Dialog/hooks/useDisableScroll.d.ts +5 -5
- package/dist/Dialog/hooks/useDisableScroll.js.map +1 -1
- package/dist/Dialog/index.d.ts +3 -3
- package/dist/DialogContentContainer/DialogContentContainer.d.ts +36 -36
- package/dist/DialogContentContainer/DialogContentContainer.module.scss.js +1 -1
- package/dist/DialogContentContainer/index.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/mocked_classnames/Dialog/Dialog.d.ts +4 -4
- package/dist/mocked_classnames/Dialog/Dialog.js.map +1 -1
- package/dist/mocked_classnames/Dialog/Dialog.module.scss.js +1 -1
- package/dist/mocked_classnames/Dialog/Dialog.types.d.ts +214 -214
- package/dist/mocked_classnames/Dialog/DialogConstants.d.ts +8 -8
- package/dist/mocked_classnames/Dialog/components/DialogContent/DialogContent.d.ts +79 -79
- package/dist/mocked_classnames/Dialog/components/DialogContent/DialogContent.js.map +1 -1
- package/dist/mocked_classnames/Dialog/components/DialogContent/DialogContent.module.scss.js +1 -1
- package/dist/mocked_classnames/Dialog/components/Refable/Refable.d.ts +18 -18
- package/dist/mocked_classnames/Dialog/components/Refable/Refable.js.map +1 -1
- package/dist/mocked_classnames/Dialog/hooks/useDisableScroll.d.ts +5 -5
- package/dist/mocked_classnames/Dialog/hooks/useDisableScroll.js.map +1 -1
- package/dist/mocked_classnames/Dialog/index.d.ts +3 -3
- package/dist/mocked_classnames/DialogContentContainer/DialogContentContainer.d.ts +36 -36
- package/dist/mocked_classnames/DialogContentContainer/DialogContentContainer.module.scss.js +1 -1
- package/dist/mocked_classnames/DialogContentContainer/index.d.ts +1 -1
- package/dist/mocked_classnames/index.d.ts +2 -2
- package/package.json +8 -7
package/dist/Dialog/Dialog.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { type DialogProps } from "./Dialog.types";
|
|
3
|
-
declare function Dialog({ id, "data-testid": dataTestId, children, content, position, moveBy, middleware: middlewareProp, startingEdge, showDelay, hideDelay, instantShowAndHide, getDynamicShowDelay, showTrigger, hideTrigger, showOnDialogEnter, showTriggerIgnoreClass, hideTriggerIgnoreClass, addKeyboardHideShowTriggersByDefault, shouldShowOnMount, disable, open, isOpen: isOpenProp, useDerivedStateFromProps, animationType, preventAnimationOnMount, tooltip, tooltipClassName, containerSelector, disableContainerScroll, zIndex, wrapperClassName, referenceWrapperClassName, referenceWrapperElement, onBlur: onBlurProp, onKeyDown: onKeyDownProp, onClick: onClickProp, onFocus: onFocusProp, onMouseDown: onMouseDownProp, onMouseEnter: onMouseEnterProp, onMouseLeave: onMouseLeaveProp, onContextMenu: onContextMenuProp, onDialogDidShow, onDialogDidHide, onClickOutside: onClickOutsideProp, onContentClick: onContentClickProp, hideWhenReferenceHidden, shouldCallbackOnMount, observeContentResize }: DialogProps): React.JSX.Element;
|
|
4
|
-
export default Dialog;
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type DialogProps } from "./Dialog.types";
|
|
3
|
+
declare function Dialog({ id, "data-testid": dataTestId, children, content, position, moveBy, middleware: middlewareProp, startingEdge, showDelay, hideDelay, instantShowAndHide, getDynamicShowDelay, showTrigger, hideTrigger, showOnDialogEnter, showTriggerIgnoreClass, hideTriggerIgnoreClass, addKeyboardHideShowTriggersByDefault, shouldShowOnMount, disable, open, isOpen: isOpenProp, useDerivedStateFromProps, animationType, preventAnimationOnMount, tooltip, tooltipClassName, containerSelector, disableContainerScroll, zIndex, wrapperClassName, referenceWrapperClassName, referenceWrapperElement, onBlur: onBlurProp, onKeyDown: onKeyDownProp, onClick: onClickProp, onFocus: onFocusProp, onMouseDown: onMouseDownProp, onMouseEnter: onMouseEnterProp, onMouseLeave: onMouseLeaveProp, onContextMenu: onContextMenuProp, onDialogDidShow, onDialogDidHide, onClickOutside: onClickOutsideProp, onContentClick: onContentClickProp, hideWhenReferenceHidden, shouldCallbackOnMount, observeContentResize }: DialogProps): React.JSX.Element;
|
|
4
|
+
export default Dialog;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sources":["../../src/Dialog/Dialog.tsx"],"sourcesContent":["import cx from \"classnames\";\nimport React, { useState, useEffect, useRef, useContext, useCallback, useMemo } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport {\n useFloating,\n offset,\n flip,\n shift,\n hide,\n arrow as arrowMiddleware,\n autoUpdate,\n type Placement,\n type Middleware\n} from \"@floating-ui/react-dom\";\nimport { isFunction } from \"es-toolkit\";\nimport {\n chainFunctions,\n chainRefFunctions,\n convertToArray,\n NOOP,\n isInsideClass,\n ComponentDefaultTestId,\n getTestId,\n isClient\n} from \"@vibe/shared\";\nimport DialogContent from \"./components/DialogContent/DialogContent\";\nimport { Refable } from \"./components/Refable/Refable\";\nimport styles from \"./Dialog.module.scss\";\nimport { type DialogTriggerEvent, type DialogEvent, type DialogProps } from \"./Dialog.types\";\nimport { LayerContext, LayerProvider } from \"@vibe/layer\";\n\nfunction Dialog({\n // Core props\n id,\n \"data-testid\": dataTestId,\n children,\n content,\n position = \"top\",\n moveBy = { main: 0, secondary: 0 },\n middleware: middlewareProp = [],\n startingEdge,\n showDelay = 100,\n hideDelay = 100,\n instantShowAndHide = false,\n getDynamicShowDelay,\n showTrigger = \"mouseenter\",\n hideTrigger = \"mouseleave\",\n showOnDialogEnter = false,\n showTriggerIgnoreClass,\n hideTriggerIgnoreClass,\n addKeyboardHideShowTriggersByDefault = true,\n shouldShowOnMount = false,\n disable = false,\n open = false,\n isOpen: isOpenProp,\n useDerivedStateFromProps = false,\n animationType = \"expand\",\n preventAnimationOnMount = false,\n tooltip = false,\n tooltipClassName,\n containerSelector,\n disableContainerScroll,\n zIndex,\n wrapperClassName,\n referenceWrapperClassName,\n referenceWrapperElement,\n onBlur: onBlurProp,\n onKeyDown: onKeyDownProp,\n onClick: onClickProp,\n onFocus: onFocusProp,\n onMouseDown: onMouseDownProp,\n onMouseEnter: onMouseEnterProp,\n onMouseLeave: onMouseLeaveProp,\n onContextMenu: onContextMenuProp,\n onDialogDidShow = NOOP,\n onDialogDidHide = NOOP,\n onClickOutside: onClickOutsideProp = NOOP,\n onContentClick: onContentClickProp = NOOP,\n hideWhenReferenceHidden = false,\n shouldCallbackOnMount = false,\n observeContentResize = false\n}: DialogProps) {\n const [isOpenState, setIsOpenState] = useState(shouldShowOnMount);\n const [preventAnimation, setPreventAnimation] = useState(false);\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null);\n\n const showTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const hideTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const arrowRef = useRef<HTMLDivElement>(null);\n\n // Check if children are valid React elements (Refable returns null for non-elements)\n const hasValidChildren = React.Children.toArray(children).some(child => React.isValidElement(child));\n\n const { layerRef } = useContext(LayerContext);\n\n // Derived state\n const isOpenInternal = useDerivedStateFromProps ? isOpenProp : isOpenState;\n const isShown = isOpenInternal || open;\n\n // Build middleware array for Floating UI\n const floatingMiddleware = useMemo<Middleware[]>(() => {\n const middlewareList: Middleware[] = [];\n\n // Get user-provided middleware (filter out invalid ones)\n const validMiddleware = middlewareProp.filter(\n (m): m is Middleware => m != null && typeof m === \"object\" && typeof m.fn === \"function\"\n );\n\n // Check if user provided their own middleware to override defaults\n const hasCustomOffset = validMiddleware.some(m => m.name === \"offset\");\n const hasCustomFlip = validMiddleware.some(m => m.name === \"flip\");\n const hasCustomShift = validMiddleware.some(m => m.name === \"shift\");\n\n // Offset middleware - skip if user provided their own\n if (!hasCustomOffset && (moveBy.main !== 0 || moveBy.secondary !== 0)) {\n middlewareList.push(offset({ mainAxis: moveBy.main || 0, crossAxis: moveBy.secondary || 0 }));\n }\n\n // Core positioning middleware - skip if user provided their own\n if (!hasCustomFlip) {\n middlewareList.push(flip());\n }\n if (!hasCustomShift) {\n middlewareList.push(shift());\n }\n\n // Add user-provided middleware\n middlewareList.push(...validMiddleware);\n\n // Arrow middleware - pass ref directly, Floating UI handles null refs\n if (tooltip) {\n middlewareList.push(arrowMiddleware({ element: arrowRef }));\n }\n\n // Hide middleware for detecting when reference is hidden\n if (hideWhenReferenceHidden) {\n middlewareList.push(hide());\n }\n\n return middlewareList;\n }, [moveBy.main, moveBy.secondary, tooltip, hideWhenReferenceHidden, middlewareProp]);\n\n // Configure autoUpdate for position tracking\n const whileElementsMounted = useCallback(\n (reference: HTMLElement, floating: HTMLElement, update: () => void) => {\n return autoUpdate(reference, floating, update, {\n elementResize: observeContentResize,\n layoutShift: false\n });\n },\n [observeContentResize]\n );\n\n // Use Floating UI hook\n const { refs, floatingStyles, placement, middlewareData } = useFloating({\n placement: position as Placement,\n middleware: floatingMiddleware,\n whileElementsMounted,\n elements: {\n reference: referenceElement\n }\n });\n\n // Check if reference is hidden (from hide middleware)\n const isReferenceHidden = middlewareData.hide?.referenceHidden ?? false;\n\n const isShowTrigger = useCallback(\n (eventName: DialogTriggerEvent) => {\n const showTriggersArray = convertToArray(showTrigger);\n if (addKeyboardHideShowTriggersByDefault && eventName === \"focus\" && showTriggersArray.includes(\"mouseenter\")) {\n return true;\n }\n return showTriggersArray.includes(eventName);\n },\n [showTrigger, addKeyboardHideShowTriggersByDefault]\n );\n\n const isHideTrigger = useCallback(\n (eventName: DialogTriggerEvent) => {\n const hideTriggersArray = convertToArray(hideTrigger);\n if (addKeyboardHideShowTriggersByDefault && eventName === \"blur\" && hideTriggersArray.includes(\"mouseleave\")) {\n return true;\n }\n return hideTriggersArray.includes(eventName);\n },\n [hideTrigger, addKeyboardHideShowTriggersByDefault]\n );\n\n const showDialog = useCallback(\n (event: DialogEvent, eventName: DialogTriggerEvent | string, options: { preventAnimation?: boolean } = {}) => {\n let finalShowDelay = showDelay;\n let preventAnimationValue = options.preventAnimation;\n if (getDynamicShowDelay) {\n const dynamicDelayObj = getDynamicShowDelay();\n finalShowDelay = dynamicDelayObj.showDelay || 0;\n preventAnimationValue = preventAnimationValue ?? dynamicDelayObj.preventAnimation;\n }\n\n if (instantShowAndHide) {\n onDialogDidShow(event, eventName);\n setIsOpenState(true);\n setPreventAnimation(!!preventAnimationValue);\n showTimeoutRef.current = null;\n } else {\n showTimeoutRef.current = setTimeout(() => {\n onDialogDidShow(event, eventName);\n showTimeoutRef.current = null;\n setIsOpenState(true);\n setPreventAnimation(!!preventAnimationValue);\n }, finalShowDelay);\n }\n },\n [showDelay, getDynamicShowDelay, instantShowAndHide, onDialogDidShow]\n );\n\n const hideDialog = useCallback(\n (event: DialogEvent, eventName: DialogTriggerEvent | string) => {\n if (instantShowAndHide) {\n onDialogDidHide(event, eventName);\n setIsOpenState(false);\n hideTimeoutRef.current = null;\n } else {\n hideTimeoutRef.current = setTimeout(() => {\n onDialogDidHide(event, eventName);\n setIsOpenState(false);\n hideTimeoutRef.current = null;\n }, hideDelay);\n }\n },\n [hideDelay, instantShowAndHide, onDialogDidHide]\n );\n\n const showDialogIfNeeded = useCallback(\n (event: DialogEvent, eventName: DialogTriggerEvent | string, options = {}) => {\n if (disable) {\n return;\n }\n\n if (hideTimeoutRef.current) {\n clearTimeout(hideTimeoutRef.current);\n hideTimeoutRef.current = null;\n }\n\n if (!showTimeoutRef.current) {\n showDialog(event, eventName, options);\n }\n },\n [disable, showDialog]\n );\n\n const hideDialogIfNeeded = useCallback(\n (event: DialogEvent, eventName: DialogTriggerEvent | string) => {\n if (showTimeoutRef.current) {\n clearTimeout(showTimeoutRef.current);\n showTimeoutRef.current = null;\n }\n\n if (!hideTimeoutRef.current) {\n hideDialog(event, eventName);\n }\n },\n [hideDialog]\n );\n\n // Event handling\n const handleEvent = useCallback(\n (eventName: DialogTriggerEvent, target: EventTarget | null, event: DialogEvent) => {\n if (!target) return; // Guard against null targets (e.g., when focus leaves the document)\n if (isShowTrigger(eventName) && !isShown && !isInsideClass(target as HTMLElement, showTriggerIgnoreClass)) {\n return showDialogIfNeeded(event, eventName);\n }\n\n if (isHideTrigger(eventName) && !isInsideClass(target as HTMLElement, hideTriggerIgnoreClass)) {\n return hideDialogIfNeeded(event, eventName);\n }\n },\n [\n isShowTrigger,\n isHideTrigger,\n isShown,\n showTriggerIgnoreClass,\n hideTriggerIgnoreClass,\n showDialogIfNeeded,\n hideDialogIfNeeded\n ]\n );\n\n const getContainer = useCallback(() => {\n if (containerSelector) {\n const containerElement = document.querySelector(containerSelector);\n if (containerElement instanceof Element) {\n return containerElement;\n }\n }\n return layerRef?.current || document.body;\n }, [containerSelector, layerRef]);\n\n // Memoized event handlers to prevent unnecessary re-renders\n const onMouseEnter = useCallback((e: React.MouseEvent) => handleEvent(\"mouseenter\", e.target, e), [handleEvent]);\n const onMouseLeave = useCallback((e: React.MouseEvent) => handleEvent(\"mouseleave\", e.target, e), [handleEvent]);\n const onClick = useCallback(\n (e: React.MouseEvent) => {\n if (e.button) return;\n handleEvent(\"click\", e.target, e);\n },\n [handleEvent]\n );\n const onKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n // Handle element-level keyboard events for triggers\n if (event.key === \"Enter\") handleEvent(\"enter\", event.target, event);\n if (event.key === \"Tab\") handleEvent(\"tab\", event.target, event);\n },\n [handleEvent]\n );\n\n const onMouseDown = useCallback(\n (e: React.MouseEvent) => {\n if (e.button) return;\n handleEvent(\"mousedown\", e.target, e);\n },\n [handleEvent]\n );\n const onFocus = useCallback((e: React.FocusEvent) => handleEvent(\"focus\", e.target, e), [handleEvent]);\n const onBlur = useCallback(\n (e: React.FocusEvent) => {\n const target = e.relatedTarget || e.target;\n handleEvent(\"blur\", target, e);\n },\n [handleEvent]\n );\n const onEsc = useCallback((e: React.KeyboardEvent) => handleEvent(\"esckey\", e.target, e), [handleEvent]);\n const onContextMenu = useCallback(\n (e: React.MouseEvent) => {\n if ((isShowTrigger(\"contextmenu\") && !isShown) || (isHideTrigger(\"contextmenu\") && isShown)) {\n e.preventDefault();\n }\n handleEvent(\"contextmenu\", e.target, e);\n },\n [isShown, isShowTrigger, isHideTrigger, handleEvent]\n );\n\n const onClickOutside = useCallback(\n (event: React.MouseEvent) => {\n handleEvent(\"clickoutside\", event.target, event);\n onClickOutsideProp(event);\n },\n [handleEvent, onClickOutsideProp]\n );\n\n const onDialogEnter = useCallback(\n (event: React.MouseEvent) => {\n if (showOnDialogEnter) showDialogIfNeeded(event, \"DialogEnter\");\n },\n [showOnDialogEnter, showDialogIfNeeded]\n );\n\n const onDialogLeave = useCallback(\n (event: React.MouseEvent) => {\n if (showOnDialogEnter) hideDialogIfNeeded(event, \"DialogLeave\");\n },\n [showOnDialogEnter, hideDialogIfNeeded]\n );\n\n const onContentClick = useCallback(\n (e: React.MouseEvent) => {\n handleEvent(\"onContentClick\", e.target, e);\n onContentClickProp(e);\n },\n [handleEvent, onContentClickProp]\n );\n\n // Memoized chained event handlers to prevent Refable children re-renders\n const chainedOnBlur = useMemo(() => chainFunctions([onBlurProp, onBlur], true), [onBlurProp, onBlur]);\n const chainedOnKeyDown = useMemo(() => chainFunctions([onKeyDownProp, onKeyDown], true), [onKeyDownProp, onKeyDown]);\n const chainedOnClick = useMemo(() => chainFunctions([onClickProp, onClick], true), [onClickProp, onClick]);\n const chainedOnFocus = useMemo(() => chainFunctions([onFocusProp, onFocus], true), [onFocusProp, onFocus]);\n const chainedOnMouseDown = useMemo(\n () => chainFunctions([onMouseDownProp, onMouseDown], true),\n [onMouseDownProp, onMouseDown]\n );\n const chainedOnMouseEnter = useMemo(\n () => chainFunctions([onMouseEnterProp, onMouseEnter], true),\n [onMouseEnterProp, onMouseEnter]\n );\n const chainedOnMouseLeave = useMemo(\n () => chainFunctions([onMouseLeaveProp, onMouseLeave], true),\n [onMouseLeaveProp, onMouseLeave]\n );\n const chainedOnContextMenu = useMemo(\n () => chainFunctions([onContextMenuProp, onContextMenu], true),\n [onContextMenuProp, onContextMenu]\n );\n\n // Document-level keyboard handler using stable ref pattern\n // Must handle Escape, Tab, and Enter at document level to match old behavior\n const closeDialogOnEscapeRef = useRef<(event: KeyboardEvent) => void>();\n closeDialogOnEscapeRef.current = (event: KeyboardEvent) => {\n if (!isShown) return;\n\n switch (event.key) {\n case \"Escape\":\n hideDialogIfNeeded(event, \"esckey\");\n break;\n case \"Tab\":\n handleEvent(\"tab\", event.target, event);\n break;\n case \"Enter\":\n handleEvent(\"enter\", event.target, event);\n break;\n }\n };\n\n // Effects\n\n // Callback on mount\n useEffect(() => {\n if (shouldCallbackOnMount && shouldShowOnMount) {\n onDialogDidShow();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Cleanup timeouts on unmount\n useEffect(() => {\n return () => {\n if (showTimeoutRef.current) clearTimeout(showTimeoutRef.current);\n if (hideTimeoutRef.current) clearTimeout(hideTimeoutRef.current);\n };\n }, []);\n\n // Document keyboard listener (stable reference via ref)\n useEffect(() => {\n if (!isClient()) return;\n\n const handler = (event: KeyboardEvent) => closeDialogOnEscapeRef.current?.(event);\n document.addEventListener(\"keyup\", handler);\n return () => document.removeEventListener(\"keyup\", handler);\n }, []);\n\n // Handle reference hidden state\n useEffect(() => {\n if (hideWhenReferenceHidden && isReferenceHidden && isShown) {\n const event = new CustomEvent(\"onReferenceHidden\");\n hideDialog(event, \"onReferenceHidden\");\n }\n }, [hideWhenReferenceHidden, isReferenceHidden, isShown, hideDialog]);\n\n // Computed values\n const overrideDataTestId = dataTestId || getTestId(ComponentDefaultTestId.DIALOG, id);\n\n const arrowStyles = useMemo<React.CSSProperties>(() => {\n if (!middlewareData.arrow) return {};\n const { x, y } = middlewareData.arrow;\n return {\n left: x != null ? `${x}px` : \"\",\n top: y != null ? `${y}px` : \"\",\n transform: \"rotate(45deg)\"\n };\n }, [middlewareData.arrow]);\n\n // Skip Floating UI positioning when no children (e.g. floating Tipseen) — let CSS handle it\n const finalFloatingStyles = useMemo<React.CSSProperties>(\n () =>\n hasValidChildren\n ? { ...floatingStyles, ...(zIndex !== undefined && { zIndex }) }\n : { ...(zIndex !== undefined && { zIndex }) },\n [floatingStyles, zIndex, hasValidChildren]\n );\n\n const animationTypeCalculated = preventAnimationOnMount || preventAnimation ? undefined : animationType;\n const contentRendered = isFunction(content) ? content() : content;\n\n // Early return if no content - wrap in fragment for type safety\n if (!contentRendered) {\n return <>{children}</>;\n }\n\n const mergedFloatingRef = chainRefFunctions([refs.setFloating, containerRef]);\n\n const dialogContent = (\n <DialogContent\n data-testid={overrideDataTestId}\n isReferenceHidden={hideWhenReferenceHidden && isReferenceHidden}\n onMouseEnter={onDialogEnter}\n onMouseLeave={onDialogLeave}\n onClickOutside={onClickOutside}\n onContextMenu={onContextMenu}\n onEsc={onEsc}\n animationType={animationTypeCalculated}\n position={placement}\n wrapperClassName={wrapperClassName}\n startingEdge={startingEdge}\n isOpen={isShown}\n showDelay={showDelay}\n styleObject={finalFloatingStyles}\n ref={mergedFloatingRef}\n onClick={onContentClick}\n hasTooltip={!!tooltip}\n containerSelector={containerSelector}\n disableContainerScroll={disableContainerScroll}\n >\n {contentRendered}\n {tooltip && (\n <div\n style={arrowStyles}\n ref={arrowRef}\n className={cx(styles.arrow, tooltipClassName)}\n data-placement={placement}\n />\n )}\n </DialogContent>\n );\n\n return (\n <>\n <Refable\n className={cx(referenceWrapperClassName)}\n wrapperElement={referenceWrapperElement}\n ref={setReferenceElement}\n onBlur={chainedOnBlur}\n onKeyDown={chainedOnKeyDown}\n onClick={chainedOnClick}\n onFocus={chainedOnFocus}\n onMouseDown={chainedOnMouseDown}\n onMouseEnter={chainedOnMouseEnter}\n onMouseLeave={chainedOnMouseLeave}\n onContextMenu={chainedOnContextMenu}\n >\n {children}\n </Refable>\n {isClient() &&\n isShown &&\n createPortal(<LayerProvider layerRef={containerRef}>{dialogContent}</LayerProvider>, getContainer())}\n </>\n );\n}\n\nexport default Dialog;\n"],"names":["Dialog","id","dataTestId","children","content","position","moveBy","main","secondary","middleware","middlewareProp","startingEdge","showDelay","hideDelay","instantShowAndHide","getDynamicShowDelay","showTrigger","hideTrigger","showOnDialogEnter","showTriggerIgnoreClass","hideTriggerIgnoreClass","addKeyboardHideShowTriggersByDefault","shouldShowOnMount","disable","open","isOpen","isOpenProp","useDerivedStateFromProps","animationType","preventAnimationOnMount","tooltip","tooltipClassName","containerSelector","disableContainerScroll","zIndex","wrapperClassName","referenceWrapperClassName","referenceWrapperElement","onBlur","onBlurProp","onKeyDown","onKeyDownProp","onClick","onClickProp","onFocus","onFocusProp","onMouseDown","onMouseDownProp","onMouseEnter","onMouseEnterProp","onMouseLeave","onMouseLeaveProp","onContextMenu","onContextMenuProp","onDialogDidShow","NOOP","onDialogDidHide","onClickOutside","onClickOutsideProp","onContentClick","onContentClickProp","hideWhenReferenceHidden","shouldCallbackOnMount","observeContentResize","isOpenState","setIsOpenState","useState","preventAnimation","setPreventAnimation","referenceElement","setReferenceElement","showTimeoutRef","useRef","hideTimeoutRef","containerRef","arrowRef","hasValidChildren","React","Children","toArray","some","child","isValidElement","layerRef","useContext","LayerContext","isShown","floatingMiddleware","useMemo","middlewareList","validMiddleware","filter","m","fn","hasCustomOffset","name","hasCustomFlip","hasCustomShift","push","offset","mainAxis","crossAxis","flip","shift","arrowMiddleware","element","hide","whileElementsMounted","useCallback","reference","floating","update","autoUpdate","elementResize","layoutShift","refs","floatingStyles","placement","middlewareData","useFloating","elements","isReferenceHidden","_b","_a","referenceHidden","isShowTrigger","eventName","showTriggersArray","convertToArray","includes","isHideTrigger","hideTriggersArray","showDialog","event","options","finalShowDelay","preventAnimationValue","dynamicDelayObj","current","setTimeout","hideDialog","showDialogIfNeeded","clearTimeout","hideDialogIfNeeded","handleEvent","target","isInsideClass","getContainer","containerElement","document","querySelector","Element","body","e","button","key","relatedTarget","onEsc","preventDefault","onDialogEnter","onDialogLeave","chainedOnBlur","chainFunctions","chainedOnKeyDown","chainedOnClick","chainedOnFocus","chainedOnMouseDown","chainedOnMouseEnter","chainedOnMouseLeave","chainedOnContextMenu","closeDialogOnEscapeRef","useEffect","isClient","handler","call","addEventListener","removeEventListener","CustomEvent","overrideDataTestId","getTestId","ComponentDefaultTestId","DIALOG","arrowStyles","arrow","x","y","left","top","transform","finalFloatingStyles","Object","assign","undefined","animationTypeCalculated","contentRendered","isFunction","createElement","Fragment","mergedFloatingRef","chainRefFunctions","setFloating","dialogContent","DialogContent","styleObject","ref","hasTooltip","style","className","cx","styles","Refable","wrapperElement","createPortal","LayerProvider"],"mappings":"4tBA+BA,SAASA,GAAOC,GAEdA,EACA,cAAeC,EAAUC,SACzBA,EAAQC,QACRA,EAAOC,SACPA,EAAW,MAAKC,OAChBA,EAAS,CAAEC,KAAM,EAAGC,UAAW,GAC/BC,WAAYC,EAAiB,GAAEC,aAC/BA,EAAYC,UACZA,EAAY,IAAGC,UACfA,EAAY,IAAGC,mBACfA,GAAqB,EAAKC,oBAC1BA,EAAmBC,YACnBA,EAAc,aAAYC,YAC1BA,EAAc,aAAYC,kBAC1BA,GAAoB,EAAKC,uBACzBA,EAAsBC,uBACtBA,EAAsBC,qCACtBA,GAAuC,EAAIC,kBAC3CA,GAAoB,EAAKC,QACzBA,GAAU,EAAKC,KACfA,GAAO,EACPC,OAAQC,EAAUC,yBAClBA,GAA2B,EAAKC,cAChCA,EAAgB,SAAQC,wBACxBA,IAA0B,EAAKC,QAC/BA,IAAU,EAAKC,iBACfA,GAAgBC,kBAChBA,GAAiBC,uBACjBA,GAAsBC,OACtBA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AOxB,GACPsB,IAAKjI,GACLoI,UAAWC,EAAGC,EAAO1B,MAAOxJ,IACZ,iBAAAsF,MAMxB,OACExC,EAAAuH,cAAAvH,EAAAwH,SAAA,KACExH,EAACuH,cAAAc,GACCH,UAAWC,EAAG5K,IACd+K,eAAgB9K,GAChBuK,IAAKtI,GACLhC,OAAQ2H,GACRzH,UAAW2H,GACXzH,QAAS0H,GACTxH,QAASyH,GACTvH,YAAawH,GACbtH,aAAcuH,GACdrH,aAAcsH,GACdpH,cAAeqH,IAEdtK,GAEFyK,KACCtF,IACA8H,EAAavI,EAACuH,cAAAiB,EAAc,CAAAlI,SAAUT,IAAe+H,IAAgCtD,MAG7F"}
|
|
1
|
+
{"version":3,"file":"Dialog.js","sources":["../../src/Dialog/Dialog.tsx"],"sourcesContent":["import cx from \"classnames\";\nimport React, { useState, useEffect, useRef, useContext, useCallback, useMemo } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport {\n useFloating,\n offset,\n flip,\n shift,\n hide,\n arrow as arrowMiddleware,\n autoUpdate,\n type Placement,\n type Middleware\n} from \"@floating-ui/react-dom\";\nimport { isFunction } from \"es-toolkit\";\nimport {\n chainFunctions,\n chainRefFunctions,\n convertToArray,\n NOOP,\n isInsideClass,\n ComponentDefaultTestId,\n getTestId,\n isClient\n} from \"@vibe/shared\";\nimport DialogContent from \"./components/DialogContent/DialogContent\";\nimport { Refable } from \"./components/Refable/Refable\";\nimport styles from \"./Dialog.module.scss\";\nimport { type DialogTriggerEvent, type DialogEvent, type DialogProps } from \"./Dialog.types\";\nimport { LayerContext, LayerProvider } from \"@vibe/layer\";\n\nfunction Dialog({\n // Core props\n id,\n \"data-testid\": dataTestId,\n children,\n content,\n position = \"top\",\n moveBy = { main: 0, secondary: 0 },\n middleware: middlewareProp = [],\n startingEdge,\n showDelay = 100,\n hideDelay = 100,\n instantShowAndHide = false,\n getDynamicShowDelay,\n showTrigger = \"mouseenter\",\n hideTrigger = \"mouseleave\",\n showOnDialogEnter = false,\n showTriggerIgnoreClass,\n hideTriggerIgnoreClass,\n addKeyboardHideShowTriggersByDefault = true,\n shouldShowOnMount = false,\n disable = false,\n open = false,\n isOpen: isOpenProp,\n useDerivedStateFromProps = false,\n animationType = \"expand\",\n preventAnimationOnMount = false,\n tooltip = false,\n tooltipClassName,\n containerSelector,\n disableContainerScroll,\n zIndex,\n wrapperClassName,\n referenceWrapperClassName,\n referenceWrapperElement,\n onBlur: onBlurProp,\n onKeyDown: onKeyDownProp,\n onClick: onClickProp,\n onFocus: onFocusProp,\n onMouseDown: onMouseDownProp,\n onMouseEnter: onMouseEnterProp,\n onMouseLeave: onMouseLeaveProp,\n onContextMenu: onContextMenuProp,\n onDialogDidShow = NOOP,\n onDialogDidHide = NOOP,\n onClickOutside: onClickOutsideProp = NOOP,\n onContentClick: onContentClickProp = NOOP,\n hideWhenReferenceHidden = false,\n shouldCallbackOnMount = false,\n observeContentResize = false\n}: DialogProps) {\n const [isOpenState, setIsOpenState] = useState(shouldShowOnMount);\n const [preventAnimation, setPreventAnimation] = useState(false);\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null);\n\n const showTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const hideTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const arrowRef = useRef<HTMLDivElement>(null);\n\n // Check if children are valid React elements (Refable returns null for non-elements)\n const hasValidChildren = React.Children.toArray(children).some(child => React.isValidElement(child));\n\n const { layerRef } = useContext(LayerContext);\n\n // Derived state\n const isOpenInternal = useDerivedStateFromProps ? isOpenProp : isOpenState;\n const isShown = isOpenInternal || open;\n\n // Build middleware array for Floating UI\n const floatingMiddleware = useMemo<Middleware[]>(() => {\n const middlewareList: Middleware[] = [];\n\n // Get user-provided middleware (filter out invalid ones)\n const validMiddleware = middlewareProp.filter(\n (m): m is Middleware => m != null && typeof m === \"object\" && typeof m.fn === \"function\"\n );\n\n // Check if user provided their own middleware to override defaults\n const hasCustomOffset = validMiddleware.some(m => m.name === \"offset\");\n const hasCustomFlip = validMiddleware.some(m => m.name === \"flip\");\n const hasCustomShift = validMiddleware.some(m => m.name === \"shift\");\n\n // Offset middleware - skip if user provided their own\n if (!hasCustomOffset && (moveBy.main !== 0 || moveBy.secondary !== 0)) {\n middlewareList.push(offset({ mainAxis: moveBy.main || 0, crossAxis: moveBy.secondary || 0 }));\n }\n\n // Core positioning middleware - skip if user provided their own\n if (!hasCustomFlip) {\n middlewareList.push(flip());\n }\n if (!hasCustomShift) {\n middlewareList.push(shift());\n }\n\n // Add user-provided middleware\n middlewareList.push(...validMiddleware);\n\n // Arrow middleware - pass ref directly, Floating UI handles null refs\n if (tooltip) {\n middlewareList.push(arrowMiddleware({ element: arrowRef }));\n }\n\n // Hide middleware for detecting when reference is hidden\n if (hideWhenReferenceHidden) {\n middlewareList.push(hide());\n }\n\n return middlewareList;\n }, [moveBy.main, moveBy.secondary, tooltip, hideWhenReferenceHidden, middlewareProp]);\n\n // Configure autoUpdate for position tracking\n const whileElementsMounted = useCallback(\n (reference: HTMLElement, floating: HTMLElement, update: () => void) => {\n return autoUpdate(reference, floating, update, {\n elementResize: observeContentResize,\n layoutShift: false\n });\n },\n [observeContentResize]\n );\n\n // Use Floating UI hook\n const { refs, floatingStyles, placement, middlewareData } = useFloating({\n placement: position as Placement,\n middleware: floatingMiddleware,\n whileElementsMounted,\n elements: {\n reference: referenceElement\n }\n });\n\n // Check if reference is hidden (from hide middleware)\n const isReferenceHidden = middlewareData.hide?.referenceHidden ?? false;\n\n const isShowTrigger = useCallback(\n (eventName: DialogTriggerEvent) => {\n const showTriggersArray = convertToArray(showTrigger);\n if (addKeyboardHideShowTriggersByDefault && eventName === \"focus\" && showTriggersArray.includes(\"mouseenter\")) {\n return true;\n }\n return showTriggersArray.includes(eventName);\n },\n [showTrigger, addKeyboardHideShowTriggersByDefault]\n );\n\n const isHideTrigger = useCallback(\n (eventName: DialogTriggerEvent) => {\n const hideTriggersArray = convertToArray(hideTrigger);\n if (addKeyboardHideShowTriggersByDefault && eventName === \"blur\" && hideTriggersArray.includes(\"mouseleave\")) {\n return true;\n }\n return hideTriggersArray.includes(eventName);\n },\n [hideTrigger, addKeyboardHideShowTriggersByDefault]\n );\n\n const showDialog = useCallback(\n (event: DialogEvent, eventName: DialogTriggerEvent | string, options: { preventAnimation?: boolean } = {}) => {\n let finalShowDelay = showDelay;\n let preventAnimationValue = options.preventAnimation;\n if (getDynamicShowDelay) {\n const dynamicDelayObj = getDynamicShowDelay();\n finalShowDelay = dynamicDelayObj.showDelay || 0;\n preventAnimationValue = preventAnimationValue ?? dynamicDelayObj.preventAnimation;\n }\n\n if (instantShowAndHide) {\n onDialogDidShow(event, eventName);\n setIsOpenState(true);\n setPreventAnimation(!!preventAnimationValue);\n showTimeoutRef.current = null;\n } else {\n showTimeoutRef.current = setTimeout(() => {\n onDialogDidShow(event, eventName);\n showTimeoutRef.current = null;\n setIsOpenState(true);\n setPreventAnimation(!!preventAnimationValue);\n }, finalShowDelay);\n }\n },\n [showDelay, getDynamicShowDelay, instantShowAndHide, onDialogDidShow]\n );\n\n const hideDialog = useCallback(\n (event: DialogEvent, eventName: DialogTriggerEvent | string) => {\n if (instantShowAndHide) {\n onDialogDidHide(event, eventName);\n setIsOpenState(false);\n hideTimeoutRef.current = null;\n } else {\n hideTimeoutRef.current = setTimeout(() => {\n onDialogDidHide(event, eventName);\n setIsOpenState(false);\n hideTimeoutRef.current = null;\n }, hideDelay);\n }\n },\n [hideDelay, instantShowAndHide, onDialogDidHide]\n );\n\n const showDialogIfNeeded = useCallback(\n (event: DialogEvent, eventName: DialogTriggerEvent | string, options = {}) => {\n if (disable) {\n return;\n }\n\n if (hideTimeoutRef.current) {\n clearTimeout(hideTimeoutRef.current);\n hideTimeoutRef.current = null;\n }\n\n if (!showTimeoutRef.current) {\n showDialog(event, eventName, options);\n }\n },\n [disable, showDialog]\n );\n\n const hideDialogIfNeeded = useCallback(\n (event: DialogEvent, eventName: DialogTriggerEvent | string) => {\n if (showTimeoutRef.current) {\n clearTimeout(showTimeoutRef.current);\n showTimeoutRef.current = null;\n }\n\n if (!hideTimeoutRef.current) {\n hideDialog(event, eventName);\n }\n },\n [hideDialog]\n );\n\n // Event handling\n const handleEvent = useCallback(\n (eventName: DialogTriggerEvent, target: EventTarget | null, event: DialogEvent) => {\n if (!target) return; // Guard against null targets (e.g., when focus leaves the document)\n if (isShowTrigger(eventName) && !isShown && !isInsideClass(target as HTMLElement, showTriggerIgnoreClass)) {\n return showDialogIfNeeded(event, eventName);\n }\n\n if (isHideTrigger(eventName) && !isInsideClass(target as HTMLElement, hideTriggerIgnoreClass)) {\n return hideDialogIfNeeded(event, eventName);\n }\n },\n [\n isShowTrigger,\n isHideTrigger,\n isShown,\n showTriggerIgnoreClass,\n hideTriggerIgnoreClass,\n showDialogIfNeeded,\n hideDialogIfNeeded\n ]\n );\n\n const getContainer = useCallback(() => {\n if (containerSelector) {\n const containerElement = document.querySelector(containerSelector);\n if (containerElement instanceof Element) {\n return containerElement;\n }\n }\n return layerRef?.current || document.body;\n }, [containerSelector, layerRef]);\n\n // Memoized event handlers to prevent unnecessary re-renders\n const onMouseEnter = useCallback((e: React.MouseEvent) => handleEvent(\"mouseenter\", e.target, e), [handleEvent]);\n const onMouseLeave = useCallback((e: React.MouseEvent) => handleEvent(\"mouseleave\", e.target, e), [handleEvent]);\n const onClick = useCallback(\n (e: React.MouseEvent) => {\n if (e.button) return;\n handleEvent(\"click\", e.target, e);\n },\n [handleEvent]\n );\n const onKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n // Handle element-level keyboard events for triggers\n if (event.key === \"Enter\") handleEvent(\"enter\", event.target, event);\n if (event.key === \"Tab\") handleEvent(\"tab\", event.target, event);\n },\n [handleEvent]\n );\n\n const onMouseDown = useCallback(\n (e: React.MouseEvent) => {\n if (e.button) return;\n handleEvent(\"mousedown\", e.target, e);\n },\n [handleEvent]\n );\n const onFocus = useCallback((e: React.FocusEvent) => handleEvent(\"focus\", e.target, e), [handleEvent]);\n const onBlur = useCallback(\n (e: React.FocusEvent) => {\n const target = e.relatedTarget || e.target;\n handleEvent(\"blur\", target, e);\n },\n [handleEvent]\n );\n const onEsc = useCallback((e: React.KeyboardEvent) => handleEvent(\"esckey\", e.target, e), [handleEvent]);\n const onContextMenu = useCallback(\n (e: React.MouseEvent) => {\n if ((isShowTrigger(\"contextmenu\") && !isShown) || (isHideTrigger(\"contextmenu\") && isShown)) {\n e.preventDefault();\n }\n handleEvent(\"contextmenu\", e.target, e);\n },\n [isShown, isShowTrigger, isHideTrigger, handleEvent]\n );\n\n const onClickOutside = useCallback(\n (event: React.MouseEvent) => {\n handleEvent(\"clickoutside\", event.target, event);\n onClickOutsideProp(event);\n },\n [handleEvent, onClickOutsideProp]\n );\n\n const onDialogEnter = useCallback(\n (event: React.MouseEvent) => {\n if (showOnDialogEnter) showDialogIfNeeded(event, \"DialogEnter\");\n },\n [showOnDialogEnter, showDialogIfNeeded]\n );\n\n const onDialogLeave = useCallback(\n (event: React.MouseEvent) => {\n if (showOnDialogEnter) hideDialogIfNeeded(event, \"DialogLeave\");\n },\n [showOnDialogEnter, hideDialogIfNeeded]\n );\n\n const onContentClick = useCallback(\n (e: React.MouseEvent) => {\n handleEvent(\"onContentClick\", e.target, e);\n onContentClickProp(e);\n },\n [handleEvent, onContentClickProp]\n );\n\n // Memoized chained event handlers to prevent Refable children re-renders\n const chainedOnBlur = useMemo(() => chainFunctions([onBlurProp, onBlur], true), [onBlurProp, onBlur]);\n const chainedOnKeyDown = useMemo(() => chainFunctions([onKeyDownProp, onKeyDown], true), [onKeyDownProp, onKeyDown]);\n const chainedOnClick = useMemo(() => chainFunctions([onClickProp, onClick], true), [onClickProp, onClick]);\n const chainedOnFocus = useMemo(() => chainFunctions([onFocusProp, onFocus], true), [onFocusProp, onFocus]);\n const chainedOnMouseDown = useMemo(\n () => chainFunctions([onMouseDownProp, onMouseDown], true),\n [onMouseDownProp, onMouseDown]\n );\n const chainedOnMouseEnter = useMemo(\n () => chainFunctions([onMouseEnterProp, onMouseEnter], true),\n [onMouseEnterProp, onMouseEnter]\n );\n const chainedOnMouseLeave = useMemo(\n () => chainFunctions([onMouseLeaveProp, onMouseLeave], true),\n [onMouseLeaveProp, onMouseLeave]\n );\n const chainedOnContextMenu = useMemo(\n () => chainFunctions([onContextMenuProp, onContextMenu], true),\n [onContextMenuProp, onContextMenu]\n );\n\n // Document-level keyboard handler using stable ref pattern\n // Must handle Escape, Tab, and Enter at document level to match old behavior\n const closeDialogOnEscapeRef = useRef<(event: KeyboardEvent) => void>();\n closeDialogOnEscapeRef.current = (event: KeyboardEvent) => {\n if (!isShown) return;\n\n switch (event.key) {\n case \"Escape\":\n hideDialogIfNeeded(event, \"esckey\");\n break;\n case \"Tab\":\n handleEvent(\"tab\", event.target, event);\n break;\n case \"Enter\":\n handleEvent(\"enter\", event.target, event);\n break;\n }\n };\n\n // Effects\n\n // Callback on mount\n useEffect(() => {\n if (shouldCallbackOnMount && shouldShowOnMount) {\n onDialogDidShow();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Cleanup timeouts on unmount\n useEffect(() => {\n return () => {\n if (showTimeoutRef.current) clearTimeout(showTimeoutRef.current);\n if (hideTimeoutRef.current) clearTimeout(hideTimeoutRef.current);\n };\n }, []);\n\n // Document keyboard listener (stable reference via ref)\n useEffect(() => {\n if (!isClient()) return;\n\n const handler = (event: KeyboardEvent) => closeDialogOnEscapeRef.current?.(event);\n document.addEventListener(\"keyup\", handler);\n return () => document.removeEventListener(\"keyup\", handler);\n }, []);\n\n // Handle reference hidden state\n useEffect(() => {\n if (hideWhenReferenceHidden && isReferenceHidden && isShown) {\n const event = new CustomEvent(\"onReferenceHidden\");\n hideDialog(event, \"onReferenceHidden\");\n }\n }, [hideWhenReferenceHidden, isReferenceHidden, isShown, hideDialog]);\n\n // Computed values\n const overrideDataTestId = dataTestId || getTestId(ComponentDefaultTestId.DIALOG, id);\n\n const arrowStyles = useMemo<React.CSSProperties>(() => {\n if (!middlewareData.arrow) return {};\n const { x, y } = middlewareData.arrow;\n return {\n left: x != null ? `${x}px` : \"\",\n top: y != null ? `${y}px` : \"\",\n transform: \"rotate(45deg)\"\n };\n }, [middlewareData.arrow]);\n\n // Skip Floating UI positioning when no children (e.g. floating Tipseen) — let CSS handle it\n const finalFloatingStyles = useMemo<React.CSSProperties>(\n () =>\n hasValidChildren\n ? { ...floatingStyles, ...(zIndex !== undefined && { zIndex }) }\n : { ...(zIndex !== undefined && { zIndex }) },\n [floatingStyles, zIndex, hasValidChildren]\n );\n\n const animationTypeCalculated = preventAnimationOnMount || preventAnimation ? undefined : animationType;\n const contentRendered = isFunction(content) ? content() : content;\n\n // Early return if no content - wrap in fragment for type safety\n if (!contentRendered) {\n return <>{children}</>;\n }\n\n const mergedFloatingRef = chainRefFunctions([refs.setFloating, containerRef]);\n\n const dialogContent = (\n <DialogContent\n data-testid={overrideDataTestId}\n isReferenceHidden={hideWhenReferenceHidden && isReferenceHidden}\n onMouseEnter={onDialogEnter}\n onMouseLeave={onDialogLeave}\n onClickOutside={onClickOutside}\n onContextMenu={onContextMenu}\n onEsc={onEsc}\n animationType={animationTypeCalculated}\n position={placement}\n wrapperClassName={wrapperClassName}\n startingEdge={startingEdge}\n isOpen={isShown}\n showDelay={showDelay}\n styleObject={finalFloatingStyles}\n ref={mergedFloatingRef}\n onClick={onContentClick}\n hasTooltip={!!tooltip}\n containerSelector={containerSelector}\n disableContainerScroll={disableContainerScroll}\n >\n {contentRendered}\n {tooltip && (\n <div\n style={arrowStyles}\n ref={arrowRef}\n className={cx(styles.arrow, tooltipClassName)}\n data-placement={placement}\n />\n )}\n </DialogContent>\n );\n\n return (\n <>\n <Refable\n className={cx(referenceWrapperClassName)}\n wrapperElement={referenceWrapperElement}\n ref={setReferenceElement}\n onBlur={chainedOnBlur}\n onKeyDown={chainedOnKeyDown}\n onClick={chainedOnClick}\n onFocus={chainedOnFocus}\n onMouseDown={chainedOnMouseDown}\n onMouseEnter={chainedOnMouseEnter}\n onMouseLeave={chainedOnMouseLeave}\n onContextMenu={chainedOnContextMenu}\n >\n {children}\n </Refable>\n {isClient() &&\n isShown &&\n createPortal(<LayerProvider layerRef={containerRef}>{dialogContent}</LayerProvider>, getContainer())}\n </>\n );\n}\n\nexport default Dialog;\n"],"names":["Dialog","id","dataTestId","children","content","position","moveBy","main","secondary","middleware","middlewareProp","startingEdge","showDelay","hideDelay","instantShowAndHide","getDynamicShowDelay","showTrigger","hideTrigger","showOnDialogEnter","showTriggerIgnoreClass","hideTriggerIgnoreClass","addKeyboardHideShowTriggersByDefault","shouldShowOnMount","disable","open","isOpen","isOpenProp","useDerivedStateFromProps","animationType","preventAnimationOnMount","tooltip","tooltipClassName","containerSelector","disableContainerScroll","zIndex","wrapperClassName","referenceWrapperClassName","referenceWrapperElement","onBlur","onBlurProp","onKeyDown","onKeyDownProp","onClick","onClickProp","onFocus","onFocusProp","onMouseDown","onMouseDownProp","onMouseEnter","onMouseEnterProp","onMouseLeave","onMouseLeaveProp","onContextMenu","onContextMenuProp","onDialogDidShow","NOOP","onDialogDidHide","onClickOutside","onClickOutsideProp","onContentClick","onContentClickProp","hideWhenReferenceHidden","shouldCallbackOnMount","observeContentResize","isOpenState","setIsOpenState","useState","preventAnimation","setPreventAnimation","referenceElement","setReferenceElement","showTimeoutRef","useRef","hideTimeoutRef","containerRef","arrowRef","hasValidChildren","React","Children","toArray","some","child","isValidElement","layerRef","useContext","LayerContext","isShown","floatingMiddleware","useMemo","middlewareList","validMiddleware","filter","m","fn","hasCustomOffset","name","hasCustomFlip","hasCustomShift","push","offset","mainAxis","crossAxis","flip","shift","arrowMiddleware","element","hide","whileElementsMounted","useCallback","reference","floating","update","autoUpdate","elementResize","layoutShift","refs","floatingStyles","placement","middlewareData","useFloating","elements","isReferenceHidden","_b","_a","referenceHidden","isShowTrigger","eventName","showTriggersArray","convertToArray","includes","isHideTrigger","hideTriggersArray","showDialog","event","options","finalShowDelay","preventAnimationValue","dynamicDelayObj","current","setTimeout","hideDialog","showDialogIfNeeded","clearTimeout","hideDialogIfNeeded","handleEvent","target","isInsideClass","getContainer","containerElement","document","querySelector","Element","body","e","button","key","relatedTarget","onEsc","preventDefault","onDialogEnter","onDialogLeave","chainedOnBlur","chainFunctions","chainedOnKeyDown","chainedOnClick","chainedOnFocus","chainedOnMouseDown","chainedOnMouseEnter","chainedOnMouseLeave","chainedOnContextMenu","closeDialogOnEscapeRef","useEffect","isClient","handler","call","addEventListener","removeEventListener","CustomEvent","overrideDataTestId","getTestId","ComponentDefaultTestId","DIALOG","arrowStyles","arrow","x","y","left","top","transform","finalFloatingStyles","Object","assign","undefined","animationTypeCalculated","contentRendered","isFunction","createElement","Fragment","mergedFloatingRef","chainRefFunctions","setFloating","dialogContent","DialogContent","styleObject","ref","hasTooltip","style","className","cx","styles","Refable","wrapperElement","createPortal","LayerProvider"],"mappings":"4tBA+BA,SAASA,GAAOC,GAEdA,EACA,cAAeC,EAAUC,SACzBA,EAAQC,QACRA,EAAOC,SACPA,EAAW,MAAKC,OAChBA,EAAS,CAAEC,KAAM,EAAGC,UAAW,GAC/BC,WAAYC,EAAiB,GAAEC,aAC/BA,EAAYC,UACZA,EAAY,IAAGC,UACfA,EAAY,IAAGC,mBACfA,GAAqB,EAAKC,oBAC1BA,EAAmBC,YACnBA,EAAc,aAAYC,YAC1BA,EAAc,aAAYC,kBAC1BA,GAAoB,EAAKC,uBACzBA,EAAsBC,uBACtBA,EAAsBC,qCACtBA,GAAuC,EAAIC,kBAC3CA,GAAoB,EAAKC,QACzBA,GAAU,EAAKC,KACfA,GAAO,EACPC,OAAQC,EAAUC,yBAClBA,GAA2B,EAAKC,cAChCA,EAAgB,SAAQC,wBACxBA,IAA0B,EAAKC,QAC/BA,IAAU,EAAKC,iBACfA,GAAgBC,kBAChBA,GAAiBC,uBACjBA,GAAsBC,OACtBA,GAAMC,iBACNA,GAAgBC,0BAChBA,GAAyBC,wBACzBA,GAC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AOxJ,IACZ,iBAAAsF,MAMxB,OACExC,EAAAuH,cAAAvH,EAAAwH,SAAA,KACExH,EAACuH,cAAAc,GACCH,UAAWC,EAAG5K,IACd+K,eAAgB9K,GAChBuK,IAAKtI,GACLhC,OAAQ2H,GACRzH,UAAW2H,GACXzH,QAAS0H,GACTxH,QAASyH,GACTvH,YAAawH,GACbtH,aAAcuH,GACdrH,aAAcsH,GACdpH,cAAeqH,IAEdtK,GAEFyK,KACCtF,IACA8H,EAAavI,EAACuH,cAAAiB,EAAc,CAAAlI,SAAUT,IAAe+H,IAAgCtD,MAG7F"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var a={arrow:"arrow_0f548a71ff"};!function(a){const e="s_id-3fb64cda561a_4_0_0-alpha_1";if("undefined"!=typeof document){const t=document.head||document.getElementsByTagName("head")[0];if(t.querySelector("#"+e))return;const r=document.createElement("style");r.id=e,t.firstChild?t.insertBefore(r,t.firstChild):t.appendChild(r),r.appendChild(document.createTextNode(a))}else globalThis.injectedStyles&&(globalThis.injectedStyles[e]=a)}(".arrow_0f548a71ff {\n width: 12px;\n height: 12px;\n position: absolute;\n border-radius: 2px;\n background-color: var(--secondary-background-color);\n}\n.dark-app-theme .arrow_0f548a71ff[data-placement*=right], .black-app-theme .arrow_0f548a71ff[data-placement*=right], .hacker-app-theme .arrow_0f548a71ff[data-placement*=right] {\n box-shadow: -1px 1px 0px 0px var(--layout-border-color);\n}\n.dark-app-theme .arrow_0f548a71ff[data-placement*=left], .black-app-theme .arrow_0f548a71ff[data-placement*=left], .hacker-app-theme .arrow_0f548a71ff[data-placement*=left] {\n box-shadow: 1px -1px 0px 0px var(--layout-border-color);\n}\n.dark-app-theme .arrow_0f548a71ff[data-placement*=bottom], .black-app-theme .arrow_0f548a71ff[data-placement*=bottom], .hacker-app-theme .arrow_0f548a71ff[data-placement*=bottom] {\n box-shadow: -1px -1px 0px 0px var(--layout-border-color);\n}\n.dark-app-theme .arrow_0f548a71ff[data-placement*=top], .black-app-theme .arrow_0f548a71ff[data-placement*=top], .hacker-app-theme .arrow_0f548a71ff[data-placement*=top] {\n box-shadow: 1px 1px 0px 0px var(--layout-border-color);\n}\n.arrow_0f548a71ff[data-placement*=bottom] {\n top: 1px;\n}\n.arrow_0f548a71ff[data-placement*=top] {\n bottom: 1px;\n}\n.arrow_0f548a71ff[data-placement*=left] {\n right: 1px;\n}\n.arrow_0f548a71ff[data-placement*=right] {\n left: 1px;\n}");export{a as default};
|
|
2
2
|
//# sourceMappingURL=Dialog.module.scss.js.map
|
|
@@ -1,214 +1,214 @@
|
|
|
1
|
-
import type React from "react";
|
|
2
|
-
import type { ReactElement } from "react";
|
|
3
|
-
import type { VibeComponentProps } from "@vibe/shared";
|
|
4
|
-
import type { Middleware, Placement } from "@floating-ui/react-dom";
|
|
5
|
-
export type DialogType = "modal" | "popover";
|
|
6
|
-
export type DialogSize = "none" | "small" | "medium" | "large";
|
|
7
|
-
export type DialogPosition = "left" | "left-start" | "left-end" | "right" | "right-start" | "right-end" | "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end";
|
|
8
|
-
export type DialogTriggerEvent = "click" | "clickoutside" | "esckey" | "tab" | "mouseenter" | "mouseleave" | "enter" | "mousedown" | "focus" | "blur" | "onContentClick" | "contextmenu";
|
|
9
|
-
export type DialogAnimationType = "opacity-and-slide" | "expand";
|
|
10
|
-
export type DialogStartingEdge = "top" | "bottom";
|
|
11
|
-
export type DialogOffset = {
|
|
12
|
-
main?: number;
|
|
13
|
-
secondary?: number;
|
|
14
|
-
};
|
|
15
|
-
export type DialogEvent = React.MouseEvent | React.KeyboardEvent | KeyboardEvent | React.FocusEvent | CustomEvent;
|
|
16
|
-
export type DialogMiddleware = Middleware;
|
|
17
|
-
export type DialogPlacement = Placement;
|
|
18
|
-
export interface DialogProps extends VibeComponentProps {
|
|
19
|
-
/**
|
|
20
|
-
* Event handler for blur events on the reference element.
|
|
21
|
-
*/
|
|
22
|
-
onBlur?: (e: React.FocusEvent) => void;
|
|
23
|
-
/**
|
|
24
|
-
* Event handler for keydown events on the reference element.
|
|
25
|
-
*/
|
|
26
|
-
onKeyDown?: (e: React.KeyboardEvent) => void;
|
|
27
|
-
/**
|
|
28
|
-
* Event handler for click events on the reference element.
|
|
29
|
-
*/
|
|
30
|
-
onClick?: (e: React.MouseEvent) => void;
|
|
31
|
-
/**
|
|
32
|
-
* Event handler for focus events on the reference element.
|
|
33
|
-
*/
|
|
34
|
-
onFocus?: (e: React.FocusEvent) => void;
|
|
35
|
-
/**
|
|
36
|
-
* Event handler for mousedown events on the reference element.
|
|
37
|
-
*/
|
|
38
|
-
onMouseDown?: (e: React.MouseEvent) => void;
|
|
39
|
-
/**
|
|
40
|
-
* Event handler for mouseenter events on the reference element.
|
|
41
|
-
*/
|
|
42
|
-
onMouseEnter?: (e: React.MouseEvent) => void;
|
|
43
|
-
/**
|
|
44
|
-
* Event handler for mouseleave events on the reference element.
|
|
45
|
-
*/
|
|
46
|
-
onMouseLeave?: (e: React.MouseEvent) => void;
|
|
47
|
-
/**
|
|
48
|
-
* Event handler for contextmenu events on the reference element.
|
|
49
|
-
*/
|
|
50
|
-
onContextMenu?: (e: React.MouseEvent) => void;
|
|
51
|
-
/**
|
|
52
|
-
* Class name applied to the reference wrapper element.
|
|
53
|
-
*/
|
|
54
|
-
referenceWrapperClassName?: string;
|
|
55
|
-
/**
|
|
56
|
-
* The wrapper element type to use for React components. Defaults to "span".
|
|
57
|
-
*/
|
|
58
|
-
referenceWrapperElement?: "span" | "div";
|
|
59
|
-
/**
|
|
60
|
-
* The placement of the dialog relative to the reference element.
|
|
61
|
-
*/
|
|
62
|
-
position?: DialogPosition;
|
|
63
|
-
/**
|
|
64
|
-
* Custom Floating UI middleware for positioning logic.
|
|
65
|
-
* If you provide `offset`, `flip`, or `shift` middleware, the defaults will be skipped.
|
|
66
|
-
* Other middleware (like `size`, `inline`, `autoPlacement`) are added to the chain.
|
|
67
|
-
* @see https://floating-ui.com/docs/middleware
|
|
68
|
-
*/
|
|
69
|
-
middleware?: DialogMiddleware[];
|
|
70
|
-
/**
|
|
71
|
-
* The starting edge of the dialog animation.
|
|
72
|
-
*/
|
|
73
|
-
startingEdge?: DialogStartingEdge;
|
|
74
|
-
/**
|
|
75
|
-
* Offset values for positioning adjustments.
|
|
76
|
-
* `main` - distance from reference element
|
|
77
|
-
* `secondary` - cross-axis offset (skidding)
|
|
78
|
-
*/
|
|
79
|
-
moveBy?: {
|
|
80
|
-
main?: number;
|
|
81
|
-
secondary?: number;
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* Delay in milliseconds before showing the dialog.
|
|
85
|
-
*/
|
|
86
|
-
showDelay?: number;
|
|
87
|
-
/**
|
|
88
|
-
* Delay in milliseconds before hiding the dialog.
|
|
89
|
-
*/
|
|
90
|
-
hideDelay?: number;
|
|
91
|
-
/**
|
|
92
|
-
* Events that trigger showing the dialog.
|
|
93
|
-
*/
|
|
94
|
-
showTrigger?: DialogTriggerEvent | DialogTriggerEvent[];
|
|
95
|
-
/**
|
|
96
|
-
* Events that trigger hiding the dialog.
|
|
97
|
-
*/
|
|
98
|
-
hideTrigger?: DialogTriggerEvent | DialogTriggerEvent[];
|
|
99
|
-
/**
|
|
100
|
-
* If true, keeps the dialog open when mouse enters it.
|
|
101
|
-
*/
|
|
102
|
-
showOnDialogEnter?: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* If true, shows the dialog when the component mounts.
|
|
105
|
-
*/
|
|
106
|
-
shouldShowOnMount?: boolean;
|
|
107
|
-
/**
|
|
108
|
-
* If true, disables opening the dialog.
|
|
109
|
-
*/
|
|
110
|
-
disable?: boolean;
|
|
111
|
-
/**
|
|
112
|
-
* Controls the open state of the dialog (controlled mode).
|
|
113
|
-
*/
|
|
114
|
-
open?: boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Controlled open state for derived state pattern.
|
|
117
|
-
*/
|
|
118
|
-
isOpen?: boolean;
|
|
119
|
-
/**
|
|
120
|
-
* CSS class names that, when present on target, prevent showing the dialog.
|
|
121
|
-
*/
|
|
122
|
-
showTriggerIgnoreClass?: string | string[];
|
|
123
|
-
/**
|
|
124
|
-
* CSS class names that, when present on target, prevent hiding the dialog.
|
|
125
|
-
*/
|
|
126
|
-
hideTriggerIgnoreClass?: string | string[];
|
|
127
|
-
/**
|
|
128
|
-
* The animation type used for the dialog.
|
|
129
|
-
*/
|
|
130
|
-
animationType?: DialogAnimationType;
|
|
131
|
-
/**
|
|
132
|
-
* Class name applied to the dialog content wrapper.
|
|
133
|
-
*/
|
|
134
|
-
wrapperClassName?: string;
|
|
135
|
-
/**
|
|
136
|
-
* If true, prevents animation when mounting.
|
|
137
|
-
*/
|
|
138
|
-
preventAnimationOnMount?: boolean;
|
|
139
|
-
/**
|
|
140
|
-
* CSS selector of the container where the dialog is portaled.
|
|
141
|
-
*/
|
|
142
|
-
containerSelector?: string;
|
|
143
|
-
/**
|
|
144
|
-
* If true, renders with tooltip arrow styling.
|
|
145
|
-
*/
|
|
146
|
-
tooltip?: boolean;
|
|
147
|
-
/**
|
|
148
|
-
* Class name applied to the tooltip arrow element.
|
|
149
|
-
*/
|
|
150
|
-
tooltipClassName?: string;
|
|
151
|
-
/**
|
|
152
|
-
* Callback fired when the dialog is shown.
|
|
153
|
-
*/
|
|
154
|
-
onDialogDidShow?: (event?: DialogEvent, eventName?: DialogTriggerEvent | string) => void;
|
|
155
|
-
/**
|
|
156
|
-
* Callback fired when the dialog is hidden.
|
|
157
|
-
*/
|
|
158
|
-
onDialogDidHide?: (event: DialogEvent, eventName: DialogTriggerEvent | string) => void;
|
|
159
|
-
/**
|
|
160
|
-
* Callback fired when clicking outside the dialog.
|
|
161
|
-
*/
|
|
162
|
-
onClickOutside?: (event: React.MouseEvent) => void;
|
|
163
|
-
/**
|
|
164
|
-
* Callback fired when clicking inside the dialog content.
|
|
165
|
-
*/
|
|
166
|
-
onContentClick?: (event: React.MouseEvent) => void;
|
|
167
|
-
/**
|
|
168
|
-
* The z-index applied to the dialog.
|
|
169
|
-
*/
|
|
170
|
-
zIndex?: number;
|
|
171
|
-
/**
|
|
172
|
-
* If true, uses derived state from props pattern.
|
|
173
|
-
*/
|
|
174
|
-
useDerivedStateFromProps?: boolean;
|
|
175
|
-
/**
|
|
176
|
-
* If true, hides the dialog when the reference element scrolls out of view.
|
|
177
|
-
*/
|
|
178
|
-
hideWhenReferenceHidden?: boolean;
|
|
179
|
-
/**
|
|
180
|
-
* If true, fires onDialogDidShow callback on mount.
|
|
181
|
-
*/
|
|
182
|
-
shouldCallbackOnMount?: boolean;
|
|
183
|
-
/**
|
|
184
|
-
* If true, shows and hides the dialog without delay.
|
|
185
|
-
*/
|
|
186
|
-
instantShowAndHide?: boolean;
|
|
187
|
-
/**
|
|
188
|
-
* Callback to dynamically adjust show delay and animation behavior.
|
|
189
|
-
*/
|
|
190
|
-
getDynamicShowDelay?: () => {
|
|
191
|
-
showDelay: number;
|
|
192
|
-
preventAnimation: boolean;
|
|
193
|
-
};
|
|
194
|
-
/**
|
|
195
|
-
* The content displayed inside the dialog. Can be a render function.
|
|
196
|
-
*/
|
|
197
|
-
content?: (() => JSX.Element) | JSX.Element;
|
|
198
|
-
/**
|
|
199
|
-
* The reference element(s) that the dialog is positioned relative to.
|
|
200
|
-
*/
|
|
201
|
-
children?: ReactElement | ReactElement[] | string;
|
|
202
|
-
/**
|
|
203
|
-
* If true, keyboard focus/blur events behave like mouse enter/leave.
|
|
204
|
-
*/
|
|
205
|
-
addKeyboardHideShowTriggersByDefault?: boolean;
|
|
206
|
-
/**
|
|
207
|
-
* If true or a selector string, disables scrolling in the container when open.
|
|
208
|
-
*/
|
|
209
|
-
disableContainerScroll?: boolean | string;
|
|
210
|
-
/**
|
|
211
|
-
* If true, automatically updates position when content resizes.
|
|
212
|
-
*/
|
|
213
|
-
observeContentResize?: boolean;
|
|
214
|
-
}
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import type { ReactElement } from "react";
|
|
3
|
+
import type { VibeComponentProps } from "@vibe/shared";
|
|
4
|
+
import type { Middleware, Placement } from "@floating-ui/react-dom";
|
|
5
|
+
export type DialogType = "modal" | "popover";
|
|
6
|
+
export type DialogSize = "none" | "small" | "medium" | "large";
|
|
7
|
+
export type DialogPosition = "left" | "left-start" | "left-end" | "right" | "right-start" | "right-end" | "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end";
|
|
8
|
+
export type DialogTriggerEvent = "click" | "clickoutside" | "esckey" | "tab" | "mouseenter" | "mouseleave" | "enter" | "mousedown" | "focus" | "blur" | "onContentClick" | "contextmenu";
|
|
9
|
+
export type DialogAnimationType = "opacity-and-slide" | "expand";
|
|
10
|
+
export type DialogStartingEdge = "top" | "bottom";
|
|
11
|
+
export type DialogOffset = {
|
|
12
|
+
main?: number;
|
|
13
|
+
secondary?: number;
|
|
14
|
+
};
|
|
15
|
+
export type DialogEvent = React.MouseEvent | React.KeyboardEvent | KeyboardEvent | React.FocusEvent | CustomEvent;
|
|
16
|
+
export type DialogMiddleware = Middleware;
|
|
17
|
+
export type DialogPlacement = Placement;
|
|
18
|
+
export interface DialogProps extends VibeComponentProps {
|
|
19
|
+
/**
|
|
20
|
+
* Event handler for blur events on the reference element.
|
|
21
|
+
*/
|
|
22
|
+
onBlur?: (e: React.FocusEvent) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Event handler for keydown events on the reference element.
|
|
25
|
+
*/
|
|
26
|
+
onKeyDown?: (e: React.KeyboardEvent) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Event handler for click events on the reference element.
|
|
29
|
+
*/
|
|
30
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Event handler for focus events on the reference element.
|
|
33
|
+
*/
|
|
34
|
+
onFocus?: (e: React.FocusEvent) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Event handler for mousedown events on the reference element.
|
|
37
|
+
*/
|
|
38
|
+
onMouseDown?: (e: React.MouseEvent) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Event handler for mouseenter events on the reference element.
|
|
41
|
+
*/
|
|
42
|
+
onMouseEnter?: (e: React.MouseEvent) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Event handler for mouseleave events on the reference element.
|
|
45
|
+
*/
|
|
46
|
+
onMouseLeave?: (e: React.MouseEvent) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Event handler for contextmenu events on the reference element.
|
|
49
|
+
*/
|
|
50
|
+
onContextMenu?: (e: React.MouseEvent) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Class name applied to the reference wrapper element.
|
|
53
|
+
*/
|
|
54
|
+
referenceWrapperClassName?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The wrapper element type to use for React components. Defaults to "span".
|
|
57
|
+
*/
|
|
58
|
+
referenceWrapperElement?: "span" | "div";
|
|
59
|
+
/**
|
|
60
|
+
* The placement of the dialog relative to the reference element.
|
|
61
|
+
*/
|
|
62
|
+
position?: DialogPosition;
|
|
63
|
+
/**
|
|
64
|
+
* Custom Floating UI middleware for positioning logic.
|
|
65
|
+
* If you provide `offset`, `flip`, or `shift` middleware, the defaults will be skipped.
|
|
66
|
+
* Other middleware (like `size`, `inline`, `autoPlacement`) are added to the chain.
|
|
67
|
+
* @see https://floating-ui.com/docs/middleware
|
|
68
|
+
*/
|
|
69
|
+
middleware?: DialogMiddleware[];
|
|
70
|
+
/**
|
|
71
|
+
* The starting edge of the dialog animation.
|
|
72
|
+
*/
|
|
73
|
+
startingEdge?: DialogStartingEdge;
|
|
74
|
+
/**
|
|
75
|
+
* Offset values for positioning adjustments.
|
|
76
|
+
* `main` - distance from reference element
|
|
77
|
+
* `secondary` - cross-axis offset (skidding)
|
|
78
|
+
*/
|
|
79
|
+
moveBy?: {
|
|
80
|
+
main?: number;
|
|
81
|
+
secondary?: number;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Delay in milliseconds before showing the dialog.
|
|
85
|
+
*/
|
|
86
|
+
showDelay?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Delay in milliseconds before hiding the dialog.
|
|
89
|
+
*/
|
|
90
|
+
hideDelay?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Events that trigger showing the dialog.
|
|
93
|
+
*/
|
|
94
|
+
showTrigger?: DialogTriggerEvent | DialogTriggerEvent[];
|
|
95
|
+
/**
|
|
96
|
+
* Events that trigger hiding the dialog.
|
|
97
|
+
*/
|
|
98
|
+
hideTrigger?: DialogTriggerEvent | DialogTriggerEvent[];
|
|
99
|
+
/**
|
|
100
|
+
* If true, keeps the dialog open when mouse enters it.
|
|
101
|
+
*/
|
|
102
|
+
showOnDialogEnter?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* If true, shows the dialog when the component mounts.
|
|
105
|
+
*/
|
|
106
|
+
shouldShowOnMount?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* If true, disables opening the dialog.
|
|
109
|
+
*/
|
|
110
|
+
disable?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Controls the open state of the dialog (controlled mode).
|
|
113
|
+
*/
|
|
114
|
+
open?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Controlled open state for derived state pattern.
|
|
117
|
+
*/
|
|
118
|
+
isOpen?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* CSS class names that, when present on target, prevent showing the dialog.
|
|
121
|
+
*/
|
|
122
|
+
showTriggerIgnoreClass?: string | string[];
|
|
123
|
+
/**
|
|
124
|
+
* CSS class names that, when present on target, prevent hiding the dialog.
|
|
125
|
+
*/
|
|
126
|
+
hideTriggerIgnoreClass?: string | string[];
|
|
127
|
+
/**
|
|
128
|
+
* The animation type used for the dialog.
|
|
129
|
+
*/
|
|
130
|
+
animationType?: DialogAnimationType;
|
|
131
|
+
/**
|
|
132
|
+
* Class name applied to the dialog content wrapper.
|
|
133
|
+
*/
|
|
134
|
+
wrapperClassName?: string;
|
|
135
|
+
/**
|
|
136
|
+
* If true, prevents animation when mounting.
|
|
137
|
+
*/
|
|
138
|
+
preventAnimationOnMount?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* CSS selector of the container where the dialog is portaled.
|
|
141
|
+
*/
|
|
142
|
+
containerSelector?: string;
|
|
143
|
+
/**
|
|
144
|
+
* If true, renders with tooltip arrow styling.
|
|
145
|
+
*/
|
|
146
|
+
tooltip?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Class name applied to the tooltip arrow element.
|
|
149
|
+
*/
|
|
150
|
+
tooltipClassName?: string;
|
|
151
|
+
/**
|
|
152
|
+
* Callback fired when the dialog is shown.
|
|
153
|
+
*/
|
|
154
|
+
onDialogDidShow?: (event?: DialogEvent, eventName?: DialogTriggerEvent | string) => void;
|
|
155
|
+
/**
|
|
156
|
+
* Callback fired when the dialog is hidden.
|
|
157
|
+
*/
|
|
158
|
+
onDialogDidHide?: (event: DialogEvent, eventName: DialogTriggerEvent | string) => void;
|
|
159
|
+
/**
|
|
160
|
+
* Callback fired when clicking outside the dialog.
|
|
161
|
+
*/
|
|
162
|
+
onClickOutside?: (event: React.MouseEvent) => void;
|
|
163
|
+
/**
|
|
164
|
+
* Callback fired when clicking inside the dialog content.
|
|
165
|
+
*/
|
|
166
|
+
onContentClick?: (event: React.MouseEvent) => void;
|
|
167
|
+
/**
|
|
168
|
+
* The z-index applied to the dialog.
|
|
169
|
+
*/
|
|
170
|
+
zIndex?: number;
|
|
171
|
+
/**
|
|
172
|
+
* If true, uses derived state from props pattern.
|
|
173
|
+
*/
|
|
174
|
+
useDerivedStateFromProps?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* If true, hides the dialog when the reference element scrolls out of view.
|
|
177
|
+
*/
|
|
178
|
+
hideWhenReferenceHidden?: boolean;
|
|
179
|
+
/**
|
|
180
|
+
* If true, fires onDialogDidShow callback on mount.
|
|
181
|
+
*/
|
|
182
|
+
shouldCallbackOnMount?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* If true, shows and hides the dialog without delay.
|
|
185
|
+
*/
|
|
186
|
+
instantShowAndHide?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Callback to dynamically adjust show delay and animation behavior.
|
|
189
|
+
*/
|
|
190
|
+
getDynamicShowDelay?: () => {
|
|
191
|
+
showDelay: number;
|
|
192
|
+
preventAnimation: boolean;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* The content displayed inside the dialog. Can be a render function.
|
|
196
|
+
*/
|
|
197
|
+
content?: (() => JSX.Element) | JSX.Element;
|
|
198
|
+
/**
|
|
199
|
+
* The reference element(s) that the dialog is positioned relative to.
|
|
200
|
+
*/
|
|
201
|
+
children?: ReactElement | ReactElement[] | string;
|
|
202
|
+
/**
|
|
203
|
+
* If true, keyboard focus/blur events behave like mouse enter/leave.
|
|
204
|
+
*/
|
|
205
|
+
addKeyboardHideShowTriggersByDefault?: boolean;
|
|
206
|
+
/**
|
|
207
|
+
* If true or a selector string, disables scrolling in the container when open.
|
|
208
|
+
*/
|
|
209
|
+
disableContainerScroll?: boolean | string;
|
|
210
|
+
/**
|
|
211
|
+
* If true, automatically updates position when content resizes.
|
|
212
|
+
*/
|
|
213
|
+
observeContentResize?: boolean;
|
|
214
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export declare enum DialogPlacement {
|
|
2
|
-
RIGHT = "right",
|
|
3
|
-
RIGHT_START = "right-start",
|
|
4
|
-
RIGHT_END = "right-end",
|
|
5
|
-
LEFT = "left",
|
|
6
|
-
LEFT_START = "left-start",
|
|
7
|
-
LEFT_END = "left-end"
|
|
8
|
-
}
|
|
1
|
+
export declare enum DialogPlacement {
|
|
2
|
+
RIGHT = "right",
|
|
3
|
+
RIGHT_START = "right-start",
|
|
4
|
+
RIGHT_END = "right-end",
|
|
5
|
+
LEFT = "left",
|
|
6
|
+
LEFT_START = "left-start",
|
|
7
|
+
LEFT_END = "left-end"
|
|
8
|
+
}
|